@lazehq/cli 0.1.37 → 0.1.38
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/dist/laze.mjs +148 -38
- package/package.json +1 -1
package/dist/laze.mjs
CHANGED
|
@@ -35708,7 +35708,7 @@ function flagText({
|
|
|
35708
35708
|
}
|
|
35709
35709
|
|
|
35710
35710
|
// src/rules/cli-version.rules.ts
|
|
35711
|
-
var STAMPED = "0.1.
|
|
35711
|
+
var STAMPED = "0.1.38";
|
|
35712
35712
|
function cliVersionOf({ stamped = STAMPED } = {}) {
|
|
35713
35713
|
return stamped.startsWith("__") ? "dev" : stamped;
|
|
35714
35714
|
}
|
|
@@ -83783,7 +83783,8 @@ import { mkdir as mkdir20, readFile as readFile31, realpath, writeFile as writeF
|
|
|
83783
83783
|
import { dirname as dirname20, join as join21 } from "node:path";
|
|
83784
83784
|
|
|
83785
83785
|
// src/rules/cli-update.rules.ts
|
|
83786
|
-
var
|
|
83786
|
+
var CLI_PACKAGE = "@lazehq/cli";
|
|
83787
|
+
var CLI_PACKAGE_LATEST = `${CLI_PACKAGE}@latest`;
|
|
83787
83788
|
var MANAGERS = [
|
|
83788
83789
|
{ manager: "bun", pattern: /[\\/]\.?bun[\\/]/, command: ["bun", "add", "-g"] },
|
|
83789
83790
|
{ manager: "pnpm", pattern: /[\\/]\.?pnpm[\\/]/, command: ["pnpm", "add", "-g"] },
|
|
@@ -83796,7 +83797,17 @@ var MANAGERS = [
|
|
|
83796
83797
|
];
|
|
83797
83798
|
var NPM_PREFIX = /^(.+)[\\/]lib[\\/]node_modules[\\/]@lazehq[\\/]cli[\\/]/;
|
|
83798
83799
|
var NPX_CACHE2 = /[\\/]_npx[\\/]/;
|
|
83799
|
-
function
|
|
83800
|
+
function releaseAgeOverrideOf({
|
|
83801
|
+
manager,
|
|
83802
|
+
nowMs
|
|
83803
|
+
}) {
|
|
83804
|
+
if (manager === "npm")
|
|
83805
|
+
return [`--before=${Temporal3.Instant.fromEpochMilliseconds(nowMs).toString()}`];
|
|
83806
|
+
if (manager === "pnpm") return [`--config.minimum-release-age-exclude=${CLI_PACKAGE}`];
|
|
83807
|
+
if (manager === "bun") return ["--minimum-release-age=0"];
|
|
83808
|
+
return [];
|
|
83809
|
+
}
|
|
83810
|
+
function updatePlanOf({ script, nowMs }) {
|
|
83800
83811
|
if (script === SANDBOX_CLI_PATH) return { kind: "sandbox" };
|
|
83801
83812
|
const found = MANAGERS.find(({ pattern }) => pattern.test(script));
|
|
83802
83813
|
if (!found) return { kind: "unmanaged", script };
|
|
@@ -83804,17 +83815,59 @@ function updatePlanOf({ script }) {
|
|
|
83804
83815
|
return {
|
|
83805
83816
|
kind: "install",
|
|
83806
83817
|
manager: found.manager,
|
|
83807
|
-
command: [
|
|
83818
|
+
command: [
|
|
83819
|
+
...found.command,
|
|
83820
|
+
...prefix ? ["--prefix", prefix] : [],
|
|
83821
|
+
...releaseAgeOverrideOf({ manager: found.manager, nowMs }),
|
|
83822
|
+
CLI_PACKAGE_LATEST
|
|
83823
|
+
]
|
|
83808
83824
|
};
|
|
83809
83825
|
}
|
|
83810
|
-
|
|
83811
|
-
function releaseAgeRetryOf({
|
|
83826
|
+
function pinnedCommandOf({
|
|
83812
83827
|
plan: plan2,
|
|
83813
|
-
|
|
83828
|
+
version: version2
|
|
83814
83829
|
}) {
|
|
83815
|
-
|
|
83816
|
-
|
|
83817
|
-
|
|
83830
|
+
return plan2.command.map(
|
|
83831
|
+
(part) => part === CLI_PACKAGE_LATEST ? `${CLI_PACKAGE}@${version2}` : part
|
|
83832
|
+
);
|
|
83833
|
+
}
|
|
83834
|
+
var RELEASE_AGE_SETTINGS = {
|
|
83835
|
+
npm: [
|
|
83836
|
+
{ setting: "min-release-age", read: ["npm", "config", "get", "min-release-age"] },
|
|
83837
|
+
{ setting: "before", read: ["npm", "config", "get", "before"] }
|
|
83838
|
+
],
|
|
83839
|
+
pnpm: [
|
|
83840
|
+
{ setting: "minimum-release-age", read: ["pnpm", "config", "get", "minimum-release-age"] }
|
|
83841
|
+
]
|
|
83842
|
+
};
|
|
83843
|
+
function settingValueOf({ printed }) {
|
|
83844
|
+
const value = printed.trim();
|
|
83845
|
+
return value === "" || value === "null" || value === "undefined" || value === "0" ? null : value;
|
|
83846
|
+
}
|
|
83847
|
+
var VERSION_LINE = /^laze (\S+)\s*$/m;
|
|
83848
|
+
function printedVersionOf({ printed }) {
|
|
83849
|
+
return VERSION_LINE.exec(printed)?.[1] ?? null;
|
|
83850
|
+
}
|
|
83851
|
+
function heldBackLineOf({
|
|
83852
|
+
manager,
|
|
83853
|
+
installed,
|
|
83854
|
+
latest,
|
|
83855
|
+
settings: settings2,
|
|
83856
|
+
command,
|
|
83857
|
+
script
|
|
83858
|
+
}) {
|
|
83859
|
+
const head = latest ? `laze is ${installed} after the install, but the latest release is ${latest}.` : `laze is still ${installed} after the install, and the npm registry did not say which release is the latest.`;
|
|
83860
|
+
const line = command.join(" ");
|
|
83861
|
+
if (settings2.length > 0) {
|
|
83862
|
+
return `${head} ${manager}'s ${settings2.join(" and ")} setting holds back releases younger than it allows, so ${manager} kept or picked an older one. Install the latest with: ${line}
|
|
83863
|
+
`;
|
|
83864
|
+
}
|
|
83865
|
+
if (manager === "bun") {
|
|
83866
|
+
return `${head} A minimumReleaseAge in bunfig.toml may hold it back, or another laze comes first on PATH (this one is ${script}). Install the latest with: ${line}
|
|
83867
|
+
`;
|
|
83868
|
+
}
|
|
83869
|
+
return `${head} No release-age setting is set, so another laze may come first on PATH (this one is ${script}). Install the latest with: ${line}
|
|
83870
|
+
`;
|
|
83818
83871
|
}
|
|
83819
83872
|
|
|
83820
83873
|
// src/rules/cli-release.rules.ts
|
|
@@ -83879,7 +83932,7 @@ async function startedUpdate({
|
|
|
83879
83932
|
server
|
|
83880
83933
|
}) {
|
|
83881
83934
|
if (context.environment.inherited.LAZE_AUTO_UPDATE === "0") return null;
|
|
83882
|
-
const plan2 = updatePlanOf({ script: await scriptOf(context) });
|
|
83935
|
+
const plan2 = updatePlanOf({ script: await scriptOf(context), nowMs: context.nowMs() });
|
|
83883
83936
|
if (plan2.kind !== "install") return null;
|
|
83884
83937
|
const folder = dirname20(context.environment.configPath);
|
|
83885
83938
|
const stamp = join21(folder, "auto-update.json");
|
|
@@ -84947,6 +85000,8 @@ async function statusUsage() {
|
|
|
84947
85000
|
// src/services/update-commands.service.ts
|
|
84948
85001
|
import { realpath as realpath2 } from "node:fs/promises";
|
|
84949
85002
|
var BY_HAND = `npm install -g ${CLI_PACKAGE_LATEST}`;
|
|
85003
|
+
var REGISTRY_LATEST_URL = `https://registry.npmjs.org/${CLI_PACKAGE}/latest`;
|
|
85004
|
+
var REGISTRY_TIMEOUT_MS = 1e4;
|
|
84950
85005
|
async function realScriptOf({ program }) {
|
|
84951
85006
|
const script = program.at(-1) ?? "";
|
|
84952
85007
|
try {
|
|
@@ -84955,11 +85010,55 @@ async function realScriptOf({ program }) {
|
|
|
84955
85010
|
return script;
|
|
84956
85011
|
}
|
|
84957
85012
|
}
|
|
85013
|
+
async function latestReleaseOf({ context }) {
|
|
85014
|
+
try {
|
|
85015
|
+
const response = await context.fetcher(REGISTRY_LATEST_URL, {
|
|
85016
|
+
signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS)
|
|
85017
|
+
});
|
|
85018
|
+
if (!response.ok) return null;
|
|
85019
|
+
const body = await response.json();
|
|
85020
|
+
return typeof body.version === "string" ? body.version : null;
|
|
85021
|
+
} catch {
|
|
85022
|
+
return null;
|
|
85023
|
+
}
|
|
85024
|
+
}
|
|
85025
|
+
async function printedBy({
|
|
85026
|
+
context,
|
|
85027
|
+
command
|
|
85028
|
+
}) {
|
|
85029
|
+
let printed = "";
|
|
85030
|
+
const sink = {
|
|
85031
|
+
write: (chunk) => {
|
|
85032
|
+
printed += chunk;
|
|
85033
|
+
}
|
|
85034
|
+
};
|
|
85035
|
+
try {
|
|
85036
|
+
const code = await context.runCommand({ command, env: {}, stdout: sink, stderr: sink });
|
|
85037
|
+
return code === 0 ? printed : null;
|
|
85038
|
+
} catch {
|
|
85039
|
+
return null;
|
|
85040
|
+
}
|
|
85041
|
+
}
|
|
85042
|
+
async function releaseAgeSettingsOf({
|
|
85043
|
+
context,
|
|
85044
|
+
manager
|
|
85045
|
+
}) {
|
|
85046
|
+
const settings2 = [];
|
|
85047
|
+
for (const { setting, read: read3 } of RELEASE_AGE_SETTINGS[manager] ?? []) {
|
|
85048
|
+
const value = settingValueOf({ printed: await printedBy({ context, command: read3 }) ?? "" });
|
|
85049
|
+
if (value) settings2.push(`${setting}=${value}`);
|
|
85050
|
+
}
|
|
85051
|
+
return settings2;
|
|
85052
|
+
}
|
|
84958
85053
|
async function update2({
|
|
84959
85054
|
context,
|
|
84960
|
-
args
|
|
85055
|
+
args,
|
|
85056
|
+
mine: mine4 = cliVersionOf()
|
|
84961
85057
|
}) {
|
|
84962
|
-
const plan2 = updatePlanOf({
|
|
85058
|
+
const plan2 = updatePlanOf({
|
|
85059
|
+
script: await realScriptOf({ program: context.program }),
|
|
85060
|
+
nowMs: context.nowMs()
|
|
85061
|
+
});
|
|
84963
85062
|
if (plan2.kind === "sandbox") {
|
|
84964
85063
|
context.out("This laze comes with your computer and updates with every Laze release.\n");
|
|
84965
85064
|
return 0;
|
|
@@ -84973,40 +85072,51 @@ async function update2({
|
|
|
84973
85072
|
}
|
|
84974
85073
|
const line = plan2.command.join(" ");
|
|
84975
85074
|
if (args.flags["dry-run"]) {
|
|
84976
|
-
context.out(`laze ${
|
|
85075
|
+
context.out(`laze ${mine4}, installed with ${plan2.manager}. Would run: ${line}
|
|
84977
85076
|
`);
|
|
84978
85077
|
return 0;
|
|
84979
85078
|
}
|
|
84980
|
-
|
|
85079
|
+
const latest = await latestReleaseOf({ context });
|
|
85080
|
+
if (latest && latest === mine4) {
|
|
85081
|
+
context.out(`laze ${mine4} is the latest release.
|
|
84981
85082
|
`);
|
|
84982
|
-
|
|
84983
|
-
|
|
84984
|
-
|
|
84985
|
-
stderr2 += chunk;
|
|
84986
|
-
context.err(chunk);
|
|
84987
|
-
}
|
|
84988
|
-
};
|
|
84989
|
-
let code = await context.runCommand({ command: plan2.command, env: {}, stderr: tee });
|
|
84990
|
-
const retry = code === 0 ? null : releaseAgeRetryOf({ plan: plan2, stderr: stderr2 });
|
|
84991
|
-
if (retry) {
|
|
84992
|
-
const retryLine = retry.join(" ");
|
|
84993
|
-
context.out(
|
|
84994
|
-
`npm's min-release-age setting held back the latest release. Trying once more with the guard off for @lazehq/cli only: ${retryLine}
|
|
84995
|
-
`
|
|
84996
|
-
);
|
|
84997
|
-
code = await context.runCommand({ command: retry, env: {} });
|
|
84998
|
-
if (code !== 0) {
|
|
84999
|
-
context.err(`npm exited ${code}. Update by hand with: ${retryLine}
|
|
85083
|
+
return 0;
|
|
85084
|
+
}
|
|
85085
|
+
context.out(`Updating laze ${mine4} with ${plan2.manager}: ${line}
|
|
85000
85086
|
`);
|
|
85001
|
-
|
|
85002
|
-
|
|
85003
|
-
} else if (code !== 0) {
|
|
85087
|
+
const code = await context.runCommand({ command: plan2.command, env: {} });
|
|
85088
|
+
if (code !== 0) {
|
|
85004
85089
|
context.err(`${plan2.manager} exited ${code}. Update by hand with: ${line}
|
|
85005
85090
|
`);
|
|
85006
85091
|
return code;
|
|
85007
85092
|
}
|
|
85008
|
-
|
|
85009
|
-
|
|
85093
|
+
const printed = await printedBy({ context, command: [...context.program, "--version"] });
|
|
85094
|
+
const installed = printed === null ? null : printedVersionOf({ printed });
|
|
85095
|
+
if (!installed) {
|
|
85096
|
+
context.out("Installed. `laze --version` names the new version.\n");
|
|
85097
|
+
return 0;
|
|
85098
|
+
}
|
|
85099
|
+
const held = latest ? releaseSkewOf({ mine: installed, server: latest }) === "older" : installed === mine4;
|
|
85100
|
+
if (!held) {
|
|
85101
|
+
context.out(
|
|
85102
|
+
installed === mine4 ? `laze ${mine4} is the latest release.
|
|
85103
|
+
` : `Updated laze ${mine4} to ${installed}.
|
|
85104
|
+
`
|
|
85105
|
+
);
|
|
85106
|
+
return 0;
|
|
85107
|
+
}
|
|
85108
|
+
const settings2 = await releaseAgeSettingsOf({ context, manager: plan2.manager });
|
|
85109
|
+
context.err(
|
|
85110
|
+
heldBackLineOf({
|
|
85111
|
+
manager: plan2.manager,
|
|
85112
|
+
installed,
|
|
85113
|
+
latest,
|
|
85114
|
+
settings: settings2,
|
|
85115
|
+
command: latest ? pinnedCommandOf({ plan: plan2, version: latest }) : plan2.command,
|
|
85116
|
+
script: context.program.at(-1) ?? ""
|
|
85117
|
+
})
|
|
85118
|
+
);
|
|
85119
|
+
return 1;
|
|
85010
85120
|
}
|
|
85011
85121
|
|
|
85012
85122
|
// src/services/vault-save-message-commands.service.ts
|
package/package.json
CHANGED