@effect/tsgo 0.16.3 → 0.17.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/README.md +1 -1
- package/dist/effect-tsgo.js +144 -88
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ This will guide you through the installation process, which includes:
|
|
|
22
22
|
4. Hinting at any additional editor configuration needed to ensure the LSP is active.
|
|
23
23
|
|
|
24
24
|
> [!NOTE]
|
|
25
|
-
> At the moment, you still need a native TypeScript install alongside `@effect/tsgo
|
|
25
|
+
> At the moment, you still need a native TypeScript install alongside `@effect/tsgo`: `typescript` >= 7 (e.g. `typescript@latest` or `typescript@next`). `effect-tsgo patch` selects the packaged Effect binary whose TypeScript git head matches the installed `typescript` package.
|
|
26
26
|
|
|
27
27
|
## Diagnostic Status
|
|
28
28
|
|
package/dist/effect-tsgo.js
CHANGED
|
@@ -204437,17 +204437,14 @@ var FileReadError = class extends TaggedError("FileReadError") {
|
|
|
204437
204437
|
//#endregion
|
|
204438
204438
|
//#region package.json
|
|
204439
204439
|
var name = "@effect/tsgo";
|
|
204440
|
-
var version = "0.
|
|
204440
|
+
var version = "0.17.0";
|
|
204441
204441
|
|
|
204442
204442
|
//#endregion
|
|
204443
204443
|
//#region src/setup/consts.ts
|
|
204444
204444
|
const LSP_PACKAGE_NAME = name;
|
|
204445
204445
|
const LSP_PLUGIN_NAME = "@effect/language-service";
|
|
204446
|
-
const NATIVE_PREVIEW_PACKAGE_NAME = "@typescript/native-preview";
|
|
204447
204446
|
const TYPESCRIPT_PACKAGE_NAME = "typescript";
|
|
204448
204447
|
const PATCH_COMMAND = "effect-tsgo patch";
|
|
204449
|
-
const DEFAULT_LSP_VERSION = version;
|
|
204450
|
-
const DEFAULT_NATIVE_PREVIEW_VERSION = "latest";
|
|
204451
204448
|
const TSCONFIG_SCHEMA_URL = "https://raw.githubusercontent.com/Effect-TS/tsgo/refs/heads/main/schema.json";
|
|
204452
204449
|
/**
|
|
204453
204450
|
* `typescript` package versions >= 7 ship the native Go-ported binary that this
|
|
@@ -204458,13 +204455,7 @@ const isNativeTypescriptVersion = (version) => {
|
|
|
204458
204455
|
const match = /\d+/.exec(version.trim());
|
|
204459
204456
|
return match !== null && Number(match[0]) >= 7;
|
|
204460
204457
|
};
|
|
204461
|
-
/** The
|
|
204462
|
-
const nativePreviewBackend = {
|
|
204463
|
-
packageName: NATIVE_PREVIEW_PACKAGE_NAME,
|
|
204464
|
-
platformPackagePrefix: "@typescript/native-preview",
|
|
204465
|
-
binaryName: "tsgo"
|
|
204466
|
-
};
|
|
204467
|
-
/** The `typescript` >= 7 backend (stable/RC releases). */
|
|
204458
|
+
/** The `typescript` >= 7 backend. */
|
|
204468
204459
|
const typescriptBackend = {
|
|
204469
204460
|
packageName: TYPESCRIPT_PACKAGE_NAME,
|
|
204470
204461
|
platformPackagePrefix: "@typescript/typescript",
|
|
@@ -204472,10 +204463,7 @@ const typescriptBackend = {
|
|
|
204472
204463
|
versionCheck: (pkg) => isNativeTypescriptVersion(pkg.version ?? "0")
|
|
204473
204464
|
};
|
|
204474
204465
|
/**
|
|
204475
|
-
* Resolve the VS Code
|
|
204476
|
-
* The "TypeScript (Native Preview)" extension reads the native install from
|
|
204477
|
-
* this path; for `@typescript/native-preview` it is `node_modules/<pkg>`, and
|
|
204478
|
-
* for `typescript` >= 7 it is `node_modules/typescript`.
|
|
204466
|
+
* Resolve the VS Code TypeScript 7 tsdk folder.
|
|
204479
204467
|
*/
|
|
204480
204468
|
const nativeBackendTsdkPath = (packageName) => "node_modules/" + packageName;
|
|
204481
204469
|
|
|
@@ -204533,14 +204521,11 @@ const assessPackageJson = (input) => {
|
|
|
204533
204521
|
return none$3();
|
|
204534
204522
|
};
|
|
204535
204523
|
const lspVersion = assessDependency(LSP_PACKAGE_NAME);
|
|
204536
|
-
const
|
|
204537
|
-
|
|
204538
|
-
|
|
204539
|
-
|
|
204540
|
-
|
|
204541
|
-
});
|
|
204542
|
-
return none$3();
|
|
204543
|
-
});
|
|
204524
|
+
const typescriptDep = assessDependency(TYPESCRIPT_PACKAGE_NAME);
|
|
204525
|
+
const typescriptVersion = isSome(typescriptDep) && isNativeTypescriptVersion(typescriptDep.value.version) ? some({
|
|
204526
|
+
...typescriptDep.value,
|
|
204527
|
+
packageName: TYPESCRIPT_PACKAGE_NAME
|
|
204528
|
+
}) : none$3();
|
|
204544
204529
|
const prepareScript = "prepare" in (parsed.scripts ?? {}) ? some({
|
|
204545
204530
|
script: parsed.scripts.prepare,
|
|
204546
204531
|
hasPatch: parsed.scripts.prepare.toLowerCase().includes(PATCH_COMMAND)
|
|
@@ -204551,7 +204536,7 @@ const assessPackageJson = (input) => {
|
|
|
204551
204536
|
parsed,
|
|
204552
204537
|
text: input.text,
|
|
204553
204538
|
lspVersion,
|
|
204554
|
-
|
|
204539
|
+
typescriptVersion,
|
|
204555
204540
|
prepareScript
|
|
204556
204541
|
};
|
|
204557
204542
|
};
|
|
@@ -204890,17 +204875,13 @@ const computePackageJsonChanges = (current, target) => {
|
|
|
204890
204875
|
if (!rootObj) return emptyFileChangesResult();
|
|
204891
204876
|
const ctx = createTrackerContext();
|
|
204892
204877
|
const fileChange = tsInternal.textChanges.ChangeTracker.with(ctx, (tracker) => {
|
|
204893
|
-
const
|
|
204894
|
-
|
|
204895
|
-
|
|
204896
|
-
|
|
204897
|
-
|
|
204898
|
-
|
|
204899
|
-
|
|
204900
|
-
const targetNativePreview = target.nativePreviewVersion.value;
|
|
204901
|
-
if (!findDependencyCollectionProperty(rootObj, targetNativePreview.dependencyType) && isSome(target.lspVersion) && target.lspVersion.value.dependencyType === targetNativePreview.dependencyType) return;
|
|
204902
|
-
descriptions.push(`Add ${nativeBackendPackageName}@${targetNativePreview.version} to ${targetNativePreview.dependencyType}`);
|
|
204903
|
-
upsertDependency(tracker, current.sourceFile, rootObj, nativeBackendPackageName, targetNativePreview);
|
|
204878
|
+
const shouldAddTypescriptWithDependencyType = (dependencyType) => isSome(target.typescriptVersion) && isNone(current.typescriptVersion) && target.typescriptVersion.value.dependencyType === dependencyType;
|
|
204879
|
+
const ensureTypescriptDependency = () => {
|
|
204880
|
+
if (isNone(target.typescriptVersion) || isSome(current.typescriptVersion)) return;
|
|
204881
|
+
const targetTypescript = target.typescriptVersion.value;
|
|
204882
|
+
if (!findDependencyCollectionProperty(rootObj, targetTypescript.dependencyType) && isSome(target.lspVersion) && target.lspVersion.value.dependencyType === targetTypescript.dependencyType) return;
|
|
204883
|
+
descriptions.push(`Add ${TYPESCRIPT_PACKAGE_NAME}@${targetTypescript.version} to ${targetTypescript.dependencyType}`);
|
|
204884
|
+
upsertDependency(tracker, current.sourceFile, rootObj, TYPESCRIPT_PACKAGE_NAME, targetTypescript);
|
|
204904
204885
|
};
|
|
204905
204886
|
if (isSome(target.lspVersion)) {
|
|
204906
204887
|
const targetDepType = target.lspVersion.value.dependencyType;
|
|
@@ -204918,9 +204899,9 @@ const computePackageJsonChanges = (current, target) => {
|
|
|
204918
204899
|
const newDepsProperty = findDependencyCollectionProperty(rootObj, targetDepType);
|
|
204919
204900
|
if (!newDepsProperty) {
|
|
204920
204901
|
const dependencyProperties = [import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(LSP_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetVersion))];
|
|
204921
|
-
if (
|
|
204922
|
-
const
|
|
204923
|
-
if (
|
|
204902
|
+
if (shouldAddTypescriptWithDependencyType(targetDepType)) {
|
|
204903
|
+
const targetTypescript = target.typescriptVersion.pipe(getOrUndefined);
|
|
204904
|
+
if (targetTypescript) dependencyProperties.push(import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(TYPESCRIPT_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetTypescript.version)));
|
|
204924
204905
|
}
|
|
204925
204906
|
const newDepsProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(targetDepType), import_typescript.factory.createObjectLiteralExpression(dependencyProperties, false));
|
|
204926
204907
|
insertNodeAtEndOfList(tracker, current.sourceFile, rootObj.properties, newDepsProp);
|
|
@@ -204938,15 +204919,15 @@ const computePackageJsonChanges = (current, target) => {
|
|
|
204938
204919
|
const depsProperty = findDependencyCollectionProperty(rootObj, targetDepType);
|
|
204939
204920
|
if (!depsProperty) {
|
|
204940
204921
|
const dependencyProperties = [import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(LSP_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetVersion))];
|
|
204941
|
-
if (
|
|
204942
|
-
const
|
|
204943
|
-
if (
|
|
204922
|
+
if (shouldAddTypescriptWithDependencyType(targetDepType)) {
|
|
204923
|
+
const targetTypescript = target.typescriptVersion.pipe(getOrUndefined);
|
|
204924
|
+
if (targetTypescript) dependencyProperties.push(import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(TYPESCRIPT_PACKAGE_NAME), import_typescript.factory.createStringLiteral(targetTypescript.version)));
|
|
204944
204925
|
}
|
|
204945
204926
|
const newDepsProp = import_typescript.factory.createPropertyAssignment(import_typescript.factory.createStringLiteral(targetDepType), import_typescript.factory.createObjectLiteralExpression(dependencyProperties, false));
|
|
204946
204927
|
insertNodeAtEndOfList(tracker, current.sourceFile, rootObj.properties, newDepsProp);
|
|
204947
204928
|
} 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)));
|
|
204948
204929
|
}
|
|
204949
|
-
|
|
204930
|
+
ensureTypescriptDependency();
|
|
204950
204931
|
} else if (isSome(current.lspVersion)) {
|
|
204951
204932
|
descriptions.push(`Remove ${LSP_PACKAGE_NAME} from dependencies`);
|
|
204952
204933
|
const currentDepType = current.lspVersion.value.dependencyType;
|
|
@@ -205230,7 +205211,7 @@ const computeChanges = (assessment, target) => {
|
|
|
205230
205211
|
if (target.editors.includes("vscode")) messages = [
|
|
205231
205212
|
...messages,
|
|
205232
205213
|
"VS Code / Cursor / VS Code-based editors:",
|
|
205233
|
-
" 1. Install the
|
|
205214
|
+
" 1. Install the TypeScript 7 extension",
|
|
205234
205215
|
" 2. Open a TypeScript file and ensure the native TS server is active",
|
|
205235
205216
|
" 3. The language service plugin will be loaded automatically",
|
|
205236
205217
|
""
|
|
@@ -207159,7 +207140,7 @@ function createRulePrompt(rules, initialSeverities) {
|
|
|
207159
207140
|
const fromAssessment = (inputState) => ({
|
|
207160
207141
|
packageJson: {
|
|
207161
207142
|
lspVersion: inputState.packageJson.lspVersion,
|
|
207162
|
-
|
|
207143
|
+
typescriptVersion: inputState.packageJson.typescriptVersion,
|
|
207163
207144
|
prepareScript: map$10(inputState.packageJson.prepareScript, (_) => _.hasPatch).pipe(getOrElse$1(() => false))
|
|
207164
207145
|
},
|
|
207165
207146
|
tsconfig: { diagnosticSeverities: inputState.tsconfig.currentDiagnosticSeverities },
|
|
@@ -207331,7 +207312,7 @@ const gatherTargetState = (assessment, context) => gen(function* () {
|
|
|
207331
207312
|
if (lspDependencyType === "no") return {
|
|
207332
207313
|
packageJson: {
|
|
207333
207314
|
lspVersion: none$3(),
|
|
207334
|
-
|
|
207315
|
+
typescriptVersion: assessment.packageJson.typescriptVersion,
|
|
207335
207316
|
prepareScript: false
|
|
207336
207317
|
},
|
|
207337
207318
|
tsconfig: { diagnosticSeverities: none$3() },
|
|
@@ -207378,12 +207359,8 @@ const gatherTargetState = (assessment, context) => gen(function* () {
|
|
|
207378
207359
|
}
|
|
207379
207360
|
]
|
|
207380
207361
|
});
|
|
207381
|
-
const nativeBackendPackage = match$8(assessment.packageJson.nativePreviewVersion, {
|
|
207382
|
-
onNone: () => NATIVE_PREVIEW_PACKAGE_NAME,
|
|
207383
|
-
onSome: (dep) => dep.packageName ?? NATIVE_PREVIEW_PACKAGE_NAME
|
|
207384
|
-
});
|
|
207385
207362
|
const vscodeSettings = editors.includes("vscode") ? some({ settings: {
|
|
207386
|
-
"typescript.native-preview.tsdk": nativeBackendTsdkPath(
|
|
207363
|
+
"typescript.native-preview.tsdk": nativeBackendTsdkPath(TYPESCRIPT_PACKAGE_NAME),
|
|
207387
207364
|
"typescript.experimental.useTsgo": true,
|
|
207388
207365
|
"js/ts.experimental.useTsgo": true
|
|
207389
207366
|
} }) : none$3();
|
|
@@ -207393,9 +207370,10 @@ const gatherTargetState = (assessment, context) => gen(function* () {
|
|
|
207393
207370
|
dependencyType: lspDependencyType,
|
|
207394
207371
|
version: context.defaultLspVersion
|
|
207395
207372
|
}),
|
|
207396
|
-
|
|
207373
|
+
typescriptVersion: orElse(assessment.packageJson.typescriptVersion, () => some({
|
|
207397
207374
|
dependencyType: lspDependencyType,
|
|
207398
|
-
version:
|
|
207375
|
+
version: context.defaultTypescriptVersion,
|
|
207376
|
+
packageName: TYPESCRIPT_PACKAGE_NAME
|
|
207399
207377
|
})),
|
|
207400
207378
|
prepareScript: true
|
|
207401
207379
|
},
|
|
@@ -207405,6 +207383,10 @@ const gatherTargetState = (assessment, context) => gen(function* () {
|
|
|
207405
207383
|
};
|
|
207406
207384
|
});
|
|
207407
207385
|
|
|
207386
|
+
//#endregion
|
|
207387
|
+
//#region upstream.json
|
|
207388
|
+
var tsVersion = "7.1.0-dev.20260708.3";
|
|
207389
|
+
|
|
207408
207390
|
//#endregion
|
|
207409
207391
|
//#region src/setup/index.ts
|
|
207410
207392
|
const setupCommand = make("setup").pipe(withDescription("Setup @effect/tsgo for the given project using an interactive CLI."), withHandler(() => gen(function* () {
|
|
@@ -207412,7 +207394,10 @@ const setupCommand = make("setup").pipe(withDescription("Setup @effect/tsgo for
|
|
|
207412
207394
|
const tsconfigInput = yield* selectTsConfigFile(currentDir);
|
|
207413
207395
|
const assessmentInput = yield* createAssessmentInput(currentDir, tsconfigInput);
|
|
207414
207396
|
const assessmentState = assess(assessmentInput);
|
|
207415
|
-
const targetState = yield* gatherTargetState(assessmentState, {
|
|
207397
|
+
const targetState = yield* gatherTargetState(assessmentState, {
|
|
207398
|
+
defaultLspVersion: version,
|
|
207399
|
+
defaultTypescriptVersion: tsVersion
|
|
207400
|
+
});
|
|
207416
207401
|
const result = computeChanges(assessmentState, targetState);
|
|
207417
207402
|
yield* reviewAndApplyChanges(result, assessmentState, { cancelMessage: "Setup cancelled. No changes were made." });
|
|
207418
207403
|
})));
|
|
@@ -207421,7 +207406,12 @@ const setupCommand = make("setup").pipe(withDescription("Setup @effect/tsgo for
|
|
|
207421
207406
|
//#region src/cli.ts
|
|
207422
207407
|
var NativeBackendNotInstalledError = class extends TaggedError("NativeBackendNotInstalledError") {
|
|
207423
207408
|
get message() {
|
|
207424
|
-
return "No native TypeScript backend is installed. Install
|
|
207409
|
+
return "No native TypeScript backend is installed. Install `typescript` >= 7 first (e.g. `typescript@latest` or `typescript@next`).";
|
|
207410
|
+
}
|
|
207411
|
+
};
|
|
207412
|
+
var MissingTypeScriptMetadataError = class extends TaggedError("MissingTypeScriptMetadataError") {
|
|
207413
|
+
get message() {
|
|
207414
|
+
return `Installed ${this.packageName} package.json does not contain a gitHead. Unable to select a compatible Effect binary.`;
|
|
207425
207415
|
}
|
|
207426
207416
|
};
|
|
207427
207417
|
var UnsupportedPlatformPackageError = class extends TaggedError("UnsupportedPlatformPackageError") {
|
|
@@ -207439,6 +207429,22 @@ var ResolvePackagedBinaryError = class extends TaggedError("ResolvePackagedBinar
|
|
|
207439
207429
|
return this.reason;
|
|
207440
207430
|
}
|
|
207441
207431
|
};
|
|
207432
|
+
var PackagedBinaryVersionMismatchError = class extends TaggedError("PackagedBinaryVersionMismatchError") {
|
|
207433
|
+
get message() {
|
|
207434
|
+
const tried = this.candidates.length === 0 ? " none" : this.candidates.map((candidate) => {
|
|
207435
|
+
if (candidate.tsVersion !== void 0 && candidate.tsGitHead !== void 0) return ` ${candidate.binaryName}: TypeScript ${candidate.tsVersion}, gitHead ${candidate.tsGitHead}`;
|
|
207436
|
+
return ` ${candidate.binaryName}: ${candidate.reason ?? "metadata unavailable"}`;
|
|
207437
|
+
}).join("\n");
|
|
207438
|
+
return [
|
|
207439
|
+
`No packaged Effect TypeScript binary matches installed TypeScript ${this.installedVersion} gitHead ${this.installedGitHead}.`,
|
|
207440
|
+
"",
|
|
207441
|
+
"Tried:",
|
|
207442
|
+
tried,
|
|
207443
|
+
"",
|
|
207444
|
+
"Install a matching @effect/tsgo release or a matching TypeScript version, or rerun with --force to use the newest packaged binary."
|
|
207445
|
+
].join("\n");
|
|
207446
|
+
}
|
|
207447
|
+
};
|
|
207442
207448
|
var BackupRestoreError = class extends TaggedError("BackupRestoreError") {
|
|
207443
207449
|
get message() {
|
|
207444
207450
|
return this.reason;
|
|
@@ -207459,6 +207465,7 @@ var VerificationFailedError = class extends TaggedError("VerificationFailedError
|
|
|
207459
207465
|
return "Warning: verification failed for " + this.targetPath + ", but binary was patched. The binary may still work correctly.";
|
|
207460
207466
|
}
|
|
207461
207467
|
};
|
|
207468
|
+
const packagedTypeScriptBinaryNames = ["tsc", "tsc-next"];
|
|
207462
207469
|
const probeBackend = (backend, cwdRequire, path) => {
|
|
207463
207470
|
const isWin = process.platform === "win32";
|
|
207464
207471
|
let mainPkg;
|
|
@@ -207490,43 +207497,38 @@ const probeBackend = (backend, cwdRequire, path) => {
|
|
|
207490
207497
|
return {
|
|
207491
207498
|
_tag: "resolved",
|
|
207492
207499
|
path: path.join(platformDir, "lib", binaryName),
|
|
207493
|
-
binaryName: backend.binaryName
|
|
207500
|
+
binaryName: backend.binaryName,
|
|
207501
|
+
packageJson: mainPkg
|
|
207494
207502
|
};
|
|
207495
207503
|
};
|
|
207496
207504
|
/**
|
|
207497
|
-
* Resolve the native TypeScript binary to patch. The
|
|
207498
|
-
*
|
|
207499
|
-
* that the TypeScript 7 RC/stable release is supported out of the box.
|
|
207500
|
-
*
|
|
207501
|
-
* Returns the target binary path plus the backend's base binary name (`tsgo` or
|
|
207502
|
-
* `tsc`); the latter selects the matching Effect-patched artifact from
|
|
207503
|
-
* `@effect/tsgo-*` (which ships separate `lib/tsgo` and `lib/tsc` builds).
|
|
207505
|
+
* Resolve the native TypeScript binary to patch. The supported upstream package
|
|
207506
|
+
* is `typescript` >= 7, whose platform package exposes a `tsc` executable.
|
|
207504
207507
|
*/
|
|
207505
207508
|
const getNativeBackendBinaryPath = gen(function* () {
|
|
207506
207509
|
const path = yield* Path;
|
|
207507
|
-
const
|
|
207508
|
-
|
|
207509
|
-
|
|
207510
|
-
|
|
207511
|
-
|
|
207512
|
-
|
|
207513
|
-
|
|
207514
|
-
|
|
207515
|
-
|
|
207516
|
-
|
|
207517
|
-
|
|
207518
|
-
}
|
|
207510
|
+
const typescriptResult = probeBackend(typescriptBackend, node_module.createRequire(path.join(process.cwd(), "noop.js")), path);
|
|
207511
|
+
if (typescriptResult._tag === "resolved") {
|
|
207512
|
+
const installedGitHead = typescriptResult.packageJson.gitHead;
|
|
207513
|
+
if (installedGitHead === void 0) return yield* fail(new MissingTypeScriptMetadataError({ packageName: typescriptBackend.packageName }));
|
|
207514
|
+
return {
|
|
207515
|
+
targetPath: typescriptResult.path,
|
|
207516
|
+
installedTypeScript: {
|
|
207517
|
+
version: typescriptResult.packageJson.version ?? "unknown",
|
|
207518
|
+
gitHead: installedGitHead
|
|
207519
|
+
}
|
|
207520
|
+
};
|
|
207521
|
+
}
|
|
207519
207522
|
if (typescriptResult._tag === "unsupportedPlatform") return yield* fail(new UnsupportedPlatformPackageError({ packageName: typescriptResult.packageName }));
|
|
207520
207523
|
return yield* fail(new NativeBackendNotInstalledError({ details: "no native backend found" }));
|
|
207521
207524
|
});
|
|
207522
207525
|
/**
|
|
207523
207526
|
* Resolve the Effect-patched binary to copy over the native target. The
|
|
207524
|
-
* `@effect/tsgo-*` platform package ships
|
|
207525
|
-
* `
|
|
207526
|
-
*
|
|
207527
|
-
* installed. Defaults to `tsgo` for the `get-exe-path` command.
|
|
207527
|
+
* `@effect/tsgo-*` platform package ships `lib/tsc` (built from
|
|
207528
|
+
* `generated/latest`) and `lib/tsc-next` (built from `main`). The adjacent JSON
|
|
207529
|
+
* metadata files identify the TypeScript gitHead each binary was built from.
|
|
207528
207530
|
*/
|
|
207529
|
-
const getPackagedBinaryPath = (
|
|
207531
|
+
const getPackagedBinaryPath = (installedTypeScript, force) => gen(function* () {
|
|
207530
207532
|
const fs = yield* FileSystem;
|
|
207531
207533
|
const path = yield* Path;
|
|
207532
207534
|
const packageName = "@effect/tsgo-" + process.platform + "-" + process.arch;
|
|
@@ -207536,17 +207538,71 @@ const getPackagedBinaryPath = (binaryName = "tsgo") => gen(function* () {
|
|
|
207536
207538
|
catch: () => new ResolvePackagedBinaryError({ reason: `Unable to resolve ${packageName}. Either your platform is unsupported, or the platform package is not installed.` })
|
|
207537
207539
|
});
|
|
207538
207540
|
const packageDir = path.dirname(packageJsonPath);
|
|
207539
|
-
const
|
|
207540
|
-
const
|
|
207541
|
-
|
|
207542
|
-
|
|
207541
|
+
const candidates = [];
|
|
207542
|
+
for (const binaryName of packagedTypeScriptBinaryNames) {
|
|
207543
|
+
const exeName = binaryName + (process.platform === "win32" ? ".exe" : "");
|
|
207544
|
+
const exePath = path.join(packageDir, "lib", exeName);
|
|
207545
|
+
const metadataPath = exePath + ".json";
|
|
207546
|
+
if (!(yield* fs.exists(exePath))) {
|
|
207547
|
+
candidates.push({
|
|
207548
|
+
binaryName,
|
|
207549
|
+
reason: "binary not packaged"
|
|
207550
|
+
});
|
|
207551
|
+
continue;
|
|
207552
|
+
}
|
|
207553
|
+
if (!(yield* fs.exists(metadataPath))) {
|
|
207554
|
+
candidates.push({
|
|
207555
|
+
binaryName,
|
|
207556
|
+
path: exePath,
|
|
207557
|
+
reason: "metadata not packaged"
|
|
207558
|
+
});
|
|
207559
|
+
continue;
|
|
207560
|
+
}
|
|
207561
|
+
const metadata = yield* fs.readFileString(metadataPath).pipe(flatMap((text) => try_({
|
|
207562
|
+
try: () => {
|
|
207563
|
+
const parsed = JSON.parse(text);
|
|
207564
|
+
if (typeof parsed.tsVersion !== "string" || typeof parsed.tsGitHead !== "string") throw new Error("invalid metadata");
|
|
207565
|
+
return {
|
|
207566
|
+
tsVersion: parsed.tsVersion,
|
|
207567
|
+
tsGitHead: parsed.tsGitHead
|
|
207568
|
+
};
|
|
207569
|
+
},
|
|
207570
|
+
catch: () => new ResolvePackagedBinaryError({ reason: "Invalid binary metadata: " + metadataPath })
|
|
207571
|
+
})));
|
|
207572
|
+
const candidate = {
|
|
207573
|
+
binaryName,
|
|
207574
|
+
path: exePath,
|
|
207575
|
+
metadata,
|
|
207576
|
+
...metadata
|
|
207577
|
+
};
|
|
207578
|
+
if (metadata.tsGitHead === installedTypeScript.gitHead) return exePath;
|
|
207579
|
+
candidates.push(candidate);
|
|
207580
|
+
}
|
|
207581
|
+
if (force) {
|
|
207582
|
+
const fallback = candidates.find((candidate) => candidate.binaryName === "tsc-next" && candidate.path !== void 0) ?? candidates.find((candidate) => candidate.binaryName === "tsc" && candidate.path !== void 0);
|
|
207583
|
+
if (fallback?.path !== void 0) {
|
|
207584
|
+
yield* warn(new PackagedBinaryVersionMismatchError({
|
|
207585
|
+
installedVersion: installedTypeScript.version,
|
|
207586
|
+
installedGitHead: installedTypeScript.gitHead,
|
|
207587
|
+
candidates
|
|
207588
|
+
}).message);
|
|
207589
|
+
yield* warn("Forcing patch with " + fallback.binaryName + ". This may be incompatible.");
|
|
207590
|
+
return fallback.path;
|
|
207591
|
+
}
|
|
207592
|
+
}
|
|
207593
|
+
if (candidates.length === 0) return yield* fail(new ResolvePackagedBinaryError({ reason: "No packaged TypeScript binaries were found in " + path.join(packageDir, "lib") }));
|
|
207594
|
+
return yield* fail(new PackagedBinaryVersionMismatchError({
|
|
207595
|
+
installedVersion: installedTypeScript.version,
|
|
207596
|
+
installedGitHead: installedTypeScript.gitHead,
|
|
207597
|
+
candidates
|
|
207598
|
+
}));
|
|
207543
207599
|
});
|
|
207544
|
-
const patch = gen(function* () {
|
|
207600
|
+
const patch = (force) => gen(function* () {
|
|
207545
207601
|
const fs = yield* FileSystem;
|
|
207546
207602
|
const path = yield* Path;
|
|
207547
|
-
const { targetPath,
|
|
207603
|
+
const { targetPath, installedTypeScript } = yield* getNativeBackendBinaryPath;
|
|
207548
207604
|
const backupPath = path.join(path.dirname(targetPath), path.basename(targetPath) + ".original");
|
|
207549
|
-
const ourBinaryPath = yield* getPackagedBinaryPath(
|
|
207605
|
+
const ourBinaryPath = yield* getPackagedBinaryPath(installedTypeScript, force);
|
|
207550
207606
|
if (!(yield* fs.exists(targetPath))) return yield* fail(new MissingTargetBinaryError({ targetPath }));
|
|
207551
207607
|
let actualBackupPath = backupPath;
|
|
207552
207608
|
let counter = 1;
|
|
@@ -207593,9 +207649,9 @@ const unpatch = gen(function* () {
|
|
|
207593
207649
|
yield* fs.rename(backupPath, targetPath).pipe(mapError(() => new BackupRestoreError({ reason: `Failed to restore backup from ${backupPath} to ${targetPath}.` })));
|
|
207594
207650
|
yield* log("Restored original binary at " + targetPath);
|
|
207595
207651
|
});
|
|
207596
|
-
const patchCommand = make("patch").pipe(withDescription("Patch the Effect Language Service binary"), withHandler(() => patch));
|
|
207652
|
+
const patchCommand = make("patch", { force: boolean("force") }).pipe(withDescription("Patch the Effect Language Service binary"), withHandler(({ force }) => patch(force)));
|
|
207597
207653
|
const unpatchCommand = make("unpatch").pipe(withDescription("Unpatch and restore the original TypeScript-Go binary"), withHandler(() => unpatch));
|
|
207598
|
-
const getExePathCommand = make("get-exe-path").pipe(withDescription("Print the Effect Language Service executable path"), withHandler(() =>
|
|
207654
|
+
const getExePathCommand = make("get-exe-path").pipe(withDescription("Print the Effect Language Service executable path"), withHandler(() => getNativeBackendBinaryPath.pipe(flatMap(({ installedTypeScript }) => getPackagedBinaryPath(installedTypeScript, false)), flatMap((exePath) => log(exePath)))));
|
|
207599
207655
|
make("tsgo").pipe(withSubcommands([
|
|
207600
207656
|
patchCommand,
|
|
207601
207657
|
unpatchCommand,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/tsgo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Effect Language Service for TypeScript-Go — Effect-specific diagnostics and hover features.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"README.md"
|
|
23
23
|
],
|
|
24
24
|
"optionalDependencies": {
|
|
25
|
-
"@effect/tsgo-win32-x64": "0.
|
|
26
|
-
"@effect/tsgo-win32-arm64": "0.
|
|
27
|
-
"@effect/tsgo-linux-x64": "0.
|
|
28
|
-
"@effect/tsgo-linux-arm64": "0.
|
|
29
|
-
"@effect/tsgo-linux-arm": "0.
|
|
30
|
-
"@effect/tsgo-darwin-x64": "0.
|
|
31
|
-
"@effect/tsgo-darwin-arm64": "0.
|
|
25
|
+
"@effect/tsgo-win32-x64": "0.17.0",
|
|
26
|
+
"@effect/tsgo-win32-arm64": "0.17.0",
|
|
27
|
+
"@effect/tsgo-linux-x64": "0.17.0",
|
|
28
|
+
"@effect/tsgo-linux-arm64": "0.17.0",
|
|
29
|
+
"@effect/tsgo-linux-arm": "0.17.0",
|
|
30
|
+
"@effect/tsgo-darwin-x64": "0.17.0",
|
|
31
|
+
"@effect/tsgo-darwin-arm64": "0.17.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@effect/platform-node": "^4.0.0-beta.83",
|