diff --git a/generators/_init-hybrid/index.js b/generators/_init-hybrid/index.js index 01972fd8..12281e2d 100644 --- a/generators/_init-hybrid/index.js +++ b/generators/_init-hybrid/index.js @@ -38,7 +38,7 @@ class Generator extends Base { default() { const types = this.config.get('type').split('-'); - this.composeWith(['phovea:_node', 'phovea:init-' + types[1], 'phovea:init-' + types[0]], {options: this.options}) + this.composeWith(['phovea:_node', 'phovea:init-' + types[1], 'phovea:init-' + types[0]], {options: this.options, skipPrompting: this.options.skipPrompting, useDefaults: true}) } end() { diff --git a/generators/change-type/index.js b/generators/change-type/index.js new file mode 100644 index 00000000..b30a8406 --- /dev/null +++ b/generators/change-type/index.js @@ -0,0 +1,32 @@ +'use strict'; +const Base = require('yeoman-generator'); +const pluginTypes = ['lib', 'slib', 'lib-slib', 'lib-service', 'service', 'app', 'app-slib',] + +class ChangeTypeGenerator extends Base { + + constructor(args, options) { + super(args, options); + } + + prompting() { + const type = this.config.get('type'); + return this.prompt([{ + type: 'checkbox', + name: 'type', + message: 'New Type', + default: ['slib'], + choices: pluginTypes + }]).then(({type}) => { + this.old = this.config.get('type') + this.log(type) + this.config.set('type', type[0]); + + }) + } + default() { + const type = this.config.get('type') + this.composeWith(`phovea:to-${type}-type`, {currentType: this.old, newType: this.config.get('type')}) + } +} + +module.exports = ChangeTypeGenerator; diff --git a/generators/to-lib-type/index.js b/generators/to-lib-type/index.js new file mode 100644 index 00000000..13685c13 --- /dev/null +++ b/generators/to-lib-type/index.js @@ -0,0 +1,49 @@ +'use strict'; +const Base = require('yeoman-generator'); + +const diff = [ + 'buildPython.js', + 'deploy/docker-compose.partial.yml', + 'docker_packages.txt', + 'docs/.gitignore', + 'docs/_static/touch.txt', + 'docs/_templates/touch.txt', + 'docs/conf.py', + 'docs/index.rst', + 'requirements.txt', + 'requirements_dev.txt', + 'setup.cfg', + 'setup.py', + 'test/__init__.py', + 'test/config.json', + 'tox.ini', +] +const prefix = '../../'; + +class DowngradeLib extends Base { + + constructor(args, options) { + super(args, options); + } + + initializing() { + this.gitIgnorePath = this.templatePath(`${prefix}_init-web/templates/_gitignore`) + this.pathToConfigYml = this.templatePath(`${prefix}_init-web/templates/plain/.circleci/config.yml`) + this.pathToPackageJSON = this.templatePath(`${prefix}_init-web/templates/package.tmpl.json`) + } + _reversePackageJSON() { + const pkg = this.fs.readJSON(this.destinationPath('package.json')); + const {scripts, files} = this.fs.readJSON(this.pathToPackageJSON); + pkg.scripts = scripts; + pkg.files = files; + this.fs.writeJSON(this.destinationPath('package.json'), pkg); + } + writing() { + diff.forEach((file) => this.fs.delete(this.destinationPath(file))) + this.fs.copyTpl(this.gitIgnorePath, this.destinationPath('.gitignore')); + this.fs.copyTpl(this.pathToConfigYml, this.destinationPath('.circleci/config.yml')); + this._reversePackageJSON(); + } +} + +module.exports = DowngradeLib; diff --git a/generators/to-slib-type/index.js b/generators/to-slib-type/index.js new file mode 100644 index 00000000..c92c7d45 --- /dev/null +++ b/generators/to-slib-type/index.js @@ -0,0 +1,59 @@ +'use strict'; +const Base = require('yeoman-generator'); +const {merge, omit, extend, template} = require('lodash'); + +const diff = [ + 'buildInfo.js', + 'index.js', + 'jest.config.js', + 'phovea_registry.js', + 'src/index.ts', + 'src/phovea.ts', + 'tests.webpack.js', + 'tests/index.test.ts', + 'tsconfig.json', + 'tsconfig_dev.json', + 'tsd.d.ts', + 'tslint.json', + 'typedoc.json', + 'webpack.config.js' +] +const prefix = '../../'; + +class DowngradeSlib extends Base { + + constructor(args, options) { + super(args, options); + } + + initializing() { + this.gitIgnorePath = this.templatePath(`${prefix}_init-python/templates/_gitignore`) + this.pathToConfigYml = this.templatePath(`${prefix}_init-python/templates/plain/.circleci/config.yml`) + this.pathToPackageJSON = this.templatePath(`${prefix}_init-python/templates/package.tmpl.json`) + } + + _reversePackageJSON() { + const config = this.config.getAll(); + let pkg = this.fs.readJSON(this.destinationPath('package.json')); + const pkgPatch = JSON.parse(template(this.fs.read(this.pathToPackageJSON))(config)); + pkg = omit(pkg, ['engines', 'dependencies', 'devDependencies']); + pkg = Object.assign(pkg, pkgPatch); + this.fs.writeJSON(this.destinationPath('package.json'), pkg); + } + _downgrade() { + diff.forEach((file) => this.fs.delete(this.destinationPath(file))) + this.fs.copyTpl(this.gitIgnorePath, this.destinationPath('.gitignore')); + this.fs.copyTpl(this.pathToConfigYml, this.destinationPath('.circleci/config.yml')); + this._reversePackageJSON(); + } + + _upgrade(){ + + } + + writing() { + this._downgrade(); + } +} + +module.exports = DowngradeSlib; diff --git a/upgrade/app b/upgrade/app new file mode 100644 index 00000000..76794d7b --- /dev/null +++ b/upgrade/app @@ -0,0 +1,32 @@ +.circleci/config.yml +.editorconfig +.gitattributes +.gitignore +.yo-rc.json +ISSUE_TEMPLATE.md +LICENSE +README.md +buildInfo.js +deploy/Dockerfile +deploy/nginx-default.conf +jest.config.js +package.json +phovea_registry.js +src/404.html +src/app.ts +src/index.html +src/index.ts +src/language.ts +src/phovea.ts +src/robots.txt +src/style.scss +src/styles/_base.scss +tests.webpack.js +tests/app.test.ts +tsconfig.json +tsconfig_dev.json +tsd.d.ts +tslint.json +typedoc.json +webpack.config.js + diff --git a/upgrade/app-slib b/upgrade/app-slib new file mode 100644 index 00000000..14ac0884 --- /dev/null +++ b/upgrade/app-slib @@ -0,0 +1,46 @@ +.circleci/config.yml +.editorconfig +.gitattributes +.gitignore +.yo-rc.json +ISSUE_TEMPLATE.md +LICENSE +README.md +buildInfo.js +buildPython.js +deploy/Dockerfile +deploy/docker-compose.partial.yml +deploy/nginx-default.conf +docker_packages.txt +docs/.gitignore +docs/_static/touch.txt +docs/_templates/touch.txt +docs/conf.py +docs/index.rst +jest.config.js +package.json +phovea_registry.js +requirements.txt +requirements_dev.txt +setup.cfg +setup.py +src/404.html +src/app.ts +src/index.html +src/index.ts +src/language.ts +src/phovea.ts +src/robots.txt +src/style.scss +src/styles/_base.scss +test/__init__.py +test/config.json +tests.webpack.js +tests/app.test.ts +tox.ini +tsconfig.json +tsconfig_dev.json +tsd.d.ts +tslint.json +typedoc.json +webpack.config.js diff --git a/upgrade/lib b/upgrade/lib new file mode 100644 index 00000000..3039c0b4 --- /dev/null +++ b/upgrade/lib @@ -0,0 +1,23 @@ +.circleci/config.yml +.editorconfig +.gitattributes +.gitignore +.yo-rc.json +ISSUE_TEMPLATE.md +LICENSE +README.md +buildInfo.js +index.js +jest.config.js +package.json +phovea_registry.js +src/index.ts +src/phovea.ts +tests.webpack.js +tests/index.test.ts +tsconfig.json +tsconfig_dev.json +tsd.d.ts +tslint.json +typedoc.json +webpack.config.js diff --git a/upgrade/lib-service b/upgrade/lib-service new file mode 100644 index 00000000..e03ea637 --- /dev/null +++ b/upgrade/lib-service @@ -0,0 +1,43 @@ +.circleci/config.yml +.editorconfig +.gitattributes +.gitignore +.yo-rc.json +ISSUE_TEMPLATE.md +LICENSE +README.md +buildInfo.js +buildPython.js +deploy/Dockerfile +deploy/Dockerfile_dev +deploy/docker-compose-debug.partial.yml +deploy/docker-compose.partial.yml +docker_packages.txt +docs/.gitignore +docs/_static/touch.txt +docs/_templates/touch.txt +docs/conf.py +docs/index.rst +index.js +jest.config.js +package.json +phovea_registry.js +requirements.txt +requirements_dev.txt +setup.cfg +setup.py +src/index.ts +src/phovea.ts +test/__init__.py +test/config.json +test/server.py +tests.webpack.js +tests/index.test.ts +tests/test_server.py +tox.ini +tsconfig.json +tsconfig_dev.json +tsd.d.ts +tslint.json +typedoc.json +webpack.config.js diff --git a/upgrade/lib-slib b/upgrade/lib-slib new file mode 100644 index 00000000..b0d54556 --- /dev/null +++ b/upgrade/lib-slib @@ -0,0 +1,38 @@ +.circleci/config.yml +.editorconfig +.gitattributes +.gitignore +.yo-rc.json +ISSUE_TEMPLATE.md +LICENSE +README.md +buildInfo.js +buildPython.js +deploy/docker-compose.partial.yml +docker_packages.txt +docs/.gitignore +docs/_static/touch.txt +docs/_templates/touch.txt +docs/conf.py +docs/index.rst +index.js +jest.config.js +package.json +phovea_registry.js +requirements.txt +requirements_dev.txt +setup.cfg +setup.py +src/index.ts +src/phovea.ts +test/__init__.py +test/config.json +tests.webpack.js +tests/index.test.ts +tox.ini +tsconfig.json +tsconfig_dev.json +tsd.d.ts +tslint.json +typedoc.json +webpack.config.js diff --git a/upgrade/service b/upgrade/service new file mode 100644 index 00000000..6ad5b9cd --- /dev/null +++ b/upgrade/service @@ -0,0 +1,29 @@ +.circleci/config.yml +.editorconfig +.gitattributes +.gitignore +.yo-rc.json +ISSUE_TEMPLATE.md +LICENSE +README.md +buildPython.js +deploy/Dockerfile +deploy/Dockerfile_dev +deploy/docker-compose-debug.partial.yml +deploy/docker-compose.partial.yml +docker_packages.txt +docs/.gitignore +docs/_static/touch.txt +docs/_templates/touch.txt +docs/conf.py +docs/index.rst +package.json +requirements.txt +requirements_dev.txt +setup.cfg +setup.py +test/__init__.py +test/config.json +test/server.py +tests/test_server.py +tox.ini diff --git a/upgrade/slib b/upgrade/slib new file mode 100644 index 00000000..2704115e --- /dev/null +++ b/upgrade/slib @@ -0,0 +1,24 @@ +.circleci/config.yml +.editorconfig +.gitattributes +.gitignore +.yo-rc.json +ISSUE_TEMPLATE.md +LICENSE +README.md +buildPython.js +deploy/docker-compose.partial.yml +docker_packages.txt +docs/.gitignore +docs/_static/touch.txt +docs/_templates/touch.txt +docs/conf.py +docs/index.rst +package.json +requirements.txt +requirements_dev.txt +setup.cfg +setup.py +test/__init__.py +test/config.json +tox.ini diff --git a/utils/index.js b/utils/index.js index c1d25005..bc8d2b23 100644 --- a/utils/index.js +++ b/utils/index.js @@ -135,8 +135,9 @@ class BaseInitPluginGenerator extends Generator { this.composeWith('phovea:_init-' + this.basetype, { options: Object.assign({ readme: this.readmeAddon() + (this.options.readme ? `\n\n${this.options.readme}` : '') - }, this.options) - }); + }, this.options), + useDefaults: this.options.useDefaults + }) } writing() {