Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 0ac059d

Browse files
author
Elliott Grieco
authored
Merge pull request #8 from NYULibraries/chore/upgrade_deps_and_workflows
Chore/upgrade deps and workflows
2 parents b20f635 + 5422f79 commit 0ac059d

11 files changed

Lines changed: 677 additions & 542 deletions

File tree

.babelrc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
"targets": "last 2 versions, not dead"
55
}]
66
],
7-
"plugins": [
8-
"@babel/plugin-proposal-object-rest-spread",
9-
"transform-html-import-to-string",
10-
],
117
"env": {
128
"test": {
139
"plugins": [

.circleci/config.yml

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,59 @@ jobs:
1313
- run:
1414
name: Run unit tests
1515
command: |
16-
mkdir -p test-results
1716
docker-compose run test
18-
docker cp "$(docker ps -q -a -l -f name=test)":/app/test-results test-results
19-
- store_test_results:
20-
path: test-results
21-
17+
build-and-pack:
18+
<<: *docker-defaults
19+
steps:
20+
- checkout
21+
- setup_remote_docker
22+
- run:
23+
name: Builds package in Docker container and copies out
24+
command: |
25+
docker-compose run pack
26+
mkdir -p ./output
27+
docker cp "$(docker ps -q -a -l -f name=pack)":/app/primo-explore-google-analytics.tgz ./output/
28+
- store_artifacts:
29+
path: output
30+
publish-to-npm:
31+
docker:
32+
- image: circleci/node:lts
33+
working_directory: ~/app
34+
steps:
35+
- checkout
36+
- run:
37+
name: Authenticate with NPM
38+
command: |
39+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/app/.npmrc
40+
- run:
41+
name: Install dependencies
42+
command: |
43+
yarn install --frozen-lockfile --ignore-optional
44+
- run:
45+
name: Publish package
46+
command: |
47+
yarn publish
2248
workflows:
2349
version: 2
24-
test:
50+
test-and-build:
51+
jobs:
52+
- run-unit-tests
53+
- build-and-pack:
54+
requires:
55+
- run-unit-tests
56+
test-and-deploy:
2557
jobs:
26-
- run-unit-tests
58+
- run-unit-tests:
59+
filters:
60+
tags:
61+
only: /.*/
62+
branches:
63+
ignore: /.*/
64+
- publish-to-npm:
65+
requires:
66+
- run-unit-tests
67+
filters:
68+
tags:
69+
only: /^v.*/
70+
branches:
71+
ignore: /.*/

.eslintrc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@
66
},
77
"rules": {
88
"semi": 2,
9-
"no-unused-vars": ["warn"],
10-
"no-console": ["error", {
11-
"allow": ["warn", "error"]
12-
}]
9+
"no-unused-vars": ["warn"]
1310
},
1411
"globals": {
15-
"angular": true
12+
"__fixtures__": false,
13+
"angular": false,
14+
"module": false,
15+
"inject": false
1616
},
1717
"env": {
18-
"browser": true,
19-
"es6": true,
20-
"node": true
21-
}
18+
"jasmine": true
19+
},
20+
"plugins": [
21+
"angular"
22+
]
2223
}

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
dist/
2-
node_modules/
3-
test-results
2+
node_modules
3+
test-results
4+
*.tgz

.npmignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
src/
22
.*
3-
karma.conf.js
43
yarn-error.log
4+
*.conf*.js
5+
screenshot*
56
test-results
6-
docker-compose.yml
7+
*.log
78
Dockerfile
8-
*.config.js
9-
yarn.lock
9+
docker-compose.yml

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
FROM quay.io/nyulibraries/chromium_headless_node:10.15.1-chromium_71.0.3578.98
2-
1+
FROM quay.io/nyulibraries/chromium_headless_node:10-chromium_latest
32
ENV INSTALL_PATH /app/
43

54
# Install node_modules with yarn
6-
ADD package.json yarn.lock /tmp/
5+
ADD package.json /tmp/
76
RUN cd /tmp && yarn install --frozen-lockfile --ignore-scripts \
87
&& mkdir -p $INSTALL_PATH \
98
&& cd $INSTALL_PATH \

docker-compose.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ services:
1717
command: yarn test --browsers=ChromiumHeadless_without_sandbox --single-run=false
1818
environment:
1919
NODE_ENV: test
20-
volumes:
21-
- ./src/:/app/src/
22-
- ./karma.conf.js:/app/karma.conf.js
20+
# volumes:
21+
# - ./src/:/app/src/
22+
# - ./karma.conf.js:/app/karma.conf.js
23+
pack:
24+
build:
25+
context: .
26+
command: yarn publish-dry-run

karma.conf.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const webpack = require('webpack');
2+
const webpackConfig = require('./webpack.config');
23
process.env.CHROME_BIN = require('puppeteer').executablePath();
34

45
module.exports = function (config) {
@@ -8,7 +9,7 @@ module.exports = function (config) {
89
'spec',
910
'junit',
1011
'coverage',
11-
'coveralls'
12+
'coveralls',
1213
],
1314
browsers: ['ChromeHeadless', 'ChromiumHeadless_without_sandbox'],
1415
basePath: './',
@@ -17,6 +18,7 @@ module.exports = function (config) {
1718
require.resolve('angular-mocks/angular-mocks.js'),
1819
'src/index.js',
1920
'src/spec/**/*.spec.js',
21+
'src/spec/**/*.html',
2022
],
2123
preprocessors: {
2224
'src/index.js': ['webpack', 'sourcemap'],
@@ -25,11 +27,7 @@ module.exports = function (config) {
2527
webpack: {
2628
mode: 'development',
2729
module: {
28-
rules: [{
29-
test: /\.js$/,
30-
exclude: /node_modules/,
31-
loader: 'babel-loader',
32-
}]
30+
rules: webpackConfig.module.rules,
3331
},
3432
devtool: 'inline-source-map',
3533
externals: {
@@ -55,4 +53,4 @@ module.exports = function (config) {
5553
dir: 'test-results/coverage',
5654
},
5755
});
58-
};
56+
};

package.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "primo-explore-google-analytics",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Google Analytics for Primo NUI packages",
55
"main": "./dist/index.js",
66
"scripts": {
77
"test": "NODE_ENV=test yarn karma start --browsers=ChromeHeadless --single-run",
88
"test:chrome-debugger": "yarn karma start --browsers=Chrome --single-run=false --debug",
9-
"build": "yarn webpack --mode=production",
10-
"prepare": "yarn rimraf dist/* && yarn build"
9+
"build": "webpack --mode=production",
10+
"prepare": "rimraf dist/* && yarn build",
11+
"publish-dry-run": "yarn prepare && yarn pack --filename primo-explore-google-analytics.tgz"
1112
},
1213
"repository": {
1314
"type": "git",
@@ -23,15 +24,12 @@
2324
},
2425
"homepage": "https://github.com/NYULibraries/primo-explore-google-analytics#readme",
2526
"devDependencies": {
26-
"@babel/cli": "^7.2.3",
27-
"@babel/core": "^7.4.0",
28-
"@babel/plugin-proposal-object-rest-spread": "^7.4.0",
29-
"@babel/preset-env": "^7.4.0",
27+
"@babel/core": "7.5.0",
28+
"@babel/preset-env": "7.5.0",
3029
"angular": "^1.7.8",
3130
"angular-mocks": "^1.7.8",
3231
"babel-loader": "^8.0.5",
3332
"babel-plugin-istanbul": "^5.1.1",
34-
"babel-plugin-transform-html-import-to-string": "^0.0.1",
3533
"jasmine-core": "^3.3.0",
3634
"karma": "^4.0.1",
3735
"karma-chrome-launcher": "^2.2.0",
@@ -41,12 +39,12 @@
4139
"karma-junit-reporter": "^1.2.0",
4240
"karma-sourcemap-loader": "^0.3.7",
4341
"karma-spec-reporter": "^0.0.32",
44-
"karma-webpack": "^4.0.0-rc.6",
42+
"karma-webpack": "^4.0.2",
4543
"puppeteer": "^1.13.0",
44+
"raw-loader": "^3.1.0",
4645
"rimraf": "^2.6.3",
4746
"webpack": "^4.29.6",
48-
"webpack-cli": "^3.2.3",
49-
"webpack-merge": "^4.2.1"
47+
"webpack-cli": "^3.2.3"
5048
},
5149
"dependencies": {
5250
"angulartics": "^1.6.0",

webpack.config.js

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,32 @@
11
const path = require('path');
2-
const merge = require('webpack-merge');
32

4-
const commonConfig = {
3+
const webpackConfig = {
54
entry: {
65
index: path.resolve(__dirname, 'src/index.js'),
76
},
87
module: {
98
rules: [{
10-
test: /\js$/,
11-
loader: 'babel-loader'
12-
}]
9+
test: /\.js$/,
10+
loader: 'babel-loader',
11+
exclude: /node_modules/
12+
},
13+
{
14+
test: /\.html$/,
15+
loader: 'raw-loader',
16+
exclude: /node_modules/,
17+
}
18+
]
1319
},
1420
devtool: 'sourcemap',
15-
};
16-
17-
const webConfig = {
18-
target: 'web',
19-
output: {
20-
filename: 'primoExploreGoogleAnalytics.min.js',
21-
library: 'primoExploreGoogleAnalytics',
22-
libraryTarget: 'var',
23-
},
24-
};
25-
26-
const nodeConfig = {
27-
target: 'node',
2821
output: {
22+
path: path.resolve(__dirname, 'dist'),
23+
filename: 'index.js',
2924
library: 'primoExploreGoogleAnalytics',
25+
libraryTarget: 'umd',
26+
libraryExport: 'default',
27+
// see: https://github.com/webpack/webpack/issues/6522
28+
globalObject: 'typeof self !== \'undefined\' ? self : this'
3029
},
31-
optimization: {
32-
minimize: false,
33-
}
3430
};
3531

36-
module.exports = [
37-
merge.smart(
38-
commonConfig,
39-
webConfig,
40-
),
41-
merge.smart(
42-
commonConfig,
43-
nodeConfig
44-
),
45-
];
32+
module.exports = webpackConfig;

0 commit comments

Comments
 (0)