@deviceyard/cli 0.1.50

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,19 @@
1
+ #!/usr/bin/env node
2
+ const { spawnSync } = require("child_process");
3
+ const { resolveBinary } = require("./resolve");
4
+
5
+ let target;
6
+ try {
7
+ target = resolveBinary(process.platform, process.arch, (id) => require.resolve(id));
8
+ } catch (err) {
9
+ console.error(err.message);
10
+ process.exit(1);
11
+ }
12
+
13
+ // stdio inherit: `deviceyard login` reads a token from the real stdin, and the
14
+ // progress stream has to reach the real stdout unbuffered.
15
+ const result = spawnSync(target.binary, process.argv.slice(2), { stdio: "inherit" });
16
+
17
+ // status is null when the child was killed by a signal - treat that as a CLI
18
+ // failure (1) rather than as success, which `exit(null)` would produce.
19
+ process.exit(result.status === null ? 1 : result.status);
package/bin/resolve.js ADDED
@@ -0,0 +1,36 @@
1
+ // Plain CommonJS, no build step: this file runs from the published tarball on
2
+ // a user's machine, before anything of ours has been compiled there.
3
+ const SUPPORTED = {
4
+ "darwin-arm64": true,
5
+ "darwin-x64": true,
6
+ "linux-x64": true,
7
+ "linux-arm64": true,
8
+ };
9
+
10
+ function resolveBinary(platform, arch, resolver) {
11
+ const key = `${platform}-${arch}`;
12
+
13
+ if (!SUPPORTED[key]) {
14
+ throw new Error(
15
+ `deviceyard: ${key} is not supported. Supported: ${Object.keys(SUPPORTED).join(", ")}.\n` +
16
+ `On another platform, use the curl installer or run from source:\n` +
17
+ ` curl -fsSL https://your-farm/cli/install.sh | sh`,
18
+ );
19
+ }
20
+
21
+ const pkg = `@deviceyard/cli-${key}`;
22
+ try {
23
+ return { pkg, binary: resolver(`${pkg}/bin/deviceyard`) };
24
+ } catch {
25
+ // npm skips an optionalDependency it cannot install, SILENTLY. Naming the
26
+ // package and the reinstall flag is the only way a user finds out why the
27
+ // command they just installed does not work.
28
+ throw new Error(
29
+ `deviceyard: the platform binary ${pkg} is not installed.\n` +
30
+ `Reinstall with optional dependencies enabled:\n` +
31
+ ` npm install -g @deviceyard/cli --include=optional`,
32
+ );
33
+ }
34
+ }
35
+
36
+ module.exports = { resolveBinary, SUPPORTED };
package/package.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@deviceyard/cli",
3
+ "version": "0.1.50",
4
+ "description": "Run Maestro flows on a DeviceYard device farm from the command line",
5
+ "bin": { "deviceyard": "bin/deviceyard.js" },
6
+ "files": ["bin"],
7
+ "engines": { "node": ">=20" },
8
+ "optionalDependencies": { "@deviceyard/cli-darwin-arm64":"0.1.50","@deviceyard/cli-darwin-x64":"0.1.50","@deviceyard/cli-linux-x64":"0.1.50","@deviceyard/cli-linux-arm64":"0.1.50" }
9
+ }