@steve31415/baselib 2.3.0 → 2.4.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/dist/bin/pw-deploy.d.ts +2 -0
- package/dist/bin/pw-deploy.js +15 -0
- package/dist/bin/pw-rollback.d.ts +2 -0
- package/dist/bin/pw-rollback.js +10 -0
- package/dist/deploy/config.d.ts +5 -0
- package/dist/deploy/config.js +67 -0
- package/dist/deploy/deploy.d.ts +13 -0
- package/dist/deploy/deploy.js +405 -0
- package/dist/deploy/evidence.d.ts +19 -0
- package/dist/deploy/evidence.js +60 -0
- package/dist/deploy/exec.d.ts +10 -0
- package/dist/deploy/exec.js +41 -0
- package/dist/deploy/gcs.d.ts +43 -0
- package/dist/deploy/gcs.js +189 -0
- package/dist/deploy/plan.d.ts +56 -0
- package/dist/deploy/plan.js +151 -0
- package/dist/deploy/rollback.d.ts +10 -0
- package/dist/deploy/rollback.js +176 -0
- package/dist/deploy/types.d.ts +119 -0
- package/dist/deploy/types.js +3 -0
- package/package.json +4 -2
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export interface ServiceHealth {
|
|
2
|
+
/** How the shared smoke reaches /health:
|
|
3
|
+
* - public-canonical: unauthenticated GET on the canonical URL
|
|
4
|
+
* - oidc-run-url: OIDC identity token with the service's run.app URL audience
|
|
5
|
+
* - oidc-audience: OIDC identity token with a fixed custom audience
|
|
6
|
+
* - none: no shared health check (app hook covers it) */
|
|
7
|
+
kind: 'public-canonical' | 'oidc-run-url' | 'oidc-audience' | 'none';
|
|
8
|
+
audience?: string;
|
|
9
|
+
path?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ServiceConfig {
|
|
12
|
+
name: string;
|
|
13
|
+
/** Canonical public URL (used by public-canonical health and printed). */
|
|
14
|
+
canonicalUrl?: string;
|
|
15
|
+
health: ServiceHealth;
|
|
16
|
+
}
|
|
17
|
+
export interface DeployConfig {
|
|
18
|
+
/** Short app name; prefixes the lock/hold/release objects. */
|
|
19
|
+
app: string;
|
|
20
|
+
project: string;
|
|
21
|
+
region: string;
|
|
22
|
+
/** GCS bucket holding lock, hold, release records, and retained assets. */
|
|
23
|
+
bucket: string;
|
|
24
|
+
/** Expected gcloud account (defaults to the fleet coding agent). */
|
|
25
|
+
account?: string;
|
|
26
|
+
image: {
|
|
27
|
+
arRepo: string;
|
|
28
|
+
name: string;
|
|
29
|
+
buildServiceAccount: string;
|
|
30
|
+
};
|
|
31
|
+
build: {
|
|
32
|
+
/** Command producing the deployable outputs; run with BUILD_ID=<sha>. */
|
|
33
|
+
command: string;
|
|
34
|
+
/** Repo-relative files/dirs copied into the sealed build context
|
|
35
|
+
* alongside Dockerfile, cloudbuild.yaml, package.json, package-lock.json. */
|
|
36
|
+
contextFiles: string[];
|
|
37
|
+
};
|
|
38
|
+
/** Gate commands run while the image builds; all must pass before traffic. */
|
|
39
|
+
gates: string[];
|
|
40
|
+
/** Default retained-asset publish (omit when a publishAssets hook or no
|
|
41
|
+
* assets exist): dir is repo-relative, prefix is bucket-relative. */
|
|
42
|
+
assets?: {
|
|
43
|
+
dir: string;
|
|
44
|
+
prefix: string;
|
|
45
|
+
};
|
|
46
|
+
/** Bucket-relative prefix for shared release records, e.g. "todo/pw-releases/". */
|
|
47
|
+
releasePrefix: string;
|
|
48
|
+
/** Secrets re-pinned on every routine deploy (name -> secret:version). */
|
|
49
|
+
updateSecrets?: Record<string, string>;
|
|
50
|
+
/** Refuse to deploy across a migrations/ diff (notes2 semantics). */
|
|
51
|
+
refuseMigrationDiffOnDeploy?: boolean;
|
|
52
|
+
/** Repo-relative path of an optional ES module exporting hooks. */
|
|
53
|
+
hooks?: string;
|
|
54
|
+
services: ServiceConfig[];
|
|
55
|
+
}
|
|
56
|
+
export interface ExecResult {
|
|
57
|
+
stdout: string;
|
|
58
|
+
stderr: string;
|
|
59
|
+
code: number;
|
|
60
|
+
}
|
|
61
|
+
export interface ExecOptions {
|
|
62
|
+
timeoutMs?: number;
|
|
63
|
+
cwd?: string;
|
|
64
|
+
env?: Record<string, string | undefined>;
|
|
65
|
+
input?: string;
|
|
66
|
+
}
|
|
67
|
+
/** Injected process runner; never throws on nonzero exit (code reports it). */
|
|
68
|
+
export type Runner = (file: string, args: string[], opts?: ExecOptions) => Promise<ExecResult>;
|
|
69
|
+
export interface ReleaseRecord {
|
|
70
|
+
sha: string;
|
|
71
|
+
at: string;
|
|
72
|
+
app: string;
|
|
73
|
+
services: {
|
|
74
|
+
name: string;
|
|
75
|
+
revision: string;
|
|
76
|
+
imageDigest: string;
|
|
77
|
+
}[];
|
|
78
|
+
timingsMs?: Record<string, number>;
|
|
79
|
+
}
|
|
80
|
+
export interface HoldRecord {
|
|
81
|
+
/** SHAs that must not deploy without an explicit override. */
|
|
82
|
+
heldShas: string[];
|
|
83
|
+
reason: string;
|
|
84
|
+
at: string;
|
|
85
|
+
}
|
|
86
|
+
export interface ServingState {
|
|
87
|
+
service: string;
|
|
88
|
+
revision: string;
|
|
89
|
+
/** BUILD_ID env of the serving revision; null before unification. */
|
|
90
|
+
buildSha: string | null;
|
|
91
|
+
imageDigest: string | null;
|
|
92
|
+
}
|
|
93
|
+
export interface HookContext {
|
|
94
|
+
sha: string;
|
|
95
|
+
/** Consistent serving base SHA across services, when determinable. */
|
|
96
|
+
baseSha: string | null;
|
|
97
|
+
config: DeployConfig;
|
|
98
|
+
repoRoot: string;
|
|
99
|
+
contextDir: string;
|
|
100
|
+
evidenceDir: string;
|
|
101
|
+
/** Resolved image digest (release phase onward). */
|
|
102
|
+
imageDigest?: string;
|
|
103
|
+
serving: ServingState[];
|
|
104
|
+
exec: Runner;
|
|
105
|
+
log: (message: string) => void;
|
|
106
|
+
}
|
|
107
|
+
export interface DeployHooks {
|
|
108
|
+
/** Runs after the local build, before the context is sealed. Overrides the
|
|
109
|
+
* default retained-asset publish when present. */
|
|
110
|
+
publishAssets?: (ctx: HookContext) => Promise<void>;
|
|
111
|
+
/** Runs after all gates pass, immediately before the first traffic switch. */
|
|
112
|
+
preRelease?: (ctx: HookContext) => Promise<void>;
|
|
113
|
+
/** Runs right after traffic moves (e.g. todo2's announce-build). */
|
|
114
|
+
postTraffic?: (ctx: HookContext) => Promise<void>;
|
|
115
|
+
/** Extra smoke checks after the shared health checks. */
|
|
116
|
+
smoke?: (ctx: HookContext) => Promise<void>;
|
|
117
|
+
/** Runs after everything else succeeded (e.g. notes2's release state). */
|
|
118
|
+
postSuccess?: (ctx: HookContext) => Promise<void>;
|
|
119
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steve31415/baselib",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Plasticine new-world shared platform library: logging, auth, service-to-service auth, db, HTTP, sync, app updates",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,7 +63,9 @@
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"bin": {
|
|
66
|
-
"check-test-owners": "./dist/bin/check-test-owners.js"
|
|
66
|
+
"check-test-owners": "./dist/bin/check-test-owners.js",
|
|
67
|
+
"pw-deploy": "./dist/bin/pw-deploy.js",
|
|
68
|
+
"pw-rollback": "./dist/bin/pw-rollback.js"
|
|
67
69
|
},
|
|
68
70
|
"engines": {
|
|
69
71
|
"node": "22.x"
|