@rainbow-robotics/muscat-plugin-kit 0.1.2-dev.37 → 0.1.2-dev.39

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/README.md CHANGED
@@ -17,29 +17,29 @@ npm install -g @rainbow-robotics/muscat-plugin-kit@dev
17
17
  npm install -g @rainbow-robotics/muscat-plugin-kit@1.2.3
18
18
  ```
19
19
 
20
- ### 방법 2 — 설치 스크립트 (Node.js 없어도 됨)
20
+ ### 방법 2 — S3 설치 스크립트 (Node.js 없어도 됨)
21
21
 
22
22
  macOS / Linux / WSL:
23
23
 
24
24
  ```bash
25
25
  # 최신 stable
26
- curl -fsSL https://raw.githubusercontent.com/rainbow-robotics/web-rainbow-ui/main/scripts/install-muscat-pk.sh | sh
26
+ curl -fsSL https://rainbow-deploy.s3.ap-northeast-2.amazonaws.com/muscat-plugin-kit/install.sh | sh
27
27
 
28
28
  # dev 채널
29
- MUSCAT_PK_TAG=dev curl -fsSL https://raw.githubusercontent.com/rainbow-robotics/web-rainbow-ui/main/scripts/install-muscat-pk.sh | sh
29
+ curl -fsSL https://rainbow-deploy.s3.ap-northeast-2.amazonaws.com/muscat-plugin-kit/install.sh | MUSCAT_PK_TAG=dev sh
30
30
 
31
31
  # 특정 버전
32
- MUSCAT_PK_TAG=1.2.3 curl -fsSL https://raw.githubusercontent.com/rainbow-robotics/web-rainbow-ui/main/scripts/install-muscat-pk.sh | sh
32
+ curl -fsSL https://rainbow-deploy.s3.ap-northeast-2.amazonaws.com/muscat-plugin-kit/install.sh | MUSCAT_PK_TAG=1.2.3 sh
33
33
  ```
34
34
 
35
35
  Windows PowerShell:
36
36
 
37
37
  ```powershell
38
38
  # 최신 stable
39
- irm https://raw.githubusercontent.com/rainbow-robotics/web-rainbow-ui/main/scripts/install-muscat-pk.ps1 | iex
39
+ irm https://rainbow-deploy.s3.ap-northeast-2.amazonaws.com/muscat-plugin-kit/install.ps1 | iex
40
40
 
41
41
  # dev 채널
42
- $env:MUSCAT_PK_TAG="dev"; irm https://raw.githubusercontent.com/rainbow-robotics/web-rainbow-ui/main/scripts/install-muscat-pk.ps1 | iex
42
+ $env:MUSCAT_PK_TAG="dev"; irm https://rainbow-deploy.s3.ap-northeast-2.amazonaws.com/muscat-plugin-kit/install.ps1 | iex
43
43
  ```
44
44
 
45
45
  > 설치 스크립트는 Node.js 20+가 있으면 npm을 우선 사용하고, 없으면 S3에서 self-contained 바이너리를 받습니다.
@@ -48,12 +48,15 @@ $env:MUSCAT_PK_TAG="dev"; irm https://raw.githubusercontent.com/rainbow-robotics
48
48
 
49
49
  ```
50
50
  https://rainbow-deploy.s3.ap-northeast-2.amazonaws.com/muscat-plugin-kit/v{버전}/{바이너리}
51
+ https://rainbow-deploy.s3.ap-northeast-2.amazonaws.com/muscat-plugin-kit/stable/{바이너리}
52
+ https://rainbow-deploy.s3.ap-northeast-2.amazonaws.com/muscat-plugin-kit/dev/{바이너리}
51
53
  ```
52
54
 
53
55
  | OS | 파일 |
54
56
  |---|---|
55
57
  | Linux x64 | `muscat-pk-linux-x64` |
56
58
  | macOS ARM64 | `muscat-pk-darwin-arm64` |
59
+ | macOS x64 | `muscat-pk-darwin-x64` |
57
60
  | Windows x64 | `muscat-pk-win-x64.exe` |
58
61
 
59
62
  채널 포인터:
@@ -66,6 +69,24 @@ https://rainbow-deploy.s3.ap-northeast-2.amazonaws.com/muscat-plugin-kit/latest-
66
69
  https://rainbow-deploy.s3.ap-northeast-2.amazonaws.com/muscat-plugin-kit/dev-version.txt
67
70
  ```
68
71
 
72
+ ### 삭제
73
+
74
+ 설치 방식과 관계없이 `muscat-pk`가 자기 자신을 삭제합니다.
75
+
76
+ ```bash
77
+ muscat-pk uninstall
78
+ ```
79
+
80
+ 수동 삭제:
81
+
82
+ ```bash
83
+ # npm으로 설치한 경우
84
+ npm uninstall -g @rainbow-robotics/muscat-plugin-kit
85
+
86
+ # S3 바이너리로 설치한 경우 (macOS/Linux 기본 경로)
87
+ sudo rm -f /usr/local/bin/muscat-pk
88
+ ```
89
+
69
90
  ---
70
91
 
71
92
  ## 빠른 시작
package/cli/README.md CHANGED
@@ -16,6 +16,7 @@ muscat-pk dev:ui # preview the plugin in a mini-Muscat (preview-host)
16
16
  muscat-pk dev:back # run the back end in a Docker container (python / cpp / ros2)
17
17
  muscat-pk dev # dev:ui + dev:back
18
18
  muscat-pk update # update @rainbow-robotics/muscat-plugin-kit and @rainbow-robotics/plugin-ui
19
+ muscat-pk uninstall # remove muscat-pk itself (npm global or S3 binary)
19
20
  muscat-pk sdk list | sdk update [version] # manage rainbow-rb-sdk (python)
20
21
  ```
21
22
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // muscat-pk — Muscat plugin developer CLI.
3
- // Subcommands: new, build, dev, dev:ui, dev:back, update, sdk.
3
+ // Subcommands: new, build, dev, dev:ui, dev:back, update, uninstall, sdk.
4
4
  import { log } from "../src/util.mjs";
5
5
  import { runNew } from "../src/new.mjs";
6
6
  import { runBuild } from "../src/build.mjs";
@@ -8,6 +8,7 @@ import { runDevUi } from "../src/devUi.mjs";
8
8
  import { runDevBack } from "../src/devBack.mjs";
9
9
  import { runDev } from "../src/dev.mjs";
10
10
  import { runUpdate } from "../src/update.mjs";
11
+ import { runUninstall } from "../src/uninstall.mjs";
11
12
  import { runSdk } from "../src/sdk.mjs";
12
13
  import { runType } from "../src/type.mjs";
13
14
  import { runPreview } from "../src/preview.mjs";
@@ -27,6 +28,7 @@ Commands:
27
28
  dev:back Run the plugin back end (python: watchfiles reload / ros2: Docker)
28
29
  preview Preview against a real Muscat server (prompts for robot IP)
29
30
  update Update @rainbow-robotics/muscat-plugin-kit and @rainbow-robotics/plugin-ui
31
+ uninstall Remove the installed muscat-pk CLI (npm global or S3 binary)
30
32
  sdk <list|update [version]> Manage the python rainbow-rb-sdk version
31
33
 
32
34
  Run "muscat-pk <command> --help" for details.`;
@@ -50,6 +52,8 @@ async function main() {
50
52
  return await runPreview(args);
51
53
  case "update":
52
54
  return await runUpdate(args);
55
+ case "uninstall":
56
+ return await runUninstall(args);
53
57
  case "sdk":
54
58
  return await runSdk(args);
55
59
  case undefined:
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ // Pre-build step: serialise cli/templates/** into cli/src/templates-embedded.mjs
3
+ // so that `bun build --compile` can embed them without needing the filesystem.
4
+ import { readdirSync, readFileSync, writeFileSync, statSync } from "node:fs";
5
+ import { resolve, relative } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ const root = resolve(fileURLToPath(import.meta.url), "..");
9
+ const templatesDir = resolve(root, "templates");
10
+ const out = resolve(root, "src/templates-embedded.mjs");
11
+
12
+ const files = {};
13
+ function walk(dir) {
14
+ for (const name of readdirSync(dir)) {
15
+ const full = resolve(dir, name);
16
+ if (statSync(full).isDirectory()) { walk(full); continue; }
17
+ const key = relative(templatesDir, full);
18
+ files[key] = readFileSync(full, "base64");
19
+ }
20
+ }
21
+ walk(templatesDir);
22
+
23
+ writeFileSync(out,
24
+ `// AUTO-GENERATED by cli/bundle-templates.mjs — do not edit.\n` +
25
+ `// ponytail: generated at publish time; not tracked in git.\n` +
26
+ `export const TEMPLATES = ${JSON.stringify(files)};\n`
27
+ );
28
+ console.log(`bundled ${Object.keys(files).length} template files → src/templates-embedded.mjs`);
@@ -53,6 +53,7 @@ function runPython(root) {
53
53
  log.step("starting Python dev container…");
54
54
  const up = docker(
55
55
  ["run", "-d", "--name", container, ...netFlags,
56
+ "-e", "PIP_ROOT_USER_ACTION=ignore",
56
57
  "-v", `${root}:/plugin`, "-w", "/plugin", PYTHON_DEV_IMAGE, "sleep", "infinity"],
57
58
  { stdio: "inherit" },
58
59
  );
@@ -112,7 +113,7 @@ function runRos2(root) {
112
113
  docker(["rm", "-f", container], { stdio: "ignore" });
113
114
  log.step("starting ROS2 dev container…");
114
115
  const up = docker(
115
- ["run", "-d", "--name", container, "-v", `${root}:/plugin`, "-w", "/plugin", ROS2_DEV_IMAGE, "sleep", "infinity"],
116
+ ["run", "-d", "--name", container, "-e", "PIP_ROOT_USER_ACTION=ignore", "-v", `${root}:/plugin`, "-w", "/plugin", ROS2_DEV_IMAGE, "sleep", "infinity"],
116
117
  { stdio: "inherit" },
117
118
  );
118
119
  if (up.status !== 0) throw new Error("failed to start dev container.");
package/cli/src/new.mjs CHANGED
@@ -7,13 +7,28 @@ import {
7
7
  readFileSync,
8
8
  readdirSync,
9
9
  renameSync,
10
+ rmSync,
10
11
  statSync,
11
12
  writeFileSync,
12
13
  } from "node:fs";
13
- import { basename, resolve } from "node:path";
14
- import { rmSync } from "node:fs";
14
+ import { basename, dirname, resolve } from "node:path";
15
15
  import { hasBin, kitVersion, parseArgs, prompt, templatesDir, log } from "./util.mjs";
16
16
 
17
+ // Like cpSync(src, dst, {recursive:true}) but reads from the embedded snapshot
18
+ // when the templates dir doesn't exist on disk (compiled binary mode).
19
+ // ponytail: import() is module-cached by the runtime — no manual cache needed.
20
+ async function copyTemplate(srcDir, dst) {
21
+ if (existsSync(templatesDir)) { cpSync(srcDir, dst, { recursive: true }); return; }
22
+ const { TEMPLATES } = await import("./templates-embedded.mjs");
23
+ const prefix = srcDir.slice(templatesDir.length + 1).replace(/\\/g, "/") + "/";
24
+ for (const [key, b64] of Object.entries(TEMPLATES)) {
25
+ if (!key.startsWith(prefix)) continue;
26
+ const dest = resolve(dst, key.slice(prefix.length));
27
+ mkdirSync(dirname(dest), { recursive: true });
28
+ writeFileSync(dest, Buffer.from(b64, "base64"));
29
+ }
30
+ }
31
+
17
32
  // `--type` values map to a runtime descriptor. ros2 has a python (rclpy) and a
18
33
  // C++ (rclcpp) flavor; we expose them as distinct type choices for clarity.
19
34
  export const TYPE_CHOICES = {
@@ -91,15 +106,15 @@ function renameSlugPaths(dir, slug) {
91
106
  // the kit (cli/docker/) so authors can't edit it. Caller runs applyTokens after.
92
107
  // rclpy → templates/ros2 (ament_python)
93
108
  // rclcpp → templates/ros2-cpp (ament_cmake)
94
- export function overlayRos2(target, slug, rosClient = "rclpy") {
109
+ export async function overlayRos2(target, slug, rosClient = "rclpy") {
95
110
  const tmpl = rosClient === "rclcpp" ? "ros2-cpp" : "ros2";
96
- cpSync(resolve(templatesDir, tmpl), target, { recursive: true });
111
+ await copyTemplate(resolve(templatesDir, tmpl), target);
97
112
  renameSlugPaths(resolve(target, "ros2_ws"), slug);
98
113
  }
99
114
 
100
115
  // Copy the cpp/ overlay (CMake project) into a plugin. Caller runs applyTokens after.
101
- export function overlayCpp(target) {
102
- cpSync(resolve(templatesDir, "cpp"), target, { recursive: true });
116
+ export async function overlayCpp(target) {
117
+ await copyTemplate(resolve(templatesDir, "cpp"), target);
103
118
  }
104
119
 
105
120
  export async function runNew(args) {
@@ -171,10 +186,10 @@ export async function runNew(args) {
171
186
  // cpp → cpp/ 오버레이, py/·requirements.txt 제거
172
187
  // ros2(*) → ros2_ws/ 오버레이 (rclpy=ament_python, rclcpp=ament_cmake)
173
188
  log.step(`scaffolding ${type} plugin → ${target}`);
174
- cpSync(resolve(templatesDir, "common"), target, { recursive: true });
175
- if (runtimeChoice.type === "ros2") overlayRos2(target, slug, runtimeChoice.rosClient);
189
+ await copyTemplate(resolve(templatesDir, "common"), target);
190
+ if (runtimeChoice.type === "ros2") await overlayRos2(target, slug, runtimeChoice.rosClient);
176
191
  if (runtimeChoice.type === "cpp") {
177
- overlayCpp(target);
192
+ await overlayCpp(target);
178
193
  rmSync(resolve(target, "py"), { recursive: true, force: true });
179
194
  rmSync(resolve(target, "requirements.txt"), { force: true });
180
195
  }
package/cli/src/ros2.mjs CHANGED
@@ -89,7 +89,7 @@ export function colconBuild(root, { image = ROS2_DEV_IMAGE, symlink = false, arc
89
89
  const platformFlags = dockerPlatform ? ["--platform", dockerPlatform] : [];
90
90
  const r = spawnSync(
91
91
  "docker",
92
- ["run", "--rm", ...platformFlags, "-v", `${root}:/plugin`, "-w", "/plugin", actualImage, "bash", "-lc", script],
92
+ ["run", "--rm", ...platformFlags, "-e", "PIP_ROOT_USER_ACTION=ignore", "-v", `${root}:/plugin`, "-w", "/plugin", actualImage, "bash", "-lc", script],
93
93
  { cwd: root, stdio: "inherit" },
94
94
  );
95
95
  if (r.status !== 0) throw new Error(`colcon build failed${arch ? ` (${arch})` : ""}.`);
package/cli/src/type.mjs CHANGED
@@ -69,7 +69,7 @@ export async function runType(args) {
69
69
  log.warn("ros2_ws/ already exists — keeping it, only flipping manifest type.");
70
70
  } else {
71
71
  log.step(`adding ros2_ws/ overlay (${runtimeChoice.rosClient})`);
72
- overlayRos2(root, slug, runtimeChoice.rosClient);
72
+ await overlayRos2(root, slug, runtimeChoice.rosClient);
73
73
  applyTokens(root, {
74
74
  __PLUGIN_ID__: pluginId,
75
75
  __PLUGIN_NAME__: pluginName,
@@ -83,7 +83,7 @@ export async function runType(args) {
83
83
  log.warn("cpp/ already exists — keeping it, only flipping manifest type.");
84
84
  } else {
85
85
  log.step("adding cpp/ overlay");
86
- overlayCpp(root);
86
+ await overlayCpp(root);
87
87
  applyTokens(root, {
88
88
  __PLUGIN_ID__: pluginId,
89
89
  __PLUGIN_NAME__: pluginName,
@@ -0,0 +1,98 @@
1
+ // muscat-pk uninstall - remove the installed CLI, whether npm-global or S3 binary.
2
+ import { execSync, spawn, spawnSync } from "node:child_process";
3
+ import { existsSync, realpathSync, rmSync } from "node:fs";
4
+ import { dirname, join, relative } from "node:path";
5
+ import { KIT_PUBLISHED_NAME, kitRoot, log, parseArgs } from "./util.mjs";
6
+
7
+ const isBinaryMode = typeof Bun !== "undefined";
8
+
9
+ function isInside(child, parent) {
10
+ const rel = relative(parent, child);
11
+ return rel === "" || (!!rel && !rel.startsWith("..") && !rel.includes(":"));
12
+ }
13
+
14
+ function npmGlobalRoot() {
15
+ return execSync("npm root -g", { encoding: "utf8" }).trim();
16
+ }
17
+
18
+ function isNpmGlobalInstall() {
19
+ try {
20
+ return isInside(realpathSync(kitRoot), realpathSync(npmGlobalRoot()));
21
+ } catch {
22
+ return false;
23
+ }
24
+ }
25
+
26
+ function uninstallNpmGlobal() {
27
+ log.step(`npm uninstall -g ${KIT_PUBLISHED_NAME}`);
28
+ execSync(`npm uninstall -g ${KIT_PUBLISHED_NAME}`, { stdio: "inherit" });
29
+ log.ok("Global npm package removed.");
30
+ }
31
+
32
+ function uninstallBinary() {
33
+ const execPath = process.execPath;
34
+ log.step(`Removing binary: ${execPath}`);
35
+
36
+ if (process.platform === "win32") {
37
+ const ps = `Start-Sleep -Milliseconds 500; Remove-Item -Force '${execPath}'`;
38
+ spawn("powershell", ["-NoProfile", "-Command", ps], {
39
+ detached: true,
40
+ stdio: "ignore",
41
+ }).unref();
42
+ log.ok("Binary will be removed after this process exits.");
43
+ return;
44
+ }
45
+
46
+ try {
47
+ rmSync(execPath, { force: true });
48
+ } catch (err) {
49
+ if (err?.code !== "EACCES" && err?.code !== "EPERM") throw err;
50
+ log.info(" sudo is required...");
51
+ const result = spawnSync("sudo", ["rm", "-f", execPath], { stdio: "inherit" });
52
+ if (result.status !== 0) throw new Error(`sudo rm failed: ${execPath}`);
53
+ }
54
+
55
+ const parent = dirname(execPath);
56
+ for (const shim of ["muscat-pk.cmd", "muscat-pk.ps1"]) {
57
+ rmSync(join(parent, shim), { force: true });
58
+ }
59
+
60
+ log.ok("Binary removed.");
61
+ }
62
+
63
+ export async function runUninstall(args = []) {
64
+ const opts = parseArgs(args, { booleans: ["help"] });
65
+
66
+ if (opts.help) {
67
+ log.info(
68
+ [
69
+ "Usage: muscat-pk uninstall",
70
+ "",
71
+ "Removes the installed muscat-pk CLI.",
72
+ " npm global install -> npm uninstall -g @rainbow-robotics/muscat-plugin-kit",
73
+ " S3 binary install -> remove the muscat-pk executable",
74
+ ].join("\n"),
75
+ );
76
+ return;
77
+ }
78
+
79
+ if (isBinaryMode) {
80
+ uninstallBinary();
81
+ return;
82
+ }
83
+
84
+ if (isNpmGlobalInstall()) {
85
+ uninstallNpmGlobal();
86
+ return;
87
+ }
88
+
89
+ const localBin = process.argv[1] || "";
90
+ if (localBin.includes(`${join("node_modules", ".bin")}`) || existsSync(join(process.cwd(), "package.json"))) {
91
+ log.warn("This muscat-pk appears to be running from a project/local install.");
92
+ log.warn("Remove it from the project package manager instead, for example:");
93
+ log.warn(` npm uninstall ${KIT_PUBLISHED_NAME}`);
94
+ return;
95
+ }
96
+
97
+ throw new Error("Could not determine install mode. Remove muscat-pk manually from your PATH.");
98
+ }
@@ -386,4 +386,5 @@ muscat-pk type change # switch backend type
386
386
  muscat-pk sdk list # show current Python SDK version
387
387
  muscat-pk sdk update # update Python SDK to latest
388
388
  muscat-pk update # update muscat-plugin-kit itself
389
+ muscat-pk uninstall # remove muscat-pk itself
389
390
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainbow-robotics/muscat-plugin-kit",
3
- "version": "0.1.2-dev.37",
3
+ "version": "0.1.2-dev.39",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -31,7 +31,7 @@
31
31
  "@types/react-dom": "^19.0.4"
32
32
  },
33
33
  "dependencies": {
34
- "@rainbow-robotics/preview-host": "0.1.2-dev.37",
34
+ "@rainbow-robotics/preview-host": "0.1.2-dev.39",
35
35
  "socket.io": "^4.8.1"
36
36
  },
37
37
  "optionalDependencies": {