@dotenvx/dotenvx 1.6.5 → 1.7.0

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/CHANGELOG.md CHANGED
@@ -2,7 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.6.5...main)
5
+ ## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.7.0...main)
6
+
7
+ ## 1.7.0
8
+
9
+ ### Removed
10
+
11
+ * remove `ext settings` command (and [`conf`](https://www.npmjs.com/package/conf) along with it) ([#323](https://github.com/dotenvx/dotenvx/pull/323))
6
12
 
7
13
  ## 1.6.5
8
14
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.6.5",
2
+ "version": "1.7.0",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -38,7 +38,6 @@
38
38
  "dependencies": {
39
39
  "chalk": "^4.1.2",
40
40
  "commander": "^11.1.0",
41
- "conf": "^10.2.0",
42
41
  "diff": "^5.2.0",
43
42
  "dotenv": "^16.4.5",
44
43
  "eciesjs": "^0.4.6",
@@ -57,13 +57,6 @@ ext.command('scan')
57
57
  .description('scan for leaked secrets')
58
58
  .action(require('./../actions/ext/scan'))
59
59
 
60
- // dotenvx settings
61
- ext.command('settings')
62
- .description('print current dotenvx settings')
63
- .argument('[key]', 'settings name')
64
- .option('-pp, --pretty-print', 'pretty print output')
65
- .action(require('./../actions/ext/settings'))
66
-
67
60
  ext.addCommand(require('./../commands/ext/vault'))
68
61
 
69
62
  module.exports = ext
package/src/lib/main.d.ts CHANGED
@@ -289,21 +289,6 @@ export function genexample(
289
289
  envFile: string
290
290
  ): GenExampleOutput;
291
291
 
292
- export type Settings = {
293
- DOTENVX_SETTINGS_FILEPATH: string;
294
- };
295
-
296
- type KeyOfSettings = Extract<keyof Settings, string>;
297
-
298
- /**
299
- * Get the dotenvx settings
300
- *
301
- * @param [key] - the key to get the value of
302
- */
303
- export function settings(
304
- key: KeyOfSettings | undefined | null = null
305
- ): Settings;
306
-
307
292
  /**
308
293
  * Decrypt ciphertext
309
294
  * @param encrypted - the encrypted ciphertext string
package/src/lib/main.js CHANGED
@@ -12,7 +12,6 @@ const Status = require('./services/status')
12
12
  const Encrypt = require('./services/encrypt')
13
13
  const Decrypt = require('./services/decrypt')
14
14
  const Genexample = require('./services/genexample')
15
- const Settings = require('./services/settings')
16
15
  const VaultEncrypt = require('./services/vaultEncrypt')
17
16
 
18
17
  // helpers
@@ -204,12 +203,6 @@ const status = function (directory) {
204
203
  return new Status(directory).run()
205
204
  }
206
205
 
207
- /** @type {import('./main').settings} */
208
- const settings = function (key = null) {
209
- // @ts-ignore
210
- return new Settings(key).run()
211
- }
212
-
213
206
  // misc/cleanup
214
207
 
215
208
  /** @type {import('./main').vaultDecrypt} */
@@ -255,8 +248,6 @@ module.exports = {
255
248
  set,
256
249
  status,
257
250
  genexample,
258
- // settings
259
- settings,
260
251
  // misc/cleanup
261
252
  vaultEncrypt,
262
253
  vaultDecrypt
@@ -1,25 +0,0 @@
1
- const { logger } = require('./../../../shared/logger')
2
-
3
- const main = require('./../../../lib/main')
4
-
5
- function settings (key = null) {
6
- logger.debug(`key: ${key}`)
7
-
8
- const options = this.opts()
9
- logger.debug(`options: ${JSON.stringify(options)}`)
10
-
11
- const value = main.settings(key)
12
-
13
- if (typeof value === 'object' && value !== null) {
14
- let space = 0
15
- if (options.prettyPrint) {
16
- space = 2
17
- }
18
-
19
- process.stdout.write(JSON.stringify(value, null, space))
20
- } else {
21
- process.stdout.write(value)
22
- }
23
- }
24
-
25
- module.exports = settings
@@ -1,28 +0,0 @@
1
- const store = require('./../../shared/store')
2
-
3
- class Settings {
4
- constructor (key = null) {
5
- this.key = key
6
- }
7
-
8
- run () {
9
- const store = this._store()
10
-
11
- if (this.key) {
12
- return store[this.key]
13
- }
14
-
15
- // json of dotenvx.settings
16
- return store
17
- }
18
-
19
- _store () {
20
- const h = {
21
- DOTENVX_SETTINGS_FILEPATH: store.configPath()
22
- }
23
-
24
- return { ...h, ...store.confStore.store }
25
- }
26
- }
27
-
28
- module.exports = Settings
@@ -1,146 +0,0 @@
1
- const Conf = require('conf')
2
- const dotenv = require('dotenv')
3
- const packageJson = require('./../lib/helpers/packageJson')
4
-
5
- function jsonToEnv (json) {
6
- return Object.entries(json).map(function ([key, value]) {
7
- return key + '=' + `"${value}"`
8
- }).join('\n')
9
- }
10
-
11
- function convertFullUsernameToEnvFormat (fullUsername) {
12
- // gh/motdotla => GH_MOTDOTLA_DOTENVX_TOKEN
13
- return fullUsername
14
- .toUpperCase()
15
- .replace(/\//g, '_') // Replace all slashes with underscores
16
- .concat('_DOTENVX_TOKEN') // Append '_DOTENVX_TOKEN' at the end
17
- }
18
-
19
- function findFirstMatchingKey (data) {
20
- const dotenvxTokenValue = data.DOTENVX_TOKEN
21
-
22
- for (const [key, value] of Object.entries(data)) {
23
- if (key !== 'DOTENVX_TOKEN' && value === dotenvxTokenValue) {
24
- return key
25
- }
26
- }
27
-
28
- return null // Return null if no matching key is found
29
- }
30
-
31
- function parseUsernameFromTokenKey (key) {
32
- // Remove the leading GH_/GL_ and trailing '_DOTENVX_TOKEN'
33
- const modifiedKey = key.replace(/^(GH_|GL_)/, '').replace(/_DOTENVX_TOKEN$/, '')
34
-
35
- // Convert to lowercase
36
- return modifiedKey.toLowerCase()
37
- }
38
-
39
- const confStore = new Conf({
40
- projectName: 'dotenvx',
41
- configName: '.env',
42
- // looks better on user's machine
43
- // https://github.com/sindresorhus/conf/tree/v10.2.0#projectsuffix.
44
- projectSuffix: '',
45
- fileExtension: '',
46
- // in the spirit of dotenv and format inherently puts limits on config complexity
47
- serialize: function (json) {
48
- return jsonToEnv(json)
49
- },
50
- // Convert .env format to an object
51
- deserialize: function (env) {
52
- return dotenv.parse(env)
53
- }
54
- })
55
-
56
- const getHostname = function () {
57
- return confStore.get('DOTENVX_HOSTNAME') || 'https://hub.dotenvx.com'
58
- }
59
-
60
- const getUsername = function () {
61
- const key = findFirstMatchingKey(confStore.store)
62
-
63
- if (key) {
64
- return parseUsernameFromTokenKey(key)
65
- } else {
66
- return null
67
- }
68
- }
69
-
70
- const getToken = function () {
71
- return confStore.get('DOTENVX_TOKEN')
72
- }
73
-
74
- const getLatestVersion = function () {
75
- return confStore.get('DOTENVX_LATEST_VERSION') || packageJson.version
76
- }
77
-
78
- const getLatestVersionLastChecked = function () {
79
- return parseInt(confStore.get('DOTENVX_LATEST_VERSION_LAST_CHECKED') || 0)
80
- }
81
-
82
- const setToken = function (fullUsername, accessToken) {
83
- // current logged in user
84
- confStore.set('DOTENVX_TOKEN', accessToken)
85
-
86
- // for future use to switch between accounts locally
87
- const memory = convertFullUsernameToEnvFormat(fullUsername)
88
- confStore.set(memory, accessToken)
89
-
90
- return accessToken
91
- }
92
-
93
- const setHostname = function (hostname) {
94
- confStore.set('DOTENVX_HOSTNAME', hostname)
95
-
96
- return hostname
97
- }
98
-
99
- const setLatestVersion = function (version) {
100
- confStore.set('DOTENVX_LATEST_VERSION', version)
101
-
102
- return version
103
- }
104
-
105
- const setLatestVersionLastChecked = function (dateNow) {
106
- confStore.set('DOTENVX_LATEST_VERSION_LAST_CHECKED', dateNow)
107
-
108
- return dateNow
109
- }
110
-
111
- const deleteToken = function () {
112
- // memory user
113
- const key = findFirstMatchingKey(confStore.store) // GH_MOTDOTLA_DOTENVX_TOKEN
114
- confStore.delete(key)
115
-
116
- // current logged in user
117
- confStore.delete('DOTENVX_TOKEN')
118
-
119
- return true
120
- }
121
-
122
- const deleteHostname = function () {
123
- confStore.delete('DOTENVX_HOSTNAME')
124
-
125
- return true
126
- }
127
-
128
- const configPath = function () {
129
- return confStore.path
130
- }
131
-
132
- module.exports = {
133
- confStore,
134
- getHostname,
135
- getToken,
136
- getUsername,
137
- getLatestVersion,
138
- getLatestVersionLastChecked,
139
- setHostname,
140
- setToken,
141
- setLatestVersion,
142
- setLatestVersionLastChecked,
143
- deleteToken,
144
- deleteHostname,
145
- configPath
146
- }