Skip to content

Commit

Permalink
feat: Revert the Release of the Extensible CLI via npm
Browse files Browse the repository at this point in the history
This reverts commit 84446aa.
  • Loading branch information
PeterSchafer committed Feb 14, 2023
1 parent 150fd95 commit 69298f6
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 6,695 deletions.
7 changes: 3 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,7 @@ jobs:
cp cliv2/bin/snyk-linux-arm64 binary-releases/snyk-linux-arm64
cp cliv2/bin/snyk-linux-arm64.sha256 binary-releases/snyk-linux-arm64.sha256
- run:
name: Making TS-Binary-Wrapper (snyk.tgz)
command: make binary-releases/snyk.tgz
- run:
name: Signing all shasums
name: Signing shasums
command: make binary-releases/sha256sums.txt.asc
- run:
name: Making release.json
Expand Down Expand Up @@ -1031,6 +1028,7 @@ workflows:
matrix:
parameters:
artifact:
- snyk.tgz
- snyk-fix.tgz
- snyk-protect.tgz
- snyk-alpine
Expand Down Expand Up @@ -1076,6 +1074,7 @@ workflows:
context:
- snyk-cli-pgp-signing
requires:
- Build (snyk.tgz)
- Build (snyk-fix.tgz)
- Build (snyk-protect.tgz)
- Build (snyk-alpine)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:
run: |
which snyk
snyk version
shellspec -f d --skip-message quiet --no-warning-as-failure
shellspec -f d --skip-message quiet
- name: Run shellspec tests - Windows
if: ${{ matrix.os == 'windows' }}
Expand Down
33 changes: 10 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ help:
@echo 'Use `npm run` for CLIv1 scripts.'

$(BINARY_RELEASES_FOLDER_TS_CLI):
@mkdir -p $(BINARY_RELEASES_FOLDER_TS_CLI)
@mkdir $(BINARY_RELEASES_FOLDER_TS_CLI)

$(BINARY_RELEASES_FOLDER_TS_CLI)/version: | $(BINARY_RELEASES_FOLDER_TS_CLI)
./release-scripts/next-version.sh > $(BINARY_RELEASES_FOLDER_TS_CLI)/version

ifneq ($(BINARY_OUTPUT_FOLDER), $(BINARY_RELEASES_FOLDER_TS_CLI))
$(BINARY_OUTPUT_FOLDER):
@mkdir -p $(BINARY_OUTPUT_FOLDER)

$(BINARY_OUTPUT_FOLDER)/version: $(BINARY_OUTPUT_FOLDER) $(BINARY_RELEASES_FOLDER_TS_CLI)/version
$(BINARY_OUTPUT_FOLDER)/version: $(BINARY_RELEASES_FOLDER_TS_CLI)/version
@cp $(BINARY_RELEASES_FOLDER_TS_CLI)/version $(BINARY_OUTPUT_FOLDER)/version
endif

Expand All @@ -41,26 +38,25 @@ endif
# Only removing "prepack" is not enough. We need to do additional cleanup (see clean-prepack).
.INTERMEDIATE: prepack
.SECONDARY: prepack
prepack: $(BINARY_OUTPUT_FOLDER)/version
prepack: $(BINARY_RELEASES_FOLDER_TS_CLI)/version
@echo "'make prepack' was run. Run 'make clean-prepack' to rollback your package.json changes and this file." > prepack
npm version "$(shell cat $(BINARY_RELEASES_FOLDER_TS_CLI)/version)" --no-git-tag-version --workspaces --include-workspace-root
cd $(BINARY_WRAPPER_DIR) && npm version "$(shell cat $(CURDIR)/$(BINARY_RELEASES_FOLDER_TS_CLI)/version)" --no-git-tag-version --include-workspace-root
npx ts-node ./release-scripts/prune-dependencies-in-packagejson.ts

.PHONY: clean-prepack
clean-prepack:
git checkout package.json package-lock.json packages/*/package.json packages/*/package-lock.json $(BINARY_WRAPPER_DIR)/package.json $(BINARY_WRAPPER_DIR)/package-lock.json
git checkout package.json package-lock.json packages/*/package.json packages/*/package-lock.json
rm -f prepack

.PHONY: clean-ts
clean-ts:
npm run clean
rm -f -r $(BINARY_RELEASES_FOLDER_TS_CLI)

$(BINARY_OUTPUT_FOLDER)/sha256sums.txt.asc:
$(BINARY_OUTPUT_FOLDER)/sha256sums.txt.asc: $(wildcard $(BINARY_OUTPUT_FOLDER)/*.sha256)
./release-scripts/sha256sums.txt.asc.sh

$(BINARY_OUTPUT_FOLDER)/release.json: $(BINARY_OUTPUT_FOLDER)/version
$(BINARY_OUTPUT_FOLDER)/release.json: $(BINARY_OUTPUT_FOLDER)/version $(wildcard $(BINARY_OUTPUT_FOLDER)/*.sha256)
./release-scripts/release.json.sh

# --commit-path is forwarded to `git log <path>`.
Expand All @@ -75,8 +71,8 @@ $(BINARY_OUTPUT_FOLDER)/RELEASE_NOTES.md: prepack | $(BINARY_RELEASES_FOLDER_TS_
%.sha256: %
cd $(@D); shasum -a 256 $(<F) > $(@F); shasum -a 256 -c $(@F)

$(BINARY_RELEASES_FOLDER_TS_CLI)/snyk.tgz: prepack | $(BINARY_RELEASES_FOLDER_TS_CLI)
$(MAKE) pack-binary-wrapper
$(BINARY_RELEASES_FOLDER_TS_CLI)/snyk.tgz: prepack | $(BINARY_RELEASES_FOLDER_TS_CLI)
mv $(shell npm pack) $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk.tgz
$(MAKE) $(BINARY_RELEASES_FOLDER_TS_CLI)/snyk.tgz.sha256

$(BINARY_RELEASES_FOLDER_TS_CLI)/snyk-fix.tgz: prepack | $(BINARY_RELEASES_FOLDER_TS_CLI)
Expand Down Expand Up @@ -125,17 +121,8 @@ $(BINARY_RELEASES_FOLDER_TS_CLI)/docker-mac-signed-bundle.tar.gz: prepack | $(BI
$(MAKE) $(BINARY_RELEASES_FOLDER_TS_CLI)/docker-mac-signed-bundle.tar.gz.sha256

# targets responsible for the Wrapper CLI (TS around Golang)
$(BINARY_WRAPPER_DIR)/README.md:
@cp ./README.md $(BINARY_WRAPPER_DIR)/README.md

$(BINARY_WRAPPER_DIR)/SECURITY.md:
@cp ./SECURITY.md $(BINARY_WRAPPER_DIR)/SECURITY.md

$(BINARY_WRAPPER_DIR)/LICENSE:
@cp ./LICENSE $(BINARY_WRAPPER_DIR)/LICENSE

$(BINARY_WRAPPER_DIR)/src/generated:
@mkdir -p $(BINARY_WRAPPER_DIR)/src/generated/
@mkdir $(BINARY_WRAPPER_DIR)/src/generated/

$(BINARY_WRAPPER_DIR)/src/generated/version: $(BINARY_WRAPPER_DIR)/src/generated $(BINARY_RELEASES_FOLDER_TS_CLI)/version
@cp $(BINARY_RELEASES_FOLDER_TS_CLI)/version $(BINARY_WRAPPER_DIR)/src/generated/version
Expand All @@ -145,7 +132,7 @@ $(BINARY_WRAPPER_DIR)/src/generated/sha256sums.txt:
@cat $(BINARY_OUTPUT_FOLDER)/*.sha256 > $(BINARY_WRAPPER_DIR)/src/generated/sha256sums.txt

.PHONY: build-binary-wrapper
build-binary-wrapper: $(BINARY_WRAPPER_DIR)/src/generated/version $(BINARY_WRAPPER_DIR)/src/generated/sha256sums.txt $(BINARY_WRAPPER_DIR)/README.md $(BINARY_WRAPPER_DIR)/SECURITY.md $(BINARY_WRAPPER_DIR)/LICENSE
build-binary-wrapper: $(BINARY_WRAPPER_DIR)/src/generated/version $(BINARY_WRAPPER_DIR)/src/generated/sha256sums.txt
@echo "-- Building Typescript Binary Wrapper ($(BINARY_WRAPPER_DIR)/dist/)"
@cd $(BINARY_WRAPPER_DIR) && npm run build

Expand Down
2 changes: 1 addition & 1 deletion test/smoke/docker-root/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16
FROM node:12

COPY ./smoke/ /snyk/smoke/
COPY ./fixtures/ /snyk/fixtures/
Expand Down
7 changes: 3 additions & 4 deletions test/smoke/docker-root/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/sh

set -ex
set -e

whoami
npm --version
echo "Install Snyk CLI with npm"
npm install snyk -g
snyk --version
su node -c "snyk --version"

shellspec -f d
2 changes: 1 addition & 1 deletion test/smoke/run-shellspec-win.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
echo "run-shellscript-win.sh"

/c/Users/runneradmin/.local/bin/shellspec -f d --skip-message quiet --no-warning-as-failure
/c/Users/runneradmin/.local/bin/shellspec -f d --skip-message quiet
10 changes: 10 additions & 0 deletions test/smoke/spec/snyk_code_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Describe "Snyk Code test command"
The output should include "Static code analysis"
The output should include "✗ [High] SQL Injection"
The status should be failure
if should_have_deprecation_warnings; then
The stderr should not equal ""
else
The stderr should equal ""
fi
End
End

Expand All @@ -24,6 +29,11 @@ Describe "Snyk Code test command"
The status should be failure # issues found
The output should include '"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json"'
The output should include '"name": "SnykCode"'
if should_have_deprecation_warnings; then
The stderr should not equal ""
else
The stderr should equal ""
fi
The result of function check_valid_json should be success
End
End
Expand Down
15 changes: 15 additions & 0 deletions test/smoke/spec/snyk_monitor_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,35 @@ Describe "Snyk monitor command"
The status should be success
The output should include "Explore this snapshot at https://app.snyk.io/org/"
The output should include "Notifications about newly disclosed issues related to these dependencies will be emailed to you."
if should_have_deprecation_warnings; then
The stderr should not equal ""
else
The stderr should equal ""
fi
End

It "monitors a project when pointing to a folder"
When run snyk monitor ../fixtures/basic-npm
The status should be success
The output should include "Explore this snapshot at https://app.snyk.io/org/"
The output should include "Notifications about newly disclosed issues related to these dependencies will be emailed to you."
if should_have_deprecation_warnings; then
The stderr should not equal ""
else
The stderr should equal ""
fi
End

It "monitors a project when pointing to a file"
When run snyk monitor --file=../fixtures/basic-npm/package.json
The status should be success
The output should include "Explore this snapshot at https://app.snyk.io/org/"
The output should include "Notifications about newly disclosed issues related to these dependencies will be emailed to you."
if should_have_deprecation_warnings; then
The stderr should not equal ""
else
The stderr should equal ""
fi
End
End

Expand Down
15 changes: 15 additions & 0 deletions test/smoke/spec/snyk_test_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,33 @@ Describe "Snyk test command"
When run run_test_in_subfolder
The status should equal 1
The output should include "https://security.snyk.io/vuln/npm:minimatch:20160620"
if should_have_deprecation_warnings; then
The stderr should not equal ""
else
The stderr should equal ""
fi
End

It "finds vulns in a project when pointing to a folder"
When run snyk test ../fixtures/basic-npm
The status should be failure # issues found
The output should include "https://security.snyk.io/vuln/npm:minimatch:20160620"
if should_have_deprecation_warnings; then
The stderr should not equal ""
else
The stderr should equal ""
fi
End

It "finds vulns in a project when pointing to a file"
When run snyk test --file=../fixtures/basic-npm/package.json
The status should be failure # issues found
The output should include "https://security.snyk.io/vuln/npm:minimatch:20160620"
if should_have_deprecation_warnings; then
The stderr should not equal ""
else
The stderr should equal ""
fi
End

It "tests a library on a specific version when passed a library@version"
Expand Down
10 changes: 10 additions & 0 deletions test/smoke/spec/spec_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,14 @@ spec_helper_configure() {
snyk() {
eval "${SNYK_COMMAND:=$ORIGINAL_SNYK_EXECUTABLE}" "$@"
}

should_have_deprecation_warnings() {
# deprecated node version will show additional stderr output for deprecation notices
if command -v node > /dev/null 2>&1; then
if node --version | grep -Eq "^v12.*"; then
return 0
fi
fi
return 1
}
}
2 changes: 0 additions & 2 deletions ts-binary-wrapper/bin/snyk

This file was deleted.

Loading

0 comments on commit 69298f6

Please sign in to comment.