This commit is contained in:
2024-11-12 22:07:38 -05:00
parent d2d18315c4
commit 59a08dc5ba
12 changed files with 364 additions and 158 deletions
+13 -23
View File
@@ -1,38 +1,28 @@
#!/usr/bin/env bun
import {
dynamicStringHandler,
} from "portainer_wrapper/src/server/portainerExpressMiddleware"
import { getJJConfigByKeyChain, getJjYamlObj, jjConfigsExp } from "./jjConfigUtils";
import _ from 'lodash';
import { jjLogError } from "./jjLogger";
import cliHelp from "cli/help";
const JJ_CLI_ARG_1 = process.env.JJ_CLI_ARG_1
import { jjCliYargs } from "./jjCliYargs";
jjCliYargs(false)
const requiredProcessEnvs = {
JJ_SOURCE_DIR: process.env.JJ_SOURCE_DIR
}
if (JJ_CLI_ARG_1 == 'help') {
await cliHelp()
process.exit(0)
}
import { getJJConfigByKeyChain, getJjYamlObj, jjConfigsExp } from "./jjConfigUtils";
import _ from 'lodash';
import { dynamicStringHandler } from "./dynamicStringHandler";
const jjCommandConfig = getJJConfigByKeyChain(`commands['${JJ_CLI_ARG_1}']`)
const jjCommandConfig = getJJConfigByKeyChain(`commands['${process.env.JJ_CLI_ARG_1}']`)
if (!jjCommandConfig || _.isEmpty(jjCommandConfig)) {
jjLogError(`Command ${JJ_CLI_ARG_1} is not available`)
console.error(`Command ${process.env.JJ_CLI_ARG_1} is not available`)
process.exit(0)
} else {
const scriptToRunPath = dynamicStringHandler(`${jjCommandConfig.scriptToRun.prePath}/${jjCommandConfig.scriptToRun.path}`, "", requiredProcessEnvs, false)
const scriptToRunFn = (await import(scriptToRunPath)).default
await scriptToRunFn()
process.exit(0)
}
const scriptToRunPath = dynamicStringHandler(`${jjCommandConfig.scriptToRun.prePath}/${jjCommandConfig.scriptToRun.path}`, "", requiredProcessEnvs, false)
const scriptToRunFn = (await import(scriptToRunPath)).default
await scriptToRunFn()
process.exit(0)