@quilted/create 0.1.21 → 0.1.22
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 +6 -0
- package/build/cjs/app.cjs +244 -525
- package/build/cjs/index.cjs +255 -996
- package/build/cjs/index3.cjs +1205 -577
- package/build/cjs/package-manager.cjs +207 -799
- package/build/cjs/package.cjs +326 -701
- package/build/cjs/parser-babel.cjs +3 -3
- package/build/cjs/parser-yaml.cjs +2 -2
- package/build/cjs/standalone.cjs +3 -3
- package/build/esm/app.mjs +249 -530
- package/build/esm/index.mjs +239 -978
- package/build/esm/index3.mjs +1205 -548
- package/build/esm/package-manager.mjs +208 -799
- package/build/esm/package.mjs +326 -701
- package/build/esm/parser-babel.mjs +1 -1
- package/build/esm/parser-yaml.mjs +1 -1
- package/build/esm/standalone.mjs +1 -1
- package/package.json +1 -1
- package/build/cjs/_commonjsHelpers.cjs +0 -10
- package/build/esm/_commonjsHelpers.mjs +0 -7
package/build/cjs/app.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var packageManager = require('./package-manager.cjs');
|
|
4
|
-
var index = require('./index.cjs');
|
|
5
3
|
var fs = require('fs');
|
|
6
4
|
var path = require('path');
|
|
7
5
|
var child_process = require('child_process');
|
|
8
|
-
require('
|
|
6
|
+
var index = require('./index.cjs');
|
|
7
|
+
var packageManager = require('./package-manager.cjs');
|
|
9
8
|
require('tty');
|
|
9
|
+
require('url');
|
|
10
10
|
require('readline');
|
|
11
11
|
require('events');
|
|
12
12
|
|
|
@@ -31,358 +31,191 @@ function _interopNamespace(e) {
|
|
|
31
31
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
32
32
|
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
let _ = t => t,
|
|
35
|
+
_t,
|
|
36
|
+
_t2,
|
|
37
|
+
_t3;
|
|
38
|
+
async function createApp() {
|
|
39
|
+
const argv = getArgv();
|
|
40
|
+
|
|
41
|
+
if (argv['--help']) {
|
|
42
|
+
var _argv$PackageManag;
|
|
43
|
+
|
|
44
|
+
const additionalOptions = index.stripIndent(_t || (_t = _`
|
|
45
|
+
${0}
|
|
46
|
+
The template to use for your new application. If you don’t specify a template,
|
|
47
|
+
this command will ask you for one instead. Must be one of the following:
|
|
48
|
+
|
|
49
|
+
- ${0}, a web app with a minimal file structure
|
|
50
|
+
- ${0}, an entire web app in a single file
|
|
51
|
+
`), index.cyan_1(`--template`), index.bold_1('basic'), index.bold_1('single-file'));
|
|
52
|
+
index.printHelp({
|
|
53
|
+
kind: 'app',
|
|
54
|
+
options: additionalOptions,
|
|
55
|
+
packageManager: (_argv$PackageManag = argv['--package-manager']) === null || _argv$PackageManag === void 0 ? void 0 : _argv$PackageManag.toLowerCase()
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const inWorkspace = fs__namespace.existsSync('quilt.workspace.ts');
|
|
61
|
+
const name = await getName(argv, {
|
|
62
|
+
inWorkspace
|
|
63
|
+
});
|
|
64
|
+
const directory = await getDirectory(argv, {
|
|
65
|
+
name
|
|
66
|
+
});
|
|
67
|
+
const template = await getTemplate(argv);
|
|
68
|
+
const createAsMonorepo = !inWorkspace && (await index.getCreateAsMonorepo(argv));
|
|
69
|
+
const shouldInstall = await index.getShouldInstall(argv);
|
|
70
|
+
const packageManager$1 = await index.getPackageManager(argv);
|
|
71
|
+
const setupExtras = await index.getExtrasToSetup(argv, {
|
|
72
|
+
inWorkspace
|
|
73
|
+
});
|
|
74
|
+
const partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
75
|
+
const appDirectory = createAsMonorepo ? path__namespace.join(directory, 'app') : directory;
|
|
76
|
+
|
|
77
|
+
if (fs__namespace.existsSync(directory)) {
|
|
78
|
+
await packageManager.emptyDirectory(directory);
|
|
79
|
+
|
|
80
|
+
if (appDirectory !== directory) {
|
|
81
|
+
fs__namespace.mkdirSync(appDirectory, {
|
|
82
|
+
recursive: true
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
fs__namespace.mkdirSync(appDirectory, {
|
|
87
|
+
recursive: true
|
|
88
|
+
});
|
|
89
|
+
}
|
|
38
90
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
}
|
|
91
|
+
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
92
|
+
const outputRoot = packageManager.createOutputTarget(rootDirectory);
|
|
93
|
+
const appTemplate = packageManager.loadTemplate(template === 'basic' ? 'app-basic' : 'app-single-file');
|
|
94
|
+
const workspaceTemplate = packageManager.loadTemplate('workspace'); // If we aren’t already in a workspace, copy the workspace files over, which
|
|
95
|
+
// are needed if we are making a monorepo or not.
|
|
96
|
+
|
|
97
|
+
if (!inWorkspace) {
|
|
98
|
+
await workspaceTemplate.copy(directory, file => {
|
|
99
|
+
// When this is a single project, we use the project’s Quilt configuration as the base.
|
|
100
|
+
if (file === 'quilt.workspace.ts') return createAsMonorepo; // We need to make some adjustments to the root package.json
|
|
101
|
+
|
|
102
|
+
return file !== 'package.json';
|
|
103
|
+
}); // If we are creating a monorepo, we need to add the root package.json and
|
|
104
|
+
// package manager workspace configuration.
|
|
105
|
+
|
|
106
|
+
if (createAsMonorepo) {
|
|
107
|
+
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
108
|
+
workspacePackageJson.name = packageManager.toValidPackageName(name);
|
|
109
|
+
|
|
110
|
+
if (packageManager$1 === 'pnpm') {
|
|
111
|
+
await outputRoot.write('pnpm-workspace.yaml', await packageManager.format(`
|
|
112
|
+
packages:
|
|
113
|
+
- './packages/*'
|
|
114
|
+
`, {
|
|
115
|
+
as: 'yaml'
|
|
116
|
+
}));
|
|
117
|
+
} else {
|
|
118
|
+
workspacePackageJson.workspaces = ['packages/*'];
|
|
378
119
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
120
|
+
|
|
121
|
+
await outputRoot.write('package.json', await packageManager.format(JSON.stringify(workspacePackageJson), {
|
|
122
|
+
as: 'json-stringify'
|
|
123
|
+
}));
|
|
124
|
+
} else {
|
|
125
|
+
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([appTemplate.read('package.json').then(content => JSON.parse(content)), appTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
126
|
+
workspacePackageJson.name = packageManager.toValidPackageName(name);
|
|
127
|
+
workspacePackageJson.eslintConfig = projectPackageJson.eslintConfig;
|
|
128
|
+
workspacePackageJson.browserslist = projectPackageJson.browserslist;
|
|
129
|
+
let quiltProject = await appTemplate.read('quilt.project.ts');
|
|
130
|
+
quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
|
|
131
|
+
await outputRoot.write('quilt.project.ts', await packageManager.format(quiltProject, {
|
|
132
|
+
as: 'typescript'
|
|
133
|
+
}));
|
|
134
|
+
await outputRoot.write('package.json', await packageManager.format(JSON.stringify(workspacePackageJson), {
|
|
135
|
+
as: 'json-stringify'
|
|
136
|
+
}));
|
|
137
|
+
await outputRoot.write('tsconfig.json', await packageManager.format(JSON.stringify(projectTSConfig), {
|
|
138
|
+
as: 'json'
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (setupExtras.has('github')) {
|
|
143
|
+
await packageManager.loadTemplate('github').copy(directory);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (setupExtras.has('vscode')) {
|
|
147
|
+
await packageManager.loadTemplate('vscode').copy(directory);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
await appTemplate.copy(appDirectory, file => {
|
|
152
|
+
// If we are in a monorepo, we can use all the template files as they are
|
|
153
|
+
if (file === 'quilt.project.ts' || file === 'tsconfig.json') {
|
|
154
|
+
return partOfMonorepo;
|
|
155
|
+
} // We need to make some adjustments the project’s package.json
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
return file !== 'package.json';
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
if (partOfMonorepo) {
|
|
162
|
+
// Write the app’s package.json (the root one was already created)
|
|
163
|
+
const projectPackageJson = JSON.parse(await appTemplate.read('package.json'));
|
|
164
|
+
projectPackageJson.name = path__namespace.basename(appDirectory);
|
|
165
|
+
await outputRoot.write(path__namespace.join(appDirectory, 'package.json'), await packageManager.format(JSON.stringify(projectPackageJson), {
|
|
166
|
+
as: 'json-stringify'
|
|
167
|
+
}));
|
|
168
|
+
await Promise.all([packageManager.addToTsConfig(appDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(appDirectory, outputRoot, packageManager$1)]);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (shouldInstall) {
|
|
172
|
+
process.stdout.write('\nInstalling dependencies...\n'); // TODO: better loading, handle errors
|
|
173
|
+
|
|
174
|
+
child_process.execSync(`${packageManager$1} install`, {
|
|
175
|
+
cwd: rootDirectory
|
|
176
|
+
});
|
|
177
|
+
process.stdout.moveCursor(0, -1);
|
|
178
|
+
process.stdout.clearLine(1);
|
|
179
|
+
console.log('Installed dependencies.');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const commands = [];
|
|
183
|
+
|
|
184
|
+
if (!inWorkspace && directory !== process.cwd()) {
|
|
185
|
+
commands.push(`cd ${index.cyan_1(packageManager.relativeDirectoryForDisplay(path__namespace.relative(process.cwd(), directory)))} ${index.dim_1('# Move into your new app’s directory')}`);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (!shouldInstall) {
|
|
189
|
+
commands.push(`pnpm install ${index.dim_1('# Install all your dependencies')}`);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (!inWorkspace) {
|
|
193
|
+
// TODO: change this condition to check if git was initialized already
|
|
194
|
+
commands.push(`git init && git add -A && git commit -m "Initial commit" ${index.dim_1('# Start your git history (optional)')}`);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
commands.push(`pnpm develop ${index.dim_1('# Start the development server')}`);
|
|
198
|
+
const whatsNext = index.stripIndent(_t2 || (_t2 = _`
|
|
199
|
+
Your new app is ready to go! There’s just ${0} you’ll need to take
|
|
200
|
+
in order to start developing:
|
|
201
|
+
`), commands.length > 1 ? 'a few more steps' : 'one more step');
|
|
202
|
+
console.log();
|
|
203
|
+
console.log(whatsNext);
|
|
204
|
+
console.log();
|
|
205
|
+
console.log(commands.map(command => ` ${command}`).join('\n'));
|
|
206
|
+
const followUp = index.stripIndent(_t3 || (_t3 = _`
|
|
207
|
+
Quilt can also help you build, test, lint, and type-check your new application.
|
|
208
|
+
You can learn more about building apps with Quilt by reading the documentation:
|
|
209
|
+
${0}
|
|
210
|
+
|
|
211
|
+
Have fun! 🎉
|
|
212
|
+
`), index.underline_1(index.magenta_1('https://github.com/lemonmade/quilt/tree/main/documentation')));
|
|
213
|
+
console.log();
|
|
214
|
+
console.log(followUp);
|
|
215
|
+
} // Argument handling
|
|
383
216
|
|
|
384
217
|
function getArgv() {
|
|
385
|
-
|
|
218
|
+
const argv = index.arg_1({
|
|
386
219
|
'--yes': Boolean,
|
|
387
220
|
'-y': '--yes',
|
|
388
221
|
'--name': String,
|
|
@@ -403,188 +236,74 @@ function getArgv() {
|
|
|
403
236
|
return argv;
|
|
404
237
|
}
|
|
405
238
|
|
|
406
|
-
function getName(
|
|
407
|
-
|
|
408
|
-
}
|
|
239
|
+
async function getName(argv, {
|
|
240
|
+
inWorkspace
|
|
241
|
+
}) {
|
|
242
|
+
let {
|
|
243
|
+
'--name': name
|
|
244
|
+
} = argv;
|
|
245
|
+
|
|
246
|
+
if (name == null) {
|
|
247
|
+
name = await index.prompt({
|
|
248
|
+
type: 'text',
|
|
249
|
+
message: 'What would you like to name your new app?',
|
|
250
|
+
initial: inWorkspace ? 'app' : 'my-quilt-app'
|
|
251
|
+
});
|
|
252
|
+
}
|
|
409
253
|
|
|
410
|
-
|
|
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);
|
|
254
|
+
return name;
|
|
446
255
|
}
|
|
447
256
|
|
|
448
|
-
function getDirectory(
|
|
449
|
-
|
|
450
|
-
}
|
|
257
|
+
async function getDirectory(argv, {
|
|
258
|
+
name
|
|
259
|
+
}) {
|
|
260
|
+
var _argv$Directory;
|
|
261
|
+
|
|
262
|
+
let directory = path__namespace.resolve((_argv$Directory = argv['--directory']) !== null && _argv$Directory !== void 0 ? _argv$Directory : packageManager.toValidPackageName(name));
|
|
263
|
+
|
|
264
|
+
while (!argv['--yes']) {
|
|
265
|
+
if (fs__namespace.existsSync(directory) && !(await packageManager.isEmpty(directory))) {
|
|
266
|
+
const relativeDirectory = path__namespace.relative(process.cwd(), directory);
|
|
267
|
+
const empty = await index.prompt({
|
|
268
|
+
type: 'confirm',
|
|
269
|
+
message: `Directory ${index.bold_1(packageManager.relativeDirectoryForDisplay(relativeDirectory))} is not empty, is it safe to empty it?`,
|
|
270
|
+
initial: true
|
|
271
|
+
});
|
|
272
|
+
if (empty) break;
|
|
273
|
+
const promptDirectory = await index.prompt({
|
|
274
|
+
type: 'text',
|
|
275
|
+
message: 'What directory do you want to create your new app in?'
|
|
276
|
+
});
|
|
277
|
+
directory = path__namespace.resolve(promptDirectory);
|
|
278
|
+
} else {
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
451
282
|
|
|
452
|
-
|
|
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);
|
|
283
|
+
return directory;
|
|
538
284
|
}
|
|
539
285
|
|
|
540
|
-
|
|
286
|
+
const VALID_TEMPLATES = new Set(['basic', 'single-file']);
|
|
541
287
|
|
|
542
|
-
function getTemplate(
|
|
543
|
-
|
|
544
|
-
|
|
288
|
+
async function getTemplate(argv) {
|
|
289
|
+
if (argv['--template'] && VALID_TEMPLATES.has(argv['--template'])) {
|
|
290
|
+
return argv['--template'];
|
|
291
|
+
}
|
|
545
292
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
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);
|
|
293
|
+
const template = await index.prompt({
|
|
294
|
+
type: 'select',
|
|
295
|
+
message: 'What template would you like to use?',
|
|
296
|
+
hint: `Use ${index.bold_1('arrow keys')} to select, and ${index.bold_1('return')} to submit`,
|
|
297
|
+
choices: [{
|
|
298
|
+
title: `${index.bold_1('The basics')}, a web app with a minimal file structure`,
|
|
299
|
+
value: 'basic'
|
|
300
|
+
}, {
|
|
301
|
+
title: `${index.bold_1('Itty-bitty')}, an entire web app in a single file`,
|
|
302
|
+
value: 'single-file'
|
|
303
|
+
} // TODO: GraphQL API
|
|
304
|
+
]
|
|
305
|
+
});
|
|
306
|
+
return template;
|
|
588
307
|
}
|
|
589
308
|
|
|
590
309
|
exports.createApp = createApp;
|