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

Commit

Permalink
Merge pull request #8 from NYULibraries/chore/upgrade_deps_and_workflows
Browse files Browse the repository at this point in the history
Chore/upgrade deps and workflows
  • Loading branch information
Elliott Grieco authored Jul 31, 2019
2 parents b20f635 + 5422f79 commit 0ac059d
Show file tree
Hide file tree
Showing 11 changed files with 677 additions and 542 deletions.
4 changes: 0 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"targets": "last 2 versions, not dead"
}]
],
"plugins": [
"@babel/plugin-proposal-object-rest-spread",
"transform-html-import-to-string",
],
"env": {
"test": {
"plugins": [
Expand Down
59 changes: 52 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,59 @@ jobs:
- run:
name: Run unit tests
command: |
mkdir -p test-results
docker-compose run test
docker cp "$(docker ps -q -a -l -f name=test)":/app/test-results test-results
- store_test_results:
path: test-results

build-and-pack:
<<: *docker-defaults
steps:
- checkout
- setup_remote_docker
- run:
name: Builds package in Docker container and copies out
command: |
docker-compose run pack
mkdir -p ./output
docker cp "$(docker ps -q -a -l -f name=pack)":/app/primo-explore-google-analytics.tgz ./output/
- store_artifacts:
path: output
publish-to-npm:
docker:
- image: circleci/node:lts
working_directory: ~/app
steps:
- checkout
- run:
name: Authenticate with NPM
command: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/app/.npmrc
- run:
name: Install dependencies
command: |
yarn install --frozen-lockfile --ignore-optional
- run:
name: Publish package
command: |
yarn publish
workflows:
version: 2
test:
test-and-build:
jobs:
- run-unit-tests
- build-and-pack:
requires:
- run-unit-tests
test-and-deploy:
jobs:
- run-unit-tests
- run-unit-tests:
filters:
tags:
only: /.*/
branches:
ignore: /.*/
- publish-to-npm:
requires:
- run-unit-tests
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
19 changes: 10 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
},
"rules": {
"semi": 2,
"no-unused-vars": ["warn"],
"no-console": ["error", {
"allow": ["warn", "error"]
}]
"no-unused-vars": ["warn"]
},
"globals": {
"angular": true
"__fixtures__": false,
"angular": false,
"module": false,
"inject": false
},
"env": {
"browser": true,
"es6": true,
"node": true
}
"jasmine": true
},
"plugins": [
"angular"
]
}
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
node_modules/
test-results
node_modules
test-results
*.tgz
8 changes: 4 additions & 4 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
src/
.*
karma.conf.js
yarn-error.log
*.conf*.js
screenshot*
test-results
docker-compose.yml
*.log
Dockerfile
*.config.js
yarn.lock
docker-compose.yml
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
FROM quay.io/nyulibraries/chromium_headless_node:10.15.1-chromium_71.0.3578.98

FROM quay.io/nyulibraries/chromium_headless_node:10-chromium_latest
ENV INSTALL_PATH /app/

# Install node_modules with yarn
ADD package.json yarn.lock /tmp/
ADD package.json /tmp/
RUN cd /tmp && yarn install --frozen-lockfile --ignore-scripts \
&& mkdir -p $INSTALL_PATH \
&& cd $INSTALL_PATH \
Expand Down
10 changes: 7 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ services:
command: yarn test --browsers=ChromiumHeadless_without_sandbox --single-run=false
environment:
NODE_ENV: test
volumes:
- ./src/:/app/src/
- ./karma.conf.js:/app/karma.conf.js
# volumes:
# - ./src/:/app/src/
# - ./karma.conf.js:/app/karma.conf.js
pack:
build:
context: .
command: yarn publish-dry-run
12 changes: 5 additions & 7 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const webpack = require('webpack');
const webpackConfig = require('./webpack.config');
process.env.CHROME_BIN = require('puppeteer').executablePath();

module.exports = function (config) {
Expand All @@ -8,7 +9,7 @@ module.exports = function (config) {
'spec',
'junit',
'coverage',
'coveralls'
'coveralls',
],
browsers: ['ChromeHeadless', 'ChromiumHeadless_without_sandbox'],
basePath: './',
Expand All @@ -17,6 +18,7 @@ module.exports = function (config) {
require.resolve('angular-mocks/angular-mocks.js'),
'src/index.js',
'src/spec/**/*.spec.js',
'src/spec/**/*.html',
],
preprocessors: {
'src/index.js': ['webpack', 'sourcemap'],
Expand All @@ -25,11 +27,7 @@ module.exports = function (config) {
webpack: {
mode: 'development',
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
}]
rules: webpackConfig.module.rules,
},
devtool: 'inline-source-map',
externals: {
Expand All @@ -55,4 +53,4 @@ module.exports = function (config) {
dir: 'test-results/coverage',
},
});
};
};
20 changes: 9 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "primo-explore-google-analytics",
"version": "1.1.0",
"version": "1.1.1",
"description": "Google Analytics for Primo NUI packages",
"main": "./dist/index.js",
"scripts": {
"test": "NODE_ENV=test yarn karma start --browsers=ChromeHeadless --single-run",
"test:chrome-debugger": "yarn karma start --browsers=Chrome --single-run=false --debug",
"build": "yarn webpack --mode=production",
"prepare": "yarn rimraf dist/* && yarn build"
"build": "webpack --mode=production",
"prepare": "rimraf dist/* && yarn build",
"publish-dry-run": "yarn prepare && yarn pack --filename primo-explore-google-analytics.tgz"
},
"repository": {
"type": "git",
Expand All @@ -23,15 +24,12 @@
},
"homepage": "https://github.com/NYULibraries/primo-explore-google-analytics#readme",
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.4.0",
"@babel/plugin-proposal-object-rest-spread": "^7.4.0",
"@babel/preset-env": "^7.4.0",
"@babel/core": "7.5.0",
"@babel/preset-env": "7.5.0",
"angular": "^1.7.8",
"angular-mocks": "^1.7.8",
"babel-loader": "^8.0.5",
"babel-plugin-istanbul": "^5.1.1",
"babel-plugin-transform-html-import-to-string": "^0.0.1",
"jasmine-core": "^3.3.0",
"karma": "^4.0.1",
"karma-chrome-launcher": "^2.2.0",
Expand All @@ -41,12 +39,12 @@
"karma-junit-reporter": "^1.2.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "^0.0.32",
"karma-webpack": "^4.0.0-rc.6",
"karma-webpack": "^4.0.2",
"puppeteer": "^1.13.0",
"raw-loader": "^3.1.0",
"rimraf": "^2.6.3",
"webpack": "^4.29.6",
"webpack-cli": "^3.2.3",
"webpack-merge": "^4.2.1"
"webpack-cli": "^3.2.3"
},
"dependencies": {
"angulartics": "^1.6.0",
Expand Down
49 changes: 18 additions & 31 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,32 @@
const path = require('path');
const merge = require('webpack-merge');

const commonConfig = {
const webpackConfig = {
entry: {
index: path.resolve(__dirname, 'src/index.js'),
},
module: {
rules: [{
test: /\js$/,
loader: 'babel-loader'
}]
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.html$/,
loader: 'raw-loader',
exclude: /node_modules/,
}
]
},
devtool: 'sourcemap',
};

const webConfig = {
target: 'web',
output: {
filename: 'primoExploreGoogleAnalytics.min.js',
library: 'primoExploreGoogleAnalytics',
libraryTarget: 'var',
},
};

const nodeConfig = {
target: 'node',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',
library: 'primoExploreGoogleAnalytics',
libraryTarget: 'umd',
libraryExport: 'default',
// see: https://github.com/webpack/webpack/issues/6522
globalObject: 'typeof self !== \'undefined\' ? self : this'
},
optimization: {
minimize: false,
}
};

module.exports = [
merge.smart(
commonConfig,
webConfig,
),
merge.smart(
commonConfig,
nodeConfig
),
];
module.exports = webpackConfig;
Loading

0 comments on commit 0ac059d

Please sign in to comment.