@quilted/create 0.1.30 → 0.1.32
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 +44 -74
- package/build/cjs/index.cjs +5950 -5408
- package/build/cjs/index2.cjs +21 -27
- package/build/cjs/index3.cjs +32 -32
- package/build/cjs/package.cjs +50 -90
- package/build/cjs/parser-babel.cjs +2 -2
- package/build/cjs/parser-typescript.cjs +2 -2
- package/build/cjs/parser-yaml.cjs +2 -2
- package/build/cjs/{package-manager.cjs → shared/package-manager.cjs} +53 -81
- package/build/cjs/standalone.cjs +2 -2
- package/build/esm/app.mjs +41 -70
- package/build/esm/index.mjs +5954 -5404
- package/build/esm/index2.mjs +5 -5
- package/build/esm/index3.mjs +32 -32
- package/build/esm/package.mjs +47 -86
- package/build/esm/parser-babel.mjs +2 -2
- package/build/esm/parser-typescript.mjs +2 -2
- package/build/esm/parser-yaml.mjs +2 -2
- package/build/esm/{package-manager.mjs → shared/package-manager.mjs} +48 -72
- package/build/esm/standalone.mjs +2 -2
- 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 +4 -4
- package/build/typescript/shared/prompts.d.ts.map +1 -1
- package/package.json +2 -2
- package/source/app.ts +10 -9
- package/source/package.ts +7 -6
- package/source/shared/prompts.ts +6 -2
- package/templates/app-basic/package.json +1 -1
- package/templates/app-single-file/package.json +1 -1
package/build/cjs/package.cjs
CHANGED
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('node:fs');
|
|
4
4
|
var path = require('node:path');
|
|
5
|
-
var node_child_process = require('node:child_process');
|
|
6
5
|
var index = require('./index.cjs');
|
|
7
|
-
var packageManager = require('./package-manager.cjs');
|
|
6
|
+
var packageManager = require('./shared/package-manager.cjs');
|
|
8
7
|
require('node:tty');
|
|
9
|
-
require('node:url');
|
|
10
8
|
require('node:readline');
|
|
11
9
|
require('node:events');
|
|
10
|
+
require('node:child_process');
|
|
11
|
+
require('node:url');
|
|
12
12
|
|
|
13
|
-
function
|
|
14
|
-
if (e && e.__esModule) return e;
|
|
13
|
+
function _interopNamespaceDefault(e) {
|
|
15
14
|
var n = Object.create(null);
|
|
16
15
|
if (e) {
|
|
17
16
|
Object.keys(e).forEach(function (k) {
|
|
@@ -28,41 +27,32 @@ function _interopNamespace(e) {
|
|
|
28
27
|
return Object.freeze(n);
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
var fs__namespace = /*#__PURE__*/
|
|
32
|
-
var path__namespace = /*#__PURE__*/
|
|
30
|
+
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
31
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
33
32
|
|
|
34
|
-
let _ = t => t,
|
|
35
|
-
_t,
|
|
36
|
-
_t2,
|
|
37
|
-
_t3,
|
|
38
|
-
_t4;
|
|
39
33
|
async function createProject() {
|
|
40
34
|
const args = getArguments();
|
|
41
|
-
|
|
42
35
|
if (args['--help']) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const additionalOptions = index.stripIndent(_t || (_t = _`
|
|
46
|
-
${0}, ${0}
|
|
36
|
+
const additionalOptions = index.stripIndent`
|
|
37
|
+
${index.cyan_1(`--react`)}, ${index.cyan_1(`--no-react`)}
|
|
47
38
|
Whether this package will use React. If you don’t provide this option, the command
|
|
48
39
|
will ask you about it later.
|
|
49
40
|
|
|
50
|
-
${
|
|
41
|
+
${index.cyan_1(`--public`)}, ${index.cyan_1(`--private`)}
|
|
51
42
|
Whether this package will be published for other projects to install. If you do not
|
|
52
43
|
provide this option, the command will ask you about it later.
|
|
53
44
|
|
|
54
|
-
${
|
|
45
|
+
${index.cyan_1(`--registry`)}
|
|
55
46
|
The package registry to publish this package to. This option only applies if you create
|
|
56
47
|
a public package. If you do not provide this option, it will use the default NPM registry.
|
|
57
|
-
|
|
48
|
+
`;
|
|
58
49
|
index.printHelp({
|
|
59
50
|
kind: 'package',
|
|
60
51
|
options: additionalOptions,
|
|
61
|
-
packageManager:
|
|
52
|
+
packageManager: args['--package-manager']?.toLowerCase()
|
|
62
53
|
});
|
|
63
54
|
return;
|
|
64
55
|
}
|
|
65
|
-
|
|
66
56
|
const inWorkspace = fs__namespace.existsSync('quilt.workspace.ts');
|
|
67
57
|
const name = await getName(args);
|
|
68
58
|
const directory = await getDirectory(args, {
|
|
@@ -73,16 +63,16 @@ async function createProject() {
|
|
|
73
63
|
const useReact = await getReact(args);
|
|
74
64
|
const createAsMonorepo = !inWorkspace && (await packageManager.getCreateAsMonorepo(args));
|
|
75
65
|
const shouldInstall = await packageManager.getShouldInstall(args);
|
|
76
|
-
const packageManager$1 = await packageManager.getPackageManager(args
|
|
66
|
+
const packageManager$1 = await packageManager.getPackageManager(args, {
|
|
67
|
+
root: directory
|
|
68
|
+
});
|
|
77
69
|
const setupExtras = await packageManager.getExtrasToSetup(args, {
|
|
78
70
|
inWorkspace
|
|
79
71
|
});
|
|
80
72
|
const partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
81
73
|
const packageDirectory = createAsMonorepo ? path__namespace.join(directory, `packages/${packageManager.toValidPackageName(name.split('/').pop())}`) : directory;
|
|
82
|
-
|
|
83
74
|
if (fs__namespace.existsSync(directory)) {
|
|
84
75
|
await packageManager.emptyDirectory(directory);
|
|
85
|
-
|
|
86
76
|
if (packageDirectory !== directory) {
|
|
87
77
|
fs__namespace.mkdirSync(packageDirectory, {
|
|
88
78
|
recursive: true
|
|
@@ -93,28 +83,29 @@ async function createProject() {
|
|
|
93
83
|
recursive: true
|
|
94
84
|
});
|
|
95
85
|
}
|
|
96
|
-
|
|
97
86
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
98
87
|
const outputRoot = packageManager.createOutputTarget(rootDirectory);
|
|
99
88
|
const packageTemplate = packageManager.loadTemplate('package');
|
|
100
89
|
const workspaceTemplate = packageManager.loadTemplate('workspace');
|
|
101
|
-
let quiltProject = await packageTemplate.read('quilt.project.ts');
|
|
102
|
-
// are needed if we are making a monorepo or not.
|
|
90
|
+
let quiltProject = await packageTemplate.read('quilt.project.ts');
|
|
103
91
|
|
|
92
|
+
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
93
|
+
// are needed if we are making a monorepo or not.
|
|
104
94
|
if (!inWorkspace) {
|
|
105
95
|
await workspaceTemplate.copy(directory, file => {
|
|
106
96
|
// When this is a single project, we use the project’s Quilt configuration as the base.
|
|
107
|
-
if (file === 'quilt.workspace.ts') return createAsMonorepo;
|
|
97
|
+
if (file === 'quilt.workspace.ts') return createAsMonorepo;
|
|
108
98
|
|
|
99
|
+
// We need to make some adjustments to the root package.json
|
|
109
100
|
return file !== 'package.json';
|
|
110
|
-
});
|
|
111
|
-
// package manager workspace configuration.
|
|
101
|
+
});
|
|
112
102
|
|
|
103
|
+
// If we are creating a monorepo, we need to add the root package.json and
|
|
104
|
+
// package manager workspace configuration.
|
|
113
105
|
if (createAsMonorepo) {
|
|
114
106
|
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
115
107
|
workspacePackageJson.name = packageManager.toValidPackageName(name);
|
|
116
|
-
|
|
117
|
-
if (packageManager$1 === 'pnpm') {
|
|
108
|
+
if (packageManager$1.type === 'pnpm') {
|
|
118
109
|
await outputRoot.write('pnpm-workspace.yaml', await packageManager.format(`
|
|
119
110
|
packages:
|
|
120
111
|
- './packages/*'
|
|
@@ -124,7 +115,6 @@ async function createProject() {
|
|
|
124
115
|
} else {
|
|
125
116
|
workspacePackageJson.workspaces = ['packages/*'];
|
|
126
117
|
}
|
|
127
|
-
|
|
128
118
|
await outputRoot.write('package.json', await packageManager.format(JSON.stringify(workspacePackageJson), {
|
|
129
119
|
as: 'json-stringify'
|
|
130
120
|
}));
|
|
@@ -132,21 +122,20 @@ async function createProject() {
|
|
|
132
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))]);
|
|
133
123
|
workspacePackageJson.eslintConfig = projectPackageJson.eslintConfig;
|
|
134
124
|
workspacePackageJson.browserslist = projectPackageJson.browserslist;
|
|
135
|
-
const newPackageJson = {};
|
|
136
|
-
// the preferred ordering (dependencies, peer dependencies, dev dependencies).
|
|
125
|
+
const newPackageJson = {};
|
|
137
126
|
|
|
127
|
+
// We want to put the project’s dependencies in the package.json, respecting
|
|
128
|
+
// the preferred ordering (dependencies, peer dependencies, dev dependencies).
|
|
138
129
|
for (const [key, value] of Object.entries(projectPackageJson)) {
|
|
139
130
|
if (key !== 'devDependencies') {
|
|
140
131
|
newPackageJson[key] = value;
|
|
141
132
|
continue;
|
|
142
133
|
}
|
|
143
|
-
|
|
144
134
|
newPackageJson.dependencies = projectPackageJson.dependencies;
|
|
145
135
|
newPackageJson.peerDependencies = projectPackageJson.peerDependencies;
|
|
146
136
|
newPackageJson.peerDependenciesMeta = projectPackageJson.peerDependenciesMeta;
|
|
147
137
|
newPackageJson.devDependencies = packageManager.mergeDependencies(workspacePackageJson.devDependencies, projectPackageJson.devDependencies);
|
|
148
138
|
}
|
|
149
|
-
|
|
150
139
|
adjustPackageJson(newPackageJson, {
|
|
151
140
|
name: packageManager.toValidPackageName(name),
|
|
152
141
|
react: useReact,
|
|
@@ -164,26 +153,22 @@ async function createProject() {
|
|
|
164
153
|
as: 'json'
|
|
165
154
|
}));
|
|
166
155
|
}
|
|
167
|
-
|
|
168
156
|
if (setupExtras.has('github')) {
|
|
169
157
|
await packageManager.loadTemplate('github').copy(directory);
|
|
170
158
|
}
|
|
171
|
-
|
|
172
159
|
if (setupExtras.has('vscode')) {
|
|
173
160
|
await packageManager.loadTemplate('vscode').copy(directory);
|
|
174
161
|
}
|
|
175
162
|
}
|
|
176
|
-
|
|
177
163
|
await packageTemplate.copy(packageDirectory, file => {
|
|
178
164
|
// If we are in a monorepo, we can use all the template files as they are
|
|
179
165
|
if (file === 'tsconfig.json') {
|
|
180
166
|
return partOfMonorepo;
|
|
181
|
-
}
|
|
182
|
-
|
|
167
|
+
}
|
|
183
168
|
|
|
169
|
+
// We need to make some adjustments the project’s package.json and Quilt config
|
|
184
170
|
return file !== 'package.json' && file !== 'quilt.project.ts';
|
|
185
171
|
});
|
|
186
|
-
|
|
187
172
|
if (partOfMonorepo) {
|
|
188
173
|
// Write the package’s package.json (the root one was already created)
|
|
189
174
|
const projectPackageJson = JSON.parse(await packageTemplate.read('package.json'));
|
|
@@ -198,68 +183,61 @@ async function createProject() {
|
|
|
198
183
|
as: 'json-stringify'
|
|
199
184
|
}));
|
|
200
185
|
await outputRoot.write(path__namespace.join(packageDirectory, 'quilt.project.ts'), quiltProject);
|
|
201
|
-
await Promise.all([packageManager.addToTsConfig(packageDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager$1)]);
|
|
186
|
+
await Promise.all([packageManager.addToTsConfig(packageDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager$1.type)]);
|
|
202
187
|
}
|
|
203
|
-
|
|
204
188
|
if (shouldInstall) {
|
|
205
|
-
process.stdout.write('\nInstalling dependencies...\n');
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
cwd: rootDirectory
|
|
209
|
-
});
|
|
189
|
+
process.stdout.write('\nInstalling dependencies...\n');
|
|
190
|
+
// TODO: better loading, handle errors
|
|
191
|
+
await packageManager$1.install();
|
|
210
192
|
process.stdout.moveCursor(0, -1);
|
|
211
193
|
process.stdout.clearLine(1);
|
|
212
194
|
console.log('Installed dependencies.');
|
|
213
195
|
}
|
|
214
|
-
|
|
215
|
-
const packageJsonInstructions = index.stripIndent(_t2 || (_t2 = _`
|
|
196
|
+
const packageJsonInstructions = index.stripIndent`
|
|
216
197
|
Your new package is ready to go! However, before you go too much further,
|
|
217
|
-
you should update the following fields in ${
|
|
198
|
+
you should update the following fields in ${index.cyan_1(packageManager.relativeDirectoryForDisplay(path__namespace.relative(process.cwd(), path__namespace.join(packageDirectory, 'package.json'))))}:
|
|
218
199
|
|
|
219
|
-
- ${
|
|
220
|
-
- ${
|
|
200
|
+
- ${index.bold_1(`"description"`)}, where you provide a description of what your package does
|
|
201
|
+
- ${index.bold_1(`"repository"`)}, where you should include the ${index.bold_1(`"url"`)} of your project’s repo
|
|
221
202
|
|
|
222
|
-
Before you publish your package, you will also want to update the ${
|
|
203
|
+
Before you publish your package, you will also want to update the ${index.bold_1(`"version"`)}
|
|
223
204
|
field in the package.json file.
|
|
224
|
-
|
|
205
|
+
`;
|
|
225
206
|
console.log();
|
|
226
207
|
console.log(packageJsonInstructions);
|
|
227
208
|
const commands = [];
|
|
228
|
-
|
|
229
209
|
if (!inWorkspace && directory !== process.cwd()) {
|
|
230
210
|
commands.push(`cd ${index.cyan_1(packageManager.relativeDirectoryForDisplay(path__namespace.relative(process.cwd(), directory)))} ${index.dim_1('# Move into your new package’s directory')}`);
|
|
231
211
|
}
|
|
232
|
-
|
|
233
212
|
if (!shouldInstall) {
|
|
234
|
-
commands.push(
|
|
213
|
+
commands.push(`${packageManager$1.commands.install()} ${index.dim_1('# Install all your dependencies')}`);
|
|
235
214
|
}
|
|
236
|
-
|
|
237
215
|
if (!inWorkspace) {
|
|
238
216
|
// TODO: change this condition to check if git was initialized already
|
|
239
217
|
commands.push(`git init && git add -A && git commit -m "Initial commit" ${index.dim_1('# Start your git history (optional)')}`);
|
|
240
218
|
}
|
|
241
|
-
|
|
242
219
|
if (commands.length > 0) {
|
|
243
|
-
const whatsNext = index.stripIndent
|
|
244
|
-
After you update your package.json, there’s ${
|
|
220
|
+
const whatsNext = index.stripIndent`
|
|
221
|
+
After you update your package.json, there’s ${commands.length > 1 ? 'a few more steps' : 'one more step'} you’ll need to take
|
|
245
222
|
in order to start building:
|
|
246
|
-
|
|
223
|
+
`;
|
|
247
224
|
console.log();
|
|
248
225
|
console.log(whatsNext);
|
|
249
226
|
console.log();
|
|
250
227
|
console.log(commands.map(command => ` ${command}`).join('\n'));
|
|
251
228
|
}
|
|
252
|
-
|
|
253
|
-
const followUp = index.stripIndent(_t4 || (_t4 = _`
|
|
229
|
+
const followUp = index.stripIndent`
|
|
254
230
|
Quilt can help you build, test, lint, and type-check your new package. You
|
|
255
231
|
can learn more about building packages with Quilt by reading the documentation:
|
|
256
|
-
${
|
|
232
|
+
${index.underline_1(index.magenta_1('https://github.com/lemonmade/quilt/tree/main/documentation'))}
|
|
257
233
|
|
|
258
234
|
Have fun! 🎉
|
|
259
|
-
|
|
235
|
+
`;
|
|
260
236
|
console.log();
|
|
261
237
|
console.log(followUp);
|
|
262
|
-
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Argument handling
|
|
263
241
|
|
|
264
242
|
function getArguments() {
|
|
265
243
|
const args = index.parseArguments({
|
|
@@ -286,12 +264,10 @@ function getArguments() {
|
|
|
286
264
|
});
|
|
287
265
|
return args;
|
|
288
266
|
}
|
|
289
|
-
|
|
290
267
|
async function getName(args) {
|
|
291
268
|
let {
|
|
292
269
|
'--name': name
|
|
293
270
|
} = args;
|
|
294
|
-
|
|
295
271
|
if (name == null) {
|
|
296
272
|
name = await index.prompt({
|
|
297
273
|
type: 'text',
|
|
@@ -299,16 +275,13 @@ async function getName(args) {
|
|
|
299
275
|
initial: '@my-team/package'
|
|
300
276
|
});
|
|
301
277
|
}
|
|
302
|
-
|
|
303
278
|
return name;
|
|
304
279
|
}
|
|
305
|
-
|
|
306
280
|
async function getDirectory(args, {
|
|
307
281
|
name,
|
|
308
282
|
inWorkspace
|
|
309
283
|
}) {
|
|
310
284
|
let directory = args['--directory'] ? path__namespace.resolve(args['--directory']) : undefined;
|
|
311
|
-
|
|
312
285
|
if (directory == null) {
|
|
313
286
|
const basePackageName = packageManager.toValidPackageName(name.split('/').pop());
|
|
314
287
|
const defaultDirectory = inWorkspace ? `packages/${basePackageName}` : basePackageName;
|
|
@@ -318,7 +291,6 @@ async function getDirectory(args, {
|
|
|
318
291
|
initial: defaultDirectory
|
|
319
292
|
}));
|
|
320
293
|
}
|
|
321
|
-
|
|
322
294
|
while (!args['--yes']) {
|
|
323
295
|
if (fs__namespace.existsSync(directory) && !(await packageManager.isEmpty(directory))) {
|
|
324
296
|
const relativeDirectory = path__namespace.relative(process.cwd(), directory);
|
|
@@ -337,13 +309,10 @@ async function getDirectory(args, {
|
|
|
337
309
|
break;
|
|
338
310
|
}
|
|
339
311
|
}
|
|
340
|
-
|
|
341
312
|
return directory;
|
|
342
313
|
}
|
|
343
|
-
|
|
344
314
|
async function getPublic(args) {
|
|
345
315
|
let isPublic;
|
|
346
|
-
|
|
347
316
|
if (args['--public'] || args['--yes']) {
|
|
348
317
|
isPublic = true;
|
|
349
318
|
} else if (args['--private']) {
|
|
@@ -355,13 +324,10 @@ async function getPublic(args) {
|
|
|
355
324
|
initial: true
|
|
356
325
|
});
|
|
357
326
|
}
|
|
358
|
-
|
|
359
327
|
return isPublic;
|
|
360
328
|
}
|
|
361
|
-
|
|
362
329
|
async function getReact(args) {
|
|
363
330
|
let useReact;
|
|
364
|
-
|
|
365
331
|
if (args['--react'] || args['--yes']) {
|
|
366
332
|
useReact = true;
|
|
367
333
|
} else if (args['--no-react']) {
|
|
@@ -373,10 +339,8 @@ async function getReact(args) {
|
|
|
373
339
|
initial: true
|
|
374
340
|
});
|
|
375
341
|
}
|
|
376
|
-
|
|
377
342
|
return useReact;
|
|
378
343
|
}
|
|
379
|
-
|
|
380
344
|
function adjustPackageJson(packageJson, {
|
|
381
345
|
name,
|
|
382
346
|
react,
|
|
@@ -386,20 +350,17 @@ function adjustPackageJson(packageJson, {
|
|
|
386
350
|
packageJson.name = name;
|
|
387
351
|
const packageParts = name.split('/');
|
|
388
352
|
const scope = packageParts[0].startsWith('@') ? packageParts[0] : undefined;
|
|
389
|
-
const finalRegistry = registry
|
|
390
|
-
|
|
353
|
+
const finalRegistry = registry ?? 'https://registry.npmjs.org';
|
|
391
354
|
if (scope) {
|
|
392
355
|
packageJson.publishConfig[`${scope}/registry`] = finalRegistry;
|
|
393
356
|
} else if (registry) {
|
|
394
357
|
packageJson.publishConfig.registry = finalRegistry;
|
|
395
358
|
}
|
|
396
|
-
|
|
397
359
|
if (isPublic) {
|
|
398
360
|
delete packageJson.private;
|
|
399
361
|
} else {
|
|
400
362
|
delete packageJson.publishConfig;
|
|
401
363
|
}
|
|
402
|
-
|
|
403
364
|
if (!react) {
|
|
404
365
|
delete packageJson.dependencies['@types/react'];
|
|
405
366
|
delete packageJson.devDependencies['react'];
|
|
@@ -407,7 +368,6 @@ function adjustPackageJson(packageJson, {
|
|
|
407
368
|
delete packageJson.peerDependenciesMeta['react'];
|
|
408
369
|
packageJson.eslintConfig.extends = packageJson.eslintConfig.extends.filter(extend => !extend.includes('react'));
|
|
409
370
|
}
|
|
410
|
-
|
|
411
371
|
return packageJson;
|
|
412
372
|
}
|
|
413
373
|
|