freestyle-sandboxes 0.1.33 → 0.1.35
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/cli.mjs +51 -3
- package/index.cjs +1196 -1338
- package/index.d.cts +1219 -2767
- package/index.d.mts +1219 -2767
- package/index.mjs +1196 -1338
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -499,6 +499,31 @@ function getDefaultTeamId() {
|
|
|
499
499
|
return stored?.defaultTeamId;
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
+
function normalizeCliProxyError(errorText) {
|
|
503
|
+
try {
|
|
504
|
+
const parsed = JSON.parse(errorText);
|
|
505
|
+
if (typeof parsed.code === "string" && typeof parsed.message === "string") {
|
|
506
|
+
return {
|
|
507
|
+
body: JSON.stringify(parsed),
|
|
508
|
+
contentType: "application/json"
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
const message = [parsed.error, parsed.message, parsed.reason].find(
|
|
512
|
+
(value) => typeof value === "string" && value.length > 0
|
|
513
|
+
);
|
|
514
|
+
if (message) {
|
|
515
|
+
return {
|
|
516
|
+
body: message,
|
|
517
|
+
contentType: "text/plain; charset=utf-8"
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
} catch {
|
|
521
|
+
}
|
|
522
|
+
return {
|
|
523
|
+
body: errorText || "Request failed",
|
|
524
|
+
contentType: "text/plain; charset=utf-8"
|
|
525
|
+
};
|
|
526
|
+
}
|
|
502
527
|
function createProxyFetch(accessToken, teamId) {
|
|
503
528
|
const dashboardApiUrl = process.env.FREESTYLE_DASHBOARD_URL || "https://dash.freestyle.sh";
|
|
504
529
|
return async (url, init) => {
|
|
@@ -522,9 +547,13 @@ function createProxyFetch(accessToken, teamId) {
|
|
|
522
547
|
});
|
|
523
548
|
if (!proxyResponse.ok) {
|
|
524
549
|
const errorText = await proxyResponse.text();
|
|
525
|
-
|
|
550
|
+
const normalizedError = normalizeCliProxyError(errorText);
|
|
551
|
+
return new Response(normalizedError.body, {
|
|
526
552
|
status: proxyResponse.status,
|
|
527
|
-
statusText: proxyResponse.statusText
|
|
553
|
+
statusText: proxyResponse.statusText,
|
|
554
|
+
headers: {
|
|
555
|
+
"Content-Type": normalizedError.contentType
|
|
556
|
+
}
|
|
528
557
|
});
|
|
529
558
|
}
|
|
530
559
|
const data = await proxyResponse.json();
|
|
@@ -1911,6 +1940,25 @@ const logoutCommand = {
|
|
|
1911
1940
|
}
|
|
1912
1941
|
};
|
|
1913
1942
|
|
|
1943
|
+
const whoamiCommand = {
|
|
1944
|
+
command: "whoami",
|
|
1945
|
+
describe: "Display information about the currently authenticated user",
|
|
1946
|
+
builder: (yargs) => yargs,
|
|
1947
|
+
handler: async (_argv) => {
|
|
1948
|
+
loadEnv();
|
|
1949
|
+
try {
|
|
1950
|
+
const client = await getFreestyleClient();
|
|
1951
|
+
const info = await client.whoami();
|
|
1952
|
+
console.log(`Account ID: ${info.accountId}`);
|
|
1953
|
+
if (info.identityId) {
|
|
1954
|
+
console.log(`Identity ID: ${info.identityId}`);
|
|
1955
|
+
}
|
|
1956
|
+
} catch (e) {
|
|
1957
|
+
handleError(e);
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
};
|
|
1961
|
+
|
|
1914
1962
|
dotenv.config({ quiet: true });
|
|
1915
1963
|
yargs(hideBin(process.argv)).scriptName("freestyle").usage("$0 <command> [options]").option("team", {
|
|
1916
1964
|
type: "string",
|
|
@@ -1920,4 +1968,4 @@ yargs(hideBin(process.argv)).scriptName("freestyle").usage("$0 <command> [option
|
|
|
1920
1968
|
if (argv.team && typeof argv.team === "string") {
|
|
1921
1969
|
process.env.FREESTYLE_TEAM_ID = argv.team;
|
|
1922
1970
|
}
|
|
1923
|
-
}).command(vmCommand).command(gitCommand).command(domainsCommand).command(cronCommand).command(loginCommand).command(logoutCommand).command(deployCommand).command(runCommand).demandCommand(1, "You need to specify a command").help().alias("help", "h").version().alias("version", "v").strict().parse();
|
|
1971
|
+
}).command(vmCommand).command(gitCommand).command(domainsCommand).command(cronCommand).command(loginCommand).command(logoutCommand).command(whoamiCommand).command(deployCommand).command(runCommand).demandCommand(1, "You need to specify a command").help().alias("help", "h").version().alias("version", "v").strict().parse();
|