runcloud 0.2.219 → 0.2.221
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/run-cloud-fleet-observations.js +1 -0
- package/dist/commands/run-cloud-fleet-pressure.js +80 -0
- package/dist/commands/run-cloud-fleet-survey.js +2 -2
- package/dist/commands/run-cloud-fleet.js +4 -2
- package/dist/commands/xcode.js +15 -7
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/runcloud-0.2.221.tgz +0 -0
- package/runcloud-0.2.219.tgz +0 -0
|
@@ -5,6 +5,7 @@ export const str = (value) => typeof value === 'string' && value.length > 0 ? va
|
|
|
5
5
|
export const num = (value) => typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : null;
|
|
6
6
|
export const stamp = (value) => str(value) && Number.isFinite(Date.parse(String(value))) ? new Date(String(value)).toISOString() : null;
|
|
7
7
|
export const time = (value) => stamp(value) ? Date.parse(String(value)) : 0;
|
|
8
|
+
export const FLEET_ADMIN_PREFIX = '/run-cloud/admin/simulators';
|
|
8
9
|
export const validFleetId = (value) => typeof value === 'string' && /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,255}$/.test(value);
|
|
9
10
|
export function fleetReadError(reason, timeoutMs) {
|
|
10
11
|
if (reason === 'HTTP 401' || reason === 'HTTP 403')
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ApiError } from '../api.js';
|
|
2
|
+
import { FLEET_ADMIN_PREFIX, validFleetId } from './run-cloud-fleet-observations.js';
|
|
3
|
+
const PRESSURE_PREFIX = FLEET_ADMIN_PREFIX;
|
|
4
|
+
const MAX_MINUTES = 360;
|
|
5
|
+
const TOO_LONG = 'pressure expires after at most 6h (6h maximum); set it again later to extend';
|
|
6
|
+
const hostPath = (hostId) => `${PRESSURE_PREFIX}/hosts/${encodeURIComponent(hostId)}/pressure`;
|
|
7
|
+
export function pressureMinutes(value) {
|
|
8
|
+
const match = /^(\d+)(m|h)$/.exec(value.trim());
|
|
9
|
+
if (!match)
|
|
10
|
+
throw new Error('--for takes minutes or hours, e.g. 30m, 2h, 6h');
|
|
11
|
+
const minutes = Number(match[1]) * (match[2] === 'h' ? 60 : 1);
|
|
12
|
+
if (minutes < 1)
|
|
13
|
+
throw new Error('--for must be at least 1m');
|
|
14
|
+
if (minutes > MAX_MINUTES)
|
|
15
|
+
throw new Error(`--for ${value}: ${TOO_LONG}`);
|
|
16
|
+
return minutes;
|
|
17
|
+
}
|
|
18
|
+
function expiresIn(expiresAt, now) {
|
|
19
|
+
const minutes = Math.floor((Date.parse(expiresAt) - now) / 60000);
|
|
20
|
+
if (!(minutes >= 1))
|
|
21
|
+
return '<1m';
|
|
22
|
+
return minutes >= 60 ? `${Math.floor(minutes / 60)}h ${minutes % 60}m` : `${minutes}m`;
|
|
23
|
+
}
|
|
24
|
+
export function pressureTable(pressures, now = Date.now()) {
|
|
25
|
+
if (!pressures.length)
|
|
26
|
+
return 'No host is under pressure.';
|
|
27
|
+
const lines = [['HOST', 'EXPIRES IN', 'SET BY', 'REASON'],
|
|
28
|
+
...pressures.map(p => [p.hostId, expiresIn(p.expiresAt, now), p.createdBy, p.reason || '-'])];
|
|
29
|
+
const widths = [0, 1, 2].map(i => Math.max(...lines.map(line => line[i].length)));
|
|
30
|
+
return lines.map(line => line.map((cell, i) => i < 3 ? cell.padEnd(widths[i]) : cell).join(' ')).join('\n');
|
|
31
|
+
}
|
|
32
|
+
function explain(error, hostId) {
|
|
33
|
+
if (!(error instanceof ApiError))
|
|
34
|
+
return error;
|
|
35
|
+
if (error.status === 401 || error.status === 403)
|
|
36
|
+
return new Error(`Fleet access denied (HTTP ${error.status}); use an admin identity`);
|
|
37
|
+
const code = error.code ?? error.detail;
|
|
38
|
+
if (code === 'unknown_host')
|
|
39
|
+
return new Error(`Host ${hostId} is not in the fleet registry`);
|
|
40
|
+
if (code === 'pressure_too_long')
|
|
41
|
+
return new Error(`Refused by the API: ${TOO_LONG}`);
|
|
42
|
+
if (code === 'invalid_duration')
|
|
43
|
+
return new Error('Refused by the API: duration must be 1 to 360 minutes');
|
|
44
|
+
return error;
|
|
45
|
+
}
|
|
46
|
+
export function registerFleetPressureCommand(fleet, client, action) {
|
|
47
|
+
fleet.command('pressure [hostId]').description('Route real traffic to one simulator host first, for at most 6h (admin)')
|
|
48
|
+
.option('--for <duration>', 'How long: 30m, 2h, 6h (max 6h)').option('--reason <text>', 'Why; kept in the audit log')
|
|
49
|
+
.option('--clear', 'Remove the pressure from the host').option('--list', 'Show active pressures')
|
|
50
|
+
.option('--json', 'Structured output')
|
|
51
|
+
.action((hostId, opts) => action(async () => {
|
|
52
|
+
if (opts.list) {
|
|
53
|
+
if (hostId || opts.for || opts.clear || opts.reason)
|
|
54
|
+
throw new Error('--list takes no host ID, --for, --reason or --clear');
|
|
55
|
+
const body = await client().get(`${PRESSURE_PREFIX}/pressure`, { signal: AbortSignal.timeout(30000) }).catch(error => { throw explain(error); });
|
|
56
|
+
const pressures = body?.pressures;
|
|
57
|
+
if (!Array.isArray(pressures))
|
|
58
|
+
throw new Error('Pressure list unavailable (invalid_response); retry and check API connectivity');
|
|
59
|
+
console.log(opts.json ? JSON.stringify({ pressures }, null, 2) : pressureTable(pressures));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!hostId || !validFleetId(hostId))
|
|
63
|
+
throw new Error('Give a valid host ID, e.g. runcloud fleet pressure gabriel-1 --for 2h');
|
|
64
|
+
if (opts.clear) {
|
|
65
|
+
if (opts.for || opts.reason)
|
|
66
|
+
throw new Error('--clear takes no --for or --reason');
|
|
67
|
+
await client().delete(hostPath(hostId)).catch(error => { throw explain(error, hostId); });
|
|
68
|
+
console.log(opts.json ? JSON.stringify({ hostId, cleared: true }, null, 2) : `Pressure cleared on ${hostId}`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (!opts.for)
|
|
72
|
+
throw new Error('Use --for <duration> (max 6h), --clear, or --list');
|
|
73
|
+
if (opts.reason !== undefined && opts.reason.length > 200)
|
|
74
|
+
throw new Error('--reason is at most 200 characters');
|
|
75
|
+
const body = { durationMinutes: pressureMinutes(opts.for), ...(opts.reason ? { reason: opts.reason } : {}) };
|
|
76
|
+
const pressure = await client().put(hostPath(hostId), body).catch(error => { throw explain(error, hostId); });
|
|
77
|
+
console.log(opts.json ? JSON.stringify(pressure, null, 2)
|
|
78
|
+
: `${pressure.hostId} gets traffic first until ${pressure.expiresAt} (${expiresIn(pressure.expiresAt, Date.now())})`);
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApiError } from '../api.js';
|
|
2
|
-
import { componentHosts, fleetReadError, hostReport, hostedObservation, num, observation, row, rows, safeFleetText, stamp, str, time, validFleetId } from './run-cloud-fleet-observations.js';
|
|
2
|
+
import { componentHosts, fleetReadError, hostReport, hostedObservation, num, observation, row, rows, safeFleetText, stamp, str, time, validFleetId, FLEET_ADMIN_PREFIX } from './run-cloud-fleet-observations.js';
|
|
3
3
|
export const SURVEY_REQUEST_BUDGET_MS = 30000;
|
|
4
|
-
const ROOT =
|
|
4
|
+
const ROOT = FLEET_ADMIN_PREFIX;
|
|
5
5
|
const RANGES = ['1h', '6h', '24h', '7d'];
|
|
6
6
|
const DEVICE_LIMIT = 512, POINT_LIMIT = 800, TYPE_LIMIT = 100;
|
|
7
7
|
function count(value) { const number = num(value); return number !== null && Number.isSafeInteger(number) ? number : null; }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { row, rows, str, num, stamp, time, pick, observation, componentHosts, fleetReadError, hostReport, safeFleetText, validFleetId } from './run-cloud-fleet-observations.js';
|
|
1
|
+
import { row, rows, str, num, stamp, time, pick, observation, componentHosts, fleetReadError, hostReport, safeFleetText, validFleetId, FLEET_ADMIN_PREFIX } from './run-cloud-fleet-observations.js';
|
|
2
2
|
export { safeFleetText } from './run-cloud-fleet-observations.js';
|
|
3
3
|
import { readFileSync, statSync } from 'node:fs';
|
|
4
4
|
import { ApiClient, ApiError } from '../api.js';
|
|
@@ -6,7 +6,8 @@ import { requireCredentials } from '../config.js';
|
|
|
6
6
|
import { surveyFleet, surveyText } from './run-cloud-fleet-survey.js';
|
|
7
7
|
import { listReleaseChannels, promoteReleaseChannel, releaseText } from './run-cloud-fleet-releases.js';
|
|
8
8
|
import { registerFleetReleaseControlCommands } from './run-cloud-fleet-release-control.js';
|
|
9
|
-
|
|
9
|
+
import { registerFleetPressureCommand } from './run-cloud-fleet-pressure.js';
|
|
10
|
+
const ROOT = FLEET_ADMIN_PREFIX;
|
|
10
11
|
const RANGES = ['1h', '6h', '24h', '7d', '30d', '90d', '1y', '2y'];
|
|
11
12
|
export const ACCESSIBILITY_CODES = ['accessibility_device_unavailable', 'accessibility_capture_failed'];
|
|
12
13
|
function bound(value, fallback, max, name) {
|
|
@@ -305,6 +306,7 @@ function printReport(report, json) {
|
|
|
305
306
|
export function registerRunCloudFleet(program) {
|
|
306
307
|
const fleet = program.command('fleet').description('Admin fleet telemetry, diagnosis, events, failure evidence and serve-sim release channels');
|
|
307
308
|
registerFleetReleaseControlCommands(fleet, credentialsClient, action);
|
|
309
|
+
registerFleetPressureCommand(fleet, credentialsClient, action);
|
|
308
310
|
fleet.command('survey [hostId]').description('Survey all fleet signals in seconds; authenticated admin reads, no local services')
|
|
309
311
|
.option('--json', 'Structured metrics, diagnosis, observations and coverage')
|
|
310
312
|
.option('--range <range>', 'Alert/input-lag window: 1h, 6h, 24h, 7d', '24h')
|
package/dist/commands/xcode.js
CHANGED
|
@@ -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 &&
|
|
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
|
|
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
|
|
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.
|
|
1
|
+
export const CLI_VERSION = '0.2.221';
|
package/package.json
CHANGED
|
Binary file
|
package/runcloud-0.2.219.tgz
DELETED
|
Binary file
|