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