From 4248f481c27a82cc2630ae49af42caa463512e2d Mon Sep 17 00:00:00 2001 From: Ariadna Roman-Angheluta Date: Fri, 30 Jun 2023 10:49:17 +0100 Subject: [PATCH] chore: downgrade node to 12 We have found nexe doesn't support node 14 for Alpine, so going back to node 12 for now. Signed-off-by: Jacek Rzeniewicz --- .circleci/config.yml | 6 ++--- .nvmrc | 2 +- .releaserc | 8 +++--- .tool-versions | 1 + package.json | 8 +++--- src/lib/git-clone.ts | 2 +- src/scripts/sync/clone-and-analyze.ts | 2 +- test/lib/git-clone.spec.ts | 4 +-- test/scripts/sync/clone-and-analyze.spec.ts | 2 +- test/scripts/sync/sync-org-projects.test.ts | 27 +++++++-------------- 10 files changed, 26 insertions(+), 36 deletions(-) create mode 100644 .tool-versions diff --git a/.circleci/config.yml b/.circleci/config.yml index a6e9c215..3fe30dfa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ orbs: jobs: build-test-monitor: docker: - - image: circleci/node:14 + - image: circleci/node:12 steps: - slack/notify: channel: C0137E8F72A @@ -20,7 +20,7 @@ jobs: only_for_branches: master build-test: docker: - - image: circleci/node:14 + - image: circleci/node:12 steps: - checkout - run: npm install @@ -33,7 +33,7 @@ jobs: only_for_branches: master build-test-from-fork: docker: - - image: circleci/node:14 + - image: circleci/node:12 steps: - checkout - run: npm install diff --git a/.nvmrc b/.nvmrc index 8351c193..48082f72 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -14 +12 diff --git a/.releaserc b/.releaserc index ec1f661c..26dbf041 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-14.15.3 -o snyk-api-import-macos" + "cmd": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t mac-x64-12.9.0 -o snyk-api-import-macos" }, { "//": "build the linux", "path": "@semantic-release/exec", - "cmd": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t linux-x64-14.15.3 -o snyk-api-import-linux" + "cmd": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t linux-x64-12.9.0 -o snyk-api-import-linux" }, { "//": "build the alpine", "path": "@semantic-release/exec", - "cmd": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t alpine-x64-14.15.3 -o snyk-api-import-alpine" + "cmd": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t alpine-x64-12.9.0 -o snyk-api-import-alpine" }, { "//": "build the windows binaries", "path": "@semantic-release/exec", - "cmd": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t windows-x64-14.15.3 -o snyk-api-import-win.exe" + "cmd": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t windows-x64-12.9.0 -o snyk-api-import-win.exe" }, { "//": "shasum all binaries", diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..961648f0 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +nodejs 12.22.12 diff --git a/package.json b/package.json index 0d3c9e48..c8555030 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "build-watch": "tsc -w", "prepare": "npm run build", "snyk-test": "snyk test", - "pkg-binaries-linux": "npx nexe@4.0.0-rc.2 dist/index.js -r './dist/**/*.js' -t linux-x64-14.15.3 -o snyk-api-import-linux", - "pkg-binaries": "npx nexe@4.0.0-rc.2 dist/index.js -r './dist/**/*.js' -t mac-x64-14.15.3 -o snyk-api-import-macos" + "pkg-binaries-linux": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t linux-x64-12.9.0 -o snyk-api-import-linux", + "pkg-binaries": "npx nexe@3.3.7 dist/index.js -r './dist/**/*.js' -t mac-x64-12.9.0 -o snyk-api-import-macos" }, "types": "./dist/index.d.ts", "repository": { @@ -30,7 +30,7 @@ "author": "Snyk Tech Services", "license": "Apache-2.0", "engines": { - "node": ">=14" + "node": ">=12" }, "files": [ "bin", @@ -47,7 +47,6 @@ "bottleneck": "2.19.5", "bunyan": "1.8.15", "debug": "4.3.4", - "fs-extra": "^11.1.1", "lodash": "4.17.21", "micromatch": "4.0.5", "needle": "2.9.1", @@ -65,7 +64,6 @@ "@semantic-release/exec": "5.0.0", "@types/bunyan": "1.8.6", "@types/debug": "4.1.5", - "@types/fs-extra": "^11.0.1", "@types/jest": "^25.1.1", "@types/lodash": "^4.14.149", "@types/micromatch": "4.0.2", diff --git a/src/lib/git-clone.ts b/src/lib/git-clone.ts index bdcc04ac..b690ad11 100644 --- a/src/lib/git-clone.ts +++ b/src/lib/git-clone.ts @@ -53,7 +53,7 @@ export async function gitClone( } catch (err: any) { debug(`Could not shallow clone the repo:\n ${err}`); if (fs.existsSync(repoClonePath)) { - fs.rmSync(repoClonePath, { recursive: true, maxRetries: 3, force: true }); + fs.rmdirSync(repoClonePath, { recursive: true, maxRetries: 3 }); } return { success: false, diff --git a/src/scripts/sync/clone-and-analyze.ts b/src/scripts/sync/clone-and-analyze.ts index 69f68f7f..9cb0ffd2 100644 --- a/src/scripts/sync/clone-and-analyze.ts +++ b/src/scripts/sync/clone-and-analyze.ts @@ -63,7 +63,7 @@ export async function cloneAndAnalyze( ); try { - fs.rmSync(repoPath, { recursive: true, maxRetries: 3, force: true }); + fs.rmdirSync(repoPath, { recursive: true, maxRetries: 3 }); } catch (error) { debug(`Failed to delete ${repoPath}. Error was ${error}.`); } diff --git a/test/lib/git-clone.spec.ts b/test/lib/git-clone.spec.ts index 8c78fa9d..38f87171 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.rmSync(f, { recursive: true, force: true, maxRetries: 3 }); + fs.rmdirSync(f, { recursive: 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.rmSync(f, { recursive: true, maxRetries: 3, force: true }); + fs.rmdirSync(f, { recursive: 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 2af8c65d..79caa794 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.rmSync(f, { recursive: true, maxRetries: 3, force: true }); + fs.rmdirSync(f, { recursive: 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 7bc59e20..aac932ca 100644 --- a/test/scripts/sync/sync-org-projects.test.ts +++ b/test/scripts/sync/sync-org-projects.test.ts @@ -2,7 +2,6 @@ import { requestsManager } from 'snyk-request-manager'; import * as uuid from 'uuid'; import * as path from 'path'; import * as fs from 'fs'; -import * as fse from 'fs-extra'; import { updateOrgTargets, updateTargets, @@ -245,7 +244,7 @@ describe('updateTargets', () => { cloneSpy.mockImplementation(() => Promise.resolve({ success: true, - repoPath: fixture('monorepo-new'), + repoPath: path.resolve(fixturesFolderPath, 'monorepo-new'), gitResponse: '', }), ); @@ -354,7 +353,7 @@ describe('updateTargets', () => { cloneSpy.mockImplementation(() => Promise.resolve({ success: true, - repoPath: fixture('goof'), + repoPath: path.resolve(fixturesFolderPath, 'goof'), gitResponse: '', }), ); @@ -464,7 +463,7 @@ describe('updateTargets', () => { cloneSpy.mockImplementation(() => Promise.resolve({ success: true, - repoPath: fixture('goof'), + repoPath: path.resolve(fixturesFolderPath, 'goof'), gitResponse: '', }), ); @@ -555,7 +554,7 @@ describe('updateTargets', () => { cloneSpy.mockImplementation(() => Promise.resolve({ success: true, - repoPath: fixture('goof'), + repoPath: path.resolve(fixturesFolderPath, 'goof'), gitResponse: '', }), ); @@ -681,7 +680,7 @@ describe('updateTargets', () => { cloneSpy.mockImplementation(() => Promise.resolve({ success: true, - repoPath: fixture('monorepo'), + repoPath: path.resolve(fixturesFolderPath, 'monorepo'), gitResponse: '', }), ); @@ -891,7 +890,7 @@ describe('updateTargets', () => { cloneSpy.mockImplementation(() => Promise.resolve({ success: true, - repoPath: fixture('monorepo'), + repoPath: path.resolve(fixturesFolderPath, 'monorepo'), gitResponse: '', }), ); @@ -1034,7 +1033,7 @@ describe('updateTargets', () => { cloneSpy.mockImplementation(() => Promise.resolve({ success: true, - repoPath: fixture('monorepo'), + repoPath: path.resolve(fixturesFolderPath, 'monorepo'), gitResponse: '', }), ); @@ -1401,7 +1400,7 @@ describe('updateOrgTargets', () => { cloneSpy.mockImplementation(() => Promise.resolve({ success: true, - repoPath: fixture('goof'), + repoPath: path.resolve(fixturesFolderPath, 'goof'), gitResponse: '', }), ); @@ -1586,7 +1585,7 @@ describe('updateOrgTargets', () => { cloneSpy.mockImplementation(() => Promise.resolve({ success: true, - repoPath: fixture('goof'), + repoPath: path.resolve(fixturesFolderPath, 'goof'), gitResponse: '', }), ); @@ -1877,11 +1876,3 @@ describe('bulkImportTargetFiles', () => { expect(updated.length).toEqual(5); }); }); - -function fixture(name: string) { - const tempDir = fs.mkdtempSync('snyk-api-import-test-'); - fse.copySync(path.resolve(fixturesFolderPath, name), tempDir, { - overwrite: true, - }); - return tempDir; -}