Browse Source

refactor: corrections

pull/9499/head
Pranav C 2 months ago
parent
commit
fc3a4087ec
  1. 18
      packages/nc-secret-cli/src/core/NcConfig.ts
  2. 21
      packages/nc-secret-cli/src/index.ts
  3. 2
      packages/nocodb/src/cli.ts

18
packages/nc-secret-cli/src/core/NcConfig.ts

@ -79,14 +79,18 @@ export class NcConfig {
} }
} }
export const getNocoConfig = () =>{ export const getNocoConfig = (options: {
ncDb?: string;
ncDbJson?: string;
ncDbJsonFile?: string;
databaseUrl?: string;
databaseUrlFile?: string;
} ={}) =>{
return NcConfig.create({ return NcConfig.create({
meta: { meta: {
metaUrl: process.env.NC_DB, metaUrl: process.env.NC_DB || options.ncDb,
metaJson: process.env.NC_DB_JSON, metaJson: process.env.NC_DB_JSON || options.ncDbJson,
metaJsonFile: process.env.NC_DB_JSON_FILE, metaJsonFile: process.env.NC_DB_JSON_FILE || options.ncDbJsonFile,
}, }
secret: process.env.NC_AUTH_JWT_SECRET,
credentialSecret: process.env.NC_KEY_CREDENTIAL_ENCRYPT,
}); });
} }

21
packages/nc-secret-cli/src/index.ts

@ -13,18 +13,19 @@ program
.version('1.0.0') .version('1.0.0')
.description('NocoDB Secret CLI') .description('NocoDB Secret CLI')
.arguments('<oldSecret> <newSecret>') .arguments('<oldSecret> <newSecret>')
.option('--nc-db <nc-db>', 'NocoDB connection database url, equivalent to NC_DB env variable') .option('--nc-db <char>', 'NocoDB connection database url, equivalent to NC_DB env variable')
.option('--nc-db-json <nc-db-json>', 'NocoDB connection database json, equivalent to NC_DB_JSON env variable') .option('--nc-db-json <char>', 'NocoDB connection database json, equivalent to NC_DB_JSON env variable')
.option('--nc-db-json-file <nc-db-json-file>', 'NocoDB connection database json file path, equivalent to NC_DB_JSON_FILE env variable') .option('--nc-db-json-file <char>', 'NocoDB connection database json file path, equivalent to NC_DB_JSON_FILE env variable')
.option('--database-url <database-url>', 'JDBC database url, equivalent to DATABASE_URL env variable') .option('--database-url <char>', 'JDBC database url, equivalent to DATABASE_URL env variable')
.option('--database-url-file <database-url-file>', 'JDBC database url file path, equivalent to DATABASE_URL_FILE env variable') .option('--database-url-file <char>', 'JDBC database url file path, equivalent to DATABASE_URL_FILE env variable')
.option('-o, --old-secret <old-secret>', 'old secret string to decrypt sources and integrations') .option('-o, --old-secret <char>', 'old secret string to decrypt sources and integrations')
.option('-n, --new-secret <new-secret>', 'new secret string to encrypt sources and integrations') .option('-n, --new-secret <char>', 'new secret string to encrypt sources and integrations')
.action(async (key, value, ...rest) => { .action(async (key, value) => {
try { try {
// extract options
const config = await getNocoConfig(); const options = program.opts();
const config = await getNocoConfig(options);
if (!key || !value) { if (!key || !value) {
console.error('Error: Both key and value are required.'); console.error('Error: Both key and value are required.');

2
packages/nocodb/src/cli.ts

@ -1,5 +1,5 @@
export { SqlClientFactory } from '~/db/sql-client/lib/SqlClientFactory'; export { SqlClientFactory } from '~/db/sql-client/lib/SqlClientFactory';
export { MetaTable } from '~/utils/globals'; export { MetaTable } from '~/utils/globals';
export * from '~/utils/encryptDecrypt'; export * from '~/utils/encryptDecrypt';
export { getToolDir, metaUrlToDbConfig } from '~/utils/nc-config/helpers'; export { getToolDir, metaUrlToDbConfig, prepareEnv } from '~/utils/nc-config/helpers';
export { DriverClient } from '~/utils/nc-config/constants'; export { DriverClient } from '~/utils/nc-config/constants';

Loading…
Cancel
Save