flowdular 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/dist/distribution.js +4601 -0
- package/dist/index.js +9611 -0
- package/package.json +34 -0
|
@@ -0,0 +1,4601 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js
|
|
28
|
+
var require_constants = __commonJS({
|
|
29
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js"(exports, module) {
|
|
30
|
+
"use strict";
|
|
31
|
+
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
32
|
+
var MAX_LENGTH = 256;
|
|
33
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
|
|
34
|
+
9007199254740991;
|
|
35
|
+
var MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
36
|
+
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
|
|
37
|
+
var RELEASE_TYPES = [
|
|
38
|
+
"major",
|
|
39
|
+
"premajor",
|
|
40
|
+
"minor",
|
|
41
|
+
"preminor",
|
|
42
|
+
"patch",
|
|
43
|
+
"prepatch",
|
|
44
|
+
"prerelease"
|
|
45
|
+
];
|
|
46
|
+
module.exports = {
|
|
47
|
+
MAX_LENGTH,
|
|
48
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
49
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
50
|
+
MAX_SAFE_INTEGER,
|
|
51
|
+
RELEASE_TYPES,
|
|
52
|
+
SEMVER_SPEC_VERSION,
|
|
53
|
+
FLAG_INCLUDE_PRERELEASE: 1,
|
|
54
|
+
FLAG_LOOSE: 2
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js
|
|
60
|
+
var require_debug = __commonJS({
|
|
61
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js"(exports, module) {
|
|
62
|
+
"use strict";
|
|
63
|
+
var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
|
|
64
|
+
};
|
|
65
|
+
module.exports = debug;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/re.js
|
|
70
|
+
var require_re = __commonJS({
|
|
71
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/re.js"(exports, module) {
|
|
72
|
+
"use strict";
|
|
73
|
+
var {
|
|
74
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
75
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
76
|
+
MAX_LENGTH
|
|
77
|
+
} = require_constants();
|
|
78
|
+
var debug = require_debug();
|
|
79
|
+
exports = module.exports = {};
|
|
80
|
+
var re = exports.re = [];
|
|
81
|
+
var safeRe = exports.safeRe = [];
|
|
82
|
+
var src = exports.src = [];
|
|
83
|
+
var safeSrc = exports.safeSrc = [];
|
|
84
|
+
var t = exports.t = {};
|
|
85
|
+
var R = 0;
|
|
86
|
+
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
87
|
+
var safeRegexReplacements = [
|
|
88
|
+
["\\s", 1],
|
|
89
|
+
["\\d", MAX_LENGTH],
|
|
90
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
91
|
+
];
|
|
92
|
+
var makeSafeRegex = (value) => {
|
|
93
|
+
for (const [token, max] of safeRegexReplacements) {
|
|
94
|
+
value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
95
|
+
}
|
|
96
|
+
return value;
|
|
97
|
+
};
|
|
98
|
+
var createToken = (name, value, isGlobal) => {
|
|
99
|
+
const safe = makeSafeRegex(value);
|
|
100
|
+
const index = R++;
|
|
101
|
+
debug(name, index, value);
|
|
102
|
+
t[name] = index;
|
|
103
|
+
src[index] = value;
|
|
104
|
+
safeSrc[index] = safe;
|
|
105
|
+
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
106
|
+
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
107
|
+
};
|
|
108
|
+
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
109
|
+
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
110
|
+
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
111
|
+
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
112
|
+
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
113
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
114
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
115
|
+
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
116
|
+
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
117
|
+
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
118
|
+
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
119
|
+
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
120
|
+
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
121
|
+
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
122
|
+
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
123
|
+
createToken("GTLT", "((?:<|>)?=?)");
|
|
124
|
+
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
125
|
+
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
126
|
+
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
127
|
+
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
128
|
+
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
129
|
+
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
130
|
+
createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
131
|
+
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
132
|
+
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
133
|
+
createToken("COERCERTL", src[t.COERCE], true);
|
|
134
|
+
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
135
|
+
createToken("LONETILDE", "(?:~>?)");
|
|
136
|
+
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
137
|
+
exports.tildeTrimReplace = "$1~";
|
|
138
|
+
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
139
|
+
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
140
|
+
createToken("LONECARET", "(?:\\^)");
|
|
141
|
+
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
142
|
+
exports.caretTrimReplace = "$1^";
|
|
143
|
+
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
144
|
+
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
145
|
+
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
146
|
+
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
147
|
+
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
148
|
+
exports.comparatorTrimReplace = "$1$2$3";
|
|
149
|
+
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
150
|
+
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
151
|
+
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
152
|
+
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
153
|
+
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/parse-options.js
|
|
158
|
+
var require_parse_options = __commonJS({
|
|
159
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/parse-options.js"(exports, module) {
|
|
160
|
+
"use strict";
|
|
161
|
+
var looseOption = Object.freeze({ loose: true });
|
|
162
|
+
var emptyOpts = Object.freeze({});
|
|
163
|
+
var parseOptions = (options) => {
|
|
164
|
+
if (!options) {
|
|
165
|
+
return emptyOpts;
|
|
166
|
+
}
|
|
167
|
+
if (typeof options !== "object") {
|
|
168
|
+
return looseOption;
|
|
169
|
+
}
|
|
170
|
+
return options;
|
|
171
|
+
};
|
|
172
|
+
module.exports = parseOptions;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/identifiers.js
|
|
177
|
+
var require_identifiers = __commonJS({
|
|
178
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/identifiers.js"(exports, module) {
|
|
179
|
+
"use strict";
|
|
180
|
+
var numeric = /^[0-9]+$/;
|
|
181
|
+
var compareIdentifiers = (a, b) => {
|
|
182
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
183
|
+
return a === b ? 0 : a < b ? -1 : 1;
|
|
184
|
+
}
|
|
185
|
+
const anum = numeric.test(a);
|
|
186
|
+
const bnum = numeric.test(b);
|
|
187
|
+
if (anum && bnum) {
|
|
188
|
+
a = +a;
|
|
189
|
+
b = +b;
|
|
190
|
+
}
|
|
191
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
192
|
+
};
|
|
193
|
+
var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
194
|
+
module.exports = {
|
|
195
|
+
compareIdentifiers,
|
|
196
|
+
rcompareIdentifiers
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/semver.js
|
|
202
|
+
var require_semver = __commonJS({
|
|
203
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/semver.js"(exports, module) {
|
|
204
|
+
"use strict";
|
|
205
|
+
var debug = require_debug();
|
|
206
|
+
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
207
|
+
var { safeRe: re, t } = require_re();
|
|
208
|
+
var parseOptions = require_parse_options();
|
|
209
|
+
var { compareIdentifiers } = require_identifiers();
|
|
210
|
+
var SemVer = class _SemVer {
|
|
211
|
+
constructor(version, options) {
|
|
212
|
+
options = parseOptions(options);
|
|
213
|
+
if (version instanceof _SemVer) {
|
|
214
|
+
if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
|
|
215
|
+
return version;
|
|
216
|
+
} else {
|
|
217
|
+
version = version.version;
|
|
218
|
+
}
|
|
219
|
+
} else if (typeof version !== "string") {
|
|
220
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
221
|
+
}
|
|
222
|
+
if (version.length > MAX_LENGTH) {
|
|
223
|
+
throw new TypeError(
|
|
224
|
+
`version is longer than ${MAX_LENGTH} characters`
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
debug("SemVer", version, options);
|
|
228
|
+
this.options = options;
|
|
229
|
+
this.loose = !!options.loose;
|
|
230
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
231
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
232
|
+
if (!m) {
|
|
233
|
+
throw new TypeError(`Invalid Version: ${version}`);
|
|
234
|
+
}
|
|
235
|
+
this.raw = version;
|
|
236
|
+
this.major = +m[1];
|
|
237
|
+
this.minor = +m[2];
|
|
238
|
+
this.patch = +m[3];
|
|
239
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
240
|
+
throw new TypeError("Invalid major version");
|
|
241
|
+
}
|
|
242
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
243
|
+
throw new TypeError("Invalid minor version");
|
|
244
|
+
}
|
|
245
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
246
|
+
throw new TypeError("Invalid patch version");
|
|
247
|
+
}
|
|
248
|
+
if (!m[4]) {
|
|
249
|
+
this.prerelease = [];
|
|
250
|
+
} else {
|
|
251
|
+
this.prerelease = m[4].split(".").map((id) => {
|
|
252
|
+
if (/^[0-9]+$/.test(id)) {
|
|
253
|
+
const num = +id;
|
|
254
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
255
|
+
return num;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return id;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
this.build = m[5] ? m[5].split(".") : [];
|
|
262
|
+
this.format();
|
|
263
|
+
}
|
|
264
|
+
format() {
|
|
265
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
266
|
+
if (this.prerelease.length) {
|
|
267
|
+
this.version += `-${this.prerelease.join(".")}`;
|
|
268
|
+
}
|
|
269
|
+
return this.version;
|
|
270
|
+
}
|
|
271
|
+
toString() {
|
|
272
|
+
return this.version;
|
|
273
|
+
}
|
|
274
|
+
compare(other) {
|
|
275
|
+
debug("SemVer.compare", this.version, this.options, other);
|
|
276
|
+
if (!(other instanceof _SemVer)) {
|
|
277
|
+
if (typeof other === "string" && other === this.version) {
|
|
278
|
+
return 0;
|
|
279
|
+
}
|
|
280
|
+
other = new _SemVer(other, this.options);
|
|
281
|
+
}
|
|
282
|
+
if (other.version === this.version) {
|
|
283
|
+
return 0;
|
|
284
|
+
}
|
|
285
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
286
|
+
}
|
|
287
|
+
compareMain(other) {
|
|
288
|
+
if (!(other instanceof _SemVer)) {
|
|
289
|
+
other = new _SemVer(other, this.options);
|
|
290
|
+
}
|
|
291
|
+
if (this.major < other.major) {
|
|
292
|
+
return -1;
|
|
293
|
+
}
|
|
294
|
+
if (this.major > other.major) {
|
|
295
|
+
return 1;
|
|
296
|
+
}
|
|
297
|
+
if (this.minor < other.minor) {
|
|
298
|
+
return -1;
|
|
299
|
+
}
|
|
300
|
+
if (this.minor > other.minor) {
|
|
301
|
+
return 1;
|
|
302
|
+
}
|
|
303
|
+
if (this.patch < other.patch) {
|
|
304
|
+
return -1;
|
|
305
|
+
}
|
|
306
|
+
if (this.patch > other.patch) {
|
|
307
|
+
return 1;
|
|
308
|
+
}
|
|
309
|
+
return 0;
|
|
310
|
+
}
|
|
311
|
+
comparePre(other) {
|
|
312
|
+
if (!(other instanceof _SemVer)) {
|
|
313
|
+
other = new _SemVer(other, this.options);
|
|
314
|
+
}
|
|
315
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
316
|
+
return -1;
|
|
317
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
318
|
+
return 1;
|
|
319
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
320
|
+
return 0;
|
|
321
|
+
}
|
|
322
|
+
let i = 0;
|
|
323
|
+
do {
|
|
324
|
+
const a = this.prerelease[i];
|
|
325
|
+
const b = other.prerelease[i];
|
|
326
|
+
debug("prerelease compare", i, a, b);
|
|
327
|
+
if (a === void 0 && b === void 0) {
|
|
328
|
+
return 0;
|
|
329
|
+
} else if (b === void 0) {
|
|
330
|
+
return 1;
|
|
331
|
+
} else if (a === void 0) {
|
|
332
|
+
return -1;
|
|
333
|
+
} else if (a === b) {
|
|
334
|
+
continue;
|
|
335
|
+
} else {
|
|
336
|
+
return compareIdentifiers(a, b);
|
|
337
|
+
}
|
|
338
|
+
} while (++i);
|
|
339
|
+
}
|
|
340
|
+
compareBuild(other) {
|
|
341
|
+
if (!(other instanceof _SemVer)) {
|
|
342
|
+
other = new _SemVer(other, this.options);
|
|
343
|
+
}
|
|
344
|
+
let i = 0;
|
|
345
|
+
do {
|
|
346
|
+
const a = this.build[i];
|
|
347
|
+
const b = other.build[i];
|
|
348
|
+
debug("build compare", i, a, b);
|
|
349
|
+
if (a === void 0 && b === void 0) {
|
|
350
|
+
return 0;
|
|
351
|
+
} else if (b === void 0) {
|
|
352
|
+
return 1;
|
|
353
|
+
} else if (a === void 0) {
|
|
354
|
+
return -1;
|
|
355
|
+
} else if (a === b) {
|
|
356
|
+
continue;
|
|
357
|
+
} else {
|
|
358
|
+
return compareIdentifiers(a, b);
|
|
359
|
+
}
|
|
360
|
+
} while (++i);
|
|
361
|
+
}
|
|
362
|
+
// preminor will bump the version up to the next minor release, and immediately
|
|
363
|
+
// down to pre-release. premajor and prepatch work the same way.
|
|
364
|
+
inc(release, identifier2, identifierBase) {
|
|
365
|
+
if (release.startsWith("pre")) {
|
|
366
|
+
if (!identifier2 && identifierBase === false) {
|
|
367
|
+
throw new Error("invalid increment argument: identifier is empty");
|
|
368
|
+
}
|
|
369
|
+
if (identifier2) {
|
|
370
|
+
const match = `-${identifier2}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
371
|
+
if (!match || match[1] !== identifier2) {
|
|
372
|
+
throw new Error(`invalid identifier: ${identifier2}`);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
switch (release) {
|
|
377
|
+
case "premajor":
|
|
378
|
+
this.prerelease.length = 0;
|
|
379
|
+
this.patch = 0;
|
|
380
|
+
this.minor = 0;
|
|
381
|
+
this.major++;
|
|
382
|
+
this.inc("pre", identifier2, identifierBase);
|
|
383
|
+
break;
|
|
384
|
+
case "preminor":
|
|
385
|
+
this.prerelease.length = 0;
|
|
386
|
+
this.patch = 0;
|
|
387
|
+
this.minor++;
|
|
388
|
+
this.inc("pre", identifier2, identifierBase);
|
|
389
|
+
break;
|
|
390
|
+
case "prepatch":
|
|
391
|
+
this.prerelease.length = 0;
|
|
392
|
+
this.inc("patch", identifier2, identifierBase);
|
|
393
|
+
this.inc("pre", identifier2, identifierBase);
|
|
394
|
+
break;
|
|
395
|
+
// If the input is a non-prerelease version, this acts the same as
|
|
396
|
+
// prepatch.
|
|
397
|
+
case "prerelease":
|
|
398
|
+
if (this.prerelease.length === 0) {
|
|
399
|
+
this.inc("patch", identifier2, identifierBase);
|
|
400
|
+
}
|
|
401
|
+
this.inc("pre", identifier2, identifierBase);
|
|
402
|
+
break;
|
|
403
|
+
case "release":
|
|
404
|
+
if (this.prerelease.length === 0) {
|
|
405
|
+
throw new Error(`version ${this.raw} is not a prerelease`);
|
|
406
|
+
}
|
|
407
|
+
this.prerelease.length = 0;
|
|
408
|
+
break;
|
|
409
|
+
case "major":
|
|
410
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
|
|
411
|
+
this.major++;
|
|
412
|
+
}
|
|
413
|
+
this.minor = 0;
|
|
414
|
+
this.patch = 0;
|
|
415
|
+
this.prerelease = [];
|
|
416
|
+
break;
|
|
417
|
+
case "minor":
|
|
418
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
419
|
+
this.minor++;
|
|
420
|
+
}
|
|
421
|
+
this.patch = 0;
|
|
422
|
+
this.prerelease = [];
|
|
423
|
+
break;
|
|
424
|
+
case "patch":
|
|
425
|
+
if (this.prerelease.length === 0) {
|
|
426
|
+
this.patch++;
|
|
427
|
+
}
|
|
428
|
+
this.prerelease = [];
|
|
429
|
+
break;
|
|
430
|
+
// This probably shouldn't be used publicly.
|
|
431
|
+
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
432
|
+
case "pre": {
|
|
433
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
434
|
+
if (this.prerelease.length === 0) {
|
|
435
|
+
this.prerelease = [base];
|
|
436
|
+
} else {
|
|
437
|
+
let i = this.prerelease.length;
|
|
438
|
+
while (--i >= 0) {
|
|
439
|
+
if (typeof this.prerelease[i] === "number") {
|
|
440
|
+
this.prerelease[i]++;
|
|
441
|
+
i = -2;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
if (i === -1) {
|
|
445
|
+
if (identifier2 === this.prerelease.join(".") && identifierBase === false) {
|
|
446
|
+
throw new Error("invalid increment argument: identifier already exists");
|
|
447
|
+
}
|
|
448
|
+
this.prerelease.push(base);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (identifier2) {
|
|
452
|
+
let prerelease = [identifier2, base];
|
|
453
|
+
if (identifierBase === false) {
|
|
454
|
+
prerelease = [identifier2];
|
|
455
|
+
}
|
|
456
|
+
if (compareIdentifiers(this.prerelease[0], identifier2) === 0) {
|
|
457
|
+
if (isNaN(this.prerelease[1])) {
|
|
458
|
+
this.prerelease = prerelease;
|
|
459
|
+
}
|
|
460
|
+
} else {
|
|
461
|
+
this.prerelease = prerelease;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
default:
|
|
467
|
+
throw new Error(`invalid increment argument: ${release}`);
|
|
468
|
+
}
|
|
469
|
+
this.raw = this.format();
|
|
470
|
+
if (this.build.length) {
|
|
471
|
+
this.raw += `+${this.build.join(".")}`;
|
|
472
|
+
}
|
|
473
|
+
return this;
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
module.exports = SemVer;
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/parse.js
|
|
481
|
+
var require_parse = __commonJS({
|
|
482
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/parse.js"(exports, module) {
|
|
483
|
+
"use strict";
|
|
484
|
+
var SemVer = require_semver();
|
|
485
|
+
var parse = (version, options, throwErrors = false) => {
|
|
486
|
+
if (version instanceof SemVer) {
|
|
487
|
+
return version;
|
|
488
|
+
}
|
|
489
|
+
try {
|
|
490
|
+
return new SemVer(version, options);
|
|
491
|
+
} catch (er) {
|
|
492
|
+
if (!throwErrors) {
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
throw er;
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
module.exports = parse;
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/valid.js
|
|
503
|
+
var require_valid = __commonJS({
|
|
504
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/valid.js"(exports, module) {
|
|
505
|
+
"use strict";
|
|
506
|
+
var parse = require_parse();
|
|
507
|
+
var valid2 = (version, options) => {
|
|
508
|
+
const v = parse(version, options);
|
|
509
|
+
return v ? v.version : null;
|
|
510
|
+
};
|
|
511
|
+
module.exports = valid2;
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/clean.js
|
|
516
|
+
var require_clean = __commonJS({
|
|
517
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/clean.js"(exports, module) {
|
|
518
|
+
"use strict";
|
|
519
|
+
var parse = require_parse();
|
|
520
|
+
var clean = (version, options) => {
|
|
521
|
+
const s = parse(version.trim().replace(/^[=v]+/, ""), options);
|
|
522
|
+
return s ? s.version : null;
|
|
523
|
+
};
|
|
524
|
+
module.exports = clean;
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/inc.js
|
|
529
|
+
var require_inc = __commonJS({
|
|
530
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/inc.js"(exports, module) {
|
|
531
|
+
"use strict";
|
|
532
|
+
var SemVer = require_semver();
|
|
533
|
+
var inc = (version, release, options, identifier2, identifierBase) => {
|
|
534
|
+
if (typeof options === "string") {
|
|
535
|
+
identifierBase = identifier2;
|
|
536
|
+
identifier2 = options;
|
|
537
|
+
options = void 0;
|
|
538
|
+
}
|
|
539
|
+
try {
|
|
540
|
+
return new SemVer(
|
|
541
|
+
version instanceof SemVer ? version.version : version,
|
|
542
|
+
options
|
|
543
|
+
).inc(release, identifier2, identifierBase).version;
|
|
544
|
+
} catch (er) {
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
module.exports = inc;
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/diff.js
|
|
553
|
+
var require_diff = __commonJS({
|
|
554
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/diff.js"(exports, module) {
|
|
555
|
+
"use strict";
|
|
556
|
+
var parse = require_parse();
|
|
557
|
+
var diff = (version1, version2) => {
|
|
558
|
+
const v1 = parse(version1, null, true);
|
|
559
|
+
const v2 = parse(version2, null, true);
|
|
560
|
+
const comparison = v1.compare(v2);
|
|
561
|
+
if (comparison === 0) {
|
|
562
|
+
return null;
|
|
563
|
+
}
|
|
564
|
+
const v1Higher = comparison > 0;
|
|
565
|
+
const highVersion = v1Higher ? v1 : v2;
|
|
566
|
+
const lowVersion = v1Higher ? v2 : v1;
|
|
567
|
+
const highHasPre = !!highVersion.prerelease.length;
|
|
568
|
+
const lowHasPre = !!lowVersion.prerelease.length;
|
|
569
|
+
if (lowHasPre && !highHasPre) {
|
|
570
|
+
if (!lowVersion.patch && !lowVersion.minor) {
|
|
571
|
+
return "major";
|
|
572
|
+
}
|
|
573
|
+
if (lowVersion.compareMain(highVersion) === 0) {
|
|
574
|
+
if (lowVersion.minor && !lowVersion.patch) {
|
|
575
|
+
return "minor";
|
|
576
|
+
}
|
|
577
|
+
return "patch";
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
const prefix = highHasPre ? "pre" : "";
|
|
581
|
+
if (v1.major !== v2.major) {
|
|
582
|
+
return prefix + "major";
|
|
583
|
+
}
|
|
584
|
+
if (v1.minor !== v2.minor) {
|
|
585
|
+
return prefix + "minor";
|
|
586
|
+
}
|
|
587
|
+
if (v1.patch !== v2.patch) {
|
|
588
|
+
return prefix + "patch";
|
|
589
|
+
}
|
|
590
|
+
return "prerelease";
|
|
591
|
+
};
|
|
592
|
+
module.exports = diff;
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/major.js
|
|
597
|
+
var require_major = __commonJS({
|
|
598
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/major.js"(exports, module) {
|
|
599
|
+
"use strict";
|
|
600
|
+
var SemVer = require_semver();
|
|
601
|
+
var major = (a, loose) => new SemVer(a, loose).major;
|
|
602
|
+
module.exports = major;
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/minor.js
|
|
607
|
+
var require_minor = __commonJS({
|
|
608
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/minor.js"(exports, module) {
|
|
609
|
+
"use strict";
|
|
610
|
+
var SemVer = require_semver();
|
|
611
|
+
var minor = (a, loose) => new SemVer(a, loose).minor;
|
|
612
|
+
module.exports = minor;
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/patch.js
|
|
617
|
+
var require_patch = __commonJS({
|
|
618
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/patch.js"(exports, module) {
|
|
619
|
+
"use strict";
|
|
620
|
+
var SemVer = require_semver();
|
|
621
|
+
var patch = (a, loose) => new SemVer(a, loose).patch;
|
|
622
|
+
module.exports = patch;
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/prerelease.js
|
|
627
|
+
var require_prerelease = __commonJS({
|
|
628
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/prerelease.js"(exports, module) {
|
|
629
|
+
"use strict";
|
|
630
|
+
var parse = require_parse();
|
|
631
|
+
var prerelease = (version, options) => {
|
|
632
|
+
const parsed = parse(version, options);
|
|
633
|
+
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
634
|
+
};
|
|
635
|
+
module.exports = prerelease;
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare.js
|
|
640
|
+
var require_compare = __commonJS({
|
|
641
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare.js"(exports, module) {
|
|
642
|
+
"use strict";
|
|
643
|
+
var SemVer = require_semver();
|
|
644
|
+
var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
645
|
+
module.exports = compare;
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rcompare.js
|
|
650
|
+
var require_rcompare = __commonJS({
|
|
651
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rcompare.js"(exports, module) {
|
|
652
|
+
"use strict";
|
|
653
|
+
var compare = require_compare();
|
|
654
|
+
var rcompare2 = (a, b, loose) => compare(b, a, loose);
|
|
655
|
+
module.exports = rcompare2;
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-loose.js
|
|
660
|
+
var require_compare_loose = __commonJS({
|
|
661
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-loose.js"(exports, module) {
|
|
662
|
+
"use strict";
|
|
663
|
+
var compare = require_compare();
|
|
664
|
+
var compareLoose = (a, b) => compare(a, b, true);
|
|
665
|
+
module.exports = compareLoose;
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-build.js
|
|
670
|
+
var require_compare_build = __commonJS({
|
|
671
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/compare-build.js"(exports, module) {
|
|
672
|
+
"use strict";
|
|
673
|
+
var SemVer = require_semver();
|
|
674
|
+
var compareBuild = (a, b, loose) => {
|
|
675
|
+
const versionA = new SemVer(a, loose);
|
|
676
|
+
const versionB = new SemVer(b, loose);
|
|
677
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
678
|
+
};
|
|
679
|
+
module.exports = compareBuild;
|
|
680
|
+
}
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/sort.js
|
|
684
|
+
var require_sort = __commonJS({
|
|
685
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/sort.js"(exports, module) {
|
|
686
|
+
"use strict";
|
|
687
|
+
var compareBuild = require_compare_build();
|
|
688
|
+
var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
689
|
+
module.exports = sort;
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rsort.js
|
|
694
|
+
var require_rsort = __commonJS({
|
|
695
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rsort.js"(exports, module) {
|
|
696
|
+
"use strict";
|
|
697
|
+
var compareBuild = require_compare_build();
|
|
698
|
+
var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
699
|
+
module.exports = rsort;
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gt.js
|
|
704
|
+
var require_gt = __commonJS({
|
|
705
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gt.js"(exports, module) {
|
|
706
|
+
"use strict";
|
|
707
|
+
var compare = require_compare();
|
|
708
|
+
var gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
709
|
+
module.exports = gt;
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lt.js
|
|
714
|
+
var require_lt = __commonJS({
|
|
715
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lt.js"(exports, module) {
|
|
716
|
+
"use strict";
|
|
717
|
+
var compare = require_compare();
|
|
718
|
+
var lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
719
|
+
module.exports = lt;
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
|
|
723
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/eq.js
|
|
724
|
+
var require_eq = __commonJS({
|
|
725
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/eq.js"(exports, module) {
|
|
726
|
+
"use strict";
|
|
727
|
+
var compare = require_compare();
|
|
728
|
+
var eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
729
|
+
module.exports = eq;
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/neq.js
|
|
734
|
+
var require_neq = __commonJS({
|
|
735
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/neq.js"(exports, module) {
|
|
736
|
+
"use strict";
|
|
737
|
+
var compare = require_compare();
|
|
738
|
+
var neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
739
|
+
module.exports = neq;
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gte.js
|
|
744
|
+
var require_gte = __commonJS({
|
|
745
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/gte.js"(exports, module) {
|
|
746
|
+
"use strict";
|
|
747
|
+
var compare = require_compare();
|
|
748
|
+
var gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
749
|
+
module.exports = gte;
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lte.js
|
|
754
|
+
var require_lte = __commonJS({
|
|
755
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/lte.js"(exports, module) {
|
|
756
|
+
"use strict";
|
|
757
|
+
var compare = require_compare();
|
|
758
|
+
var lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
759
|
+
module.exports = lte;
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
|
|
763
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/cmp.js
|
|
764
|
+
var require_cmp = __commonJS({
|
|
765
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/cmp.js"(exports, module) {
|
|
766
|
+
"use strict";
|
|
767
|
+
var eq = require_eq();
|
|
768
|
+
var neq = require_neq();
|
|
769
|
+
var gt = require_gt();
|
|
770
|
+
var gte = require_gte();
|
|
771
|
+
var lt = require_lt();
|
|
772
|
+
var lte = require_lte();
|
|
773
|
+
var cmp = (a, op, b, loose) => {
|
|
774
|
+
switch (op) {
|
|
775
|
+
case "===":
|
|
776
|
+
if (typeof a === "object") {
|
|
777
|
+
a = a.version;
|
|
778
|
+
}
|
|
779
|
+
if (typeof b === "object") {
|
|
780
|
+
b = b.version;
|
|
781
|
+
}
|
|
782
|
+
return a === b;
|
|
783
|
+
case "!==":
|
|
784
|
+
if (typeof a === "object") {
|
|
785
|
+
a = a.version;
|
|
786
|
+
}
|
|
787
|
+
if (typeof b === "object") {
|
|
788
|
+
b = b.version;
|
|
789
|
+
}
|
|
790
|
+
return a !== b;
|
|
791
|
+
case "":
|
|
792
|
+
case "=":
|
|
793
|
+
case "==":
|
|
794
|
+
return eq(a, b, loose);
|
|
795
|
+
case "!=":
|
|
796
|
+
return neq(a, b, loose);
|
|
797
|
+
case ">":
|
|
798
|
+
return gt(a, b, loose);
|
|
799
|
+
case ">=":
|
|
800
|
+
return gte(a, b, loose);
|
|
801
|
+
case "<":
|
|
802
|
+
return lt(a, b, loose);
|
|
803
|
+
case "<=":
|
|
804
|
+
return lte(a, b, loose);
|
|
805
|
+
default:
|
|
806
|
+
throw new TypeError(`Invalid operator: ${op}`);
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
module.exports = cmp;
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/coerce.js
|
|
814
|
+
var require_coerce = __commonJS({
|
|
815
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/coerce.js"(exports, module) {
|
|
816
|
+
"use strict";
|
|
817
|
+
var SemVer = require_semver();
|
|
818
|
+
var parse = require_parse();
|
|
819
|
+
var { safeRe: re, t } = require_re();
|
|
820
|
+
var coerce = (version, options) => {
|
|
821
|
+
if (version instanceof SemVer) {
|
|
822
|
+
return version;
|
|
823
|
+
}
|
|
824
|
+
if (typeof version === "number") {
|
|
825
|
+
version = String(version);
|
|
826
|
+
}
|
|
827
|
+
if (typeof version !== "string") {
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
options = options || {};
|
|
831
|
+
let match = null;
|
|
832
|
+
if (!options.rtl) {
|
|
833
|
+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
834
|
+
} else {
|
|
835
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
836
|
+
let next;
|
|
837
|
+
while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
|
|
838
|
+
if (!match || next.index + next[0].length !== match.index + match[0].length) {
|
|
839
|
+
match = next;
|
|
840
|
+
}
|
|
841
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
842
|
+
}
|
|
843
|
+
coerceRtlRegex.lastIndex = -1;
|
|
844
|
+
}
|
|
845
|
+
if (match === null) {
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
const major = match[2];
|
|
849
|
+
const minor = match[3] || "0";
|
|
850
|
+
const patch = match[4] || "0";
|
|
851
|
+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
|
|
852
|
+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
|
|
853
|
+
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
|
|
854
|
+
};
|
|
855
|
+
module.exports = coerce;
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/lrucache.js
|
|
860
|
+
var require_lrucache = __commonJS({
|
|
861
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/lrucache.js"(exports, module) {
|
|
862
|
+
"use strict";
|
|
863
|
+
var LRUCache = class {
|
|
864
|
+
constructor() {
|
|
865
|
+
this.max = 1e3;
|
|
866
|
+
this.map = /* @__PURE__ */ new Map();
|
|
867
|
+
}
|
|
868
|
+
get(key) {
|
|
869
|
+
const value = this.map.get(key);
|
|
870
|
+
if (value === void 0) {
|
|
871
|
+
return void 0;
|
|
872
|
+
} else {
|
|
873
|
+
this.map.delete(key);
|
|
874
|
+
this.map.set(key, value);
|
|
875
|
+
return value;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
delete(key) {
|
|
879
|
+
return this.map.delete(key);
|
|
880
|
+
}
|
|
881
|
+
set(key, value) {
|
|
882
|
+
const deleted = this.delete(key);
|
|
883
|
+
if (!deleted && value !== void 0) {
|
|
884
|
+
if (this.map.size >= this.max) {
|
|
885
|
+
const firstKey = this.map.keys().next().value;
|
|
886
|
+
this.delete(firstKey);
|
|
887
|
+
}
|
|
888
|
+
this.map.set(key, value);
|
|
889
|
+
}
|
|
890
|
+
return this;
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
module.exports = LRUCache;
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
|
|
897
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/range.js
|
|
898
|
+
var require_range = __commonJS({
|
|
899
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/range.js"(exports, module) {
|
|
900
|
+
"use strict";
|
|
901
|
+
var SPACE_CHARACTERS = /\s+/g;
|
|
902
|
+
var Range = class _Range {
|
|
903
|
+
constructor(range, options) {
|
|
904
|
+
options = parseOptions(options);
|
|
905
|
+
if (range instanceof _Range) {
|
|
906
|
+
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
|
|
907
|
+
return range;
|
|
908
|
+
} else {
|
|
909
|
+
return new _Range(range.raw, options);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
if (range instanceof Comparator) {
|
|
913
|
+
this.raw = range.value;
|
|
914
|
+
this.set = [[range]];
|
|
915
|
+
this.formatted = void 0;
|
|
916
|
+
return this;
|
|
917
|
+
}
|
|
918
|
+
this.options = options;
|
|
919
|
+
this.loose = !!options.loose;
|
|
920
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
921
|
+
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
922
|
+
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
|
|
923
|
+
if (!this.set.length) {
|
|
924
|
+
throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
925
|
+
}
|
|
926
|
+
if (this.set.length > 1) {
|
|
927
|
+
const first = this.set[0];
|
|
928
|
+
this.set = this.set.filter((c) => !isNullSet(c[0]));
|
|
929
|
+
if (this.set.length === 0) {
|
|
930
|
+
this.set = [first];
|
|
931
|
+
} else if (this.set.length > 1) {
|
|
932
|
+
for (const c of this.set) {
|
|
933
|
+
if (c.length === 1 && isAny(c[0])) {
|
|
934
|
+
this.set = [c];
|
|
935
|
+
break;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
this.formatted = void 0;
|
|
941
|
+
}
|
|
942
|
+
get range() {
|
|
943
|
+
if (this.formatted === void 0) {
|
|
944
|
+
this.formatted = "";
|
|
945
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
946
|
+
if (i > 0) {
|
|
947
|
+
this.formatted += "||";
|
|
948
|
+
}
|
|
949
|
+
const comps = this.set[i];
|
|
950
|
+
for (let k = 0; k < comps.length; k++) {
|
|
951
|
+
if (k > 0) {
|
|
952
|
+
this.formatted += " ";
|
|
953
|
+
}
|
|
954
|
+
this.formatted += comps[k].toString().trim();
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
return this.formatted;
|
|
959
|
+
}
|
|
960
|
+
format() {
|
|
961
|
+
return this.range;
|
|
962
|
+
}
|
|
963
|
+
toString() {
|
|
964
|
+
return this.range;
|
|
965
|
+
}
|
|
966
|
+
parseRange(range) {
|
|
967
|
+
const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
|
|
968
|
+
const memoKey = memoOpts + ":" + range;
|
|
969
|
+
const cached = cache.get(memoKey);
|
|
970
|
+
if (cached) {
|
|
971
|
+
return cached;
|
|
972
|
+
}
|
|
973
|
+
const loose = this.options.loose;
|
|
974
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
975
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
976
|
+
debug("hyphen replace", range);
|
|
977
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
978
|
+
debug("comparator trim", range);
|
|
979
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
980
|
+
debug("tilde trim", range);
|
|
981
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
982
|
+
debug("caret trim", range);
|
|
983
|
+
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
984
|
+
if (loose) {
|
|
985
|
+
rangeList = rangeList.filter((comp) => {
|
|
986
|
+
debug("loose invalid filter", comp, this.options);
|
|
987
|
+
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
debug("range list", rangeList);
|
|
991
|
+
const rangeMap = /* @__PURE__ */ new Map();
|
|
992
|
+
const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
993
|
+
for (const comp of comparators) {
|
|
994
|
+
if (isNullSet(comp)) {
|
|
995
|
+
return [comp];
|
|
996
|
+
}
|
|
997
|
+
rangeMap.set(comp.value, comp);
|
|
998
|
+
}
|
|
999
|
+
if (rangeMap.size > 1 && rangeMap.has("")) {
|
|
1000
|
+
rangeMap.delete("");
|
|
1001
|
+
}
|
|
1002
|
+
const result = [...rangeMap.values()];
|
|
1003
|
+
cache.set(memoKey, result);
|
|
1004
|
+
return result;
|
|
1005
|
+
}
|
|
1006
|
+
intersects(range, options) {
|
|
1007
|
+
if (!(range instanceof _Range)) {
|
|
1008
|
+
throw new TypeError("a Range is required");
|
|
1009
|
+
}
|
|
1010
|
+
return this.set.some((thisComparators) => {
|
|
1011
|
+
return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
|
|
1012
|
+
return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
|
|
1013
|
+
return rangeComparators.every((rangeComparator) => {
|
|
1014
|
+
return thisComparator.intersects(rangeComparator, options);
|
|
1015
|
+
});
|
|
1016
|
+
});
|
|
1017
|
+
});
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
// if ANY of the sets match ALL of its comparators, then pass
|
|
1021
|
+
test(version) {
|
|
1022
|
+
if (!version) {
|
|
1023
|
+
return false;
|
|
1024
|
+
}
|
|
1025
|
+
if (typeof version === "string") {
|
|
1026
|
+
try {
|
|
1027
|
+
version = new SemVer(version, this.options);
|
|
1028
|
+
} catch (er) {
|
|
1029
|
+
return false;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
1033
|
+
if (testSet(this.set[i], version, this.options)) {
|
|
1034
|
+
return true;
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
return false;
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
module.exports = Range;
|
|
1041
|
+
var LRU = require_lrucache();
|
|
1042
|
+
var cache = new LRU();
|
|
1043
|
+
var parseOptions = require_parse_options();
|
|
1044
|
+
var Comparator = require_comparator();
|
|
1045
|
+
var debug = require_debug();
|
|
1046
|
+
var SemVer = require_semver();
|
|
1047
|
+
var {
|
|
1048
|
+
safeRe: re,
|
|
1049
|
+
t,
|
|
1050
|
+
comparatorTrimReplace,
|
|
1051
|
+
tildeTrimReplace,
|
|
1052
|
+
caretTrimReplace
|
|
1053
|
+
} = require_re();
|
|
1054
|
+
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
|
|
1055
|
+
var isNullSet = (c) => c.value === "<0.0.0-0";
|
|
1056
|
+
var isAny = (c) => c.value === "";
|
|
1057
|
+
var isSatisfiable = (comparators, options) => {
|
|
1058
|
+
let result = true;
|
|
1059
|
+
const remainingComparators = comparators.slice();
|
|
1060
|
+
let testComparator = remainingComparators.pop();
|
|
1061
|
+
while (result && remainingComparators.length) {
|
|
1062
|
+
result = remainingComparators.every((otherComparator) => {
|
|
1063
|
+
return testComparator.intersects(otherComparator, options);
|
|
1064
|
+
});
|
|
1065
|
+
testComparator = remainingComparators.pop();
|
|
1066
|
+
}
|
|
1067
|
+
return result;
|
|
1068
|
+
};
|
|
1069
|
+
var parseComparator = (comp, options) => {
|
|
1070
|
+
comp = comp.replace(re[t.BUILD], "");
|
|
1071
|
+
debug("comp", comp, options);
|
|
1072
|
+
comp = replaceCarets(comp, options);
|
|
1073
|
+
debug("caret", comp);
|
|
1074
|
+
comp = replaceTildes(comp, options);
|
|
1075
|
+
debug("tildes", comp);
|
|
1076
|
+
comp = replaceXRanges(comp, options);
|
|
1077
|
+
debug("xrange", comp);
|
|
1078
|
+
comp = replaceStars(comp, options);
|
|
1079
|
+
debug("stars", comp);
|
|
1080
|
+
return comp;
|
|
1081
|
+
};
|
|
1082
|
+
var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
1083
|
+
var replaceTildes = (comp, options) => {
|
|
1084
|
+
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
1085
|
+
};
|
|
1086
|
+
var replaceTilde = (comp, options) => {
|
|
1087
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
1088
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1089
|
+
debug("tilde", comp, _, M, m, p, pr);
|
|
1090
|
+
let ret;
|
|
1091
|
+
if (isX(M)) {
|
|
1092
|
+
ret = "";
|
|
1093
|
+
} else if (isX(m)) {
|
|
1094
|
+
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
1095
|
+
} else if (isX(p)) {
|
|
1096
|
+
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
1097
|
+
} else if (pr) {
|
|
1098
|
+
debug("replaceTilde pr", pr);
|
|
1099
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1100
|
+
} else {
|
|
1101
|
+
ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
1102
|
+
}
|
|
1103
|
+
debug("tilde return", ret);
|
|
1104
|
+
return ret;
|
|
1105
|
+
});
|
|
1106
|
+
};
|
|
1107
|
+
var replaceCarets = (comp, options) => {
|
|
1108
|
+
return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
|
|
1109
|
+
};
|
|
1110
|
+
var replaceCaret = (comp, options) => {
|
|
1111
|
+
debug("caret", comp, options);
|
|
1112
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
1113
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
1114
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1115
|
+
debug("caret", comp, _, M, m, p, pr);
|
|
1116
|
+
let ret;
|
|
1117
|
+
if (isX(M)) {
|
|
1118
|
+
ret = "";
|
|
1119
|
+
} else if (isX(m)) {
|
|
1120
|
+
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
1121
|
+
} else if (isX(p)) {
|
|
1122
|
+
if (M === "0") {
|
|
1123
|
+
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
1124
|
+
} else {
|
|
1125
|
+
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
1126
|
+
}
|
|
1127
|
+
} else if (pr) {
|
|
1128
|
+
debug("replaceCaret pr", pr);
|
|
1129
|
+
if (M === "0") {
|
|
1130
|
+
if (m === "0") {
|
|
1131
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
1132
|
+
} else {
|
|
1133
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1134
|
+
}
|
|
1135
|
+
} else {
|
|
1136
|
+
ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
1137
|
+
}
|
|
1138
|
+
} else {
|
|
1139
|
+
debug("no pr");
|
|
1140
|
+
if (M === "0") {
|
|
1141
|
+
if (m === "0") {
|
|
1142
|
+
ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
|
|
1143
|
+
} else {
|
|
1144
|
+
ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
|
|
1145
|
+
}
|
|
1146
|
+
} else {
|
|
1147
|
+
ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
debug("caret return", ret);
|
|
1151
|
+
return ret;
|
|
1152
|
+
});
|
|
1153
|
+
};
|
|
1154
|
+
var replaceXRanges = (comp, options) => {
|
|
1155
|
+
debug("replaceXRanges", comp, options);
|
|
1156
|
+
return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
|
|
1157
|
+
};
|
|
1158
|
+
var replaceXRange = (comp, options) => {
|
|
1159
|
+
comp = comp.trim();
|
|
1160
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
1161
|
+
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
1162
|
+
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
1163
|
+
const xM = isX(M);
|
|
1164
|
+
const xm = xM || isX(m);
|
|
1165
|
+
const xp = xm || isX(p);
|
|
1166
|
+
const anyX = xp;
|
|
1167
|
+
if (gtlt === "=" && anyX) {
|
|
1168
|
+
gtlt = "";
|
|
1169
|
+
}
|
|
1170
|
+
pr = options.includePrerelease ? "-0" : "";
|
|
1171
|
+
if (xM) {
|
|
1172
|
+
if (gtlt === ">" || gtlt === "<") {
|
|
1173
|
+
ret = "<0.0.0-0";
|
|
1174
|
+
} else {
|
|
1175
|
+
ret = "*";
|
|
1176
|
+
}
|
|
1177
|
+
} else if (gtlt && anyX) {
|
|
1178
|
+
if (xm) {
|
|
1179
|
+
m = 0;
|
|
1180
|
+
}
|
|
1181
|
+
p = 0;
|
|
1182
|
+
if (gtlt === ">") {
|
|
1183
|
+
gtlt = ">=";
|
|
1184
|
+
if (xm) {
|
|
1185
|
+
M = +M + 1;
|
|
1186
|
+
m = 0;
|
|
1187
|
+
p = 0;
|
|
1188
|
+
} else {
|
|
1189
|
+
m = +m + 1;
|
|
1190
|
+
p = 0;
|
|
1191
|
+
}
|
|
1192
|
+
} else if (gtlt === "<=") {
|
|
1193
|
+
gtlt = "<";
|
|
1194
|
+
if (xm) {
|
|
1195
|
+
M = +M + 1;
|
|
1196
|
+
} else {
|
|
1197
|
+
m = +m + 1;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
if (gtlt === "<") {
|
|
1201
|
+
pr = "-0";
|
|
1202
|
+
}
|
|
1203
|
+
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
1204
|
+
} else if (xm) {
|
|
1205
|
+
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
1206
|
+
} else if (xp) {
|
|
1207
|
+
ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
1208
|
+
}
|
|
1209
|
+
debug("xRange return", ret);
|
|
1210
|
+
return ret;
|
|
1211
|
+
});
|
|
1212
|
+
};
|
|
1213
|
+
var replaceStars = (comp, options) => {
|
|
1214
|
+
debug("replaceStars", comp, options);
|
|
1215
|
+
return comp.trim().replace(re[t.STAR], "");
|
|
1216
|
+
};
|
|
1217
|
+
var replaceGTE0 = (comp, options) => {
|
|
1218
|
+
debug("replaceGTE0", comp, options);
|
|
1219
|
+
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
1220
|
+
};
|
|
1221
|
+
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
1222
|
+
if (isX(fM)) {
|
|
1223
|
+
from = "";
|
|
1224
|
+
} else if (isX(fm)) {
|
|
1225
|
+
from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
|
1226
|
+
} else if (isX(fp)) {
|
|
1227
|
+
from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
|
1228
|
+
} else if (fpr) {
|
|
1229
|
+
from = `>=${from}`;
|
|
1230
|
+
} else {
|
|
1231
|
+
from = `>=${from}${incPr ? "-0" : ""}`;
|
|
1232
|
+
}
|
|
1233
|
+
if (isX(tM)) {
|
|
1234
|
+
to = "";
|
|
1235
|
+
} else if (isX(tm)) {
|
|
1236
|
+
to = `<${+tM + 1}.0.0-0`;
|
|
1237
|
+
} else if (isX(tp)) {
|
|
1238
|
+
to = `<${tM}.${+tm + 1}.0-0`;
|
|
1239
|
+
} else if (tpr) {
|
|
1240
|
+
to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
1241
|
+
} else if (incPr) {
|
|
1242
|
+
to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
1243
|
+
} else {
|
|
1244
|
+
to = `<=${to}`;
|
|
1245
|
+
}
|
|
1246
|
+
return `${from} ${to}`.trim();
|
|
1247
|
+
};
|
|
1248
|
+
var testSet = (set, version, options) => {
|
|
1249
|
+
for (let i = 0; i < set.length; i++) {
|
|
1250
|
+
if (!set[i].test(version)) {
|
|
1251
|
+
return false;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
1255
|
+
for (let i = 0; i < set.length; i++) {
|
|
1256
|
+
debug(set[i].semver);
|
|
1257
|
+
if (set[i].semver === Comparator.ANY) {
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1260
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
1261
|
+
const allowed = set[i].semver;
|
|
1262
|
+
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
|
|
1263
|
+
return true;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
return false;
|
|
1268
|
+
}
|
|
1269
|
+
return true;
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
|
|
1274
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/comparator.js
|
|
1275
|
+
var require_comparator = __commonJS({
|
|
1276
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/comparator.js"(exports, module) {
|
|
1277
|
+
"use strict";
|
|
1278
|
+
var ANY = /* @__PURE__ */ Symbol("SemVer ANY");
|
|
1279
|
+
var Comparator = class _Comparator {
|
|
1280
|
+
static get ANY() {
|
|
1281
|
+
return ANY;
|
|
1282
|
+
}
|
|
1283
|
+
constructor(comp, options) {
|
|
1284
|
+
options = parseOptions(options);
|
|
1285
|
+
if (comp instanceof _Comparator) {
|
|
1286
|
+
if (comp.loose === !!options.loose) {
|
|
1287
|
+
return comp;
|
|
1288
|
+
} else {
|
|
1289
|
+
comp = comp.value;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
comp = comp.trim().split(/\s+/).join(" ");
|
|
1293
|
+
debug("comparator", comp, options);
|
|
1294
|
+
this.options = options;
|
|
1295
|
+
this.loose = !!options.loose;
|
|
1296
|
+
this.parse(comp);
|
|
1297
|
+
if (this.semver === ANY) {
|
|
1298
|
+
this.value = "";
|
|
1299
|
+
} else {
|
|
1300
|
+
this.value = this.operator + this.semver.version;
|
|
1301
|
+
}
|
|
1302
|
+
debug("comp", this);
|
|
1303
|
+
}
|
|
1304
|
+
parse(comp) {
|
|
1305
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
1306
|
+
const m = comp.match(r);
|
|
1307
|
+
if (!m) {
|
|
1308
|
+
throw new TypeError(`Invalid comparator: ${comp}`);
|
|
1309
|
+
}
|
|
1310
|
+
this.operator = m[1] !== void 0 ? m[1] : "";
|
|
1311
|
+
if (this.operator === "=") {
|
|
1312
|
+
this.operator = "";
|
|
1313
|
+
}
|
|
1314
|
+
if (!m[2]) {
|
|
1315
|
+
this.semver = ANY;
|
|
1316
|
+
} else {
|
|
1317
|
+
this.semver = new SemVer(m[2], this.options.loose);
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
toString() {
|
|
1321
|
+
return this.value;
|
|
1322
|
+
}
|
|
1323
|
+
test(version) {
|
|
1324
|
+
debug("Comparator.test", version, this.options.loose);
|
|
1325
|
+
if (this.semver === ANY || version === ANY) {
|
|
1326
|
+
return true;
|
|
1327
|
+
}
|
|
1328
|
+
if (typeof version === "string") {
|
|
1329
|
+
try {
|
|
1330
|
+
version = new SemVer(version, this.options);
|
|
1331
|
+
} catch (er) {
|
|
1332
|
+
return false;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
return cmp(version, this.operator, this.semver, this.options);
|
|
1336
|
+
}
|
|
1337
|
+
intersects(comp, options) {
|
|
1338
|
+
if (!(comp instanceof _Comparator)) {
|
|
1339
|
+
throw new TypeError("a Comparator is required");
|
|
1340
|
+
}
|
|
1341
|
+
if (this.operator === "") {
|
|
1342
|
+
if (this.value === "") {
|
|
1343
|
+
return true;
|
|
1344
|
+
}
|
|
1345
|
+
return new Range(comp.value, options).test(this.value);
|
|
1346
|
+
} else if (comp.operator === "") {
|
|
1347
|
+
if (comp.value === "") {
|
|
1348
|
+
return true;
|
|
1349
|
+
}
|
|
1350
|
+
return new Range(this.value, options).test(comp.semver);
|
|
1351
|
+
}
|
|
1352
|
+
options = parseOptions(options);
|
|
1353
|
+
if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
|
|
1354
|
+
return false;
|
|
1355
|
+
}
|
|
1356
|
+
if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
|
|
1357
|
+
return false;
|
|
1358
|
+
}
|
|
1359
|
+
if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
|
|
1360
|
+
return true;
|
|
1361
|
+
}
|
|
1362
|
+
if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
|
|
1363
|
+
return true;
|
|
1364
|
+
}
|
|
1365
|
+
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
|
|
1366
|
+
return true;
|
|
1367
|
+
}
|
|
1368
|
+
if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
|
|
1369
|
+
return true;
|
|
1370
|
+
}
|
|
1371
|
+
if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
|
|
1372
|
+
return true;
|
|
1373
|
+
}
|
|
1374
|
+
return false;
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
module.exports = Comparator;
|
|
1378
|
+
var parseOptions = require_parse_options();
|
|
1379
|
+
var { safeRe: re, t } = require_re();
|
|
1380
|
+
var cmp = require_cmp();
|
|
1381
|
+
var debug = require_debug();
|
|
1382
|
+
var SemVer = require_semver();
|
|
1383
|
+
var Range = require_range();
|
|
1384
|
+
}
|
|
1385
|
+
});
|
|
1386
|
+
|
|
1387
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/satisfies.js
|
|
1388
|
+
var require_satisfies = __commonJS({
|
|
1389
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/satisfies.js"(exports, module) {
|
|
1390
|
+
"use strict";
|
|
1391
|
+
var Range = require_range();
|
|
1392
|
+
var satisfies2 = (version, range, options) => {
|
|
1393
|
+
try {
|
|
1394
|
+
range = new Range(range, options);
|
|
1395
|
+
} catch (er) {
|
|
1396
|
+
return false;
|
|
1397
|
+
}
|
|
1398
|
+
return range.test(version);
|
|
1399
|
+
};
|
|
1400
|
+
module.exports = satisfies2;
|
|
1401
|
+
}
|
|
1402
|
+
});
|
|
1403
|
+
|
|
1404
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/to-comparators.js
|
|
1405
|
+
var require_to_comparators = __commonJS({
|
|
1406
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/to-comparators.js"(exports, module) {
|
|
1407
|
+
"use strict";
|
|
1408
|
+
var Range = require_range();
|
|
1409
|
+
var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
1410
|
+
module.exports = toComparators;
|
|
1411
|
+
}
|
|
1412
|
+
});
|
|
1413
|
+
|
|
1414
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/max-satisfying.js
|
|
1415
|
+
var require_max_satisfying = __commonJS({
|
|
1416
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/max-satisfying.js"(exports, module) {
|
|
1417
|
+
"use strict";
|
|
1418
|
+
var SemVer = require_semver();
|
|
1419
|
+
var Range = require_range();
|
|
1420
|
+
var maxSatisfying = (versions, range, options) => {
|
|
1421
|
+
let max = null;
|
|
1422
|
+
let maxSV = null;
|
|
1423
|
+
let rangeObj = null;
|
|
1424
|
+
try {
|
|
1425
|
+
rangeObj = new Range(range, options);
|
|
1426
|
+
} catch (er) {
|
|
1427
|
+
return null;
|
|
1428
|
+
}
|
|
1429
|
+
versions.forEach((v) => {
|
|
1430
|
+
if (rangeObj.test(v)) {
|
|
1431
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
1432
|
+
max = v;
|
|
1433
|
+
maxSV = new SemVer(max, options);
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
});
|
|
1437
|
+
return max;
|
|
1438
|
+
};
|
|
1439
|
+
module.exports = maxSatisfying;
|
|
1440
|
+
}
|
|
1441
|
+
});
|
|
1442
|
+
|
|
1443
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-satisfying.js
|
|
1444
|
+
var require_min_satisfying = __commonJS({
|
|
1445
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-satisfying.js"(exports, module) {
|
|
1446
|
+
"use strict";
|
|
1447
|
+
var SemVer = require_semver();
|
|
1448
|
+
var Range = require_range();
|
|
1449
|
+
var minSatisfying = (versions, range, options) => {
|
|
1450
|
+
let min = null;
|
|
1451
|
+
let minSV = null;
|
|
1452
|
+
let rangeObj = null;
|
|
1453
|
+
try {
|
|
1454
|
+
rangeObj = new Range(range, options);
|
|
1455
|
+
} catch (er) {
|
|
1456
|
+
return null;
|
|
1457
|
+
}
|
|
1458
|
+
versions.forEach((v) => {
|
|
1459
|
+
if (rangeObj.test(v)) {
|
|
1460
|
+
if (!min || minSV.compare(v) === 1) {
|
|
1461
|
+
min = v;
|
|
1462
|
+
minSV = new SemVer(min, options);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
return min;
|
|
1467
|
+
};
|
|
1468
|
+
module.exports = minSatisfying;
|
|
1469
|
+
}
|
|
1470
|
+
});
|
|
1471
|
+
|
|
1472
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-version.js
|
|
1473
|
+
var require_min_version = __commonJS({
|
|
1474
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/min-version.js"(exports, module) {
|
|
1475
|
+
"use strict";
|
|
1476
|
+
var SemVer = require_semver();
|
|
1477
|
+
var Range = require_range();
|
|
1478
|
+
var gt = require_gt();
|
|
1479
|
+
var minVersion = (range, loose) => {
|
|
1480
|
+
range = new Range(range, loose);
|
|
1481
|
+
let minver = new SemVer("0.0.0");
|
|
1482
|
+
if (range.test(minver)) {
|
|
1483
|
+
return minver;
|
|
1484
|
+
}
|
|
1485
|
+
minver = new SemVer("0.0.0-0");
|
|
1486
|
+
if (range.test(minver)) {
|
|
1487
|
+
return minver;
|
|
1488
|
+
}
|
|
1489
|
+
minver = null;
|
|
1490
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
1491
|
+
const comparators = range.set[i];
|
|
1492
|
+
let setMin = null;
|
|
1493
|
+
comparators.forEach((comparator) => {
|
|
1494
|
+
const compver = new SemVer(comparator.semver.version);
|
|
1495
|
+
switch (comparator.operator) {
|
|
1496
|
+
case ">":
|
|
1497
|
+
if (compver.prerelease.length === 0) {
|
|
1498
|
+
compver.patch++;
|
|
1499
|
+
} else {
|
|
1500
|
+
compver.prerelease.push(0);
|
|
1501
|
+
}
|
|
1502
|
+
compver.raw = compver.format();
|
|
1503
|
+
/* fallthrough */
|
|
1504
|
+
case "":
|
|
1505
|
+
case ">=":
|
|
1506
|
+
if (!setMin || gt(compver, setMin)) {
|
|
1507
|
+
setMin = compver;
|
|
1508
|
+
}
|
|
1509
|
+
break;
|
|
1510
|
+
case "<":
|
|
1511
|
+
case "<=":
|
|
1512
|
+
break;
|
|
1513
|
+
/* istanbul ignore next */
|
|
1514
|
+
default:
|
|
1515
|
+
throw new Error(`Unexpected operation: ${comparator.operator}`);
|
|
1516
|
+
}
|
|
1517
|
+
});
|
|
1518
|
+
if (setMin && (!minver || gt(minver, setMin))) {
|
|
1519
|
+
minver = setMin;
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
if (minver && range.test(minver)) {
|
|
1523
|
+
return minver;
|
|
1524
|
+
}
|
|
1525
|
+
return null;
|
|
1526
|
+
};
|
|
1527
|
+
module.exports = minVersion;
|
|
1528
|
+
}
|
|
1529
|
+
});
|
|
1530
|
+
|
|
1531
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/valid.js
|
|
1532
|
+
var require_valid2 = __commonJS({
|
|
1533
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/valid.js"(exports, module) {
|
|
1534
|
+
"use strict";
|
|
1535
|
+
var Range = require_range();
|
|
1536
|
+
var validRange2 = (range, options) => {
|
|
1537
|
+
try {
|
|
1538
|
+
return new Range(range, options).range || "*";
|
|
1539
|
+
} catch (er) {
|
|
1540
|
+
return null;
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1543
|
+
module.exports = validRange2;
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1546
|
+
|
|
1547
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/outside.js
|
|
1548
|
+
var require_outside = __commonJS({
|
|
1549
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/outside.js"(exports, module) {
|
|
1550
|
+
"use strict";
|
|
1551
|
+
var SemVer = require_semver();
|
|
1552
|
+
var Comparator = require_comparator();
|
|
1553
|
+
var { ANY } = Comparator;
|
|
1554
|
+
var Range = require_range();
|
|
1555
|
+
var satisfies2 = require_satisfies();
|
|
1556
|
+
var gt = require_gt();
|
|
1557
|
+
var lt = require_lt();
|
|
1558
|
+
var lte = require_lte();
|
|
1559
|
+
var gte = require_gte();
|
|
1560
|
+
var outside = (version, range, hilo, options) => {
|
|
1561
|
+
version = new SemVer(version, options);
|
|
1562
|
+
range = new Range(range, options);
|
|
1563
|
+
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
1564
|
+
switch (hilo) {
|
|
1565
|
+
case ">":
|
|
1566
|
+
gtfn = gt;
|
|
1567
|
+
ltefn = lte;
|
|
1568
|
+
ltfn = lt;
|
|
1569
|
+
comp = ">";
|
|
1570
|
+
ecomp = ">=";
|
|
1571
|
+
break;
|
|
1572
|
+
case "<":
|
|
1573
|
+
gtfn = lt;
|
|
1574
|
+
ltefn = gte;
|
|
1575
|
+
ltfn = gt;
|
|
1576
|
+
comp = "<";
|
|
1577
|
+
ecomp = "<=";
|
|
1578
|
+
break;
|
|
1579
|
+
default:
|
|
1580
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
1581
|
+
}
|
|
1582
|
+
if (satisfies2(version, range, options)) {
|
|
1583
|
+
return false;
|
|
1584
|
+
}
|
|
1585
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
1586
|
+
const comparators = range.set[i];
|
|
1587
|
+
let high = null;
|
|
1588
|
+
let low = null;
|
|
1589
|
+
comparators.forEach((comparator) => {
|
|
1590
|
+
if (comparator.semver === ANY) {
|
|
1591
|
+
comparator = new Comparator(">=0.0.0");
|
|
1592
|
+
}
|
|
1593
|
+
high = high || comparator;
|
|
1594
|
+
low = low || comparator;
|
|
1595
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
|
1596
|
+
high = comparator;
|
|
1597
|
+
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
1598
|
+
low = comparator;
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
if (high.operator === comp || high.operator === ecomp) {
|
|
1602
|
+
return false;
|
|
1603
|
+
}
|
|
1604
|
+
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
|
|
1605
|
+
return false;
|
|
1606
|
+
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
1607
|
+
return false;
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
return true;
|
|
1611
|
+
};
|
|
1612
|
+
module.exports = outside;
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
|
|
1616
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/gtr.js
|
|
1617
|
+
var require_gtr = __commonJS({
|
|
1618
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/gtr.js"(exports, module) {
|
|
1619
|
+
"use strict";
|
|
1620
|
+
var outside = require_outside();
|
|
1621
|
+
var gtr = (version, range, options) => outside(version, range, ">", options);
|
|
1622
|
+
module.exports = gtr;
|
|
1623
|
+
}
|
|
1624
|
+
});
|
|
1625
|
+
|
|
1626
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/ltr.js
|
|
1627
|
+
var require_ltr = __commonJS({
|
|
1628
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/ltr.js"(exports, module) {
|
|
1629
|
+
"use strict";
|
|
1630
|
+
var outside = require_outside();
|
|
1631
|
+
var ltr = (version, range, options) => outside(version, range, "<", options);
|
|
1632
|
+
module.exports = ltr;
|
|
1633
|
+
}
|
|
1634
|
+
});
|
|
1635
|
+
|
|
1636
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/intersects.js
|
|
1637
|
+
var require_intersects = __commonJS({
|
|
1638
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/intersects.js"(exports, module) {
|
|
1639
|
+
"use strict";
|
|
1640
|
+
var Range = require_range();
|
|
1641
|
+
var intersects = (r1, r2, options) => {
|
|
1642
|
+
r1 = new Range(r1, options);
|
|
1643
|
+
r2 = new Range(r2, options);
|
|
1644
|
+
return r1.intersects(r2, options);
|
|
1645
|
+
};
|
|
1646
|
+
module.exports = intersects;
|
|
1647
|
+
}
|
|
1648
|
+
});
|
|
1649
|
+
|
|
1650
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/simplify.js
|
|
1651
|
+
var require_simplify = __commonJS({
|
|
1652
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/simplify.js"(exports, module) {
|
|
1653
|
+
"use strict";
|
|
1654
|
+
var satisfies2 = require_satisfies();
|
|
1655
|
+
var compare = require_compare();
|
|
1656
|
+
module.exports = (versions, range, options) => {
|
|
1657
|
+
const set = [];
|
|
1658
|
+
let first = null;
|
|
1659
|
+
let prev = null;
|
|
1660
|
+
const v = versions.sort((a, b) => compare(a, b, options));
|
|
1661
|
+
for (const version of v) {
|
|
1662
|
+
const included = satisfies2(version, range, options);
|
|
1663
|
+
if (included) {
|
|
1664
|
+
prev = version;
|
|
1665
|
+
if (!first) {
|
|
1666
|
+
first = version;
|
|
1667
|
+
}
|
|
1668
|
+
} else {
|
|
1669
|
+
if (prev) {
|
|
1670
|
+
set.push([first, prev]);
|
|
1671
|
+
}
|
|
1672
|
+
prev = null;
|
|
1673
|
+
first = null;
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
if (first) {
|
|
1677
|
+
set.push([first, null]);
|
|
1678
|
+
}
|
|
1679
|
+
const ranges = [];
|
|
1680
|
+
for (const [min, max] of set) {
|
|
1681
|
+
if (min === max) {
|
|
1682
|
+
ranges.push(min);
|
|
1683
|
+
} else if (!max && min === v[0]) {
|
|
1684
|
+
ranges.push("*");
|
|
1685
|
+
} else if (!max) {
|
|
1686
|
+
ranges.push(`>=${min}`);
|
|
1687
|
+
} else if (min === v[0]) {
|
|
1688
|
+
ranges.push(`<=${max}`);
|
|
1689
|
+
} else {
|
|
1690
|
+
ranges.push(`${min} - ${max}`);
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
const simplified = ranges.join(" || ");
|
|
1694
|
+
const original = typeof range.raw === "string" ? range.raw : String(range);
|
|
1695
|
+
return simplified.length < original.length ? simplified : range;
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
});
|
|
1699
|
+
|
|
1700
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/subset.js
|
|
1701
|
+
var require_subset = __commonJS({
|
|
1702
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/ranges/subset.js"(exports, module) {
|
|
1703
|
+
"use strict";
|
|
1704
|
+
var Range = require_range();
|
|
1705
|
+
var Comparator = require_comparator();
|
|
1706
|
+
var { ANY } = Comparator;
|
|
1707
|
+
var satisfies2 = require_satisfies();
|
|
1708
|
+
var compare = require_compare();
|
|
1709
|
+
var subset = (sub, dom, options = {}) => {
|
|
1710
|
+
if (sub === dom) {
|
|
1711
|
+
return true;
|
|
1712
|
+
}
|
|
1713
|
+
sub = new Range(sub, options);
|
|
1714
|
+
dom = new Range(dom, options);
|
|
1715
|
+
let sawNonNull = false;
|
|
1716
|
+
OUTER: for (const simpleSub of sub.set) {
|
|
1717
|
+
for (const simpleDom of dom.set) {
|
|
1718
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
1719
|
+
sawNonNull = sawNonNull || isSub !== null;
|
|
1720
|
+
if (isSub) {
|
|
1721
|
+
continue OUTER;
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
if (sawNonNull) {
|
|
1725
|
+
return false;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
return true;
|
|
1729
|
+
};
|
|
1730
|
+
var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
|
|
1731
|
+
var minimumVersion = [new Comparator(">=0.0.0")];
|
|
1732
|
+
var simpleSubset = (sub, dom, options) => {
|
|
1733
|
+
if (sub === dom) {
|
|
1734
|
+
return true;
|
|
1735
|
+
}
|
|
1736
|
+
if (sub.length === 1 && sub[0].semver === ANY) {
|
|
1737
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
1738
|
+
return true;
|
|
1739
|
+
} else if (options.includePrerelease) {
|
|
1740
|
+
sub = minimumVersionWithPreRelease;
|
|
1741
|
+
} else {
|
|
1742
|
+
sub = minimumVersion;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
1746
|
+
if (options.includePrerelease) {
|
|
1747
|
+
return true;
|
|
1748
|
+
} else {
|
|
1749
|
+
dom = minimumVersion;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
const eqSet = /* @__PURE__ */ new Set();
|
|
1753
|
+
let gt, lt;
|
|
1754
|
+
for (const c of sub) {
|
|
1755
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
1756
|
+
gt = higherGT(gt, c, options);
|
|
1757
|
+
} else if (c.operator === "<" || c.operator === "<=") {
|
|
1758
|
+
lt = lowerLT(lt, c, options);
|
|
1759
|
+
} else {
|
|
1760
|
+
eqSet.add(c.semver);
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
if (eqSet.size > 1) {
|
|
1764
|
+
return null;
|
|
1765
|
+
}
|
|
1766
|
+
let gtltComp;
|
|
1767
|
+
if (gt && lt) {
|
|
1768
|
+
gtltComp = compare(gt.semver, lt.semver, options);
|
|
1769
|
+
if (gtltComp > 0) {
|
|
1770
|
+
return null;
|
|
1771
|
+
} else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
|
|
1772
|
+
return null;
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
for (const eq of eqSet) {
|
|
1776
|
+
if (gt && !satisfies2(eq, String(gt), options)) {
|
|
1777
|
+
return null;
|
|
1778
|
+
}
|
|
1779
|
+
if (lt && !satisfies2(eq, String(lt), options)) {
|
|
1780
|
+
return null;
|
|
1781
|
+
}
|
|
1782
|
+
for (const c of dom) {
|
|
1783
|
+
if (!satisfies2(eq, String(c), options)) {
|
|
1784
|
+
return false;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
return true;
|
|
1788
|
+
}
|
|
1789
|
+
let higher, lower;
|
|
1790
|
+
let hasDomLT, hasDomGT;
|
|
1791
|
+
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
|
|
1792
|
+
let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
|
|
1793
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
|
|
1794
|
+
needDomLTPre = false;
|
|
1795
|
+
}
|
|
1796
|
+
for (const c of dom) {
|
|
1797
|
+
hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
|
|
1798
|
+
hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
|
|
1799
|
+
if (gt) {
|
|
1800
|
+
if (needDomGTPre) {
|
|
1801
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
|
|
1802
|
+
needDomGTPre = false;
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
1806
|
+
higher = higherGT(gt, c, options);
|
|
1807
|
+
if (higher === c && higher !== gt) {
|
|
1808
|
+
return false;
|
|
1809
|
+
}
|
|
1810
|
+
} else if (gt.operator === ">=" && !satisfies2(gt.semver, String(c), options)) {
|
|
1811
|
+
return false;
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
if (lt) {
|
|
1815
|
+
if (needDomLTPre) {
|
|
1816
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
|
|
1817
|
+
needDomLTPre = false;
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
if (c.operator === "<" || c.operator === "<=") {
|
|
1821
|
+
lower = lowerLT(lt, c, options);
|
|
1822
|
+
if (lower === c && lower !== lt) {
|
|
1823
|
+
return false;
|
|
1824
|
+
}
|
|
1825
|
+
} else if (lt.operator === "<=" && !satisfies2(lt.semver, String(c), options)) {
|
|
1826
|
+
return false;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) {
|
|
1830
|
+
return false;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) {
|
|
1834
|
+
return false;
|
|
1835
|
+
}
|
|
1836
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) {
|
|
1837
|
+
return false;
|
|
1838
|
+
}
|
|
1839
|
+
if (needDomGTPre || needDomLTPre) {
|
|
1840
|
+
return false;
|
|
1841
|
+
}
|
|
1842
|
+
return true;
|
|
1843
|
+
};
|
|
1844
|
+
var higherGT = (a, b, options) => {
|
|
1845
|
+
if (!a) {
|
|
1846
|
+
return b;
|
|
1847
|
+
}
|
|
1848
|
+
const comp = compare(a.semver, b.semver, options);
|
|
1849
|
+
return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
|
|
1850
|
+
};
|
|
1851
|
+
var lowerLT = (a, b, options) => {
|
|
1852
|
+
if (!a) {
|
|
1853
|
+
return b;
|
|
1854
|
+
}
|
|
1855
|
+
const comp = compare(a.semver, b.semver, options);
|
|
1856
|
+
return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
|
|
1857
|
+
};
|
|
1858
|
+
module.exports = subset;
|
|
1859
|
+
}
|
|
1860
|
+
});
|
|
1861
|
+
|
|
1862
|
+
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js
|
|
1863
|
+
var require_semver2 = __commonJS({
|
|
1864
|
+
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js"(exports, module) {
|
|
1865
|
+
"use strict";
|
|
1866
|
+
var internalRe = require_re();
|
|
1867
|
+
var constants = require_constants();
|
|
1868
|
+
var SemVer = require_semver();
|
|
1869
|
+
var identifiers = require_identifiers();
|
|
1870
|
+
var parse = require_parse();
|
|
1871
|
+
var valid2 = require_valid();
|
|
1872
|
+
var clean = require_clean();
|
|
1873
|
+
var inc = require_inc();
|
|
1874
|
+
var diff = require_diff();
|
|
1875
|
+
var major = require_major();
|
|
1876
|
+
var minor = require_minor();
|
|
1877
|
+
var patch = require_patch();
|
|
1878
|
+
var prerelease = require_prerelease();
|
|
1879
|
+
var compare = require_compare();
|
|
1880
|
+
var rcompare2 = require_rcompare();
|
|
1881
|
+
var compareLoose = require_compare_loose();
|
|
1882
|
+
var compareBuild = require_compare_build();
|
|
1883
|
+
var sort = require_sort();
|
|
1884
|
+
var rsort = require_rsort();
|
|
1885
|
+
var gt = require_gt();
|
|
1886
|
+
var lt = require_lt();
|
|
1887
|
+
var eq = require_eq();
|
|
1888
|
+
var neq = require_neq();
|
|
1889
|
+
var gte = require_gte();
|
|
1890
|
+
var lte = require_lte();
|
|
1891
|
+
var cmp = require_cmp();
|
|
1892
|
+
var coerce = require_coerce();
|
|
1893
|
+
var Comparator = require_comparator();
|
|
1894
|
+
var Range = require_range();
|
|
1895
|
+
var satisfies2 = require_satisfies();
|
|
1896
|
+
var toComparators = require_to_comparators();
|
|
1897
|
+
var maxSatisfying = require_max_satisfying();
|
|
1898
|
+
var minSatisfying = require_min_satisfying();
|
|
1899
|
+
var minVersion = require_min_version();
|
|
1900
|
+
var validRange2 = require_valid2();
|
|
1901
|
+
var outside = require_outside();
|
|
1902
|
+
var gtr = require_gtr();
|
|
1903
|
+
var ltr = require_ltr();
|
|
1904
|
+
var intersects = require_intersects();
|
|
1905
|
+
var simplifyRange = require_simplify();
|
|
1906
|
+
var subset = require_subset();
|
|
1907
|
+
module.exports = {
|
|
1908
|
+
parse,
|
|
1909
|
+
valid: valid2,
|
|
1910
|
+
clean,
|
|
1911
|
+
inc,
|
|
1912
|
+
diff,
|
|
1913
|
+
major,
|
|
1914
|
+
minor,
|
|
1915
|
+
patch,
|
|
1916
|
+
prerelease,
|
|
1917
|
+
compare,
|
|
1918
|
+
rcompare: rcompare2,
|
|
1919
|
+
compareLoose,
|
|
1920
|
+
compareBuild,
|
|
1921
|
+
sort,
|
|
1922
|
+
rsort,
|
|
1923
|
+
gt,
|
|
1924
|
+
lt,
|
|
1925
|
+
eq,
|
|
1926
|
+
neq,
|
|
1927
|
+
gte,
|
|
1928
|
+
lte,
|
|
1929
|
+
cmp,
|
|
1930
|
+
coerce,
|
|
1931
|
+
Comparator,
|
|
1932
|
+
Range,
|
|
1933
|
+
satisfies: satisfies2,
|
|
1934
|
+
toComparators,
|
|
1935
|
+
maxSatisfying,
|
|
1936
|
+
minSatisfying,
|
|
1937
|
+
minVersion,
|
|
1938
|
+
validRange: validRange2,
|
|
1939
|
+
outside,
|
|
1940
|
+
gtr,
|
|
1941
|
+
ltr,
|
|
1942
|
+
intersects,
|
|
1943
|
+
simplifyRange,
|
|
1944
|
+
subset,
|
|
1945
|
+
SemVer,
|
|
1946
|
+
re: internalRe.re,
|
|
1947
|
+
src: internalRe.src,
|
|
1948
|
+
tokens: internalRe.t,
|
|
1949
|
+
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
1950
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
1951
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
1952
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
1953
|
+
};
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
|
|
1957
|
+
// src/module-artifact.ts
|
|
1958
|
+
import { parse as parseYaml2 } from "yaml";
|
|
1959
|
+
import { createHash } from "node:crypto";
|
|
1960
|
+
import { lstat, readdir as readdir2, readFile as readFile2 } from "node:fs/promises";
|
|
1961
|
+
import { join as join2 } from "node:path";
|
|
1962
|
+
|
|
1963
|
+
// ../kernel/src/errors.ts
|
|
1964
|
+
var RegistryError = class extends Error {
|
|
1965
|
+
code;
|
|
1966
|
+
constructor(code, message) {
|
|
1967
|
+
super(message);
|
|
1968
|
+
this.name = "RegistryError";
|
|
1969
|
+
this.code = code;
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
|
|
1973
|
+
// ../kernel/src/module-compatibility.ts
|
|
1974
|
+
var import_semver = __toESM(require_semver2(), 1);
|
|
1975
|
+
var PLATFORM_API_VERSION = "0.1.0";
|
|
1976
|
+
function satisfiesModuleVersion(version, range) {
|
|
1977
|
+
return (0, import_semver.valid)(version) !== null && (0, import_semver.validRange)(range) !== null && (0, import_semver.satisfies)(version, range);
|
|
1978
|
+
}
|
|
1979
|
+
function compareModuleVersions(left, right) {
|
|
1980
|
+
return (0, import_semver.rcompare)(left, right);
|
|
1981
|
+
}
|
|
1982
|
+
function assertModuleCompatibility(manifest, platformVersion = PLATFORM_API_VERSION) {
|
|
1983
|
+
if (!(0, import_semver.valid)(manifest.version))
|
|
1984
|
+
throw new RegistryError(
|
|
1985
|
+
"MODULE_VERSION_INVALID",
|
|
1986
|
+
`Invalid version for ${manifest.id}: ${manifest.version}`
|
|
1987
|
+
);
|
|
1988
|
+
if (manifest.platformApi !== void 0 && (!(0, import_semver.validRange)(manifest.platformApi) || platformVersion !== null && !satisfiesModuleVersion(platformVersion, manifest.platformApi))) {
|
|
1989
|
+
throw new RegistryError(
|
|
1990
|
+
"MODULE_PLATFORM_INCOMPATIBLE",
|
|
1991
|
+
`${manifest.id} requires platform API ${manifest.platformApi}; available ${PLATFORM_API_VERSION}.`
|
|
1992
|
+
);
|
|
1993
|
+
}
|
|
1994
|
+
const ids = /* @__PURE__ */ new Set();
|
|
1995
|
+
for (const dependency of manifest.dependencies) {
|
|
1996
|
+
if (!dependency.range.trim() || !(0, import_semver.validRange)(dependency.range))
|
|
1997
|
+
throw new RegistryError(
|
|
1998
|
+
"MODULE_RANGE_INVALID",
|
|
1999
|
+
`${manifest.id} declares an invalid range for ${dependency.id}: ${dependency.range}`
|
|
2000
|
+
);
|
|
2001
|
+
if (ids.has(dependency.id))
|
|
2002
|
+
throw new RegistryError(
|
|
2003
|
+
"MODULE_DEPENDENCY_DUPLICATE",
|
|
2004
|
+
`${manifest.id} declares ${dependency.id} more than once.`
|
|
2005
|
+
);
|
|
2006
|
+
ids.add(dependency.id);
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
function assertModuleDependency(consumer, dependency, version) {
|
|
2010
|
+
if (!satisfiesModuleVersion(version, dependency.range)) {
|
|
2011
|
+
throw new RegistryError(
|
|
2012
|
+
"MODULE_DEPENDENCY_INCOMPATIBLE",
|
|
2013
|
+
`${consumer} requires ${dependency.id} ${dependency.range}; available ${version}.`
|
|
2014
|
+
);
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
// ../kernel/src/module-registry.ts
|
|
2019
|
+
function compareModules(left, right) {
|
|
2020
|
+
return left.manifest.id.localeCompare(right.manifest.id);
|
|
2021
|
+
}
|
|
2022
|
+
function visitModule(id, modules, visiting, visited, ordered) {
|
|
2023
|
+
if (visited.has(id)) return;
|
|
2024
|
+
if (visiting.has(id)) {
|
|
2025
|
+
throw new RegistryError(
|
|
2026
|
+
"MODULE_DEPENDENCY_CYCLE",
|
|
2027
|
+
`Dependency cycle detected at "${id}".`
|
|
2028
|
+
);
|
|
2029
|
+
}
|
|
2030
|
+
const current = modules.get(id);
|
|
2031
|
+
if (!current) {
|
|
2032
|
+
throw new RegistryError(
|
|
2033
|
+
"MODULE_NOT_FOUND",
|
|
2034
|
+
`Module "${id}" is not registered.`
|
|
2035
|
+
);
|
|
2036
|
+
}
|
|
2037
|
+
visiting.add(id);
|
|
2038
|
+
for (const dependency of [...current.manifest.dependencies].sort(
|
|
2039
|
+
(a, b) => a.id.localeCompare(b.id)
|
|
2040
|
+
)) {
|
|
2041
|
+
if (!modules.has(dependency.id)) {
|
|
2042
|
+
throw new RegistryError(
|
|
2043
|
+
"MODULE_DEPENDENCY_MISSING",
|
|
2044
|
+
`Module "${id}" requires missing module "${dependency.id}".`
|
|
2045
|
+
);
|
|
2046
|
+
}
|
|
2047
|
+
assertModuleDependency(
|
|
2048
|
+
id,
|
|
2049
|
+
dependency,
|
|
2050
|
+
modules.get(dependency.id).manifest.version
|
|
2051
|
+
);
|
|
2052
|
+
visitModule(dependency.id, modules, visiting, visited, ordered);
|
|
2053
|
+
}
|
|
2054
|
+
visiting.delete(id);
|
|
2055
|
+
visited.add(id);
|
|
2056
|
+
ordered.push(current);
|
|
2057
|
+
}
|
|
2058
|
+
function createModuleRegistry(input) {
|
|
2059
|
+
const byId = /* @__PURE__ */ new Map();
|
|
2060
|
+
const navigationIds = /* @__PURE__ */ new Set();
|
|
2061
|
+
for (const module of input) {
|
|
2062
|
+
assertModuleCompatibility(module.manifest);
|
|
2063
|
+
if (byId.has(module.manifest.id)) {
|
|
2064
|
+
throw new RegistryError(
|
|
2065
|
+
"MODULE_DUPLICATE",
|
|
2066
|
+
`Module "${module.manifest.id}" is registered more than once.`
|
|
2067
|
+
);
|
|
2068
|
+
}
|
|
2069
|
+
byId.set(module.manifest.id, module);
|
|
2070
|
+
for (const item of module.navigation ?? []) {
|
|
2071
|
+
if (navigationIds.has(item.id)) {
|
|
2072
|
+
throw new RegistryError(
|
|
2073
|
+
"NAVIGATION_DUPLICATE",
|
|
2074
|
+
`Navigation contribution "${item.id}" is registered more than once.`
|
|
2075
|
+
);
|
|
2076
|
+
}
|
|
2077
|
+
navigationIds.add(item.id);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
const ordered = [];
|
|
2081
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
2082
|
+
const visited = /* @__PURE__ */ new Set();
|
|
2083
|
+
for (const module of [...input].sort(compareModules)) {
|
|
2084
|
+
visitModule(module.manifest.id, byId, visiting, visited, ordered);
|
|
2085
|
+
}
|
|
2086
|
+
return Object.freeze({
|
|
2087
|
+
modules: Object.freeze(ordered),
|
|
2088
|
+
get: (id) => byId.get(id),
|
|
2089
|
+
has: (id) => byId.has(id),
|
|
2090
|
+
navigation: (permissions) => Object.freeze(
|
|
2091
|
+
ordered.flatMap((module) => module.navigation ?? []).filter(
|
|
2092
|
+
(item) => !item.permission || permissions?.has(item.permission)
|
|
2093
|
+
).sort(
|
|
2094
|
+
(left, right) => (left.order ?? 1e3) - (right.order ?? 1e3) || left.id.localeCompare(right.id)
|
|
2095
|
+
)
|
|
2096
|
+
)
|
|
2097
|
+
});
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
// ../contracts/schemas/blueprint.schema.json
|
|
2101
|
+
var blueprint_schema_default = {
|
|
2102
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
2103
|
+
$id: "https://flowdular.dev/schemas/blueprint.schema.json",
|
|
2104
|
+
type: "object",
|
|
2105
|
+
additionalProperties: false,
|
|
2106
|
+
required: [
|
|
2107
|
+
"schemaVersion",
|
|
2108
|
+
"id",
|
|
2109
|
+
"version",
|
|
2110
|
+
"architecture",
|
|
2111
|
+
"risk",
|
|
2112
|
+
"owner",
|
|
2113
|
+
"agentRoles",
|
|
2114
|
+
"executorProfiles",
|
|
2115
|
+
"requiredReviewers",
|
|
2116
|
+
"requiresApprovedSpec",
|
|
2117
|
+
"status"
|
|
2118
|
+
],
|
|
2119
|
+
properties: {
|
|
2120
|
+
$schema: { type: "string" },
|
|
2121
|
+
schemaVersion: { const: 1 },
|
|
2122
|
+
id: { type: "string", pattern: "^[a-z][a-z0-9-]+$" },
|
|
2123
|
+
version: { type: "string", pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
|
|
2124
|
+
architecture: { type: "string", minLength: 1 },
|
|
2125
|
+
risk: {
|
|
2126
|
+
enum: ["read", "workspace-write", "process", "external", "destructive"]
|
|
2127
|
+
},
|
|
2128
|
+
owner: { type: "string", minLength: 1 },
|
|
2129
|
+
agentRoles: {
|
|
2130
|
+
type: "array",
|
|
2131
|
+
minItems: 1,
|
|
2132
|
+
items: { type: "string" },
|
|
2133
|
+
uniqueItems: true
|
|
2134
|
+
},
|
|
2135
|
+
executorProfiles: {
|
|
2136
|
+
type: "array",
|
|
2137
|
+
items: { type: "string" },
|
|
2138
|
+
uniqueItems: true
|
|
2139
|
+
},
|
|
2140
|
+
requiredReviewers: {
|
|
2141
|
+
type: "array",
|
|
2142
|
+
items: { type: "string" },
|
|
2143
|
+
uniqueItems: true
|
|
2144
|
+
},
|
|
2145
|
+
requiresApprovedSpec: { type: "boolean" },
|
|
2146
|
+
status: { enum: ["draft", "approved", "deprecated"] }
|
|
2147
|
+
}
|
|
2148
|
+
};
|
|
2149
|
+
|
|
2150
|
+
// ../contracts/schemas/cli-extension.schema.json
|
|
2151
|
+
var cli_extension_schema_default = {
|
|
2152
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
2153
|
+
$id: "https://flowdular.dev/schemas/cli-extension.schema.json",
|
|
2154
|
+
type: "object",
|
|
2155
|
+
additionalProperties: false,
|
|
2156
|
+
required: ["protocolVersion", "moduleId", "commands"],
|
|
2157
|
+
properties: {
|
|
2158
|
+
protocolVersion: { const: 1 },
|
|
2159
|
+
moduleId: {
|
|
2160
|
+
type: "string",
|
|
2161
|
+
pattern: "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$"
|
|
2162
|
+
},
|
|
2163
|
+
commands: {
|
|
2164
|
+
type: "array",
|
|
2165
|
+
items: {
|
|
2166
|
+
type: "object",
|
|
2167
|
+
additionalProperties: false,
|
|
2168
|
+
required: ["path", "capability"],
|
|
2169
|
+
properties: {
|
|
2170
|
+
path: {
|
|
2171
|
+
type: "array",
|
|
2172
|
+
minItems: 2,
|
|
2173
|
+
items: {
|
|
2174
|
+
type: "string",
|
|
2175
|
+
pattern: "^[a-z][a-z0-9-]*$"
|
|
2176
|
+
}
|
|
2177
|
+
},
|
|
2178
|
+
capability: {
|
|
2179
|
+
type: "object",
|
|
2180
|
+
additionalProperties: false,
|
|
2181
|
+
required: [
|
|
2182
|
+
"id",
|
|
2183
|
+
"version",
|
|
2184
|
+
"summary",
|
|
2185
|
+
"risk",
|
|
2186
|
+
"requiresApprovedSpec",
|
|
2187
|
+
"supportsDryRun"
|
|
2188
|
+
],
|
|
2189
|
+
properties: {
|
|
2190
|
+
id: {
|
|
2191
|
+
type: "string",
|
|
2192
|
+
pattern: "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$"
|
|
2193
|
+
},
|
|
2194
|
+
version: { type: "integer", minimum: 1 },
|
|
2195
|
+
summary: {
|
|
2196
|
+
type: "string",
|
|
2197
|
+
minLength: 1,
|
|
2198
|
+
maxLength: 240
|
|
2199
|
+
},
|
|
2200
|
+
risk: {
|
|
2201
|
+
enum: [
|
|
2202
|
+
"read",
|
|
2203
|
+
"workspace-write",
|
|
2204
|
+
"process",
|
|
2205
|
+
"external",
|
|
2206
|
+
"destructive"
|
|
2207
|
+
]
|
|
2208
|
+
},
|
|
2209
|
+
requiresApprovedSpec: { type: "boolean" },
|
|
2210
|
+
supportsDryRun: { type: "boolean" },
|
|
2211
|
+
localOnly: { type: "boolean" },
|
|
2212
|
+
confirmation: {
|
|
2213
|
+
type: "string",
|
|
2214
|
+
pattern: "^[a-z][a-z0-9-]{2,63}$"
|
|
2215
|
+
}
|
|
2216
|
+
},
|
|
2217
|
+
allOf: [
|
|
2218
|
+
{
|
|
2219
|
+
if: {
|
|
2220
|
+
properties: {
|
|
2221
|
+
risk: { const: "destructive" },
|
|
2222
|
+
localOnly: { const: true }
|
|
2223
|
+
},
|
|
2224
|
+
required: ["risk", "localOnly"]
|
|
2225
|
+
},
|
|
2226
|
+
then: {
|
|
2227
|
+
properties: {
|
|
2228
|
+
confirmation: true,
|
|
2229
|
+
supportsDryRun: { const: true }
|
|
2230
|
+
},
|
|
2231
|
+
required: ["confirmation"]
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
]
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
};
|
|
2241
|
+
|
|
2242
|
+
// ../contracts/schemas/module.schema.json
|
|
2243
|
+
var module_schema_default = {
|
|
2244
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
2245
|
+
$id: "https://flowdular.dev/schemas/module.schema.json",
|
|
2246
|
+
type: "object",
|
|
2247
|
+
additionalProperties: false,
|
|
2248
|
+
required: [
|
|
2249
|
+
"schemaVersion",
|
|
2250
|
+
"id",
|
|
2251
|
+
"package",
|
|
2252
|
+
"version",
|
|
2253
|
+
"profile",
|
|
2254
|
+
"capabilities",
|
|
2255
|
+
"dependencies",
|
|
2256
|
+
"tenancy",
|
|
2257
|
+
"locales",
|
|
2258
|
+
"stability"
|
|
2259
|
+
],
|
|
2260
|
+
properties: {
|
|
2261
|
+
$schema: {
|
|
2262
|
+
type: "string"
|
|
2263
|
+
},
|
|
2264
|
+
schemaVersion: {
|
|
2265
|
+
const: 1
|
|
2266
|
+
},
|
|
2267
|
+
id: {
|
|
2268
|
+
type: "string",
|
|
2269
|
+
pattern: "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$"
|
|
2270
|
+
},
|
|
2271
|
+
package: {
|
|
2272
|
+
type: "string",
|
|
2273
|
+
pattern: "^(@[a-z0-9][a-z0-9._-]*/)?[a-z0-9][a-z0-9._-]*$"
|
|
2274
|
+
},
|
|
2275
|
+
version: {
|
|
2276
|
+
type: "string",
|
|
2277
|
+
pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$"
|
|
2278
|
+
},
|
|
2279
|
+
profile: {
|
|
2280
|
+
enum: ["full", "headless", "ui", "integration"]
|
|
2281
|
+
},
|
|
2282
|
+
capabilities: {
|
|
2283
|
+
type: "array",
|
|
2284
|
+
items: {
|
|
2285
|
+
enum: [
|
|
2286
|
+
"api",
|
|
2287
|
+
"database",
|
|
2288
|
+
"client",
|
|
2289
|
+
"translations",
|
|
2290
|
+
"integration",
|
|
2291
|
+
"cli"
|
|
2292
|
+
]
|
|
2293
|
+
},
|
|
2294
|
+
uniqueItems: true
|
|
2295
|
+
},
|
|
2296
|
+
dependencies: {
|
|
2297
|
+
type: "array",
|
|
2298
|
+
items: {
|
|
2299
|
+
type: "object",
|
|
2300
|
+
additionalProperties: false,
|
|
2301
|
+
required: ["id", "range"],
|
|
2302
|
+
properties: {
|
|
2303
|
+
id: {
|
|
2304
|
+
type: "string",
|
|
2305
|
+
pattern: "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$"
|
|
2306
|
+
},
|
|
2307
|
+
range: {
|
|
2308
|
+
type: "string",
|
|
2309
|
+
minLength: 1
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
},
|
|
2314
|
+
tenancy: {
|
|
2315
|
+
enum: ["required", "optional", "none"]
|
|
2316
|
+
},
|
|
2317
|
+
locales: {
|
|
2318
|
+
type: "array",
|
|
2319
|
+
items: {
|
|
2320
|
+
type: "string",
|
|
2321
|
+
pattern: "^[a-z]{2}(-[A-Z]{2})?$"
|
|
2322
|
+
},
|
|
2323
|
+
uniqueItems: true
|
|
2324
|
+
},
|
|
2325
|
+
stability: {
|
|
2326
|
+
enum: ["experimental", "stable", "deprecated"]
|
|
2327
|
+
},
|
|
2328
|
+
platform: {
|
|
2329
|
+
type: "object",
|
|
2330
|
+
additionalProperties: false,
|
|
2331
|
+
properties: {
|
|
2332
|
+
server: {
|
|
2333
|
+
type: "boolean"
|
|
2334
|
+
},
|
|
2335
|
+
client: {
|
|
2336
|
+
type: "boolean"
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
},
|
|
2340
|
+
cli: {
|
|
2341
|
+
type: "object",
|
|
2342
|
+
additionalProperties: false,
|
|
2343
|
+
required: ["catalog", "entry"],
|
|
2344
|
+
properties: {
|
|
2345
|
+
catalog: {
|
|
2346
|
+
type: "string",
|
|
2347
|
+
pattern: "^src/cli/[a-z0-9-/]+\\.json$"
|
|
2348
|
+
},
|
|
2349
|
+
entry: {
|
|
2350
|
+
type: "string",
|
|
2351
|
+
pattern: "^src/cli/[a-z0-9-/]+\\.ts$"
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
},
|
|
2355
|
+
platformApi: {
|
|
2356
|
+
type: "string",
|
|
2357
|
+
minLength: 1
|
|
2358
|
+
}
|
|
2359
|
+
},
|
|
2360
|
+
allOf: [
|
|
2361
|
+
{
|
|
2362
|
+
if: {
|
|
2363
|
+
properties: {
|
|
2364
|
+
capabilities: {
|
|
2365
|
+
type: "array",
|
|
2366
|
+
contains: {
|
|
2367
|
+
const: "cli"
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
},
|
|
2372
|
+
then: {
|
|
2373
|
+
properties: {
|
|
2374
|
+
cli: true
|
|
2375
|
+
},
|
|
2376
|
+
required: ["cli"]
|
|
2377
|
+
}
|
|
2378
|
+
},
|
|
2379
|
+
{
|
|
2380
|
+
if: {
|
|
2381
|
+
properties: {
|
|
2382
|
+
cli: true
|
|
2383
|
+
},
|
|
2384
|
+
required: ["cli"]
|
|
2385
|
+
},
|
|
2386
|
+
then: {
|
|
2387
|
+
properties: {
|
|
2388
|
+
capabilities: {
|
|
2389
|
+
type: "array",
|
|
2390
|
+
contains: {
|
|
2391
|
+
const: "cli"
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
]
|
|
2398
|
+
};
|
|
2399
|
+
|
|
2400
|
+
// ../contracts/schemas/module-spec.schema.json
|
|
2401
|
+
var module_spec_schema_default = {
|
|
2402
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
2403
|
+
$id: "https://flowdular.dev/schemas/module-spec.schema.json",
|
|
2404
|
+
type: "object",
|
|
2405
|
+
additionalProperties: false,
|
|
2406
|
+
required: [
|
|
2407
|
+
"schemaVersion",
|
|
2408
|
+
"id",
|
|
2409
|
+
"specVersion",
|
|
2410
|
+
"status",
|
|
2411
|
+
"name",
|
|
2412
|
+
"description",
|
|
2413
|
+
"profile",
|
|
2414
|
+
"capabilities",
|
|
2415
|
+
"dependencies",
|
|
2416
|
+
"tenancy",
|
|
2417
|
+
"locales"
|
|
2418
|
+
],
|
|
2419
|
+
properties: {
|
|
2420
|
+
$schema: { type: "string" },
|
|
2421
|
+
schemaVersion: { const: 1 },
|
|
2422
|
+
id: {
|
|
2423
|
+
type: "string",
|
|
2424
|
+
pattern: "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$"
|
|
2425
|
+
},
|
|
2426
|
+
specVersion: {
|
|
2427
|
+
type: "string",
|
|
2428
|
+
pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$"
|
|
2429
|
+
},
|
|
2430
|
+
status: {
|
|
2431
|
+
enum: ["draft", "in-review", "approved", "implemented", "deprecated"]
|
|
2432
|
+
},
|
|
2433
|
+
name: { type: "string", minLength: 1 },
|
|
2434
|
+
description: { type: "string", minLength: 1 },
|
|
2435
|
+
profile: { enum: ["full", "headless", "ui", "integration"] },
|
|
2436
|
+
capabilities: {
|
|
2437
|
+
type: "array",
|
|
2438
|
+
items: {
|
|
2439
|
+
enum: [
|
|
2440
|
+
"api",
|
|
2441
|
+
"database",
|
|
2442
|
+
"client",
|
|
2443
|
+
"translations",
|
|
2444
|
+
"integration",
|
|
2445
|
+
"cli"
|
|
2446
|
+
]
|
|
2447
|
+
},
|
|
2448
|
+
uniqueItems: true
|
|
2449
|
+
},
|
|
2450
|
+
dependencies: {
|
|
2451
|
+
type: "array",
|
|
2452
|
+
items: {
|
|
2453
|
+
type: "object",
|
|
2454
|
+
additionalProperties: false,
|
|
2455
|
+
required: ["id", "range"],
|
|
2456
|
+
properties: {
|
|
2457
|
+
id: { type: "string" },
|
|
2458
|
+
range: { type: "string" }
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
},
|
|
2462
|
+
tenancy: { enum: ["required", "optional", "none"] },
|
|
2463
|
+
locales: {
|
|
2464
|
+
type: "array",
|
|
2465
|
+
minItems: 1,
|
|
2466
|
+
items: { type: "string" },
|
|
2467
|
+
uniqueItems: true
|
|
2468
|
+
},
|
|
2469
|
+
invariants: {
|
|
2470
|
+
type: "array",
|
|
2471
|
+
items: { type: "string", minLength: 1 },
|
|
2472
|
+
uniqueItems: true
|
|
2473
|
+
},
|
|
2474
|
+
permissions: {
|
|
2475
|
+
type: "array",
|
|
2476
|
+
items: {
|
|
2477
|
+
type: "object",
|
|
2478
|
+
additionalProperties: false,
|
|
2479
|
+
required: ["id", "description"],
|
|
2480
|
+
properties: {
|
|
2481
|
+
id: {
|
|
2482
|
+
type: "string",
|
|
2483
|
+
pattern: "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$"
|
|
2484
|
+
},
|
|
2485
|
+
description: { type: "string", minLength: 1 }
|
|
2486
|
+
}
|
|
2487
|
+
},
|
|
2488
|
+
uniqueItems: true
|
|
2489
|
+
},
|
|
2490
|
+
dataOwnership: {
|
|
2491
|
+
type: "array",
|
|
2492
|
+
items: { type: "string", minLength: 1 },
|
|
2493
|
+
uniqueItems: true
|
|
2494
|
+
},
|
|
2495
|
+
acceptanceScenarios: {
|
|
2496
|
+
type: "array",
|
|
2497
|
+
items: {
|
|
2498
|
+
type: "object",
|
|
2499
|
+
additionalProperties: false,
|
|
2500
|
+
required: ["id", "given", "when", "then"],
|
|
2501
|
+
properties: {
|
|
2502
|
+
id: { type: "string", pattern: "^[A-Z][A-Z0-9-]+$" },
|
|
2503
|
+
given: { type: "string", minLength: 1 },
|
|
2504
|
+
when: { type: "string", minLength: 1 },
|
|
2505
|
+
then: { type: "string", minLength: 1 }
|
|
2506
|
+
}
|
|
2507
|
+
},
|
|
2508
|
+
uniqueItems: true
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
};
|
|
2512
|
+
|
|
2513
|
+
// ../contracts/schemas/platform-spec.schema.json
|
|
2514
|
+
var platform_spec_schema_default = {
|
|
2515
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
2516
|
+
$id: "https://flowdular.dev/schemas/platform-spec.schema.json",
|
|
2517
|
+
type: "object",
|
|
2518
|
+
required: ["schemaVersion", "id", "version", "status"],
|
|
2519
|
+
properties: {
|
|
2520
|
+
schemaVersion: { const: 1 },
|
|
2521
|
+
id: {
|
|
2522
|
+
type: "string",
|
|
2523
|
+
pattern: "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)*$"
|
|
2524
|
+
},
|
|
2525
|
+
version: { type: "string", pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
|
|
2526
|
+
status: {
|
|
2527
|
+
enum: ["draft", "in-review", "approved", "implemented", "deprecated"]
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
};
|
|
2531
|
+
|
|
2532
|
+
// ../contracts/schemas/project.schema.json
|
|
2533
|
+
var project_schema_default = {
|
|
2534
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
2535
|
+
$id: "https://flowdular.dev/schemas/project.schema.json",
|
|
2536
|
+
type: "object",
|
|
2537
|
+
additionalProperties: false,
|
|
2538
|
+
required: [
|
|
2539
|
+
"schemaVersion",
|
|
2540
|
+
"architectureVersion",
|
|
2541
|
+
"specs",
|
|
2542
|
+
"modules",
|
|
2543
|
+
"locales",
|
|
2544
|
+
"agent"
|
|
2545
|
+
],
|
|
2546
|
+
properties: {
|
|
2547
|
+
$schema: {
|
|
2548
|
+
type: "string"
|
|
2549
|
+
},
|
|
2550
|
+
schemaVersion: {
|
|
2551
|
+
const: 1
|
|
2552
|
+
},
|
|
2553
|
+
architectureVersion: {
|
|
2554
|
+
type: "string",
|
|
2555
|
+
pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$"
|
|
2556
|
+
},
|
|
2557
|
+
specs: {
|
|
2558
|
+
type: "object",
|
|
2559
|
+
additionalProperties: false,
|
|
2560
|
+
required: [
|
|
2561
|
+
"platformRoot",
|
|
2562
|
+
"moduleDirectory"
|
|
2563
|
+
],
|
|
2564
|
+
properties: {
|
|
2565
|
+
platformRoot: {
|
|
2566
|
+
type: "string",
|
|
2567
|
+
minLength: 1
|
|
2568
|
+
},
|
|
2569
|
+
moduleDirectory: {
|
|
2570
|
+
type: "string",
|
|
2571
|
+
minLength: 1
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
},
|
|
2575
|
+
modules: {
|
|
2576
|
+
type: "object",
|
|
2577
|
+
additionalProperties: false,
|
|
2578
|
+
required: [
|
|
2579
|
+
"roots",
|
|
2580
|
+
"enabled"
|
|
2581
|
+
],
|
|
2582
|
+
properties: {
|
|
2583
|
+
roots: {
|
|
2584
|
+
type: "array",
|
|
2585
|
+
minItems: 1,
|
|
2586
|
+
items: {
|
|
2587
|
+
type: "string",
|
|
2588
|
+
minLength: 1
|
|
2589
|
+
},
|
|
2590
|
+
uniqueItems: true
|
|
2591
|
+
},
|
|
2592
|
+
enabled: {
|
|
2593
|
+
type: "array",
|
|
2594
|
+
items: {
|
|
2595
|
+
type: "string",
|
|
2596
|
+
pattern: "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$"
|
|
2597
|
+
},
|
|
2598
|
+
uniqueItems: true
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
},
|
|
2602
|
+
locales: {
|
|
2603
|
+
type: "array",
|
|
2604
|
+
minItems: 1,
|
|
2605
|
+
items: {
|
|
2606
|
+
type: "string",
|
|
2607
|
+
pattern: "^[a-z]{2}(-[A-Z]{2})?$"
|
|
2608
|
+
},
|
|
2609
|
+
uniqueItems: true
|
|
2610
|
+
},
|
|
2611
|
+
agent: {
|
|
2612
|
+
type: "object",
|
|
2613
|
+
additionalProperties: false,
|
|
2614
|
+
required: [
|
|
2615
|
+
"policy",
|
|
2616
|
+
"blueprints",
|
|
2617
|
+
"modelRouting"
|
|
2618
|
+
],
|
|
2619
|
+
properties: {
|
|
2620
|
+
policy: {
|
|
2621
|
+
type: "string",
|
|
2622
|
+
minLength: 1
|
|
2623
|
+
},
|
|
2624
|
+
blueprints: {
|
|
2625
|
+
type: "string",
|
|
2626
|
+
minLength: 1
|
|
2627
|
+
},
|
|
2628
|
+
modelRouting: {
|
|
2629
|
+
type: "string",
|
|
2630
|
+
minLength: 1
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
},
|
|
2634
|
+
sandbox: {
|
|
2635
|
+
type: "object",
|
|
2636
|
+
additionalProperties: false,
|
|
2637
|
+
properties: {
|
|
2638
|
+
delivery: {
|
|
2639
|
+
type: "object",
|
|
2640
|
+
additionalProperties: false,
|
|
2641
|
+
properties: {
|
|
2642
|
+
default: {
|
|
2643
|
+
$ref: "#/$defs/deliveryTarget"
|
|
2644
|
+
},
|
|
2645
|
+
targets: {
|
|
2646
|
+
type: "array",
|
|
2647
|
+
minItems: 1,
|
|
2648
|
+
items: {
|
|
2649
|
+
$ref: "#/$defs/deliveryTarget"
|
|
2650
|
+
},
|
|
2651
|
+
uniqueItems: true
|
|
2652
|
+
},
|
|
2653
|
+
git: {
|
|
2654
|
+
type: "object",
|
|
2655
|
+
additionalProperties: false,
|
|
2656
|
+
properties: {
|
|
2657
|
+
remote: {
|
|
2658
|
+
$ref: "#/$defs/gitName"
|
|
2659
|
+
},
|
|
2660
|
+
repository: {
|
|
2661
|
+
$ref: "#/$defs/githubRepository"
|
|
2662
|
+
},
|
|
2663
|
+
baseBranch: {
|
|
2664
|
+
$ref: "#/$defs/gitName"
|
|
2665
|
+
},
|
|
2666
|
+
branchPrefix: {
|
|
2667
|
+
$ref: "#/$defs/gitName"
|
|
2668
|
+
},
|
|
2669
|
+
provider: {
|
|
2670
|
+
enum: [
|
|
2671
|
+
"github",
|
|
2672
|
+
"none"
|
|
2673
|
+
]
|
|
2674
|
+
},
|
|
2675
|
+
mode: {
|
|
2676
|
+
enum: [
|
|
2677
|
+
"auto",
|
|
2678
|
+
"direct",
|
|
2679
|
+
"fork"
|
|
2680
|
+
]
|
|
2681
|
+
},
|
|
2682
|
+
forkOwner: {
|
|
2683
|
+
$ref: "#/$defs/githubAccount"
|
|
2684
|
+
},
|
|
2685
|
+
reviewers: {
|
|
2686
|
+
type: "array",
|
|
2687
|
+
maxItems: 20,
|
|
2688
|
+
items: {
|
|
2689
|
+
$ref: "#/$defs/githubAccount"
|
|
2690
|
+
},
|
|
2691
|
+
uniqueItems: true
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
},
|
|
2695
|
+
maxChangedFiles: {
|
|
2696
|
+
type: "integer",
|
|
2697
|
+
minimum: 1
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
},
|
|
2703
|
+
web: {
|
|
2704
|
+
type: "object",
|
|
2705
|
+
additionalProperties: false,
|
|
2706
|
+
required: [
|
|
2707
|
+
"mounts"
|
|
2708
|
+
],
|
|
2709
|
+
properties: {
|
|
2710
|
+
mounts: {
|
|
2711
|
+
type: "array",
|
|
2712
|
+
maxItems: 256,
|
|
2713
|
+
items: {
|
|
2714
|
+
type: "object",
|
|
2715
|
+
additionalProperties: false,
|
|
2716
|
+
required: [
|
|
2717
|
+
"id",
|
|
2718
|
+
"moduleId",
|
|
2719
|
+
"surfaceId",
|
|
2720
|
+
"path",
|
|
2721
|
+
"tenantId"
|
|
2722
|
+
],
|
|
2723
|
+
properties: {
|
|
2724
|
+
id: {
|
|
2725
|
+
type: "string",
|
|
2726
|
+
pattern: "^[a-z][a-z0-9-]*$"
|
|
2727
|
+
},
|
|
2728
|
+
moduleId: {
|
|
2729
|
+
type: "string",
|
|
2730
|
+
pattern: "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$"
|
|
2731
|
+
},
|
|
2732
|
+
surfaceId: {
|
|
2733
|
+
type: "string",
|
|
2734
|
+
pattern: "^[a-z][a-z0-9-]*$"
|
|
2735
|
+
},
|
|
2736
|
+
path: {
|
|
2737
|
+
type: "string",
|
|
2738
|
+
maxLength: 256,
|
|
2739
|
+
pattern: "^(/|/[a-z0-9-]+(/[a-z0-9-]+)*)$"
|
|
2740
|
+
},
|
|
2741
|
+
tenantId: {
|
|
2742
|
+
type: "string",
|
|
2743
|
+
minLength: 1,
|
|
2744
|
+
maxLength: 128
|
|
2745
|
+
},
|
|
2746
|
+
enabled: {
|
|
2747
|
+
type: "boolean"
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
},
|
|
2754
|
+
application: {
|
|
2755
|
+
type: "object",
|
|
2756
|
+
additionalProperties: false,
|
|
2757
|
+
required: [
|
|
2758
|
+
"path"
|
|
2759
|
+
],
|
|
2760
|
+
properties: {
|
|
2761
|
+
path: {
|
|
2762
|
+
type: "string",
|
|
2763
|
+
pattern: "^/[a-z][a-z0-9-]*$",
|
|
2764
|
+
not: {
|
|
2765
|
+
enum: [
|
|
2766
|
+
"/auth",
|
|
2767
|
+
"/api",
|
|
2768
|
+
"/sites",
|
|
2769
|
+
"/sign-in",
|
|
2770
|
+
"/sign-up",
|
|
2771
|
+
"/forgot-password",
|
|
2772
|
+
"/reset-password",
|
|
2773
|
+
"/accept-invitation"
|
|
2774
|
+
]
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
},
|
|
2780
|
+
$defs: {
|
|
2781
|
+
deliveryTarget: {
|
|
2782
|
+
enum: [
|
|
2783
|
+
"workspace",
|
|
2784
|
+
"git-pr",
|
|
2785
|
+
"official-modules"
|
|
2786
|
+
]
|
|
2787
|
+
},
|
|
2788
|
+
gitName: {
|
|
2789
|
+
type: "string",
|
|
2790
|
+
maxLength: 120,
|
|
2791
|
+
pattern: "^[A-Za-z0-9][A-Za-z0-9._/-]*$"
|
|
2792
|
+
},
|
|
2793
|
+
githubRepository: {
|
|
2794
|
+
type: "string",
|
|
2795
|
+
pattern: "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})/[A-Za-z0-9._-]{1,100}$"
|
|
2796
|
+
},
|
|
2797
|
+
githubAccount: {
|
|
2798
|
+
type: "string",
|
|
2799
|
+
pattern: "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$"
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
};
|
|
2803
|
+
|
|
2804
|
+
// ../contracts/schemas/module-catalog.schema.json
|
|
2805
|
+
var module_catalog_schema_default = {
|
|
2806
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
2807
|
+
$id: "https://flowdular.dev/schemas/module-catalog.schema.json",
|
|
2808
|
+
type: "object",
|
|
2809
|
+
additionalProperties: false,
|
|
2810
|
+
required: ["schemaVersion", "releases"],
|
|
2811
|
+
properties: {
|
|
2812
|
+
schemaVersion: {
|
|
2813
|
+
const: 1
|
|
2814
|
+
},
|
|
2815
|
+
releases: {
|
|
2816
|
+
type: "array",
|
|
2817
|
+
maxItems: 4096,
|
|
2818
|
+
items: {
|
|
2819
|
+
type: "object",
|
|
2820
|
+
additionalProperties: false,
|
|
2821
|
+
required: [
|
|
2822
|
+
"manifest",
|
|
2823
|
+
"artifact",
|
|
2824
|
+
"sha256",
|
|
2825
|
+
"sourceCommit",
|
|
2826
|
+
"license"
|
|
2827
|
+
],
|
|
2828
|
+
properties: {
|
|
2829
|
+
manifest: {
|
|
2830
|
+
$ref: "https://flowdular.dev/schemas/module.schema.json"
|
|
2831
|
+
},
|
|
2832
|
+
artifact: {
|
|
2833
|
+
type: "string",
|
|
2834
|
+
minLength: 1
|
|
2835
|
+
},
|
|
2836
|
+
sha256: {
|
|
2837
|
+
type: "string",
|
|
2838
|
+
pattern: "^[a-f0-9]{64}$"
|
|
2839
|
+
},
|
|
2840
|
+
sourceCommit: {
|
|
2841
|
+
type: "string",
|
|
2842
|
+
pattern: "^[a-f0-9]{40}$"
|
|
2843
|
+
},
|
|
2844
|
+
license: {
|
|
2845
|
+
type: "string",
|
|
2846
|
+
minLength: 1
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
};
|
|
2853
|
+
|
|
2854
|
+
// ../contracts/schemas/module-artifact.schema.json
|
|
2855
|
+
var module_artifact_schema_default = {
|
|
2856
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
2857
|
+
$id: "https://flowdular.dev/schemas/module-artifact.schema.json",
|
|
2858
|
+
type: "object",
|
|
2859
|
+
additionalProperties: false,
|
|
2860
|
+
required: ["schemaVersion", "manifest", "review", "files"],
|
|
2861
|
+
properties: {
|
|
2862
|
+
schemaVersion: {
|
|
2863
|
+
const: 1
|
|
2864
|
+
},
|
|
2865
|
+
manifest: {
|
|
2866
|
+
$ref: "https://flowdular.dev/schemas/module.schema.json"
|
|
2867
|
+
},
|
|
2868
|
+
review: {
|
|
2869
|
+
type: "object",
|
|
2870
|
+
additionalProperties: false,
|
|
2871
|
+
required: ["sourceSha256", "requirements", "findings", "checks"],
|
|
2872
|
+
properties: {
|
|
2873
|
+
sourceSha256: {
|
|
2874
|
+
type: "string",
|
|
2875
|
+
pattern: "^[a-f0-9]{64}$"
|
|
2876
|
+
},
|
|
2877
|
+
requirements: {
|
|
2878
|
+
type: "array",
|
|
2879
|
+
minItems: 1,
|
|
2880
|
+
items: {
|
|
2881
|
+
type: "string",
|
|
2882
|
+
minLength: 1
|
|
2883
|
+
}
|
|
2884
|
+
},
|
|
2885
|
+
findings: {
|
|
2886
|
+
type: "array",
|
|
2887
|
+
maxItems: 0
|
|
2888
|
+
},
|
|
2889
|
+
checks: {
|
|
2890
|
+
type: "array",
|
|
2891
|
+
minItems: 3,
|
|
2892
|
+
items: {
|
|
2893
|
+
type: "object",
|
|
2894
|
+
additionalProperties: false,
|
|
2895
|
+
required: ["name", "command", "exitCode"],
|
|
2896
|
+
properties: {
|
|
2897
|
+
name: {
|
|
2898
|
+
enum: ["typecheck", "test", "validate"]
|
|
2899
|
+
},
|
|
2900
|
+
command: {
|
|
2901
|
+
type: "string",
|
|
2902
|
+
minLength: 1
|
|
2903
|
+
},
|
|
2904
|
+
exitCode: {
|
|
2905
|
+
const: 0
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
},
|
|
2912
|
+
files: {
|
|
2913
|
+
type: "array",
|
|
2914
|
+
maxItems: 4096,
|
|
2915
|
+
items: {
|
|
2916
|
+
type: "object",
|
|
2917
|
+
additionalProperties: false,
|
|
2918
|
+
required: ["path", "content", "sha256"],
|
|
2919
|
+
properties: {
|
|
2920
|
+
path: {
|
|
2921
|
+
type: "string",
|
|
2922
|
+
minLength: 1,
|
|
2923
|
+
maxLength: 239
|
|
2924
|
+
},
|
|
2925
|
+
content: {
|
|
2926
|
+
type: "string"
|
|
2927
|
+
},
|
|
2928
|
+
sha256: {
|
|
2929
|
+
type: "string",
|
|
2930
|
+
pattern: "^[a-f0-9]{64}$"
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
}
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2936
|
+
};
|
|
2937
|
+
|
|
2938
|
+
// ../contracts/src/schemas.ts
|
|
2939
|
+
var blueprintSchema = blueprint_schema_default;
|
|
2940
|
+
var cliExtensionSchema = cli_extension_schema_default;
|
|
2941
|
+
var moduleSchema = module_schema_default;
|
|
2942
|
+
var moduleSpecSchema = module_spec_schema_default;
|
|
2943
|
+
var platformSpecSchema = platform_spec_schema_default;
|
|
2944
|
+
var projectSchema = project_schema_default;
|
|
2945
|
+
var moduleCatalogSchema = module_catalog_schema_default;
|
|
2946
|
+
var moduleArtifactSchema = module_artifact_schema_default;
|
|
2947
|
+
|
|
2948
|
+
// src/validation.ts
|
|
2949
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
2950
|
+
import { basename, dirname, join, relative } from "node:path";
|
|
2951
|
+
import Ajv2020 from "ajv/dist/2020.js";
|
|
2952
|
+
import { parse as parseYaml } from "yaml";
|
|
2953
|
+
var ajv = new Ajv2020({ allErrors: true, strict: true });
|
|
2954
|
+
var validators = {
|
|
2955
|
+
application: ajv.compile(projectSchema.properties.application),
|
|
2956
|
+
web: ajv.compile(projectSchema.properties.web),
|
|
2957
|
+
project: ajv.compile(projectSchema),
|
|
2958
|
+
module: ajv.compile(moduleSchema),
|
|
2959
|
+
moduleCatalog: ajv.compile(moduleCatalogSchema),
|
|
2960
|
+
moduleArtifact: ajv.compile(moduleArtifactSchema),
|
|
2961
|
+
moduleSpec: ajv.compile(moduleSpecSchema),
|
|
2962
|
+
blueprint: ajv.compile(blueprintSchema),
|
|
2963
|
+
cliExtension: ajv.compile(cliExtensionSchema),
|
|
2964
|
+
platformSpec: ajv.compile(platformSpecSchema)
|
|
2965
|
+
};
|
|
2966
|
+
var SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
2967
|
+
".git",
|
|
2968
|
+
".flowdular",
|
|
2969
|
+
".coreloom",
|
|
2970
|
+
"node_modules",
|
|
2971
|
+
"dist"
|
|
2972
|
+
]);
|
|
2973
|
+
async function findNamedFiles(root, name) {
|
|
2974
|
+
const matches = [];
|
|
2975
|
+
async function visit(directory) {
|
|
2976
|
+
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
2977
|
+
if (SKIPPED_DIRECTORIES.has(entry.name)) continue;
|
|
2978
|
+
const path = join(directory, entry.name);
|
|
2979
|
+
if (entry.isDirectory()) await visit(path);
|
|
2980
|
+
else if (entry.name === name) matches.push(path);
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
await visit(root);
|
|
2984
|
+
return matches.sort();
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
// src/module-artifact.ts
|
|
2988
|
+
var MAX_ARTIFACT_BYTES = 48 * 1024 * 1024;
|
|
2989
|
+
var MAX_SOURCE_BYTES = 32 * 1024 * 1024;
|
|
2990
|
+
var MAX_FILES = 4096;
|
|
2991
|
+
var hashBytes = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
2992
|
+
var HASH = /^[a-f0-9]{64}$/;
|
|
2993
|
+
var ROOTS = /* @__PURE__ */ new Set(["src", "tests", "migrations", "translations", "spec"]);
|
|
2994
|
+
var ROOT_FILES = /* @__PURE__ */ new Set([
|
|
2995
|
+
"module.json",
|
|
2996
|
+
"package.json",
|
|
2997
|
+
"README.md",
|
|
2998
|
+
"CHANGELOG.md",
|
|
2999
|
+
"LICENSE",
|
|
3000
|
+
"tsconfig.json",
|
|
3001
|
+
"vitest.config.ts"
|
|
3002
|
+
]);
|
|
3003
|
+
var ModuleDistributionError = class extends Error {
|
|
3004
|
+
constructor(code, message) {
|
|
3005
|
+
super(message);
|
|
3006
|
+
this.code = code;
|
|
3007
|
+
}
|
|
3008
|
+
};
|
|
3009
|
+
function distributionAssert(condition, code, message) {
|
|
3010
|
+
if (!condition) throw new ModuleDistributionError(code, message);
|
|
3011
|
+
}
|
|
3012
|
+
function safeSourcePath(path) {
|
|
3013
|
+
const parts = path.split("/");
|
|
3014
|
+
return path.length < 240 && /^[a-zA-Z0-9_./@+ -]+$/.test(path) && parts.every(
|
|
3015
|
+
(part) => part && part !== "." && part !== ".." && !part.startsWith(".") && part !== "node_modules" && part !== "dist"
|
|
3016
|
+
) && (parts.length === 1 ? ROOT_FILES.has(path) : ROOTS.has(parts[0]));
|
|
3017
|
+
}
|
|
3018
|
+
function sourceDigest(files) {
|
|
3019
|
+
return hashBytes(
|
|
3020
|
+
JSON.stringify(
|
|
3021
|
+
[...files].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0).map((file) => [file.path, file.sha256])
|
|
3022
|
+
)
|
|
3023
|
+
);
|
|
3024
|
+
}
|
|
3025
|
+
async function readModuleSource(root) {
|
|
3026
|
+
const files = [];
|
|
3027
|
+
let size = 0;
|
|
3028
|
+
async function visit(directory, prefix) {
|
|
3029
|
+
for (const entry of await readdir2(directory, { withFileTypes: true })) {
|
|
3030
|
+
const path = prefix + entry.name;
|
|
3031
|
+
if (!prefix && !ROOT_FILES.has(path) && !ROOTS.has(path)) continue;
|
|
3032
|
+
distributionAssert(
|
|
3033
|
+
!entry.isSymbolicLink(),
|
|
3034
|
+
"MODULE_SOURCE_LINK",
|
|
3035
|
+
`Module source contains a link: ${path}`
|
|
3036
|
+
);
|
|
3037
|
+
if (entry.isDirectory()) {
|
|
3038
|
+
distributionAssert(
|
|
3039
|
+
!entry.name.startsWith(".") && entry.name !== "node_modules" && entry.name !== "dist",
|
|
3040
|
+
"MODULE_SOURCE_PATH",
|
|
3041
|
+
`Unexpected module directory: ${path}`
|
|
3042
|
+
);
|
|
3043
|
+
await visit(join2(directory, entry.name), path + "/");
|
|
3044
|
+
} else {
|
|
3045
|
+
distributionAssert(
|
|
3046
|
+
entry.isFile() && safeSourcePath(path),
|
|
3047
|
+
"MODULE_SOURCE_PATH",
|
|
3048
|
+
`Unexpected module source: ${path}`
|
|
3049
|
+
);
|
|
3050
|
+
const stat2 = await lstat(join2(directory, entry.name));
|
|
3051
|
+
distributionAssert(
|
|
3052
|
+
size + stat2.size <= MAX_SOURCE_BYTES && files.length < MAX_FILES,
|
|
3053
|
+
"MODULE_SOURCE_LIMIT",
|
|
3054
|
+
"Module source is too large."
|
|
3055
|
+
);
|
|
3056
|
+
const bytes = await readFile2(join2(directory, entry.name));
|
|
3057
|
+
size += bytes.length;
|
|
3058
|
+
files.push({
|
|
3059
|
+
path,
|
|
3060
|
+
content: bytes.toString("base64"),
|
|
3061
|
+
sha256: hashBytes(bytes)
|
|
3062
|
+
});
|
|
3063
|
+
}
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
distributionAssert(
|
|
3067
|
+
!(await lstat(root)).isSymbolicLink(),
|
|
3068
|
+
"MODULE_SOURCE_LINK",
|
|
3069
|
+
"Module root cannot be a link."
|
|
3070
|
+
);
|
|
3071
|
+
await visit(root, "");
|
|
3072
|
+
return files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
3073
|
+
}
|
|
3074
|
+
function validateModuleArtifact(value) {
|
|
3075
|
+
const artifact = value;
|
|
3076
|
+
distributionAssert(
|
|
3077
|
+
validators.moduleArtifact(artifact) && artifact && artifact.schemaVersion === 1 && Array.isArray(artifact.files) && artifact.files.length <= MAX_FILES && validators.module(artifact.manifest),
|
|
3078
|
+
"MODULE_ARTIFACT_INVALID",
|
|
3079
|
+
"Invalid module artifact."
|
|
3080
|
+
);
|
|
3081
|
+
assertModuleCompatibility(artifact.manifest);
|
|
3082
|
+
distributionAssert(
|
|
3083
|
+
artifact.manifest.platformApi,
|
|
3084
|
+
"MODULE_PLATFORM_REQUIRED",
|
|
3085
|
+
"Distributed modules must declare platformApi."
|
|
3086
|
+
);
|
|
3087
|
+
const paths = /* @__PURE__ */ new Set();
|
|
3088
|
+
let size = 0;
|
|
3089
|
+
for (const file of artifact.files) {
|
|
3090
|
+
distributionAssert(
|
|
3091
|
+
file && typeof file.path === "string" && safeSourcePath(file.path) && typeof file.content === "string" && typeof file.sha256 === "string" && HASH.test(file.sha256),
|
|
3092
|
+
"MODULE_ARTIFACT_PATH",
|
|
3093
|
+
"Invalid artifact file."
|
|
3094
|
+
);
|
|
3095
|
+
const key = file.path.toLowerCase();
|
|
3096
|
+
distributionAssert(
|
|
3097
|
+
!paths.has(key),
|
|
3098
|
+
"MODULE_ARTIFACT_COLLISION",
|
|
3099
|
+
`Duplicate file: ${file.path}`
|
|
3100
|
+
);
|
|
3101
|
+
paths.add(key);
|
|
3102
|
+
const bytes = Buffer.from(file.content, "base64");
|
|
3103
|
+
size += bytes.length;
|
|
3104
|
+
distributionAssert(
|
|
3105
|
+
bytes.toString("base64") === file.content && hashBytes(bytes) === file.sha256 && size <= MAX_SOURCE_BYTES,
|
|
3106
|
+
"MODULE_ARTIFACT_DIGEST",
|
|
3107
|
+
`Invalid content: ${file.path}`
|
|
3108
|
+
);
|
|
3109
|
+
}
|
|
3110
|
+
for (const path of paths)
|
|
3111
|
+
for (const parent of path.split("/").slice(0, -1).map(
|
|
3112
|
+
(_, i) => path.split("/").slice(0, i + 1).join("/")
|
|
3113
|
+
))
|
|
3114
|
+
distributionAssert(
|
|
3115
|
+
!paths.has(parent),
|
|
3116
|
+
"MODULE_ARTIFACT_COLLISION",
|
|
3117
|
+
`File/directory collision: ${path}`
|
|
3118
|
+
);
|
|
3119
|
+
function json(path) {
|
|
3120
|
+
const file = artifact.files.find((file2) => file2.path === path);
|
|
3121
|
+
distributionAssert(
|
|
3122
|
+
file,
|
|
3123
|
+
"MODULE_ARTIFACT_MISSING",
|
|
3124
|
+
`Artifact is missing ${path}.`
|
|
3125
|
+
);
|
|
3126
|
+
return JSON.parse(
|
|
3127
|
+
Buffer.from(file.content, "base64").toString("utf8")
|
|
3128
|
+
);
|
|
3129
|
+
}
|
|
3130
|
+
const manifest = json("module.json");
|
|
3131
|
+
const pkg = json("package.json");
|
|
3132
|
+
distributionAssert(
|
|
3133
|
+
JSON.stringify(manifest) === JSON.stringify(artifact.manifest) && pkg.name === artifact.manifest.package && pkg.version === artifact.manifest.version && paths.has("spec/module.yaml"),
|
|
3134
|
+
"MODULE_ARTIFACT_IDENTITY",
|
|
3135
|
+
"Artifact identity does not match source/package/spec."
|
|
3136
|
+
);
|
|
3137
|
+
for (const section of [
|
|
3138
|
+
"dependencies",
|
|
3139
|
+
"devDependencies",
|
|
3140
|
+
"peerDependencies",
|
|
3141
|
+
"optionalDependencies"
|
|
3142
|
+
]) {
|
|
3143
|
+
const dependencies = pkg[section] ?? {};
|
|
3144
|
+
distributionAssert(
|
|
3145
|
+
Object.values(dependencies).every(
|
|
3146
|
+
(value2) => typeof value2 === "string" && !/^(workspace:|file:|link:)/.test(value2)
|
|
3147
|
+
),
|
|
3148
|
+
"MODULE_NONPORTABLE_DEPENDENCY",
|
|
3149
|
+
"Distributed module dependencies must resolve outside the authoring workspace."
|
|
3150
|
+
);
|
|
3151
|
+
}
|
|
3152
|
+
const specFile = artifact.files.find(
|
|
3153
|
+
(file) => file.path === "spec/module.yaml"
|
|
3154
|
+
);
|
|
3155
|
+
const spec = parseYaml2(
|
|
3156
|
+
Buffer.from(specFile.content, "base64").toString("utf8")
|
|
3157
|
+
);
|
|
3158
|
+
distributionAssert(
|
|
3159
|
+
validators.moduleSpec(spec) && spec.id === artifact.manifest.id && spec.specVersion === artifact.manifest.version,
|
|
3160
|
+
"MODULE_SPEC_INVALID",
|
|
3161
|
+
"Module specification is invalid or differs from the released identity."
|
|
3162
|
+
);
|
|
3163
|
+
const scripts = pkg.scripts ?? {};
|
|
3164
|
+
for (const script of ["preinstall", "install", "postinstall", "prepare"])
|
|
3165
|
+
distributionAssert(
|
|
3166
|
+
!(script in scripts),
|
|
3167
|
+
"MODULE_INSTALL_SCRIPT",
|
|
3168
|
+
`Install lifecycle scripts are forbidden: ${script}`
|
|
3169
|
+
);
|
|
3170
|
+
const review = artifact.review;
|
|
3171
|
+
distributionAssert(
|
|
3172
|
+
review && review.sourceSha256 === sourceDigest(artifact.files) && Array.isArray(review.findings) && review.findings.length === 0 && Array.isArray(review.requirements) && review.requirements.length > 0 && review.requirements.every(
|
|
3173
|
+
(item) => typeof item === "string" && item.trim()
|
|
3174
|
+
) && Array.isArray(review.checks),
|
|
3175
|
+
"MODULE_REVIEW_INVALID",
|
|
3176
|
+
"Missing, stale or failing review evidence."
|
|
3177
|
+
);
|
|
3178
|
+
for (const name of ["typecheck", "test", "validate"])
|
|
3179
|
+
distributionAssert(
|
|
3180
|
+
review.checks.some(
|
|
3181
|
+
(check) => check && check.name === name && check.exitCode === 0 && typeof check.command === "string" && check.command.trim()
|
|
3182
|
+
),
|
|
3183
|
+
"MODULE_REVIEW_INVALID",
|
|
3184
|
+
`Missing passing ${name} evidence.`
|
|
3185
|
+
);
|
|
3186
|
+
distributionAssert(
|
|
3187
|
+
review.checks.every((check) => check.exitCode === 0),
|
|
3188
|
+
"MODULE_REVIEW_INVALID",
|
|
3189
|
+
"Review contains a failing check."
|
|
3190
|
+
);
|
|
3191
|
+
return artifact;
|
|
3192
|
+
}
|
|
3193
|
+
async function packModule(root, review) {
|
|
3194
|
+
const files = await readModuleSource(root);
|
|
3195
|
+
const file = files.find((file2) => file2.path === "module.json");
|
|
3196
|
+
distributionAssert(
|
|
3197
|
+
file,
|
|
3198
|
+
"MODULE_ARTIFACT_MISSING",
|
|
3199
|
+
"module.json is missing."
|
|
3200
|
+
);
|
|
3201
|
+
const manifest = JSON.parse(
|
|
3202
|
+
Buffer.from(file.content, "base64").toString("utf8")
|
|
3203
|
+
);
|
|
3204
|
+
return validateModuleArtifact({ schemaVersion: 1, manifest, files, review });
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
// src/module-catalog.ts
|
|
3208
|
+
import { readFile as readFile4, stat } from "node:fs/promises";
|
|
3209
|
+
import { dirname as dirname3, resolve as resolve2 } from "node:path";
|
|
3210
|
+
|
|
3211
|
+
// src/workspace.ts
|
|
3212
|
+
import { access, readFile as readFile3, realpath } from "node:fs/promises";
|
|
3213
|
+
import { dirname as dirname2, isAbsolute, relative as relative2, resolve } from "node:path";
|
|
3214
|
+
function resolveInside(root, candidate) {
|
|
3215
|
+
const absolute = isAbsolute(candidate) ? resolve(candidate) : resolve(root, candidate);
|
|
3216
|
+
const pathFromRoot = relative2(root, absolute);
|
|
3217
|
+
if (pathFromRoot.startsWith("..") || isAbsolute(pathFromRoot)) {
|
|
3218
|
+
throw new Error(`Path escapes the workspace: ${candidate}`);
|
|
3219
|
+
}
|
|
3220
|
+
return absolute;
|
|
3221
|
+
}
|
|
3222
|
+
async function resolveExistingInside(root, candidate) {
|
|
3223
|
+
const canonicalRoot = await realpath(root);
|
|
3224
|
+
const canonicalCandidate = await realpath(resolveInside(root, candidate));
|
|
3225
|
+
const pathFromRoot = relative2(canonicalRoot, canonicalCandidate);
|
|
3226
|
+
if (pathFromRoot.startsWith("..") || isAbsolute(pathFromRoot)) {
|
|
3227
|
+
throw new Error(`Path escapes the workspace through a link: ${candidate}`);
|
|
3228
|
+
}
|
|
3229
|
+
return canonicalCandidate;
|
|
3230
|
+
}
|
|
3231
|
+
|
|
3232
|
+
// src/module-catalog.ts
|
|
3233
|
+
var OFFICIAL_CATALOG = "https://raw.githubusercontent.com/Flowdular/official-modules/main/registry/index.json";
|
|
3234
|
+
var OFFICIAL_PREFIX = "https://raw.githubusercontent.com/Flowdular/official-modules/";
|
|
3235
|
+
async function boundedRead(location, limit, fetcher = fetch) {
|
|
3236
|
+
if (!location.startsWith("https://")) {
|
|
3237
|
+
distributionAssert(
|
|
3238
|
+
(await stat(location)).size <= limit,
|
|
3239
|
+
"MODULE_DOWNLOAD_LIMIT",
|
|
3240
|
+
"Module metadata/artifact exceeds the size limit."
|
|
3241
|
+
);
|
|
3242
|
+
const result = await readFile4(location);
|
|
3243
|
+
distributionAssert(
|
|
3244
|
+
result.length <= limit,
|
|
3245
|
+
"MODULE_DOWNLOAD_LIMIT",
|
|
3246
|
+
"Module file grew beyond the size limit."
|
|
3247
|
+
);
|
|
3248
|
+
return result;
|
|
3249
|
+
}
|
|
3250
|
+
distributionAssert(
|
|
3251
|
+
location.startsWith(OFFICIAL_PREFIX),
|
|
3252
|
+
"MODULE_SOURCE_UNTRUSTED",
|
|
3253
|
+
"Only the official HTTPS publisher is supported. Use an explicit local catalog for offline releases."
|
|
3254
|
+
);
|
|
3255
|
+
const response = await fetcher(location, {
|
|
3256
|
+
redirect: "error",
|
|
3257
|
+
signal: AbortSignal.timeout(3e4)
|
|
3258
|
+
});
|
|
3259
|
+
distributionAssert(
|
|
3260
|
+
response.ok && response.body,
|
|
3261
|
+
"MODULE_DOWNLOAD_FAILED",
|
|
3262
|
+
`Official module download failed (${response.status}).`
|
|
3263
|
+
);
|
|
3264
|
+
const reader = response.body.getReader();
|
|
3265
|
+
const chunks = [];
|
|
3266
|
+
let size = 0;
|
|
3267
|
+
try {
|
|
3268
|
+
for (; ; ) {
|
|
3269
|
+
const { done, value } = await reader.read();
|
|
3270
|
+
if (done) break;
|
|
3271
|
+
size += value.length;
|
|
3272
|
+
distributionAssert(
|
|
3273
|
+
size <= limit,
|
|
3274
|
+
"MODULE_DOWNLOAD_LIMIT",
|
|
3275
|
+
"Module download exceeds the size limit."
|
|
3276
|
+
);
|
|
3277
|
+
chunks.push(value);
|
|
3278
|
+
}
|
|
3279
|
+
} finally {
|
|
3280
|
+
await reader.cancel();
|
|
3281
|
+
}
|
|
3282
|
+
return Buffer.concat(chunks);
|
|
3283
|
+
}
|
|
3284
|
+
async function loadModuleCatalog(location = OFFICIAL_CATALOG, fetcher = fetch) {
|
|
3285
|
+
distributionAssert(
|
|
3286
|
+
location === OFFICIAL_CATALOG || !/^[a-z][a-z0-9+.-]*:/i.test(location),
|
|
3287
|
+
"MODULE_SOURCE_UNTRUSTED",
|
|
3288
|
+
"Use the official catalog or an explicit local catalog path."
|
|
3289
|
+
);
|
|
3290
|
+
const catalog = JSON.parse(
|
|
3291
|
+
(await boundedRead(location, 4 * 1024 * 1024, fetcher)).toString("utf8")
|
|
3292
|
+
);
|
|
3293
|
+
distributionAssert(
|
|
3294
|
+
validators.moduleCatalog(catalog) && catalog && catalog.schemaVersion === 1 && Array.isArray(catalog.releases) && catalog.releases.length <= 4096,
|
|
3295
|
+
"MODULE_CATALOG_INVALID",
|
|
3296
|
+
"Invalid module catalog."
|
|
3297
|
+
);
|
|
3298
|
+
const identities = /* @__PURE__ */ new Set();
|
|
3299
|
+
for (const release of catalog.releases) {
|
|
3300
|
+
distributionAssert(
|
|
3301
|
+
release && validators.module(release.manifest) && /^@flowdular\/module-[a-z0-9-]+$/.test(release.manifest.package) && typeof release.artifact === "string" && /^[a-f0-9]{64}$/.test(release.sha256) && /^[a-f0-9]{40}$/.test(release.sourceCommit) && typeof release.license === "string" && release.license.trim(),
|
|
3302
|
+
"MODULE_CATALOG_INVALID",
|
|
3303
|
+
"Invalid module release."
|
|
3304
|
+
);
|
|
3305
|
+
assertModuleCompatibility(release.manifest, null);
|
|
3306
|
+
distributionAssert(
|
|
3307
|
+
release.manifest.platformApi,
|
|
3308
|
+
"MODULE_PLATFORM_REQUIRED",
|
|
3309
|
+
"Distributed modules must declare platformApi."
|
|
3310
|
+
);
|
|
3311
|
+
const identity = release.manifest.id + "@" + release.manifest.version;
|
|
3312
|
+
distributionAssert(
|
|
3313
|
+
!identities.has(identity),
|
|
3314
|
+
"MODULE_CATALOG_DUPLICATE",
|
|
3315
|
+
`Duplicate release: ${identity}`
|
|
3316
|
+
);
|
|
3317
|
+
identities.add(identity);
|
|
3318
|
+
}
|
|
3319
|
+
return { catalog, location };
|
|
3320
|
+
}
|
|
3321
|
+
async function releaseLocation(source, release) {
|
|
3322
|
+
if (source.location.startsWith("https://")) {
|
|
3323
|
+
const prefix = OFFICIAL_PREFIX + release.sourceCommit + "/";
|
|
3324
|
+
distributionAssert(
|
|
3325
|
+
release.artifact.startsWith(prefix) && new URL(release.artifact).href === release.artifact && !new URL(release.artifact).search && !new URL(release.artifact).hash,
|
|
3326
|
+
"MODULE_SOURCE_UNTRUSTED",
|
|
3327
|
+
"Release artifact must be pinned to its official source commit."
|
|
3328
|
+
);
|
|
3329
|
+
return release.artifact;
|
|
3330
|
+
}
|
|
3331
|
+
distributionAssert(
|
|
3332
|
+
!/^[a-z][a-z0-9+.-]*:/i.test(release.artifact),
|
|
3333
|
+
"MODULE_SOURCE_UNTRUSTED",
|
|
3334
|
+
"An offline catalog must use local artifacts."
|
|
3335
|
+
);
|
|
3336
|
+
return resolveExistingInside(
|
|
3337
|
+
dirname3(resolve2(source.location)),
|
|
3338
|
+
release.artifact
|
|
3339
|
+
);
|
|
3340
|
+
}
|
|
3341
|
+
function resolveModuleReleases(catalog, target, installed) {
|
|
3342
|
+
const split = target.lastIndexOf("@");
|
|
3343
|
+
const id = split < 0 ? target : target.slice(0, split);
|
|
3344
|
+
const range = split < 0 ? "*" : target.slice(split + 1);
|
|
3345
|
+
distributionAssert(
|
|
3346
|
+
/^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/.test(id) && range,
|
|
3347
|
+
"MODULE_TARGET_INVALID",
|
|
3348
|
+
"Use module.id or module.id@version/range."
|
|
3349
|
+
);
|
|
3350
|
+
const existing = new Map(
|
|
3351
|
+
installed.map((manifest) => [manifest.id, manifest])
|
|
3352
|
+
);
|
|
3353
|
+
const candidates = /* @__PURE__ */ new Map();
|
|
3354
|
+
for (const release of catalog.releases) {
|
|
3355
|
+
const entries = candidates.get(release.manifest.id) ?? [];
|
|
3356
|
+
entries.push(release);
|
|
3357
|
+
candidates.set(release.manifest.id, entries);
|
|
3358
|
+
}
|
|
3359
|
+
for (const entries of candidates.values())
|
|
3360
|
+
entries.sort(
|
|
3361
|
+
(a, b) => compareModuleVersions(a.manifest.version, b.manifest.version)
|
|
3362
|
+
);
|
|
3363
|
+
let attempts = 0;
|
|
3364
|
+
function search(selected2, pending) {
|
|
3365
|
+
distributionAssert(
|
|
3366
|
+
++attempts <= 1e4 && pending.length <= 4096 && selected2.size <= 256,
|
|
3367
|
+
"MODULE_RESOLUTION_LIMIT",
|
|
3368
|
+
"Module dependency resolution limit exceeded."
|
|
3369
|
+
);
|
|
3370
|
+
const [next, ...rest] = pending;
|
|
3371
|
+
if (!next) return selected2;
|
|
3372
|
+
const fixed = selected2.get(next.id)?.manifest ?? existing.get(next.id);
|
|
3373
|
+
if (fixed)
|
|
3374
|
+
return satisfiesModuleVersion(fixed.version, next.range) ? search(selected2, rest) : void 0;
|
|
3375
|
+
for (const candidate of candidates.get(next.id) ?? []) {
|
|
3376
|
+
if (!satisfiesModuleVersion(candidate.manifest.version, next.range) || !satisfiesModuleVersion(
|
|
3377
|
+
PLATFORM_API_VERSION,
|
|
3378
|
+
candidate.manifest.platformApi
|
|
3379
|
+
))
|
|
3380
|
+
continue;
|
|
3381
|
+
const found = search(new Map([...selected2, [next.id, candidate]]), [
|
|
3382
|
+
...candidate.manifest.dependencies,
|
|
3383
|
+
...rest
|
|
3384
|
+
]);
|
|
3385
|
+
if (found) return found;
|
|
3386
|
+
}
|
|
3387
|
+
return void 0;
|
|
3388
|
+
}
|
|
3389
|
+
const selected = search(/* @__PURE__ */ new Map(), [{ id, range }]);
|
|
3390
|
+
distributionAssert(
|
|
3391
|
+
selected,
|
|
3392
|
+
"MODULE_RESOLUTION_FAILED",
|
|
3393
|
+
`No compatible dependency closure for ${target}. Installed versions are preserved.`
|
|
3394
|
+
);
|
|
3395
|
+
const all = [
|
|
3396
|
+
...installed,
|
|
3397
|
+
...[...selected.values()].map((release) => release.manifest)
|
|
3398
|
+
];
|
|
3399
|
+
const registry = createModuleRegistry(all.map((manifest) => ({ manifest })));
|
|
3400
|
+
return registry.modules.flatMap((module) => {
|
|
3401
|
+
const release = selected.get(module.manifest.id);
|
|
3402
|
+
return release ? [release] : [];
|
|
3403
|
+
});
|
|
3404
|
+
}
|
|
3405
|
+
async function readRelease(source, release, fetcher = fetch) {
|
|
3406
|
+
return boundedRead(
|
|
3407
|
+
await releaseLocation(source, release),
|
|
3408
|
+
MAX_ARTIFACT_BYTES,
|
|
3409
|
+
fetcher
|
|
3410
|
+
);
|
|
3411
|
+
}
|
|
3412
|
+
|
|
3413
|
+
// src/module-install.ts
|
|
3414
|
+
import {
|
|
3415
|
+
lstat as lstat3,
|
|
3416
|
+
mkdir,
|
|
3417
|
+
readFile as readFile8,
|
|
3418
|
+
readdir as readdir4,
|
|
3419
|
+
rename,
|
|
3420
|
+
rm,
|
|
3421
|
+
writeFile
|
|
3422
|
+
} from "node:fs/promises";
|
|
3423
|
+
import { dirname as dirname6, join as join6, relative as relative5 } from "node:path";
|
|
3424
|
+
|
|
3425
|
+
// src/sdk.ts
|
|
3426
|
+
import { createRequire } from "node:module";
|
|
3427
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
3428
|
+
import { dirname as dirname4, join as join3 } from "node:path";
|
|
3429
|
+
var SDK_VERSION = "0.1.0";
|
|
3430
|
+
function npmPackage(specifier) {
|
|
3431
|
+
return specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0];
|
|
3432
|
+
}
|
|
3433
|
+
async function sdkModules(workspace) {
|
|
3434
|
+
const require2 = createRequire(join3(workspace.root, "platform/package.json"));
|
|
3435
|
+
let indexPath;
|
|
3436
|
+
try {
|
|
3437
|
+
indexPath = require2.resolve("@flowdular/sdk/modules.json");
|
|
3438
|
+
} catch (error) {
|
|
3439
|
+
if (["MODULE_NOT_FOUND", "ERR_PACKAGE_PATH_NOT_EXPORTED"].includes(
|
|
3440
|
+
error.code ?? ""
|
|
3441
|
+
))
|
|
3442
|
+
return /* @__PURE__ */ new Map();
|
|
3443
|
+
throw error;
|
|
3444
|
+
}
|
|
3445
|
+
const index = JSON.parse(await readFile5(indexPath, "utf8"));
|
|
3446
|
+
if (index.schemaVersion !== 1 || !Array.isArray(index.modules) || index.modules.length > 256)
|
|
3447
|
+
throw new Error("Invalid SDK module index.");
|
|
3448
|
+
const result = /* @__PURE__ */ new Map();
|
|
3449
|
+
for (const entry of index.modules) {
|
|
3450
|
+
if (!/^@flowdular\/sdk\/modules\/[a-z0-9-]+$/.test(entry.import))
|
|
3451
|
+
throw new Error("Invalid SDK module entrypoint.");
|
|
3452
|
+
const path = await resolveExistingInside(
|
|
3453
|
+
dirname4(indexPath),
|
|
3454
|
+
entry.manifest
|
|
3455
|
+
);
|
|
3456
|
+
if (result.has(path)) throw new Error("Duplicate SDK module path.");
|
|
3457
|
+
result.set(path, entry.import);
|
|
3458
|
+
}
|
|
3459
|
+
return result;
|
|
3460
|
+
}
|
|
3461
|
+
|
|
3462
|
+
// src/module-files.ts
|
|
3463
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
3464
|
+
import { lstat as lstat2, readFile as readFile6 } from "node:fs/promises";
|
|
3465
|
+
import { join as join4, relative as relative3 } from "node:path";
|
|
3466
|
+
function moduleRoots(workspace) {
|
|
3467
|
+
const roots = workspace.config.modules?.roots ?? ["modules"];
|
|
3468
|
+
if (!Array.isArray(roots) || !roots.length || roots.some(
|
|
3469
|
+
(root) => typeof root !== "string" || !root || root.startsWith(".") || root.includes("\\") || root.split("/").some((part) => part === ".." || !part)
|
|
3470
|
+
))
|
|
3471
|
+
throw new Error(
|
|
3472
|
+
"Invalid modules.roots. Use relative workspace directories."
|
|
3473
|
+
);
|
|
3474
|
+
return roots.map((root) => {
|
|
3475
|
+
const path = resolveInside(workspace.root, root);
|
|
3476
|
+
if (!relative3(workspace.root, path))
|
|
3477
|
+
throw new Error("The workspace root cannot be a module root.");
|
|
3478
|
+
return path;
|
|
3479
|
+
});
|
|
3480
|
+
}
|
|
3481
|
+
async function findModuleFiles(workspace) {
|
|
3482
|
+
const files = /* @__PURE__ */ new Set();
|
|
3483
|
+
for (const root of moduleRoots(workspace)) {
|
|
3484
|
+
try {
|
|
3485
|
+
await lstat2(root);
|
|
3486
|
+
} catch (error) {
|
|
3487
|
+
if (error.code === "ENOENT") continue;
|
|
3488
|
+
throw error;
|
|
3489
|
+
}
|
|
3490
|
+
await resolveExistingInside(workspace.root, root);
|
|
3491
|
+
for (const file of await findNamedFiles(root, "module.json")) {
|
|
3492
|
+
if (relative3(root, file).split("/").length === 2) files.add(file);
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
const packages = /* @__PURE__ */ new Set();
|
|
3496
|
+
for (const file of files)
|
|
3497
|
+
packages.add(
|
|
3498
|
+
JSON.parse(await readFile6(file, "utf8")).package
|
|
3499
|
+
);
|
|
3500
|
+
for (const file of (await sdkModules(workspace)).keys()) {
|
|
3501
|
+
const manifest = JSON.parse(await readFile6(file, "utf8"));
|
|
3502
|
+
if (!packages.has(manifest.package)) files.add(file);
|
|
3503
|
+
}
|
|
3504
|
+
const platformPackage = join4(workspace.root, "platform/package.json");
|
|
3505
|
+
try {
|
|
3506
|
+
const pkg = JSON.parse(await readFile6(platformPackage, "utf8"));
|
|
3507
|
+
const require2 = createRequire2(platformPackage);
|
|
3508
|
+
for (const name of Object.keys(pkg.dependencies ?? {}).sort()) {
|
|
3509
|
+
if (!name.startsWith("@flowdular/module-") || packages.has(name))
|
|
3510
|
+
continue;
|
|
3511
|
+
let file;
|
|
3512
|
+
try {
|
|
3513
|
+
file = require2.resolve(name + "/module.json");
|
|
3514
|
+
} catch (error) {
|
|
3515
|
+
if (["MODULE_NOT_FOUND", "ERR_PACKAGE_PATH_NOT_EXPORTED"].includes(
|
|
3516
|
+
error.code ?? ""
|
|
3517
|
+
))
|
|
3518
|
+
continue;
|
|
3519
|
+
throw error;
|
|
3520
|
+
}
|
|
3521
|
+
files.add(file);
|
|
3522
|
+
}
|
|
3523
|
+
} catch (error) {
|
|
3524
|
+
if (error.code !== "ENOENT") throw error;
|
|
3525
|
+
}
|
|
3526
|
+
return [...files].sort();
|
|
3527
|
+
}
|
|
3528
|
+
|
|
3529
|
+
// src/module-validate.ts
|
|
3530
|
+
import { access as access2, readFile as readFile7, readdir as readdir3 } from "node:fs/promises";
|
|
3531
|
+
import { dirname as dirname5, join as join5, relative as relative4 } from "node:path";
|
|
3532
|
+
import { parse as parseYaml3 } from "yaml";
|
|
3533
|
+
function issue(code, message, path, severity = "error") {
|
|
3534
|
+
return { code, message, path, severity };
|
|
3535
|
+
}
|
|
3536
|
+
async function exists(path) {
|
|
3537
|
+
try {
|
|
3538
|
+
await access2(path);
|
|
3539
|
+
return true;
|
|
3540
|
+
} catch {
|
|
3541
|
+
return false;
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
async function readJson(path) {
|
|
3545
|
+
return JSON.parse(await readFile7(path, "utf8"));
|
|
3546
|
+
}
|
|
3547
|
+
async function clientSourceFiles(moduleRoot) {
|
|
3548
|
+
const clientRoot = join5(moduleRoot, "src/client");
|
|
3549
|
+
if (!await exists(clientRoot)) return [];
|
|
3550
|
+
return (await readdir3(clientRoot, {
|
|
3551
|
+
recursive: true,
|
|
3552
|
+
withFileTypes: true
|
|
3553
|
+
})).filter((entry) => entry.isFile() && /\.(?:ts|tsx|tsrx)$/.test(entry.name)).map((entry) => join5(entry.parentPath, entry.name));
|
|
3554
|
+
}
|
|
3555
|
+
async function platformIssues(moduleRoot, manifest) {
|
|
3556
|
+
const issues = [];
|
|
3557
|
+
let exports = {};
|
|
3558
|
+
let packageName;
|
|
3559
|
+
let packageVersion;
|
|
3560
|
+
try {
|
|
3561
|
+
const pkg = await readJson(join5(moduleRoot, "package.json"));
|
|
3562
|
+
exports = pkg.exports ?? {};
|
|
3563
|
+
packageName = pkg.name;
|
|
3564
|
+
packageVersion = pkg.version;
|
|
3565
|
+
} catch (error) {
|
|
3566
|
+
issues.push(
|
|
3567
|
+
issue(
|
|
3568
|
+
"PACKAGE_MANIFEST_INVALID",
|
|
3569
|
+
`package.json could not be read: ${error instanceof Error ? error.message : String(error)}`,
|
|
3570
|
+
"package.json"
|
|
3571
|
+
)
|
|
3572
|
+
);
|
|
3573
|
+
return issues;
|
|
3574
|
+
}
|
|
3575
|
+
if (packageName !== manifest.package) {
|
|
3576
|
+
issues.push(
|
|
3577
|
+
issue(
|
|
3578
|
+
"PACKAGE_NAME_MISMATCH",
|
|
3579
|
+
`package.json name "${String(packageName)}" differs from module.json package "${manifest.package}".`,
|
|
3580
|
+
"package.json"
|
|
3581
|
+
)
|
|
3582
|
+
);
|
|
3583
|
+
}
|
|
3584
|
+
if (packageVersion !== manifest.version) {
|
|
3585
|
+
issues.push(
|
|
3586
|
+
issue(
|
|
3587
|
+
"PACKAGE_VERSION_MISMATCH",
|
|
3588
|
+
`package.json version "${String(packageVersion)}" differs from module.json version "${manifest.version}".`,
|
|
3589
|
+
"package.json"
|
|
3590
|
+
)
|
|
3591
|
+
);
|
|
3592
|
+
}
|
|
3593
|
+
if (manifest.platform?.server === true) {
|
|
3594
|
+
if (!await exists(join5(moduleRoot, "src/platform.ts"))) {
|
|
3595
|
+
issues.push(
|
|
3596
|
+
issue(
|
|
3597
|
+
"PLATFORM_SERVER_ENTRY_MISSING",
|
|
3598
|
+
"platform.server requires src/platform.ts exporting createServerComposition.",
|
|
3599
|
+
"src/platform.ts"
|
|
3600
|
+
)
|
|
3601
|
+
);
|
|
3602
|
+
}
|
|
3603
|
+
if (!("./platform" in exports)) {
|
|
3604
|
+
issues.push(
|
|
3605
|
+
issue(
|
|
3606
|
+
"PLATFORM_EXPORT_MISSING",
|
|
3607
|
+
'platform.server requires a "./platform" entry in package.json exports.',
|
|
3608
|
+
"package.json"
|
|
3609
|
+
)
|
|
3610
|
+
);
|
|
3611
|
+
}
|
|
3612
|
+
}
|
|
3613
|
+
if (manifest.platform?.client === true) {
|
|
3614
|
+
if (!await exists(join5(moduleRoot, "src/client/index.ts"))) {
|
|
3615
|
+
issues.push(
|
|
3616
|
+
issue(
|
|
3617
|
+
"PLATFORM_CLIENT_ENTRY_MISSING",
|
|
3618
|
+
"platform.client requires src/client/index.ts exporting createClientContribution.",
|
|
3619
|
+
"src/client/index.ts"
|
|
3620
|
+
)
|
|
3621
|
+
);
|
|
3622
|
+
}
|
|
3623
|
+
if (!("./client" in exports)) {
|
|
3624
|
+
issues.push(
|
|
3625
|
+
issue(
|
|
3626
|
+
"PLATFORM_CLIENT_EXPORT_MISSING",
|
|
3627
|
+
'platform.client requires a "./client" entry in package.json exports.',
|
|
3628
|
+
"package.json"
|
|
3629
|
+
)
|
|
3630
|
+
);
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
return issues;
|
|
3634
|
+
}
|
|
3635
|
+
async function specIssues(moduleRoot, manifest, specDirectory) {
|
|
3636
|
+
const specPath = join5(specDirectory, "module.yaml");
|
|
3637
|
+
let spec;
|
|
3638
|
+
try {
|
|
3639
|
+
spec = parseYaml3(
|
|
3640
|
+
await readFile7(join5(moduleRoot, specPath), "utf8")
|
|
3641
|
+
);
|
|
3642
|
+
} catch (error) {
|
|
3643
|
+
return [
|
|
3644
|
+
issue(
|
|
3645
|
+
"SPEC_FILE_MISSING",
|
|
3646
|
+
`Module specification could not be read: ${error instanceof Error ? error.message : String(error)}`,
|
|
3647
|
+
specPath,
|
|
3648
|
+
"warning"
|
|
3649
|
+
)
|
|
3650
|
+
];
|
|
3651
|
+
}
|
|
3652
|
+
const issues = [];
|
|
3653
|
+
if (spec.id !== manifest.id) {
|
|
3654
|
+
issues.push(
|
|
3655
|
+
issue(
|
|
3656
|
+
"SPEC_ID_MISMATCH",
|
|
3657
|
+
`Specification id "${String(spec.id)}" differs from module.json id "${manifest.id}".`,
|
|
3658
|
+
specPath
|
|
3659
|
+
)
|
|
3660
|
+
);
|
|
3661
|
+
}
|
|
3662
|
+
if (String(spec.specVersion) !== manifest.version) {
|
|
3663
|
+
issues.push(
|
|
3664
|
+
issue(
|
|
3665
|
+
"SPEC_VERSION_DRIFT",
|
|
3666
|
+
`module.json version ${manifest.version} differs from specVersion ${String(spec.specVersion)}.`,
|
|
3667
|
+
specPath,
|
|
3668
|
+
"warning"
|
|
3669
|
+
)
|
|
3670
|
+
);
|
|
3671
|
+
}
|
|
3672
|
+
return issues;
|
|
3673
|
+
}
|
|
3674
|
+
async function translationIssues(moduleRoot, manifest, projectLocales) {
|
|
3675
|
+
const issues = [];
|
|
3676
|
+
if (projectLocales) {
|
|
3677
|
+
for (const locale of manifest.locales) {
|
|
3678
|
+
if (!projectLocales.includes(locale)) {
|
|
3679
|
+
issues.push(
|
|
3680
|
+
issue(
|
|
3681
|
+
"LOCALE_NOT_IN_PROJECT",
|
|
3682
|
+
`Locale "${locale}" is not listed in flowdular.json locales.`,
|
|
3683
|
+
"module.json",
|
|
3684
|
+
"warning"
|
|
3685
|
+
)
|
|
3686
|
+
);
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
if (!manifest.capabilities.includes("translations")) return issues;
|
|
3691
|
+
const keySets = /* @__PURE__ */ new Map();
|
|
3692
|
+
for (const locale of manifest.locales) {
|
|
3693
|
+
const path = `translations/${locale}.json`;
|
|
3694
|
+
if (!await exists(join5(moduleRoot, path))) {
|
|
3695
|
+
issues.push(
|
|
3696
|
+
issue(
|
|
3697
|
+
"TRANSLATION_FILE_MISSING",
|
|
3698
|
+
`Locale "${locale}" has no ${path}.`,
|
|
3699
|
+
path
|
|
3700
|
+
)
|
|
3701
|
+
);
|
|
3702
|
+
continue;
|
|
3703
|
+
}
|
|
3704
|
+
try {
|
|
3705
|
+
const bundle = await readJson(join5(moduleRoot, path));
|
|
3706
|
+
if (!bundle || typeof bundle !== "object" || Array.isArray(bundle)) {
|
|
3707
|
+
throw new Error("Expected a JSON object.");
|
|
3708
|
+
}
|
|
3709
|
+
keySets.set(locale, Object.keys(bundle).sort());
|
|
3710
|
+
} catch (error) {
|
|
3711
|
+
issues.push(
|
|
3712
|
+
issue(
|
|
3713
|
+
"TRANSLATION_PARSE_ERROR",
|
|
3714
|
+
`${path} is not a JSON object: ${error instanceof Error ? error.message : String(error)}`,
|
|
3715
|
+
path
|
|
3716
|
+
)
|
|
3717
|
+
);
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
const [reference, ...others] = [...keySets.entries()];
|
|
3721
|
+
if (!reference) return issues;
|
|
3722
|
+
for (const [locale, keys] of others) {
|
|
3723
|
+
const missing = reference[1].filter((key) => !keys.includes(key));
|
|
3724
|
+
const extra = keys.filter((key) => !reference[1].includes(key));
|
|
3725
|
+
if (missing.length === 0 && extra.length === 0) continue;
|
|
3726
|
+
const detail = [
|
|
3727
|
+
...missing.length > 0 ? [`missing ${missing.join(", ")}`] : [],
|
|
3728
|
+
...extra.length > 0 ? [`extra ${extra.join(", ")}`] : []
|
|
3729
|
+
].join("; ");
|
|
3730
|
+
issues.push(
|
|
3731
|
+
issue(
|
|
3732
|
+
"TRANSLATION_KEYS_MISMATCH",
|
|
3733
|
+
`translations/${locale}.json keys differ from translations/${reference[0]}.json: ${detail}.`,
|
|
3734
|
+
`translations/${locale}.json`
|
|
3735
|
+
)
|
|
3736
|
+
);
|
|
3737
|
+
}
|
|
3738
|
+
const referenceKeys = new Set(reference[1]);
|
|
3739
|
+
const files = await clientSourceFiles(moduleRoot);
|
|
3740
|
+
if (files.length > 0) {
|
|
3741
|
+
const namespace = manifest.id.split(".")[0] ?? manifest.id;
|
|
3742
|
+
const prefix = namespace + ".";
|
|
3743
|
+
const missing = /* @__PURE__ */ new Map();
|
|
3744
|
+
const pattern = /\bt\s*\(\s*(['"])([a-zA-Z0-9._-]+)\1/g;
|
|
3745
|
+
for (const file of files) {
|
|
3746
|
+
const source = await readFile7(file, "utf8");
|
|
3747
|
+
for (const match of source.matchAll(pattern)) {
|
|
3748
|
+
const fullKey = match[2];
|
|
3749
|
+
if (!fullKey.startsWith(prefix) || fullKey.endsWith(".")) continue;
|
|
3750
|
+
const localKey = fullKey.slice(prefix.length);
|
|
3751
|
+
if (!referenceKeys.has(localKey)) {
|
|
3752
|
+
missing.set(fullKey, relative4(moduleRoot, file));
|
|
3753
|
+
}
|
|
3754
|
+
}
|
|
3755
|
+
}
|
|
3756
|
+
for (const [key, path] of [...missing].sort(
|
|
3757
|
+
([left], [right]) => left.localeCompare(right)
|
|
3758
|
+
)) {
|
|
3759
|
+
issues.push(
|
|
3760
|
+
issue(
|
|
3761
|
+
"TRANSLATION_KEY_MISSING",
|
|
3762
|
+
`Translation key "${key}" is used by the client but absent from translations/${reference[0]}.json.`,
|
|
3763
|
+
path
|
|
3764
|
+
)
|
|
3765
|
+
);
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
return issues;
|
|
3769
|
+
}
|
|
3770
|
+
async function userInterfaceIssues(moduleRoot) {
|
|
3771
|
+
const issues = [];
|
|
3772
|
+
for (const file of await clientSourceFiles(moduleRoot)) {
|
|
3773
|
+
const source = await readFile7(file, "utf8");
|
|
3774
|
+
const path = relative4(moduleRoot, file);
|
|
3775
|
+
if (/<table\b/.test(source)) {
|
|
3776
|
+
issues.push(
|
|
3777
|
+
issue(
|
|
3778
|
+
"RAW_TABLE_FORBIDDEN",
|
|
3779
|
+
"Module screens use Table or TableCard from @flowdular/ui instead of raw table markup.",
|
|
3780
|
+
path
|
|
3781
|
+
)
|
|
3782
|
+
);
|
|
3783
|
+
}
|
|
3784
|
+
if (/from\s+['"]@octanejs\/tanstack-table['"]/.test(source)) {
|
|
3785
|
+
issues.push(
|
|
3786
|
+
issue(
|
|
3787
|
+
"TANSTACK_TABLE_DIRECT_IMPORT",
|
|
3788
|
+
"Modules use the shared Table contract from @flowdular/ui; TanStack configuration belongs to the UI package.",
|
|
3789
|
+
path
|
|
3790
|
+
)
|
|
3791
|
+
);
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
return issues;
|
|
3795
|
+
}
|
|
3796
|
+
async function moduleLayoutIssues(moduleRoot, manifest, options = {}) {
|
|
3797
|
+
return [
|
|
3798
|
+
...await platformIssues(moduleRoot, manifest),
|
|
3799
|
+
...await specIssues(
|
|
3800
|
+
moduleRoot,
|
|
3801
|
+
manifest,
|
|
3802
|
+
options.specDirectory ?? "spec"
|
|
3803
|
+
),
|
|
3804
|
+
...await translationIssues(moduleRoot, manifest, options.projectLocales),
|
|
3805
|
+
...await userInterfaceIssues(moduleRoot)
|
|
3806
|
+
];
|
|
3807
|
+
}
|
|
3808
|
+
|
|
3809
|
+
// src/module-install.ts
|
|
3810
|
+
var LOCK = "flowdular.modules.lock.json";
|
|
3811
|
+
var TRANSACTION = ".flowdular-module-install";
|
|
3812
|
+
async function exists2(path) {
|
|
3813
|
+
try {
|
|
3814
|
+
await lstat3(path);
|
|
3815
|
+
return true;
|
|
3816
|
+
} catch (error) {
|
|
3817
|
+
if (error.code === "ENOENT") return false;
|
|
3818
|
+
throw error;
|
|
3819
|
+
}
|
|
3820
|
+
}
|
|
3821
|
+
async function safeParents(workspace, path) {
|
|
3822
|
+
const parts = relative5(
|
|
3823
|
+
workspace.root,
|
|
3824
|
+
resolveInside(workspace.root, path)
|
|
3825
|
+
).split("/");
|
|
3826
|
+
let current = workspace.root;
|
|
3827
|
+
for (const part of parts) {
|
|
3828
|
+
current = join6(current, part);
|
|
3829
|
+
if (!await exists2(current)) break;
|
|
3830
|
+
distributionAssert(
|
|
3831
|
+
!(await lstat3(current)).isSymbolicLink(),
|
|
3832
|
+
"MODULE_DESTINATION_LINK",
|
|
3833
|
+
"Module installation paths cannot contain links."
|
|
3834
|
+
);
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3837
|
+
function validateLock(workspace, value) {
|
|
3838
|
+
const lock = value;
|
|
3839
|
+
distributionAssert(
|
|
3840
|
+
lock && lock.schemaVersion === 1 && Array.isArray(lock.modules) && lock.modules.length <= 256,
|
|
3841
|
+
"MODULE_LOCK_INVALID",
|
|
3842
|
+
"Invalid module lockfile."
|
|
3843
|
+
);
|
|
3844
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3845
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
3846
|
+
for (const entry of lock.modules) {
|
|
3847
|
+
distributionAssert(
|
|
3848
|
+
entry && typeof entry.id === "string" && typeof entry.version === "string" && typeof entry.directory === "string" && entry.files && typeof entry.files === "object" && !Array.isArray(entry.files),
|
|
3849
|
+
"MODULE_LOCK_INVALID",
|
|
3850
|
+
"Invalid installed module entry."
|
|
3851
|
+
);
|
|
3852
|
+
const path = resolveInside(workspace.root, entry.directory);
|
|
3853
|
+
distributionAssert(
|
|
3854
|
+
moduleRoots(workspace).some((root) => dirname6(path) === root) && !ids.has(entry.id) && !dirs.has(path.toLowerCase()),
|
|
3855
|
+
"MODULE_LOCK_INVALID",
|
|
3856
|
+
"Duplicate or invalid installed module path."
|
|
3857
|
+
);
|
|
3858
|
+
ids.add(entry.id);
|
|
3859
|
+
dirs.add(path.toLowerCase());
|
|
3860
|
+
distributionAssert(
|
|
3861
|
+
Object.entries(entry.files).every(
|
|
3862
|
+
([path2, hash]) => safeSourcePath(path2) && typeof hash === "string" && /^[a-f0-9]{64}$/.test(hash)
|
|
3863
|
+
),
|
|
3864
|
+
"MODULE_LOCK_INVALID",
|
|
3865
|
+
"Invalid module file hashes."
|
|
3866
|
+
);
|
|
3867
|
+
}
|
|
3868
|
+
return lock;
|
|
3869
|
+
}
|
|
3870
|
+
async function readLock(workspace) {
|
|
3871
|
+
const path = join6(workspace.root, LOCK);
|
|
3872
|
+
await safeParents(workspace, path);
|
|
3873
|
+
if (!await exists2(path))
|
|
3874
|
+
return { lock: { schemaVersion: 1, modules: [] }, raw: null };
|
|
3875
|
+
const raw = await readFile8(path, "utf8");
|
|
3876
|
+
return { lock: validateLock(workspace, JSON.parse(raw)), raw };
|
|
3877
|
+
}
|
|
3878
|
+
async function directoryHashes(root) {
|
|
3879
|
+
const hashes = /* @__PURE__ */ Object.create(null);
|
|
3880
|
+
async function visit(directory, prefix) {
|
|
3881
|
+
for (const entry of await readdir4(directory, { withFileTypes: true })) {
|
|
3882
|
+
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git")
|
|
3883
|
+
continue;
|
|
3884
|
+
distributionAssert(
|
|
3885
|
+
!entry.isSymbolicLink(),
|
|
3886
|
+
"MODULE_LOCAL_CHANGES",
|
|
3887
|
+
"Installed module contains a symbolic link."
|
|
3888
|
+
);
|
|
3889
|
+
const path = prefix + entry.name;
|
|
3890
|
+
if (entry.isDirectory())
|
|
3891
|
+
await visit(join6(directory, entry.name), path + "/");
|
|
3892
|
+
else {
|
|
3893
|
+
distributionAssert(
|
|
3894
|
+
entry.isFile(),
|
|
3895
|
+
"MODULE_LOCAL_CHANGES",
|
|
3896
|
+
"Installed module contains a special file."
|
|
3897
|
+
);
|
|
3898
|
+
hashes[path] = hashBytes(await readFile8(join6(directory, entry.name)));
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
}
|
|
3902
|
+
await visit(root, "");
|
|
3903
|
+
return hashes;
|
|
3904
|
+
}
|
|
3905
|
+
function equalHashes(a, b) {
|
|
3906
|
+
return Object.keys(a).length === Object.keys(b).length && Object.entries(a).every(([path, hash]) => b[path] === hash);
|
|
3907
|
+
}
|
|
3908
|
+
async function assertUnmodified(workspace, entry) {
|
|
3909
|
+
const path = resolveInside(workspace.root, entry.directory);
|
|
3910
|
+
await safeParents(workspace, path);
|
|
3911
|
+
distributionAssert(
|
|
3912
|
+
await exists2(path) && equalHashes(await directoryHashes(path), entry.files),
|
|
3913
|
+
"MODULE_LOCAL_CHANGES",
|
|
3914
|
+
`Module ${entry.id} has local changes or is missing. Preserve/merge those changes before updating.`
|
|
3915
|
+
);
|
|
3916
|
+
}
|
|
3917
|
+
async function validateInstalledModules(workspace) {
|
|
3918
|
+
const { lock, raw } = await readLock(workspace);
|
|
3919
|
+
distributionAssert(
|
|
3920
|
+
raw !== null,
|
|
3921
|
+
"MODULE_LOCK_MISSING",
|
|
3922
|
+
"No module lockfile exists."
|
|
3923
|
+
);
|
|
3924
|
+
for (const entry of lock.modules) {
|
|
3925
|
+
await assertUnmodified(workspace, entry);
|
|
3926
|
+
const manifest = JSON.parse(
|
|
3927
|
+
await readFile8(
|
|
3928
|
+
join6(workspace.root, entry.directory, "module.json"),
|
|
3929
|
+
"utf8"
|
|
3930
|
+
)
|
|
3931
|
+
);
|
|
3932
|
+
distributionAssert(
|
|
3933
|
+
manifest.id === entry.id && manifest.version === entry.version,
|
|
3934
|
+
"MODULE_LOCK_INVALID",
|
|
3935
|
+
"Lock identity differs from the installed manifest."
|
|
3936
|
+
);
|
|
3937
|
+
}
|
|
3938
|
+
return lock;
|
|
3939
|
+
}
|
|
3940
|
+
async function rollback(workspace, journal) {
|
|
3941
|
+
const transaction = join6(workspace.root, TRANSACTION);
|
|
3942
|
+
validateLock(workspace, {
|
|
3943
|
+
schemaVersion: 1,
|
|
3944
|
+
modules: journal.entries.map((entry) => entry.installed)
|
|
3945
|
+
});
|
|
3946
|
+
for (const [index, entry] of [...journal.entries.entries()].reverse()) {
|
|
3947
|
+
const destination = resolveInside(
|
|
3948
|
+
workspace.root,
|
|
3949
|
+
entry.installed.directory
|
|
3950
|
+
);
|
|
3951
|
+
await safeParents(workspace, destination);
|
|
3952
|
+
const backup = join6(transaction, `backup-${index}`);
|
|
3953
|
+
const moved = !await exists2(join6(transaction, `stage-${index}`));
|
|
3954
|
+
if (moved && await exists2(destination)) {
|
|
3955
|
+
const hashes = await directoryHashes(destination);
|
|
3956
|
+
if (equalHashes(hashes, entry.installed.files))
|
|
3957
|
+
await rm(destination, { recursive: true });
|
|
3958
|
+
else
|
|
3959
|
+
distributionAssert(
|
|
3960
|
+
entry.previous && equalHashes(hashes, entry.previous.files) && !await exists2(backup),
|
|
3961
|
+
"MODULE_RECOVERY_CONFLICT",
|
|
3962
|
+
`Recovery preserved modified files in ${entry.installed.directory}.`
|
|
3963
|
+
);
|
|
3964
|
+
}
|
|
3965
|
+
if (await exists2(backup)) {
|
|
3966
|
+
distributionAssert(
|
|
3967
|
+
!await exists2(destination),
|
|
3968
|
+
"MODULE_RECOVERY_CONFLICT",
|
|
3969
|
+
"Recovery destination is occupied."
|
|
3970
|
+
);
|
|
3971
|
+
await safeParents(workspace, backup);
|
|
3972
|
+
await rename(backup, destination);
|
|
3973
|
+
}
|
|
3974
|
+
}
|
|
3975
|
+
const lockPath = join6(workspace.root, LOCK);
|
|
3976
|
+
await safeParents(workspace, lockPath);
|
|
3977
|
+
const current = await exists2(lockPath) ? await readFile8(lockPath, "utf8") : null;
|
|
3978
|
+
distributionAssert(
|
|
3979
|
+
current === journal.previous || current === journal.next,
|
|
3980
|
+
"MODULE_RECOVERY_CONFLICT",
|
|
3981
|
+
"Lockfile changed during installation; recovery preserved it."
|
|
3982
|
+
);
|
|
3983
|
+
if (journal.previous === null) await rm(lockPath, { force: true });
|
|
3984
|
+
else await writeFile(lockPath, journal.previous);
|
|
3985
|
+
}
|
|
3986
|
+
async function installModule(workspace, options) {
|
|
3987
|
+
const transaction = join6(workspace.root, TRANSACTION);
|
|
3988
|
+
await safeParents(workspace, transaction);
|
|
3989
|
+
distributionAssert(
|
|
3990
|
+
!await exists2(transaction),
|
|
3991
|
+
"MODULE_INSTALL_BUSY",
|
|
3992
|
+
"A module installation is active or interrupted. Use module recover after its process exits."
|
|
3993
|
+
);
|
|
3994
|
+
const source = await loadModuleCatalog(options.registry, options.fetcher);
|
|
3995
|
+
const snapshot = await readLock(workspace);
|
|
3996
|
+
const manifests = [];
|
|
3997
|
+
for (const root of moduleRoots(workspace)) await safeParents(workspace, root);
|
|
3998
|
+
const files = await findModuleFiles(workspace);
|
|
3999
|
+
for (const file of files)
|
|
4000
|
+
manifests.push(JSON.parse(await readFile8(file, "utf8")));
|
|
4001
|
+
const id = options.target.split("@")[0];
|
|
4002
|
+
const previous = snapshot.lock.modules.find((entry) => entry.id === id);
|
|
4003
|
+
distributionAssert(
|
|
4004
|
+
previous || !manifests.some((manifest) => manifest.id === id),
|
|
4005
|
+
"MODULE_NOT_MANAGED",
|
|
4006
|
+
`Module ${id} already exists as unmanaged workspace/package source.`
|
|
4007
|
+
);
|
|
4008
|
+
if (options.update) {
|
|
4009
|
+
distributionAssert(
|
|
4010
|
+
previous,
|
|
4011
|
+
"MODULE_NOT_MANAGED",
|
|
4012
|
+
`Module ${id} is not managed by this installer.`
|
|
4013
|
+
);
|
|
4014
|
+
await assertUnmodified(workspace, previous);
|
|
4015
|
+
}
|
|
4016
|
+
const retained = options.update ? manifests.filter((manifest) => manifest.id !== id) : manifests;
|
|
4017
|
+
const releases = resolveModuleReleases(
|
|
4018
|
+
source.catalog,
|
|
4019
|
+
options.target,
|
|
4020
|
+
retained
|
|
4021
|
+
);
|
|
4022
|
+
if (options.update) {
|
|
4023
|
+
const next = releases.find((release) => release.manifest.id === id);
|
|
4024
|
+
distributionAssert(
|
|
4025
|
+
next && compareModuleVersions(next.manifest.version, previous.version) <= 0,
|
|
4026
|
+
"MODULE_DOWNGRADE_FORBIDDEN",
|
|
4027
|
+
"Module downgrades are not supported."
|
|
4028
|
+
);
|
|
4029
|
+
}
|
|
4030
|
+
const registry = createModuleRegistry(
|
|
4031
|
+
[...retained, ...releases.map((release) => release.manifest)].map(
|
|
4032
|
+
(manifest) => ({ manifest })
|
|
4033
|
+
)
|
|
4034
|
+
);
|
|
4035
|
+
void registry;
|
|
4036
|
+
if (!releases.length) {
|
|
4037
|
+
if (previous) await assertUnmodified(workspace, previous);
|
|
4038
|
+
return { applied: false, modules: [], activationRequired: false };
|
|
4039
|
+
}
|
|
4040
|
+
const entries = [];
|
|
4041
|
+
let totalBytes = 0;
|
|
4042
|
+
for (const release of releases) {
|
|
4043
|
+
const bytes = await readRelease(source, release, options.fetcher);
|
|
4044
|
+
totalBytes += bytes.length;
|
|
4045
|
+
distributionAssert(
|
|
4046
|
+
totalBytes <= 96 * 1024 * 1024,
|
|
4047
|
+
"MODULE_INSTALL_LIMIT",
|
|
4048
|
+
"The dependency closure exceeds the installation size limit."
|
|
4049
|
+
);
|
|
4050
|
+
distributionAssert(
|
|
4051
|
+
hashBytes(bytes) === release.sha256,
|
|
4052
|
+
"MODULE_ARTIFACT_DIGEST",
|
|
4053
|
+
`Artifact digest mismatch for ${release.manifest.id}.`
|
|
4054
|
+
);
|
|
4055
|
+
const artifact = validateModuleArtifact(JSON.parse(bytes.toString("utf8")));
|
|
4056
|
+
distributionAssert(
|
|
4057
|
+
JSON.stringify(artifact.manifest) === JSON.stringify(release.manifest),
|
|
4058
|
+
"MODULE_ARTIFACT_IDENTITY",
|
|
4059
|
+
"Catalog and artifact manifest differ."
|
|
4060
|
+
);
|
|
4061
|
+
const old = snapshot.lock.modules.find((entry) => entry.id === release.manifest.id) ?? null;
|
|
4062
|
+
const destination = old ? resolveInside(workspace.root, old.directory) : join6(
|
|
4063
|
+
moduleRoots(workspace)[0],
|
|
4064
|
+
release.manifest.package.replace("@flowdular/module-", "")
|
|
4065
|
+
);
|
|
4066
|
+
await safeParents(workspace, destination);
|
|
4067
|
+
if (old) {
|
|
4068
|
+
distributionAssert(
|
|
4069
|
+
options.update && old.id === id,
|
|
4070
|
+
"MODULE_ALREADY_INSTALLED",
|
|
4071
|
+
`Module ${old.id} is already managed.`
|
|
4072
|
+
);
|
|
4073
|
+
await assertUnmodified(workspace, old);
|
|
4074
|
+
} else
|
|
4075
|
+
distributionAssert(
|
|
4076
|
+
!await exists2(destination),
|
|
4077
|
+
"MODULE_DESTINATION_EXISTS",
|
|
4078
|
+
`Destination exists: ${relative5(workspace.root, destination)}`
|
|
4079
|
+
);
|
|
4080
|
+
const hashes = Object.fromEntries(
|
|
4081
|
+
artifact.files.map((file) => [file.path, file.sha256])
|
|
4082
|
+
);
|
|
4083
|
+
if (old) {
|
|
4084
|
+
for (const [path, hash] of Object.entries(old.files))
|
|
4085
|
+
if (path.startsWith("migrations/"))
|
|
4086
|
+
distributionAssert(
|
|
4087
|
+
hashes[path] === hash,
|
|
4088
|
+
"MODULE_MIGRATION_CHANGED",
|
|
4089
|
+
`Update changes historical migration ${path}.`
|
|
4090
|
+
);
|
|
4091
|
+
}
|
|
4092
|
+
entries.push({
|
|
4093
|
+
release,
|
|
4094
|
+
artifact,
|
|
4095
|
+
previous: old,
|
|
4096
|
+
installed: {
|
|
4097
|
+
id: release.manifest.id,
|
|
4098
|
+
version: release.manifest.version,
|
|
4099
|
+
directory: relative5(workspace.root, destination),
|
|
4100
|
+
artifact: release.artifact,
|
|
4101
|
+
sha256: release.sha256,
|
|
4102
|
+
sourceCommit: release.sourceCommit,
|
|
4103
|
+
files: hashes
|
|
4104
|
+
}
|
|
4105
|
+
});
|
|
4106
|
+
}
|
|
4107
|
+
const nextLock = {
|
|
4108
|
+
schemaVersion: 1,
|
|
4109
|
+
modules: [
|
|
4110
|
+
...snapshot.lock.modules.filter(
|
|
4111
|
+
(entry) => !entries.some((next) => next.installed.id === entry.id)
|
|
4112
|
+
),
|
|
4113
|
+
...entries.map((entry) => entry.installed)
|
|
4114
|
+
].sort((a, b) => a.id.localeCompare(b.id))
|
|
4115
|
+
};
|
|
4116
|
+
validateLock(workspace, nextLock);
|
|
4117
|
+
if (!options.apply)
|
|
4118
|
+
return {
|
|
4119
|
+
applied: false,
|
|
4120
|
+
modules: entries.map((entry) => entry.installed),
|
|
4121
|
+
activationRequired: true
|
|
4122
|
+
};
|
|
4123
|
+
await mkdir(transaction);
|
|
4124
|
+
const journal = {
|
|
4125
|
+
schemaVersion: 1,
|
|
4126
|
+
pid: process.pid,
|
|
4127
|
+
previous: snapshot.raw,
|
|
4128
|
+
next: JSON.stringify(nextLock, null, " ") + "\n",
|
|
4129
|
+
entries: entries.map((entry) => ({
|
|
4130
|
+
installed: entry.installed,
|
|
4131
|
+
previous: entry.previous
|
|
4132
|
+
}))
|
|
4133
|
+
};
|
|
4134
|
+
let journalWritten = false;
|
|
4135
|
+
try {
|
|
4136
|
+
await writeFile(
|
|
4137
|
+
join6(transaction, "owner.json"),
|
|
4138
|
+
JSON.stringify({ schemaVersion: 1, pid: process.pid })
|
|
4139
|
+
);
|
|
4140
|
+
for (const [index, entry] of entries.entries()) {
|
|
4141
|
+
const stage = join6(transaction, `stage-${index}`);
|
|
4142
|
+
await mkdir(stage);
|
|
4143
|
+
for (const file of entry.artifact.files) {
|
|
4144
|
+
const path = join6(stage, file.path);
|
|
4145
|
+
await mkdir(dirname6(path), { recursive: true });
|
|
4146
|
+
await writeFile(path, Buffer.from(file.content, "base64"), {
|
|
4147
|
+
flag: "wx"
|
|
4148
|
+
});
|
|
4149
|
+
}
|
|
4150
|
+
const issues = await moduleLayoutIssues(stage, entry.artifact.manifest);
|
|
4151
|
+
distributionAssert(
|
|
4152
|
+
!issues.some((issue2) => issue2.severity === "error"),
|
|
4153
|
+
"MODULE_LAYOUT_INVALID",
|
|
4154
|
+
`Invalid module layout: ${issues.map((issue2) => issue2.message).join("; ")}`
|
|
4155
|
+
);
|
|
4156
|
+
}
|
|
4157
|
+
await writeFile(join6(transaction, "journal.tmp"), JSON.stringify(journal));
|
|
4158
|
+
await rename(
|
|
4159
|
+
join6(transaction, "journal.tmp"),
|
|
4160
|
+
join6(transaction, "journal.json")
|
|
4161
|
+
);
|
|
4162
|
+
journalWritten = true;
|
|
4163
|
+
distributionAssert(
|
|
4164
|
+
(await readLock(workspace)).raw === snapshot.raw,
|
|
4165
|
+
"MODULE_CONCURRENT_CHANGE",
|
|
4166
|
+
"Module lock changed during planning."
|
|
4167
|
+
);
|
|
4168
|
+
for (const [index, entry] of entries.entries()) {
|
|
4169
|
+
const destination = resolveInside(
|
|
4170
|
+
workspace.root,
|
|
4171
|
+
entry.installed.directory
|
|
4172
|
+
);
|
|
4173
|
+
await safeParents(workspace, destination);
|
|
4174
|
+
if (entry.previous) {
|
|
4175
|
+
await assertUnmodified(workspace, entry.previous);
|
|
4176
|
+
await rename(destination, join6(transaction, `backup-${index}`));
|
|
4177
|
+
} else
|
|
4178
|
+
distributionAssert(
|
|
4179
|
+
!await exists2(destination),
|
|
4180
|
+
"MODULE_DESTINATION_EXISTS",
|
|
4181
|
+
`Destination appeared during installation: ${entry.installed.directory}`
|
|
4182
|
+
);
|
|
4183
|
+
await mkdir(dirname6(destination), { recursive: true });
|
|
4184
|
+
await rename(join6(transaction, `stage-${index}`), destination);
|
|
4185
|
+
}
|
|
4186
|
+
await writeFile(join6(transaction, "next-lock.json"), journal.next);
|
|
4187
|
+
await rename(
|
|
4188
|
+
join6(transaction, "next-lock.json"),
|
|
4189
|
+
join6(workspace.root, LOCK)
|
|
4190
|
+
);
|
|
4191
|
+
} catch (error) {
|
|
4192
|
+
if (journalWritten) await rollback(workspace, journal);
|
|
4193
|
+
await rm(transaction, { recursive: true });
|
|
4194
|
+
throw error;
|
|
4195
|
+
}
|
|
4196
|
+
await rm(transaction, { recursive: true });
|
|
4197
|
+
return {
|
|
4198
|
+
applied: true,
|
|
4199
|
+
modules: entries.map((entry) => entry.installed),
|
|
4200
|
+
activationRequired: true
|
|
4201
|
+
};
|
|
4202
|
+
}
|
|
4203
|
+
|
|
4204
|
+
// src/module-sync.ts
|
|
4205
|
+
import { spawnSync } from "node:child_process";
|
|
4206
|
+
import { access as access3, mkdir as mkdir2, readFile as readFile9, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
4207
|
+
import { dirname as dirname7, join as join8 } from "node:path";
|
|
4208
|
+
|
|
4209
|
+
// src/format.ts
|
|
4210
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
4211
|
+
import { join as join7 } from "node:path";
|
|
4212
|
+
import { pathToFileURL } from "node:url";
|
|
4213
|
+
var DEFAULT_OPTIONS = {
|
|
4214
|
+
useTabs: true,
|
|
4215
|
+
singleQuote: true,
|
|
4216
|
+
trailingComma: "all"
|
|
4217
|
+
};
|
|
4218
|
+
var TSRX_PLUGIN = "@tsrx/prettier-plugin";
|
|
4219
|
+
function resolveFrom(workspaceRoot, specifier) {
|
|
4220
|
+
for (const base of [join7(workspaceRoot, "package.json"), import.meta.url]) {
|
|
4221
|
+
try {
|
|
4222
|
+
return createRequire3(base).resolve(specifier);
|
|
4223
|
+
} catch {
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
throw new Error(`Cannot resolve ${specifier} from ${workspaceRoot}.`);
|
|
4227
|
+
}
|
|
4228
|
+
async function importModule(path) {
|
|
4229
|
+
const imported = await import(pathToFileURL(path).href);
|
|
4230
|
+
return imported.default ?? imported;
|
|
4231
|
+
}
|
|
4232
|
+
async function loadWorkspaceFormatter(workspaceRoot) {
|
|
4233
|
+
let prettier;
|
|
4234
|
+
let plugins;
|
|
4235
|
+
try {
|
|
4236
|
+
prettier = await importModule(
|
|
4237
|
+
resolveFrom(workspaceRoot, "prettier")
|
|
4238
|
+
);
|
|
4239
|
+
plugins = [
|
|
4240
|
+
await importModule(
|
|
4241
|
+
resolveFrom(workspaceRoot, TSRX_PLUGIN)
|
|
4242
|
+
)
|
|
4243
|
+
];
|
|
4244
|
+
} catch {
|
|
4245
|
+
return null;
|
|
4246
|
+
}
|
|
4247
|
+
const configured = await prettier.resolveConfig(
|
|
4248
|
+
join7(workspaceRoot, "package.json"),
|
|
4249
|
+
{ editorconfig: false }
|
|
4250
|
+
);
|
|
4251
|
+
const { plugins: _ignored, ...options } = configured ?? DEFAULT_OPTIONS;
|
|
4252
|
+
return {
|
|
4253
|
+
async format(path, source) {
|
|
4254
|
+
const info = await prettier.getFileInfo(path, { plugins });
|
|
4255
|
+
if (!info.inferredParser) return source;
|
|
4256
|
+
return prettier.format(source, { ...options, plugins, filepath: path });
|
|
4257
|
+
}
|
|
4258
|
+
};
|
|
4259
|
+
}
|
|
4260
|
+
|
|
4261
|
+
// src/module-sync.ts
|
|
4262
|
+
async function writeProjectConfig(workspace, config) {
|
|
4263
|
+
const raw = JSON.stringify(config, null, " ") + "\n";
|
|
4264
|
+
const formatter = await loadWorkspaceFormatter(workspace.root);
|
|
4265
|
+
const output = formatter ? await formatter.format(workspace.configPath, raw) : raw;
|
|
4266
|
+
await writeFile2(workspace.configPath, output);
|
|
4267
|
+
}
|
|
4268
|
+
var GENERATED_FILES = {
|
|
4269
|
+
server: "platform/src/generated/modules.server.ts",
|
|
4270
|
+
client: "platform/src/generated/modules.client.ts"
|
|
4271
|
+
};
|
|
4272
|
+
var GENERATED_HEADER = '/* GENERATED by "flowdular module sync". Do not edit by hand; run\n "pnpm flowdular module sync --apply" after enabling or disabling modules. */\n';
|
|
4273
|
+
function identifier(id) {
|
|
4274
|
+
return id.replace(/[^a-zA-Z0-9]+/g, "_");
|
|
4275
|
+
}
|
|
4276
|
+
function platformImport(id, pkg, entry) {
|
|
4277
|
+
return `import { ${entry} as ${identifier(id)} } from '${pkg}/platform';`;
|
|
4278
|
+
}
|
|
4279
|
+
function clientImport(id, pkg) {
|
|
4280
|
+
return `import { createClientContribution as ${identifier(id)} } from '${pkg}/client';`;
|
|
4281
|
+
}
|
|
4282
|
+
function generateServerComposition(modules, sdk = false, mounts = [], applicationPath = "/app") {
|
|
4283
|
+
const server = modules.filter((module) => module.server);
|
|
4284
|
+
const typeImport = `import type {
|
|
4285
|
+
PlatformServerComposition,
|
|
4286
|
+
PlatformServerContext,
|
|
4287
|
+
} from '${sdk ? "@flowdular/sdk/modules/auth" : "@flowdular/module-auth"}/server';
|
|
4288
|
+
`;
|
|
4289
|
+
if (server.length === 0) {
|
|
4290
|
+
return GENERATED_HEADER + typeImport + "\nexport function composeModuleServer(\n _context: PlatformServerContext,\n): readonly PlatformServerComposition[] {\n return [];\n}\n\nexport const moduleWebMounts = " + JSON.stringify(mounts) + " as const;\nexport const applicationBasePath = " + JSON.stringify(applicationPath) + ";\n";
|
|
4291
|
+
}
|
|
4292
|
+
const imports = server.map(
|
|
4293
|
+
(module) => platformImport(module.id, module.package, "createServerComposition")
|
|
4294
|
+
).join("\n");
|
|
4295
|
+
const calls = server.map(
|
|
4296
|
+
(module) => ` { ...${identifier(module.id)}({
|
|
4297
|
+
...context,
|
|
4298
|
+
agentDefinitions: context.agentDefinitions.forModule('${module.id}'),
|
|
4299
|
+
}), moduleId: '${module.id}' },`
|
|
4300
|
+
).join("\n");
|
|
4301
|
+
return GENERATED_HEADER + typeImport + imports + "\n\nexport function composeModuleServer(\n context: PlatformServerContext,\n): readonly PlatformServerComposition[] {\n return [\n" + calls + "\n ];\n}\n\nexport const moduleWebMounts = " + JSON.stringify(mounts) + " as const;\nexport const applicationBasePath = " + JSON.stringify(applicationPath) + ";\n";
|
|
4302
|
+
}
|
|
4303
|
+
function generateClientComposition(modules, sdk = false, applicationPath = "/app") {
|
|
4304
|
+
const client = modules.filter((module) => module.client);
|
|
4305
|
+
const typeImport = `import type {
|
|
4306
|
+
ModuleClientContext,
|
|
4307
|
+
ModuleClientContribution,
|
|
4308
|
+
} from '${sdk ? "@flowdular/sdk/client" : "@flowdular/client"}';
|
|
4309
|
+
`;
|
|
4310
|
+
if (client.length === 0) {
|
|
4311
|
+
return GENERATED_HEADER + "export const applicationBasePath = " + JSON.stringify(applicationPath) + ";\n" + typeImport + "\nexport function createModuleClientContributions(\n _context: ModuleClientContext,\n): readonly ModuleClientContribution[] {\n return [];\n}\n";
|
|
4312
|
+
}
|
|
4313
|
+
const imports = client.map((module) => clientImport(module.id, module.package)).join("\n");
|
|
4314
|
+
const calls = client.map((module) => ` ${identifier(module.id)}(context),`).join("\n");
|
|
4315
|
+
return GENERATED_HEADER + "export const applicationBasePath = " + JSON.stringify(applicationPath) + ";\n" + typeImport + imports + "\n\nexport function createModuleClientContributions(\n context: ModuleClientContext,\n): readonly ModuleClientContribution[] {\n return [\n" + calls + "\n ];\n}\n";
|
|
4316
|
+
}
|
|
4317
|
+
async function loadManifests(workspace) {
|
|
4318
|
+
const files = await findModuleFiles(workspace);
|
|
4319
|
+
const bundled = await sdkModules(workspace);
|
|
4320
|
+
const descriptors = /* @__PURE__ */ new Map();
|
|
4321
|
+
for (const file of files) {
|
|
4322
|
+
const manifest = JSON.parse(
|
|
4323
|
+
await readFile9(file, "utf8")
|
|
4324
|
+
);
|
|
4325
|
+
if (!validators.module(manifest))
|
|
4326
|
+
throw new Error(`Invalid module manifest: ${file}`);
|
|
4327
|
+
assertModuleCompatibility(manifest);
|
|
4328
|
+
if (descriptors.has(manifest.id)) {
|
|
4329
|
+
throw new Error(`Module id is registered more than once: ${manifest.id}`);
|
|
4330
|
+
}
|
|
4331
|
+
descriptors.set(manifest.id, {
|
|
4332
|
+
manifest,
|
|
4333
|
+
id: manifest.id,
|
|
4334
|
+
package: bundled.get(file) ?? manifest.package,
|
|
4335
|
+
server: manifest.platform?.server === true,
|
|
4336
|
+
client: manifest.platform?.client === true,
|
|
4337
|
+
dependencies: manifest.dependencies.map((dependency) => dependency.id)
|
|
4338
|
+
});
|
|
4339
|
+
}
|
|
4340
|
+
return descriptors;
|
|
4341
|
+
}
|
|
4342
|
+
function moduleOrder(manifests, roots, includeDependencies) {
|
|
4343
|
+
const requested = new Set(roots);
|
|
4344
|
+
const visiting = [];
|
|
4345
|
+
const visited = /* @__PURE__ */ new Set();
|
|
4346
|
+
const ordered = [];
|
|
4347
|
+
const visit = (id, requiredBy) => {
|
|
4348
|
+
if (visited.has(id)) return;
|
|
4349
|
+
const cycleStart = visiting.indexOf(id);
|
|
4350
|
+
if (cycleStart !== -1) {
|
|
4351
|
+
const cycle = [...visiting.slice(cycleStart), id];
|
|
4352
|
+
throw new Error(`Dependency cycle detected: ${cycle.join(" -> ")}.`);
|
|
4353
|
+
}
|
|
4354
|
+
const current = manifests.get(id);
|
|
4355
|
+
if (!current) {
|
|
4356
|
+
if (requiredBy) {
|
|
4357
|
+
throw new Error(
|
|
4358
|
+
`Module "${requiredBy}" requires missing module "${id}".`
|
|
4359
|
+
);
|
|
4360
|
+
}
|
|
4361
|
+
throw new Error(`Enabled module is not registered: ${id}`);
|
|
4362
|
+
}
|
|
4363
|
+
visiting.push(id);
|
|
4364
|
+
for (const dependency of [...current.dependencies].sort(
|
|
4365
|
+
(left, right) => left.localeCompare(right)
|
|
4366
|
+
)) {
|
|
4367
|
+
if (!includeDependencies && !requested.has(dependency)) {
|
|
4368
|
+
throw new Error(
|
|
4369
|
+
`Enabled module "${id}" requires disabled module "${dependency}". Enable the dependency first.`
|
|
4370
|
+
);
|
|
4371
|
+
}
|
|
4372
|
+
const constraint = current.manifest?.dependencies.find(
|
|
4373
|
+
(entry) => entry.id === dependency
|
|
4374
|
+
);
|
|
4375
|
+
const version = manifests.get(dependency)?.manifest?.version;
|
|
4376
|
+
if (constraint && version)
|
|
4377
|
+
assertModuleDependency(id, constraint, version);
|
|
4378
|
+
visit(dependency, id);
|
|
4379
|
+
}
|
|
4380
|
+
visiting.pop();
|
|
4381
|
+
visited.add(id);
|
|
4382
|
+
ordered.push(current);
|
|
4383
|
+
};
|
|
4384
|
+
for (const id of [...requested].sort(
|
|
4385
|
+
(left, right) => left.localeCompare(right)
|
|
4386
|
+
)) {
|
|
4387
|
+
visit(id);
|
|
4388
|
+
}
|
|
4389
|
+
return ordered;
|
|
4390
|
+
}
|
|
4391
|
+
function enabledModules(workspace) {
|
|
4392
|
+
return workspace.config.modules?.enabled ?? [];
|
|
4393
|
+
}
|
|
4394
|
+
async function resolveEnabled(workspace, enabled) {
|
|
4395
|
+
const manifests = await loadManifests(workspace);
|
|
4396
|
+
return moduleOrder(manifests, enabled, false);
|
|
4397
|
+
}
|
|
4398
|
+
function equalIds(left, right) {
|
|
4399
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
4400
|
+
}
|
|
4401
|
+
async function takeSnapshots(paths) {
|
|
4402
|
+
return Promise.all(
|
|
4403
|
+
paths.map(async (path) => {
|
|
4404
|
+
try {
|
|
4405
|
+
return { path, content: await readFile9(path, "utf8") };
|
|
4406
|
+
} catch (error) {
|
|
4407
|
+
if (error.code === "ENOENT") {
|
|
4408
|
+
return { path, content: void 0 };
|
|
4409
|
+
}
|
|
4410
|
+
throw error;
|
|
4411
|
+
}
|
|
4412
|
+
})
|
|
4413
|
+
);
|
|
4414
|
+
}
|
|
4415
|
+
async function restoreSnapshots(snapshots) {
|
|
4416
|
+
for (const snapshot of [...snapshots].reverse()) {
|
|
4417
|
+
if (snapshot.content === void 0) {
|
|
4418
|
+
await rm2(snapshot.path, { force: true });
|
|
4419
|
+
continue;
|
|
4420
|
+
}
|
|
4421
|
+
await mkdir2(dirname7(snapshot.path), { recursive: true });
|
|
4422
|
+
await writeFile2(snapshot.path, snapshot.content);
|
|
4423
|
+
}
|
|
4424
|
+
}
|
|
4425
|
+
async function syncPlatformModules(workspace, apply, enabledOverride) {
|
|
4426
|
+
if (workspace.config.web !== void 0 && !validators.web(workspace.config.web))
|
|
4427
|
+
throw new Error("Invalid web mount configuration in flowdular.json.");
|
|
4428
|
+
if (workspace.config.application !== void 0 && !validators.application(workspace.config.application)) throw new Error("Invalid application path in flowdular.json.");
|
|
4429
|
+
const applicationPath = workspace.config.application?.path ?? "/app";
|
|
4430
|
+
const enabled = enabledOverride ?? enabledModules(workspace);
|
|
4431
|
+
const sdk = (await sdkModules(workspace)).size > 0;
|
|
4432
|
+
const modules = await resolveEnabled(workspace, enabled);
|
|
4433
|
+
const formatter = await loadWorkspaceFormatter(workspace.root);
|
|
4434
|
+
const targets = await Promise.all(
|
|
4435
|
+
[
|
|
4436
|
+
{
|
|
4437
|
+
path: GENERATED_FILES.server,
|
|
4438
|
+
content: generateServerComposition(
|
|
4439
|
+
modules,
|
|
4440
|
+
sdk,
|
|
4441
|
+
workspace.config.web?.mounts ?? []
|
|
4442
|
+
)
|
|
4443
|
+
},
|
|
4444
|
+
{
|
|
4445
|
+
path: GENERATED_FILES.client,
|
|
4446
|
+
content: generateClientComposition(modules, sdk, applicationPath)
|
|
4447
|
+
}
|
|
4448
|
+
].map(async (target) => {
|
|
4449
|
+
const absolute = join8(workspace.root, target.path);
|
|
4450
|
+
return {
|
|
4451
|
+
...target,
|
|
4452
|
+
content: formatter ? await formatter.format(absolute, target.content) : target.content
|
|
4453
|
+
};
|
|
4454
|
+
})
|
|
4455
|
+
);
|
|
4456
|
+
const files = [];
|
|
4457
|
+
for (const target of targets) {
|
|
4458
|
+
const absolute = join8(workspace.root, target.path);
|
|
4459
|
+
let current = "";
|
|
4460
|
+
try {
|
|
4461
|
+
current = await readFile9(absolute, "utf8");
|
|
4462
|
+
} catch {
|
|
4463
|
+
}
|
|
4464
|
+
const changed = current !== target.content;
|
|
4465
|
+
if (apply && changed) {
|
|
4466
|
+
await mkdir2(dirname7(absolute), { recursive: true });
|
|
4467
|
+
await writeFile2(absolute, target.content);
|
|
4468
|
+
}
|
|
4469
|
+
files.push({ path: target.path, changed });
|
|
4470
|
+
}
|
|
4471
|
+
return {
|
|
4472
|
+
modules: modules.map((module) => module.id),
|
|
4473
|
+
files,
|
|
4474
|
+
applied: apply
|
|
4475
|
+
};
|
|
4476
|
+
}
|
|
4477
|
+
async function enableModule(workspace, id, apply) {
|
|
4478
|
+
const manifests = await loadManifests(workspace);
|
|
4479
|
+
const descriptor = manifests.get(id);
|
|
4480
|
+
if (!descriptor) {
|
|
4481
|
+
throw new Error(`Unknown module id: ${id}`);
|
|
4482
|
+
}
|
|
4483
|
+
const current = enabledModules(workspace);
|
|
4484
|
+
const alreadyEnabled = current.includes(id);
|
|
4485
|
+
const modules = moduleOrder(manifests, [...current, id], true);
|
|
4486
|
+
const enabled = modules.map((module) => module.id);
|
|
4487
|
+
const currentSet = new Set(current);
|
|
4488
|
+
const newlyEnabled = enabled.filter((moduleId) => !currentSet.has(moduleId));
|
|
4489
|
+
const configChanged = !equalIds(current, enabled);
|
|
4490
|
+
const platformPackagePath = join8(workspace.root, "platform/package.json");
|
|
4491
|
+
const platformPackage = JSON.parse(
|
|
4492
|
+
await readFile9(platformPackagePath, "utf8")
|
|
4493
|
+
);
|
|
4494
|
+
const dependencies = platformPackage.dependencies ?? {};
|
|
4495
|
+
const platformDependenciesAdded = modules.map((module) => npmPackage(module.package)).filter((packageName) => !(packageName in dependencies)).sort((left, right) => left.localeCompare(right));
|
|
4496
|
+
const platformDependencyAdded = platformDependenciesAdded.length > 0;
|
|
4497
|
+
for (const packageName of platformDependenciesAdded) {
|
|
4498
|
+
dependencies[packageName] = packageName === "@flowdular/sdk" ? SDK_VERSION : "workspace:*";
|
|
4499
|
+
}
|
|
4500
|
+
if (platformDependencyAdded) {
|
|
4501
|
+
platformPackage.dependencies = Object.fromEntries(
|
|
4502
|
+
Object.entries(dependencies).sort(
|
|
4503
|
+
([left], [right]) => left.localeCompare(right)
|
|
4504
|
+
)
|
|
4505
|
+
);
|
|
4506
|
+
}
|
|
4507
|
+
const linked = async (module) => {
|
|
4508
|
+
try {
|
|
4509
|
+
await access3(
|
|
4510
|
+
join8(
|
|
4511
|
+
workspace.root,
|
|
4512
|
+
"platform/node_modules",
|
|
4513
|
+
npmPackage(module.package)
|
|
4514
|
+
)
|
|
4515
|
+
);
|
|
4516
|
+
return true;
|
|
4517
|
+
} catch {
|
|
4518
|
+
return false;
|
|
4519
|
+
}
|
|
4520
|
+
};
|
|
4521
|
+
const allLinked = async () => (await Promise.all(modules.map((module) => linked(module)))).every(Boolean);
|
|
4522
|
+
let installed = await allLinked();
|
|
4523
|
+
let installRan = false;
|
|
4524
|
+
let sync;
|
|
4525
|
+
if (apply) {
|
|
4526
|
+
const snapshots = await takeSnapshots([
|
|
4527
|
+
workspace.configPath,
|
|
4528
|
+
join8(workspace.root, "pnpm-lock.yaml"),
|
|
4529
|
+
platformPackagePath,
|
|
4530
|
+
...Object.values(GENERATED_FILES).map(
|
|
4531
|
+
(path) => join8(workspace.root, path)
|
|
4532
|
+
)
|
|
4533
|
+
]);
|
|
4534
|
+
try {
|
|
4535
|
+
if (configChanged) {
|
|
4536
|
+
const config = JSON.parse(
|
|
4537
|
+
await readFile9(workspace.configPath, "utf8")
|
|
4538
|
+
);
|
|
4539
|
+
const configModules = config.modules ?? {};
|
|
4540
|
+
configModules.enabled = enabled;
|
|
4541
|
+
config.modules = configModules;
|
|
4542
|
+
await writeProjectConfig(workspace, config);
|
|
4543
|
+
}
|
|
4544
|
+
if (platformDependencyAdded) {
|
|
4545
|
+
await writeFile2(
|
|
4546
|
+
platformPackagePath,
|
|
4547
|
+
JSON.stringify(platformPackage, null, " ") + "\n"
|
|
4548
|
+
);
|
|
4549
|
+
}
|
|
4550
|
+
if (!installed) {
|
|
4551
|
+
installRan = true;
|
|
4552
|
+
const install = spawnSync(
|
|
4553
|
+
"pnpm",
|
|
4554
|
+
["install", "--ignore-scripts", "--no-frozen-lockfile"],
|
|
4555
|
+
{
|
|
4556
|
+
cwd: workspace.root,
|
|
4557
|
+
stdio: "pipe",
|
|
4558
|
+
encoding: "utf8"
|
|
4559
|
+
}
|
|
4560
|
+
);
|
|
4561
|
+
if (install.error || install.status !== 0) {
|
|
4562
|
+
const output = `${install.stdout ?? ""}${install.stderr ?? ""}`.trim().split("\n").slice(-20).join("\n");
|
|
4563
|
+
throw new Error(
|
|
4564
|
+
`pnpm install failed while linking the module package${install.error ? ` (${install.error.message})` : ` (exit ${install.status})`}. Run it manually and retry.${output ? `
|
|
4565
|
+
${output}` : ""}`
|
|
4566
|
+
);
|
|
4567
|
+
}
|
|
4568
|
+
installed = await allLinked();
|
|
4569
|
+
}
|
|
4570
|
+
sync = await syncPlatformModules(workspace, true, enabled);
|
|
4571
|
+
} catch (error) {
|
|
4572
|
+
await restoreSnapshots(snapshots);
|
|
4573
|
+
throw error;
|
|
4574
|
+
}
|
|
4575
|
+
} else {
|
|
4576
|
+
sync = await syncPlatformModules(workspace, false, enabled);
|
|
4577
|
+
}
|
|
4578
|
+
return {
|
|
4579
|
+
...sync,
|
|
4580
|
+
enabled,
|
|
4581
|
+
newlyEnabled,
|
|
4582
|
+
alreadyEnabled,
|
|
4583
|
+
platformDependencyAdded,
|
|
4584
|
+
platformDependenciesAdded,
|
|
4585
|
+
installRan,
|
|
4586
|
+
installed
|
|
4587
|
+
};
|
|
4588
|
+
}
|
|
4589
|
+
export {
|
|
4590
|
+
enableModule,
|
|
4591
|
+
hashBytes,
|
|
4592
|
+
installModule,
|
|
4593
|
+
loadModuleCatalog,
|
|
4594
|
+
packModule,
|
|
4595
|
+
readModuleSource,
|
|
4596
|
+
resolveModuleReleases,
|
|
4597
|
+
sourceDigest,
|
|
4598
|
+
syncPlatformModules,
|
|
4599
|
+
validateInstalledModules,
|
|
4600
|
+
validateModuleArtifact
|
|
4601
|
+
};
|