Skip to content

Commit 367fe0b

Browse files
feat(runtime): mark code-server as optional component
Mark code-server as optional component (required: false) to align with omniroute. This allows code-server to be excluded from default bundled runtime installs and only installed when explicitly requested. Changes: - Add required: false to code-server component in manifest - Update integration tests to verify code-server is not installed by default - Update unit tests to verify code-server optional behavior - Update optional install test to include code-server Co-Authored-By: Hagicode <noreply@hagicode.com> Signed-off-by: newbe36524 <newbe36524@qq.com>
1 parent f955a3d commit 367fe0b

3 files changed

Lines changed: 20 additions & 30 deletions

File tree

runtime/manifest.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ components:
5050

5151
- name: "code-server"
5252
type: "bundled-runtime"
53+
required: false
5354
source: "desktop-vendored-runtime"
5455
version: "4.117.0"
5556
bundledInstallMode: "archive-7z-only"

scripts/integration-runtime-key-path.mjs

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -253,32 +253,14 @@ try {
253253
".hagicode-runtime.json"
254254
);
255255

256-
assertFile(codeServerArchive);
256+
assertMissingPath(codeServerArchive);
257257
assertMissingPath(omnirouteArchive);
258258
assertMissingPath(omnirouteBin);
259259
assertMissingPath(codeServerBin);
260260
assertMissingPath(omnirouteCurrentRoot);
261261
assertMissingPath(codeServerCurrentRoot);
262262
assertMissingPath(omnirouteMarkerPath);
263-
264-
const codeServerMarker = JSON.parse(
265-
fs.readFileSync(codeServerMarkerPath, "utf8")
266-
);
267-
assertEqual(
268-
codeServerMarker.bundledInstallMode,
269-
"archive-7z-only",
270-
"code-server archive-only marker mode"
271-
);
272-
assertEqual(
273-
codeServerMarker.archivePath,
274-
codeServerArchive,
275-
"code-server archive marker path"
276-
);
277-
assertEqual(
278-
codeServerMarker.wrapperPath,
279-
null,
280-
"code-server archive-only wrapper marker"
281-
);
263+
assertMissingPath(codeServerMarkerPath);
282264

283265
runtimeInstallLines.push(
284266
`- Managed root: ${managedRoot}`,
@@ -287,9 +269,8 @@ try {
287269
`- Managed npm prefix reserved path: ${path.join(managedRoot, "program", "npm")}`,
288270
`- Installed components: ${componentNames.join(", ")}`,
289271
`- Omniroute optional archive not installed by default: ${omnirouteArchive}`,
290-
`- Code-server archive: ${codeServerArchive}`,
291-
`- Code-server vendored asset: ${codeServerMarker.vendoredAssetName}`,
292-
"- Verified default bundled runtime install keeps required code-server as archive-7z-only and leaves optional omniroute uninstalled"
272+
`- Code-server optional archive not installed by default: ${codeServerArchive}`,
273+
"- Verified default bundled runtime install leaves optional omniroute and code-server uninstalled"
293274
);
294275
});
295276

@@ -341,14 +322,14 @@ try {
341322
"--runtime-root",
342323
managedRoot,
343324
"--components",
344-
"omniroute"
325+
"omniroute,code-server"
345326
],
346327
repoRoot
347328
);
348329
assertIncludes(
349330
optionalInstallOutput,
350331
"Runtime install complete.",
351-
"optional omniroute archive install output"
332+
"optional bundled runtime archive install output"
352333
);
353334

354335
await prepareBundledServiceConfigs(managedRoot);

src/__tests__/runtime-manager.test.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ components:
135135
)
136136
expect(manifest.componentMap.get("omniroute")?.required).toBe(false)
137137
expect(manifest.componentMap.get("omniroute")?.bundledInstallMode).toBe("archive-7z-only")
138+
expect(manifest.componentMap.get("code-server")?.required).toBe(false)
138139
expect(manifest.componentMap.get("code-server")?.bundledInstallMode).toBe("archive-7z-only")
139140
})
140141

@@ -149,10 +150,10 @@ components:
149150
expect(plan.plan.map((item) => item.componentName)).toEqual([
150151
"node",
151152
"dotnet",
152-
"server",
153-
"code-server"
153+
"server"
154154
])
155155
expect(plan.plan.map((item) => item.componentName)).not.toContain("omniroute")
156+
expect(plan.plan.map((item) => item.componentName)).not.toContain("code-server")
156157
})
157158

158159
it("includes optional components when explicitly requested", async () => {
@@ -161,11 +162,15 @@ components:
161162
})
162163
const state = createInitialRuntimeState(manifest, resolveRuntimePaths(manifest))
163164

164-
const plan = planRuntimeLifecycle("install", manifest, state, {
165+
const omniRoutePlan = planRuntimeLifecycle("install", manifest, state, {
165166
components: ["omniroute"]
166167
})
168+
const codeServerPlan = planRuntimeLifecycle("install", manifest, state, {
169+
components: ["code-server"]
170+
})
167171

168-
expect(plan.plan.map((item) => item.componentName)).toEqual(["node", "omniroute"])
172+
expect(omniRoutePlan.plan.map((item) => item.componentName)).toEqual(["node", "omniroute"])
173+
expect(codeServerPlan.plan.map((item) => item.componentName)).toEqual(["node", "code-server"])
169174
})
170175

171176
it("rejects bundledInstallMode on non-bundled runtime components", async () => {
@@ -490,7 +495,7 @@ components:
490495
const state = createInitialRuntimeState(manifest, paths)
491496
const now = new Date().toISOString()
492497

493-
for (const componentName of ["node", "dotnet", "server", "code-server"] as const) {
498+
for (const componentName of ["node", "dotnet", "server"] as const) {
494499
const component = manifest.componentMap.get(componentName)
495500
if (!component) {
496501
throw new Error(`Missing fixture component ${componentName}`)
@@ -518,10 +523,13 @@ components:
518523

519524
const report = await queryRuntimeState({ runtimeRoot })
520525
const omniroute = report.components.find((component) => component.name === "omniroute")
526+
const codeServer = report.components.find((component) => component.name === "code-server")
521527

522528
expect(report.ready).toBe(true)
523529
expect(omniroute?.required).toBe(false)
524530
expect(omniroute?.status).toBe("not-installed")
531+
expect(codeServer?.required).toBe(false)
532+
expect(codeServer?.status).toBe("not-installed")
525533
} finally {
526534
await rm(runtimeRoot, { recursive: true, force: true })
527535
}

0 commit comments

Comments
 (0)