@basaltkit/deploy 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/commits.d.ts +14 -1
- package/dist/commits.js +41 -0
- package/dist/index.d.ts +1 -1
- package/dist/pipeline.js +4 -1
- package/dist/protocol.d.ts +13 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -208,7 +208,7 @@ As the app user, in the checkout (`node node_modules/@basaltkit/deploy/dist/bin.
|
|
|
208
208
|
| `run` | preflight → fetch → env → infra → build → validate → backup → migrate → release → health → record |
|
|
209
209
|
| `env` | the `.env` and the containers only |
|
|
210
210
|
| `rollback [--to=<sha>]` | the last healthy release. Code only — the database keeps its migrations. Holds the commit it left. |
|
|
211
|
-
| `status` | the last releases (who, from where), the process, the deploy lock, a hold |
|
|
211
|
+
| `status` | where the code comes from (remote, branch, address without credentials), the last releases (who, from where), the process, the deploy lock, a hold |
|
|
212
212
|
| `commits --from=<sha> --to=<sha>` | the commits between two releases. Read-only: no lock, no fetch. |
|
|
213
213
|
| `commits --rollback [--to=<sha>]` | what `rollback` would take out of production, to the commit it would choose |
|
|
214
214
|
| `install-plan [--out=<file>\|-]` | what `install` needs, as JSON (default `<state dir>/install-plan.json`, 0600), and the root command to run |
|
|
@@ -368,7 +368,7 @@ node node_modules/@basaltkit/deploy/dist/bin.js cancel 20261013T100000Z-5f2c9a1b
|
|
|
368
368
|
first signal: when the run was already cancelled once, from any client, it
|
|
369
369
|
is refused (`already-cancelled`) and nothing is signalled. A client that
|
|
370
370
|
asked for the mild cancel never sends the immediate one by surprise.
|
|
371
|
-
- `status --json` reports the lock, the active run and the last run.
|
|
371
|
+
- `status --json` reports the lock, the active run and the last run, and (0.9.0) `source`: the config's remote and branch, and the remote's address as `host/path`, never with credentials, a query or a local path.
|
|
372
372
|
- `--via=ui` records `via: "ui"` with the release; like `--actor`, it
|
|
373
373
|
attributes, it does not authenticate.
|
|
374
374
|
|
package/dist/commits.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DeployContext } from './context.js';
|
|
2
|
-
import { type CommitInfo, type Commits } from './protocol.js';
|
|
2
|
+
import { type CommitInfo, type Commits, type Source } from './protocol.js';
|
|
3
3
|
export declare const MAX_SUBJECT = 200;
|
|
4
4
|
export declare const MAX_AUTHOR = 100;
|
|
5
5
|
/** Per git call: a list of 50 capped commits is far below this; a huge one is cut, never read. */
|
|
@@ -37,3 +37,16 @@ export declare function incomingCommits(ctx: DeployContext, target: {
|
|
|
37
37
|
remote: string;
|
|
38
38
|
head: string;
|
|
39
39
|
}, skipFetch: boolean): Promise<Commits>;
|
|
40
|
+
/**
|
|
41
|
+
* A remote's address as a person reads it: `host[:port]/path`, without the
|
|
42
|
+
* scheme, any `user:token@`, a query, a fragment or `.git`. scp-like
|
|
43
|
+
* addresses (`git@host:org/repo.git`) too. A local path, `file://`, or
|
|
44
|
+
* anything outside a plain host-and-path grammar gives undefined: the
|
|
45
|
+
* address never carries a secret or a path of the server to the page.
|
|
46
|
+
*/
|
|
47
|
+
export declare function describeRemoteUrl(raw: string): string | undefined;
|
|
48
|
+
/** The config's remote and branch, and where that remote points; never throws. */
|
|
49
|
+
export declare function remoteSource(ctx: DeployContext, target: {
|
|
50
|
+
remote: string;
|
|
51
|
+
branch: string;
|
|
52
|
+
}): Promise<Source>;
|
package/dist/commits.js
CHANGED
|
@@ -186,3 +186,44 @@ export async function incomingCommits(ctx, target, skipFetch) {
|
|
|
186
186
|
await git(ctx, ['update-ref', '-d', PREVIEW_REF]);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
+
const HOST_PATH = /^[A-Za-z0-9](?:[A-Za-z0-9.-]{0,252})(?::\d{1,5})?\/[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+){0,15}$/;
|
|
190
|
+
/**
|
|
191
|
+
* A remote's address as a person reads it: `host[:port]/path`, without the
|
|
192
|
+
* scheme, any `user:token@`, a query, a fragment or `.git`. scp-like
|
|
193
|
+
* addresses (`git@host:org/repo.git`) too. A local path, `file://`, or
|
|
194
|
+
* anything outside a plain host-and-path grammar gives undefined: the
|
|
195
|
+
* address never carries a secret or a path of the server to the page.
|
|
196
|
+
*/
|
|
197
|
+
export function describeRemoteUrl(raw) {
|
|
198
|
+
const text = raw.trim();
|
|
199
|
+
let host;
|
|
200
|
+
let path;
|
|
201
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(text)) {
|
|
202
|
+
let url;
|
|
203
|
+
try {
|
|
204
|
+
url = new URL(text);
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
if (!['https:', 'http:', 'ssh:', 'git:'].includes(url.protocol) || url.hostname === '')
|
|
210
|
+
return undefined;
|
|
211
|
+
host = url.port ? `${url.hostname}:${url.port}` : url.hostname;
|
|
212
|
+
path = url.pathname;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
const scp = /^(?:[^@/\s]+@)?([A-Za-z0-9][A-Za-z0-9.-]*):(?!\/)([^\s]+)$/.exec(text);
|
|
216
|
+
if (!scp)
|
|
217
|
+
return undefined;
|
|
218
|
+
host = scp[1];
|
|
219
|
+
path = scp[2];
|
|
220
|
+
}
|
|
221
|
+
const clean = `${host}/${path.replace(/^\/+/, '').replace(/\/+$/, '').replace(/\.git$/, '')}`;
|
|
222
|
+
return clean.length <= 200 && HOST_PATH.test(clean) ? clean : undefined;
|
|
223
|
+
}
|
|
224
|
+
/** The config's remote and branch, and where that remote points; never throws. */
|
|
225
|
+
export async function remoteSource(ctx, target) {
|
|
226
|
+
const answer = await git(ctx, ['remote', 'get-url', target.remote]);
|
|
227
|
+
const url = answer.ok && answer.code === 0 ? describeRemoteUrl(answer.stdout) : undefined;
|
|
228
|
+
return { remote: target.remote, branch: target.branch, ...(url ? { url } : {}) };
|
|
229
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,4 +13,4 @@ export { DeployLockedError, type LockHolder } from './lock.js';
|
|
|
13
13
|
export { EXIT_ABORTED, EXIT_LOCKED } from './cli.js';
|
|
14
14
|
export type { Hold, Release } from './state.js';
|
|
15
15
|
export type { Audit } from './audit.js';
|
|
16
|
-
export { parseEvent, parseAnswerLine, PROTOCOL_VERSION, STEP_IDS, ERROR_CODES, EVENT_TYPES, RUN_ID, type DeployEvent, type EventBody, type EventType, type Envelope, type HelloEvent, type StepStartEvent, type StepEndEvent, type LogEvent, type FindingEvent, type PromptEvent, type PromptDescriptor, type ResultEvent, type ErrorEvent, type DoneEvent, type AttachedEvent, type StepId, type StepStatus, type ErrorCode, type AnswerLine, type StatusResult, type CheckResult, type PlanResult, type RunResult, type RollbackResult, type EnvResult, type DetachResult, type CancelResult, type InstallPlanResult, } from './protocol.js';
|
|
16
|
+
export { parseEvent, parseAnswerLine, PROTOCOL_VERSION, STEP_IDS, ERROR_CODES, EVENT_TYPES, RUN_ID, type DeployEvent, type EventBody, type EventType, type Envelope, type HelloEvent, type StepStartEvent, type StepEndEvent, type LogEvent, type FindingEvent, type PromptEvent, type PromptDescriptor, type ResultEvent, type ErrorEvent, type DoneEvent, type AttachedEvent, type StepId, type StepStatus, type ErrorCode, type AnswerLine, type Source, type StatusResult, type CheckResult, type PlanResult, type RunResult, type RollbackResult, type EnvResult, type DetachResult, type CancelResult, type InstallPlanResult, } from './protocol.js';
|
package/dist/pipeline.js
CHANGED
|
@@ -13,7 +13,7 @@ import { applyInfra, describeInfra, dockerPostgres, maintainServices, planInfra
|
|
|
13
13
|
import { appRoleOf, describeServices, dumpContainer, dumpUrlKey, externalOf, externalPostgres, grantTenantSchemas } from './services.js';
|
|
14
14
|
import { pm2List, pm2Preflight, pm2Release, resolvePort } from './pm2.js';
|
|
15
15
|
import { clearHold, migrationNames, readHold, readReleases, recordRelease, rollbackTarget, writeHold } from './state.js';
|
|
16
|
-
import { commitRange, commitSubjects, incomingCommits, resolveCommit } from './commits.js';
|
|
16
|
+
import { commitRange, commitSubjects, incomingCommits, remoteSource, resolveCommit } from './commits.js';
|
|
17
17
|
import { acquireLock, describeHolder, readLock } from './lock.js';
|
|
18
18
|
import { auditOf } from './audit.js';
|
|
19
19
|
import { questionDescriptors } from './env-step.js';
|
|
@@ -887,6 +887,8 @@ export async function status(ctx) {
|
|
|
887
887
|
const { host } = ctx;
|
|
888
888
|
const releases = (await readReleases(ctx)).slice(-10).reverse();
|
|
889
889
|
host.out.step(`${ctx.config.app} — last ${releases.length} release(s)`);
|
|
890
|
+
const source = await remoteSource(ctx, gitTarget(ctx));
|
|
891
|
+
host.out.info(`source: ${source.remote}/${source.branch}${source.url ? ` (${source.url})` : ''}`);
|
|
890
892
|
const lock = await readLock(host, ctx.stateDir);
|
|
891
893
|
if (!lock)
|
|
892
894
|
host.out.info('no deploy running');
|
|
@@ -930,6 +932,7 @@ export async function status(ctx) {
|
|
|
930
932
|
hold: hold ?? null,
|
|
931
933
|
releases,
|
|
932
934
|
process: running,
|
|
935
|
+
source,
|
|
933
936
|
...await subjectsOf(ctx, releases),
|
|
934
937
|
});
|
|
935
938
|
}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -240,6 +240,17 @@ export interface PromptEvent extends Envelope, PromptDescriptor {
|
|
|
240
240
|
type: 'prompt';
|
|
241
241
|
attempt: number;
|
|
242
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* The config's remote and branch, and the remote's address for a person:
|
|
245
|
+
* host and path only (`github.com/acme/app`) — never credentials, a query or
|
|
246
|
+
* a local path. `url` is absent when git could not say or the address is
|
|
247
|
+
* not a plain host and path.
|
|
248
|
+
*/
|
|
249
|
+
export interface Source {
|
|
250
|
+
remote: string;
|
|
251
|
+
branch: string;
|
|
252
|
+
url?: string;
|
|
253
|
+
}
|
|
243
254
|
export interface StatusResult {
|
|
244
255
|
app: string;
|
|
245
256
|
stateDir: string;
|
|
@@ -268,6 +279,8 @@ export interface StatusResult {
|
|
|
268
279
|
releases: Release[];
|
|
269
280
|
/** The subject of each release's commit, by sha (`--json` only; absent when git could not say). */
|
|
270
281
|
subjects?: Record<string, string>;
|
|
282
|
+
/** Where a run fetches from (0.9.0+): which app a target really is. */
|
|
283
|
+
source?: Source;
|
|
271
284
|
process: {
|
|
272
285
|
kind: 'pm2';
|
|
273
286
|
name: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basaltkit/deploy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=22.5.0"
|
|
6
6
|
},
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^26.6.5",
|
|
29
29
|
"typescript": "^7.0.2",
|
|
30
|
-
"vitest": "^5.0.
|
|
30
|
+
"vitest": "^5.0.5",
|
|
31
31
|
"@basaltkit/tsconfig": "^0.24.0"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|