@quilted/create 0.1.35 → 0.1.37
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/app.cjs +16 -21
- package/build/cjs/index4.cjs +7635 -0
- package/build/cjs/package.cjs +124 -63
- package/build/cjs/shared/package-manager.cjs +61 -9
- package/build/esm/app.mjs +17 -22
- package/build/esm/index4.mjs +7626 -0
- package/build/esm/package.mjs +126 -65
- package/build/esm/shared/package-manager.mjs +61 -10
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/package.d.ts.map +1 -1
- package/build/typescript/shared/prompts.d.ts +9 -2
- package/build/typescript/shared/prompts.d.ts.map +1 -1
- package/build/typescript/shared.d.ts +1 -0
- package/build/typescript/shared.d.ts.map +1 -1
- package/package.json +2 -1
- package/source/app.ts +19 -28
- package/source/package.ts +174 -102
- package/source/shared/prompts.ts +21 -6
- package/source/shared.ts +69 -7
- package/templates/app-basic/server.tsx +9 -5
- package/templates/package/quilt.project.ts +1 -1
- package/templates/workspace/package.json +4 -0
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
|
-
import { s as stripIndent, c as cyan_1,
|
|
4
|
-
import { g as
|
|
3
|
+
import { s as stripIndent, c as cyan_1, d as dim_1, p as printHelp, b as bold_1, u as underline_1, m as magenta_1, e as parseArguments, a as prompt } from './index.mjs';
|
|
4
|
+
import { g as getInWorkspace, a as getCreateAsMonorepo, d as getExtrasToSetup, e as getShouldInstall, f as getPackageManager, t as toValidPackageName, h as emptyDirectory, r as relativeDirectoryForDisplay, i as format, m as mergeWorkspaceAndProjectPackageJsons, l as loadTemplate, j as addToTsConfig, k as addToPackageManagerWorkspaces, p as isEmpty, q as createOutputTarget } from './shared/package-manager.mjs';
|
|
5
5
|
import 'node:tty';
|
|
6
6
|
import 'node:readline';
|
|
7
7
|
import 'node:events';
|
|
@@ -12,6 +12,11 @@ async function createProject() {
|
|
|
12
12
|
const args = getArguments();
|
|
13
13
|
if (args['--help']) {
|
|
14
14
|
const additionalOptions = stripIndent`
|
|
15
|
+
${cyan_1(`--description`)}, ${cyan_1(`--no-description`)}
|
|
16
|
+
A short description of the package. If you don’t provide this option, the command will ask
|
|
17
|
+
you for a description later.
|
|
18
|
+
${dim_1(`@see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#description`)}
|
|
19
|
+
|
|
15
20
|
${cyan_1(`--react`)}, ${cyan_1(`--no-react`)}
|
|
16
21
|
Whether this package will use React. If you don’t provide this option, the command
|
|
17
22
|
will ask you about it later.
|
|
@@ -20,6 +25,11 @@ async function createProject() {
|
|
|
20
25
|
Whether this package will be published for other projects to install. If you do not
|
|
21
26
|
provide this option, the command will ask you about it later.
|
|
22
27
|
|
|
28
|
+
${cyan_1(`--repository`)}, ${cyan_1(`--no-repository`)}
|
|
29
|
+
The URL of a git repository where your code lives. If you do not provide this option,
|
|
30
|
+
this command will try to guess the correct repository to use based on existing packages.
|
|
31
|
+
${dim_1(`@see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#repository`)}
|
|
32
|
+
|
|
23
33
|
${cyan_1(`--registry`)}
|
|
24
34
|
The package registry to publish this package to. This option only applies if you create
|
|
25
35
|
a public package. If you do not provide this option, it will use the default NPM registry.
|
|
@@ -31,22 +41,30 @@ async function createProject() {
|
|
|
31
41
|
});
|
|
32
42
|
return;
|
|
33
43
|
}
|
|
34
|
-
const inWorkspace = fs.existsSync('quilt.workspace.ts');
|
|
35
44
|
const name = await getName(args);
|
|
45
|
+
const description = await getDescription(args);
|
|
46
|
+
const inWorkspace = await getInWorkspace(args);
|
|
36
47
|
const directory = await getDirectory(args, {
|
|
37
48
|
name,
|
|
38
49
|
inWorkspace
|
|
39
50
|
});
|
|
40
51
|
const isPublic = await getPublic(args);
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
const shouldInstall = await getShouldInstall(args);
|
|
44
|
-
const packageManager = await getPackageManager(args, {
|
|
45
|
-
root: directory
|
|
52
|
+
const repository = await getRepository(args, {
|
|
53
|
+
inWorkspace
|
|
46
54
|
});
|
|
55
|
+
const useReact = await getReact(args);
|
|
56
|
+
const createAsMonorepo = !inWorkspace && (await getCreateAsMonorepo(args, {
|
|
57
|
+
type: 'package'
|
|
58
|
+
}));
|
|
47
59
|
const setupExtras = await getExtrasToSetup(args, {
|
|
48
60
|
inWorkspace
|
|
49
61
|
});
|
|
62
|
+
const shouldInstall = await getShouldInstall(args, {
|
|
63
|
+
type: 'package'
|
|
64
|
+
});
|
|
65
|
+
const packageManager = await getPackageManager(args, {
|
|
66
|
+
root: directory
|
|
67
|
+
});
|
|
50
68
|
const partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
51
69
|
const packageDirectory = createAsMonorepo ? path.join(directory, `packages/${toValidPackageName(name.split('/').pop())}`) : directory;
|
|
52
70
|
if (fs.existsSync(directory)) {
|
|
@@ -66,12 +84,15 @@ async function createProject() {
|
|
|
66
84
|
const packageTemplate = loadTemplate('package');
|
|
67
85
|
const workspaceTemplate = loadTemplate('workspace');
|
|
68
86
|
let quiltProject = await packageTemplate.read('quilt.project.ts');
|
|
87
|
+
if (!useReact) {
|
|
88
|
+
quiltProject = quiltProject.replace('quiltPackage()', 'quiltPackage({react: false})');
|
|
89
|
+
}
|
|
69
90
|
|
|
70
91
|
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
71
92
|
// are needed if we are making a monorepo or not.
|
|
72
93
|
if (!inWorkspace) {
|
|
73
94
|
await workspaceTemplate.copy(directory, file => {
|
|
74
|
-
// When this is a single project, we use the project’s Quilt
|
|
95
|
+
// When this is a single project, we use the project’s Quilt configuration as the base.
|
|
75
96
|
if (file === 'quilt.workspace.ts') return createAsMonorepo;
|
|
76
97
|
|
|
77
98
|
// We need to make some adjustments to the root package.json
|
|
@@ -81,41 +102,28 @@ async function createProject() {
|
|
|
81
102
|
// If we are creating a monorepo, we need to add the root package.json and
|
|
82
103
|
// package manager workspace configuration.
|
|
83
104
|
if (createAsMonorepo) {
|
|
105
|
+
const packageRelativeToRoot = path.relative(rootDirectory, packageDirectory);
|
|
106
|
+
const packageGlobRelativeToRoot = relativeDirectoryForDisplay(path.join(packageRelativeToRoot, '*'));
|
|
84
107
|
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
85
108
|
workspacePackageJson.name = toValidPackageName(name);
|
|
109
|
+
workspacePackageJson.workspaces = [packageGlobRelativeToRoot];
|
|
86
110
|
if (packageManager.type === 'pnpm') {
|
|
87
111
|
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
88
112
|
packages:
|
|
89
|
-
- '
|
|
113
|
+
- '${packageGlobRelativeToRoot}'
|
|
90
114
|
`, {
|
|
91
115
|
as: 'yaml'
|
|
92
116
|
}));
|
|
93
|
-
} else {
|
|
94
|
-
workspacePackageJson.workspaces = ['packages/*'];
|
|
95
117
|
}
|
|
96
118
|
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
97
119
|
as: 'json-stringify'
|
|
98
120
|
}));
|
|
99
121
|
} else {
|
|
100
122
|
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))]);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const newPackageJson = {};
|
|
104
|
-
|
|
105
|
-
// We want to put the project’s dependencies in the package.json, respecting
|
|
106
|
-
// the preferred ordering (dependencies, peer dependencies, dev dependencies).
|
|
107
|
-
for (const [key, value] of Object.entries(projectPackageJson)) {
|
|
108
|
-
if (key !== 'devDependencies') {
|
|
109
|
-
newPackageJson[key] = value;
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
newPackageJson.dependencies = projectPackageJson.dependencies;
|
|
113
|
-
newPackageJson.peerDependencies = projectPackageJson.peerDependencies;
|
|
114
|
-
newPackageJson.peerDependenciesMeta = projectPackageJson.peerDependenciesMeta;
|
|
115
|
-
newPackageJson.devDependencies = mergeDependencies(workspacePackageJson.devDependencies, projectPackageJson.devDependencies);
|
|
116
|
-
}
|
|
117
|
-
adjustPackageJson(newPackageJson, {
|
|
123
|
+
const mergedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
124
|
+
adjustPackageJson(mergedPackageJson, {
|
|
118
125
|
name: toValidPackageName(name),
|
|
126
|
+
description,
|
|
119
127
|
react: useReact,
|
|
120
128
|
isPublic,
|
|
121
129
|
registry: args['--registry']
|
|
@@ -124,7 +132,7 @@ async function createProject() {
|
|
|
124
132
|
await outputRoot.write('quilt.project.ts', await format(quiltProject, {
|
|
125
133
|
as: 'typescript'
|
|
126
134
|
}));
|
|
127
|
-
await outputRoot.write('package.json', await format(JSON.stringify(
|
|
135
|
+
await outputRoot.write('package.json', await format(JSON.stringify(mergedPackageJson), {
|
|
128
136
|
as: 'json-stringify'
|
|
129
137
|
}));
|
|
130
138
|
await outputRoot.write('tsconfig.json', await format(JSON.stringify(projectTSConfig), {
|
|
@@ -150,9 +158,29 @@ async function createProject() {
|
|
|
150
158
|
if (partOfMonorepo) {
|
|
151
159
|
// Write the package’s package.json (the root one was already created)
|
|
152
160
|
const projectPackageJson = JSON.parse(await packageTemplate.read('package.json'));
|
|
153
|
-
|
|
161
|
+
if (repository === false) {
|
|
162
|
+
delete projectPackageJson.repository;
|
|
163
|
+
} else {
|
|
164
|
+
const directory = path.relative(rootDirectory, packageDirectory);
|
|
165
|
+
if (typeof repository === 'string') {
|
|
166
|
+
projectPackageJson.repository = {
|
|
167
|
+
type: 'git',
|
|
168
|
+
url: repository,
|
|
169
|
+
directory
|
|
170
|
+
};
|
|
171
|
+
} else if (repository != null) {
|
|
172
|
+
projectPackageJson.repository = {
|
|
173
|
+
type: 'git',
|
|
174
|
+
...repository,
|
|
175
|
+
directory
|
|
176
|
+
};
|
|
177
|
+
} else {
|
|
178
|
+
projectPackageJson.repository.directory = directory;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
154
181
|
adjustPackageJson(projectPackageJson, {
|
|
155
182
|
name: toValidPackageName(name),
|
|
183
|
+
description,
|
|
156
184
|
react: useReact,
|
|
157
185
|
isPublic,
|
|
158
186
|
registry: args['--registry']
|
|
@@ -164,45 +192,36 @@ async function createProject() {
|
|
|
164
192
|
await Promise.all([addToTsConfig(packageDirectory, outputRoot), addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager.type)]);
|
|
165
193
|
}
|
|
166
194
|
if (shouldInstall) {
|
|
167
|
-
process.stdout.write('\nInstalling dependencies...\n');
|
|
168
195
|
// TODO: better loading, handle errors
|
|
169
196
|
await packageManager.install();
|
|
170
|
-
process.stdout.moveCursor(0, -1);
|
|
171
|
-
process.stdout.clearLine(1);
|
|
172
|
-
console.log('Installed dependencies.');
|
|
173
197
|
}
|
|
174
|
-
const packageJsonInstructions = stripIndent`
|
|
175
|
-
Your new package is ready to go! However, before you go too much further,
|
|
176
|
-
you should update the following fields in ${cyan_1(relativeDirectoryForDisplay(path.relative(process.cwd(), path.join(packageDirectory, 'package.json'))))}:
|
|
177
|
-
|
|
178
|
-
- ${bold_1(`"description"`)}, where you provide a description of what your package does
|
|
179
|
-
- ${bold_1(`"repository"`)}, where you should include the ${bold_1(`"url"`)} of your project’s repo
|
|
180
|
-
|
|
181
|
-
Before you publish your package, you will also want to update the ${bold_1(`"version"`)}
|
|
182
|
-
field in the package.json file.
|
|
183
|
-
`;
|
|
184
198
|
console.log();
|
|
185
|
-
console.log(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (commands.length > 0) {
|
|
198
|
-
const whatsNext = stripIndent`
|
|
199
|
-
After you update your package.json, there’s ${commands.length > 1 ? 'a few more steps' : 'one more step'} you’ll need to take
|
|
200
|
-
in order to start building:
|
|
201
|
-
`;
|
|
202
|
-
console.log();
|
|
203
|
-
console.log(whatsNext);
|
|
199
|
+
console.log(stripIndent`
|
|
200
|
+
Your new package, ${bold_1(name)}, is ready to go! You can edit the code for your package in
|
|
201
|
+
${cyan_1(relativeDirectoryForDisplay(path.relative(process.cwd(), path.join(packageDirectory, 'source'))))}.
|
|
202
|
+
`);
|
|
203
|
+
if (isPublic) {
|
|
204
|
+
const needsPackageJsonKeys = [];
|
|
205
|
+
if (!description) {
|
|
206
|
+
needsPackageJsonKeys.push('description');
|
|
207
|
+
}
|
|
208
|
+
if (repository == null) {
|
|
209
|
+
needsPackageJsonKeys.push('repository.url');
|
|
210
|
+
}
|
|
204
211
|
console.log();
|
|
205
|
-
|
|
212
|
+
if (needsPackageJsonKeys.length > 0) {
|
|
213
|
+
console.log(stripIndent`
|
|
214
|
+
Before you publish your package, you will need to add the ${needsPackageJsonKeys.map(key => bold_1(JSON.stringify(key))).join(' and ')} key${needsPackageJsonKeys.length > 1 ? 's' : ''}
|
|
215
|
+
to ${cyan_1(relativeDirectoryForDisplay(path.relative(process.cwd(), path.join(packageDirectory, 'package.json'))))}. In that same file, make sure the contents of the
|
|
216
|
+
${bold_1('"version"')}, ${bold_1('"exports"')}, and ${bold_1('"license"')} fields are correct for your package.
|
|
217
|
+
`);
|
|
218
|
+
} else {
|
|
219
|
+
console.log(stripIndent`
|
|
220
|
+
Before you publish your package, make sure the content of the
|
|
221
|
+
${bold_1('"version"')}, ${bold_1('exports')}, and ${bold_1('license')} fields in
|
|
222
|
+
${cyan_1(relativeDirectoryForDisplay(path.relative(process.cwd(), path.join(packageDirectory, 'package.json'))))} are correct for your package.
|
|
223
|
+
`);
|
|
224
|
+
}
|
|
206
225
|
}
|
|
207
226
|
const followUp = stripIndent`
|
|
208
227
|
Quilt can help you build, test, lint, and type-check your new package. You
|
|
@@ -223,6 +242,10 @@ function getArguments() {
|
|
|
223
242
|
'-y': '--yes',
|
|
224
243
|
'--name': String,
|
|
225
244
|
'--directory': String,
|
|
245
|
+
'--description': String,
|
|
246
|
+
'--no-description': Boolean,
|
|
247
|
+
'--repository': String,
|
|
248
|
+
'--no-repository': Boolean,
|
|
226
249
|
'--install': Boolean,
|
|
227
250
|
'--no-install': Boolean,
|
|
228
251
|
'--monorepo': Boolean,
|
|
@@ -289,6 +312,36 @@ async function getDirectory(args, {
|
|
|
289
312
|
}
|
|
290
313
|
return directory;
|
|
291
314
|
}
|
|
315
|
+
async function getDescription(args) {
|
|
316
|
+
if (args['--description']) return args['--description'];
|
|
317
|
+
if (args['--no-description']) return false;
|
|
318
|
+
const description = await prompt({
|
|
319
|
+
type: 'text',
|
|
320
|
+
message: 'What is a short description of what this package will do?'
|
|
321
|
+
});
|
|
322
|
+
return description;
|
|
323
|
+
}
|
|
324
|
+
async function getRepository(args, {
|
|
325
|
+
inWorkspace = false
|
|
326
|
+
} = {}) {
|
|
327
|
+
if (args['--repository']) return args['--repository'];
|
|
328
|
+
if (args['--no-repository']) return false;
|
|
329
|
+
if (!inWorkspace) return;
|
|
330
|
+
const {
|
|
331
|
+
globby
|
|
332
|
+
} = await import('./index4.mjs');
|
|
333
|
+
const files = await globby('**/package.json', {
|
|
334
|
+
ignore: ['**/node_modules']
|
|
335
|
+
});
|
|
336
|
+
for (const file of files) {
|
|
337
|
+
try {
|
|
338
|
+
const json = JSON.parse(await fs.promises.readFile(file, 'utf8'));
|
|
339
|
+
if (json.repository) return json.repository;
|
|
340
|
+
} catch {
|
|
341
|
+
// noop
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
292
345
|
async function getPublic(args) {
|
|
293
346
|
let isPublic;
|
|
294
347
|
if (args['--public'] || args['--yes']) {
|
|
@@ -321,6 +374,7 @@ async function getReact(args) {
|
|
|
321
374
|
}
|
|
322
375
|
function adjustPackageJson(packageJson, {
|
|
323
376
|
name,
|
|
377
|
+
description,
|
|
324
378
|
react,
|
|
325
379
|
isPublic,
|
|
326
380
|
registry
|
|
@@ -329,6 +383,11 @@ function adjustPackageJson(packageJson, {
|
|
|
329
383
|
const packageParts = name.split('/');
|
|
330
384
|
const scope = packageParts[0].startsWith('@') ? packageParts[0] : undefined;
|
|
331
385
|
const finalRegistry = registry ?? 'https://registry.npmjs.org';
|
|
386
|
+
if (description) {
|
|
387
|
+
packageJson.description = description;
|
|
388
|
+
} else {
|
|
389
|
+
delete packageJson.description;
|
|
390
|
+
}
|
|
332
391
|
if (scope) {
|
|
333
392
|
packageJson.publishConfig[`${scope}/registry`] = finalRegistry;
|
|
334
393
|
} else if (registry) {
|
|
@@ -336,6 +395,8 @@ function adjustPackageJson(packageJson, {
|
|
|
336
395
|
}
|
|
337
396
|
if (isPublic) {
|
|
338
397
|
delete packageJson.private;
|
|
398
|
+
delete packageJson.license;
|
|
399
|
+
delete packageJson.repository;
|
|
339
400
|
} else {
|
|
340
401
|
delete packageJson.publishConfig;
|
|
341
402
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import require$$0 from 'node:tty';
|
|
2
|
-
import { a as prompt } from '../index.mjs';
|
|
3
1
|
import * as fs from 'node:fs';
|
|
4
2
|
import { existsSync } from 'node:fs';
|
|
3
|
+
import require$$0 from 'node:tty';
|
|
4
|
+
import { a as prompt } from '../index.mjs';
|
|
5
5
|
import { execSync } from 'node:child_process';
|
|
6
6
|
import * as path from 'node:path';
|
|
7
7
|
import { relative } from 'node:path';
|
|
@@ -23,12 +23,14 @@ function createPackageManagerRunner(type, {
|
|
|
23
23
|
},
|
|
24
24
|
async install() {
|
|
25
25
|
execSync(`${type} install`, {
|
|
26
|
-
cwd: root
|
|
26
|
+
cwd: root,
|
|
27
|
+
stdio: 'inherit'
|
|
27
28
|
});
|
|
28
29
|
},
|
|
29
30
|
async run(command, args) {
|
|
30
31
|
execSync(`${type} ${command} ${args.join(' ')}`, {
|
|
31
|
-
cwd: root
|
|
32
|
+
cwd: root,
|
|
33
|
+
stdio: 'inherit'
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
36
|
};
|
|
@@ -153,7 +155,8 @@ async function format(content, {
|
|
|
153
155
|
as: parser
|
|
154
156
|
}) {
|
|
155
157
|
const [{
|
|
156
|
-
format
|
|
158
|
+
format: rootFormat,
|
|
159
|
+
default: prettier
|
|
157
160
|
}, {
|
|
158
161
|
default: babel
|
|
159
162
|
}, {
|
|
@@ -161,6 +164,9 @@ async function format(content, {
|
|
|
161
164
|
}, {
|
|
162
165
|
default: yaml
|
|
163
166
|
}] = await Promise.all([import('../standalone.mjs').then(function (n) { return n.s; }), import('../parser-babel.mjs').then(function (n) { return n.p; }), import('../parser-typescript.mjs').then(function (n) { return n.p; }), import('../parser-yaml.mjs').then(function (n) { return n.p; })]);
|
|
167
|
+
|
|
168
|
+
// CJS workaround
|
|
169
|
+
const format = rootFormat ?? prettier.format;
|
|
164
170
|
return format(content, {
|
|
165
171
|
arrowParens: 'always',
|
|
166
172
|
bracketSpacing: false,
|
|
@@ -181,6 +187,42 @@ function mergeDependencies(first = {}, second = {}) {
|
|
|
181
187
|
}
|
|
182
188
|
return merged;
|
|
183
189
|
}
|
|
190
|
+
const PACKAGE_JSON_DEPENDENCY_KEYS = new Set(['dependencies', 'devDependencies', 'peerDependencies', 'peerDependenciesMeta']);
|
|
191
|
+
|
|
192
|
+
// Merges a project and workspace package.json together, with the following nitpicky preferences:
|
|
193
|
+
//
|
|
194
|
+
// - Take all the project’s fields in the order they appear by default
|
|
195
|
+
// - Merge the relevant dependencies together
|
|
196
|
+
// - Projects don’t come with `scripts` by default, but that should go before the first dependency list
|
|
197
|
+
// - If there are other keys in the workspace package.json, they should go last, in the order they appeared
|
|
198
|
+
function mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson) {
|
|
199
|
+
const newPackageJson = {};
|
|
200
|
+
const seenKeys = new Set();
|
|
201
|
+
let hasHandledScriptsField = workspacePackageJson.scripts != null && projectPackageJson.scripts == null;
|
|
202
|
+
for (const [key, value] of Object.entries(projectPackageJson)) {
|
|
203
|
+
seenKeys.add(key);
|
|
204
|
+
const isDependencyKey = PACKAGE_JSON_DEPENDENCY_KEYS.has(key);
|
|
205
|
+
if (key === 'scripts' || isDependencyKey && !hasHandledScriptsField) {
|
|
206
|
+
newPackageJson.scripts = {
|
|
207
|
+
...workspacePackageJson.scripts,
|
|
208
|
+
...projectPackageJson.scripts
|
|
209
|
+
};
|
|
210
|
+
hasHandledScriptsField = true;
|
|
211
|
+
}
|
|
212
|
+
if (isDependencyKey) {
|
|
213
|
+
newPackageJson[key] = mergeDependencies(value, workspacePackageJson[key]);
|
|
214
|
+
} else {
|
|
215
|
+
newPackageJson[key] = value;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
for (const [key, value] of Object.entries(workspacePackageJson)) {
|
|
219
|
+
if (seenKeys.has(key)) continue;
|
|
220
|
+
// Merged workspace + project package.json means we are not in a monorepo
|
|
221
|
+
if (key === 'workspaces') continue;
|
|
222
|
+
newPackageJson[key] = value;
|
|
223
|
+
}
|
|
224
|
+
return newPackageJson;
|
|
225
|
+
}
|
|
184
226
|
|
|
185
227
|
var colorette = {};
|
|
186
228
|
|
|
@@ -398,7 +440,14 @@ colorette.whiteBright = whiteBright;
|
|
|
398
440
|
colorette.yellow = yellow;
|
|
399
441
|
colorette.yellowBright = yellowBright;
|
|
400
442
|
|
|
401
|
-
async function
|
|
443
|
+
async function getInWorkspace(argv) {
|
|
444
|
+
if (argv['--in-workspace']) return true;
|
|
445
|
+
if (argv['--not-in-workspace']) return false;
|
|
446
|
+
return fs.existsSync('quilt.workspace.ts');
|
|
447
|
+
}
|
|
448
|
+
async function getCreateAsMonorepo(argv, {
|
|
449
|
+
type
|
|
450
|
+
}) {
|
|
402
451
|
let createAsMonorepo;
|
|
403
452
|
if (argv['--monorepo' ]) {
|
|
404
453
|
createAsMonorepo = true;
|
|
@@ -407,13 +456,15 @@ async function getCreateAsMonorepo(argv) {
|
|
|
407
456
|
} else {
|
|
408
457
|
createAsMonorepo = await prompt({
|
|
409
458
|
type: 'confirm',
|
|
410
|
-
message:
|
|
459
|
+
message: `Do you want to create this ${type} as a monorepo, with room for more projects?`,
|
|
411
460
|
initial: true
|
|
412
461
|
});
|
|
413
462
|
}
|
|
414
463
|
return createAsMonorepo;
|
|
415
464
|
}
|
|
416
|
-
async function getShouldInstall(argv
|
|
465
|
+
async function getShouldInstall(argv, {
|
|
466
|
+
type
|
|
467
|
+
}) {
|
|
417
468
|
let shouldInstall;
|
|
418
469
|
if (argv['--install'] || argv['--yes']) {
|
|
419
470
|
shouldInstall = true;
|
|
@@ -422,7 +473,7 @@ async function getShouldInstall(argv) {
|
|
|
422
473
|
} else {
|
|
423
474
|
shouldInstall = await prompt({
|
|
424
475
|
type: 'confirm',
|
|
425
|
-
message:
|
|
476
|
+
message: `Do you want to install dependencies for this ${type} after creating it?`,
|
|
426
477
|
initial: true
|
|
427
478
|
});
|
|
428
479
|
}
|
|
@@ -572,4 +623,4 @@ async function addToWorkspaces(relative, workspaces) {
|
|
|
572
623
|
return [...workspaces, pretty ? relativeDirectoryForDisplay(relative) : relative].sort((patternOne, patternTwo) => patternOne.localeCompare(patternTwo));
|
|
573
624
|
}
|
|
574
625
|
|
|
575
|
-
export {
|
|
626
|
+
export { getCreateAsMonorepo as a, bold_1 as b, cyan_1 as c, getExtrasToSetup as d, getShouldInstall as e, getPackageManager as f, getInWorkspace as g, emptyDirectory as h, format as i, addToTsConfig as j, addToPackageManagerWorkspaces as k, loadTemplate as l, mergeWorkspaceAndProjectPackageJsons as m, dim_1 as n, magenta_1 as o, isEmpty as p, createOutputTarget as q, relativeDirectoryForDisplay as r, toValidPackageName as t, underline_1 as u };
|