Skip to content

Commit e9c7377

Browse files
sjfdcbartlett
authored andcommitted
Update build scripts to include extension files in the standalone zip. (RooCodeInc#4122)
Update the standalone vscontext with the extension directory.
1 parent 28bc432 commit e9c7377

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

scripts/package-standalone.mjs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ if (nativeModules.length > 0) {
3636
// Zip the build directory (excluding any pre-existing output zip).
3737
const zipPath = path.join(BUILD_DIR, "standalone.zip")
3838
const output = fs.createWriteStream(zipPath)
39-
const archive = archiver("zip", { zlib: { level: 9 } })
39+
const archive = archiver("zip", { zlib: { level: 3 } })
4040

4141
output.on("close", () => {
4242
console.log(`Created ${zipPath} (${(archive.pointer() / 1024 / 1024).toFixed(1)} MB)`)
4343
})
44-
44+
archive.on("warning", (err) => {
45+
console.warn(`Warning: ${err}`)
46+
})
4547
archive.on("error", (err) => {
4648
throw err
4749
})
@@ -51,4 +53,20 @@ archive.glob("**/*", {
5153
cwd: BUILD_DIR,
5254
ignore: ["standalone.zip"],
5355
})
56+
57+
// Add the whole cline directory under "extension"
58+
archive.directory(process.cwd(), "extension", (entry) => {
59+
// Skip certain directories
60+
if (
61+
entry.name.startsWith(BUILD_DIR + "/") ||
62+
entry.name.startsWith("node_modules/") || // node_modules nearly 1GB.
63+
entry.name.startsWith("webview-ui/node_modules/") || // node_modules nearly 1GB.
64+
entry.name.match(/(^|\/)\./) // exclude dot directories
65+
) {
66+
return false
67+
}
68+
return entry
69+
})
70+
71+
console.log("Zipping package...")
5472
await archive.finalize()

src/standalone/vscode-context.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import { URI } from "vscode-uri"
22

3-
import path from "path"
4-
import { mkdirSync } from "fs"
3+
import { mkdirSync, readFileSync } from "fs"
4+
import path, { join } from "path"
55
import type { Extension, ExtensionContext } from "vscode"
66
import { ExtensionKind, ExtensionMode } from "vscode"
7+
import { log } from "./utils"
78
import { outputChannel, postMessage } from "./vscode-context-stubs"
89
import { EnvironmentVariableCollection, MementoStore, readJson, SecretStore } from "./vscode-context-utils"
9-
import { log } from "./utils"
1010

1111
if (!process.env.CLINE_DIR) {
1212
console.warn("Environment variable CLINE_DIR was not set.")
1313
process.exit(1)
1414
}
15+
16+
const VERSION = getPackageVersion()
17+
log("Running standalone cline ", VERSION)
18+
1519
const DATA_DIR = path.join(process.env.CLINE_DIR, "data")
1620
mkdirSync(DATA_DIR, { recursive: true })
1721
log("Using settings dir:", DATA_DIR)
1822

19-
const EXTENSION_DIR = path.join(process.env.CLINE_DIR, "core")
23+
const EXTENSION_DIR = path.join(process.env.CLINE_DIR, "core", VERSION, "extension")
2024
const EXTENSION_MODE = process.env.IS_DEV === "true" ? ExtensionMode.Development : ExtensionMode.Production
2125

2226
const extension: Extension<void> = {
@@ -59,6 +63,11 @@ const extensionContext: ExtensionContext = {
5963
workspaceState: new MementoStore(path.join(DATA_DIR, "workspaceState.json")),
6064
}
6165

66+
function getPackageVersion(): string {
67+
const packageJson = JSON.parse(readFileSync(join(__dirname, "package.json"), "utf8"))
68+
return packageJson.version
69+
}
70+
6271
console.log("Finished loading vscode context...")
6372

6473
export { extensionContext, outputChannel, postMessage }

standalone/runtime-files/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cline-standalone",
3-
"version": "1.0.0",
3+
"version": "0.0.1",
44
"main": "standalone.js",
55
"dependencies": {
66
"@grpc/grpc-js": "^1.13.3",

0 commit comments

Comments
 (0)