@rigkit/provider-vscode 0.2.0 → 0.2.2
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/extension.cjs +150 -15
- package/package.json +2 -2
- package/src/version.ts +1 -1
package/dist/extension.cjs
CHANGED
|
@@ -30126,6 +30126,7 @@ function runtimeClientSchema(schema2) {
|
|
|
30126
30126
|
}
|
|
30127
30127
|
var RuntimeHandleEffectSchema = exports_Schema.Struct({
|
|
30128
30128
|
projectId: exports_Schema.String,
|
|
30129
|
+
runtimeFingerprint: exports_Schema.optional(exports_Schema.String),
|
|
30129
30130
|
projectDir: exports_Schema.String,
|
|
30130
30131
|
configPath: exports_Schema.String,
|
|
30131
30132
|
statePath: exports_Schema.optional(exports_Schema.String),
|
|
@@ -30145,6 +30146,7 @@ var RuntimeReadyEffectSchema = exports_Schema.Struct({
|
|
|
30145
30146
|
var RuntimeHealthEffectSchema = exports_Schema.Struct({
|
|
30146
30147
|
ok: exports_Schema.Boolean,
|
|
30147
30148
|
projectId: exports_Schema.String,
|
|
30149
|
+
runtimeFingerprint: exports_Schema.optional(exports_Schema.String),
|
|
30148
30150
|
projectDir: exports_Schema.optional(exports_Schema.String),
|
|
30149
30151
|
configPath: exports_Schema.optional(exports_Schema.String),
|
|
30150
30152
|
statePath: exports_Schema.optional(exports_Schema.String),
|
|
@@ -30175,6 +30177,7 @@ var OptionalString = exports_Schema.optional(exports_Schema.String);
|
|
|
30175
30177
|
var RuntimeControlHealthEffectSchema = exports_Schema.Struct({
|
|
30176
30178
|
ok: exports_Schema.Boolean,
|
|
30177
30179
|
projectId: exports_Schema.String,
|
|
30180
|
+
runtimeFingerprint: OptionalString,
|
|
30178
30181
|
projectDir: exports_Schema.String,
|
|
30179
30182
|
configPath: exports_Schema.String,
|
|
30180
30183
|
statePath: OptionalString,
|
|
@@ -30549,12 +30552,18 @@ async function getOrStartRuntimeUnsafe(options7) {
|
|
|
30549
30552
|
statePath,
|
|
30550
30553
|
source: options7.source
|
|
30551
30554
|
});
|
|
30555
|
+
const runtimeFingerprint = runtimeFingerprintFor({
|
|
30556
|
+
projectDir,
|
|
30557
|
+
configPath,
|
|
30558
|
+
statePath,
|
|
30559
|
+
source: options7.source
|
|
30560
|
+
});
|
|
30552
30561
|
const paths = runtimePaths(projectId, options7.rigkitHome);
|
|
30553
|
-
const existing = await tryExistingRuntime(paths, projectId);
|
|
30562
|
+
const existing = await tryExistingRuntime(paths, projectId, runtimeFingerprint);
|
|
30554
30563
|
if (existing)
|
|
30555
30564
|
return existing;
|
|
30556
30565
|
await withRuntimeLock(paths.lockPath, async () => {
|
|
30557
|
-
const secondCheck = await tryExistingRuntime(paths, projectId);
|
|
30566
|
+
const secondCheck = await tryExistingRuntime(paths, projectId, runtimeFingerprint);
|
|
30558
30567
|
if (secondCheck)
|
|
30559
30568
|
return;
|
|
30560
30569
|
await startRuntime({
|
|
@@ -30563,10 +30572,11 @@ async function getOrStartRuntimeUnsafe(options7) {
|
|
|
30563
30572
|
configPath,
|
|
30564
30573
|
statePath,
|
|
30565
30574
|
projectId,
|
|
30575
|
+
runtimeFingerprint,
|
|
30566
30576
|
paths
|
|
30567
30577
|
});
|
|
30568
30578
|
});
|
|
30569
|
-
const started = await tryExistingRuntime(paths, projectId);
|
|
30579
|
+
const started = await tryExistingRuntime(paths, projectId, runtimeFingerprint);
|
|
30570
30580
|
if (!started) {
|
|
30571
30581
|
throw new RuntimeStartupError({
|
|
30572
30582
|
reason: "unhealthy-after-start",
|
|
@@ -30582,12 +30592,33 @@ function projectIdFor(options7) {
|
|
|
30582
30592
|
hash2.update(JSON.stringify({
|
|
30583
30593
|
projectDir: import_node_path.resolve(options7.projectDir),
|
|
30584
30594
|
configPath,
|
|
30585
|
-
configHash: configHashFor(configPath),
|
|
30586
30595
|
statePath: options7.statePath ? import_node_path.resolve(options7.statePath) : null,
|
|
30587
30596
|
source: options7.source ?? null
|
|
30588
30597
|
}));
|
|
30589
30598
|
return `sha256-${hash2.digest("hex").slice(0, 32)}`;
|
|
30590
30599
|
}
|
|
30600
|
+
function runtimeFingerprintFor(options7) {
|
|
30601
|
+
const projectDir = import_node_path.resolve(options7.projectDir);
|
|
30602
|
+
const configPath = import_node_path.resolve(options7.configPath);
|
|
30603
|
+
const statePath = options7.statePath ? import_node_path.resolve(options7.statePath) : null;
|
|
30604
|
+
const hash2 = import_node_crypto.createHash("sha256");
|
|
30605
|
+
hash2.update("project\x00");
|
|
30606
|
+
hash2.update(projectDir);
|
|
30607
|
+
hash2.update("\x00config\x00");
|
|
30608
|
+
hash2.update(configPath);
|
|
30609
|
+
hash2.update("\x00state\x00");
|
|
30610
|
+
hash2.update(statePath ?? "");
|
|
30611
|
+
hash2.update("\x00source\x00");
|
|
30612
|
+
hash2.update(JSON.stringify(options7.source ?? null));
|
|
30613
|
+
updateFileFingerprint(hash2, "config", configPath);
|
|
30614
|
+
for (const file2 of dotenvFilesFor(projectDir))
|
|
30615
|
+
updateFileFingerprint(hash2, "dotenv", file2);
|
|
30616
|
+
for (const file2 of projectFingerprintFiles(projectDir))
|
|
30617
|
+
updateFileFingerprint(hash2, "project-file", file2);
|
|
30618
|
+
updateProjectSurfaceFingerprint(hash2, projectDir);
|
|
30619
|
+
updateRigkitPackageFingerprint(hash2, import_node_path.join(projectDir, "node_modules", "@rigkit"));
|
|
30620
|
+
return `sha256-${hash2.digest("hex")}`;
|
|
30621
|
+
}
|
|
30591
30622
|
function runtimePaths(projectId, rigkitHome = defaultRigkitHome()) {
|
|
30592
30623
|
const root = import_node_path.join(rigkitHome, "runtimes");
|
|
30593
30624
|
return {
|
|
@@ -30600,13 +30631,20 @@ function runtimePaths(projectId, rigkitHome = defaultRigkitHome()) {
|
|
|
30600
30631
|
function defaultRigkitHome() {
|
|
30601
30632
|
return process.env.RIGKIT_HOME ? import_node_path.resolve(process.env.RIGKIT_HOME) : import_node_path.join(import_node_os.homedir(), ".rigkit");
|
|
30602
30633
|
}
|
|
30603
|
-
async function tryExistingRuntime(paths, projectId) {
|
|
30634
|
+
async function tryExistingRuntime(paths, projectId, runtimeFingerprint) {
|
|
30604
30635
|
const handle = readHandle(paths.handlePath);
|
|
30605
30636
|
if (!handle || handle.projectId !== projectId)
|
|
30606
30637
|
return;
|
|
30607
30638
|
const token = readToken(handle.tokenPath);
|
|
30608
|
-
if (!token)
|
|
30639
|
+
if (!token) {
|
|
30640
|
+
removeStale(paths);
|
|
30609
30641
|
return;
|
|
30642
|
+
}
|
|
30643
|
+
if (handle.runtimeFingerprint !== runtimeFingerprint) {
|
|
30644
|
+
await shutdownRuntime(handle, token);
|
|
30645
|
+
removeStale(paths);
|
|
30646
|
+
return;
|
|
30647
|
+
}
|
|
30610
30648
|
try {
|
|
30611
30649
|
const body = await createRuntimeHttpClient({ baseUrl: handle.url, token }).health();
|
|
30612
30650
|
if (body.projectId !== projectId) {
|
|
@@ -30616,6 +30654,13 @@ async function tryExistingRuntime(paths, projectId) {
|
|
|
30616
30654
|
message: `runtime project mismatch`
|
|
30617
30655
|
});
|
|
30618
30656
|
}
|
|
30657
|
+
if (body.runtimeFingerprint !== runtimeFingerprint) {
|
|
30658
|
+
throw new RuntimeConnectionError({
|
|
30659
|
+
method: "GET",
|
|
30660
|
+
path: "/health",
|
|
30661
|
+
message: `runtime fingerprint mismatch`
|
|
30662
|
+
});
|
|
30663
|
+
}
|
|
30619
30664
|
return createClient(handle, paths, token);
|
|
30620
30665
|
} catch (error) {
|
|
30621
30666
|
if (error instanceof RuntimeApiVersionError)
|
|
@@ -30632,6 +30677,8 @@ async function startRuntime(input) {
|
|
|
30632
30677
|
"serve",
|
|
30633
30678
|
"--project-id",
|
|
30634
30679
|
input.projectId,
|
|
30680
|
+
"--runtime-fingerprint",
|
|
30681
|
+
input.runtimeFingerprint,
|
|
30635
30682
|
"--project-dir",
|
|
30636
30683
|
input.projectDir,
|
|
30637
30684
|
"--config",
|
|
@@ -30783,7 +30830,7 @@ function readReadyLine(proc, paths, projectDir) {
|
|
|
30783
30830
|
reason: "startup-timeout",
|
|
30784
30831
|
projectDir,
|
|
30785
30832
|
message: `Timed out waiting for Rigkit runtime to start`
|
|
30786
|
-
}));
|
|
30833
|
+
}), { kill: true });
|
|
30787
30834
|
}, 15000);
|
|
30788
30835
|
const cleanup = () => {
|
|
30789
30836
|
clearTimeout(timer);
|
|
@@ -30800,11 +30847,14 @@ function readReadyLine(proc, paths, projectDir) {
|
|
|
30800
30847
|
cleanup();
|
|
30801
30848
|
resolvePromise(line);
|
|
30802
30849
|
};
|
|
30803
|
-
function fail15(error) {
|
|
30850
|
+
function fail15(error, options7 = {}) {
|
|
30804
30851
|
if (settled)
|
|
30805
30852
|
return;
|
|
30806
30853
|
settled = true;
|
|
30807
30854
|
cleanup();
|
|
30855
|
+
if (options7.kill)
|
|
30856
|
+
killRuntimeProcess(proc);
|
|
30857
|
+
removeStale(paths);
|
|
30808
30858
|
rejectPromise(error);
|
|
30809
30859
|
}
|
|
30810
30860
|
function onData(chunk3) {
|
|
@@ -30839,15 +30889,100 @@ function readReadyLine(proc, paths, projectDir) {
|
|
|
30839
30889
|
proc.once("exit", onExit4);
|
|
30840
30890
|
});
|
|
30841
30891
|
}
|
|
30892
|
+
function killRuntimeProcess(proc) {
|
|
30893
|
+
if (!proc.pid)
|
|
30894
|
+
return;
|
|
30895
|
+
try {
|
|
30896
|
+
proc.kill("SIGTERM");
|
|
30897
|
+
} catch {}
|
|
30898
|
+
}
|
|
30842
30899
|
function removeStale(paths) {
|
|
30843
30900
|
import_node_fs.rmSync(paths.handlePath, { force: true });
|
|
30844
30901
|
}
|
|
30845
|
-
function
|
|
30846
|
-
|
|
30847
|
-
|
|
30848
|
-
|
|
30849
|
-
|
|
30850
|
-
|
|
30902
|
+
async function shutdownRuntime(handle, token) {
|
|
30903
|
+
try {
|
|
30904
|
+
await createRuntimeHttpClient({ baseUrl: handle.url, token }).shutdown();
|
|
30905
|
+
} catch {
|
|
30906
|
+
if (handle.pid !== process.pid) {
|
|
30907
|
+
try {
|
|
30908
|
+
process.kill(handle.pid);
|
|
30909
|
+
} catch {}
|
|
30910
|
+
}
|
|
30911
|
+
}
|
|
30912
|
+
}
|
|
30913
|
+
function updateFileFingerprint(hash2, label, path) {
|
|
30914
|
+
hash2.update(`\x00${label}\x00${path}\x00`);
|
|
30915
|
+
if (!import_node_fs.existsSync(path)) {
|
|
30916
|
+
hash2.update("missing");
|
|
30917
|
+
return;
|
|
30918
|
+
}
|
|
30919
|
+
const stat = import_node_fs.statSync(path);
|
|
30920
|
+
if (!stat.isFile()) {
|
|
30921
|
+
hash2.update(`not-file:${stat.mode}`);
|
|
30922
|
+
return;
|
|
30923
|
+
}
|
|
30924
|
+
hash2.update(import_node_fs.readFileSync(path));
|
|
30925
|
+
}
|
|
30926
|
+
function projectFingerprintFiles(projectDir) {
|
|
30927
|
+
return [
|
|
30928
|
+
"package.json",
|
|
30929
|
+
"bun.lock",
|
|
30930
|
+
"bun.lockb",
|
|
30931
|
+
"pnpm-lock.yaml",
|
|
30932
|
+
"package-lock.json",
|
|
30933
|
+
"yarn.lock"
|
|
30934
|
+
].map((file2) => import_node_path.join(projectDir, file2));
|
|
30935
|
+
}
|
|
30936
|
+
function updateProjectSurfaceFingerprint(hash2, projectDir) {
|
|
30937
|
+
if (!import_node_fs.existsSync(projectDir))
|
|
30938
|
+
return;
|
|
30939
|
+
const ignored = new Set([".git", ".rigkit", "node_modules", "dist", "build", ".next", ".astro"]);
|
|
30940
|
+
const entries2 = import_node_fs.readdirSync(projectDir, { withFileTypes: true }).filter((entry) => !ignored.has(entry.name)).map((entry) => `${entry.name}:${entry.isDirectory() ? "dir" : entry.isFile() ? "file" : "other"}`).sort();
|
|
30941
|
+
hash2.update("\x00project-surface\x00");
|
|
30942
|
+
hash2.update(entries2.join(`
|
|
30943
|
+
`));
|
|
30944
|
+
}
|
|
30945
|
+
function updateRigkitPackageFingerprint(hash2, scopeDir) {
|
|
30946
|
+
if (!import_node_fs.existsSync(scopeDir))
|
|
30947
|
+
return;
|
|
30948
|
+
const packageDirs = import_node_fs.readdirSync(scopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => import_node_path.join(scopeDir, entry.name)).sort();
|
|
30949
|
+
for (const packageDir of packageDirs) {
|
|
30950
|
+
updateFileFingerprint(hash2, "rigkit-package", import_node_path.join(packageDir, "package.json"));
|
|
30951
|
+
for (const file2 of collectFiles(import_node_path.join(packageDir, "src"))) {
|
|
30952
|
+
updateFileFingerprint(hash2, "rigkit-source", file2);
|
|
30953
|
+
}
|
|
30954
|
+
}
|
|
30955
|
+
}
|
|
30956
|
+
function collectFiles(root) {
|
|
30957
|
+
if (!import_node_fs.existsSync(root))
|
|
30958
|
+
return [];
|
|
30959
|
+
const out = [];
|
|
30960
|
+
const visit = (dir) => {
|
|
30961
|
+
for (const entry of import_node_fs.readdirSync(dir, { withFileTypes: true })) {
|
|
30962
|
+
const path = import_node_path.join(dir, entry.name);
|
|
30963
|
+
if (entry.isDirectory()) {
|
|
30964
|
+
visit(path);
|
|
30965
|
+
} else if (entry.isFile()) {
|
|
30966
|
+
out.push(path);
|
|
30967
|
+
}
|
|
30968
|
+
}
|
|
30969
|
+
};
|
|
30970
|
+
visit(root);
|
|
30971
|
+
return out.sort();
|
|
30972
|
+
}
|
|
30973
|
+
function dotenvFilesFor(projectDir) {
|
|
30974
|
+
const files = [];
|
|
30975
|
+
let current = projectDir;
|
|
30976
|
+
while (true) {
|
|
30977
|
+
const candidate = import_node_path.join(current, ".env");
|
|
30978
|
+
if (import_node_fs.existsSync(candidate))
|
|
30979
|
+
files.unshift(candidate);
|
|
30980
|
+
const parent = import_node_path.dirname(current);
|
|
30981
|
+
if (parent === current)
|
|
30982
|
+
break;
|
|
30983
|
+
current = parent;
|
|
30984
|
+
}
|
|
30985
|
+
return files;
|
|
30851
30986
|
}
|
|
30852
30987
|
function isFileExistsError(error) {
|
|
30853
30988
|
return Boolean(error && typeof error === "object" && error.code === "EEXIST");
|
|
@@ -30973,7 +31108,7 @@ function findConfigUp(startDir, fileExists = import_node_fs2.existsSync) {
|
|
|
30973
31108
|
}
|
|
30974
31109
|
|
|
30975
31110
|
// src/version.ts
|
|
30976
|
-
var RIGKIT_PROVIDER_VSCODE_VERSION = "0.2.
|
|
31111
|
+
var RIGKIT_PROVIDER_VSCODE_VERSION = "0.2.2";
|
|
30977
31112
|
|
|
30978
31113
|
// src/extension.ts
|
|
30979
31114
|
var VSCODE_HOST_METHODS = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rigkit/provider-vscode",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"README.md"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@rigkit/runtime-client": "0.2.
|
|
60
|
+
"@rigkit/runtime-client": "0.2.2"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/bun": "latest",
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const RIGKIT_PROVIDER_VSCODE_VERSION = "0.2.
|
|
1
|
+
export const RIGKIT_PROVIDER_VSCODE_VERSION = "0.2.2";
|