@starci/hfs 4.9.9 → 4.10.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 +33 -0
- package/README.md +20 -8
- package/db/backup-receipt.mjs +10 -47
- package/db/drift.mjs +289 -0
- package/db/dump.mjs +12 -11
- package/db/entity-list.mjs +9 -0
- package/db/migrate.mjs +84 -260
- package/db/new.mjs +46 -0
- package/db/post-cutover.mjs +13 -17
- package/db/postgres.mjs +80 -0
- package/emit/contracts.mjs +5 -9
- package/lint/run.mjs +12 -2
- package/package.json +5 -3
- package/release/gate.mjs +82 -31
- package/release/index.mjs +19 -8
- package/release/push.mjs +4 -4
- package/release/records.mjs +54 -0
- package/release/urgent.mjs +129 -0
- package/runtime/knowledge/hfs/canon-pins.yaml +54 -24
- package/runtime/knowledge/hfs/design-truths.yaml +1 -1
- package/runtime/knowledge/hfs/fe-stack.yaml +4 -11
- package/runtime/knowledge/hfs/rules.yaml +250 -157
- package/runtime/knowledge/hfs/slots.yaml +199 -174
- package/runtime/knowledge/patterns/be/event-bus.yaml +3 -3
- package/runtime/knowledge/patterns/be/idempotency.yaml +3 -3
- package/runtime/knowledge/patterns/be/jobs.yaml +4 -4
- package/runtime/knowledge/patterns/be/projections.yaml +7 -5
- package/runtime/knowledge/patterns/be/queues.yaml +8 -8
- package/runtime/knowledge/patterns/be/reactors.yaml +2 -2
- package/runtime/knowledge/patterns/be/realtime.yaml +6 -6
- package/runtime/knowledge/patterns/be/saga.yaml +3 -3
- package/runtime/knowledge/patterns/be/webhooks.yaml +1 -1
- package/runtime/modules/kernel/command-policy.yaml +1 -1
- package/runtime/modules/kernel/failure-codes.yaml +86 -115
- package/runtime/modules/schemas/application-stacks.schema.yaml +5 -5
- package/runtime/scripts/hfs/app-wiring.mjs +23 -2
- package/runtime/scripts/hfs/architecture/canon-clones.mjs +1 -1
- package/runtime/scripts/hfs/architecture/{supabase-be.mjs → identity.mjs} +45 -15
- package/runtime/scripts/hfs/architecture/index.mjs +2 -3
- package/runtime/scripts/hfs/architecture/{supabase-ast.mjs → jwt-ast.mjs} +2 -103
- package/runtime/scripts/hfs/architecture/register-once.mjs +1 -1
- package/runtime/scripts/hfs/architecture/schema-owner.mjs +29 -4
- package/runtime/scripts/hfs/architecture/server-action.mjs +3 -4
- package/runtime/scripts/hfs/architecture/side-boundary.mjs +1 -1
- package/runtime/scripts/hfs/architecture/{supabase-keys.mjs → sql-keys.mjs} +1 -1
- package/runtime/scripts/hfs/architecture/sql-owner.mjs +25 -27
- package/runtime/scripts/hfs/architecture/transport-owner.mjs +7 -3
- package/runtime/scripts/hfs/check.mjs +8 -8
- package/runtime/scripts/hfs/coverage-scope.mjs +1 -1
- package/runtime/scripts/hfs/db-baseline-verb.mjs +48 -30
- package/runtime/scripts/hfs/db-plan-verb.mjs +17 -106
- package/runtime/scripts/hfs/db-restamp-verb.mjs +11 -10
- package/runtime/scripts/hfs/declaration-shape.mjs +15 -18
- package/runtime/scripts/hfs/manifest-shape.mjs +6 -5
- package/runtime/scripts/hfs/rule-params-shape.mjs +4 -1
- package/runtime/scripts/hfs/rules/a15-findings.mjs +1 -1
- package/runtime/scripts/hfs/rules/cli.mjs +1 -1
- package/runtime/scripts/hfs/rules/database-access.mjs +8 -74
- package/runtime/scripts/hfs/rules/database-baseline.mjs +3 -3
- package/runtime/scripts/hfs/rules/database-config.mjs +6 -214
- package/runtime/scripts/hfs/rules/database-constants.mjs +8 -10
- package/runtime/scripts/hfs/rules/database-migrations.mjs +3 -3
- package/runtime/scripts/hfs/rules/database-queues.mjs +4 -5
- package/runtime/scripts/hfs/rules/database-sql.mjs +1 -1
- package/runtime/scripts/hfs/rules/database.mjs +36 -39
- package/runtime/scripts/hfs/rules/edition.mjs +1 -1
- package/runtime/scripts/hfs/rules/{supabase-secrets.mjs → lite-secrets.mjs} +6 -6
- package/runtime/scripts/hfs/rules/script-hygiene.mjs +1 -10
- package/runtime/scripts/hfs/rules/stacks-lite-backing.mjs +5 -4
- package/runtime/scripts/hfs/rules/stacks-release.mjs +3 -2
- package/runtime/scripts/hfs/rules/stacks-runtime.mjs +2 -2
- package/runtime/scripts/hfs/rules/stacks.mjs +1 -1
- package/runtime/scripts/hfs/slot-app-view.mjs +1 -1
- package/runtime/scripts/hfs/slots.mjs +8 -2
- package/runtime/scripts/hfs/sql/pg-parse.mjs +2 -2
- package/runtime/scripts/lib/secret-patterns.mjs +2 -2
- package/runtime/scripts/lib/swarm-stack.mjs +7 -4
- package/scaffold/add-app.mjs +2 -10
- package/scaffold/add-cli-lite.mjs +6 -6
- package/scaffold/add-compose.mjs +1 -1
- package/scaffold/add-inbox-lite.mjs +4 -8
- package/scaffold/add-plan.mjs +1 -1
- package/scaffold/add-queue-lite.mjs +16 -24
- package/scaffold/add-table.mjs +34 -26
- package/scaffold/add.mjs +2 -2
- package/scaffold/app.mjs +19 -86
- package/scaffold/lite-exports.mjs +1 -1
- package/src/main.mjs +24 -22
- package/stack/cli.mjs +10 -2
- package/stack/deploy.mjs +21 -4
- package/stack/target-binding.mjs +0 -60
- package/stack/urgent-floor.mjs +147 -0
- package/sync/ci-commands.mjs +3 -1
- package/sync/index.mjs +32 -8
- package/templates/app/ci-workflows/github/workflows/stack-deploy.yml +4 -1
- package/templates/app/ci-workflows-lite/github/workflows/ci.yml +1 -17
- package/templates/app/ci-workflows-lite/github/workflows/db-deploy.yml +6 -8
- package/templates/app/ci-workflows-lite/github/workflows/stack-deploy.yml +4 -1
- package/templates/app/codegen-lite/scripts/codegen.mjs +2 -39
- package/templates/app/db-bootstrap/db/bootstrap.sql +139 -0
- package/templates/app/gitignore-lite +0 -3
- package/templates/app/package-scripts/db.json +9 -0
- package/templates/app/package-scripts/package.json +0 -1
- package/templates/app/package-scripts-lite/package.json +1 -1
- package/templates/app/skeleton/.starcistacks/dev/README.md +1 -1
- package/templates/app/skeleton/.starcistacks/production/README.md +1 -1
- package/templates/app/skeleton/README.md +1 -1
- package/templates/app/skeleton-lite/.starcistacks/application-stacks.yaml +84 -19
- package/templates/app/skeleton-lite/.starcistacks/dev/README.md +5 -5
- package/templates/app/skeleton-lite/.starcistacks/dev/environment.json +1 -1
- package/templates/app/skeleton-lite/.starcistacks/dev/infra/swarm/recovery/restore-proof.md +1 -1
- package/templates/app/skeleton-lite/.starcistacks/dev/infra/swarm/stack.yaml +69 -6
- package/templates/app/skeleton-lite/.starcistacks/dev/runtime/env/KEYS.md +18 -7
- package/templates/app/skeleton-lite/.starcistacks/production/README.md +6 -6
- package/templates/app/skeleton-lite/.starcistacks/production/environment.json +1 -1
- package/templates/app/skeleton-lite/.starcistacks/production/infra/swarm/recovery/restore-proof.md +2 -2
- package/templates/app/skeleton-lite/.starcistacks/production/infra/swarm/stack.yaml +69 -6
- package/templates/app/skeleton-lite/.starcistacks/production/runtime/env/KEYS.md +17 -9
- package/templates/app/skeleton-lite/README.md +11 -11
- package/templates/app/skeleton-lite/{supabase → db}/migrations/__timestamp___baseline.sql +21 -1
- package/templates/app/tool-config-lite/prettierignore +0 -1
- package/templates/be/inbox/database-client.spec.ts.tpl +9 -5
- package/templates/be/inbox/database-client.ts.tpl +13 -4
- package/templates/be/inbox/platform/client-operation-outcomes.sql.tpl +47 -0
- package/templates/be/inbox/platform/event-bus/event-bus.service.spec.ts.tpl +3 -1
- package/templates/be/inbox/platform/event-bus/event-bus.service.ts.tpl +2 -2
- package/templates/be/inbox/platform/inbox/inbox.service.spec.ts.tpl +6 -1
- package/templates/be/inbox/platform/inbox/inbox.service.ts.tpl +39 -7
- package/templates/be/inbox/platform/migration.sql.tpl +22 -0
- package/templates/be/inbox/service.spec.ts.tpl +2 -2
- package/templates/be/inbox/service.ts.tpl +1 -2
- package/templates/be/patterns/jobs/platform-lite/job-claim.service.spec.ts.tpl +156 -0
- package/templates/be/patterns/jobs/platform-lite/job-claim.service.ts.tpl +114 -0
- package/templates/be/patterns/jobs/platform-lite/jobs.sql.tpl +51 -0
- package/templates/be/patterns/queues/platform-lite/queue-outbox.service.spec.ts.tpl +62 -0
- package/templates/be/patterns/queues/platform-lite/queue-outbox.service.ts.tpl +20 -0
- package/templates/be/patterns/queues/platform-lite/queue-outbox.sql.tpl +35 -0
- package/templates/be/patterns/queues/platform-lite/queue-relay.service.spec.ts.tpl +4 -1
- package/templates/be/patterns/queues/platform-lite/queue-relay.service.ts.tpl +16 -5
- package/templates/be/patterns/realtime/channel.gateway.spec.ts.tpl +8 -8
- package/templates/be/patterns/realtime/channel.websocket.module.ts.tpl +3 -3
- package/templates/be/patterns/realtime/channel.websocket.options.ts.tpl +2 -2
- package/templates/be/skeleton/src/modules/domain/identity/identity.decorators.ts +18 -7
- package/templates/be/skeleton/src/modules/platform/composition/composition.decorators.ts +3 -0
- package/templates/be/skeleton/src/modules/platform/composition/index.ts +1 -1
- package/templates/be/skeleton/src/modules/platform/errors/errors.filter.spec.ts +15 -1
- package/templates/be/skeleton/src/modules/platform/errors/errors.filter.ts +10 -9
- package/templates/be/skeleton/src/modules/platform/http-security/index.ts +1 -1
- package/templates/be/skeleton/src/modules/platform/http-security/origin.guard.spec.ts +34 -18
- package/templates/be/skeleton/src/modules/platform/http-security/origin.guard.ts +29 -8
- package/templates/be/skeleton/src/modules/platform/http-security/rate-limit.guard.spec.ts +80 -4
- package/templates/be/skeleton/src/modules/platform/http-security/rate-limit.guard.ts +39 -11
- package/templates/be/skeleton-lite/apps/api/Dockerfile +0 -1
- package/templates/be/skeleton-lite/apps/api/src/api.env.ts +9 -5
- package/templates/be/skeleton-lite/apps/api/src/api.options.ts +7 -4
- package/templates/be/skeleton-lite/apps/api/src/app.module.ts +4 -4
- package/templates/be/skeleton-lite/apps/api/src/compose/domain.ts +3 -3
- package/templates/be/skeleton-lite/apps/api/src/compose/integrations.ts +9 -13
- package/templates/be/skeleton-lite/apps/api/src/compose/platform.ts +4 -2
- package/templates/be/skeleton-lite/apps/cli/src/cli.env.ts +2 -2
- package/templates/be/skeleton-lite/apps/cli/src/compose/platform.ts +3 -2
- package/templates/be/skeleton-lite/src/modules/domain/identity/auth.guard.spec.ts +4 -4
- package/templates/be/skeleton-lite/src/modules/domain/identity/auth.guard.ts +3 -3
- package/templates/be/skeleton-lite/src/modules/domain/identity/identity.contracts.ts +1 -1
- package/templates/be/skeleton-lite/src/modules/domain/identity/identity.decorators.ts +23 -13
- package/templates/be/skeleton-lite/src/modules/domain/identity/identity.options.ts +3 -3
- package/templates/be/skeleton-lite/src/modules/integrations/object-storage/index.ts +4 -0
- package/templates/be/skeleton-lite/src/modules/integrations/object-storage/object-storage.client.spec.ts +22 -0
- package/templates/be/skeleton-lite/src/modules/integrations/object-storage/object-storage.client.ts +25 -0
- package/templates/be/skeleton-lite/src/modules/integrations/object-storage/object-storage.config.ts +12 -0
- package/templates/be/skeleton-lite/src/modules/integrations/object-storage/object-storage.decorators.ts +9 -0
- package/templates/be/skeleton-lite/src/modules/integrations/object-storage/object-storage.options.ts +35 -0
- package/templates/be/skeleton-lite/src/modules/integrations/passport/errors/passport.error.ts +22 -0
- package/templates/be/skeleton-lite/src/modules/integrations/passport/index.ts +12 -0
- package/templates/be/skeleton-lite/src/modules/integrations/passport/passport.config.ts +23 -0
- package/templates/be/skeleton-lite/src/modules/integrations/passport/passport.cookie.ts +29 -0
- package/templates/be/skeleton-lite/src/modules/integrations/passport/passport.decorators.ts +22 -0
- package/templates/be/skeleton-lite/src/modules/integrations/passport/passport.options.ts +63 -0
- package/templates/be/skeleton-lite/src/modules/integrations/passport/passport.password.ts +11 -0
- package/templates/be/skeleton-lite/src/modules/integrations/passport/passport.tokens.spec.ts +32 -0
- package/templates/be/skeleton-lite/src/modules/integrations/passport/passport.tokens.ts +69 -0
- package/templates/be/skeleton-lite/src/modules/integrations/passport/strategies/google.strategy.ts +37 -0
- package/templates/be/skeleton-lite/src/modules/integrations/passport/strategies/local.strategy.ts +36 -0
- package/templates/be/skeleton-lite/src/modules/integrations/passport/strategies/oauth-state.store.ts +59 -0
- package/templates/be/skeleton-lite/src/modules/platform/database/database.functions.ts +24 -0
- package/templates/be/skeleton-lite/src/modules/platform/database/database.module.ts +2 -1
- package/templates/be/skeleton-lite/src/modules/platform/database/database.options.ts +4 -2
- package/templates/be/skeleton-lite/src/modules/platform/database/database.sql.ts +19 -6
- package/templates/be/skeleton-lite/src/modules/platform/database/entities.ts +6 -0
- package/templates/be/skeleton-lite/src/modules/platform/database/index.ts +1 -0
- package/templates/be/skeleton-lite/src/modules/platform/database/migration-runner.service.ts +1 -1
- package/templates/be/skeleton-lite/src/modules/platform/database/primary.config.ts +2 -2
- package/templates/be/skeleton-lite/src/modules/platform/database/seed-runner.service.ts +2 -2
- package/templates/be/skeleton-lite/src/modules/platform/http-security/index.ts +1 -1
- package/templates/be/skeleton-lite/src/tests/fixtures/builders/api.builder.ts +18 -5
- package/templates/be/skeleton-lite/src/tests/fixtures/builders/cli.builder.ts +1 -1
- package/templates/be/table/entities.index.ts.tpl +4 -0
- package/templates/be/table/entity.ts.tpl +21 -0
- package/templates/be/table/index.ts.tpl +1 -0
- package/templates/be/table/module.ts.tpl +1 -1
- package/templates/be/table/service.api.ts.tpl +10 -11
- package/templates/be/table/service.ts.tpl +5 -6
- package/templates/fe/skeleton-lite/apps/__app__/src/modules/auth/auth-door.ts +30 -0
- package/templates/fe/skeleton-lite/apps/__app__/src/modules/auth/client.ts +46 -14
- package/templates/fe/skeleton-lite/apps/__app__/src/modules/auth/token-store.ts +31 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/config/index.ts +2 -5
- package/db/local-migrate.mjs +0 -194
- package/db/reset.mjs +0 -125
- package/emit/db-types.mjs +0 -271
- package/runtime/scripts/api/supabase/database-dump.mjs +0 -5
- package/runtime/scripts/api/supabase/database-push.mjs +0 -5
- package/runtime/scripts/api/supabase/database-query.mjs +0 -5
- package/runtime/scripts/api/supabase/lib.mjs +0 -55
- package/runtime/scripts/api/supabase/migration-repair.mjs +0 -5
- package/runtime/scripts/hfs/architecture/supabase-tables.mjs +0 -50
- package/runtime/scripts/hfs/architecture/supabase.mjs +0 -226
- package/scaffold/supabase-ports.mjs +0 -26
- package/templates/app/package-scripts/supabase.json +0 -7
- package/templates/app/skeleton-lite/supabase/config.toml +0 -48
- package/templates/be/inbox/platform/event-bus/persistence/event-bus.sql.ts.tpl +0 -5
- package/templates/be/inbox/platform/inbox/persistence/inbox.rows.ts.tpl +0 -33
- package/templates/be/inbox/platform/inbox/persistence/inbox.sql.ts.tpl +0 -33
- package/templates/be/inbox/sql.ts.tpl +0 -16
- package/templates/be/patterns/jobs/platform-lite/persistence.jobs.sql.ts.tpl +0 -33
- package/templates/be/patterns/queues/platform-lite/persistence.queue.sql.ts.tpl +0 -12
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/errors/supabase.error.ts +0 -16
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/index.ts +0 -6
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/supabase.client.spec.ts +0 -27
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/supabase.client.ts +0 -24
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/supabase.config.ts +0 -8
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/supabase.decorators.ts +0 -17
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/supabase.jwks.ts +0 -32
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/supabase.options.ts +0 -24
- package/templates/be/table/rows.ts.tpl +0 -4
- package/templates/be/table/sql.api.ts.tpl +0 -7
- package/templates/be/table/sql.ts.tpl +0 -4
- package/templates/fe/auth/supabase-client.ts.tpl +0 -38
- package/templates/fe/skeleton/apps/__app__/src/app/auth/callback/route.ts +0 -11
- package/templates/fe/skeleton/apps/__app__/src/modules/auth/pkce-client.ts +0 -18
- package/templates/fe/skeleton/apps/__app__/src/modules/auth/server.ts +0 -19
- /package/templates/app/skeleton-lite/{supabase → db}/seed.sql +0 -0
package/db/post-cutover.mjs
CHANGED
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
// 2. a time gate: --green-at <ISO> at least minAgeHours (48) ago, or --owner-confirms-old-app-gone;
|
|
7
7
|
// 3. STARCI_DB_ARMED=1.
|
|
8
8
|
// Idempotent: when every held-back version is already on the remote it prints `nothing to do`. The pg_proc query goes through `options.query(sql)`
|
|
9
|
-
// (specs inject one) or, by default,
|
|
9
|
+
// (specs inject one) or, by default, psql against the database --url-env names (default DATABASE_URL).
|
|
10
10
|
import fs from 'node:fs';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { failure, refusal } from '../stack/errors.mjs';
|
|
13
13
|
import { runVerb } from '../release/index.mjs';
|
|
14
|
-
import { buildModel, listRemote, loadDatabase,
|
|
14
|
+
import { applyVersions, buildModel, listRemote, loadDatabase, requireArmed, resolveTarget } from './migrate.mjs';
|
|
15
|
+
import { queryRows as psqlRows } from './postgres.mjs';
|
|
15
16
|
|
|
16
17
|
const DROP_FUNCTION = /^drop\s+function\s+/iu;
|
|
17
18
|
const IF_EXISTS = /^if\s+exists\s+/iu;
|
|
@@ -54,7 +55,7 @@ function preflightSql({ schema, prefixes, names }) {
|
|
|
54
55
|
return `select oid::regprocedure::text as signature from pg_proc where pronamespace = '${schema}'::regnamespace and (${clauses.join(' or ')})`;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
const cliQuery = (session) => (sql) =>
|
|
58
|
+
const cliQuery = (session) => (sql) => psqlRows(session.ctx, session.target, sql, { withhold: true });
|
|
58
59
|
|
|
59
60
|
async function queryRows(session, sql, options) {
|
|
60
61
|
try {
|
|
@@ -89,26 +90,21 @@ function timeGate(ctx, post, options) {
|
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
function applyHeld(session, remote) {
|
|
92
|
-
const { model
|
|
93
|
+
const { model } = session;
|
|
93
94
|
const lacking = [...model.pushVersions].filter((version) => !remote.has(version));
|
|
94
|
-
if (lacking.length > 0) throw refusal('DB_BASELINE_NOT_APPLIED', `the
|
|
95
|
-
|
|
96
|
-
const pending = pendingVersions(runCli(session, [...args, '--dry-run', ...targetArgs(session.target, ctx.cwd)]).text);
|
|
97
|
-
const stray = pending.filter((version) => !model.heldVersions.includes(version));
|
|
98
|
-
if (stray.length > 0) throw failure('DB_PUSH_STRAY', `the dry run lists more than the held-back migrations: ${pending.join(', ')}. Stopped.`);
|
|
99
|
-
if (pending.length > 0) runCli(session, [...args, '--yes', ...targetArgs(session.target, ctx.cwd)]);
|
|
100
|
-
return pending;
|
|
95
|
+
if (lacking.length > 0) throw refusal('DB_BASELINE_NOT_APPLIED', `the history lacks ${lacking.join(', ')}: run starci app db migrate first`);
|
|
96
|
+
return applyVersions(session, model.heldVersions.filter((version) => !remote.has(version)));
|
|
101
97
|
}
|
|
102
98
|
|
|
103
99
|
/**
|
|
104
|
-
* `starci app db post-cutover`. options: { execute,
|
|
105
|
-
* --execute: gate open and STARCI_DB_ARMED=1, then
|
|
100
|
+
* `starci app db post-cutover`. options: { execute, urlEnv, greenAt, ownerConfirms, query }. Dry run: history read plus the read-only preflight.
|
|
101
|
+
* --execute: gate open and STARCI_DB_ARMED=1, then exactly the held-back versions, each with its history row in one transaction.
|
|
106
102
|
*/
|
|
107
103
|
async function postCutoverDatabase(ctx, decl, options = {}) {
|
|
108
104
|
const model = buildModel(ctx.cwd, decl);
|
|
109
105
|
if (model.held.length === 0) return { ok: true, lines: ['no held-back migration in the repository. Nothing to do.'], data: { held: [], done: true, executed: false } };
|
|
110
106
|
if (decl.postCutover === null) throw refusal('DB_POSTCUTOVER_UNDECLARED', 'database.postCutover is not declared: the function preflight needs it (an empty mapping declares no family)');
|
|
111
|
-
const session = { ctx, decl, model, target: resolveTarget(ctx,
|
|
107
|
+
const session = { ctx, decl, model, target: resolveTarget(ctx, options) };
|
|
112
108
|
const remote = listRemote(session);
|
|
113
109
|
const data = { held: model.heldVersions, done: false, executed: false };
|
|
114
110
|
if (model.heldVersions.every((version) => remote.has(version))) return { ok: true, lines: [`held-back migrations ${model.held.join(', ')} are already applied. Nothing to do.`], data: { ...data, done: true } };
|
|
@@ -123,14 +119,14 @@ async function postCutoverDatabase(ctx, decl, options = {}) {
|
|
|
123
119
|
return { ok: true, lines: [...lines, pending.length > 0 ? `applied: ${pending.join(', ')}` : 'nothing pending: already applied.'], data: { ...data, done: true, executed: true, pushed: pending, signatures: preflight.count } };
|
|
124
120
|
}
|
|
125
121
|
|
|
126
|
-
const SPEC = { boolean: ['--execute', '--json', '--
|
|
122
|
+
const SPEC = { boolean: ['--execute', '--json', '--owner-confirms-old-app-gone'], value: ['--url-env', '--green-at'] };
|
|
127
123
|
|
|
128
|
-
/** Entry of the verb: `starci app db post-cutover [--execute] [--green-at <ISO> | --owner-confirms-old-app-gone] [--
|
|
124
|
+
/** Entry of the verb: `starci app db post-cutover [--execute] [--green-at <ISO> | --owner-confirms-old-app-gone] [--url-env NAME] [--json]`. */
|
|
129
125
|
export function dbPostCutoverMain(argv, io = {}) {
|
|
130
126
|
return runVerb({
|
|
131
127
|
label: 'starci app db post-cutover', name: 'db post-cutover', code: 'DB_USAGE', io, argv, spec: SPEC,
|
|
132
128
|
run: (ctx, flags) => postCutoverDatabase(ctx, loadDatabase(ctx.cwd), {
|
|
133
|
-
execute: flags.execute === true,
|
|
129
|
+
execute: flags.execute === true, urlEnv: flags['url-env'], greenAt: flags['green-at'], ownerConfirms: flags['owner-confirms-old-app-gone'] === true,
|
|
134
130
|
}),
|
|
135
131
|
});
|
|
136
132
|
}
|
package/db/postgres.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// postgres.mjs - the one door of the `starci app db` verbs to a self-hosted PostgreSQL: psql and pg_dump through ctx.spawn (never a
|
|
2
|
+
// shell). The database is named by an environment variable holding a postgres connection URL (`--url-env <NAME>`, default
|
|
3
|
+
// DATABASE_URL); the password travels only in the child's PGPASSWORD, never in argv, a file, a line or an error.
|
|
4
|
+
import { failure, refusal } from '../stack/errors.mjs';
|
|
5
|
+
import { firstLine, tool } from '../stack/context.mjs';
|
|
6
|
+
|
|
7
|
+
/** The default environment variable that names the app's database. */
|
|
8
|
+
export const DEFAULT_DB_URL_ENV = 'DATABASE_URL';
|
|
9
|
+
/** The history table `starci app db migrate` records applied migrations in (the layout the supabase/postgres image already ships). */
|
|
10
|
+
export const HISTORY_TABLE = 'supabase_migrations.schema_migrations';
|
|
11
|
+
|
|
12
|
+
const KEY = /^[A-Z][A-Z0-9_]*$/u;
|
|
13
|
+
|
|
14
|
+
const scrub = (text, secrets) => secrets.reduce((out, secret) => out.replaceAll(secret, '[value]'), String(text));
|
|
15
|
+
|
|
16
|
+
/** { url, password } of a postgres connection URL with the password removed, or null when `value` is not one. */
|
|
17
|
+
export function parseConnection(value) {
|
|
18
|
+
try {
|
|
19
|
+
const url = new URL(value);
|
|
20
|
+
if (!/^postgres(?:ql)?:$/u.test(url.protocol)) return null;
|
|
21
|
+
const password = decodeURIComponent(url.password);
|
|
22
|
+
url.password = '';
|
|
23
|
+
return { url: url.toString(), password };
|
|
24
|
+
} catch { return null; }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The database `name` (an UPPER_CASE environment variable, default DATABASE_URL) names: { how, url, env, secrets }. */
|
|
28
|
+
export function dbTarget(ctx, name = DEFAULT_DB_URL_ENV) {
|
|
29
|
+
if (!KEY.test(name)) throw refusal('DB_USAGE', '--url-env must name an UPPER_CASE environment variable');
|
|
30
|
+
const value = ctx.env[name];
|
|
31
|
+
if (typeof value !== 'string' || value === '') throw refusal('DB_URL_ENV_MISSING', `${name} is not set`);
|
|
32
|
+
const parsed = parseConnection(value);
|
|
33
|
+
if (!parsed) throw refusal('DB_URL_INVALID', `${name} is not a postgres connection URL`);
|
|
34
|
+
return { kind: 'url', how: `connection string from ${name}`, urlEnv: name, url: parsed.url, env: parsed.password ? { PGPASSWORD: parsed.password } : {}, secrets: [value, parsed.password].filter(Boolean) };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Runs a PostgreSQL client tool against `target`; a failure names the first stderr line with every secret scrubbed (or withholds it). */
|
|
38
|
+
export function pgTool(ctx, target, command, args, { withhold = false, code = 'DB_CLI_FAILED' } = {}) {
|
|
39
|
+
const run = tool(ctx, command, args, { cwd: ctx.cwd, env: { ...ctx.env, ...target.env } });
|
|
40
|
+
if (run.error) throw failure('DB_CLI_MISSING', `cannot run ${command}; install the PostgreSQL client tools (psql, pg_dump)`);
|
|
41
|
+
if (run.status !== 0) throw failure(code, withhold ? `${command} failed; output withheld` : `${command} failed: ${scrub(firstLine(run.stderr), target.secrets)}`);
|
|
42
|
+
return { stdout: run.stdout ?? '', text: `${run.stdout ?? ''}${run.stderr ?? ''}` };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const PSQL = ['-X', '-q', '-v', 'ON_ERROR_STOP=1'];
|
|
46
|
+
|
|
47
|
+
/** Runs SQL statements (`-c`) and files (`-f`) in ONE transaction: each step is { sql } or { file }. */
|
|
48
|
+
export function psqlTransaction(ctx, target, steps, options = {}) {
|
|
49
|
+
const args = [...PSQL, '-1', '-d', target.url, ...steps.flatMap((step) => (step.file !== undefined ? ['-f', step.file] : ['-c', step.sql]))];
|
|
50
|
+
return pgTool(ctx, target, 'psql', args, options);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The rows of one read-only query as plain objects (json_agg on the server, so no psql formatting is parsed). */
|
|
54
|
+
export function queryRows(ctx, target, sql, options = {}) {
|
|
55
|
+
const wrapped = `select coalesce(json_agg(row_to_json(q)), '[]'::json) from (${sql.replace(/;\s*$/u, '')}) q`;
|
|
56
|
+
const { stdout } = pgTool(ctx, target, 'psql', [...PSQL, '-A', '-t', '-d', target.url, '-c', wrapped], options);
|
|
57
|
+
let rows;
|
|
58
|
+
try { rows = JSON.parse(stdout.trim() || '[]'); } catch { throw failure('DB_QUERY_UNREADABLE', 'the database answered rows psql could not print as JSON; output withheld'); }
|
|
59
|
+
if (!Array.isArray(rows) || rows.some((row) => !row || typeof row !== 'object' || Array.isArray(row))) throw failure('DB_QUERY_UNREADABLE', 'the database answer is not a rows array');
|
|
60
|
+
return rows;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** A SQL string literal of `value`. */
|
|
64
|
+
export const literal = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
65
|
+
|
|
66
|
+
/** The versions the history table records; an absent table is an empty history (a database `migrate` has never touched). */
|
|
67
|
+
export function historyVersions(ctx, target) {
|
|
68
|
+
const [presence] = queryRows(ctx, target, `select pg_catalog.to_regclass(${literal(HISTORY_TABLE)}) is not null as present`);
|
|
69
|
+
if (presence?.present !== true) return new Set();
|
|
70
|
+
return new Set(queryRows(ctx, target, `select version from ${HISTORY_TABLE} order by version`).map((row) => String(row.version)));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The statement that creates the history table when it is absent (same columns as the image's own: version, statements, name). */
|
|
74
|
+
export const HISTORY_DDL = `create schema if not exists supabase_migrations; create table if not exists ${HISTORY_TABLE} (version text primary key, statements text[], name text)`;
|
|
75
|
+
|
|
76
|
+
/** Records `version` (named `name`) as applied. */
|
|
77
|
+
export const markApplied = (version, name) => `insert into ${HISTORY_TABLE} (version, name) values (${literal(version)}, ${literal(name)}) on conflict (version) do update set name = excluded.name`;
|
|
78
|
+
|
|
79
|
+
/** Removes `version` from the history. */
|
|
80
|
+
export const markReverted = (version) => `delete from ${HISTORY_TABLE} where version = ${literal(version)}`;
|
package/emit/contracts.mjs
CHANGED
|
@@ -18,10 +18,7 @@
|
|
|
18
18
|
* TypeScript, Nest and graphql are the repository's own packages; nothing is added to the managed devDependencies. Every app
|
|
19
19
|
* runs in its own child process (`schema-worker.mjs`) because Nest GraphQL's type metadata is process-global.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
* Database types written: `supabase/types/database.types.ts` at the app root through `writeDbTypes` (emit/db-types.mjs), the
|
|
23
|
-
* same `supabase gen types typescript --local` text L09 DB_TYPES_DRIFT regenerates to judge drift. The types are an app-level
|
|
24
|
-
* artifact, so a redirected `outDir` (the R23 check mode, which emits into a scratch root) does not get them.
|
|
21
|
+
* * artifact, so a redirected `outDir` (the R23 check mode, which emits into a scratch root) does not get them.
|
|
25
22
|
*/
|
|
26
23
|
import { spawnSync } from 'node:child_process';
|
|
27
24
|
import fs from 'node:fs';
|
|
@@ -30,7 +27,6 @@ import { fileURLToPath } from 'node:url';
|
|
|
30
27
|
import { emitEvents, eventServices, eventsSnapshotPath } from './events.mjs';
|
|
31
28
|
import { openapiPath } from './operations.mjs';
|
|
32
29
|
import { readEnv } from '../runtime/scripts/lib/env.mjs';
|
|
33
|
-
import { appHasDbTypes, writeDbTypes } from './db-types.mjs';
|
|
34
30
|
import { createSlotResolver, loadSlotManifest, locateDeclaration, readRepoDeclaration } from '../runtime/scripts/hfs/slots.mjs';
|
|
35
31
|
|
|
36
32
|
/** The stderr prefix of a dependency the worker could not load and stood in for. */
|
|
@@ -84,7 +80,7 @@ function emitApp(repoRoot, app) {
|
|
|
84
80
|
* resolves there (a bare folder is not an app and emits no types). `repoRoot` is the be side folder, so `locateDeclaration`
|
|
85
81
|
* answers the app root above it.
|
|
86
82
|
*/
|
|
87
|
-
function
|
|
83
|
+
function appDbScope(repoRoot) {
|
|
88
84
|
try {
|
|
89
85
|
const { appRoot } = locateDeclaration(repoRoot);
|
|
90
86
|
const manifest = loadSlotManifest();
|
|
@@ -100,9 +96,9 @@ function appSupabaseScope(repoRoot) {
|
|
|
100
96
|
* being the apps with neither. `declaration` is the parsed hfs.json. `outDir` (absolute) redirects the snapshots to another
|
|
101
97
|
* root, keeping their relative paths.
|
|
102
98
|
*
|
|
103
|
-
* On the real write pass (`outDir` is `repoRoot`) the app's
|
|
99
|
+
* On the real write pass (`outDir` is `repoRoot`) the app's database types are written too when the slot `app.db.types`
|
|
104
100
|
* is enabled: `resolver` is the app-scope slot view (built from the declaration at the app root when not passed), `appRoot`
|
|
105
|
-
* overrides where the types land, and `run` is the command runner `writeDbTypes` spawns `
|
|
101
|
+
* overrides where the types land, and `run` is the command runner `writeDbTypes` spawns `psql` with. `types` in the answer
|
|
106
102
|
* is `writeDbTypes`'s `{ path, changed }`, or null for an app without the slot or a redirected pass.
|
|
107
103
|
*/
|
|
108
104
|
export function emitContracts({ repoRoot, declaration, outDir = repoRoot, resolver, appRoot, run } = {}) {
|
|
@@ -137,7 +133,7 @@ export function emitContracts({ repoRoot, declaration, outDir = repoRoot, resolv
|
|
|
137
133
|
// The generated Database types are an app-level artifact of the write pass only: a redirected outDir is the R23 check
|
|
138
134
|
// mode, and L09 judges drift on the same emitted text through the injected emitTypes (emit/db-types.mjs dbTypesEmitter).
|
|
139
135
|
if (outDir === repoRoot) {
|
|
140
|
-
const scope = resolver === undefined ?
|
|
136
|
+
const scope = resolver === undefined ? appDbScope(repoRoot) : { appRoot: locateDeclaration(repoRoot).appRoot, resolver };
|
|
141
137
|
const target = appRoot ?? scope?.appRoot;
|
|
142
138
|
if (target !== null && target !== undefined && scope?.resolver != null && appHasDbTypes(scope.resolver)) types = writeDbTypes({ root: target, run });
|
|
143
139
|
}
|
package/lint/run.mjs
CHANGED
|
@@ -85,6 +85,15 @@ export function parseLintArgs(argv) {
|
|
|
85
85
|
/** The typed ESLint run reads nothing above the app root: its TypeScript `sys` is bound by this preload (3.3, bound-sys.cjs). */
|
|
86
86
|
const BOUND_ENV = 'STARCI_LINT_BOUND';
|
|
87
87
|
const linterBoundArgs = () => ['--require', fileURLToPath(new URL('./bound-sys.cjs', import.meta.url))];
|
|
88
|
+
/**
|
|
89
|
+
* The heap of the ESLint child in MiB: the starci CLI sets it from its one owner, the eslint memory of ops/liveness.yaml `heavy` (a typed whole-side
|
|
90
|
+
* lint of a large app outgrows node's default heap). Unset, ESLint runs on node's default.
|
|
91
|
+
*/
|
|
92
|
+
export const ESLINT_HEAP_ENV = 'STARCI_ESLINT_HEAP_MB';
|
|
93
|
+
export function eslintHeapArgs(env = process.env) {
|
|
94
|
+
const mb = Number(env[ESLINT_HEAP_ENV]);
|
|
95
|
+
return Number.isInteger(mb) && mb > 0 ? [`--max-old-space-size=${mb}`] : [];
|
|
96
|
+
}
|
|
88
97
|
|
|
89
98
|
/** The child `node` ran with `args` from `cwd`: its exit status, signal, spawn error and the text of both streams, once it closes. */
|
|
90
99
|
function runNode(args, options) {
|
|
@@ -103,7 +112,7 @@ function runNode(args, options) {
|
|
|
103
112
|
}
|
|
104
113
|
|
|
105
114
|
/** A linter's json results through the app's own install, run from `cwd` (a side folder): `{ results }` or `{ error }`. The child runs while the caller goes on. */
|
|
106
|
-
async function runLinter({ cwd, pkg, bin, args, bound = null }) {
|
|
115
|
+
export async function runLinter({ cwd, pkg, bin, args, bound = null }) {
|
|
107
116
|
let entry;
|
|
108
117
|
try {
|
|
109
118
|
const manifest = createRequire(path.join(cwd, 'package.json')).resolve(`${pkg}/package.json`);
|
|
@@ -112,7 +121,8 @@ async function runLinter({ cwd, pkg, bin, args, bound = null }) {
|
|
|
112
121
|
} catch {
|
|
113
122
|
return { error: `${pkg} is not installed for ${cwd}` };
|
|
114
123
|
}
|
|
115
|
-
const
|
|
124
|
+
const heap = pkg === 'eslint' ? eslintHeapArgs() : [];
|
|
125
|
+
const run = await runNode([...heap, ...(bound ? linterBoundArgs() : []), entry, ...args], { cwd, ...(bound ? { env: { ...process.env, [BOUND_ENV]: bound } } : {}) });
|
|
116
126
|
// ESLint prints its report on stdout; stylelint uses stderr. JSON does not prove a completed child: only exits 0/1
|
|
117
127
|
// without a spawn error or signal are measurable, and exit 1 must carry findings.
|
|
118
128
|
let results;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starci/hfs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"description": "The StarCi app command implementation for scaffolding, linting, checking and synchronizing one product repository.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,20 +26,22 @@
|
|
|
26
26
|
"smol-toml": "1.9.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@typescript-eslint/eslint-plugin": "8.71.0",
|
|
30
|
-
"@typescript-eslint/parser": "8.71.0",
|
|
31
29
|
"@graphql-codegen/cli": "7.4.6",
|
|
32
30
|
"@graphql-codegen/client-preset": "6.2.3",
|
|
33
31
|
"@nestjs/common": "11.2.5",
|
|
34
32
|
"@nestjs/core": "11.2.5",
|
|
35
33
|
"@nestjs/graphql": "13.4.5",
|
|
36
34
|
"@nestjs/testing": "11.2.5",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "8.71.0",
|
|
36
|
+
"@typescript-eslint/parser": "8.71.0",
|
|
37
37
|
"class-validator": "0.15.1",
|
|
38
38
|
"eslint": "10.11.0",
|
|
39
39
|
"graphql": "16.14.2",
|
|
40
|
+
"pg": "8.23.1",
|
|
40
41
|
"prettier": "3.9.6",
|
|
41
42
|
"reflect-metadata": "0.2.2",
|
|
42
43
|
"rxjs": "7.8.2",
|
|
44
|
+
"typeorm": "0.3.31",
|
|
43
45
|
"typescript": "5.9.3",
|
|
44
46
|
"zod": "4.6.7"
|
|
45
47
|
},
|
package/release/gate.mjs
CHANGED
|
@@ -8,9 +8,11 @@ import fs from 'node:fs';
|
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { isPlainObject as plain } from '../runtime/engine/plain-object.mjs';
|
|
10
10
|
import { qualityServices } from '../runtime/scripts/hfs/ci-declaration.mjs';
|
|
11
|
+
import { openHfs } from '../runtime/scripts/hfs/slots.mjs';
|
|
11
12
|
import { firstLine, lines, tool } from '../stack/context.mjs';
|
|
12
13
|
import { failure, refusal } from '../stack/errors.mjs';
|
|
13
14
|
import { produceLintReports } from './lint-report.mjs';
|
|
15
|
+
import { URGENT_RULING, l4Path, readUrgent, recordRow, writeUrgent } from './records.mjs';
|
|
14
16
|
import { sonarQualityGate } from './sonar-quality-gate.mjs';
|
|
15
17
|
|
|
16
18
|
export const RELEASE_CODE = 'RELEASE_CONFIG_INVALID';
|
|
@@ -31,13 +33,13 @@ export const VERSION = /^(\d+)\.(\d+)\.(\d+)$/u;
|
|
|
31
33
|
const THRESHOLD_MISS = /coverage threshold .* not met/gu;
|
|
32
34
|
const WRAPPED = new Set(['npm', 'npx']);
|
|
33
35
|
// Every row the managed CI runs, so a release that does not wait for its candidate CI (release.requireCi false) still ran them all locally:
|
|
34
|
-
// fast (audit, format, typecheck), lint, test + coverage (the managed `test` script is the per-file 100 threshold), build, the lite database lint
|
|
36
|
+
// fast (audit, format, typecheck), lint, test + coverage (the managed `test` script is the per-file 100 threshold), build, the lite database lint, and Sonar.
|
|
35
37
|
const SCRIPT_GATES = ['format:check', 'typecheck', 'build:be', 'lint', 'db:lint', 'build:fe', 'test'];
|
|
36
38
|
// A full app has a test world (integration, e2e and contract projects, always present: the managed `test:e2e` script marks it), so those layers are rows of its gate;
|
|
37
39
|
// a lite app's integration project exists only where it has integration specs, so it has no world rows.
|
|
38
40
|
const WORLD_SCRIPTS = ['test:integration', 'test:e2e', 'test:contract'];
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
+
// An app with an entity list (db/entity-list.mjs) checks its entities against the migrated schema: a row of every gate, declared or default.
|
|
42
|
+
const DB_DRIFT = { name: 'db-drift', command: ['npx', 'starci', 'app', 'db', 'drift'], summary: null, env: {} };
|
|
41
43
|
|
|
42
44
|
/** True for a branch or remote name git can take as one argument (no leading dash, only path-like characters). */
|
|
43
45
|
export const refName = (value) => typeof value === 'string' && REF_NAME.test(value);
|
|
@@ -49,21 +51,11 @@ const scriptGate = (script) => ({
|
|
|
49
51
|
env: {},
|
|
50
52
|
});
|
|
51
53
|
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
* The stop is the teardown of the start (`teardownOf`): it runs whenever the start ran, also after a red row, so a failed database row never leaves Supabase running.
|
|
55
|
-
*/
|
|
56
|
-
function dbTypesGates(scripts) {
|
|
57
|
-
if (!DB_TYPES_SCRIPTS.every((script) => typeof scripts?.[script] === 'string')) return [];
|
|
58
|
-
const [start, reset, types, stop] = DB_TYPES_SCRIPTS.map(scriptGate);
|
|
59
|
-
return [start, reset, types, DB_TYPES_COMMITTED, { ...stop, teardownOf: start.name }];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** Default gates run app-check, the enabled audit, then every managed script present in the app and the database-types rows, Sonar following when it is declared. */
|
|
63
|
-
function defaultGates(scripts, audit) {
|
|
54
|
+
/** Default gates run app-check, the enabled audit, then every managed script present in the app and the entity drift row, Sonar following when it is declared. */
|
|
55
|
+
function defaultGates(scripts, audit, entities) {
|
|
64
56
|
const present = SCRIPT_GATES.filter((script) => typeof scripts?.[script] === 'string');
|
|
65
57
|
const world = typeof scripts?.['test:e2e'] === 'string' ? WORLD_SCRIPTS.filter((script) => typeof scripts?.[script] === 'string') : [];
|
|
66
|
-
return [{ name: 'app-check', command: ['npx', 'starci', 'app', 'check'], summary: null, env: {} }, ...(audit ? [audit] : []), ...present.map(scriptGate), ...world.map(scriptGate), ...
|
|
58
|
+
return [{ name: 'app-check', command: ['npx', 'starci', 'app', 'check'], summary: null, env: {} }, ...(audit ? [audit] : []), ...present.map(scriptGate), ...world.map(scriptGate), ...(entities ? [DB_DRIFT] : [])];
|
|
67
59
|
}
|
|
68
60
|
|
|
69
61
|
/** Shared quality settings retain the release reader's audit validation, disabled mode and legacy string host compatibility. */
|
|
@@ -148,8 +140,9 @@ export function normalizeRelease(block, scripts = {}, services = {}, options = {
|
|
|
148
140
|
if (typeof requireCi !== 'boolean') problems.push('release.requireCi: must be true or false');
|
|
149
141
|
const quality = releaseServices(services, options);
|
|
150
142
|
const audit = auditGate(quality.audit);
|
|
151
|
-
const gates = raw.gates === undefined ? defaultGates(scripts, audit) : gatesOf(raw.gates, problems);
|
|
143
|
+
const gates = raw.gates === undefined ? defaultGates(scripts, audit, options.entities === true) : gatesOf(raw.gates, problems);
|
|
152
144
|
if (raw.gates !== undefined && audit && !gates.some((gate) => gate.name === 'audit')) gates.push(audit);
|
|
145
|
+
if (raw.gates !== undefined && options.entities === true && !gates.some((gate) => gate.name === DB_DRIFT.name)) gates.push(DB_DRIFT);
|
|
153
146
|
return problems.length === 0 ? { config: { gates, tagPrefix, defaultBranch, requireCi, services: quality } } : { problems };
|
|
154
147
|
}
|
|
155
148
|
|
|
@@ -175,7 +168,22 @@ export function annotatedOnHead(ctx, prefix) {
|
|
|
175
168
|
/** Every tag on HEAD whose name ends in a version, annotated or not, under any prefix: a release commit carries exactly one. */
|
|
176
169
|
const versionTagsOnHead = (ctx) => lines(git(ctx, ['tag', '--points-at', 'HEAD']).stdout).filter((name) => /[0-9]+[.][0-9]+[.][0-9]+$/u.test(name));
|
|
177
170
|
|
|
178
|
-
|
|
171
|
+
/** The rewrittenBy predicate of the app's slots: true for a path a dev server writes (hfs slots `rewrittenBy`); without a readable hfs.json, for none. */
|
|
172
|
+
function rewrittenByDevServer(root) {
|
|
173
|
+
let hfs;
|
|
174
|
+
try { hfs = openHfs({ repoRoot: root }); } catch { return () => false; }
|
|
175
|
+
return (file) => typeof hfs.slotOf(file)?.rewrittenBy === 'string';
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The paths that make the tree dirty: every changed tracked path and every untracked one, except an untracked file the app's slots declare a dev
|
|
180
|
+
* server rewrites (`rewrittenBy`, e.g. the AGENTS.md `next dev` writes): that one is known generated output, never a change of the release.
|
|
181
|
+
*/
|
|
182
|
+
export function dirtyPaths(ctx) {
|
|
183
|
+
const rewritten = rewrittenByDevServer(ctx.cwd);
|
|
184
|
+
return lines(git(ctx, ['status', '--porcelain', '--untracked-files=all']).stdout)
|
|
185
|
+
.filter((line) => !(line.startsWith('?? ') && rewritten(line.slice(3).replace(/^"|"$/gu, ''))));
|
|
186
|
+
}
|
|
179
187
|
|
|
180
188
|
/** Tag names that exist locally or on the remote. */
|
|
181
189
|
function takenTags(ctx, prefix, remote) {
|
|
@@ -243,7 +251,7 @@ async function sonarAvailability(ctx, gate) {
|
|
|
243
251
|
}
|
|
244
252
|
|
|
245
253
|
/** An unreachable Sonar host stays a red row with a real log and no scan invocation. */
|
|
246
|
-
async function runAvailableGate(ctx, gate, options) {
|
|
254
|
+
export async function runAvailableGate(ctx, gate, options) {
|
|
247
255
|
const availability = await sonarAvailability(ctx, gate);
|
|
248
256
|
const log = path.join(options.dir, `${gate.name}.log`);
|
|
249
257
|
if (!availability) {
|
|
@@ -274,12 +282,12 @@ async function judgeQualityGate(ctx, gate, row) {
|
|
|
274
282
|
return { ...row, pass: verdict.pass, detail: verdict.detail, seconds: row.seconds + Math.round((ctx.now() - started) / 1000), logSha256: sha256(row.log) };
|
|
275
283
|
}
|
|
276
284
|
|
|
277
|
-
const withoutCredentials = (values, credentialNames) => {
|
|
285
|
+
export const withoutCredentials = (values, credentialNames) => {
|
|
278
286
|
const selected = new Set(credentialNames);
|
|
279
287
|
return Object.fromEntries(Object.entries(values ?? {}).filter(([key]) => !selected.has(key.toUpperCase())));
|
|
280
288
|
};
|
|
281
289
|
|
|
282
|
-
function runGate(ctx, gate, { dir, platform, credentialNames, preface = '' }) {
|
|
290
|
+
export function runGate(ctx, gate, { dir, platform, credentialNames, preface = '' }) {
|
|
283
291
|
const log = path.join(dir, `${gate.name}.log`);
|
|
284
292
|
const started = ctx.now();
|
|
285
293
|
const [command, args] = launch(gate.command, platform);
|
|
@@ -323,7 +331,7 @@ function tagLine({ tag, state }) {
|
|
|
323
331
|
}
|
|
324
332
|
|
|
325
333
|
/** Everything that can be known without running a gate: the facts, the red preconditions and the lines that describe them. */
|
|
326
|
-
function inspect(ctx, config, options) {
|
|
334
|
+
export function inspect(ctx, config, options) {
|
|
327
335
|
const head = git(ctx, ['rev-parse', 'HEAD']).stdout;
|
|
328
336
|
const branch = git(ctx, ['rev-parse', '--abbrev-ref', 'HEAD'], { allowFail: true }).stdout;
|
|
329
337
|
const out = [`checkout ${ctx.cwd}`, `HEAD ${head} (${branch})`];
|
|
@@ -354,18 +362,19 @@ function planLines(config, facts, dir, recordPath) {
|
|
|
354
362
|
return out;
|
|
355
363
|
}
|
|
356
364
|
|
|
357
|
-
function assertUnmoved(ctx, head) {
|
|
365
|
+
export function assertUnmoved(ctx, head) {
|
|
358
366
|
const now = git(ctx, ['rev-parse', 'HEAD']).stdout;
|
|
359
367
|
if (now !== head) throw failure('RELEASE_HEAD_MOVED', `HEAD moved during the gates (${head.slice(0, 10)} -> ${now.slice(0, 10)}). No record.`);
|
|
360
368
|
const dirty = dirtyPaths(ctx);
|
|
361
369
|
if (dirty.length > 0) throw failure('RELEASE_TREE_DIRTY', `the gates left ${dirty.length} changed or untracked path(s) (first: ${dirty[0].slice(0, 100)}): generated files differ from HEAD. Commit or ignore them properly, then rerun. No record.`);
|
|
362
370
|
}
|
|
363
371
|
|
|
364
|
-
function writeRecord(ctx, { head, tag, results, recordPath, requireCi }) {
|
|
372
|
+
function writeRecord(ctx, { head, tag, results, recordPath, requireCi, promotedFrom = null }) {
|
|
365
373
|
const record = {
|
|
366
374
|
schema: 'starci-app-l4-record/1', head, tag, createdAt: new Date(ctx.now()).toISOString(), producedBy: 'starci app release gate',
|
|
367
375
|
note: 'Every gate passed on a clean HEAD; every entry links its log and sha256.',
|
|
368
376
|
ci: requireCi === true ? { required: true, note: 'starci app release push waits for the candidate CI of this sha (release.requireCi=true)' } : { required: false, note: CI_NOT_REQUIRED },
|
|
377
|
+
...(promotedFrom ? { promotedFrom } : {}),
|
|
369
378
|
gates: results,
|
|
370
379
|
};
|
|
371
380
|
fs.mkdirSync(path.dirname(recordPath), { recursive: true });
|
|
@@ -381,17 +390,48 @@ async function runAll(ctx, config, options) {
|
|
|
381
390
|
return config.gates.reduce(async (pending, gate) => {
|
|
382
391
|
const results = await pending;
|
|
383
392
|
if (results.some((result) => !result.pass) && !(gate.teardownOf && results.some((result) => result.name === gate.teardownOf))) return results;
|
|
384
|
-
|
|
393
|
+
const result = await runAvailableGate(ctx, gate, options);
|
|
394
|
+
recordRow(options.common, options.head, result);
|
|
395
|
+
return [...results, result];
|
|
385
396
|
}, Promise.resolve([]));
|
|
386
397
|
}
|
|
387
398
|
|
|
388
|
-
function summaryOf(result) {
|
|
399
|
+
export function summaryOf(result) {
|
|
389
400
|
return `${result.pass ? 'PASS' : 'FAIL'} ${result.name} (${result.detail}, ${result.seconds}s) log ${result.log}`;
|
|
390
401
|
}
|
|
391
402
|
|
|
403
|
+
/**
|
|
404
|
+
* The urgent release a back-fill judges: `tag` must name HEAD (the back-fill runs on the very commit that shipped, never a re-release) and HEAD must
|
|
405
|
+
* carry an urgent record of that tag. Returns the record; refuses otherwise.
|
|
406
|
+
*/
|
|
407
|
+
function backfillTarget(ctx, common, tag, head) {
|
|
408
|
+
if (!refName(tag)) throw refusal('RELEASE_USAGE', `--backfill ${tag} is not a tag name`);
|
|
409
|
+
const resolved = git(ctx, ['rev-parse', '--verify', '--quiet', `refs/tags/${tag}^{commit}`], { allowFail: true });
|
|
410
|
+
if (resolved.code !== 0 || resolved.stdout === '') throw refusal('RELEASE_BACKFILL_TAG_UNKNOWN', `no tag ${tag} in this repository`);
|
|
411
|
+
if (resolved.stdout !== head) throw refusal('RELEASE_BACKFILL_NOT_ON_TAG', `${tag} is ${resolved.stdout.slice(0, 10)} but HEAD is ${head.slice(0, 10)}: run the back-fill in a clean checkout of the tag (git worktree add --detach <dir> ${tag}), so the full gate judges exactly what shipped`);
|
|
412
|
+
const urgent = readUrgent(common, head);
|
|
413
|
+
if (!urgent || urgent.tag !== tag) throw refusal('RELEASE_BACKFILL_NOT_URGENT', `${tag} has no urgent record on ${head.slice(0, 10)}: only a release pushed with release push --urgent is back-filled`);
|
|
414
|
+
return urgent;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/** A red back-fill: the urgent record keeps the verdict and the fix ticket (kind verify) the harness opened; nothing on the remote or on prod changes. */
|
|
418
|
+
function backfillRed(ctx, { common, urgent, failed, openTicket }) {
|
|
419
|
+
const names = failed.map((item) => item.name);
|
|
420
|
+
const title = `RELEASE_BACKFILL_RED: the back-fill of urgent release ${urgent.tag} (${urgent.head.slice(0, 12)}) is red at ${names.join(', ')}`;
|
|
421
|
+
const tail = failed.map((item) => `${item.name}: ${item.detail} (log ${item.log})`).join('\n');
|
|
422
|
+
const ticket = typeof openTicket === 'function' ? openTicket({ title, tail, code: 'RELEASE_BACKFILL_RED', tag: urgent.tag, head: urgent.head }) : null;
|
|
423
|
+
writeUrgent(common, { ...urgent, backfill: { state: 'red', at: new Date(ctx.now()).toISOString(), failed: names, ticket: ticket ?? null } });
|
|
424
|
+
const said = ticket
|
|
425
|
+
? `back-fill red: fix ticket ${ticket} opened (kind verify); ${urgent.tag} stays an urgent release and nothing on the remote or on prod changed`
|
|
426
|
+
: `back-fill red: no ticket queue in this run (run it through the starci CLI to open one); ${urgent.tag} stays an urgent release and nothing on the remote or on prod changed`;
|
|
427
|
+
return { said, ticket: ticket ?? null };
|
|
428
|
+
}
|
|
429
|
+
|
|
392
430
|
/**
|
|
393
431
|
* `starci app release gate`: dry run prints the preconditions, the gate list, the head and the tag; --execute runs every gate and, only if required gates pass,
|
|
394
|
-
* writes the L4 record and creates the annotated tag. options: { execute, sonar, source, tagPrefix, platform }.
|
|
432
|
+
* writes the L4 record and creates the annotated tag. options: { execute, sonar, source, tagPrefix, platform, backfill, openTicket }.
|
|
433
|
+
* With `backfill` (a tag pushed by `release push --urgent`, checked out at HEAD) the same full gate judges that commit: green writes its L4 record
|
|
434
|
+
* (promotedFrom the urgent record) and marks the urgent record promoted, with no new tag and no push; red opens a fix ticket through `openTicket`.
|
|
395
435
|
*/
|
|
396
436
|
export async function releaseGate(ctx, config, options = {}) {
|
|
397
437
|
// Sonar is a row of the managed CI, so it is a row of the local gate whenever the app declares it (and when --sonar asks for it); a missing token is a refusal, never a skip.
|
|
@@ -402,18 +442,29 @@ export async function releaseGate(ctx, config, options = {}) {
|
|
|
402
442
|
// the gate no longer refuses over the latest default-branch run.
|
|
403
443
|
const facts = inspect(ctx, config, options);
|
|
404
444
|
const common = releaseDir(ctx);
|
|
405
|
-
const
|
|
445
|
+
const urgent = options.backfill === undefined ? null : backfillTarget(ctx, common, options.backfill, facts.head);
|
|
446
|
+
const recordPath = l4Path(common, facts.head);
|
|
406
447
|
const dir = path.join(common, facts.head.slice(0, 12));
|
|
407
448
|
const plan = [...facts.out, ...planLines(config, facts, dir, recordPath)];
|
|
408
|
-
|
|
449
|
+
if (urgent) plan.push(`back-fill urgent release ${urgent.tag} (${URGENT_RULING}): green promotes it to this L4 record with no new tag and no push; red opens a fix ticket and changes nothing on prod`);
|
|
450
|
+
const base = { head: facts.head, tag: facts.chosen.tag, record: recordPath, gates: config.gates.map((gate) => gate.name), ...(urgent ? { backfill: urgent.tag } : {}) };
|
|
451
|
+
if (urgent?.backfill?.state === 'promoted') return { ok: true, lines: [...plan, `back-fill already promoted ${urgent.tag} to ${urgent.backfill.l4}. Nothing to do.`], data: { ...base, red: [], executed: false, promoted: true } };
|
|
409
452
|
if (facts.red.length > 0) return { ok: false, lines: [...plan, ...facts.red.map((item) => `RED: ${item}`), 'nothing was run.'], data: { ...base, red: facts.red, executed: false } };
|
|
410
453
|
if (options.execute !== true) return { ok: true, lines: [...plan, '', 'dry run: no gate was run, nothing written. preconditions OK.'], data: { ...base, red: [], executed: false } };
|
|
411
|
-
const results = await runAll(ctx, config, { dir, platform: options.platform ?? process.platform, credentialNames });
|
|
454
|
+
const results = await runAll(ctx, config, { dir, common, head: facts.head, platform: options.platform ?? process.platform, credentialNames });
|
|
412
455
|
const report = results.map(summaryOf);
|
|
413
456
|
const failed = results.filter((result) => !result.pass);
|
|
457
|
+
if (failed.length > 0 && urgent) {
|
|
458
|
+
const { said, ticket } = backfillRed(ctx, { common, urgent, failed, openTicket: options.openTicket });
|
|
459
|
+
return { ok: false, lines: [...plan, ...report, `gate(s) red: ${failed.map((item) => item.name).join(', ')}. No L4 record.`, said], data: { ...base, executed: true, results, promoted: false, ticket } };
|
|
460
|
+
}
|
|
414
461
|
if (failed.length > 0) return { ok: false, lines: [...plan, ...report, `gate(s) red: ${failed.map((item) => item.name).join(', ')}. No L4 record, no tag.`], data: { ...base, executed: true, results } };
|
|
415
462
|
assertUnmoved(ctx, facts.head);
|
|
416
|
-
writeRecord(ctx, { head: facts.head, tag: facts.chosen.tag, results, recordPath, requireCi: config.requireCi });
|
|
463
|
+
writeRecord(ctx, { head: facts.head, tag: facts.chosen.tag, results, recordPath, requireCi: config.requireCi, promotedFrom: urgent ? { record: `${facts.head}.urgent.json`, reason: urgent.reason, role: urgent.role, at: urgent.createdAt } : null });
|
|
464
|
+
if (urgent) {
|
|
465
|
+
writeUrgent(common, { ...urgent, backfill: { state: 'promoted', at: new Date(ctx.now()).toISOString(), l4: recordPath } });
|
|
466
|
+
return { ok: true, lines: [...plan, ...report, `L4 record written: ${recordPath}`, `back-fill green: urgent release ${urgent.tag} is promoted to a normal L4 release (no re-release, no push)`], data: { ...base, executed: true, results, promoted: true } };
|
|
467
|
+
}
|
|
417
468
|
const created = facts.chosen.state !== 'on-head';
|
|
418
469
|
if (created) git(ctx, ['tag', '-a', facts.chosen.tag, '-m', `release ${facts.chosen.tag}: required gates passed on ${facts.head.slice(0, 12)} (L4 record ${path.basename(recordPath)})`, facts.head]);
|
|
419
470
|
const tagged = created ? `annotated tag ${facts.chosen.tag} created on ${facts.head.slice(0, 10)}` : `annotated tag ${facts.chosen.tag} already on ${facts.head.slice(0, 10)}`;
|
package/release/index.mjs
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
// index.mjs - `starci app release <gate|push>` and the plumbing the release and database verbs share: the context built from the app's IO, strict flag
|
|
2
2
|
// parsing, the optional `release:` / `database:` blocks of .starcistacks/application-stacks.yaml, text and --json output and the exit-code mapping.
|
|
3
|
-
// starci app release gate [--execute] [--sonar] [--source <ref>] [--tag-prefix <prefix>] [--json]
|
|
4
|
-
// starci app release push [--execute] [--remote <name>] [--json]
|
|
3
|
+
// starci app release gate [--execute] [--sonar] [--source <ref>] [--tag-prefix <prefix>] [--backfill <tag>] [--json]
|
|
4
|
+
// starci app release push [--execute] [--remote <name>] [--urgent --reason <text>] [--json]
|
|
5
|
+
// `harness` of the app IO ({ version, role, openTicket }) is what the starci CLI hands in: the caller's role an urgent record names and the ticket
|
|
6
|
+
// queue a red back-fill files into.
|
|
5
7
|
// Every action is a dry run unless --execute is given. A refusal is a StackError (exit 2); a failed step returns ok false (exit 1).
|
|
6
8
|
import fs from 'node:fs';
|
|
7
9
|
import path from 'node:path';
|
|
8
10
|
import { isPlainObject as plain } from '../runtime/engine/plain-object.mjs';
|
|
9
11
|
import { parseYaml } from '../runtime/engine/yaml.mjs';
|
|
10
12
|
import { isRuntimeExampleApp } from '../runtime/scripts/lib/runtime-example.mjs';
|
|
13
|
+
import { hasEntityList } from '../db/entity-list.mjs';
|
|
11
14
|
import { STACKS_DIR, STACKS_FILE } from '../stack/config.mjs';
|
|
12
15
|
import { stackContext } from '../stack/context.mjs';
|
|
13
16
|
import { EXIT, StackError, refusal } from '../stack/errors.mjs';
|
|
14
17
|
import { RELEASE_CODE, VERSION, normalizeRelease, releaseGate } from './gate.mjs';
|
|
15
18
|
import { releasePush } from './push.mjs';
|
|
19
|
+
import { releaseUrgentPush } from './urgent.mjs';
|
|
16
20
|
|
|
17
21
|
const IO_KEYS = ['cwd', 'stdout', 'stderr', 'env', 'sops'];
|
|
18
22
|
|
|
@@ -58,7 +62,7 @@ function loadReleaseConfig(root) {
|
|
|
58
62
|
const pkg = readPackage(root);
|
|
59
63
|
if (typeof pkg.version !== 'string' || !VERSION.test(pkg.version)) throw refusal(RELEASE_CODE, 'package.json needs a version like 1.2.3 (the release tag derives from it)');
|
|
60
64
|
const declaration = readDeclaration(root);
|
|
61
|
-
const { config, problems } = normalizeRelease(declaration.release, pkg.scripts, declaration.services, { example: isRuntimeExampleApp(root) });
|
|
65
|
+
const { config, problems } = normalizeRelease(declaration.release, pkg.scripts, declaration.services, { example: isRuntimeExampleApp(root), entities: hasEntityList(root) });
|
|
62
66
|
if (!config) throw refusal(RELEASE_CODE, `${problems.length} problem(s) in release: ${problems.slice(0, 6).join('; ')}`);
|
|
63
67
|
return { root, version: pkg.version, ...config };
|
|
64
68
|
}
|
|
@@ -85,12 +89,19 @@ export async function runVerb({ label, name, io, argv, spec, run, code = 'RELEAS
|
|
|
85
89
|
|
|
86
90
|
const ACTIONS = {
|
|
87
91
|
gate: {
|
|
88
|
-
spec: { boolean: ['--execute', '--json', '--sonar'], value: ['--source', '--tag-prefix'] },
|
|
89
|
-
run: (ctx, flags) => releaseGate(ctx, loadReleaseConfig(ctx.cwd), {
|
|
92
|
+
spec: { boolean: ['--execute', '--json', '--sonar'], value: ['--source', '--tag-prefix', '--backfill'] },
|
|
93
|
+
run: (ctx, flags, harness) => releaseGate(ctx, loadReleaseConfig(ctx.cwd), {
|
|
94
|
+
execute: flags.execute === true, sonar: flags.sonar === true, source: flags.source, tagPrefix: flags['tag-prefix'], backfill: flags.backfill, openTicket: harness?.openTicket,
|
|
95
|
+
}),
|
|
90
96
|
},
|
|
91
97
|
push: {
|
|
92
|
-
spec: { boolean: ['--execute', '--json'], value: ['--remote'] },
|
|
93
|
-
run: (ctx, flags) =>
|
|
98
|
+
spec: { boolean: ['--execute', '--json', '--urgent'], value: ['--remote', '--reason'] },
|
|
99
|
+
run: (ctx, flags, harness) => {
|
|
100
|
+
if (flags.reason !== undefined && flags.urgent !== true) throw refusal('RELEASE_USAGE', '--reason belongs to an urgent release (--urgent)');
|
|
101
|
+
const config = loadReleaseConfig(ctx.cwd);
|
|
102
|
+
if (flags.urgent === true) return releaseUrgentPush(ctx, config, { execute: flags.execute === true, remote: flags.remote, reason: flags.reason, role: harness?.role ?? ctx.env.STARCI_ROLE });
|
|
103
|
+
return releasePush(ctx, config, { execute: flags.execute === true, remote: flags.remote });
|
|
104
|
+
},
|
|
94
105
|
},
|
|
95
106
|
};
|
|
96
107
|
|
|
@@ -101,5 +112,5 @@ export async function releaseMain(argv, io = {}) {
|
|
|
101
112
|
contextOf(io).stderr('starci app release: takes gate or push\n');
|
|
102
113
|
return EXIT.refused;
|
|
103
114
|
}
|
|
104
|
-
return runVerb({ label: 'starci app release', name: argv[0], io, argv: argv.slice(1), spec: action.spec, run: action.run });
|
|
115
|
+
return runVerb({ label: 'starci app release', name: argv[0], io, argv: argv.slice(1), spec: action.spec, run: (ctx, flags) => action.run(ctx, flags, io.harness) });
|
|
105
116
|
}
|
package/release/push.mjs
CHANGED
|
@@ -49,7 +49,7 @@ function remoteTagObject(ctx, remote, tag) {
|
|
|
49
49
|
return listed.map((line) => line.split('\t')).find((parts) => parts[1] === wanted)?.[0] ?? '';
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
function branchRefs(ctx, { head, remote, branch }, red) {
|
|
52
|
+
export function branchRefs(ctx, { head, remote, branch }, red) {
|
|
53
53
|
const tip = remoteTip(ctx, remote, branch);
|
|
54
54
|
if (tip === null || isAncestor(ctx, tip, head)) return { refs: tip === head ? [] : [`${head}:refs/heads/${branch}`], tip };
|
|
55
55
|
if (isAncestor(ctx, head, tip)) return { refs: [], tip };
|
|
@@ -57,14 +57,14 @@ function branchRefs(ctx, { head, remote, branch }, red) {
|
|
|
57
57
|
return { refs: [], tip };
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
function tagRefs(ctx, { remote, tag }, red) {
|
|
60
|
+
export function tagRefs(ctx, { remote, tag }, red) {
|
|
61
61
|
const object = remoteTagObject(ctx, remote, tag);
|
|
62
62
|
if (object === '') return [`refs/tags/${tag}`];
|
|
63
63
|
if (object !== git(ctx, ['rev-parse', `refs/tags/${tag}`]).stdout) red.push(`tag ${tag} exists on ${remote} as a different object`);
|
|
64
64
|
return [];
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
function probe(ctx, remote, refs, red) {
|
|
67
|
+
export function probe(ctx, remote, refs, red) {
|
|
68
68
|
const run = git(ctx, ['push', '--dry-run', '--atomic', remote, ...refs], { allowFail: true });
|
|
69
69
|
const verdict = `${run.stderr}\n${run.stdout}`.split('\n').filter((line) => VERDICT.test(line)).slice(0, 4);
|
|
70
70
|
if (run.code !== 0) red.push('the pre-push hook refuses this push as things stand');
|
|
@@ -73,7 +73,7 @@ function probe(ctx, remote, refs, red) {
|
|
|
73
73
|
|
|
74
74
|
const NAME_RULE = '^[A-Za-z0-9._/-]+$';
|
|
75
75
|
|
|
76
|
-
function assertNames(remote, branch) {
|
|
76
|
+
export function assertNames(remote, branch) {
|
|
77
77
|
if (!refName(remote)) throw refusal('RELEASE_USAGE', `--remote ${remote} must match ${NAME_RULE}`);
|
|
78
78
|
if (!refName(branch)) throw refusal('RELEASE_USAGE', `the default branch ${branch} must match ${NAME_RULE}`);
|
|
79
79
|
}
|