@rytuz/machine-access 0.1.0 → 0.1.2

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.
@@ -6,18 +6,27 @@ const fs = require("fs");
6
6
  const path = require("path");
7
7
  const { spawnSync } = require("child_process");
8
8
 
9
+ const RELEASE_METADATA_PATH = path.resolve(
10
+ __dirname,
11
+ "..",
12
+ "release",
13
+ "windows-x64.json"
14
+ );
15
+ const RELEASE_METADATA = JSON.parse(
16
+ fs.readFileSync(RELEASE_METADATA_PATH, "utf8")
17
+ );
9
18
  const RUNTIME_RELEASE = Object.freeze({
10
- schemaVersion: "1.0",
11
- version: "0.1.0-standard.1",
12
- platform: "win32",
13
- arch: "x64",
14
- sha256: "036f1f0d9699b0ca06bda20afd5f702b3e62793ccf7e21c2ef4b244218583ea6",
15
- size: 11137124,
19
+ schemaVersion: RELEASE_METADATA.schema_version,
20
+ packageName: RELEASE_METADATA.package_name,
21
+ packageVersion: RELEASE_METADATA.package_version,
22
+ version: RELEASE_METADATA.runtime_version,
23
+ platform: RELEASE_METADATA.platform,
24
+ arch: RELEASE_METADATA.arch,
25
+ sha256: RELEASE_METADATA.payload_sha256,
26
+ size: RELEASE_METADATA.payload_size,
16
27
  relativePath: path.join(
17
28
  "..",
18
- "payload",
19
- "windows-x64",
20
- "rytuz-machine-access-standard.zip"
29
+ ...RELEASE_METADATA.payload_path.split("/")
21
30
  )
22
31
  });
23
32
 
@@ -37,6 +46,9 @@ function stateRoot(env = process.env) {
37
46
  function validateRelease(release = RUNTIME_RELEASE) {
38
47
  if (
39
48
  release.schemaVersion !== "1.0" ||
49
+ release.packageName !== "@rytuz/machine-access" ||
50
+ typeof release.packageVersion !== "string" ||
51
+ !/^[0-9]+\.[0-9]+\.[0-9]+$/.test(release.packageVersion) ||
40
52
  release.platform !== "win32" ||
41
53
  release.arch !== "x64" ||
42
54
  typeof release.version !== "string" ||
@@ -195,7 +207,21 @@ function expandVerifiedPayload(zipPath, release, root, env = process.env) {
195
207
  return target;
196
208
  }
197
209
 
198
- function runConnect(runtime, root, env = process.env) {
210
+ const PUBLIC_COMMANDS = Object.freeze([
211
+ "connect",
212
+ "start",
213
+ "stop",
214
+ "status",
215
+ "reconnect",
216
+ "enable-autostart",
217
+ "disable-autostart",
218
+ "update"
219
+ ]);
220
+
221
+ function runAgentCommand(runtime, command, env = process.env) {
222
+ if (!PUBLIC_COMMANDS.includes(command)) {
223
+ fail("unsupported Rytuz Standard command");
224
+ }
199
225
  const python = path.join(runtime, "python.exe");
200
226
  const childEnv = { ...env };
201
227
  delete childEnv.PYTHONPATH;
@@ -204,23 +230,31 @@ function runConnect(runtime, root, env = process.env) {
204
230
  childEnv.PYTHONSAFEPATH = "1";
205
231
  const child = spawnSync(
206
232
  python,
207
- ["-B", "-S", "-m", "oryx_access.standard_agent", "connect"],
233
+ ["-B", "-S", "-m", "oryx_access.standard_agent", command],
208
234
  {
209
235
  cwd: runtime,
210
236
  env: childEnv,
211
237
  stdio: "inherit",
212
- windowsHide: false
238
+ windowsHide: command !== "connect"
213
239
  }
214
240
  );
215
241
  if (child.error) throw child.error;
216
242
  if (child.status !== 0) {
217
- fail("Rytuz Standard agent exited with code " + child.status);
243
+ fail(
244
+ "Rytuz Standard " + command + " exited with code " + child.status
245
+ );
218
246
  }
219
247
  }
220
248
 
221
249
  async function main(argv = process.argv.slice(2)) {
222
- if (argv.length !== 1 || argv[0] !== "connect") {
223
- console.error("Usage: npx @rytuz/machine-access@latest connect");
250
+ if (
251
+ argv.length !== 1 ||
252
+ !PUBLIC_COMMANDS.includes(argv[0])
253
+ ) {
254
+ console.error(
255
+ "Usage: npx @rytuz/machine-access@latest " +
256
+ "<connect|start|stop|status|reconnect|enable-autostart|disable-autostart|update>"
257
+ );
224
258
  return 2;
225
259
  }
226
260
  if (process.platform !== "win32" || process.arch !== "x64") {
@@ -233,7 +267,7 @@ async function main(argv = process.argv.slice(2)) {
233
267
 
234
268
  const payload = verifyPayload(bundledPayloadPath(), release);
235
269
  const runtime = expandVerifiedPayload(payload, release, root);
236
- runConnect(runtime, root);
270
+ runAgentCommand(runtime, argv[0]);
237
271
  return 0;
238
272
  }
239
273
 
@@ -244,7 +278,7 @@ if (require.main === module) {
244
278
  },
245
279
  (error) => {
246
280
  console.error(
247
- "Rytuz connect failed:",
281
+ "Rytuz command failed:",
248
282
  error && error.message ? error.message : error
249
283
  );
250
284
  process.exitCode = 1;
@@ -254,6 +288,7 @@ if (require.main === module) {
254
288
 
255
289
  module.exports = {
256
290
  RUNTIME_RELEASE,
291
+ PUBLIC_COMMANDS,
257
292
  stateRoot,
258
293
  validateRelease,
259
294
  sha256File,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rytuz/machine-access",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Rytuz Machine Access Standard user-space bootstrap",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -9,7 +9,8 @@
9
9
  },
10
10
  "files": [
11
11
  "bin",
12
- "payload"
12
+ "payload",
13
+ "release"
13
14
  ],
14
15
  "engines": {
15
16
  "node": ">=18"
@@ -0,0 +1 @@
1
+ {"schema_version":"1.0","package_name":"@rytuz/machine-access","package_version":"0.1.2","runtime_version":"0.1.2-standard.2","platform":"win32","arch":"x64","payload_path":"payload/windows-x64/rytuz-machine-access-standard.zip","payload_sha256":"7210ec8d8715ca49d07ad96ce359dd96ab72c2ad336a1a521124e3a15c83fd45","payload_size":11142358}