@quilted/create 0.1.29 → 0.1.31
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 +233 -39
- package/build/cjs/index.cjs +315 -413
- package/build/cjs/package.cjs +36 -36
- package/build/cjs/shared/package-manager.cjs +677 -0
- package/build/esm/app.mjs +207 -13
- package/build/esm/index.mjs +314 -389
- package/build/esm/package.mjs +37 -37
- package/build/esm/parser-babel.mjs +1 -1
- package/build/esm/parser-typescript.mjs +1 -1
- package/build/esm/parser-yaml.mjs +1 -1
- package/build/esm/shared/package-manager.mjs +635 -0
- package/build/esm/standalone.mjs +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/help.d.ts.map +1 -1
- package/build/typescript/package.d.ts.map +1 -1
- package/build/typescript/shared/prompts.d.ts +3 -4
- package/build/typescript/shared/prompts.d.ts.map +1 -1
- package/build/typescript/shared.d.ts +1 -1
- package/build/typescript/shared.d.ts.map +1 -1
- package/package.json +2 -2
- package/source/app.ts +12 -11
- package/source/create.ts +2 -5
- package/source/help.ts +1 -2
- package/source/package.ts +36 -38
- package/source/shared/prompts.ts +13 -44
- package/source/shared.ts +1 -2
- package/tsconfig.json +6 -1
- package/build/cjs/package-manager.cjs +0 -330
- package/build/esm/package-manager.mjs +0 -299
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @quilted/create
|
|
2
2
|
|
|
3
|
+
## 0.1.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`20390858`](https://github.com/lemonmade/quilt/commit/2039085884e75951ff020f63a4fcc94f6d06d135) Thanks [@lemonmade](https://github.com/lemonmade)! - Add package manager running utilities to cli-kit
|
|
8
|
+
|
|
9
|
+
## 0.1.30
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`0a69e630`](https://github.com/lemonmade/quilt/commit/0a69e630d9da9233e676f6a5de863b3f836a667e) Thanks [@lemonmade](https://github.com/lemonmade)! - Add cli-kit package
|
|
14
|
+
|
|
3
15
|
## 0.1.29
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/build/cjs/app.cjs
CHANGED
|
@@ -2,35 +2,231 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('node:fs');
|
|
4
4
|
var path = require('node:path');
|
|
5
|
-
var
|
|
5
|
+
var packageManager = require('./shared/package-manager.cjs');
|
|
6
6
|
var index = require('./index.cjs');
|
|
7
|
-
var packageManager = require('./package-manager.cjs');
|
|
8
7
|
require('node:tty');
|
|
8
|
+
require('node:child_process');
|
|
9
9
|
require('node:url');
|
|
10
10
|
require('node:readline');
|
|
11
11
|
require('node:events');
|
|
12
12
|
|
|
13
13
|
function _interopNamespace(e) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
29
|
}
|
|
30
30
|
|
|
31
31
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
32
32
|
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
33
33
|
|
|
34
|
+
const flagSymbol = Symbol('arg flag');
|
|
35
|
+
|
|
36
|
+
class ArgError extends Error {
|
|
37
|
+
constructor(msg, code) {
|
|
38
|
+
super(msg);
|
|
39
|
+
this.name = 'ArgError';
|
|
40
|
+
this.code = code;
|
|
41
|
+
|
|
42
|
+
Object.setPrototypeOf(this, ArgError.prototype);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function arg(
|
|
47
|
+
opts,
|
|
48
|
+
{
|
|
49
|
+
argv = process.argv.slice(2),
|
|
50
|
+
permissive = false,
|
|
51
|
+
stopAtPositional = false
|
|
52
|
+
} = {}
|
|
53
|
+
) {
|
|
54
|
+
if (!opts) {
|
|
55
|
+
throw new ArgError(
|
|
56
|
+
'argument specification object is required',
|
|
57
|
+
'ARG_CONFIG_NO_SPEC'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const result = { _: [] };
|
|
62
|
+
|
|
63
|
+
const aliases = {};
|
|
64
|
+
const handlers = {};
|
|
65
|
+
|
|
66
|
+
for (const key of Object.keys(opts)) {
|
|
67
|
+
if (!key) {
|
|
68
|
+
throw new ArgError(
|
|
69
|
+
'argument key cannot be an empty string',
|
|
70
|
+
'ARG_CONFIG_EMPTY_KEY'
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (key[0] !== '-') {
|
|
75
|
+
throw new ArgError(
|
|
76
|
+
`argument key must start with '-' but found: '${key}'`,
|
|
77
|
+
'ARG_CONFIG_NONOPT_KEY'
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (key.length === 1) {
|
|
82
|
+
throw new ArgError(
|
|
83
|
+
`argument key must have a name; singular '-' keys are not allowed: ${key}`,
|
|
84
|
+
'ARG_CONFIG_NONAME_KEY'
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (typeof opts[key] === 'string') {
|
|
89
|
+
aliases[key] = opts[key];
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let type = opts[key];
|
|
94
|
+
let isFlag = false;
|
|
95
|
+
|
|
96
|
+
if (
|
|
97
|
+
Array.isArray(type) &&
|
|
98
|
+
type.length === 1 &&
|
|
99
|
+
typeof type[0] === 'function'
|
|
100
|
+
) {
|
|
101
|
+
const [fn] = type;
|
|
102
|
+
type = (value, name, prev = []) => {
|
|
103
|
+
prev.push(fn(value, name, prev[prev.length - 1]));
|
|
104
|
+
return prev;
|
|
105
|
+
};
|
|
106
|
+
isFlag = fn === Boolean || fn[flagSymbol] === true;
|
|
107
|
+
} else if (typeof type === 'function') {
|
|
108
|
+
isFlag = type === Boolean || type[flagSymbol] === true;
|
|
109
|
+
} else {
|
|
110
|
+
throw new ArgError(
|
|
111
|
+
`type missing or not a function or valid array type: ${key}`,
|
|
112
|
+
'ARG_CONFIG_VAD_TYPE'
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (key[1] !== '-' && key.length > 2) {
|
|
117
|
+
throw new ArgError(
|
|
118
|
+
`short argument keys (with a single hyphen) must have only one character: ${key}`,
|
|
119
|
+
'ARG_CONFIG_SHORTOPT_TOOLONG'
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
handlers[key] = [type, isFlag];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
for (let i = 0, len = argv.length; i < len; i++) {
|
|
127
|
+
const wholeArg = argv[i];
|
|
128
|
+
|
|
129
|
+
if (stopAtPositional && result._.length > 0) {
|
|
130
|
+
result._ = result._.concat(argv.slice(i));
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (wholeArg === '--') {
|
|
135
|
+
result._ = result._.concat(argv.slice(i + 1));
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (wholeArg.length > 1 && wholeArg[0] === '-') {
|
|
140
|
+
/* eslint-disable operator-linebreak */
|
|
141
|
+
const separatedArguments =
|
|
142
|
+
wholeArg[1] === '-' || wholeArg.length === 2
|
|
143
|
+
? [wholeArg]
|
|
144
|
+
: wholeArg
|
|
145
|
+
.slice(1)
|
|
146
|
+
.split('')
|
|
147
|
+
.map((a) => `-${a}`);
|
|
148
|
+
/* eslint-enable operator-linebreak */
|
|
149
|
+
|
|
150
|
+
for (let j = 0; j < separatedArguments.length; j++) {
|
|
151
|
+
const arg = separatedArguments[j];
|
|
152
|
+
const [originalArgName, argStr] =
|
|
153
|
+
arg[1] === '-' ? arg.split(/=(.*)/, 2) : [arg, undefined];
|
|
154
|
+
|
|
155
|
+
let argName = originalArgName;
|
|
156
|
+
while (argName in aliases) {
|
|
157
|
+
argName = aliases[argName];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (!(argName in handlers)) {
|
|
161
|
+
if (permissive) {
|
|
162
|
+
result._.push(arg);
|
|
163
|
+
continue;
|
|
164
|
+
} else {
|
|
165
|
+
throw new ArgError(
|
|
166
|
+
`unknown or unexpected option: ${originalArgName}`,
|
|
167
|
+
'ARG_UNKNOWN_OPTION'
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const [type, isFlag] = handlers[argName];
|
|
173
|
+
|
|
174
|
+
if (!isFlag && j + 1 < separatedArguments.length) {
|
|
175
|
+
throw new ArgError(
|
|
176
|
+
`option requires argument (but was followed by another short argument): ${originalArgName}`,
|
|
177
|
+
'ARG_MISSING_REQUIRED_SHORTARG'
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (isFlag) {
|
|
182
|
+
result[argName] = type(true, argName, result[argName]);
|
|
183
|
+
} else if (argStr === undefined) {
|
|
184
|
+
if (
|
|
185
|
+
argv.length < i + 2 ||
|
|
186
|
+
(argv[i + 1].length > 1 &&
|
|
187
|
+
argv[i + 1][0] === '-' &&
|
|
188
|
+
!(
|
|
189
|
+
argv[i + 1].match(/^-?\d*(\.(?=\d))?\d*$/) &&
|
|
190
|
+
(type === Number ||
|
|
191
|
+
// eslint-disable-next-line no-undef
|
|
192
|
+
(typeof BigInt !== 'undefined' && type === BigInt))
|
|
193
|
+
))
|
|
194
|
+
) {
|
|
195
|
+
const extended =
|
|
196
|
+
originalArgName === argName ? '' : ` (alias for ${argName})`;
|
|
197
|
+
throw new ArgError(
|
|
198
|
+
`option requires argument: ${originalArgName}${extended}`,
|
|
199
|
+
'ARG_MISSING_REQUIRED_LONGARG'
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
result[argName] = type(argv[i + 1], argName, result[argName]);
|
|
204
|
+
++i;
|
|
205
|
+
} else {
|
|
206
|
+
result[argName] = type(argStr, argName, result[argName]);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
result._.push(wholeArg);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
arg.flag = (fn) => {
|
|
218
|
+
fn[flagSymbol] = true;
|
|
219
|
+
return fn;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// Utility types
|
|
223
|
+
arg.COUNT = arg.flag((v, name, existingCount) => (existingCount || 0) + 1);
|
|
224
|
+
|
|
225
|
+
// Expose error class
|
|
226
|
+
arg.ArgError = ArgError;
|
|
227
|
+
|
|
228
|
+
var arg_1 = arg;
|
|
229
|
+
|
|
34
230
|
let _ = t => t,
|
|
35
231
|
_t,
|
|
36
232
|
_t2,
|
|
@@ -48,7 +244,7 @@ async function createApp() {
|
|
|
48
244
|
|
|
49
245
|
- ${0}, a web app with a minimal file structure
|
|
50
246
|
- ${0}, an entire web app in a single file
|
|
51
|
-
`),
|
|
247
|
+
`), packageManager.cyan_1(`--template`), packageManager.bold_1('basic'), packageManager.bold_1('single-file'));
|
|
52
248
|
index.printHelp({
|
|
53
249
|
kind: 'app',
|
|
54
250
|
options: additionalOptions,
|
|
@@ -65,10 +261,12 @@ async function createApp() {
|
|
|
65
261
|
name
|
|
66
262
|
});
|
|
67
263
|
const template = await getTemplate(argv);
|
|
68
|
-
const createAsMonorepo = !inWorkspace && (await
|
|
69
|
-
const shouldInstall = await
|
|
70
|
-
const packageManager$1 = await
|
|
71
|
-
|
|
264
|
+
const createAsMonorepo = !inWorkspace && (await packageManager.getCreateAsMonorepo(argv));
|
|
265
|
+
const shouldInstall = await packageManager.getShouldInstall(argv);
|
|
266
|
+
const packageManager$1 = await packageManager.getPackageManager(argv, {
|
|
267
|
+
root: directory
|
|
268
|
+
});
|
|
269
|
+
const setupExtras = await packageManager.getExtrasToSetup(argv, {
|
|
72
270
|
inWorkspace
|
|
73
271
|
});
|
|
74
272
|
const partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
@@ -107,7 +305,7 @@ async function createApp() {
|
|
|
107
305
|
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
108
306
|
workspacePackageJson.name = packageManager.toValidPackageName(name);
|
|
109
307
|
|
|
110
|
-
if (packageManager$1 === 'pnpm') {
|
|
308
|
+
if (packageManager$1.type === 'pnpm') {
|
|
111
309
|
await outputRoot.write('pnpm-workspace.yaml', await packageManager.format(`
|
|
112
310
|
packages:
|
|
113
311
|
- './packages/*'
|
|
@@ -166,15 +364,13 @@ async function createApp() {
|
|
|
166
364
|
await outputRoot.write(path__namespace.join(appDirectory, 'package.json'), await packageManager.format(JSON.stringify(projectPackageJson), {
|
|
167
365
|
as: 'json-stringify'
|
|
168
366
|
}));
|
|
169
|
-
await Promise.all([packageManager.addToTsConfig(appDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(appDirectory, outputRoot, packageManager$1)]);
|
|
367
|
+
await Promise.all([packageManager.addToTsConfig(appDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(appDirectory, outputRoot, packageManager$1.type)]);
|
|
170
368
|
}
|
|
171
369
|
|
|
172
370
|
if (shouldInstall) {
|
|
173
371
|
process.stdout.write('\nInstalling dependencies...\n'); // TODO: better loading, handle errors
|
|
174
372
|
|
|
175
|
-
|
|
176
|
-
cwd: rootDirectory
|
|
177
|
-
});
|
|
373
|
+
await packageManager$1.install();
|
|
178
374
|
process.stdout.moveCursor(0, -1);
|
|
179
375
|
process.stdout.clearLine(1);
|
|
180
376
|
console.log('Installed dependencies.');
|
|
@@ -182,22 +378,20 @@ async function createApp() {
|
|
|
182
378
|
|
|
183
379
|
const commands = [];
|
|
184
380
|
|
|
185
|
-
const packageManagerRun = command => packageManager$1 === 'npm' ? `npm run ${command}` : `pnpm ${command}`;
|
|
186
|
-
|
|
187
381
|
if (!inWorkspace && directory !== process.cwd()) {
|
|
188
|
-
commands.push(`cd ${
|
|
382
|
+
commands.push(`cd ${packageManager.cyan_1(packageManager.relativeDirectoryForDisplay(path__namespace.relative(process.cwd(), directory)))} ${packageManager.dim_1('# Move into your new app’s directory')}`);
|
|
189
383
|
}
|
|
190
384
|
|
|
191
385
|
if (!shouldInstall) {
|
|
192
|
-
commands.push(`${packageManager$1}
|
|
386
|
+
commands.push(`${packageManager$1.commands.install()} ${packageManager.dim_1('# Install all your dependencies')}`);
|
|
193
387
|
}
|
|
194
388
|
|
|
195
389
|
if (!inWorkspace) {
|
|
196
390
|
// TODO: change this condition to check if git was initialized already
|
|
197
|
-
commands.push(`git init && git add -A && git commit -m "Initial commit" ${
|
|
391
|
+
commands.push(`git init && git add -A && git commit -m "Initial commit" ${packageManager.dim_1('# Start your git history (optional)')}`);
|
|
198
392
|
}
|
|
199
393
|
|
|
200
|
-
commands.push(`${
|
|
394
|
+
commands.push(`${packageManager$1.commands.run('develop')} ${packageManager.dim_1('# Start the development server')}`);
|
|
201
395
|
const whatsNext = index.stripIndent(_t2 || (_t2 = _`
|
|
202
396
|
Your new app is ready to go! There’s just ${0} you’ll need to take
|
|
203
397
|
in order to start developing:
|
|
@@ -212,13 +406,13 @@ async function createApp() {
|
|
|
212
406
|
${0}
|
|
213
407
|
|
|
214
408
|
Have fun! 🎉
|
|
215
|
-
`),
|
|
409
|
+
`), packageManager.underline_1(packageManager.magenta_1('https://github.com/lemonmade/quilt/tree/main/documentation')));
|
|
216
410
|
console.log();
|
|
217
411
|
console.log(followUp);
|
|
218
412
|
} // Argument handling
|
|
219
413
|
|
|
220
414
|
function getArgv() {
|
|
221
|
-
const argv =
|
|
415
|
+
const argv = arg_1({
|
|
222
416
|
'--yes': Boolean,
|
|
223
417
|
'-y': '--yes',
|
|
224
418
|
'--name': String,
|
|
@@ -269,7 +463,7 @@ async function getDirectory(argv, {
|
|
|
269
463
|
const relativeDirectory = path__namespace.relative(process.cwd(), directory);
|
|
270
464
|
const empty = await index.prompt({
|
|
271
465
|
type: 'confirm',
|
|
272
|
-
message: `Directory ${
|
|
466
|
+
message: `Directory ${packageManager.bold_1(packageManager.relativeDirectoryForDisplay(relativeDirectory))} is not empty, is it safe to empty it?`,
|
|
273
467
|
initial: true
|
|
274
468
|
});
|
|
275
469
|
if (empty) break;
|
|
@@ -296,12 +490,12 @@ async function getTemplate(argv) {
|
|
|
296
490
|
const template = await index.prompt({
|
|
297
491
|
type: 'select',
|
|
298
492
|
message: 'What template would you like to use?',
|
|
299
|
-
hint: `Use ${
|
|
493
|
+
hint: `Use ${packageManager.bold_1('arrow keys')} to select, and ${packageManager.bold_1('return')} to submit`,
|
|
300
494
|
choices: [{
|
|
301
|
-
title: `${
|
|
495
|
+
title: `${packageManager.bold_1('The basics')}, a web app with a minimal file structure`,
|
|
302
496
|
value: 'basic'
|
|
303
497
|
}, {
|
|
304
|
-
title: `${
|
|
498
|
+
title: `${packageManager.bold_1('Itty-bitty')}, an entire web app in a single file`,
|
|
305
499
|
value: 'single-file'
|
|
306
500
|
} // TODO: GraphQL API
|
|
307
501
|
]
|