From b6e7c360627561177220a3413378c353124d1828 Mon Sep 17 00:00:00 2001 From: Tierney Cyren Date: Fri, 8 Nov 2024 15:56:40 +0000 Subject: [PATCH 1/3] feat: add @nodevu/latest module Signed-off-by: Tierney Cyren --- newest/LICENSE | 21 +++++++++++++++++++++ newest/README.md | 31 +++++++++++++++++++++++++++++++ newest/biome.json | 17 +++++++++++++++++ newest/index.js | 25 +++++++++++++++++++++++++ newest/package.json | 33 +++++++++++++++++++++++++++++++++ newest/test/test.js | 31 +++++++++++++++++++++++++++++++ package.json | 1 + 7 files changed, 159 insertions(+) create mode 100644 newest/LICENSE create mode 100644 newest/README.md create mode 100644 newest/biome.json create mode 100644 newest/index.js create mode 100644 newest/package.json create mode 100644 newest/test/test.js diff --git a/newest/LICENSE b/newest/LICENSE new file mode 100644 index 00000000..b8e356ab --- /dev/null +++ b/newest/LICENSE @@ -0,0 +1,21 @@ +MIT License Copyright (c) 2022 Tierney Cyren + +Permission is hereby granted, free +of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice +(including the next paragraph) shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO +EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/newest/README.md b/newest/README.md new file mode 100644 index 00000000..b35027be --- /dev/null +++ b/newest/README.md @@ -0,0 +1,31 @@ +# @nodevu/newest + +A module that returns newest LTS or Security release of a given Node.js release line. + +## Usage + +```js +const { newest } = require('@nodevu/newest') + +const newestLts = newest('v16', 'lts') +const newestSecurity = newest('v16', 'security') +``` + +```js +const { lts, security } = require('@nodevu/newest') + +const newestLts = lts('v16') +const newestSecurity = security('v16') +``` + +## API + +This module exports three functions: + +- `newest(name, type)` + - `name` (string): Node.js release line name. Examples: `v16`, `v11`, `v8`, `v0.10`. + - `type` (string): `lts` or `security`. +- `lts(name)` + - `name` (string): Node.js release line name. Examples: `v16`, `v11`, `v8`, `v0.10`. +- `security(name)` + - `name` (string): Node.js release line name. Examples: `v16`, `v11`, `v8`, `v0.10`. \ No newline at end of file diff --git a/newest/biome.json b/newest/biome.json new file mode 100644 index 00000000..3a7b021c --- /dev/null +++ b/newest/biome.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.6.1/schema.json", + "organizeImports": { + "enabled": true + }, + "javascript": { + "formatter": { + "quoteStyle": "single" + } + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + } +} diff --git a/newest/index.js b/newest/index.js new file mode 100644 index 00000000..11250e8a --- /dev/null +++ b/newest/index.js @@ -0,0 +1,25 @@ +const nodevu = require('@nodevu/core'); + +async function newest(name, type) { + const data = await nodevu(); + + if (type === 'lts') { + return data[name].support.lts.newest; + } + + if (type === 'security') { + return data[name].security.newest; + } +} + +async function lts(name) { + return await newest(name, 'lts'); +} + +async function security(name) { + return await newest(name, 'security'); +} + +module.exports.newest = newest; +module.exports.lts = lts; +module.exports.security = security; diff --git a/newest/package.json b/newest/package.json new file mode 100644 index 00000000..17a651ba --- /dev/null +++ b/newest/package.json @@ -0,0 +1,33 @@ +{ + "name": "@nodevu/newest", + "version": "0.1.0", + "description": "a module that returns the newest lts or security release of the release line passed.", + "main": "index.js", + "files": ["index.js", "LICENSE"], + "scripts": { + "lint": "biome check ./", + "lint:write": "biome check ./ --write", + "test": "node --test", + "coverage": "c8 node --test", + "updates:check": "npx npm-check-updates", + "updates:update": "npx npm-check-updates -u" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/cutenode/nodevu.git" + }, + "keywords": ["node.js", "versions"], + "author": "Tierney Cyren (https://bnb.im/)", + "license": "MIT", + "bugs": { + "url": "https://github.com/cutenode/nodevu/issues" + }, + "homepage": "https://github.com/cutenode/nodevu#readme", + "dependencies": { + "@nodevu/core": "^0.3.0" + }, + "devDependencies": { + "@biomejs/biome": "1.9.4", + "c8": "^10.1.2" + } +} diff --git a/newest/test/test.js b/newest/test/test.js new file mode 100644 index 00000000..0c86b09c --- /dev/null +++ b/newest/test/test.js @@ -0,0 +1,31 @@ +const assert = require('node:assert'); +const { newest, lts, security } = require('../index'); +const { describe, it } = require('node:test'); + +describe('check v10', async () => { + describe('running newest', async () => { + it('should return the correct security version for v10', async () => { + const data = await newest('v10', 'security'); + assert.equal(data, '10.24.1'); + }); + + it('should return the correct lts version for v10', async () => { + const data = await newest('v10', 'lts'); + assert.equal(data, '10.24.1'); + }); + }); + + describe('running security', async () => { + it('should return the correct security version for v10', async () => { + const data = await security('v10'); + assert.equal(data, '10.24.1'); + }); + }); + + describe('running lts', async () => { + it('should return the correct lts version for v10', async () => { + const data = await lts('v10'); + assert.equal(data, '10.24.1'); + }); + }); +}); diff --git a/package.json b/package.json index 2911f646..7510ac32 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "static", "parsefiles", "earliest", + "newest", "ranges", "aliases", "translate" From 9c4ff55350680269215793e3ceaefbab845354d7 Mon Sep 17 00:00:00 2001 From: Tierney Cyren Date: Fri, 8 Nov 2024 16:02:10 +0000 Subject: [PATCH 2/3] ci: add linting and testing CI for newest Signed-off-by: Tierney Cyren --- .github/workflows/lint-newest.yml | 27 ++++++++++++++++++++++++++ .github/workflows/tests-newest.yml | 31 ++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .github/workflows/lint-newest.yml create mode 100644 .github/workflows/tests-newest.yml diff --git a/.github/workflows/lint-newest.yml b/.github/workflows/lint-newest.yml new file mode 100644 index 00000000..17400743 --- /dev/null +++ b/.github/workflows/lint-newest.yml @@ -0,0 +1,27 @@ +name: "Test Suite: Linter (newest)" + +on: + push: + pull_request: + paths: + - 'newest/**' + branches: + - main + workflow_dispatch: + workflow_call: + +jobs: + tests: + if: github.repository == 'cutenode/nodevu' + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: current + - name: Run npm install -w newest + run: npm install -w newest + - name: Run npm run lint -w newest + run: npm run lint -w newest diff --git a/.github/workflows/tests-newest.yml b/.github/workflows/tests-newest.yml new file mode 100644 index 00000000..f15dbef2 --- /dev/null +++ b/.github/workflows/tests-newest.yml @@ -0,0 +1,31 @@ +name: "Test Suite: @nodevu/newest" + +on: + pull_request: + paths: + - 'newest/**' + branches: + - main + workflow_dispatch: + workflow_call: + +jobs: + tests: + if: github.repository == 'cutenode/nodevu' + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [current, lts/*, lts/-1] + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - name: Install most recent npm + run: npm install -g npm + - name: Run npm install -w newest + run: npm install -w newest + - name: Run npm test -w newest + run: npm test -w newest From 7d26d6e2acd138e5eb0b6dccf9ced2e8af5d62d5 Mon Sep 17 00:00:00 2001 From: Tierney Cyren Date: Fri, 8 Nov 2024 16:04:27 +0000 Subject: [PATCH 3/3] ci: add publishing workflow for @nodevu/newest Signed-off-by: Tierney Cyren --- .github/workflows/publish-newest.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/publish-newest.yml diff --git a/.github/workflows/publish-newest.yml b/.github/workflows/publish-newest.yml new file mode 100644 index 00000000..0eb09e75 --- /dev/null +++ b/.github/workflows/publish-newest.yml @@ -0,0 +1,22 @@ +name: Publish @nodevu/newest to npmjs +on: + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + # Setup .npmrc file to publish to npm + - uses: actions/setup-node@v4 + with: + node-version: 'latest' + registry-url: 'https://registry.npmjs.org' + - run: npm install -w newest + - run: npm run lint -w newest + - run: npm run coverage -w newest + - run: npm publish --provenance --access public -w newest + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}