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`)
|
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') {
|
||||||
|
|
||||||
|
|||||||
+160
-177
@@ -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,
|
indent: 4,
|
||||||
lineWidth: 3,
|
lineWidth: 3,
|
||||||
forceQuotes: true,
|
forceQuotes: true,
|
||||||
// sortKeys: 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": {
|
},
|
||||||
"desc": "Secrets",
|
secrets: {
|
||||||
"mainTitle": "Secrets",
|
desc: "Secrets",
|
||||||
"postCommand": "",
|
mainTitle: "Secrets",
|
||||||
"maxLength": 12,
|
postCommand: "",
|
||||||
"keys": [
|
maxLength: 12,
|
||||||
|
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, "[2]", "") == "init") {
|
||||||
if (
|
const jj = await jjEnsure({ returnProcessEnvs: false });
|
||||||
_.get(process.argv, "[1]", "")?.includes('helpers/jjEnsure.ts')
|
process.exit(0);
|
||||||
) {
|
|
||||||
if (_.get(process.argv, "[2]", "") == 'returnProcessEnvs') {
|
|
||||||
const jj = await jjEnsure({ returnProcessEnvs: true })
|
|
||||||
process.exit(0)
|
|
||||||
}
|
}
|
||||||
if (_.get(process.argv, "[2]", "") == 'init') {
|
process.exit(0);
|
||||||
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
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"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"
|
||||||
@@ -42,9 +42,7 @@
|
|||||||
"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",
|
"license": "MIT",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
|
|||||||
Reference in New Issue
Block a user