@effect/tsgo 0.27.1 → 0.29.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/dist/effect-tsgo.cjs +399 -94
- package/package.json +8 -8
package/dist/effect-tsgo.cjs
CHANGED
|
@@ -206981,14 +206981,15 @@ var FileReadError = class extends TaggedError("FileReadError") {
|
|
|
206981
206981
|
//#endregion
|
|
206982
206982
|
//#region package.json
|
|
206983
206983
|
var name = "@effect/tsgo";
|
|
206984
|
-
var version = "0.
|
|
206984
|
+
var version = "0.29.0";
|
|
206985
206985
|
|
|
206986
206986
|
//#endregion
|
|
206987
206987
|
//#region src/cli/setup/consts.ts
|
|
206988
206988
|
const LSP_PACKAGE_NAME = name;
|
|
206989
206989
|
const LSP_PLUGIN_NAME = "@effect/language-service";
|
|
206990
206990
|
const defaultTypescriptPackageNames = ["typescript", "@typescript/native"];
|
|
206991
|
-
const
|
|
206991
|
+
const OXLINT_PACKAGE_NAME = "oxlint";
|
|
206992
|
+
const OXLINT_TSGOLINT_PACKAGE_NAME = "oxlint-tsgolint";
|
|
206992
206993
|
/**
|
|
206993
206994
|
* `typescript` package versions >= 7 ship the native Go-ported binary that this
|
|
206994
206995
|
* tool patches. Older `typescript` releases (<= 6) are the JS compiler and must
|
|
@@ -206999,6 +207000,196 @@ const isNativeTypescriptVersion = (version) => {
|
|
|
206999
207000
|
return match !== null && Number(match[0]) >= 7;
|
|
207000
207001
|
};
|
|
207001
207002
|
|
|
207003
|
+
//#endregion
|
|
207004
|
+
//#region src/cli/setup/patch-command.ts
|
|
207005
|
+
const integrationFlagNames = new Set([
|
|
207006
|
+
"--typescript",
|
|
207007
|
+
"--no-typescript",
|
|
207008
|
+
"--oxlint",
|
|
207009
|
+
"--no-oxlint"
|
|
207010
|
+
]);
|
|
207011
|
+
const getPatchCommand = (integrations) => {
|
|
207012
|
+
const typescript = integrations.includes("typescript");
|
|
207013
|
+
const oxlint = integrations.includes("oxlint");
|
|
207014
|
+
if (!typescript && !oxlint) return void 0;
|
|
207015
|
+
return `effect-tsgo patch ${typescript ? "--typescript" : "--no-typescript"} ${oxlint ? "--oxlint" : "--no-oxlint"}`;
|
|
207016
|
+
};
|
|
207017
|
+
const splitCommands = (script) => {
|
|
207018
|
+
const ranges = [];
|
|
207019
|
+
let start = 0;
|
|
207020
|
+
let quote;
|
|
207021
|
+
let escaped = false;
|
|
207022
|
+
let nesting = 0;
|
|
207023
|
+
for (let index = 0; index < script.length; index++) {
|
|
207024
|
+
const char = script[index];
|
|
207025
|
+
if (escaped) {
|
|
207026
|
+
escaped = false;
|
|
207027
|
+
continue;
|
|
207028
|
+
}
|
|
207029
|
+
if (char === "\\" && quote !== "'") {
|
|
207030
|
+
escaped = true;
|
|
207031
|
+
continue;
|
|
207032
|
+
}
|
|
207033
|
+
if (quote !== void 0) {
|
|
207034
|
+
if (char === quote) quote = void 0;
|
|
207035
|
+
continue;
|
|
207036
|
+
}
|
|
207037
|
+
if (char === "'" || char === "\"") {
|
|
207038
|
+
quote = char;
|
|
207039
|
+
continue;
|
|
207040
|
+
}
|
|
207041
|
+
if (char === "(") {
|
|
207042
|
+
nesting++;
|
|
207043
|
+
continue;
|
|
207044
|
+
}
|
|
207045
|
+
if (char === ")" && nesting > 0) {
|
|
207046
|
+
nesting--;
|
|
207047
|
+
continue;
|
|
207048
|
+
}
|
|
207049
|
+
if (nesting > 0) continue;
|
|
207050
|
+
const operatorLength = char === ";" ? 1 : (char === "&" || char === "|") && script[index + 1] === char ? 2 : char === "|" || char === "&" ? 1 : 0;
|
|
207051
|
+
if (operatorLength === 0) continue;
|
|
207052
|
+
ranges.push({
|
|
207053
|
+
start,
|
|
207054
|
+
end: index,
|
|
207055
|
+
operator: script.slice(index, index + operatorLength)
|
|
207056
|
+
});
|
|
207057
|
+
start = index + operatorLength;
|
|
207058
|
+
index += operatorLength - 1;
|
|
207059
|
+
}
|
|
207060
|
+
ranges.push({
|
|
207061
|
+
start,
|
|
207062
|
+
end: script.length
|
|
207063
|
+
});
|
|
207064
|
+
return ranges;
|
|
207065
|
+
};
|
|
207066
|
+
const tokenize = (script, range) => {
|
|
207067
|
+
const tokens = [];
|
|
207068
|
+
let index = range.start;
|
|
207069
|
+
while (index < range.end) {
|
|
207070
|
+
while (index < range.end && /\s/.test(script[index])) index++;
|
|
207071
|
+
if (index >= range.end) break;
|
|
207072
|
+
const start = index;
|
|
207073
|
+
let value = "";
|
|
207074
|
+
let quote;
|
|
207075
|
+
let escaped = false;
|
|
207076
|
+
for (; index < range.end; index++) {
|
|
207077
|
+
const char = script[index];
|
|
207078
|
+
if (escaped) {
|
|
207079
|
+
value += char;
|
|
207080
|
+
escaped = false;
|
|
207081
|
+
continue;
|
|
207082
|
+
}
|
|
207083
|
+
if (char === "\\" && quote !== "'") {
|
|
207084
|
+
escaped = true;
|
|
207085
|
+
continue;
|
|
207086
|
+
}
|
|
207087
|
+
if (quote !== void 0) {
|
|
207088
|
+
if (char === quote) quote = void 0;
|
|
207089
|
+
else value += char;
|
|
207090
|
+
continue;
|
|
207091
|
+
}
|
|
207092
|
+
if (char === "'" || char === "\"") {
|
|
207093
|
+
quote = char;
|
|
207094
|
+
continue;
|
|
207095
|
+
}
|
|
207096
|
+
if (/\s/.test(char)) break;
|
|
207097
|
+
if ("<>`".includes(char) || char === "$" && script[index + 1] === "(") return void 0;
|
|
207098
|
+
value += char;
|
|
207099
|
+
}
|
|
207100
|
+
if (quote !== void 0 || escaped) return void 0;
|
|
207101
|
+
tokens.push({
|
|
207102
|
+
value,
|
|
207103
|
+
start,
|
|
207104
|
+
end: index
|
|
207105
|
+
});
|
|
207106
|
+
}
|
|
207107
|
+
return tokens;
|
|
207108
|
+
};
|
|
207109
|
+
const findPatchCommand = (script, range) => {
|
|
207110
|
+
const tokens = tokenize(script, range);
|
|
207111
|
+
if (tokens === void 0 || tokens.length < 2) return void 0;
|
|
207112
|
+
let commandIndex = 0;
|
|
207113
|
+
while (/^[A-Za-z_][A-Za-z0-9_]*=/.test(tokens[commandIndex]?.value ?? "")) commandIndex++;
|
|
207114
|
+
if (tokens[commandIndex]?.value === "pnpm" && tokens[commandIndex + 1]?.value === "exec") commandIndex += 2;
|
|
207115
|
+
else if (tokens[commandIndex]?.value === "npm" && tokens[commandIndex + 1]?.value === "exec") commandIndex += tokens[commandIndex + 2]?.value === "--" ? 3 : 2;
|
|
207116
|
+
else if (tokens[commandIndex]?.value === "npx") commandIndex++;
|
|
207117
|
+
if (tokens[commandIndex]?.value !== "effect-tsgo" || tokens[commandIndex + 1]?.value !== "patch") return;
|
|
207118
|
+
return {
|
|
207119
|
+
start: range.start,
|
|
207120
|
+
end: range.end,
|
|
207121
|
+
patchEnd: tokens[commandIndex + 1].end,
|
|
207122
|
+
integrationFlags: tokens.slice(commandIndex + 2).filter((token) => integrationFlagNames.has(token.value)).map(({ value, start, end }) => ({
|
|
207123
|
+
value,
|
|
207124
|
+
start,
|
|
207125
|
+
end
|
|
207126
|
+
}))
|
|
207127
|
+
};
|
|
207128
|
+
};
|
|
207129
|
+
const hasPatchCommand = (script) => splitCommands(script).some((range) => findPatchCommand(script, range) !== void 0);
|
|
207130
|
+
const getPatchIntegrations = (script) => {
|
|
207131
|
+
const match = splitCommands(script).flatMap((range) => {
|
|
207132
|
+
const command = findPatchCommand(script, range);
|
|
207133
|
+
return command === void 0 ? [] : [command];
|
|
207134
|
+
})[0];
|
|
207135
|
+
if (match === void 0) return [];
|
|
207136
|
+
let typescript = true;
|
|
207137
|
+
let oxlint = false;
|
|
207138
|
+
for (const flag of match.integrationFlags) if (flag.value === "--typescript") typescript = true;
|
|
207139
|
+
else if (flag.value === "--no-typescript") typescript = false;
|
|
207140
|
+
else if (flag.value === "--oxlint") oxlint = true;
|
|
207141
|
+
else if (flag.value === "--no-oxlint") oxlint = false;
|
|
207142
|
+
return [...typescript ? ["typescript"] : [], ...oxlint ? ["oxlint"] : []];
|
|
207143
|
+
};
|
|
207144
|
+
const updatePatchCommand = (script, integrations) => {
|
|
207145
|
+
const command = getPatchCommand(integrations);
|
|
207146
|
+
const ranges = splitCommands(script);
|
|
207147
|
+
const matches = ranges.flatMap((range) => {
|
|
207148
|
+
const match = findPatchCommand(script, range);
|
|
207149
|
+
return match === void 0 ? [] : [match];
|
|
207150
|
+
});
|
|
207151
|
+
if (matches.length === 0) return {
|
|
207152
|
+
script,
|
|
207153
|
+
found: false
|
|
207154
|
+
};
|
|
207155
|
+
if (command !== void 0) {
|
|
207156
|
+
const flags = command.slice(17);
|
|
207157
|
+
let updated = script;
|
|
207158
|
+
for (const match of [...matches].reverse()) {
|
|
207159
|
+
let suffix = updated.slice(match.patchEnd, match.end);
|
|
207160
|
+
for (const flag of [...match.integrationFlags].reverse()) {
|
|
207161
|
+
const relativeStart = flag.start - match.patchEnd;
|
|
207162
|
+
const relativeEnd = flag.end - match.patchEnd;
|
|
207163
|
+
const whitespaceStart = suffix.slice(0, relativeStart).search(/\s+$/);
|
|
207164
|
+
suffix = suffix.slice(0, whitespaceStart < 0 ? relativeStart : whitespaceStart) + suffix.slice(relativeEnd);
|
|
207165
|
+
}
|
|
207166
|
+
updated = updated.slice(0, match.patchEnd) + flags + suffix + updated.slice(match.end);
|
|
207167
|
+
}
|
|
207168
|
+
return {
|
|
207169
|
+
script: updated,
|
|
207170
|
+
found: true
|
|
207171
|
+
};
|
|
207172
|
+
}
|
|
207173
|
+
if (ranges.some((range) => range.operator === "||" || range.operator === "|" || range.operator === "&")) return {
|
|
207174
|
+
script,
|
|
207175
|
+
found: false
|
|
207176
|
+
};
|
|
207177
|
+
let updated = script;
|
|
207178
|
+
for (const match of [...matches].reverse()) {
|
|
207179
|
+
const before = updated.slice(0, match.start);
|
|
207180
|
+
const after = updated.slice(match.end);
|
|
207181
|
+
const previousOperator = /\s*(?:&&|\|\||[;|&])\s*$/.exec(before);
|
|
207182
|
+
const nextOperator = /^\s*(?:&&|\|\||[;|&])\s*/.exec(after);
|
|
207183
|
+
if (previousOperator !== null && nextOperator?.[0].trim() !== "&&") updated = before.slice(0, previousOperator.index) + after;
|
|
207184
|
+
else if (nextOperator !== null) updated = before + (/^\s*/.exec(updated.slice(match.start, match.end))?.[0] ?? "") + after.slice(nextOperator[0].length);
|
|
207185
|
+
else updated = before + after;
|
|
207186
|
+
}
|
|
207187
|
+
return {
|
|
207188
|
+
script: updated.trim(),
|
|
207189
|
+
found: true
|
|
207190
|
+
};
|
|
207191
|
+
};
|
|
207192
|
+
|
|
207002
207193
|
//#endregion
|
|
207003
207194
|
//#region src/cli/setup/assessment.ts
|
|
207004
207195
|
/**
|
|
@@ -207053,6 +207244,8 @@ const assessPackageJson = (input) => {
|
|
|
207053
207244
|
return none$3();
|
|
207054
207245
|
};
|
|
207055
207246
|
const lspVersion = assessDependency(LSP_PACKAGE_NAME);
|
|
207247
|
+
const oxlintVersion = assessDependency(OXLINT_PACKAGE_NAME);
|
|
207248
|
+
const oxlintTsgolintVersion = assessDependency(OXLINT_TSGOLINT_PACKAGE_NAME);
|
|
207056
207249
|
let typescriptVersion = none$3();
|
|
207057
207250
|
for (const packageName of defaultTypescriptPackageNames) {
|
|
207058
207251
|
const typescriptDep = assessDependency(packageName);
|
|
@@ -207066,7 +207259,8 @@ const assessPackageJson = (input) => {
|
|
|
207066
207259
|
}
|
|
207067
207260
|
const prepareScript = "prepare" in (parsed.scripts ?? {}) ? some({
|
|
207068
207261
|
script: parsed.scripts.prepare,
|
|
207069
|
-
hasPatch: parsed.scripts.prepare
|
|
207262
|
+
hasPatch: hasPatchCommand(parsed.scripts.prepare),
|
|
207263
|
+
integrations: getPatchIntegrations(parsed.scripts.prepare)
|
|
207070
207264
|
}) : none$3();
|
|
207071
207265
|
return {
|
|
207072
207266
|
path: input.fileName,
|
|
@@ -207075,6 +207269,8 @@ const assessPackageJson = (input) => {
|
|
|
207075
207269
|
text: input.text,
|
|
207076
207270
|
lspVersion,
|
|
207077
207271
|
typescriptVersion,
|
|
207272
|
+
oxlintVersion,
|
|
207273
|
+
oxlintTsgolintVersion,
|
|
207078
207274
|
prepareScript
|
|
207079
207275
|
};
|
|
207080
207276
|
};
|
|
@@ -207422,6 +207618,20 @@ const computePackageJsonChanges = (current, target) => {
|
|
|
207422
207618
|
if (!targetTypescript) return;
|
|
207423
207619
|
dependencyProperties.push(import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(getTypescriptPackageName(targetTypescript)), import_typescript.factory.createStringLiteral(targetTypescript.version)));
|
|
207424
207620
|
};
|
|
207621
|
+
const appendNewOxlintDependencies = (dependencyProperties, dependencyType) => {
|
|
207622
|
+
for (const [packageName, currentDependency, targetDependency] of [[
|
|
207623
|
+
OXLINT_PACKAGE_NAME,
|
|
207624
|
+
current.oxlintVersion,
|
|
207625
|
+
target.oxlintVersion
|
|
207626
|
+
], [
|
|
207627
|
+
OXLINT_TSGOLINT_PACKAGE_NAME,
|
|
207628
|
+
current.oxlintTsgolintVersion,
|
|
207629
|
+
target.oxlintTsgolintVersion
|
|
207630
|
+
]]) if (target.integrations.includes("oxlint") && isNone(currentDependency) && isSome(targetDependency) && targetDependency.value.dependencyType === dependencyType) {
|
|
207631
|
+
descriptions.push(`Add ${packageName}@${targetDependency.value.version} in ${dependencyType}`);
|
|
207632
|
+
dependencyProperties.push(import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(packageName), import_typescript.factory.createStringLiteral(targetDependency.value.version)));
|
|
207633
|
+
}
|
|
207634
|
+
};
|
|
207425
207635
|
const ensureTypescriptDependency = () => {
|
|
207426
207636
|
if (isNone(target.typescriptVersion) || isSome(current.typescriptVersion)) return;
|
|
207427
207637
|
const targetTypescript = target.typescriptVersion.value;
|
|
@@ -207430,6 +207640,13 @@ const computePackageJsonChanges = (current, target) => {
|
|
|
207430
207640
|
descriptions.push(`Add ${targetTypescriptPackageName}@${targetTypescript.version} to ${targetTypescript.dependencyType}`);
|
|
207431
207641
|
upsertDependency(tracker, current.sourceFile, rootObj, targetTypescriptPackageName, targetTypescript);
|
|
207432
207642
|
};
|
|
207643
|
+
const ensurePinnedDependency = (packageName, currentDependency, targetDependency) => {
|
|
207644
|
+
if (isNone(targetDependency)) return;
|
|
207645
|
+
if (isSome(currentDependency) && currentDependency.value.version === targetDependency.value.version && currentDependency.value.dependencyType === targetDependency.value.dependencyType) return;
|
|
207646
|
+
if (isNone(currentDependency) && !findDependencyCollectionProperty(rootObj, targetDependency.value.dependencyType) && isSome(target.lspVersion) && target.lspVersion.value.dependencyType === targetDependency.value.dependencyType) return;
|
|
207647
|
+
descriptions.push(`${isSome(currentDependency) ? "Update" : "Add"} ${packageName}@${targetDependency.value.version} in ${targetDependency.value.dependencyType}`);
|
|
207648
|
+
upsertDependency(tracker, current.sourceFile, rootObj, packageName, targetDependency.value);
|
|
207649
|
+
};
|
|
207433
207650
|
if (isSome(target.lspVersion)) {
|
|
207434
207651
|
const targetDepType = target.lspVersion.value.dependencyType;
|
|
207435
207652
|
const targetVersion = target.lspVersion.value.version;
|
|
@@ -207447,6 +207664,7 @@ const computePackageJsonChanges = (current, target) => {
|
|
|
207447
207664
|
if (!newDepsProperty) {
|
|
207448
207665
|
const dependencyProperties = [import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(LSP_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetVersion))];
|
|
207449
207666
|
if (shouldAddTypescriptWithDependencyType(targetDepType)) appendTypescriptDependencyProperty(dependencyProperties);
|
|
207667
|
+
appendNewOxlintDependencies(dependencyProperties, targetDepType);
|
|
207450
207668
|
const newDepsProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(targetDepType), import_typescript.factory.createObjectLiteralExpression(dependencyProperties, false));
|
|
207451
207669
|
insertNodeAtEndOfList(tracker, current.sourceFile, rootObj.properties, newDepsProp);
|
|
207452
207670
|
} else if (import_typescript.isObjectLiteralExpression(newDepsProperty.initializer)) insertNodeAtEndOfList(tracker, current.sourceFile, newDepsProperty.initializer.properties, import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(LSP_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetVersion)));
|
|
@@ -207464,11 +207682,16 @@ const computePackageJsonChanges = (current, target) => {
|
|
|
207464
207682
|
if (!depsProperty) {
|
|
207465
207683
|
const dependencyProperties = [import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(LSP_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetVersion))];
|
|
207466
207684
|
if (shouldAddTypescriptWithDependencyType(targetDepType)) appendTypescriptDependencyProperty(dependencyProperties);
|
|
207685
|
+
appendNewOxlintDependencies(dependencyProperties, targetDepType);
|
|
207467
207686
|
const newDepsProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(targetDepType), import_typescript.factory.createObjectLiteralExpression(dependencyProperties, false));
|
|
207468
207687
|
insertNodeAtEndOfList(tracker, current.sourceFile, rootObj.properties, newDepsProp);
|
|
207469
207688
|
} else if (import_typescript.isObjectLiteralExpression(depsProperty.initializer)) insertNodeAtEndOfList(tracker, current.sourceFile, depsProperty.initializer.properties, import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(LSP_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetVersion)));
|
|
207470
207689
|
}
|
|
207471
207690
|
ensureTypescriptDependency();
|
|
207691
|
+
if (target.integrations.includes("oxlint")) {
|
|
207692
|
+
ensurePinnedDependency(OXLINT_PACKAGE_NAME, current.oxlintVersion, target.oxlintVersion);
|
|
207693
|
+
ensurePinnedDependency(OXLINT_TSGOLINT_PACKAGE_NAME, current.oxlintTsgolintVersion, target.oxlintTsgolintVersion);
|
|
207694
|
+
}
|
|
207472
207695
|
} else if (isSome(current.lspVersion)) {
|
|
207473
207696
|
descriptions.push(`Remove ${LSP_PACKAGE_NAME} from dependencies`);
|
|
207474
207697
|
const currentDepType = current.lspVersion.value.dependencyType;
|
|
@@ -207478,39 +207701,47 @@ const computePackageJsonChanges = (current, target) => {
|
|
|
207478
207701
|
if (lspProperty) deleteNodeFromList(tracker, current.sourceFile, depsProperty.initializer.properties, lspProperty);
|
|
207479
207702
|
}
|
|
207480
207703
|
}
|
|
207481
|
-
|
|
207704
|
+
const patchCommand = target.prepareScript && isSome(target.lspVersion) ? getPatchCommand(target.integrations) : void 0;
|
|
207705
|
+
if (!target.managePrepareScript) return;
|
|
207706
|
+
else if (patchCommand !== void 0) {
|
|
207482
207707
|
const scriptsProperty = findPropertyInObject(rootObj, "scripts");
|
|
207483
207708
|
if (!scriptsProperty) {
|
|
207484
207709
|
descriptions.push("Add scripts section with prepare script");
|
|
207485
|
-
const newScriptsProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("scripts"), import_typescript.factory.createObjectLiteralExpression([import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("prepare"), import_typescript.factory.createStringLiteral(
|
|
207710
|
+
const newScriptsProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("scripts"), import_typescript.factory.createObjectLiteralExpression([import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("prepare"), import_typescript.factory.createStringLiteral(patchCommand))], false));
|
|
207486
207711
|
insertNodeAtEndOfList(tracker, current.sourceFile, rootObj.properties, newScriptsProp);
|
|
207487
207712
|
} else if (import_typescript.isObjectLiteralExpression(scriptsProperty.initializer)) {
|
|
207488
207713
|
const prepareProperty = findPropertyInObject(scriptsProperty.initializer, "prepare");
|
|
207489
207714
|
if (!prepareProperty) {
|
|
207490
207715
|
descriptions.push("Add prepare script");
|
|
207491
|
-
const newPrepareProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("prepare"), import_typescript.factory.createStringLiteral(
|
|
207716
|
+
const newPrepareProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("prepare"), import_typescript.factory.createStringLiteral(patchCommand));
|
|
207492
207717
|
insertNodeAtEndOfList(tracker, current.sourceFile, scriptsProperty.initializer.properties, newPrepareProp);
|
|
207493
207718
|
} else if (isSome(current.prepareScript) && !current.prepareScript.value.hasPatch) {
|
|
207494
207719
|
descriptions.push("Update prepare script to include patch command");
|
|
207495
|
-
const newScript = `${current.prepareScript.value.script} && ${
|
|
207720
|
+
const newScript = `${current.prepareScript.value.script} && ${patchCommand}`;
|
|
207496
207721
|
tracker.replaceNode(current.sourceFile, prepareProperty.initializer, import_typescript.factory.createStringLiteral(newScript));
|
|
207722
|
+
} else if (isSome(current.prepareScript)) {
|
|
207723
|
+
const currentScript = current.prepareScript.value.script;
|
|
207724
|
+
const updated = updatePatchCommand(currentScript, target.integrations);
|
|
207725
|
+
if (updated.found && updated.script !== currentScript) {
|
|
207726
|
+
descriptions.push("Update effect-tsgo patch integrations in prepare script");
|
|
207727
|
+
tracker.replaceNode(current.sourceFile, prepareProperty.initializer, import_typescript.factory.createStringLiteral(updated.script));
|
|
207728
|
+
}
|
|
207497
207729
|
}
|
|
207498
207730
|
}
|
|
207499
|
-
} else if (
|
|
207731
|
+
} else if (isSome(current.prepareScript) && current.prepareScript.value.hasPatch) {
|
|
207500
207732
|
const scriptsProperty = findPropertyInObject(rootObj, "scripts");
|
|
207501
207733
|
if (scriptsProperty && import_typescript.isObjectLiteralExpression(scriptsProperty.initializer)) {
|
|
207502
207734
|
const prepareProperty = findPropertyInObject(scriptsProperty.initializer, "prepare");
|
|
207503
207735
|
if (prepareProperty && import_typescript.isStringLiteral(prepareProperty.initializer)) {
|
|
207504
207736
|
const currentScript = current.prepareScript.value.script;
|
|
207505
|
-
|
|
207737
|
+
const updated = updatePatchCommand(currentScript, []);
|
|
207738
|
+
if (updated.found && updated.script.length > 0) {
|
|
207506
207739
|
descriptions.push("Remove effect-tsgo patch command from prepare script");
|
|
207507
|
-
|
|
207508
|
-
|
|
207509
|
-
tracker.replaceNode(current.sourceFile, prepareProperty.initializer, import_typescript.factory.createStringLiteral(newScript));
|
|
207510
|
-
} else {
|
|
207740
|
+
tracker.replaceNode(current.sourceFile, prepareProperty.initializer, import_typescript.factory.createStringLiteral(updated.script));
|
|
207741
|
+
} else if (updated.found) {
|
|
207511
207742
|
descriptions.push("Remove prepare script with patch command");
|
|
207512
207743
|
deleteNodeFromList(tracker, current.sourceFile, scriptsProperty.initializer.properties, prepareProperty);
|
|
207513
|
-
}
|
|
207744
|
+
} else messages.push("WARNING: The prepare script uses shell control flow that cannot be safely rewritten. Remove the effect-tsgo patch command manually.");
|
|
207514
207745
|
}
|
|
207515
207746
|
}
|
|
207516
207747
|
}
|
|
@@ -207540,9 +207771,30 @@ const computeTsConfigChanges = (current, target, lspVersion) => {
|
|
|
207540
207771
|
const messages = [];
|
|
207541
207772
|
const rootObj = getRootObject(current.sourceFile);
|
|
207542
207773
|
if (!rootObj) return emptyFileChangesResult();
|
|
207774
|
+
const isEffectSchemaProperty = (property) => property !== void 0 && import_typescript.isStringLiteral(property.initializer) && property.initializer.text.replaceAll("\\", "/").endsWith("node_modules/@effect/tsgo/schema.json");
|
|
207543
207775
|
const compilerOptionsProperty = findPropertyInObject(rootObj, "compilerOptions");
|
|
207544
207776
|
if (!compilerOptionsProperty || !import_typescript.isObjectLiteralExpression(compilerOptionsProperty.initializer)) {
|
|
207545
|
-
if (isNone(lspVersion))
|
|
207777
|
+
if (isNone(lspVersion)) {
|
|
207778
|
+
if (!target.manageIntegration) return emptyFileChangesResult();
|
|
207779
|
+
const schemaProperty = findPropertyInObject(rootObj, "$schema");
|
|
207780
|
+
if (!isEffectSchemaProperty(schemaProperty)) return emptyFileChangesResult();
|
|
207781
|
+
const ctx = createTrackerContext();
|
|
207782
|
+
const fileChange = tsInternal.textChanges.ChangeTracker.with(ctx, (tracker) => {
|
|
207783
|
+
descriptions.push("Remove $schema from tsconfig");
|
|
207784
|
+
deleteNodeFromList(tracker, current.sourceFile, rootObj.properties, schemaProperty);
|
|
207785
|
+
}).find((fc) => fc.fileName === current.sourceFile.fileName);
|
|
207786
|
+
return {
|
|
207787
|
+
codeActions: fileChange ? [{
|
|
207788
|
+
description: descriptions.join("; "),
|
|
207789
|
+
changes: [{
|
|
207790
|
+
fileName: current.sourceFile.fileName,
|
|
207791
|
+
textChanges: fileChange.textChanges,
|
|
207792
|
+
isNewFile: false
|
|
207793
|
+
}]
|
|
207794
|
+
}] : [],
|
|
207795
|
+
messages
|
|
207796
|
+
};
|
|
207797
|
+
}
|
|
207546
207798
|
const ctx = createTrackerContext();
|
|
207547
207799
|
const fileChange = tsInternal.textChanges.ChangeTracker.with(ctx, (tracker) => {
|
|
207548
207800
|
const schemaProperty = findPropertyInObject(rootObj, "$schema");
|
|
@@ -207557,7 +207809,7 @@ const computeTsConfigChanges = (current, target, lspVersion) => {
|
|
|
207557
207809
|
if (schemaProperty && property === schemaProperty && isSome(schemaPropertyAssignment)) return schemaPropertyAssignment.value;
|
|
207558
207810
|
return property;
|
|
207559
207811
|
});
|
|
207560
|
-
if (shouldAddSchema && isSome(schemaPropertyAssignment)) nextProperties.
|
|
207812
|
+
if (shouldAddSchema && isSome(schemaPropertyAssignment)) nextProperties.unshift(schemaPropertyAssignment.value);
|
|
207561
207813
|
nextProperties.push(compilerOptionsAssignment);
|
|
207562
207814
|
tracker.replaceNode(current.sourceFile, rootObj, import_typescript.factory.createObjectLiteralExpression(nextProperties, true));
|
|
207563
207815
|
}).find((fc) => fc.fileName === current.sourceFile.fileName);
|
|
@@ -207584,20 +207836,46 @@ const computeTsConfigChanges = (current, target, lspVersion) => {
|
|
|
207584
207836
|
const schemaProperty = findPropertyInObject(rootObj, "$schema");
|
|
207585
207837
|
const pluginsProperty = findPropertyInObject(compilerOptions, "plugins");
|
|
207586
207838
|
const schemaPropertyAssignment = map$11(target.schemaPath, (schemaPath) => import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("$schema"), import_typescript.factory.createStringLiteral(schemaPath)));
|
|
207839
|
+
const updateDiagnosticSeverity = (lspPluginElement) => {
|
|
207840
|
+
const diagnosticSeverityProperty = findPropertyInObject(lspPluginElement, "diagnosticSeverity");
|
|
207841
|
+
if (isSome(target.diagnosticSeverities)) {
|
|
207842
|
+
const newDiagnosticSeverityValue = createDiagnosticSeverityObject(target.diagnosticSeverities.value);
|
|
207843
|
+
if (!diagnosticSeverityProperty) {
|
|
207844
|
+
descriptions.push(`Add diagnosticSeverity to ${LSP_PLUGIN_NAME} plugin`);
|
|
207845
|
+
insertNodeAtEndOfList(tracker, current.sourceFile, lspPluginElement.properties, import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("diagnosticSeverity"), newDiagnosticSeverityValue));
|
|
207846
|
+
} else {
|
|
207847
|
+
descriptions.push(`Update diagnosticSeverity in ${LSP_PLUGIN_NAME} plugin`);
|
|
207848
|
+
tracker.replaceNode(current.sourceFile, diagnosticSeverityProperty.initializer, newDiagnosticSeverityValue);
|
|
207849
|
+
}
|
|
207850
|
+
} else if (diagnosticSeverityProperty) {
|
|
207851
|
+
descriptions.push(`Remove diagnosticSeverity from ${LSP_PLUGIN_NAME} plugin`);
|
|
207852
|
+
deleteNodeFromList(tracker, current.sourceFile, lspPluginElement.properties, diagnosticSeverityProperty);
|
|
207853
|
+
}
|
|
207854
|
+
};
|
|
207855
|
+
const findLspPlugin = () => {
|
|
207856
|
+
if (!pluginsProperty || !import_typescript.isArrayLiteralExpression(pluginsProperty.initializer)) return void 0;
|
|
207857
|
+
return pluginsProperty.initializer.elements.find((element) => {
|
|
207858
|
+
if (!import_typescript.isObjectLiteralExpression(element)) return false;
|
|
207859
|
+
const nameProperty = findPropertyInObject(element, "name");
|
|
207860
|
+
return nameProperty !== void 0 && import_typescript.isStringLiteral(nameProperty.initializer) && nameProperty.initializer.text === LSP_PLUGIN_NAME;
|
|
207861
|
+
});
|
|
207862
|
+
};
|
|
207863
|
+
if (!target.manageIntegration) {
|
|
207864
|
+
const lspPluginElement = findLspPlugin();
|
|
207865
|
+
if (lspPluginElement) {
|
|
207866
|
+
updateDiagnosticSeverity(lspPluginElement);
|
|
207867
|
+
return;
|
|
207868
|
+
}
|
|
207869
|
+
if (isNone(lspVersion)) return;
|
|
207870
|
+
}
|
|
207587
207871
|
if (isNone(lspVersion)) {
|
|
207588
|
-
if (schemaProperty) {
|
|
207872
|
+
if (isEffectSchemaProperty(schemaProperty)) {
|
|
207589
207873
|
descriptions.push("Remove $schema from tsconfig");
|
|
207590
207874
|
deleteNodeFromList(tracker, current.sourceFile, rootObj.properties, schemaProperty);
|
|
207591
207875
|
}
|
|
207592
207876
|
if (pluginsProperty && import_typescript.isArrayLiteralExpression(pluginsProperty.initializer)) {
|
|
207593
207877
|
const pluginsArray = pluginsProperty.initializer;
|
|
207594
|
-
const lspPluginElement =
|
|
207595
|
-
if (import_typescript.isObjectLiteralExpression(element)) {
|
|
207596
|
-
const nameProperty = findPropertyInObject(element, "name");
|
|
207597
|
-
if (nameProperty && import_typescript.isStringLiteral(nameProperty.initializer)) return nameProperty.initializer.text === LSP_PLUGIN_NAME;
|
|
207598
|
-
}
|
|
207599
|
-
return false;
|
|
207600
|
-
});
|
|
207878
|
+
const lspPluginElement = findLspPlugin();
|
|
207601
207879
|
if (lspPluginElement) {
|
|
207602
207880
|
descriptions.push(`Remove ${LSP_PLUGIN_NAME} plugin from tsconfig`);
|
|
207603
207881
|
deleteNodeFromList(tracker, current.sourceFile, pluginsArray.elements, lspPluginElement);
|
|
@@ -207606,7 +207884,7 @@ const computeTsConfigChanges = (current, target, lspVersion) => {
|
|
|
207606
207884
|
} else {
|
|
207607
207885
|
if (!schemaProperty && isSome(schemaPropertyAssignment)) {
|
|
207608
207886
|
descriptions.push("Add $schema to tsconfig");
|
|
207609
|
-
|
|
207887
|
+
tracker.insertNodeAtObjectStart(current.sourceFile, rootObj, schemaPropertyAssignment.value);
|
|
207610
207888
|
} else if (schemaProperty && isSome(target.schemaPath) && (!import_typescript.isStringLiteral(schemaProperty.initializer) || schemaProperty.initializer.text !== target.schemaPath.value)) {
|
|
207611
207889
|
descriptions.push("Update $schema in tsconfig");
|
|
207612
207890
|
tracker.replaceNode(current.sourceFile, schemaProperty.initializer, getOrThrow(schemaPropertyAssignment).initializer);
|
|
@@ -207618,32 +207896,11 @@ const computeTsConfigChanges = (current, target, lspVersion) => {
|
|
|
207618
207896
|
insertNodeAtEndOfList(tracker, current.sourceFile, compilerOptions.properties, newPluginsProp);
|
|
207619
207897
|
} else if (import_typescript.isArrayLiteralExpression(pluginsProperty.initializer)) {
|
|
207620
207898
|
const pluginsArray = pluginsProperty.initializer;
|
|
207621
|
-
const lspPluginElement =
|
|
207622
|
-
if (import_typescript.isObjectLiteralExpression(element)) {
|
|
207623
|
-
const nameProperty = findPropertyInObject(element, "name");
|
|
207624
|
-
if (nameProperty && import_typescript.isStringLiteral(nameProperty.initializer)) return nameProperty.initializer.text === LSP_PLUGIN_NAME;
|
|
207625
|
-
}
|
|
207626
|
-
return false;
|
|
207627
|
-
});
|
|
207899
|
+
const lspPluginElement = findLspPlugin();
|
|
207628
207900
|
if (!lspPluginElement) {
|
|
207629
207901
|
descriptions.push(`Add ${LSP_PLUGIN_NAME} plugin to existing plugins array`);
|
|
207630
207902
|
insertNodeAtEndOfList(tracker, current.sourceFile, pluginsArray.elements, pluginObject);
|
|
207631
|
-
} else if (import_typescript.isObjectLiteralExpression(lspPluginElement))
|
|
207632
|
-
const diagnosticSeverityProperty = findPropertyInObject(lspPluginElement, "diagnosticSeverity");
|
|
207633
|
-
if (isSome(target.diagnosticSeverities)) {
|
|
207634
|
-
const newDiagnosticSeverityValue = createDiagnosticSeverityObject(target.diagnosticSeverities.value);
|
|
207635
|
-
if (!diagnosticSeverityProperty) {
|
|
207636
|
-
descriptions.push(`Add diagnosticSeverity to ${LSP_PLUGIN_NAME} plugin`);
|
|
207637
|
-
insertNodeAtEndOfList(tracker, current.sourceFile, lspPluginElement.properties, import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("diagnosticSeverity"), newDiagnosticSeverityValue));
|
|
207638
|
-
} else if (import_typescript.isPropertyAssignment(diagnosticSeverityProperty)) {
|
|
207639
|
-
descriptions.push(`Update diagnosticSeverity in ${LSP_PLUGIN_NAME} plugin`);
|
|
207640
|
-
tracker.replaceNode(current.sourceFile, diagnosticSeverityProperty.initializer, newDiagnosticSeverityValue);
|
|
207641
|
-
}
|
|
207642
|
-
} else if (diagnosticSeverityProperty) {
|
|
207643
|
-
descriptions.push(`Remove diagnosticSeverity from ${LSP_PLUGIN_NAME} plugin`);
|
|
207644
|
-
deleteNodeFromList(tracker, current.sourceFile, lspPluginElement.properties, diagnosticSeverityProperty);
|
|
207645
|
-
}
|
|
207646
|
-
}
|
|
207903
|
+
} else if (import_typescript.isObjectLiteralExpression(lspPluginElement)) updateDiagnosticSeverity(lspPluginElement);
|
|
207647
207904
|
}
|
|
207648
207905
|
}
|
|
207649
207906
|
}).find((fc) => fc.fileName === current.path);
|
|
@@ -207715,7 +207972,7 @@ const computeChanges = (assessment, target) => {
|
|
|
207715
207972
|
const packageJsonResult = computePackageJsonChanges(assessment.packageJson, target.packageJson);
|
|
207716
207973
|
codeActions = [...codeActions, ...packageJsonResult.codeActions];
|
|
207717
207974
|
messages = [...messages, ...packageJsonResult.messages];
|
|
207718
|
-
const tsconfigResult = computeTsConfigChanges(assessment.tsconfig, target.tsconfig, target.packageJson.lspVersion);
|
|
207975
|
+
const tsconfigResult = computeTsConfigChanges(assessment.tsconfig, target.tsconfig, target.packageJson.integrations.includes("typescript") ? target.packageJson.lspVersion : none$3());
|
|
207719
207976
|
codeActions = [...codeActions, ...tsconfigResult.codeActions];
|
|
207720
207977
|
messages = [...messages, ...tsconfigResult.messages];
|
|
207721
207978
|
if (target.editors.includes("vscode")) {
|
|
@@ -207746,8 +208003,16 @@ const computeChanges = (assessment, target) => {
|
|
|
207746
208003
|
}
|
|
207747
208004
|
}
|
|
207748
208005
|
}
|
|
207749
|
-
if (isSome(target.packageJson.lspVersion) && codeActions.length > 0)
|
|
207750
|
-
|
|
208006
|
+
if (isSome(target.packageJson.lspVersion) && codeActions.length > 0) {
|
|
208007
|
+
const patchCommand = getPatchCommand(target.packageJson.integrations);
|
|
208008
|
+
messages = [...messages, `Run \`${patchCommand ?? "effect-tsgo patch"}\` to complete the installation.`];
|
|
208009
|
+
} else if (isNone(target.packageJson.lspVersion) && isSome(assessment.packageJson.lspVersion)) {
|
|
208010
|
+
const unpatchCommand = getPatchCommand(match$8(assessment.packageJson.prepareScript, {
|
|
208011
|
+
onNone: () => ["typescript"],
|
|
208012
|
+
onSome: (_) => _.integrations
|
|
208013
|
+
}))?.replace(" patch ", " unpatch ") ?? "effect-tsgo unpatch";
|
|
208014
|
+
messages = [...messages, `Run \`${unpatchCommand}\` to restore the original integrations.`];
|
|
208015
|
+
}
|
|
207751
208016
|
if (isSome(target.packageJson.lspVersion) && target.editors.length > 0) {
|
|
207752
208017
|
messages = [...messages, ""];
|
|
207753
208018
|
if (target.editors.includes("vscode")) messages = [
|
|
@@ -209892,11 +210157,19 @@ const fromAssessment = (inputState) => ({
|
|
|
209892
210157
|
packageJson: {
|
|
209893
210158
|
lspVersion: inputState.packageJson.lspVersion,
|
|
209894
210159
|
typescriptVersion: inputState.packageJson.typescriptVersion,
|
|
209895
|
-
|
|
210160
|
+
oxlintVersion: inputState.packageJson.oxlintVersion,
|
|
210161
|
+
oxlintTsgolintVersion: inputState.packageJson.oxlintTsgolintVersion,
|
|
210162
|
+
prepareScript: map$11(inputState.packageJson.prepareScript, (_) => _.hasPatch).pipe(getOrElse(() => false)),
|
|
210163
|
+
managePrepareScript: false,
|
|
210164
|
+
integrations: match$8(inputState.packageJson.prepareScript, {
|
|
210165
|
+
onNone: () => isSome(inputState.packageJson.lspVersion) ? ["typescript"] : [],
|
|
210166
|
+
onSome: (_) => _.integrations
|
|
210167
|
+
})
|
|
209896
210168
|
},
|
|
209897
210169
|
tsconfig: {
|
|
209898
210170
|
schemaPath: inputState.tsconfig.currentSchemaPath,
|
|
209899
|
-
diagnosticSeverities: inputState.tsconfig.currentDiagnosticSeverities
|
|
210171
|
+
diagnosticSeverities: inputState.tsconfig.currentDiagnosticSeverities,
|
|
210172
|
+
manageIntegration: false
|
|
209900
210173
|
},
|
|
209901
210174
|
vscodeSettings: map$11(inputState.vscodeSettings, (settings) => ({ settings: settings.parsed })),
|
|
209902
210175
|
editors: []
|
|
@@ -210040,10 +210313,10 @@ var ExperimentalOxlintPatchError = class extends TaggedError("ExperimentalOxlint
|
|
|
210040
210313
|
return `Unable to manage the experimental Oxlint integration: ${this.reason}`;
|
|
210041
210314
|
}
|
|
210042
210315
|
};
|
|
210043
|
-
const oxlintProfile = profiles.find((profile) => profile.kind === "oxlint");
|
|
210044
|
-
if (oxlintProfile === void 0 || oxlintProfile.kind !== "oxlint") throw new Error("Missing Oxlint profile in upstream.json");
|
|
210045
|
-
const supportedOxlintVersion = oxlintProfile.oxlint.npmVersion;
|
|
210046
|
-
const supportedTsgolintVersion = oxlintProfile.tsgolint.npmVersion;
|
|
210316
|
+
const oxlintProfile$1 = profiles.find((profile) => profile.kind === "oxlint");
|
|
210317
|
+
if (oxlintProfile$1 === void 0 || oxlintProfile$1.kind !== "oxlint") throw new Error("Missing Oxlint profile in upstream.json");
|
|
210318
|
+
const supportedOxlintVersion = oxlintProfile$1.oxlint.npmVersion;
|
|
210319
|
+
const supportedTsgolintVersion = oxlintProfile$1.tsgolint.npmVersion;
|
|
210047
210320
|
const readPackageMetadataFromRequire = (require, packageName) => gen(function* () {
|
|
210048
210321
|
const fs = yield* FileSystem;
|
|
210049
210322
|
const packageJsonPath = yield* try_({
|
|
@@ -210276,50 +210549,61 @@ function isPresetEnabled(presetName, severities) {
|
|
|
210276
210549
|
*/
|
|
210277
210550
|
const gatherTargetState = (assessment, context) => gen(function* () {
|
|
210278
210551
|
const path = yield* Path;
|
|
210279
|
-
const
|
|
210280
|
-
|
|
210281
|
-
|
|
210282
|
-
|
|
210283
|
-
|
|
210284
|
-
|
|
210285
|
-
|
|
210286
|
-
|
|
210287
|
-
|
|
210288
|
-
|
|
210289
|
-
|
|
210290
|
-
selected: currentLspState === "no" || currentLspState === "devDependencies"
|
|
210291
|
-
},
|
|
210292
|
-
{
|
|
210293
|
-
title: "Install in dependencies",
|
|
210294
|
-
description: "We usually don't recommend this, but if you need it for any reason",
|
|
210295
|
-
value: "dependencies",
|
|
210296
|
-
selected: currentLspState === "dependencies"
|
|
210297
|
-
},
|
|
210298
|
-
{
|
|
210299
|
-
title: "Uninstall",
|
|
210300
|
-
description: "Language service won't be installed or will be removed if already present",
|
|
210301
|
-
value: "no"
|
|
210302
|
-
}
|
|
210303
|
-
]
|
|
210552
|
+
const integrations = yield* multiSelect({
|
|
210553
|
+
message: "Which integrations would you like to configure?",
|
|
210554
|
+
choices: [{
|
|
210555
|
+
title: "TypeScript language service",
|
|
210556
|
+
value: "typescript",
|
|
210557
|
+
selected: true
|
|
210558
|
+
}, {
|
|
210559
|
+
title: "Oxlint type-aware rules",
|
|
210560
|
+
value: "oxlint",
|
|
210561
|
+
selected: isSome(assessment.packageJson.oxlintVersion) || isSome(assessment.packageJson.oxlintTsgolintVersion)
|
|
210562
|
+
}]
|
|
210304
210563
|
});
|
|
210305
|
-
|
|
210564
|
+
const useTypescript = integrations.includes("typescript");
|
|
210565
|
+
const useOxlint = integrations.includes("oxlint");
|
|
210566
|
+
if (integrations.length === 0) return {
|
|
210306
210567
|
packageJson: {
|
|
210307
210568
|
lspVersion: none$3(),
|
|
210308
210569
|
typescriptVersion: assessment.packageJson.typescriptVersion,
|
|
210309
|
-
|
|
210570
|
+
oxlintVersion: assessment.packageJson.oxlintVersion,
|
|
210571
|
+
oxlintTsgolintVersion: assessment.packageJson.oxlintTsgolintVersion,
|
|
210572
|
+
prepareScript: false,
|
|
210573
|
+
managePrepareScript: true,
|
|
210574
|
+
integrations
|
|
210310
210575
|
},
|
|
210311
210576
|
tsconfig: {
|
|
210312
210577
|
schemaPath: none$3(),
|
|
210313
|
-
diagnosticSeverities: none$3()
|
|
210578
|
+
diagnosticSeverities: none$3(),
|
|
210579
|
+
manageIntegration: true
|
|
210314
210580
|
},
|
|
210315
210581
|
vscodeSettings: none$3(),
|
|
210316
210582
|
editors: []
|
|
210317
210583
|
};
|
|
210584
|
+
const currentLspState = match$8(assessment.packageJson.lspVersion, {
|
|
210585
|
+
onNone: () => "no",
|
|
210586
|
+
onSome: (lsp) => lsp.dependencyType
|
|
210587
|
+
});
|
|
210588
|
+
const lspDependencyType = yield* select({
|
|
210589
|
+
message: "@effect/tsgo installation:",
|
|
210590
|
+
choices: [{
|
|
210591
|
+
title: "Install in devDependencies",
|
|
210592
|
+
description: "This is the recommended default option",
|
|
210593
|
+
value: "devDependencies",
|
|
210594
|
+
selected: currentLspState === "no" || currentLspState === "devDependencies"
|
|
210595
|
+
}, {
|
|
210596
|
+
title: "Install in dependencies",
|
|
210597
|
+
description: "We usually don't recommend this, but if you need it for any reason",
|
|
210598
|
+
value: "dependencies",
|
|
210599
|
+
selected: currentLspState === "dependencies"
|
|
210600
|
+
}]
|
|
210601
|
+
});
|
|
210318
210602
|
const currentDiagnosticSeverities = match$8(assessment.tsconfig.currentDiagnosticSeverities, {
|
|
210319
210603
|
onNone: () => ({}),
|
|
210320
210604
|
onSome: (diagnosticSeverities) => diagnosticSeverities
|
|
210321
210605
|
});
|
|
210322
|
-
const selectedDiagnosticModes = yield* multiSelect({
|
|
210606
|
+
const selectedDiagnosticModes = useTypescript ? yield* multiSelect({
|
|
210323
210607
|
message: "Which diagnostic presets would you like to use?",
|
|
210324
210608
|
choices: [{
|
|
210325
210609
|
title: "Custom",
|
|
@@ -210331,13 +210615,13 @@ const gatherTargetState = (assessment, context) => gen(function* () {
|
|
|
210331
210615
|
value: preset.name,
|
|
210332
210616
|
selected: isPresetEnabled(preset.name, currentDiagnosticSeverities)
|
|
210333
210617
|
}))]
|
|
210334
|
-
});
|
|
210618
|
+
}) : [];
|
|
210335
210619
|
const shouldCustomizeDiagnostics = selectedDiagnosticModes.includes("custom");
|
|
210336
210620
|
const initialSeverities = applyPresetDiagnosticSeverities(currentDiagnosticSeverities, selectedDiagnosticModes.filter((value) => value !== "custom"));
|
|
210337
210621
|
const diagnosticSeveritiesRecord = shouldCustomizeDiagnostics ? yield* createRulePrompt(getAllRules(), initialSeverities) : initialSeverities;
|
|
210338
210622
|
const diagnosticSeverities = Object.keys(diagnosticSeveritiesRecord).length > 0 ? some(diagnosticSeveritiesRecord) : none$3();
|
|
210339
210623
|
const hasVscodeSettings = isSome(assessment.vscodeSettings);
|
|
210340
|
-
const editors = yield* multiSelect({
|
|
210624
|
+
const editors = useTypescript ? yield* multiSelect({
|
|
210341
210625
|
message: "Which editors do you use?",
|
|
210342
210626
|
choices: [
|
|
210343
210627
|
{
|
|
@@ -210354,7 +210638,7 @@ const gatherTargetState = (assessment, context) => gen(function* () {
|
|
|
210354
210638
|
value: "emacs"
|
|
210355
210639
|
}
|
|
210356
210640
|
]
|
|
210357
|
-
});
|
|
210641
|
+
}) : [];
|
|
210358
210642
|
const defaultTypescriptPackageName = defaultTypescriptPackageNames[0];
|
|
210359
210643
|
const relativeSchemaPath = path.relative(path.dirname(assessment.tsconfig.path), context.defaultSchemaPath).replaceAll("\\", "/");
|
|
210360
210644
|
const vscodeSettings = editors.includes("vscode") ? some({ settings: {
|
|
@@ -210369,16 +210653,33 @@ const gatherTargetState = (assessment, context) => gen(function* () {
|
|
|
210369
210653
|
dependencyType: lspDependencyType,
|
|
210370
210654
|
version: context.defaultLspVersion
|
|
210371
210655
|
}),
|
|
210372
|
-
typescriptVersion: orElse(assessment.packageJson.typescriptVersion, () => some({
|
|
210656
|
+
typescriptVersion: useTypescript ? orElse(assessment.packageJson.typescriptVersion, () => some({
|
|
210373
210657
|
dependencyType: lspDependencyType,
|
|
210374
210658
|
version: context.defaultTypescriptVersion,
|
|
210375
210659
|
packageName: defaultTypescriptPackageName
|
|
210376
|
-
})),
|
|
210377
|
-
|
|
210660
|
+
})) : assessment.packageJson.typescriptVersion,
|
|
210661
|
+
oxlintVersion: useOxlint ? some({
|
|
210662
|
+
dependencyType: match$8(assessment.packageJson.oxlintVersion, {
|
|
210663
|
+
onNone: () => lspDependencyType,
|
|
210664
|
+
onSome: (dependency) => dependency.dependencyType
|
|
210665
|
+
}),
|
|
210666
|
+
version: context.defaultOxlintVersion
|
|
210667
|
+
}) : assessment.packageJson.oxlintVersion,
|
|
210668
|
+
oxlintTsgolintVersion: useOxlint ? some({
|
|
210669
|
+
dependencyType: match$8(assessment.packageJson.oxlintTsgolintVersion, {
|
|
210670
|
+
onNone: () => lspDependencyType,
|
|
210671
|
+
onSome: (dependency) => dependency.dependencyType
|
|
210672
|
+
}),
|
|
210673
|
+
version: context.defaultOxlintTsgolintVersion
|
|
210674
|
+
}) : assessment.packageJson.oxlintTsgolintVersion,
|
|
210675
|
+
prepareScript: true,
|
|
210676
|
+
managePrepareScript: true,
|
|
210677
|
+
integrations
|
|
210378
210678
|
},
|
|
210379
210679
|
tsconfig: {
|
|
210380
|
-
schemaPath: some(relativeSchemaPath.startsWith(".") ? relativeSchemaPath : `./${relativeSchemaPath}`),
|
|
210381
|
-
diagnosticSeverities
|
|
210680
|
+
schemaPath: useTypescript ? some(relativeSchemaPath.startsWith(".") ? relativeSchemaPath : `./${relativeSchemaPath}`) : none$3(),
|
|
210681
|
+
diagnosticSeverities,
|
|
210682
|
+
manageIntegration: true
|
|
210382
210683
|
},
|
|
210383
210684
|
vscodeSettings,
|
|
210384
210685
|
editors
|
|
@@ -210389,6 +210690,8 @@ const gatherTargetState = (assessment, context) => gen(function* () {
|
|
|
210389
210690
|
//#region src/cli/setup/index.ts
|
|
210390
210691
|
const latestProfile = profiles.find((profile) => profile.name === "latest");
|
|
210391
210692
|
if (latestProfile === void 0) throw new Error("Missing latest profile in upstream.json");
|
|
210693
|
+
const oxlintProfile = profiles.find((profile) => profile.kind === "oxlint");
|
|
210694
|
+
if (oxlintProfile?.oxlint === void 0 || oxlintProfile.tsgolint === void 0) throw new Error("Missing oxlint profile in upstream.json");
|
|
210392
210695
|
const setupCommand = make("setup").pipe(withDescription("Setup @effect/tsgo for the given project using an interactive CLI."), withHandler(() => gen(function* () {
|
|
210393
210696
|
const path = yield* Path;
|
|
210394
210697
|
const currentDir = path.resolve(process.cwd());
|
|
@@ -210398,6 +210701,8 @@ const setupCommand = make("setup").pipe(withDescription("Setup @effect/tsgo for
|
|
|
210398
210701
|
const targetState = yield* gatherTargetState(assessmentState, {
|
|
210399
210702
|
defaultLspVersion: version,
|
|
210400
210703
|
defaultTypescriptVersion: latestProfile.ts.npmVersion,
|
|
210704
|
+
defaultOxlintVersion: oxlintProfile.oxlint.npmVersion,
|
|
210705
|
+
defaultOxlintTsgolintVersion: oxlintProfile.tsgolint.npmVersion,
|
|
210401
210706
|
defaultSchemaPath: path.resolve(currentDir, "node_modules", name, "schema.json")
|
|
210402
210707
|
});
|
|
210403
210708
|
const result = computeChanges(assessmentState, targetState);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/tsgo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Effect Language Service for TypeScript-Go — Effect-specific diagnostics and hover features.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"schema.json"
|
|
33
33
|
],
|
|
34
34
|
"optionalDependencies": {
|
|
35
|
-
"@effect/tsgo-win32-x64": "0.
|
|
36
|
-
"@effect/tsgo-win32-arm64": "0.
|
|
37
|
-
"@effect/tsgo-linux-x64": "0.
|
|
38
|
-
"@effect/tsgo-linux-arm64": "0.
|
|
39
|
-
"@effect/tsgo-linux-arm": "0.
|
|
40
|
-
"@effect/tsgo-darwin-x64": "0.
|
|
41
|
-
"@effect/tsgo-darwin-arm64": "0.
|
|
35
|
+
"@effect/tsgo-win32-x64": "0.29.0",
|
|
36
|
+
"@effect/tsgo-win32-arm64": "0.29.0",
|
|
37
|
+
"@effect/tsgo-linux-x64": "0.29.0",
|
|
38
|
+
"@effect/tsgo-linux-arm64": "0.29.0",
|
|
39
|
+
"@effect/tsgo-linux-arm": "0.29.0",
|
|
40
|
+
"@effect/tsgo-darwin-x64": "0.29.0",
|
|
41
|
+
"@effect/tsgo-darwin-arm64": "0.29.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@effect/platform-node": "^4.0.0-beta.101",
|