@herodevs/cli 2.0.0-beta.15 → 2.0.0-beta.17
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/README.md +8 -20
- package/bin/main.js +2 -6
- package/dist/api/ci-token.client.d.ts +1 -0
- package/dist/api/ci-token.client.js +1 -1
- package/dist/api/user-setup.client.d.ts +3 -0
- package/dist/api/user-setup.client.js +2 -2
- package/dist/commands/auth/provision-ci-token.js +10 -0
- package/dist/service/auth.svc.d.ts +2 -2
- package/dist/service/auth.svc.js +6 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -38,18 +38,6 @@ npx @herodevs/cli@beta
|
|
|
38
38
|
npm install -g @herodevs/cli@beta
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
#### Binary Installation
|
|
42
|
-
|
|
43
|
-
HeroDevs CLI is available as a binary installation, without requiring `npm`. To do that, you may either download and run the script manually, or use the following cURL or Wget command:
|
|
44
|
-
|
|
45
|
-
```sh
|
|
46
|
-
curl -o- https://raw.githubusercontent.com/herodevs/cli/v2.0.0-beta.15/scripts/install.sh | bash
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
```sh
|
|
50
|
-
wget -qO- https://raw.githubusercontent.com/herodevs/cli/v2.0.0-beta.15/scripts/install.sh | bash
|
|
51
|
-
```
|
|
52
|
-
|
|
53
41
|
## Scanning Behavior
|
|
54
42
|
|
|
55
43
|
The CLI is designed to be non-invasive:
|
|
@@ -72,7 +60,7 @@ $ npm install -g @herodevs/cli@beta
|
|
|
72
60
|
$ hd COMMAND
|
|
73
61
|
running command...
|
|
74
62
|
$ hd (--version)
|
|
75
|
-
@herodevs/cli/2.0.0-beta.
|
|
63
|
+
@herodevs/cli/2.0.0-beta.16 darwin-arm64 node-v24.10.0
|
|
76
64
|
$ hd --help [COMMAND]
|
|
77
65
|
USAGE
|
|
78
66
|
$ hd COMMAND
|
|
@@ -104,7 +92,7 @@ DESCRIPTION
|
|
|
104
92
|
OAuth CLI login
|
|
105
93
|
```
|
|
106
94
|
|
|
107
|
-
_See code: [src/commands/auth/login.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
95
|
+
_See code: [src/commands/auth/login.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.16/src/commands/auth/login.ts)_
|
|
108
96
|
|
|
109
97
|
## `hd auth logout`
|
|
110
98
|
|
|
@@ -118,7 +106,7 @@ DESCRIPTION
|
|
|
118
106
|
Logs out of HeroDevs OAuth and clears stored tokens
|
|
119
107
|
```
|
|
120
108
|
|
|
121
|
-
_See code: [src/commands/auth/logout.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
109
|
+
_See code: [src/commands/auth/logout.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.16/src/commands/auth/logout.ts)_
|
|
122
110
|
|
|
123
111
|
## `hd auth provision-ci-token`
|
|
124
112
|
|
|
@@ -132,7 +120,7 @@ DESCRIPTION
|
|
|
132
120
|
Provision a CI/CD long-lived refresh token for headless auth
|
|
133
121
|
```
|
|
134
122
|
|
|
135
|
-
_See code: [src/commands/auth/provision-ci-token.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
123
|
+
_See code: [src/commands/auth/provision-ci-token.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.16/src/commands/auth/provision-ci-token.ts)_
|
|
136
124
|
|
|
137
125
|
## `hd help [COMMAND]`
|
|
138
126
|
|
|
@@ -188,7 +176,7 @@ EXAMPLES
|
|
|
188
176
|
$ hd report committers --csv
|
|
189
177
|
```
|
|
190
178
|
|
|
191
|
-
_See code: [src/commands/report/committers.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
179
|
+
_See code: [src/commands/report/committers.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.16/src/commands/report/committers.ts)_
|
|
192
180
|
|
|
193
181
|
## `hd scan eol`
|
|
194
182
|
|
|
@@ -240,7 +228,7 @@ EXAMPLES
|
|
|
240
228
|
$ hd scan eol --json
|
|
241
229
|
```
|
|
242
230
|
|
|
243
|
-
_See code: [src/commands/scan/eol.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
231
|
+
_See code: [src/commands/scan/eol.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.16/src/commands/scan/eol.ts)_
|
|
244
232
|
|
|
245
233
|
## `hd tracker init`
|
|
246
234
|
|
|
@@ -274,7 +262,7 @@ EXAMPLES
|
|
|
274
262
|
$ hd tracker init -o
|
|
275
263
|
```
|
|
276
264
|
|
|
277
|
-
_See code: [src/commands/tracker/init.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
265
|
+
_See code: [src/commands/tracker/init.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.16/src/commands/tracker/init.ts)_
|
|
278
266
|
|
|
279
267
|
## `hd tracker run`
|
|
280
268
|
|
|
@@ -299,7 +287,7 @@ EXAMPLES
|
|
|
299
287
|
$ hd tracker run -d tracker -f settings.json
|
|
300
288
|
```
|
|
301
289
|
|
|
302
|
-
_See code: [src/commands/tracker/run.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
290
|
+
_See code: [src/commands/tracker/run.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.16/src/commands/tracker/run.ts)_
|
|
303
291
|
|
|
304
292
|
## `hd update [CHANNEL]`
|
|
305
293
|
|
package/bin/main.js
CHANGED
|
@@ -7,13 +7,9 @@ async function main(isProduction = false) {
|
|
|
7
7
|
strict: false, // Don't validate flags
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
// If no arguments at all, default to
|
|
10
|
+
// If no arguments at all, default to help
|
|
11
11
|
if (positionals.length === 0) {
|
|
12
|
-
process.argv.splice(2, 0, '
|
|
13
|
-
}
|
|
14
|
-
// If only flags are provided, set scan:eol as the command for those flags
|
|
15
|
-
else if (positionals.length === 1 && positionals[0].startsWith('-')) {
|
|
16
|
-
process.argv.splice(2, 0, 'scan:eol');
|
|
12
|
+
process.argv.splice(2, 0, 'help');
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
try {
|
|
@@ -91,5 +91,5 @@ export async function provisionCIToken(options = {}) {
|
|
|
91
91
|
throw new Error('Either orgId or previousToken is required to provision a CI token');
|
|
92
92
|
}
|
|
93
93
|
const result = await getOrgAccessTokens(input);
|
|
94
|
-
return { refresh_token: result.refreshToken };
|
|
94
|
+
return { access_token: result.accessToken, refresh_token: result.refreshToken };
|
|
95
95
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
export declare function getUserSetupStatus(options?: {
|
|
2
2
|
preferOAuth?: boolean;
|
|
3
|
+
orgAccessToken?: string;
|
|
3
4
|
}): Promise<{
|
|
4
5
|
isComplete: boolean;
|
|
5
6
|
orgId?: number | null;
|
|
6
7
|
}>;
|
|
7
8
|
export declare function completeUserSetup(options?: {
|
|
8
9
|
preferOAuth?: boolean;
|
|
10
|
+
orgAccessToken?: string;
|
|
9
11
|
}): Promise<{
|
|
10
12
|
isComplete: boolean;
|
|
11
13
|
orgId?: number | null;
|
|
12
14
|
}>;
|
|
13
15
|
export declare function ensureUserSetup(options?: {
|
|
14
16
|
preferOAuth?: boolean;
|
|
17
|
+
orgAccessToken?: string;
|
|
15
18
|
}): Promise<number>;
|
|
@@ -18,7 +18,7 @@ function extractErrorCode(errors) {
|
|
|
18
18
|
return code;
|
|
19
19
|
}
|
|
20
20
|
export async function getUserSetupStatus(options) {
|
|
21
|
-
const tokenProvider = getTokenProvider(options?.preferOAuth);
|
|
21
|
+
const tokenProvider = getTokenProvider(options?.preferOAuth, options?.orgAccessToken);
|
|
22
22
|
const client = createApollo(getGraphqlUrl(), tokenProvider);
|
|
23
23
|
const res = await client.query({ query: userSetupStatusQuery });
|
|
24
24
|
const errors = getGraphQLErrors(res);
|
|
@@ -46,7 +46,7 @@ export async function getUserSetupStatus(options) {
|
|
|
46
46
|
return { isComplete: status.isComplete, orgId: status.orgId ?? undefined };
|
|
47
47
|
}
|
|
48
48
|
export async function completeUserSetup(options) {
|
|
49
|
-
const tokenProvider = getTokenProvider(options?.preferOAuth);
|
|
49
|
+
const tokenProvider = getTokenProvider(options?.preferOAuth, options?.orgAccessToken);
|
|
50
50
|
const client = createApollo(getGraphqlUrl(), tokenProvider);
|
|
51
51
|
const res = await client.mutate({ mutation: completeUserSetupMutation });
|
|
52
52
|
const errors = getGraphQLErrors(res);
|
|
@@ -41,6 +41,16 @@ export default class AuthProvisionCiToken extends Command {
|
|
|
41
41
|
}
|
|
42
42
|
try {
|
|
43
43
|
const result = await provisionCIToken({ orgId });
|
|
44
|
+
try {
|
|
45
|
+
await ensureUserSetup({ orgAccessToken: result.access_token });
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
track('CLI CI Token Provision Failed', () => ({
|
|
49
|
+
command: 'auth provision-ci-token',
|
|
50
|
+
error: `user_setup_failed:${getErrorMessage(error)}`,
|
|
51
|
+
}));
|
|
52
|
+
this.error(`User Org setup failed. ${getErrorMessage(error)}`);
|
|
53
|
+
}
|
|
44
54
|
const refreshToken = result.refresh_token;
|
|
45
55
|
saveCIToken(refreshToken);
|
|
46
56
|
this.log('CI token provisioned and saved locally.');
|
|
@@ -11,7 +11,7 @@ export declare const AUTH_ERROR_MESSAGES: {
|
|
|
11
11
|
readonly FORBIDDEN: "You do not have permission to perform this action.";
|
|
12
12
|
readonly NOT_LOGGED_IN_GENERIC: "You are not logged in. Please run an \"auth login\" command to authenticate.";
|
|
13
13
|
};
|
|
14
|
-
export declare function getTokenForScanWithSource(preferOAuth?: boolean): Promise<{
|
|
14
|
+
export declare function getTokenForScanWithSource(preferOAuth?: boolean, orgAccessToken?: string): Promise<{
|
|
15
15
|
token: string;
|
|
16
16
|
source: TokenSource;
|
|
17
17
|
}>;
|
|
@@ -21,7 +21,7 @@ export declare class AuthError extends Error {
|
|
|
21
21
|
}
|
|
22
22
|
export declare function persistTokenResponse(token: TokenResponse): Promise<void>;
|
|
23
23
|
export declare function getAccessToken(): Promise<string | undefined>;
|
|
24
|
-
export declare function getTokenProvider(preferOAuth?: boolean): TokenProvider;
|
|
24
|
+
export declare function getTokenProvider(preferOAuth?: boolean, orgAccessToken?: string): TokenProvider;
|
|
25
25
|
export declare function requireAccessToken(): Promise<string>;
|
|
26
26
|
export declare function logoutLocally(): Promise<void>;
|
|
27
27
|
export declare const requireAccessTokenForScan: TokenProvider;
|
package/dist/service/auth.svc.js
CHANGED
|
@@ -11,7 +11,10 @@ export const AUTH_ERROR_MESSAGES = {
|
|
|
11
11
|
FORBIDDEN: 'You do not have permission to perform this action.',
|
|
12
12
|
NOT_LOGGED_IN_GENERIC: 'You are not logged in. Please run an "auth login" command to authenticate.',
|
|
13
13
|
};
|
|
14
|
-
export async function getTokenForScanWithSource(preferOAuth) {
|
|
14
|
+
export async function getTokenForScanWithSource(preferOAuth, orgAccessToken) {
|
|
15
|
+
if (orgAccessToken) {
|
|
16
|
+
return { token: orgAccessToken, source: 'ci' };
|
|
17
|
+
}
|
|
15
18
|
if (preferOAuth) {
|
|
16
19
|
const token = await requireAccessToken();
|
|
17
20
|
return { token, source: 'oauth' };
|
|
@@ -69,9 +72,9 @@ export async function getAccessToken() {
|
|
|
69
72
|
await persistTokenResponse(refreshed);
|
|
70
73
|
return refreshed.access_token;
|
|
71
74
|
}
|
|
72
|
-
export function getTokenProvider(preferOAuth) {
|
|
75
|
+
export function getTokenProvider(preferOAuth, orgAccessToken) {
|
|
73
76
|
return async (_forceRefresh) => {
|
|
74
|
-
const { token } = await getTokenForScanWithSource(preferOAuth);
|
|
77
|
+
const { token } = await getTokenForScanWithSource(preferOAuth, orgAccessToken);
|
|
75
78
|
return token;
|
|
76
79
|
};
|
|
77
80
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herodevs/cli",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.17",
|
|
4
4
|
"author": "HeroDevs, Inc",
|
|
5
5
|
"bin": {
|
|
6
6
|
"hd": "./bin/run.js"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@amplitude/analytics-node": "^1.5.26",
|
|
46
46
|
"@apollo/client": "^4.0.9",
|
|
47
47
|
"@cyclonedx/cdxgen": "^12.1.1",
|
|
48
|
-
"@herodevs/eol-shared": "github:herodevs/eol-shared#v0.1.
|
|
48
|
+
"@herodevs/eol-shared": "github:herodevs/eol-shared#v0.1.18",
|
|
49
49
|
"@inquirer/prompts": "^8.0.2",
|
|
50
50
|
"@napi-rs/keyring": "^1.2.0",
|
|
51
51
|
"@oclif/core": "^4.8.0",
|