Skip to content

Commit

Permalink
Fix Compiling latest VS Code Version 1.91 fails & other improvements (#…
Browse files Browse the repository at this point in the history
…38)

* enhanced build (from zorse)

* bump up vscode-version to 1.81.1

* fix workbench compile errors (from zorse)

* fetch product.json relative (so demo can be hosted in nested path)

* fix build node version

* bump up node and action version in publish

* no patching

* implemented feedback
  • Loading branch information
thorsten-wolf-neptune authored Jul 15, 2024
1 parent 97ee15a commit 1c80e8e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Setup Build Environment
run: |
Expand Down
66 changes: 56 additions & 10 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,79 @@ const process = require("process");
const child_process = require("child_process");
const fs = require("fs");
const fse = require("fs-extra");
const { version } = require("./package.json");

const vscodeVersion = "1.84.2";
const vscodeVersion = version.split("-")[0];

function error(msg) {
console.info("\x1b[31merror %s\x1b[0m", msg)
}
function ok(msg) {
console.info("\x1b[32m%s\x1b[0m", msg)
}
function note(msg) {
console.info("\x1b[90m%s\x1b[0m", msg)
}
function exec(cmd, opts) {
console.info("\x1b[36m%s\x1b[0m", cmd)
return child_process.execSync(cmd, opts);
}

const requiredTools = ["node", "yarn", "git", "python"];
note(`required tools ${JSON.stringify(requiredTools)}`)
for (const tool of requiredTools) {
try {
child_process.execSync(`${tool} --version`, { stdio: "ignore" });
} catch (e) {
error(`"${tool}" is not available.`);
process.exit(1);
}
}
ok("required tools installed")

const node_version_out = child_process.execSync(`node -v`);
const node_version = node_version_out.toString().trim()
if (node_version < "v20.0") {
error(`Want node > 20. Got "${node_version}"`);
process.exit(1);
}

if (!fs.existsSync("vscode")) {
child_process.execSync(`git clone --depth 1 https://github.com/microsoft/vscode.git -b ${vscodeVersion}`, {
note("cloning vscode")
exec(`git clone --depth 1 https://github.com/microsoft/vscode.git -b ${vscodeVersion}`, {
stdio: "inherit",
});
} else {
ok("vscode already installed")
note("delete vscode folder to clone again")
}

note("changing directory to vscode")
process.chdir("vscode");

if (!fs.existsSync("node_modules")) {
child_process.execSync("yarn", { stdio: "inherit" });
exec("yarn", { stdio: "inherit" });
} else {
ok("node_modules exists. Skipping yarn")
}

// Use simple workbench
fs.copyFileSync(
"../workbench.ts",
"src/vs/code/browser/workbench/workbench.ts"
);
note("copying workbench file")
fs.copyFileSync("../workbench.ts", "src/vs/code/browser/workbench/workbench.ts");

// Compile
child_process.execSync("yarn gulp vscode-web-min", { stdio: "inherit" });
note("starting compile")
exec("yarn gulp vscode-web-min", { stdio: "inherit" });
ok("compile completed")

// Extract compiled files
if (fs.existsSync("../dist")) {
note("cleaning ../dist")
fs.rmdirSync("../dist", { recursive: true });
} else {
ok("../dist did not exist. No need to clean")
}

fs.mkdirSync("../dist");
fse.copySync("../vscode-web", "../dist");


ok("copied ../vscode-web to ../dist")
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-web",
"version": "1.84.2",
"version": "1.91.1",
"description": "Visual Studio Code for browser",
"files": ["dist"],
"scripts": {
Expand Down
7 changes: 3 additions & 4 deletions workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import {
create
} from "vs/workbench/workbench.web.main";
import { URI, UriComponents } from "vs/base/common/uri";
import { IWorkbenchConstructionOptions } from "vs/workbench/browser/web.api";
import { IWorkspace, IWorkspaceProvider } from "vs/workbench/services/host/browser/browserHostService";
import { IWorkbenchConstructionOptions, IWorkspace, IWorkspaceProvider } from "vs/workbench/browser/web.api";
declare const window: any;

(async function () {
Expand All @@ -17,7 +16,7 @@ declare const window: any;
if (window.product) {
config = window.product;
} else {
const result = await fetch("/product.json");
const result = await fetch("product.json");
config = await result.json();
}

Expand Down Expand Up @@ -55,4 +54,4 @@ declare const window: any;
|| document.body;

create(domElement, config);
})();
})();

0 comments on commit 1c80e8e

Please sign in to comment.