@bluestep-systems/b6p-core 0.6.1 → 0.8.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 +43 -0
- package/dist/Err.d.ts +15 -0
- package/dist/Err.js +20 -0
- package/dist/Err.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/providers.d.ts +32 -1
- package/dist/script/ScriptFile.d.ts +92 -0
- package/dist/script/ScriptFile.js +196 -35
- package/dist/script/ScriptFile.js.map +1 -1
- package/dist/script/ScriptFolder.d.ts +1 -0
- package/dist/script/ScriptFolder.js.map +1 -1
- package/dist/script/ScriptNode.d.ts +2 -0
- package/dist/script/ScriptNode.js.map +1 -1
- package/dist/script/ScriptRoot.d.ts +14 -1
- package/dist/script/ScriptRoot.js +22 -6
- package/dist/script/ScriptRoot.js.map +1 -1
- package/dist/script/ScriptService.d.ts +10 -0
- package/dist/script/ScriptService.js +13 -1
- package/dist/script/ScriptService.js.map +1 -1
- package/dist/script/ScriptTranspiler.d.ts +78 -6
- package/dist/script/ScriptTranspiler.js +137 -27
- package/dist/script/ScriptTranspiler.js.map +1 -1
- package/dist/script/push.d.ts +213 -1
- package/dist/script/push.js +336 -18
- package/dist/script/push.js.map +1 -1
- package/package.json +2 -2
package/dist/script/push.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { GlobMatcher } from "../data/GlobMatcher";
|
|
1
2
|
import type { ScriptContext } from "./ScriptContext";
|
|
3
|
+
import type { FileSystem } from "../providers";
|
|
4
|
+
import { ScriptFile } from "./ScriptFile";
|
|
2
5
|
/**
|
|
3
6
|
* Outcome of a push, for callers that need more signal than the human-facing
|
|
4
7
|
* messages — e.g. a CLI that must exit non-zero or emit `--json` when nothing
|
|
@@ -10,7 +13,8 @@ import type { ScriptContext } from "./ScriptContext";
|
|
|
10
13
|
export interface PushResult {
|
|
11
14
|
/**
|
|
12
15
|
* True when the upload actually ran. False when the push aborted before
|
|
13
|
-
* uploading anything (draft folder missing, or empty
|
|
16
|
+
* uploading anything (draft folder missing, or empty; or, on a snapshot push,
|
|
17
|
+
* the compiled `scripts/app.js` missing or blank) — a state a machine
|
|
14
18
|
* consumer must not read as success.
|
|
15
19
|
* @lastreviewed null
|
|
16
20
|
*/
|
|
@@ -21,7 +25,185 @@ export interface PushResult {
|
|
|
21
25
|
* @lastreviewed null
|
|
22
26
|
*/
|
|
23
27
|
historyRecorded: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Type-check outcome of the pre-publish transpile:
|
|
30
|
+
* - `null` — no platform-code type-check ran. A plain (non-snapshot) push
|
|
31
|
+
* does not compile; a push that aborted before compiling never got there;
|
|
32
|
+
* and a snapshot whose TS all lives under nested client bundles (nothing
|
|
33
|
+
* governed by the draft-root tsconfig) has no draft-root code to check.
|
|
34
|
+
* - `0` — the draft-root code compiled with zero diagnostics: genuinely
|
|
35
|
+
* type-checked.
|
|
36
|
+
* - `> 0` — compiled, but N diagnostics were reported. The JavaScript was
|
|
37
|
+
* emitted and published anyway (the platform runs the emitted JS on
|
|
38
|
+
* GraalVM regardless of type errors, and local declarations may be
|
|
39
|
+
* incomplete), so this is a loud warning, not a failure. A machine consumer
|
|
40
|
+
* should treat `> 0` as "published without a passing type-check".
|
|
41
|
+
* @lastreviewed null
|
|
42
|
+
*/
|
|
43
|
+
typeCheckDiagnostics: number | null;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the live (`snapshot/`) copy of every file this push wrote reads back identical to the
|
|
46
|
+
* local bytes (compared by ETag, the platform's SHA-512 of the content):
|
|
47
|
+
* - `null` — no read-back ran: a plain push, or a push that aborted before uploading.
|
|
48
|
+
* Also `null` when no copy was wrong but at least one was served without a content hash
|
|
49
|
+
* (ETag), so it could not be compared: those files are named in a warning, and cleanup and
|
|
50
|
+
* history still run.
|
|
51
|
+
* - `true` — every written file reads back identical. Files skipped as already in sync count as
|
|
52
|
+
* verified, since the skip rule compared both copies.
|
|
53
|
+
* - `false` — at least one file was still different, missing (`404`) or unreadable (another
|
|
54
|
+
* non-2xx) after one re-upload; see `liveMismatches`. The push stopped there: no cleanup ran
|
|
55
|
+
* and no history entry was recorded (`historyRecorded` is false), so a consumer that already
|
|
56
|
+
* reads that field fails the run.
|
|
57
|
+
* @lastreviewed null
|
|
58
|
+
*/
|
|
59
|
+
liveVerified: boolean | null;
|
|
60
|
+
/**
|
|
61
|
+
* Draft-relative paths (`/`-separated, e.g. `.build/scripts/app.js`) whose live copy failed the
|
|
62
|
+
* read-back. Empty unless `liveVerified` is false.
|
|
63
|
+
* @lastreviewed null
|
|
64
|
+
*/
|
|
65
|
+
liveMismatches: string[];
|
|
66
|
+
/**
|
|
67
|
+
* Draft-relative paths (`/`-separated) of files that exist only on the platform and were kept
|
|
68
|
+
* because deleting them was not confirmed: declined, or answered with the safe default (an empty
|
|
69
|
+
* answer, or the CLI's `--yes`). Empty when there were none, when they were deleted, or when
|
|
70
|
+
* cleanup did not run.
|
|
71
|
+
* @lastreviewed null
|
|
72
|
+
*/
|
|
73
|
+
keptPlatformOnly: string[];
|
|
74
|
+
}
|
|
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[];
|
|
24
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Outcome of {@link checkEmittedEntrypoint}.
|
|
95
|
+
* @lastreviewed null
|
|
96
|
+
*/
|
|
97
|
+
export interface EmittedEntrypointCheck {
|
|
98
|
+
/**
|
|
99
|
+
* - `"no-source"` — the draft has no `scripts/app.ts` (a JS-only draft): nothing to check.
|
|
100
|
+
* - `"ok"` — the compiled entrypoint exists and has content.
|
|
101
|
+
* - `"missing"` — `scripts/app.ts` exists but the compile wrote no `scripts/app.js`.
|
|
102
|
+
* - `"empty"` — the compiled entrypoint has no code: only comments (the inline source map
|
|
103
|
+
* included) and the compiler's empty-module lines, e.g. from a blank `app.ts` or one holding
|
|
104
|
+
* only types. The platform serves such a file as an empty `200`.
|
|
105
|
+
* @lastreviewed null
|
|
106
|
+
*/
|
|
107
|
+
status: "no-source" | "ok" | "missing" | "empty";
|
|
108
|
+
/**
|
|
109
|
+
* Absolute path of the compiled entrypoint the check looked for.
|
|
110
|
+
* @lastreviewed null
|
|
111
|
+
*/
|
|
112
|
+
emittedPath: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Pre-publish check for a snapshot push: after the compile, the entrypoint the platform runtime
|
|
116
|
+
* loads must be there. The runtime resolves `scripts/app` to `<build folder>/scripts/app.js`; if
|
|
117
|
+
* that file is missing or has no code, publishing it breaks the live version (a missing one fails
|
|
118
|
+
* with `NoSuchFileException .../scripts/app`, one with no code answers an empty `200`), so the push
|
|
119
|
+
* must stop before any upload (ClickUp 86bbqnrtp).
|
|
120
|
+
*
|
|
121
|
+
* Only the entrypoint is checked. A helper module may legitimately compile to almost nothing, so
|
|
122
|
+
* checking every emitted file would stop good pushes. The transpiler sets `rootDir` to the
|
|
123
|
+
* tsconfig's folder, which is why `scripts/app.ts` always maps to `<build folder>/scripts/app.js`.
|
|
124
|
+
* @param opts.draftPath The draft folder
|
|
125
|
+
* @param opts.buildFolderPath The draft-root tsconfig's build folder ({@link ScriptRoot.getDraftBuildFolder})
|
|
126
|
+
* @param opts.fs The file system to read
|
|
127
|
+
* @returns What was found, and the path it looked at
|
|
128
|
+
* @lastreviewed null
|
|
129
|
+
*/
|
|
130
|
+
export declare function checkEmittedEntrypoint(opts: {
|
|
131
|
+
draftPath: string;
|
|
132
|
+
buildFolderPath: string;
|
|
133
|
+
fs: FileSystem;
|
|
134
|
+
}): Promise<EmittedEntrypointCheck>;
|
|
135
|
+
/**
|
|
136
|
+
* Post-publish read-back for a snapshot push: `HEAD`s the `snapshot/` copy of each file the push
|
|
137
|
+
* wrote and compares its ETag with the local SHA-512. The platform can accept a write (2xx) and
|
|
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).
|
|
140
|
+
*
|
|
141
|
+
* A copy that differs, is missing (`404`) or can't be read (another non-2xx) is re-sent once and
|
|
142
|
+
* checked again; a re-send the platform refuses leaves it a mismatch. Only a 2xx without a content
|
|
143
|
+
* hash is indeterminate. Files are checked one at a time, in the order given.
|
|
144
|
+
* @param files The files this push wrote to `snapshot/`
|
|
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>>;
|
|
25
207
|
/**
|
|
26
208
|
* Core push implementation.
|
|
27
209
|
*
|
|
@@ -31,6 +213,16 @@ export interface PushResult {
|
|
|
31
213
|
* - snapshot dual-write (draft + snapshot)
|
|
32
214
|
* - metadata `lastVerifiedHash` updates via touch()
|
|
33
215
|
* - rich error wrapping
|
|
216
|
+
*
|
|
217
|
+
* Before any upload, one confirmation covers every file that would overwrite a platform version
|
|
218
|
+
* nobody here has seen ({@link confirmOverwrites}); declining stops the push with nothing written.
|
|
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`.
|
|
221
|
+
* @param opts.overwrite Draft-relative paths whose overwrite the caller confirms up front, so the
|
|
222
|
+
* push doesn't ask about them (e.g. a consumer's flag, after the user approved the files a
|
|
223
|
+
* declined push listed). Other at-risk files still ask.
|
|
224
|
+
* @throws an {@link Err.OverwriteDeclinedError} when an overwrite is not confirmed
|
|
225
|
+
* @lastreviewed null
|
|
34
226
|
*/
|
|
35
227
|
export declare function executePush(opts: {
|
|
36
228
|
ctx: ScriptContext;
|
|
@@ -38,4 +230,24 @@ export declare function executePush(opts: {
|
|
|
38
230
|
rootPath: string;
|
|
39
231
|
snapshot: boolean;
|
|
40
232
|
message?: string;
|
|
233
|
+
overwrite?: string[];
|
|
41
234
|
}): 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[]>;
|