Skip to content

Commit

Permalink
Use npm run instead of Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
timokoessler committed Jan 10, 2025
1 parent 927f4f2 commit 72d307d
Show file tree
Hide file tree
Showing 15 changed files with 911 additions and 158 deletions.
15 changes: 8 additions & 7 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ First off, thanks for taking the time to contribute! ❤️
All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉

> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
>
> - Star the project
> - Tweet about it
> - Refer this project in your project's readme
Expand Down Expand Up @@ -64,7 +65,7 @@ We use GitHub issues to track bugs and errors. If you run into an issue with the

- Open an [Issue](https://github.com/AikidoSec/firewall-node/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
- Explain the behavior you would expect and the actual behavior.
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
- Please provide as much context as possible and describe the _reproduction steps_ that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
- Provide the information you collected in the previous section.

Once it's filed:
Expand Down Expand Up @@ -96,12 +97,12 @@ Enhancement suggestions are tracked as [GitHub issues](https://github.com/Aikido
### Your First Code Contribution

- clone the repository to your local machine
- run `$ make install` to install dependencies
- run `$ make build` to build the library
- run `$ make watch` to watch for changes and rebuild the library
- run `$ make test` to run tests using tap
- run `$ make end2end` to run end-to-end tests using tap
- run `$ make lint` to run ESLint
- run `$ npm install` to install dependencies
- run `$ npm run build` to build the library
- run `$ npm run watch` to watch for changes and rebuild the library
- run `$ npm t` to run tests using tap
- run `$ npm run end2end` to run end-to-end tests using tap
- run `$ npm run lint` to run ESLint

## Styleguides

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y wrk
- run: make install
- run: make build
- run: npm install
- run: npm run build
- name: Run NoSQL Injection Benchmark
run: cd benchmarks/nosql-injection && AIKIDO_CI=true node benchmark.js
- name: Run SQL Injection Benchmark
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ jobs:
registry-url: "https://registry.npmjs.org"
scope: "@aikidosec"
- name: Install dependencies
run: make install
run: npm install
- name: Get the version
id: get_version
run: echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
- name: Set the version
run: cd library && npm --no-git-tag-version version ${{ steps.get_version.outputs.tag }}
- name: Build the library
run: make build
run: npm run build
- name: Linting
run: make lint
run: npm run lint
- name: Publish to NPM
run: |
if [ "${{ github.event.release.prerelease }}" = "true" ]; then
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ jobs:
- name: Build and run server
run: |
cd end2end/server && docker build -t server . && docker run -d -p 5874:3000 server
- run: make install
- run: make build
- run: make end2end
- run: npm install
- run: npm run build
- run: npm run end2end
6 changes: 3 additions & 3 deletions .github/workflows/lint-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- run: make install-lib-only
- run: make build
- run: make lint
- run: npm run install-lib-only
- run: npm run build
- run: npm run lint
6 changes: 3 additions & 3 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ jobs:
- name: Add local.aikido.io to /etc/hosts
run: |
sudo echo "127.0.0.1 local.aikido.io" | sudo tee -a /etc/hosts
- run: make install-lib-only
- run: make build
- run: make test-ci
- run: npm run install-lib-only
- run: npm run build
- run: npm run test:ci
- name: "Upload coverage"
uses: codecov/[email protected]
with:
Expand Down
74 changes: 0 additions & 74 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
INTERNALS_VERSION = v0.1.34
INTERNALS_URL = https://github.com/AikidoSec/zen-internals/releases/download/$(INTERNALS_VERSION)
TARBALL = zen_internals.tgz
CHECKSUM_FILE = zen_internals.tgz.sha256sum
INTERNALS_DIR = library/internals

.PHONY: containers
containers:
cd sample-apps && docker-compose up -d --remove-orphans

.PHONY: express-mongodb
express-mongodb:
cd sample-apps/express-mongodb && AIKIDO_DEBUG=true AIKIDO_BLOCKING=true node app.js
Expand Down Expand Up @@ -87,67 +77,3 @@ fastify-clickhouse:
.PHONY: hono-prisma
hono-prisma:
cd sample-apps/hono-prisma && AIKIDO_DEBUG=true AIKIDO_BLOCK=true node app.js

NPM_INSTALL_CMD := $(if $(CI),ci,install)

.PHONY: install-lib-only
install-lib-only:
mkdir -p build
node scripts/copyPackageJSON.js
touch build/index.js
npm $(NPM_INSTALL_CMD)
cd library && npm $(NPM_INSTALL_CMD)

.PHONY: install
install: install-lib-only
cd end2end && npm $(NPM_INSTALL_CMD)
node scripts/install.js

.PHONY: build
build: $(INTERNALS_DIR)/zen_internals.js
mkdir -p build
rm -r build
cd library && npm run build
cp README.md build/README.md
cp LICENSE build/LICENSE
cp library/package.json build/package.json
mkdir -p build/internals
cp $(INTERNALS_DIR)/zen_internals_bg.wasm build/internals/zen_internals_bg.wasm

$(INTERNALS_DIR)/zen_internals.js: Makefile
curl -L $(INTERNALS_URL)/$(TARBALL) -o $(INTERNALS_DIR)/$(TARBALL)
curl -L $(INTERNALS_URL)/$(CHECKSUM_FILE) -o $(INTERNALS_DIR)/$(CHECKSUM_FILE)
cd $(INTERNALS_DIR) && sha256sum -c $(CHECKSUM_FILE)
tar -xzf $(INTERNALS_DIR)/$(TARBALL) -C $(INTERNALS_DIR)
touch $@
rm $(INTERNALS_DIR)/zen_internals.d.ts
rm $(INTERNALS_DIR)/$(TARBALL)
rm $(INTERNALS_DIR)/$(CHECKSUM_FILE)

.PHONY: watch
watch: build
cd library && npm run build:watch

.PHONY: test
test:
cd library && npm run test

.PHONY: test-ci
test-ci:
cd library && npm run test:ci

.PHONY: lint
lint:
cd library && npm run lint

.PHONY: end2end
end2end:
cd end2end && npm run test

benchmark: build
cd benchmarks/nosql-injection && AIKIDO_CI=true node benchmark.js
cd benchmarks/shell-injection && node benchmark.js
cd benchmarks/sql-injection && node benchmark.js
cd benchmarks/hono-pg && node benchmark.js
cd benchmarks/api-discovery && node benchmark.js
cd benchmarks/express && node benchmark.js
Loading

0 comments on commit 72d307d

Please sign in to comment.