@dotenvx/dotenvx-ops 0.29.0 → 0.29.2
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 +13 -1
- package/package.json +1 -1
- package/src/cli/actions/backup.js +10 -6
- package/src/cli/actions/rotate/github/connect.js +1 -1
- package/src/cli/actions/rotate/npm/connect.js +1 -1
- package/src/cli/actions/rotate/openai/connect.js +1 -1
- package/src/cli/actions/sync.js +1 -6
- package/src/lib/api/postBackup.js +4 -1
- package/src/lib/helpers/sha256File.js +9 -0
- package/src/lib/services/backup.js +11 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,19 @@
|
|
|
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-ops/compare/v0.29.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.29.2...main)
|
|
6
|
+
|
|
7
|
+
## [0.29.2](https://github.com/dotenvx/dotenvx-ops/compare/v0.29.1...v0.29.2) (2026-01-07)
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
* Write `.env.x` file as part of smooth onboarding
|
|
12
|
+
|
|
13
|
+
## [0.29.1](https://github.com/dotenvx/dotenvx-ops/compare/v0.29.0...v0.29.1) (2026-01-07)
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
* Send `org` with post to `/backup`
|
|
6
18
|
|
|
7
19
|
## [0.29.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.28.1...v0.29.0) (2026-01-07)
|
|
8
20
|
|
package/package.json
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
1
2
|
const open = require('open')
|
|
3
|
+
|
|
2
4
|
const { logger } = require('@dotenvx/dotenvx')
|
|
3
5
|
|
|
4
6
|
const { createSpinner } = require('./../../lib/helpers/createSpinner')
|
|
@@ -6,6 +8,7 @@ const clipboardy = require('./../../lib/helpers/clipboardy')
|
|
|
6
8
|
const confirm = require('./../../lib/helpers/confirm')
|
|
7
9
|
const formatCode = require('./../../lib/helpers/formatCode')
|
|
8
10
|
const truncate = require('./../../lib/helpers/truncate')
|
|
11
|
+
const sha256File = require('./../../lib/helpers/sha256File')
|
|
9
12
|
|
|
10
13
|
const LoggedIn = require('./../../lib/services/loggedIn')
|
|
11
14
|
const Login = require('./../../lib/services/login')
|
|
@@ -55,14 +58,15 @@ async function backup () {
|
|
|
55
58
|
|
|
56
59
|
const {
|
|
57
60
|
projectUsernameName,
|
|
58
|
-
|
|
61
|
+
projectEnvXSrc,
|
|
62
|
+
projectEnvXFileNeedsWrite
|
|
59
63
|
} = await new Backup(hostname, options.org).run()
|
|
60
|
-
logger.debug(`files: ${JSON.stringify(files)}`)
|
|
61
64
|
|
|
62
|
-
// write
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
// write .env.x
|
|
66
|
+
if (projectEnvXFileNeedsWrite) {
|
|
67
|
+
logger.debug(`writing .env.x`)
|
|
68
|
+
fs.writeFileSync('.env.x', projectEnvXSrc, 'utf8')
|
|
69
|
+
}
|
|
66
70
|
|
|
67
71
|
spinner.stop()
|
|
68
72
|
|
package/src/cli/actions/sync.js
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
|
-
const crypto = require('crypto')
|
|
3
2
|
|
|
4
3
|
const { logger } = require('@dotenvx/dotenvx')
|
|
5
4
|
|
|
6
5
|
const { createSpinner } = require('./../../lib/helpers/createSpinner')
|
|
7
6
|
const pluralize = require('./../../lib/helpers/pluralize')
|
|
7
|
+
const sha256File = require('./../../lib/helpers/sha256File')
|
|
8
8
|
|
|
9
9
|
const Sync = require('./../../lib/services/sync')
|
|
10
10
|
const SyncConflict = require('./../../lib/services/syncConflict')
|
|
11
11
|
|
|
12
12
|
const spinner = createSpinner('syncing')
|
|
13
13
|
|
|
14
|
-
function sha256File (filepath) {
|
|
15
|
-
const buf = fs.readFileSync(filepath)
|
|
16
|
-
return crypto.createHash('sha256').update(buf).digest('hex')
|
|
17
|
-
}
|
|
18
|
-
|
|
19
14
|
async function sync () {
|
|
20
15
|
// debug opts
|
|
21
16
|
const options = this.opts()
|
|
@@ -3,12 +3,13 @@ const buildApiError = require('../../lib/helpers/buildApiError')
|
|
|
3
3
|
const packageJson = require('../../lib/helpers/packageJson')
|
|
4
4
|
|
|
5
5
|
class PostBackup {
|
|
6
|
-
constructor (hostname, token, devicePublicKey, encoded, dotenvxProjectId, pwd = null, gitUrl = null, gitBranch = null, systemUuid = null, osPlatform = null, osArch = null) {
|
|
6
|
+
constructor (hostname, token, devicePublicKey, encoded, dotenvxProjectId = null, org = null, pwd = null, gitUrl = null, gitBranch = null, systemUuid = null, osPlatform = null, osArch = null) {
|
|
7
7
|
this.hostname = hostname || 'https://ops.dotenvx.com'
|
|
8
8
|
this.token = token
|
|
9
9
|
this.devicePublicKey = devicePublicKey
|
|
10
10
|
this.encoded = encoded
|
|
11
11
|
this.dotenvxProjectId = dotenvxProjectId
|
|
12
|
+
this.org = org
|
|
12
13
|
this.pwd = pwd
|
|
13
14
|
this.gitUrl = gitUrl
|
|
14
15
|
this.gitBranch = gitBranch
|
|
@@ -23,6 +24,7 @@ class PostBackup {
|
|
|
23
24
|
const url = `${this.hostname}/api/backup`
|
|
24
25
|
const encoded = this.encoded
|
|
25
26
|
const dotenvxProjectId = this.dotenvxProjectId
|
|
27
|
+
const org = this.org
|
|
26
28
|
const backedupAt = new Date().toISOString()
|
|
27
29
|
const pwd = this.pwd
|
|
28
30
|
const gitUrl = this.gitUrl
|
|
@@ -41,6 +43,7 @@ class PostBackup {
|
|
|
41
43
|
device_public_key: devicePublicKey,
|
|
42
44
|
encoded,
|
|
43
45
|
dotenvx_project_id: dotenvxProjectId,
|
|
46
|
+
org: org,
|
|
44
47
|
backedup_at: backedupAt,
|
|
45
48
|
pwd,
|
|
46
49
|
git_url: gitUrl,
|
|
@@ -25,7 +25,8 @@ class Backup {
|
|
|
25
25
|
const sesh = new Session()
|
|
26
26
|
const token = sesh.token()
|
|
27
27
|
const devicePublicKey = sesh.devicePublicKey()
|
|
28
|
-
let
|
|
28
|
+
let _org = this.org
|
|
29
|
+
let projectEnvXFileNeedsWrite = false
|
|
29
30
|
|
|
30
31
|
// required
|
|
31
32
|
const files = this._files()
|
|
@@ -40,18 +41,20 @@ class Backup {
|
|
|
40
41
|
|
|
41
42
|
// missing .env.x file
|
|
42
43
|
if (!_dotenvxProjectId) {
|
|
44
|
+
projectEnvXFileNeedsWrite = true // for writing
|
|
45
|
+
|
|
43
46
|
// set org
|
|
44
|
-
if (!
|
|
47
|
+
if (!_org) {
|
|
45
48
|
const choices = accountJson.organizations.map(o => ({
|
|
46
49
|
name: o.provider_slug,
|
|
47
50
|
value: o.provider_slug
|
|
48
51
|
}))
|
|
49
52
|
|
|
50
53
|
if (choices.length === 1) {
|
|
51
|
-
|
|
54
|
+
_org = choices[0].value // just use first choice
|
|
52
55
|
} else {
|
|
53
|
-
|
|
54
|
-
message: 'Select
|
|
56
|
+
_org = await prompts.select({
|
|
57
|
+
message: 'Select org',
|
|
55
58
|
choices
|
|
56
59
|
})
|
|
57
60
|
}
|
|
@@ -70,12 +73,14 @@ class Backup {
|
|
|
70
73
|
const _osPlatform = osInfo.platform
|
|
71
74
|
const _osArch = osInfo.arch
|
|
72
75
|
|
|
73
|
-
const data = await new PostBackup(this.hostname, token, devicePublicKey, encoded, _dotenvxProjectId, _pwd, _gitUrl, _gitBranch, _systemUuid, _osPlatform, _osArch).run()
|
|
76
|
+
const data = await new PostBackup(this.hostname, token, devicePublicKey, encoded, _dotenvxProjectId, _org, _pwd, _gitUrl, _gitBranch, _systemUuid, _osPlatform, _osArch).run()
|
|
74
77
|
|
|
75
78
|
return {
|
|
76
79
|
id: data.id,
|
|
77
80
|
dotenvxProjectId: data.dotenvx_project_id,
|
|
78
81
|
projectUsernameName: data.project_username_name,
|
|
82
|
+
projectEnvXSrc: data.project_env_x_src,
|
|
83
|
+
projectEnvXFileNeedsWrite,
|
|
79
84
|
files: data.files
|
|
80
85
|
}
|
|
81
86
|
}
|