@kvell007/embed-labs-cli 0.1.0-alpha.77 → 0.1.0-alpha.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +80 -13
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { homedir, tmpdir } from "node:os";
|
|
|
8
8
|
import { basename, delimiter, dirname, join, resolve } from "node:path";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
import { composeBootLogoPackage } from "./image-compose.js";
|
|
11
|
-
import { buildTaishanPiQtSmoke, compileTaishanPiSingleFile, currentLocalToolchain, installLocalToolchain, latestLocalToolchain, validateLocalToolchain } from "./local-toolchain.js";
|
|
11
|
+
import { buildTaishanPiQtSmoke, compileTaishanPiSingleFile, currentLocalToolchain, installLocalToolchain, latestLocalToolchain, uninstallLocalToolchain, validateLocalToolchain } from "./local-toolchain.js";
|
|
12
12
|
import { fail, ok } from "@embed-labs/protocol";
|
|
13
13
|
const require = createRequire(import.meta.url);
|
|
14
14
|
const CLI_MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
@@ -82,7 +82,8 @@ const BUILD_IMAGE_DTB_USAGE = "Usage: embed build image dtb --dtb <local.dtb|loc
|
|
|
82
82
|
const IMAGE_DTB_COMPOSE_USAGE = "Usage: embed image dtb compose --package <dtb-package.json> --base-image <boot.img|image.img> --output <image> [--manifest <manifest.json>] [--force] [--json]";
|
|
83
83
|
const LOCAL_TOOLCHAIN_LATEST_USAGE = "Usage: embed local toolchain latest [--board taishanpi-1m-rk3566] [--channel stable] [--metadata-root <path>] [--json]";
|
|
84
84
|
const LOCAL_TOOLCHAIN_CURRENT_USAGE = "Usage: embed local toolchain current [--install-root <path>] [--json]";
|
|
85
|
-
const LOCAL_TOOLCHAIN_INSTALL_USAGE = "Usage: embed local toolchain install [--board taishanpi-1m-rk3566] [--channel stable] [--metadata-root <path>] [--source-url <tar.gz-url>|--source-release-root <path>] [--install-root <path>] [--force] [--json]\nDefault source: the production download channel at download.embedboard.com.";
|
|
85
|
+
const LOCAL_TOOLCHAIN_INSTALL_USAGE = "Usage: embed local toolchain install [--board taishanpi-1m-rk3566] [--channel stable] [--mode minimal|runtime|compile|qt|firmware|full|images] [--metadata-root <path>] [--source-url <tar.gz-url>|--source-release-root <path>] [--install-root <path>] [--force] [--json]\nDefault source: the production download channel at download.embedboard.com.";
|
|
86
|
+
const LOCAL_TOOLCHAIN_UNINSTALL_USAGE = "Usage: embed local toolchain uninstall --board <board_id> [--install-root <path>] [--yes] [--json]";
|
|
86
87
|
const LOCAL_TOOLCHAIN_VALIDATE_USAGE = "Usage: embed local toolchain validate [--release-root <path>] [--json]";
|
|
87
88
|
const LOCAL_COMPILE_TAISHANPI_USAGE = "Usage: embed local compile taishanpi --source <main.c|main.cpp> --output <artifact> [--release-root <path>] [--account <account_id>] [--json]";
|
|
88
89
|
const LOCAL_BUILD_QT_SMOKE_USAGE = "Usage: embed local build qt-smoke --build-dir <dir> [--source <qt-smoke-dir>] [--release-root <path>] [--account <account_id>] [--json]";
|
|
@@ -535,6 +536,13 @@ async function main(argv) {
|
|
|
535
536
|
}
|
|
536
537
|
return output(parsed, ok(await installLocalToolchain(request)), renderLocalToolchainInstall);
|
|
537
538
|
}
|
|
539
|
+
if (action === "toolchain" && parsed.command[2] === "uninstall") {
|
|
540
|
+
const request = localToolchainUninstallRequest(parsed);
|
|
541
|
+
if (typeof request === "string") {
|
|
542
|
+
return output(parsed, fail("invalid_args", request), undefined, 2);
|
|
543
|
+
}
|
|
544
|
+
return output(parsed, ok(await uninstallLocalToolchain(request)), renderLocalToolchainUninstall);
|
|
545
|
+
}
|
|
538
546
|
if (action === "toolchain" && parsed.command[2] === "validate") {
|
|
539
547
|
const request = localToolchainValidateRequest(parsed);
|
|
540
548
|
if (typeof request === "string") {
|
|
@@ -560,6 +568,7 @@ async function main(argv) {
|
|
|
560
568
|
LOCAL_TOOLCHAIN_LATEST_USAGE,
|
|
561
569
|
LOCAL_TOOLCHAIN_CURRENT_USAGE,
|
|
562
570
|
LOCAL_TOOLCHAIN_INSTALL_USAGE,
|
|
571
|
+
LOCAL_TOOLCHAIN_UNINSTALL_USAGE,
|
|
563
572
|
LOCAL_TOOLCHAIN_VALIDATE_USAGE,
|
|
564
573
|
LOCAL_COMPILE_TAISHANPI_USAGE,
|
|
565
574
|
LOCAL_BUILD_QT_SMOKE_USAGE
|
|
@@ -2083,19 +2092,27 @@ async function pathExists(pathValue) {
|
|
|
2083
2092
|
}
|
|
2084
2093
|
async function runLocalProcess(command, args) {
|
|
2085
2094
|
return await new Promise((resolveProcess) => {
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2095
|
+
let child;
|
|
2096
|
+
try {
|
|
2097
|
+
child = spawn(command, args, {
|
|
2098
|
+
cwd: process.cwd(),
|
|
2099
|
+
env: process.env,
|
|
2100
|
+
shell: process.platform === "win32",
|
|
2101
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
2102
|
+
});
|
|
2103
|
+
}
|
|
2104
|
+
catch (error) {
|
|
2105
|
+
resolveProcess({ code: 127, stdout: "", stderr: error instanceof Error ? error.message : String(error) });
|
|
2106
|
+
return;
|
|
2107
|
+
}
|
|
2091
2108
|
let stdout = "";
|
|
2092
2109
|
let stderr = "";
|
|
2093
|
-
child.stdout
|
|
2094
|
-
child.stderr
|
|
2095
|
-
child.stdout
|
|
2110
|
+
child.stdout?.setEncoding("utf8");
|
|
2111
|
+
child.stderr?.setEncoding("utf8");
|
|
2112
|
+
child.stdout?.on("data", (chunk) => {
|
|
2096
2113
|
stdout += chunk;
|
|
2097
2114
|
});
|
|
2098
|
-
child.stderr
|
|
2115
|
+
child.stderr?.on("data", (chunk) => {
|
|
2099
2116
|
stderr += chunk;
|
|
2100
2117
|
});
|
|
2101
2118
|
child.on("error", (error) => {
|
|
@@ -4143,7 +4160,7 @@ function localToolchainCurrentRequest(parsed) {
|
|
|
4143
4160
|
return { installRoot: installRoot.value };
|
|
4144
4161
|
}
|
|
4145
4162
|
function localToolchainInstallRequest(parsed) {
|
|
4146
|
-
const unknownFlag = firstUnknownFlag(parsed, ["json", "board", "board-id", "channel", "metadata-root", "source-url", "source-release-root", "install-root", "force"]);
|
|
4163
|
+
const unknownFlag = firstUnknownFlag(parsed, ["json", "board", "board-id", "channel", "mode", "metadata-root", "source-url", "source-release-root", "install-root", "force"]);
|
|
4147
4164
|
if (unknownFlag) {
|
|
4148
4165
|
return `Unknown flag --${unknownFlag}. ${LOCAL_TOOLCHAIN_INSTALL_USAGE}`;
|
|
4149
4166
|
}
|
|
@@ -4157,6 +4174,9 @@ function localToolchainInstallRequest(parsed) {
|
|
|
4157
4174
|
const channel = optionalTrimmedStringFlag(parsed, "channel");
|
|
4158
4175
|
if (channel.error)
|
|
4159
4176
|
return channel.error;
|
|
4177
|
+
const mode = optionalTrimmedStringFlag(parsed, "mode");
|
|
4178
|
+
if (mode.error)
|
|
4179
|
+
return mode.error;
|
|
4160
4180
|
const metadataRoot = optionalTrimmedStringFlag(parsed, "metadata-root");
|
|
4161
4181
|
if (metadataRoot.error)
|
|
4162
4182
|
return metadataRoot.error;
|
|
@@ -4175,6 +4195,7 @@ function localToolchainInstallRequest(parsed) {
|
|
|
4175
4195
|
return {
|
|
4176
4196
|
boardId: board.value,
|
|
4177
4197
|
channel: channel.value,
|
|
4198
|
+
mode: mode.value,
|
|
4178
4199
|
metadataRoot: metadataRoot.value,
|
|
4179
4200
|
sourceUrl: sourceUrl.value,
|
|
4180
4201
|
sourceReleaseRoot: sourceReleaseRoot.value,
|
|
@@ -4182,6 +4203,26 @@ function localToolchainInstallRequest(parsed) {
|
|
|
4182
4203
|
force: booleanFlag(parsed, "force")
|
|
4183
4204
|
};
|
|
4184
4205
|
}
|
|
4206
|
+
function localToolchainUninstallRequest(parsed) {
|
|
4207
|
+
const unknownFlag = firstUnknownFlag(parsed, ["json", "board", "board-id", "install-root", "yes"]);
|
|
4208
|
+
if (unknownFlag) {
|
|
4209
|
+
return `Unknown flag --${unknownFlag}. ${LOCAL_TOOLCHAIN_UNINSTALL_USAGE}`;
|
|
4210
|
+
}
|
|
4211
|
+
const extra = parsed.command.slice(3);
|
|
4212
|
+
if (extra.length > 0) {
|
|
4213
|
+
return `Unexpected argument: ${extra[0]}. ${LOCAL_TOOLCHAIN_UNINSTALL_USAGE}`;
|
|
4214
|
+
}
|
|
4215
|
+
const board = optionalTrimmedStringAliasFlag(parsed, ["board", "board-id"], "board or board-id");
|
|
4216
|
+
if (board.error)
|
|
4217
|
+
return board.error;
|
|
4218
|
+
if (!board.value) {
|
|
4219
|
+
return `Missing --board. ${LOCAL_TOOLCHAIN_UNINSTALL_USAGE}`;
|
|
4220
|
+
}
|
|
4221
|
+
const installRoot = optionalTrimmedStringFlag(parsed, "install-root");
|
|
4222
|
+
if (installRoot.error)
|
|
4223
|
+
return installRoot.error;
|
|
4224
|
+
return { boardId: board.value, installRoot: installRoot.value };
|
|
4225
|
+
}
|
|
4185
4226
|
function localToolchainValidateRequest(parsed) {
|
|
4186
4227
|
const unknownFlag = firstUnknownFlag(parsed, ["json", "release-root"]);
|
|
4187
4228
|
if (unknownFlag) {
|
|
@@ -5384,6 +5425,29 @@ function renderLocalToolchainInstall(result) {
|
|
|
5384
5425
|
}
|
|
5385
5426
|
return lines.join("\n");
|
|
5386
5427
|
}
|
|
5428
|
+
function renderLocalToolchainUninstall(result) {
|
|
5429
|
+
const lines = [
|
|
5430
|
+
result.removed ? "Local toolchain uninstalled." : "Local toolchain was not installed.",
|
|
5431
|
+
`board=${result.board_id}`,
|
|
5432
|
+
`install_root=${result.install_root}`,
|
|
5433
|
+
`registry=${result.registry_path}`,
|
|
5434
|
+
`removed=${result.removed}`,
|
|
5435
|
+
`removed_registry_entry=${result.removed_registry_entry}`
|
|
5436
|
+
];
|
|
5437
|
+
if (result.removed_paths.length > 0) {
|
|
5438
|
+
lines.push("removed_paths:");
|
|
5439
|
+
for (const removedPath of result.removed_paths) {
|
|
5440
|
+
lines.push(` ${removedPath}`);
|
|
5441
|
+
}
|
|
5442
|
+
}
|
|
5443
|
+
if (result.remaining_installed_boards.length > 0) {
|
|
5444
|
+
lines.push("remaining_installed_boards:");
|
|
5445
|
+
for (const boardId of result.remaining_installed_boards) {
|
|
5446
|
+
lines.push(` ${boardId}`);
|
|
5447
|
+
}
|
|
5448
|
+
}
|
|
5449
|
+
return lines.join("\n");
|
|
5450
|
+
}
|
|
5387
5451
|
function renderLocalToolchainValidation(result) {
|
|
5388
5452
|
const lines = [
|
|
5389
5453
|
result.ok ? "Local toolchain ready." : "Local toolchain not ready.",
|
|
@@ -6149,6 +6213,7 @@ Main workflow:
|
|
|
6149
6213
|
embed local toolchain latest
|
|
6150
6214
|
embed local toolchain install
|
|
6151
6215
|
embed local toolchain validate
|
|
6216
|
+
embed local toolchain uninstall --board <board_id>
|
|
6152
6217
|
embed local compile taishanpi --source ./main.c --output ./.embed-labs/build/main
|
|
6153
6218
|
embed local build qt-smoke --build-dir ./.embed-labs/build/qt-smoke
|
|
6154
6219
|
6. Pick a cloud build template:
|
|
@@ -6196,6 +6261,7 @@ Local hardware:
|
|
|
6196
6261
|
embed local toolchain latest
|
|
6197
6262
|
embed local toolchain current
|
|
6198
6263
|
embed local toolchain install
|
|
6264
|
+
embed local toolchain uninstall --board <board_id>
|
|
6199
6265
|
embed local toolchain validate
|
|
6200
6266
|
embed local compile taishanpi --source ./main.c --output ./.embed-labs/build/main
|
|
6201
6267
|
embed local build qt-smoke --build-dir ./.embed-labs/build/qt-smoke
|
|
@@ -6399,7 +6465,8 @@ Usage:
|
|
|
6399
6465
|
embed image boot-logo compose --package <boot-logo-package.json> --base-image <boot.img|image.img> --output <image> [--manifest <manifest.json>] [--force] [--json]
|
|
6400
6466
|
embed local toolchain latest [--board taishanpi-1m-rk3566] [--channel stable] [--metadata-root <path>] [--json]
|
|
6401
6467
|
embed local toolchain current [--install-root <path>] [--json]
|
|
6402
|
-
embed local toolchain install [--board taishanpi-1m-rk3566] [--channel stable] [--metadata-root <path>] [--source-url <tar.gz-url>|--source-release-root <path>] [--install-root <path>] [--force] [--json]
|
|
6468
|
+
embed local toolchain install [--board taishanpi-1m-rk3566] [--channel stable] [--mode minimal|runtime|compile|qt|firmware|full|images] [--metadata-root <path>] [--source-url <tar.gz-url>|--source-release-root <path>] [--install-root <path>] [--force] [--json]
|
|
6469
|
+
embed local toolchain uninstall --board <board_id> [--install-root <path>] [--yes] [--json]
|
|
6403
6470
|
Defaults to the production download channel at download.embedboard.com.
|
|
6404
6471
|
embed local toolchain validate [--release-root <path>] [--json]
|
|
6405
6472
|
embed local compile taishanpi --source <main.c|main.cpp> --output <artifact> [--release-root <path>] [--account <account_id>] [--json]
|