@quilted/create 0.1.30 → 0.1.32
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 +44 -74
- package/build/cjs/index.cjs +5950 -5408
- package/build/cjs/index2.cjs +21 -27
- package/build/cjs/index3.cjs +32 -32
- package/build/cjs/package.cjs +50 -90
- package/build/cjs/parser-babel.cjs +2 -2
- package/build/cjs/parser-typescript.cjs +2 -2
- package/build/cjs/parser-yaml.cjs +2 -2
- package/build/cjs/{package-manager.cjs → shared/package-manager.cjs} +53 -81
- package/build/cjs/standalone.cjs +2 -2
- package/build/esm/app.mjs +41 -70
- package/build/esm/index.mjs +5954 -5404
- package/build/esm/index2.mjs +5 -5
- package/build/esm/index3.mjs +32 -32
- package/build/esm/package.mjs +47 -86
- package/build/esm/parser-babel.mjs +2 -2
- package/build/esm/parser-typescript.mjs +2 -2
- package/build/esm/parser-yaml.mjs +2 -2
- package/build/esm/{package-manager.mjs → shared/package-manager.mjs} +48 -72
- package/build/esm/standalone.mjs +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/package.d.ts.map +1 -1
- package/build/typescript/shared/prompts.d.ts +4 -4
- package/build/typescript/shared/prompts.d.ts.map +1 -1
- package/package.json +2 -2
- package/source/app.ts +10 -9
- package/source/package.ts +7 -6
- package/source/shared/prompts.ts +6 -2
- package/templates/app-basic/package.json +1 -1
- package/templates/app-single-file/package.json +1 -1
package/build/esm/index2.mjs
CHANGED
|
@@ -164,7 +164,7 @@ async function pLocate(
|
|
|
164
164
|
{
|
|
165
165
|
concurrency = Number.POSITIVE_INFINITY,
|
|
166
166
|
preserveOrder = true,
|
|
167
|
-
},
|
|
167
|
+
} = {},
|
|
168
168
|
) {
|
|
169
169
|
const limit = pLimit(concurrency);
|
|
170
170
|
|
|
@@ -255,7 +255,7 @@ const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath)
|
|
|
255
255
|
|
|
256
256
|
const findUpStop = Symbol('findUpStop');
|
|
257
257
|
|
|
258
|
-
async function findUpMultiple(name, options) {
|
|
258
|
+
async function findUpMultiple(name, options = {}) {
|
|
259
259
|
let directory = path__default.resolve(toPath(options.cwd) || '');
|
|
260
260
|
const {root} = path__default.parse(directory);
|
|
261
261
|
const stopAt = path__default.resolve(directory, options.stopAt || root);
|
|
@@ -299,7 +299,7 @@ async function findUpMultiple(name, options) {
|
|
|
299
299
|
return matches;
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
function findUpMultipleSync(name, options) {
|
|
302
|
+
function findUpMultipleSync(name, options = {}) {
|
|
303
303
|
let directory = path__default.resolve(toPath(options.cwd) || '');
|
|
304
304
|
const {root} = path__default.parse(directory);
|
|
305
305
|
const stopAt = options.stopAt || root;
|
|
@@ -342,12 +342,12 @@ function findUpMultipleSync(name, options) {
|
|
|
342
342
|
return matches;
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
async function findUp(name, options) {
|
|
345
|
+
async function findUp(name, options = {}) {
|
|
346
346
|
const matches = await findUpMultiple(name, {...options, limit: 1});
|
|
347
347
|
return matches[0];
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
function findUpSync(name, options) {
|
|
350
|
+
function findUpSync(name, options = {}) {
|
|
351
351
|
const matches = findUpMultipleSync(name, {...options, limit: 1});
|
|
352
352
|
return matches[0];
|
|
353
353
|
}
|
package/build/esm/index3.mjs
CHANGED
|
@@ -579,7 +579,7 @@ var anchors$2 = anchors$3;
|
|
|
579
579
|
var visit$2 = visit$6;
|
|
580
580
|
var Node$p = Node$t;
|
|
581
581
|
|
|
582
|
-
|
|
582
|
+
let Alias$4 = class Alias extends Node$p.NodeBase {
|
|
583
583
|
constructor(source) {
|
|
584
584
|
super(Node$p.ALIAS);
|
|
585
585
|
this.source = source;
|
|
@@ -644,7 +644,7 @@ class Alias$4 extends Node$p.NodeBase {
|
|
|
644
644
|
}
|
|
645
645
|
return src;
|
|
646
646
|
}
|
|
647
|
-
}
|
|
647
|
+
};
|
|
648
648
|
function getAliasCount(doc, node, anchors) {
|
|
649
649
|
if (Node$p.isAlias(node)) {
|
|
650
650
|
const source = node.resolve(doc);
|
|
@@ -720,7 +720,7 @@ var Node$n = Node$t;
|
|
|
720
720
|
var toJS$4 = toJS$6;
|
|
721
721
|
|
|
722
722
|
const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
|
|
723
|
-
|
|
723
|
+
let Scalar$j = class Scalar extends Node$n.NodeBase {
|
|
724
724
|
constructor(value) {
|
|
725
725
|
super(Node$n.SCALAR);
|
|
726
726
|
this.value = value;
|
|
@@ -731,7 +731,7 @@ class Scalar$j extends Node$n.NodeBase {
|
|
|
731
731
|
toString() {
|
|
732
732
|
return String(this.value);
|
|
733
733
|
}
|
|
734
|
-
}
|
|
734
|
+
};
|
|
735
735
|
Scalar$j.BLOCK_FOLDED = 'BLOCK_FOLDED';
|
|
736
736
|
Scalar$j.BLOCK_LITERAL = 'BLOCK_LITERAL';
|
|
737
737
|
Scalar$j.PLAIN = 'PLAIN';
|
|
@@ -857,7 +857,7 @@ function collectionFromPath(schema, path, value) {
|
|
|
857
857
|
// as it does not cover untypable empty non-string iterables (e.g. []).
|
|
858
858
|
const isEmptyPath = (path) => path == null ||
|
|
859
859
|
(typeof path === 'object' && !!path[Symbol.iterator]().next().done);
|
|
860
|
-
|
|
860
|
+
let Collection$4 = class Collection extends Node$l.NodeBase {
|
|
861
861
|
constructor(type, schema) {
|
|
862
862
|
super(type);
|
|
863
863
|
Object.defineProperty(this, 'schema', {
|
|
@@ -970,7 +970,7 @@ class Collection$4 extends Node$l.NodeBase {
|
|
|
970
970
|
throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
|
-
}
|
|
973
|
+
};
|
|
974
974
|
Collection$4.maxFlowStringSingleLineLength = 60;
|
|
975
975
|
|
|
976
976
|
Collection$5.Collection = Collection$4;
|
|
@@ -1851,7 +1851,7 @@ function createPair(key, value, ctx) {
|
|
|
1851
1851
|
const v = createNode$2.createNode(value, undefined, ctx);
|
|
1852
1852
|
return new Pair$8(k, v);
|
|
1853
1853
|
}
|
|
1854
|
-
|
|
1854
|
+
let Pair$8 = class Pair {
|
|
1855
1855
|
constructor(key, value = null) {
|
|
1856
1856
|
Object.defineProperty(this, Node$h.NODE_TYPE, { value: Node$h.PAIR });
|
|
1857
1857
|
this.key = key;
|
|
@@ -1874,7 +1874,7 @@ class Pair$8 {
|
|
|
1874
1874
|
? stringifyPair.stringifyPair(this, ctx, onComment, onChompKeep)
|
|
1875
1875
|
: JSON.stringify(this);
|
|
1876
1876
|
}
|
|
1877
|
-
}
|
|
1877
|
+
};
|
|
1878
1878
|
|
|
1879
1879
|
Pair$9.Pair = Pair$8;
|
|
1880
1880
|
Pair$9.createPair = createPair;
|
|
@@ -2058,7 +2058,7 @@ function findPair(items, key) {
|
|
|
2058
2058
|
}
|
|
2059
2059
|
return undefined;
|
|
2060
2060
|
}
|
|
2061
|
-
|
|
2061
|
+
let YAMLMap$6 = class YAMLMap extends Collection$2.Collection {
|
|
2062
2062
|
constructor(schema) {
|
|
2063
2063
|
super(Node$f.MAP, schema);
|
|
2064
2064
|
this.items = [];
|
|
@@ -2152,7 +2152,7 @@ class YAMLMap$6 extends Collection$2.Collection {
|
|
|
2152
2152
|
onComment
|
|
2153
2153
|
});
|
|
2154
2154
|
}
|
|
2155
|
-
}
|
|
2155
|
+
};
|
|
2156
2156
|
|
|
2157
2157
|
YAMLMap$7.YAMLMap = YAMLMap$6;
|
|
2158
2158
|
YAMLMap$7.findPair = findPair;
|
|
@@ -2210,7 +2210,7 @@ var Node$d = Node$t;
|
|
|
2210
2210
|
var Scalar$d = Scalar$k;
|
|
2211
2211
|
var toJS$2 = toJS$6;
|
|
2212
2212
|
|
|
2213
|
-
|
|
2213
|
+
let YAMLSeq$6 = class YAMLSeq extends Collection$1.Collection {
|
|
2214
2214
|
constructor(schema) {
|
|
2215
2215
|
super(Node$d.SEQ, schema);
|
|
2216
2216
|
this.items = [];
|
|
@@ -2290,7 +2290,7 @@ class YAMLSeq$6 extends Collection$1.Collection {
|
|
|
2290
2290
|
onComment
|
|
2291
2291
|
});
|
|
2292
2292
|
}
|
|
2293
|
-
}
|
|
2293
|
+
};
|
|
2294
2294
|
function asItemIndex(key) {
|
|
2295
2295
|
let idx = Node$d.isScalar(key) ? key.value : key;
|
|
2296
2296
|
if (idx && typeof idx === 'string')
|
|
@@ -3323,7 +3323,7 @@ var string = string$5;
|
|
|
3323
3323
|
var tags = tags$1;
|
|
3324
3324
|
|
|
3325
3325
|
const sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
3326
|
-
|
|
3326
|
+
let Schema$2 = class Schema {
|
|
3327
3327
|
constructor({ compat, customTags, merge, resolveKnownTags, schema, sortMapEntries, toStringDefaults }) {
|
|
3328
3328
|
this.compat = Array.isArray(compat)
|
|
3329
3329
|
? tags.getTags(compat, 'compat')
|
|
@@ -3351,7 +3351,7 @@ class Schema$2 {
|
|
|
3351
3351
|
copy.tags = this.tags.slice();
|
|
3352
3352
|
return copy;
|
|
3353
3353
|
}
|
|
3354
|
-
}
|
|
3354
|
+
};
|
|
3355
3355
|
|
|
3356
3356
|
Schema$3.Schema = Schema$2;
|
|
3357
3357
|
|
|
@@ -3513,7 +3513,7 @@ var applyReviver = applyReviver$2;
|
|
|
3513
3513
|
var createNode = createNode$5;
|
|
3514
3514
|
var directives$1 = directives$2;
|
|
3515
3515
|
|
|
3516
|
-
|
|
3516
|
+
let Document$4 = class Document {
|
|
3517
3517
|
constructor(value, replacer, options) {
|
|
3518
3518
|
/** A comment before this Document */
|
|
3519
3519
|
this.commentBefore = null;
|
|
@@ -3824,7 +3824,7 @@ class Document$4 {
|
|
|
3824
3824
|
}
|
|
3825
3825
|
return stringifyDocument.stringifyDocument(this, options);
|
|
3826
3826
|
}
|
|
3827
|
-
}
|
|
3827
|
+
};
|
|
3828
3828
|
function assertCollection(contents) {
|
|
3829
3829
|
if (Node$6.isCollection(contents))
|
|
3830
3830
|
return true;
|
|
@@ -3835,7 +3835,7 @@ Document$5.Document = Document$4;
|
|
|
3835
3835
|
|
|
3836
3836
|
var errors$4 = {};
|
|
3837
3837
|
|
|
3838
|
-
|
|
3838
|
+
let YAMLError$1 = class YAMLError extends Error {
|
|
3839
3839
|
constructor(name, pos, code, message) {
|
|
3840
3840
|
super();
|
|
3841
3841
|
this.name = name;
|
|
@@ -3843,17 +3843,17 @@ class YAMLError$1 extends Error {
|
|
|
3843
3843
|
this.message = message;
|
|
3844
3844
|
this.pos = pos;
|
|
3845
3845
|
}
|
|
3846
|
-
}
|
|
3847
|
-
|
|
3846
|
+
};
|
|
3847
|
+
let YAMLParseError$1 = class YAMLParseError extends YAMLError$1 {
|
|
3848
3848
|
constructor(pos, code, message) {
|
|
3849
3849
|
super('YAMLParseError', pos, code, message);
|
|
3850
3850
|
}
|
|
3851
|
-
}
|
|
3852
|
-
|
|
3851
|
+
};
|
|
3852
|
+
let YAMLWarning$1 = class YAMLWarning extends YAMLError$1 {
|
|
3853
3853
|
constructor(pos, code, message) {
|
|
3854
3854
|
super('YAMLWarning', pos, code, message);
|
|
3855
3855
|
}
|
|
3856
|
-
}
|
|
3856
|
+
};
|
|
3857
3857
|
const prettifyError = (src, lc) => (error) => {
|
|
3858
3858
|
if (error.pos[0] === -1)
|
|
3859
3859
|
return;
|
|
@@ -5298,7 +5298,7 @@ function parsePrelude(prelude) {
|
|
|
5298
5298
|
* const docs = new Composer().compose(tokens)
|
|
5299
5299
|
* ```
|
|
5300
5300
|
*/
|
|
5301
|
-
|
|
5301
|
+
let Composer$1 = class Composer {
|
|
5302
5302
|
constructor(options = {}) {
|
|
5303
5303
|
this.doc = null;
|
|
5304
5304
|
this.atDirectives = false;
|
|
@@ -5460,7 +5460,7 @@ class Composer$1 {
|
|
|
5460
5460
|
yield doc;
|
|
5461
5461
|
}
|
|
5462
5462
|
}
|
|
5463
|
-
}
|
|
5463
|
+
};
|
|
5464
5464
|
|
|
5465
5465
|
composer$2.Composer = Composer$1;
|
|
5466
5466
|
|
|
@@ -6063,7 +6063,7 @@ const isNotAnchorChar = (ch) => !ch || invalidAnchorChars.includes(ch);
|
|
|
6063
6063
|
* - `\x1f` (Unit Separator): Next token is a scalar value
|
|
6064
6064
|
* - `\u{FEFF}` (Byte order mark): Emitted separately outside documents
|
|
6065
6065
|
*/
|
|
6066
|
-
|
|
6066
|
+
let Lexer$1 = class Lexer {
|
|
6067
6067
|
constructor() {
|
|
6068
6068
|
/**
|
|
6069
6069
|
* Flag indicating whether the end of the current buffer marks the end of
|
|
@@ -6660,7 +6660,7 @@ class Lexer$1 {
|
|
|
6660
6660
|
ch = this.buffer[++i];
|
|
6661
6661
|
return yield* this.pushToIndex(i, false);
|
|
6662
6662
|
}
|
|
6663
|
-
}
|
|
6663
|
+
};
|
|
6664
6664
|
|
|
6665
6665
|
lexer$2.Lexer = Lexer$1;
|
|
6666
6666
|
|
|
@@ -6671,7 +6671,7 @@ var lineCounter$2 = {};
|
|
|
6671
6671
|
* determining the one-indexed `{ line, col }` position for any offset
|
|
6672
6672
|
* within the input.
|
|
6673
6673
|
*/
|
|
6674
|
-
|
|
6674
|
+
let LineCounter$1 = class LineCounter {
|
|
6675
6675
|
constructor() {
|
|
6676
6676
|
this.lineStarts = [];
|
|
6677
6677
|
/**
|
|
@@ -6702,7 +6702,7 @@ class LineCounter$1 {
|
|
|
6702
6702
|
return { line: low, col: offset - start + 1 };
|
|
6703
6703
|
};
|
|
6704
6704
|
}
|
|
6705
|
-
}
|
|
6705
|
+
};
|
|
6706
6706
|
|
|
6707
6707
|
lineCounter$2.LineCounter = LineCounter$1;
|
|
6708
6708
|
|
|
@@ -6827,7 +6827,7 @@ function fixFlowSeqItems(fc) {
|
|
|
6827
6827
|
* }
|
|
6828
6828
|
* ```
|
|
6829
6829
|
*/
|
|
6830
|
-
|
|
6830
|
+
let Parser$1 = class Parser {
|
|
6831
6831
|
/**
|
|
6832
6832
|
* @param onNewLine - If defined, called separately with the start position of
|
|
6833
6833
|
* each new line (in `parse()`, including the start of input).
|
|
@@ -7657,7 +7657,7 @@ class Parser$1 {
|
|
|
7657
7657
|
yield* this.pop();
|
|
7658
7658
|
}
|
|
7659
7659
|
}
|
|
7660
|
-
}
|
|
7660
|
+
};
|
|
7661
7661
|
|
|
7662
7662
|
parser$2.Parser = Parser$1;
|
|
7663
7663
|
|
|
@@ -7817,7 +7817,6 @@ var visitAsync = dist.visitAsync = visit.visitAsync;
|
|
|
7817
7817
|
|
|
7818
7818
|
var index = /*#__PURE__*/_mergeNamespaces({
|
|
7819
7819
|
__proto__: null,
|
|
7820
|
-
'default': dist,
|
|
7821
7820
|
Composer: Composer,
|
|
7822
7821
|
Document: Document_1,
|
|
7823
7822
|
Schema: Schema_1,
|
|
@@ -7846,7 +7845,8 @@ var index = /*#__PURE__*/_mergeNamespaces({
|
|
|
7846
7845
|
parseDocument: parseDocument,
|
|
7847
7846
|
stringify: stringify,
|
|
7848
7847
|
visit: visit_1,
|
|
7849
|
-
visitAsync: visitAsync
|
|
7848
|
+
visitAsync: visitAsync,
|
|
7849
|
+
'default': dist
|
|
7850
7850
|
}, [dist]);
|
|
7851
7851
|
|
|
7852
7852
|
export { index as i };
|
package/build/esm/package.mjs
CHANGED
|
@@ -1,45 +1,36 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
|
-
import { execSync } from 'node:child_process';
|
|
4
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';
|
|
5
|
-
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 './package-manager.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
|
-
import 'node:url';
|
|
8
6
|
import 'node:readline';
|
|
9
7
|
import 'node:events';
|
|
8
|
+
import 'node:child_process';
|
|
9
|
+
import 'node:url';
|
|
10
10
|
|
|
11
|
-
let _ = t => t,
|
|
12
|
-
_t,
|
|
13
|
-
_t2,
|
|
14
|
-
_t3,
|
|
15
|
-
_t4;
|
|
16
11
|
async function createProject() {
|
|
17
12
|
const args = getArguments();
|
|
18
|
-
|
|
19
13
|
if (args['--help']) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const additionalOptions = stripIndent(_t || (_t = _`
|
|
23
|
-
${0}, ${0}
|
|
14
|
+
const additionalOptions = stripIndent`
|
|
15
|
+
${cyan_1(`--react`)}, ${cyan_1(`--no-react`)}
|
|
24
16
|
Whether this package will use React. If you don’t provide this option, the command
|
|
25
17
|
will ask you about it later.
|
|
26
18
|
|
|
27
|
-
${
|
|
19
|
+
${cyan_1(`--public`)}, ${cyan_1(`--private`)}
|
|
28
20
|
Whether this package will be published for other projects to install. If you do not
|
|
29
21
|
provide this option, the command will ask you about it later.
|
|
30
22
|
|
|
31
|
-
${
|
|
23
|
+
${cyan_1(`--registry`)}
|
|
32
24
|
The package registry to publish this package to. This option only applies if you create
|
|
33
25
|
a public package. If you do not provide this option, it will use the default NPM registry.
|
|
34
|
-
|
|
26
|
+
`;
|
|
35
27
|
printHelp({
|
|
36
28
|
kind: 'package',
|
|
37
29
|
options: additionalOptions,
|
|
38
|
-
packageManager:
|
|
30
|
+
packageManager: args['--package-manager']?.toLowerCase()
|
|
39
31
|
});
|
|
40
32
|
return;
|
|
41
33
|
}
|
|
42
|
-
|
|
43
34
|
const inWorkspace = fs.existsSync('quilt.workspace.ts');
|
|
44
35
|
const name = await getName(args);
|
|
45
36
|
const directory = await getDirectory(args, {
|
|
@@ -50,16 +41,16 @@ async function createProject() {
|
|
|
50
41
|
const useReact = await getReact(args);
|
|
51
42
|
const createAsMonorepo = !inWorkspace && (await getCreateAsMonorepo(args));
|
|
52
43
|
const shouldInstall = await getShouldInstall(args);
|
|
53
|
-
const packageManager = await getPackageManager(args
|
|
44
|
+
const packageManager = await getPackageManager(args, {
|
|
45
|
+
root: directory
|
|
46
|
+
});
|
|
54
47
|
const setupExtras = await getExtrasToSetup(args, {
|
|
55
48
|
inWorkspace
|
|
56
49
|
});
|
|
57
50
|
const partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
58
51
|
const packageDirectory = createAsMonorepo ? path.join(directory, `packages/${toValidPackageName(name.split('/').pop())}`) : directory;
|
|
59
|
-
|
|
60
52
|
if (fs.existsSync(directory)) {
|
|
61
53
|
await emptyDirectory(directory);
|
|
62
|
-
|
|
63
54
|
if (packageDirectory !== directory) {
|
|
64
55
|
fs.mkdirSync(packageDirectory, {
|
|
65
56
|
recursive: true
|
|
@@ -70,28 +61,29 @@ async function createProject() {
|
|
|
70
61
|
recursive: true
|
|
71
62
|
});
|
|
72
63
|
}
|
|
73
|
-
|
|
74
64
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
75
65
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
76
66
|
const packageTemplate = loadTemplate('package');
|
|
77
67
|
const workspaceTemplate = loadTemplate('workspace');
|
|
78
|
-
let quiltProject = await packageTemplate.read('quilt.project.ts');
|
|
79
|
-
// are needed if we are making a monorepo or not.
|
|
68
|
+
let quiltProject = await packageTemplate.read('quilt.project.ts');
|
|
80
69
|
|
|
70
|
+
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
71
|
+
// are needed if we are making a monorepo or not.
|
|
81
72
|
if (!inWorkspace) {
|
|
82
73
|
await workspaceTemplate.copy(directory, file => {
|
|
83
74
|
// When this is a single project, we use the project’s Quilt configuration as the base.
|
|
84
|
-
if (file === 'quilt.workspace.ts') return createAsMonorepo;
|
|
75
|
+
if (file === 'quilt.workspace.ts') return createAsMonorepo;
|
|
85
76
|
|
|
77
|
+
// We need to make some adjustments to the root package.json
|
|
86
78
|
return file !== 'package.json';
|
|
87
|
-
});
|
|
88
|
-
// package manager workspace configuration.
|
|
79
|
+
});
|
|
89
80
|
|
|
81
|
+
// If we are creating a monorepo, we need to add the root package.json and
|
|
82
|
+
// package manager workspace configuration.
|
|
90
83
|
if (createAsMonorepo) {
|
|
91
84
|
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
92
85
|
workspacePackageJson.name = toValidPackageName(name);
|
|
93
|
-
|
|
94
|
-
if (packageManager === 'pnpm') {
|
|
86
|
+
if (packageManager.type === 'pnpm') {
|
|
95
87
|
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
96
88
|
packages:
|
|
97
89
|
- './packages/*'
|
|
@@ -101,7 +93,6 @@ async function createProject() {
|
|
|
101
93
|
} else {
|
|
102
94
|
workspacePackageJson.workspaces = ['packages/*'];
|
|
103
95
|
}
|
|
104
|
-
|
|
105
96
|
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
106
97
|
as: 'json-stringify'
|
|
107
98
|
}));
|
|
@@ -109,21 +100,20 @@ async function createProject() {
|
|
|
109
100
|
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([packageTemplate.read('package.json').then(content => JSON.parse(content)), packageTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
110
101
|
workspacePackageJson.eslintConfig = projectPackageJson.eslintConfig;
|
|
111
102
|
workspacePackageJson.browserslist = projectPackageJson.browserslist;
|
|
112
|
-
const newPackageJson = {};
|
|
113
|
-
// the preferred ordering (dependencies, peer dependencies, dev dependencies).
|
|
103
|
+
const newPackageJson = {};
|
|
114
104
|
|
|
105
|
+
// We want to put the project’s dependencies in the package.json, respecting
|
|
106
|
+
// the preferred ordering (dependencies, peer dependencies, dev dependencies).
|
|
115
107
|
for (const [key, value] of Object.entries(projectPackageJson)) {
|
|
116
108
|
if (key !== 'devDependencies') {
|
|
117
109
|
newPackageJson[key] = value;
|
|
118
110
|
continue;
|
|
119
111
|
}
|
|
120
|
-
|
|
121
112
|
newPackageJson.dependencies = projectPackageJson.dependencies;
|
|
122
113
|
newPackageJson.peerDependencies = projectPackageJson.peerDependencies;
|
|
123
114
|
newPackageJson.peerDependenciesMeta = projectPackageJson.peerDependenciesMeta;
|
|
124
115
|
newPackageJson.devDependencies = mergeDependencies(workspacePackageJson.devDependencies, projectPackageJson.devDependencies);
|
|
125
116
|
}
|
|
126
|
-
|
|
127
117
|
adjustPackageJson(newPackageJson, {
|
|
128
118
|
name: toValidPackageName(name),
|
|
129
119
|
react: useReact,
|
|
@@ -141,26 +131,22 @@ async function createProject() {
|
|
|
141
131
|
as: 'json'
|
|
142
132
|
}));
|
|
143
133
|
}
|
|
144
|
-
|
|
145
134
|
if (setupExtras.has('github')) {
|
|
146
135
|
await loadTemplate('github').copy(directory);
|
|
147
136
|
}
|
|
148
|
-
|
|
149
137
|
if (setupExtras.has('vscode')) {
|
|
150
138
|
await loadTemplate('vscode').copy(directory);
|
|
151
139
|
}
|
|
152
140
|
}
|
|
153
|
-
|
|
154
141
|
await packageTemplate.copy(packageDirectory, file => {
|
|
155
142
|
// If we are in a monorepo, we can use all the template files as they are
|
|
156
143
|
if (file === 'tsconfig.json') {
|
|
157
144
|
return partOfMonorepo;
|
|
158
|
-
}
|
|
159
|
-
|
|
145
|
+
}
|
|
160
146
|
|
|
147
|
+
// We need to make some adjustments the project’s package.json and Quilt config
|
|
161
148
|
return file !== 'package.json' && file !== 'quilt.project.ts';
|
|
162
149
|
});
|
|
163
|
-
|
|
164
150
|
if (partOfMonorepo) {
|
|
165
151
|
// Write the package’s package.json (the root one was already created)
|
|
166
152
|
const projectPackageJson = JSON.parse(await packageTemplate.read('package.json'));
|
|
@@ -175,68 +161,61 @@ async function createProject() {
|
|
|
175
161
|
as: 'json-stringify'
|
|
176
162
|
}));
|
|
177
163
|
await outputRoot.write(path.join(packageDirectory, 'quilt.project.ts'), quiltProject);
|
|
178
|
-
await Promise.all([addToTsConfig(packageDirectory, outputRoot), addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager)]);
|
|
164
|
+
await Promise.all([addToTsConfig(packageDirectory, outputRoot), addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager.type)]);
|
|
179
165
|
}
|
|
180
|
-
|
|
181
166
|
if (shouldInstall) {
|
|
182
|
-
process.stdout.write('\nInstalling dependencies...\n');
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
cwd: rootDirectory
|
|
186
|
-
});
|
|
167
|
+
process.stdout.write('\nInstalling dependencies...\n');
|
|
168
|
+
// TODO: better loading, handle errors
|
|
169
|
+
await packageManager.install();
|
|
187
170
|
process.stdout.moveCursor(0, -1);
|
|
188
171
|
process.stdout.clearLine(1);
|
|
189
172
|
console.log('Installed dependencies.');
|
|
190
173
|
}
|
|
191
|
-
|
|
192
|
-
const packageJsonInstructions = stripIndent(_t2 || (_t2 = _`
|
|
174
|
+
const packageJsonInstructions = stripIndent`
|
|
193
175
|
Your new package is ready to go! However, before you go too much further,
|
|
194
|
-
you should update the following fields in ${
|
|
176
|
+
you should update the following fields in ${cyan_1(relativeDirectoryForDisplay(path.relative(process.cwd(), path.join(packageDirectory, 'package.json'))))}:
|
|
195
177
|
|
|
196
|
-
- ${
|
|
197
|
-
- ${
|
|
178
|
+
- ${bold_1(`"description"`)}, where you provide a description of what your package does
|
|
179
|
+
- ${bold_1(`"repository"`)}, where you should include the ${bold_1(`"url"`)} of your project’s repo
|
|
198
180
|
|
|
199
|
-
Before you publish your package, you will also want to update the ${
|
|
181
|
+
Before you publish your package, you will also want to update the ${bold_1(`"version"`)}
|
|
200
182
|
field in the package.json file.
|
|
201
|
-
|
|
183
|
+
`;
|
|
202
184
|
console.log();
|
|
203
185
|
console.log(packageJsonInstructions);
|
|
204
186
|
const commands = [];
|
|
205
|
-
|
|
206
187
|
if (!inWorkspace && directory !== process.cwd()) {
|
|
207
188
|
commands.push(`cd ${cyan_1(relativeDirectoryForDisplay(path.relative(process.cwd(), directory)))} ${dim_1('# Move into your new package’s directory')}`);
|
|
208
189
|
}
|
|
209
|
-
|
|
210
190
|
if (!shouldInstall) {
|
|
211
|
-
commands.push(
|
|
191
|
+
commands.push(`${packageManager.commands.install()} ${dim_1('# Install all your dependencies')}`);
|
|
212
192
|
}
|
|
213
|
-
|
|
214
193
|
if (!inWorkspace) {
|
|
215
194
|
// TODO: change this condition to check if git was initialized already
|
|
216
195
|
commands.push(`git init && git add -A && git commit -m "Initial commit" ${dim_1('# Start your git history (optional)')}`);
|
|
217
196
|
}
|
|
218
|
-
|
|
219
197
|
if (commands.length > 0) {
|
|
220
|
-
const whatsNext = stripIndent
|
|
221
|
-
After you update your package.json, there’s ${
|
|
198
|
+
const whatsNext = stripIndent`
|
|
199
|
+
After you update your package.json, there’s ${commands.length > 1 ? 'a few more steps' : 'one more step'} you’ll need to take
|
|
222
200
|
in order to start building:
|
|
223
|
-
|
|
201
|
+
`;
|
|
224
202
|
console.log();
|
|
225
203
|
console.log(whatsNext);
|
|
226
204
|
console.log();
|
|
227
205
|
console.log(commands.map(command => ` ${command}`).join('\n'));
|
|
228
206
|
}
|
|
229
|
-
|
|
230
|
-
const followUp = stripIndent(_t4 || (_t4 = _`
|
|
207
|
+
const followUp = stripIndent`
|
|
231
208
|
Quilt can help you build, test, lint, and type-check your new package. You
|
|
232
209
|
can learn more about building packages with Quilt by reading the documentation:
|
|
233
|
-
${
|
|
210
|
+
${underline_1(magenta_1('https://github.com/lemonmade/quilt/tree/main/documentation'))}
|
|
234
211
|
|
|
235
212
|
Have fun! 🎉
|
|
236
|
-
|
|
213
|
+
`;
|
|
237
214
|
console.log();
|
|
238
215
|
console.log(followUp);
|
|
239
|
-
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Argument handling
|
|
240
219
|
|
|
241
220
|
function getArguments() {
|
|
242
221
|
const args = parseArguments({
|
|
@@ -263,12 +242,10 @@ function getArguments() {
|
|
|
263
242
|
});
|
|
264
243
|
return args;
|
|
265
244
|
}
|
|
266
|
-
|
|
267
245
|
async function getName(args) {
|
|
268
246
|
let {
|
|
269
247
|
'--name': name
|
|
270
248
|
} = args;
|
|
271
|
-
|
|
272
249
|
if (name == null) {
|
|
273
250
|
name = await prompt({
|
|
274
251
|
type: 'text',
|
|
@@ -276,16 +253,13 @@ async function getName(args) {
|
|
|
276
253
|
initial: '@my-team/package'
|
|
277
254
|
});
|
|
278
255
|
}
|
|
279
|
-
|
|
280
256
|
return name;
|
|
281
257
|
}
|
|
282
|
-
|
|
283
258
|
async function getDirectory(args, {
|
|
284
259
|
name,
|
|
285
260
|
inWorkspace
|
|
286
261
|
}) {
|
|
287
262
|
let directory = args['--directory'] ? path.resolve(args['--directory']) : undefined;
|
|
288
|
-
|
|
289
263
|
if (directory == null) {
|
|
290
264
|
const basePackageName = toValidPackageName(name.split('/').pop());
|
|
291
265
|
const defaultDirectory = inWorkspace ? `packages/${basePackageName}` : basePackageName;
|
|
@@ -295,7 +269,6 @@ async function getDirectory(args, {
|
|
|
295
269
|
initial: defaultDirectory
|
|
296
270
|
}));
|
|
297
271
|
}
|
|
298
|
-
|
|
299
272
|
while (!args['--yes']) {
|
|
300
273
|
if (fs.existsSync(directory) && !(await isEmpty(directory))) {
|
|
301
274
|
const relativeDirectory = path.relative(process.cwd(), directory);
|
|
@@ -314,13 +287,10 @@ async function getDirectory(args, {
|
|
|
314
287
|
break;
|
|
315
288
|
}
|
|
316
289
|
}
|
|
317
|
-
|
|
318
290
|
return directory;
|
|
319
291
|
}
|
|
320
|
-
|
|
321
292
|
async function getPublic(args) {
|
|
322
293
|
let isPublic;
|
|
323
|
-
|
|
324
294
|
if (args['--public'] || args['--yes']) {
|
|
325
295
|
isPublic = true;
|
|
326
296
|
} else if (args['--private']) {
|
|
@@ -332,13 +302,10 @@ async function getPublic(args) {
|
|
|
332
302
|
initial: true
|
|
333
303
|
});
|
|
334
304
|
}
|
|
335
|
-
|
|
336
305
|
return isPublic;
|
|
337
306
|
}
|
|
338
|
-
|
|
339
307
|
async function getReact(args) {
|
|
340
308
|
let useReact;
|
|
341
|
-
|
|
342
309
|
if (args['--react'] || args['--yes']) {
|
|
343
310
|
useReact = true;
|
|
344
311
|
} else if (args['--no-react']) {
|
|
@@ -350,10 +317,8 @@ async function getReact(args) {
|
|
|
350
317
|
initial: true
|
|
351
318
|
});
|
|
352
319
|
}
|
|
353
|
-
|
|
354
320
|
return useReact;
|
|
355
321
|
}
|
|
356
|
-
|
|
357
322
|
function adjustPackageJson(packageJson, {
|
|
358
323
|
name,
|
|
359
324
|
react,
|
|
@@ -363,20 +328,17 @@ function adjustPackageJson(packageJson, {
|
|
|
363
328
|
packageJson.name = name;
|
|
364
329
|
const packageParts = name.split('/');
|
|
365
330
|
const scope = packageParts[0].startsWith('@') ? packageParts[0] : undefined;
|
|
366
|
-
const finalRegistry = registry
|
|
367
|
-
|
|
331
|
+
const finalRegistry = registry ?? 'https://registry.npmjs.org';
|
|
368
332
|
if (scope) {
|
|
369
333
|
packageJson.publishConfig[`${scope}/registry`] = finalRegistry;
|
|
370
334
|
} else if (registry) {
|
|
371
335
|
packageJson.publishConfig.registry = finalRegistry;
|
|
372
336
|
}
|
|
373
|
-
|
|
374
337
|
if (isPublic) {
|
|
375
338
|
delete packageJson.private;
|
|
376
339
|
} else {
|
|
377
340
|
delete packageJson.publishConfig;
|
|
378
341
|
}
|
|
379
|
-
|
|
380
342
|
if (!react) {
|
|
381
343
|
delete packageJson.dependencies['@types/react'];
|
|
382
344
|
delete packageJson.devDependencies['react'];
|
|
@@ -384,7 +346,6 @@ function adjustPackageJson(packageJson, {
|
|
|
384
346
|
delete packageJson.peerDependenciesMeta['react'];
|
|
385
347
|
packageJson.eslintConfig.extends = packageJson.eslintConfig.extends.filter(extend => !extend.includes('react'));
|
|
386
348
|
}
|
|
387
|
-
|
|
388
349
|
return packageJson;
|
|
389
350
|
}
|
|
390
351
|
|