@zappinginc/zm2 6.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/.claude/settings.local.json +8 -0
  2. package/.gitattributes +4 -0
  3. package/.mocharc.js +14 -0
  4. package/CHANGELOG.md +2416 -0
  5. package/CLAUDE.md +84 -0
  6. package/CONTRIBUTING.md +124 -0
  7. package/GNU-AGPL-3.0.txt +665 -0
  8. package/LICENSE +1 -0
  9. package/README.md +248 -0
  10. package/bin/zm2 +3 -0
  11. package/bin/zm2-dev +3 -0
  12. package/bin/zm2-docker +3 -0
  13. package/bin/zm2-runtime +3 -0
  14. package/bin/zm2-windows +3 -0
  15. package/bin/zm2.ps1 +3 -0
  16. package/bun.lock +421 -0
  17. package/constants.js +114 -0
  18. package/index.js +13 -0
  19. package/lib/API/Configuration.js +212 -0
  20. package/lib/API/Containerizer.js +335 -0
  21. package/lib/API/Dashboard.js +459 -0
  22. package/lib/API/Deploy.js +117 -0
  23. package/lib/API/Extra.js +775 -0
  24. package/lib/API/ExtraMgmt/Docker.js +30 -0
  25. package/lib/API/Log.js +315 -0
  26. package/lib/API/LogManagement.js +371 -0
  27. package/lib/API/Modules/LOCAL.js +122 -0
  28. package/lib/API/Modules/Modularizer.js +148 -0
  29. package/lib/API/Modules/NPM.js +445 -0
  30. package/lib/API/Modules/TAR.js +362 -0
  31. package/lib/API/Modules/flagExt.js +46 -0
  32. package/lib/API/Modules/index.js +120 -0
  33. package/lib/API/Monit.js +247 -0
  34. package/lib/API/Serve.js +343 -0
  35. package/lib/API/Startup.js +629 -0
  36. package/lib/API/UX/helpers.js +213 -0
  37. package/lib/API/UX/index.js +9 -0
  38. package/lib/API/UX/pm2-describe.js +193 -0
  39. package/lib/API/UX/pm2-ls-minimal.js +31 -0
  40. package/lib/API/UX/pm2-ls.js +483 -0
  41. package/lib/API/Version.js +382 -0
  42. package/lib/API/interpreter.json +12 -0
  43. package/lib/API/pm2-plus/PM2IO.js +372 -0
  44. package/lib/API/pm2-plus/auth-strategies/CliAuth.js +288 -0
  45. package/lib/API/pm2-plus/auth-strategies/WebAuth.js +187 -0
  46. package/lib/API/pm2-plus/helpers.js +97 -0
  47. package/lib/API/pm2-plus/link.js +126 -0
  48. package/lib/API/pm2-plus/pres/motd +16 -0
  49. package/lib/API/pm2-plus/pres/motd.update +26 -0
  50. package/lib/API/pm2-plus/pres/welcome +28 -0
  51. package/lib/API/pm2-plus/process-selector.js +52 -0
  52. package/lib/API/schema.json +379 -0
  53. package/lib/API.js +1931 -0
  54. package/lib/Client.js +776 -0
  55. package/lib/Common.js +911 -0
  56. package/lib/Configuration.js +304 -0
  57. package/lib/Daemon.js +456 -0
  58. package/lib/Event.js +37 -0
  59. package/lib/God/ActionMethods.js +909 -0
  60. package/lib/God/ClusterMode.js +97 -0
  61. package/lib/God/ForkMode.js +297 -0
  62. package/lib/God/Methods.js +265 -0
  63. package/lib/God/Reload.js +240 -0
  64. package/lib/God.js +632 -0
  65. package/lib/HttpInterface.js +76 -0
  66. package/lib/ProcessContainer.js +305 -0
  67. package/lib/ProcessContainerBun.js +360 -0
  68. package/lib/ProcessContainerFork.js +42 -0
  69. package/lib/ProcessContainerForkBun.js +33 -0
  70. package/lib/ProcessUtils.js +55 -0
  71. package/lib/TreeKill.js +118 -0
  72. package/lib/Utility.js +430 -0
  73. package/lib/VersionCheck.js +46 -0
  74. package/lib/Watcher.js +117 -0
  75. package/lib/Worker.js +169 -0
  76. package/lib/binaries/CLI.js +1041 -0
  77. package/lib/binaries/DevCLI.js +183 -0
  78. package/lib/binaries/Runtime.js +101 -0
  79. package/lib/binaries/Runtime4Docker.js +192 -0
  80. package/lib/completion.js +229 -0
  81. package/lib/completion.sh +40 -0
  82. package/lib/motd +36 -0
  83. package/lib/templates/Dockerfiles/Dockerfile-java.tpl +7 -0
  84. package/lib/templates/Dockerfiles/Dockerfile-nodejs.tpl +8 -0
  85. package/lib/templates/Dockerfiles/Dockerfile-ruby.tpl +7 -0
  86. package/lib/templates/ecosystem-es.tpl +24 -0
  87. package/lib/templates/ecosystem-simple-es.tpl +8 -0
  88. package/lib/templates/ecosystem-simple.tpl +6 -0
  89. package/lib/templates/ecosystem.tpl +22 -0
  90. package/lib/templates/init-scripts/launchd.tpl +35 -0
  91. package/lib/templates/init-scripts/openrc.tpl +52 -0
  92. package/lib/templates/init-scripts/pm2-init-amazon.sh +86 -0
  93. package/lib/templates/init-scripts/rcd-openbsd.tpl +41 -0
  94. package/lib/templates/init-scripts/rcd.tpl +44 -0
  95. package/lib/templates/init-scripts/smf.tpl +43 -0
  96. package/lib/templates/init-scripts/systemd-online.tpl +22 -0
  97. package/lib/templates/init-scripts/systemd.tpl +22 -0
  98. package/lib/templates/init-scripts/upstart.tpl +103 -0
  99. package/lib/templates/logrotate.d/pm2 +10 -0
  100. package/lib/templates/sample-apps/http-server/README.md +14 -0
  101. package/lib/templates/sample-apps/http-server/api.js +9 -0
  102. package/lib/templates/sample-apps/http-server/ecosystem.config.js +14 -0
  103. package/lib/templates/sample-apps/http-server/package.json +11 -0
  104. package/lib/templates/sample-apps/pm2-plus-metrics-actions/README.md +45 -0
  105. package/lib/templates/sample-apps/pm2-plus-metrics-actions/custom-metrics.js +66 -0
  106. package/lib/templates/sample-apps/pm2-plus-metrics-actions/ecosystem.config.js +12 -0
  107. package/lib/templates/sample-apps/pm2-plus-metrics-actions/package.json +11 -0
  108. package/lib/templates/sample-apps/python-app/README.md +4 -0
  109. package/lib/templates/sample-apps/python-app/echo.py +7 -0
  110. package/lib/templates/sample-apps/python-app/ecosystem.config.js +12 -0
  111. package/lib/templates/sample-apps/python-app/package.json +11 -0
  112. package/lib/tools/Config.js +248 -0
  113. package/lib/tools/IsAbsolute.js +20 -0
  114. package/lib/tools/copydirSync.js +101 -0
  115. package/lib/tools/deleteFolderRecursive.js +19 -0
  116. package/lib/tools/find-package-json.js +74 -0
  117. package/lib/tools/fmt.js +72 -0
  118. package/lib/tools/isbinaryfile.js +94 -0
  119. package/lib/tools/json5.js +752 -0
  120. package/lib/tools/open.js +63 -0
  121. package/lib/tools/passwd.js +58 -0
  122. package/lib/tools/promise.min.js +1 -0
  123. package/lib/tools/sexec.js +55 -0
  124. package/lib/tools/treeify.js +113 -0
  125. package/lib/tools/which.js +120 -0
  126. package/lib/tools/xdg-open +861 -0
  127. package/package.json +219 -0
  128. package/paths.js +93 -0
  129. package/pm2 +11 -0
  130. package/preinstall.js +24 -0
  131. package/run.sh +9 -0
  132. package/types/index.d.ts +722 -0
  133. package/types/tsconfig.json +14 -0
@@ -0,0 +1,72 @@
1
+ // --------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // fmt.js - Command line output formatting.
4
+ //
5
+ // Copyright (c) 2012 Andrew Chilton - http://chilts.org/
6
+ // Written by Andrew Chilton <andychilton@gmail.com>
7
+ //
8
+ // License: http://opensource.org/licenses/MIT
9
+ //
10
+ // --------------------------------------------------------------------------------------------------------------------
11
+
12
+ var util = require('util');
13
+
14
+ // --------------------------------------------------------------------------------------------------------------------
15
+
16
+ var sep = '===============================================================================';
17
+ var line = '-------------------------------------------------------------------------------';
18
+ var field = ' ';
19
+
20
+ // --------------------------------------------------------------------------------------------------------------------
21
+
22
+ // separator
23
+ module.exports.separator = function() {
24
+ console.log(sep);
25
+ };
26
+
27
+ // alias the above
28
+ module.exports.sep = module.exports.separator;
29
+
30
+ // line
31
+ module.exports.line = function() {
32
+ console.log(line);
33
+ };
34
+
35
+ // title
36
+ module.exports.title = function(title) {
37
+ var out = '--- ' + title + ' ';
38
+ out += line.substr(out.length);
39
+ console.log(out);
40
+ };
41
+
42
+ // field
43
+ module.exports.field = function(key, value) {
44
+ console.log('' + key + field.substr(key.length) + ' : ' + value);
45
+ };
46
+
47
+ // subfield
48
+ module.exports.subfield = function(key, value) {
49
+ console.log('- ' + key + field.substr(key.length + 2) + ' : ' + value);
50
+ };
51
+
52
+ // list item
53
+ module.exports.li = function(msg) {
54
+ console.log('* ' + msg);
55
+ };
56
+
57
+ // dump
58
+ module.exports.dump = function(data, name) {
59
+ if ( name ) {
60
+ console.log(name + ' :', util.inspect(data, false, null, true));
61
+ }
62
+ else {
63
+ console.log(util.inspect(data, false, null, true));
64
+ }
65
+ };
66
+
67
+ // msg
68
+ module.exports.msg = function(msg) {
69
+ console.log(msg);
70
+ };
71
+
72
+ // --------------------------------------------------------------------------------------------------------------------
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Copyright 2013-2022 the PM2 project authors. All rights reserved.
3
+ * Use of this source code is governed by a license that
4
+ * can be found in the LICENSE file.
5
+ */
6
+ var fs = require('fs');
7
+ var max_bytes = 512;
8
+
9
+ module.exports = function(bytes, size) {
10
+ // Read the file with no encoding for raw buffer access.
11
+ if (size === undefined) {
12
+ var file = bytes;
13
+ try {
14
+ if(!fs.statSync(file).isFile()) return false;
15
+ } catch (err) {
16
+ // otherwise continue on
17
+ }
18
+ var descriptor = fs.openSync(file, 'r');
19
+ try {
20
+ bytes = Buffer.alloc(max_bytes);
21
+ size = fs.readSync(descriptor, bytes, 0, bytes.length, 0);
22
+ } finally {
23
+ fs.closeSync(descriptor);
24
+ }
25
+ }
26
+ // async version has a function instead of a `size`
27
+ else if (typeof size === "function") {
28
+ var file = bytes, callback = size;
29
+ fs.stat(file, function(err, stat) {
30
+ if (err || !stat.isFile()) return callback(null, false);
31
+
32
+ fs.open(file, 'r', function(err, descriptor){
33
+ if (err) return callback(err);
34
+ var bytes = Buffer.alloc(max_bytes);
35
+ // Read the file with no encoding for raw buffer access.
36
+ fs.read(descriptor, bytes, 0, bytes.length, 0, function(err, size, bytes){
37
+ fs.close(descriptor, function(err2){
38
+ if (err || err2)
39
+ return callback(err || err2);
40
+ return callback(null, isBinaryCheck(bytes, size));
41
+ });
42
+ });
43
+ });
44
+ });
45
+ }
46
+
47
+ return isBinaryCheck(bytes, size);
48
+ }
49
+
50
+ function isBinaryCheck(bytes, size) {
51
+ if (size === 0)
52
+ return false;
53
+
54
+ var suspicious_bytes = 0;
55
+ var total_bytes = Math.min(size, max_bytes);
56
+
57
+ if (size >= 3 && bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) {
58
+ // UTF-8 BOM. This isn't binary.
59
+ return false;
60
+ }
61
+
62
+ for (var i = 0; i < total_bytes; i++) {
63
+ if (bytes[i] === 0) { // NULL byte--it's binary!
64
+ return true;
65
+ }
66
+ else if ((bytes[i] < 7 || bytes[i] > 14) && (bytes[i] < 32 || bytes[i] > 127)) {
67
+ // UTF-8 detection
68
+ if (bytes[i] > 193 && bytes[i] < 224 && i + 1 < total_bytes) {
69
+ i++;
70
+ if (bytes[i] > 127 && bytes[i] < 192) {
71
+ continue;
72
+ }
73
+ }
74
+ else if (bytes[i] > 223 && bytes[i] < 240 && i + 2 < total_bytes) {
75
+ i++;
76
+ if (bytes[i] > 127 && bytes[i] < 192 && bytes[i + 1] > 127 && bytes[i + 1] < 192) {
77
+ i++;
78
+ continue;
79
+ }
80
+ }
81
+ suspicious_bytes++;
82
+ // Read at least 32 bytes before making a decision
83
+ if (i > 32 && (suspicious_bytes * 100) / total_bytes > 10) {
84
+ return true;
85
+ }
86
+ }
87
+ }
88
+
89
+ if ((suspicious_bytes * 100) / total_bytes > 10) {
90
+ return true;
91
+ }
92
+
93
+ return false;
94
+ }