make cli more reliable

This commit is contained in:
Ruben Fiszel
2024-10-11 16:33:18 +02:00
parent 86e1ab94ea
commit a7d3a0eaa3
3 changed files with 22 additions and 16 deletions
+18 -15
View File
@@ -29,21 +29,23 @@ export function replaceInlineScripts(
) {
modules.forEach((m) => {
if (m.value.type == "rawscript") {
const path = m.value.content.split(" ")[1];
m.value.content = Deno.readTextFileSync(localPath + path);
const lock = m.value.lock;
if (removeLocks && removeLocks.includes(path)) {
m.value.lock = undefined;
} else if (
lock &&
typeof lock == "string" &&
lock.trimStart().startsWith("!inline ")
) {
const path = lock.split(" ")[1];
try {
m.value.lock = readInlinePathSync(localPath + path);
} catch {
log.error(`Lock file ${path} not found`);
if (m.value.content.startsWith("!inline")) {
const path = m.value.content.split(" ")[1];
m.value.content = Deno.readTextFileSync(localPath + path);
const lock = m.value.lock;
if (removeLocks && removeLocks.includes(path)) {
m.value.lock = undefined;
} else if (
lock &&
typeof lock == "string" &&
lock.trimStart().startsWith("!inline ")
) {
const path = lock.split(" ")[1];
try {
m.value.lock = readInlinePathSync(localPath + path);
} catch {
log.error(`Lock file ${path} not found`);
}
}
}
} else if (m.value.type == "forloopflow") {
@@ -120,6 +122,7 @@ export async function pushFlow(
});
} catch (e) {
throw new Error(
//@ts-ignore
`Failed to create flow ${remotePath}: ${e.body ?? e.message}`
);
}
+2
View File
@@ -73,6 +73,7 @@ export async function pushFolder(
},
});
} catch (e) {
//@ts-ignore
console.error(e.body);
throw e;
}
@@ -87,6 +88,7 @@ export async function pushFolder(
},
});
} catch (e) {
//@ts-ignore
throw Error(`Failed to create folder ${name}: ${e.body ?? e.message}`);
}
}
+2 -1
View File
@@ -578,6 +578,7 @@ async function whoami(opts: {}) {
log.info(JSON.stringify(whoamiInfo, null, 2));
} catch (error) {
log.error(
//@ts-ignore
colors.red(`Failed to retrieve whoami information: ${error.message}`)
);
}
@@ -620,7 +621,7 @@ const command = new Command()
.description("Remove an instance")
.complete("instance", async () => (await allInstances()).map((x) => x.name))
.arguments("<instance:string:instance>")
.action(async (instance) => {
.action(async (instance: any) => {
const instances = await allInstances();
const choice = (await Select.prompt({