@nativescript/cloudflare-cli 0.1.0-beta.6 → 0.1.0-beta.7

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.
Files changed (2) hide show
  1. package/dist/bin.js +17 -11
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -9,12 +9,14 @@ import { applyChanges, collect, createProject, projectUrl, report, SYNCED } from
9
9
  const CONFIG = '.ns-edge.json';
10
10
  const DEBOUNCE_MS = 120;
11
11
  const LIVE_SERVER = process.env.NS_EDGE_SERVER ?? 'https://preview.nativescript.org';
12
- /** The hosts `live --mac` and `live --electron` run; bump them with each host release this CLI is tested against. */
12
+ /** The hosts `live --mac`, `--electron` and `--expo` run; bump them with each host release this CLI is tested against. */
13
13
  const DESKTOP_HOSTS = {
14
- macos: '@nativescript/cloudflare-desktop@0.1.0-alpha.5',
15
- electron: '@nativescript/cloudflare-electron@0.1.0-alpha.2',
14
+ macos: { spec: '@nativescript/cloudflare-desktop@0.1.0-alpha.5', bin: 'ns-edge-desktop' },
15
+ electron: { spec: '@nativescript/cloudflare-electron@0.1.0-alpha.2', bin: 'ns-edge-electron' },
16
+ expo: { spec: '@nativescript/cloudflare-expo-desktop@0.1.0-alpha.0', bin: 'ns-edge-expo-desktop' },
16
17
  };
17
- const DESKTOP_TEMPLATES = new Set(['macos', 'electron']);
18
+ const DESKTOP_TEMPLATES = new Set(['macos', 'electron', 'expo']);
19
+ const DESKTOP_FLAGS = { macos: 'mac', electron: 'electron', expo: 'expo' };
18
20
  const MAX_CRASHES = 3;
19
21
  const CRASH_WINDOW_MS = 60_000;
20
22
  const RESTART_DELAY_MS = 1000;
@@ -90,6 +92,8 @@ async function runDesktopHost(ref) {
90
92
  const device = `${projectUrl(ref)}#${ref.deviceKey}`;
91
93
  const extra = has('allow-eval') ? ['--allow-eval'] : [];
92
94
  const host = DESKTOP_HOSTS[ref.template ?? 'macos'] ?? DESKTOP_HOSTS.macos;
95
+ // NS_EDGE_HOST runs another spec of the host (a version, or file:<packed .tgz>) to test a release before publishing it.
96
+ const spec = process.env.NS_EDGE_HOST ?? host.spec;
93
97
  let child;
94
98
  let stopping = false;
95
99
  for (const signal of ['SIGINT', 'SIGTERM']) {
@@ -100,7 +104,7 @@ async function runDesktopHost(ref) {
100
104
  }
101
105
  const crashes = [];
102
106
  for (;;) {
103
- child = spawn('npx', ['-y', host, device, '--yes', ...extra], { stdio: 'inherit' });
107
+ child = spawn('npx', ['-y', '--package', spec, '--', host.bin, device, '--yes', ...extra], { stdio: 'inherit' });
104
108
  const exit = await new Promise((resolve, reject) => {
105
109
  child.on('error', reject);
106
110
  child.on('exit', (code, signal) => resolve({ code, signal }));
@@ -123,11 +127,11 @@ const commands = {
123
127
  async live() {
124
128
  for (const later of ['ios', 'android', 'all']) {
125
129
  if (has(later))
126
- throw new Error(`--${later} isn't available yet. Run \`live\` for a phone app or \`live --mac\` for a Mac app.`);
130
+ throw new Error(`--${later} isn't available yet. Run \`live\` for a phone app, or \`live --mac\`, \`--electron\` or \`--expo\` for a Mac app.`);
127
131
  }
128
132
  let ref = has('new') ? null : await savedProject();
129
133
  // Without a platform flag, this folder's project runs as whatever it was made as.
130
- const template = flag('template') ?? (has('electron') ? 'electron' : has('mac') ? 'macos' : (ref?.template ?? 'core'));
134
+ const template = flag('template') ?? Object.entries(DESKTOP_FLAGS).find(([, name]) => has(name))?.[0] ?? ref?.template ?? 'core';
131
135
  const desktop = DESKTOP_TEMPLATES.has(template);
132
136
  if (ref && DESKTOP_TEMPLATES.has(ref.template ?? 'core') !== desktop) {
133
137
  throw new Error(`This folder's project (${CONFIG}) is a ${desktop ? 'phone' : 'Mac'} project. Add --new to replace it, or run this in another folder.`);
@@ -141,7 +145,8 @@ const commands = {
141
145
  else {
142
146
  ref = await createProject(flag('server') ?? LIVE_SERVER, flag('token') ?? process.env.NS_EDGE_CREATE_TOKEN, template);
143
147
  await writeFile(join(root, CONFIG), JSON.stringify(ref, null, 2) + '\n');
144
- console.log(`Created ${template === 'electron' ? 'an Electron' : desktop ? 'a Mac' : 'a phone'} project, saved to ${CONFIG} (it holds the project's keys: keep it private and out of git).`);
148
+ const kind = template === 'electron' ? 'an Electron' : template === 'expo' ? 'an Expo Desktop' : desktop ? 'a Mac' : 'a phone';
149
+ console.log(`Created ${kind} project, saved to ${CONFIG} (it holds the project's keys: keep it private and out of git).`);
145
150
  if (ref.free) {
146
151
  console.log(`It's a free project: ${ref.free.agentTurnsPerDay} hosted agent turn${ref.free.agentTurnsPerDay === 1 ? '' : 's'} a day, deleted after ${ref.free.idleDays} days unused. ` +
147
152
  'For an unlimited agent, add your own API key in the agent panel or connect Claude Code from Connect agent.');
@@ -152,7 +157,8 @@ const commands = {
152
157
  if (!has('no-open'))
153
158
  openInBrowser(ide);
154
159
  if (desktop) {
155
- console.log(`Starting the app on this Mac${template === 'electron' ? ' (the first run downloads Electron)' : ''}. Its window streams to the IDE's Device pane. Press Ctrl+C to stop.\n`);
160
+ const first = template === 'electron' ? ' (the first run downloads Electron)' : template === 'expo' ? ' (the first run downloads the Expo Desktop shell)' : '';
161
+ console.log(`Starting the app on this Mac${first}. Its window streams to the IDE's Device pane. Press Ctrl+C to stop.\n`);
156
162
  return runDesktopHost(ref);
157
163
  }
158
164
  const device = `${projectUrl(ref)}#${ref.deviceKey}`;
@@ -232,9 +238,9 @@ const commands = {
232
238
  async help() {
233
239
  console.log(`ns-edge <command>
234
240
 
235
- live [--mac|--electron] [--new] [--no-open] [--allow-eval]
241
+ live [--mac|--electron|--expo] [--new] [--no-open] [--allow-eval]
236
242
  create a project (or reopen this folder's), open its IDE, and print a QR code
237
- for your phone; --mac or --electron runs it on this Mac instead
243
+ for your phone; --mac, --electron or --expo runs it on this Mac instead
238
244
  create [--server <url>] [--token <t>] [--template core|vue|react|solid|svelte|angular]
239
245
  create an edge project and save .ns-edge.json
240
246
  push upload app/ and server/ in one transaction
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript/cloudflare-cli",
3
- "version": "0.1.0-beta.6",
3
+ "version": "0.1.0-beta.7",
4
4
  "description": "Mirror a NativeScript project into an ns-edge project from a terminal or a Vite dev server",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",