@quilted/create 0.1.84 → 0.1.86
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 +12 -0
- package/build/cjs/package.cjs +54 -95
- package/build/cjs/shared/prompts.cjs +2 -2
- package/build/esm/package.mjs +55 -96
- package/build/esm/shared/prompts.mjs +2 -2
- package/build/esnext/package.esnext +55 -96
- package/build/esnext/shared/prompts.esnext +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/package.d.ts.map +1 -1
- package/build/typescript/shared.d.ts +1 -1
- package/build/typescript/shared.d.ts.map +1 -1
- package/package.json +1 -1
- package/source/package.ts +92 -158
- package/source/shared/prompts.ts +2 -2
- package/source/shared.ts +4 -0
- package/templates/github/_github/workflows/ci.yml +4 -4
- package/templates/package-simple/README.md +1 -0
- package/templates/package-simple/package.json +51 -0
- package/templates/package-simple/rollup.config.js +3 -0
- package/templates/package-simple/source/index.test.ts +9 -0
- package/templates/package-simple/source/index.ts +3 -0
- package/templates/package-simple/tsconfig.json +10 -0
- package/templates/workspace-simple/_gitignore +13 -0
- package/templates/workspace-simple/_nvmrc +1 -0
- package/templates/workspace-simple/_prettierignore +8 -0
- package/templates/workspace-simple/package.json +26 -0
- package/templates/workspace-simple/tsconfig.json +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @quilted/create
|
|
2
2
|
|
|
3
|
+
## 0.1.86
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`d3e5cc05`](https://github.com/lemonmade/quilt/commit/d3e5cc058cabcf4ad373d79daaf8bc39470a0791) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix creation of packages in simple workspaces
|
|
8
|
+
|
|
9
|
+
## 0.1.85
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`25413301`](https://github.com/lemonmade/quilt/commit/25413301513cdee72156a70ff14095e145cafb91) Thanks [@lemonmade](https://github.com/lemonmade)! - Add simpler package template
|
|
14
|
+
|
|
3
15
|
## 0.1.84
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/build/cjs/package.cjs
CHANGED
|
@@ -50,15 +50,11 @@ async function createProject() {
|
|
|
50
50
|
const args = getArguments();
|
|
51
51
|
if (args['--help']) {
|
|
52
52
|
const additionalOptions = stripIndent["default"]`
|
|
53
|
-
${index.cyan(`--description`)}, ${index.cyan(`--no-description`)}
|
|
53
|
+
${index.cyan(`--description [description]`)}, ${index.cyan(`--no-description`)}
|
|
54
54
|
A short description of the package. If you don’t provide this option, the command will ask
|
|
55
55
|
you for a description later.
|
|
56
56
|
${index.dim(`@see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#description`)}
|
|
57
57
|
|
|
58
|
-
${index.cyan(`--react`)}, ${index.cyan(`--no-react`)}
|
|
59
|
-
Whether this package will use React. If you don’t provide this option, the command
|
|
60
|
-
will ask you about it later.
|
|
61
|
-
|
|
62
58
|
${index.cyan(`--public`)}, ${index.cyan(`--private`)}
|
|
63
59
|
Whether this package will be published for other projects to install. If you do not
|
|
64
60
|
provide this option, the command will ask you about it later.
|
|
@@ -68,9 +64,12 @@ async function createProject() {
|
|
|
68
64
|
this command will try to guess the correct repository to use based on existing packages.
|
|
69
65
|
${index.dim(`@see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#repository`)}
|
|
70
66
|
|
|
71
|
-
${index.cyan(`--registry`)}
|
|
67
|
+
${index.cyan(`--registry [registry]`)}
|
|
72
68
|
The package registry to publish this package to. This option only applies if you create
|
|
73
69
|
a public package. If you do not provide this option, it will use the default NPM registry.
|
|
70
|
+
|
|
71
|
+
${index.cyan(`--react`)}
|
|
72
|
+
Whether this package will use React. Defaults to false.
|
|
74
73
|
`;
|
|
75
74
|
help.printHelp({
|
|
76
75
|
kind: 'package',
|
|
@@ -117,86 +116,36 @@ async function createProject() {
|
|
|
117
116
|
}
|
|
118
117
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
119
118
|
const outputRoot = shared.createOutputTarget(rootDirectory);
|
|
120
|
-
const packageTemplate = shared.loadTemplate('package');
|
|
121
|
-
const workspaceTemplate = shared.loadTemplate('workspace');
|
|
122
|
-
|
|
123
|
-
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
124
|
-
// are needed if we are making a monorepo or not.
|
|
125
|
-
if (!inWorkspace) {
|
|
119
|
+
const packageTemplate = shared.loadTemplate('package-simple');
|
|
120
|
+
const workspaceTemplate = shared.loadTemplate('workspace-simple');
|
|
121
|
+
if (createAsMonorepo) {
|
|
126
122
|
await workspaceTemplate.copy(directory, file => {
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// We need to make some adjustments to the root package.json
|
|
131
|
-
if (file === 'package.json') return false;
|
|
132
|
-
return true;
|
|
123
|
+
// We will adjust the package.json before writing it
|
|
124
|
+
return file !== 'package.json';
|
|
133
125
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
workspacePackageJson.workspaces = [packageGlobRelativeToRoot];
|
|
143
|
-
if (packageManager$1.type === 'pnpm') {
|
|
144
|
-
await outputRoot.write('pnpm-workspace.yaml', await shared.format(`
|
|
145
|
-
packages:
|
|
146
|
-
- '${packageGlobRelativeToRoot}'
|
|
147
|
-
`, {
|
|
148
|
-
as: 'yaml'
|
|
149
|
-
}));
|
|
150
|
-
}
|
|
151
|
-
await outputRoot.write('package.json', await shared.format(JSON.stringify(workspacePackageJson), {
|
|
152
|
-
as: 'json-stringify'
|
|
153
|
-
}));
|
|
154
|
-
} else {
|
|
155
|
-
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([packageTemplate.read('package.json').then(content => JSON.parse(content)), packageTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
156
|
-
const mergedPackageJson = shared.mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
157
|
-
delete mergedPackageJson.workspaces;
|
|
158
|
-
adjustPackageJson(mergedPackageJson, {
|
|
159
|
-
name: shared.toValidPackageName(name),
|
|
160
|
-
description,
|
|
161
|
-
react: useReact,
|
|
162
|
-
isPublic,
|
|
163
|
-
registry: args['--registry']
|
|
164
|
-
});
|
|
165
|
-
await outputRoot.write('package.json', await shared.format(JSON.stringify(mergedPackageJson), {
|
|
166
|
-
as: 'json-stringify'
|
|
167
|
-
}));
|
|
168
|
-
await outputRoot.write('tsconfig.json', await shared.format(JSON.stringify(projectTSConfig), {
|
|
169
|
-
as: 'json'
|
|
126
|
+
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
127
|
+
workspacePackageJson.name = shared.toValidPackageName(name);
|
|
128
|
+
if (packageManager$1.type === 'pnpm') {
|
|
129
|
+
await outputRoot.write('pnpm-workspace.yaml', await shared.format(`
|
|
130
|
+
packages:
|
|
131
|
+
- './packages/*'
|
|
132
|
+
`, {
|
|
133
|
+
as: 'yaml'
|
|
170
134
|
}));
|
|
171
135
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
if (setupExtras.has('vscode')) {
|
|
176
|
-
await shared.loadTemplate('vscode').copy(directory);
|
|
177
|
-
}
|
|
136
|
+
await outputRoot.write('package.json', await shared.format(JSON.stringify(workspacePackageJson), {
|
|
137
|
+
as: 'json-stringify'
|
|
138
|
+
}));
|
|
178
139
|
}
|
|
179
140
|
await packageTemplate.copy(packageDirectory, file => {
|
|
180
|
-
//
|
|
181
|
-
|
|
182
|
-
return partOfMonorepo;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// We need to make some adjustments the project’s package.json, README, and Quilt config
|
|
186
|
-
return file !== 'package.json' && file !== 'quilt.project.ts' && file !== 'README.md';
|
|
141
|
+
// We will adjust the package.json and README.md before writing them
|
|
142
|
+
return file !== 'package.json' && file !== 'README.md';
|
|
187
143
|
});
|
|
188
|
-
let quiltProject = await packageTemplate.read('quilt.project.ts');
|
|
189
|
-
if (!partOfMonorepo) {
|
|
190
|
-
quiltProject = quiltProject.replace('quiltPackage', 'quiltWorkspace, quiltPackage').replace('quiltPackage(', 'quiltWorkspace(), quiltPackage(');
|
|
191
|
-
}
|
|
192
|
-
if (!useReact) {
|
|
193
|
-
quiltProject = quiltProject.replace('quiltPackage()', 'quiltPackage({react: false})');
|
|
194
|
-
}
|
|
195
|
-
await outputRoot.write(path__namespace.join(packageDirectory, 'quilt.project.ts'), await shared.format(quiltProject, {
|
|
196
|
-
as: 'typescript'
|
|
197
|
-
}));
|
|
198
144
|
await outputRoot.write(path__namespace.join(packageDirectory, 'README.md'), (await packageTemplate.read('README.md')).replaceAll('{{name}}', shared.toValidPackageName(name)));
|
|
199
145
|
if (partOfMonorepo) {
|
|
146
|
+
// Add the package to the workspace configuration files
|
|
147
|
+
await Promise.all([tsconfig.addToTsConfig(packageDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager$1.type)]);
|
|
148
|
+
|
|
200
149
|
// Write the package’s package.json (the root one was already created)
|
|
201
150
|
const projectPackageJson = JSON.parse(await packageTemplate.read('package.json'));
|
|
202
151
|
if (repository === false) {
|
|
@@ -229,7 +178,29 @@ async function createProject() {
|
|
|
229
178
|
await outputRoot.write(path__namespace.join(packageDirectory, 'package.json'), await shared.format(JSON.stringify(projectPackageJson), {
|
|
230
179
|
as: 'json-stringify'
|
|
231
180
|
}));
|
|
232
|
-
|
|
181
|
+
} else {
|
|
182
|
+
// Write the package’s package.json by combining elements of the root and
|
|
183
|
+
// package templates
|
|
184
|
+
const [projectPackageJson, workspacePackageJson] = await Promise.all([packageTemplate.read('package.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
185
|
+
const mergedPackageJson = shared.mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
186
|
+
adjustPackageJson(mergedPackageJson, {
|
|
187
|
+
name: shared.toValidPackageName(name),
|
|
188
|
+
description,
|
|
189
|
+
react: useReact,
|
|
190
|
+
isPublic,
|
|
191
|
+
registry: args['--registry']
|
|
192
|
+
});
|
|
193
|
+
await outputRoot.write('package.json', await shared.format(JSON.stringify(mergedPackageJson), {
|
|
194
|
+
as: 'json-stringify'
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
if (!inWorkspace) {
|
|
198
|
+
if (setupExtras.has('github')) {
|
|
199
|
+
await shared.loadTemplate('github').copy(directory);
|
|
200
|
+
}
|
|
201
|
+
if (setupExtras.has('vscode')) {
|
|
202
|
+
await shared.loadTemplate('vscode').copy(directory);
|
|
203
|
+
}
|
|
233
204
|
}
|
|
234
205
|
if (shouldInstall) {
|
|
235
206
|
console.log();
|
|
@@ -316,7 +287,6 @@ function getArguments() {
|
|
|
316
287
|
'--extras': [String],
|
|
317
288
|
'--no-extras': Boolean,
|
|
318
289
|
'--react': Boolean,
|
|
319
|
-
'--no-react': Boolean,
|
|
320
290
|
'--public': Boolean,
|
|
321
291
|
'--private': Boolean,
|
|
322
292
|
'--registry': String,
|
|
@@ -328,9 +298,11 @@ function getArguments() {
|
|
|
328
298
|
return args;
|
|
329
299
|
}
|
|
330
300
|
async function getName(args) {
|
|
331
|
-
|
|
332
|
-
|
|
301
|
+
const {
|
|
302
|
+
_,
|
|
303
|
+
'--name': nameArgument
|
|
333
304
|
} = args;
|
|
305
|
+
let name = nameArgument ?? _[0];
|
|
334
306
|
if (name == null) {
|
|
335
307
|
name = await prompt.prompt({
|
|
336
308
|
type: 'text',
|
|
@@ -420,19 +392,7 @@ async function getPublic(args) {
|
|
|
420
392
|
return isPublic;
|
|
421
393
|
}
|
|
422
394
|
async function getReact(args) {
|
|
423
|
-
|
|
424
|
-
if (args['--react'] || args['--yes']) {
|
|
425
|
-
useReact = true;
|
|
426
|
-
} else if (args['--no-react']) {
|
|
427
|
-
useReact = false;
|
|
428
|
-
} else {
|
|
429
|
-
useReact = await prompt.prompt({
|
|
430
|
-
type: 'confirm',
|
|
431
|
-
message: 'Will this package depend on React?',
|
|
432
|
-
initial: true
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
return useReact;
|
|
395
|
+
return Boolean(args['--react']);
|
|
436
396
|
}
|
|
437
397
|
function adjustPackageJson(packageJson, {
|
|
438
398
|
name,
|
|
@@ -480,7 +440,6 @@ function adjustPackageJson(packageJson, {
|
|
|
480
440
|
delete packageJson.devDependencies['react'];
|
|
481
441
|
delete packageJson.peerDependencies['react'];
|
|
482
442
|
delete packageJson.peerDependenciesMeta['react'];
|
|
483
|
-
packageJson.eslintConfig.extends = packageJson.eslintConfig.extends.filter(extend => !extend.includes('react'));
|
|
484
443
|
}
|
|
485
444
|
return packageJson;
|
|
486
445
|
}
|
|
@@ -27,7 +27,7 @@ var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
|
27
27
|
async function getInWorkspace(argv) {
|
|
28
28
|
if (argv['--in-workspace']) return true;
|
|
29
29
|
if (argv['--not-in-workspace']) return false;
|
|
30
|
-
return fs__namespace.existsSync('
|
|
30
|
+
return fs__namespace.existsSync('pnpm-workspace.yaml');
|
|
31
31
|
}
|
|
32
32
|
async function getCreateAsMonorepo(argv, {
|
|
33
33
|
type,
|
|
@@ -52,7 +52,7 @@ async function getShouldInstall(argv) {
|
|
|
52
52
|
}
|
|
53
53
|
async function getPackageManager(argv, options) {
|
|
54
54
|
const packageManager$1 = await packageManager.getPackageManager(argv['--package-manager']);
|
|
55
|
-
return packageManager.createPackageManagerRunner(packageManager$1 ?? '
|
|
55
|
+
return packageManager.createPackageManagerRunner(packageManager$1 ?? 'pnpm', options);
|
|
56
56
|
}
|
|
57
57
|
const VALID_EXTRAS = new Set(['github', 'vscode']);
|
|
58
58
|
async function getExtrasToSetup(argv, {
|
package/build/esm/package.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { printHelp } from './help.mjs';
|
|
4
|
-
import { toValidPackageName, emptyDirectory,
|
|
4
|
+
import { toValidPackageName, emptyDirectory, format, mergeWorkspaceAndProjectPackageJsons, loadTemplate, relativeDirectoryForDisplay, isEmpty, createOutputTarget } from './shared.mjs';
|
|
5
5
|
import { getInWorkspace, getCreateAsMonorepo, getExtrasToSetup, getShouldInstall, getPackageManager } from './shared/prompts.mjs';
|
|
6
6
|
import { addToTsConfig } from './shared/tsconfig.mjs';
|
|
7
7
|
import { addToPackageManagerWorkspaces } from './shared/package-manager.mjs';
|
|
@@ -28,15 +28,11 @@ async function createProject() {
|
|
|
28
28
|
const args = getArguments();
|
|
29
29
|
if (args['--help']) {
|
|
30
30
|
const additionalOptions = stripIndent`
|
|
31
|
-
${cyan_1(`--description`)}, ${cyan_1(`--no-description`)}
|
|
31
|
+
${cyan_1(`--description [description]`)}, ${cyan_1(`--no-description`)}
|
|
32
32
|
A short description of the package. If you don’t provide this option, the command will ask
|
|
33
33
|
you for a description later.
|
|
34
34
|
${dim_1(`@see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#description`)}
|
|
35
35
|
|
|
36
|
-
${cyan_1(`--react`)}, ${cyan_1(`--no-react`)}
|
|
37
|
-
Whether this package will use React. If you don’t provide this option, the command
|
|
38
|
-
will ask you about it later.
|
|
39
|
-
|
|
40
36
|
${cyan_1(`--public`)}, ${cyan_1(`--private`)}
|
|
41
37
|
Whether this package will be published for other projects to install. If you do not
|
|
42
38
|
provide this option, the command will ask you about it later.
|
|
@@ -46,9 +42,12 @@ async function createProject() {
|
|
|
46
42
|
this command will try to guess the correct repository to use based on existing packages.
|
|
47
43
|
${dim_1(`@see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#repository`)}
|
|
48
44
|
|
|
49
|
-
${cyan_1(`--registry`)}
|
|
45
|
+
${cyan_1(`--registry [registry]`)}
|
|
50
46
|
The package registry to publish this package to. This option only applies if you create
|
|
51
47
|
a public package. If you do not provide this option, it will use the default NPM registry.
|
|
48
|
+
|
|
49
|
+
${cyan_1(`--react`)}
|
|
50
|
+
Whether this package will use React. Defaults to false.
|
|
52
51
|
`;
|
|
53
52
|
printHelp({
|
|
54
53
|
kind: 'package',
|
|
@@ -95,86 +94,36 @@ async function createProject() {
|
|
|
95
94
|
}
|
|
96
95
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
97
96
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
98
|
-
const packageTemplate = loadTemplate('package');
|
|
99
|
-
const workspaceTemplate = loadTemplate('workspace');
|
|
100
|
-
|
|
101
|
-
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
102
|
-
// are needed if we are making a monorepo or not.
|
|
103
|
-
if (!inWorkspace) {
|
|
97
|
+
const packageTemplate = loadTemplate('package-simple');
|
|
98
|
+
const workspaceTemplate = loadTemplate('workspace-simple');
|
|
99
|
+
if (createAsMonorepo) {
|
|
104
100
|
await workspaceTemplate.copy(directory, file => {
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
// We need to make some adjustments to the root package.json
|
|
109
|
-
if (file === 'package.json') return false;
|
|
110
|
-
return true;
|
|
101
|
+
// We will adjust the package.json before writing it
|
|
102
|
+
return file !== 'package.json';
|
|
111
103
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
workspacePackageJson.workspaces = [packageGlobRelativeToRoot];
|
|
121
|
-
if (packageManager.type === 'pnpm') {
|
|
122
|
-
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
123
|
-
packages:
|
|
124
|
-
- '${packageGlobRelativeToRoot}'
|
|
125
|
-
`, {
|
|
126
|
-
as: 'yaml'
|
|
127
|
-
}));
|
|
128
|
-
}
|
|
129
|
-
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
130
|
-
as: 'json-stringify'
|
|
131
|
-
}));
|
|
132
|
-
} else {
|
|
133
|
-
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([packageTemplate.read('package.json').then(content => JSON.parse(content)), packageTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
134
|
-
const mergedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
135
|
-
delete mergedPackageJson.workspaces;
|
|
136
|
-
adjustPackageJson(mergedPackageJson, {
|
|
137
|
-
name: toValidPackageName(name),
|
|
138
|
-
description,
|
|
139
|
-
react: useReact,
|
|
140
|
-
isPublic,
|
|
141
|
-
registry: args['--registry']
|
|
142
|
-
});
|
|
143
|
-
await outputRoot.write('package.json', await format(JSON.stringify(mergedPackageJson), {
|
|
144
|
-
as: 'json-stringify'
|
|
145
|
-
}));
|
|
146
|
-
await outputRoot.write('tsconfig.json', await format(JSON.stringify(projectTSConfig), {
|
|
147
|
-
as: 'json'
|
|
104
|
+
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
105
|
+
workspacePackageJson.name = toValidPackageName(name);
|
|
106
|
+
if (packageManager.type === 'pnpm') {
|
|
107
|
+
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
108
|
+
packages:
|
|
109
|
+
- './packages/*'
|
|
110
|
+
`, {
|
|
111
|
+
as: 'yaml'
|
|
148
112
|
}));
|
|
149
113
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
if (setupExtras.has('vscode')) {
|
|
154
|
-
await loadTemplate('vscode').copy(directory);
|
|
155
|
-
}
|
|
114
|
+
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
115
|
+
as: 'json-stringify'
|
|
116
|
+
}));
|
|
156
117
|
}
|
|
157
118
|
await packageTemplate.copy(packageDirectory, file => {
|
|
158
|
-
//
|
|
159
|
-
|
|
160
|
-
return partOfMonorepo;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// We need to make some adjustments the project’s package.json, README, and Quilt config
|
|
164
|
-
return file !== 'package.json' && file !== 'quilt.project.ts' && file !== 'README.md';
|
|
119
|
+
// We will adjust the package.json and README.md before writing them
|
|
120
|
+
return file !== 'package.json' && file !== 'README.md';
|
|
165
121
|
});
|
|
166
|
-
let quiltProject = await packageTemplate.read('quilt.project.ts');
|
|
167
|
-
if (!partOfMonorepo) {
|
|
168
|
-
quiltProject = quiltProject.replace('quiltPackage', 'quiltWorkspace, quiltPackage').replace('quiltPackage(', 'quiltWorkspace(), quiltPackage(');
|
|
169
|
-
}
|
|
170
|
-
if (!useReact) {
|
|
171
|
-
quiltProject = quiltProject.replace('quiltPackage()', 'quiltPackage({react: false})');
|
|
172
|
-
}
|
|
173
|
-
await outputRoot.write(path.join(packageDirectory, 'quilt.project.ts'), await format(quiltProject, {
|
|
174
|
-
as: 'typescript'
|
|
175
|
-
}));
|
|
176
122
|
await outputRoot.write(path.join(packageDirectory, 'README.md'), (await packageTemplate.read('README.md')).replaceAll('{{name}}', toValidPackageName(name)));
|
|
177
123
|
if (partOfMonorepo) {
|
|
124
|
+
// Add the package to the workspace configuration files
|
|
125
|
+
await Promise.all([addToTsConfig(packageDirectory, outputRoot), addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager.type)]);
|
|
126
|
+
|
|
178
127
|
// Write the package’s package.json (the root one was already created)
|
|
179
128
|
const projectPackageJson = JSON.parse(await packageTemplate.read('package.json'));
|
|
180
129
|
if (repository === false) {
|
|
@@ -207,7 +156,29 @@ async function createProject() {
|
|
|
207
156
|
await outputRoot.write(path.join(packageDirectory, 'package.json'), await format(JSON.stringify(projectPackageJson), {
|
|
208
157
|
as: 'json-stringify'
|
|
209
158
|
}));
|
|
210
|
-
|
|
159
|
+
} else {
|
|
160
|
+
// Write the package’s package.json by combining elements of the root and
|
|
161
|
+
// package templates
|
|
162
|
+
const [projectPackageJson, workspacePackageJson] = await Promise.all([packageTemplate.read('package.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
163
|
+
const mergedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
164
|
+
adjustPackageJson(mergedPackageJson, {
|
|
165
|
+
name: toValidPackageName(name),
|
|
166
|
+
description,
|
|
167
|
+
react: useReact,
|
|
168
|
+
isPublic,
|
|
169
|
+
registry: args['--registry']
|
|
170
|
+
});
|
|
171
|
+
await outputRoot.write('package.json', await format(JSON.stringify(mergedPackageJson), {
|
|
172
|
+
as: 'json-stringify'
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
if (!inWorkspace) {
|
|
176
|
+
if (setupExtras.has('github')) {
|
|
177
|
+
await loadTemplate('github').copy(directory);
|
|
178
|
+
}
|
|
179
|
+
if (setupExtras.has('vscode')) {
|
|
180
|
+
await loadTemplate('vscode').copy(directory);
|
|
181
|
+
}
|
|
211
182
|
}
|
|
212
183
|
if (shouldInstall) {
|
|
213
184
|
console.log();
|
|
@@ -294,7 +265,6 @@ function getArguments() {
|
|
|
294
265
|
'--extras': [String],
|
|
295
266
|
'--no-extras': Boolean,
|
|
296
267
|
'--react': Boolean,
|
|
297
|
-
'--no-react': Boolean,
|
|
298
268
|
'--public': Boolean,
|
|
299
269
|
'--private': Boolean,
|
|
300
270
|
'--registry': String,
|
|
@@ -306,9 +276,11 @@ function getArguments() {
|
|
|
306
276
|
return args;
|
|
307
277
|
}
|
|
308
278
|
async function getName(args) {
|
|
309
|
-
|
|
310
|
-
|
|
279
|
+
const {
|
|
280
|
+
_,
|
|
281
|
+
'--name': nameArgument
|
|
311
282
|
} = args;
|
|
283
|
+
let name = nameArgument ?? _[0];
|
|
312
284
|
if (name == null) {
|
|
313
285
|
name = await prompt({
|
|
314
286
|
type: 'text',
|
|
@@ -398,19 +370,7 @@ async function getPublic(args) {
|
|
|
398
370
|
return isPublic;
|
|
399
371
|
}
|
|
400
372
|
async function getReact(args) {
|
|
401
|
-
|
|
402
|
-
if (args['--react'] || args['--yes']) {
|
|
403
|
-
useReact = true;
|
|
404
|
-
} else if (args['--no-react']) {
|
|
405
|
-
useReact = false;
|
|
406
|
-
} else {
|
|
407
|
-
useReact = await prompt({
|
|
408
|
-
type: 'confirm',
|
|
409
|
-
message: 'Will this package depend on React?',
|
|
410
|
-
initial: true
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
return useReact;
|
|
373
|
+
return Boolean(args['--react']);
|
|
414
374
|
}
|
|
415
375
|
function adjustPackageJson(packageJson, {
|
|
416
376
|
name,
|
|
@@ -458,7 +418,6 @@ function adjustPackageJson(packageJson, {
|
|
|
458
418
|
delete packageJson.devDependencies['react'];
|
|
459
419
|
delete packageJson.peerDependencies['react'];
|
|
460
420
|
delete packageJson.peerDependenciesMeta['react'];
|
|
461
|
-
packageJson.eslintConfig.extends = packageJson.eslintConfig.extends.filter(extend => !extend.includes('react'));
|
|
462
421
|
}
|
|
463
422
|
return packageJson;
|
|
464
423
|
}
|
|
@@ -6,7 +6,7 @@ import { getPackageManager as getPackageManager$1, createPackageManagerRunner }
|
|
|
6
6
|
async function getInWorkspace(argv) {
|
|
7
7
|
if (argv['--in-workspace']) return true;
|
|
8
8
|
if (argv['--not-in-workspace']) return false;
|
|
9
|
-
return fs.existsSync('
|
|
9
|
+
return fs.existsSync('pnpm-workspace.yaml');
|
|
10
10
|
}
|
|
11
11
|
async function getCreateAsMonorepo(argv, {
|
|
12
12
|
type,
|
|
@@ -31,7 +31,7 @@ async function getShouldInstall(argv) {
|
|
|
31
31
|
}
|
|
32
32
|
async function getPackageManager(argv, options) {
|
|
33
33
|
const packageManager = await getPackageManager$1(argv['--package-manager']);
|
|
34
|
-
return createPackageManagerRunner(packageManager ?? '
|
|
34
|
+
return createPackageManagerRunner(packageManager ?? 'pnpm', options);
|
|
35
35
|
}
|
|
36
36
|
const VALID_EXTRAS = new Set(['github', 'vscode']);
|
|
37
37
|
async function getExtrasToSetup(argv, {
|