Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Build as single executable application #618

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions build/single-executable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

"use strict";

const fs = require("fs");
const cp = require("child_process");

/**
* Create a single executable file for the devcontainer CLI.
* https://nodejs.org/api/single-executable-applications.html
*/

process.chdir("dist/spec-node");

const name = "devcontainer";
const binary = `${name}${process.platform === "win32" ? ".exe" : ""}`;

fs.copyFileSync(process.execPath, binary);

const config = {
main: "devContainersSpecCLI.js",
output: `prepared.blob`,
};

fs.writeFileSync("config.json", JSON.stringify(config));

cp.spawnSync(process.execPath, ["--experimental-sea-config", "config.json"], {
stdio: "inherit",
});

cp.spawnSync(
"npx",
[
"--yes",
"postject",
binary,
"NODE_SEA_BLOB",
config.output,
"--sentinel-fuse",
"NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2",
...(process.platform === "darwin"
? ["--macho-segment-name", "NODE_SEA"]
: []),
],
{ stdio: "inherit" }
);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"definitions-clean": "rimraf dist/node_modules/vscode-dev-containers",
"definitions-copy": "copyfiles \"node_modules/vscode-dev-containers/container-features/{devcontainer-features.json,feature-scripts.env,fish-debian.sh,homebrew-debian.sh,install.sh}\" dist",
"npm-pack": "npm pack",
"build-executable": "node build/single-executable.js",
"clean": "npm-run-all clean-dist clean-built",
"clean-dist": "rimraf dist",
"clean-built": "rimraf built",
Expand Down