@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.
@@ -1,12 +1,12 @@
1
1
  import * as fs from 'node:fs';
2
2
  import * as path from 'node:path';
3
- import { execSync } from 'node:child_process';
4
- import { s as stripIndent, c as cyan_1, p as printHelp, g as getCreateAsMonorepo, a as getShouldInstall, d as getPackageManager, e as getExtrasToSetup, b as bold_1, f as dim_1, u as underline_1, m as magenta_1, h as arg_1, i as prompt } from './index.mjs';
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 argv = getArgv();
17
+ const args = getArguments();
18
18
 
19
- if (argv['--help']) {
20
- var _argv$PackageManag;
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: (_argv$PackageManag = argv['--package-manager']) === null || _argv$PackageManag === void 0 ? void 0 : _argv$PackageManag.toLowerCase()
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(argv);
45
- const directory = await getDirectory(argv, {
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(argv);
50
- const useReact = await getReact(argv);
51
- const createAsMonorepo = !inWorkspace && (await getCreateAsMonorepo(argv));
52
- const shouldInstall = await getShouldInstall(argv);
53
- const packageManager = await getPackageManager(argv);
54
- const setupExtras = await getExtrasToSetup(argv, {
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: argv['--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: argv['--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
- execSync(`${packageManager} install`, {
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(`pnpm install ${dim_1('# Install all your dependencies')}`);
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 getArgv() {
242
- const argv = arg_1({
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 argv;
264
+ return args;
265
265
  }
266
266
 
267
- async function getName(argv) {
267
+ async function getName(args) {
268
268
  let {
269
269
  '--name': name
270
- } = argv;
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(argv, {
283
+ async function getDirectory(args, {
284
284
  name,
285
285
  inWorkspace
286
286
  }) {
287
- let directory = argv['--directory'] ? path.resolve(argv['--directory']) : undefined;
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 (!argv['--yes']) {
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(argv) {
321
+ async function getPublic(args) {
322
322
  let isPublic;
323
323
 
324
- if (argv['--public'] || argv['--yes']) {
324
+ if (args['--public'] || args['--yes']) {
325
325
  isPublic = true;
326
- } else if (argv['--private']) {
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(argv) {
339
+ async function getReact(args) {
340
340
  let useReact;
341
341
 
342
- if (argv['--react'] || argv['--yes']) {
342
+ if (args['--react'] || args['--yes']) {
343
343
  useReact = true;
344
- } else if (argv['--no-react']) {
344
+ } else if (args['--no-react']) {
345
345
  useReact = false;
346
346
  } else {
347
347
  useReact = await prompt({
@@ -1,4 +1,4 @@
1
- import { j as getDefaultExportFromCjs, k as commonjsGlobal } from './index.mjs';
1
+ import { g as getDefaultExportFromCjs, f as commonjsGlobal } from './index.mjs';
2
2
 
3
3
  function _mergeNamespaces(n, m) {
4
4
  m.forEach(function (e) {
@@ -1,4 +1,4 @@
1
- import { j as getDefaultExportFromCjs, k as commonjsGlobal } from './index.mjs';
1
+ import { g as getDefaultExportFromCjs, f as commonjsGlobal } from './index.mjs';
2
2
 
3
3
  function _mergeNamespaces(n, m) {
4
4
  m.forEach(function (e) {
@@ -1,4 +1,4 @@
1
- import { j as getDefaultExportFromCjs } from './index.mjs';
1
+ import { g as getDefaultExportFromCjs } from './index.mjs';
2
2
 
3
3
  function _mergeNamespaces(n, m) {
4
4
  m.forEach(function (e) {