@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/build/esm/package.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as toValidPackageName, e as emptyDirectory, f as format, m as mergeDependencies, l as loadTemplate, a as addToTsConfig, b as addToPackageManagerWorkspaces, r as relativeDirectoryForDisplay, i as isEmpty, c as createOutputTarget } from './package-manager.mjs';
|
|
3
|
+
import { s as stripIndent, c as cyan_1, p as printHelp, b as bold_1, d as dim_1, u as underline_1, m as magenta_1, e as parseArguments, a as prompt } from './index.mjs';
|
|
4
|
+
import { g as getCreateAsMonorepo, a as getShouldInstall, d as getPackageManager, e as getExtrasToSetup, t as toValidPackageName, f as emptyDirectory, h as format, m as mergeDependencies, l as loadTemplate, i as addToTsConfig, j as addToPackageManagerWorkspaces, r as relativeDirectoryForDisplay, o as isEmpty, p as createOutputTarget } from './shared/package-manager.mjs';
|
|
6
5
|
import 'node:tty';
|
|
7
6
|
import 'node:url';
|
|
8
7
|
import 'node:readline';
|
|
9
8
|
import 'node:events';
|
|
9
|
+
import 'node:child_process';
|
|
10
10
|
|
|
11
11
|
let _ = t => t,
|
|
12
12
|
_t,
|
|
@@ -14,10 +14,10 @@ let _ = t => t,
|
|
|
14
14
|
_t3,
|
|
15
15
|
_t4;
|
|
16
16
|
async function createProject() {
|
|
17
|
-
const
|
|
17
|
+
const args = getArguments();
|
|
18
18
|
|
|
19
|
-
if (
|
|
20
|
-
var
|
|
19
|
+
if (args['--help']) {
|
|
20
|
+
var _args$PackageManag;
|
|
21
21
|
|
|
22
22
|
const additionalOptions = stripIndent(_t || (_t = _`
|
|
23
23
|
${0}, ${0}
|
|
@@ -35,23 +35,25 @@ async function createProject() {
|
|
|
35
35
|
printHelp({
|
|
36
36
|
kind: 'package',
|
|
37
37
|
options: additionalOptions,
|
|
38
|
-
packageManager: (
|
|
38
|
+
packageManager: (_args$PackageManag = args['--package-manager']) === null || _args$PackageManag === void 0 ? void 0 : _args$PackageManag.toLowerCase()
|
|
39
39
|
});
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const inWorkspace = fs.existsSync('quilt.workspace.ts');
|
|
44
|
-
const name = await getName(
|
|
45
|
-
const directory = await getDirectory(
|
|
44
|
+
const name = await getName(args);
|
|
45
|
+
const directory = await getDirectory(args, {
|
|
46
46
|
name,
|
|
47
47
|
inWorkspace
|
|
48
48
|
});
|
|
49
|
-
const isPublic = await getPublic(
|
|
50
|
-
const useReact = await getReact(
|
|
51
|
-
const createAsMonorepo = !inWorkspace && (await getCreateAsMonorepo(
|
|
52
|
-
const shouldInstall = await getShouldInstall(
|
|
53
|
-
const packageManager = await getPackageManager(
|
|
54
|
-
|
|
49
|
+
const isPublic = await getPublic(args);
|
|
50
|
+
const useReact = await getReact(args);
|
|
51
|
+
const createAsMonorepo = !inWorkspace && (await getCreateAsMonorepo(args));
|
|
52
|
+
const shouldInstall = await getShouldInstall(args);
|
|
53
|
+
const packageManager = await getPackageManager(args, {
|
|
54
|
+
root: directory
|
|
55
|
+
});
|
|
56
|
+
const setupExtras = await getExtrasToSetup(args, {
|
|
55
57
|
inWorkspace
|
|
56
58
|
});
|
|
57
59
|
const partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
@@ -91,7 +93,7 @@ async function createProject() {
|
|
|
91
93
|
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
92
94
|
workspacePackageJson.name = toValidPackageName(name);
|
|
93
95
|
|
|
94
|
-
if (packageManager === 'pnpm') {
|
|
96
|
+
if (packageManager.type === 'pnpm') {
|
|
95
97
|
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
96
98
|
packages:
|
|
97
99
|
- './packages/*'
|
|
@@ -128,7 +130,7 @@ async function createProject() {
|
|
|
128
130
|
name: toValidPackageName(name),
|
|
129
131
|
react: useReact,
|
|
130
132
|
isPublic,
|
|
131
|
-
registry:
|
|
133
|
+
registry: args['--registry']
|
|
132
134
|
});
|
|
133
135
|
quiltProject = quiltProject.replace('quiltPackage', 'quiltWorkspace, quiltPackage').replace('quiltPackage(', 'quiltWorkspace(), quiltPackage(');
|
|
134
136
|
await outputRoot.write('quilt.project.ts', await format(quiltProject, {
|
|
@@ -169,21 +171,19 @@ async function createProject() {
|
|
|
169
171
|
name: toValidPackageName(name),
|
|
170
172
|
react: useReact,
|
|
171
173
|
isPublic,
|
|
172
|
-
registry:
|
|
174
|
+
registry: args['--registry']
|
|
173
175
|
});
|
|
174
176
|
await outputRoot.write(path.join(packageDirectory, 'package.json'), await format(JSON.stringify(projectPackageJson), {
|
|
175
177
|
as: 'json-stringify'
|
|
176
178
|
}));
|
|
177
179
|
await outputRoot.write(path.join(packageDirectory, 'quilt.project.ts'), quiltProject);
|
|
178
|
-
await Promise.all([addToTsConfig(packageDirectory, outputRoot), addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager)]);
|
|
180
|
+
await Promise.all([addToTsConfig(packageDirectory, outputRoot), addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager.type)]);
|
|
179
181
|
}
|
|
180
182
|
|
|
181
183
|
if (shouldInstall) {
|
|
182
184
|
process.stdout.write('\nInstalling dependencies...\n'); // TODO: better loading, handle errors
|
|
183
185
|
|
|
184
|
-
|
|
185
|
-
cwd: rootDirectory
|
|
186
|
-
});
|
|
186
|
+
await packageManager.install();
|
|
187
187
|
process.stdout.moveCursor(0, -1);
|
|
188
188
|
process.stdout.clearLine(1);
|
|
189
189
|
console.log('Installed dependencies.');
|
|
@@ -208,7 +208,7 @@ async function createProject() {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
if (!shouldInstall) {
|
|
211
|
-
commands.push(
|
|
211
|
+
commands.push(`${packageManager.commands.install()} ${dim_1('# Install all your dependencies')}`);
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
if (!inWorkspace) {
|
|
@@ -238,8 +238,8 @@ async function createProject() {
|
|
|
238
238
|
console.log(followUp);
|
|
239
239
|
} // Argument handling
|
|
240
240
|
|
|
241
|
-
function
|
|
242
|
-
const
|
|
241
|
+
function getArguments() {
|
|
242
|
+
const args = parseArguments({
|
|
243
243
|
'--yes': Boolean,
|
|
244
244
|
'-y': '--yes',
|
|
245
245
|
'--name': String,
|
|
@@ -261,13 +261,13 @@ function getArgv() {
|
|
|
261
261
|
}, {
|
|
262
262
|
permissive: true
|
|
263
263
|
});
|
|
264
|
-
return
|
|
264
|
+
return args;
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
async function getName(
|
|
267
|
+
async function getName(args) {
|
|
268
268
|
let {
|
|
269
269
|
'--name': name
|
|
270
|
-
} =
|
|
270
|
+
} = args;
|
|
271
271
|
|
|
272
272
|
if (name == null) {
|
|
273
273
|
name = await prompt({
|
|
@@ -280,11 +280,11 @@ async function getName(argv) {
|
|
|
280
280
|
return name;
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
async function getDirectory(
|
|
283
|
+
async function getDirectory(args, {
|
|
284
284
|
name,
|
|
285
285
|
inWorkspace
|
|
286
286
|
}) {
|
|
287
|
-
let directory =
|
|
287
|
+
let directory = args['--directory'] ? path.resolve(args['--directory']) : undefined;
|
|
288
288
|
|
|
289
289
|
if (directory == null) {
|
|
290
290
|
const basePackageName = toValidPackageName(name.split('/').pop());
|
|
@@ -296,7 +296,7 @@ async function getDirectory(argv, {
|
|
|
296
296
|
}));
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
-
while (!
|
|
299
|
+
while (!args['--yes']) {
|
|
300
300
|
if (fs.existsSync(directory) && !(await isEmpty(directory))) {
|
|
301
301
|
const relativeDirectory = path.relative(process.cwd(), directory);
|
|
302
302
|
const empty = await prompt({
|
|
@@ -318,12 +318,12 @@ async function getDirectory(argv, {
|
|
|
318
318
|
return directory;
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
async function getPublic(
|
|
321
|
+
async function getPublic(args) {
|
|
322
322
|
let isPublic;
|
|
323
323
|
|
|
324
|
-
if (
|
|
324
|
+
if (args['--public'] || args['--yes']) {
|
|
325
325
|
isPublic = true;
|
|
326
|
-
} else if (
|
|
326
|
+
} else if (args['--private']) {
|
|
327
327
|
isPublic = false;
|
|
328
328
|
} else {
|
|
329
329
|
isPublic = await prompt({
|
|
@@ -336,12 +336,12 @@ async function getPublic(argv) {
|
|
|
336
336
|
return isPublic;
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
-
async function getReact(
|
|
339
|
+
async function getReact(args) {
|
|
340
340
|
let useReact;
|
|
341
341
|
|
|
342
|
-
if (
|
|
342
|
+
if (args['--react'] || args['--yes']) {
|
|
343
343
|
useReact = true;
|
|
344
|
-
} else if (
|
|
344
|
+
} else if (args['--no-react']) {
|
|
345
345
|
useReact = false;
|
|
346
346
|
} else {
|
|
347
347
|
useReact = await prompt({
|