Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 7.0.0 #466

Merged
231 commits merged into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
231 commits
Select commit Hold shift + click to select a range
a0c346b
Commit fixes
oltionchampari Aug 10, 2020
12461ee
Add default value for argument to avoid string with undefined concati…
oltionchampari Aug 13, 2020
41d3eb4
use MiniCssExtractPlugin instead of style loader
dvvanessastoiber Aug 18, 2020
0090056
load css files first
dvvanessastoiber Aug 18, 2020
e190ae2
load fonts before css
dvvanessastoiber Aug 18, 2020
d1327bb
remove style-loader dependency
dvvanessastoiber Aug 18, 2020
e226b46
fix indentation
dvvanessastoiber Aug 18, 2020
f76d5df
prepare next dev version
dvvanessastoiber Aug 18, 2020
d0babb0
update functionality in build.js
dvvanessastoiber Aug 18, 2020
711c648
update .gitignore
dvvanessastoiber Aug 18, 2020
b521659
Merge branch 'develop' into ochampari/402_setup-workspace-fixes
oltionchampari Aug 19, 2020
dd1f56f
Copy product templates to workspace
oltionchampari Aug 19, 2020
8418da9
Add config to ignore dist files showing in PRs
oltionchampari Aug 19, 2020
e773162
Improve comment
oltionchampari Aug 19, 2020
a76860d
Merge pull request #417 from phovea/ochampari/416_hide_dist_files
Aug 20, 2020
3d8c28e
Use `PHOVEA_NGINX_PORT` in nginx-default.conf
thinkh Aug 20, 2020
86c5828
Merge pull request #421 from phovea/use-PHOVEA_NGINX_PORT-in-nginx-de…
Aug 20, 2020
211cef5
add flags to tsconfig.json
dvvanessastoiber Aug 24, 2020
3fe1bfd
add buildInfoFile in .gitignore
dvvanessastoiber Aug 24, 2020
eac015d
Extract `version.js` into different classes and extend tests
oltionchampari Sep 4, 2020
3fd9eac
Write tests for `pip.js` and refactor into a class method
oltionchampari Sep 4, 2020
2beb41c
Write tests for `repo.js` and refactor into a Util class
oltionchampari Sep 4, 2020
21ef372
Merge pull request #403 from phovea/ochampari/402_setup-workspace-fixes
Sep 9, 2020
1b27955
Merge pull request #411 from phovea/vstoiber/410_webpack_config_fouc
thinkh Sep 10, 2020
a448c9b
Merge branch 'develop' into develop_refactoring
oltionchampari Sep 10, 2020
5d202f5
Refactor SpawnUtils
oltionchampari Sep 10, 2020
19ead1e
Remove list-plugins file
oltionchampari Sep 10, 2020
9666dd8
Extend tests and extract functions into util clases
oltionchampari Sep 11, 2020
ab4ae9b
Extract mkdir function
oltionchampari Sep 11, 2020
e160827
Create `WorkspaceUtils`
oltionchampari Sep 11, 2020
9bae930
Refactor useDevVersion
oltionchampari Sep 11, 2020
d6e60ca
Fix spawnOrAbort bug
oltionchampari Sep 15, 2020
3b13e28
Extract yo method
oltionchampari Sep 15, 2020
8f5e84c
Remove unused import
oltionchampari Sep 15, 2020
03a4106
Fix useDevVersion bug
oltionchampari Sep 15, 2020
841235f
Refactor clone repo
oltionchampari Sep 15, 2020
28273c5
Commenting
oltionchampari Sep 15, 2020
df2f068
Refactor resolveNeighbours
oltionchampari Sep 15, 2020
c708b6d
Update function calls
oltionchampari Sep 15, 2020
16e04aa
Test check-node-version generator
oltionchampari Sep 15, 2020
894da0f
Minor change
oltionchampari Sep 15, 2020
e7cfd95
Remove unused import
oltionchampari Sep 15, 2020
1c245eb
Test clone-repo generator
oltionchampari Sep 15, 2020
18d9212
Extending tests
oltionchampari Sep 16, 2020
61268a9
Code cleanup
oltionchampari Sep 16, 2020
fcf51bd
Further refactoring
oltionchampari Sep 16, 2020
eeb8090
Refactor setup-workspace generator and extend tests
oltionchampari Sep 16, 2020
bb27b9c
Extend tests-fix bugs
oltionchampari Sep 16, 2020
b5c4c23
Refactor- extend tests
oltionchampari Sep 17, 2020
3ffe83f
Add comments
oltionchampari Sep 17, 2020
20c7c0f
Remove `chalk.default()` since it does not exist
oltionchampari Sep 23, 2020
10517bc
Run npm install sync
oltionchampari Sep 23, 2020
bbda376
Fix spawn function impl
oltionchampari Sep 23, 2020
6963e17
Rename function `spawn` to `spawnSync`
oltionchampari Sep 23, 2020
4a4a3df
Extend test of the init-lib sub-generator
oltionchampari Sep 23, 2020
4fab422
Extract and test function `toLibraryAliasMap`
oltionchampari Sep 23, 2020
5559968
Extract and test function `toLibraryExternals`
oltionchampari Sep 23, 2020
ff09962
Change text color
oltionchampari Sep 24, 2020
c5d32ab
Remove jenkins file from product templates
oltionchampari Sep 24, 2020
b7bf824
Extract and test function `buildPossibleAdditionalPlugins`
oltionchampari Sep 24, 2020
661bf0b
Add test for the init-product generator
oltionchampari Sep 24, 2020
c3a9484
Further refactoring
oltionchampari Sep 24, 2020
f8615de
Extract and test `stringifyAble` function
oltionchampari Sep 24, 2020
716baa6
Extract and test `toJSONFromText` function
oltionchampari Sep 25, 2020
9608dd8
Create BasePhoveaGenerator class
oltionchampari Sep 25, 2020
3c8edda
Use import instead of System.import in phovea.ts
oltionchampari Sep 25, 2020
bb1b219
Add tests for the add-extension generator
oltionchampari Sep 25, 2020
4ca798f
Further test refactoring
oltionchampari Sep 25, 2020
f50ec5c
Refactor tests
oltionchampari Sep 25, 2020
db6be89
Change folder structure of the tests
oltionchampari Sep 25, 2020
8714ae4
FIx path in tests
oltionchampari Sep 25, 2020
1b73128
FIrst basic implementation
oltionchampari Oct 2, 2020
8bbf0f4
Merge pull request #423 from phovea/vstoiber/422_incremental_build
Oct 11, 2020
d7ebfe2
Update package.json
oltionchampari Oct 29, 2020
93bf582
Extend npm utils
oltionchampari Oct 29, 2020
95e81f4
Extend spawn utils
oltionchampari Oct 29, 2020
1a1a044
Expand implementation
oltionchampari Oct 29, 2020
4627664
Use single instead of double quotes
oltionchampari Oct 30, 2020
e59fa08
Use enum for basetypes
oltionchampari Oct 30, 2020
f22f93d
Format
oltionchampari Oct 30, 2020
c6fb2cd
add dotenv-webpack
Nov 1, 2020
9f2a469
first draft
Nov 3, 2020
e9d97b1
Credential logic
oltionchampari Nov 3, 2020
6610eb5
Refactor and fix bugs
oltionchampari Nov 4, 2020
6d3a16c
Fix bugs and improve error log
oltionchampari Nov 6, 2020
458c2bf
Update generators/_init-hybrid/templates/plain/.circleci/config.yml
Nov 13, 2020
e94f49c
Update generators/_init-web/templates/plain/.circleci/config.yml
Nov 13, 2020
69d57ca
change build-nightly
Nov 13, 2020
0d3c908
Merge branch 'asteiner/433_circleci' of github.com:phovea/generator-p…
Nov 13, 2020
8dc0dd9
Merge pull request #435 from phovea/asteiner/434_webpack_dotenv
thinkh Nov 13, 2020
c75e2b2
change tab space
Nov 13, 2020
c563afb
Remove unecessary spaces
thinkh Nov 13, 2020
85c2c63
Merge branch 'asteiner/433_circleci' of github.com:phovea/generator-p…
thinkh Nov 13, 2020
9f7a79e
change executor
Nov 13, 2020
ed2194a
Merge branch 'asteiner/433_circleci' of github.com:phovea/generator-p…
Nov 13, 2020
4f63efb
Update indent
thinkh Nov 13, 2020
9a18e2b
Merge branch 'asteiner/433_circleci' of github.com:phovea/generator-p…
thinkh Nov 13, 2020
b5c2140
Add csss minimizer plugin to webpack config
oltionchampari Nov 19, 2020
1c9fef1
Update webpack helper
oltionchampari Nov 19, 2020
346a3d5
Compose workspace.scss in workspace generator
oltionchampari Nov 20, 2020
c520ee2
Remove scss import from initialize.ts
oltionchampari Nov 24, 2020
4ed30dc
create scss base directory
oltionchampari Nov 24, 2020
5de1999
Fix import
oltionchampari Nov 24, 2020
aae32d1
Add read config method
oltionchampari Nov 24, 2020
74c240e
Formatting
oltionchampari Nov 24, 2020
9eeeb08
Extend tests
oltionchampari Nov 24, 2020
b2a0816
Update impl and fix errors
oltionchampari Nov 25, 2020
57fb795
Minor change
oltionchampari Nov 25, 2020
e459909
Do not log error twice
oltionchampari Nov 26, 2020
0d3305a
Extend tests
oltionchampari Nov 26, 2020
a38a806
Check if yo-rc.json exist in workspace before deleting it
oltionchampari Nov 26, 2020
6f35028
Minor fix
oltionchampari Nov 26, 2020
5835196
Fix test
oltionchampari Nov 26, 2020
9772d5d
Remove cwd from config
oltionchampari Nov 26, 2020
70440ef
Format source code
thinkh Nov 26, 2020
819c6f8
add space
Nov 30, 2020
aa0ddb8
Merge branch 'develop_refactoring' of github.com:phovea/generator-pho…
Nov 30, 2020
36bd182
Copy templates in correct subdir
oltionchampari Nov 30, 2020
a1e2b95
Ignore emty dir when copying templates
oltionchampari Nov 30, 2020
c319308
Extend test
oltionchampari Nov 30, 2020
cb230f9
Transform dir name to lowercase
oltionchampari Nov 30, 2020
8eb906f
Fix cwd bug
oltionchampari Dec 1, 2020
7b5f4ac
Use rimraf package instead of unix command
oltionchampari Dec 2, 2020
bbaacc0
Remove options
oltionchampari Dec 2, 2020
585a58a
Remove buildInfo.js from web plugins
oltionchampari Dec 2, 2020
3e46731
Add base directory to package.json files
oltionchampari Dec 3, 2020
7c25950
Merge branch 'develop_refactoring' into ochampari/stylesheet_refactor…
oltionchampari Dec 3, 2020
6f65eff
Log workspace.scss
oltionchampari Dec 4, 2020
9dce1bb
update workspace dependencies
Dec 6, 2020
e71058d
Fix `copy-app-assets` npm command
thinkh Dec 7, 2020
b47c5df
Merge pull request #447 from phovea/thinkh/fix-copy-app-assets-command
Dec 9, 2020
c2bdf13
Add underscore to variables path
oltionchampari Dec 9, 2020
df33573
Do not overwrite workspace.scss if already included in product
oltionchampari Dec 9, 2020
39e5dc5
Fix typo
oltionchampari Dec 9, 2020
f0f4c07
Update tests
oltionchampari Dec 9, 2020
79949f5
Remove unnecessary property
oltionchampari Dec 9, 2020
5d6ef5d
Skip task instead of throwing error
oltionchampari Dec 9, 2020
98c8479
Better variable names
oltionchampari Dec 10, 2020
1a482b2
Better error handling
oltionchampari Dec 10, 2020
38dbdc4
Minor improvement
oltionchampari Dec 10, 2020
60018e3
Refactor code
oltionchampari Dec 10, 2020
324a8ff
Extract org from link
oltionchampari Dec 10, 2020
7f3b291
Use dynamic env variables
oltionchampari Dec 10, 2020
1eece0d
Improve task titles
oltionchampari Dec 11, 2020
c3f5b9a
Add code documentation
oltionchampari Dec 11, 2020
272d692
Update generators/workspace/templates/package.tmpl.json
Dec 15, 2020
a903166
Update generators/workspace/templates/package.tmpl.json
Dec 15, 2020
2c63cb5
Merge pull request #446 from phovea/asteiner/update_workspace_depende…
Dec 15, 2020
1f73072
Comment code
oltionchampari Dec 15, 2020
16da2f0
Check if required env variables are set
oltionchampari Dec 17, 2020
0b9f4cc
Update package.tmpl.json
Dec 17, 2020
8bdb0c9
Update implementation
oltionchampari Dec 17, 2020
1ff790e
use older css-loader version
dvvanessastoiber Dec 22, 2020
35fcea0
use older sass-loader version
dvvanessastoiber Dec 22, 2020
17102c9
add dotenv-webpack
dvvanessastoiber Dec 22, 2020
3d1b4be
Update webpack.dev.js
Dec 23, 2020
ce84c6e
Update webpack.prod.js
Dec 23, 2020
4f86e86
Update package.tmpl.json
Dec 23, 2020
67311af
Update package.tmpl.json
Dec 23, 2020
1ba0577
Add SCSS file per Webpack entry point
thinkh Dec 23, 2020
e112093
Merge pull request #428 from phovea/develop_refactoring
Dec 28, 2020
e29078f
Merge pull request #437 from phovea/ochampari/auto-update-generator
Dec 28, 2020
d9bcd80
Merge branch 'develop' into ochamapri/handle_workspace_yo-rc
Dec 28, 2020
1b16ea6
Merge pull request #441 from phovea/ochamapri/handle_workspace_yo-rc
Dec 28, 2020
cb47931
Refactor workspace and default app path
thinkh Dec 28, 2020
f79fca2
Move files from plain_initialize_once into plain
thinkh Dec 28, 2020
2a0bd28
Fix `copy` npm scripts for Windows
thinkh Dec 28, 2020
54a6b28
Merge branch 'develop' into ochampari/stylesheet_refactoring_changes
thinkh Dec 29, 2020
da27044
add console log
Dec 30, 2020
7bb0b81
Update package.tmpl.json
Dec 30, 2020
64896a5
Merge pull request #440 from phovea/ochampari/stylesheet_refactoring_…
Dec 30, 2020
7f5c214
Merge branch 'develop' into thinkh/450_support-multiple-workspace-scss
Dec 30, 2020
6728162
Merge pull request #451 from phovea/thinkh/450_support-multiple-works…
Dec 30, 2020
d4b1711
Merge pull request #453 from phovea/thinkh/429_copy-npm-scripts-for-w…
Dec 30, 2020
8eebfa9
Merge pull request #443 from phovea/ochampari/404_preinstall_script_c…
Dec 30, 2020
e8ad425
workspace.scss changes
Dec 31, 2020
98caf5c
workspace.scss changes
Dec 31, 2020
94f7e6a
remove dummy workspace
Jan 4, 2021
8685ab0
Update index.js
thinkh Jan 4, 2021
c15eaf5
Merge pull request #454 from phovea/asteiner/workspacescss_changes
thinkh Jan 4, 2021
409245d
Merge branch 'develop' into asteiner/webpack_changes_frontend_config
Jan 5, 2021
ade082d
Update generators/workspace/templates/plain/config/webpack.dev.js
Jan 5, 2021
fc3bf57
Update generators/workspace/templates/plain/config/webpack.prod.js
Jan 5, 2021
0a50885
Merge pull request #449 from phovea/asteiner/webpack_changes_frontend…
thinkh Jan 5, 2021
673dd7c
changes for scss folder
Jan 5, 2021
81a957c
change files of scss folders
Jan 5, 2021
a0d0318
remove styling for app
Jan 5, 2021
c5aae86
Merge pull request #455 from phovea/asteiner/add_scss_folder
thinkh Jan 5, 2021
ffa050b
Add 404 and 500 error pages
dvdanielamoitzi Jan 8, 2021
2efb86c
Update 404.html
dvdanielamoitzi Jan 8, 2021
6306bd9
Update and rename 500.html to 50x.html
dvdanielamoitzi Jan 8, 2021
eacc7f2
Delete main.css
dvdanielamoitzi Jan 8, 2021
cf66f63
change docker config
Jan 12, 2021
c0d90e5
Update google font import
dvdanielamoitzi Jan 12, 2021
cd7aae6
Update 404.html
dvdanielamoitzi Jan 12, 2021
bf88e74
Update 50x.html
dvdanielamoitzi Jan 12, 2021
6b4eca8
remove imports
Jan 13, 2021
ac732ac
Merge branch 'dmoitzi/452_add-error-pages' of github.com:phovea/gener…
Jan 13, 2021
c6abbf4
change copy command
Jan 13, 2021
a2fc5f0
update deprecated config option
dvvanessastoiber Jan 13, 2021
74533f0
update dependencies
dvvanessastoiber Jan 13, 2021
5c2b8ec
update requirements
dvvanessastoiber Jan 13, 2021
45ace68
update generator and product dependencies
dvvanessastoiber Jan 14, 2021
38d2804
update package-lock.json
dvvanessastoiber Jan 14, 2021
cf8a6bd
use older jest-cli version
dvvanessastoiber Jan 14, 2021
9bfb1dd
update package-lock.json
dvvanessastoiber Jan 14, 2021
d7a8416
downgrade yeoman-test
dvvanessastoiber Jan 14, 2021
68aa69d
avoid major updates
dvvanessastoiber Jan 14, 2021
89afbc2
update dependencies
dvvanessastoiber Jan 14, 2021
085a03e
Merge pull request #456 from phovea/dmoitzi/452_add-error-pages
Jan 23, 2021
597767d
Update package.tmpl.json
Jan 23, 2021
9ebcf51
Merge pull request #458 from phovea/vstoiber/457_update_requirements_…
Jan 23, 2021
b92dc01
update codeowner
dvvanessastoiber Feb 4, 2021
393983f
Merge pull request #465 from phovea/vstoiber/update_codeowner
Feb 4, 2021
0598142
Update config.yml
Feb 12, 2021
5caf8f2
Update config.yml
Feb 12, 2021
af6c9aa
Update config.yml
Feb 12, 2021
b6ab060
Update config.yml
Feb 12, 2021
57dca15
Update config.yml
Feb 12, 2021
18cc3fc
Update config.yml
Feb 12, 2021
a73b714
Update config.yml
Feb 12, 2021
a2d7cf0
Update config.yml
Feb 12, 2021
97aedf9
Update config.yml
Feb 12, 2021
01fc3de
Update config.yml
Feb 12, 2021
9134efc
Update config.yml
Feb 12, 2021
217d94a
Merge pull request #436 from phovea/asteiner/433_circleci
dvvanessastoiber Feb 15, 2021
fa11905
Merge pull request #414 from phovea/vstoiber/413_templates_folder_lab…
Feb 15, 2021
6d87950
update package-lock json
Feb 15, 2021
1ada37e
Merge branch 'develop' of github.com:phovea/generator-phovea into dev…
Feb 15, 2021
4806f91
update plugins; change circleci
Feb 15, 2021
5cfac08
prepare release 7.0.0
dvvanessastoiber Feb 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 42 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
version: 2
jobs:
build:
version: 2.1

executors:
node-executor:
working_directory: ~/phovea
docker:
- image: circleci/node:12-browsers
- image: circleci/node:12.13-buster-browsers

jobs:
build:
executor: node-executor
steps:
- checkout
- run:
Expand All @@ -12,22 +17,37 @@ jobs:
node -v
npm -v
- restore_cache:
key: deps-{{ .Branch }}-{{ checksum "package.json" }}
key: deps1-{{ .Branch }}-{{ checksum "package.json" }}
- run:
name: Install npm dependencies
command: npm install
- save_cache:
key: deps-{{ .Branch }}-{{ checksum "package.json" }}
paths:
- ./node_modules
key: deps1-{{ .Branch }}-{{ checksum "package.json" }}
paths: ./node_modules

- run:
name: Show installed npm dependencies
command: npm list --depth=1 || true
- run:
name: Run test
command: npm run test
- persist_to_workspace:
root: ~/phovea
paths: .
publish:
executor: node-executor
steps:
- attach_workspace:
at: ~/phovea
- run:
name: Authentication
command: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run:
name: Publish package
command: npm publish
workflows:
version: 2
version: 2.1
# build-nightly:
# triggers:
# - schedule:
Expand All @@ -38,17 +58,27 @@ workflows:
# - develop
# jobs:
# - build
build-branch:
build-branches-only:
jobs:
- build:
filters:
tags:
ignore: /^v.*/
build-tag:
ignore: /.*/
build-publish-tag:
jobs:
- build:
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
- publish:
context:
- org-public
requires:
- build
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @thinkh
* @anita-steiner
25 changes: 25 additions & 0 deletions base/BaseInitHybridGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';
const BaseInitPluginGenerator = require('./BaseInitPluginGenerator');
const {basetype} = require('./config');

class BaseInitHybridGenerator extends BaseInitPluginGenerator {

constructor(args, options) {
super(args, options, basetype.HYBRID);
}

initializing() {
// since just last in the hierarchy used, need to do super calls
super.initializing();
}

default() {
return super.default();
}

writing() {
return super.writing();
}
}

module.exports = BaseInitHybridGenerator;
95 changes: 95 additions & 0 deletions base/BaseInitPluginGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
'use strict';
const path = require('path');
const fs = require('fs-extra');
const chalk = require('chalk');
const GeneratorUtils = require('../utils/GeneratorUtils');
const BasePhoveaGenerator = require('../base/BasePhoveaGenerator');
const config = require('./config');

class BaseInitPluginGenerator extends BasePhoveaGenerator {

constructor(args, options, basetype) {
super(args, options);
this.type = path.basename(path.dirname(this.resolved)).substring(5); // init-web ... web
this.basetype = basetype || config.basetype.WEB;
// Make options available
this.option('skipInstall');
this.option('noSamples');
this.option('useDefaults');
this.cwd = '';
}

initializing() {
if (this._isInvalidWorkspace()) {
throw new Error(chalk.red('Execution failed, because a ".yo-rc.json" and ".yo-rc-workspace.json" file was found. If this directory is a workspace, please remove the ".yo-rc.json" file and try again.\n'));
}

this.composeWith(['phovea:_check-own-version', 'phovea:check-node-version']);

this.config.defaults({
type: this.type
});
}

_isWorkspace() {
return fs.existsSync(this.destinationPath('.yo-rc-workspace.json'));
}

_hasConfigFile() {
return fs.existsSync(this.destinationPath('.yo-rc.json'));
}

/**
* If there is both a `.yo-rc-workspace.json` and `.yo-rc.json` file in the current directory
* the workspace is invalid and the generator cannot function properly.
*/
_isInvalidWorkspace() {
return this._isWorkspace() && this._hasConfigFile();
}

/**
* Create a subdirectory in the current directory.
* Initialize the property cwd.
* @param {string} dir Directory name.
*/
async _createSubDir(dir) {
if (this._isWorkspace() && this.cwd !== dir + '/') {
this.cwd = dir + '/';
return GeneratorUtils.mkdir(dir);
}
return Promise.resolve();
}

readmeAddon() {
const f = this.templatePath('README.partial.md');
if (fs.existsSync(f)) {
return this.fs.read(f);
}
return '';
}

default() {
this.composeWith('phovea:_init-' + this.basetype, {
options: Object.assign({
readme: this.readmeAddon() + (this.options.readme ? `\n\n${this.options.readme}` : '')
}, this.options),
isWorkspace: this._isWorkspace() // inform the sub generator that the cwd is the workspace to avoid reading prompt default values from the workspace package.json
});
}

async writing() {
const config = this.config.getAll();
await this._createSubDir(config.app || config.serviceName || config.name);
if (fs.existsSync(this.templatePath('package.tmpl.json'))) {
this._patchPackageJSON(config, null, null, null, this.cwd);
}
if (fs.existsSync(this.templatePath('_gitignore'))) {
this.fs.copy(this.templatePath('_gitignore'), this.destinationPath(this.cwd + '.gitignore'));
}

this._writeTemplates(config, !this.options.noSamples, this.cwd);

}
}

module.exports = BaseInitPluginGenerator;
26 changes: 26 additions & 0 deletions base/BaseInitServerGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

const BaseInitPluginGenerator = require('./BaseInitPluginGenerator');
const {basetype} = require('./config');

class BaseInitServerGenerator extends BaseInitPluginGenerator {

constructor(args, options) {
super(args, options, basetype.PYTHON);
}

initializing() {
// since just last in the hierarchy used, need to do super calls
super.initializing();
}

default() {
return super.default();
}

writing() {
return super.writing();
}
}

module.exports = BaseInitServerGenerator;
98 changes: 98 additions & 0 deletions base/BasePhoveaGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
'use strict';
const Generator = require('yeoman-generator');
const {merge, template} = require('lodash');
const path = require('path');
const glob = require('glob').sync;
const fs = require('fs-extra');
const GeneratorUtils = require('../utils/GeneratorUtils');

class BasePhoveaGenerator extends Generator {

/**
* Modify package.json by passing the configuration.
*
* @param {object} config Current configuration
* @param {*} unset
* @param {*} extra
* @param {*} replaceExtra
* @param {string} cwd The directory from which the generator is being called, i.e., `tdp_core/`.
* If cwd is provided than the `package.json` is going to be written to that subdirectory, otherwise to the current directory.
*/
_patchPackageJSON(config, unset, extra, replaceExtra, cwd = '') {
const pkg = this.fs.readJSON(this.destinationPath(cwd + 'package.json'), {});
let pkgPatch;
if (fs.existsSync(this.templatePath('package.tmpl.json'))) {
pkgPatch = JSON.parse(template(this.fs.read(this.templatePath('package.tmpl.json')))(config));
} else {
pkgPatch = {};
}
merge(pkg, pkgPatch);
if (replaceExtra && extra) {
Object.assign(pkg, extra);
} else {
merge(pkg, extra || {});
}

(unset || []).forEach((d) => delete pkg[d]);

this.fs.writeJSON(this.destinationPath(cwd + 'package.json'), pkg);
}

/**
* Copies the template files to the current directory or to a subdirectory if `cwd` is provided.
* @param {object} config Current configuration
* @param {*} withSamples
* @param {string} cwd The directory from which the generator is being called, i.e., `tdp_core/`.
* If `cwd` is provided than the `package.json` is going to be written to that subdirectory, otherwise to the current directory.
*/
_writeTemplates(config, withSamples, cwd = '') {
const includeDot = {
globOptions: {
dot: true
}
};

const pattern = GeneratorUtils.stringifyAble(config);

const copyTpl = (base, dbase, initialize_once) => {
// see https://github.com/SBoudrias/mem-fs-editor/issues/25
// copyTpl doesn't support glob options
const f = glob(base + '/**/*', {
dot: true,
nodir: true
});
f.forEach((fi) => {
const rel = path.relative(base, fi);
if (!initialize_once || !fs.existsSync(this.destinationPath(cwd + dbase + rel))) {
this.fs.copyTpl(fi, this.destinationPath(cwd + dbase + rel), pattern);
}
});
};

const copy = (prefix) => {
if (fs.existsSync(this.templatePath(prefix + 'plain'))) {
this.fs.copy(this.templatePath(prefix + 'plain/**/*'), this.destinationPath(cwd), includeDot);
}

const plainTemplatePath = this.templatePath(prefix + 'plain_initialize_once');
if (fs.existsSync(plainTemplatePath)) {
copyTpl(plainTemplatePath, '', true);
}

copyTpl(this.templatePath(prefix + 'processed'), '', false);

if (config.name) {
if (fs.existsSync(this.templatePath(prefix + 'pluginname_plain'))) {
this.fs.copy(this.templatePath(prefix + 'pluginname_plain/**/*'), this.destinationPath(cwd + config.name.toLowerCase() + '/'), includeDot);
}
copyTpl(this.templatePath(prefix + 'pluginname_processed'), config.name.toLowerCase() + '/', false);
}
};
copy('');
if (withSamples) {
copy('sample_');
}
}
}

module.exports = BasePhoveaGenerator;
13 changes: 13 additions & 0 deletions base/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

/**
* Base classes types each plugin type can belong to.
*/
const basetype = {
PYTHON: 'python',
WEB: 'web',
HYBRID: 'hybrid'
};

module.exports = {
basetype
};
10 changes: 5 additions & 5 deletions generators/_init-hybrid/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';
const Base = require('../../utils').Base;
const known = () => require('../../utils/known');
const {toLibraryAliasMap, toLibraryExternals} = require('../_init-web');
const BaseInitPluginGenerator = require('../../base/BaseInitPluginGenerator');
const RepoUtils = require('../../utils/RepoUtils');

class Generator extends Base {
class Generator extends BaseInitPluginGenerator {

initializing() {
this.config.defaults({
Expand Down Expand Up @@ -31,8 +31,8 @@ class Generator extends Base {
this.config.set('modules', props.modules);
this.config.set('libraries', props.libraries);
}
this.config.set('libraryAliases', toLibraryAliasMap.call(this, this.config.get('modules'), this.config.get('libraries')));
this.config.set('libraryExternals', toLibraryExternals.call(this, this.config.get('modules'), this.config.get('libraries')));
this.config.set('libraryAliases', RepoUtils.toLibraryAliasMap(this.config.get('modules'), this.config.get('libraries')));
this.config.set('libraryExternals', RepoUtils.toLibraryExternals(this.config.get('modules'), this.config.get('libraries')));
});
}

Expand Down
1 change: 1 addition & 0 deletions generators/_init-hybrid/templates/_gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/.tscache
/.idea
/build/
/dist/tsBuildInfoFile
/lib/
*.egg-info/
*.py[cod]
Expand Down
Loading