@quilted/create 0.1.31 → 0.1.33
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 +34 -62
- 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 +41 -81
- 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/shared/package-manager.cjs +17 -81
- package/build/cjs/standalone.cjs +2 -2
- package/build/esm/app.mjs +31 -58
- 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 +38 -77
- 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/shared/package-manager.mjs +13 -73
- package/build/esm/standalone.mjs +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/shared/prompts.d.ts +2 -2
- package/build/typescript/shared/prompts.d.ts.map +1 -1
- package/package.json +2 -2
- package/templates/app-basic/package.json +1 -1
- package/templates/app-basic/server.tsx +4 -4
- package/templates/app-single-file/package.json +1 -1
package/build/esm/app.mjs
CHANGED
|
@@ -204,32 +204,24 @@ arg.ArgError = ArgError;
|
|
|
204
204
|
|
|
205
205
|
var arg_1 = arg;
|
|
206
206
|
|
|
207
|
-
let _ = t => t,
|
|
208
|
-
_t,
|
|
209
|
-
_t2,
|
|
210
|
-
_t3;
|
|
211
207
|
async function createApp() {
|
|
212
208
|
const argv = getArgv();
|
|
213
|
-
|
|
214
209
|
if (argv['--help']) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const additionalOptions = stripIndent(_t || (_t = _`
|
|
218
|
-
${0}
|
|
210
|
+
const additionalOptions = stripIndent`
|
|
211
|
+
${cyan_1(`--template`)}
|
|
219
212
|
The template to use for your new application. If you don’t specify a template,
|
|
220
213
|
this command will ask you for one instead. Must be one of the following:
|
|
221
214
|
|
|
222
|
-
- ${
|
|
223
|
-
- ${
|
|
224
|
-
|
|
215
|
+
- ${bold_1('basic')}, a web app with a minimal file structure
|
|
216
|
+
- ${bold_1('single-file')}, an entire web app in a single file
|
|
217
|
+
`;
|
|
225
218
|
printHelp({
|
|
226
219
|
kind: 'app',
|
|
227
220
|
options: additionalOptions,
|
|
228
|
-
packageManager:
|
|
221
|
+
packageManager: argv['--package-manager']?.toLowerCase()
|
|
229
222
|
});
|
|
230
223
|
return;
|
|
231
224
|
}
|
|
232
|
-
|
|
233
225
|
const inWorkspace = fs.existsSync('quilt.workspace.ts');
|
|
234
226
|
const name = await getName(argv, {
|
|
235
227
|
inWorkspace
|
|
@@ -248,10 +240,8 @@ async function createApp() {
|
|
|
248
240
|
});
|
|
249
241
|
const partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
250
242
|
const appDirectory = createAsMonorepo ? path.join(directory, 'app') : directory;
|
|
251
|
-
|
|
252
243
|
if (fs.existsSync(directory)) {
|
|
253
244
|
await emptyDirectory(directory);
|
|
254
|
-
|
|
255
245
|
if (appDirectory !== directory) {
|
|
256
246
|
fs.mkdirSync(appDirectory, {
|
|
257
247
|
recursive: true
|
|
@@ -262,26 +252,27 @@ async function createApp() {
|
|
|
262
252
|
recursive: true
|
|
263
253
|
});
|
|
264
254
|
}
|
|
265
|
-
|
|
266
255
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
267
256
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
268
257
|
const appTemplate = loadTemplate(template === 'basic' ? 'app-basic' : 'app-single-file');
|
|
269
|
-
const workspaceTemplate = loadTemplate('workspace');
|
|
270
|
-
// are needed if we are making a monorepo or not.
|
|
258
|
+
const workspaceTemplate = loadTemplate('workspace');
|
|
271
259
|
|
|
260
|
+
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
261
|
+
// are needed if we are making a monorepo or not.
|
|
272
262
|
if (!inWorkspace) {
|
|
273
263
|
await workspaceTemplate.copy(directory, file => {
|
|
274
264
|
// When this is a single project, we use the project’s Quilt configuration as the base.
|
|
275
|
-
if (file === 'quilt.workspace.ts') return createAsMonorepo;
|
|
265
|
+
if (file === 'quilt.workspace.ts') return createAsMonorepo;
|
|
276
266
|
|
|
267
|
+
// We need to make some adjustments to the root package.json
|
|
277
268
|
return file !== 'package.json';
|
|
278
|
-
});
|
|
279
|
-
// package manager workspace configuration.
|
|
269
|
+
});
|
|
280
270
|
|
|
271
|
+
// If we are creating a monorepo, we need to add the root package.json and
|
|
272
|
+
// package manager workspace configuration.
|
|
281
273
|
if (createAsMonorepo) {
|
|
282
274
|
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
283
275
|
workspacePackageJson.name = toValidPackageName(name);
|
|
284
|
-
|
|
285
276
|
if (packageManager.type === 'pnpm') {
|
|
286
277
|
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
287
278
|
packages:
|
|
@@ -292,7 +283,6 @@ async function createApp() {
|
|
|
292
283
|
} else {
|
|
293
284
|
workspacePackageJson.workspaces = ['packages/*'];
|
|
294
285
|
}
|
|
295
|
-
|
|
296
286
|
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
297
287
|
as: 'json-stringify'
|
|
298
288
|
}));
|
|
@@ -314,26 +304,22 @@ async function createApp() {
|
|
|
314
304
|
as: 'json'
|
|
315
305
|
}));
|
|
316
306
|
}
|
|
317
|
-
|
|
318
307
|
if (setupExtras.has('github')) {
|
|
319
308
|
await loadTemplate('github').copy(directory);
|
|
320
309
|
}
|
|
321
|
-
|
|
322
310
|
if (setupExtras.has('vscode')) {
|
|
323
311
|
await loadTemplate('vscode').copy(directory);
|
|
324
312
|
}
|
|
325
313
|
}
|
|
326
|
-
|
|
327
314
|
await appTemplate.copy(appDirectory, file => {
|
|
328
315
|
// If we are in a monorepo, we can use all the template files as they are
|
|
329
316
|
if (file === 'quilt.project.ts' || file === 'tsconfig.json') {
|
|
330
317
|
return partOfMonorepo;
|
|
331
|
-
}
|
|
332
|
-
|
|
318
|
+
}
|
|
333
319
|
|
|
320
|
+
// We need to make some adjustments the project’s package.json
|
|
334
321
|
return file !== 'package.json';
|
|
335
322
|
});
|
|
336
|
-
|
|
337
323
|
if (partOfMonorepo) {
|
|
338
324
|
// Write the app’s package.json (the root one was already created)
|
|
339
325
|
const projectPackageJson = JSON.parse(await appTemplate.read('package.json'));
|
|
@@ -343,50 +329,46 @@ async function createApp() {
|
|
|
343
329
|
}));
|
|
344
330
|
await Promise.all([addToTsConfig(appDirectory, outputRoot), addToPackageManagerWorkspaces(appDirectory, outputRoot, packageManager.type)]);
|
|
345
331
|
}
|
|
346
|
-
|
|
347
332
|
if (shouldInstall) {
|
|
348
|
-
process.stdout.write('\nInstalling dependencies...\n');
|
|
349
|
-
|
|
333
|
+
process.stdout.write('\nInstalling dependencies...\n');
|
|
334
|
+
// TODO: better loading, handle errors
|
|
350
335
|
await packageManager.install();
|
|
351
336
|
process.stdout.moveCursor(0, -1);
|
|
352
337
|
process.stdout.clearLine(1);
|
|
353
338
|
console.log('Installed dependencies.');
|
|
354
339
|
}
|
|
355
|
-
|
|
356
340
|
const commands = [];
|
|
357
|
-
|
|
358
341
|
if (!inWorkspace && directory !== process.cwd()) {
|
|
359
342
|
commands.push(`cd ${cyan_1(relativeDirectoryForDisplay(path.relative(process.cwd(), directory)))} ${dim_1('# Move into your new app’s directory')}`);
|
|
360
343
|
}
|
|
361
|
-
|
|
362
344
|
if (!shouldInstall) {
|
|
363
345
|
commands.push(`${packageManager.commands.install()} ${dim_1('# Install all your dependencies')}`);
|
|
364
346
|
}
|
|
365
|
-
|
|
366
347
|
if (!inWorkspace) {
|
|
367
348
|
// TODO: change this condition to check if git was initialized already
|
|
368
349
|
commands.push(`git init && git add -A && git commit -m "Initial commit" ${dim_1('# Start your git history (optional)')}`);
|
|
369
350
|
}
|
|
370
|
-
|
|
371
351
|
commands.push(`${packageManager.commands.run('develop')} ${dim_1('# Start the development server')}`);
|
|
372
|
-
const whatsNext = stripIndent
|
|
373
|
-
Your new app is ready to go! There’s just ${
|
|
352
|
+
const whatsNext = stripIndent`
|
|
353
|
+
Your new app is ready to go! There’s just ${commands.length > 1 ? 'a few more steps' : 'one more step'} you’ll need to take
|
|
374
354
|
in order to start developing:
|
|
375
|
-
|
|
355
|
+
`;
|
|
376
356
|
console.log();
|
|
377
357
|
console.log(whatsNext);
|
|
378
358
|
console.log();
|
|
379
359
|
console.log(commands.map(command => ` ${command}`).join('\n'));
|
|
380
|
-
const followUp = stripIndent
|
|
360
|
+
const followUp = stripIndent`
|
|
381
361
|
Quilt can also help you build, test, lint, and type-check your new application.
|
|
382
362
|
You can learn more about building apps with Quilt by reading the documentation:
|
|
383
|
-
${
|
|
363
|
+
${underline_1(magenta_1('https://github.com/lemonmade/quilt/tree/main/documentation'))}
|
|
384
364
|
|
|
385
365
|
Have fun! 🎉
|
|
386
|
-
|
|
366
|
+
`;
|
|
387
367
|
console.log();
|
|
388
368
|
console.log(followUp);
|
|
389
|
-
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Argument handling
|
|
390
372
|
|
|
391
373
|
function getArgv() {
|
|
392
374
|
const argv = arg_1({
|
|
@@ -409,14 +391,12 @@ function getArgv() {
|
|
|
409
391
|
});
|
|
410
392
|
return argv;
|
|
411
393
|
}
|
|
412
|
-
|
|
413
394
|
async function getName(argv, {
|
|
414
395
|
inWorkspace
|
|
415
396
|
}) {
|
|
416
397
|
let {
|
|
417
398
|
'--name': name
|
|
418
399
|
} = argv;
|
|
419
|
-
|
|
420
400
|
if (name == null) {
|
|
421
401
|
name = await prompt({
|
|
422
402
|
type: 'text',
|
|
@@ -424,17 +404,12 @@ async function getName(argv, {
|
|
|
424
404
|
initial: inWorkspace ? 'app' : 'my-quilt-app'
|
|
425
405
|
});
|
|
426
406
|
}
|
|
427
|
-
|
|
428
407
|
return name;
|
|
429
408
|
}
|
|
430
|
-
|
|
431
409
|
async function getDirectory(argv, {
|
|
432
410
|
name
|
|
433
411
|
}) {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
let directory = path.resolve((_argv$Directory = argv['--directory']) !== null && _argv$Directory !== void 0 ? _argv$Directory : toValidPackageName(name));
|
|
437
|
-
|
|
412
|
+
let directory = path.resolve(argv['--directory'] ?? toValidPackageName(name));
|
|
438
413
|
while (!argv['--yes']) {
|
|
439
414
|
if (fs.existsSync(directory) && !(await isEmpty(directory))) {
|
|
440
415
|
const relativeDirectory = path.relative(process.cwd(), directory);
|
|
@@ -453,17 +428,13 @@ async function getDirectory(argv, {
|
|
|
453
428
|
break;
|
|
454
429
|
}
|
|
455
430
|
}
|
|
456
|
-
|
|
457
431
|
return directory;
|
|
458
432
|
}
|
|
459
|
-
|
|
460
433
|
const VALID_TEMPLATES = new Set(['basic', 'single-file']);
|
|
461
|
-
|
|
462
434
|
async function getTemplate(argv) {
|
|
463
435
|
if (argv['--template'] && VALID_TEMPLATES.has(argv['--template'])) {
|
|
464
436
|
return argv['--template'];
|
|
465
437
|
}
|
|
466
|
-
|
|
467
438
|
const template = await prompt({
|
|
468
439
|
type: 'select',
|
|
469
440
|
message: 'What template would you like to use?',
|
|
@@ -474,9 +445,11 @@ async function getTemplate(argv) {
|
|
|
474
445
|
}, {
|
|
475
446
|
title: `${bold_1('Itty-bitty')}, an entire web app in a single file`,
|
|
476
447
|
value: 'single-file'
|
|
477
|
-
}
|
|
448
|
+
}
|
|
449
|
+
// TODO: GraphQL API
|
|
478
450
|
]
|
|
479
451
|
});
|
|
452
|
+
|
|
480
453
|
return template;
|
|
481
454
|
}
|
|
482
455
|
|