@d-zero/create-frontend 5.0.0-alpha.24 → 5.0.0-alpha.25
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 +9 -0
- package/index.spec.js +176 -6
- package/package.json +4 -4
- package/plopfile.js +81 -28
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
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
|
+
# [5.0.0-alpha.25](https://github.com/d-zero-dev/frontend-env/compare/v5.0.0-alpha.24...v5.0.0-alpha.25) (2024-10-29)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **create-frontend:** add `--debug` option ([835529e](https://github.com/d-zero-dev/frontend-env/commit/835529e798d634ed75dbb5ec8d7e3e75f58b0fae))
|
|
11
|
+
- **create-frontend:** add interactive mode ([e0cf69d](https://github.com/d-zero-dev/frontend-env/commit/e0cf69daca825b26fd490ea0ea6bc10a3f258c58))
|
|
12
|
+
- **create-frontend:** add settings for `type=burger` ([b755336](https://github.com/d-zero-dev/frontend-env/commit/b755336b704086adcc67af8111a49a0bcb5b82cd))
|
|
13
|
+
- **create-frontend:** add settings for `type=static` ([7298f7e](https://github.com/d-zero-dev/frontend-env/commit/7298f7edbda2cfdf267cd9145686be7cb125587f))
|
|
14
|
+
|
|
6
15
|
# [5.0.0-alpha.24](https://github.com/d-zero-dev/frontend-env/compare/v5.0.0-alpha.23...v5.0.0-alpha.24) (2024-10-24)
|
|
7
16
|
|
|
8
17
|
**Note:** Version bump only for package @d-zero/create-frontend
|
package/index.spec.js
CHANGED
|
@@ -14,14 +14,12 @@ beforeEach((ctx) => {
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
describe('CLI', () => {
|
|
17
|
-
|
|
18
|
-
const dir = path.join(tmpDir, getName(task));
|
|
17
|
+
async function cliTest(dir, type) {
|
|
19
18
|
const { stdout } = await execa(
|
|
20
19
|
'npx',
|
|
21
20
|
[
|
|
22
21
|
'@d-zero/create-frontend',
|
|
23
|
-
'--type',
|
|
24
|
-
'burger',
|
|
22
|
+
...(type ? ['--type', type] : []),
|
|
25
23
|
'--dir',
|
|
26
24
|
dir,
|
|
27
25
|
'--no-install',
|
|
@@ -34,7 +32,101 @@ describe('CLI', () => {
|
|
|
34
32
|
},
|
|
35
33
|
},
|
|
36
34
|
);
|
|
37
|
-
|
|
35
|
+
return stdout.replaceAll(path.sep, '/').split('\n');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
test('npx', async ({ tmpDir, task }) => {
|
|
39
|
+
const dir = path.join(tmpDir, getName(task));
|
|
40
|
+
const actual = await cliTest(dir);
|
|
41
|
+
expect(actual).toStrictEqual([
|
|
42
|
+
`✔ ++ ${dir}/tsconfig.json`,
|
|
43
|
+
`✔ ++ ${dir}/prh.yaml`,
|
|
44
|
+
`✔ ++ ${dir}/package.json`,
|
|
45
|
+
`✔ ++ ${dir}/lint-staged.config.mjs`,
|
|
46
|
+
`✔ ++ ${dir}/eleventy.config.mjs`,
|
|
47
|
+
`✔ ++ ${dir}/cspell.json`,
|
|
48
|
+
`✔ ++ ${dir}/README.md`,
|
|
49
|
+
`✔ ++ ${dir}/CHANGELOG.md`,
|
|
50
|
+
`✔ ++ ${dir}/.textlintrc.js`,
|
|
51
|
+
`✔ ++ ${dir}/.textlintignore`,
|
|
52
|
+
`✔ ++ ${dir}/.stylelintrc`,
|
|
53
|
+
`✔ ++ ${dir}/.pug-lintrc`,
|
|
54
|
+
`✔ ++ ${dir}/.prettierrc.mjs`,
|
|
55
|
+
`✔ ++ ${dir}/.postcssrc.js`,
|
|
56
|
+
`✔ ++ ${dir}/.npmignore`,
|
|
57
|
+
`✔ ++ ${dir}/.markuplintrc`,
|
|
58
|
+
`✔ ++ ${dir}/.gitignore`,
|
|
59
|
+
`✔ ++ ${dir}/.eslintrc.cjs`,
|
|
60
|
+
`✔ ++ ${dir}/.editorconfig`,
|
|
61
|
+
`✔ ++ ${dir}/__assets/htdocs/index.pug`,
|
|
62
|
+
`✔ ++ ${dir}/__assets/htdocs/.eslintrc`,
|
|
63
|
+
`✔ ++ ${dir}/__assets/htdocs/js/script.ts`,
|
|
64
|
+
`✔ ++ ${dir}/__assets/htdocs/css/style.scss`,
|
|
65
|
+
`✔ ++ ${dir}/__assets/htdocs/css/bge-style.scss`,
|
|
66
|
+
`✔ ++ ${dir}/__assets/htdocs/__tmpl/index.pug`,
|
|
67
|
+
`✔ ++ ${dir}/__assets/htdocs/__tmpl/302_form_complete.pug`,
|
|
68
|
+
`✔ ++ ${dir}/__assets/htdocs/__tmpl/301_form_confirm.pug`,
|
|
69
|
+
`✔ ++ ${dir}/__assets/htdocs/__tmpl/300_form_input.pug`,
|
|
70
|
+
`✔ ++ ${dir}/__assets/htdocs/__tmpl/210_blog_index.pug`,
|
|
71
|
+
`✔ ++ ${dir}/__assets/htdocs/__tmpl/200_blog_index.pug`,
|
|
72
|
+
`✔ ++ ${dir}/__assets/htdocs/__tmpl/100_sub.pug`,
|
|
73
|
+
`✔ ++ ${dir}/__assets/htdocs/__tmpl/000_home.pug`,
|
|
74
|
+
`✔ ++ ${dir}/__assets/htdocs/__tmpl/.markuplintrc`,
|
|
75
|
+
`✔ ++ ${dir}/__assets/_libs/.markuplintrc`,
|
|
76
|
+
`✔ ++ ${dir}/__assets/_libs/style/theme/index.scss`,
|
|
77
|
+
`✔ ++ ${dir}/__assets/_libs/style/theme/font.scss`,
|
|
78
|
+
`✔ ++ ${dir}/__assets/_libs/style/theme/dimension.scss`,
|
|
79
|
+
`✔ ++ ${dir}/__assets/_libs/style/theme/color.scss`,
|
|
80
|
+
`✔ ++ ${dir}/__assets/_libs/style/general/img.scss`,
|
|
81
|
+
`✔ ++ ${dir}/__assets/_libs/style/general/button.scss`,
|
|
82
|
+
`✔ ++ ${dir}/__assets/_libs/style/general/body.scss`,
|
|
83
|
+
`✔ ++ ${dir}/__assets/_libs/style/general/all.scss`,
|
|
84
|
+
`✔ ++ ${dir}/__assets/_libs/style/base/root.scss`,
|
|
85
|
+
`✔ ++ ${dir}/__assets/_libs/script/index.ts`,
|
|
86
|
+
`✔ ++ ${dir}/__assets/_libs/mixin/meta.pug`,
|
|
87
|
+
`✔ ++ ${dir}/__assets/_libs/img/bg-repeat-01.gif`,
|
|
88
|
+
`✔ ++ ${dir}/__assets/_libs/img/bg-arrow.svg`,
|
|
89
|
+
`✔ ++ ${dir}/__assets/_libs/data/data.yml`,
|
|
90
|
+
`✔ ++ ${dir}/__assets/_libs/data/blocks.html`,
|
|
91
|
+
`✔ ++ ${dir}/__assets/_libs/data/blocks.cjs`,
|
|
92
|
+
`✔ ++ ${dir}/__assets/_libs/data/bge-blocks.html`,
|
|
93
|
+
`✔ ++ ${dir}/__assets/_libs/data/.markuplintrc`,
|
|
94
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-title-page.scss`,
|
|
95
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-title-page.pug`,
|
|
96
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-pagination.scss`,
|
|
97
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-pagination.pug`,
|
|
98
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-page-sub.scss`,
|
|
99
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-page-home.scss`,
|
|
100
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-nav-sitemap.scss`,
|
|
101
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-nav-sitemap.pug`,
|
|
102
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-nav-global.scss`,
|
|
103
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-nav-global.pug`,
|
|
104
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-nav-breadcrumb.scss`,
|
|
105
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-nav-breadcrumb.pug`,
|
|
106
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-media.scss`,
|
|
107
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-media.pug`,
|
|
108
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-media-list.scss`,
|
|
109
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-header.scss`,
|
|
110
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-header.pug`,
|
|
111
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-footer.scss`,
|
|
112
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-footer.pug`,
|
|
113
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-content-main.scss`,
|
|
114
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-content-index.scss`,
|
|
115
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-card.scss`,
|
|
116
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-card.pug`,
|
|
117
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-card-list.scss`,
|
|
118
|
+
`✔ ++ ${dir}/__assets/_libs/component/bge-content.scss`,
|
|
119
|
+
`✔ ++ ${dir}/.vscode/settings.json`,
|
|
120
|
+
`✔ ++ ${dir}/.vscode/extensions.json`,
|
|
121
|
+
`✔ ++ ${dir}/.husky/pre-commit`,
|
|
122
|
+
'✔ Install dependencies : skipped',
|
|
123
|
+
]);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('npx --type burger', async ({ tmpDir, task }) => {
|
|
127
|
+
const dir = path.join(tmpDir, getName(task));
|
|
128
|
+
const actual = await cliTest(dir, 'burger');
|
|
129
|
+
expect(actual).toStrictEqual([
|
|
38
130
|
`✔ ++ ${dir}/tsconfig.json`,
|
|
39
131
|
`✔ ++ ${dir}/prh.yaml`,
|
|
40
132
|
`✔ ++ ${dir}/package.json`,
|
|
@@ -58,6 +150,7 @@ describe('CLI', () => {
|
|
|
58
150
|
`✔ ++ ${dir}/__assets/htdocs/.eslintrc`,
|
|
59
151
|
`✔ ++ ${dir}/__assets/htdocs/js/script.ts`,
|
|
60
152
|
`✔ ++ ${dir}/__assets/htdocs/css/style.scss`,
|
|
153
|
+
`✔ ++ ${dir}/__assets/htdocs/css/bge-style.scss`,
|
|
61
154
|
`✔ ++ ${dir}/__assets/htdocs/__tmpl/index.pug`,
|
|
62
155
|
`✔ ++ ${dir}/__assets/htdocs/__tmpl/302_form_complete.pug`,
|
|
63
156
|
`✔ ++ ${dir}/__assets/htdocs/__tmpl/301_form_confirm.pug`,
|
|
@@ -84,7 +177,84 @@ describe('CLI', () => {
|
|
|
84
177
|
`✔ ++ ${dir}/__assets/_libs/data/data.yml`,
|
|
85
178
|
`✔ ++ ${dir}/__assets/_libs/data/blocks.html`,
|
|
86
179
|
`✔ ++ ${dir}/__assets/_libs/data/blocks.cjs`,
|
|
87
|
-
`✔ ++ ${dir}/__assets/_libs/data/blocks
|
|
180
|
+
`✔ ++ ${dir}/__assets/_libs/data/bge-blocks.html`,
|
|
181
|
+
`✔ ++ ${dir}/__assets/_libs/data/.markuplintrc`,
|
|
182
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-title-page.scss`,
|
|
183
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-title-page.pug`,
|
|
184
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-pagination.scss`,
|
|
185
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-pagination.pug`,
|
|
186
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-page-sub.scss`,
|
|
187
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-page-home.scss`,
|
|
188
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-nav-sitemap.scss`,
|
|
189
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-nav-sitemap.pug`,
|
|
190
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-nav-global.scss`,
|
|
191
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-nav-global.pug`,
|
|
192
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-nav-breadcrumb.scss`,
|
|
193
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-nav-breadcrumb.pug`,
|
|
194
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-media.scss`,
|
|
195
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-media.pug`,
|
|
196
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-media-list.scss`,
|
|
197
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-header.scss`,
|
|
198
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-header.pug`,
|
|
199
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-footer.scss`,
|
|
200
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-footer.pug`,
|
|
201
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-content-main.scss`,
|
|
202
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-content-index.scss`,
|
|
203
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-card.scss`,
|
|
204
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-card.pug`,
|
|
205
|
+
`✔ ++ ${dir}/__assets/_libs/component/c-card-list.scss`,
|
|
206
|
+
`✔ ++ ${dir}/__assets/_libs/component/bge-content.scss`,
|
|
207
|
+
`✔ ++ ${dir}/.vscode/settings.json`,
|
|
208
|
+
`✔ ++ ${dir}/.vscode/extensions.json`,
|
|
209
|
+
`✔ ++ ${dir}/.husky/pre-commit`,
|
|
210
|
+
'✔ Install dependencies : skipped',
|
|
211
|
+
]);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test('npx --type static', async ({ tmpDir, task }) => {
|
|
215
|
+
const dir = path.join(tmpDir, getName(task));
|
|
216
|
+
const actual = await cliTest(dir, 'static');
|
|
217
|
+
expect(actual).toStrictEqual([
|
|
218
|
+
`✔ ++ ${dir}/tsconfig.json`,
|
|
219
|
+
`✔ ++ ${dir}/prh.yaml`,
|
|
220
|
+
`✔ ++ ${dir}/package.json`,
|
|
221
|
+
`✔ ++ ${dir}/lint-staged.config.mjs`,
|
|
222
|
+
`✔ ++ ${dir}/eleventy.config.mjs`,
|
|
223
|
+
`✔ ++ ${dir}/cspell.json`,
|
|
224
|
+
`✔ ++ ${dir}/README.md`,
|
|
225
|
+
`✔ ++ ${dir}/CHANGELOG.md`,
|
|
226
|
+
`✔ ++ ${dir}/.textlintrc.js`,
|
|
227
|
+
`✔ ++ ${dir}/.textlintignore`,
|
|
228
|
+
`✔ ++ ${dir}/.stylelintrc`,
|
|
229
|
+
`✔ ++ ${dir}/.pug-lintrc`,
|
|
230
|
+
`✔ ++ ${dir}/.prettierrc.mjs`,
|
|
231
|
+
`✔ ++ ${dir}/.postcssrc.js`,
|
|
232
|
+
`✔ ++ ${dir}/.npmignore`,
|
|
233
|
+
`✔ ++ ${dir}/.markuplintrc`,
|
|
234
|
+
`✔ ++ ${dir}/.gitignore`,
|
|
235
|
+
`✔ ++ ${dir}/.eslintrc.cjs`,
|
|
236
|
+
`✔ ++ ${dir}/.editorconfig`,
|
|
237
|
+
`✔ ++ ${dir}/__assets/htdocs/index.pug`,
|
|
238
|
+
`✔ ++ ${dir}/__assets/htdocs/.eslintrc`,
|
|
239
|
+
`✔ ++ ${dir}/__assets/htdocs/js/script.ts`,
|
|
240
|
+
`✔ ++ ${dir}/__assets/htdocs/css/style.scss`,
|
|
241
|
+
`✔ ++ ${dir}/__assets/_libs/.markuplintrc`,
|
|
242
|
+
`✔ ++ ${dir}/__assets/_libs/style/theme/index.scss`,
|
|
243
|
+
`✔ ++ ${dir}/__assets/_libs/style/theme/font.scss`,
|
|
244
|
+
`✔ ++ ${dir}/__assets/_libs/style/theme/dimension.scss`,
|
|
245
|
+
`✔ ++ ${dir}/__assets/_libs/style/theme/color.scss`,
|
|
246
|
+
`✔ ++ ${dir}/__assets/_libs/style/general/img.scss`,
|
|
247
|
+
`✔ ++ ${dir}/__assets/_libs/style/general/button.scss`,
|
|
248
|
+
`✔ ++ ${dir}/__assets/_libs/style/general/body.scss`,
|
|
249
|
+
`✔ ++ ${dir}/__assets/_libs/style/general/all.scss`,
|
|
250
|
+
`✔ ++ ${dir}/__assets/_libs/style/base/root.scss`,
|
|
251
|
+
`✔ ++ ${dir}/__assets/_libs/script/index.ts`,
|
|
252
|
+
`✔ ++ ${dir}/__assets/_libs/mixin/meta.pug`,
|
|
253
|
+
`✔ ++ ${dir}/__assets/_libs/img/bg-repeat-01.gif`,
|
|
254
|
+
`✔ ++ ${dir}/__assets/_libs/img/bg-arrow.svg`,
|
|
255
|
+
`✔ ++ ${dir}/__assets/_libs/data/data.yml`,
|
|
256
|
+
`✔ ++ ${dir}/__assets/_libs/data/blocks.html`,
|
|
257
|
+
`✔ ++ ${dir}/__assets/_libs/data/blocks.cjs`,
|
|
88
258
|
`✔ ++ ${dir}/__assets/_libs/data/.markuplintrc`,
|
|
89
259
|
`✔ ++ ${dir}/__assets/_libs/component/c-title-page.scss`,
|
|
90
260
|
`✔ ++ ${dir}/__assets/_libs/component/c-title-page.pug`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-zero/create-frontend",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.25",
|
|
4
4
|
"description": "Create a new frontend project from a scaffolding template",
|
|
5
5
|
"repository": "https://github.com/d-zero-dev/frontend-env.git",
|
|
6
6
|
"author": "D-ZERO Co., Ltd.",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"create-dzero-frontend": "./index.js"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@d-zero/scaffold": "5.0.0-alpha.
|
|
17
|
+
"@d-zero/scaffold": "5.0.0-alpha.25",
|
|
18
18
|
"glob": "11.0.0",
|
|
19
19
|
"i18n-js": "4.5.0",
|
|
20
20
|
"ignore": "6.0.2",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/glob": "8.1.0",
|
|
26
|
-
"execa": "9.
|
|
26
|
+
"execa": "9.5.0"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "a5e901787293d253e2ba91dac6624cc73f4d60a5"
|
|
29
29
|
}
|
package/plopfile.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
2
3
|
import path from 'node:path';
|
|
4
|
+
import { argv } from 'node:process';
|
|
3
5
|
|
|
4
6
|
import { globSync } from 'glob';
|
|
5
7
|
import ignore from 'ignore';
|
|
@@ -23,6 +25,9 @@ const cli = meow(
|
|
|
23
25
|
Examples
|
|
24
26
|
$ yarn create @d-zero/frontend
|
|
25
27
|
$ yarn create @d-zero/frontend --type cms --dir ./my-cms --install
|
|
28
|
+
|
|
29
|
+
Note
|
|
30
|
+
Running the command without any options will start in interactive mode, allowing you to configure the project step-by-step.
|
|
26
31
|
`,
|
|
27
32
|
{
|
|
28
33
|
importMeta: import.meta,
|
|
@@ -30,15 +35,21 @@ const cli = meow(
|
|
|
30
35
|
type: {
|
|
31
36
|
type: 'string',
|
|
32
37
|
shortFlag: 't',
|
|
38
|
+
default: 'burger',
|
|
33
39
|
},
|
|
34
40
|
dir: {
|
|
35
41
|
type: 'string',
|
|
36
42
|
shortFlag: 'd',
|
|
43
|
+
default: '.',
|
|
37
44
|
},
|
|
38
45
|
install: {
|
|
39
46
|
type: 'boolean',
|
|
40
47
|
default: true,
|
|
41
48
|
},
|
|
49
|
+
debug: {
|
|
50
|
+
type: 'boolean',
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
42
53
|
},
|
|
43
54
|
},
|
|
44
55
|
);
|
|
@@ -53,6 +64,8 @@ export default function (plop) {
|
|
|
53
64
|
|
|
54
65
|
const gitignore = readFileSafe(path.resolve(scaffoldDir, '.gitignore'));
|
|
55
66
|
const ignoreFiles = gitignore?.split('\n').filter(Boolean) ?? [];
|
|
67
|
+
const hasArgs = argv.length > 2;
|
|
68
|
+
const interactive = !hasArgs;
|
|
56
69
|
|
|
57
70
|
const ig = ignore()
|
|
58
71
|
// Ignore files in .gitignore
|
|
@@ -61,7 +74,15 @@ export default function (plop) {
|
|
|
61
74
|
.add([
|
|
62
75
|
// Test directories
|
|
63
76
|
'**/*.test/**/*',
|
|
64
|
-
])
|
|
77
|
+
])
|
|
78
|
+
.add(
|
|
79
|
+
// BurgerEditor
|
|
80
|
+
cli.flags.type === 'burger' ? [] : ['**/bge-*'],
|
|
81
|
+
)
|
|
82
|
+
.add(
|
|
83
|
+
// static
|
|
84
|
+
cli.flags.type === 'static' ? ['**/__tmpl/**/*'] : [],
|
|
85
|
+
);
|
|
65
86
|
|
|
66
87
|
const scaffoldFiles = ig.filter(
|
|
67
88
|
globSync('**/*', {
|
|
@@ -72,9 +93,7 @@ export default function (plop) {
|
|
|
72
93
|
);
|
|
73
94
|
|
|
74
95
|
plop.setActionType('Install dependencies', (answers) => {
|
|
75
|
-
const dest = answers
|
|
76
|
-
const doInstall =
|
|
77
|
-
answers['__d-zero_scaffold_yarn_install__'] ?? cli.flags.install ?? true;
|
|
96
|
+
const { dest, doInstall } = answerToConfig(answers);
|
|
78
97
|
|
|
79
98
|
const { promise, resolve, reject } = Promise.withResolvers();
|
|
80
99
|
|
|
@@ -110,34 +129,43 @@ export default function (plop) {
|
|
|
110
129
|
name: '__d-zero_project_type__',
|
|
111
130
|
message: t`What's the type of project?`,
|
|
112
131
|
choices: [
|
|
113
|
-
|
|
114
|
-
|
|
132
|
+
{
|
|
133
|
+
name: 'Static',
|
|
134
|
+
value: 'static',
|
|
135
|
+
},
|
|
115
136
|
'CMS (WordPress etc.)',
|
|
116
137
|
{
|
|
117
138
|
name: 'CMS (baserCMS with BurgerEditor)',
|
|
118
139
|
value: 'burger',
|
|
119
140
|
},
|
|
120
141
|
],
|
|
121
|
-
default: cli.flags.type
|
|
142
|
+
default: cli.flags.type,
|
|
122
143
|
filter: (val) => val.toLowerCase(),
|
|
123
|
-
when:
|
|
144
|
+
when: interactive,
|
|
124
145
|
},
|
|
125
146
|
{
|
|
126
147
|
type: 'input',
|
|
127
148
|
name: '__d-zero_scaffold_dest__',
|
|
128
149
|
message: t`Destination path`,
|
|
129
|
-
default:
|
|
130
|
-
when:
|
|
150
|
+
default: cli.flags.dir,
|
|
151
|
+
when: interactive,
|
|
131
152
|
},
|
|
132
153
|
{
|
|
133
154
|
type: 'confirm',
|
|
134
155
|
name: '__d-zero_scaffold_yarn_install__',
|
|
135
156
|
message: t`Install dependencies with yarn?`,
|
|
136
|
-
default:
|
|
137
|
-
when:
|
|
157
|
+
default: cli.flags.install,
|
|
158
|
+
when: interactive,
|
|
138
159
|
},
|
|
139
160
|
],
|
|
140
161
|
actions: function (answers) {
|
|
162
|
+
const config = answerToConfig(answers);
|
|
163
|
+
|
|
164
|
+
if (cli.flags.debug) {
|
|
165
|
+
// eslint-disable-next-line no-console
|
|
166
|
+
console.log(config);
|
|
167
|
+
}
|
|
168
|
+
|
|
141
169
|
return [
|
|
142
170
|
...scaffoldFiles.map(
|
|
143
171
|
/**
|
|
@@ -145,26 +173,43 @@ export default function (plop) {
|
|
|
145
173
|
* @type {import('plop').AddActionConfig}
|
|
146
174
|
*/
|
|
147
175
|
(originFile) => {
|
|
148
|
-
const dest = answers['__d-zero_scaffold_dest__'] ?? cli.flags.dir ?? '.';
|
|
149
176
|
return {
|
|
150
177
|
type: 'add',
|
|
151
|
-
path: path.resolve(dest, originFile),
|
|
178
|
+
path: path.resolve(config.dest, originFile),
|
|
152
179
|
templateFile: path.resolve(scaffoldDir, originFile),
|
|
153
180
|
transform(content) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
181
|
+
const nameCandidate = path.basename(path.resolve(config.dest));
|
|
182
|
+
|
|
183
|
+
switch (originFile) {
|
|
184
|
+
case 'package.json': {
|
|
185
|
+
const pkg = JSON.parse(content);
|
|
186
|
+
pkg._createdBy = `${pkg.name}@${pkg.version}`;
|
|
187
|
+
pkg.name = nameCandidate;
|
|
188
|
+
pkg.private = true;
|
|
189
|
+
delete pkg.version;
|
|
190
|
+
delete pkg.description;
|
|
191
|
+
delete pkg.repository;
|
|
192
|
+
delete pkg.author;
|
|
193
|
+
delete pkg.license;
|
|
194
|
+
delete pkg.publishConfig;
|
|
195
|
+
delete pkg.files;
|
|
196
|
+
content = JSON.stringify(pkg, null, '\t');
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
case '__assets/_libs/data/blocks.cjs': {
|
|
200
|
+
if (config.type === 'burger') {
|
|
201
|
+
content = content.replace("blocks.html'", "bge-blocks.html'");
|
|
202
|
+
}
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
case '__assets/htdocs/index.pug': {
|
|
206
|
+
if (config.type === 'static') {
|
|
207
|
+
content = fs.readFileSync(
|
|
208
|
+
path.resolve(scaffoldDir, '__assets/htdocs/__tmpl/000_home.pug'),
|
|
209
|
+
'utf8',
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
168
213
|
}
|
|
169
214
|
return content;
|
|
170
215
|
},
|
|
@@ -178,3 +223,11 @@ export default function (plop) {
|
|
|
178
223
|
},
|
|
179
224
|
});
|
|
180
225
|
}
|
|
226
|
+
|
|
227
|
+
function answerToConfig(answers) {
|
|
228
|
+
const type = answers['__d-zero_project_type__'] ?? cli.flags.type;
|
|
229
|
+
const dest = answers['__d-zero_scaffold_dest__'] ?? cli.flags.dir;
|
|
230
|
+
const doInstall = answers['__d-zero_scaffold_yarn_install__'] ?? cli.flags.install;
|
|
231
|
+
|
|
232
|
+
return { type, dest, doInstall };
|
|
233
|
+
}
|