Skip to content

Commit a68ae7e

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/oclif/plugin-help-6.2.35
2 parents 9ccd463 + 91b4406 commit a68ae7e

File tree

7 files changed

+710
-847
lines changed

7 files changed

+710
-847
lines changed

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.2.2/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.3/schema.json",
33
"assist": { "actions": { "source": { "organizeImports": "on" } } },
44
"linter": {
55
"enabled": true,

e2e/scan/eol.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ describe('scan:eol e2e', () => {
9393

9494
describe('default arguments', () => {
9595
it('runs scan:eol with file flag and shows results', async () => {
96-
const { stdout } = await execAsync(`node bin/run.js scan:eol --file ${simpleSbom}`);
96+
const { stdout } = await run(`scan:eol --file ${simpleSbom}`);
9797
match(stdout, /Scan results:/, 'Should show results header');
9898
match(stdout, /1( .*)End-of-Life \(EOL\)/, 'Should show EOL count of 1');
9999
match(stdout, /total packages scanned/i, 'Should show total packages scanned');
100100
});
101101

102102
it('runs scan:eol with --json and produces valid JSON', async () => {
103-
const { stdout } = await execAsync(`node bin/run.js scan:eol --file ${simpleSbom} --json`);
103+
const { stdout } = await run(`scan:eol --file ${simpleSbom} --json`);
104104
doesNotMatch(stdout, /Scan results:/, 'Should not show results header');
105105
doesNotThrow(() => JSON.parse(stdout), 'Output should be valid JSON');
106106
});

package-lock.json

Lines changed: 673 additions & 750 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,28 @@
3939
"herodevs cli"
4040
],
4141
"dependencies": {
42-
"@amplitude/analytics-node": "^1.5.21",
43-
"@apollo/client": "^3.13.8",
42+
"@amplitude/analytics-node": "^1.5.22",
43+
"@apollo/client": "^4.0.9",
4444
"@cyclonedx/cdxgen": "^11.11.0",
4545
"@herodevs/eol-shared": "github:herodevs/eol-shared#v0.1.12",
4646
"@oclif/core": "^4.8.0",
4747
"@oclif/plugin-help": "^6.2.35",
48-
"@oclif/plugin-update": "^4.7.13",
48+
"@oclif/plugin-update": "^4.7.14",
4949
"node-machine-id": "^1.1.12",
5050
"ora": "^9.0.0",
5151
"packageurl-js": "^2.0.1",
5252
"terminal-link": "^5.0.0",
5353
"update-notifier": "^7.3.1"
5454
},
5555
"devDependencies": {
56-
"@biomejs/biome": "^2.3.3",
56+
"@biomejs/biome": "^2.3.4",
5757
"@oclif/test": "^4.1.13",
5858
"@types/inquirer": "^9.0.9",
5959
"@types/node": "^24.10.0",
6060
"@types/sinon": "^17.0.4",
6161
"@types/update-notifier": "^6.0.8",
6262
"globstar": "^1.0.0",
63-
"oclif": "^4.22.38",
63+
"oclif": "^4.22.47",
6464
"shx": "^0.4.0",
6565
"sinon": "^21.0.0",
6666
"ts-node": "^10.9.2",
@@ -110,4 +110,4 @@
110110
}
111111
},
112112
"types": "dist/index.d.ts"
113-
}
113+
}

scripts/install.sh

Lines changed: 6 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ set -o pipefail # Catch errors in piped commands
2121
# - Proper cleanup of temporary files
2222
# - Error handling for failed operations
2323
#
24-
# Usage:
25-
# Beta release: curl -sSfL https://raw.githubusercontent.com/herodevs/cli/refs/heads/main/scripts/install.sh | bash
26-
# Latest release: curl -sSfL https://raw.githubusercontent.com/herodevs/cli/refs/heads/main/scripts/install.sh | bash -s -- --latest
24+
# Usage: curl -sSfL https://raw.githubusercontent.com/herodevs/cli/refs/heads/main/scripts/install.sh | bash
2725
#=============================================================================
2826

2927
# Configuration
@@ -34,8 +32,7 @@ INSTALL_DIR="$HOME/.herodevs"
3432
BIN_DIR="$INSTALL_DIR/bin"
3533
GITHUB_API_URL="https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases"
3634
TMP_DIR=""
37-
USE_BETA=true
38-
# LATEST_VERSION="v2.0.0-beta.13"
35+
LATEST_VERSION="v2.0.0-beta.13"
3936
DEBUG=${DEBUG:-}
4037

4138
# Colors for output
@@ -81,26 +78,6 @@ error_exit() {
8178
exit 1
8279
}
8380

84-
# Parse arguments
85-
while [ $# -gt 0 ]; do
86-
case $1 in
87-
-l | --latest)
88-
USE_BETA=false
89-
shift
90-
;;
91-
-h | --help)
92-
# Help text goes to the original stdout
93-
emit "Usage: $0 [-l|--latest]"
94-
emit " -l, --latest Install latest release (default: install beta)"
95-
emit " -h, --help Show this help message"
96-
exit 0
97-
;;
98-
*)
99-
error_exit "Unknown option: $1"
100-
;;
101-
esac
102-
done
103-
10481
# Cleanup on exit/interrupt
10582
cleanup() {
10683
if [ -n "$TMP_DIR" ] && [ -d "$TMP_DIR" ]; then
@@ -113,49 +90,6 @@ trap cleanup EXIT INT TERM
11390

11491
log "INFO" "Installing HeroDevs CLI"
11592

116-
# Get release version (beta or latest)
117-
get_version() {
118-
local use_beta="$1"
119-
local releases_data="$2"
120-
121-
log "INFO" "Extracting release version"
122-
local all_tags
123-
local latest_release
124-
local beta_release
125-
local version_tag
126-
127-
# Split complex command chains for Bash 3 compatibility
128-
all_tags=$(echo "$releases_data" | grep -o '"tag_name": "[^"]*"')
129-
all_tags=$(echo "$all_tags" | cut -d'"' -f4)
130-
131-
# Get latest non-beta release
132-
latest_release=$(echo "$all_tags" | grep -v "beta" | head -n 1)
133-
134-
# Get latest beta release
135-
beta_release=$(echo "$all_tags" | grep "beta" | head -n 1)
136-
137-
log "DEBUG" "All tags: $all_tags"
138-
log "DEBUG" "Latest release: $latest_release"
139-
log "DEBUG" "Beta release: $beta_release"
140-
141-
if [ "$use_beta" = "true" ]; then
142-
version_tag="$beta_release"
143-
if [ -z "$version_tag" ]; then
144-
log "ERROR" "No beta release found. Please try again later or use --latest to install the latest stable release."
145-
exit 1
146-
fi
147-
else
148-
version_tag="$latest_release"
149-
if [ -z "$version_tag" ]; then
150-
error_exit "No latest release found. Please try again later."
151-
fi
152-
fi
153-
154-
log "INFO" "Using version: $version_tag"
155-
# Output actual return value to the original stdout (FD 3)
156-
emit "$version_tag"
157-
}
158-
15993
# Download and install
16094
install() {
16195
# Fetch releases from GitHub
@@ -171,21 +105,13 @@ install() {
171105
error_exit "Empty response from GitHub API. Please try again later."
172106
fi
173107

174-
# Ensure the response contains release data
175-
if ! echo "$releases" | grep -q '"tag_name"'; then
176-
error_exit "Invalid response from GitHub API. Please try again later."
177-
fi
178-
179-
# Determine VERSION_TAG
180-
VERSION_TAG=$(get_version "$USE_BETA" "$releases" 3>&1 1>&2)
181-
182-
local version_tag="$VERSION_TAG"
108+
local version_tag="$LATEST_VERSION"
183109

184110
# Remove 'v' prefix if present
185111
local version
186112
version=${version_tag#v}
187113

188-
log "DEBUG" "Version string: $version"
114+
log "INFO" "Installing version: $version"
189115

190116
# Detect system
191117
local os
@@ -207,7 +133,7 @@ install() {
207133
pattern="${os}-${arch}"
208134

209135
# Extract all browser_download_url values for the matching release
210-
release_block=$(echo "$releases" | awk -v tag="\"$VERSION_TAG\"" '
136+
release_block=$(echo "$releases" | awk -v tag="\"$LATEST_VERSION\"" '
211137
BEGIN {found=0; block=""}
212138
$0 ~ tag {found=1}
213139
found {
@@ -227,7 +153,7 @@ install() {
227153

228154
# Ensure we found a matching asset
229155
if [ -z "$download_url" ]; then
230-
error_exit "No release found system $pattern for release $VERSION_TAG"
156+
error_exit "No release found system $pattern for release $LATEST_VERSION"
231157
fi
232158

233159
log "DEBUG" "Download URL: $download_url"

src/api/gql-operations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { gql } from '@apollo/client/core/core.cjs';
1+
import { gql } from '@apollo/client/core';
22

33
export const createReportMutation = gql`
44
mutation createReport($input: CreateEolReportInput) {

src/api/nes.client.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client/core/index.js';
1+
import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client/core';
22
import type {
33
CreateEolReportInput,
44
EolReport,
55
EolReportMutationResponse,
66
EolReportQueryResponse,
77
GetEolReportInput,
88
} from '@herodevs/eol-shared';
9+
import type { GraphQLFormattedError } from 'graphql';
910
import { config } from '../config/constants.ts';
1011
import { debugLogger } from '../service/log.svc.ts';
1112
import { stripTypename } from '../utils/strip-typename.ts';
1213
import { createReportMutation, getEolReportQuery } from './gql-operations.ts';
1314

15+
type GraphQLExecutionResult = {
16+
errors?: ReadonlyArray<GraphQLFormattedError>;
17+
};
18+
1419
export const createApollo = (uri: string) =>
1520
new ApolloClient({
1621
cache: new InMemoryCache(),
@@ -28,13 +33,17 @@ export const createApollo = (uri: string) =>
2833

2934
export const SbomScanner = (client: ReturnType<typeof createApollo>) => {
3035
return async (input: CreateEolReportInput): Promise<EolReport> => {
31-
const res = await client.mutate<EolReportMutationResponse, { input: CreateEolReportInput }>({
36+
let res: Awaited<ReturnType<typeof client.mutate<EolReportMutationResponse, { input: CreateEolReportInput }>>>;
37+
res = await client.mutate<EolReportMutationResponse, { input: CreateEolReportInput }>({
3238
mutation: createReportMutation,
3339
variables: { input },
3440
});
3541

36-
if (res?.errors?.length) {
37-
debugLogger('GraphQL errors in createReport: %o', res.errors);
42+
if (res?.error || (res as GraphQLExecutionResult)?.errors) {
43+
debugLogger(
44+
'Error returned from createReport mutation: %o',
45+
res.error || (res as GraphQLExecutionResult | undefined)?.errors,
46+
);
3847
throw new Error('Failed to create EOL report');
3948
}
4049

@@ -64,11 +73,16 @@ export const SbomScanner = (client: ReturnType<typeof createApollo>) => {
6473

6574
for (let i = 0; i < pages.length; i += config.concurrentPageRequests) {
6675
const batch = pages.slice(i, i + config.concurrentPageRequests);
67-
const batchResponses = await Promise.all(batch);
76+
let batchResponses: Awaited<
77+
ReturnType<typeof client.query<EolReportQueryResponse, { input: GetEolReportInput }>>
78+
>[];
79+
80+
batchResponses = await Promise.all(batch);
6881

6982
for (const response of batchResponses) {
70-
if (response?.errors?.length) {
71-
debugLogger('GraphQL errors in getReport query: %o', response.errors);
83+
const queryErrors = (response as GraphQLExecutionResult | undefined)?.errors;
84+
if (response?.error || queryErrors?.length || !response.data?.eol) {
85+
debugLogger('Error in getReport query response: %o', response?.error ?? queryErrors ?? response);
7286
throw new Error('Failed to fetch EOL report');
7387
}
7488

0 commit comments

Comments
 (0)