@effect/tsgo 0.29.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,7 +206981,7 @@ var FileReadError = class extends TaggedError("FileReadError") {
206981
206981
  //#endregion
206982
206982
  //#region package.json
206983
206983
  var name = "@effect/tsgo";
206984
- var version = "0.29.0";
206984
+ var version = "0.30.0";
206985
206985
 
206986
206986
  //#endregion
206987
206987
  //#region src/cli/setup/consts.ts
@@ -207207,6 +207207,19 @@ const createAssessmentInput = (currentDir, tsconfigInput) => gen(function* () {
207207
207207
  cause
207208
207208
  })))
207209
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
+ }
207210
207223
  const vscodeSettingsPath = path.join(currentDir, ".vscode", "settings.json");
207211
207224
  const vscodeSettingsExists = yield* fs.exists(vscodeSettingsPath);
207212
207225
  let vscodeSettingsInput = none$3();
@@ -207223,6 +207236,7 @@ const createAssessmentInput = (currentDir, tsconfigInput) => gen(function* () {
207223
207236
  return {
207224
207237
  packageJson: packageJsonInput,
207225
207238
  tsconfig: tsconfigInput,
207239
+ oxlintConfig: oxlintConfigInput,
207226
207240
  vscodeSettings: vscodeSettingsInput
207227
207241
  };
207228
207242
  });
@@ -207318,6 +207332,17 @@ const assessVSCodeSettings = (input) => {
207318
207332
  text: input.text
207319
207333
  };
207320
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
+ };
207321
207346
  /**
207322
207347
  * Perform assessment from input data
207323
207348
  */
@@ -207325,6 +207350,7 @@ const assess = (input) => {
207325
207350
  return {
207326
207351
  packageJson: assessPackageJson(input.packageJson),
207327
207352
  tsconfig: assessTsConfig(input.tsconfig),
207353
+ oxlintConfig: isSome(input.oxlintConfig) ? some(assessOxlintConfig(input.oxlintConfig.value)) : none$3(),
207328
207354
  vscodeSettings: isSome(input.vscodeSettings) ? some(assessVSCodeSettings(input.vscodeSettings.value)) : none$3()
207329
207355
  };
207330
207356
  };
@@ -207456,6 +207482,7 @@ const renderCodeActions = (result, assessmentState) => gen(function* () {
207456
207482
  return;
207457
207483
  }
207458
207484
  const sourceFiles = [assessmentState.packageJson.sourceFile, assessmentState.tsconfig.sourceFile];
207485
+ if (isSome(assessmentState.oxlintConfig)) sourceFiles.push(assessmentState.oxlintConfig.value.sourceFile);
207459
207486
  if (isSome(assessmentState.vscodeSettings)) sourceFiles.push(assessmentState.vscodeSettings.value.sourceFile);
207460
207487
  for (const codeAction of result.codeActions) for (const fileChange of codeAction.changes) {
207461
207488
  yield* log("");
@@ -207921,6 +207948,31 @@ const computeTsConfigChanges = (current, target, lspVersion) => {
207921
207948
  messages
207922
207949
  };
207923
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
+ };
207924
207976
  /**
207925
207977
  * Compute .vscode/settings.json changes using ChangeTracker
207926
207978
  */
@@ -207975,6 +208027,11 @@ const computeChanges = (assessment, target) => {
207975
208027
  const tsconfigResult = computeTsConfigChanges(assessment.tsconfig, target.tsconfig, target.packageJson.integrations.includes("typescript") ? target.packageJson.lspVersion : none$3());
207976
208028
  codeActions = [...codeActions, ...tsconfigResult.codeActions];
207977
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
+ }
207978
208035
  if (target.editors.includes("vscode")) {
207979
208036
  if (isSome(target.packageJson.lspVersion) && isSome(target.vscodeSettings)) {
207980
208037
  const vscodeTarget = target.vscodeSettings.value;
@@ -210171,6 +210228,7 @@ const fromAssessment = (inputState) => ({
210171
210228
  diagnosticSeverities: inputState.tsconfig.currentDiagnosticSeverities,
210172
210229
  manageIntegration: false
210173
210230
  },
210231
+ oxlintrcSchemaPath: flatMap$3(inputState.oxlintConfig, (config) => config.currentSchemaPath),
210174
210232
  vscodeSettings: map$11(inputState.vscodeSettings, (settings) => ({ settings: settings.parsed })),
210175
210233
  editors: []
210176
210234
  });
@@ -210578,6 +210636,7 @@ const gatherTargetState = (assessment, context) => gen(function* () {
210578
210636
  diagnosticSeverities: none$3(),
210579
210637
  manageIntegration: true
210580
210638
  },
210639
+ oxlintrcSchemaPath: none$3(),
210581
210640
  vscodeSettings: none$3(),
210582
210641
  editors: []
210583
210642
  };
@@ -210641,6 +210700,10 @@ const gatherTargetState = (assessment, context) => gen(function* () {
210641
210700
  }) : [];
210642
210701
  const defaultTypescriptPackageName = defaultTypescriptPackageNames[0];
210643
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();
210644
210707
  const vscodeSettings = editors.includes("vscode") ? some({ settings: {
210645
210708
  "js/ts.experimental.useTsgo": true,
210646
210709
  "js/ts.tsdk.path": "./node_modules/typescript/bin",
@@ -210681,6 +210744,7 @@ const gatherTargetState = (assessment, context) => gen(function* () {
210681
210744
  diagnosticSeverities,
210682
210745
  manageIntegration: true
210683
210746
  },
210747
+ oxlintrcSchemaPath,
210684
210748
  vscodeSettings,
210685
210749
  editors
210686
210750
  };
@@ -210703,7 +210767,8 @@ const setupCommand = make("setup").pipe(withDescription("Setup @effect/tsgo for
210703
210767
  defaultTypescriptVersion: latestProfile.ts.npmVersion,
210704
210768
  defaultOxlintVersion: oxlintProfile.oxlint.npmVersion,
210705
210769
  defaultOxlintTsgolintVersion: oxlintProfile.tsgolint.npmVersion,
210706
- defaultSchemaPath: path.resolve(currentDir, "node_modules", name, "schema.json")
210770
+ defaultSchemaPath: path.resolve(currentDir, "node_modules", name, "schema.json"),
210771
+ defaultOxlintrcSchemaPath: path.resolve(currentDir, "node_modules", name, "oxlint-schema.json")
210707
210772
  });
210708
210773
  const result = computeChanges(assessmentState, targetState);
210709
210774
  yield* reviewAndApplyChanges(result, assessmentState, { cancelMessage: "Setup cancelled. No changes were made." });