Skip to content

Commit

Permalink
feat: support cjs and esm both by tshy (#63)
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
fengmk2 authored Dec 31, 2024
1 parent 16d468e commit d9d0bc6
Show file tree
Hide file tree
Showing 70 changed files with 1,765 additions and 1,325 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "eslint-config-egg"
"extends": [
"eslint-config-egg/typescript",
"eslint-config-egg/lib/rules/enforce-node-prefix"
]
}
24 changes: 0 additions & 24 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ jobs:
name: Node.js
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
version: '16, 18, 20, 22'
version: '18.19.0, 18, 20, 22'
os: 'ubuntu-latest, macos-latest'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/pkg.pr.new.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish Any Commit
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm install

- name: Build
run: npm run prepublishOnly --if-present

- run: npx pkg-pr-new publish
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ test/fixtures/ts-pkg/app/controller/home.js
!test/fixtures/**/node_modules
package-lock.json
.package-lock.json
.tshy*
.eslintcache
dist
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# egg-scripts
# @eggjs/scripts

[![NPM version][npm-image]][npm-url]
[![Node.js CI](https://github.com/eggjs/scripts/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/scripts/actions/workflows/nodejs.yml)
[![Test coverage][codecov-image]][codecov-url]
[![npm download][download-image]][download-url]
[![Node.js Version](https://img.shields.io/node/v/@eggjs/scripts.svg?style=flat)](https://nodejs.org/en/download/)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)

[npm-image]: https://img.shields.io/npm/v/@eggjs/scripts.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@eggjs/scripts
[codecov-image]: https://codecov.io/github/eggjs/scripts/coverage.svg?branch=master
[codecov-url]: https://codecov.io/github/eggjs/scripts?branch=master
[download-image]: https://img.shields.io/npm/dm/@eggjs/scripts.svg?style=flat-square
[download-url]: https://npmjs.org/package/@eggjs/scripts

deploy tool for egg project.

Expand All @@ -7,7 +21,7 @@ deploy tool for egg project.
## Install

```bash
$ npm i egg-scripts --save
npm i @eggjs/scripts --save
```

## Usage
Expand Down Expand Up @@ -38,6 +52,7 @@ Start egg at prod mode.

```bash
$ eggctl start [options] [baseDir]

# Usage
# eggctl start --port=7001
# eggctl start ./server
Expand Down Expand Up @@ -67,6 +82,7 @@ Stop egg gracefull.

```bash
$ eggctl stop [options]

# Usage
# eggctl stop --title=example
```
Expand All @@ -85,12 +101,13 @@ In addition to the command line specification, options can also be specified in
"port": 1234,
"ignore-stderr": true,
// will pass as `node --max-http-header-size=20000`
"node-options--max-http-header-size": "20000"
"node-options--max-http-header-size": "20000",
// will pass as `node --allow-wasi`
"node-options--allow-wasi": true
}
}
```


## Questions & Suggestions

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

## Contributors

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

Made with [contributors-img](https://contrib.rocks).
3 changes: 3 additions & 0 deletions bin/dev.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
5 changes: 5 additions & 0 deletions bin/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning

import { execute } from '@oclif/core';

await execute({ development: true, dir: import.meta.url });
7 changes: 0 additions & 7 deletions bin/egg-scripts.js

This file was deleted.

3 changes: 3 additions & 0 deletions bin/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\run" %*
5 changes: 5 additions & 0 deletions bin/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

import { execute } from '@oclif/core';

await execute({ dir: import.meta.url });
19 changes: 0 additions & 19 deletions index.js

This file was deleted.

Loading

0 comments on commit d9d0bc6

Please sign in to comment.