@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,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var index = require('./index.cjs');
3
4
  var path = require('path');
4
5
  var fs = require('fs');
5
6
  var url = require('url');
6
- require('./index.cjs');
7
7
 
8
8
  function _interopNamespace(e) {
9
9
  if (e && e.__esModule) return e;
@@ -26,80 +26,296 @@ 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; }
29
95
  function loadTemplate(name) {
30
- let templateRootPromise;
96
+ var templateRootPromise;
31
97
  return {
32
- async copy(to, handleFile) {
33
- templateRootPromise ?? (templateRootPromise = templateDirectory(name));
34
- const templateRoot = await templateRootPromise;
35
- const targetRoot = path__namespace.resolve(to);
36
- const files = fs__namespace.readdirSync(templateRoot).filter(file => !path__namespace.basename(file).startsWith('.'));
37
-
38
- for (const file of files) {
39
- if (handleFile) {
40
- if (!handleFile(file)) {
41
- continue;
42
- }
43
- }
98
+ copy: function copy(to, handleFile) {
99
+ return index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee() {
100
+ var _templateRootPromise;
44
101
 
45
- const targetPath = path__namespace.join(targetRoot, file.startsWith('_') ? `.${file.slice(1)}` : file);
46
- copy(path__namespace.join(templateRoot, file), targetPath);
47
- }
48
- },
102
+ var templateRoot, targetRoot, files, _iterator, _step, _file, targetPath;
49
103
 
50
- async read(file) {
51
- templateRootPromise ?? (templateRootPromise = templateDirectory(name));
52
- const templateRoot = await templateRootPromise;
53
- return fs__namespace.readFileSync(path__namespace.join(templateRoot, file), {
54
- encoding: 'utf8'
55
- });
56
- }
104
+ return index.regenerator.wrap(function _callee$(_context) {
105
+ while (1) {
106
+ switch (_context.prev = _context.next) {
107
+ case 0:
108
+ (_templateRootPromise = templateRootPromise) !== null && _templateRootPromise !== void 0 ? _templateRootPromise : templateRootPromise = templateDirectory(name);
109
+ _context.next = 3;
110
+ return templateRootPromise;
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;
57
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;
164
+
165
+ _iterator.f();
166
+
167
+ return _context.finish(23);
168
+
169
+ case 26:
170
+ case "end":
171
+ return _context.stop();
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
+ }))();
203
+ }
58
204
  };
59
205
  }
60
206
  function createOutputTarget(target) {
61
207
  return {
62
208
  root: target,
63
-
64
- read(file) {
209
+ read: function read(file) {
65
210
  return fs__namespace.promises.readFile(path__namespace.resolve(target, file), {
66
211
  encoding: 'utf8'
67
212
  });
68
213
  },
69
-
70
- async write(file, content) {
71
- await writeFile(path__namespace.resolve(target, file), content);
214
+ write: function write(file, content) {
215
+ return index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee3() {
216
+ return index.regenerator.wrap(function _callee3$(_context3) {
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
+ }))();
72
230
  }
73
-
74
231
  };
75
232
  }
76
- let packageRootPromise;
233
+ var packageRootPromise;
77
234
 
78
- async function templateDirectory(name) {
79
- return path__namespace.join(await getPackageRoot(), 'templates', name);
235
+ function templateDirectory(_x) {
236
+ return _templateDirectory.apply(this, arguments);
80
237
  }
81
238
 
82
- async function getPackageRoot() {
83
- if (!packageRootPromise) {
84
- packageRootPromise = (async () => {
85
- const {
86
- packageDirectory
87
- } = await Promise.resolve().then(function () { return require('./index2.cjs'); });
88
- return packageDirectory({
89
- 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))))
90
- });
91
- })();
92
- }
239
+ function _templateDirectory() {
240
+ _templateDirectory = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee4(name) {
241
+ return index.regenerator.wrap(function _callee4$(_context4) {
242
+ while (1) {
243
+ switch (_context4.prev = _context4.next) {
244
+ case 0:
245
+ _context4.t0 = path__namespace;
246
+ _context4.next = 3;
247
+ return getPackageRoot();
248
+
249
+ case 3:
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
+ }
263
+
264
+ function getPackageRoot() {
265
+ return _getPackageRoot.apply(this, arguments);
266
+ }
93
267
 
94
- return packageRootPromise;
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);
95
311
  }
96
312
 
97
313
  function toValidPackageName(projectName) {
98
314
  return projectName.trim().toLowerCase().replace(/\s+/g, '-').replace(/^[._]/, '').replace(/[^a-z0-9-~@/]+/g, '-');
99
315
  }
100
316
 
101
- function copy(source, destination) {
102
- const stat = fs__namespace.statSync(source);
317
+ function _copy(source, destination) {
318
+ var stat = fs__namespace.statSync(source);
103
319
 
104
320
  if (stat.isDirectory()) {
105
321
  copyDirectory(source, destination);
@@ -108,192 +324,578 @@ function copy(source, destination) {
108
324
  }
109
325
  }
110
326
 
111
- async function copyDirectory(source, destination) {
112
- fs__namespace.mkdirSync(destination, {
113
- recursive: true
114
- });
327
+ function copyDirectory(_x2, _x3) {
328
+ return _copyDirectory.apply(this, arguments);
329
+ }
115
330
 
116
- for (const file of fs__namespace.readdirSync(source)) {
117
- const srcFile = path__namespace.resolve(source, file);
118
- const destFile = path__namespace.resolve(destination, file);
119
- copy(srcFile, destFile);
120
- }
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);
121
366
  }
122
367
 
123
- async function writeFile(file, content) {
124
- await fs__namespace.promises.writeFile(file, content);
368
+ function writeFile(_x4, _x5) {
369
+ return _writeFile.apply(this, arguments);
125
370
  }
126
- async function isEmpty(path) {
127
- return fs__namespace.readdirSync(path).length === 0;
371
+
372
+ function _writeFile() {
373
+ _writeFile = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee8(file, content) {
374
+ return index.regenerator.wrap(function _callee8$(_context8) {
375
+ while (1) {
376
+ switch (_context8.prev = _context8.next) {
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);
128
389
  }
129
- async function emptyDirectory(dir) {
130
- if (!fs__namespace.existsSync(dir)) {
131
- return;
132
- }
133
390
 
134
- for (const file of fs__namespace.readdirSync(dir)) {
135
- fs__namespace.rmSync(path__namespace.resolve(dir, file), {
136
- force: true,
137
- recursive: true
138
- });
139
- }
391
+ function isEmpty(_x6) {
392
+ return _isEmpty.apply(this, arguments);
393
+ }
394
+
395
+ function _isEmpty() {
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);
415
+ }
416
+
417
+ function _emptyDirectory() {
418
+ _emptyDirectory = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee10(dir) {
419
+ var _iterator3, _step3, _file3;
420
+
421
+ return index.regenerator.wrap(function _callee10$(_context10) {
422
+ while (1) {
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);
140
457
  }
458
+
141
459
  function relativeDirectoryForDisplay(relativeDirectory) {
142
- return relativeDirectory.startsWith('.') ? relativeDirectory : `.${path__namespace.sep}${relativeDirectory}`;
143
- }
144
- async function format(content, {
145
- as: parser
146
- }) {
147
- const [{
148
- format
149
- }, {
150
- default: babel
151
- }, {
152
- default: yaml
153
- }] = 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-yaml.cjs'); }).then(function (n) { return n.parserYaml; })]);
154
- return format(content, {
155
- arrowParens: 'always',
156
- bracketSpacing: false,
157
- singleQuote: true,
158
- trailingComma: 'all',
159
- parser,
160
- plugins: [babel, yaml]
161
- });
162
- }
163
-
164
- const ENDS_WITH_TSCONFIG = /[/]?tsconfig[.a-z0-9]*[.]json/i;
165
- async function addToTsConfig(directory, output) {
166
- const tsconfig = JSON.parse(await output.read('tsconfig.json'));
167
- tsconfig.references ?? (tsconfig.references = []);
168
- const relativePath = path.relative(output.root, directory);
169
- const relativeForDisplay = relativeDirectoryForDisplay(relativePath);
170
-
171
- if (tsconfig.references.length === 0) {
172
- tsconfig.references.push({
173
- path: relativeForDisplay
174
- });
175
- } else {
176
- let hasExistingReference = false;
177
- let referenceFormat = 'pretty-relative';
460
+ return relativeDirectory.startsWith('.') ? relativeDirectory : ".".concat(path__namespace.sep).concat(relativeDirectory);
461
+ }
462
+ function format(_x8, _x9) {
463
+ return _format.apply(this, arguments);
464
+ }
465
+
466
+ function _format() {
467
+ _format = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee11(content, _ref) {
468
+ var parser, _yield$Promise$all, _yield$Promise$all2, format, babel, yaml;
469
+
470
+ return index.regenerator.wrap(function _callee11$(_context11) {
471
+ while (1) {
472
+ switch (_context11.prev = _context11.next) {
473
+ case 0:
474
+ parser = _ref.as;
475
+ _context11.next = 3;
476
+ return 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-yaml.cjs'); }).then(function (n) { return n.parserYaml; })]);
477
+
478
+ case 3:
479
+ _yield$Promise$all = _context11.sent;
480
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
481
+ format = _yield$Promise$all2[0].format;
482
+ babel = _yield$Promise$all2[1]["default"];
483
+ yaml = _yield$Promise$all2[2]["default"];
484
+ return _context11.abrupt("return", format(content, {
485
+ arrowParens: 'always',
486
+ bracketSpacing: false,
487
+ singleQuote: true,
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; } } }; }
504
+
505
+ 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); }
506
+
507
+ 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; }
508
+ var ENDS_WITH_TSCONFIG = /[/]?tsconfig[.a-z0-9]*[.]json/i;
509
+ function addToTsConfig(_x, _x2) {
510
+ return _addToTsConfig.apply(this, arguments);
511
+ }
512
+
513
+ function _addToTsConfig() {
514
+ _addToTsConfig = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee(directory, output) {
515
+ var _tsconfig$references;
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;
178
544
 
179
- for (const {
180
- path
181
- } of tsconfig.references) {
182
- if (path.startsWith('./')) {
183
- if (ENDS_WITH_TSCONFIG.test(path)) {
184
- referenceFormat = 'pretty-tsconfig';
545
+ case 12:
546
+ hasExistingReference = false;
547
+ referenceFormat = 'pretty-relative';
548
+ _iterator = _createForOfIteratorHelper$1(tsconfig.references);
549
+ _context.prev = 15;
550
+
551
+ _iterator.s();
552
+
553
+ case 17:
554
+ if ((_step = _iterator.n()).done) {
555
+ _context.next = 44;
556
+ break;
557
+ }
558
+
559
+ _path = _step.value.path;
560
+
561
+ if (!_path.startsWith('./')) {
562
+ _context.next = 31;
563
+ break;
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
+ }
185
588
 
186
- if (path === `${relativeForDisplay}/tsconfig.json`) {
187
589
  hasExistingReference = true;
590
+ return _context.abrupt("break", 44);
591
+
592
+ case 29:
593
+ _context.next = 42;
188
594
  break;
189
- }
190
- }
191
595
 
192
- referenceFormat = 'pretty-relative';
596
+ case 31:
597
+ if (!ENDS_WITH_TSCONFIG.test(_path)) {
598
+ _context.next = 38;
599
+ break;
600
+ }
193
601
 
194
- if (path === relativeForDisplay) {
195
- hasExistingReference = true;
196
- break;
197
- }
198
- } else if (ENDS_WITH_TSCONFIG.test(path)) {
199
- referenceFormat = 'tsconfig';
602
+ referenceFormat = 'tsconfig';
200
603
 
201
- if (path === `${relativePath}/tsconfig.json`) {
202
- hasExistingReference = true;
203
- break;
204
- }
205
- } else {
206
- referenceFormat = 'relative';
604
+ if (!(_path === "".concat(relativePath, "/tsconfig.json"))) {
605
+ _context.next = 36;
606
+ break;
607
+ }
608
+
609
+ hasExistingReference = true;
610
+ return _context.abrupt("break", 44);
611
+
612
+ case 36:
613
+ _context.next = 42;
614
+ break;
615
+
616
+ case 38:
617
+ referenceFormat = 'relative';
207
618
 
208
- if (path === relativePath) {
209
- hasExistingReference = true;
210
- break;
619
+ if (!(_path === relativePath)) {
620
+ _context.next = 42;
621
+ break;
622
+ }
623
+
624
+ hasExistingReference = true;
625
+ return _context.abrupt("break", 44);
626
+
627
+ case 42:
628
+ _context.next = 17;
629
+ break;
630
+
631
+ case 44:
632
+ _context.next = 49;
633
+ break;
634
+
635
+ case 46:
636
+ _context.prev = 46;
637
+ _context.t2 = _context["catch"](15);
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();
211
685
  }
212
686
  }
213
- }
687
+ }, _callee, null, [[15, 46, 49, 52]]);
688
+ }));
689
+ return _addToTsConfig.apply(this, arguments);
690
+ }
214
691
 
215
- if (!hasExistingReference) {
216
- let path;
217
-
218
- if (referenceFormat === 'pretty-tsconfig') {
219
- path = `${relativeForDisplay}/tsconfig.json`;
220
- } else if (referenceFormat === 'pretty-relative') {
221
- path = relativeForDisplay;
222
- } else if (referenceFormat === 'tsconfig') {
223
- path = `${relativePath}/tsconfig.json`;
224
- } else {
225
- path = relativePath;
226
- }
692
+ function _arrayWithoutHoles(arr) {
693
+ if (Array.isArray(arr)) return _arrayLikeToArray$3(arr);
694
+ }
227
695
 
228
- tsconfig.references.push({
229
- path
230
- });
231
- }
232
- }
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; } } }; }
233
709
 
234
- tsconfig.references = tsconfig.references.sort(({
235
- path: pathOne
236
- }, {
237
- path: pathTwo
238
- }) => pathOne.localeCompare(pathTwo));
239
- await output.write('tsconfig.json', await format(JSON.stringify(tsconfig), {
240
- as: 'json'
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); }
711
+
712
+ 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; }
713
+ function addToPackageManagerWorkspaces(_x, _x2, _x3) {
714
+ return _addToPackageManagerWorkspaces.apply(this, arguments);
715
+ }
716
+
717
+ function _addToPackageManagerWorkspaces() {
718
+ _addToPackageManagerWorkspaces = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee(directory, output, packageManager) {
719
+ var _workspaceYaml$packag, _yield$import, parse, stringify, workspaceYaml, _packageJson$workspac, packageJson;
720
+
721
+ return index.regenerator.wrap(function _callee$(_context) {
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;
763
+
764
+ case 22:
765
+ _context.t4 = JSON;
766
+ _context.next = 25;
767
+ return output.read('package.json');
768
+
769
+ case 25:
770
+ _context.t5 = _context.sent;
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);
241
794
  }));
795
+ return _addToPackageManagerWorkspaces.apply(this, arguments);
242
796
  }
243
797
 
244
- async function addToPackageManagerWorkspaces(directory, output, packageManager) {
245
- if (packageManager === 'pnpm') {
246
- const {
247
- parse,
248
- stringify
249
- } = await Promise.resolve().then(function () { return require('./index3.cjs'); }).then(function (n) { return n.index; });
250
- const workspaceYaml = parse(await output.read('pnpm-workspace.yaml'));
251
- workspaceYaml.packages = await addToWorkspaces(path.relative(output.root, directory), workspaceYaml.packages ?? []);
252
- await output.write('pnpm-workspace.yaml', await format(stringify(workspaceYaml), {
253
- as: 'yaml'
254
- }));
255
- } else {
256
- const packageJson = JSON.parse(await output.read('package.json'));
257
- packageJson.workspaces = await addToWorkspaces(path.relative(output.root, directory), packageJson.workspaces ?? []);
258
- await output.write('package.json', await format(JSON.stringify(packageJson), {
259
- as: 'json-stringify'
260
- }));
261
- }
798
+ function addToWorkspaces(_x4, _x5) {
799
+ return _addToWorkspaces.apply(this, arguments);
262
800
  }
263
801
 
264
- async function addToWorkspaces(relative, workspaces) {
265
- if (workspaces.length === 0) {
266
- return [relative];
267
- } // Default documentation seems to generally exclude leading `./` on paths
802
+ function _addToWorkspaces() {
803
+ _addToWorkspaces = index._asyncToGenerator( /*#__PURE__*/index.regenerator.mark(function _callee2(relative, workspaces) {
804
+ var pretty, hasMatch, _yield$import2, minimatch, _iterator, _step, pattern, normalizedPattern;
805
+
806
+ return index.regenerator.wrap(function _callee2$(_context2) {
807
+ while (1) {
808
+ switch (_context2.prev = _context2.next) {
809
+ case 0:
810
+ if (!(workspaces.length === 0)) {
811
+ _context2.next = 2;
812
+ break;
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;
268
857
 
858
+ case 20:
859
+ _context2.next = 25;
860
+ break;
269
861
 
270
- let pretty = false;
271
- let hasMatch = false;
272
- const {
273
- default: minimatch
274
- } = await Promise.resolve().then(function () { return require('./minimatch.cjs'); }).then(function (n) { return n.minimatch; });
862
+ case 22:
863
+ _context2.prev = 22;
864
+ _context2.t0 = _context2["catch"](9);
275
865
 
276
- for (const pattern of workspaces) {
277
- let normalizedPattern = pattern;
866
+ _iterator.e(_context2.t0);
278
867
 
279
- if (pattern.startsWith('./')) {
280
- pretty = true;
281
- normalizedPattern = pattern.slice(2);
282
- }
868
+ case 25:
869
+ _context2.prev = 25;
283
870
 
284
- if (minimatch(relative, normalizedPattern)) {
285
- hasMatch = true;
286
- break;
287
- }
288
- }
871
+ _iterator.f();
289
872
 
290
- if (hasMatch) {
291
- return workspaces;
292
- }
873
+ return _context2.finish(25);
874
+
875
+ case 28:
876
+ if (!hasMatch) {
877
+ _context2.next = 30;
878
+ break;
879
+ }
293
880
 
294
- return [...workspaces, pretty ? relativeDirectoryForDisplay(relative) : relative].sort((patternOne, patternTwo) => patternOne.localeCompare(patternTwo));
881
+ return _context2.abrupt("return", workspaces);
882
+
883
+ case 30:
884
+ return _context2.abrupt("return", [].concat(_toConsumableArray(workspaces), [pretty ? relativeDirectoryForDisplay(relative) : relative]).sort(function (patternOne, patternTwo) {
885
+ return patternOne.localeCompare(patternTwo);
886
+ }));
887
+
888
+ case 31:
889
+ case "end":
890
+ return _context2.stop();
891
+ }
892
+ }
893
+ }, _callee2, null, [[9, 22, 25, 28]]);
894
+ }));
895
+ return _addToWorkspaces.apply(this, arguments);
295
896
  }
296
897
 
898
+ exports._slicedToArray = _slicedToArray;
297
899
  exports.addToPackageManagerWorkspaces = addToPackageManagerWorkspaces;
298
900
  exports.addToTsConfig = addToTsConfig;
299
901
  exports.createOutputTarget = createOutputTarget;