@embedder/embedder 0.3.6

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/bin/embedder ADDED
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env node
2
+
3
+ const childProcess = require("child_process");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const os = require("os");
7
+
8
+ function run(target) {
9
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
10
+ stdio: "inherit",
11
+ });
12
+ if (result.error) {
13
+ console.error(result.error.message);
14
+ process.exit(1);
15
+ }
16
+ const code = typeof result.status === "number" ? result.status : 0;
17
+ process.exit(code);
18
+ }
19
+
20
+ const envPath = process.env.EMBEDDER_BIN_PATH;
21
+ if (envPath) {
22
+ run(envPath);
23
+ }
24
+
25
+ const scriptPath = fs.realpathSync(__filename);
26
+ const scriptDir = path.dirname(scriptPath);
27
+
28
+ const platformMap = {
29
+ darwin: "darwin",
30
+ linux: "linux",
31
+ win32: "windows",
32
+ };
33
+ const archMap = {
34
+ x64: "x64",
35
+ arm64: "arm64",
36
+ };
37
+
38
+ let platform = platformMap[os.platform()];
39
+ if (!platform) {
40
+ platform = os.platform();
41
+ }
42
+ let arch = archMap[os.arch()];
43
+ if (!arch) {
44
+ arch = os.arch();
45
+ }
46
+ const base = "@embedder/embedder-" + platform + "-" + arch;
47
+ const binary = platform === "windows" ? "embedder.exe" : "embedder";
48
+
49
+ function findBinary(startDir) {
50
+ let current = startDir;
51
+ for (;;) {
52
+ const modules = path.join(current, "node_modules");
53
+ if (fs.existsSync(modules)) {
54
+ // Check for scoped package
55
+ const scopedDir = path.join(modules, "@embedder");
56
+ if (fs.existsSync(scopedDir)) {
57
+ const entries = fs.readdirSync(scopedDir);
58
+ for (const entry of entries) {
59
+ const expectedName = "embedder-" + platform + "-" + arch;
60
+ if (entry === expectedName) {
61
+ const candidate = path.join(scopedDir, entry, "bin", binary);
62
+ if (fs.existsSync(candidate)) {
63
+ return candidate;
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ const parent = path.dirname(current);
70
+ if (parent === current) {
71
+ return;
72
+ }
73
+ current = parent;
74
+ }
75
+ }
76
+
77
+ const resolved = findBinary(scriptDir);
78
+ if (!resolved) {
79
+ console.error(
80
+ 'It seems that your package manager failed to install the right version of the embedder CLI for your platform. You can try manually installing the "' +
81
+ base +
82
+ '" package'
83
+ );
84
+ process.exit(1);
85
+ }
86
+
87
+ run(resolved);
88
+
89
+
90
+
91
+
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@embedder/embedder",
3
+ "version": "0.3.6",
4
+ "description": "AI-powered embedded systems development tool",
5
+ "bin": {
6
+ "embedder": "./bin/embedder"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node ./postinstall.mjs"
10
+ },
11
+ "optionalDependencies": {
12
+ "@embedder/embedder-darwin-arm64": "0.3.6",
13
+ "@embedder/embedder-darwin-x64": "0.3.6",
14
+ "@embedder/embedder-linux-x64": "0.3.6",
15
+ "@embedder/embedder-windows-x64": "0.3.6"
16
+ },
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/embedder-dev/embedder-cli"
21
+ },
22
+ "keywords": [
23
+ "embedder",
24
+ "ai",
25
+ "embedded",
26
+ "cli",
27
+ "development"
28
+ ]
29
+ }
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs";
4
+ import { createRequire } from "node:module";
5
+ import os from "node:os";
6
+ import path from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
+ const require = createRequire(import.meta.url);
11
+
12
+ function detectPlatformAndArch() {
13
+ let platform;
14
+ switch (os.platform()) {
15
+ case "darwin":
16
+ platform = "darwin";
17
+ break;
18
+ case "linux":
19
+ platform = "linux";
20
+ break;
21
+ case "win32":
22
+ platform = "windows";
23
+ break;
24
+ default:
25
+ platform = os.platform();
26
+ break;
27
+ }
28
+
29
+ let arch;
30
+ switch (os.arch()) {
31
+ case "x64":
32
+ arch = "x64";
33
+ break;
34
+ case "arm64":
35
+ arch = "arm64";
36
+ break;
37
+ default:
38
+ arch = os.arch();
39
+ break;
40
+ }
41
+
42
+ return { platform, arch };
43
+ }
44
+
45
+ function findBinary() {
46
+ const { platform, arch } = detectPlatformAndArch();
47
+ const packageName = `@embedder/embedder-${platform}-${arch}`;
48
+ const binaryName = platform === "windows" ? "embedder.exe" : "embedder";
49
+
50
+ try {
51
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
52
+ const packageDir = path.dirname(packageJsonPath);
53
+ const binaryPath = path.join(packageDir, "bin", binaryName);
54
+
55
+ if (!fs.existsSync(binaryPath)) {
56
+ throw new Error(`Binary not found at ${binaryPath}`);
57
+ }
58
+
59
+ return { binaryPath, binaryName, packageName };
60
+ } catch (error) {
61
+ throw new Error(`Could not find package ${packageName}: ${error.message}`);
62
+ }
63
+ }
64
+
65
+ async function main() {
66
+ try {
67
+ if (os.platform() === "win32") {
68
+ console.log("Windows detected: binary setup complete");
69
+ return;
70
+ }
71
+
72
+ const { binaryPath, packageName } = findBinary();
73
+ console.log(`Platform binary verified: ${packageName}`);
74
+ console.log(`Binary location: ${binaryPath}`);
75
+ } catch (error) {
76
+ console.error("Failed to setup embedder binary:", error.message);
77
+ console.error(
78
+ "You may need to manually install the platform-specific package.",
79
+ );
80
+ process.exit(1);
81
+ }
82
+ }
83
+
84
+ try {
85
+ main();
86
+ } catch (error) {
87
+ console.error("Postinstall script error:", error.message);
88
+ process.exit(0);
89
+ }