@ariestools/toolchain 9.0.1 → 9.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/enable/editXyConfigCompile.d.ts +32 -0
- package/dist/actions/enable/editXyConfigCompile.d.ts.map +1 -0
- package/dist/actions/enable/index.d.ts +3 -0
- package/dist/actions/enable/index.d.ts.map +1 -0
- package/dist/actions/enable/tsNative.d.ts +36 -0
- package/dist/actions/enable/tsNative.d.ts.map +1 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/package/compile/XyConfig.d.ts +7 -2
- package/dist/actions/package/compile/XyConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/resolveTscBin.d.ts +10 -0
- package/dist/actions/package/compile/resolveTscBin.d.ts.map +1 -1
- package/dist/actions/package/compile/runTsc.d.ts.map +1 -1
- package/dist/bin/package/build.mjs +40 -2
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/clean.mjs +34 -1
- package/dist/bin/package/clean.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +46 -5
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/publint.mjs +34 -1
- package/dist/bin/package/publint.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +40 -2
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/package/sync-layout.mjs +40 -4
- package/dist/bin/package/sync-layout.mjs.map +1 -1
- package/dist/bin/xy.mjs +431 -75
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/xy/common/enable/index.d.ts +3 -0
- package/dist/xy/common/enable/index.d.ts.map +1 -0
- package/dist/xy/common/index.d.ts.map +1 -1
- package/package.json +8 -7
package/dist/bin/xy.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import { execFile, execFileSync, execSync, spawn } from "node:child_process";
|
|
|
19
19
|
import * as readline$1 from "node:readline";
|
|
20
20
|
import readline, { createInterface } from "node:readline";
|
|
21
21
|
import { fileURLToPath as fileURLToPath$1 } from "url";
|
|
22
|
-
import {
|
|
22
|
+
import { createJiti } from "jiti";
|
|
23
23
|
import { performance as performance$1 } from "node:perf_hooks";
|
|
24
24
|
import util, { promisify, stripVTControlCharacters } from "node:util";
|
|
25
25
|
import ts from "typescript";
|
|
@@ -10457,6 +10457,39 @@ var require_dist$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
10457
10457
|
exports.cosmiconfigSync = cosmiconfigSync;
|
|
10458
10458
|
}));
|
|
10459
10459
|
//#endregion
|
|
10460
|
+
//#region ../../node_modules/.pnpm/cosmiconfig-typescript-loader@6.3.0_@types+node@26.2.0_cosmiconfig@10.0.0_typescript@6.0.3/node_modules/cosmiconfig-typescript-loader/dist/esm/typescript-compile-error.mjs
|
|
10461
|
+
var TypeScriptCompileError = class _TypeScriptCompileError extends Error {
|
|
10462
|
+
constructor(message) {
|
|
10463
|
+
super(message);
|
|
10464
|
+
this.name = this.constructor.name;
|
|
10465
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
10466
|
+
}
|
|
10467
|
+
static fromError(error) {
|
|
10468
|
+
const message = `TypeScriptLoader failed to compile TypeScript:
|
|
10469
|
+
${error.message}`;
|
|
10470
|
+
const newError = new _TypeScriptCompileError(message);
|
|
10471
|
+
newError.stack = error.stack;
|
|
10472
|
+
return newError;
|
|
10473
|
+
}
|
|
10474
|
+
};
|
|
10475
|
+
//#endregion
|
|
10476
|
+
//#region ../../node_modules/.pnpm/cosmiconfig-typescript-loader@6.3.0_@types+node@26.2.0_cosmiconfig@10.0.0_typescript@6.0.3/node_modules/cosmiconfig-typescript-loader/dist/esm/loader.mjs
|
|
10477
|
+
function TypeScriptLoader(options) {
|
|
10478
|
+
const loader = createJiti("", {
|
|
10479
|
+
interopDefault: true,
|
|
10480
|
+
...options
|
|
10481
|
+
});
|
|
10482
|
+
return async (path, _content) => {
|
|
10483
|
+
try {
|
|
10484
|
+
const result = await loader.import(path);
|
|
10485
|
+
return result.default || result;
|
|
10486
|
+
} catch (error) {
|
|
10487
|
+
if (error instanceof Error) throw TypeScriptCompileError.fromError(error);
|
|
10488
|
+
throw error;
|
|
10489
|
+
}
|
|
10490
|
+
};
|
|
10491
|
+
}
|
|
10492
|
+
//#endregion
|
|
10460
10493
|
//#region src/lib/ruleCommandRegistry.ts
|
|
10461
10494
|
/** Title for the root `xy --rules` catalog. */
|
|
10462
10495
|
const ROOT_RULES_TITLE = "XY Rules";
|
|
@@ -10597,7 +10630,7 @@ In-flight workspace loads — concurrent jobs for the same dir share one search.
|
|
|
10597
10630
|
*/
|
|
10598
10631
|
const workspaceConfigLoadPromises = /* @__PURE__ */ new Map();
|
|
10599
10632
|
const deprecationWarned = /* @__PURE__ */ new Set();
|
|
10600
|
-
function isRecord$
|
|
10633
|
+
function isRecord$10(value) {
|
|
10601
10634
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10602
10635
|
}
|
|
10603
10636
|
const explorerState = {};
|
|
@@ -10678,12 +10711,12 @@ function warnOnce(key, message) {
|
|
|
10678
10711
|
*/
|
|
10679
10712
|
function resolveCommandField(cfg, commandName, configPath) {
|
|
10680
10713
|
const configKey = canonicalRuleConfigKey(commandName);
|
|
10681
|
-
const commands = isRecord$
|
|
10714
|
+
const commands = isRecord$10(cfg.commands) ? cfg.commands : void 0;
|
|
10682
10715
|
const fromCommands = commands?.[configKey];
|
|
10683
|
-
if (isRecord$
|
|
10716
|
+
if (isRecord$10(fromCommands)) return fromCommands;
|
|
10684
10717
|
for (const alias of deprecatedRuleConfigAliases(configKey)) {
|
|
10685
10718
|
const fromAlias = commands?.[alias];
|
|
10686
|
-
if (!isRecord$
|
|
10719
|
+
if (!isRecord$10(fromAlias)) continue;
|
|
10687
10720
|
warnOnce(`${configPath ?? "unknown"}:commands.${alias}`, `[xy] Deprecated: "commands.${alias}" in ${configPath ?? "xy.config"} — use "commands.${configKey}"`);
|
|
10688
10721
|
return fromAlias;
|
|
10689
10722
|
}
|
|
@@ -10695,7 +10728,7 @@ function resolveCommandField(cfg, commandName, configPath) {
|
|
|
10695
10728
|
return {};
|
|
10696
10729
|
}
|
|
10697
10730
|
function mergeRuleConfigs(target, source) {
|
|
10698
|
-
if (isRecord$
|
|
10731
|
+
if (isRecord$10(target) && isRecord$10(source)) return {
|
|
10699
10732
|
...target,
|
|
10700
10733
|
...source
|
|
10701
10734
|
};
|
|
@@ -19434,7 +19467,7 @@ const SEVERITIES = /* @__PURE__ */ new Set([
|
|
|
19434
19467
|
]);
|
|
19435
19468
|
const SCOPES = /* @__PURE__ */ new Set(["development", "runtime"]);
|
|
19436
19469
|
const RELATIONSHIPS = /* @__PURE__ */ new Set(["direct", "transitive"]);
|
|
19437
|
-
function isRecord$
|
|
19470
|
+
function isRecord$9(value) {
|
|
19438
19471
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19439
19472
|
}
|
|
19440
19473
|
function readString(value) {
|
|
@@ -19453,13 +19486,13 @@ function readRelationship(value) {
|
|
|
19453
19486
|
return RELATIONSHIPS.has(raw) ? raw : "unknown";
|
|
19454
19487
|
}
|
|
19455
19488
|
function parseDependabotAlert(raw) {
|
|
19456
|
-
if (!isRecord$
|
|
19457
|
-
const dependency = isRecord$
|
|
19458
|
-
const dependencyPackage = isRecord$
|
|
19459
|
-
const advisory = isRecord$
|
|
19460
|
-
const vulnerability = isRecord$
|
|
19461
|
-
const patched = isRecord$
|
|
19462
|
-
const repository = isRecord$
|
|
19489
|
+
if (!isRecord$9(raw)) return void 0;
|
|
19490
|
+
const dependency = isRecord$9(raw.dependency) ? raw.dependency : {};
|
|
19491
|
+
const dependencyPackage = isRecord$9(dependency.package) ? dependency.package : {};
|
|
19492
|
+
const advisory = isRecord$9(raw.security_advisory) ? raw.security_advisory : {};
|
|
19493
|
+
const vulnerability = isRecord$9(raw.security_vulnerability) ? raw.security_vulnerability : {};
|
|
19494
|
+
const patched = isRecord$9(vulnerability.first_patched_version) ? vulnerability.first_patched_version : {};
|
|
19495
|
+
const repository = isRecord$9(raw.repository) ? raw.repository : {};
|
|
19463
19496
|
const packageName = readString(dependencyPackage.name);
|
|
19464
19497
|
if (packageName.length === 0) return void 0;
|
|
19465
19498
|
const patchedVersion = readString(patched.identifier);
|
|
@@ -21759,8 +21792,8 @@ const MAJOR_CEILINGS = /* @__PURE__ */ new Map([["typescript", {
|
|
|
21759
21792
|
reason: [
|
|
21760
21793
|
"typescript@7 is the native compiler and exports no compiler API —",
|
|
21761
21794
|
"ESLint, deplint, dead-code and api-exposure all load it from `typescript`.",
|
|
21762
|
-
"Install it side by side instead:
|
|
21763
|
-
"with `compile.compiler: \"native\"`."
|
|
21795
|
+
"Install it side by side instead: run `xy enable ts-native`, or add",
|
|
21796
|
+
"`\"typescript-native\": \"npm:typescript@7\"` with `compile.compiler: \"native\"`."
|
|
21764
21797
|
].join(" ")
|
|
21765
21798
|
}]]);
|
|
21766
21799
|
/**
|
|
@@ -23022,7 +23055,7 @@ const RULE_LEVELS$2 = /* @__PURE__ */ new Set([
|
|
|
23022
23055
|
"off",
|
|
23023
23056
|
"warn"
|
|
23024
23057
|
]);
|
|
23025
|
-
function isRecord$
|
|
23058
|
+
function isRecord$8(value) {
|
|
23026
23059
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23027
23060
|
}
|
|
23028
23061
|
function isValidWeight(value) {
|
|
@@ -23039,7 +23072,7 @@ function parseTupleRuleSetting(location, setting) {
|
|
|
23039
23072
|
if (setting.length !== 2) throw new TypeError(`${location} tuple must be [level, options]`);
|
|
23040
23073
|
const [level, options] = setting;
|
|
23041
23074
|
if (!isRuleLevel$5(level)) throw new TypeError(`${location} level must be "error", "warn", or "off"`);
|
|
23042
|
-
if (!isRecord$
|
|
23075
|
+
if (!isRecord$8(options)) throw new TypeError(`${location} options must be an object`);
|
|
23043
23076
|
return {
|
|
23044
23077
|
enabled: level !== "off",
|
|
23045
23078
|
level,
|
|
@@ -23072,7 +23105,7 @@ function parseRuleSetting(location, setting) {
|
|
|
23072
23105
|
weight: parseWeight(location, setting)
|
|
23073
23106
|
};
|
|
23074
23107
|
if (Array.isArray(setting)) return parseTupleRuleSetting(location, setting);
|
|
23075
|
-
if (isRecord$
|
|
23108
|
+
if (isRecord$8(setting)) return parseObjectRuleSetting(location, setting);
|
|
23076
23109
|
throw new TypeError(`${location} must be a boolean, rule level, number, "infinite", [level, options], or { enabled?, level?, weight? } object`);
|
|
23077
23110
|
}
|
|
23078
23111
|
function validateRuleIds(location, rules) {
|
|
@@ -26147,18 +26180,18 @@ function findXyConfigFile(dir) {
|
|
|
26147
26180
|
if (fs.existsSync(candidate)) return candidate;
|
|
26148
26181
|
}
|
|
26149
26182
|
}
|
|
26150
|
-
function isJsonConfigPath(configPath) {
|
|
26183
|
+
function isJsonConfigPath$1(configPath) {
|
|
26151
26184
|
const base = PATH.basename(configPath);
|
|
26152
26185
|
return base === ".xyrc.json" || base.endsWith(".json");
|
|
26153
26186
|
}
|
|
26154
|
-
function getPropertyName$
|
|
26187
|
+
function getPropertyName$3(prop) {
|
|
26155
26188
|
if (ts.isPropertyAssignment(prop)) {
|
|
26156
26189
|
const { name } = prop;
|
|
26157
26190
|
if (ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNoSubstitutionTemplateLiteral(name)) return name.text;
|
|
26158
26191
|
}
|
|
26159
26192
|
if (ts.isShorthandPropertyAssignment(prop)) return prop.name.text;
|
|
26160
26193
|
}
|
|
26161
|
-
function isWhitespace$
|
|
26194
|
+
function isWhitespace$2(char) {
|
|
26162
26195
|
return char !== void 0 && /\s/.test(char);
|
|
26163
26196
|
}
|
|
26164
26197
|
/**
|
|
@@ -26169,9 +26202,9 @@ function findDeplintPackagesAssignment(sourceFile) {
|
|
|
26169
26202
|
let found;
|
|
26170
26203
|
function visit(node) {
|
|
26171
26204
|
if (found !== void 0) return;
|
|
26172
|
-
if (ts.isPropertyAssignment(node) && getPropertyName$
|
|
26205
|
+
if (ts.isPropertyAssignment(node) && getPropertyName$3(node) === "packages" && ts.isObjectLiteralExpression(node.initializer)) {
|
|
26173
26206
|
const parentObject = node.parent;
|
|
26174
|
-
if (ts.isObjectLiteralExpression(parentObject) && ts.isPropertyAssignment(parentObject.parent) && getPropertyName$
|
|
26207
|
+
if (ts.isObjectLiteralExpression(parentObject) && ts.isPropertyAssignment(parentObject.parent) && getPropertyName$3(parentObject.parent) === "deplint") {
|
|
26175
26208
|
found = node;
|
|
26176
26209
|
return;
|
|
26177
26210
|
}
|
|
@@ -26185,7 +26218,7 @@ function findDeplintObjectAssignment(sourceFile) {
|
|
|
26185
26218
|
let found;
|
|
26186
26219
|
function visit(node) {
|
|
26187
26220
|
if (found !== void 0) return;
|
|
26188
|
-
if (ts.isPropertyAssignment(node) && getPropertyName$
|
|
26221
|
+
if (ts.isPropertyAssignment(node) && getPropertyName$3(node) === "deplint" && ts.isObjectLiteralExpression(node.initializer)) {
|
|
26189
26222
|
found = node;
|
|
26190
26223
|
return;
|
|
26191
26224
|
}
|
|
@@ -26198,7 +26231,7 @@ function findCommandsObjectAssignment(sourceFile) {
|
|
|
26198
26231
|
let found;
|
|
26199
26232
|
function visit(node) {
|
|
26200
26233
|
if (found !== void 0) return;
|
|
26201
|
-
if (ts.isPropertyAssignment(node) && getPropertyName$
|
|
26234
|
+
if (ts.isPropertyAssignment(node) && getPropertyName$3(node) === "commands" && ts.isObjectLiteralExpression(node.initializer)) {
|
|
26202
26235
|
found = node;
|
|
26203
26236
|
return;
|
|
26204
26237
|
}
|
|
@@ -26207,7 +26240,7 @@ function findCommandsObjectAssignment(sourceFile) {
|
|
|
26207
26240
|
visit(sourceFile);
|
|
26208
26241
|
return found;
|
|
26209
26242
|
}
|
|
26210
|
-
function findDefaultExportObject(sourceFile) {
|
|
26243
|
+
function findDefaultExportObject$1(sourceFile) {
|
|
26211
26244
|
for (const statement of sourceFile.statements) {
|
|
26212
26245
|
if (ts.isExportAssignment(statement) && !statement.isExportEquals && ts.isObjectLiteralExpression(statement.expression)) return statement.expression;
|
|
26213
26246
|
if (!ts.isVariableStatement(statement)) continue;
|
|
@@ -26230,7 +26263,7 @@ function formatPackageConfigValue(config) {
|
|
|
26230
26263
|
if (config.refType !== void 0) parts.push(`refType: '${config.refType}'`);
|
|
26231
26264
|
return `{ ${parts.join(", ")} }`;
|
|
26232
26265
|
}
|
|
26233
|
-
function detectIndent$
|
|
26266
|
+
function detectIndent$2(text, packagesObject, sourceFile) {
|
|
26234
26267
|
if (packagesObject.properties.length > 0) {
|
|
26235
26268
|
const start = packagesObject.properties[0].getStart(sourceFile);
|
|
26236
26269
|
let lineStart = start;
|
|
@@ -26246,18 +26279,18 @@ function detectIndent$1(text, packagesObject, sourceFile) {
|
|
|
26246
26279
|
function findPackageProperty(packagesObject, dependency) {
|
|
26247
26280
|
for (const prop of packagesObject.properties) {
|
|
26248
26281
|
if (!ts.isPropertyAssignment(prop)) continue;
|
|
26249
|
-
if (getPropertyName$
|
|
26282
|
+
if (getPropertyName$3(prop) === dependency) return prop;
|
|
26250
26283
|
}
|
|
26251
26284
|
}
|
|
26252
|
-
function removePropertyFromObject(text, prop, sourceFile) {
|
|
26285
|
+
function removePropertyFromObject$1(text, prop, sourceFile) {
|
|
26253
26286
|
let start = prop.getFullStart();
|
|
26254
26287
|
let end = prop.getEnd();
|
|
26255
26288
|
let cursor = end;
|
|
26256
|
-
while (isWhitespace$
|
|
26289
|
+
while (isWhitespace$2(text[cursor])) cursor++;
|
|
26257
26290
|
if (text[cursor] === ",") end = cursor + 1;
|
|
26258
26291
|
else {
|
|
26259
26292
|
let back = prop.getStart(sourceFile) - 1;
|
|
26260
|
-
while (back >= 0 && isWhitespace$
|
|
26293
|
+
while (back >= 0 && isWhitespace$2(text[back])) back--;
|
|
26261
26294
|
if (text[back] === ",") start = back;
|
|
26262
26295
|
}
|
|
26263
26296
|
return `${text.slice(0, start)}${text.slice(end)}`;
|
|
@@ -26268,7 +26301,7 @@ function upsertPackagePropertyInObject(text, packagesAssignment, sourceFile, dep
|
|
|
26268
26301
|
const existing = findPackageProperty(packagesObject, dependency);
|
|
26269
26302
|
if (config === void 0) {
|
|
26270
26303
|
if (existing === void 0) return text;
|
|
26271
|
-
return removePropertyFromObject(text, existing, sourceFile);
|
|
26304
|
+
return removePropertyFromObject$1(text, existing, sourceFile);
|
|
26272
26305
|
}
|
|
26273
26306
|
if (existing !== void 0) {
|
|
26274
26307
|
const valueText = formatPackageConfigValue(config);
|
|
@@ -26278,7 +26311,7 @@ function upsertPackagePropertyInObject(text, packagesAssignment, sourceFile, dep
|
|
|
26278
26311
|
}
|
|
26279
26312
|
const valueText = formatPackageConfigValue(config);
|
|
26280
26313
|
const keyText = quotePackageKey(dependency);
|
|
26281
|
-
const indent = detectIndent$
|
|
26314
|
+
const indent = detectIndent$2(text, packagesObject, sourceFile);
|
|
26282
26315
|
const entry = `${keyText}: ${valueText}`;
|
|
26283
26316
|
const openBraceEnd = packagesObject.getStart(sourceFile) + 1;
|
|
26284
26317
|
const insertion = `\n${indent}${entry},`;
|
|
@@ -26287,7 +26320,7 @@ function upsertPackagePropertyInObject(text, packagesAssignment, sourceFile, dep
|
|
|
26287
26320
|
function insertPackagesIntoDeplint(text, deplintAssignment, sourceFile, dependency, config) {
|
|
26288
26321
|
if (!ts.isObjectLiteralExpression(deplintAssignment.initializer)) throw new TypeError("deplint must be an object literal");
|
|
26289
26322
|
const deplintObject = deplintAssignment.initializer;
|
|
26290
|
-
const indent = detectIndent$
|
|
26323
|
+
const indent = detectIndent$2(text, deplintObject, sourceFile);
|
|
26291
26324
|
const packagesBlock = `packages: {\n${indent} ${quotePackageKey(dependency)}: ${formatPackageConfigValue(config)},\n${indent}}`;
|
|
26292
26325
|
const openBraceEnd = deplintObject.getStart(sourceFile) + 1;
|
|
26293
26326
|
const insertion = `\n${indent}${packagesBlock},`;
|
|
@@ -26296,7 +26329,7 @@ function insertPackagesIntoDeplint(text, deplintAssignment, sourceFile, dependen
|
|
|
26296
26329
|
function insertDeplintIntoCommands(text, commandsAssignment, sourceFile, dependency, config) {
|
|
26297
26330
|
if (!ts.isObjectLiteralExpression(commandsAssignment.initializer)) throw new TypeError("commands must be an object literal");
|
|
26298
26331
|
const commandsObject = commandsAssignment.initializer;
|
|
26299
|
-
const indent = detectIndent$
|
|
26332
|
+
const indent = detectIndent$2(text, commandsObject, sourceFile);
|
|
26300
26333
|
const block = [
|
|
26301
26334
|
"deplint: {",
|
|
26302
26335
|
`${indent} packages: {`,
|
|
@@ -26309,7 +26342,7 @@ function insertDeplintIntoCommands(text, commandsAssignment, sourceFile, depende
|
|
|
26309
26342
|
return `${text.slice(0, openBraceEnd)}${insertion}${text.slice(openBraceEnd)}`;
|
|
26310
26343
|
}
|
|
26311
26344
|
function insertCommandsIntoConfigObject(text, configObject, sourceFile, dependency, config) {
|
|
26312
|
-
const indent = detectIndent$
|
|
26345
|
+
const indent = detectIndent$2(text, configObject, sourceFile);
|
|
26313
26346
|
const block = [
|
|
26314
26347
|
"commands: {",
|
|
26315
26348
|
`${indent} deplint: {`,
|
|
@@ -26348,7 +26381,7 @@ function applyPackageEditsToTsSource(text, edits) {
|
|
|
26348
26381
|
result = insertDeplintIntoCommands(result, commandsAssignment, sourceFile, edit.dependency, edit.config);
|
|
26349
26382
|
continue;
|
|
26350
26383
|
}
|
|
26351
|
-
const configObject = findDefaultExportObject(sourceFile);
|
|
26384
|
+
const configObject = findDefaultExportObject$1(sourceFile);
|
|
26352
26385
|
if (configObject !== void 0) {
|
|
26353
26386
|
result = insertCommandsIntoConfigObject(result, configObject, sourceFile, edit.dependency, edit.config);
|
|
26354
26387
|
continue;
|
|
@@ -26357,11 +26390,11 @@ function applyPackageEditsToTsSource(text, edits) {
|
|
|
26357
26390
|
}
|
|
26358
26391
|
return result;
|
|
26359
26392
|
}
|
|
26360
|
-
function isRecord$
|
|
26393
|
+
function isRecord$7(value) {
|
|
26361
26394
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26362
26395
|
}
|
|
26363
26396
|
function readJsonPackageConfig(value) {
|
|
26364
|
-
if (!isRecord$
|
|
26397
|
+
if (!isRecord$7(value)) return void 0;
|
|
26365
26398
|
const config = {};
|
|
26366
26399
|
if (typeof value.placement === "string") config.placement = value.placement;
|
|
26367
26400
|
if (typeof value.presence === "string") config.presence = value.presence;
|
|
@@ -26370,10 +26403,10 @@ function readJsonPackageConfig(value) {
|
|
|
26370
26403
|
return config;
|
|
26371
26404
|
}
|
|
26372
26405
|
function resolveJsonDeplintObject(root) {
|
|
26373
|
-
const commands = isRecord$
|
|
26374
|
-
if (commands !== void 0 && isRecord$
|
|
26375
|
-
if (isRecord$
|
|
26376
|
-
if (!isRecord$
|
|
26406
|
+
const commands = isRecord$7(root.commands) ? root.commands : void 0;
|
|
26407
|
+
if (commands !== void 0 && isRecord$7(commands.deplint)) return commands.deplint;
|
|
26408
|
+
if (isRecord$7(root.deplint)) return root.deplint;
|
|
26409
|
+
if (!isRecord$7(root.commands)) root.commands = {};
|
|
26377
26410
|
const cmds = root.commands;
|
|
26378
26411
|
const deplint = {};
|
|
26379
26412
|
cmds.deplint = deplint;
|
|
@@ -26386,7 +26419,7 @@ function applyPackageEditsToJsonSource(text, edits) {
|
|
|
26386
26419
|
if (edits.length === 0) return text;
|
|
26387
26420
|
const root = JSON.parse(text);
|
|
26388
26421
|
const deplint = resolveJsonDeplintObject(root);
|
|
26389
|
-
const packages = isRecord$
|
|
26422
|
+
const packages = isRecord$7(deplint.packages) ? deplint.packages : deplint.packages = {};
|
|
26390
26423
|
for (const edit of edits) if (edit.config === void 0) delete packages[edit.dependency];
|
|
26391
26424
|
else packages[edit.dependency] = edit.config;
|
|
26392
26425
|
if (Object.keys(packages).length === 0) delete deplint.packages;
|
|
@@ -26396,7 +26429,7 @@ function readPackageConfigFromObjectLiteral(objectLiteral) {
|
|
|
26396
26429
|
const config = {};
|
|
26397
26430
|
for (const prop of objectLiteral.properties) {
|
|
26398
26431
|
if (!ts.isPropertyAssignment(prop)) continue;
|
|
26399
|
-
const key = getPropertyName$
|
|
26432
|
+
const key = getPropertyName$3(prop);
|
|
26400
26433
|
if (key === void 0) continue;
|
|
26401
26434
|
const { initializer } = prop;
|
|
26402
26435
|
if ([
|
|
@@ -26419,11 +26452,11 @@ Read `commands.deplint.packages` (or top-level `deplint.packages`) from a config
|
|
|
26419
26452
|
function readPackagesFromConfigFile(configPath) {
|
|
26420
26453
|
const text = fs.readFileSync(configPath, "utf8");
|
|
26421
26454
|
const result = /* @__PURE__ */ new Map();
|
|
26422
|
-
if (isJsonConfigPath(configPath)) try {
|
|
26455
|
+
if (isJsonConfigPath$1(configPath)) try {
|
|
26423
26456
|
const root = JSON.parse(text);
|
|
26424
|
-
const commands = isRecord$
|
|
26425
|
-
const deplint = commands !== void 0 && isRecord$
|
|
26426
|
-
const packages = deplint !== void 0 && isRecord$
|
|
26457
|
+
const commands = isRecord$7(root.commands) ? root.commands : void 0;
|
|
26458
|
+
const deplint = commands !== void 0 && isRecord$7(commands.deplint) ? commands.deplint : isRecord$7(root.deplint) ? root.deplint : void 0;
|
|
26459
|
+
const packages = deplint !== void 0 && isRecord$7(deplint.packages) ? deplint.packages : void 0;
|
|
26427
26460
|
if (packages === void 0) return result;
|
|
26428
26461
|
for (const [name, value] of Object.entries(packages)) {
|
|
26429
26462
|
const config = readJsonPackageConfig(value);
|
|
@@ -26437,7 +26470,7 @@ function readPackagesFromConfigFile(configPath) {
|
|
|
26437
26470
|
if (packagesAssignment === void 0 || !ts.isObjectLiteralExpression(packagesAssignment.initializer)) return result;
|
|
26438
26471
|
for (const prop of packagesAssignment.initializer.properties) {
|
|
26439
26472
|
if (!ts.isPropertyAssignment(prop)) continue;
|
|
26440
|
-
const name = getPropertyName$
|
|
26473
|
+
const name = getPropertyName$3(prop);
|
|
26441
26474
|
if (name === void 0 || !ts.isObjectLiteralExpression(prop.initializer)) continue;
|
|
26442
26475
|
result.set(name, readPackageConfigFromObjectLiteral(prop.initializer));
|
|
26443
26476
|
}
|
|
@@ -26482,7 +26515,7 @@ function applyPackageEditsToConfigDir(dir, edits) {
|
|
|
26482
26515
|
return configPath;
|
|
26483
26516
|
}
|
|
26484
26517
|
const before = fs.readFileSync(existingPath, "utf8");
|
|
26485
|
-
const after = isJsonConfigPath(existingPath) ? applyPackageEditsToJsonSource(before, edits) : applyPackageEditsToTsSource(before, edits);
|
|
26518
|
+
const after = isJsonConfigPath$1(existingPath) ? applyPackageEditsToJsonSource(before, edits) : applyPackageEditsToTsSource(before, edits);
|
|
26486
26519
|
if (after === before) return void 0;
|
|
26487
26520
|
fs.writeFileSync(existingPath, after, "utf8");
|
|
26488
26521
|
return existingPath;
|
|
@@ -26769,7 +26802,7 @@ const BUILT_IN_RULE_OPTION_KEYS = {
|
|
|
26769
26802
|
]),
|
|
26770
26803
|
"dep.workspace.protocol": /* @__PURE__ */ new Set(["ignore", "protocol"])
|
|
26771
26804
|
};
|
|
26772
|
-
function isRecord$
|
|
26805
|
+
function isRecord$6(value) {
|
|
26773
26806
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26774
26807
|
}
|
|
26775
26808
|
function isRuleLevel$4(value) {
|
|
@@ -26806,7 +26839,7 @@ function parseRuleConfig$1(ruleId, value) {
|
|
|
26806
26839
|
const level = value[0];
|
|
26807
26840
|
if (!isRuleLevel$4(level)) throw new TypeError(`${formatRuleConfigLocation$1(ruleId)} level must be one of "off", "warn", or "error"`);
|
|
26808
26841
|
const options = value[1];
|
|
26809
|
-
if (!isRecord$
|
|
26842
|
+
if (!isRecord$6(options)) throw new TypeError(`${formatRuleConfigLocation$1(ruleId)} options must be an object`);
|
|
26810
26843
|
return {
|
|
26811
26844
|
level,
|
|
26812
26845
|
options: { ...options }
|
|
@@ -27258,7 +27291,7 @@ const npmPackageNamePattern = /^@?[a-z0-9][\w./-]*$/i;
|
|
|
27258
27291
|
function isStorybookMainFile(filePath) {
|
|
27259
27292
|
return storybookMainPattern.test(filePath);
|
|
27260
27293
|
}
|
|
27261
|
-
function getPropertyName$
|
|
27294
|
+
function getPropertyName$2(prop) {
|
|
27262
27295
|
if (ts.isIdentifier(prop.name)) return prop.name.text;
|
|
27263
27296
|
if (ts.isStringLiteral(prop.name) || ts.isNoSubstitutionTemplateLiteral(prop.name)) return prop.name.text;
|
|
27264
27297
|
}
|
|
@@ -27275,7 +27308,7 @@ function extractFromEntry(node, collected) {
|
|
|
27275
27308
|
return;
|
|
27276
27309
|
}
|
|
27277
27310
|
if (ts.isObjectLiteralExpression(node)) {
|
|
27278
|
-
for (const prop of node.properties) if (ts.isPropertyAssignment(prop) && getPropertyName$
|
|
27311
|
+
for (const prop of node.properties) if (ts.isPropertyAssignment(prop) && getPropertyName$2(prop) === "name") extractFromEntry(prop.initializer, collected);
|
|
27279
27312
|
return;
|
|
27280
27313
|
}
|
|
27281
27314
|
if (ts.isCallExpression(node)) {
|
|
@@ -27292,7 +27325,7 @@ function getStorybookConfigImports(filePath, importPaths) {
|
|
|
27292
27325
|
const collected = [];
|
|
27293
27326
|
function visit(node) {
|
|
27294
27327
|
if (ts.isPropertyAssignment(node)) {
|
|
27295
|
-
const name = getPropertyName$
|
|
27328
|
+
const name = getPropertyName$2(node);
|
|
27296
27329
|
if (name === "addons") {
|
|
27297
27330
|
if (ts.isArrayLiteralExpression(node.initializer)) for (const element of node.initializer.elements) extractFromEntry(element, collected);
|
|
27298
27331
|
} else if (name === "framework" || name === "builder") extractFromEntry(node.initializer, collected);
|
|
@@ -27536,7 +27569,7 @@ function getMostUsedKey(indents) {
|
|
|
27536
27569
|
function makeIndentString(type, amount) {
|
|
27537
27570
|
return (type === INDENT_TYPE_SPACE ? " " : " ").repeat(amount);
|
|
27538
27571
|
}
|
|
27539
|
-
function detectIndent(string) {
|
|
27572
|
+
function detectIndent$1(string) {
|
|
27540
27573
|
if (typeof string !== "string") throw new TypeError("Expected a string");
|
|
27541
27574
|
let indents = makeIndentsMap(string, true);
|
|
27542
27575
|
if (indents.size === 0) indents = makeIndentsMap(string, false);
|
|
@@ -28172,7 +28205,7 @@ const defaultSortOrder = fields.map(({ key }) => key);
|
|
|
28172
28205
|
const overFields = pipe(fields.map(({ key, over }) => over ? overProperty(key, over) : void 0).filter(Boolean));
|
|
28173
28206
|
function editStringJSON(json, over) {
|
|
28174
28207
|
if (typeof json === "string") {
|
|
28175
|
-
const { indent, type } = detectIndent(json);
|
|
28208
|
+
const { indent, type } = detectIndent$1(json);
|
|
28176
28209
|
const endCharacters = json.slice(-1) === "\n" ? "\n" : "";
|
|
28177
28210
|
const newline = detectNewlineGraceful(json);
|
|
28178
28211
|
json = JSON.parse(json);
|
|
@@ -33300,6 +33333,18 @@ const resolveCompilePlatforms = (compile) => {
|
|
|
33300
33333
|
};
|
|
33301
33334
|
};
|
|
33302
33335
|
//#endregion
|
|
33336
|
+
//#region src/actions/package/compile/resolveTscBin.ts
|
|
33337
|
+
/**
|
|
33338
|
+
* Default `package.json` key the native compiler is expected under:
|
|
33339
|
+
* `"typescript-native": "npm:typescript@~7.0.2"`. Override per package with
|
|
33340
|
+
* `compile.nativePackage`.
|
|
33341
|
+
*/
|
|
33342
|
+
const DEFAULT_NATIVE_PACKAGE = "typescript-native";
|
|
33343
|
+
/**
|
|
33344
|
+
* Full `package.json` alias spec for {@link DEFAULT_NATIVE_PACKAGE}.
|
|
33345
|
+
*/
|
|
33346
|
+
const DEFAULT_NATIVE_ALIAS_SPEC = `npm:typescript@~7.0.2`;
|
|
33347
|
+
//#endregion
|
|
33303
33348
|
//#region src/actions/package/compile/monolithCopyEntries.ts
|
|
33304
33349
|
const copyPlatforms = /* @__PURE__ */ new Set([
|
|
33305
33350
|
"browser",
|
|
@@ -33412,7 +33457,7 @@ function findConfigFile(pkgDir) {
|
|
|
33412
33457
|
if (fs.existsSync(candidate)) return candidate;
|
|
33413
33458
|
}
|
|
33414
33459
|
}
|
|
33415
|
-
function getPropertyName(prop) {
|
|
33460
|
+
function getPropertyName$1(prop) {
|
|
33416
33461
|
if (!ts.isPropertyAssignment(prop)) return void 0;
|
|
33417
33462
|
const { name } = prop;
|
|
33418
33463
|
if (ts.isIdentifier(name) || ts.isStringLiteral(name)) return name.text;
|
|
@@ -33425,15 +33470,15 @@ function getPropertyName(prop) {
|
|
|
33425
33470
|
function collectEmptyTargetProps(sourceFile) {
|
|
33426
33471
|
const found = [];
|
|
33427
33472
|
function visit(node) {
|
|
33428
|
-
if (ts.isPropertyAssignment(node) && getPropertyName(node) === "compile" && ts.isObjectLiteralExpression(node.initializer)) {
|
|
33429
|
-
for (const prop of node.initializer.properties) if (ts.isPropertyAssignment(prop) && COMPILE_TARGET_NAMES.has(getPropertyName(prop) ?? "") && ts.isObjectLiteralExpression(prop.initializer) && prop.initializer.properties.length === 0) found.push(prop);
|
|
33473
|
+
if (ts.isPropertyAssignment(node) && getPropertyName$1(node) === "compile" && ts.isObjectLiteralExpression(node.initializer)) {
|
|
33474
|
+
for (const prop of node.initializer.properties) if (ts.isPropertyAssignment(prop) && COMPILE_TARGET_NAMES.has(getPropertyName$1(prop) ?? "") && ts.isObjectLiteralExpression(prop.initializer) && prop.initializer.properties.length === 0) found.push(prop);
|
|
33430
33475
|
}
|
|
33431
33476
|
ts.forEachChild(node, visit);
|
|
33432
33477
|
}
|
|
33433
33478
|
visit(sourceFile);
|
|
33434
33479
|
return found;
|
|
33435
33480
|
}
|
|
33436
|
-
function isWhitespace(char) {
|
|
33481
|
+
function isWhitespace$1(char) {
|
|
33437
33482
|
return char !== void 0 && /\s/.test(char);
|
|
33438
33483
|
}
|
|
33439
33484
|
/**
|
|
@@ -33449,11 +33494,11 @@ function removeProperties(text, props, sourceFile) {
|
|
|
33449
33494
|
let start = prop.getFullStart();
|
|
33450
33495
|
let end = prop.getEnd();
|
|
33451
33496
|
let cursor = end;
|
|
33452
|
-
while (isWhitespace(result[cursor])) cursor++;
|
|
33497
|
+
while (isWhitespace$1(result[cursor])) cursor++;
|
|
33453
33498
|
if (result[cursor] === ",") end = cursor + 1;
|
|
33454
33499
|
else {
|
|
33455
33500
|
let back = prop.getStart(sourceFile) - 1;
|
|
33456
|
-
while (back >= 0 && isWhitespace(result[back])) back--;
|
|
33501
|
+
while (back >= 0 && isWhitespace$1(result[back])) back--;
|
|
33457
33502
|
if (result[back] === ",") start = back;
|
|
33458
33503
|
}
|
|
33459
33504
|
result = result.slice(0, start) + result.slice(end);
|
|
@@ -33477,9 +33522,9 @@ function checkCompileTargets(pkgDir, shouldFix) {
|
|
|
33477
33522
|
const configName = PATH.basename(configPath);
|
|
33478
33523
|
if (shouldFix) {
|
|
33479
33524
|
fs.writeFileSync(configPath, removeProperties(text, emptyProps, sourceFile));
|
|
33480
|
-
for (const prop of emptyProps) console.warn(chalk.yellow(`Publint [compileTargets]: removed deprecated empty "compile.${getPropertyName(prop)}" target from ${configName}`));
|
|
33525
|
+
for (const prop of emptyProps) console.warn(chalk.yellow(`Publint [compileTargets]: removed deprecated empty "compile.${getPropertyName$1(prop)}" target from ${configName}`));
|
|
33481
33526
|
result.modified = true;
|
|
33482
|
-
} else for (const prop of emptyProps) console.warn(chalk.yellow(`Publint [compileTargets]: "compile.${getPropertyName(prop)} = {}" is treated as "do not build" — set it to \`false\` or remove it (use --fix to remove) in ${configName}`));
|
|
33527
|
+
} else for (const prop of emptyProps) console.warn(chalk.yellow(`Publint [compileTargets]: "compile.${getPropertyName$1(prop)} = {}" is treated as "do not build" — set it to \`false\` or remove it (use --fix to remove) in ${configName}`));
|
|
33483
33528
|
result.warnings += emptyProps.length;
|
|
33484
33529
|
return result;
|
|
33485
33530
|
}
|
|
@@ -33734,7 +33779,7 @@ function formatExportPath$1(pathParts) {
|
|
|
33734
33779
|
function ensureExportsPath$1(value) {
|
|
33735
33780
|
return value.startsWith("./") ? value : `./${value}`;
|
|
33736
33781
|
}
|
|
33737
|
-
function isRecord$
|
|
33782
|
+
function isRecord$5(value) {
|
|
33738
33783
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33739
33784
|
}
|
|
33740
33785
|
function normalizeTarget(target) {
|
|
@@ -33771,7 +33816,7 @@ function collectExportLeaves(value, subpath = ".", pathParts = ["exports"], cond
|
|
|
33771
33816
|
}];
|
|
33772
33817
|
}
|
|
33773
33818
|
if (Array.isArray(value)) return value.flatMap((entry, index) => collectExportLeaves(entry, subpath, [...pathParts, `[${index}]`], conditionPath));
|
|
33774
|
-
if (!isRecord$
|
|
33819
|
+
if (!isRecord$5(value)) return [];
|
|
33775
33820
|
return Object.entries(value).flatMap(([key, nested]) => {
|
|
33776
33821
|
if (isSubpathExportKey$1(key)) return collectExportLeaves(nested, key, [...pathParts, key], conditionPath);
|
|
33777
33822
|
return collectExportLeaves(nested, subpath, [...pathParts, key], [...conditionPath, key]);
|
|
@@ -33869,14 +33914,14 @@ function shouldNormalizeExportsForFix(pkg) {
|
|
|
33869
33914
|
pkg.exports = { ".": pkg.exports };
|
|
33870
33915
|
return true;
|
|
33871
33916
|
}
|
|
33872
|
-
if (isRecord$
|
|
33917
|
+
if (isRecord$5(pkg.exports) && !hasSubpathKeys(pkg.exports)) {
|
|
33873
33918
|
pkg.exports = { ".": pkg.exports };
|
|
33874
33919
|
return true;
|
|
33875
33920
|
}
|
|
33876
33921
|
return false;
|
|
33877
33922
|
}
|
|
33878
33923
|
function isRecordObject(value) {
|
|
33879
|
-
return isRecord$
|
|
33924
|
+
return isRecord$5(value);
|
|
33880
33925
|
}
|
|
33881
33926
|
function ensureSubpath(exports, subpath) {
|
|
33882
33927
|
const existing = exports[subpath];
|
|
@@ -39443,7 +39488,7 @@ const VALID_RULE_LEVELS = /* @__PURE__ */ new Set([
|
|
|
39443
39488
|
"warn",
|
|
39444
39489
|
"error"
|
|
39445
39490
|
]);
|
|
39446
|
-
function isRecord$
|
|
39491
|
+
function isRecord$4(value) {
|
|
39447
39492
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
39448
39493
|
}
|
|
39449
39494
|
function isRuleLevel$1(value) {
|
|
@@ -39468,13 +39513,13 @@ function parseRuleConfig(ruleId, value) {
|
|
|
39468
39513
|
const level = value[0];
|
|
39469
39514
|
if (!isRuleLevel$1(level)) throw new TypeError(`${formatRuleConfigLocation(ruleId)} level must be one of "off", "warn", or "error"`);
|
|
39470
39515
|
const options = value[1];
|
|
39471
|
-
if (!isRecord$
|
|
39516
|
+
if (!isRecord$4(options)) throw new TypeError(`${formatRuleConfigLocation(ruleId)} options must be an object`);
|
|
39472
39517
|
return {
|
|
39473
39518
|
level,
|
|
39474
39519
|
options: { ...options }
|
|
39475
39520
|
};
|
|
39476
39521
|
}
|
|
39477
|
-
if (isRecord$
|
|
39522
|
+
if (isRecord$4(value)) return {
|
|
39478
39523
|
level: "warn",
|
|
39479
39524
|
options: { ...value }
|
|
39480
39525
|
};
|
|
@@ -40510,6 +40555,290 @@ const eject = () => {
|
|
|
40510
40555
|
return runSteps("Eject", [[pm.command, "react-scripts eject"]]);
|
|
40511
40556
|
};
|
|
40512
40557
|
//#endregion
|
|
40558
|
+
//#region src/actions/enable/editXyConfigCompile.ts
|
|
40559
|
+
function isJsonConfigPath(configPath) {
|
|
40560
|
+
const base = PATH.basename(configPath);
|
|
40561
|
+
return base === ".xyrc.json" || base.endsWith(".json");
|
|
40562
|
+
}
|
|
40563
|
+
function getPropertyName(prop) {
|
|
40564
|
+
if (ts.isPropertyAssignment(prop)) {
|
|
40565
|
+
const { name } = prop;
|
|
40566
|
+
if (ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNoSubstitutionTemplateLiteral(name)) return name.text;
|
|
40567
|
+
}
|
|
40568
|
+
if (ts.isShorthandPropertyAssignment(prop)) return prop.name.text;
|
|
40569
|
+
}
|
|
40570
|
+
function isWhitespace(char) {
|
|
40571
|
+
return char !== void 0 && /\s/.test(char);
|
|
40572
|
+
}
|
|
40573
|
+
function findDefaultExportObject(sourceFile) {
|
|
40574
|
+
for (const statement of sourceFile.statements) {
|
|
40575
|
+
if (ts.isExportAssignment(statement) && !statement.isExportEquals && ts.isObjectLiteralExpression(statement.expression)) return statement.expression;
|
|
40576
|
+
if (!ts.isVariableStatement(statement)) continue;
|
|
40577
|
+
for (const decl of statement.declarationList.declarations) if (decl.initializer && ts.isObjectLiteralExpression(decl.initializer) && ts.isIdentifier(decl.name) && decl.name.text === "config") return decl.initializer;
|
|
40578
|
+
}
|
|
40579
|
+
for (const statement of sourceFile.statements) {
|
|
40580
|
+
if (!ts.isVariableStatement(statement)) continue;
|
|
40581
|
+
for (const decl of statement.declarationList.declarations) if (decl.initializer && ts.isObjectLiteralExpression(decl.initializer)) return decl.initializer;
|
|
40582
|
+
}
|
|
40583
|
+
}
|
|
40584
|
+
function findObjectProperty(object, key) {
|
|
40585
|
+
for (const prop of object.properties) {
|
|
40586
|
+
if (!ts.isPropertyAssignment(prop)) continue;
|
|
40587
|
+
if (getPropertyName(prop) === key) return prop;
|
|
40588
|
+
}
|
|
40589
|
+
}
|
|
40590
|
+
function detectIndent(text, object, sourceFile) {
|
|
40591
|
+
if (object.properties.length > 0) {
|
|
40592
|
+
const start = object.properties[0].getStart(sourceFile);
|
|
40593
|
+
let lineStart = start;
|
|
40594
|
+
while (lineStart > 0 && text[lineStart - 1] !== "\n" && text[lineStart - 1] !== "\r") lineStart -= 1;
|
|
40595
|
+
const indent = text.slice(lineStart, start).match(/^[ \t]*/)?.[0];
|
|
40596
|
+
if (indent !== void 0 && indent.length > 0) return indent;
|
|
40597
|
+
}
|
|
40598
|
+
const braceStart = object.getStart(sourceFile);
|
|
40599
|
+
let lineStart = braceStart;
|
|
40600
|
+
while (lineStart > 0 && text[lineStart - 1] !== "\n" && text[lineStart - 1] !== "\r") lineStart -= 1;
|
|
40601
|
+
return `${text.slice(lineStart, braceStart).match(/^[ \t]*/)?.[0] ?? ""} `;
|
|
40602
|
+
}
|
|
40603
|
+
function removePropertyFromObject(text, prop, sourceFile) {
|
|
40604
|
+
let start = prop.getFullStart();
|
|
40605
|
+
let end = prop.getEnd();
|
|
40606
|
+
let cursor = end;
|
|
40607
|
+
while (isWhitespace(text[cursor])) cursor++;
|
|
40608
|
+
if (text[cursor] === ",") end = cursor + 1;
|
|
40609
|
+
else {
|
|
40610
|
+
let back = prop.getStart(sourceFile) - 1;
|
|
40611
|
+
while (back >= 0 && isWhitespace(text[back])) back--;
|
|
40612
|
+
if (text[back] === ",") start = back;
|
|
40613
|
+
}
|
|
40614
|
+
return `${text.slice(0, start)}${text.slice(end)}`;
|
|
40615
|
+
}
|
|
40616
|
+
function insertPropertyIntoObject(text, object, sourceFile, entry) {
|
|
40617
|
+
const indent = detectIndent(text, object, sourceFile);
|
|
40618
|
+
const openBraceEnd = object.getStart(sourceFile) + 1;
|
|
40619
|
+
const insertion = `\n${indent}${entry},`;
|
|
40620
|
+
return `${text.slice(0, openBraceEnd)}${insertion}${text.slice(openBraceEnd)}`;
|
|
40621
|
+
}
|
|
40622
|
+
function setStringProperty(text, object, sourceFile, key, value) {
|
|
40623
|
+
const existing = findObjectProperty(object, key);
|
|
40624
|
+
const valueText = `'${value}'`;
|
|
40625
|
+
if (existing !== void 0) {
|
|
40626
|
+
const valueStart = existing.initializer.getStart(sourceFile);
|
|
40627
|
+
const valueEnd = existing.initializer.getEnd();
|
|
40628
|
+
return `${text.slice(0, valueStart)}${valueText}${text.slice(valueEnd)}`;
|
|
40629
|
+
}
|
|
40630
|
+
return insertPropertyIntoObject(text, object, sourceFile, `${key}: ${valueText}`);
|
|
40631
|
+
}
|
|
40632
|
+
/**
|
|
40633
|
+
* Ensure `compile.compiler` is set on a TypeScript/JS xy.config source.
|
|
40634
|
+
* When `compiler` is `native` and `compile.validator` is `'shared'`, drops the
|
|
40635
|
+
* validator field — shared validation only works with the JS compiler API.
|
|
40636
|
+
*/
|
|
40637
|
+
function applyCompileCompilerToTsSource(text, compiler) {
|
|
40638
|
+
const sourceFile = ts.createSourceFile("xy.config.ts", text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
40639
|
+
const configObject = findDefaultExportObject(sourceFile);
|
|
40640
|
+
if (configObject === void 0) throw new Error("Could not find a config object in xy.config to set compile.compiler");
|
|
40641
|
+
const compileAssignment = findObjectProperty(configObject, "compile");
|
|
40642
|
+
if (compileAssignment === void 0) return insertPropertyIntoObject(text, configObject, sourceFile, `compile: { compiler: '${compiler}' }`);
|
|
40643
|
+
if (!ts.isObjectLiteralExpression(compileAssignment.initializer)) throw new TypeError("compile must be an object literal to set compiler");
|
|
40644
|
+
let result = setStringProperty(text, compileAssignment.initializer, sourceFile, "compiler", compiler);
|
|
40645
|
+
if (compiler !== "native") return result;
|
|
40646
|
+
const afterCompiler = ts.createSourceFile("xy.config.ts", result, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
40647
|
+
const afterConfig = findDefaultExportObject(afterCompiler);
|
|
40648
|
+
if (afterConfig === void 0) return result;
|
|
40649
|
+
const afterCompile = findObjectProperty(afterConfig, "compile");
|
|
40650
|
+
if (afterCompile === void 0 || !ts.isObjectLiteralExpression(afterCompile.initializer)) return result;
|
|
40651
|
+
const validator = findObjectProperty(afterCompile.initializer, "validator");
|
|
40652
|
+
if (validator === void 0) return result;
|
|
40653
|
+
if ((ts.isStringLiteral(validator.initializer) || ts.isNoSubstitutionTemplateLiteral(validator.initializer)) && validator.initializer.text === "shared") result = removePropertyFromObject(result, validator, afterCompiler);
|
|
40654
|
+
return result;
|
|
40655
|
+
}
|
|
40656
|
+
function isRecord$3(value) {
|
|
40657
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
40658
|
+
}
|
|
40659
|
+
/**
|
|
40660
|
+
* Ensure `compile.compiler` is set on a JSON xy.config (`.xyrc.json`).
|
|
40661
|
+
*/
|
|
40662
|
+
function applyCompileCompilerToJsonSource(text, compiler) {
|
|
40663
|
+
const root = JSON.parse(text);
|
|
40664
|
+
const compile = isRecord$3(root.compile) ? { ...root.compile } : {};
|
|
40665
|
+
compile.compiler = compiler;
|
|
40666
|
+
if (compiler === "native" && compile.validator === "shared") delete compile.validator;
|
|
40667
|
+
root.compile = compile;
|
|
40668
|
+
return `${JSON.stringify(root, null, 2)}\n`;
|
|
40669
|
+
}
|
|
40670
|
+
function createMinimalNativeCompileConfigSource() {
|
|
40671
|
+
return [
|
|
40672
|
+
"import type { XyConfig } from '@ariestools/toolchain'",
|
|
40673
|
+
"",
|
|
40674
|
+
"const config: XyConfig = {",
|
|
40675
|
+
" compile: { compiler: 'native' },",
|
|
40676
|
+
"}",
|
|
40677
|
+
"",
|
|
40678
|
+
"export default config",
|
|
40679
|
+
""
|
|
40680
|
+
].join("\n");
|
|
40681
|
+
}
|
|
40682
|
+
/**
|
|
40683
|
+
* Set `compile.compiler` on the repo's xy config.
|
|
40684
|
+
* Creates `xy.config.ts` when none exists.
|
|
40685
|
+
*/
|
|
40686
|
+
function applyCompileCompilerToConfigDir(dir, compiler) {
|
|
40687
|
+
const existingPath = findXyConfigFile(dir);
|
|
40688
|
+
if (existingPath === void 0) {
|
|
40689
|
+
const configPath = PATH.join(dir, "xy.config.ts");
|
|
40690
|
+
const text = compiler === "native" ? createMinimalNativeCompileConfigSource() : [
|
|
40691
|
+
"import type { XyConfig } from '@ariestools/toolchain'",
|
|
40692
|
+
"",
|
|
40693
|
+
"const config: XyConfig = {",
|
|
40694
|
+
` compile: { compiler: '${compiler}' },`,
|
|
40695
|
+
"}",
|
|
40696
|
+
"",
|
|
40697
|
+
"export default config",
|
|
40698
|
+
""
|
|
40699
|
+
].join("\n");
|
|
40700
|
+
fs.writeFileSync(configPath, text, "utf8");
|
|
40701
|
+
return {
|
|
40702
|
+
changed: true,
|
|
40703
|
+
created: true,
|
|
40704
|
+
path: configPath
|
|
40705
|
+
};
|
|
40706
|
+
}
|
|
40707
|
+
const before = fs.readFileSync(existingPath, "utf8");
|
|
40708
|
+
const after = isJsonConfigPath(existingPath) ? applyCompileCompilerToJsonSource(before, compiler) : applyCompileCompilerToTsSource(before, compiler);
|
|
40709
|
+
if (after === before) return {
|
|
40710
|
+
changed: false,
|
|
40711
|
+
created: false,
|
|
40712
|
+
path: existingPath
|
|
40713
|
+
};
|
|
40714
|
+
fs.writeFileSync(existingPath, after, "utf8");
|
|
40715
|
+
return {
|
|
40716
|
+
changed: true,
|
|
40717
|
+
created: false,
|
|
40718
|
+
path: existingPath
|
|
40719
|
+
};
|
|
40720
|
+
}
|
|
40721
|
+
//#endregion
|
|
40722
|
+
//#region src/actions/enable/tsNative.ts
|
|
40723
|
+
function formatAliasSpec(range) {
|
|
40724
|
+
return `npm:typescript@${range}`;
|
|
40725
|
+
}
|
|
40726
|
+
/**
|
|
40727
|
+
* Prefer an existing 7.x alias range when already declared; otherwise use the
|
|
40728
|
+
* toolchain default (`~7.0.2`).
|
|
40729
|
+
*/
|
|
40730
|
+
function resolveNativeAliasSpec(existing) {
|
|
40731
|
+
if (existing === void 0) return DEFAULT_NATIVE_ALIAS_SPEC;
|
|
40732
|
+
if (existing.startsWith("npm:typescript@")) return existing;
|
|
40733
|
+
if (import_semver.default.validRange(existing) !== null) return formatAliasSpec(existing);
|
|
40734
|
+
return DEFAULT_NATIVE_ALIAS_SPEC;
|
|
40735
|
+
}
|
|
40736
|
+
function typescriptMajor(spec) {
|
|
40737
|
+
if (spec === void 0) return void 0;
|
|
40738
|
+
if (spec.startsWith("workspace:") || spec.startsWith("npm:")) return void 0;
|
|
40739
|
+
return import_semver.default.coerce(spec)?.major;
|
|
40740
|
+
}
|
|
40741
|
+
/**
|
|
40742
|
+
* Ensure `typescript-native` lives in devDependencies at the resolved alias
|
|
40743
|
+
* spec. Moves a misplaced `dependencies` entry when present.
|
|
40744
|
+
*/
|
|
40745
|
+
function ensureNativeDevDependency(cwd, pkg, nativeSpec, isVerbose) {
|
|
40746
|
+
if ((pkg.devDependencies?.["typescript-native"] ?? pkg.dependencies?.["typescript-native"]) === nativeSpec && pkg.devDependencies?.["typescript-native"] === nativeSpec) {
|
|
40747
|
+
if (isVerbose) console.log(chalk.gray(` ${DEFAULT_NATIVE_PACKAGE} already declared as ${nativeSpec}`));
|
|
40748
|
+
return false;
|
|
40749
|
+
}
|
|
40750
|
+
if (pkg.dependencies?.["typescript-native"] !== void 0) {
|
|
40751
|
+
delete pkg.dependencies[DEFAULT_NATIVE_PACKAGE];
|
|
40752
|
+
if (Object.keys(pkg.dependencies).length === 0) delete pkg.dependencies;
|
|
40753
|
+
}
|
|
40754
|
+
addDep(pkg, DEFAULT_NATIVE_PACKAGE, nativeSpec, "devDependencies");
|
|
40755
|
+
writePackageJson$2(cwd, pkg);
|
|
40756
|
+
console.log(chalk.green(`Added ${DEFAULT_NATIVE_PACKAGE}@${nativeSpec} to devDependencies`));
|
|
40757
|
+
return true;
|
|
40758
|
+
}
|
|
40759
|
+
/**
|
|
40760
|
+
* Warn when the JS compiler API package is missing or pinned to major 7+.
|
|
40761
|
+
*/
|
|
40762
|
+
function logTypescriptApiStatus(pkg, isVerbose) {
|
|
40763
|
+
const apiSpec = pkg.devDependencies?.typescript ?? pkg.dependencies?.typescript;
|
|
40764
|
+
if (apiSpec === void 0) {
|
|
40765
|
+
console.warn(chalk.yellow("Note: no \"typescript\" package found. Keep typescript@6.x installed for ESLint and xy analyzers (the native compiler exports no compiler API)."));
|
|
40766
|
+
return;
|
|
40767
|
+
}
|
|
40768
|
+
const apiMajor = typescriptMajor(apiSpec);
|
|
40769
|
+
if (apiMajor !== void 0 && apiMajor >= 7) {
|
|
40770
|
+
console.warn(chalk.yellow(`Note: "typescript" is pinned to ${apiSpec} (major ${apiMajor}). Major 7+ is the native compiler and exports no API — pin typescript to 6.x and use ${DEFAULT_NATIVE_PACKAGE} for compile.`));
|
|
40771
|
+
return;
|
|
40772
|
+
}
|
|
40773
|
+
if (isVerbose) console.log(chalk.gray(` typescript (compiler API) remains ${apiSpec}`));
|
|
40774
|
+
}
|
|
40775
|
+
function configDisplayPath(cwd, configPath) {
|
|
40776
|
+
return PATH.relative(cwd, configPath) || PATH.basename(configPath);
|
|
40777
|
+
}
|
|
40778
|
+
function logConfigResult(cwd, configResult) {
|
|
40779
|
+
const display = configDisplayPath(cwd, configResult.path);
|
|
40780
|
+
if (configResult.created) {
|
|
40781
|
+
console.log(chalk.green(`Created ${display} with compile.compiler: 'native'`));
|
|
40782
|
+
return;
|
|
40783
|
+
}
|
|
40784
|
+
if (configResult.changed) {
|
|
40785
|
+
console.log(chalk.green(`Updated ${display} → compile.compiler: 'native'`));
|
|
40786
|
+
return;
|
|
40787
|
+
}
|
|
40788
|
+
console.log(chalk.gray(`${display} already has compile.compiler: 'native'`));
|
|
40789
|
+
}
|
|
40790
|
+
function maybeInstall(cwd, packageJsonChanged, noInstall) {
|
|
40791
|
+
if (!packageJsonChanged) return;
|
|
40792
|
+
if (noInstall) {
|
|
40793
|
+
console.log(chalk.gray("Skipped install (--no-install). Run your package manager install when ready."));
|
|
40794
|
+
return;
|
|
40795
|
+
}
|
|
40796
|
+
shouldRunInstall(cwd);
|
|
40797
|
+
}
|
|
40798
|
+
/**
|
|
40799
|
+
* Enable TypeScript native (`typescript@7` Go compiler) for type-check and
|
|
40800
|
+
* declaration emit in the current repo:
|
|
40801
|
+
*
|
|
40802
|
+
* 1. `devDependencies["typescript-native"] = "npm:typescript@~7.0.2"`
|
|
40803
|
+
* 2. `xy.config` → `compile.compiler: 'native'`
|
|
40804
|
+
* 3. Drop incompatible `compile.validator: 'shared'` when present
|
|
40805
|
+
* 4. Install when package.json changed (unless `--no-install`)
|
|
40806
|
+
*
|
|
40807
|
+
* Leaves the `typescript` (JS compiler API, 6.x) package alone — ESLint,
|
|
40808
|
+
* deplint, dead-code, and api-exposure still load it.
|
|
40809
|
+
*/
|
|
40810
|
+
function enableTsNative({ noInstall = false, isVerbose = false } = {}) {
|
|
40811
|
+
const cwd = INIT_CWD();
|
|
40812
|
+
const packageJsonPath = PATH.join(cwd, "package.json");
|
|
40813
|
+
if (!existsSync(packageJsonPath)) throw new Error(`No package.json found in ${cwd}`);
|
|
40814
|
+
const pkg = readPackageJson$4(cwd);
|
|
40815
|
+
const nativeSpec = resolveNativeAliasSpec(pkg.devDependencies?.["typescript-native"] ?? pkg.dependencies?.["typescript-native"]);
|
|
40816
|
+
const packageJsonChanged = ensureNativeDevDependency(cwd, pkg, nativeSpec, isVerbose);
|
|
40817
|
+
logTypescriptApiStatus(pkg, isVerbose);
|
|
40818
|
+
const configResult = applyCompileCompilerToConfigDir(cwd, "native");
|
|
40819
|
+
logConfigResult(cwd, configResult);
|
|
40820
|
+
maybeInstall(cwd, packageJsonChanged, noInstall);
|
|
40821
|
+
console.log(chalk.cyan("TypeScript native compile enabled. `xy compile` will use the Go tsc for validation and declarations."));
|
|
40822
|
+
return {
|
|
40823
|
+
configChanged: configResult.changed,
|
|
40824
|
+
configCreated: configResult.created,
|
|
40825
|
+
configPath: configResult.path,
|
|
40826
|
+
packageJsonChanged,
|
|
40827
|
+
nativePackage: DEFAULT_NATIVE_PACKAGE,
|
|
40828
|
+
nativeSpec
|
|
40829
|
+
};
|
|
40830
|
+
}
|
|
40831
|
+
async function enableTsNativeAction(params = {}) {
|
|
40832
|
+
try {
|
|
40833
|
+
enableTsNative(params);
|
|
40834
|
+
return 0;
|
|
40835
|
+
} catch (error) {
|
|
40836
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
40837
|
+
console.error(chalk.red(message));
|
|
40838
|
+
return resultFromExitCode(1);
|
|
40839
|
+
}
|
|
40840
|
+
}
|
|
40841
|
+
//#endregion
|
|
40513
40842
|
//#region src/actions/fix.ts
|
|
40514
40843
|
const fix = async ({ jobs, pkg, verbose }) => {
|
|
40515
40844
|
const pkgOpts = pkg === void 0 ? [] : [pkg];
|
|
@@ -54091,6 +54420,33 @@ const deadCommand = {
|
|
|
54091
54420
|
}
|
|
54092
54421
|
};
|
|
54093
54422
|
//#endregion
|
|
54423
|
+
//#region src/xy/common/enable/index.ts
|
|
54424
|
+
const tsNativeCommand = {
|
|
54425
|
+
command: "ts-native",
|
|
54426
|
+
describe: "Enable TypeScript native (Go) compiler for type-check and declaration emit",
|
|
54427
|
+
builder: (yargs) => {
|
|
54428
|
+
return yargs.option("no-install", {
|
|
54429
|
+
default: false,
|
|
54430
|
+
description: "Skip package manager install after adding typescript-native",
|
|
54431
|
+
type: "boolean"
|
|
54432
|
+
});
|
|
54433
|
+
},
|
|
54434
|
+
handler: async (argv) => {
|
|
54435
|
+
await withEnvelope("enable ts-native", () => enableTsNativeAction({
|
|
54436
|
+
isVerbose: !!Boolean(argv.verbose),
|
|
54437
|
+
noInstall: !!Boolean(argv["no-install"])
|
|
54438
|
+
}));
|
|
54439
|
+
}
|
|
54440
|
+
};
|
|
54441
|
+
const enableCommand = {
|
|
54442
|
+
builder: (yargs) => {
|
|
54443
|
+
return yargs.command(tsNativeCommand).demandCommand(1, "Please specify what to enable (e.g. ts-native)").strictCommands();
|
|
54444
|
+
},
|
|
54445
|
+
command: "enable",
|
|
54446
|
+
describe: "Enable optional toolchain features for this repository",
|
|
54447
|
+
handler: () => {}
|
|
54448
|
+
};
|
|
54449
|
+
//#endregion
|
|
54094
54450
|
//#region src/xy/deprecatedCommand.ts
|
|
54095
54451
|
function warnDeprecatedCommand(oldCommand, newCommand) {
|
|
54096
54452
|
console.warn(chalk.yellow(`Deprecated: "xy ${oldCommand}" is deprecated; use "xy ${newCommand}" instead.`));
|
|
@@ -55089,7 +55445,7 @@ const workCommand = {
|
|
|
55089
55445
|
//#endregion
|
|
55090
55446
|
//#region src/xy/common/index.ts
|
|
55091
55447
|
const xyCommonCommands = (args) => {
|
|
55092
|
-
return args.command(checkCommand).command(licenseCommand).command(deadCommand).command(gitCommand).command(gitlintCommand).command(gitignoreCommand).command(npmignoreGenCommand).command(orphanCommand).command(packmanCommand).command(repoCommand).command(retestCommand).command(secureCommand).command(skillsCommand).command(testCommand).command(workCommand);
|
|
55448
|
+
return args.command(checkCommand).command(licenseCommand).command(deadCommand).command(enableCommand).command(gitCommand).command(gitlintCommand).command(gitignoreCommand).command(npmignoreGenCommand).command(orphanCommand).command(packmanCommand).command(repoCommand).command(retestCommand).command(secureCommand).command(skillsCommand).command(testCommand).command(workCommand);
|
|
55093
55449
|
};
|
|
55094
55450
|
//#endregion
|
|
55095
55451
|
//#region src/xy/deploy/deployCommand.ts
|