Skip to content

Commit

Permalink
feat: enhance project configuration with modern setup (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton authored Nov 17, 2024
1 parent ef586f1 commit f16d17b
Show file tree
Hide file tree
Showing 20 changed files with 5,033 additions and 922 deletions.
13 changes: 0 additions & 13 deletions .babelrc

This file was deleted.

3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
dist
node_modules
8 changes: 0 additions & 8 deletions .eslintrc

This file was deleted.

14 changes: 14 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
extends: 'eslint:recommended',
parser: '@babel/eslint-parser',
env: {
browser: true,
node: true,
jest: true,
},
plugins: [
'@babel',
],
rules: {
},
};
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push:
branches:
- master
pull_request:
workflow_dispatch:

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- run: |
yarn run eslint
yarn run build
yarn run test
- uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
/.nyc_output
/lib
/build
/coverage
/dist
node_modules
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/coverage
package-lock.json
yarn.lock
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2017 Cheton Wu
Copyright (c) 2015-present Cheton Wu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: '@trendmicro/babel-config',
presets: [
'@babel/preset-env',
],
};
75 changes: 41 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gcode-parser",
"version": "1.3.7",
"version": "2.0.0",
"description": "G-code parser for Node.js",
"author": "Cheton Wu <[email protected]>",
"homepage": "https://github.com/cncjs/gcode-parser",
Expand All @@ -9,50 +9,57 @@
"type": "git",
"url": "[email protected]:cncjs/gcode-parser.git"
},
"engines": {
"node": ">=4"
},
"keywords": [
"cnc",
"gcode"
],
"scripts": {
"prepublish": "npm run eslint && npm run build && npm test",
"eslint": "eslint src",
"build": "babel --out-dir ./lib ./src",
"test": "cross-env NODE_ENV=test nyc mocha",
"coveralls": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls"
"build": "cross-env rollup --config rollup.config.mjs",
"clean": "del build coverage dist",
"eslint": "eslint --ext .js,.jsx,.mjs .",
"pre-push": "bash -c 'echo -e \"=> \\e[1;33m$npm_package_name\\e[0m\"' && yarn run build && yarn run eslint && yarn run test",
"prepublish": "yarn run build",
"test": "jest --maxWorkers=2"
},
"main": "lib/index.js",
"sideEffects": false,
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"files": [
"dist"
],
"dependencies": {},
"devDependencies": {
"@babel/cli": "~7.4.4",
"@babel/core": "~7.4.5",
"@babel/preset-env": "~7.4.5",
"@babel/register": "~7.4.4",
"@trendmicro/babel-config": "~1.0.0-alpha",
"babel-eslint": "^10.0.1",
"babel-plugin-istanbul": "^5.1.4",
"chai": "^4.2.0",
"coveralls": "^3.0.3",
"cross-env": "^5.2.0",
"eslint": "^5.16.0",
"eslint-config-trendmicro": "^1.4.1",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.13.0",
"mocha": "^6.1.4",
"nyc": "^14.1.1"
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/eslint-parser": "^7.0.0",
"@babel/eslint-plugin": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@rollup/plugin-babel": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@trendmicro/babel-config": "^1.0.2",
"cross-env": "^7.0.3",
"del-cli": "^5.0.0",
"eslint": "^8.25.0",
"jest": "^29.0.0",
"rollup": "^3"
},
"nyc": {
"require": [
"@babel/register"
"jest": {
"collectCoverage": true,
"collectCoverageFrom": [
"<rootDir>/src/**/*.js"
],
"reporter": [
"coverageReporters": [
"lcov",
"text"
"text",
"html"
],
"sourceMap": false,
"instrument": false
"modulePathIgnorePatterns": [],
"setupFiles": [],
"setupFilesAfterEnv": [],
"testEnvironment": "node",
"testMatch": [
"<rootDir>/**/__tests__/**/*.test.js"
]
}
}
45 changes: 45 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import path from 'path';
import { fileURLToPath } from 'url';
import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const input = path.resolve(__dirname, 'src', 'index.js');
const cjsOutputDirectory = path.resolve(__dirname, 'dist', 'cjs');
const esmOutputDirectory = path.resolve(__dirname, 'dist', 'esm');
const isExternal = id => !id.startsWith('.') && !id.startsWith('/');

export default [
{
input,
output: {
dir: cjsOutputDirectory,
format: 'cjs',

// https://rollupjs.org/guide/en/#changed-defaults
// https://rollupjs.org/guide/en/#outputinterop
interop: 'auto',
preserveModules: true,
},
external: isExternal,
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
],
},
{
input,
output: {
dir: esmOutputDirectory,
format: 'esm',
preserveModules: true,
},
external: isExternal,
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
],
}
];
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit f16d17b

Please sign in to comment.