Skip to content

Commit 04fad96

Browse files
committed
v7 refactor
1 parent 5b2b295 commit 04fad96

File tree

266 files changed

+22191
-582
lines changed

Some content is hidden

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

266 files changed

+22191
-582
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11

2+
## 7.0.0
3+
4+
- Require Node.js >= 20.0.0
5+
- Internalize pm2-axon, pm2-axon-rpc, pm2-io-bpm, pm2-io-agent, fclone as local modules
6+
- Internalize pm2-multimeter and charm into lib/tools/multimeter (zero external deps)
7+
- Replace `needle` with native `fetch` (CliAuth, TAR publish)
8+
- Replace `enquirer` with lightweight built-in prompt (boilerplate selector)
9+
- Replace `promptly` with built-in lib/tools/prompt
10+
- Replace `mkdirp` with native `fs.mkdirSync({ recursive: true })`
11+
- Replace `source-map-support` with native `process.setSourceMapsEnabled()`
12+
- Replace `sprintf-js` with template literals (Dashboard)
13+
- Replace `url.parse()` with native `URL` constructor (Serve, Utility, CliAuth)
14+
- Remove `fclone` npm dep, use internalized module
15+
- Add OpenTelemetry tracing as direct dependencies
16+
- Add test scripts for internalized modules (bpm, axon, axon-rpc, io-agent)
17+
- Expand Docker parallel test runner to cover all internalized module tests
18+
- Drop auto source map file detection in Common.prepareAppConf
19+
220
## 6.0.14
321

422
- Fixed version of @pm2/pm2-version-check #6055

constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2013-2022 the PM2 project authors. All rights reserved.
2+
* Copyright 2013-present the PM2 project authors. All rights reserved.
33
* Use of this source code is governed by a license that
44
* can be found in the LICENSE file.
55
*/

examples/misc-examples/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
var Wrap = require('./wrap.js');
4-
var axon = require('pm2-axon');
4+
var axon = require('../../modules/pm2-axon');
55

66
var Module = require('module');
77
Wrap.wrap(Module, '_load', function(load) {

examples/sourcemap-auto-resolve/API.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2013-2022 the PM2 project authors. All rights reserved.
2+
* Copyright 2013-present the PM2 project authors. All rights reserved.
33
* Use of this source code is governed by a license that
44
* can be found in the LICENSE file.
55
*/

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2013-2022 the PM2 project authors. All rights reserved.
2+
* Copyright 2013-present the PM2 project authors. All rights reserved.
33
* Use of this source code is governed by a license that
44
* can be found in the LICENSE file.
55
*/

lib/API.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2013-2022 the PM2 project authors. All rights reserved.
2+
* Copyright 2013-present the PM2 project authors. All rights reserved.
33
* Use of this source code is governed by a license that
44
* can be found in the LICENSE file.
55
*/
@@ -13,13 +13,13 @@ const series = require('async/series');
1313
const debug = require('debug')('pm2:cli');
1414
const util = require('util');
1515
const chalk = require('ansis');
16-
const fclone = require('fclone');
16+
const fclone = require('../modules/fclone');
1717

1818
var DockerMgmt = require('./API/ExtraMgmt/Docker.js')
1919
var conf = require('../constants.js');
2020
var Client = require('./Client');
2121
var Common = require('./Common');
22-
var KMDaemon = require('@pm2/agent/src/InteractorClient');
22+
var KMDaemon = require('../modules/pm2-io-agent/src/InteractorClient');
2323
var Config = require('./tools/Config');
2424
var Modularizer = require('./API/Modules/Modularizer.js');
2525
var path_structure = require('../paths.js');

lib/API/Containerizer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ module.exports = function(CLI) {
191191
};
192192

193193
CLI.prototype.dockerMode = function(script, opts, mode) {
194-
var promptly = require('promptly');
194+
var promptly = require('../../tools/prompt');
195195
var self = this;
196196
handleExit(self, opts, mode);
197197

lib/API/Dashboard.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2013-2022 the PM2 project authors. All rights reserved.
2+
* Copyright 2013-present the PM2 project authors. All rights reserved.
33
* Use of this source code is governed by a license that
44
* can be found in the LICENSE file.
55
*/
@@ -8,7 +8,6 @@ var os = require('os');
88
var p = require('path');
99
var blessed = require('@pm2/blessed');
1010
var debug = require('debug')('pm2:monit');
11-
var printf = require('sprintf-js').sprintf;
1211

1312
// Total memory
1413
const totalMem = os.totalmem();
@@ -273,17 +272,16 @@ Dashboard.refresh = function(processes) {
273272
status = status + '{bold}' + processes[i].pm2_env.status + '{/}';
274273

275274
var name = processes[i].pm2_env.name || p.basename(processes[i].pm2_env.pm_exec_path);
275+
var maxNameLen = 15;
276+
if (name.length > maxNameLen) name = name.substring(0, maxNameLen - 1) + '…';
277+
name = name.padEnd(maxNameLen);
276278

277279
// Line of list
278-
var item = printf('[%2s] %s {|} Mem: {bold}{%s-fg}%3d{/} MB CPU: {bold}{%s-fg}%2d{/} %s %s',
279-
processes[i].pm2_env.pm_id,
280-
name,
281-
gradient(memPercent, [255, 0, 0], [0, 255, 0]),
282-
(processes[i].monit.memory / 1048576).toFixed(2),
283-
gradient(processes[i].monit.cpu, [255, 0, 0], [0, 255, 0]),
284-
processes[i].monit.cpu,
285-
"%",
286-
status);
280+
var memMB = (processes[i].monit.memory / 1048576).toFixed(0);
281+
var cpu = processes[i].monit.cpu;
282+
var memColor = gradient(memPercent, [255, 0, 0], [0, 255, 0]);
283+
var cpuColor = gradient(cpu, [255, 0, 0], [0, 255, 0]);
284+
var item = `[${String(processes[i].pm2_env.pm_id).padStart(2)}] ${name} Mem: {bold}{${memColor}-fg}${String(memMB).padStart(3)}{/} MB CPU: {bold}{${cpuColor}-fg}${String(cpu).padStart(2)}{/} % ${status}`;
287285

288286
// Check if item exist
289287
if (this.list.getItem(i)) {

lib/API/Deploy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2013-2022 the PM2 project authors. All rights reserved.
2+
* Copyright 2013-present the PM2 project authors. All rights reserved.
33
* Use of this source code is governed by a license that
44
* can be found in the LICENSE file.
55
*/

lib/API/Extra.js

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ module.exports = function(CLI) {
275275
CLI.prototype.boilerplate = function(cb) {
276276
var i = 0
277277
var projects = []
278-
var enquirer = require('enquirer')
278+
var promptly = require('../tools/prompt')
279279
const forEach = require('async/forEach')
280280

281281
fs.readdir(path.join(__dirname, '../templates/sample-apps'), (err, items) => {
@@ -289,32 +289,21 @@ module.exports = function(CLI) {
289289
next()
290290
})
291291
}, () => {
292-
const prompt = new enquirer.Select({
293-
name: 'boilerplate',
294-
message: 'Select a boilerplate',
295-
choices: projects.map((p, i) => {
296-
return {
297-
message: `${chalk.bold.blue(p.name)} ${p.description}`,
298-
value: `${i}`
299-
}
300-
})
301-
});
302-
303-
prompt.run()
304-
.then(answer => {
305-
var p = projects[parseInt(answer)]
306-
basicMDHighlight(fs.readFileSync(path.join(p.fullpath, 'README.md')).toString())
307-
console.log(chalk.bold(`>> Project copied inside folder ./${p.folder_name}/\n`))
308-
copyDirSync(p.fullpath, path.join(process.cwd(), p.folder_name));
309-
this.start(path.join(p.fullpath, 'ecosystem.config.js'), {
310-
cwd: p.fullpath
311-
}, () => {
312-
return cb ? cb.apply(null, arguments) : this.speedList(cst.SUCCESS_EXIT);
313-
})
314-
})
315-
.catch(e => {
292+
var choices = projects.map((p) => `${p.name} - ${p.description}`)
293+
294+
promptly.choose('Select a boilerplate:', choices, (err, answer) => {
295+
if (err) return cb ? cb(err) : this.speedList(cst.ERROR_EXIT);
296+
var idx = choices.indexOf(answer)
297+
var p = projects[idx]
298+
basicMDHighlight(fs.readFileSync(path.join(p.fullpath, 'README.md')).toString())
299+
console.log(chalk.bold(`>> Project copied inside folder ./${p.folder_name}/\n`))
300+
copyDirSync(p.fullpath, path.join(process.cwd(), p.folder_name));
301+
this.start(path.join(p.fullpath, 'ecosystem.config.js'), {
302+
cwd: p.fullpath
303+
}, () => {
316304
return cb ? cb.apply(null, arguments) : this.speedList(cst.SUCCESS_EXIT);
317-
});
305+
})
306+
})
318307

319308
})
320309
})

0 commit comments

Comments
 (0)