@rentaltide/cli 0.1.0 → 0.1.1
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/dist/api.js +18 -1
- package/dist/commands/dev.js +19 -3
- package/dist/commands/link.js +2 -2
- package/dist/commands/push.js +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -52,11 +52,28 @@ function safeJson(text) {
|
|
|
52
52
|
return { message: text.slice(0, 300) };
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Fetch one app.
|
|
57
|
+
*
|
|
58
|
+
* The endpoint answers `{ success, app }`, not the app — reading it flat gives
|
|
59
|
+
* an object whose every field is undefined, which is not an error anywhere: the
|
|
60
|
+
* diff simply shows every value being cleared. Unwrapped in one place so no
|
|
61
|
+
* command can get it wrong again.
|
|
62
|
+
*/
|
|
63
|
+
export async function getApp(appId) {
|
|
64
|
+
const data = await request(`/developer/apps/${appId}`);
|
|
65
|
+
const app = data.app ?? data;
|
|
66
|
+
if (!app?.appId)
|
|
67
|
+
fail('That app could not be loaded.', 'Run `rentaltide link` to pick another.');
|
|
68
|
+
return app;
|
|
69
|
+
}
|
|
55
70
|
/** Project config → the field names the API expects. */
|
|
56
71
|
export function configToAppPayload(config) {
|
|
57
72
|
return {
|
|
58
73
|
appName: config.name,
|
|
59
|
-
appSlug:
|
|
74
|
+
// `appSlug` is deliberately absent: the API cannot change a slug after
|
|
75
|
+
// creation, so sending one is a silent no-op that shows in a diff as a
|
|
76
|
+
// change that never happens.
|
|
60
77
|
developerName: config.developerName,
|
|
61
78
|
description: config.description,
|
|
62
79
|
category: config.category,
|
package/dist/commands/dev.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* - It restores the previous embed URL on exit, including Ctrl-C, and says so
|
|
15
15
|
* if it could not.
|
|
16
16
|
*/
|
|
17
|
-
import { request } from '../api.js';
|
|
17
|
+
import { getApp, request } from '../api.js';
|
|
18
18
|
import { requireAppConfig } from '../config.js';
|
|
19
19
|
import { bold, cyan, dim, fail, ok, say, step, warn, yellow } from '../ui.js';
|
|
20
20
|
const DEFAULT_DEV_URL = 'http://localhost:5173';
|
|
@@ -24,7 +24,7 @@ export async function dev(args) {
|
|
|
24
24
|
fail('This project is not linked yet.', 'Run `rentaltide link`.');
|
|
25
25
|
const flagIndex = args.findIndex((a) => a === '--url');
|
|
26
26
|
const devUrl = (flagIndex >= 0 ? args[flagIndex + 1] : undefined) || config.dev?.embedUrl || DEFAULT_DEV_URL;
|
|
27
|
-
const app = await
|
|
27
|
+
const app = await getApp(config.appId);
|
|
28
28
|
if (app.status === 'approved') {
|
|
29
29
|
fail(`${app.appName} is approved and installed by real merchants.`, 'Repointing its embed URL would point all of them at your laptop. Work on a draft copy instead.');
|
|
30
30
|
}
|
|
@@ -38,6 +38,15 @@ export async function dev(args) {
|
|
|
38
38
|
if (!sandbox)
|
|
39
39
|
fail('Could not create your sandbox.');
|
|
40
40
|
await request(`/developer/apps/${config.appId}/sandbox-install`, { method: 'POST' }).catch(() => undefined);
|
|
41
|
+
// Is anything actually listening? A sandbox pointed at a dead port renders a
|
|
42
|
+
// blank frame, which looks like the platform failing rather than a dev server
|
|
43
|
+
// that was never started.
|
|
44
|
+
try {
|
|
45
|
+
await fetch(devUrl, { signal: AbortSignal.timeout(2000) });
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
warn(`Nothing is answering at ${devUrl} yet — start your dev server.`);
|
|
49
|
+
}
|
|
41
50
|
step(`Pointing ${app.appName} at ${bold(devUrl)}`);
|
|
42
51
|
await request(`/developer/apps/${config.appId}`, {
|
|
43
52
|
method: 'PUT',
|
|
@@ -74,7 +83,14 @@ export async function dev(args) {
|
|
|
74
83
|
say();
|
|
75
84
|
say(dim('Open the console from the partner portal → App Sandbox → Open sandbox console.'));
|
|
76
85
|
say(dim('Edit your app and refresh the page. No redeploy, no reinstall.'));
|
|
77
|
-
|
|
86
|
+
if (devUrl.startsWith('http://')) {
|
|
87
|
+
// http://localhost is a potentially-trustworthy origin, so Chrome and
|
|
88
|
+
// Firefox embed it inside an https page. Safari does not, and shows an
|
|
89
|
+
// empty frame with the reason only in its console.
|
|
90
|
+
say(dim('Chrome and Firefox will embed a plain-http localhost URL. Safari will not —\n' +
|
|
91
|
+
' use --url https://localhost:5173 with a local certificate there.'));
|
|
92
|
+
say();
|
|
93
|
+
}
|
|
78
94
|
say(yellow('Leave this running.') + dim(' Ctrl-C restores the embed URL.'));
|
|
79
95
|
// Nothing to poll: the page reloads from the developer's own dev server.
|
|
80
96
|
// This process exists to hold the restore handler.
|
package/dist/commands/link.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Attach this directory to one of your apps, and pull its config down. */
|
|
2
|
-
import { appToConfig, request } from '../api.js';
|
|
2
|
+
import { appToConfig, getApp, request } from '../api.js';
|
|
3
3
|
import { readAppConfig, requireAppConfig, writeAppConfig, CONFIG_FILENAME } from '../config.js';
|
|
4
4
|
import { ask, bold, dim, fail, ok, say } from '../ui.js';
|
|
5
5
|
async function listApps() {
|
|
@@ -27,7 +27,7 @@ export async function pull() {
|
|
|
27
27
|
const config = requireAppConfig();
|
|
28
28
|
if (!config.appId)
|
|
29
29
|
fail('This project is not linked yet.', 'Run `rentaltide link`.');
|
|
30
|
-
const app = await
|
|
30
|
+
const app = await getApp(config.appId);
|
|
31
31
|
writeAppConfig(appToConfig(app, config));
|
|
32
32
|
ok(`Pulled ${app.appName} into ${CONFIG_FILENAME}.`);
|
|
33
33
|
}
|
package/dist/commands/push.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* may read and where it renders; applying a change to them silently because a
|
|
6
6
|
* file moved is not a thing a tool should do.
|
|
7
7
|
*/
|
|
8
|
-
import { appToConfig, configToAppPayload, request } from '../api.js';
|
|
8
|
+
import { appToConfig, configToAppPayload, getApp, request } from '../api.js';
|
|
9
9
|
import { requireAppConfig } from '../config.js';
|
|
10
10
|
import { bold, confirm, dim, fail, green, ok, red, say } from '../ui.js';
|
|
11
11
|
function flatten(value) {
|
|
@@ -19,7 +19,7 @@ export async function push(args) {
|
|
|
19
19
|
const config = requireAppConfig();
|
|
20
20
|
if (!config.appId)
|
|
21
21
|
fail('This project is not linked yet.', 'Run `rentaltide link`.');
|
|
22
|
-
const current = await
|
|
22
|
+
const current = await getApp(config.appId);
|
|
23
23
|
const before = appToConfig(current);
|
|
24
24
|
const fields = [
|
|
25
25
|
['name', before.name, config.name],
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { init } from './commands/init.js';
|
|
|
15
15
|
import { webhook } from './commands/webhook.js';
|
|
16
16
|
import { open } from './commands/open.js';
|
|
17
17
|
import { bold, dim, say } from './ui.js';
|
|
18
|
-
const VERSION = '0.1.
|
|
18
|
+
const VERSION = '0.1.1';
|
|
19
19
|
function usage() {
|
|
20
20
|
say(`${bold('rentaltide')} ${dim(VERSION)} — build apps for RentalTide`);
|
|
21
21
|
say();
|