-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enhance project configuration with modern setup
- Loading branch information
Showing
18 changed files
with
4,808 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build | ||
dist | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: { | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- v2 | ||
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
node_modules | ||
/.nyc_output | ||
/build | ||
/coverage | ||
/dist | ||
/lib | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
/.nyc_output | ||
/coverage | ||
/dist | ||
package-lock.json | ||
yarn.lock |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
extends: '@trendmicro/babel-config', | ||
presets: [ | ||
'@babel/preset-env', | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,8 @@ | ||
{ | ||
"name": "cncjs-controller", | ||
"version": "2.0.0-alpha.2", | ||
"version": "2.0.0-alpha.3", | ||
"description": "A controller library for event-based communication between client and CNCjs server.", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"prepublish": "npm run eslint && npm test && npm run clean && npm run build && npm run dist", | ||
"build": "babel --out-dir ./lib ./src", | ||
"dist": "webpack", | ||
"clean": "rm -rf lib/* dist/*", | ||
"eslint": "eslint ./src", | ||
"test": "tap test/*.js --node-arg=--require --node-arg=babel-register --node-arg=--require --node-arg=babel-polyfill", | ||
"coveralls": "tap test/*.js --coverage --coverage-report=text-lcov --nyc-arg=--require --nyc-arg=babel-register --nyc-arg=--require --nyc-arg=babel-polyfill | coveralls" | ||
}, | ||
"author": "Cheton Wu <[email protected]>", | ||
"contributors": [ | ||
{ | ||
"name": "Cheton Wu", | ||
"email": "[email protected]", | ||
"url": "https://github.com/cheton" | ||
} | ||
], | ||
"author": "Cheton Wu", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
|
@@ -33,25 +16,53 @@ | |
"events", | ||
"client" | ||
], | ||
"scripts": { | ||
"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" | ||
}, | ||
"sideEffects": false, | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"files": [ | ||
"dist" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"babel-cli": "~6.24.1", | ||
"babel-core": "~6.24.1", | ||
"babel-eslint": "~7.2.3", | ||
"babel-preset-es2015": "~6.24.1", | ||
"babel-preset-stage-0": "~6.24.1", | ||
"coveralls": "~2.13.1", | ||
"eslint": "~3.19.0", | ||
"eslint-config-trendmicro": "~0.5.1", | ||
"eslint-plugin-import": "~2.2.0", | ||
"eslint-plugin-jsx-a11y": "~2.2.3", | ||
"eslint-plugin-react": "~6.10.0", | ||
"tap": "~10.3.2", | ||
"webpack": "~3.5.6" | ||
"@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": { | ||
"exclude": [ | ||
"test/index.js" | ||
"jest": { | ||
"collectCoverage": true, | ||
"collectCoverageFrom": [ | ||
"<rootDir>/src/**/*.js" | ||
], | ||
"coverageReporters": [ | ||
"lcov", | ||
"text", | ||
"html" | ||
], | ||
"modulePathIgnorePatterns": [], | ||
"setupFiles": [], | ||
"setupFilesAfterEnv": [], | ||
"testEnvironment": "node", | ||
"testMatch": [ | ||
"<rootDir>/**/__tests__/**/*.test.js" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' }), | ||
], | ||
} | ||
]; |
Oops, something went wrong.