From a7ec6fd5bf6c300898a2b944e97d505b7544bc54 Mon Sep 17 00:00:00 2001 From: ghe Date: Sun, 31 May 2020 21:38:45 +0100 Subject: [PATCH] fix: add .releaserc change import variable --- .releaserc | 63 ++++++++++++++++++++++++++++++++++++++ README.md | 5 +-- package.json | 4 ++- src/lib/get-import-path.ts | 2 +- 4 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 .releaserc diff --git a/.releaserc b/.releaserc new file mode 100644 index 00000000..fa818c98 --- /dev/null +++ b/.releaserc @@ -0,0 +1,63 @@ +{ + "prepare": [ + "@semantic-release/npm", + { + "//": "adds a file to identify a build as a standalone binary", + "path": "@semantic-release/exec", + "cmd": "echo '' > dist/STANDALONE" + }, + { + "//": "build the alpine, macos, linux and windows binaries", + "path": "@semantic-release/exec", + "cmd": "npx pkg . -t node12-linux-x64,node12-macos-x64,node12-win-x64", + }, + { + "//": "shasum all binaries", + "path": "@semantic-release/exec", + "cmd": "shasum -a 256 snyk-import-linux > snyk-import-linux.sha256 && shasum -a 256 snyk-import-macos > snyk-import-macos.sha256 && shasum -a 256 snyk-import-win.exe > snyk-import-win.exe.sha256" + }, + { + "//": "removes the file we use to identify a build as a standalone binary", + "path": "@semantic-release/exec", + "cmd": "rm dist/STANDALONE" + } + ], + "publish": [ + "@semantic-release/npm", + { + "path": "@semantic-release/github", + "assets": [ + { + "path": "./snyk-linux", + "name": "snyk-import-linux", + "label": "snyk-import-linux" + }, + { + "path": "./snyk-import-linux.sha256", + "name": "snyk-import-linux.sha256", + "label": "snyk-import-linux.sha256" + }, + { + "path": "./snyk-import-macos", + "name": "snyk-import-macos", + "label": "snyk-import-macos" + }, + { + "path": "./snyk-import-macos.sha256", + "name": "snyk-import-macos.sha256", + "label": "snyk-import-macos.sha256" + }, + { + "path": "./snyk-import-win.exe", + "name": "snyk-import-win.exe", + "label": "snyk-import-win.exe" + }, + { + "path": "./snyk-import-win.exe.sha256", + "name": "snyk-import-win.exe.sha256", + "label": "snyk-import-win.exe.sha256" + } + ] + } + ] +} diff --git a/README.md b/README.md index 6f03f525..ce9fe7a3 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ This script is intended to help import projects into Snyk with a controlled pace "target": { "name": "shallow-goof-policy", "owner": "snyk-fixtures", - "branch": "master" // optional! + "branch": "master" } }, { @@ -53,9 +53,10 @@ This script is intended to help import projects into Snyk with a controlled pace } ``` 2. Set the env vars mentioned: +- `SNYK_IMPORT_PATH`- the path to the import file - `SNYK_API_TOKEN` - your [Snyk api token](https://app.snyk.io/account) - `SNYK_LOG_PATH` - the path to folder where all logs should be saved - `CONCURRENT_IMPORTS` (optional) defaults to 5 repos at a time, which is the recommended amount to import at once as a max. Just 1 repo may have many projects inside. (10 may also be okay if all repos are small) - `SNYK_HOST` (optional) defaults to `https://snyk.io` -3. `npm run build` and then `DEBUG=snyk* node dist/index.js` +1. `npm run build` and then `DEBUG=snyk* node dist/index.js` diff --git a/package.json b/package.json index e271fb87..20a54ec9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,9 @@ "name": "snyk-api-import", "description": "Walmart import for 20k+ repos", "main": "dist/index.js", - "bin": "dist/index.js", + "bin": { + "snyk-import": "dist/index.js" + }, "scripts": { "format:check": "prettier --check '{''{lib,test}/!(test/**/fixtures)/**/*,*}.{js,ts,json,yml}'", "format": "prettier --write '{''{lib,test}/!(test/**/fixtures)/**/*,*}.{js,ts,json,yml}'", diff --git a/src/lib/get-import-path.ts b/src/lib/get-import-path.ts index 52121a17..6e4cb562 100644 --- a/src/lib/get-import-path.ts +++ b/src/lib/get-import-path.ts @@ -1,5 +1,5 @@ export function getImportProjectsFile(): string { - const snykImportPath = process.env.SNYK_LOG_PATH; + const snykImportPath = process.env.SNYK_IMPORT_PATH; if (!snykImportPath) { throw new Error( `Please set the SNYK_IMPORT_PATH e.g. export SNYK_IMPORT_PATH='~/my/path/to/file'`,