@elaraai/e3-cloud-cli 1.1.18 → 1.1.20
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 +92 -4
- package/dist/src/app-source.d.ts +184 -11
- package/dist/src/app-source.d.ts.map +1 -1
- package/dist/src/app-source.js +302 -0
- package/dist/src/app-source.js.map +1 -1
- package/dist/src/cli.js +13 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/app.d.ts +9 -2
- package/dist/src/commands/app.d.ts.map +1 -1
- package/dist/src/commands/app.js +674 -38
- package/dist/src/commands/app.js.map +1 -1
- package/dist/src/commands/release.d.ts.map +1 -1
- package/dist/src/commands/release.js +53 -19
- package/dist/src/commands/release.js.map +1 -1
- package/dist/src/package-compare.d.ts +139 -0
- package/dist/src/package-compare.d.ts.map +1 -0
- package/dist/src/package-compare.js +422 -0
- package/dist/src/package-compare.js.map +1 -0
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -343,7 +343,9 @@ e3-cloud app build src/apps/ops.tsx -o dist/ops.app
|
|
|
343
343
|
# Deploy (owner or admin): the bundle's package is imported first when the
|
|
344
344
|
# repository lacks its version; then the app is checked against it and, when
|
|
345
345
|
# the workspace runs it, is live at once. A refusal prints every problem and
|
|
346
|
-
# exits non-zero; --dry-run checks and changes nothing
|
|
346
|
+
# exits non-zero; --dry-run checks and changes nothing a person, a deploy or a
|
|
347
|
+
# listing can see: it imports and holds no package, and the build it sends to
|
|
348
|
+
# be checked is dropped, its object never written
|
|
347
349
|
e3-cloud app deploy https://e3.example.com/repos/my-repo staging dist/ops.app --dry-run
|
|
348
350
|
e3-cloud app deploy https://e3.example.com/repos/my-repo staging dist/ops.app
|
|
349
351
|
|
|
@@ -351,8 +353,16 @@ e3-cloud app deploy https://e3.example.com/repos/my-repo staging dist/ops.app
|
|
|
351
353
|
e3-cloud app deploy https://e3.example.com/repos/my-repo staging dist/ops.app dist/exec.app
|
|
352
354
|
e3-cloud app deploy https://e3.example.com/repos/my-repo staging --from-source src/apps/ops.tsx
|
|
353
355
|
|
|
354
|
-
#
|
|
355
|
-
|
|
356
|
+
# Prepare a build made with the platform's next e3, for the platform deploy that moves to it;
|
|
357
|
+
# a package of its own the repository lacks is held for the move, which deploys it
|
|
358
|
+
e3-cloud app deploy https://e3.example.com/repos/my-repo staging dist/ops.app --for-platform 1.0.86
|
|
359
|
+
# Remove a prepared build, the live version staying (owner or admin)
|
|
360
|
+
e3-cloud app remove-prepared https://e3.example.com/repos/my-repo staging ops
|
|
361
|
+
|
|
362
|
+
# Built against the package the workspace runs, as the repository holds it, not the package
|
|
363
|
+
# its source exports again: the bundle names that package and carries none (--against-workspace)
|
|
364
|
+
e3-cloud app build src/apps/ops.tsx --against-workspace https://e3.example.com/repos/my-repo/workspaces/staging
|
|
365
|
+
e3-cloud app deploy https://e3.example.com/repos/my-repo staging --from-source src/apps/ops.tsx --against-workspace --for-platform 1.0.86 --dry-run
|
|
356
366
|
|
|
357
367
|
# What is deployed: every workspace's apps, or one's; an app's kept versions (owner or admin)
|
|
358
368
|
e3-cloud app list https://e3.example.com/repos/my-repo
|
|
@@ -379,6 +389,80 @@ A deploy whose package the workspace does not run deploys the package first,
|
|
|
379
389
|
as a deploy job that keeps the inputs people set and starts no run; the
|
|
380
390
|
CLI waits for the job, and the apps go live as it completes.
|
|
381
391
|
|
|
392
|
+
At a version change of e3, step by step (nothing is removed):
|
|
393
|
+
|
|
394
|
+
1. Bump the project's `@elaraai` dependencies to the release built with the next e3.
|
|
395
|
+
2. If an app has a page that reads a record through indexes, give the package a new version in its source.
|
|
396
|
+
3. Deploy each app as always: `e3-cloud app deploy URL staging --from-source src/apps/ops.tsx`. A build made with a newer e3 than the platform runs is prepared for the platform's move by itself.
|
|
397
|
+
4. Release staging to production: `e3-cloud release URL staging production`.
|
|
398
|
+
|
|
399
|
+
A version names one package once it is in use (two workspaces, a staging or a protected workspace, or a build prepared on it), and the move must import exactly the package each build was checked against. So when a build's package is the version the workspace runs at other bytes, `app deploy` (with no flag) tells the two cases apart by what differs:
|
|
400
|
+
- **Code alone** (a function's compiled code with its signature unchanged; a task whose object differs, which includes its inputs and its runner as well as its code; a record's programs: its mutations', indexes' or migrations' code), which the next e3's export also changes: the build is prepared on the package the workspace runs if the app fits it, and the CLI says so first: "This prepares ops on the package production runs, acme@1.5.0, not on the package built here: a change you made to the package's code is not deployed. To send it with the app, give acme a new version in its source and deploy again". A change to a function's body or a task's logic is code alone, so it is not deployed this way.
|
|
401
|
+
- **Anything e3 shows** (a dataset, a type, a function's signature, an initial value, a file source): that is your change to the package, and it is refused before anything is sent, naming what differs, with the step: give the package a new version (it is X now). Where an input's file source differs, the workspace's Files declarations must fit the new version too: until they do, its deploy is refused `package_files_differ`, which says how.
|
|
402
|
+
- Which case a difference is is decided where the comparison finds it, never from its words. Two packages whose hashes differ where the comparison reads nothing different (a part it does not read) are said so on a line of their own, and refused as a change shown, never bound as code alone.
|
|
403
|
+
- A page that reads through indexes, or a fit the checks refuse, is refused the same way.
|
|
404
|
+
|
|
405
|
+
`--against-workspace`, given explicitly, binds as it always has, saying what differs.
|
|
406
|
+
|
|
407
|
+
**A build for the next e3 with a package of its own.** With `--for-platform`,
|
|
408
|
+
a build whose package the repository lacks hands the platform the package to
|
|
409
|
+
hold until its move: the e3 the platform runs would refuse to import a
|
|
410
|
+
package the next e3 exported. The move deploys it to each workspace a build
|
|
411
|
+
is prepared on with it, keeping the inputs people set and migrating records,
|
|
412
|
+
with no run, and puts the builds live. The deploy keeps only the outputs of
|
|
413
|
+
tasks it leaves unchanged, and the next e3's export usually changes every
|
|
414
|
+
task, so each such workspace usually needs a run. The CLI checks the build
|
|
415
|
+
against that package first, by the project's checks (this CLI's for a bundle
|
|
416
|
+
file), and holds nothing when it does not fit; a platform on an older e3 may not read
|
|
417
|
+
the package, and then checks the build only at the move, before it deploys.
|
|
418
|
+
A `--dry-run` with a package not held yet is answered by those checks alone,
|
|
419
|
+
exit 0 when the build fits. After preparing, the CLI names the workspace's
|
|
420
|
+
apps still without a build for that e3. Another build of a held version is
|
|
421
|
+
refused: give the package a new version, or, an admin alone, `--replace` the
|
|
422
|
+
zip held while no build is prepared on it. `app remove-prepared` removes a
|
|
423
|
+
prepared build. A deployment gains this only once it runs a release that has
|
|
424
|
+
it: an older one is refused in words naming its release, offering
|
|
425
|
+
`--against-workspace`.
|
|
426
|
+
|
|
427
|
+
**Against the package the workspace runs.** `app build` exports the app's
|
|
428
|
+
package again from its source, with the e3 installed. A next e3 may export the
|
|
429
|
+
same source to other bytes (a Python-authored function's code, say): the
|
|
430
|
+
repository then holds another package of that version, and the deploy is
|
|
431
|
+
refused (`package_version_conflict`). `--against-workspace` builds the app's
|
|
432
|
+
pages as always but names the package the workspace runs, as the repository
|
|
433
|
+
holds it, and carries no package. It needs nothing of the platform, so it
|
|
434
|
+
stages a bundle for the next e3 on any release. It binds an app only when:
|
|
435
|
+
|
|
436
|
+
- its source declares the package and version the workspace runs;
|
|
437
|
+
- no page of it reads a record through indexes (`Data.bindPaged(record, {
|
|
438
|
+
indexes })`): such a page carries the record's index programs from its own
|
|
439
|
+
source, which can't be shown to be the workspace's, and is refused, naming
|
|
440
|
+
the page and the record. Its way through is a build that brings its own
|
|
441
|
+
package, once the platform takes one; until then, remove the app before the
|
|
442
|
+
platform moves and deploy it after;
|
|
443
|
+
- what its pages bind fits the held package, by the checks the platform runs,
|
|
444
|
+
of the release the project's build ran (refused in their words otherwise;
|
|
445
|
+
a problem of the app as built, rather than of the package, is said as such).
|
|
446
|
+
A page calling a bind of the workspace this CLI doesn't know (one of e3-ui's
|
|
447
|
+
data, record, function or decision families) is refused too, and a record
|
|
448
|
+
Slice (`Slice.bindRecord`) counts as an indexed read; page-local binds
|
|
449
|
+
(`State.bind`, `Slice.bind`) are no matter. Anything else that differs is printed and
|
|
450
|
+
allowed: a type e3 or east-ui itself changed between releases that no page
|
|
451
|
+
binds (a `ui()` task's output, a nested series index's span), code, a
|
|
452
|
+
record's programs, initial values, the inputs taken from files.
|
|
453
|
+
|
|
454
|
+
A `Page.task` page whose task's output the held package types otherwise is
|
|
455
|
+
named: it is bound, since the platform holds a task page only to its task and
|
|
456
|
+
its UI role, and after the platform's move it shows output computed in the held
|
|
457
|
+
package's type until the package is exported again with the new release.
|
|
458
|
+
|
|
459
|
+
A bundle that carries no package is deployed only when the workspace runs
|
|
460
|
+
exactly its package, as read seconds before the deploy; otherwise it is
|
|
461
|
+
refused, and is built again against the package the workspace runs now. A
|
|
462
|
+
workspace deploy that completes within those seconds leads the platform to
|
|
463
|
+
deploy the held package back over it: nothing on the platform side refuses that
|
|
464
|
+
yet. The CLI then says so loudly, with how to put it right, and exits non-zero.
|
|
465
|
+
|
|
382
466
|
**Developing an app** is done in the cloud, not locally: deploy each change
|
|
383
467
|
to a workspace of your own, a staging say (`--from-source` builds and
|
|
384
468
|
deploys in one step; `--dry-run` checks it against the workspace's package
|
|
@@ -451,7 +535,11 @@ starts. A refused plan prints its problems and exits 1, changing nothing; the
|
|
|
451
535
|
plan names any change an admin forced onto the target since its last release,
|
|
452
536
|
which the release undoes. A rollback releases an entry of the history again,
|
|
453
537
|
its package and apps exactly; a record migrated forward may refuse to go back,
|
|
454
|
-
and the plan says so. A rollback stays open on a protected workspace.
|
|
538
|
+
and the plan says so. A rollback stays open on a protected workspace. A
|
|
539
|
+
release or rollback of more than ten apps switches them ten at a time: if one
|
|
540
|
+
does not switch, those switched before it stay live, and the job's failure
|
|
541
|
+
names the apps that did not and the way out (release, or roll back to the same
|
|
542
|
+
entry, again).
|
|
455
543
|
|
|
456
544
|
#### Files
|
|
457
545
|
|
package/dist/src/app-source.d.ts
CHANGED
|
@@ -2,18 +2,9 @@
|
|
|
2
2
|
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
3
|
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
* Builds an app from its source: `e3-cloud app build` and `app deploy
|
|
7
|
-
* --from-source`, as e3's CLI loads a package for `e3 workspace deploy
|
|
8
|
-
* --from-source`. esbuild bundles the entry (multi-file TypeScript and TSX,
|
|
9
|
-
* with the nearest tsconfig.json), leaving every `@elaraai/*` import to the
|
|
10
|
-
* project's own packages; the bundle is imported from under the project's
|
|
11
|
-
* `node_modules`, and its default export must be an app (`App(...)` of
|
|
12
|
-
* `@elaraai/e3-cloud-ui`). The app is built by the project's own
|
|
13
|
-
* `@elaraai/e3-cloud-ui`, the one its source imports, so the app, its pages
|
|
14
|
-
* and its package are of the modules the build reads them with.
|
|
15
|
-
*/
|
|
5
|
+
import { type AppProblem, type AppProblems } from '@elaraai/e3-cloud-types';
|
|
16
6
|
import type { AppBundle } from '@elaraai/e3-cloud-ui/types';
|
|
7
|
+
import type { Checks } from './package-compare.js';
|
|
17
8
|
/**
|
|
18
9
|
* Builds the app a source file's default export defines into a bundle.
|
|
19
10
|
*
|
|
@@ -24,4 +15,186 @@ import type { AppBundle } from '@elaraai/e3-cloud-ui/types';
|
|
|
24
15
|
* the app (`AppBuildError`, naming each problem)
|
|
25
16
|
*/
|
|
26
17
|
export declare function buildAppFromSource(file: string): Promise<AppBundle>;
|
|
18
|
+
/** A package as a repository names it: its name, its version and its object's hash. */
|
|
19
|
+
export interface PackageRef {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly version: string;
|
|
22
|
+
readonly hash: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Binds a bundle to the package a workspace runs, as its repository holds it
|
|
26
|
+
* (`--against-workspace`): the app names that package, and the bundle carries
|
|
27
|
+
* no package of its own (a zip of no bytes). Its pages and the e3 they were
|
|
28
|
+
* built with stay as built. Whether the two packages differ only where no page
|
|
29
|
+
* reads is `comparePackages`' to say, before this binds.
|
|
30
|
+
*
|
|
31
|
+
* @param bundle - The bundle, as the build made it
|
|
32
|
+
* @param running - The package the workspace runs
|
|
33
|
+
* @param workspace - The workspace, for the words
|
|
34
|
+
* @returns The bound bundle
|
|
35
|
+
* @throws {Error} When the source declares another package, or another
|
|
36
|
+
* version of it, than the workspace runs
|
|
37
|
+
*/
|
|
38
|
+
export declare function bindToWorkspacePackage(bundle: AppBundle, running: PackageRef, workspace: string): AppBundle;
|
|
39
|
+
/**
|
|
40
|
+
* Whether one e3 release is newer than another, by e3's own order; false for
|
|
41
|
+
* a text that is no release.
|
|
42
|
+
*
|
|
43
|
+
* @param release - The release
|
|
44
|
+
* @param than - The release it is compared with
|
|
45
|
+
* @returns Whether `release` comes after `than`
|
|
46
|
+
*/
|
|
47
|
+
export declare function newerRelease(release: string, than: string): boolean;
|
|
48
|
+
/** The checks' problems that are of an app's fit to a package, as against its own form or its e3. */
|
|
49
|
+
export declare const FIT_PROBLEMS: ReadonlySet<AppProblem['type']>;
|
|
50
|
+
/**
|
|
51
|
+
* What the CLI says of a build for the platform's next e3 with a package of
|
|
52
|
+
* its own, on a deployment that holds that package for its move: the
|
|
53
|
+
* way across the move for an app that can't be built against the package its
|
|
54
|
+
* workspace runs, rather than removing it before the move.
|
|
55
|
+
*/
|
|
56
|
+
export declare const HOLDS_FOR_THE_MOVE = "the platform holds that package for its move and deploys it then";
|
|
57
|
+
/**
|
|
58
|
+
* Whether the deployment holds a build's own package for its move: true,
|
|
59
|
+
* false (it answered that it serves no hold: a release from before it), or
|
|
60
|
+
* the error that kept it from being asked, in words: then no way across the
|
|
61
|
+
* move is advised, since either may be wrong.
|
|
62
|
+
*/
|
|
63
|
+
export type Holds = boolean | {
|
|
64
|
+
readonly unknown: string;
|
|
65
|
+
};
|
|
66
|
+
/** What a refusal says of the way across the move when whether the platform holds packages could not be read. */
|
|
67
|
+
export declare function holdsUnknownWords(holds: {
|
|
68
|
+
readonly unknown: string;
|
|
69
|
+
}): string;
|
|
70
|
+
/**
|
|
71
|
+
* What follows the problems of a refused deploy for the apps of it built
|
|
72
|
+
* against a package their repository holds: for an app the package does not
|
|
73
|
+
* fit, that it cannot as its source declares it, and how it crosses the
|
|
74
|
+
* platform's move (with a package of its own, where the platform holds one
|
|
75
|
+
* for the move; else only by its removal); for one built with a newer
|
|
76
|
+
* e3 than the platform runs, that a bundle for the platform's next e3 is
|
|
77
|
+
* staged with `--for-platform`. Nothing for any other problem.
|
|
78
|
+
*
|
|
79
|
+
* @param refused - Each refused app's problems
|
|
80
|
+
* @param bound - The apps of the deploy built against a package their repository holds
|
|
81
|
+
* @param pkg - That package, as `name@version`
|
|
82
|
+
* @param which - Which package it is, in words: `which production runs`
|
|
83
|
+
* @param staging - The e3 the deploy stages for (`--for-platform`), or null
|
|
84
|
+
* @param holds - Whether the platform holds a build's own package for its
|
|
85
|
+
* move: then an app that cannot fit is prepared with it, and is
|
|
86
|
+
* never removed across the move
|
|
87
|
+
* @returns The lines
|
|
88
|
+
*/
|
|
89
|
+
export declare function boundRefusalLines(refused: readonly AppProblems[], bound: ReadonlySet<string>, pkg: string, which: string, staging: string | null, holds?: Holds): string[];
|
|
90
|
+
/**
|
|
91
|
+
* Whether a bundle carries its package's zip: one built against a package
|
|
92
|
+
* its repository holds carries none.
|
|
93
|
+
*
|
|
94
|
+
* @param bundle - The bundle
|
|
95
|
+
* @returns Whether its zip has any bytes
|
|
96
|
+
*/
|
|
97
|
+
export declare function carriesPackage(bundle: AppBundle): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* The lines a binding prints of its `Page.task` pages whose task's output the
|
|
100
|
+
* held package types otherwise than the app's source: the checks hold such a
|
|
101
|
+
* page to its task and its UI role alone, so it is bound, and after the
|
|
102
|
+
* platform's move it shows output computed in the held package's type.
|
|
103
|
+
*
|
|
104
|
+
* @param app - The app's name
|
|
105
|
+
* @param held - The held package in words, e.g. `acme@1.5.0`
|
|
106
|
+
* @param pages - Those pages, each with the task it shows
|
|
107
|
+
* @returns A line each
|
|
108
|
+
*/
|
|
109
|
+
export declare function taskPageLines(app: string, held: string, pages: readonly {
|
|
110
|
+
page: string;
|
|
111
|
+
task: string;
|
|
112
|
+
}[]): string[];
|
|
113
|
+
/** The checks a binding runs, where they come from, and their release of `@elaraai/e3-cloud-ui`. */
|
|
114
|
+
export interface BindingChecks {
|
|
115
|
+
readonly checks: Checks;
|
|
116
|
+
/** The project's, which its build ran; or this CLI's own, when the project's can't be loaded */
|
|
117
|
+
readonly from: 'project' | 'cli';
|
|
118
|
+
/** Their `@elaraai/e3-cloud-ui` release; null when it can't be read */
|
|
119
|
+
readonly version: string | null;
|
|
120
|
+
/**
|
|
121
|
+
* Why this CLI's own are run, when they are: the project resolves no
|
|
122
|
+
* `@elaraai/e3-cloud-ui/check`, or its module failed to load (the reason),
|
|
123
|
+
* or gives no checks; null for the project's
|
|
124
|
+
*/
|
|
125
|
+
readonly fallback: string | null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The checks a binding runs: those of the `@elaraai/e3-cloud-ui` the
|
|
129
|
+
* source's project resolves, the release its build ran. The checks read a
|
|
130
|
+
* page as e3-ui of their release reads it (its manifest, the binds it
|
|
131
|
+
* makes), so a check of another release than the build's may refuse a page
|
|
132
|
+
* the build made (`manifest_mismatch`, `invalid_page`). This CLI's own are
|
|
133
|
+
* the fallback, said, when the project's can't be loaded.
|
|
134
|
+
*
|
|
135
|
+
* @param source - The app's source
|
|
136
|
+
* @returns The checks, where they come from, and their release
|
|
137
|
+
*/
|
|
138
|
+
export declare function bindingChecks(source: string): Promise<BindingChecks>;
|
|
139
|
+
/**
|
|
140
|
+
* The checks a build is checked with here: the project's, as {@link
|
|
141
|
+
* bindingChecks} finds them, for a build from source; this CLI's own for a
|
|
142
|
+
* bundle read from a file, which names no project.
|
|
143
|
+
*
|
|
144
|
+
* @param source - The app's source, or null for a bundle file
|
|
145
|
+
* @returns The checks, where they come from, and their release
|
|
146
|
+
*/
|
|
147
|
+
export declare function checksFor(source: string | null): Promise<BindingChecks>;
|
|
148
|
+
/**
|
|
149
|
+
* The checks' problems as lines: each kind this CLI knows in its words
|
|
150
|
+
* (`appProblemLines`); one it doesn't (from a newer project's checks) as it
|
|
151
|
+
* came, its kind and its text fields, never a failure of its own.
|
|
152
|
+
*
|
|
153
|
+
* @param problems - The problems
|
|
154
|
+
* @param names - The app and the package, for the words
|
|
155
|
+
* @returns A line each, indented two spaces
|
|
156
|
+
*/
|
|
157
|
+
export declare function problemLines(problems: readonly AppProblem[], names: {
|
|
158
|
+
app: string;
|
|
159
|
+
package: string;
|
|
160
|
+
}): string[];
|
|
161
|
+
/**
|
|
162
|
+
* The lines refusing a binding the checks refuse, split by what the problems
|
|
163
|
+
* are of. Problems of fit are of what the app's pages bind against what the
|
|
164
|
+
* held package declares. Any other is of the app as built (its pages, their
|
|
165
|
+
* manifests, its names), which the checks read as e3-ui of their release does.
|
|
166
|
+
*
|
|
167
|
+
* @param app - The app's name
|
|
168
|
+
* @param held - The held package in words, e.g. `acme@1.5.0`
|
|
169
|
+
* @param which - Which workspace runs it, e.g. `which production runs`
|
|
170
|
+
* @param problems - The checks' problems against the held package
|
|
171
|
+
* @param checks - Where the checks came from, and their release
|
|
172
|
+
* @param holds - Whether the platform holds a build's own package for its
|
|
173
|
+
* move: then the way across the move is that package, never the
|
|
174
|
+
* app's removal
|
|
175
|
+
* @returns The lines; none for no problems
|
|
176
|
+
*/
|
|
177
|
+
export declare function bindingRefusalLines(app: string, held: string, which: string, problems: readonly AppProblem[], checks: Pick<BindingChecks, 'from' | 'version' | 'fallback'>, holds?: Holds): string[];
|
|
178
|
+
/**
|
|
179
|
+
* The lines a deploy of bundles carrying no package prints when the platform
|
|
180
|
+
* answers it with a deploy of their package: the workspace moved in the
|
|
181
|
+
* seconds after it was read, and the held package is being deployed back over
|
|
182
|
+
* it. Nothing on the platform side refuses that yet; the CLI says it loudly
|
|
183
|
+
* and exits non-zero, so it can't pass unnoticed.
|
|
184
|
+
*
|
|
185
|
+
* The way back is a rollback to the workspace's entry for the package it had
|
|
186
|
+
* moved to, which gives it that entry's package and apps exactly: a protected
|
|
187
|
+
* workspace takes a package only by a release or a rollback, and a deploy of
|
|
188
|
+
* that package alone would be refused by the apps now live on the held one,
|
|
189
|
+
* where they don't fit it.
|
|
190
|
+
*
|
|
191
|
+
* @param url - The repository's URL
|
|
192
|
+
* @param workspace - The workspace
|
|
193
|
+
* @param held - The package the bundles were built against, with its hash
|
|
194
|
+
* @param movedTo - The package the workspace had moved to, with its hash, when read; null when not known
|
|
195
|
+
* @param job - The platform's deploy job
|
|
196
|
+
* @param apps - The apps carrying no package
|
|
197
|
+
* @returns The lines
|
|
198
|
+
*/
|
|
199
|
+
export declare function movedDuringDeployLines(url: string, workspace: string, held: string, movedTo: string | null, job: string, apps: readonly string[]): string[];
|
|
27
200
|
//# sourceMappingURL=app-source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-source.d.ts","sourceRoot":"","sources":["../../src/app-source.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"app-source.d.ts","sourceRoot":"","sources":["../../src/app-source.ts"],"names":[],"mappings":"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"}
|
package/dist/src/app-source.js
CHANGED
|
@@ -2,7 +2,32 @@
|
|
|
2
2
|
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
3
|
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Builds an app from its source: `e3-cloud app build` and `app deploy
|
|
7
|
+
* --from-source`, as e3's CLI loads a package for `e3 workspace deploy
|
|
8
|
+
* --from-source`. esbuild bundles the entry (multi-file TypeScript and TSX,
|
|
9
|
+
* with the nearest tsconfig.json), leaving every `@elaraai/*` import to the
|
|
10
|
+
* project's own packages; the bundle is imported from under the project's
|
|
11
|
+
* `node_modules`, and its default export must be an app (`App(...)` of
|
|
12
|
+
* `@elaraai/e3-cloud-ui`). The app is built by the project's own
|
|
13
|
+
* `@elaraai/e3-cloud-ui`, the one its source imports, so the app, its pages
|
|
14
|
+
* and its package are of the modules the build reads them with.
|
|
15
|
+
*
|
|
16
|
+
* Built `--against-workspace`, an app names the package a workspace runs, as
|
|
17
|
+
* its repository holds it, rather than the package its source exports again
|
|
18
|
+
* ({@link bindToWorkspacePackage}), once the two are found to differ only
|
|
19
|
+
* where no page reads (`package-compare.ts`): the bundle then carries no
|
|
20
|
+
* package.
|
|
21
|
+
*/
|
|
22
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
23
|
+
import { createRequire } from 'node:module';
|
|
24
|
+
import { dirname, join, parse } from 'node:path';
|
|
25
|
+
import { StringType, equalFor, isValueOf } from '@elaraai/east';
|
|
26
|
+
import { compareReleases } from '@elaraai/e3-types';
|
|
27
|
+
import { AppProblemType, appProblemLines } from '@elaraai/e3-cloud-types';
|
|
28
|
+
import * as ownChecks from '@elaraai/e3-cloud-ui/check';
|
|
5
29
|
import { importEntry, resolveSource, sourceDefaultExport } from './source-module.js';
|
|
30
|
+
const sameString = equalFor(StringType);
|
|
6
31
|
/**
|
|
7
32
|
* Builds the app a source file's default export defines into a bundle.
|
|
8
33
|
*
|
|
@@ -21,4 +46,281 @@ export async function buildAppFromSource(file) {
|
|
|
21
46
|
const ui = await importEntry(entryPath);
|
|
22
47
|
return ui.buildApp(exported);
|
|
23
48
|
}
|
|
49
|
+
/** A package, as people name it: `acme@1.5.0`. */
|
|
50
|
+
function packageWords(pkg) {
|
|
51
|
+
return `${pkg.name}@${pkg.version}`;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Binds a bundle to the package a workspace runs, as its repository holds it
|
|
55
|
+
* (`--against-workspace`): the app names that package, and the bundle carries
|
|
56
|
+
* no package of its own (a zip of no bytes). Its pages and the e3 they were
|
|
57
|
+
* built with stay as built. Whether the two packages differ only where no page
|
|
58
|
+
* reads is `comparePackages`' to say, before this binds.
|
|
59
|
+
*
|
|
60
|
+
* @param bundle - The bundle, as the build made it
|
|
61
|
+
* @param running - The package the workspace runs
|
|
62
|
+
* @param workspace - The workspace, for the words
|
|
63
|
+
* @returns The bound bundle
|
|
64
|
+
* @throws {Error} When the source declares another package, or another
|
|
65
|
+
* version of it, than the workspace runs
|
|
66
|
+
*/
|
|
67
|
+
export function bindToWorkspacePackage(bundle, running, workspace) {
|
|
68
|
+
const { app } = bundle;
|
|
69
|
+
const declared = app.package;
|
|
70
|
+
if (!sameString(declared.name, running.name) || !sameString(declared.version, running.version)) {
|
|
71
|
+
throw new Error(`${workspace} runs ${packageWords(running)}, and ${app.name}'s source declares ${packageWords(declared)}: an app is built against the package its workspace runs only from the source of that package and version`);
|
|
72
|
+
}
|
|
73
|
+
return { app: { ...app, package: { name: running.name, version: running.version, hash: running.hash } }, package: new Uint8Array(0) };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Whether one e3 release is newer than another, by e3's own order; false for
|
|
77
|
+
* a text that is no release.
|
|
78
|
+
*
|
|
79
|
+
* @param release - The release
|
|
80
|
+
* @param than - The release it is compared with
|
|
81
|
+
* @returns Whether `release` comes after `than`
|
|
82
|
+
*/
|
|
83
|
+
export function newerRelease(release, than) {
|
|
84
|
+
try {
|
|
85
|
+
return compareReleases(release, than) > 0;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** The checks' problems that are of an app's fit to a package, as against its own form or its e3. */
|
|
92
|
+
export const FIT_PROBLEMS = new Set([
|
|
93
|
+
'dataset_missing', 'dataset_type', 'dataset_not_writable', 'paged_missing', 'paged_type',
|
|
94
|
+
'function_missing', 'function_signature', 'function_drafts',
|
|
95
|
+
'record_missing', 'record_type', 'mutation_missing', 'mutation_signature', 'index_missing', 'index_type',
|
|
96
|
+
'task_missing', 'task_not_ui',
|
|
97
|
+
]);
|
|
98
|
+
/**
|
|
99
|
+
* What the CLI says of a build for the platform's next e3 with a package of
|
|
100
|
+
* its own, on a deployment that holds that package for its move: the
|
|
101
|
+
* way across the move for an app that can't be built against the package its
|
|
102
|
+
* workspace runs, rather than removing it before the move.
|
|
103
|
+
*/
|
|
104
|
+
export const HOLDS_FOR_THE_MOVE = 'the platform holds that package for its move and deploys it then';
|
|
105
|
+
/** What a refusal says of the way across the move when whether the platform holds packages could not be read. */
|
|
106
|
+
export function holdsUnknownWords(holds) {
|
|
107
|
+
return `Whether this deployment holds a package for the platform's move could not be read (${holds.unknown}): run it again to be told the way across the move`;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* What follows the problems of a refused deploy for the apps of it built
|
|
111
|
+
* against a package their repository holds: for an app the package does not
|
|
112
|
+
* fit, that it cannot as its source declares it, and how it crosses the
|
|
113
|
+
* platform's move (with a package of its own, where the platform holds one
|
|
114
|
+
* for the move; else only by its removal); for one built with a newer
|
|
115
|
+
* e3 than the platform runs, that a bundle for the platform's next e3 is
|
|
116
|
+
* staged with `--for-platform`. Nothing for any other problem.
|
|
117
|
+
*
|
|
118
|
+
* @param refused - Each refused app's problems
|
|
119
|
+
* @param bound - The apps of the deploy built against a package their repository holds
|
|
120
|
+
* @param pkg - That package, as `name@version`
|
|
121
|
+
* @param which - Which package it is, in words: `which production runs`
|
|
122
|
+
* @param staging - The e3 the deploy stages for (`--for-platform`), or null
|
|
123
|
+
* @param holds - Whether the platform holds a build's own package for its
|
|
124
|
+
* move: then an app that cannot fit is prepared with it, and is
|
|
125
|
+
* never removed across the move
|
|
126
|
+
* @returns The lines
|
|
127
|
+
*/
|
|
128
|
+
export function boundRefusalLines(refused, bound, pkg, which, staging, holds = false) {
|
|
129
|
+
const lines = [];
|
|
130
|
+
for (const entry of refused) {
|
|
131
|
+
if (!bound.has(entry.app))
|
|
132
|
+
continue;
|
|
133
|
+
if (entry.problems.some((problem) => FIT_PROBLEMS.has(problem.type))) {
|
|
134
|
+
lines.push(`${entry.app} was built against ${pkg}, ${which}, and doesn't fit it: its source declares other types or names than that package. Build it from the source ${pkg} was exported from. ${holds === true
|
|
135
|
+
? `Or deploy it with a package of its own, without --against-workspace, giving the package a new version in its source: ${HOLDS_FOR_THE_MOVE}.`
|
|
136
|
+
: holds === false ? 'A bundle for the next e3 that cannot fit is staged only by removing the app before the platform moves and deploying it after.' : `${holdsUnknownWords(holds)}.`}`);
|
|
137
|
+
}
|
|
138
|
+
const other = entry.problems.find((problem) => problem.type === 'e3_version');
|
|
139
|
+
// Staged only for a move to a newer e3 than the platform runs
|
|
140
|
+
if (other !== undefined && staging === null && newerRelease(other.value.builtWith, other.value.platform)) {
|
|
141
|
+
const { builtWith, platform } = other.value;
|
|
142
|
+
lines.push(`${entry.app} is built with e3 ${builtWith}, and the platform runs e3 ${platform}: stage it for the platform's move to ${builtWith} with --for-platform ${builtWith}.`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return lines;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Whether a bundle carries its package's zip: one built against a package
|
|
149
|
+
* its repository holds carries none.
|
|
150
|
+
*
|
|
151
|
+
* @param bundle - The bundle
|
|
152
|
+
* @returns Whether its zip has any bytes
|
|
153
|
+
*/
|
|
154
|
+
export function carriesPackage(bundle) {
|
|
155
|
+
return bundle.package.byteLength > 0;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The lines a binding prints of its `Page.task` pages whose task's output the
|
|
159
|
+
* held package types otherwise than the app's source: the checks hold such a
|
|
160
|
+
* page to its task and its UI role alone, so it is bound, and after the
|
|
161
|
+
* platform's move it shows output computed in the held package's type.
|
|
162
|
+
*
|
|
163
|
+
* @param app - The app's name
|
|
164
|
+
* @param held - The held package in words, e.g. `acme@1.5.0`
|
|
165
|
+
* @param pages - Those pages, each with the task it shows
|
|
166
|
+
* @returns A line each
|
|
167
|
+
*/
|
|
168
|
+
export function taskPageLines(app, held, pages) {
|
|
169
|
+
return pages.map(({ page, task }) => `Page ${page} of ${app} shows task ${task}, whose output ${held} types otherwise than ${app}'s source: it is bound, since the platform holds a task page only to its task and its UI role; after the platform's move it shows output computed in ${held}'s type until the package is exported again with the new release`);
|
|
170
|
+
}
|
|
171
|
+
/** The release of the package an entry belongs to: the nearest package.json above it of that name. */
|
|
172
|
+
function releaseOf(entryPath, name) {
|
|
173
|
+
for (let dir = dirname(entryPath); dir !== parse(dir).root; dir = dirname(dir)) {
|
|
174
|
+
const file = join(dir, 'package.json');
|
|
175
|
+
if (!existsSync(file))
|
|
176
|
+
continue;
|
|
177
|
+
try {
|
|
178
|
+
const pkg = JSON.parse(readFileSync(file, 'utf8'));
|
|
179
|
+
if (pkg.name === name && typeof pkg.version === 'string')
|
|
180
|
+
return pkg.version;
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The checks a binding runs: those of the `@elaraai/e3-cloud-ui` the
|
|
190
|
+
* source's project resolves, the release its build ran. The checks read a
|
|
191
|
+
* page as e3-ui of their release reads it (its manifest, the binds it
|
|
192
|
+
* makes), so a check of another release than the build's may refuse a page
|
|
193
|
+
* the build made (`manifest_mismatch`, `invalid_page`). This CLI's own are
|
|
194
|
+
* the fallback, said, when the project's can't be loaded.
|
|
195
|
+
*
|
|
196
|
+
* @param source - The app's source
|
|
197
|
+
* @returns The checks, where they come from, and their release
|
|
198
|
+
*/
|
|
199
|
+
export async function bindingChecks(source) {
|
|
200
|
+
const own = (fallback) => ({
|
|
201
|
+
checks: ownChecks, from: 'cli', fallback,
|
|
202
|
+
version: releaseOf(createRequire(import.meta.url).resolve('@elaraai/e3-cloud-ui/check'), '@elaraai/e3-cloud-ui'),
|
|
203
|
+
});
|
|
204
|
+
let entryPath;
|
|
205
|
+
try {
|
|
206
|
+
entryPath = resolveSource(source, '@elaraai/e3-cloud-ui/check', 'an app is checked').entryPath;
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
return own('its project resolves no @elaraai/e3-cloud-ui/check');
|
|
210
|
+
}
|
|
211
|
+
let checks;
|
|
212
|
+
try {
|
|
213
|
+
checks = await importEntry(entryPath);
|
|
214
|
+
}
|
|
215
|
+
catch (err) {
|
|
216
|
+
return own(`its project's @elaraai/e3-cloud-ui/check failed to load: ${err instanceof Error ? err.message.split('\n')[0] : 'an error'}`);
|
|
217
|
+
}
|
|
218
|
+
if (typeof checks.checkApp !== 'function' || typeof checks.readPackageView !== 'function') {
|
|
219
|
+
return own("its project's @elaraai/e3-cloud-ui/check gives no checkApp and readPackageView");
|
|
220
|
+
}
|
|
221
|
+
return { checks, from: 'project', fallback: null, version: releaseOf(entryPath, '@elaraai/e3-cloud-ui') };
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The checks a build is checked with here: the project's, as {@link
|
|
225
|
+
* bindingChecks} finds them, for a build from source; this CLI's own for a
|
|
226
|
+
* bundle read from a file, which names no project.
|
|
227
|
+
*
|
|
228
|
+
* @param source - The app's source, or null for a bundle file
|
|
229
|
+
* @returns The checks, where they come from, and their release
|
|
230
|
+
*/
|
|
231
|
+
export async function checksFor(source) {
|
|
232
|
+
if (source !== null)
|
|
233
|
+
return bindingChecks(source);
|
|
234
|
+
return {
|
|
235
|
+
checks: ownChecks, from: 'cli', fallback: 'a bundle file names no project',
|
|
236
|
+
version: releaseOf(createRequire(import.meta.url).resolve('@elaraai/e3-cloud-ui/check'), '@elaraai/e3-cloud-ui'),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* The checks' problems as lines: each kind this CLI knows in its words
|
|
241
|
+
* (`appProblemLines`); one it doesn't (from a newer project's checks) as it
|
|
242
|
+
* came, its kind and its text fields, never a failure of its own.
|
|
243
|
+
*
|
|
244
|
+
* @param problems - The problems
|
|
245
|
+
* @param names - The app and the package, for the words
|
|
246
|
+
* @returns A line each, indented two spaces
|
|
247
|
+
*/
|
|
248
|
+
export function problemLines(problems, names) {
|
|
249
|
+
const known = problems.filter((problem) => Object.hasOwn(AppProblemType.cases, problem.type));
|
|
250
|
+
const unknown = problems.filter((problem) => !Object.hasOwn(AppProblemType.cases, problem.type));
|
|
251
|
+
return [
|
|
252
|
+
...appProblemLines(known, names, ' '),
|
|
253
|
+
...unknown.map((problem) => {
|
|
254
|
+
const value = problem.value;
|
|
255
|
+
const fields = value !== null && typeof value === 'object'
|
|
256
|
+
? Object.entries(value).filter(([, field]) => isValueOf(field, StringType)).map(([name, field]) => `${name} ${field}`)
|
|
257
|
+
: [];
|
|
258
|
+
return ` ${problem.type} a problem this e3-cloud CLI doesn't know${fields.length === 0 ? '' : `: ${fields.join(', ')}`}`;
|
|
259
|
+
}),
|
|
260
|
+
];
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The lines refusing a binding the checks refuse, split by what the problems
|
|
264
|
+
* are of. Problems of fit are of what the app's pages bind against what the
|
|
265
|
+
* held package declares. Any other is of the app as built (its pages, their
|
|
266
|
+
* manifests, its names), which the checks read as e3-ui of their release does.
|
|
267
|
+
*
|
|
268
|
+
* @param app - The app's name
|
|
269
|
+
* @param held - The held package in words, e.g. `acme@1.5.0`
|
|
270
|
+
* @param which - Which workspace runs it, e.g. `which production runs`
|
|
271
|
+
* @param problems - The checks' problems against the held package
|
|
272
|
+
* @param checks - Where the checks came from, and their release
|
|
273
|
+
* @param holds - Whether the platform holds a build's own package for its
|
|
274
|
+
* move: then the way across the move is that package, never the
|
|
275
|
+
* app's removal
|
|
276
|
+
* @returns The lines; none for no problems
|
|
277
|
+
*/
|
|
278
|
+
export function bindingRefusalLines(app, held, which, problems, checks, holds = false) {
|
|
279
|
+
const fit = problems.filter((problem) => FIT_PROBLEMS.has(problem.type));
|
|
280
|
+
const other = problems.filter((problem) => !FIT_PROBLEMS.has(problem.type));
|
|
281
|
+
const lines = [];
|
|
282
|
+
const names = { app, package: held };
|
|
283
|
+
if (fit.length > 0) {
|
|
284
|
+
lines.push(`${app} can't be built against ${held}, ${which}: its pages bind what that package declares otherwise, which the platform's checks refuse`, ...problemLines(fit, names), `Its source declares them otherwise, in its own code or because this release of e3 or east-ui defines a type otherwise than the one that exported ${held}. Build it from the source and the e3 ${held} was exported with${holds === true
|
|
285
|
+
? `; or deploy ${app} with a package of its own, without --against-workspace, giving the package a new version in its source: ${HOLDS_FOR_THE_MOVE}`
|
|
286
|
+
: holds === false ? `; or, to carry it across the platform's move, remove ${app} before the move and deploy it after` : `. ${holdsUnknownWords(holds)}`}`);
|
|
287
|
+
}
|
|
288
|
+
if (other.length > 0) {
|
|
289
|
+
const release = checks.version === null ? '' : ` ${checks.version}`;
|
|
290
|
+
lines.push(`${app} can't be built against ${held}, ${which}: the checks refuse ${app} as built, which is no matter of what ${held} declares`, ...problemLines(other, names), checks.from === 'project'
|
|
291
|
+
? `These are of its pages as the project's @elaraai/e3-cloud-ui${release} builds and reads them, the checks its own build ran: the platform's deploy would refuse them too. Correct the pages`
|
|
292
|
+
: `These are this CLI's checks (@elaraai/e3-cloud-ui${release}), since ${checks.fallback ?? "the project's can't be loaded"}; they read a page as e3-ui of their release does, so when the project builds with another release they may refuse what its build made. Check it with e3-cloud app deploy … --dry-run, which the platform's own checks answer`);
|
|
293
|
+
}
|
|
294
|
+
return lines;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The lines a deploy of bundles carrying no package prints when the platform
|
|
298
|
+
* answers it with a deploy of their package: the workspace moved in the
|
|
299
|
+
* seconds after it was read, and the held package is being deployed back over
|
|
300
|
+
* it. Nothing on the platform side refuses that yet; the CLI says it loudly
|
|
301
|
+
* and exits non-zero, so it can't pass unnoticed.
|
|
302
|
+
*
|
|
303
|
+
* The way back is a rollback to the workspace's entry for the package it had
|
|
304
|
+
* moved to, which gives it that entry's package and apps exactly: a protected
|
|
305
|
+
* workspace takes a package only by a release or a rollback, and a deploy of
|
|
306
|
+
* that package alone would be refused by the apps now live on the held one,
|
|
307
|
+
* where they don't fit it.
|
|
308
|
+
*
|
|
309
|
+
* @param url - The repository's URL
|
|
310
|
+
* @param workspace - The workspace
|
|
311
|
+
* @param held - The package the bundles were built against, with its hash
|
|
312
|
+
* @param movedTo - The package the workspace had moved to, with its hash, when read; null when not known
|
|
313
|
+
* @param job - The platform's deploy job
|
|
314
|
+
* @param apps - The apps carrying no package
|
|
315
|
+
* @returns The lines
|
|
316
|
+
*/
|
|
317
|
+
export function movedDuringDeployLines(url, workspace, held, movedTo, job, apps) {
|
|
318
|
+
const one = apps.length === 1;
|
|
319
|
+
return [
|
|
320
|
+
`!! ${workspace} moved to ${movedTo ?? 'another package'} in the seconds after it was read, and the platform is deploying ${held} back over it (job ${job}).`,
|
|
321
|
+
`!! ${apps.join(', ')} ${one ? 'carries' : 'carry'} no package and ${one ? 'was' : 'were'} built against ${held}, which ${workspace} ran when it was read.`,
|
|
322
|
+
`!! To put it right, once the job completes: e3-cloud history ${url} ${workspace} lists the deploy it had moved to${movedTo === null ? '' : ` (${movedTo})`}; e3-cloud rollback ${url} ${workspace} --plan, then without --plan, gives it back that entry's package and apps exactly (owner or admin).`,
|
|
323
|
+
`!! Not a deploy of that package alone: a protected workspace takes a package only by a release or a rollback, and the apps now live on ${held} are checked against it and refused where they don't fit. Then build ${one ? 'the app' : 'the apps'} again with --against-workspace.`,
|
|
324
|
+
];
|
|
325
|
+
}
|
|
24
326
|
//# sourceMappingURL=app-source.js.map
|