-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from phovea/release-1.1.0
Release 1.1.0
- Loading branch information
Showing
17 changed files
with
542 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
image: circleci/node:6-browsers | ||
image: circleci/node:8-browsers | ||
|
||
variables: | ||
GIT_DEPTH: "1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
'use strict'; | ||
const Base = require('yeoman-generator').Base; | ||
const chalk = require('chalk'); | ||
const { | ||
simplifyRepoUrl | ||
} = require('../../utils/repo'); | ||
const version = require('../../utils/version'); | ||
|
||
function failed(spawnResult) { | ||
return spawnResult.status !== 0; | ||
} | ||
|
||
/** | ||
* Clone a given repository and supports version ranges for git tags. | ||
* @see https://docs.npmjs.com/misc/semver#advanced-range-syntax | ||
*/ | ||
class Generator extends Base { | ||
|
||
constructor(args, options) { | ||
super(args, options); | ||
|
||
this.argument('repository', { | ||
alias: 'r', | ||
defaults: '', | ||
type: String, | ||
required: true | ||
}); | ||
|
||
// Note for Windows Powershell | ||
// Using caret version range like `-b '^v2.0.0'` does not work! | ||
// Instead you must escape the caret sign as explained in | ||
// https://stackoverflow.com/a/5254713/940219 | ||
// Correct version: `-b '^^^^v2.0.0'` | ||
this.option('branch', { | ||
alias: 'b', | ||
defaults: 'master', | ||
required: false, | ||
type: String | ||
}); | ||
|
||
// Note for Windows Powershell | ||
// Using `-e '--depth 1'` does not work! | ||
// Instead add an additional space at the beginning | ||
// to the argument value: `-e ' --depth 1'` | ||
this.option('extras', { | ||
alias: 'e', | ||
defaults: '', | ||
type: String | ||
}); | ||
|
||
// no prompt implemented | ||
this.option('cwd', { | ||
defaults: '', | ||
type: String | ||
}); | ||
|
||
// no prompt implemented | ||
this.option('dir', { | ||
alias: 'd', | ||
defaults: '', | ||
type: String | ||
}); | ||
} | ||
|
||
prompting() { | ||
return this.prompt([{ | ||
type: 'input', | ||
name: 'repository', | ||
message: 'Repository URL', | ||
required: true, | ||
default: this.args.length > 0 ? this.args[0] : undefined, | ||
when: this.args.length === 0, | ||
validate: (d) => d.length > 0 | ||
}, { | ||
type: 'input', | ||
name: 'branch', | ||
message: 'Git branch or tag', | ||
required: true, | ||
default: this.options.branch, | ||
when: this.options.branch === '', | ||
validate: (d) => d.length > 0 | ||
}, { | ||
type: 'input', | ||
name: 'extras', | ||
message: 'Additional git clone parameters', | ||
required: false, | ||
default: this.options.extras || undefined, | ||
when: this.options.extras === undefined | ||
}]).then((props) => { | ||
this.cwd = this.options.cwd || undefined; | ||
this.cloneDirName = (this.options.dir === '') ? this.options.dir : ` ${this.options.dir}`; // add space at the beginning | ||
this.options.repository = props.repository || this.args[0]; | ||
this.options.branch = props.branch || this.options.branch; | ||
this.options.extras = props.extras || this.options.extras; | ||
this.options.extras = (this.options.extras === '') ? this.options.extras : ` ${this.options.extras}`; // add space at the beginning | ||
}); | ||
} | ||
|
||
writing() { | ||
return this._cloneRepo(this.options.repository, this.options.branch, this.options.extras, this.cloneDirName); | ||
} | ||
|
||
_cloneRepo(repoUrl, branch, extras, cloneDirName) { | ||
if (!version.isGitCommit(branch)) { | ||
// modify branch name, if it is an advance version tag | ||
// otherwise just use the branch name as it is | ||
if (version.isAdvancedVersionTag(branch)) { | ||
this.log(chalk.white(`found branch with version range`), chalk.green(branch), chalk.white(`for`), chalk.green(repoUrl)); | ||
|
||
const line = `ls-remote --tags ${repoUrl}`; | ||
this.log(chalk.white(`fetching possible version tags:`), `git ${line}`); | ||
const r = this._spawn('git', line.split(/ +/)); | ||
|
||
if (failed(r)) { | ||
this.log(chalk.red(`failed to fetch list of tags from git repository`), `status code: ${r.status}`); | ||
this.log(r.stderr.toString()); | ||
return this._abort(`failed to fetch list of tags from git repository - status code: ${r.status}`); | ||
} | ||
|
||
const gitLog = r.stdout.toString(); | ||
const gitVersions = version.extractVersionsFromGitLog(gitLog); | ||
this.log(chalk.white(`found the following version tags: `), gitVersions); | ||
|
||
const highestVersion = version.findHighestVersion(gitVersions, branch); | ||
if (!highestVersion) { | ||
this.log(chalk.red(`failed to find git version tag for given version range`)); | ||
return this._abort(`failed to find git version tag for given version range`); | ||
} | ||
|
||
this.log(chalk.white(`use version tag`), chalk.green(highestVersion), chalk.white(`as branch name`)); | ||
branch = highestVersion; | ||
} | ||
|
||
const line = `clone -b ${branch}${extras || ''} ${repoUrl}${cloneDirName}`; | ||
this.log(chalk.white(`clone repository:`), `git ${line}`); | ||
return this._spawnOrAbort('git', line.split(/ +/)); | ||
} | ||
// clone a specific commit | ||
const line = `clone ${extras || ''} ${repoUrl}${cloneDirName}`; | ||
this.log(chalk.white(`clone repository:`), `git ${line}`); | ||
return this._spawnOrAbort('git', line.split(/ +/)).then(() => { | ||
const line = `checkout ${branch}`; | ||
this.log(chalk.white(`checkout commit:`), `git ${line}`); | ||
let repoName = simplifyRepoUrl(repoUrl); | ||
repoName = repoName.slice(repoName.lastIndexOf('/') + 1); | ||
return this._spawnOrAbort('git', line.split(/ +/), { | ||
cwd: `${this.cwd}/${repoName}` | ||
}); | ||
}); | ||
} | ||
|
||
_abort(msg) { | ||
return Promise.reject(msg ? msg : 'Step Failed: Aborting'); | ||
} | ||
|
||
_spawn(cmd, argline, cwd) { | ||
const options = cwd === false ? {} : Object.assign({ | ||
cwd: this.cwd, | ||
stdio: ['inherit', 'pipe', 'pipe'] // pipe `stdout` and `stderr` to host process | ||
}, cwd || {}); | ||
return this.spawnCommandSync(cmd, Array.isArray(argline) ? argline : argline.split(' '), options); | ||
} | ||
|
||
_spawnOrAbort(cmd, argline, cwd) { | ||
const r = this._spawn(cmd, argline, cwd); | ||
if (failed(r)) { | ||
this.log(r.stderr.toString()); | ||
return this._abort(`failed: "${cmd} ${Array.isArray(argline) ? argline.join(' ') : argline}" - status code: ${r.status}`); | ||
} | ||
return Promise.resolve(r); | ||
} | ||
|
||
} | ||
|
||
module.exports = Generator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
FROM nginx:alpine | ||
|
||
MAINTAINER Samuel Gratzl <[email protected]> | ||
LABEL maintainer="[email protected]" | ||
|
||
ENV PHOVEA_API_SERVER=api | ||
ENV PHOVEA_NGINX_PORT=80 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
generators/init-service/templates/sample_processed/deploy/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
FROM caleydo/phovea_python:v1.1 | ||
|
||
MAINTAINER Samuel Gratzl <[email protected]> | ||
LABEL maintainer="[email protected]" | ||
WORKDIR /phovea | ||
RUN printf "from phovea_server import launch\nlaunch.run()\n" > /phovea/launch.py | ||
|
||
# install dependencies last step such that everything before can be cached | ||
COPY requirements*.txt docker_packages.txt docker_script*.sh ./ | ||
RUN (!(test -s docker_packages.txt) || (apt-get update && \ | ||
(cat docker_packages.txt | xargs apt-get install -y))) && \ | ||
(pip install --no-cache-dir -r requirements.txt) | ||
(cat docker_packages.txt | xargs apt-get install -y))) && \ | ||
(pip install --no-cache-dir -r requirements.txt) | ||
RUN (!(test -f docker_script.sh) || (bash ./docker_script.sh)) | ||
|
||
COPY ./build/source ./ | ||
|
2 changes: 1 addition & 1 deletion
2
generators/init-service/templates/sample_processed/deploy/Dockerfile_dev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
FROM caleydo/phovea_python:v1.1-dev | ||
|
||
MAINTAINER Samuel Gratzl <[email protected]> | ||
LABEL maintainer="[email protected]" | ||
WORKDIR /phovea | ||
|
||
# install dependencies last step such that everything before can be cached | ||
|
Oops, something went wrong.