@bluestep-systems/b6p-core 0.8.1 → 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 +58 -19
- package/dist/B6PCore.js +42 -0
- package/dist/B6PCore.js.map +1 -1
- package/dist/Err.d.ts +6 -0
- package/dist/Err.js +6 -0
- package/dist/Err.js.map +1 -1
- package/dist/data/ScriptKey.d.ts +3 -27
- package/dist/data/ScriptKey.js +12 -24
- package/dist/data/ScriptKey.js.map +1 -1
- package/dist/data/ScriptUrlParser.js +3 -1
- package/dist/data/ScriptUrlParser.js.map +1 -1
- package/dist/index.d.ts +10 -4
- package/dist/index.js +52 -6
- package/dist/index.js.map +1 -1
- package/dist/providers.d.ts +13 -0
- package/dist/script/GitIdentity.d.ts +48 -0
- package/dist/script/GitIdentity.js +52 -0
- package/dist/script/GitIdentity.js.map +1 -0
- package/dist/script/GitSync.d.ts +321 -0
- package/dist/script/GitSync.js +1001 -0
- package/dist/script/GitSync.js.map +1 -0
- package/dist/script/ScriptContext.d.ts +22 -0
- package/dist/script/ScriptFile.d.ts +0 -94
- package/dist/script/ScriptFile.js +0 -245
- package/dist/script/ScriptFile.js.map +1 -1
- package/dist/script/ScriptFolder.d.ts +0 -9
- package/dist/script/ScriptFolder.js +4 -7
- package/dist/script/ScriptFolder.js.map +1 -1
- package/dist/script/ScriptNode.d.ts +0 -9
- package/dist/script/ScriptNode.js.map +1 -1
- package/dist/script/ScriptRoot.d.ts +0 -2
- package/dist/script/ScriptRoot.js +0 -21
- package/dist/script/ScriptRoot.js.map +1 -1
- package/dist/script/ScriptService.d.ts +78 -8
- package/dist/script/ScriptService.js +126 -52
- package/dist/script/ScriptService.js.map +1 -1
- package/dist/script/ScriptTranspiler.d.ts +62 -0
- package/dist/script/ScriptTranspiler.js +97 -5
- package/dist/script/ScriptTranspiler.js.map +1 -1
- package/dist/script/push.d.ts +82 -148
- package/dist/script/push.js +145 -384
- package/dist/script/push.js.map +1 -1
- package/package.json +12 -8
- package/dist/script/SnapshotHistoryRecorder.d.ts +0 -47
- package/dist/script/SnapshotHistoryRecorder.js +0 -231
- package/dist/script/SnapshotHistoryRecorder.js.map +0 -1
package/dist/script/push.d.ts
CHANGED
|
@@ -1,30 +1,63 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type GitIdentity } from "@bluestep-systems/b6p-core-bsjs-git";
|
|
2
2
|
import type { ScriptContext } from "./ScriptContext";
|
|
3
|
+
import type { TypeCheckError } from "./ScriptTranspiler";
|
|
3
4
|
import type { FileSystem } from "../providers";
|
|
4
|
-
import {
|
|
5
|
+
import { type LastSyncedLookup, type PublishRefusal } from "./GitSync";
|
|
6
|
+
import type { ScriptRoot } from "./ScriptRoot";
|
|
7
|
+
/**
|
|
8
|
+
* The hashes a pre-git push or pull recorded for the files of a draft folder, as the lookup the git side uses to tell a
|
|
9
|
+
* local edit from a platform change in a folder that has no repository yet.
|
|
10
|
+
* @param scriptRoot The script whose metadata holds the records
|
|
11
|
+
* @param draftPath The draft folder the records' paths are under
|
|
12
|
+
* @lastreviewed null
|
|
13
|
+
*/
|
|
14
|
+
export declare function legacySyncRecords(scriptRoot: ScriptRoot, draftPath: string): Promise<LastSyncedLookup>;
|
|
5
15
|
/**
|
|
6
16
|
* Outcome of a push, for callers that need more signal than the human-facing
|
|
7
17
|
* messages — e.g. a CLI that must exit non-zero or emit `--json` when nothing
|
|
8
|
-
* was
|
|
9
|
-
*
|
|
10
|
-
*
|
|
18
|
+
* was pushed or a snapshot did not publish. Check `pushed` before reading
|
|
19
|
+
* anything else: a push that aborted early pushed nothing, regardless of what
|
|
20
|
+
* the other fields say.
|
|
11
21
|
* @lastreviewed null
|
|
12
22
|
*/
|
|
13
23
|
export interface PushResult {
|
|
14
24
|
/**
|
|
15
|
-
* True when the
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* consumer must not read as success.
|
|
25
|
+
* True when the draft is on the platform: the draft branch was pushed, or already matched. False when the push
|
|
26
|
+
* aborted before that (draft folder missing, or empty; or, on a snapshot push, the compiled `scripts/app.js`
|
|
27
|
+
* missing or blank) — a state a machine consumer must not read as success.
|
|
19
28
|
* @lastreviewed null
|
|
20
29
|
*/
|
|
21
30
|
pushed: boolean;
|
|
22
31
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
32
|
+
* The draft branch's head commit on the platform after the push: the commit this push made, or the one already
|
|
33
|
+
* there when nothing changed. `null` when `pushed` is false.
|
|
34
|
+
* @lastreviewed null
|
|
35
|
+
*/
|
|
36
|
+
commitSha: string | null;
|
|
37
|
+
/**
|
|
38
|
+
* The commit the platform published, on a snapshot push. `null` on a plain push, when the push aborted, and when the
|
|
39
|
+
* publish failed (`publishError` says why); a consumer asking for a snapshot must treat `null` as a failure.
|
|
40
|
+
* @lastreviewed null
|
|
41
|
+
*/
|
|
42
|
+
publishedSha: string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Why the platform refused or failed the publish of a snapshot push, when it did; the draft was pushed regardless.
|
|
45
|
+
* `null` otherwise.
|
|
46
|
+
* @lastreviewed null
|
|
47
|
+
*/
|
|
48
|
+
publishError: string | null;
|
|
49
|
+
/**
|
|
50
|
+
* The platform's structured refusal of the publish: `reason` and `withheld` from the server's `PUBLISH_REFUSED`
|
|
51
|
+
* extensions (every reason, `DRAFT_MOVED` and `BUILD_*` included). `null` when the publish was not refused.
|
|
25
52
|
* @lastreviewed null
|
|
26
53
|
*/
|
|
27
|
-
|
|
54
|
+
publishRefusal: PublishRefusal | null;
|
|
55
|
+
/**
|
|
56
|
+
* True when this push switched the script from WebDAV to git publishing. The switch is one-way: the script's draft
|
|
57
|
+
* and snapshot no longer accept WebDAV writes.
|
|
58
|
+
* @lastreviewed null
|
|
59
|
+
*/
|
|
60
|
+
switchedToGit: boolean;
|
|
28
61
|
/**
|
|
29
62
|
* Type-check outcome of the pre-publish transpile:
|
|
30
63
|
* - `null` — no platform-code type-check ran. A plain (non-snapshot) push
|
|
@@ -42,54 +75,36 @@ export interface PushResult {
|
|
|
42
75
|
*/
|
|
43
76
|
typeCheckDiagnostics: number | null;
|
|
44
77
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
* - `
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
78
|
+
* The diagnostics `typeCheckDiagnostics` counts, located: `{ file, line, column, code, message }` for each, with `file`
|
|
79
|
+
* relative to the draft folder. Only the script's own sources are counted, never a `.d.ts`. Empty when none, and when
|
|
80
|
+
* no type-check ran.
|
|
81
|
+
* @lastreviewed null
|
|
82
|
+
*/
|
|
83
|
+
typeCheckErrors: TypeCheckError[];
|
|
84
|
+
/**
|
|
85
|
+
* Whether the platform's published branch reads back at the commit it reported publishing (`publishedSha`):
|
|
86
|
+
* - `null` — no read-back ran: a plain push, an aborted one, a failed publish, or the published branch could not be
|
|
87
|
+
* fetched to compare.
|
|
88
|
+
* - `true` — the published branch is at `publishedSha`.
|
|
89
|
+
* - `false` — it is at another commit; see `liveMismatches`.
|
|
57
90
|
* @lastreviewed null
|
|
58
91
|
*/
|
|
59
92
|
liveVerified: boolean | null;
|
|
60
93
|
/**
|
|
61
|
-
* Draft-relative paths (`/`-separated
|
|
62
|
-
*
|
|
94
|
+
* Draft-relative paths (`/`-separated) that differ between the commit the platform reported publishing and its
|
|
95
|
+
* published branch. Empty unless `liveVerified` is false (and then empty too when the difference can't be listed).
|
|
63
96
|
* @lastreviewed null
|
|
64
97
|
*/
|
|
65
98
|
liveMismatches: string[];
|
|
66
99
|
/**
|
|
67
100
|
* Draft-relative paths (`/`-separated) of files that exist only on the platform and were kept
|
|
68
101
|
* because deleting them was not confirmed: declined, or answered with the safe default (an empty
|
|
69
|
-
* answer, or the CLI's `--yes`).
|
|
70
|
-
*
|
|
102
|
+
* answer, or the CLI's `--yes`). They are part of the pushed commit. Empty when there were none or
|
|
103
|
+
* when they were deleted.
|
|
71
104
|
* @lastreviewed null
|
|
72
105
|
*/
|
|
73
106
|
keptPlatformOnly: string[];
|
|
74
107
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Outcome of {@link verifyLiveSnapshot}. Paths are draft-relative and `/`-separated.
|
|
77
|
-
* @lastreviewed null
|
|
78
|
-
*/
|
|
79
|
-
export interface LiveSnapshotCheck {
|
|
80
|
-
/**
|
|
81
|
-
* Files whose `snapshot/` copy still differs from local, is missing (`404`) or can't be read
|
|
82
|
-
* (another non-2xx) after one re-upload.
|
|
83
|
-
* @lastreviewed null
|
|
84
|
-
*/
|
|
85
|
-
mismatches: string[];
|
|
86
|
-
/**
|
|
87
|
-
* Files the platform served (2xx) without a SHA-512 ETag, so neither match nor mismatch can be
|
|
88
|
-
* said.
|
|
89
|
-
* @lastreviewed null
|
|
90
|
-
*/
|
|
91
|
-
indeterminate: string[];
|
|
92
|
-
}
|
|
93
108
|
/**
|
|
94
109
|
* Outcome of {@link checkEmittedEntrypoint}.
|
|
95
110
|
* @lastreviewed null
|
|
@@ -133,95 +148,24 @@ export declare function checkEmittedEntrypoint(opts: {
|
|
|
133
148
|
fs: FileSystem;
|
|
134
149
|
}): Promise<EmittedEntrypointCheck>;
|
|
135
150
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* still serve different bytes, e.g. an empty or cut-off file, so a clean upload alone doesn't prove
|
|
139
|
-
* the live version is right (ClickUp 86bbqnrtp).
|
|
151
|
+
* Core push implementation, on git: the draft folder is the script's git working tree, a push commits it and pushes the
|
|
152
|
+
* draft branch, and a snapshot then publishes it (see {@link pushDraft}).
|
|
140
153
|
*
|
|
141
|
-
* A
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* @param ctx Where the retries are logged
|
|
146
|
-
* @returns The files still mismatched, and the ones that could not be compared
|
|
147
|
-
* @lastreviewed null
|
|
148
|
-
*/
|
|
149
|
-
export declare function verifyLiveSnapshot(files: ScriptFile[], ctx: Pick<ScriptContext, "logger">): Promise<LiveSnapshotCheck>;
|
|
150
|
-
/**
|
|
151
|
-
* A file whose upload would overwrite a platform version nobody here has seen.
|
|
152
|
-
* @lastreviewed null
|
|
153
|
-
*/
|
|
154
|
-
export interface OverwriteCandidate {
|
|
155
|
-
/**
|
|
156
|
-
* The file to upload.
|
|
157
|
-
* @lastreviewed null
|
|
158
|
-
*/
|
|
159
|
-
file: ScriptFile;
|
|
160
|
-
/**
|
|
161
|
-
* Draft-relative, `/`-separated path, e.g. `scripts/app.ts`.
|
|
162
|
-
* @lastreviewed null
|
|
163
|
-
*/
|
|
164
|
-
path: string;
|
|
165
|
-
/**
|
|
166
|
-
* Why it is at risk; see {@link ScriptFile.platformChangeAtRisk}.
|
|
167
|
-
* @lastreviewed null
|
|
168
|
-
*/
|
|
169
|
-
risk: "changed" | "unsynced";
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Finds the files of a push whose upload would overwrite a platform version nobody here has seen,
|
|
173
|
-
* by the rule in {@link ScriptFile.platformChangeAtRisk}. Files the push won't upload anyway
|
|
174
|
-
* (ignored, declarations, already in sync) are left out, so they are never asked about.
|
|
175
|
-
*
|
|
176
|
-
* Reads the platform one file at a time. The skip check it runs is cached on each file, so the
|
|
177
|
-
* upload that follows doesn't repeat it.
|
|
178
|
-
* @param files The push's files, the same instances the upload will use
|
|
179
|
-
* @param opts.isSnapshot Whether the push also publishes to `snapshot/`
|
|
180
|
-
* @returns The files at risk, in the order given
|
|
181
|
-
* @lastreviewed null
|
|
182
|
-
*/
|
|
183
|
-
export declare function collectOverwriteCandidates(files: ScriptFile[], opts: {
|
|
184
|
-
isSnapshot: boolean;
|
|
185
|
-
}): Promise<OverwriteCandidate[]>;
|
|
186
|
-
/**
|
|
187
|
-
* The push's one overwrite confirmation (ClickUp 86bbjennm). Before anything is uploaded, it finds
|
|
188
|
-
* every file at risk ({@link collectOverwriteCandidates}) and asks once for all of them, so an
|
|
189
|
-
* answer, or the lack of one, can no longer leave a push half done. Files the caller already
|
|
190
|
-
* confirmed in `preConfirmed` are not asked about: that is how a consumer confirms without a
|
|
191
|
-
* prompt, e.g. from a flag.
|
|
192
|
-
* @param opts.files The push's files, the same instances the upload will use
|
|
193
|
-
* @param opts.ctx Where the prompt goes
|
|
194
|
-
* @param opts.isSnapshot Whether the push also publishes to `snapshot/`
|
|
195
|
-
* @param opts.preConfirmed Draft-relative paths (`/`- or `\`-separated) the caller confirms up front
|
|
196
|
-
* @returns The files whose overwrite is confirmed; `upload()` skips its own prompt for them
|
|
197
|
-
* @throws an {@link Err.OverwriteDeclinedError} listing the files, when the answer is anything but
|
|
198
|
-
* "Overwrite all". Nothing has been uploaded at that point.
|
|
199
|
-
* @lastreviewed null
|
|
200
|
-
*/
|
|
201
|
-
export declare function confirmOverwrites(opts: {
|
|
202
|
-
files: ScriptFile[];
|
|
203
|
-
ctx: Pick<ScriptContext, "prompt">;
|
|
204
|
-
isSnapshot: boolean;
|
|
205
|
-
preConfirmed?: string[];
|
|
206
|
-
}): Promise<Set<ScriptFile>>;
|
|
207
|
-
/**
|
|
208
|
-
* Core push implementation.
|
|
209
|
-
*
|
|
210
|
-
* Delegates the per-file work to {@link ScriptFile.upload}, which handles:
|
|
211
|
-
* - exclusion logic (declarations / .git / .gitignore / integrity match)
|
|
212
|
-
* - collision detection against last-verified hash with user prompt
|
|
213
|
-
* - snapshot dual-write (draft + snapshot)
|
|
214
|
-
* - metadata `lastVerifiedHash` updates via touch()
|
|
215
|
-
* - rich error wrapping
|
|
154
|
+
* A snapshot push compiles first and stops before pushing anything if the compiled entrypoint is missing or blank. It
|
|
155
|
+
* is published as pushed: the compiled output is part of the commit. If the platform refuses the publish the draft
|
|
156
|
+
* stays pushed and the result carries `publishError`. A snapshot that compiled with diagnostics is published anyway and
|
|
157
|
+
* warned about loudly.
|
|
216
158
|
*
|
|
217
|
-
* Before
|
|
218
|
-
*
|
|
219
|
-
* A snapshot push then reads the live copies back ({@link verifyLiveSnapshot}). If any is still
|
|
220
|
-
* wrong, the push stops before cleanup and history and returns `liveVerified: false`.
|
|
159
|
+
* Before anything is pushed, one confirmation covers every platform file the push would overwrite; declining stops the
|
|
160
|
+
* push with nothing sent.
|
|
221
161
|
* @param opts.overwrite Draft-relative paths whose overwrite the caller confirms up front, so the
|
|
222
162
|
* push doesn't ask about them (e.g. a consumer's flag, after the user approved the files a
|
|
223
163
|
* declined push listed). Other at-risk files still ask.
|
|
164
|
+
* @param opts.author Who the commit is by. When absent: the folder's `git config`, then the environment.
|
|
165
|
+
* @param opts.adoptUnbound `false` for a deploy to a script the folder isn't the working copy of: the folder is then
|
|
166
|
+
* never bound to the target's repo. Default `true`.
|
|
224
167
|
* @throws an {@link Err.OverwriteDeclinedError} when an overwrite is not confirmed
|
|
168
|
+
* @throws {GitIdentityError} when no commit author can be found
|
|
225
169
|
* @lastreviewed null
|
|
226
170
|
*/
|
|
227
171
|
export declare function executePush(opts: {
|
|
@@ -231,23 +175,13 @@ export declare function executePush(opts: {
|
|
|
231
175
|
snapshot: boolean;
|
|
232
176
|
message?: string;
|
|
233
177
|
overwrite?: string[];
|
|
178
|
+
author?: GitIdentity;
|
|
179
|
+
adoptUnbound?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* The script is built by a bundler outside this tool (its `externallyBuilt` config flag): no build manifest is
|
|
182
|
+
* written for it.
|
|
183
|
+
* @lastreviewed null
|
|
184
|
+
*/
|
|
185
|
+
externallyBuilt?: boolean;
|
|
186
|
+
enableGit?: boolean;
|
|
234
187
|
}): Promise<PushResult>;
|
|
235
|
-
/**
|
|
236
|
-
* Delete remote files that no longer have a local counterpart, after one confirmation listing
|
|
237
|
-
* them. Anything but an explicit "Yes" keeps them all, including a prompt that throws because it
|
|
238
|
-
* got no answer. Files matched by `.gitignore` are never deleted. Failures are logged, never
|
|
239
|
-
* thrown: a push that uploaded fine is not failed by cleanup.
|
|
240
|
-
* @param opts.ctx Where requests, prompts and logs go
|
|
241
|
-
* @param opts.targetUrl The script's WebDAV base URL, listed with `PROPFIND`
|
|
242
|
-
* @param opts.draftPath The local draft folder to compare against
|
|
243
|
-
* @param opts.gitignoreMatcher The script's `.gitignore` patterns
|
|
244
|
-
* @returns Draft-relative paths of the platform-only files it kept because deleting them was not
|
|
245
|
-
* confirmed; empty when there were none, when they were deleted, or when cleanup failed
|
|
246
|
-
* @lastreviewed null
|
|
247
|
-
*/
|
|
248
|
-
export declare function cleanupUnusedUpstairsPaths(opts: {
|
|
249
|
-
ctx: ScriptContext;
|
|
250
|
-
targetUrl: string;
|
|
251
|
-
draftPath: string;
|
|
252
|
-
gitignoreMatcher: GlobMatcher;
|
|
253
|
-
}): Promise<string[]>;
|