jetbridge 0.1.0-rc.0

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.
@@ -0,0 +1,327 @@
1
+ import { z } from 'zod';
2
+
3
+ interface RunOptions {
4
+ cwd?: string;
5
+ env?: Record<string, string>;
6
+ /** Stream the child's output to the terminal instead of capturing it. */
7
+ stdio?: 'pipe' | 'inherit';
8
+ /** Return a failed result instead of throwing. */
9
+ allowFail?: boolean;
10
+ input?: string;
11
+ timeoutMs?: number;
12
+ }
13
+ interface CommandResult {
14
+ ok: boolean;
15
+ /** null when the process was killed by a signal. */
16
+ code: number | null;
17
+ stdout: string;
18
+ stderr: string;
19
+ }
20
+ /** A command as it was invoked — what tests assert against. */
21
+ interface CommandCall {
22
+ command: string;
23
+ args: string[];
24
+ options: RunOptions;
25
+ }
26
+ interface HttpResponse {
27
+ status: number;
28
+ ok: boolean;
29
+ headers: Record<string, string>;
30
+ text: () => Promise<string>;
31
+ json: <T = unknown>() => Promise<T>;
32
+ }
33
+ interface HttpRequest {
34
+ method: string;
35
+ url: string;
36
+ headers: Record<string, string>;
37
+ body?: string;
38
+ /** Overrides the default. A request that never answers is a hang, so there is always one. */
39
+ timeoutMs?: number;
40
+ }
41
+ interface FileSystem {
42
+ exists(path: string): boolean;
43
+ read(path: string): string;
44
+ readBytes(path: string): Uint8Array;
45
+ write(path: string, contents: string | Uint8Array): void;
46
+ mkdirp(path: string): void;
47
+ readdir(path: string): string[];
48
+ rm(path: string, opts?: {
49
+ recursive?: boolean;
50
+ }): void;
51
+ isDirectory(path: string): boolean;
52
+ size(path: string): number;
53
+ }
54
+ interface Logger {
55
+ info(message: string): void;
56
+ warn(message: string): void;
57
+ error(message: string): void;
58
+ /** Progress that is noise in a log file — suppressed when not a TTY. */
59
+ step(message: string): void;
60
+ }
61
+ interface Boundary {
62
+ exec: {
63
+ run(command: string, args: string[], options?: RunOptions): Promise<CommandResult>;
64
+ runSync(command: string, args: string[], options?: RunOptions): CommandResult;
65
+ };
66
+ fs: FileSystem;
67
+ http(request: HttpRequest): Promise<HttpResponse>;
68
+ env(name: string): string | undefined;
69
+ /** Unix seconds. Injected because build numbers are derived from it. */
70
+ now(): number;
71
+ homedir(): string;
72
+ cwd(): string;
73
+ log: Logger;
74
+ /** False behind a pipe or in CI: never prompt, never expect a terminal. */
75
+ interactive: boolean;
76
+ }
77
+ declare const nodeFileSystem: FileSystem;
78
+ /**
79
+ * Is there a person to ask?
80
+ *
81
+ * A TTY that is not CI, and that nobody has explicitly opted out of. All three
82
+ * halves matter: `CI=1` on a developer's machine is the documented way to force
83
+ * the non-interactive path, and `JETBRIDGE_NON_INTERACTIVE` is the same lever
84
+ * for someone who is not in CI and does not want to be prompted.
85
+ *
86
+ * Nothing REQUIRES any of them. No terminal is sufficient on its own — an agent
87
+ * behind a pipe gets the unattended behaviour without setting a variable, which
88
+ * is the whole point.
89
+ */
90
+ declare function isInteractive(env?: NodeJS.ProcessEnv): boolean;
91
+ interface NodeBoundaryOptions {
92
+ /**
93
+ * Force the unattended path even on a terminal — what `--non-interactive`
94
+ * hands down. Never needed behind a pipe, which is already unattended.
95
+ */
96
+ nonInteractive?: boolean;
97
+ }
98
+ declare function nodeBoundary(options?: NodeBoundaryOptions): Boundary;
99
+
100
+ /**
101
+ * `jetbridge.config.json` — one schema, three jobs: the TypeScript types, the
102
+ * runtime validator, and the published JSON Schema editors autocomplete
103
+ * against. Defining it three times is how they drift.
104
+ *
105
+ * Every value here was a hardcoded constant in the tool this package was
106
+ * extracted from. Nothing project-specific is allowed back in as a default.
107
+ */
108
+
109
+ declare const CONFIG_FILENAMES: readonly ["jetbridge.config.json", ".jetbridge.json"];
110
+ declare const CONFIG_VERSION = 1;
111
+ /**
112
+ * An Xcode target that gets its own bundle id — the app, plus any extension
113
+ * that ships inside it. An extension's id is the app's id plus its own segment,
114
+ * which is why a variant has to register more than one.
115
+ */
116
+ declare const targetSchema: z.ZodObject<{
117
+ name: z.ZodString;
118
+ bundleIdSuffix: z.ZodOptional<z.ZodString>;
119
+ entitlements: z.ZodOptional<z.ZodString>;
120
+ variantEntitlements: z.ZodOptional<z.ZodString>;
121
+ capabilities: z.ZodDefault<z.ZodArray<z.ZodString>>;
122
+ profileSetting: z.ZodOptional<z.ZodString>;
123
+ }, z.core.$strip>;
124
+ declare const configSchema: z.ZodObject<{
125
+ $schema: z.ZodOptional<z.ZodString>;
126
+ configVersion: z.ZodLiteral<1>;
127
+ project: z.ZodObject<{
128
+ iosDir: z.ZodDefault<z.ZodString>;
129
+ xcodeproj: z.ZodOptional<z.ZodString>;
130
+ xcworkspace: z.ZodOptional<z.ZodString>;
131
+ scheme: z.ZodString;
132
+ teamId: z.ZodString;
133
+ baseBundleId: z.ZodString;
134
+ projectYml: z.ZodOptional<z.ZodString>;
135
+ xcodegen: z.ZodDefault<z.ZodBoolean>;
136
+ appIcon: z.ZodOptional<z.ZodString>;
137
+ deviceTypes: z.ZodDefault<z.ZodArray<z.ZodEnum<{
138
+ iPhone: "iPhone";
139
+ iPad: "iPad";
140
+ }>>>;
141
+ }, z.core.$strip>;
142
+ configurations: z.ZodPrefault<z.ZodObject<{
143
+ available: z.ZodDefault<z.ZodArray<z.ZodString>>;
144
+ wired: z.ZodDefault<z.ZodString>;
145
+ sim: z.ZodDefault<z.ZodString>;
146
+ archive: z.ZodDefault<z.ZodString>;
147
+ }, z.core.$strip>>;
148
+ variant: z.ZodObject<{
149
+ displayName: z.ZodString;
150
+ labelPrefix: z.ZodOptional<z.ZodString>;
151
+ labelBudget: z.ZodDefault<z.ZodNumber>;
152
+ noiseWords: z.ZodOptional<z.ZodArray<z.ZodString>>;
153
+ targets: z.ZodDefault<z.ZodArray<z.ZodObject<{
154
+ name: z.ZodString;
155
+ bundleIdSuffix: z.ZodOptional<z.ZodString>;
156
+ entitlements: z.ZodOptional<z.ZodString>;
157
+ variantEntitlements: z.ZodOptional<z.ZodString>;
158
+ capabilities: z.ZodDefault<z.ZodArray<z.ZodString>>;
159
+ profileSetting: z.ZodOptional<z.ZodString>;
160
+ }, z.core.$strip>>>;
161
+ buildSettings: z.ZodPrefault<z.ZodObject<{
162
+ bundleSuffix: z.ZodDefault<z.ZodString>;
163
+ displayName: z.ZodDefault<z.ZodString>;
164
+ signStyle: z.ZodDefault<z.ZodString>;
165
+ gitSha: z.ZodDefault<z.ZodString>;
166
+ }, z.core.$strip>>;
167
+ profilePrefix: z.ZodOptional<z.ZodString>;
168
+ }, z.core.$strip>;
169
+ xcconfigOverrides: z.ZodOptional<z.ZodObject<{
170
+ file: z.ZodString;
171
+ key: z.ZodString;
172
+ presets: z.ZodPrefault<z.ZodRecord<z.ZodString, z.ZodString>>;
173
+ }, z.core.$strip>>;
174
+ hooks: z.ZodPrefault<z.ZodObject<{
175
+ preBuild: z.ZodOptional<z.ZodString>;
176
+ postBuild: z.ZodOptional<z.ZodString>;
177
+ }, z.core.$strip>>;
178
+ credentials: z.ZodPrefault<z.ZodObject<{
179
+ ascKeyId: z.ZodDefault<z.ZodString>;
180
+ ascIssuerId: z.ZodDefault<z.ZodString>;
181
+ ascKeyPath: z.ZodDefault<z.ZodString>;
182
+ }, z.core.$strip>>;
183
+ ota: z.ZodOptional<z.ZodObject<{
184
+ storage: z.ZodObject<{
185
+ bucket: z.ZodString;
186
+ region: z.ZodDefault<z.ZodString>;
187
+ endpoint: z.ZodOptional<z.ZodString>;
188
+ publicBaseUrl: z.ZodString;
189
+ prefix: z.ZodDefault<z.ZodString>;
190
+ accessKeyId: z.ZodDefault<z.ZodString>;
191
+ secretAccessKey: z.ZodDefault<z.ZodString>;
192
+ }, z.core.$strip>;
193
+ exportMethod: z.ZodDefault<z.ZodEnum<{
194
+ "ad-hoc": "ad-hoc";
195
+ enterprise: "enterprise";
196
+ }>>;
197
+ maxBuilds: z.ZodDefault<z.ZodNumber>;
198
+ access: z.ZodDefault<z.ZodEnum<{
199
+ path: "path";
200
+ none: "none";
201
+ }>>;
202
+ branding: z.ZodPrefault<z.ZodObject<{
203
+ title: z.ZodOptional<z.ZodString>;
204
+ accent: z.ZodOptional<z.ZodString>;
205
+ }, z.core.$strip>>;
206
+ }, z.core.$strip>>;
207
+ git: z.ZodPrefault<z.ZodObject<{
208
+ defaultBranch: z.ZodDefault<z.ZodString>;
209
+ requireCleanDefaultBranch: z.ZodDefault<z.ZodBoolean>;
210
+ }, z.core.$strip>>;
211
+ }, z.core.$strip>;
212
+ type Config = z.infer<typeof configSchema>;
213
+ type OtaConfig = NonNullable<Config['ota']>;
214
+ type TargetConfig = z.infer<typeof targetSchema>;
215
+ /**
216
+ * The noise words actually used: whatever was configured, or the default —
217
+ * commit types plus the segments of the base bundle id.
218
+ */
219
+ declare function noiseWordsFor(config: Config): Set<string>;
220
+ /** `Acme Dev` → `Acme`, unless a prefix was set explicitly. */
221
+ declare function labelPrefixFor(config: Config): string;
222
+ interface ConfigError {
223
+ path: string;
224
+ message: string;
225
+ }
226
+ type ParseResult = {
227
+ ok: true;
228
+ config: Config;
229
+ } | {
230
+ ok: false;
231
+ errors: ConfigError[];
232
+ };
233
+ /** Validate an already-parsed object. Separated so the wizard can check its own draft. */
234
+ declare function parseConfig(value: unknown): ParseResult;
235
+ declare function formatConfigErrors(errors: ConfigError[]): string;
236
+ /** The published JSON Schema, generated from the same definition the runtime uses. */
237
+ declare function jsonSchema(): unknown;
238
+
239
+ interface Project {
240
+ /** Directory holding the config file. Everything relative resolves from here. */
241
+ root: string;
242
+ configPath: string;
243
+ config: Config;
244
+ /** Absolute path to a project-relative one. */
245
+ path(...segments: string[]): string;
246
+ /** Absolute path inside the Xcode project directory. */
247
+ iosPath(...segments: string[]): string;
248
+ /** The `-project` or `-workspace` argument pair for xcodebuild. */
249
+ xcodebuildTarget(): [flag: string, path: string];
250
+ }
251
+ /** The nearest config file at or above `from`, or null. */
252
+ declare function findConfigFile(boundary: Boundary, from: string): string | null;
253
+ declare function projectFrom(configPath: string, config: Config): Project;
254
+ interface LoadOptions {
255
+ /** Start the upward walk here instead of the working directory. */
256
+ from?: string;
257
+ /** Use exactly this file, e.g. from `--config-file`. */
258
+ configPath?: string;
259
+ }
260
+ declare function loadProject(boundary: Boundary, options?: LoadOptions): Project;
261
+
262
+ /**
263
+ * Naming a variant build.
264
+ *
265
+ * A variant gets its own bundle id and its own home-screen label, so two
266
+ * branches install side by side as two distinguishable apps instead of
267
+ * overwriting each other. Every name below comes from ONE parse of the raw
268
+ * slug: derive the bundle-id segment and the label separately and they drift
269
+ * (`feat/seeded-feed` became bundle `featseededfeed` but label "Seeded Feed").
270
+ */
271
+
272
+ /**
273
+ * The words a variant is named from.
274
+ *
275
+ * Leading noise words are dropped, repeatedly: a conventional-commit type, and
276
+ * the segments of the base bundle id someone might paste back in. So
277
+ * `feat/seeded-feed` and `seeded-feed` name the same app, and
278
+ * `com.example.dev.testtestes` yields `testtestes` rather than the absurd
279
+ * `com.example.app.dev.comexampledevtesttestes`.
280
+ *
281
+ * Guarded on `length > 1` at each step, so an explicit `--suffix fix` still
282
+ * names the variant "fix".
283
+ */
284
+ declare function variantWords(raw: string, noiseWords: Set<string>): string[];
285
+ /** Bundle-id segment and DNS label: lowercase alphanumerics only. */
286
+ declare function sanitizeSuffix(raw: string, config: Config): string;
287
+ /**
288
+ * Human words for a variant, from the RAW slug — before `sanitizeSuffix`
289
+ * collapses the separators a bundle id cannot carry. `seeded-feed` → `Seeded
290
+ * Feed`; derive it from the collapsed `seededfeed` instead and you get
291
+ * `Seededfeed`.
292
+ */
293
+ declare function variantTitle(raw: string, config: Config): string;
294
+ /** Interpolated into plist XML and a build setting — keep it boring. */
295
+ declare function sanitizeName(raw: string): string;
296
+ /**
297
+ * The name App Store Connect accepts for a bundle-id entity.
298
+ *
299
+ * Not the same string as the home-screen label, though it is derived from it.
300
+ * iOS is happy with `CFBundleDisplayName = "Acme_Hello_World"`; the ASC API
301
+ * rejects it outright:
302
+ *
303
+ * 409 ENTITY_ERROR.ATTRIBUTE.INVALID
304
+ * The attribute 'name' is invalid: 'Acme_Hello_World'
305
+ *
306
+ * Apple allows letters, digits and spaces there — not the `._-` a display name
307
+ * permits. Punctuation becomes a space rather than vanishing, so
308
+ * `Acme_Hello_World` reads `Acme Hello World`, not `AcmeHelloWorld`.
309
+ */
310
+ declare function ascEntityName(displayName: string): string;
311
+ declare function bundleIdFor(suffix: string, config: Config): string;
312
+ /**
313
+ * The home-screen label. An explicit name always wins; otherwise a variant gets
314
+ * `<prefix> <Title>`, so two branches are never two identical icons. A plain
315
+ * build keeps the project's own default.
316
+ */
317
+ declare function displayNameFor(rawSuffix: string, explicit: string, config: Config): string;
318
+ /** True when iOS will visibly truncate this label on the home screen. */
319
+ declare function exceedsLabelBudget(label: string, config: Config): boolean;
320
+ /**
321
+ * A slug is ONE bundle-id segment. A pasted bundle id is rejected rather than
322
+ * quietly flattened: `--suffix com.example.dev.foo` used to build
323
+ * `com.example.app.dev.comexampledevfoo`.
324
+ */
325
+ declare function assertSingleSegment(value: string, config: Config): string;
326
+
327
+ export { sanitizeSuffix as A, type Boundary as B, type Config as C, variantTitle as D, variantWords as E, type FileSystem as F, type HttpRequest as H, type LoadOptions as L, type OtaConfig as O, type Project as P, type RunOptions as R, type TargetConfig as T, assertSingleSegment as a, CONFIG_FILENAMES as b, CONFIG_VERSION as c, type CommandCall as d, type CommandResult as e, type ConfigError as f, type HttpResponse as g, type Logger as h, type ParseResult as i, ascEntityName as j, bundleIdFor as k, configSchema as l, displayNameFor as m, exceedsLabelBudget as n, findConfigFile as o, formatConfigErrors as p, isInteractive as q, jsonSchema as r, labelPrefixFor as s, loadProject as t, nodeBoundary as u, nodeFileSystem as v, noiseWordsFor as w, parseConfig as x, projectFrom as y, sanitizeName as z };
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "jetbridge",
3
+ "version": "0.1.0-rc.0",
4
+ "description": "Build, sign and deliver iOS dev builds — to a simulator, down a cable, or over the air to your own bucket.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=20"
9
+ },
10
+ "bin": {
11
+ "jetbridge": "dist/cli.js"
12
+ },
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./schema": "./schema/v1.json"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "schema",
25
+ "templates"
26
+ ],
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/panofm/jetbridge.git"
33
+ },
34
+ "scripts": {
35
+ "build": "tsup",
36
+ "test": "vitest run",
37
+ "test:watch": "vitest",
38
+ "typecheck": "tsc --noEmit",
39
+ "lint": "eslint .",
40
+ "format": "prettier --write .",
41
+ "format:check": "prettier --check .",
42
+ "schema": "node scripts/generate-schema.mjs",
43
+ "check:schema": "node scripts/generate-schema.mjs --check",
44
+ "check:identifiers": "node scripts/check-no-private-identifiers.mjs",
45
+ "check:changeset": "node scripts/check-changeset.mjs",
46
+ "check": "npm run typecheck && npm run lint && npm run format:check && npm run check:identifiers && npm run test",
47
+ "changeset": "changeset",
48
+ "version-packages": "changeset version",
49
+ "prepack": "npm run build",
50
+ "release": "npm run build && changeset publish"
51
+ },
52
+ "dependencies": {
53
+ "@aws-sdk/client-s3": "^3.984.0",
54
+ "@clack/prompts": "^1.0.1",
55
+ "chalk": "^5.6.2",
56
+ "commander": "^15.0.0",
57
+ "execa": "^9.5.2",
58
+ "zod": "^4.4.3"
59
+ },
60
+ "devDependencies": {
61
+ "@changesets/changelog-github": "^0.7.0",
62
+ "@changesets/cli": "^2.31.1",
63
+ "@eslint/js": "^9.17.0",
64
+ "@types/node": "^22.10.0",
65
+ "eslint": "^9.17.0",
66
+ "prettier": "^3.4.2",
67
+ "tsup": "^8.3.5",
68
+ "typescript": "^5.7.2",
69
+ "typescript-eslint": "^8.18.0",
70
+ "vitest": "^2.1.8"
71
+ },
72
+ "keywords": [
73
+ "ios",
74
+ "xcode",
75
+ "xcodebuild",
76
+ "install",
77
+ "ota",
78
+ "ad-hoc",
79
+ "itms-services",
80
+ "testflight",
81
+ "simulator",
82
+ "devicectl"
83
+ ]
84
+ }