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 8002be9de6a3f426c8fb5ca237f8271905bcc916.
  • Loading branch information
PeterSchafer committed Mar 6, 2023
1 parent 1e09ff7 commit 19f8721
Show file tree
Hide file tree
Showing 25 changed files with 245 additions and 7,514 deletions.
35 changes: 4 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,13 @@ jobs:
- setup_npm
- run:
name: Building project
command: |
make pre-build
npm run build:prod
command: npm run build:prod
- persist_to_workspace:
root: .
paths:
- dist/
- packages/*/dist
- pysrc
- ts-binary-wrapper/
version:
executor: docker-node
steps:
Expand Down Expand Up @@ -578,10 +575,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 @@ -990,22 +984,6 @@ jobs:
- cliv2/bin/snyk_windows_amd64.exe
- cliv2/bin/snyk_windows_amd64.exe.sha256

test-in-proxy-environment-linux-amd64:
executor: linux
working_directory: /home/circleci/snyk
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Run acceptance tests in a proxied environment
working_directory: ./
environment:
TEST_SNYK_COMMAND: ./bin/snyk-linux
command: |
export SNYK_TOKEN="${SNYK_API_KEY}"
make acceptance-test-with-proxy
workflows:
version: 2
test_and_release:
Expand Down Expand Up @@ -1059,6 +1037,7 @@ workflows:
matrix:
parameters:
artifact:
- snyk.tgz
- snyk-fix.tgz
- snyk-protect.tgz
- snyk-alpine
Expand Down Expand Up @@ -1119,6 +1098,7 @@ workflows:
context:
- snyk-cli-pgp-signing
requires:
- Build (snyk.tgz)
- Build (snyk-fix.tgz)
- Build (snyk-protect.tgz)
- Build (snyk-alpine)
Expand Down Expand Up @@ -1338,10 +1318,3 @@ workflows:
- v2 / Rename linux/arm64 artifact
- v2 / Rename macos/amd64 artifact
- v2 / Rename windows/amd64 artifact
- test-in-proxy-environment-linux-amd64:
filters:
branches:
ignore: master
name: v2 / Acceptance Tests With Proxy (linux/amd64)
requires:
- v2 / Rename linux/amd64 artifact
2 changes: 1 addition & 1 deletion .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,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
66 changes: 13 additions & 53 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,20 +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/binary-deployments.json: $(BINARY_WRAPPER_DIR)/src/generated
@cp ./binary-deployments.json $(BINARY_WRAPPER_DIR)/src/generated/binary-deployments.json

$(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 @@ -148,59 +132,35 @@ $(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: pre-build-binary-wrapper $(BINARY_WRAPPER_DIR)/src/generated/version $(BINARY_WRAPPER_DIR)/src/generated/sha256sums.txt
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

.PHONY: clean-binary-wrapper
clean-binary-wrapper:
@rm -f $(BINARY_WRAPPER_DIR)/config.default.json
@rm -f $(BINARY_WRAPPER_DIR)/src/generated/binary-deployments.json
@rm -f $(BINARY_WRAPPER_DIR)/README.md
@rm -f $(BINARY_WRAPPER_DIR)/SECURITY.md
@rm -f $(BINARY_WRAPPER_DIR)/LICENSE
@rm -rf $(BINARY_WRAPPER_DIR)/src/generated
@rm -rf $(BINARY_WRAPPER_DIR)/help
@rm -rf $(BINARY_WRAPPER_DIR)/pysrc
@cd $(BINARY_WRAPPER_DIR) && npm run clean

.PHONY: pre-build-binary-wrapper
pre-build-binary-wrapper: $(BINARY_WRAPPER_DIR)/README.md $(BINARY_WRAPPER_DIR)/SECURITY.md $(BINARY_WRAPPER_DIR)/LICENSE $(BINARY_WRAPPER_DIR)/src/generated/binary-deployments.json

# for compatibility reasons, we pack the legacy and the ts-binary-wrapper next to each other
.PHONY: pack-binary-wrapper
pack-binary-wrapper: build-binary-wrapper
@echo "-- Packaging tarball ($(BINARY_OUTPUT_FOLDER)/snyk.tgz)"
release-scripts/create-npm-artifact.sh $(BINARY_OUTPUT_FOLDER) $(BINARY_WRAPPER_DIR)

@mv $(BINARY_WRAPPER_DIR)/$(shell cd $(BINARY_WRAPPER_DIR) && npm pack) $(BINARY_OUTPUT_FOLDER)/snyk.tgz

.PHONY: test-binary-wrapper
test-binary-wrapper: build-binary-wrapper
test-binary-wrapper:
@echo "-- Testing binary wrapper"
@cd $(BINARY_WRAPPER_DIR) && npm run test


# targets responsible for the complete CLI build
.PHONY: pre-build
pre-build: pre-build-binary-wrapper $(BINARY_RELEASES_FOLDER_TS_CLI)

.PHONY: build
build: pre-build
build:
@cd $(EXTENSIBLE_CLI_DIR) && $(MAKE) build-full install bindir=$(CURDIR)/$(BINARY_OUTPUT_FOLDER) USE_LEGACY_EXECUTABLE_NAME=1

.PHONY: clean
clean:
@cd $(EXTENSIBLE_CLI_DIR) && $(MAKE) clean-full
$(MAKE) clean-prepack

# targets responsible for the testing of CLI build
.PHONY: acceptance-test-with-proxy
acceptance-test-with-proxy:
@echo "-- Running acceptance tests in a proxied environment"
@docker build -t acceptance-test-with-proxy -f ./test/acceptance/environments/proxy/Dockerfile .
@docker run --rm --cap-add=NET_ADMIN acceptance-test-with-proxy ./node_modules/.bin/jest ./ts-binary-wrapper/test/acceptance/basic.spec.ts
# TODO: Run all acceptance tests behind a proxy using npm run test:acceptance

# targets responsible for the CLI release
.PHONY: release-pre
release-pre:
Expand Down
16 changes: 0 additions & 16 deletions binary-deployments.json

This file was deleted.

29 changes: 0 additions & 29 deletions release-scripts/create-npm-artifact.sh

This file was deleted.

41 changes: 0 additions & 41 deletions test/acceptance/environments/proxy/Dockerfile

This file was deleted.

31 changes: 0 additions & 31 deletions test/acceptance/environments/proxy/entrypoint.sh

This file was deleted.

27 changes: 0 additions & 27 deletions test/acceptance/environments/proxy/settings.xml

This file was deleted.

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
Loading

0 comments on commit 19f8721

Please sign in to comment.