This commit is contained in:
2024-11-14 19:33:12 -05:00
parent 1b722e7c85
commit a22018cf1a
5 changed files with 238 additions and 251 deletions
+3
View File
@@ -0,0 +1,3 @@
node_modules/
.~*
~~
+8 -7
View File
@@ -15,14 +15,14 @@ const logger = makeJJlogger({
}) })
const getSecretFolder = () => { export const getSecretFolder = () => {
let secretsFolder = getJJConfigByKeyChain(`secretsFolder`) let secretsFolder = getJJConfigByKeyChain(`secretsFolder`)
secretsFolder = dynamicStringHandler(secretsFolder, "", process.env, false) secretsFolder = dynamicStringHandler(secretsFolder, "", process.env, false)
return secretsFolder return secretsFolder
} }
const getEncryptionKeyForEnv = (envKey) => { export const getEncryptionKeyForEnv = (envKey) => {
const secretsFolder = getSecretFolder() const secretsFolder = getSecretFolder()
if (!fs.existsSync(`${secretsFolder}/~~${envKey}`)) { if (!fs.existsSync(`${secretsFolder}/~~${envKey}`)) {
logger.error(`Encryption key for ${envKey} env not fond and nt exist `) logger.error(`Encryption key for ${envKey} env not fond and nt exist `)
@@ -33,7 +33,7 @@ const getEncryptionKeyForEnv = (envKey) => {
} }
const decryptFile = async (absFilePath) => { export const decryptFile = async (absFilePath) => {
if (!fs.existsSync(absFilePath)) { if (!fs.existsSync(absFilePath)) {
logger.error(`Secret ${absFilePath} is not exist`) logger.error(`Secret ${absFilePath} is not exist`)
} }
@@ -73,10 +73,11 @@ const decryptFile = async (absFilePath) => {
const decryptedShFormat = `${absDirPath}/~~decrypt/${fileName}.sh` const decryptedShFormat = `${absDirPath}/~~decrypt/${fileName}.sh`
fs.writeFileSync(decryptedShFormat, shFormatDecrypt, 'utf-8'); fs.writeFileSync(decryptedShFormat, shFormatDecrypt, 'utf-8');
logger.success(`decrypt file-secret for ${absFilePath} done`) logger.success(`decrypt file-secret for ${absFilePath} done`)
return decryptedSecretObj
} }
const setSecretFileFromFile = async ({ export const setSecretFileFromFile = async ({
absFilePath, absFilePath,
secretKey, secretKey,
secretAbsFilePath secretAbsFilePath
@@ -94,7 +95,7 @@ const setSecretFileFromFile = async ({
}) })
} }
const setSecretFile = async ({ export const setSecretFile = async ({
absFilePath, absFilePath,
secretKey, secretKey,
secretValue secretValue
@@ -117,7 +118,7 @@ const setSecretFile = async ({
} }
const commitSecretMeta = async () => { export const commitSecretMeta = async () => {
const metadataRepoFolderRelative = getJJConfigByKeyChain(`metadataRepo.path`) const metadataRepoFolderRelative = getJJConfigByKeyChain(`metadataRepo.path`)
const metadataRepoBranch = getJJConfigByKeyChain(`metadataRepo.branch`) const metadataRepoBranch = getJJConfigByKeyChain(`metadataRepo.branch`)
@@ -195,7 +196,7 @@ const commitSecretMeta = async () => {
} }
const secrets = async () => { export const secrets = async () => {
if (process.env.JJ_CLI_ARG_2 == 'commitSecretMeta') { if (process.env.JJ_CLI_ARG_2 == 'commitSecretMeta') {
+164 -181
View File
@@ -1,9 +1,9 @@
#!/usr/bin/env bun #!/usr/bin/env bun
import path from "path"; import path from "path";
import fs from 'fs-extra'; import fs from "fs-extra";
import inquirer from "inquirer"; import inquirer from "inquirer";
import * as YAML from "js-yaml" import * as YAML from "js-yaml";
import { _ } from "lodash"; import { _ } from "lodash";
import { jjLog, jjLogAction, jjLogError } from "./jjLogger"; import { jjLog, jjLogAction, jjLogError } from "./jjLogger";
import { saveFileIfItChanged } from "./saveFileIfItChanged"; import { saveFileIfItChanged } from "./saveFileIfItChanged";
@@ -11,279 +11,262 @@ import { gitUserEmail, gitUserName, jjUserName } from "./userUtils";
import chalk from "chalk"; import chalk from "chalk";
export const jjConfigs: any = { export const jjConfigs: any = {
processEnvs: {} processEnvs: {},
} };
export const jjEnsure = async ({ returnProcessEnvs = false }) => {
export const jjEnsure = async ({
returnProcessEnvs = false
}) => {
// return // return
jjConfigs.JJ_SOURCE_DIR = process.env.JJ_SOURCE_DIR jjConfigs.JJ_SOURCE_DIR = process.env.JJ_SOURCE_DIR;
jjConfigs.JJ_DATA_DIR = process.env.JJ_DATA_DIR jjConfigs.JJ_DATA_DIR = process.env.JJ_DATA_DIR;
jjConfigs.JJ_TMP_DIR = `${jjConfigs.JJ_DATA_DIR}/~~tmp` jjConfigs.JJ_TMP_DIR = `${jjConfigs.JJ_DATA_DIR}/~~tmp`;
jjConfigs.JJ_DEPS_DIR = `${jjConfigs.JJ_DATA_DIR}/~~tmp/deps` jjConfigs.JJ_DEPS_DIR = `${jjConfigs.JJ_DATA_DIR}/~~tmp/deps`;
jjConfigs.configSaveFilePath = `${jjConfigs.JJ_TMP_DIR}/configSaveFilePath.txt` jjConfigs.configSaveFilePath = `${jjConfigs.JJ_TMP_DIR}/configSaveFilePath.txt`;
jjConfigs.workspacesFilePath = `${jjConfigs.JJ_TMP_DIR}/workspacesFilePath.json` jjConfigs.workspacesFilePath = `${jjConfigs.JJ_TMP_DIR}/workspacesFilePath.json`;
if (!fs.existsSync(jjConfigs.JJ_TMP_DIR)) { if (!fs.existsSync(jjConfigs.JJ_TMP_DIR)) {
jjLog(`tmp folder ${jjConfigs.JJ_TMP_DIR} is not exist creating`) jjLog(`tmp folder ${jjConfigs.JJ_TMP_DIR} is not exist creating`);
fs.mkdirSync(jjConfigs.JJ_TMP_DIR, { recursive: true }) fs.mkdirSync(jjConfigs.JJ_TMP_DIR, { recursive: true });
} }
if (!fs.existsSync(jjConfigs.workspacesFilePath)) { if (!fs.existsSync(jjConfigs.workspacesFilePath)) {
await fs.writeFile(jjConfigs.workspacesFilePath, JSON.stringify([], null, 4), "utf8") await fs.writeFile(jjConfigs.workspacesFilePath, JSON.stringify([], null, 4), "utf8");
} }
jjConfigs.workspaces = JSON.parse((await fs.readFile(jjConfigs.workspacesFilePath, "utf8"))) jjConfigs.workspaces = JSON.parse(await fs.readFile(jjConfigs.workspacesFilePath, "utf8"));
if (!fs.existsSync(jjConfigs.configSaveFilePath)) { if (!fs.existsSync(jjConfigs.configSaveFilePath)) {
console.log(chalk.yellow.bold(`JJ cli require jj.yaml absolute`));
console.log(chalk.yellow.bold(`JJ cli require jj.yaml absolute`))
if (jjConfigs.workspaces.length > 0) { if (jjConfigs.workspaces.length > 0) {
console.log(chalk.magenta.bold(`please select following options:`)) console.log(chalk.magenta.bold(`please select following options:`));
jjConfigs.workspaces.forEach((jjYamlPath, index) => { jjConfigs.workspaces.forEach((jjYamlPath, index) => {
console.log(chalk.magenta.bold(`${index + 1} ${jjYamlPath}`)) console.log(chalk.magenta.bold(`${index + 1} ${jjYamlPath}`));
}) });
console.log(chalk.magenta.bold(`${jjConfigs.workspaces.length + 1} new workspace`)) console.log(chalk.magenta.bold(`${jjConfigs.workspaces.length + 1} new workspace`));
const optionSelect: any = await inquirer.prompt([ const optionSelect: any = await inquirer.prompt([
{ {
type: 'input', type: "input",
name: 'optionSelect', name: "optionSelect",
message: '', message: "",
}, },
]) ]);
if (optionSelect?.optionSelect - 1 != jjConfigs.workspaces.length) { if (optionSelect?.optionSelect - 1 != jjConfigs.workspaces.length) {
jjConfigs.jjYamlPath = jjConfigs.workspaces[optionSelect?.optionSelect - 1] jjConfigs.jjYamlPath = jjConfigs.workspaces[optionSelect?.optionSelect - 1];
} }
} }
if (!jjConfigs.jjYamlPath) { if (!jjConfigs.jjYamlPath) {
console.log(chalk.magenta.bold(`please add it here in absolute path`));
console.log(chalk.magenta.bold(`please add it here in absolute path`))
const answer: any = await inquirer.prompt([ const answer: any = await inquirer.prompt([
{ {
type: 'input', type: "input",
name: 'jjYamlPath', name: "jjYamlPath",
message: '', message: "",
}, },
]) ]);
jjConfigs.jjYamlPath = answer.jjYamlPath jjConfigs.jjYamlPath = answer.jjYamlPath;
} }
if (!fs.existsSync(jjConfigs.jjYamlPath)) { if (!fs.existsSync(jjConfigs.jjYamlPath)) {
jjLogError(`can not find ${jjConfigs.jjYamlPath}`) jjLogError(`can not find ${jjConfigs.jjYamlPath}`);
} }
const jjYamlRawContent = await fs.readFile(jjConfigs.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 ${jjConfigs.jjYamlPath} file`) jjLogError(`Wrong ${jjConfigs.jjYamlPath} file`);
} }
jjConfigs.workspaces = [... new Set([...jjConfigs.workspaces, jjConfigs.jjYamlPath])] jjConfigs.workspaces = [...new Set([...jjConfigs.workspaces, jjConfigs.jjYamlPath])];
await fs.writeFile(jjConfigs.workspacesFilePath, JSON.stringify(jjConfigs.workspaces, null, 4), "utf8") await fs.writeFile(jjConfigs.workspacesFilePath, JSON.stringify(jjConfigs.workspaces, null, 4), "utf8");
jjConfigs.jjWorkSpacePath = path.dirname(jjConfigs.jjYamlPath) jjConfigs.JJ_WORKSPACE_DIR = path.dirname(jjConfigs.jjYamlPath);
jjConfigs.jjYamlObj = jjYamlObj jjConfigs.jjYamlObj = jjYamlObj;
await fs.writeFile(jjConfigs.configSaveFilePath, jjConfigs.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");
jjConfigs.jjWorkSpacePath = path.dirname(jjConfigs.jjYamlPath) jjConfigs.JJ_WORKSPACE_DIR = path.dirname(jjConfigs.jjYamlPath);
const jjYamlRawContent = await fs.readFile(jjConfigs.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 ${jjConfigs.jjYamlPath} file`) jjLogError(`Wrong ${jjConfigs.jjYamlPath} file`);
} }
jjConfigs.jjYamlObj = jjYamlObj jjConfigs.jjYamlObj = jjYamlObj;
} }
jjConfigs.processEnvs.JJ_WORKSPACE_DIR = jjConfigs.JJ_WORKSPACE_DIR;
jjConfigs.processEnvs.JJ_TMP_DIR = jjConfigs.JJ_TMP_DIR;
jjConfigs.processEnvs.JJ_SOURCE_DIR = jjConfigs.JJ_SOURCE_DIR;
jjConfigs.processEnvs.JJ_DATA_DIR = jjConfigs.JJ_DATA_DIR;
jjConfigs.JJ_WORKSPACE_TMP_DIR = `${jjConfigs.JJ_WORKSPACE_DIR}/~~tmp`;
jjConfigs.processEnvs.JJ_WORKSPACE_TMP_DIR = jjConfigs.JJ_WORKSPACE_TMP_DIR;
jjConfigs.processEnvs.JJ_WORKSPACE_PROJECT_NAME = jjConfigs.jjYamlObj.name;
jjConfigs.processEnvs.ASDF_DIR = `${process.env.JJ_DATA_DIR}/~~asdf_${jjConfigs.processEnvs.JJ_WORKSPACE_PROJECT_NAME}`;
jjConfigs.processEnvs.ASDF_DATA_DIR = `${process.env.JJ_DATA_DIR}/~~asdf_${jjConfigs.processEnvs.JJ_WORKSPACE_PROJECT_NAME}`;
jjConfigs.processEnvs.ASDF_DEFAULT_TOOL_VERSIONS_FILENAME = `${jjConfigs.JJ_TMP_DIR}/.tool-versions`;
jjConfigs.processEnvs.JJ_WORKSPACE_DIR = jjConfigs.jjWorkSpacePath const asdfToolsVersionFileContent = Object.keys(jjConfigs.jjYamlObj.asdf.tools)
jjConfigs.processEnvs.JJ_SOURCE_DIR = jjConfigs.JJ_SOURCE_DIR .map((key) => `${key} ${jjConfigs.jjYamlObj.asdf.tools[key].version}`)
jjConfigs.processEnvs.JJ_DATA_DIR = jjConfigs.JJ_DATA_DIR .join("\n");
jjConfigs.JJ_WORKSPACE_DIR = jjConfigs.JJ_WORKSPACE_DIR
jjConfigs.processEnvs.JJ_WORKSPACE_PROJECT_NAME = jjConfigs.jjYamlObj.name
jjConfigs.processEnvs.ASDF_DIR = `${process.env.JJ_DATA_DIR}/~~asdf_${jjConfigs.processEnvs.JJ_WORKSPACE_PROJECT_NAME}`
jjConfigs.processEnvs.ASDF_DATA_DIR = `${process.env.JJ_DATA_DIR}/~~asdf_${jjConfigs.processEnvs.JJ_WORKSPACE_PROJECT_NAME}`
jjConfigs.processEnvs.ASDF_DEFAULT_TOOL_VERSIONS_FILENAME = `${jjConfigs.JJ_TMP_DIR}/.tool-versions`
const asdfToolsVersionFileContent = Object.keys(jjConfigs.jjYamlObj.asdf.tools).map(key => `${key} ${jjConfigs.jjYamlObj.asdf.tools[key].version}`).join('\n') saveFileIfItChanged(asdfToolsVersionFileContent, jjConfigs.processEnvs.ASDF_DEFAULT_TOOL_VERSIONS_FILENAME);
saveFileIfItChanged(asdfToolsVersionFileContent, jjConfigs.processEnvs.ASDF_DEFAULT_TOOL_VERSIONS_FILENAME)
// export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="$GC_HOME_DIR/.tool-versions" // export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="$GC_HOME_DIR/.tool-versions"
jjConfigs.processEnvs.ASDF_VERSION = jjConfigs.jjYamlObj.asdf.version jjConfigs.processEnvs.ASDF_VERSION = jjConfigs.jjYamlObj.asdf.version;
jjConfigs.processEnvs.OS_DEPENDENCIES = jjConfigs.jjYamlObj.osDependencies.join(' ') jjConfigs.processEnvs.OS_DEPENDENCIES = jjConfigs.jjYamlObj.osDependencies.join(" ");
const bunGlobalDependencies = jjConfigs.jjYamlObj.bun.globals.join(' ') const bunGlobalDependencies = jjConfigs.jjYamlObj.bun.globals.join(" ");
saveFileIfItChanged(bunGlobalDependencies, `${jjConfigs.JJ_TMP_DIR}/bunGlobalDependencies.txt`) saveFileIfItChanged(bunGlobalDependencies, `${jjConfigs.JJ_TMP_DIR}/bunGlobalDependencies.txt`);
jjConfigs.processEnvs.BUN_GLOBAL_DEPENDENCIES = bunGlobalDependencies jjConfigs.processEnvs.BUN_GLOBAL_DEPENDENCIES = bunGlobalDependencies;
jjConfigs.processEnvs.JJ_GIT_METADATA_DIR = `${jjConfigs.processEnvs.JJ_WORKSPACE_DIR}/${jjConfigs.jjYamlObj.metadataRepo.path}` jjConfigs.processEnvs.JJ_GIT_METADATA_DIR = `${jjConfigs.processEnvs.JJ_WORKSPACE_DIR}/${jjConfigs.jjYamlObj.metadataRepo.path}`;
jjConfigs.processEnvs.JJ_GIT_METADATA_BRANCH = jjConfigs.jjYamlObj.metadataRepo.branch jjConfigs.processEnvs.JJ_GIT_METADATA_BRANCH = jjConfigs.jjYamlObj.metadataRepo.branch;
jjConfigs.processEnvs.JJ_GIT_METADATA_MAIN_ORIGIN = jjConfigs.jjYamlObj.metadataRepo.remotes.origin jjConfigs.processEnvs.JJ_GIT_METADATA_MAIN_ORIGIN = jjConfigs.jjYamlObj.metadataRepo.remotes.origin;
if (jjConfigs.jjYamlObj.metadataRepo.remotes.github) { if (jjConfigs.jjYamlObj.metadataRepo.remotes.github) {
jjConfigs.processEnvs.JJ_GIT_METADATA_GITHUB_ORIGIN = jjConfigs.jjYamlObj.metadataRepo.remotes.github jjConfigs.processEnvs.JJ_GIT_METADATA_GITHUB_ORIGIN = jjConfigs.jjYamlObj.metadataRepo.remotes.github;
jjConfigs.processEnvs.JJ_GIT_METADATA_GITHUB_ORIGIN_NAME = 'github' jjConfigs.processEnvs.JJ_GIT_METADATA_GITHUB_ORIGIN_NAME = "github";
} }
jjConfigs.processEnvs.JJ_GIT_USER_EMAIL = gitUserEmail;
jjConfigs.processEnvs.JJ_GIT_USER_EMAIL = gitUserEmail jjConfigs.processEnvs.JJ_GIT_USER_NAME = gitUserName;
jjConfigs.processEnvs.JJ_GIT_USER_NAME = gitUserName jjConfigs.processEnvs.JJ_GIT_USER_KEY_NAME = jjUserName(jjConfigs.processEnvs.JJ_GIT_USER_EMAIL);
jjConfigs.processEnvs.JJ_GIT_USER_KEY_NAME = jjUserName(jjConfigs.processEnvs.JJ_GIT_USER_EMAIL)
if (jjConfigs.processEnvs.JJ_GIT_USER_KEY_NAME && !jjConfigs.jjYamlObj.users[jjConfigs.processEnvs.JJ_GIT_USER_KEY_NAME]) { if (jjConfigs.processEnvs.JJ_GIT_USER_KEY_NAME && !jjConfigs.jjYamlObj.users[jjConfigs.processEnvs.JJ_GIT_USER_KEY_NAME]) {
jjConfigs.jjYamlObj.users[jjConfigs.processEnvs.JJ_GIT_USER_KEY_NAME] = { jjConfigs.jjYamlObj.users[jjConfigs.processEnvs.JJ_GIT_USER_KEY_NAME] = {
name: jjConfigs.processEnvs.JJ_GIT_USER_NAME, name: jjConfigs.processEnvs.JJ_GIT_USER_NAME,
email: jjConfigs.processEnvs.JJ_GIT_USER_EMAIL, email: jjConfigs.processEnvs.JJ_GIT_USER_EMAIL,
} };
} }
saveFileIfItChanged( saveFileIfItChanged(
YAML.dump( YAML.dump(jjConfigs.jjYamlObj, {
jjConfigs.jjYamlObj, indent: 4,
{ lineWidth: 3,
indent: 4, forceQuotes: true,
lineWidth: 3, // sortKeys: true
forceQuotes: true, }),
// sortKeys: true
}
),
jjConfigs.jjYamlPath jjConfigs.jjYamlPath
) );
jjConfigs.jjYamlObj.commands = { jjConfigs.jjYamlObj.commands = {
"help": { help: {
"desc": "This help info.", desc: "This help info.",
"mainTitle": "Help", mainTitle: "Help",
"postCommand": "", postCommand: "",
"maxLength": 12, maxLength: 12,
"keys": [ keys: [
{ {
"key": "auto-completion", key: "auto-completion",
"desc": "auto-completion", desc: "auto-completion",
"keys": [] keys: [],
}, },
{ {
"key": "workDirs", key: "workDirs",
"desc": "workDirs", desc: "workDirs",
"keys": [] keys: [],
}, },
{ {
"key": "version-source", key: "version-source",
"desc": "version-source", desc: "version-source",
"keys": [] keys: [],
}, },
{ {
"key": "version-workspace", key: "version-workspace",
"desc": "version-workspace", desc: "version-workspace",
"keys": [] keys: [],
}, },
{ {
"key": "change-workspace", key: "change-workspace",
"desc": "change-workspace", desc: "change-workspace",
"keys": [] keys: [],
}, },
{ {
"key": "clean-workspace", key: "clean-workspace",
"desc": "clean-workspace", desc: "clean-workspace",
"keys": [] keys: [],
} },
], ],
"scriptToRun": { scriptToRun: {
"prePath": "__JJ_SOURCE_DIR__", prePath: "__JJ_SOURCE_DIR__",
"path": "cli/help.ts" path: "cli/help.ts",
} },
}, },
"secrets": { secrets: {
"desc": "Secrets", desc: "Secrets",
"mainTitle": "Secrets", mainTitle: "Secrets",
"postCommand": "", postCommand: "",
"maxLength": 12, maxLength: 12,
"keys": [ keys: [
{ {
"key": "setSecret", key: "setSecret",
"desc": "Set a secret to the given file", desc: "Set a secret to the given file",
"postCommand": " file key val", postCommand: " file key val",
"maxLength": 50, maxLength: 50,
"keys": [], keys: [],
"postCommandsForce": [] postCommandsForce: [],
}, },
{ {
"key": "setSecretFromFile", key: "setSecretFromFile",
"desc": "Set a secret to the given file", desc: "Set a secret to the given file",
"postCommand": " file key absFile", postCommand: " file key absFile",
"maxLength": 50, maxLength: 50,
"keys": [], keys: [],
"postCommandsForce": [] postCommandsForce: [],
}, },
{ {
"key": "decryptFile", key: "decryptFile",
"desc": "decrypt file", desc: "decrypt file",
"postCommand": " file", postCommand: " file",
"maxLength": 50, maxLength: 50,
"keys": [], keys: [],
"postCommandsForce": [] postCommandsForce: [],
}, },
{ {
"key": "commitSecretMeta", key: "commitSecretMeta",
"desc": "", desc: "",
"postCommand": "", postCommand: "",
"maxLength": 50, maxLength: 50,
"keys": [], keys: [],
"postCommandsForce": [] postCommandsForce: [],
} },
], ],
"scriptToRun": { scriptToRun: {
"prePath": "__JJ_SOURCE_DIR__", prePath: "__JJ_SOURCE_DIR__",
"path": "cli/secrets.ts" path: "cli/secrets.ts",
} },
}, },
...jjConfigs.jjYamlObj.commands ...jjConfigs.jjYamlObj.commands,
} };
saveFileIfItChanged(JSON.stringify(jjConfigs, null, 4), `${jjConfigs.JJ_TMP_DIR}/jjConfigs.json`)
saveFileIfItChanged(JSON.stringify(jjConfigs, null, 4), `${jjConfigs.JJ_TMP_DIR}/jjConfigs.json`);
if (returnProcessEnvs) { if (returnProcessEnvs) {
let shEnvs = "";
let shEnvs = ''
Object.keys(jjConfigs.processEnvs).forEach((envKey) => { Object.keys(jjConfigs.processEnvs).forEach((envKey) => {
const command = `export ${envKey.toUpperCase().split("-").join("_")}="${jjConfigs.processEnvs[envKey]}"` const command = `export ${envKey.toUpperCase().split("-").join("_")}="${jjConfigs.processEnvs[envKey]}"`;
shEnvs += `${command}\n` shEnvs += `${command}\n`;
console.log(command) console.log(command);
}) });
fs.writeFileSync(`${jjConfigs.JJ_TMP_DIR}/shEnvs.sh`, shEnvs, 'utf-8'); fs.writeFileSync(`${jjConfigs.JJ_TMP_DIR}/shEnvs.sh`, shEnvs, "utf-8");
} }
return jjConfigs;
};
return jjConfigs if (_.get(process.argv, "[1]", "")?.includes("helpers/jjEnsure.ts")) {
if (_.get(process.argv, "[2]", "") == "returnProcessEnvs") {
const jj = await jjEnsure({ returnProcessEnvs: true });
} process.exit(0);
if (
_.get(process.argv, "[1]", "")?.includes('helpers/jjEnsure.ts')
) {
if (_.get(process.argv, "[2]", "") == 'returnProcessEnvs') {
const jj = await jjEnsure({ returnProcessEnvs: true })
process.exit(0)
} }
if (_.get(process.argv, "[2]", "") == 'init') { if (_.get(process.argv, "[2]", "") == "init") {
const jj = await jjEnsure({ returnProcessEnvs: false }) const jj = await jjEnsure({ returnProcessEnvs: false });
process.exit(0) process.exit(0);
} }
process.exit(0) process.exit(0);
} }
+2
View File
@@ -117,6 +117,8 @@ if [[ -e $JJ_WORKSPACE_DIR ]]; then
pushd "${JJ_GIT_METADATA_DIR}/" > /dev/null pushd "${JJ_GIT_METADATA_DIR}/" > /dev/null
git pull origin > /dev/null & git pull origin > /dev/null &
popd > /dev/null popd > /dev/null
mkdir -p $JJ_WORKSPACE_DIR/~~tmp
fi fi
+58 -60
View File
@@ -1,62 +1,60 @@
{ {
"name": "jj-command-line", "name": "jj-command-line",
"description": "jj cli", "description": "jj cli",
"version": "1.0.8", "version": "1.0.11",
"author": "Jason Jafari", "author": "Jason Jafari",
"bin": { "bin": {
"jj": "./jj.sh" "jj": "./jj.sh"
}, },
"bugs": "https://github.com/https://github.com/jafarijason/jj/jj/issues", "bugs": "https://github.com/https://github.com/jafarijason/jj/jj/issues",
"dependencies": { "dependencies": {
"chalk": "^5.3.0", "chalk": "^5.3.0",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"flatted": "^3.3.1", "flatted": "^3.3.1",
"folder-hash": "^4.0.4", "folder-hash": "^4.0.4",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"inquirer": "^12.0.1", "inquirer": "^12.0.1",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"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",
"shelljs": "^0.8.5", "shelljs": "^0.8.5",
"winston": "^3.16.0", "winston": "^3.16.0",
"yargs": "^17.7.2" "yargs": "^17.7.2"
}, },
"devDependencies": { "devDependencies": {
"@types/chai": "^4", "@types/chai": "^4",
"@types/mocha": "^10", "@types/mocha": "^10",
"@types/node": "^18", "@types/node": "^18",
"chai": "^4", "chai": "^4",
"eslint": "^8", "eslint": "^8",
"eslint-config-oclif": "^5", "eslint-config-oclif": "^5",
"eslint-config-oclif-typescript": "^3", "eslint-config-oclif-typescript": "^3",
"eslint-config-prettier": "^9", "eslint-config-prettier": "^9",
"mocha": "^10", "mocha": "^10",
"oclif": "^4", "oclif": "^4",
"shx": "^0.3.3", "shx": "^0.3.3",
"ts-node": "^10", "ts-node": "^10",
"typescript": "^5.6.3" "typescript": "^5.6.3"
}, },
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"
}, },
"homepage": "https://github.com/https://github.com/jafarijason/jj/jj", "homepage": "https://github.com/https://github.com/jafarijason/jj/jj",
"keywords": [ "keywords": ["oclif"],
"oclif" "license": "MIT",
], "main": "src/index.ts",
"license": "MIT", "type": "commonjs",
"main": "src/index.ts", "repository": "https://github.com/jafarijason/jj/jj",
"type": "commonjs", "scripts": {
"repository": "https://github.com/jafarijason/jj/jj", "build": " ",
"scripts": { "lint": "eslint . --ext .ts",
"build": " ", "test": "mocha --forbid-only \"test/**/*.test.ts\"",
"lint": "eslint . --ext .ts", "pre-publish": "git add . && git push --follow-tags"
"test": "mocha --forbid-only \"test/**/*.test.ts\"", },
"pre-publish": "git add . && git push --follow-tags" "alias": {
}, "@jjHelpers/*": "./helpers/$1",
"alias": { "@jjSrc/*": "./src/$1"
"@jjHelpers/*": "./helpers/$1", }
"@jjSrc/*": "./src/$1"
}
} }