@autter/runtime-cli 1.0.0 → 1.1.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/README.md CHANGED
@@ -22,7 +22,7 @@ npm install -D @autter/runtime-cli
22
22
  ```
23
23
 
24
24
  Set `AUTTER_RUNTIME_KEY` to a **server** ingest key (`autter_rt_…`) where your
25
- build runs. Without it, debug ids are injected and nothing is uploaded.
25
+ build runs. Without it, the plugins turn no source maps on and change nothing.
26
26
 
27
27
  ## Vite / Rollup
28
28
 
@@ -50,8 +50,10 @@ export default withAutterSourceMaps({ reactStrictMode: true });
50
50
  ```
51
51
 
52
52
  All three turn on hidden source maps when you haven't configured maps, inject
53
- debug ids after the build, upload when a key is present, and delete the maps
54
- they created once uploaded. Options (all optional): `release`, `urlPrefix`,
53
+ debug ids after the build, upload when a key is present, and then delete the
54
+ maps they created whether or not the upload succeeded (a rejected upload, an
55
+ unreachable ingester, a dry run), printing one line that says why; without a
56
+ key they turn none on. Maps you configured yourself are left alone. Options (all optional): `release`, `urlPrefix`,
55
57
  `endpoint`, `key`, `upload: false`, `deleteAfterUpload`, `dryRun`,
56
58
  `concurrency`, `failOnError` (default `false`: a failed upload is logged and
57
59
  never fails the build), `silent`.
@@ -74,10 +76,14 @@ autter-runtime sourcemaps upload <dir> [--release <r>] [--url-prefix <prefix>]
74
76
  `globalThis._autterDebugIds[new Error().stack] = "<id>"`, and `"debugId"` in
75
77
  the `.map`, for each `.js`/`.mjs`/`.cjs` with a map. The id is derived from
76
78
  sha256 of the bundle bytes; running it again changes nothing.
77
- - **upload** posts each map (without `sourcesContent`) to
78
- `<endpoint>/v1/sourcemaps`, in parallel, skipping maps the ingester already
79
- has. Release: `--release`, else `GITHUB_SHA`, `VERCEL_GIT_COMMIT_SHA`,
80
- `CF_PAGES_COMMIT_SHA`, `GIT_SHA`, then `git rev-parse HEAD`.
79
+ - **upload** posts each map (without `sourcesContent`, gzipped, up to 32 MB)
80
+ to `<endpoint>/v1/sourcemaps`, in parallel, skipping maps the ingester
81
+ already has. Each map carries the bundle's function scopes (`x_autter_scopes`),
82
+ parsed from the file as served, so frames are named after the function they
83
+ are in rather than their call site; a bundle that does not parse is uploaded
84
+ without them, with a warning. Release: `--release`, else `GITHUB_SHA`,
85
+ `VERCEL_GIT_COMMIT_SHA`, `CF_PAGES_COMMIT_SHA`, `GIT_SHA`, then
86
+ `git rev-parse HEAD`.
81
87
 
82
88
  Exit codes: `0` ok, `1` some maps failed, `2` no key / no release / key
83
89
  rejected, `64` usage error.
@@ -69,7 +69,11 @@ declare function injectBundle(bundle: BundleWithMap, options?: InjectOptions): P
69
69
  declare function injectDir(dir: string, options?: InjectOptions): Promise<InjectResult[]>;
70
70
 
71
71
  declare const DEFAULT_ENDPOINT = "https://otlp.autter.dev";
72
- /** The ingester's `/v1/sourcemaps` body limit. */
72
+ /** Largest map the ingester stores: characters of JSON without
73
+ * `sourcesContent` (otlp-ingester's SOURCE_MAP_MAX_CHARS). */
74
+ declare const MAX_MAP_CHARS: number;
75
+ /** The ingester's `/v1/sourcemaps` body limit, counted after the gzip body
76
+ * is inflated: the map plus room for the rest of the request. */
73
77
  declare const MAX_UPLOAD_BYTES: number;
74
78
  interface UploadOptions {
75
79
  /** Only these bundles (absolute, or relative to the directory). */
@@ -145,13 +149,17 @@ interface AutterSourceMapsOptions {
145
149
  /** Ingester base URL. Default: $AUTTER_ENDPOINT, $AUTTER_RUNTIME_ENDPOINT,
146
150
  * $OTEL_EXPORTER_OTLP_ENDPOINT, else https://otlp.autter.dev. */
147
151
  endpoint?: string;
148
- /** Server ingest key. Default: $AUTTER_RUNTIME_KEY. Without one, debug ids
149
- * are still injected but nothing is uploaded. */
152
+ /** Server ingest key. Default: $AUTTER_RUNTIME_KEY. Without one (and
153
+ * without `upload: false` or `dryRun`), the plugin generates no source
154
+ * maps it would have to delete again: the build is left as it was. */
150
155
  key?: string;
151
- /** Set false to inject debug ids only (upload later with the CLI). */
156
+ /** Set false to inject debug ids only (upload later with the CLI). Maps
157
+ * the plugin generated are then kept for that upload: don't deploy them. */
152
158
  upload?: boolean;
153
- /** Delete `.map` files once uploaded so they are never deployed. Default:
154
- * true when the plugin turned source maps on itself, false when you had. */
159
+ /** Maps the plugin generated itself are always deleted after the upload
160
+ * step, uploaded or not, so they are never deployed; set false to keep
161
+ * them (you must then keep them out of the deploy). Maps you configured
162
+ * yourself are deleted only when this is true, and only once uploaded. */
155
163
  deleteAfterUpload?: boolean;
156
164
  /** Log what would be uploaded without sending anything. */
157
165
  dryRun?: boolean;
@@ -166,13 +174,19 @@ interface AutterSourceMapsOptions {
166
174
  interface BuildOutputResult {
167
175
  injected: InjectResult[];
168
176
  upload: UploadSummary | null;
177
+ /** Maps the plugin generated and deleted (paths relative to the directory). */
178
+ removedMaps: string[];
169
179
  }
170
180
  /** Human-readable lines for an upload summary (CLI and plugins). */
171
181
  declare function formatUploadSummary(summary: UploadSummary): string[];
172
182
  /**
173
183
  * What every bundler integration does after a build: inject debug ids into
174
184
  * the emitted bundles, then upload their maps when a key is present.
175
- * Failures are logged, and thrown only with `failOnError`.
185
+ * Failures are logged, and thrown only with `failOnError`. When the
186
+ * integration turned source maps on itself (`ownMaps`), every map it made
187
+ * is deleted afterwards whatever happened to the upload (no key, a failed
188
+ * or partial upload, an unreachable ingester, a dry run), with the
189
+ * sourceMappingURL comments that name them, so none is deployed.
176
190
  */
177
191
  declare function processBuildOutput(input: {
178
192
  dir: string;
@@ -182,6 +196,11 @@ declare function processBuildOutput(input: {
182
196
  /** Default for `deleteAfterUpload` (true when the plugin enabled maps). */
183
197
  deleteAfterUpload: boolean;
184
198
  stripSourceMappingUrl?: boolean;
199
+ /** The integration turned source maps on itself: none may be deployed. */
200
+ ownMaps?: boolean;
201
+ /** Map files the build emitted (absolute), when the bundler lists them;
202
+ * the maps of `files` (or of every bundle under `dir`) are added. */
203
+ maps?: string[];
185
204
  }): Promise<BuildOutputResult>;
186
205
 
187
- export { type AutterSourceMapsOptions as A, BUNDLE_RE as B, DEFAULT_ENDPOINT as D, FatalUploadError as F, type InjectOptions as I, MAX_UPLOAD_BYTES as M, SNIPPET_LINE_KEY as S, type UploadItem as U, type BuildOutputResult as a, type BundleWithMap as b, type InjectResult as c, type UploadOptions as d, type UploadSummary as e, findBundles as f, formatUploadSummary as g, injectDir as h, injectBundle as i, resolveEndpoint as j, shiftMappings as k, snippetLine as l, mapPathFor as m, storedMapJson as n, stripSourceMappingUrl as o, processBuildOutput as p, readSourceMappingUrl as r, servedFilename as s, uploadDir as u };
206
+ export { type AutterSourceMapsOptions as A, BUNDLE_RE as B, DEFAULT_ENDPOINT as D, FatalUploadError as F, type InjectOptions as I, MAX_MAP_CHARS as M, SNIPPET_LINE_KEY as S, type UploadItem as U, type BuildOutputResult as a, type BundleWithMap as b, type InjectResult as c, MAX_UPLOAD_BYTES as d, type UploadOptions as e, type UploadSummary as f, findBundles as g, formatUploadSummary as h, injectBundle as i, injectDir as j, resolveEndpoint as k, shiftMappings as l, mapPathFor as m, snippetLine as n, storedMapJson as o, processBuildOutput as p, stripSourceMappingUrl as q, readSourceMappingUrl as r, servedFilename as s, uploadDir as u };
@@ -69,7 +69,11 @@ declare function injectBundle(bundle: BundleWithMap, options?: InjectOptions): P
69
69
  declare function injectDir(dir: string, options?: InjectOptions): Promise<InjectResult[]>;
70
70
 
71
71
  declare const DEFAULT_ENDPOINT = "https://otlp.autter.dev";
72
- /** The ingester's `/v1/sourcemaps` body limit. */
72
+ /** Largest map the ingester stores: characters of JSON without
73
+ * `sourcesContent` (otlp-ingester's SOURCE_MAP_MAX_CHARS). */
74
+ declare const MAX_MAP_CHARS: number;
75
+ /** The ingester's `/v1/sourcemaps` body limit, counted after the gzip body
76
+ * is inflated: the map plus room for the rest of the request. */
73
77
  declare const MAX_UPLOAD_BYTES: number;
74
78
  interface UploadOptions {
75
79
  /** Only these bundles (absolute, or relative to the directory). */
@@ -145,13 +149,17 @@ interface AutterSourceMapsOptions {
145
149
  /** Ingester base URL. Default: $AUTTER_ENDPOINT, $AUTTER_RUNTIME_ENDPOINT,
146
150
  * $OTEL_EXPORTER_OTLP_ENDPOINT, else https://otlp.autter.dev. */
147
151
  endpoint?: string;
148
- /** Server ingest key. Default: $AUTTER_RUNTIME_KEY. Without one, debug ids
149
- * are still injected but nothing is uploaded. */
152
+ /** Server ingest key. Default: $AUTTER_RUNTIME_KEY. Without one (and
153
+ * without `upload: false` or `dryRun`), the plugin generates no source
154
+ * maps it would have to delete again: the build is left as it was. */
150
155
  key?: string;
151
- /** Set false to inject debug ids only (upload later with the CLI). */
156
+ /** Set false to inject debug ids only (upload later with the CLI). Maps
157
+ * the plugin generated are then kept for that upload: don't deploy them. */
152
158
  upload?: boolean;
153
- /** Delete `.map` files once uploaded so they are never deployed. Default:
154
- * true when the plugin turned source maps on itself, false when you had. */
159
+ /** Maps the plugin generated itself are always deleted after the upload
160
+ * step, uploaded or not, so they are never deployed; set false to keep
161
+ * them (you must then keep them out of the deploy). Maps you configured
162
+ * yourself are deleted only when this is true, and only once uploaded. */
155
163
  deleteAfterUpload?: boolean;
156
164
  /** Log what would be uploaded without sending anything. */
157
165
  dryRun?: boolean;
@@ -166,13 +174,19 @@ interface AutterSourceMapsOptions {
166
174
  interface BuildOutputResult {
167
175
  injected: InjectResult[];
168
176
  upload: UploadSummary | null;
177
+ /** Maps the plugin generated and deleted (paths relative to the directory). */
178
+ removedMaps: string[];
169
179
  }
170
180
  /** Human-readable lines for an upload summary (CLI and plugins). */
171
181
  declare function formatUploadSummary(summary: UploadSummary): string[];
172
182
  /**
173
183
  * What every bundler integration does after a build: inject debug ids into
174
184
  * the emitted bundles, then upload their maps when a key is present.
175
- * Failures are logged, and thrown only with `failOnError`.
185
+ * Failures are logged, and thrown only with `failOnError`. When the
186
+ * integration turned source maps on itself (`ownMaps`), every map it made
187
+ * is deleted afterwards whatever happened to the upload (no key, a failed
188
+ * or partial upload, an unreachable ingester, a dry run), with the
189
+ * sourceMappingURL comments that name them, so none is deployed.
176
190
  */
177
191
  declare function processBuildOutput(input: {
178
192
  dir: string;
@@ -182,6 +196,11 @@ declare function processBuildOutput(input: {
182
196
  /** Default for `deleteAfterUpload` (true when the plugin enabled maps). */
183
197
  deleteAfterUpload: boolean;
184
198
  stripSourceMappingUrl?: boolean;
199
+ /** The integration turned source maps on itself: none may be deployed. */
200
+ ownMaps?: boolean;
201
+ /** Map files the build emitted (absolute), when the bundler lists them;
202
+ * the maps of `files` (or of every bundle under `dir`) are added. */
203
+ maps?: string[];
185
204
  }): Promise<BuildOutputResult>;
186
205
 
187
- export { type AutterSourceMapsOptions as A, BUNDLE_RE as B, DEFAULT_ENDPOINT as D, FatalUploadError as F, type InjectOptions as I, MAX_UPLOAD_BYTES as M, SNIPPET_LINE_KEY as S, type UploadItem as U, type BuildOutputResult as a, type BundleWithMap as b, type InjectResult as c, type UploadOptions as d, type UploadSummary as e, findBundles as f, formatUploadSummary as g, injectDir as h, injectBundle as i, resolveEndpoint as j, shiftMappings as k, snippetLine as l, mapPathFor as m, storedMapJson as n, stripSourceMappingUrl as o, processBuildOutput as p, readSourceMappingUrl as r, servedFilename as s, uploadDir as u };
206
+ export { type AutterSourceMapsOptions as A, BUNDLE_RE as B, DEFAULT_ENDPOINT as D, FatalUploadError as F, type InjectOptions as I, MAX_MAP_CHARS as M, SNIPPET_LINE_KEY as S, type UploadItem as U, type BuildOutputResult as a, type BundleWithMap as b, type InjectResult as c, MAX_UPLOAD_BYTES as d, type UploadOptions as e, type UploadSummary as f, findBundles as g, formatUploadSummary as h, injectBundle as i, injectDir as j, resolveEndpoint as k, shiftMappings as l, mapPathFor as m, snippetLine as n, storedMapJson as o, processBuildOutput as p, stripSourceMappingUrl as q, readSourceMappingUrl as r, servedFilename as s, uploadDir as u };