@vvedantb/config 0.12.0 → 0.14.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/CHANGELOG.md CHANGED
@@ -1,11 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#335](https://github.com/vvedantb/packages/pull/335) [`86d63c8`](https://github.com/vvedantb/packages/commit/86d63c83d4a927575fb2a7a812895442de095b22) Thanks [@vvedantb](https://github.com/vvedantb)! - `defineWebVitestConfig` takes `dedupe` (`resolve.dedupe`, as `defineWebViteConfig` does). Pass `dedupe: REACT_DEDUPE` when the tests load a workspace package from source: without it that package can load another copy of React than the app's.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#335](https://github.com/vvedantb/packages/pull/335) [`86d63c8`](https://github.com/vvedantb/packages/commit/86d63c83d4a927575fb2a7a812895442de095b22) Thanks [@vvedantb](https://github.com/vvedantb)! - The `vvedantb-*` bins are now small committed files in `bin/` that import the built CLI from `dist`. pnpm links a bin only when its file exists at install: in a workspace `dist` does not exist yet, so no bin was linked and scripts such as `vvedantb-check-shared-ui` failed. The commands and their behaviour do not change.
12
+
13
+ - [#335](https://github.com/vvedantb/packages/pull/335) [`86d63c8`](https://github.com/vvedantb/packages/commit/86d63c83d4a927575fb2a7a812895442de095b22) Thanks [@vvedantb](https://github.com/vvedantb)! - `vvedantb-doctor` accepts the shared workflow from `vvedantb/workflows`. Before, `ci-reusable-workflow` and `ci-commands` failed for a repo that called `vvedantb/workflows/.github/workflows/ci-app.yml`, because the doctor looked only for the `vvedantb/packages` path. A call to the older path still passes.
14
+
15
+ ## 0.13.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [#333](https://github.com/vvedantb/packages/pull/333) [`659811a`](https://github.com/vvedantb/packages/commit/659811aa48efa54b1a6f3c8f908d1fa78d34d16b) Thanks [@vvedantb](https://github.com/vvedantb)! - `ci-runner` now matches the new Boat runner policy. Check jobs use `boat` (or `boat-small`). `boat-large` is only for Android release builds: the `release-android-apk.yml` and `release-gallery-android.yml` workflows, or a workflow file with `android` in its name. A `boat-large` runner on a `ci-app.yml` job fails. An unknown `boat*` label such as `boat-medium` fails and the message lists the valid labels.
20
+
3
21
  ## 0.12.0
4
22
 
5
23
  ### Minor Changes
6
24
 
7
25
  - [#318](https://github.com/vvedantb/packages/pull/318) [`5f7ce9d`](https://github.com/vvedantb/packages/commit/5f7ce9d342f04bfd979baacc17fd00930f34bb56) Thanks [@vvedantb](https://github.com/vvedantb)! - Speed up the shared Android APK release path.
8
-
26
+
9
27
  - Add `pickAndroidReleaseVersion` and its helpers (`compareSemver`, `highestSemver`, `publishedVersionNames`). The tests own the version rules. The `release-android-apk.yml` version step now lists tags once, takes published versionNames from tag suffixes and downloads `release.json` only for the highest semver tag, instead of every release.
10
28
  - `vvedantb-android-release` builds `arm64-v8a` only (no `x86_64`), sets `org.gradle.workers.max=8` (replacing Expo's lower default) and `org.gradle.parallel=true`. `org.gradle.configuration-cache` stays off: ephemeral CI runners never reuse the cache, so a cold release build only pays the store cost, and native modules can still be incompatible on release tasks.
11
29
  - Add the config flags `syncAppVersion` (write the version to `app.json` and the root `package.json`) and `versionNameFromAppJson` (use `expo.version` when `VERSION_NAME` is unset) so v-store can use the shared bin. Both default to `false`.
@@ -34,7 +52,7 @@
34
52
  ### Minor Changes
35
53
 
36
54
  - [#292](https://github.com/vvedantb/packages/pull/292) [`dfd2849`](https://github.com/vvedantb/packages/commit/dfd2849e95d2f55e2a697767d3de171aaf1fe763) Thanks [@vvedantb](https://github.com/vvedantb)! - Add a shared-worker Vitest preset and a `vvedantb-doctor` CLI.
37
-
55
+
38
56
  - `sharedWorkerVitestConfig` (and `SHARED_WORKER_SETUP`): an opt-in Vitest preset that lets test files share a worker (`isolate: false`), shuffles file order, and resets mocks, env stubs, global stubs and fake timers after each test. Trades per-file isolation for a faster run; adopt it per repo where tests are independent.
39
57
  - `vvedantb-doctor`: a dependency-free CLI that inspects a repo for drift from the shared CI and tooling house rules (ESLint, Prettier, plain `tsc`, missing `tsrs`, missing `oxlint` dep or script, an older `@vvedantb/config` minor, a CI workflow that does not call the shared reusable workflow). It walks workspace packages, supports `--json` and a per-repo waiver file, makes no network requests, and exits non-zero on drift.
40
58
 
@@ -79,7 +97,7 @@
79
97
  ### Minor Changes
80
98
 
81
99
  - [#225](https://github.com/vvedantb/packages/pull/225) [`4eada13`](https://github.com/vvedantb/packages/commit/4eada137e0ff7871dd1003c9b92e92fa29c1b892) Thanks [@vvedantb](https://github.com/vvedantb)! - Add four shared tooling items used across the apps:
82
-
100
+
83
101
  - `withReleaseSigning`: an Expo config plugin that signs the Android `release` build type from a keystore (environment, else `keystore.properties`), failing a release when a value is missing. `expo/config-plugins` is an optional, lazily resolved peer. Marker is configurable and defaults to a value containing `plugins/withReleaseSigning.js` so build-script greps pass.
84
102
  - `singletons` (and `nativeWindConfig`) on `defineExpoMetroConfig`: rewrites `originModulePath` to the app's `package.json` for the given module heads so a single copy resolves. Backward compatible for apps that omit it.
85
103
  - `vvedantb-android-release`: a config-driven Android release build bin that merges the per-app build scripts into one and keeps the reusable-workflow `GITHUB_OUTPUT` interface (`apk`, `release_json`, `version_name`, `version_code`, `sha256`). Runs on Linux CI.
package/README.md CHANGED
@@ -201,8 +201,8 @@ Each check has a stable id:
201
201
  | `oxlint-dep` | No `oxlint` dependency. |
202
202
  | `oxlint-script` | No `lint` script that runs `oxlint`. |
203
203
  | `config-version` | The `@vvedantb/config` range floor is an older minor than the running `vvedantb-doctor` version. |
204
- | `ci-reusable-workflow` | No workflow calls `vvedantb/packages/.github/workflows/ci-app.yml`. |
205
- | `ci-runner` | A workflow has `runs-on: boat` or `runs_on: boat`. Every boat.dev job runs on `boat-large`. GitHub-hosted labels pass. |
204
+ | `ci-reusable-workflow` | No workflow calls `vvedantb/workflows/.github/workflows/ci-app.yml`. A call to the older `vvedantb/packages/.github/workflows/ci-app.yml` also passes. |
205
+ | `ci-runner` | A job uses a runner the Boat policy does not allow. `boat`, `boat-small` and `boat-xlarge` pass, as do GitHub-hosted labels and `${{ ... }}` expressions. `boat-large` is for Android release builds only: it passes as `runs_on` for `release-android-apk.yml` or `release-gallery-android.yml`, or in a workflow file with `android` in its name, and fails on check jobs such as `ci-app.yml`. An unknown `boat*` label such as `boat-medium` fails. |
206
206
  | `ci-commands` | A line in the `commands` input of the shared workflow is not `lint`, `typecheck` or `test` and has no written reason, or a reason names a command that CI does not run. |
207
207
 
208
208
  **CI commands.** The standard commands are `pnpm lint`, `pnpm typecheck` and `pnpm test` (`npm run` or `bun run` also pass, and so does `--filter <package>`). Every other line needs a reason, keyed by the exact command, in `.vvedantb-doctor.json` or under `vvedantbDoctor.ciCommands` in the root `package.json`:
@@ -262,7 +262,7 @@ export default defineConfig({
262
262
 
263
263
  Keys that are not asked for are left out, so `resolve` and `build` appear only when set. `reactPlugins(setup)` and `vendorChunkBuild(tests?)` are exported on their own.
264
264
 
265
- `defineWebVitestConfig` takes `plugins`, `tsconfigPaths`, `alias`, `automaticJsx` (`esbuild: { jsx: "automatic" }`), `include` (default `["src/**/*.test.ts"]`) and `inline` (`test.server.deps.inline`). It always sets `test.environment: "node"`. Pass the result to `defineConfig` from `vitest/config`.
265
+ `defineWebVitestConfig` takes `plugins`, `tsconfigPaths`, `alias`, `automaticJsx` (`esbuild: { jsx: "automatic" }`), `include` (default `["src/**/*.test.ts"]`), `inline` (`test.server.deps.inline`) and `dedupe` (`resolve.dedupe`). Pass `dedupe: REACT_DEDUPE` when the tests load a workspace package from source (`workspace:*` with `inline`): without it that package can load another copy of React than the app's, and hooks fail. It always sets `test.environment: "node"`. Pass the result to `defineConfig` from `vitest/config`.
266
266
 
267
267
  ### Shared-worker Vitest preset (opt-in, faster)
268
268
 
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/android-release-cli.js";
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/check-asar-cli.js";
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/check-no-source-text-cli.js";
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/check-shared-ui-cli.js";
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/clerk-allow-cli.js";
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/cli.js";
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/doctor-cli.js";
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/cli.js CHANGED
File without changes
File without changes
package/dist/doctor.d.ts CHANGED
@@ -62,8 +62,15 @@ export declare function isOlderMinor(range: string, running: string): boolean;
62
62
  export declare function checkConfigVersion(repo: RepoModel, runningVersion: string): CheckResult;
63
63
  export declare function checkCiReusableWorkflow(repo: RepoModel): CheckResult;
64
64
  /**
65
- * Fails on a job that names the small `boat` runner, as `runs-on: boat` or as the `runs_on: boat`
66
- * input of a reusable workflow. GitHub-hosted labels and `boat-large` pass.
65
+ * Checks the Boat runner policy on every `runs-on` line and every `runs_on` input of a reusable
66
+ * workflow.
67
+ *
68
+ * - `boat-small`, `boat` and `boat-xlarge` pass.
69
+ * - GitHub-hosted labels (any label not starting `boat`) and expressions (`${{ ... }}`) pass.
70
+ * - `boat-large` passes as the `runs_on` input of a job that calls `release-android-apk.yml` or
71
+ * `release-gallery-android.yml`, and on any job in a workflow file whose name contains `android`.
72
+ * It fails elsewhere, including on a job that calls the shared `ci-app.yml`.
73
+ * - An unknown `boat*` label (for example `boat-medium`) fails.
67
74
  */
68
75
  export declare function checkCiRunner(repo: RepoModel): CheckResult;
69
76
  /** The lines of every `commands: |` block in the workflows that call the shared ci-app.yml. */
package/dist/doctor.js CHANGED
@@ -303,7 +303,14 @@ export function checkConfigVersion(repo, runningVersion) {
303
303
  }
304
304
  return result("config-version", "@vvedantb/config is current to the running minor", details);
305
305
  }
306
- const CI_WORKFLOW_REF = "vvedantb/packages/.github/workflows/ci-app.yml";
306
+ /** Where the shared ci-app.yml lives. A repo may call either one; the first is the one to use from now on. */
307
+ const CI_WORKFLOW_REFS = [
308
+ "vvedantb/workflows/.github/workflows/ci-app.yml",
309
+ "vvedantb/packages/.github/workflows/ci-app.yml",
310
+ ];
311
+ function callsSharedCi(text) {
312
+ return CI_WORKFLOW_REFS.some((ref) => text.includes(ref));
313
+ }
307
314
  export function checkCiReusableWorkflow(repo) {
308
315
  const dir = join(repo.root, ".github", "workflows");
309
316
  if (!existsSync(dir)) {
@@ -314,14 +321,14 @@ export function checkCiReusableWorkflow(repo) {
314
321
  if (!/\.ya?ml$/.test(name))
315
322
  continue;
316
323
  try {
317
- if (readFileSync(join(dir, name), "utf8").includes(CI_WORKFLOW_REF))
324
+ if (callsSharedCi(readFileSync(join(dir, name), "utf8")))
318
325
  found = true;
319
326
  }
320
327
  catch {
321
328
  // Unreadable workflow file: ignore and keep scanning.
322
329
  }
323
330
  }
324
- const details = found ? [] : [`no workflow calls ${CI_WORKFLOW_REF}`];
331
+ const details = found ? [] : [`no workflow calls ${CI_WORKFLOW_REFS[0]}`];
325
332
  return result("ci-reusable-workflow", "CI calls the shared ci-app.yml workflow", details);
326
333
  }
327
334
  function workflowFiles(root) {
@@ -341,35 +348,99 @@ function workflowFiles(root) {
341
348
  }
342
349
  return files;
343
350
  }
344
- /** The plain `boat` runner label. Every boat.dev job runs on `boat-large` (8 cores, 15 GB). */
345
- const SMALL_RUNNER = "boat";
351
+ const BOAT_LABELS = ["boat-small", "boat", "boat-large", "boat-xlarge"];
352
+ const BOAT_GUIDANCE = "check jobs use boat; boat-large is for Android release builds";
353
+ const ANDROID_RELEASE_WORKFLOW = /(?:^|\/)(?:release-android-apk|release-gallery-android)\.ya?ml(?:@|$)/;
354
+ const CI_APP_WORKFLOW = /(?:^|\/)ci-app\.ya?ml(?:@|$)/;
346
355
  /**
347
- * Fails on a job that names the small `boat` runner, as `runs-on: boat` or as the `runs_on: boat`
348
- * input of a reusable workflow. GitHub-hosted labels and `boat-large` pass.
356
+ * Scans a workflow for runner lines and for each job's own `uses:` value (the reusable workflow
357
+ * it calls). Jobs are the keys one level under `jobs:`. A `uses:` counts only at the job's own
358
+ * level, so a step's `uses: actions/checkout` is ignored.
349
359
  */
350
- export function checkCiRunner(repo) {
351
- const details = [];
352
- for (const file of workflowFiles(repo.root)) {
353
- file.text.split(/\r?\n/).forEach((line, index) => {
354
- const match = line.match(/^\s*(?:-\s+)?(runs[-_]on)\s*:\s*(.+?)\s*(?:#.*)?$/);
355
- if (!match?.[1] || match[2] === undefined)
360
+ function scanRunners(text) {
361
+ const runners = [];
362
+ const jobUses = [];
363
+ let inJobs = false;
364
+ let jobIndent = -1;
365
+ let childIndent = -1;
366
+ let job = -1;
367
+ text.split(/\r?\n/).forEach((line, index) => {
368
+ if (line.trim() === "" || line.trim().startsWith("#"))
369
+ return;
370
+ const indent = line.length - line.trimStart().length;
371
+ if (indent === 0)
372
+ inJobs = /^jobs\s*:/.test(line);
373
+ if (inJobs && indent > 0) {
374
+ if (jobIndent < 0)
375
+ jobIndent = indent;
376
+ if (indent === jobIndent && /^\s*[\w.-]+\s*:/.test(line)) {
377
+ job = jobUses.length;
378
+ jobUses.push(undefined);
379
+ childIndent = -1;
356
380
  return;
357
- const labels = match[2]
381
+ }
382
+ if (job >= 0 && childIndent < 0 && indent > jobIndent)
383
+ childIndent = indent;
384
+ const uses = line.match(/^\s*uses\s*:\s*(.+?)\s*(?:#.*)?$/);
385
+ if (uses?.[1] && job >= 0 && indent === childIndent)
386
+ jobUses[job] = stripQuotes(uses[1]);
387
+ }
388
+ const match = line.match(/^\s*(?:-\s+)?(runs[-_]on)\s*:\s*(.+?)\s*(?:#.*)?$/);
389
+ if (!match?.[1] || match[2] === undefined)
390
+ return;
391
+ const labels = match[2].includes("${{")
392
+ ? [match[2]]
393
+ : match[2]
358
394
  .replace(/^\[|\]$/g, "")
359
395
  .split(",")
360
396
  .map((label) => stripQuotes(label));
361
- if (labels.includes(SMALL_RUNNER)) {
362
- details.push(`.github/workflows/${file.name}:${index + 1} ${match[1]} is ${SMALL_RUNNER}; use boat-large`);
397
+ runners.push({ line: index + 1, key: match[1], labels, job: inJobs ? job : -1 });
398
+ });
399
+ return { runners, jobUses };
400
+ }
401
+ /**
402
+ * Checks the Boat runner policy on every `runs-on` line and every `runs_on` input of a reusable
403
+ * workflow.
404
+ *
405
+ * - `boat-small`, `boat` and `boat-xlarge` pass.
406
+ * - GitHub-hosted labels (any label not starting `boat`) and expressions (`${{ ... }}`) pass.
407
+ * - `boat-large` passes as the `runs_on` input of a job that calls `release-android-apk.yml` or
408
+ * `release-gallery-android.yml`, and on any job in a workflow file whose name contains `android`.
409
+ * It fails elsewhere, including on a job that calls the shared `ci-app.yml`.
410
+ * - An unknown `boat*` label (for example `boat-medium`) fails.
411
+ */
412
+ export function checkCiRunner(repo) {
413
+ const details = [];
414
+ for (const file of workflowFiles(repo.root)) {
415
+ const { runners, jobUses } = scanRunners(file.text);
416
+ const androidFile = /android/i.test(file.name);
417
+ for (const runner of runners) {
418
+ const uses = runner.job >= 0 ? jobUses[runner.job] : undefined;
419
+ const where = `.github/workflows/${file.name}:${runner.line} ${runner.key}`;
420
+ for (const label of runner.labels) {
421
+ if (label.includes("${{") || !label.startsWith("boat"))
422
+ continue;
423
+ if (label === "boat-large") {
424
+ if (androidFile)
425
+ continue;
426
+ if (runner.key === "runs_on" && uses !== undefined && ANDROID_RELEASE_WORKFLOW.test(uses))
427
+ continue;
428
+ const caller = uses !== undefined && CI_APP_WORKFLOW.test(uses) ? " on a ci-app.yml job" : "";
429
+ details.push(`${where} is boat-large${caller}; ${BOAT_GUIDANCE}`);
430
+ }
431
+ else if (!BOAT_LABELS.includes(label)) {
432
+ details.push(`${where} is ${label}, an unknown boat label; valid labels are ${BOAT_LABELS.join(", ")}`);
433
+ }
363
434
  }
364
- });
435
+ }
365
436
  }
366
- return result("ci-runner", "No job runs on the small boat runner", details);
437
+ return result("ci-runner", "Jobs use valid Boat runners and boat-large only for Android release builds", details);
367
438
  }
368
439
  /** The lines of every `commands: |` block in the workflows that call the shared ci-app.yml. */
369
440
  export function ciCommands(repo) {
370
441
  const found = [];
371
442
  for (const file of workflowFiles(repo.root)) {
372
- if (!file.text.includes(CI_WORKFLOW_REF))
443
+ if (!callsSharedCi(file.text))
373
444
  continue;
374
445
  let blockIndent = -1;
375
446
  for (const line of file.text.split(/\r?\n/)) {
package/dist/vite.d.ts CHANGED
@@ -101,6 +101,12 @@ export interface WebVitestOptions extends PathOptions {
101
101
  include?: string[];
102
102
  /** Packages Vitest transforms instead of loading from node_modules (`test.server.deps.inline`). */
103
103
  inline?: string[];
104
+ /**
105
+ * `resolve.dedupe`, as given. See `REACT_DEDUPE`. Set it when the tests load a
106
+ * workspace package from source: without it that package can load another copy
107
+ * of React than the app's.
108
+ */
109
+ dedupe?: readonly string[];
104
110
  }
105
111
  export interface WebVitestConfig {
106
112
  plugins?: VitePluginOption[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/config",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "license": "MIT",
5
5
  "description": "Shared tsconfig bases, oxlint base, Vite, Vitest, Babel and Metro presets, a WXT preset and host-permission helper for Chrome extensions, pinned tool versions, a sync CLI for Claude commands, CLAUDE.md, Cursor environment and Convex tsconfig, a packaged Electron app.asar module check, a shared header and footer check, a no-source-text-in-tests check, shared oxlint JS plugins and a CLI that adds an extension to Clerk's allowed origins.",
6
6
  "type": "module",
@@ -14,13 +14,13 @@
14
14
  "directory": "packages/config"
15
15
  },
16
16
  "bin": {
17
- "vvedantb-config": "./dist/cli.js",
18
- "vvedantb-check-asar": "./dist/check-asar-cli.js",
19
- "vvedantb-clerk-allow": "./dist/clerk-allow-cli.js",
20
- "vvedantb-android-release": "./dist/android-release-cli.js",
21
- "vvedantb-check-shared-ui": "./dist/check-shared-ui-cli.js",
22
- "vvedantb-check-no-source-text": "./dist/check-no-source-text-cli.js",
23
- "vvedantb-doctor": "./dist/doctor-cli.js"
17
+ "vvedantb-config": "./bin/vvedantb-config.js",
18
+ "vvedantb-check-asar": "./bin/vvedantb-check-asar.js",
19
+ "vvedantb-clerk-allow": "./bin/vvedantb-clerk-allow.js",
20
+ "vvedantb-android-release": "./bin/vvedantb-android-release.js",
21
+ "vvedantb-check-shared-ui": "./bin/vvedantb-check-shared-ui.js",
22
+ "vvedantb-check-no-source-text": "./bin/vvedantb-check-no-source-text.js",
23
+ "vvedantb-doctor": "./bin/vvedantb-doctor.js"
24
24
  },
25
25
  "exports": {
26
26
  ".": {
@@ -46,6 +46,7 @@
46
46
  },
47
47
  "types": "./dist/index.d.ts",
48
48
  "files": [
49
+ "bin",
49
50
  "dist",
50
51
  "files",
51
52
  "tsconfig",
@@ -76,8 +77,9 @@
76
77
  "esbuild": "0.28.2",
77
78
  "eslint-plugin-react-you-might-not-need-an-effect": "1.0.2",
78
79
  "@vitejs/plugin-react": "^6.1.2",
80
+ "happy-dom": "18.0.1",
79
81
  "oxlint": "^1.80.0",
80
- "typescript": "^5.9.0",
82
+ "typescript": "7.0.2",
81
83
  "vite": "^8.3.4",
82
84
  "vitest": "^3.2.0"
83
85
  },