@herodevs/cli 2.0.0-beta.15 → 2.0.0-beta.16
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 +10 -10
- 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 +1 -1
package/README.md
CHANGED
|
@@ -43,11 +43,11 @@ npm install -g @herodevs/cli@beta
|
|
|
43
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
44
|
|
|
45
45
|
```sh
|
|
46
|
-
curl -o- https://raw.githubusercontent.com/herodevs/cli/v2.0.0-beta.
|
|
46
|
+
curl -o- https://raw.githubusercontent.com/herodevs/cli/v2.0.0-beta.16/scripts/install.sh | bash
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
```sh
|
|
50
|
-
wget -qO- https://raw.githubusercontent.com/herodevs/cli/v2.0.0-beta.
|
|
50
|
+
wget -qO- https://raw.githubusercontent.com/herodevs/cli/v2.0.0-beta.16/scripts/install.sh | bash
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
## Scanning Behavior
|
|
@@ -72,7 +72,7 @@ $ npm install -g @herodevs/cli@beta
|
|
|
72
72
|
$ hd COMMAND
|
|
73
73
|
running command...
|
|
74
74
|
$ hd (--version)
|
|
75
|
-
@herodevs/cli/2.0.0-beta.
|
|
75
|
+
@herodevs/cli/2.0.0-beta.16 darwin-arm64 node-v24.10.0
|
|
76
76
|
$ hd --help [COMMAND]
|
|
77
77
|
USAGE
|
|
78
78
|
$ hd COMMAND
|
|
@@ -104,7 +104,7 @@ DESCRIPTION
|
|
|
104
104
|
OAuth CLI login
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
_See code: [src/commands/auth/login.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
107
|
+
_See code: [src/commands/auth/login.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.16/src/commands/auth/login.ts)_
|
|
108
108
|
|
|
109
109
|
## `hd auth logout`
|
|
110
110
|
|
|
@@ -118,7 +118,7 @@ DESCRIPTION
|
|
|
118
118
|
Logs out of HeroDevs OAuth and clears stored tokens
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
_See code: [src/commands/auth/logout.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
121
|
+
_See code: [src/commands/auth/logout.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.16/src/commands/auth/logout.ts)_
|
|
122
122
|
|
|
123
123
|
## `hd auth provision-ci-token`
|
|
124
124
|
|
|
@@ -132,7 +132,7 @@ DESCRIPTION
|
|
|
132
132
|
Provision a CI/CD long-lived refresh token for headless auth
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
_See code: [src/commands/auth/provision-ci-token.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
135
|
+
_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
136
|
|
|
137
137
|
## `hd help [COMMAND]`
|
|
138
138
|
|
|
@@ -188,7 +188,7 @@ EXAMPLES
|
|
|
188
188
|
$ hd report committers --csv
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
-
_See code: [src/commands/report/committers.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
191
|
+
_See code: [src/commands/report/committers.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.16/src/commands/report/committers.ts)_
|
|
192
192
|
|
|
193
193
|
## `hd scan eol`
|
|
194
194
|
|
|
@@ -240,7 +240,7 @@ EXAMPLES
|
|
|
240
240
|
$ hd scan eol --json
|
|
241
241
|
```
|
|
242
242
|
|
|
243
|
-
_See code: [src/commands/scan/eol.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
243
|
+
_See code: [src/commands/scan/eol.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.16/src/commands/scan/eol.ts)_
|
|
244
244
|
|
|
245
245
|
## `hd tracker init`
|
|
246
246
|
|
|
@@ -274,7 +274,7 @@ EXAMPLES
|
|
|
274
274
|
$ hd tracker init -o
|
|
275
275
|
```
|
|
276
276
|
|
|
277
|
-
_See code: [src/commands/tracker/init.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
277
|
+
_See code: [src/commands/tracker/init.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.16/src/commands/tracker/init.ts)_
|
|
278
278
|
|
|
279
279
|
## `hd tracker run`
|
|
280
280
|
|
|
@@ -299,7 +299,7 @@ EXAMPLES
|
|
|
299
299
|
$ hd tracker run -d tracker -f settings.json
|
|
300
300
|
```
|
|
301
301
|
|
|
302
|
-
_See code: [src/commands/tracker/run.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.
|
|
302
|
+
_See code: [src/commands/tracker/run.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.16/src/commands/tracker/run.ts)_
|
|
303
303
|
|
|
304
304
|
## `hd update [CHANNEL]`
|
|
305
305
|
|
|
@@ -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
|
}
|