@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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
|
+
|
|
9
|
+
## 0.1.31
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`20390858`](https://github.com/lemonmade/quilt/commit/2039085884e75951ff020f63a4fcc94f6d06d135) Thanks [@lemonmade](https://github.com/lemonmade)! - Add package manager running utilities to cli-kit
|
|
14
|
+
|
|
3
15
|
## 0.1.30
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/build/cjs/app.cjs
CHANGED
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('node:fs');
|
|
4
4
|
var path = require('node:path');
|
|
5
|
-
var
|
|
6
|
-
var packageManager = require('./package-manager.cjs');
|
|
5
|
+
var packageManager = require('./shared/package-manager.cjs');
|
|
7
6
|
var index = require('./index.cjs');
|
|
8
7
|
require('node:tty');
|
|
8
|
+
require('node:child_process');
|
|
9
9
|
require('node:url');
|
|
10
10
|
require('node:readline');
|
|
11
11
|
require('node:events');
|
|
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,8 +27,8 @@ 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
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
|
-
|
|
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
|
-
- ${
|
|
246
|
-
- ${
|
|
247
|
-
|
|
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:
|
|
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
|
|
@@ -263,16 +254,16 @@ async function createApp() {
|
|
|
263
254
|
const template = await getTemplate(argv);
|
|
264
255
|
const createAsMonorepo = !inWorkspace && (await packageManager.getCreateAsMonorepo(argv));
|
|
265
256
|
const shouldInstall = await packageManager.getShouldInstall(argv);
|
|
266
|
-
const packageManager$1 = await packageManager.getPackageManager(argv
|
|
257
|
+
const packageManager$1 = await packageManager.getPackageManager(argv, {
|
|
258
|
+
root: directory
|
|
259
|
+
});
|
|
267
260
|
const setupExtras = await packageManager.getExtrasToSetup(argv, {
|
|
268
261
|
inWorkspace
|
|
269
262
|
});
|
|
270
263
|
const partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
271
264
|
const appDirectory = createAsMonorepo ? path__namespace.join(directory, 'app') : directory;
|
|
272
|
-
|
|
273
265
|
if (fs__namespace.existsSync(directory)) {
|
|
274
266
|
await packageManager.emptyDirectory(directory);
|
|
275
|
-
|
|
276
267
|
if (appDirectory !== directory) {
|
|
277
268
|
fs__namespace.mkdirSync(appDirectory, {
|
|
278
269
|
recursive: true
|
|
@@ -283,27 +274,28 @@ async function createApp() {
|
|
|
283
274
|
recursive: true
|
|
284
275
|
});
|
|
285
276
|
}
|
|
286
|
-
|
|
287
277
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
288
278
|
const outputRoot = packageManager.createOutputTarget(rootDirectory);
|
|
289
279
|
const appTemplate = packageManager.loadTemplate(template === 'basic' ? 'app-basic' : 'app-single-file');
|
|
290
|
-
const workspaceTemplate = packageManager.loadTemplate('workspace');
|
|
291
|
-
// are needed if we are making a monorepo or not.
|
|
280
|
+
const workspaceTemplate = packageManager.loadTemplate('workspace');
|
|
292
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.
|
|
293
284
|
if (!inWorkspace) {
|
|
294
285
|
await workspaceTemplate.copy(directory, file => {
|
|
295
286
|
// When this is a single project, we use the project’s Quilt configuration as the base.
|
|
296
|
-
if (file === 'quilt.workspace.ts') return createAsMonorepo;
|
|
287
|
+
if (file === 'quilt.workspace.ts') return createAsMonorepo;
|
|
297
288
|
|
|
289
|
+
// We need to make some adjustments to the root package.json
|
|
298
290
|
return file !== 'package.json';
|
|
299
|
-
});
|
|
300
|
-
// package manager workspace configuration.
|
|
291
|
+
});
|
|
301
292
|
|
|
293
|
+
// If we are creating a monorepo, we need to add the root package.json and
|
|
294
|
+
// package manager workspace configuration.
|
|
302
295
|
if (createAsMonorepo) {
|
|
303
296
|
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
304
297
|
workspacePackageJson.name = packageManager.toValidPackageName(name);
|
|
305
|
-
|
|
306
|
-
if (packageManager$1 === 'pnpm') {
|
|
298
|
+
if (packageManager$1.type === 'pnpm') {
|
|
307
299
|
await outputRoot.write('pnpm-workspace.yaml', await packageManager.format(`
|
|
308
300
|
packages:
|
|
309
301
|
- './packages/*'
|
|
@@ -313,7 +305,6 @@ async function createApp() {
|
|
|
313
305
|
} else {
|
|
314
306
|
workspacePackageJson.workspaces = ['packages/*'];
|
|
315
307
|
}
|
|
316
|
-
|
|
317
308
|
await outputRoot.write('package.json', await packageManager.format(JSON.stringify(workspacePackageJson), {
|
|
318
309
|
as: 'json-stringify'
|
|
319
310
|
}));
|
|
@@ -335,26 +326,22 @@ async function createApp() {
|
|
|
335
326
|
as: 'json'
|
|
336
327
|
}));
|
|
337
328
|
}
|
|
338
|
-
|
|
339
329
|
if (setupExtras.has('github')) {
|
|
340
330
|
await packageManager.loadTemplate('github').copy(directory);
|
|
341
331
|
}
|
|
342
|
-
|
|
343
332
|
if (setupExtras.has('vscode')) {
|
|
344
333
|
await packageManager.loadTemplate('vscode').copy(directory);
|
|
345
334
|
}
|
|
346
335
|
}
|
|
347
|
-
|
|
348
336
|
await appTemplate.copy(appDirectory, file => {
|
|
349
337
|
// If we are in a monorepo, we can use all the template files as they are
|
|
350
338
|
if (file === 'quilt.project.ts' || file === 'tsconfig.json') {
|
|
351
339
|
return partOfMonorepo;
|
|
352
|
-
}
|
|
353
|
-
|
|
340
|
+
}
|
|
354
341
|
|
|
342
|
+
// We need to make some adjustments the project’s package.json
|
|
355
343
|
return file !== 'package.json';
|
|
356
344
|
});
|
|
357
|
-
|
|
358
345
|
if (partOfMonorepo) {
|
|
359
346
|
// Write the app’s package.json (the root one was already created)
|
|
360
347
|
const projectPackageJson = JSON.parse(await appTemplate.read('package.json'));
|
|
@@ -362,56 +349,48 @@ async function createApp() {
|
|
|
362
349
|
await outputRoot.write(path__namespace.join(appDirectory, 'package.json'), await packageManager.format(JSON.stringify(projectPackageJson), {
|
|
363
350
|
as: 'json-stringify'
|
|
364
351
|
}));
|
|
365
|
-
await Promise.all([packageManager.addToTsConfig(appDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(appDirectory, outputRoot, packageManager$1)]);
|
|
352
|
+
await Promise.all([packageManager.addToTsConfig(appDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(appDirectory, outputRoot, packageManager$1.type)]);
|
|
366
353
|
}
|
|
367
|
-
|
|
368
354
|
if (shouldInstall) {
|
|
369
|
-
process.stdout.write('\nInstalling dependencies...\n');
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
cwd: rootDirectory
|
|
373
|
-
});
|
|
355
|
+
process.stdout.write('\nInstalling dependencies...\n');
|
|
356
|
+
// TODO: better loading, handle errors
|
|
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
|
-
const packageManagerRun = command => packageManager$1 === 'npm' ? `npm run ${command}` : `pnpm ${command}`;
|
|
382
|
-
|
|
383
363
|
if (!inWorkspace && directory !== process.cwd()) {
|
|
384
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')}`);
|
|
385
365
|
}
|
|
386
|
-
|
|
387
366
|
if (!shouldInstall) {
|
|
388
|
-
commands.push(`${packageManager$1}
|
|
367
|
+
commands.push(`${packageManager$1.commands.install()} ${packageManager.dim_1('# Install all your dependencies')}`);
|
|
389
368
|
}
|
|
390
|
-
|
|
391
369
|
if (!inWorkspace) {
|
|
392
370
|
// TODO: change this condition to check if git was initialized already
|
|
393
371
|
commands.push(`git init && git add -A && git commit -m "Initial commit" ${packageManager.dim_1('# Start your git history (optional)')}`);
|
|
394
372
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
Your new app is ready to go! There’s just ${0} you’ll need to take
|
|
373
|
+
commands.push(`${packageManager$1.commands.run('develop')} ${packageManager.dim_1('# Start the development server')}`);
|
|
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
|
|
399
376
|
in order to start developing:
|
|
400
|
-
|
|
377
|
+
`;
|
|
401
378
|
console.log();
|
|
402
379
|
console.log(whatsNext);
|
|
403
380
|
console.log();
|
|
404
381
|
console.log(commands.map(command => ` ${command}`).join('\n'));
|
|
405
|
-
const followUp = index.stripIndent
|
|
382
|
+
const followUp = index.stripIndent`
|
|
406
383
|
Quilt can also help you build, test, lint, and type-check your new application.
|
|
407
384
|
You can learn more about building apps with Quilt by reading the documentation:
|
|
408
|
-
${
|
|
385
|
+
${packageManager.underline_1(packageManager.magenta_1('https://github.com/lemonmade/quilt/tree/main/documentation'))}
|
|
409
386
|
|
|
410
387
|
Have fun! 🎉
|
|
411
|
-
|
|
388
|
+
`;
|
|
412
389
|
console.log();
|
|
413
390
|
console.log(followUp);
|
|
414
|
-
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// Argument handling
|
|
415
394
|
|
|
416
395
|
function getArgv() {
|
|
417
396
|
const argv = arg_1({
|
|
@@ -434,14 +413,12 @@ function getArgv() {
|
|
|
434
413
|
});
|
|
435
414
|
return argv;
|
|
436
415
|
}
|
|
437
|
-
|
|
438
416
|
async function getName(argv, {
|
|
439
417
|
inWorkspace
|
|
440
418
|
}) {
|
|
441
419
|
let {
|
|
442
420
|
'--name': name
|
|
443
421
|
} = argv;
|
|
444
|
-
|
|
445
422
|
if (name == null) {
|
|
446
423
|
name = await index.prompt({
|
|
447
424
|
type: 'text',
|
|
@@ -449,17 +426,12 @@ async function getName(argv, {
|
|
|
449
426
|
initial: inWorkspace ? 'app' : 'my-quilt-app'
|
|
450
427
|
});
|
|
451
428
|
}
|
|
452
|
-
|
|
453
429
|
return name;
|
|
454
430
|
}
|
|
455
|
-
|
|
456
431
|
async function getDirectory(argv, {
|
|
457
432
|
name
|
|
458
433
|
}) {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
let directory = path__namespace.resolve((_argv$Directory = argv['--directory']) !== null && _argv$Directory !== void 0 ? _argv$Directory : packageManager.toValidPackageName(name));
|
|
462
|
-
|
|
434
|
+
let directory = path__namespace.resolve(argv['--directory'] ?? packageManager.toValidPackageName(name));
|
|
463
435
|
while (!argv['--yes']) {
|
|
464
436
|
if (fs__namespace.existsSync(directory) && !(await packageManager.isEmpty(directory))) {
|
|
465
437
|
const relativeDirectory = path__namespace.relative(process.cwd(), directory);
|
|
@@ -478,17 +450,13 @@ async function getDirectory(argv, {
|
|
|
478
450
|
break;
|
|
479
451
|
}
|
|
480
452
|
}
|
|
481
|
-
|
|
482
453
|
return directory;
|
|
483
454
|
}
|
|
484
|
-
|
|
485
455
|
const VALID_TEMPLATES = new Set(['basic', 'single-file']);
|
|
486
|
-
|
|
487
456
|
async function getTemplate(argv) {
|
|
488
457
|
if (argv['--template'] && VALID_TEMPLATES.has(argv['--template'])) {
|
|
489
458
|
return argv['--template'];
|
|
490
459
|
}
|
|
491
|
-
|
|
492
460
|
const template = await index.prompt({
|
|
493
461
|
type: 'select',
|
|
494
462
|
message: 'What template would you like to use?',
|
|
@@ -499,9 +467,11 @@ async function getTemplate(argv) {
|
|
|
499
467
|
}, {
|
|
500
468
|
title: `${packageManager.bold_1('Itty-bitty')}, an entire web app in a single file`,
|
|
501
469
|
value: 'single-file'
|
|
502
|
-
}
|
|
470
|
+
}
|
|
471
|
+
// TODO: GraphQL API
|
|
503
472
|
]
|
|
504
473
|
});
|
|
474
|
+
|
|
505
475
|
return template;
|
|
506
476
|
}
|
|
507
477
|
|