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