Skip to content

Commit

Permalink
ref: use esm (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiangWeixian authored Jan 7, 2022
1 parent f45c6eb commit db8c461
Show file tree
Hide file tree
Showing 18 changed files with 1,804 additions and 2,250 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-rats-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@aiou/bin-template": major
---

build with esm
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["@aiou"],
"rules": {
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }]
}
}
3 changes: 0 additions & 3 deletions .eslintrc.js

This file was deleted.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@

## features

- Native ESM Module development
- Use [**commander**](https://github.com/tj/commander.js/) build cli application
- Interaction interface with [**inquirer**](https://github.com/SBoudrias/Inquirer.js/) and [**ora**](https://github.com/sindresorhus/ora)
- Type safe
- Release with github workflows and changeset
- PNPM

## install

Expand All @@ -33,4 +36,4 @@ display loading and loading text

## development

- `pnpm run dev`
- `pnpm run build`
16 changes: 0 additions & 16 deletions bin/cli.ts

This file was deleted.

27 changes: 0 additions & 27 deletions bin/hello.ts

This file was deleted.

2 changes: 2 additions & 0 deletions bin/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
import '../lib/cli.mjs'
3 changes: 0 additions & 3 deletions bin/index.ts

This file was deleted.

15 changes: 9 additions & 6 deletions jest.config.js → jest.config.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
/**
* @type {import('@jest/types').Config.InitialOptions}
*/
module.exports = {
export default {
testEnvironment: 'jest-environment-node',
cacheDirectory: './jest/cache',
collectCoverage: true,
collectCoverageFrom: ['src/**/*'],
coverageDirectory: './jest/coverage',
preset: 'ts-jest',
resetMocks: true,
resetModules: true,
restoreMocks: true,
globals: {
'ts-jest': {
diagnostics: false,
useESM: true,
},
},
resetMocks: true,
resetModules: true,
restoreMocks: true,
moduleNameMapper: {
'@/(.*)': '<rootDir>/src/$1',
},
roots: ['<rootDir>/test'],
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'],
testRegex: '/test/.+\\.test\\.tsx?$',
extensionsToTreatAsEsm: ['.ts'],
testRegex: '/test/.+\\.test\\.ts?$',
verbose: true,
}
85 changes: 50 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
{
"name": "@aiou/bin-template",
"version": "2.1.1",
"description": "templates for command project",
"description": "templates for cli project",
"keywords": [
"aiou",
"cli",
"neo",
"template"
],
"license": "MIT",
"homepage": "https://github.com/spring-catponents/bin-template#readme",
"homepage": "https://github.com/neo-hack/bin-template#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/spring-catponents/bin-template.git"
"url": "git+https://github.com/neo-hack/bin-template.git"
},
"bugs": {
"url": "https://github.com/spring-catponents/bin-template/issues",
"url": "https://github.com/neo-hack/bin-template/issues",
"email": "jiangweixian1994@gmail.com"
},
"author": {
"name": "JW",
"email": "jiangweixian1994@gmail.com",
"url": "https://twitter.com/jiangweixian"
},
"main": "dist/index.js",
"module": "dist/index.js",
"type": "module",
"bin": {
"bin-template": "dist/cli.js"
"bin-template": "bin/index.mjs"
},
"engines": {
"node": ">=12.20.0"
},
"scripts": {
"build": "rimraf lib && tsc",
"test": "pnpm run build && jest",
"build": "rimraf lib && rollup -c --silent --environment BUILD:production",
"dev": "rollup -c --silent -w",
"jest": "NO_COLOR=1 node --experimental-vm-modules node_modules/jest/bin/jest.js",
"test": "pnpm run build && pnpm run jest",
"ci:publish": "pnpm run build && pnpx changeset publish",
"ci:version": "pnpx changeset version",
"ci:snapshot": "pnpx changeset version --snapshot beta",
Expand All @@ -37,34 +47,39 @@
"eslint --fix"
]
},
"dependencies": {
"chalk": "4.1.1",
"commander": "8.0.0",
"inquirer": "8.1.2",
"ora": "5.4.1",
"tslib": "^2.3.1"
},
"dependencies": {},
"devDependencies": {
"@aiou/eslint-config": "0.2.1",
"@changesets/cli": "^2.16.0",
"@types/download": "8.0.1",
"@types/fs-extra": "9.0.12",
"@types/inquirer": "7.3.3",
"@types/jest": "^27.0.2",
"@types/node": "16.3.3",
"@types/rimraf": "3.0.1",
"@aiou/eslint-config": "^0.3.2",
"@changesets/cli": "^2.19.0",
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@types/download": "^8.0.1",
"@types/inquirer": "^8.1.3",
"@types/jest": "^27.4.0",
"@types/node": "17.0.8",
"@types/rimraf": "^3.0.2",
"commander": "8.3.0",
"consola": "^2.15.3",
"cz-emoji": "^1.3.1",
"eslint": "^7.30.0",
"execa": "^5.1.1",
"husky": "^7.0.0",
"jest": "^27.3.1",
"lint-staged": "^11.0.1",
"np": "7.5.0",
"prettier": "2.3.2",
"pretty-quick": "3.1.1",
"rimraf": "3.0.2",
"ts-jest": "^27.0.7",
"typescript": "4.3.5"
"esbuild": "^0.14.10",
"eslint": "7.x",
"execa": "^6.0.0",
"husky": "^7.0.4",
"inquirer": "8.2.0",
"jest": "^27.4.7",
"lint-staged": "^12.1.5",
"ora": "6.0.1",
"picocolors": "1.0.0",
"prettier": "^2.5.1",
"pretty-quick": "^3.1.3",
"rimraf": "^3.0.2",
"rollup": "^2.63.0",
"rollup-plugin-esbuild": "^4.8.2",
"rollup-plugin-size": "^0.2.2",
"ts-jest": "^27.1.2",
"typescript": "^4.5.4"
},
"config": {
"commitizen": {
Expand Down
Loading

0 comments on commit db8c461

Please sign in to comment.