runcloud 0.2.220 → 0.2.222

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.
@@ -1185,6 +1185,73 @@ async function simulatorSessionSettings(platform, sessionId, softKeyboard) {
1185
1185
  throw error;
1186
1186
  }
1187
1187
  }
1188
+ export const SIMULATOR_APPEARANCES = ['light', 'dark'];
1189
+ export const SIMULATOR_PERMISSION_SERVICES = [
1190
+ 'camera', 'microphone', 'location', 'location-always', 'notifications', 'photos',
1191
+ 'contacts', 'calendar', 'reminders', 'motion', 'media-library', 'siri',
1192
+ ];
1193
+ export const SIMULATOR_PERMISSION_ACTIONS = ['grant', 'revoke', 'reset'];
1194
+ const SIMULATOR_APP_ID_PATTERN = /^[A-Za-z0-9._-]{1,255}$/;
1195
+ const SIMULATOR_PUSH_MAX_BYTES = 4096;
1196
+ function parseSimulatorAppId(value) {
1197
+ if (!SIMULATOR_APP_ID_PATTERN.test(value)) {
1198
+ throw new InvalidArgumentError("must be 1-255 characters of A-Z, a-z, 0-9, '.', '_' or '-'");
1199
+ }
1200
+ return value;
1201
+ }
1202
+ function parseAllowed(allowed, value, field) {
1203
+ if (!allowed.includes(value)) {
1204
+ throw new InvalidArgumentError(`${field} must be one of ${allowed.join(', ')}`);
1205
+ }
1206
+ return value;
1207
+ }
1208
+ export function readSimulatorPushPayload(file, readStdin = () => readFileSync(0)) {
1209
+ const raw = file === '-' ? readStdin() : readFileSync(resolve(file));
1210
+ let payload;
1211
+ try {
1212
+ payload = JSON.parse(raw.toString('utf8'));
1213
+ }
1214
+ catch {
1215
+ throw new Error('The push payload must be valid JSON');
1216
+ }
1217
+ const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
1218
+ if (!isObject(payload) || !isObject(payload.aps))
1219
+ throw new Error('The push payload must be a JSON object with an "aps" object');
1220
+ const bytes = Buffer.byteLength(JSON.stringify(payload), 'utf8');
1221
+ if (bytes > SIMULATOR_PUSH_MAX_BYTES)
1222
+ throw new Error(`The push payload is ${bytes} bytes; the limit is ${SIMULATOR_PUSH_MAX_BYTES}`);
1223
+ return payload;
1224
+ }
1225
+ async function simulatorDeviceControl(platform, sessionId, kind, body) {
1226
+ const path = `/run-cloud/${platform}/${encodeURIComponent(sessionId)}/${kind}`;
1227
+ try {
1228
+ const response = await client().post(path, body);
1229
+ const result = typeof response === 'object' && response !== null && !Array.isArray(response)
1230
+ ? response
1231
+ : {};
1232
+ if (result.ok !== true || result.platform !== platform || result.sessionId !== sessionId || typeof result.device !== 'string') {
1233
+ throw new ApiError(0, `Simulator ${kind} returned an invalid acknowledgement`, path, {
1234
+ code: 'device_control_invalid_response', retryable: true, sessionId, platform, action: kind,
1235
+ });
1236
+ }
1237
+ return result;
1238
+ }
1239
+ catch (error) {
1240
+ if (error instanceof ApiTransportError) {
1241
+ throw new ApiError(0, `Simulator ${kind} could not reach the run.cloud API`, path, {
1242
+ code: 'device_control_transport_error', retryable: true, sessionId, platform, action: kind,
1243
+ });
1244
+ }
1245
+ if (error instanceof ApiError) {
1246
+ Object.assign(error, {
1247
+ sessionId: error.sessionId ?? sessionId,
1248
+ platform: error.platform ?? platform,
1249
+ action: error.action ?? kind,
1250
+ });
1251
+ }
1252
+ throw error;
1253
+ }
1254
+ }
1188
1255
  function registerSimulatorCommands(program, platform) {
1189
1256
  const label = platform === 'android' ? 'Android emulator' : 'iOS simulator';
1190
1257
  const article = platform === 'android' ? 'an' : 'an';
@@ -1329,6 +1396,51 @@ function registerSimulatorCommands(program, platform) {
1329
1396
  .action((id, opts) => action(async () => {
1330
1397
  print(await simulatorSessionSettings(platform, id, opts.softKeyboard), opts);
1331
1398
  }, opts));
1399
+ simulator
1400
+ .command('appearance')
1401
+ .description(`Switch ${article} ${label} session to light or dark appearance`)
1402
+ .argument('<id>', 'session id')
1403
+ .argument('<mode>', 'light or dark', (value) => parseAllowed(SIMULATOR_APPEARANCES, value, 'mode'))
1404
+ .option('--json', 'output JSON', false)
1405
+ .action((id, mode, opts) => action(async () => {
1406
+ print(await simulatorDeviceControl(platform, id, 'appearance', { mode }), opts);
1407
+ }, opts));
1408
+ const appKey = platform === 'android' ? 'packageName' : 'bundleId';
1409
+ const permissions = simulator
1410
+ .command('permissions')
1411
+ .alias('permission')
1412
+ .description(`Grant, revoke, or reset app privacy permissions in ${article} ${label} session`);
1413
+ for (const verb of SIMULATOR_PERMISSION_ACTIONS) {
1414
+ permissions
1415
+ .command(verb)
1416
+ .description(verb === 'reset'
1417
+ ? 'Reset permissions so the app asks again'
1418
+ : `${verb === 'grant' ? 'Grant' : 'Revoke'} permissions for an app`)
1419
+ .argument('<id>', 'session id')
1420
+ .argument('<services...>', `one or more of ${SIMULATOR_PERMISSION_SERVICES.join(', ')}`, (value, previous = []) => [...previous, parseAllowed(SIMULATOR_PERMISSION_SERVICES, value, 'service')])
1421
+ .requiredOption('--app <id>', platform === 'android' ? 'Android package name' : 'iOS bundle identifier', parseSimulatorAppId)
1422
+ .option('--json', 'output JSON', false)
1423
+ .action((id, services, opts) => action(async () => {
1424
+ const results = [];
1425
+ for (const service of services) {
1426
+ results.push(await simulatorDeviceControl(platform, id, 'permissions', { [appKey]: opts.app, service, action: verb }));
1427
+ }
1428
+ print(results.length === 1 ? results[0] : results, opts);
1429
+ }, opts));
1430
+ }
1431
+ if (platform === 'ios') {
1432
+ simulator
1433
+ .command('push')
1434
+ .description('Deliver a simulated APNs push notification to an app (simctl push)')
1435
+ .argument('<id>', 'session id')
1436
+ .argument('<payload>', 'APNs JSON file with an "aps" object (max 4 KiB), or - for stdin')
1437
+ .requiredOption('--app <bundle-id>', 'iOS bundle identifier', parseSimulatorAppId)
1438
+ .option('--json', 'output JSON', false)
1439
+ .action((id, file, opts) => action(async () => {
1440
+ const payload = readSimulatorPushPayload(file);
1441
+ print(await simulatorDeviceControl(platform, id, 'push', { bundleId: opts.app, payload }), opts);
1442
+ }, opts));
1443
+ }
1332
1444
  addInteractionOptions(simulator
1333
1445
  .command('tap')
1334
1446
  .description(`Tap normalized display coordinates in ${article} ${label} session`)
@@ -266,14 +266,18 @@ export async function requestFor(flags) {
266
266
  }
267
267
  const manualValues = [flags.certificateP12, flags.certificatePassword, ...(flags.provisioningProfile ?? [])];
268
268
  const hasManual = manualValues.some(Boolean);
269
- if (hasManual && (!flags.certificateP12 || !flags.certificatePassword || !(flags.provisioningProfile?.length))) {
269
+ if (hasManual && flags.sdk === 'macosx' && (!flags.certificateP12 || !flags.certificatePassword)) {
270
+ throw new Error('--certificate-p12 and --certificate-password are required together for a Developer ID macOS build');
271
+ }
272
+ if (hasManual && flags.sdk !== 'macosx' && (!flags.certificateP12 || !flags.certificatePassword || !(flags.provisioningProfile?.length))) {
270
273
  throw new Error('--certificate-p12, --certificate-password, and at least one --provisioning-profile are required together');
271
274
  }
272
275
  let sdk = flags.sdk;
273
276
  if (hasManual && !sdk)
274
277
  sdk = 'iphoneos';
275
- if (hasManual && sdk && !['iphoneos', 'watchos'].includes(sdk))
276
- throw new Error('Manual signing requires --sdk iphoneos or --sdk watchos');
278
+ if (hasManual && sdk && !['iphoneos', 'watchos', 'macosx'].includes(sdk)) {
279
+ throw new Error('Manual signing requires --sdk iphoneos, --sdk watchos, or --sdk macosx');
280
+ }
277
281
  if (flags.applicationId !== undefined && !/^[A-Za-z0-9_.:-]{1,200}$/.test(flags.applicationId)) {
278
282
  throw new Error('--application-id must contain 1–200 letters, digits, dots, underscores, colons, or hyphens');
279
283
  }
@@ -307,7 +311,7 @@ export async function requestFor(flags) {
307
311
  ? { signing: {
308
312
  certificateP12Base64: await base64File(flags.certificateP12, '--certificate-p12'),
309
313
  certificatePassword: flags.certificatePassword,
310
- provisioningProfilesBase64: await Promise.all(flags.provisioningProfile.map((file) => base64File(file, '--provisioning-profile'))),
314
+ provisioningProfilesBase64: await Promise.all((flags.provisioningProfile ?? []).map((file) => base64File(file, '--provisioning-profile'))),
311
315
  } }
312
316
  : {}),
313
317
  ...(flags.upload ? { upload: { assetName: flags.upload } } : {}),
@@ -379,12 +383,16 @@ Examples:
379
383
  Build a standalone watchOS app for the watch simulator:
380
384
  $ runcloud xcode build . --scheme WatchApp --sdk watchsimulator
381
385
  Build an iOS app that embeds a watch app (the watch app is built with it):
382
- $ runcloud xcode build . --scheme App --sdk iphonesimulator`)
386
+ $ runcloud xcode build . --scheme App --sdk iphonesimulator
387
+ Build a macOS app, unsigned (ad hoc), as a zipped .app:
388
+ $ runcloud xcode build . --scheme MacApp --sdk macosx -o MacApp.zip
389
+ Build a macOS app signed with Developer ID (the profile is needed only for restricted entitlements):
390
+ $ runcloud xcode build . --scheme MacApp --sdk macosx --certificate-p12 DeveloperID.p12 --certificate-password "$P12_PASSWORD" -o MacApp.zip`)
383
391
  .argument('[path]', 'local source directory', '.')
384
392
  .option('--scheme <name>', 'Xcode scheme')
385
393
  .option('--workspace <path>', 'relative .xcworkspace path')
386
394
  .option('--project <path>', 'relative .xcodeproj path')
387
- .option('--sdk <sdk>', 'iphonesimulator, iphoneos, watchsimulator, or watchos')
395
+ .option('--sdk <sdk>', 'iphonesimulator, iphoneos, watchsimulator, watchos, or macosx')
388
396
  .option('--configuration <name>', 'Debug or Release')
389
397
  .option('--xcodegen-spec <path>', 'relative XcodeGen spec path')
390
398
  .option('--xcodegen-project <path>', 'relative XcodeGen output directory')
@@ -395,7 +403,7 @@ Examples:
395
403
  .option('--build-setting <KEY=VALUE>', 'safe Xcode build setting; repeatable', repeated, [])
396
404
  .option('--certificate-p12 <path>', 'PKCS#12 signing certificate')
397
405
  .option('--certificate-password <password>', 'PKCS#12 certificate password')
398
- .option('--provisioning-profile <path>', 'provisioning profile; repeatable', repeated, [])
406
+ .option('--provisioning-profile <path>', 'provisioning profile (.mobileprovision, or .provisionprofile for macOS); repeatable', repeated, [])
399
407
  .option('--upload <filename>', 'public filename for the retained run.cloud artifact')
400
408
  .option('--signed-upload-url <url>', 'also PUT the artifact to this presigned HTTPS URL')
401
409
  .option('--ignore <regex>', 'exclude source paths matching a regular expression; repeatable', repeated, [])
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = '0.2.220';
1
+ export const CLI_VERSION = '0.2.222';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runcloud",
3
- "version": "0.2.220",
3
+ "version": "0.2.222",
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
@@ -40,7 +40,7 @@ runcloud ios get "$SESSION_ID" --json
40
40
  ```
41
41
 
42
42
  Replace `ios` with `android` for an Android artifact. The shared lifecycle is
43
- `create`, `list`, `get`, `open-url`, `location set|clear`, `settings`, `logs`, and `delete` (with `--save-state`). Use `--json` whenever
43
+ `create`, `list`, `get`, `open-url`, `location set|clear`, `settings`, `appearance`, `permissions`, `logs`, and `delete` (with `--save-state`; `push` on iOS). Use `--json` whenever
44
44
  another program consumes output, and inspect `runcloud ios|android --help` for
45
45
  create and log options.
46
46
 
@@ -72,6 +72,27 @@ runcloud states delete "$STATE_ID"
72
72
  - SDK: `delete(id, { saveState: true })`, `create({ restoreState })`,
73
73
  `cloud.states.get(stateId, { waitMs })`, and `cloud.states.delete(stateId)`.
74
74
 
75
+ ## Appearance, Permissions, and Push
76
+
77
+ ```bash
78
+ runcloud ios appearance "$SESSION_ID" dark --json
79
+ runcloud ios permissions grant "$SESSION_ID" --app com.example.App camera location notifications --json
80
+ runcloud ios permissions reset "$SESSION_ID" --app com.example.App camera --json
81
+ runcloud ios push "$SESSION_ID" --app com.example.App payload.json --json
82
+ ```
83
+
84
+ - `appearance` takes `light` or `dark`; `permissions grant|revoke|reset` takes
85
+ `--app` (bundle id or Android package) and one or more of `camera`,
86
+ `microphone`, `location`, `location-always`, `notifications`, `photos`,
87
+ `contacts`, `calendar`, `reminders`, `motion`, `media-library`, `siri`.
88
+ - Grant permissions before the app asks, so no system prompt blocks a run.
89
+ On Android the app must declare the permission (`permission_not_declared`).
90
+ - `push` is iOS only: an APNs JSON object with `aps`, at most 4 KiB, from a
91
+ file or `-` for stdin. Android returns `push_unsupported` (501): emulators
92
+ have no FCM delivery, so send a real FCM message from your server instead.
93
+ - SDK: `setAppearance(id, mode)`, `setPermission(id, { app, service, action })`,
94
+ `grantPermissions(id, app, services)`, and `sendPush(id, { app, payload })`.
95
+
75
96
  ## Control a Session
76
97
 
77
98
  Both platform groups expose acknowledged controls:
Binary file