Skip to content

Commit d9d0bc6

Browse files
authored
feat: support cjs and esm both by tshy (#63)
BREAKING CHANGE: drop Node.js < 18.19.0 support part of eggjs/egg#3644 eggjs/egg#5257 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Added support for ECMAScript modules (ESM). - Enhanced CLI with more robust start and stop commands. - Improved TypeScript integration and type safety. - Introduced new commands for stopping an Egg.js server application. - Added new configuration options for logging and process management. - **Improvements** - Updated package configuration for better modularity. - Modernized test infrastructure with TypeScript support. - Refined error handling and logging mechanisms. - Enhanced process management capabilities. - Improved documentation with updated installation instructions and usage examples. - **Breaking Changes** - Renamed package from `egg-scripts` to `@eggjs/scripts`. - Requires Node.js version 18.19.0 or higher. - Significant changes to project structure and module exports. - **Bug Fixes** - Improved process management for server start and stop operations. - Enhanced cross-platform compatibility. - Fixed issues with asynchronous route handlers in various applications. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 16d468e commit d9d0bc6

70 files changed

Lines changed: 1765 additions & 1325 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "eslint-config-egg"
2+
"extends": [
3+
"eslint-config-egg/typescript",
4+
"eslint-config-egg/lib/rules/enforce-node-prefix"
5+
]
36
}

.github/PULL_REQUEST_TEMPLATE.md

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

.github/workflows/nodejs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ jobs:
1111
name: Node.js
1212
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
1313
with:
14-
version: '16, 18, 20, 22'
14+
version: '18.19.0, 18, 20, 22'
15+
os: 'ubuntu-latest, macos-latest'
16+
secrets:
17+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/pkg.pr.new.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish Any Commit
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- name: Checkout code
10+
uses: actions/checkout@v4
11+
12+
- run: corepack enable
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: 20
16+
17+
- name: Install dependencies
18+
run: npm install
19+
20+
- name: Build
21+
run: npm run prepublishOnly --if-present
22+
23+
- run: npx pkg-pr-new publish

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ test/fixtures/ts-pkg/app/controller/home.js
1111
!test/fixtures/**/node_modules
1212
package-lock.json
1313
.package-lock.json
14+
.tshy*
15+
.eslintcache
16+
dist

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
# egg-scripts
1+
# @eggjs/scripts
2+
3+
[![NPM version][npm-image]][npm-url]
4+
[![Node.js CI](https://github.com/eggjs/scripts/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/scripts/actions/workflows/nodejs.yml)
5+
[![Test coverage][codecov-image]][codecov-url]
6+
[![npm download][download-image]][download-url]
7+
[![Node.js Version](https://img.shields.io/node/v/@eggjs/scripts.svg?style=flat)](https://nodejs.org/en/download/)
8+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
9+
10+
[npm-image]: https://img.shields.io/npm/v/@eggjs/scripts.svg?style=flat-square
11+
[npm-url]: https://npmjs.org/package/@eggjs/scripts
12+
[codecov-image]: https://codecov.io/github/eggjs/scripts/coverage.svg?branch=master
13+
[codecov-url]: https://codecov.io/github/eggjs/scripts?branch=master
14+
[download-image]: https://img.shields.io/npm/dm/@eggjs/scripts.svg?style=flat-square
15+
[download-url]: https://npmjs.org/package/@eggjs/scripts
216

317
deploy tool for egg project.
418

@@ -7,7 +21,7 @@ deploy tool for egg project.
721
## Install
822

923
```bash
10-
$ npm i egg-scripts --save
24+
npm i @eggjs/scripts --save
1125
```
1226

1327
## Usage
@@ -38,6 +52,7 @@ Start egg at prod mode.
3852

3953
```bash
4054
$ eggctl start [options] [baseDir]
55+
4156
# Usage
4257
# eggctl start --port=7001
4358
# eggctl start ./server
@@ -67,6 +82,7 @@ Stop egg gracefull.
6782

6883
```bash
6984
$ eggctl stop [options]
85+
7086
# Usage
7187
# eggctl stop --title=example
7288
```
@@ -85,12 +101,13 @@ In addition to the command line specification, options can also be specified in
85101
"port": 1234,
86102
"ignore-stderr": true,
87103
// will pass as `node --max-http-header-size=20000`
88-
"node-options--max-http-header-size": "20000"
104+
"node-options--max-http-header-size": "20000",
105+
// will pass as `node --allow-wasi`
106+
"node-options--allow-wasi": true
89107
}
90108
}
91109
```
92110

93-
94111
## Questions & Suggestions
95112

96113
Please open an issue [here](https://github.com/eggjs/egg/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).
@@ -101,6 +118,6 @@ Please open an issue [here](https://github.com/eggjs/egg/issues?q=is%3Aissue+is%
101118

102119
## Contributors
103120

104-
[![Contributors](https://contrib.rocks/image?repo=eggjs/egg-scripts)](https://github.com/eggjs/egg-scripts/graphs/contributors)
121+
[![Contributors](https://contrib.rocks/image?repo=eggjs/scripts)](https://github.com/eggjs/scripts/graphs/contributors)
105122

106123
Made with [contributors-img](https://contrib.rocks).

bin/dev.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*

bin/dev.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning
2+
3+
import { execute } from '@oclif/core';
4+
5+
await execute({ development: true, dir: import.meta.url });

bin/egg-scripts.js

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

bin/run.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node "%~dp0\run" %*

0 commit comments

Comments
 (0)