@effect/tsgo 0.28.0 → 0.30.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.
@@ -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.28.0";
206984
+ var version = "0.30.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 PATCH_COMMAND = "effect-tsgo patch";
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
  /**
@@ -207016,6 +207207,19 @@ const createAssessmentInput = (currentDir, tsconfigInput) => gen(function* () {
207016
207207
  cause
207017
207208
  })))
207018
207209
  };
207210
+ const oxlintConfigPath = path.join(currentDir, ".oxlintrc.json");
207211
+ const oxlintConfigExists = yield* fs.exists(oxlintConfigPath);
207212
+ let oxlintConfigInput = none$3();
207213
+ if (oxlintConfigExists) {
207214
+ const oxlintConfigText = yield* fs.readFileString(oxlintConfigPath).pipe(mapError((cause) => new FileReadError({
207215
+ path: oxlintConfigPath,
207216
+ cause
207217
+ })));
207218
+ oxlintConfigInput = some({
207219
+ fileName: oxlintConfigPath,
207220
+ text: oxlintConfigText
207221
+ });
207222
+ }
207019
207223
  const vscodeSettingsPath = path.join(currentDir, ".vscode", "settings.json");
207020
207224
  const vscodeSettingsExists = yield* fs.exists(vscodeSettingsPath);
207021
207225
  let vscodeSettingsInput = none$3();
@@ -207032,6 +207236,7 @@ const createAssessmentInput = (currentDir, tsconfigInput) => gen(function* () {
207032
207236
  return {
207033
207237
  packageJson: packageJsonInput,
207034
207238
  tsconfig: tsconfigInput,
207239
+ oxlintConfig: oxlintConfigInput,
207035
207240
  vscodeSettings: vscodeSettingsInput
207036
207241
  };
207037
207242
  });
@@ -207053,6 +207258,8 @@ const assessPackageJson = (input) => {
207053
207258
  return none$3();
207054
207259
  };
207055
207260
  const lspVersion = assessDependency(LSP_PACKAGE_NAME);
207261
+ const oxlintVersion = assessDependency(OXLINT_PACKAGE_NAME);
207262
+ const oxlintTsgolintVersion = assessDependency(OXLINT_TSGOLINT_PACKAGE_NAME);
207056
207263
  let typescriptVersion = none$3();
207057
207264
  for (const packageName of defaultTypescriptPackageNames) {
207058
207265
  const typescriptDep = assessDependency(packageName);
@@ -207066,7 +207273,8 @@ const assessPackageJson = (input) => {
207066
207273
  }
207067
207274
  const prepareScript = "prepare" in (parsed.scripts ?? {}) ? some({
207068
207275
  script: parsed.scripts.prepare,
207069
- hasPatch: parsed.scripts.prepare.toLowerCase().includes(PATCH_COMMAND)
207276
+ hasPatch: hasPatchCommand(parsed.scripts.prepare),
207277
+ integrations: getPatchIntegrations(parsed.scripts.prepare)
207070
207278
  }) : none$3();
207071
207279
  return {
207072
207280
  path: input.fileName,
@@ -207075,6 +207283,8 @@ const assessPackageJson = (input) => {
207075
207283
  text: input.text,
207076
207284
  lspVersion,
207077
207285
  typescriptVersion,
207286
+ oxlintVersion,
207287
+ oxlintTsgolintVersion,
207078
207288
  prepareScript
207079
207289
  };
207080
207290
  };
@@ -207122,6 +207332,17 @@ const assessVSCodeSettings = (input) => {
207122
207332
  text: input.text
207123
207333
  };
207124
207334
  };
207335
+ const assessOxlintConfig = (input) => {
207336
+ const sourceFile = import_typescript.parseJsonText(input.fileName, input.text);
207337
+ const parsed = import_typescript.convertToObject(sourceFile, []);
207338
+ return {
207339
+ path: input.fileName,
207340
+ sourceFile,
207341
+ parsed,
207342
+ text: input.text,
207343
+ currentSchemaPath: typeof parsed.$schema === "string" ? some(parsed.$schema) : none$3()
207344
+ };
207345
+ };
207125
207346
  /**
207126
207347
  * Perform assessment from input data
207127
207348
  */
@@ -207129,6 +207350,7 @@ const assess = (input) => {
207129
207350
  return {
207130
207351
  packageJson: assessPackageJson(input.packageJson),
207131
207352
  tsconfig: assessTsConfig(input.tsconfig),
207353
+ oxlintConfig: isSome(input.oxlintConfig) ? some(assessOxlintConfig(input.oxlintConfig.value)) : none$3(),
207132
207354
  vscodeSettings: isSome(input.vscodeSettings) ? some(assessVSCodeSettings(input.vscodeSettings.value)) : none$3()
207133
207355
  };
207134
207356
  };
@@ -207260,6 +207482,7 @@ const renderCodeActions = (result, assessmentState) => gen(function* () {
207260
207482
  return;
207261
207483
  }
207262
207484
  const sourceFiles = [assessmentState.packageJson.sourceFile, assessmentState.tsconfig.sourceFile];
207485
+ if (isSome(assessmentState.oxlintConfig)) sourceFiles.push(assessmentState.oxlintConfig.value.sourceFile);
207263
207486
  if (isSome(assessmentState.vscodeSettings)) sourceFiles.push(assessmentState.vscodeSettings.value.sourceFile);
207264
207487
  for (const codeAction of result.codeActions) for (const fileChange of codeAction.changes) {
207265
207488
  yield* log("");
@@ -207422,6 +207645,20 @@ const computePackageJsonChanges = (current, target) => {
207422
207645
  if (!targetTypescript) return;
207423
207646
  dependencyProperties.push(import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(getTypescriptPackageName(targetTypescript)), import_typescript.factory.createStringLiteral(targetTypescript.version)));
207424
207647
  };
207648
+ const appendNewOxlintDependencies = (dependencyProperties, dependencyType) => {
207649
+ for (const [packageName, currentDependency, targetDependency] of [[
207650
+ OXLINT_PACKAGE_NAME,
207651
+ current.oxlintVersion,
207652
+ target.oxlintVersion
207653
+ ], [
207654
+ OXLINT_TSGOLINT_PACKAGE_NAME,
207655
+ current.oxlintTsgolintVersion,
207656
+ target.oxlintTsgolintVersion
207657
+ ]]) if (target.integrations.includes("oxlint") && isNone(currentDependency) && isSome(targetDependency) && targetDependency.value.dependencyType === dependencyType) {
207658
+ descriptions.push(`Add ${packageName}@${targetDependency.value.version} in ${dependencyType}`);
207659
+ dependencyProperties.push(import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(packageName), import_typescript.factory.createStringLiteral(targetDependency.value.version)));
207660
+ }
207661
+ };
207425
207662
  const ensureTypescriptDependency = () => {
207426
207663
  if (isNone(target.typescriptVersion) || isSome(current.typescriptVersion)) return;
207427
207664
  const targetTypescript = target.typescriptVersion.value;
@@ -207430,6 +207667,13 @@ const computePackageJsonChanges = (current, target) => {
207430
207667
  descriptions.push(`Add ${targetTypescriptPackageName}@${targetTypescript.version} to ${targetTypescript.dependencyType}`);
207431
207668
  upsertDependency(tracker, current.sourceFile, rootObj, targetTypescriptPackageName, targetTypescript);
207432
207669
  };
207670
+ const ensurePinnedDependency = (packageName, currentDependency, targetDependency) => {
207671
+ if (isNone(targetDependency)) return;
207672
+ if (isSome(currentDependency) && currentDependency.value.version === targetDependency.value.version && currentDependency.value.dependencyType === targetDependency.value.dependencyType) return;
207673
+ if (isNone(currentDependency) && !findDependencyCollectionProperty(rootObj, targetDependency.value.dependencyType) && isSome(target.lspVersion) && target.lspVersion.value.dependencyType === targetDependency.value.dependencyType) return;
207674
+ descriptions.push(`${isSome(currentDependency) ? "Update" : "Add"} ${packageName}@${targetDependency.value.version} in ${targetDependency.value.dependencyType}`);
207675
+ upsertDependency(tracker, current.sourceFile, rootObj, packageName, targetDependency.value);
207676
+ };
207433
207677
  if (isSome(target.lspVersion)) {
207434
207678
  const targetDepType = target.lspVersion.value.dependencyType;
207435
207679
  const targetVersion = target.lspVersion.value.version;
@@ -207447,6 +207691,7 @@ const computePackageJsonChanges = (current, target) => {
207447
207691
  if (!newDepsProperty) {
207448
207692
  const dependencyProperties = [import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(LSP_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetVersion))];
207449
207693
  if (shouldAddTypescriptWithDependencyType(targetDepType)) appendTypescriptDependencyProperty(dependencyProperties);
207694
+ appendNewOxlintDependencies(dependencyProperties, targetDepType);
207450
207695
  const newDepsProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(targetDepType), import_typescript.factory.createObjectLiteralExpression(dependencyProperties, false));
207451
207696
  insertNodeAtEndOfList(tracker, current.sourceFile, rootObj.properties, newDepsProp);
207452
207697
  } 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 +207709,16 @@ const computePackageJsonChanges = (current, target) => {
207464
207709
  if (!depsProperty) {
207465
207710
  const dependencyProperties = [import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(LSP_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetVersion))];
207466
207711
  if (shouldAddTypescriptWithDependencyType(targetDepType)) appendTypescriptDependencyProperty(dependencyProperties);
207712
+ appendNewOxlintDependencies(dependencyProperties, targetDepType);
207467
207713
  const newDepsProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(targetDepType), import_typescript.factory.createObjectLiteralExpression(dependencyProperties, false));
207468
207714
  insertNodeAtEndOfList(tracker, current.sourceFile, rootObj.properties, newDepsProp);
207469
207715
  } 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
207716
  }
207471
207717
  ensureTypescriptDependency();
207718
+ if (target.integrations.includes("oxlint")) {
207719
+ ensurePinnedDependency(OXLINT_PACKAGE_NAME, current.oxlintVersion, target.oxlintVersion);
207720
+ ensurePinnedDependency(OXLINT_TSGOLINT_PACKAGE_NAME, current.oxlintTsgolintVersion, target.oxlintTsgolintVersion);
207721
+ }
207472
207722
  } else if (isSome(current.lspVersion)) {
207473
207723
  descriptions.push(`Remove ${LSP_PACKAGE_NAME} from dependencies`);
207474
207724
  const currentDepType = current.lspVersion.value.dependencyType;
@@ -207478,39 +207728,47 @@ const computePackageJsonChanges = (current, target) => {
207478
207728
  if (lspProperty) deleteNodeFromList(tracker, current.sourceFile, depsProperty.initializer.properties, lspProperty);
207479
207729
  }
207480
207730
  }
207481
- if (target.prepareScript && isSome(target.lspVersion)) {
207731
+ const patchCommand = target.prepareScript && isSome(target.lspVersion) ? getPatchCommand(target.integrations) : void 0;
207732
+ if (!target.managePrepareScript) return;
207733
+ else if (patchCommand !== void 0) {
207482
207734
  const scriptsProperty = findPropertyInObject(rootObj, "scripts");
207483
207735
  if (!scriptsProperty) {
207484
207736
  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(PATCH_COMMAND))], false));
207737
+ 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
207738
  insertNodeAtEndOfList(tracker, current.sourceFile, rootObj.properties, newScriptsProp);
207487
207739
  } else if (import_typescript.isObjectLiteralExpression(scriptsProperty.initializer)) {
207488
207740
  const prepareProperty = findPropertyInObject(scriptsProperty.initializer, "prepare");
207489
207741
  if (!prepareProperty) {
207490
207742
  descriptions.push("Add prepare script");
207491
- const newPrepareProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("prepare"), import_typescript.factory.createStringLiteral(PATCH_COMMAND));
207743
+ const newPrepareProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("prepare"), import_typescript.factory.createStringLiteral(patchCommand));
207492
207744
  insertNodeAtEndOfList(tracker, current.sourceFile, scriptsProperty.initializer.properties, newPrepareProp);
207493
207745
  } else if (isSome(current.prepareScript) && !current.prepareScript.value.hasPatch) {
207494
207746
  descriptions.push("Update prepare script to include patch command");
207495
- const newScript = `${current.prepareScript.value.script} && ${PATCH_COMMAND}`;
207747
+ const newScript = `${current.prepareScript.value.script} && ${patchCommand}`;
207496
207748
  tracker.replaceNode(current.sourceFile, prepareProperty.initializer, import_typescript.factory.createStringLiteral(newScript));
207749
+ } else if (isSome(current.prepareScript)) {
207750
+ const currentScript = current.prepareScript.value.script;
207751
+ const updated = updatePatchCommand(currentScript, target.integrations);
207752
+ if (updated.found && updated.script !== currentScript) {
207753
+ descriptions.push("Update effect-tsgo patch integrations in prepare script");
207754
+ tracker.replaceNode(current.sourceFile, prepareProperty.initializer, import_typescript.factory.createStringLiteral(updated.script));
207755
+ }
207497
207756
  }
207498
207757
  }
207499
- } else if (isNone(target.lspVersion) && isSome(current.prepareScript) && current.prepareScript.value.hasPatch) {
207758
+ } else if (isSome(current.prepareScript) && current.prepareScript.value.hasPatch) {
207500
207759
  const scriptsProperty = findPropertyInObject(rootObj, "scripts");
207501
207760
  if (scriptsProperty && import_typescript.isObjectLiteralExpression(scriptsProperty.initializer)) {
207502
207761
  const prepareProperty = findPropertyInObject(scriptsProperty.initializer, "prepare");
207503
207762
  if (prepareProperty && import_typescript.isStringLiteral(prepareProperty.initializer)) {
207504
207763
  const currentScript = current.prepareScript.value.script;
207505
- if (currentScript.includes("&&") || currentScript.includes(";")) {
207764
+ const updated = updatePatchCommand(currentScript, []);
207765
+ if (updated.found && updated.script.length > 0) {
207506
207766
  descriptions.push("Remove effect-tsgo patch command from prepare script");
207507
- messages.push("WARNING: Your prepare script contained multiple commands. I attempted to automatically remove only the 'effect-tsgo patch' command. Please verify that the prepare script is correct after this change.");
207508
- const newScript = currentScript.replace(/\s*&&\s*effect-tsgo\s+patch/g, "").replace(/effect-tsgo\s+patch\s*&&\s*/g, "").replace(/\s*;\s*effect-tsgo\s+patch/g, "").replace(/effect-tsgo\s+patch\s*;\s*/g, "").trim();
207509
- tracker.replaceNode(current.sourceFile, prepareProperty.initializer, import_typescript.factory.createStringLiteral(newScript));
207510
- } else {
207767
+ tracker.replaceNode(current.sourceFile, prepareProperty.initializer, import_typescript.factory.createStringLiteral(updated.script));
207768
+ } else if (updated.found) {
207511
207769
  descriptions.push("Remove prepare script with patch command");
207512
207770
  deleteNodeFromList(tracker, current.sourceFile, scriptsProperty.initializer.properties, prepareProperty);
207513
- }
207771
+ } else messages.push("WARNING: The prepare script uses shell control flow that cannot be safely rewritten. Remove the effect-tsgo patch command manually.");
207514
207772
  }
207515
207773
  }
207516
207774
  }
@@ -207540,9 +207798,30 @@ const computeTsConfigChanges = (current, target, lspVersion) => {
207540
207798
  const messages = [];
207541
207799
  const rootObj = getRootObject(current.sourceFile);
207542
207800
  if (!rootObj) return emptyFileChangesResult();
207801
+ const isEffectSchemaProperty = (property) => property !== void 0 && import_typescript.isStringLiteral(property.initializer) && property.initializer.text.replaceAll("\\", "/").endsWith("node_modules/@effect/tsgo/schema.json");
207543
207802
  const compilerOptionsProperty = findPropertyInObject(rootObj, "compilerOptions");
207544
207803
  if (!compilerOptionsProperty || !import_typescript.isObjectLiteralExpression(compilerOptionsProperty.initializer)) {
207545
- if (isNone(lspVersion)) return emptyFileChangesResult();
207804
+ if (isNone(lspVersion)) {
207805
+ if (!target.manageIntegration) return emptyFileChangesResult();
207806
+ const schemaProperty = findPropertyInObject(rootObj, "$schema");
207807
+ if (!isEffectSchemaProperty(schemaProperty)) return emptyFileChangesResult();
207808
+ const ctx = createTrackerContext();
207809
+ const fileChange = tsInternal.textChanges.ChangeTracker.with(ctx, (tracker) => {
207810
+ descriptions.push("Remove $schema from tsconfig");
207811
+ deleteNodeFromList(tracker, current.sourceFile, rootObj.properties, schemaProperty);
207812
+ }).find((fc) => fc.fileName === current.sourceFile.fileName);
207813
+ return {
207814
+ codeActions: fileChange ? [{
207815
+ description: descriptions.join("; "),
207816
+ changes: [{
207817
+ fileName: current.sourceFile.fileName,
207818
+ textChanges: fileChange.textChanges,
207819
+ isNewFile: false
207820
+ }]
207821
+ }] : [],
207822
+ messages
207823
+ };
207824
+ }
207546
207825
  const ctx = createTrackerContext();
207547
207826
  const fileChange = tsInternal.textChanges.ChangeTracker.with(ctx, (tracker) => {
207548
207827
  const schemaProperty = findPropertyInObject(rootObj, "$schema");
@@ -207557,7 +207836,7 @@ const computeTsConfigChanges = (current, target, lspVersion) => {
207557
207836
  if (schemaProperty && property === schemaProperty && isSome(schemaPropertyAssignment)) return schemaPropertyAssignment.value;
207558
207837
  return property;
207559
207838
  });
207560
- if (shouldAddSchema && isSome(schemaPropertyAssignment)) nextProperties.push(schemaPropertyAssignment.value);
207839
+ if (shouldAddSchema && isSome(schemaPropertyAssignment)) nextProperties.unshift(schemaPropertyAssignment.value);
207561
207840
  nextProperties.push(compilerOptionsAssignment);
207562
207841
  tracker.replaceNode(current.sourceFile, rootObj, import_typescript.factory.createObjectLiteralExpression(nextProperties, true));
207563
207842
  }).find((fc) => fc.fileName === current.sourceFile.fileName);
@@ -207584,20 +207863,46 @@ const computeTsConfigChanges = (current, target, lspVersion) => {
207584
207863
  const schemaProperty = findPropertyInObject(rootObj, "$schema");
207585
207864
  const pluginsProperty = findPropertyInObject(compilerOptions, "plugins");
207586
207865
  const schemaPropertyAssignment = map$11(target.schemaPath, (schemaPath) => import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("$schema"), import_typescript.factory.createStringLiteral(schemaPath)));
207866
+ const updateDiagnosticSeverity = (lspPluginElement) => {
207867
+ const diagnosticSeverityProperty = findPropertyInObject(lspPluginElement, "diagnosticSeverity");
207868
+ if (isSome(target.diagnosticSeverities)) {
207869
+ const newDiagnosticSeverityValue = createDiagnosticSeverityObject(target.diagnosticSeverities.value);
207870
+ if (!diagnosticSeverityProperty) {
207871
+ descriptions.push(`Add diagnosticSeverity to ${LSP_PLUGIN_NAME} plugin`);
207872
+ insertNodeAtEndOfList(tracker, current.sourceFile, lspPluginElement.properties, import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("diagnosticSeverity"), newDiagnosticSeverityValue));
207873
+ } else {
207874
+ descriptions.push(`Update diagnosticSeverity in ${LSP_PLUGIN_NAME} plugin`);
207875
+ tracker.replaceNode(current.sourceFile, diagnosticSeverityProperty.initializer, newDiagnosticSeverityValue);
207876
+ }
207877
+ } else if (diagnosticSeverityProperty) {
207878
+ descriptions.push(`Remove diagnosticSeverity from ${LSP_PLUGIN_NAME} plugin`);
207879
+ deleteNodeFromList(tracker, current.sourceFile, lspPluginElement.properties, diagnosticSeverityProperty);
207880
+ }
207881
+ };
207882
+ const findLspPlugin = () => {
207883
+ if (!pluginsProperty || !import_typescript.isArrayLiteralExpression(pluginsProperty.initializer)) return void 0;
207884
+ return pluginsProperty.initializer.elements.find((element) => {
207885
+ if (!import_typescript.isObjectLiteralExpression(element)) return false;
207886
+ const nameProperty = findPropertyInObject(element, "name");
207887
+ return nameProperty !== void 0 && import_typescript.isStringLiteral(nameProperty.initializer) && nameProperty.initializer.text === LSP_PLUGIN_NAME;
207888
+ });
207889
+ };
207890
+ if (!target.manageIntegration) {
207891
+ const lspPluginElement = findLspPlugin();
207892
+ if (lspPluginElement) {
207893
+ updateDiagnosticSeverity(lspPluginElement);
207894
+ return;
207895
+ }
207896
+ if (isNone(lspVersion)) return;
207897
+ }
207587
207898
  if (isNone(lspVersion)) {
207588
- if (schemaProperty) {
207899
+ if (isEffectSchemaProperty(schemaProperty)) {
207589
207900
  descriptions.push("Remove $schema from tsconfig");
207590
207901
  deleteNodeFromList(tracker, current.sourceFile, rootObj.properties, schemaProperty);
207591
207902
  }
207592
207903
  if (pluginsProperty && import_typescript.isArrayLiteralExpression(pluginsProperty.initializer)) {
207593
207904
  const pluginsArray = pluginsProperty.initializer;
207594
- const lspPluginElement = pluginsArray.elements.find((element) => {
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
- });
207905
+ const lspPluginElement = findLspPlugin();
207601
207906
  if (lspPluginElement) {
207602
207907
  descriptions.push(`Remove ${LSP_PLUGIN_NAME} plugin from tsconfig`);
207603
207908
  deleteNodeFromList(tracker, current.sourceFile, pluginsArray.elements, lspPluginElement);
@@ -207606,7 +207911,7 @@ const computeTsConfigChanges = (current, target, lspVersion) => {
207606
207911
  } else {
207607
207912
  if (!schemaProperty && isSome(schemaPropertyAssignment)) {
207608
207913
  descriptions.push("Add $schema to tsconfig");
207609
- insertNodeAtEndOfList(tracker, current.sourceFile, rootObj.properties, schemaPropertyAssignment.value);
207914
+ tracker.insertNodeAtObjectStart(current.sourceFile, rootObj, schemaPropertyAssignment.value);
207610
207915
  } else if (schemaProperty && isSome(target.schemaPath) && (!import_typescript.isStringLiteral(schemaProperty.initializer) || schemaProperty.initializer.text !== target.schemaPath.value)) {
207611
207916
  descriptions.push("Update $schema in tsconfig");
207612
207917
  tracker.replaceNode(current.sourceFile, schemaProperty.initializer, getOrThrow(schemaPropertyAssignment).initializer);
@@ -207618,32 +207923,11 @@ const computeTsConfigChanges = (current, target, lspVersion) => {
207618
207923
  insertNodeAtEndOfList(tracker, current.sourceFile, compilerOptions.properties, newPluginsProp);
207619
207924
  } else if (import_typescript.isArrayLiteralExpression(pluginsProperty.initializer)) {
207620
207925
  const pluginsArray = pluginsProperty.initializer;
207621
- const lspPluginElement = pluginsArray.elements.find((element) => {
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
- });
207926
+ const lspPluginElement = findLspPlugin();
207628
207927
  if (!lspPluginElement) {
207629
207928
  descriptions.push(`Add ${LSP_PLUGIN_NAME} plugin to existing plugins array`);
207630
207929
  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
- }
207930
+ } else if (import_typescript.isObjectLiteralExpression(lspPluginElement)) updateDiagnosticSeverity(lspPluginElement);
207647
207931
  }
207648
207932
  }
207649
207933
  }).find((fc) => fc.fileName === current.path);
@@ -207664,6 +207948,31 @@ const computeTsConfigChanges = (current, target, lspVersion) => {
207664
207948
  messages
207665
207949
  };
207666
207950
  };
207951
+ const computeOxlintConfigChanges = (current, schemaPath) => {
207952
+ if (isNone(schemaPath)) return emptyFileChangesResult();
207953
+ const rootObj = getRootObject(current.sourceFile);
207954
+ if (!rootObj) return emptyFileChangesResult();
207955
+ const schemaProperty = findPropertyInObject(rootObj, "$schema");
207956
+ if (schemaProperty && import_typescript.isStringLiteral(schemaProperty.initializer) && schemaProperty.initializer.text === schemaPath.value) return emptyFileChangesResult();
207957
+ const schemaPropertyAssignment = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral("$schema"), import_typescript.factory.createStringLiteral(schemaPath.value));
207958
+ const ctx = createTrackerContext();
207959
+ const fileChange = tsInternal.textChanges.ChangeTracker.with(ctx, (tracker) => {
207960
+ if (schemaProperty) tracker.replaceNode(current.sourceFile, schemaProperty.initializer, schemaPropertyAssignment.initializer);
207961
+ else tracker.insertNodeAtObjectStart(current.sourceFile, rootObj, schemaPropertyAssignment);
207962
+ }).find((change) => change.fileName === current.sourceFile.fileName);
207963
+ if (!fileChange) return emptyFileChangesResult();
207964
+ return {
207965
+ codeActions: [{
207966
+ description: schemaProperty ? "Update $schema in .oxlintrc.json" : "Add $schema to .oxlintrc.json",
207967
+ changes: [{
207968
+ fileName: current.path,
207969
+ textChanges: fileChange.textChanges,
207970
+ isNewFile: false
207971
+ }]
207972
+ }],
207973
+ messages: []
207974
+ };
207975
+ };
207667
207976
  /**
207668
207977
  * Compute .vscode/settings.json changes using ChangeTracker
207669
207978
  */
@@ -207715,9 +208024,14 @@ const computeChanges = (assessment, target) => {
207715
208024
  const packageJsonResult = computePackageJsonChanges(assessment.packageJson, target.packageJson);
207716
208025
  codeActions = [...codeActions, ...packageJsonResult.codeActions];
207717
208026
  messages = [...messages, ...packageJsonResult.messages];
207718
- const tsconfigResult = computeTsConfigChanges(assessment.tsconfig, target.tsconfig, target.packageJson.lspVersion);
208027
+ const tsconfigResult = computeTsConfigChanges(assessment.tsconfig, target.tsconfig, target.packageJson.integrations.includes("typescript") ? target.packageJson.lspVersion : none$3());
207719
208028
  codeActions = [...codeActions, ...tsconfigResult.codeActions];
207720
208029
  messages = [...messages, ...tsconfigResult.messages];
208030
+ if (isSome(assessment.oxlintConfig)) {
208031
+ const oxlintConfigResult = computeOxlintConfigChanges(assessment.oxlintConfig.value, target.oxlintrcSchemaPath);
208032
+ codeActions = [...codeActions, ...oxlintConfigResult.codeActions];
208033
+ messages = [...messages, ...oxlintConfigResult.messages];
208034
+ }
207721
208035
  if (target.editors.includes("vscode")) {
207722
208036
  if (isSome(target.packageJson.lspVersion) && isSome(target.vscodeSettings)) {
207723
208037
  const vscodeTarget = target.vscodeSettings.value;
@@ -207746,8 +208060,16 @@ const computeChanges = (assessment, target) => {
207746
208060
  }
207747
208061
  }
207748
208062
  }
207749
- if (isSome(target.packageJson.lspVersion) && codeActions.length > 0) messages = [...messages, "Run `effect-tsgo patch` to complete the installation."];
207750
- else if (isNone(target.packageJson.lspVersion) && isSome(assessment.packageJson.lspVersion)) messages = [...messages, "Run `effect-tsgo unpatch` to restore the original TypeScript-Go binary."];
208063
+ if (isSome(target.packageJson.lspVersion) && codeActions.length > 0) {
208064
+ const patchCommand = getPatchCommand(target.packageJson.integrations);
208065
+ messages = [...messages, `Run \`${patchCommand ?? "effect-tsgo patch"}\` to complete the installation.`];
208066
+ } else if (isNone(target.packageJson.lspVersion) && isSome(assessment.packageJson.lspVersion)) {
208067
+ const unpatchCommand = getPatchCommand(match$8(assessment.packageJson.prepareScript, {
208068
+ onNone: () => ["typescript"],
208069
+ onSome: (_) => _.integrations
208070
+ }))?.replace(" patch ", " unpatch ") ?? "effect-tsgo unpatch";
208071
+ messages = [...messages, `Run \`${unpatchCommand}\` to restore the original integrations.`];
208072
+ }
207751
208073
  if (isSome(target.packageJson.lspVersion) && target.editors.length > 0) {
207752
208074
  messages = [...messages, ""];
207753
208075
  if (target.editors.includes("vscode")) messages = [
@@ -209892,12 +210214,21 @@ const fromAssessment = (inputState) => ({
209892
210214
  packageJson: {
209893
210215
  lspVersion: inputState.packageJson.lspVersion,
209894
210216
  typescriptVersion: inputState.packageJson.typescriptVersion,
209895
- prepareScript: map$11(inputState.packageJson.prepareScript, (_) => _.hasPatch).pipe(getOrElse(() => false))
210217
+ oxlintVersion: inputState.packageJson.oxlintVersion,
210218
+ oxlintTsgolintVersion: inputState.packageJson.oxlintTsgolintVersion,
210219
+ prepareScript: map$11(inputState.packageJson.prepareScript, (_) => _.hasPatch).pipe(getOrElse(() => false)),
210220
+ managePrepareScript: false,
210221
+ integrations: match$8(inputState.packageJson.prepareScript, {
210222
+ onNone: () => isSome(inputState.packageJson.lspVersion) ? ["typescript"] : [],
210223
+ onSome: (_) => _.integrations
210224
+ })
209896
210225
  },
209897
210226
  tsconfig: {
209898
210227
  schemaPath: inputState.tsconfig.currentSchemaPath,
209899
- diagnosticSeverities: inputState.tsconfig.currentDiagnosticSeverities
210228
+ diagnosticSeverities: inputState.tsconfig.currentDiagnosticSeverities,
210229
+ manageIntegration: false
209900
210230
  },
210231
+ oxlintrcSchemaPath: flatMap$3(inputState.oxlintConfig, (config) => config.currentSchemaPath),
209901
210232
  vscodeSettings: map$11(inputState.vscodeSettings, (settings) => ({ settings: settings.parsed })),
209902
210233
  editors: []
209903
210234
  });
@@ -210040,10 +210371,10 @@ var ExperimentalOxlintPatchError = class extends TaggedError("ExperimentalOxlint
210040
210371
  return `Unable to manage the experimental Oxlint integration: ${this.reason}`;
210041
210372
  }
210042
210373
  };
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;
210374
+ const oxlintProfile$1 = profiles.find((profile) => profile.kind === "oxlint");
210375
+ if (oxlintProfile$1 === void 0 || oxlintProfile$1.kind !== "oxlint") throw new Error("Missing Oxlint profile in upstream.json");
210376
+ const supportedOxlintVersion = oxlintProfile$1.oxlint.npmVersion;
210377
+ const supportedTsgolintVersion = oxlintProfile$1.tsgolint.npmVersion;
210047
210378
  const readPackageMetadataFromRequire = (require, packageName) => gen(function* () {
210048
210379
  const fs = yield* FileSystem;
210049
210380
  const packageJsonPath = yield* try_({
@@ -210276,50 +210607,62 @@ function isPresetEnabled(presetName, severities) {
210276
210607
  */
210277
210608
  const gatherTargetState = (assessment, context) => gen(function* () {
210278
210609
  const path = yield* Path;
210279
- const currentLspState = match$8(assessment.packageJson.lspVersion, {
210280
- onNone: () => "no",
210281
- onSome: (lsp) => lsp.dependencyType
210282
- });
210283
- const lspDependencyType = yield* select({
210284
- message: "Language service installation:",
210285
- choices: [
210286
- {
210287
- title: "Install in devDependencies",
210288
- description: "This is the recommended default option",
210289
- value: "devDependencies",
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
- ]
210610
+ const integrations = yield* multiSelect({
210611
+ message: "Which integrations would you like to configure?",
210612
+ choices: [{
210613
+ title: "TypeScript language service",
210614
+ value: "typescript",
210615
+ selected: true
210616
+ }, {
210617
+ title: "Oxlint type-aware rules",
210618
+ value: "oxlint",
210619
+ selected: isSome(assessment.packageJson.oxlintVersion) || isSome(assessment.packageJson.oxlintTsgolintVersion)
210620
+ }]
210304
210621
  });
210305
- if (lspDependencyType === "no") return {
210622
+ const useTypescript = integrations.includes("typescript");
210623
+ const useOxlint = integrations.includes("oxlint");
210624
+ if (integrations.length === 0) return {
210306
210625
  packageJson: {
210307
210626
  lspVersion: none$3(),
210308
210627
  typescriptVersion: assessment.packageJson.typescriptVersion,
210309
- prepareScript: false
210628
+ oxlintVersion: assessment.packageJson.oxlintVersion,
210629
+ oxlintTsgolintVersion: assessment.packageJson.oxlintTsgolintVersion,
210630
+ prepareScript: false,
210631
+ managePrepareScript: true,
210632
+ integrations
210310
210633
  },
210311
210634
  tsconfig: {
210312
210635
  schemaPath: none$3(),
210313
- diagnosticSeverities: none$3()
210636
+ diagnosticSeverities: none$3(),
210637
+ manageIntegration: true
210314
210638
  },
210639
+ oxlintrcSchemaPath: none$3(),
210315
210640
  vscodeSettings: none$3(),
210316
210641
  editors: []
210317
210642
  };
210643
+ const currentLspState = match$8(assessment.packageJson.lspVersion, {
210644
+ onNone: () => "no",
210645
+ onSome: (lsp) => lsp.dependencyType
210646
+ });
210647
+ const lspDependencyType = yield* select({
210648
+ message: "@effect/tsgo installation:",
210649
+ choices: [{
210650
+ title: "Install in devDependencies",
210651
+ description: "This is the recommended default option",
210652
+ value: "devDependencies",
210653
+ selected: currentLspState === "no" || currentLspState === "devDependencies"
210654
+ }, {
210655
+ title: "Install in dependencies",
210656
+ description: "We usually don't recommend this, but if you need it for any reason",
210657
+ value: "dependencies",
210658
+ selected: currentLspState === "dependencies"
210659
+ }]
210660
+ });
210318
210661
  const currentDiagnosticSeverities = match$8(assessment.tsconfig.currentDiagnosticSeverities, {
210319
210662
  onNone: () => ({}),
210320
210663
  onSome: (diagnosticSeverities) => diagnosticSeverities
210321
210664
  });
210322
- const selectedDiagnosticModes = yield* multiSelect({
210665
+ const selectedDiagnosticModes = useTypescript ? yield* multiSelect({
210323
210666
  message: "Which diagnostic presets would you like to use?",
210324
210667
  choices: [{
210325
210668
  title: "Custom",
@@ -210331,13 +210674,13 @@ const gatherTargetState = (assessment, context) => gen(function* () {
210331
210674
  value: preset.name,
210332
210675
  selected: isPresetEnabled(preset.name, currentDiagnosticSeverities)
210333
210676
  }))]
210334
- });
210677
+ }) : [];
210335
210678
  const shouldCustomizeDiagnostics = selectedDiagnosticModes.includes("custom");
210336
210679
  const initialSeverities = applyPresetDiagnosticSeverities(currentDiagnosticSeverities, selectedDiagnosticModes.filter((value) => value !== "custom"));
210337
210680
  const diagnosticSeveritiesRecord = shouldCustomizeDiagnostics ? yield* createRulePrompt(getAllRules(), initialSeverities) : initialSeverities;
210338
210681
  const diagnosticSeverities = Object.keys(diagnosticSeveritiesRecord).length > 0 ? some(diagnosticSeveritiesRecord) : none$3();
210339
210682
  const hasVscodeSettings = isSome(assessment.vscodeSettings);
210340
- const editors = yield* multiSelect({
210683
+ const editors = useTypescript ? yield* multiSelect({
210341
210684
  message: "Which editors do you use?",
210342
210685
  choices: [
210343
210686
  {
@@ -210354,9 +210697,13 @@ const gatherTargetState = (assessment, context) => gen(function* () {
210354
210697
  value: "emacs"
210355
210698
  }
210356
210699
  ]
210357
- });
210700
+ }) : [];
210358
210701
  const defaultTypescriptPackageName = defaultTypescriptPackageNames[0];
210359
210702
  const relativeSchemaPath = path.relative(path.dirname(assessment.tsconfig.path), context.defaultSchemaPath).replaceAll("\\", "/");
210703
+ const oxlintrcSchemaPath = useOxlint ? map$11(assessment.oxlintConfig, (config) => {
210704
+ const relativePath = path.relative(path.dirname(config.path), context.defaultOxlintrcSchemaPath).replaceAll("\\", "/");
210705
+ return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
210706
+ }) : none$3();
210360
210707
  const vscodeSettings = editors.includes("vscode") ? some({ settings: {
210361
210708
  "js/ts.experimental.useTsgo": true,
210362
210709
  "js/ts.tsdk.path": "./node_modules/typescript/bin",
@@ -210369,17 +210716,35 @@ const gatherTargetState = (assessment, context) => gen(function* () {
210369
210716
  dependencyType: lspDependencyType,
210370
210717
  version: context.defaultLspVersion
210371
210718
  }),
210372
- typescriptVersion: orElse(assessment.packageJson.typescriptVersion, () => some({
210719
+ typescriptVersion: useTypescript ? orElse(assessment.packageJson.typescriptVersion, () => some({
210373
210720
  dependencyType: lspDependencyType,
210374
210721
  version: context.defaultTypescriptVersion,
210375
210722
  packageName: defaultTypescriptPackageName
210376
- })),
210377
- prepareScript: true
210723
+ })) : assessment.packageJson.typescriptVersion,
210724
+ oxlintVersion: useOxlint ? some({
210725
+ dependencyType: match$8(assessment.packageJson.oxlintVersion, {
210726
+ onNone: () => lspDependencyType,
210727
+ onSome: (dependency) => dependency.dependencyType
210728
+ }),
210729
+ version: context.defaultOxlintVersion
210730
+ }) : assessment.packageJson.oxlintVersion,
210731
+ oxlintTsgolintVersion: useOxlint ? some({
210732
+ dependencyType: match$8(assessment.packageJson.oxlintTsgolintVersion, {
210733
+ onNone: () => lspDependencyType,
210734
+ onSome: (dependency) => dependency.dependencyType
210735
+ }),
210736
+ version: context.defaultOxlintTsgolintVersion
210737
+ }) : assessment.packageJson.oxlintTsgolintVersion,
210738
+ prepareScript: true,
210739
+ managePrepareScript: true,
210740
+ integrations
210378
210741
  },
210379
210742
  tsconfig: {
210380
- schemaPath: some(relativeSchemaPath.startsWith(".") ? relativeSchemaPath : `./${relativeSchemaPath}`),
210381
- diagnosticSeverities
210743
+ schemaPath: useTypescript ? some(relativeSchemaPath.startsWith(".") ? relativeSchemaPath : `./${relativeSchemaPath}`) : none$3(),
210744
+ diagnosticSeverities,
210745
+ manageIntegration: true
210382
210746
  },
210747
+ oxlintrcSchemaPath,
210383
210748
  vscodeSettings,
210384
210749
  editors
210385
210750
  };
@@ -210389,6 +210754,8 @@ const gatherTargetState = (assessment, context) => gen(function* () {
210389
210754
  //#region src/cli/setup/index.ts
210390
210755
  const latestProfile = profiles.find((profile) => profile.name === "latest");
210391
210756
  if (latestProfile === void 0) throw new Error("Missing latest profile in upstream.json");
210757
+ const oxlintProfile = profiles.find((profile) => profile.kind === "oxlint");
210758
+ if (oxlintProfile?.oxlint === void 0 || oxlintProfile.tsgolint === void 0) throw new Error("Missing oxlint profile in upstream.json");
210392
210759
  const setupCommand = make("setup").pipe(withDescription("Setup @effect/tsgo for the given project using an interactive CLI."), withHandler(() => gen(function* () {
210393
210760
  const path = yield* Path;
210394
210761
  const currentDir = path.resolve(process.cwd());
@@ -210398,7 +210765,10 @@ const setupCommand = make("setup").pipe(withDescription("Setup @effect/tsgo for
210398
210765
  const targetState = yield* gatherTargetState(assessmentState, {
210399
210766
  defaultLspVersion: version,
210400
210767
  defaultTypescriptVersion: latestProfile.ts.npmVersion,
210401
- defaultSchemaPath: path.resolve(currentDir, "node_modules", name, "schema.json")
210768
+ defaultOxlintVersion: oxlintProfile.oxlint.npmVersion,
210769
+ defaultOxlintTsgolintVersion: oxlintProfile.tsgolint.npmVersion,
210770
+ defaultSchemaPath: path.resolve(currentDir, "node_modules", name, "schema.json"),
210771
+ defaultOxlintrcSchemaPath: path.resolve(currentDir, "node_modules", name, "oxlint-schema.json")
210402
210772
  });
210403
210773
  const result = computeChanges(assessmentState, targetState);
210404
210774
  yield* reviewAndApplyChanges(result, assessmentState, { cancelMessage: "Setup cancelled. No changes were made." });