runcloud 0.2.234 → 0.2.237

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.
@@ -3,7 +3,7 @@ import { evaluateCompliance, renderEvaluation } from './appStoreEvaluate.js';
3
3
  const STATUSES = new Set(['pass', 'warning', 'fail', 'info']);
4
4
  const EVIDENCE_REQUIRED = new Set(['pass', 'warning', 'fail']);
5
5
  function activeItems(manifest) {
6
- return manifest.items.filter((item) => !item.deferred && item.resolvedBy !== 'card');
6
+ return manifest.items.filter((item) => !item.deferred && item.resolvedBy !== 'card' && !item.rollout);
7
7
  }
8
8
  export function loadComplianceManifest(path) {
9
9
  const manifestPath = path ?? process.env.NEWLY_APP_STORE_COMPLIANCE_MANIFEST;
@@ -155,7 +155,7 @@ export function evaluateCompliance(manifest, projectDir, options = {}) {
155
155
  const targetPlatforms = dynamicConfig ? ['ios', 'android'] : targetPlatformsFromAppJson(appJson);
156
156
  const items = [];
157
157
  const unresolved = [];
158
- for (const item of activeItems(manifest)) {
158
+ for (const item of activeItems(manifest, options.rollouts)) {
159
159
  if (!targetsItem(item, targetPlatforms)) {
160
160
  items.push(makeItem(item, 'info', `Not targeting ${platformNames(item.platform)}.`, 'app.json target platform detection'));
161
161
  continue;
@@ -206,8 +206,8 @@ export function renderEvaluation(result) {
206
206
  lines.push('', 'JSON shape: { "items": [...deterministic report_compliance rows...], "unresolved": [...] }');
207
207
  return lines.join('\n');
208
208
  }
209
- function activeItems(manifest) {
210
- return manifest.items.filter((item) => !item.deferred && item.resolvedBy !== 'card');
209
+ function activeItems(manifest, rollouts = []) {
210
+ return manifest.items.filter((item) => !item.deferred && item.resolvedBy !== 'card' && (!item.rollout || rollouts.includes(item.rollout)));
211
211
  }
212
212
  function evaluateLocalItem(root, appJson, item) {
213
213
  if (item.id === 'scheme')
@@ -263,6 +263,8 @@ function evaluateLocalItem(root, appJson, item) {
263
263
  return evaluatePrivacyManifest(root, appJson, item);
264
264
  case 'rating_prompt':
265
265
  return evaluateRatingPrompt(root, item);
266
+ case 'release_backend_target':
267
+ return evaluateReleaseBackendTarget(root, item);
266
268
  default:
267
269
  if (STORE_REMINDER_IDS.has(item.id)) {
268
270
  return makeItem(item, 'info', 'Complete this declaration in Google Play Console.', 'Play Console questionnaire');
@@ -312,6 +314,26 @@ function evaluateRestorePurchases(root, item) {
312
314
  return makeItem(item, 'pass', 'Restore purchases flow appears in source.', evidence(restore));
313
315
  return makeItem(item, 'fail', 'IAP APIs found but no restore purchases flow was found.', evidence(iap));
314
316
  }
317
+ 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
+ const RELEASE_ENV_FILES = ['.env', '.env.production', '.env.production.local', '.env.local'];
319
+ const TEST_FILE = /(^|\/)(__tests__|e2e)\/|\.(test|spec)\.[cm]?[jt]sx?$/;
320
+ function evaluateReleaseBackendTarget(root, item) {
321
+ const matches = [
322
+ ...scan(root, NON_RELEASE_BACKEND, { dirs: ['app', 'src', 'components', 'lib', 'app.json'], filter: (match) => !TEST_FILE.test(match.file) }),
323
+ ...scanFiles(root, RELEASE_ENV_FILES, NON_RELEASE_BACKEND),
324
+ ];
325
+ if (!matches.length)
326
+ return makeItem(item, 'pass', 'The release talks to no development backend or tunnel.', `scan: no matches for ${NON_RELEASE_BACKEND.source.slice(0, 60)}…`);
327
+ return makeItem(item, 'fail', 'The release still talks to a development backend or a tunnel. App Review uses the build as it ships, so a dev server that is paused, reset or rate-limited during review leaves the reviewer with an app that cannot load. Deploy the backend to production and point the app at its production address before you submit.', matches.slice(0, 5).map(({ file, line }) => `${file}:${line}`).join('\n'));
328
+ }
329
+ function scanFiles(root, names, regex) {
330
+ return names.flatMap((name) => {
331
+ const content = readText(path.join(root, name));
332
+ if (content == null)
333
+ return [];
334
+ return content.split(/\r?\n/).flatMap((line, index) => (regex.test(line) ? [{ file: name, line: index + 1, text: compact(line) }] : []));
335
+ });
336
+ }
315
337
  function evaluateRatingPrompt(root, item) {
316
338
  const asks = scan(root, /expo-store-review|react-native-in-app-review|requestReview|SKStoreReviewController/);
317
339
  if (asks.length)
@@ -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 = `npm install -g ${PACKAGE_NAME}@latest`;
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 latestPublishedVersion(exec);
64
+ latest = await source.latest(exec);
29
65
  }
30
66
  catch (error) {
31
- throw new Error(`Could not reach the npm registry to check for updates: ${errorText(error)}\n` +
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 npm registry did not report a version for ${PACKAGE_NAME}.\n` +
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 ${PACKAGE_NAME} ${current} → ${latest}…`);
76
+ log(`Updating ${source.name} ${current} → ${latest}…`);
43
77
  try {
44
- await exec('npm', ['install', '-g', `${PACKAGE_NAME}@latest`]);
78
+ await source.install(exec);
45
79
  }
46
80
  catch (error) {
47
- throw new Error(`Update failed: ${errorText(error)}\n` + `Run \`${UPDATE_COMMAND}\` to update by hand.`);
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
- if (program.opts().update !== true) {
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);
@@ -25,6 +25,7 @@ async function post(apiUrl, path, body, token) {
25
25
  method: 'POST',
26
26
  headers: {
27
27
  'content-type': 'application/json',
28
+ origin: new URL(apiUrl).origin,
28
29
  ...(token ? { authorization: `Bearer ${token}` } : {}),
29
30
  },
30
31
  body: JSON.stringify(body),
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = '0.2.234';
1
+ export const CLI_VERSION = '0.2.237';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runcloud",
3
- "version": "0.2.234",
3
+ "version": "0.2.237",
4
4
  "description": "Create and control run.cloud remote mobile simulators and cloud sandboxes",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
Binary file
Binary file