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