@auroraflow/code 0.0.5 → 0.0.7

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.
@@ -0,0 +1,267 @@
1
+ import { spawn, spawnSync } from "node:child_process";
2
+ import { randomBytes } from "node:crypto";
3
+ import { existsSync, readFileSync } from "node:fs";
4
+ import { mkdir, writeFile } from "node:fs/promises";
5
+ import { delimiter, dirname, join, resolve } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import { AURORA_SIDECAR_PORT } from "../../protocol/src/index.js";
8
+ import { CLAUDE_HOME, CODEX_HOME, readSidecarInfo, readState, writeSidecarInfo } from "../../state/src/index.js";
9
+
10
+ const here = dirname(fileURLToPath(import.meta.url));
11
+ const packageRoot = resolve(here, "..", "..", "..");
12
+ const rootSidecarBin = join(packageRoot, "bin", "aurora-sidecar.js");
13
+
14
+ const OFFICIAL_CLIENTS = {
15
+ claude: {
16
+ name: "Claude Code",
17
+ packageName: "@anthropic-ai/claude-code",
18
+ binName: "claude"
19
+ },
20
+ codex: {
21
+ name: "Codex",
22
+ packageName: "@openai/codex",
23
+ binName: "codex"
24
+ }
25
+ };
26
+
27
+ export async function createClientLaunchSpec(client, args = []) {
28
+ const sidecar = await ensureSidecar();
29
+ const state = await readState();
30
+ const model = selectedModelAlias(state);
31
+ const key = selectedKey(state);
32
+ if (client === "claude") {
33
+ const env = {
34
+ ...process.env,
35
+ AURORA_HOME: process.env.AURORA_HOME ?? "",
36
+ CLAUDE_CONFIG_DIR: CLAUDE_HOME,
37
+ ANTHROPIC_BASE_URL: sidecar.baseURL,
38
+ ANTHROPIC_AUTH_TOKEN: sidecar.token,
39
+ CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1",
40
+ CLAUDE_CODE_DISABLE_TELEMETRY: "1",
41
+ DISABLE_AUTOUPDATER: "1"
42
+ };
43
+ env.ANTHROPIC_MODEL = model;
44
+ return { command: officialClientBin("claude"), args, env };
45
+ }
46
+ await writeCodexRuntimeFiles({ sidecar, model, key });
47
+ const env = {
48
+ ...process.env,
49
+ AURORA_HOME: process.env.AURORA_HOME ?? "",
50
+ CODEX_HOME,
51
+ OPENAI_API_KEY: sidecar.token,
52
+ OPENAI_BASE_URL: `${sidecar.baseURL}/v1`
53
+ };
54
+ env.OPENAI_MODEL = model;
55
+ return { command: officialClientBin("codex"), args, env };
56
+ }
57
+
58
+ export async function runClient(client, args = []) {
59
+ const spec = await createClientLaunchSpec(client, args);
60
+ await spawnAndExit(spec.command, spec.args, spec.env);
61
+ }
62
+
63
+ export function officialClientStatuses() {
64
+ return Object.entries(OFFICIAL_CLIENTS).map(([id, client]) => {
65
+ const bin = resolveOfficialClientBin(client.binName);
66
+ const packagePath = officialClientPackageJSONPath(client.packageName);
67
+ const version = readOfficialClientVersion(bin) ?? (packagePath ? JSON.parse(readFileSync(packagePath, "utf8")).version : null);
68
+ return {
69
+ id,
70
+ name: client.name,
71
+ packageName: client.packageName,
72
+ bin,
73
+ installed: Boolean(bin),
74
+ version
75
+ };
76
+ });
77
+ }
78
+
79
+ export async function updateOfficialClients() {
80
+ await installOfficialClients();
81
+ }
82
+
83
+ export async function installOfficialClients() {
84
+ const npm = process.env.npm_execpath || "npm";
85
+ const args = ["install", "-g", "@anthropic-ai/claude-code@latest", "@openai/codex@latest"];
86
+ await spawnAndWait(npm, args, { ...process.env });
87
+ }
88
+
89
+ export function isGlobalNpmLifecycle() {
90
+ return process.env.npm_config_global === "true" || process.env.npm_config_location === "global";
91
+ }
92
+
93
+ function officialClientBin(client) {
94
+ const spec = OFFICIAL_CLIENTS[client];
95
+ if (!spec) throw new Error(`unknown official client: ${client}`);
96
+ const bin = resolveOfficialClientBin(spec.binName);
97
+ if (!bin) {
98
+ throw new Error(`${spec.name} is not installed. Run: aurora install-clients`);
99
+ }
100
+ return bin;
101
+ }
102
+
103
+ function resolveOfficialClientBin(binName) {
104
+ return findPathCommand(binName) ?? localClientBinPath(binName);
105
+ }
106
+
107
+ function localClientBinPath(binName) {
108
+ const suffix = process.platform === "win32" ? ".cmd" : "";
109
+ const bin = join(packageRoot, "node_modules", ".bin", `${binName}${suffix}`);
110
+ return existsSync(bin) ? bin : null;
111
+ }
112
+
113
+ function findPathCommand(binName) {
114
+ const suffixes = process.platform === "win32" ? [".cmd", ".exe", ""] : [""];
115
+ for (const dir of String(process.env.PATH ?? "").split(delimiter)) {
116
+ if (!dir) continue;
117
+ for (const suffix of suffixes) {
118
+ const candidate = join(dir, `${binName}${suffix}`);
119
+ if (existsSync(candidate)) return candidate;
120
+ }
121
+ }
122
+ return null;
123
+ }
124
+
125
+ function officialClientPackageJSONPath(packageName) {
126
+ const parts = packageName.startsWith("@") ? packageName.split("/") : [packageName];
127
+ const packagePath = join(packageRoot, "node_modules", ...parts, "package.json");
128
+ return existsSync(packagePath) ? packagePath : null;
129
+ }
130
+
131
+ function readOfficialClientVersion(bin) {
132
+ if (!bin) return null;
133
+ try {
134
+ const result = spawnSyncCompat(bin, ["--version"]);
135
+ if (result.status !== 0) return null;
136
+ return String(result.stdout || result.stderr || "").trim() || null;
137
+ } catch {
138
+ return null;
139
+ }
140
+ }
141
+
142
+ async function ensureSidecar() {
143
+ try {
144
+ const info = await readSidecarInfo();
145
+ if (info?.port && info?.token && await pingSidecar(info)) return normalizedSidecarInfo(info);
146
+ } catch {
147
+ // Start below.
148
+ }
149
+ const token = `aurora-local-${randomBytes(24).toString("hex")}`;
150
+ const child = spawn(process.execPath, [process.env.AURORA_SIDECAR_BIN || rootSidecarBin, "--token", token], {
151
+ detached: true,
152
+ stdio: "ignore",
153
+ env: process.env
154
+ });
155
+ child.unref();
156
+ const info = { port: AURORA_SIDECAR_PORT, token, baseURL: `http://127.0.0.1:${AURORA_SIDECAR_PORT}` };
157
+ await waitForSidecar(info);
158
+ await writeSidecarInfo(info);
159
+ return info;
160
+ }
161
+
162
+ async function writeCodexRuntimeFiles({ sidecar, model }) {
163
+ await mkdir(CODEX_HOME, { recursive: true });
164
+ const config = `model = ${tomlString(model)}
165
+ model_provider = "aurora"
166
+ suppress_unstable_features_warning = true
167
+
168
+ [model_providers.aurora]
169
+ name = "Aurora"
170
+ base_url = ${tomlString(`${sidecar.baseURL}/v1`)}
171
+ env_key = "OPENAI_API_KEY"
172
+ wire_api = "responses"
173
+ requires_openai_auth = false
174
+ request_max_retries = 0
175
+ stream_max_retries = 0
176
+ stream_idle_timeout_ms = 300000
177
+ `;
178
+ const auth = {
179
+ OPENAI_API_KEY: sidecar.token,
180
+ tokens: null,
181
+ last_refresh: null
182
+ };
183
+ await writeFile(join(CODEX_HOME, "config.toml"), config, { mode: 0o600 });
184
+ await writeFile(join(CODEX_HOME, "auth.json"), `${JSON.stringify(auth, null, 2)}\n`, { mode: 0o600 });
185
+ }
186
+
187
+ async function waitForSidecar(info) {
188
+ const deadline = Date.now() + 2500;
189
+ while (Date.now() < deadline) {
190
+ if (await pingSidecar(info)) return;
191
+ await new Promise(resolve => setTimeout(resolve, 100));
192
+ }
193
+ throw new Error("Aurora sidecar did not become ready on 127.0.0.1:17878");
194
+ }
195
+
196
+ async function pingSidecar(info) {
197
+ try {
198
+ const normalized = normalizedSidecarInfo(info);
199
+ const response = await fetch(`${normalized.baseURL}/aurora/status`, {
200
+ headers: { authorization: `Bearer ${normalized.token}` },
201
+ signal: AbortSignal.timeout(500)
202
+ });
203
+ return response.ok;
204
+ } catch {
205
+ return false;
206
+ }
207
+ }
208
+
209
+ function normalizedSidecarInfo(info) {
210
+ return {
211
+ port: Number(info.port),
212
+ token: String(info.token),
213
+ baseURL: info.baseURL || `http://127.0.0.1:${Number(info.port)}`
214
+ };
215
+ }
216
+
217
+ function selectedModelAlias(state) {
218
+ const model = state.selectedModel?.alias;
219
+ if (!model) throw new Error("Aurora runtime model is not selected. Select a model in Aurora Desktop > 本机调用.");
220
+ return model;
221
+ }
222
+
223
+ function selectedKey(state) {
224
+ const key = state.selectedKey?.presentedKey;
225
+ if (!key) throw new Error("Aurora runtime key is not selected. Select a key in Aurora Desktop > 本机调用.");
226
+ return key;
227
+ }
228
+
229
+ function tomlString(value) {
230
+ return JSON.stringify(String(value));
231
+ }
232
+
233
+ async function spawnAndExit(command, args, env) {
234
+ const child = spawn(command, args, {
235
+ stdio: "inherit",
236
+ env,
237
+ shell: process.platform === "win32" && command.endsWith(".cmd")
238
+ });
239
+ child.on("error", error => {
240
+ console.error(`Failed to start ${command}: ${error.message}`);
241
+ process.exit(1);
242
+ });
243
+ child.on("exit", code => process.exit(code ?? 1));
244
+ }
245
+
246
+ function spawnAndWait(command, args, env) {
247
+ return new Promise((resolve, reject) => {
248
+ const child = spawn(command, args, {
249
+ cwd: packageRoot,
250
+ stdio: "inherit",
251
+ env,
252
+ shell: process.platform === "win32"
253
+ });
254
+ child.on("error", reject);
255
+ child.on("exit", code => {
256
+ if (code === 0) resolve();
257
+ else reject(new Error(`${command} exited with code ${code ?? 1}`));
258
+ });
259
+ });
260
+ }
261
+
262
+ function spawnSyncCompat(command, args) {
263
+ return spawnSync(command, args, {
264
+ encoding: "utf8",
265
+ shell: process.platform === "win32" && command.endsWith(".cmd")
266
+ });
267
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@aurora/protocol",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./src/index.js"
8
+ }
9
+ }
@@ -0,0 +1,43 @@
1
+ export const AURORA_SIDECAR_PORT = 17878;
2
+ export const AURORA_LOCALHOST = "127.0.0.1";
3
+
4
+ export function trimSlash(value) {
5
+ return String(value).replace(/\/+$/, "");
6
+ }
7
+
8
+ export function selectedKeyHeaders(state) {
9
+ const key = state.selectedKey?.presentedKey;
10
+ return key ? { authorization: `Bearer ${key}`, "x-api-key": key } : {};
11
+ }
12
+
13
+ export function rewriteRuntimeModel(raw, selectedAlias) {
14
+ if (!selectedAlias || !raw.trim()) return raw;
15
+ try {
16
+ const parsed = JSON.parse(raw);
17
+ parsed.model = selectedAlias;
18
+ return JSON.stringify(parsed);
19
+ } catch {
20
+ return raw;
21
+ }
22
+ }
23
+
24
+ export function toClientModelItem(item) {
25
+ const provider = String(item.provider ?? "aurora").replace(/[^a-zA-Z0-9_-]/g, "-");
26
+ const modelID = encodeURIComponent(String(item.model_id ?? item.alias ?? item.id));
27
+ return {
28
+ id: `claude-${provider}/${modelID}`,
29
+ object: "model",
30
+ owned_by: provider,
31
+ display_name: item.display_name || `${provider} / ${item.model_id ?? item.alias ?? item.id}`,
32
+ aurora_alias: item.alias ?? item.id,
33
+ aurora_provider: item.provider,
34
+ aurora_model_id: item.model_id
35
+ };
36
+ }
37
+
38
+ export function isRuntimePath(pathname) {
39
+ return pathname === "/v1/messages" ||
40
+ pathname === "/v1/responses" ||
41
+ pathname === "/v1/chat/completions" ||
42
+ pathname === "/v1/messages/count_tokens";
43
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@aurora/sidecar",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./src/index.js"
8
+ }
9
+ }
@@ -0,0 +1,109 @@
1
+ import { createServer } from "node:http";
2
+ import { AURORA_LOCALHOST, AURORA_SIDECAR_PORT, isRuntimePath, rewriteRuntimeModel, selectedKeyHeaders, toClientModelItem, trimSlash } from "../../protocol/src/index.js";
3
+ import { readState, writeSidecarInfo } from "../../state/src/index.js";
4
+
5
+ export async function startSidecar(options = {}) {
6
+ const token = options.token || readArg("--token") || process.env.AURORA_SIDECAR_TOKEN || "aurora-local-dev";
7
+ const port = Number(options.port || readArg("--port") || process.env.AURORA_SIDECAR_PORT || AURORA_SIDECAR_PORT);
8
+ const server = createServer((request, response) => {
9
+ handle(request, response, token).catch(error => {
10
+ response.writeHead(500, { "content-type": "application/json" });
11
+ response.end(JSON.stringify({ error: { type: "sidecar_error", message: error.message } }));
12
+ });
13
+ });
14
+ server.listen(port, AURORA_LOCALHOST, async () => {
15
+ await writeSidecarInfo({ port, token, baseURL: `http://${AURORA_LOCALHOST}:${port}` });
16
+ console.error(`Aurora sidecar listening on http://${AURORA_LOCALHOST}:${port}`);
17
+ });
18
+ }
19
+
20
+ async function handle(request, response, token) {
21
+ if (!isAuthorized(request, token)) {
22
+ writeJSON(response, 401, { error: { type: "unauthorized", message: "sidecar token required" } });
23
+ return;
24
+ }
25
+ const url = new URL(request.url, `http://${AURORA_LOCALHOST}`);
26
+ if (request.method === "GET" && url.pathname === "/aurora/status") {
27
+ const state = await readState();
28
+ writeJSON(response, 200, {
29
+ ok: true,
30
+ selectedKey: Boolean(state.selectedKey?.presentedKey),
31
+ selectedModel: state.selectedModel ?? null
32
+ });
33
+ return;
34
+ }
35
+ if (request.method === "GET" && url.pathname === "/v1/models") {
36
+ await proxyModels(response);
37
+ return;
38
+ }
39
+ if (request.method === "POST" && isRuntimePath(url.pathname)) {
40
+ await proxyRuntime(request, response, url.pathname + url.search);
41
+ return;
42
+ }
43
+ writeJSON(response, 404, { error: { type: "not_found", message: "unknown sidecar route" } });
44
+ }
45
+
46
+ async function proxyModels(response) {
47
+ const state = await readState();
48
+ const gatewayURL = trimSlash(state.gatewayURL ?? "https://auroramos.com");
49
+ const upstream = await fetch(`${gatewayURL}/v1/aurora-cli/models`, {
50
+ headers: selectedKeyHeaders(state)
51
+ });
52
+ const payload = await upstream.json().catch(() => ({ object: "list", data: [] }));
53
+ const data = Array.isArray(payload.data) ? payload.data.map(toClientModelItem) : [];
54
+ writeJSON(response, upstream.ok ? 200 : upstream.status, { object: "list", data });
55
+ }
56
+
57
+ async function proxyRuntime(request, response, path) {
58
+ const state = await readState();
59
+ const body = await readBody(request);
60
+ const gatewayURL = trimSlash(state.gatewayURL ?? "https://auroramos.com");
61
+ const upstream = await fetch(`${gatewayURL}${path}`, {
62
+ method: request.method,
63
+ headers: {
64
+ ...copyForwardHeaders(request.headers),
65
+ ...selectedKeyHeaders(state),
66
+ "content-type": request.headers["content-type"] ?? "application/json"
67
+ },
68
+ body: rewriteRuntimeModel(body, state.selectedModel?.alias)
69
+ });
70
+ response.writeHead(upstream.status, Object.fromEntries(upstream.headers.entries()));
71
+ if (upstream.body) {
72
+ for await (const chunk of upstream.body) response.write(chunk);
73
+ }
74
+ response.end();
75
+ }
76
+
77
+ function isAuthorized(request, token) {
78
+ const auth = String(request.headers.authorization ?? "");
79
+ const xKey = String(request.headers["x-api-key"] ?? "");
80
+ return auth === `Bearer ${token}` || xKey === token;
81
+ }
82
+
83
+ function copyForwardHeaders(headers) {
84
+ const out = {};
85
+ for (const [key, value] of Object.entries(headers)) {
86
+ if (["host", "authorization", "x-api-key", "content-length"].includes(key.toLowerCase())) continue;
87
+ if (value !== undefined) out[key] = Array.isArray(value) ? value.join(", ") : value;
88
+ }
89
+ return out;
90
+ }
91
+
92
+ function readBody(request) {
93
+ return new Promise((resolve, reject) => {
94
+ const chunks = [];
95
+ request.on("data", chunk => chunks.push(chunk));
96
+ request.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
97
+ request.on("error", reject);
98
+ });
99
+ }
100
+
101
+ function writeJSON(response, status, payload) {
102
+ response.writeHead(status, { "content-type": "application/json" });
103
+ response.end(JSON.stringify(payload));
104
+ }
105
+
106
+ function readArg(name) {
107
+ const index = process.argv.indexOf(name);
108
+ return index >= 0 ? process.argv[index + 1] : "";
109
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@aurora/state",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./src/index.js"
8
+ }
9
+ }
@@ -0,0 +1,57 @@
1
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+
5
+ export const AURORA_HOME = process.env.AURORA_HOME || join(homedir(), ".aurora");
6
+ export const STATE_PATH = join(AURORA_HOME, "agent-state.json");
7
+ export const ACCOUNT_PATH = join(AURORA_HOME, "account.json");
8
+ export const SIDECAR_PATH = join(AURORA_HOME, "sidecar.json");
9
+ export const CLAUDE_HOME = join(AURORA_HOME, "clients", "claude");
10
+ export const CODEX_HOME = join(AURORA_HOME, "clients", "codex");
11
+
12
+ export async function ensureLayout() {
13
+ await mkdir(AURORA_HOME, { recursive: true });
14
+ await mkdir(CLAUDE_HOME, { recursive: true });
15
+ await mkdir(CODEX_HOME, { recursive: true });
16
+ }
17
+
18
+ export async function readState() {
19
+ try {
20
+ return JSON.parse(await readFile(STATE_PATH, "utf8"));
21
+ } catch {
22
+ return {
23
+ gatewayURL: "https://auroramos.com",
24
+ controlPlaneURL: "https://auroramos.com/api/v1"
25
+ };
26
+ }
27
+ }
28
+
29
+ export async function writeState(next) {
30
+ await ensureLayout();
31
+ await writeFile(STATE_PATH, JSON.stringify(next, null, 2) + "\n", { mode: 0o600 });
32
+ }
33
+
34
+ export async function readAccount() {
35
+ try {
36
+ return JSON.parse(await readFile(ACCOUNT_PATH, "utf8"));
37
+ } catch {
38
+ return {
39
+ controlPlaneURL: "https://auroramos.com/api/v1",
40
+ gatewayURL: "https://auroramos.com"
41
+ };
42
+ }
43
+ }
44
+
45
+ export async function writeAccount(next) {
46
+ await ensureLayout();
47
+ await writeFile(ACCOUNT_PATH, JSON.stringify(next, null, 2) + "\n", { mode: 0o600 });
48
+ }
49
+
50
+ export async function writeSidecarInfo(info) {
51
+ await ensureLayout();
52
+ await writeFile(SIDECAR_PATH, JSON.stringify(info, null, 2) + "\n", { mode: 0o600 });
53
+ }
54
+
55
+ export async function readSidecarInfo() {
56
+ return JSON.parse(await readFile(SIDECAR_PATH, "utf8"));
57
+ }
@@ -1,106 +0,0 @@
1
- #!/usr/bin/env node
2
- // Replaces the installed Unix npm shim with a launcher that execs the native binary.
3
-
4
- import { chmodSync, existsSync, readFileSync, writeFileSync } from "node:fs";
5
- import path from "node:path";
6
- import { fileURLToPath } from "node:url";
7
-
8
- if (process.platform === "win32") {
9
- process.exit(0);
10
- }
11
-
12
- const __filename = fileURLToPath(import.meta.url);
13
- const packageRoot = path.resolve(path.dirname(__filename), "..");
14
- const binDir = path.join(packageRoot, "bin");
15
- const entryPath = path.join(binDir, "aurora.js");
16
- const nodeEntryPath = path.join(binDir, "aurora-node.js");
17
-
18
- if (!existsSync(entryPath)) {
19
- process.exit(0);
20
- }
21
-
22
- if (!existsSync(nodeEntryPath)) {
23
- writeFileSync(nodeEntryPath, readFileSync(entryPath));
24
- chmodSync(nodeEntryPath, 0o755);
25
- }
26
-
27
- const launcher = `#!/bin/sh
28
- # Aurora Code POSIX launcher. Generated at npm install time.
29
-
30
- set -e
31
-
32
- resolve_dir() {
33
- CDPATH= cd -- "$1" 2>/dev/null && pwd -P
34
- }
35
-
36
- SELF=$0
37
- while [ -L "$SELF" ]; do
38
- LINK=$(readlink "$SELF")
39
- case "$LINK" in
40
- /*) SELF=$LINK ;;
41
- *) SELF=$(dirname -- "$SELF")/$LINK ;;
42
- esac
43
- done
44
-
45
- BIN_DIR=$(resolve_dir "$(dirname -- "$SELF")")
46
- PACKAGE_ROOT=$(resolve_dir "$BIN_DIR/..")
47
-
48
- case "$(uname -s)" in
49
- Darwin) OS=apple-darwin ;;
50
- Linux) OS=unknown-linux-gnu ;;
51
- *) exec node "$BIN_DIR/aurora-node.js" "$@" ;;
52
- esac
53
-
54
- case "$(uname -m)" in
55
- arm64|aarch64) ARCH=aarch64 ;;
56
- x86_64|amd64) ARCH=x86_64 ;;
57
- *) exec node "$BIN_DIR/aurora-node.js" "$@" ;;
58
- esac
59
-
60
- TARGET="$ARCH-$OS"
61
- case "$TARGET" in
62
- aarch64-apple-darwin) NATIVE_PACKAGE="@auroraflow/code-darwin-arm64" ;;
63
- x86_64-apple-darwin) NATIVE_PACKAGE="@auroraflow/code-darwin-x64" ;;
64
- aarch64-unknown-linux-gnu) NATIVE_PACKAGE="@auroraflow/code-linux-arm64" ;;
65
- x86_64-unknown-linux-gnu) NATIVE_PACKAGE="@auroraflow/code-linux-x64" ;;
66
- *) exec node "$BIN_DIR/aurora-node.js" "$@" ;;
67
- esac
68
-
69
- NATIVE_ROOT="$PACKAGE_ROOT/node_modules/$NATIVE_PACKAGE/vendor/$TARGET"
70
- BINARY="$NATIVE_ROOT/bin/aurora"
71
- if [ ! -x "$BINARY" ]; then
72
- NATIVE_ROOT="$PACKAGE_ROOT/vendor/$TARGET"
73
- BINARY="$NATIVE_ROOT/bin/aurora"
74
- fi
75
-
76
- if [ ! -x "$BINARY" ]; then
77
- exec node "$BIN_DIR/aurora-node.js" "$@"
78
- fi
79
-
80
- if [ -z "\${AURORA_HOME+x}" ] || [ -z "$AURORA_HOME" ]; then
81
- AURORA_HOME="$HOME/.aurora"
82
- fi
83
-
84
- export AURORA_HOME
85
- export CODEX_HOME="$AURORA_HOME"
86
- export AURORA_MANAGED_BY_NPM=1
87
- export CODEX_MANAGED_BY_NPM=1
88
- export AURORA_MANAGED_PACKAGE_ROOT="$PACKAGE_ROOT"
89
- export CODEX_MANAGED_PACKAGE_ROOT="$PACKAGE_ROOT"
90
-
91
- if [ -d "$NATIVE_ROOT/aurora-path" ]; then
92
- PATH="$NATIVE_ROOT/aurora-path:$PATH"
93
- elif [ -d "$NATIVE_ROOT/path" ]; then
94
- PATH="$NATIVE_ROOT/path:$PATH"
95
- fi
96
- export PATH
97
-
98
- if [ -t 1 ]; then
99
- printf '\\033]0;aurora\\007'
100
- fi
101
-
102
- exec "$BINARY" "$@"
103
- `;
104
-
105
- writeFileSync(entryPath, launcher);
106
- chmodSync(entryPath, 0o755);