auix 0.0.3 → 0.0.4
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 +85 -21
- 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", {});
|
|
@@ -2733,7 +2797,7 @@ async function ensureToken(project) {
|
|
|
2733
2797
|
os: process.platform,
|
|
2734
2798
|
arch: process.arch,
|
|
2735
2799
|
nodeVersion: process.version,
|
|
2736
|
-
cliVersion: "0.0.
|
|
2800
|
+
cliVersion: "0.0.4",
|
|
2737
2801
|
shell: process.env.SHELL ?? process.env.COMSPEC,
|
|
2738
2802
|
ci: isCI || void 0,
|
|
2739
2803
|
ciName: process.env.GITHUB_ACTIONS ? "github-actions" : process.env.GITLAB_CI ? "gitlab-ci" : process.env.CIRCLECI ? "circleci" : void 0,
|
|
@@ -3643,7 +3707,7 @@ const whoamiCommand = defineCommand({
|
|
|
3643
3707
|
runMain(defineCommand({
|
|
3644
3708
|
meta: {
|
|
3645
3709
|
name: "auix",
|
|
3646
|
-
version: "0.0.
|
|
3710
|
+
version: "0.0.4",
|
|
3647
3711
|
description: "AUIX CLI"
|
|
3648
3712
|
},
|
|
3649
3713
|
subCommands: {
|