@ozyman42/ozy-cli 0.4.9-linux-x64.0 → 0.4.9
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/LICENSE +21 -0
- package/README.md +8 -0
- package/bin/ozy +209 -0
- package/bin/ozy-signing-agent +209 -0
- package/bin/ozy-ssh-keygen +209 -0
- package/bin/ozy-virtual-security-key +209 -0
- package/dist/commands/git/hosts.js +18 -0
- package/dist/commands/git/hosts.js.map +1 -0
- package/dist/commands/git/index.js +8 -0
- package/dist/commands/git/index.js.map +1 -0
- package/dist/commands/git/setup.js +145 -0
- package/dist/commands/git/setup.js.map +1 -0
- package/dist/commands/index.js +13 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/npm/index.js +7 -0
- package/dist/commands/npm/index.js.map +1 -0
- package/dist/commands/npm/setup/git-remote.js +66 -0
- package/dist/commands/npm/setup/git-remote.js.map +1 -0
- package/dist/commands/npm/setup/index.js +168 -0
- package/dist/commands/npm/setup/index.js.map +1 -0
- package/dist/commands/npm/setup/npm-auth.js +62 -0
- package/dist/commands/npm/setup/npm-auth.js.map +1 -0
- package/dist/commands/npm/setup/package-json-validate.js +47 -0
- package/dist/commands/npm/setup/package-json-validate.js.map +1 -0
- package/dist/commands/npm/setup/package-registry.js +20 -0
- package/dist/commands/npm/setup/package-registry.js.map +1 -0
- package/dist/commands/npm/setup/setup.test.js +95 -0
- package/dist/commands/npm/setup/setup.test.js.map +1 -0
- package/dist/commands/npm/setup/trusted-publishing.js +84 -0
- package/dist/commands/npm/setup/trusted-publishing.js.map +1 -0
- package/dist/commands/npm/setup/workflow.js +19 -0
- package/dist/commands/npm/setup/workflow.js.map +1 -0
- package/dist/commands/ssh/get-sk-credential.js +104 -0
- package/dist/commands/ssh/get-sk-credential.js.map +1 -0
- package/dist/commands/ssh/index.js +7 -0
- package/dist/commands/ssh/index.js.map +1 -0
- package/dist/commands/upgrade.js +236 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/common/command.js +15 -0
- package/dist/common/command.js.map +1 -0
- package/dist/common/constants.js +25 -0
- package/dist/common/constants.js.map +1 -0
- package/dist/common/effective-modules-extensions.js +13 -0
- package/dist/common/effective-modules-extensions.js.map +1 -0
- package/dist/common/log.js +4 -0
- package/dist/common/log.js.map +1 -0
- package/dist/common/render-caller-tree.js +20 -0
- package/dist/common/render-caller-tree.js.map +1 -0
- package/dist/entrypoints/ozy-signing-agent.js +48 -0
- package/dist/entrypoints/ozy-signing-agent.js.map +1 -0
- package/dist/entrypoints/ozy-ssh-keygen.js +9 -0
- package/dist/entrypoints/ozy-ssh-keygen.js.map +1 -0
- package/dist/entrypoints/ozy-virtual-security-key.js +18 -0
- package/dist/entrypoints/ozy-virtual-security-key.js.map +1 -0
- package/dist/entrypoints/ozy.js +3 -0
- package/dist/entrypoints/ozy.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/thing.js +4 -0
- package/dist/internal/thing.js.map +1 -0
- package/dist/modules/cli/agent-client/impl.js +109 -0
- package/dist/modules/cli/agent-client/impl.js.map +1 -0
- package/dist/modules/cli/agent-client/interface.js +11 -0
- package/dist/modules/cli/agent-client/interface.js.map +1 -0
- package/dist/modules/cli/git/impl.js +124 -0
- package/dist/modules/cli/git/impl.js.map +1 -0
- package/dist/modules/cli/git/interface.js +3 -0
- package/dist/modules/cli/git/interface.js.map +1 -0
- package/dist/modules/cli/git/submodule/fix.js +257 -0
- package/dist/modules/cli/git/submodule/fix.js.map +1 -0
- package/dist/modules/cli/git/submodule/git-state.js +154 -0
- package/dist/modules/cli/git/submodule/git-state.js.map +1 -0
- package/dist/modules/cli/git/submodule/gitmodules.js +113 -0
- package/dist/modules/cli/git/submodule/gitmodules.js.map +1 -0
- package/dist/modules/cli/git/submodule/printer.js +232 -0
- package/dist/modules/cli/git/submodule/printer.js.map +1 -0
- package/dist/modules/cli/git/submodule/resolve-git-dir.js +16 -0
- package/dist/modules/cli/git/submodule/resolve-git-dir.js.map +1 -0
- package/dist/modules/cli/github/impl.js +137 -0
- package/dist/modules/cli/github/impl.js.map +1 -0
- package/dist/modules/cli/github/interface.js +2 -0
- package/dist/modules/cli/github/interface.js.map +1 -0
- package/dist/modules/cli/index.js +9 -0
- package/dist/modules/cli/index.js.map +1 -0
- package/dist/modules/common/crypto/impl.js +133 -0
- package/dist/modules/common/crypto/impl.js.map +1 -0
- package/dist/modules/common/crypto/interface.js +2 -0
- package/dist/modules/common/crypto/interface.js.map +1 -0
- package/dist/modules/common/index.js +10 -0
- package/dist/modules/common/index.js.map +1 -0
- package/dist/modules/common/kep-map-store/impl.js +42 -0
- package/dist/modules/common/kep-map-store/impl.js.map +1 -0
- package/dist/modules/common/kep-map-store/interface.js +2 -0
- package/dist/modules/common/kep-map-store/interface.js.map +1 -0
- package/dist/modules/common/os-platform/caller-info.js +132 -0
- package/dist/modules/common/os-platform/caller-info.js.map +1 -0
- package/dist/modules/common/os-platform/impl.js +95 -0
- package/dist/modules/common/os-platform/impl.js.map +1 -0
- package/dist/modules/common/os-platform/interface.js +2 -0
- package/dist/modules/common/os-platform/interface.js.map +1 -0
- package/dist/modules/common/os-platform/virtual-hid/index.js +12 -0
- package/dist/modules/common/os-platform/virtual-hid/index.js.map +1 -0
- package/dist/modules/common/os-platform/virtual-hid/linux.js +5 -0
- package/dist/modules/common/os-platform/virtual-hid/linux.js.map +1 -0
- package/dist/modules/common/os-platform/virtual-hid/mac.js +119 -0
- package/dist/modules/common/os-platform/virtual-hid/mac.js.map +1 -0
- package/dist/modules/common/os-platform/virtual-hid/windows.js +5 -0
- package/dist/modules/common/os-platform/virtual-hid/windows.js.map +1 -0
- package/dist/modules/common/ssh-config/impl.js +116 -0
- package/dist/modules/common/ssh-config/impl.js.map +1 -0
- package/dist/modules/common/ssh-config/interface.js +10 -0
- package/dist/modules/common/ssh-config/interface.js.map +1 -0
- package/dist/modules/ssh-agent/index.js +8 -0
- package/dist/modules/ssh-agent/index.js.map +1 -0
- package/dist/modules/ssh-agent/session/impl.js +265 -0
- package/dist/modules/ssh-agent/session/impl.js.map +1 -0
- package/dist/modules/ssh-agent/session/interface-rpc.js +20 -0
- package/dist/modules/ssh-agent/session/interface-rpc.js.map +1 -0
- package/dist/modules/ssh-agent/session/interface.js +32 -0
- package/dist/modules/ssh-agent/session/interface.js.map +1 -0
- package/dist/modules/ssh-agent/session/passkey-prf-page.js +204 -0
- package/dist/modules/ssh-agent/session/passkey-prf-page.js.map +1 -0
- package/dist/modules/ssh-agent/session/prf-flow.js +103 -0
- package/dist/modules/ssh-agent/session/prf-flow.js.map +1 -0
- package/dist/modules/ssh-agent/ssh-agent/impl.js +117 -0
- package/dist/modules/ssh-agent/ssh-agent/impl.js.map +1 -0
- package/dist/modules/ssh-agent/ssh-agent/interface.js +2 -0
- package/dist/modules/ssh-agent/ssh-agent/interface.js.map +1 -0
- package/dist/scripts/build.js +444 -0
- package/dist/scripts/build.js.map +1 -0
- package/dist/scripts/check-npm-version.js +8 -0
- package/dist/scripts/check-npm-version.js.map +1 -0
- package/dist/scripts/constants.js +12 -0
- package/dist/scripts/constants.js.map +1 -0
- package/dist/scripts/kill-existing-agent.js +21 -0
- package/dist/scripts/kill-existing-agent.js.map +1 -0
- package/dist/scripts/publish.js +83 -0
- package/dist/scripts/publish.js.map +1 -0
- package/install.js +209 -0
- package/package.json +58 -11
- package/src/commands/git/hosts.ts +20 -0
- package/src/commands/git/index.ts +9 -0
- package/src/commands/git/setup.ts +182 -0
- package/src/commands/index.ts +15 -0
- package/src/commands/npm/index.ts +8 -0
- package/src/commands/npm/setup/git-remote.ts +78 -0
- package/src/commands/npm/setup/index.ts +189 -0
- package/src/commands/npm/setup/npm-auth.ts +58 -0
- package/src/commands/npm/setup/package-json-validate.ts +68 -0
- package/src/commands/npm/setup/package-registry.ts +24 -0
- package/src/commands/npm/setup/publish-workflow.yml +35 -0
- package/src/commands/npm/setup/setup.test.ts +117 -0
- package/src/commands/npm/setup/trusted-publishing.ts +106 -0
- package/src/commands/npm/setup/workflow.ts +20 -0
- package/src/commands/ssh/get-sk-credential.ts +110 -0
- package/src/commands/ssh/index.ts +8 -0
- package/src/commands/upgrade.ts +261 -0
- package/src/common/command.ts +16 -0
- package/src/common/constants.ts +26 -0
- package/src/common/effective-modules-extensions.ts +24 -0
- package/src/common/log.ts +3 -0
- package/src/common/render-caller-tree.ts +22 -0
- package/src/entrypoints/ozy-signing-agent.ts +48 -0
- package/src/entrypoints/ozy-ssh-keygen.ts +10 -0
- package/src/entrypoints/ozy-virtual-security-key.ts +21 -0
- package/src/entrypoints/ozy.ts +2 -0
- package/src/index.ts +1 -0
- package/src/internal/thing.ts +3 -0
- package/src/modules/cli/agent-client/impl.ts +152 -0
- package/src/modules/cli/agent-client/interface.ts +17 -0
- package/src/modules/cli/git/impl.ts +133 -0
- package/src/modules/cli/git/interface.ts +23 -0
- package/src/modules/cli/git/submodule/fix.ts +298 -0
- package/src/modules/cli/git/submodule/git-state.ts +217 -0
- package/src/modules/cli/git/submodule/gitmodules.ts +126 -0
- package/src/modules/cli/git/submodule/printer.ts +256 -0
- package/src/modules/cli/git/submodule/resolve-git-dir.ts +14 -0
- package/src/modules/cli/github/impl.ts +169 -0
- package/src/modules/cli/github/interface.ts +29 -0
- package/src/modules/cli/index.ts +16 -0
- package/src/modules/common/crypto/impl.ts +173 -0
- package/src/modules/common/crypto/interface.ts +20 -0
- package/src/modules/common/index.ts +19 -0
- package/src/modules/common/kep-map-store/impl.ts +47 -0
- package/src/modules/common/kep-map-store/interface.ts +9 -0
- package/src/modules/common/os-platform/caller-info.ts +152 -0
- package/src/modules/common/os-platform/impl.ts +91 -0
- package/src/modules/common/os-platform/interface.ts +16 -0
- package/src/modules/common/os-platform/virtual-hid/index.ts +12 -0
- package/src/modules/common/os-platform/virtual-hid/linux.ts +7 -0
- package/src/modules/common/os-platform/virtual-hid/mac.ts +150 -0
- package/src/modules/common/os-platform/virtual-hid/windows.ts +7 -0
- package/src/modules/common/ssh-config/impl.ts +130 -0
- package/src/modules/common/ssh-config/interface.ts +33 -0
- package/src/modules/ssh-agent/index.ts +13 -0
- package/src/modules/ssh-agent/session/agent-notes.md +210 -0
- package/src/modules/ssh-agent/session/design.md +2 -0
- package/src/modules/ssh-agent/session/html-refactor.md +23 -0
- package/src/modules/ssh-agent/session/impl.ts +328 -0
- package/src/modules/ssh-agent/session/interface-rpc.ts +24 -0
- package/src/modules/ssh-agent/session/interface.ts +62 -0
- package/src/modules/ssh-agent/session/passkey-prf-page.ts +224 -0
- package/src/modules/ssh-agent/session/prf-flow.ts +152 -0
- package/src/modules/ssh-agent/ssh-agent/impl.ts +136 -0
- package/src/modules/ssh-agent/ssh-agent/interface.ts +9 -0
- package/src/scripts/build.ts +559 -0
- package/src/scripts/check-npm-version.ts +7 -0
- package/src/scripts/command-launcher.js.ejs +186 -0
- package/src/scripts/constants.ts +11 -0
- package/src/scripts/kill-existing-agent.ts +22 -0
- package/src/scripts/publish.ts +89 -0
- package/src/scripts/windows-bin-shims.md +1104 -0
- package/multi-call-binary +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alexander Leung
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
- Set up any git repo to use a passkey-based SSH key.
|
|
2
|
+
Auto registers SSH authn and signing keys with github.
|
|
3
|
+
- Auto provision npm packages and set up trusted publishing. Precursor to jive.sh tool
|
|
4
|
+
|
|
5
|
+
## Follow-up investigations
|
|
6
|
+
|
|
7
|
+
- Verify Windows package-manager behavior when an entrypoint command name includes literal `.exe` text, including names that already end with `.exe` such as `src/entrypoints/foo.exe.ts`.
|
|
8
|
+
- Define how the build should handle source files that import runtime assets or modules outside `src`.
|
package/bin/ozy
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import {
|
|
5
|
+
chmodSync,
|
|
6
|
+
copyFileSync,
|
|
7
|
+
existsSync,
|
|
8
|
+
linkSync,
|
|
9
|
+
mkdirSync,
|
|
10
|
+
readFileSync,
|
|
11
|
+
renameSync,
|
|
12
|
+
rmSync,
|
|
13
|
+
writeFileSync,
|
|
14
|
+
} from "node:fs";
|
|
15
|
+
import { basename, dirname, join } from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
|
|
18
|
+
const PLATFORM_MAP = {
|
|
19
|
+
"darwin-arm64": "darwin-arm64",
|
|
20
|
+
"darwin-x64": "darwin-x64",
|
|
21
|
+
"linux-arm64": "linux-arm64",
|
|
22
|
+
"linux-x64": "linux-x64",
|
|
23
|
+
"win32-x64": "windows-x64"
|
|
24
|
+
};
|
|
25
|
+
const PLATFORM_PACKAGES = {
|
|
26
|
+
"darwin-arm64": "@ozyman42/ozy-cli-darwin-arm64",
|
|
27
|
+
"darwin-x64": "@ozyman42/ozy-cli-darwin-x64",
|
|
28
|
+
"linux-arm64": "@ozyman42/ozy-cli-linux-arm64",
|
|
29
|
+
"linux-x64": "@ozyman42/ozy-cli-linux-x64",
|
|
30
|
+
"windows-x64": "@ozyman42/ozy-cli-windows-x64"
|
|
31
|
+
};
|
|
32
|
+
const PLATFORM_BINARIES = {
|
|
33
|
+
"darwin-arm64": "multi-call-binary",
|
|
34
|
+
"darwin-x64": "multi-call-binary",
|
|
35
|
+
"linux-arm64": "multi-call-binary",
|
|
36
|
+
"linux-x64": "multi-call-binary",
|
|
37
|
+
"windows-x64": "multi-call-binary.exe"
|
|
38
|
+
};
|
|
39
|
+
const COMMANDS = [
|
|
40
|
+
"ozy",
|
|
41
|
+
"ozy-signing-agent",
|
|
42
|
+
"ozy-ssh-keygen",
|
|
43
|
+
"ozy-virtual-security-key"
|
|
44
|
+
];
|
|
45
|
+
const BIN_DIR = "bin";
|
|
46
|
+
const INSTALL_SCRIPT = "install.js";
|
|
47
|
+
// Root install.js repairs command targets; bin launchers repair and then execute.
|
|
48
|
+
const IS_INSTALL_SCRIPT = false;
|
|
49
|
+
const WINDOWS_EXECUTABLE_SUFFIX = ".exe";
|
|
50
|
+
const INSTALLED_JSON = "installed.json";
|
|
51
|
+
|
|
52
|
+
const require = createRequire(import.meta.url);
|
|
53
|
+
const launcherPath = fileURLToPath(import.meta.url);
|
|
54
|
+
const launcherDir = dirname(launcherPath);
|
|
55
|
+
const packageDir = IS_INSTALL_SCRIPT ? launcherDir : dirname(launcherDir);
|
|
56
|
+
const commandTargetDir = join(packageDir, BIN_DIR);
|
|
57
|
+
const rootInstallScriptPath = join(packageDir, INSTALL_SCRIPT);
|
|
58
|
+
|
|
59
|
+
function fail(message) {
|
|
60
|
+
console.error(message);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function currentPlatformKey() {
|
|
65
|
+
const platformKey = PLATFORM_MAP[`${process.platform}-${process.arch}`];
|
|
66
|
+
if (!platformKey) {
|
|
67
|
+
fail(`Unsupported platform: ${process.platform}-${process.arch}`);
|
|
68
|
+
}
|
|
69
|
+
return platformKey;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function currentPlatformPackageName() {
|
|
73
|
+
const platformKey = currentPlatformKey();
|
|
74
|
+
const packageName = PLATFORM_PACKAGES[platformKey];
|
|
75
|
+
if (!packageName) {
|
|
76
|
+
fail(`No platform package is configured for ${platformKey}`);
|
|
77
|
+
}
|
|
78
|
+
return packageName;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* When a Jive library contains any number of CLIs (entrypoints or agents), then the base package
|
|
83
|
+
* will have an optional dependency for each possible architecture, with those platform-specific
|
|
84
|
+
* packages containing a platform build of the CLI.
|
|
85
|
+
* @returns the path to the platform binary and the exact version of the platform package.
|
|
86
|
+
*/
|
|
87
|
+
function currentPlatformPackage() {
|
|
88
|
+
const platformKey = currentPlatformKey();
|
|
89
|
+
const binaryFile = PLATFORM_BINARIES[platformKey];
|
|
90
|
+
if (!binaryFile) {
|
|
91
|
+
fail(`No platform binary is configured for ${platformKey}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const packageName = currentPlatformPackageName();
|
|
95
|
+
try {
|
|
96
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
97
|
+
const packageDir = dirname(packageJsonPath);
|
|
98
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
99
|
+
return {
|
|
100
|
+
binaryPath: join(packageDir, binaryFile),
|
|
101
|
+
version: packageJson.version,
|
|
102
|
+
};
|
|
103
|
+
} catch (error) {
|
|
104
|
+
fail(`Could not resolve optional platform package ${packageName}. Reinstall dependencies for ${process.platform}-${process.arch}.`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function commandTargetPath(command) {
|
|
109
|
+
const suffix = process.platform === "win32" ? WINDOWS_EXECUTABLE_SUFFIX : "";
|
|
110
|
+
return join(commandTargetDir, `${command}${suffix}`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function installedJsonPath() {
|
|
114
|
+
return join(commandTargetDir, INSTALLED_JSON);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function windowsTargetsAreCurrent(version) {
|
|
118
|
+
if (process.platform !== "win32") return false;
|
|
119
|
+
if (!COMMANDS.every((command) => existsSync(commandTargetPath(command)))) return false;
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
const installed = JSON.parse(readFileSync(installedJsonPath(), "utf-8"));
|
|
123
|
+
return installed.version === version;
|
|
124
|
+
} catch {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function linkOrCopyFirstExecutable(sourcePath, targetPath) {
|
|
130
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
131
|
+
const tempPath = `${targetPath}.${process.pid}.${Date.now()}.tmp${process.platform === "win32" ? WINDOWS_EXECUTABLE_SUFFIX : ""}`;
|
|
132
|
+
rmSync(tempPath, { force: true });
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
try {
|
|
136
|
+
linkSync(sourcePath, tempPath);
|
|
137
|
+
} catch {
|
|
138
|
+
copyFileSync(sourcePath, tempPath);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
chmodSync(tempPath, 0o755);
|
|
142
|
+
rmSync(targetPath, { force: true });
|
|
143
|
+
renameSync(tempPath, targetPath);
|
|
144
|
+
} finally {
|
|
145
|
+
rmSync(tempPath, { force: true });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function hardLinkCommandTarget(sourcePath, targetPath) {
|
|
150
|
+
if (sourcePath === targetPath) return;
|
|
151
|
+
|
|
152
|
+
const tempPath = `${targetPath}.${process.pid}.${Date.now()}.tmp${process.platform === "win32" ? WINDOWS_EXECUTABLE_SUFFIX : ""}`;
|
|
153
|
+
rmSync(tempPath, { force: true });
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
linkSync(sourcePath, tempPath);
|
|
157
|
+
chmodSync(tempPath, 0o755);
|
|
158
|
+
rmSync(targetPath, { force: true });
|
|
159
|
+
renameSync(tempPath, targetPath);
|
|
160
|
+
} finally {
|
|
161
|
+
rmSync(tempPath, { force: true });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function repairCommandTargets() {
|
|
166
|
+
const platformPackage = currentPlatformPackage();
|
|
167
|
+
|
|
168
|
+
if (windowsTargetsAreCurrent(platformPackage.version)) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const firstTargetPath = commandTargetPath(COMMANDS[0]);
|
|
173
|
+
linkOrCopyFirstExecutable(platformPackage.binaryPath, firstTargetPath);
|
|
174
|
+
|
|
175
|
+
for (const command of COMMANDS.slice(1)) {
|
|
176
|
+
hardLinkCommandTarget(firstTargetPath, commandTargetPath(command));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (process.platform === "win32") {
|
|
180
|
+
writeFileSync(installedJsonPath(), `${JSON.stringify({ version: platformPackage.version }, null, 2)}\n`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function runExecutable(executablePath) {
|
|
185
|
+
const result = spawnSync(executablePath, process.argv.slice(2), { stdio: "inherit" });
|
|
186
|
+
|
|
187
|
+
if (result.error) {
|
|
188
|
+
fail(result.error.message);
|
|
189
|
+
}
|
|
190
|
+
if (result.status !== 0) {
|
|
191
|
+
process.exit(result.status ?? 1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function removeInstallScript() {
|
|
196
|
+
try {
|
|
197
|
+
rmSync(rootInstallScriptPath, { force: true });
|
|
198
|
+
// TODO: should we also remove the postinstall script line from package.json?
|
|
199
|
+
} catch {
|
|
200
|
+
// Cleanup is best-effort; failing to remove install.js should not fail package installation.
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
repairCommandTargets();
|
|
205
|
+
removeInstallScript();
|
|
206
|
+
if (!IS_INSTALL_SCRIPT) {
|
|
207
|
+
const commandName = basename(launcherPath);
|
|
208
|
+
runExecutable(commandTargetPath(commandName));
|
|
209
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import {
|
|
5
|
+
chmodSync,
|
|
6
|
+
copyFileSync,
|
|
7
|
+
existsSync,
|
|
8
|
+
linkSync,
|
|
9
|
+
mkdirSync,
|
|
10
|
+
readFileSync,
|
|
11
|
+
renameSync,
|
|
12
|
+
rmSync,
|
|
13
|
+
writeFileSync,
|
|
14
|
+
} from "node:fs";
|
|
15
|
+
import { basename, dirname, join } from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
|
|
18
|
+
const PLATFORM_MAP = {
|
|
19
|
+
"darwin-arm64": "darwin-arm64",
|
|
20
|
+
"darwin-x64": "darwin-x64",
|
|
21
|
+
"linux-arm64": "linux-arm64",
|
|
22
|
+
"linux-x64": "linux-x64",
|
|
23
|
+
"win32-x64": "windows-x64"
|
|
24
|
+
};
|
|
25
|
+
const PLATFORM_PACKAGES = {
|
|
26
|
+
"darwin-arm64": "@ozyman42/ozy-cli-darwin-arm64",
|
|
27
|
+
"darwin-x64": "@ozyman42/ozy-cli-darwin-x64",
|
|
28
|
+
"linux-arm64": "@ozyman42/ozy-cli-linux-arm64",
|
|
29
|
+
"linux-x64": "@ozyman42/ozy-cli-linux-x64",
|
|
30
|
+
"windows-x64": "@ozyman42/ozy-cli-windows-x64"
|
|
31
|
+
};
|
|
32
|
+
const PLATFORM_BINARIES = {
|
|
33
|
+
"darwin-arm64": "multi-call-binary",
|
|
34
|
+
"darwin-x64": "multi-call-binary",
|
|
35
|
+
"linux-arm64": "multi-call-binary",
|
|
36
|
+
"linux-x64": "multi-call-binary",
|
|
37
|
+
"windows-x64": "multi-call-binary.exe"
|
|
38
|
+
};
|
|
39
|
+
const COMMANDS = [
|
|
40
|
+
"ozy",
|
|
41
|
+
"ozy-signing-agent",
|
|
42
|
+
"ozy-ssh-keygen",
|
|
43
|
+
"ozy-virtual-security-key"
|
|
44
|
+
];
|
|
45
|
+
const BIN_DIR = "bin";
|
|
46
|
+
const INSTALL_SCRIPT = "install.js";
|
|
47
|
+
// Root install.js repairs command targets; bin launchers repair and then execute.
|
|
48
|
+
const IS_INSTALL_SCRIPT = false;
|
|
49
|
+
const WINDOWS_EXECUTABLE_SUFFIX = ".exe";
|
|
50
|
+
const INSTALLED_JSON = "installed.json";
|
|
51
|
+
|
|
52
|
+
const require = createRequire(import.meta.url);
|
|
53
|
+
const launcherPath = fileURLToPath(import.meta.url);
|
|
54
|
+
const launcherDir = dirname(launcherPath);
|
|
55
|
+
const packageDir = IS_INSTALL_SCRIPT ? launcherDir : dirname(launcherDir);
|
|
56
|
+
const commandTargetDir = join(packageDir, BIN_DIR);
|
|
57
|
+
const rootInstallScriptPath = join(packageDir, INSTALL_SCRIPT);
|
|
58
|
+
|
|
59
|
+
function fail(message) {
|
|
60
|
+
console.error(message);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function currentPlatformKey() {
|
|
65
|
+
const platformKey = PLATFORM_MAP[`${process.platform}-${process.arch}`];
|
|
66
|
+
if (!platformKey) {
|
|
67
|
+
fail(`Unsupported platform: ${process.platform}-${process.arch}`);
|
|
68
|
+
}
|
|
69
|
+
return platformKey;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function currentPlatformPackageName() {
|
|
73
|
+
const platformKey = currentPlatformKey();
|
|
74
|
+
const packageName = PLATFORM_PACKAGES[platformKey];
|
|
75
|
+
if (!packageName) {
|
|
76
|
+
fail(`No platform package is configured for ${platformKey}`);
|
|
77
|
+
}
|
|
78
|
+
return packageName;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* When a Jive library contains any number of CLIs (entrypoints or agents), then the base package
|
|
83
|
+
* will have an optional dependency for each possible architecture, with those platform-specific
|
|
84
|
+
* packages containing a platform build of the CLI.
|
|
85
|
+
* @returns the path to the platform binary and the exact version of the platform package.
|
|
86
|
+
*/
|
|
87
|
+
function currentPlatformPackage() {
|
|
88
|
+
const platformKey = currentPlatformKey();
|
|
89
|
+
const binaryFile = PLATFORM_BINARIES[platformKey];
|
|
90
|
+
if (!binaryFile) {
|
|
91
|
+
fail(`No platform binary is configured for ${platformKey}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const packageName = currentPlatformPackageName();
|
|
95
|
+
try {
|
|
96
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
97
|
+
const packageDir = dirname(packageJsonPath);
|
|
98
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
99
|
+
return {
|
|
100
|
+
binaryPath: join(packageDir, binaryFile),
|
|
101
|
+
version: packageJson.version,
|
|
102
|
+
};
|
|
103
|
+
} catch (error) {
|
|
104
|
+
fail(`Could not resolve optional platform package ${packageName}. Reinstall dependencies for ${process.platform}-${process.arch}.`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function commandTargetPath(command) {
|
|
109
|
+
const suffix = process.platform === "win32" ? WINDOWS_EXECUTABLE_SUFFIX : "";
|
|
110
|
+
return join(commandTargetDir, `${command}${suffix}`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function installedJsonPath() {
|
|
114
|
+
return join(commandTargetDir, INSTALLED_JSON);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function windowsTargetsAreCurrent(version) {
|
|
118
|
+
if (process.platform !== "win32") return false;
|
|
119
|
+
if (!COMMANDS.every((command) => existsSync(commandTargetPath(command)))) return false;
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
const installed = JSON.parse(readFileSync(installedJsonPath(), "utf-8"));
|
|
123
|
+
return installed.version === version;
|
|
124
|
+
} catch {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function linkOrCopyFirstExecutable(sourcePath, targetPath) {
|
|
130
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
131
|
+
const tempPath = `${targetPath}.${process.pid}.${Date.now()}.tmp${process.platform === "win32" ? WINDOWS_EXECUTABLE_SUFFIX : ""}`;
|
|
132
|
+
rmSync(tempPath, { force: true });
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
try {
|
|
136
|
+
linkSync(sourcePath, tempPath);
|
|
137
|
+
} catch {
|
|
138
|
+
copyFileSync(sourcePath, tempPath);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
chmodSync(tempPath, 0o755);
|
|
142
|
+
rmSync(targetPath, { force: true });
|
|
143
|
+
renameSync(tempPath, targetPath);
|
|
144
|
+
} finally {
|
|
145
|
+
rmSync(tempPath, { force: true });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function hardLinkCommandTarget(sourcePath, targetPath) {
|
|
150
|
+
if (sourcePath === targetPath) return;
|
|
151
|
+
|
|
152
|
+
const tempPath = `${targetPath}.${process.pid}.${Date.now()}.tmp${process.platform === "win32" ? WINDOWS_EXECUTABLE_SUFFIX : ""}`;
|
|
153
|
+
rmSync(tempPath, { force: true });
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
linkSync(sourcePath, tempPath);
|
|
157
|
+
chmodSync(tempPath, 0o755);
|
|
158
|
+
rmSync(targetPath, { force: true });
|
|
159
|
+
renameSync(tempPath, targetPath);
|
|
160
|
+
} finally {
|
|
161
|
+
rmSync(tempPath, { force: true });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function repairCommandTargets() {
|
|
166
|
+
const platformPackage = currentPlatformPackage();
|
|
167
|
+
|
|
168
|
+
if (windowsTargetsAreCurrent(platformPackage.version)) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const firstTargetPath = commandTargetPath(COMMANDS[0]);
|
|
173
|
+
linkOrCopyFirstExecutable(platformPackage.binaryPath, firstTargetPath);
|
|
174
|
+
|
|
175
|
+
for (const command of COMMANDS.slice(1)) {
|
|
176
|
+
hardLinkCommandTarget(firstTargetPath, commandTargetPath(command));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (process.platform === "win32") {
|
|
180
|
+
writeFileSync(installedJsonPath(), `${JSON.stringify({ version: platformPackage.version }, null, 2)}\n`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function runExecutable(executablePath) {
|
|
185
|
+
const result = spawnSync(executablePath, process.argv.slice(2), { stdio: "inherit" });
|
|
186
|
+
|
|
187
|
+
if (result.error) {
|
|
188
|
+
fail(result.error.message);
|
|
189
|
+
}
|
|
190
|
+
if (result.status !== 0) {
|
|
191
|
+
process.exit(result.status ?? 1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function removeInstallScript() {
|
|
196
|
+
try {
|
|
197
|
+
rmSync(rootInstallScriptPath, { force: true });
|
|
198
|
+
// TODO: should we also remove the postinstall script line from package.json?
|
|
199
|
+
} catch {
|
|
200
|
+
// Cleanup is best-effort; failing to remove install.js should not fail package installation.
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
repairCommandTargets();
|
|
205
|
+
removeInstallScript();
|
|
206
|
+
if (!IS_INSTALL_SCRIPT) {
|
|
207
|
+
const commandName = basename(launcherPath);
|
|
208
|
+
runExecutable(commandTargetPath(commandName));
|
|
209
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import {
|
|
5
|
+
chmodSync,
|
|
6
|
+
copyFileSync,
|
|
7
|
+
existsSync,
|
|
8
|
+
linkSync,
|
|
9
|
+
mkdirSync,
|
|
10
|
+
readFileSync,
|
|
11
|
+
renameSync,
|
|
12
|
+
rmSync,
|
|
13
|
+
writeFileSync,
|
|
14
|
+
} from "node:fs";
|
|
15
|
+
import { basename, dirname, join } from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
|
|
18
|
+
const PLATFORM_MAP = {
|
|
19
|
+
"darwin-arm64": "darwin-arm64",
|
|
20
|
+
"darwin-x64": "darwin-x64",
|
|
21
|
+
"linux-arm64": "linux-arm64",
|
|
22
|
+
"linux-x64": "linux-x64",
|
|
23
|
+
"win32-x64": "windows-x64"
|
|
24
|
+
};
|
|
25
|
+
const PLATFORM_PACKAGES = {
|
|
26
|
+
"darwin-arm64": "@ozyman42/ozy-cli-darwin-arm64",
|
|
27
|
+
"darwin-x64": "@ozyman42/ozy-cli-darwin-x64",
|
|
28
|
+
"linux-arm64": "@ozyman42/ozy-cli-linux-arm64",
|
|
29
|
+
"linux-x64": "@ozyman42/ozy-cli-linux-x64",
|
|
30
|
+
"windows-x64": "@ozyman42/ozy-cli-windows-x64"
|
|
31
|
+
};
|
|
32
|
+
const PLATFORM_BINARIES = {
|
|
33
|
+
"darwin-arm64": "multi-call-binary",
|
|
34
|
+
"darwin-x64": "multi-call-binary",
|
|
35
|
+
"linux-arm64": "multi-call-binary",
|
|
36
|
+
"linux-x64": "multi-call-binary",
|
|
37
|
+
"windows-x64": "multi-call-binary.exe"
|
|
38
|
+
};
|
|
39
|
+
const COMMANDS = [
|
|
40
|
+
"ozy",
|
|
41
|
+
"ozy-signing-agent",
|
|
42
|
+
"ozy-ssh-keygen",
|
|
43
|
+
"ozy-virtual-security-key"
|
|
44
|
+
];
|
|
45
|
+
const BIN_DIR = "bin";
|
|
46
|
+
const INSTALL_SCRIPT = "install.js";
|
|
47
|
+
// Root install.js repairs command targets; bin launchers repair and then execute.
|
|
48
|
+
const IS_INSTALL_SCRIPT = false;
|
|
49
|
+
const WINDOWS_EXECUTABLE_SUFFIX = ".exe";
|
|
50
|
+
const INSTALLED_JSON = "installed.json";
|
|
51
|
+
|
|
52
|
+
const require = createRequire(import.meta.url);
|
|
53
|
+
const launcherPath = fileURLToPath(import.meta.url);
|
|
54
|
+
const launcherDir = dirname(launcherPath);
|
|
55
|
+
const packageDir = IS_INSTALL_SCRIPT ? launcherDir : dirname(launcherDir);
|
|
56
|
+
const commandTargetDir = join(packageDir, BIN_DIR);
|
|
57
|
+
const rootInstallScriptPath = join(packageDir, INSTALL_SCRIPT);
|
|
58
|
+
|
|
59
|
+
function fail(message) {
|
|
60
|
+
console.error(message);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function currentPlatformKey() {
|
|
65
|
+
const platformKey = PLATFORM_MAP[`${process.platform}-${process.arch}`];
|
|
66
|
+
if (!platformKey) {
|
|
67
|
+
fail(`Unsupported platform: ${process.platform}-${process.arch}`);
|
|
68
|
+
}
|
|
69
|
+
return platformKey;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function currentPlatformPackageName() {
|
|
73
|
+
const platformKey = currentPlatformKey();
|
|
74
|
+
const packageName = PLATFORM_PACKAGES[platformKey];
|
|
75
|
+
if (!packageName) {
|
|
76
|
+
fail(`No platform package is configured for ${platformKey}`);
|
|
77
|
+
}
|
|
78
|
+
return packageName;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* When a Jive library contains any number of CLIs (entrypoints or agents), then the base package
|
|
83
|
+
* will have an optional dependency for each possible architecture, with those platform-specific
|
|
84
|
+
* packages containing a platform build of the CLI.
|
|
85
|
+
* @returns the path to the platform binary and the exact version of the platform package.
|
|
86
|
+
*/
|
|
87
|
+
function currentPlatformPackage() {
|
|
88
|
+
const platformKey = currentPlatformKey();
|
|
89
|
+
const binaryFile = PLATFORM_BINARIES[platformKey];
|
|
90
|
+
if (!binaryFile) {
|
|
91
|
+
fail(`No platform binary is configured for ${platformKey}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const packageName = currentPlatformPackageName();
|
|
95
|
+
try {
|
|
96
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
97
|
+
const packageDir = dirname(packageJsonPath);
|
|
98
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
99
|
+
return {
|
|
100
|
+
binaryPath: join(packageDir, binaryFile),
|
|
101
|
+
version: packageJson.version,
|
|
102
|
+
};
|
|
103
|
+
} catch (error) {
|
|
104
|
+
fail(`Could not resolve optional platform package ${packageName}. Reinstall dependencies for ${process.platform}-${process.arch}.`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function commandTargetPath(command) {
|
|
109
|
+
const suffix = process.platform === "win32" ? WINDOWS_EXECUTABLE_SUFFIX : "";
|
|
110
|
+
return join(commandTargetDir, `${command}${suffix}`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function installedJsonPath() {
|
|
114
|
+
return join(commandTargetDir, INSTALLED_JSON);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function windowsTargetsAreCurrent(version) {
|
|
118
|
+
if (process.platform !== "win32") return false;
|
|
119
|
+
if (!COMMANDS.every((command) => existsSync(commandTargetPath(command)))) return false;
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
const installed = JSON.parse(readFileSync(installedJsonPath(), "utf-8"));
|
|
123
|
+
return installed.version === version;
|
|
124
|
+
} catch {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function linkOrCopyFirstExecutable(sourcePath, targetPath) {
|
|
130
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
131
|
+
const tempPath = `${targetPath}.${process.pid}.${Date.now()}.tmp${process.platform === "win32" ? WINDOWS_EXECUTABLE_SUFFIX : ""}`;
|
|
132
|
+
rmSync(tempPath, { force: true });
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
try {
|
|
136
|
+
linkSync(sourcePath, tempPath);
|
|
137
|
+
} catch {
|
|
138
|
+
copyFileSync(sourcePath, tempPath);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
chmodSync(tempPath, 0o755);
|
|
142
|
+
rmSync(targetPath, { force: true });
|
|
143
|
+
renameSync(tempPath, targetPath);
|
|
144
|
+
} finally {
|
|
145
|
+
rmSync(tempPath, { force: true });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function hardLinkCommandTarget(sourcePath, targetPath) {
|
|
150
|
+
if (sourcePath === targetPath) return;
|
|
151
|
+
|
|
152
|
+
const tempPath = `${targetPath}.${process.pid}.${Date.now()}.tmp${process.platform === "win32" ? WINDOWS_EXECUTABLE_SUFFIX : ""}`;
|
|
153
|
+
rmSync(tempPath, { force: true });
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
linkSync(sourcePath, tempPath);
|
|
157
|
+
chmodSync(tempPath, 0o755);
|
|
158
|
+
rmSync(targetPath, { force: true });
|
|
159
|
+
renameSync(tempPath, targetPath);
|
|
160
|
+
} finally {
|
|
161
|
+
rmSync(tempPath, { force: true });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function repairCommandTargets() {
|
|
166
|
+
const platformPackage = currentPlatformPackage();
|
|
167
|
+
|
|
168
|
+
if (windowsTargetsAreCurrent(platformPackage.version)) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const firstTargetPath = commandTargetPath(COMMANDS[0]);
|
|
173
|
+
linkOrCopyFirstExecutable(platformPackage.binaryPath, firstTargetPath);
|
|
174
|
+
|
|
175
|
+
for (const command of COMMANDS.slice(1)) {
|
|
176
|
+
hardLinkCommandTarget(firstTargetPath, commandTargetPath(command));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (process.platform === "win32") {
|
|
180
|
+
writeFileSync(installedJsonPath(), `${JSON.stringify({ version: platformPackage.version }, null, 2)}\n`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function runExecutable(executablePath) {
|
|
185
|
+
const result = spawnSync(executablePath, process.argv.slice(2), { stdio: "inherit" });
|
|
186
|
+
|
|
187
|
+
if (result.error) {
|
|
188
|
+
fail(result.error.message);
|
|
189
|
+
}
|
|
190
|
+
if (result.status !== 0) {
|
|
191
|
+
process.exit(result.status ?? 1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function removeInstallScript() {
|
|
196
|
+
try {
|
|
197
|
+
rmSync(rootInstallScriptPath, { force: true });
|
|
198
|
+
// TODO: should we also remove the postinstall script line from package.json?
|
|
199
|
+
} catch {
|
|
200
|
+
// Cleanup is best-effort; failing to remove install.js should not fail package installation.
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
repairCommandTargets();
|
|
205
|
+
removeInstallScript();
|
|
206
|
+
if (!IS_INSTALL_SCRIPT) {
|
|
207
|
+
const commandName = basename(launcherPath);
|
|
208
|
+
runExecutable(commandTargetPath(commandName));
|
|
209
|
+
}
|