@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
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
import require$$0 from 'node:tty';
|
|
2
|
+
import { a as prompt } from '../index.mjs';
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
import { execSync } from 'node:child_process';
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import { relative } from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
|
|
10
|
+
const VALID_PACKAGE_MANAGERS = new Set(['npm', 'pnpm', 'yarn']);
|
|
11
|
+
function createPackageManagerRunner(type, {
|
|
12
|
+
root = process.cwd()
|
|
13
|
+
} = {}) {
|
|
14
|
+
return {
|
|
15
|
+
type,
|
|
16
|
+
commands: {
|
|
17
|
+
run(command, ...args) {
|
|
18
|
+
return type === 'npm' ? `npm run ${command}${stringifyArgs(args)}` : `${type} ${command}${stringifyArgs(args)}`;
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
install(...args) {
|
|
22
|
+
return `${type} install${stringifyArgs(args)}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
async install() {
|
|
28
|
+
execSync(`${type} install`, {
|
|
29
|
+
cwd: root
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
async run(command, args) {
|
|
34
|
+
execSync(`${type} ${command} ${args.join(' ')}`, {
|
|
35
|
+
cwd: root
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function stringifyArgs(args) {
|
|
43
|
+
return args.length === 0 ? '' : ` ${args.join(' ')}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function getPackageManager$1(explicitPackageManager) {
|
|
47
|
+
if (explicitPackageManager) {
|
|
48
|
+
const normalizedPackageManager = explicitPackageManager.toLowerCase();
|
|
49
|
+
return VALID_PACKAGE_MANAGERS.has(normalizedPackageManager) ? normalizedPackageManager : undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const npmUserAgent = process.env['npm_config_user_agent'];
|
|
53
|
+
|
|
54
|
+
if (npmUserAgent !== null && npmUserAgent !== void 0 && npmUserAgent.includes('pnpm') || existsSync('pnpm-lock.yaml')) {
|
|
55
|
+
return 'pnpm';
|
|
56
|
+
} else if (npmUserAgent !== null && npmUserAgent !== void 0 && npmUserAgent.includes('yarn') || existsSync('yarn.lock')) {
|
|
57
|
+
return 'yarn';
|
|
58
|
+
} else if (npmUserAgent !== null && npmUserAgent !== void 0 && npmUserAgent.includes('npm') || existsSync('package-lock.json')) {
|
|
59
|
+
return 'npm';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function loadTemplate(name) {
|
|
64
|
+
let templateRootPromise;
|
|
65
|
+
return {
|
|
66
|
+
async copy(to, handleFile) {
|
|
67
|
+
var _templateRootPromise;
|
|
68
|
+
|
|
69
|
+
(_templateRootPromise = templateRootPromise) !== null && _templateRootPromise !== void 0 ? _templateRootPromise : templateRootPromise = templateDirectory(name);
|
|
70
|
+
const templateRoot = await templateRootPromise;
|
|
71
|
+
const targetRoot = path.resolve(to);
|
|
72
|
+
const files = fs.readdirSync(templateRoot).filter(file => !path.basename(file).startsWith('.'));
|
|
73
|
+
|
|
74
|
+
for (const file of files) {
|
|
75
|
+
if (handleFile) {
|
|
76
|
+
if (!handleFile(file)) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const targetPath = path.join(targetRoot, file.startsWith('_') ? `.${file.slice(1)}` : file);
|
|
82
|
+
copy(path.join(templateRoot, file), targetPath);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
async read(file) {
|
|
87
|
+
var _templateRootPromise2;
|
|
88
|
+
|
|
89
|
+
(_templateRootPromise2 = templateRootPromise) !== null && _templateRootPromise2 !== void 0 ? _templateRootPromise2 : templateRootPromise = templateDirectory(name);
|
|
90
|
+
const templateRoot = await templateRootPromise;
|
|
91
|
+
return fs.readFileSync(path.join(templateRoot, file), {
|
|
92
|
+
encoding: 'utf8'
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function createOutputTarget(target) {
|
|
99
|
+
return {
|
|
100
|
+
root: target,
|
|
101
|
+
|
|
102
|
+
read(file) {
|
|
103
|
+
return fs.promises.readFile(path.resolve(target, file), {
|
|
104
|
+
encoding: 'utf8'
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
async write(file, content) {
|
|
109
|
+
await writeFile(path.resolve(target, file), content);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
let packageRootPromise;
|
|
115
|
+
|
|
116
|
+
async function templateDirectory(name) {
|
|
117
|
+
return path.join(await getPackageRoot(), 'templates', name);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function getPackageRoot() {
|
|
121
|
+
if (!packageRootPromise) {
|
|
122
|
+
packageRootPromise = (async () => {
|
|
123
|
+
const {
|
|
124
|
+
packageDirectory
|
|
125
|
+
} = await import('../index2.mjs');
|
|
126
|
+
return packageDirectory({
|
|
127
|
+
cwd: path.dirname(fileURLToPath(import.meta.url))
|
|
128
|
+
});
|
|
129
|
+
})();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return packageRootPromise;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function toValidPackageName(projectName) {
|
|
136
|
+
return projectName.trim().toLowerCase().replace(/\s+/g, '-').replace(/^[._]/, '').replace(/[^a-z0-9-~@/]+/g, '-');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function copy(source, destination) {
|
|
140
|
+
const stat = fs.statSync(source);
|
|
141
|
+
|
|
142
|
+
if (stat.isDirectory()) {
|
|
143
|
+
copyDirectory(source, destination);
|
|
144
|
+
} else {
|
|
145
|
+
fs.copyFileSync(source, destination);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function copyDirectory(source, destination) {
|
|
150
|
+
fs.mkdirSync(destination, {
|
|
151
|
+
recursive: true
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
for (const file of fs.readdirSync(source)) {
|
|
155
|
+
const srcFile = path.resolve(source, file);
|
|
156
|
+
const destFile = path.resolve(destination, file);
|
|
157
|
+
copy(srcFile, destFile);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function writeFile(file, content) {
|
|
162
|
+
await fs.promises.writeFile(file, content);
|
|
163
|
+
}
|
|
164
|
+
async function isEmpty(path) {
|
|
165
|
+
return fs.readdirSync(path).length === 0;
|
|
166
|
+
}
|
|
167
|
+
async function emptyDirectory(dir) {
|
|
168
|
+
if (!fs.existsSync(dir)) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
for (const file of fs.readdirSync(dir)) {
|
|
173
|
+
fs.rmSync(path.resolve(dir, file), {
|
|
174
|
+
force: true,
|
|
175
|
+
recursive: true
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function relativeDirectoryForDisplay(relativeDirectory) {
|
|
180
|
+
return relativeDirectory.startsWith('.') ? relativeDirectory : `.${path.sep}${relativeDirectory}`;
|
|
181
|
+
}
|
|
182
|
+
async function format(content, {
|
|
183
|
+
as: parser
|
|
184
|
+
}) {
|
|
185
|
+
const [{
|
|
186
|
+
format
|
|
187
|
+
}, {
|
|
188
|
+
default: babel
|
|
189
|
+
}, {
|
|
190
|
+
default: typescript
|
|
191
|
+
}, {
|
|
192
|
+
default: yaml
|
|
193
|
+
}] = await Promise.all([import('../standalone.mjs').then(function (n) { return n.s; }), import('../parser-babel.mjs').then(function (n) { return n.p; }), import('../parser-typescript.mjs').then(function (n) { return n.p; }), import('../parser-yaml.mjs').then(function (n) { return n.p; })]);
|
|
194
|
+
return format(content, {
|
|
195
|
+
arrowParens: 'always',
|
|
196
|
+
bracketSpacing: false,
|
|
197
|
+
singleQuote: true,
|
|
198
|
+
trailingComma: 'all',
|
|
199
|
+
parser,
|
|
200
|
+
plugins: [babel, typescript, yaml]
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function mergeDependencies(first = {}, second = {}) {
|
|
204
|
+
const all = { ...first,
|
|
205
|
+
...second
|
|
206
|
+
};
|
|
207
|
+
const merged = {};
|
|
208
|
+
|
|
209
|
+
for (const [key, value] of Object.entries(all).sort(([keyOne], [keyTwo]) => keyOne.localeCompare(keyTwo))) {
|
|
210
|
+
merged[key] = value;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return merged;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
var colorette = {};
|
|
217
|
+
|
|
218
|
+
Object.defineProperty(colorette, '__esModule', { value: true });
|
|
219
|
+
|
|
220
|
+
var tty = require$$0;
|
|
221
|
+
|
|
222
|
+
function _interopNamespace(e) {
|
|
223
|
+
if (e && e.__esModule) return e;
|
|
224
|
+
var n = Object.create(null);
|
|
225
|
+
if (e) {
|
|
226
|
+
Object.keys(e).forEach(function (k) {
|
|
227
|
+
if (k !== 'default') {
|
|
228
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
229
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
230
|
+
enumerable: true,
|
|
231
|
+
get: function () { return e[k]; }
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
n["default"] = e;
|
|
237
|
+
return Object.freeze(n);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
var tty__namespace = /*#__PURE__*/_interopNamespace(tty);
|
|
241
|
+
|
|
242
|
+
const env = process.env || {};
|
|
243
|
+
const argv = process.argv || [];
|
|
244
|
+
|
|
245
|
+
const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
|
246
|
+
const isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
|
247
|
+
const isWindows = process.platform === "win32";
|
|
248
|
+
|
|
249
|
+
const isCompatibleTerminal =
|
|
250
|
+
tty__namespace && tty__namespace.isatty && tty__namespace.isatty(1) && env.TERM && env.TERM !== "dumb";
|
|
251
|
+
|
|
252
|
+
const isCI =
|
|
253
|
+
"CI" in env &&
|
|
254
|
+
("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
|
255
|
+
|
|
256
|
+
const isColorSupported =
|
|
257
|
+
!isDisabled && (isForced || isWindows || isCompatibleTerminal || isCI);
|
|
258
|
+
|
|
259
|
+
const replaceClose = (
|
|
260
|
+
index,
|
|
261
|
+
string,
|
|
262
|
+
close,
|
|
263
|
+
replace,
|
|
264
|
+
head = string.substring(0, index) + replace,
|
|
265
|
+
tail = string.substring(index + close.length),
|
|
266
|
+
next = tail.indexOf(close)
|
|
267
|
+
) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
268
|
+
|
|
269
|
+
const clearBleed = (index, string, open, close, replace) =>
|
|
270
|
+
index < 0
|
|
271
|
+
? open + string + close
|
|
272
|
+
: open + replaceClose(index, string, close, replace) + close;
|
|
273
|
+
|
|
274
|
+
const filterEmpty =
|
|
275
|
+
(open, close, replace = open, at = open.length + 1) =>
|
|
276
|
+
(string) =>
|
|
277
|
+
string || !(string === "" || string === undefined)
|
|
278
|
+
? clearBleed(
|
|
279
|
+
("" + string).indexOf(close, at),
|
|
280
|
+
string,
|
|
281
|
+
open,
|
|
282
|
+
close,
|
|
283
|
+
replace
|
|
284
|
+
)
|
|
285
|
+
: "";
|
|
286
|
+
|
|
287
|
+
const init = (open, close, replace) =>
|
|
288
|
+
filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
289
|
+
|
|
290
|
+
const colors = {
|
|
291
|
+
reset: init(0, 0),
|
|
292
|
+
bold: init(1, 22, "\x1b[22m\x1b[1m"),
|
|
293
|
+
dim: init(2, 22, "\x1b[22m\x1b[2m"),
|
|
294
|
+
italic: init(3, 23),
|
|
295
|
+
underline: init(4, 24),
|
|
296
|
+
inverse: init(7, 27),
|
|
297
|
+
hidden: init(8, 28),
|
|
298
|
+
strikethrough: init(9, 29),
|
|
299
|
+
black: init(30, 39),
|
|
300
|
+
red: init(31, 39),
|
|
301
|
+
green: init(32, 39),
|
|
302
|
+
yellow: init(33, 39),
|
|
303
|
+
blue: init(34, 39),
|
|
304
|
+
magenta: init(35, 39),
|
|
305
|
+
cyan: init(36, 39),
|
|
306
|
+
white: init(37, 39),
|
|
307
|
+
gray: init(90, 39),
|
|
308
|
+
bgBlack: init(40, 49),
|
|
309
|
+
bgRed: init(41, 49),
|
|
310
|
+
bgGreen: init(42, 49),
|
|
311
|
+
bgYellow: init(43, 49),
|
|
312
|
+
bgBlue: init(44, 49),
|
|
313
|
+
bgMagenta: init(45, 49),
|
|
314
|
+
bgCyan: init(46, 49),
|
|
315
|
+
bgWhite: init(47, 49),
|
|
316
|
+
blackBright: init(90, 39),
|
|
317
|
+
redBright: init(91, 39),
|
|
318
|
+
greenBright: init(92, 39),
|
|
319
|
+
yellowBright: init(93, 39),
|
|
320
|
+
blueBright: init(94, 39),
|
|
321
|
+
magentaBright: init(95, 39),
|
|
322
|
+
cyanBright: init(96, 39),
|
|
323
|
+
whiteBright: init(97, 39),
|
|
324
|
+
bgBlackBright: init(100, 49),
|
|
325
|
+
bgRedBright: init(101, 49),
|
|
326
|
+
bgGreenBright: init(102, 49),
|
|
327
|
+
bgYellowBright: init(103, 49),
|
|
328
|
+
bgBlueBright: init(104, 49),
|
|
329
|
+
bgMagentaBright: init(105, 49),
|
|
330
|
+
bgCyanBright: init(106, 49),
|
|
331
|
+
bgWhiteBright: init(107, 49),
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
const none = (any) => any;
|
|
335
|
+
|
|
336
|
+
const createColors = ({ useColor = isColorSupported } = {}) =>
|
|
337
|
+
useColor
|
|
338
|
+
? colors
|
|
339
|
+
: Object.keys(colors).reduce(
|
|
340
|
+
(colors, key) => ({ ...colors, [key]: none }),
|
|
341
|
+
{}
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
const {
|
|
345
|
+
reset,
|
|
346
|
+
bold,
|
|
347
|
+
dim,
|
|
348
|
+
italic,
|
|
349
|
+
underline,
|
|
350
|
+
inverse,
|
|
351
|
+
hidden,
|
|
352
|
+
strikethrough,
|
|
353
|
+
black,
|
|
354
|
+
red,
|
|
355
|
+
green,
|
|
356
|
+
yellow,
|
|
357
|
+
blue,
|
|
358
|
+
magenta,
|
|
359
|
+
cyan,
|
|
360
|
+
white,
|
|
361
|
+
gray,
|
|
362
|
+
bgBlack,
|
|
363
|
+
bgRed,
|
|
364
|
+
bgGreen,
|
|
365
|
+
bgYellow,
|
|
366
|
+
bgBlue,
|
|
367
|
+
bgMagenta,
|
|
368
|
+
bgCyan,
|
|
369
|
+
bgWhite,
|
|
370
|
+
blackBright,
|
|
371
|
+
redBright,
|
|
372
|
+
greenBright,
|
|
373
|
+
yellowBright,
|
|
374
|
+
blueBright,
|
|
375
|
+
magentaBright,
|
|
376
|
+
cyanBright,
|
|
377
|
+
whiteBright,
|
|
378
|
+
bgBlackBright,
|
|
379
|
+
bgRedBright,
|
|
380
|
+
bgGreenBright,
|
|
381
|
+
bgYellowBright,
|
|
382
|
+
bgBlueBright,
|
|
383
|
+
bgMagentaBright,
|
|
384
|
+
bgCyanBright,
|
|
385
|
+
bgWhiteBright,
|
|
386
|
+
} = createColors();
|
|
387
|
+
|
|
388
|
+
colorette.bgBlack = bgBlack;
|
|
389
|
+
colorette.bgBlackBright = bgBlackBright;
|
|
390
|
+
colorette.bgBlue = bgBlue;
|
|
391
|
+
colorette.bgBlueBright = bgBlueBright;
|
|
392
|
+
colorette.bgCyan = bgCyan;
|
|
393
|
+
colorette.bgCyanBright = bgCyanBright;
|
|
394
|
+
colorette.bgGreen = bgGreen;
|
|
395
|
+
colorette.bgGreenBright = bgGreenBright;
|
|
396
|
+
colorette.bgMagenta = bgMagenta;
|
|
397
|
+
colorette.bgMagentaBright = bgMagentaBright;
|
|
398
|
+
colorette.bgRed = bgRed;
|
|
399
|
+
colorette.bgRedBright = bgRedBright;
|
|
400
|
+
colorette.bgWhite = bgWhite;
|
|
401
|
+
colorette.bgWhiteBright = bgWhiteBright;
|
|
402
|
+
colorette.bgYellow = bgYellow;
|
|
403
|
+
colorette.bgYellowBright = bgYellowBright;
|
|
404
|
+
colorette.black = black;
|
|
405
|
+
colorette.blackBright = blackBright;
|
|
406
|
+
colorette.blue = blue;
|
|
407
|
+
colorette.blueBright = blueBright;
|
|
408
|
+
var bold_1 = colorette.bold = bold;
|
|
409
|
+
colorette.createColors = createColors;
|
|
410
|
+
var cyan_1 = colorette.cyan = cyan;
|
|
411
|
+
colorette.cyanBright = cyanBright;
|
|
412
|
+
var dim_1 = colorette.dim = dim;
|
|
413
|
+
colorette.gray = gray;
|
|
414
|
+
colorette.green = green;
|
|
415
|
+
colorette.greenBright = greenBright;
|
|
416
|
+
colorette.hidden = hidden;
|
|
417
|
+
colorette.inverse = inverse;
|
|
418
|
+
colorette.isColorSupported = isColorSupported;
|
|
419
|
+
colorette.italic = italic;
|
|
420
|
+
var magenta_1 = colorette.magenta = magenta;
|
|
421
|
+
colorette.magentaBright = magentaBright;
|
|
422
|
+
colorette.red = red;
|
|
423
|
+
colorette.redBright = redBright;
|
|
424
|
+
colorette.reset = reset;
|
|
425
|
+
colorette.strikethrough = strikethrough;
|
|
426
|
+
var underline_1 = colorette.underline = underline;
|
|
427
|
+
colorette.white = white;
|
|
428
|
+
colorette.whiteBright = whiteBright;
|
|
429
|
+
colorette.yellow = yellow;
|
|
430
|
+
colorette.yellowBright = yellowBright;
|
|
431
|
+
|
|
432
|
+
async function getCreateAsMonorepo(argv) {
|
|
433
|
+
let createAsMonorepo;
|
|
434
|
+
|
|
435
|
+
if (argv['--monorepo' ]) {
|
|
436
|
+
createAsMonorepo = true;
|
|
437
|
+
} else if (argv['--no-monorepo']) {
|
|
438
|
+
createAsMonorepo = false;
|
|
439
|
+
} else {
|
|
440
|
+
createAsMonorepo = await prompt({
|
|
441
|
+
type: 'confirm',
|
|
442
|
+
message: 'Do you want to create this app as a monorepo, with room for more projects?',
|
|
443
|
+
initial: true
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return createAsMonorepo;
|
|
448
|
+
}
|
|
449
|
+
async function getShouldInstall(argv) {
|
|
450
|
+
let shouldInstall;
|
|
451
|
+
|
|
452
|
+
if (argv['--install'] || argv['--yes']) {
|
|
453
|
+
shouldInstall = true;
|
|
454
|
+
} else if (argv['--no-install']) {
|
|
455
|
+
shouldInstall = false;
|
|
456
|
+
} else {
|
|
457
|
+
shouldInstall = await prompt({
|
|
458
|
+
type: 'confirm',
|
|
459
|
+
message: 'Do you want to install dependencies for this app after creating it?',
|
|
460
|
+
initial: true
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return shouldInstall;
|
|
465
|
+
}
|
|
466
|
+
async function getPackageManager(argv, options) {
|
|
467
|
+
const packageManager = await getPackageManager$1(argv['--package-manager']);
|
|
468
|
+
return createPackageManagerRunner(packageManager !== null && packageManager !== void 0 ? packageManager : 'npm', options);
|
|
469
|
+
}
|
|
470
|
+
const VALID_EXTRAS = new Set(['github', 'vscode']);
|
|
471
|
+
async function getExtrasToSetup(argv, {
|
|
472
|
+
inWorkspace
|
|
473
|
+
}) {
|
|
474
|
+
if (inWorkspace || argv['--no-extras']) return new Set();
|
|
475
|
+
|
|
476
|
+
if (argv['--extras']) {
|
|
477
|
+
return new Set(argv['--extras'].filter(extra => VALID_EXTRAS.has(extra)));
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
const setupExtras = await prompt({
|
|
481
|
+
type: 'multiselect',
|
|
482
|
+
message: 'Which additional tools would you like to configure?',
|
|
483
|
+
instructions: dim_1(`\n Use ${bold_1('space')} to select, ${bold_1('a')} to select all, ${bold_1('return')} to submit`),
|
|
484
|
+
choices: [{
|
|
485
|
+
title: 'VSCode',
|
|
486
|
+
value: 'vscode'
|
|
487
|
+
}, {
|
|
488
|
+
title: 'GitHub',
|
|
489
|
+
value: 'github'
|
|
490
|
+
}]
|
|
491
|
+
});
|
|
492
|
+
const extrasToSetup = new Set(setupExtras);
|
|
493
|
+
return extrasToSetup;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
const ENDS_WITH_TSCONFIG = /[/]?tsconfig[.a-z0-9]*[.]json/i;
|
|
497
|
+
async function addToTsConfig(directory, output) {
|
|
498
|
+
var _tsconfig$references;
|
|
499
|
+
|
|
500
|
+
const tsconfig = JSON.parse(await output.read('tsconfig.json'));
|
|
501
|
+
(_tsconfig$references = tsconfig.references) !== null && _tsconfig$references !== void 0 ? _tsconfig$references : tsconfig.references = [];
|
|
502
|
+
const relativePath = relative(output.root, directory);
|
|
503
|
+
const relativeForDisplay = relativeDirectoryForDisplay(relativePath);
|
|
504
|
+
|
|
505
|
+
if (tsconfig.references.length === 0) {
|
|
506
|
+
tsconfig.references.push({
|
|
507
|
+
path: relativeForDisplay
|
|
508
|
+
});
|
|
509
|
+
} else {
|
|
510
|
+
let hasExistingReference = false;
|
|
511
|
+
let referenceFormat = 'pretty-relative';
|
|
512
|
+
|
|
513
|
+
for (const {
|
|
514
|
+
path
|
|
515
|
+
} of tsconfig.references) {
|
|
516
|
+
if (path.startsWith('./')) {
|
|
517
|
+
if (ENDS_WITH_TSCONFIG.test(path)) {
|
|
518
|
+
referenceFormat = 'pretty-tsconfig';
|
|
519
|
+
|
|
520
|
+
if (path === `${relativeForDisplay}/tsconfig.json`) {
|
|
521
|
+
hasExistingReference = true;
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
referenceFormat = 'pretty-relative';
|
|
527
|
+
|
|
528
|
+
if (path === relativeForDisplay) {
|
|
529
|
+
hasExistingReference = true;
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
} else if (ENDS_WITH_TSCONFIG.test(path)) {
|
|
533
|
+
referenceFormat = 'tsconfig';
|
|
534
|
+
|
|
535
|
+
if (path === `${relativePath}/tsconfig.json`) {
|
|
536
|
+
hasExistingReference = true;
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
} else {
|
|
540
|
+
referenceFormat = 'relative';
|
|
541
|
+
|
|
542
|
+
if (path === relativePath) {
|
|
543
|
+
hasExistingReference = true;
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if (!hasExistingReference) {
|
|
550
|
+
let path;
|
|
551
|
+
|
|
552
|
+
if (referenceFormat === 'pretty-tsconfig') {
|
|
553
|
+
path = `${relativeForDisplay}/tsconfig.json`;
|
|
554
|
+
} else if (referenceFormat === 'pretty-relative') {
|
|
555
|
+
path = relativeForDisplay;
|
|
556
|
+
} else if (referenceFormat === 'tsconfig') {
|
|
557
|
+
path = `${relativePath}/tsconfig.json`;
|
|
558
|
+
} else {
|
|
559
|
+
path = relativePath;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
tsconfig.references.push({
|
|
563
|
+
path
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
tsconfig.references = tsconfig.references.sort(({
|
|
569
|
+
path: pathOne
|
|
570
|
+
}, {
|
|
571
|
+
path: pathTwo
|
|
572
|
+
}) => pathOne.localeCompare(pathTwo));
|
|
573
|
+
await output.write('tsconfig.json', await format(JSON.stringify(tsconfig), {
|
|
574
|
+
as: 'json'
|
|
575
|
+
}));
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
async function addToPackageManagerWorkspaces(directory, output, packageManager) {
|
|
579
|
+
if (packageManager === 'pnpm') {
|
|
580
|
+
var _workspaceYaml$packag;
|
|
581
|
+
|
|
582
|
+
const {
|
|
583
|
+
parse,
|
|
584
|
+
stringify
|
|
585
|
+
} = await import('../index3.mjs').then(function (n) { return n.i; });
|
|
586
|
+
const workspaceYaml = parse(await output.read('pnpm-workspace.yaml'));
|
|
587
|
+
workspaceYaml.packages = await addToWorkspaces(relative(output.root, directory), (_workspaceYaml$packag = workspaceYaml.packages) !== null && _workspaceYaml$packag !== void 0 ? _workspaceYaml$packag : []);
|
|
588
|
+
await output.write('pnpm-workspace.yaml', await format(stringify(workspaceYaml), {
|
|
589
|
+
as: 'yaml'
|
|
590
|
+
}));
|
|
591
|
+
} else {
|
|
592
|
+
var _packageJson$workspac;
|
|
593
|
+
|
|
594
|
+
const packageJson = JSON.parse(await output.read('package.json'));
|
|
595
|
+
packageJson.workspaces = await addToWorkspaces(relative(output.root, directory), (_packageJson$workspac = packageJson.workspaces) !== null && _packageJson$workspac !== void 0 ? _packageJson$workspac : []);
|
|
596
|
+
await output.write('package.json', await format(JSON.stringify(packageJson), {
|
|
597
|
+
as: 'json-stringify'
|
|
598
|
+
}));
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
async function addToWorkspaces(relative, workspaces) {
|
|
603
|
+
if (workspaces.length === 0) {
|
|
604
|
+
return [relative];
|
|
605
|
+
} // Default documentation seems to generally exclude leading `./` on paths
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
let pretty = false;
|
|
609
|
+
let hasMatch = false;
|
|
610
|
+
const {
|
|
611
|
+
default: minimatch
|
|
612
|
+
} = await import('../minimatch.mjs').then(function (n) { return n.m; });
|
|
613
|
+
|
|
614
|
+
for (const pattern of workspaces) {
|
|
615
|
+
let normalizedPattern = pattern;
|
|
616
|
+
|
|
617
|
+
if (pattern.startsWith('./')) {
|
|
618
|
+
pretty = true;
|
|
619
|
+
normalizedPattern = pattern.slice(2);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
if (minimatch(relative, normalizedPattern)) {
|
|
623
|
+
hasMatch = true;
|
|
624
|
+
break;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
if (hasMatch) {
|
|
629
|
+
return workspaces;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
return [...workspaces, pretty ? relativeDirectoryForDisplay(relative) : relative].sort((patternOne, patternTwo) => patternOne.localeCompare(patternTwo));
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
export { getShouldInstall as a, bold_1 as b, cyan_1 as c, getPackageManager as d, getExtrasToSetup as e, emptyDirectory as f, getCreateAsMonorepo as g, format as h, addToTsConfig as i, addToPackageManagerWorkspaces as j, dim_1 as k, loadTemplate as l, mergeDependencies as m, magenta_1 as n, isEmpty as o, createOutputTarget as p, relativeDirectoryForDisplay as r, toValidPackageName as t, underline_1 as u };
|
package/build/esm/standalone.mjs
CHANGED