projen 0.65.21 → 0.65.23

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.
Files changed (123) hide show
  1. package/.jsii +2 -2
  2. package/lib/awscdk/auto-discover.js +5 -5
  3. package/lib/awscdk/awscdk-app-java.js +1 -1
  4. package/lib/awscdk/awscdk-app-py.js +1 -1
  5. package/lib/awscdk/awscdk-app-ts.js +1 -1
  6. package/lib/awscdk/awscdk-construct.js +2 -2
  7. package/lib/awscdk/awscdk-deps-java.js +1 -1
  8. package/lib/awscdk/awscdk-deps-js.js +1 -1
  9. package/lib/awscdk/awscdk-deps-py.js +1 -1
  10. package/lib/awscdk/awscdk-deps.js +1 -1
  11. package/lib/awscdk/cdk-config.js +1 -1
  12. package/lib/awscdk/cdk-tasks.js +1 -1
  13. package/lib/awscdk/integration-test.js +1 -1
  14. package/lib/awscdk/lambda-extension.js +1 -1
  15. package/lib/awscdk/lambda-function.js +2 -2
  16. package/lib/build/build-workflow.js +1 -1
  17. package/lib/cdk/auto-discover-base.js +2 -2
  18. package/lib/cdk/construct-lib.js +1 -1
  19. package/lib/cdk/integration-test-base.js +1 -1
  20. package/lib/cdk/jsii-docgen.js +1 -1
  21. package/lib/cdk/jsii-project.js +1 -1
  22. package/lib/cdk8s/auto-discover.js +2 -2
  23. package/lib/cdk8s/cdk8s-app-py.js +1 -1
  24. package/lib/cdk8s/cdk8s-app-ts.js +1 -1
  25. package/lib/cdk8s/cdk8s-construct.js +1 -1
  26. package/lib/cdk8s/cdk8s-deps-py.js +1 -1
  27. package/lib/cdk8s/cdk8s-deps.js +1 -1
  28. package/lib/cdk8s/integration-test.js +1 -1
  29. package/lib/cdktf/cdktf-construct.js +1 -1
  30. package/lib/circleci/circleci.js +1 -1
  31. package/lib/component.js +1 -1
  32. package/lib/dependencies.js +1 -1
  33. package/lib/dev-env.js +1 -1
  34. package/lib/docker-compose.js +2 -2
  35. package/lib/file.js +1 -1
  36. package/lib/gitattributes.js +1 -1
  37. package/lib/github/auto-approve.js +1 -1
  38. package/lib/github/auto-merge.js +1 -1
  39. package/lib/github/dependabot.js +1 -1
  40. package/lib/github/github-credentials.js +1 -1
  41. package/lib/github/github-project.js +1 -1
  42. package/lib/github/github.js +1 -1
  43. package/lib/github/mergify.js +1 -1
  44. package/lib/github/pr-template.js +1 -1
  45. package/lib/github/pull-request-lint.js +1 -1
  46. package/lib/github/stale.js +1 -1
  47. package/lib/github/task-workflow.js +1 -1
  48. package/lib/github/workflows.js +1 -1
  49. package/lib/gitlab/configuration.js +1 -1
  50. package/lib/gitlab/gitlab-configuration.js +1 -1
  51. package/lib/gitlab/nested-configuration.js +1 -1
  52. package/lib/gitpod.js +1 -1
  53. package/lib/ignore-file.js +1 -1
  54. package/lib/ini.js +1 -1
  55. package/lib/java/java-project.js +1 -1
  56. package/lib/java/junit.js +1 -1
  57. package/lib/java/maven-compile.js +1 -1
  58. package/lib/java/maven-packaging.js +1 -1
  59. package/lib/java/maven-sample.js +1 -1
  60. package/lib/java/pom.js +1 -1
  61. package/lib/java/projenrc.js +1 -1
  62. package/lib/javascript/bundler.js +1 -1
  63. package/lib/javascript/eslint.js +1 -1
  64. package/lib/javascript/jest.js +1 -1
  65. package/lib/javascript/node-package.js +1 -1
  66. package/lib/javascript/node-project.js +1 -1
  67. package/lib/javascript/npm-config.js +1 -1
  68. package/lib/javascript/prettier.js +1 -1
  69. package/lib/javascript/projenrc.js +1 -1
  70. package/lib/javascript/typescript-config.js +1 -1
  71. package/lib/javascript/upgrade-dependencies.js +2 -2
  72. package/lib/json-patch.js +1 -1
  73. package/lib/json.js +1 -1
  74. package/lib/license.js +1 -1
  75. package/lib/logger.js +1 -1
  76. package/lib/makefile.js +1 -1
  77. package/lib/object-file.js +1 -1
  78. package/lib/project-build.js +1 -1
  79. package/lib/project.js +1 -1
  80. package/lib/projects.js +1 -1
  81. package/lib/projenrc-json.js +1 -1
  82. package/lib/python/pip.js +1 -1
  83. package/lib/python/poetry.js +2 -2
  84. package/lib/python/projenrc.js +1 -1
  85. package/lib/python/pytest-sample.js +1 -1
  86. package/lib/python/pytest.js +1 -1
  87. package/lib/python/python-project.js +1 -1
  88. package/lib/python/python-sample.js +1 -1
  89. package/lib/python/requirements-file.js +1 -1
  90. package/lib/python/setuppy.js +1 -1
  91. package/lib/python/setuptools.js +1 -1
  92. package/lib/python/venv.js +1 -1
  93. package/lib/readme.js +1 -1
  94. package/lib/release/publisher.js +1 -1
  95. package/lib/release/release-trigger.js +1 -1
  96. package/lib/release/release.js +1 -1
  97. package/lib/renovatebot.js +1 -1
  98. package/lib/run-task.js +0 -1833
  99. package/lib/sample-file.js +2 -2
  100. package/lib/semver.js +1 -1
  101. package/lib/source-code.js +1 -1
  102. package/lib/task-runtime.js +1 -1
  103. package/lib/task.js +1 -1
  104. package/lib/tasks.js +1 -1
  105. package/lib/testing.js +1 -1
  106. package/lib/textfile.js +1 -1
  107. package/lib/toml.js +1 -1
  108. package/lib/typescript/projenrc.js +1 -1
  109. package/lib/typescript/typescript-typedoc.js +1 -1
  110. package/lib/typescript/typescript.js +3 -3
  111. package/lib/version.js +1 -1
  112. package/lib/vscode/devcontainer.js +1 -1
  113. package/lib/vscode/extensions.js +1 -1
  114. package/lib/vscode/launch-config.js +1 -1
  115. package/lib/vscode/settings.js +1 -1
  116. package/lib/vscode/vscode.js +1 -1
  117. package/lib/web/next.js +3 -3
  118. package/lib/web/postcss.js +1 -1
  119. package/lib/web/react.js +4 -4
  120. package/lib/web/tailwind.js +1 -1
  121. package/lib/xmlfile.js +1 -1
  122. package/lib/yaml.js +1 -1
  123. package/package.json +1 -1
package/lib/run-task.js CHANGED
@@ -1,1836 +1,3 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJS = (cb, mod) => function __require() {
10
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
- };
12
- var __export = (target, all) => {
13
- for (var name in all)
14
- __defProp(target, name, { get: all[name], enumerable: true });
15
- };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // node_modules/color-name/index.js
31
- var require_color_name = __commonJS({
32
- "node_modules/color-name/index.js"(exports, module2) {
33
- "use strict";
34
- module2.exports = {
35
- "aliceblue": [240, 248, 255],
36
- "antiquewhite": [250, 235, 215],
37
- "aqua": [0, 255, 255],
38
- "aquamarine": [127, 255, 212],
39
- "azure": [240, 255, 255],
40
- "beige": [245, 245, 220],
41
- "bisque": [255, 228, 196],
42
- "black": [0, 0, 0],
43
- "blanchedalmond": [255, 235, 205],
44
- "blue": [0, 0, 255],
45
- "blueviolet": [138, 43, 226],
46
- "brown": [165, 42, 42],
47
- "burlywood": [222, 184, 135],
48
- "cadetblue": [95, 158, 160],
49
- "chartreuse": [127, 255, 0],
50
- "chocolate": [210, 105, 30],
51
- "coral": [255, 127, 80],
52
- "cornflowerblue": [100, 149, 237],
53
- "cornsilk": [255, 248, 220],
54
- "crimson": [220, 20, 60],
55
- "cyan": [0, 255, 255],
56
- "darkblue": [0, 0, 139],
57
- "darkcyan": [0, 139, 139],
58
- "darkgoldenrod": [184, 134, 11],
59
- "darkgray": [169, 169, 169],
60
- "darkgreen": [0, 100, 0],
61
- "darkgrey": [169, 169, 169],
62
- "darkkhaki": [189, 183, 107],
63
- "darkmagenta": [139, 0, 139],
64
- "darkolivegreen": [85, 107, 47],
65
- "darkorange": [255, 140, 0],
66
- "darkorchid": [153, 50, 204],
67
- "darkred": [139, 0, 0],
68
- "darksalmon": [233, 150, 122],
69
- "darkseagreen": [143, 188, 143],
70
- "darkslateblue": [72, 61, 139],
71
- "darkslategray": [47, 79, 79],
72
- "darkslategrey": [47, 79, 79],
73
- "darkturquoise": [0, 206, 209],
74
- "darkviolet": [148, 0, 211],
75
- "deeppink": [255, 20, 147],
76
- "deepskyblue": [0, 191, 255],
77
- "dimgray": [105, 105, 105],
78
- "dimgrey": [105, 105, 105],
79
- "dodgerblue": [30, 144, 255],
80
- "firebrick": [178, 34, 34],
81
- "floralwhite": [255, 250, 240],
82
- "forestgreen": [34, 139, 34],
83
- "fuchsia": [255, 0, 255],
84
- "gainsboro": [220, 220, 220],
85
- "ghostwhite": [248, 248, 255],
86
- "gold": [255, 215, 0],
87
- "goldenrod": [218, 165, 32],
88
- "gray": [128, 128, 128],
89
- "green": [0, 128, 0],
90
- "greenyellow": [173, 255, 47],
91
- "grey": [128, 128, 128],
92
- "honeydew": [240, 255, 240],
93
- "hotpink": [255, 105, 180],
94
- "indianred": [205, 92, 92],
95
- "indigo": [75, 0, 130],
96
- "ivory": [255, 255, 240],
97
- "khaki": [240, 230, 140],
98
- "lavender": [230, 230, 250],
99
- "lavenderblush": [255, 240, 245],
100
- "lawngreen": [124, 252, 0],
101
- "lemonchiffon": [255, 250, 205],
102
- "lightblue": [173, 216, 230],
103
- "lightcoral": [240, 128, 128],
104
- "lightcyan": [224, 255, 255],
105
- "lightgoldenrodyellow": [250, 250, 210],
106
- "lightgray": [211, 211, 211],
107
- "lightgreen": [144, 238, 144],
108
- "lightgrey": [211, 211, 211],
109
- "lightpink": [255, 182, 193],
110
- "lightsalmon": [255, 160, 122],
111
- "lightseagreen": [32, 178, 170],
112
- "lightskyblue": [135, 206, 250],
113
- "lightslategray": [119, 136, 153],
114
- "lightslategrey": [119, 136, 153],
115
- "lightsteelblue": [176, 196, 222],
116
- "lightyellow": [255, 255, 224],
117
- "lime": [0, 255, 0],
118
- "limegreen": [50, 205, 50],
119
- "linen": [250, 240, 230],
120
- "magenta": [255, 0, 255],
121
- "maroon": [128, 0, 0],
122
- "mediumaquamarine": [102, 205, 170],
123
- "mediumblue": [0, 0, 205],
124
- "mediumorchid": [186, 85, 211],
125
- "mediumpurple": [147, 112, 219],
126
- "mediumseagreen": [60, 179, 113],
127
- "mediumslateblue": [123, 104, 238],
128
- "mediumspringgreen": [0, 250, 154],
129
- "mediumturquoise": [72, 209, 204],
130
- "mediumvioletred": [199, 21, 133],
131
- "midnightblue": [25, 25, 112],
132
- "mintcream": [245, 255, 250],
133
- "mistyrose": [255, 228, 225],
134
- "moccasin": [255, 228, 181],
135
- "navajowhite": [255, 222, 173],
136
- "navy": [0, 0, 128],
137
- "oldlace": [253, 245, 230],
138
- "olive": [128, 128, 0],
139
- "olivedrab": [107, 142, 35],
140
- "orange": [255, 165, 0],
141
- "orangered": [255, 69, 0],
142
- "orchid": [218, 112, 214],
143
- "palegoldenrod": [238, 232, 170],
144
- "palegreen": [152, 251, 152],
145
- "paleturquoise": [175, 238, 238],
146
- "palevioletred": [219, 112, 147],
147
- "papayawhip": [255, 239, 213],
148
- "peachpuff": [255, 218, 185],
149
- "peru": [205, 133, 63],
150
- "pink": [255, 192, 203],
151
- "plum": [221, 160, 221],
152
- "powderblue": [176, 224, 230],
153
- "purple": [128, 0, 128],
154
- "rebeccapurple": [102, 51, 153],
155
- "red": [255, 0, 0],
156
- "rosybrown": [188, 143, 143],
157
- "royalblue": [65, 105, 225],
158
- "saddlebrown": [139, 69, 19],
159
- "salmon": [250, 128, 114],
160
- "sandybrown": [244, 164, 96],
161
- "seagreen": [46, 139, 87],
162
- "seashell": [255, 245, 238],
163
- "sienna": [160, 82, 45],
164
- "silver": [192, 192, 192],
165
- "skyblue": [135, 206, 235],
166
- "slateblue": [106, 90, 205],
167
- "slategray": [112, 128, 144],
168
- "slategrey": [112, 128, 144],
169
- "snow": [255, 250, 250],
170
- "springgreen": [0, 255, 127],
171
- "steelblue": [70, 130, 180],
172
- "tan": [210, 180, 140],
173
- "teal": [0, 128, 128],
174
- "thistle": [216, 191, 216],
175
- "tomato": [255, 99, 71],
176
- "turquoise": [64, 224, 208],
177
- "violet": [238, 130, 238],
178
- "wheat": [245, 222, 179],
179
- "white": [255, 255, 255],
180
- "whitesmoke": [245, 245, 245],
181
- "yellow": [255, 255, 0],
182
- "yellowgreen": [154, 205, 50]
183
- };
184
- }
185
- });
186
-
187
- // node_modules/color-convert/conversions.js
188
- var require_conversions = __commonJS({
189
- "node_modules/color-convert/conversions.js"(exports, module2) {
190
- var cssKeywords = require_color_name();
191
- var reverseKeywords = {};
192
- for (const key of Object.keys(cssKeywords)) {
193
- reverseKeywords[cssKeywords[key]] = key;
194
- }
195
- var convert = {
196
- rgb: { channels: 3, labels: "rgb" },
197
- hsl: { channels: 3, labels: "hsl" },
198
- hsv: { channels: 3, labels: "hsv" },
199
- hwb: { channels: 3, labels: "hwb" },
200
- cmyk: { channels: 4, labels: "cmyk" },
201
- xyz: { channels: 3, labels: "xyz" },
202
- lab: { channels: 3, labels: "lab" },
203
- lch: { channels: 3, labels: "lch" },
204
- hex: { channels: 1, labels: ["hex"] },
205
- keyword: { channels: 1, labels: ["keyword"] },
206
- ansi16: { channels: 1, labels: ["ansi16"] },
207
- ansi256: { channels: 1, labels: ["ansi256"] },
208
- hcg: { channels: 3, labels: ["h", "c", "g"] },
209
- apple: { channels: 3, labels: ["r16", "g16", "b16"] },
210
- gray: { channels: 1, labels: ["gray"] }
211
- };
212
- module2.exports = convert;
213
- for (const model of Object.keys(convert)) {
214
- if (!("channels" in convert[model])) {
215
- throw new Error("missing channels property: " + model);
216
- }
217
- if (!("labels" in convert[model])) {
218
- throw new Error("missing channel labels property: " + model);
219
- }
220
- if (convert[model].labels.length !== convert[model].channels) {
221
- throw new Error("channel and label counts mismatch: " + model);
222
- }
223
- const { channels, labels } = convert[model];
224
- delete convert[model].channels;
225
- delete convert[model].labels;
226
- Object.defineProperty(convert[model], "channels", { value: channels });
227
- Object.defineProperty(convert[model], "labels", { value: labels });
228
- }
229
- convert.rgb.hsl = function(rgb) {
230
- const r = rgb[0] / 255;
231
- const g = rgb[1] / 255;
232
- const b = rgb[2] / 255;
233
- const min = Math.min(r, g, b);
234
- const max = Math.max(r, g, b);
235
- const delta = max - min;
236
- let h;
237
- let s;
238
- if (max === min) {
239
- h = 0;
240
- } else if (r === max) {
241
- h = (g - b) / delta;
242
- } else if (g === max) {
243
- h = 2 + (b - r) / delta;
244
- } else if (b === max) {
245
- h = 4 + (r - g) / delta;
246
- }
247
- h = Math.min(h * 60, 360);
248
- if (h < 0) {
249
- h += 360;
250
- }
251
- const l = (min + max) / 2;
252
- if (max === min) {
253
- s = 0;
254
- } else if (l <= 0.5) {
255
- s = delta / (max + min);
256
- } else {
257
- s = delta / (2 - max - min);
258
- }
259
- return [h, s * 100, l * 100];
260
- };
261
- convert.rgb.hsv = function(rgb) {
262
- let rdif;
263
- let gdif;
264
- let bdif;
265
- let h;
266
- let s;
267
- const r = rgb[0] / 255;
268
- const g = rgb[1] / 255;
269
- const b = rgb[2] / 255;
270
- const v = Math.max(r, g, b);
271
- const diff = v - Math.min(r, g, b);
272
- const diffc = function(c) {
273
- return (v - c) / 6 / diff + 1 / 2;
274
- };
275
- if (diff === 0) {
276
- h = 0;
277
- s = 0;
278
- } else {
279
- s = diff / v;
280
- rdif = diffc(r);
281
- gdif = diffc(g);
282
- bdif = diffc(b);
283
- if (r === v) {
284
- h = bdif - gdif;
285
- } else if (g === v) {
286
- h = 1 / 3 + rdif - bdif;
287
- } else if (b === v) {
288
- h = 2 / 3 + gdif - rdif;
289
- }
290
- if (h < 0) {
291
- h += 1;
292
- } else if (h > 1) {
293
- h -= 1;
294
- }
295
- }
296
- return [
297
- h * 360,
298
- s * 100,
299
- v * 100
300
- ];
301
- };
302
- convert.rgb.hwb = function(rgb) {
303
- const r = rgb[0];
304
- const g = rgb[1];
305
- let b = rgb[2];
306
- const h = convert.rgb.hsl(rgb)[0];
307
- const w = 1 / 255 * Math.min(r, Math.min(g, b));
308
- b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
309
- return [h, w * 100, b * 100];
310
- };
311
- convert.rgb.cmyk = function(rgb) {
312
- const r = rgb[0] / 255;
313
- const g = rgb[1] / 255;
314
- const b = rgb[2] / 255;
315
- const k = Math.min(1 - r, 1 - g, 1 - b);
316
- const c = (1 - r - k) / (1 - k) || 0;
317
- const m = (1 - g - k) / (1 - k) || 0;
318
- const y = (1 - b - k) / (1 - k) || 0;
319
- return [c * 100, m * 100, y * 100, k * 100];
320
- };
321
- function comparativeDistance(x, y) {
322
- return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
323
- }
324
- convert.rgb.keyword = function(rgb) {
325
- const reversed = reverseKeywords[rgb];
326
- if (reversed) {
327
- return reversed;
328
- }
329
- let currentClosestDistance = Infinity;
330
- let currentClosestKeyword;
331
- for (const keyword of Object.keys(cssKeywords)) {
332
- const value = cssKeywords[keyword];
333
- const distance = comparativeDistance(rgb, value);
334
- if (distance < currentClosestDistance) {
335
- currentClosestDistance = distance;
336
- currentClosestKeyword = keyword;
337
- }
338
- }
339
- return currentClosestKeyword;
340
- };
341
- convert.keyword.rgb = function(keyword) {
342
- return cssKeywords[keyword];
343
- };
344
- convert.rgb.xyz = function(rgb) {
345
- let r = rgb[0] / 255;
346
- let g = rgb[1] / 255;
347
- let b = rgb[2] / 255;
348
- r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
349
- g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
350
- b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
351
- const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
352
- const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
353
- const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
354
- return [x * 100, y * 100, z * 100];
355
- };
356
- convert.rgb.lab = function(rgb) {
357
- const xyz = convert.rgb.xyz(rgb);
358
- let x = xyz[0];
359
- let y = xyz[1];
360
- let z = xyz[2];
361
- x /= 95.047;
362
- y /= 100;
363
- z /= 108.883;
364
- x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
365
- y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
366
- z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
367
- const l = 116 * y - 16;
368
- const a = 500 * (x - y);
369
- const b = 200 * (y - z);
370
- return [l, a, b];
371
- };
372
- convert.hsl.rgb = function(hsl) {
373
- const h = hsl[0] / 360;
374
- const s = hsl[1] / 100;
375
- const l = hsl[2] / 100;
376
- let t2;
377
- let t3;
378
- let val;
379
- if (s === 0) {
380
- val = l * 255;
381
- return [val, val, val];
382
- }
383
- if (l < 0.5) {
384
- t2 = l * (1 + s);
385
- } else {
386
- t2 = l + s - l * s;
387
- }
388
- const t1 = 2 * l - t2;
389
- const rgb = [0, 0, 0];
390
- for (let i = 0; i < 3; i++) {
391
- t3 = h + 1 / 3 * -(i - 1);
392
- if (t3 < 0) {
393
- t3++;
394
- }
395
- if (t3 > 1) {
396
- t3--;
397
- }
398
- if (6 * t3 < 1) {
399
- val = t1 + (t2 - t1) * 6 * t3;
400
- } else if (2 * t3 < 1) {
401
- val = t2;
402
- } else if (3 * t3 < 2) {
403
- val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
404
- } else {
405
- val = t1;
406
- }
407
- rgb[i] = val * 255;
408
- }
409
- return rgb;
410
- };
411
- convert.hsl.hsv = function(hsl) {
412
- const h = hsl[0];
413
- let s = hsl[1] / 100;
414
- let l = hsl[2] / 100;
415
- let smin = s;
416
- const lmin = Math.max(l, 0.01);
417
- l *= 2;
418
- s *= l <= 1 ? l : 2 - l;
419
- smin *= lmin <= 1 ? lmin : 2 - lmin;
420
- const v = (l + s) / 2;
421
- const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
422
- return [h, sv * 100, v * 100];
423
- };
424
- convert.hsv.rgb = function(hsv) {
425
- const h = hsv[0] / 60;
426
- const s = hsv[1] / 100;
427
- let v = hsv[2] / 100;
428
- const hi = Math.floor(h) % 6;
429
- const f = h - Math.floor(h);
430
- const p = 255 * v * (1 - s);
431
- const q = 255 * v * (1 - s * f);
432
- const t = 255 * v * (1 - s * (1 - f));
433
- v *= 255;
434
- switch (hi) {
435
- case 0:
436
- return [v, t, p];
437
- case 1:
438
- return [q, v, p];
439
- case 2:
440
- return [p, v, t];
441
- case 3:
442
- return [p, q, v];
443
- case 4:
444
- return [t, p, v];
445
- case 5:
446
- return [v, p, q];
447
- }
448
- };
449
- convert.hsv.hsl = function(hsv) {
450
- const h = hsv[0];
451
- const s = hsv[1] / 100;
452
- const v = hsv[2] / 100;
453
- const vmin = Math.max(v, 0.01);
454
- let sl;
455
- let l;
456
- l = (2 - s) * v;
457
- const lmin = (2 - s) * vmin;
458
- sl = s * vmin;
459
- sl /= lmin <= 1 ? lmin : 2 - lmin;
460
- sl = sl || 0;
461
- l /= 2;
462
- return [h, sl * 100, l * 100];
463
- };
464
- convert.hwb.rgb = function(hwb) {
465
- const h = hwb[0] / 360;
466
- let wh = hwb[1] / 100;
467
- let bl = hwb[2] / 100;
468
- const ratio = wh + bl;
469
- let f;
470
- if (ratio > 1) {
471
- wh /= ratio;
472
- bl /= ratio;
473
- }
474
- const i = Math.floor(6 * h);
475
- const v = 1 - bl;
476
- f = 6 * h - i;
477
- if ((i & 1) !== 0) {
478
- f = 1 - f;
479
- }
480
- const n = wh + f * (v - wh);
481
- let r;
482
- let g;
483
- let b;
484
- switch (i) {
485
- default:
486
- case 6:
487
- case 0:
488
- r = v;
489
- g = n;
490
- b = wh;
491
- break;
492
- case 1:
493
- r = n;
494
- g = v;
495
- b = wh;
496
- break;
497
- case 2:
498
- r = wh;
499
- g = v;
500
- b = n;
501
- break;
502
- case 3:
503
- r = wh;
504
- g = n;
505
- b = v;
506
- break;
507
- case 4:
508
- r = n;
509
- g = wh;
510
- b = v;
511
- break;
512
- case 5:
513
- r = v;
514
- g = wh;
515
- b = n;
516
- break;
517
- }
518
- return [r * 255, g * 255, b * 255];
519
- };
520
- convert.cmyk.rgb = function(cmyk) {
521
- const c = cmyk[0] / 100;
522
- const m = cmyk[1] / 100;
523
- const y = cmyk[2] / 100;
524
- const k = cmyk[3] / 100;
525
- const r = 1 - Math.min(1, c * (1 - k) + k);
526
- const g = 1 - Math.min(1, m * (1 - k) + k);
527
- const b = 1 - Math.min(1, y * (1 - k) + k);
528
- return [r * 255, g * 255, b * 255];
529
- };
530
- convert.xyz.rgb = function(xyz) {
531
- const x = xyz[0] / 100;
532
- const y = xyz[1] / 100;
533
- const z = xyz[2] / 100;
534
- let r;
535
- let g;
536
- let b;
537
- r = x * 3.2406 + y * -1.5372 + z * -0.4986;
538
- g = x * -0.9689 + y * 1.8758 + z * 0.0415;
539
- b = x * 0.0557 + y * -0.204 + z * 1.057;
540
- r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
541
- g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
542
- b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
543
- r = Math.min(Math.max(0, r), 1);
544
- g = Math.min(Math.max(0, g), 1);
545
- b = Math.min(Math.max(0, b), 1);
546
- return [r * 255, g * 255, b * 255];
547
- };
548
- convert.xyz.lab = function(xyz) {
549
- let x = xyz[0];
550
- let y = xyz[1];
551
- let z = xyz[2];
552
- x /= 95.047;
553
- y /= 100;
554
- z /= 108.883;
555
- x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
556
- y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
557
- z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
558
- const l = 116 * y - 16;
559
- const a = 500 * (x - y);
560
- const b = 200 * (y - z);
561
- return [l, a, b];
562
- };
563
- convert.lab.xyz = function(lab) {
564
- const l = lab[0];
565
- const a = lab[1];
566
- const b = lab[2];
567
- let x;
568
- let y;
569
- let z;
570
- y = (l + 16) / 116;
571
- x = a / 500 + y;
572
- z = y - b / 200;
573
- const y2 = y ** 3;
574
- const x2 = x ** 3;
575
- const z2 = z ** 3;
576
- y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
577
- x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
578
- z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
579
- x *= 95.047;
580
- y *= 100;
581
- z *= 108.883;
582
- return [x, y, z];
583
- };
584
- convert.lab.lch = function(lab) {
585
- const l = lab[0];
586
- const a = lab[1];
587
- const b = lab[2];
588
- let h;
589
- const hr = Math.atan2(b, a);
590
- h = hr * 360 / 2 / Math.PI;
591
- if (h < 0) {
592
- h += 360;
593
- }
594
- const c = Math.sqrt(a * a + b * b);
595
- return [l, c, h];
596
- };
597
- convert.lch.lab = function(lch) {
598
- const l = lch[0];
599
- const c = lch[1];
600
- const h = lch[2];
601
- const hr = h / 360 * 2 * Math.PI;
602
- const a = c * Math.cos(hr);
603
- const b = c * Math.sin(hr);
604
- return [l, a, b];
605
- };
606
- convert.rgb.ansi16 = function(args, saturation = null) {
607
- const [r, g, b] = args;
608
- let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
609
- value = Math.round(value / 50);
610
- if (value === 0) {
611
- return 30;
612
- }
613
- let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
614
- if (value === 2) {
615
- ansi += 60;
616
- }
617
- return ansi;
618
- };
619
- convert.hsv.ansi16 = function(args) {
620
- return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
621
- };
622
- convert.rgb.ansi256 = function(args) {
623
- const r = args[0];
624
- const g = args[1];
625
- const b = args[2];
626
- if (r === g && g === b) {
627
- if (r < 8) {
628
- return 16;
629
- }
630
- if (r > 248) {
631
- return 231;
632
- }
633
- return Math.round((r - 8) / 247 * 24) + 232;
634
- }
635
- const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
636
- return ansi;
637
- };
638
- convert.ansi16.rgb = function(args) {
639
- let color = args % 10;
640
- if (color === 0 || color === 7) {
641
- if (args > 50) {
642
- color += 3.5;
643
- }
644
- color = color / 10.5 * 255;
645
- return [color, color, color];
646
- }
647
- const mult = (~~(args > 50) + 1) * 0.5;
648
- const r = (color & 1) * mult * 255;
649
- const g = (color >> 1 & 1) * mult * 255;
650
- const b = (color >> 2 & 1) * mult * 255;
651
- return [r, g, b];
652
- };
653
- convert.ansi256.rgb = function(args) {
654
- if (args >= 232) {
655
- const c = (args - 232) * 10 + 8;
656
- return [c, c, c];
657
- }
658
- args -= 16;
659
- let rem;
660
- const r = Math.floor(args / 36) / 5 * 255;
661
- const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
662
- const b = rem % 6 / 5 * 255;
663
- return [r, g, b];
664
- };
665
- convert.rgb.hex = function(args) {
666
- const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
667
- const string = integer.toString(16).toUpperCase();
668
- return "000000".substring(string.length) + string;
669
- };
670
- convert.hex.rgb = function(args) {
671
- const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
672
- if (!match) {
673
- return [0, 0, 0];
674
- }
675
- let colorString = match[0];
676
- if (match[0].length === 3) {
677
- colorString = colorString.split("").map((char) => {
678
- return char + char;
679
- }).join("");
680
- }
681
- const integer = parseInt(colorString, 16);
682
- const r = integer >> 16 & 255;
683
- const g = integer >> 8 & 255;
684
- const b = integer & 255;
685
- return [r, g, b];
686
- };
687
- convert.rgb.hcg = function(rgb) {
688
- const r = rgb[0] / 255;
689
- const g = rgb[1] / 255;
690
- const b = rgb[2] / 255;
691
- const max = Math.max(Math.max(r, g), b);
692
- const min = Math.min(Math.min(r, g), b);
693
- const chroma = max - min;
694
- let grayscale;
695
- let hue;
696
- if (chroma < 1) {
697
- grayscale = min / (1 - chroma);
698
- } else {
699
- grayscale = 0;
700
- }
701
- if (chroma <= 0) {
702
- hue = 0;
703
- } else if (max === r) {
704
- hue = (g - b) / chroma % 6;
705
- } else if (max === g) {
706
- hue = 2 + (b - r) / chroma;
707
- } else {
708
- hue = 4 + (r - g) / chroma;
709
- }
710
- hue /= 6;
711
- hue %= 1;
712
- return [hue * 360, chroma * 100, grayscale * 100];
713
- };
714
- convert.hsl.hcg = function(hsl) {
715
- const s = hsl[1] / 100;
716
- const l = hsl[2] / 100;
717
- const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
718
- let f = 0;
719
- if (c < 1) {
720
- f = (l - 0.5 * c) / (1 - c);
721
- }
722
- return [hsl[0], c * 100, f * 100];
723
- };
724
- convert.hsv.hcg = function(hsv) {
725
- const s = hsv[1] / 100;
726
- const v = hsv[2] / 100;
727
- const c = s * v;
728
- let f = 0;
729
- if (c < 1) {
730
- f = (v - c) / (1 - c);
731
- }
732
- return [hsv[0], c * 100, f * 100];
733
- };
734
- convert.hcg.rgb = function(hcg) {
735
- const h = hcg[0] / 360;
736
- const c = hcg[1] / 100;
737
- const g = hcg[2] / 100;
738
- if (c === 0) {
739
- return [g * 255, g * 255, g * 255];
740
- }
741
- const pure = [0, 0, 0];
742
- const hi = h % 1 * 6;
743
- const v = hi % 1;
744
- const w = 1 - v;
745
- let mg = 0;
746
- switch (Math.floor(hi)) {
747
- case 0:
748
- pure[0] = 1;
749
- pure[1] = v;
750
- pure[2] = 0;
751
- break;
752
- case 1:
753
- pure[0] = w;
754
- pure[1] = 1;
755
- pure[2] = 0;
756
- break;
757
- case 2:
758
- pure[0] = 0;
759
- pure[1] = 1;
760
- pure[2] = v;
761
- break;
762
- case 3:
763
- pure[0] = 0;
764
- pure[1] = w;
765
- pure[2] = 1;
766
- break;
767
- case 4:
768
- pure[0] = v;
769
- pure[1] = 0;
770
- pure[2] = 1;
771
- break;
772
- default:
773
- pure[0] = 1;
774
- pure[1] = 0;
775
- pure[2] = w;
776
- }
777
- mg = (1 - c) * g;
778
- return [
779
- (c * pure[0] + mg) * 255,
780
- (c * pure[1] + mg) * 255,
781
- (c * pure[2] + mg) * 255
782
- ];
783
- };
784
- convert.hcg.hsv = function(hcg) {
785
- const c = hcg[1] / 100;
786
- const g = hcg[2] / 100;
787
- const v = c + g * (1 - c);
788
- let f = 0;
789
- if (v > 0) {
790
- f = c / v;
791
- }
792
- return [hcg[0], f * 100, v * 100];
793
- };
794
- convert.hcg.hsl = function(hcg) {
795
- const c = hcg[1] / 100;
796
- const g = hcg[2] / 100;
797
- const l = g * (1 - c) + 0.5 * c;
798
- let s = 0;
799
- if (l > 0 && l < 0.5) {
800
- s = c / (2 * l);
801
- } else if (l >= 0.5 && l < 1) {
802
- s = c / (2 * (1 - l));
803
- }
804
- return [hcg[0], s * 100, l * 100];
805
- };
806
- convert.hcg.hwb = function(hcg) {
807
- const c = hcg[1] / 100;
808
- const g = hcg[2] / 100;
809
- const v = c + g * (1 - c);
810
- return [hcg[0], (v - c) * 100, (1 - v) * 100];
811
- };
812
- convert.hwb.hcg = function(hwb) {
813
- const w = hwb[1] / 100;
814
- const b = hwb[2] / 100;
815
- const v = 1 - b;
816
- const c = v - w;
817
- let g = 0;
818
- if (c < 1) {
819
- g = (v - c) / (1 - c);
820
- }
821
- return [hwb[0], c * 100, g * 100];
822
- };
823
- convert.apple.rgb = function(apple) {
824
- return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
825
- };
826
- convert.rgb.apple = function(rgb) {
827
- return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
828
- };
829
- convert.gray.rgb = function(args) {
830
- return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
831
- };
832
- convert.gray.hsl = function(args) {
833
- return [0, 0, args[0]];
834
- };
835
- convert.gray.hsv = convert.gray.hsl;
836
- convert.gray.hwb = function(gray3) {
837
- return [0, 100, gray3[0]];
838
- };
839
- convert.gray.cmyk = function(gray3) {
840
- return [0, 0, 0, gray3[0]];
841
- };
842
- convert.gray.lab = function(gray3) {
843
- return [gray3[0], 0, 0];
844
- };
845
- convert.gray.hex = function(gray3) {
846
- const val = Math.round(gray3[0] / 100 * 255) & 255;
847
- const integer = (val << 16) + (val << 8) + val;
848
- const string = integer.toString(16).toUpperCase();
849
- return "000000".substring(string.length) + string;
850
- };
851
- convert.rgb.gray = function(rgb) {
852
- const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
853
- return [val / 255 * 100];
854
- };
855
- }
856
- });
857
-
858
- // node_modules/color-convert/route.js
859
- var require_route = __commonJS({
860
- "node_modules/color-convert/route.js"(exports, module2) {
861
- var conversions = require_conversions();
862
- function buildGraph() {
863
- const graph = {};
864
- const models = Object.keys(conversions);
865
- for (let len = models.length, i = 0; i < len; i++) {
866
- graph[models[i]] = {
867
- distance: -1,
868
- parent: null
869
- };
870
- }
871
- return graph;
872
- }
873
- function deriveBFS(fromModel) {
874
- const graph = buildGraph();
875
- const queue = [fromModel];
876
- graph[fromModel].distance = 0;
877
- while (queue.length) {
878
- const current = queue.pop();
879
- const adjacents = Object.keys(conversions[current]);
880
- for (let len = adjacents.length, i = 0; i < len; i++) {
881
- const adjacent = adjacents[i];
882
- const node = graph[adjacent];
883
- if (node.distance === -1) {
884
- node.distance = graph[current].distance + 1;
885
- node.parent = current;
886
- queue.unshift(adjacent);
887
- }
888
- }
889
- }
890
- return graph;
891
- }
892
- function link(from, to) {
893
- return function(args) {
894
- return to(from(args));
895
- };
896
- }
897
- function wrapConversion(toModel, graph) {
898
- const path2 = [graph[toModel].parent, toModel];
899
- let fn = conversions[graph[toModel].parent][toModel];
900
- let cur = graph[toModel].parent;
901
- while (graph[cur].parent) {
902
- path2.unshift(graph[cur].parent);
903
- fn = link(conversions[graph[cur].parent][cur], fn);
904
- cur = graph[cur].parent;
905
- }
906
- fn.conversion = path2;
907
- return fn;
908
- }
909
- module2.exports = function(fromModel) {
910
- const graph = deriveBFS(fromModel);
911
- const conversion = {};
912
- const models = Object.keys(graph);
913
- for (let len = models.length, i = 0; i < len; i++) {
914
- const toModel = models[i];
915
- const node = graph[toModel];
916
- if (node.parent === null) {
917
- continue;
918
- }
919
- conversion[toModel] = wrapConversion(toModel, graph);
920
- }
921
- return conversion;
922
- };
923
- }
924
- });
925
-
926
- // node_modules/color-convert/index.js
927
- var require_color_convert = __commonJS({
928
- "node_modules/color-convert/index.js"(exports, module2) {
929
- var conversions = require_conversions();
930
- var route = require_route();
931
- var convert = {};
932
- var models = Object.keys(conversions);
933
- function wrapRaw(fn) {
934
- const wrappedFn = function(...args) {
935
- const arg0 = args[0];
936
- if (arg0 === void 0 || arg0 === null) {
937
- return arg0;
938
- }
939
- if (arg0.length > 1) {
940
- args = arg0;
941
- }
942
- return fn(args);
943
- };
944
- if ("conversion" in fn) {
945
- wrappedFn.conversion = fn.conversion;
946
- }
947
- return wrappedFn;
948
- }
949
- function wrapRounded(fn) {
950
- const wrappedFn = function(...args) {
951
- const arg0 = args[0];
952
- if (arg0 === void 0 || arg0 === null) {
953
- return arg0;
954
- }
955
- if (arg0.length > 1) {
956
- args = arg0;
957
- }
958
- const result = fn(args);
959
- if (typeof result === "object") {
960
- for (let len = result.length, i = 0; i < len; i++) {
961
- result[i] = Math.round(result[i]);
962
- }
963
- }
964
- return result;
965
- };
966
- if ("conversion" in fn) {
967
- wrappedFn.conversion = fn.conversion;
968
- }
969
- return wrappedFn;
970
- }
971
- models.forEach((fromModel) => {
972
- convert[fromModel] = {};
973
- Object.defineProperty(convert[fromModel], "channels", { value: conversions[fromModel].channels });
974
- Object.defineProperty(convert[fromModel], "labels", { value: conversions[fromModel].labels });
975
- const routes = route(fromModel);
976
- const routeModels = Object.keys(routes);
977
- routeModels.forEach((toModel) => {
978
- const fn = routes[toModel];
979
- convert[fromModel][toModel] = wrapRounded(fn);
980
- convert[fromModel][toModel].raw = wrapRaw(fn);
981
- });
982
- });
983
- module2.exports = convert;
984
- }
985
- });
986
-
987
- // node_modules/ansi-styles/index.js
988
- var require_ansi_styles = __commonJS({
989
- "node_modules/ansi-styles/index.js"(exports, module2) {
990
- "use strict";
991
- var wrapAnsi16 = (fn, offset) => (...args) => {
992
- const code = fn(...args);
993
- return `\x1B[${code + offset}m`;
994
- };
995
- var wrapAnsi256 = (fn, offset) => (...args) => {
996
- const code = fn(...args);
997
- return `\x1B[${38 + offset};5;${code}m`;
998
- };
999
- var wrapAnsi16m = (fn, offset) => (...args) => {
1000
- const rgb = fn(...args);
1001
- return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
1002
- };
1003
- var ansi2ansi = (n) => n;
1004
- var rgb2rgb = (r, g, b) => [r, g, b];
1005
- var setLazyProperty = (object, property, get) => {
1006
- Object.defineProperty(object, property, {
1007
- get: () => {
1008
- const value = get();
1009
- Object.defineProperty(object, property, {
1010
- value,
1011
- enumerable: true,
1012
- configurable: true
1013
- });
1014
- return value;
1015
- },
1016
- enumerable: true,
1017
- configurable: true
1018
- });
1019
- };
1020
- var colorConvert;
1021
- var makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
1022
- if (colorConvert === void 0) {
1023
- colorConvert = require_color_convert();
1024
- }
1025
- const offset = isBackground ? 10 : 0;
1026
- const styles = {};
1027
- for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
1028
- const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
1029
- if (sourceSpace === targetSpace) {
1030
- styles[name] = wrap(identity, offset);
1031
- } else if (typeof suite === "object") {
1032
- styles[name] = wrap(suite[targetSpace], offset);
1033
- }
1034
- }
1035
- return styles;
1036
- };
1037
- function assembleStyles() {
1038
- const codes = /* @__PURE__ */ new Map();
1039
- const styles = {
1040
- modifier: {
1041
- reset: [0, 0],
1042
- bold: [1, 22],
1043
- dim: [2, 22],
1044
- italic: [3, 23],
1045
- underline: [4, 24],
1046
- inverse: [7, 27],
1047
- hidden: [8, 28],
1048
- strikethrough: [9, 29]
1049
- },
1050
- color: {
1051
- black: [30, 39],
1052
- red: [31, 39],
1053
- green: [32, 39],
1054
- yellow: [33, 39],
1055
- blue: [34, 39],
1056
- magenta: [35, 39],
1057
- cyan: [36, 39],
1058
- white: [37, 39],
1059
- blackBright: [90, 39],
1060
- redBright: [91, 39],
1061
- greenBright: [92, 39],
1062
- yellowBright: [93, 39],
1063
- blueBright: [94, 39],
1064
- magentaBright: [95, 39],
1065
- cyanBright: [96, 39],
1066
- whiteBright: [97, 39]
1067
- },
1068
- bgColor: {
1069
- bgBlack: [40, 49],
1070
- bgRed: [41, 49],
1071
- bgGreen: [42, 49],
1072
- bgYellow: [43, 49],
1073
- bgBlue: [44, 49],
1074
- bgMagenta: [45, 49],
1075
- bgCyan: [46, 49],
1076
- bgWhite: [47, 49],
1077
- bgBlackBright: [100, 49],
1078
- bgRedBright: [101, 49],
1079
- bgGreenBright: [102, 49],
1080
- bgYellowBright: [103, 49],
1081
- bgBlueBright: [104, 49],
1082
- bgMagentaBright: [105, 49],
1083
- bgCyanBright: [106, 49],
1084
- bgWhiteBright: [107, 49]
1085
- }
1086
- };
1087
- styles.color.gray = styles.color.blackBright;
1088
- styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
1089
- styles.color.grey = styles.color.blackBright;
1090
- styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
1091
- for (const [groupName, group] of Object.entries(styles)) {
1092
- for (const [styleName, style] of Object.entries(group)) {
1093
- styles[styleName] = {
1094
- open: `\x1B[${style[0]}m`,
1095
- close: `\x1B[${style[1]}m`
1096
- };
1097
- group[styleName] = styles[styleName];
1098
- codes.set(style[0], style[1]);
1099
- }
1100
- Object.defineProperty(styles, groupName, {
1101
- value: group,
1102
- enumerable: false
1103
- });
1104
- }
1105
- Object.defineProperty(styles, "codes", {
1106
- value: codes,
1107
- enumerable: false
1108
- });
1109
- styles.color.close = "\x1B[39m";
1110
- styles.bgColor.close = "\x1B[49m";
1111
- setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
1112
- setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
1113
- setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
1114
- setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
1115
- setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
1116
- setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
1117
- return styles;
1118
- }
1119
- Object.defineProperty(module2, "exports", {
1120
- enumerable: true,
1121
- get: assembleStyles
1122
- });
1123
- }
1124
- });
1125
-
1126
- // node_modules/has-flag/index.js
1127
- var require_has_flag = __commonJS({
1128
- "node_modules/has-flag/index.js"(exports, module2) {
1129
- "use strict";
1130
- module2.exports = (flag, argv = process.argv) => {
1131
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
1132
- const position = argv.indexOf(prefix + flag);
1133
- const terminatorPosition = argv.indexOf("--");
1134
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
1135
- };
1136
- }
1137
- });
1138
-
1139
- // node_modules/supports-color/index.js
1140
- var require_supports_color = __commonJS({
1141
- "node_modules/supports-color/index.js"(exports, module2) {
1142
- "use strict";
1143
- var os = require("os");
1144
- var tty = require("tty");
1145
- var hasFlag = require_has_flag();
1146
- var { env } = process;
1147
- var forceColor;
1148
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
1149
- forceColor = 0;
1150
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
1151
- forceColor = 1;
1152
- }
1153
- if ("FORCE_COLOR" in env) {
1154
- if (env.FORCE_COLOR === "true") {
1155
- forceColor = 1;
1156
- } else if (env.FORCE_COLOR === "false") {
1157
- forceColor = 0;
1158
- } else {
1159
- forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
1160
- }
1161
- }
1162
- function translateLevel(level) {
1163
- if (level === 0) {
1164
- return false;
1165
- }
1166
- return {
1167
- level,
1168
- hasBasic: true,
1169
- has256: level >= 2,
1170
- has16m: level >= 3
1171
- };
1172
- }
1173
- function supportsColor(haveStream, streamIsTTY) {
1174
- if (forceColor === 0) {
1175
- return 0;
1176
- }
1177
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
1178
- return 3;
1179
- }
1180
- if (hasFlag("color=256")) {
1181
- return 2;
1182
- }
1183
- if (haveStream && !streamIsTTY && forceColor === void 0) {
1184
- return 0;
1185
- }
1186
- const min = forceColor || 0;
1187
- if (env.TERM === "dumb") {
1188
- return min;
1189
- }
1190
- if (process.platform === "win32") {
1191
- const osRelease = os.release().split(".");
1192
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
1193
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
1194
- }
1195
- return 1;
1196
- }
1197
- if ("CI" in env) {
1198
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
1199
- return 1;
1200
- }
1201
- return min;
1202
- }
1203
- if ("TEAMCITY_VERSION" in env) {
1204
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1205
- }
1206
- if (env.COLORTERM === "truecolor") {
1207
- return 3;
1208
- }
1209
- if ("TERM_PROGRAM" in env) {
1210
- const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
1211
- switch (env.TERM_PROGRAM) {
1212
- case "iTerm.app":
1213
- return version >= 3 ? 3 : 2;
1214
- case "Apple_Terminal":
1215
- return 2;
1216
- }
1217
- }
1218
- if (/-256(color)?$/i.test(env.TERM)) {
1219
- return 2;
1220
- }
1221
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
1222
- return 1;
1223
- }
1224
- if ("COLORTERM" in env) {
1225
- return 1;
1226
- }
1227
- return min;
1228
- }
1229
- function getSupportLevel(stream) {
1230
- const level = supportsColor(stream, stream && stream.isTTY);
1231
- return translateLevel(level);
1232
- }
1233
- module2.exports = {
1234
- supportsColor: getSupportLevel,
1235
- stdout: translateLevel(supportsColor(true, tty.isatty(1))),
1236
- stderr: translateLevel(supportsColor(true, tty.isatty(2)))
1237
- };
1238
- }
1239
- });
1240
-
1241
- // node_modules/chalk/source/util.js
1242
- var require_util = __commonJS({
1243
- "node_modules/chalk/source/util.js"(exports, module2) {
1244
- "use strict";
1245
- var stringReplaceAll = (string, substring, replacer) => {
1246
- let index = string.indexOf(substring);
1247
- if (index === -1) {
1248
- return string;
1249
- }
1250
- const substringLength = substring.length;
1251
- let endIndex = 0;
1252
- let returnValue = "";
1253
- do {
1254
- returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
1255
- endIndex = index + substringLength;
1256
- index = string.indexOf(substring, endIndex);
1257
- } while (index !== -1);
1258
- returnValue += string.substr(endIndex);
1259
- return returnValue;
1260
- };
1261
- var stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
1262
- let endIndex = 0;
1263
- let returnValue = "";
1264
- do {
1265
- const gotCR = string[index - 1] === "\r";
1266
- returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
1267
- endIndex = index + 1;
1268
- index = string.indexOf("\n", endIndex);
1269
- } while (index !== -1);
1270
- returnValue += string.substr(endIndex);
1271
- return returnValue;
1272
- };
1273
- module2.exports = {
1274
- stringReplaceAll,
1275
- stringEncaseCRLFWithFirstIndex
1276
- };
1277
- }
1278
- });
1279
-
1280
- // node_modules/chalk/source/templates.js
1281
- var require_templates = __commonJS({
1282
- "node_modules/chalk/source/templates.js"(exports, module2) {
1283
- "use strict";
1284
- var TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
1285
- var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
1286
- var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
1287
- var ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
1288
- var ESCAPES = /* @__PURE__ */ new Map([
1289
- ["n", "\n"],
1290
- ["r", "\r"],
1291
- ["t", " "],
1292
- ["b", "\b"],
1293
- ["f", "\f"],
1294
- ["v", "\v"],
1295
- ["0", "\0"],
1296
- ["\\", "\\"],
1297
- ["e", "\x1B"],
1298
- ["a", "\x07"]
1299
- ]);
1300
- function unescape(c) {
1301
- const u = c[0] === "u";
1302
- const bracket = c[1] === "{";
1303
- if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
1304
- return String.fromCharCode(parseInt(c.slice(1), 16));
1305
- }
1306
- if (u && bracket) {
1307
- return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
1308
- }
1309
- return ESCAPES.get(c) || c;
1310
- }
1311
- function parseArguments(name, arguments_) {
1312
- const results = [];
1313
- const chunks = arguments_.trim().split(/\s*,\s*/g);
1314
- let matches;
1315
- for (const chunk of chunks) {
1316
- const number = Number(chunk);
1317
- if (!Number.isNaN(number)) {
1318
- results.push(number);
1319
- } else if (matches = chunk.match(STRING_REGEX)) {
1320
- results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
1321
- } else {
1322
- throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
1323
- }
1324
- }
1325
- return results;
1326
- }
1327
- function parseStyle(style) {
1328
- STYLE_REGEX.lastIndex = 0;
1329
- const results = [];
1330
- let matches;
1331
- while ((matches = STYLE_REGEX.exec(style)) !== null) {
1332
- const name = matches[1];
1333
- if (matches[2]) {
1334
- const args = parseArguments(name, matches[2]);
1335
- results.push([name].concat(args));
1336
- } else {
1337
- results.push([name]);
1338
- }
1339
- }
1340
- return results;
1341
- }
1342
- function buildStyle(chalk3, styles) {
1343
- const enabled2 = {};
1344
- for (const layer of styles) {
1345
- for (const style of layer.styles) {
1346
- enabled2[style[0]] = layer.inverse ? null : style.slice(1);
1347
- }
1348
- }
1349
- let current = chalk3;
1350
- for (const [styleName, styles2] of Object.entries(enabled2)) {
1351
- if (!Array.isArray(styles2)) {
1352
- continue;
1353
- }
1354
- if (!(styleName in current)) {
1355
- throw new Error(`Unknown Chalk style: ${styleName}`);
1356
- }
1357
- current = styles2.length > 0 ? current[styleName](...styles2) : current[styleName];
1358
- }
1359
- return current;
1360
- }
1361
- module2.exports = (chalk3, temporary) => {
1362
- const styles = [];
1363
- const chunks = [];
1364
- let chunk = [];
1365
- temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
1366
- if (escapeCharacter) {
1367
- chunk.push(unescape(escapeCharacter));
1368
- } else if (style) {
1369
- const string = chunk.join("");
1370
- chunk = [];
1371
- chunks.push(styles.length === 0 ? string : buildStyle(chalk3, styles)(string));
1372
- styles.push({ inverse, styles: parseStyle(style) });
1373
- } else if (close) {
1374
- if (styles.length === 0) {
1375
- throw new Error("Found extraneous } in Chalk template literal");
1376
- }
1377
- chunks.push(buildStyle(chalk3, styles)(chunk.join("")));
1378
- chunk = [];
1379
- styles.pop();
1380
- } else {
1381
- chunk.push(character);
1382
- }
1383
- });
1384
- chunks.push(chunk.join(""));
1385
- if (styles.length > 0) {
1386
- const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
1387
- throw new Error(errMessage);
1388
- }
1389
- return chunks.join("");
1390
- };
1391
- }
1392
- });
1393
-
1394
- // node_modules/chalk/source/index.js
1395
- var require_source = __commonJS({
1396
- "node_modules/chalk/source/index.js"(exports, module2) {
1397
- "use strict";
1398
- var ansiStyles = require_ansi_styles();
1399
- var { stdout: stdoutColor, stderr: stderrColor } = require_supports_color();
1400
- var {
1401
- stringReplaceAll,
1402
- stringEncaseCRLFWithFirstIndex
1403
- } = require_util();
1404
- var { isArray } = Array;
1405
- var levelMapping = [
1406
- "ansi",
1407
- "ansi",
1408
- "ansi256",
1409
- "ansi16m"
1410
- ];
1411
- var styles = /* @__PURE__ */ Object.create(null);
1412
- var applyOptions = (object, options = {}) => {
1413
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1414
- throw new Error("The `level` option should be an integer from 0 to 3");
1415
- }
1416
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
1417
- object.level = options.level === void 0 ? colorLevel : options.level;
1418
- };
1419
- var ChalkClass = class {
1420
- constructor(options) {
1421
- return chalkFactory(options);
1422
- }
1423
- };
1424
- var chalkFactory = (options) => {
1425
- const chalk4 = {};
1426
- applyOptions(chalk4, options);
1427
- chalk4.template = (...arguments_) => chalkTag(chalk4.template, ...arguments_);
1428
- Object.setPrototypeOf(chalk4, Chalk.prototype);
1429
- Object.setPrototypeOf(chalk4.template, chalk4);
1430
- chalk4.template.constructor = () => {
1431
- throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
1432
- };
1433
- chalk4.template.Instance = ChalkClass;
1434
- return chalk4.template;
1435
- };
1436
- function Chalk(options) {
1437
- return chalkFactory(options);
1438
- }
1439
- for (const [styleName, style] of Object.entries(ansiStyles)) {
1440
- styles[styleName] = {
1441
- get() {
1442
- const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
1443
- Object.defineProperty(this, styleName, { value: builder });
1444
- return builder;
1445
- }
1446
- };
1447
- }
1448
- styles.visible = {
1449
- get() {
1450
- const builder = createBuilder(this, this._styler, true);
1451
- Object.defineProperty(this, "visible", { value: builder });
1452
- return builder;
1453
- }
1454
- };
1455
- var usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
1456
- for (const model of usedModels) {
1457
- styles[model] = {
1458
- get() {
1459
- const { level } = this;
1460
- return function(...arguments_) {
1461
- const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
1462
- return createBuilder(this, styler, this._isEmpty);
1463
- };
1464
- }
1465
- };
1466
- }
1467
- for (const model of usedModels) {
1468
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1469
- styles[bgModel] = {
1470
- get() {
1471
- const { level } = this;
1472
- return function(...arguments_) {
1473
- const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
1474
- return createBuilder(this, styler, this._isEmpty);
1475
- };
1476
- }
1477
- };
1478
- }
1479
- var proto = Object.defineProperties(() => {
1480
- }, {
1481
- ...styles,
1482
- level: {
1483
- enumerable: true,
1484
- get() {
1485
- return this._generator.level;
1486
- },
1487
- set(level) {
1488
- this._generator.level = level;
1489
- }
1490
- }
1491
- });
1492
- var createStyler = (open, close, parent) => {
1493
- let openAll;
1494
- let closeAll;
1495
- if (parent === void 0) {
1496
- openAll = open;
1497
- closeAll = close;
1498
- } else {
1499
- openAll = parent.openAll + open;
1500
- closeAll = close + parent.closeAll;
1501
- }
1502
- return {
1503
- open,
1504
- close,
1505
- openAll,
1506
- closeAll,
1507
- parent
1508
- };
1509
- };
1510
- var createBuilder = (self, _styler, _isEmpty) => {
1511
- const builder = (...arguments_) => {
1512
- if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
1513
- return applyStyle(builder, chalkTag(builder, ...arguments_));
1514
- }
1515
- return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1516
- };
1517
- Object.setPrototypeOf(builder, proto);
1518
- builder._generator = self;
1519
- builder._styler = _styler;
1520
- builder._isEmpty = _isEmpty;
1521
- return builder;
1522
- };
1523
- var applyStyle = (self, string) => {
1524
- if (self.level <= 0 || !string) {
1525
- return self._isEmpty ? "" : string;
1526
- }
1527
- let styler = self._styler;
1528
- if (styler === void 0) {
1529
- return string;
1530
- }
1531
- const { openAll, closeAll } = styler;
1532
- if (string.indexOf("\x1B") !== -1) {
1533
- while (styler !== void 0) {
1534
- string = stringReplaceAll(string, styler.close, styler.open);
1535
- styler = styler.parent;
1536
- }
1537
- }
1538
- const lfIndex = string.indexOf("\n");
1539
- if (lfIndex !== -1) {
1540
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
1541
- }
1542
- return openAll + string + closeAll;
1543
- };
1544
- var template;
1545
- var chalkTag = (chalk4, ...strings) => {
1546
- const [firstString] = strings;
1547
- if (!isArray(firstString) || !isArray(firstString.raw)) {
1548
- return strings.join(" ");
1549
- }
1550
- const arguments_ = strings.slice(1);
1551
- const parts = [firstString.raw[0]];
1552
- for (let i = 1; i < firstString.length; i++) {
1553
- parts.push(
1554
- String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
1555
- String(firstString.raw[i])
1556
- );
1557
- }
1558
- if (template === void 0) {
1559
- template = require_templates();
1560
- }
1561
- return template(chalk4, parts.join(""));
1562
- };
1563
- Object.defineProperties(Chalk.prototype, styles);
1564
- var chalk3 = Chalk();
1565
- chalk3.supportsColor = stdoutColor;
1566
- chalk3.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
1567
- chalk3.stderr.supportsColor = stderrColor;
1568
- module2.exports = chalk3;
1569
- }
1570
- });
1571
-
1572
- // src/task-runtime.ts
1573
- var task_runtime_exports = {};
1574
- __export(task_runtime_exports, {
1575
- TaskRuntime: () => TaskRuntime
1576
- });
1577
- module.exports = __toCommonJS(task_runtime_exports);
1578
- var import_child_process = require("child_process");
1579
- var import_fs = require("fs");
1580
- var import_os = require("os");
1581
- var import_path = require("path");
1582
- var path = __toESM(require("path"));
1583
- var import_util = require("util");
1584
- var chalk2 = __toESM(require_source());
1585
-
1586
- // src/common.ts
1587
- var PROJEN_DIR = ".projen";
1588
- var IS_TEST_RUN = process.env.NODE_ENV === "test";
1589
- var packageVersion = require("../package.json").version;
1590
-
1591
- // src/logging.ts
1592
- var chalk = __toESM(require_source());
1593
- var ICON = "\u{1F47E}";
1594
- var enabled = IS_TEST_RUN ? false : true;
1595
- function log(isError, color, ...text) {
1596
- if (!enabled && !isError) {
1597
- return;
1598
- }
1599
- console.error(`${ICON} ${color(...text)}`);
1600
- }
1601
- function debug(...text) {
1602
- if (process.env.DEBUG) {
1603
- log(false, chalk.gray, ...text);
1604
- }
1605
- }
1606
- function verbose(...text) {
1607
- log(false, chalk.white, ...text);
1608
- }
1609
- function info(...text) {
1610
- log(false, chalk.cyan, ...text);
1611
- }
1612
-
1613
- // src/task-runtime.ts
1614
- var ENV_TRIM_LEN = 20;
1615
- var _TaskRuntime = class {
1616
- constructor(workdir) {
1617
- this.workdir = (0, import_path.resolve)(workdir);
1618
- const manifestPath = (0, import_path.join)(this.workdir, _TaskRuntime.MANIFEST_FILE);
1619
- this.manifest = (0, import_fs.existsSync)(manifestPath) ? JSON.parse((0, import_fs.readFileSync)(manifestPath, "utf-8")) : { tasks: {} };
1620
- }
1621
- get tasks() {
1622
- return Object.values(this.manifest.tasks ?? {});
1623
- }
1624
- tryFindTask(name) {
1625
- if (!this.manifest.tasks) {
1626
- return void 0;
1627
- }
1628
- return this.manifest.tasks[name];
1629
- }
1630
- runTask(name, parents = []) {
1631
- const task = this.tryFindTask(name);
1632
- if (!task) {
1633
- throw new Error(`cannot find command ${task}`);
1634
- }
1635
- new RunTask(this, task, parents);
1636
- }
1637
- };
1638
- var TaskRuntime = _TaskRuntime;
1639
- TaskRuntime.MANIFEST_FILE = path.posix.join(
1640
- PROJEN_DIR,
1641
- "tasks.json"
1642
- );
1643
- var RunTask = class {
1644
- constructor(runtime, task, parents = []) {
1645
- this.runtime = runtime;
1646
- this.task = task;
1647
- this.env = {};
1648
- this.workdir = task.cwd ?? this.runtime.workdir;
1649
- this.parents = parents;
1650
- if (!task.steps || task.steps.length === 0) {
1651
- this.logDebug(
1652
- chalk2.gray("No actions have been specified for this task.")
1653
- );
1654
- return;
1655
- }
1656
- this.env = this.resolveEnvironment(parents);
1657
- const envlogs = [];
1658
- for (const [k, v] of Object.entries(this.env)) {
1659
- const vv = v ?? "";
1660
- const trimmed = vv.length > ENV_TRIM_LEN ? vv.substr(0, ENV_TRIM_LEN) + "..." : vv;
1661
- envlogs.push(`${k}=${trimmed}`);
1662
- }
1663
- if (envlogs.length) {
1664
- this.logDebug(
1665
- chalk2.gray(`${chalk2.underline("env")}: ${envlogs.join(" ")}`)
1666
- );
1667
- }
1668
- if (!this.evalCondition(task)) {
1669
- this.log("condition exited with non-zero - skipping");
1670
- return;
1671
- }
1672
- const merged = { ...process.env, ...this.env };
1673
- const missing = new Array();
1674
- for (const name of task.requiredEnv ?? []) {
1675
- if (!(name in merged)) {
1676
- missing.push(name);
1677
- }
1678
- }
1679
- if (missing.length > 0) {
1680
- throw new Error(
1681
- `missing required environment variables: ${missing.join(",")}`
1682
- );
1683
- }
1684
- for (const step of task.steps) {
1685
- if (step.say) {
1686
- info(this.fmtLog(step.say));
1687
- }
1688
- if (step.spawn) {
1689
- this.runtime.runTask(step.spawn, [...this.parents, this.task.name]);
1690
- }
1691
- const execs = step.exec ? [step.exec] : [];
1692
- if (step.builtin) {
1693
- execs.push(this.renderBuiltin(step.builtin));
1694
- }
1695
- for (const exec of execs) {
1696
- let command = "";
1697
- let hasError = false;
1698
- const cmd = exec.split(" ")[0];
1699
- if ((0, import_os.platform)() == "win32" && ["mkdir", "mv", "rm", "cp"].includes(cmd)) {
1700
- command = `shx ${exec}`;
1701
- } else {
1702
- command = exec;
1703
- }
1704
- const cwd = step.cwd;
1705
- try {
1706
- const result = this.shell({
1707
- command,
1708
- cwd
1709
- });
1710
- hasError = result.status !== 0;
1711
- } catch (e) {
1712
- if (e?.message?.startsWith("non-zero exit code:")) {
1713
- hasError = true;
1714
- }
1715
- throw e;
1716
- }
1717
- if (hasError) {
1718
- throw new Error(
1719
- `Task "${this.fullname}" failed when executing "${command}" (cwd: ${(0, import_path.resolve)(
1720
- cwd ?? this.workdir
1721
- )})`
1722
- );
1723
- }
1724
- }
1725
- }
1726
- }
1727
- evalCondition(task) {
1728
- if (!task.condition) {
1729
- return true;
1730
- }
1731
- this.log(chalk2.gray(`${chalk2.underline("condition")}: ${task.condition}`));
1732
- const result = this.shell({
1733
- command: task.condition,
1734
- logprefix: "condition: ",
1735
- quiet: true
1736
- });
1737
- if (result.status === 0) {
1738
- return true;
1739
- } else {
1740
- return false;
1741
- }
1742
- }
1743
- resolveEnvironment(parents) {
1744
- let env = this.runtime.manifest.env ?? {};
1745
- for (const parent of parents) {
1746
- env = {
1747
- ...env,
1748
- ...this.runtime.tryFindTask(parent)?.env ?? {}
1749
- };
1750
- }
1751
- env = {
1752
- ...env,
1753
- ...this.task.env ?? {}
1754
- };
1755
- const output = {};
1756
- for (const [key, value] of Object.entries(env ?? {})) {
1757
- if (value.startsWith("$(") && value.endsWith(")")) {
1758
- const query = value.substring(2, value.length - 1);
1759
- const result = this.shellEval({ command: query });
1760
- if (result.status !== 0) {
1761
- const error = result.error ? result.error.stack : result.stderr?.toString() ?? "unknown error";
1762
- throw new Error(
1763
- `unable to evaluate environment variable ${key}=${value}: ${error}`
1764
- );
1765
- }
1766
- output[key] = result.stdout.toString("utf-8").trim();
1767
- } else {
1768
- output[key] = value;
1769
- }
1770
- }
1771
- return output;
1772
- }
1773
- get fullname() {
1774
- return [...this.parents, this.task.name].join(" \xBB ");
1775
- }
1776
- log(...args) {
1777
- verbose(this.fmtLog(...args));
1778
- }
1779
- logDebug(...args) {
1780
- debug(this.fmtLog(...args));
1781
- }
1782
- fmtLog(...args) {
1783
- return (0, import_util.format)(`${chalk2.underline(this.fullname)} |`, ...args);
1784
- }
1785
- shell(options) {
1786
- const quiet = options.quiet ?? false;
1787
- if (!quiet) {
1788
- const log2 = new Array();
1789
- if (options.logprefix) {
1790
- log2.push(options.logprefix);
1791
- }
1792
- log2.push(options.command);
1793
- if (options.cwd) {
1794
- log2.push(`(cwd: ${options.cwd})`);
1795
- }
1796
- this.log(log2.join(" "));
1797
- }
1798
- const cwd = options.cwd ?? this.workdir;
1799
- if (!(0, import_fs.existsSync)(cwd) || !(0, import_fs.statSync)(cwd).isDirectory()) {
1800
- throw new Error(
1801
- `invalid workdir (cwd): ${cwd} must be an existing directory`
1802
- );
1803
- }
1804
- return (0, import_child_process.spawnSync)(options.command, {
1805
- ...options,
1806
- cwd,
1807
- shell: true,
1808
- stdio: "inherit",
1809
- env: {
1810
- ...process.env,
1811
- ...this.env
1812
- },
1813
- ...options.spawnOptions
1814
- });
1815
- }
1816
- shellEval(options) {
1817
- return this.shell({
1818
- quiet: true,
1819
- ...options,
1820
- spawnOptions: {
1821
- stdio: ["inherit", "pipe", "inherit"]
1822
- }
1823
- });
1824
- }
1825
- renderBuiltin(builtin) {
1826
- const moduleRoot = (0, import_path.dirname)(require.resolve("../package.json"));
1827
- const program = require.resolve((0, import_path.join)(moduleRoot, "lib", `${builtin}.task.js`));
1828
- return `${process.execPath} ${program}`;
1829
- }
1830
- };
1831
- // Annotate the CommonJS export names for ESM import in node:
1832
- 0 && (module.exports = {
1833
- TaskRuntime
1834
- });
1835
2
  const runtime = new TaskRuntime(".");
1836
3
  runtime.runTask(process.argv[2]);