Files
accounted/scripts/generate-crontabs.ts
Jakob Wennberg 50f13cf198 feat(connect): self-host connector enablement: EB/SKV in the preset, connector-mode seam, status endpoint (#1758)
* feat(entitlements): partition the self-host bypass so connector capabilities fall through to grants; capability_grants.source accepts 'connector'

Sovereign plan WS3 PR3: ships dark, nothing changes for hosted.

- lib/entitlements/keys.ts: CONNECTOR_CAPABILITIES = bank_sync,
  skatteverket, org_lookup, migration (services Accounted operates that a
  self-hosted instance cannot provide itself) + isConnectorCapability().
  Separate from PAID_CAPABILITIES and outside the trial-seed trigger on
  purpose: a hosted company can never hold a connector grant.
- lib/entitlements/has-capability.ts: isPaywallBypassed() -> isBypassedFor(key).
  Hosted: byte-identical (dev / DISABLE_PAYWALL bypass, FORCE_PAYWALL wins,
  else the grant lookup). Self-host: local capabilities always on
  (FORCE_PAYWALL included, as the existing test demands); connector
  capabilities behave like hosted, i.e. dev bypass, FORCE_PAYWALL, else the
  grant lookup where the connector sync will write source='connector' rows.
  getCompanyEntitlements on a self-host: local paid keys + active connector
  keys, state 'paid' with an active connector grant else 'none' (never the
  hosted trial copy).
- Migration 20260820122000: capability_grants.source CHECK gains
  'connector', found through pg_constraint (the CHECK was declared inline
  and auto-named; Postgres stores IN as = ANY, matched accordingly).
  pg-real test: connector accepted, unknown source rejected, upsert on the
  (scope, key, source) identity, trial seed writes no connector rows.
- Tests: self-hosted connector matrix (local all-on without DB, connector
  gated by grant/expiry, dev bypass all-on, FORCE_PAYWALL gates connector
  keys only, bulk resolution, entitlements shape); two pre-existing tests
  that asserted the old "self-host holds connector keys" contract updated
  to the new one.

Verified: full unit suite green, pg-real suite for lib/entitlements green
against a local supabase/postgres with every migration applied, lint
ratchet, guards. Deferred to the instance-wiring PR: adding the connector
extensions to the self-host Docker preset (dead-end upsells until a key can
be issued).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(entitlements): fold the self-host branch into the existing grants query

One .or(scopeFilter), not two: the duplicated helper pushed the
no-phantom-columns unresolvable-expression count to 380/379. Behaviour is
unchanged; the self-host matrix tests still pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(connect): hosted connector-key registry + validate RPC + entitlements endpoint; instance sync writes connector grants hourly

Sovereign plan WS3 PR4 ("key infra enabling manual sales"), stacked on the
entitlement partition (#1747). Nothing is purchasable yet; this is the
plumbing both ends need before the first manually issued key.

Hosted side:
- Migration 20260820123000: connector_keys (SHA-256 key_hash, prefix,
  org_number, pinned instance_url, scopes, status, Stripe ids,
  current_period_end, per-minute rate limit, active_company_count,
  last_seen/synced) and connector_usage_events (per-request metering,
  separate from metered_events whose company_id references hosted
  companies). RLS on, NO policies: service role only. RPC
  validate_and_increment_connector_key copies the api_keys pattern (FOR
  UPDATE, minute window, suspended reported not counted, revoked = no row)
  and is REVOKEd from PUBLIC/anon/authenticated, GRANTed to service_role.
  pg-real test covers validate/count, unknown+revoked, suspended, rate
  limit, execute privileges per role, RLS invisibility, usage cascade.
- lib/connect/contract.ts (shared wire types), lib/connect/hosted/keys.ts
  (generate/hash/validate -> 401/403/429 mapping),
  with-connector-auth.ts (Bearer or X-Connector-Key, one usage row per
  request, 500 envelope on handler throw), /api/connect/entitlements GET +
  POST (records active_company_count, pins instance_url on first report,
  never moves a pinned one), scripts/issue-connector-key.ts (dry run unless
  --confirm, prints the key once + the .env lines).

Instance side:
- lib/connect/instance/config.ts (GNUBOK_CONNECTOR_KEY, GNUBOK_CONNECT_URL
  default https://app.gnubok.se), sync.ts: reports the active company count
  and writes source='connector' grants for every company x covered scope,
  expires_at = min(now+72h, period_end+3d); 401/403 or a non-active status
  deletes them (freeze-and-retain); network/5xx/429 leave them alone.
  /api/connector/sync/cron (hourly) runs it; not_configured without a key.
- Crontab generator gains EXTRA_JOBS (variant-only jobs not in vercel.json,
  with reasons) + drift tests; docker/crontab.self-hosted regenerated with
  the hourly sync. Docs (SELF-HOSTING connector section, env templates),
  DECISIONS.

Tests: 52 new unit tests (keys, auth wrapper, route, config, sync outcomes
and grant arithmetic, cron route, crontab EXTRA_JOBS) + 7 pg-real tests
run locally against supabase/postgres with every migration applied.
no-phantom-columns ceiling +1 with a reason (the bulk grant upsert).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(connect): Enable Banking proxy for self-hosted instances, with a secret-free ownership ledger and a global rate budget

Sovereign plan WS3 PR5a, stacked on the connector-key infra (#1748). A
self-hosted instance with a `bank_sync`-scoped connector key can now connect
a bank through Arcim's PSD2 credentials; the bank session id and all
transaction data stay in the instance's own database (founder decision:
tokens on the instance, proxy stateless).

- Migration 20260820124000: `connector_connections` (secret-free ledger:
  sha256 of the EB session id + account uids, service-role only),
  `connector_upstream_counters` + RPC `connector_reserve_upstream` (global
  budget under EB Annex 1 §5's 300/min, shared with hosted), and
  `connector_keys.limits` jsonb; validate RPC v2 returns limits. All RPCs
  REVOKEd from PUBLIC/anon/authenticated, GRANTed service_role. pg-real
  covers all of it.
- EB JWT minting moved to lib/connect/upstreams/enable-banking-jwt.ts (core
  must not import @/extensions/); the extension re-exports it, tests
  unchanged.
- lib/connect/hosted/{state,ledger,upstream-budget}.ts: HMAC-signed
  connector state (15-min TTL) so the consent redirect can use OUR
  registered EB callback and bounce back to the instance, no per-instance
  redirect URI at EB; the callback route gains that connector branch.
- app/api/connect/bank/[...path]: path allowlist (aspsps, auth, sessions,
  accounts/{uid}/{balances,transactions}), never open passthrough. POST
  /auth enforces the per-company connection quota + rewrites redirect/state;
  reads/deletes verify ledger ownership; every upstream call takes the
  global budget (429 + Retry-After when exhausted).
- issue-connector-key.ts: scopes default bank_sync,skatteverket (TIC out of
  v1), --bank/skv-connections-per-company + --sync-min-interval.
- Docs (SELF-HOSTING: bank connector live), DECISIONS.

Verified: 52 connect unit tests + 13 pg-real (run locally against
supabase/postgres with all migrations) + EB extension suite (225, jwt
relocation intact); full unit suite 15 979 green; tsc, guards, lint clean.
Not in this PR: SKV broker (PR5b) and instance wiring (PR6).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(connect): Skatteverket broker + data proxy for self-hosted instances (tokens stay on the instance)

Sovereign plan WS3 PR5b, stacked on the bank proxy (#1751). A self-hosted
instance with a `skatteverket`-scoped connector key can now run the BankID
consent, file VAT/AGI and sync skattekonto through Arcim's registered
Skatteverket client; the SKV tokens are returned to the instance and stored
(encrypted) there.

- lib/connect/upstreams/skatteverket-oauth.ts: core-side SKV OAuth + data
  helpers (authorize URL, code/refresh exchange with Arcim's client secret,
  the four backing-API base URLs, the API-gateway Client_Id/Client_Secret
  headers). Core can't import @/extensions/, so this duplicates the
  extension's endpoints/scope set (one integrator = Arcim), mirroring the EB
  JWT relocation.
- app/api/connect/skv/oauth/authorize-url: builds the authorize URL against
  OUR registered redirect_uri + a signed connector state, per-company SKV
  connection quota, pending ledger row.
- app/api/connect/skv/oauth/token: exchanges/refreshes and RETURNS the tokens
  to the instance; the ledger keeps only sha256(access_token) +
  sha256(refresh_token).
- app/api/connect/skv/api/[...path]: allowlist over moms / skattekonto /
  agd-inlamning / agd-period. The instance sends the user's SKV Bearer (as
  X-Connector-Upstream-Authorization) + X-Connector-Key; the proxy checks the
  token hash against the ledger, adds Arcim's gateway credentials (never
  exposed to the instance), forwards. Same per-key + global budget as bank.
- The Skatteverket extension /callback gains the connector branch
  (isConnectorState -> 302 back to the instance; code never exchanged there).
- Docs (SELF-HOSTING: SKV connector live) + DECISIONS.

Tests: SKV oauth lib, authorize-url, token, data proxy, callback connector
branch (all green; 74 connect + 425 connect/SKV). tsc, guards, lint clean;
no-phantom-columns held at 380 (literal update branches). Not in this PR:
instance-side wiring (PR6).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(connect): self-host connector enablement: EB/SKV in the preset, connector-mode seam, status endpoint

Sovereign plan WS3 PR6 (enablement layer), stacked on the SKV broker (#1757).

- docker/extensions.self-hosted.json += enable-banking, skatteverket: a
  connector-key self-host now ships the bank + Skatteverket extensions; a key
  with the matching scope makes them work, without one they show the existing
  capability_blocked upsell (unconfigured extensions no-op).
- lib/connect/instance/upstreams.ts: the connector-mode seam. An upstream is
  in connector mode only when GNUBOK_CONNECTOR_KEY is set AND the instance has
  no own credentials for it (hasOwnEnableBankingCredentials /
  hasOwnSkatteverketCredentials). Hosted always has own credentials, so hosted
  is provably never in connector mode: the guard is what keeps hosted
  byte-identical. Base URLs GNUBOK_CONNECT_URL/api/connect/{bank,skv}, headers
  X-Connector-Company / X-Connector-Upstream-Authorization.
- GET /api/connector/status: the operator's wiring view (self_hosted, per
  upstream own_credentials|connector|unconfigured, key prefix never the key,
  granted connector capabilities). Hosted returns self_hosted:false.
- Docs (SELF-HOSTING: status endpoint + extensions ship in the image),
  DECISIONS.

Tests: connector-mode detection matrix (off without a key, off with own
creds incl. the _PRODUCTION EB variants, on via the proxy, CONNECT_URL
override) + status route (self-host vs hosted, unconfigured, per-upstream
mode, prefix-not-key). 83 connect/connector tests green; tsc, guards, lint.

DEFERRED to PR6b (needs a live connector key + a real bank/SKV to verify
end to end, touches the live consent path): wiring the EB api-client /
consent callback and the SKV oauth / api-client to call the proxy in
connector mode, and the "Synka nu" settings row (UI, needs visual sign-off).
The seam + preset + status route make PR6b a contained follow-up.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(connect): upstreams seam reuses lib/entitlements/own-credentials

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UzNkSsR18pLFitJdYn8QEb

* test(connector): status route tests pass the Next params argument (post-merge withRouteContext signature)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UzNkSsR18pLFitJdYn8QEb

* docs(self-host): collapse the re-duplicated connector section; correct the crontab generator's preset comment

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UzNkSsR18pLFitJdYn8QEb

* fix(self-host): UpgradeNote and SKV tooltip name the connector key, never the hosted subscription; SOVEREIGN.md updated to merged reality

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UzNkSsR18pLFitJdYn8QEb

* fix(self-host): BankSyncNowButton gate copy branches like UpgradeNote (connector key, not hosted billing)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UzNkSsR18pLFitJdYn8QEb

---------

Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Emil <emilmattsson14@gmail.com>
2026-08-31 23:18:43 +02:00

302 lines
12 KiB
TypeScript

#!/usr/bin/env npx tsx
/**
* Crontab generator: emits docker/crontab.hosted and docker/crontab.self-hosted
* from the `crons` array in vercel.json.
*
* vercel.json is the single source of truth for what runs on a schedule. The
* Docker deployments run the same HTTP endpoints through supercronic, so their
* crontabs are generated from that array instead of hand-maintained.
*
* Hand-maintaining them is exactly what went wrong: seven of sixteen jobs were
* missing from Docker entirely (recurring invoices never sent, webhooks never
* dispatched, idempotency_keys grew unbounded), /api/tax-deadlines/cron had
* degraded from daily to "0 0 2 1 *" (once a year, on 2 January), and
* /api/documents/verify/cron ran weekly against a daily vercel.json.
*
* Usage:
* npx tsx scripts/generate-crontabs.ts # rewrite both crontabs
* npm run crontabs:generate # same, via package.json
*
* scripts/__tests__/generate-crontabs.test.ts fails CI if the committed files
* drift from vercel.json again.
*/
import { readFileSync, writeFileSync } from 'node:fs'
import { join, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
const __filename = fileURLToPath(import.meta.url)
const ROOT = dirname(dirname(__filename))
const VERCEL_JSON_PATH = join(ROOT, 'vercel.json')
const DOCKER_DIR = join(ROOT, 'docker')
export type CrontabVariant = 'hosted' | 'self-hosted'
export const VARIANTS: readonly CrontabVariant[] = ['hosted', 'self-hosted']
export interface VercelCron {
path: string
schedule: string
}
/** The compose file that bind-mounts each variant, quoted in the file header. */
const MOUNTED_BY: Record<CrontabVariant, string> = {
hosted: 'docker-compose.hosted.yml',
'self-hosted': 'docker-compose.yml',
}
/**
* The invocation. `${CRON_SECRET}` and `${APP_URL}` are expanded by the shell
* supercronic runs each job under; both come from the cron service's
* environment in docker-compose.yml. Not a template literal on purpose: the
* `${...}` must reach the file verbatim.
*/
const CURL_PREFIX = 'curl -sf -H "Authorization: Bearer ${CRON_SECRET}" ${APP_URL}'
/**
* Paths in vercel.json deliberately NOT emitted into the Docker crontabs, each
* with its reason. A silent omission is drift; this table is the only
* sanctioned way to leave a scheduled endpoint out of a self-hosted install.
*
* Empty, and that is the reviewed answer rather than an oversight:
*
* - Extension endpoints stay in, including extensions the self-hosted preset
* does not enable. docker/extensions.self-hosted.json turns on eight
* extensions, but the preset only drives the runtime registry: the
* Dockerfile builds the whole app/ tree, so every extension cron route is
* compiled into the image either way. And every one of them answers HTTP
* 200 with a no-op body when its extension is unconfigured (skatteverket
* checks SKATTEVERKET_ENABLED, stripe checks STRIPE_SECRET_KEY plus
* STRIPE_CONNECT_CLIENT_ID, cloud-backup and enable-banking simply find no
* rows). An unused extension therefore costs one cheap request at its
* cadence, and a self-hoster who enables it later does not have to discover
* that the schedule was never there. This also matches the pre-existing
* intent: the hand-written crontabs already listed enable-banking and
* skattekonto, both of which are now in the self-hosted preset (unconfigured extensions no-op).
* - /api/sandbox/cleanup/cron stays in. The sandbox is a database flag
* (company_settings.is_sandbox), not a hosted-only build flag, and the
* cleanup_expired_sandbox_users RPC ships in supabase/migrations
* (20260311120000_sandbox_support.sql), so a self-hosted database has it.
* With no sandbox users it deletes 0 rows and returns 200.
*/
export const EXCLUDED_PATHS: Readonly<Record<string, string>> = {}
/**
* Per-variant schedule overrides, path to cron expression. This is where a
* deliberate hosted/self-hosted divergence gets recorded, so it reads as a
* decision with a reason instead of as drift in a hand-edited file.
*
* Empty on both variants: every job currently runs the vercel.json cadence
* everywhere. Two candidates were considered and rejected:
*
* - /api/documents/verify/cron ran weekly ("0 3 * * 0") in the hand-written
* crontabs against a daily vercel.json. Not a load concession: the run is
* capped at 200 documents (DOCUMENT_VERIFY_BATCH_SIZE) and walks a
* nulls-first queue, so weekly drains the WORM integrity queue seven times
* slower on a check that exists to satisfy BFL 7-year retention. The weekly
* cadence also sat in crontab.hosted, which is not a small box (the two
* files were byte-identical), so it cannot have been a self-hosted
* concession. Treated as drift and realigned to daily.
* - /api/webhooks/dispatch/cron at "* * * * *" is 1440 requests/day that
* self-hosted was not making before. Left at parity anyway: the retry
* ladder in lib/webhooks/dispatcher.ts opens with a 60-second first retry,
* which a coarser tick would silently stretch, and each tick is one indexed
* query that returns immediately when nothing is due. See the load note in
* the generated file header.
*/
export const SCHEDULE_OVERRIDES: Readonly<
Record<CrontabVariant, Readonly<Record<string, string>>>
> = {
hosted: {},
'self-hosted': {},
}
/**
* Jobs that exist in ONE variant only and therefore have no vercel.json entry
* (vercel.json is the hosted schedule). Each carries its reason, the same
* discipline as EXCLUDED_PATHS: a self-hosted-only endpoint that silently
* lacked a schedule would be dead code that looks alive.
*
* Rendered after the vercel.json jobs under their own comment line. The
* crontab drift test checks both halves: the vercel.json mirror AND that
* every EXTRA_JOBS path is a real cron route that vercel.json does NOT
* schedule (the moment it does, the entry must go).
*/
export interface ExtraJob {
path: string
schedule: string
reason: string
}
export const EXTRA_JOBS: Readonly<Record<CrontabVariant, readonly ExtraJob[]>> = {
hosted: [],
'self-hosted': [
{
path: '/api/connector/sync/cron',
schedule: '17 * * * *',
reason:
'Self-hosted only: refreshes the source=connector capability grants from the instance\'s ' +
'GNUBOK_CONNECTOR_KEY (hourly; grants carry a 72h offline grace). Hosted has no connector ' +
'key, so the route is not in vercel.json; an instance without a key answers not_configured.',
},
],
}
/** Read and shape-check the `crons` array. */
export function readVercelCrons(vercelJson: string): VercelCron[] {
const parsed = JSON.parse(vercelJson) as { crons?: VercelCron[] }
const crons = parsed.crons ?? []
for (const cron of crons) {
if (typeof cron.path !== 'string' || !cron.path.startsWith('/api/')) {
throw new Error(`vercel.json: cron path must start with /api/, got ${JSON.stringify(cron.path)}`)
}
if (typeof cron.schedule !== 'string' || cron.schedule.trim().split(/\s+/).length !== 5) {
throw new Error(
`vercel.json: ${cron.path} needs a 5-field cron expression, got ${JSON.stringify(cron.schedule)}`,
)
}
}
const seen = new Set<string>()
for (const cron of crons) {
if (seen.has(cron.path)) throw new Error(`vercel.json: duplicate cron path ${cron.path}`)
seen.add(cron.path)
}
return crons
}
/** The schedule a given variant should run a path on. */
export function scheduleFor(cron: VercelCron, variant: CrontabVariant): string {
return SCHEDULE_OVERRIDES[variant][cron.path] ?? cron.schedule
}
function buildHeader(variant: CrontabVariant): string[] {
return [
'# AUTO-GENERATED: do not edit. Run `npm run crontabs:generate` to regenerate.',
'#',
`# Variant: ${variant} (bind-mounted by ${MOUNTED_BY[variant]}).`,
'# Source of truth: the `crons` array in vercel.json. Paths, order and',
'# cadence mirror it exactly; scripts/__tests__/generate-crontabs.test.ts',
'# fails CI if this file drifts from it.',
'#',
'# Consumed by supercronic (docker/cron.Dockerfile), bind-mounted read-only',
'# at /etc/supercronic/crontab. Times are UTC: the cron container sets no TZ',
'# and Alpine defaults to UTC, same as Vercel Cron. supercronic skips a tick',
'# whose previous run is still going (overlapping is off by default), so a',
'# slow endpoint cannot pile up.',
'#',
'# Extension endpoints are listed unconditionally, including extensions this',
"# image's preset does not enable. Each answers 200 with a no-op body when",
'# its extension is unconfigured, so an unused one costs a single cheap',
'# request, and enabling it later needs no crontab change.',
'#',
'# Load note: /api/webhooks/dispatch/cron runs every minute, 1440 requests a',
'# day. Each tick is one indexed query that returns immediately when no',
'# delivery is due, and the per-minute cadence is what makes the dispatcher',
'# 60-second first retry actually happen after 60 seconds. Change it only',
'# through SCHEDULE_OVERRIDES in scripts/generate-crontabs.ts, never by',
'# editing this file.',
'',
]
}
/** Render one crontab. Always LF, always newline-terminated. */
export function buildCrontab(
crons: VercelCron[],
variant: CrontabVariant,
options: {
excluded?: Readonly<Record<string, string>>
overrides?: Readonly<Record<CrontabVariant, Readonly<Record<string, string>>>>
extraJobs?: Readonly<Record<CrontabVariant, readonly ExtraJob[]>>
} = {},
): string {
const excluded = options.excluded ?? EXCLUDED_PATHS
const overrides = options.overrides ?? SCHEDULE_OVERRIDES
const jobs = crons
.filter((cron) => !(cron.path in excluded))
.map((cron) => ({
path: cron.path,
schedule: overrides[variant][cron.path] ?? cron.schedule,
}))
const extraJobs = (options.extraJobs ?? EXTRA_JOBS)[variant]
// Align the commands: pad to the widest schedule plus two spaces, the same
// column convention the hand-written files used.
const width = [...jobs, ...extraJobs].reduce((max, job) => Math.max(max, job.schedule.length), 0) + 2
const lines = [
...buildHeader(variant),
...jobs.map((job) => `${job.schedule.padEnd(width)}${CURL_PREFIX}${job.path}`),
...(extraJobs.length > 0
? [
'',
`# ${variant}-only jobs, not in vercel.json: see EXTRA_JOBS in scripts/generate-crontabs.ts`,
...extraJobs.map((job) => `${job.schedule.padEnd(width)}${CURL_PREFIX}${job.path}`),
]
: []),
]
return `${lines.join('\n')}\n`
}
function main(): void {
const crons = readVercelCrons(readFileSync(VERCEL_JSON_PATH, 'utf8'))
for (const path of Object.keys(EXCLUDED_PATHS)) {
if (!crons.some((cron) => cron.path === path)) {
throw new Error(`EXCLUDED_PATHS lists ${path}, which is not in vercel.json. Remove the stale entry.`)
}
}
for (const variant of VARIANTS) {
for (const path of Object.keys(SCHEDULE_OVERRIDES[variant])) {
if (!crons.some((cron) => cron.path === path)) {
throw new Error(
`SCHEDULE_OVERRIDES.${variant} lists ${path}, which is not in vercel.json. Remove the stale entry.`,
)
}
}
}
for (const variant of VARIANTS) {
for (const job of EXTRA_JOBS[variant]) {
if (crons.some((cron) => cron.path === job.path)) {
throw new Error(
`EXTRA_JOBS.${variant} lists ${job.path}, which vercel.json now schedules. Remove the extra entry.`,
)
}
}
}
for (const variant of VARIANTS) {
const target = join(DOCKER_DIR, `crontab.${variant}`)
writeFileSync(target, buildCrontab(crons, variant), 'utf8')
const emitted = crons.filter((cron) => !(cron.path in EXCLUDED_PATHS)).length + EXTRA_JOBS[variant].length
const overridden = Object.keys(SCHEDULE_OVERRIDES[variant]).length
console.log(
`Wrote docker/crontab.${variant}: ${emitted} jobs` +
(overridden > 0 ? `, ${overridden} schedule override(s)` : ''),
)
}
const skipped = Object.keys(EXCLUDED_PATHS)
if (skipped.length > 0) {
console.log(`Excluded ${skipped.length} path(s): ${skipped.join(', ')}`)
} else {
console.log('No exclusions: every vercel.json cron runs on Docker too.')
}
}
// Only run when invoked directly (not when imported by tests).
if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
try {
main()
} catch (err) {
console.error(err instanceof Error ? err.message : err)
process.exit(1)
}
}