@quilted/create 0.1.20 → 0.1.21
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 +6 -0
- package/bin/create-quilt.mjs +2 -0
- package/build/cjs/_commonjsHelpers.cjs +10 -0
- package/build/cjs/app.cjs +590 -0
- package/build/cjs/index.cjs +7571 -0
- package/build/cjs/index2.cjs +374 -0
- package/build/cjs/index3.cjs +7226 -0
- package/build/cjs/minimatch.cjs +1202 -0
- package/build/cjs/package-manager.cjs +907 -0
- package/build/cjs/package.cjs +807 -0
- package/build/cjs/parser-babel.cjs +59 -0
- package/build/cjs/parser-yaml.cjs +182 -0
- package/build/cjs/standalone.cjs +147 -0
- package/build/esm/_commonjsHelpers.mjs +7 -0
- package/build/esm/app.mjs +567 -0
- package/build/esm/index.mjs +7526 -0
- package/build/esm/index2.mjs +365 -0
- package/build/esm/index3.mjs +7195 -0
- package/build/esm/minimatch.mjs +1200 -0
- package/build/esm/package-manager.mjs +876 -0
- package/build/esm/package.mjs +784 -0
- package/build/esm/parser-babel.mjs +57 -0
- package/build/esm/parser-yaml.mjs +180 -0
- package/build/esm/standalone.mjs +145 -0
- package/package.json +1 -1
|
@@ -0,0 +1,784 @@
|
|
|
1
|
+
import { _ as _asyncToGenerator, r as regenerator, s as stripIndent, a as _taggedTemplateLiteral, c as cyan_1, h as bold_1, d as dim_1, u as underline_1, m as magenta_1, g as getExtrasToSetup, b as getPackageManager, e as getShouldInstall, f as getCreateAsMonorepo, p as printHelp, i as arg_1, j as prompt, k as _defineProperty } from './index.mjs';
|
|
2
|
+
import { r as relativeDirectoryForDisplay, a as addToTsConfig, b as addToPackageManagerWorkspaces, t as toValidPackageName, f as format, l as loadTemplate, _ as _slicedToArray, c as createOutputTarget, e as emptyDirectory, i as isEmpty } from './package-manager.mjs';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import { execSync } from 'child_process';
|
|
6
|
+
import 'tty';
|
|
7
|
+
import 'url';
|
|
8
|
+
import 'readline';
|
|
9
|
+
import 'events';
|
|
10
|
+
|
|
11
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
12
|
+
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
|
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
+
|
|
17
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
18
|
+
|
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
+
|
|
21
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
22
|
+
function createProject() {
|
|
23
|
+
return _createProject.apply(this, arguments);
|
|
24
|
+
} // Argument handling
|
|
25
|
+
|
|
26
|
+
function _createProject() {
|
|
27
|
+
_createProject = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
28
|
+
var argv, _argv$PackageManag, additionalOptions, inWorkspace, name, directory, isPublic, useReact, createAsMonorepo, shouldInstall, packageManager, setupExtras, partOfMonorepo, packageDirectory, rootDirectory, outputRoot, packageTemplate, workspaceTemplate, quiltProject, workspacePackageJson, _yield$Promise$all, _yield$Promise$all2, projectPackageJson, projectTSConfig, _workspacePackageJson, newPackageJson, _i, _Object$entries, _Object$entries$_i, key, value, _projectPackageJson, packageJsonInstructions, commands, whatsNext, followUp;
|
|
29
|
+
|
|
30
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
31
|
+
while (1) {
|
|
32
|
+
switch (_context.prev = _context.next) {
|
|
33
|
+
case 0:
|
|
34
|
+
argv = getArgv();
|
|
35
|
+
|
|
36
|
+
if (!argv['--help']) {
|
|
37
|
+
_context.next = 5;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
additionalOptions = stripIndent(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ", ", "\n Whether this package will use React. If you don\u2019t provide this option, the command\n will ask you about it later.\n\n ", ", ", "\n Whether this package will be published for other projects to install. If you do not\n provide this option, the command will ask you about it later.\n\n ", "\n The package registry to publish this package to. This option only applies if you create\n a public package. If you do not provide this option, it will use the default NPM registry.\n "])), cyan_1("--react"), cyan_1("--no-react"), cyan_1("--public"), cyan_1("--private"), cyan_1("--registry"));
|
|
42
|
+
printHelp({
|
|
43
|
+
kind: 'package',
|
|
44
|
+
options: additionalOptions,
|
|
45
|
+
packageManager: (_argv$PackageManag = argv['--package-manager']) === null || _argv$PackageManag === void 0 ? void 0 : _argv$PackageManag.toLowerCase()
|
|
46
|
+
});
|
|
47
|
+
return _context.abrupt("return");
|
|
48
|
+
|
|
49
|
+
case 5:
|
|
50
|
+
inWorkspace = fs.existsSync('quilt.workspace.ts');
|
|
51
|
+
_context.next = 8;
|
|
52
|
+
return getName(argv);
|
|
53
|
+
|
|
54
|
+
case 8:
|
|
55
|
+
name = _context.sent;
|
|
56
|
+
_context.next = 11;
|
|
57
|
+
return getDirectory(argv, {
|
|
58
|
+
name: name,
|
|
59
|
+
inWorkspace: inWorkspace
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
case 11:
|
|
63
|
+
directory = _context.sent;
|
|
64
|
+
_context.next = 14;
|
|
65
|
+
return getPublic(argv);
|
|
66
|
+
|
|
67
|
+
case 14:
|
|
68
|
+
isPublic = _context.sent;
|
|
69
|
+
_context.next = 17;
|
|
70
|
+
return getReact(argv);
|
|
71
|
+
|
|
72
|
+
case 17:
|
|
73
|
+
useReact = _context.sent;
|
|
74
|
+
_context.t0 = !inWorkspace;
|
|
75
|
+
|
|
76
|
+
if (!_context.t0) {
|
|
77
|
+
_context.next = 23;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
_context.next = 22;
|
|
82
|
+
return getCreateAsMonorepo(argv);
|
|
83
|
+
|
|
84
|
+
case 22:
|
|
85
|
+
_context.t0 = _context.sent;
|
|
86
|
+
|
|
87
|
+
case 23:
|
|
88
|
+
createAsMonorepo = _context.t0;
|
|
89
|
+
_context.next = 26;
|
|
90
|
+
return getShouldInstall(argv);
|
|
91
|
+
|
|
92
|
+
case 26:
|
|
93
|
+
shouldInstall = _context.sent;
|
|
94
|
+
_context.next = 29;
|
|
95
|
+
return getPackageManager(argv);
|
|
96
|
+
|
|
97
|
+
case 29:
|
|
98
|
+
packageManager = _context.sent;
|
|
99
|
+
_context.next = 32;
|
|
100
|
+
return getExtrasToSetup(argv, {
|
|
101
|
+
inWorkspace: inWorkspace
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
case 32:
|
|
105
|
+
setupExtras = _context.sent;
|
|
106
|
+
partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
107
|
+
packageDirectory = createAsMonorepo ? path.join(directory, "packages/".concat(toValidPackageName(name.split('/').pop()))) : directory;
|
|
108
|
+
|
|
109
|
+
if (!fs.existsSync(directory)) {
|
|
110
|
+
_context.next = 41;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_context.next = 38;
|
|
115
|
+
return emptyDirectory(directory);
|
|
116
|
+
|
|
117
|
+
case 38:
|
|
118
|
+
if (packageDirectory !== directory) {
|
|
119
|
+
fs.mkdirSync(packageDirectory, {
|
|
120
|
+
recursive: true
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
_context.next = 42;
|
|
125
|
+
break;
|
|
126
|
+
|
|
127
|
+
case 41:
|
|
128
|
+
fs.mkdirSync(packageDirectory, {
|
|
129
|
+
recursive: true
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
case 42:
|
|
133
|
+
rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
134
|
+
outputRoot = createOutputTarget(rootDirectory);
|
|
135
|
+
packageTemplate = loadTemplate('package');
|
|
136
|
+
workspaceTemplate = loadTemplate('workspace');
|
|
137
|
+
_context.next = 48;
|
|
138
|
+
return packageTemplate.read('quilt.project.ts');
|
|
139
|
+
|
|
140
|
+
case 48:
|
|
141
|
+
quiltProject = _context.sent;
|
|
142
|
+
|
|
143
|
+
if (useReact) {
|
|
144
|
+
quiltProject = quiltProject.replace('react: false', 'react: true');
|
|
145
|
+
} // If we aren’t already in a workspace, copy the workspace files over, which
|
|
146
|
+
// are needed if we are making a monorepo or not.
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
if (inWorkspace) {
|
|
150
|
+
_context.next = 127;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
_context.next = 53;
|
|
155
|
+
return workspaceTemplate.copy(directory, function (file) {
|
|
156
|
+
// When this is a single project, we use the project’s Quilt configuration as the base.
|
|
157
|
+
if (file === 'quilt.workspace.ts') return createAsMonorepo; // We need to make some adjustments to the root package.json
|
|
158
|
+
|
|
159
|
+
return file !== 'package.json';
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
case 53:
|
|
163
|
+
if (!createAsMonorepo) {
|
|
164
|
+
_context.next = 78;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_context.t1 = JSON;
|
|
169
|
+
_context.next = 57;
|
|
170
|
+
return workspaceTemplate.read('package.json');
|
|
171
|
+
|
|
172
|
+
case 57:
|
|
173
|
+
_context.t2 = _context.sent;
|
|
174
|
+
workspacePackageJson = _context.t1.parse.call(_context.t1, _context.t2);
|
|
175
|
+
workspacePackageJson.name = toValidPackageName(name);
|
|
176
|
+
|
|
177
|
+
if (!(packageManager === 'pnpm')) {
|
|
178
|
+
_context.next = 69;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
_context.t3 = outputRoot;
|
|
183
|
+
_context.next = 64;
|
|
184
|
+
return format("\n packages:\n - './packages/*'\n ", {
|
|
185
|
+
as: 'yaml'
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
case 64:
|
|
189
|
+
_context.t4 = _context.sent;
|
|
190
|
+
_context.next = 67;
|
|
191
|
+
return _context.t3.write.call(_context.t3, 'pnpm-workspace.yaml', _context.t4);
|
|
192
|
+
|
|
193
|
+
case 67:
|
|
194
|
+
_context.next = 70;
|
|
195
|
+
break;
|
|
196
|
+
|
|
197
|
+
case 69:
|
|
198
|
+
workspacePackageJson.workspaces = ['packages/*'];
|
|
199
|
+
|
|
200
|
+
case 70:
|
|
201
|
+
_context.t5 = outputRoot;
|
|
202
|
+
_context.next = 73;
|
|
203
|
+
return format(JSON.stringify(workspacePackageJson), {
|
|
204
|
+
as: 'json-stringify'
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
case 73:
|
|
208
|
+
_context.t6 = _context.sent;
|
|
209
|
+
_context.next = 76;
|
|
210
|
+
return _context.t5.write.call(_context.t5, 'package.json', _context.t6);
|
|
211
|
+
|
|
212
|
+
case 76:
|
|
213
|
+
_context.next = 121;
|
|
214
|
+
break;
|
|
215
|
+
|
|
216
|
+
case 78:
|
|
217
|
+
_context.next = 80;
|
|
218
|
+
return Promise.all([packageTemplate.read('package.json').then(function (content) {
|
|
219
|
+
return JSON.parse(content);
|
|
220
|
+
}), packageTemplate.read('tsconfig.json').then(function (content) {
|
|
221
|
+
return JSON.parse(content);
|
|
222
|
+
}), workspaceTemplate.read('package.json').then(function (content) {
|
|
223
|
+
return JSON.parse(content);
|
|
224
|
+
})]);
|
|
225
|
+
|
|
226
|
+
case 80:
|
|
227
|
+
_yield$Promise$all = _context.sent;
|
|
228
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
|
|
229
|
+
projectPackageJson = _yield$Promise$all2[0];
|
|
230
|
+
projectTSConfig = _yield$Promise$all2[1];
|
|
231
|
+
_workspacePackageJson = _yield$Promise$all2[2];
|
|
232
|
+
_workspacePackageJson.eslintConfig = projectPackageJson.eslintConfig;
|
|
233
|
+
_workspacePackageJson.browserslist = projectPackageJson.browserslist;
|
|
234
|
+
newPackageJson = {}; // We want to put the project’s dependencies in the package.json, respecting
|
|
235
|
+
// the preferred ordering (dependencies, peer dependencies, dev dependencies).
|
|
236
|
+
|
|
237
|
+
_i = 0, _Object$entries = Object.entries(projectPackageJson);
|
|
238
|
+
|
|
239
|
+
case 89:
|
|
240
|
+
if (!(_i < _Object$entries.length)) {
|
|
241
|
+
_context.next = 101;
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
_Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), key = _Object$entries$_i[0], value = _Object$entries$_i[1];
|
|
246
|
+
|
|
247
|
+
if (!(key !== 'devDependencies')) {
|
|
248
|
+
_context.next = 94;
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
newPackageJson[key] = value;
|
|
253
|
+
return _context.abrupt("continue", 98);
|
|
254
|
+
|
|
255
|
+
case 94:
|
|
256
|
+
newPackageJson.dependencies = projectPackageJson.dependencies;
|
|
257
|
+
newPackageJson.peerDependencies = projectPackageJson.peerDependencies;
|
|
258
|
+
newPackageJson.peerDependenciesMeta = projectPackageJson.peerDependenciesMeta;
|
|
259
|
+
newPackageJson.devDependencies = sortKeys(_objectSpread(_objectSpread({}, _workspacePackageJson.devDependencies), projectPackageJson.devDependencies));
|
|
260
|
+
|
|
261
|
+
case 98:
|
|
262
|
+
_i++;
|
|
263
|
+
_context.next = 89;
|
|
264
|
+
break;
|
|
265
|
+
|
|
266
|
+
case 101:
|
|
267
|
+
adjustPackageJson(newPackageJson, {
|
|
268
|
+
name: toValidPackageName(name),
|
|
269
|
+
react: useReact,
|
|
270
|
+
isPublic: isPublic,
|
|
271
|
+
registry: argv['--registry']
|
|
272
|
+
});
|
|
273
|
+
quiltProject = quiltProject.replace('quiltPackage', 'quiltWorkspace, quiltPackage').replace('quiltPackage(', 'quiltWorkspace(), quiltPackage(');
|
|
274
|
+
_context.t7 = outputRoot;
|
|
275
|
+
_context.next = 106;
|
|
276
|
+
return format(quiltProject, {
|
|
277
|
+
as: 'typescript'
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
case 106:
|
|
281
|
+
_context.t8 = _context.sent;
|
|
282
|
+
_context.next = 109;
|
|
283
|
+
return _context.t7.write.call(_context.t7, 'quilt.project.ts', _context.t8);
|
|
284
|
+
|
|
285
|
+
case 109:
|
|
286
|
+
_context.t9 = outputRoot;
|
|
287
|
+
_context.next = 112;
|
|
288
|
+
return format(JSON.stringify(newPackageJson), {
|
|
289
|
+
as: 'json-stringify'
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
case 112:
|
|
293
|
+
_context.t10 = _context.sent;
|
|
294
|
+
_context.next = 115;
|
|
295
|
+
return _context.t9.write.call(_context.t9, 'package.json', _context.t10);
|
|
296
|
+
|
|
297
|
+
case 115:
|
|
298
|
+
_context.t11 = outputRoot;
|
|
299
|
+
_context.next = 118;
|
|
300
|
+
return format(JSON.stringify(projectTSConfig), {
|
|
301
|
+
as: 'json'
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
case 118:
|
|
305
|
+
_context.t12 = _context.sent;
|
|
306
|
+
_context.next = 121;
|
|
307
|
+
return _context.t11.write.call(_context.t11, 'tsconfig.json', _context.t12);
|
|
308
|
+
|
|
309
|
+
case 121:
|
|
310
|
+
if (!setupExtras.has('github')) {
|
|
311
|
+
_context.next = 124;
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
_context.next = 124;
|
|
316
|
+
return loadTemplate('github').copy(directory);
|
|
317
|
+
|
|
318
|
+
case 124:
|
|
319
|
+
if (!setupExtras.has('vscode')) {
|
|
320
|
+
_context.next = 127;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
_context.next = 127;
|
|
325
|
+
return loadTemplate('vscode').copy(directory);
|
|
326
|
+
|
|
327
|
+
case 127:
|
|
328
|
+
_context.next = 129;
|
|
329
|
+
return packageTemplate.copy(packageDirectory, function (file) {
|
|
330
|
+
// If we are in a monorepo, we can use all the template files as they are
|
|
331
|
+
if (file === 'tsconfig.json') {
|
|
332
|
+
return partOfMonorepo;
|
|
333
|
+
} // We need to make some adjustments the project’s package.json and Quilt config
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
return file !== 'package.json' && file !== 'quilt.project.ts';
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
case 129:
|
|
340
|
+
if (!partOfMonorepo) {
|
|
341
|
+
_context.next = 148;
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
_context.t13 = JSON;
|
|
346
|
+
_context.next = 133;
|
|
347
|
+
return packageTemplate.read('package.json');
|
|
348
|
+
|
|
349
|
+
case 133:
|
|
350
|
+
_context.t14 = _context.sent;
|
|
351
|
+
_projectPackageJson = _context.t13.parse.call(_context.t13, _context.t14);
|
|
352
|
+
_projectPackageJson.repository.directory = path.relative(directory, packageDirectory);
|
|
353
|
+
adjustPackageJson(_projectPackageJson, {
|
|
354
|
+
name: toValidPackageName(name),
|
|
355
|
+
react: useReact,
|
|
356
|
+
isPublic: isPublic,
|
|
357
|
+
registry: argv['--registry']
|
|
358
|
+
});
|
|
359
|
+
_context.t15 = outputRoot;
|
|
360
|
+
_context.t16 = path.join(packageDirectory, 'package.json');
|
|
361
|
+
_context.next = 141;
|
|
362
|
+
return format(JSON.stringify(_projectPackageJson), {
|
|
363
|
+
as: 'json-stringify'
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
case 141:
|
|
367
|
+
_context.t17 = _context.sent;
|
|
368
|
+
_context.next = 144;
|
|
369
|
+
return _context.t15.write.call(_context.t15, _context.t16, _context.t17);
|
|
370
|
+
|
|
371
|
+
case 144:
|
|
372
|
+
_context.next = 146;
|
|
373
|
+
return outputRoot.write(path.join(packageDirectory, 'quilt.project.ts'), quiltProject);
|
|
374
|
+
|
|
375
|
+
case 146:
|
|
376
|
+
_context.next = 148;
|
|
377
|
+
return Promise.all([addToTsConfig(packageDirectory, outputRoot), addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager)]);
|
|
378
|
+
|
|
379
|
+
case 148:
|
|
380
|
+
if (shouldInstall) {
|
|
381
|
+
process.stdout.write('\nInstalling dependencies...\n'); // TODO: better loading, handle errors
|
|
382
|
+
|
|
383
|
+
execSync("".concat(packageManager, " install"), {
|
|
384
|
+
cwd: rootDirectory
|
|
385
|
+
});
|
|
386
|
+
process.stdout.moveCursor(0, -1);
|
|
387
|
+
process.stdout.clearLine(1);
|
|
388
|
+
console.log('Installed dependencies.');
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
packageJsonInstructions = stripIndent(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n Your new package is ready to go! However, before you go too much further,\n you should update the following fields in ", ":\n\n - ", ", where you provide a description of what your package does\n - ", ", where you should include the ", " of your project\u2019s repo\n\n Before you publish your package, you will also want to update the ", "\n field in the package.json file.\n "])), cyan_1(relativeDirectoryForDisplay(path.relative(process.cwd(), path.join(packageDirectory, 'package.json')))), bold_1("\"description\""), bold_1("\"repository\""), bold_1("\"url\""), bold_1("\"version\""));
|
|
392
|
+
console.log();
|
|
393
|
+
console.log(packageJsonInstructions);
|
|
394
|
+
commands = [];
|
|
395
|
+
|
|
396
|
+
if (!inWorkspace && directory !== process.cwd()) {
|
|
397
|
+
commands.push("cd ".concat(cyan_1(relativeDirectoryForDisplay(path.relative(process.cwd(), directory))), " ").concat(dim_1('# Move into your new package’s directory')));
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (!shouldInstall) {
|
|
401
|
+
commands.push("pnpm install ".concat(dim_1('# Install all your dependencies')));
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if (!inWorkspace) {
|
|
405
|
+
// TODO: change this condition to check if git was initialized already
|
|
406
|
+
commands.push("git init && git add -A && git commit -m \"Initial commit\" ".concat(dim_1('# Start your git history (optional)')));
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
if (commands.length > 0) {
|
|
410
|
+
whatsNext = stripIndent(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n After you update your package.json, there\u2019s ", " you\u2019ll need to take\n in order to start building:\n "])), commands.length > 1 ? 'a few more steps' : 'one more step');
|
|
411
|
+
console.log();
|
|
412
|
+
console.log(whatsNext);
|
|
413
|
+
console.log();
|
|
414
|
+
console.log(commands.map(function (command) {
|
|
415
|
+
return " ".concat(command);
|
|
416
|
+
}).join('\n'));
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
followUp = stripIndent(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n Quilt can help you build, test, lint, and type-check your new package. You\n can learn more about building packages with Quilt by reading the documentation:\n ", "\n\n Have fun! \uD83C\uDF89\n "])), underline_1(magenta_1('https://github.com/lemonmade/quilt/tree/main/documentation')));
|
|
420
|
+
console.log();
|
|
421
|
+
console.log(followUp);
|
|
422
|
+
|
|
423
|
+
case 160:
|
|
424
|
+
case "end":
|
|
425
|
+
return _context.stop();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}, _callee);
|
|
429
|
+
}));
|
|
430
|
+
return _createProject.apply(this, arguments);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function getArgv() {
|
|
434
|
+
var argv = arg_1({
|
|
435
|
+
'--yes': Boolean,
|
|
436
|
+
'-y': '--yes',
|
|
437
|
+
'--name': String,
|
|
438
|
+
'--directory': String,
|
|
439
|
+
'--install': Boolean,
|
|
440
|
+
'--no-install': Boolean,
|
|
441
|
+
'--monorepo': Boolean,
|
|
442
|
+
'--no-monorepo': Boolean,
|
|
443
|
+
'--package-manager': String,
|
|
444
|
+
'--extras': [String],
|
|
445
|
+
'--no-extras': Boolean,
|
|
446
|
+
'--react': Boolean,
|
|
447
|
+
'--no-react': Boolean,
|
|
448
|
+
'--public': Boolean,
|
|
449
|
+
'--private': Boolean,
|
|
450
|
+
'--registry': String,
|
|
451
|
+
'--help': Boolean,
|
|
452
|
+
'-h': '--help'
|
|
453
|
+
}, {
|
|
454
|
+
permissive: true
|
|
455
|
+
});
|
|
456
|
+
return argv;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function getName(_x) {
|
|
460
|
+
return _getName.apply(this, arguments);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function _getName() {
|
|
464
|
+
_getName = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(argv) {
|
|
465
|
+
var name;
|
|
466
|
+
return regenerator.wrap(function _callee2$(_context2) {
|
|
467
|
+
while (1) {
|
|
468
|
+
switch (_context2.prev = _context2.next) {
|
|
469
|
+
case 0:
|
|
470
|
+
name = argv['--name'];
|
|
471
|
+
|
|
472
|
+
if (!(name == null)) {
|
|
473
|
+
_context2.next = 5;
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
_context2.next = 4;
|
|
478
|
+
return prompt({
|
|
479
|
+
type: 'text',
|
|
480
|
+
message: 'What would you like to name your new package?',
|
|
481
|
+
initial: '@my-team/package'
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
case 4:
|
|
485
|
+
name = _context2.sent;
|
|
486
|
+
|
|
487
|
+
case 5:
|
|
488
|
+
return _context2.abrupt("return", name);
|
|
489
|
+
|
|
490
|
+
case 6:
|
|
491
|
+
case "end":
|
|
492
|
+
return _context2.stop();
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}, _callee2);
|
|
496
|
+
}));
|
|
497
|
+
return _getName.apply(this, arguments);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function getDirectory(_x2, _x3) {
|
|
501
|
+
return _getDirectory.apply(this, arguments);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function _getDirectory() {
|
|
505
|
+
_getDirectory = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(argv, _ref) {
|
|
506
|
+
var name, inWorkspace, directory, basePackageName, defaultDirectory, relativeDirectory, empty, promptDirectory;
|
|
507
|
+
return regenerator.wrap(function _callee3$(_context3) {
|
|
508
|
+
while (1) {
|
|
509
|
+
switch (_context3.prev = _context3.next) {
|
|
510
|
+
case 0:
|
|
511
|
+
name = _ref.name, inWorkspace = _ref.inWorkspace;
|
|
512
|
+
directory = argv['--directory'] ? path.resolve(argv['--directory']) : undefined;
|
|
513
|
+
|
|
514
|
+
if (!(directory == null)) {
|
|
515
|
+
_context3.next = 10;
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
basePackageName = toValidPackageName(name.split('/').pop());
|
|
520
|
+
defaultDirectory = inWorkspace ? "packages/".concat(basePackageName) : basePackageName;
|
|
521
|
+
_context3.t0 = path;
|
|
522
|
+
_context3.next = 8;
|
|
523
|
+
return prompt({
|
|
524
|
+
type: 'text',
|
|
525
|
+
message: 'Where would you like to create your new package?',
|
|
526
|
+
initial: defaultDirectory
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
case 8:
|
|
530
|
+
_context3.t1 = _context3.sent;
|
|
531
|
+
directory = _context3.t0.resolve.call(_context3.t0, _context3.t1);
|
|
532
|
+
|
|
533
|
+
case 10:
|
|
534
|
+
if (argv['--yes']) {
|
|
535
|
+
_context3.next = 32;
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
_context3.t2 = fs.existsSync(directory);
|
|
540
|
+
|
|
541
|
+
if (!_context3.t2) {
|
|
542
|
+
_context3.next = 16;
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
_context3.next = 15;
|
|
547
|
+
return isEmpty(directory);
|
|
548
|
+
|
|
549
|
+
case 15:
|
|
550
|
+
_context3.t2 = !_context3.sent;
|
|
551
|
+
|
|
552
|
+
case 16:
|
|
553
|
+
if (!_context3.t2) {
|
|
554
|
+
_context3.next = 29;
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
relativeDirectory = path.relative(process.cwd(), directory);
|
|
559
|
+
_context3.next = 20;
|
|
560
|
+
return prompt({
|
|
561
|
+
type: 'confirm',
|
|
562
|
+
message: "Directory ".concat(bold_1(relativeDirectoryForDisplay(relativeDirectory)), " is not empty, is it safe to empty it?"),
|
|
563
|
+
initial: true
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
case 20:
|
|
567
|
+
empty = _context3.sent;
|
|
568
|
+
|
|
569
|
+
if (!empty) {
|
|
570
|
+
_context3.next = 23;
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
return _context3.abrupt("break", 32);
|
|
575
|
+
|
|
576
|
+
case 23:
|
|
577
|
+
_context3.next = 25;
|
|
578
|
+
return prompt({
|
|
579
|
+
type: 'text',
|
|
580
|
+
message: 'What directory do you want to create your package in?'
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
case 25:
|
|
584
|
+
promptDirectory = _context3.sent;
|
|
585
|
+
directory = path.resolve(promptDirectory);
|
|
586
|
+
_context3.next = 30;
|
|
587
|
+
break;
|
|
588
|
+
|
|
589
|
+
case 29:
|
|
590
|
+
return _context3.abrupt("break", 32);
|
|
591
|
+
|
|
592
|
+
case 30:
|
|
593
|
+
_context3.next = 10;
|
|
594
|
+
break;
|
|
595
|
+
|
|
596
|
+
case 32:
|
|
597
|
+
return _context3.abrupt("return", directory);
|
|
598
|
+
|
|
599
|
+
case 33:
|
|
600
|
+
case "end":
|
|
601
|
+
return _context3.stop();
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}, _callee3);
|
|
605
|
+
}));
|
|
606
|
+
return _getDirectory.apply(this, arguments);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function getPublic(_x4) {
|
|
610
|
+
return _getPublic.apply(this, arguments);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function _getPublic() {
|
|
614
|
+
_getPublic = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(argv) {
|
|
615
|
+
var isPublic;
|
|
616
|
+
return regenerator.wrap(function _callee4$(_context4) {
|
|
617
|
+
while (1) {
|
|
618
|
+
switch (_context4.prev = _context4.next) {
|
|
619
|
+
case 0:
|
|
620
|
+
if (!(argv['--public'] || argv['--yes'])) {
|
|
621
|
+
_context4.next = 4;
|
|
622
|
+
break;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
isPublic = true;
|
|
626
|
+
_context4.next = 11;
|
|
627
|
+
break;
|
|
628
|
+
|
|
629
|
+
case 4:
|
|
630
|
+
if (!argv['--private']) {
|
|
631
|
+
_context4.next = 8;
|
|
632
|
+
break;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
isPublic = false;
|
|
636
|
+
_context4.next = 11;
|
|
637
|
+
break;
|
|
638
|
+
|
|
639
|
+
case 8:
|
|
640
|
+
_context4.next = 10;
|
|
641
|
+
return prompt({
|
|
642
|
+
type: 'confirm',
|
|
643
|
+
message: 'Will you publish this package to use in other projects?',
|
|
644
|
+
initial: true
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
case 10:
|
|
648
|
+
isPublic = _context4.sent;
|
|
649
|
+
|
|
650
|
+
case 11:
|
|
651
|
+
return _context4.abrupt("return", isPublic);
|
|
652
|
+
|
|
653
|
+
case 12:
|
|
654
|
+
case "end":
|
|
655
|
+
return _context4.stop();
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}, _callee4);
|
|
659
|
+
}));
|
|
660
|
+
return _getPublic.apply(this, arguments);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
function getReact(_x5) {
|
|
664
|
+
return _getReact.apply(this, arguments);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
function _getReact() {
|
|
668
|
+
_getReact = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(argv) {
|
|
669
|
+
var useReact;
|
|
670
|
+
return regenerator.wrap(function _callee5$(_context5) {
|
|
671
|
+
while (1) {
|
|
672
|
+
switch (_context5.prev = _context5.next) {
|
|
673
|
+
case 0:
|
|
674
|
+
if (!(argv['--react'] || argv['--yes'])) {
|
|
675
|
+
_context5.next = 4;
|
|
676
|
+
break;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
useReact = true;
|
|
680
|
+
_context5.next = 11;
|
|
681
|
+
break;
|
|
682
|
+
|
|
683
|
+
case 4:
|
|
684
|
+
if (!argv['--no-react']) {
|
|
685
|
+
_context5.next = 8;
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
useReact = false;
|
|
690
|
+
_context5.next = 11;
|
|
691
|
+
break;
|
|
692
|
+
|
|
693
|
+
case 8:
|
|
694
|
+
_context5.next = 10;
|
|
695
|
+
return prompt({
|
|
696
|
+
type: 'confirm',
|
|
697
|
+
message: 'Will this package depend on React?',
|
|
698
|
+
initial: true
|
|
699
|
+
});
|
|
700
|
+
|
|
701
|
+
case 10:
|
|
702
|
+
useReact = _context5.sent;
|
|
703
|
+
|
|
704
|
+
case 11:
|
|
705
|
+
return _context5.abrupt("return", useReact);
|
|
706
|
+
|
|
707
|
+
case 12:
|
|
708
|
+
case "end":
|
|
709
|
+
return _context5.stop();
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}, _callee5);
|
|
713
|
+
}));
|
|
714
|
+
return _getReact.apply(this, arguments);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
function adjustPackageJson(packageJson, _ref2) {
|
|
718
|
+
var name = _ref2.name,
|
|
719
|
+
react = _ref2.react,
|
|
720
|
+
isPublic = _ref2.isPublic,
|
|
721
|
+
registry = _ref2.registry;
|
|
722
|
+
packageJson.name = name;
|
|
723
|
+
var packageParts = name.split('/');
|
|
724
|
+
var scope = packageParts[0].startsWith('@') ? packageParts[0] : undefined;
|
|
725
|
+
var finalRegistry = registry !== null && registry !== void 0 ? registry : 'https://registry.npmjs.org';
|
|
726
|
+
|
|
727
|
+
if (scope) {
|
|
728
|
+
packageJson.publishConfig["".concat(scope, "/registry")] = finalRegistry;
|
|
729
|
+
} else if (registry) {
|
|
730
|
+
packageJson.publishConfig.registry = finalRegistry;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
if (isPublic) {
|
|
734
|
+
delete packageJson["private"];
|
|
735
|
+
} else {
|
|
736
|
+
delete packageJson.publishConfig;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
if (!react) {
|
|
740
|
+
delete packageJson.dependencies['@types/react'];
|
|
741
|
+
delete packageJson.devDependencies['react'];
|
|
742
|
+
delete packageJson.peerDependencies['react'];
|
|
743
|
+
delete packageJson.peerDependenciesMeta['react'];
|
|
744
|
+
packageJson.eslintConfig["extends"] = packageJson.eslintConfig["extends"].filter(function (extend) {
|
|
745
|
+
return !extend.includes('react');
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
return packageJson;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
function sortKeys(object) {
|
|
753
|
+
var newObject = {};
|
|
754
|
+
var sortedEntries = Object.entries(object).sort(function (_ref3, _ref4) {
|
|
755
|
+
var _ref5 = _slicedToArray(_ref3, 1),
|
|
756
|
+
keyOne = _ref5[0];
|
|
757
|
+
|
|
758
|
+
var _ref6 = _slicedToArray(_ref4, 1),
|
|
759
|
+
keyTwo = _ref6[0];
|
|
760
|
+
|
|
761
|
+
return keyOne.localeCompare(keyTwo);
|
|
762
|
+
});
|
|
763
|
+
|
|
764
|
+
var _iterator = _createForOfIteratorHelper(sortedEntries),
|
|
765
|
+
_step;
|
|
766
|
+
|
|
767
|
+
try {
|
|
768
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
769
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
|
770
|
+
key = _step$value[0],
|
|
771
|
+
value = _step$value[1];
|
|
772
|
+
|
|
773
|
+
newObject[key] = value;
|
|
774
|
+
}
|
|
775
|
+
} catch (err) {
|
|
776
|
+
_iterator.e(err);
|
|
777
|
+
} finally {
|
|
778
|
+
_iterator.f();
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
return newObject;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
export { createProject };
|