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