Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set nodejs v18 as min version supported #166

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1

orbs:
win: circleci/[email protected]
prodsec: snyk/prodsec-orb@1.0
prodsec: snyk/prodsec-orb@1.1

defaults: &defaults
parameters:
Expand All @@ -14,7 +14,7 @@ defaults: &defaults
default: '8'
node_version:
type: string
default: '16'
default: '18.19.1'
working_directory: ~/snyk-mvn-plugin

windows_defaults: &windows_defaults
Expand All @@ -26,11 +26,11 @@ windows_defaults: &windows_defaults
test_matrix_unix: &test_matrix_unix
jdk_version: ['8.0.342-amzn', '17.0.4.1.fx-librca']
maven_version: ['3.3.9', '3.6.3', '3.8.4']
node_version: ['12', '16']
node_version: ['18.19.1']
test_matrix_win: &test_matrix_win
jdk_version: ['8', '17']
maven_version: ['3.3.9.2', '3.6.3', '3.8.4']
node_version: ['12', '16']
node_version: ['18.19.1']

commands:
install_deps:
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
lint:
<<: *defaults
docker:
- image: circleci/node:<< parameters.node_version >>
- image: cimg/node:<< parameters.node_version >>
steps:
- checkout
- install_deps
Expand Down Expand Up @@ -142,7 +142,7 @@ jobs:
test-unix:
<<: *defaults
docker:
- image: circleci/node:<< parameters.node_version >>
- image: cimg/node:<< parameters.node_version >>
environment:
MAVEN_VERSION: << parameters.maven_version >>
JDK: << parameters.jdk_version >>
Expand Down Expand Up @@ -206,12 +206,12 @@ workflows:
<<: *test_matrix_win
name: Windows Tests for Maven=<< matrix.maven_version >> JDK=<< matrix.jdk_version >> Node=<< matrix.node_version >>
context: nodejs-install

# Release
- release:
name: Release
context: nodejs-app-release
node_version: '16'
node_version: '18.19.1'
requires:
- test-windows
- test-unix
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
18
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ If you are looking to add tasks to your Maven build process you should use our [

| Node | Supported |
| ---- | --------- |
| 12 | ✅ |
| 14 | ✅ |
| 16 | ✅ |
| 18 | ✅ |

## Supported Maven versions

Expand Down
13 changes: 13 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Config } from '@jest/types';

export default async (): Promise<Config.InitialOptions> => {
return {
preset: 'ts-jest',
testEnvironment: 'node',
transform: {}, // ignore .babelrc file
collectCoverage: false, // Enabled by running `npm run test:coverage`
collectCoverageFrom: ['src/**/*.ts'],
coverageReporters: ['text-summary', 'html'],
testMatch: ['<rootDir>/tests/**/*.spec.ts', '<rootDir>/test/**/*.test.ts'],
};
};
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
isArchive,
} from './archive';
import { formatGenericPluginError } from './error-format';
import debugModule = require('debug');
import * as debugModule from 'debug';
import { parse } from './parse';
import { SnykHttpClient } from './parse/types';

Expand Down
26 changes: 17 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,49 @@
"files": [
"dist"
],
"engines": {
"node": "^18"
},
"scripts": {
"build": "tsc",
"format:check": "prettier --check '{lib,test}/**/*.{js,ts,json,yml}'",
"format": "prettier --write '{lib,test}/**/*.{js,ts,json,yml}'",
"lint": "npm run format:check && npm run lint:eslint",
"lint:eslint": "eslint --color --cache 'lib/**/*.{js,ts}'",
"prepare": "npm run build",
"test": "npm run prepare && npm run test:functional && npm run test:system",
"test:functional": "tap -R spec ./tests/functional/*.test.ts",
"test:system": "tap -R spec --timeout=180 ./tests/system/*.test.ts",
"test:jest": "npm run prepare && jest",
"test": "npm run prepare && npm run test:functional && npm run test:system && npm run test:jest",
"test:functional": "tap --disable-coverage --allow-incomplete-coverage --allow-empty-coverage ./tests/tap/functional/*.test.ts",
"test:system": "tap --disable-coverage --allow-incomplete-coverage --allow-empty-coverage --timeout=180 ./tests/tap/system/*.test.ts",
"semantic-release": "semantic-release"
},
"author": "snyk.io",
"license": "Apache-2.0",
"devDependencies": {
"@types/node": "11.13.8",
"@types/debug": "^4.1.12",
"@types/jest": "^29.5.12",
"@types/node": "^18.11.18",
"@types/sinon": "^7.5.2",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.5.0",
"jest": "^29.7.0",
"prettier": "^2.7.1",
"semantic-release": "^15",
"sinon": "^2.4.1",
"tap": "^12.0.1",
"tap": "^18.5.0",
"tap-only": "0.0.5",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.4.2"
},
"dependencies": {
"@snyk/cli-interface": "2.11.3",
"@snyk/dep-graph": "^1.23.1",
"packageurl-js": "^1.0.0",
"debug": "^4.1.1",
"debug": "^4.3.4",
"glob": "^7.1.6",
"packageurl-js": "^1.0.0",
"shescape": "1.6.1",
"tslib": "^2.4.0"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import * as test from 'tap-only';
import { parseDigraph } from '../../lib/parse-digraph';
import { readFixture } from '../helpers/read';
import { parseDigraph } from '../../../lib/parse-digraph';
import { readFixture } from '../../helpers/read';

test('parse valid input to expected string', async (t) => {
it('parse valid input to expected string', async () => {
const input = await readFixture('parse-digraph/output-without-labels.txt');
const result = parseDigraph(input);
const expected = `digraph "com.snyk.platform:tester-service:jar:4.0.5-SNAPSHOT" {
"com.snyk.platform:tester-service:jar:4.0.5-SNAPSHOT" -> "com.snyk.tester:tester-queue:jar:15.0.0:compile" ;
"com.snyk.platform:tester-service:jar:4.0.5-SNAPSHOT" -> "com.snyk.tester:tester-queue:test-jar:tests:15.0.0:test" ;
}`;
t.equals(result?.[0], expected);
expect(result?.[0]).toEqual(expected);
});

test('parse valid input with env vars to expected string', async (t) => {
test('parse valid input with env vars to expected string', async () => {
const input = await readFixture(
'parse-digraph/output-without-labels-with-env-var.txt',
);
Expand All @@ -21,5 +20,5 @@ test('parse valid input with env vars to expected string', async (t) => {
"com.snyk.platform:tester-service:jar:\${my.version}" -> "com.snyk.tester:tester-queue:jar:15.0.0:compile" ;
"com.snyk.platform:tester-service:jar:\${my.version}" -> "com.snyk.tester:tester-queue:test-jar:tests:15.0.0:test" ;
}`;
t.equals(result?.[0], expected);
expect(result?.[0]).toEqual(expected);
});
27 changes: 27 additions & 0 deletions tests/jest/system/get-command.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as path from 'path';
import { getCommand } from '../../../lib';
import * as os from 'os';

it("should return 'mvn' when no mvnw present in path", async () => {
const cmd = getCommand(
'.',
path.join(__dirname, '../..', 'fixtures/path with spaces', 'pom.xml'),
);

expect(cmd).toBe('mvn');
});

it("should return 'mvnw' when 'mvnw' present in path", async () => {
const cmd = getCommand(
'.',
path.join(__dirname, '../..', 'fixtures/maven-with-mvnw', 'pom.xml'),
);

const isWinLocal = /^win/.test(os.platform());

if (isWinLocal) {
expect(cmd).toBe('mvnw.cmd');
} else {
expect(cmd).toBe('./mvnw');
}
});
28 changes: 0 additions & 28 deletions tests/system/get-command.test.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as test from 'tap-only';
import * as path from 'path';
import { findArchives, isArchive } from '../../lib/archive';
import { findArchives, isArchive } from '../../../lib/archive';

test('isArchive', async (t) => {
[
Expand All @@ -22,7 +22,7 @@ test('isArchive', async (t) => {
].forEach((i) => t.notOk(isArchive(i), 'should be false for ' + i));
});

const fixturesPath = path.join(__dirname, '..', 'fixtures');
const fixturesPath = path.join(__dirname, '../..', 'fixtures');
const springCorePath = path.join(fixturesPath, 'spring-core');
const badPath = path.join(fixturesPath, 'bad');
const dummyPath = path.join(fixturesPath, 'dummy');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { test } from 'tap';
import { parseDigraphs } from '../../lib/parse/digraph';
import { buildDepGraph } from '../../lib/parse/dep-graph';
import tap from 'tap';
import { parseDigraphs } from '../../../lib/parse/digraph';
import { buildDepGraph } from '../../../lib/parse/dep-graph';

const test = tap.test;

test('buildDepGraph', async (t) => {
// input:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { test } from 'tap';
import { parseDependency } from '../../lib/parse/dependency';
import tap from 'tap';
import { parseDependency } from '../../../lib/parse/dependency';

const test = tap.test;

test('parseDependency returns expected object', async (t) => {
t.same(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { test } from 'tap';
import { parseDigraphs } from '../../lib/parse/digraph';
import tap from 'tap';
import { parseDigraphs } from '../../../lib/parse/digraph';

const test = tap.test;

const core = `digraph "io.snyk:core:jar:1.0.0" {
"io.snyk:core:jar:1.0.0" -> "org.apache.logging.log4j:log4j-api:jar:2.17.2:compile" ;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { test } from 'tap';
import { MavenGraphBuilder } from '../../lib/parse/maven-graph-builder';
import tap from 'tap';
import { MavenGraphBuilder } from '../../../lib/parse/maven-graph-builder';

const test = tap.test;

test('default constructor', async (t) => {
const builder = new MavenGraphBuilder('root');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as test from 'tap-only';
import * as plugin from '../../lib';
import * as plugin from '../../../lib';

test('buildArgs with array', async (t) => {
const result = plugin.buildArgs('.', '.', undefined, ['-Paxis', '-Pjaxen']);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as test from 'tap-only';
import { readFixture } from '../helpers/read';
import { parseVersions } from '../../lib/parse-versions';
import { readFixture } from '../../helpers/read';
import { parseVersions } from '../../../lib/parse-versions';

test('parseVersions from mvn --version', async (t) => {
const mavenOutput = await readFixture('parse-mvn/maven-versions.txt');
const result = parseVersions(mavenOutput);
if (result) {
t.equals(
t.equal(
result.javaVersion,
'Java version: 12.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/openjdk-12.0.1.jdk/Contents/Home',
);
t.equals(
t.equal(
result.mavenVersion,
'Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T17:06:16+02:00)',
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test } from 'tap';
import { parseStdout } from '../../lib/parse/stdout';
import tap from 'tap';
import { parseStdout } from '../../../lib/parse/stdout';

const test = tap.test;
const singleProjectStdout = `[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< io.snyk:single-project >-----------------------
Expand Down Expand Up @@ -171,7 +172,7 @@ test('output contains errors', async (t) => {
t.fail('expected error to be thrown');
} catch (err: unknown) {
if (err instanceof Error) {
t.equals(
t.equal(
err.message,
'Maven output contains errors.',
'throws expected error',
Expand All @@ -188,7 +189,7 @@ test('output contains error, but succeeds building', async (t) => {
t.fail('expected error to be thrown');
} catch (err: unknown) {
if (err instanceof Error) {
t.equals(
t.equal(
err.message,
'Cannot find any digraphs.',
'throws expected error',
Expand All @@ -205,7 +206,7 @@ test('output does not contain digraph', async (t) => {
t.fail('expected error to be thrown');
} catch (err: unknown) {
if (err instanceof Error) {
t.equals(
t.equal(
err.message,
'Cannot find any digraphs.',
'throws expected error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { legacyPlugin } from '@snyk/cli-interface';
import * as depGraphLib from '@snyk/dep-graph';
import * as path from 'path';
import * as test from 'tap-only';
import * as plugin from '../../lib';
import { readFixtureJSON } from '../helpers/read';
import { mockSnykSearchClient } from '../helpers/mock-search';
import * as plugin from '../../../lib';
import { readFixtureJSON } from '../../helpers/read';
import { mockSnykSearchClient } from '../../helpers/mock-search';

const testsPath = path.join(__dirname, '..');
const testsPath = path.join(__dirname, '../..');
const fixturesPath = path.join(testsPath, 'fixtures');
const badPath = path.join(fixturesPath, 'bad');

Expand Down
Loading