runcloud 0.1.22 → 0.1.24
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/commands/desktop.js +11 -6
- package/dist/commands/sandbox.js +4 -6
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/commands/desktop.js
CHANGED
|
@@ -2,19 +2,20 @@ import { execFileSync } from 'node:child_process';
|
|
|
2
2
|
import { randomUUID } from 'node:crypto';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
const DESKTOP_RUN_START_URL = 'http://127.0.0.1:4500/run/start';
|
|
5
|
-
export function desktopRunUrl(project, mode, start = true) {
|
|
5
|
+
export function desktopRunUrl(project, mode, start = true, platform = 'ios') {
|
|
6
6
|
const url = new URL('newly://run');
|
|
7
7
|
url.searchParams.set('project', resolve(project));
|
|
8
8
|
url.searchParams.set('mode', mode);
|
|
9
|
+
url.searchParams.set('platform', platform);
|
|
9
10
|
url.searchParams.set('start', start ? '1' : '0');
|
|
10
11
|
url.searchParams.set('request', randomUUID());
|
|
11
12
|
return url.toString();
|
|
12
13
|
}
|
|
13
|
-
export async function startDesktopRun(project, mode, fetchImpl = fetch) {
|
|
14
|
+
export async function startDesktopRun(project, mode, platform = 'ios', fetchImpl = fetch) {
|
|
14
15
|
const response = await fetchImpl(DESKTOP_RUN_START_URL, {
|
|
15
16
|
method: 'POST',
|
|
16
17
|
headers: { 'content-type': 'application/json' },
|
|
17
|
-
body: JSON.stringify({ cwd: resolve(project), key: 'default', mode }),
|
|
18
|
+
body: JSON.stringify({ cwd: resolve(project), key: 'default', mode, platform }),
|
|
18
19
|
});
|
|
19
20
|
if (response.ok)
|
|
20
21
|
return;
|
|
@@ -33,14 +34,18 @@ export function registerDesktop(program) {
|
|
|
33
34
|
const desktop = program.command('desktop').description('Control the Newly desktop app');
|
|
34
35
|
desktop
|
|
35
36
|
.command('run')
|
|
37
|
+
.alias('simulator')
|
|
36
38
|
.requiredOption('--project <path>', 'local Expo project directory')
|
|
37
39
|
.option('--mode <mode>', 'simulator mode: local or remote', 'local')
|
|
40
|
+
.option('--platform <platform>', 'simulator platform: ios or android', 'ios')
|
|
38
41
|
.action(async (opts) => {
|
|
39
42
|
if (opts.mode !== 'local' && opts.mode !== 'remote')
|
|
40
43
|
throw new Error('--mode must be local or remote');
|
|
41
|
-
|
|
44
|
+
if (opts.platform !== 'ios' && opts.platform !== 'android')
|
|
45
|
+
throw new Error('--platform must be ios or android');
|
|
46
|
+
const url = desktopRunUrl(opts.project, opts.mode, false, opts.platform);
|
|
42
47
|
openDesktopUrl(url);
|
|
43
|
-
await startDesktopRun(opts.project, opts.mode);
|
|
44
|
-
console.log(`Opened Newly and started the ${opts.mode} simulator run for ${resolve(opts.project)}`);
|
|
48
|
+
await startDesktopRun(opts.project, opts.mode, opts.platform);
|
|
49
|
+
console.log(`Opened Newly and started the ${opts.mode} ${opts.platform} simulator run for ${resolve(opts.project)}`);
|
|
45
50
|
});
|
|
46
51
|
}
|
package/dist/commands/sandbox.js
CHANGED
|
@@ -167,11 +167,13 @@ function parseMetricInterval(value) {
|
|
|
167
167
|
function formatMetricBytes(value) {
|
|
168
168
|
if (!Number.isFinite(value) || value <= 0)
|
|
169
169
|
return '0 B';
|
|
170
|
-
const unit = Math.min(Math.floor(Math.log(value) / Math.log(1024)), BYTE_UNITS.length - 1);
|
|
170
|
+
const unit = Math.max(0, Math.min(Math.floor(Math.log(value) / Math.log(1024)), BYTE_UNITS.length - 1));
|
|
171
171
|
const amount = value / 1024 ** unit;
|
|
172
172
|
return `${amount.toFixed(amount >= 10 || unit === 0 ? 0 : 1)} ${BYTE_UNITS[unit]}`;
|
|
173
173
|
}
|
|
174
174
|
function formatMetricCpu(millicores) {
|
|
175
|
+
if (!Number.isFinite(millicores) || millicores <= 0)
|
|
176
|
+
return '0m';
|
|
175
177
|
return millicores >= 1000
|
|
176
178
|
? `${(millicores / 1000).toFixed(2).replace(/\.?0+$/, '')} cores`
|
|
177
179
|
: `${Math.round(millicores)}m`;
|
|
@@ -361,11 +363,7 @@ export function registerSandbox(program) {
|
|
|
361
363
|
const api = runCloudApi();
|
|
362
364
|
const [data, boxes] = await Promise.all([
|
|
363
365
|
api.get(`/run-cloud/sandboxes${qs}`),
|
|
364
|
-
api.get('/run-cloud/boxes').catch((
|
|
365
|
-
if (err instanceof ApiError && err.status === 404)
|
|
366
|
-
return { items: [] };
|
|
367
|
-
throw err;
|
|
368
|
-
}),
|
|
366
|
+
api.get('/run-cloud/boxes').catch(() => ({ items: [] })),
|
|
369
367
|
]);
|
|
370
368
|
const bySandbox = new Map((boxes?.items ?? []).map((box) => [box.sandboxId, box]));
|
|
371
369
|
const items = (data?.items ?? []).map((item) => {
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = '0.1.
|
|
1
|
+
export const CLI_VERSION = '0.1.24';
|