@dotenvx/dotenvx 2.38.1 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +186 -3315
- package/bin/dotenvx.cjs +34 -0
- package/config.cjs +1 -0
- package/config.d.ts +1 -0
- package/config.mjs +2 -0
- package/index.cjs +139 -0
- package/index.d.ts +66 -0
- package/index.mjs +3 -0
- package/lib/cli.cjs +43 -0
- package/lib/native-package.cjs +21 -0
- package/lib/platforms.cjs +18 -0
- package/{src/lib/helpers/redactOutput.js → lib/redactOutput.cjs} +2 -48
- package/lib/redaction.cjs +64 -0
- package/lib/validateOptions.cjs +57 -0
- package/native.cjs +23 -0
- package/package.json +57 -65
- package/CHANGELOG.md +0 -2727
- package/src/cli/actions/armor/down.js +0 -38
- package/src/cli/actions/armor/invite.js +0 -21
- package/src/cli/actions/armor/move.js +0 -43
- package/src/cli/actions/armor/open.js +0 -28
- package/src/cli/actions/armor/pull.js +0 -38
- package/src/cli/actions/armor/push.js +0 -38
- package/src/cli/actions/armor/status.js +0 -7
- package/src/cli/actions/armor/up.js +0 -38
- package/src/cli/actions/check.js +0 -78
- package/src/cli/actions/curl.js +0 -71
- package/src/cli/actions/decrypt.js +0 -119
- package/src/cli/actions/del.js +0 -54
- package/src/cli/actions/doctor.js +0 -22
- package/src/cli/actions/encrypt.js +0 -104
- package/src/cli/actions/ext/genexample.js +0 -36
- package/src/cli/actions/ext/gitignore.js +0 -106
- package/src/cli/actions/ext/prebuild.js +0 -7
- package/src/cli/actions/ext/precommit.js +0 -38
- package/src/cli/actions/ext/scan.js +0 -33
- package/src/cli/actions/feedback.js +0 -42
- package/src/cli/actions/get.js +0 -128
- package/src/cli/actions/init.js +0 -67
- package/src/cli/actions/keychain/down.js +0 -30
- package/src/cli/actions/keychain/pull.js +0 -30
- package/src/cli/actions/keychain/push.js +0 -30
- package/src/cli/actions/keychain/up.js +0 -30
- package/src/cli/actions/keypair.js +0 -84
- package/src/cli/actions/login.js +0 -64
- package/src/cli/actions/logout.js +0 -37
- package/src/cli/actions/ls.js +0 -76
- package/src/cli/actions/policy.js +0 -14
- package/src/cli/actions/primitivesCheck.js +0 -32
- package/src/cli/actions/primitivesProfile.js +0 -15
- package/src/cli/actions/primitivesRedact.js +0 -19
- package/src/cli/actions/protect.js +0 -75
- package/src/cli/actions/protectDocker.js +0 -30
- package/src/cli/actions/protectProcess.js +0 -126
- package/src/cli/actions/protectStdin.js +0 -80
- package/src/cli/actions/run.js +0 -203
- package/src/cli/actions/set.js +0 -103
- package/src/cli/actions/settings/device.js +0 -23
- package/src/cli/actions/settings/hostname.js +0 -20
- package/src/cli/actions/settings/off.js +0 -14
- package/src/cli/actions/settings/on.js +0 -14
- package/src/cli/actions/settings/path.js +0 -20
- package/src/cli/actions/settings/token.js +0 -23
- package/src/cli/actions/settings/username.js +0 -20
- package/src/cli/actions/update.js +0 -15
- package/src/cli/commandAction.js +0 -16
- package/src/cli/commands/armor.js +0 -129
- package/src/cli/commands/custody.js +0 -45
- package/src/cli/commands/ext.js +0 -88
- package/src/cli/commands/fileOptions.js +0 -22
- package/src/cli/commands/native.js +0 -54
- package/src/cli/commands/primitives.js +0 -73
- package/src/cli/commands/settings.js +0 -63
- package/src/cli/dotenvx.js +0 -443
- package/src/cli/help.js +0 -179
- package/src/db/device.js +0 -67
- package/src/db/session.js +0 -330
- package/src/lib/api/getAccount.js +0 -32
- package/src/lib/api/getConnectionResources.js +0 -21
- package/src/lib/api/getTeamConnections.js +0 -27
- package/src/lib/api/getTeamServices.js +0 -23
- package/src/lib/api/getTeams.js +0 -28
- package/src/lib/api/postArmorDown.js +0 -48
- package/src/lib/api/postArmorMove.js +0 -48
- package/src/lib/api/postArmorPull.js +0 -48
- package/src/lib/api/postArmorPush.js +0 -48
- package/src/lib/api/postArmorUp.js +0 -53
- package/src/lib/api/postConnectionKeypair.js +0 -23
- package/src/lib/api/postFeedback.js +0 -31
- package/src/lib/api/postLogout.js +0 -34
- package/src/lib/api/postOauthDeviceCode.js +0 -38
- package/src/lib/api/postOauthToken.js +0 -35
- package/src/lib/api/postTeamInvitation.js +0 -28
- package/src/lib/api/teamConnectionSetup.js +0 -31
- package/src/lib/config.d.ts +0 -1
- package/src/lib/config.js +0 -1
- package/src/lib/conventions/environment.js +0 -27
- package/src/lib/conventions/filepaths.js +0 -9
- package/src/lib/conventions/keynames.js +0 -38
- package/src/lib/custodians/index.js +0 -75
- package/src/lib/custodians/local/bitwarden.js +0 -165
- package/src/lib/custodians/local/file.js +0 -18
- package/src/lib/custodians/local/native/backend.js +0 -56
- package/src/lib/custodians/local/native/index.js +0 -28
- package/src/lib/custodians/local/native/store.js +0 -24
- package/src/lib/custodians/local/onepassword.js +0 -149
- package/src/lib/custodians/managed/armor/index.js +0 -14
- package/src/lib/custodians/managed/armor/store.js +0 -48
- package/src/lib/custodians/resolveLocalKey.js +0 -67
- package/src/lib/decryptors/armor/index.js +0 -23
- package/src/lib/decryptors/decryptor-worker.js +0 -6
- package/src/lib/decryptors/index.js +0 -69
- package/src/lib/envfile/discovery/discoverEnvFiles.js +0 -29
- package/src/lib/envfile/discovery/extractEnvKeys.js +0 -173
- package/src/lib/envfile/discovery/scanSource.js +0 -79
- package/src/lib/envfile/parsing/formatEnvfileSyntaxError.js +0 -24
- package/src/lib/envfile/parsing/readEnvfile.js +0 -43
- package/src/lib/envfile/parsing/resolveEnvfilePath.js +0 -5
- package/src/lib/envfile/rendering/normalizeEnvfile.js +0 -53
- package/src/lib/envfile/rendering/previewEnvfile.js +0 -43
- package/src/lib/envfile/rendering/renderEnvfile.js +0 -30
- package/src/lib/envfile/validation/diagnosticLocation.js +0 -29
- package/src/lib/envfile/validation/protectEnvfile.js +0 -40
- package/src/lib/envfile/validation/validateEnvfile.js +0 -14
- package/src/lib/events/backends/armor.js +0 -31
- package/src/lib/events/background.js +0 -59
- package/src/lib/events/catalog.js +0 -14
- package/src/lib/events/cli.js +0 -40
- package/src/lib/events/delivery.js +0 -89
- package/src/lib/events/index.js +0 -73
- package/src/lib/events/metadata.js +0 -25
- package/src/lib/events/sdk.js +0 -44
- package/src/lib/events/worker.js +0 -29
- package/src/lib/events/workerEnvironment.js +0 -14
- package/src/lib/helpers/armoredKeyDisplay.js +0 -10
- package/src/lib/helpers/arrayToTree.js +0 -27
- package/src/lib/helpers/buildApiError.js +0 -19
- package/src/lib/helpers/buildCommandEnvs.js +0 -40
- package/src/lib/helpers/buildConfigEnvs.js +0 -13
- package/src/lib/helpers/buildEnvs.js +0 -24
- package/src/lib/helpers/buildOauthError.js +0 -14
- package/src/lib/helpers/canonicalEnvFilename.js +0 -13
- package/src/lib/helpers/catchAndLog.js +0 -16
- package/src/lib/helpers/checklist.js +0 -50
- package/src/lib/helpers/chomp.js +0 -5
- package/src/lib/helpers/colorDepth.js +0 -23
- package/src/lib/helpers/conventions.js +0 -28
- package/src/lib/helpers/createElapsedStatus.js +0 -17
- package/src/lib/helpers/createProtectSpinner.js +0 -13
- package/src/lib/helpers/createSpinner.js +0 -40
- package/src/lib/helpers/cryptography/decryptKeyValue.js +0 -50
- package/src/lib/helpers/cryptography/index.js +0 -7
- package/src/lib/helpers/cryptography/isDotenvPublicKey.js +0 -7
- package/src/lib/helpers/cryptography/isPlainKey.js +0 -7
- package/src/lib/helpers/cryptography/mutateKeysSrc.js +0 -22
- package/src/lib/helpers/cryptography/mutateSrc.js +0 -24
- package/src/lib/helpers/custodySelect.js +0 -25
- package/src/lib/helpers/decryptDeviceValue.js +0 -7
- package/src/lib/helpers/detectEncoding.js +0 -22
- package/src/lib/helpers/detectEncodingSync.js +0 -22
- package/src/lib/helpers/dotenvOptionPaths.js +0 -25
- package/src/lib/helpers/dotenvPrivateKeyNames.js +0 -7
- package/src/lib/helpers/enclavedHint.js +0 -11
- package/src/lib/helpers/encryptDeviceValue.js +0 -7
- package/src/lib/helpers/envResolution/determine.js +0 -49
- package/src/lib/helpers/envResolution/index.js +0 -8
- package/src/lib/helpers/errors.js +0 -374
- package/src/lib/helpers/escape.js +0 -6
- package/src/lib/helpers/execute.js +0 -12
- package/src/lib/helpers/executeCommand.js +0 -208
- package/src/lib/helpers/executeDynamic.js +0 -86
- package/src/lib/helpers/executeExtension.js +0 -39
- package/src/lib/helpers/filterKeys.js +0 -15
- package/src/lib/helpers/findEnvFiles.js +0 -25
- package/src/lib/helpers/formatCode.js +0 -11
- package/src/lib/helpers/fsx.js +0 -110
- package/src/lib/helpers/guessPrivateKeyFilename.js +0 -15
- package/src/lib/helpers/hasPlaintextSecrets.js +0 -7
- package/src/lib/helpers/http.js +0 -14
- package/src/lib/helpers/installPrecommitHook.js +0 -82
- package/src/lib/helpers/installProtectFilter.js +0 -57
- package/src/lib/helpers/installProtectIgnore.js +0 -27
- package/src/lib/helpers/isPublicKey.js +0 -3
- package/src/lib/helpers/isTeamRequiredError.js +0 -10
- package/src/lib/helpers/jsonToEnv.js +0 -7
- package/src/lib/helpers/keypairMetadata.js +0 -90
- package/src/lib/helpers/kits/sample.js +0 -5
- package/src/lib/helpers/linuxSecretService.js +0 -52
- package/src/lib/helpers/listenForOpenKey.js +0 -46
- package/src/lib/helpers/logProtectedFiles.js +0 -9
- package/src/lib/helpers/logSetSummary.js +0 -21
- package/src/lib/helpers/macosKeychain.js +0 -52
- package/src/lib/helpers/mask.js +0 -22
- package/src/lib/helpers/maskEnvSrc.js +0 -15
- package/src/lib/helpers/maskProcessedEnvs.js +0 -29
- package/src/lib/helpers/matchesStoredKey.js +0 -5
- package/src/lib/helpers/nativeStoreError.js +0 -10
- package/src/lib/helpers/normalizeDotenvConfigConvention.js +0 -13
- package/src/lib/helpers/normalizeDotenvConfigIgnore.js +0 -18
- package/src/lib/helpers/normalizeDotenvConfigPath.js +0 -14
- package/src/lib/helpers/normalizeDotenvConfigQuiet.js +0 -13
- package/src/lib/helpers/normalizeToken.js +0 -5
- package/src/lib/helpers/openUrl.js +0 -7
- package/src/lib/helpers/packageJson.js +0 -3
- package/src/lib/helpers/parseWithDecryptor.js +0 -115
- package/src/lib/helpers/plaintextKeys.js +0 -9
- package/src/lib/helpers/precommitEnvPatterns.js +0 -1
- package/src/lib/helpers/prependPublicKey.js +0 -17
- package/src/lib/helpers/preserveShebang.js +0 -16
- package/src/lib/helpers/prompts.js +0 -169
- package/src/lib/helpers/protectSettings.js +0 -64
- package/src/lib/helpers/ptyCommand.js +0 -27
- package/src/lib/helpers/readEnvKey.js +0 -32
- package/src/lib/helpers/redact.js +0 -9
- package/src/lib/helpers/redactProcessOutput.js +0 -58
- package/src/lib/helpers/redactedValues.js +0 -29
- package/src/lib/helpers/removeDynamicHelpSection.js +0 -21
- package/src/lib/helpers/removeEnvKey.js +0 -51
- package/src/lib/helpers/removeLegacyProtectFilter.js +0 -43
- package/src/lib/helpers/removeOptionsHelpParts.js +0 -59
- package/src/lib/helpers/resolveBitwardenPassword.js +0 -165
- package/src/lib/helpers/resolveDirectoryFilepath.js +0 -16
- package/src/lib/helpers/resolveEnvKeysFile.js +0 -11
- package/src/lib/helpers/resolveHome.js +0 -12
- package/src/lib/helpers/resolveOnePassword.js +0 -82
- package/src/lib/helpers/sanitizeCommandForMetadata.js +0 -64
- package/src/lib/helpers/selectConnection.js +0 -51
- package/src/lib/helpers/selectConnectionResource.js +0 -41
- package/src/lib/helpers/selectEnvfileEnvs.js +0 -29
- package/src/lib/helpers/selectKeyStorage.js +0 -140
- package/src/lib/helpers/statusReporter.js +0 -8
- package/src/lib/helpers/storeKeyStorage.js +0 -39
- package/src/lib/helpers/teamChoicesFromMeta.js +0 -8
- package/src/lib/helpers/truncate.js +0 -10
- package/src/lib/helpers/uninstallPrecommitHook.js +0 -67
- package/src/lib/helpers/upsertEnvKey.js +0 -62
- package/src/lib/helpers/windowsCredentialManager.js +0 -166
- package/src/lib/main.d.ts +0 -509
- package/src/lib/main.js +0 -468
- package/src/lib/providers/index.js +0 -86
- package/src/lib/providers/native/index.js +0 -2
- package/src/lib/resolvers/envs.js +0 -416
- package/src/lib/resolvers/get.js +0 -87
- package/src/lib/resolvers/keypair.js +0 -135
- package/src/lib/resolvers/ls.js +0 -69
- package/src/lib/services/armorDown.js +0 -73
- package/src/lib/services/armorInvite.js +0 -36
- package/src/lib/services/armorMove.js +0 -55
- package/src/lib/services/armorOpen.js +0 -26
- package/src/lib/services/armorPull.js +0 -73
- package/src/lib/services/armorPush.js +0 -66
- package/src/lib/services/armorUp.js +0 -71
- package/src/lib/services/custodyTransfer.js +0 -50
- package/src/lib/services/doctor.js +0 -93
- package/src/lib/services/genexample.js +0 -112
- package/src/lib/services/init.js +0 -83
- package/src/lib/services/keychainDown.js +0 -60
- package/src/lib/services/keychainPull.js +0 -46
- package/src/lib/services/keychainPush.js +0 -51
- package/src/lib/services/keychainUp.js +0 -72
- package/src/lib/services/login.js +0 -51
- package/src/lib/services/logout.js +0 -26
- package/src/lib/services/prebuild.js +0 -91
- package/src/lib/services/precommit.js +0 -144
- package/src/lib/services/validate.js +0 -57
- package/src/lib/transforms/decrypt.js +0 -98
- package/src/lib/transforms/del.js +0 -58
- package/src/lib/transforms/encrypt.js +0 -164
- package/src/lib/transforms/set.js +0 -144
- package/src/shared/colors.js +0 -67
- package/src/shared/logger.js +0 -148
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
const fsx = require('./../../lib/helpers/fsx')
|
|
2
|
-
const { logger } = require('./../../shared/logger')
|
|
3
|
-
|
|
4
|
-
const encryptTransform = require('./../../lib/transforms/encrypt')
|
|
5
|
-
|
|
6
|
-
const catchAndLog = require('../../lib/helpers/catchAndLog')
|
|
7
|
-
const createSpinner = require('../../lib/helpers/createSpinner')
|
|
8
|
-
const statusReporter = require('../../lib/helpers/statusReporter')
|
|
9
|
-
const keypair = require('../../lib/resolvers/keypair')
|
|
10
|
-
const { publickeys, injectsummary } = require('@dotenvx/primitives')
|
|
11
|
-
|
|
12
|
-
async function encryptAction () {
|
|
13
|
-
const options = this.opts()
|
|
14
|
-
const spinnerOptions = typeof this.optsWithGlobals === 'function' ? this.optsWithGlobals() : options
|
|
15
|
-
const spinner = await createSpinner({ ...spinnerOptions, ...options, text: 'encrypting' })
|
|
16
|
-
|
|
17
|
-
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
18
|
-
|
|
19
|
-
const envs = this.envs || []
|
|
20
|
-
const ik = options.key
|
|
21
|
-
const ek = options.excludeKey
|
|
22
|
-
const fk = options.envKeysFile || '.env.keys'
|
|
23
|
-
const noCreate = options.create === false
|
|
24
|
-
const noArmor = options.armor === false
|
|
25
|
-
const noNative = options.native === false || options.noNative === true
|
|
26
|
-
|
|
27
|
-
const noBitwarden = options.bitwarden === false || options.noBitwarden === true
|
|
28
|
-
const no1Password = options['1password'] === false || options.no1Password === true
|
|
29
|
-
|
|
30
|
-
let errorCount = 0
|
|
31
|
-
|
|
32
|
-
// stdout - should not have a try so that exit codes can surface to stdout
|
|
33
|
-
if (options.stdout) {
|
|
34
|
-
const { processedEnvs } = await encryptTransform({ with: options.with, profile: options.profile, envs, ik, ek, fk, noArmor, token: options.token, noCreate, noNative, no1Password, noBitwarden })
|
|
35
|
-
|
|
36
|
-
if (spinner) spinner.stop()
|
|
37
|
-
for (const processedEnv of processedEnvs) {
|
|
38
|
-
if (processedEnv.error) {
|
|
39
|
-
errorCount += 1
|
|
40
|
-
logger.error(processedEnv.error.messageWithHelp || processedEnv.error.message)
|
|
41
|
-
}
|
|
42
|
-
if (!processedEnv.error && processedEnv.envSrc) {
|
|
43
|
-
console.log(processedEnv.envSrc)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
const { keysSrc, processedEnvs, changedFilepaths, unchangedFilepaths } = await encryptTransform({ with: options.with, profile: options.profile, envs, ik, ek, fk, noArmor, token: options.token, noCreate, noNative, no1Password, noBitwarden })
|
|
52
|
-
|
|
53
|
-
if (keysSrc && options.with === undefined) {
|
|
54
|
-
await fsx.writeKeyFile(fk, keysSrc)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (spinner) spinner.stop()
|
|
58
|
-
for (const processedEnv of processedEnvs) {
|
|
59
|
-
logger.verbose(`encrypting ${processedEnv.envFilepath} (${processedEnv.filepath})`)
|
|
60
|
-
if (processedEnv.error) {
|
|
61
|
-
errorCount += 1
|
|
62
|
-
logger.error(processedEnv.error.messageWithHelp || processedEnv.error.message)
|
|
63
|
-
} else if (processedEnv.changed) {
|
|
64
|
-
await fsx.writeFileX(processedEnv.filepath, processedEnv.envSrc)
|
|
65
|
-
logger.verbose(`encrypted ${processedEnv.envFilepath} (${processedEnv.filepath})`)
|
|
66
|
-
} else {
|
|
67
|
-
logger.verbose(`no change ${processedEnv.envFilepath} (${processedEnv.filepath})`)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Existing public keys can encrypt without private-key access. Metadata
|
|
72
|
-
// lookup must never turn successful encryption into a failure.
|
|
73
|
-
for (const row of processedEnvs) {
|
|
74
|
-
if (options.with !== undefined || options.quiet || row.error || row.keySources || !publickeys(row.envSrc || '').length) continue
|
|
75
|
-
try {
|
|
76
|
-
const resolved = await keypair({ ...options, envFile: [row.filepath], envKeysFile: fk, noArmor, noNative, no1Password, noBitwarden, includeProvider: true, onStatus: statusReporter(null) })
|
|
77
|
-
row.keySources = { [publickeys(row.envSrc)[0]]: resolved.provider }
|
|
78
|
-
} catch {}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const summaryRows = new Map(processedEnvs.map(row => [row.envFilepath, {
|
|
82
|
-
filepath: row.envFilepath,
|
|
83
|
-
publicKeys: publickeys(row.envSrc || ''),
|
|
84
|
-
keySources: row.keySources
|
|
85
|
-
}]))
|
|
86
|
-
if (changedFilepaths.length > 0) {
|
|
87
|
-
const summary = injectsummary.sources(changedFilepaths.map(filepath => summaryRows.get(filepath) || filepath))
|
|
88
|
-
logger.success(`◈ encrypted ${summary.files.join(',')}${summary.suffix}`)
|
|
89
|
-
} else if (unchangedFilepaths.length > 0) {
|
|
90
|
-
const summary = injectsummary.sources(unchangedFilepaths.map(filepath => summaryRows.get(filepath) || filepath))
|
|
91
|
-
logger.info(`○ no change to ${summary.files.join(',')}${summary.suffix}`)
|
|
92
|
-
} else {
|
|
93
|
-
// do nothing - scenario when no .env files found
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
|
|
97
|
-
} catch (error) {
|
|
98
|
-
if (spinner) spinner.stop()
|
|
99
|
-
catchAndLog(error)
|
|
100
|
-
return { exitCode: 1, error }
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
module.exports = require('../../lib/events/cli')('encrypt', encryptAction)
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const fsx = require('./../../../lib/helpers/fsx')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const Genexample = require('./../../../lib/services/genexample')
|
|
4
|
-
const { logger } = require('./../../../shared/logger')
|
|
5
|
-
const catchAndLog = require('./../../../lib/helpers/catchAndLog')
|
|
6
|
-
|
|
7
|
-
function genexample (directory) {
|
|
8
|
-
logger.debug(`directory: ${directory}`)
|
|
9
|
-
|
|
10
|
-
const options = this.opts()
|
|
11
|
-
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const {
|
|
15
|
-
envExampleFile,
|
|
16
|
-
envFile,
|
|
17
|
-
exampleFilepath,
|
|
18
|
-
addedKeys
|
|
19
|
-
} = new Genexample(directory, options.envFile).run()
|
|
20
|
-
|
|
21
|
-
logger.verbose(`loading env from ${envFile}`)
|
|
22
|
-
|
|
23
|
-
fsx.writeFileXSync(exampleFilepath, envExampleFile)
|
|
24
|
-
|
|
25
|
-
if (addedKeys.length > 0) {
|
|
26
|
-
logger.success(`▣ generated (${path.basename(exampleFilepath)})`)
|
|
27
|
-
} else {
|
|
28
|
-
logger.info('○ no change (.env.example)')
|
|
29
|
-
}
|
|
30
|
-
} catch (error) {
|
|
31
|
-
catchAndLog(error)
|
|
32
|
-
return { exitCode: 1, error }
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
module.exports = genexample
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
const fsx = require('./../../../lib/helpers/fsx')
|
|
2
|
-
|
|
3
|
-
const DEFAULT_PATTERNS = ['.env*']
|
|
4
|
-
const { logger } = require('./../../../shared/logger')
|
|
5
|
-
|
|
6
|
-
class Generic {
|
|
7
|
-
constructor (filename, patterns = DEFAULT_PATTERNS, touchFile = false) {
|
|
8
|
-
this.filename = filename
|
|
9
|
-
this.patterns = patterns
|
|
10
|
-
this.touchFile = touchFile
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
append (str) {
|
|
14
|
-
fsx.appendFileSync(this.filename, `\n${str}`)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
run () {
|
|
18
|
-
const changedPatterns = []
|
|
19
|
-
if (!fsx.existsSync(this.filename)) {
|
|
20
|
-
if (this.touchFile === true && this.patterns.length > 0) {
|
|
21
|
-
fsx.writeFileXSync(this.filename, '')
|
|
22
|
-
} else {
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const lines = fsx.readFileXSync(this.filename).split(/\r?\n/)
|
|
28
|
-
this.patterns.forEach(pattern => {
|
|
29
|
-
if (!lines.includes(pattern.trim())) {
|
|
30
|
-
this.append(pattern)
|
|
31
|
-
|
|
32
|
-
changedPatterns.push(pattern.trim())
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
if (changedPatterns.length > 0) {
|
|
37
|
-
logger.success(`▣ ignored ${this.patterns} (${this.filename})`)
|
|
38
|
-
} else {
|
|
39
|
-
logger.info(`○ no change (${this.filename})`)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
class Git {
|
|
45
|
-
constructor (patterns = DEFAULT_PATTERNS) {
|
|
46
|
-
this.patterns = patterns
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
run () {
|
|
50
|
-
logger.verbose('add to .gitignore')
|
|
51
|
-
new Generic('.gitignore', this.patterns, true).run()
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
class Docker {
|
|
56
|
-
constructor (patterns = DEFAULT_PATTERNS) {
|
|
57
|
-
this.patterns = patterns
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
run () {
|
|
61
|
-
logger.verbose('add to .dockerignore (if exists)')
|
|
62
|
-
new Generic('.dockerignore', this.patterns).run()
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
class Npm {
|
|
67
|
-
constructor (patterns = DEFAULT_PATTERNS) {
|
|
68
|
-
this.patterns = patterns
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
run () {
|
|
72
|
-
logger.verbose('add to .npmignore (if existing)')
|
|
73
|
-
new Generic('.npmignore', this.patterns).run()
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
class Vercel {
|
|
78
|
-
constructor (patterns = DEFAULT_PATTERNS) {
|
|
79
|
-
this.patterns = patterns
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
run () {
|
|
83
|
-
logger.verbose('add to .vercelignore (if existing)')
|
|
84
|
-
new Generic('.vercelignore', this.patterns).run()
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function gitignore () {
|
|
89
|
-
logger.warn('[DEPRECATED] dotenvx gitignore. fix: run [dotenvx protect]')
|
|
90
|
-
const options = this.opts()
|
|
91
|
-
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
92
|
-
|
|
93
|
-
const patterns = options.pattern
|
|
94
|
-
|
|
95
|
-
new Git(patterns).run()
|
|
96
|
-
new Docker(patterns).run()
|
|
97
|
-
new Npm(patterns).run()
|
|
98
|
-
new Vercel(patterns).run()
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
module.exports = gitignore
|
|
102
|
-
module.exports.Git = Git
|
|
103
|
-
module.exports.Docker = Docker
|
|
104
|
-
module.exports.Npm = Npm
|
|
105
|
-
module.exports.Vercel = Vercel
|
|
106
|
-
module.exports.Generic = Generic
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const { logger } = require('../../../shared/logger')
|
|
2
|
-
const protectDocker = require('../../../lib/events/cli')('protect', require('../protectDocker'))
|
|
3
|
-
|
|
4
|
-
module.exports = function prebuild (directory) {
|
|
5
|
-
logger.warn('[DEPRECATED] dotenvx prebuild. fix: run [dotenvx protect --docker]')
|
|
6
|
-
return protectDocker.call(this, directory)
|
|
7
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const { logger } = require('./../../../shared/logger')
|
|
2
|
-
|
|
3
|
-
const Precommit = require('./../../../lib/services/precommit')
|
|
4
|
-
const catchAndLog = require('./../../../lib/helpers/catchAndLog')
|
|
5
|
-
|
|
6
|
-
function precommit (directory) {
|
|
7
|
-
// debug args
|
|
8
|
-
logger.debug(`directory: ${directory}`)
|
|
9
|
-
|
|
10
|
-
const options = this.opts()
|
|
11
|
-
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
if (options.uninstall) {
|
|
15
|
-
if (options.install) throw new Error('--install and --uninstall cannot be used together')
|
|
16
|
-
const { removed, warning } = require('../../../lib/helpers/uninstallPrecommitHook')(directory)
|
|
17
|
-
if (warning) logger.warn(warning)
|
|
18
|
-
else logger.success(removed ? '▣ uninstalled (dotenvx precommit hook)' : '○ no dotenvx precommit hook found')
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
logger.warn('[DEPRECATED] dotenvx precommit. fix: run [dotenvx protect]')
|
|
22
|
-
const {
|
|
23
|
-
successMessage,
|
|
24
|
-
warnings
|
|
25
|
-
} = new Precommit(directory, options).run()
|
|
26
|
-
|
|
27
|
-
for (const warning of warnings) {
|
|
28
|
-
logger.warn(warning.messageWithHelp || warning.message)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
logger.success(successMessage)
|
|
32
|
-
} catch (error) {
|
|
33
|
-
catchAndLog(error)
|
|
34
|
-
process.exit(1)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = precommit
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const childProcess = require('child_process')
|
|
2
|
-
|
|
3
|
-
const { logger } = require('./../../../shared/logger')
|
|
4
|
-
const chomp = require('./../../../lib/helpers/chomp')
|
|
5
|
-
|
|
6
|
-
function scan () {
|
|
7
|
-
const options = this.opts()
|
|
8
|
-
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
// redirect stderr to stdout to capture and ignore it
|
|
12
|
-
childProcess.execSync('gitleaks version', { stdio: ['ignore', 'pipe', 'ignore'] })
|
|
13
|
-
} catch (error) {
|
|
14
|
-
logger.error('gitleaks: command not found')
|
|
15
|
-
logger.help('fix: install gitleaks: [brew install gitleaks]')
|
|
16
|
-
logger.help('fix: other install options: [https://github.com/gitleaks/gitleaks]')
|
|
17
|
-
return { exitCode: 1, error }
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let output = ''
|
|
21
|
-
try {
|
|
22
|
-
output = childProcess.execSync('gitleaks detect --no-banner --verbose 2>&1').toString() // gitleaks sends exit code 1 but puts data on stdout for failures, so we catch later and resurface the stdout
|
|
23
|
-
logger.info(chomp(output))
|
|
24
|
-
} catch (error) {
|
|
25
|
-
if (error.stdout) {
|
|
26
|
-
logger.error(chomp(error.stdout.toString()))
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return { exitCode: 1, error }
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
module.exports = scan
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const { logger } = require('../../shared/logger')
|
|
2
|
-
const Session = require('../../db/session')
|
|
3
|
-
const PostFeedback = require('../../lib/api/postFeedback')
|
|
4
|
-
const prompts = require('../../lib/helpers/prompts')
|
|
5
|
-
const createSpinner = require('../../lib/helpers/createSpinner')
|
|
6
|
-
|
|
7
|
-
async function feedback (body) {
|
|
8
|
-
let spinner
|
|
9
|
-
try {
|
|
10
|
-
if (body === undefined) {
|
|
11
|
-
if (!process.stdin.isTTY) {
|
|
12
|
-
throw new Error('provide a message: dotenvx feedback "Your feedback"')
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
body = await prompts.input({
|
|
16
|
-
message: 'Send feedback'
|
|
17
|
-
}, { input: process.stdin, output: process.stderr })
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (!body.trim()) {
|
|
21
|
-
throw new Error('feedback cannot be empty')
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const options = this.opts()
|
|
25
|
-
const spinnerOptions = typeof this.optsWithGlobals === 'function' ? this.optsWithGlobals() : options
|
|
26
|
-
const hostname = options.hostname || new Session().hostname()
|
|
27
|
-
spinner = await createSpinner({ ...spinnerOptions, ...options, text: 'sending' })
|
|
28
|
-
await new PostFeedback(hostname, body).run()
|
|
29
|
-
if (spinner) spinner.stop()
|
|
30
|
-
logger.success('✔ Feedback sent, thanks!')
|
|
31
|
-
} catch (error) {
|
|
32
|
-
if (spinner) spinner.stop()
|
|
33
|
-
if (error.code === 'PROMPT_CANCELLED') {
|
|
34
|
-
return { exitCode: 130, error }
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
logger.error(error.message || error)
|
|
38
|
-
return { exitCode: 1, error }
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
module.exports = feedback
|
package/src/cli/actions/get.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
const statusReporter = require('../../lib/helpers/statusReporter')
|
|
2
|
-
const { logger } = require('./../../shared/logger')
|
|
3
|
-
|
|
4
|
-
const escape = require('./../../lib/helpers/escape')
|
|
5
|
-
const catchAndLog = require('./../../lib/helpers/catchAndLog')
|
|
6
|
-
const createSpinner = require('../../lib/helpers/createSpinner')
|
|
7
|
-
const Session = require('../../db/session')
|
|
8
|
-
const getResolver = require('./../../lib/resolvers/get')
|
|
9
|
-
const normalizeDotenvConfigConvention = require('../../lib/helpers/normalizeDotenvConfigConvention')
|
|
10
|
-
const normalizeDotenvConfigIgnore = require('../../lib/helpers/normalizeDotenvConfigIgnore')
|
|
11
|
-
const resolveEnvKeysFile = require('../../lib/helpers/resolveEnvKeysFile')
|
|
12
|
-
const mask = require('../../lib/helpers/mask')
|
|
13
|
-
const filterKeys = require('../../lib/helpers/filterKeys')
|
|
14
|
-
|
|
15
|
-
async function get (key) {
|
|
16
|
-
const options = normalizeDotenvConfigIgnore(normalizeDotenvConfigConvention(this.opts()))
|
|
17
|
-
const spinnerOptions = typeof this.optsWithGlobals === 'function' ? this.optsWithGlobals() : options
|
|
18
|
-
const spinner = await createSpinner({ ...spinnerOptions, ...options, text: 'decrypting' })
|
|
19
|
-
|
|
20
|
-
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
21
|
-
if (key) {
|
|
22
|
-
logger.debug(`key: ${key}`)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const prettyPrint = options.prettyPrint || options.pp
|
|
26
|
-
const ignore = options.ignore || []
|
|
27
|
-
let errorCount = 0
|
|
28
|
-
|
|
29
|
-
const envs = this.envs
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const sesh = new Session()
|
|
33
|
-
const noArmor = options.armor === false || (await sesh.noArmor())
|
|
34
|
-
const noNative = options.native === false || options.noNative === true
|
|
35
|
-
const { parsed: resolved, errors } = await getResolver({
|
|
36
|
-
key,
|
|
37
|
-
envs,
|
|
38
|
-
profile: options.profile,
|
|
39
|
-
convention: options.convention,
|
|
40
|
-
overload: options.overload,
|
|
41
|
-
all: options.all,
|
|
42
|
-
envKeysFile: resolveEnvKeysFile(options.envKeysFile),
|
|
43
|
-
noArmor,
|
|
44
|
-
noNative,
|
|
45
|
-
no1Password: options['1password'] === false || options.no1Password === true,
|
|
46
|
-
noBitwarden: options.bitwarden === false || options.noBitwarden === true,
|
|
47
|
-
onStatus: statusReporter(spinner)
|
|
48
|
-
})
|
|
49
|
-
const parsed = filterKeys(resolved, options.includeKey, options.excludeKey)
|
|
50
|
-
|
|
51
|
-
for (const error of errors || []) {
|
|
52
|
-
if (options.strict) throw error // throw immediately if strict
|
|
53
|
-
|
|
54
|
-
if (ignore.includes(error.code)) {
|
|
55
|
-
continue // ignore error
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
errorCount += 1
|
|
59
|
-
logger.error(error.messageWithHelp || error.message)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (spinner) spinner.stop()
|
|
63
|
-
if (options.mask !== undefined) {
|
|
64
|
-
let showChar = options.mask
|
|
65
|
-
if (options.mask === true) {
|
|
66
|
-
showChar = 6
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
for (const key of Object.keys(parsed)) {
|
|
70
|
-
parsed[key] = mask(parsed[key], showChar)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (key) {
|
|
75
|
-
const single = parsed[key]
|
|
76
|
-
if (single === undefined) {
|
|
77
|
-
console.log('')
|
|
78
|
-
} else {
|
|
79
|
-
console.log(single)
|
|
80
|
-
}
|
|
81
|
-
} else {
|
|
82
|
-
if (options.format === 'eval' || options.format === 'eval-export') {
|
|
83
|
-
const prefix = options.format === 'eval-export' ? 'export ' : ''
|
|
84
|
-
let inline = ''
|
|
85
|
-
for (const [key, value] of Object.entries(parsed)) {
|
|
86
|
-
inline += `${prefix}${key}=${escape(value)}\n`
|
|
87
|
-
}
|
|
88
|
-
inline = inline.trim()
|
|
89
|
-
|
|
90
|
-
console.log(inline)
|
|
91
|
-
} else if (options.format === 'shell') {
|
|
92
|
-
let inline = ''
|
|
93
|
-
for (const [key, value] of Object.entries(parsed)) {
|
|
94
|
-
inline += `${key}=${value} `
|
|
95
|
-
}
|
|
96
|
-
inline = inline.trim()
|
|
97
|
-
|
|
98
|
-
console.log(inline)
|
|
99
|
-
} else if (options.format === 'colon') {
|
|
100
|
-
let inline = ''
|
|
101
|
-
for (const [key, value] of Object.entries(parsed)) {
|
|
102
|
-
inline += `${key}:${value} `
|
|
103
|
-
}
|
|
104
|
-
inline = inline.trim()
|
|
105
|
-
|
|
106
|
-
console.log(inline)
|
|
107
|
-
} else {
|
|
108
|
-
let space = 0
|
|
109
|
-
if (prettyPrint) {
|
|
110
|
-
space = 2
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
console.log(JSON.stringify(parsed, null, space))
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
|
|
118
|
-
} catch (error) {
|
|
119
|
-
if (spinner) spinner.stop()
|
|
120
|
-
if (error.code === 'PROMPT_CANCELLED') {
|
|
121
|
-
return { exitCode: 130, error }
|
|
122
|
-
}
|
|
123
|
-
catchAndLog(error)
|
|
124
|
-
return { exitCode: 1, error }
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
module.exports = require('../../lib/events/cli')('get', get)
|
package/src/cli/actions/init.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const fs = require('node:fs')
|
|
2
|
-
const process = require('node:process')
|
|
3
|
-
const prompts = require('../../lib/helpers/prompts')
|
|
4
|
-
const initEnvfile = require('../../lib/services/init')
|
|
5
|
-
const scanSource = require('../../lib/envfile/discovery/scanSource')
|
|
6
|
-
const discoverEnvFiles = require('../../lib/envfile/discovery/discoverEnvFiles')
|
|
7
|
-
const createSpinner = require('../../lib/helpers/createSpinner')
|
|
8
|
-
const { logger } = require('../../shared/logger')
|
|
9
|
-
const catchAndLog = require('../../lib/helpers/catchAndLog')
|
|
10
|
-
|
|
11
|
-
module.exports = async function spec () {
|
|
12
|
-
const options = this.opts()
|
|
13
|
-
const envFile = options.envFile
|
|
14
|
-
const overwrite = options.overwrite === true
|
|
15
|
-
const stdout = options.stdout === true
|
|
16
|
-
const interactive = !process.env.CI && process.stdin.isTTY && process.stderr.isTTY
|
|
17
|
-
let spinner
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
const existing = stdout ? undefined : fs.lstatSync('Envfile', { throwIfNoEntry: false })
|
|
21
|
-
if (existing && !overwrite) {
|
|
22
|
-
logger.info('○ Envfile already exists [edit or run: spec --overwrite]')
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
if (existing && !existing.isFile()) throw new Error('Cannot replace Envfile: expected a regular file')
|
|
26
|
-
|
|
27
|
-
let envFiles
|
|
28
|
-
let sourceKeys = []
|
|
29
|
-
let scanCode = false
|
|
30
|
-
const onFile = filename => {
|
|
31
|
-
if (spinner) spinner.text = `scanning ${filename}`
|
|
32
|
-
}
|
|
33
|
-
if (interactive && !envFile) {
|
|
34
|
-
const candidates = discoverEnvFiles()
|
|
35
|
-
const selected = await prompts.multiselect({
|
|
36
|
-
message: existing ? 'Recreate Envfile from .env files and code' : 'Create Envfile from .env files and code',
|
|
37
|
-
submitLabel: existing ? 'Recreate Envfile' : 'Create Envfile',
|
|
38
|
-
choices: [...candidates, { name: 'code ./**/* (env references)', value: '__scan_source' }],
|
|
39
|
-
initial: [...candidates, '__scan_source']
|
|
40
|
-
})
|
|
41
|
-
envFiles = selected.filter(value => value !== '__scan_source')
|
|
42
|
-
scanCode = selected.includes('__scan_source')
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const spinnerOptions = typeof this.optsWithGlobals === 'function' ? this.optsWithGlobals() : options
|
|
46
|
-
spinner = await createSpinner({ ...spinnerOptions, ...options, text: 'scanning' })
|
|
47
|
-
if (scanCode) {
|
|
48
|
-
const { keys } = await scanSource({ onFile })
|
|
49
|
-
sourceKeys = keys
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const { created, replaced, content } = initEnvfile({ envFile, envFiles, sourceKeys, overwrite, stdout, onFile })
|
|
53
|
-
if (spinner) spinner.stop()
|
|
54
|
-
if (stdout) {
|
|
55
|
-
process.stdout.write(content)
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
if (created) {
|
|
59
|
-
logger.success(replaced ? '◈ recreated (Envfile)' : '◈ created (Envfile)')
|
|
60
|
-
logger.help('⮕ next run [dotenvx check]')
|
|
61
|
-
} else logger.info('○ Envfile already exists [edit or run: spec --overwrite]')
|
|
62
|
-
} catch (error) {
|
|
63
|
-
if (spinner) spinner.stop()
|
|
64
|
-
catchAndLog(error)
|
|
65
|
-
return { exitCode: 1, error }
|
|
66
|
-
}
|
|
67
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const { logger } = require('../../../shared/logger')
|
|
2
|
-
const KeychainDown = require('./../../../lib/services/keychainDown')
|
|
3
|
-
const createSpinner = require('../../../lib/helpers/createSpinner')
|
|
4
|
-
const armoredKeyDisplay = require('../../../lib/helpers/armoredKeyDisplay')
|
|
5
|
-
|
|
6
|
-
async function down () {
|
|
7
|
-
const options = this.opts()
|
|
8
|
-
const spinnerOptions = typeof this.optsWithGlobals === 'function' ? this.optsWithGlobals() : options
|
|
9
|
-
const spinner = await createSpinner({ ...spinnerOptions, ...options, text: 'unkeychaining' })
|
|
10
|
-
|
|
11
|
-
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const { changed, privateKeyName, publicKeyValue } = new KeychainDown(options.envFile, options.envKeysFile).run()
|
|
15
|
-
const keyDisplay = armoredKeyDisplay(publicKeyValue) || privateKeyName
|
|
16
|
-
|
|
17
|
-
if (spinner) spinner.stop()
|
|
18
|
-
if (changed) {
|
|
19
|
-
logger.success(`◇ moved to .env.keys (${keyDisplay})`)
|
|
20
|
-
} else {
|
|
21
|
-
logger.info(`○ no change (${keyDisplay})`)
|
|
22
|
-
}
|
|
23
|
-
} catch (error) {
|
|
24
|
-
if (spinner) spinner.stop()
|
|
25
|
-
logger.error(error.message)
|
|
26
|
-
return { exitCode: 1, error }
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
module.exports = down
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const { logger } = require('../../../shared/logger')
|
|
2
|
-
const KeychainPull = require('./../../../lib/services/keychainPull')
|
|
3
|
-
const createSpinner = require('../../../lib/helpers/createSpinner')
|
|
4
|
-
const armoredKeyDisplay = require('../../../lib/helpers/armoredKeyDisplay')
|
|
5
|
-
|
|
6
|
-
async function pull () {
|
|
7
|
-
const options = this.opts()
|
|
8
|
-
const spinnerOptions = typeof this.optsWithGlobals === 'function' ? this.optsWithGlobals() : options
|
|
9
|
-
const spinner = await createSpinner({ ...spinnerOptions, ...options, text: 'pulling' })
|
|
10
|
-
|
|
11
|
-
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const { changed, privateKeyName, publicKeyValue } = new KeychainPull(options.envFile, options.envKeysFile).run()
|
|
15
|
-
const keyDisplay = armoredKeyDisplay(publicKeyValue) || privateKeyName
|
|
16
|
-
|
|
17
|
-
if (spinner) spinner.stop()
|
|
18
|
-
if (changed) {
|
|
19
|
-
logger.success(`◇ pulled to .env.keys (${keyDisplay})`)
|
|
20
|
-
} else {
|
|
21
|
-
logger.info(`○ no change (${keyDisplay})`)
|
|
22
|
-
}
|
|
23
|
-
} catch (error) {
|
|
24
|
-
if (spinner) spinner.stop()
|
|
25
|
-
logger.error(error.message)
|
|
26
|
-
return { exitCode: 1, error }
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
module.exports = pull
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const { logger } = require('../../../shared/logger')
|
|
2
|
-
const KeychainPush = require('./../../../lib/services/keychainPush')
|
|
3
|
-
const createSpinner = require('../../../lib/helpers/createSpinner')
|
|
4
|
-
const armoredKeyDisplay = require('../../../lib/helpers/armoredKeyDisplay')
|
|
5
|
-
|
|
6
|
-
async function push () {
|
|
7
|
-
const options = this.opts()
|
|
8
|
-
const spinnerOptions = typeof this.optsWithGlobals === 'function' ? this.optsWithGlobals() : options
|
|
9
|
-
const spinner = await createSpinner({ ...spinnerOptions, ...options, text: 'pushing' })
|
|
10
|
-
|
|
11
|
-
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const { changed, privateKeyName, publicKeyValue } = new KeychainPush(options.envFile, options.envKeysFile).run()
|
|
15
|
-
const keyDisplay = armoredKeyDisplay(publicKeyValue) || privateKeyName
|
|
16
|
-
|
|
17
|
-
if (spinner) spinner.stop()
|
|
18
|
-
if (changed) {
|
|
19
|
-
logger.success(`⌥ pushed (${keyDisplay})`)
|
|
20
|
-
} else {
|
|
21
|
-
logger.info(`○ no change (${keyDisplay})`)
|
|
22
|
-
}
|
|
23
|
-
} catch (error) {
|
|
24
|
-
if (spinner) spinner.stop()
|
|
25
|
-
logger.error(error.message)
|
|
26
|
-
return { exitCode: 1, error }
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
module.exports = push
|