Skip to content

Commit

Permalink
feat(ts): move to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
srod committed Feb 16, 2023
1 parent e93addf commit f3b9528
Show file tree
Hide file tree
Showing 16 changed files with 1,786 additions and 1,651 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ root = true
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/dist/*
25 changes: 19 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"env": {
"es6": true,
"node": true,
"jest": true,
"jasmine": true
"es6": true
},
"plugins": ["@typescript-eslint", "prettier"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"rules": {
"no-console": 0
},
"extends": "eslint:recommended"
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"no-console": 0,
"no-var": "error",
"strict": [2, "never"],
"@typescript-eslint/no-explicit-any": "off"
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
node_modules
coverage
.history
dist
2 changes: 2 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
9 changes: 7 additions & 2 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
tag-version-prefix=
save-prefix=
save-prefix=""
save-exact = true
tag-version-prefix=""
strict-peer-dependencies = false
auto-install-peers = true
lockfile = true
enable-pre-post-scripts = true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.21.1
1 change: 0 additions & 1 deletion .yarnrc

This file was deleted.

67 changes: 0 additions & 67 deletions __tests__/node-version-test.js

This file was deleted.

66 changes: 66 additions & 0 deletions __tests__/node-version.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*!
* node-version
* Copyright(c) 2011-2023 Rodolphe Stoclin
* MIT Licensed
*/

import { describe, expect, test } from 'vitest';
import nodeVersion from '../src';

const TARGET_NODE_MAJOR = '14';
const TARGET_NODE_MINOR = '21';
const TARGET_NODE_PATCH = '1';

describe('node-version', () => {
test('should be ok', () => {
expect(nodeVersion).toBeTruthy();
});

test('should have original property', () => {
expect(nodeVersion).toHaveProperty('original');
});

test('original value should be ok', () => {
expect(nodeVersion.original).toBe(`v${TARGET_NODE_MAJOR}.${TARGET_NODE_MINOR}.${TARGET_NODE_PATCH}`);
});

test('should have short property', () => {
expect(nodeVersion).toHaveProperty('short');
});

test('short value should be ok', () => {
expect(nodeVersion.short).toBe(`${TARGET_NODE_MAJOR}.${TARGET_NODE_MINOR}`);
});

test('should have long property', () => {
expect(nodeVersion).toHaveProperty('long');
});

test('long value should be ok', () => {
expect(nodeVersion.long).toBe(`${TARGET_NODE_MAJOR}.${TARGET_NODE_MINOR}.${TARGET_NODE_PATCH}`);
});

test('should have major property', () => {
expect(nodeVersion).toHaveProperty('major');
});

test('major value should be ok', () => {
expect(nodeVersion.major).toBe(TARGET_NODE_MAJOR);
});

test('should have minor property', () => {
expect(nodeVersion).toHaveProperty('minor');
});

test('minor value should be ok', () => {
expect(nodeVersion.minor).toBe(TARGET_NODE_MINOR);
});

test('should have build property', () => {
expect(nodeVersion).toHaveProperty('build');
});

test('build value should be ok', () => {
expect(nodeVersion.build).toBe(TARGET_NODE_PATCH);
});
});
20 changes: 0 additions & 20 deletions index.js

This file was deleted.

95 changes: 71 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,97 @@
"name": "node-version",
"version": "2.0.0",
"description": "Get Node current version",
"homepage": "https://github.com/srod/node-version",
"keywords": [
"node",
"version"
],
"author": {
"name": "Rodolphe Stoclin",
"email": "rodolphe@2clics.net",
"url": "http://2clics.net"
},
"homepage": "https://github.com/srod/node-version",
"license": "MIT",
"main": "./index.js",
"engines": {
"node": ">=14.0.0"
},
"packageManager": "pnpm@7.27.0",
"directories": {
"lib": "dist",
"test": "__tests__"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"files": [
"dist/**/*"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/srod/node-version.git"
},
"engines": {
"node": ">=14.0.0"
"bugs": {
"url": "https://github.com/srod/node-version/issues"
},
"keywords": [
"node",
"version"
],
"scripts": {
"eslint": "eslint index.js || true",
"pretest": "npm run eslint",
"test": "jest",
"clean": "pnpm dlx rimraf dist",
"build": "pnpm clean && tsup src/index.ts --format cjs,esm --dts --clean --sourcemap",
"prepublishOnly": "pnpm build",
"coverage": "vitest run --coverage",
"precoverage:ci": "pnpm run build && pnpm run eslint",
"coverage:ci": "vitest run --coverage",
"eslint": "eslint --ext .ts .",
"lint": "pnpm run eslint || true",
"release-patch": "npm version patch -m 'Bump %s' && git push --tags origin HEAD:master",
"release-minor": "npm version minor -m 'Bump %s' && git push --tags origin HEAD:master",
"release-major": "npm version major -m 'Bump %s' && git push --tags origin HEAD:master",
"pretest": "pnpm run build && pnpm run eslint",
"publish-latest": "npm publish",
"publish-beta": "npm publish --tag beta"
"publish-beta": "npm publish --tag beta",
"test": "vitest"
},
"devDependencies": {
"@tsconfig/node14": "1.0.3",
"@types/node": "18.13.0",
"@typescript-eslint/eslint-plugin": "5.52.0",
"@typescript-eslint/parser": "5.52.0",
"@vitest/coverage-c8": "0.28.5",
"codecov": "3.8.3",
"eslint": "8.34.0",
"jest": "29.4.3",
"node-notifier": "10.0.1"
},
"jest": {
"notify": true,
"verbose": true,
"testEnvironment": "node",
"coverageDirectory": "./coverage/",
"collectCoverage": true,
"testPathIgnorePatterns": [
"/node_modules/",
".history"
"eslint-config-prettier": "8.6.0",
"eslint-plugin-prettier": "4.2.1",
"husky": "8.0.3",
"lint-staged": "13.1.2",
"node-notifier": "10.0.1",
"prettier": "2.8.4",
"rimraf": "4.1.2",
"tsup": "6.6.3",
"typescript": "4.9.5",
"vitest": "0.28.5"
},
"lint-staged": {
"*.ts": [
"prettier --write",
"git add"
]
},
"prettier": {
"singleQuote": true,
"printWidth": 120,
"arrowParens": "avoid",
"trailingComma": "none"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}
Loading

0 comments on commit f3b9528

Please sign in to comment.