Skip to content

Commit fd95af1

Browse files
committed
fix code-server
1 parent c613d99 commit fd95af1

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

.woodpecker/snapshot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ steps:
2020
tags_file: .tags
2121
force_tag: true
2222
pull_image: true
23+
build_args:
24+
VSIX_VERSION: snapshot
2325
platforms:
2426
- linux/amd64
2527
- linux/arm64

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
FROM node:20-alpine as extension
1+
FROM node:20-alpine AS extension
2+
3+
ARG VSIX_VERSION=""
24

35
COPY . /src/
4-
RUN cd /src && npm run install:all && npm test && npm run package:web
6+
RUN cd /src && npm run install:all && npm test && VSIX_VERSION=${VSIX_VERSION} npm run package:web
57

68

7-
FROM ghcr.io/ldproxy/xtracfg:4.3.5 as xtracfg
9+
FROM ghcr.io/ldproxy/xtracfg:4.3.5 AS xtracfg
810

911

1012
FROM codercom/code-server:4.107.1

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"prepackage:web": "VITE_DEV=false npm run build:ui && npm run build:web && node vsix.mjs web",
6767
"package:web": "cd dist/web && vsce package -o ../vsix -t web --pre-release",
6868
"publish": "vsce publish --packagePath dist/vsix/ldproxy-editor-*.vsix",
69+
"docker": "docker build -t editor:local-dev --no-cache --progress plain --build-arg VSIX_VERSION=snapshot .",
6970
"test": "jest",
7071
"lint": "eslint ./ --ext ts"
7172
},

vsix.mjs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,40 @@ const target = process.argv[2];
66
const platform = process.argv[3];
77

88
if (!target) {
9-
throw new Error("Missing target");
9+
throw new Error("Missing target");
1010
}
1111

12-
const {browser,main,scripts,dependencies,devDependencies,...rest} = pkg;
12+
const { browser, main, scripts, dependencies, devDependencies, version, ...rest } = pkg;
1313

1414
const vsixPkg = {
15-
...rest,
16-
[target === "web" ? "browser" : "main"]: "./extension.js",
15+
...rest,
16+
version:
17+
process.env.VSIX_VERSION === "snapshot"
18+
? version +
19+
"-snapshot." +
20+
new Date()
21+
.toISOString()
22+
.substring(0, 19)
23+
.replace("T", "")
24+
.replaceAll("-", "")
25+
.replaceAll(":", "")
26+
: version,
27+
[target === "web" ? "browser" : "main"]: "./extension.js",
1728
};
1829

19-
2030
mkdirSync("dist/vsix", { recursive: true });
2131
mkdirSync(`dist/${target}`, { recursive: true });
2232

2333
writeFileSync(`dist/${target}/package.json`, JSON.stringify(vsixPkg, null, 2));
2434

2535
if (target === "native") {
26-
writeFileSync(`dist/${target}/.vscodeignore`, `
36+
writeFileSync(
37+
`dist/${target}/.vscodeignore`,
38+
`
2739
prebuilds/**
2840
!prebuilds/${platform}
29-
`);
41+
`
42+
);
3043
}
3144

3245
copySync("LICENSE", `dist/${target}/LICENSE`);

web/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export function deactivate() {
1616
// for some reason, the location is not set in the web worker as it should be (see https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation)
1717
// so we need to retrieve it manually so that the xtracfg websocket client can connect to the correct location
1818
const getLocation = () => {
19+
// set from environment variable BASE_URL
1920
const baseUrl = workspace.getConfiguration("ldproxy-editor").get<string>("baseUrl");
20-
console.log("BASE URL", baseUrl);
2121

2222
if (baseUrl) {
2323
const url = new URL(baseUrl);
@@ -30,8 +30,8 @@ const getLocation = () => {
3030
return location;
3131
}
3232

33+
// default from VSCode file root, ignore pathname (use BASE_URL if needed)
3334
const vscodeFileRoot = (self as any)._VSCODE_FILE_ROOT;
34-
console.log("VSCODE FILE ROOT", vscodeFileRoot);
3535

3636
if (vscodeFileRoot) {
3737
const url = new URL(vscodeFileRoot);
@@ -44,6 +44,7 @@ const getLocation = () => {
4444
return location;
4545
}
4646

47+
// fallback to self location
4748
return self.location;
4849
};
4950

@@ -53,7 +54,6 @@ const getUrl = () => {
5354
}
5455

5556
const location = getLocation();
56-
console.log("LOCATION", location);
5757
const protocol = location.protocol === "https:" ? "wss" : "ws";
5858
const path = location.pathname.endsWith("/")
5959
? location.pathname.substring(0, location.pathname.length - 1)

0 commit comments

Comments
 (0)