pob 9.12.3 → 9.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/README.md +2 -5
- package/lib/generators/app/PobAppGenerator.js +10 -4
- package/lib/generators/common/babel/CommonBabelGenerator.js +13 -8
- package/lib/generators/common/release/CommonReleaseGenerator.js +0 -1
- package/lib/generators/common/testing/CommonTestingGenerator.js +3 -17
- package/lib/generators/core/ci/CoreCIGenerator.js +20 -0
- package/lib/generators/core/ci/templates/github-action-documentation-workflow.yml.ejs +48 -0
- package/lib/generators/core/ci/templates/github-action-node-workflow.yml.ejs +9 -19
- package/lib/generators/core/gitignore/CoreGitignoreGenerator.js +8 -0
- package/lib/generators/core/gitignore/templates/gitignore.ejs +12 -2
- package/lib/generators/core/vscode/CoreVSCodeGenerator.js +81 -1
- package/lib/generators/core/vscode/templates/settings.json.ejs +5 -0
- package/lib/generators/core/yarn/CoreYarnGenerator.js +4 -11
- package/lib/generators/lib/PobLibGenerator.js +10 -0
- package/lib/generators/lib/doc/LibDocGenerator.js +4 -7
- package/lib/generators/monorepo/PobMonorepoGenerator.js +19 -6
- package/lib/generators/monorepo/typescript/MonorepoTypescriptGenerator.js +1 -3
- package/lib/generators/pob/PobBaseGenerator.js +0 -9
- package/lib/utils/writeAndFormat.js +6 -2
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,68 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [9.14.0](https://github.com/christophehurpeau/pob/compare/pob@9.13.2...pob@9.14.0) (2022-01-20)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **deps:** update dependency @yarnpkg/parsers to v2.5.0-rc.9 ([#1165](https://github.com/christophehurpeau/pob/issues/1165)) ([bdb496f](https://github.com/christophehurpeau/pob/commit/bdb496febb6ec534a0ca0ac24cb32fe16b639e79))
|
|
12
|
+
* full vscode workspace config ([f3aa63d](https://github.com/christophehurpeau/pob/commit/f3aa63de6cc2b597c3114eb34757e94347cf5f3f))
|
|
13
|
+
* remove tasks from workspace config ([cc4b1a7](https://github.com/christophehurpeau/pob/commit/cc4b1a7efe39e2d7f13ac3079a32c58d3cd86c75))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **deps:** update dependency eslint to v8.7.0 ([#1164](https://github.com/christophehurpeau/pob/issues/1164)) ([9ec0c31](https://github.com/christophehurpeau/pob/commit/9ec0c3156cf5ed5d1f9e3e4ce4636b77da826850))
|
|
19
|
+
* **pob:** generate vscode monorepo workspace ([23ceaae](https://github.com/christophehurpeau/pob/commit/23ceaae63bc1abc58061366d90f8cd5c397bf232))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [9.13.2](https://github.com/christophehurpeau/pob/compare/pob@9.13.1...pob@9.13.2) (2022-01-15)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **@pob/root:** fix use default github token for gh-pages workflow ([784ce66](https://github.com/christophehurpeau/pob/commit/784ce6633d5d5d14cdcf63aeb5a83ed036434673))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## [9.13.1](https://github.com/christophehurpeau/pob/compare/pob@9.13.0...pob@9.13.1) (2022-01-15)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
* **pob:** multiple newlines in gitignore template ([f00c5be](https://github.com/christophehurpeau/pob/commit/f00c5bed9a6200d3ded4737ffcdab175eb56b2c5))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# [9.13.0](https://github.com/christophehurpeau/pob/compare/pob@9.12.3...pob@9.13.0) (2022-01-15)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Bug Fixes
|
|
51
|
+
|
|
52
|
+
* disable gh-pages for apps ([0f935ff](https://github.com/christophehurpeau/pob/commit/0f935ff24207ebe782bb7f0a2f75372ab87ac240))
|
|
53
|
+
* **deps:** update dependency @pob/eslint-config-typescript-react to v48.0.7 ([#1153](https://github.com/christophehurpeau/pob/issues/1153)) ([b96b1c4](https://github.com/christophehurpeau/pob/commit/b96b1c4497529772b58e18c04b6b19020bb4931f))
|
|
54
|
+
* **deps:** update dependency @yarnpkg/parsers to v2.5.0-rc.8 ([#1155](https://github.com/christophehurpeau/pob/issues/1155)) ([4a01d49](https://github.com/christophehurpeau/pob/commit/4a01d4929b0b6ae0d19494e478357a6d7bf4acb6))
|
|
55
|
+
* **pob:** add @babel/core when pkg has peer dependency ([acd04cb](https://github.com/christophehurpeau/pob/commit/acd04cbc77c914af56db8b83734d187cc926f4e4))
|
|
56
|
+
* **pob:** extraEntries for pkg.type === "module" ([2fae75c](https://github.com/christophehurpeau/pob/commit/2fae75cdf6ee5678f436d11a15f02bd22f1a9c66))
|
|
57
|
+
* **pob:** remove /private_key in gitignore ([368d819](https://github.com/christophehurpeau/pob/commit/368d8193d638ec41a7caa7a46e9cbcd6607dcaf2))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### Features
|
|
61
|
+
|
|
62
|
+
* generate documentation and coverage on gh-pages ([32e4801](https://github.com/christophehurpeau/pob/commit/32e4801e8a4d1ff221a7fe63d42c6fe52d46f796))
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
6
68
|
## [9.12.3](https://github.com/christophehurpeau/pob/compare/pob@9.12.2...pob@9.12.3) (2022-01-02)
|
|
7
69
|
|
|
8
70
|
|
package/README.md
CHANGED
|
@@ -40,9 +40,8 @@ You can check the code by running the task `yarn run lint`. With an editor, inst
|
|
|
40
40
|
|
|
41
41
|
#### Documentation
|
|
42
42
|
|
|
43
|
-
[
|
|
43
|
+
[typedoc](https://typedoc.org/) allows to document the code and generate the api.
|
|
44
44
|
[jest](https://www.npmjs.com/package/jest) is used to generate the coverage.
|
|
45
|
-
You can generate the documentation with `yarn run generate:docs`.
|
|
46
45
|
|
|
47
46
|
Documentation can be generated by github actions and pushed to github-pages.
|
|
48
47
|
|
|
@@ -61,9 +60,7 @@ Tests are in the directory `src` with jest. Use the task `yarn test` to run the
|
|
|
61
60
|
|
|
62
61
|
### Generate documentation
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
- `generate:api`: generate api with jsdoc
|
|
66
|
-
- `generate:test-coverage`: generate coverage documentation
|
|
63
|
+
Documentation (api + test coverage) is deployed to gh-pages via a github action.
|
|
67
64
|
|
|
68
65
|
### Publish a new release
|
|
69
66
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
1
|
import Generator from 'yeoman-generator';
|
|
3
2
|
import inLerna from '../../utils/inLerna.js';
|
|
4
3
|
import inNpmLerna from '../../utils/inNpmLerna.js';
|
|
@@ -179,17 +178,24 @@ export default class PobAppGenerator extends Generator {
|
|
|
179
178
|
updateOnly: this.options.updateOnly,
|
|
180
179
|
});
|
|
181
180
|
|
|
181
|
+
this.composeWith('pob:core:vscode', {
|
|
182
|
+
root: !inLerna,
|
|
183
|
+
monorepo: false,
|
|
184
|
+
packageManager: this.options.packageManager,
|
|
185
|
+
yarnNodeLinker: this.options.yarnNodeLinker,
|
|
186
|
+
typescript: babel,
|
|
187
|
+
testing: this.appConfig.testing,
|
|
188
|
+
});
|
|
189
|
+
|
|
182
190
|
// only for gitignore
|
|
183
191
|
if (this.fs.exists('.env.example')) {
|
|
184
192
|
ignorePaths.push('/.env*', '!/.env.example');
|
|
185
193
|
}
|
|
186
|
-
if (fs.existsSync('private_key')) {
|
|
187
|
-
ignorePaths.push('/private_key');
|
|
188
|
-
}
|
|
189
194
|
|
|
190
195
|
this.composeWith('pob:core:gitignore', {
|
|
191
196
|
root: !inLerna || inLerna.root,
|
|
192
197
|
documentation: false,
|
|
198
|
+
testing: this.appConfig.testing,
|
|
193
199
|
withBabel: babel,
|
|
194
200
|
paths: ignorePaths.join('\n'),
|
|
195
201
|
buildInGit: false,
|
|
@@ -319,10 +319,12 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
319
319
|
|
|
320
320
|
/* dependencies */
|
|
321
321
|
|
|
322
|
-
packageUtils.addOrRemoveDevDependencies(
|
|
323
|
-
|
|
324
|
-
'
|
|
325
|
-
|
|
322
|
+
packageUtils.addOrRemoveDevDependencies(
|
|
323
|
+
pkg,
|
|
324
|
+
useBabel || (pkg.peerDependencies && pkg.peerDependencies['@babel/core']),
|
|
325
|
+
['@babel/core'],
|
|
326
|
+
);
|
|
327
|
+
packageUtils.addOrRemoveDevDependencies(pkg, useBabel, ['pob-babel']);
|
|
326
328
|
|
|
327
329
|
if (pkg.dependencies && pkg.dependencies['pob-babel']) {
|
|
328
330
|
// update pob-babel in alp-dev
|
|
@@ -651,10 +653,13 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
651
653
|
|
|
652
654
|
if (pkg.pob.extraEntries) {
|
|
653
655
|
pkg.pob.extraEntries.forEach((exportName) => {
|
|
654
|
-
pkg.exports[`./${exportName}`] =
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
656
|
+
pkg.exports[`./${exportName}`] =
|
|
657
|
+
pkg.type === 'module'
|
|
658
|
+
? `./${exportName}.js`
|
|
659
|
+
: {
|
|
660
|
+
import: `./${exportName}.mjs`,
|
|
661
|
+
require: `./${exportName}.js`,
|
|
662
|
+
};
|
|
658
663
|
});
|
|
659
664
|
}
|
|
660
665
|
} else if (!pkg.exports) {
|
|
@@ -85,6 +85,7 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
85
85
|
'babel-core',
|
|
86
86
|
'ts-jest',
|
|
87
87
|
'babel-jest',
|
|
88
|
+
'pob-lcov-reporter',
|
|
88
89
|
]);
|
|
89
90
|
|
|
90
91
|
const yoConfigPobMonorepo = inLerna && inLerna.pobMonorepoConfig;
|
|
@@ -116,13 +117,10 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
116
117
|
packageUtils.addOrRemoveDevDependencies(
|
|
117
118
|
pkg,
|
|
118
119
|
enableForMonorepo || !globalTesting,
|
|
119
|
-
[
|
|
120
|
-
pkg.name !== 'pob-monorepo' && 'pob-lcov-reporter',
|
|
121
|
-
'jest',
|
|
122
|
-
'@types/jest',
|
|
123
|
-
],
|
|
120
|
+
['jest', '@types/jest'],
|
|
124
121
|
);
|
|
125
122
|
|
|
123
|
+
packageUtils.removeScripts(['test:coverage']);
|
|
126
124
|
if (this.options.monorepo && !globalTesting) {
|
|
127
125
|
delete pkg.jest;
|
|
128
126
|
packageUtils.addScripts(pkg, {
|
|
@@ -139,12 +137,6 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
139
137
|
|
|
140
138
|
packageUtils.addScripts(pkg, {
|
|
141
139
|
test: jestCommand,
|
|
142
|
-
'generate:test-coverage': [
|
|
143
|
-
'rm -Rf docs/coverage/',
|
|
144
|
-
`NODE_ENV=production ${
|
|
145
|
-
transpileWithBabel ? 'BABEL_ENV=test ' : ''
|
|
146
|
-
}${jestCommand} --coverage --coverageReporters=pob-lcov-reporter --coverageDirectory=docs/coverage/`,
|
|
147
|
-
].join(' ; '),
|
|
148
140
|
});
|
|
149
141
|
|
|
150
142
|
const workspacesWithoutStar = pkg.workspaces.map((workspace) => {
|
|
@@ -206,12 +198,6 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
206
198
|
packageUtils.addScripts(pkg, {
|
|
207
199
|
test: jestCommand,
|
|
208
200
|
'test:watch': `${jestCommand} --watch`,
|
|
209
|
-
'generate:test-coverage': [
|
|
210
|
-
'rm -Rf docs/coverage/',
|
|
211
|
-
`NODE_ENV=production ${
|
|
212
|
-
transpileWithBabel ? 'BABEL_ENV=test ' : ''
|
|
213
|
-
}${jestCommand} --coverage --coverageReporters=pob-lcov-reporter --coverageDirectory=docs/coverage/`,
|
|
214
|
-
].join(' ; '),
|
|
215
201
|
});
|
|
216
202
|
|
|
217
203
|
const srcDirectory = transpileWithBabel ? 'src' : 'lib';
|
|
@@ -66,6 +66,7 @@ export default class CoreCIGenerator extends Generator {
|
|
|
66
66
|
if (fs.existsSync(this.destinationPath('.circleci'))) {
|
|
67
67
|
fs.rmdirSync(this.destinationPath('.circleci'), { recursive: true });
|
|
68
68
|
}
|
|
69
|
+
|
|
69
70
|
if (this.options.enable) {
|
|
70
71
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'));
|
|
71
72
|
|
|
@@ -87,6 +88,25 @@ export default class CoreCIGenerator extends Generator {
|
|
|
87
88
|
} else {
|
|
88
89
|
this.fs.delete(this.destinationPath('.github/workflows/push.yml'));
|
|
89
90
|
}
|
|
91
|
+
|
|
92
|
+
if (
|
|
93
|
+
this.options.enable &&
|
|
94
|
+
!this.options.isApp &&
|
|
95
|
+
(this.options.documentation || this.options.testing)
|
|
96
|
+
) {
|
|
97
|
+
copyAndFormatTpl(
|
|
98
|
+
this.fs,
|
|
99
|
+
this.templatePath('github-action-documentation-workflow.yml.ejs'),
|
|
100
|
+
this.destinationPath('.github/workflows/gh-pages.yml'),
|
|
101
|
+
{
|
|
102
|
+
packageManager: this.options.packageManager,
|
|
103
|
+
testing: this.options.testing,
|
|
104
|
+
typedoc: this.options.documentation && this.options.typescript,
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
} else {
|
|
108
|
+
this.fs.delete(this.destinationPath('.github/workflows/gh-pages.yml'));
|
|
109
|
+
}
|
|
90
110
|
}
|
|
91
111
|
|
|
92
112
|
writing() {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: 'Create documentation and deploy to Github pages'
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
create-documentation-and-deploy:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v2
|
|
12
|
+
|
|
13
|
+
- uses: actions/setup-node@v2
|
|
14
|
+
with:
|
|
15
|
+
node-version: 16
|
|
16
|
+
|
|
17
|
+
- name: Cache dependencies
|
|
18
|
+
uses: actions/cache@v2
|
|
19
|
+
with:
|
|
20
|
+
path: |
|
|
21
|
+
.yarn/unplugged
|
|
22
|
+
.yarn/install-state.gz
|
|
23
|
+
key: v2-dependencies--${{ matrix.node-version }}-${{ runner.OS }}-${{ hashFiles('yarn.lock') }}
|
|
24
|
+
restore-keys: |
|
|
25
|
+
v2-dependencies--${{ matrix.node-version }}-${{ runner.OS }}-
|
|
26
|
+
v2-dependencies--${{ matrix.node-version }}-
|
|
27
|
+
|
|
28
|
+
- name: Check Dependencies
|
|
29
|
+
run: yarn install --immutable --immutable-cache
|
|
30
|
+
|
|
31
|
+
<% if (typedoc) { -%>
|
|
32
|
+
- name: Generate Typedoc
|
|
33
|
+
run: yarn typedoc --tsconfig tsconfig.doc.json
|
|
34
|
+
<% } -%>
|
|
35
|
+
|
|
36
|
+
<% if (testing) { -%>
|
|
37
|
+
- name: Generate Coverage
|
|
38
|
+
run: yarn test --coverage --coverageReporters=lcov --coverageDirectory=docs/coverage/
|
|
39
|
+
<% } -%>
|
|
40
|
+
|
|
41
|
+
- name: Create nojekyll
|
|
42
|
+
run: touch docs/.nojekyll
|
|
43
|
+
|
|
44
|
+
- name: Deploy
|
|
45
|
+
uses: peaceiris/actions-gh-pages@v3
|
|
46
|
+
with:
|
|
47
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
48
|
+
publish_dir: ./docs
|
|
@@ -73,35 +73,25 @@ jobs:
|
|
|
73
73
|
run: yarn run tsc
|
|
74
74
|
if: startsWith(matrix.node-version, '16.')
|
|
75
75
|
<% } -%>
|
|
76
|
-
<% if (
|
|
77
|
-
|
|
78
|
-
- name: Test
|
|
79
|
-
run: <%= packageManager %> run test
|
|
80
|
-
env:
|
|
81
|
-
CI: true
|
|
82
|
-
<% } -%>
|
|
83
|
-
<% if (documentation) { -%>
|
|
84
|
-
|
|
85
|
-
- name: Documentation
|
|
86
|
-
run: <%= packageManager %> run generate:docs
|
|
87
|
-
if: startsWith(matrix.node-version, '16.')
|
|
88
|
-
env:
|
|
89
|
-
CI: true
|
|
90
|
-
<% } else if (codecov) { -%>
|
|
76
|
+
<% if (codecov) { -%>
|
|
91
77
|
|
|
92
|
-
- name: Generate Coverage
|
|
93
|
-
run: <%= packageManager %> run
|
|
78
|
+
- name: Generate Test Coverage
|
|
79
|
+
run: <%= packageManager %> run test --coverage --coverageReporters=json --coverageReporters=text
|
|
94
80
|
if: startsWith(matrix.node-version, '16.')
|
|
95
81
|
env:
|
|
96
82
|
CI: true
|
|
97
|
-
<% } -%>
|
|
98
|
-
<% if (codecov) { -%>
|
|
99
83
|
|
|
100
84
|
- name: Send results to codecov
|
|
101
85
|
uses: codecov/codecov-action@v2
|
|
102
86
|
with:
|
|
103
87
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
104
88
|
if: startsWith(matrix.node-version, '16.')
|
|
89
|
+
<% } else if (testing) { -%>
|
|
90
|
+
|
|
91
|
+
- name: Test
|
|
92
|
+
run: <%= packageManager %> run test
|
|
93
|
+
env:
|
|
94
|
+
CI: true
|
|
105
95
|
<% } -%>
|
|
106
96
|
<% if (true) { -%>
|
|
107
97
|
|
|
@@ -18,6 +18,13 @@ export default class CoreGitignoreGenerator extends Generator {
|
|
|
18
18
|
desc: 'Documentation enabled.',
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
this.option('testing', {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
required: false,
|
|
24
|
+
defaults: false,
|
|
25
|
+
desc: 'Testing enabled.',
|
|
26
|
+
});
|
|
27
|
+
|
|
21
28
|
this.option('withBabel', {
|
|
22
29
|
type: Boolean,
|
|
23
30
|
required: false,
|
|
@@ -66,6 +73,7 @@ export default class CoreGitignoreGenerator extends Generator {
|
|
|
66
73
|
this.fs.copyTpl(this.templatePath('gitignore.ejs'), dest, {
|
|
67
74
|
root: this.options.root,
|
|
68
75
|
documentation: this.options.documentation,
|
|
76
|
+
testing: this.options.testing,
|
|
69
77
|
withBabel,
|
|
70
78
|
typescript: withBabel || this.options.typescript,
|
|
71
79
|
paths: this.options.paths,
|
|
@@ -7,12 +7,12 @@ npm-debug.log*
|
|
|
7
7
|
yarn-debug.log*
|
|
8
8
|
yarn-error.log*
|
|
9
9
|
<% } -%>
|
|
10
|
-
|
|
11
10
|
<% if (paths) { -%>
|
|
11
|
+
|
|
12
12
|
<%= paths %>
|
|
13
13
|
<% } -%>
|
|
14
|
-
|
|
15
14
|
<% if (root) { -%>
|
|
15
|
+
|
|
16
16
|
# IDE
|
|
17
17
|
/.settings
|
|
18
18
|
/.project
|
|
@@ -20,8 +20,18 @@ yarn-error.log*
|
|
|
20
20
|
!/.vscode
|
|
21
21
|
*.sublime-project
|
|
22
22
|
*.sublime-workspace
|
|
23
|
+
<% if (documentation) { -%>
|
|
23
24
|
|
|
25
|
+
# generated documentation directory
|
|
26
|
+
/docs
|
|
27
|
+
<% } -%>
|
|
28
|
+
<% if (testing) { -%>
|
|
29
|
+
|
|
30
|
+
# jest default coverage directory
|
|
31
|
+
/coverage
|
|
32
|
+
<% } -%>
|
|
24
33
|
<% if (typescript && buildInGit) { -%>
|
|
34
|
+
|
|
25
35
|
# Typescript
|
|
26
36
|
tsbuildinfo
|
|
27
37
|
<% } -%>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import Generator from 'yeoman-generator';
|
|
2
2
|
import { readJSON5 } from '../../../utils/json5.js';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
copyAndFormatTpl,
|
|
5
|
+
writeAndFormatJson,
|
|
6
|
+
} from '../../../utils/writeAndFormat.js';
|
|
4
7
|
|
|
5
8
|
export default class CoreVSCodeGenerator extends Generator {
|
|
6
9
|
constructor(args, opts) {
|
|
@@ -20,6 +23,20 @@ export default class CoreVSCodeGenerator extends Generator {
|
|
|
20
23
|
desc: 'yarn|npm.',
|
|
21
24
|
});
|
|
22
25
|
|
|
26
|
+
this.option('monorepo', {
|
|
27
|
+
type: String,
|
|
28
|
+
required: false,
|
|
29
|
+
defaults: 'yarn',
|
|
30
|
+
desc: 'yarn|npm.',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
this.option('testing', {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
required: false,
|
|
36
|
+
defaults: false,
|
|
37
|
+
desc: 'Testing enabled',
|
|
38
|
+
});
|
|
39
|
+
|
|
23
40
|
this.option('yarnNodeLinker', {
|
|
24
41
|
type: String,
|
|
25
42
|
required: false,
|
|
@@ -33,10 +50,21 @@ export default class CoreVSCodeGenerator extends Generator {
|
|
|
33
50
|
defaults: false,
|
|
34
51
|
desc: 'Typescript enabled',
|
|
35
52
|
});
|
|
53
|
+
|
|
54
|
+
this.option('packageNames', {
|
|
55
|
+
type: String,
|
|
56
|
+
required: false,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
this.option('packageLocations', {
|
|
60
|
+
type: String,
|
|
61
|
+
required: false,
|
|
62
|
+
});
|
|
36
63
|
}
|
|
37
64
|
|
|
38
65
|
writing() {
|
|
39
66
|
if (this.options.root) {
|
|
67
|
+
const pkg = this.fs.readJSON(this.destinationPath('package.json'));
|
|
40
68
|
copyAndFormatTpl(
|
|
41
69
|
this.fs,
|
|
42
70
|
this.templatePath('extensions.json.ejs'),
|
|
@@ -55,6 +83,8 @@ export default class CoreVSCodeGenerator extends Generator {
|
|
|
55
83
|
pnp: this.options.yarnNodeLinker === 'pnp',
|
|
56
84
|
npm: this.options.packageManager === 'npm',
|
|
57
85
|
typescript: this.options.typescript,
|
|
86
|
+
testing: this.options.testing,
|
|
87
|
+
module: pkg.type === 'module',
|
|
58
88
|
},
|
|
59
89
|
);
|
|
60
90
|
|
|
@@ -72,6 +102,56 @@ export default class CoreVSCodeGenerator extends Generator {
|
|
|
72
102
|
tasks: JSON.stringify(tasksConfig.tasks || [], null, 2),
|
|
73
103
|
},
|
|
74
104
|
);
|
|
105
|
+
|
|
106
|
+
if (this.options.monorepo) {
|
|
107
|
+
const packageNames = JSON.parse(this.options.packageNames);
|
|
108
|
+
const packageLocations = JSON.parse(this.options.packageLocations);
|
|
109
|
+
const folders = packageLocations.map((location, i) => ({
|
|
110
|
+
name: packageNames[i],
|
|
111
|
+
path: `../${location}`,
|
|
112
|
+
}));
|
|
113
|
+
folders.sort((a, b) => a.name.localeCompare(b.name, 'en'));
|
|
114
|
+
|
|
115
|
+
const extensions = readJSON5(
|
|
116
|
+
this.fs,
|
|
117
|
+
this.destinationPath('.vscode/extensions.json'),
|
|
118
|
+
{},
|
|
119
|
+
);
|
|
120
|
+
const settings = readJSON5(
|
|
121
|
+
this.fs,
|
|
122
|
+
this.destinationPath('.vscode/settings.json'),
|
|
123
|
+
{},
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const projectName = pkg.name.replace('/', '-');
|
|
127
|
+
writeAndFormatJson(
|
|
128
|
+
this.fs,
|
|
129
|
+
this.destinationPath(`.vscode/${projectName}.code-workspace`),
|
|
130
|
+
{
|
|
131
|
+
extensions,
|
|
132
|
+
settings: {
|
|
133
|
+
...settings,
|
|
134
|
+
...(this.options.testing
|
|
135
|
+
? {
|
|
136
|
+
'jest.jestCommandLine':
|
|
137
|
+
'NODE_OPTIONS=--experimental-vm-modules node_modules/.bin/jest',
|
|
138
|
+
// disable all folders to enable only root.
|
|
139
|
+
'jest.disabledWorkspaceFolders': folders.map(
|
|
140
|
+
(folder) => folder.name,
|
|
141
|
+
),
|
|
142
|
+
}
|
|
143
|
+
: {}),
|
|
144
|
+
},
|
|
145
|
+
folders: [
|
|
146
|
+
{
|
|
147
|
+
name: '✨ root',
|
|
148
|
+
path: '..',
|
|
149
|
+
},
|
|
150
|
+
...folders,
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
);
|
|
154
|
+
}
|
|
75
155
|
} else {
|
|
76
156
|
this.fs.delete('.vscode');
|
|
77
157
|
}
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"source.organizeImports": false
|
|
30
30
|
},
|
|
31
31
|
|
|
32
|
+
<% if (testing && module) { -%>
|
|
33
|
+
// jest
|
|
34
|
+
"jest.jestCommandLine": "NODE_OPTIONS=--experimental-vm-modules node_modules/.bin/jest",
|
|
35
|
+
<% } -%>
|
|
36
|
+
|
|
32
37
|
// eslint config
|
|
33
38
|
"eslint.workingDirectories": ["."],
|
|
34
39
|
"eslint.options": {
|
|
@@ -129,17 +129,10 @@ export default class CoreYarnGenerator extends Generator {
|
|
|
129
129
|
try {
|
|
130
130
|
this.spawnCommandSync('yarn', ['run', 'preversion']);
|
|
131
131
|
} catch {}
|
|
132
|
-
} else {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
} catch {}
|
|
137
|
-
}
|
|
138
|
-
if (pkg.scripts['generate:docs']) {
|
|
139
|
-
try {
|
|
140
|
-
this.spawnCommandSync('yarn', ['run', 'generate:docs']);
|
|
141
|
-
} catch {}
|
|
142
|
-
}
|
|
132
|
+
} else if (pkg.scripts.build) {
|
|
133
|
+
try {
|
|
134
|
+
this.spawnCommandSync('yarn', ['run', 'build']);
|
|
135
|
+
} catch {}
|
|
143
136
|
}
|
|
144
137
|
}
|
|
145
138
|
}
|
|
@@ -285,12 +285,22 @@ export default class PobLibGenerator extends Generator {
|
|
|
285
285
|
updateOnly: this.options.updateOnly,
|
|
286
286
|
});
|
|
287
287
|
|
|
288
|
+
this.composeWith('pob:core:vscode', {
|
|
289
|
+
root: !inLerna,
|
|
290
|
+
monorepo: false,
|
|
291
|
+
packageManager: this.options.packageManager,
|
|
292
|
+
yarnNodeLinker: this.options.yarnNodeLinker,
|
|
293
|
+
typescript: withBabel,
|
|
294
|
+
testing: this.pobjson.testing,
|
|
295
|
+
});
|
|
296
|
+
|
|
288
297
|
// must be after doc, testing
|
|
289
298
|
this.composeWith('pob:core:gitignore', {
|
|
290
299
|
root: !inLerna,
|
|
291
300
|
withBabel: babelEnvs.length > 0,
|
|
292
301
|
typescript: babelEnvs.length > 0,
|
|
293
302
|
documentation: this.pobjson.documentation,
|
|
303
|
+
testing: !!this.pobjson.testing,
|
|
294
304
|
});
|
|
295
305
|
|
|
296
306
|
this.composeWith('pob:core:npm', {
|
|
@@ -146,19 +146,16 @@ export default class LibDocGenerator extends Generator {
|
|
|
146
146
|
// },
|
|
147
147
|
// );
|
|
148
148
|
|
|
149
|
+
if (pkg.scripts) {
|
|
150
|
+
delete pkg.scripts['generate:docs'];
|
|
151
|
+
}
|
|
152
|
+
|
|
149
153
|
if (this.options.enabled) {
|
|
150
154
|
packageUtils.addScripts(pkg, {
|
|
151
|
-
'generate:docs':
|
|
152
|
-
'rm -Rf docs ; yarn run generate:api ; touch docs/.nojekyll',
|
|
153
155
|
'generate:api': 'typedoc --tsconfig tsconfig.doc.json',
|
|
154
156
|
});
|
|
155
|
-
|
|
156
|
-
if (this.options.testing && (!inLerna || !inLerna.root)) {
|
|
157
|
-
pkg.scripts['generate:docs'] += ' && yarn run generate:test-coverage';
|
|
158
|
-
}
|
|
159
157
|
} else {
|
|
160
158
|
delete pkg.scripts['generate:api'];
|
|
161
|
-
delete pkg.scripts['generate:docs'];
|
|
162
159
|
}
|
|
163
160
|
|
|
164
161
|
this.fs.writeJSON(this.destinationPath('package.json'), pkg);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
1
2
|
import fs from 'fs';
|
|
2
3
|
import path from 'path';
|
|
3
4
|
import { PackageGraph } from '@lerna/package-graph';
|
|
@@ -214,10 +215,24 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
214
215
|
packagePaths: JSON.stringify(packagePaths),
|
|
215
216
|
packageManager: this.options.packageManager,
|
|
216
217
|
});
|
|
218
|
+
|
|
219
|
+
this.composeWith('pob:core:vscode', {
|
|
220
|
+
root: true,
|
|
221
|
+
monorepo: true,
|
|
222
|
+
packageManager: this.options.packageManager,
|
|
223
|
+
yarnNodeLinker: this.options.yarnNodeLinker,
|
|
224
|
+
typescript: this.pobLernaConfig.typescript,
|
|
225
|
+
testing: this.pobLernaConfig.testing,
|
|
226
|
+
packageNames: JSON.stringify(packageNames),
|
|
227
|
+
packageLocations: JSON.stringify(this.packageLocations),
|
|
228
|
+
});
|
|
229
|
+
|
|
217
230
|
// Always add a gitignore, because npm publish uses it.
|
|
218
231
|
this.composeWith('pob:core:gitignore', {
|
|
219
232
|
root: true,
|
|
220
233
|
typescript: this.pobLernaConfig.typescript,
|
|
234
|
+
documentation: this.pobLernaConfig.documentation,
|
|
235
|
+
testing: this.pobLernaConfig.testing,
|
|
221
236
|
});
|
|
222
237
|
|
|
223
238
|
this.composeWith('pob:common:remove-old-dependencies');
|
|
@@ -229,13 +244,11 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
229
244
|
packagePaths: JSON.stringify(packagePaths),
|
|
230
245
|
});
|
|
231
246
|
|
|
232
|
-
if (this.pobLernaConfig.documentation) {
|
|
233
|
-
pkg.scripts.build = `${
|
|
234
|
-
pkg.scripts.build ? `${pkg.scripts.build} && ` : ''
|
|
235
|
-
}yarn run generate:docs`;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
247
|
this.fs.writeJSON(this.destinationPath('package.json'), pkg);
|
|
248
|
+
|
|
249
|
+
execSync(
|
|
250
|
+
`rm -Rf ${['lib-*', 'coverage', 'docs'].filter(Boolean).join(' ')}`,
|
|
251
|
+
);
|
|
239
252
|
}
|
|
240
253
|
|
|
241
254
|
end() {
|
|
@@ -61,9 +61,7 @@ export default class MonorepoTypescriptGenerator extends Generator {
|
|
|
61
61
|
delete pkg.scripts.postbuild;
|
|
62
62
|
|
|
63
63
|
if (!this.options.isAppProject) {
|
|
64
|
-
pkg.scripts.build +=
|
|
65
|
-
pkg.scripts['generate:docs'] ? ' && yarn run generate:docs' : ''
|
|
66
|
-
}`;
|
|
64
|
+
pkg.scripts.build += ' && yarn run build:definitions';
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
const packagePaths = JSON.parse(this.options.packagePaths);
|
|
@@ -149,15 +149,6 @@ export default class PobBaseGenerator extends Generator {
|
|
|
149
149
|
app: this.projectConfig.type === 'app',
|
|
150
150
|
});
|
|
151
151
|
|
|
152
|
-
const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
|
|
153
|
-
|
|
154
|
-
this.composeWith('pob:core:vscode', {
|
|
155
|
-
root: this.isRoot,
|
|
156
|
-
packageManager: this.projectConfig.packageManager,
|
|
157
|
-
yarnNodeLinker: this.projectConfig.yarnNodeLinker,
|
|
158
|
-
typescript: !!(pkg.devDependencies && pkg.devDependencies.typescript),
|
|
159
|
-
});
|
|
160
|
-
|
|
161
152
|
this.composeWith('pob:core:yarn', {
|
|
162
153
|
type: this.projectConfig.type,
|
|
163
154
|
enable: this.isRoot && this.projectConfig.packageManager === 'yarn',
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import prettier from 'prettier';
|
|
2
2
|
|
|
3
|
-
export function writeAndFormat(fs, destinationPath, content) {
|
|
3
|
+
export function writeAndFormat(fs, destinationPath, content, { parser } = {}) {
|
|
4
4
|
fs.write(
|
|
5
5
|
destinationPath,
|
|
6
6
|
prettier.format(content, {
|
|
7
|
+
parser,
|
|
7
8
|
filepath: destinationPath,
|
|
8
9
|
trailingComma: 'all',
|
|
9
10
|
singleQuote: true,
|
|
@@ -13,7 +14,10 @@ export function writeAndFormat(fs, destinationPath, content) {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export function writeAndFormatJson(fs, destinationPath, value) {
|
|
16
|
-
writeAndFormat(fs, destinationPath, JSON.stringify(value, null, 2)
|
|
17
|
+
writeAndFormat(fs, destinationPath, JSON.stringify(value, null, 2), {
|
|
18
|
+
// project.code-workspace is json
|
|
19
|
+
parser: destinationPath.endsWith('json') ? undefined : 'json',
|
|
20
|
+
});
|
|
17
21
|
}
|
|
18
22
|
export function copyAndFormatTpl(fs, templatePath, destinationPath, options) {
|
|
19
23
|
fs.copyTpl(templatePath, destinationPath, options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pob",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.14.0",
|
|
4
4
|
"description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"skeleton"
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"@lerna/project": "^4.0.0",
|
|
44
44
|
"@pob/eslint-config": "48.0.5",
|
|
45
45
|
"@pob/eslint-config-typescript": "48.0.6",
|
|
46
|
-
"@pob/eslint-config-typescript-react": "48.0.
|
|
46
|
+
"@pob/eslint-config-typescript-react": "48.0.7",
|
|
47
47
|
"@pob/sort-eslint-config": "^3.0.1",
|
|
48
48
|
"@pob/sort-object": "^4.0.1",
|
|
49
49
|
"@pob/sort-pkg": "^4.0.1",
|
|
50
|
-
"@yarnpkg/parsers": "2.5.0-rc.
|
|
51
|
-
"eslint": "8.
|
|
50
|
+
"@yarnpkg/parsers": "2.5.0-rc.9",
|
|
51
|
+
"eslint": "8.7.0",
|
|
52
52
|
"findup-sync": "^5.0.0",
|
|
53
53
|
"git-remote-url": "^1.0.1",
|
|
54
54
|
"github-username": "^6.0.0",
|
|
@@ -61,11 +61,11 @@
|
|
|
61
61
|
"mem-fs-editor": "9.4.0",
|
|
62
62
|
"minimist-argv": "^1.1.0",
|
|
63
63
|
"parse-author": "^2.0.0",
|
|
64
|
-
"pob-dependencies": "6.
|
|
64
|
+
"pob-dependencies": "6.9.0",
|
|
65
65
|
"prettier": "2.5.1",
|
|
66
66
|
"semver": "^7.3.4",
|
|
67
67
|
"yeoman-environment": "^3.5.1",
|
|
68
68
|
"yeoman-generator": "^5.4.0"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "0c5c353e99cdf592997765ff3f954b73d65df1d0"
|
|
71
71
|
}
|