Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Commit

Permalink
Update template files and dependencies (#18)
Browse files Browse the repository at this point in the history
Update template files and dependencies
  • Loading branch information
Holger Stitz authored Dec 18, 2019
2 parents feff500 + 722c55c commit e638f1c
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 107 deletions.
60 changes: 44 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,82 @@ jobs:
build:
working_directory: ~/phovea
docker:
- image: caleydo/phovea_circleci_python:v2.0
- image: caleydo/phovea_circleci_python:v3.0
steps:
- checkout
- run:
name: Show Node.js and npm version
command: |
node -v
npm -v
- run:
name: Show Python and pip version
command: |
python --version
pip --version
- run:
name: Install Docker packages from docker_packages.txt
command: |
(!(test -f docker_packages.txt) || (cat docker_packages.txt | xargs sudo apt-get install -y))
- restore_cache:
key: deps1-{{ checksum "package.json" }}
key: deps2-{{ .Branch }}-{{ checksum "package.json" }}
- run:
name: install-npm-wee
name: Install npm dependencies
command: npm install
- run: #remove all resolved github dependencies
name: delete-vcs-dependencies
- 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-{{ checksum "package.json" }}
key: deps2-{{ .Branch }}-{{ checksum "package.json" }}
paths:
- ./node_modules
- run: #install all dependencies
name: install-npm-wee2
- 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
- restore_cache:
key: deps1-{{ checksum "requirements.txt" }}-{{ checksum "requirements_dev.txt" }}
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_dev.txt" }}
- run:
name: install-pip-wee
name: Install pip requirements
command: |
virtualenv ~/venv
. ~/venv/bin/activate
pip install -r requirements_dev.txt
pip install -r requirements.txt
- save_cache:
key: deps1-{{ checksum "requirements.txt" }}-{{ checksum "requirements_dev.txt" }}
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_dev.txt" }}
paths:
- ~/venv
- run: #force update of VCS dependencies?
name: update-pip-vcs-dependencies
- run:
name: Force an update of pip dependencies from git repositories # not sure if this is working ?
command: |
. ~/venv/bin/activate
pip install --upgrade --upgrade-strategy=only-if-needed -r requirements.txt
- run:
name: build
name: Show installed pip packages
command: pip list || true
- run:
name: Build
command: |
. ~/venv/bin/activate
npm run build
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:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ node_modules/
/tests/**/*.js
*.map
*.css
/.cache-loader
8 changes: 7 additions & 1 deletion .yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
"libraryExternals": [],
"entries": "./index.js",
"ignores": [],
"today": "Sun, 06 Nov 2016 22:40:46 GMT"
"today": "Sun, 06 Nov 2016 22:40:46 GMT",
"promptValues": {
"authorName": "The Caleydo Team",
"authorEmail": "contact@caleydo.org",
"authorUrl": "https://caleydo.org",
"githubAccount": "caleydo"
}
}
}
8 changes: 5 additions & 3 deletions buildInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ 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 = [];
let r;
while ((r = regex.exec(reg)) !== null) {
Expand All @@ -56,7 +56,7 @@ function resolveWorkspace() {
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 {
Expand Down Expand Up @@ -139,16 +139,18 @@ function resolveScreenshot() {
if (!fs.existsSync(f)) {
return null;
}
const buffer = new Buffer(fs.readFileSync(f)).toString('base64');
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()
};
Expand Down
69 changes: 69 additions & 0 deletions buildPython.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Created by sam on 13.11.2016.
*/

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

function gitHead(cwd) {
const r = spawnSync('git', ['rev-parse', '--verify', 'HEAD'], {
cwd: cwd
});
if (!r.stdout) {
console.error(cwd, r.error);
return 'error';
}
return r.stdout.toString().trim();
}

function resolvePlugin(repo, version) {
if (fs.lstatSync('.git').isDirectory() && repo) {
if (repo.endsWith('.git')) {
repo = repo.slice(0, repo.length - 4);
return repo + '/commit/' + gitHead('.');
}
}
// not a git repo
return version;
}

function toVersion(v) {
const now = new Date().toISOString();
// %Y%m%d-%H%M%S
const fmt = now
.replace(/T/, ' ')
.replace(/\..+/, '')
.replace(/[-:]/, '')
.replace(' ', '-');
return v.replace('SNAPSHOT', fmt);
}

function _main() {
const pkg = require('./package.json');
const name = pkg.name;
const version = toVersion(pkg.version);
const resolved = resolvePlugin((pkg.repository || {}).url, version);

const buildInfo = {
name,
version,
resolved,
description: pkg.description,
homepage: pkg.homepage,
repository: (pkg.repository || {}).url
};

const l = ('build/source/' + name.toLowerCase()).split('/');
l.forEach((_, i) => {
const path = l.slice(0, i + 1).join('/');
if (!fs.existsSync(path)) {
fs.mkdirSync(path);
}
});

fs.writeFileSync('build/source/' + name.toLowerCase() + '/buildInfo.json', JSON.stringify(buildInfo, null, ' '));
}

if (require.main === module) {
_main();
}
1 change: 1 addition & 0 deletions deploy/docker-compose.partial.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version: '2.0'
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
},
"main": "build/tdp_dummy.js",
"engines": {
"npm": ">= 3",
"node": ">= 6",
"npm": ">= 6.12",
"node": ">= 12.13",
"iojs": ">= 3"
},
"files": [
Expand All @@ -43,7 +43,7 @@
"predist": "echo hybrid",
"dist": "npm run dist:web && npm run dist:python",
"compile": "tsc",
"lint": "tslint -c tslint.json -p .",
"lint": "tslint -c tslint.json -p . 'src/**/*.ts?(x)' 'tests/**/*.ts?(x)'",
"docs": "npm run docs:web && npm run docs:python",
"prebuild": "echo hybrid",
"posttest": "echo hybrid",
Expand All @@ -63,10 +63,10 @@
"test:python": "test ! $(find tests -name \"*.py\") || python setup.py test",
"predist:web": "npm run build:web && npm run docs:web",
"dist:web": "mkdirp dist && cd build && tar cvzf ../dist/tdp_dummy.tar.gz *",
"dist:python": "python setup.py bdist_egg",
"dist:python": "python setup.py sdist bdist_wheel",
"docs:web": "typedoc --options typedoc.json src/**.ts",
"docs:python": "sphinx-apidoc -o docs -f ./tdp_dummy && sphinx-build ./docs build/docs",
"build:python": "python build.py",
"build:python": "rm -rf build/source && find . -name '*.pyc' -delete && node buildPython.js && cp -r ./tdp_dummy build/source/",
"build:web": "webpack --env prod",
"prebuild:python": "node -e \"process.exit(process.env.PHOVEA_SKIP_TESTS === undefined?1:0)\" || npm run test:python",
"prebuild:web": "node -e \"process.exit(process.env.PHOVEA_SKIP_TESTS === undefined?1:0)\" || npm run test:web",
Expand All @@ -82,10 +82,13 @@
"devDependencies": {
"@types/jasmine": "2.5.47",
"awesome-typescript-loader": "3.1.2",
"cache-loader": "1.2.0",
"css-loader": "0.28.0",
"extract-loader": "0.1.0",
"extract-text-webpack-plugin": "2.1.0",
"extract-loader": "0.1.0",
"ifdef-loader": "2.0.0",
"file-loader": "0.11.1",
"fork-ts-checker-webpack-plugin": "0.4.1",
"html-loader": "0.4.5",
"imports-loader": "0.7.1",
"jasmine": "2.5.3",
Expand All @@ -103,17 +106,14 @@
"raw-loader": "0.5.1",
"sass-loader": "6.0.7",
"style-loader": "0.16.1",
"thread-loader": "1.1.2",
"ts-loader": "4.0.1",
"tslib": "1.9.0",
"tslint": "5.9.1",
"typedoc": "0.11.1",
"typescript": "2.7.2",
"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"
"webpack-dev-server": "2.4.2"
}
}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-e git+https://github.com/datavisyn/tdp_core.git@develop#egg=tdp_core
-e git+https://github.com/datavisyn/tdp_core.git@develop#egg=tdp_core
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ def to_version(v):
now = datetime.datetime.utcnow()
return v.replace('SNAPSHOT', now.strftime('%Y%m%d-%H%M%S'))


setup(
name=pkg['name'],
name=pkg['name'].lower(),
version=to_version(pkg['version']),
url=pkg['homepage'],
description=pkg['description'],
long_description=read_it('README.md'),
long_description_content_type='text/markdown',
keywords=pkg.get('keywords', ''),
author=pkg['author']['name'],
author_email=pkg['author']['email'],
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
],
"baseUrl": "../",
"noImplicitAny": false,
"skipLibCheck": true
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true
},
"include": [
"src/**/*.ts",
Expand Down
42 changes: 27 additions & 15 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"forin": true,
"indent": [
true,
"spaces",
2
],
"interface-name": true,
Expand All @@ -31,9 +32,25 @@
"max-line-length": false,
"member-ordering": [
false,
"public-before-private",
"static-before-instance",
"variables-before-functions"
{
"order": [
"public-static-field",
"public-static-method",
"public-instance-field",
"public-constructor",
"public-instance-method",
"protected-static-field",
"protected-static-method",
"protected-instance-field",
"protected-constructor",
"protected-instance-method",
"private-static-field",
"private-static-method",
"private-instance-field",
"private-constructor",
"private-instance-method"
]
}
],
"new-parens": true,
"no-arg": true,
Expand Down Expand Up @@ -96,18 +113,13 @@
],
"typedef-whitespace": [
true,
[
"callSignature",
"noSpace"
],
[
"catchClause",
"noSpace"
],
[
"indexSignature",
"space"
]
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"use-isnan": true,
"variable-name": [
Expand Down
Loading

0 comments on commit e638f1c

Please sign in to comment.