Skip to content

Commit 61f3fdd

Browse files
authored
feat: [OSM-1039] move nodejs plugin functionality (#3)
1 parent 52920d5 commit 61f3fdd

35 files changed

Lines changed: 1669 additions & 202 deletions

.circleci/config.yml

Lines changed: 115 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,135 @@
11
version: 2.1
22

33
orbs:
4-
prodsec: snyk/prodsec-orb@1
4+
win: circleci/windows@2.4.0
5+
prodsec: snyk/prodsec-orb@1.0
56

67
filters_branches_ignore_main: &filters_branches_ignore_main
78
filters:
89
branches:
910
ignore:
1011
- main
1112

13+
defaults: &defaults
14+
parameters:
15+
node_version:
16+
type: string
17+
default: "18.19.1"
18+
working_directory: ~/snyk-nodejs-plugin
19+
20+
windows_defaults: &windows_defaults
21+
environment:
22+
npm_config_loglevel: silent
23+
executor:
24+
name: win/default
25+
26+
test_matrix: &test_matrix
27+
node_version: ['14.17.6', '16.13.2', '18.19.1']
28+
29+
commands:
30+
install_deps:
31+
description: Install dependencies
32+
steps:
33+
- checkout
34+
- run:
35+
name: Use snyk-main npmjs user
36+
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
37+
- run:
38+
name: Install dependencies
39+
command: npm install
40+
install_node_npm:
41+
description: Install correct Node version
42+
parameters:
43+
node_version:
44+
type: string
45+
default: ""
46+
steps:
47+
- run:
48+
name: Install correct version of Node
49+
command: nvm install << parameters.node_version >>
50+
- run:
51+
name: Use correct version of Node
52+
command: nvm use << parameters.node_version >>
53+
show_node_version:
54+
description: Log Node and npm version
55+
steps:
56+
- run:
57+
name: Node version
58+
command: node --version
59+
- run:
60+
name: NPM version
61+
command: npm --version
62+
63+
jobs:
64+
lint:
65+
<<: *defaults
66+
docker:
67+
- image: cimg/node:<< parameters.node_version >>
68+
steps:
69+
- checkout
70+
- install_deps
71+
- show_node_version
72+
- run:
73+
name: Run lint
74+
command: npm run lint
75+
76+
test-windows:
77+
<<: *defaults
78+
<<: *windows_defaults
79+
steps:
80+
- run: git config --global core.autocrlf false
81+
- checkout
82+
- install_node_npm:
83+
node_version: << parameters.node_version >>
84+
- install_deps
85+
- show_node_version
86+
- run:
87+
name: Run tests
88+
command: npm test
89+
90+
test-unix:
91+
<<: *defaults
92+
docker:
93+
- image: cimg/node:<< parameters.node_version >>
94+
steps:
95+
- checkout
96+
- install_deps
97+
- show_node_version
98+
- run:
99+
name: Run tests
100+
command: npm test
101+
12102
workflows:
13103
version: 2
14104
test_and_release:
15105
jobs:
16106
- prodsec/secrets-scan:
17107
name: Scan repository for secrets
18-
trusted-branch: main
19108
context:
20109
- snyk-bot-slack
21110
channel: os-team-managed-alerts
111+
- lint:
112+
name: Lint
113+
context: nodejs-install
114+
node_version: "lts"
115+
- test-windows:
116+
matrix:
117+
alias: test-windows
118+
parameters:
119+
<<: *test_matrix
120+
name: Windows Tests for Node=<< matrix.node_version >>
121+
context: nodejs-install
122+
requires:
123+
- Lint
22124
<<: *filters_branches_ignore_main
125+
- test-unix:
126+
matrix:
127+
alias: test-unix
128+
parameters:
129+
<<: *test_matrix
130+
name: Unix Tests for Node=<< matrix.node_version >>
131+
context: nodejs-install
132+
requires:
133+
- Lint
134+
<<: *filters_branches_ignore_main
135+

.eslintrc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": [
5+
"@typescript-eslint"
6+
],
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/recommended"
10+
],
11+
"rules": {
12+
"@typescript-eslint/no-explicit-any": "off",
13+
"require-await": "warn",
14+
"camelcase": "error",
15+
"default-case": "error",
16+
"default-case-last": "error",
17+
"no-constant-binary-expression": "error",
18+
"no-duplicate-imports": "error",
19+
"no-else-return": "error",
20+
"no-invalid-this": "error",
21+
"no-template-curly-in-string": "error",
22+
"no-use-before-define": "error",
23+
"no-var": "error",
24+
"prefer-const": "error",
25+
"require-atomic-updates": "error",
26+
"spaced-comment": "error",
27+
"yoda": "error"
28+
}
29+
}

.github/CONTRIBUTING.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Contributing
2+
3+
## Commit messages
4+
5+
Commit messages must follow the [Angular-style](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit-message-format) commit format (but excluding the scope).
6+
7+
i.e:
8+
9+
```text
10+
fix: minified scripts being removed
11+
12+
Also includes tests
13+
```
14+
15+
This will allow for the automatic changelog to generate correctly.
16+
17+
### Commit types
18+
19+
Must be one of the following:
20+
21+
- **feat**: A new feature
22+
- **fix**: A bug fix
23+
- **docs**: Documentation only changes
24+
- **test**: Adding missing tests
25+
- **chore**: Changes to the build process or auxiliary tools and libraries such as documentation generation
26+
- **refactor**: A code change that neither fixes a bug nor adds a feature
27+
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
28+
- **perf**: A code change that improves performance
29+
30+
To release a major you need to add `BREAKING CHANGE: ` to the start of the body and the detail of the breaking change.
31+
32+
## Code standards
33+
34+
Ensure that your code adheres to the included `.eslintrc` config by running `npm run lint`.
35+
36+
## Sending pull requests
37+
38+
- add tests for newly added code (and try to mirror directory and file structure if possible)
39+
- spell check
40+
- PRs will not be code reviewed unless all tests are passing (run `npm test`)
41+
42+
_Important:_ when fixing a bug, please commit a **failing test** first demonstrate the current code is failing. Once that commit is in place, then commit the bug fix, so that we can test _before_ and _after_.
43+
44+
Remember that you're developing for multiple platforms and versions of node, so if the tests pass on your Mac or Linux or Windows machine, it _may_ not pass elsewhere.
45+
46+
## Contributor Agreement
47+
48+
A pull-request will only be considered for merging into the upstream codebase after you have signed our [contributor agreement](https://github.com/snyk/snyk-nuget-plugin/blob/main/Contributor-Agreement.md), assigning us the rights to the contributed code and granting you a license to use it in return. If you submit a pull request, you will be prompted to review and sign the agreement with one click (we use [CLA assistant](https://cla-assistant.io/)).

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
- [ ] Tests written and linted
2+
- [ ] Documentation written / README.md updated [https://snyk.io/docs/snyk-for-node/](i)
3+
- [ ] Follows [CONTRIBUTING agreement](CONTRIBUTING.md)
4+
- [ ] Commit history is tidy [https://git-scm.com/book/en/v2/Git-Branching-Rebasing](i)
5+
- [ ] Reviewed by Snyk team
6+
7+
### What this does
8+
9+
_Explain why this PR exists_
10+
11+
### Notes for the reviewer
12+
13+
_Instructions on how to run this locally, background context, what to review, questions…_
14+
15+
### More information
16+
17+
- [SC-XXXX]()
18+
- [Link to documentation]()
19+
20+
### Screenshots
21+
22+
_Visuals that may help the reviewer_
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
on:
2+
schedule:
3+
- cron: "0 0 * * *" # Every day at midnight
4+
workflow_dispatch:
5+
6+
jobs:
7+
stale:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/stale@v7
11+
with:
12+
stale-pr-message: "Your PR has not had any activity for 60 days. In 7 days I'll close it. Make some activity to remove this."
13+
close-pr-message: "Your PR has now been stale for 7 days. I'm closing it."

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.DS_Store
2+
3+
dist
4+
node_modules
5+
./package-lock.json
6+
7+
.eslintcache
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
coverage/
12+
13+
# IDEs
14+
.idea
15+
.vscode
16+
.ionide/

.npmignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.github
2+
.jscsrc
3+
.travis.yml
4+
.vscode
5+
.idea
6+
/dev-test.js
7+
/test

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18

.prettierrc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"overrides": [
5+
{
6+
"files": "*.json",
7+
"options": {
8+
"printWidth": 40,
9+
"parser": "json",
10+
"bracketSpacing": true,
11+
"trailingComma": "none"
12+
}
13+
}
14+
]
15+
}

0 commit comments

Comments
 (0)