@dotenvx/dotenvx 2.35.0 → 2.36.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/v2.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v2.36.0...main)
|
|
6
|
+
|
|
7
|
+
## [2.36.0](https://github.com/dotenvx/dotenvx/compare/v2.35.0...v2.36.0) (2026-10-14)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
* Add `dotenvx armor invite` command ([#1025](https://github.com/dotenvx/dotenvx/pull/1025))
|
|
6
12
|
|
|
7
13
|
## [2.35.0](https://github.com/dotenvx/dotenvx/compare/v2.34.2...v2.35.0) (2026-10-13)
|
|
8
14
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const { logger } = require('../../../shared/logger')
|
|
2
|
+
const Session = require('../../../db/session')
|
|
3
|
+
const ArmorInvite = require('../../../lib/services/armorInvite')
|
|
4
|
+
|
|
5
|
+
async function invite () {
|
|
6
|
+
const options = this.opts()
|
|
7
|
+
const sesh = new Session()
|
|
8
|
+
await sesh.notifyUpdate()
|
|
9
|
+
const hostname = options.hostname || sesh.hostname()
|
|
10
|
+
const token = options.token || sesh.token()
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
const { team, email } = await new ArmorInvite(hostname, token, options.team, options.email).run()
|
|
14
|
+
logger.success(`⛨ invited ${email} to ${team}`)
|
|
15
|
+
} catch (error) {
|
|
16
|
+
logger.error(error.message)
|
|
17
|
+
return { exitCode: 1, error }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = invite
|
|
@@ -81,6 +81,17 @@ function configureArmorCommand (armor) {
|
|
|
81
81
|
return commandAction(require('./../actions/armor/move')).apply(this, args)
|
|
82
82
|
})
|
|
83
83
|
|
|
84
|
+
// dotenvx armor invite
|
|
85
|
+
armor
|
|
86
|
+
.command('invite')
|
|
87
|
+
.description('invite a member to your team')
|
|
88
|
+
.option('--team <team>', 'team to invite member to')
|
|
89
|
+
.option('--email <email>', 'email address to invite')
|
|
90
|
+
.option('--token <token>', 'set token')
|
|
91
|
+
.action(function (...args) {
|
|
92
|
+
return commandAction(require('./../actions/armor/invite')).apply(this, args)
|
|
93
|
+
})
|
|
94
|
+
|
|
84
95
|
// dotenvx armor login
|
|
85
96
|
armor
|
|
86
97
|
.command('login')
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { http } = require('../helpers/http')
|
|
2
|
+
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
+
const normalizeToken = require('../helpers/normalizeToken')
|
|
4
|
+
|
|
5
|
+
class GetTeams {
|
|
6
|
+
constructor (hostname, token) {
|
|
7
|
+
this.hostname = hostname
|
|
8
|
+
this.token = token
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async run () {
|
|
12
|
+
const teams = []
|
|
13
|
+
let page = 1
|
|
14
|
+
while (page) {
|
|
15
|
+
const resp = await http(`${this.hostname}/api/teams?page=${page}`, {
|
|
16
|
+
method: 'GET',
|
|
17
|
+
headers: { Authorization: `Bearer ${normalizeToken(this.token)}` }
|
|
18
|
+
})
|
|
19
|
+
const json = await resp.body.json()
|
|
20
|
+
if (resp.statusCode >= 400) throw buildApiError(resp.statusCode, json)
|
|
21
|
+
teams.push(...json.teams)
|
|
22
|
+
page = json.meta && json.meta.next_page
|
|
23
|
+
}
|
|
24
|
+
return { teams }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = GetTeams
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { http } = require('../helpers/http')
|
|
2
|
+
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
+
const normalizeToken = require('../helpers/normalizeToken')
|
|
4
|
+
|
|
5
|
+
class PostTeamInvitation {
|
|
6
|
+
constructor (hostname, token, team, email) {
|
|
7
|
+
this.hostname = hostname
|
|
8
|
+
this.token = token
|
|
9
|
+
this.team = team
|
|
10
|
+
this.email = email
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async run () {
|
|
14
|
+
const resp = await http(`${this.hostname}/api/teams/${encodeURIComponent(this.team)}/invitations`, {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: {
|
|
17
|
+
Authorization: `Bearer ${normalizeToken(this.token)}`,
|
|
18
|
+
'Content-Type': 'application/json'
|
|
19
|
+
},
|
|
20
|
+
body: JSON.stringify({ email: this.email, role: 'member' })
|
|
21
|
+
})
|
|
22
|
+
const json = await resp.body.json()
|
|
23
|
+
if (resp.statusCode >= 400) throw buildApiError(resp.statusCode, json)
|
|
24
|
+
return json
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = PostTeamInvitation
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const prompts = require('../helpers/prompts')
|
|
2
|
+
const GetTeams = require('../api/getTeams')
|
|
3
|
+
const PostTeamInvitation = require('../api/postTeamInvitation')
|
|
4
|
+
|
|
5
|
+
class ArmorInvite {
|
|
6
|
+
constructor (hostname, token, team, email) {
|
|
7
|
+
this.hostname = hostname
|
|
8
|
+
this.token = token
|
|
9
|
+
this.team = team
|
|
10
|
+
this.email = email
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async run () {
|
|
14
|
+
let team = this.team
|
|
15
|
+
let email = this.email
|
|
16
|
+
const context = { input: process.stdin, output: process.stderr }
|
|
17
|
+
if ((!team || !email) && !process.stdin.isTTY) {
|
|
18
|
+
throw new Error('provide --team and --email when running non-interactively')
|
|
19
|
+
}
|
|
20
|
+
if (!team) {
|
|
21
|
+
const { teams } = await new GetTeams(this.hostname, this.token).run()
|
|
22
|
+
const choices = teams
|
|
23
|
+
.filter(team => ['owner', 'admin'].includes(team.current_user_role))
|
|
24
|
+
.map(team => ({ name: team.slug, value: team.slug }))
|
|
25
|
+
if (!choices.length) throw new Error('no teams available to invite members to (requires owner or admin role)')
|
|
26
|
+
team = await prompts.select({ message: 'Select team', prefix: '⛨', choices }, context)
|
|
27
|
+
}
|
|
28
|
+
if (!email) email = await prompts.input({ message: 'Email address' }, context)
|
|
29
|
+
email = email.trim()
|
|
30
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) throw new Error('enter a valid email address')
|
|
31
|
+
const json = await new PostTeamInvitation(this.hostname, this.token, team, email).run()
|
|
32
|
+
return { ...json, team, email }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = ArmorInvite
|