@dotenvx/dotenvx-ops 0.15.6

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +161 -0
  2. package/LICENSE +71 -0
  3. package/README.md +9 -0
  4. package/package.json +66 -0
  5. package/src/cli/actions/login.js +118 -0
  6. package/src/cli/actions/logout.js +42 -0
  7. package/src/cli/actions/observe.js +33 -0
  8. package/src/cli/actions/settings/device.js +24 -0
  9. package/src/cli/actions/settings/hostname.js +20 -0
  10. package/src/cli/actions/settings/token.js +24 -0
  11. package/src/cli/actions/settings/username.js +22 -0
  12. package/src/cli/actions/status.js +13 -0
  13. package/src/cli/actions/sync.js +39 -0
  14. package/src/cli/commands/settings.js +39 -0
  15. package/src/cli/dotenvx-ops.js +93 -0
  16. package/src/db/device.js +73 -0
  17. package/src/db/session.js +119 -0
  18. package/src/lib/api/postLogout.js +34 -0
  19. package/src/lib/api/postOauthDeviceCode.js +42 -0
  20. package/src/lib/api/postOauthToken.js +38 -0
  21. package/src/lib/api/postObserve.js +59 -0
  22. package/src/lib/api/postSync.js +65 -0
  23. package/src/lib/helpers/buildApiError.js +13 -0
  24. package/src/lib/helpers/buildOauthError.js +13 -0
  25. package/src/lib/helpers/clipboardy/fallbacks/linux/xsel +0 -0
  26. package/src/lib/helpers/clipboardy/fallbacks/windows/clipboard_i686.exe +0 -0
  27. package/src/lib/helpers/clipboardy/fallbacks/windows/clipboard_x86_64.exe +0 -0
  28. package/src/lib/helpers/clipboardy/linux.js +57 -0
  29. package/src/lib/helpers/clipboardy/macos.js +14 -0
  30. package/src/lib/helpers/clipboardy/termux.js +41 -0
  31. package/src/lib/helpers/clipboardy/windows.js +16 -0
  32. package/src/lib/helpers/clipboardy.js +51 -0
  33. package/src/lib/helpers/confirm.js +17 -0
  34. package/src/lib/helpers/createSpinner.js +101 -0
  35. package/src/lib/helpers/decryptValue.js +10 -0
  36. package/src/lib/helpers/encryptValue.js +9 -0
  37. package/src/lib/helpers/errors.js +30 -0
  38. package/src/lib/helpers/formatCode.js +11 -0
  39. package/src/lib/helpers/gitBranch.js +13 -0
  40. package/src/lib/helpers/gitUrl.js +13 -0
  41. package/src/lib/helpers/http.js +17 -0
  42. package/src/lib/helpers/jsonToEnv.js +7 -0
  43. package/src/lib/helpers/mask.js +12 -0
  44. package/src/lib/helpers/packageJson.js +3 -0
  45. package/src/lib/helpers/smartMask.js +11 -0
  46. package/src/lib/helpers/truncate.js +10 -0
  47. package/src/lib/main.d.ts +129 -0
  48. package/src/lib/main.js +47 -0
  49. package/src/lib/services/logout.js +28 -0
  50. package/src/lib/services/status.js +11 -0
  51. package/src/lib/services/sync.js +94 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,161 @@
1
+ # Changelog
2
+
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
+
5
+ [Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.15.6...main)
6
+
7
+ ## [0.15.6](https://github.com/dotenvx/dotenvx-ops/compare/v0.15.5...v0.15.6) (2025-08-27)
8
+
9
+ ### Changed
10
+
11
+ * Send device public key along with sync ([#19](https://github.com/dotenvx/dotenvx-ops/pull/19))
12
+
13
+ ## [0.15.5](https://github.com/dotenvx/dotenvx-ops/compare/v0.15.3...v0.15.5) (2025-08-23)
14
+
15
+ ### Added
16
+
17
+ * Mark device during login handshake ([#18](https://github.com/dotenvx/dotenvx-ops/pull/18))
18
+
19
+ ## [0.15.3](https://github.com/dotenvx/dotenvx-ops/compare/v0.15.2...v0.15.3) (2025-08-23)
20
+
21
+ ### Changed
22
+
23
+ * Install latest dotenvx when installing dotenvx-ops ([#17](https://github.com/dotenvx/dotenvx-ops/pull/17))
24
+
25
+ ## [0.15.2](https://github.com/dotenvx/dotenvx-ops/compare/v0.15.1...v0.15.2) (2025-08-18)
26
+
27
+ ### Changed
28
+
29
+ * Fix bad method name ([#15](https://github.com/dotenvx/dotenvx-ops/pull/15))
30
+
31
+ ## [0.15.1](https://github.com/dotenvx/dotenvx-ops/compare/v0.15.0...v0.15.1) (2025-08-18)
32
+
33
+ ### Changed
34
+
35
+ * Switch to `DOTENVX_PROJECT_ID`
36
+
37
+ ## [0.15.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.14.2...v0.15.0) (2025-08-18)
38
+
39
+ ### Added
40
+
41
+ * Add sync command ([#14](https://github.com/dotenvx/dotenvx-ops/pull/14))
42
+
43
+ ## [0.14.2](https://github.com/dotenvx/dotenvx-ops/compare/v0.14.1...v0.14.2) (2025-07-21)
44
+
45
+ * Patch usage description ([#13](https://github.com/dotenvx/dotenvx-ops/pull/13))
46
+
47
+ ## [0.14.1](https://github.com/dotenvx/dotenvx-ops/compare/v0.14.0...v0.14.1) (2025-07-21)
48
+
49
+ * Update README
50
+
51
+ ## [0.14.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.13.0...v0.14.0) (2025-07-19)
52
+
53
+ * Add `dotenvx-ops status` ([#12](https://github.com/dotenvx/dotenvx-ops/pull/12))
54
+
55
+ ## [0.13.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.12.0...v0.13.0) (2025-07-15)
56
+
57
+ * Add `dotenvx-ops settings` ([#11](https://github.com/dotenvx/dotenvx-ops/pull/11))
58
+
59
+ ## [0.12.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.11.0...v0.12.0) (2025-07-15)
60
+
61
+ * Add additional fields to observe ([#10](https://github.com/dotenvx/dotenvx-ops/pull/10))
62
+
63
+ ## [0.11.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.10.0...v0.11.0) (2025-07-15)
64
+
65
+ * Add `observe` with git url ([#9](https://github.com/dotenvx/dotenvx-ops/pull/9))
66
+
67
+ ## [0.10.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.9.1...v0.10.0) (2025-07-14)
68
+
69
+ ### Added
70
+
71
+ * Add `dotenvx-ops logout` ([#8](https://github.com/dotenvx/dotenvx-ops/pull/8))
72
+
73
+ ## [0.9.1](https://github.com/dotenvx/dotenvx-ops/compare/v0.9.0...v0.9.1) (2025-07-14)
74
+
75
+ ### Changed
76
+
77
+ * Include `dotenv` in package.json ([#7](https://github.com/dotenvx/dotenvx-ops/pull/7))
78
+
79
+ ## [0.9.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.8.0...v0.9.0) (2025-07-14)
80
+
81
+ ### Added
82
+
83
+ * Add bearer token support to `dotenvx-ops observe` ([#6](https://github.com/dotenvx/dotenvx-ops/pull/6))
84
+
85
+ ## [0.8.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.7.0...v0.8.0) (2025-07-14)
86
+
87
+ ### Added
88
+
89
+ * Add `dotenvx-ops login` command ([#5](https://github.com/dotenvx/dotenvx-ops/pull/5))
90
+
91
+ ## [0.7.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.6.0...v0.7.0) (2025-07-11)
92
+
93
+ ### Added
94
+
95
+ * Send observation data to api ([#4](https://github.com/dotenvx/dotenvx-ops/pull/4))
96
+
97
+ ## [0.6.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.5.0...v0.6.0) (2025-07-09)
98
+
99
+ ### Added
100
+
101
+ * Add `dotenvx-ops observe` cli that proxies to `main#observe` ([#3](https://github.com/dotenvx/dotenvx-ops/pull/3))
102
+
103
+ ## [0.5.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.4.3...v0.5.0) (2025-07-09)
104
+
105
+ ### Added
106
+
107
+ * Add `observe` function ([#2](https://github.com/dotenvx/dotenvx-ops/pull/2))
108
+
109
+ ## 0.4.3
110
+
111
+ ### Changed
112
+
113
+ * Patch bad formatting
114
+
115
+ ## 0.4.2
116
+
117
+ ### Changed
118
+
119
+ * Change log to reflect `dotenvx-ops`
120
+
121
+ ## 0.4.1
122
+
123
+ ### Changed
124
+
125
+ * Bump to `dotenvx` that supports exported cli
126
+
127
+ ## 0.4.0
128
+
129
+ ### Added
130
+
131
+ * Add `run` command that proxies to `dotenvx run` ([#1](https://github.com/dotenvx/dotenvx-ops/pull/1))
132
+
133
+ ## 0.3.0
134
+
135
+ ### Added
136
+
137
+ * Install `dotenvx` if not already installed in `install.sh` script
138
+
139
+ ## 0.2.3
140
+
141
+ ### Changed
142
+
143
+ * Patch `hello` action
144
+
145
+ ## 0.2.2
146
+
147
+ ### Changed
148
+
149
+ * Fix filename in `install.sh`
150
+
151
+ ## 0.2.1
152
+
153
+ ### Changed
154
+
155
+ * Fix registry url in `install.sh`
156
+
157
+ ## 0.1.0
158
+
159
+ ### Added
160
+
161
+ * Initial publish
package/LICENSE ADDED
@@ -0,0 +1,71 @@
1
+ Dotenvx Ops End-User License Agreement (EULA)
2
+
3
+ Applies to: Dotenvx Ops (CLI, SDKs, and related software)
4
+
5
+ ---
6
+
7
+ Summary
8
+
9
+ Dotenvx Ops is a commercial product. This agreement outlines your rights to use the software, and our expectations in return. It’s written to be understandable, developer-friendly, and fair.
10
+
11
+ By installing, accessing, or using Dotenvx Ops, you agree to these terms.
12
+
13
+ ---
14
+
15
+ 1. License
16
+
17
+ You are granted a non-exclusive, non-transferable, revocable license to use Dotenvx Ops as long as:
18
+ - You have an active license (via paid subscription or evaluation, including time-limited free trials)
19
+ - You do not distribute or sublicense the software
20
+ - You do not attempt to bypass license enforcement or API restrictions
21
+
22
+ ---
23
+
24
+ 2. Use
25
+
26
+ You may:
27
+ - Use Dotenvx Ops internally for your own development or production workflows
28
+ - Install the CLI or SDKs on machines you or your team control
29
+
30
+ You may not:
31
+ - Share the software or source with third parties
32
+ - Offer it as a hosted service, SaaS platform, or similar product
33
+ - Use it in a way that competes with dotenvx.com
34
+
35
+ ---
36
+
37
+ 3. Ownership
38
+
39
+ All rights, title, and interest in Dotenvx Ops remain with DOTENVX LLC. You’re granted limited usage rights, not ownership.
40
+
41
+ ---
42
+
43
+ 4. Termination
44
+
45
+ We may revoke your license if you:
46
+ - Violate these terms
47
+ - Fail to pay your subscription
48
+
49
+ You must stop using the software immediately if your license is terminated.
50
+
51
+ ---
52
+
53
+ 5. Warranty Disclaimer
54
+
55
+ Dotenvx Ops is provided as-is, with no guarantees that it will work for your specific use case. You assume all risk.
56
+
57
+ ---
58
+
59
+ 6. Limitation of Liability
60
+
61
+ We are not liable for any indirect or consequential damages, including loss of data, downtime, or lost profits. Our total liability is limited to the amount you paid us for your license.
62
+
63
+ ---
64
+
65
+ 7. Contact
66
+
67
+ Have questions? Email us at ops@dotenvx.com
68
+
69
+ ---
70
+
71
+ © 2025 DOTENVX LLC. All rights reserved.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ [![dotenvx-ops](https://dotenvx.com/dotenvx-ops-banner.png)](https://dotenvx.com/ops)
2
+
3
+ > Dotenvx Ops is a commercial product for secrets operations using [dotenvx](https://github.com/dotenvx/dotenvx).
4
+
5
+ *Use dotenvx across your team, infrastructure, agents, and more.*
6
+
7
+ [Learn more](https://dotenvx.com/docs/ops)
8
+
9
+  
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "version": "0.15.6",
3
+ "name": "@dotenvx/dotenvx-ops",
4
+ "description": "Dotenvx Ops",
5
+ "author": "@motdotla",
6
+ "keywords": [
7
+ "dotenv",
8
+ "dotenvx",
9
+ "ops",
10
+ "env"
11
+ ],
12
+ "homepage": "https://dotenvx.com/ops",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/dotenvx/dotenvx-ops.git"
16
+ },
17
+ "license": "See LICENSE",
18
+ "files": [
19
+ "src/**/*",
20
+ "CHANGELOG.md"
21
+ ],
22
+ "main": "src/lib/main.js",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./src/lib/main.d.ts",
26
+ "require": "./src/lib/main.js",
27
+ "default": "./src/lib/main.js"
28
+ },
29
+ "./package.json": "./package.json"
30
+ },
31
+ "bin": {
32
+ "dotenvx-ops": "./src/cli/dotenvx-ops.js"
33
+ },
34
+ "scripts": {
35
+ "standard": "standard",
36
+ "standard:fix": "standard --fix",
37
+ "test": "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
38
+ "test-coverage": "tap run --show-full-coverage --timeout=60000",
39
+ "prerelease": "npm test",
40
+ "release": "standard-version"
41
+ },
42
+ "dependencies": {
43
+ "@clack/core": "^0.4.2",
44
+ "@dotenvx/dotenvx": "^1.48.1",
45
+ "arch": "^2.1.1",
46
+ "commander": "^11.1.0",
47
+ "conf": "^10.2.0",
48
+ "dotenv": "^17.2.0",
49
+ "eciesjs": "^0.4.7",
50
+ "execa": "^5.1.1",
51
+ "open": "^8.4.2",
52
+ "systeminformation": "^5.22.11",
53
+ "undici": "^7.11.0"
54
+ },
55
+ "devDependencies": {
56
+ "@yao-pkg/pkg": "^5.14.2",
57
+ "capture-console": "^1.0.2",
58
+ "sinon": "^14.0.1",
59
+ "standard": "^17.1.2",
60
+ "standard-version": "^9.5.0",
61
+ "tap": "^19.2.5"
62
+ },
63
+ "publishConfig": {
64
+ "access": "public"
65
+ }
66
+ }
@@ -0,0 +1,118 @@
1
+ const open = require('open')
2
+ const { logger } = require('@dotenvx/dotenvx')
3
+
4
+ const Session = require('./../../db/session')
5
+
6
+ const clipboardy = require('./../../lib/helpers/clipboardy')
7
+ const { createSpinner } = require('./../../lib/helpers/createSpinner')
8
+ const confirm = require('./../../lib/helpers/confirm')
9
+ const truncate = require('./../../lib/helpers/truncate')
10
+ const formatCode = require('./../../lib/helpers/formatCode')
11
+
12
+ const spinner = createSpinner('waiting on browser authorization')
13
+
14
+ // api calls
15
+ const PostOauthToken = require('./../../lib/api/postOauthToken')
16
+ const PostOauthDeviceCode = require('./../../lib/api/postOauthDeviceCode')
17
+
18
+ async function pollTokenUrl (hostname, deviceCode, interval) {
19
+ logger.debug(`POST ${hostname} with deviceCode ${deviceCode} at interval ${interval}`)
20
+
21
+ const sesh = new Session()
22
+
23
+ while (true) {
24
+ try {
25
+ let data
26
+ try {
27
+ data = await new PostOauthToken(hostname, deviceCode).run()
28
+ if (data.access_token) {
29
+ const id = data.id
30
+ const username = data.username
31
+ const accessToken = data.access_token
32
+
33
+ // log in user
34
+ sesh.login(hostname, id, username, accessToken)
35
+ spinner.succeed(`logged in [${username}] to this device and activated token [${truncate(accessToken, 11)}]`)
36
+ // logger.help('⮕ next run [dotenvx-ops sync]')
37
+
38
+ process.exit(0)
39
+ } else {
40
+ await new Promise(resolve => setTimeout(resolve, interval * 1000))
41
+ }
42
+ } catch (error) {
43
+ // continue polling if authorization_pending
44
+ if (error.code === 'authorization_pending') {
45
+ const newInterval = interval + 1 // grow the interval
46
+ await new Promise(resolve => setTimeout(resolve, newInterval * 1000))
47
+ } else {
48
+ throw error
49
+ }
50
+ }
51
+ } catch (error) {
52
+ spinner.stop()
53
+ if (error.message) {
54
+ logger.error(error.message)
55
+ } else {
56
+ logger.error(error)
57
+ }
58
+ if (error.help) {
59
+ logger.help(error.help)
60
+ }
61
+ process.exit(1)
62
+ }
63
+ }
64
+ }
65
+
66
+ async function login () {
67
+ const options = this.opts()
68
+ logger.debug(`options: ${JSON.stringify(options)}`)
69
+
70
+ const hostname = options.hostname
71
+
72
+ try {
73
+ const sesh = new Session()
74
+ const devicePublicKey = sesh.devicePublicKey()
75
+ const systemInformation = await sesh.systemInformation()
76
+ const data = await new PostOauthDeviceCode(hostname, devicePublicKey, systemInformation).run()
77
+
78
+ const deviceCode = data.device_code
79
+ const userCode = data.user_code
80
+ const verificationUri = data.verification_uri
81
+ const verificationUriComplete = data.verification_uri_complete
82
+ const interval = data.interval
83
+
84
+ try { clipboardy.writeSync(userCode) } catch (_e) {}
85
+
86
+ // begin polling
87
+ pollTokenUrl(hostname, deviceCode, interval)
88
+
89
+ logger.info(`press Enter to open [${verificationUri}] and enter code [${formatCode(userCode)}]...`)
90
+ spinner.start()
91
+
92
+ // // optionally allow user to open browser
93
+ const answer = await confirm({ message: `press Enter to open [${verificationUri}] and enter code [${formatCode(userCode)}]...` })
94
+
95
+ if (answer) {
96
+ await open(verificationUriComplete)
97
+ } else {
98
+ spinner.stop()
99
+ process.exit(1)
100
+ }
101
+ } catch (error) {
102
+ spinner.stop()
103
+ if (error.message) {
104
+ logger.error(error.message)
105
+ } else {
106
+ logger.error(error)
107
+ }
108
+ if (error.help) {
109
+ logger.help(error.help)
110
+ }
111
+ if (error.stack) {
112
+ logger.debug(error.stack)
113
+ }
114
+ process.exit(1)
115
+ }
116
+ }
117
+
118
+ module.exports = login
@@ -0,0 +1,42 @@
1
+ const { logger } = require('@dotenvx/dotenvx')
2
+
3
+ const { createSpinner } = require('./../../lib/helpers/createSpinner')
4
+ const truncate = require('./../../lib/helpers/truncate')
5
+ const Logout = require('./../../lib/services/logout')
6
+
7
+ const spinner = createSpinner('waiting on browser authorization')
8
+
9
+ async function logout () {
10
+ const options = this.opts()
11
+ logger.debug(`options: ${JSON.stringify(options)}`)
12
+
13
+ const hostname = options.hostname
14
+
15
+ try {
16
+ spinner.start()
17
+
18
+ const {
19
+ username,
20
+ accessToken
21
+ } = await new Logout(hostname).run()
22
+
23
+ spinner.succeed(`logged out [${username}] from this device and revoked token [${truncate(accessToken, 11)}]`)
24
+ // logger.help(`⮕ next visit [${settingsDevicesUrl}] to view your devices`)
25
+ } catch (error) {
26
+ spinner.stop()
27
+ if (error.message) {
28
+ logger.error(error.message)
29
+ } else {
30
+ logger.error(error)
31
+ }
32
+ if (error.help) {
33
+ logger.help(error.help)
34
+ }
35
+ if (error.stack) {
36
+ logger.debug(error.stack)
37
+ }
38
+ process.exit(1)
39
+ }
40
+ }
41
+
42
+ module.exports = logout
@@ -0,0 +1,33 @@
1
+ const { logger } = require('@dotenvx/dotenvx')
2
+
3
+ const main = require('./../../lib/main')
4
+
5
+ async function observe (base64) {
6
+ const commandArgs = this.args
7
+ logger.debug(`process command [${commandArgs.join(' ')}]`)
8
+
9
+ const options = this.opts()
10
+ logger.debug(`options: ${JSON.stringify(options)}`)
11
+
12
+ const hostname = options.hostname
13
+ const token = options.token
14
+
15
+ try {
16
+ await main.observe(base64, { hostname, token })
17
+ } catch (error) {
18
+ if (error.message) {
19
+ logger.error(error.message)
20
+ } else {
21
+ logger.error(error)
22
+ }
23
+ if (error.help) {
24
+ logger.help(error.help)
25
+ }
26
+ if (error.stack) {
27
+ logger.debug(error.stack)
28
+ }
29
+ // do not process exit 1 since that would exit dotenvx run --
30
+ }
31
+ }
32
+
33
+ module.exports = observe
@@ -0,0 +1,24 @@
1
+ const { logger } = require('@dotenvx/dotenvx')
2
+
3
+ const Session = require('./../../../db/session')
4
+ const smartMask = require('./../../../lib/helpers/smartMask')
5
+
6
+ function device () {
7
+ const options = this.opts()
8
+
9
+ try {
10
+ const sesh = new Session()
11
+ const devicePublicKey = sesh.devicePublicKey()
12
+ if (devicePublicKey && devicePublicKey.length > 1) {
13
+ process.stdout.write(smartMask(devicePublicKey, options.unmask, 11))
14
+ } else {
15
+ logger.error('missing device. Try generating one with [dotenvx-ops login].')
16
+ process.exit(1)
17
+ }
18
+ } catch (error) {
19
+ logger.error(error.message)
20
+ process.exit(1)
21
+ }
22
+ }
23
+
24
+ module.exports = device
@@ -0,0 +1,20 @@
1
+ const { logger } = require('@dotenvx/dotenvx')
2
+ const Session = require('./../../../db/session')
3
+
4
+ function hostname () {
5
+ try {
6
+ const sesh = new Session()
7
+ const _hostname = sesh.hostname()
8
+ if (_hostname && _hostname.length > 1) {
9
+ process.stdout.write(_hostname)
10
+ } else {
11
+ logger.error('missing hostname. Try running [dotenvx-ops login].')
12
+ process.exit(1)
13
+ }
14
+ } catch (error) {
15
+ logger.error(error.message)
16
+ process.exit(1)
17
+ }
18
+ }
19
+
20
+ module.exports = hostname
@@ -0,0 +1,24 @@
1
+ const { logger } = require('@dotenvx/dotenvx')
2
+
3
+ const Session = require('./../../../db/session')
4
+ const smartMask = require('./../../../lib/helpers/smartMask')
5
+
6
+ function token () {
7
+ const options = this.opts()
8
+
9
+ try {
10
+ const sesh = new Session()
11
+ const token = sesh.token()
12
+ if (token && token.length > 1) {
13
+ process.stdout.write(smartMask(token, options.unmask, 11))
14
+ } else {
15
+ logger.error('missing token. Try generating one with [dotenvx-ops login].')
16
+ process.exit(1)
17
+ }
18
+ } catch (error) {
19
+ logger.error(error.message)
20
+ process.exit(1)
21
+ }
22
+ }
23
+
24
+ module.exports = token
@@ -0,0 +1,22 @@
1
+ const { logger } = require('@dotenvx/dotenvx')
2
+
3
+ const Session = require('./../../../db/session')
4
+
5
+ async function username () {
6
+ try {
7
+ const sesh = new Session()
8
+ const username = sesh.username()
9
+
10
+ if (username) {
11
+ process.stdout.write(username)
12
+ } else {
13
+ logger.error('login required. Try running [dotenvx-pro login].')
14
+ process.exit(1)
15
+ }
16
+ } catch (error) {
17
+ logger.error(error.message)
18
+ process.exit(1)
19
+ }
20
+ }
21
+
22
+ module.exports = username
@@ -0,0 +1,13 @@
1
+ const { logger } = require('@dotenvx/dotenvx')
2
+
3
+ const Status = require('./../../lib/services/status')
4
+
5
+ async function status () {
6
+ const options = this.opts()
7
+ logger.debug(`options: ${JSON.stringify(options)}`)
8
+
9
+ const { status } = new Status().run()
10
+ process.stdout.write(status)
11
+ }
12
+
13
+ module.exports = status
@@ -0,0 +1,39 @@
1
+ const { logger } = require('@dotenvx/dotenvx')
2
+
3
+ const { createSpinner } = require('./../../lib/helpers/createSpinner')
4
+
5
+ const Sync = require('./../../lib/services/sync')
6
+
7
+ const spinner = createSpinner('syncing')
8
+
9
+ async function sync () {
10
+ try {
11
+ // debug opts
12
+ const options = this.opts()
13
+ logger.debug(`options: ${JSON.stringify(options)}`)
14
+
15
+ spinner.start()
16
+
17
+ const { projectUsernameName } = await new Sync(options.hostname).run()
18
+
19
+ spinner.stop()
20
+
21
+ logger.success(`✔ synced [${projectUsernameName}]`)
22
+ } catch (error) {
23
+ spinner.stop()
24
+ if (error.message) {
25
+ logger.error(error.message)
26
+ } else {
27
+ logger.error(error)
28
+ }
29
+ if (error.help) {
30
+ logger.help(error.help)
31
+ }
32
+ if (error.stack) {
33
+ logger.debug(error.stack)
34
+ }
35
+ process.exit(1)
36
+ }
37
+ }
38
+
39
+ module.exports = sync
@@ -0,0 +1,39 @@
1
+ const { Command } = require('commander')
2
+
3
+ const settings = new Command('settings')
4
+
5
+ settings
6
+ .description('⚙️ settings')
7
+ .allowUnknownOption()
8
+
9
+ // dotenvx-ops settings username
10
+ const usernameAction = require('./../actions/settings/username')
11
+ settings
12
+ .command('username')
13
+ .description('print your username')
14
+ .action(usernameAction)
15
+
16
+ // dotenvx-ops settings token
17
+ const tokenAction = require('./../actions/settings/token')
18
+ settings
19
+ .command('token')
20
+ .description('print your access token (--unmask)')
21
+ .option('--unmask', 'unmask access token')
22
+ .action(tokenAction)
23
+
24
+ // dotenvx-ops settings device
25
+ const deviceAction = require('./../actions/settings/device')
26
+ settings
27
+ .command('device')
28
+ .description('print your device pubkey (--unmask)')
29
+ .option('--unmask', 'unmask device pubkey')
30
+ .action(deviceAction)
31
+
32
+ // dotenvx-ops settings hostname
33
+ const hostnameAction = require('./../actions/settings/hostname')
34
+ settings
35
+ .command('hostname')
36
+ .description('print hostname')
37
+ .action(hostnameAction)
38
+
39
+ module.exports = settings