diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 000000000..437c56272 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,57 @@ +--- +name: "🐛 Bug Report" +description: Report a bug +title: "[Bug]: Bug title" +labels: [bug] +assignees: [] +body: + - type: textarea + id: description + attributes: + label: Describe the bug + description: What is the problem? + placeholder: A clear and concise description of the bug. + validations: + required: true + - type: textarea + id: reproduction + attributes: + label: Reproduction Steps + description: Reproducible repository address, fast code, screenshot or screen recording, etc... + validations: + required: true + - type: textarea + id: observed-behavior + attributes: + label: Observed Behavior + description: | + What actually happened? + + Please include full errors, uncaught exceptions, stack traces, and relevant logs. + If service responses are relevant, please include wire logs. + validations: + required: true + - type: textarea + id: expected-behavior + attributes: + label: Expected Behavior + description: | + What did you expect to happen? + validations: + required: true + - type: textarea + id: solution + attributes: + label: Possible Solution + description: | + Suggest a fix/reason for the bug + validations: + required: false + - type: textarea + id: context + attributes: + label: Additional Information/Context + description: | + Anything else that might be relevant for troubleshooting this bug. Providing context helps us come up with a solution that is most useful in the real world. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..b2c060171 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,6 @@ +--- +blank_issues_enabled: false +contact_links: + - name: 💬 General Question + url: 2565978507@qq.com + about: Please ask and answer questions as a discussion thread diff --git a/.github/ISSUE_TEMPLATE/discuss.yml b/.github/ISSUE_TEMPLATE/discuss.yml new file mode 100644 index 000000000..183f3cf84 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/discuss.yml @@ -0,0 +1,21 @@ +--- +name: "💬 Discuss" +description: Start a discussion +title: "[Discuss]: Discuss title" +labels: [discuss] +assignees: [] +body: + - type: textarea + id: description + attributes: + label: Discuss topic + validations: + required: true + - type: textarea + id: reproduction + attributes: + label: Screenshots + - type: textarea + id: observed-behavior + attributes: + label: Useful Links diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml new file mode 100644 index 000000000..eeae5639f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -0,0 +1,23 @@ +--- +name: "🚀 Feature" +description: Start a feature request +title: "[Feature]: Feature title" +labels: [feature] +assignees: [] +body: + - type: textarea + id: Why + attributes: + label: Why you want this Feature? + description: What is the usage scenario? + validations: + required: true + - type: textarea + id: Use + attributes: + label: Describe the solution you'd like + description: How to use it? + - type: textarea + id: additional + attributes: + label: Additional context diff --git a/.github/workflows/check-pr-title.yml b/.github/workflows/check-pr-title.yml new file mode 100644 index 000000000..46ec7de6a --- /dev/null +++ b/.github/workflows/check-pr-title.yml @@ -0,0 +1,20 @@ +name: check-pr-title + +on: + pull_request: + types: + - opened + - reopened + - edited + - synchronize + branches: + - master + - dev + +jobs: + lint-title: + runs-on: ubuntu-latest + steps: + - uses: ArcBlock/action-lint-pull-request-title@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/publish-beta-to-npm.yaml b/.github/workflows/publish-beta-to-npm.yaml new file mode 100644 index 000000000..02ec282b4 --- /dev/null +++ b/.github/workflows/publish-beta-to-npm.yaml @@ -0,0 +1,36 @@ +name: publish-beta-to-npm + +on: + push: + branches: [master] + +jobs: + publish-beta-to-npm: + runs-on: ubuntu-latest + if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" + steps: + - name: Checkout release branch code + uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + registry-url: "https://registry.npmjs.org" + + - name: Install deps + run: npm install + + - name: Build + run: npm run build + + - name: Publish to NPM + run: | + node scripts/update-beta-package-version.js + cat package.json | grep version + npm publish --tag beta + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/publish-to-npm.yaml b/.github/workflows/publish-to-npm.yaml new file mode 100644 index 000000000..5ff1e9d99 --- /dev/null +++ b/.github/workflows/publish-to-npm.yaml @@ -0,0 +1,32 @@ +name: publish-to-npm + +on: + push: + branches: [release] + +jobs: + publish-to-npm: + runs-on: ubuntu-latest + steps: + - name: Checkout release branch code + uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + registry-url: "https://registry.npmjs.org" + + - name: Install deps + run: npm install + + - name: Build + run: npm run build + + - name: Publish to NPM + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/task-list-checker.yml b/.github/workflows/task-list-checker.yml new file mode 100644 index 000000000..d0692475d --- /dev/null +++ b/.github/workflows/task-list-checker.yml @@ -0,0 +1,12 @@ +name: task-list-checker +on: + pull_request: + types: [opened, edited, synchronize, reopened] +jobs: + task-list-checker: + runs-on: ubuntu-latest + steps: + - name: Check for incomplete task list items + uses: Shopify/task-list-checker@main + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..d828bf783 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "cSpell.words": [ + "arcblock" + ] +} \ No newline at end of file diff --git a/examples/test-all-keymetrics-features/actions-fibonacci.js b/examples/test-all-keymetrics-features/actions-fibonacci.js index 608753f69..7c27e71fb 100644 --- a/examples/test-all-keymetrics-features/actions-fibonacci.js +++ b/examples/test-all-keymetrics-features/actions-fibonacci.js @@ -47,7 +47,7 @@ function fib(n) { } -var axm = require('@pm2/io'); +var axm = require('@arcblock/pm2.io'); axm.action('load:start', function(reply) { fib(50000); diff --git a/examples/test-all-keymetrics-features/custom_action.js b/examples/test-all-keymetrics-features/custom_action.js index d11d82572..deeddbb67 100644 --- a/examples/test-all-keymetrics-features/custom_action.js +++ b/examples/test-all-keymetrics-features/custom_action.js @@ -1,5 +1,5 @@ -var axm = require('@pm2/io'); +var axm = require('@arcblock/pm2.io'); axm.action('getEnv', function(reply) { reply(process.env); diff --git a/examples/test-all-keymetrics-features/custom_action_with_params.js b/examples/test-all-keymetrics-features/custom_action_with_params.js index 023c75e77..c9c96dacf 100644 --- a/examples/test-all-keymetrics-features/custom_action_with_params.js +++ b/examples/test-all-keymetrics-features/custom_action_with_params.js @@ -1,5 +1,5 @@ -var axm = require('@pm2/io'); +var axm = require('@arcblock/pm2.io'); axm.action('refresh:db', { comment : 'Refresh the database' }, function(reply) { console.log('Refreshing'); diff --git a/examples/test-all-keymetrics-features/event.js b/examples/test-all-keymetrics-features/event.js index 3c092ac14..7cd1d4279 100644 --- a/examples/test-all-keymetrics-features/event.js +++ b/examples/test-all-keymetrics-features/event.js @@ -1,5 +1,5 @@ -var axm = require('@pm2/io'); +var axm = require('@arcblock/pm2.io'); setInterval(function() { diff --git a/examples/test-all-keymetrics-features/http_app.js b/examples/test-all-keymetrics-features/http_app.js index 2e24737a9..3992c6e97 100644 --- a/examples/test-all-keymetrics-features/http_app.js +++ b/examples/test-all-keymetrics-features/http_app.js @@ -1,6 +1,6 @@ -var io = require('@pm2/io').init({ http : true }); +var io = require('@arcblock/pm2.io').init({ http : true }); var probe = io.probe(); var http = require('http'); diff --git a/examples/test-all-keymetrics-features/http_transaction.js b/examples/test-all-keymetrics-features/http_transaction.js index 1334ea85b..d6e476eda 100644 --- a/examples/test-all-keymetrics-features/http_transaction.js +++ b/examples/test-all-keymetrics-features/http_transaction.js @@ -1,6 +1,6 @@ -var axm = require('@pm2/io'); +var axm = require('@arcblock/pm2.io'); var probe = axm.probe(); diff --git a/examples/test-all-keymetrics-features/pm2_probe.js b/examples/test-all-keymetrics-features/pm2_probe.js index a8741ae3c..878477216 100644 --- a/examples/test-all-keymetrics-features/pm2_probe.js +++ b/examples/test-all-keymetrics-features/pm2_probe.js @@ -1,4 +1,4 @@ -var io = require('@pm2/io'); +var io = require('@arcblock/pm2.io'); var pm2 = require('../..'); var fs = require('fs'); var path = require('path'); diff --git a/examples/test-all-keymetrics-features/probes.js b/examples/test-all-keymetrics-features/probes.js index 082e6de5e..3d6a992e0 100644 --- a/examples/test-all-keymetrics-features/probes.js +++ b/examples/test-all-keymetrics-features/probes.js @@ -1,6 +1,6 @@ -var io = require('@pm2/io'); +var io = require('@arcblock/pm2.io'); var users = { 'alex' : 'ok', diff --git a/examples/test-all-keymetrics-features/process-transpose.js b/examples/test-all-keymetrics-features/process-transpose.js index d02ed7e85..cf4861aab 100644 --- a/examples/test-all-keymetrics-features/process-transpose.js +++ b/examples/test-all-keymetrics-features/process-transpose.js @@ -1,5 +1,5 @@ -var Probe = require('@pm2/io').probe(); +var Probe = require('@arcblock/pm2.io').probe(); var counter = 0; diff --git a/examples/test-all-keymetrics-features/scoped-actions.js b/examples/test-all-keymetrics-features/scoped-actions.js index 427dcc8c6..d596b25b3 100644 --- a/examples/test-all-keymetrics-features/scoped-actions.js +++ b/examples/test-all-keymetrics-features/scoped-actions.js @@ -1,5 +1,5 @@ -var io = require('@pm2/io'); +var io = require('@arcblock/pm2.io'); io.scopedAction('simple test', function(data, emitter) { var i = setInterval(function() { diff --git a/examples/test-all-keymetrics-features/test-threshold.js b/examples/test-all-keymetrics-features/test-threshold.js index 567ac812c..f5de39af2 100644 --- a/examples/test-all-keymetrics-features/test-threshold.js +++ b/examples/test-all-keymetrics-features/test-threshold.js @@ -1,5 +1,5 @@ -var axm = require('@pm2/io'); +var axm = require('@arcblock/pm2.io'); var users = 55 diff --git a/examples/test-all-keymetrics-features/throw.js b/examples/test-all-keymetrics-features/throw.js index 1c9dfd1f4..b431547d9 100644 --- a/examples/test-all-keymetrics-features/throw.js +++ b/examples/test-all-keymetrics-features/throw.js @@ -1,5 +1,5 @@ -var axm = require('@pm2/io'); +var axm = require('@arcblock/pm2.io'); setTimeout(function() { console.log('log message from echo auto kill'); diff --git a/lib/API/Serve.js b/lib/API/Serve.js index 178b9c36c..79c0e49be 100644 --- a/lib/API/Serve.js +++ b/lib/API/Serve.js @@ -11,7 +11,7 @@ var url = require('url'); var path = require('path'); var debug = require('debug')('pm2:serve'); -var probe = require('@pm2/io'); +var probe = require('@arcblock/pm2.io'); var errorMeter = probe.meter({ name : '404/sec', samples : 1, diff --git a/lib/ProcessUtils.js b/lib/ProcessUtils.js index b57706ed3..626d2218a 100644 --- a/lib/ProcessUtils.js +++ b/lib/ProcessUtils.js @@ -3,7 +3,7 @@ module.exports = { injectModules: function() { if (process.env.pmx !== 'false') { - const pmx = require('@pm2/io') + const pmx = require('@arcblock/pm2.io') let conf = {} const hasSpecificConfig = typeof process.env.io === 'string' || process.env.trace === 'true' diff --git a/lib/templates/sample-apps/pm2-plus-metrics-actions/README.md b/lib/templates/sample-apps/pm2-plus-metrics-actions/README.md index 4dbe4538b..c4985f9fe 100644 --- a/lib/templates/sample-apps/pm2-plus-metrics-actions/README.md +++ b/lib/templates/sample-apps/pm2-plus-metrics-actions/README.md @@ -28,7 +28,7 @@ Or on the PM2+ Web interface ## Example ```javascript -const io = require('@pm2/io') +const io = require('@arcblock/pm2.io') const currentReq = io.counter({ name: 'CM: Current Processing', diff --git a/lib/templates/sample-apps/pm2-plus-metrics-actions/custom-metrics.js b/lib/templates/sample-apps/pm2-plus-metrics-actions/custom-metrics.js index 767a96fdf..796f694ad 100644 --- a/lib/templates/sample-apps/pm2-plus-metrics-actions/custom-metrics.js +++ b/lib/templates/sample-apps/pm2-plus-metrics-actions/custom-metrics.js @@ -1,5 +1,5 @@ -const io = require('@pm2/io') +const io = require('@arcblock/pm2.io') // Straight Metric var user_count = 10 diff --git a/package-lock.json b/package-lock.json index 01c30190a..2293654ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { - "name": "pm2", + "name": "@arcblock/pm2", "version": "5.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "pm2", + "name": "@arcblock/pm2", "version": "5.4.0", "license": "AGPL-3.0", "dependencies": { + "@arcblock/pm2.io": "~6.0.1", "@pm2/agent": "~2.0.0", - "@pm2/io": "~6.0.0", "@pm2/js-api": "~0.8.0", "@pm2/pm2-version-check": "latest", "async": "~3.2.0", @@ -20,12 +20,14 @@ "cli-tableau": "^2.0.0", "commander": "2.15.1", "croner": "~4.1.92", - "dayjs": "~1.11.5", + "dayjs": "~1.11.11", "debug": "^4.3.1", "enquirer": "2.3.6", "eventemitter2": "5.0.1", "fclone": "1.0.11", + "fs-extra": "^11.2.0", "js-yaml": "~4.1.0", + "lodash": "^4.17.21", "mkdirp": "1.0.4", "needle": "2.4.0", "pidusage": "~3.0", @@ -47,7 +49,8 @@ }, "devDependencies": { "mocha": "^10.4.0", - "should": "^13.2.3" + "should": "^13.2.3", + "zx": "^8.1.2" }, "engines": { "node": ">=12.0.0" @@ -56,35 +59,46 @@ "pm2-sysmonit": "^1.2.8" } }, - "node_modules/@pm2/agent": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@pm2/agent/-/agent-2.0.3.tgz", - "integrity": "sha512-xkqqCoTf5VsciMqN0vb9jthW7olVAi4KRFNddCc7ZkeJZ3i8QwZANr4NSH2H5DvseRFHq7MiPspRY/EWAFWWTg==", + "node_modules/@arcblock/pm2.io": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@arcblock/pm2.io/-/pm2.io-6.0.1.tgz", + "integrity": "sha512-O6s05TU5kuCn4ovb2t9eiav0KHDbZ0P/zeQeHkU5TqO5TacgAYyY5Bs1Hr5erh2pnvESG7FWmr7MwmCCcE4lTw==", + "license": "Apache-2", "dependencies": { - "async": "~3.2.0", - "chalk": "~3.0.0", - "dayjs": "~1.8.24", + "async": "~2.6.1", + "dayjs": "^1.11.11", "debug": "~4.3.1", - "eventemitter2": "~5.0.1", - "fast-json-patch": "^3.0.0-1", - "fclone": "~1.0.11", - "nssocket": "0.6.0", - "pm2-axon": "~4.0.1", - "pm2-axon-rpc": "~0.7.0", - "proxy-agent": "~6.3.0", - "semver": "~7.5.0", - "ws": "~7.4.0" + "eventemitter2": "^6.3.1", + "require-in-the-middle": "^5.0.0", + "semver": "~7.5.4", + "shimmer": "^1.2.0", + "signal-exit": "^3.0.3", + "tslib": "1.9.3" + }, + "engines": { + "node": ">=6.0" } }, - "node_modules/@pm2/agent/node_modules/dayjs": { - "version": "1.8.36", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.36.tgz", - "integrity": "sha512-3VmRXEtw7RZKAf+4Tv1Ym9AGeo8r8+CjDi26x+7SYQil1UqtqdaokhzoEJohqlzt0m5kacJSDhJQkG/LWhpRBw==" + "node_modules/@arcblock/pm2.io/node_modules/async": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", + "license": "MIT", + "dependencies": { + "lodash": "^4.17.14" + } }, - "node_modules/@pm2/agent/node_modules/lru-cache": { + "node_modules/@arcblock/pm2.io/node_modules/eventemitter2": { + "version": "6.4.9", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.9.tgz", + "integrity": "sha512-JEPTiaOt9f04oa6NOkc4aH+nVp5I3wEjpHbIPqfgCdD5v5bUzy7xQqwcVO2aDQgOWhI28da57HksMrzK9HlRxg==", + "license": "MIT" + }, + "node_modules/@arcblock/pm2.io/node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -92,10 +106,11 @@ "node": ">=10" } }, - "node_modules/@pm2/agent/node_modules/semver": { + "node_modules/@arcblock/pm2.io/node_modules/semver": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -106,38 +121,32 @@ "node": ">=10" } }, - "node_modules/@pm2/io": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@pm2/io/-/io-6.0.0.tgz", - "integrity": "sha512-sKUEgZoQ5/jRwTyMB1I7u2wXL6dG0j/F/M4ANJ7dJCApfW8nWC0RElMW2siEKvZ79iplIPAaWV27oyBoerEflw==", + "node_modules/@pm2/agent": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@pm2/agent/-/agent-2.0.3.tgz", + "integrity": "sha512-xkqqCoTf5VsciMqN0vb9jthW7olVAi4KRFNddCc7ZkeJZ3i8QwZANr4NSH2H5DvseRFHq7MiPspRY/EWAFWWTg==", "dependencies": { - "async": "~2.6.1", + "async": "~3.2.0", + "chalk": "~3.0.0", + "dayjs": "~1.8.24", "debug": "~4.3.1", - "eventemitter2": "^6.3.1", - "require-in-the-middle": "^5.0.0", - "semver": "~7.5.4", - "shimmer": "^1.2.0", - "signal-exit": "^3.0.3", - "tslib": "1.9.3" - }, - "engines": { - "node": ">=6.0" - } - }, - "node_modules/@pm2/io/node_modules/async": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", - "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", - "dependencies": { - "lodash": "^4.17.14" + "eventemitter2": "~5.0.1", + "fast-json-patch": "^3.0.0-1", + "fclone": "~1.0.11", + "nssocket": "0.6.0", + "pm2-axon": "~4.0.1", + "pm2-axon-rpc": "~0.7.0", + "proxy-agent": "~6.3.0", + "semver": "~7.5.0", + "ws": "~7.4.0" } }, - "node_modules/@pm2/io/node_modules/eventemitter2": { - "version": "6.4.9", - "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.9.tgz", - "integrity": "sha512-JEPTiaOt9f04oa6NOkc4aH+nVp5I3wEjpHbIPqfgCdD5v5bUzy7xQqwcVO2aDQgOWhI28da57HksMrzK9HlRxg==" + "node_modules/@pm2/agent/node_modules/dayjs": { + "version": "1.8.36", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.36.tgz", + "integrity": "sha512-3VmRXEtw7RZKAf+4Tv1Ym9AGeo8r8+CjDi26x+7SYQil1UqtqdaokhzoEJohqlzt0m5kacJSDhJQkG/LWhpRBw==" }, - "node_modules/@pm2/io/node_modules/lru-cache": { + "node_modules/@pm2/agent/node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", @@ -148,7 +157,7 @@ "node": ">=10" } }, - "node_modules/@pm2/io/node_modules/semver": { + "node_modules/@pm2/agent/node_modules/semver": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", @@ -203,6 +212,40 @@ "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==" }, + "node_modules/@types/fs-extra": { + "version": "11.0.4", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.4.tgz", + "integrity": "sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@types/jsonfile": "*", + "@types/node": "*" + } + }, + "node_modules/@types/jsonfile": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/@types/jsonfile/-/jsonfile-6.1.4.tgz", + "integrity": "sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "20.14.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.2.tgz", + "integrity": "sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, "node_modules/agent-base": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", @@ -1875,6 +1918,14 @@ "json-stringify-safe": "^5.0.1" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true, + "license": "MIT", + "optional": true + }, "node_modules/universalify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", @@ -2021,6 +2072,23 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zx": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/zx/-/zx-8.1.2.tgz", + "integrity": "sha512-zkCiXKh8D/eo6r58OmJvO5mc2NthcSRvysb3fuS6VQlHPbEPBcxduRwM3m6ZfHj+7cLHcrahCnuO2TDAbW+6xw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "zx": "build/cli.js" + }, + "engines": { + "node": ">= 12.17.0" + }, + "optionalDependencies": { + "@types/fs-extra": "^11.0.4", + "@types/node": ">=20.12.12" + } } } } diff --git a/package.json b/package.json index 57868f533..62fb6af93 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,10 @@ { - "name": "pm2", + "name": "@arcblock/pm2", "preferGlobal": true, "version": "5.4.0", + "publishConfig": { + "access": "public" + }, "engines": { "node": ">=12.0.0" }, @@ -101,7 +104,8 @@ "scripts": { "test:unit": "bash test/unit.sh", "test:e2e": "bash test/e2e.sh", - "test": "bash test/unit.sh && bash test/e2e.sh" + "test": "bash test/unit.sh && bash test/e2e.sh", + "build": "echo 'build successfully!'" }, "keywords": [ "cli", @@ -169,8 +173,8 @@ }, "dependencies": { "@pm2/agent": "~2.0.0", + "@arcblock/pm2.io": "~6.0.1", "@pm2/js-api": "~0.8.0", - "@pm2/io": "~6.0.0", "@pm2/pm2-version-check": "latest", "async": "~3.2.0", "blessed": "0.1.81", @@ -179,11 +183,14 @@ "cli-tableau": "^2.0.0", "commander": "2.15.1", "croner": "~4.1.92", - "dayjs": "~1.11.5", + "dayjs": "~1.11.11", "debug": "^4.3.1", "enquirer": "2.3.6", "eventemitter2": "5.0.1", "fclone": "1.0.11", + "fs-extra": "^11.2.0", + "js-yaml": "~4.1.0", + "lodash": "^4.17.21", "mkdirp": "1.0.4", "needle": "2.4.0", "pidusage": "~3.0", @@ -195,15 +202,15 @@ "semver": "^7.2", "source-map-support": "0.5.21", "sprintf-js": "1.1.2", - "vizion": "~2.2.1", - "js-yaml": "~4.1.0" + "vizion": "~2.2.1" }, "optionalDependencies": { "pm2-sysmonit": "^1.2.8" }, "devDependencies": { "mocha": "^10.4.0", - "should": "^13.2.3" + "should": "^13.2.3", + "zx": "^8.1.2" }, "bugs": { "url": "https://github.com/Unitech/pm2/issues" @@ -213,4 +220,4 @@ "url": "git://github.com/Unitech/pm2.git" }, "license": "AGPL-3.0" -} +} \ No newline at end of file diff --git a/scripts/bump-version.mjs b/scripts/bump-version.mjs new file mode 100644 index 000000000..d9cebdd0f --- /dev/null +++ b/scripts/bump-version.mjs @@ -0,0 +1,35 @@ +/* eslint-disable no-console */ +import { execSync } from 'child_process'; +import { $, chalk, fs } from 'zx'; + +// or use pnpm to bump version: `pnpm -r --filter {packages/*, themes/*} -- pnpm version` +execSync('bumpp package.json', { stdio: 'inherit' }); + +const { version } = await fs.readJSON('package.json'); +await fs.writeFileSync('version', version); + + +let newChangelog = ''; + +try { + const gitRes = await $`git log --pretty=format:"- %s" "main"...HEAD`; + newChangelog = gitRes.stdout.trim(); +} catch { + console.error(chalk.redBright('Could not get git log, please write changelog manually.')); +} + +const now = new Date(); +const currentDate = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`; +const title = `## ${version} (${currentDate})`; + +await fs.ensureFile('CHANGELOG.md'); +const oldChangelog = await fs.readFile('CHANGELOG.md', 'utf8'); +const changelog = [title, newChangelog, oldChangelog].filter((item) => !!item).join('\n\n'); + +await fs.writeFile('CHANGELOG.md', changelog); + +console.log(`\nNow you can make adjustments to ${chalk.cyan('CHANGELOG.md')} . Then press enter to continue.`); + +process.stdin.setRawMode(true); +process.stdin.resume(); +process.stdin.on('data', process.exit.bind(process, 0)); \ No newline at end of file diff --git a/scripts/libs/work-spaces.js b/scripts/libs/work-spaces.js new file mode 100644 index 000000000..46ca2ce67 --- /dev/null +++ b/scripts/libs/work-spaces.js @@ -0,0 +1,101 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const { join } = require("path"); +const { existsSync, readdirSync } = require("fs-extra"); +const { readJsonSync } = require("fs-extra"); +const { outputFileSync } = require("fs-extra"); +const { isArray } = require("lodash"); + +class WorkSpaces { + /** + * @type {string} + */ + rootDir; + + /** + * @type {string[]} + * @example ['core', 'services', 'packages'] + */ + workSpaces; + + includeWorkspaceRoot; + + #packageJson = "package.json"; + + constructor({ rootDir, workSpaces, includeWorkspaceRoot }) { + this.rootDir = rootDir; + this.workSpaces = workSpaces; + this.includeWorkspaceRoot = includeWorkspaceRoot; + } + + async setVersion(version) { + return this.#setVersion(version); + } + + async #setVersion(version) { + const packageJsonPaths = await this.#getPackageJsonPaths(); + + await Promise.all( + packageJsonPaths.map((packageJsonPath) => + this.#setPackageVersion(packageJsonPath, version) + ) + ); + } + + /** + * + * @param {string} packageJsonPath + * @param {string} version + * @returns {Promise} + */ + async #setPackageVersion(packageJsonPath, version) { + const packageJson = readJsonSync(packageJsonPath); + packageJson.version = version; + outputFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); + } + + /** + * + * @returns {Promise} + */ + async #getPackageJsonPaths() { + const packageJsonPaths = []; + + if ( + this.includeWorkspaceRoot && + existsSync(join(this.rootDir, this.#packageJson)) + ) { + packageJsonPaths.push(join(this.rootDir, this.#packageJson)); + } + + if (!isArray(this.workSpaces)) { + return packageJsonPaths; + } + + for (const workspace of this.workSpaces) { + if (!existsSync(join(this.rootDir, workspace))) { + throw new Error(`workspace(${workspace}) not found`); + } + + const files = readdirSync(workspace, { withFileTypes: true }); + + for (const file of files) { + if ( + file.isDirectory() && + existsSync( + join(this.rootDir, workspace, file.name, this.#packageJson) + ) + ) { + packageJsonPaths.push( + join(this.rootDir, workspace, file.name, this.#packageJson) + ); + } + } + } + + return packageJsonPaths; + } +} + +module.exports = { + WorkSpaces, +}; diff --git a/scripts/update-beta-package-version.js b/scripts/update-beta-package-version.js new file mode 100644 index 000000000..34ecb23eb --- /dev/null +++ b/scripts/update-beta-package-version.js @@ -0,0 +1,20 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const { WorkSpaces } = require("./libs/work-spaces"); +const { cwd } = require("process"); +const utc = require("dayjs/plugin/utc"); +const dayjs = require("dayjs"); +const { join } = require("path"); +const { readJSONSync } = require("fs-extra"); +dayjs.extend(utc); + +const currentVersion = readJSONSync( + join(cwd(), "package.json") +).version.replace(/-.*/, ""); +const time = dayjs().utcOffset(8).format("YYYY-MM-DD-HH-mm-SSS"); + +const newVersion = `${currentVersion}-beta-${time}`; +const workspace = new WorkSpaces({ + rootDir: cwd(), + includeWorkspaceRoot: true, +}); +workspace.setVersion(newVersion); diff --git a/test/fixtures/child_no_http.js b/test/fixtures/child_no_http.js index f38d18c46..58bc631a7 100644 --- a/test/fixtures/child_no_http.js +++ b/test/fixtures/child_no_http.js @@ -1,4 +1,4 @@ -var pmx = require('@pm2/io').init({ +var pmx = require('@arcblock/pm2.io').init({ http: false }); diff --git a/test/fixtures/custom_actions/index.js b/test/fixtures/custom_actions/index.js index b68bdd9e8..081730c4e 100644 --- a/test/fixtures/custom_actions/index.js +++ b/test/fixtures/custom_actions/index.js @@ -1,5 +1,5 @@ -var pmx = require('@pm2/io'); +var pmx = require('@arcblock/pm2.io'); pmx.action('ping', function(reply) { return reply({ 'pong' : 'hehe' }) diff --git a/test/fixtures/events/custom_action.js b/test/fixtures/events/custom_action.js index 693d8b9ac..e9eead564 100755 --- a/test/fixtures/events/custom_action.js +++ b/test/fixtures/events/custom_action.js @@ -1,5 +1,5 @@ -var axm = require('@pm2/io'); +var axm = require('@arcblock/pm2.io'); axm.action('refresh:db', function(reply) { console.log('Refreshing'); diff --git a/test/fixtures/events/custom_action_with_params.js b/test/fixtures/events/custom_action_with_params.js index 023c75e77..c9c96dacf 100755 --- a/test/fixtures/events/custom_action_with_params.js +++ b/test/fixtures/events/custom_action_with_params.js @@ -1,5 +1,5 @@ -var axm = require('@pm2/io'); +var axm = require('@arcblock/pm2.io'); axm.action('refresh:db', { comment : 'Refresh the database' }, function(reply) { console.log('Refreshing'); diff --git a/test/fixtures/events/own_event.js b/test/fixtures/events/own_event.js index a0df61bc3..25bec9d82 100644 --- a/test/fixtures/events/own_event.js +++ b/test/fixtures/events/own_event.js @@ -1,5 +1,5 @@ -var axm = require('@pm2/io'); +var axm = require('@arcblock/pm2.io'); setInterval(function() { axm.emit('user:register', { diff --git a/test/fixtures/homogen-json-action/http.js b/test/fixtures/homogen-json-action/http.js index a5442309d..7ccfc573e 100644 --- a/test/fixtures/homogen-json-action/http.js +++ b/test/fixtures/homogen-json-action/http.js @@ -1,4 +1,4 @@ -var pmx = require('@pm2/io').init({ +var pmx = require('@arcblock/pm2.io').init({ http : true }); diff --git a/test/fixtures/interface/http_transaction.js b/test/fixtures/interface/http_transaction.js index 1a3d9a695..ba43406fd 100644 --- a/test/fixtures/interface/http_transaction.js +++ b/test/fixtures/interface/http_transaction.js @@ -1,5 +1,5 @@ -var axm = require('@pm2/io'); +var axm = require('@arcblock/pm2.io'); axm.init({ http: true diff --git a/test/fixtures/interface/human_event.js b/test/fixtures/interface/human_event.js index e18072567..10f3e8d7f 100644 --- a/test/fixtures/interface/human_event.js +++ b/test/fixtures/interface/human_event.js @@ -1,5 +1,5 @@ -var axm = require('@pm2/io'); +var axm = require('@arcblock/pm2.io'); setInterval(function() { axm.emit('content:page:created', { diff --git a/test/fixtures/interface/process_exception.js b/test/fixtures/interface/process_exception.js index 23575d2bf..3b56a3f88 100644 --- a/test/fixtures/interface/process_exception.js +++ b/test/fixtures/interface/process_exception.js @@ -1,5 +1,5 @@ -var axm = require('@pm2/io'); +var axm = require('@arcblock/pm2.io'); axm.catchAll(); diff --git a/test/fixtures/interface/process_exception_with_logs.js b/test/fixtures/interface/process_exception_with_logs.js index da8e43e77..6f8035183 100644 --- a/test/fixtures/interface/process_exception_with_logs.js +++ b/test/fixtures/interface/process_exception_with_logs.js @@ -1,5 +1,5 @@ -var pmx = require('@pm2/io'); +var pmx = require('@arcblock/pm2.io'); pmx.action('exception', function(reply) { console.log('Im going to crash'); diff --git a/test/fixtures/module-fixture/scoped-action.js b/test/fixtures/module-fixture/scoped-action.js index bf988d6d2..045d9cfad 100644 --- a/test/fixtures/module-fixture/scoped-action.js +++ b/test/fixtures/module-fixture/scoped-action.js @@ -1,5 +1,5 @@ -var pmx = require('@pm2/io'); +var pmx = require('@arcblock/pm2.io'); var conf = pmx.initModule({ diff --git a/test/fixtures/probes.js b/test/fixtures/probes.js index 1cafbfb21..67b68f055 100644 --- a/test/fixtures/probes.js +++ b/test/fixtures/probes.js @@ -1,6 +1,6 @@ -var pmx = require('@pm2/io'); +var pmx = require('@arcblock/pm2.io'); var conf = pmx.init(); var http = require('http'); diff --git a/test/fixtures/start-consistency/child.js b/test/fixtures/start-consistency/child.js index c457878b2..8698ff51b 100644 --- a/test/fixtures/start-consistency/child.js +++ b/test/fixtures/start-consistency/child.js @@ -1,5 +1,5 @@ -require('@pm2/io').init({ +require('@arcblock/pm2.io').init({ http : true });