@quilted/create 0.1.20 → 0.1.21

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.21
4
+
5
+ ### Patch Changes
6
+
7
+ - [`0629288e`](https://github.com/lemonmade/quilt/commit/0629288ee4ba2e2ccfd73fbb216c3559e1a5c77e) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix missing package builds
8
+
3
9
  ## 0.1.20
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node --experimental-vm-modules
2
+ import "../build/esm/index.mjs";
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
+
5
+ function getDefaultExportFromCjs (x) {
6
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
7
+ }
8
+
9
+ exports.commonjsGlobal = commonjsGlobal;
10
+ exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
@@ -0,0 +1,590 @@
1
+ 'use strict';
2
+
3
+ var packageManager = require('./package-manager.cjs');
4
+ var index = require('./index.cjs');
5
+ var fs = require('fs');
6
+ var path = require('path');
7
+ var child_process = require('child_process');
8
+ require('url');
9
+ require('tty');
10
+ require('readline');
11
+ require('events');
12
+
13
+ function _interopNamespace(e) {
14
+ if (e && e.__esModule) return e;
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ Object.keys(e).forEach(function (k) {
18
+ if (k !== 'default') {
19
+ var d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: function () { return e[k]; }
23
+ });
24
+ }
25
+ });
26
+ }
27
+ n["default"] = e;
28
+ return Object.freeze(n);
29
+ }
30
+
31
+ var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
32
+ var path__namespace = /*#__PURE__*/_interopNamespace(path);
33
+
34
+ var _templateObject, _templateObject2, _templateObject3;
35
+ function createApp() {
36
+ return _createApp.apply(this, arguments);
37
+ } // Argument handling
38
+
39
+ function _createApp() {
40
+ _createApp = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee() {
41
+ var argv, _argv$PackageManag, additionalOptions, inWorkspace, name, directory, template, createAsMonorepo, shouldInstall, packageManager$1, setupExtras, partOfMonorepo, appDirectory, rootDirectory, outputRoot, appTemplate, workspaceTemplate, workspacePackageJson, _yield$Promise$all, _yield$Promise$all2, projectPackageJson, projectTSConfig, _workspacePackageJson, quiltProject, _projectPackageJson, commands, whatsNext, followUp;
42
+
43
+ return index.regenerator.wrap(function _callee$(_context) {
44
+ while (1) {
45
+ switch (_context.prev = _context.next) {
46
+ case 0:
47
+ argv = getArgv();
48
+
49
+ if (!argv['--help']) {
50
+ _context.next = 5;
51
+ break;
52
+ }
53
+
54
+ additionalOptions = index.stripIndent(_templateObject || (_templateObject = index._taggedTemplateLiteral(["\n ", "\n The template to use for your new application. If you don\u2019t specify a template,\n this command will ask you for one instead. Must be one of the following:\n\n - ", ", a web app with a minimal file structure\n - ", ", an entire web app in a single file\n "])), index.cyan_1("--template"), index.bold_1('basic'), index.bold_1('single-file'));
55
+ index.printHelp({
56
+ kind: 'app',
57
+ options: additionalOptions,
58
+ packageManager: (_argv$PackageManag = argv['--package-manager']) === null || _argv$PackageManag === void 0 ? void 0 : _argv$PackageManag.toLowerCase()
59
+ });
60
+ return _context.abrupt("return");
61
+
62
+ case 5:
63
+ inWorkspace = fs__namespace.existsSync('quilt.workspace.ts');
64
+ _context.next = 8;
65
+ return getName(argv, {
66
+ inWorkspace: inWorkspace
67
+ });
68
+
69
+ case 8:
70
+ name = _context.sent;
71
+ _context.next = 11;
72
+ return getDirectory(argv, {
73
+ name: name
74
+ });
75
+
76
+ case 11:
77
+ directory = _context.sent;
78
+ _context.next = 14;
79
+ return getTemplate(argv);
80
+
81
+ case 14:
82
+ template = _context.sent;
83
+ _context.t0 = !inWorkspace;
84
+
85
+ if (!_context.t0) {
86
+ _context.next = 20;
87
+ break;
88
+ }
89
+
90
+ _context.next = 19;
91
+ return index.getCreateAsMonorepo(argv);
92
+
93
+ case 19:
94
+ _context.t0 = _context.sent;
95
+
96
+ case 20:
97
+ createAsMonorepo = _context.t0;
98
+ _context.next = 23;
99
+ return index.getShouldInstall(argv);
100
+
101
+ case 23:
102
+ shouldInstall = _context.sent;
103
+ _context.next = 26;
104
+ return index.getPackageManager(argv);
105
+
106
+ case 26:
107
+ packageManager$1 = _context.sent;
108
+ _context.next = 29;
109
+ return index.getExtrasToSetup(argv, {
110
+ inWorkspace: inWorkspace
111
+ });
112
+
113
+ case 29:
114
+ setupExtras = _context.sent;
115
+ partOfMonorepo = inWorkspace || createAsMonorepo;
116
+ appDirectory = createAsMonorepo ? path__namespace.join(directory, 'app') : directory;
117
+
118
+ if (!fs__namespace.existsSync(directory)) {
119
+ _context.next = 38;
120
+ break;
121
+ }
122
+
123
+ _context.next = 35;
124
+ return packageManager.emptyDirectory(directory);
125
+
126
+ case 35:
127
+ if (appDirectory !== directory) {
128
+ fs__namespace.mkdirSync(appDirectory, {
129
+ recursive: true
130
+ });
131
+ }
132
+
133
+ _context.next = 39;
134
+ break;
135
+
136
+ case 38:
137
+ fs__namespace.mkdirSync(appDirectory, {
138
+ recursive: true
139
+ });
140
+
141
+ case 39:
142
+ rootDirectory = inWorkspace ? process.cwd() : directory;
143
+ outputRoot = packageManager.createOutputTarget(rootDirectory);
144
+ appTemplate = packageManager.loadTemplate(template === 'basic' ? 'app-basic' : 'app-single-file');
145
+ workspaceTemplate = packageManager.loadTemplate('workspace'); // If we aren’t already in a workspace, copy the workspace files over, which
146
+ // are needed if we are making a monorepo or not.
147
+
148
+ if (inWorkspace) {
149
+ _context.next = 109;
150
+ break;
151
+ }
152
+
153
+ _context.next = 46;
154
+ return workspaceTemplate.copy(directory, function (file) {
155
+ // When this is a single project, we use the project’s Quilt configuration as the base.
156
+ if (file === 'quilt.workspace.ts') return createAsMonorepo; // We need to make some adjustments to the root package.json
157
+
158
+ return file !== 'package.json';
159
+ });
160
+
161
+ case 46:
162
+ if (!createAsMonorepo) {
163
+ _context.next = 71;
164
+ break;
165
+ }
166
+
167
+ _context.t1 = JSON;
168
+ _context.next = 50;
169
+ return workspaceTemplate.read('package.json');
170
+
171
+ case 50:
172
+ _context.t2 = _context.sent;
173
+ workspacePackageJson = _context.t1.parse.call(_context.t1, _context.t2);
174
+ workspacePackageJson.name = packageManager.toValidPackageName(name);
175
+
176
+ if (!(packageManager$1 === 'pnpm')) {
177
+ _context.next = 62;
178
+ break;
179
+ }
180
+
181
+ _context.t3 = outputRoot;
182
+ _context.next = 57;
183
+ return packageManager.format("\n packages:\n - './packages/*'\n ", {
184
+ as: 'yaml'
185
+ });
186
+
187
+ case 57:
188
+ _context.t4 = _context.sent;
189
+ _context.next = 60;
190
+ return _context.t3.write.call(_context.t3, 'pnpm-workspace.yaml', _context.t4);
191
+
192
+ case 60:
193
+ _context.next = 63;
194
+ break;
195
+
196
+ case 62:
197
+ workspacePackageJson.workspaces = ['packages/*'];
198
+
199
+ case 63:
200
+ _context.t5 = outputRoot;
201
+ _context.next = 66;
202
+ return packageManager.format(JSON.stringify(workspacePackageJson), {
203
+ as: 'json-stringify'
204
+ });
205
+
206
+ case 66:
207
+ _context.t6 = _context.sent;
208
+ _context.next = 69;
209
+ return _context.t5.write.call(_context.t5, 'package.json', _context.t6);
210
+
211
+ case 69:
212
+ _context.next = 103;
213
+ break;
214
+
215
+ case 71:
216
+ _context.next = 73;
217
+ return Promise.all([appTemplate.read('package.json').then(function (content) {
218
+ return JSON.parse(content);
219
+ }), appTemplate.read('tsconfig.json').then(function (content) {
220
+ return JSON.parse(content);
221
+ }), workspaceTemplate.read('package.json').then(function (content) {
222
+ return JSON.parse(content);
223
+ })]);
224
+
225
+ case 73:
226
+ _yield$Promise$all = _context.sent;
227
+ _yield$Promise$all2 = packageManager._slicedToArray(_yield$Promise$all, 3);
228
+ projectPackageJson = _yield$Promise$all2[0];
229
+ projectTSConfig = _yield$Promise$all2[1];
230
+ _workspacePackageJson = _yield$Promise$all2[2];
231
+ _workspacePackageJson.name = packageManager.toValidPackageName(name);
232
+ _workspacePackageJson.eslintConfig = projectPackageJson.eslintConfig;
233
+ _workspacePackageJson.browserslist = projectPackageJson.browserslist;
234
+ _context.next = 83;
235
+ return appTemplate.read('quilt.project.ts');
236
+
237
+ case 83:
238
+ quiltProject = _context.sent;
239
+ quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
240
+ _context.t7 = outputRoot;
241
+ _context.next = 88;
242
+ return packageManager.format(quiltProject, {
243
+ as: 'typescript'
244
+ });
245
+
246
+ case 88:
247
+ _context.t8 = _context.sent;
248
+ _context.next = 91;
249
+ return _context.t7.write.call(_context.t7, 'quilt.project.ts', _context.t8);
250
+
251
+ case 91:
252
+ _context.t9 = outputRoot;
253
+ _context.next = 94;
254
+ return packageManager.format(JSON.stringify(_workspacePackageJson), {
255
+ as: 'json-stringify'
256
+ });
257
+
258
+ case 94:
259
+ _context.t10 = _context.sent;
260
+ _context.next = 97;
261
+ return _context.t9.write.call(_context.t9, 'package.json', _context.t10);
262
+
263
+ case 97:
264
+ _context.t11 = outputRoot;
265
+ _context.next = 100;
266
+ return packageManager.format(JSON.stringify(projectTSConfig), {
267
+ as: 'json'
268
+ });
269
+
270
+ case 100:
271
+ _context.t12 = _context.sent;
272
+ _context.next = 103;
273
+ return _context.t11.write.call(_context.t11, 'tsconfig.json', _context.t12);
274
+
275
+ case 103:
276
+ if (!setupExtras.has('github')) {
277
+ _context.next = 106;
278
+ break;
279
+ }
280
+
281
+ _context.next = 106;
282
+ return packageManager.loadTemplate('github').copy(directory);
283
+
284
+ case 106:
285
+ if (!setupExtras.has('vscode')) {
286
+ _context.next = 109;
287
+ break;
288
+ }
289
+
290
+ _context.next = 109;
291
+ return packageManager.loadTemplate('vscode').copy(directory);
292
+
293
+ case 109:
294
+ _context.next = 111;
295
+ return appTemplate.copy(appDirectory, function (file) {
296
+ // If we are in a monorepo, we can use all the template files as they are
297
+ if (file === 'quilt.project.ts' || file === 'tsconfig.json') {
298
+ return partOfMonorepo;
299
+ } // We need to make some adjustments the project’s package.json
300
+
301
+
302
+ return file !== 'package.json';
303
+ });
304
+
305
+ case 111:
306
+ if (!partOfMonorepo) {
307
+ _context.next = 127;
308
+ break;
309
+ }
310
+
311
+ _context.t13 = JSON;
312
+ _context.next = 115;
313
+ return appTemplate.read('package.json');
314
+
315
+ case 115:
316
+ _context.t14 = _context.sent;
317
+ _projectPackageJson = _context.t13.parse.call(_context.t13, _context.t14);
318
+ _projectPackageJson.name = path__namespace.basename(appDirectory);
319
+ _context.t15 = outputRoot;
320
+ _context.t16 = path__namespace.join(appDirectory, 'package.json');
321
+ _context.next = 122;
322
+ return packageManager.format(JSON.stringify(_projectPackageJson), {
323
+ as: 'json-stringify'
324
+ });
325
+
326
+ case 122:
327
+ _context.t17 = _context.sent;
328
+ _context.next = 125;
329
+ return _context.t15.write.call(_context.t15, _context.t16, _context.t17);
330
+
331
+ case 125:
332
+ _context.next = 127;
333
+ return Promise.all([packageManager.addToTsConfig(appDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(appDirectory, outputRoot, packageManager$1)]);
334
+
335
+ case 127:
336
+ if (shouldInstall) {
337
+ process.stdout.write('\nInstalling dependencies...\n'); // TODO: better loading, handle errors
338
+
339
+ child_process.execSync("".concat(packageManager$1, " install"), {
340
+ cwd: rootDirectory
341
+ });
342
+ process.stdout.moveCursor(0, -1);
343
+ process.stdout.clearLine(1);
344
+ console.log('Installed dependencies.');
345
+ }
346
+
347
+ commands = [];
348
+
349
+ if (!inWorkspace && directory !== process.cwd()) {
350
+ commands.push("cd ".concat(index.cyan_1(packageManager.relativeDirectoryForDisplay(path__namespace.relative(process.cwd(), directory))), " ").concat(index.dim_1('# Move into your new app’s directory')));
351
+ }
352
+
353
+ if (!shouldInstall) {
354
+ commands.push("pnpm install ".concat(index.dim_1('# Install all your dependencies')));
355
+ }
356
+
357
+ if (!inWorkspace) {
358
+ // TODO: change this condition to check if git was initialized already
359
+ commands.push("git init && git add -A && git commit -m \"Initial commit\" ".concat(index.dim_1('# Start your git history (optional)')));
360
+ }
361
+
362
+ commands.push("pnpm develop ".concat(index.dim_1('# Start the development server')));
363
+ whatsNext = index.stripIndent(_templateObject2 || (_templateObject2 = index._taggedTemplateLiteral(["\n Your new app is ready to go! There\u2019s just ", " you\u2019ll need to take\n in order to start developing:\n "])), commands.length > 1 ? 'a few more steps' : 'one more step');
364
+ console.log();
365
+ console.log(whatsNext);
366
+ console.log();
367
+ console.log(commands.map(function (command) {
368
+ return " ".concat(command);
369
+ }).join('\n'));
370
+ followUp = index.stripIndent(_templateObject3 || (_templateObject3 = index._taggedTemplateLiteral(["\n Quilt can also help you build, test, lint, and type-check your new application.\n You can learn more about building apps with Quilt by reading the documentation:\n ", "\n\n Have fun! \uD83C\uDF89\n "])), index.underline_1(index.magenta_1('https://github.com/lemonmade/quilt/tree/main/documentation')));
371
+ console.log();
372
+ console.log(followUp);
373
+
374
+ case 141:
375
+ case "end":
376
+ return _context.stop();
377
+ }
378
+ }
379
+ }, _callee);
380
+ }));
381
+ return _createApp.apply(this, arguments);
382
+ }
383
+
384
+ function getArgv() {
385
+ var argv = index.arg_1({
386
+ '--yes': Boolean,
387
+ '-y': '--yes',
388
+ '--name': String,
389
+ '--template': String,
390
+ '--directory': String,
391
+ '--install': Boolean,
392
+ '--no-install': Boolean,
393
+ '--monorepo': Boolean,
394
+ '--no-monorepo': Boolean,
395
+ '--package-manager': String,
396
+ '--extras': [String],
397
+ '--no-extras': Boolean,
398
+ '--help': Boolean,
399
+ '-h': '--help'
400
+ }, {
401
+ permissive: true
402
+ });
403
+ return argv;
404
+ }
405
+
406
+ function getName(_x, _x2) {
407
+ return _getName.apply(this, arguments);
408
+ }
409
+
410
+ function _getName() {
411
+ _getName = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee2(argv, _ref) {
412
+ var inWorkspace, name;
413
+ return index.regenerator.wrap(function _callee2$(_context2) {
414
+ while (1) {
415
+ switch (_context2.prev = _context2.next) {
416
+ case 0:
417
+ inWorkspace = _ref.inWorkspace;
418
+ name = argv['--name'];
419
+
420
+ if (!(name == null)) {
421
+ _context2.next = 6;
422
+ break;
423
+ }
424
+
425
+ _context2.next = 5;
426
+ return index.prompt({
427
+ type: 'text',
428
+ message: 'What would you like to name your new app?',
429
+ initial: inWorkspace ? 'app' : 'my-quilt-app'
430
+ });
431
+
432
+ case 5:
433
+ name = _context2.sent;
434
+
435
+ case 6:
436
+ return _context2.abrupt("return", name);
437
+
438
+ case 7:
439
+ case "end":
440
+ return _context2.stop();
441
+ }
442
+ }
443
+ }, _callee2);
444
+ }));
445
+ return _getName.apply(this, arguments);
446
+ }
447
+
448
+ function getDirectory(_x3, _x4) {
449
+ return _getDirectory.apply(this, arguments);
450
+ }
451
+
452
+ function _getDirectory() {
453
+ _getDirectory = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee3(argv, _ref2) {
454
+ var _argv$Directory;
455
+
456
+ var name, directory, relativeDirectory, empty, promptDirectory;
457
+ return index.regenerator.wrap(function _callee3$(_context3) {
458
+ while (1) {
459
+ switch (_context3.prev = _context3.next) {
460
+ case 0:
461
+ name = _ref2.name;
462
+ directory = path__namespace.resolve((_argv$Directory = argv['--directory']) !== null && _argv$Directory !== void 0 ? _argv$Directory : packageManager.toValidPackageName(name));
463
+
464
+ case 2:
465
+ if (argv['--yes']) {
466
+ _context3.next = 24;
467
+ break;
468
+ }
469
+
470
+ _context3.t0 = fs__namespace.existsSync(directory);
471
+
472
+ if (!_context3.t0) {
473
+ _context3.next = 8;
474
+ break;
475
+ }
476
+
477
+ _context3.next = 7;
478
+ return packageManager.isEmpty(directory);
479
+
480
+ case 7:
481
+ _context3.t0 = !_context3.sent;
482
+
483
+ case 8:
484
+ if (!_context3.t0) {
485
+ _context3.next = 21;
486
+ break;
487
+ }
488
+
489
+ relativeDirectory = path__namespace.relative(process.cwd(), directory);
490
+ _context3.next = 12;
491
+ return index.prompt({
492
+ type: 'confirm',
493
+ message: "Directory ".concat(index.bold_1(packageManager.relativeDirectoryForDisplay(relativeDirectory)), " is not empty, is it safe to empty it?"),
494
+ initial: true
495
+ });
496
+
497
+ case 12:
498
+ empty = _context3.sent;
499
+
500
+ if (!empty) {
501
+ _context3.next = 15;
502
+ break;
503
+ }
504
+
505
+ return _context3.abrupt("break", 24);
506
+
507
+ case 15:
508
+ _context3.next = 17;
509
+ return index.prompt({
510
+ type: 'text',
511
+ message: 'What directory do you want to create your new app in?'
512
+ });
513
+
514
+ case 17:
515
+ promptDirectory = _context3.sent;
516
+ directory = path__namespace.resolve(promptDirectory);
517
+ _context3.next = 22;
518
+ break;
519
+
520
+ case 21:
521
+ return _context3.abrupt("break", 24);
522
+
523
+ case 22:
524
+ _context3.next = 2;
525
+ break;
526
+
527
+ case 24:
528
+ return _context3.abrupt("return", directory);
529
+
530
+ case 25:
531
+ case "end":
532
+ return _context3.stop();
533
+ }
534
+ }
535
+ }, _callee3);
536
+ }));
537
+ return _getDirectory.apply(this, arguments);
538
+ }
539
+
540
+ var VALID_TEMPLATES = new Set(['basic', 'single-file']);
541
+
542
+ function getTemplate(_x5) {
543
+ return _getTemplate.apply(this, arguments);
544
+ }
545
+
546
+ function _getTemplate() {
547
+ _getTemplate = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee4(argv) {
548
+ var template;
549
+ return index.regenerator.wrap(function _callee4$(_context4) {
550
+ while (1) {
551
+ switch (_context4.prev = _context4.next) {
552
+ case 0:
553
+ if (!(argv['--template'] && VALID_TEMPLATES.has(argv['--template']))) {
554
+ _context4.next = 2;
555
+ break;
556
+ }
557
+
558
+ return _context4.abrupt("return", argv['--template']);
559
+
560
+ case 2:
561
+ _context4.next = 4;
562
+ return index.prompt({
563
+ type: 'select',
564
+ message: 'What template would you like to use?',
565
+ hint: "Use ".concat(index.bold_1('arrow keys'), " to select, and ").concat(index.bold_1('return'), " to submit"),
566
+ choices: [{
567
+ title: "".concat(index.bold_1('The basics'), ", a web app with a minimal file structure"),
568
+ value: 'basic'
569
+ }, {
570
+ title: "".concat(index.bold_1('Itty-bitty'), ", an entire web app in a single file"),
571
+ value: 'single-file'
572
+ } // TODO: GraphQL API
573
+ ]
574
+ });
575
+
576
+ case 4:
577
+ template = _context4.sent;
578
+ return _context4.abrupt("return", template);
579
+
580
+ case 6:
581
+ case "end":
582
+ return _context4.stop();
583
+ }
584
+ }
585
+ }, _callee4);
586
+ }));
587
+ return _getTemplate.apply(this, arguments);
588
+ }
589
+
590
+ exports.createApp = createApp;