Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Update project config + CI configs with Node 12 (#73)
Browse files Browse the repository at this point in the history
Update project config + CI configs with Node 12
  • Loading branch information
thinkh authored Dec 12, 2019
2 parents ab2e22a + 49a350c commit 5d2fc6b
Show file tree
Hide file tree
Showing 16 changed files with 384 additions and 154 deletions.
63 changes: 63 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: 2
jobs:
build:
working_directory: ~/phovea
docker:
- image: circleci/node:12-browsers
steps:
- checkout
- run:
name: Show Node.js and npm version
command: |
node -v
npm -v
- restore_cache:
key: deps1-{{ .Branch }}-{{ checksum "package.json" }}
- run:
name: Install npm dependencies
command: npm install
- run:
name: Remove npm dependencies installed from git repositories (avoid caching of old commits)
command: |
(grep -l '._resolved.: .\(git[^:]*\|bitbucket\):' ./node_modules/*/package.json || true) | xargs -r dirname | xargs -r rm -rf
- save_cache:
key: deps1-{{ .Branch }}-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: Install npm dependencies from git repositories (always get latest commit)
command: npm install
- run:
name: Show installed npm dependencies
command: npm list --depth=1 || true
- run:
name: Build
command: npm run dist
- store_artifacts:
path: dist
workflows:
version: 2
# build-nightly:
# triggers:
# - schedule:
# cron: "15 1 * * 1-5" # "At 01:15 on every day-of-week from Monday through Friday.”, see: https://crontab.guru/#15_1_*_*_1-5
# filters:
# branches:
# only:
# - develop
# jobs:
# - build
build-branch:
jobs:
- build:
filters:
tags:
ignore: /^v.*/
build-tag:
jobs:
- build:
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ node_modules/
*.map
*.css
*.log
/.cache-loader
46 changes: 46 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
image: circleci/node:12-browsers

variables:
GIT_DEPTH: "1"

cache:
key: "$CI_REPOSITORY_URL-$CI_COMMIT_REF_NAME"
paths:
- node_modules

before_script:
# Install ssh-agent if not already installed, it is required by Docker.
# (change apt-get to yum if you use a CentOS-based image)
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'

# Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)

# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
- ssh-add <(echo "$SSH_PRIVATE_KEY")

# For Docker builds disable host key checking. Be aware that by adding that
# you are suspectible to man-in-the-middle attacks.
# WARNING: Use this only with the Docker executor, if you use it with shell
# you will overwrite your user's SSH config.
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

stages:
- install
- build

install-npm-wee:
stage: install
script:
- npm install

dist:
stage: build
script:
- npm run dist
allow_failure: false
artifacts:
expire_in: 1 week
paths:
- dist
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
language: node_js
node_js:
- 6
- 12
addons:
firefox: 49.0.1
services:
- xvfb
before_install:
- export DISPLAY=:99.0
- if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi
- sh -e /etc/init.d/xvfb start
- if [[ `npm -v` != 6* ]]; then npm i -g npm@6; fi
script: npm run dist
notifications:
slack:
Expand Down
8 changes: 7 additions & 1 deletion .yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@
"today": "Thu, 03 Nov 2016 13:55:14 GMT",
"libraryExternals": [
"d3"
]
],
"promptValues": {
"authorName": "The Caleydo Team",
"authorEmail": "contact@caleydo.org",
"authorUrl": "https://caleydo.org",
"githubAccount": "phovea"
}
}
}
56 changes: 40 additions & 16 deletions buildInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
* Created by sam on 13.11.2016.
*/


const spawnSync = require('child_process').spawnSync;
const path = require('path');
const resolve = path.resolve;
const fs = require('fs');


function dependencyGraph(cwd) {
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
const r = spawnSync(npm, ['ls', '--prod', '--json'], {
Expand Down Expand Up @@ -37,9 +35,9 @@ function gitHead(cwd) {

function resolveModules() {
const reg = fs.readFileSync('../phovea_registry.js').toString();
const regex = /import '(.*)\/phovea_registry.js'/g;
const regex = /^import '(.*)\/phovea_registry.js'/gm;
const modules = [];
var r;
let r;
while ((r = regex.exec(reg)) !== null) {
modules.push(r[1]);
}
Expand All @@ -55,19 +53,20 @@ function resolveWorkspace() {
const workspaceDeps = dependencyGraph('..').dependencies;
const modules = new Set(resolveModules());

let deps = null;
const resolveModule = (m) => {
console.log('resolve', m);
const pkg = require(`../${m}/package.json`);
const pkg = JSON.parse(fs.readFileSync(`../${m}/package.json`).toString());
const head = gitHead('../' + m);
const repo = pkg.repository.url;
return {
name: pkg.name,
version: pkg.version,
resolved: head ? `${repo.endsWith('.git') ? repo.slice(0, repo.length-4) : repo}/commit/${head}` : pkg.version,
resolved: head ? `${repo.endsWith('.git') ? repo.slice(0, repo.length - 4) : repo}/commit/${head}` : pkg.version,
dependencies: deps(pkg.dependencies)
};
};
const deps = (deps) => {
deps = (deps) => {
const r = {};
Object.keys(deps).forEach((d) => {
if (d in workspaceDeps) {
Expand Down Expand Up @@ -121,31 +120,56 @@ function generate() {
const isWorkspaceContext = fs.existsSync('../phovea_registry.js');
if (isWorkspaceContext) {
return resolveWorkspace();
} else {
return resolveSingle();
}
return resolveSingle();
}


const IS_WINDOWS = process.platform === 'win32';

function tmpdir() {
if (IS_WINDOWS) {
return process.env.TEMP || process.env.TMP ||
(process.env.SystemRoot || process.env.windir) + '\\temp';
} else {
return process.env.TMPDIR || process.env.TMP || process.env.TEMP || '/tmp';
(process.env.SystemRoot || process.env.windir) + '\\temp';
}
return process.env.TMPDIR || process.env.TMP || process.env.TEMP || '/tmp';
}

function resolveScreenshot() {
const f = resolve(__dirname, 'media/screenshot.png');
if (!fs.existsSync(f)) {
return null;
}
const buffer = Buffer.from(fs.readFileSync(f)).toString('base64');
return `data:image/png;base64,${buffer}`;
}

function metaData(pkg) {
pkg = pkg || require(`./package.json`);
return {
name: pkg.name,
displayName: pkg.displayName,
version: pkg.version,
repository: pkg.repository.url,
homepage: pkg.homepage,
description: pkg.description,
screenshot: resolveScreenshot()
};
}

module.exports.metaData = metaData;
module.exports.metaDataTmpFile = function (pkg) {
const s = metaData(pkg);
const file = `${tmpdir()}/metaData${Math.random().toString(36).slice(-8)}.txt`;
fs.writeFileSync(file, JSON.stringify(s, null, ' '));
return file;
};
module.exports.generate = generate;
module.exports.tmpFile = function() {
module.exports.tmpFile = function () {
const s = generate();
const file = `${tmpdir()}/buildInfo${Math.random().toString(36).slice(-8)}.txt`;
fs.writeFileSync(file, JSON.stringify(s, null, ' '));
return file;
}

};

if (require.main === module) {
fs.writeFile('deps.json', JSON.stringify(generate(), null, ' '));
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* generates and object that contain all modules in the src folder accessible as properties
*/

/***
/**
* magic file name for the pseudo root file
* @type {string}
*/
Expand All @@ -28,19 +28,19 @@ function byName(a, b) {
}
return a.toLowerCase().localeCompare(b.toLowerCase());
}
//list all modules in the src folder excluding the one starting with _
// list all modules in the src folder excluding the one starting with _
var req = require.context('./src', true, /^\.\/(?!internal)(([^_][\w]+)|(\w+\/index))\.tsx?$/);

var files = req.keys().sort(byName);

//root file exists? else use anonymous root object
// root file exists? else use anonymous root object
if (files[0] === INDEX_FILE) {
module.exports = req(files.shift());
} else {
module.exports = {};
}

//generate getter for all modules
// generate getter for all modules
files.forEach(function (f) {
Object.defineProperty(module.exports, f.substring(2, f.lastIndexOf('/index.') > 0 ? f.lastIndexOf('/index.') : f.lastIndexOf('.')), {
get: function () {
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = (config) => {

// list of files / patterns to load in the browser
files: [
'tests.webpack.js' //just load this file
'tests.webpack.js' // just load this file
],

// preprocess matching files before serving them to the browser
Expand Down
58 changes: 31 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
"build"
],
"engines": {
"npm": ">= 3",
"node": ">= 6",
"iojs": ">= 3"
"npm": ">= 6.12",
"node": ">= 12.13"
},
"scripts": {
"compile": "tsc",
"lint": "tslint -c tslint.json src/**.ts tests/**.ts",
"docs": "typedoc --options typedoc.json src/**.ts",
"lint": "tslint -c tslint.json -p . 'src/**/*.ts?(x)' 'tests/**/*.ts?(x)'",
"docs": "typedoc --options typedoc.json src/",
"prebuild": "node -e \"process.exit(process.env.PHOVEA_SKIP_TESTS === undefined?1:0)\" || npm run test",
"pretest": "npm run compile",
"test": "test ! -d tests || karma start",
Expand All @@ -52,39 +51,44 @@
"dependencies": {
"phovea_core": "github:phovea/phovea_core#develop",
"phovea_d3": "github:phovea/phovea_d3#develop",
"@types/d3": "3.5.36",
"d3": "3.5.17"
"@types/d3": "~3.5.36",
"d3": "~3.5.17"
},
"devDependencies": {
"@types/jasmine": "2.5.41",
"awesome-typescript-loader": "3.0.3",
"css-loader": "0.26.1",
"extract-text-webpack-plugin": "2.0.0-rc.3",
"file-loader": "0.10.0",
"html-loader": "0.4.4",
"imports-loader": "0.7.0",
"@types/jasmine": "2.5.47",
"awesome-typescript-loader": "3.1.2",
"css-loader": "0.28.0",
"extract-loader": "0.1.0",
"extract-text-webpack-plugin": "2.1.0",
"file-loader": "0.11.1",
"html-loader": "0.4.5",
"imports-loader": "0.7.1",
"jasmine": "2.5.3",
"json-loader": "0.5.4",
"karma": "1.4.0",
"karma": "1.5.0",
"karma-chrome-launcher": "2.0.0",
"karma-firefox-launcher": "1.0.0",
"karma-firefox-launcher": "1.0.1",
"karma-jasmine": "1.1.0",
"karma-junit-reporter": "2.0.0",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "2.0.2",
"karma-webpack": "2.0.3",
"mkdirp": "0.5.1",
"node-sass": "^4.12.0",
"null-loader": "0.1.1",
"raw-loader": "0.5.1",
"sass-loader": "5.0.0",
"style-loader": "0.13.1",
"tslib": "1.5.0",
"tslint": "4.4.2",
"typedoc": "0.5.5",
"typescript": "2.2.0",
"url-loader": "0.5.7",
"webpack": "2.2.1",
"webpack-dev-server": "2.3.0",
"extract-loader": "0.1.0"
"sass-loader": "6.0.7",
"style-loader": "0.16.1",
"tslib": "1.9.0",
"tslint": "5.9.1",
"typedoc": "0.11.1",
"typescript": "2.8.1",
"url-loader": "0.5.8",
"webpack": "2.3.3",
"webpack-dev-server": "2.4.2",
"cache-loader": "1.2.0",
"ifdef-loader": "2.0.0",
"fork-ts-checker-webpack-plugin": "0.4.1",
"thread-loader": "1.1.2",
"ts-loader": "4.0.1"
}
}
Loading

0 comments on commit 5d2fc6b

Please sign in to comment.