Skip to content

Commit d03dc18

Browse files
authored
Merge pull request #2 from CheckmarxDev/benalvo/create-runtime-wrapper
JS Wrapper | Remove CLI from the wrapper and download from S3 (AST-64803)
2 parents e6281ef + 18407b8 commit d03dc18

29 files changed

+9094
-5427
lines changed

.gitattributes

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/scripts/update_cli.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,17 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- uses: actions/checkout@v4
9-
with:
10-
lfs: true
11-
12-
- name: Install Git LFS
13-
run: |
14-
sudo apt-get update
15-
sudo apt-get install git-lfs
16-
git lfs install
179

18-
- name: Use Node.js 14
10+
- name: Use Node.js 16
1911
uses: actions/[email protected]
2012
with:
21-
node-version: 14
13+
node-version: 16
2214
registry-url: https://npm.pkg.github.com/
2315
- run: npm ci
2416
- name: Code Linting
2517
run: npm run lint
2618
- run: npm run build --if-present
2719

28-
- name: Check existence of cx-linux binary
29-
run: |
30-
if [ ! -f "src/main/wrapper/resources/cx-linux" ]; then
31-
echo "cx-linux binary does not exist"; exit 1;
32-
fi
33-
34-
- name: Check existence of cx.exe binary
35-
run: |
36-
if [ ! -f "src/main/wrapper/resources/cx.exe" ]; then
37-
echo "cx.exe binary does not exist"; exit 1;
38-
fi
39-
40-
- name: Check existence of cx-mac binary
41-
run: |
42-
if [ ! -f "src/main/wrapper/resources/cx-mac" ]; then
43-
echo "cx-mac binary does not exist"; exit 1;
44-
fi
45-
4620
- name: Run tests
4721
env:
4822
CX_CLIENT_ID: ${{ secrets.CX_CLIENT_ID}}

.github/workflows/delete-packages-and-releases.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ jobs:
3030
3131
echo "Deleting all npm packages whose name ends with '-${{inputs.tag}}.0'"
3232
33-
VERSION_IDS=($(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/orgs/CheckmarxDev/packages/npm/ast-cli-javascript-wrapper/versions | jq '.[]|select(.name | contains("-${{inputs.tag}}.0"))|.id'))
33+
VERSION_IDS=($(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/orgs/CheckmarxDev/packages/npm/ast-cli-javascript-wrapper-runtime-cli/versions | jq '.[]|select(.name | contains("-${{inputs.tag}}.0"))|.id'))
3434
3535
for versionId in "${VERSION_IDS[@]}"
3636
do
3737
echo "Deleting version $versionId..."
38-
curl -L -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/orgs/CheckmarxDev/packages/npm/ast-cli-javascript-wrapper/versions/$versionId"
38+
curl -L -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/orgs/CheckmarxDev/packages/npm/ast-cli-javascript-wrapper-runtime-cli/versions/$versionId"
3939
echo "Version $versionId deleted successfully!"
4040
done
4141

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ on:
1212

1313
jobs:
1414
nightly:
15-
uses: CheckmarxDev/ast-cli-javascript-wrapper/.github/workflows/release.yml@main
15+
uses: CheckmarxDev/ast-cli-javascript-wrapper-runtime-cli/.github/workflows/release.yml@main
1616
secrets: inherit

.github/workflows/release.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ permissions:
4242

4343
jobs:
4444
delete:
45-
uses: CheckmarxDev/ast-cli-javascript-wrapper/.github/workflows/delete-packages-and-releases.yml@main
45+
uses: CheckmarxDev/ast-cli-javascript-wrapper-runtime-cli/.github/workflows/delete-packages-and-releases.yml@main
4646
with:
4747
tag: ${{ inputs.jsTag }}
4848
secrets: inherit
@@ -58,7 +58,6 @@ jobs:
5858
- uses: actions/checkout@v4
5959
with:
6060
fetch-depth: 0
61-
lfs: true # Ensure LFS files are checked out
6261

6362
# GIT CONFIGURATION
6463
- run: |
@@ -80,14 +79,6 @@ jobs:
8079
echo "TAG_NAME=$(npm version patch --no-git-tag-version)" >> $GITHUB_ENV
8180
fi
8281
83-
# DOWNLOAD CLI IF IT IS A DEV VERSION AND A CLI TAG WAS PROVIDED
84-
- name: Download cli with tag ${{ inputs.cliTag }}
85-
if: inputs.dev == true && inputs.cliTag != ''
86-
run: |
87-
# Update binaries
88-
chmod +x ./.github/scripts/update_cli.sh
89-
./.github/scripts/update_cli.sh ${{ inputs.cliTag }}
90-
9182
# RUN NPM INSTALL AND BUILD
9283
- name: NPM ci and build
9384
run: |

.github/workflows/update-cli.yml

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,53 @@
1-
name: Update checkmarx ast cli
1+
name: Update Checkmarx AST CLI
2+
23
on:
34
workflow_dispatch:
5+
inputs:
6+
new_cli_version:
7+
description: 'New CLI version (optional)'
8+
required: false
49
schedule:
510
- cron: '0 0 * * *'
611

712
jobs:
813
update-checkmarx-cli:
914
runs-on: ubuntu-latest
15+
1016
steps:
1117
- uses: actions/checkout@v4
12-
with:
13-
lfs: true
14-
15-
- name: Install Git LFS
16-
run: |
17-
sudo apt-get update
18-
sudo apt-get install git-lfs
19-
git lfs install
20-
21-
- name: Configure Git user
22-
run: |
23-
git config --global user.name github-actions
24-
git config --global user.email [email protected]
2518

19+
# Fetch the latest Checkmarx AST CLI version
2620
- name: Get Latest Checkmarx API version
2721
id: checkmarx-ast-cli
2822
run: |
29-
echo ::set-output name=release_tag::$(curl -sL https://api.github.com/repos/Checkmarx/ast-cli/releases/latest | jq -r ".tag_name")
30-
echo ::set-output name=current_tag::$(<checkmarx-ast-cli.version)
23+
if [ "${{ github.event.inputs.new_cli_version }}" ]; then
24+
LATEST_VERSION=${{ github.event.inputs.new_cli_version }}
25+
else
26+
LATEST_VERSION=$(curl -sL https://api.github.com/repos/Checkmarx/ast-cli/releases/latest | jq -r ".tag_name")
27+
fi
28+
CURRENT_VERSION=$(<checkmarx-ast-cli.version)
29+
echo ::set-output name=release_tag::$LATEST_VERSION
30+
echo ::set-output name=current_tag::$CURRENT_VERSION
3131
32-
- name: Update Checkmarx cli version
32+
# Update the version file if the latest version differs
33+
- name: Update Checkmarx CLI version in version file
3334
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
3435
env:
3536
RELEASE_TAG: ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
3637
run: |
37-
# Update current release
3838
echo ${{ steps.checkmarx-ast-cli.outputs.release_tag }} > checkmarx-ast-cli.version
3939
40-
- name: Download latest cli and update branch
41-
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
42-
run: |
43-
# Update binaries
44-
chmod +x ./.github/scripts/update_cli.sh
45-
./.github/scripts/update_cli.sh ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
46-
47-
- name: Track large files with Git LFS
40+
# Update the TypeScript file's cliDefaultVersion field
41+
- name: Update cliDefaultVersion in CxInstaller.ts
4842
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
43+
env:
44+
NEW_CLI_VERSION: ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
4945
run: |
50-
git lfs track "src/main/wrapper/resources/cx-linux"
51-
git lfs track "src/main/wrapper/resources/cx.exe"
52-
git lfs track "src/main/wrapper/resources/cx-mac"
53-
git add .gitattributes
54-
git add src/main/wrapper/resources/cx-linux src/main/wrapper/resources/cx.exe src/main/wrapper/resources/cx-mac
55-
git commit -m "Track Checkmarx CLI binaries with Git LFS"
46+
FILE_PATH="src/main/osinstaller/CxInstaller.ts"
47+
# Ensure that 'cliDefaultVersion' is updated correctly
48+
sed -i "s/\(cliDefaultVersion = '\)[^']*\(';\)/\1${NEW_CLI_VERSION}\2/" $FILE_PATH
5649
50+
# Create a Pull Request with the version changes
5751
- name: Create Pull Request
5852
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
5953
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c #v6

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<img src="./logo.png" alt="Logo" width="80" height="80">
66
</a>
77

8-
<h3 align="center">AST-CLI-JAVASCRIPT-WRAPPER</h3>
8+
<h3 align="center">AST-CLI-JAVASCRIPT-WRAPPER-RUNTIME-CLI</h3>
99

1010
<!-- TABLE OF CONTENTS -->
1111
<details open="open">
@@ -40,7 +40,7 @@ Add the following dependency:
4040

4141
```
4242
"dependencies": {
43-
"@checkmarxdev/ast-cli-javascript-wrapper": "{version}"
43+
"@checkmarxdev/ast-cli-javascript-wrapper-runtime-cli": "{version}"
4444
}
4545
```
4646

@@ -86,7 +86,7 @@ setx PATH_TO_EXECUTABLE {value}
8686

8787
Checkmarx - AST Integrations Team
8888

89-
CxProject Link: [https://github.com/CheckmarxDev/ast-cli-javascript-wrapper](https://github.com/CheckmarxDev/ast-cli-javascript-wrapper)
89+
CxProject Link: [https://github.com/CheckmarxDev/ast-cli-javascript-wrapper-runtime-cli](https://github.com/CheckmarxDev/ast-cli-javascript-wrapper-runtime-cli)
9090

9191

9292
© 2021 Checkmarx Ltd. All Rights Reserved.

checkmarx-ast-cli.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.6
1+
2.2.5

0 commit comments

Comments
 (0)