ezship 0.1.13 → 0.1.14
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/commands.d.mts +16 -0
- package/commands.mjs +82 -5
- package/package.json +1 -1
- package/types.d.mts +21 -1
package/commands.d.mts
CHANGED
|
@@ -41,6 +41,7 @@ import type {
|
|
|
41
41
|
DeployResult,
|
|
42
42
|
FormatResult,
|
|
43
43
|
FunctionResult,
|
|
44
|
+
GlobalSinceDeploy,
|
|
44
45
|
RenderRequest,
|
|
45
46
|
RenderRow,
|
|
46
47
|
InstanceInfo,
|
|
@@ -630,6 +631,21 @@ export const AUTH_PATH: string;
|
|
|
630
631
|
|
|
631
632
|
export function hashContent(s: string): string;
|
|
632
633
|
export function localChanges(files: Record<string, string>, pulled: Pulled | null): Changes;
|
|
634
|
+
/**
|
|
635
|
+
* Whether a change to this Global Workspace file reaches a deployed Site only at its next Preview or Deploy
|
|
636
|
+
* (docs/adr/0096): false for the Live-only files (session.ts, schedules.json, jobs/) and the files no app is
|
|
637
|
+
* built from (CONTEXT.md, docs/, the generated db/types.d.ts).
|
|
638
|
+
*/
|
|
639
|
+
export function pinnedGlobalPath(path: string): boolean;
|
|
640
|
+
/**
|
|
641
|
+
* What the Site's next deploy brings in from the Global Workspace (`site` is its remoteStatus, `global` the
|
|
642
|
+
* Global Workspace): null when the Site has no recorded deploy or the Host does not say which Global Version
|
|
643
|
+
* it built in.
|
|
644
|
+
*/
|
|
645
|
+
export function globalSinceDeploy(
|
|
646
|
+
site: WorkspaceInfo,
|
|
647
|
+
global: Workspace,
|
|
648
|
+
): Promise<GlobalSinceDeploy | null>;
|
|
633
649
|
export function countChanges(c: Changes): number;
|
|
634
650
|
export function ago(at: number | null | undefined): string;
|
|
635
651
|
|
package/commands.mjs
CHANGED
|
@@ -4458,6 +4458,8 @@ How to work
|
|
|
4458
4458
|
6. \`ez preview\` (or \`ez dev\`, which keeps it current) and give the user \`ez link --preview <name>\`;
|
|
4459
4459
|
a successful preview is also a check. Its data is the live data.
|
|
4460
4460
|
7. Keep CONTEXT.md and the docs current, \`ez pull\`, \`ez push -m "<what it is for>"\`, and \`ez deploy\` once the user agrees.
|
|
4461
|
+
Before you ask, \`ez status\`: its "global:" line names the Global changes pushed since the live app
|
|
4462
|
+
was built, which the deploy brings in too; name them to the user.
|
|
4461
4463
|
Ask the user before \`ez deploy\` and before every App Database write: \`ez db sql\` INSERT, UPDATE or DELETE,
|
|
4462
4464
|
\`ez db attach\`, \`ez db redact\` and \`ez function call\`. \`ez check\`, \`ez format\` and \`ez preview\` are free
|
|
4463
4465
|
to run. When ezship itself fails (a command errors in a way no change to the code fixes, or the platform does
|
|
@@ -5507,7 +5509,7 @@ export const COMMANDS = [
|
|
|
5507
5509
|
},
|
|
5508
5510
|
{
|
|
5509
5511
|
usage: "ez status",
|
|
5510
|
-
help: "the shared files' version, what you pulled, your unpushed changes, what deploy would do to the schema",
|
|
5512
|
+
help: "the shared files' version, what you pulled, your unpushed changes, what deploy would do to the schema and which Global changes it brings in",
|
|
5511
5513
|
},
|
|
5512
5514
|
{
|
|
5513
5515
|
usage: "ez pull [--force] [--version <n>] [--all]",
|
|
@@ -5515,7 +5517,7 @@ export const COMMANDS = [
|
|
|
5515
5517
|
},
|
|
5516
5518
|
{
|
|
5517
5519
|
usage: 'ez push [-m "<message>"] [--prune] [--force] [--dry-run] [--acknowledge-exposure]',
|
|
5518
|
-
help: "replace the shared files with the working copy, deleting the pulled files you removed (--prune also deletes shared files this copy never pulled); -m says what the push is for, shown by ez versions; in <instance>/global, the Global Workspace's, after `ez global check` passes for it and every Site (--force skips that; admins only); a global push lists what takes effect now (defaults, access rules, session.ts, rules), --dry-run shows that and each changed rule's effect without pushing, --acknowledge-exposure accepts access rules that let Members read more",
|
|
5520
|
+
help: "replace the shared files with the working copy, deleting the pulled files you removed (--prune also deletes shared files this copy never pulled); -m says what the push is for, shown by ez versions; in <instance>/global, the Global Workspace's, after `ez global check` passes for it and every Site (--force skips that; admins only); a global push lists what takes effect now (defaults, access rules, session.ts, rules), --dry-run shows that and each changed rule's effect without pushing (a Site push refuses it), --acknowledge-exposure accepts access rules that let Members read more",
|
|
5519
5521
|
},
|
|
5520
5522
|
{ usage: "ez deploy", help: "ship the shared files to the live app" },
|
|
5521
5523
|
{
|
|
@@ -5820,6 +5822,15 @@ export function ago(at) {
|
|
|
5820
5822
|
return `${Math.round(s / 86400)}d ago`;
|
|
5821
5823
|
}
|
|
5822
5824
|
|
|
5825
|
+
/** @type {typeof import("./commands.d.mts").pinnedGlobalPath} */
|
|
5826
|
+
export const pinnedGlobalPath = (path) =>
|
|
5827
|
+
path !== SESSION_FILE &&
|
|
5828
|
+
path !== SCHEDULES_FILE &&
|
|
5829
|
+
jobName(path) === null &&
|
|
5830
|
+
path !== CONTEXT_FILE &&
|
|
5831
|
+
docName(path) === null &&
|
|
5832
|
+
path !== TYPES_FILE;
|
|
5833
|
+
|
|
5823
5834
|
/**
|
|
5824
5835
|
* A Global push's two kinds of change (docs/adr/0096): Live ones took effect for every deployed Site at once;
|
|
5825
5836
|
* the rest reach each Site at its next Preview or Deploy.
|
|
@@ -5896,9 +5907,7 @@ function liveLines(result) {
|
|
|
5896
5907
|
}`,
|
|
5897
5908
|
);
|
|
5898
5909
|
}
|
|
5899
|
-
const pinned = result.written.filter(
|
|
5900
|
-
(p) => p !== SESSION_FILE && p !== SCHEDULES_FILE && !jobName(p),
|
|
5901
|
-
);
|
|
5910
|
+
const pinned = result.written.filter(pinnedGlobalPath);
|
|
5902
5911
|
if (pinned.length)
|
|
5903
5912
|
lines.push(`Takes effect at each Site's next Preview or Deploy: ${pinned.join(", ")}`);
|
|
5904
5913
|
return lines;
|
|
@@ -6008,6 +6017,59 @@ async function schemaStatus(ws, files, instance, siteId) {
|
|
|
6008
6017
|
return { lines, data: { ok: true, created, added, indexed, conflicts: plan.conflicts } };
|
|
6009
6018
|
}
|
|
6010
6019
|
|
|
6020
|
+
/**
|
|
6021
|
+
* What the Site's next deploy brings in from the Global Workspace (docs/adr/0141): the pushed Global files that
|
|
6022
|
+
* changed since the Version its live app was built with, as the Host recorded that deploy. A deploy builds the
|
|
6023
|
+
* pushed Global, so unpushed Global changes are not among them.
|
|
6024
|
+
* @type {typeof import("./commands.d.mts").globalSinceDeploy}
|
|
6025
|
+
*/
|
|
6026
|
+
export async function globalSinceDeploy(site, global) {
|
|
6027
|
+
const deployed = site.deployedGlobal;
|
|
6028
|
+
if (site.deployedAt === null || typeof deployed !== "number") return null;
|
|
6029
|
+
const newest = (await global.remoteStatus()).version.n;
|
|
6030
|
+
if (newest <= deployed)
|
|
6031
|
+
return { deployed, current: newest, paths: { added: [], changed: [], removed: [] } };
|
|
6032
|
+
const [before, after] = await Promise.all([
|
|
6033
|
+
deployed === 0
|
|
6034
|
+
? { files: /** @type {Record<string, string>} */ ({}) }
|
|
6035
|
+
: global.fetchAll(deployed).catch(() => null),
|
|
6036
|
+
global.fetchAll(),
|
|
6037
|
+
]);
|
|
6038
|
+
const current = after.version.n;
|
|
6039
|
+
if (!before) return { deployed, current, paths: null };
|
|
6040
|
+
const was = before.files;
|
|
6041
|
+
const now = after.files;
|
|
6042
|
+
/** @param {string[]} paths */
|
|
6043
|
+
const pinned = (paths) => paths.filter(pinnedGlobalPath).sort();
|
|
6044
|
+
return {
|
|
6045
|
+
deployed,
|
|
6046
|
+
current,
|
|
6047
|
+
paths: {
|
|
6048
|
+
added: pinned(Object.keys(now).filter((p) => !(p in was))),
|
|
6049
|
+
changed: pinned(Object.keys(now).filter((p) => p in was && was[p] !== now[p])),
|
|
6050
|
+
removed: pinned(Object.keys(was).filter((p) => !(p in now))),
|
|
6051
|
+
},
|
|
6052
|
+
};
|
|
6053
|
+
}
|
|
6054
|
+
|
|
6055
|
+
/**
|
|
6056
|
+
* `ez status`'s Global line: what a deploy brings in from the Global Workspace.
|
|
6057
|
+
* @param {import("./types.d.mts").GlobalSinceDeploy} g
|
|
6058
|
+
*/
|
|
6059
|
+
function globalStatusLine(g) {
|
|
6060
|
+
const live = `the live app was built with Global v${g.deployed}`;
|
|
6061
|
+
if (!g.paths)
|
|
6062
|
+
return `global: deploy would bring in Global v${g.current} (${live}, no longer retained, so its changes cannot be listed)`;
|
|
6063
|
+
const { added, changed, removed } = g.paths;
|
|
6064
|
+
if (added.length + changed.length + removed.length === 0)
|
|
6065
|
+
return `global: up to date (${live}${g.current > g.deployed ? `; v${g.current} changed nothing a deploy brings in` : ""})`;
|
|
6066
|
+
const parts = [];
|
|
6067
|
+
if (added.length) parts.push(`added ${added.join(", ")}`);
|
|
6068
|
+
if (changed.length) parts.push(`changed ${changed.join(", ")}`);
|
|
6069
|
+
if (removed.length) parts.push(`removed ${removed.join(", ")}`);
|
|
6070
|
+
return `global: deploy would bring in Global v${g.current} (${live}): ${parts.join("; ")}`;
|
|
6071
|
+
}
|
|
6072
|
+
|
|
6011
6073
|
/**
|
|
6012
6074
|
* A short human label for a command, for the chat UI ("Read index.html"). Never shows the argv itself.
|
|
6013
6075
|
* @type {typeof import("./commands.d.mts").describeCommand}
|
|
@@ -6515,6 +6577,14 @@ async function execute(ws, argv, stdin) {
|
|
|
6515
6577
|
? null
|
|
6516
6578
|
: await schemaStatus(ws, (await ws.globalFiles?.()) ?? {}, remote.instance, remote.id);
|
|
6517
6579
|
if (schema) lines.push(...schema.lines);
|
|
6580
|
+
// What the deploy also brings in from the Global Workspace (docs/adr/0141); never fails the status.
|
|
6581
|
+
const brings = global
|
|
6582
|
+
? null
|
|
6583
|
+
: await (async () => {
|
|
6584
|
+
const g = await ws.globalWorkspace?.();
|
|
6585
|
+
return g ? globalSinceDeploy(remote, g) : null;
|
|
6586
|
+
})().catch(() => null);
|
|
6587
|
+
if (brings) lines.push(globalStatusLine(brings));
|
|
6518
6588
|
return out(lines.join("\n"), {
|
|
6519
6589
|
site: { instance: remote.instance, id: remote.id, name: remote.name },
|
|
6520
6590
|
version: remote.version,
|
|
@@ -6524,6 +6594,7 @@ async function execute(ws, argv, stdin) {
|
|
|
6524
6594
|
behind: !!(pulled && remote.version.n > pulled.version.n),
|
|
6525
6595
|
changes,
|
|
6526
6596
|
schema: schema?.data ?? null,
|
|
6597
|
+
global: brings,
|
|
6527
6598
|
});
|
|
6528
6599
|
}
|
|
6529
6600
|
|
|
@@ -6588,6 +6659,12 @@ async function execute(ws, argv, stdin) {
|
|
|
6588
6659
|
throw usage('ez push [-m "<message>"] [--prune] [--force]');
|
|
6589
6660
|
const checked = messageText(message, "The message");
|
|
6590
6661
|
if ("error" in checked) throw new Error(checked.error);
|
|
6662
|
+
// --dry-run reports a Global push's Live changes (docs/adr/0096). A Site push has none, and ignoring the
|
|
6663
|
+
// flag would push for real, so it is refused before anything is sent.
|
|
6664
|
+
if (!global && flags.has("--dry-run"))
|
|
6665
|
+
throw new Error(
|
|
6666
|
+
"--dry-run is for the Global Workspace (ez global push --dry-run); here it would push for real. Nothing was pushed. Run ez status to see what a push sends.",
|
|
6667
|
+
);
|
|
6591
6668
|
const files = await ws.files();
|
|
6592
6669
|
if (global && SCHEMA_FILE in files) await regenerateTypes(ws, SCHEMA_FILE);
|
|
6593
6670
|
await regenerateInventory(ws);
|
package/package.json
CHANGED
package/types.d.mts
CHANGED
|
@@ -78,7 +78,27 @@ export type Site = {
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
/** The Site row plus the shared files' version, its app URL and the caller's role (`ez config`, Workspace.remoteStatus). */
|
|
81
|
-
export type WorkspaceInfo = Site & {
|
|
81
|
+
export type WorkspaceInfo = Site & {
|
|
82
|
+
version: Version;
|
|
83
|
+
appUrl: string | null;
|
|
84
|
+
role: BuilderRole;
|
|
85
|
+
/**
|
|
86
|
+
* The Global Workspace's Version the Site's latest deploy compiled in (docs/adr/0141; 0 when Global was never
|
|
87
|
+
* pushed then), null when the Site has no recorded deploy. Absent from a Host older than the field.
|
|
88
|
+
*/
|
|
89
|
+
deployedGlobal?: number | null;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* What a Site's next deploy brings in from the Global Workspace (`ez status`, docs/adr/0141): the Version its
|
|
94
|
+
* live app was built with, the newest pushed one, and the files changed between them that reach an app only at
|
|
95
|
+
* a deploy (`pinnedGlobalPath`). `paths` is null when the live one is no longer retained.
|
|
96
|
+
*/
|
|
97
|
+
export type GlobalSinceDeploy = {
|
|
98
|
+
deployed: number;
|
|
99
|
+
current: number;
|
|
100
|
+
paths: { added: string[]; changed: string[]; removed: string[] } | null;
|
|
101
|
+
};
|
|
82
102
|
|
|
83
103
|
/**
|
|
84
104
|
* What a push did (Workspace.pushAll). A Global push also lists its Live changes (docs/adr/0096), which took
|