@getargus/build-tools 0.0.0-stage → 0.3.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.
- package/LICENSE +21 -0
- package/README.md +218 -2
- package/bin/argus-build.cjs +8 -0
- package/dist/cli-C6Vb06ix.d.ts +317 -0
- package/dist/cli-Poqz5E1p.d.cts +317 -0
- package/dist/cli.cjs +1283 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1254 -0
- package/dist/cli.js.map +1 -0
- package/dist/ids-T7ddcOxQ.d.cts +41 -0
- package/dist/ids-T7ddcOxQ.d.ts +41 -0
- package/dist/index.cjs +1548 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +1486 -0
- package/dist/index.js.map +1 -0
- package/dist/metro.cjs +117 -0
- package/dist/metro.cjs.map +1 -0
- package/dist/metro.d.cts +40 -0
- package/dist/metro.d.ts +40 -0
- package/dist/metro.js +92 -0
- package/dist/metro.js.map +1 -0
- package/dist/next.cjs +609 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +60 -0
- package/dist/next.d.ts +60 -0
- package/dist/next.js +582 -0
- package/dist/next.js.map +1 -0
- package/package.json +67 -3
package/dist/cli.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/collect.ts","../src/ids.ts","../src/init.ts","../src/upload.ts","../src/http-upload.ts"],"sourcesContent":["/**\n * `argus-build` — project setup (`init`), id generation, artifact discovery (`collect`) and the\n * upload step (`upload`: HTTP from Node for JS sets, the Rust `argus` binary for native symbols).\n */\nimport { rmSync } from 'node:fs';\nimport { relative, resolve, sep } from 'node:path';\nimport { createInterface } from 'node:readline';\nimport {\n browserSourceMaps,\n formatCommand,\n manifestName,\n planExpoExport,\n planFiles,\n planNative,\n planNext,\n uploadArgs,\n type ExpoExportPlanOptions,\n type MobilePlatform,\n type UploadMeta,\n type UploadPlan,\n} from './collect';\nimport { newArtifactSetId, writeArtifactSetModule, type BuildPlatform } from './ids';\nimport { runInit, type RunInitOptions } from './init';\nimport { runUploads, type RunOptions } from './upload';\n\nexport const USAGE = `argus-build <command>\n\n init [--dsn <dsn>] [--yes] [--dry-run] [--dir <project>]\n set a Next.js / Node / Expo project up for Argus: prints every file it\n would write; writes with --yes (or after asking, on a terminal); never\n overwrites a file, never installs anything\n new-id [--prefix <p>] print a new artifact set id (same format as \\`argus artifacts new-id\\`)\n prelude --set-id <id> --out <file> write the generated module that defines globalThis.__ARGUS_ARTIFACT_SET_ID__\n collect <target> [options] print what would be uploaded, per artifact set (no network)\n upload <target> [options] upload each artifact set (JS sets over HTTP, native symbols via the argus CLI)\n\nTargets\n next --set-id <web id> [--server-set-id <id>] [--dir <project>] [--dist-dir .next] [--url-prefix /_next/]\n browser chunks and server chunks go to two different sets (default server id: <web id>-node)\n expo-export --ios-set-id <id> --android-set-id <id> [--dir dist] [--platform ios|android]\n [--update-id <id> | --ios-update-id <id> --android-update-id <id>]\n [--parent-set-id <id> | --ios-parent-set-id <id> --android-parent-set-id <id>] [--runtime-version <v>]\n ios --set-id <id> --dir <xcarchive | dSYMs | build dir>... [--bundle <main.jsbundle>] [--sourcemap <map>]\n android --set-id <id> --dir <android/app/build>... [--bundle <f>] [--sourcemap <map>] [--native-libs]\n files --set-id <id> --platform <ios|android|web|node> --dir <dir or file>... [--strip-prefix <p>] [--url-prefix <p>]\n\nCommon options\n --release <r> --dist <d> --native-release <v> --native-build <b> --runtime-version <v> --git-sha <sha>\n --no-bundles upload source maps only (next, files)\n --json collect: machine readable output\n --dry-run upload: print the manifests and upload nothing\n --print upload: only print the commands\n --transport <t> upload: http (from Node, JS artifacts only), cli (the argus binary) or auto (default:\n http for JS-only sets, cli for native symbols)\n --delete-maps upload next: delete browser .map files from the build output after a successful upload\n --argus-bin <path> the argus binary (default $ARGUS_BIN, else \"argus\")\n --url <base url> server (default: $ARGUS_URL as read by the argus CLI)\n\nEnvironment: ARGUS_UPLOAD_KEY (upload key; never passed on the command line), ARGUS_URL, ARGUS_BIN, ARGUS_GIT_SHA.\n`;\n\nconst BOOLEAN_FLAGS = new Set(['yes', 'json', 'dry-run', 'print', 'no-bundles', 'delete-maps', 'native-libs', 'help']);\nconst MULTI_FLAGS = new Set(['dir']);\n\nexport interface ParsedArgs {\n positionals: string[];\n flags: Record<string, string | boolean | undefined>;\n multi: Record<string, string[]>;\n}\n\nexport function parseArgs(argv: string[]): ParsedArgs {\n const out: ParsedArgs = { positionals: [], flags: {}, multi: {} };\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i]!;\n if (!a.startsWith('--')) {\n out.positionals.push(a);\n continue;\n }\n const eq = a.indexOf('=');\n const name = a.slice(2, eq === -1 ? undefined : eq);\n if (BOOLEAN_FLAGS.has(name)) {\n out.flags[name] = true;\n continue;\n }\n const value = eq === -1 ? argv[++i] : a.slice(eq + 1);\n if (value === undefined) throw new Error(`missing value for --${name}`);\n if (MULTI_FLAGS.has(name)) (out.multi[name] ??= []).push(value);\n else out.flags[name] = value;\n }\n return out;\n}\n\nconst s = (v: string | boolean | undefined): string | undefined => (typeof v === 'string' ? v : undefined);\n\nfunction need(args: ParsedArgs, name: string): string {\n const v = s(args.flags[name]);\n if (!v) throw new Error(`--${name} is required`);\n return v;\n}\n\nfunction metaOf(args: ParsedArgs, env: Record<string, string | undefined>): UploadMeta {\n return {\n release: s(args.flags.release),\n dist: s(args.flags.dist),\n nativeRelease: s(args.flags['native-release']),\n nativeBuild: s(args.flags['native-build']),\n runtimeVersion: s(args.flags['runtime-version']),\n gitSha: s(args.flags['git-sha']) ?? env.ARGUS_GIT_SHA,\n };\n}\n\n/** Builds the upload plans for a target from CLI arguments. Exported for tests. */\nexport function plansFor(target: string, args: ParsedArgs, env: Record<string, string | undefined> = process.env, cwd: string = process.cwd()): UploadPlan[] {\n const meta = metaOf(args, env);\n const dirs = (args.multi.dir ?? []).map((d) => resolve(cwd, d));\n const setId = (): string => s(args.flags['set-id']) ?? env.ARGUS_ARTIFACT_SET_ID ?? need(args, 'set-id');\n switch (target) {\n case 'next': {\n const opts: Parameters<typeof planNext>[0] = { ...meta, projectDir: dirs[0] ?? cwd, artifactSetId: setId(), includeBundles: !args.flags['no-bundles'] };\n const serverId = s(args.flags['server-set-id']) ?? env.ARGUS_ARTIFACT_SET_ID_NODE;\n if (serverId) opts.serverArtifactSetId = serverId;\n const distDir = s(args.flags['dist-dir']);\n if (distDir) opts.distDir = distDir;\n const urlPrefix = s(args.flags['url-prefix']);\n if (urlPrefix !== undefined) opts.urlPrefix = urlPrefix;\n return planNext(opts);\n }\n case 'expo-export': {\n const per = (flag: string, envName?: string): Partial<Record<MobilePlatform, string>> => {\n const out: Partial<Record<MobilePlatform, string>> = {};\n for (const p of ['ios', 'android'] as const) {\n const v = s(args.flags[`${p}-${flag}`]) ?? (envName ? env[`${envName}_${p.toUpperCase()}`] : undefined);\n if (v) out[p] = v;\n }\n return out;\n };\n const opts: ExpoExportPlanOptions = { ...meta, exportDir: dirs[0] ?? resolve(cwd, 'dist'), artifactSetIds: per('set-id', 'ARGUS_ARTIFACT_SET_ID') };\n const platform = s(args.flags.platform);\n if (platform) {\n if (platform !== 'ios' && platform !== 'android') throw new Error('--platform must be ios or android for expo-export');\n opts.platforms = [platform];\n // A single platform may use the generic flags.\n const generic = s(args.flags['set-id']) ?? env.ARGUS_ARTIFACT_SET_ID;\n if (!opts.artifactSetIds[platform] && generic) opts.artifactSetIds[platform] = generic;\n }\n const updateIds = per('update-id');\n const oneUpdate = s(args.flags['update-id']);\n if (Object.keys(updateIds).length > 0) opts.updateId = updateIds;\n else if (oneUpdate) opts.updateId = oneUpdate;\n const parents = per('parent-set-id');\n const oneParent = s(args.flags['parent-set-id']);\n if (oneParent && platform) parents[platform as MobilePlatform] ??= oneParent;\n else if (oneParent) throw new Error('--parent-set-id needs --platform; a native build set belongs to one platform (use --ios-parent-set-id / --android-parent-set-id)');\n if (Object.keys(parents).length > 0) opts.parentSetIds = parents;\n return planExpoExport(opts);\n }\n case 'ios':\n case 'android': {\n if (dirs.length === 0) throw new Error('--dir is required (where the build left its dSYMs / mapping.txt / bundle map)');\n const opts: Parameters<typeof planNative>[0] = { ...meta, platform: target, artifactSetId: setId(), searchPaths: dirs };\n const bundle = s(args.flags.bundle);\n const sourcemap = s(args.flags.sourcemap);\n if (bundle) opts.bundle = resolve(cwd, bundle);\n if (sourcemap) opts.sourcemap = resolve(cwd, sourcemap);\n if (args.flags['native-libs']) opts.includeNativeLibs = true;\n return [planNative(opts)];\n }\n case 'files': {\n const platform = need(args, 'platform');\n if (!['ios', 'android', 'web', 'node'].includes(platform)) throw new Error('--platform must be ios, android, web or node');\n if (dirs.length === 0) throw new Error('--dir is required');\n const opts: Parameters<typeof planFiles>[0] = { ...meta, artifactSetId: setId(), platform: platform as BuildPlatform, paths: dirs, includeBundles: !args.flags['no-bundles'] };\n const strip = s(args.flags['strip-prefix']);\n if (strip) opts.stripPrefix = resolve(cwd, strip);\n const urlPrefix = s(args.flags['url-prefix']);\n if (urlPrefix !== undefined) opts.urlPrefix = urlPrefix;\n return [planFiles(opts)];\n }\n default:\n throw new Error(`unknown target \"${target}\" (next, expo-export, ios, android, files)`);\n }\n}\n\n/** Human readable listing of the plans: what `collect` prints. */\nexport function renderPlans(plans: UploadPlan[], bin: string, cwd: string): string {\n const lines: string[] = [];\n const rel = (p: string): string => (p.startsWith(cwd + sep) ? relative(cwd, p) : p);\n for (const plan of plans) {\n lines.push(`${plan.label} set=${plan.artifactSetId} platform=${plan.platform}${plan.ota ? ' ota' : ''}${plan.updateId ? ` update=${plan.updateId}` : ''}${plan.parentSetId ? ` parent=${plan.parentSetId}` : ''}`);\n for (const f of plan.files) {\n const name = f.kind === 'sourcemap' || f.kind === 'js_bundle' ? ` → ${manifestName(plan, f.path)}` : '';\n lines.push(` ${f.kind.padEnd(9)} ${String(f.size).padStart(9)} ${rel(f.path)}${name}`);\n }\n for (const w of plan.warnings) lines.push(` warning: ${w}`);\n lines.push(` $ ${formatCommand(bin, uploadArgs(plan), cwd)}`);\n lines.push('');\n }\n return lines.join('\\n');\n}\n\nexport interface CliIo {\n out?: (text: string) => void;\n err?: (text: string) => void;\n env?: Record<string, string | undefined>;\n cwd?: string;\n exec?: RunOptions['exec'];\n /** `init`: asks before writing. Default: a y/N prompt when stdin and stdout are terminals, else no prompt. */\n confirm?: RunInitOptions['confirm'];\n}\n\nfunction ttyConfirm(question: string): Promise<boolean> {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n return new Promise((done) => {\n rl.question(question, (answer) => {\n rl.close();\n done(/^y(es)?$/i.test(answer.trim()));\n });\n });\n}\n\n/** Runs the CLI. Returns the process exit code; never throws. */\nexport async function main(argv: string[], io: CliIo = {}): Promise<number> {\n const out = io.out ?? ((t: string) => void process.stdout.write(`${t}\\n`));\n const err = io.err ?? ((t: string) => void process.stderr.write(`${t}\\n`));\n const env = io.env ?? process.env;\n const cwd = io.cwd ?? process.cwd();\n try {\n const args = parseArgs(argv);\n const [command, target] = args.positionals;\n if (!command || args.flags.help || command === 'help') {\n out(USAGE);\n return command || args.flags.help ? 0 : 2;\n }\n const bin = s(args.flags['argus-bin']) ?? env.ARGUS_BIN ?? 'argus';\n switch (command) {\n case 'init': {\n const opts: RunInitOptions = { dir: resolve(cwd, (args.multi.dir ?? [])[0] ?? '.'), out };\n const dsn = s(args.flags.dsn);\n if (dsn) opts.dsn = dsn;\n if (args.flags.yes) opts.yes = true;\n if (args.flags['dry-run']) opts.dryRun = true;\n const confirm = io.confirm ?? (process.stdin.isTTY && process.stdout.isTTY && !io.out ? ttyConfirm : undefined);\n if (confirm) opts.confirm = confirm;\n await runInit(opts);\n return 0;\n }\n case 'new-id':\n out(newArtifactSetId(s(args.flags.prefix) ?? 'build'));\n return 0;\n case 'prelude': {\n const res = writeArtifactSetModule({ file: resolve(cwd, need(args, 'out')), artifactSetId: s(args.flags['set-id']) ?? env.ARGUS_ARTIFACT_SET_ID ?? need(args, 'set-id') });\n out(res.file);\n return 0;\n }\n case 'collect': {\n if (!target) throw new Error('collect needs a target (next, expo-export, ios, android, files)');\n const plans = plansFor(target, args, env, cwd);\n if (args.flags.json) out(JSON.stringify(plans.map((p) => ({ ...p, args: uploadArgs(p) })), null, 2));\n else out(renderPlans(plans, bin, cwd));\n return 0;\n }\n case 'upload': {\n if (!target) throw new Error('upload needs a target (next, expo-export, ios, android, files)');\n const plans = plansFor(target, args, env, cwd);\n if (args.flags.print) {\n for (const p of plans) out(formatCommand(bin, uploadArgs(p, args.flags['dry-run'] ? { dryRun: true } : {}), cwd));\n return 0;\n }\n const runOpts: RunOptions = { bin, env, cwd, log: err };\n if (args.flags['dry-run']) runOpts.dryRun = true;\n const url = s(args.flags.url);\n if (url) runOpts.url = url;\n if (io.exec) runOpts.exec = io.exec;\n const transport = s(args.flags.transport);\n if (transport) runOpts.transport = transport as NonNullable<RunOptions['transport']>;\n // An explicit --bin means \"use this binary\".\n else if (s(args.flags['argus-bin'])) runOpts.transport = 'cli';\n const results = await runUploads(plans, runOpts);\n const failed = results.find((r) => r.code !== 0);\n if (failed) {\n err(`[argus] upload failed for ${failed.plan.label} (exit ${failed.code}): ${failed.command}`);\n return failed.code || 1;\n }\n if (target === 'next' && args.flags['delete-maps'] && !args.flags['dry-run']) {\n const maps = browserSourceMaps((args.multi.dir ?? [])[0] ? resolve(cwd, args.multi.dir![0]!) : cwd, s(args.flags['dist-dir']) ?? '.next');\n for (const m of maps) rmSync(m, { force: true });\n err(`[argus] deleted ${maps.length} browser source map(s) from the build output`);\n }\n return 0;\n }\n default:\n throw new Error(`unknown command \"${command}\"`);\n }\n } catch (e) {\n err(`argus-build: ${e instanceof Error ? e.message : String(e)}`);\n return 2;\n }\n}\n","/**\n * Artifact discovery and upload planning. A plan is one `argus artifacts upload` invocation:\n * one artifact set, one platform, an explicit file list. The Rust CLI (`crates/cli`) hashes the\n * files, builds the manifest and uploads; this module only decides WHAT goes into WHICH set and\n * with which naming flags, so that namespaces never mix (browser vs server chunks, iOS vs\n * Android, embedded build vs OTA update).\n */\nimport { closeSync, existsSync, openSync, readFileSync, readSync, readdirSync, statSync } from 'node:fs';\nimport { basename, dirname, join, relative, resolve, sep } from 'node:path';\nimport { assertArtifactSetId, type BuildPlatform } from './ids';\n\nexport type ArtifactFileKind = 'sourcemap' | 'js_bundle' | 'dsym' | 'proguard' | 'elf';\n\n/** Mirrors `classify` in crates/cli/src/upload.rs (hermes maps are detected by the CLI from content). */\nexport function classifyArtifact(path: string): ArtifactFileKind | undefined {\n const lower = basename(path).toLowerCase();\n if (lower.endsWith('.map')) return 'sourcemap';\n if (lower === 'mapping.txt' || lower.endsWith('.mapping.txt')) return 'proguard';\n if (lower.endsWith('.so') || lower.endsWith('.so.dbg')) return 'elf';\n const parts = path.split(/[\\\\/]/);\n if (parts.includes('DWARF') && parts.some((p) => p.endsWith('.dSYM'))) return 'dsym';\n if (/\\.(js|mjs|cjs|bundle|jsbundle|hbc)$/.test(lower)) return 'js_bundle';\n return undefined;\n}\n\nconst SKIP_DIRS = new Set(['node_modules', '.git', 'cache', '.cache', 'Pods']);\n\n/** Recursive file list, sorted, symlinks not followed. */\nexport function walkFiles(dir: string, opts: { skipDirs?: ReadonlySet<string> } = {}): string[] {\n const skip = opts.skipDirs ?? SKIP_DIRS;\n const out: string[] = [];\n const visit = (d: string): void => {\n let entries;\n try {\n entries = readdirSync(d, { withFileTypes: true });\n } catch {\n return;\n }\n for (const e of entries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))) {\n const p = join(d, e.name);\n if (e.isDirectory()) {\n if (!skip.has(e.name)) visit(p);\n } else if (e.isFile()) out.push(p);\n }\n };\n visit(dir);\n return out;\n}\n\nexport interface UploadMeta {\n release?: string | undefined;\n dist?: string | undefined;\n nativeRelease?: string | undefined;\n nativeBuild?: string | undefined;\n runtimeVersion?: string | undefined;\n gitSha?: string | undefined;\n}\n\nexport interface UploadPlan extends UploadMeta {\n /** e.g. `next:browser`, `expo-export:ios`, `native:android`. */\n label: string;\n artifactSetId: string;\n platform: BuildPlatform;\n /** Absolute paths handed to the CLI. A `.dSYM` bundle is passed as its directory. */\n paths: string[];\n /** Every file that will be part of the set, with its kind — what `collect` prints. */\n files: { path: string; kind: ArtifactFileKind; size: number }[];\n /** `--strip-prefix`: removed from JS paths to form the name frames are matched against. */\n stripPrefix?: string | undefined;\n /** `--url-prefix`: prepended to that name. */\n urlPrefix?: string | undefined;\n /**\n * Source map → generated file, for maps not named `<generated file>.map` (Turbopack chunks).\n * Only the HTTP transport honours it; the argus CLI names a map after its own file name.\n */\n generatedFor?: Record<string, string> | undefined;\n /** OTA update (not embedded in a native binary). */\n ota?: boolean | undefined;\n updateId?: string | undefined;\n /** Artifact set of the native build this OTA update runs on (native symbols are resolved there). */\n parentSetId?: string | undefined;\n warnings: string[];\n}\n\nfunction describe(paths: string[]): UploadPlan['files'] {\n const out: UploadPlan['files'] = [];\n for (const p of paths) {\n const files = statSync(p).isDirectory() ? walkFiles(p, { skipDirs: new Set() }) : [p];\n for (const f of files) {\n const kind = classifyArtifact(f);\n if (kind) out.push({ path: f, kind, size: statSync(f).size });\n }\n }\n return out;\n}\n\nfunction meta(m: UploadMeta): UploadMeta {\n const out: UploadMeta = {};\n for (const k of ['release', 'dist', 'nativeRelease', 'nativeBuild', 'runtimeVersion', 'gitSha'] as const) {\n if (m[k]) out[k] = m[k];\n }\n return out;\n}\n\nconst RE_JS = /\\.(js|mjs|cjs|bundle|jsbundle|hbc)$/;\nconst RE_JS_MAP = /\\.(js|mjs|cjs|bundle|jsbundle|hbc)\\.map$/;\n\n/** The file named by the trailing `//# sourceMappingURL=` comment of a generated file, if any. */\nfunction referencedMap(file: string): string | undefined {\n let tail = '';\n try {\n const size = statSync(file).size;\n const buf = Buffer.alloc(Math.min(size, 1024));\n const fd = openSync(file, 'r');\n try {\n readSync(fd, buf, 0, buf.length, size - buf.length);\n } finally {\n closeSync(fd);\n }\n tail = buf.toString('utf8');\n } catch {\n return undefined;\n }\n const ref = /\\/\\/[#@] sourceMappingURL=([^\\s'\"]+)\\s*$/.exec(tail)?.[1];\n if (!ref || /^[a-z][a-z0-9+.-]*:/i.test(ref)) return undefined; // data: or absolute URL\n return resolve(dirname(file), ref.split(/[?#]/)[0]!);\n}\n\ninterface JsPairs {\n /** Source maps and (with bundles) their generated files, sorted. */\n paths: string[];\n /** Map → generated file, for maps that are not named `<generated file>.map`. */\n generatedFor: Record<string, string>;\n}\n\n/**\n * Source maps with their generated JS file. The usual pairing is the sibling `<file>.map`;\n * Turbopack names a chunk's map after the map's own hash, so the chunk's `sourceMappingURL`\n * comment is the only link. Maps without a generated file are reported.\n */\nfunction jsPairs(dir: string, includeBundles: boolean, warnings: string[], label: string): JsPairs {\n const files = walkFiles(dir);\n const set = new Set(files);\n const orphans = new Set(files.filter((f) => RE_JS_MAP.test(f.toLowerCase()) && !set.has(f.slice(0, -4))));\n const generatedFor: Record<string, string> = {};\n const referenced = new Set<string>();\n if (orphans.size > 0) {\n for (const f of files) {\n if (!RE_JS.test(f.toLowerCase()) || set.has(`${f}.map`)) continue;\n const map = referencedMap(f);\n if (map && orphans.has(map) && !generatedFor[map]) {\n generatedFor[map] = f;\n referenced.add(f);\n }\n }\n }\n const out: string[] = [];\n let unmapped = 0;\n for (const f of files) {\n const lower = f.toLowerCase();\n if (RE_JS_MAP.test(lower)) {\n const generated = generatedFor[f] ?? (set.has(f.slice(0, -4)) ? f.slice(0, -4) : undefined);\n if (!generated) warnings.push(`${label}: ${f} has no generated file next to it`);\n out.push(f);\n if (includeBundles && generated) out.push(generated);\n } else if (RE_JS.test(lower) && !set.has(`${f}.map`) && !referenced.has(f)) unmapped++;\n }\n if (unmapped > 0) warnings.push(`${label}: ${unmapped} JS file(s) without a source map were skipped`);\n return { paths: [...new Set(out)].sort(), generatedFor };\n}\n\n/* --------------------------------------------------------------------- Next */\n\nexport interface NextPlanOptions extends UploadMeta {\n /** Project directory containing the build output. Default `process.cwd()`. */\n projectDir?: string;\n /** Build output directory relative to the project. Default `.next`. */\n distDir?: string;\n /** Artifact set of the browser chunks. */\n artifactSetId: string;\n /** Artifact set of the server chunks. Default `<artifactSetId>-node`. */\n serverArtifactSetId?: string;\n /** Public path the browser loads chunks from. Default `/_next/` (add your basePath / assetPrefix path). */\n urlPrefix?: string;\n /** Upload the generated JS next to each map. Default true. */\n includeBundles?: boolean;\n}\n\n/**\n * Two plans, two artifact sets:\n * - `next:browser` — `<dist>/static/**` as `/_next/static/...` (platform `web`);\n * - `next:server` — `<dist>/server/**` named relative to the project (`.next/server/...`, platform `node`).\n * A plan is omitted (with a warning on the other one) when it has no source maps.\n */\nconst NO_PAIRS: JsPairs = { paths: [], generatedFor: {} };\nconst renamed = (pairs: JsPairs): Pick<UploadPlan, 'generatedFor'> => (Object.keys(pairs.generatedFor).length > 0 ? { generatedFor: pairs.generatedFor } : {});\n\nexport function planNext(options: NextPlanOptions): UploadPlan[] {\n const projectDir = resolve(options.projectDir ?? process.cwd());\n const dist = resolve(projectDir, options.distDir ?? '.next');\n if (!existsSync(dist)) throw new Error(`Argus: Next build output not found at ${dist} (run \\`next build\\` first)`);\n const web = assertArtifactSetId(options.artifactSetId);\n const node = assertArtifactSetId(options.serverArtifactSetId ?? `${web}-node`, 'server artifact set id');\n if (web === node) throw new Error('Argus: browser and server chunks must use different artifact set ids');\n const include = options.includeBundles !== false;\n const plans: UploadPlan[] = [];\n const notes: string[] = [];\n\n const browserWarnings: string[] = [];\n const browser = existsSync(join(dist, 'static')) ? jsPairs(join(dist, 'static'), include, browserWarnings, 'next:browser') : NO_PAIRS;\n if (browser.paths.some((f) => f.endsWith('.map'))) {\n plans.push({\n label: 'next:browser',\n artifactSetId: web,\n platform: 'web',\n paths: browser.paths,\n files: describe(browser.paths),\n stripPrefix: dist,\n urlPrefix: options.urlPrefix ?? '/_next/',\n ...renamed(browser),\n ...meta(options),\n warnings: browserWarnings,\n });\n } else notes.push('next:browser: no source maps under static/ (is productionBrowserSourceMaps enabled?)');\n\n const serverWarnings: string[] = [];\n const server = existsSync(join(dist, 'server')) ? jsPairs(join(dist, 'server'), include, serverWarnings, 'next:server') : NO_PAIRS;\n if (server.paths.some((f) => f.endsWith('.map'))) {\n plans.push({\n label: 'next:server',\n artifactSetId: node,\n platform: 'node',\n paths: server.paths,\n files: describe(server.paths),\n // Server frames are filesystem paths ending in `.next/server/...`.\n stripPrefix: projectDir,\n urlPrefix: '',\n ...renamed(server),\n ...meta(options),\n warnings: serverWarnings,\n });\n } else notes.push('next:server: no source maps under server/ (server source maps are not emitted by default)');\n\n if (plans.length === 0) throw new Error(`Argus: no source maps found in ${dist}. ${notes.join('; ')}`);\n plans[0]!.warnings.push(...notes);\n return plans;\n}\n\n/** Deletes browser `.map` files from the build output so they are never deployed or served. Returns the removed paths. */\nexport function browserSourceMaps(projectDir: string, distDir = '.next'): string[] {\n const dir = resolve(projectDir, distDir, 'static');\n return existsSync(dir) ? walkFiles(dir).filter((f) => f.endsWith('.map')) : [];\n}\n\n/* -------------------------------------------------------------- Expo export */\n\nexport type MobilePlatform = 'ios' | 'android';\n\nexport interface ExpoExportPlanOptions extends UploadMeta {\n /** Output directory of `expo export`. Default `dist`. */\n exportDir?: string;\n /** One artifact set per platform (an artifact set has exactly one platform). */\n artifactSetIds: Partial<Record<MobilePlatform, string>>;\n /** Limit to these platforms. Default: every platform in `metadata.json` that has an id. */\n platforms?: MobilePlatform[];\n /** OTA update id per platform (or one string for a single platform). Falls back to `metadata.json` when it carries one. */\n updateId?: string | Partial<Record<MobilePlatform, string>>;\n /** Artifact set of the native build the update targets, per platform. */\n parentSetIds?: Partial<Record<MobilePlatform, string>>;\n}\n\ninterface ExpoMetadata {\n id?: unknown;\n updateId?: unknown;\n fileMetadata?: Record<string, { bundle?: unknown; id?: unknown; updateId?: unknown } | undefined>;\n}\n\nfunction str(v: unknown): string | undefined {\n return typeof v === 'string' && v ? v : undefined;\n}\n\n/**\n * One plan per platform from `expo export` output: the bundle named by\n * `metadata.json → fileMetadata.<platform>.bundle` and its `.map` (export with\n * `--dump-sourcemap` / `--source-maps`). Marked `--ota` with update id, runtime version and the\n * parent (native build) set.\n */\nexport function planExpoExport(options: ExpoExportPlanOptions): UploadPlan[] {\n const dir = resolve(options.exportDir ?? 'dist');\n const metadataPath = join(dir, 'metadata.json');\n if (!existsSync(metadataPath)) throw new Error(`Argus: ${metadataPath} not found (run \\`expo export\\` first)`);\n const metadata = JSON.parse(readFileSync(metadataPath, 'utf8')) as ExpoMetadata;\n const available = Object.keys(metadata.fileMetadata ?? {}).filter((p): p is MobilePlatform => p === 'ios' || p === 'android');\n const wanted = options.platforms ?? available.filter((p) => options.artifactSetIds[p]);\n if (wanted.length === 0) throw new Error('Argus: no platform to upload — pass an artifact set id for ios and/or android');\n const ids = wanted.map((p) => options.artifactSetIds[p]);\n if (new Set(ids).size !== ids.length) throw new Error('Argus: iOS and Android updates need different artifact set ids');\n\n const plans: UploadPlan[] = [];\n for (const platform of wanted) {\n const label = `expo-export:${platform}`;\n const artifactSetId = assertArtifactSetId(options.artifactSetIds[platform], `artifact set id for ${platform}`);\n const entry = metadata.fileMetadata?.[platform];\n const bundleRel = str(entry?.bundle);\n if (!bundleRel) throw new Error(`Argus: metadata.json has no bundle for ${platform}`);\n const bundle = resolve(dir, bundleRel);\n if (!bundle.startsWith(dir + sep)) throw new Error(`Argus: metadata.json bundle path escapes the export directory: ${bundleRel}`);\n const map = `${bundle}.map`;\n if (!existsSync(bundle)) throw new Error(`Argus: ${bundle} is missing`);\n if (!existsSync(map)) throw new Error(`Argus: ${map} is missing — export with source maps (\\`expo export --dump-sourcemap\\`)`);\n const warnings: string[] = [];\n const given = typeof options.updateId === 'string' ? (wanted.length === 1 ? options.updateId : undefined) : options.updateId?.[platform];\n if (typeof options.updateId === 'string' && wanted.length > 1) warnings.push(`${label}: a single --update-id cannot apply to several platforms; pass one per platform`);\n const updateId = given ?? str(entry?.updateId) ?? str(entry?.id) ?? str(metadata.updateId) ?? str(metadata.id);\n if (!updateId) warnings.push(`${label}: no update id (not in metadata.json, none given) — the set is still matched by artifact_set_id`);\n const parentSetId = options.parentSetIds?.[platform];\n if (!parentSetId) warnings.push(`${label}: no parent set id — native frames of crashes during this update cannot be tied to the native build's symbols`);\n const paths = [bundle, map];\n plans.push({\n label,\n artifactSetId,\n platform,\n paths,\n files: describe(paths),\n // Named by file name: `entry-<hash>.hbc` ← `entry-<hash>.hbc.map`.\n stripPrefix: dirname(bundle),\n urlPrefix: '',\n ota: true,\n updateId,\n parentSetId: parentSetId ? assertArtifactSetId(parentSetId, `parent set id for ${platform}`) : undefined,\n ...meta(options),\n warnings,\n });\n }\n return plans;\n}\n\n/* ------------------------------------------------------------ native builds */\n\nexport interface NativePlanOptions extends UploadMeta {\n platform: MobilePlatform;\n artifactSetId: string;\n /**\n * Directories / files to search: an `.xcarchive`, a `dSYMs` folder, `ios/build`,\n * `android/app/build`, an EAS artifacts folder, or explicit files.\n */\n searchPaths: string[];\n /** Embedded JS bundle and its (Hermes-composed) source map, when not found by the search. */\n bundle?: string;\n sourcemap?: string;\n /** Android: also upload unstripped `.so` files found under the search paths. Default false. */\n includeNativeLibs?: boolean;\n}\n\nfunction findDsyms(root: string): string[] {\n const out: string[] = [];\n const visit = (d: string, depth: number): void => {\n if (depth > 12) return;\n let entries;\n try {\n entries = readdirSync(d, { withFileTypes: true });\n } catch {\n return;\n }\n for (const e of entries) {\n if (!e.isDirectory() || e.name === 'node_modules' || e.name === '.git') continue;\n const p = join(d, e.name);\n if (e.name.endsWith('.dSYM')) out.push(p);\n else visit(p, depth + 1);\n }\n };\n if (root.endsWith('.dSYM')) out.push(root);\n else visit(root, 0);\n return out.sort();\n}\n\n/**\n * The embedded build of one platform — one artifact set holding\n * - iOS: every `.dSYM` bundle + `main.jsbundle(.map)`;\n * - Android: R8 `mapping.txt` + `index.android.bundle(.map)` (+ unstripped `.so` on request).\n * JS files keep their file name (`index.android.bundle`), which is what Hermes frames report.\n */\nexport function planNative(options: NativePlanOptions): UploadPlan {\n const label = `native:${options.platform}`;\n const artifactSetId = assertArtifactSetId(options.artifactSetId);\n const warnings: string[] = [];\n const paths = new Set<string>();\n const roots = options.searchPaths.map((p) => resolve(p));\n for (const root of roots) if (!existsSync(root)) throw new Error(`Argus: ${root} does not exist`);\n\n const jsMaps: string[] = [];\n for (const root of roots) {\n const isDir = statSync(root).isDirectory();\n if (options.platform === 'ios') {\n if (isDir) for (const d of findDsyms(root)) paths.add(d);\n }\n const files = isDir ? (root.endsWith('.dSYM') ? [] : walkFiles(root, { skipDirs: new Set(['node_modules', '.git', 'Pods']) })) : [root];\n for (const f of files) {\n const name = basename(f).toLowerCase();\n if (f.split(sep).some((part) => part.endsWith('.dSYM'))) continue; // covered by the bundle directory\n if (options.platform === 'android') {\n if (name === 'mapping.txt') paths.add(f);\n else if (options.includeNativeLibs && name.endsWith('.so')) paths.add(f);\n }\n if (/\\.(jsbundle|bundle)\\.map$/.test(name)) jsMaps.push(f);\n }\n }\n if (options.sourcemap) jsMaps.unshift(resolve(options.sourcemap));\n\n const uniqueMaps = [...new Set(jsMaps)];\n if (uniqueMaps.length > 1 && !options.sourcemap) {\n warnings.push(`${label}: several JS source maps found, using ${uniqueMaps[0]} (pass --sourcemap to choose): ${uniqueMaps.slice(1).join(', ')}`);\n }\n const map = uniqueMaps[0];\n if (map) {\n if (!existsSync(map)) throw new Error(`Argus: ${map} does not exist`);\n paths.add(map);\n const bundle = options.bundle ? resolve(options.bundle) : map.slice(0, -4);\n if (existsSync(bundle)) {\n if (basename(bundle) !== basename(map).slice(0, -4)) {\n warnings.push(`${label}: bundle ${basename(bundle)} and map ${basename(map)} have different names; frames are matched against \"${basename(map).slice(0, -4)}\"`);\n }\n paths.add(bundle);\n }\n } else warnings.push(`${label}: no JS source map found (*.bundle.map / *.jsbundle.map) — JS frames of this build will stay unsymbolicated`);\n\n const list = [...paths].sort();\n const files = describe(list);\n if (options.platform === 'ios' && !files.some((f) => f.kind === 'dsym')) warnings.push(`${label}: no .dSYM found — native iOS frames will stay unsymbolicated`);\n if (options.platform === 'android') {\n const mappings = files.filter((f) => f.kind === 'proguard');\n if (mappings.length === 0) warnings.push(`${label}: no mapping.txt found — fine only if R8/ProGuard is disabled for this build`);\n if (mappings.length > 1) throw new Error(`Argus: several mapping.txt files found (${mappings.map((m) => m.path).join(', ')}); point --dir at one build variant`);\n }\n if (list.length === 0) throw new Error(`Argus: nothing to upload for ${label} under ${roots.join(', ')}`);\n return { label, artifactSetId, platform: options.platform, paths: list, files, ...meta(options), warnings };\n}\n\n/* ------------------------------------------------------------------ generic */\n\nexport interface FilesPlanOptions extends UploadMeta {\n artifactSetId: string;\n platform: BuildPlatform;\n /** Files or directories; directories are searched for `*.map` with their generated file. */\n paths: string[];\n stripPrefix?: string;\n urlPrefix?: string;\n includeBundles?: boolean;\n}\n\n/** Any bundler output (esbuild, Vite, a worker build…): source maps plus their generated files. */\nexport function planFiles(options: FilesPlanOptions): UploadPlan {\n const label = `files:${options.platform}`;\n const warnings: string[] = [];\n const paths: string[] = [];\n const generatedFor: Record<string, string> = {};\n for (const p of options.paths.map((x) => resolve(x))) {\n if (!existsSync(p)) throw new Error(`Argus: ${p} does not exist`);\n if (statSync(p).isDirectory()) {\n const pairs = jsPairs(p, options.includeBundles !== false, warnings, label);\n paths.push(...pairs.paths);\n Object.assign(generatedFor, pairs.generatedFor);\n } else paths.push(p);\n }\n const unique = [...new Set(paths)].sort();\n if (unique.length === 0) throw new Error(`Argus: no artifacts found in ${options.paths.join(', ')}`);\n const plan: UploadPlan = {\n label,\n artifactSetId: assertArtifactSetId(options.artifactSetId),\n platform: options.platform,\n paths: unique,\n files: describe(unique),\n ...meta(options),\n warnings,\n };\n if (options.stripPrefix !== undefined) plan.stripPrefix = resolve(options.stripPrefix);\n if (options.urlPrefix !== undefined) plan.urlPrefix = options.urlPrefix;\n if (Object.keys(generatedFor).length > 0) plan.generatedFor = generatedFor;\n return plan;\n}\n\n/* ----------------------------------------------------------- CLI arguments */\n\n/**\n * Arguments for the Rust CLI: `argus artifacts upload …` (flags as defined in\n * crates/cli/src/upload.rs). The upload key is never put on the command line; the CLI reads\n * `ARGUS_UPLOAD_KEY` (and `ARGUS_URL`) from the environment.\n */\nexport function uploadArgs(plan: UploadPlan, opts: { dryRun?: boolean; url?: string } = {}): string[] {\n const args = ['artifacts', 'upload', '--set-id', plan.artifactSetId, '--platform', plan.platform];\n const flag = (name: string, value: string | undefined): void => {\n if (value !== undefined && value !== '') args.push(name, value);\n };\n flag('--url', opts.url);\n flag('--release', plan.release);\n flag('--dist', plan.dist);\n flag('--native-release', plan.nativeRelease);\n flag('--native-build', plan.nativeBuild);\n flag('--runtime-version', plan.runtimeVersion);\n if (plan.ota) args.push('--ota');\n flag('--update-id', plan.updateId);\n flag('--parent-set-id', plan.parentSetId);\n flag('--git-sha', plan.gitSha);\n flag('--strip-prefix', plan.stripPrefix);\n flag('--url-prefix', plan.urlPrefix);\n if (opts.dryRun) args.push('--dry-run');\n args.push('--', ...plan.paths);\n return args;\n}\n\n/** The name a JS file gets in the manifest (`bundle_name`), mirroring the CLI's rule. For display and tests. */\nexport function manifestName(plan: Pick<UploadPlan, 'stripPrefix' | 'urlPrefix' | 'generatedFor'>, file: string): string {\n const generated = file.endsWith('.map') ? (plan.generatedFor?.[file] ?? file.slice(0, -4)) : file;\n const prefix = plan.stripPrefix;\n const rel = prefix && (generated === prefix || generated.startsWith(prefix.endsWith(sep) ? prefix : prefix + sep)) ? relative(prefix, generated) : basename(generated);\n return `${plan.urlPrefix ?? ''}${rel.split(sep).join('/').replace(/^\\/+/, '')}`;\n}\n\n/** A copy-pasteable shell command for a plan (paths relative to `cwd` when inside it). */\nexport function formatCommand(bin: string, args: string[], cwd: string = process.cwd()): string {\n const quote = (s: string): string => (/^[A-Za-z0-9_./:@=+-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\\\''`)}'`);\n const short = (s: string): string => {\n if (!s.startsWith(cwd + sep)) return s;\n return relative(cwd, s);\n };\n return [bin, ...args.map((a) => quote(short(a)))].join(' ');\n}\n","/**\n * Artifact set identity (docs/protocol/artifacts-v1.md §1): generated at build start, compiled\n * into the app and written to the upload manifest. `release` / `dist` are human context only.\n */\nimport { randomBytes } from 'node:crypto';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\n\n/** The global the SDKs read (`@getargus/react-native` → `globalThis.__ARGUS_ARTIFACT_SET_ID__`). */\nexport const ARTIFACT_SET_GLOBAL = '__ARGUS_ARTIFACT_SET_ID__';\nexport const NEXT_PUBLIC_ENV = 'NEXT_PUBLIC_ARGUS_ARTIFACT_SET_ID';\nexport const NEXT_SERVER_ENV = 'ARGUS_SERVER_ARTIFACT_SET_ID';\n\nconst RE_ARTIFACT_SET_ID = /^[A-Za-z0-9._:-]{1,128}$/;\nconst GENERATED_MARK = '/* generated by @getargus/build-tools — do not edit, do not commit */';\n\nexport type BuildPlatform = 'ios' | 'android' | 'web' | 'node';\n\nexport function isValidArtifactSetId(id: unknown): id is string {\n return typeof id === 'string' && RE_ARTIFACT_SET_ID.test(id);\n}\n\nexport function assertArtifactSetId(id: unknown, what = 'artifact set id'): string {\n if (!isValidArtifactSetId(id)) {\n throw new Error(`Argus: invalid ${what} ${JSON.stringify(id)} — expected 1..128 chars of [A-Za-z0-9._:-]`);\n }\n return id;\n}\n\n/**\n * Same format as `argus artifacts new-id`: `<prefix>-<uuidv7 without dashes>`. The prefix keeps\n * only `[A-Za-z0-9._-]` (max 80 chars), e.g. `ios-1.2.0-34`.\n */\nexport function newArtifactSetId(prefix = 'build', now: number = Date.now()): string {\n const clean = Array.from(String(prefix))\n .filter((c) => /[A-Za-z0-9._-]/.test(c))\n .slice(0, 80)\n .join('');\n const b = randomBytes(16);\n b.writeUIntBE(now, 0, 6); // 48-bit ms timestamp\n b[6] = (b[6]! & 0x0f) | 0x70;\n b[8] = (b[8]! & 0x3f) | 0x80;\n return `${clean || 'build'}-${b.toString('hex')}`;\n}\n\nexport type ArtifactSetIdInput = string | Partial<Record<BuildPlatform, string>> | ((platform: BuildPlatform) => string | undefined) | undefined;\n\n/**\n * Picks the id for one platform. Environment wins over configuration so CI can inject the id\n * generated at build start (same rule as the `@getargus/expo` config plugin):\n * `ARGUS_ARTIFACT_SET_ID_<PLATFORM>` → `ARGUS_ARTIFACT_SET_ID` → the `artifactSetId` option.\n */\nexport function resolveArtifactSetId(input: ArtifactSetIdInput, platform: BuildPlatform, env: Record<string, string | undefined> = process.env): string | undefined {\n const fromEnv = env[`ARGUS_ARTIFACT_SET_ID_${platform.toUpperCase()}`] || env.ARGUS_ARTIFACT_SET_ID;\n const fromOption = typeof input === 'function' ? input(platform) : typeof input === 'string' ? input : input?.[platform];\n const id = fromEnv || fromOption;\n return id ? assertArtifactSetId(id, `artifact set id for ${platform}`) : undefined;\n}\n\n/** A script that defines the global. Valid as a Metro polyfill, a plain `<script>` or a module with side effects. */\nexport function artifactSetPrelude(artifactSetId: string): string {\n const id = JSON.stringify(assertArtifactSetId(artifactSetId));\n return (\n `${GENERATED_MARK}\\n` +\n `(function (g) {\\n g.${ARTIFACT_SET_GLOBAL} = ${id};\\n})(\\n` +\n \" typeof globalThis !== 'undefined' ? globalThis : typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this,\\n\" +\n ');\\n'\n );\n}\n\nexport interface WriteArtifactSetModuleOptions {\n /** Where to write the generated source file. It is an INPUT of the bundler, never a built output. */\n file: string;\n artifactSetId: string;\n}\n\n/**\n * Writes a tiny generated source file that defines `globalThis.__ARGUS_ARTIFACT_SET_ID__`.\n *\n * This is the only way the id gets into a bundle: as source that goes through the bundler, so\n * bundle ↔ source map coordinates stay consistent. Nothing here ever edits a built bundle, a\n * `.map` or Hermes bytecode, and the function refuses to overwrite a file it did not generate.\n */\nexport function writeArtifactSetModule(options: WriteArtifactSetModuleOptions): { file: string; changed: boolean } {\n const file = resolve(options.file);\n const content = artifactSetPrelude(options.artifactSetId);\n if (existsSync(file)) {\n const current = readFileSync(file, 'utf8');\n if (current === content) return { file, changed: false };\n if (!current.startsWith(GENERATED_MARK)) {\n throw new Error(`Argus: refusing to overwrite ${file}: it was not generated by @getargus/build-tools (built output is never patched)`);\n }\n }\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, content);\n return { file, changed: true };\n}\n\n/** Alias of `writeArtifactSetModule` under the name the integration docs use. */\nexport const injectArtifactSetId = writeArtifactSetModule;\n","/**\n * `argus-build init` — sets a project up for Argus: detects Next.js / Expo-React Native / Node\n * from `package.json` in the working directory and writes the few files the SDK needs.\n *\n * Rules it never breaks: an existing file is not overwritten (the snippet to add is printed\n * instead), secrets never go into a tracked file, nothing is installed (the command is printed),\n * and a second run changes nothing.\n */\nimport { spawnSync } from 'node:child_process';\nimport { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';\nimport { dirname, extname, join, resolve } from 'node:path';\n\nexport type ProjectKind = 'next' | 'expo' | 'react-native' | 'node';\nexport type PackageManager = 'pnpm' | 'yarn' | 'npm' | 'bun';\n\nexport interface ProjectInfo {\n kind: ProjectKind;\n dir: string;\n /** Package name from `package.json`, for messages only. */\n name: string | undefined;\n typescript: boolean;\n /** `\"type\": \"module\"` in package.json. */\n esm: boolean;\n packageManager: PackageManager;\n /** All dependency names (dependencies + devDependencies). */\n deps: Set<string>;\n /** Next: `src` when the app lives in `src/`, else ``. Node: `src` when that directory exists. */\n sourceDir: string;\n /** Next only. */\n router?: 'app' | 'pages' | undefined;\n nextConfig?: string | undefined;\n /** Next only: `[major, minor]` of the installed (else declared) version. */\n nextVersion?: [number, number] | undefined;\n /** Node only: `main` of package.json when it names a file. */\n main?: string | undefined;\n}\n\ninterface PackageJson {\n name?: unknown;\n type?: unknown;\n main?: unknown;\n packageManager?: unknown;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n}\n\nconst isDir = (p: string): boolean => existsSync(p) && statSync(p).isDirectory();\n\nconst LOCKFILES: [string, PackageManager][] = [\n ['pnpm-lock.yaml', 'pnpm'],\n ['yarn.lock', 'yarn'],\n ['bun.lockb', 'bun'],\n ['bun.lock', 'bun'],\n ['package-lock.json', 'npm'],\n];\n\n/** Lockfile next to package.json, else in a parent (a workspace keeps one lockfile at its root). */\nexport function detectPackageManager(dir: string, pkg: PackageJson = {}): PackageManager {\n const declared = typeof pkg.packageManager === 'string' ? /^(pnpm|yarn|npm|bun)@/.exec(pkg.packageManager)?.[1] : undefined;\n if (declared) return declared as PackageManager;\n for (let d = resolve(dir); ; d = dirname(d)) {\n for (const [file, pm] of LOCKFILES) if (existsSync(join(d, file))) return pm;\n if (dirname(d) === d) return 'npm';\n }\n}\n\nfunction versionOf(dir: string, declared: string | undefined): [number, number] | undefined {\n let version: string | undefined;\n try {\n version = (JSON.parse(readFileSync(join(dir, 'node_modules/next/package.json'), 'utf8')) as { version?: string }).version;\n } catch {\n version = declared;\n }\n const m = /(\\d+)(?:\\.(\\d+))?/.exec(version ?? '');\n return m ? [Number(m[1]), Number(m[2] ?? 0)] : undefined;\n}\n\n/** Reads `package.json` in `dir` (only there: in a monorepo, run it inside the app's package). */\nexport function detectProject(dir: string): ProjectInfo {\n const root = resolve(dir);\n const pkgPath = join(root, 'package.json');\n if (!existsSync(pkgPath)) throw new Error(`no package.json in ${root} — run this in the directory of the app (in a monorepo: the app's own package)`);\n let pkg: PackageJson;\n try {\n pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as PackageJson;\n } catch (e) {\n throw new Error(`cannot read ${pkgPath}: ${e instanceof Error ? e.message : String(e)}`);\n }\n const deps = new Set([...Object.keys(pkg.dependencies ?? {}), ...Object.keys(pkg.devDependencies ?? {})]);\n const info: ProjectInfo = {\n kind: deps.has('next') ? 'next' : deps.has('expo') ? 'expo' : deps.has('react-native') ? 'react-native' : 'node',\n dir: root,\n name: typeof pkg.name === 'string' ? pkg.name : undefined,\n typescript: existsSync(join(root, 'tsconfig.json')) || deps.has('typescript'),\n esm: pkg.type === 'module',\n packageManager: detectPackageManager(root, pkg),\n deps,\n sourceDir: '',\n };\n if (info.kind === 'next') {\n // Next ignores `src/app` when a root `app` (or `pages`) exists.\n const rootRouter = isDir(join(root, 'app')) || isDir(join(root, 'pages'));\n const src = !rootRouter && (isDir(join(root, 'src/app')) || isDir(join(root, 'src/pages')));\n info.sourceDir = src ? 'src' : '';\n info.router = isDir(join(root, info.sourceDir, 'app')) ? 'app' : isDir(join(root, info.sourceDir, 'pages')) ? 'pages' : 'app';\n info.nextConfig = ['next.config.ts', 'next.config.mjs', 'next.config.js', 'next.config.cjs'].find((f) => existsSync(join(root, f)));\n info.nextVersion = versionOf(root, pkg.dependencies?.next ?? pkg.devDependencies?.next);\n } else if (info.kind === 'node') {\n info.sourceDir = isDir(join(root, 'src')) ? 'src' : '';\n info.main = typeof pkg.main === 'string' ? pkg.main : undefined;\n }\n return info;\n}\n\n/* ------------------------------------------------------------------ templates */\n\nexport function nextInstrumentation(typescript: boolean): string {\n const args = typescript ? '...args: unknown[]' : '...args';\n const call = typescript ? '(onRequestError as (...a: unknown[]) => Promise<void>)(...args)' : 'onRequestError(...args)';\n return `// Argus server-side capture. Next calls register() once per server process.\nexport async function register() {\n if (process.env.NEXT_RUNTIME === 'nodejs') {\n const { register } = await import('@getargus/node/next');\n // DSN, environment and release are read from ARGUS_DSN / ARGUS_ENVIRONMENT / ARGUS_RELEASE.\n register({ artifactSetId: process.env.ARGUS_SERVER_ARTIFACT_SET_ID });\n }\n}\n\n// Errors of server components, route handlers and server actions.\nexport const onRequestError = async (${args}) => {\n if (process.env.NEXT_RUNTIME === 'nodejs') {\n const { onRequestError } = await import('@getargus/node/next');\n return ${call};\n }\n};\n`;\n}\n\nexport function nextInstrumentationClient(): string {\n return `// Argus browser capture; Next loads this file before the app hydrates.\nimport { initClient } from '@getargus/browser/next';\n\n// The DSN is read from NEXT_PUBLIC_ARGUS_DSN (inlined at build time).\ninitClient({ artifactSetId: process.env.NEXT_PUBLIC_ARGUS_ARTIFACT_SET_ID });\n\nexport { onRouterTransitionStart } from '@getargus/browser/next';\n`;\n}\n\nexport function nodeSetup(style: 'esm' | 'cjs'): string {\n const load = style === 'esm' ? \"import { init } from '@getargus/node';\" : \"const { init } = require('@getargus/node');\";\n return `// Argus: load this file first in the entry file, so capture is installed before anything else runs.\n${load}\n\ninit(); // reads ARGUS_DSN, ARGUS_ENVIRONMENT (else NODE_ENV) and ARGUS_RELEASE\n`;\n}\n\nconst WITH_ARGUS_IMPORT = \"import { withArgus } from '@getargus/build-tools/next';\";\nconst WITH_ARGUS_REQUIRE = \"const { withArgus } = require('@getargus/build-tools/next');\";\n\n/**\n * Wraps the exported config with `withArgus` when the file ends in the one shape that can be\n * rewritten without parsing JavaScript: a single `export default <identifier>` or\n * `module.exports = <identifier>`. Anything else returns undefined and is left to the user.\n */\nexport function wrapNextConfig(source: string): { content: string; removed: string; added: string[] } | undefined {\n const esm = [...source.matchAll(/^export default ([A-Za-z_$][\\w$]*);?[ \\t]*$/gm)];\n const cjs = [...source.matchAll(/^module\\.exports = ([A-Za-z_$][\\w$]*);?[ \\t]*$/gm)];\n if (esm.length + cjs.length !== 1) return undefined;\n const isEsm = esm.length === 1;\n // A second export form anywhere means the file is not as simple as it looks.\n if (isEsm ? /\\bmodule\\.exports\\b/.test(source) : /^export /m.test(source)) return undefined;\n const m = (isEsm ? esm : cjs)[0]!;\n const wrapped = isEsm ? `export default withArgus(${m[1]});` : `module.exports = withArgus(${m[1]});`;\n const header = isEsm ? WITH_ARGUS_IMPORT : WITH_ARGUS_REQUIRE;\n const body = source.slice(0, m.index) + wrapped + source.slice(m.index! + m[0].length);\n return { content: `${header}\\n${body}`, removed: m[0], added: [header, wrapped] };\n}\n\n/* -------------------------------------------------------------------- planning */\n\nexport interface InitAction {\n /** `create`/`append`/`modify` write; `ok` is already in place; `manual` is printed for the user to do. */\n type: 'create' | 'append' | 'modify' | 'ok' | 'manual';\n /** Path relative to the project directory. */\n file: string;\n /** One line: what and why. */\n summary: string;\n /** create: the whole file. append: the text added at the end. modify: the whole new file. */\n content?: string;\n /** What is shown for the action: the new file, the appended lines, a diff or a snippet. */\n preview?: string;\n}\n\nexport interface InitPlan {\n project: ProjectInfo;\n actions: InitAction[];\n /** Missing packages, as the command for the project's package manager. */\n install: string | undefined;\n /** What is left for the user, in order. */\n nextSteps: string[];\n}\n\nconst DSN_FORM = 'https://<ingest key>@<host>';\nconst RE_DSN = /^https?:\\/\\/[^@\\s/]+@[^@\\s/]+/;\n\nfunction read(dir: string, file: string): string | undefined {\n try {\n return readFileSync(join(dir, file), 'utf8');\n } catch {\n return undefined;\n }\n}\n\nfunction installCommand(pm: PackageManager, packages: string[]): string {\n return `${pm === 'npm' ? 'npm install' : `${pm} add`} ${packages.join(' ')}`;\n}\n\n/** Keys of an env file that are missing from `existing`, as the block to append. */\nfunction envBlock(existing: string | undefined, entries: [key: string, value: string, comment?: string][]): { text: string; keys: string[] } {\n const has = (key: string): boolean => new RegExp(`^\\\\s*(?:export\\\\s+)?${key}\\\\s*=`, 'm').test(existing ?? '');\n const lines: string[] = [];\n const keys: string[] = [];\n for (const [key, value, comment] of entries) {\n if (has(key)) continue;\n if (comment) lines.push(`# ${comment}`);\n lines.push(`${key}=${value}`);\n keys.push(key);\n }\n if (keys.length === 0) return { text: '', keys };\n const lead = existing === undefined || existing === '' ? '' : existing.endsWith('\\n') ? '\\n' : '\\n\\n';\n return { text: `${lead}${lines.join('\\n')}\\n`, keys };\n}\n\nfunction envAction(dir: string, file: string, entries: [string, string, string?][], why: string): InitAction {\n const existing = read(dir, file);\n const block = envBlock(existing, entries);\n if (block.keys.length === 0) return { type: 'ok', file, summary: 'already lists the Argus variables' };\n return {\n type: existing === undefined ? 'create' : 'append',\n file,\n summary: `${block.keys.join(', ')} — ${why}`,\n content: block.text,\n preview: block.text.trim(),\n };\n}\n\n/** True when git (or, outside a repository, `.gitignore` in the project) ignores the file. */\nexport function isGitIgnored(dir: string, file: string): boolean {\n const git = spawnSync('git', ['check-ignore', '-q', file], { cwd: dir, stdio: 'ignore' });\n if (git.status === 0) return true;\n if (git.status === 1) return false;\n // Not a repository (yet) or no git: read the project's own .gitignore, basename patterns only.\n let ignored = false;\n for (const raw of (read(dir, '.gitignore') ?? '').split('\\n')) {\n const line = raw.trim();\n if (!line || line.startsWith('#')) continue;\n const negated = line.startsWith('!');\n const pattern = line.replace(/^!/, '').replace(/^\\//, '');\n if (pattern.includes('/')) continue;\n const escaped = pattern.replace(/[.+^$(){}|[\\]\\\\]/g, '\\\\$&');\n const re = new RegExp(`^${escaped.replace(/\\*/g, '.*').replace(/\\?/g, '.')}$`);\n if (re.test(file)) ignored = !negated;\n }\n return ignored;\n}\n\n/** The DSN goes into a git-ignored local env file; if that cannot be guaranteed it is only printed. */\nfunction dsnAction(dir: string, file: string, entries: [string, string][]): InitAction {\n const existing = read(dir, file);\n const block = envBlock(existing, entries);\n if (block.keys.length === 0) return { type: 'ok', file, summary: `already sets ${entries.map(([k]) => k).join(', ')}` };\n if (!isGitIgnored(dir, file)) {\n return {\n type: 'manual',\n file,\n summary: `not git-ignored, so the DSN was not written — add \"${file}\" to .gitignore, then put this in it`,\n preview: block.text.trim(),\n };\n }\n return { type: existing === undefined ? 'create' : 'append', file, summary: `${block.keys.join(', ')} (git-ignored)`, content: block.text, preview: block.text.trim() };\n}\n\nconst USES_ARGUS = /@getargus\\//;\n\nfunction sourceFile(dir: string, candidates: string[], create: string, content: string, summary: string): InitAction {\n const existing = candidates.find((f) => existsSync(join(dir, f)));\n if (!existing) return { type: 'create', file: create, summary, content, preview: content.trimEnd() };\n if (USES_ARGUS.test(read(dir, existing) ?? '')) return { type: 'ok', file: existing, summary: 'already uses Argus' };\n return { type: 'manual', file: existing, summary: 'exists and is not overwritten — merge this into it', preview: content.trimEnd() };\n}\n\nfunction planNextProject(p: ProjectInfo, dsn: string | undefined): InitPlan {\n const ext = p.typescript ? 'ts' : 'js';\n const at = (name: string): string => (p.sourceDir ? `${p.sourceDir}/${name}` : name);\n const variants = (base: string): string[] => ['ts', 'tsx', 'js', 'jsx', 'mjs'].flatMap((e) => [`${base}.${e}`, `src/${base}.${e}`]);\n const actions: InitAction[] = [\n sourceFile(p.dir, variants('instrumentation'), at(`instrumentation.${ext}`), nextInstrumentation(p.typescript), 'server capture: register() + onRequestError'),\n sourceFile(p.dir, variants('instrumentation-client'), at(`instrumentation-client.${ext}`), nextInstrumentationClient(), 'browser capture: initClient()'),\n ];\n\n if (!p.nextConfig) {\n const content = `${WITH_ARGUS_IMPORT}\\n\\nexport default withArgus({});\\n`;\n actions.push({ type: 'create', file: 'next.config.mjs', summary: 'build id + source map upload: withArgus()', content, preview: content.trimEnd() });\n } else {\n const source = read(p.dir, p.nextConfig) ?? '';\n const wrapped = /\\bwithArgus\\b/.test(source) ? undefined : wrapNextConfig(source);\n if (/\\bwithArgus\\b/.test(source)) actions.push({ type: 'ok', file: p.nextConfig, summary: 'already wrapped with withArgus' });\n else if (wrapped) {\n actions.push({\n type: 'modify',\n file: p.nextConfig,\n summary: 'wrap the exported config with withArgus()',\n content: wrapped.content,\n preview: [`- ${wrapped.removed}`, ...wrapped.added.map((l) => `+ ${l}`)].join('\\n'),\n });\n } else {\n const cjs = /\\bmodule\\.exports\\b/.test(source);\n actions.push({\n type: 'manual',\n file: p.nextConfig,\n summary: 'its export is not a plain identifier, so it was left alone — wrap it yourself',\n preview: cjs\n ? `+ ${WITH_ARGUS_REQUIRE}\\n- module.exports = <your config>;\\n+ module.exports = withArgus(<your config>);`\n : `+ ${WITH_ARGUS_IMPORT}\\n- export default <your config>;\\n+ export default withArgus(<your config>);`,\n });\n }\n }\n\n actions.push(\n envAction(\n p.dir,\n '.env.example',\n [\n ['ARGUS_DSN', '', `Argus (${DSN_FORM}). The browser needs the same value under the NEXT_PUBLIC_ name.`],\n ['NEXT_PUBLIC_ARGUS_DSN', ''],\n ['ARGUS_URL', '', 'Build / CI only: with both set, `next build` uploads source maps. An upload key, never the ingest key.'],\n ['ARGUS_UPLOAD_KEY', ''],\n ],\n 'names only, no values',\n ),\n );\n if (dsn) actions.push(dsnAction(p.dir, '.env.local', [['ARGUS_DSN', dsn], ['NEXT_PUBLIC_ARGUS_DSN', dsn]]));\n\n const missing = ['@getargus/node', '@getargus/browser', '@getargus/build-tools'].filter((d) => !p.deps.has(d));\n const nextSteps: string[] = [];\n if (!dsn) nextSteps.push(`Set ARGUS_DSN and NEXT_PUBLIC_ARGUS_DSN (${DSN_FORM}) in .env.local and in your deployment.`);\n else nextSteps.push('Set ARGUS_DSN and NEXT_PUBLIC_ARGUS_DSN in your deployment too (.env.local is for this machine).');\n nextSteps.push('Set ARGUS_URL and ARGUS_UPLOAD_KEY where `next build` runs (CI): source maps are then uploaded at the end of the build.');\n const v = p.nextVersion;\n if (v && (v[0] < 15 || (v[0] === 15 && v[1] < 3))) nextSteps.push(`Next ${v.join('.')} does not load instrumentation-client (15.3+): import that file from your earliest client entry instead.`);\n if (v && (v[0] < 15 || (v[0] === 15 && v[1] < 4))) nextSteps.push(`Next ${v.join('.')} has no post-compile hook (15.4+): run \\`argus-build upload next --delete-maps\\` after \\`next build\\`.`);\n if (p.router === 'app') nextSteps.push(\"Optional: report render errors from app/error.tsx and app/global-error.tsx with captureNextError (see '@getargus/browser/next').\");\n return { project: p, actions, install: missing.length > 0 ? installCommand(p.packageManager, missing) : undefined, nextSteps };\n}\n\nfunction planNodeProject(p: ProjectInfo, dsn: string | undefined): InitPlan {\n // Follow the entry file when it says which module system is in use; `.js` follows package.json.\n const mainExt = extname(p.main ?? '');\n const ext = p.typescript ? '.ts' : mainExt === '.mjs' || mainExt === '.cjs' ? mainExt : '.js';\n const style: 'esm' | 'cjs' = ext === '.mjs' ? 'esm' : ext === '.cjs' ? 'cjs' : p.typescript || p.esm ? 'esm' : 'cjs';\n const at = (name: string): string => (p.sourceDir ? `${p.sourceDir}/${name}` : name);\n const variants = ['.ts', '.js', '.mjs', '.cjs'].flatMap((e) => [`argus${e}`, `src/argus${e}`]);\n const setup = sourceFile(p.dir, variants, at(`argus${ext}`), nodeSetup(style), 'init() from the environment');\n const actions: InitAction[] = [\n setup,\n envAction(p.dir, '.env.example', [['ARGUS_DSN', '', `Argus (${DSN_FORM})`], ['ARGUS_RELEASE', '', 'Optional: what the dashboard shows as the version, e.g. api@1.2.0']], 'names only, no values'),\n ];\n if (dsn) actions.push(dsnAction(p.dir, '.env', [['ARGUS_DSN', dsn]]));\n\n // TypeScript resolves './argus' except under node16/nodenext, where the emitted name is required.\n const nodeNext = /\"module(?:Resolution)?\"\\s*:\\s*\"node(?:16|next)\"/i.test(read(p.dir, 'tsconfig.json') ?? '');\n const base = setup.file.replace(/^src\\//, '');\n const specifier = p.typescript ? (nodeNext ? './argus.js' : './argus') : `./${base}`;\n const line = style === 'esm' ? `import '${specifier}';` : `require('${specifier}');`;\n const entry = p.main ?? (p.sourceDir ? `${p.sourceDir}/index${ext}` : `index${ext}`);\n const nextSteps = [\n `Make this the first line of your entry file (${entry}; adjust the path if the entry is in another directory):\\n\\n ${line}\\n`,\n dsn\n ? 'Node does not read .env by itself: start with `node --env-file=.env …` or export ARGUS_DSN in the process environment.'\n : `Set ARGUS_DSN (${DSN_FORM}) in the process environment. Without it the SDK is disabled and every call is a no-op.`,\n ];\n const missing = ['@getargus/node'].filter((d) => !p.deps.has(d));\n return { project: p, actions, install: missing.length > 0 ? installCommand(p.packageManager, missing) : undefined, nextSteps };\n}\n\nfunction planMobileProject(p: ProjectInfo): InitPlan {\n const expo = p.kind === 'expo';\n const wanted = expo ? ['@getargus/react-native', '@getargus/expo', '@getargus/build-tools', 'expo-sqlite'] : ['@getargus/react-native', '@getargus/build-tools'];\n const missing = wanted.filter((d) => !p.deps.has(d));\n const metro = expo\n ? \"const { getDefaultConfig } = require('expo/metro-config');\\n const { withArgus } = require('@getargus/build-tools/metro');\\n module.exports = withArgus(getDefaultConfig(__dirname));\"\n : \"const { withArgus } = require('@getargus/build-tools/metro');\\n module.exports = withArgus(<your metro config>);\";\n const nextSteps = [\n ...(expo\n ? [`app.json — add the config plugin (native crash capture; needs a development or release build, not Expo Go):\\n\\n \"plugins\": [[\"@getargus/expo\", { \"release\": \"${p.name ?? 'app'}@1.0.0\" }]]\\n`]\n : ['Native crash capture needs @getargus/expo, an Expo module: add it once the project has expo-modules-core; JS errors work without it.']),\n `metro.config.js — compile the build's artifact set id into the bundle:\\n\\n ${metro}\\n`,\n `Entry file (before anything else of the app is imported):\\n\\n import { init } from '@getargus/react-native';\\n init({ dsn: '${DSN_FORM}', release: '${p.name ?? 'app'}@1.0.0' });\\n`,\n 'Add `.argus/` to .gitignore (generated by the Metro helper).',\n 'After `expo export` / an EAS build, upload the source maps (ARGUS_URL and ARGUS_UPLOAD_KEY in the environment):\\n\\n npx argus-build upload expo-export --ios-set-id \"$ARGUS_ARTIFACT_SET_ID_IOS\" --android-set-id \"$ARGUS_ARTIFACT_SET_ID_ANDROID\"\\n',\n ];\n return { project: p, actions: [], install: missing.length > 0 ? installCommand(p.packageManager, missing) : undefined, nextSteps };\n}\n\nexport interface InitOptions {\n /** Project directory. Default `process.cwd()`. */\n dir?: string;\n /** Written to a git-ignored local env file (`.env.local` for Next, `.env` for Node); never to a tracked file. */\n dsn?: string;\n}\n\n/** Decides what to do. Reads the project, writes nothing. */\nexport function planInit(options: InitOptions = {}): InitPlan {\n if (options.dsn !== undefined && !RE_DSN.test(options.dsn)) throw new Error(`--dsn must look like ${DSN_FORM}`);\n const project = detectProject(options.dir ?? process.cwd());\n if (project.kind === 'next') return planNextProject(project, options.dsn);\n if (project.kind === 'node') return planNodeProject(project, options.dsn);\n // Native config is never edited: an app.json / metro.config change deserves a human eye.\n return planMobileProject(project);\n}\n\n/** Applies the writing actions of a plan. Refuses to replace a file that appeared since planning. */\nexport function applyInit(plan: InitPlan): string[] {\n const written: string[] = [];\n for (const a of plan.actions) {\n if (a.content === undefined || a.type === 'ok' || a.type === 'manual') continue;\n const path = join(plan.project.dir, a.file);\n if (a.type === 'create') {\n mkdirSync(dirname(path), { recursive: true });\n // `wx`: fails instead of overwriting.\n writeFileSync(path, a.content, { flag: 'wx' });\n } else if (a.type === 'append') writeFileSync(path, a.content, { flag: 'a' });\n else writeFileSync(path, a.content);\n written.push(a.file);\n }\n return written;\n}\n\n/* ------------------------------------------------------------------- rendering */\n\nconst KIND_LABEL: Record<ProjectKind, string> = { next: 'Next.js', expo: 'Expo', 'react-native': 'React Native', node: 'Node.js' };\n\nexport function describeProject(p: ProjectInfo): string {\n const parts: string[] = [];\n if (p.kind === 'next') parts.push(`${p.router} router`, p.sourceDir ? 'src/' : 'no src/');\n if (p.kind === 'node') parts.push(p.typescript || p.esm ? 'ESM' : 'CommonJS');\n if (p.kind === 'next' || p.kind === 'node') parts.push(p.typescript ? 'TypeScript' : 'JavaScript');\n parts.push(p.packageManager);\n return `${KIND_LABEL[p.kind]} (${parts.join(', ')})`;\n}\n\nconst indent = (text: string): string =>\n text\n .split('\\n')\n .map((l) => (l ? ` ${l}` : ''))\n .join('\\n');\n\ntype RenderMode = 'applied' | 'dry-run' | 'preview';\nconst isWrite = (a: InitAction): boolean => a.type === 'create' || a.type === 'append' || a.type === 'modify';\n\n/** What was found and every file with exactly what goes into it. */\nfunction renderActions(plan: InitPlan, mode: RenderMode): string {\n const out: string[] = [`Argus init — ${describeProject(plan.project)} in ${plan.project.dir}`, ''];\n const done = mode === 'applied';\n const verb: Record<InitAction['type'], string> = {\n create: done ? 'created ' : 'create ',\n append: done ? 'appended' : 'append ',\n modify: done ? 'modified' : 'modify ',\n ok: 'ok ',\n manual: 'manual ',\n };\n for (const a of plan.actions) {\n out.push(` ${verb[a.type]} ${a.file} — ${a.summary}`);\n if (a.preview) out.push('', indent(a.preview), '');\n }\n return out.join('\\n').replace(/\\n{3,}/g, '\\n\\n').trimEnd();\n}\n\n/** What happened to the files, the install command and the steps left to the user. */\nfunction renderOutcome(plan: InitPlan, mode: RenderMode): string {\n const out: string[] = [];\n const writes = plan.actions.filter(isWrite).length;\n if (plan.actions.length > 0) {\n if (writes === 0) out.push('Nothing to write.');\n else if (mode === 'applied') out.push(`${writes} file(s) written.`);\n else if (mode === 'dry-run') out.push(`Dry run: ${writes} file(s) would be written, nothing was changed.`);\n else out.push(`Nothing was changed: ${writes} file(s) would be written. Run again with --yes to write them.`);\n out.push('');\n }\n if (plan.install) out.push('Install the packages:', '', ` ${plan.install}`, '');\n if (plan.nextSteps.length > 0) {\n out.push(plan.actions.length > 0 ? 'Then:' : 'Steps (nothing is edited automatically for a native app):', '');\n plan.nextSteps.forEach((s, n) => out.push(` ${n + 1}. ${s}`));\n }\n return out.join('\\n').replace(/\\n{3,}/g, '\\n\\n').trimEnd();\n}\n\n/** The full report of a plan. */\nexport function renderInit(plan: InitPlan, mode: RenderMode): string {\n return `${renderActions(plan, mode)}\\n\\n${renderOutcome(plan, mode)}`;\n}\n\nexport interface RunInitOptions extends InitOptions {\n /** Write without asking. */\n yes?: boolean;\n /** Never write. Wins over `yes`. */\n dryRun?: boolean;\n /** Asked once when neither flag is given and there is something to write. Absent: do not ask, do not write. */\n confirm?: (question: string) => Promise<boolean>;\n out?: (text: string) => void;\n}\n\n/** Plan, show, and write when allowed. Returns the plan and the files written. */\nexport async function runInit(options: RunInitOptions = {}): Promise<{ plan: InitPlan; written: string[] }> {\n const out = options.out ?? ((t: string) => void process.stdout.write(`${t}\\n`));\n const plan = planInit(options);\n let apply = !!options.yes && !options.dryRun;\n if (!apply && !options.dryRun && options.confirm && plan.actions.some(isWrite)) {\n // Shown before the question, so the answer is about exactly these files.\n out(renderActions(plan, 'preview'));\n apply = await options.confirm('\\nWrite these files? [y/N] ');\n const written = apply ? applyInit(plan) : [];\n out(`\\n${renderOutcome(plan, apply ? 'applied' : 'preview')}`);\n return { plan, written };\n }\n const written = apply ? applyInit(plan) : [];\n out(renderInit(plan, apply ? 'applied' : options.dryRun ? 'dry-run' : 'preview'));\n return { plan, written };\n}\n","/**\n * Runs upload plans: JavaScript sets go straight to the server over HTTP (no binary needed),\n * sets with native symbols through the Rust CLI (`argus artifacts upload`).\n */\nimport { spawn } from 'node:child_process';\nimport { formatCommand, uploadArgs, type UploadPlan } from './collect';\nimport { isJsOnlyPlan, uploadPlanOverHttp, type HttpFetch } from './http-upload';\n\nexport interface RunResult {\n plan: UploadPlan;\n command: string;\n code: number;\n}\n\nexport interface RunOptions {\n /** The `argus` binary. Default: `$ARGUS_BIN`, else `argus` on PATH. */\n bin?: string;\n /** Pass `--dry-run`: the CLI prints the manifest and uploads nothing. */\n dryRun?: boolean;\n /** Server base URL (`--url`). Default: the CLI's own `ARGUS_URL` handling. */\n url?: string;\n env?: Record<string, string | undefined>;\n cwd?: string;\n /**\n * `http`: upload from Node (JS artifacts only). `cli`: run the `argus` binary. Default `auto`\n * (env `ARGUS_UPLOAD_TRANSPORT`): HTTP for JS-only sets unless `ARGUS_BIN` names a binary,\n * the CLI for sets with native symbols.\n */\n transport?: 'auto' | 'http' | 'cli';\n /** HTTP client for the `http` transport, replaceable in tests. */\n fetch?: HttpFetch;\n /** Process launcher, replaceable in tests. Resolves with the exit code. */\n exec?: (bin: string, args: string[], opts: { env: Record<string, string | undefined>; cwd: string }) => Promise<number>;\n log?: (line: string) => void;\n}\n\nfunction defaultExec(bin: string, args: string[], opts: { env: Record<string, string | undefined>; cwd: string }): Promise<number> {\n return new Promise((resolvePromise, reject) => {\n const child = spawn(bin, args, { stdio: 'inherit', env: opts.env as NodeJS.ProcessEnv, cwd: opts.cwd });\n child.on('error', (e: NodeJS.ErrnoException) => {\n reject(e.code === 'ENOENT' ? new Error(`Argus: cannot run \"${bin}\" — install the argus CLI or set ARGUS_BIN`) : e);\n });\n child.on('close', (code) => resolvePromise(code ?? 1));\n });\n}\n\n/**\n * Uploads the plans one after another and stops at the first failure (a build must not be\n * promoted with a half-uploaded artifact set). Credentials come from the environment\n * (`ARGUS_UPLOAD_KEY`); they are never placed on the command line.\n */\nexport async function runUploads(plans: UploadPlan[], options: RunOptions = {}): Promise<RunResult[]> {\n const env = options.env ?? process.env;\n const cwd = options.cwd ?? process.cwd();\n const bin = options.bin ?? env.ARGUS_BIN ?? 'argus';\n const exec = options.exec ?? defaultExec;\n const log = options.log ?? ((line: string) => console.error(line));\n const requested = options.transport ?? env.ARGUS_UPLOAD_TRANSPORT ?? 'auto';\n if (requested !== 'auto' && requested !== 'http' && requested !== 'cli') throw new Error(`Argus: unknown upload transport \"${requested}\" (auto, http or cli)`);\n const transport: 'auto' | 'http' | 'cli' = requested;\n const results: RunResult[] = [];\n if (!options.dryRun && !env.ARGUS_UPLOAD_KEY) throw new Error('Argus: ARGUS_UPLOAD_KEY is not set (an upload key, never the public ingest key)');\n for (const plan of plans) {\n const argOpts: { dryRun?: boolean; url?: string } = {};\n if (options.dryRun) argOpts.dryRun = true;\n if (options.url) argOpts.url = options.url;\n const args = uploadArgs(plan, argOpts);\n const command = formatCommand(bin, args, cwd);\n for (const w of plan.warnings) log(`[argus] warning: ${w}`);\n log(`[argus] ${plan.label}: ${plan.files.length} file(s) → set ${plan.artifactSetId}`);\n const viaHttp = transport === 'http' || (transport === 'auto' && !options.exec && !env.ARGUS_BIN && isJsOnlyPlan(plan));\n if (viaHttp) {\n const url = options.url ?? env.ARGUS_URL;\n if (!url) throw new Error('Argus: ARGUS_URL is not set (the server base URL, e.g. https://argus.example.com)');\n const http: Parameters<typeof uploadPlanOverHttp>[1] = { url, uploadKey: env.ARGUS_UPLOAD_KEY ?? '', log };\n if (options.dryRun) http.dryRun = true;\n if (options.fetch) http.fetch = options.fetch;\n let code = 0;\n try {\n await uploadPlanOverHttp(plan, http);\n } catch (e) {\n log(`[argus] ${e instanceof Error ? e.message : String(e)}`);\n code = 1;\n }\n results.push({ plan, command: `http upload → ${url}`, code });\n if (code !== 0) break;\n continue;\n }\n const renamedMaps = Object.keys(plan.generatedFor ?? {}).length;\n if (renamedMaps > 0) log(`[argus] warning: ${plan.label}: ${renamedMaps} source map(s) are tied to their chunk only by its sourceMappingURL comment (Turbopack); the argus CLI names them after the map file, so their frames will not resolve — use the http transport`);\n const code = await exec(bin, args, { env, cwd });\n results.push({ plan, command, code });\n if (code !== 0) break;\n }\n return results;\n}\n","/**\n * Uploads a JavaScript artifact set straight to the server (artifacts-v1: manifest → missing\n * blobs → finalize). No `argus` binary needed, so a web / Node / OTA build can upload from any CI\n * image that has Node. Mirrors `argus artifacts upload` for the kinds it supports.\n *\n * Native symbols (dSYM, ELF, R8 mapping) are NOT uploaded here: the CLI validates them locally\n * with the server's own parser and declares their debug ids. Plans that contain them go through\n * the CLI.\n */\nimport { createHash } from 'node:crypto';\nimport { createReadStream, openSync, readSync, closeSync, statSync, readFileSync } from 'node:fs';\nimport { basename, relative, sep } from 'node:path';\nimport { manifestName, type UploadPlan } from './collect';\n\nexport type HttpFetch = (url: string, init: { method: string; headers: Record<string, string>; body?: string | Uint8Array }) => Promise<{\n status: number;\n text(): Promise<string>;\n}>;\n\nexport interface HttpUploadOptions {\n /** Server base URL, e.g. `https://argus.example.com`. */\n url: string;\n /** Upload key (kind `upload`). */\n uploadKey: string;\n dryRun?: boolean;\n fetch?: HttpFetch;\n log?: (line: string) => void;\n}\n\nexport interface ManifestFileEntry {\n kind: 'sourcemap' | 'hermes_sourcemap' | 'js_bundle';\n name: string;\n bundle_name?: string;\n sha256: string;\n size: number;\n}\n\ninterface Found {\n path: string;\n file: ManifestFileEntry;\n}\n\nconst NATIVE_KINDS = new Set(['dsym', 'elf', 'proguard']);\n\n/** True when every file of the plan can be uploaded without the CLI. */\nexport function isJsOnlyPlan(plan: UploadPlan): boolean {\n return plan.files.length > 0 && plan.files.every((f) => !NATIVE_KINDS.has(f.kind));\n}\n\nfunction sha256File(path: string): Promise<string> {\n return new Promise((resolvePromise, reject) => {\n const hash = createHash('sha256');\n createReadStream(path)\n .on('data', (chunk) => hash.update(chunk))\n .on('error', reject)\n .on('end', () => resolvePromise(hash.digest('hex')));\n });\n}\n\n/** Hermes-composed maps carry Metro's function map; that is what makes them \"hermes\" maps. */\nfunction isHermesMap(path: string): boolean {\n const needle = 'x_facebook_sources';\n const head = Buffer.alloc(256 * 1024);\n const fd = openSync(path, 'r');\n let n = 0;\n try {\n n = readSync(fd, head, 0, head.length, 0);\n } finally {\n closeSync(fd);\n }\n if (head.subarray(0, n).includes(needle)) return true;\n return statSync(path).size > n && readFileSync(path).includes(needle);\n}\n\n/** The name of a file inside the set: its path below the strip prefix (the CLI's rule). */\nfunction setName(plan: Pick<UploadPlan, 'stripPrefix'>, file: string): string {\n const prefix = plan.stripPrefix;\n const inside = prefix && (file === prefix || file.startsWith(prefix.endsWith(sep) ? prefix : prefix + sep));\n return (inside ? relative(prefix, file) : file).split(sep).join('/').replace(/^\\/+/, '');\n}\n\n/** Builds the manifest for a JS-only plan. Exported for tests and `--dry-run`. */\nexport async function buildManifest(plan: UploadPlan): Promise<{ manifest: Record<string, unknown>; found: Found[] }> {\n const found: Found[] = [];\n const paths = [...new Set(plan.files.map((f) => f.path))].sort();\n for (const path of paths) {\n const kind = plan.files.find((f) => f.path === path)!.kind;\n if (NATIVE_KINDS.has(kind)) throw new Error(`Argus: ${basename(path)} is a native symbol file; upload it with the argus CLI`);\n const size = statSync(path).size;\n if (size === 0) throw new Error(`Argus: ${path} is empty`);\n const sha256 = await sha256File(path);\n if (kind === 'sourcemap') {\n found.push({\n path,\n file: { kind: isHermesMap(path) ? 'hermes_sourcemap' : 'sourcemap', name: setName(plan, path), bundle_name: manifestName(plan, path), sha256, size },\n });\n } else {\n found.push({ path, file: { kind: 'js_bundle', name: manifestName(plan, path), sha256, size } });\n }\n }\n // The same file reached through two paths must not appear twice under one name.\n found.sort((a, b) => (a.file.name < b.file.name ? -1 : a.file.name > b.file.name ? 1 : 0));\n const unique = found.filter((f, i) => i === 0 || found[i - 1]!.file.name !== f.file.name);\n if (unique.length === 0) throw new Error('Argus: no artifacts found in the given paths');\n\n const manifest: Record<string, unknown> = {\n schema_version: 1,\n artifact_set_id: plan.artifactSetId,\n platform: plan.platform,\n is_embedded: !plan.ota,\n files: unique.map((f) => f.file),\n };\n const set = (key: string, value: string | undefined): void => {\n if (value !== undefined && value !== '') manifest[key] = value;\n };\n set('release', plan.release);\n set('dist', plan.dist);\n set('native_release', plan.nativeRelease);\n set('native_build', plan.nativeBuild);\n set('runtime_version', plan.runtimeVersion);\n set('update_id', plan.updateId);\n set('git_sha', plan.gitSha);\n set('parent_artifact_set_id', plan.parentSetId);\n return { manifest, found: unique };\n}\n\nconst defaultFetch: HttpFetch = async (url, init) => {\n const res = await fetch(url, init as RequestInit);\n return { status: res.status, text: () => res.text() };\n};\n\nasync function call(doFetch: HttpFetch, method: string, url: string, key: string, body?: { json?: unknown; bytes?: Uint8Array }): Promise<Record<string, unknown>> {\n const headers: Record<string, string> = { authorization: `Bearer ${key}` };\n let payload: string | Uint8Array | undefined;\n if (body?.json !== undefined) {\n headers['content-type'] = 'application/json';\n payload = JSON.stringify(body.json);\n } else if (body?.bytes) {\n headers['content-type'] = 'application/octet-stream';\n payload = body.bytes;\n }\n const init: { method: string; headers: Record<string, string>; body?: string | Uint8Array } = { method, headers };\n if (payload !== undefined) init.body = payload;\n let res;\n try {\n res = await doFetch(url, init);\n } catch (e) {\n throw new Error(`Argus: cannot reach ${new URL(url).origin} (${e instanceof Error ? e.message : String(e)})`);\n }\n const text = await res.text();\n let parsed: unknown;\n try {\n parsed = text ? JSON.parse(text) : {};\n } catch {\n parsed = undefined;\n }\n if (res.status < 200 || res.status >= 300) {\n const detail = parsed && typeof parsed === 'object' ? JSON.stringify(parsed) : text.slice(0, 300);\n throw new Error(`Argus: ${method} ${new URL(url).pathname} → HTTP ${res.status} ${detail}`);\n }\n if (!parsed || typeof parsed !== 'object') throw new Error(`Argus: ${method} ${new URL(url).pathname} did not return JSON (is ARGUS_URL the server's base URL?)`);\n return parsed as Record<string, unknown>;\n}\n\n/**\n * Creates the set, uploads the blobs the server does not have yet and finalizes. Idempotent:\n * re-running with identical files uploads nothing. Throws unless the set ends up `ready`.\n */\nexport async function uploadPlanOverHttp(plan: UploadPlan, options: HttpUploadOptions): Promise<{ status: string; uploaded: number; files: number }> {\n const log = options.log ?? ((line: string) => console.error(line));\n const { manifest, found } = await buildManifest(plan);\n if (options.dryRun) {\n log(JSON.stringify(manifest, null, 2));\n return { status: 'dry_run', uploaded: 0, files: found.length };\n }\n const base = options.url.replace(/\\/+$/, '');\n if (!/^https?:\\/\\//i.test(base)) throw new Error('Argus: ARGUS_URL must be the server base URL (https://host)');\n const doFetch = options.fetch ?? defaultFetch;\n const id = encodeURIComponent(plan.artifactSetId);\n\n const created = await call(doFetch, 'POST', `${base}/v1/artifact-sets`, options.uploadKey, { json: manifest });\n const states = Array.isArray(created.files) ? (created.files as { sha256?: string; state?: string }[]) : [];\n const done = new Set<string>();\n let uploaded = 0;\n for (const f of states) {\n if (!f.sha256 || f.state === 'uploaded' || done.has(f.sha256)) continue;\n done.add(f.sha256);\n const local = found.find((x) => x.file.sha256 === f.sha256);\n if (!local) throw new Error(`Argus: server asks for unknown blob ${f.sha256}`);\n log(`[argus] uploading ${local.file.name} (${local.file.size} bytes)`);\n await call(doFetch, 'PUT', `${base}/v1/artifact-sets/${id}/files/${f.sha256}`, options.uploadKey, { bytes: readFileSync(local.path) });\n uploaded++;\n }\n const final = await call(doFetch, 'POST', `${base}/v1/artifact-sets/${id}/finalize`, options.uploadKey);\n const status = typeof final.status === 'string' ? final.status : 'unknown';\n const queued = typeof final.reprocess_queued === 'number' ? final.reprocess_queued : 0;\n log(`[argus] set ${plan.artifactSetId}: ${status}, ${found.length} file(s), ${uploaded} uploaded${queued > 0 ? `, ${queued} waiting event(s) queued for reprocessing` : ''}`);\n if (status !== 'ready') throw new Error(`Argus: artifact set ${plan.artifactSetId} is not ready (${status})`);\n return { status, uploaded, files: found.length };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,IAAAA,kBAAuB;AACvB,IAAAC,oBAAuC;AACvC,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A8C;AAAA,QAClF;AACA,eAAO;AAAA,MACT;AAAA,MACA;AACE,cAAM,IAAI,MAAM,oBAAoB,OAAO,GAAG;AAAA,IAClD;AAAA,EACF,SAAS,GAAG;AACV,QAAI,gBAAgB,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC,EAAE;AAChE,WAAO;AAAA,EACT;AACF;","names":["import_node_fs","import_node_path","import_node_fs","import_node_path","isDir","files","s","import_node_fs","import_node_path","call","s","written","import_node_child_process","import_node_crypto","import_node_fs","import_node_path","code","meta"]}
|
package/dist/cli.d.cts
ADDED
package/dist/cli.d.ts
ADDED