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