@tokenoftrust/cli 2.1.1 → 2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/cli",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Token of Trust developer CLI — clone a tenant store, run it locally with save→reload, and submit it for preview. Installs the `tot` command.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Token of Trust",
@@ -267,10 +267,18 @@ export async function run(argv, ctx) {
267
267
  noLogin: false, noOpen: args.noOpen, docker: args.docker,
268
268
  });
269
269
  const runtime = /** @type {{ useDocker: boolean, runnerDir: any }} */ ({ useDocker: args.docker, runnerDir: null });
270
- await Promise.all([
270
+ await settleCheckoutAndRuntime(
271
271
  ensureCheckout(client, tenant, dir, env),
272
272
  prefetchRuntime(client, devArgs, env, runtime, ctx),
273
- ]);
273
+ {
274
+ onRuntimeFailedAfterCheckout: () => {
275
+ printCheckoutLocation(dir);
276
+ console.log(
277
+ ` Once the problem below is fixed, run \`tot start\` again from ${resolve(dir, "..")} — it reuses ./${tenant}.`,
278
+ );
279
+ },
280
+ },
281
+ );
274
282
 
275
283
  // Say EXACTLY where the code landed + THE one next step, so a freshly
276
284
  // checked-out dev is never left wondering what to open. Absolute path (works
@@ -690,10 +698,32 @@ export function formatElapsed(ms) {
690
698
  * Developer Cockpit URL, the one next step is framed as "edit a line → see it in
691
699
  * your cockpit"; otherwise it's the same edit-to-see-it-reload action.
692
700
  */
693
- /** @param {string} dir @param {string|null} [cockpitUrl] */
694
- function printCheckoutLanding(dir, cockpitUrl = null) {
701
+ /** @param {string} dir */
702
+ function printCheckoutLocation(dir) {
695
703
  console.log("");
696
704
  console.log(` 📁 Your store code is at: ${dir}`);
705
+ }
706
+
707
+ /**
708
+ * Run the checkout and the runner prefetch together, but never let a failed prefetch hide
709
+ * a checkout that succeeded: the code is already on disk, so say where before re-throwing
710
+ * the prefetch error. A failed checkout wins (nothing landed, nothing to point at).
711
+ * @param {Promise<unknown>} checkout
712
+ * @param {Promise<unknown>} runtime
713
+ * @param {{ onRuntimeFailedAfterCheckout: () => void }} hooks
714
+ */
715
+ export async function settleCheckoutAndRuntime(checkout, runtime, { onRuntimeFailedAfterCheckout }) {
716
+ const [checkedOut, prepared] = await Promise.allSettled([checkout, runtime]);
717
+ if (checkedOut.status === "rejected") throw checkedOut.reason;
718
+ if (prepared.status === "rejected") {
719
+ onRuntimeFailedAfterCheckout();
720
+ throw prepared.reason;
721
+ }
722
+ }
723
+
724
+ /** @param {string} dir @param {string|null} [cockpitUrl] */
725
+ function printCheckoutLanding(dir, cockpitUrl = null) {
726
+ printCheckoutLocation(dir);
697
727
  const where = cockpitUrl ? `your ${DEVELOPER_COCKPIT}` : "your browser";
698
728
  console.log(` Next: open it in your editor and change one line in`);
699
729
  console.log(` content/home.html — you'll see it reflected in ${where}.`);