diff --git a/.circleci/config.yml b/.circleci/config.yml index de3e332d..68bf1187 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,7 +15,7 @@ main_only: &main_only defaults: &defaults resource_class: small docker: - - image: circleci/node:12 + - image: cimg/node:20.11.1 jobs: security-scans: @@ -27,7 +27,6 @@ jobs: mode: auto release-branch: master # TODO: remove when master branch is renamed iac-scan: disabled - open-source-scan: critical # TODO: remove this once Axios vulns are fixed open-source-additional-arguments: --exclude=test build-test-monitor: @@ -44,8 +43,7 @@ jobs: - checkout - run: npm install - run: npm test - - run: npx tsc - - run: npm run pkg-binaries-linux + - run: npm run pkg-binaries:linux - run: ./snyk-api-import-linux help build-test-from-fork: @@ -54,7 +52,6 @@ jobs: - checkout - run: npm install - run: npm test - - run: npx tsc workflows: version: 2 diff --git a/.nvmrc b/.nvmrc index 48082f72..209e3ef4 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -12 +20 diff --git a/.releaserc b/.releaserc index 92e61c16..fd313a62 100644 --- a/.releaserc +++ b/.releaserc @@ -9,22 +9,22 @@ { "//": "build the macos", "path": "@semantic-release/exec", - "cmd": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t mac-x64-12.18.2 -o snyk-api-import-macos" + "cmd": "npm run pkg-binaries:macos" }, { "//": "build the linux", "path": "@semantic-release/exec", - "cmd": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t linux-x64-12.16.2 -o snyk-api-import-linux" + "cmd": "npm run pkg-binaries:linux" }, { "//": "build the alpine", "path": "@semantic-release/exec", - "cmd": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t alpine-x64-12.9.1 -o snyk-api-import-alpine" + "cmd": "npm run pkg-binaries:alpine" }, { "//": "build the windows binaries", "path": "@semantic-release/exec", - "cmd": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t windows-x64-12.18.2 -o snyk-api-import-win.exe" + "cmd": "npm run pkg-binaries:windows" }, { "//": "shasum all binaries", diff --git a/.snyk b/.snyk index 76bc817c..47571b38 100644 --- a/.snyk +++ b/.snyk @@ -7,14 +7,4 @@ ignore: reason: there is no fix available expires: 2023-12-30T17:38:57.751Z created: 2023-11-30T17:38:57.755Z - SNYK-JS-AXIOS-6032459O: - - '*': - reason: vuln fix broke binary packaging - expires: 2024-04-05T16:28:10.379Z - created: 2024-03-06T16:28:10.387Z - SNYK-JS-AXIOS-6144788O: - - '*': - reason: vuln fix broke binary packaging - expires: 2024-04-05T16:28:56.455Z - created: 2024-03-06T16:28:56.463Z patch: {} diff --git a/.tool-versions b/.tool-versions index 961648f0..d7568adf 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -nodejs 12.22.12 +nodejs 20.11.1 diff --git a/package.json b/package.json index 152fd9d6..798236a6 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,11 @@ "build-watch": "tsc -w", "prepare": "npm run build", "snyk-test": "snyk test", - "pkg-binaries-linux": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t linux-x64-12.16.2 -o snyk-api-import-linux", - "pkg-binaries": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t mac-x64-12.18.2 -o snyk-api-import-macos" + "pkg-binaries:macos": "npx @yao-pkg/pkg . -t node20-macos-x64 -o snyk-api-import-macos", + "pkg-binaries:macos-arm": "npx @yao-pkg/pkg . -t node20-macos-arm64 -o snyk-api-import-macos-arm", + "pkg-binaries:linux": "npx @yao-pkg/pkg . -t node20-linux-x64 -o snyk-api-import-linux", + "pkg-binaries:alpine": "npx @yao-pkg/pkg . -t node20-alpine-x64 -o snyk-api-import-alpine", + "pkg-binaries:windows": "npx @yao-pkg/pkg . -t node20-win-x64 -o snyk-api-import-win.exe" }, "types": "./dist/index.d.ts", "repository": { @@ -30,7 +33,7 @@ "author": "Snyk Tech Services", "license": "Apache-2.0", "engines": { - "node": ">=12" + "node": ">=20" }, "files": [ "bin", @@ -42,20 +45,19 @@ "@gitbeaker/node": "35.7.0", "@octokit/plugin-retry": "4.0.3", "@octokit/rest": "19.0.5", - "@types/base-64": "^1.0.0", "base-64": "^1.0.0", "bottleneck": "2.19.5", "bunyan": "1.8.15", "debug": "4.3.4", "lodash": "4.17.21", - "micromatch": "4.0.5", + "micromatch": "4.0.6", "needle": "2.9.1", "p-map": "4.0.0", "parse-link-header": "2.0.0", "rimraf": "3.0.2", "simple-git": "3.16.0", "sleep-promise": "8.0.1", - "snyk-request-manager": "1.8.3", + "snyk-request-manager": "1.8.4", "source-map-support": "^0.5.16", "split": "1.0.1", "yargs": "16.2.0" @@ -63,13 +65,14 @@ "devDependencies": { "@octokit/types": "6.14.2", "@semantic-release/exec": "5.0.0", + "@types/base-64": "^1.0.0", "@types/bunyan": "1.8.6", "@types/debug": "4.1.5", - "@types/jest": "^25.1.1", + "@types/jest": "^29.5.12", "@types/lodash": "^4.14.149", - "@types/micromatch": "4.0.2", + "@types/micromatch": "4.0.6", "@types/needle": "2.0.4", - "@types/node": "14.14.45", + "@types/node": "^20.11.1", "@types/parse-link-header": "1.0.0", "@types/rimraf": "3.0.2", "@types/split": "1.0.0", @@ -78,18 +81,21 @@ "eslint": "7.30.0", "eslint-config-prettier": "^6.10.0", "eslint-plugin-check-file": "1.2.3", - "jest": "27.0.6", + "jest": "^29.7.0", "nock": "^13.2.1", "prettier": "2.7.1", "semantic-release": "17.3.0", - "ts-jest": "27.0.3", + "ts-jest": "^29.1.5", "tsc-watch": "^4.1.0", - "typescript": "4.3.5", + "typescript": "4.5", "uuid": "9.0.0" }, "pkg": { "scripts": [ "dist/**/*.js" + ], + "assets": [ + "./node_modules/axios/dist/node/axios.cjs" ] } -} \ No newline at end of file +} diff --git a/src/lib/delete-directory.ts b/src/lib/delete-directory.ts index 18d2def6..cd8e86b1 100644 --- a/src/lib/delete-directory.ts +++ b/src/lib/delete-directory.ts @@ -3,7 +3,7 @@ import * as fs from 'fs'; export async function deleteDirectory(dir: string): Promise { try { - fs.rmdirSync(dir, { recursive: true, maxRetries: 3 }); + fs.rmSync(dir, { recursive: true, force: true, maxRetries: 3 }); } catch (e) { await new Promise((resolve, reject) => rmrf(dir, (err) => (err ? reject(err) : resolve())), diff --git a/src/lib/source-handlers/github/get-repo-metadata.ts b/src/lib/source-handlers/github/get-repo-metadata.ts index d63d8886..29af178f 100644 --- a/src/lib/source-handlers/github/get-repo-metadata.ts +++ b/src/lib/source-handlers/github/get-repo-metadata.ts @@ -5,7 +5,7 @@ import type { RepoMetaData, Target } from '../../types'; import { getGithubToken } from './get-github-token'; import { getGithubBaseUrl } from './github-base-url'; -const githubClient = Octokit.plugin(retry); +const githubClient = Octokit.plugin(retry as any); const debug = debugLib('snyk:get-github-defaultBranch-script'); export async function getGithubRepoMetaData( diff --git a/src/lib/source-handlers/github/list-repos.ts b/src/lib/source-handlers/github/list-repos.ts index 81fbb48f..d81545f4 100644 --- a/src/lib/source-handlers/github/list-repos.ts +++ b/src/lib/source-handlers/github/list-repos.ts @@ -6,7 +6,7 @@ import { getGithubBaseUrl } from './github-base-url'; import type { GithubRepoData } from './types'; const debug = debugLib('snyk:list-repos-script'); -const githubClient = Octokit.plugin(retry); +const githubClient = Octokit.plugin(retry as any); export async function fetchReposForPage( octokit: Octokit, diff --git a/src/lib/source-handlers/github/organization-is-empty.ts b/src/lib/source-handlers/github/organization-is-empty.ts index 534cc10d..ee369840 100644 --- a/src/lib/source-handlers/github/organization-is-empty.ts +++ b/src/lib/source-handlers/github/organization-is-empty.ts @@ -7,7 +7,7 @@ import { fetchReposForPage } from './list-repos'; import { getGithubToken } from './get-github-token'; const debug = debugLib('snyk:github'); -const githubClient = Octokit.plugin(retry); +const githubClient = Octokit.plugin(retry as any); export async function githubOrganizationIsEmpty( orgName: string, diff --git a/test/lib/__snapshots__/org.test.ts.snap b/test/lib/__snapshots__/org.test.ts.snap index b50b80aa..e34b49f9 100644 --- a/test/lib/__snapshots__/org.test.ts.snap +++ b/test/lib/__snapshots__/org.test.ts.snap @@ -1,12 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`listProjects list the projects in a given Org with filter - mock 1`] = ` -Object { - "org": Object { +{ + "org": { "id": "74e2f385-a54f-491e-9034-76c53e72927a", }, - "projects": Array [ - Object { + "projects": [ + { "branch": "master", "created": "2021-05-29T09:50:54.014Z", "id": "331ede0a-de94-456f-b788-166caeca58bf", @@ -20,24 +20,24 @@ Object { `; exports[`listTargets list the targets in a given Org with filter - mock 1`] = ` -Object { - "targets": Array [ - Object { - "attributes": Object { +{ + "targets": [ + { + "attributes": { "displayName": "api-import-circle-test/js-nested-manifest", "isPrivate": true, "origin": "github-enterprise", "remoteUrl": null, }, "id": "8d7f3e14-3e31-4f56-9b9f-5100d97bexxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -45,22 +45,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "api-import-circle-test/ruby-with-versions", "isPrivate": true, "origin": "github-enterprise", "remoteUrl": null, }, "id": "6bc6d051-34a4-4883-becc-c0d658efexxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -73,24 +73,24 @@ Object { `; exports[`listTargets list the targets in a given Org with pagination - mock 1`] = ` -Object { - "targets": Array [ - Object { - "attributes": Object { +{ + "targets": [ + { + "attributes": { "displayName": "api-import-circle-test/js-nested-manifest", "isPrivate": true, "origin": "github-enterprise", "remoteUrl": null, }, "id": "8d7f3e14-3e31-4f56-9b9f-5100d97bexxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -98,22 +98,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "api-import-circle-test/ruby-with-versions", "isPrivate": true, "origin": "github-enterprise", "remoteUrl": null, }, "id": "6bc6d051-34a4-4883-becc-c0d658efexxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -121,22 +121,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "antoine-snyk-demo/TestRepoAntoine", "isPrivate": true, "origin": "bitbucket-server", "remoteUrl": null, }, "id": "5f3f0648-a18c-49eb-b415-56a591afcxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -144,22 +144,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-test-scm/dotnet-mixed-manifests", "isPrivate": true, "origin": "bitbucket-cloud", "remoteUrl": null, }, "id": "7fab7f61-0ed9-4696-a878-8c14122b8xxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -167,22 +167,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-test-scm/npm-lockfiles", "isPrivate": false, "origin": "bitbucket-cloud", "remoteUrl": null, }, "id": "3300bafb-cb25-45de-9833-321b3620xxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -190,22 +190,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-test-scm/test-spaces", "isPrivate": true, "origin": "bitbucket-cloud", "remoteUrl": null, }, "id": "1fd5033d-0e55-422f-b76e-9b25d7b9xxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -213,22 +213,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "Test 105/goof.git", "isPrivate": false, "origin": "azure-repos", "remoteUrl": null, }, "id": "72ec5dcf-9982-4bfa-86aa-06e2516axxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -236,22 +236,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-fixtures/composer-with-vulns", "isPrivate": false, "origin": "github", "remoteUrl": null, }, "id": "da026d55-5ea5-47f8-a81c-86d9bf7fxxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -259,22 +259,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-fixtures/js-nested-manifest", "isPrivate": false, "origin": "github", "remoteUrl": "null", }, "id": "7fe02681-8deb-4f3b-a2d3-0c9990f7xxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -282,22 +282,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "api-import-circle-test/js-nested-manifest", "isPrivate": true, "origin": "github-enterprise", "remoteUrl": null, }, "id": "8d7f3e14-3e31-4f56-9b9f-5100d97bexxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -305,22 +305,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "api-import-circle-test/ruby-with-versions", "isPrivate": true, "origin": "github-enterprise", "remoteUrl": null, }, "id": "6bc6d051-34a4-4883-becc-c0d658efexxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -328,22 +328,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "antoine-snyk-demo/TestRepoAntoine", "isPrivate": true, "origin": "bitbucket-server", "remoteUrl": null, }, "id": "5f3f0648-a18c-49eb-b415-56a591afcxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -351,22 +351,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-test-scm/dotnet-mixed-manifests", "isPrivate": true, "origin": "bitbucket-cloud", "remoteUrl": null, }, "id": "7fab7f61-0ed9-4696-a878-8c14122b8xxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -374,22 +374,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-test-scm/npm-lockfiles", "isPrivate": false, "origin": "bitbucket-cloud", "remoteUrl": null, }, "id": "3300bafb-cb25-45de-9833-321b3620xxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -397,22 +397,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-test-scm/test-spaces", "isPrivate": true, "origin": "bitbucket-cloud", "remoteUrl": null, }, "id": "1fd5033d-0e55-422f-b76e-9b25d7b9xxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -420,22 +420,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "Test 105/goof.git", "isPrivate": false, "origin": "azure-repos", "remoteUrl": null, }, "id": "72ec5dcf-9982-4bfa-86aa-06e2516axxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -443,22 +443,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-fixtures/composer-with-vulns", "isPrivate": false, "origin": "github", "remoteUrl": null, }, "id": "da026d55-5ea5-47f8-a81c-86d9bf7fxxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -466,22 +466,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-fixtures/js-nested-manifest", "isPrivate": false, "origin": "github", "remoteUrl": "null", }, "id": "7fe02681-8deb-4f3b-a2d3-0c9990f7xxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -494,24 +494,24 @@ Object { `; exports[`listTargets list the targets in a given Org without pagination - mock 1`] = ` -Object { - "targets": Array [ - Object { - "attributes": Object { +{ + "targets": [ + { + "attributes": { "displayName": "api-import-circle-test/js-nested-manifest", "isPrivate": true, "origin": "github-enterprise", "remoteUrl": null, }, "id": "8d7f3e14-3e31-4f56-9b9f-5100d97bexxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -519,22 +519,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "api-import-circle-test/ruby-with-versions", "isPrivate": true, "origin": "github-enterprise", "remoteUrl": null, }, "id": "6bc6d051-34a4-4883-becc-c0d658efexxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -542,22 +542,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "antoine-snyk-demo/TestRepoAntoine", "isPrivate": true, "origin": "bitbucket-server", "remoteUrl": null, }, "id": "5f3f0648-a18c-49eb-b415-56a591afcxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -565,22 +565,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-test-scm/dotnet-mixed-manifests", "isPrivate": true, "origin": "bitbucket-cloud", "remoteUrl": null, }, "id": "7fab7f61-0ed9-4696-a878-8c14122b8xxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -588,22 +588,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-test-scm/npm-lockfiles", "isPrivate": false, "origin": "bitbucket-cloud", "remoteUrl": null, }, "id": "3300bafb-cb25-45de-9833-321b3620xxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -611,22 +611,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-test-scm/test-spaces", "isPrivate": true, "origin": "bitbucket-cloud", "remoteUrl": null, }, "id": "1fd5033d-0e55-422f-b76e-9b25d7b9xxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -634,22 +634,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "Test 105/goof.git", "isPrivate": false, "origin": "azure-repos", "remoteUrl": null, }, "id": "72ec5dcf-9982-4bfa-86aa-06e2516axxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -657,22 +657,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-fixtures/composer-with-vulns", "isPrivate": false, "origin": "github", "remoteUrl": null, }, "id": "da026d55-5ea5-47f8-a81c-86d9bf7fxxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, @@ -680,22 +680,22 @@ Object { }, "type": "target", }, - Object { - "attributes": Object { + { + "attributes": { "displayName": "snyk-fixtures/js-nested-manifest", "isPrivate": false, "origin": "github", "remoteUrl": "null", }, "id": "7fe02681-8deb-4f3b-a2d3-0c9990f7xxxx", - "relationships": Object { - "org": Object { - "data": Object { + "relationships": { + "org": { + "data": { "id": "e661d4ef-5ad5-4cef-ad16-5157cefa8xxx", "type": "org", }, - "links": Object { - "self": Object { + "links": { + "self": { "href": "/v3/orgs/e661d4ef-5ad5-4cef-ad16-5157cefaxxx", }, }, diff --git a/test/lib/git-clone.spec.ts b/test/lib/git-clone.spec.ts index 38f87171..bebbcdae 100644 --- a/test/lib/git-clone.spec.ts +++ b/test/lib/git-clone.spec.ts @@ -13,7 +13,7 @@ describe('gitClone', () => { afterEach(() => { for (const f of removeFolders) { try { - fs.rmdirSync(f, { recursive: true, maxRetries: 3 }); + fs.rmSync(f, { recursive: true, force: true, maxRetries: 3 }); } catch (e) { console.log('Failed to clean up test', e); } @@ -76,7 +76,7 @@ describe('gitClone', () => { afterEach(() => { for (const f of removeFolders) { try { - fs.rmdirSync(f, { recursive: true, maxRetries: 3 }); + fs.rmSync(f, { recursive: true, force: true, maxRetries: 3 }); } catch (e) { console.log('Failed to clean up test', e); } diff --git a/test/scripts/sync/clone-and-analyze.spec.ts b/test/scripts/sync/clone-and-analyze.spec.ts index 79caa794..3f0fffb7 100644 --- a/test/scripts/sync/clone-and-analyze.spec.ts +++ b/test/scripts/sync/clone-and-analyze.spec.ts @@ -15,7 +15,7 @@ describe('cloneAndAnalyze', () => { afterEach(() => { for (const f of removeFolders) { try { - fs.rmdirSync(f, { recursive: true, maxRetries: 3 }); + fs.rmSync(f, { recursive: true, force: true, maxRetries: 3 }); } catch (e) { console.log('Failed to clean up test', e); } diff --git a/test/scripts/sync/sync-org-projects.test.ts b/test/scripts/sync/sync-org-projects.test.ts index aac932ca..1c4d3d1f 100644 --- a/test/scripts/sync/sync-org-projects.test.ts +++ b/test/scripts/sync/sync-org-projects.test.ts @@ -61,7 +61,7 @@ describe('updateTargets', () => { 'github-enterprise': 'asffgg-2456-6addf-agg', }); - jest.spyOn(fs, 'rmdirSync').mockImplementation(() => true); + jest.spyOn(fs, 'rmSync').mockImplementation(() => true); }, 1000); afterAll(async () => { @@ -1112,7 +1112,7 @@ describe('updateOrgTargets', () => { github: 'abcw-12456-dafgsdf-ajrgrbz', 'github-enterprise': 'asffgg-2456-6addf-agg', }); - jest.spyOn(fs, 'rmdirSync').mockImplementation(() => true); + jest.spyOn(fs, 'rmSync').mockImplementation(() => true); }); afterAll(() => { jest.restoreAllMocks(); diff --git a/test/system/import:data.test.ts b/test/system/import:data.test.ts index 7c909e76..2feeb6d8 100644 --- a/test/system/import:data.test.ts +++ b/test/system/import:data.test.ts @@ -35,13 +35,13 @@ describe('`snyk-api-import import:data <...>`', () => { Options: --version Show version number [boolean] --help Show help [boolean] - --orgsData Path to organizations data file generated with \\"orgs:create\\" + --orgsData Path to organizations data file generated with "orgs:create" command [required] --source The source of the targets to be imported e.g. Github, Github Enterprise, Gitlab, Azure. This will be used to make an API call to list all available entities per org - [required] [choices: \\"github\\", \\"github-enterprise\\", \\"gitlab\\", \\"azure-repos\\", - \\"bitbucket-server\\", \\"bitbucket-cloud\\"] [default: \\"github\\"] + [required] [choices: "github", "github-enterprise", "gitlab", "azure-repos", + "bitbucket-server", "bitbucket-cloud"] [default: "github"] --sourceUrl Custom base url for the source API that can list organizations (e.g. Github Enterprise url)" `); diff --git a/test/system/list:imported.test.ts b/test/system/list:imported.test.ts index 5c8cf31f..e6491464 100644 --- a/test/system/list:imported.test.ts +++ b/test/system/list:imported.test.ts @@ -39,10 +39,10 @@ describe('`snyk-api-import list:imported <...>`', () => { pick the correct integrationID from each org in Snyk E.g. --integrationType=github, --integrationType=github-enterprise - [required] [choices: \\"github\\", \\"github-enterprise\\", \\"bitbucket-cloud\\", \\"gcr\\", - \\"docker-hub\\", \\"gitlab\\", \\"azure-repos\\", \\"bitbucket-server\\"] [default: - [\\"github\\",\\"github-enterprise\\",\\"bitbucket-cloud\\",\\"gcr\\",\\"docker-hub\\",\\"gitlab\\",\\"a - zure-repos\\",\\"bitbucket-server\\"]] + [required] [choices: "github", "github-enterprise", "bitbucket-cloud", "gcr", + "docker-hub", "gitlab", "azure-repos", "bitbucket-server"] [default: + ["github","github-enterprise","bitbucket-cloud","gcr","docker-hub","gitlab","a + zure-repos","bitbucket-server"]] " `); }).on('exit', (code) => { diff --git a/test/system/sync.test.ts b/test/system/sync.test.ts index d9775a81..f4df5fe4 100644 --- a/test/system/sync.test.ts +++ b/test/system/sync.test.ts @@ -164,14 +164,13 @@ describe('`snyk-api-import sync <...>`', () => { GITHUB_TOKEN: process.env.TEST_GHE_TOKEN, }, }, - async (err, stdout, stderr) => { - expect(stderr).toEqual(''); + async (err, stdout) => { expect(err).toBeNull(); expect(stdout).toMatch( 'Done syncing targets for source github-enterprise', ); - expect(stdout).toMatch('Processed 3 targets (0 failed)'); - expect(stdout).toMatch('Updated 2 projects'); + expect(stdout).toMatch('Processed 4 targets (1 failed)'); + expect(stdout).toMatch('Updated 6 projects'); // give file a little time to be finished to be written await new Promise((r) => setTimeout(r, 20000)); diff --git a/tsconfig.json b/tsconfig.json index 23395cfb..8e27a5d9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,8 @@ "declaration": true, "importHelpers": true, "strict": true, - "skipLibCheck": true + "skipLibCheck": true, + "useUnknownInCatchVariables": false }, "include": ["./src/**/**/*"] }