Skip to content

Commit f7f4539

Browse files
committed
feat: enhance project configuration with modern setup
1 parent ef586f1 commit f7f4539

20 files changed

+5033
-922
lines changed

.babelrc

Lines changed: 0 additions & 13 deletions
This file was deleted.

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build
2+
dist
3+
node_modules

.eslintrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

.eslintrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
extends: 'eslint:recommended',
3+
parser: '@babel/eslint-parser',
4+
env: {
5+
browser: true,
6+
node: true,
7+
jest: true,
8+
},
9+
plugins: [
10+
'@babel',
11+
],
12+
rules: {
13+
},
14+
};

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
node-version: [20.x]
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
- run: yarn
26+
- run: |
27+
yarn run eslint
28+
yarn run build
29+
yarn run test
30+
- uses: codecov/codecov-action@v4
31+
env:
32+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
node_modules
2-
/.nyc_output
3-
/lib
1+
/build
42
/coverage
3+
/dist
4+
node_modules

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/coverage
1+
package-lock.json
2+
yarn.lock

.travis.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015-2017 Cheton Wu
3+
Copyright (c) 2015-present Cheton Wu
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

babel.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
extends: '@trendmicro/babel-config',
3+
presets: [
4+
'@babel/preset-env',
5+
],
6+
};

package.json

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gcode-parser",
3-
"version": "1.3.7",
3+
"version": "2.0.0",
44
"description": "G-code parser for Node.js",
55
"author": "Cheton Wu <[email protected]>",
66
"homepage": "https://github.com/cncjs/gcode-parser",
@@ -9,50 +9,57 @@
99
"type": "git",
1010
"url": "[email protected]:cncjs/gcode-parser.git"
1111
},
12-
"engines": {
13-
"node": ">=4"
14-
},
1512
"keywords": [
1613
"cnc",
1714
"gcode"
1815
],
1916
"scripts": {
20-
"prepublish": "npm run eslint && npm run build && npm test",
21-
"eslint": "eslint src",
22-
"build": "babel --out-dir ./lib ./src",
23-
"test": "cross-env NODE_ENV=test nyc mocha",
24-
"coveralls": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls"
17+
"build": "cross-env rollup --config rollup.config.mjs",
18+
"clean": "del build coverage dist",
19+
"eslint": "eslint --ext .js,.jsx,.mjs .",
20+
"pre-push": "bash -c 'echo -e \"=> \\e[1;33m$npm_package_name\\e[0m\"' && yarn run build && yarn run eslint && yarn run test",
21+
"prepublish": "yarn run build",
22+
"test": "jest --maxWorkers=2"
2523
},
26-
"main": "lib/index.js",
24+
"sideEffects": false,
25+
"main": "dist/cjs/index.js",
26+
"module": "dist/esm/index.js",
27+
"files": [
28+
"dist"
29+
],
2730
"dependencies": {},
2831
"devDependencies": {
29-
"@babel/cli": "~7.4.4",
30-
"@babel/core": "~7.4.5",
31-
"@babel/preset-env": "~7.4.5",
32-
"@babel/register": "~7.4.4",
33-
"@trendmicro/babel-config": "~1.0.0-alpha",
34-
"babel-eslint": "^10.0.1",
35-
"babel-plugin-istanbul": "^5.1.4",
36-
"chai": "^4.2.0",
37-
"coveralls": "^3.0.3",
38-
"cross-env": "^5.2.0",
39-
"eslint": "^5.16.0",
40-
"eslint-config-trendmicro": "^1.4.1",
41-
"eslint-plugin-import": "^2.17.2",
42-
"eslint-plugin-jsx-a11y": "^6.2.1",
43-
"eslint-plugin-react": "^7.13.0",
44-
"mocha": "^6.1.4",
45-
"nyc": "^14.1.1"
32+
"@babel/cli": "^7.0.0",
33+
"@babel/core": "^7.0.0",
34+
"@babel/eslint-parser": "^7.0.0",
35+
"@babel/eslint-plugin": "^7.0.0",
36+
"@babel/plugin-transform-runtime": "^7.0.0",
37+
"@babel/preset-env": "^7.0.0",
38+
"@rollup/plugin-babel": "^6.0.0",
39+
"@rollup/plugin-node-resolve": "^15.0.0",
40+
"@trendmicro/babel-config": "^1.0.2",
41+
"cross-env": "^7.0.3",
42+
"del-cli": "^5.0.0",
43+
"eslint": "^8.25.0",
44+
"jest": "^29.0.0",
45+
"rollup": "^3"
4646
},
47-
"nyc": {
48-
"require": [
49-
"@babel/register"
47+
"jest": {
48+
"collectCoverage": true,
49+
"collectCoverageFrom": [
50+
"<rootDir>/src/**/*.js"
5051
],
51-
"reporter": [
52+
"coverageReporters": [
5253
"lcov",
53-
"text"
54+
"text",
55+
"html"
5456
],
55-
"sourceMap": false,
56-
"instrument": false
57+
"modulePathIgnorePatterns": [],
58+
"setupFiles": [],
59+
"setupFilesAfterEnv": [],
60+
"testEnvironment": "node",
61+
"testMatch": [
62+
"<rootDir>/**/__tests__/**/*.test.js"
63+
]
5764
}
5865
}

rollup.config.mjs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import path from 'path';
2+
import { fileURLToPath } from 'url';
3+
import { babel } from '@rollup/plugin-babel';
4+
import { nodeResolve } from '@rollup/plugin-node-resolve';
5+
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = path.dirname(__filename);
8+
9+
const input = path.resolve(__dirname, 'src', 'index.js');
10+
const cjsOutputDirectory = path.resolve(__dirname, 'dist', 'cjs');
11+
const esmOutputDirectory = path.resolve(__dirname, 'dist', 'esm');
12+
const isExternal = id => !id.startsWith('.') && !id.startsWith('/');
13+
14+
export default [
15+
{
16+
input,
17+
output: {
18+
dir: cjsOutputDirectory,
19+
format: 'cjs',
20+
21+
// https://rollupjs.org/guide/en/#changed-defaults
22+
// https://rollupjs.org/guide/en/#outputinterop
23+
interop: 'auto',
24+
preserveModules: true,
25+
},
26+
external: isExternal,
27+
plugins: [
28+
nodeResolve(),
29+
babel({ babelHelpers: 'bundled' }),
30+
],
31+
},
32+
{
33+
input,
34+
output: {
35+
dir: esmOutputDirectory,
36+
format: 'esm',
37+
preserveModules: true,
38+
},
39+
external: isExternal,
40+
plugins: [
41+
nodeResolve(),
42+
babel({ babelHelpers: 'bundled' }),
43+
],
44+
}
45+
];
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)