@quilted/create 0.1.21 → 0.1.24
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 +18 -0
- package/build/cjs/app.cjs +252 -530
- package/build/cjs/index.cjs +261 -1002
- package/build/cjs/index3.cjs +1205 -577
- package/build/cjs/package-manager.cjs +219 -796
- package/build/cjs/package.cjs +325 -713
- package/build/cjs/parser-babel.cjs +3 -3
- package/build/cjs/parser-typescript.cjs +312 -0
- package/build/cjs/parser-yaml.cjs +2 -2
- package/build/cjs/standalone.cjs +3 -3
- package/build/esm/app.mjs +259 -537
- package/build/esm/index.mjs +245 -984
- package/build/esm/index2.mjs +16 -16
- package/build/esm/index3.mjs +1205 -548
- package/build/esm/package-manager.mjs +220 -797
- package/build/esm/package.mjs +328 -716
- package/build/esm/parser-babel.mjs +1 -1
- package/build/esm/parser-typescript.mjs +310 -0
- package/build/esm/parser-yaml.mjs +1 -1
- 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/package.d.ts.map +1 -1
- package/build/typescript/shared.d.ts +1 -0
- package/build/typescript/shared.d.ts.map +1 -1
- package/package.json +1 -1
- package/source/app.ts +15 -2
- package/source/package.ts +5 -17
- package/source/shared.ts +24 -6
- package/templates/vscode/_vscode/settings.json +6 -1
- package/build/cjs/_commonjsHelpers.cjs +0 -10
- package/build/esm/_commonjsHelpers.mjs +0 -7
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
3
|
+
var path = require('node:path');
|
|
4
|
+
var fs = require('node:fs');
|
|
5
|
+
var node_url = require('node:url');
|
|
6
|
+
require('./index.cjs');
|
|
7
7
|
|
|
8
8
|
function _interopNamespace(e) {
|
|
9
9
|
if (e && e.__esModule) return e;
|
|
@@ -26,296 +26,84 @@ function _interopNamespace(e) {
|
|
|
26
26
|
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
27
27
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
28
28
|
|
|
29
|
-
function _arrayWithHoles(arr) {
|
|
30
|
-
if (Array.isArray(arr)) return arr;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function _iterableToArrayLimit(arr, i) {
|
|
34
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
35
|
-
|
|
36
|
-
if (_i == null) return;
|
|
37
|
-
var _arr = [];
|
|
38
|
-
var _n = true;
|
|
39
|
-
var _d = false;
|
|
40
|
-
|
|
41
|
-
var _s, _e;
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
45
|
-
_arr.push(_s.value);
|
|
46
|
-
|
|
47
|
-
if (i && _arr.length === i) break;
|
|
48
|
-
}
|
|
49
|
-
} catch (err) {
|
|
50
|
-
_d = true;
|
|
51
|
-
_e = err;
|
|
52
|
-
} finally {
|
|
53
|
-
try {
|
|
54
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
55
|
-
} finally {
|
|
56
|
-
if (_d) throw _e;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return _arr;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function _arrayLikeToArray$3(arr, len) {
|
|
64
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
65
|
-
|
|
66
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
67
|
-
arr2[i] = arr[i];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return arr2;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function _unsupportedIterableToArray$3(o, minLen) {
|
|
74
|
-
if (!o) return;
|
|
75
|
-
if (typeof o === "string") return _arrayLikeToArray$3(o, minLen);
|
|
76
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
77
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
78
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
79
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function _nonIterableRest() {
|
|
83
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function _slicedToArray(arr, i) {
|
|
87
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$3(arr, i) || _nonIterableRest();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function _createForOfIteratorHelper$2(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(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; } } }; }
|
|
91
|
-
|
|
92
|
-
function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(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$2(o, minLen); }
|
|
93
|
-
|
|
94
|
-
function _arrayLikeToArray$2(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; }
|
|
95
29
|
function loadTemplate(name) {
|
|
96
|
-
|
|
30
|
+
let templateRootPromise;
|
|
97
31
|
return {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
case 3:
|
|
113
|
-
templateRoot = _context.sent;
|
|
114
|
-
targetRoot = path__namespace.resolve(to);
|
|
115
|
-
files = fs__namespace.readdirSync(templateRoot).filter(function (file) {
|
|
116
|
-
return !path__namespace.basename(file).startsWith('.');
|
|
117
|
-
});
|
|
118
|
-
_iterator = _createForOfIteratorHelper$2(files);
|
|
119
|
-
_context.prev = 7;
|
|
120
|
-
|
|
121
|
-
_iterator.s();
|
|
122
|
-
|
|
123
|
-
case 9:
|
|
124
|
-
if ((_step = _iterator.n()).done) {
|
|
125
|
-
_context.next = 18;
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
_file = _step.value;
|
|
130
|
-
|
|
131
|
-
if (!handleFile) {
|
|
132
|
-
_context.next = 14;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (handleFile(_file)) {
|
|
137
|
-
_context.next = 14;
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return _context.abrupt("continue", 16);
|
|
142
|
-
|
|
143
|
-
case 14:
|
|
144
|
-
targetPath = path__namespace.join(targetRoot, _file.startsWith('_') ? ".".concat(_file.slice(1)) : _file);
|
|
145
|
-
|
|
146
|
-
_copy(path__namespace.join(templateRoot, _file), targetPath);
|
|
147
|
-
|
|
148
|
-
case 16:
|
|
149
|
-
_context.next = 9;
|
|
150
|
-
break;
|
|
151
|
-
|
|
152
|
-
case 18:
|
|
153
|
-
_context.next = 23;
|
|
154
|
-
break;
|
|
155
|
-
|
|
156
|
-
case 20:
|
|
157
|
-
_context.prev = 20;
|
|
158
|
-
_context.t0 = _context["catch"](7);
|
|
159
|
-
|
|
160
|
-
_iterator.e(_context.t0);
|
|
161
|
-
|
|
162
|
-
case 23:
|
|
163
|
-
_context.prev = 23;
|
|
32
|
+
async copy(to, handleFile) {
|
|
33
|
+
var _templateRootPromise;
|
|
34
|
+
|
|
35
|
+
(_templateRootPromise = templateRootPromise) !== null && _templateRootPromise !== void 0 ? _templateRootPromise : templateRootPromise = templateDirectory(name);
|
|
36
|
+
const templateRoot = await templateRootPromise;
|
|
37
|
+
const targetRoot = path__namespace.resolve(to);
|
|
38
|
+
const files = fs__namespace.readdirSync(templateRoot).filter(file => !path__namespace.basename(file).startsWith('.'));
|
|
39
|
+
|
|
40
|
+
for (const file of files) {
|
|
41
|
+
if (handleFile) {
|
|
42
|
+
if (!handleFile(file)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
164
46
|
|
|
165
|
-
|
|
47
|
+
const targetPath = path__namespace.join(targetRoot, file.startsWith('_') ? `.${file.slice(1)}` : file);
|
|
48
|
+
copy(path__namespace.join(templateRoot, file), targetPath);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
166
51
|
|
|
167
|
-
|
|
52
|
+
async read(file) {
|
|
53
|
+
var _templateRootPromise2;
|
|
168
54
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}, _callee, null, [[7, 20, 23, 26]]);
|
|
175
|
-
}))();
|
|
176
|
-
},
|
|
177
|
-
read: function read(file) {
|
|
178
|
-
return index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee2() {
|
|
179
|
-
var _templateRootPromise2;
|
|
180
|
-
|
|
181
|
-
var templateRoot;
|
|
182
|
-
return index.regenerator.wrap(function _callee2$(_context2) {
|
|
183
|
-
while (1) {
|
|
184
|
-
switch (_context2.prev = _context2.next) {
|
|
185
|
-
case 0:
|
|
186
|
-
(_templateRootPromise2 = templateRootPromise) !== null && _templateRootPromise2 !== void 0 ? _templateRootPromise2 : templateRootPromise = templateDirectory(name);
|
|
187
|
-
_context2.next = 3;
|
|
188
|
-
return templateRootPromise;
|
|
189
|
-
|
|
190
|
-
case 3:
|
|
191
|
-
templateRoot = _context2.sent;
|
|
192
|
-
return _context2.abrupt("return", fs__namespace.readFileSync(path__namespace.join(templateRoot, file), {
|
|
193
|
-
encoding: 'utf8'
|
|
194
|
-
}));
|
|
195
|
-
|
|
196
|
-
case 5:
|
|
197
|
-
case "end":
|
|
198
|
-
return _context2.stop();
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}, _callee2);
|
|
202
|
-
}))();
|
|
55
|
+
(_templateRootPromise2 = templateRootPromise) !== null && _templateRootPromise2 !== void 0 ? _templateRootPromise2 : templateRootPromise = templateDirectory(name);
|
|
56
|
+
const templateRoot = await templateRootPromise;
|
|
57
|
+
return fs__namespace.readFileSync(path__namespace.join(templateRoot, file), {
|
|
58
|
+
encoding: 'utf8'
|
|
59
|
+
});
|
|
203
60
|
}
|
|
61
|
+
|
|
204
62
|
};
|
|
205
63
|
}
|
|
206
64
|
function createOutputTarget(target) {
|
|
207
65
|
return {
|
|
208
66
|
root: target,
|
|
209
|
-
|
|
67
|
+
|
|
68
|
+
read(file) {
|
|
210
69
|
return fs__namespace.promises.readFile(path__namespace.resolve(target, file), {
|
|
211
70
|
encoding: 'utf8'
|
|
212
71
|
});
|
|
213
72
|
},
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
while (1) {
|
|
218
|
-
switch (_context3.prev = _context3.next) {
|
|
219
|
-
case 0:
|
|
220
|
-
_context3.next = 2;
|
|
221
|
-
return writeFile(path__namespace.resolve(target, file), content);
|
|
222
|
-
|
|
223
|
-
case 2:
|
|
224
|
-
case "end":
|
|
225
|
-
return _context3.stop();
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}, _callee3);
|
|
229
|
-
}))();
|
|
73
|
+
|
|
74
|
+
async write(file, content) {
|
|
75
|
+
await writeFile(path__namespace.resolve(target, file), content);
|
|
230
76
|
}
|
|
77
|
+
|
|
231
78
|
};
|
|
232
79
|
}
|
|
233
|
-
|
|
80
|
+
let packageRootPromise;
|
|
234
81
|
|
|
235
|
-
function templateDirectory(
|
|
236
|
-
return
|
|
82
|
+
async function templateDirectory(name) {
|
|
83
|
+
return path__namespace.join(await getPackageRoot(), 'templates', name);
|
|
237
84
|
}
|
|
238
85
|
|
|
239
|
-
function
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
_context4.t1 = _context4.sent;
|
|
251
|
-
_context4.t2 = name;
|
|
252
|
-
return _context4.abrupt("return", _context4.t0.join.call(_context4.t0, _context4.t1, 'templates', _context4.t2));
|
|
253
|
-
|
|
254
|
-
case 6:
|
|
255
|
-
case "end":
|
|
256
|
-
return _context4.stop();
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}, _callee4);
|
|
260
|
-
}));
|
|
261
|
-
return _templateDirectory.apply(this, arguments);
|
|
262
|
-
}
|
|
86
|
+
async function getPackageRoot() {
|
|
87
|
+
if (!packageRootPromise) {
|
|
88
|
+
packageRootPromise = (async () => {
|
|
89
|
+
const {
|
|
90
|
+
packageDirectory
|
|
91
|
+
} = await Promise.resolve().then(function () { return require('./index2.cjs'); });
|
|
92
|
+
return packageDirectory({
|
|
93
|
+
cwd: path__namespace.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('package-manager.cjs', document.baseURI).href))))
|
|
94
|
+
});
|
|
95
|
+
})();
|
|
96
|
+
}
|
|
263
97
|
|
|
264
|
-
|
|
265
|
-
return _getPackageRoot.apply(this, arguments);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function _getPackageRoot() {
|
|
269
|
-
_getPackageRoot = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee6() {
|
|
270
|
-
return index.regenerator.wrap(function _callee6$(_context6) {
|
|
271
|
-
while (1) {
|
|
272
|
-
switch (_context6.prev = _context6.next) {
|
|
273
|
-
case 0:
|
|
274
|
-
if (!packageRootPromise) {
|
|
275
|
-
packageRootPromise = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee5() {
|
|
276
|
-
var _yield$import, packageDirectory;
|
|
277
|
-
|
|
278
|
-
return index.regenerator.wrap(function _callee5$(_context5) {
|
|
279
|
-
while (1) {
|
|
280
|
-
switch (_context5.prev = _context5.next) {
|
|
281
|
-
case 0:
|
|
282
|
-
_context5.next = 2;
|
|
283
|
-
return Promise.resolve().then(function () { return require('./index2.cjs'); });
|
|
284
|
-
|
|
285
|
-
case 2:
|
|
286
|
-
_yield$import = _context5.sent;
|
|
287
|
-
packageDirectory = _yield$import.packageDirectory;
|
|
288
|
-
return _context5.abrupt("return", packageDirectory({
|
|
289
|
-
cwd: path__namespace.dirname(url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('package-manager.cjs', document.baseURI).href))))
|
|
290
|
-
}));
|
|
291
|
-
|
|
292
|
-
case 5:
|
|
293
|
-
case "end":
|
|
294
|
-
return _context5.stop();
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}, _callee5);
|
|
298
|
-
}))();
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return _context6.abrupt("return", packageRootPromise);
|
|
302
|
-
|
|
303
|
-
case 2:
|
|
304
|
-
case "end":
|
|
305
|
-
return _context6.stop();
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}, _callee6);
|
|
309
|
-
}));
|
|
310
|
-
return _getPackageRoot.apply(this, arguments);
|
|
98
|
+
return packageRootPromise;
|
|
311
99
|
}
|
|
312
100
|
|
|
313
101
|
function toValidPackageName(projectName) {
|
|
314
102
|
return projectName.trim().toLowerCase().replace(/\s+/g, '-').replace(/^[._]/, '').replace(/[^a-z0-9-~@/]+/g, '-');
|
|
315
103
|
}
|
|
316
104
|
|
|
317
|
-
function
|
|
318
|
-
|
|
105
|
+
function copy(source, destination) {
|
|
106
|
+
const stat = fs__namespace.statSync(source);
|
|
319
107
|
|
|
320
108
|
if (stat.isDirectory()) {
|
|
321
109
|
copyDirectory(source, destination);
|
|
@@ -324,578 +112,212 @@ function _copy(source, destination) {
|
|
|
324
112
|
}
|
|
325
113
|
}
|
|
326
114
|
|
|
327
|
-
function copyDirectory(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
function _copyDirectory() {
|
|
332
|
-
_copyDirectory = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee7(source, destination) {
|
|
333
|
-
var _iterator2, _step2, _file2, srcFile, destFile;
|
|
334
|
-
|
|
335
|
-
return index.regenerator.wrap(function _callee7$(_context7) {
|
|
336
|
-
while (1) {
|
|
337
|
-
switch (_context7.prev = _context7.next) {
|
|
338
|
-
case 0:
|
|
339
|
-
fs__namespace.mkdirSync(destination, {
|
|
340
|
-
recursive: true
|
|
341
|
-
});
|
|
342
|
-
_iterator2 = _createForOfIteratorHelper$2(fs__namespace.readdirSync(source));
|
|
343
|
-
|
|
344
|
-
try {
|
|
345
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
346
|
-
_file2 = _step2.value;
|
|
347
|
-
srcFile = path__namespace.resolve(source, _file2);
|
|
348
|
-
destFile = path__namespace.resolve(destination, _file2);
|
|
349
|
-
|
|
350
|
-
_copy(srcFile, destFile);
|
|
351
|
-
}
|
|
352
|
-
} catch (err) {
|
|
353
|
-
_iterator2.e(err);
|
|
354
|
-
} finally {
|
|
355
|
-
_iterator2.f();
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
case 3:
|
|
359
|
-
case "end":
|
|
360
|
-
return _context7.stop();
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}, _callee7);
|
|
364
|
-
}));
|
|
365
|
-
return _copyDirectory.apply(this, arguments);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function writeFile(_x4, _x5) {
|
|
369
|
-
return _writeFile.apply(this, arguments);
|
|
370
|
-
}
|
|
115
|
+
async function copyDirectory(source, destination) {
|
|
116
|
+
fs__namespace.mkdirSync(destination, {
|
|
117
|
+
recursive: true
|
|
118
|
+
});
|
|
371
119
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
case 0:
|
|
378
|
-
_context8.next = 2;
|
|
379
|
-
return fs__namespace.promises.writeFile(file, content);
|
|
380
|
-
|
|
381
|
-
case 2:
|
|
382
|
-
case "end":
|
|
383
|
-
return _context8.stop();
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}, _callee8);
|
|
387
|
-
}));
|
|
388
|
-
return _writeFile.apply(this, arguments);
|
|
120
|
+
for (const file of fs__namespace.readdirSync(source)) {
|
|
121
|
+
const srcFile = path__namespace.resolve(source, file);
|
|
122
|
+
const destFile = path__namespace.resolve(destination, file);
|
|
123
|
+
copy(srcFile, destFile);
|
|
124
|
+
}
|
|
389
125
|
}
|
|
390
126
|
|
|
391
|
-
function
|
|
392
|
-
|
|
127
|
+
async function writeFile(file, content) {
|
|
128
|
+
await fs__namespace.promises.writeFile(file, content);
|
|
393
129
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
_isEmpty = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee9(path) {
|
|
397
|
-
return index.regenerator.wrap(function _callee9$(_context9) {
|
|
398
|
-
while (1) {
|
|
399
|
-
switch (_context9.prev = _context9.next) {
|
|
400
|
-
case 0:
|
|
401
|
-
return _context9.abrupt("return", fs__namespace.readdirSync(path).length === 0);
|
|
402
|
-
|
|
403
|
-
case 1:
|
|
404
|
-
case "end":
|
|
405
|
-
return _context9.stop();
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}, _callee9);
|
|
409
|
-
}));
|
|
410
|
-
return _isEmpty.apply(this, arguments);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
function emptyDirectory(_x7) {
|
|
414
|
-
return _emptyDirectory.apply(this, arguments);
|
|
130
|
+
async function isEmpty(path) {
|
|
131
|
+
return fs__namespace.readdirSync(path).length === 0;
|
|
415
132
|
}
|
|
133
|
+
async function emptyDirectory(dir) {
|
|
134
|
+
if (!fs__namespace.existsSync(dir)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
416
137
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
switch (_context10.prev = _context10.next) {
|
|
424
|
-
case 0:
|
|
425
|
-
if (fs__namespace.existsSync(dir)) {
|
|
426
|
-
_context10.next = 2;
|
|
427
|
-
break;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
return _context10.abrupt("return");
|
|
431
|
-
|
|
432
|
-
case 2:
|
|
433
|
-
_iterator3 = _createForOfIteratorHelper$2(fs__namespace.readdirSync(dir));
|
|
434
|
-
|
|
435
|
-
try {
|
|
436
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
437
|
-
_file3 = _step3.value;
|
|
438
|
-
fs__namespace.rmSync(path__namespace.resolve(dir, _file3), {
|
|
439
|
-
force: true,
|
|
440
|
-
recursive: true
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
} catch (err) {
|
|
444
|
-
_iterator3.e(err);
|
|
445
|
-
} finally {
|
|
446
|
-
_iterator3.f();
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
case 4:
|
|
450
|
-
case "end":
|
|
451
|
-
return _context10.stop();
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
}, _callee10);
|
|
455
|
-
}));
|
|
456
|
-
return _emptyDirectory.apply(this, arguments);
|
|
138
|
+
for (const file of fs__namespace.readdirSync(dir)) {
|
|
139
|
+
fs__namespace.rmSync(path__namespace.resolve(dir, file), {
|
|
140
|
+
force: true,
|
|
141
|
+
recursive: true
|
|
142
|
+
});
|
|
143
|
+
}
|
|
457
144
|
}
|
|
458
|
-
|
|
459
145
|
function relativeDirectoryForDisplay(relativeDirectory) {
|
|
460
|
-
return relativeDirectory.startsWith('.') ? relativeDirectory :
|
|
461
|
-
}
|
|
462
|
-
function format(
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
trailingComma: 'all',
|
|
489
|
-
parser: parser,
|
|
490
|
-
plugins: [babel, yaml]
|
|
491
|
-
}));
|
|
492
|
-
|
|
493
|
-
case 9:
|
|
494
|
-
case "end":
|
|
495
|
-
return _context11.stop();
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
}, _callee11);
|
|
499
|
-
}));
|
|
500
|
-
return _format.apply(this, arguments);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(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; } } }; }
|
|
146
|
+
return relativeDirectory.startsWith('.') ? relativeDirectory : `.${path__namespace.sep}${relativeDirectory}`;
|
|
147
|
+
}
|
|
148
|
+
async function format(content, {
|
|
149
|
+
as: parser
|
|
150
|
+
}) {
|
|
151
|
+
const [{
|
|
152
|
+
format
|
|
153
|
+
}, {
|
|
154
|
+
default: babel
|
|
155
|
+
}, {
|
|
156
|
+
default: typescript
|
|
157
|
+
}, {
|
|
158
|
+
default: yaml
|
|
159
|
+
}] = await Promise.all([Promise.resolve().then(function () { return require('./standalone.cjs'); }).then(function (n) { return n.standalone; }), Promise.resolve().then(function () { return require('./parser-babel.cjs'); }).then(function (n) { return n.parserBabel; }), Promise.resolve().then(function () { return require('./parser-typescript.cjs'); }).then(function (n) { return n.parserTypescript; }), Promise.resolve().then(function () { return require('./parser-yaml.cjs'); }).then(function (n) { return n.parserYaml; })]);
|
|
160
|
+
return format(content, {
|
|
161
|
+
arrowParens: 'always',
|
|
162
|
+
bracketSpacing: false,
|
|
163
|
+
singleQuote: true,
|
|
164
|
+
trailingComma: 'all',
|
|
165
|
+
parser,
|
|
166
|
+
plugins: [babel, typescript, yaml]
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function mergeDependencies(first = {}, second = {}) {
|
|
170
|
+
const all = { ...first,
|
|
171
|
+
...second
|
|
172
|
+
};
|
|
173
|
+
const merged = {};
|
|
504
174
|
|
|
505
|
-
|
|
175
|
+
for (const [key, value] of Object.entries(all).sort(([keyOne], [keyTwo]) => keyOne.localeCompare(keyTwo))) {
|
|
176
|
+
merged[key] = value;
|
|
177
|
+
}
|
|
506
178
|
|
|
507
|
-
|
|
508
|
-
var ENDS_WITH_TSCONFIG = /[/]?tsconfig[.a-z0-9]*[.]json/i;
|
|
509
|
-
function addToTsConfig(_x, _x2) {
|
|
510
|
-
return _addToTsConfig.apply(this, arguments);
|
|
179
|
+
return merged;
|
|
511
180
|
}
|
|
512
181
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
var tsconfig, relativePath, relativeForDisplay, hasExistingReference, referenceFormat, _iterator, _step, _path, path$1;
|
|
518
|
-
|
|
519
|
-
return index.regenerator.wrap(function _callee$(_context) {
|
|
520
|
-
while (1) {
|
|
521
|
-
switch (_context.prev = _context.next) {
|
|
522
|
-
case 0:
|
|
523
|
-
_context.t0 = JSON;
|
|
524
|
-
_context.next = 3;
|
|
525
|
-
return output.read('tsconfig.json');
|
|
526
|
-
|
|
527
|
-
case 3:
|
|
528
|
-
_context.t1 = _context.sent;
|
|
529
|
-
tsconfig = _context.t0.parse.call(_context.t0, _context.t1);
|
|
530
|
-
(_tsconfig$references = tsconfig.references) !== null && _tsconfig$references !== void 0 ? _tsconfig$references : tsconfig.references = [];
|
|
531
|
-
relativePath = path.relative(output.root, directory);
|
|
532
|
-
relativeForDisplay = relativeDirectoryForDisplay(relativePath);
|
|
533
|
-
|
|
534
|
-
if (!(tsconfig.references.length === 0)) {
|
|
535
|
-
_context.next = 12;
|
|
536
|
-
break;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
tsconfig.references.push({
|
|
540
|
-
path: relativeForDisplay
|
|
541
|
-
});
|
|
542
|
-
_context.next = 53;
|
|
543
|
-
break;
|
|
544
|
-
|
|
545
|
-
case 12:
|
|
546
|
-
hasExistingReference = false;
|
|
547
|
-
referenceFormat = 'pretty-relative';
|
|
548
|
-
_iterator = _createForOfIteratorHelper$1(tsconfig.references);
|
|
549
|
-
_context.prev = 15;
|
|
550
|
-
|
|
551
|
-
_iterator.s();
|
|
182
|
+
const ENDS_WITH_TSCONFIG = /[/]?tsconfig[.a-z0-9]*[.]json/i;
|
|
183
|
+
async function addToTsConfig(directory, output) {
|
|
184
|
+
var _tsconfig$references;
|
|
552
185
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
186
|
+
const tsconfig = JSON.parse(await output.read('tsconfig.json'));
|
|
187
|
+
(_tsconfig$references = tsconfig.references) !== null && _tsconfig$references !== void 0 ? _tsconfig$references : tsconfig.references = [];
|
|
188
|
+
const relativePath = path.relative(output.root, directory);
|
|
189
|
+
const relativeForDisplay = relativeDirectoryForDisplay(relativePath);
|
|
558
190
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
if (!ENDS_WITH_TSCONFIG.test(_path)) {
|
|
567
|
-
_context.next = 25;
|
|
568
|
-
break;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
referenceFormat = 'pretty-tsconfig';
|
|
572
|
-
|
|
573
|
-
if (!(_path === "".concat(relativeForDisplay, "/tsconfig.json"))) {
|
|
574
|
-
_context.next = 25;
|
|
575
|
-
break;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
hasExistingReference = true;
|
|
579
|
-
return _context.abrupt("break", 44);
|
|
580
|
-
|
|
581
|
-
case 25:
|
|
582
|
-
referenceFormat = 'pretty-relative';
|
|
583
|
-
|
|
584
|
-
if (!(_path === relativeForDisplay)) {
|
|
585
|
-
_context.next = 29;
|
|
586
|
-
break;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
hasExistingReference = true;
|
|
590
|
-
return _context.abrupt("break", 44);
|
|
591
|
-
|
|
592
|
-
case 29:
|
|
593
|
-
_context.next = 42;
|
|
594
|
-
break;
|
|
595
|
-
|
|
596
|
-
case 31:
|
|
597
|
-
if (!ENDS_WITH_TSCONFIG.test(_path)) {
|
|
598
|
-
_context.next = 38;
|
|
599
|
-
break;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
referenceFormat = 'tsconfig';
|
|
191
|
+
if (tsconfig.references.length === 0) {
|
|
192
|
+
tsconfig.references.push({
|
|
193
|
+
path: relativeForDisplay
|
|
194
|
+
});
|
|
195
|
+
} else {
|
|
196
|
+
let hasExistingReference = false;
|
|
197
|
+
let referenceFormat = 'pretty-relative';
|
|
603
198
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
199
|
+
for (const {
|
|
200
|
+
path
|
|
201
|
+
} of tsconfig.references) {
|
|
202
|
+
if (path.startsWith('./')) {
|
|
203
|
+
if (ENDS_WITH_TSCONFIG.test(path)) {
|
|
204
|
+
referenceFormat = 'pretty-tsconfig';
|
|
608
205
|
|
|
206
|
+
if (path === `${relativeForDisplay}/tsconfig.json`) {
|
|
609
207
|
hasExistingReference = true;
|
|
610
|
-
return _context.abrupt("break", 44);
|
|
611
|
-
|
|
612
|
-
case 36:
|
|
613
|
-
_context.next = 42;
|
|
614
208
|
break;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
615
211
|
|
|
616
|
-
|
|
617
|
-
referenceFormat = 'relative';
|
|
618
|
-
|
|
619
|
-
if (!(_path === relativePath)) {
|
|
620
|
-
_context.next = 42;
|
|
621
|
-
break;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
hasExistingReference = true;
|
|
625
|
-
return _context.abrupt("break", 44);
|
|
212
|
+
referenceFormat = 'pretty-relative';
|
|
626
213
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
214
|
+
if (path === relativeForDisplay) {
|
|
215
|
+
hasExistingReference = true;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
} else if (ENDS_WITH_TSCONFIG.test(path)) {
|
|
219
|
+
referenceFormat = 'tsconfig';
|
|
630
220
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
221
|
+
if (path === `${relativePath}/tsconfig.json`) {
|
|
222
|
+
hasExistingReference = true;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
referenceFormat = 'relative';
|
|
634
227
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
_iterator.e(_context.t2);
|
|
640
|
-
|
|
641
|
-
case 49:
|
|
642
|
-
_context.prev = 49;
|
|
643
|
-
|
|
644
|
-
_iterator.f();
|
|
645
|
-
|
|
646
|
-
return _context.finish(49);
|
|
647
|
-
|
|
648
|
-
case 52:
|
|
649
|
-
if (!hasExistingReference) {
|
|
650
|
-
if (referenceFormat === 'pretty-tsconfig') {
|
|
651
|
-
path$1 = "".concat(relativeForDisplay, "/tsconfig.json");
|
|
652
|
-
} else if (referenceFormat === 'pretty-relative') {
|
|
653
|
-
path$1 = relativeForDisplay;
|
|
654
|
-
} else if (referenceFormat === 'tsconfig') {
|
|
655
|
-
path$1 = "".concat(relativePath, "/tsconfig.json");
|
|
656
|
-
} else {
|
|
657
|
-
path$1 = relativePath;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
tsconfig.references.push({
|
|
661
|
-
path: path$1
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
case 53:
|
|
666
|
-
tsconfig.references = tsconfig.references.sort(function (_ref, _ref2) {
|
|
667
|
-
var pathOne = _ref.path;
|
|
668
|
-
var pathTwo = _ref2.path;
|
|
669
|
-
return pathOne.localeCompare(pathTwo);
|
|
670
|
-
});
|
|
671
|
-
_context.t3 = output;
|
|
672
|
-
_context.next = 57;
|
|
673
|
-
return format(JSON.stringify(tsconfig), {
|
|
674
|
-
as: 'json'
|
|
675
|
-
});
|
|
676
|
-
|
|
677
|
-
case 57:
|
|
678
|
-
_context.t4 = _context.sent;
|
|
679
|
-
_context.next = 60;
|
|
680
|
-
return _context.t3.write.call(_context.t3, 'tsconfig.json', _context.t4);
|
|
681
|
-
|
|
682
|
-
case 60:
|
|
683
|
-
case "end":
|
|
684
|
-
return _context.stop();
|
|
228
|
+
if (path === relativePath) {
|
|
229
|
+
hasExistingReference = true;
|
|
230
|
+
break;
|
|
685
231
|
}
|
|
686
232
|
}
|
|
687
|
-
}
|
|
688
|
-
}));
|
|
689
|
-
return _addToTsConfig.apply(this, arguments);
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
function _arrayWithoutHoles(arr) {
|
|
693
|
-
if (Array.isArray(arr)) return _arrayLikeToArray$3(arr);
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
function _iterableToArray(iter) {
|
|
697
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
function _nonIterableSpread() {
|
|
701
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
function _toConsumableArray(arr) {
|
|
705
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$3(arr) || _nonIterableSpread();
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
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; } } }; }
|
|
709
|
-
|
|
710
|
-
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); }
|
|
233
|
+
}
|
|
711
234
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
235
|
+
if (!hasExistingReference) {
|
|
236
|
+
let path;
|
|
237
|
+
|
|
238
|
+
if (referenceFormat === 'pretty-tsconfig') {
|
|
239
|
+
path = `${relativeForDisplay}/tsconfig.json`;
|
|
240
|
+
} else if (referenceFormat === 'pretty-relative') {
|
|
241
|
+
path = relativeForDisplay;
|
|
242
|
+
} else if (referenceFormat === 'tsconfig') {
|
|
243
|
+
path = `${relativePath}/tsconfig.json`;
|
|
244
|
+
} else {
|
|
245
|
+
path = relativePath;
|
|
246
|
+
}
|
|
716
247
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
while (1) {
|
|
723
|
-
switch (_context.prev = _context.next) {
|
|
724
|
-
case 0:
|
|
725
|
-
if (!(packageManager === 'pnpm')) {
|
|
726
|
-
_context.next = 22;
|
|
727
|
-
break;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
_context.next = 3;
|
|
731
|
-
return Promise.resolve().then(function () { return require('./index3.cjs'); });
|
|
732
|
-
|
|
733
|
-
case 3:
|
|
734
|
-
_yield$import = _context.sent;
|
|
735
|
-
parse = _yield$import.parse;
|
|
736
|
-
stringify = _yield$import.stringify;
|
|
737
|
-
_context.t0 = parse;
|
|
738
|
-
_context.next = 9;
|
|
739
|
-
return output.read('pnpm-workspace.yaml');
|
|
740
|
-
|
|
741
|
-
case 9:
|
|
742
|
-
_context.t1 = _context.sent;
|
|
743
|
-
workspaceYaml = (0, _context.t0)(_context.t1);
|
|
744
|
-
_context.next = 13;
|
|
745
|
-
return addToWorkspaces(path.relative(output.root, directory), (_workspaceYaml$packag = workspaceYaml.packages) !== null && _workspaceYaml$packag !== void 0 ? _workspaceYaml$packag : []);
|
|
746
|
-
|
|
747
|
-
case 13:
|
|
748
|
-
workspaceYaml.packages = _context.sent;
|
|
749
|
-
_context.t2 = output;
|
|
750
|
-
_context.next = 17;
|
|
751
|
-
return format(stringify(workspaceYaml), {
|
|
752
|
-
as: 'yaml'
|
|
753
|
-
});
|
|
754
|
-
|
|
755
|
-
case 17:
|
|
756
|
-
_context.t3 = _context.sent;
|
|
757
|
-
_context.next = 20;
|
|
758
|
-
return _context.t2.write.call(_context.t2, 'pnpm-workspace.yaml', _context.t3);
|
|
759
|
-
|
|
760
|
-
case 20:
|
|
761
|
-
_context.next = 36;
|
|
762
|
-
break;
|
|
248
|
+
tsconfig.references.push({
|
|
249
|
+
path
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}
|
|
763
253
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
packageJson = _context.t4.parse.call(_context.t4, _context.t5);
|
|
772
|
-
_context.next = 29;
|
|
773
|
-
return addToWorkspaces(path.relative(output.root, directory), (_packageJson$workspac = packageJson.workspaces) !== null && _packageJson$workspac !== void 0 ? _packageJson$workspac : []);
|
|
774
|
-
|
|
775
|
-
case 29:
|
|
776
|
-
packageJson.workspaces = _context.sent;
|
|
777
|
-
_context.t6 = output;
|
|
778
|
-
_context.next = 33;
|
|
779
|
-
return format(JSON.stringify(packageJson), {
|
|
780
|
-
as: 'json-stringify'
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
case 33:
|
|
784
|
-
_context.t7 = _context.sent;
|
|
785
|
-
_context.next = 36;
|
|
786
|
-
return _context.t6.write.call(_context.t6, 'package.json', _context.t7);
|
|
787
|
-
|
|
788
|
-
case 36:
|
|
789
|
-
case "end":
|
|
790
|
-
return _context.stop();
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
}, _callee);
|
|
254
|
+
tsconfig.references = tsconfig.references.sort(({
|
|
255
|
+
path: pathOne
|
|
256
|
+
}, {
|
|
257
|
+
path: pathTwo
|
|
258
|
+
}) => pathOne.localeCompare(pathTwo));
|
|
259
|
+
await output.write('tsconfig.json', await format(JSON.stringify(tsconfig), {
|
|
260
|
+
as: 'json'
|
|
794
261
|
}));
|
|
795
|
-
return _addToPackageManagerWorkspaces.apply(this, arguments);
|
|
796
262
|
}
|
|
797
263
|
|
|
798
|
-
function
|
|
799
|
-
|
|
800
|
-
|
|
264
|
+
async function addToPackageManagerWorkspaces(directory, output, packageManager) {
|
|
265
|
+
if (packageManager === 'pnpm') {
|
|
266
|
+
var _workspaceYaml$packag;
|
|
801
267
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
return _context2.abrupt("return", [relative]);
|
|
816
|
-
|
|
817
|
-
case 2:
|
|
818
|
-
// Default documentation seems to generally exclude leading `./` on paths
|
|
819
|
-
pretty = false;
|
|
820
|
-
hasMatch = false;
|
|
821
|
-
_context2.next = 6;
|
|
822
|
-
return Promise.resolve().then(function () { return require('./minimatch.cjs'); }).then(function (n) { return n.minimatch; });
|
|
823
|
-
|
|
824
|
-
case 6:
|
|
825
|
-
_yield$import2 = _context2.sent;
|
|
826
|
-
minimatch = _yield$import2["default"];
|
|
827
|
-
_iterator = _createForOfIteratorHelper(workspaces);
|
|
828
|
-
_context2.prev = 9;
|
|
829
|
-
|
|
830
|
-
_iterator.s();
|
|
831
|
-
|
|
832
|
-
case 11:
|
|
833
|
-
if ((_step = _iterator.n()).done) {
|
|
834
|
-
_context2.next = 20;
|
|
835
|
-
break;
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
pattern = _step.value;
|
|
839
|
-
normalizedPattern = pattern;
|
|
840
|
-
|
|
841
|
-
if (pattern.startsWith('./')) {
|
|
842
|
-
pretty = true;
|
|
843
|
-
normalizedPattern = pattern.slice(2);
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
if (!minimatch(relative, normalizedPattern)) {
|
|
847
|
-
_context2.next = 18;
|
|
848
|
-
break;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
hasMatch = true;
|
|
852
|
-
return _context2.abrupt("break", 20);
|
|
853
|
-
|
|
854
|
-
case 18:
|
|
855
|
-
_context2.next = 11;
|
|
856
|
-
break;
|
|
857
|
-
|
|
858
|
-
case 20:
|
|
859
|
-
_context2.next = 25;
|
|
860
|
-
break;
|
|
268
|
+
const {
|
|
269
|
+
parse,
|
|
270
|
+
stringify
|
|
271
|
+
} = await Promise.resolve().then(function () { return require('./index3.cjs'); }).then(function (n) { return n.index; });
|
|
272
|
+
const workspaceYaml = parse(await output.read('pnpm-workspace.yaml'));
|
|
273
|
+
workspaceYaml.packages = await addToWorkspaces(path.relative(output.root, directory), (_workspaceYaml$packag = workspaceYaml.packages) !== null && _workspaceYaml$packag !== void 0 ? _workspaceYaml$packag : []);
|
|
274
|
+
await output.write('pnpm-workspace.yaml', await format(stringify(workspaceYaml), {
|
|
275
|
+
as: 'yaml'
|
|
276
|
+
}));
|
|
277
|
+
} else {
|
|
278
|
+
var _packageJson$workspac;
|
|
861
279
|
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
280
|
+
const packageJson = JSON.parse(await output.read('package.json'));
|
|
281
|
+
packageJson.workspaces = await addToWorkspaces(path.relative(output.root, directory), (_packageJson$workspac = packageJson.workspaces) !== null && _packageJson$workspac !== void 0 ? _packageJson$workspac : []);
|
|
282
|
+
await output.write('package.json', await format(JSON.stringify(packageJson), {
|
|
283
|
+
as: 'json-stringify'
|
|
284
|
+
}));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
865
287
|
|
|
866
|
-
|
|
288
|
+
async function addToWorkspaces(relative, workspaces) {
|
|
289
|
+
if (workspaces.length === 0) {
|
|
290
|
+
return [relative];
|
|
291
|
+
} // Default documentation seems to generally exclude leading `./` on paths
|
|
867
292
|
|
|
868
|
-
case 25:
|
|
869
|
-
_context2.prev = 25;
|
|
870
293
|
|
|
871
|
-
|
|
294
|
+
let pretty = false;
|
|
295
|
+
let hasMatch = false;
|
|
296
|
+
const {
|
|
297
|
+
default: minimatch
|
|
298
|
+
} = await Promise.resolve().then(function () { return require('./minimatch.cjs'); }).then(function (n) { return n.minimatch; });
|
|
872
299
|
|
|
873
|
-
|
|
300
|
+
for (const pattern of workspaces) {
|
|
301
|
+
let normalizedPattern = pattern;
|
|
874
302
|
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
}
|
|
303
|
+
if (pattern.startsWith('./')) {
|
|
304
|
+
pretty = true;
|
|
305
|
+
normalizedPattern = pattern.slice(2);
|
|
306
|
+
}
|
|
880
307
|
|
|
881
|
-
|
|
308
|
+
if (minimatch(relative, normalizedPattern)) {
|
|
309
|
+
hasMatch = true;
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
882
313
|
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
}));
|
|
314
|
+
if (hasMatch) {
|
|
315
|
+
return workspaces;
|
|
316
|
+
}
|
|
887
317
|
|
|
888
|
-
|
|
889
|
-
case "end":
|
|
890
|
-
return _context2.stop();
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
}, _callee2, null, [[9, 22, 25, 28]]);
|
|
894
|
-
}));
|
|
895
|
-
return _addToWorkspaces.apply(this, arguments);
|
|
318
|
+
return [...workspaces, pretty ? relativeDirectoryForDisplay(relative) : relative].sort((patternOne, patternTwo) => patternOne.localeCompare(patternTwo));
|
|
896
319
|
}
|
|
897
320
|
|
|
898
|
-
exports._slicedToArray = _slicedToArray;
|
|
899
321
|
exports.addToPackageManagerWorkspaces = addToPackageManagerWorkspaces;
|
|
900
322
|
exports.addToTsConfig = addToTsConfig;
|
|
901
323
|
exports.createOutputTarget = createOutputTarget;
|
|
@@ -903,5 +325,6 @@ exports.emptyDirectory = emptyDirectory;
|
|
|
903
325
|
exports.format = format;
|
|
904
326
|
exports.isEmpty = isEmpty;
|
|
905
327
|
exports.loadTemplate = loadTemplate;
|
|
328
|
+
exports.mergeDependencies = mergeDependencies;
|
|
906
329
|
exports.relativeDirectoryForDisplay = relativeDirectoryForDisplay;
|
|
907
330
|
exports.toValidPackageName = toValidPackageName;
|