-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support cjs and esm both by tshy #279
Changes from 25 commits
89f3ec5
a04021d
eebc2f6
4917ce9
dd858a9
e0ccbc7
afb8d34
b1a61fc
07d15fb
7255dbd
996f96a
e20d85a
d7b3540
f26d53f
b08f033
961eb75
029a9d0
b2d53a8
ae0db57
5a8dae3
825206a
164e1e6
13428be
e1bc617
78339a1
70f5ec7
5a6fb3b
a02f3b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
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 | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add safeguards to the publish step The publish step lacks version and authentication checks. Consider adding these safeguards: - - run: npx pkg-pr-new publish
+ - name: Publish
+ if: startsWith(github.ref, 'refs/tags/v')
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ run: |
+ echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
+ npx pkg-pr-new publish 📝 Committable suggestion
Suggested change
|
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" %* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning --no-deprecation | ||
|
||
import { execute } from '@oclif/core'; | ||
|
||
await execute({ | ||
// development: true, | ||
dir: import.meta.url, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
|
||
node "%~dp0\run" %* |
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 }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,122 @@ | ||
{ | ||
"name": "egg-bin", | ||
"version": "6.13.0", | ||
"name": "@eggjs/bin", | ||
"version": "7.0.0-beta.4", | ||
Comment on lines
+2
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Breaking changes need to be documented in CHANGELOG.md and README.md The package introduces significant breaking changes without proper documentation:
While the README.md shows the new package name in badges and installation instructions, there's no clear migration guide or documentation of breaking changes for users upgrading from previous versions. The CHANGELOG.md also lacks entries for version 7.0.0-beta.4.
🔗 Analysis chainBreaking changes need clear documentation This update introduces significant breaking changes:
Let's verify if these breaking changes are documented: Also applies to: 17-19 Let's gather more information to check for documentation about the specific breaking changes in the current version. Let's check one more thing to see if there are any recent commits or PRs that might document these changes. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check if breaking changes are documented in changelog or readme
rg -i "breaking|migration|upgrade" README.md CHANGELOG.md
Length of output: 1234 Script: #!/bin/bash
# Check recent changes and migration guides
rg -i "7\.0\.0|@eggjs/bin|node.*18" README.md CHANGELOG.md -A 3
# Check package.json for any migration or upgrade notes
cat package.json
Length of output: 4710 Script: #!/bin/bash
# Check recent commits and PRs for documentation
git log -n 10 --oneline
# Check if there's a migration guide or docs directory
fd -t f -e md
Length of output: 38 |
||
"publishConfig": { | ||
"tag": "latest" | ||
"access": "public" | ||
}, | ||
"description": "egg developer tool", | ||
"files": [ | ||
"dist", | ||
"scripts" | ||
], | ||
"main": "dist/index.js", | ||
"bin": { | ||
"egg-bin": "dist/bin/cli.js" | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:eggjs/bin.git" | ||
}, | ||
"bug": { | ||
"url": "https://github.com/eggjs/egg/issues" | ||
}, | ||
"homepage": "https://github.com/eggjs/bin", | ||
"author": "fengmk2 <fengmk2@gmail.com> (https://github.com/fengmk2)", | ||
"engines": { | ||
"node": ">= 18.19.0" | ||
}, | ||
"dependencies": { | ||
"@artus-cli/artus-cli": "^0.2.9", | ||
"@artus-cli/plugin-autocomplete": "^0.1.1", | ||
"@artus-cli/plugin-version": "^1.0.1", | ||
"@eggjs/utils": "^4.0.2", | ||
"@eggjs/utils": "^4.1.2", | ||
"@oclif/core": "^4.2.0", | ||
"@types/mocha": "^10.0.10", | ||
"@types/supertest": "^6.0.2", | ||
"c8": "^10.0.0", | ||
"detect-port": "^2.0.0", | ||
"egg-ts-helper": "^2.1.0", | ||
"globby": "^11.1.0", | ||
"jest-changed-files": "^29.4.2", | ||
"mocha": "^10.2.0", | ||
"mocha": "^11.0.1", | ||
"mochawesome-with-mocha": "^7.1.3", | ||
"runscript": "^2.0.0", | ||
"ts-node": "^10.9.2", | ||
"tsconfig-paths": "^4.1.2" | ||
"tsconfig-paths": "^4.1.2", | ||
"utility": "^2.4.0" | ||
}, | ||
"peerDependencies": { | ||
"egg-mock": ">=5.10.2" | ||
"@eggjs/mock": "beta" | ||
}, | ||
"peerDependenciesMeta": { | ||
"egg-mock": { | ||
"@eggjs/mock": { | ||
"optional": true | ||
} | ||
Comment on lines
+38
to
43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Pin beta dependencies to specific versions for better stability Both packages have specific beta versions available that should be used instead of the generic "beta" tag:
Update the dependencies to use specific versions:
This ensures consistent builds and prevents unexpected updates to newer beta versions. 🔗 Analysis chainVerify stability of beta dependencies The following dependencies are using beta versions:
While this might be intentional during development, consider pinning to specific beta versions for better reproducibility. Let's check the stability of these beta versions: Also applies to: 59-59 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check beta dependencies stability
# Verify if specific beta versions are available
# Check available versions
npm view @eggjs/mock versions --json
npm view egg versions --json
Length of output: 2462 |
||
}, | ||
"devDependencies": { | ||
"@eggjs/tsconfig": "^1.3.0", | ||
"@arethetypeswrong/cli": "^0.17.1", | ||
"@eggjs/mock": "beta", | ||
"@eggjs/tsconfig": "1", | ||
"@swc-node/register": "^1.6.1", | ||
"@swc/core": "^1.3.35", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^22.10.1", | ||
"@types/node": "22", | ||
"assert-file": "^1.0.0", | ||
"coffee": "^5.4.0", | ||
"coffee": "^5.5.1", | ||
"cpy": "^8.1.2", | ||
"egg": "^3.9.1", | ||
"egg-mock": "^5.10.2", | ||
"cpy-cli": "^5.0.0", | ||
"cross-env": "^7.0.3", | ||
"egg": "beta", | ||
"esbuild": "^0.17.7", | ||
"esbuild-register": "^3.4.2", | ||
"eslint": "^8.16.0", | ||
"eslint-config-egg": "^13.1.0", | ||
"npminstall": "^7.5.0", | ||
"typescript": "^5.2.2" | ||
"eslint": "8", | ||
"eslint-config-egg": "14", | ||
"npminstall": "^7.12.0", | ||
"rimraf": "6", | ||
"supertest": "^7.0.0", | ||
"tshy": "3", | ||
"tshy-after": "1", | ||
"typescript": "5" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:eggjs/egg-bin.git" | ||
"scripts": { | ||
"postinstall-skip": "node scripts/postinstall.mjs", | ||
"lint": "eslint --cache src test --ext .ts", | ||
"pretest": "npm run clean && npm run lint -- --fix && npm run prepublishOnly", | ||
"test": "node bin/run.js test", | ||
"cov": "c8 --temp-directory node_modules/.c8_output -r text-summary -r json-summary -r json -r lcov -r cobertura node bin/run.js test", | ||
"preci": "npm run clean && npm run lint && npm run prepublishOnly", | ||
"ci": "npm run cov", | ||
"clean": "rimraf dist", | ||
"copyScripts": "rimraf dist/scripts && cpy scripts dist", | ||
"prepublishOnly": "tshy && tshy-after && attw --pack && npm run copyScripts" | ||
}, | ||
"bug": { | ||
"url": "https://github.com/eggjs/egg/issues" | ||
"type": "module", | ||
"tshy": { | ||
"exports": { | ||
".": "./src/index.ts", | ||
"./package.json": "./package.json" | ||
} | ||
}, | ||
"homepage": "https://github.com/eggjs/egg-bin", | ||
"author": "fengmk2 <fengmk2@gmail.com> (https://github.com/fengmk2)", | ||
"scripts": { | ||
"postinstall": "node scripts/postinstall.js", | ||
"contributor": "git-contributor", | ||
"lint": "eslint . --cache --ext ts", | ||
"test": "npm run lint -- --fix && npm run test-local", | ||
"test-local": "npm run tsc && node dist/bin/cli.js test", | ||
"test-local-with-ts-node-transpile-only": "node -r ts-node/register/transpile-only src/bin/cli.ts test", | ||
"test-local-with-swc": "node -r @swc-node/register src/bin/cli.ts test", | ||
"test-local-with-esbuild": "node -r esbuild-register src/bin/cli.ts test", | ||
"test-tsc": "npm run clean && npm run tsc && node dist/bin/cli.js && node dist/bin/cli.js test --base test/fixtures/example-ts && node dist/bin/cli.js dev --base test/fixtures/example-ts", | ||
"cov": "c8 -r lcov -r text-summary -x 'test/**' npm run test-local -- --timeout 120000", | ||
"ci": "npm run lint && npm run test-local && npm run test-tsc", | ||
"prepublishOnly": "npm run clean && npm run tsc", | ||
"tsc": "tsc", | ||
"clean": "rm -rf dist" | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/esm/index.d.ts", | ||
"default": "./dist/esm/index.js" | ||
}, | ||
"require": { | ||
"types": "./dist/commonjs/index.d.ts", | ||
"default": "./dist/commonjs/index.js" | ||
} | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"engines": { | ||
"node": ">= 16.19.0" | ||
"files": [ | ||
"bin", | ||
"dist", | ||
"src", | ||
"scripts" | ||
], | ||
"bin": { | ||
"egg-bin": "./bin/run.js" | ||
}, | ||
"types": "./dist/commonjs/index.d.ts", | ||
"main": "./dist/commonjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"oclif": { | ||
"bin": "egg-bin", | ||
"commands": "./dist/esm/commands", | ||
"dirname": "egg-bin", | ||
"topicSeparator": " ", | ||
"additionalHelpFlags": [ | ||
"-h" | ||
] | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add conditions to prevent unintended publishes
Running the publish workflow on both push and pull_request events without conditions could lead to unintended publishes.
Add conditions to ensure publishing only occurs on intended events. Here's a suggested change:
📝 Committable suggestion