@webority/ensemble 0.5.1 → 0.5.3

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/bin/ensemble.js CHANGED
@@ -39,8 +39,8 @@ async function login(args) {
39
39
  core.openBrowser(grant.verificationUriComplete);
40
40
  core.log('• waiting for your approval …');
41
41
  const token = await waitForApproval(api, grant);
42
- core.log('\n✓ Approved. Connecting this machine …');
43
- const { runnerPath } = core.requireRuntime();
42
+ core.log('\n✓ Approved. Setting up this machine …');
43
+ const { runnerPath } = await core.ensureRuntime();
44
44
  reportSetup(core.finishSetup(api, token, runnerPath));
45
45
  }
46
46
 
@@ -73,7 +73,7 @@ async function enroll(args) {
73
73
  core.log('Ensemble — enrolling "' + name + '" with ' + api);
74
74
  core.log('• exchanging the enrollment token for a per-machine token');
75
75
  const machineToken = await core.enrollMachine(api, token, name);
76
- const { runnerPath } = core.requireRuntime();
76
+ const { runnerPath } = await core.ensureRuntime();
77
77
  reportSetup(core.finishSetup(api, machineToken, runnerPath));
78
78
  }
79
79
 
@@ -97,7 +97,7 @@ function usage() {
97
97
  `ensemble — connect this machine to your Ensemble control plane
98
98
 
99
99
  ensemble login [--api <url>] [--name <machine>]
100
- sign in via your browser + connect this machine (runtime is installed at npm install)
100
+ sign in via your browser + set up this machine (downloads the runtime on first run)
101
101
  ensemble enroll --token <enrollment-token> [--api <url>] [--name <machine>]
102
102
  headless / CI: enrol with an enrollment token from the portal
103
103
  ensemble install (re)download the runner + bus for this platform
package/lib/core.js CHANGED
@@ -101,6 +101,15 @@ function requireRuntime() {
101
101
  return runtimePaths();
102
102
  }
103
103
 
104
+ // Ensure the runner + bus are present, downloading them if this is the first run. Called by
105
+ // `login`/`enroll` AFTER authentication, so the whole thing is: `npm i` then `ensemble login`.
106
+ async function ensureRuntime() {
107
+ if (runtimeInstalled()) {
108
+ return runtimePaths();
109
+ }
110
+ return ensureBinaries();
111
+ }
112
+
104
113
  async function ensureBinaries() {
105
114
  ensureDirs();
106
115
  const pf = platform();
@@ -315,5 +324,5 @@ module.exports = {
315
324
  log, warn, die, platform, DEFAULT_API, ENSEMBLE_DIR, RUNNER_DIR, BIN_DIR,
316
325
  ensureBinaries, enrollMachine, writeRunnerConfig, wireHooks, installAutostart, startRunner, request,
317
326
  sleep, openBrowser, startDevice, pollDevice, finishSetup, assertSupported,
318
- runtimePaths, runtimeInstalled, requireRuntime,
327
+ runtimePaths, runtimeInstalled, requireRuntime, ensureRuntime,
319
328
  };
package/package.json CHANGED
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "name": "@webority/ensemble",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Connect this machine to your Ensemble control plane — runs the local agent runner and wires the ensemble-bus session bus so your coding sessions talk (per-org, isolated).",
5
5
  "bin": {
6
6
  "ensemble": "bin/ensemble.js"
7
7
  },
8
- "scripts": {
9
- "postinstall": "node lib/postinstall.js"
10
- },
11
8
  "engines": {
12
9
  "node": ">=18"
13
10
  },
@@ -1,22 +0,0 @@
1
- 'use strict';
2
- // Runs at `npm install` (postinstall). Downloads the runner + bus for this platform so that
3
- // `ensemble login` is auth-only. Resilient by design: any failure (offline, unsupported OS,
4
- // --ignore-scripts) warns and exits 0 so it never breaks `npm install` — `ensemble install`
5
- // (or the next install) can retry.
6
- const core = require('./core');
7
-
8
- (async () => {
9
- try {
10
- if (core.runtimeInstalled()) {
11
- return; // already present (e.g. reinstall of the same version)
12
- }
13
- core.assertSupported();
14
- core.log('Ensemble: installing the runner + bus for this machine …');
15
- await core.ensureBinaries();
16
- core.log('Ensemble: runtime installed. Next: ensemble login');
17
- } catch (e) {
18
- core.warn('Ensemble: could not install the runtime now (' + (e && e.message ? e.message : e) + ').');
19
- core.warn(' Run ensemble install when ready, then ensemble login.');
20
- // exit 0 — never fail `npm install`.
21
- }
22
- })();