@herodevs/cli 0.2.4 → 0.2.5

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 (218) hide show
  1. package/README.md +11 -0
  2. package/core-types/README.md +11 -0
  3. package/core-types/package.json +11 -0
  4. package/core-types/src/index.d.ts +1 -0
  5. package/core-types/src/index.js +5 -0
  6. package/core-types/src/index.js.map +1 -0
  7. package/core-types/src/lib/project-type.d.ts +1 -0
  8. package/core-types/src/lib/project-type.js +3 -0
  9. package/core-types/src/lib/project-type.js.map +1 -0
  10. package/init/README.md +11 -0
  11. package/init/package.json +11 -0
  12. package/init/src/index.d.ts +1 -0
  13. package/init/src/index.js +5 -0
  14. package/init/src/index.js.map +1 -0
  15. package/init/src/lib/configure-project.d.ts +3 -0
  16. package/init/src/lib/configure-project.js +11 -0
  17. package/init/src/lib/configure-project.js.map +1 -0
  18. package/init/src/lib/get-package-choices.d.ts +2 -0
  19. package/init/src/lib/get-package-choices.js +17 -0
  20. package/init/src/lib/get-package-choices.js.map +1 -0
  21. package/init/src/lib/get-product-choices.d.ts +3 -0
  22. package/init/src/lib/get-product-choices.js +19 -0
  23. package/init/src/lib/get-product-choices.js.map +1 -0
  24. package/init/src/lib/get-release-trains.d.ts +3 -0
  25. package/init/src/lib/get-release-trains.js +63 -0
  26. package/init/src/lib/get-release-trains.js.map +1 -0
  27. package/init/src/lib/init.d.ts +5 -0
  28. package/init/src/lib/init.js +56 -0
  29. package/init/src/lib/init.js.map +1 -0
  30. package/init/src/lib/mock-trains.d.ts +2 -0
  31. package/init/src/lib/mock-trains.js +190 -0
  32. package/init/src/lib/mock-trains.js.map +1 -0
  33. package/init/src/lib/models/choice.d.ts +4 -0
  34. package/init/src/lib/models/choice.js +3 -0
  35. package/init/src/lib/models/choice.js.map +1 -0
  36. package/init/src/lib/models/entry.d.ts +6 -0
  37. package/init/src/lib/models/entry.js +3 -0
  38. package/init/src/lib/models/entry.js.map +1 -0
  39. package/init/src/lib/models/index.d.ts +5 -0
  40. package/init/src/lib/models/index.js +9 -0
  41. package/init/src/lib/models/index.js.map +1 -0
  42. package/init/src/lib/models/package-version.d.ts +14 -0
  43. package/init/src/lib/models/package-version.js +3 -0
  44. package/init/src/lib/models/package-version.js.map +1 -0
  45. package/init/src/lib/models/product.d.ts +5 -0
  46. package/init/src/lib/models/product.js +3 -0
  47. package/init/src/lib/models/product.js.map +1 -0
  48. package/init/src/lib/models/release-train.d.ts +9 -0
  49. package/init/src/lib/models/release-train.js +3 -0
  50. package/init/src/lib/models/release-train.js.map +1 -0
  51. package/init/src/lib/npm/configure-npm-project.d.ts +2 -0
  52. package/init/src/lib/npm/configure-npm-project.js +60 -0
  53. package/init/src/lib/npm/configure-npm-project.js.map +1 -0
  54. package/init/src/lib/verify-project-type.d.ts +6 -0
  55. package/init/src/lib/verify-project-type.js +20 -0
  56. package/init/src/lib/verify-project-type.js.map +1 -0
  57. package/package.json +12 -11
  58. package/report-committers/README.md +11 -0
  59. package/report-committers/package.json +11 -0
  60. package/report-committers/src/index.d.ts +1 -0
  61. package/report-committers/src/index.js +5 -0
  62. package/report-committers/src/index.js.map +1 -0
  63. package/report-committers/src/lib/collapse-and-sort-committer-info.d.ts +2 -0
  64. package/report-committers/src/lib/collapse-and-sort-committer-info.js +31 -0
  65. package/report-committers/src/lib/collapse-and-sort-committer-info.js.map +1 -0
  66. package/report-committers/src/lib/committers.d.ts +9 -0
  67. package/report-committers/src/lib/committers.js +102 -0
  68. package/report-committers/src/lib/committers.js.map +1 -0
  69. package/report-committers/src/lib/constants.d.ts +4 -0
  70. package/report-committers/src/lib/constants.js +8 -0
  71. package/report-committers/src/lib/constants.js.map +1 -0
  72. package/report-committers/src/lib/get-committer-counts.d.ts +2 -0
  73. package/report-committers/src/lib/get-committer-counts.js +18 -0
  74. package/report-committers/src/lib/get-committer-counts.js.map +1 -0
  75. package/report-committers/src/lib/parse-date-flags.d.ts +4 -0
  76. package/report-committers/src/lib/parse-date-flags.js +12 -0
  77. package/report-committers/src/lib/parse-date-flags.js.map +1 -0
  78. package/report-committers/src/lib/parse-git-log-entries.d.ts +2 -0
  79. package/report-committers/src/lib/parse-git-log-entries.js +12 -0
  80. package/report-committers/src/lib/parse-git-log-entries.js.map +1 -0
  81. package/report-committers/src/lib/parse-monthly.d.ts +6 -0
  82. package/report-committers/src/lib/parse-monthly.js +41 -0
  83. package/report-committers/src/lib/parse-monthly.js.map +1 -0
  84. package/report-committers/src/lib/print-committers.d.ts +0 -0
  85. package/report-committers/src/lib/print-committers.js +2 -0
  86. package/report-committers/src/lib/print-committers.js.map +1 -0
  87. package/report-committers/src/lib/print-monthly.d.ts +2 -0
  88. package/report-committers/src/lib/print-monthly.js +79 -0
  89. package/report-committers/src/lib/print-monthly.js.map +1 -0
  90. package/report-committers/src/lib/types.d.ts +26 -0
  91. package/report-committers/src/lib/types.js +3 -0
  92. package/report-committers/src/lib/types.js.map +1 -0
  93. package/report-diagnostics/README.md +11 -0
  94. package/report-diagnostics/package.json +11 -0
  95. package/report-diagnostics/src/index.d.ts +1 -0
  96. package/report-diagnostics/src/index.js +5 -0
  97. package/report-diagnostics/src/index.js.map +1 -0
  98. package/report-diagnostics/src/lib/diagnostics.d.ts +7 -0
  99. package/report-diagnostics/src/lib/diagnostics.js +94 -0
  100. package/report-diagnostics/src/lib/diagnostics.js.map +1 -0
  101. package/report-diagnostics/src/lib/get-diagnostic-types.d.ts +4 -0
  102. package/report-diagnostics/src/lib/get-diagnostic-types.js +16 -0
  103. package/report-diagnostics/src/lib/get-diagnostic-types.js.map +1 -0
  104. package/report-diagnostics/src/lib/get-file-contents.d.ts +1 -0
  105. package/report-diagnostics/src/lib/get-file-contents.js +13 -0
  106. package/report-diagnostics/src/lib/get-file-contents.js.map +1 -0
  107. package/report-diagnostics/src/lib/get-package-json-section.d.ts +1 -0
  108. package/report-diagnostics/src/lib/get-package-json-section.js +16 -0
  109. package/report-diagnostics/src/lib/get-package-json-section.js.map +1 -0
  110. package/src/lib/cli.d.ts +1 -0
  111. package/src/lib/cli.js +22 -0
  112. package/src/lib/cli.js.map +1 -0
  113. package/src/lib/create-group-command.d.ts +2 -0
  114. package/src/lib/create-group-command.js +29 -0
  115. package/src/lib/create-group-command.js.map +1 -0
  116. package/src/lib/ensure-version.d.ts +2 -0
  117. package/src/lib/ensure-version.js +52 -0
  118. package/src/lib/ensure-version.js.map +1 -0
  119. package/src/lib/get-commands.d.ts +2 -0
  120. package/src/lib/get-commands.js +18 -0
  121. package/src/lib/get-commands.js.map +1 -0
  122. package/src/lib/log-colors.d.ts +28 -0
  123. package/src/lib/log-colors.js +10 -0
  124. package/src/lib/log-colors.js.map +1 -0
  125. package/src/main.d.ts +1 -0
  126. package/src/main.js +5 -0
  127. package/src/main.js.map +1 -0
  128. package/tracker-init/README.md +11 -0
  129. package/tracker-init/package.json +11 -0
  130. package/tracker-init/src/index.d.ts +1 -0
  131. package/tracker-init/src/index.js +5 -0
  132. package/tracker-init/src/index.js.map +1 -0
  133. package/tracker-init/src/lib/default-config.d.ts +2 -0
  134. package/tracker-init/src/lib/default-config.js +20 -0
  135. package/tracker-init/src/lib/default-config.js.map +1 -0
  136. package/tracker-init/src/lib/init.d.ts +5 -0
  137. package/tracker-init/src/lib/init.js +25 -0
  138. package/tracker-init/src/lib/init.js.map +1 -0
  139. package/tracker-run/README.md +11 -0
  140. package/tracker-run/package.json +11 -0
  141. package/tracker-run/src/index.d.ts +1 -0
  142. package/tracker-run/src/index.js +5 -0
  143. package/tracker-run/src/index.js.map +1 -0
  144. package/tracker-run/src/lib/get-data-filepath.d.ts +1 -0
  145. package/tracker-run/src/lib/get-data-filepath.js +9 -0
  146. package/tracker-run/src/lib/get-data-filepath.js.map +1 -0
  147. package/tracker-run/src/lib/get-data.d.ts +1 -0
  148. package/tracker-run/src/lib/get-data.js +15 -0
  149. package/tracker-run/src/lib/get-data.js.map +1 -0
  150. package/tracker-run/src/lib/get-git-commit.d.ts +4 -0
  151. package/tracker-run/src/lib/get-git-commit.js +33 -0
  152. package/tracker-run/src/lib/get-git-commit.js.map +1 -0
  153. package/tracker-run/src/lib/process-category.d.ts +2 -0
  154. package/tracker-run/src/lib/process-category.js +152 -0
  155. package/tracker-run/src/lib/process-category.js.map +1 -0
  156. package/tracker-run/src/lib/process-config.d.ts +2 -0
  157. package/tracker-run/src/lib/process-config.js +20 -0
  158. package/tracker-run/src/lib/process-config.js.map +1 -0
  159. package/tracker-run/src/lib/run.d.ts +7 -0
  160. package/tracker-run/src/lib/run.js +29 -0
  161. package/tracker-run/src/lib/run.js.map +1 -0
  162. package/tracker-run/src/lib/save-results.d.ts +2 -0
  163. package/tracker-run/src/lib/save-results.js +20 -0
  164. package/tracker-run/src/lib/save-results.js.map +1 -0
  165. package/tracker-shared/README.md +11 -0
  166. package/tracker-shared/package.json +11 -0
  167. package/tracker-shared/src/index.d.ts +2 -0
  168. package/tracker-shared/src/index.js +14 -0
  169. package/tracker-shared/src/index.js.map +1 -0
  170. package/tracker-shared/src/lib/models/aggregate-result.d.ts +4 -0
  171. package/tracker-shared/src/lib/models/aggregate-result.js +3 -0
  172. package/tracker-shared/src/lib/models/aggregate-result.js.map +1 -0
  173. package/tracker-shared/src/lib/models/category-result.d.ts +7 -0
  174. package/tracker-shared/src/lib/models/category-result.js +3 -0
  175. package/tracker-shared/src/lib/models/category-result.js.map +1 -0
  176. package/tracker-shared/src/lib/models/category.d.ts +9 -0
  177. package/tracker-shared/src/lib/models/category.js +3 -0
  178. package/tracker-shared/src/lib/models/category.js.map +1 -0
  179. package/tracker-shared/src/lib/models/config.d.ts +8 -0
  180. package/tracker-shared/src/lib/models/config.js +3 -0
  181. package/tracker-shared/src/lib/models/config.js.map +1 -0
  182. package/tracker-shared/src/lib/models/file-result.d.ts +5 -0
  183. package/tracker-shared/src/lib/models/file-result.js +3 -0
  184. package/tracker-shared/src/lib/models/file-result.js.map +1 -0
  185. package/tracker-shared/src/lib/models/index.d.ts +8 -0
  186. package/tracker-shared/src/lib/models/index.js +12 -0
  187. package/tracker-shared/src/lib/models/index.js.map +1 -0
  188. package/tracker-shared/src/lib/models/process-result.d.ts +6 -0
  189. package/tracker-shared/src/lib/models/process-result.js +3 -0
  190. package/tracker-shared/src/lib/models/process-result.js.map +1 -0
  191. package/tracker-shared/src/lib/models/result.d.ts +11 -0
  192. package/tracker-shared/src/lib/models/result.js +3 -0
  193. package/tracker-shared/src/lib/models/result.js.map +1 -0
  194. package/tracker-shared/src/lib/models/total-result.d.ts +4 -0
  195. package/tracker-shared/src/lib/models/total-result.js +3 -0
  196. package/tracker-shared/src/lib/models/total-result.js.map +1 -0
  197. package/tracker-shared/src/lib/read-config.d.ts +2 -0
  198. package/tracker-shared/src/lib/read-config.js +14 -0
  199. package/tracker-shared/src/lib/read-config.js.map +1 -0
  200. package/utility/README.md +11 -0
  201. package/utility/package.json +11 -0
  202. package/utility/src/index.d.ts +4 -0
  203. package/utility/src/index.js +8 -0
  204. package/utility/src/index.js.map +1 -0
  205. package/utility/src/lib/get-project-types.d.ts +2 -0
  206. package/utility/src/lib/get-project-types.js +14 -0
  207. package/utility/src/lib/get-project-types.js.map +1 -0
  208. package/utility/src/lib/get-root-dir.d.ts +1 -0
  209. package/utility/src/lib/get-root-dir.js +13 -0
  210. package/utility/src/lib/get-root-dir.js.map +1 -0
  211. package/utility/src/lib/run-command.d.ts +1 -0
  212. package/utility/src/lib/run-command.js +32 -0
  213. package/utility/src/lib/run-command.js.map +1 -0
  214. package/utility/src/lib/sort-by-name.d.ts +3 -0
  215. package/utility/src/lib/sort-by-name.js +8 -0
  216. package/utility/src/lib/sort-by-name.js.map +1 -0
  217. package/cli.cjs +0 -997
  218. package/hd-cli.js +0 -1
package/cli.cjs DELETED
@@ -1,997 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
- var __export = (target, all) => {
12
- for (var name in all)
13
- __defProp(target, name, { get: all[name], enumerable: true });
14
- };
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
31
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
-
33
- // apps/cli/package.json
34
- var require_package = __commonJS({
35
- "apps/cli/package.json"(exports2, module2) {
36
- module2.exports = {
37
- name: "@herodevs/cli",
38
- version: "0.0.0",
39
- bin: "./hd-cli.js",
40
- dependencies: {
41
- tslib: "^2.3.0"
42
- },
43
- type: "commonjs",
44
- main: "./hd-cli.js"
45
- };
46
- }
47
- });
48
-
49
- // apps/cli/src/lib/cli.ts
50
- var cli_exports = {};
51
- __export(cli_exports, {
52
- cli: () => cli
53
- });
54
- module.exports = __toCommonJS(cli_exports);
55
- var yargs = __toESM(require("yargs"));
56
- var import_helpers = require("yargs/helpers");
57
-
58
- // libs/report/committers/src/lib/committers.ts
59
- var import_date_fns2 = require("date-fns");
60
-
61
- // libs/utility/src/lib/get-root-dir.ts
62
- var import_fs = require("fs");
63
- var import_path = require("path");
64
- function getRootDir(directory) {
65
- if ((0, import_fs.existsSync)((0, import_path.join)(directory, "package.json"))) {
66
- return directory;
67
- }
68
- return getRootDir((0, import_path.resolve)((0, import_path.join)(directory, "..")));
69
- }
70
-
71
- // libs/utility/src/lib/run-command.ts
72
- var import_child_process = require("child_process");
73
- async function runCommand(cmd) {
74
- return new Promise((resolve4, reject) => {
75
- const options = {
76
- timeout: 1e4
77
- };
78
- (0, import_child_process.exec)(cmd, options, (err, stdout, stderr) => {
79
- if (err) {
80
- const rejection = {
81
- err,
82
- stdout,
83
- stderr
84
- };
85
- reject(rejection);
86
- return;
87
- }
88
- let result = stdout;
89
- if (typeof stdout === "string") {
90
- result = (stdout || "").trim();
91
- }
92
- resolve4(result);
93
- });
94
- });
95
- }
96
-
97
- // libs/utility/src/lib/get-project-types.ts
98
- var import_fs2 = require("fs");
99
- var path = require("path");
100
- function getProjectTypes() {
101
- const types = [];
102
- if ((0, import_fs2.existsSync)(path.join(process.cwd(), "package.json"))) {
103
- types.push("npm");
104
- }
105
- return types;
106
- }
107
-
108
- // libs/utility/src/lib/sort-by-name.ts
109
- function sortByName(a, b) {
110
- return a.name === b.name ? 0 : a.name > b.name ? 1 : -1;
111
- }
112
-
113
- // libs/report/committers/src/lib/parse-date-flags.ts
114
- var import_date_fns = require("date-fns");
115
- function parseDateFlags(dateFormat2, startDate, endDate) {
116
- return {
117
- endDate: (0, import_date_fns.parse)(endDate, dateFormat2, /* @__PURE__ */ new Date()),
118
- startDate: (0, import_date_fns.parse)(startDate, dateFormat2, /* @__PURE__ */ new Date())
119
- };
120
- }
121
-
122
- // libs/report/committers/src/lib/constants.ts
123
- var dateFormat = "yyyy-MM-dd";
124
- var gammaDelimiter = "\u0393\u0393\u0393\u0393";
125
- var monthsToSubtract = 12;
126
- var gitOutputFormat = `"${["%h", "%an", "%ad"].join(gammaDelimiter)}"`;
127
-
128
- // libs/report/committers/src/lib/parse-git-log-entries.ts
129
- function parseGitLogEntries(entries) {
130
- return entries.map((entry) => {
131
- const [commitHash, committer, date] = entry.split(gammaDelimiter);
132
- return { commitHash, committer, date: new Date(date) };
133
- });
134
- }
135
-
136
- // libs/report/committers/src/lib/get-committer-counts.ts
137
- function getCommitterCounts(entries) {
138
- return entries.reduce((acc, entry) => {
139
- let committerCount = acc.find((c) => c.name === entry.committer);
140
- if (!committerCount) {
141
- committerCount = { name: entry.committer, count: 0 };
142
- acc.push(committerCount);
143
- }
144
- committerCount.count++;
145
- return acc;
146
- }, []).sort((a, b) => b.count - a.count);
147
- }
148
-
149
- // libs/report/committers/src/lib/committers.ts
150
- var reportCommittersCommand = {
151
- command: "committers",
152
- describe: "show git committers",
153
- aliases: [],
154
- builder: {
155
- startDate: {
156
- alias: "s",
157
- default: (0, import_date_fns2.format)(/* @__PURE__ */ new Date(), dateFormat),
158
- describe: `Start Date (format: ${dateFormat})`,
159
- string: true
160
- },
161
- endDate: {
162
- alias: "e",
163
- describe: `End Date (format: ${dateFormat})`,
164
- required: false,
165
- default: (0, import_date_fns2.format)((0, import_date_fns2.subMonths)(/* @__PURE__ */ new Date(), monthsToSubtract), dateFormat)
166
- },
167
- exclude: {
168
- alias: "x",
169
- array: true,
170
- describe: 'Path Exclusions (eg -x="./src/bin" -x="./dist")',
171
- required: false
172
- },
173
- json: {
174
- describe: "Output to JSON format",
175
- required: false,
176
- default: false,
177
- boolean: true
178
- }
179
- // monthly: {
180
- // alias: 'm',
181
- // describe:
182
- // 'Break down by calendar month, rather than by committer. (eg -m)',
183
- // required: false,
184
- // default: false,
185
- // },
186
- },
187
- handler: run
188
- };
189
- async function run(args) {
190
- const { startDate, endDate } = parseDateFlags(dateFormat, args.startDate, args.endDate);
191
- const ignores = args.exclude && args.exclude.length ? `-- . "!(${args.exclude.join("|")})"` : "";
192
- const gitCommand = `git log --since "${endDate}" --until "${startDate}" --pretty=format:${gitOutputFormat} ${ignores}`;
193
- const result = await runCommand(gitCommand);
194
- const rawEntries = result.split("\n");
195
- if (rawEntries.length === 1 && rawEntries[0] === "") {
196
- const startDateStr = (0, import_date_fns2.format)(startDate, "yyyy-MM-dd");
197
- const endDateStr = (0, import_date_fns2.format)(endDate, "yyyy-MM-dd");
198
- console.log(`No commits found between ${endDateStr} and ${startDateStr}`);
199
- return;
200
- }
201
- const entries = parseGitLogEntries(rawEntries);
202
- const committerCounts = getCommitterCounts(entries);
203
- if (args.json) {
204
- outputCommittersJson(committerCounts);
205
- } else {
206
- outputCommitters(committerCounts);
207
- }
208
- }
209
- function outputCommitters(committerCounts) {
210
- const longestNameLength = committerCounts.reduce((acc, c) => {
211
- return c.name.length > acc ? c.name.length : acc;
212
- }, "Committer".length);
213
- const header = `Committer${" ".repeat(longestNameLength - 9)} | Commits`;
214
- console.log(header);
215
- console.log(
216
- header.split("").map((c) => c === "|" ? "|" : "-").join("")
217
- );
218
- console.log(
219
- committerCounts.map((c) => {
220
- const committer = `${c.name}${" ".repeat(longestNameLength - c.name.length)}`;
221
- const count = " ".repeat(7 - c.count.toString().length) + c.count;
222
- return `${committer} | ${count}`;
223
- }).join("\n")
224
- );
225
- }
226
- function outputCommittersJson(committerCounts) {
227
- console.log(JSON.stringify(committerCounts, null, 2));
228
- }
229
-
230
- // libs/report/diagnostics/src/lib/diagnostics.ts
231
- var import_prompts = require("@inquirer/prompts");
232
-
233
- // libs/report/diagnostics/src/lib/get-file-contents.ts
234
- var import_fs3 = require("fs");
235
- function getFileContents(filePath) {
236
- if (!(0, import_fs3.existsSync)(filePath)) {
237
- return `${filePath} not found`;
238
- }
239
- const diagData = (0, import_fs3.readFileSync)(filePath, "utf8");
240
- return diagData;
241
- }
242
-
243
- // libs/report/diagnostics/src/lib/get-package-json-section.ts
244
- function getPackageJsonSection(section) {
245
- const filePath = "package.json";
246
- const pkg = JSON.parse(getFileContents(filePath));
247
- const sectionData = pkg[section];
248
- if (!sectionData) {
249
- return `${section} not found in package.json`;
250
- }
251
- const diagData = JSON.stringify(sectionData, null, 2);
252
- return diagData;
253
- }
254
-
255
- // libs/report/diagnostics/src/lib/get-diagnostic-types.ts
256
- function getDiagnosticTypes() {
257
- const diagTypeList = [
258
- { name: "Package JSON - dependencies", value: "dependencies" },
259
- { name: "Package JSON - devDependencies", value: "devDependencies" },
260
- { name: "Package JSON - overrides", value: "overrides" },
261
- { name: ".npmrc file contents", value: "npmrc" },
262
- { name: "npm config", value: "npm config" },
263
- { name: "List of installed packages (npm ls)", value: "npm ls" }
264
- ];
265
- return diagTypeList;
266
- }
267
-
268
- // libs/report/diagnostics/src/lib/diagnostics.ts
269
- var reportDiagnosticsCommand = {
270
- command: "diagnostics",
271
- describe: "show diagnostic information",
272
- aliases: ["diag", "d"],
273
- builder: {
274
- all: {
275
- describe: "Return all available diagnostics",
276
- required: false,
277
- default: false,
278
- boolean: true
279
- },
280
- consent: {
281
- describe: "Agree to understanding that sensitive data may be outputted",
282
- required: false,
283
- default: false,
284
- boolean: true
285
- }
286
- },
287
- handler: run2
288
- };
289
- async function run2(args) {
290
- const consentPrompt = "Data produced may contain sensitive data, please review before sharing it.";
291
- if (!args.consent) {
292
- const answer = await (0, import_prompts.confirm)({
293
- message: `${consentPrompt} Continue?`
294
- });
295
- if (!answer) {
296
- return;
297
- }
298
- } else {
299
- console.log(consentPrompt);
300
- }
301
- const diagTypeList = getDiagnosticTypes().map((d) => ({
302
- ...d,
303
- checked: true
304
- }));
305
- const diagTypes = args.all ? diagTypeList.map((d) => d.value) : await (0, import_prompts.checkbox)({
306
- message: "select diagnostic(s) to run",
307
- choices: diagTypeList,
308
- required: true,
309
- pageSize: diagTypeList.length
310
- });
311
- for (let i = 0; i < diagTypes.length; i++) {
312
- let output = "";
313
- let title = "";
314
- switch (diagTypes[i]) {
315
- case "dependencies":
316
- title = "Package JSON - dependencies";
317
- output = getPackageJsonSection("dependencies");
318
- break;
319
- case "devDependencies":
320
- title = "Package JSON - devDependencies";
321
- output = getPackageJsonSection("devDependencies");
322
- break;
323
- case "overrides":
324
- title = "Package JSON - overrides";
325
- output = getPackageJsonSection("overrides");
326
- break;
327
- case "npmrc":
328
- title = ".npmrc file contents";
329
- output = getFileContents(".npmrc");
330
- break;
331
- case "npm config":
332
- try {
333
- title = "npm config results";
334
- output = await runCommand("npm config get");
335
- } catch (e) {
336
- output = e.stderr;
337
- }
338
- break;
339
- case "npm ls":
340
- title = "npm ls results";
341
- output = await runCommand("npm ls --depth=1000");
342
- break;
343
- }
344
- const titleMsg = `*** ${title} ***`;
345
- const titleWrapper = "*".repeat(titleMsg.length);
346
- console.log(`${titleWrapper}
347
- ${titleMsg}
348
- ${titleWrapper}
349
- ${output}
350
- `);
351
- }
352
- }
353
-
354
- // libs/tracker/init/src/lib/default-config.ts
355
- var defaultConfig = {
356
- categories: {
357
- legacy: {
358
- fileTypes: ["js", "ts", "html", "css", "scss", "less"],
359
- includes: ["./legacy"],
360
- jsTsPairs: "js"
361
- },
362
- modern: {
363
- fileTypes: ["ts", "html", "css", "scss", "less"],
364
- includes: ["./modern"],
365
- jsTsPairs: "ts"
366
- }
367
- },
368
- ignorePatterns: ["node_modules"],
369
- outputDir: "hd-tracker"
370
- };
371
-
372
- // libs/tracker/init/src/lib/init.ts
373
- var import_path2 = require("path");
374
- var import_fs4 = require("fs");
375
- var trackerInitCommand = {
376
- command: "init",
377
- describe: "Initialize the tracker configuration",
378
- aliases: [],
379
- builder: {},
380
- handler: run3
381
- };
382
- function run3(args) {
383
- const rootDir = getRootDir(global.process.cwd());
384
- const output = JSON.stringify(defaultConfig, null, 2);
385
- const dir = (0, import_path2.join)(rootDir, "hd-tracker");
386
- if (!(0, import_fs4.existsSync)(dir)) {
387
- (0, import_fs4.mkdirSync)(dir);
388
- }
389
- (0, import_fs4.writeFileSync)((0, import_path2.join)(dir, "config.json"), output);
390
- }
391
-
392
- // libs/tracker/shared/src/lib/read-config.ts
393
- var import_fs5 = require("fs");
394
- var import_path3 = require("path");
395
- function readConfig(rootDirectory, optionsPath) {
396
- const path3 = optionsPath && (0, import_fs5.existsSync)((0, import_path3.join)(rootDirectory, optionsPath)) ? (0, import_path3.join)(rootDirectory, optionsPath) : (0, import_path3.join)(rootDirectory, "hd-tracker", "config.json");
397
- const contents = (0, import_fs5.readFileSync)(path3).toString("utf-8");
398
- return JSON.parse(contents);
399
- }
400
-
401
- // libs/tracker/run/src/lib/run.ts
402
- var import_path6 = require("path");
403
-
404
- // libs/tracker/run/src/lib/process-category.ts
405
- var sloc = __toESM(require("sloc"));
406
- var import_fs6 = require("fs");
407
- var import_path4 = require("path");
408
- function processCategory(rootDirectory, category, ignorePatterns) {
409
- console.log(`Processing "${category.name}"...`);
410
- const allFiles = category.includes.reduce((acc, include) => {
411
- return [...acc, ...findAllFilesInDirectory((0, import_path4.join)(rootDirectory, include))];
412
- }, []);
413
- const includedFiles = findIncludedFiles(category, ignorePatterns, allFiles);
414
- console.log(` ${includedFiles.length} files...`);
415
- const results = includedFiles.map(getFileStats);
416
- const resultMap = aggregateResults(results);
417
- const aggregatedResults = Object.values(resultMap).map((val) => val);
418
- const totals = aggregatedResults.reduce(
419
- (totals2, curr) => ({
420
- fileCount: totals2.fileCount + curr.fileCount,
421
- total: totals2.total + curr.total,
422
- source: totals2.source + curr.source,
423
- comment: totals2.comment + curr.comment,
424
- single: totals2.single + curr.single,
425
- block: totals2.block + curr.block,
426
- mixed: totals2.mixed + curr.mixed,
427
- empty: totals2.empty + curr.empty,
428
- todo: totals2.todo + curr.todo,
429
- blockEmpty: totals2.blockEmpty + curr.blockEmpty
430
- }),
431
- {
432
- fileCount: 0,
433
- total: 0,
434
- source: 0,
435
- comment: 0,
436
- single: 0,
437
- block: 0,
438
- mixed: 0,
439
- empty: 0,
440
- todo: 0,
441
- blockEmpty: 0
442
- }
443
- );
444
- const final = {
445
- name: category.name,
446
- totals,
447
- fileTypes: aggregatedResults
448
- };
449
- console.log(` ${final.totals.total} total lines`);
450
- return final;
451
- }
452
- function aggregateResults(results) {
453
- return results.reduce((acc, result) => {
454
- const fileTypeResults = acc[result.fileType];
455
- if (!fileTypeResults) {
456
- acc[result.fileType] = {
457
- fileType: result.fileType,
458
- fileCount: 1,
459
- total: result.total,
460
- source: result.source,
461
- comment: result.comment,
462
- single: result.single,
463
- block: result.block,
464
- mixed: result.mixed,
465
- empty: result.empty,
466
- todo: result.todo,
467
- blockEmpty: result.blockEmpty
468
- };
469
- } else {
470
- acc[result.fileType] = {
471
- fileType: result.fileType,
472
- fileCount: fileTypeResults.fileCount + 1,
473
- total: fileTypeResults.total + result.total,
474
- source: fileTypeResults.source + result.source,
475
- comment: fileTypeResults.comment + result.comment,
476
- single: fileTypeResults.single + result.single,
477
- block: fileTypeResults.block + result.block,
478
- mixed: fileTypeResults.mixed + result.mixed,
479
- empty: fileTypeResults.empty + result.empty,
480
- todo: fileTypeResults.todo + result.todo,
481
- blockEmpty: fileTypeResults.blockEmpty + result.blockEmpty
482
- };
483
- }
484
- return acc;
485
- }, {});
486
- }
487
- function getFileStats(file) {
488
- const contents = (0, import_fs6.readFileSync)(file).toString("utf-8");
489
- const fileType = getFileExt(file);
490
- const stats = sloc(contents, fileType);
491
- return {
492
- path: file,
493
- fileType,
494
- ...stats
495
- };
496
- }
497
- function findIncludedFiles(category, ignorePatterns, allFiles) {
498
- return allFiles.filter((file) => {
499
- const ext = getFileExt(file);
500
- let shouldBeIncluded = !!category.fileTypes.find(
501
- (fileType) => fileType === ext
502
- );
503
- if (shouldBeIncluded) {
504
- ignorePatterns?.forEach((ignorePattern) => {
505
- if (file.indexOf(ignorePattern) !== -1) {
506
- shouldBeIncluded = false;
507
- }
508
- });
509
- }
510
- if (shouldBeIncluded) {
511
- category.excludes?.forEach((exclude) => {
512
- if (file.indexOf(exclude) !== -1) {
513
- shouldBeIncluded = false;
514
- }
515
- });
516
- }
517
- return shouldBeIncluded;
518
- }).filter((file, _index, files) => {
519
- if (category.jsTsPairs === "ignore" || category.jsTsPairs === void 0) {
520
- return true;
521
- }
522
- const fileExtToKeep = category.jsTsPairs;
523
- const ext = getFileExt(file);
524
- const fileExtToDiscard = fileExtToKeep === "js" ? "ts" : "js";
525
- if (fileExtToKeep === ext || fileExtToDiscard !== ext) {
526
- return true;
527
- }
528
- const counterpartExt = ext === "js" ? "ts" : "js";
529
- const parts = file.split(".");
530
- parts[parts.length - 1] = counterpartExt;
531
- const counterpartExists = files.filter((f) => f === parts.join(".")).length !== 0;
532
- if (counterpartExists) {
533
- return false;
534
- }
535
- return true;
536
- });
537
- }
538
- function findAllFilesInDirectory(directory) {
539
- const results = (0, import_fs6.readdirSync)(directory);
540
- const subfiles = results.filter((result) => (0, import_fs6.lstatSync)((0, import_path4.join)(directory, result)).isDirectory()).reduce((acc, subdir) => {
541
- const files2 = findAllFilesInDirectory((0, import_path4.join)(directory, subdir));
542
- return [...acc, ...files2];
543
- }, []);
544
- const files = results.filter((result) => (0, import_fs6.lstatSync)((0, import_path4.join)(directory, result)).isFile()).map((fileName) => (0, import_path4.join)(directory, fileName));
545
- return [...files, ...subfiles];
546
- }
547
- function getFileExt(file) {
548
- return (0, import_path4.extname)(file).replace(/\./g, "");
549
- }
550
-
551
- // libs/tracker/run/src/lib/get-git-commit.ts
552
- var import_date_fns3 = require("date-fns");
553
- var import_git_last_commit = require("git-last-commit");
554
- async function getGitCommit() {
555
- const commit = await getLastCommitAsPromise();
556
- return {
557
- hash: commit.hash,
558
- timestamp: formatDate(getGitDate(commit.committedOn))
559
- };
560
- }
561
- function getLastCommitAsPromise() {
562
- return new Promise((resolve4, reject) => {
563
- (0, import_git_last_commit.getLastCommit)((err, commit) => {
564
- if (err) {
565
- reject(err);
566
- }
567
- resolve4(commit);
568
- });
569
- });
570
- }
571
- function formatDate(date) {
572
- return (0, import_date_fns3.format)(date, "yyyy-MM-dd-HH-mm-ss-SSS");
573
- }
574
- function getGitDate(date) {
575
- return new Date(+date * 1e3);
576
- }
577
-
578
- // libs/tracker/run/src/lib/process-config.ts
579
- async function processConfig(config, rootDirectory) {
580
- console.log(`Starting...`);
581
- const categoryResults = Object.entries(config.categories).map(
582
- ([name, category]) => processCategory(
583
- rootDirectory,
584
- { ...category, name },
585
- config.ignorePatterns || []
586
- )
587
- );
588
- const commit = await getGitCommit();
589
- return {
590
- timestamp: commit.timestamp,
591
- hash: commit.hash,
592
- categories: categoryResults
593
- };
594
- }
595
-
596
- // libs/tracker/run/src/lib/get-data.ts
597
- var import_fs7 = require("fs");
598
-
599
- // libs/tracker/run/src/lib/get-data-filepath.ts
600
- var import_path5 = require("path");
601
- function getDataFilePath(localRootDir, outputDir) {
602
- return (0, import_path5.resolve)((0, import_path5.join)(localRootDir, outputDir, "data.json"));
603
- }
604
-
605
- // libs/tracker/run/src/lib/get-data.ts
606
- function getData(localRootDir, outputDir) {
607
- const outputPath = getDataFilePath(localRootDir, outputDir);
608
- let contents = "";
609
- if ((0, import_fs7.existsSync)(outputPath)) {
610
- contents = (0, import_fs7.readFileSync)(outputPath).toString("utf-8");
611
- }
612
- return contents === "" ? [] : JSON.parse(contents);
613
- }
614
-
615
- // libs/tracker/run/src/lib/save-results.ts
616
- var import_fs8 = require("fs");
617
- function saveResults(localRootDir, outputDir, results) {
618
- console.log("Outputting file");
619
- const output = getData(localRootDir, outputDir);
620
- if (!Array.isArray(output)) {
621
- console.error("Invalid output file format");
622
- }
623
- output.push(results);
624
- const outputPath = getDataFilePath(localRootDir, outputDir);
625
- const outputText = JSON.stringify(output, null, 2);
626
- (0, import_fs8.writeFileSync)(outputPath, outputText);
627
- console.log(`Output written to: ${outputPath}`);
628
- }
629
-
630
- // libs/tracker/run/src/lib/run.ts
631
- var trackerRunCommand = {
632
- command: "run",
633
- describe: "Run the tracker",
634
- aliases: [],
635
- builder: {
636
- // root: Flags.string({ char: 'r', description: 'root dir of the project' }),
637
- // config: Flags.string({ char: 'c', description: 'path to config file' }),
638
- },
639
- handler: run4
640
- };
641
- async function run4(args) {
642
- const localRootDir = getRootDir(global.process.cwd());
643
- const rootDirectory = args.root ? (0, import_path6.resolve)(args.root) : localRootDir;
644
- const config = readConfig(localRootDir, args.config);
645
- const results = await processConfig(config, rootDirectory);
646
- saveResults(localRootDir, config.outputDir, results);
647
- }
648
-
649
- // apps/cli/src/lib/create-group-command.ts
650
- function createGroupCommand(group, description, subCommand, subCommandDescription, aliases, commands, errorMessage) {
651
- const cmd = {
652
- command: `${group} <${subCommand}>`,
653
- describe: description,
654
- aliases,
655
- positional: {
656
- type: {
657
- type: "string",
658
- demandOption: true,
659
- describe: subCommandDescription
660
- }
661
- },
662
- builder: (yargs2) => {
663
- return yargs2.command(commands);
664
- },
665
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
666
- handler: (args) => {
667
- console.log(`${errorMessage} (${args[subCommand]})`);
668
- }
669
- };
670
- return cmd;
671
- }
672
-
673
- // libs/nes/init/src/lib/init.ts
674
- var import_prompts2 = require("@inquirer/prompts");
675
-
676
- // libs/nes/init/src/lib/verify-project-type.ts
677
- function verifyProjectType() {
678
- const types = getProjectTypes();
679
- let valid = true;
680
- let error = void 0;
681
- if (types.length === 0) {
682
- valid = false;
683
- error = "Unable to recognize a supported project type.";
684
- }
685
- return {
686
- types,
687
- valid,
688
- error
689
- };
690
- }
691
-
692
- // libs/nes/init/src/lib/get-release-trains.ts
693
- var import_core = require("@apollo/client/core");
694
- async function getReleaseTrains(accessToken, types) {
695
- const client = new import_core.ApolloClient({
696
- cache: new import_core.InMemoryCache(),
697
- uri: "https://api.nes.herodevs.com/graphql"
698
- });
699
- try {
700
- const queryResult = await client.query({
701
- query: import_core.gql`
702
- query RT($input: LicensingReleaseTrainsInput) {
703
- licensing {
704
- releaseTrains(input: $input) {
705
- results {
706
- key
707
- name
708
- products {
709
- id
710
- key
711
- name
712
- }
713
- entries {
714
- packageVersion {
715
- id
716
- name
717
- fqns
718
- origination {
719
- name
720
- type
721
- version
722
- }
723
- }
724
- }
725
- }
726
- }
727
- }
728
- }
729
- `,
730
- variables: { input: { tenantId: 1e3, byToken: accessToken } }
731
- });
732
- const results = queryResult.data?.licensing?.releaseTrains?.results;
733
- if (!results) {
734
- throw new Error(`Error getting release trains`);
735
- }
736
- return results;
737
- } catch (error) {
738
- throw new Error(`Error getting release trains`);
739
- }
740
- }
741
-
742
- // libs/nes/init/src/lib/get-product-choices.ts
743
- async function getProductChoices(accessToken, types) {
744
- const releaseTrains = await getReleaseTrains(accessToken, types);
745
- return releaseTrains.map((rt) => ({
746
- name: rt.name,
747
- value: rt
748
- })).sort(sortByName);
749
- }
750
-
751
- // libs/nes/init/src/lib/get-package-choices.ts
752
- function getPackageChoices(releaseTrain) {
753
- return releaseTrain.entries.map((e) => ({
754
- name: e.packageVersion.origination?.name || e.packageVersion.name,
755
- value: e
756
- })).sort(sortByName);
757
- }
758
-
759
- // libs/nes/init/src/lib/npm/configure-npm-project.ts
760
- var import_fs9 = require("fs");
761
- var path2 = require("path");
762
- function configureNpmProject(accessToken, packages) {
763
- updatePackageJson(packages);
764
- updateNpmrc(accessToken);
765
- }
766
- function updatePackageJson(packages) {
767
- const packageJsonPath = path2.join(process.cwd(), "package.json");
768
- const packageJsonContents = (0, import_fs9.readFileSync)(packageJsonPath, "utf8");
769
- const packageJson = JSON.parse(packageJsonContents);
770
- const pkgUpdates = packages.map((p) => ({
771
- key: p.packageVersion.origination?.name || p.packageVersion.name,
772
- value: p.packageVersion.fqns
773
- })).reduce(
774
- (acc, cur) => {
775
- if (packageJson.devDependencies?.[cur.key]) {
776
- acc.devDeps[cur.key] = `npm:${cur.value}`;
777
- } else if (packageJson.peerDependencies?.[cur.key]) {
778
- acc.peerDeps[cur.key] = `npm:${cur.value}`;
779
- } else {
780
- acc.deps[cur.key] = `npm:${cur.value}`;
781
- }
782
- acc.overrides[cur.key] = { ".": `npm:${cur.value}` };
783
- return acc;
784
- },
785
- { deps: {}, devDeps: {}, peerDeps: {}, overrides: {} }
786
- );
787
- packageJson.dependencies = {
788
- ...packageJson.dependencies || {},
789
- ...pkgUpdates.deps
790
- };
791
- packageJson.devDependencies = {
792
- ...packageJson.devDependencies || {},
793
- ...pkgUpdates.devDeps
794
- };
795
- packageJson.peerDependencies = {
796
- ...packageJson.peerDependencies || {},
797
- ...pkgUpdates.peerDeps
798
- };
799
- packageJson.overrides = {
800
- ...packageJson.overrides || {},
801
- ...pkgUpdates.overrides
802
- };
803
- (0, import_fs9.writeFileSync)(packageJsonPath, JSON.stringify(packageJson, null, 2));
804
- }
805
- function updateNpmrc(accessToken) {
806
- const npmrcPath = path2.join(process.cwd(), ".npmrc");
807
- let npmrcContents = "";
808
- if ((0, import_fs9.existsSync)(npmrcPath)) {
809
- npmrcContents = (0, import_fs9.readFileSync)(npmrcPath, "utf8");
810
- }
811
- if (npmrcContents.includes(`@neverendingsupport:registry`)) {
812
- return;
813
- }
814
- const updatedContents = npmrcContents + `
815
-
816
- @neverendingsupport:registry=https://registry.nes.herodevs.com/npm/pkg/
817
- //registry.nes.herodevs.com/npm/pkg/:_authToken="${accessToken}"`;
818
- (0, import_fs9.writeFileSync)(npmrcPath, updatedContents);
819
- }
820
-
821
- // libs/nes/init/src/lib/configure-project.ts
822
- function configureProject(accessToken, projectTypes, packages) {
823
- if (projectTypes.includes("npm")) {
824
- configureNpmProject(accessToken, packages);
825
- }
826
- }
827
-
828
- // libs/nes/init/src/lib/init.ts
829
- var ora = __toESM(require("ora"));
830
- var nesInitCommand = {
831
- command: "init",
832
- describe: "Initialize the NES project",
833
- aliases: [],
834
- builder: {},
835
- handler: run5
836
- };
837
- async function run5(args) {
838
- const spinner = ora();
839
- const projectType = verifyProjectType();
840
- if (!projectType.valid) {
841
- console.error(projectType.error);
842
- return;
843
- }
844
- if (!await (0, import_prompts2.confirm)({
845
- message: "Before initializing, please commit all changes. Continue?"
846
- })) {
847
- return;
848
- }
849
- const accessToken = await (0, import_prompts2.password)({
850
- message: "Enter access token",
851
- mask: "*"
852
- });
853
- spinner.start("loading your products");
854
- const productList = await getProductChoices(accessToken, projectType.types);
855
- spinner.stop();
856
- const releaseTrain = await (0, import_prompts2.select)({
857
- message: "select a product",
858
- choices: productList,
859
- pageSize: productList.length
860
- // no scrolling
861
- });
862
- const packageList = getPackageChoices(releaseTrain).map((p) => ({
863
- ...p,
864
- checked: true
865
- }));
866
- const packages = await (0, import_prompts2.checkbox)({
867
- message: `select the package(s)`,
868
- choices: packageList,
869
- loop: false,
870
- pageSize: packageList.length
871
- // no scrolling
872
- });
873
- console.log("configuring your project...");
874
- configureProject(accessToken, projectType.types, packages);
875
- console.log("Your project is now configured to access your NES product");
876
- }
877
-
878
- // apps/cli/src/lib/get-commands.ts
879
- function getCommands() {
880
- const nesCommand = createGroupCommand(
881
- "nes",
882
- "",
883
- "command",
884
- "nes command",
885
- [],
886
- [nesInitCommand],
887
- "Invalid nes command"
888
- );
889
- const reportCommand = createGroupCommand(
890
- "report",
891
- "",
892
- "type",
893
- "type of report",
894
- "r",
895
- [reportCommittersCommand, reportDiagnosticsCommand],
896
- "Invalid report type"
897
- );
898
- const trackerCommand = createGroupCommand(
899
- "tracker",
900
- "",
901
- "command",
902
- "tracker command",
903
- [],
904
- [trackerInitCommand, trackerRunCommand],
905
- "Invalid tracker command"
906
- );
907
- return [nesCommand, reportCommand, trackerCommand];
908
- }
909
-
910
- // apps/cli/src/lib/ensure-version.ts
911
- var getJson = __toESM(require("get-json"));
912
-
913
- // apps/cli/src/lib/log-colors.ts
914
- function color(color2) {
915
- return (...args) => {
916
- return `${color2}${args.join(
917
- ` ${color2}`
918
- /*reset color for nested color*/
919
- )}${"\x1B[0m" /* Reset */}`;
920
- };
921
- }
922
-
923
- // apps/cli/src/lib/ensure-version.ts
924
- var red = color("\x1B[31m" /* FgRed */);
925
- var yellow = color("\x1B[33m" /* FgYellow */);
926
- async function getLatestVersion(pkgName) {
927
- return getJson(`https://registry.npmjs.org/${pkgName}`).then(
928
- (packageData) => {
929
- return packageData["dist-tags"].latest;
930
- }
931
- );
932
- }
933
- async function isVersionUpToDate(packageName, packageVersion, quietIfSuccessful = false) {
934
- if (packageVersion === "0.0.0") {
935
- return true;
936
- }
937
- const latestVersion = await getLatestVersion(packageName);
938
- if (latestVersion === packageVersion) {
939
- if (!quietIfSuccessful) {
940
- console.log(`${packageName}@${latestVersion} is up to date`);
941
- }
942
- return true;
943
- }
944
- console.log(
945
- `${yellow(
946
- "Your version:",
947
- red(`${packageName}@${packageVersion}`),
948
- `is not up to date`
949
- )}`
950
- );
951
- console.log(
952
- `${yellow("Latest version:", red(`${packageName}@${latestVersion}...`))}`
953
- );
954
- return false;
955
- }
956
- async function ensureVersionIsUpToDate(packageName, packageVersion) {
957
- const versionUpToDate = await isVersionUpToDate(packageName, packageVersion);
958
- if (!versionUpToDate) {
959
- console.log(
960
- [
961
- `
962
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
963
-
964
- `,
965
- `${red(`ERROR:`)} Did not run command.
966
-
967
- `,
968
- ` - Rerun your command with the ${yellow(
969
- "@latest"
970
- )} tag to ensure correct output:
971
-
972
-
973
- `,
974
- ` ${yellow(`npx ${packageName}@latest`)}
975
- `,
976
- `
977
-
978
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
979
- `
980
- ].join(" ")
981
- );
982
- return process.exit(1);
983
- }
984
- }
985
-
986
- // apps/cli/src/lib/cli.ts
987
- function cli() {
988
- const commands = getCommands();
989
- const pkg = require_package();
990
- const packageName = pkg.name;
991
- const packageVersion = pkg.version;
992
- yargs.scriptName(packageName).usage("Usage: $0 <command> [options]").middleware(() => ensureVersionIsUpToDate(packageName, packageVersion)).command(commands).parse((0, import_helpers.hideBin)(process.argv));
993
- }
994
- // Annotate the CommonJS export names for ESM import in node:
995
- 0 && (module.exports = {
996
- cli
997
- });