deepline 0.3.118 → 0.3.119
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/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +22 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/plays/deploy/control-plane-types.ts +5 -3
- package/dist/bundling-sources/shared_libs/plays/deploy/project-serializer.ts +12 -6
- package/dist/bundling-sources/shared_libs/plays/deploy/run-deployment.ts +1355 -0
- package/dist/cli/index.js +3365 -373
- package/dist/cli/index.mjs +3309 -295
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/install-integrity.json +1 -0
- package/dist/plays/bundle-play-file.d.mts +11 -1
- package/dist/plays/bundle-play-file.d.ts +11 -1
- package/dist/plays/bundle-play-file.mjs +12 -0
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +1 -1
- package/dist/release.mjs +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -1,4 +1,1796 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
|
|
28
|
+
// ../../node_modules/picomatch/lib/constants.js
|
|
29
|
+
var require_constants = __commonJS({
|
|
30
|
+
"../../node_modules/picomatch/lib/constants.js"(exports, module) {
|
|
31
|
+
"use strict";
|
|
32
|
+
var WIN_SLASH = "\\\\/";
|
|
33
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
34
|
+
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
35
|
+
var DOT_LITERAL = "\\.";
|
|
36
|
+
var PLUS_LITERAL = "\\+";
|
|
37
|
+
var QMARK_LITERAL = "\\?";
|
|
38
|
+
var SLASH_LITERAL = "\\/";
|
|
39
|
+
var ONE_CHAR = "(?=.)";
|
|
40
|
+
var QMARK = "[^/]";
|
|
41
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
42
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
43
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
44
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
45
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
46
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
47
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
48
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
49
|
+
var STAR = `${QMARK}*?`;
|
|
50
|
+
var SEP = "/";
|
|
51
|
+
var POSIX_CHARS = {
|
|
52
|
+
DOT_LITERAL,
|
|
53
|
+
PLUS_LITERAL,
|
|
54
|
+
QMARK_LITERAL,
|
|
55
|
+
SLASH_LITERAL,
|
|
56
|
+
ONE_CHAR,
|
|
57
|
+
QMARK,
|
|
58
|
+
END_ANCHOR,
|
|
59
|
+
DOTS_SLASH,
|
|
60
|
+
NO_DOT,
|
|
61
|
+
NO_DOTS,
|
|
62
|
+
NO_DOT_SLASH,
|
|
63
|
+
NO_DOTS_SLASH,
|
|
64
|
+
QMARK_NO_DOT,
|
|
65
|
+
STAR,
|
|
66
|
+
START_ANCHOR,
|
|
67
|
+
SEP
|
|
68
|
+
};
|
|
69
|
+
var WINDOWS_CHARS = {
|
|
70
|
+
...POSIX_CHARS,
|
|
71
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
72
|
+
QMARK: WIN_NO_SLASH,
|
|
73
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
74
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
75
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
76
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
77
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
78
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
79
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
80
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
81
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
82
|
+
SEP: "\\"
|
|
83
|
+
};
|
|
84
|
+
var POSIX_REGEX_SOURCE = {
|
|
85
|
+
__proto__: null,
|
|
86
|
+
alnum: "a-zA-Z0-9",
|
|
87
|
+
alpha: "a-zA-Z",
|
|
88
|
+
ascii: "\\x00-\\x7F",
|
|
89
|
+
blank: " \\t",
|
|
90
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
91
|
+
digit: "0-9",
|
|
92
|
+
graph: "\\x21-\\x7E",
|
|
93
|
+
lower: "a-z",
|
|
94
|
+
print: "\\x20-\\x7E ",
|
|
95
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
96
|
+
space: " \\t\\r\\n\\v\\f",
|
|
97
|
+
upper: "A-Z",
|
|
98
|
+
word: "A-Za-z0-9_",
|
|
99
|
+
xdigit: "A-Fa-f0-9"
|
|
100
|
+
};
|
|
101
|
+
module.exports = {
|
|
102
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
103
|
+
MAX_LENGTH: 1024 * 64,
|
|
104
|
+
POSIX_REGEX_SOURCE,
|
|
105
|
+
// regular expressions
|
|
106
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
107
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
108
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
109
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
110
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
111
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
112
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
113
|
+
REPLACEMENTS: {
|
|
114
|
+
__proto__: null,
|
|
115
|
+
"***": "*",
|
|
116
|
+
"**/**": "**",
|
|
117
|
+
"**/**/**": "**"
|
|
118
|
+
},
|
|
119
|
+
// Digits
|
|
120
|
+
CHAR_0: 48,
|
|
121
|
+
/* 0 */
|
|
122
|
+
CHAR_9: 57,
|
|
123
|
+
/* 9 */
|
|
124
|
+
// Alphabet chars.
|
|
125
|
+
CHAR_UPPERCASE_A: 65,
|
|
126
|
+
/* A */
|
|
127
|
+
CHAR_LOWERCASE_A: 97,
|
|
128
|
+
/* a */
|
|
129
|
+
CHAR_UPPERCASE_Z: 90,
|
|
130
|
+
/* Z */
|
|
131
|
+
CHAR_LOWERCASE_Z: 122,
|
|
132
|
+
/* z */
|
|
133
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
134
|
+
/* ( */
|
|
135
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
136
|
+
/* ) */
|
|
137
|
+
CHAR_ASTERISK: 42,
|
|
138
|
+
/* * */
|
|
139
|
+
// Non-alphabetic chars.
|
|
140
|
+
CHAR_AMPERSAND: 38,
|
|
141
|
+
/* & */
|
|
142
|
+
CHAR_AT: 64,
|
|
143
|
+
/* @ */
|
|
144
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
145
|
+
/* \ */
|
|
146
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
147
|
+
/* \r */
|
|
148
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
149
|
+
/* ^ */
|
|
150
|
+
CHAR_COLON: 58,
|
|
151
|
+
/* : */
|
|
152
|
+
CHAR_COMMA: 44,
|
|
153
|
+
/* , */
|
|
154
|
+
CHAR_DOT: 46,
|
|
155
|
+
/* . */
|
|
156
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
157
|
+
/* " */
|
|
158
|
+
CHAR_EQUAL: 61,
|
|
159
|
+
/* = */
|
|
160
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
161
|
+
/* ! */
|
|
162
|
+
CHAR_FORM_FEED: 12,
|
|
163
|
+
/* \f */
|
|
164
|
+
CHAR_FORWARD_SLASH: 47,
|
|
165
|
+
/* / */
|
|
166
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
167
|
+
/* ` */
|
|
168
|
+
CHAR_HASH: 35,
|
|
169
|
+
/* # */
|
|
170
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
171
|
+
/* - */
|
|
172
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
173
|
+
/* < */
|
|
174
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
175
|
+
/* { */
|
|
176
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
177
|
+
/* [ */
|
|
178
|
+
CHAR_LINE_FEED: 10,
|
|
179
|
+
/* \n */
|
|
180
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
181
|
+
/* \u00A0 */
|
|
182
|
+
CHAR_PERCENT: 37,
|
|
183
|
+
/* % */
|
|
184
|
+
CHAR_PLUS: 43,
|
|
185
|
+
/* + */
|
|
186
|
+
CHAR_QUESTION_MARK: 63,
|
|
187
|
+
/* ? */
|
|
188
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
189
|
+
/* > */
|
|
190
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
191
|
+
/* } */
|
|
192
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
193
|
+
/* ] */
|
|
194
|
+
CHAR_SEMICOLON: 59,
|
|
195
|
+
/* ; */
|
|
196
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
197
|
+
/* ' */
|
|
198
|
+
CHAR_SPACE: 32,
|
|
199
|
+
/* */
|
|
200
|
+
CHAR_TAB: 9,
|
|
201
|
+
/* \t */
|
|
202
|
+
CHAR_UNDERSCORE: 95,
|
|
203
|
+
/* _ */
|
|
204
|
+
CHAR_VERTICAL_LINE: 124,
|
|
205
|
+
/* | */
|
|
206
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
207
|
+
/* \uFEFF */
|
|
208
|
+
/**
|
|
209
|
+
* Create EXTGLOB_CHARS
|
|
210
|
+
*/
|
|
211
|
+
extglobChars(chars) {
|
|
212
|
+
return {
|
|
213
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
214
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
215
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
216
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
217
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
218
|
+
};
|
|
219
|
+
},
|
|
220
|
+
/**
|
|
221
|
+
* Create GLOB_CHARS
|
|
222
|
+
*/
|
|
223
|
+
globChars(win32) {
|
|
224
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// ../../node_modules/picomatch/lib/utils.js
|
|
231
|
+
var require_utils = __commonJS({
|
|
232
|
+
"../../node_modules/picomatch/lib/utils.js"(exports) {
|
|
233
|
+
"use strict";
|
|
234
|
+
var {
|
|
235
|
+
REGEX_BACKSLASH,
|
|
236
|
+
REGEX_REMOVE_BACKSLASH,
|
|
237
|
+
REGEX_SPECIAL_CHARS,
|
|
238
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
239
|
+
} = require_constants();
|
|
240
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
241
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
242
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
243
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
244
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
245
|
+
exports.isWindows = () => {
|
|
246
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
247
|
+
const platform3 = navigator.platform.toLowerCase();
|
|
248
|
+
return platform3 === "win32" || platform3 === "windows";
|
|
249
|
+
}
|
|
250
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
251
|
+
return process.platform === "win32";
|
|
252
|
+
}
|
|
253
|
+
return false;
|
|
254
|
+
};
|
|
255
|
+
exports.removeBackslashes = (str) => {
|
|
256
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
257
|
+
return match === "\\" ? "" : match;
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
exports.escapeLast = (input2, char, lastIdx) => {
|
|
261
|
+
const idx = input2.lastIndexOf(char, lastIdx);
|
|
262
|
+
if (idx === -1) return input2;
|
|
263
|
+
if (input2[idx - 1] === "\\") return exports.escapeLast(input2, char, idx - 1);
|
|
264
|
+
return `${input2.slice(0, idx)}\\${input2.slice(idx)}`;
|
|
265
|
+
};
|
|
266
|
+
exports.removePrefix = (input2, state = {}) => {
|
|
267
|
+
let output2 = input2;
|
|
268
|
+
if (output2.startsWith("./")) {
|
|
269
|
+
output2 = output2.slice(2);
|
|
270
|
+
state.prefix = "./";
|
|
271
|
+
}
|
|
272
|
+
return output2;
|
|
273
|
+
};
|
|
274
|
+
exports.wrapOutput = (input2, state = {}, options = {}) => {
|
|
275
|
+
const prepend = options.contains ? "" : "^";
|
|
276
|
+
const append = options.contains ? "" : "$";
|
|
277
|
+
let output2 = `${prepend}(?:${input2})${append}`;
|
|
278
|
+
if (state.negated === true) {
|
|
279
|
+
output2 = `(?:^(?!${output2}).*$)`;
|
|
280
|
+
}
|
|
281
|
+
return output2;
|
|
282
|
+
};
|
|
283
|
+
exports.basename = (path, { windows } = {}) => {
|
|
284
|
+
const segs = path.split(windows ? /[\\/]/ : "/");
|
|
285
|
+
const last = segs[segs.length - 1];
|
|
286
|
+
if (last === "") {
|
|
287
|
+
return segs[segs.length - 2];
|
|
288
|
+
}
|
|
289
|
+
return last;
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// ../../node_modules/picomatch/lib/scan.js
|
|
295
|
+
var require_scan = __commonJS({
|
|
296
|
+
"../../node_modules/picomatch/lib/scan.js"(exports, module) {
|
|
297
|
+
"use strict";
|
|
298
|
+
var utils = require_utils();
|
|
299
|
+
var {
|
|
300
|
+
CHAR_ASTERISK,
|
|
301
|
+
/* * */
|
|
302
|
+
CHAR_AT,
|
|
303
|
+
/* @ */
|
|
304
|
+
CHAR_BACKWARD_SLASH,
|
|
305
|
+
/* \ */
|
|
306
|
+
CHAR_COMMA,
|
|
307
|
+
/* , */
|
|
308
|
+
CHAR_DOT,
|
|
309
|
+
/* . */
|
|
310
|
+
CHAR_EXCLAMATION_MARK,
|
|
311
|
+
/* ! */
|
|
312
|
+
CHAR_FORWARD_SLASH,
|
|
313
|
+
/* / */
|
|
314
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
315
|
+
/* { */
|
|
316
|
+
CHAR_LEFT_PARENTHESES,
|
|
317
|
+
/* ( */
|
|
318
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
319
|
+
/* [ */
|
|
320
|
+
CHAR_PLUS,
|
|
321
|
+
/* + */
|
|
322
|
+
CHAR_QUESTION_MARK,
|
|
323
|
+
/* ? */
|
|
324
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
325
|
+
/* } */
|
|
326
|
+
CHAR_RIGHT_PARENTHESES,
|
|
327
|
+
/* ) */
|
|
328
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
329
|
+
/* ] */
|
|
330
|
+
} = require_constants();
|
|
331
|
+
var isPathSeparator = (code) => {
|
|
332
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
333
|
+
};
|
|
334
|
+
var depth = (token) => {
|
|
335
|
+
if (token.isPrefix !== true) {
|
|
336
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
var scan = (input2, options) => {
|
|
340
|
+
const opts = options || {};
|
|
341
|
+
const length = input2.length - 1;
|
|
342
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
343
|
+
const slashes = [];
|
|
344
|
+
const tokens = [];
|
|
345
|
+
const parts = [];
|
|
346
|
+
let str = input2;
|
|
347
|
+
let index = -1;
|
|
348
|
+
let start = 0;
|
|
349
|
+
let lastIndex = 0;
|
|
350
|
+
let isBrace = false;
|
|
351
|
+
let isBracket = false;
|
|
352
|
+
let isGlob = false;
|
|
353
|
+
let isExtglob = false;
|
|
354
|
+
let isGlobstar = false;
|
|
355
|
+
let braceEscaped = false;
|
|
356
|
+
let backslashes = false;
|
|
357
|
+
let negated = false;
|
|
358
|
+
let negatedExtglob = false;
|
|
359
|
+
let finished = false;
|
|
360
|
+
let braces = 0;
|
|
361
|
+
let prev;
|
|
362
|
+
let code;
|
|
363
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
364
|
+
const eos = () => index >= length;
|
|
365
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
366
|
+
const advance = () => {
|
|
367
|
+
prev = code;
|
|
368
|
+
return str.charCodeAt(++index);
|
|
369
|
+
};
|
|
370
|
+
while (index < length) {
|
|
371
|
+
code = advance();
|
|
372
|
+
let next;
|
|
373
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
374
|
+
backslashes = token.backslashes = true;
|
|
375
|
+
code = advance();
|
|
376
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
377
|
+
braceEscaped = true;
|
|
378
|
+
}
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
382
|
+
braces++;
|
|
383
|
+
while (eos() !== true && (code = advance())) {
|
|
384
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
385
|
+
backslashes = token.backslashes = true;
|
|
386
|
+
advance();
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
390
|
+
braces++;
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
394
|
+
isBrace = token.isBrace = true;
|
|
395
|
+
isGlob = token.isGlob = true;
|
|
396
|
+
finished = true;
|
|
397
|
+
if (scanToEnd === true) {
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
403
|
+
isBrace = token.isBrace = true;
|
|
404
|
+
isGlob = token.isGlob = true;
|
|
405
|
+
finished = true;
|
|
406
|
+
if (scanToEnd === true) {
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
412
|
+
braces--;
|
|
413
|
+
if (braces === 0) {
|
|
414
|
+
braceEscaped = false;
|
|
415
|
+
isBrace = token.isBrace = true;
|
|
416
|
+
finished = true;
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (scanToEnd === true) {
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
427
|
+
slashes.push(index);
|
|
428
|
+
tokens.push(token);
|
|
429
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
430
|
+
if (finished === true) continue;
|
|
431
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
432
|
+
start += 2;
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
lastIndex = index + 1;
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
if (opts.noext !== true) {
|
|
439
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
440
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
441
|
+
isGlob = token.isGlob = true;
|
|
442
|
+
isExtglob = token.isExtglob = true;
|
|
443
|
+
finished = true;
|
|
444
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
445
|
+
negatedExtglob = true;
|
|
446
|
+
}
|
|
447
|
+
if (scanToEnd === true) {
|
|
448
|
+
while (eos() !== true && (code = advance())) {
|
|
449
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
450
|
+
backslashes = token.backslashes = true;
|
|
451
|
+
code = advance();
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
455
|
+
isGlob = token.isGlob = true;
|
|
456
|
+
finished = true;
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (code === CHAR_ASTERISK) {
|
|
466
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
467
|
+
isGlob = token.isGlob = true;
|
|
468
|
+
finished = true;
|
|
469
|
+
if (scanToEnd === true) {
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
475
|
+
isGlob = token.isGlob = true;
|
|
476
|
+
finished = true;
|
|
477
|
+
if (scanToEnd === true) {
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
483
|
+
while (eos() !== true && (next = advance())) {
|
|
484
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
485
|
+
backslashes = token.backslashes = true;
|
|
486
|
+
advance();
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
490
|
+
isBracket = token.isBracket = true;
|
|
491
|
+
isGlob = token.isGlob = true;
|
|
492
|
+
finished = true;
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
if (scanToEnd === true) {
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
502
|
+
negated = token.negated = true;
|
|
503
|
+
start++;
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
507
|
+
isGlob = token.isGlob = true;
|
|
508
|
+
if (scanToEnd === true) {
|
|
509
|
+
while (eos() !== true && (code = advance())) {
|
|
510
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
511
|
+
backslashes = token.backslashes = true;
|
|
512
|
+
code = advance();
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
516
|
+
finished = true;
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
if (isGlob === true) {
|
|
525
|
+
finished = true;
|
|
526
|
+
if (scanToEnd === true) {
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (opts.noext === true) {
|
|
533
|
+
isExtglob = false;
|
|
534
|
+
isGlob = false;
|
|
535
|
+
}
|
|
536
|
+
let base = str;
|
|
537
|
+
let prefix = "";
|
|
538
|
+
let glob = "";
|
|
539
|
+
if (start > 0) {
|
|
540
|
+
prefix = str.slice(0, start);
|
|
541
|
+
str = str.slice(start);
|
|
542
|
+
lastIndex -= start;
|
|
543
|
+
}
|
|
544
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
545
|
+
base = str.slice(0, lastIndex);
|
|
546
|
+
glob = str.slice(lastIndex);
|
|
547
|
+
} else if (isGlob === true) {
|
|
548
|
+
base = "";
|
|
549
|
+
glob = str;
|
|
550
|
+
} else {
|
|
551
|
+
base = str;
|
|
552
|
+
}
|
|
553
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
554
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
555
|
+
base = base.slice(0, -1);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
if (opts.unescape === true) {
|
|
559
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
560
|
+
if (base && backslashes === true) {
|
|
561
|
+
base = utils.removeBackslashes(base);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
const state = {
|
|
565
|
+
prefix,
|
|
566
|
+
input: input2,
|
|
567
|
+
start,
|
|
568
|
+
base,
|
|
569
|
+
glob,
|
|
570
|
+
isBrace,
|
|
571
|
+
isBracket,
|
|
572
|
+
isGlob,
|
|
573
|
+
isExtglob,
|
|
574
|
+
isGlobstar,
|
|
575
|
+
negated,
|
|
576
|
+
negatedExtglob
|
|
577
|
+
};
|
|
578
|
+
if (opts.tokens === true) {
|
|
579
|
+
state.maxDepth = 0;
|
|
580
|
+
if (!isPathSeparator(code)) {
|
|
581
|
+
tokens.push(token);
|
|
582
|
+
}
|
|
583
|
+
state.tokens = tokens;
|
|
584
|
+
}
|
|
585
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
586
|
+
let prevIndex;
|
|
587
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
588
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
589
|
+
const i = slashes[idx];
|
|
590
|
+
const value = input2.slice(n, i);
|
|
591
|
+
if (opts.tokens) {
|
|
592
|
+
if (idx === 0 && start !== 0) {
|
|
593
|
+
tokens[idx].isPrefix = true;
|
|
594
|
+
tokens[idx].value = prefix;
|
|
595
|
+
} else {
|
|
596
|
+
tokens[idx].value = value;
|
|
597
|
+
}
|
|
598
|
+
depth(tokens[idx]);
|
|
599
|
+
state.maxDepth += tokens[idx].depth;
|
|
600
|
+
}
|
|
601
|
+
if (idx !== 0 || value !== "") {
|
|
602
|
+
parts.push(value);
|
|
603
|
+
}
|
|
604
|
+
prevIndex = i;
|
|
605
|
+
}
|
|
606
|
+
if (prevIndex && prevIndex + 1 < input2.length) {
|
|
607
|
+
const value = input2.slice(prevIndex + 1);
|
|
608
|
+
parts.push(value);
|
|
609
|
+
if (opts.tokens) {
|
|
610
|
+
tokens[tokens.length - 1].value = value;
|
|
611
|
+
depth(tokens[tokens.length - 1]);
|
|
612
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
state.slashes = slashes;
|
|
616
|
+
state.parts = parts;
|
|
617
|
+
}
|
|
618
|
+
return state;
|
|
619
|
+
};
|
|
620
|
+
module.exports = scan;
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
// ../../node_modules/picomatch/lib/parse.js
|
|
625
|
+
var require_parse = __commonJS({
|
|
626
|
+
"../../node_modules/picomatch/lib/parse.js"(exports, module) {
|
|
627
|
+
"use strict";
|
|
628
|
+
var constants = require_constants();
|
|
629
|
+
var utils = require_utils();
|
|
630
|
+
var {
|
|
631
|
+
MAX_LENGTH,
|
|
632
|
+
POSIX_REGEX_SOURCE,
|
|
633
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
634
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
635
|
+
REPLACEMENTS
|
|
636
|
+
} = constants;
|
|
637
|
+
var expandRange = (args, options) => {
|
|
638
|
+
if (typeof options.expandRange === "function") {
|
|
639
|
+
return options.expandRange(...args, options);
|
|
640
|
+
}
|
|
641
|
+
args.sort();
|
|
642
|
+
const value = `[${args.join("-")}]`;
|
|
643
|
+
try {
|
|
644
|
+
new RegExp(value);
|
|
645
|
+
} catch (ex) {
|
|
646
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
647
|
+
}
|
|
648
|
+
return value;
|
|
649
|
+
};
|
|
650
|
+
var syntaxError = (type, char) => {
|
|
651
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
652
|
+
};
|
|
653
|
+
var splitTopLevel = (input2) => {
|
|
654
|
+
const parts = [];
|
|
655
|
+
let bracket = 0;
|
|
656
|
+
let paren = 0;
|
|
657
|
+
let quote = 0;
|
|
658
|
+
let value = "";
|
|
659
|
+
let escaped = false;
|
|
660
|
+
for (const ch of input2) {
|
|
661
|
+
if (escaped === true) {
|
|
662
|
+
value += ch;
|
|
663
|
+
escaped = false;
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
if (ch === "\\") {
|
|
667
|
+
value += ch;
|
|
668
|
+
escaped = true;
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
if (ch === '"') {
|
|
672
|
+
quote = quote === 1 ? 0 : 1;
|
|
673
|
+
value += ch;
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
if (quote === 0) {
|
|
677
|
+
if (ch === "[") {
|
|
678
|
+
bracket++;
|
|
679
|
+
} else if (ch === "]" && bracket > 0) {
|
|
680
|
+
bracket--;
|
|
681
|
+
} else if (bracket === 0) {
|
|
682
|
+
if (ch === "(") {
|
|
683
|
+
paren++;
|
|
684
|
+
} else if (ch === ")" && paren > 0) {
|
|
685
|
+
paren--;
|
|
686
|
+
} else if (ch === "|" && paren === 0) {
|
|
687
|
+
parts.push(value);
|
|
688
|
+
value = "";
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
value += ch;
|
|
694
|
+
}
|
|
695
|
+
parts.push(value);
|
|
696
|
+
return parts;
|
|
697
|
+
};
|
|
698
|
+
var isPlainBranch = (branch) => {
|
|
699
|
+
let escaped = false;
|
|
700
|
+
for (const ch of branch) {
|
|
701
|
+
if (escaped === true) {
|
|
702
|
+
escaped = false;
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
if (ch === "\\") {
|
|
706
|
+
escaped = true;
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
710
|
+
return false;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return true;
|
|
714
|
+
};
|
|
715
|
+
var normalizeSimpleBranch = (branch) => {
|
|
716
|
+
let value = branch.trim();
|
|
717
|
+
let changed = true;
|
|
718
|
+
while (changed === true) {
|
|
719
|
+
changed = false;
|
|
720
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
721
|
+
value = value.slice(2, -1);
|
|
722
|
+
changed = true;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
if (!isPlainBranch(value)) {
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
return value.replace(/\\(.)/g, "$1");
|
|
729
|
+
};
|
|
730
|
+
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
731
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
732
|
+
for (let i = 0; i < values.length; i++) {
|
|
733
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
734
|
+
const a = values[i];
|
|
735
|
+
const b = values[j];
|
|
736
|
+
const char = a[0];
|
|
737
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
738
|
+
continue;
|
|
739
|
+
}
|
|
740
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
741
|
+
return true;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
return false;
|
|
746
|
+
};
|
|
747
|
+
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
748
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
let bracket = 0;
|
|
752
|
+
let paren = 0;
|
|
753
|
+
let quote = 0;
|
|
754
|
+
let escaped = false;
|
|
755
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
756
|
+
const ch = pattern[i];
|
|
757
|
+
if (escaped === true) {
|
|
758
|
+
escaped = false;
|
|
759
|
+
continue;
|
|
760
|
+
}
|
|
761
|
+
if (ch === "\\") {
|
|
762
|
+
escaped = true;
|
|
763
|
+
continue;
|
|
764
|
+
}
|
|
765
|
+
if (ch === '"') {
|
|
766
|
+
quote = quote === 1 ? 0 : 1;
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
if (quote === 1) {
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
if (ch === "[") {
|
|
773
|
+
bracket++;
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
if (ch === "]" && bracket > 0) {
|
|
777
|
+
bracket--;
|
|
778
|
+
continue;
|
|
779
|
+
}
|
|
780
|
+
if (bracket > 0) {
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
783
|
+
if (ch === "(") {
|
|
784
|
+
paren++;
|
|
785
|
+
continue;
|
|
786
|
+
}
|
|
787
|
+
if (ch === ")") {
|
|
788
|
+
paren--;
|
|
789
|
+
if (paren === 0) {
|
|
790
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
return {
|
|
794
|
+
type: pattern[0],
|
|
795
|
+
body: pattern.slice(2, i),
|
|
796
|
+
end: i
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
var buildCharClassStar = (chars) => {
|
|
803
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
804
|
+
return `${source}*`;
|
|
805
|
+
};
|
|
806
|
+
var getStarExtglobSequenceChars = (pattern) => {
|
|
807
|
+
let index = 0;
|
|
808
|
+
const chars = [];
|
|
809
|
+
while (index < pattern.length) {
|
|
810
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
811
|
+
if (!match || match.type !== "*") {
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
|
|
815
|
+
if (branches.length !== 1) {
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
819
|
+
if (!branch || branch.length !== 1) {
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
chars.push(branch);
|
|
823
|
+
index += match.end + 1;
|
|
824
|
+
}
|
|
825
|
+
if (chars.length < 1) {
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
return chars;
|
|
829
|
+
};
|
|
830
|
+
var repeatedExtglobRecursion = (pattern) => {
|
|
831
|
+
let depth = 0;
|
|
832
|
+
let value = pattern.trim();
|
|
833
|
+
let match = parseRepeatedExtglob(value);
|
|
834
|
+
while (match) {
|
|
835
|
+
depth++;
|
|
836
|
+
value = match.body.trim();
|
|
837
|
+
match = parseRepeatedExtglob(value);
|
|
838
|
+
}
|
|
839
|
+
return depth;
|
|
840
|
+
};
|
|
841
|
+
var analyzeRepeatedExtglob = (body, options) => {
|
|
842
|
+
if (options.maxExtglobRecursion === false) {
|
|
843
|
+
return { risky: false };
|
|
844
|
+
}
|
|
845
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
846
|
+
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
847
|
+
if (branches.length > 1) {
|
|
848
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
849
|
+
return { risky: true };
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
const safeChars = [];
|
|
853
|
+
let sawStarSequence = false;
|
|
854
|
+
let combinable = true;
|
|
855
|
+
for (const branch of branches) {
|
|
856
|
+
const chars = getStarExtglobSequenceChars(branch);
|
|
857
|
+
if (chars) {
|
|
858
|
+
sawStarSequence = true;
|
|
859
|
+
safeChars.push(...chars);
|
|
860
|
+
continue;
|
|
861
|
+
}
|
|
862
|
+
const literal = normalizeSimpleBranch(branch);
|
|
863
|
+
if (literal && literal.length === 1) {
|
|
864
|
+
safeChars.push(literal);
|
|
865
|
+
continue;
|
|
866
|
+
}
|
|
867
|
+
combinable = false;
|
|
868
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
869
|
+
return { risky: true };
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
if (sawStarSequence) {
|
|
873
|
+
return combinable ? { risky: true, safeOutput: buildCharClassStar([...new Set(safeChars)]) } : { risky: true };
|
|
874
|
+
}
|
|
875
|
+
return { risky: false };
|
|
876
|
+
};
|
|
877
|
+
var parse2 = (input2, options) => {
|
|
878
|
+
if (typeof input2 !== "string") {
|
|
879
|
+
throw new TypeError("Expected a string");
|
|
880
|
+
}
|
|
881
|
+
input2 = REPLACEMENTS[input2] || input2;
|
|
882
|
+
const opts = { ...options };
|
|
883
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
884
|
+
let len = input2.length;
|
|
885
|
+
if (len > max) {
|
|
886
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
887
|
+
}
|
|
888
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
889
|
+
const tokens = [bos];
|
|
890
|
+
const capture = opts.capture ? "" : "?:";
|
|
891
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
892
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
893
|
+
const {
|
|
894
|
+
DOT_LITERAL,
|
|
895
|
+
PLUS_LITERAL,
|
|
896
|
+
SLASH_LITERAL,
|
|
897
|
+
ONE_CHAR,
|
|
898
|
+
DOTS_SLASH,
|
|
899
|
+
NO_DOT,
|
|
900
|
+
NO_DOT_SLASH,
|
|
901
|
+
NO_DOTS_SLASH,
|
|
902
|
+
QMARK,
|
|
903
|
+
QMARK_NO_DOT,
|
|
904
|
+
STAR,
|
|
905
|
+
START_ANCHOR
|
|
906
|
+
} = PLATFORM_CHARS;
|
|
907
|
+
const globstar = (opts2) => {
|
|
908
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
909
|
+
};
|
|
910
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
911
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
912
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
913
|
+
if (opts.capture) {
|
|
914
|
+
star = `(${star})`;
|
|
915
|
+
}
|
|
916
|
+
if (typeof opts.noext === "boolean") {
|
|
917
|
+
opts.noextglob = opts.noext;
|
|
918
|
+
}
|
|
919
|
+
const state = {
|
|
920
|
+
input: input2,
|
|
921
|
+
index: -1,
|
|
922
|
+
start: 0,
|
|
923
|
+
dot: opts.dot === true,
|
|
924
|
+
consumed: "",
|
|
925
|
+
output: "",
|
|
926
|
+
prefix: "",
|
|
927
|
+
backtrack: false,
|
|
928
|
+
negated: false,
|
|
929
|
+
brackets: 0,
|
|
930
|
+
braces: 0,
|
|
931
|
+
parens: 0,
|
|
932
|
+
quotes: 0,
|
|
933
|
+
globstar: false,
|
|
934
|
+
tokens
|
|
935
|
+
};
|
|
936
|
+
input2 = utils.removePrefix(input2, state);
|
|
937
|
+
len = input2.length;
|
|
938
|
+
const extglobs = [];
|
|
939
|
+
const braces = [];
|
|
940
|
+
const stack = [];
|
|
941
|
+
let prev = bos;
|
|
942
|
+
let value;
|
|
943
|
+
const eos = () => state.index === len - 1;
|
|
944
|
+
const peek = state.peek = (n = 1) => input2[state.index + n];
|
|
945
|
+
const advance = state.advance = () => input2[++state.index] || "";
|
|
946
|
+
const remaining = () => input2.slice(state.index + 1);
|
|
947
|
+
const consume = (value2 = "", num = 0) => {
|
|
948
|
+
state.consumed += value2;
|
|
949
|
+
state.index += num;
|
|
950
|
+
};
|
|
951
|
+
const append = (token) => {
|
|
952
|
+
state.output += token.output != null ? token.output : token.value;
|
|
953
|
+
consume(token.value);
|
|
954
|
+
};
|
|
955
|
+
const negate = () => {
|
|
956
|
+
let count = 1;
|
|
957
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
958
|
+
advance();
|
|
959
|
+
state.start++;
|
|
960
|
+
count++;
|
|
961
|
+
}
|
|
962
|
+
if (count % 2 === 0) {
|
|
963
|
+
return false;
|
|
964
|
+
}
|
|
965
|
+
state.negated = true;
|
|
966
|
+
state.start++;
|
|
967
|
+
return true;
|
|
968
|
+
};
|
|
969
|
+
const increment = (type) => {
|
|
970
|
+
state[type]++;
|
|
971
|
+
stack.push(type);
|
|
972
|
+
};
|
|
973
|
+
const decrement = (type) => {
|
|
974
|
+
state[type]--;
|
|
975
|
+
stack.pop();
|
|
976
|
+
};
|
|
977
|
+
const push = (tok) => {
|
|
978
|
+
if (prev.type === "globstar") {
|
|
979
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
980
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
981
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
982
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
983
|
+
prev.type = "star";
|
|
984
|
+
prev.value = "*";
|
|
985
|
+
prev.output = star;
|
|
986
|
+
state.output += prev.output;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
990
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
991
|
+
}
|
|
992
|
+
if (tok.value || tok.output) append(tok);
|
|
993
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
994
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
995
|
+
prev.value += tok.value;
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
tok.prev = prev;
|
|
999
|
+
tokens.push(tok);
|
|
1000
|
+
prev = tok;
|
|
1001
|
+
};
|
|
1002
|
+
const extglobOpen = (type, value2) => {
|
|
1003
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
1004
|
+
token.prev = prev;
|
|
1005
|
+
token.parens = state.parens;
|
|
1006
|
+
token.output = state.output;
|
|
1007
|
+
token.startIndex = state.index;
|
|
1008
|
+
token.tokensIndex = tokens.length;
|
|
1009
|
+
const output2 = (opts.capture ? "(" : "") + token.open;
|
|
1010
|
+
increment("parens");
|
|
1011
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
1012
|
+
push({ type: "paren", extglob: true, value: advance(), output: output2 });
|
|
1013
|
+
extglobs.push(token);
|
|
1014
|
+
};
|
|
1015
|
+
const extglobClose = (token) => {
|
|
1016
|
+
const literal = input2.slice(token.startIndex, state.index + 1);
|
|
1017
|
+
const body = input2.slice(token.startIndex + 2, state.index);
|
|
1018
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
1019
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
1020
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
1021
|
+
const open2 = tokens[token.tokensIndex];
|
|
1022
|
+
open2.type = "text";
|
|
1023
|
+
open2.value = literal;
|
|
1024
|
+
open2.output = safeOutput || utils.escapeRegex(literal);
|
|
1025
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
1026
|
+
tokens[i].value = "";
|
|
1027
|
+
tokens[i].output = "";
|
|
1028
|
+
delete tokens[i].suffix;
|
|
1029
|
+
}
|
|
1030
|
+
state.output = token.output + open2.output;
|
|
1031
|
+
state.backtrack = true;
|
|
1032
|
+
push({ type: "paren", extglob: true, value, output: "" });
|
|
1033
|
+
decrement("parens");
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
let output2 = token.close + (opts.capture ? ")" : "");
|
|
1037
|
+
let rest;
|
|
1038
|
+
if (token.type === "negate") {
|
|
1039
|
+
let extglobStar = star;
|
|
1040
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
1041
|
+
extglobStar = globstar(opts);
|
|
1042
|
+
}
|
|
1043
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
1044
|
+
output2 = token.close = `)$))${extglobStar}`;
|
|
1045
|
+
}
|
|
1046
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
1047
|
+
const expression = parse2(rest, { ...options, fastpaths: false }).output;
|
|
1048
|
+
output2 = token.close = `)${expression})${extglobStar})`;
|
|
1049
|
+
}
|
|
1050
|
+
if (token.prev.type === "bos") {
|
|
1051
|
+
state.negatedExtglob = true;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
push({ type: "paren", extglob: true, value, output: output2 });
|
|
1055
|
+
decrement("parens");
|
|
1056
|
+
};
|
|
1057
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input2)) {
|
|
1058
|
+
let backslashes = false;
|
|
1059
|
+
let output2 = input2.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
1060
|
+
if (first === "\\") {
|
|
1061
|
+
backslashes = true;
|
|
1062
|
+
return m;
|
|
1063
|
+
}
|
|
1064
|
+
if (first === "?") {
|
|
1065
|
+
if (esc) {
|
|
1066
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
1067
|
+
}
|
|
1068
|
+
if (index === 0) {
|
|
1069
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
1070
|
+
}
|
|
1071
|
+
return QMARK.repeat(chars.length);
|
|
1072
|
+
}
|
|
1073
|
+
if (first === ".") {
|
|
1074
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
1075
|
+
}
|
|
1076
|
+
if (first === "*") {
|
|
1077
|
+
if (esc) {
|
|
1078
|
+
return esc + first + (rest ? star : "");
|
|
1079
|
+
}
|
|
1080
|
+
return star;
|
|
1081
|
+
}
|
|
1082
|
+
return esc ? m : `\\${m}`;
|
|
1083
|
+
});
|
|
1084
|
+
if (backslashes === true) {
|
|
1085
|
+
if (opts.unescape === true) {
|
|
1086
|
+
output2 = output2.replace(/\\/g, "");
|
|
1087
|
+
} else {
|
|
1088
|
+
output2 = output2.replace(/\\+/g, (m) => {
|
|
1089
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
if (output2 === input2 && opts.contains === true) {
|
|
1094
|
+
state.output = input2;
|
|
1095
|
+
return state;
|
|
1096
|
+
}
|
|
1097
|
+
state.output = utils.wrapOutput(output2, state, options);
|
|
1098
|
+
return state;
|
|
1099
|
+
}
|
|
1100
|
+
while (!eos()) {
|
|
1101
|
+
value = advance();
|
|
1102
|
+
if (value === "\0") {
|
|
1103
|
+
continue;
|
|
1104
|
+
}
|
|
1105
|
+
if (value === "\\") {
|
|
1106
|
+
const next = peek();
|
|
1107
|
+
if (next === "/" && opts.bash !== true) {
|
|
1108
|
+
continue;
|
|
1109
|
+
}
|
|
1110
|
+
if (next === "." || next === ";") {
|
|
1111
|
+
continue;
|
|
1112
|
+
}
|
|
1113
|
+
if (!next) {
|
|
1114
|
+
value += "\\";
|
|
1115
|
+
push({ type: "text", value });
|
|
1116
|
+
continue;
|
|
1117
|
+
}
|
|
1118
|
+
const match = /^\\+/.exec(remaining());
|
|
1119
|
+
let slashes = 0;
|
|
1120
|
+
if (match && match[0].length > 2) {
|
|
1121
|
+
slashes = match[0].length;
|
|
1122
|
+
state.index += slashes;
|
|
1123
|
+
if (slashes % 2 !== 0) {
|
|
1124
|
+
value += "\\";
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
if (opts.unescape === true) {
|
|
1128
|
+
value = advance();
|
|
1129
|
+
} else {
|
|
1130
|
+
value += advance();
|
|
1131
|
+
}
|
|
1132
|
+
if (state.brackets === 0) {
|
|
1133
|
+
push({ type: "text", value });
|
|
1134
|
+
continue;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
1138
|
+
if (opts.posix !== false && value === ":") {
|
|
1139
|
+
const inner = prev.value.slice(1);
|
|
1140
|
+
if (inner.includes("[")) {
|
|
1141
|
+
prev.posix = true;
|
|
1142
|
+
if (inner.includes(":")) {
|
|
1143
|
+
const idx = prev.value.lastIndexOf("[");
|
|
1144
|
+
const pre = prev.value.slice(0, idx);
|
|
1145
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
1146
|
+
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
1147
|
+
if (posix) {
|
|
1148
|
+
prev.value = pre + posix;
|
|
1149
|
+
state.backtrack = true;
|
|
1150
|
+
advance();
|
|
1151
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
1152
|
+
bos.output = ONE_CHAR;
|
|
1153
|
+
}
|
|
1154
|
+
continue;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
1160
|
+
value = `\\${value}`;
|
|
1161
|
+
}
|
|
1162
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
1163
|
+
value = `\\${value}`;
|
|
1164
|
+
}
|
|
1165
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
1166
|
+
value = "^";
|
|
1167
|
+
}
|
|
1168
|
+
prev.value += value;
|
|
1169
|
+
append({ value });
|
|
1170
|
+
continue;
|
|
1171
|
+
}
|
|
1172
|
+
if (state.quotes === 1 && value !== '"') {
|
|
1173
|
+
value = utils.escapeRegex(value);
|
|
1174
|
+
prev.value += value;
|
|
1175
|
+
append({ value });
|
|
1176
|
+
continue;
|
|
1177
|
+
}
|
|
1178
|
+
if (value === '"') {
|
|
1179
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
1180
|
+
if (opts.keepQuotes === true) {
|
|
1181
|
+
push({ type: "text", value });
|
|
1182
|
+
}
|
|
1183
|
+
continue;
|
|
1184
|
+
}
|
|
1185
|
+
if (value === "(") {
|
|
1186
|
+
increment("parens");
|
|
1187
|
+
push({ type: "paren", value });
|
|
1188
|
+
continue;
|
|
1189
|
+
}
|
|
1190
|
+
if (value === ")") {
|
|
1191
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
1192
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
1193
|
+
}
|
|
1194
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
1195
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
1196
|
+
extglobClose(extglobs.pop());
|
|
1197
|
+
continue;
|
|
1198
|
+
}
|
|
1199
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
1200
|
+
decrement("parens");
|
|
1201
|
+
continue;
|
|
1202
|
+
}
|
|
1203
|
+
if (value === "[") {
|
|
1204
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
1205
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
1206
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
1207
|
+
}
|
|
1208
|
+
value = `\\${value}`;
|
|
1209
|
+
} else {
|
|
1210
|
+
increment("brackets");
|
|
1211
|
+
}
|
|
1212
|
+
push({ type: "bracket", value });
|
|
1213
|
+
continue;
|
|
1214
|
+
}
|
|
1215
|
+
if (value === "]") {
|
|
1216
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
1217
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1218
|
+
continue;
|
|
1219
|
+
}
|
|
1220
|
+
if (state.brackets === 0) {
|
|
1221
|
+
if (opts.strictBrackets === true) {
|
|
1222
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
1223
|
+
}
|
|
1224
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1225
|
+
continue;
|
|
1226
|
+
}
|
|
1227
|
+
decrement("brackets");
|
|
1228
|
+
const prevValue = prev.value.slice(1);
|
|
1229
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
1230
|
+
value = `/${value}`;
|
|
1231
|
+
}
|
|
1232
|
+
prev.value += value;
|
|
1233
|
+
append({ value });
|
|
1234
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
1235
|
+
continue;
|
|
1236
|
+
}
|
|
1237
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
1238
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
1239
|
+
if (opts.literalBrackets === true) {
|
|
1240
|
+
state.output += escaped;
|
|
1241
|
+
prev.value = escaped;
|
|
1242
|
+
continue;
|
|
1243
|
+
}
|
|
1244
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1245
|
+
state.output += prev.value;
|
|
1246
|
+
continue;
|
|
1247
|
+
}
|
|
1248
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
1249
|
+
increment("braces");
|
|
1250
|
+
const open2 = {
|
|
1251
|
+
type: "brace",
|
|
1252
|
+
value,
|
|
1253
|
+
output: "(",
|
|
1254
|
+
outputIndex: state.output.length,
|
|
1255
|
+
tokensIndex: state.tokens.length
|
|
1256
|
+
};
|
|
1257
|
+
braces.push(open2);
|
|
1258
|
+
push(open2);
|
|
1259
|
+
continue;
|
|
1260
|
+
}
|
|
1261
|
+
if (value === "}") {
|
|
1262
|
+
const brace = braces[braces.length - 1];
|
|
1263
|
+
if (opts.nobrace === true || !brace) {
|
|
1264
|
+
push({ type: "text", value, output: value });
|
|
1265
|
+
continue;
|
|
1266
|
+
}
|
|
1267
|
+
let output2 = ")";
|
|
1268
|
+
if (brace.dots === true) {
|
|
1269
|
+
const arr = tokens.slice();
|
|
1270
|
+
const range = [];
|
|
1271
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
1272
|
+
tokens.pop();
|
|
1273
|
+
if (arr[i].type === "brace") {
|
|
1274
|
+
break;
|
|
1275
|
+
}
|
|
1276
|
+
if (arr[i].type !== "dots") {
|
|
1277
|
+
range.unshift(arr[i].value);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
output2 = expandRange(range, opts);
|
|
1281
|
+
state.backtrack = true;
|
|
1282
|
+
}
|
|
1283
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
1284
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1285
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1286
|
+
brace.value = brace.output = "\\{";
|
|
1287
|
+
value = output2 = "\\}";
|
|
1288
|
+
state.output = out;
|
|
1289
|
+
for (const t of toks) {
|
|
1290
|
+
state.output += t.output || t.value;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
push({ type: "brace", value, output: output2 });
|
|
1294
|
+
decrement("braces");
|
|
1295
|
+
braces.pop();
|
|
1296
|
+
continue;
|
|
1297
|
+
}
|
|
1298
|
+
if (value === "|") {
|
|
1299
|
+
if (extglobs.length > 0) {
|
|
1300
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
1301
|
+
}
|
|
1302
|
+
push({ type: "text", value });
|
|
1303
|
+
continue;
|
|
1304
|
+
}
|
|
1305
|
+
if (value === ",") {
|
|
1306
|
+
let output2 = value;
|
|
1307
|
+
const brace = braces[braces.length - 1];
|
|
1308
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
1309
|
+
brace.comma = true;
|
|
1310
|
+
output2 = "|";
|
|
1311
|
+
}
|
|
1312
|
+
push({ type: "comma", value, output: output2 });
|
|
1313
|
+
continue;
|
|
1314
|
+
}
|
|
1315
|
+
if (value === "/") {
|
|
1316
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1317
|
+
state.start = state.index + 1;
|
|
1318
|
+
state.consumed = "";
|
|
1319
|
+
state.output = "";
|
|
1320
|
+
tokens.pop();
|
|
1321
|
+
prev = bos;
|
|
1322
|
+
continue;
|
|
1323
|
+
}
|
|
1324
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
1325
|
+
continue;
|
|
1326
|
+
}
|
|
1327
|
+
if (value === ".") {
|
|
1328
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1329
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1330
|
+
const brace = braces[braces.length - 1];
|
|
1331
|
+
prev.type = "dots";
|
|
1332
|
+
prev.output += value;
|
|
1333
|
+
prev.value += value;
|
|
1334
|
+
brace.dots = true;
|
|
1335
|
+
continue;
|
|
1336
|
+
}
|
|
1337
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1338
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
1339
|
+
continue;
|
|
1340
|
+
}
|
|
1341
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
1342
|
+
continue;
|
|
1343
|
+
}
|
|
1344
|
+
if (value === "?") {
|
|
1345
|
+
const isGroup = prev && prev.value === "(";
|
|
1346
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1347
|
+
extglobOpen("qmark", value);
|
|
1348
|
+
continue;
|
|
1349
|
+
}
|
|
1350
|
+
if (prev && prev.type === "paren") {
|
|
1351
|
+
const next = peek();
|
|
1352
|
+
let output2 = value;
|
|
1353
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
1354
|
+
output2 = `\\${value}`;
|
|
1355
|
+
}
|
|
1356
|
+
push({ type: "text", value, output: output2 });
|
|
1357
|
+
continue;
|
|
1358
|
+
}
|
|
1359
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1360
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
1361
|
+
continue;
|
|
1362
|
+
}
|
|
1363
|
+
push({ type: "qmark", value, output: QMARK });
|
|
1364
|
+
continue;
|
|
1365
|
+
}
|
|
1366
|
+
if (value === "!") {
|
|
1367
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
1368
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1369
|
+
extglobOpen("negate", value);
|
|
1370
|
+
continue;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
1374
|
+
negate();
|
|
1375
|
+
continue;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
if (value === "+") {
|
|
1379
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1380
|
+
extglobOpen("plus", value);
|
|
1381
|
+
continue;
|
|
1382
|
+
}
|
|
1383
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1384
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1385
|
+
continue;
|
|
1386
|
+
}
|
|
1387
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1388
|
+
push({ type: "plus", value });
|
|
1389
|
+
continue;
|
|
1390
|
+
}
|
|
1391
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
1392
|
+
continue;
|
|
1393
|
+
}
|
|
1394
|
+
if (value === "@") {
|
|
1395
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1396
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
1397
|
+
continue;
|
|
1398
|
+
}
|
|
1399
|
+
push({ type: "text", value });
|
|
1400
|
+
continue;
|
|
1401
|
+
}
|
|
1402
|
+
if (value !== "*") {
|
|
1403
|
+
if (value === "$" || value === "^") {
|
|
1404
|
+
value = `\\${value}`;
|
|
1405
|
+
}
|
|
1406
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1407
|
+
if (match) {
|
|
1408
|
+
value += match[0];
|
|
1409
|
+
state.index += match[0].length;
|
|
1410
|
+
}
|
|
1411
|
+
push({ type: "text", value });
|
|
1412
|
+
continue;
|
|
1413
|
+
}
|
|
1414
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1415
|
+
prev.type = "star";
|
|
1416
|
+
prev.star = true;
|
|
1417
|
+
prev.value += value;
|
|
1418
|
+
prev.output = star;
|
|
1419
|
+
state.backtrack = true;
|
|
1420
|
+
state.globstar = true;
|
|
1421
|
+
consume(value);
|
|
1422
|
+
continue;
|
|
1423
|
+
}
|
|
1424
|
+
let rest = remaining();
|
|
1425
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1426
|
+
extglobOpen("star", value);
|
|
1427
|
+
continue;
|
|
1428
|
+
}
|
|
1429
|
+
if (prev.type === "star") {
|
|
1430
|
+
if (opts.noglobstar === true) {
|
|
1431
|
+
consume(value);
|
|
1432
|
+
continue;
|
|
1433
|
+
}
|
|
1434
|
+
const prior = prev.prev;
|
|
1435
|
+
const before = prior.prev;
|
|
1436
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1437
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1438
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1439
|
+
push({ type: "star", value, output: "" });
|
|
1440
|
+
continue;
|
|
1441
|
+
}
|
|
1442
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1443
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1444
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1445
|
+
push({ type: "star", value, output: "" });
|
|
1446
|
+
continue;
|
|
1447
|
+
}
|
|
1448
|
+
while (rest.slice(0, 3) === "/**") {
|
|
1449
|
+
const after = input2[state.index + 4];
|
|
1450
|
+
if (after && after !== "/") {
|
|
1451
|
+
break;
|
|
1452
|
+
}
|
|
1453
|
+
rest = rest.slice(3);
|
|
1454
|
+
consume("/**", 3);
|
|
1455
|
+
}
|
|
1456
|
+
if (prior.type === "bos" && eos()) {
|
|
1457
|
+
prev.type = "globstar";
|
|
1458
|
+
prev.value += value;
|
|
1459
|
+
prev.output = globstar(opts);
|
|
1460
|
+
state.output = prev.output;
|
|
1461
|
+
state.globstar = true;
|
|
1462
|
+
consume(value);
|
|
1463
|
+
continue;
|
|
1464
|
+
}
|
|
1465
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1466
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1467
|
+
prior.output = `(?:${prior.output}`;
|
|
1468
|
+
prev.type = "globstar";
|
|
1469
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1470
|
+
prev.value += value;
|
|
1471
|
+
state.globstar = true;
|
|
1472
|
+
state.output += prior.output + prev.output;
|
|
1473
|
+
consume(value);
|
|
1474
|
+
continue;
|
|
1475
|
+
}
|
|
1476
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1477
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1478
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1479
|
+
prior.output = `(?:${prior.output}`;
|
|
1480
|
+
prev.type = "globstar";
|
|
1481
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1482
|
+
prev.value += value;
|
|
1483
|
+
state.output += prior.output + prev.output;
|
|
1484
|
+
state.globstar = true;
|
|
1485
|
+
consume(value + advance());
|
|
1486
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1487
|
+
continue;
|
|
1488
|
+
}
|
|
1489
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
1490
|
+
prev.type = "globstar";
|
|
1491
|
+
prev.value += value;
|
|
1492
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1493
|
+
state.output = prev.output;
|
|
1494
|
+
state.globstar = true;
|
|
1495
|
+
consume(value + advance());
|
|
1496
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1497
|
+
continue;
|
|
1498
|
+
}
|
|
1499
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1500
|
+
prev.type = "globstar";
|
|
1501
|
+
prev.output = globstar(opts);
|
|
1502
|
+
prev.value += value;
|
|
1503
|
+
state.output += prev.output;
|
|
1504
|
+
state.globstar = true;
|
|
1505
|
+
consume(value);
|
|
1506
|
+
continue;
|
|
1507
|
+
}
|
|
1508
|
+
const token = { type: "star", value, output: star };
|
|
1509
|
+
if (opts.bash === true) {
|
|
1510
|
+
token.output = ".*?";
|
|
1511
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
1512
|
+
token.output = nodot + token.output;
|
|
1513
|
+
}
|
|
1514
|
+
push(token);
|
|
1515
|
+
continue;
|
|
1516
|
+
}
|
|
1517
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
1518
|
+
token.output = value;
|
|
1519
|
+
push(token);
|
|
1520
|
+
continue;
|
|
1521
|
+
}
|
|
1522
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1523
|
+
if (prev.type === "dot") {
|
|
1524
|
+
state.output += NO_DOT_SLASH;
|
|
1525
|
+
prev.output += NO_DOT_SLASH;
|
|
1526
|
+
} else if (opts.dot === true) {
|
|
1527
|
+
state.output += NO_DOTS_SLASH;
|
|
1528
|
+
prev.output += NO_DOTS_SLASH;
|
|
1529
|
+
} else {
|
|
1530
|
+
state.output += nodot;
|
|
1531
|
+
prev.output += nodot;
|
|
1532
|
+
}
|
|
1533
|
+
if (peek() !== "*") {
|
|
1534
|
+
state.output += ONE_CHAR;
|
|
1535
|
+
prev.output += ONE_CHAR;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
push(token);
|
|
1539
|
+
}
|
|
1540
|
+
while (state.brackets > 0) {
|
|
1541
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1542
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
1543
|
+
decrement("brackets");
|
|
1544
|
+
}
|
|
1545
|
+
while (state.parens > 0) {
|
|
1546
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
1547
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
1548
|
+
decrement("parens");
|
|
1549
|
+
}
|
|
1550
|
+
while (state.braces > 0) {
|
|
1551
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
1552
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
1553
|
+
decrement("braces");
|
|
1554
|
+
}
|
|
1555
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
1556
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
1557
|
+
}
|
|
1558
|
+
if (state.backtrack === true) {
|
|
1559
|
+
state.output = "";
|
|
1560
|
+
for (const token of state.tokens) {
|
|
1561
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1562
|
+
if (token.suffix) {
|
|
1563
|
+
state.output += token.suffix;
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
return state;
|
|
1568
|
+
};
|
|
1569
|
+
parse2.fastpaths = (input2, options) => {
|
|
1570
|
+
const opts = { ...options };
|
|
1571
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1572
|
+
const len = input2.length;
|
|
1573
|
+
if (len > max) {
|
|
1574
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1575
|
+
}
|
|
1576
|
+
input2 = REPLACEMENTS[input2] || input2;
|
|
1577
|
+
const {
|
|
1578
|
+
DOT_LITERAL,
|
|
1579
|
+
SLASH_LITERAL,
|
|
1580
|
+
ONE_CHAR,
|
|
1581
|
+
DOTS_SLASH,
|
|
1582
|
+
NO_DOT,
|
|
1583
|
+
NO_DOTS,
|
|
1584
|
+
NO_DOTS_SLASH,
|
|
1585
|
+
STAR,
|
|
1586
|
+
START_ANCHOR
|
|
1587
|
+
} = constants.globChars(opts.windows);
|
|
1588
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1589
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1590
|
+
const capture = opts.capture ? "" : "?:";
|
|
1591
|
+
const state = { negated: false, prefix: "" };
|
|
1592
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
1593
|
+
if (opts.capture) {
|
|
1594
|
+
star = `(${star})`;
|
|
1595
|
+
}
|
|
1596
|
+
const globstar = (opts2) => {
|
|
1597
|
+
if (opts2.noglobstar === true) return star;
|
|
1598
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1599
|
+
};
|
|
1600
|
+
const create = (str) => {
|
|
1601
|
+
switch (str) {
|
|
1602
|
+
case "*":
|
|
1603
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
1604
|
+
case ".*":
|
|
1605
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1606
|
+
case "*.*":
|
|
1607
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1608
|
+
case "*/*":
|
|
1609
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1610
|
+
case "**":
|
|
1611
|
+
return nodot + globstar(opts);
|
|
1612
|
+
case "**/*":
|
|
1613
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1614
|
+
case "**/*.*":
|
|
1615
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1616
|
+
case "**/.*":
|
|
1617
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1618
|
+
default: {
|
|
1619
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1620
|
+
if (!match) return;
|
|
1621
|
+
const source2 = create(match[1]);
|
|
1622
|
+
if (!source2) return;
|
|
1623
|
+
return source2 + DOT_LITERAL + match[2];
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1627
|
+
const output2 = utils.removePrefix(input2, state);
|
|
1628
|
+
let source = create(output2);
|
|
1629
|
+
if (source && opts.strictSlashes !== true) {
|
|
1630
|
+
source += `${SLASH_LITERAL}?`;
|
|
1631
|
+
}
|
|
1632
|
+
return source;
|
|
1633
|
+
};
|
|
1634
|
+
module.exports = parse2;
|
|
1635
|
+
}
|
|
1636
|
+
});
|
|
1637
|
+
|
|
1638
|
+
// ../../node_modules/picomatch/lib/picomatch.js
|
|
1639
|
+
var require_picomatch = __commonJS({
|
|
1640
|
+
"../../node_modules/picomatch/lib/picomatch.js"(exports, module) {
|
|
1641
|
+
"use strict";
|
|
1642
|
+
var scan = require_scan();
|
|
1643
|
+
var parse2 = require_parse();
|
|
1644
|
+
var utils = require_utils();
|
|
1645
|
+
var constants = require_constants();
|
|
1646
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1647
|
+
var picomatch2 = (glob, options, returnState = false) => {
|
|
1648
|
+
if (Array.isArray(glob)) {
|
|
1649
|
+
const fns = glob.map((input2) => picomatch2(input2, options, returnState));
|
|
1650
|
+
const arrayMatcher = (str) => {
|
|
1651
|
+
for (const isMatch of fns) {
|
|
1652
|
+
const state2 = isMatch(str);
|
|
1653
|
+
if (state2) return state2;
|
|
1654
|
+
}
|
|
1655
|
+
return false;
|
|
1656
|
+
};
|
|
1657
|
+
return arrayMatcher;
|
|
1658
|
+
}
|
|
1659
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1660
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
1661
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
1662
|
+
}
|
|
1663
|
+
const opts = options || {};
|
|
1664
|
+
const posix = opts.windows;
|
|
1665
|
+
const regex = isState ? picomatch2.compileRe(glob, options) : picomatch2.makeRe(glob, options, false, true);
|
|
1666
|
+
const state = regex.state;
|
|
1667
|
+
delete regex.state;
|
|
1668
|
+
let isIgnored = () => false;
|
|
1669
|
+
if (opts.ignore) {
|
|
1670
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
1671
|
+
isIgnored = picomatch2(opts.ignore, ignoreOpts, returnState);
|
|
1672
|
+
}
|
|
1673
|
+
const matcher = (input2, returnObject = false) => {
|
|
1674
|
+
const { isMatch, match, output: output2 } = picomatch2.test(input2, regex, options, { glob, posix });
|
|
1675
|
+
const result = { glob, state, regex, posix, input: input2, output: output2, match, isMatch };
|
|
1676
|
+
if (typeof opts.onResult === "function") {
|
|
1677
|
+
opts.onResult(result);
|
|
1678
|
+
}
|
|
1679
|
+
if (isMatch === false) {
|
|
1680
|
+
result.isMatch = false;
|
|
1681
|
+
return returnObject ? result : false;
|
|
1682
|
+
}
|
|
1683
|
+
if (isIgnored(input2)) {
|
|
1684
|
+
if (typeof opts.onIgnore === "function") {
|
|
1685
|
+
opts.onIgnore(result);
|
|
1686
|
+
}
|
|
1687
|
+
result.isMatch = false;
|
|
1688
|
+
return returnObject ? result : false;
|
|
1689
|
+
}
|
|
1690
|
+
if (typeof opts.onMatch === "function") {
|
|
1691
|
+
opts.onMatch(result);
|
|
1692
|
+
}
|
|
1693
|
+
return returnObject ? result : true;
|
|
1694
|
+
};
|
|
1695
|
+
if (returnState) {
|
|
1696
|
+
matcher.state = state;
|
|
1697
|
+
}
|
|
1698
|
+
return matcher;
|
|
1699
|
+
};
|
|
1700
|
+
picomatch2.test = (input2, regex, options, { glob, posix } = {}) => {
|
|
1701
|
+
if (typeof input2 !== "string") {
|
|
1702
|
+
throw new TypeError("Expected input to be a string");
|
|
1703
|
+
}
|
|
1704
|
+
if (input2 === "") {
|
|
1705
|
+
return { isMatch: false, output: "" };
|
|
1706
|
+
}
|
|
1707
|
+
const opts = options || {};
|
|
1708
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
1709
|
+
let match = input2 === glob;
|
|
1710
|
+
let output2 = match && format ? format(input2) : input2;
|
|
1711
|
+
if (match === false) {
|
|
1712
|
+
output2 = format ? format(input2) : input2;
|
|
1713
|
+
match = output2 === glob;
|
|
1714
|
+
}
|
|
1715
|
+
if (match === false || opts.capture === true) {
|
|
1716
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
1717
|
+
match = picomatch2.matchBase(input2, regex, options, posix);
|
|
1718
|
+
} else {
|
|
1719
|
+
match = regex.exec(output2);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
return { isMatch: Boolean(match), match, output: output2 };
|
|
1723
|
+
};
|
|
1724
|
+
picomatch2.matchBase = (input2, glob, options, posix = options && options.windows) => {
|
|
1725
|
+
const regex = glob instanceof RegExp ? glob : picomatch2.makeRe(glob, options);
|
|
1726
|
+
return regex.test(utils.basename(input2, { windows: posix }));
|
|
1727
|
+
};
|
|
1728
|
+
picomatch2.isMatch = (str, patterns, options) => picomatch2(patterns, options)(str);
|
|
1729
|
+
picomatch2.parse = (pattern, options) => {
|
|
1730
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch2.parse(p, options));
|
|
1731
|
+
return parse2(pattern, { ...options, fastpaths: false });
|
|
1732
|
+
};
|
|
1733
|
+
picomatch2.scan = (input2, options) => scan(input2, options);
|
|
1734
|
+
picomatch2.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
1735
|
+
if (returnOutput === true) {
|
|
1736
|
+
return state.output;
|
|
1737
|
+
}
|
|
1738
|
+
const opts = options || {};
|
|
1739
|
+
const prepend = opts.contains ? "" : "^";
|
|
1740
|
+
const append = opts.contains ? "" : "$";
|
|
1741
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
1742
|
+
if (state && state.negated === true) {
|
|
1743
|
+
source = `^(?!${source}).*$`;
|
|
1744
|
+
}
|
|
1745
|
+
const regex = picomatch2.toRegex(source, options);
|
|
1746
|
+
if (returnState === true) {
|
|
1747
|
+
regex.state = state;
|
|
1748
|
+
}
|
|
1749
|
+
return regex;
|
|
1750
|
+
};
|
|
1751
|
+
picomatch2.makeRe = (input2, options = {}, returnOutput = false, returnState = false) => {
|
|
1752
|
+
if (!input2 || typeof input2 !== "string") {
|
|
1753
|
+
throw new TypeError("Expected a non-empty string");
|
|
1754
|
+
}
|
|
1755
|
+
let parsed = { negated: false, fastpaths: true };
|
|
1756
|
+
if (options.fastpaths !== false && (input2[0] === "." || input2[0] === "*")) {
|
|
1757
|
+
parsed.output = parse2.fastpaths(input2, options);
|
|
1758
|
+
}
|
|
1759
|
+
if (!parsed.output) {
|
|
1760
|
+
parsed = parse2(input2, options);
|
|
1761
|
+
}
|
|
1762
|
+
return picomatch2.compileRe(parsed, options, returnOutput, returnState);
|
|
1763
|
+
};
|
|
1764
|
+
picomatch2.toRegex = (source, options) => {
|
|
1765
|
+
try {
|
|
1766
|
+
const opts = options || {};
|
|
1767
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
1768
|
+
} catch (err) {
|
|
1769
|
+
if (options && options.debug === true) throw err;
|
|
1770
|
+
return /$^/;
|
|
1771
|
+
}
|
|
1772
|
+
};
|
|
1773
|
+
picomatch2.constants = constants;
|
|
1774
|
+
module.exports = picomatch2;
|
|
1775
|
+
}
|
|
1776
|
+
});
|
|
1777
|
+
|
|
1778
|
+
// ../../node_modules/picomatch/index.js
|
|
1779
|
+
var require_picomatch2 = __commonJS({
|
|
1780
|
+
"../../node_modules/picomatch/index.js"(exports, module) {
|
|
1781
|
+
"use strict";
|
|
1782
|
+
var pico = require_picomatch();
|
|
1783
|
+
var utils = require_utils();
|
|
1784
|
+
function picomatch2(glob, options, returnState = false) {
|
|
1785
|
+
if (options && (options.windows === null || options.windows === void 0)) {
|
|
1786
|
+
options = { ...options, windows: utils.isWindows() };
|
|
1787
|
+
}
|
|
1788
|
+
return pico(glob, options, returnState);
|
|
1789
|
+
}
|
|
1790
|
+
Object.assign(picomatch2, pico);
|
|
1791
|
+
module.exports = picomatch2;
|
|
1792
|
+
}
|
|
1793
|
+
});
|
|
2
1794
|
|
|
3
1795
|
// src/cli/proxy-env.ts
|
|
4
1796
|
import { Agent, Dispatcher, ProxyAgent, setGlobalDispatcher } from "undici";
|
|
@@ -158,9 +1950,9 @@ function configureProxyFromEnv() {
|
|
|
158
1950
|
configureProxyFromEnv();
|
|
159
1951
|
|
|
160
1952
|
// src/cli/index.ts
|
|
161
|
-
import { mkdtemp as
|
|
162
|
-
import { join as
|
|
163
|
-
import { tmpdir as
|
|
1953
|
+
import { mkdtemp as mkdtemp3, rm as rm4, writeFile as writeFile6 } from "fs/promises";
|
|
1954
|
+
import { join as join27 } from "path";
|
|
1955
|
+
import { tmpdir as tmpdir7 } from "os";
|
|
164
1956
|
import { Command as Command5 } from "commander";
|
|
165
1957
|
|
|
166
1958
|
// src/pagination.ts
|
|
@@ -1044,9 +2836,9 @@ function findNearestGitCommonDir(startDir) {
|
|
|
1044
2836
|
const candidate = join(current, ".git");
|
|
1045
2837
|
if (existsSync(candidate)) {
|
|
1046
2838
|
try {
|
|
1047
|
-
const
|
|
1048
|
-
if (
|
|
1049
|
-
if (
|
|
2839
|
+
const stat5 = statSync(candidate);
|
|
2840
|
+
if (stat5.isDirectory()) return candidate;
|
|
2841
|
+
if (stat5.isFile()) {
|
|
1050
2842
|
const match = readFileSync(candidate, "utf8").match(
|
|
1051
2843
|
/^gitdir:\s*(.+)$/m
|
|
1052
2844
|
);
|
|
@@ -1271,7 +3063,7 @@ var SDK_RELEASE = {
|
|
|
1271
3063
|
// getters keep their established compatibility behavior.
|
|
1272
3064
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
1273
3065
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
1274
|
-
version: "0.3.
|
|
3066
|
+
version: "0.3.119",
|
|
1275
3067
|
updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
|
|
1276
3068
|
packageCapabilities: {
|
|
1277
3069
|
updatePreferences: 1
|
|
@@ -2451,7 +4243,7 @@ function decodeSseFrame(frame) {
|
|
|
2451
4243
|
return parsed;
|
|
2452
4244
|
}
|
|
2453
4245
|
function sleep(ms) {
|
|
2454
|
-
return new Promise((
|
|
4246
|
+
return new Promise((resolve22) => setTimeout(resolve22, ms));
|
|
2455
4247
|
}
|
|
2456
4248
|
function withCoworkNetworkHint(message) {
|
|
2457
4249
|
if (!isCoworkLikeSandbox2() || message.includes(COWORK_NETWORK_HINT)) {
|
|
@@ -4348,14 +6140,14 @@ async function* observeRunEvents(options) {
|
|
|
4348
6140
|
try {
|
|
4349
6141
|
for (; ; ) {
|
|
4350
6142
|
if (queue.length === 0) {
|
|
4351
|
-
const waitForItem = new Promise((
|
|
4352
|
-
wake =
|
|
6143
|
+
const waitForItem = new Promise((resolve22) => {
|
|
6144
|
+
wake = resolve22;
|
|
4353
6145
|
});
|
|
4354
6146
|
if (!sawFirstSnapshot) {
|
|
4355
6147
|
const timedOut = await Promise.race([
|
|
4356
6148
|
waitForItem.then(() => false),
|
|
4357
6149
|
new Promise(
|
|
4358
|
-
(
|
|
6150
|
+
(resolve22) => setTimeout(() => resolve22(true), OBSERVE_BOOTSTRAP_TIMEOUT_MS)
|
|
4359
6151
|
)
|
|
4360
6152
|
]);
|
|
4361
6153
|
if (timedOut && queue.length === 0) {
|
|
@@ -4754,7 +6546,7 @@ function parseEnvTestPolicyOverrides() {
|
|
|
4754
6546
|
return normalizeTestPolicyOverrides(parsed, "DEEPLINE_TEST_POLICY_OVERRIDES");
|
|
4755
6547
|
}
|
|
4756
6548
|
function sleep2(ms) {
|
|
4757
|
-
return new Promise((
|
|
6549
|
+
return new Promise((resolve22) => setTimeout(resolve22, ms));
|
|
4758
6550
|
}
|
|
4759
6551
|
function isTransientCompileManifestError(error) {
|
|
4760
6552
|
if (error instanceof DeeplineError && typeof error.statusCode === "number") {
|
|
@@ -9435,7 +11227,7 @@ function buildCandidateUrls2(url) {
|
|
|
9435
11227
|
}
|
|
9436
11228
|
}
|
|
9437
11229
|
function sleep4(ms) {
|
|
9438
|
-
return new Promise((
|
|
11230
|
+
return new Promise((resolve22) => setTimeout(resolve22, ms));
|
|
9439
11231
|
}
|
|
9440
11232
|
function printDeeplineLogo() {
|
|
9441
11233
|
if (process.stdout.isTTY && (process.stdout.columns ?? 80) >= 70) {
|
|
@@ -12329,38 +14121,38 @@ function buildDatasetStats(rows, totalRows = rows.length, columns = inferColumns
|
|
|
12329
14121
|
}
|
|
12330
14122
|
}
|
|
12331
14123
|
const denominator = nonEmpty + empty;
|
|
12332
|
-
const
|
|
14124
|
+
const stat5 = {
|
|
12333
14125
|
non_empty: percentText(nonEmpty, denominator),
|
|
12334
14126
|
unique: valueCounts.size
|
|
12335
14127
|
};
|
|
12336
14128
|
const rawExecutionStats = executionStats?.columnStats[column];
|
|
12337
14129
|
if (rawExecutionStats) {
|
|
12338
|
-
|
|
14130
|
+
stat5.execution = formatDatasetExecutionStats(
|
|
12339
14131
|
rawExecutionStats,
|
|
12340
14132
|
totalRows
|
|
12341
14133
|
);
|
|
12342
14134
|
}
|
|
12343
14135
|
if (sampleValue !== void 0 && sampleValueType) {
|
|
12344
|
-
|
|
12345
|
-
|
|
14136
|
+
stat5.sample_value = sampleValue;
|
|
14137
|
+
stat5.sample_type = sampleValueType;
|
|
12346
14138
|
}
|
|
12347
14139
|
if (valueCounts.size > 0 && valueCounts.size < nonEmpty) {
|
|
12348
14140
|
const top = [...valueCounts.entries()].sort((left, right) => right[1] - left[1]).slice(0, 3);
|
|
12349
14141
|
const topKeys = new Set(top.map(([key]) => key));
|
|
12350
14142
|
const otherCount = [...valueCounts.entries()].filter(([key]) => !topKeys.has(key)).reduce((sum, [, count]) => sum + count, 0);
|
|
12351
|
-
|
|
14143
|
+
stat5.top_values = Object.fromEntries(
|
|
12352
14144
|
top.map(([key, count]) => [key, countPercentText(count, denominator)])
|
|
12353
14145
|
);
|
|
12354
14146
|
if (otherCount > 0) {
|
|
12355
|
-
|
|
14147
|
+
stat5.top_values["(other)"] = countPercentText(otherCount, denominator);
|
|
12356
14148
|
}
|
|
12357
14149
|
if (empty > 0) {
|
|
12358
|
-
|
|
14150
|
+
stat5.top_values["(null)"] = countPercentText(empty, denominator);
|
|
12359
14151
|
}
|
|
12360
14152
|
} else if (empty > 0 && nonEmpty > 0) {
|
|
12361
|
-
|
|
14153
|
+
stat5.top_values = { "(null)": countPercentText(empty, denominator) };
|
|
12362
14154
|
}
|
|
12363
|
-
columnStats[column] =
|
|
14155
|
+
columnStats[column] = stat5;
|
|
12364
14156
|
}
|
|
12365
14157
|
return {
|
|
12366
14158
|
total_rows: totalRows,
|
|
@@ -13263,20 +15055,20 @@ import {
|
|
|
13263
15055
|
copyFile,
|
|
13264
15056
|
lstat as lstat2,
|
|
13265
15057
|
mkdir as mkdir4,
|
|
13266
|
-
mkdtemp,
|
|
13267
|
-
readFile as
|
|
13268
|
-
realpath as
|
|
15058
|
+
mkdtemp as mkdtemp2,
|
|
15059
|
+
readFile as readFile4,
|
|
15060
|
+
realpath as realpath4,
|
|
13269
15061
|
rename,
|
|
13270
|
-
rm,
|
|
13271
|
-
stat as
|
|
15062
|
+
rm as rm3,
|
|
15063
|
+
stat as stat4,
|
|
13272
15064
|
writeFile as writeFile4
|
|
13273
15065
|
} from "fs/promises";
|
|
13274
|
-
import { homedir as homedir6, tmpdir as
|
|
13275
|
-
import { basename as basename4, dirname as dirname11, extname as extname3, join as
|
|
15066
|
+
import { homedir as homedir6, tmpdir as tmpdir5 } from "os";
|
|
15067
|
+
import { basename as basename4, dirname as dirname11, extname as extname3, join as join14, resolve as resolve13 } from "path";
|
|
13276
15068
|
import { Option as Option2 } from "commander";
|
|
13277
15069
|
|
|
13278
15070
|
// src/cli/commands/play.ts
|
|
13279
|
-
import { createHash as createHash4, randomUUID as
|
|
15071
|
+
import { createHash as createHash4, randomUUID as randomUUID4 } from "crypto";
|
|
13280
15072
|
import {
|
|
13281
15073
|
existsSync as existsSync9,
|
|
13282
15074
|
mkdirSync as mkdirSync7,
|
|
@@ -13297,9 +15089,9 @@ import {
|
|
|
13297
15089
|
basename as basename3,
|
|
13298
15090
|
dirname as dirname10,
|
|
13299
15091
|
isAbsolute as isAbsolute5,
|
|
13300
|
-
join as
|
|
13301
|
-
relative as
|
|
13302
|
-
resolve as
|
|
15092
|
+
join as join13,
|
|
15093
|
+
relative as relative5,
|
|
15094
|
+
resolve as resolve12
|
|
13303
15095
|
} from "path";
|
|
13304
15096
|
import { parse as parseCsvSync2 } from "csv-parse/sync";
|
|
13305
15097
|
|
|
@@ -18358,6 +20150,1203 @@ function normalizeFixtureScopeValue(value, maxLength) {
|
|
|
18358
20150
|
return { value: normalized };
|
|
18359
20151
|
}
|
|
18360
20152
|
|
|
20153
|
+
// src/cli/commands/plays-deploy.ts
|
|
20154
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
20155
|
+
import { mkdtemp, realpath as realpath3, rm as rm2 } from "fs/promises";
|
|
20156
|
+
import { tmpdir as tmpdir4 } from "os";
|
|
20157
|
+
import { join as join12, resolve as resolve11 } from "path";
|
|
20158
|
+
|
|
20159
|
+
// ../plays/deploy/run-deployment.ts
|
|
20160
|
+
import { join as join11 } from "path";
|
|
20161
|
+
import { rm } from "fs/promises";
|
|
20162
|
+
|
|
20163
|
+
// ../plays/deploy/api-client.ts
|
|
20164
|
+
var REGISTER_MAX_BATCH_COUNT = 3;
|
|
20165
|
+
var REGISTER_MAX_BATCH_BYTES = 25e5;
|
|
20166
|
+
var DeployApiError = class extends Error {
|
|
20167
|
+
status;
|
|
20168
|
+
code;
|
|
20169
|
+
body;
|
|
20170
|
+
constructor(input2) {
|
|
20171
|
+
super(input2.message);
|
|
20172
|
+
this.name = "DeployApiError";
|
|
20173
|
+
this.status = input2.status;
|
|
20174
|
+
this.code = input2.code ?? null;
|
|
20175
|
+
this.body = input2.body;
|
|
20176
|
+
}
|
|
20177
|
+
};
|
|
20178
|
+
var DeployApiClient = class {
|
|
20179
|
+
constructor(config) {
|
|
20180
|
+
this.config = config;
|
|
20181
|
+
}
|
|
20182
|
+
async request(input2) {
|
|
20183
|
+
const doFetch = this.config.fetchImpl ?? fetch;
|
|
20184
|
+
const response = await doFetch(
|
|
20185
|
+
`${this.config.appBaseUrl.replace(/\/$/, "")}${input2.path}`,
|
|
20186
|
+
{
|
|
20187
|
+
method: input2.method,
|
|
20188
|
+
headers: {
|
|
20189
|
+
Authorization: `Bearer ${this.config.deployToken}`,
|
|
20190
|
+
...input2.body !== void 0 ? { "Content-Type": "application/json" } : {}
|
|
20191
|
+
},
|
|
20192
|
+
body: input2.body !== void 0 ? JSON.stringify(input2.body) : void 0
|
|
20193
|
+
}
|
|
20194
|
+
);
|
|
20195
|
+
const text = await response.text();
|
|
20196
|
+
let parsed = null;
|
|
20197
|
+
try {
|
|
20198
|
+
parsed = text ? JSON.parse(text) : null;
|
|
20199
|
+
} catch {
|
|
20200
|
+
parsed = text;
|
|
20201
|
+
}
|
|
20202
|
+
if (!response.ok) {
|
|
20203
|
+
const record3 = parsed ?? {};
|
|
20204
|
+
throw new DeployApiError({
|
|
20205
|
+
message: typeof record3.error === "string" ? record3.error : `Deploy API ${input2.path} failed (${response.status}).`,
|
|
20206
|
+
status: response.status,
|
|
20207
|
+
code: typeof record3.code === "string" ? record3.code : null,
|
|
20208
|
+
body: parsed
|
|
20209
|
+
});
|
|
20210
|
+
}
|
|
20211
|
+
return parsed;
|
|
20212
|
+
}
|
|
20213
|
+
/** Every deployment-scoped route hangs off this one path. */
|
|
20214
|
+
deploymentPath(suffix = "") {
|
|
20215
|
+
return `/api/v2/deployments/${this.config.deploymentId}${suffix}`;
|
|
20216
|
+
}
|
|
20217
|
+
getDeployment() {
|
|
20218
|
+
return this.request({
|
|
20219
|
+
method: "GET",
|
|
20220
|
+
path: this.deploymentPath()
|
|
20221
|
+
});
|
|
20222
|
+
}
|
|
20223
|
+
setStatus(input2) {
|
|
20224
|
+
return this.request({
|
|
20225
|
+
method: "POST",
|
|
20226
|
+
path: this.deploymentPath("/status"),
|
|
20227
|
+
body: input2
|
|
20228
|
+
});
|
|
20229
|
+
}
|
|
20230
|
+
mintGitHubToken() {
|
|
20231
|
+
return this.request({
|
|
20232
|
+
method: "POST",
|
|
20233
|
+
path: this.deploymentPath("/github-token"),
|
|
20234
|
+
body: {}
|
|
20235
|
+
});
|
|
20236
|
+
}
|
|
20237
|
+
playsState(names) {
|
|
20238
|
+
return this.request({
|
|
20239
|
+
method: "POST",
|
|
20240
|
+
path: this.deploymentPath("/plays-state"),
|
|
20241
|
+
body: { names }
|
|
20242
|
+
});
|
|
20243
|
+
}
|
|
20244
|
+
compileManifest(input2) {
|
|
20245
|
+
return this.request({
|
|
20246
|
+
method: "POST",
|
|
20247
|
+
path: "/api/v2/plays/compile-manifest",
|
|
20248
|
+
body: input2
|
|
20249
|
+
});
|
|
20250
|
+
}
|
|
20251
|
+
async registerArtifacts(entries) {
|
|
20252
|
+
const results = [];
|
|
20253
|
+
let batch = [];
|
|
20254
|
+
let batchBytes = 0;
|
|
20255
|
+
const flush = async () => {
|
|
20256
|
+
if (batch.length === 0) return;
|
|
20257
|
+
const payload = await this.request({
|
|
20258
|
+
method: "POST",
|
|
20259
|
+
path: "/api/v2/plays/artifacts",
|
|
20260
|
+
body: {
|
|
20261
|
+
artifacts: batch.map((entry) => ({ ...entry, publish: false }))
|
|
20262
|
+
}
|
|
20263
|
+
});
|
|
20264
|
+
results.push(...payload.artifacts);
|
|
20265
|
+
batch = [];
|
|
20266
|
+
batchBytes = 0;
|
|
20267
|
+
};
|
|
20268
|
+
for (const entry of entries) {
|
|
20269
|
+
const entryBytes = Buffer.byteLength(
|
|
20270
|
+
JSON.stringify({ ...entry, publish: false }),
|
|
20271
|
+
"utf8"
|
|
20272
|
+
);
|
|
20273
|
+
if (batch.length >= REGISTER_MAX_BATCH_COUNT || batch.length > 0 && batchBytes + entryBytes > REGISTER_MAX_BATCH_BYTES) {
|
|
20274
|
+
await flush();
|
|
20275
|
+
}
|
|
20276
|
+
batch.push(entry);
|
|
20277
|
+
batchBytes += entryBytes;
|
|
20278
|
+
}
|
|
20279
|
+
await flush();
|
|
20280
|
+
return results;
|
|
20281
|
+
}
|
|
20282
|
+
promote(plays) {
|
|
20283
|
+
return this.request({
|
|
20284
|
+
method: "POST",
|
|
20285
|
+
path: this.deploymentPath("/promote"),
|
|
20286
|
+
body: { plays }
|
|
20287
|
+
});
|
|
20288
|
+
}
|
|
20289
|
+
};
|
|
20290
|
+
|
|
20291
|
+
// ../plays/deploy/manifest.ts
|
|
20292
|
+
var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
20293
|
+
import { readdir, readFile as readFile3, stat as stat3 } from "fs/promises";
|
|
20294
|
+
import { join as join10, relative as relative4 } from "path";
|
|
20295
|
+
var DEFAULT_PLAY_GLOBS = ["**/*.play.ts"];
|
|
20296
|
+
var MAX_DISCOVERED_PLAY_FILES = 200;
|
|
20297
|
+
var IGNORED_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
20298
|
+
"node_modules",
|
|
20299
|
+
".git",
|
|
20300
|
+
"dist",
|
|
20301
|
+
"build",
|
|
20302
|
+
".next"
|
|
20303
|
+
]);
|
|
20304
|
+
var DeeplineManifestError = class extends Error {
|
|
20305
|
+
constructor(message) {
|
|
20306
|
+
super(message);
|
|
20307
|
+
this.name = "DeeplineManifestError";
|
|
20308
|
+
}
|
|
20309
|
+
};
|
|
20310
|
+
function parseDeeplineManifest(raw) {
|
|
20311
|
+
if (raw === null) {
|
|
20312
|
+
return { plays: DEFAULT_PLAY_GLOBS };
|
|
20313
|
+
}
|
|
20314
|
+
let parsed;
|
|
20315
|
+
try {
|
|
20316
|
+
parsed = JSON.parse(raw);
|
|
20317
|
+
} catch (error) {
|
|
20318
|
+
throw new DeeplineManifestError(
|
|
20319
|
+
`deepline.json is not valid JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
20320
|
+
);
|
|
20321
|
+
}
|
|
20322
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
20323
|
+
throw new DeeplineManifestError("deepline.json must be a JSON object.");
|
|
20324
|
+
}
|
|
20325
|
+
const record3 = parsed;
|
|
20326
|
+
let plays = DEFAULT_PLAY_GLOBS;
|
|
20327
|
+
if (record3.plays !== void 0) {
|
|
20328
|
+
if (!Array.isArray(record3.plays) || record3.plays.length === 0 || !record3.plays.every(
|
|
20329
|
+
(glob) => typeof glob === "string" && glob.trim().length > 0
|
|
20330
|
+
)) {
|
|
20331
|
+
throw new DeeplineManifestError(
|
|
20332
|
+
'deepline.json "plays" must be a non-empty array of glob strings, e.g. ["plays/**/*.play.ts"].'
|
|
20333
|
+
);
|
|
20334
|
+
}
|
|
20335
|
+
plays = record3.plays.map((glob) => glob.trim().replace(/^\.\//, ""));
|
|
20336
|
+
}
|
|
20337
|
+
if (plays.some((glob) => glob.startsWith("/") || glob.includes(".."))) {
|
|
20338
|
+
throw new DeeplineManifestError(
|
|
20339
|
+
'deepline.json "plays" globs must be relative and must not contain "..".'
|
|
20340
|
+
);
|
|
20341
|
+
}
|
|
20342
|
+
const org = typeof record3.org === "string" && record3.org.trim() ? record3.org.trim() : void 0;
|
|
20343
|
+
return { plays, ...org ? { org } : {} };
|
|
20344
|
+
}
|
|
20345
|
+
var DEFAULT_MANIFEST_FILE = "deepline.json";
|
|
20346
|
+
async function readDeeplineManifest(projectRoot, manifestFile = DEFAULT_MANIFEST_FILE) {
|
|
20347
|
+
let raw = null;
|
|
20348
|
+
try {
|
|
20349
|
+
raw = await readFile3(join10(projectRoot, manifestFile), "utf8");
|
|
20350
|
+
} catch (error) {
|
|
20351
|
+
const code = error.code;
|
|
20352
|
+
if (code !== "ENOENT" && code !== "ENOTDIR") {
|
|
20353
|
+
throw error;
|
|
20354
|
+
}
|
|
20355
|
+
if (manifestFile !== DEFAULT_MANIFEST_FILE) {
|
|
20356
|
+
throw new DeeplineManifestError(
|
|
20357
|
+
`DEEPLINE_MANIFEST_MISSING: this project is configured to read ${manifestFile}, but the file does not exist at the project root.`
|
|
20358
|
+
);
|
|
20359
|
+
}
|
|
20360
|
+
raw = null;
|
|
20361
|
+
}
|
|
20362
|
+
try {
|
|
20363
|
+
return parseDeeplineManifest(raw);
|
|
20364
|
+
} catch (error) {
|
|
20365
|
+
if (error instanceof DeeplineManifestError) {
|
|
20366
|
+
throw new DeeplineManifestError(
|
|
20367
|
+
error.message.replace(/^deepline\.json/, manifestFile)
|
|
20368
|
+
);
|
|
20369
|
+
}
|
|
20370
|
+
throw error;
|
|
20371
|
+
}
|
|
20372
|
+
}
|
|
20373
|
+
async function discoverPlayFiles(input2) {
|
|
20374
|
+
const matchers = input2.globs.map((glob) => (0, import_picomatch.default)(glob));
|
|
20375
|
+
const found = [];
|
|
20376
|
+
async function walk(dir) {
|
|
20377
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
20378
|
+
for (const entry of entries) {
|
|
20379
|
+
if (entry.name.startsWith(".") && entry.name !== ".") continue;
|
|
20380
|
+
const absolute = join10(dir, entry.name);
|
|
20381
|
+
if (entry.isDirectory()) {
|
|
20382
|
+
if (IGNORED_DIRECTORIES.has(entry.name)) continue;
|
|
20383
|
+
await walk(absolute);
|
|
20384
|
+
continue;
|
|
20385
|
+
}
|
|
20386
|
+
if (!entry.isFile()) continue;
|
|
20387
|
+
const relativePath = relative4(input2.projectRoot, absolute);
|
|
20388
|
+
if (matchers.some((match) => match(relativePath))) {
|
|
20389
|
+
found.push(relativePath);
|
|
20390
|
+
if (found.length > MAX_DISCOVERED_PLAY_FILES) {
|
|
20391
|
+
throw new DeeplineManifestError(
|
|
20392
|
+
`deepline.json globs matched more than ${MAX_DISCOVERED_PLAY_FILES} play files. Tighten the globs.`
|
|
20393
|
+
);
|
|
20394
|
+
}
|
|
20395
|
+
}
|
|
20396
|
+
}
|
|
20397
|
+
}
|
|
20398
|
+
const rootStat = await stat3(input2.projectRoot).catch(() => null);
|
|
20399
|
+
if (!rootStat?.isDirectory()) {
|
|
20400
|
+
throw new DeeplineManifestError(
|
|
20401
|
+
`Project root directory does not exist in the repo: ${input2.projectRoot}`
|
|
20402
|
+
);
|
|
20403
|
+
}
|
|
20404
|
+
await walk(input2.projectRoot);
|
|
20405
|
+
return found.sort();
|
|
20406
|
+
}
|
|
20407
|
+
|
|
20408
|
+
// ../plays/play-reference.ts
|
|
20409
|
+
var PREBUILT_PLAY_NAMESPACE = "prebuilt";
|
|
20410
|
+
var SELF_PLAY_NAMESPACE = "self";
|
|
20411
|
+
function buildPlayReference(ownerSlug, playName) {
|
|
20412
|
+
return `${ownerSlug.trim()}/${playName.trim()}`;
|
|
20413
|
+
}
|
|
20414
|
+
function buildPrebuiltPlayReference(playName) {
|
|
20415
|
+
return buildPlayReference(PREBUILT_PLAY_NAMESPACE, playName);
|
|
20416
|
+
}
|
|
20417
|
+
function buildSelfPlayReference(playName) {
|
|
20418
|
+
return buildPlayReference(SELF_PLAY_NAMESPACE, playName);
|
|
20419
|
+
}
|
|
20420
|
+
function parsePlayReference(reference) {
|
|
20421
|
+
const trimmed = reference.trim();
|
|
20422
|
+
if (!trimmed) {
|
|
20423
|
+
return { kind: "invalid", reference: trimmed };
|
|
20424
|
+
}
|
|
20425
|
+
const segments = trimmed.split("/");
|
|
20426
|
+
if (segments.length === 1) {
|
|
20427
|
+
return { kind: "bare", reference: trimmed, name: trimmed };
|
|
20428
|
+
}
|
|
20429
|
+
if (segments.length !== 2) {
|
|
20430
|
+
return { kind: "invalid", reference: trimmed };
|
|
20431
|
+
}
|
|
20432
|
+
const [rawOwnerSlug = "", rawName = ""] = segments;
|
|
20433
|
+
const ownerSlug = rawOwnerSlug.trim();
|
|
20434
|
+
const name = rawName.trim();
|
|
20435
|
+
if (!ownerSlug || !name) {
|
|
20436
|
+
return { kind: "invalid", reference: trimmed };
|
|
20437
|
+
}
|
|
20438
|
+
const normalizedOwnerSlug = ownerSlug.toLowerCase();
|
|
20439
|
+
if (normalizedOwnerSlug === PREBUILT_PLAY_NAMESPACE) {
|
|
20440
|
+
return {
|
|
20441
|
+
kind: "prebuilt",
|
|
20442
|
+
reference: buildPrebuiltPlayReference(name),
|
|
20443
|
+
name
|
|
20444
|
+
};
|
|
20445
|
+
}
|
|
20446
|
+
if (normalizedOwnerSlug === SELF_PLAY_NAMESPACE) {
|
|
20447
|
+
return {
|
|
20448
|
+
kind: "self",
|
|
20449
|
+
reference: buildSelfPlayReference(name),
|
|
20450
|
+
name
|
|
20451
|
+
};
|
|
20452
|
+
}
|
|
20453
|
+
return {
|
|
20454
|
+
kind: "org",
|
|
20455
|
+
reference: buildPlayReference(ownerSlug, name),
|
|
20456
|
+
ownerSlug,
|
|
20457
|
+
name
|
|
20458
|
+
};
|
|
20459
|
+
}
|
|
20460
|
+
function resolveOwnedPlayReferenceName(reference, ownerSlug) {
|
|
20461
|
+
const parsed = parsePlayReference(reference);
|
|
20462
|
+
if (parsed.kind === "bare" || parsed.kind === "self") {
|
|
20463
|
+
return parsed.name;
|
|
20464
|
+
}
|
|
20465
|
+
if (parsed.kind !== "org") {
|
|
20466
|
+
return null;
|
|
20467
|
+
}
|
|
20468
|
+
const normalizedOwnerSlug = ownerSlug?.trim().toLowerCase() ?? "";
|
|
20469
|
+
return normalizedOwnerSlug && parsed.ownerSlug.trim().toLowerCase() === normalizedOwnerSlug ? parsed.name : null;
|
|
20470
|
+
}
|
|
20471
|
+
|
|
20472
|
+
// ../plays/deploy/run-deployment.ts
|
|
20473
|
+
var RUN_PLAY_METHOD_NAMES = /* @__PURE__ */ new Set(["runPlay", "runPlayAsync"]);
|
|
20474
|
+
function isRunPlayReceiver(node) {
|
|
20475
|
+
return isAstNode(node) && node.type === "Identifier" && typeof node.name === "string" && (node.name === "ctx" || node.name.endsWith("Ctx"));
|
|
20476
|
+
}
|
|
20477
|
+
function stringLiteralValue(node) {
|
|
20478
|
+
if (!isAstNode(node)) return null;
|
|
20479
|
+
if (node.type === "Literal" && typeof node.value === "string") {
|
|
20480
|
+
return node.value;
|
|
20481
|
+
}
|
|
20482
|
+
if (node.type === "TemplateLiteral" && Array.isArray(node.expressions) && node.expressions.length === 0 && Array.isArray(node.quasis) && node.quasis.length === 1) {
|
|
20483
|
+
const cooked = node.quasis[0].value?.cooked;
|
|
20484
|
+
return typeof cooked === "string" ? cooked : null;
|
|
20485
|
+
}
|
|
20486
|
+
return null;
|
|
20487
|
+
}
|
|
20488
|
+
async function extractRunPlayStringTargets(sourceCode) {
|
|
20489
|
+
const program = parsePlaySourceForAnalysis(sourceCode);
|
|
20490
|
+
if (!program) return await extractWithCompiler(sourceCode) ?? [];
|
|
20491
|
+
const targets = /* @__PURE__ */ new Set();
|
|
20492
|
+
const visit = (node) => {
|
|
20493
|
+
const callee = node.callee;
|
|
20494
|
+
if (node.type === "CallExpression" && isAstNode(callee) && callee.type === "MemberExpression" && callee.computed !== true && isAstNode(callee.property) && RUN_PLAY_METHOD_NAMES.has(String(callee.property.name)) && isRunPlayReceiver(callee.object) && Array.isArray(node.arguments)) {
|
|
20495
|
+
const playRef = stringLiteralValue(node.arguments[1]);
|
|
20496
|
+
const ownedName = playRef === null ? null : resolveOwnedPlayReferenceName(playRef);
|
|
20497
|
+
if (ownedName) targets.add(ownedName);
|
|
20498
|
+
}
|
|
20499
|
+
for (const [key, value] of Object.entries(node)) {
|
|
20500
|
+
if (key === "loc") continue;
|
|
20501
|
+
for (const child of Array.isArray(value) ? value : [value]) {
|
|
20502
|
+
if (isAstNode(child)) visit(child);
|
|
20503
|
+
}
|
|
20504
|
+
}
|
|
20505
|
+
};
|
|
20506
|
+
visit(program);
|
|
20507
|
+
return [...targets];
|
|
20508
|
+
}
|
|
20509
|
+
async function extractWithCompiler(sourceCode) {
|
|
20510
|
+
let ts;
|
|
20511
|
+
try {
|
|
20512
|
+
const loaded = await import("typescript");
|
|
20513
|
+
ts = loaded.default ?? loaded;
|
|
20514
|
+
} catch {
|
|
20515
|
+
return null;
|
|
20516
|
+
}
|
|
20517
|
+
const sourceFile = ts.createSourceFile(
|
|
20518
|
+
"play.ts",
|
|
20519
|
+
sourceCode,
|
|
20520
|
+
ts.ScriptTarget.Latest,
|
|
20521
|
+
true,
|
|
20522
|
+
ts.ScriptKind.TS
|
|
20523
|
+
);
|
|
20524
|
+
const targets = /* @__PURE__ */ new Set();
|
|
20525
|
+
const visit = (node) => {
|
|
20526
|
+
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && RUN_PLAY_METHOD_NAMES.has(node.expression.name.text) && ts.isIdentifier(node.expression.expression) && (node.expression.expression.text === "ctx" || node.expression.expression.text.endsWith("Ctx"))) {
|
|
20527
|
+
const playRefArgument = node.arguments[1];
|
|
20528
|
+
if (playRefArgument && ts.isStringLiteralLike(playRefArgument)) {
|
|
20529
|
+
const ownedName = resolveOwnedPlayReferenceName(playRefArgument.text);
|
|
20530
|
+
if (ownedName) targets.add(ownedName);
|
|
20531
|
+
}
|
|
20532
|
+
}
|
|
20533
|
+
ts.forEachChild(node, visit);
|
|
20534
|
+
};
|
|
20535
|
+
visit(sourceFile);
|
|
20536
|
+
return [...targets];
|
|
20537
|
+
}
|
|
20538
|
+
var RetryableDeploymentError = class extends Error {
|
|
20539
|
+
};
|
|
20540
|
+
var TERMINAL_TOKEN_CODES = /* @__PURE__ */ new Set([
|
|
20541
|
+
"PLAY_DEPLOYMENT_SUPERSEDED",
|
|
20542
|
+
"PLAY_DEPLOYMENT_TERMINAL",
|
|
20543
|
+
"PLAY_PROJECT_DISABLED",
|
|
20544
|
+
"GITHUB_INSTALLATION_INACTIVE"
|
|
20545
|
+
]);
|
|
20546
|
+
function revokedFinalStatus(error) {
|
|
20547
|
+
if (!(error instanceof DeployApiError) || !error.code || !TERMINAL_TOKEN_CODES.has(error.code)) {
|
|
20548
|
+
return null;
|
|
20549
|
+
}
|
|
20550
|
+
return error.code === "PLAY_DEPLOYMENT_SUPERSEDED" ? "superseded" : "cancelled";
|
|
20551
|
+
}
|
|
20552
|
+
function carriesArtifact(revision, artifact) {
|
|
20553
|
+
return Boolean(
|
|
20554
|
+
revision && revision.sourceHash === artifact.sourceHash && revision.artifactHash === artifact.artifactHash && revision.graphHash === artifact.graphHash && revision.artifactKind === artifact.artifactKind
|
|
20555
|
+
);
|
|
20556
|
+
}
|
|
20557
|
+
function annotationForFailure(input2) {
|
|
20558
|
+
return {
|
|
20559
|
+
path: input2.file,
|
|
20560
|
+
start_line: 1,
|
|
20561
|
+
end_line: 1,
|
|
20562
|
+
annotation_level: "failure",
|
|
20563
|
+
message: input2.message.slice(0, 4e3)
|
|
20564
|
+
};
|
|
20565
|
+
}
|
|
20566
|
+
async function runDeployment(params, hooks) {
|
|
20567
|
+
const startedAt = Date.now();
|
|
20568
|
+
const client2 = new DeployApiClient({
|
|
20569
|
+
appBaseUrl: params.appBaseUrl,
|
|
20570
|
+
deployToken: params.deployToken,
|
|
20571
|
+
deploymentId: params.deploymentId,
|
|
20572
|
+
fetchImpl: hooks.fetchImpl
|
|
20573
|
+
});
|
|
20574
|
+
let state;
|
|
20575
|
+
try {
|
|
20576
|
+
state = await client2.getDeployment();
|
|
20577
|
+
} catch (error) {
|
|
20578
|
+
const revoked = revokedFinalStatus(error);
|
|
20579
|
+
if (revoked) {
|
|
20580
|
+
console.info("[deploy-worker] aborting: deployment no longer buildable", {
|
|
20581
|
+
deploymentId: params.deploymentId,
|
|
20582
|
+
code: error.code
|
|
20583
|
+
});
|
|
20584
|
+
return { finalStatus: revoked, outcomes: [] };
|
|
20585
|
+
}
|
|
20586
|
+
if (error instanceof DeployApiError && error.status === 401) {
|
|
20587
|
+
console.error("[deploy-worker] aborting: deploy token rejected", {
|
|
20588
|
+
deploymentId: params.deploymentId,
|
|
20589
|
+
error: error.message.slice(0, 200)
|
|
20590
|
+
});
|
|
20591
|
+
return { finalStatus: "cancelled", outcomes: [] };
|
|
20592
|
+
}
|
|
20593
|
+
throw error;
|
|
20594
|
+
}
|
|
20595
|
+
const { deployment, project } = state;
|
|
20596
|
+
const target = project ?? hooks.target;
|
|
20597
|
+
if (!target) {
|
|
20598
|
+
throw new Error(
|
|
20599
|
+
`Deployment ${params.deploymentId} has no linked repository and no target directory was given.`
|
|
20600
|
+
);
|
|
20601
|
+
}
|
|
20602
|
+
const checkRunName = state.checkRunName?.trim() || void 0;
|
|
20603
|
+
let mergedPullRequestNumber = null;
|
|
20604
|
+
let promoted = false;
|
|
20605
|
+
const setStatus = (input2) => client2.setStatus({
|
|
20606
|
+
...input2,
|
|
20607
|
+
...mergedPullRequestNumber ? { mergedPullRequestNumber } : {}
|
|
20608
|
+
});
|
|
20609
|
+
try {
|
|
20610
|
+
await setStatus({ status: "building" });
|
|
20611
|
+
} catch (error) {
|
|
20612
|
+
if (!(error instanceof DeployApiError && error.code === "PLAY_DEPLOYMENT_INVALID_TRANSITION")) {
|
|
20613
|
+
throw error;
|
|
20614
|
+
}
|
|
20615
|
+
}
|
|
20616
|
+
const buildSeconds = () => Math.max(0, (Date.now() - startedAt) / 1e3);
|
|
20617
|
+
const finishFailed = async (input2) => {
|
|
20618
|
+
try {
|
|
20619
|
+
await setStatus({
|
|
20620
|
+
status: "failed",
|
|
20621
|
+
error: input2.error.slice(0, 2e3),
|
|
20622
|
+
results: { plays: input2.outcomes },
|
|
20623
|
+
buildSeconds: buildSeconds(),
|
|
20624
|
+
...input2.checkRunId ? { checkRunId: input2.checkRunId } : {}
|
|
20625
|
+
});
|
|
20626
|
+
} catch (statusError) {
|
|
20627
|
+
console.error(
|
|
20628
|
+
"[deploy-worker] failed-status write failed; retrying task",
|
|
20629
|
+
{
|
|
20630
|
+
deploymentId: params.deploymentId,
|
|
20631
|
+
error: statusError instanceof Error ? statusError.message : String(statusError)
|
|
20632
|
+
}
|
|
20633
|
+
);
|
|
20634
|
+
throw new Error(
|
|
20635
|
+
`Terminal status write failed for ${params.deploymentId} (original failure: ${input2.error.slice(0, 300)})`
|
|
20636
|
+
);
|
|
20637
|
+
}
|
|
20638
|
+
return {
|
|
20639
|
+
finalStatus: "failed",
|
|
20640
|
+
outcomes: input2.outcomes,
|
|
20641
|
+
checkRunId: input2.checkRunId
|
|
20642
|
+
};
|
|
20643
|
+
};
|
|
20644
|
+
const finishSucceeded = async (outcomes, checkRun) => {
|
|
20645
|
+
const finalStatus = outcomes.some((outcome) => outcome.warning) ? "succeeded_with_warnings" : "succeeded";
|
|
20646
|
+
try {
|
|
20647
|
+
await setStatus({
|
|
20648
|
+
status: finalStatus,
|
|
20649
|
+
results: { plays: outcomes },
|
|
20650
|
+
buildSeconds: buildSeconds(),
|
|
20651
|
+
...checkRun ? { checkRunId: checkRun.checkRunId } : {}
|
|
20652
|
+
});
|
|
20653
|
+
} catch (statusError) {
|
|
20654
|
+
const message = statusError instanceof Error ? statusError.message : String(statusError);
|
|
20655
|
+
console.warn(
|
|
20656
|
+
"[deploy-worker] succeeded-status write failed; retrying task",
|
|
20657
|
+
{ deploymentId: params.deploymentId, error: message.slice(0, 300) }
|
|
20658
|
+
);
|
|
20659
|
+
throw new RetryableDeploymentError(
|
|
20660
|
+
`SUCCEEDED_STATUS_WRITE_FAILED: ${message}`
|
|
20661
|
+
);
|
|
20662
|
+
}
|
|
20663
|
+
return {
|
|
20664
|
+
finalStatus,
|
|
20665
|
+
outcomes,
|
|
20666
|
+
checkRunId: checkRun?.checkRunId
|
|
20667
|
+
};
|
|
20668
|
+
};
|
|
20669
|
+
const workDir = join11(hooks.workRoot, `deploy-${params.deploymentId}`);
|
|
20670
|
+
const postCheck = async (postCheckOnce, input2) => {
|
|
20671
|
+
let lastError;
|
|
20672
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
20673
|
+
try {
|
|
20674
|
+
return await postCheckOnce(input2);
|
|
20675
|
+
} catch (error) {
|
|
20676
|
+
lastError = error;
|
|
20677
|
+
if (attempt >= 2) {
|
|
20678
|
+
throw lastError;
|
|
20679
|
+
}
|
|
20680
|
+
await new Promise(
|
|
20681
|
+
(resolve22) => setTimeout(resolve22, hooks.checkRunRetryDelayMs ?? 1e3)
|
|
20682
|
+
);
|
|
20683
|
+
}
|
|
20684
|
+
}
|
|
20685
|
+
};
|
|
20686
|
+
let postFailureCheck = null;
|
|
20687
|
+
try {
|
|
20688
|
+
const source = await hooks.openSource({ client: client2, deployment });
|
|
20689
|
+
if (deployment.isProduction) {
|
|
20690
|
+
try {
|
|
20691
|
+
mergedPullRequestNumber = await source.findMergedPullRequest?.() ?? null;
|
|
20692
|
+
} catch (error) {
|
|
20693
|
+
console.warn("[deploy-worker] merged PR lookup failed", {
|
|
20694
|
+
deploymentId: params.deploymentId,
|
|
20695
|
+
error: (error instanceof Error ? error.message : String(error)).slice(
|
|
20696
|
+
0,
|
|
20697
|
+
300
|
|
20698
|
+
)
|
|
20699
|
+
});
|
|
20700
|
+
}
|
|
20701
|
+
}
|
|
20702
|
+
const writeCheck = async (input2) => {
|
|
20703
|
+
if (!source.postCheck) return null;
|
|
20704
|
+
try {
|
|
20705
|
+
return await postCheck(source.postCheck, {
|
|
20706
|
+
name: checkRunName,
|
|
20707
|
+
// Idempotency key: a retry after a lost create response updates
|
|
20708
|
+
// the existing run instead of posting a duplicate check.
|
|
20709
|
+
externalId: params.deploymentId,
|
|
20710
|
+
...input2
|
|
20711
|
+
});
|
|
20712
|
+
} catch (error) {
|
|
20713
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
20714
|
+
if (!deployment.isProduction) {
|
|
20715
|
+
throw new RetryableDeploymentError(
|
|
20716
|
+
`GITHUB_CHECK_WRITE_FAILED: could not post the PR Check Run after retries: ${message}`
|
|
20717
|
+
);
|
|
20718
|
+
}
|
|
20719
|
+
console.warn(
|
|
20720
|
+
"[deploy-worker] check write lost; status row is authoritative",
|
|
20721
|
+
{
|
|
20722
|
+
deploymentId: params.deploymentId,
|
|
20723
|
+
error: message.slice(0, 300)
|
|
20724
|
+
}
|
|
20725
|
+
);
|
|
20726
|
+
return null;
|
|
20727
|
+
}
|
|
20728
|
+
};
|
|
20729
|
+
const assertNotRevoked = async () => {
|
|
20730
|
+
try {
|
|
20731
|
+
await client2.getDeployment();
|
|
20732
|
+
} catch (error) {
|
|
20733
|
+
if (revokedFinalStatus(error)) throw error;
|
|
20734
|
+
}
|
|
20735
|
+
};
|
|
20736
|
+
const postCheckOrNull = async (input2) => {
|
|
20737
|
+
if (promoted) return writeCheck(input2);
|
|
20738
|
+
await assertNotRevoked();
|
|
20739
|
+
const checkRun2 = await writeCheck(input2);
|
|
20740
|
+
await assertNotRevoked().catch(async (revocation) => {
|
|
20741
|
+
const stopped = revokedFinalStatus(revocation);
|
|
20742
|
+
await writeCheck({
|
|
20743
|
+
conclusion: "neutral",
|
|
20744
|
+
title: `Deployment ${stopped}`,
|
|
20745
|
+
summary: "This deployment was stopped before it finished. Nothing from it went live."
|
|
20746
|
+
}).catch(() => void 0);
|
|
20747
|
+
throw revocation;
|
|
20748
|
+
});
|
|
20749
|
+
return checkRun2;
|
|
20750
|
+
};
|
|
20751
|
+
const failWithCheck = async (input2) => {
|
|
20752
|
+
const checkRun2 = await postCheckOrNull({
|
|
20753
|
+
conclusion: "failure",
|
|
20754
|
+
title: input2.title,
|
|
20755
|
+
summary: input2.summary,
|
|
20756
|
+
...input2.annotations ? { annotations: input2.annotations } : {}
|
|
20757
|
+
});
|
|
20758
|
+
return finishFailed({
|
|
20759
|
+
error: input2.error,
|
|
20760
|
+
outcomes: input2.outcomes,
|
|
20761
|
+
checkRunId: checkRun2?.checkRunId
|
|
20762
|
+
});
|
|
20763
|
+
};
|
|
20764
|
+
postFailureCheck = async (summary) => (await postCheckOrNull({
|
|
20765
|
+
conclusion: "failure",
|
|
20766
|
+
title: "Deploy failed",
|
|
20767
|
+
summary
|
|
20768
|
+
}))?.checkRunId;
|
|
20769
|
+
const deploymentBranch = deployment.ref?.startsWith("refs/heads/") ? deployment.ref.slice("refs/heads/".length) : project?.productionBranch ?? null;
|
|
20770
|
+
const supersedeIfHeadMoved = async () => {
|
|
20771
|
+
if (!deployment.isProduction || !source.branchHead || !deploymentBranch) {
|
|
20772
|
+
return null;
|
|
20773
|
+
}
|
|
20774
|
+
const head = await source.branchHead(deploymentBranch);
|
|
20775
|
+
if (head === deployment.commitSha) return null;
|
|
20776
|
+
console.info("[deploy-worker] superseding: branch head moved", {
|
|
20777
|
+
deploymentId: params.deploymentId,
|
|
20778
|
+
commitSha: deployment.commitSha,
|
|
20779
|
+
head: head ?? "<branch deleted>"
|
|
20780
|
+
});
|
|
20781
|
+
await setStatus({
|
|
20782
|
+
status: "superseded",
|
|
20783
|
+
error: `Branch ${deploymentBranch} is now at ${head?.slice(0, 12) ?? "<deleted>"}; this deployment's commit is no longer the head.`,
|
|
20784
|
+
buildSeconds: buildSeconds(),
|
|
20785
|
+
...head ? { observedHeadSha: head } : {}
|
|
20786
|
+
});
|
|
20787
|
+
return { finalStatus: "superseded", outcomes: [] };
|
|
20788
|
+
};
|
|
20789
|
+
{
|
|
20790
|
+
const superseded = await supersedeIfHeadMoved();
|
|
20791
|
+
if (superseded) return superseded;
|
|
20792
|
+
}
|
|
20793
|
+
const { repoRoot } = await source.open(workDir);
|
|
20794
|
+
const projectRoot = target.rootDirectory ? join11(repoRoot, target.rootDirectory) : repoRoot;
|
|
20795
|
+
const manifestFile = target.manifestPath || DEFAULT_MANIFEST_FILE;
|
|
20796
|
+
let manifest;
|
|
20797
|
+
let playFiles;
|
|
20798
|
+
try {
|
|
20799
|
+
manifest = await readDeeplineManifest(projectRoot, manifestFile);
|
|
20800
|
+
playFiles = await discoverPlayFiles({
|
|
20801
|
+
projectRoot,
|
|
20802
|
+
globs: manifest.plays
|
|
20803
|
+
});
|
|
20804
|
+
} catch (error) {
|
|
20805
|
+
if (error instanceof DeeplineManifestError) {
|
|
20806
|
+
return await failWithCheck({
|
|
20807
|
+
title: `${manifestFile} is invalid`,
|
|
20808
|
+
summary: error.message,
|
|
20809
|
+
error: error.message,
|
|
20810
|
+
outcomes: []
|
|
20811
|
+
});
|
|
20812
|
+
}
|
|
20813
|
+
throw error;
|
|
20814
|
+
}
|
|
20815
|
+
if (manifest.org) {
|
|
20816
|
+
const expected = manifest.org.trim().toLowerCase();
|
|
20817
|
+
const actual = (state.workspaceSlug ?? "").trim().toLowerCase();
|
|
20818
|
+
if (expected !== actual) {
|
|
20819
|
+
const message = `DEEPLINE_MANIFEST_ORG_MISMATCH: ${manifestFile} declares org "${manifest.org}", but this deployment targets workspace "${state.workspaceSlug ?? "<unknown>"}". Fix the manifest or unbind the repo from this workspace.`;
|
|
20820
|
+
return await failWithCheck({
|
|
20821
|
+
title: "Workspace guard rejected this deployment",
|
|
20822
|
+
summary: message,
|
|
20823
|
+
error: message,
|
|
20824
|
+
outcomes: []
|
|
20825
|
+
});
|
|
20826
|
+
}
|
|
20827
|
+
}
|
|
20828
|
+
if (playFiles.length === 0) {
|
|
20829
|
+
const checkRun2 = await postCheckOrNull({
|
|
20830
|
+
conclusion: "neutral",
|
|
20831
|
+
title: "No plays matched",
|
|
20832
|
+
summary: `No files matched ${manifest.plays.join(", ")} under ${target.rootDirectory || "the deployed directory"}.`
|
|
20833
|
+
});
|
|
20834
|
+
return await finishSucceeded([], checkRun2);
|
|
20835
|
+
}
|
|
20836
|
+
if (playFiles.length > 100) {
|
|
20837
|
+
const message = `PLAY_DEPLOY_BATCH_TOO_LARGE: this deployment contains ${playFiles.length} plays (max 100). Split the repo into multiple projects.`;
|
|
20838
|
+
return await failWithCheck({
|
|
20839
|
+
title: "Too many plays in one deployment",
|
|
20840
|
+
summary: message,
|
|
20841
|
+
error: message,
|
|
20842
|
+
outcomes: []
|
|
20843
|
+
});
|
|
20844
|
+
}
|
|
20845
|
+
const bundled = [];
|
|
20846
|
+
const failures = [];
|
|
20847
|
+
const annotations = [];
|
|
20848
|
+
const seenNames = /* @__PURE__ */ new Map();
|
|
20849
|
+
const repoRelative = (file) => target.rootDirectory ? `${target.rootDirectory}/${file}` : file;
|
|
20850
|
+
const failPlay = (name, file, message) => {
|
|
20851
|
+
failures.push({ name, file, status: "failed", error: message });
|
|
20852
|
+
annotations.push(annotationForFailure({ file, message }));
|
|
20853
|
+
};
|
|
20854
|
+
for (const file of playFiles) {
|
|
20855
|
+
const entryFile = join11(projectRoot, file);
|
|
20856
|
+
const result = await hooks.bundle(entryFile, {
|
|
20857
|
+
sourceIdentityRoot: projectRoot
|
|
20858
|
+
});
|
|
20859
|
+
const repoRelativeFile = repoRelative(file);
|
|
20860
|
+
if (!result.success) {
|
|
20861
|
+
const message = result.errors.join("\n").split(`${projectRoot}/`).join(target.rootDirectory ? `${target.rootDirectory}/` : "").split(`${repoRoot}/`).join("") || "Bundle failed.";
|
|
20862
|
+
failPlay(file, repoRelativeFile, message);
|
|
20863
|
+
continue;
|
|
20864
|
+
}
|
|
20865
|
+
const name = result.playName?.trim() ?? "";
|
|
20866
|
+
if (!name) {
|
|
20867
|
+
failPlay(
|
|
20868
|
+
file,
|
|
20869
|
+
repoRelativeFile,
|
|
20870
|
+
`${file} does not export a definePlay(...) play with a name.`
|
|
20871
|
+
);
|
|
20872
|
+
continue;
|
|
20873
|
+
}
|
|
20874
|
+
const duplicateOf = seenNames.get(name);
|
|
20875
|
+
if (duplicateOf) {
|
|
20876
|
+
failPlay(
|
|
20877
|
+
name,
|
|
20878
|
+
repoRelativeFile,
|
|
20879
|
+
`The play name "${name}" is declared by more than one file: ${repoRelative(duplicateOf)} and ${repoRelativeFile}. A play name must be unique across the repository. Rename one of them or delete it.`
|
|
20880
|
+
);
|
|
20881
|
+
continue;
|
|
20882
|
+
}
|
|
20883
|
+
seenNames.set(name, file);
|
|
20884
|
+
const disallowed = (result.artifact.importPolicy?.packages ?? []).map(
|
|
20885
|
+
(pkg) => typeof pkg === "string" ? pkg : pkg.name ?? ""
|
|
20886
|
+
).filter((pkgName) => pkgName && pkgName !== "deepline");
|
|
20887
|
+
if (disallowed.length > 0) {
|
|
20888
|
+
failPlay(
|
|
20889
|
+
name,
|
|
20890
|
+
repoRelativeFile,
|
|
20891
|
+
`PLAY_DEPLOY_DEPENDENCY_NOT_ALLOWED: ${file} imports npm package(s) ${disallowed.join(", ")}. Deploy-on-push builds support only the deepline SDK and node builtins.`
|
|
20892
|
+
);
|
|
20893
|
+
continue;
|
|
20894
|
+
}
|
|
20895
|
+
bundled.push({
|
|
20896
|
+
file: repoRelativeFile,
|
|
20897
|
+
name,
|
|
20898
|
+
result,
|
|
20899
|
+
runPlayStringTargets: await extractRunPlayStringTargets(
|
|
20900
|
+
result.sourceCode
|
|
20901
|
+
)
|
|
20902
|
+
});
|
|
20903
|
+
}
|
|
20904
|
+
if (failures.length > 0) {
|
|
20905
|
+
return await failWithCheck({
|
|
20906
|
+
title: `${failures.length} play${failures.length === 1 ? "" : "s"} failed to build`,
|
|
20907
|
+
summary: failures.map((failure) => `- \`${failure.file}\`: ${failure.error}`).join("\n"),
|
|
20908
|
+
annotations,
|
|
20909
|
+
error: `Build failed for ${failures.length} play file(s).`,
|
|
20910
|
+
outcomes: failures
|
|
20911
|
+
});
|
|
20912
|
+
}
|
|
20913
|
+
const manifestByName = /* @__PURE__ */ new Map();
|
|
20914
|
+
const ordered = topoSortByPlayDependencies(bundled);
|
|
20915
|
+
const validationFailures = [];
|
|
20916
|
+
for (const play of ordered) {
|
|
20917
|
+
const dependencyNames = /* @__PURE__ */ new Set([
|
|
20918
|
+
...(play.result.importedPlayDependencies ?? []).map(
|
|
20919
|
+
(dependency) => dependency.playName
|
|
20920
|
+
),
|
|
20921
|
+
...play.runPlayStringTargets
|
|
20922
|
+
]);
|
|
20923
|
+
const dependencies = [...dependencyNames].map((dependencyName) => manifestByName.get(dependencyName)).filter((entry) => Boolean(entry));
|
|
20924
|
+
try {
|
|
20925
|
+
const compiled = await client2.compileManifest({
|
|
20926
|
+
name: play.name,
|
|
20927
|
+
sourceCode: play.result.sourceCode,
|
|
20928
|
+
sourceFiles: play.result.sourceFiles,
|
|
20929
|
+
artifact: play.result.artifact,
|
|
20930
|
+
...dependencies.length ? { importedPlayDependencies: dependencies } : {}
|
|
20931
|
+
});
|
|
20932
|
+
manifestByName.set(play.name, compiled.compilerManifest);
|
|
20933
|
+
} catch (error) {
|
|
20934
|
+
if (revokedFinalStatus(error)) throw error;
|
|
20935
|
+
const body = error instanceof DeployApiError ? error.body : null;
|
|
20936
|
+
const messages = body && Array.isArray(body.errors) ? body.errors.map(String) : [error instanceof Error ? error.message : String(error)];
|
|
20937
|
+
const message = messages.join("\n");
|
|
20938
|
+
validationFailures.push({
|
|
20939
|
+
name: play.name,
|
|
20940
|
+
file: play.file,
|
|
20941
|
+
status: "failed",
|
|
20942
|
+
error: message
|
|
20943
|
+
});
|
|
20944
|
+
annotations.push(annotationForFailure({ file: play.file, message }));
|
|
20945
|
+
}
|
|
20946
|
+
}
|
|
20947
|
+
if (validationFailures.length > 0) {
|
|
20948
|
+
return await failWithCheck({
|
|
20949
|
+
title: `${validationFailures.length} play${validationFailures.length === 1 ? "" : "s"} failed validation`,
|
|
20950
|
+
summary: validationFailures.map((failure) => `- \`${failure.name}\`: ${failure.error}`).join("\n"),
|
|
20951
|
+
annotations,
|
|
20952
|
+
error: `Validation failed for ${validationFailures.length} play(s).`,
|
|
20953
|
+
outcomes: validationFailures
|
|
20954
|
+
});
|
|
20955
|
+
}
|
|
20956
|
+
{
|
|
20957
|
+
const superseded = await supersedeIfHeadMoved();
|
|
20958
|
+
if (superseded) return superseded;
|
|
20959
|
+
}
|
|
20960
|
+
await setStatus({ status: "publishing" }).catch(() => void 0);
|
|
20961
|
+
const states = await client2.playsState(ordered.map((play) => play.name));
|
|
20962
|
+
const stateByName = new Map(
|
|
20963
|
+
states.plays.map((play) => [play.name, play])
|
|
20964
|
+
);
|
|
20965
|
+
const conflicts = [];
|
|
20966
|
+
for (const play of ordered) {
|
|
20967
|
+
const owner = stateByName.get(play.name);
|
|
20968
|
+
if (!project || !owner?.playProjectRepo || owner.playProjectRepo === project?.repoFullName || owner.playProjectDisabled) {
|
|
20969
|
+
continue;
|
|
20970
|
+
}
|
|
20971
|
+
const message = `The play name "${play.name}" is already deployed from ${owner.playProjectRepo}. A play name belongs to one repository at a time. Rename it here, or disable that deployment target first.`;
|
|
20972
|
+
conflicts.push({
|
|
20973
|
+
name: play.name,
|
|
20974
|
+
file: play.file,
|
|
20975
|
+
status: "failed",
|
|
20976
|
+
error: message
|
|
20977
|
+
});
|
|
20978
|
+
annotations.push(annotationForFailure({ file: play.file, message }));
|
|
20979
|
+
}
|
|
20980
|
+
if (conflicts.length > 0) {
|
|
20981
|
+
return await failWithCheck({
|
|
20982
|
+
title: `${conflicts.length} play name${conflicts.length === 1 ? "" : "s"} owned by another repository`,
|
|
20983
|
+
summary: conflicts.map((conflict) => `- \`${conflict.file}\`: ${conflict.error}`).join("\n"),
|
|
20984
|
+
annotations,
|
|
20985
|
+
error: `${conflicts.length} play name(s) are deployed from another repository.`,
|
|
20986
|
+
outcomes: conflicts
|
|
20987
|
+
});
|
|
20988
|
+
}
|
|
20989
|
+
const playByName = new Map(ordered.map((play) => [play.name, play]));
|
|
20990
|
+
const outcomes = [];
|
|
20991
|
+
const toRegister = [];
|
|
20992
|
+
const toPromote = [];
|
|
20993
|
+
const takeoverWarning = (state2) => {
|
|
20994
|
+
const owner = state2?.playProjectRepo;
|
|
20995
|
+
if (!owner || owner === project?.repoFullName) return void 0;
|
|
20996
|
+
if (!project) {
|
|
20997
|
+
return `This play is deployed from ${owner}. This directory deploy made a different revision live, so it is marked drifted from ${owner} until that repository deploys again.`;
|
|
20998
|
+
}
|
|
20999
|
+
return `This play was deployed from ${owner} and now deploys from ${project.repoFullName}. Taking it over was allowed because the old deployment target is disabled; re-enabling that target will not give the play back \u2014 its deploys will fail on this name instead.`;
|
|
21000
|
+
};
|
|
21001
|
+
for (const play of ordered) {
|
|
21002
|
+
const playState = stateByName.get(play.name);
|
|
21003
|
+
const warning = project ? takeoverWarning(playState) : void 0;
|
|
21004
|
+
const artifact = play.result.artifact;
|
|
21005
|
+
const importsOtherPlays = (play.result.importedPlayDependencies ?? []).length > 0;
|
|
21006
|
+
const matches = (revision) => !importsOtherPlays && carriesArtifact(revision, artifact);
|
|
21007
|
+
if (matches(playState?.liveRevision ?? null)) {
|
|
21008
|
+
if (deployment.isProduction && project && (playState?.playProjectId !== project.id || playState?.driftFromGit)) {
|
|
21009
|
+
toPromote.push({
|
|
21010
|
+
name: play.name,
|
|
21011
|
+
revisionId: playState.liveRevision.revisionId
|
|
21012
|
+
});
|
|
21013
|
+
continue;
|
|
21014
|
+
}
|
|
21015
|
+
outcomes.push({
|
|
21016
|
+
name: play.name,
|
|
21017
|
+
file: play.file,
|
|
21018
|
+
status: "unchanged",
|
|
21019
|
+
version: playState?.liveRevision?.version ?? void 0,
|
|
21020
|
+
...warning ? { warning } : {}
|
|
21021
|
+
});
|
|
21022
|
+
continue;
|
|
21023
|
+
}
|
|
21024
|
+
if (matches(playState?.workingRevision ?? null)) {
|
|
21025
|
+
if (deployment.isProduction) {
|
|
21026
|
+
toPromote.push({
|
|
21027
|
+
name: play.name,
|
|
21028
|
+
revisionId: playState.workingRevision.revisionId
|
|
21029
|
+
});
|
|
21030
|
+
} else {
|
|
21031
|
+
outcomes.push({
|
|
21032
|
+
name: play.name,
|
|
21033
|
+
file: play.file,
|
|
21034
|
+
status: "registered",
|
|
21035
|
+
version: playState?.workingRevision?.version ?? void 0,
|
|
21036
|
+
...warning ? { warning } : {}
|
|
21037
|
+
});
|
|
21038
|
+
}
|
|
21039
|
+
continue;
|
|
21040
|
+
}
|
|
21041
|
+
toRegister.push({
|
|
21042
|
+
play,
|
|
21043
|
+
entry: {
|
|
21044
|
+
name: play.name,
|
|
21045
|
+
sourceCode: play.result.sourceCode,
|
|
21046
|
+
sourceFiles: play.result.sourceFiles,
|
|
21047
|
+
...play.result.playDescription ? { description: play.result.playDescription } : {},
|
|
21048
|
+
artifact: play.result.artifact,
|
|
21049
|
+
compilerManifest: manifestByName.get(play.name),
|
|
21050
|
+
sourceFilePath: play.file
|
|
21051
|
+
}
|
|
21052
|
+
});
|
|
21053
|
+
}
|
|
21054
|
+
if (toRegister.length > 0) {
|
|
21055
|
+
const registered = await client2.registerArtifacts(
|
|
21056
|
+
toRegister.map((item) => item.entry)
|
|
21057
|
+
);
|
|
21058
|
+
registered.forEach((artifact, index) => {
|
|
21059
|
+
const item = toRegister[index];
|
|
21060
|
+
if (!artifact.revisionId) {
|
|
21061
|
+
throw new Error(
|
|
21062
|
+
`Registration returned no revision id for ${item.play.name}.`
|
|
21063
|
+
);
|
|
21064
|
+
}
|
|
21065
|
+
if (deployment.isProduction) {
|
|
21066
|
+
toPromote.push({
|
|
21067
|
+
name: item.play.name,
|
|
21068
|
+
revisionId: String(artifact.revisionId)
|
|
21069
|
+
});
|
|
21070
|
+
} else {
|
|
21071
|
+
const warning = takeoverWarning(stateByName.get(item.play.name));
|
|
21072
|
+
outcomes.push({
|
|
21073
|
+
name: item.play.name,
|
|
21074
|
+
file: item.play.file,
|
|
21075
|
+
status: "registered",
|
|
21076
|
+
version: typeof artifact.version === "number" ? artifact.version : void 0,
|
|
21077
|
+
...warning ? { warning } : {}
|
|
21078
|
+
});
|
|
21079
|
+
}
|
|
21080
|
+
});
|
|
21081
|
+
}
|
|
21082
|
+
if (!deployment.isProduction) {
|
|
21083
|
+
const registeredCount = outcomes.filter(
|
|
21084
|
+
(outcome) => outcome.status === "registered"
|
|
21085
|
+
).length;
|
|
21086
|
+
const checkRun2 = await postCheckOrNull({
|
|
21087
|
+
conclusion: "success",
|
|
21088
|
+
title: `${ordered.length} play${ordered.length === 1 ? "" : "s"} validated and registered (not deployed)`,
|
|
21089
|
+
...annotations.length > 0 ? { annotations } : {},
|
|
21090
|
+
summary: outcomes.map(
|
|
21091
|
+
(outcome) => `- \`${outcome.name}\`: ${outcome.status}${outcome.version !== void 0 ? ` (v${outcome.version})` : ""}${outcome.warning ? `
|
|
21092
|
+
- :warning: ${outcome.warning}` : ""}`
|
|
21093
|
+
).join("\n")
|
|
21094
|
+
});
|
|
21095
|
+
const result = await finishSucceeded(outcomes, checkRun2);
|
|
21096
|
+
console.info("[deploy-worker] PR registration complete", {
|
|
21097
|
+
deploymentId: params.deploymentId,
|
|
21098
|
+
registered: registeredCount,
|
|
21099
|
+
unchanged: outcomes.filter((o) => o.status === "unchanged").length
|
|
21100
|
+
});
|
|
21101
|
+
return result;
|
|
21102
|
+
}
|
|
21103
|
+
{
|
|
21104
|
+
const superseded = await supersedeIfHeadMoved();
|
|
21105
|
+
if (superseded) return superseded;
|
|
21106
|
+
}
|
|
21107
|
+
if (toPromote.length > 0) {
|
|
21108
|
+
try {
|
|
21109
|
+
const promotion = await client2.promote(toPromote);
|
|
21110
|
+
promoted = true;
|
|
21111
|
+
for (const outcome of promotion.outcomes) {
|
|
21112
|
+
const previousVersion = stateByName.get(outcome.name)?.liveRevision?.version ?? null;
|
|
21113
|
+
const warning = takeoverWarning(stateByName.get(outcome.name));
|
|
21114
|
+
outcomes.push({
|
|
21115
|
+
name: outcome.name,
|
|
21116
|
+
file: playByName.get(outcome.name)?.file ?? outcome.name,
|
|
21117
|
+
status: outcome.status === "promoted" ? "promoted" : "failed",
|
|
21118
|
+
version: outcome.version,
|
|
21119
|
+
...outcome.status === "promoted" && typeof previousVersion === "number" && previousVersion !== outcome.version ? { previousVersion } : {},
|
|
21120
|
+
...outcome.status === "promoted" && warning ? { warning } : {},
|
|
21121
|
+
...outcome.error ? { error: outcome.error } : {}
|
|
21122
|
+
});
|
|
21123
|
+
}
|
|
21124
|
+
} catch (error) {
|
|
21125
|
+
if (revokedFinalStatus(error)) throw error;
|
|
21126
|
+
const body = error instanceof DeployApiError ? error.body : null;
|
|
21127
|
+
const errorText2 = body?.error ?? (error instanceof Error ? error.message : String(error));
|
|
21128
|
+
if (/PLAY_DEPLOYMENT_NOT_ACTIVE/.test(errorText2)) {
|
|
21129
|
+
console.info("[deploy-worker] cancelled at promote", {
|
|
21130
|
+
deploymentId: params.deploymentId
|
|
21131
|
+
});
|
|
21132
|
+
return { finalStatus: "cancelled", outcomes: [] };
|
|
21133
|
+
}
|
|
21134
|
+
if (/PLAY_DEPLOYMENT_STALE/.test(errorText2)) {
|
|
21135
|
+
console.info("[deploy-worker] superseded at promote", {
|
|
21136
|
+
deploymentId: params.deploymentId
|
|
21137
|
+
});
|
|
21138
|
+
await setStatus({
|
|
21139
|
+
status: "superseded",
|
|
21140
|
+
error: errorText2.slice(0, 2e3),
|
|
21141
|
+
buildSeconds: buildSeconds()
|
|
21142
|
+
});
|
|
21143
|
+
return { finalStatus: "superseded", outcomes: [] };
|
|
21144
|
+
}
|
|
21145
|
+
return await failWithCheck({
|
|
21146
|
+
title: "Deploy failed during promotion",
|
|
21147
|
+
summary: errorText2,
|
|
21148
|
+
error: errorText2,
|
|
21149
|
+
outcomes: [
|
|
21150
|
+
...outcomes,
|
|
21151
|
+
...(body?.outcomes ?? toPromote).map((entry) => ({
|
|
21152
|
+
name: entry.name,
|
|
21153
|
+
file: playByName.get(entry.name)?.file ?? entry.name,
|
|
21154
|
+
status: "failed",
|
|
21155
|
+
error: ("error" in entry ? entry.error : void 0) ?? errorText2
|
|
21156
|
+
}))
|
|
21157
|
+
]
|
|
21158
|
+
});
|
|
21159
|
+
}
|
|
21160
|
+
}
|
|
21161
|
+
const checkRun = await postCheckOrNull({
|
|
21162
|
+
conclusion: "success",
|
|
21163
|
+
title: `Deployed ${outcomes.filter((o) => o.status === "promoted").length} play(s) (${outcomes.filter((o) => o.status === "unchanged").length} unchanged)`,
|
|
21164
|
+
...annotations.length > 0 ? { annotations } : {},
|
|
21165
|
+
summary: outcomes.map(
|
|
21166
|
+
(outcome) => `- \`${outcome.name}\`: ${outcome.status}${outcome.warning ? `
|
|
21167
|
+
- :warning: ${outcome.warning}` : ""}`
|
|
21168
|
+
).join("\n")
|
|
21169
|
+
});
|
|
21170
|
+
return await finishSucceeded(outcomes, checkRun);
|
|
21171
|
+
} catch (error) {
|
|
21172
|
+
const revoked = revokedFinalStatus(error);
|
|
21173
|
+
if (revoked) {
|
|
21174
|
+
console.info("[deploy-worker] aborting: deployment revoked mid-build", {
|
|
21175
|
+
deploymentId: params.deploymentId,
|
|
21176
|
+
code: error.code
|
|
21177
|
+
});
|
|
21178
|
+
return { finalStatus: revoked, outcomes: [] };
|
|
21179
|
+
}
|
|
21180
|
+
if (error instanceof RetryableDeploymentError) {
|
|
21181
|
+
console.warn("[deploy-worker] retryable failure, leaving non-terminal", {
|
|
21182
|
+
deploymentId: params.deploymentId,
|
|
21183
|
+
error: error.message.slice(0, 300)
|
|
21184
|
+
});
|
|
21185
|
+
throw error;
|
|
21186
|
+
}
|
|
21187
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
21188
|
+
console.error("[deploy-worker] deployment crashed", {
|
|
21189
|
+
deploymentId: params.deploymentId,
|
|
21190
|
+
error: message.slice(0, 500)
|
|
21191
|
+
});
|
|
21192
|
+
let checkRunId;
|
|
21193
|
+
try {
|
|
21194
|
+
checkRunId = await postFailureCheck?.(message.slice(0, 2e3));
|
|
21195
|
+
} catch (checkError) {
|
|
21196
|
+
const revokedAtCheck = revokedFinalStatus(checkError);
|
|
21197
|
+
if (revokedAtCheck) {
|
|
21198
|
+
return { finalStatus: revokedAtCheck, outcomes: [] };
|
|
21199
|
+
}
|
|
21200
|
+
if (checkError instanceof RetryableDeploymentError) {
|
|
21201
|
+
console.warn(
|
|
21202
|
+
"[deploy-worker] retryable failure, leaving non-terminal",
|
|
21203
|
+
{
|
|
21204
|
+
deploymentId: params.deploymentId,
|
|
21205
|
+
error: checkError.message.slice(0, 300)
|
|
21206
|
+
}
|
|
21207
|
+
);
|
|
21208
|
+
throw checkError;
|
|
21209
|
+
}
|
|
21210
|
+
}
|
|
21211
|
+
await setStatus({
|
|
21212
|
+
status: "failed",
|
|
21213
|
+
error: message.slice(0, 2e3),
|
|
21214
|
+
buildSeconds: buildSeconds(),
|
|
21215
|
+
...checkRunId ? { checkRunId } : {}
|
|
21216
|
+
}).catch(() => void 0);
|
|
21217
|
+
throw error;
|
|
21218
|
+
} finally {
|
|
21219
|
+
await rm(workDir, { recursive: true, force: true }).catch(() => void 0);
|
|
21220
|
+
}
|
|
21221
|
+
}
|
|
21222
|
+
function topoSortByPlayDependencies(plays) {
|
|
21223
|
+
const byName = new Map(plays.map((play) => [play.name, play]));
|
|
21224
|
+
const visited = /* @__PURE__ */ new Set();
|
|
21225
|
+
const ordered = [];
|
|
21226
|
+
const visit = (play, stack) => {
|
|
21227
|
+
if (visited.has(play.name)) return;
|
|
21228
|
+
if (stack.has(play.name)) {
|
|
21229
|
+
return;
|
|
21230
|
+
}
|
|
21231
|
+
stack.add(play.name);
|
|
21232
|
+
const dependencyNames = /* @__PURE__ */ new Set([
|
|
21233
|
+
...(play.result.importedPlayDependencies ?? []).map(
|
|
21234
|
+
(dependency) => dependency.playName
|
|
21235
|
+
),
|
|
21236
|
+
...play.runPlayStringTargets
|
|
21237
|
+
]);
|
|
21238
|
+
for (const dependencyName of dependencyNames) {
|
|
21239
|
+
const target = byName.get(dependencyName);
|
|
21240
|
+
if (target) visit(target, stack);
|
|
21241
|
+
}
|
|
21242
|
+
stack.delete(play.name);
|
|
21243
|
+
visited.add(play.name);
|
|
21244
|
+
ordered.push(play);
|
|
21245
|
+
};
|
|
21246
|
+
for (const play of plays) visit(play, /* @__PURE__ */ new Set());
|
|
21247
|
+
return ordered;
|
|
21248
|
+
}
|
|
21249
|
+
|
|
21250
|
+
// src/cli/commands/plays-deploy.ts
|
|
21251
|
+
var MAX_DEPLOY_ATTEMPTS = 3;
|
|
21252
|
+
function renderOutcome(outcome) {
|
|
21253
|
+
const version = outcome.version === void 0 ? "" : outcome.previousVersion === void 0 ? ` v${outcome.version}` : ` v${outcome.previousVersion} -> v${outcome.version}`;
|
|
21254
|
+
const note = outcome.error ?? outcome.warning;
|
|
21255
|
+
return `${outcome.name} (${outcome.file}): ${outcome.status}${version}${note ? ` - ${note}` : ""}`;
|
|
21256
|
+
}
|
|
21257
|
+
function printResult(input2) {
|
|
21258
|
+
const failed = input2.status === "failed" || input2.status === "cancelled";
|
|
21259
|
+
if (failed) process.exitCode = 1;
|
|
21260
|
+
printCommandEnvelope(
|
|
21261
|
+
{
|
|
21262
|
+
deployment: { ...input2.deployment, status: input2.status },
|
|
21263
|
+
plays: input2.outcomes,
|
|
21264
|
+
render: {
|
|
21265
|
+
sections: [
|
|
21266
|
+
{
|
|
21267
|
+
title: `deployment ${input2.deployment.id}`,
|
|
21268
|
+
lines: [
|
|
21269
|
+
`${input2.directory}: ${input2.status}`,
|
|
21270
|
+
...input2.outcomes.map(renderOutcome),
|
|
21271
|
+
...failed && input2.deployment.error ? [input2.deployment.error] : []
|
|
21272
|
+
]
|
|
21273
|
+
}
|
|
21274
|
+
]
|
|
21275
|
+
}
|
|
21276
|
+
},
|
|
21277
|
+
{ json: input2.json }
|
|
21278
|
+
);
|
|
21279
|
+
}
|
|
21280
|
+
async function handlePlaysDeploy(directory, options) {
|
|
21281
|
+
const root = await realpath3(resolve11(directory ?? ".")).catch(() => {
|
|
21282
|
+
throw new Error(`No such directory: ${resolve11(directory ?? ".")}`);
|
|
21283
|
+
});
|
|
21284
|
+
const { http, config } = getAuthedHttpClient();
|
|
21285
|
+
const deliveryId = `local:${randomUUID3()}`;
|
|
21286
|
+
const startDeployment = () => http.post("/api/v2/deployments", {
|
|
21287
|
+
deliveryId,
|
|
21288
|
+
...options.repo ? { repo: options.repo } : {},
|
|
21289
|
+
...options.ref ? { ref: options.ref } : {},
|
|
21290
|
+
...options.commit ? { commit: options.commit } : {}
|
|
21291
|
+
});
|
|
21292
|
+
const { bundleDeployPlayFile } = await loadPlayBundler();
|
|
21293
|
+
const workRoot = await mkdtemp(join12(tmpdir4(), "deepline-deploy-"));
|
|
21294
|
+
const consoleInfo = console.info;
|
|
21295
|
+
console.info = console.error;
|
|
21296
|
+
try {
|
|
21297
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
21298
|
+
const { deployment } = await startDeployment();
|
|
21299
|
+
let result;
|
|
21300
|
+
try {
|
|
21301
|
+
result = await runDeployment(
|
|
21302
|
+
{
|
|
21303
|
+
deploymentId: deployment.id,
|
|
21304
|
+
// The workspace key drives its own deployment; there is no
|
|
21305
|
+
// separate deploy token to mint.
|
|
21306
|
+
deployToken: config.apiKey,
|
|
21307
|
+
appBaseUrl: config.baseUrl
|
|
21308
|
+
},
|
|
21309
|
+
{
|
|
21310
|
+
bundle: bundleDeployPlayFile,
|
|
21311
|
+
// The plays are already here: "opening" the source is naming it.
|
|
21312
|
+
openSource: async () => ({
|
|
21313
|
+
open: async () => ({ repoRoot: root })
|
|
21314
|
+
}),
|
|
21315
|
+
target: {
|
|
21316
|
+
rootDirectory: "",
|
|
21317
|
+
manifestPath: options.manifest?.trim() ?? ""
|
|
21318
|
+
},
|
|
21319
|
+
workRoot
|
|
21320
|
+
}
|
|
21321
|
+
);
|
|
21322
|
+
} catch (error) {
|
|
21323
|
+
if (error instanceof RetryableDeploymentError && attempt < MAX_DEPLOY_ATTEMPTS) {
|
|
21324
|
+
process.stderr.write(
|
|
21325
|
+
`Deployment ${deployment.id} did not finish (${error.message}); retrying (${attempt + 1}/${MAX_DEPLOY_ATTEMPTS}).
|
|
21326
|
+
`
|
|
21327
|
+
);
|
|
21328
|
+
continue;
|
|
21329
|
+
}
|
|
21330
|
+
throw error;
|
|
21331
|
+
}
|
|
21332
|
+
const finished = await http.get(
|
|
21333
|
+
`/api/v2/deployments/${encodeURIComponent(deployment.id)}`
|
|
21334
|
+
).then((payload) => payload.deployment).catch(() => deployment);
|
|
21335
|
+
printResult({
|
|
21336
|
+
directory: root,
|
|
21337
|
+
deployment: finished,
|
|
21338
|
+
status: result.finalStatus,
|
|
21339
|
+
outcomes: result.outcomes,
|
|
21340
|
+
json: options.json
|
|
21341
|
+
});
|
|
21342
|
+
return;
|
|
21343
|
+
}
|
|
21344
|
+
} finally {
|
|
21345
|
+
console.info = consoleInfo;
|
|
21346
|
+
await rm2(workRoot, { recursive: true, force: true });
|
|
21347
|
+
}
|
|
21348
|
+
}
|
|
21349
|
+
|
|
18361
21350
|
// src/cli/commands/play.ts
|
|
18362
21351
|
var PLAY_BUNDLER_MODULE_PATHS = [
|
|
18363
21352
|
// Built CLI bundle: dist/cli/index.mjs -> dist/plays/bundle-play-file.mjs.
|
|
@@ -18454,9 +21443,9 @@ async function pathExistsIncludingSymlink(path) {
|
|
|
18454
21443
|
}
|
|
18455
21444
|
}
|
|
18456
21445
|
function runIdFileTempPath(destination) {
|
|
18457
|
-
return
|
|
21446
|
+
return join13(
|
|
18458
21447
|
dirname10(destination),
|
|
18459
|
-
`.${basename3(destination)}.${process.pid}.${
|
|
21448
|
+
`.${basename3(destination)}.${process.pid}.${randomUUID4()}.tmp`
|
|
18460
21449
|
);
|
|
18461
21450
|
}
|
|
18462
21451
|
async function removeRunIdTempFile(path) {
|
|
@@ -18469,7 +21458,7 @@ async function removeRunIdTempFile(path) {
|
|
|
18469
21458
|
}
|
|
18470
21459
|
}
|
|
18471
21460
|
async function preflightRunIdFile(path) {
|
|
18472
|
-
const destination =
|
|
21461
|
+
const destination = resolve12(path);
|
|
18473
21462
|
if (await pathExistsIncludingSymlink(destination)) {
|
|
18474
21463
|
throw new Error(
|
|
18475
21464
|
`--run-id-file destination already exists: ${destination}. Choose a new path so this run cannot overwrite another run identity.`
|
|
@@ -18575,7 +21564,7 @@ function traceCliSync(phase, fields, run) {
|
|
|
18575
21564
|
}
|
|
18576
21565
|
}
|
|
18577
21566
|
function sleep5(ms) {
|
|
18578
|
-
return new Promise((
|
|
21567
|
+
return new Promise((resolve22) => setTimeout(resolve22, ms));
|
|
18579
21568
|
}
|
|
18580
21569
|
function parseReferencedPlayTarget2(target) {
|
|
18581
21570
|
const trimmed = target.trim();
|
|
@@ -18829,7 +21818,7 @@ function formatPlayListReference(play) {
|
|
|
18829
21818
|
return play.reference || play.name;
|
|
18830
21819
|
}
|
|
18831
21820
|
function defaultMaterializedPlayPath(reference) {
|
|
18832
|
-
return
|
|
21821
|
+
return resolve12(defaultStarterPlayPath(reference));
|
|
18833
21822
|
}
|
|
18834
21823
|
function defaultStarterPlayPath(reference) {
|
|
18835
21824
|
const playName = parseReferencedPlayTarget2(reference).unqualifiedPlayName;
|
|
@@ -18862,12 +21851,12 @@ function materializeRemotePlaySource(input2) {
|
|
|
18862
21851
|
`Play ${input2.playName} has ${files.length} source files. Use --out <directory> to write the complete bundle.`
|
|
18863
21852
|
);
|
|
18864
21853
|
}
|
|
18865
|
-
const outputDirectory =
|
|
21854
|
+
const outputDirectory = resolve12(input2.outPath);
|
|
18866
21855
|
let created = 0;
|
|
18867
21856
|
let updated = 0;
|
|
18868
21857
|
for (const [logicalPath, sourceCode] of files) {
|
|
18869
|
-
const outputPath2 =
|
|
18870
|
-
const outputRelativePath =
|
|
21858
|
+
const outputPath2 = resolve12(outputDirectory, logicalPath);
|
|
21859
|
+
const outputRelativePath = relative5(outputDirectory, outputPath2);
|
|
18871
21860
|
if (!outputRelativePath || outputRelativePath.startsWith("..") || isAbsolute5(outputRelativePath)) {
|
|
18872
21861
|
throw new Error(
|
|
18873
21862
|
`Refusing to materialize unsafe Play source path ${JSON.stringify(logicalPath)}.`
|
|
@@ -18943,7 +21932,7 @@ function extractPlayName(code, filePath) {
|
|
|
18943
21932
|
throw buildMissingDefinePlayError(filePath);
|
|
18944
21933
|
}
|
|
18945
21934
|
function isFileTarget(target) {
|
|
18946
|
-
return existsSync9(
|
|
21935
|
+
return existsSync9(resolve12(target));
|
|
18947
21936
|
}
|
|
18948
21937
|
function looksLikeRunId(target) {
|
|
18949
21938
|
return /^play\/[^/]+\/run\/[^/]+/.test(target.trim());
|
|
@@ -18972,7 +21961,7 @@ function parsePositiveInteger3(value, flagName) {
|
|
|
18972
21961
|
return parsed;
|
|
18973
21962
|
}
|
|
18974
21963
|
function parseJsonInput(raw) {
|
|
18975
|
-
const source = raw.startsWith("@") ? readFileSync8(
|
|
21964
|
+
const source = raw.startsWith("@") ? readFileSync8(resolve12(raw.slice(1)), "utf-8") : raw;
|
|
18976
21965
|
const parsed = JSON.parse(source);
|
|
18977
21966
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
18978
21967
|
throw new Error("--input must be a JSON object.");
|
|
@@ -19076,7 +22065,7 @@ function fileInputBindingsFromStaticPipeline(staticPipeline) {
|
|
|
19076
22065
|
function isLocalFilePathValue(value) {
|
|
19077
22066
|
if (typeof value !== "string" || !value.trim()) return false;
|
|
19078
22067
|
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(value.trim())) return false;
|
|
19079
|
-
return existsSync9(
|
|
22068
|
+
return existsSync9(resolve12(value));
|
|
19080
22069
|
}
|
|
19081
22070
|
function inputContainsLocalFilePath(value) {
|
|
19082
22071
|
if (isLocalFilePathValue(value)) {
|
|
@@ -19123,7 +22112,7 @@ function collectLocalFileInputRefs(value, inputPath, key, out) {
|
|
|
19123
22112
|
const looksLikeFile = /\.[a-z0-9]{1,8}$/i.test(trimmed);
|
|
19124
22113
|
if (keyIsCsvData) {
|
|
19125
22114
|
out.push({ inputPath, value: trimmed, isCsvData: true });
|
|
19126
|
-
} else if (endsWithCsv || looksLikeFile && existsSync9(
|
|
22115
|
+
} else if (endsWithCsv || looksLikeFile && existsSync9(resolve12(trimmed))) {
|
|
19127
22116
|
out.push({ inputPath, value: trimmed, isCsvData: false });
|
|
19128
22117
|
}
|
|
19129
22118
|
return;
|
|
@@ -19165,7 +22154,7 @@ function preflightLocalFileInputs(runtimeInput) {
|
|
|
19165
22154
|
collectLocalFileInputRefs(value, key, key, refs);
|
|
19166
22155
|
}
|
|
19167
22156
|
for (const ref of refs) {
|
|
19168
|
-
const absolutePath =
|
|
22157
|
+
const absolutePath = resolve12(ref.value);
|
|
19169
22158
|
if (!existsSync9(absolutePath)) {
|
|
19170
22159
|
throw new DeeplineError(
|
|
19171
22160
|
`Input ${ref.inputPath} references a local file that does not exist: ${ref.value} (resolved to ${absolutePath}). No run was created.`,
|
|
@@ -19174,9 +22163,9 @@ function preflightLocalFileInputs(runtimeInput) {
|
|
|
19174
22163
|
{ inputPath: ref.inputPath, path: ref.value, resolved: absolutePath }
|
|
19175
22164
|
);
|
|
19176
22165
|
}
|
|
19177
|
-
let
|
|
22166
|
+
let stat5;
|
|
19178
22167
|
try {
|
|
19179
|
-
|
|
22168
|
+
stat5 = statSync3(absolutePath);
|
|
19180
22169
|
} catch (error) {
|
|
19181
22170
|
throw new DeeplineError(
|
|
19182
22171
|
`Input ${ref.inputPath} references a local file that is not readable: ${ref.value} (${error instanceof Error ? error.message : String(error)}). No run was created.`,
|
|
@@ -19185,7 +22174,7 @@ function preflightLocalFileInputs(runtimeInput) {
|
|
|
19185
22174
|
{ inputPath: ref.inputPath, path: ref.value }
|
|
19186
22175
|
);
|
|
19187
22176
|
}
|
|
19188
|
-
if (!
|
|
22177
|
+
if (!stat5.isFile()) {
|
|
19189
22178
|
throw new DeeplineError(
|
|
19190
22179
|
`Input ${ref.inputPath} references ${ref.value}, which is not a file. No run was created.`,
|
|
19191
22180
|
void 0,
|
|
@@ -19284,7 +22273,7 @@ async function stageFileInputArgs(input2) {
|
|
|
19284
22273
|
const localFiles = uniqueBindings.flatMap((binding) => {
|
|
19285
22274
|
const value = getDottedInputValue(input2.runtimeInput, binding.inputPath);
|
|
19286
22275
|
if (!isLocalFilePathValue(value)) return [];
|
|
19287
|
-
const absolutePath =
|
|
22276
|
+
const absolutePath = resolve12(value);
|
|
19288
22277
|
return [{ binding, absolutePath, logicalPath: basename3(absolutePath) }];
|
|
19289
22278
|
});
|
|
19290
22279
|
if (localFiles.length === 0) {
|
|
@@ -19328,9 +22317,9 @@ function stageFile(logicalPath, absolutePath) {
|
|
|
19328
22317
|
}
|
|
19329
22318
|
function normalizePlayPath(filePath) {
|
|
19330
22319
|
try {
|
|
19331
|
-
return realpathSync2.native(
|
|
22320
|
+
return realpathSync2.native(resolve12(filePath));
|
|
19332
22321
|
} catch {
|
|
19333
|
-
return
|
|
22322
|
+
return resolve12(filePath);
|
|
19334
22323
|
}
|
|
19335
22324
|
}
|
|
19336
22325
|
function formatBundlingErrors(filePath, errors) {
|
|
@@ -21804,7 +24793,7 @@ function shellSingleQuote(value) {
|
|
|
21804
24793
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
21805
24794
|
}
|
|
21806
24795
|
function runExportRetryCommand(runId, outPath, datasetPath) {
|
|
21807
|
-
return `deepline runs export ${runId}${datasetPath ? ` --dataset ${shellSingleQuote(datasetPath)}` : ""} --out ${shellSingleQuote(
|
|
24796
|
+
return `deepline runs export ${runId}${datasetPath ? ` --dataset ${shellSingleQuote(datasetPath)}` : ""} --out ${shellSingleQuote(resolve12(outPath))}`;
|
|
21808
24797
|
}
|
|
21809
24798
|
function extractRunPlayName(status) {
|
|
21810
24799
|
const run = status.run;
|
|
@@ -21933,7 +24922,7 @@ async function fetchBackingDatasetRows(input2) {
|
|
|
21933
24922
|
function exportDatasetCommand(input2) {
|
|
21934
24923
|
return `deepline runs export ${input2.runId} --dataset ${shellSingleQuote(
|
|
21935
24924
|
input2.datasetPath
|
|
21936
|
-
)} --out ${shellSingleQuote(
|
|
24925
|
+
)} --out ${shellSingleQuote(resolve12(input2.outPath))}`;
|
|
21937
24926
|
}
|
|
21938
24927
|
function datasetChoiceLines(input2) {
|
|
21939
24928
|
return input2.datasets.flatMap((dataset) => {
|
|
@@ -23199,7 +26188,7 @@ async function handlePlayCheck(args) {
|
|
|
23199
26188
|
}
|
|
23200
26189
|
return 0;
|
|
23201
26190
|
} catch (error) {
|
|
23202
|
-
const resolved =
|
|
26191
|
+
const resolved = resolve12(options.target);
|
|
23203
26192
|
const message = error instanceof Error && error.message ? error.message : `File not found: ${resolved}`;
|
|
23204
26193
|
if (options.jsonOutput) {
|
|
23205
26194
|
printCompactJson({
|
|
@@ -23213,7 +26202,7 @@ async function handlePlayCheck(args) {
|
|
|
23213
26202
|
return 1;
|
|
23214
26203
|
}
|
|
23215
26204
|
}
|
|
23216
|
-
const absolutePlayPath =
|
|
26205
|
+
const absolutePlayPath = resolve12(options.target);
|
|
23217
26206
|
const sourceCode = readFileSync8(absolutePlayPath, "utf-8");
|
|
23218
26207
|
const exportNames = resolvePlayCheckExportNames(sourceCode);
|
|
23219
26208
|
const outcomes = [];
|
|
@@ -23455,7 +26444,7 @@ async function handleFileBackedRun(options, hooks) {
|
|
|
23455
26444
|
}
|
|
23456
26445
|
const client2 = new DeeplineClient(playRunClientOptions(options));
|
|
23457
26446
|
const progress = getActiveCliProgress() ?? createCliProgress(!options.jsonOutput);
|
|
23458
|
-
const absolutePlayPath =
|
|
26447
|
+
const absolutePlayPath = resolve12(options.target.path);
|
|
23459
26448
|
progress.phase("compiling play");
|
|
23460
26449
|
const sourceCode = traceCliSync(
|
|
23461
26450
|
"cli.play_file_read_source",
|
|
@@ -23855,7 +26844,7 @@ async function handlePlayRun(args, hooks) {
|
|
|
23855
26844
|
if (isFileTarget(options.target.path)) {
|
|
23856
26845
|
return handleFileBackedRun(options, runHooks);
|
|
23857
26846
|
}
|
|
23858
|
-
const resolved =
|
|
26847
|
+
const resolved = resolve12(options.target.path);
|
|
23859
26848
|
console.error(`File not found: ${resolved}`);
|
|
23860
26849
|
const dir = dirname10(resolved);
|
|
23861
26850
|
if (existsSync9(dir)) {
|
|
@@ -23867,7 +26856,7 @@ async function handlePlayRun(args, hooks) {
|
|
|
23867
26856
|
if (siblings.length > 0) {
|
|
23868
26857
|
console.error(`Did you mean one of these?`);
|
|
23869
26858
|
for (const s of siblings.slice(0, 5)) {
|
|
23870
|
-
console.error(` ${
|
|
26859
|
+
console.error(` ${join13(dir, s)}`);
|
|
23871
26860
|
}
|
|
23872
26861
|
}
|
|
23873
26862
|
} catch {
|
|
@@ -24245,7 +27234,7 @@ async function handleRunLogs(args) {
|
|
|
24245
27234
|
continue;
|
|
24246
27235
|
}
|
|
24247
27236
|
if (arg === "--out" && args[index + 1]) {
|
|
24248
|
-
outPath =
|
|
27237
|
+
outPath = resolve12(args[++index]);
|
|
24249
27238
|
continue;
|
|
24250
27239
|
}
|
|
24251
27240
|
if (arg.startsWith("--")) {
|
|
@@ -24457,7 +27446,7 @@ async function handleRunExport(args) {
|
|
|
24457
27446
|
for (let index = 0; index < args.length; index += 1) {
|
|
24458
27447
|
const arg = args[index];
|
|
24459
27448
|
if (arg === "--out" && args[index + 1]) {
|
|
24460
|
-
outPath =
|
|
27449
|
+
outPath = resolve12(args[++index]);
|
|
24461
27450
|
continue;
|
|
24462
27451
|
}
|
|
24463
27452
|
if (arg === "--dataset" && args[index + 1]) {
|
|
@@ -24465,7 +27454,7 @@ async function handleRunExport(args) {
|
|
|
24465
27454
|
continue;
|
|
24466
27455
|
}
|
|
24467
27456
|
if (arg === "--metadata-out" && args[index + 1]) {
|
|
24468
|
-
metadataOutPath =
|
|
27457
|
+
metadataOutPath = resolve12(args[++index]);
|
|
24469
27458
|
}
|
|
24470
27459
|
}
|
|
24471
27460
|
if (!outPath) {
|
|
@@ -24561,7 +27550,7 @@ async function handlePlayGet(args) {
|
|
|
24561
27550
|
for (let index = 1; index < args.length; index += 1) {
|
|
24562
27551
|
const arg = args[index];
|
|
24563
27552
|
if (arg === "--out" && args[index + 1]) {
|
|
24564
|
-
outPath =
|
|
27553
|
+
outPath = resolve12(args[++index]);
|
|
24565
27554
|
}
|
|
24566
27555
|
if (arg === "--revision") {
|
|
24567
27556
|
const rawVersion = args[++index];
|
|
@@ -24582,7 +27571,7 @@ async function handlePlayGet(args) {
|
|
|
24582
27571
|
);
|
|
24583
27572
|
return 2;
|
|
24584
27573
|
}
|
|
24585
|
-
const playName = isFileTarget(target) ? extractPlayName(readFileSync8(
|
|
27574
|
+
const playName = isFileTarget(target) ? extractPlayName(readFileSync8(resolve12(target), "utf-8"), resolve12(target)) : parseReferencedPlayTarget2(target).playName;
|
|
24586
27575
|
const includeSource = sourceOutput || outPath !== null;
|
|
24587
27576
|
const detail = isFileTarget(target) ? await client2.getPlay(
|
|
24588
27577
|
playName,
|
|
@@ -25087,7 +28076,7 @@ async function handlePlayDescribe(args) {
|
|
|
25087
28076
|
const definedName = isFileTarget(playName) ? (() => {
|
|
25088
28077
|
try {
|
|
25089
28078
|
return extractPlayName(
|
|
25090
|
-
readFileSync8(
|
|
28079
|
+
readFileSync8(resolve12(playName), "utf-8"),
|
|
25091
28080
|
playName
|
|
25092
28081
|
);
|
|
25093
28082
|
} catch {
|
|
@@ -25149,7 +28138,7 @@ async function handlePlaySave(args) {
|
|
|
25149
28138
|
graph = await traceCliSpan(
|
|
25150
28139
|
"cli.play_save_bundle_graph",
|
|
25151
28140
|
{ targetKind: "file" },
|
|
25152
|
-
() => collectBundledPlayGraph(
|
|
28141
|
+
() => collectBundledPlayGraph(resolve12(options.target))
|
|
25153
28142
|
);
|
|
25154
28143
|
assertBundledPlayGraphDescriptions(graph);
|
|
25155
28144
|
} catch (error) {
|
|
@@ -25274,7 +28263,7 @@ async function handlePlayPublish(args) {
|
|
|
25274
28263
|
graph = await traceCliSpan(
|
|
25275
28264
|
"cli.play_publish_bundle_graph",
|
|
25276
28265
|
{ targetKind: "file" },
|
|
25277
|
-
() => collectBundledPlayGraph(
|
|
28266
|
+
() => collectBundledPlayGraph(resolve12(playName))
|
|
25278
28267
|
);
|
|
25279
28268
|
assertBundledPlayGraphDescriptions(graph);
|
|
25280
28269
|
} catch (error) {
|
|
@@ -26036,6 +29025,28 @@ Examples:
|
|
|
26036
29025
|
deepline plays publish my.play.ts --dry-run --json
|
|
26037
29026
|
`
|
|
26038
29027
|
);
|
|
29028
|
+
play.command("deploy [directory]").description(
|
|
29029
|
+
"Deploy every play in a directory as one unit (all go live together, or none)."
|
|
29030
|
+
).addHelpText(
|
|
29031
|
+
"after",
|
|
29032
|
+
`
|
|
29033
|
+
Notes:
|
|
29034
|
+
The directory's deepline.json selects which plays deploy (default
|
|
29035
|
+
**/*.play.ts). Unchanged plays are skipped; the rest are validated,
|
|
29036
|
+
registered, and promoted in one transaction.
|
|
29037
|
+
Nothing here touches git: check the code out however you like first.
|
|
29038
|
+
--repo/--ref/--commit are recorded on the deployment as provenance.
|
|
29039
|
+
|
|
29040
|
+
Examples:
|
|
29041
|
+
deepline plays deploy
|
|
29042
|
+
deepline plays deploy ./plays --commit "$GITHUB_SHA" --ref "$GITHUB_REF"
|
|
29043
|
+
`
|
|
29044
|
+
).option(
|
|
29045
|
+
"--manifest <file>",
|
|
29046
|
+
"Manifest file name in the directory (default: deepline.json)"
|
|
29047
|
+
).option("--repo <owner/name>", "Repository to record on the deployment").option("--ref <ref>", "Branch or ref to record on the deployment").option("--commit <sha>", "Commit to record on the deployment").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(
|
|
29048
|
+
async (directory, options) => handlePlaysDeploy(directory, options)
|
|
29049
|
+
);
|
|
26039
29050
|
addPublishHelp(
|
|
26040
29051
|
play.command("publish <target>").description(
|
|
26041
29052
|
"Promote a saved play revision or publish a local play file."
|
|
@@ -28256,7 +31267,7 @@ function emitEnrichDebug(message) {
|
|
|
28256
31267
|
);
|
|
28257
31268
|
}
|
|
28258
31269
|
function sleep6(ms) {
|
|
28259
|
-
return new Promise((
|
|
31270
|
+
return new Promise((resolve22) => setTimeout(resolve22, ms));
|
|
28260
31271
|
}
|
|
28261
31272
|
function enrichExportBackingRowsWaitMs() {
|
|
28262
31273
|
const raw = process.env.DEEPLINE_ENRICH_EXPORT_BACKING_ROWS_WAIT_MS?.trim();
|
|
@@ -28288,7 +31299,7 @@ function expandAtFilePath(rawPath) {
|
|
|
28288
31299
|
return homedir6();
|
|
28289
31300
|
}
|
|
28290
31301
|
if (expanded.startsWith("~/") || expanded.startsWith("~\\")) {
|
|
28291
|
-
return
|
|
31302
|
+
return join14(homedir6(), expanded.slice(2));
|
|
28292
31303
|
}
|
|
28293
31304
|
return expanded;
|
|
28294
31305
|
}
|
|
@@ -28301,7 +31312,7 @@ async function readAtFileReference(value, argumentName, strip = true) {
|
|
|
28301
31312
|
throw new Error(`Invalid ${argumentName} value: empty @file path.`);
|
|
28302
31313
|
}
|
|
28303
31314
|
try {
|
|
28304
|
-
const text = await
|
|
31315
|
+
const text = await readFile4(filePath, "utf8");
|
|
28305
31316
|
const normalized = text.replace(/^\uFEFF/, "");
|
|
28306
31317
|
return strip ? normalized.trim() : normalized;
|
|
28307
31318
|
} catch (error) {
|
|
@@ -28597,9 +31608,9 @@ async function buildPlanArgs(args) {
|
|
|
28597
31608
|
return planArgs;
|
|
28598
31609
|
}
|
|
28599
31610
|
async function assertInputCsvExists(inputCsv) {
|
|
28600
|
-
const path =
|
|
31611
|
+
const path = resolve13(inputCsv);
|
|
28601
31612
|
try {
|
|
28602
|
-
const info = await
|
|
31613
|
+
const info = await stat4(path);
|
|
28603
31614
|
if (info.isFile()) {
|
|
28604
31615
|
return;
|
|
28605
31616
|
}
|
|
@@ -28611,8 +31622,8 @@ async function assertInputCsvExists(inputCsv) {
|
|
|
28611
31622
|
}
|
|
28612
31623
|
}
|
|
28613
31624
|
async function assertSafeOutputPath(inputCsv, outputPath) {
|
|
28614
|
-
const input2 =
|
|
28615
|
-
const output2 =
|
|
31625
|
+
const input2 = resolve13(inputCsv);
|
|
31626
|
+
const output2 = resolve13(outputPath);
|
|
28616
31627
|
if (input2 === output2) {
|
|
28617
31628
|
throw new Error(
|
|
28618
31629
|
"--input and --output must be different files when not using --in-place."
|
|
@@ -28620,8 +31631,8 @@ async function assertSafeOutputPath(inputCsv, outputPath) {
|
|
|
28620
31631
|
}
|
|
28621
31632
|
try {
|
|
28622
31633
|
const [inputInfo, outputInfo] = await Promise.all([
|
|
28623
|
-
|
|
28624
|
-
|
|
31634
|
+
stat4(input2),
|
|
31635
|
+
stat4(output2)
|
|
28625
31636
|
]);
|
|
28626
31637
|
if (inputInfo.dev === outputInfo.dev && inputInfo.ino === outputInfo.ino) {
|
|
28627
31638
|
throw new Error(
|
|
@@ -28641,7 +31652,7 @@ async function assertSafeOutputPath(inputCsv, outputPath) {
|
|
|
28641
31652
|
}
|
|
28642
31653
|
async function regularFileExists(path) {
|
|
28643
31654
|
try {
|
|
28644
|
-
const info = await
|
|
31655
|
+
const info = await stat4(resolve13(path));
|
|
28645
31656
|
return info.isFile();
|
|
28646
31657
|
} catch (error) {
|
|
28647
31658
|
const code = error && typeof error === "object" ? error.code : void 0;
|
|
@@ -28652,7 +31663,7 @@ async function regularFileExists(path) {
|
|
|
28652
31663
|
}
|
|
28653
31664
|
}
|
|
28654
31665
|
async function readConfig(path) {
|
|
28655
|
-
const source = await
|
|
31666
|
+
const source = await readFile4(resolve13(path), "utf8");
|
|
28656
31667
|
let parsed;
|
|
28657
31668
|
try {
|
|
28658
31669
|
parsed = JSON.parse(source);
|
|
@@ -29074,7 +32085,7 @@ async function writeOutputCsv(outputPath, status, options) {
|
|
|
29074
32085
|
options?.config
|
|
29075
32086
|
);
|
|
29076
32087
|
await writeFile4(
|
|
29077
|
-
|
|
32088
|
+
resolve13(outputPath),
|
|
29078
32089
|
csvStringFromRows(merged.rows, columns),
|
|
29079
32090
|
"utf8"
|
|
29080
32091
|
);
|
|
@@ -29084,7 +32095,7 @@ async function writeOutputCsv(outputPath, status, options) {
|
|
|
29084
32095
|
selectedRows: rowsInfo.totalRows,
|
|
29085
32096
|
enrichedRows: rowsInfo.rows.length,
|
|
29086
32097
|
rows: merged.rows.length,
|
|
29087
|
-
path:
|
|
32098
|
+
path: resolve13(outputPath),
|
|
29088
32099
|
partial: !rowsInfo.complete,
|
|
29089
32100
|
enrichedDataRows: rowsInfo.rows
|
|
29090
32101
|
};
|
|
@@ -29265,7 +32276,7 @@ function enrichCustomerDbJson(input2) {
|
|
|
29265
32276
|
...actions.slowExportAsCsvCommand ? { command: actions.slowExportAsCsvCommand } : runId && input2.outputPath ? {
|
|
29266
32277
|
command: `deepline runs export ${runId} --dataset ${shellSingleQuote2(
|
|
29267
32278
|
exportDatasetPath
|
|
29268
|
-
)} --out ${shellSingleQuote2(
|
|
32279
|
+
)} --out ${shellSingleQuote2(resolve13(input2.outputPath))}`
|
|
29269
32280
|
} : {},
|
|
29270
32281
|
action: actions.exportCsv ?? {}
|
|
29271
32282
|
}
|
|
@@ -30289,10 +33300,10 @@ function waterfallExecutionSignal(status, spec) {
|
|
|
30289
33300
|
let everyChildStatOnlyConditionSkipped = true;
|
|
30290
33301
|
const childAliasesWithStats = /* @__PURE__ */ new Set();
|
|
30291
33302
|
for (const childAlias of childAliases) {
|
|
30292
|
-
for (const
|
|
33303
|
+
for (const stat5 of summaries.map((summary) => summary[childAlias]).filter(isRecord11)) {
|
|
30293
33304
|
sawChildStats = true;
|
|
30294
33305
|
childAliasesWithStats.add(childAlias);
|
|
30295
|
-
const execution = isRecord11(
|
|
33306
|
+
const execution = isRecord11(stat5.execution) ? stat5.execution : null;
|
|
30296
33307
|
const executedSummary = parseExecutionSummary(
|
|
30297
33308
|
execution?.["completed:executed"]
|
|
30298
33309
|
);
|
|
@@ -30307,7 +33318,7 @@ function waterfallExecutionSignal(status, spec) {
|
|
|
30307
33318
|
const skippedConditionCount = skippedConditionSummary?.count ?? 0;
|
|
30308
33319
|
const totalCount = executedSummary?.total ?? reusedSummary?.total ?? skippedConditionSummary?.total;
|
|
30309
33320
|
const onlyConditionSkips = totalCount !== void 0 && skippedConditionCount >= totalCount && executedCount + reusedCount <= skippedConditionCount;
|
|
30310
|
-
if (executedCount + reusedCount > 0 && !onlyConditionSkips || numericFailedRowSignal(execution?.failed) > 0 || numericFailedRowSignal(
|
|
33321
|
+
if (executedCount + reusedCount > 0 && !onlyConditionSkips || numericFailedRowSignal(execution?.failed) > 0 || numericFailedRowSignal(stat5.failed) > 0 || numericFailedRowSignal(stat5.failedRows) > 0) {
|
|
30311
33322
|
return "executed";
|
|
30312
33323
|
}
|
|
30313
33324
|
if (!onlyConditionSkips) {
|
|
@@ -30323,8 +33334,8 @@ function waterfallExecutionSignal(status, spec) {
|
|
|
30323
33334
|
function emptyWaterfallStatsEvidence(status, spec) {
|
|
30324
33335
|
const summaries = collectColumnStats(status);
|
|
30325
33336
|
const parentStats = summaries.map((summary) => summary[spec.alias]).filter(isRecord11);
|
|
30326
|
-
for (const
|
|
30327
|
-
const nonEmpty = parseExecutionSummary(
|
|
33337
|
+
for (const stat5 of parentStats) {
|
|
33338
|
+
const nonEmpty = parseExecutionSummary(stat5.non_empty);
|
|
30328
33339
|
if (nonEmpty?.total && nonEmpty.count === 0) {
|
|
30329
33340
|
return { selectedRows: nonEmpty.total };
|
|
30330
33341
|
}
|
|
@@ -30336,16 +33347,16 @@ function emptyWaterfallStatsEvidence(status, spec) {
|
|
|
30336
33347
|
let selectedRows = 0;
|
|
30337
33348
|
let sawStatsForEveryChild = true;
|
|
30338
33349
|
for (const childAlias of childAliases) {
|
|
30339
|
-
const
|
|
30340
|
-
if (!
|
|
33350
|
+
const stat5 = summaries.map((summary) => summary[childAlias]).find(isRecord11);
|
|
33351
|
+
if (!stat5) {
|
|
30341
33352
|
sawStatsForEveryChild = false;
|
|
30342
33353
|
break;
|
|
30343
33354
|
}
|
|
30344
|
-
const nonEmpty = parseExecutionSummary(
|
|
33355
|
+
const nonEmpty = parseExecutionSummary(stat5.non_empty);
|
|
30345
33356
|
if ((nonEmpty?.count ?? 0) > 0) {
|
|
30346
33357
|
return null;
|
|
30347
33358
|
}
|
|
30348
|
-
const execution = isRecord11(
|
|
33359
|
+
const execution = isRecord11(stat5.execution) ? stat5.execution : null;
|
|
30349
33360
|
const executed = parseExecutionSummary(execution?.["completed:executed"]);
|
|
30350
33361
|
const reused = parseExecutionSummary(execution?.["completed:reused"]);
|
|
30351
33362
|
const skipped = parseExecutionSummary(execution?.["skipped:condition"]);
|
|
@@ -30387,16 +33398,16 @@ function collectStatusFailureJobs(input2) {
|
|
|
30387
33398
|
const jobs = [];
|
|
30388
33399
|
aliases.forEach((spec, aliasIndex) => {
|
|
30389
33400
|
const { alias } = spec;
|
|
30390
|
-
const
|
|
30391
|
-
if (!
|
|
33401
|
+
const stat5 = summaries.map((summary) => summary[alias]).find(isRecord11);
|
|
33402
|
+
if (!stat5) {
|
|
30392
33403
|
return;
|
|
30393
33404
|
}
|
|
30394
|
-
const execution = isRecord11(
|
|
33405
|
+
const execution = isRecord11(stat5.execution) ? stat5.execution : null;
|
|
30395
33406
|
const failedCount = Math.min(
|
|
30396
33407
|
selectedRows,
|
|
30397
33408
|
Math.max(
|
|
30398
|
-
numericFailedRowSignal(
|
|
30399
|
-
numericFailedRowSignal(
|
|
33409
|
+
numericFailedRowSignal(stat5.failed),
|
|
33410
|
+
numericFailedRowSignal(stat5.failedRows),
|
|
30400
33411
|
numericFailedRowSignal(execution?.failed)
|
|
30401
33412
|
)
|
|
30402
33413
|
);
|
|
@@ -30404,7 +33415,7 @@ function collectStatusFailureJobs(input2) {
|
|
|
30404
33415
|
return;
|
|
30405
33416
|
}
|
|
30406
33417
|
const message = statusFailureMessage({
|
|
30407
|
-
stat:
|
|
33418
|
+
stat: stat5,
|
|
30408
33419
|
alias,
|
|
30409
33420
|
failedCount,
|
|
30410
33421
|
operation: spec.operation
|
|
@@ -30513,12 +33524,12 @@ function firstAliasExecutionCounts(input2) {
|
|
|
30513
33524
|
const aliases = collectConfigScalarAliasOrder(input2.config);
|
|
30514
33525
|
const summaries = collectColumnStats(input2.status);
|
|
30515
33526
|
for (const alias of aliases) {
|
|
30516
|
-
const
|
|
30517
|
-
if (!
|
|
33527
|
+
const stat5 = summaries.map((summary) => summary[alias]).find(isRecord11);
|
|
33528
|
+
if (!stat5) continue;
|
|
30518
33529
|
if (input2.forceAliases.has(normalizeAlias2(alias))) {
|
|
30519
33530
|
return { executed: input2.selectedRows, reused: 0 };
|
|
30520
33531
|
}
|
|
30521
|
-
const execution = isRecord11(
|
|
33532
|
+
const execution = isRecord11(stat5.execution) ? stat5.execution : null;
|
|
30522
33533
|
if (!execution) continue;
|
|
30523
33534
|
return {
|
|
30524
33535
|
executed: parseExecutionCount(execution["completed:executed"]),
|
|
@@ -30578,11 +33589,11 @@ function rewriteEnrichJsonStatus(input2) {
|
|
|
30578
33589
|
if (isRecord11(next.columnStats) && selectedRows > 0) {
|
|
30579
33590
|
const columnStats = { ...next.columnStats };
|
|
30580
33591
|
for (const alias of forcedAliases) {
|
|
30581
|
-
const
|
|
30582
|
-
const execution = isRecord11(
|
|
30583
|
-
if (!
|
|
33592
|
+
const stat5 = isRecord11(columnStats[alias]) ? columnStats[alias] : null;
|
|
33593
|
+
const execution = isRecord11(stat5?.execution) ? stat5.execution : null;
|
|
33594
|
+
if (!stat5 || !execution) continue;
|
|
30584
33595
|
columnStats[alias] = {
|
|
30585
|
-
...
|
|
33596
|
+
...stat5,
|
|
30586
33597
|
execution: {
|
|
30587
33598
|
...execution,
|
|
30588
33599
|
"completed:executed": executionSummaryText(
|
|
@@ -30662,15 +33673,15 @@ function addEnrichRowsExportFollowUpCommand(commands, seen, input2) {
|
|
|
30662
33673
|
label: "export enrich rows",
|
|
30663
33674
|
path: GENERATED_ENRICH_ROWS_TABLE_NAMESPACE,
|
|
30664
33675
|
command: `deepline runs export ${input2.runId} --dataset ${GENERATED_ENRICH_ROWS_TABLE_NAMESPACE} --out ${shellSingleQuote2(
|
|
30665
|
-
|
|
33676
|
+
resolve13(input2.outputPath)
|
|
30666
33677
|
)}`
|
|
30667
33678
|
});
|
|
30668
33679
|
}
|
|
30669
33680
|
function sidecarEnrichRowsExportPath(outputPath) {
|
|
30670
|
-
const resolved =
|
|
33681
|
+
const resolved = resolve13(outputPath);
|
|
30671
33682
|
const ext = extname3(resolved) || ".csv";
|
|
30672
33683
|
const stem = basename4(resolved, ext);
|
|
30673
|
-
return
|
|
33684
|
+
return join14(dirname11(resolved), `${stem}.deepline-enrich-rows${ext}`);
|
|
30674
33685
|
}
|
|
30675
33686
|
function collectDatasetFollowUpCommands(value, state) {
|
|
30676
33687
|
if (state.depth > 12 || !value || typeof value !== "object" || state.commands.length >= 8) {
|
|
@@ -30711,7 +33722,7 @@ function collectDatasetFollowUpCommands(value, state) {
|
|
|
30711
33722
|
path: selector,
|
|
30712
33723
|
command: `deepline runs export ${state.runId} --dataset ${shellSingleQuote2(
|
|
30713
33724
|
selector
|
|
30714
|
-
)} --out ${shellSingleQuote2(
|
|
33725
|
+
)} --out ${shellSingleQuote2(resolve13(state.outputPath))}`
|
|
30715
33726
|
});
|
|
30716
33727
|
}
|
|
30717
33728
|
}
|
|
@@ -30751,10 +33762,10 @@ async function persistEnrichFailureReport(input2) {
|
|
|
30751
33762
|
if (input2.jobs.length === 0 && input2.issues.length === 0) {
|
|
30752
33763
|
return null;
|
|
30753
33764
|
}
|
|
30754
|
-
const stateDir =
|
|
33765
|
+
const stateDir = join14(homedir6(), ".local", "deepline", "runtime", "state");
|
|
30755
33766
|
const reportPrefix = input2.jobs.length > 0 ? "run-block-failures" : "enrich-issues";
|
|
30756
33767
|
await mkdir4(stateDir, { recursive: true });
|
|
30757
|
-
const reportPath =
|
|
33768
|
+
const reportPath = join14(
|
|
30758
33769
|
stateDir,
|
|
30759
33770
|
`${reportPrefix}-${Math.floor(Date.now() / 1e3)}-${process.pid}.json`
|
|
30760
33771
|
);
|
|
@@ -31637,8 +34648,8 @@ function registerEnrichCommand(program) {
|
|
|
31637
34648
|
if (options.json) {
|
|
31638
34649
|
printJson({
|
|
31639
34650
|
dryRun: true,
|
|
31640
|
-
input:
|
|
31641
|
-
output: options.output ?
|
|
34651
|
+
input: resolve13(inputCsv),
|
|
34652
|
+
output: options.output ? resolve13(options.output) : null,
|
|
31642
34653
|
plan: summary
|
|
31643
34654
|
});
|
|
31644
34655
|
return;
|
|
@@ -31649,7 +34660,7 @@ function registerEnrichCommand(program) {
|
|
|
31649
34660
|
}
|
|
31650
34661
|
const rows = parseRows(options.rows, options.all);
|
|
31651
34662
|
let outputPath = options.inPlace ? inputCsv : options.output;
|
|
31652
|
-
const requestedOutputPath = options.inPlace ?
|
|
34663
|
+
const requestedOutputPath = options.inPlace ? resolve13(inputCsv) : options.output ? resolve13(options.output) : void 0;
|
|
31653
34664
|
const sourceCsvPath = !options.inPlace && outputPath && await regularFileExists(outputPath) ? outputPath : inputCsv;
|
|
31654
34665
|
const forceAliases = resolveForceAliases(config, options);
|
|
31655
34666
|
for (const alias of collectFailedInputAliases(
|
|
@@ -31683,13 +34694,13 @@ function registerEnrichCommand(program) {
|
|
|
31683
34694
|
sdkEnrichTelemetryCompleted = true;
|
|
31684
34695
|
await completeSdkEnrichTelemetry(sdkEnrichTelemetry, input2);
|
|
31685
34696
|
};
|
|
31686
|
-
const tempDir = await
|
|
34697
|
+
const tempDir = await mkdtemp2(join14(tmpdir5(), "deepline-enrich-play-"));
|
|
31687
34698
|
await emitSdkEnrichTelemetry(sdkEnrichTelemetry, "enrich_started");
|
|
31688
|
-
const tempPlay =
|
|
34699
|
+
const tempPlay = join14(tempDir, "deepline-enrich.play.ts");
|
|
31689
34700
|
let inPlaceTempDir = null;
|
|
31690
34701
|
let inPlaceTempOutputPath = null;
|
|
31691
|
-
const inPlaceFinalOutputPath = options.inPlace ?
|
|
31692
|
-
const inPlaceCommitOutputPath = options.inPlace ? (await lstat2(inputCsv)).isSymbolicLink() ? await
|
|
34702
|
+
const inPlaceFinalOutputPath = options.inPlace ? resolve13(inputCsv) : null;
|
|
34703
|
+
const inPlaceCommitOutputPath = options.inPlace ? (await lstat2(inputCsv)).isSymbolicLink() ? await realpath4(inputCsv) : inPlaceFinalOutputPath : null;
|
|
31693
34704
|
const failureReportOutputPath = options.inPlace ? inPlaceFinalOutputPath : null;
|
|
31694
34705
|
const enrichIssueFollowUpOutputPath = options.inPlace && inPlaceFinalOutputPath ? sidecarEnrichRowsExportPath(inPlaceFinalOutputPath) : null;
|
|
31695
34706
|
let activeRunId2 = null;
|
|
@@ -31710,16 +34721,16 @@ function registerEnrichCommand(program) {
|
|
|
31710
34721
|
return;
|
|
31711
34722
|
}
|
|
31712
34723
|
if (inPlaceTempDir) {
|
|
31713
|
-
await
|
|
34724
|
+
await rm3(inPlaceTempDir, { recursive: true, force: true });
|
|
31714
34725
|
}
|
|
31715
|
-
inPlaceTempDir = await
|
|
31716
|
-
|
|
31717
|
-
dirname11(inPlaceCommitOutputPath ??
|
|
34726
|
+
inPlaceTempDir = await mkdtemp2(
|
|
34727
|
+
join14(
|
|
34728
|
+
dirname11(inPlaceCommitOutputPath ?? resolve13(inputCsv)),
|
|
31718
34729
|
".deepline-enrich-in-place-"
|
|
31719
34730
|
)
|
|
31720
34731
|
);
|
|
31721
|
-
inPlaceTempOutputPath =
|
|
31722
|
-
await copyFile(
|
|
34732
|
+
inPlaceTempOutputPath = join14(inPlaceTempDir, "output.csv");
|
|
34733
|
+
await copyFile(resolve13(inputCsv), inPlaceTempOutputPath);
|
|
31723
34734
|
outputPath = inPlaceTempOutputPath;
|
|
31724
34735
|
};
|
|
31725
34736
|
const commitInPlaceOutput = async (exportResult) => {
|
|
@@ -31732,7 +34743,7 @@ function registerEnrichCommand(program) {
|
|
|
31732
34743
|
inPlaceTempOutputPath = null;
|
|
31733
34744
|
outputPath = inPlaceFinalOutputPath;
|
|
31734
34745
|
if (committedTempDir) {
|
|
31735
|
-
await
|
|
34746
|
+
await rm3(committedTempDir, { recursive: true, force: true });
|
|
31736
34747
|
}
|
|
31737
34748
|
if (!exportResult) {
|
|
31738
34749
|
return null;
|
|
@@ -31751,7 +34762,7 @@ function registerEnrichCommand(program) {
|
|
|
31751
34762
|
}
|
|
31752
34763
|
const runOne = async (input2) => {
|
|
31753
34764
|
const runtimeInput = {
|
|
31754
|
-
file:
|
|
34765
|
+
file: resolve13(input2.sourceCsvPath),
|
|
31755
34766
|
...input2.rows.rowStart !== null ? { rowStart: input2.rows.rowStart } : {},
|
|
31756
34767
|
...input2.rows.rowEnd !== null ? { rowEnd: input2.rows.rowEnd } : {}
|
|
31757
34768
|
};
|
|
@@ -31939,11 +34950,11 @@ function registerEnrichCommand(program) {
|
|
|
31939
34950
|
process.removeListener("SIGINT", onSigint);
|
|
31940
34951
|
process.removeListener("SIGTERM", onSigterm);
|
|
31941
34952
|
if (inPlaceTempDir) {
|
|
31942
|
-
await
|
|
34953
|
+
await rm3(inPlaceTempDir, { recursive: true, force: true });
|
|
31943
34954
|
} else if (inPlaceTempOutputPath) {
|
|
31944
|
-
await
|
|
34955
|
+
await rm3(inPlaceTempOutputPath, { force: true });
|
|
31945
34956
|
}
|
|
31946
|
-
await
|
|
34957
|
+
await rm3(tempDir, { recursive: true, force: true });
|
|
31947
34958
|
}
|
|
31948
34959
|
});
|
|
31949
34960
|
}
|
|
@@ -31974,7 +34985,7 @@ async function handleFeedback(text, options) {
|
|
|
31974
34985
|
{ json: options.json }
|
|
31975
34986
|
);
|
|
31976
34987
|
}
|
|
31977
|
-
function resolveFeedbackText(text, file,
|
|
34988
|
+
function resolveFeedbackText(text, file, readFile7 = (path) => readFileSync9(path, "utf8")) {
|
|
31978
34989
|
if (text !== void 0 && file !== void 0) {
|
|
31979
34990
|
throw new Error(
|
|
31980
34991
|
"Pass feedback text positionally or with --file, not both."
|
|
@@ -31983,7 +34994,7 @@ function resolveFeedbackText(text, file, readFile6 = (path) => readFileSync9(pat
|
|
|
31983
34994
|
let value;
|
|
31984
34995
|
if (file !== void 0) {
|
|
31985
34996
|
try {
|
|
31986
|
-
value =
|
|
34997
|
+
value = readFile7(file === "-" ? 0 : file);
|
|
31987
34998
|
} catch (error) {
|
|
31988
34999
|
throw new Error(
|
|
31989
35000
|
`Could not read feedback ${file === "-" ? "from stdin" : `file ${file}`}: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -31992,7 +35003,7 @@ function resolveFeedbackText(text, file, readFile6 = (path) => readFileSync9(pat
|
|
|
31992
35003
|
} else if (text !== void 0) {
|
|
31993
35004
|
value = text;
|
|
31994
35005
|
} else if (!process.stdin.isTTY) {
|
|
31995
|
-
value =
|
|
35006
|
+
value = readFile7(0);
|
|
31996
35007
|
} else {
|
|
31997
35008
|
throw new Error(
|
|
31998
35009
|
"Feedback text is required. Pass it positionally, use --file <path>, or pipe stdin."
|
|
@@ -32050,9 +35061,9 @@ import {
|
|
|
32050
35061
|
writeFileSync as writeFileSync11
|
|
32051
35062
|
} from "fs";
|
|
32052
35063
|
import { homedir as homedir7, platform } from "os";
|
|
32053
|
-
import { basename as basename5, dirname as dirname12, join as
|
|
35064
|
+
import { basename as basename5, dirname as dirname12, join as join15, resolve as resolve14 } from "path";
|
|
32054
35065
|
import { gzipSync } from "zlib";
|
|
32055
|
-
import { randomUUID as
|
|
35066
|
+
import { randomUUID as randomUUID5 } from "crypto";
|
|
32056
35067
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
32057
35068
|
var UUID_IN_TEXT_RE = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
|
|
32058
35069
|
var MAX_SESSION_UPLOAD_BYTES = 35e5;
|
|
@@ -32076,10 +35087,10 @@ function detectShellContext() {
|
|
|
32076
35087
|
};
|
|
32077
35088
|
}
|
|
32078
35089
|
function claudeProjectsRoot() {
|
|
32079
|
-
return
|
|
35090
|
+
return join15(homeDir(), ".claude", "projects");
|
|
32080
35091
|
}
|
|
32081
35092
|
function codexSessionsRoot() {
|
|
32082
|
-
return
|
|
35093
|
+
return join15(homeDir(), ".codex", "sessions");
|
|
32083
35094
|
}
|
|
32084
35095
|
function listClaudeSessionFiles() {
|
|
32085
35096
|
const root = claudeProjectsRoot();
|
|
@@ -32087,18 +35098,18 @@ function listClaudeSessionFiles() {
|
|
|
32087
35098
|
const projectDirs = readDirectoryNames(root);
|
|
32088
35099
|
const files = [];
|
|
32089
35100
|
for (const projectDir of projectDirs) {
|
|
32090
|
-
const fullProjectDir =
|
|
35101
|
+
const fullProjectDir = join15(root, projectDir);
|
|
32091
35102
|
for (const fileName of readDirectoryNames(fullProjectDir)) {
|
|
32092
35103
|
if (fileName.endsWith(".jsonl")) {
|
|
32093
|
-
const filePath =
|
|
35104
|
+
const filePath = join15(fullProjectDir, fileName);
|
|
32094
35105
|
const sessionId = sessionIdFromClaudeFilePath(filePath);
|
|
32095
|
-
const
|
|
32096
|
-
if (sessionId &&
|
|
35106
|
+
const stat5 = statIfReadable(filePath);
|
|
35107
|
+
if (sessionId && stat5) {
|
|
32097
35108
|
files.push({
|
|
32098
35109
|
agent: "claude",
|
|
32099
35110
|
sessionId,
|
|
32100
35111
|
filePath,
|
|
32101
|
-
mtimeMs:
|
|
35112
|
+
mtimeMs: stat5.mtimeMs
|
|
32102
35113
|
});
|
|
32103
35114
|
}
|
|
32104
35115
|
}
|
|
@@ -32111,11 +35122,11 @@ function listCodexSessionFiles() {
|
|
|
32111
35122
|
if (!existsSync10(root)) return [];
|
|
32112
35123
|
const files = [];
|
|
32113
35124
|
for (const filePath of listJsonlFilesRecursive(root, 5)) {
|
|
32114
|
-
const
|
|
32115
|
-
if (!
|
|
35125
|
+
const stat5 = statIfReadable(filePath);
|
|
35126
|
+
if (!stat5) continue;
|
|
32116
35127
|
const sessionId = sessionIdFromCodexFilePath(filePath) ?? readCodexSessionId(filePath);
|
|
32117
35128
|
if (!sessionId) continue;
|
|
32118
|
-
files.push({ agent: "codex", sessionId, filePath, mtimeMs:
|
|
35129
|
+
files.push({ agent: "codex", sessionId, filePath, mtimeMs: stat5.mtimeMs });
|
|
32119
35130
|
}
|
|
32120
35131
|
return files;
|
|
32121
35132
|
}
|
|
@@ -32147,7 +35158,7 @@ function listJsonlFilesRecursive(root, maxDepth) {
|
|
|
32147
35158
|
return;
|
|
32148
35159
|
}
|
|
32149
35160
|
for (const entry of entries) {
|
|
32150
|
-
const fullPath =
|
|
35161
|
+
const fullPath = join15(dir, entry.name);
|
|
32151
35162
|
if (entry.isDirectory()) {
|
|
32152
35163
|
visit(fullPath, depth + 1);
|
|
32153
35164
|
} else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
@@ -32451,7 +35462,7 @@ async function uploadPayload(path, payload) {
|
|
|
32451
35462
|
return await http.post(path, payload);
|
|
32452
35463
|
}
|
|
32453
35464
|
async function uploadChunkedSessions(sessions, options) {
|
|
32454
|
-
const uploadId =
|
|
35465
|
+
const uploadId = randomUUID5();
|
|
32455
35466
|
for (const session of sessions) {
|
|
32456
35467
|
const bytes = Buffer.from(session.encodedContent, "base64");
|
|
32457
35468
|
const chunks = [];
|
|
@@ -32497,7 +35508,7 @@ async function uploadChunkedSessions(sessions, options) {
|
|
|
32497
35508
|
}
|
|
32498
35509
|
async function handleSessionsSend(options) {
|
|
32499
35510
|
if (options.file) {
|
|
32500
|
-
const filePath =
|
|
35511
|
+
const filePath = resolve14(options.file);
|
|
32501
35512
|
if (!existsSync10(filePath)) {
|
|
32502
35513
|
throw new Error(`File not found: ${options.file}`);
|
|
32503
35514
|
}
|
|
@@ -32596,11 +35607,11 @@ function fallbackViewerAssets() {
|
|
|
32596
35607
|
};
|
|
32597
35608
|
}
|
|
32598
35609
|
function loadViewerAssets() {
|
|
32599
|
-
const cliEntry = process.argv[1]?.trim() ?
|
|
35610
|
+
const cliEntry = process.argv[1]?.trim() ? resolve14(process.argv[1]) : null;
|
|
32600
35611
|
const candidateRoots2 = [
|
|
32601
35612
|
...cliEntry ? [
|
|
32602
|
-
|
|
32603
|
-
|
|
35613
|
+
join15(dirname12(dirname12(cliEntry)), "viewer"),
|
|
35614
|
+
join15(
|
|
32604
35615
|
dirname12(dirname12(dirname12(cliEntry))),
|
|
32605
35616
|
"src",
|
|
32606
35617
|
"lib",
|
|
@@ -32608,12 +35619,12 @@ function loadViewerAssets() {
|
|
|
32608
35619
|
"viewer"
|
|
32609
35620
|
)
|
|
32610
35621
|
] : [],
|
|
32611
|
-
|
|
35622
|
+
join15(process.cwd(), "packages", "sdk", "assets", "viewer")
|
|
32612
35623
|
];
|
|
32613
35624
|
for (const root of candidateRoots2) {
|
|
32614
35625
|
try {
|
|
32615
|
-
const cssPath =
|
|
32616
|
-
const jsPath =
|
|
35626
|
+
const cssPath = join15(root, "viewer.css");
|
|
35627
|
+
const jsPath = join15(root, "viewer.js");
|
|
32617
35628
|
if (!existsSync10(cssPath) || !existsSync10(jsPath)) continue;
|
|
32618
35629
|
return {
|
|
32619
35630
|
css: readFileSync10(cssPath, "utf8"),
|
|
@@ -32641,11 +35652,11 @@ async function handleSessionsRender(options) {
|
|
|
32641
35652
|
currentSession: options.currentSession,
|
|
32642
35653
|
agent: options.agent
|
|
32643
35654
|
});
|
|
32644
|
-
let outputPath = options.output ?
|
|
35655
|
+
let outputPath = options.output ? resolve14(options.output) : "";
|
|
32645
35656
|
if (!outputPath) {
|
|
32646
|
-
const outputDir =
|
|
35657
|
+
const outputDir = join15(process.cwd(), "deepline", "data");
|
|
32647
35658
|
mkdirSync8(outputDir, { recursive: true });
|
|
32648
|
-
outputPath =
|
|
35659
|
+
outputPath = join15(
|
|
32649
35660
|
outputDir,
|
|
32650
35661
|
targets.length > 1 ? "session-viewer.html" : `session-${targets[0]?.sessionId}.html`
|
|
32651
35662
|
);
|
|
@@ -32888,9 +35899,9 @@ Examples:
|
|
|
32888
35899
|
}
|
|
32889
35900
|
|
|
32890
35901
|
// src/cli/commands/monitors.ts
|
|
32891
|
-
import { randomUUID as
|
|
35902
|
+
import { randomUUID as randomUUID6 } from "crypto";
|
|
32892
35903
|
import { readFileSync as readFileSync11, writeFileSync as writeFileSync12 } from "fs";
|
|
32893
|
-
import { resolve as
|
|
35904
|
+
import { resolve as resolve15 } from "path";
|
|
32894
35905
|
import { createInterface } from "readline/promises";
|
|
32895
35906
|
|
|
32896
35907
|
// ../integration-contracts/monitor-input-contract.ts
|
|
@@ -33753,7 +36764,7 @@ function parseJsonObjectArg(raw, argLabel) {
|
|
|
33753
36764
|
return parsed;
|
|
33754
36765
|
}
|
|
33755
36766
|
function resolveMonitorJsonBody(input2) {
|
|
33756
|
-
const
|
|
36767
|
+
const readFile7 = input2.readFile ?? ((path) => readFileSync11(path, "utf-8"));
|
|
33757
36768
|
const readStdin = input2.readStdin ?? (() => readFileSync11(0, "utf-8"));
|
|
33758
36769
|
if (input2.positional !== void 0 && input2.file !== void 0) {
|
|
33759
36770
|
throw new MonitorsUsageError(
|
|
@@ -33769,7 +36780,7 @@ function resolveMonitorJsonBody(input2) {
|
|
|
33769
36780
|
}
|
|
33770
36781
|
let raw;
|
|
33771
36782
|
try {
|
|
33772
|
-
raw =
|
|
36783
|
+
raw = readFile7(input2.file);
|
|
33773
36784
|
} catch (error) {
|
|
33774
36785
|
throw new MonitorsUsageError(
|
|
33775
36786
|
`Could not read --file ${input2.file}: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -34405,14 +37416,14 @@ function fleetIdempotencyKey(operation, supplied) {
|
|
|
34405
37416
|
if (supplied !== void 0 && !normalized) {
|
|
34406
37417
|
throw new MonitorsUsageError("--idempotency-key must not be empty.");
|
|
34407
37418
|
}
|
|
34408
|
-
return normalized ?? `monitor-fleet-${operation}-${
|
|
37419
|
+
return normalized ?? `monitor-fleet-${operation}-${randomUUID6()}`;
|
|
34409
37420
|
}
|
|
34410
37421
|
function monitorJobIdempotencyKey(operation, supplied) {
|
|
34411
37422
|
const normalized = supplied?.trim();
|
|
34412
37423
|
if (supplied !== void 0 && !normalized) {
|
|
34413
37424
|
throw new MonitorsUsageError("--idempotency-key must not be empty.");
|
|
34414
37425
|
}
|
|
34415
|
-
return normalized ?? `monitor-job-${operation}-${
|
|
37426
|
+
return normalized ?? `monitor-job-${operation}-${randomUUID6()}`;
|
|
34416
37427
|
}
|
|
34417
37428
|
function readMonitorDefinitionsJsonFile(file) {
|
|
34418
37429
|
let raw;
|
|
@@ -34486,7 +37497,7 @@ async function handleMonitorJobBatchDeploy(options, idempotencyKey) {
|
|
|
34486
37497
|
);
|
|
34487
37498
|
}
|
|
34488
37499
|
function namedBatchIdempotencyKey(batchId, intent, supplied) {
|
|
34489
|
-
return supplied?.trim() || `monitor-batch-${intent}-${batchId}-${
|
|
37500
|
+
return supplied?.trim() || `monitor-batch-${intent}-${batchId}-${randomUUID6()}`;
|
|
34490
37501
|
}
|
|
34491
37502
|
async function handleNamedMonitorBatchSync(batchId, options) {
|
|
34492
37503
|
if (!options.file) {
|
|
@@ -35047,7 +38058,7 @@ async function handleMonitorFleetsInit(fleetId, options) {
|
|
|
35047
38058
|
}
|
|
35048
38059
|
};
|
|
35049
38060
|
const definition = requireCompiledFleetDefinition(authoredDefinition);
|
|
35050
|
-
const file =
|
|
38061
|
+
const file = resolve15(out);
|
|
35051
38062
|
writeFileSync12(file, `${JSON.stringify(definition, null, 2)}
|
|
35052
38063
|
`, "utf8");
|
|
35053
38064
|
const next = `deepline monitors fleets deploy --file ${fleetShellArg(file)} --dry-run --json`;
|
|
@@ -35743,7 +38754,7 @@ async function watchMonitorHealth(input2) {
|
|
|
35743
38754
|
return last;
|
|
35744
38755
|
}
|
|
35745
38756
|
await new Promise(
|
|
35746
|
-
(
|
|
38757
|
+
(resolve22) => setTimeout(resolve22, MONITOR_VERB_POLL_INTERVAL_MS)
|
|
35747
38758
|
);
|
|
35748
38759
|
last = await input2.client.monitors.health(scope);
|
|
35749
38760
|
input2.onProgress(last);
|
|
@@ -35903,7 +38914,7 @@ function monitorBatchScope(options, kind) {
|
|
|
35903
38914
|
return { kind: "keys", monitorKeys };
|
|
35904
38915
|
}
|
|
35905
38916
|
function monitorBatchIdempotencyKey(kind, value) {
|
|
35906
|
-
return value?.trim() || `monitor-batch-${kind}-${
|
|
38917
|
+
return value?.trim() || `monitor-batch-${kind}-${randomUUID6()}`;
|
|
35907
38918
|
}
|
|
35908
38919
|
function isCanonicalBatchJsonDocument(raw) {
|
|
35909
38920
|
try {
|
|
@@ -35928,7 +38939,7 @@ async function handleMonitorBatchDeploy(options) {
|
|
|
35928
38939
|
}
|
|
35929
38940
|
let manifestNdjson;
|
|
35930
38941
|
try {
|
|
35931
|
-
manifestNdjson = readFileSync11(
|
|
38942
|
+
manifestNdjson = readFileSync11(resolve15(options.file), "utf8");
|
|
35932
38943
|
} catch (error) {
|
|
35933
38944
|
throw new MonitorsUsageError(
|
|
35934
38945
|
`Could not read monitor batch manifest '${options.file}': ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -36827,7 +39838,7 @@ Example:
|
|
|
36827
39838
|
}
|
|
36828
39839
|
|
|
36829
39840
|
// src/cli/commands/org.ts
|
|
36830
|
-
import { createHash as createHash5, randomUUID as
|
|
39841
|
+
import { createHash as createHash5, randomUUID as randomUUID7 } from "crypto";
|
|
36831
39842
|
import {
|
|
36832
39843
|
existsSync as existsSync11,
|
|
36833
39844
|
mkdirSync as mkdirSync9,
|
|
@@ -36835,10 +39846,10 @@ import {
|
|
|
36835
39846
|
unlinkSync,
|
|
36836
39847
|
writeFileSync as writeFileSync13
|
|
36837
39848
|
} from "fs";
|
|
36838
|
-
import { join as
|
|
39849
|
+
import { join as join16 } from "path";
|
|
36839
39850
|
function pendingOrgCreatePath(baseUrl, accountId, sourceOrgId, name) {
|
|
36840
39851
|
const intent = createHash5("sha256").update(accountId).update("\0").update(sourceOrgId).update("\0").update(name).digest("hex");
|
|
36841
|
-
return
|
|
39852
|
+
return join16(sdkCliStateDirPath(baseUrl), `pending-org-create-${intent}.json`);
|
|
36842
39853
|
}
|
|
36843
39854
|
function readPendingOrgCreate(path, accountId, sourceOrgId, name) {
|
|
36844
39855
|
let value;
|
|
@@ -36880,7 +39891,7 @@ function loadOrCreatePendingOrgCreate(input2) {
|
|
|
36880
39891
|
accountId: input2.accountId,
|
|
36881
39892
|
sourceOrgId: input2.sourceOrgId,
|
|
36882
39893
|
name: input2.name,
|
|
36883
|
-
idempotencyKey:
|
|
39894
|
+
idempotencyKey: randomUUID7()
|
|
36884
39895
|
};
|
|
36885
39896
|
try {
|
|
36886
39897
|
writeFileSync13(path, `${JSON.stringify(pending)}
|
|
@@ -37653,10 +40664,13 @@ function renderProject(project) {
|
|
|
37653
40664
|
return `${project.id} ${project.repoFullName}${root} - ${flags}`;
|
|
37654
40665
|
}
|
|
37655
40666
|
function renderDeployment(deployment) {
|
|
37656
|
-
const ref = deployment.ref.replace("refs/heads/", "");
|
|
37657
40667
|
const kind = deployment.isProduction ? "production" : deployment.trigger === "pull_request" ? `pr #${deployment.pullRequestNumber ?? "?"}` : deployment.trigger;
|
|
37658
40668
|
const suffix = deployment.error ? ` - ${deployment.error.slice(0, 80)}` : "";
|
|
37659
|
-
|
|
40669
|
+
const source = [
|
|
40670
|
+
deployment.commitSha?.slice(0, 10),
|
|
40671
|
+
deployment.ref?.replace("refs/heads/", "") ?? deployment.repoFullName
|
|
40672
|
+
].filter(Boolean).join(" ") || "directory";
|
|
40673
|
+
return `${deployment.id} ${source} (${kind}) - ${deployment.status}${suffix}`;
|
|
37660
40674
|
}
|
|
37661
40675
|
async function handleList(options) {
|
|
37662
40676
|
const { http } = getAuthedHttpClient();
|
|
@@ -38160,7 +41174,7 @@ Deprecated:
|
|
|
38160
41174
|
|
|
38161
41175
|
// src/cli/commands/secrets.ts
|
|
38162
41176
|
import { stdin as input, stdout as output } from "process";
|
|
38163
|
-
import { readFile as
|
|
41177
|
+
import { readFile as readFile5 } from "fs/promises";
|
|
38164
41178
|
var hiddenInputBuffer = "";
|
|
38165
41179
|
function normalizeSecretName(value) {
|
|
38166
41180
|
const normalized = value.trim().toUpperCase();
|
|
@@ -38195,7 +41209,7 @@ async function readHiddenLine(prompt, streams = {}) {
|
|
|
38195
41209
|
}
|
|
38196
41210
|
let value = "";
|
|
38197
41211
|
inputStream.resume();
|
|
38198
|
-
return await new Promise((
|
|
41212
|
+
return await new Promise((resolve22, reject) => {
|
|
38199
41213
|
let settled = false;
|
|
38200
41214
|
const cleanup = () => {
|
|
38201
41215
|
inputStream.off("data", onData);
|
|
@@ -38213,7 +41227,7 @@ async function readHiddenLine(prompt, streams = {}) {
|
|
|
38213
41227
|
settled = true;
|
|
38214
41228
|
outputStream.write("\n");
|
|
38215
41229
|
cleanup();
|
|
38216
|
-
|
|
41230
|
+
resolve22(line);
|
|
38217
41231
|
};
|
|
38218
41232
|
const fail = (error) => {
|
|
38219
41233
|
if (settled) return;
|
|
@@ -38306,7 +41320,7 @@ async function readSecretValueFromOptions(options) {
|
|
|
38306
41320
|
}
|
|
38307
41321
|
value = envValue;
|
|
38308
41322
|
} else {
|
|
38309
|
-
value = trimOneTerminalNewline(await
|
|
41323
|
+
value = trimOneTerminalNewline(await readFile5(options.fromFile, "utf8"));
|
|
38310
41324
|
}
|
|
38311
41325
|
if (!value) throw new Error("Secret value is required.");
|
|
38312
41326
|
return value;
|
|
@@ -38519,7 +41533,7 @@ import {
|
|
|
38519
41533
|
writeFileSync as writeFileSync16
|
|
38520
41534
|
} from "fs";
|
|
38521
41535
|
import { homedir as homedir9 } from "os";
|
|
38522
|
-
import { dirname as dirname16, join as
|
|
41536
|
+
import { dirname as dirname16, join as join20, resolve as resolve17 } from "path";
|
|
38523
41537
|
|
|
38524
41538
|
// src/cli/installation-lifecycle.ts
|
|
38525
41539
|
import {
|
|
@@ -38529,7 +41543,7 @@ import {
|
|
|
38529
41543
|
realpathSync as realpathSync3,
|
|
38530
41544
|
rmSync as rmSync4
|
|
38531
41545
|
} from "fs";
|
|
38532
|
-
import { basename as basename6, dirname as dirname13, join as
|
|
41546
|
+
import { basename as basename6, dirname as dirname13, join as join17, relative as relative6, resolve as resolve16 } from "path";
|
|
38533
41547
|
var nodeFileSystem = {
|
|
38534
41548
|
exists: existsSync12,
|
|
38535
41549
|
isSymbolicLink(path) {
|
|
@@ -38585,25 +41599,25 @@ var CliInstallation = class _CliInstallation {
|
|
|
38585
41599
|
});
|
|
38586
41600
|
}
|
|
38587
41601
|
static isNpmPackagePath(path) {
|
|
38588
|
-
return path?.includes(`${
|
|
41602
|
+
return path?.includes(`${join17("node_modules", "deepline")}`) ?? false;
|
|
38589
41603
|
}
|
|
38590
41604
|
launcher(path) {
|
|
38591
41605
|
return inspectLauncher(path, this.input.fileSystem);
|
|
38592
41606
|
}
|
|
38593
41607
|
retiredArtifacts() {
|
|
38594
|
-
const hostDir =
|
|
41608
|
+
const hostDir = join17(
|
|
38595
41609
|
this.input.home,
|
|
38596
41610
|
".local",
|
|
38597
41611
|
"deepline",
|
|
38598
41612
|
this.input.baseUrlSlug
|
|
38599
41613
|
);
|
|
38600
|
-
const legacyLauncherPath =
|
|
41614
|
+
const legacyLauncherPath = join17(
|
|
38601
41615
|
this.input.home,
|
|
38602
41616
|
".local",
|
|
38603
41617
|
"bin",
|
|
38604
41618
|
"deepline"
|
|
38605
41619
|
);
|
|
38606
|
-
const installerCommandPath = this.input.fileSystem.read(
|
|
41620
|
+
const installerCommandPath = this.input.fileSystem.read(join17(hostDir, "sdk", ".command-path")).trim();
|
|
38607
41621
|
const ownedInstallerCommand = isOwnedInstallerCommandPath({
|
|
38608
41622
|
hostDir,
|
|
38609
41623
|
commandPath: installerCommandPath
|
|
@@ -38611,16 +41625,16 @@ var CliInstallation = class _CliInstallation {
|
|
|
38611
41625
|
const legacyLauncher = this.launcher(legacyLauncherPath);
|
|
38612
41626
|
const candidates = [
|
|
38613
41627
|
...legacyLauncher.ownership === "installer_legacy" ? [legacyLauncherPath] : [],
|
|
38614
|
-
|
|
38615
|
-
|
|
38616
|
-
|
|
38617
|
-
|
|
38618
|
-
|
|
38619
|
-
|
|
38620
|
-
|
|
41628
|
+
join17(this.input.home, ".local", "bin", "deepline-real"),
|
|
41629
|
+
join17(hostDir, "bin", "deepline"),
|
|
41630
|
+
join17(hostDir, "bin", "deepline-real"),
|
|
41631
|
+
join17(hostDir, "cli", ".install-method"),
|
|
41632
|
+
join17(hostDir, "cli", ".version"),
|
|
41633
|
+
join17(hostDir, "sdk", ".install-method"),
|
|
41634
|
+
join17(hostDir, "sdk", ".command-path"),
|
|
38621
41635
|
...ownedInstallerCommand ? [
|
|
38622
41636
|
installerCommandPath,
|
|
38623
|
-
|
|
41637
|
+
join17(dirname13(installerCommandPath), "deepline-sdk")
|
|
38624
41638
|
] : []
|
|
38625
41639
|
];
|
|
38626
41640
|
return {
|
|
@@ -38644,8 +41658,8 @@ function isOwnedInstallerCommandPath(input2) {
|
|
|
38644
41658
|
if (!input2.commandPath || basename6(input2.commandPath) !== "deepline") {
|
|
38645
41659
|
return false;
|
|
38646
41660
|
}
|
|
38647
|
-
const commandPath =
|
|
38648
|
-
const fromHost =
|
|
41661
|
+
const commandPath = resolve16(input2.commandPath);
|
|
41662
|
+
const fromHost = relative6(resolve16(input2.hostDir), commandPath);
|
|
38649
41663
|
return fromHost !== "" && fromHost !== ".." && !fromHost.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`);
|
|
38650
41664
|
}
|
|
38651
41665
|
|
|
@@ -38653,7 +41667,7 @@ function isOwnedInstallerCommandPath(input2) {
|
|
|
38653
41667
|
import { spawn as spawn3 } from "child_process";
|
|
38654
41668
|
import { existsSync as existsSync14, mkdirSync as mkdirSync11, readFileSync as readFileSync15, writeFileSync as writeFileSync15 } from "fs";
|
|
38655
41669
|
import { homedir as homedir8 } from "os";
|
|
38656
|
-
import { dirname as dirname15, join as
|
|
41670
|
+
import { dirname as dirname15, join as join19 } from "path";
|
|
38657
41671
|
|
|
38658
41672
|
// contracts/install-commands.json
|
|
38659
41673
|
var install_commands_default = {
|
|
@@ -38763,7 +41777,7 @@ function buildSkillsAddArgs(baseUrl, skillName, options = {}) {
|
|
|
38763
41777
|
|
|
38764
41778
|
// src/cli/skills-sync.ts
|
|
38765
41779
|
import { spawn as spawn2, spawnSync } from "child_process";
|
|
38766
|
-
import { randomUUID as
|
|
41780
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
38767
41781
|
import {
|
|
38768
41782
|
appendFileSync,
|
|
38769
41783
|
existsSync as existsSync13,
|
|
@@ -38774,7 +41788,7 @@ import {
|
|
|
38774
41788
|
unlinkSync as unlinkSync2,
|
|
38775
41789
|
writeFileSync as writeFileSync14
|
|
38776
41790
|
} from "fs";
|
|
38777
|
-
import { dirname as dirname14, join as
|
|
41791
|
+
import { dirname as dirname14, join as join18 } from "path";
|
|
38778
41792
|
|
|
38779
41793
|
// src/cli/windows-arg-escape.ts
|
|
38780
41794
|
var CMD_META_CHARS = /([()\][%!^"`<>&|;, *?])/g;
|
|
@@ -39137,7 +42151,7 @@ function shouldSkipSkillsSync() {
|
|
|
39137
42151
|
return value === "1" || value === "true" || value === "yes" || value === "on";
|
|
39138
42152
|
}
|
|
39139
42153
|
function unavailableSkillsNoticePath(baseUrl) {
|
|
39140
|
-
return
|
|
42154
|
+
return join18(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
|
|
39141
42155
|
}
|
|
39142
42156
|
var SKILLS_SYNC_IN_PROGRESS_TTL_MS = 10 * 60 * 1e3;
|
|
39143
42157
|
var SKILLS_SYNC_IN_PROGRESS_PID_CAP_MS = 6 * 60 * 60 * 1e3;
|
|
@@ -39147,21 +42161,21 @@ function sortedLeaseAgents(agents) {
|
|
|
39147
42161
|
return [...new Set(expanded)].sort((a, b) => a.localeCompare(b));
|
|
39148
42162
|
}
|
|
39149
42163
|
function inProgressSkillsSyncPath(baseUrl, agent) {
|
|
39150
|
-
return
|
|
42164
|
+
return join18(
|
|
39151
42165
|
sdkCliStateDirPath(baseUrl),
|
|
39152
42166
|
`skills-sync-in-progress-${agentLeaseSegment(agent)}`
|
|
39153
42167
|
);
|
|
39154
42168
|
}
|
|
39155
42169
|
function readInProgressSkillsSyncLeaseFromDir(dir) {
|
|
39156
|
-
const claim = readMarkedSkillsSyncVersion(
|
|
42170
|
+
const claim = readMarkedSkillsSyncVersion(join18(dir, "claim"));
|
|
39157
42171
|
const [version = "", startedAt = ""] = claim.split(" ");
|
|
39158
|
-
const pidRaw = readMarkedSkillsSyncVersion(
|
|
42172
|
+
const pidRaw = readMarkedSkillsSyncVersion(join18(dir, "pid"));
|
|
39159
42173
|
return {
|
|
39160
42174
|
claimToken: version && startedAt ? `${version} ${startedAt}` : "",
|
|
39161
42175
|
version,
|
|
39162
42176
|
startedAt: Number(startedAt),
|
|
39163
42177
|
pid: /^\d+$/.test(pidRaw) ? Number(pidRaw) : null,
|
|
39164
|
-
owner: readMarkedSkillsSyncVersion(
|
|
42178
|
+
owner: readMarkedSkillsSyncVersion(join18(dir, "owner"))
|
|
39165
42179
|
};
|
|
39166
42180
|
}
|
|
39167
42181
|
function readInProgressSkillsSyncLease(baseUrl, agent) {
|
|
@@ -39219,9 +42233,9 @@ function claimOneInProgressSkillsSync(baseUrl, remoteVersion, agent, owner) {
|
|
|
39219
42233
|
const claimToken = `${remoteVersion} ${Date.now()}`;
|
|
39220
42234
|
const staging = `${dir}.staging-${process.pid}-${Date.now()}`;
|
|
39221
42235
|
mkdirSync10(staging);
|
|
39222
|
-
writeFileSync14(
|
|
42236
|
+
writeFileSync14(join18(staging, "claim"), `${claimToken}
|
|
39223
42237
|
`, "utf-8");
|
|
39224
|
-
writeFileSync14(
|
|
42238
|
+
writeFileSync14(join18(staging, "owner"), `${owner}
|
|
39225
42239
|
`, "utf-8");
|
|
39226
42240
|
try {
|
|
39227
42241
|
renameSync(staging, dir);
|
|
@@ -39256,7 +42270,7 @@ function claimOneInProgressSkillsSync(baseUrl, remoteVersion, agent, owner) {
|
|
|
39256
42270
|
}
|
|
39257
42271
|
function claimInProgressSkillsSync(baseUrl, remoteVersion, agents) {
|
|
39258
42272
|
const claimTokens = /* @__PURE__ */ new Map();
|
|
39259
|
-
const owner =
|
|
42273
|
+
const owner = randomUUID8();
|
|
39260
42274
|
for (const agent of sortedLeaseAgents(agents)) {
|
|
39261
42275
|
const claim = claimOneInProgressSkillsSync(
|
|
39262
42276
|
baseUrl,
|
|
@@ -39295,7 +42309,7 @@ function recordOwnPidOnInProgressSkillsSync(baseUrl, leases) {
|
|
|
39295
42309
|
if (!lease.claimToken) continue;
|
|
39296
42310
|
try {
|
|
39297
42311
|
writeFileSync14(
|
|
39298
|
-
|
|
42312
|
+
join18(inProgressSkillsSyncPath(baseUrl, agent), "pid"),
|
|
39299
42313
|
`${process.pid}
|
|
39300
42314
|
`,
|
|
39301
42315
|
"utf-8"
|
|
@@ -39357,14 +42371,14 @@ async function acquireSkillsInstallLease(baseUrl, agents, version, options = {
|
|
|
39357
42371
|
waited = true;
|
|
39358
42372
|
options.onWait?.();
|
|
39359
42373
|
}
|
|
39360
|
-
await new Promise((
|
|
42374
|
+
await new Promise((resolve22) => setTimeout(resolve22, pollMs));
|
|
39361
42375
|
}
|
|
39362
42376
|
}
|
|
39363
42377
|
function skillsInstallLeasePath(baseUrl, agents) {
|
|
39364
42378
|
return sortedLeaseAgents(agents).map((agent) => inProgressSkillsSyncPath(baseUrl, agent)).join(", ");
|
|
39365
42379
|
}
|
|
39366
42380
|
function deferredSkillsNoticePath(baseUrl, agents) {
|
|
39367
|
-
return
|
|
42381
|
+
return join18(
|
|
39368
42382
|
sdkCliStateDirPath(baseUrl),
|
|
39369
42383
|
`skills-sync-notice-${sortedLeaseAgents(agents).map(agentLeaseSegment).join("-")}`
|
|
39370
42384
|
);
|
|
@@ -39415,7 +42429,7 @@ function spawnDetachedSkillsSyncChild(argv, onSpawnError) {
|
|
|
39415
42429
|
child.unref();
|
|
39416
42430
|
}
|
|
39417
42431
|
function failedSkillsSyncPath(baseUrl, agents) {
|
|
39418
|
-
return
|
|
42432
|
+
return join18(
|
|
39419
42433
|
sdkCliStateDirPath(baseUrl),
|
|
39420
42434
|
`skills-sync-failed-${agents.map(agentLeaseSegment).join("-")}-version`
|
|
39421
42435
|
);
|
|
@@ -39588,7 +42602,7 @@ function resolveSkillsInstallCommands(baseUrl, skillNames = DEFAULT_SDK_SKILL_NA
|
|
|
39588
42602
|
return commands;
|
|
39589
42603
|
}
|
|
39590
42604
|
function runOneSkillsInstall(install) {
|
|
39591
|
-
return new Promise((
|
|
42605
|
+
return new Promise((resolve22) => {
|
|
39592
42606
|
const plan = resolveSkillsInstallSpawn(install);
|
|
39593
42607
|
const child = spawn2(plan.command, plan.args, {
|
|
39594
42608
|
stdio: ["ignore", "ignore", "pipe"],
|
|
@@ -39600,7 +42614,7 @@ function runOneSkillsInstall(install) {
|
|
|
39600
42614
|
stderr += chunk.toString("utf-8");
|
|
39601
42615
|
});
|
|
39602
42616
|
child.on("error", (error) => {
|
|
39603
|
-
|
|
42617
|
+
resolve22({
|
|
39604
42618
|
ok: false,
|
|
39605
42619
|
detail: `failed to start ${install.command}: ${error.message}`,
|
|
39606
42620
|
manualCommand: install.manualCommand,
|
|
@@ -39613,11 +42627,11 @@ function runOneSkillsInstall(install) {
|
|
|
39613
42627
|
});
|
|
39614
42628
|
child.on("close", (code) => {
|
|
39615
42629
|
if (code === 0) {
|
|
39616
|
-
|
|
42630
|
+
resolve22({ ok: true });
|
|
39617
42631
|
return;
|
|
39618
42632
|
}
|
|
39619
42633
|
const detail = stderr.trim();
|
|
39620
|
-
|
|
42634
|
+
resolve22({
|
|
39621
42635
|
ok: false,
|
|
39622
42636
|
detail: detail ? `${install.command}: ${detail}` : `${install.command} exited ${code}`,
|
|
39623
42637
|
manualCommand: install.manualCommand,
|
|
@@ -39913,13 +42927,13 @@ function detectSkillsAgents(input2) {
|
|
|
39913
42927
|
];
|
|
39914
42928
|
const detected = AGENT_MARKERS.filter(
|
|
39915
42929
|
(marker) => roots.some(
|
|
39916
|
-
(root) => marker.paths.some((path) => existsSync14(
|
|
42930
|
+
(root) => marker.paths.some((path) => existsSync14(join19(root, path)))
|
|
39917
42931
|
)
|
|
39918
42932
|
).map((marker) => marker.agent);
|
|
39919
42933
|
return detected.length > 0 ? detected : ["*"];
|
|
39920
42934
|
}
|
|
39921
42935
|
function skillsStatePathForScope(baseUrl, scope, root) {
|
|
39922
|
-
return scope === "local" && root ?
|
|
42936
|
+
return scope === "local" && root ? join19(root, ".deepline", "setup", "skills.json") : join19(sdkCliStateDirPath(baseUrl), "skills-install.json");
|
|
39923
42937
|
}
|
|
39924
42938
|
function buildSkillsPlan(input2) {
|
|
39925
42939
|
const scopeArgs = input2.scope === "global" ? ["--global"] : [];
|
|
@@ -39993,7 +43007,7 @@ function readSkillsInstallState(path) {
|
|
|
39993
43007
|
}
|
|
39994
43008
|
}
|
|
39995
43009
|
function runProcess(command, args, cwd) {
|
|
39996
|
-
return new Promise((
|
|
43010
|
+
return new Promise((resolve22, reject) => {
|
|
39997
43011
|
const plan = resolveShellSpawn(command, args);
|
|
39998
43012
|
const child = spawn3(plan.command, plan.args, {
|
|
39999
43013
|
cwd,
|
|
@@ -40024,7 +43038,7 @@ function runProcess(command, args, cwd) {
|
|
|
40024
43038
|
process.stderr.write(`${SKILLS_NPX_PACKAGE} exited ${code}.
|
|
40025
43039
|
`);
|
|
40026
43040
|
}
|
|
40027
|
-
|
|
43041
|
+
resolve22(code ?? 1);
|
|
40028
43042
|
});
|
|
40029
43043
|
});
|
|
40030
43044
|
}
|
|
@@ -40430,7 +43444,7 @@ function buildPendingAuthorizationOutput(input2) {
|
|
|
40430
43444
|
};
|
|
40431
43445
|
}
|
|
40432
43446
|
function setupStatePath(baseUrl, scope, root) {
|
|
40433
|
-
return scope === "local" && root ?
|
|
43447
|
+
return scope === "local" && root ? join20(root, ".deepline", "setup", "state.json") : join20(sdkCliStateDirPath(baseUrl), "setup.json");
|
|
40434
43448
|
}
|
|
40435
43449
|
async function captureStdout2(run) {
|
|
40436
43450
|
let stdout = "";
|
|
@@ -40478,7 +43492,7 @@ function resolvePathCommands(command) {
|
|
|
40478
43492
|
);
|
|
40479
43493
|
return [
|
|
40480
43494
|
...new Set(
|
|
40481
|
-
String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) =>
|
|
43495
|
+
String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => resolve17(path))
|
|
40482
43496
|
)
|
|
40483
43497
|
];
|
|
40484
43498
|
}
|
|
@@ -40511,7 +43525,7 @@ function resolvePersistentGlobalCommand(dependencies = {}) {
|
|
|
40511
43525
|
if (prefix.status !== 0) return null;
|
|
40512
43526
|
const root = String(prefix.stdout ?? "").trim();
|
|
40513
43527
|
if (!root) return null;
|
|
40514
|
-
const candidates = platform3 === "win32" ? [
|
|
43528
|
+
const candidates = platform3 === "win32" ? [join20(root, "deepline.cmd"), join20(root, "deepline")] : [join20(root, "bin", "deepline")];
|
|
40515
43529
|
return candidates.find((candidate) => pathExists(candidate)) ?? null;
|
|
40516
43530
|
}
|
|
40517
43531
|
function inspectGlobalCliAvailability(input2) {
|
|
@@ -40526,18 +43540,18 @@ function pathsResolveToSameFile(left, right) {
|
|
|
40526
43540
|
try {
|
|
40527
43541
|
return realpathSync4(left) === realpathSync4(right);
|
|
40528
43542
|
} catch {
|
|
40529
|
-
return
|
|
43543
|
+
return resolve17(left) === resolve17(right);
|
|
40530
43544
|
}
|
|
40531
43545
|
}
|
|
40532
43546
|
function isKnownDeeplineCommand(path) {
|
|
40533
|
-
const entrypoint = process.argv[1] ?
|
|
43547
|
+
const entrypoint = process.argv[1] ? resolve17(process.argv[1]) : "";
|
|
40534
43548
|
let resolvedPath = path;
|
|
40535
43549
|
try {
|
|
40536
43550
|
resolvedPath = realpathSync4(path);
|
|
40537
43551
|
} catch {
|
|
40538
43552
|
}
|
|
40539
43553
|
if (entrypoint && resolvedPath === entrypoint) return true;
|
|
40540
|
-
if (resolvedPath.includes(`${
|
|
43554
|
+
if (resolvedPath.includes(`${join20("node_modules", "deepline")}`)) return true;
|
|
40541
43555
|
const content = safeRead(path);
|
|
40542
43556
|
return content.includes("node_modules/deepline") || content.includes("node_modules\\deepline") || content.includes("DEEPLINE_CONFIG_SCOPE") || content.includes("deepline-real");
|
|
40543
43557
|
}
|
|
@@ -40547,7 +43561,7 @@ function inspectPathConflict() {
|
|
|
40547
43561
|
try {
|
|
40548
43562
|
if (lstatSync2(commandPath).isSymbolicLink()) {
|
|
40549
43563
|
const target = realpathSync4(commandPath);
|
|
40550
|
-
if (target.includes(`${
|
|
43564
|
+
if (target.includes(`${join20("node_modules", "deepline")}`)) return null;
|
|
40551
43565
|
}
|
|
40552
43566
|
} catch {
|
|
40553
43567
|
}
|
|
@@ -40596,7 +43610,7 @@ function failSetupPhase(phases, phase, code) {
|
|
|
40596
43610
|
phases[phase] = { status: "failed", code };
|
|
40597
43611
|
}
|
|
40598
43612
|
function rollbackCommand(scope, root) {
|
|
40599
|
-
const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify(
|
|
43613
|
+
const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify(join20(root, ".deepline", "runtime"))}` : "";
|
|
40600
43614
|
return `npm install -g${prefix} --no-audit --no-fund --include=optional deepline@${SDK_VERSION}`;
|
|
40601
43615
|
}
|
|
40602
43616
|
function setupResumeCommand(baseUrl, scope) {
|
|
@@ -40683,12 +43697,12 @@ function buildDoctorAssessment(input2) {
|
|
|
40683
43697
|
const connected = input2.authStatus.payload?.connected === true;
|
|
40684
43698
|
const authScopeOk = input2.scope === "local" ? Boolean(projectAuth) : Boolean(apiKey && !projectAuth);
|
|
40685
43699
|
const skillsOk = skillsState?.scope === input2.scope && typeof skillsState.skillsVersion === "string" && Array.isArray(skillsState.agents) && skillsState.agents.length > 0;
|
|
40686
|
-
const runningCliPath = process.argv[1] ?
|
|
43700
|
+
const runningCliPath = process.argv[1] ? resolve17(process.argv[1]) : null;
|
|
40687
43701
|
const globalCli = input2.scope === "global" ? inspectGlobalCliAvailability() : null;
|
|
40688
43702
|
const pathGlobalCli = globalCli?.path ?? null;
|
|
40689
43703
|
const cliPath = input2.scope === "global" ? pathGlobalCli : runningCliPath;
|
|
40690
43704
|
const cliScopeOk = input2.scope === "global" ? Boolean(pathGlobalCli) : Boolean(
|
|
40691
|
-
input2.root && runningCliPath?.includes(
|
|
43705
|
+
input2.root && runningCliPath?.includes(join20(input2.root, ".deepline", "runtime"))
|
|
40692
43706
|
);
|
|
40693
43707
|
const checks = {
|
|
40694
43708
|
cli: {
|
|
@@ -41230,7 +44244,7 @@ import {
|
|
|
41230
44244
|
writeFileSync as writeFileSync17
|
|
41231
44245
|
} from "fs";
|
|
41232
44246
|
import { homedir as homedir10 } from "os";
|
|
41233
|
-
import { dirname as dirname17, join as
|
|
44247
|
+
import { dirname as dirname17, join as join21 } from "path";
|
|
41234
44248
|
var UPDATE_PREFERENCES_SCHEMA_VERSION = 1;
|
|
41235
44249
|
var CLI_UPDATE_MESSAGES = [
|
|
41236
44250
|
{
|
|
@@ -41259,7 +44273,7 @@ function unreadablePreferences(path, error) {
|
|
|
41259
44273
|
};
|
|
41260
44274
|
}
|
|
41261
44275
|
function cliUpdatePreferencesPath(homeDir2 = homedir10()) {
|
|
41262
|
-
return
|
|
44276
|
+
return join21(
|
|
41263
44277
|
homeDir2,
|
|
41264
44278
|
".local",
|
|
41265
44279
|
"deepline",
|
|
@@ -41361,15 +44375,15 @@ import {
|
|
|
41361
44375
|
basename as basename7,
|
|
41362
44376
|
dirname as dirname18,
|
|
41363
44377
|
isAbsolute as isAbsolute7,
|
|
41364
|
-
join as
|
|
41365
|
-
relative as
|
|
41366
|
-
resolve as
|
|
44378
|
+
join as join23,
|
|
44379
|
+
relative as relative8,
|
|
44380
|
+
resolve as resolve19
|
|
41367
44381
|
} from "path";
|
|
41368
44382
|
|
|
41369
44383
|
// src/cli/install-integrity.ts
|
|
41370
44384
|
import { createRequire } from "module";
|
|
41371
44385
|
import { existsSync as existsSync17, readFileSync as readFileSync18, statSync as statSync5 } from "fs";
|
|
41372
|
-
import { isAbsolute as isAbsolute6, join as
|
|
44386
|
+
import { isAbsolute as isAbsolute6, join as join22, relative as relative7, resolve as resolve18 } from "path";
|
|
41373
44387
|
var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
|
|
41374
44388
|
"dist/cli/index.mjs",
|
|
41375
44389
|
"dist/index.mjs",
|
|
@@ -41396,8 +44410,8 @@ function safeRelativePath(value) {
|
|
|
41396
44410
|
}
|
|
41397
44411
|
function resolveContainedPath(root, value) {
|
|
41398
44412
|
if (!safeRelativePath(value)) return null;
|
|
41399
|
-
const target =
|
|
41400
|
-
const relativeTarget =
|
|
44413
|
+
const target = resolve18(root, value);
|
|
44414
|
+
const relativeTarget = relative7(resolve18(root), target);
|
|
41401
44415
|
if (!relativeTarget || relativeTarget.startsWith("..") || isAbsolute6(relativeTarget)) {
|
|
41402
44416
|
return null;
|
|
41403
44417
|
}
|
|
@@ -41414,7 +44428,7 @@ function isFile(path) {
|
|
|
41414
44428
|
}
|
|
41415
44429
|
}
|
|
41416
44430
|
function readManifest(packageRoot) {
|
|
41417
|
-
const packageJsonPath =
|
|
44431
|
+
const packageJsonPath = join22(packageRoot, "package.json");
|
|
41418
44432
|
let packageJson;
|
|
41419
44433
|
try {
|
|
41420
44434
|
packageJson = parseJson(packageJsonPath);
|
|
@@ -41488,8 +44502,8 @@ function readManifest(packageRoot) {
|
|
|
41488
44502
|
return { mode: "manifest", manifest };
|
|
41489
44503
|
}
|
|
41490
44504
|
function inspectSdkSidecarInstall(versionDir) {
|
|
41491
|
-
const nodeModulesRoot =
|
|
41492
|
-
const packageRoot =
|
|
44505
|
+
const nodeModulesRoot = join22(versionDir, "node_modules");
|
|
44506
|
+
const packageRoot = join22(nodeModulesRoot, "deepline");
|
|
41493
44507
|
const manifestResult = readManifest(packageRoot);
|
|
41494
44508
|
if ("invalidReason" in manifestResult) {
|
|
41495
44509
|
return {
|
|
@@ -41500,8 +44514,8 @@ function inspectSdkSidecarInstall(versionDir) {
|
|
|
41500
44514
|
};
|
|
41501
44515
|
}
|
|
41502
44516
|
const missing = [
|
|
41503
|
-
...manifestResult.manifest.packageFiles.filter((path) => !isFile(
|
|
41504
|
-
...manifestResult.manifest.dependencyFiles.filter((path) => !isFile(
|
|
44517
|
+
...manifestResult.manifest.packageFiles.filter((path) => !isFile(join22(packageRoot, path))).map((path) => `deepline/${path}`),
|
|
44518
|
+
...manifestResult.manifest.dependencyFiles.filter((path) => !isFile(join22(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
|
|
41505
44519
|
];
|
|
41506
44520
|
return {
|
|
41507
44521
|
ok: missing.length === 0,
|
|
@@ -41512,7 +44526,7 @@ function inspectSdkSidecarInstall(versionDir) {
|
|
|
41512
44526
|
}
|
|
41513
44527
|
function probeSdkSidecarEsbuild(versionDir) {
|
|
41514
44528
|
try {
|
|
41515
|
-
const requireFromInstall = createRequire(
|
|
44529
|
+
const requireFromInstall = createRequire(join22(versionDir, "package.json"));
|
|
41516
44530
|
const esbuild = requireFromInstall("esbuild");
|
|
41517
44531
|
if (typeof esbuild.transformSync !== "function") {
|
|
41518
44532
|
return "esbuild does not export transformSync";
|
|
@@ -41581,7 +44595,7 @@ function sidecarStateDir(input2) {
|
|
|
41581
44595
|
if (!scope || scope.includes("/") || scope.includes("\\")) {
|
|
41582
44596
|
return null;
|
|
41583
44597
|
}
|
|
41584
|
-
return
|
|
44598
|
+
return join23(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
|
|
41585
44599
|
}
|
|
41586
44600
|
function sidecarRegistryUrl(hostUrl) {
|
|
41587
44601
|
let url;
|
|
@@ -41616,19 +44630,19 @@ function readOptionalText(path) {
|
|
|
41616
44630
|
function resolvePythonSidecarUpdatePlan(options) {
|
|
41617
44631
|
const stateDir = sidecarStateDir(options);
|
|
41618
44632
|
if (!stateDir) return null;
|
|
41619
|
-
const relativeEntrypoint =
|
|
41620
|
-
|
|
41621
|
-
|
|
44633
|
+
const relativeEntrypoint = relative8(
|
|
44634
|
+
resolve19(stateDir),
|
|
44635
|
+
resolve19(options.entrypoint)
|
|
41622
44636
|
);
|
|
41623
44637
|
if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || isAbsolute7(relativeEntrypoint)) {
|
|
41624
44638
|
return null;
|
|
41625
44639
|
}
|
|
41626
|
-
const installMethod = readOptionalText(
|
|
44640
|
+
const installMethod = readOptionalText(join23(stateDir, ".install-method"));
|
|
41627
44641
|
if (installMethod !== "python-sidecar") return null;
|
|
41628
44642
|
const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
|
|
41629
44643
|
const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
|
|
41630
|
-
const nodeBin = readOptionalText(
|
|
41631
|
-
const sidecarPath = readOptionalText(
|
|
44644
|
+
const nodeBin = readOptionalText(join23(stateDir, ".node-bin")) || process.execPath;
|
|
44645
|
+
const sidecarPath = readOptionalText(join23(stateDir, ".command-path")) || join23(
|
|
41632
44646
|
stateDir,
|
|
41633
44647
|
"bin",
|
|
41634
44648
|
process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
|
|
@@ -41636,7 +44650,7 @@ function resolvePythonSidecarUpdatePlan(options) {
|
|
|
41636
44650
|
const packageSpec = options.packageSpec || "deepline@latest";
|
|
41637
44651
|
const npmCommand = "npm";
|
|
41638
44652
|
const registryUrl = sidecarRegistryUrl(hostUrl);
|
|
41639
|
-
const versionDir =
|
|
44653
|
+
const versionDir = join23(stateDir, "versions", "<version>");
|
|
41640
44654
|
const manualCommand = `${buildSidecarProjectConfigCommand(versionDir, nodeBin)} && ${npmCommand} install --prefix ${shellQuote5(versionDir)} --registry ${shellQuote5(registryUrl)} ${NPM_SDK_INSTALL_COMMON_FLAGS.map(shellQuote5).join(" ")} ${shellQuote5(packageSpec)}`;
|
|
41641
44655
|
return {
|
|
41642
44656
|
kind: "python-sidecar",
|
|
@@ -41652,13 +44666,13 @@ function resolvePythonSidecarUpdatePlan(options) {
|
|
|
41652
44666
|
};
|
|
41653
44667
|
}
|
|
41654
44668
|
function findRepoBackedSdkRoot(startPath) {
|
|
41655
|
-
let current =
|
|
44669
|
+
let current = resolve19(startPath);
|
|
41656
44670
|
while (true) {
|
|
41657
|
-
if (existsSync18(
|
|
44671
|
+
if (existsSync18(join23(current, "package.json")) && existsSync18(join23(current, "bin", "deepline-dev.ts"))) {
|
|
41658
44672
|
const parent2 = dirname18(current);
|
|
41659
44673
|
return basename7(parent2) === "packages" && basename7(current) === "sdk" ? dirname18(parent2) : parent2;
|
|
41660
44674
|
}
|
|
41661
|
-
if (existsSync18(
|
|
44675
|
+
if (existsSync18(join23(current, "sdk", "package.json")) && existsSync18(join23(current, "sdk", "bin", "deepline-dev.ts"))) {
|
|
41662
44676
|
return current;
|
|
41663
44677
|
}
|
|
41664
44678
|
const parent = dirname18(current);
|
|
@@ -41671,7 +44685,7 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint, env) {
|
|
|
41671
44685
|
try {
|
|
41672
44686
|
return realpathSync5(entrypoint);
|
|
41673
44687
|
} catch {
|
|
41674
|
-
return
|
|
44688
|
+
return resolve19(entrypoint);
|
|
41675
44689
|
}
|
|
41676
44690
|
})();
|
|
41677
44691
|
const parts = normalized.split(/[\\/]+/);
|
|
@@ -41686,10 +44700,10 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint, env) {
|
|
|
41686
44700
|
const directPrefix = prefixParts.join("/").toLowerCase();
|
|
41687
44701
|
const knownWindowsPrefixes = [
|
|
41688
44702
|
env.npm_config_prefix,
|
|
41689
|
-
env.APPDATA ?
|
|
41690
|
-
].filter((value) => Boolean(value)).map((value) =>
|
|
44703
|
+
env.APPDATA ? join23(env.APPDATA, "npm") : void 0
|
|
44704
|
+
].filter((value) => Boolean(value)).map((value) => resolve19(value).replace(/\\/g, "/").toLowerCase());
|
|
41691
44705
|
if (!knownWindowsPrefixes.includes(
|
|
41692
|
-
|
|
44706
|
+
resolve19(directPrefix).replace(/\\/g, "/").toLowerCase()
|
|
41693
44707
|
)) {
|
|
41694
44708
|
return null;
|
|
41695
44709
|
}
|
|
@@ -41702,9 +44716,9 @@ function normalizedNpmPrefix(value) {
|
|
|
41702
44716
|
if (!trimmed) return null;
|
|
41703
44717
|
const normalized = (() => {
|
|
41704
44718
|
try {
|
|
41705
|
-
return realpathSync5(
|
|
44719
|
+
return realpathSync5(resolve19(trimmed));
|
|
41706
44720
|
} catch {
|
|
41707
|
-
return
|
|
44721
|
+
return resolve19(trimmed);
|
|
41708
44722
|
}
|
|
41709
44723
|
})().replace(/\\/g, "/");
|
|
41710
44724
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
@@ -41729,7 +44743,7 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
|
|
|
41729
44743
|
try {
|
|
41730
44744
|
return realpathSync5(entrypoint);
|
|
41731
44745
|
} catch {
|
|
41732
|
-
return
|
|
44746
|
+
return resolve19(entrypoint);
|
|
41733
44747
|
}
|
|
41734
44748
|
})();
|
|
41735
44749
|
const parts = normalized.split(/[\\/]+/);
|
|
@@ -41739,7 +44753,7 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
|
|
|
41739
44753
|
function resolveUpdatePlan(options = {}) {
|
|
41740
44754
|
const env = options.env ?? process.env;
|
|
41741
44755
|
const homeDir2 = options.homeDir ?? homedir11();
|
|
41742
|
-
const entrypoint = options.entrypoint ?? (process.argv[1] ?
|
|
44756
|
+
const entrypoint = options.entrypoint ?? (process.argv[1] ? resolve19(process.argv[1]) : "");
|
|
41743
44757
|
const sourceRoot = entrypoint ? findRepoBackedSdkRoot(dirname18(entrypoint)) : null;
|
|
41744
44758
|
if (sourceRoot) {
|
|
41745
44759
|
return {
|
|
@@ -41791,9 +44805,9 @@ var AUTO_UPDATE_FAILURE_FILE = ".auto-update-failure.json";
|
|
|
41791
44805
|
function autoUpdateFailurePath(plan) {
|
|
41792
44806
|
if (plan.kind === "source" || plan.kind === "homebrew") return null;
|
|
41793
44807
|
if (plan.kind === "python-sidecar") {
|
|
41794
|
-
return
|
|
44808
|
+
return join23(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
|
|
41795
44809
|
}
|
|
41796
|
-
return
|
|
44810
|
+
return join23(
|
|
41797
44811
|
homedir11(),
|
|
41798
44812
|
".local",
|
|
41799
44813
|
"deepline",
|
|
@@ -41880,7 +44894,7 @@ function safeVersionSegment(value) {
|
|
|
41880
44894
|
return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
|
|
41881
44895
|
}
|
|
41882
44896
|
function entryPathInVersionDir(versionDir) {
|
|
41883
|
-
return
|
|
44897
|
+
return join23(
|
|
41884
44898
|
versionDir,
|
|
41885
44899
|
"node_modules",
|
|
41886
44900
|
"deepline",
|
|
@@ -41890,7 +44904,7 @@ function entryPathInVersionDir(versionDir) {
|
|
|
41890
44904
|
);
|
|
41891
44905
|
}
|
|
41892
44906
|
function installedPackageVersion(versionDir) {
|
|
41893
|
-
const packageJsonPath =
|
|
44907
|
+
const packageJsonPath = join23(
|
|
41894
44908
|
versionDir,
|
|
41895
44909
|
"node_modules",
|
|
41896
44910
|
"deepline",
|
|
@@ -42018,10 +45032,10 @@ function writeSidecarLauncher(input2) {
|
|
|
42018
45032
|
const esbuildProbe = "const {createRequire}=require('node:module');const path=require('node:path');const req=createRequire(path.join(process.argv[1],'package.json'));const result=req('esbuild').transformSync('const value: number = 1;',{loader:'ts'});if(!result||typeof result.code!=='string')process.exit(3);";
|
|
42019
45033
|
const criticalPaths = [
|
|
42020
45034
|
...SDK_SIDECAR_CRITICAL_PACKAGE_FILES.map(
|
|
42021
|
-
(path) =>
|
|
45035
|
+
(path) => join23(packageRoot, path)
|
|
42022
45036
|
),
|
|
42023
45037
|
...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES.map(
|
|
42024
|
-
(path) =>
|
|
45038
|
+
(path) => join23(versionDir, "node_modules", path)
|
|
42025
45039
|
)
|
|
42026
45040
|
];
|
|
42027
45041
|
if (process.platform === "win32") {
|
|
@@ -42075,14 +45089,14 @@ function writeSidecarLauncher(input2) {
|
|
|
42075
45089
|
);
|
|
42076
45090
|
}
|
|
42077
45091
|
async function runPythonSidecarUpdatePlan(plan) {
|
|
42078
|
-
const versionsDir =
|
|
42079
|
-
const tempDir =
|
|
45092
|
+
const versionsDir = join23(plan.stateDir, "versions");
|
|
45093
|
+
const tempDir = join23(
|
|
42080
45094
|
versionsDir,
|
|
42081
45095
|
`.tmp-sdk-update-${process.pid}-${Date.now()}`
|
|
42082
45096
|
);
|
|
42083
45097
|
rmSync7(tempDir, { recursive: true, force: true });
|
|
42084
45098
|
mkdirSync14(tempDir, { recursive: true });
|
|
42085
|
-
writeFileSync18(
|
|
45099
|
+
writeFileSync18(join23(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
|
|
42086
45100
|
const env = {
|
|
42087
45101
|
...process.env,
|
|
42088
45102
|
PATH: `${dirname18(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
|
|
@@ -42122,7 +45136,7 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
42122
45136
|
rmSync7(tempDir, { recursive: true, force: true });
|
|
42123
45137
|
return 1;
|
|
42124
45138
|
}
|
|
42125
|
-
const finalDir =
|
|
45139
|
+
const finalDir = join23(versionsDir, installedVersion);
|
|
42126
45140
|
const finalEntryPath = entryPathInVersionDir(finalDir);
|
|
42127
45141
|
const finalFailure = sidecarInstallFailure(finalDir);
|
|
42128
45142
|
let backupDir = null;
|
|
@@ -42131,7 +45145,7 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
42131
45145
|
} else {
|
|
42132
45146
|
let shouldPublishTemp = true;
|
|
42133
45147
|
if (existsSync18(finalDir)) {
|
|
42134
|
-
backupDir =
|
|
45148
|
+
backupDir = join23(
|
|
42135
45149
|
versionsDir,
|
|
42136
45150
|
`.backup-${installedVersion}-${process.pid}-${Date.now()}`
|
|
42137
45151
|
);
|
|
@@ -42206,27 +45220,27 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
42206
45220
|
entryPath: finalEntryPath
|
|
42207
45221
|
});
|
|
42208
45222
|
writeFileSync18(
|
|
42209
|
-
|
|
45223
|
+
join23(plan.stateDir, ".version"),
|
|
42210
45224
|
`${installedVersion}
|
|
42211
45225
|
`,
|
|
42212
45226
|
"utf8"
|
|
42213
45227
|
);
|
|
42214
45228
|
writeFileSync18(
|
|
42215
|
-
|
|
45229
|
+
join23(plan.stateDir, ".install-method"),
|
|
42216
45230
|
"python-sidecar\n",
|
|
42217
45231
|
"utf8"
|
|
42218
45232
|
);
|
|
42219
45233
|
writeFileSync18(
|
|
42220
|
-
|
|
45234
|
+
join23(plan.stateDir, ".command-path"),
|
|
42221
45235
|
`${plan.sidecarPath}
|
|
42222
45236
|
`,
|
|
42223
45237
|
"utf8"
|
|
42224
45238
|
);
|
|
42225
|
-
writeFileSync18(
|
|
42226
|
-
writeFileSync18(
|
|
45239
|
+
writeFileSync18(join23(plan.stateDir, ".runner"), "node\n", "utf8");
|
|
45240
|
+
writeFileSync18(join23(plan.stateDir, ".node-bin"), `${plan.nodeBin}
|
|
42227
45241
|
`, "utf8");
|
|
42228
45242
|
writeFileSync18(
|
|
42229
|
-
|
|
45243
|
+
join23(plan.stateDir, ".entry-path"),
|
|
42230
45244
|
`${finalEntryPath}
|
|
42231
45245
|
`,
|
|
42232
45246
|
"utf8"
|
|
@@ -43283,8 +46297,8 @@ import {
|
|
|
43283
46297
|
readFileSync as readFileSync21,
|
|
43284
46298
|
writeFileSync as writeFileSync20
|
|
43285
46299
|
} from "fs";
|
|
43286
|
-
import { tmpdir as
|
|
43287
|
-
import { join as
|
|
46300
|
+
import { tmpdir as tmpdir6 } from "os";
|
|
46301
|
+
import { join as join25, resolve as resolve20 } from "path";
|
|
43288
46302
|
|
|
43289
46303
|
// src/tool-output.ts
|
|
43290
46304
|
import {
|
|
@@ -43295,7 +46309,7 @@ import {
|
|
|
43295
46309
|
writeSync
|
|
43296
46310
|
} from "fs";
|
|
43297
46311
|
import { homedir as homedir12 } from "os";
|
|
43298
|
-
import { dirname as dirname19, join as
|
|
46312
|
+
import { dirname as dirname19, join as join24 } from "path";
|
|
43299
46313
|
function isPlainObject(value) {
|
|
43300
46314
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
43301
46315
|
}
|
|
@@ -43422,18 +46436,18 @@ function projectRowOutput(conversion) {
|
|
|
43422
46436
|
};
|
|
43423
46437
|
}
|
|
43424
46438
|
function ensureOutputDir() {
|
|
43425
|
-
const outputDir =
|
|
46439
|
+
const outputDir = join24(homedir12(), ".local", "share", "deepline", "data");
|
|
43426
46440
|
mkdirSync15(outputDir, { recursive: true });
|
|
43427
46441
|
return outputDir;
|
|
43428
46442
|
}
|
|
43429
46443
|
function writeJsonOutputFile(payload, stem) {
|
|
43430
46444
|
const outputDir = ensureOutputDir();
|
|
43431
|
-
const outputPath =
|
|
46445
|
+
const outputPath = join24(outputDir, `${stem}_${Date.now()}.json`);
|
|
43432
46446
|
writeFileSync19(outputPath, JSON.stringify(payload, null, 2), "utf-8");
|
|
43433
46447
|
return outputPath;
|
|
43434
46448
|
}
|
|
43435
46449
|
function writeCsvOutputFile(rows, stem, options) {
|
|
43436
|
-
const outputPath = options?.outPath ? options.outPath :
|
|
46450
|
+
const outputPath = options?.outPath ? options.outPath : join24(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
|
|
43437
46451
|
mkdirSync15(dirname19(outputPath), { recursive: true });
|
|
43438
46452
|
const columns = columnsForRows(rows);
|
|
43439
46453
|
const escapeCell = (value) => {
|
|
@@ -45407,10 +48421,10 @@ function normalizeOutputFormat(raw) {
|
|
|
45407
48421
|
}
|
|
45408
48422
|
function resolveAtFilePath(rawPath) {
|
|
45409
48423
|
const trimmed = rawPath.trim();
|
|
45410
|
-
const resolved =
|
|
48424
|
+
const resolved = resolve20(trimmed);
|
|
45411
48425
|
if (existsSync19(resolved)) return resolved;
|
|
45412
48426
|
if (process.platform !== "win32" && trimmed.includes("\\")) {
|
|
45413
|
-
const normalized =
|
|
48427
|
+
const normalized = resolve20(trimmed.replace(/\\/g, "/"));
|
|
45414
48428
|
if (existsSync19(normalized)) return normalized;
|
|
45415
48429
|
}
|
|
45416
48430
|
return resolved;
|
|
@@ -45499,7 +48513,7 @@ function parseExecuteOptions(args) {
|
|
|
45499
48513
|
continue;
|
|
45500
48514
|
}
|
|
45501
48515
|
if ((arg === "--out" || arg === "-o") && args[index + 1]) {
|
|
45502
|
-
outPath =
|
|
48516
|
+
outPath = resolve20(args[++index]);
|
|
45503
48517
|
continue;
|
|
45504
48518
|
}
|
|
45505
48519
|
throw new Error(`Unknown option: ${arg}`);
|
|
@@ -45529,9 +48543,9 @@ function starterScriptJson(script) {
|
|
|
45529
48543
|
function seedToolListScript(input2) {
|
|
45530
48544
|
const stem = safeFileStem(input2.toolId);
|
|
45531
48545
|
const fileName = `${stem}-workflow-seed-${Date.now()}.play.ts`;
|
|
45532
|
-
const scriptDir = mkdtempSync(
|
|
48546
|
+
const scriptDir = mkdtempSync(join25(tmpdir6(), "deepline-workflow-seed-"));
|
|
45533
48547
|
chmodSync(scriptDir, 448);
|
|
45534
|
-
const scriptPath =
|
|
48548
|
+
const scriptPath = join25(scriptDir, fileName);
|
|
45535
48549
|
const projectDir = `deepline/projects/${stem}-workflow`;
|
|
45536
48550
|
const playName = `${stem}-workflow`;
|
|
45537
48551
|
const sampleRows = input2.rows.length > 0 ? `${JSON.stringify(input2.rows.slice(0, 2)).replace(/\]$/, "")}, ...]` : "[]";
|
|
@@ -45998,8 +49012,8 @@ Examples:
|
|
|
45998
49012
|
}
|
|
45999
49013
|
|
|
46000
49014
|
// src/cli/commands/workflow.ts
|
|
46001
|
-
import { mkdir as mkdir5, readFile as
|
|
46002
|
-
import { dirname as dirname20, join as
|
|
49015
|
+
import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
|
|
49016
|
+
import { dirname as dirname20, join as join26, resolve as resolve21 } from "path";
|
|
46003
49017
|
|
|
46004
49018
|
// src/cli/workflow-to-play.ts
|
|
46005
49019
|
import { createHash as createHash6 } from "crypto";
|
|
@@ -46216,7 +49230,7 @@ function readStatus(payload) {
|
|
|
46216
49230
|
}
|
|
46217
49231
|
async function readJsonOption(payload, file) {
|
|
46218
49232
|
if (file) {
|
|
46219
|
-
const raw = await
|
|
49233
|
+
const raw = await readFile6(resolve21(file), "utf8");
|
|
46220
49234
|
return JSON.parse(raw);
|
|
46221
49235
|
}
|
|
46222
49236
|
if (payload) {
|
|
@@ -46250,7 +49264,7 @@ async function transformOne(api, workflowId, outDir, publish) {
|
|
|
46250
49264
|
revision.config,
|
|
46251
49265
|
{ workflowName: workflow.name, version: revision.version }
|
|
46252
49266
|
);
|
|
46253
|
-
const file =
|
|
49267
|
+
const file = join26(resolve21(outDir), `${compiled.playName}.play.ts`);
|
|
46254
49268
|
await mkdir5(dirname20(file), { recursive: true });
|
|
46255
49269
|
await writeFile5(file, compiled.sourceCode, "utf8");
|
|
46256
49270
|
let published = false;
|
|
@@ -46631,7 +49645,7 @@ function isDowngradeAutoUpdateResponse(response) {
|
|
|
46631
49645
|
return compareSemver(target, current) < 0;
|
|
46632
49646
|
}
|
|
46633
49647
|
function relaunchCurrentCommand(plan) {
|
|
46634
|
-
return new Promise((
|
|
49648
|
+
return new Promise((resolve22) => {
|
|
46635
49649
|
const command = plan.kind === "python-sidecar" ? plan.sidecarPath : process.execPath;
|
|
46636
49650
|
const args = plan.kind === "python-sidecar" ? process.argv.slice(2) : process.argv.slice(1);
|
|
46637
49651
|
const child = spawn5(command, args, {
|
|
@@ -46647,9 +49661,9 @@ function relaunchCurrentCommand(plan) {
|
|
|
46647
49661
|
`Deepline SDK/CLI updated, but relaunch failed: ${error.message}
|
|
46648
49662
|
`
|
|
46649
49663
|
);
|
|
46650
|
-
|
|
49664
|
+
resolve22(1);
|
|
46651
49665
|
});
|
|
46652
|
-
child.on("close", (code) =>
|
|
49666
|
+
child.on("close", (code) => resolve22(code ?? 1));
|
|
46653
49667
|
});
|
|
46654
49668
|
}
|
|
46655
49669
|
async function maybeAutoUpdateAndRelaunch(response, baseUrl) {
|
|
@@ -46793,8 +49807,8 @@ function topLevelCommandKnown(program, commandName) {
|
|
|
46793
49807
|
);
|
|
46794
49808
|
}
|
|
46795
49809
|
async function runPlayRunnerHealthCheck() {
|
|
46796
|
-
const dir = await
|
|
46797
|
-
const file =
|
|
49810
|
+
const dir = await mkdtemp3(join27(tmpdir7(), "deepline-health-play-"));
|
|
49811
|
+
const file = join27(dir, "health-check.play.ts");
|
|
46798
49812
|
try {
|
|
46799
49813
|
await writeFile6(
|
|
46800
49814
|
file,
|
|
@@ -46845,7 +49859,7 @@ async function runPlayRunnerHealthCheck() {
|
|
|
46845
49859
|
}
|
|
46846
49860
|
};
|
|
46847
49861
|
} finally {
|
|
46848
|
-
await
|
|
49862
|
+
await rm4(dir, { recursive: true, force: true });
|
|
46849
49863
|
}
|
|
46850
49864
|
}
|
|
46851
49865
|
function pickString(value, ...keys) {
|