Skip to content

chore: support minimum node 20, use native node test runner #230

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
15 changes: 8 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [ 16.x, 18.x, 20.x ]
node-version: [ 20.x, 22.x, 24.x ]
os: [ windows-latest, ubuntu-latest, macOS-latest ]

# Go
Expand Down Expand Up @@ -46,22 +46,23 @@ jobs:
- name: Install
run: npm install

- name: Test (Node.js <= 16.x only)
if: matrix.node-version <= '16.x'
run: npm run test:nolint
- name: Test (Node.js <= 20.x)
if: matrix.node-version <= '20.x'
# node 20 doesnt support excluding files from coverage report, and by default includes test files themselves.
run: npm run test:node20
env:
CI: true

- name: Test
if: matrix.node-version > '16.x'
run: npm test
if: matrix.node-version > '20.x'
run: npm test
env:
CI: true

- name: Notify
uses: sarisia/actions-status-discord@v1
# Only fire alert once
if: github.ref == 'refs/heads/main' && failure() && matrix.node-version == '20.x' && matrix.os == 'ubuntu-latest'
if: github.ref == 'refs/heads/main' && failure() && matrix.node-version == '24.x' && matrix.os == 'ubuntu-latest'
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
title: "build and test"
Expand Down
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

---

## [8.0.0] 2025-04-06

### Changed

- Breaking change: dropped node 16, 18 support

---

## [7.0.0 - 7.0.1] 2024-01-08

### Changed
Expand Down
15 changes: 6 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
{
"name": "@architect/parser",
"version": "7.0.1",
"version": "8.0.0-RC.0",
"description": "Architect Parser accepts plaintext, JSON, or YAML .arc manifests and returns a plain JavaScript Object",
"main": "./src/index.js",
"scripts": {
"deno:test": "deno test -A --unstable mod.test.ts",
"deno:fmt": "deno fmt mod.ts && deno fmt mod.test.ts",
"lint": "eslint . --fix",
"test:unit": "cross-env tape 'test/*-test.js' | tap-arc",
"coverage": "nyc --reporter=lcov --reporter=text-summary npm run test:unit",
"test:nolint": "npm run coverage",
"test:unit": "node --test --test-reporter=spec",
"coverage:node20": "npm run test:unit -- --experimental-test-coverage",
"coverage": "npm run coverage:node20 -- --test-coverage-exclude=test/*.js",
"test:node20": "npm run lint && npm run coverage:node20",
"test": "npm run lint && npm run coverage",
"rc": "npm version prerelease --preid RC",
"build": "rollup -c",
"vendor:js-yaml": "mkdir -p tmp && browserify --node --standalone js-yaml --im --no-builtins node_modules/js-yaml/index.js > tmp/js-yaml.js && mkdir -p src/compat/vendor && terser tmp/js-yaml.js -o src/compat/vendor/js-yaml.min.js",
"vendor": "npm run vendor:js-yaml"
},
"engines": {
"node": ">=16"
"node": ">=20"
},
"repository": {
"type": "git",
Expand All @@ -34,13 +35,9 @@
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-terser": "~0.4.3",
"browserify": "~17.0.0",
"cross-env": "~7.0.3",
"eslint": "~9.1.1",
"js-yaml": "~4.1.0",
"nyc": "^15.1.0",
"rollup": "^3.27.0",
"tap-arc": "~1.2.2",
"tape": "~5.7.5",
"terser": "~5.31.0"
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Parsing the file with the following code:
```javascript
#!/usr/bin/env node
const parse = require('@architect/parser')
const fs = require('fs')
const fs = require('node:fs')
const text = fs.readFileSync('./some-arc-file.txt').toString()
const result = parse(text)

Expand Down
16 changes: 8 additions & 8 deletions test/00-lexer-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let test = require('tape')
let test = require('node:test')
let lex = require('../src/lexer')

let arcfile = `
Expand All @@ -14,25 +14,25 @@ false false false

# comment with spaces
foo bar

#semi;colons?
`

test('lex', t => {
t.plan(5)

// can lex
t.ok(lex, 'exists')
t.assert.ok(lex, 'exists')
let result = lex(arcfile)

// got an array
t.ok(Array.isArray(result), 'lexed')
t.assert.ok(Array.isArray(result), 'lexed')
let first = result[0]
let second = result[1]
let third = result[2]

// ensure the arcfile parses as we'd expect
t.ok(first.type === 'newline' && first.line === 1 && first.column === 1, 'line 1 column 1 is a newline')
t.ok(second.type === 'newline' && second.line === 2 && first.column === 1, 'line 2 column 1 is a newline')
t.ok(third.type === 'pragma' && third.value === 'pragma1' && third.line === 3 && third.column === 1, 'hunp')

console.log(result)
t.assert.ok(first.type === 'newline' && first.line === 1 && first.column === 1, 'line 1 column 1 is a newline')
t.assert.ok(second.type === 'newline' && second.line === 2 && first.column === 1, 'line 2 column 1 is a newline')
t.assert.ok(third.type === 'pragma' && third.value === 'pragma1' && third.line === 3 && third.column === 1, 'hunp')
})
14 changes: 7 additions & 7 deletions test/01-ast-scalar-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let test = require('tape')
let { test } = require('node:test')
let parse = require('../')

test('ast empty', t => {
Expand Down Expand Up @@ -32,8 +32,8 @@ test('ast empty', t => {
}

let parsed = parse.parser(parse.lexer(mock))
console.dir(parsed, { depth: null })
t.same(parsed, expected, 'successfully parsed ast for empty types')
// console.dir(parsed, { depth: null })
t.assert.deepEqual(parsed, expected, 'successfully parsed ast for empty types')
})

test('ast scalars', t => {
Expand Down Expand Up @@ -74,8 +74,8 @@ true`
}

let parsed = parse.parser(parse.lexer(mock))
console.dir(parsed, { depth: null })
t.same(parsed, expected, 'successfully parsed ast for scalar types')
// console.dir(parsed, { depth: null })
t.assert.deepEqual(parsed, expected, 'successfully parsed ast for scalar types')
})

test('ast arrays', t => {
Expand Down Expand Up @@ -127,6 +127,6 @@ one true 3 # comment2`

let tokens = parse.lexer(mock)
let parsed = parse.parser(tokens)
console.dir(parsed, { depth: null })
t.same(parsed, expected, 'successfully parsed array')
// console.dir(parsed, { depth: null })
t.assert.deepEqual(parsed, expected, 'successfully parsed array')
})
32 changes: 16 additions & 16 deletions test/02-ast-complex-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let test = require('tape')
let { test } = require('node:test')
let parse = require('../')
let isVector = require('../src/parser/_is-vector')
let isMap = require('../src/parser/_is-map')
Expand All @@ -15,7 +15,7 @@ vec # hi
some stuff here`
let tokens = parse.lexer(mock)
let start = tokens.slice(3, tokens.length) // start at 'vec'
t.ok(isVector(start), 'found a valid vector')
t.assert.ok(isVector(start), 'found a valid vector')
})

test('is not a vector', t => {
Expand All @@ -26,7 +26,7 @@ map
one two`
let tokens = parse.lexer(mock)
let start = tokens.slice(3, tokens.length) // start at 'map' token
t.ok(isVector(start) === false, 'did not find a valid vector')
t.assert.ok(isVector(start) === false, 'did not find a valid vector')
})

test('ast vectors', t => {
Expand Down Expand Up @@ -106,8 +106,8 @@ this should be ignored`
],
}
let parsed = parse.parser(parse.lexer(mock))
console.dir(parsed, { depth: null })
t.same(parsed, expected, 'successfully parsed vector')
// console.dir(parsed, { depth: null })
t.assert.deepEqual(parsed, expected, 'successfully parsed vector')
})

test('isMap', t => {
Expand All @@ -123,8 +123,8 @@ map
`
let tokens = parse.lexer(mock)
let start = tokens.slice(3, tokens.length)
console.log(start)
t.ok(isMap(start))
// console.log(start)
t.assert.ok(isMap(start))
})

test('map has three keys (vectors)', t => {
Expand All @@ -137,11 +137,11 @@ m1 # also cool
three 3`
let tokens = parse.lexer(mock)
let ast = parse.parser(tokens)
console.dir(ast, { depth: null })
// console.dir(ast, { depth: null })
let pragma = ast.values.find(t => t.type === 'pragma' && t.name === 'map-test')
let map = pragma.values.find(t => t.type === 'map' && t.name === 'm1')
let keys = map.values.filter(t => t.type === 'vector')
t.ok(keys.length === 3, 'has three keys')
t.assert.ok(keys.length === 3, 'has three keys')
})

test('map with vector', t => {
Expand All @@ -157,10 +157,10 @@ m1 #comment2
false`
let tokens = parse.lexer(mock)
let mapTokens = tokens.slice(5, tokens.length)
t.ok(isVector(mapTokens) === false, 'isVector is false')
t.ok(isMap(mapTokens) === true, 'isMap is true')
let parsed = parse.parser(tokens)
console.dir(parsed, { depth: null })
t.assert.ok(isVector(mapTokens) === false, 'isVector is false')
t.assert.ok(isMap(mapTokens) === true, 'isMap is true')
/* let parsed = */parse.parser(tokens)
// console.dir(parsed, { depth: null })
})

test('map with scalars and vectors', t => {
Expand All @@ -185,7 +185,7 @@ m1 #comment2
let map = pragma.values.find(t => t.type === 'map')
let keys = map.values.filter( t => t.type === 'vector')
let bools = keys.find(t => t.name === 'bools')
t.ok(keys.length === 4, 'has four keys')
t.ok(bools.values.filter(t => t.type === 'boolean').length === 2, 'bools has two booleans')
console.dir(parsed, { depth: null })
t.assert.ok(keys.length === 4, 'has four keys')
t.assert.ok(bools.values.filter(t => t.type === 'boolean').length === 2, 'bools has two booleans')
// console.dir(parsed, { depth: null })
})
Loading