runcloud 0.2.235 → 0.2.238
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/appStoreEvaluate.js +191 -13
- package/dist/commands/update.js +52 -16
- package/dist/run-cloud-interactive.js +1 -1
- package/dist/run-cloud.js +2 -0
- package/dist/runCloudAuth.js +1 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/runcloud-0.2.238.tgz +0 -0
- package/runcloud-0.2.235.tgz +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, readFileSync, readdirSync, statSync, } from 'node:fs';
|
|
1
|
+
import { existsSync, lstatSync, readFileSync, readdirSync, realpathSync, statSync, } from 'node:fs';
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
const PREVIEW_APP_ID = 'app.newly.preview';
|
|
@@ -28,7 +28,7 @@ const CONFIG_RULES = {
|
|
|
28
28
|
orientation: { path: ['expo', 'orientation'], absent: 'info' },
|
|
29
29
|
ios_supports_tablet: { path: ['expo', 'ios', 'supportsTablet'], absent: 'info' },
|
|
30
30
|
};
|
|
31
|
-
const READS_APP_CONFIG = new Set([...Object.keys(CONFIG_RULES), 'ios_encryption', 'plugin_permission_missing', 'permission_descriptions', 'privacy_manifest']);
|
|
31
|
+
const READS_APP_CONFIG = new Set([...Object.keys(CONFIG_RULES), 'ios_encryption', 'plugin_permission_missing', 'permission_descriptions', 'privacy_manifest', 'app_icon', 'app_icon_alpha', 'splash_screen', 'splash_bg_color']);
|
|
32
32
|
const DYNAMIC_CONFIGS = ['ts', 'mts', 'cts', 'mjs', 'cjs', 'js'].map((ext) => `app.config.${ext}`);
|
|
33
33
|
export function dynamicExpoConfig(root) {
|
|
34
34
|
return DYNAMIC_CONFIGS.find((name) => existsSync(path.join(root, name)));
|
|
@@ -117,6 +117,8 @@ const SKIP_DIRS = new Set([
|
|
|
117
117
|
'.expo',
|
|
118
118
|
'.git',
|
|
119
119
|
'.next',
|
|
120
|
+
'.newly',
|
|
121
|
+
'legacy-attachments',
|
|
120
122
|
'build',
|
|
121
123
|
'dist',
|
|
122
124
|
'node_modules',
|
|
@@ -217,11 +219,15 @@ function evaluateLocalItem(root, appJson, item) {
|
|
|
217
219
|
return evaluateConfigItem(appJson, item, rule);
|
|
218
220
|
switch (item.id) {
|
|
219
221
|
case 'hardcoded_secrets':
|
|
220
|
-
return
|
|
221
|
-
filter: (match) => !isFirebaseClientKey(root, match),
|
|
222
|
-
});
|
|
222
|
+
return evaluateSecrets(root, item);
|
|
223
223
|
case 'http_endpoints':
|
|
224
|
-
return
|
|
224
|
+
return evaluateHttpEndpoints(root, appJson, item);
|
|
225
|
+
case 'app_icon':
|
|
226
|
+
case 'app_icon_alpha':
|
|
227
|
+
return evaluateIcon(root, appJson, item);
|
|
228
|
+
case 'splash_screen':
|
|
229
|
+
case 'splash_bg_color':
|
|
230
|
+
return evaluateSplash(root, appJson, item);
|
|
225
231
|
case 'placeholder_content':
|
|
226
232
|
return patternItem(root, item, PLACEHOLDER_COPY, 'warning', 'Placeholder text found.', 'No placeholder text found.', {
|
|
227
233
|
filter: (match) => PLACEHOLDER_COPY.test(withoutInputPlaceholders(match.text)),
|
|
@@ -305,14 +311,186 @@ function evaluateEncryption(appJson, item) {
|
|
|
305
311
|
return makeItem(item, 'pass', `${item.label} is set.`, evidence);
|
|
306
312
|
return makeItem(item, 'info', `${item.label} is declared exempt (no non-exempt encryption) when you publish.`, evidence);
|
|
307
313
|
}
|
|
314
|
+
const IAP_PACKAGES = ['react-native-purchases', 'react-native-iap', 'expo-iap', 'expo-in-app-purchases'];
|
|
308
315
|
function evaluateRestorePurchases(root, item) {
|
|
309
|
-
const
|
|
310
|
-
|
|
316
|
+
const deps = objectValue(getPath(readJson(path.join(root, 'package.json')), ['dependencies']));
|
|
317
|
+
const installed = IAP_PACKAGES.filter((name) => Object.hasOwn(deps, name));
|
|
318
|
+
const iap = scan(root, /['"](?:react-native-purchases|react-native-iap|expo-iap|expo-in-app-purchases)['"]|StoreKit/i, { projectWide: true });
|
|
319
|
+
if (!installed.length && !iap.length)
|
|
311
320
|
return makeItem(item, 'pass', 'No in-app purchase APIs found.', 'scan: no IAP APIs found');
|
|
312
|
-
const restore = scan(root,
|
|
321
|
+
const restore = scan(root, /\b(?:restorePurchases|restoreTransactions|getAvailablePurchases)\s*\(/i, { projectWide: true });
|
|
313
322
|
if (restore.length)
|
|
314
323
|
return makeItem(item, 'pass', 'Restore purchases flow appears in source.', evidence(restore));
|
|
315
|
-
return makeItem(item, 'fail', 'IAP APIs found but no restore purchases flow was found.', evidence(iap));
|
|
324
|
+
return makeItem(item, 'fail', 'IAP APIs found but no restore purchases flow was found.', installed.length ? `package.json dependencies: ${installed.join(', ')}` : evidence(iap));
|
|
325
|
+
}
|
|
326
|
+
function evaluateSecrets(root, item) {
|
|
327
|
+
const pattern = /sk-[A-Za-z0-9_-]{20,}|sk_live_[A-Za-z0-9]{20,}|AIza[0-9A-Za-z_-]{30,}|['"]AAAA[A-Za-z0-9:_-]{100,}['"]|-----BEGIN.*PRIVATE KEY|(?:api[_-]?key|service[_-]?role[_-]?key|secret)\s*[:=]\s*['"][A-Za-z0-9_.-]{16,}/i;
|
|
328
|
+
const hits = scan(root, pattern, { projectWide: true, filter: (match) => !isFirebaseClientKey(root, match) });
|
|
329
|
+
if (!hits.length)
|
|
330
|
+
return makeItem(item, 'pass', 'No secret-like values found.', 'scan: no secret-like values found');
|
|
331
|
+
const locations = hits.slice(0, 5).map(({ file, line }) => `${file}:${line}`).join('\n');
|
|
332
|
+
return makeItem(item, 'fail', 'Hardcoded secret-like value found.', locations);
|
|
333
|
+
}
|
|
334
|
+
function nonLocalHttpHosts(line) {
|
|
335
|
+
if (line.trimStart().startsWith('//'))
|
|
336
|
+
return [];
|
|
337
|
+
return [...line.matchAll(/['"`]http:\/\/([^'"`\s]+)['"`]/gi)].flatMap((endpoint) => {
|
|
338
|
+
if (/^www\.apple\.com\/DTDs\//i.test(endpoint[1] ?? ''))
|
|
339
|
+
return [];
|
|
340
|
+
const host = endpoint[1]?.split(/[/:]/, 1)[0]?.toLowerCase();
|
|
341
|
+
return !host || /^(?:localhost$|127\.|0\.0\.0\.0$|10\.|192\.168\.|172\.(?:1[6-9]|2\d|3[01])\.|www\.w3\.org$|schemas\.android\.com$)/.test(host) ? [] : [host];
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
function evaluateHttpEndpoints(root, appJson, item) {
|
|
345
|
+
const hits = scan(root, /http:\/\//i, { projectWide: true, filter: (match) => nonLocalHttpHosts(match.text).length > 0 });
|
|
346
|
+
if (!hits.length)
|
|
347
|
+
return makeItem(item, 'pass', 'No non-local HTTP endpoints found.', 'scan: no non-local HTTP endpoints found');
|
|
348
|
+
const hosts = new Set(hits.flatMap((hit) => nonLocalHttpHosts(hit.text)));
|
|
349
|
+
const ats = objectValue(getPath(appJson, ['expo', 'ios', 'infoPlist', 'NSAppTransportSecurity']));
|
|
350
|
+
const exceptions = objectValue(ats.NSExceptionDomains);
|
|
351
|
+
const uncovered = [...hosts].filter((host) => !Object.entries(exceptions).some(([domain, config]) => {
|
|
352
|
+
const rule = objectValue(config);
|
|
353
|
+
return (host === domain || (rule.NSIncludesSubdomains === true && host.endsWith(`.${domain}`))) &&
|
|
354
|
+
(rule.NSExceptionAllowsInsecureHTTPLoads === true || rule.NSTemporaryExceptionAllowsInsecureHTTPLoads === true);
|
|
355
|
+
}));
|
|
356
|
+
const allowed = ats.NSAllowsArbitraryLoads === true || !uncovered.length;
|
|
357
|
+
const message = allowed
|
|
358
|
+
? 'Non-local HTTP endpoint found. App Transport Security allows it, but HTTPS is recommended.'
|
|
359
|
+
: 'Non-local HTTP endpoint found without a matching App Transport Security exception. Use HTTPS.';
|
|
360
|
+
return makeItem(item, 'warning', message, hits.slice(0, 5).map(({ file, line }) => `${file}:${line}`).join('\n'));
|
|
361
|
+
}
|
|
362
|
+
const MAX_INSPECT_BYTES = 32 * 1024 * 1024;
|
|
363
|
+
function inspectProjectAsset(root, value) {
|
|
364
|
+
if (/^[a-z][a-z\d+.-]*:/i.test(value) || path.isAbsolute(value))
|
|
365
|
+
return { kind: 'unchecked' };
|
|
366
|
+
const file = path.resolve(root, value);
|
|
367
|
+
if (!file.startsWith(root + path.sep))
|
|
368
|
+
return { kind: 'unchecked' };
|
|
369
|
+
try {
|
|
370
|
+
const realRoot = realpathSync(root);
|
|
371
|
+
const realFile = realpathSync(file);
|
|
372
|
+
if (!realFile.startsWith(realRoot + path.sep))
|
|
373
|
+
return { kind: 'unchecked' };
|
|
374
|
+
const info = lstatSync(realFile);
|
|
375
|
+
if (info.isDirectory() && value.endsWith('.icon')) {
|
|
376
|
+
const descriptor = lstatSync(path.join(realFile, 'icon.json'));
|
|
377
|
+
return { kind: descriptor.isFile() ? 'composer' : 'missing' };
|
|
378
|
+
}
|
|
379
|
+
if (!info.isFile() || info.size > MAX_INSPECT_BYTES)
|
|
380
|
+
return { kind: 'unchecked' };
|
|
381
|
+
const image = inspectImage(readFileSync(realFile));
|
|
382
|
+
return image ? { kind: 'image', ...image } : { kind: 'unchecked' };
|
|
383
|
+
}
|
|
384
|
+
catch (error) {
|
|
385
|
+
return { kind: error.code === 'ENOENT' ? 'missing' : 'unchecked' };
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
const PNG_SIGNATURE = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
|
389
|
+
function inspectImage(bytes) {
|
|
390
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
391
|
+
if (bytes.length > 24 && PNG_SIGNATURE.every((byte, i) => bytes[i] === byte)) {
|
|
392
|
+
const colorType = bytes[25];
|
|
393
|
+
let alpha = colorType === 4 || colorType === 6;
|
|
394
|
+
for (let at = 8; !alpha && at + 8 <= bytes.length;) {
|
|
395
|
+
const length = view.getUint32(at);
|
|
396
|
+
const type = String.fromCharCode(...bytes.subarray(at + 4, at + 8));
|
|
397
|
+
if (type === "IDAT" || type === "IEND")
|
|
398
|
+
break;
|
|
399
|
+
if (type === "tRNS")
|
|
400
|
+
alpha = true;
|
|
401
|
+
at += 12 + length;
|
|
402
|
+
}
|
|
403
|
+
return { format: "png", width: view.getUint32(16), height: view.getUint32(20), alpha };
|
|
404
|
+
}
|
|
405
|
+
if (bytes[0] === 0xff && bytes[1] === 0xd8) {
|
|
406
|
+
for (let at = 2; at + 9 < bytes.length;) {
|
|
407
|
+
if (bytes[at] !== 0xff)
|
|
408
|
+
return null;
|
|
409
|
+
const marker = bytes[at + 1];
|
|
410
|
+
if (marker === 0xff) {
|
|
411
|
+
at += 1;
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
const length = view.getUint16(at + 2);
|
|
415
|
+
if (marker >= 0xc0 && marker <= 0xcf && ![0xc4, 0xc8, 0xcc].includes(marker)) {
|
|
416
|
+
return { format: "jpeg", height: view.getUint16(at + 5), width: view.getUint16(at + 7), alpha: false };
|
|
417
|
+
}
|
|
418
|
+
at += 2 + length;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
function evaluateIcon(root, appJson, item) {
|
|
424
|
+
const config = getPath(appJson, ['expo', 'ios', 'icon']);
|
|
425
|
+
const base = stringValue(getPath(appJson, ['expo', 'icon']));
|
|
426
|
+
const appearances = objectValue(config);
|
|
427
|
+
const primary = stringValue(config) ?? stringValue(appearances.light) ?? base;
|
|
428
|
+
const alpha = item.id === 'app_icon_alpha';
|
|
429
|
+
const icons = [primary, ...(alpha ? [] : [stringValue(appearances.dark), stringValue(appearances.tinted)])]
|
|
430
|
+
.filter((icon) => Boolean(icon));
|
|
431
|
+
if (existsSync(path.join(root, 'ios'))) {
|
|
432
|
+
return makeItem(item, 'info', 'Check the app icon in the native Xcode asset catalog.', 'ios project checked in');
|
|
433
|
+
}
|
|
434
|
+
if (!primary) {
|
|
435
|
+
return makeItem(item, alpha ? 'info' : 'fail', 'No default iOS app icon is set in app.json.', 'app.json expo.ios.icon and expo.icon');
|
|
436
|
+
}
|
|
437
|
+
let unchecked = false;
|
|
438
|
+
for (const icon of icons) {
|
|
439
|
+
const asset = inspectProjectAsset(root, icon);
|
|
440
|
+
if (asset.kind === 'missing') {
|
|
441
|
+
return makeItem(item, alpha ? 'info' : 'fail', 'The configured iOS app icon is missing.', icon);
|
|
442
|
+
}
|
|
443
|
+
if (asset.kind === 'composer' && alpha) {
|
|
444
|
+
return makeItem(item, 'pass', 'Icon Composer renders the App Store icon from its layers.', icon);
|
|
445
|
+
}
|
|
446
|
+
if (asset.kind === 'image') {
|
|
447
|
+
if (alpha && asset.alpha)
|
|
448
|
+
return makeItem(item, 'fail', 'The iOS app icon has an alpha channel. Export an opaque icon.', icon);
|
|
449
|
+
if (!alpha && (asset.width !== asset.height || asset.width < 1024)) {
|
|
450
|
+
return makeItem(item, 'fail', `The iOS app icon is ${asset.width}×${asset.height}. Use a square image at least 1024×1024.`, icon);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
else if (asset.kind === 'unchecked') {
|
|
454
|
+
unchecked = true;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
if (unchecked)
|
|
458
|
+
return makeItem(item, 'info', 'Check the rendered icon for this asset at build time.', icons.join(', '));
|
|
459
|
+
return makeItem(item, 'pass', alpha ? 'The iOS app icon has no alpha channel.' : 'The configured iOS app icon passed the asset check.', icons.join(', '));
|
|
460
|
+
}
|
|
461
|
+
function evaluateSplash(root, appJson, item) {
|
|
462
|
+
if (existsSync(path.join(root, 'ios'))) {
|
|
463
|
+
return makeItem(item, 'info', 'Check the splash screen in the native Xcode project.', 'ios project checked in');
|
|
464
|
+
}
|
|
465
|
+
const plugins = getPath(appJson, ['expo', 'plugins']);
|
|
466
|
+
const plugin = Array.isArray(plugins) ? plugins.find((entry) => Array.isArray(entry) && entry[0] === 'expo-splash-screen') : undefined;
|
|
467
|
+
const pluginConfig = objectValue(plugin?.[1]);
|
|
468
|
+
const iosPluginConfig = objectValue(pluginConfig.ios);
|
|
469
|
+
const iosSplash = getPath(appJson, ['expo', 'ios', 'splash']);
|
|
470
|
+
const splash = getPath(appJson, ['expo', 'splash']);
|
|
471
|
+
const splashColor = [iosPluginConfig.backgroundColor, pluginConfig.backgroundColor, getPath(iosSplash, ['backgroundColor']), getPath(splash, ['backgroundColor'])].map(stringValue).find(Boolean);
|
|
472
|
+
if (item.id === 'splash_bg_color') {
|
|
473
|
+
const color = splashColor;
|
|
474
|
+
return makeItem(item, color ? 'pass' : 'info', color ? 'The splash background color is set.' : 'No splash background color is set.', 'app.json splash settings');
|
|
475
|
+
}
|
|
476
|
+
const pluginImage = [iosPluginConfig.image, pluginConfig.image].map(stringValue).find(Boolean);
|
|
477
|
+
const image = pluginImage ?? stringValue(getPath(iosSplash, ['image'])) ?? stringValue(getPath(splash, ['image']));
|
|
478
|
+
if (!image)
|
|
479
|
+
return makeItem(item, splashColor ? 'info' : 'warning', splashColor ? 'The splash screen uses a background color only.' : 'No splash image is set in app.json.', 'app.json splash settings');
|
|
480
|
+
const darkImage = [objectValue(iosPluginConfig.dark).image, objectValue(pluginConfig.dark).image, getPath(iosSplash, ['dark', 'image'])]
|
|
481
|
+
.map(stringValue).find(Boolean);
|
|
482
|
+
if (darkImage && inspectProjectAsset(root, darkImage).kind === 'missing') {
|
|
483
|
+
return makeItem(item, 'warning', 'The configured dark mode splash image is missing.', darkImage);
|
|
484
|
+
}
|
|
485
|
+
const asset = inspectProjectAsset(root, image);
|
|
486
|
+
if (asset.kind === 'missing')
|
|
487
|
+
return makeItem(item, 'warning', 'The configured splash image is missing.', image);
|
|
488
|
+
if (asset.kind !== 'image')
|
|
489
|
+
return makeItem(item, 'info', 'The configured splash image could not be inspected.', image);
|
|
490
|
+
if (!pluginImage && (asset.width < 1024 || asset.height < 1024)) {
|
|
491
|
+
return makeItem(item, 'warning', `The legacy full-screen splash image is ${asset.width}×${asset.height}. Use an image at least 1024×1024.`, image);
|
|
492
|
+
}
|
|
493
|
+
return makeItem(item, 'pass', `The splash image is ${asset.width}×${asset.height}.`, image);
|
|
316
494
|
}
|
|
317
495
|
const NON_RELEASE_BACKEND = /[a-z0-9]+-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}-dev\.api\.newlyapp\.com|\.api-dev\.newlyapp\.com|\b[a-z0-9-]+\.(?:ngrok(?:-free)?\.(?:app|dev|io)|loca\.lt|trycloudflare\.com)\b|\b10\.0\.2\.2\b/i;
|
|
318
496
|
const RELEASE_ENV_FILES = ['.env', '.env.production', '.env.production.local', '.env.local'];
|
|
@@ -624,7 +802,7 @@ function makeItem(manifestItem, status, message, evidenceText) {
|
|
|
624
802
|
};
|
|
625
803
|
}
|
|
626
804
|
function scan(root, regex, options = {}) {
|
|
627
|
-
const files = collectScanFiles(root, options.dirs);
|
|
805
|
+
const files = options.projectWide ? walkFiles(root).filter((file) => !file.endsWith('.md') && (safeStat(file)?.size ?? Infinity) <= 1_000_000) : collectScanFiles(root, options.dirs);
|
|
628
806
|
const matches = [];
|
|
629
807
|
for (const file of files) {
|
|
630
808
|
const content = readText(file);
|
|
@@ -636,7 +814,7 @@ function scan(root, regex, options = {}) {
|
|
|
636
814
|
regex.lastIndex = 0;
|
|
637
815
|
if (!regex.test(line))
|
|
638
816
|
return;
|
|
639
|
-
const match = { file: rel, line: index + 1, text:
|
|
817
|
+
const match = { file: rel, line: index + 1, text: line };
|
|
640
818
|
if (options.filter && !options.filter(match))
|
|
641
819
|
return;
|
|
642
820
|
matches.push(match);
|
|
@@ -700,7 +878,7 @@ function routeKeys(appDir, file) {
|
|
|
700
878
|
return keys;
|
|
701
879
|
}
|
|
702
880
|
function evidence(matches) {
|
|
703
|
-
return matches.slice(0, 5).map((match) => `${match.file}:${match.line}: ${match.text}`).join('\n');
|
|
881
|
+
return matches.slice(0, 5).map((match) => `${match.file}:${match.line}: ${compact(match.text)}`).join('\n');
|
|
704
882
|
}
|
|
705
883
|
function asReleased(appJson, iosBundleId) {
|
|
706
884
|
const expo = getPath(appJson, ['expo']);
|
package/dist/commands/update.js
CHANGED
|
@@ -1,12 +1,50 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
2
|
import { promisify } from 'node:util';
|
|
3
|
+
import { dirname } from 'node:path';
|
|
4
|
+
import { Option } from 'commander';
|
|
3
5
|
import { CLI_VERSION } from '../version.js';
|
|
4
6
|
export const PACKAGE_NAME = '@newly/cli';
|
|
5
|
-
export const UPDATE_COMMAND =
|
|
7
|
+
export const UPDATE_COMMAND = npmSource(PACKAGE_NAME).manualCommand;
|
|
6
8
|
const defaultExec = async (file, args) => {
|
|
7
9
|
const { stdout } = await promisify(execFile)(file, args, { encoding: 'utf8' });
|
|
8
10
|
return { stdout };
|
|
9
11
|
};
|
|
12
|
+
export function npmSource(packageName) {
|
|
13
|
+
return {
|
|
14
|
+
name: packageName,
|
|
15
|
+
manualCommand: `npm install -g ${packageName}@latest`,
|
|
16
|
+
latest: async (exec) => (await exec('npm', ['view', `${packageName}@latest`, 'version'])).stdout.trim(),
|
|
17
|
+
install: async (exec) => {
|
|
18
|
+
await exec('npm', ['install', '-g', `${packageName}@latest`]);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export const RUNCLOUD_INSTALLER_URL = 'https://run.cloud/install';
|
|
23
|
+
export const RUNCLOUD_LATEST_URL = 'https://dl.run.cloud/latest.json';
|
|
24
|
+
export function runCloudBinarySource(binaryPath) {
|
|
25
|
+
const installDir = dirname(binaryPath);
|
|
26
|
+
return {
|
|
27
|
+
name: 'runcloud',
|
|
28
|
+
manualCommand: `curl -fsSL ${RUNCLOUD_INSTALLER_URL} | RUNCLOUD_INSTALL_DIR=${installDir} sh`,
|
|
29
|
+
latest: async (exec) => {
|
|
30
|
+
const { stdout } = await exec('curl', ['-fsSL', RUNCLOUD_LATEST_URL]);
|
|
31
|
+
const version = JSON.parse(stdout).version;
|
|
32
|
+
return typeof version === 'string' ? version.trim() : '';
|
|
33
|
+
},
|
|
34
|
+
install: async (exec) => {
|
|
35
|
+
await exec('sh', [
|
|
36
|
+
'-c',
|
|
37
|
+
'curl -fsSL "$1" | RUNCLOUD_INSTALL_DIR="$2" RUNCLOUD_NO_LOGIN=1 sh',
|
|
38
|
+
'sh',
|
|
39
|
+
RUNCLOUD_INSTALLER_URL,
|
|
40
|
+
installDir,
|
|
41
|
+
]);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export function runCloudSource() {
|
|
46
|
+
return process.versions.bun ? runCloudBinarySource(process.execPath) : npmSource('runcloud');
|
|
47
|
+
}
|
|
10
48
|
function errorText(error) {
|
|
11
49
|
if (error && typeof error === 'object') {
|
|
12
50
|
const stderr = error.stderr;
|
|
@@ -15,48 +53,46 @@ function errorText(error) {
|
|
|
15
53
|
}
|
|
16
54
|
return error instanceof Error ? error.message : String(error);
|
|
17
55
|
}
|
|
18
|
-
export async function latestPublishedVersion(exec) {
|
|
19
|
-
const { stdout } = await exec('npm', ['view', `${PACKAGE_NAME}@latest`, 'version']);
|
|
20
|
-
return stdout.trim();
|
|
21
|
-
}
|
|
22
56
|
export async function updateCli(deps = {}) {
|
|
23
57
|
const exec = deps.exec ?? defaultExec;
|
|
24
58
|
const log = deps.log ?? ((message) => console.log(message));
|
|
25
59
|
const current = deps.currentVersion ?? CLI_VERSION;
|
|
60
|
+
const source = deps.source ?? npmSource(PACKAGE_NAME);
|
|
61
|
+
const byHand = `Run \`${source.manualCommand}\` to update by hand.`;
|
|
26
62
|
let latest;
|
|
27
63
|
try {
|
|
28
|
-
latest = await
|
|
64
|
+
latest = await source.latest(exec);
|
|
29
65
|
}
|
|
30
66
|
catch (error) {
|
|
31
|
-
throw new Error(`Could not
|
|
32
|
-
`Run \`${UPDATE_COMMAND}\` to update by hand.`);
|
|
67
|
+
throw new Error(`Could not check for updates: ${errorText(error)}\n${byHand}`);
|
|
33
68
|
}
|
|
34
69
|
if (!latest) {
|
|
35
|
-
throw new Error(`The
|
|
36
|
-
`Run \`${UPDATE_COMMAND}\` to update by hand.`);
|
|
70
|
+
throw new Error(`The release source did not report a version for ${source.name}.\n${byHand}`);
|
|
37
71
|
}
|
|
38
72
|
if (latest === current) {
|
|
39
73
|
log(`Already on the latest version (${current}).`);
|
|
40
74
|
return;
|
|
41
75
|
}
|
|
42
|
-
log(`Updating ${
|
|
76
|
+
log(`Updating ${source.name} ${current} → ${latest}…`);
|
|
43
77
|
try {
|
|
44
|
-
await exec
|
|
78
|
+
await source.install(exec);
|
|
45
79
|
}
|
|
46
80
|
catch (error) {
|
|
47
|
-
throw new Error(`Update failed: ${errorText(error)}\n
|
|
81
|
+
throw new Error(`Update failed: ${errorText(error)}\n${byHand}`);
|
|
48
82
|
}
|
|
49
83
|
log(`Updated to ${latest}.`);
|
|
50
84
|
}
|
|
51
|
-
export function registerUpdate(program) {
|
|
85
|
+
export function registerUpdate(program, source) {
|
|
52
86
|
program.option('-u, --update', 'update this CLI to the latest published version');
|
|
87
|
+
program.addOption(new Option('-U', 'same as --update').hideHelp());
|
|
53
88
|
program.action(async () => {
|
|
54
|
-
|
|
89
|
+
const opts = program.opts();
|
|
90
|
+
if (opts.update !== true && opts.U !== true) {
|
|
55
91
|
program.help();
|
|
56
92
|
return;
|
|
57
93
|
}
|
|
58
94
|
try {
|
|
59
|
-
await updateCli();
|
|
95
|
+
await updateCli({ source });
|
|
60
96
|
}
|
|
61
97
|
catch (error) {
|
|
62
98
|
console.error(error instanceof Error ? error.message : String(error));
|
|
@@ -88,7 +88,7 @@ function beforeDelimiter(argv) {
|
|
|
88
88
|
return delimiter < 0 ? argv : argv.slice(0, delimiter);
|
|
89
89
|
}
|
|
90
90
|
function suppressInteractive(argv) {
|
|
91
|
-
return beforeDelimiter(argv).some(arg => ['--json', '--help', '-h', '--version', '-V'].includes(arg) || arg.startsWith('--json='))
|
|
91
|
+
return beforeDelimiter(argv).some(arg => ['--json', '--help', '-h', '--version', '-V', '--update', '-u', '-U'].includes(arg) || arg.startsWith('--json='))
|
|
92
92
|
|| argv[0] === 'help';
|
|
93
93
|
}
|
|
94
94
|
function quoted(value) {
|
package/dist/run-cloud.js
CHANGED
|
@@ -7,6 +7,7 @@ import { registerRunCloudFleet } from './commands/run-cloud-fleet.js';
|
|
|
7
7
|
import { registerSandbox } from './commands/sandbox.js';
|
|
8
8
|
import { registerSecrets } from './commands/secrets.js';
|
|
9
9
|
import { registerToken } from './commands/token.js';
|
|
10
|
+
import { registerUpdate, runCloudSource } from './commands/update.js';
|
|
10
11
|
import { registerXcode } from './commands/xcode.js';
|
|
11
12
|
import { CLI_VERSION } from './version.js';
|
|
12
13
|
import { runCloudCli } from './run-cloud-interactive.js';
|
|
@@ -28,4 +29,5 @@ registerSecrets(program);
|
|
|
28
29
|
registerToken(program);
|
|
29
30
|
registerXcode(program);
|
|
30
31
|
registerImage(program);
|
|
32
|
+
registerUpdate(program, runCloudSource());
|
|
31
33
|
await runCloudCli(program);
|
package/dist/runCloudAuth.js
CHANGED
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = '0.2.
|
|
1
|
+
export const CLI_VERSION = '0.2.238';
|
package/package.json
CHANGED
|
Binary file
|
package/runcloud-0.2.235.tgz
DELETED
|
Binary file
|