@drupal-canvas/cli 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +216 -5
- package/dist/index.js +1471 -979
- package/dist/index.js.map +1 -0
- package/dist/templates/hello-world/component.yml +4 -4
- package/dist/templates/hello-world/index.jsx +3 -3
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -1,270 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import chalk2 from 'chalk';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
-
import * as
|
|
4
|
+
import * as p from '@clack/prompts';
|
|
5
5
|
import * as fs from 'fs';
|
|
6
6
|
import fs__default, { realpathSync as realpathSync$1, readlinkSync, readdirSync, readdir as readdir$1, lstatSync, promises } from 'fs';
|
|
7
|
-
import
|
|
7
|
+
import path11, { win32, posix } from 'path';
|
|
8
8
|
import dotenv from 'dotenv';
|
|
9
9
|
import { transform, Features } from 'lightningcss';
|
|
10
10
|
import axios from 'axios';
|
|
11
11
|
import fs2, { realpath, readlink, readdir, lstat } from 'fs/promises';
|
|
12
12
|
import os from 'os';
|
|
13
13
|
import { transformSync } from '@swc/wasm';
|
|
14
|
-
import {
|
|
14
|
+
import { basename } from 'path/win32';
|
|
15
|
+
import { ESLint } from 'eslint';
|
|
16
|
+
import { required } from '@drupal-canvas/eslint-config';
|
|
15
17
|
import { fileURLToPath } from 'url';
|
|
16
18
|
import { EventEmitter } from 'events';
|
|
17
19
|
import Stream from 'stream';
|
|
18
20
|
import { StringDecoder } from 'string_decoder';
|
|
21
|
+
import { table } from 'table';
|
|
19
22
|
import * as yaml from 'js-yaml';
|
|
20
23
|
import yaml__default from 'js-yaml';
|
|
21
24
|
import { parse } from '@babel/parser';
|
|
22
25
|
|
|
23
|
-
var __create = Object.create;
|
|
24
|
-
var __defProp = Object.defineProperty;
|
|
25
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
26
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
27
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
28
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
29
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
30
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
31
|
-
};
|
|
32
|
-
var __copyProps = (to2, from, except, desc) => {
|
|
33
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
34
|
-
for (let key of __getOwnPropNames(from))
|
|
35
|
-
if (!__hasOwnProp.call(to2, key) && key !== except)
|
|
36
|
-
__defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
37
|
-
}
|
|
38
|
-
return to2;
|
|
39
|
-
};
|
|
40
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
41
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
42
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
43
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
44
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
45
|
-
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
46
|
-
mod
|
|
47
|
-
));
|
|
48
|
-
|
|
49
|
-
// ../node_modules/balanced-match/index.js
|
|
50
|
-
var require_balanced_match = __commonJS({
|
|
51
|
-
"../node_modules/balanced-match/index.js"(exports, module) {
|
|
52
|
-
module.exports = balanced;
|
|
53
|
-
function balanced(a, b, str) {
|
|
54
|
-
if (a instanceof RegExp) a = maybeMatch(a, str);
|
|
55
|
-
if (b instanceof RegExp) b = maybeMatch(b, str);
|
|
56
|
-
var r = range(a, b, str);
|
|
57
|
-
return r && {
|
|
58
|
-
start: r[0],
|
|
59
|
-
end: r[1],
|
|
60
|
-
pre: str.slice(0, r[0]),
|
|
61
|
-
body: str.slice(r[0] + a.length, r[1]),
|
|
62
|
-
post: str.slice(r[1] + b.length)
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function maybeMatch(reg, str) {
|
|
66
|
-
var m = str.match(reg);
|
|
67
|
-
return m ? m[0] : null;
|
|
68
|
-
}
|
|
69
|
-
balanced.range = range;
|
|
70
|
-
function range(a, b, str) {
|
|
71
|
-
var begs, beg, left, right, result;
|
|
72
|
-
var ai2 = str.indexOf(a);
|
|
73
|
-
var bi2 = str.indexOf(b, ai2 + 1);
|
|
74
|
-
var i = ai2;
|
|
75
|
-
if (ai2 >= 0 && bi2 > 0) {
|
|
76
|
-
if (a === b) {
|
|
77
|
-
return [ai2, bi2];
|
|
78
|
-
}
|
|
79
|
-
begs = [];
|
|
80
|
-
left = str.length;
|
|
81
|
-
while (i >= 0 && !result) {
|
|
82
|
-
if (i == ai2) {
|
|
83
|
-
begs.push(i);
|
|
84
|
-
ai2 = str.indexOf(a, i + 1);
|
|
85
|
-
} else if (begs.length == 1) {
|
|
86
|
-
result = [begs.pop(), bi2];
|
|
87
|
-
} else {
|
|
88
|
-
beg = begs.pop();
|
|
89
|
-
if (beg < left) {
|
|
90
|
-
left = beg;
|
|
91
|
-
right = bi2;
|
|
92
|
-
}
|
|
93
|
-
bi2 = str.indexOf(b, i + 1);
|
|
94
|
-
}
|
|
95
|
-
i = ai2 < bi2 && ai2 >= 0 ? ai2 : bi2;
|
|
96
|
-
}
|
|
97
|
-
if (begs.length) {
|
|
98
|
-
result = [left, right];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return result;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// ../node_modules/glob/node_modules/brace-expansion/index.js
|
|
107
|
-
var require_brace_expansion = __commonJS({
|
|
108
|
-
"../node_modules/glob/node_modules/brace-expansion/index.js"(exports, module) {
|
|
109
|
-
var balanced = require_balanced_match();
|
|
110
|
-
module.exports = expandTop;
|
|
111
|
-
var escSlash = "\0SLASH" + Math.random() + "\0";
|
|
112
|
-
var escOpen = "\0OPEN" + Math.random() + "\0";
|
|
113
|
-
var escClose = "\0CLOSE" + Math.random() + "\0";
|
|
114
|
-
var escComma = "\0COMMA" + Math.random() + "\0";
|
|
115
|
-
var escPeriod = "\0PERIOD" + Math.random() + "\0";
|
|
116
|
-
function numeric(str) {
|
|
117
|
-
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
|
|
118
|
-
}
|
|
119
|
-
function escapeBraces(str) {
|
|
120
|
-
return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
|
|
121
|
-
}
|
|
122
|
-
function unescapeBraces(str) {
|
|
123
|
-
return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
|
|
124
|
-
}
|
|
125
|
-
function parseCommaParts(str) {
|
|
126
|
-
if (!str)
|
|
127
|
-
return [""];
|
|
128
|
-
var parts = [];
|
|
129
|
-
var m = balanced("{", "}", str);
|
|
130
|
-
if (!m)
|
|
131
|
-
return str.split(",");
|
|
132
|
-
var pre = m.pre;
|
|
133
|
-
var body = m.body;
|
|
134
|
-
var post = m.post;
|
|
135
|
-
var p12 = pre.split(",");
|
|
136
|
-
p12[p12.length - 1] += "{" + body + "}";
|
|
137
|
-
var postParts = parseCommaParts(post);
|
|
138
|
-
if (post.length) {
|
|
139
|
-
p12[p12.length - 1] += postParts.shift();
|
|
140
|
-
p12.push.apply(p12, postParts);
|
|
141
|
-
}
|
|
142
|
-
parts.push.apply(parts, p12);
|
|
143
|
-
return parts;
|
|
144
|
-
}
|
|
145
|
-
function expandTop(str) {
|
|
146
|
-
if (!str)
|
|
147
|
-
return [];
|
|
148
|
-
if (str.substr(0, 2) === "{}") {
|
|
149
|
-
str = "\\{\\}" + str.substr(2);
|
|
150
|
-
}
|
|
151
|
-
return expand2(escapeBraces(str), true).map(unescapeBraces);
|
|
152
|
-
}
|
|
153
|
-
function embrace(str) {
|
|
154
|
-
return "{" + str + "}";
|
|
155
|
-
}
|
|
156
|
-
function isPadded(el2) {
|
|
157
|
-
return /^-?0\d/.test(el2);
|
|
158
|
-
}
|
|
159
|
-
function lte(i, y) {
|
|
160
|
-
return i <= y;
|
|
161
|
-
}
|
|
162
|
-
function gte(i, y) {
|
|
163
|
-
return i >= y;
|
|
164
|
-
}
|
|
165
|
-
function expand2(str, isTop) {
|
|
166
|
-
var expansions = [];
|
|
167
|
-
var m = balanced("{", "}", str);
|
|
168
|
-
if (!m) return [str];
|
|
169
|
-
var pre = m.pre;
|
|
170
|
-
var post = m.post.length ? expand2(m.post, false) : [""];
|
|
171
|
-
if (/\$$/.test(m.pre)) {
|
|
172
|
-
for (var k = 0; k < post.length; k++) {
|
|
173
|
-
var expansion = pre + "{" + m.body + "}" + post[k];
|
|
174
|
-
expansions.push(expansion);
|
|
175
|
-
}
|
|
176
|
-
} else {
|
|
177
|
-
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
178
|
-
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
179
|
-
var isSequence = isNumericSequence || isAlphaSequence;
|
|
180
|
-
var isOptions = m.body.indexOf(",") >= 0;
|
|
181
|
-
if (!isSequence && !isOptions) {
|
|
182
|
-
if (m.post.match(/,(?!,).*\}/)) {
|
|
183
|
-
str = m.pre + "{" + m.body + escClose + m.post;
|
|
184
|
-
return expand2(str);
|
|
185
|
-
}
|
|
186
|
-
return [str];
|
|
187
|
-
}
|
|
188
|
-
var n;
|
|
189
|
-
if (isSequence) {
|
|
190
|
-
n = m.body.split(/\.\./);
|
|
191
|
-
} else {
|
|
192
|
-
n = parseCommaParts(m.body);
|
|
193
|
-
if (n.length === 1) {
|
|
194
|
-
n = expand2(n[0], false).map(embrace);
|
|
195
|
-
if (n.length === 1) {
|
|
196
|
-
return post.map(function(p12) {
|
|
197
|
-
return m.pre + n[0] + p12;
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
var N;
|
|
203
|
-
if (isSequence) {
|
|
204
|
-
var x = numeric(n[0]);
|
|
205
|
-
var y = numeric(n[1]);
|
|
206
|
-
var width = Math.max(n[0].length, n[1].length);
|
|
207
|
-
var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
|
|
208
|
-
var test = lte;
|
|
209
|
-
var reverse = y < x;
|
|
210
|
-
if (reverse) {
|
|
211
|
-
incr *= -1;
|
|
212
|
-
test = gte;
|
|
213
|
-
}
|
|
214
|
-
var pad = n.some(isPadded);
|
|
215
|
-
N = [];
|
|
216
|
-
for (var i = x; test(i, y); i += incr) {
|
|
217
|
-
var c;
|
|
218
|
-
if (isAlphaSequence) {
|
|
219
|
-
c = String.fromCharCode(i);
|
|
220
|
-
if (c === "\\")
|
|
221
|
-
c = "";
|
|
222
|
-
} else {
|
|
223
|
-
c = String(i);
|
|
224
|
-
if (pad) {
|
|
225
|
-
var need = width - c.length;
|
|
226
|
-
if (need > 0) {
|
|
227
|
-
var z = new Array(need + 1).join("0");
|
|
228
|
-
if (i < 0)
|
|
229
|
-
c = "-" + z + c.slice(1);
|
|
230
|
-
else
|
|
231
|
-
c = z + c;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
N.push(c);
|
|
236
|
-
}
|
|
237
|
-
} else {
|
|
238
|
-
N = [];
|
|
239
|
-
for (var j = 0; j < n.length; j++) {
|
|
240
|
-
N.push.apply(N, expand2(n[j], false));
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
for (var j = 0; j < N.length; j++) {
|
|
244
|
-
for (var k = 0; k < post.length; k++) {
|
|
245
|
-
var expansion = pre + N[j] + post[k];
|
|
246
|
-
if (!isTop || isSequence || expansion)
|
|
247
|
-
expansions.push(expansion);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return expansions;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
|
|
256
26
|
// package.json
|
|
257
27
|
var package_default = {
|
|
258
|
-
};
|
|
28
|
+
version: "0.4.0"};
|
|
259
29
|
function loadEnvFiles() {
|
|
260
30
|
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
261
31
|
if (homeDir) {
|
|
262
|
-
const homeEnvPath =
|
|
32
|
+
const homeEnvPath = path11.resolve(homeDir, ".canvasrc");
|
|
263
33
|
if (fs__default.existsSync(homeEnvPath)) {
|
|
264
34
|
dotenv.config({ path: homeEnvPath });
|
|
265
35
|
}
|
|
266
36
|
}
|
|
267
|
-
const localEnvPath =
|
|
37
|
+
const localEnvPath = path11.resolve(process.cwd(), ".env");
|
|
268
38
|
if (fs__default.existsSync(localEnvPath)) {
|
|
269
39
|
dotenv.config({ path: localEnvPath });
|
|
270
40
|
}
|
|
@@ -276,7 +46,8 @@ var config = {
|
|
|
276
46
|
clientSecret: process.env.CANVAS_CLIENT_SECRET || "",
|
|
277
47
|
scope: process.env.CANVAS_SCOPE || "canvas:js_component canvas:asset_library",
|
|
278
48
|
componentDir: process.env.CANVAS_COMPONENT_DIR || "./components",
|
|
279
|
-
verbose: process.env.CANVAS_VERBOSE === "true"
|
|
49
|
+
verbose: process.env.CANVAS_VERBOSE === "true",
|
|
50
|
+
userAgent: process.env.CANVAS_USER_AGENT || ""
|
|
280
51
|
};
|
|
281
52
|
function getConfig() {
|
|
282
53
|
return config;
|
|
@@ -294,7 +65,7 @@ async function ensureConfig(requiredKeys) {
|
|
|
294
65
|
async function promptForConfig(key) {
|
|
295
66
|
switch (key) {
|
|
296
67
|
case "siteUrl": {
|
|
297
|
-
const value = await
|
|
68
|
+
const value = await p.text({
|
|
298
69
|
message: "Enter the site URL",
|
|
299
70
|
placeholder: "https://example.com",
|
|
300
71
|
validate: (value2) => {
|
|
@@ -304,45 +75,45 @@ async function promptForConfig(key) {
|
|
|
304
75
|
return;
|
|
305
76
|
}
|
|
306
77
|
});
|
|
307
|
-
if (
|
|
308
|
-
|
|
78
|
+
if (p.isCancel(value)) {
|
|
79
|
+
p.cancel("Operation cancelled");
|
|
309
80
|
process.exit(0);
|
|
310
81
|
}
|
|
311
82
|
setConfig({ siteUrl: value });
|
|
312
83
|
break;
|
|
313
84
|
}
|
|
314
85
|
case "clientId": {
|
|
315
|
-
const value = await
|
|
86
|
+
const value = await p.text({
|
|
316
87
|
message: "Enter your client ID",
|
|
317
88
|
validate: (value2) => {
|
|
318
89
|
if (!value2) return "Client ID is required";
|
|
319
90
|
return;
|
|
320
91
|
}
|
|
321
92
|
});
|
|
322
|
-
if (
|
|
323
|
-
|
|
93
|
+
if (p.isCancel(value)) {
|
|
94
|
+
p.cancel("Operation cancelled");
|
|
324
95
|
process.exit(0);
|
|
325
96
|
}
|
|
326
97
|
setConfig({ clientId: value });
|
|
327
98
|
break;
|
|
328
99
|
}
|
|
329
100
|
case "clientSecret": {
|
|
330
|
-
const value = await
|
|
101
|
+
const value = await p.password({
|
|
331
102
|
message: "Enter your client secret",
|
|
332
103
|
validate: (value2) => {
|
|
333
104
|
if (!value2) return "Client secret is required";
|
|
334
105
|
return;
|
|
335
106
|
}
|
|
336
107
|
});
|
|
337
|
-
if (
|
|
338
|
-
|
|
108
|
+
if (p.isCancel(value)) {
|
|
109
|
+
p.cancel("Operation cancelled");
|
|
339
110
|
process.exit(0);
|
|
340
111
|
}
|
|
341
112
|
setConfig({ clientSecret: value });
|
|
342
113
|
break;
|
|
343
114
|
}
|
|
344
115
|
case "componentDir": {
|
|
345
|
-
const value = await
|
|
116
|
+
const value = await p.text({
|
|
346
117
|
message: "Enter the component directory",
|
|
347
118
|
placeholder: "./components",
|
|
348
119
|
validate: (value2) => {
|
|
@@ -350,8 +121,8 @@ async function promptForConfig(key) {
|
|
|
350
121
|
return;
|
|
351
122
|
}
|
|
352
123
|
});
|
|
353
|
-
if (
|
|
354
|
-
|
|
124
|
+
if (p.isCancel(value)) {
|
|
125
|
+
p.cancel("Operation cancelled");
|
|
355
126
|
process.exit(0);
|
|
356
127
|
}
|
|
357
128
|
setConfig({ componentDir: value });
|
|
@@ -480,10 +251,10 @@ var $E = Ej((DA) => {
|
|
|
480
251
|
return Array(F + 1).join("../") + j.substr(A2.length + 1);
|
|
481
252
|
}
|
|
482
253
|
DA.relative = u0;
|
|
483
|
-
var ie = function() {
|
|
254
|
+
var ie = (function() {
|
|
484
255
|
var A2 = /* @__PURE__ */ Object.create(null);
|
|
485
256
|
return !("__proto__" in A2);
|
|
486
|
-
}();
|
|
257
|
+
})();
|
|
487
258
|
function oe(A2) {
|
|
488
259
|
return A2;
|
|
489
260
|
}
|
|
@@ -1122,15 +893,15 @@ function xF(A2, j) {
|
|
|
1122
893
|
if (!(s === J6 && ($ = A2.charCodeAt(a + 1), $ === NA))) if (s === A6) r === "" && (n = a), r += A2.slice(a, a + 2), a += 1;
|
|
1123
894
|
else if (s === M6 && A2.charCodeAt(a + 1) === _6) {
|
|
1124
895
|
let i = a;
|
|
1125
|
-
for (let
|
|
1126
|
-
else if ($ === _6 && A2.charCodeAt(
|
|
1127
|
-
a =
|
|
896
|
+
for (let p13 = a + 2; p13 < A2.length; p13++) if ($ = A2.charCodeAt(p13), $ === A6) p13 += 1;
|
|
897
|
+
else if ($ === _6 && A2.charCodeAt(p13 + 1) === M6) {
|
|
898
|
+
a = p13 + 1;
|
|
1128
899
|
break;
|
|
1129
900
|
}
|
|
1130
901
|
let c = A2.slice(i, a + 1);
|
|
1131
902
|
if (c.charCodeAt(2) === D8) {
|
|
1132
|
-
let
|
|
1133
|
-
k.push(
|
|
903
|
+
let p13 = dt(c.slice(2, -2));
|
|
904
|
+
k.push(p13), F && (p13.src = [F, i, a + 1], p13.dst = [F, i, a + 1]);
|
|
1134
905
|
}
|
|
1135
906
|
} else if (s === fG || s === mG) {
|
|
1136
907
|
let i = XG(A2, a, s);
|
|
@@ -1141,7 +912,7 @@ function xF(A2, j) {
|
|
|
1141
912
|
if (r.length === 0) continue;
|
|
1142
913
|
$ = r.charCodeAt(r.length - 1), $ !== j6 && $ !== NA && $ !== R6 && (r += " ");
|
|
1143
914
|
} else if (s === PG && A2.charCodeAt(a + 1) === PG && r.length === 0) {
|
|
1144
|
-
let i = "", c = a,
|
|
915
|
+
let i = "", c = a, p13 = -1;
|
|
1145
916
|
for (let I = a + 2; I < A2.length; I++) if ($ = A2.charCodeAt(I), $ === A6) I += 1;
|
|
1146
917
|
else if ($ === fG || $ === mG) I = XG(A2, I, $);
|
|
1147
918
|
else if ($ === M6 && A2.charCodeAt(I + 1) === _6) {
|
|
@@ -1150,7 +921,7 @@ function xF(A2, j) {
|
|
|
1150
921
|
I = g + 1;
|
|
1151
922
|
break;
|
|
1152
923
|
}
|
|
1153
|
-
} else if (
|
|
924
|
+
} else if (p13 === -1 && $ === h8) p13 = r.length + I - c;
|
|
1154
925
|
else if ($ === N6 && i.length === 0) {
|
|
1155
926
|
r += A2.slice(c, I), a = I;
|
|
1156
927
|
break;
|
|
@@ -1161,7 +932,7 @@ function xF(A2, j) {
|
|
|
1161
932
|
a = I - 1, r += A2.slice(c, I);
|
|
1162
933
|
break;
|
|
1163
934
|
} else ($ === HG || $ === d8 || $ === JE) && i.length > 0 && A2[I] === i[i.length - 1] && (i = i.slice(0, -1));
|
|
1164
|
-
let h = VE(r,
|
|
935
|
+
let h = VE(r, p13);
|
|
1165
936
|
if (!h) throw new Error("Invalid custom property, expected a value");
|
|
1166
937
|
F && (h.src = [F, c, a], h.dst = [F, c, a]), t ? t.nodes.push(h) : E.push(h), r = "";
|
|
1167
938
|
} else if (s === N6 && r.charCodeAt(0) === UE) q = z6(r), F && (q.src = [F, n, a], q.dst = [F, n, a]), t ? t.nodes.push(q) : E.push(q), r = "", q = null;
|
|
@@ -1179,9 +950,9 @@ function xF(A2, j) {
|
|
|
1179
950
|
else {
|
|
1180
951
|
let c = r.indexOf(":");
|
|
1181
952
|
if (t) {
|
|
1182
|
-
let
|
|
1183
|
-
if (!
|
|
1184
|
-
F && (
|
|
953
|
+
let p13 = VE(r, c);
|
|
954
|
+
if (!p13) throw new Error(`Invalid declaration: \`${r.trim()}\``);
|
|
955
|
+
F && (p13.src = [F, n, a], p13.dst = [F, n, a]), t.nodes.push(p13);
|
|
1185
956
|
}
|
|
1186
957
|
}
|
|
1187
958
|
let i = G.pop() ?? null;
|
|
@@ -1560,23 +1331,23 @@ function ZE(A2, j, F = [], E = {}) {
|
|
|
1560
1331
|
}
|
|
1561
1332
|
function E6(A2, j, F = 3) {
|
|
1562
1333
|
let E = [], k = /* @__PURE__ */ new Set(), G = new iA(() => /* @__PURE__ */ new Set()), t = new iA(() => /* @__PURE__ */ new Set()), q = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), e = [], n = [], $ = new iA(() => /* @__PURE__ */ new Set());
|
|
1563
|
-
function a(i, c,
|
|
1334
|
+
function a(i, c, p13 = {}, h = 0) {
|
|
1564
1335
|
if (i.kind === "declaration") {
|
|
1565
1336
|
if (i.property === "--tw-sort" || i.value === void 0 || i.value === null) return;
|
|
1566
|
-
if (
|
|
1337
|
+
if (p13.theme && i.property[0] === "-" && i.property[1] === "-") {
|
|
1567
1338
|
if (i.value === "initial") {
|
|
1568
1339
|
i.value = void 0;
|
|
1569
1340
|
return;
|
|
1570
1341
|
}
|
|
1571
|
-
|
|
1342
|
+
p13.keyframes || G.get(c).add(i);
|
|
1572
1343
|
}
|
|
1573
|
-
if (i.value.includes("var(")) if (
|
|
1344
|
+
if (i.value.includes("var(")) if (p13.theme && i.property[0] === "-" && i.property[1] === "-") for (let I of ut(i.value)) $.get(I).add(i.property);
|
|
1574
1345
|
else j.trackUsedVariables(i.value);
|
|
1575
1346
|
if (i.property === "animation") for (let I of zG(i.value)) r.add(I);
|
|
1576
1347
|
F & 2 && i.value.includes("color-mix(") && t.get(c).add(i), c.push(i);
|
|
1577
1348
|
} else if (i.kind === "rule") {
|
|
1578
1349
|
let I = [];
|
|
1579
|
-
for (let b of i.nodes) a(b, I,
|
|
1350
|
+
for (let b of i.nodes) a(b, I, p13, h + 1);
|
|
1580
1351
|
let g = {}, v = /* @__PURE__ */ new Set();
|
|
1581
1352
|
for (let b of I) {
|
|
1582
1353
|
if (b.kind !== "declaration") continue;
|
|
@@ -1596,31 +1367,31 @@ function E6(A2, j, F = 3) {
|
|
|
1596
1367
|
}
|
|
1597
1368
|
k.add(i.params);
|
|
1598
1369
|
let I = { ...i, nodes: [] };
|
|
1599
|
-
for (let g of i.nodes) a(g, I.nodes,
|
|
1370
|
+
for (let g of i.nodes) a(g, I.nodes, p13, h + 1);
|
|
1600
1371
|
c.push(I);
|
|
1601
1372
|
} else if (i.kind === "at-rule") {
|
|
1602
|
-
i.name === "@keyframes" && (
|
|
1373
|
+
i.name === "@keyframes" && (p13 = { ...p13, keyframes: true });
|
|
1603
1374
|
let I = { ...i, nodes: [] };
|
|
1604
|
-
for (let g of i.nodes) a(g, I.nodes,
|
|
1605
|
-
i.name === "@keyframes" &&
|
|
1375
|
+
for (let g of i.nodes) a(g, I.nodes, p13, h + 1);
|
|
1376
|
+
i.name === "@keyframes" && p13.theme && q.add(I), (I.nodes.length > 0 || I.name === "@layer" || I.name === "@charset" || I.name === "@custom-media" || I.name === "@namespace" || I.name === "@import") && c.push(I);
|
|
1606
1377
|
} else if (i.kind === "at-root") for (let I of i.nodes) {
|
|
1607
1378
|
let g = [];
|
|
1608
|
-
a(I, g,
|
|
1379
|
+
a(I, g, p13, 0);
|
|
1609
1380
|
for (let v of g) E.push(v);
|
|
1610
1381
|
}
|
|
1611
1382
|
else if (i.kind === "context") {
|
|
1612
1383
|
if (i.context.reference) return;
|
|
1613
|
-
for (let I of i.nodes) a(I, c, { ...
|
|
1384
|
+
for (let I of i.nodes) a(I, c, { ...p13, ...i.context }, h);
|
|
1614
1385
|
} else i.kind === "comment" && c.push(i);
|
|
1615
1386
|
}
|
|
1616
1387
|
let s = [];
|
|
1617
1388
|
for (let i of A2) a(i, s, {}, 0);
|
|
1618
|
-
A: for (let [i, c] of G) for (let
|
|
1619
|
-
if (Dt(
|
|
1620
|
-
if (
|
|
1389
|
+
A: for (let [i, c] of G) for (let p13 of c) {
|
|
1390
|
+
if (Dt(p13.property, j.theme, $)) {
|
|
1391
|
+
if (p13.property.startsWith(j.theme.prefixKey("--animate-"))) for (let I of zG(p13.value)) r.add(I);
|
|
1621
1392
|
continue;
|
|
1622
1393
|
}
|
|
1623
|
-
let h = i.indexOf(
|
|
1394
|
+
let h = i.indexOf(p13);
|
|
1624
1395
|
if (i.splice(h, 1), i.length === 0) {
|
|
1625
1396
|
let I = L8(s, (g) => g.kind === "rule" && g.nodes === i);
|
|
1626
1397
|
if (!I || I.length === 0) continue A;
|
|
@@ -1641,10 +1412,10 @@ function E6(A2, j, F = 3) {
|
|
|
1641
1412
|
let c = E.indexOf(i);
|
|
1642
1413
|
E.splice(c, 1);
|
|
1643
1414
|
}
|
|
1644
|
-
if (s = s.concat(E), F & 2) for (let [i, c] of t) for (let
|
|
1645
|
-
let h = i.indexOf(
|
|
1646
|
-
if (h === -1 ||
|
|
1647
|
-
let I = BA(
|
|
1415
|
+
if (s = s.concat(E), F & 2) for (let [i, c] of t) for (let p13 of c) {
|
|
1416
|
+
let h = i.indexOf(p13);
|
|
1417
|
+
if (h === -1 || p13.value == null) continue;
|
|
1418
|
+
let I = BA(p13.value), g = false;
|
|
1648
1419
|
if (wA(I, (L, { replaceWith: T }) => {
|
|
1649
1420
|
if (L.kind !== "function" || L.value !== "color-mix") return;
|
|
1650
1421
|
let P = false, AA = false;
|
|
@@ -1685,8 +1456,8 @@ function E6(A2, j, F = 3) {
|
|
|
1685
1456
|
S.kind === "word" && (S.value === "oklab" || S.value === "oklch" || S.value === "lab" || S.value === "lch") && (S.value = "srgb");
|
|
1686
1457
|
}
|
|
1687
1458
|
}), !g) continue;
|
|
1688
|
-
let v = { ...
|
|
1689
|
-
b.src =
|
|
1459
|
+
let v = { ...p13, value: mA(I) }, b = uA("@supports (color: color-mix(in lab, red, red))", [p13]);
|
|
1460
|
+
b.src = p13.src, i.splice(h, 1, v, b);
|
|
1690
1461
|
}
|
|
1691
1462
|
if (F & 1) {
|
|
1692
1463
|
let i = [];
|
|
@@ -1699,8 +1470,8 @@ function E6(A2, j, F = 3) {
|
|
|
1699
1470
|
c.src = n[0].src, i.push(c);
|
|
1700
1471
|
}
|
|
1701
1472
|
if (i.length > 0) {
|
|
1702
|
-
let c = s.findIndex((I) => !(I.kind === "comment" || I.kind === "at-rule" && (I.name === "@charset" || I.name === "@import"))),
|
|
1703
|
-
|
|
1473
|
+
let c = s.findIndex((I) => !(I.kind === "comment" || I.kind === "at-rule" && (I.name === "@charset" || I.name === "@import"))), p13 = EA("@layer", "properties", []);
|
|
1474
|
+
p13.src = i[0].src, s.splice(c < 0 ? s.length : c, 0, p13);
|
|
1704
1475
|
let h = uA("@layer properties", [EA("@supports", "((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b))))", i)]);
|
|
1705
1476
|
h.src = i[0].src, h.nodes[0].src = i[0].src, s.push(h);
|
|
1706
1477
|
}
|
|
@@ -1939,17 +1710,17 @@ function* T8(A2, j) {
|
|
|
1939
1710
|
if (a[a.length - 1] !== "]") return;
|
|
1940
1711
|
let c = hj(a.slice(i + 1, -1));
|
|
1941
1712
|
if (!$j(c)) continue;
|
|
1942
|
-
let
|
|
1713
|
+
let p13 = "";
|
|
1943
1714
|
for (let h = 0; h < c.length; h++) {
|
|
1944
1715
|
let I = c.charCodeAt(h);
|
|
1945
1716
|
if (I === O8) {
|
|
1946
|
-
|
|
1717
|
+
p13 = c.slice(0, h), c = c.slice(h + 1);
|
|
1947
1718
|
break;
|
|
1948
1719
|
}
|
|
1949
1720
|
if (!(I === JG || I >= UG && I <= VG)) break;
|
|
1950
1721
|
}
|
|
1951
1722
|
if (c.length === 0 || c.trim().length === 0) continue;
|
|
1952
|
-
s.value = { kind: "arbitrary", dataType:
|
|
1723
|
+
s.value = { kind: "arbitrary", dataType: p13 || null, value: c };
|
|
1953
1724
|
} else {
|
|
1954
1725
|
let c = q === null || s.modifier?.kind === "arbitrary" ? null : `${a}/${q}`;
|
|
1955
1726
|
s.value = { kind: "named", value: a, fraction: c };
|
|
@@ -3064,8 +2835,8 @@ function W8(A2) {
|
|
|
3064
2835
|
Only valid data types are: ${FF.map((c) => `"${c}"`).join(", ")}.
|
|
3065
2836
|
`);
|
|
3066
2837
|
let e = r.value, n = structuredClone(t), $ = "\xB6";
|
|
3067
|
-
wA(n.nodes, (c, { replaceWith:
|
|
3068
|
-
c.kind === "word" && c.value === e &&
|
|
2838
|
+
wA(n.nodes, (c, { replaceWith: p13 }) => {
|
|
2839
|
+
c.kind === "word" && c.value === e && p13({ kind: "word", value: $ });
|
|
3069
2840
|
});
|
|
3070
2841
|
let a = "^".repeat(mA([r]).length), s = mA([n]).indexOf($), i = ["```css", mA([t]), " ".repeat(s) + a, "```"].join(`
|
|
3071
2842
|
`);
|
|
@@ -3076,7 +2847,7 @@ Only valid data types are: ${FF.map((c) => `"${c}"`).join(", ")}.
|
|
|
3076
2847
|
let G = structuredClone(A2), t = k.value, q = k.modifier;
|
|
3077
2848
|
if (t === null) return;
|
|
3078
2849
|
let r = false, e = false, n = false, $ = false, a = /* @__PURE__ */ new Map(), s = false;
|
|
3079
|
-
if (Y([G], (i, { parent: c, replaceWith:
|
|
2850
|
+
if (Y([G], (i, { parent: c, replaceWith: p13 }) => {
|
|
3080
2851
|
if (c?.kind !== "rule" && c?.kind !== "at-rule" || i.kind !== "declaration" || !i.value) return;
|
|
3081
2852
|
let h = BA(i.value);
|
|
3082
2853
|
(wA(h, (I, { replaceWith: g }) => {
|
|
@@ -3084,19 +2855,19 @@ Only valid data types are: ${FF.map((c) => `"${c}"`).join(", ")}.
|
|
|
3084
2855
|
if (I.value === "--value") {
|
|
3085
2856
|
r = true;
|
|
3086
2857
|
let v = WG(t, I, F);
|
|
3087
|
-
return v ? (e = true, v.ratio ? s = true : a.set(i, c), g(v.nodes), 1) : (r ||= false,
|
|
2858
|
+
return v ? (e = true, v.ratio ? s = true : a.set(i, c), g(v.nodes), 1) : (r ||= false, p13([]), 2);
|
|
3088
2859
|
} else if (I.value === "--modifier") {
|
|
3089
|
-
if (q === null) return
|
|
2860
|
+
if (q === null) return p13([]), 2;
|
|
3090
2861
|
n = true;
|
|
3091
2862
|
let v = WG(q, I, F);
|
|
3092
|
-
return v ? ($ = true, g(v.nodes), 1) : (n ||= false,
|
|
2863
|
+
return v ? ($ = true, g(v.nodes), 1) : (n ||= false, p13([]), 2);
|
|
3093
2864
|
}
|
|
3094
2865
|
}
|
|
3095
2866
|
}) ?? 0) === 0 && (i.value = mA(h));
|
|
3096
2867
|
}), r && !e || n && !$ || s && $ || q && !s && !$) return null;
|
|
3097
2868
|
if (s) for (let [i, c] of a) {
|
|
3098
|
-
let
|
|
3099
|
-
|
|
2869
|
+
let p13 = c.nodes.indexOf(i);
|
|
2870
|
+
p13 !== -1 && c.nodes.splice(p13, 1);
|
|
3100
2871
|
}
|
|
3101
2872
|
return G.nodes;
|
|
3102
2873
|
}), F.utilities.suggest(j.slice(0, -2), () => {
|
|
@@ -3314,8 +3085,8 @@ function ex(A2) {
|
|
|
3314
3085
|
let v = I.kind === "at-rule", b = g.kind === "at-rule";
|
|
3315
3086
|
return v && !b ? -1 : !v && b ? 1 : 0;
|
|
3316
3087
|
});
|
|
3317
|
-
let
|
|
3318
|
-
for (let I =
|
|
3088
|
+
let p13 = c.flatMap((I) => I.kind === "rule" ? I.selector === "&" ? [] : [I.selector] : I.kind === "at-rule" ? [`${I.name} ${I.params}`] : []), h = "";
|
|
3089
|
+
for (let I = p13.length - 1; I >= 0; I--) h = h === "" ? p13[I] : `${p13[I]} { ${h} }`;
|
|
3319
3090
|
s.push(h);
|
|
3320
3091
|
}), s;
|
|
3321
3092
|
};
|
|
@@ -3474,25 +3245,25 @@ function xx(A2) {
|
|
|
3474
3245
|
let i = [], c = [];
|
|
3475
3246
|
for (let h of s) h.kind === "at-rule" ? i.push(h) : h.kind === "rule" && c.push(h);
|
|
3476
3247
|
if (i.length > 1 || c.length > 1) return 2;
|
|
3477
|
-
let
|
|
3248
|
+
let p13 = [];
|
|
3478
3249
|
for (let h of c) {
|
|
3479
3250
|
let I = t(h.selector);
|
|
3480
3251
|
if (!I) return $ = false, 2;
|
|
3481
|
-
|
|
3252
|
+
p13.push(FA(I, []));
|
|
3482
3253
|
}
|
|
3483
3254
|
for (let h of i) {
|
|
3484
3255
|
let I = G(h);
|
|
3485
3256
|
if (!I) return $ = false, 2;
|
|
3486
|
-
|
|
3257
|
+
p13.push(I);
|
|
3487
3258
|
}
|
|
3488
|
-
return Object.assign(e, FA("&",
|
|
3259
|
+
return Object.assign(e, FA("&", p13)), $ = true, 1;
|
|
3489
3260
|
}), e.kind === "rule" && e.selector === "&" && e.nodes.length === 1 && Object.assign(e, e.nodes[0]), !$) return null;
|
|
3490
3261
|
}), j.suggest("not", () => Array.from(j.keys()).filter((e) => j.compoundsWith("not", e))), j.compound("group", 2, (e, n) => {
|
|
3491
3262
|
if (n.variant.kind === "arbitrary" && n.variant.relative) return null;
|
|
3492
3263
|
let $ = n.modifier ? `:where(.${A2.prefix ? `${A2.prefix}\\:` : ""}group\\/${n.modifier.value})` : `:where(.${A2.prefix ? `${A2.prefix}\\:` : ""}group)`, a = false;
|
|
3493
3264
|
if (Y([e], (s, { path: i }) => {
|
|
3494
3265
|
if (s.kind !== "rule") return 0;
|
|
3495
|
-
for (let
|
|
3266
|
+
for (let p13 of i.slice(0, -1)) if (p13.kind === "rule") return a = false, 2;
|
|
3496
3267
|
let c = s.selector.replaceAll("&", $);
|
|
3497
3268
|
U(c, ",").length > 1 && (c = `:is(${c})`), s.selector = `&:is(${c} *)`, a = true;
|
|
3498
3269
|
}), !a) return null;
|
|
@@ -3501,7 +3272,7 @@ function xx(A2) {
|
|
|
3501
3272
|
let $ = n.modifier ? `:where(.${A2.prefix ? `${A2.prefix}\\:` : ""}peer\\/${n.modifier.value})` : `:where(.${A2.prefix ? `${A2.prefix}\\:` : ""}peer)`, a = false;
|
|
3502
3273
|
if (Y([e], (s, { path: i }) => {
|
|
3503
3274
|
if (s.kind !== "rule") return 0;
|
|
3504
|
-
for (let
|
|
3275
|
+
for (let p13 of i.slice(0, -1)) if (p13.kind === "rule") return a = false, 2;
|
|
3505
3276
|
let c = s.selector.replaceAll("&", $);
|
|
3506
3277
|
U(c, ",").length > 1 && (c = `:is(${c})`), s.selector = `&:is(${c} ~ *)`, a = true;
|
|
3507
3278
|
}), !a) return null;
|
|
@@ -3735,9 +3506,9 @@ function jE(A2, j, { onInvalidCandidate: F, respectImportant: E } = {}) {
|
|
|
3735
3506
|
if (s.length !== 0) {
|
|
3736
3507
|
$ = true;
|
|
3737
3508
|
for (let { node: i, propertySort: c } of s) {
|
|
3738
|
-
let
|
|
3739
|
-
for (let h of a.variants)
|
|
3740
|
-
k.set(i, { properties: c, variants:
|
|
3509
|
+
let p13 = 0n;
|
|
3510
|
+
for (let h of a.variants) p13 |= 1n << BigInt(r.get(h));
|
|
3511
|
+
k.set(i, { properties: c, variants: p13, candidate: e }), G.push(i);
|
|
3741
3512
|
}
|
|
3742
3513
|
}
|
|
3743
3514
|
}
|
|
@@ -3846,7 +3617,7 @@ function GF(A2, j) {
|
|
|
3846
3617
|
t.get(i).add($), Y($.nodes, (c) => {
|
|
3847
3618
|
if (!(c.kind !== "at-rule" || c.name !== "@apply")) {
|
|
3848
3619
|
k.add($);
|
|
3849
|
-
for (let
|
|
3620
|
+
for (let p13 of Ft(c, j)) G.get($).add(p13);
|
|
3850
3621
|
}
|
|
3851
3622
|
});
|
|
3852
3623
|
return;
|
|
@@ -3866,12 +3637,12 @@ function GF(A2, j) {
|
|
|
3866
3637
|
throw $.kind === "at-rule" && $.name === "@utility" && s.kind === "at-rule" && s.name === "@utility" && Y($.nodes, (i) => {
|
|
3867
3638
|
if (i.kind !== "at-rule" || i.name !== "@apply") return;
|
|
3868
3639
|
let c = i.params.split(/\s+/g);
|
|
3869
|
-
for (let
|
|
3640
|
+
for (let p13 of c) for (let h of j.parseCandidate(p13)) switch (h.kind) {
|
|
3870
3641
|
case "arbitrary":
|
|
3871
3642
|
break;
|
|
3872
3643
|
case "static":
|
|
3873
3644
|
case "functional":
|
|
3874
|
-
if (s.params.replace(/-\*$/, "") === h.root) throw new Error(`You cannot \`@apply\` the \`${
|
|
3645
|
+
if (s.params.replace(/-\*$/, "") === h.root) throw new Error(`You cannot \`@apply\` the \`${p13}\` utility here because it creates a circular dependency.`);
|
|
3875
3646
|
break;
|
|
3876
3647
|
}
|
|
3877
3648
|
}), new Error(`Circular dependency detected:
|
|
@@ -3889,8 +3660,8 @@ ${uj([s])}`);
|
|
|
3889
3660
|
for (let $ of k) n($);
|
|
3890
3661
|
for (let $ of r) "nodes" in $ && Y($.nodes, (a, { replaceWith: s }) => {
|
|
3891
3662
|
if (a.kind !== "at-rule" || a.name !== "@apply") return;
|
|
3892
|
-
let i = a.params.split(/(\s+)/g), c = {},
|
|
3893
|
-
for (let [h, I] of i.entries()) h % 2 === 0 && (c[I] =
|
|
3663
|
+
let i = a.params.split(/(\s+)/g), c = {}, p13 = 0;
|
|
3664
|
+
for (let [h, I] of i.entries()) h % 2 === 0 && (c[I] = p13), p13 += I.length;
|
|
3894
3665
|
{
|
|
3895
3666
|
let h = Object.keys(c), I = jE(h, j, { respectImportant: false, onInvalidCandidate: (L) => {
|
|
3896
3667
|
if (j.theme.prefix && !L.startsWith(j.theme.prefix)) throw new Error(`Cannot apply unprefixed utility class \`${L}\`. Did you mean \`${j.theme.prefix}:${L}\`?`);
|
|
@@ -3949,8 +3720,8 @@ async function Lt(A2, j, F, E = 0, k = false) {
|
|
|
3949
3720
|
let i = pj({}, []);
|
|
3950
3721
|
return t.push((async () => {
|
|
3951
3722
|
if (E > 100) throw new Error(`Exceeded maximum recursion depth while resolving \`${n}\` in \`${j}\`)`);
|
|
3952
|
-
let c = await F(n, j),
|
|
3953
|
-
await Lt(
|
|
3723
|
+
let c = await F(n, j), p13 = xF(c.content, { from: k ? c.path : void 0 });
|
|
3724
|
+
await Lt(p13, c.base, F, E + 1, k), i.nodes = ox(q, [pj({ base: c.base }, p13)], $, a, s);
|
|
3954
3725
|
})()), r(i), 1;
|
|
3955
3726
|
}
|
|
3956
3727
|
}), t.length > 0 && await Promise.all(t), G;
|
|
@@ -4133,14 +3904,14 @@ function px(A2, j) {
|
|
|
4133
3904
|
continue;
|
|
4134
3905
|
}
|
|
4135
3906
|
let a = n.indexOf("--"), s = n.slice(0, a), i = n.slice(a + 2);
|
|
4136
|
-
i = i.replace(/-([a-z])/g, (c,
|
|
3907
|
+
i = i.replace(/-([a-z])/g, (c, p13) => p13.toUpperCase()), k.get(s === "" ? null : s).set(i, [$, A2.getOptions(`--${F}${n}`)]);
|
|
4137
3908
|
}
|
|
4138
3909
|
let q = A2.getOptions(`--${F}`);
|
|
4139
3910
|
for (let [n, $] of k) {
|
|
4140
3911
|
let a = E.get(n);
|
|
4141
3912
|
if (typeof a != "string") continue;
|
|
4142
3913
|
let s = {}, i = {};
|
|
4143
|
-
for (let [c, [
|
|
3914
|
+
for (let [c, [p13, h]] of $) s[c] = p13, i[c] = h;
|
|
4144
3915
|
E.set(n, [a, s]), t.set(n, [q, i]);
|
|
4145
3916
|
}
|
|
4146
3917
|
let r = {}, e = {};
|
|
@@ -4391,10 +4162,10 @@ function Bt({ designSystem: A2, ast: j, resolvedConfig: F, featuresRef: E, refer
|
|
|
4391
4162
|
});
|
|
4392
4163
|
}, (a, s) => {
|
|
4393
4164
|
if (a.kind !== "functional" || s.kind !== "functional") return 0;
|
|
4394
|
-
let i = a.value ? a.value.value : "DEFAULT", c = s.value ? s.value.value : "DEFAULT",
|
|
4395
|
-
if (e && typeof e.sort == "function") return e.sort({ value:
|
|
4165
|
+
let i = a.value ? a.value.value : "DEFAULT", c = s.value ? s.value.value : "DEFAULT", p13 = e?.values?.[i] ?? i, h = e?.values?.[c] ?? c;
|
|
4166
|
+
if (e && typeof e.sort == "function") return e.sort({ value: p13, modifier: a.modifier?.value ?? null }, { value: h, modifier: s.modifier?.value ?? null });
|
|
4396
4167
|
let I = $.indexOf(i), g = $.indexOf(c);
|
|
4397
|
-
return I = I === -1 ? $.length : I, g = g === -1 ? $.length : g, I !== g ? I - g :
|
|
4168
|
+
return I = I === -1 ? $.length : I, g = g === -1 ? $.length : g, I !== g ? I - g : p13 < h ? -1 : 1;
|
|
4398
4169
|
}), A2.variants.suggest(q, () => Object.keys(e?.values ?? {}).filter((a) => a !== "DEFAULT"));
|
|
4399
4170
|
}, addUtilities(q) {
|
|
4400
4171
|
q = Array.isArray(q) ? q : [q];
|
|
@@ -4416,7 +4187,7 @@ function Bt({ designSystem: A2, ast: j, resolvedConfig: F, featuresRef: E, refer
|
|
|
4416
4187
|
if (i.kind === "selector" && i.value[0] === "." && st.test(i.value.slice(1))) {
|
|
4417
4188
|
let c = i.value;
|
|
4418
4189
|
i.value = "&";
|
|
4419
|
-
let
|
|
4190
|
+
let p13 = Z6(a), h = c.slice(1), I = p13 === "&" ? Gj($) : [uA(p13, Gj($))];
|
|
4420
4191
|
e.get(h).push(...I), s = true, i.value = c;
|
|
4421
4192
|
return;
|
|
4422
4193
|
}
|
|
@@ -4440,19 +4211,19 @@ function Bt({ designSystem: A2, ast: j, resolvedConfig: F, featuresRef: E, refer
|
|
|
4440
4211
|
let s = function({ negative: i }) {
|
|
4441
4212
|
return (c) => {
|
|
4442
4213
|
if (c.value?.kind === "arbitrary" && e.length > 0 && !e.includes("any") && (c.value.dataType && !e.includes(c.value.dataType) || !c.value.dataType && !xA(c.value.value, e))) return;
|
|
4443
|
-
let
|
|
4214
|
+
let p13 = e.includes("color"), h = null, I = false;
|
|
4444
4215
|
{
|
|
4445
4216
|
let b = r?.values ?? {};
|
|
4446
|
-
|
|
4217
|
+
p13 && (b = Object.assign({ inherit: "inherit", transparent: "transparent", current: "currentcolor" }, b)), c.value ? c.value.kind === "arbitrary" ? h = c.value.value : c.value.fraction && b[c.value.fraction] ? (h = b[c.value.fraction], I = true) : b[c.value.value] ? h = b[c.value.value] : b.__BARE_VALUE__ && (h = b.__BARE_VALUE__(c.value) ?? null, I = (c.value.fraction !== null && h?.includes("/")) ?? false) : h = b.DEFAULT ?? null;
|
|
4447
4218
|
}
|
|
4448
4219
|
if (h === null) return;
|
|
4449
4220
|
let g;
|
|
4450
4221
|
{
|
|
4451
4222
|
let b = r?.modifiers ?? null;
|
|
4452
|
-
c.modifier ? b === "any" || c.modifier.kind === "arbitrary" ? g = c.modifier.value : b?.[c.modifier.value] ? g = b[c.modifier.value] :
|
|
4223
|
+
c.modifier ? b === "any" || c.modifier.kind === "arbitrary" ? g = c.modifier.value : b?.[c.modifier.value] ? g = b[c.modifier.value] : p13 && !Number.isNaN(Number(c.modifier.value)) ? g = `${c.modifier.value}%` : g = null : g = null;
|
|
4453
4224
|
}
|
|
4454
4225
|
if (c.modifier && g === null && !I) return c.value?.kind === "arbitrary" ? null : void 0;
|
|
4455
|
-
|
|
4226
|
+
p13 && g !== null && (h = vA(h, g)), i && (h = `calc(${h} * -1)`);
|
|
4456
4227
|
let v = Gj(a(h, { modifier: g }));
|
|
4457
4228
|
return Ct(v, $, c.raw), E.current |= GF(v, A2), v;
|
|
4458
4229
|
};
|
|
@@ -4461,7 +4232,7 @@ function Bt({ designSystem: A2, ast: j, resolvedConfig: F, featuresRef: E, refer
|
|
|
4461
4232
|
r?.supportsNegativeValues && A2.utilities.functional(`-${$}`, s({ negative: true }), { types: e }), A2.utilities.functional($, s({ negative: false }), { types: e }), A2.utilities.suggest($, () => {
|
|
4462
4233
|
let i = r?.values ?? {}, c = new Set(Object.keys(i));
|
|
4463
4234
|
c.delete("__BARE_VALUE__"), c.delete("__CSS_VALUES__"), c.has("DEFAULT") && (c.delete("DEFAULT"), c.add(null));
|
|
4464
|
-
let
|
|
4235
|
+
let p13 = r?.modifiers ?? {}, h = p13 === "any" ? [] : Object.keys(p13);
|
|
4465
4236
|
return [{ supportsNegative: r?.supportsNegativeValues ?? false, values: Array.from(c), modifiers: h }];
|
|
4466
4237
|
});
|
|
4467
4238
|
}
|
|
@@ -4703,7 +4474,7 @@ async function Jx({ designSystem: A2, base: j, ast: F, loadModule: E, sources: k
|
|
|
4703
4474
|
if (a !== null) throw new Error("`@plugin` cannot be nested.");
|
|
4704
4475
|
let c = $.params.slice(1, -1);
|
|
4705
4476
|
if (c.length === 0) throw new Error("`@plugin` must have a path.");
|
|
4706
|
-
let
|
|
4477
|
+
let p13 = {};
|
|
4707
4478
|
for (let h of $.nodes ?? []) {
|
|
4708
4479
|
if (h.kind !== "declaration") throw new Error(`Unexpected \`@plugin\` option:
|
|
4709
4480
|
|
|
@@ -4723,9 +4494,9 @@ Using an object as a plugin option is currently only supported in JavaScript con
|
|
|
4723
4494
|
} else return Number(v);
|
|
4724
4495
|
return v;
|
|
4725
4496
|
});
|
|
4726
|
-
|
|
4497
|
+
p13[h.property] = g.length === 1 ? g[0] : g;
|
|
4727
4498
|
}
|
|
4728
|
-
t.push([{ id: c, base: i.base, reference: !!i.reference, src: $.src }, Object.keys(
|
|
4499
|
+
t.push([{ id: c, base: i.base, reference: !!i.reference, src: $.src }, Object.keys(p13).length > 0 ? p13 : null]), s([]), G |= 4;
|
|
4729
4500
|
return;
|
|
4730
4501
|
}
|
|
4731
4502
|
if ($.name === "@config") {
|
|
@@ -4744,8 +4515,8 @@ Using an object as a plugin option is currently only supported in JavaScript con
|
|
|
4744
4515
|
let c = await E($, a, "config");
|
|
4745
4516
|
return { path: $, base: c.base, config: c.module, reference: s, src: i };
|
|
4746
4517
|
})), Promise.all(t.map(async ([{ id: $, base: a, reference: s, src: i }, c]) => {
|
|
4747
|
-
let
|
|
4748
|
-
return { path: $, base:
|
|
4518
|
+
let p13 = await E($, a, "plugin");
|
|
4519
|
+
return { path: $, base: p13.base, plugin: p13.module, options: c, reference: s, src: i };
|
|
4749
4520
|
}))]);
|
|
4750
4521
|
return G |= pt({ designSystem: A2, base: j, ast: F, sources: k, configs: e, pluginDetails: n }), G;
|
|
4751
4522
|
}
|
|
@@ -4759,13 +4530,13 @@ function pt({ designSystem: A2, base: j, ast: F, sources: E, configs: k, pluginD
|
|
|
4759
4530
|
} } }, a = Bt({ ...$, referenceMode: false, src: void 0 }), s = A2.resolveThemeValue;
|
|
4760
4531
|
A2.resolveThemeValue = function(i, c) {
|
|
4761
4532
|
if (i[0] === "-" && i[1] === "-") return s(i, c);
|
|
4762
|
-
let
|
|
4763
|
-
if (Array.isArray(
|
|
4764
|
-
if (Array.isArray(
|
|
4765
|
-
if (typeof
|
|
4533
|
+
let p13 = a.theme(i, void 0);
|
|
4534
|
+
if (Array.isArray(p13) && p13.length === 2) return p13[0];
|
|
4535
|
+
if (Array.isArray(p13)) return p13.join(", ");
|
|
4536
|
+
if (typeof p13 == "string") return p13;
|
|
4766
4537
|
};
|
|
4767
|
-
for (let { handler: i, reference: c, src:
|
|
4768
|
-
let h = Bt({ ...$, referenceMode: c ?? false, src:
|
|
4538
|
+
for (let { handler: i, reference: c, src: p13 } of r.plugins) {
|
|
4539
|
+
let h = Bt({ ...$, referenceMode: c ?? false, src: p13 });
|
|
4769
4540
|
i(h);
|
|
4770
4541
|
}
|
|
4771
4542
|
if (sx(A2, e, n), Px(A2, e), Nx(e, A2), Rx(e, A2), wx(e, A2), !A2.theme.prefix && r.prefix) {
|
|
@@ -4774,8 +4545,8 @@ function pt({ designSystem: A2, base: j, ast: F, sources: E, configs: k, pluginD
|
|
|
4774
4545
|
}
|
|
4775
4546
|
if (!A2.important && r.important === true && (A2.important = true), typeof r.important == "string") {
|
|
4776
4547
|
let i = r.important;
|
|
4777
|
-
Y(F, (c, { replaceWith:
|
|
4778
|
-
if (c.kind === "at-rule" && !(c.name !== "@tailwind" || c.params !== "utilities")) return h?.kind === "rule" && h.selector === i ||
|
|
4548
|
+
Y(F, (c, { replaceWith: p13, parent: h }) => {
|
|
4549
|
+
if (c.kind === "at-rule" && !(c.name !== "@tailwind" || c.params !== "utilities")) return h?.kind === "rule" && h.selector === i || p13(FA(i, [c])), 2;
|
|
4779
4550
|
});
|
|
4780
4551
|
}
|
|
4781
4552
|
for (let i of r.blocklist) A2.invalidCandidates.add(i);
|
|
@@ -4884,7 +4655,7 @@ var Mt = ((A2) => (A2[A2.None = 0] = "None", A2[A2.AtApply = 1] = "AtApply", A2[
|
|
|
4884
4655
|
async function E0(A2, { base: j = "", from: F, loadModule: E = Zx, loadStylesheet: k = A0 } = {}) {
|
|
4885
4656
|
let G = 0;
|
|
4886
4657
|
A2 = [pj({ base: j }, A2)], G |= await Lt(A2, j, k, 0, F !== void 0);
|
|
4887
|
-
let t = null, q = new K8(), r = [], e = [], n = null, $ = null, a = [], s = [], i = [], c = [],
|
|
4658
|
+
let t = null, q = new K8(), r = [], e = [], n = null, $ = null, a = [], s = [], i = [], c = [], p13 = null;
|
|
4888
4659
|
Y(A2, (I, { parent: g, replaceWith: v, context: b }) => {
|
|
4889
4660
|
if (I.kind === "at-rule") {
|
|
4890
4661
|
if (I.name === "@tailwind" && (I.params === "utilities" || I.params.startsWith("utilities"))) {
|
|
@@ -4900,11 +4671,11 @@ async function E0(A2, { base: j = "", from: F, loadModule: E = Zx, loadStyleshee
|
|
|
4900
4671
|
for (let T of L) if (T.startsWith("source(")) {
|
|
4901
4672
|
let P = T.slice(7, -1);
|
|
4902
4673
|
if (P === "none") {
|
|
4903
|
-
|
|
4674
|
+
p13 = P;
|
|
4904
4675
|
continue;
|
|
4905
4676
|
}
|
|
4906
4677
|
if (P[0] === '"' && P[P.length - 1] !== '"' || P[0] === "'" && P[P.length - 1] !== "'" || P[0] !== "'" && P[0] !== '"') throw new Error("`source(\u2026)` paths must be quoted.");
|
|
4907
|
-
|
|
4678
|
+
p13 = { base: b.sourceBase ?? b.base, pattern: P.slice(1, -1) };
|
|
4908
4679
|
}
|
|
4909
4680
|
$ = I, G |= 16;
|
|
4910
4681
|
}
|
|
@@ -5042,7 +4813,7 @@ ${AA}`);
|
|
|
5042
4813
|
}
|
|
5043
4814
|
return Y(A2, (I, { replaceWith: g }) => {
|
|
5044
4815
|
if (I.kind === "at-rule") return I.name === "@utility" && g([]), 1;
|
|
5045
|
-
}), { designSystem: h, ast: A2, sources: s, root:
|
|
4816
|
+
}), { designSystem: h, ast: A2, sources: s, root: p13, utilitiesNode: $, features: G, inlineCandidates: i };
|
|
5046
4817
|
}
|
|
5047
4818
|
async function _t(A2, j = {}) {
|
|
5048
4819
|
let { designSystem: F, ast: E, sources: k, root: G, utilitiesNode: t, features: q, inlineCandidates: r } = await E0(A2, j);
|
|
@@ -5055,18 +4826,18 @@ async function _t(A2, j = {}) {
|
|
|
5055
4826
|
return { sources: k, root: G, features: q, build(i) {
|
|
5056
4827
|
if (q === 0) return A2;
|
|
5057
4828
|
if (!t) return $ ??= E6(E, F, j.polyfills), $;
|
|
5058
|
-
let c = s,
|
|
4829
|
+
let c = s, p13 = false;
|
|
5059
4830
|
s = false;
|
|
5060
4831
|
let h = n.size;
|
|
5061
4832
|
for (let g of i) if (!F.invalidCandidates.has(g)) if (g[0] === "-" && g[1] === "-") {
|
|
5062
4833
|
let v = F.theme.markUsedVariable(g);
|
|
5063
|
-
c ||= v,
|
|
4834
|
+
c ||= v, p13 ||= v;
|
|
5064
4835
|
} else n.add(g), c ||= n.size !== h;
|
|
5065
4836
|
if (!c) return $ ??= E6(E, F, j.polyfills), $;
|
|
5066
4837
|
let I = jE(n, F, { onInvalidCandidate: e }).astNodes;
|
|
5067
4838
|
return j.from && Y(I, (g) => {
|
|
5068
4839
|
g.src ??= t.src;
|
|
5069
|
-
}), !
|
|
4840
|
+
}), !p13 && a === I.length ? ($ ??= E6(E, F, j.polyfills), $) : (a = I.length, t.nodes = I, $ = E6(E, F, j.polyfills), $);
|
|
5070
4841
|
} };
|
|
5071
4842
|
}
|
|
5072
4843
|
async function FE(A2, j = {}) {
|
|
@@ -7460,7 +7231,7 @@ var Yt = 60;
|
|
|
7460
7231
|
var Zt = " ";
|
|
7461
7232
|
function Ae({ source: A2, line: j, column: F, baseLine: E, baseColumn: k }, G) {
|
|
7462
7233
|
function t(i, c) {
|
|
7463
|
-
return e.slice(i, c).map((
|
|
7234
|
+
return e.slice(i, c).map((p13, h) => String(i + h + 1).padStart(a) + " |" + p13).join(`
|
|
7464
7235
|
`);
|
|
7465
7236
|
}
|
|
7466
7237
|
let q = `
|
|
@@ -7616,9 +7387,9 @@ function Ge(A2) {
|
|
|
7616
7387
|
j = e, n = n || {}, q.setSource(j, ij), t.setSource(j, n.offset, n.line, n.column), F = n.filename || "<unknown>", E = !!n.positions, k = typeof n.onParseError == "function" ? n.onParseError : Ee, G = false, q.parseAtrulePrelude = "parseAtrulePrelude" in n ? !!n.parseAtrulePrelude : true, q.parseRulePrelude = "parseRulePrelude" in n ? !!n.parseRulePrelude : true, q.parseValue = "parseValue" in n ? !!n.parseValue : true, q.parseCustomProperty = "parseCustomProperty" in n ? !!n.parseCustomProperty : false;
|
|
7617
7388
|
let { context: $ = "default", onComment: a } = n;
|
|
7618
7389
|
if (!($ in q.context)) throw new Error("Unknown context `" + $ + "`");
|
|
7619
|
-
typeof a == "function" && q.forEachToken((i, c,
|
|
7390
|
+
typeof a == "function" && q.forEachToken((i, c, p13) => {
|
|
7620
7391
|
if (i === 25) {
|
|
7621
|
-
let h = q.getLocation(c,
|
|
7392
|
+
let h = q.getLocation(c, p13), I = ej(j, p13 - 2, p13, "*/") ? j.slice(c + 2, p13 - 2) : j.slice(c + 2, p13);
|
|
7622
7393
|
a(I, h);
|
|
7623
7394
|
}
|
|
7624
7395
|
});
|
|
@@ -7771,10 +7542,10 @@ function be(A2) {
|
|
|
7771
7542
|
for (let e in j) gF.call(j, e) && j[e] !== null && (F[e] = Xe(j[e], false), E[e] = Xe(j[e], true));
|
|
7772
7543
|
let t = Le(F), q = Le(E), r = function(e, n) {
|
|
7773
7544
|
function $(h, I, g) {
|
|
7774
|
-
let v = a.call(
|
|
7775
|
-
return v === k ? true : v === G ? false : !!(i.hasOwnProperty(h.type) && i[h.type](h,
|
|
7545
|
+
let v = a.call(p13, h, I, g);
|
|
7546
|
+
return v === k ? true : v === G ? false : !!(i.hasOwnProperty(h.type) && i[h.type](h, p13, $, c) || s.call(p13, h, I, g) === k);
|
|
7776
7547
|
}
|
|
7777
|
-
let a = s6, s = s6, i = F, c = (h, I, g, v) => h || $(I, g, v),
|
|
7548
|
+
let a = s6, s = s6, i = F, c = (h, I, g, v) => h || $(I, g, v), p13 = { break: k, skip: G, root: e, stylesheet: null, atrule: null, atrulePrelude: null, rule: null, selector: null, block: null, declaration: null, function: null };
|
|
7778
7549
|
if (typeof n == "function") a = n;
|
|
7779
7550
|
else if (n && (a = He(n.enter), s = He(n.leave), n.reverse && (i = E), n.visit)) {
|
|
7780
7551
|
if (t.hasOwnProperty(n.visit)) i = n.reverse ? q[n.visit] : t[n.visit];
|
|
@@ -8671,15 +8442,15 @@ function kn(A2, j, F) {
|
|
|
8671
8442
|
function n() {
|
|
8672
8443
|
v.type === YF ? v = v.prev : v = { type: ar, syntax: $.syntax, token: v.token, prev: v }, $ = $.prev;
|
|
8673
8444
|
}
|
|
8674
|
-
let $ = null, a = null, s = null, i = null, c = 0,
|
|
8675
|
-
for (E();
|
|
8445
|
+
let $ = null, a = null, s = null, i = null, c = 0, p13 = null, h = null, I = -1, g = 0, v = { type: Wl, syntax: null, token: null, prev: null };
|
|
8446
|
+
for (E(); p13 === null && ++c < lr; ) switch (j.type) {
|
|
8676
8447
|
case "Match":
|
|
8677
8448
|
if (a === null) {
|
|
8678
8449
|
if (h !== null && (I !== A2.length - 1 || h.value !== "\\0" && h.value !== "\\9")) {
|
|
8679
8450
|
j = GA;
|
|
8680
8451
|
break;
|
|
8681
8452
|
}
|
|
8682
|
-
|
|
8453
|
+
p13 = xr;
|
|
8683
8454
|
break;
|
|
8684
8455
|
}
|
|
8685
8456
|
if (j = a.nextState, j === mE) if (a.matchStack === v) {
|
|
@@ -8692,7 +8463,7 @@ function kn(A2, j, F) {
|
|
|
8692
8463
|
case "Mismatch":
|
|
8693
8464
|
if (i !== null && i !== false) (s === null || I > s.tokenIndex) && (s = i, i = false);
|
|
8694
8465
|
else if (s === null) {
|
|
8695
|
-
|
|
8466
|
+
p13 = Zl;
|
|
8696
8467
|
break;
|
|
8697
8468
|
}
|
|
8698
8469
|
j = s.nextState, a = s.thenStack, $ = s.syntaxStack, v = s.matchStack, I = s.tokenIndex, h = I < A2.length ? A2[I] : null, s = s.prev;
|
|
@@ -8802,9 +8573,9 @@ function kn(A2, j, F) {
|
|
|
8802
8573
|
default:
|
|
8803
8574
|
throw new Error("Unknown node type: " + j.type);
|
|
8804
8575
|
}
|
|
8805
|
-
switch (
|
|
8576
|
+
switch (p13) {
|
|
8806
8577
|
case null:
|
|
8807
|
-
console.warn("[csstree-match] BREAK after " + lr + " iterations"),
|
|
8578
|
+
console.warn("[csstree-match] BREAK after " + lr + " iterations"), p13 = An, v = null;
|
|
8808
8579
|
break;
|
|
8809
8580
|
case xr:
|
|
8810
8581
|
for (; $ !== null; ) n();
|
|
@@ -8812,7 +8583,7 @@ function kn(A2, j, F) {
|
|
|
8812
8583
|
default:
|
|
8813
8584
|
v = null;
|
|
8814
8585
|
}
|
|
8815
|
-
return { tokens: A2, reason:
|
|
8586
|
+
return { tokens: A2, reason: p13, iterations: c, match: v, longestMatch: g };
|
|
8816
8587
|
}
|
|
8817
8588
|
function ZF(A2, j, F) {
|
|
8818
8589
|
let E = kn(A2, j, F || {});
|
|
@@ -10697,19 +10468,26 @@ var ApiService = class _ApiService {
|
|
|
10697
10468
|
clientId;
|
|
10698
10469
|
clientSecret;
|
|
10699
10470
|
scope;
|
|
10471
|
+
userAgent;
|
|
10700
10472
|
accessToken = null;
|
|
10473
|
+
refreshPromise = null;
|
|
10701
10474
|
constructor(options) {
|
|
10702
10475
|
this.clientId = options.clientId;
|
|
10703
10476
|
this.clientSecret = options.clientSecret;
|
|
10704
10477
|
this.siteUrl = options.siteUrl;
|
|
10705
10478
|
this.scope = options.scope;
|
|
10479
|
+
this.userAgent = options.userAgent || "";
|
|
10480
|
+
const headers = {
|
|
10481
|
+
"Content-Type": "application/json",
|
|
10482
|
+
// Add the CLI marker header to identify CLI requests
|
|
10483
|
+
"X-Canvas-CLI": "1"
|
|
10484
|
+
};
|
|
10485
|
+
if (this.userAgent) {
|
|
10486
|
+
headers["User-Agent"] = this.userAgent;
|
|
10487
|
+
}
|
|
10706
10488
|
this.client = axios.create({
|
|
10707
10489
|
baseURL: options.siteUrl,
|
|
10708
|
-
headers
|
|
10709
|
-
"Content-Type": "application/json",
|
|
10710
|
-
// Add the CLI marker header to identify CLI requests
|
|
10711
|
-
"X-Canvas-CLI": "1"
|
|
10712
|
-
},
|
|
10490
|
+
headers,
|
|
10713
10491
|
// Allow longer timeout for uploads
|
|
10714
10492
|
timeout: 3e4,
|
|
10715
10493
|
transformResponse: [
|
|
@@ -10726,33 +10504,80 @@ var ApiService = class _ApiService {
|
|
|
10726
10504
|
}
|
|
10727
10505
|
]
|
|
10728
10506
|
});
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
{
|
|
10742
|
-
headers: {
|
|
10743
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
10507
|
+
this.client.interceptors.response.use(
|
|
10508
|
+
(response) => response,
|
|
10509
|
+
async (error) => {
|
|
10510
|
+
const originalRequest = error.config;
|
|
10511
|
+
if (error.response?.status === 401 && !originalRequest._retry && !originalRequest.url?.includes("/oauth/token")) {
|
|
10512
|
+
originalRequest._retry = true;
|
|
10513
|
+
try {
|
|
10514
|
+
const newToken = await this.refreshAccessToken();
|
|
10515
|
+
originalRequest.headers.Authorization = `Bearer ${newToken}`;
|
|
10516
|
+
return this.client(originalRequest);
|
|
10517
|
+
} catch (refreshError) {
|
|
10518
|
+
return Promise.reject(error);
|
|
10744
10519
|
}
|
|
10745
10520
|
}
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10521
|
+
return Promise.reject(error);
|
|
10522
|
+
}
|
|
10523
|
+
);
|
|
10524
|
+
this.client.interceptors.request.use(
|
|
10525
|
+
async (config2) => {
|
|
10526
|
+
if (!this.accessToken && !config2.url?.includes("/oauth/token")) {
|
|
10527
|
+
try {
|
|
10528
|
+
const token = await this.refreshAccessToken();
|
|
10529
|
+
config2.headers.Authorization = `Bearer ${token}`;
|
|
10530
|
+
} catch (error) {
|
|
10531
|
+
return Promise.reject(error);
|
|
10532
|
+
}
|
|
10533
|
+
}
|
|
10534
|
+
return config2;
|
|
10535
|
+
},
|
|
10536
|
+
(error) => {
|
|
10537
|
+
return Promise.reject(error);
|
|
10538
|
+
}
|
|
10539
|
+
);
|
|
10540
|
+
}
|
|
10541
|
+
/**
|
|
10542
|
+
* Refresh the access token using client credentials.
|
|
10543
|
+
* Handles concurrent refresh attempts by reusing the same promise.
|
|
10544
|
+
*/
|
|
10545
|
+
async refreshAccessToken() {
|
|
10546
|
+
if (this.refreshPromise) {
|
|
10547
|
+
return this.refreshPromise;
|
|
10548
|
+
}
|
|
10549
|
+
this.refreshPromise = (async () => {
|
|
10550
|
+
try {
|
|
10551
|
+
const response = await this.client.post(
|
|
10552
|
+
"/oauth/token",
|
|
10553
|
+
new URLSearchParams({
|
|
10554
|
+
grant_type: "client_credentials",
|
|
10555
|
+
client_id: this.clientId,
|
|
10556
|
+
client_secret: this.clientSecret,
|
|
10557
|
+
scope: this.scope
|
|
10558
|
+
}).toString(),
|
|
10559
|
+
{
|
|
10560
|
+
headers: {
|
|
10561
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
10562
|
+
}
|
|
10563
|
+
}
|
|
10564
|
+
);
|
|
10565
|
+
this.accessToken = response.data.access_token;
|
|
10566
|
+
this.client.defaults.headers.common["Authorization"] = `Bearer ${this.accessToken}`;
|
|
10567
|
+
return this.accessToken;
|
|
10568
|
+
} catch (error) {
|
|
10569
|
+
this.handleApiError(error);
|
|
10570
|
+
throw new Error("Failed to refresh access token");
|
|
10571
|
+
}
|
|
10572
|
+
})();
|
|
10573
|
+
try {
|
|
10574
|
+
return await this.refreshPromise;
|
|
10575
|
+
} finally {
|
|
10576
|
+
this.refreshPromise = null;
|
|
10754
10577
|
}
|
|
10755
|
-
|
|
10578
|
+
}
|
|
10579
|
+
static async create(options) {
|
|
10580
|
+
return new _ApiService(options);
|
|
10756
10581
|
}
|
|
10757
10582
|
getAccessToken() {
|
|
10758
10583
|
return this.accessToken;
|
|
@@ -10976,29 +10801,30 @@ function createApiService() {
|
|
|
10976
10801
|
siteUrl: config2.siteUrl,
|
|
10977
10802
|
clientId: config2.clientId,
|
|
10978
10803
|
clientSecret: config2.clientSecret,
|
|
10979
|
-
scope: config2.scope
|
|
10804
|
+
scope: config2.scope,
|
|
10805
|
+
userAgent: config2.userAgent
|
|
10980
10806
|
});
|
|
10981
10807
|
}
|
|
10982
|
-
var CANVAS_CACHE_DIR =
|
|
10808
|
+
var CANVAS_CACHE_DIR = path11.join(os.homedir(), ".canvas");
|
|
10983
10809
|
async function downloadJsSourceFromCanvas(componentsToDownload) {
|
|
10984
10810
|
for (const key in componentsToDownload) {
|
|
10985
10811
|
const component = componentsToDownload[key];
|
|
10986
10812
|
try {
|
|
10987
|
-
const componentDir =
|
|
10813
|
+
const componentDir = path11.join(CANVAS_CACHE_DIR, component.machineName);
|
|
10988
10814
|
await fs2.rm(componentDir, { recursive: true, force: true });
|
|
10989
10815
|
await fs2.mkdir(componentDir, { recursive: true });
|
|
10990
10816
|
if (component.sourceCodeJs) {
|
|
10991
10817
|
await fs2.writeFile(
|
|
10992
|
-
|
|
10818
|
+
path11.join(componentDir, `index.jsx`),
|
|
10993
10819
|
component.sourceCodeJs,
|
|
10994
10820
|
"utf-8"
|
|
10995
10821
|
);
|
|
10996
10822
|
}
|
|
10997
10823
|
} catch (error) {
|
|
10998
10824
|
if (error instanceof Error) {
|
|
10999
|
-
|
|
10825
|
+
p.note(chalk2.red(`Error: ${error.message}`));
|
|
11000
10826
|
} else {
|
|
11001
|
-
|
|
10827
|
+
p.note(chalk2.red(`Unknown error: ${String(error)}`));
|
|
11002
10828
|
}
|
|
11003
10829
|
}
|
|
11004
10830
|
}
|
|
@@ -11007,22 +10833,22 @@ async function copyLocalJsSource(componentsToCopy) {
|
|
|
11007
10833
|
try {
|
|
11008
10834
|
await fs2.mkdir(CANVAS_CACHE_DIR, { recursive: true });
|
|
11009
10835
|
for (const componentPath of componentsToCopy) {
|
|
11010
|
-
const baseName =
|
|
10836
|
+
const baseName = path11.basename(componentPath);
|
|
11011
10837
|
const sourcePath = componentPath;
|
|
11012
|
-
const targetPath =
|
|
10838
|
+
const targetPath = path11.join(CANVAS_CACHE_DIR, baseName);
|
|
11013
10839
|
const stats = await fs2.stat(sourcePath);
|
|
11014
10840
|
if (stats.isDirectory()) {
|
|
11015
10841
|
await fs2.mkdir(targetPath, { recursive: true });
|
|
11016
|
-
const sourceFile =
|
|
11017
|
-
const targetFile =
|
|
10842
|
+
const sourceFile = path11.join(sourcePath, "index.jsx");
|
|
10843
|
+
const targetFile = path11.join(targetPath, "index.jsx");
|
|
11018
10844
|
await fs2.copyFile(sourceFile, targetFile);
|
|
11019
10845
|
}
|
|
11020
10846
|
}
|
|
11021
10847
|
} catch (error) {
|
|
11022
10848
|
if (error instanceof Error) {
|
|
11023
|
-
|
|
10849
|
+
p.note(chalk2.red(`Error: ${error.message}`));
|
|
11024
10850
|
} else {
|
|
11025
|
-
|
|
10851
|
+
p.note(chalk2.red(`Unknown error: ${String(error)}`));
|
|
11026
10852
|
}
|
|
11027
10853
|
}
|
|
11028
10854
|
}
|
|
@@ -11032,7 +10858,7 @@ async function cleanUpCacheDirectory() {
|
|
|
11032
10858
|
withFileTypes: true
|
|
11033
10859
|
});
|
|
11034
10860
|
for (const entry of cacheEntries) {
|
|
11035
|
-
const entryPath =
|
|
10861
|
+
const entryPath = path11.join(CANVAS_CACHE_DIR, entry.name);
|
|
11036
10862
|
if (entry.isDirectory()) {
|
|
11037
10863
|
await fs2.rm(entryPath, { recursive: true, force: true });
|
|
11038
10864
|
} else {
|
|
@@ -11040,7 +10866,7 @@ async function cleanUpCacheDirectory() {
|
|
|
11040
10866
|
}
|
|
11041
10867
|
}
|
|
11042
10868
|
} catch (error) {
|
|
11043
|
-
|
|
10869
|
+
p.note(
|
|
11044
10870
|
chalk2.red(
|
|
11045
10871
|
`Failed to clean cache directory contents: ${error instanceof Error ? error.message : String(error)}`
|
|
11046
10872
|
)
|
|
@@ -11057,7 +10883,7 @@ async function getAllClassNameCandidatesFromCacheDir(componentsToDownload, local
|
|
|
11057
10883
|
const cacheEntries = await promises.readdir(CANVAS_CACHE_DIR, {
|
|
11058
10884
|
withFileTypes: true
|
|
11059
10885
|
});
|
|
11060
|
-
const cacheDirs = cacheEntries.filter((entry) => entry.isDirectory()).map((dir) =>
|
|
10886
|
+
const cacheDirs = cacheEntries.filter((entry) => entry.isDirectory()).map((dir) => path11.join(CANVAS_CACHE_DIR, dir.name));
|
|
11061
10887
|
let allClassNameCandidates = [];
|
|
11062
10888
|
for (const cacheDir of cacheDirs) {
|
|
11063
10889
|
const componentClassNameCandidates = await getClassNameCandidatesForComponent(cacheDir);
|
|
@@ -11075,16 +10901,16 @@ async function buildTailwindCss(classNameCandidates, globalSourceCodeCss, distDi
|
|
|
11075
10901
|
globalSourceCodeCss
|
|
11076
10902
|
);
|
|
11077
10903
|
const transformedTwCss = await transformCss(compiledTwCss);
|
|
11078
|
-
await promises.writeFile(
|
|
10904
|
+
await promises.writeFile(path11.join(distDir, "index.css"), transformedTwCss);
|
|
11079
10905
|
}
|
|
11080
10906
|
async function getClassNameCandidatesForComponent(dir) {
|
|
11081
|
-
const componentName =
|
|
10907
|
+
const componentName = path11.basename(dir);
|
|
11082
10908
|
const config2 = getConfig();
|
|
11083
10909
|
const componentsDir = config2.componentDir;
|
|
11084
|
-
const distDir =
|
|
11085
|
-
const jsSource = await promises.readFile(
|
|
10910
|
+
const distDir = path11.join(componentsDir, "dist");
|
|
10911
|
+
const jsSource = await promises.readFile(path11.join(dir, "index.jsx"), "utf-8");
|
|
11086
10912
|
const currentGlobalSourceCodeJs = await promises.readFile(
|
|
11087
|
-
|
|
10913
|
+
path11.join(distDir, "index.js"),
|
|
11088
10914
|
"utf-8"
|
|
11089
10915
|
);
|
|
11090
10916
|
const classNameCandidates = OE(jsSource);
|
|
@@ -11093,7 +10919,7 @@ async function getClassNameCandidatesForComponent(dir) {
|
|
|
11093
10919
|
componentName,
|
|
11094
10920
|
classNameCandidates
|
|
11095
10921
|
);
|
|
11096
|
-
await promises.writeFile(
|
|
10922
|
+
await promises.writeFile(path11.join(distDir, "index.js"), globalJSClassNameIndex);
|
|
11097
10923
|
return nextClassNameCandidates;
|
|
11098
10924
|
}
|
|
11099
10925
|
async function buildTailwindForComponents(selectedComponents) {
|
|
@@ -11104,9 +10930,9 @@ async function buildTailwindForComponents(selectedComponents) {
|
|
|
11104
10930
|
const globalAssetLibrary = await apiService.getGlobalAssetLibrary();
|
|
11105
10931
|
const globalSourceCodeJs = globalAssetLibrary.js.original;
|
|
11106
10932
|
const globalSourceCodeCss = globalAssetLibrary.css.original;
|
|
11107
|
-
const distDir =
|
|
10933
|
+
const distDir = path11.join(config2.componentDir, "dist");
|
|
11108
10934
|
await promises.mkdir(distDir, { recursive: true });
|
|
11109
|
-
const targetFile =
|
|
10935
|
+
const targetFile = path11.join(distDir, "index.js");
|
|
11110
10936
|
await promises.writeFile(targetFile, globalSourceCodeJs, "utf-8");
|
|
11111
10937
|
const allClassNameCandidates = await getAllClassNameCandidatesFromCacheDir(
|
|
11112
10938
|
onlineComponents,
|
|
@@ -11169,16 +10995,49 @@ async function fileExists(filePath) {
|
|
|
11169
10995
|
async function directoryExists(dirPath) {
|
|
11170
10996
|
return await fs2.stat(dirPath).then(() => true).catch(() => false);
|
|
11171
10997
|
}
|
|
10998
|
+
async function validateComponent(componentDir, fix = false) {
|
|
10999
|
+
const eslint = new ESLint({
|
|
11000
|
+
overrideConfigFile: true,
|
|
11001
|
+
overrideConfig: required,
|
|
11002
|
+
fix
|
|
11003
|
+
});
|
|
11004
|
+
const eslintResults = await eslint.lintFiles(componentDir + "/**/*");
|
|
11005
|
+
if (fix) {
|
|
11006
|
+
await ESLint.outputFixes(eslintResults);
|
|
11007
|
+
}
|
|
11008
|
+
const success = eslintResults.every((result) => result.errorCount === 0);
|
|
11009
|
+
const details = [];
|
|
11010
|
+
eslintResults.filter((result) => result.errorCount > 0).forEach((result) => {
|
|
11011
|
+
const messages = result.messages.map(
|
|
11012
|
+
(msg) => `Line ${msg.line}, Column ${msg.column}: ` + msg.message + (msg.ruleId ? ` (${msg.ruleId})` : "")
|
|
11013
|
+
);
|
|
11014
|
+
details.push({
|
|
11015
|
+
heading: path11.relative(process.cwd(), result.filePath),
|
|
11016
|
+
content: messages.join("\n\n")
|
|
11017
|
+
});
|
|
11018
|
+
});
|
|
11019
|
+
return {
|
|
11020
|
+
itemName: basename(componentDir),
|
|
11021
|
+
success,
|
|
11022
|
+
details
|
|
11023
|
+
};
|
|
11024
|
+
}
|
|
11172
11025
|
|
|
11173
11026
|
// src/utils/build.ts
|
|
11174
11027
|
async function buildComponent(componentDir) {
|
|
11175
|
-
const componentName =
|
|
11028
|
+
const componentName = path11.basename(componentDir);
|
|
11176
11029
|
const result = {
|
|
11177
11030
|
itemName: componentName,
|
|
11178
11031
|
success: true,
|
|
11179
11032
|
details: []
|
|
11180
11033
|
};
|
|
11181
|
-
const
|
|
11034
|
+
const validationResult = await validateComponent(componentDir);
|
|
11035
|
+
if (!validationResult.success) {
|
|
11036
|
+
result.success = false;
|
|
11037
|
+
result.details = validationResult.details;
|
|
11038
|
+
return result;
|
|
11039
|
+
}
|
|
11040
|
+
const distDir = path11.join(componentDir, "dist");
|
|
11182
11041
|
try {
|
|
11183
11042
|
await promises.mkdir(distDir, { recursive: true });
|
|
11184
11043
|
} catch (error) {
|
|
@@ -11191,11 +11050,11 @@ async function buildComponent(componentDir) {
|
|
|
11191
11050
|
}
|
|
11192
11051
|
try {
|
|
11193
11052
|
const jsSource = await promises.readFile(
|
|
11194
|
-
|
|
11053
|
+
path11.join(componentDir, "index.jsx"),
|
|
11195
11054
|
"utf-8"
|
|
11196
11055
|
);
|
|
11197
11056
|
const jsCompiled = compileJS(jsSource);
|
|
11198
|
-
await promises.writeFile(
|
|
11057
|
+
await promises.writeFile(path11.join(distDir, "index.js"), jsCompiled);
|
|
11199
11058
|
} catch (error) {
|
|
11200
11059
|
result.success = false;
|
|
11201
11060
|
result.details?.push({
|
|
@@ -11207,7 +11066,7 @@ async function buildComponent(componentDir) {
|
|
|
11207
11066
|
const globalAssetLibrary = await apiService.getGlobalAssetLibrary();
|
|
11208
11067
|
const globalSourceCodeCss = globalAssetLibrary.css.original;
|
|
11209
11068
|
try {
|
|
11210
|
-
const cssPath =
|
|
11069
|
+
const cssPath = path11.join(componentDir, "index.css");
|
|
11211
11070
|
const cssFileExists = await fileExists(cssPath);
|
|
11212
11071
|
if (cssFileExists) {
|
|
11213
11072
|
const cssSource = await promises.readFile(cssPath, "utf-8");
|
|
@@ -11216,7 +11075,7 @@ async function buildComponent(componentDir) {
|
|
|
11216
11075
|
globalSourceCodeCss
|
|
11217
11076
|
);
|
|
11218
11077
|
const cssTranspiled = await transformCss(cssCompiled);
|
|
11219
|
-
await promises.writeFile(
|
|
11078
|
+
await promises.writeFile(path11.join(distDir, "index.css"), cssTranspiled);
|
|
11220
11079
|
}
|
|
11221
11080
|
} catch (error) {
|
|
11222
11081
|
result.success = false;
|
|
@@ -11227,56 +11086,238 @@ async function buildComponent(componentDir) {
|
|
|
11227
11086
|
}
|
|
11228
11087
|
return result;
|
|
11229
11088
|
}
|
|
11230
|
-
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
const summary = `${succeededText}, ${failedText}`;
|
|
11238
|
-
if (results.length > 0) {
|
|
11239
|
-
const tableData = [
|
|
11240
|
-
hasDetails ? [chalk2.bold(title), "", ""] : [chalk2.bold(title), ""],
|
|
11241
|
-
hasDetails ? [itemLabel, "Status", "Details"] : [itemLabel, "Status"],
|
|
11242
|
-
...results.map(
|
|
11243
|
-
(r) => hasDetails ? [
|
|
11244
|
-
r.itemName,
|
|
11245
|
-
r.success ? chalk2.green("Success") : chalk2.red("Failed"),
|
|
11246
|
-
r.details?.map(
|
|
11247
|
-
(d2) => d2.heading ? `${chalk2.underline(d2.heading)}:
|
|
11248
|
-
${d2.content}` : d2.content
|
|
11249
|
-
).join("\n\n")
|
|
11250
|
-
] : [
|
|
11251
|
-
r.itemName,
|
|
11252
|
-
r.success ? chalk2.green("Success") : chalk2.red("Failed")
|
|
11253
|
-
]
|
|
11254
|
-
),
|
|
11255
|
-
hasDetails ? ["SUMMARY", "", summary] : ["SUMMARY", summary]
|
|
11256
|
-
];
|
|
11257
|
-
p9.log.info(
|
|
11258
|
-
table(tableData, {
|
|
11259
|
-
spanningCells: [
|
|
11260
|
-
{
|
|
11261
|
-
row: 0,
|
|
11262
|
-
col: 0,
|
|
11263
|
-
colSpan: hasDetails ? 3 : 2,
|
|
11264
|
-
alignment: "center"
|
|
11265
|
-
},
|
|
11266
|
-
{
|
|
11267
|
-
row: results.length + 2,
|
|
11268
|
-
col: 0,
|
|
11269
|
-
colSpan: hasDetails ? 2 : 1,
|
|
11270
|
-
alignment: hasDetails ? "right" : "left"
|
|
11271
|
-
}
|
|
11272
|
-
]
|
|
11273
|
-
})
|
|
11089
|
+
|
|
11090
|
+
// src/utils/command-helpers.ts
|
|
11091
|
+
var ALL_COMPONENTS_SELECTOR = "_allComponents";
|
|
11092
|
+
function validateComponentOptions(options) {
|
|
11093
|
+
if (options.components && options.all) {
|
|
11094
|
+
throw new Error(
|
|
11095
|
+
"Cannot use --all and --components options together. Please use either:\n \u2022 --components to specify specific components, or\n \u2022 --all to process everything."
|
|
11274
11096
|
);
|
|
11275
11097
|
}
|
|
11276
11098
|
}
|
|
11099
|
+
function updateConfigFromOptions(options) {
|
|
11100
|
+
if (options.clientId) setConfig({ clientId: options.clientId });
|
|
11101
|
+
if (options.clientSecret) setConfig({ clientSecret: options.clientSecret });
|
|
11102
|
+
if (options.siteUrl) setConfig({ siteUrl: options.siteUrl });
|
|
11103
|
+
if (options.dir) setConfig({ componentDir: options.dir });
|
|
11104
|
+
if (options.scope) setConfig({ scope: options.scope });
|
|
11105
|
+
if (options.all) setConfig({ all: options.all });
|
|
11106
|
+
if (options.verbose) setConfig({ verbose: true });
|
|
11107
|
+
}
|
|
11108
|
+
function pluralizeComponent(count) {
|
|
11109
|
+
return count === 1 ? "component" : "components";
|
|
11110
|
+
}
|
|
11111
|
+
|
|
11112
|
+
// ../node_modules/@isaacs/balanced-match/dist/esm/index.js
|
|
11113
|
+
var balanced = (a, b, str) => {
|
|
11114
|
+
const ma2 = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
11115
|
+
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
11116
|
+
const r = ma2 !== null && mb != null && range(ma2, mb, str);
|
|
11117
|
+
return r && {
|
|
11118
|
+
start: r[0],
|
|
11119
|
+
end: r[1],
|
|
11120
|
+
pre: str.slice(0, r[0]),
|
|
11121
|
+
body: str.slice(r[0] + ma2.length, r[1]),
|
|
11122
|
+
post: str.slice(r[1] + mb.length)
|
|
11123
|
+
};
|
|
11124
|
+
};
|
|
11125
|
+
var maybeMatch = (reg, str) => {
|
|
11126
|
+
const m = str.match(reg);
|
|
11127
|
+
return m ? m[0] : null;
|
|
11128
|
+
};
|
|
11129
|
+
var range = (a, b, str) => {
|
|
11130
|
+
let begs, beg, left, right = void 0, result;
|
|
11131
|
+
let ai2 = str.indexOf(a);
|
|
11132
|
+
let bi2 = str.indexOf(b, ai2 + 1);
|
|
11133
|
+
let i = ai2;
|
|
11134
|
+
if (ai2 >= 0 && bi2 > 0) {
|
|
11135
|
+
if (a === b) {
|
|
11136
|
+
return [ai2, bi2];
|
|
11137
|
+
}
|
|
11138
|
+
begs = [];
|
|
11139
|
+
left = str.length;
|
|
11140
|
+
while (i >= 0 && !result) {
|
|
11141
|
+
if (i === ai2) {
|
|
11142
|
+
begs.push(i);
|
|
11143
|
+
ai2 = str.indexOf(a, i + 1);
|
|
11144
|
+
} else if (begs.length === 1) {
|
|
11145
|
+
const r = begs.pop();
|
|
11146
|
+
if (r !== void 0)
|
|
11147
|
+
result = [r, bi2];
|
|
11148
|
+
} else {
|
|
11149
|
+
beg = begs.pop();
|
|
11150
|
+
if (beg !== void 0 && beg < left) {
|
|
11151
|
+
left = beg;
|
|
11152
|
+
right = bi2;
|
|
11153
|
+
}
|
|
11154
|
+
bi2 = str.indexOf(b, i + 1);
|
|
11155
|
+
}
|
|
11156
|
+
i = ai2 < bi2 && ai2 >= 0 ? ai2 : bi2;
|
|
11157
|
+
}
|
|
11158
|
+
if (begs.length && right !== void 0) {
|
|
11159
|
+
result = [left, right];
|
|
11160
|
+
}
|
|
11161
|
+
}
|
|
11162
|
+
return result;
|
|
11163
|
+
};
|
|
11277
11164
|
|
|
11278
|
-
// ../node_modules/
|
|
11279
|
-
var
|
|
11165
|
+
// ../node_modules/@isaacs/brace-expansion/dist/esm/index.js
|
|
11166
|
+
var escSlash = "\0SLASH" + Math.random() + "\0";
|
|
11167
|
+
var escOpen = "\0OPEN" + Math.random() + "\0";
|
|
11168
|
+
var escClose = "\0CLOSE" + Math.random() + "\0";
|
|
11169
|
+
var escComma = "\0COMMA" + Math.random() + "\0";
|
|
11170
|
+
var escPeriod = "\0PERIOD" + Math.random() + "\0";
|
|
11171
|
+
var escSlashPattern = new RegExp(escSlash, "g");
|
|
11172
|
+
var escOpenPattern = new RegExp(escOpen, "g");
|
|
11173
|
+
var escClosePattern = new RegExp(escClose, "g");
|
|
11174
|
+
var escCommaPattern = new RegExp(escComma, "g");
|
|
11175
|
+
var escPeriodPattern = new RegExp(escPeriod, "g");
|
|
11176
|
+
var slashPattern = /\\\\/g;
|
|
11177
|
+
var openPattern = /\\{/g;
|
|
11178
|
+
var closePattern = /\\}/g;
|
|
11179
|
+
var commaPattern = /\\,/g;
|
|
11180
|
+
var periodPattern = /\\./g;
|
|
11181
|
+
function numeric(str) {
|
|
11182
|
+
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
|
11183
|
+
}
|
|
11184
|
+
function escapeBraces(str) {
|
|
11185
|
+
return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
|
|
11186
|
+
}
|
|
11187
|
+
function unescapeBraces(str) {
|
|
11188
|
+
return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
|
|
11189
|
+
}
|
|
11190
|
+
function parseCommaParts(str) {
|
|
11191
|
+
if (!str) {
|
|
11192
|
+
return [""];
|
|
11193
|
+
}
|
|
11194
|
+
const parts = [];
|
|
11195
|
+
const m = balanced("{", "}", str);
|
|
11196
|
+
if (!m) {
|
|
11197
|
+
return str.split(",");
|
|
11198
|
+
}
|
|
11199
|
+
const { pre, body, post } = m;
|
|
11200
|
+
const p13 = pre.split(",");
|
|
11201
|
+
p13[p13.length - 1] += "{" + body + "}";
|
|
11202
|
+
const postParts = parseCommaParts(post);
|
|
11203
|
+
if (post.length) {
|
|
11204
|
+
p13[p13.length - 1] += postParts.shift();
|
|
11205
|
+
p13.push.apply(p13, postParts);
|
|
11206
|
+
}
|
|
11207
|
+
parts.push.apply(parts, p13);
|
|
11208
|
+
return parts;
|
|
11209
|
+
}
|
|
11210
|
+
function expand(str) {
|
|
11211
|
+
if (!str) {
|
|
11212
|
+
return [];
|
|
11213
|
+
}
|
|
11214
|
+
if (str.slice(0, 2) === "{}") {
|
|
11215
|
+
str = "\\{\\}" + str.slice(2);
|
|
11216
|
+
}
|
|
11217
|
+
return expand_(escapeBraces(str), true).map(unescapeBraces);
|
|
11218
|
+
}
|
|
11219
|
+
function embrace(str) {
|
|
11220
|
+
return "{" + str + "}";
|
|
11221
|
+
}
|
|
11222
|
+
function isPadded(el2) {
|
|
11223
|
+
return /^-?0\d/.test(el2);
|
|
11224
|
+
}
|
|
11225
|
+
function lte(i, y) {
|
|
11226
|
+
return i <= y;
|
|
11227
|
+
}
|
|
11228
|
+
function gte(i, y) {
|
|
11229
|
+
return i >= y;
|
|
11230
|
+
}
|
|
11231
|
+
function expand_(str, isTop) {
|
|
11232
|
+
const expansions = [];
|
|
11233
|
+
const m = balanced("{", "}", str);
|
|
11234
|
+
if (!m)
|
|
11235
|
+
return [str];
|
|
11236
|
+
const pre = m.pre;
|
|
11237
|
+
const post = m.post.length ? expand_(m.post, false) : [""];
|
|
11238
|
+
if (/\$$/.test(m.pre)) {
|
|
11239
|
+
for (let k = 0; k < post.length; k++) {
|
|
11240
|
+
const expansion = pre + "{" + m.body + "}" + post[k];
|
|
11241
|
+
expansions.push(expansion);
|
|
11242
|
+
}
|
|
11243
|
+
} else {
|
|
11244
|
+
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
11245
|
+
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
11246
|
+
const isSequence = isNumericSequence || isAlphaSequence;
|
|
11247
|
+
const isOptions = m.body.indexOf(",") >= 0;
|
|
11248
|
+
if (!isSequence && !isOptions) {
|
|
11249
|
+
if (m.post.match(/,(?!,).*\}/)) {
|
|
11250
|
+
str = m.pre + "{" + m.body + escClose + m.post;
|
|
11251
|
+
return expand_(str);
|
|
11252
|
+
}
|
|
11253
|
+
return [str];
|
|
11254
|
+
}
|
|
11255
|
+
let n;
|
|
11256
|
+
if (isSequence) {
|
|
11257
|
+
n = m.body.split(/\.\./);
|
|
11258
|
+
} else {
|
|
11259
|
+
n = parseCommaParts(m.body);
|
|
11260
|
+
if (n.length === 1 && n[0] !== void 0) {
|
|
11261
|
+
n = expand_(n[0], false).map(embrace);
|
|
11262
|
+
if (n.length === 1) {
|
|
11263
|
+
return post.map((p13) => m.pre + n[0] + p13);
|
|
11264
|
+
}
|
|
11265
|
+
}
|
|
11266
|
+
}
|
|
11267
|
+
let N;
|
|
11268
|
+
if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
|
|
11269
|
+
const x = numeric(n[0]);
|
|
11270
|
+
const y = numeric(n[1]);
|
|
11271
|
+
const width = Math.max(n[0].length, n[1].length);
|
|
11272
|
+
let incr = n.length === 3 && n[2] !== void 0 ? Math.abs(numeric(n[2])) : 1;
|
|
11273
|
+
let test = lte;
|
|
11274
|
+
const reverse = y < x;
|
|
11275
|
+
if (reverse) {
|
|
11276
|
+
incr *= -1;
|
|
11277
|
+
test = gte;
|
|
11278
|
+
}
|
|
11279
|
+
const pad = n.some(isPadded);
|
|
11280
|
+
N = [];
|
|
11281
|
+
for (let i = x; test(i, y); i += incr) {
|
|
11282
|
+
let c;
|
|
11283
|
+
if (isAlphaSequence) {
|
|
11284
|
+
c = String.fromCharCode(i);
|
|
11285
|
+
if (c === "\\") {
|
|
11286
|
+
c = "";
|
|
11287
|
+
}
|
|
11288
|
+
} else {
|
|
11289
|
+
c = String(i);
|
|
11290
|
+
if (pad) {
|
|
11291
|
+
const need = width - c.length;
|
|
11292
|
+
if (need > 0) {
|
|
11293
|
+
const z = new Array(need + 1).join("0");
|
|
11294
|
+
if (i < 0) {
|
|
11295
|
+
c = "-" + z + c.slice(1);
|
|
11296
|
+
} else {
|
|
11297
|
+
c = z + c;
|
|
11298
|
+
}
|
|
11299
|
+
}
|
|
11300
|
+
}
|
|
11301
|
+
}
|
|
11302
|
+
N.push(c);
|
|
11303
|
+
}
|
|
11304
|
+
} else {
|
|
11305
|
+
N = [];
|
|
11306
|
+
for (let j = 0; j < n.length; j++) {
|
|
11307
|
+
N.push.apply(N, expand_(n[j], false));
|
|
11308
|
+
}
|
|
11309
|
+
}
|
|
11310
|
+
for (let j = 0; j < N.length; j++) {
|
|
11311
|
+
for (let k = 0; k < post.length; k++) {
|
|
11312
|
+
const expansion = pre + N[j] + post[k];
|
|
11313
|
+
if (!isTop || isSequence || expansion) {
|
|
11314
|
+
expansions.push(expansion);
|
|
11315
|
+
}
|
|
11316
|
+
}
|
|
11317
|
+
}
|
|
11318
|
+
}
|
|
11319
|
+
return expansions;
|
|
11320
|
+
}
|
|
11280
11321
|
|
|
11281
11322
|
// ../node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
11282
11323
|
var MAX_PATTERN_LENGTH = 1024 * 64;
|
|
@@ -11399,8 +11440,11 @@ var parseClass = (glob2, position) => {
|
|
|
11399
11440
|
};
|
|
11400
11441
|
|
|
11401
11442
|
// ../node_modules/glob/node_modules/minimatch/dist/esm/unescape.js
|
|
11402
|
-
var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
11403
|
-
|
|
11443
|
+
var unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
|
|
11444
|
+
if (magicalBraces) {
|
|
11445
|
+
return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
|
11446
|
+
}
|
|
11447
|
+
return windowsPathsNoEscape ? s.replace(/\[([^\/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\{}])\]/g, "$1$2").replace(/\\([^\/{}])/g, "$1");
|
|
11404
11448
|
};
|
|
11405
11449
|
|
|
11406
11450
|
// ../node_modules/glob/node_modules/minimatch/dist/esm/ast.js
|
|
@@ -11445,10 +11489,10 @@ var AST = class _AST {
|
|
|
11445
11489
|
get hasMagic() {
|
|
11446
11490
|
if (this.#hasMagic !== void 0)
|
|
11447
11491
|
return this.#hasMagic;
|
|
11448
|
-
for (const
|
|
11449
|
-
if (typeof
|
|
11492
|
+
for (const p13 of this.#parts) {
|
|
11493
|
+
if (typeof p13 === "string")
|
|
11450
11494
|
continue;
|
|
11451
|
-
if (
|
|
11495
|
+
if (p13.type || p13.hasMagic)
|
|
11452
11496
|
return this.#hasMagic = true;
|
|
11453
11497
|
}
|
|
11454
11498
|
return this.#hasMagic;
|
|
@@ -11458,9 +11502,9 @@ var AST = class _AST {
|
|
|
11458
11502
|
if (this.#toString !== void 0)
|
|
11459
11503
|
return this.#toString;
|
|
11460
11504
|
if (!this.type) {
|
|
11461
|
-
return this.#toString = this.#parts.map((
|
|
11505
|
+
return this.#toString = this.#parts.map((p13) => String(p13)).join("");
|
|
11462
11506
|
} else {
|
|
11463
|
-
return this.#toString = this.type + "(" + this.#parts.map((
|
|
11507
|
+
return this.#toString = this.type + "(" + this.#parts.map((p13) => String(p13)).join("|") + ")";
|
|
11464
11508
|
}
|
|
11465
11509
|
}
|
|
11466
11510
|
#fillNegs() {
|
|
@@ -11474,10 +11518,10 @@ var AST = class _AST {
|
|
|
11474
11518
|
while (n = this.#negs.pop()) {
|
|
11475
11519
|
if (n.type !== "!")
|
|
11476
11520
|
continue;
|
|
11477
|
-
let
|
|
11478
|
-
let pp =
|
|
11521
|
+
let p13 = n;
|
|
11522
|
+
let pp = p13.#parent;
|
|
11479
11523
|
while (pp) {
|
|
11480
|
-
for (let i =
|
|
11524
|
+
for (let i = p13.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) {
|
|
11481
11525
|
for (const part of n.#parts) {
|
|
11482
11526
|
if (typeof part === "string") {
|
|
11483
11527
|
throw new Error("string part in extglob AST??");
|
|
@@ -11485,24 +11529,24 @@ var AST = class _AST {
|
|
|
11485
11529
|
part.copyIn(pp.#parts[i]);
|
|
11486
11530
|
}
|
|
11487
11531
|
}
|
|
11488
|
-
|
|
11489
|
-
pp =
|
|
11532
|
+
p13 = pp;
|
|
11533
|
+
pp = p13.#parent;
|
|
11490
11534
|
}
|
|
11491
11535
|
}
|
|
11492
11536
|
return this;
|
|
11493
11537
|
}
|
|
11494
11538
|
push(...parts) {
|
|
11495
|
-
for (const
|
|
11496
|
-
if (
|
|
11539
|
+
for (const p13 of parts) {
|
|
11540
|
+
if (p13 === "")
|
|
11497
11541
|
continue;
|
|
11498
|
-
if (typeof
|
|
11499
|
-
throw new Error("invalid part: " +
|
|
11542
|
+
if (typeof p13 !== "string" && !(p13 instanceof _AST && p13.#parent === this)) {
|
|
11543
|
+
throw new Error("invalid part: " + p13);
|
|
11500
11544
|
}
|
|
11501
|
-
this.#parts.push(
|
|
11545
|
+
this.#parts.push(p13);
|
|
11502
11546
|
}
|
|
11503
11547
|
}
|
|
11504
11548
|
toJSON() {
|
|
11505
|
-
const ret = this.type === null ? this.#parts.slice().map((
|
|
11549
|
+
const ret = this.type === null ? this.#parts.slice().map((p13) => typeof p13 === "string" ? p13 : p13.toJSON()) : [this.type, ...this.#parts.map((p13) => p13.toJSON())];
|
|
11506
11550
|
if (this.isStart() && !this.type)
|
|
11507
11551
|
ret.unshift([]);
|
|
11508
11552
|
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) {
|
|
@@ -11517,9 +11561,9 @@ var AST = class _AST {
|
|
|
11517
11561
|
return false;
|
|
11518
11562
|
if (this.#parentIndex === 0)
|
|
11519
11563
|
return true;
|
|
11520
|
-
const
|
|
11564
|
+
const p13 = this.#parent;
|
|
11521
11565
|
for (let i = 0; i < this.#parentIndex; i++) {
|
|
11522
|
-
const pp =
|
|
11566
|
+
const pp = p13.#parts[i];
|
|
11523
11567
|
if (!(pp instanceof _AST && pp.type === "!")) {
|
|
11524
11568
|
return false;
|
|
11525
11569
|
}
|
|
@@ -11546,8 +11590,8 @@ var AST = class _AST {
|
|
|
11546
11590
|
}
|
|
11547
11591
|
clone(parent) {
|
|
11548
11592
|
const c = new _AST(this.type, parent);
|
|
11549
|
-
for (const
|
|
11550
|
-
c.copyIn(
|
|
11593
|
+
for (const p13 of this.#parts) {
|
|
11594
|
+
c.copyIn(p13);
|
|
11551
11595
|
}
|
|
11552
11596
|
return c;
|
|
11553
11597
|
}
|
|
@@ -11754,9 +11798,9 @@ var AST = class _AST {
|
|
|
11754
11798
|
if (this.#root === this)
|
|
11755
11799
|
this.#fillNegs();
|
|
11756
11800
|
if (!this.type) {
|
|
11757
|
-
const noEmpty = this.isStart() && this.isEnd();
|
|
11758
|
-
const src = this.#parts.map((
|
|
11759
|
-
const [re, _2, hasMagic2, uflag] = typeof
|
|
11801
|
+
const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s) => typeof s !== "string");
|
|
11802
|
+
const src = this.#parts.map((p13) => {
|
|
11803
|
+
const [re, _2, hasMagic2, uflag] = typeof p13 === "string" ? _AST.#parseGlob(p13, this.#hasMagic, noEmpty) : p13.toRegExpSource(allowDot);
|
|
11760
11804
|
this.#hasMagic = this.#hasMagic || hasMagic2;
|
|
11761
11805
|
this.#uflag = this.#uflag || uflag;
|
|
11762
11806
|
return re;
|
|
@@ -11825,14 +11869,14 @@ var AST = class _AST {
|
|
|
11825
11869
|
];
|
|
11826
11870
|
}
|
|
11827
11871
|
#partsToRegExp(dot) {
|
|
11828
|
-
return this.#parts.map((
|
|
11829
|
-
if (typeof
|
|
11872
|
+
return this.#parts.map((p13) => {
|
|
11873
|
+
if (typeof p13 === "string") {
|
|
11830
11874
|
throw new Error("string type in extglob ast??");
|
|
11831
11875
|
}
|
|
11832
|
-
const [re, _2, _hasMagic, uflag] =
|
|
11876
|
+
const [re, _2, _hasMagic, uflag] = p13.toRegExpSource(dot);
|
|
11833
11877
|
this.#uflag = this.#uflag || uflag;
|
|
11834
11878
|
return re;
|
|
11835
|
-
}).filter((
|
|
11879
|
+
}).filter((p13) => !(this.isStart() && this.isEnd()) || !!p13).join("|");
|
|
11836
11880
|
}
|
|
11837
11881
|
static #parseGlob(glob2, hasMagic2, noEmpty = false) {
|
|
11838
11882
|
let escaping = false;
|
|
@@ -11864,10 +11908,7 @@ var AST = class _AST {
|
|
|
11864
11908
|
}
|
|
11865
11909
|
}
|
|
11866
11910
|
if (c === "*") {
|
|
11867
|
-
|
|
11868
|
-
re += starNoEmpty;
|
|
11869
|
-
else
|
|
11870
|
-
re += star;
|
|
11911
|
+
re += noEmpty && glob2 === "*" ? starNoEmpty : star;
|
|
11871
11912
|
hasMagic2 = true;
|
|
11872
11913
|
continue;
|
|
11873
11914
|
}
|
|
@@ -11883,17 +11924,20 @@ var AST = class _AST {
|
|
|
11883
11924
|
};
|
|
11884
11925
|
|
|
11885
11926
|
// ../node_modules/glob/node_modules/minimatch/dist/esm/escape.js
|
|
11886
|
-
var escape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
11927
|
+
var escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
|
|
11928
|
+
if (magicalBraces) {
|
|
11929
|
+
return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&");
|
|
11930
|
+
}
|
|
11887
11931
|
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
11888
11932
|
};
|
|
11889
11933
|
|
|
11890
11934
|
// ../node_modules/glob/node_modules/minimatch/dist/esm/index.js
|
|
11891
|
-
var minimatch = (
|
|
11935
|
+
var minimatch = (p13, pattern, options = {}) => {
|
|
11892
11936
|
assertValidPattern(pattern);
|
|
11893
11937
|
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
11894
11938
|
return false;
|
|
11895
11939
|
}
|
|
11896
|
-
return new Minimatch(pattern, options).match(
|
|
11940
|
+
return new Minimatch(pattern, options).match(p13);
|
|
11897
11941
|
};
|
|
11898
11942
|
var starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
11899
11943
|
var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
|
|
@@ -11946,11 +11990,11 @@ var qmarksTestNoExtDot = ([$02]) => {
|
|
|
11946
11990
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
11947
11991
|
};
|
|
11948
11992
|
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
11949
|
-
var
|
|
11993
|
+
var path6 = {
|
|
11950
11994
|
win32: { sep: "\\" },
|
|
11951
11995
|
posix: { sep: "/" }
|
|
11952
11996
|
};
|
|
11953
|
-
var sep = defaultPlatform === "win32" ?
|
|
11997
|
+
var sep = defaultPlatform === "win32" ? path6.win32.sep : path6.posix.sep;
|
|
11954
11998
|
minimatch.sep = sep;
|
|
11955
11999
|
var GLOBSTAR = Symbol("globstar **");
|
|
11956
12000
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -11958,7 +12002,7 @@ var qmark2 = "[^/]";
|
|
|
11958
12002
|
var star2 = qmark2 + "*?";
|
|
11959
12003
|
var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
11960
12004
|
var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
11961
|
-
var filter = (pattern, options = {}) => (
|
|
12005
|
+
var filter = (pattern, options = {}) => (p13) => minimatch(p13, pattern, options);
|
|
11962
12006
|
minimatch.filter = filter;
|
|
11963
12007
|
var ext = (a, b = {}) => Object.assign({}, a, b);
|
|
11964
12008
|
var defaults = (def) => {
|
|
@@ -11966,7 +12010,7 @@ var defaults = (def) => {
|
|
|
11966
12010
|
return minimatch;
|
|
11967
12011
|
}
|
|
11968
12012
|
const orig = minimatch;
|
|
11969
|
-
const m = (
|
|
12013
|
+
const m = (p13, pattern, options = {}) => orig(p13, pattern, ext(def, options));
|
|
11970
12014
|
return Object.assign(m, {
|
|
11971
12015
|
Minimatch: class Minimatch extends orig.Minimatch {
|
|
11972
12016
|
constructor(pattern, options = {}) {
|
|
@@ -12003,7 +12047,7 @@ var braceExpand = (pattern, options = {}) => {
|
|
|
12003
12047
|
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
|
12004
12048
|
return [pattern];
|
|
12005
12049
|
}
|
|
12006
|
-
return (
|
|
12050
|
+
return expand(pattern);
|
|
12007
12051
|
};
|
|
12008
12052
|
minimatch.braceExpand = braceExpand;
|
|
12009
12053
|
var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
@@ -12112,9 +12156,9 @@ var Minimatch = class {
|
|
|
12112
12156
|
this.set = set.filter((s) => s.indexOf(false) === -1);
|
|
12113
12157
|
if (this.isWindows) {
|
|
12114
12158
|
for (let i = 0; i < this.set.length; i++) {
|
|
12115
|
-
const
|
|
12116
|
-
if (
|
|
12117
|
-
|
|
12159
|
+
const p13 = this.set[i];
|
|
12160
|
+
if (p13[0] === "" && p13[1] === "" && this.globParts[i][2] === "?" && typeof p13[3] === "string" && /^[a-z]:$/i.test(p13[3])) {
|
|
12161
|
+
p13[2] = "?";
|
|
12118
12162
|
}
|
|
12119
12163
|
}
|
|
12120
12164
|
}
|
|
@@ -12191,10 +12235,10 @@ var Minimatch = class {
|
|
|
12191
12235
|
didSomething = false;
|
|
12192
12236
|
if (!this.preserveMultipleSlashes) {
|
|
12193
12237
|
for (let i = 1; i < parts.length - 1; i++) {
|
|
12194
|
-
const
|
|
12195
|
-
if (i === 1 &&
|
|
12238
|
+
const p13 = parts[i];
|
|
12239
|
+
if (i === 1 && p13 === "" && parts[0] === "")
|
|
12196
12240
|
continue;
|
|
12197
|
-
if (
|
|
12241
|
+
if (p13 === "." || p13 === "") {
|
|
12198
12242
|
didSomething = true;
|
|
12199
12243
|
parts.splice(i, 1);
|
|
12200
12244
|
i--;
|
|
@@ -12207,8 +12251,8 @@ var Minimatch = class {
|
|
|
12207
12251
|
}
|
|
12208
12252
|
let dd = 0;
|
|
12209
12253
|
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
12210
|
-
const
|
|
12211
|
-
if (
|
|
12254
|
+
const p13 = parts[dd - 1];
|
|
12255
|
+
if (p13 && p13 !== "." && p13 !== ".." && p13 !== "**") {
|
|
12212
12256
|
didSomething = true;
|
|
12213
12257
|
parts.splice(dd - 1, 2);
|
|
12214
12258
|
dd -= 2;
|
|
@@ -12250,11 +12294,11 @@ var Minimatch = class {
|
|
|
12250
12294
|
parts.splice(gs + 1, gss - gs);
|
|
12251
12295
|
}
|
|
12252
12296
|
let next = parts[gs + 1];
|
|
12253
|
-
const
|
|
12297
|
+
const p13 = parts[gs + 2];
|
|
12254
12298
|
const p22 = parts[gs + 3];
|
|
12255
12299
|
if (next !== "..")
|
|
12256
12300
|
continue;
|
|
12257
|
-
if (!
|
|
12301
|
+
if (!p13 || p13 === "." || p13 === ".." || !p22 || p22 === "." || p22 === "..") {
|
|
12258
12302
|
continue;
|
|
12259
12303
|
}
|
|
12260
12304
|
didSomething = true;
|
|
@@ -12266,10 +12310,10 @@ var Minimatch = class {
|
|
|
12266
12310
|
}
|
|
12267
12311
|
if (!this.preserveMultipleSlashes) {
|
|
12268
12312
|
for (let i = 1; i < parts.length - 1; i++) {
|
|
12269
|
-
const
|
|
12270
|
-
if (i === 1 &&
|
|
12313
|
+
const p13 = parts[i];
|
|
12314
|
+
if (i === 1 && p13 === "" && parts[0] === "")
|
|
12271
12315
|
continue;
|
|
12272
|
-
if (
|
|
12316
|
+
if (p13 === "." || p13 === "") {
|
|
12273
12317
|
didSomething = true;
|
|
12274
12318
|
parts.splice(i, 1);
|
|
12275
12319
|
i--;
|
|
@@ -12282,8 +12326,8 @@ var Minimatch = class {
|
|
|
12282
12326
|
}
|
|
12283
12327
|
let dd = 0;
|
|
12284
12328
|
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
12285
|
-
const
|
|
12286
|
-
if (
|
|
12329
|
+
const p13 = parts[dd - 1];
|
|
12330
|
+
if (p13 && p13 !== "." && p13 !== ".." && p13 !== "**") {
|
|
12287
12331
|
didSomething = true;
|
|
12288
12332
|
const needDot = dd === 1 && parts[dd + 1] === "**";
|
|
12289
12333
|
const splin = needDot ? ["."] : [];
|
|
@@ -12401,14 +12445,14 @@ var Minimatch = class {
|
|
|
12401
12445
|
this.debug("matchOne", file.length, pattern.length);
|
|
12402
12446
|
for (var fi2 = 0, pi2 = 0, fl2 = file.length, pl2 = pattern.length; fi2 < fl2 && pi2 < pl2; fi2++, pi2++) {
|
|
12403
12447
|
this.debug("matchOne loop");
|
|
12404
|
-
var
|
|
12448
|
+
var p13 = pattern[pi2];
|
|
12405
12449
|
var f = file[fi2];
|
|
12406
|
-
this.debug(pattern,
|
|
12407
|
-
if (
|
|
12450
|
+
this.debug(pattern, p13, f);
|
|
12451
|
+
if (p13 === false) {
|
|
12408
12452
|
return false;
|
|
12409
12453
|
}
|
|
12410
|
-
if (
|
|
12411
|
-
this.debug("GLOBSTAR", [pattern,
|
|
12454
|
+
if (p13 === GLOBSTAR) {
|
|
12455
|
+
this.debug("GLOBSTAR", [pattern, p13, f]);
|
|
12412
12456
|
var fr2 = fi2;
|
|
12413
12457
|
var pr2 = pi2 + 1;
|
|
12414
12458
|
if (pr2 === pl2) {
|
|
@@ -12443,12 +12487,12 @@ var Minimatch = class {
|
|
|
12443
12487
|
return false;
|
|
12444
12488
|
}
|
|
12445
12489
|
let hit;
|
|
12446
|
-
if (typeof
|
|
12447
|
-
hit = f ===
|
|
12448
|
-
this.debug("string match",
|
|
12490
|
+
if (typeof p13 === "string") {
|
|
12491
|
+
hit = f === p13;
|
|
12492
|
+
this.debug("string match", p13, f, hit);
|
|
12449
12493
|
} else {
|
|
12450
|
-
hit =
|
|
12451
|
-
this.debug("pattern match",
|
|
12494
|
+
hit = p13.test(f);
|
|
12495
|
+
this.debug("pattern match", p13, f, hit);
|
|
12452
12496
|
}
|
|
12453
12497
|
if (!hit)
|
|
12454
12498
|
return false;
|
|
@@ -12504,17 +12548,17 @@ var Minimatch = class {
|
|
|
12504
12548
|
const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
|
|
12505
12549
|
const flags = new Set(options.nocase ? ["i"] : []);
|
|
12506
12550
|
let re = set.map((pattern) => {
|
|
12507
|
-
const pp = pattern.map((
|
|
12508
|
-
if (
|
|
12509
|
-
for (const f of
|
|
12551
|
+
const pp = pattern.map((p13) => {
|
|
12552
|
+
if (p13 instanceof RegExp) {
|
|
12553
|
+
for (const f of p13.flags.split(""))
|
|
12510
12554
|
flags.add(f);
|
|
12511
12555
|
}
|
|
12512
|
-
return typeof
|
|
12556
|
+
return typeof p13 === "string" ? regExpEscape2(p13) : p13 === GLOBSTAR ? GLOBSTAR : p13._src;
|
|
12513
12557
|
});
|
|
12514
|
-
pp.forEach((
|
|
12558
|
+
pp.forEach((p13, i) => {
|
|
12515
12559
|
const next = pp[i + 1];
|
|
12516
12560
|
const prev = pp[i - 1];
|
|
12517
|
-
if (
|
|
12561
|
+
if (p13 !== GLOBSTAR || prev === GLOBSTAR) {
|
|
12518
12562
|
return;
|
|
12519
12563
|
}
|
|
12520
12564
|
if (prev === void 0) {
|
|
@@ -12524,16 +12568,27 @@ var Minimatch = class {
|
|
|
12524
12568
|
pp[i] = twoStar;
|
|
12525
12569
|
}
|
|
12526
12570
|
} else if (next === void 0) {
|
|
12527
|
-
pp[i - 1] = prev + "(
|
|
12571
|
+
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
|
|
12528
12572
|
} else if (next !== GLOBSTAR) {
|
|
12529
12573
|
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
12530
12574
|
pp[i + 1] = GLOBSTAR;
|
|
12531
12575
|
}
|
|
12532
12576
|
});
|
|
12533
|
-
|
|
12577
|
+
const filtered = pp.filter((p13) => p13 !== GLOBSTAR);
|
|
12578
|
+
if (this.partial && filtered.length >= 1) {
|
|
12579
|
+
const prefixes = [];
|
|
12580
|
+
for (let i = 1; i <= filtered.length; i++) {
|
|
12581
|
+
prefixes.push(filtered.slice(0, i).join("/"));
|
|
12582
|
+
}
|
|
12583
|
+
return "(?:" + prefixes.join("|") + ")";
|
|
12584
|
+
}
|
|
12585
|
+
return filtered.join("/");
|
|
12534
12586
|
}).join("|");
|
|
12535
12587
|
const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
12536
12588
|
re = "^" + open + re + close + "$";
|
|
12589
|
+
if (this.partial) {
|
|
12590
|
+
re = "^(?:\\/|" + open + re.slice(1, -1) + close + ")$";
|
|
12591
|
+
}
|
|
12537
12592
|
if (this.negate)
|
|
12538
12593
|
re = "^(?!" + re + ").+$";
|
|
12539
12594
|
try {
|
|
@@ -12543,13 +12598,13 @@ var Minimatch = class {
|
|
|
12543
12598
|
}
|
|
12544
12599
|
return this.regexp;
|
|
12545
12600
|
}
|
|
12546
|
-
slashSplit(
|
|
12601
|
+
slashSplit(p13) {
|
|
12547
12602
|
if (this.preserveMultipleSlashes) {
|
|
12548
|
-
return
|
|
12549
|
-
} else if (this.isWindows && /^\/\/[^\/]+/.test(
|
|
12550
|
-
return ["", ...
|
|
12603
|
+
return p13.split("/");
|
|
12604
|
+
} else if (this.isWindows && /^\/\/[^\/]+/.test(p13)) {
|
|
12605
|
+
return ["", ...p13.split(/\/+/)];
|
|
12551
12606
|
} else {
|
|
12552
|
-
return
|
|
12607
|
+
return p13.split(/\/+/);
|
|
12553
12608
|
}
|
|
12554
12609
|
}
|
|
12555
12610
|
match(f, partial = this.partial) {
|
|
@@ -12605,8 +12660,8 @@ minimatch.Minimatch = Minimatch;
|
|
|
12605
12660
|
minimatch.escape = escape;
|
|
12606
12661
|
minimatch.unescape = unescape;
|
|
12607
12662
|
|
|
12608
|
-
// ../node_modules/lru-cache/dist/esm/index.js
|
|
12609
|
-
var
|
|
12663
|
+
// ../node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js
|
|
12664
|
+
var defaultPerf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
|
|
12610
12665
|
var warned = /* @__PURE__ */ new Set();
|
|
12611
12666
|
var PROCESS = typeof process === "object" && !!process ? process : {};
|
|
12612
12667
|
var emitWarning = (msg, type, code, fn2) => {
|
|
@@ -12690,9 +12745,17 @@ var LRUCache = class _LRUCache {
|
|
|
12690
12745
|
#max;
|
|
12691
12746
|
#maxSize;
|
|
12692
12747
|
#dispose;
|
|
12748
|
+
#onInsert;
|
|
12693
12749
|
#disposeAfter;
|
|
12694
12750
|
#fetchMethod;
|
|
12695
12751
|
#memoMethod;
|
|
12752
|
+
#perf;
|
|
12753
|
+
/**
|
|
12754
|
+
* {@link LRUCache.OptionsBase.perf}
|
|
12755
|
+
*/
|
|
12756
|
+
get perf() {
|
|
12757
|
+
return this.#perf;
|
|
12758
|
+
}
|
|
12696
12759
|
/**
|
|
12697
12760
|
* {@link LRUCache.OptionsBase.ttl}
|
|
12698
12761
|
*/
|
|
@@ -12771,6 +12834,7 @@ var LRUCache = class _LRUCache {
|
|
|
12771
12834
|
#hasDispose;
|
|
12772
12835
|
#hasFetchMethod;
|
|
12773
12836
|
#hasDisposeAfter;
|
|
12837
|
+
#hasOnInsert;
|
|
12774
12838
|
/**
|
|
12775
12839
|
* Do not call this method unless you need to inspect the
|
|
12776
12840
|
* inner workings of the cache. If anything returned by this
|
|
@@ -12799,7 +12863,7 @@ var LRUCache = class _LRUCache {
|
|
|
12799
12863
|
},
|
|
12800
12864
|
free: c.#free,
|
|
12801
12865
|
// methods
|
|
12802
|
-
isBackgroundFetch: (
|
|
12866
|
+
isBackgroundFetch: (p13) => c.#isBackgroundFetch(p13),
|
|
12803
12867
|
backgroundFetch: (k, index, options, context) => c.#backgroundFetch(k, index, options, context),
|
|
12804
12868
|
moveToTail: (index) => c.#moveToTail(index),
|
|
12805
12869
|
indexes: (options) => c.#indexes(options),
|
|
@@ -12847,6 +12911,12 @@ var LRUCache = class _LRUCache {
|
|
|
12847
12911
|
get dispose() {
|
|
12848
12912
|
return this.#dispose;
|
|
12849
12913
|
}
|
|
12914
|
+
/**
|
|
12915
|
+
* {@link LRUCache.OptionsBase.onInsert} (read-only)
|
|
12916
|
+
*/
|
|
12917
|
+
get onInsert() {
|
|
12918
|
+
return this.#onInsert;
|
|
12919
|
+
}
|
|
12850
12920
|
/**
|
|
12851
12921
|
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
|
|
12852
12922
|
*/
|
|
@@ -12854,7 +12924,13 @@ var LRUCache = class _LRUCache {
|
|
|
12854
12924
|
return this.#disposeAfter;
|
|
12855
12925
|
}
|
|
12856
12926
|
constructor(options) {
|
|
12857
|
-
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options;
|
|
12927
|
+
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, perf } = options;
|
|
12928
|
+
if (perf !== void 0) {
|
|
12929
|
+
if (typeof perf?.now !== "function") {
|
|
12930
|
+
throw new TypeError("perf option must have a now() method if specified");
|
|
12931
|
+
}
|
|
12932
|
+
}
|
|
12933
|
+
this.#perf = perf ?? defaultPerf;
|
|
12858
12934
|
if (max !== 0 && !isPosInt(max)) {
|
|
12859
12935
|
throw new TypeError("max option must be a nonnegative integer");
|
|
12860
12936
|
}
|
|
@@ -12896,6 +12972,9 @@ var LRUCache = class _LRUCache {
|
|
|
12896
12972
|
if (typeof dispose === "function") {
|
|
12897
12973
|
this.#dispose = dispose;
|
|
12898
12974
|
}
|
|
12975
|
+
if (typeof onInsert === "function") {
|
|
12976
|
+
this.#onInsert = onInsert;
|
|
12977
|
+
}
|
|
12899
12978
|
if (typeof disposeAfter === "function") {
|
|
12900
12979
|
this.#disposeAfter = disposeAfter;
|
|
12901
12980
|
this.#disposed = [];
|
|
@@ -12904,6 +12983,7 @@ var LRUCache = class _LRUCache {
|
|
|
12904
12983
|
this.#disposed = void 0;
|
|
12905
12984
|
}
|
|
12906
12985
|
this.#hasDispose = !!this.#dispose;
|
|
12986
|
+
this.#hasOnInsert = !!this.#onInsert;
|
|
12907
12987
|
this.#hasDisposeAfter = !!this.#disposeAfter;
|
|
12908
12988
|
this.noDisposeOnSet = !!noDisposeOnSet;
|
|
12909
12989
|
this.noUpdateTTL = !!noUpdateTTL;
|
|
@@ -12959,7 +13039,7 @@ var LRUCache = class _LRUCache {
|
|
|
12959
13039
|
const starts = new ZeroArray(this.#max);
|
|
12960
13040
|
this.#ttls = ttls;
|
|
12961
13041
|
this.#starts = starts;
|
|
12962
|
-
this.#setItemTTL = (index, ttl, start = perf.now()) => {
|
|
13042
|
+
this.#setItemTTL = (index, ttl, start = this.#perf.now()) => {
|
|
12963
13043
|
starts[index] = ttl !== 0 ? start : 0;
|
|
12964
13044
|
ttls[index] = ttl;
|
|
12965
13045
|
if (ttl !== 0 && this.ttlAutopurge) {
|
|
@@ -12974,7 +13054,7 @@ var LRUCache = class _LRUCache {
|
|
|
12974
13054
|
}
|
|
12975
13055
|
};
|
|
12976
13056
|
this.#updateItemAge = (index) => {
|
|
12977
|
-
starts[index] = ttls[index] !== 0 ? perf.now() : 0;
|
|
13057
|
+
starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0;
|
|
12978
13058
|
};
|
|
12979
13059
|
this.#statusTTL = (status, index) => {
|
|
12980
13060
|
if (ttls[index]) {
|
|
@@ -12991,7 +13071,7 @@ var LRUCache = class _LRUCache {
|
|
|
12991
13071
|
};
|
|
12992
13072
|
let cachedNow = 0;
|
|
12993
13073
|
const getNow = () => {
|
|
12994
|
-
const n = perf.now();
|
|
13074
|
+
const n = this.#perf.now();
|
|
12995
13075
|
if (this.ttlResolution > 0) {
|
|
12996
13076
|
cachedNow = n;
|
|
12997
13077
|
const t = setTimeout(() => cachedNow = 0, this.ttlResolution);
|
|
@@ -13294,7 +13374,7 @@ var LRUCache = class _LRUCache {
|
|
|
13294
13374
|
const ttl = this.#ttls[i];
|
|
13295
13375
|
const start = this.#starts[i];
|
|
13296
13376
|
if (ttl && start) {
|
|
13297
|
-
const remain = ttl - (perf.now() - start);
|
|
13377
|
+
const remain = ttl - (this.#perf.now() - start);
|
|
13298
13378
|
entry.ttl = remain;
|
|
13299
13379
|
entry.start = Date.now();
|
|
13300
13380
|
}
|
|
@@ -13306,7 +13386,7 @@ var LRUCache = class _LRUCache {
|
|
|
13306
13386
|
}
|
|
13307
13387
|
/**
|
|
13308
13388
|
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
|
|
13309
|
-
* passed to {@link
|
|
13389
|
+
* passed to {@link LRUCache#load}.
|
|
13310
13390
|
*
|
|
13311
13391
|
* The `start` fields are calculated relative to a portable `Date.now()`
|
|
13312
13392
|
* timestamp, even if `performance.now()` is available.
|
|
@@ -13328,7 +13408,7 @@ var LRUCache = class _LRUCache {
|
|
|
13328
13408
|
const entry = { value };
|
|
13329
13409
|
if (this.#ttls && this.#starts) {
|
|
13330
13410
|
entry.ttl = this.#ttls[i];
|
|
13331
|
-
const age = perf.now() - this.#starts[i];
|
|
13411
|
+
const age = this.#perf.now() - this.#starts[i];
|
|
13332
13412
|
entry.start = Math.floor(Date.now() - age);
|
|
13333
13413
|
}
|
|
13334
13414
|
if (this.#sizes) {
|
|
@@ -13352,7 +13432,7 @@ var LRUCache = class _LRUCache {
|
|
|
13352
13432
|
for (const [key, entry] of arr) {
|
|
13353
13433
|
if (entry.start) {
|
|
13354
13434
|
const age = Date.now() - entry.start;
|
|
13355
|
-
entry.start = perf.now() - age;
|
|
13435
|
+
entry.start = this.#perf.now() - age;
|
|
13356
13436
|
}
|
|
13357
13437
|
this.set(key, entry.value, entry);
|
|
13358
13438
|
}
|
|
@@ -13417,6 +13497,9 @@ var LRUCache = class _LRUCache {
|
|
|
13417
13497
|
if (status)
|
|
13418
13498
|
status.set = "add";
|
|
13419
13499
|
noUpdateTTL = false;
|
|
13500
|
+
if (this.#hasOnInsert) {
|
|
13501
|
+
this.#onInsert?.(v, k, "add");
|
|
13502
|
+
}
|
|
13420
13503
|
} else {
|
|
13421
13504
|
this.#moveToTail(index);
|
|
13422
13505
|
const oldVal = this.#valList[index];
|
|
@@ -13452,6 +13535,9 @@ var LRUCache = class _LRUCache {
|
|
|
13452
13535
|
} else if (status) {
|
|
13453
13536
|
status.set = "update";
|
|
13454
13537
|
}
|
|
13538
|
+
if (this.#hasOnInsert) {
|
|
13539
|
+
this.onInsert?.(v, k, v === oldVal ? "update" : "replace");
|
|
13540
|
+
}
|
|
13455
13541
|
}
|
|
13456
13542
|
if (ttl !== 0 && !this.#ttls) {
|
|
13457
13543
|
this.#initializeTTLTracking();
|
|
@@ -13618,10 +13704,11 @@ var LRUCache = class _LRUCache {
|
|
|
13618
13704
|
if (aborted && !ignoreAbort && !updateCache) {
|
|
13619
13705
|
return fetchFail(ac2.signal.reason);
|
|
13620
13706
|
}
|
|
13621
|
-
const bf2 =
|
|
13622
|
-
|
|
13707
|
+
const bf2 = p13;
|
|
13708
|
+
const vl2 = this.#valList[index];
|
|
13709
|
+
if (vl2 === p13 || ignoreAbort && updateCache && vl2 === void 0) {
|
|
13623
13710
|
if (v2 === void 0) {
|
|
13624
|
-
if (bf2.__staleWhileFetching) {
|
|
13711
|
+
if (bf2.__staleWhileFetching !== void 0) {
|
|
13625
13712
|
this.#valList[index] = bf2.__staleWhileFetching;
|
|
13626
13713
|
} else {
|
|
13627
13714
|
this.#delete(k, "fetch");
|
|
@@ -13646,8 +13733,8 @@ var LRUCache = class _LRUCache {
|
|
|
13646
13733
|
const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
|
|
13647
13734
|
const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
|
|
13648
13735
|
const noDelete = allowStale || options.noDeleteOnFetchRejection;
|
|
13649
|
-
const bf2 =
|
|
13650
|
-
if (this.#valList[index] ===
|
|
13736
|
+
const bf2 = p13;
|
|
13737
|
+
if (this.#valList[index] === p13) {
|
|
13651
13738
|
const del = !noDelete || bf2.__staleWhileFetching === void 0;
|
|
13652
13739
|
if (del) {
|
|
13653
13740
|
this.#delete(k, "fetch");
|
|
@@ -13680,8 +13767,8 @@ var LRUCache = class _LRUCache {
|
|
|
13680
13767
|
};
|
|
13681
13768
|
if (options.status)
|
|
13682
13769
|
options.status.fetchDispatched = true;
|
|
13683
|
-
const
|
|
13684
|
-
const bf = Object.assign(
|
|
13770
|
+
const p13 = new Promise(pcall).then(cb, eb);
|
|
13771
|
+
const bf = Object.assign(p13, {
|
|
13685
13772
|
__abortController: ac2,
|
|
13686
13773
|
__staleWhileFetching: v,
|
|
13687
13774
|
__returned: void 0
|
|
@@ -13694,10 +13781,10 @@ var LRUCache = class _LRUCache {
|
|
|
13694
13781
|
}
|
|
13695
13782
|
return bf;
|
|
13696
13783
|
}
|
|
13697
|
-
#isBackgroundFetch(
|
|
13784
|
+
#isBackgroundFetch(p13) {
|
|
13698
13785
|
if (!this.#hasFetchMethod)
|
|
13699
13786
|
return false;
|
|
13700
|
-
const b =
|
|
13787
|
+
const b = p13;
|
|
13701
13788
|
return !!b && b instanceof Promise && b.hasOwnProperty("__staleWhileFetching") && b.__abortController instanceof AC;
|
|
13702
13789
|
}
|
|
13703
13790
|
async fetch(k, fetchOptions = {}) {
|
|
@@ -13752,8 +13839,8 @@ var LRUCache = class _LRUCache {
|
|
|
13752
13839
|
if (index === void 0) {
|
|
13753
13840
|
if (status)
|
|
13754
13841
|
status.fetch = "miss";
|
|
13755
|
-
const
|
|
13756
|
-
return
|
|
13842
|
+
const p13 = this.#backgroundFetch(k, index, options, context);
|
|
13843
|
+
return p13.__returned = p13;
|
|
13757
13844
|
} else {
|
|
13758
13845
|
const v = this.#valList[index];
|
|
13759
13846
|
if (this.#isBackgroundFetch(v)) {
|
|
@@ -13777,15 +13864,15 @@ var LRUCache = class _LRUCache {
|
|
|
13777
13864
|
this.#statusTTL(status, index);
|
|
13778
13865
|
return v;
|
|
13779
13866
|
}
|
|
13780
|
-
const
|
|
13781
|
-
const hasStale =
|
|
13867
|
+
const p13 = this.#backgroundFetch(k, index, options, context);
|
|
13868
|
+
const hasStale = p13.__staleWhileFetching !== void 0;
|
|
13782
13869
|
const staleVal = hasStale && allowStale;
|
|
13783
13870
|
if (status) {
|
|
13784
13871
|
status.fetch = isStale ? "stale" : "refresh";
|
|
13785
13872
|
if (staleVal && isStale)
|
|
13786
13873
|
status.returnedStale = true;
|
|
13787
13874
|
}
|
|
13788
|
-
return staleVal ?
|
|
13875
|
+
return staleVal ? p13.__staleWhileFetching : p13.__returned = p13;
|
|
13789
13876
|
}
|
|
13790
13877
|
}
|
|
13791
13878
|
async forceFetch(k, fetchOptions = {}) {
|
|
@@ -13856,9 +13943,9 @@ var LRUCache = class _LRUCache {
|
|
|
13856
13943
|
status.get = "miss";
|
|
13857
13944
|
}
|
|
13858
13945
|
}
|
|
13859
|
-
#connect(
|
|
13860
|
-
this.#prev[n] =
|
|
13861
|
-
this.#next[
|
|
13946
|
+
#connect(p13, n) {
|
|
13947
|
+
this.#prev[n] = p13;
|
|
13948
|
+
this.#next[p13] = n;
|
|
13862
13949
|
}
|
|
13863
13950
|
#moveToTail(index) {
|
|
13864
13951
|
if (index !== this.#tail) {
|
|
@@ -14453,16 +14540,16 @@ var Minipass = class extends EventEmitter {
|
|
|
14453
14540
|
* {@link Minipass#resume} is explicitly called.
|
|
14454
14541
|
*/
|
|
14455
14542
|
unpipe(dest) {
|
|
14456
|
-
const
|
|
14457
|
-
if (
|
|
14543
|
+
const p13 = this[PIPES].find((p14) => p14.dest === dest);
|
|
14544
|
+
if (p13) {
|
|
14458
14545
|
if (this[PIPES].length === 1) {
|
|
14459
14546
|
if (this[FLOWING] && this[DATALISTENERS] === 0) {
|
|
14460
14547
|
this[FLOWING] = false;
|
|
14461
14548
|
}
|
|
14462
14549
|
this[PIPES] = [];
|
|
14463
14550
|
} else
|
|
14464
|
-
this[PIPES].splice(this[PIPES].indexOf(
|
|
14465
|
-
|
|
14551
|
+
this[PIPES].splice(this[PIPES].indexOf(p13), 1);
|
|
14552
|
+
p13.unpipe();
|
|
14466
14553
|
}
|
|
14467
14554
|
}
|
|
14468
14555
|
/**
|
|
@@ -14628,8 +14715,8 @@ var Minipass = class extends EventEmitter {
|
|
|
14628
14715
|
return ret;
|
|
14629
14716
|
}
|
|
14630
14717
|
[EMITDATA](data) {
|
|
14631
|
-
for (const
|
|
14632
|
-
if (
|
|
14718
|
+
for (const p13 of this[PIPES]) {
|
|
14719
|
+
if (p13.dest.write(data) === false)
|
|
14633
14720
|
this.pause();
|
|
14634
14721
|
}
|
|
14635
14722
|
const ret = this[DISCARDED] ? false : super.emit("data", data);
|
|
@@ -14647,15 +14734,15 @@ var Minipass = class extends EventEmitter {
|
|
|
14647
14734
|
if (this[DECODER]) {
|
|
14648
14735
|
const data = this[DECODER].end();
|
|
14649
14736
|
if (data) {
|
|
14650
|
-
for (const
|
|
14651
|
-
|
|
14737
|
+
for (const p13 of this[PIPES]) {
|
|
14738
|
+
p13.dest.write(data);
|
|
14652
14739
|
}
|
|
14653
14740
|
if (!this[DISCARDED])
|
|
14654
14741
|
super.emit("data", data);
|
|
14655
14742
|
}
|
|
14656
14743
|
}
|
|
14657
|
-
for (const
|
|
14658
|
-
|
|
14744
|
+
for (const p13 of this[PIPES]) {
|
|
14745
|
+
p13.end();
|
|
14659
14746
|
}
|
|
14660
14747
|
const ret = super.emit("end");
|
|
14661
14748
|
this.removeAllListeners("end");
|
|
@@ -14671,13 +14758,13 @@ var Minipass = class extends EventEmitter {
|
|
|
14671
14758
|
});
|
|
14672
14759
|
if (!this[OBJECTMODE])
|
|
14673
14760
|
buf2.dataLength = 0;
|
|
14674
|
-
const
|
|
14761
|
+
const p13 = this.promise();
|
|
14675
14762
|
this.on("data", (c) => {
|
|
14676
14763
|
buf2.push(c);
|
|
14677
14764
|
if (!this[OBJECTMODE])
|
|
14678
14765
|
buf2.dataLength += c.length;
|
|
14679
14766
|
});
|
|
14680
|
-
await
|
|
14767
|
+
await p13;
|
|
14681
14768
|
return buf2;
|
|
14682
14769
|
}
|
|
14683
14770
|
/**
|
|
@@ -14891,7 +14978,7 @@ var ENOREALPATH = 512;
|
|
|
14891
14978
|
var ENOCHILD = ENOTDIR | ENOENT | ENOREALPATH;
|
|
14892
14979
|
var TYPEMASK = 1023;
|
|
14893
14980
|
var entToType = (s) => s.isFile() ? IFREG : s.isDirectory() ? IFDIR : s.isSymbolicLink() ? IFLNK : s.isCharacterDevice() ? IFCHR : s.isBlockDevice() ? IFBLK : s.isSocket() ? IFSOCK : s.isFIFO() ? IFIFO : UNKNOWN;
|
|
14894
|
-
var normalizeCache =
|
|
14981
|
+
var normalizeCache = new LRUCache({ max: 2 ** 12 });
|
|
14895
14982
|
var normalize = (s) => {
|
|
14896
14983
|
const c = normalizeCache.get(s);
|
|
14897
14984
|
if (c)
|
|
@@ -14900,7 +14987,7 @@ var normalize = (s) => {
|
|
|
14900
14987
|
normalizeCache.set(s, n);
|
|
14901
14988
|
return n;
|
|
14902
14989
|
};
|
|
14903
|
-
var normalizeNocaseCache =
|
|
14990
|
+
var normalizeNocaseCache = new LRUCache({ max: 2 ** 12 });
|
|
14904
14991
|
var normalizeNocase = (s) => {
|
|
14905
14992
|
const c = normalizeNocaseCache.get(s);
|
|
14906
14993
|
if (c)
|
|
@@ -15057,13 +15144,17 @@ var PathBase = class {
|
|
|
15057
15144
|
get parentPath() {
|
|
15058
15145
|
return (this.parent || this).fullpath();
|
|
15059
15146
|
}
|
|
15147
|
+
/* c8 ignore start */
|
|
15060
15148
|
/**
|
|
15061
15149
|
* Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively,
|
|
15062
15150
|
* this property refers to the *parent* path, not the path object itself.
|
|
15151
|
+
*
|
|
15152
|
+
* @deprecated
|
|
15063
15153
|
*/
|
|
15064
15154
|
get path() {
|
|
15065
15155
|
return this.parentPath;
|
|
15066
15156
|
}
|
|
15157
|
+
/* c8 ignore stop */
|
|
15067
15158
|
/**
|
|
15068
15159
|
* Do not create new Path objects directly. They should always be accessed
|
|
15069
15160
|
* via the PathScurry class or other methods on the Path class.
|
|
@@ -15109,22 +15200,22 @@ var PathBase = class {
|
|
|
15109
15200
|
/**
|
|
15110
15201
|
* Get the Path object referenced by the string path, resolved from this Path
|
|
15111
15202
|
*/
|
|
15112
|
-
resolve(
|
|
15113
|
-
if (!
|
|
15203
|
+
resolve(path13) {
|
|
15204
|
+
if (!path13) {
|
|
15114
15205
|
return this;
|
|
15115
15206
|
}
|
|
15116
|
-
const rootPath = this.getRootString(
|
|
15117
|
-
const dir =
|
|
15207
|
+
const rootPath = this.getRootString(path13);
|
|
15208
|
+
const dir = path13.substring(rootPath.length);
|
|
15118
15209
|
const dirParts = dir.split(this.splitSep);
|
|
15119
15210
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
15120
15211
|
return result;
|
|
15121
15212
|
}
|
|
15122
15213
|
#resolveParts(dirParts) {
|
|
15123
|
-
let
|
|
15214
|
+
let p13 = this;
|
|
15124
15215
|
for (const part of dirParts) {
|
|
15125
|
-
|
|
15216
|
+
p13 = p13.child(part);
|
|
15126
15217
|
}
|
|
15127
|
-
return
|
|
15218
|
+
return p13;
|
|
15128
15219
|
}
|
|
15129
15220
|
/**
|
|
15130
15221
|
* Returns the cached children Path objects, if still available. If they
|
|
@@ -15166,9 +15257,9 @@ var PathBase = class {
|
|
|
15166
15257
|
}
|
|
15167
15258
|
const children = this.children();
|
|
15168
15259
|
const name = this.nocase ? normalizeNocase(pathPart) : normalize(pathPart);
|
|
15169
|
-
for (const
|
|
15170
|
-
if (
|
|
15171
|
-
return
|
|
15260
|
+
for (const p13 of children) {
|
|
15261
|
+
if (p13.#matchName === name) {
|
|
15262
|
+
return p13;
|
|
15172
15263
|
}
|
|
15173
15264
|
}
|
|
15174
15265
|
const s = this.parent ? this.sep : "";
|
|
@@ -15195,12 +15286,12 @@ var PathBase = class {
|
|
|
15195
15286
|
return this.#relative;
|
|
15196
15287
|
}
|
|
15197
15288
|
const name = this.name;
|
|
15198
|
-
const
|
|
15199
|
-
if (!
|
|
15289
|
+
const p13 = this.parent;
|
|
15290
|
+
if (!p13) {
|
|
15200
15291
|
return this.#relative = this.name;
|
|
15201
15292
|
}
|
|
15202
|
-
const pv =
|
|
15203
|
-
return pv + (!pv || !
|
|
15293
|
+
const pv = p13.relative();
|
|
15294
|
+
return pv + (!pv || !p13.parent ? "" : this.sep) + name;
|
|
15204
15295
|
}
|
|
15205
15296
|
/**
|
|
15206
15297
|
* The relative path from the cwd, using / as the path separator.
|
|
@@ -15216,12 +15307,12 @@ var PathBase = class {
|
|
|
15216
15307
|
if (this.#relativePosix !== void 0)
|
|
15217
15308
|
return this.#relativePosix;
|
|
15218
15309
|
const name = this.name;
|
|
15219
|
-
const
|
|
15220
|
-
if (!
|
|
15310
|
+
const p13 = this.parent;
|
|
15311
|
+
if (!p13) {
|
|
15221
15312
|
return this.#relativePosix = this.fullpathPosix();
|
|
15222
15313
|
}
|
|
15223
|
-
const pv =
|
|
15224
|
-
return pv + (!pv || !
|
|
15314
|
+
const pv = p13.relativePosix();
|
|
15315
|
+
return pv + (!pv || !p13.parent ? "" : "/") + name;
|
|
15225
15316
|
}
|
|
15226
15317
|
/**
|
|
15227
15318
|
* The fully resolved path string for this Path entry
|
|
@@ -15231,12 +15322,12 @@ var PathBase = class {
|
|
|
15231
15322
|
return this.#fullpath;
|
|
15232
15323
|
}
|
|
15233
15324
|
const name = this.name;
|
|
15234
|
-
const
|
|
15235
|
-
if (!
|
|
15325
|
+
const p13 = this.parent;
|
|
15326
|
+
if (!p13) {
|
|
15236
15327
|
return this.#fullpath = this.name;
|
|
15237
15328
|
}
|
|
15238
|
-
const pv =
|
|
15239
|
-
const fp = pv + (!
|
|
15329
|
+
const pv = p13.fullpath();
|
|
15330
|
+
const fp = pv + (!p13.parent ? "" : this.sep) + name;
|
|
15240
15331
|
return this.#fullpath = fp;
|
|
15241
15332
|
}
|
|
15242
15333
|
/**
|
|
@@ -15251,16 +15342,16 @@ var PathBase = class {
|
|
|
15251
15342
|
if (this.sep === "/")
|
|
15252
15343
|
return this.#fullpathPosix = this.fullpath();
|
|
15253
15344
|
if (!this.parent) {
|
|
15254
|
-
const
|
|
15255
|
-
if (/^[a-z]:\//i.test(
|
|
15256
|
-
return this.#fullpathPosix = `//?/${
|
|
15345
|
+
const p14 = this.fullpath().replace(/\\/g, "/");
|
|
15346
|
+
if (/^[a-z]:\//i.test(p14)) {
|
|
15347
|
+
return this.#fullpathPosix = `//?/${p14}`;
|
|
15257
15348
|
} else {
|
|
15258
|
-
return this.#fullpathPosix =
|
|
15349
|
+
return this.#fullpathPosix = p14;
|
|
15259
15350
|
}
|
|
15260
15351
|
}
|
|
15261
|
-
const
|
|
15262
|
-
const pfpp =
|
|
15263
|
-
const fpp = pfpp + (!pfpp || !
|
|
15352
|
+
const p13 = this.parent;
|
|
15353
|
+
const pfpp = p13.fullpathPosix();
|
|
15354
|
+
const fpp = pfpp + (!pfpp || !p13.parent ? "" : "/") + this.name;
|
|
15264
15355
|
return this.#fullpathPosix = fpp;
|
|
15265
15356
|
}
|
|
15266
15357
|
/**
|
|
@@ -15469,8 +15560,8 @@ var PathBase = class {
|
|
|
15469
15560
|
}
|
|
15470
15561
|
#readdirSuccess(children) {
|
|
15471
15562
|
this.#type |= READDIR_CALLED;
|
|
15472
|
-
for (let
|
|
15473
|
-
const c = children[
|
|
15563
|
+
for (let p13 = children.provisional; p13 < children.length; p13++) {
|
|
15564
|
+
const c = children[p13];
|
|
15474
15565
|
if (c)
|
|
15475
15566
|
c.#markENOENT();
|
|
15476
15567
|
}
|
|
@@ -15484,8 +15575,8 @@ var PathBase = class {
|
|
|
15484
15575
|
#markChildrenENOENT() {
|
|
15485
15576
|
const children = this.children();
|
|
15486
15577
|
children.provisional = 0;
|
|
15487
|
-
for (const
|
|
15488
|
-
|
|
15578
|
+
for (const p13 of children) {
|
|
15579
|
+
p13.#markENOENT();
|
|
15489
15580
|
}
|
|
15490
15581
|
}
|
|
15491
15582
|
#markENOREALPATH() {
|
|
@@ -15513,8 +15604,8 @@ var PathBase = class {
|
|
|
15513
15604
|
}
|
|
15514
15605
|
#lstatFail(code = "") {
|
|
15515
15606
|
if (code === "ENOTDIR") {
|
|
15516
|
-
const
|
|
15517
|
-
|
|
15607
|
+
const p13 = this.parent;
|
|
15608
|
+
p13.#markENOTDIR();
|
|
15518
15609
|
} else if (code === "ENOENT") {
|
|
15519
15610
|
this.#markENOENT();
|
|
15520
15611
|
}
|
|
@@ -15547,29 +15638,29 @@ var PathBase = class {
|
|
|
15547
15638
|
return child;
|
|
15548
15639
|
}
|
|
15549
15640
|
#readdirMaybePromoteChild(e, c) {
|
|
15550
|
-
for (let
|
|
15551
|
-
const pchild = c[
|
|
15641
|
+
for (let p13 = c.provisional; p13 < c.length; p13++) {
|
|
15642
|
+
const pchild = c[p13];
|
|
15552
15643
|
const name = this.nocase ? normalizeNocase(e.name) : normalize(e.name);
|
|
15553
15644
|
if (name !== pchild.#matchName) {
|
|
15554
15645
|
continue;
|
|
15555
15646
|
}
|
|
15556
|
-
return this.#readdirPromoteChild(e, pchild,
|
|
15647
|
+
return this.#readdirPromoteChild(e, pchild, p13, c);
|
|
15557
15648
|
}
|
|
15558
15649
|
}
|
|
15559
|
-
#readdirPromoteChild(e,
|
|
15560
|
-
const v =
|
|
15561
|
-
|
|
15650
|
+
#readdirPromoteChild(e, p13, index, c) {
|
|
15651
|
+
const v = p13.name;
|
|
15652
|
+
p13.#type = p13.#type & IFMT_UNKNOWN | entToType(e);
|
|
15562
15653
|
if (v !== e.name)
|
|
15563
|
-
|
|
15654
|
+
p13.name = e.name;
|
|
15564
15655
|
if (index !== c.provisional) {
|
|
15565
15656
|
if (index === c.length - 1)
|
|
15566
15657
|
c.pop();
|
|
15567
15658
|
else
|
|
15568
15659
|
c.splice(index, 1);
|
|
15569
|
-
c.unshift(
|
|
15660
|
+
c.unshift(p13);
|
|
15570
15661
|
}
|
|
15571
15662
|
c.provisional++;
|
|
15572
|
-
return
|
|
15663
|
+
return p13;
|
|
15573
15664
|
}
|
|
15574
15665
|
/**
|
|
15575
15666
|
* Call lstat() on this Path, and update all known information that can be
|
|
@@ -15823,19 +15914,19 @@ var PathBase = class {
|
|
|
15823
15914
|
this.isCWD = true;
|
|
15824
15915
|
const changed = /* @__PURE__ */ new Set([]);
|
|
15825
15916
|
let rp = [];
|
|
15826
|
-
let
|
|
15827
|
-
while (
|
|
15828
|
-
changed.add(
|
|
15829
|
-
|
|
15830
|
-
|
|
15831
|
-
|
|
15917
|
+
let p13 = this;
|
|
15918
|
+
while (p13 && p13.parent) {
|
|
15919
|
+
changed.add(p13);
|
|
15920
|
+
p13.#relative = rp.join(this.sep);
|
|
15921
|
+
p13.#relativePosix = rp.join("/");
|
|
15922
|
+
p13 = p13.parent;
|
|
15832
15923
|
rp.push("..");
|
|
15833
15924
|
}
|
|
15834
|
-
|
|
15835
|
-
while (
|
|
15836
|
-
|
|
15837
|
-
|
|
15838
|
-
|
|
15925
|
+
p13 = oldCwd;
|
|
15926
|
+
while (p13 && p13.parent && !changed.has(p13)) {
|
|
15927
|
+
p13.#relative = void 0;
|
|
15928
|
+
p13.#relativePosix = void 0;
|
|
15929
|
+
p13 = p13.parent;
|
|
15839
15930
|
}
|
|
15840
15931
|
}
|
|
15841
15932
|
};
|
|
@@ -15866,8 +15957,8 @@ var PathWin32 = class _PathWin32 extends PathBase {
|
|
|
15866
15957
|
/**
|
|
15867
15958
|
* @internal
|
|
15868
15959
|
*/
|
|
15869
|
-
getRootString(
|
|
15870
|
-
return win32.parse(
|
|
15960
|
+
getRootString(path13) {
|
|
15961
|
+
return win32.parse(path13).root;
|
|
15871
15962
|
}
|
|
15872
15963
|
/**
|
|
15873
15964
|
* @internal
|
|
@@ -15913,8 +16004,8 @@ var PathPosix = class _PathPosix extends PathBase {
|
|
|
15913
16004
|
/**
|
|
15914
16005
|
* @internal
|
|
15915
16006
|
*/
|
|
15916
|
-
getRootString(
|
|
15917
|
-
return
|
|
16007
|
+
getRootString(path13) {
|
|
16008
|
+
return path13.startsWith("/") ? "/" : "";
|
|
15918
16009
|
}
|
|
15919
16010
|
/**
|
|
15920
16011
|
* @internal
|
|
@@ -16003,11 +16094,11 @@ var PathScurryBase = class {
|
|
|
16003
16094
|
/**
|
|
16004
16095
|
* Get the depth of a provided path, string, or the cwd
|
|
16005
16096
|
*/
|
|
16006
|
-
depth(
|
|
16007
|
-
if (typeof
|
|
16008
|
-
|
|
16097
|
+
depth(path13 = this.cwd) {
|
|
16098
|
+
if (typeof path13 === "string") {
|
|
16099
|
+
path13 = this.cwd.resolve(path13);
|
|
16009
16100
|
}
|
|
16010
|
-
return
|
|
16101
|
+
return path13.depth();
|
|
16011
16102
|
}
|
|
16012
16103
|
/**
|
|
16013
16104
|
* Return the cache of child entries. Exposed so subclasses can create
|
|
@@ -16030,11 +16121,11 @@ var PathScurryBase = class {
|
|
|
16030
16121
|
resolve(...paths) {
|
|
16031
16122
|
let r = "";
|
|
16032
16123
|
for (let i = paths.length - 1; i >= 0; i--) {
|
|
16033
|
-
const
|
|
16034
|
-
if (!
|
|
16124
|
+
const p13 = paths[i];
|
|
16125
|
+
if (!p13 || p13 === ".")
|
|
16035
16126
|
continue;
|
|
16036
|
-
r = r ? `${
|
|
16037
|
-
if (this.isAbsolute(
|
|
16127
|
+
r = r ? `${p13}/${r}` : p13;
|
|
16128
|
+
if (this.isAbsolute(p13)) {
|
|
16038
16129
|
break;
|
|
16039
16130
|
}
|
|
16040
16131
|
}
|
|
@@ -16060,11 +16151,11 @@ var PathScurryBase = class {
|
|
|
16060
16151
|
resolvePosix(...paths) {
|
|
16061
16152
|
let r = "";
|
|
16062
16153
|
for (let i = paths.length - 1; i >= 0; i--) {
|
|
16063
|
-
const
|
|
16064
|
-
if (!
|
|
16154
|
+
const p13 = paths[i];
|
|
16155
|
+
if (!p13 || p13 === ".")
|
|
16065
16156
|
continue;
|
|
16066
|
-
r = r ? `${
|
|
16067
|
-
if (this.isAbsolute(
|
|
16157
|
+
r = r ? `${p13}/${r}` : p13;
|
|
16158
|
+
if (this.isAbsolute(p13)) {
|
|
16068
16159
|
break;
|
|
16069
16160
|
}
|
|
16070
16161
|
}
|
|
@@ -16126,8 +16217,8 @@ var PathScurryBase = class {
|
|
|
16126
16217
|
if (!entry.canReaddir()) {
|
|
16127
16218
|
return [];
|
|
16128
16219
|
} else {
|
|
16129
|
-
const
|
|
16130
|
-
return withFileTypes ?
|
|
16220
|
+
const p13 = await entry.readdir();
|
|
16221
|
+
return withFileTypes ? p13 : p13.map((e) => e.name);
|
|
16131
16222
|
}
|
|
16132
16223
|
}
|
|
16133
16224
|
readdirSync(entry = this.cwd, opts = {
|
|
@@ -16494,9 +16585,9 @@ var PathScurryBase = class {
|
|
|
16494
16585
|
process2();
|
|
16495
16586
|
return results;
|
|
16496
16587
|
}
|
|
16497
|
-
chdir(
|
|
16588
|
+
chdir(path13 = this.cwd) {
|
|
16498
16589
|
const oldCwd = this.cwd;
|
|
16499
|
-
this.cwd = typeof
|
|
16590
|
+
this.cwd = typeof path13 === "string" ? this.cwd.resolve(path13) : path13;
|
|
16500
16591
|
this.cwd[setAsCwd](oldCwd);
|
|
16501
16592
|
}
|
|
16502
16593
|
};
|
|
@@ -16509,8 +16600,8 @@ var PathScurryWin32 = class extends PathScurryBase {
|
|
|
16509
16600
|
const { nocase = true } = opts;
|
|
16510
16601
|
super(cwd, win32, "\\", { ...opts, nocase });
|
|
16511
16602
|
this.nocase = nocase;
|
|
16512
|
-
for (let
|
|
16513
|
-
|
|
16603
|
+
for (let p13 = this.cwd; p13; p13 = p13.parent) {
|
|
16604
|
+
p13.nocase = this.nocase;
|
|
16514
16605
|
}
|
|
16515
16606
|
}
|
|
16516
16607
|
/**
|
|
@@ -16528,8 +16619,8 @@ var PathScurryWin32 = class extends PathScurryBase {
|
|
|
16528
16619
|
/**
|
|
16529
16620
|
* Return true if the provided path string is an absolute path
|
|
16530
16621
|
*/
|
|
16531
|
-
isAbsolute(
|
|
16532
|
-
return
|
|
16622
|
+
isAbsolute(p13) {
|
|
16623
|
+
return p13.startsWith("/") || p13.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p13);
|
|
16533
16624
|
}
|
|
16534
16625
|
};
|
|
16535
16626
|
var PathScurryPosix = class extends PathScurryBase {
|
|
@@ -16557,8 +16648,8 @@ var PathScurryPosix = class extends PathScurryBase {
|
|
|
16557
16648
|
/**
|
|
16558
16649
|
* Return true if the provided path string is an absolute path
|
|
16559
16650
|
*/
|
|
16560
|
-
isAbsolute(
|
|
16561
|
-
return
|
|
16651
|
+
isAbsolute(p13) {
|
|
16652
|
+
return p13.startsWith("/");
|
|
16562
16653
|
}
|
|
16563
16654
|
};
|
|
16564
16655
|
var PathScurryDarwin = class extends PathScurryPosix {
|
|
@@ -16611,9 +16702,9 @@ var Pattern = class _Pattern {
|
|
|
16611
16702
|
prest.shift();
|
|
16612
16703
|
grest.shift();
|
|
16613
16704
|
}
|
|
16614
|
-
const
|
|
16705
|
+
const p13 = [p0, p1, p22, p32, ""].join("/");
|
|
16615
16706
|
const g = [g0, g1, g2, g3, ""].join("/");
|
|
16616
|
-
this.#patternList = [
|
|
16707
|
+
this.#patternList = [p13, ...prest];
|
|
16617
16708
|
this.#globList = [g, ...grest];
|
|
16618
16709
|
this.length = this.#patternList.length;
|
|
16619
16710
|
} else if (this.isDrive() || this.isAbsolute()) {
|
|
@@ -16623,9 +16714,9 @@ var Pattern = class _Pattern {
|
|
|
16623
16714
|
prest.shift();
|
|
16624
16715
|
grest.shift();
|
|
16625
16716
|
}
|
|
16626
|
-
const
|
|
16717
|
+
const p13 = p1 + "/";
|
|
16627
16718
|
const g = g1 + "/";
|
|
16628
|
-
this.#patternList = [
|
|
16719
|
+
this.#patternList = [p13, ...prest];
|
|
16629
16720
|
this.#globList = [g, ...grest];
|
|
16630
16721
|
this.length = this.#patternList.length;
|
|
16631
16722
|
}
|
|
@@ -16714,8 +16805,8 @@ var Pattern = class _Pattern {
|
|
|
16714
16805
|
* consume the root of the pattern, and return it
|
|
16715
16806
|
*/
|
|
16716
16807
|
root() {
|
|
16717
|
-
const
|
|
16718
|
-
return typeof
|
|
16808
|
+
const p13 = this.#patternList[0];
|
|
16809
|
+
return typeof p13 === "string" && this.isAbsolute() && this.#index === 0 ? p13 : "";
|
|
16719
16810
|
}
|
|
16720
16811
|
/**
|
|
16721
16812
|
* Check to see if the current globstar pattern is allowed to follow
|
|
@@ -16776,10 +16867,10 @@ var Ignore = class {
|
|
|
16776
16867
|
parsed.shift();
|
|
16777
16868
|
globParts.shift();
|
|
16778
16869
|
}
|
|
16779
|
-
const
|
|
16780
|
-
const m = new Minimatch(
|
|
16870
|
+
const p13 = new Pattern(parsed, globParts, 0, this.platform);
|
|
16871
|
+
const m = new Minimatch(p13.globString(), this.mmopts);
|
|
16781
16872
|
const children = globParts[globParts.length - 1] === "**";
|
|
16782
|
-
const absolute =
|
|
16873
|
+
const absolute = p13.isAbsolute();
|
|
16783
16874
|
if (absolute)
|
|
16784
16875
|
this.absolute.push(m);
|
|
16785
16876
|
else
|
|
@@ -16792,10 +16883,10 @@ var Ignore = class {
|
|
|
16792
16883
|
}
|
|
16793
16884
|
}
|
|
16794
16885
|
}
|
|
16795
|
-
ignored(
|
|
16796
|
-
const fullpath =
|
|
16886
|
+
ignored(p13) {
|
|
16887
|
+
const fullpath = p13.fullpath();
|
|
16797
16888
|
const fullpaths = `${fullpath}/`;
|
|
16798
|
-
const relative =
|
|
16889
|
+
const relative = p13.relative() || ".";
|
|
16799
16890
|
const relatives = `${relative}/`;
|
|
16800
16891
|
for (const m of this.relative) {
|
|
16801
16892
|
if (m.match(relative) || m.match(relatives))
|
|
@@ -16807,9 +16898,9 @@ var Ignore = class {
|
|
|
16807
16898
|
}
|
|
16808
16899
|
return false;
|
|
16809
16900
|
}
|
|
16810
|
-
childrenIgnored(
|
|
16811
|
-
const fullpath =
|
|
16812
|
-
const relative = (
|
|
16901
|
+
childrenIgnored(p13) {
|
|
16902
|
+
const fullpath = p13.fullpath() + "/";
|
|
16903
|
+
const relative = (p13.relative() || ".") + "/";
|
|
16813
16904
|
for (const m of this.relativeChildren) {
|
|
16814
16905
|
if (m.match(relative))
|
|
16815
16906
|
return true;
|
|
@@ -16852,8 +16943,8 @@ var MatchRecord = class {
|
|
|
16852
16943
|
}
|
|
16853
16944
|
// match, absolute, ifdir
|
|
16854
16945
|
entries() {
|
|
16855
|
-
return [...this.store.entries()].map(([
|
|
16856
|
-
|
|
16946
|
+
return [...this.store.entries()].map(([path13, n]) => [
|
|
16947
|
+
path13,
|
|
16857
16948
|
!!(n & 2),
|
|
16858
16949
|
!!(n & 1)
|
|
16859
16950
|
]);
|
|
@@ -16867,7 +16958,7 @@ var SubWalks = class {
|
|
|
16867
16958
|
}
|
|
16868
16959
|
const subs = this.store.get(target);
|
|
16869
16960
|
if (subs) {
|
|
16870
|
-
if (!subs.find((
|
|
16961
|
+
if (!subs.find((p13) => p13.globString() === pattern.globString())) {
|
|
16871
16962
|
subs.push(pattern);
|
|
16872
16963
|
}
|
|
16873
16964
|
} else
|
|
@@ -16903,7 +16994,7 @@ var Processor = class _Processor {
|
|
|
16903
16994
|
}
|
|
16904
16995
|
processPatterns(target, patterns) {
|
|
16905
16996
|
this.patterns = patterns;
|
|
16906
|
-
const processingSet = patterns.map((
|
|
16997
|
+
const processingSet = patterns.map((p13) => [target, p13]);
|
|
16907
16998
|
for (let [t, pattern] of processingSet) {
|
|
16908
16999
|
this.hasWalkedCache.storeWalked(t, pattern);
|
|
16909
17000
|
const root = pattern.root();
|
|
@@ -16920,27 +17011,27 @@ var Processor = class _Processor {
|
|
|
16920
17011
|
}
|
|
16921
17012
|
if (t.isENOENT())
|
|
16922
17013
|
continue;
|
|
16923
|
-
let
|
|
17014
|
+
let p13;
|
|
16924
17015
|
let rest;
|
|
16925
17016
|
let changed = false;
|
|
16926
|
-
while (typeof (
|
|
16927
|
-
const c = t.resolve(
|
|
17017
|
+
while (typeof (p13 = pattern.pattern()) === "string" && (rest = pattern.rest())) {
|
|
17018
|
+
const c = t.resolve(p13);
|
|
16928
17019
|
t = c;
|
|
16929
17020
|
pattern = rest;
|
|
16930
17021
|
changed = true;
|
|
16931
17022
|
}
|
|
16932
|
-
|
|
17023
|
+
p13 = pattern.pattern();
|
|
16933
17024
|
rest = pattern.rest();
|
|
16934
17025
|
if (changed) {
|
|
16935
17026
|
if (this.hasWalkedCache.hasWalked(t, pattern))
|
|
16936
17027
|
continue;
|
|
16937
17028
|
this.hasWalkedCache.storeWalked(t, pattern);
|
|
16938
17029
|
}
|
|
16939
|
-
if (typeof
|
|
16940
|
-
const ifDir =
|
|
16941
|
-
this.matches.add(t.resolve(
|
|
17030
|
+
if (typeof p13 === "string") {
|
|
17031
|
+
const ifDir = p13 === ".." || p13 === "" || p13 === ".";
|
|
17032
|
+
this.matches.add(t.resolve(p13), absolute, ifDir);
|
|
16942
17033
|
continue;
|
|
16943
|
-
} else if (
|
|
17034
|
+
} else if (p13 === GLOBSTAR) {
|
|
16944
17035
|
if (!t.isSymbolicLink() || this.follow || pattern.checkFollowGlobstar()) {
|
|
16945
17036
|
this.subwalks.add(t, pattern);
|
|
16946
17037
|
}
|
|
@@ -16958,7 +17049,7 @@ var Processor = class _Processor {
|
|
|
16958
17049
|
}
|
|
16959
17050
|
}
|
|
16960
17051
|
}
|
|
16961
|
-
} else if (
|
|
17052
|
+
} else if (p13 instanceof RegExp) {
|
|
16962
17053
|
this.subwalks.add(t, pattern);
|
|
16963
17054
|
}
|
|
16964
17055
|
}
|
|
@@ -16980,14 +17071,14 @@ var Processor = class _Processor {
|
|
|
16980
17071
|
for (const e of entries) {
|
|
16981
17072
|
for (const pattern of patterns) {
|
|
16982
17073
|
const absolute = pattern.isAbsolute();
|
|
16983
|
-
const
|
|
17074
|
+
const p13 = pattern.pattern();
|
|
16984
17075
|
const rest = pattern.rest();
|
|
16985
|
-
if (
|
|
17076
|
+
if (p13 === GLOBSTAR) {
|
|
16986
17077
|
results.testGlobstar(e, pattern, rest, absolute);
|
|
16987
|
-
} else if (
|
|
16988
|
-
results.testRegExp(e,
|
|
17078
|
+
} else if (p13 instanceof RegExp) {
|
|
17079
|
+
results.testRegExp(e, p13, rest, absolute);
|
|
16989
17080
|
} else {
|
|
16990
|
-
results.testString(e,
|
|
17081
|
+
results.testString(e, p13, rest, absolute);
|
|
16991
17082
|
}
|
|
16992
17083
|
}
|
|
16993
17084
|
}
|
|
@@ -17023,8 +17114,8 @@ var Processor = class _Processor {
|
|
|
17023
17114
|
}
|
|
17024
17115
|
}
|
|
17025
17116
|
}
|
|
17026
|
-
testRegExp(e,
|
|
17027
|
-
if (!
|
|
17117
|
+
testRegExp(e, p13, rest, absolute) {
|
|
17118
|
+
if (!p13.test(e.name))
|
|
17028
17119
|
return;
|
|
17029
17120
|
if (!rest) {
|
|
17030
17121
|
this.matches.add(e, absolute, false);
|
|
@@ -17032,8 +17123,8 @@ var Processor = class _Processor {
|
|
|
17032
17123
|
this.subwalks.add(e, rest);
|
|
17033
17124
|
}
|
|
17034
17125
|
}
|
|
17035
|
-
testString(e,
|
|
17036
|
-
if (!e.isNamed(
|
|
17126
|
+
testString(e, p13, rest, absolute) {
|
|
17127
|
+
if (!e.isNamed(p13))
|
|
17037
17128
|
return;
|
|
17038
17129
|
if (!rest) {
|
|
17039
17130
|
this.matches.add(e, absolute, false);
|
|
@@ -17058,9 +17149,9 @@ var GlobUtil = class {
|
|
|
17058
17149
|
signal;
|
|
17059
17150
|
maxDepth;
|
|
17060
17151
|
includeChildMatches;
|
|
17061
|
-
constructor(patterns,
|
|
17152
|
+
constructor(patterns, path13, opts) {
|
|
17062
17153
|
this.patterns = patterns;
|
|
17063
|
-
this.path =
|
|
17154
|
+
this.path = path13;
|
|
17064
17155
|
this.opts = opts;
|
|
17065
17156
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
17066
17157
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -17079,11 +17170,11 @@ var GlobUtil = class {
|
|
|
17079
17170
|
});
|
|
17080
17171
|
}
|
|
17081
17172
|
}
|
|
17082
|
-
#ignored(
|
|
17083
|
-
return this.seen.has(
|
|
17173
|
+
#ignored(path13) {
|
|
17174
|
+
return this.seen.has(path13) || !!this.#ignore?.ignored?.(path13);
|
|
17084
17175
|
}
|
|
17085
|
-
#childrenIgnored(
|
|
17086
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
17176
|
+
#childrenIgnored(path13) {
|
|
17177
|
+
return !!this.#ignore?.childrenIgnored?.(path13);
|
|
17087
17178
|
}
|
|
17088
17179
|
// backpressure mechanism
|
|
17089
17180
|
pause() {
|
|
@@ -17174,14 +17265,14 @@ var GlobUtil = class {
|
|
|
17174
17265
|
}
|
|
17175
17266
|
}
|
|
17176
17267
|
async match(e, absolute, ifDir) {
|
|
17177
|
-
const
|
|
17178
|
-
if (
|
|
17179
|
-
this.matchFinish(
|
|
17268
|
+
const p13 = await this.matchCheck(e, ifDir);
|
|
17269
|
+
if (p13)
|
|
17270
|
+
this.matchFinish(p13, absolute);
|
|
17180
17271
|
}
|
|
17181
17272
|
matchSync(e, absolute, ifDir) {
|
|
17182
|
-
const
|
|
17183
|
-
if (
|
|
17184
|
-
this.matchFinish(
|
|
17273
|
+
const p13 = this.matchCheckSync(e, ifDir);
|
|
17274
|
+
if (p13)
|
|
17275
|
+
this.matchFinish(p13, absolute);
|
|
17185
17276
|
}
|
|
17186
17277
|
walkCB(target, patterns, cb) {
|
|
17187
17278
|
if (this.signal?.aborted)
|
|
@@ -17298,8 +17389,8 @@ var GlobUtil = class {
|
|
|
17298
17389
|
};
|
|
17299
17390
|
var GlobWalker = class extends GlobUtil {
|
|
17300
17391
|
matches = /* @__PURE__ */ new Set();
|
|
17301
|
-
constructor(patterns,
|
|
17302
|
-
super(patterns,
|
|
17392
|
+
constructor(patterns, path13, opts) {
|
|
17393
|
+
super(patterns, path13, opts);
|
|
17303
17394
|
}
|
|
17304
17395
|
matchEmit(e) {
|
|
17305
17396
|
this.matches.add(e);
|
|
@@ -17336,8 +17427,8 @@ var GlobWalker = class extends GlobUtil {
|
|
|
17336
17427
|
};
|
|
17337
17428
|
var GlobStream = class extends GlobUtil {
|
|
17338
17429
|
results;
|
|
17339
|
-
constructor(patterns,
|
|
17340
|
-
super(patterns,
|
|
17430
|
+
constructor(patterns, path13, opts) {
|
|
17431
|
+
super(patterns, path13, opts);
|
|
17341
17432
|
this.results = new Minipass({
|
|
17342
17433
|
signal: this.signal,
|
|
17343
17434
|
objectMode: true
|
|
@@ -17454,13 +17545,13 @@ var Glob = class {
|
|
|
17454
17545
|
}
|
|
17455
17546
|
this.windowsPathsNoEscape = !!opts.windowsPathsNoEscape || opts.allowWindowsEscape === false;
|
|
17456
17547
|
if (this.windowsPathsNoEscape) {
|
|
17457
|
-
pattern = pattern.map((
|
|
17548
|
+
pattern = pattern.map((p13) => p13.replace(/\\/g, "/"));
|
|
17458
17549
|
}
|
|
17459
17550
|
if (this.matchBase) {
|
|
17460
17551
|
if (opts.noglobstar) {
|
|
17461
17552
|
throw new TypeError("base matching requires globstar");
|
|
17462
17553
|
}
|
|
17463
|
-
pattern = pattern.map((
|
|
17554
|
+
pattern = pattern.map((p13) => p13.includes("/") ? p13 : `./**/${p13}`);
|
|
17464
17555
|
}
|
|
17465
17556
|
this.pattern = pattern;
|
|
17466
17557
|
this.platform = opts.platform || defaultPlatform3;
|
|
@@ -17495,7 +17586,7 @@ var Glob = class {
|
|
|
17495
17586
|
windowsPathsNoEscape: this.windowsPathsNoEscape,
|
|
17496
17587
|
debug: !!this.opts.debug
|
|
17497
17588
|
};
|
|
17498
|
-
const mms = this.pattern.map((
|
|
17589
|
+
const mms = this.pattern.map((p13) => new Minimatch(p13, mmo));
|
|
17499
17590
|
const [matchSet, globParts] = mms.reduce((set, m) => {
|
|
17500
17591
|
set[0].push(...m.set);
|
|
17501
17592
|
set[1].push(...m.globParts);
|
|
@@ -17575,8 +17666,8 @@ var hasMagic = (pattern, options = {}) => {
|
|
|
17575
17666
|
if (!Array.isArray(pattern)) {
|
|
17576
17667
|
pattern = [pattern];
|
|
17577
17668
|
}
|
|
17578
|
-
for (const
|
|
17579
|
-
if (new Minimatch(
|
|
17669
|
+
for (const p13 of pattern) {
|
|
17670
|
+
if (new Minimatch(p13, options).hasMagic())
|
|
17580
17671
|
return true;
|
|
17581
17672
|
}
|
|
17582
17673
|
return false;
|
|
@@ -17637,11 +17728,11 @@ async function findComponentDirectories(baseDir) {
|
|
|
17637
17728
|
const namedYmls = await glob(`${baseDir}/**/*.component.yml`);
|
|
17638
17729
|
const allComponentPaths = [...standardYmls, ...namedYmls];
|
|
17639
17730
|
const uniqueDirs = new Set(
|
|
17640
|
-
allComponentPaths.map((filePath) =>
|
|
17731
|
+
allComponentPaths.map((filePath) => path11.dirname(filePath))
|
|
17641
17732
|
);
|
|
17642
17733
|
let componentDirs = Array.from(uniqueDirs).sort();
|
|
17643
17734
|
let sdcs = await glob(`${baseDir}/**/*.twig`);
|
|
17644
|
-
sdcs = sdcs.map((sdc) =>
|
|
17735
|
+
sdcs = sdcs.map((sdc) => path11.dirname(sdc));
|
|
17645
17736
|
componentDirs = componentDirs.filter(
|
|
17646
17737
|
(componentDir) => !sdcs.includes(componentDir)
|
|
17647
17738
|
);
|
|
@@ -17652,50 +17743,244 @@ async function findComponentDirectories(baseDir) {
|
|
|
17652
17743
|
}
|
|
17653
17744
|
}
|
|
17654
17745
|
|
|
17655
|
-
// src/utils/
|
|
17656
|
-
async function selectLocalComponents(
|
|
17746
|
+
// src/utils/component-selector.ts
|
|
17747
|
+
async function selectLocalComponents(options) {
|
|
17657
17748
|
const config2 = getConfig();
|
|
17658
|
-
const
|
|
17659
|
-
const
|
|
17660
|
-
if (
|
|
17661
|
-
|
|
17662
|
-
|
|
17749
|
+
const componentDir = options.componentDir || config2.componentDir;
|
|
17750
|
+
const allLocalDirs = await findComponentDirectories(componentDir);
|
|
17751
|
+
if (allLocalDirs.length === 0) {
|
|
17752
|
+
throw new Error(`No local components were found in ${componentDir}`);
|
|
17753
|
+
}
|
|
17754
|
+
if (options.components) {
|
|
17755
|
+
return selectSpecificLocalComponents(
|
|
17756
|
+
options.components,
|
|
17757
|
+
allLocalDirs,
|
|
17758
|
+
options
|
|
17759
|
+
);
|
|
17663
17760
|
}
|
|
17664
|
-
if (
|
|
17665
|
-
|
|
17666
|
-
|
|
17761
|
+
if (options.all) {
|
|
17762
|
+
if (!options.skipConfirmation) {
|
|
17763
|
+
const confirmed = await confirmSelection(
|
|
17764
|
+
allLocalDirs.length,
|
|
17765
|
+
options.confirmMessage
|
|
17766
|
+
);
|
|
17767
|
+
if (!confirmed) {
|
|
17768
|
+
throw new Error("Operation cancelled by user");
|
|
17769
|
+
}
|
|
17770
|
+
}
|
|
17771
|
+
p.log.info(`Selected all components`);
|
|
17772
|
+
return { directories: allLocalDirs };
|
|
17667
17773
|
}
|
|
17668
|
-
|
|
17669
|
-
|
|
17774
|
+
return selectLocalComponentsInteractive(allLocalDirs, options);
|
|
17775
|
+
}
|
|
17776
|
+
async function selectSpecificLocalComponents(componentsInput, allLocalDirs, options) {
|
|
17777
|
+
const requestedNames = componentsInput.split(",").map((name) => name.trim()).filter((name) => name.length > 0);
|
|
17778
|
+
const notFound = [];
|
|
17779
|
+
const foundDirs = [];
|
|
17780
|
+
for (const requestedName of requestedNames) {
|
|
17781
|
+
const dir = allLocalDirs.find((d2) => path11.basename(d2) === requestedName);
|
|
17782
|
+
if (dir) {
|
|
17783
|
+
foundDirs.push(dir);
|
|
17784
|
+
} else {
|
|
17785
|
+
notFound.push(requestedName);
|
|
17786
|
+
}
|
|
17787
|
+
}
|
|
17788
|
+
if (notFound.length > 0) {
|
|
17789
|
+
const message = options.notFoundMessage || `The following component(s) were not found locally: ${notFound.join(", ")}`;
|
|
17790
|
+
throw new Error(message);
|
|
17791
|
+
}
|
|
17792
|
+
if (!options.skipConfirmation) {
|
|
17793
|
+
const confirmed = await confirmSelection(
|
|
17794
|
+
foundDirs.length,
|
|
17795
|
+
options.confirmMessage
|
|
17796
|
+
);
|
|
17797
|
+
if (!confirmed) {
|
|
17798
|
+
throw new Error("Operation cancelled by user");
|
|
17799
|
+
}
|
|
17800
|
+
}
|
|
17801
|
+
return { directories: foundDirs };
|
|
17802
|
+
}
|
|
17803
|
+
async function selectLocalComponentsInteractive(allLocalDirs, options) {
|
|
17804
|
+
const selectedDirs = await p.multiselect({
|
|
17805
|
+
message: options.selectMessage || "Select components",
|
|
17670
17806
|
options: [
|
|
17671
17807
|
{
|
|
17672
|
-
value:
|
|
17808
|
+
value: ALL_COMPONENTS_SELECTOR,
|
|
17673
17809
|
label: "All components"
|
|
17674
17810
|
},
|
|
17675
|
-
...
|
|
17811
|
+
...allLocalDirs.map((dir) => ({
|
|
17676
17812
|
value: dir,
|
|
17677
|
-
label:
|
|
17813
|
+
label: path11.basename(dir)
|
|
17678
17814
|
}))
|
|
17679
17815
|
],
|
|
17680
17816
|
required: true
|
|
17681
17817
|
});
|
|
17682
|
-
if (
|
|
17683
|
-
|
|
17684
|
-
|
|
17818
|
+
if (p.isCancel(selectedDirs)) {
|
|
17819
|
+
throw new Error("Operation cancelled by user");
|
|
17820
|
+
}
|
|
17821
|
+
const finalDirs = selectedDirs.includes(ALL_COMPONENTS_SELECTOR) ? allLocalDirs : selectedDirs;
|
|
17822
|
+
if (!options.skipConfirmation) {
|
|
17823
|
+
const confirmed = await confirmSelection(
|
|
17824
|
+
finalDirs.length,
|
|
17825
|
+
options.confirmMessage
|
|
17826
|
+
);
|
|
17827
|
+
if (!confirmed) {
|
|
17828
|
+
throw new Error("Operation cancelled by user");
|
|
17829
|
+
}
|
|
17830
|
+
}
|
|
17831
|
+
return { directories: finalDirs };
|
|
17832
|
+
}
|
|
17833
|
+
async function selectRemoteComponents(allComponents, options) {
|
|
17834
|
+
const componentCount = Object.keys(allComponents).length;
|
|
17835
|
+
if (componentCount === 0) {
|
|
17836
|
+
throw new Error("No components found");
|
|
17837
|
+
}
|
|
17838
|
+
if (options.all) {
|
|
17839
|
+
if (!options.skipConfirmation) {
|
|
17840
|
+
const confirmed = await confirmSelection(
|
|
17841
|
+
componentCount,
|
|
17842
|
+
options.confirmMessage
|
|
17843
|
+
);
|
|
17844
|
+
if (!confirmed) {
|
|
17845
|
+
throw new Error("Operation cancelled by user");
|
|
17846
|
+
}
|
|
17847
|
+
}
|
|
17848
|
+
return { components: allComponents };
|
|
17849
|
+
}
|
|
17850
|
+
if (options.components) {
|
|
17851
|
+
return selectSpecificRemoteComponents(
|
|
17852
|
+
options.components,
|
|
17853
|
+
allComponents,
|
|
17854
|
+
options
|
|
17855
|
+
);
|
|
17856
|
+
}
|
|
17857
|
+
return selectRemoteComponentsInteractive(allComponents, options);
|
|
17858
|
+
}
|
|
17859
|
+
async function selectSpecificRemoteComponents(componentsInput, allComponents, options) {
|
|
17860
|
+
const requestedNames = componentsInput.split(",").map((name) => name.trim()).filter((name) => name.length > 0);
|
|
17861
|
+
const notFound = [];
|
|
17862
|
+
const selected = {};
|
|
17863
|
+
for (const requestedName of requestedNames) {
|
|
17864
|
+
const component = allComponents[requestedName];
|
|
17865
|
+
if (component) {
|
|
17866
|
+
selected[requestedName] = component;
|
|
17867
|
+
} else {
|
|
17868
|
+
notFound.push(requestedName);
|
|
17869
|
+
}
|
|
17870
|
+
}
|
|
17871
|
+
if (notFound.length > 0) {
|
|
17872
|
+
const message = options.notFoundMessage || `The following component(s) were not found: ${notFound.join(", ")}`;
|
|
17873
|
+
throw new Error(message);
|
|
17874
|
+
}
|
|
17875
|
+
if (!options.skipConfirmation) {
|
|
17876
|
+
const confirmed = await confirmSelection(
|
|
17877
|
+
Object.keys(selected).length,
|
|
17878
|
+
options.confirmMessage
|
|
17879
|
+
);
|
|
17880
|
+
if (!confirmed) {
|
|
17881
|
+
throw new Error("Operation cancelled by user");
|
|
17882
|
+
}
|
|
17685
17883
|
}
|
|
17686
|
-
|
|
17687
|
-
|
|
17688
|
-
|
|
17884
|
+
return { components: selected };
|
|
17885
|
+
}
|
|
17886
|
+
async function selectRemoteComponentsInteractive(allComponents, options) {
|
|
17887
|
+
const selectedMachineNames = await p.multiselect({
|
|
17888
|
+
message: options.selectMessage || "Select components to download",
|
|
17889
|
+
options: [
|
|
17890
|
+
{
|
|
17891
|
+
value: ALL_COMPONENTS_SELECTOR,
|
|
17892
|
+
label: "All components"
|
|
17893
|
+
},
|
|
17894
|
+
...Object.keys(allComponents).map((key) => ({
|
|
17895
|
+
value: allComponents[key].machineName,
|
|
17896
|
+
label: `${allComponents[key].name} (${allComponents[key].machineName})`
|
|
17897
|
+
}))
|
|
17898
|
+
],
|
|
17899
|
+
required: true
|
|
17900
|
+
});
|
|
17901
|
+
if (p.isCancel(selectedMachineNames)) {
|
|
17902
|
+
throw new Error("Operation cancelled by user");
|
|
17903
|
+
}
|
|
17904
|
+
const selected = selectedMachineNames.includes(
|
|
17905
|
+
ALL_COMPONENTS_SELECTOR
|
|
17906
|
+
) ? allComponents : Object.fromEntries(
|
|
17907
|
+
Object.entries(allComponents).filter(
|
|
17908
|
+
([, component]) => selectedMachineNames.includes(component.machineName)
|
|
17909
|
+
)
|
|
17910
|
+
);
|
|
17911
|
+
if (!options.skipConfirmation) {
|
|
17912
|
+
const confirmed = await confirmSelection(
|
|
17913
|
+
Object.keys(selected).length,
|
|
17914
|
+
options.confirmMessage
|
|
17915
|
+
);
|
|
17916
|
+
if (!confirmed) {
|
|
17917
|
+
throw new Error("Operation cancelled by user");
|
|
17918
|
+
}
|
|
17919
|
+
}
|
|
17920
|
+
return { components: selected };
|
|
17921
|
+
}
|
|
17922
|
+
async function confirmSelection(count, customMessage) {
|
|
17923
|
+
const componentLabel = count === 1 ? "component" : "components";
|
|
17924
|
+
const message = customMessage || `Process ${count} ${componentLabel}?`;
|
|
17925
|
+
const confirmed = await p.confirm({
|
|
17926
|
+
message,
|
|
17689
17927
|
initialValue: true
|
|
17690
17928
|
});
|
|
17691
|
-
if (
|
|
17692
|
-
|
|
17693
|
-
return null;
|
|
17929
|
+
if (p.isCancel(confirmed) || !confirmed) {
|
|
17930
|
+
return false;
|
|
17694
17931
|
}
|
|
17695
|
-
|
|
17696
|
-
|
|
17932
|
+
return true;
|
|
17933
|
+
}
|
|
17934
|
+
function reportResults(results, title, itemLabel = "Component") {
|
|
17935
|
+
results.sort((a, b) => a.itemName.localeCompare(b.itemName));
|
|
17936
|
+
const successful = results.filter((r) => r.success).length;
|
|
17937
|
+
const failed = results.filter((r) => !r.success).length;
|
|
17938
|
+
const hasDetails = results.some((r) => (r.details?.length ?? 0) > 0);
|
|
17939
|
+
const succeededText = failed === 0 ? chalk2.green(`${successful} succeeded`) : `${successful} succeeded`;
|
|
17940
|
+
const failedText = failed > 0 ? chalk2.red(`${failed} failed`) : chalk2.dim(`${failed} failed`);
|
|
17941
|
+
const summary = `${succeededText}, ${failedText}`;
|
|
17942
|
+
if (results.length > 0) {
|
|
17943
|
+
const tableData = [
|
|
17944
|
+
hasDetails ? [chalk2.bold(title), "", ""] : [chalk2.bold(title), ""],
|
|
17945
|
+
hasDetails ? [itemLabel, "Status", "Details"] : [itemLabel, "Status"],
|
|
17946
|
+
...results.map(
|
|
17947
|
+
(r) => hasDetails ? [
|
|
17948
|
+
r.itemName,
|
|
17949
|
+
r.success ? chalk2.green("Success") : chalk2.red("Failed"),
|
|
17950
|
+
r.details?.map(
|
|
17951
|
+
(d2) => d2.heading ? `${chalk2.underline(d2.heading)}:
|
|
17952
|
+
${d2.content}` : d2.content
|
|
17953
|
+
).join("\n\n") ?? ""
|
|
17954
|
+
] : [
|
|
17955
|
+
r.itemName,
|
|
17956
|
+
r.success ? chalk2.green("Success") : chalk2.red("Failed")
|
|
17957
|
+
]
|
|
17958
|
+
),
|
|
17959
|
+
hasDetails ? ["SUMMARY", "", summary] : ["SUMMARY", summary]
|
|
17960
|
+
];
|
|
17961
|
+
p.log.info(
|
|
17962
|
+
table(tableData, {
|
|
17963
|
+
spanningCells: [
|
|
17964
|
+
{
|
|
17965
|
+
row: 0,
|
|
17966
|
+
col: 0,
|
|
17967
|
+
colSpan: hasDetails ? 3 : 2,
|
|
17968
|
+
alignment: "center"
|
|
17969
|
+
},
|
|
17970
|
+
{
|
|
17971
|
+
row: results.length + 2,
|
|
17972
|
+
col: 0,
|
|
17973
|
+
colSpan: hasDetails ? 2 : 1,
|
|
17974
|
+
alignment: hasDetails ? "right" : "left"
|
|
17975
|
+
}
|
|
17976
|
+
],
|
|
17977
|
+
columns: {
|
|
17978
|
+
// Limit the width of the details column for improved readability of long details.
|
|
17979
|
+
2: { width: 100, wrapWord: true }
|
|
17980
|
+
}
|
|
17981
|
+
})
|
|
17982
|
+
);
|
|
17697
17983
|
}
|
|
17698
|
-
return selectedDirs;
|
|
17699
17984
|
}
|
|
17700
17985
|
|
|
17701
17986
|
// src/commands/build.ts
|
|
@@ -17703,75 +17988,84 @@ function buildCommand(program2) {
|
|
|
17703
17988
|
program2.command("build").description("build local components and Tailwind CSS assets").option(
|
|
17704
17989
|
"-d, --dir <directory>",
|
|
17705
17990
|
"Component directory to build the components in"
|
|
17706
|
-
).option("--all", "Build all components").option(
|
|
17707
|
-
|
|
17708
|
-
|
|
17709
|
-
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
17713
|
-
|
|
17714
|
-
|
|
17715
|
-
|
|
17716
|
-
|
|
17717
|
-
|
|
17718
|
-
|
|
17719
|
-
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
|
|
17724
|
-
|
|
17725
|
-
|
|
17726
|
-
|
|
17727
|
-
const s1 = p9.spinner();
|
|
17728
|
-
s1.start(`Building ${componentLabelPluralized}`);
|
|
17729
|
-
const results = [];
|
|
17730
|
-
for (const componentDir of selectedComponents) {
|
|
17731
|
-
results.push(await buildComponent(componentDir));
|
|
17732
|
-
}
|
|
17733
|
-
s1.stop(
|
|
17734
|
-
chalk2.green(
|
|
17735
|
-
`Processed ${selectedComponents.length} ${componentLabelPluralized}`
|
|
17736
|
-
)
|
|
17737
|
-
);
|
|
17738
|
-
reportResults(results, "Built components", "Component");
|
|
17739
|
-
if (results.map((result) => result.success).includes(false)) {
|
|
17740
|
-
process.exit(1);
|
|
17741
|
-
}
|
|
17742
|
-
if (skipTailwind) {
|
|
17743
|
-
p9.log.info("Skipping Tailwind CSS build");
|
|
17744
|
-
} else {
|
|
17745
|
-
const s2 = p9.spinner();
|
|
17746
|
-
s2.start("Building Tailwind CSS");
|
|
17747
|
-
const tailwindResult = await buildTailwindForComponents(
|
|
17748
|
-
selectedComponents
|
|
17991
|
+
).option("--all", "Build all components").option(
|
|
17992
|
+
"-c, --components <names>",
|
|
17993
|
+
"Specific component(s) to build (comma-separated)"
|
|
17994
|
+
).option("--no-tailwind", "Skip Tailwind CSS building").option("-y, --yes", "Skip confirmation prompts").option("--client-id <id>", "Client ID").option("--client-secret <secret>", "Client Secret").option("--site-url <url>", "Site URL").option("--verbose", "Enable verbose output").action(async (options) => {
|
|
17995
|
+
try {
|
|
17996
|
+
p.intro(chalk2.bold("Drupal Canvas CLI: build"));
|
|
17997
|
+
validateComponentOptions(options);
|
|
17998
|
+
const allFlag = options.all || options.yes && !options.components || false;
|
|
17999
|
+
const skipTailwind = !options.tailwind;
|
|
18000
|
+
updateConfigFromOptions(options);
|
|
18001
|
+
if (!skipTailwind) {
|
|
18002
|
+
await ensureConfig(["siteUrl", "clientId", "clientSecret"]);
|
|
18003
|
+
}
|
|
18004
|
+
const { directories: componentsToBuild } = await selectLocalComponents({
|
|
18005
|
+
all: allFlag,
|
|
18006
|
+
components: options.components,
|
|
18007
|
+
skipConfirmation: options.yes,
|
|
18008
|
+
selectMessage: "Select components to build"
|
|
18009
|
+
});
|
|
18010
|
+
const componentLabelPluralized = pluralizeComponent(
|
|
18011
|
+
componentsToBuild.length
|
|
17749
18012
|
);
|
|
17750
|
-
|
|
18013
|
+
const s1 = p.spinner();
|
|
18014
|
+
s1.start(`Building ${componentLabelPluralized}`);
|
|
18015
|
+
const results = [];
|
|
18016
|
+
for (const componentDir of componentsToBuild) {
|
|
18017
|
+
results.push(await buildComponent(componentDir));
|
|
18018
|
+
}
|
|
18019
|
+
s1.stop(
|
|
17751
18020
|
chalk2.green(
|
|
17752
|
-
`Processed
|
|
18021
|
+
`Processed ${componentsToBuild.length} ${componentLabelPluralized}`
|
|
17753
18022
|
)
|
|
17754
18023
|
);
|
|
17755
|
-
reportResults(
|
|
17756
|
-
if (
|
|
17757
|
-
|
|
18024
|
+
reportResults(results, "Built components", "Component");
|
|
18025
|
+
if (results.map((result) => result.success).includes(false)) {
|
|
18026
|
+
process.exit(1);
|
|
18027
|
+
}
|
|
18028
|
+
if (skipTailwind) {
|
|
18029
|
+
p.log.info("Skipping Tailwind CSS build");
|
|
18030
|
+
} else {
|
|
18031
|
+
const s2 = p.spinner();
|
|
18032
|
+
s2.start("Building Tailwind CSS");
|
|
18033
|
+
const tailwindResult = await buildTailwindForComponents(
|
|
18034
|
+
componentsToBuild
|
|
18035
|
+
);
|
|
18036
|
+
s2.stop(
|
|
18037
|
+
chalk2.green(
|
|
18038
|
+
`Processed Tailwind CSS classes from ${componentsToBuild.length} selected local ${componentLabelPluralized} and all online components`
|
|
18039
|
+
)
|
|
18040
|
+
);
|
|
18041
|
+
reportResults([tailwindResult], "Built assets", "Asset");
|
|
18042
|
+
if (!tailwindResult.success) {
|
|
18043
|
+
return process.exit(1);
|
|
18044
|
+
}
|
|
17758
18045
|
}
|
|
18046
|
+
p.outro(`\u{1F4E6} Build completed`);
|
|
18047
|
+
} catch (error) {
|
|
18048
|
+
if (error instanceof Error) {
|
|
18049
|
+
p.note(chalk2.red(`Error: ${error.message}`));
|
|
18050
|
+
} else {
|
|
18051
|
+
p.note(chalk2.red(`Unknown error: ${String(error)}`));
|
|
18052
|
+
}
|
|
18053
|
+
process.exit(1);
|
|
17759
18054
|
}
|
|
17760
|
-
p9.outro(`\u{1F4E6} Build completed`);
|
|
17761
18055
|
});
|
|
17762
18056
|
}
|
|
17763
18057
|
function downloadCommand(program2) {
|
|
17764
|
-
program2.command("download").description("download components to your local filesystem").option("--client-id <id>", "Client ID").option("--client-secret <secret>", "Client Secret").option("--site-url <url>", "Site URL").option("--scope <scope>", "Scope").option("-d, --dir <directory>", "Component directory").option(
|
|
17765
|
-
|
|
18058
|
+
program2.command("download").description("download components to your local filesystem").option("--client-id <id>", "Client ID").option("--client-secret <secret>", "Client Secret").option("--site-url <url>", "Site URL").option("--scope <scope>", "Scope").option("-d, --dir <directory>", "Component directory").option(
|
|
18059
|
+
"-c, --components <names>",
|
|
18060
|
+
"Specific component(s) to download (comma-separated)"
|
|
18061
|
+
).option("--all", "Download all components").option("-y, --yes", "Skip all confirmation prompts").option(
|
|
18062
|
+
"--skip-overwrite",
|
|
18063
|
+
"Skip downloading components that already exist locally"
|
|
18064
|
+
).option("--verbose", "Enable verbose output").action(async (options) => {
|
|
18065
|
+
p.intro(chalk2.bold("Drupal Canvas CLI: download"));
|
|
17766
18066
|
try {
|
|
17767
|
-
|
|
17768
|
-
|
|
17769
|
-
setConfig({ clientSecret: options.clientSecret });
|
|
17770
|
-
if (options.siteUrl) setConfig({ siteUrl: options.siteUrl });
|
|
17771
|
-
if (options.dir) setConfig({ componentDir: options.dir });
|
|
17772
|
-
if (options.all) setConfig({ all: options.all });
|
|
17773
|
-
if (options.scope) setConfig({ scope: options.scope });
|
|
17774
|
-
if (options.verbose) setConfig({ verbose: true });
|
|
18067
|
+
validateComponentOptions(options);
|
|
18068
|
+
updateConfigFromOptions(options);
|
|
17775
18069
|
await ensureConfig([
|
|
17776
18070
|
"siteUrl",
|
|
17777
18071
|
"clientId",
|
|
@@ -17781,7 +18075,7 @@ function downloadCommand(program2) {
|
|
|
17781
18075
|
]);
|
|
17782
18076
|
const config2 = getConfig();
|
|
17783
18077
|
const apiService = await createApiService();
|
|
17784
|
-
const s =
|
|
18078
|
+
const s = p.spinner();
|
|
17785
18079
|
s.start("Fetching components");
|
|
17786
18080
|
const components = await apiService.listComponents();
|
|
17787
18081
|
const {
|
|
@@ -17789,69 +18083,27 @@ function downloadCommand(program2) {
|
|
|
17789
18083
|
} = await apiService.getGlobalAssetLibrary();
|
|
17790
18084
|
if (Object.keys(components).length === 0) {
|
|
17791
18085
|
s.stop("No components found");
|
|
17792
|
-
|
|
18086
|
+
p.outro("Download cancelled - no components were found");
|
|
17793
18087
|
return;
|
|
17794
18088
|
}
|
|
17795
18089
|
s.stop(`Found ${Object.keys(components).length} components`);
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
|
|
17801
|
-
|
|
17802
|
-
|
|
17803
|
-
if (!component) {
|
|
17804
|
-
p9.note(chalk2.red(`Component "${options.component}" not found`));
|
|
17805
|
-
p9.outro("Download cancelled");
|
|
17806
|
-
return;
|
|
17807
|
-
}
|
|
17808
|
-
componentsToDownload = { component };
|
|
17809
|
-
} else {
|
|
17810
|
-
const selectedComponents = await p9.multiselect({
|
|
17811
|
-
message: "Select components to download",
|
|
17812
|
-
options: [
|
|
17813
|
-
{
|
|
17814
|
-
value: "_allComponents",
|
|
17815
|
-
label: "All components"
|
|
17816
|
-
},
|
|
17817
|
-
...Object.keys(components).map((key) => ({
|
|
17818
|
-
value: components[key].machineName,
|
|
17819
|
-
label: `${components[key].name} (${components[key].machineName})`
|
|
17820
|
-
}))
|
|
17821
|
-
],
|
|
17822
|
-
required: true
|
|
17823
|
-
});
|
|
17824
|
-
if (p9.isCancel(selectedComponents)) {
|
|
17825
|
-
p9.cancel("Operation cancelled");
|
|
17826
|
-
return;
|
|
17827
|
-
}
|
|
17828
|
-
if (selectedComponents.includes("_allComponents")) {
|
|
17829
|
-
componentsToDownload = components;
|
|
17830
|
-
} else {
|
|
17831
|
-
componentsToDownload = Object.fromEntries(
|
|
17832
|
-
Object.entries(components).filter(
|
|
17833
|
-
([, component]) => selectedComponents.includes(
|
|
17834
|
-
component.machineName
|
|
17835
|
-
)
|
|
17836
|
-
)
|
|
17837
|
-
);
|
|
17838
|
-
}
|
|
17839
|
-
}
|
|
17840
|
-
const componentPluralized = `component${Object.keys(componentsToDownload).length > 1 ? "s" : ""}`;
|
|
17841
|
-
const confirmDownload = await p9.confirm({
|
|
17842
|
-
message: `Download ${Object.keys(componentsToDownload).length} ${componentPluralized} to ${config2.componentDir}?`,
|
|
17843
|
-
initialValue: true
|
|
18090
|
+
const allFlag = options.all || options.yes && !options.components || false;
|
|
18091
|
+
const { components: componentsToDownload } = await selectRemoteComponents(components, {
|
|
18092
|
+
all: allFlag,
|
|
18093
|
+
components: options.components,
|
|
18094
|
+
skipConfirmation: options.yes,
|
|
18095
|
+
selectMessage: "Select components to download",
|
|
18096
|
+
confirmMessage: `Download to ${config2.componentDir}?`
|
|
17844
18097
|
});
|
|
17845
|
-
|
|
17846
|
-
|
|
17847
|
-
|
|
17848
|
-
}
|
|
18098
|
+
const componentPluralized = pluralizeComponent(
|
|
18099
|
+
Object.keys(componentsToDownload).length
|
|
18100
|
+
);
|
|
17849
18101
|
const results = [];
|
|
17850
18102
|
s.start(`Downloading ${componentPluralized}`);
|
|
17851
18103
|
for (const key in componentsToDownload) {
|
|
17852
18104
|
const component = componentsToDownload[key];
|
|
17853
18105
|
try {
|
|
17854
|
-
const componentDir =
|
|
18106
|
+
const componentDir = path11.join(
|
|
17855
18107
|
config2.componentDir,
|
|
17856
18108
|
component.machineName
|
|
17857
18109
|
);
|
|
@@ -17859,13 +18111,27 @@ function downloadCommand(program2) {
|
|
|
17859
18111
|
if (dirExists) {
|
|
17860
18112
|
const files = await fs2.readdir(componentDir);
|
|
17861
18113
|
if (files.length > 0) {
|
|
17862
|
-
|
|
17863
|
-
|
|
17864
|
-
|
|
17865
|
-
|
|
17866
|
-
|
|
17867
|
-
|
|
17868
|
-
|
|
18114
|
+
if (options.skipOverwrite) {
|
|
18115
|
+
results.push({
|
|
18116
|
+
itemName: component.machineName,
|
|
18117
|
+
success: true,
|
|
18118
|
+
details: [
|
|
18119
|
+
{
|
|
18120
|
+
content: "Skipped (already exists)"
|
|
18121
|
+
}
|
|
18122
|
+
]
|
|
18123
|
+
});
|
|
18124
|
+
continue;
|
|
18125
|
+
}
|
|
18126
|
+
if (!options.yes) {
|
|
18127
|
+
const confirmDelete = await p.confirm({
|
|
18128
|
+
message: `The "${componentDir}" directory is not empty. Are you sure you want to delete and overwrite this directory?`,
|
|
18129
|
+
initialValue: true
|
|
18130
|
+
});
|
|
18131
|
+
if (p.isCancel(confirmDelete) || !confirmDelete) {
|
|
18132
|
+
p.cancel("Operation cancelled");
|
|
18133
|
+
process.exit(0);
|
|
18134
|
+
}
|
|
17869
18135
|
}
|
|
17870
18136
|
}
|
|
17871
18137
|
}
|
|
@@ -17882,20 +18148,20 @@ function downloadCommand(program2) {
|
|
|
17882
18148
|
slots: component.slots || {}
|
|
17883
18149
|
};
|
|
17884
18150
|
await fs2.writeFile(
|
|
17885
|
-
|
|
18151
|
+
path11.join(componentDir, `component.yml`),
|
|
17886
18152
|
yaml__default.dump(metadata),
|
|
17887
18153
|
"utf-8"
|
|
17888
18154
|
);
|
|
17889
18155
|
if (component.sourceCodeJs) {
|
|
17890
18156
|
await fs2.writeFile(
|
|
17891
|
-
|
|
18157
|
+
path11.join(componentDir, `index.jsx`),
|
|
17892
18158
|
component.sourceCodeJs,
|
|
17893
18159
|
"utf-8"
|
|
17894
18160
|
);
|
|
17895
18161
|
}
|
|
17896
18162
|
if (component.sourceCodeCss) {
|
|
17897
18163
|
await fs2.writeFile(
|
|
17898
|
-
|
|
18164
|
+
path11.join(componentDir, `index.css`),
|
|
17899
18165
|
component.sourceCodeCss,
|
|
17900
18166
|
"utf-8"
|
|
17901
18167
|
);
|
|
@@ -17925,7 +18191,7 @@ function downloadCommand(program2) {
|
|
|
17925
18191
|
if (globalCss) {
|
|
17926
18192
|
let globalCssResult;
|
|
17927
18193
|
try {
|
|
17928
|
-
const globalCssPath =
|
|
18194
|
+
const globalCssPath = path11.join(config2.componentDir, "global.css");
|
|
17929
18195
|
await fs2.writeFile(globalCssPath, globalCss, "utf-8");
|
|
17930
18196
|
globalCssResult = {
|
|
17931
18197
|
itemName: "global.css",
|
|
@@ -17945,12 +18211,12 @@ function downloadCommand(program2) {
|
|
|
17945
18211
|
}
|
|
17946
18212
|
reportResults([globalCssResult], "Downloaded assets", "Asset");
|
|
17947
18213
|
}
|
|
17948
|
-
|
|
18214
|
+
p.outro(`\u2B07\uFE0F Download command completed`);
|
|
17949
18215
|
} catch (error) {
|
|
17950
18216
|
if (error instanceof Error) {
|
|
17951
|
-
|
|
18217
|
+
p.note(chalk2.red(`Error: ${error.message}`));
|
|
17952
18218
|
} else {
|
|
17953
|
-
|
|
18219
|
+
p.note(chalk2.red(`Unknown error: ${String(error)}`));
|
|
17954
18220
|
}
|
|
17955
18221
|
process.exit(1);
|
|
17956
18222
|
}
|
|
@@ -17964,7 +18230,7 @@ function scaffoldCommand(program2) {
|
|
|
17964
18230
|
"-d, --dir <directory>",
|
|
17965
18231
|
"Component directory to create component in"
|
|
17966
18232
|
).option("--verbose", "Enable verbose output").action(async (options) => {
|
|
17967
|
-
|
|
18233
|
+
p.intro(chalk2.bold("Drupal Canvas CLI: scaffold"));
|
|
17968
18234
|
try {
|
|
17969
18235
|
if (options.dir) setConfig({ componentDir: options.dir });
|
|
17970
18236
|
if (options.verbose) setConfig({ verbose: options.verbose });
|
|
@@ -17972,7 +18238,7 @@ function scaffoldCommand(program2) {
|
|
|
17972
18238
|
const baseDir = config2.componentDir;
|
|
17973
18239
|
let componentName = options.name;
|
|
17974
18240
|
if (!componentName) {
|
|
17975
|
-
const name = await
|
|
18241
|
+
const name = await p.text({
|
|
17976
18242
|
message: "Enter the component name",
|
|
17977
18243
|
placeholder: "my-component",
|
|
17978
18244
|
validate: (value) => {
|
|
@@ -17982,57 +18248,57 @@ function scaffoldCommand(program2) {
|
|
|
17982
18248
|
return;
|
|
17983
18249
|
}
|
|
17984
18250
|
});
|
|
17985
|
-
if (
|
|
17986
|
-
|
|
18251
|
+
if (p.isCancel(name)) {
|
|
18252
|
+
p.cancel("Operation cancelled");
|
|
17987
18253
|
return;
|
|
17988
18254
|
}
|
|
17989
18255
|
componentName = name;
|
|
17990
18256
|
}
|
|
17991
|
-
const componentDir =
|
|
17992
|
-
const s =
|
|
18257
|
+
const componentDir = path11.join(baseDir, componentName);
|
|
18258
|
+
const s = p.spinner();
|
|
17993
18259
|
s.start(`Creating component "${componentName}"`);
|
|
17994
18260
|
try {
|
|
17995
18261
|
await fs2.mkdir(componentDir, { recursive: true });
|
|
17996
|
-
const templateDir =
|
|
17997
|
-
|
|
18262
|
+
const templateDir = path11.join(
|
|
18263
|
+
path11.dirname(new URL(import.meta.url).pathname),
|
|
17998
18264
|
"templates/hello-world"
|
|
17999
18265
|
);
|
|
18000
18266
|
const files = await fs2.readdir(templateDir);
|
|
18001
18267
|
const newDirFiles = await fs2.readdir(componentDir);
|
|
18002
18268
|
if (newDirFiles.length > 0) {
|
|
18003
|
-
const confirmDelete = await
|
|
18269
|
+
const confirmDelete = await p.confirm({
|
|
18004
18270
|
message: `The "${componentDir}" directory is not empty. Do you want to proceed and potentially overwrite existing files?`,
|
|
18005
18271
|
initialValue: true
|
|
18006
18272
|
});
|
|
18007
|
-
if (
|
|
18008
|
-
|
|
18273
|
+
if (p.isCancel(confirmDelete) || !confirmDelete) {
|
|
18274
|
+
p.cancel("Operation cancelled");
|
|
18009
18275
|
process.exit(0);
|
|
18010
18276
|
}
|
|
18011
18277
|
}
|
|
18012
18278
|
for (const file of files) {
|
|
18013
|
-
const srcPath =
|
|
18014
|
-
const destPath =
|
|
18279
|
+
const srcPath = path11.join(templateDir, file);
|
|
18280
|
+
const destPath = path11.join(componentDir, file);
|
|
18015
18281
|
let content = await fs2.readFile(srcPath, "utf-8");
|
|
18016
18282
|
const { pascalCaseName, className, displayName, machineName } = generateComponentNameFormats(componentName);
|
|
18017
18283
|
content = content.replace(/HelloWorld/g, pascalCaseName).replace(/hello-world-component/g, className).replace(/Hello World/g, displayName).replace(/hello_world/g, machineName);
|
|
18018
18284
|
await fs2.writeFile(destPath, content, "utf-8");
|
|
18019
18285
|
}
|
|
18020
18286
|
s.stop(chalk2.green(`Created component "${componentName}"`));
|
|
18021
|
-
|
|
18287
|
+
p.note(`Component "${componentName}" has been created:
|
|
18022
18288
|
- Directory: ${componentDir}
|
|
18023
|
-
- Component metadata: ${
|
|
18024
|
-
- Source file: ${
|
|
18025
|
-
- CSS file: ${
|
|
18026
|
-
|
|
18289
|
+
- Component metadata: ${path11.join(componentDir, `component.yml`)}
|
|
18290
|
+
- Source file: ${path11.join(componentDir, `index.jsx`)}
|
|
18291
|
+
- CSS file: ${path11.join(componentDir, `index.css`)}`);
|
|
18292
|
+
p.outro("\u{1F3D7}\uFE0F Scaffold command completed");
|
|
18027
18293
|
} catch (error) {
|
|
18028
18294
|
s.stop(chalk2.red(`Failed to create component "${componentName}"`));
|
|
18029
18295
|
throw error;
|
|
18030
18296
|
}
|
|
18031
18297
|
} catch (error) {
|
|
18032
18298
|
if (error instanceof Error) {
|
|
18033
|
-
|
|
18299
|
+
p.note(chalk2.red(`Error: ${error.message}`));
|
|
18034
18300
|
} else {
|
|
18035
|
-
|
|
18301
|
+
p.note(chalk2.red(`Unknown error: ${String(error)}`));
|
|
18036
18302
|
}
|
|
18037
18303
|
process.exit(1);
|
|
18038
18304
|
}
|
|
@@ -18100,20 +18366,20 @@ var getDataDependenciesFromAst = (ast) => ast.program.body.filter((d2) => d2.typ
|
|
|
18100
18366
|
async function processComponentFiles(componentDir) {
|
|
18101
18367
|
const metadataPath = await findMetadataPath(componentDir);
|
|
18102
18368
|
const metadata = await readComponentMetadata(metadataPath);
|
|
18103
|
-
const distDir =
|
|
18369
|
+
const distDir = path11.join(componentDir, "dist");
|
|
18104
18370
|
const sourceCodeJs = await promises.readFile(
|
|
18105
|
-
|
|
18371
|
+
path11.join(componentDir, "index.jsx"),
|
|
18106
18372
|
"utf-8"
|
|
18107
18373
|
);
|
|
18108
|
-
const compiledJs = await promises.readFile(
|
|
18374
|
+
const compiledJs = await promises.readFile(path11.join(distDir, "index.js"), "utf-8");
|
|
18109
18375
|
let sourceCodeCss = "";
|
|
18110
18376
|
let compiledCss = "";
|
|
18111
18377
|
try {
|
|
18112
18378
|
sourceCodeCss = await promises.readFile(
|
|
18113
|
-
|
|
18379
|
+
path11.join(componentDir, "index.css"),
|
|
18114
18380
|
"utf-8"
|
|
18115
18381
|
);
|
|
18116
|
-
compiledCss = await promises.readFile(
|
|
18382
|
+
compiledCss = await promises.readFile(path11.join(distDir, "index.css"), "utf-8");
|
|
18117
18383
|
} catch {
|
|
18118
18384
|
}
|
|
18119
18385
|
return {
|
|
@@ -18125,7 +18391,7 @@ async function processComponentFiles(componentDir) {
|
|
|
18125
18391
|
};
|
|
18126
18392
|
}
|
|
18127
18393
|
async function findMetadataPath(componentDir) {
|
|
18128
|
-
const metadataPath =
|
|
18394
|
+
const metadataPath = path11.join(componentDir, "component.yml");
|
|
18129
18395
|
try {
|
|
18130
18396
|
await promises.access(metadataPath);
|
|
18131
18397
|
return metadataPath;
|
|
@@ -18146,10 +18412,10 @@ async function readComponentMetadata(filePath) {
|
|
|
18146
18412
|
}
|
|
18147
18413
|
const metadata = rawMetadata;
|
|
18148
18414
|
if (!metadata.name) {
|
|
18149
|
-
metadata.name =
|
|
18415
|
+
metadata.name = path11.basename(path11.dirname(filePath));
|
|
18150
18416
|
}
|
|
18151
18417
|
if (!metadata.machineName) {
|
|
18152
|
-
metadata.machineName =
|
|
18418
|
+
metadata.machineName = path11.basename(path11.dirname(filePath));
|
|
18153
18419
|
}
|
|
18154
18420
|
if (!metadata.slots || typeof metadata.slots !== "object") {
|
|
18155
18421
|
metadata.slots = {};
|
|
@@ -18193,21 +18459,139 @@ function createComponentPayload(params) {
|
|
|
18193
18459
|
};
|
|
18194
18460
|
}
|
|
18195
18461
|
|
|
18462
|
+
// src/utils/request-pool.ts
|
|
18463
|
+
async function processInPool(items, processor, concurrency = 10) {
|
|
18464
|
+
const results = [];
|
|
18465
|
+
for (let i = 0; i < items.length; i += concurrency) {
|
|
18466
|
+
const batch = items.slice(i, i + concurrency);
|
|
18467
|
+
const batchStartIndex = i;
|
|
18468
|
+
const batchPromises = batch.map(async (item, batchIndex) => {
|
|
18469
|
+
const globalIndex = batchStartIndex + batchIndex;
|
|
18470
|
+
try {
|
|
18471
|
+
const result = await processor(item, globalIndex);
|
|
18472
|
+
return { success: true, result, index: globalIndex };
|
|
18473
|
+
} catch (error) {
|
|
18474
|
+
return {
|
|
18475
|
+
success: false,
|
|
18476
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
18477
|
+
index: globalIndex
|
|
18478
|
+
};
|
|
18479
|
+
}
|
|
18480
|
+
});
|
|
18481
|
+
const batchResults = await Promise.allSettled(batchPromises);
|
|
18482
|
+
for (const settledResult of batchResults) {
|
|
18483
|
+
if (settledResult.status === "fulfilled") {
|
|
18484
|
+
results.push(settledResult.value);
|
|
18485
|
+
} else {
|
|
18486
|
+
results.push({
|
|
18487
|
+
success: false,
|
|
18488
|
+
error: new Error(`Batch processing failed: ${settledResult.reason}`),
|
|
18489
|
+
index: results.length
|
|
18490
|
+
});
|
|
18491
|
+
}
|
|
18492
|
+
}
|
|
18493
|
+
}
|
|
18494
|
+
return results.sort((a, b) => a.index - b.index);
|
|
18495
|
+
}
|
|
18496
|
+
function createProgressCallback(spinner6, operation, total) {
|
|
18497
|
+
let completed = 0;
|
|
18498
|
+
return () => {
|
|
18499
|
+
completed++;
|
|
18500
|
+
const percentage = Math.round(completed / total * 100);
|
|
18501
|
+
spinner6.message(`${operation} (${completed}/${total} - ${percentage}%)`);
|
|
18502
|
+
};
|
|
18503
|
+
}
|
|
18504
|
+
|
|
18196
18505
|
// src/commands/upload.ts
|
|
18506
|
+
async function checkComponentsExist(machineNames, apiService, onProgress) {
|
|
18507
|
+
try {
|
|
18508
|
+
const existingComponents = await apiService.listComponents();
|
|
18509
|
+
const existingMachineNames = new Set(Object.keys(existingComponents));
|
|
18510
|
+
return machineNames.map((machineName) => {
|
|
18511
|
+
onProgress();
|
|
18512
|
+
return {
|
|
18513
|
+
machineName,
|
|
18514
|
+
exists: existingMachineNames.has(machineName)
|
|
18515
|
+
};
|
|
18516
|
+
});
|
|
18517
|
+
} catch (error) {
|
|
18518
|
+
return machineNames.map((machineName) => {
|
|
18519
|
+
onProgress();
|
|
18520
|
+
return {
|
|
18521
|
+
machineName,
|
|
18522
|
+
exists: false,
|
|
18523
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
18524
|
+
};
|
|
18525
|
+
});
|
|
18526
|
+
}
|
|
18527
|
+
}
|
|
18528
|
+
async function uploadComponents(uploadTasks, apiService, onProgress) {
|
|
18529
|
+
const results = await processInPool(uploadTasks, async (task) => {
|
|
18530
|
+
try {
|
|
18531
|
+
if (task.shouldUpdate) {
|
|
18532
|
+
await apiService.updateComponent(
|
|
18533
|
+
task.machineName,
|
|
18534
|
+
task.componentPayload
|
|
18535
|
+
);
|
|
18536
|
+
} else {
|
|
18537
|
+
await apiService.createComponent(task.componentPayload, true);
|
|
18538
|
+
}
|
|
18539
|
+
onProgress?.();
|
|
18540
|
+
return {
|
|
18541
|
+
machineName: task.machineName,
|
|
18542
|
+
success: true,
|
|
18543
|
+
operation: task.shouldUpdate ? "update" : "create"
|
|
18544
|
+
};
|
|
18545
|
+
} catch {
|
|
18546
|
+
try {
|
|
18547
|
+
if (task.shouldUpdate) {
|
|
18548
|
+
await apiService.updateComponent(
|
|
18549
|
+
task.machineName,
|
|
18550
|
+
task.componentPayload
|
|
18551
|
+
);
|
|
18552
|
+
} else {
|
|
18553
|
+
await apiService.createComponent(task.componentPayload);
|
|
18554
|
+
}
|
|
18555
|
+
onProgress?.();
|
|
18556
|
+
return {
|
|
18557
|
+
machineName: task.machineName,
|
|
18558
|
+
success: true,
|
|
18559
|
+
operation: task.shouldUpdate ? "update" : "create"
|
|
18560
|
+
};
|
|
18561
|
+
} catch (fallbackError) {
|
|
18562
|
+
onProgress?.();
|
|
18563
|
+
return {
|
|
18564
|
+
machineName: task.machineName,
|
|
18565
|
+
success: false,
|
|
18566
|
+
operation: task.shouldUpdate ? "update" : "create",
|
|
18567
|
+
error: fallbackError instanceof Error ? fallbackError : new Error(String(fallbackError))
|
|
18568
|
+
};
|
|
18569
|
+
}
|
|
18570
|
+
}
|
|
18571
|
+
});
|
|
18572
|
+
return results.map((result) => {
|
|
18573
|
+
if (result.success && result.result) {
|
|
18574
|
+
return result.result;
|
|
18575
|
+
}
|
|
18576
|
+
return {
|
|
18577
|
+
machineName: uploadTasks[result.index]?.machineName || "unknown",
|
|
18578
|
+
success: false,
|
|
18579
|
+
operation: "create",
|
|
18580
|
+
error: result.error || new Error("Unknown error during upload")
|
|
18581
|
+
};
|
|
18582
|
+
});
|
|
18583
|
+
}
|
|
18197
18584
|
function uploadCommand(program2) {
|
|
18198
|
-
program2.command("upload").description("build and upload local components and global CSS assets").option("--client-id <id>", "Client ID").option("--client-secret <secret>", "Client Secret").option("--site-url <url>", "Site URL").option("--scope <scope>", "Scope").option("-d, --dir <directory>", "Component directory").option(
|
|
18199
|
-
|
|
18585
|
+
program2.command("upload").description("build and upload local components and global CSS assets").option("--client-id <id>", "Client ID").option("--client-secret <secret>", "Client Secret").option("--site-url <url>", "Site URL").option("--scope <scope>", "Scope").option("-d, --dir <directory>", "Component directory").option(
|
|
18586
|
+
"-c, --components <names>",
|
|
18587
|
+
"Specific component(s) to upload (comma-separated)"
|
|
18588
|
+
).option("--all", "Upload all components").option("-y, --yes", "Skip confirmation prompts").option("--verbose", "Verbose output").option("--no-tailwind", "Skip Tailwind CSS building").action(async (options) => {
|
|
18589
|
+
const allFlag = options.all || options.yes && !options.components || false;
|
|
18200
18590
|
const skipTailwind = !options.tailwind;
|
|
18201
18591
|
try {
|
|
18202
|
-
|
|
18203
|
-
|
|
18204
|
-
|
|
18205
|
-
setConfig({ clientSecret: options.clientSecret });
|
|
18206
|
-
if (options.siteUrl) setConfig({ siteUrl: options.siteUrl });
|
|
18207
|
-
if (options.dir) setConfig({ componentDir: options.dir });
|
|
18208
|
-
if (options.scope) setConfig({ scope: options.scope });
|
|
18209
|
-
if (options.all) setConfig({ all: options.all });
|
|
18210
|
-
if (options.verbose) setConfig({ verbose: options.verbose });
|
|
18592
|
+
p.intro(chalk2.bold("Drupal Canvas CLI: upload"));
|
|
18593
|
+
validateComponentOptions(options);
|
|
18594
|
+
updateConfigFromOptions(options);
|
|
18211
18595
|
await ensureConfig([
|
|
18212
18596
|
"siteUrl",
|
|
18213
18597
|
"clientId",
|
|
@@ -18216,28 +18600,34 @@ function uploadCommand(program2) {
|
|
|
18216
18600
|
"componentDir"
|
|
18217
18601
|
]);
|
|
18218
18602
|
const config2 = getConfig();
|
|
18219
|
-
const componentsToUpload = await selectLocalComponents(
|
|
18220
|
-
|
|
18221
|
-
|
|
18603
|
+
const { directories: componentsToUpload } = await selectLocalComponents(
|
|
18604
|
+
{
|
|
18605
|
+
all: allFlag,
|
|
18606
|
+
components: options.components,
|
|
18607
|
+
skipConfirmation: options.yes,
|
|
18608
|
+
selectMessage: "Select components to upload"
|
|
18609
|
+
}
|
|
18222
18610
|
);
|
|
18223
|
-
if (!componentsToUpload || componentsToUpload.length === 0) {
|
|
18224
|
-
return;
|
|
18225
|
-
}
|
|
18226
18611
|
const apiService = await createApiService();
|
|
18227
18612
|
const componentResults = await getBuildAndUploadResults(
|
|
18228
18613
|
componentsToUpload,
|
|
18229
18614
|
apiService
|
|
18230
18615
|
);
|
|
18231
18616
|
reportResults(componentResults, "Uploaded components", "Component");
|
|
18617
|
+
if (componentResults.some((result) => !result.success)) {
|
|
18618
|
+
process.exit(1);
|
|
18619
|
+
}
|
|
18232
18620
|
if (skipTailwind) {
|
|
18233
|
-
|
|
18621
|
+
p.log.info("Skipping Tailwind CSS build");
|
|
18234
18622
|
} else {
|
|
18235
|
-
const s2 =
|
|
18623
|
+
const s2 = p.spinner();
|
|
18236
18624
|
s2.start("Building Tailwind CSS");
|
|
18237
18625
|
const tailwindResult = await buildTailwindForComponents(
|
|
18238
18626
|
componentsToUpload
|
|
18239
18627
|
);
|
|
18240
|
-
const componentLabelPluralized =
|
|
18628
|
+
const componentLabelPluralized = pluralizeComponent(
|
|
18629
|
+
componentsToUpload.length
|
|
18630
|
+
);
|
|
18241
18631
|
s2.stop(
|
|
18242
18632
|
chalk2.green(
|
|
18243
18633
|
`Processed Tailwind CSS classes from ${componentsToUpload.length} selected local ${componentLabelPluralized} and all online components`
|
|
@@ -18245,7 +18635,7 @@ function uploadCommand(program2) {
|
|
|
18245
18635
|
);
|
|
18246
18636
|
if (!tailwindResult.success && tailwindResult.details) {
|
|
18247
18637
|
reportResults([tailwindResult], "Built assets", "Asset");
|
|
18248
|
-
|
|
18638
|
+
p.note(
|
|
18249
18639
|
chalk2.red(`Tailwind build failed, global assets upload aborted.`)
|
|
18250
18640
|
);
|
|
18251
18641
|
} else {
|
|
@@ -18256,35 +18646,27 @@ function uploadCommand(program2) {
|
|
|
18256
18646
|
reportResults([globalCssResult], "Uploaded assets", "Asset");
|
|
18257
18647
|
}
|
|
18258
18648
|
}
|
|
18259
|
-
|
|
18649
|
+
p.outro("\u2B06\uFE0F Upload command completed");
|
|
18260
18650
|
} catch (error) {
|
|
18261
18651
|
if (error instanceof Error) {
|
|
18262
|
-
|
|
18652
|
+
p.note(chalk2.red(`Error: ${error.message}`));
|
|
18263
18653
|
} else {
|
|
18264
|
-
|
|
18654
|
+
p.note(chalk2.red(`Unknown error: ${String(error)}`));
|
|
18265
18655
|
}
|
|
18266
18656
|
process.exit(1);
|
|
18267
18657
|
}
|
|
18268
18658
|
});
|
|
18269
18659
|
}
|
|
18270
|
-
async function
|
|
18271
|
-
const
|
|
18272
|
-
const
|
|
18273
|
-
const successfulBuilds = buildResults.filter((build) => build.success);
|
|
18274
|
-
const failedBuilds = buildResults.filter((build) => !build.success);
|
|
18275
|
-
if (successfulBuilds.length === 0) {
|
|
18276
|
-
const message = "All component builds failed.";
|
|
18277
|
-
p9.note(chalk2.red(message));
|
|
18278
|
-
}
|
|
18279
|
-
const spinner5 = p9.spinner();
|
|
18280
|
-
spinner5.start("Uploading components");
|
|
18660
|
+
async function prepareComponentsForUpload(successfulBuilds, componentsToUpload) {
|
|
18661
|
+
const prepared = [];
|
|
18662
|
+
const failed = [];
|
|
18281
18663
|
for (const buildResult of successfulBuilds) {
|
|
18282
18664
|
const dir = buildResult.itemName ? componentsToUpload.find(
|
|
18283
|
-
(d2) =>
|
|
18665
|
+
(d2) => path11.basename(d2) === buildResult.itemName
|
|
18284
18666
|
) : void 0;
|
|
18285
18667
|
if (!dir) continue;
|
|
18286
18668
|
try {
|
|
18287
|
-
const componentName =
|
|
18669
|
+
const componentName = path11.basename(dir);
|
|
18288
18670
|
const { sourceCodeJs, compiledJs, sourceCodeCss, compiledCss, metadata } = await processComponentFiles(dir);
|
|
18289
18671
|
if (!metadata) {
|
|
18290
18672
|
throw new Error("Invalid metadata file");
|
|
@@ -18301,7 +18683,7 @@ async function getBuildAndUploadResults(componentsToUpload, apiService) {
|
|
|
18301
18683
|
importedJsComponents = getImportsFromAst(ast, scope);
|
|
18302
18684
|
dataDependencies = getDataDependenciesFromAst(ast);
|
|
18303
18685
|
} catch (error) {
|
|
18304
|
-
|
|
18686
|
+
p.note(chalk2.red(`Error: ${error}`));
|
|
18305
18687
|
}
|
|
18306
18688
|
const componentPayloadArg = {
|
|
18307
18689
|
metadata,
|
|
@@ -18315,42 +18697,95 @@ async function getBuildAndUploadResults(componentsToUpload, apiService) {
|
|
|
18315
18697
|
dataDependencies
|
|
18316
18698
|
};
|
|
18317
18699
|
const componentPayload = createComponentPayload(componentPayloadArg);
|
|
18318
|
-
|
|
18319
|
-
|
|
18320
|
-
|
|
18321
|
-
|
|
18322
|
-
|
|
18323
|
-
|
|
18324
|
-
|
|
18325
|
-
|
|
18326
|
-
|
|
18327
|
-
|
|
18328
|
-
|
|
18329
|
-
|
|
18330
|
-
|
|
18331
|
-
|
|
18332
|
-
|
|
18333
|
-
|
|
18334
|
-
|
|
18335
|
-
|
|
18336
|
-
|
|
18700
|
+
prepared.push({
|
|
18701
|
+
machineName,
|
|
18702
|
+
componentName,
|
|
18703
|
+
componentPayload,
|
|
18704
|
+
dir,
|
|
18705
|
+
buildResult
|
|
18706
|
+
});
|
|
18707
|
+
} catch (error) {
|
|
18708
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
18709
|
+
failed.push({
|
|
18710
|
+
itemName: buildResult.itemName,
|
|
18711
|
+
success: false,
|
|
18712
|
+
details: [
|
|
18713
|
+
{
|
|
18714
|
+
content: errorMessage
|
|
18715
|
+
}
|
|
18716
|
+
]
|
|
18717
|
+
});
|
|
18718
|
+
}
|
|
18719
|
+
}
|
|
18720
|
+
return { prepared, failed };
|
|
18721
|
+
}
|
|
18722
|
+
async function getBuildAndUploadResults(componentsToUpload, apiService) {
|
|
18723
|
+
const results = [];
|
|
18724
|
+
const spinner6 = p.spinner();
|
|
18725
|
+
spinner6.start("Building components");
|
|
18726
|
+
const buildResults = await buildSelectedComponents(componentsToUpload);
|
|
18727
|
+
const successfulBuilds = buildResults.filter((build) => build.success);
|
|
18728
|
+
const failedBuilds = buildResults.filter((build) => !build.success);
|
|
18729
|
+
if (successfulBuilds.length === 0) {
|
|
18730
|
+
const message = "All component builds failed.";
|
|
18731
|
+
spinner6.stop(chalk2.red(message));
|
|
18732
|
+
return failedBuilds;
|
|
18733
|
+
}
|
|
18734
|
+
spinner6.message("Preparing components for upload");
|
|
18735
|
+
const { prepared: preparedComponents, failed: preparationFailures } = await prepareComponentsForUpload(successfulBuilds, componentsToUpload);
|
|
18736
|
+
results.push(...preparationFailures);
|
|
18737
|
+
if (preparedComponents.length === 0) {
|
|
18738
|
+
spinner6.stop(chalk2.red("All component preparations failed"));
|
|
18739
|
+
return [...results, ...failedBuilds];
|
|
18740
|
+
}
|
|
18741
|
+
const machineNames = preparedComponents.map((c) => c.machineName);
|
|
18742
|
+
const existenceProgress = createProgressCallback(
|
|
18743
|
+
spinner6,
|
|
18744
|
+
"Checking component existence",
|
|
18745
|
+
machineNames.length
|
|
18746
|
+
);
|
|
18747
|
+
spinner6.message("Checking component existence");
|
|
18748
|
+
const existenceResults = await checkComponentsExist(
|
|
18749
|
+
machineNames,
|
|
18750
|
+
apiService,
|
|
18751
|
+
existenceProgress
|
|
18752
|
+
);
|
|
18753
|
+
const uploadTasks = preparedComponents.map((component, index) => ({
|
|
18754
|
+
machineName: component.machineName,
|
|
18755
|
+
componentPayload: component.componentPayload,
|
|
18756
|
+
shouldUpdate: existenceResults[index]?.exists || false
|
|
18757
|
+
}));
|
|
18758
|
+
const uploadProgress = createProgressCallback(
|
|
18759
|
+
spinner6,
|
|
18760
|
+
"Uploading components",
|
|
18761
|
+
uploadTasks.length
|
|
18762
|
+
);
|
|
18763
|
+
spinner6.message("Uploading components");
|
|
18764
|
+
const uploadResults = await uploadComponents(
|
|
18765
|
+
uploadTasks,
|
|
18766
|
+
apiService,
|
|
18767
|
+
uploadProgress
|
|
18768
|
+
);
|
|
18769
|
+
for (let i = 0; i < preparedComponents.length; i++) {
|
|
18770
|
+
const component = preparedComponents[i];
|
|
18771
|
+
const uploadResult = uploadResults[i];
|
|
18772
|
+
if (uploadResult.success) {
|
|
18337
18773
|
results.push({
|
|
18338
|
-
itemName: componentName,
|
|
18774
|
+
itemName: component.componentName,
|
|
18339
18775
|
success: true,
|
|
18340
18776
|
details: [
|
|
18341
18777
|
{
|
|
18342
|
-
content:
|
|
18778
|
+
content: uploadResult.operation === "update" ? "Updated" : "Created"
|
|
18343
18779
|
}
|
|
18344
18780
|
]
|
|
18345
18781
|
});
|
|
18346
|
-
}
|
|
18347
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
18782
|
+
} else {
|
|
18348
18783
|
results.push({
|
|
18349
|
-
itemName:
|
|
18784
|
+
itemName: component.componentName,
|
|
18350
18785
|
success: false,
|
|
18351
18786
|
details: [
|
|
18352
18787
|
{
|
|
18353
|
-
content:
|
|
18788
|
+
content: uploadResult.error?.message || "Unknown upload error"
|
|
18354
18789
|
}
|
|
18355
18790
|
]
|
|
18356
18791
|
});
|
|
@@ -18358,7 +18793,7 @@ async function getBuildAndUploadResults(componentsToUpload, apiService) {
|
|
|
18358
18793
|
}
|
|
18359
18794
|
results.push(...failedBuilds);
|
|
18360
18795
|
const componentLabelPluralized = results.length === 1 ? "component" : "components";
|
|
18361
|
-
|
|
18796
|
+
spinner6.stop(
|
|
18362
18797
|
chalk2.green(`Processed ${results.length} ${componentLabelPluralized}`)
|
|
18363
18798
|
);
|
|
18364
18799
|
return results;
|
|
@@ -18372,16 +18807,16 @@ async function buildSelectedComponents(componentDirs) {
|
|
|
18372
18807
|
}
|
|
18373
18808
|
async function uploadGlobalAssetLibrary(apiService, componentDir) {
|
|
18374
18809
|
try {
|
|
18375
|
-
const distDir =
|
|
18376
|
-
const globalCompiledCssPath =
|
|
18810
|
+
const distDir = path11.join(componentDir, "dist");
|
|
18811
|
+
const globalCompiledCssPath = path11.join(distDir, "index.css");
|
|
18377
18812
|
const globalCompiledCssExists = await fileExists(globalCompiledCssPath);
|
|
18378
18813
|
if (globalCompiledCssExists) {
|
|
18379
18814
|
const globalCompiledCss = await fs2.readFile(
|
|
18380
|
-
|
|
18815
|
+
path11.join(distDir, "index.css"),
|
|
18381
18816
|
"utf-8"
|
|
18382
18817
|
);
|
|
18383
18818
|
const classNameCandidateIndexFile = await fs2.readFile(
|
|
18384
|
-
|
|
18819
|
+
path11.join(distDir, "index.js"),
|
|
18385
18820
|
"utf-8"
|
|
18386
18821
|
);
|
|
18387
18822
|
const current = await apiService.getGlobalAssetLibrary();
|
|
@@ -18424,15 +18859,70 @@ async function uploadGlobalAssetLibrary(apiService, componentDir) {
|
|
|
18424
18859
|
};
|
|
18425
18860
|
}
|
|
18426
18861
|
}
|
|
18862
|
+
function validateCommand(program2) {
|
|
18863
|
+
program2.command("validate").description("validate local components").option(
|
|
18864
|
+
"-d, --dir <directory>",
|
|
18865
|
+
"Component directory to validate the components in"
|
|
18866
|
+
).option(
|
|
18867
|
+
"-c, --components <names>",
|
|
18868
|
+
"Specific component(s) to validate (comma-separated)"
|
|
18869
|
+
).option("--all", "Validate all components").option("-y, --yes", "Skip confirmation prompts").option("--verbose", "Enable verbose output").option(
|
|
18870
|
+
"--fix",
|
|
18871
|
+
"Apply available automatic fixes for linting issues",
|
|
18872
|
+
false
|
|
18873
|
+
).action(async (options) => {
|
|
18874
|
+
try {
|
|
18875
|
+
p.intro(chalk2.bold("Drupal Canvas CLI: validate"));
|
|
18876
|
+
validateComponentOptions(options);
|
|
18877
|
+
const allFlag = options.all || options.yes && !options.components || false;
|
|
18878
|
+
updateConfigFromOptions(options);
|
|
18879
|
+
const { directories: componentsToValidate } = await selectLocalComponents({
|
|
18880
|
+
all: allFlag,
|
|
18881
|
+
components: options.components,
|
|
18882
|
+
skipConfirmation: options.yes,
|
|
18883
|
+
selectMessage: "Select components to validate"
|
|
18884
|
+
});
|
|
18885
|
+
const componentPluralized = pluralizeComponent(
|
|
18886
|
+
componentsToValidate.length
|
|
18887
|
+
);
|
|
18888
|
+
const s = p.spinner();
|
|
18889
|
+
s.start(`Validating ${componentPluralized}`);
|
|
18890
|
+
const results = [];
|
|
18891
|
+
for (const componentDir of componentsToValidate) {
|
|
18892
|
+
results.push(await validateComponent(componentDir, options.fix));
|
|
18893
|
+
}
|
|
18894
|
+
s.stop(
|
|
18895
|
+
chalk2.green(
|
|
18896
|
+
`Processed ${componentsToValidate.length} ${componentPluralized}`
|
|
18897
|
+
)
|
|
18898
|
+
);
|
|
18899
|
+
reportResults(results, "Validation results", "Component");
|
|
18900
|
+
const hasErrors = results.some((r) => !r.success);
|
|
18901
|
+
if (hasErrors) {
|
|
18902
|
+
p.outro(`\u274C Validation completed with errors`);
|
|
18903
|
+
process.exit(1);
|
|
18904
|
+
}
|
|
18905
|
+
p.outro(`\u2705 Validation completed`);
|
|
18906
|
+
} catch (error) {
|
|
18907
|
+
if (error instanceof Error) {
|
|
18908
|
+
p.note(chalk2.red(`Error: ${error.message}`));
|
|
18909
|
+
} else {
|
|
18910
|
+
p.note(chalk2.red(`Unknown error: ${String(error)}`));
|
|
18911
|
+
}
|
|
18912
|
+
process.exit(1);
|
|
18913
|
+
}
|
|
18914
|
+
});
|
|
18915
|
+
}
|
|
18427
18916
|
|
|
18428
18917
|
// src/index.ts
|
|
18429
18918
|
var version = package_default.version;
|
|
18430
18919
|
var program = new Command();
|
|
18431
|
-
program.name("canvas").description("CLI tool for managing Drupal Canvas code components").version(version
|
|
18920
|
+
program.name("canvas").description("CLI tool for managing Drupal Canvas code components").version(version);
|
|
18432
18921
|
downloadCommand(program);
|
|
18433
18922
|
scaffoldCommand(program);
|
|
18434
18923
|
uploadCommand(program);
|
|
18435
18924
|
buildCommand(program);
|
|
18925
|
+
validateCommand(program);
|
|
18436
18926
|
program.showHelpAfterError();
|
|
18437
18927
|
program.showSuggestionAfterError(true);
|
|
18438
18928
|
try {
|
|
@@ -18443,3 +18933,5 @@ try {
|
|
|
18443
18933
|
process.exit(1);
|
|
18444
18934
|
}
|
|
18445
18935
|
}
|
|
18936
|
+
//# sourceMappingURL=index.js.map
|
|
18937
|
+
//# sourceMappingURL=index.js.map
|