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