@secure-exec/typescript 0.1.1-rc.3 → 0.2.0-rc.1
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/index.d.ts +2 -1
- package/dist/index.js +27 -5
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { NodeRuntimeDriverFactory
|
|
1
|
+
import type { NodeRuntimeDriverFactory } from "secure-exec";
|
|
2
|
+
import type { SystemDriver } from "@secure-exec/core";
|
|
2
3
|
export interface TypeScriptDiagnostic {
|
|
3
4
|
code: number;
|
|
4
5
|
category: "error" | "warning" | "suggestion" | "message";
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { NodeRuntime } from "secure-exec";
|
|
2
2
|
const DEFAULT_COMPILER_RUNTIME_MEMORY_LIMIT = 512;
|
|
3
3
|
const COMPILER_RUNTIME_FILE_PATH = "/root/__secure_exec_typescript_compiler__.js";
|
|
4
|
+
const DEFAULT_COMPILER_SPECIFIER = "/root/node_modules/typescript/lib/typescript.js";
|
|
4
5
|
export function createTypeScriptTools(options) {
|
|
5
6
|
return {
|
|
6
7
|
typecheckProject: async (requestOptions = {}) => runCompilerRequest(options, {
|
|
7
8
|
kind: "typecheckProject",
|
|
8
|
-
compilerSpecifier: options.compilerSpecifier ??
|
|
9
|
+
compilerSpecifier: options.compilerSpecifier ?? DEFAULT_COMPILER_SPECIFIER,
|
|
9
10
|
options: requestOptions,
|
|
10
11
|
}),
|
|
11
12
|
compileProject: async (requestOptions = {}) => runCompilerRequest(options, {
|
|
12
13
|
kind: "compileProject",
|
|
13
|
-
compilerSpecifier: options.compilerSpecifier ??
|
|
14
|
+
compilerSpecifier: options.compilerSpecifier ?? DEFAULT_COMPILER_SPECIFIER,
|
|
14
15
|
options: requestOptions,
|
|
15
16
|
}),
|
|
16
17
|
typecheckSource: async (requestOptions) => runCompilerRequest(options, {
|
|
17
18
|
kind: "typecheckSource",
|
|
18
|
-
compilerSpecifier: options.compilerSpecifier ??
|
|
19
|
+
compilerSpecifier: options.compilerSpecifier ?? DEFAULT_COMPILER_SPECIFIER,
|
|
19
20
|
options: requestOptions,
|
|
20
21
|
}),
|
|
21
22
|
compileSource: async (requestOptions) => runCompilerRequest(options, {
|
|
22
23
|
kind: "compileSource",
|
|
23
|
-
compilerSpecifier: options.compilerSpecifier ??
|
|
24
|
+
compilerSpecifier: options.compilerSpecifier ?? DEFAULT_COMPILER_SPECIFIER,
|
|
24
25
|
options: requestOptions,
|
|
25
26
|
}),
|
|
26
27
|
};
|
|
@@ -88,7 +89,28 @@ function buildCompilerRuntimeSource(request) {
|
|
|
88
89
|
function compilerRuntimeMain(request) {
|
|
89
90
|
const fs = require("node:fs");
|
|
90
91
|
const path = require("node:path");
|
|
91
|
-
const ts =
|
|
92
|
+
const ts = loadCompiler(request.compilerSpecifier);
|
|
93
|
+
function loadCompiler(compilerSpecifier) {
|
|
94
|
+
const candidates = new Set([compilerSpecifier]);
|
|
95
|
+
if (compilerSpecifier === "typescript") {
|
|
96
|
+
candidates.add("/root/node_modules/typescript/lib/typescript.js");
|
|
97
|
+
}
|
|
98
|
+
if (compilerSpecifier === "/root/node_modules/typescript/lib/typescript.js") {
|
|
99
|
+
candidates.add("typescript");
|
|
100
|
+
}
|
|
101
|
+
let lastError;
|
|
102
|
+
for (const candidate of candidates) {
|
|
103
|
+
try {
|
|
104
|
+
return require(candidate);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
lastError = error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
throw lastError instanceof Error
|
|
111
|
+
? lastError
|
|
112
|
+
: new Error(`Cannot load TypeScript compiler from '${compilerSpecifier}'`);
|
|
113
|
+
}
|
|
92
114
|
function toDiagnostic(diagnostic) {
|
|
93
115
|
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n").trim();
|
|
94
116
|
const result = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secure-exec/typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-rc.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "https://github.com/rivet-dev/secure-exec.git",
|
|
15
|
-
"directory": "packages/
|
|
15
|
+
"directory": "packages/typescript"
|
|
16
16
|
},
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"typescript": "^5.9.3",
|
|
25
|
-
"secure-exec": "0.
|
|
25
|
+
"@secure-exec/core": "0.2.0-rc.1",
|
|
26
|
+
"secure-exec": "0.2.0-rc.1"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@types/node": "^22.10.2",
|