@nativescript/edge-cli 0.1.0-beta.12 → 0.1.0-beta.13
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/bin.js +15 -7
- package/dist/sync.js +2 -2
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -11,8 +11,8 @@ const DEBOUNCE_MS = 120;
|
|
|
11
11
|
const LIVE_SERVER = process.env.NS_EDGE_SERVER ?? 'https://preview.nativescript.org';
|
|
12
12
|
/** The hosts `live --desktop` (or `--mac`, `--windows`), `--electron` and `--expo` run; bump them with each host release this CLI is tested against. */
|
|
13
13
|
const DESKTOP_HOSTS = {
|
|
14
|
-
macos: { spec: '@nativescript/edge-desktop@0.1.0-alpha.
|
|
15
|
-
electron: { spec: '@nativescript/edge-electron@0.1.0-alpha.
|
|
14
|
+
macos: { spec: '@nativescript/edge-desktop@0.1.0-alpha.7', bin: 'ns-edge-desktop' },
|
|
15
|
+
electron: { spec: '@nativescript/edge-electron@0.1.0-alpha.4', bin: 'ns-edge-electron' },
|
|
16
16
|
expo: { spec: '@nativescript/edge-expo-desktop@0.1.0-alpha.1', bin: 'ns-edge-expo-desktop' },
|
|
17
17
|
};
|
|
18
18
|
const DESKTOP_TEMPLATES = new Set(['macos', 'electron', 'expo']);
|
|
@@ -26,6 +26,7 @@ const FRAMEWORK_FLAGS = {
|
|
|
26
26
|
svelte: ['svelte'],
|
|
27
27
|
solid: ['solid', 'solidjs'],
|
|
28
28
|
core: ['ts', 'tsc', 'typescript'],
|
|
29
|
+
unified: ['unified'],
|
|
29
30
|
};
|
|
30
31
|
const TEMPLATE_KINDS = {
|
|
31
32
|
core: 'a phone',
|
|
@@ -37,6 +38,7 @@ const TEMPLATE_KINDS = {
|
|
|
37
38
|
macos: 'a desktop',
|
|
38
39
|
electron: 'an Electron',
|
|
39
40
|
expo: 'an Expo Desktop',
|
|
41
|
+
unified: 'a unified multi-platform',
|
|
40
42
|
};
|
|
41
43
|
const MAX_CRASHES = 3;
|
|
42
44
|
const CRASH_WINDOW_MS = 60_000;
|
|
@@ -245,13 +247,16 @@ const commands = {
|
|
|
245
247
|
const fromArg = flag('from');
|
|
246
248
|
const source = fromArg ? await sourceProject(fromArg) : null;
|
|
247
249
|
let ref = has('new') || source ? null : await savedProject();
|
|
248
|
-
|
|
250
|
+
// Unified projects run on phones and in the desktop/Electron hosts, so --desktop or --electron picks which host to launch.
|
|
251
|
+
const unifiedDesktopHost = (source?.template === 'unified' || ref?.template === 'unified') &&
|
|
252
|
+
(DESKTOP_FLAGS.electron.some((n) => has(n)) ? 'electron' : DESKTOP_FLAGS.macos.some((n) => has(n)) ? 'macos' : undefined);
|
|
253
|
+
const requested = unifiedDesktopHost ? undefined : requestedTemplate();
|
|
249
254
|
if (source && requested && requested !== source.template) {
|
|
250
255
|
throw new Error(`--from names ${TEMPLATE_KINDS[source.template] ?? `a ${source.template}`} project, so leave out the flag asking for ${TEMPLATE_KINDS[requested] ?? `a ${requested}`} one.`);
|
|
251
256
|
}
|
|
252
257
|
// Without a template flag, this folder's project runs as whatever it was made as.
|
|
253
258
|
const template = source?.template ?? requested ?? ref?.template ?? 'core';
|
|
254
|
-
const
|
|
259
|
+
const desktopHost = unifiedDesktopHost ?? (DESKTOP_TEMPLATES.has(template) ? template : undefined);
|
|
255
260
|
if (ref && requested && (ref.template ?? 'core') !== requested) {
|
|
256
261
|
const current = TEMPLATE_KINDS[ref.template ?? 'core'] ?? `a ${ref.template}`;
|
|
257
262
|
throw new Error(`This folder's project (${CONFIG}) is ${current} project. Add --new to start ${TEMPLATE_KINDS[requested] ?? `a ${requested}`} one, or run this in another folder.`);
|
|
@@ -273,14 +278,17 @@ const commands = {
|
|
|
273
278
|
console.log(`\n IDE ${ide}\n`);
|
|
274
279
|
if (!has('no-open'))
|
|
275
280
|
openInBrowser(ide);
|
|
276
|
-
if (
|
|
277
|
-
const first =
|
|
281
|
+
if (desktopHost) {
|
|
282
|
+
const first = desktopHost === 'electron' ? ' (the first run downloads Electron)' : desktopHost === 'expo' ? ' (the first run downloads the Expo Desktop shell)' : '';
|
|
278
283
|
console.log(`Starting the app on this ${COMPUTER}${first}. Its window streams to the IDE's Device pane. Press Ctrl+C to stop.\n`);
|
|
279
|
-
return runDesktopHost(ref);
|
|
284
|
+
return runDesktopHost({ ...ref, template: desktopHost });
|
|
280
285
|
}
|
|
281
286
|
const device = `${projectUrl(ref)}#${ref.deviceKey}`;
|
|
282
287
|
console.log(await QRCode.toString(`${ref.pairScheme ?? 'nsedge'}://pair?url=${encodeURIComponent(device)}`, { type: 'terminal', small: true }));
|
|
283
288
|
console.log(`Scan with your phone's camera to open it in ${ref.pairScheme === 'nspreview' ? 'NativeScript Preview' : 'the edge shell'}, then edit in the IDE.`);
|
|
289
|
+
if (template === 'unified') {
|
|
290
|
+
console.log(`To also run this unified project on this ${COMPUTER}, run \`npx @nativescript/edge-cli live --desktop\` (or \`--electron\`) here.`);
|
|
291
|
+
}
|
|
284
292
|
console.log('Run this command again in this folder to reopen the project.');
|
|
285
293
|
},
|
|
286
294
|
async create() {
|
package/dist/sync.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile, readdir, stat } from 'node:fs/promises';
|
|
2
2
|
import { join, relative, sep } from 'node:path';
|
|
3
3
|
/** Project-relative paths that are mirrored to the edge. */
|
|
4
|
-
export const SYNCED = /^(app|server)\/.+\.(ts|tsx|mts|js|jsx|mjs|vue|svelte|xml|html|css|json)$/;
|
|
4
|
+
export const SYNCED = /^(app|server|web)\/.+\.(ts|tsx|mts|js|jsx|mjs|vue|svelte|xml|html|css|json|svg)$/;
|
|
5
5
|
export function projectUrl(ref) {
|
|
6
6
|
return `${ref.server.replace(/\/$/, '')}/p/${ref.id}`;
|
|
7
7
|
}
|
|
@@ -48,7 +48,7 @@ export async function collect(root) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
for (const top of ['app', 'server']) {
|
|
51
|
+
for (const top of ['app', 'server', 'web']) {
|
|
52
52
|
const dir = join(root, top);
|
|
53
53
|
if (await stat(dir).then((s) => s.isDirectory(), () => false))
|
|
54
54
|
await walk(dir);
|
package/package.json
CHANGED