Skip to content

Commit

Permalink
Merge pull request #64 from dotenv-org/informative-text
Browse files Browse the repository at this point in the history
Informative text
  • Loading branch information
motdotla committed Jun 10, 2022
2 parents 2f962dc + cbbbd8b commit dd99e95
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
11 changes: 11 additions & 0 deletions .env.vault
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
#################################################################################
# #
# This file uniquely identifies your project in Dotenv Vault. #
# You SHOULD commit this file to source control. #
# #
# Generated with `npx dotenv-vault new` #
# #
# Learn more at https://dotenv.org/env-vault #
# #
#################################################################################

DOTENV_VAULT=vlt_0a2981c4dcad3981c18c30e9a86a49c7697ba52c589b774e49686f611fe597aa
21 changes: 19 additions & 2 deletions src/services/login-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class LoginService {
CliUx.ux.action.start(`${chalk.dim(this.log.pretextLocal)}Adding .env.me (DOTENV_ME)`)
await CliUx.ux.wait(1000)
CliUx.ux.action.stop()
writeFileSync('.env.me', `DOTENV_ME=${this.dotenvMe}`)
writeFileSync('.env.me', this.meFileContent(this.dotenvMe))
this.log.local(`Added to .env.me (DOTENV_ME=${this.dotenvMe.slice(0, 9)}...)`)
this.log.plain('')
this.log.plain(`Next run ${chalk.bold('npx dotenv-vault@latest pull')} or ${chalk.bold('npx dotenv-vault@latest push')}`)
Expand Down Expand Up @@ -110,7 +110,7 @@ class LoginService {
// Step 3
CliUx.ux.action.stop()
const meUid = resp.data.data.meUid
writeFileSync('.env.me', `DOTENV_ME=${meUid}`)
writeFileSync('.env.me', this.meFileContent(meUid))
this.log.local(`Logged in as .env.me (DOTENV_ME=${meUid.slice(0, 9)}...)`)
if (tip) {
this.log.plain('')
Expand All @@ -127,6 +127,23 @@ class LoginService {
}
}

meFileContent(value: string): string {
const s = `#################################################################################
# #
# This file uniquely authorizes you against this project in Dotenv Vault. #
# Do NOT commit this file to source control. #
# #
# Generated with 'npx dotenv-vault login' #
# #
# Learn more at https://dotenv.org/env-me #
# #
#################################################################################
DOTENV_ME=${value}`

return s
}

get loginUrl(): string {
return `${vars.apiUrl}/login?vaultUid=${vars.vaultValue}&requestUid=${this.requestUid}`
}
Expand Down
23 changes: 20 additions & 3 deletions src/services/new-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class NewService {

// Step 1
if (vars.missingEnvVault) {
writeFileSync(vars.vaultFilename, `${vars.vaultKey}= # Generate vault identifiers at ${this.url}`)
writeFileSync(vars.vaultFilename, this.vaultFileContent(` # Generate vault identifiers at ${this.url}`))
}

// Step 2 B
Expand All @@ -55,7 +55,7 @@ class NewService {
CliUx.ux.action.start(`${chalk.dim(this.log.pretextLocal)}Adding ${vars.vaultFilename} (${vars.vaultKey})`)
await CliUx.ux.wait(1000)
CliUx.ux.action.stop()
writeFileSync(vars.vaultFilename, `${vars.vaultKey}=${this.dotenvVault}`)
writeFileSync(vars.vaultFilename, this.vaultFileContent(this.dotenvVault))
this.log.local(`Added to ${vars.vaultFilename} (${vars.vaultKey}=${this.dotenvVault.slice(0, 9)}...)`)
this.log.plain('')
this.log.plain(`Next run ${chalk.bold('npx dotenv-vault@latest login')}`)
Expand Down Expand Up @@ -106,7 +106,7 @@ class NewService {
// Step 3
CliUx.ux.action.stop()
const vaultUid = resp.data.data.vaultUid
writeFileSync(vars.vaultFilename, `${vars.vaultKey}=${vaultUid}`)
writeFileSync(vars.vaultFilename, this.vaultFileContent(vaultUid))
this.log.local(`Added to ${vars.vaultFilename} (${vars.vaultKey}=${vaultUid.slice(0, 9)}...)`)
this.log.plain('')
this.log.plain(`Next run ${chalk.bold('npx dotenv-vault@latest login')}`)
Expand All @@ -121,6 +121,23 @@ class NewService {
}
}

vaultFileContent(value: string): string {
const s = `#################################################################################
# #
# This file uniquely identifies your project in Dotenv Vault. #
# You SHOULD commit this file to source control. #
# #
# Generated with 'npx dotenv-vault new' #
# #
# Learn more at https://dotenv.org/env-vault #
# #
#################################################################################
${vars.vaultKey}=${value}`

return s
}

get url(): string {
return vars.apiUrl + '/new'
}
Expand Down

0 comments on commit dd99e95

Please sign in to comment.