@victorysightsound/dial-cli 4.2.5
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 +29 -0
- package/bin/dial.js +43 -0
- package/lib/package-paths.mjs +34 -0
- package/lib/platform.mjs +64 -0
- package/package.json +54 -0
- package/scripts/postinstall.js +95 -0
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @victorysightsound/dial-cli
|
|
2
|
+
|
|
3
|
+
Install the DIAL CLI from npm:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g @victorysightsound/dial-cli
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
This package downloads the matching prebuilt DIAL binary from the GitHub release for the current package version and exposes `dial` as the global command.
|
|
10
|
+
|
|
11
|
+
Supported targets:
|
|
12
|
+
- macOS Apple Silicon
|
|
13
|
+
- macOS Intel
|
|
14
|
+
- Linux x86_64
|
|
15
|
+
- Linux ARM64
|
|
16
|
+
- Windows x86_64
|
|
17
|
+
|
|
18
|
+
Requirements:
|
|
19
|
+
- Node.js 18 or newer
|
|
20
|
+
- internet access during install so the matching GitHub release asset can be downloaded
|
|
21
|
+
|
|
22
|
+
Verify the install:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
dial --version
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
If you need the full onboarding guide, see the main project docs:
|
|
29
|
+
- https://github.com/victorysightsound/dial/blob/main/docs/getting-started.md
|
package/bin/dial.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
|
|
6
|
+
import { installedBinaryPath, packageRootFrom } from "../lib/package-paths.mjs";
|
|
7
|
+
import { resolveAssetSpec } from "../lib/platform.mjs";
|
|
8
|
+
|
|
9
|
+
let asset;
|
|
10
|
+
try {
|
|
11
|
+
asset = resolveAssetSpec();
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error(`dial-cli: ${error.message}`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const packageRoot = packageRootFrom(import.meta.url);
|
|
18
|
+
const binaryPath = installedBinaryPath(packageRoot, asset.binaryName);
|
|
19
|
+
|
|
20
|
+
if (!fs.existsSync(binaryPath)) {
|
|
21
|
+
console.error(
|
|
22
|
+
`dial-cli: missing platform binary at ${binaryPath}. Reinstall with 'npm install -g @victorysightsound/dial-cli'.`,
|
|
23
|
+
);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
28
|
+
stdio: "inherit",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
child.on("error", (error) => {
|
|
32
|
+
console.error(`dial-cli: failed to start '${binaryPath}': ${error.message}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
child.on("exit", (code, signal) => {
|
|
37
|
+
if (signal) {
|
|
38
|
+
process.kill(process.pid, signal);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
process.exit(code ?? 1);
|
|
43
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
export function packageRootFrom(importMetaUrl) {
|
|
6
|
+
return path.resolve(path.dirname(fileURLToPath(importMetaUrl)), "..");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function vendorDirectory(packageRoot) {
|
|
10
|
+
return path.join(packageRoot, "vendor");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function installedBinaryPath(packageRoot, binaryName) {
|
|
14
|
+
return path.join(vendorDirectory(packageRoot), binaryName);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function readPackageVersion(packageRoot) {
|
|
18
|
+
const packageJsonPath = path.join(packageRoot, "package.json");
|
|
19
|
+
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
|
|
20
|
+
return String(packageJson.version);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function buildDownloadUrl(version, assetName, env = process.env) {
|
|
24
|
+
if (env.DIAL_NPM_BINARY_URL) {
|
|
25
|
+
return env.DIAL_NPM_BINARY_URL;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const normalizedVersion = String(version).replace(/^v/, "");
|
|
29
|
+
const baseUrl =
|
|
30
|
+
env.DIAL_NPM_BASE_URL ??
|
|
31
|
+
`https://github.com/victorysightsound/dial/releases/download/v${normalizedVersion}`;
|
|
32
|
+
|
|
33
|
+
return `${baseUrl.replace(/\/$/, "")}/${assetName}`;
|
|
34
|
+
}
|
package/lib/platform.mjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const TARGETS = new Map([
|
|
2
|
+
[
|
|
3
|
+
"darwin:arm64",
|
|
4
|
+
{
|
|
5
|
+
target: "aarch64-apple-darwin",
|
|
6
|
+
archive: "tar.gz",
|
|
7
|
+
binaryName: "dial",
|
|
8
|
+
},
|
|
9
|
+
],
|
|
10
|
+
[
|
|
11
|
+
"darwin:x64",
|
|
12
|
+
{
|
|
13
|
+
target: "x86_64-apple-darwin",
|
|
14
|
+
archive: "tar.gz",
|
|
15
|
+
binaryName: "dial",
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
"linux:arm64",
|
|
20
|
+
{
|
|
21
|
+
target: "aarch64-unknown-linux-gnu",
|
|
22
|
+
archive: "tar.gz",
|
|
23
|
+
binaryName: "dial",
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
[
|
|
27
|
+
"linux:x64",
|
|
28
|
+
{
|
|
29
|
+
target: "x86_64-unknown-linux-gnu",
|
|
30
|
+
archive: "tar.gz",
|
|
31
|
+
binaryName: "dial",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
"win32:x64",
|
|
36
|
+
{
|
|
37
|
+
target: "x86_64-pc-windows-msvc",
|
|
38
|
+
archive: "zip",
|
|
39
|
+
binaryName: "dial.exe",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
export function supportedTargetKeys() {
|
|
45
|
+
return [...TARGETS.keys()].sort();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function resolveAssetSpec(
|
|
49
|
+
platform = process.platform,
|
|
50
|
+
arch = process.arch,
|
|
51
|
+
) {
|
|
52
|
+
const key = `${platform}:${arch}`;
|
|
53
|
+
const spec = TARGETS.get(key);
|
|
54
|
+
if (!spec) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Unsupported platform '${platform}' on '${arch}'. Supported targets: ${supportedTargetKeys().join(", ")}`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
...spec,
|
|
62
|
+
assetName: `dial-${spec.target}.${spec.archive}`,
|
|
63
|
+
};
|
|
64
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@victorysightsound/dial-cli",
|
|
3
|
+
"version": "4.2.5",
|
|
4
|
+
"description": "Install the DIAL CLI as a global command via npm",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dial",
|
|
7
|
+
"cli",
|
|
8
|
+
"ai",
|
|
9
|
+
"automation",
|
|
10
|
+
"development"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT OR Apache-2.0",
|
|
13
|
+
"homepage": "https://github.com/victorysightsound/dial#readme",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/victorysightsound/dial.git"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/victorysightsound/dial/issues"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"bin": {
|
|
23
|
+
"dial": "bin/dial.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"README.md",
|
|
27
|
+
"bin/",
|
|
28
|
+
"lib/",
|
|
29
|
+
"scripts/"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"postinstall": "node ./scripts/postinstall.js",
|
|
33
|
+
"test": "node --test ./test/*.test.mjs"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"extract-zip": "^2.0.1",
|
|
37
|
+
"tar": "^7.4.3"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"os": [
|
|
43
|
+
"darwin",
|
|
44
|
+
"linux",
|
|
45
|
+
"win32"
|
|
46
|
+
],
|
|
47
|
+
"cpu": [
|
|
48
|
+
"x64",
|
|
49
|
+
"arm64"
|
|
50
|
+
],
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
|
+
import { createWriteStream } from "node:fs";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { Readable } from "node:stream";
|
|
8
|
+
import { pipeline } from "node:stream/promises";
|
|
9
|
+
|
|
10
|
+
import extractZip from "extract-zip";
|
|
11
|
+
import * as tar from "tar";
|
|
12
|
+
|
|
13
|
+
import { buildDownloadUrl, installedBinaryPath, packageRootFrom, readPackageVersion, vendorDirectory } from "../lib/package-paths.mjs";
|
|
14
|
+
import { resolveAssetSpec } from "../lib/platform.mjs";
|
|
15
|
+
|
|
16
|
+
async function downloadFile(url, destinationPath) {
|
|
17
|
+
const response = await fetch(url, {
|
|
18
|
+
headers: {
|
|
19
|
+
"user-agent": "dial-cli-npm-installer",
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (!response.ok || !response.body) {
|
|
24
|
+
const detail =
|
|
25
|
+
response.status === 404
|
|
26
|
+
? "matching GitHub release asset was not found"
|
|
27
|
+
: `download failed with HTTP ${response.status}`;
|
|
28
|
+
throw new Error(`Unable to download ${url}: ${detail}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
await pipeline(
|
|
32
|
+
Readable.fromWeb(response.body),
|
|
33
|
+
createWriteStream(destinationPath),
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function extractArchive(archivePath, archiveType, destinationDir) {
|
|
38
|
+
if (archiveType === "tar.gz") {
|
|
39
|
+
await tar.x({
|
|
40
|
+
cwd: destinationDir,
|
|
41
|
+
file: archivePath,
|
|
42
|
+
strict: true,
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (archiveType === "zip") {
|
|
48
|
+
await extractZip(archivePath, { dir: destinationDir });
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
throw new Error(`Unsupported archive type '${archiveType}'`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function main() {
|
|
56
|
+
if (process.env.DIAL_NPM_SKIP_DOWNLOAD === "1") {
|
|
57
|
+
console.log("dial-cli: skipping binary download because DIAL_NPM_SKIP_DOWNLOAD=1");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const packageRoot = packageRootFrom(import.meta.url);
|
|
62
|
+
const version = await readPackageVersion(packageRoot);
|
|
63
|
+
const asset = resolveAssetSpec();
|
|
64
|
+
const downloadUrl = buildDownloadUrl(version, asset.assetName);
|
|
65
|
+
const targetBinary = installedBinaryPath(packageRoot, asset.binaryName);
|
|
66
|
+
const targetVendorDir = vendorDirectory(packageRoot);
|
|
67
|
+
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "dial-cli-"));
|
|
68
|
+
const archivePath = path.join(tempDir, asset.assetName);
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
console.log(`dial-cli: downloading ${asset.assetName}`);
|
|
72
|
+
await downloadFile(downloadUrl, archivePath);
|
|
73
|
+
await extractArchive(archivePath, asset.archive, tempDir);
|
|
74
|
+
await fs.mkdir(targetVendorDir, { recursive: true });
|
|
75
|
+
|
|
76
|
+
const extractedBinary = path.join(tempDir, asset.binaryName);
|
|
77
|
+
await fs.copyFile(extractedBinary, targetBinary);
|
|
78
|
+
|
|
79
|
+
if (process.platform !== "win32") {
|
|
80
|
+
await fs.chmod(targetBinary, 0o755);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
console.log(`dial-cli: installed DIAL ${version} for ${asset.target}`);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(`dial-cli: ${error.message}`);
|
|
86
|
+
console.error(
|
|
87
|
+
"dial-cli: install failed. Ensure the matching GitHub release exists and try the install again.",
|
|
88
|
+
);
|
|
89
|
+
process.exitCode = 1;
|
|
90
|
+
} finally {
|
|
91
|
+
await fs.rm(tempDir, { force: true, recursive: true });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
await main();
|