auix 0.0.3 → 0.0.5
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/index.js +92 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1946,26 +1946,35 @@ const initCommand = defineCommand({
|
|
|
1946
1946
|
const config = { project: projectSlug };
|
|
1947
1947
|
const workspaceDirs = detectWorkspaceDirs();
|
|
1948
1948
|
if (workspaceDirs && workspaceDirs.length > 0) {
|
|
1949
|
-
|
|
1950
|
-
for (const dir of workspaceDirs)
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1949
|
+
const apps = {};
|
|
1950
|
+
for (const dir of workspaceDirs) apps[dir] = basename(dir);
|
|
1951
|
+
console.log(`\nDetected monorepo with ${workspaceDirs.length} packages:\n`);
|
|
1952
|
+
for (const [dir, name] of Object.entries(apps)) console.log(` ${dir} → ${name}`);
|
|
1953
|
+
const action = await consola.prompt("\nUse these app mappings?", {
|
|
1954
|
+
type: "select",
|
|
1955
|
+
options: [
|
|
1956
|
+
{
|
|
1957
|
+
label: "Yes, use as-is",
|
|
1958
|
+
value: "accept"
|
|
1959
|
+
},
|
|
1960
|
+
{
|
|
1961
|
+
label: "Edit some mappings",
|
|
1962
|
+
value: "edit"
|
|
1963
|
+
},
|
|
1964
|
+
{
|
|
1965
|
+
label: "Skip app mapping",
|
|
1966
|
+
value: "skip"
|
|
1964
1967
|
}
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1968
|
+
]
|
|
1969
|
+
});
|
|
1970
|
+
if (typeof action === "symbol") {
|
|
1971
|
+
console.log("Cancelled.");
|
|
1972
|
+
return;
|
|
1973
|
+
}
|
|
1974
|
+
if (action === "accept") config.apps = apps;
|
|
1975
|
+
else if (action === "edit") {
|
|
1976
|
+
if (await editAppMappings(apps, workspaceDirs)) return;
|
|
1977
|
+
config.apps = apps;
|
|
1969
1978
|
}
|
|
1970
1979
|
}
|
|
1971
1980
|
writeFileSync(rcPath, `${JSON.stringify(config, null, 2)}\n`);
|
|
@@ -1974,6 +1983,61 @@ const initCommand = defineCommand({
|
|
|
1974
1983
|
if (config.apps) console.log(` apps: ${Object.entries(config.apps).map(([d, a]) => `${d} → ${a}`).join(", ")}`);
|
|
1975
1984
|
}
|
|
1976
1985
|
});
|
|
1986
|
+
const DONE_VALUE = "__done__";
|
|
1987
|
+
async function editAppMappings(apps, dirs) {
|
|
1988
|
+
while (true) {
|
|
1989
|
+
const search = await consola.prompt("Search apps (empty to show all)", {
|
|
1990
|
+
type: "text",
|
|
1991
|
+
default: "",
|
|
1992
|
+
placeholder: "e.g. web, api, database..."
|
|
1993
|
+
});
|
|
1994
|
+
if (typeof search === "symbol") {
|
|
1995
|
+
console.log("Cancelled.");
|
|
1996
|
+
return true;
|
|
1997
|
+
}
|
|
1998
|
+
const query = search.trim().toLowerCase();
|
|
1999
|
+
const matched = dirs.filter((dir) => {
|
|
2000
|
+
if (!query) return true;
|
|
2001
|
+
return dir.toLowerCase().includes(query) || apps[dir].toLowerCase().includes(query);
|
|
2002
|
+
});
|
|
2003
|
+
if (matched.length === 0) {
|
|
2004
|
+
console.log(" No matches found.\n");
|
|
2005
|
+
continue;
|
|
2006
|
+
}
|
|
2007
|
+
const options = [...matched.map((dir) => ({
|
|
2008
|
+
label: `${dir} → ${apps[dir]}`,
|
|
2009
|
+
value: dir
|
|
2010
|
+
})), {
|
|
2011
|
+
label: "Done editing",
|
|
2012
|
+
value: DONE_VALUE
|
|
2013
|
+
}];
|
|
2014
|
+
const selected = await consola.prompt("Select app to rename", {
|
|
2015
|
+
type: "select",
|
|
2016
|
+
options
|
|
2017
|
+
});
|
|
2018
|
+
if (typeof selected === "symbol") {
|
|
2019
|
+
console.log("Cancelled.");
|
|
2020
|
+
return true;
|
|
2021
|
+
}
|
|
2022
|
+
if (selected === DONE_VALUE) break;
|
|
2023
|
+
const dir = selected;
|
|
2024
|
+
const name = await consola.prompt(`App name for ${dir}`, {
|
|
2025
|
+
type: "text",
|
|
2026
|
+
default: apps[dir],
|
|
2027
|
+
placeholder: apps[dir]
|
|
2028
|
+
});
|
|
2029
|
+
if (typeof name === "symbol") {
|
|
2030
|
+
console.log("Cancelled.");
|
|
2031
|
+
return true;
|
|
2032
|
+
}
|
|
2033
|
+
const trimmed = name.trim();
|
|
2034
|
+
if (trimmed) {
|
|
2035
|
+
apps[dir] = trimmed;
|
|
2036
|
+
console.log(` ${dir} → ${trimmed}\n`);
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
return false;
|
|
2040
|
+
}
|
|
1977
2041
|
async function selectProject() {
|
|
1978
2042
|
try {
|
|
1979
2043
|
const res = await apiRequest("/v1/env/projects/list", {});
|
|
@@ -2394,7 +2458,8 @@ const pullCommand = defineCommand({
|
|
|
2394
2458
|
project,
|
|
2395
2459
|
environment: args.env,
|
|
2396
2460
|
app,
|
|
2397
|
-
branch: args.branch
|
|
2461
|
+
branch: args.branch,
|
|
2462
|
+
context: { intent: "pull" }
|
|
2398
2463
|
});
|
|
2399
2464
|
if (!res.ok) {
|
|
2400
2465
|
const text = await res.text().catch(() => "");
|
|
@@ -2733,7 +2798,7 @@ async function ensureToken(project) {
|
|
|
2733
2798
|
os: process.platform,
|
|
2734
2799
|
arch: process.arch,
|
|
2735
2800
|
nodeVersion: process.version,
|
|
2736
|
-
cliVersion: "0.0.
|
|
2801
|
+
cliVersion: "0.0.5",
|
|
2737
2802
|
shell: process.env.SHELL ?? process.env.COMSPEC,
|
|
2738
2803
|
ci: isCI || void 0,
|
|
2739
2804
|
ciName: process.env.GITHUB_ACTIONS ? "github-actions" : process.env.GITLAB_CI ? "gitlab-ci" : process.env.CIRCLECI ? "circleci" : void 0,
|
|
@@ -2812,7 +2877,11 @@ const runCommand = defineCommand({
|
|
|
2812
2877
|
project: projectSlug,
|
|
2813
2878
|
environment: args.env,
|
|
2814
2879
|
app,
|
|
2815
|
-
branch: args.branch
|
|
2880
|
+
branch: args.branch,
|
|
2881
|
+
context: {
|
|
2882
|
+
intent: "run",
|
|
2883
|
+
command: command.join(" ")
|
|
2884
|
+
}
|
|
2816
2885
|
};
|
|
2817
2886
|
const resolveVars = async () => {
|
|
2818
2887
|
const res = await apiRequestWithToken("/v1/env/resolve", resolvePayload, token);
|
|
@@ -3643,7 +3712,7 @@ const whoamiCommand = defineCommand({
|
|
|
3643
3712
|
runMain(defineCommand({
|
|
3644
3713
|
meta: {
|
|
3645
3714
|
name: "auix",
|
|
3646
|
-
version: "0.0.
|
|
3715
|
+
version: "0.0.5",
|
|
3647
3716
|
description: "AUIX CLI"
|
|
3648
3717
|
},
|
|
3649
3718
|
subCommands: {
|