@dreamboard-games/cli 0.1.30-alpha.18 → 0.1.30-alpha.19
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/agent-verifier/agent-workspace-verifier.mjs +10 -10
- package/dist/agent-verifier/{chunk-7MAOGFFP.mjs → chunk-3Y4FRMTK.mjs} +2 -2
- package/dist/agent-verifier/{chunk-RP7ZWFVH.mjs → chunk-5D3OJBDT.mjs} +4 -4
- package/dist/agent-verifier/{chunk-AQ6UQHPT.mjs → chunk-6AKXIY37.mjs} +52 -8
- package/dist/agent-verifier/chunk-6AKXIY37.mjs.map +1 -0
- package/dist/agent-verifier/{chunk-AG5J3SMN.mjs → chunk-AWZ4M4NS.mjs} +6 -2
- package/dist/agent-verifier/chunk-AWZ4M4NS.mjs.map +1 -0
- package/dist/agent-verifier/{chunk-PWPOLHTW.mjs → chunk-H5L4KK4Y.mjs} +5 -5
- package/dist/agent-verifier/{chunk-PWPOLHTW.mjs.map → chunk-H5L4KK4Y.mjs.map} +1 -1
- package/dist/agent-verifier/{chunk-B42OHJNY.mjs → chunk-LEWM26XR.mjs} +2 -2
- package/dist/agent-verifier/chunk-LEWM26XR.mjs.map +1 -0
- package/dist/agent-verifier/{chunk-RCYO6HWW.mjs → chunk-UMW24KZI.mjs} +2 -2
- package/dist/agent-verifier/{chunk-JB7VXCMB.mjs → chunk-ZOR5FTIG.mjs} +2 -2
- package/dist/agent-verifier/{compile-VOBO2I6D.mjs → compile-MO2URO5Z.mjs} +8 -8
- package/dist/agent-verifier/{global-config-L7PLLUK5.mjs → global-config-SXR6X3OZ.mjs} +3 -3
- package/dist/agent-verifier/{materialize-workspace-PAC75NSP.mjs → materialize-workspace-PWNT6HQK.mjs} +2 -2
- package/dist/agent-verifier/{reducer-native-test-harness-HSXRUGOR.mjs → reducer-native-test-harness-X2KQYSCD.mjs} +4 -4
- package/dist/agent-verifier/{static-scaffold-KSOTKJNQ.mjs → static-scaffold-HXUQLJVN.mjs} +2 -2
- package/dist/agent-verifier/{sync-MQJJEZAA.mjs → sync-5YM4CSXL.mjs} +8 -8
- package/dist/agent-verifier/{test-R6HC6CYZ.mjs → test-CNNVTFIG.mjs} +7 -7
- package/dist/authoring-compatibility-internal.js +1 -1
- package/dist/{chunk-2WB3DYW4.js → chunk-R6RB4EKH.js} +9 -4
- package/dist/chunk-R6RB4EKH.js.map +1 -0
- package/dist/{chunk-J3CWZHY7.js → chunk-VWMKJL4A.js} +47 -10
- package/dist/chunk-VWMKJL4A.js.map +1 -0
- package/dist/{chunk-2XMBZPL5.js → chunk-YRSE5DLH.js} +5 -5
- package/dist/{chunk-2XMBZPL5.js.map → chunk-YRSE5DLH.js.map} +1 -1
- package/dist/{global-config-VQWFTIAV.js → global-config-UHGWFJIK.js} +2 -2
- package/dist/index.js +401 -10
- package/dist/index.js.map +1 -1
- package/dist/internal.js +3 -3
- package/package.json +1 -1
- package/release/authoring-release-set.json +4 -4
- package/skills/dreamboard/SKILL.md +0 -8
- package/skills/dreamboard/references/building-your-first-game.md +15 -37
- package/skills/dreamboard/references/game-interface.md +2 -15
- package/skills/dreamboard/references/manifest-authoring.md +0 -8
- package/skills/dreamboard/references/reducer.md +2 -47
- package/skills/dreamboard/references/rule-authoring.md +0 -10
- package/skills/dreamboard/references/testing.md +3 -7
- package/dist/agent-verifier/chunk-AG5J3SMN.mjs.map +0 -1
- package/dist/agent-verifier/chunk-AQ6UQHPT.mjs.map +0 -1
- package/dist/agent-verifier/chunk-B42OHJNY.mjs.map +0 -1
- package/dist/chunk-2WB3DYW4.js.map +0 -1
- package/dist/chunk-J3CWZHY7.js.map +0 -1
- package/skills/dreamboard/references/canonical-concepts.md +0 -74
- /package/dist/agent-verifier/{chunk-7MAOGFFP.mjs.map → chunk-3Y4FRMTK.mjs.map} +0 -0
- /package/dist/agent-verifier/{chunk-RP7ZWFVH.mjs.map → chunk-5D3OJBDT.mjs.map} +0 -0
- /package/dist/agent-verifier/{chunk-RCYO6HWW.mjs.map → chunk-UMW24KZI.mjs.map} +0 -0
- /package/dist/agent-verifier/{chunk-JB7VXCMB.mjs.map → chunk-ZOR5FTIG.mjs.map} +0 -0
- /package/dist/agent-verifier/{compile-VOBO2I6D.mjs.map → compile-MO2URO5Z.mjs.map} +0 -0
- /package/dist/agent-verifier/{global-config-L7PLLUK5.mjs.map → global-config-SXR6X3OZ.mjs.map} +0 -0
- /package/dist/agent-verifier/{materialize-workspace-PAC75NSP.mjs.map → materialize-workspace-PWNT6HQK.mjs.map} +0 -0
- /package/dist/agent-verifier/{reducer-native-test-harness-HSXRUGOR.mjs.map → reducer-native-test-harness-X2KQYSCD.mjs.map} +0 -0
- /package/dist/agent-verifier/{static-scaffold-KSOTKJNQ.mjs.map → static-scaffold-HXUQLJVN.mjs.map} +0 -0
- /package/dist/agent-verifier/{sync-MQJJEZAA.mjs.map → sync-5YM4CSXL.mjs.map} +0 -0
- /package/dist/agent-verifier/{test-R6HC6CYZ.mjs.map → test-CNNVTFIG.mjs.map} +0 -0
- /package/dist/{global-config-VQWFTIAV.js.map → global-config-UHGWFJIK.js.map} +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
getGlobalConfigPath,
|
|
5
5
|
loadGlobalConfig,
|
|
6
6
|
saveGlobalConfig
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VWMKJL4A.js";
|
|
8
8
|
import "./chunk-FFO2IJL3.js";
|
|
9
9
|
import "./chunk-2H7UOFLK.js";
|
|
10
10
|
export {
|
|
@@ -13,4 +13,4 @@ export {
|
|
|
13
13
|
loadGlobalConfig,
|
|
14
14
|
saveGlobalConfig
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=global-config-
|
|
16
|
+
//# sourceMappingURL=global-config-UHGWFJIK.js.map
|
package/dist/index.js
CHANGED
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
parseQueryCommandArgs,
|
|
49
49
|
parseStatusCommandArgs,
|
|
50
50
|
parseSyncCommandArgs,
|
|
51
|
+
presentCliError,
|
|
51
52
|
projectIdFromSessionGameSource,
|
|
52
53
|
queueProjectRevisionCompileSdk,
|
|
53
54
|
refreshResolvedAuthSession,
|
|
@@ -64,7 +65,7 @@ import {
|
|
|
64
65
|
toDreamboardApiError,
|
|
65
66
|
valueOrUndefined,
|
|
66
67
|
waitForCompiledResultJobSdk
|
|
67
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-R6RB4EKH.js";
|
|
68
69
|
import {
|
|
69
70
|
applyWorkspaceCodegen,
|
|
70
71
|
assertCliStaticScaffoldComplete,
|
|
@@ -116,7 +117,7 @@ import {
|
|
|
116
117
|
writeSnapshotFromFiles,
|
|
117
118
|
writeSourceFiles,
|
|
118
119
|
writeWorkspaceTextFile
|
|
119
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-YRSE5DLH.js";
|
|
120
121
|
import {
|
|
121
122
|
clearCredentials,
|
|
122
123
|
getActiveCredentialBackendName,
|
|
@@ -127,7 +128,7 @@ import {
|
|
|
127
128
|
saveGlobalConfig,
|
|
128
129
|
setAccessOnlySession,
|
|
129
130
|
setCredentials
|
|
130
|
-
} from "./chunk-
|
|
131
|
+
} from "./chunk-VWMKJL4A.js";
|
|
131
132
|
import {
|
|
132
133
|
DEFAULT_LOGIN_TIMEOUT_MS,
|
|
133
134
|
MANIFEST_FILE,
|
|
@@ -1874,6 +1875,164 @@ function openBrowser(url) {
|
|
|
1874
1875
|
child.unref();
|
|
1875
1876
|
}
|
|
1876
1877
|
|
|
1878
|
+
// ../../packages/cli-core/src/results/command-result.ts
|
|
1879
|
+
var COMMAND_RESULT_SCHEMA_VERSION = 1;
|
|
1880
|
+
var ExitCode = /* @__PURE__ */ ((ExitCode2) => {
|
|
1881
|
+
ExitCode2[ExitCode2["Ok"] = 0] = "Ok";
|
|
1882
|
+
ExitCode2[ExitCode2["Unexpected"] = 1] = "Unexpected";
|
|
1883
|
+
ExitCode2[ExitCode2["Unauthenticated"] = 2] = "Unauthenticated";
|
|
1884
|
+
ExitCode2[ExitCode2["Forbidden"] = 3] = "Forbidden";
|
|
1885
|
+
ExitCode2[ExitCode2["Conflict"] = 4] = "Conflict";
|
|
1886
|
+
ExitCode2[ExitCode2["Validation"] = 5] = "Validation";
|
|
1887
|
+
ExitCode2[ExitCode2["Transient"] = 6] = "Transient";
|
|
1888
|
+
ExitCode2[ExitCode2["CommitNotPushed"] = 7] = "CommitNotPushed";
|
|
1889
|
+
ExitCode2[ExitCode2["ConfirmationRequired"] = 8] = "ConfirmationRequired";
|
|
1890
|
+
return ExitCode2;
|
|
1891
|
+
})(ExitCode || {});
|
|
1892
|
+
function commandSuccess(command, result, nextActions = []) {
|
|
1893
|
+
return {
|
|
1894
|
+
schemaVersion: COMMAND_RESULT_SCHEMA_VERSION,
|
|
1895
|
+
ok: true,
|
|
1896
|
+
command,
|
|
1897
|
+
result,
|
|
1898
|
+
nextActions
|
|
1899
|
+
};
|
|
1900
|
+
}
|
|
1901
|
+
function commandFailure(command, problem, exitCode, nextActions = []) {
|
|
1902
|
+
return {
|
|
1903
|
+
schemaVersion: COMMAND_RESULT_SCHEMA_VERSION,
|
|
1904
|
+
ok: false,
|
|
1905
|
+
command,
|
|
1906
|
+
problem,
|
|
1907
|
+
nextActions,
|
|
1908
|
+
exitCode
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
// ../../packages/cli-core/src/progress/progress-events.ts
|
|
1913
|
+
var PROGRESS_EVENT_SCHEMA_VERSION = 1;
|
|
1914
|
+
function createProgressSequencer(input) {
|
|
1915
|
+
let seq = 0;
|
|
1916
|
+
const sequencer = {
|
|
1917
|
+
next(event) {
|
|
1918
|
+
seq += 1;
|
|
1919
|
+
return {
|
|
1920
|
+
schemaVersion: PROGRESS_EVENT_SCHEMA_VERSION,
|
|
1921
|
+
runId: input.runId,
|
|
1922
|
+
seq,
|
|
1923
|
+
...event
|
|
1924
|
+
};
|
|
1925
|
+
},
|
|
1926
|
+
terminal(result) {
|
|
1927
|
+
seq += 1;
|
|
1928
|
+
return {
|
|
1929
|
+
schemaVersion: PROGRESS_EVENT_SCHEMA_VERSION,
|
|
1930
|
+
runId: input.runId,
|
|
1931
|
+
seq,
|
|
1932
|
+
command: input.command,
|
|
1933
|
+
kind: "result",
|
|
1934
|
+
event: "terminal",
|
|
1935
|
+
payload: result
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
};
|
|
1939
|
+
return sequencer;
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
// ../../packages/cli-core/src/auth/git-credential.ts
|
|
1943
|
+
var DEFAULT_REPOSITORY_PATH = /^repos\/[0-9a-fA-F-]{36}\.git$/;
|
|
1944
|
+
function parseGitCredentialRequest(input) {
|
|
1945
|
+
const result = {};
|
|
1946
|
+
for (const line of input.split(/\r?\n/)) {
|
|
1947
|
+
if (line === "") continue;
|
|
1948
|
+
const separator = line.indexOf("=");
|
|
1949
|
+
if (separator <= 0) continue;
|
|
1950
|
+
result[line.slice(0, separator)] = line.slice(separator + 1);
|
|
1951
|
+
}
|
|
1952
|
+
return {
|
|
1953
|
+
protocol: result.protocol,
|
|
1954
|
+
host: result.host,
|
|
1955
|
+
path: result.path
|
|
1956
|
+
};
|
|
1957
|
+
}
|
|
1958
|
+
function formatGitCredentialResponse(response) {
|
|
1959
|
+
return `username=${response.username}
|
|
1960
|
+
password=${response.password}
|
|
1961
|
+
|
|
1962
|
+
`;
|
|
1963
|
+
}
|
|
1964
|
+
async function resolveGitCredential(input) {
|
|
1965
|
+
const protocol = input.request.protocol?.toLowerCase();
|
|
1966
|
+
const host = input.request.host?.toLowerCase();
|
|
1967
|
+
const path12 = normalizeCredentialPath(input.request.path);
|
|
1968
|
+
const allowedHosts = new Set(
|
|
1969
|
+
input.policy.allowedHosts.map((value) => value.toLowerCase())
|
|
1970
|
+
);
|
|
1971
|
+
const pathPattern = input.policy.allowedPathPattern ?? DEFAULT_REPOSITORY_PATH;
|
|
1972
|
+
if (protocol !== "https" || !host || !allowedHosts.has(host)) {
|
|
1973
|
+
return null;
|
|
1974
|
+
}
|
|
1975
|
+
if (!path12 || !pathPattern.test(path12)) {
|
|
1976
|
+
return null;
|
|
1977
|
+
}
|
|
1978
|
+
const token = await input.tokenManager.resolveGitToken();
|
|
1979
|
+
return {
|
|
1980
|
+
username: "x-dreamboard-token",
|
|
1981
|
+
password: token.token
|
|
1982
|
+
};
|
|
1983
|
+
}
|
|
1984
|
+
function normalizeCredentialPath(value) {
|
|
1985
|
+
if (!value) return null;
|
|
1986
|
+
return value.replace(/^\/+/, "");
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
// ../../packages/cli-core/src/git/system-git.ts
|
|
1990
|
+
import { execFile } from "child_process";
|
|
1991
|
+
import { promisify } from "util";
|
|
1992
|
+
var execFileAsync = promisify(execFile);
|
|
1993
|
+
|
|
1994
|
+
// src/services/git/git-credential-helper.ts
|
|
1995
|
+
var DEFAULT_ALLOWED_GIT_HOSTS = [
|
|
1996
|
+
"git.staging.dreamboard.games",
|
|
1997
|
+
"git.dreamboard.games"
|
|
1998
|
+
];
|
|
1999
|
+
async function runGitCredentialHelper(input = {}) {
|
|
2000
|
+
const stdin = input.stdin ?? process.stdin;
|
|
2001
|
+
const stdout = input.stdout ?? process.stdout;
|
|
2002
|
+
const env2 = input.env ?? process.env;
|
|
2003
|
+
const request = parseGitCredentialRequest(await readAll(stdin));
|
|
2004
|
+
const response = await resolveGitCredential({
|
|
2005
|
+
request,
|
|
2006
|
+
policy: {
|
|
2007
|
+
allowedHosts: resolveAllowedGitHosts(env2)
|
|
2008
|
+
},
|
|
2009
|
+
tokenManager: createUserTokenManager(
|
|
2010
|
+
resolveConfig(
|
|
2011
|
+
await loadGlobalConfig(),
|
|
2012
|
+
{},
|
|
2013
|
+
void 0,
|
|
2014
|
+
await getStoredSession()
|
|
2015
|
+
)
|
|
2016
|
+
)
|
|
2017
|
+
});
|
|
2018
|
+
if (!response) {
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
stdout.write(formatGitCredentialResponse(response));
|
|
2022
|
+
}
|
|
2023
|
+
function resolveAllowedGitHosts(env2) {
|
|
2024
|
+
const configured = env2.DREAMBOARD_GIT_ALLOWED_HOSTS?.split(",").map((host) => host.trim()).filter(Boolean);
|
|
2025
|
+
return configured && configured.length > 0 ? configured : DEFAULT_ALLOWED_GIT_HOSTS;
|
|
2026
|
+
}
|
|
2027
|
+
async function readAll(stream) {
|
|
2028
|
+
let data = "";
|
|
2029
|
+
stream.setEncoding("utf8");
|
|
2030
|
+
for await (const chunk of stream) {
|
|
2031
|
+
data += chunk;
|
|
2032
|
+
}
|
|
2033
|
+
return data;
|
|
2034
|
+
}
|
|
2035
|
+
|
|
1877
2036
|
// src/commands/auth.ts
|
|
1878
2037
|
async function loginWithBrowser(config, quiet) {
|
|
1879
2038
|
const state = crypto2.randomUUID();
|
|
@@ -1928,7 +2087,7 @@ var auth_default = defineCommand({
|
|
|
1928
2087
|
args: {
|
|
1929
2088
|
action: {
|
|
1930
2089
|
type: "positional",
|
|
1931
|
-
description: IS_PUBLISHED_BUILD ? "Action: clear | login" : "Action: set | clear | login | env | status",
|
|
2090
|
+
description: IS_PUBLISHED_BUILD ? "Action: clear | login" : "Action: set | clear | login | env | status | git-credential",
|
|
1932
2091
|
required: true
|
|
1933
2092
|
},
|
|
1934
2093
|
...IS_PUBLISHED_BUILD ? {} : {
|
|
@@ -1955,6 +2114,10 @@ var auth_default = defineCommand({
|
|
|
1955
2114
|
const parsedArgs = parseAuthCommandArgs(args);
|
|
1956
2115
|
const action = parsedArgs.action;
|
|
1957
2116
|
const globalConfig = await loadGlobalConfig();
|
|
2117
|
+
if (action === "git-credential") {
|
|
2118
|
+
await runGitCredentialHelper();
|
|
2119
|
+
return;
|
|
2120
|
+
}
|
|
1958
2121
|
if (IS_PUBLISHED_BUILD && action !== "login" && action !== "clear") {
|
|
1959
2122
|
throw new Error(
|
|
1960
2123
|
"The published Dreamboard CLI only supports browser login and logout. Use `dreamboard login` or `dreamboard logout`."
|
|
@@ -1995,7 +2158,7 @@ var auth_default = defineCommand({
|
|
|
1995
2158
|
return;
|
|
1996
2159
|
}
|
|
1997
2160
|
if (action === "clear") {
|
|
1998
|
-
await clearCredentials();
|
|
2161
|
+
await clearCredentials("auth_clear_command");
|
|
1999
2162
|
consola.success(
|
|
2000
2163
|
`Stored Dreamboard session cleared from ${getGlobalAuthPath()}.`
|
|
2001
2164
|
);
|
|
@@ -5997,7 +6160,7 @@ var logout_default = defineCommand({
|
|
|
5997
6160
|
meta: { name: "logout", description: "Clear the stored Dreamboard session" },
|
|
5998
6161
|
args: {},
|
|
5999
6162
|
async run() {
|
|
6000
|
-
await clearCredentials();
|
|
6163
|
+
await clearCredentials("logout_command");
|
|
6001
6164
|
consola.success(`Logged out. Cleared session from ${getGlobalAuthPath()}.`);
|
|
6002
6165
|
}
|
|
6003
6166
|
});
|
|
@@ -6976,8 +7139,225 @@ var test_default = defineCommand({
|
|
|
6976
7139
|
}
|
|
6977
7140
|
});
|
|
6978
7141
|
|
|
7142
|
+
// src/machine-output.ts
|
|
7143
|
+
import crypto4 from "crypto";
|
|
7144
|
+
function consumeMachineOutputMode(argv2) {
|
|
7145
|
+
let mode = null;
|
|
7146
|
+
for (let index = argv2.length - 1; index >= 2; index -= 1) {
|
|
7147
|
+
const arg = argv2[index];
|
|
7148
|
+
if (arg !== "--json" && arg !== "--json-events") continue;
|
|
7149
|
+
const nextMode = arg === "--json" ? "json" : "json-events";
|
|
7150
|
+
if (mode && mode !== nextMode) {
|
|
7151
|
+
throw new Error("Use only one machine output mode: --json or --json-events.");
|
|
7152
|
+
}
|
|
7153
|
+
mode = nextMode;
|
|
7154
|
+
argv2.splice(index, 1);
|
|
7155
|
+
}
|
|
7156
|
+
return mode ? {
|
|
7157
|
+
mode,
|
|
7158
|
+
runId: crypto4.randomUUID()
|
|
7159
|
+
} : null;
|
|
7160
|
+
}
|
|
7161
|
+
function commandPathToId(path12) {
|
|
7162
|
+
const [first, second] = path12;
|
|
7163
|
+
if (first === "auth") {
|
|
7164
|
+
if (second === "git-credential") return "auth.git_credential";
|
|
7165
|
+
if (second === "status") return "auth.status";
|
|
7166
|
+
if (second === "clear") return "auth.logout";
|
|
7167
|
+
return "auth.login";
|
|
7168
|
+
}
|
|
7169
|
+
switch (first) {
|
|
7170
|
+
case "login":
|
|
7171
|
+
return "auth.login";
|
|
7172
|
+
case "logout":
|
|
7173
|
+
return "auth.logout";
|
|
7174
|
+
case "new":
|
|
7175
|
+
return "project.create";
|
|
7176
|
+
case "clone":
|
|
7177
|
+
return "project.clone";
|
|
7178
|
+
case "status":
|
|
7179
|
+
case "pull":
|
|
7180
|
+
return "project.status";
|
|
7181
|
+
case "sync":
|
|
7182
|
+
return "verify";
|
|
7183
|
+
case "compile":
|
|
7184
|
+
return "build";
|
|
7185
|
+
case "test":
|
|
7186
|
+
return "test";
|
|
7187
|
+
case "dev":
|
|
7188
|
+
case "join":
|
|
7189
|
+
return "dev";
|
|
7190
|
+
case "config":
|
|
7191
|
+
case "query":
|
|
7192
|
+
return "doctor";
|
|
7193
|
+
default:
|
|
7194
|
+
return "doctor";
|
|
7195
|
+
}
|
|
7196
|
+
}
|
|
7197
|
+
async function runWithMachineOutput(context, command, run) {
|
|
7198
|
+
const sequencer = createProgressSequencer({
|
|
7199
|
+
runId: context.runId,
|
|
7200
|
+
command
|
|
7201
|
+
});
|
|
7202
|
+
if (context.mode === "json-events") {
|
|
7203
|
+
writeJsonLine(
|
|
7204
|
+
sequencer.next({
|
|
7205
|
+
command,
|
|
7206
|
+
kind: "progress",
|
|
7207
|
+
event: "started"
|
|
7208
|
+
})
|
|
7209
|
+
);
|
|
7210
|
+
}
|
|
7211
|
+
const previousExitCode = process.exitCode;
|
|
7212
|
+
process.exitCode = 0;
|
|
7213
|
+
try {
|
|
7214
|
+
const captured = await captureProcessWrites(async () => {
|
|
7215
|
+
await run();
|
|
7216
|
+
});
|
|
7217
|
+
const exitCode = typeof process.exitCode === "number" ? process.exitCode : 0 /* Ok */;
|
|
7218
|
+
const result = exitCode === 0 ? commandSuccess(command, captured) : commandFailure(
|
|
7219
|
+
command,
|
|
7220
|
+
{
|
|
7221
|
+
title: "Command failed",
|
|
7222
|
+
detail: `Command completed with exit code ${exitCode}.`,
|
|
7223
|
+
code: "COMMAND_EXIT_CODE"
|
|
7224
|
+
},
|
|
7225
|
+
normalizeExitCode(exitCode)
|
|
7226
|
+
);
|
|
7227
|
+
emitMachineResult(context, sequencer.terminal(result), result);
|
|
7228
|
+
process.exitCode = exitCode;
|
|
7229
|
+
} catch (error) {
|
|
7230
|
+
const failure = commandFailure(
|
|
7231
|
+
command,
|
|
7232
|
+
problemFromError(error),
|
|
7233
|
+
exitCodeFromError(error),
|
|
7234
|
+
nextActionsFromError(error)
|
|
7235
|
+
);
|
|
7236
|
+
emitMachineResult(context, sequencer.terminal(failure), failure);
|
|
7237
|
+
process.exit(exitCodeFromError(error));
|
|
7238
|
+
} finally {
|
|
7239
|
+
if (process.exitCode === 0 && previousExitCode) {
|
|
7240
|
+
process.exitCode = previousExitCode;
|
|
7241
|
+
}
|
|
7242
|
+
}
|
|
7243
|
+
}
|
|
7244
|
+
function emitMachineFailureAndExit(context, command, error) {
|
|
7245
|
+
const sequencer = createProgressSequencer({
|
|
7246
|
+
runId: context.runId,
|
|
7247
|
+
command
|
|
7248
|
+
});
|
|
7249
|
+
const failure = commandFailure(
|
|
7250
|
+
command,
|
|
7251
|
+
problemFromError(error),
|
|
7252
|
+
exitCodeFromError(error),
|
|
7253
|
+
nextActionsFromError(error)
|
|
7254
|
+
);
|
|
7255
|
+
emitMachineResult(context, sequencer.terminal(failure), failure);
|
|
7256
|
+
process.exit(failure.exitCode);
|
|
7257
|
+
}
|
|
7258
|
+
async function captureProcessWrites(run) {
|
|
7259
|
+
const stdoutWrite = process.stdout.write.bind(process.stdout);
|
|
7260
|
+
const stderrWrite = process.stderr.write.bind(process.stderr);
|
|
7261
|
+
let stdout = "";
|
|
7262
|
+
let stderr = "";
|
|
7263
|
+
process.stdout.write = ((chunk, ...args) => {
|
|
7264
|
+
stdout += stringifyChunk(chunk);
|
|
7265
|
+
const callback = args.find((arg) => typeof arg === "function");
|
|
7266
|
+
callback?.();
|
|
7267
|
+
return true;
|
|
7268
|
+
});
|
|
7269
|
+
process.stderr.write = ((chunk, ...args) => {
|
|
7270
|
+
stderr += stringifyChunk(chunk);
|
|
7271
|
+
const callback = args.find((arg) => typeof arg === "function");
|
|
7272
|
+
callback?.();
|
|
7273
|
+
return true;
|
|
7274
|
+
});
|
|
7275
|
+
try {
|
|
7276
|
+
await run();
|
|
7277
|
+
return {
|
|
7278
|
+
exitCode: typeof process.exitCode === "number" ? process.exitCode : 0 /* Ok */,
|
|
7279
|
+
stdout,
|
|
7280
|
+
stderr
|
|
7281
|
+
};
|
|
7282
|
+
} finally {
|
|
7283
|
+
process.stdout.write = stdoutWrite;
|
|
7284
|
+
process.stderr.write = stderrWrite;
|
|
7285
|
+
}
|
|
7286
|
+
}
|
|
7287
|
+
function emitMachineResult(context, terminalEvent, result) {
|
|
7288
|
+
if (context.mode === "json-events") {
|
|
7289
|
+
writeJsonLine(terminalEvent);
|
|
7290
|
+
return;
|
|
7291
|
+
}
|
|
7292
|
+
writeJsonLine(result);
|
|
7293
|
+
}
|
|
7294
|
+
function writeJsonLine(value) {
|
|
7295
|
+
process.stdout.write(`${JSON.stringify(value)}
|
|
7296
|
+
`);
|
|
7297
|
+
}
|
|
7298
|
+
function stringifyChunk(chunk) {
|
|
7299
|
+
if (typeof chunk === "string") return chunk;
|
|
7300
|
+
if (chunk instanceof Uint8Array) return Buffer.from(chunk).toString("utf8");
|
|
7301
|
+
return String(chunk);
|
|
7302
|
+
}
|
|
7303
|
+
function problemFromError(error) {
|
|
7304
|
+
if (isDreamboardApiError(error)) {
|
|
7305
|
+
return {
|
|
7306
|
+
type: error.problem.type,
|
|
7307
|
+
title: error.problem.title,
|
|
7308
|
+
status: error.problem.status,
|
|
7309
|
+
detail: error.problem.detail,
|
|
7310
|
+
code: error.problem.type
|
|
7311
|
+
};
|
|
7312
|
+
}
|
|
7313
|
+
const presentation = presentCliError(error);
|
|
7314
|
+
return {
|
|
7315
|
+
title: presentation.message || "Command failed",
|
|
7316
|
+
detail: presentation.resolution,
|
|
7317
|
+
code: error instanceof Error ? error.name : void 0
|
|
7318
|
+
};
|
|
7319
|
+
}
|
|
7320
|
+
function exitCodeFromError(error) {
|
|
7321
|
+
if (isStaleContractArtifactError(error)) return 5 /* Validation */;
|
|
7322
|
+
if (isDreamboardApiError(error)) {
|
|
7323
|
+
if (error.status === 401) return 2 /* Unauthenticated */;
|
|
7324
|
+
if (error.status === 403) return 3 /* Forbidden */;
|
|
7325
|
+
if (error.status === 409) return 4 /* Conflict */;
|
|
7326
|
+
if (error.status === 422 || error.status === 400) {
|
|
7327
|
+
return 5 /* Validation */;
|
|
7328
|
+
}
|
|
7329
|
+
if (error.retryable || error.status === 429 || error.status >= 500) {
|
|
7330
|
+
return 6 /* Transient */;
|
|
7331
|
+
}
|
|
7332
|
+
}
|
|
7333
|
+
return 1 /* Unexpected */;
|
|
7334
|
+
}
|
|
7335
|
+
function normalizeExitCode(exitCode) {
|
|
7336
|
+
return Object.values(ExitCode).includes(exitCode) ? exitCode : 1 /* Unexpected */;
|
|
7337
|
+
}
|
|
7338
|
+
function nextActionsFromError(error) {
|
|
7339
|
+
if (isDreamboardApiError(error) && error.status === 401) {
|
|
7340
|
+
return [
|
|
7341
|
+
{
|
|
7342
|
+
id: "auth.login",
|
|
7343
|
+
environment: "staging",
|
|
7344
|
+
unattended: false
|
|
7345
|
+
}
|
|
7346
|
+
];
|
|
7347
|
+
}
|
|
7348
|
+
return [];
|
|
7349
|
+
}
|
|
7350
|
+
|
|
6979
7351
|
// src/cli-main.ts
|
|
7352
|
+
var machineOutputContext = null;
|
|
6980
7353
|
function handleFatalError(error) {
|
|
7354
|
+
if (machineOutputContext) {
|
|
7355
|
+
emitMachineFailureAndExit(
|
|
7356
|
+
machineOutputContext,
|
|
7357
|
+
commandPathToId(process.argv.slice(2)),
|
|
7358
|
+
error
|
|
7359
|
+
);
|
|
7360
|
+
}
|
|
6981
7361
|
const message = formatCliError(error);
|
|
6982
7362
|
process.stderr.write(`Error: ${message}
|
|
6983
7363
|
`);
|
|
@@ -7001,21 +7381,31 @@ var publicSubCommands = {
|
|
|
7001
7381
|
logout: logout_default,
|
|
7002
7382
|
config: config_default
|
|
7003
7383
|
};
|
|
7004
|
-
function wrapCommandMapForCli(commands, fatalErrorHandler) {
|
|
7384
|
+
function wrapCommandMapForCli(commands, fatalErrorHandler, parentPath = []) {
|
|
7005
7385
|
return Object.fromEntries(
|
|
7006
7386
|
Object.entries(commands).map(([name, command]) => [
|
|
7007
7387
|
name,
|
|
7008
|
-
wrapCommandForCli(command, fatalErrorHandler)
|
|
7388
|
+
wrapCommandForCli(command, fatalErrorHandler, [...parentPath, name])
|
|
7009
7389
|
])
|
|
7010
7390
|
);
|
|
7011
7391
|
}
|
|
7012
|
-
function wrapCommandForCli(command, fatalErrorHandler = handleFatalError) {
|
|
7392
|
+
function wrapCommandForCli(command, fatalErrorHandler = handleFatalError, commandPath = []) {
|
|
7013
7393
|
const subCommands = command.subCommands;
|
|
7014
7394
|
return {
|
|
7015
7395
|
...command,
|
|
7016
|
-
subCommands: subCommands ? wrapCommandMapForCli(subCommands, fatalErrorHandler) : void 0,
|
|
7396
|
+
subCommands: subCommands ? wrapCommandMapForCli(subCommands, fatalErrorHandler, commandPath) : void 0,
|
|
7017
7397
|
run: command.run ? async (context) => {
|
|
7018
7398
|
try {
|
|
7399
|
+
if (machineOutputContext) {
|
|
7400
|
+
await runWithMachineOutput(
|
|
7401
|
+
machineOutputContext,
|
|
7402
|
+
commandPathToId(process.argv.slice(2)),
|
|
7403
|
+
async () => {
|
|
7404
|
+
await command.run?.(context);
|
|
7405
|
+
}
|
|
7406
|
+
);
|
|
7407
|
+
return;
|
|
7408
|
+
}
|
|
7019
7409
|
return await command.run?.(context);
|
|
7020
7410
|
} catch (error) {
|
|
7021
7411
|
fatalErrorHandler(error);
|
|
@@ -7024,6 +7414,7 @@ function wrapCommandForCli(command, fatalErrorHandler = handleFatalError) {
|
|
|
7024
7414
|
};
|
|
7025
7415
|
}
|
|
7026
7416
|
function runDreamboardCli(internalSubCommands = {}) {
|
|
7417
|
+
machineOutputContext = consumeMachineOutputMode(process.argv);
|
|
7027
7418
|
const subCommands = wrapCommandMapForCli(
|
|
7028
7419
|
{
|
|
7029
7420
|
...publicSubCommands,
|