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
+40
View File
@@ -0,0 +1,40 @@
#/usr/bin/env zsh
autoload -U compinit
compinit
function findJJSource {
# @source http://stackoverflow.com/a/246128/330439
local SOURCE="$jjCpmmandRunPoint"
local DIR=""
while [[ -h "$SOURCE" ]]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
while [[ ! -e "${DIR}/jj.filelocation" ]]; do
DIR=$(dirname "${DIR}")
done
echo "${DIR}"
}
export JJ_SOURCE_DIR=$(findJJSource)
if [[ -e "$JJ_SOURCE_DIR/~~tmp/shEnvs.sh" ]]; then
source $JJ_SOURCE_DIR/~~tmp/shEnvs.sh
fi
typeset -A opt_args
function _AuctoCompletion(){
# echo $words
COMMANDS_WITH_HELP=$($JJ_SOURCE_DIR/bashUtils/auto-completion.ts "1" $words )
COMMANDS=$($JJ_SOURCE_DIR/bashUtils/auto-completion.ts "0" $words )
_arguments "1: :($COMMANDS)"
_describe 'command' "$COMMANDS_WITH_HELP" && ret=0
}
compdef _AuctoCompletion jj
+110
View File
@@ -0,0 +1,110 @@
#!/usr/bin/env bun
import { bashRunAndReturnSync } from "@helpers/bashUtils"
import { getJJConfigByKeyChain } from "@helpers/jjConfigUtils"
async function main() {
const inputArgs = [...process.argv]
inputArgs.shift()
inputArgs.shift()
const displayHelp = inputArgs[0]
inputArgs.shift()
inputArgs.shift()
let remainingArgsCount = inputArgs.length
const commandConfig = getJJConfigByKeyChain(`commands`)
const jjCommandsList = Object.keys(commandConfig).map((cmdKey) => ({
key: cmdKey,
...commandConfig[cmdKey]
}))
let lastArrayOfKeys = [...jjCommandsList]
let commands = ""
let preHelp = ``
while (remainingArgsCount > 0) {
const matchingCommand = lastArrayOfKeys.find((item) => {
return item?.key == inputArgs[0]
})
if (matchingCommand?.commandForRetrieveKeys) {
if (remainingArgsCount == 2 && matchingCommand?.commandForRetrieveKeys2) {
matchingCommand.commandForRetrieveKeys = matchingCommand?.commandForRetrieveKeys2
}
const oldArgOrder = remainingArgsCount
remainingArgsCount = 0
const command =
matchingCommand?.commandForRetrieveKeys + ` ${matchingCommand?.commandForRetrieveKeys?.includes("auto-completion") ? ` auto-completion ${process.argv.join(" ")}` : ""}`
const res = await bashRunAndReturnSync(command)
const newCommands = res?.split("\n") || []
newCommands.push(String(""))
lastArrayOfKeys = []
newCommands.forEach((element) => {
if (element.includes(".") && !element.includes(".com")) {
return
}
lastArrayOfKeys.push({
key: element,
desc: "",
keys: [],
})
})
}
if (matchingCommand?.keysOnly && matchingCommand?.keysOnly?.length > 0) {
remainingArgsCount = 0
lastArrayOfKeys = []
matchingCommand?.keysOnly.forEach((element) => {
lastArrayOfKeys.push({
key: element,
desc: "",
keys: [],
})
})
}
if (matchingCommand?.postCommandsForce && matchingCommand?.postCommandsForce?.length > 0) {
remainingArgsCount = 0
matchingCommand?.postCommandsForce.forEach((element) => {
lastArrayOfKeys.push({
key: element,
desc: "",
keys: [],
})
})
}
if (matchingCommand?.key && matchingCommand?.keys && remainingArgsCount > 0) {
preHelp += `${matchingCommand?.desc || ""} `
lastArrayOfKeys = matchingCommand?.keys
inputArgs.shift()
remainingArgsCount -= 1
} else {
// lastArrayOfKeys = [];
remainingArgsCount = 0
}
}
if (remainingArgsCount == 0) {
for (const item of lastArrayOfKeys) {
if (displayHelp == "1") {
commands += `'${item?.key}:${preHelp}${item?.desc}' `
} else {
commands += `${item?.key} `
}
if (item?.commandForRetrieveKeys) {
commands += `-- `
}
}
}
console.log(`(${commands})`)
}
main().catch((err) => {
console.error("FATAL ERROR:", err)
process.exit(1)
})
+8 -16
View File
@@ -1,10 +1,6 @@
#!/usr/bin/env zsh #!/usr/bin/env bash
# source "$JJ_SOURCE_DIR/bashUtils/index.sh" for osDependency in $OS_DEPENDENCIES ; do
osDependencies=(${=OS_DEPENDENCIES})
for osDependency in $osDependencies ; do
if ! hash $osDependency; then if ! hash $osDependency; then
jjCliLog jjLogWarning "bashUtils/ensureDependency.sh Unable to find OS package '$osDependency'. Installing now..." jjCliLog jjLogWarning "bashUtils/ensureDependency.sh Unable to find OS package '$osDependency'. Installing now..."
eval "$PACKAGE_MANAGER_INSTALL $osDependency" eval "$PACKAGE_MANAGER_INSTALL $osDependency"
@@ -20,11 +16,7 @@ if [[ -e $ASDF_DIR/asdf.sh ]]; then
fi fi
asdfInstalledVersionPrefix=$(asdf info 2> /dev/null | grep -A 1 'ASDF VERSION' | tail -1 | grep "^${ASDF_VERSION}") if ! hash asdf || \
if [[ -z "${asdfInstalledVersionPrefix}" ]] || \
! hash asdf || \
[[ "${asdfInstalledVersionPrefix}" != "$ASDF_VERSION" ]] || \
[[ ! -e $JJ_SOURCE_DIR/~~tmp/deps/asdf-tools-installed ]] \ [[ ! -e $JJ_SOURCE_DIR/~~tmp/deps/asdf-tools-installed ]] \
|| jjIsFileNewerFile "$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" "$JJ_SOURCE_DIR/~~tmp/deps/asdf-tools-installed" ; then || jjIsFileNewerFile "$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" "$JJ_SOURCE_DIR/~~tmp/deps/asdf-tools-installed" ; then
rm -rf $ASDF_DIR rm -rf $ASDF_DIR
@@ -39,11 +31,11 @@ if [[ -z "${asdfInstalledVersionPrefix}" ]] || \
set +e set +e
while read tool_and_version; do while read tool_and_version; do
jjCliLog jjLog "... checking tool: $tool_and_version" jjCliLog jjLog "... checking tool: $tool_and_version"
tool_and_version_split=(${=tool_and_version}) tool_and_version_split=(${tool_and_version})
# echo ${tool_and_version_split[1]} echo ${tool_and_version_split[0]}
# echo ${tool_and_version_split[2]} echo ${tool_and_version_split[1]}
asdf plugin add ${tool_and_version_split[1]} || true asdf plugin add ${tool_and_version_split[0]} || true
asdf install ${tool_and_version_split[1]} ${tool_and_version_split[2]} asdf install ${tool_and_version_split[0]} ${tool_and_version_split[1]}
done <${ASDF_DEFAULT_TOOL_VERSIONS_FILENAME} done <${ASDF_DEFAULT_TOOL_VERSIONS_FILENAME}
asdf install asdf install
set -e set -e
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env zsh #!/usr/bin/env bash
set -e set -e
BIN
View File
Binary file not shown.
+10 -6
View File
@@ -29,16 +29,15 @@ const generateHelp = ({ cmds, prefixCmd = "", prefixDesc = "" }) => {
const commandLabel = cmd?.postCommand ? `${cmd?.key} ${cmd?.postCommand}` : cmd?.key const commandLabel = cmd?.postCommand ? `${cmd?.key} ${cmd?.postCommand}` : cmd?.key
if (cmd?.mainTitle) { if (cmd?.mainTitle) {
italicEmphasizeGreen(cmd?.mainTitle) italicEmphasizeGreen(cmd?.mainTitle)
if (cmd?.subCommands?.length > 0) { if (cmd?.keys?.length > 0) {
generateHelp({ generateHelp({
cmds: cmd?.subCommands || [], cmds: cmd?.keys || [],
prefixCmd: cmd?.key, prefixCmd: cmd?.key,
prefixDesc: cmd?.desc, prefixDesc: cmd?.desc,
}) })
} else { } else {
emphasizeText(formatCommandSection(commandLabel, prefixCmd, cmd?.maxLength), formatHelpSection(cmd?.desc, prefixDesc)) emphasizeText(formatCommandSection(commandLabel, prefixCmd, cmd?.maxLength), formatHelpSection(cmd?.desc, prefixDesc))
} }
console.groupEnd()
} else { } else {
emphasizeText(formatCommandSection(commandLabel, prefixCmd, cmd?.maxLength), formatHelpSection(cmd?.desc, prefixDesc)) emphasizeText(formatCommandSection(commandLabel, prefixCmd, cmd?.maxLength), formatHelpSection(cmd?.desc, prefixDesc))
} }
@@ -46,10 +45,14 @@ const generateHelp = ({ cmds, prefixCmd = "", prefixDesc = "" }) => {
} }
const cliHelp = async () => { const cliHelp = async () => {
if (process.env.JJ_CLI_ARG_2 == "auto-completion") {
// const aaa = getJJConfigByKeyChain(`commands`)
console.log(`add this to .zshrc: "source ${process.env.JJ_SOURCE_DIR}/bashUtils/auto-completion.sh" `)
return
}
console.log(chalk.blue.italic.bold("Usage: jj <COMMAND>")) console.log(chalk.blue.italic.bold("Usage: jj <COMMAND>"))
console.log("")
console.group(chalk.blue.italic.bold("Commands:")) console.group(chalk.blue.italic.bold("Commands:"))
console.log("")
cliConfig.commandsObject = getJJConfigByKeyChain(`commands`) cliConfig.commandsObject = getJJConfigByKeyChain(`commands`)
cliConfig.commandList = Object.keys(cliConfig.commandsObject).map((cmdKey) => ({ cliConfig.commandList = Object.keys(cliConfig.commandsObject).map((cmdKey) => ({
@@ -61,7 +64,8 @@ const cliHelp = async () => {
cmds: cliConfig.commandList, cmds: cliConfig.commandList,
}) })
console.groupEnd() return
} }
export default cliHelp; export default cliHelp;
+13
View File
@@ -0,0 +1,13 @@
export const dynamicStringHandler = (string: string, prefix: string, objectSource = {}, forceString = true) => {
let newString = string
Object.keys(objectSource).forEach((key) => {
const value = objectSource[key]
const keyReg = new RegExp(`__${prefix}${key}__`, "g")
if (forceString) {
newString = newString.replace(keyReg, typeof value == "string" ? `"${value}"` : value)
} else {
newString = newString.replace(keyReg, value)
}
})
return newString
}
+13 -23
View File
@@ -1,38 +1,28 @@
#!/usr/bin/env bun #!/usr/bin/env bun
import { import { jjCliYargs } from "./jjCliYargs";
dynamicStringHandler, jjCliYargs(false)
} 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
const requiredProcessEnvs = { const requiredProcessEnvs = {
JJ_SOURCE_DIR: process.env.JJ_SOURCE_DIR JJ_SOURCE_DIR: process.env.JJ_SOURCE_DIR
} }
if (JJ_CLI_ARG_1 == 'help') { import { getJJConfigByKeyChain, getJjYamlObj, jjConfigsExp } from "./jjConfigUtils";
await cliHelp() import _ from 'lodash';
process.exit(0) import { dynamicStringHandler } from "./dynamicStringHandler";
}
const jjCommandConfig = getJJConfigByKeyChain(`commands['${process.env.JJ_CLI_ARG_1}']`)
const jjCommandConfig = getJJConfigByKeyChain(`commands['${JJ_CLI_ARG_1}']`)
if (!jjCommandConfig || _.isEmpty(jjCommandConfig)) { 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) 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)
+39 -10
View File
@@ -5,7 +5,13 @@ import { hideBin } from "yargs/helpers";
import fs from "fs-extra"; import fs from "fs-extra";
import { jjConfigsExp } from "./jjConfigUtils"; import { jjConfigsExp } from "./jjConfigUtils";
try {
export const jjCliYargs = (cli = true) => {
const envsObj = {
}
try {
const parsedConfig = jjConfigsExp; const parsedConfig = jjConfigsExp;
const availableEnvironments = parsedConfig?.jjYamlObj?.environments || {}; const availableEnvironments = parsedConfig?.jjYamlObj?.environments || {};
@@ -19,15 +25,15 @@ try {
let commandString = ""; let commandString = "";
const commandList = []; const commandList = [];
mainCommands.forEach((command, index) => { mainCommands.forEach((command, index) => {
console.log(`export JJ_CLI_ARG_${index + 1}="${command}"`); envsObj[`JJ_CLI_ARG_${index + 1}`] = command
commandString += `"${command}" `; commandString += `"${command}" `;
commandList.push(command); commandList.push(command);
}); });
console.log(`export JJ_CLI_COMMANDS="${commandString}"`); envsObj[`JJ_CLI_COMMANDS`] = commandString
console.log(`export JJ_CLI_COMMANDS_COMMA_SEPTATE="${commandList.join(",")}"`); envsObj[`JJ_CLI_COMMANDS_COMMA_SEPTATE`] = commandList.join(",")
console.log(`export JJ_CLI_ADDITIONAL_ARGS="${remainingArgs.reduce((str, arg) => (str += `${arg} `), "").trim()}"`); envsObj[`JJ_CLI_ADDITIONAL_ARGS`] = remainingArgs.reduce((str, arg) => (str += `${arg} `), "").trim()
console.log(`export JJ_CLI_ADDITIONAL_ARGS_COMMA_SEPTATE="${remainingArgs.join(",")}"`); envsObj[`JJ_CLI_ADDITIONAL_ARGS_COMMA_SEPTATE`] = remainingArgs.join(",")
delete argumentsObj._; delete argumentsObj._;
delete argumentsObj["$0"]; delete argumentsObj["$0"];
@@ -64,16 +70,39 @@ try {
const matchedEnvIndex = keyIndex > -1 ? keyIndex : aliasIndex; const matchedEnvIndex = keyIndex > -1 ? keyIndex : aliasIndex;
argumentsObj[`${key}_alias`] = envAliases[matchedEnvIndex]; argumentsObj[`${key}_alias`] = envAliases[matchedEnvIndex];
} }
console.log(`export JJ_CLI_OPTION_${key.toUpperCase().split("-").join("_")}="${argumentsObj[key]}"`); envsObj[`JJ_CLI_OPTION_${key.toUpperCase().split("-").join("_")}`] = argumentsObj[key]
console.log(`export JJ_CLI_OPTION_${key.toUpperCase().split("-").join("_")}_ALIAS="${argumentsObj[`${key}_alias`]}"`); envsObj[`JJ_CLI_OPTION_${key.toUpperCase().split("-").join("_")}_ALIAS`] = argumentsObj[`${key}_alias`]
allOptionsMap[`${key.toUpperCase().split("-").join("_")}`] = argumentsObj[key]; allOptionsMap[`${key.toUpperCase().split("-").join("_")}`] = argumentsObj[key];
allOptionsMap[`${key.toUpperCase().split("-").join("_")}_ALIAS`] = argumentsObj[`${key}_alias`]; allOptionsMap[`${key.toUpperCase().split("-").join("_")}_ALIAS`] = argumentsObj[`${key}_alias`];
}); });
console.log(`export JJ_CLI_OPTIONS="${JSON.stringify(allOptionsMap)}"`); envsObj[`JJ_CLI_OPTIONS`] = JSON.stringify(allOptionsMap)
if(!envsObj['JJ_CLI_OPTION_COMMIT']){
envsObj['JJ_CLI_SELECTED_COMMIT'] = envsObj['JJ_WORKSPACE_CURRENT_COMMIT']
} else {
envsObj['JJ_CLI_SELECTED_COMMIT'] = envsObj['JJ_CLI_OPTION_COMMIT']
}
if (cli) {
Object.keys(envsObj).forEach(envKey => {
console.log(`export ${envKey}="${envsObj[envKey]}"`)
})
process.exit(0) process.exit(0)
} else {
process.env = {
...process.env,
...envsObj
}
}
} catch (exception) { } catch (exception) {
console.error(exception); console.error(exception);
process.exit(1); process.exit(1);
}
}
if(process.argv[process.argv.length - 1]== "cli"){
process.argv.pop()
jjCliYargs()
} }
+27 -20
View File
@@ -19,6 +19,7 @@ export const jjConfigs: any = {
export const jjEnsure = async ({ export const jjEnsure = async ({
returnProcessEnvs = false returnProcessEnvs = false
}) => { }) => {
// return
jjConfigs.modulePath = path.resolve(__dirname, "../") jjConfigs.modulePath = path.resolve(__dirname, "../")
jjConfigs.tmpDir = `${jjConfigs.modulePath}/~~tmp` jjConfigs.tmpDir = `${jjConfigs.modulePath}/~~tmp`
jjConfigs.configSaveFilePath = `${jjConfigs.tmpDir}/configSaveFilePath.txt` jjConfigs.configSaveFilePath = `${jjConfigs.tmpDir}/configSaveFilePath.txt`
@@ -39,20 +40,21 @@ export const jjEnsure = async ({
message: '', message: '',
}, },
]) ])
if (!fs.existsSync(answer.jjYamlPath)) { jjConfigs.jjYamlPath = answer.jjYamlPath
jjLogError(`can not find ${answer.jjYamlPath}`) if (!fs.existsSync(jjConfigs.jjYamlPath)) {
jjLogError(`can not find ${jjConfigs.jjYamlPath}`)
} }
const jjYamlRawContent = await fs.readFile(answer.jjYamlPath, "utf8") const jjYamlRawContent = await fs.readFile(jjConfigs.jjYamlPath, "utf8")
const jjYamlObj: any = YAML.load(jjYamlRawContent) const jjYamlObj: any = YAML.load(jjYamlRawContent)
if (_.isEmpty(jjYamlObj?.environments || {})) { if (_.isEmpty(jjYamlObj?.environments || {})) {
jjLogError(`Wrong ${answer.jjYamlPath} file`) jjLogError(`Wrong ${jjConfigs.jjYamlPath} file`)
} }
jjConfigs.jjWorkSpacePath = path.dirname(answer.jjYamlPath) jjConfigs.jjWorkSpacePath = path.dirname(jjConfigs.jjYamlPath)
jjConfigs.jjYamlObj = jjYamlObj jjConfigs.jjYamlObj = jjYamlObj
await fs.writeFile(jjConfigs.configSaveFilePath, answer.jjYamlPath, "utf8") await fs.writeFile(jjConfigs.configSaveFilePath, jjConfigs.jjYamlPath, "utf8")
} else { } else {
jjConfigs.jjYamlPath = await fs.readFile(jjConfigs.configSaveFilePath, "utf8") jjConfigs.jjYamlPath = await fs.readFile(jjConfigs.configSaveFilePath, "utf8")
@@ -104,8 +106,8 @@ export const jjEnsure = async ({
email: jjConfigs.processEnvs.JJ_GIT_USER_EMAIL, email: jjConfigs.processEnvs.JJ_GIT_USER_EMAIL,
} }
} }
fs.writeFileSync(
jjConfigs.jjYamlPath, saveFileIfItChanged(
YAML.dump( YAML.dump(
jjConfigs.jjYamlObj, jjConfigs.jjYamlObj,
{ {
@@ -115,36 +117,41 @@ export const jjEnsure = async ({
// sortKeys: true // sortKeys: true
} }
), ),
"utf8" jjConfigs.jjYamlPath
) )
saveFileIfItChanged(JSON.stringify(jjConfigs, null, 4), `${jjConfigs.tmpDir}/jjConfigs.json`) saveFileIfItChanged(JSON.stringify(jjConfigs, null, 4), `${jjConfigs.tmpDir}/jjConfigs.json`)
if (returnProcessEnvs) { if (returnProcessEnvs) {
Object.keys(jjConfigs.processEnvs).forEach((envKey) => { let shEnvs = ''
console.log(`export ${envKey.toUpperCase().split("-").join("_")}="${jjConfigs.processEnvs[envKey]}"`)
})
} else {
console.log(jjConfigs.jjYamlObj)
Object.keys(jjConfigs.processEnvs).forEach((envKey) => {
const command = `export ${envKey.toUpperCase().split("-").join("_")}="${jjConfigs.processEnvs[envKey]}"`
shEnvs += `${command}\n`
console.log(command)
})
fs.writeFileSync(`${jjConfigs.tmpDir}/shEnvs.sh`, shEnvs, 'utf-8');
} }
return jjConfigs return jjConfigs
} }
if ( if (
//
_.get(process.argv, "[1]", "")?.includes('helpers/jjEnsure.ts') _.get(process.argv, "[1]", "")?.includes('helpers/jjEnsure.ts')
&& _.get(process.argv, "[2]", "") == 'returnProcessEnvs'
) { ) {
if (_.get(process.argv, "[2]", "") == 'returnProcessEnvs') {
const jj = await jjEnsure({ returnProcessEnvs: true }) const jj = await jjEnsure({ returnProcessEnvs: true })
process.exit(0) process.exit(0)
}
if (_.get(process.argv, "[2]", "") == 'init') {
const jj = await jjEnsure({ returnProcessEnvs: false })
process.exit(0)
}
process.exit(0)
} }
+53 -31
View File
@@ -1,23 +1,27 @@
#!/usr/bin/env zsh #!/usr/bin/env bash
MILLISECONDS_START=$(echo "$EPOCHREALTIME * 1000" | bc)
get_milliseconds() {
local current_time=$(echo "$EPOCHREALTIME * 1000" | bc)
echo "$(echo "$current_time - $MILLISECONDS_START" | bc | awk '{printf "%.0f", $0}')"
}
set -e set -e
trap '[[ "$?" == "1" ]] && echo -e "\033[1;31m[jj] ERROR !\033[0m" >&2' EXIT trap '[[ "$?" == "1" ]] && echo -e "\033[1;31m[jj] ERROR !\033[0m" >&2' EXIT
# set + # set +
# ZSH specific
autoload -U compinit # autoload -U compinit
compinit # compinit
jjCpmmandRunPoint=$(echo ${BASH_SOURCE[0]}) jjCpmmandRunPoint=$(echo ${BASH_SOURCE[0]})
function findJJSource { function findJJSource {
# @source http://stackoverflow.com/a/246128/330439 # @source http://stackoverflow.com/a/246128/330439
local SOURCE="$jjCpmmandRunPoint" local SOURCE="$jjCpmmandRunPoint"
@@ -37,10 +41,15 @@ function findJJSource {
export JJ_SOURCE_DIR=$(findJJSource) export JJ_SOURCE_DIR=$(findJJSource)
if [[ "$1" == "--clean" ]]; then if [[ "$1" == "--clean" ]]; then
rm -rf $JJ_SOURCE_DIR/~~tmp/deps rm -rf $JJ_SOURCE_DIR/~~tmp/deps
fi fi
if [[ -e ~/.bun/bin/bun ]]; then if [[ -e ~/.bun/bin/bun ]]; then
export PATH="~/.bun/bin:${PATH}" export PATH="~/.bun/bin:${PATH}"
fi fi
@@ -53,38 +62,42 @@ if [[ "$__currentBunVersion" != "${__bunVersionExpect}" ]]; then
export PATH="~/.bun/bin:${PATH}" export PATH="~/.bun/bin:${PATH}"
fi fi
mkdir -p "$JJ_SOURCE_DIR/~~tmp/deps" mkdir -p "$JJ_SOURCE_DIR/~~tmp/deps"
alias jj="$JJ_SOURCE_DIR/jj.sh" alias jj="$JJ_SOURCE_DIR/jj.sh"
source "$JJ_SOURCE_DIR/bashUtils/index.sh" source "$JJ_SOURCE_DIR/bashUtils/index.sh"
if [[ ! -e "$JJ_SOURCE_DIR/~~tmp/configSaveFilePath.txt" ]]; then
$JJ_SOURCE_DIR/helpers/jjEnsure.ts init
fi
# $JJ_SOURCE_DIR/helpers/jjEnsure.ts returnProcessEnvs # $JJ_SOURCE_DIR/helpers/jjEnsure.ts returnProcessEnvs
# exit 0 # exit 0
eval $($JJ_SOURCE_DIR/helpers/jjEnsure.ts returnProcessEnvs) if [[ ! -e "$JJ_SOURCE_DIR/~~tmp/configSaveFilePath.txt" ]]; then
# echo $JJ_WORKSPACE_DIR $JJ_SOURCE_DIR/helpers/jjEnsure.ts init
fi
# jjCliLog jjLog testjjLog a b c s if [[ -e "$JJ_SOURCE_DIR/~~tmp/shEnvs.sh" ]]; then
# jjCliLog jjLogInfo testjjLogInfo source $JJ_SOURCE_DIR/~~tmp/shEnvs.sh
# jjCliLog jjLogHeading testjjLogHeading fi
if [[ ! -e "$JJ_SOURCE_DIR/~~tmp/shEnvs.sh" ]] \
source "$JJ_SOURCE_DIR/bashUtils/ensureDependency.sh" || [[ -z $JJ_WORKSPACE_DIR ]] \
|| jjIsFileNewerFile "$JJ_WORKSPACE_DIR/jj.yaml" "$JJ_SOURCE_DIR/~~tmp/shEnvs.sh" \
|| jjIsFileNewerFile "$JJ_SOURCE_DIR/~~tmp/jjConfigs.json" "$JJ_SOURCE_DIR/~~tmp/shEnvs.sh" \
|| jjIsFileNewerFile "$JJ_SOURCE_DIR/package.json" "$JJ_SOURCE_DIR/~~tmp/shEnvs.sh" \
# ${JJ_SOURCE_DIR}/helpers/jjCliYargs.ts $@ || jjIsFileNewerFile "$JJ_WORKSPACE_DIR/package.json" "$JJ_SOURCE_DIR/~~tmp/shEnvs.sh" \
eval $(${JJ_SOURCE_DIR}/helpers/jjCliYargs.ts $@ ) ; then
set -- $(echo $JJ_CLI_COMMANDS) MILLISECONDS=$(get_milliseconds) ; echo "returnProcessEnvs 01 $MILLISECONDS"
eval $($JJ_SOURCE_DIR/helpers/jjEnsure.ts returnProcessEnvs)
echo $JJ_CLI_ADDITIONAL_ARGS_COMMA_SEPTATE MILLISECONDS=$(get_milliseconds) ; echo "returnProcessEnvs 02 $MILLISECONDS"
fi
source $JJ_SOURCE_DIR/~~tmp/shEnvs.sh
export JJ_WORKSPACE_CURRENT_COMMIT=$(cd $JJ_WORKSPACE_DIR ; git rev-parse HEAD) export JJ_WORKSPACE_CURRENT_COMMIT=$(cd $JJ_WORKSPACE_DIR ; git rev-parse HEAD)
export JJ_WORKSPACE_CURRENT_BRANCH=$(cd $JJ_WORKSPACE_DIR ; git rev-parse --abbrev-ref HEAD) export JJ_WORKSPACE_CURRENT_BRANCH=$(cd $JJ_WORKSPACE_DIR ; git rev-parse --abbrev-ref HEAD)
@@ -93,18 +106,27 @@ export JJ_WORKSPACE_CURRENT_VERSION=$(cat $JJ_WORKSPACE_DIR/package.json | jq -r
export JJ_WORKSPACE_CURRENT_ISO_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") export JJ_WORKSPACE_CURRENT_ISO_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
if [[ -z "$JJ_CLI_OPTION_COMMIT" ]]; then
export JJ_CLI_SELECTED_COMMIT=$JJ_WORKSPACE_CURRENT_COMMIT source "$JJ_SOURCE_DIR/bashUtils/ensureDependency.sh"
else
export JJ_CLI_SELECTED_COMMIT=$JJ_CLI_OPTION_COMMIT # echo 2
fi # # exit 0
# ${JJ_SOURCE_DIR}/helpers/jjCliYargs.ts $@
# eval $(${JJ_SOURCE_DIR}/helpers/jjCliYargs.ts $@ cli)
# set -- $(echo $JJ_CLI_COMMANDS)
# echo $JJ_CLI_ADDITIONAL_ARGS_COMMA_SEPTATE
# if [[ ! -e $JJ_SOURCE_DIR/~~tmp/pa ]]; then # if [[ ! -e $JJ_SOURCE_DIR/~~tmp/pa ]]; then
# echo "asdadasd" # echo "asdadasd"
# fi # fi
${JJ_SOURCE_DIR}/helpers/jjCli.ts ${JJ_SOURCE_DIR}/helpers/jjCli.ts $@
+1 -2
View File
@@ -1,7 +1,7 @@
{ {
"name": "jj-command-line", "name": "jj-command-line",
"description": "jj cli", "description": "jj cli",
"version": "0.0.7", "version": "1.0.1",
"author": "Jason Jafari", "author": "Jason Jafari",
"bin": { "bin": {
"jj": "./jj.sh $@" "jj": "./jj.sh $@"
@@ -27,7 +27,6 @@
"moment": "^2.30.1", "moment": "^2.30.1",
"pino": "^9.5.0", "pino": "^9.5.0",
"pino-pretty": "^12.1.0", "pino-pretty": "^12.1.0",
"portainer_wrapper": "1.0.50",
"shelljs": "^0.8.5", "shelljs": "^0.8.5",
"winston": "^3.16.0", "winston": "^3.16.0",
"yargs": "^17.7.2" "yargs": "^17.7.2"