@quilted/create 0.1.22 → 0.1.25

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/build/esm/app.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { execSync } from 'child_process';
1
+ import * as fs from 'node:fs';
2
+ import * as path from 'node:path';
3
+ import { execSync } from 'node:child_process';
4
4
  import { s as stripIndent, c as cyan_1, b as bold_1, p as printHelp, g as getCreateAsMonorepo, a as getShouldInstall, d as getPackageManager, e as getExtrasToSetup, f as dim_1, u as underline_1, m as magenta_1, h as arg_1, i as prompt } from './index.mjs';
5
- import { e as emptyDirectory, t as toValidPackageName, f as format, l as loadTemplate, a as addToTsConfig, b as addToPackageManagerWorkspaces, r as relativeDirectoryForDisplay, i as isEmpty, c as createOutputTarget } from './package-manager.mjs';
6
- import 'tty';
7
- import 'url';
8
- import 'readline';
9
- import 'events';
5
+ import { e as emptyDirectory, t as toValidPackageName, 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';
6
+ import 'node:tty';
7
+ import 'node:url';
8
+ import 'node:readline';
9
+ import 'node:events';
10
10
 
11
11
  let _ = t => t,
12
12
  _t,
@@ -103,6 +103,7 @@ async function createApp() {
103
103
  workspacePackageJson.name = toValidPackageName(name);
104
104
  workspacePackageJson.eslintConfig = projectPackageJson.eslintConfig;
105
105
  workspacePackageJson.browserslist = projectPackageJson.browserslist;
106
+ workspacePackageJson.devDependencies = mergeDependencies(workspacePackageJson.devDependencies, projectPackageJson.devDependencies);
106
107
  let quiltProject = await appTemplate.read('quilt.project.ts');
107
108
  quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
108
109
  await outputRoot.write('quilt.project.ts', await format(quiltProject, {
@@ -158,12 +159,14 @@ async function createApp() {
158
159
 
159
160
  const commands = [];
160
161
 
162
+ const packageManagerRun = command => packageManager === 'npm' ? `npm run ${command}` : `pnpm ${command}`;
163
+
161
164
  if (!inWorkspace && directory !== process.cwd()) {
162
165
  commands.push(`cd ${cyan_1(relativeDirectoryForDisplay(path.relative(process.cwd(), directory)))} ${dim_1('# Move into your new app’s directory')}`);
163
166
  }
164
167
 
165
168
  if (!shouldInstall) {
166
- commands.push(`pnpm install ${dim_1('# Install all your dependencies')}`);
169
+ commands.push(`${packageManager} install ${dim_1('# Install all your dependencies')}`);
167
170
  }
168
171
 
169
172
  if (!inWorkspace) {
@@ -171,7 +174,7 @@ async function createApp() {
171
174
  commands.push(`git init && git add -A && git commit -m "Initial commit" ${dim_1('# Start your git history (optional)')}`);
172
175
  }
173
176
 
174
- commands.push(`pnpm develop ${dim_1('# Start the development server')}`);
177
+ commands.push(`${packageManagerRun('develop')} ${dim_1('# Start the development server')}`);
175
178
  const whatsNext = stripIndent(_t2 || (_t2 = _`
176
179
  Your new app is ready to go! There’s just ${0} you’ll need to take
177
180
  in order to start developing:
@@ -1,9 +1,9 @@
1
- import require$$0 from 'tty';
2
- import * as fs from 'fs';
3
- import 'path';
4
- import 'url';
5
- import require$$0$1 from 'readline';
6
- import require$$2 from 'events';
1
+ import require$$0 from 'node:tty';
2
+ import * as fs from 'node:fs';
3
+ import 'node:path';
4
+ import 'node:url';
5
+ import require$$0$1 from 'node:readline';
6
+ import require$$2 from 'node:events';
7
7
 
8
8
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
9
9
 
@@ -1,7 +1,7 @@
1
- import path from 'node:path';
1
+ import path__default from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import process from 'node:process';
4
- import fs, { promises } from 'node:fs';
4
+ import fs__default, { promises } from 'node:fs';
5
5
 
6
6
  /*
7
7
  How it works:
@@ -219,7 +219,7 @@ async function locatePath(
219
219
 
220
220
  return pLocate(paths, async path_ => {
221
221
  try {
222
- const stat = await statFunction(path.resolve(cwd, path_));
222
+ const stat = await statFunction(path__default.resolve(cwd, path_));
223
223
  return matchType(type, stat);
224
224
  } catch {
225
225
  return false;
@@ -238,11 +238,11 @@ function locatePathSync(
238
238
  checkType(type);
239
239
  cwd = toPath$1(cwd);
240
240
 
241
- const statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;
241
+ const statFunction = allowSymlinks ? fs__default.statSync : fs__default.lstatSync;
242
242
 
243
243
  for (const path_ of paths) {
244
244
  try {
245
- const stat = statFunction(path.resolve(cwd, path_));
245
+ const stat = statFunction(path__default.resolve(cwd, path_));
246
246
 
247
247
  if (matchType(type, stat)) {
248
248
  return path_;
@@ -256,9 +256,9 @@ const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath)
256
256
  const findUpStop = Symbol('findUpStop');
257
257
 
258
258
  async function findUpMultiple(name, options) {
259
- let directory = path.resolve(toPath(options.cwd) || '');
260
- const {root} = path.parse(directory);
261
- const stopAt = path.resolve(directory, options.stopAt || root);
259
+ let directory = path__default.resolve(toPath(options.cwd) || '');
260
+ const {root} = path__default.parse(directory);
261
+ const stopAt = path__default.resolve(directory, options.stopAt || root);
262
262
  const limit = options.limit || Number.POSITIVE_INFINITY;
263
263
  const paths = [name].flat();
264
264
 
@@ -286,22 +286,22 @@ async function findUpMultiple(name, options) {
286
286
  }
287
287
 
288
288
  if (foundPath) {
289
- matches.push(path.resolve(directory, foundPath));
289
+ matches.push(path__default.resolve(directory, foundPath));
290
290
  }
291
291
 
292
292
  if (directory === stopAt || matches.length >= limit) {
293
293
  break;
294
294
  }
295
295
 
296
- directory = path.dirname(directory);
296
+ directory = path__default.dirname(directory);
297
297
  }
298
298
 
299
299
  return matches;
300
300
  }
301
301
 
302
302
  function findUpMultipleSync(name, options) {
303
- let directory = path.resolve(toPath(options.cwd) || '');
304
- const {root} = path.parse(directory);
303
+ let directory = path__default.resolve(toPath(options.cwd) || '');
304
+ const {root} = path__default.parse(directory);
305
305
  const stopAt = options.stopAt || root;
306
306
  const limit = options.limit || Number.POSITIVE_INFINITY;
307
307
  const paths = [name].flat();
@@ -329,14 +329,14 @@ function findUpMultipleSync(name, options) {
329
329
  }
330
330
 
331
331
  if (foundPath) {
332
- matches.push(path.resolve(directory, foundPath));
332
+ matches.push(path__default.resolve(directory, foundPath));
333
333
  }
334
334
 
335
335
  if (directory === stopAt || matches.length >= limit) {
336
336
  break;
337
337
  }
338
338
 
339
- directory = path.dirname(directory);
339
+ directory = path__default.dirname(directory);
340
340
  }
341
341
 
342
342
  return matches;
@@ -354,12 +354,12 @@ function findUpSync(name, options) {
354
354
 
355
355
  async function packageDirectory({cwd} = {}) {
356
356
  const filePath = await findUp('package.json', {cwd});
357
- return filePath && path.dirname(filePath);
357
+ return filePath && path__default.dirname(filePath);
358
358
  }
359
359
 
360
360
  function packageDirectorySync({cwd} = {}) {
361
361
  const filePath = findUpSync('package.json', {cwd});
362
- return filePath && path.dirname(filePath);
362
+ return filePath && path__default.dirname(filePath);
363
363
  }
364
364
 
365
365
  export { packageDirectory, packageDirectorySync };
@@ -1,7 +1,7 @@
1
- import * as path from 'path';
2
- import { relative } from 'path';
3
- import * as fs from 'fs';
4
- import { fileURLToPath } from 'url';
1
+ import * as path from 'node:path';
2
+ import { relative } from 'node:path';
3
+ import * as fs from 'node:fs';
4
+ import { fileURLToPath } from 'node:url';
5
5
  import './index.mjs';
6
6
 
7
7
  function loadTemplate(name) {
@@ -130,18 +130,32 @@ async function format(content, {
130
130
  format
131
131
  }, {
132
132
  default: babel
133
+ }, {
134
+ default: typescript
133
135
  }, {
134
136
  default: yaml
135
- }] = await Promise.all([import('./standalone.mjs').then(function (n) { return n.s; }), import('./parser-babel.mjs').then(function (n) { return n.p; }), import('./parser-yaml.mjs').then(function (n) { return n.p; })]);
137
+ }] = 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; })]);
136
138
  return format(content, {
137
139
  arrowParens: 'always',
138
140
  bracketSpacing: false,
139
141
  singleQuote: true,
140
142
  trailingComma: 'all',
141
143
  parser,
142
- plugins: [babel, yaml]
144
+ plugins: [babel, typescript, yaml]
143
145
  });
144
146
  }
147
+ function mergeDependencies(first = {}, second = {}) {
148
+ const all = { ...first,
149
+ ...second
150
+ };
151
+ const merged = {};
152
+
153
+ for (const [key, value] of Object.entries(all).sort(([keyOne], [keyTwo]) => keyOne.localeCompare(keyTwo))) {
154
+ merged[key] = value;
155
+ }
156
+
157
+ return merged;
158
+ }
145
159
 
146
160
  const ENDS_WITH_TSCONFIG = /[/]?tsconfig[.a-z0-9]*[.]json/i;
147
161
  async function addToTsConfig(directory, output) {
@@ -282,4 +296,4 @@ async function addToWorkspaces(relative, workspaces) {
282
296
  return [...workspaces, pretty ? relativeDirectoryForDisplay(relative) : relative].sort((patternOne, patternTwo) => patternOne.localeCompare(patternTwo));
283
297
  }
284
298
 
285
- export { addToTsConfig as a, addToPackageManagerWorkspaces as b, createOutputTarget as c, emptyDirectory as e, format as f, isEmpty as i, loadTemplate as l, relativeDirectoryForDisplay as r, toValidPackageName as t };
299
+ export { addToTsConfig as a, addToPackageManagerWorkspaces as b, createOutputTarget as c, emptyDirectory as e, format as f, isEmpty as i, loadTemplate as l, mergeDependencies as m, relativeDirectoryForDisplay as r, toValidPackageName as t };
@@ -1,12 +1,12 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { execSync } from 'child_process';
1
+ import * as fs from 'node:fs';
2
+ import * as path from 'node:path';
3
+ import { execSync } from 'node:child_process';
4
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, l as loadTemplate, a as addToTsConfig, b as addToPackageManagerWorkspaces, r as relativeDirectoryForDisplay, i as isEmpty, c as createOutputTarget } from './package-manager.mjs';
6
- import 'tty';
7
- import 'url';
8
- import 'readline';
9
- import 'events';
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';
6
+ import 'node:tty';
7
+ import 'node:url';
8
+ import 'node:readline';
9
+ import 'node:events';
10
10
 
11
11
  let _ = t => t,
12
12
  _t,
@@ -75,14 +75,9 @@ async function createProject() {
75
75
  const outputRoot = createOutputTarget(rootDirectory);
76
76
  const packageTemplate = loadTemplate('package');
77
77
  const workspaceTemplate = loadTemplate('workspace');
78
- let quiltProject = await packageTemplate.read('quilt.project.ts');
79
-
80
- if (useReact) {
81
- quiltProject = quiltProject.replace('react: false', 'react: true');
82
- } // If we aren’t already in a workspace, copy the workspace files over, which
78
+ let quiltProject = await packageTemplate.read('quilt.project.ts'); // If we aren’t already in a workspace, copy the workspace files over, which
83
79
  // are needed if we are making a monorepo or not.
84
80
 
85
-
86
81
  if (!inWorkspace) {
87
82
  await workspaceTemplate.copy(directory, file => {
88
83
  // When this is a single project, we use the project’s Quilt configuration as the base.
@@ -126,9 +121,7 @@ async function createProject() {
126
121
  newPackageJson.dependencies = projectPackageJson.dependencies;
127
122
  newPackageJson.peerDependencies = projectPackageJson.peerDependencies;
128
123
  newPackageJson.peerDependenciesMeta = projectPackageJson.peerDependenciesMeta;
129
- newPackageJson.devDependencies = sortKeys({ ...workspacePackageJson.devDependencies,
130
- ...projectPackageJson.devDependencies
131
- });
124
+ newPackageJson.devDependencies = mergeDependencies(workspacePackageJson.devDependencies, projectPackageJson.devDependencies);
132
125
  }
133
126
 
134
127
  adjustPackageJson(newPackageJson, {
@@ -395,15 +388,4 @@ function adjustPackageJson(packageJson, {
395
388
  return packageJson;
396
389
  }
397
390
 
398
- function sortKeys(object) {
399
- const newObject = {};
400
- const sortedEntries = Object.entries(object).sort(([keyOne], [keyTwo]) => keyOne.localeCompare(keyTwo));
401
-
402
- for (const [key, value] of sortedEntries) {
403
- newObject[key] = value;
404
- }
405
-
406
- return newObject;
407
- }
408
-
409
391
  export { createProject };