@xylabs/ts-scripts-yarn3 2.20.0-rc.1 → 3.0.0-rc.1

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 (284) hide show
  1. package/dist/actions/build.mjs +133 -0
  2. package/dist/actions/build.mjs.map +1 -0
  3. package/dist/actions/clean-docs.mjs +29 -0
  4. package/dist/actions/clean-docs.mjs.map +1 -0
  5. package/dist/actions/clean-eslint.mjs +15 -0
  6. package/dist/actions/clean-eslint.mjs.map +1 -0
  7. package/dist/actions/clean-jest.mjs +100 -0
  8. package/dist/actions/clean-jest.mjs.map +1 -0
  9. package/dist/actions/clean.mjs +210 -0
  10. package/dist/actions/clean.mjs.map +1 -0
  11. package/dist/actions/compile.mjs +124 -0
  12. package/dist/actions/compile.mjs.map +1 -0
  13. package/dist/actions/copy-assets.mjs +71 -0
  14. package/dist/actions/copy-assets.mjs.map +1 -0
  15. package/dist/actions/cycle.mjs +100 -0
  16. package/dist/actions/cycle.mjs.map +1 -0
  17. package/dist/actions/dead.mjs +99 -0
  18. package/dist/actions/dead.mjs.map +1 -0
  19. package/dist/actions/deploy-major.mjs +106 -0
  20. package/dist/actions/deploy-major.mjs.map +1 -0
  21. package/dist/actions/deploy-minor.mjs +106 -0
  22. package/dist/actions/deploy-minor.mjs.map +1 -0
  23. package/dist/actions/deploy-next.mjs +106 -0
  24. package/dist/actions/deploy-next.mjs.map +1 -0
  25. package/dist/actions/deploy.mjs +107 -0
  26. package/dist/actions/deploy.mjs.map +1 -0
  27. package/dist/actions/deps.mjs +121 -0
  28. package/dist/actions/deps.mjs.map +1 -0
  29. package/dist/actions/dupdeps.mjs +181 -0
  30. package/dist/actions/dupdeps.mjs.map +1 -0
  31. package/dist/actions/fix.mjs +99 -0
  32. package/dist/actions/fix.mjs.map +1 -0
  33. package/dist/actions/gen-docs.mjs +110 -0
  34. package/dist/actions/gen-docs.mjs.map +1 -0
  35. package/dist/actions/gitignore-gen.mjs +87 -0
  36. package/dist/actions/gitignore-gen.mjs.map +1 -0
  37. package/dist/actions/gitlint-fix.mjs +27 -0
  38. package/dist/actions/gitlint-fix.mjs.map +1 -0
  39. package/dist/actions/gitlint.mjs +48 -0
  40. package/dist/actions/gitlint.mjs.map +1 -0
  41. package/dist/actions/index.mjs +1405 -0
  42. package/dist/actions/index.mjs.map +1 -0
  43. package/dist/actions/license.mjs +87 -0
  44. package/dist/actions/license.mjs.map +1 -0
  45. package/dist/actions/lint-clean.mjs +147 -0
  46. package/dist/actions/lint-clean.mjs.map +1 -0
  47. package/dist/actions/lint-profile.mjs +99 -0
  48. package/dist/actions/lint-profile.mjs.map +1 -0
  49. package/dist/actions/lint.mjs +137 -0
  50. package/dist/actions/lint.mjs.map +1 -0
  51. package/dist/actions/npmignore-gen.mjs +87 -0
  52. package/dist/actions/npmignore-gen.mjs.map +1 -0
  53. package/dist/actions/package/clean-outputs.mjs +18 -0
  54. package/dist/actions/package/clean-outputs.mjs.map +1 -0
  55. package/dist/actions/package/clean-typescript.mjs +18 -0
  56. package/dist/actions/package/clean-typescript.mjs.map +1 -0
  57. package/dist/actions/package/clean.mjs +38 -0
  58. package/dist/actions/package/clean.mjs.map +1 -0
  59. package/dist/actions/package/compile.mjs +63 -0
  60. package/dist/actions/package/compile.mjs.map +1 -0
  61. package/dist/actions/package/copy-assets.mjs +43 -0
  62. package/dist/actions/package/copy-assets.mjs.map +1 -0
  63. package/dist/actions/package/deps.mjs +96 -0
  64. package/dist/actions/package/deps.mjs.map +1 -0
  65. package/dist/actions/package/gen-docs.mjs +112 -0
  66. package/dist/actions/package/gen-docs.mjs.map +1 -0
  67. package/dist/actions/package/index.mjs +400 -0
  68. package/dist/actions/package/index.mjs.map +1 -0
  69. package/dist/actions/package/publint.mjs +21 -0
  70. package/dist/actions/package/publint.mjs.map +1 -0
  71. package/dist/actions/package/recompile.mjs +103 -0
  72. package/dist/actions/package/recompile.mjs.map +1 -0
  73. package/dist/actions/package/tsup.mjs +31 -0
  74. package/dist/actions/package/tsup.mjs.map +1 -0
  75. package/dist/actions/package/types.d.js +2 -0
  76. package/dist/actions/package/types.d.js.map +1 -0
  77. package/dist/actions/package/types.d.mjs +1 -0
  78. package/dist/actions/package/types.d.mjs.map +1 -0
  79. package/dist/actions/publint.mjs +168 -0
  80. package/dist/actions/publint.mjs.map +1 -0
  81. package/dist/actions/rebuild.mjs +102 -0
  82. package/dist/actions/rebuild.mjs.map +1 -0
  83. package/dist/actions/recompile.mjs +140 -0
  84. package/dist/actions/recompile.mjs.map +1 -0
  85. package/dist/actions/reinstall.mjs +130 -0
  86. package/dist/actions/reinstall.mjs.map +1 -0
  87. package/dist/actions/relint.mjs +128 -0
  88. package/dist/actions/relint.mjs.map +1 -0
  89. package/dist/actions/retest.mjs +102 -0
  90. package/dist/actions/retest.mjs.map +1 -0
  91. package/dist/actions/sonar.mjs +99 -0
  92. package/dist/actions/sonar.mjs.map +1 -0
  93. package/dist/actions/statics.mjs +181 -0
  94. package/dist/actions/statics.mjs.map +1 -0
  95. package/dist/actions/test.mjs +99 -0
  96. package/dist/actions/test.mjs.map +1 -0
  97. package/dist/actions/up.mjs +99 -0
  98. package/dist/actions/up.mjs.map +1 -0
  99. package/dist/actions/updo.mjs +103 -0
  100. package/dist/actions/updo.mjs.map +1 -0
  101. package/dist/actions/upplug.mjs +104 -0
  102. package/dist/actions/upplug.mjs.map +1 -0
  103. package/dist/actions/upyarn.mjs +99 -0
  104. package/dist/actions/upyarn.mjs.map +1 -0
  105. package/dist/actions/yarn3only.mjs +60 -0
  106. package/dist/actions/yarn3only.mjs.map +1 -0
  107. package/dist/bin/build.mjs +13 -0
  108. package/dist/bin/build.mjs.map +1 -0
  109. package/dist/bin/clean.mjs +13 -0
  110. package/dist/bin/clean.mjs.map +1 -0
  111. package/dist/bin/compile.mjs +13 -0
  112. package/dist/bin/compile.mjs.map +1 -0
  113. package/dist/bin/cycle.mjs +13 -0
  114. package/dist/bin/cycle.mjs.map +1 -0
  115. package/dist/bin/dead.mjs +13 -0
  116. package/dist/bin/dead.mjs.map +1 -0
  117. package/dist/bin/deploy-major.mjs +13 -0
  118. package/dist/bin/deploy-major.mjs.map +1 -0
  119. package/dist/bin/deploy-minor.mjs +13 -0
  120. package/dist/bin/deploy-minor.mjs.map +1 -0
  121. package/dist/bin/deploy-next.mjs +13 -0
  122. package/dist/bin/deploy-next.mjs.map +1 -0
  123. package/dist/bin/deploy.mjs +13 -0
  124. package/dist/bin/deploy.mjs.map +1 -0
  125. package/dist/bin/deps.mjs +13 -0
  126. package/dist/bin/deps.mjs.map +1 -0
  127. package/dist/bin/fix.mjs +13 -0
  128. package/dist/bin/fix.mjs.map +1 -0
  129. package/dist/bin/gen-docs.mjs +13 -0
  130. package/dist/bin/gen-docs.mjs.map +1 -0
  131. package/dist/bin/gitlint-fix.mjs +13 -0
  132. package/dist/bin/gitlint-fix.mjs.map +1 -0
  133. package/dist/bin/gitlint.mjs +13 -0
  134. package/dist/bin/gitlint.mjs.map +1 -0
  135. package/dist/bin/license.mjs +13 -0
  136. package/dist/bin/license.mjs.map +1 -0
  137. package/dist/bin/lint-clean.mjs +13 -0
  138. package/dist/bin/lint-clean.mjs.map +1 -0
  139. package/dist/bin/lint-fast.mjs +13 -0
  140. package/dist/bin/lint-fast.mjs.map +1 -0
  141. package/dist/bin/lint-profile.mjs +13 -0
  142. package/dist/bin/lint-profile.mjs.map +1 -0
  143. package/dist/bin/lint.mjs +13 -0
  144. package/dist/bin/lint.mjs.map +1 -0
  145. package/dist/bin/package/clean-outputs.mjs +20 -0
  146. package/dist/bin/package/clean-outputs.mjs.map +1 -0
  147. package/dist/bin/package/clean-typescript.mjs +20 -0
  148. package/dist/bin/package/clean-typescript.mjs.map +1 -0
  149. package/dist/bin/package/clean.mjs +40 -0
  150. package/dist/bin/package/clean.mjs.map +1 -0
  151. package/dist/bin/package/compile.mjs +71 -0
  152. package/dist/bin/package/compile.mjs.map +1 -0
  153. package/dist/bin/package/copy-assets-cjs.mjs +51 -0
  154. package/dist/bin/package/copy-assets-cjs.mjs.map +1 -0
  155. package/dist/bin/package/copy-assets-esm.mjs +51 -0
  156. package/dist/bin/package/copy-assets-esm.mjs.map +1 -0
  157. package/dist/bin/package/deps.mjs +102 -0
  158. package/dist/bin/package/deps.mjs.map +1 -0
  159. package/dist/bin/package/gen-docs.mjs +114 -0
  160. package/dist/bin/package/gen-docs.mjs.map +1 -0
  161. package/dist/bin/package/publint.mjs +29 -0
  162. package/dist/bin/package/publint.mjs.map +1 -0
  163. package/dist/bin/package/recompile.mjs +111 -0
  164. package/dist/bin/package/recompile.mjs.map +1 -0
  165. package/dist/bin/package/tsup.mjs +39 -0
  166. package/dist/bin/package/tsup.mjs.map +1 -0
  167. package/dist/bin/publint.mjs +13 -0
  168. package/dist/bin/publint.mjs.map +1 -0
  169. package/dist/bin/rebuild.mjs +13 -0
  170. package/dist/bin/rebuild.mjs.map +1 -0
  171. package/dist/bin/recompile.mjs +13 -0
  172. package/dist/bin/recompile.mjs.map +1 -0
  173. package/dist/bin/reinstall.mjs +13 -0
  174. package/dist/bin/reinstall.mjs.map +1 -0
  175. package/dist/bin/relint.mjs +13 -0
  176. package/dist/bin/relint.mjs.map +1 -0
  177. package/dist/bin/sonar.mjs +13 -0
  178. package/dist/bin/sonar.mjs.map +1 -0
  179. package/dist/bin/test.mjs +13 -0
  180. package/dist/bin/test.mjs.map +1 -0
  181. package/dist/bin/tsconfig-gen-clean.mjs +13 -0
  182. package/dist/bin/tsconfig-gen-clean.mjs.map +1 -0
  183. package/dist/bin/tsconfig-gen.mjs +13 -0
  184. package/dist/bin/tsconfig-gen.mjs.map +1 -0
  185. package/dist/bin/up.mjs +13 -0
  186. package/dist/bin/up.mjs.map +1 -0
  187. package/dist/bin/updo.mjs +13 -0
  188. package/dist/bin/updo.mjs.map +1 -0
  189. package/dist/bin/upplug.mjs +13 -0
  190. package/dist/bin/upplug.mjs.map +1 -0
  191. package/dist/bin/upyarn.mjs +13 -0
  192. package/dist/bin/upyarn.mjs.map +1 -0
  193. package/dist/bin/xy-ts.mjs +1465 -0
  194. package/dist/bin/xy-ts.mjs.map +1 -0
  195. package/dist/bin/xy.mjs +1465 -0
  196. package/dist/bin/xy.mjs.map +1 -0
  197. package/dist/bin/yarn3only.mjs +13 -0
  198. package/dist/bin/yarn3only.mjs.map +1 -0
  199. package/dist/index.d.mts +299 -0
  200. package/dist/index.mjs +2024 -0
  201. package/dist/index.mjs.map +1 -0
  202. package/dist/lib/checkResult.mjs +16 -0
  203. package/dist/lib/checkResult.mjs.map +1 -0
  204. package/dist/lib/createBuildConfig.mjs +45 -0
  205. package/dist/lib/createBuildConfig.mjs.map +1 -0
  206. package/dist/lib/defaultBuildConfig.mjs +13 -0
  207. package/dist/lib/defaultBuildConfig.mjs.map +1 -0
  208. package/dist/lib/dependencies/DuplicateDetector.mjs +77 -0
  209. package/dist/lib/dependencies/DuplicateDetector.mjs.map +1 -0
  210. package/dist/lib/dependencies/detectDuplicateDependencies.mjs +162 -0
  211. package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +1 -0
  212. package/dist/lib/dependencies/index.mjs +163 -0
  213. package/dist/lib/dependencies/index.mjs.map +1 -0
  214. package/dist/lib/file/ReadFileSyncOptions.mjs +6 -0
  215. package/dist/lib/file/ReadFileSyncOptions.mjs.map +1 -0
  216. package/dist/lib/file/constants.mjs +8 -0
  217. package/dist/lib/file/constants.mjs.map +1 -0
  218. package/dist/lib/file/fileLines.mjs +29 -0
  219. package/dist/lib/file/fileLines.mjs.map +1 -0
  220. package/dist/lib/file/index.mjs +39 -0
  221. package/dist/lib/file/index.mjs.map +1 -0
  222. package/dist/lib/file/tryReadFileSync.mjs +14 -0
  223. package/dist/lib/file/tryReadFileSync.mjs.map +1 -0
  224. package/dist/lib/generateIgnoreFiles.mjs +83 -0
  225. package/dist/lib/generateIgnoreFiles.mjs.map +1 -0
  226. package/dist/lib/index.mjs +1562 -0
  227. package/dist/lib/index.mjs.map +1 -0
  228. package/dist/lib/jsonFormatters.mjs +11 -0
  229. package/dist/lib/jsonFormatters.mjs.map +1 -0
  230. package/dist/lib/parsedPackageJSON.mjs +11 -0
  231. package/dist/lib/parsedPackageJSON.mjs.map +1 -0
  232. package/dist/lib/processEx.mjs +36 -0
  233. package/dist/lib/processEx.mjs.map +1 -0
  234. package/dist/lib/runSteps.mjs +96 -0
  235. package/dist/lib/runSteps.mjs.map +1 -0
  236. package/dist/lib/runStepsAsync.mjs +113 -0
  237. package/dist/lib/runStepsAsync.mjs.map +1 -0
  238. package/dist/lib/runXy.mjs +101 -0
  239. package/dist/lib/runXy.mjs.map +1 -0
  240. package/dist/lib/runXyWithWarning.mjs +11 -0
  241. package/dist/lib/runXyWithWarning.mjs.map +1 -0
  242. package/dist/lib/safeExit.mjs +61 -0
  243. package/dist/lib/safeExit.mjs.map +1 -0
  244. package/dist/lib/string/empty.mjs +8 -0
  245. package/dist/lib/string/empty.mjs.map +1 -0
  246. package/dist/lib/string/index.mjs +12 -0
  247. package/dist/lib/string/index.mjs.map +1 -0
  248. package/dist/lib/string/union.mjs +6 -0
  249. package/dist/lib/string/union.mjs.map +1 -0
  250. package/dist/lib/withErrnoException.mjs +13 -0
  251. package/dist/lib/withErrnoException.mjs.map +1 -0
  252. package/dist/lib/withError.mjs +8 -0
  253. package/dist/lib/withError.mjs.map +1 -0
  254. package/dist/lib/xy/index.mjs +1471 -0
  255. package/dist/lib/xy/index.mjs.map +1 -0
  256. package/dist/lib/xy/xy.mjs +1465 -0
  257. package/dist/lib/xy/xy.mjs.map +1 -0
  258. package/dist/lib/xy/xyBuildCommands.mjs +393 -0
  259. package/dist/lib/xy/xyBuildCommands.mjs.map +1 -0
  260. package/dist/lib/xy/xyCommonCommands.mjs +579 -0
  261. package/dist/lib/xy/xyCommonCommands.mjs.map +1 -0
  262. package/dist/lib/xy/xyDeployCommands.mjs +192 -0
  263. package/dist/lib/xy/xyDeployCommands.mjs.map +1 -0
  264. package/dist/lib/xy/xyInstallCommands.mjs +459 -0
  265. package/dist/lib/xy/xyInstallCommands.mjs.map +1 -0
  266. package/dist/lib/xy/xyLintCommands.mjs +334 -0
  267. package/dist/lib/xy/xyLintCommands.mjs.map +1 -0
  268. package/dist/lib/xy/xyParseOptions.mjs +45 -0
  269. package/dist/lib/xy/xyParseOptions.mjs.map +1 -0
  270. package/dist/lib/yarn/index.mjs +49 -0
  271. package/dist/lib/yarn/index.mjs.map +1 -0
  272. package/dist/lib/yarn/isYarnVersionOrGreater.mjs +18 -0
  273. package/dist/lib/yarn/isYarnVersionOrGreater.mjs.map +1 -0
  274. package/dist/lib/yarn/workspace/Workspace.mjs +1 -0
  275. package/dist/lib/yarn/workspace/Workspace.mjs.map +1 -0
  276. package/dist/lib/yarn/workspace/index.mjs +25 -0
  277. package/dist/lib/yarn/workspace/index.mjs.map +1 -0
  278. package/dist/lib/yarn/workspace/yarnWorkspace.mjs +24 -0
  279. package/dist/lib/yarn/workspace/yarnWorkspace.mjs.map +1 -0
  280. package/dist/lib/yarn/workspace/yarnWorkspaces.mjs +16 -0
  281. package/dist/lib/yarn/workspace/yarnWorkspaces.mjs.map +1 -0
  282. package/dist/lib/yarn/yarnInitCwd.mjs +10 -0
  283. package/dist/lib/yarn/yarnInitCwd.mjs.map +1 -0
  284. package/package.json +5 -5
@@ -0,0 +1,1405 @@
1
+ // src/actions/build.ts
2
+ import chalk7 from "chalk";
3
+
4
+ // src/lib/checkResult.ts
5
+ import chalk from "chalk";
6
+ var checkResult = (name, result, level = "error", exitOnFail = false) => {
7
+ if (result) {
8
+ const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
9
+ const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
10
+ console[level](chalkFunc(`${name} had ${result} failures ${exiting}`));
11
+ if (exitOnFail) {
12
+ process.exit(result);
13
+ }
14
+ }
15
+ };
16
+
17
+ // src/lib/dependencies/detectDuplicateDependencies.ts
18
+ import { execSync } from "child_process";
19
+
20
+ // src/lib/processEx.ts
21
+ import chalk2 from "chalk";
22
+
23
+ // src/lib/withError.ts
24
+ var withError = (ex, closure, predicate = (ex2) => ex2.name !== void 0 && ex2.message !== void 0) => {
25
+ return predicate(ex) ? closure(ex) : void 0;
26
+ };
27
+
28
+ // src/lib/withErrnoException.ts
29
+ var withErrnoException = (ex, closure) => {
30
+ return withError(ex, closure, (ex2) => ex2.errno !== void 0);
31
+ };
32
+
33
+ // src/lib/processEx.ts
34
+ var processEx = (ex) => {
35
+ const error = typeof ex === "string" ? Error(ex) : ex;
36
+ const exitCode = withErrnoException(error, (error2) => {
37
+ if (error2.code === "ENOENT") {
38
+ console.error(chalk2.red(`'${error2.path}' not found.`));
39
+ } else {
40
+ console.error(chalk2.red(`Errno: ${error2.code}`));
41
+ }
42
+ return error2.errno ?? -1;
43
+ }) ?? withError(error, (error2) => {
44
+ console.error(chalk2.red(`${error2.name}: ${error2.message}`));
45
+ return -1;
46
+ }) ?? (() => {
47
+ console.error(chalk2.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`));
48
+ return -1;
49
+ })();
50
+ process.exit(process.exitCode ?? exitCode);
51
+ };
52
+
53
+ // src/lib/safeExit.ts
54
+ var safeExit = (func, exitOnFail = true) => {
55
+ try {
56
+ const result = func();
57
+ if (result && exitOnFail) {
58
+ process.exit(result);
59
+ }
60
+ return result;
61
+ } catch (ex) {
62
+ return processEx(ex);
63
+ }
64
+ };
65
+ var safeExitAsync = async (func, exitOnFail = true) => {
66
+ try {
67
+ const result = await func();
68
+ if (result && exitOnFail) {
69
+ process.exit(result);
70
+ }
71
+ return result;
72
+ } catch (ex) {
73
+ return processEx(ex);
74
+ }
75
+ };
76
+
77
+ // src/lib/dependencies/DuplicateDetector.ts
78
+ import chalk3 from "chalk";
79
+ import uniq from "lodash/uniq";
80
+ import { EOL } from "os";
81
+
82
+ // src/lib/jsonFormatters.ts
83
+ var multiLineToJSONArray = (output) => {
84
+ const withCommas = output.replace(/\r\n/g, "").replace(/\n/g, ",");
85
+ const cleanCollection = withCommas.substring(0, withCommas.length - 1);
86
+ const collection = `[${cleanCollection}]`;
87
+ return JSON.parse(collection);
88
+ };
89
+
90
+ // src/lib/dependencies/DuplicateDetector.ts
91
+ var trimVirtualMeta = (value) => {
92
+ const virtualParts = value.split("virtual:");
93
+ if (virtualParts.length > 1) {
94
+ const hashParts = virtualParts[1].split("#");
95
+ return virtualParts[0] + hashParts[1];
96
+ } else {
97
+ return value;
98
+ }
99
+ };
100
+ var trimObjectDependencyVirtualMeta = (obj) => {
101
+ const resultObj = {};
102
+ Object.entries(obj).forEach(([key, value]) => {
103
+ resultObj[trimVirtualMeta(key)] = {
104
+ descriptor: trimVirtualMeta(value.descriptor),
105
+ locator: trimVirtualMeta(value.locator)
106
+ };
107
+ });
108
+ return resultObj;
109
+ };
110
+ var trimDependencyVirtualMeta = (dependencies) => {
111
+ return dependencies.map((dependency) => {
112
+ return { children: trimObjectDependencyVirtualMeta(dependency.children), value: trimVirtualMeta(dependency.value) };
113
+ });
114
+ };
115
+ var DuplicateDetector = class {
116
+ dependency;
117
+ dependencyEntries;
118
+ constructor(output, dependency) {
119
+ this.dependency = dependency;
120
+ this.dependencyEntries = trimDependencyVirtualMeta(multiLineToJSONArray(output));
121
+ }
122
+ detect() {
123
+ const result = this.dependencyEntries.reduce(this.detectReducer, this.resultsFactory(this.dependency));
124
+ if (result.duplicateVersions.length) {
125
+ console.log(chalk3.yellow(`${EOL}Duplicates found for: ${this.dependency}`));
126
+ console.log(chalk3.grey(` ${result.duplicateVersions.toString().replaceAll(",", `${EOL} `)}`, EOL));
127
+ return 1;
128
+ } else {
129
+ console.log(`${this.dependency} - OK`);
130
+ return 0;
131
+ }
132
+ }
133
+ detectReducer(acc, entry) {
134
+ const version = Object.entries(entry.children).map(([k]) => k)[0];
135
+ if (!acc.currentVersion) {
136
+ acc.currentVersion = version;
137
+ return acc;
138
+ }
139
+ if (acc.currentVersion && acc.currentVersion !== version && !version.includes("@virtual:")) {
140
+ if (acc.duplicateVersions.length === 0) {
141
+ acc.duplicateVersions.push(acc.currentVersion);
142
+ }
143
+ acc.duplicateVersions.push(version);
144
+ acc.duplicateVersions = uniq(acc.duplicateVersions);
145
+ }
146
+ return acc;
147
+ }
148
+ resultsFactory = (dependency) => ({ currentVersion: void 0, dependency, duplicateVersions: [] });
149
+ };
150
+
151
+ // src/lib/dependencies/detectDuplicateDependencies.ts
152
+ var detectDuplicateDependencies = (depsFromPackageJSON, DefaultDependencies2) => {
153
+ let exitCode = 0;
154
+ const dependencies = depsFromPackageJSON?.length ? depsFromPackageJSON : DefaultDependencies2;
155
+ return safeExit(() => {
156
+ if (dependencies) {
157
+ dependencies.forEach((dependency) => {
158
+ let output;
159
+ try {
160
+ const cmd = `yarn why ${dependency} --json`;
161
+ output = execSync(cmd).toString();
162
+ } catch (e) {
163
+ console.error(`Error running yarn why: ${e}`);
164
+ exitCode = 1;
165
+ return exitCode;
166
+ }
167
+ if (output) {
168
+ exitCode = new DuplicateDetector(output, dependency).detect();
169
+ return exitCode;
170
+ } else {
171
+ console.log(`${dependency} - N/A`);
172
+ if (depsFromPackageJSON) {
173
+ exitCode = 1;
174
+ console.log(`\u{1F6A8} Library ${dependency} was requested in package.json but not found`);
175
+ }
176
+ return exitCode;
177
+ }
178
+ });
179
+ return exitCode;
180
+ } else {
181
+ console.log("\u{1F6A8} No dependencies where passed");
182
+ return exitCode;
183
+ }
184
+ });
185
+ };
186
+
187
+ // src/lib/file/constants.ts
188
+ var WINDOWS_NEWLINE_REGEX = /\r\n/g;
189
+ var CROSS_PLATFORM_NEWLINE = "\n";
190
+
191
+ // src/lib/file/fileLines.ts
192
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
193
+
194
+ // src/lib/string/empty.ts
195
+ var empty = (value) => value?.trim().length === 0;
196
+ var notEmpty = (value) => !empty(value);
197
+
198
+ // src/lib/string/union.ts
199
+ var union = (a, b) => /* @__PURE__ */ new Set([...new Set(a), ...new Set(b)]);
200
+
201
+ // src/lib/file/ReadFileSyncOptions.ts
202
+ var defaultReadFileSyncOptions = { encoding: "utf-8" };
203
+
204
+ // src/lib/file/fileLines.ts
205
+ var readLines = (uri, options = defaultReadFileSyncOptions) => existsSync(uri) ? readFileSync(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE) : [];
206
+ var readNonEmptyLines = (uri, options = defaultReadFileSyncOptions) => readLines(uri, options).filter(notEmpty);
207
+ var writeLines = (uri, lines, options = defaultReadFileSyncOptions) => {
208
+ const existing = existsSync(uri) ? readFileSync(uri, options) : void 0;
209
+ const desired = lines.join(CROSS_PLATFORM_NEWLINE);
210
+ if (existing !== desired)
211
+ writeFileSync(uri, desired, options);
212
+ };
213
+
214
+ // src/lib/generateIgnoreFiles.ts
215
+ import chalk4 from "chalk";
216
+
217
+ // src/lib/yarn/isYarnVersionOrGreater.ts
218
+ import { spawnSync } from "child_process";
219
+ var isYarnVersionOrGreater = (major, minor, patch) => {
220
+ const result = spawnSync("yarn", ["-v"], { encoding: "utf8", shell: true });
221
+ const version = result.stdout.toString().replaceAll("\n", "");
222
+ const versionNumbers = version.split(".").map((ver) => parseInt(ver));
223
+ const majorDelta = versionNumbers[0] - major;
224
+ const minorDelta = versionNumbers[1] - (minor ?? versionNumbers[1]);
225
+ const patchDelta = versionNumbers[2] - (patch ?? versionNumbers[2]);
226
+ const majorOk = majorDelta >= 0;
227
+ const minorOk = majorDelta > 0 || minorDelta >= 0;
228
+ const patchOk = majorDelta > 0 || minorDelta > 0 || patchDelta >= 0;
229
+ return [majorOk && minorOk && patchOk, version];
230
+ };
231
+
232
+ // src/lib/yarn/workspace/yarnWorkspaces.ts
233
+ import { spawnSync as spawnSync2 } from "child_process";
234
+ var yarnWorkspaces = () => {
235
+ const result = spawnSync2("yarn", ["workspaces", "list", "--json", "--recursive"], { encoding: "utf8", shell: true });
236
+ if (result.error) {
237
+ throw result.error;
238
+ }
239
+ const list = result.stdout.toString().split("\n").slice(0, -1).map((item) => {
240
+ return JSON.parse(item);
241
+ });
242
+ return list;
243
+ };
244
+
245
+ // src/lib/yarn/workspace/yarnWorkspace.ts
246
+ var yarnWorkspace = (pkg) => {
247
+ const workspace = yarnWorkspaces().find(({ name }) => name === pkg);
248
+ if (!workspace)
249
+ throw new Error(`Workspace ${pkg} not found`);
250
+ return workspace;
251
+ };
252
+
253
+ // src/lib/yarn/yarnInitCwd.ts
254
+ var INIT_CWD = () => {
255
+ if (!process.env.INIT_CWD)
256
+ console.error("Missing INIT_CWD");
257
+ return process.env.INIT_CWD;
258
+ };
259
+
260
+ // src/lib/generateIgnoreFiles.ts
261
+ var mergeEntries = (a, b) => [...union(a, b)].sort();
262
+ var generateIgnoreFiles = (filename3, pkg) => {
263
+ console.log(chalk4.green(`Generate ${filename3} Files`));
264
+ const cwd = INIT_CWD() ?? ".";
265
+ const workspaces = pkg ? [yarnWorkspace(pkg)] : yarnWorkspaces();
266
+ const readEntries = (location) => readNonEmptyLines(`${location}/${filename3}`);
267
+ const writeEntries = (location, entries) => writeLines(`${location}/${filename3}`, entries);
268
+ const results = workspaces.map(({ location, name }) => {
269
+ try {
270
+ writeEntries(location, mergeEntries(readEntries(cwd), readEntries(location)));
271
+ return 0;
272
+ } catch (ex) {
273
+ const error = ex;
274
+ console.error(`Generate ${filename3} Files [${name}] [${error.message}]`);
275
+ return 1;
276
+ }
277
+ });
278
+ const succeeded = results.every((result) => result === 0);
279
+ return succeeded ? 0 : 1;
280
+ };
281
+
282
+ // src/lib/parsedPackageJSON.ts
283
+ import { readFileSync as readFileSync2 } from "fs";
284
+ var parsedPackageJSON = (path8) => {
285
+ const pathToPackageJSON = path8 ?? process.env.npm_package_json ?? "";
286
+ const packageJSON = readFileSync2(pathToPackageJSON).toString();
287
+ return JSON.parse(packageJSON);
288
+ };
289
+
290
+ // src/lib/runSteps.ts
291
+ import chalk5 from "chalk";
292
+ import { spawnSync as spawnSync3 } from "child_process";
293
+ import { existsSync as existsSync2 } from "fs";
294
+ var runSteps = (name, steps, exitOnFail = true, messages) => {
295
+ return safeExit(() => {
296
+ const pkgName = process.env.npm_package_name;
297
+ console.log(chalk5.green(`${name} [${pkgName}]`));
298
+ let totalStatus = 0;
299
+ for (let i = 0; i < steps.length; i++) {
300
+ const [command, args, config] = steps[i];
301
+ if (messages?.[i]) {
302
+ console.log(chalk5.gray(messages?.[i]));
303
+ }
304
+ const argList = Array.isArray(args) ? args : args.split(" ");
305
+ if (command === "node" && !existsSync2(argList[0])) {
306
+ throw Error(`File not found [${argList[0]}]`);
307
+ }
308
+ const status = spawnSync3(command, Array.isArray(args) ? args : args.split(" "), {
309
+ ...config,
310
+ encoding: "utf8",
311
+ env: { FORCE_COLOR: "3", ...process.env },
312
+ shell: true,
313
+ stdio: "inherit"
314
+ }).status ?? 0;
315
+ checkResult(name, status, "error", exitOnFail);
316
+ totalStatus += status ?? 0;
317
+ }
318
+ return totalStatus;
319
+ }, !!exitOnFail);
320
+ };
321
+
322
+ // src/lib/runStepsAsync.ts
323
+ import chalk6 from "chalk";
324
+ import { spawn } from "child_process";
325
+ import { existsSync as existsSync3 } from "fs";
326
+ var runStepAsync = (name, step, exitOnFail = true, message) => {
327
+ return new Promise((resolve) => {
328
+ const [command, args, config] = step;
329
+ if (message) {
330
+ console.log(chalk6.gray(message));
331
+ }
332
+ const argList = Array.isArray(args) ? args : args.split(" ");
333
+ if (command === "node" && !existsSync3(argList[0])) {
334
+ throw Error(`File not found [${argList[0]}]`);
335
+ }
336
+ spawn(command, Array.isArray(args) ? args : args.split(" "), {
337
+ ...config,
338
+ env: { FORCE_COLOR: "3", ...process.env },
339
+ shell: true,
340
+ stdio: "inherit"
341
+ }).on("close", (code) => {
342
+ if (code) {
343
+ console.error(
344
+ chalk6.red(
345
+ `Command Exited With Non-Zero Result [${chalk6.gray(code)}] | ${chalk6.yellow(command)} ${chalk6.white(
346
+ Array.isArray(args) ? args.join(" ") : args
347
+ )}`
348
+ )
349
+ );
350
+ checkResult(name, code, "error", exitOnFail);
351
+ resolve(code);
352
+ } else {
353
+ resolve(0);
354
+ }
355
+ });
356
+ });
357
+ };
358
+ var runStepsAsync = async (name, steps, exitOnFail = true, messages) => {
359
+ return await safeExitAsync(async () => {
360
+ const pkgName = process.env.npm_package_name;
361
+ console.log(chalk6.green(`${name} [${pkgName}]`));
362
+ let result = 0;
363
+ for (let i = 0; i < steps.length; i++) {
364
+ result += await runStepAsync(name, steps[i], exitOnFail, messages?.[i]);
365
+ }
366
+ return result;
367
+ });
368
+ };
369
+
370
+ // src/actions/build.ts
371
+ var build = async ({ incremental, jobs, target, verbose, pkg }) => {
372
+ const start = Date.now();
373
+ const pkgOptions = pkg ? [pkg] : [];
374
+ const incrementalOptions = incremental ? ["-i"] : [];
375
+ const verboseOptions = verbose ? ["-v"] : [];
376
+ const targetOptions = target ? ["-t", target] : [];
377
+ const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
378
+ if (jobs) {
379
+ console.log(chalk7.blue(`Jobs set to [${jobs}]`));
380
+ }
381
+ const result = await runStepsAsync(`Build${incremental ? "-Incremental" : ""} [${pkg ?? "All"}]`, [
382
+ ["yarn", ["xy", "compile", ...pkgOptions, ...targetOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],
383
+ ["yarn", ["xy", "lint", ...pkgOptions, ...verboseOptions, ...incrementalOptions]],
384
+ ["yarn", ["xy", "deps", ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]]
385
+ ]);
386
+ console.log(`${chalk7.gray("Built in")} [${chalk7.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk7.gray("seconds")}`);
387
+ return result;
388
+ };
389
+
390
+ // src/actions/clean-docs.ts
391
+ import chalk8 from "chalk";
392
+ import path from "path";
393
+ import { rimrafSync } from "rimraf";
394
+ var cleanDocs = () => {
395
+ const pkgName = process.env.npm_package_name;
396
+ console.log(chalk8.green(`Cleaning Docs [${pkgName}]`));
397
+ yarnWorkspaces().map(({ location }) => rimrafSync(path.join(location, "docs"), { glob: true }));
398
+ return 0;
399
+ };
400
+
401
+ // src/actions/clean-eslint.ts
402
+ import chalk9 from "chalk";
403
+ import path2 from "path";
404
+ import { rimrafSync as rimrafSync2 } from "rimraf";
405
+ var cleanESLint = () => {
406
+ const pkg = process.env.INIT_CWD ?? ".";
407
+ const pkgName = process.env.npm_package_name;
408
+ console.log(chalk9.green(`Cleaning ESLint [${pkgName}]`));
409
+ rimrafSync2(path2.join(pkg, ".eslintcache"), { glob: true });
410
+ return 0;
411
+ };
412
+
413
+ // src/actions/clean-jest.ts
414
+ var cleanJest = () => {
415
+ const pkgName = process.env.npm_package_name;
416
+ return runSteps(`Cleaning Jest [${pkgName}]`, [["jest", ["--clearCache"]]]);
417
+ };
418
+
419
+ // src/actions/clean.ts
420
+ var clean = async ({ verbose, pkg }) => {
421
+ return pkg ? await cleanPackage({ pkg, verbose }) : cleanAll({ verbose });
422
+ };
423
+ var cleanPackage = ({ verbose, pkg }) => {
424
+ const verboseOptions = verbose ? ["-v"] : [];
425
+ return runStepsAsync(`Clean [${pkg}]`, [["yarn", ["workspace", pkg, "run", "package-clean", ...verboseOptions]]]);
426
+ };
427
+ var cleanAll = ({ verbose }) => {
428
+ const verboseOptions = verbose ? ["-v"] : [];
429
+ return cleanJest() + cleanESLint() + cleanDocs() + runSteps("Clean", [["yarn", ["workspaces foreach -pA run package-clean", ...verboseOptions]]]);
430
+ };
431
+
432
+ // src/actions/compile.ts
433
+ import chalk10 from "chalk";
434
+ var compile = ({ verbose, target, pkg, incremental }) => {
435
+ return pkg ? compilePackage({ pkg, target, verbose }) : compileAll({ incremental, target, verbose });
436
+ };
437
+ var compilePackage = ({ verbose, target, pkg }) => {
438
+ const verboseOptions = verbose ? ["-v"] : [];
439
+ const targetOptions = target ? ["-t", target] : [];
440
+ return runSteps(`Compile [${pkg}]`, [["yarn", ["workspace", pkg, "run", "package-compile", ...verboseOptions, ...targetOptions]]]);
441
+ };
442
+ var compileAll = ({ jobs, verbose, target, incremental }) => {
443
+ const start = Date.now();
444
+ const verboseOptions = verbose ? ["-v"] : [];
445
+ const targetOptions = target ? ["-t", target] : [];
446
+ const incrementalOptions = incremental ? ["--since", "-ptA"] : ["-ptA"];
447
+ const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
448
+ if (jobs) {
449
+ console.log(chalk10.blue(`Jobs set to [${jobs}]`));
450
+ }
451
+ const result = runSteps(`Compile${incremental ? "-Incremental" : ""} [All]`, [
452
+ ["yarn", ["workspaces", "foreach", ...incrementalOptions, ...jobsOptions, "run", "package-compile", ...verboseOptions, ...targetOptions]]
453
+ ]);
454
+ console.log(`${chalk10.gray("Compiled in")} [${chalk10.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk10.gray("seconds")}`);
455
+ return result;
456
+ };
457
+
458
+ // src/actions/copy-assets.ts
459
+ import chalk11 from "chalk";
460
+ import cpy from "cpy";
461
+ import path3 from "path/posix";
462
+ var copyPackageTargetAssets = async (target, name, location) => {
463
+ try {
464
+ const values = await cpy(
465
+ ["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
466
+ `../dist/${target}`,
467
+ {
468
+ cwd: path3.join(process.cwd(), location, "src"),
469
+ parents: true
470
+ }
471
+ );
472
+ values.forEach((value) => {
473
+ console.log(`${value.split("/").pop()} => ./dist/${target}`);
474
+ });
475
+ return 0;
476
+ } catch (reason) {
477
+ console.log(`Copy Failed: ${name}: ${reason}`);
478
+ return 1;
479
+ }
480
+ };
481
+ var copyTargetAssets = async (target, pkg) => {
482
+ const workspaces = yarnWorkspaces();
483
+ console.log(chalk11.green(`Copying Assets [${target.toUpperCase()}]`));
484
+ const workspaceList = workspaces.filter(({ name }) => {
485
+ return pkg === void 0 || name === pkg;
486
+ });
487
+ if (workspaceList.length === 0) {
488
+ console.error(`Package not found [${pkg}]`);
489
+ } else {
490
+ const results = await Promise.all(
491
+ workspaceList.map(async (workspace) => {
492
+ const { location, name } = workspace;
493
+ return await copyPackageTargetAssets(target, name, location);
494
+ })
495
+ );
496
+ return results.reduce((prev, result) => prev || result, 0);
497
+ }
498
+ return 0;
499
+ };
500
+ var copyAssets = async ({ target, pkg }) => {
501
+ switch (target) {
502
+ case "esm":
503
+ return await copyTargetAssets("esm", pkg);
504
+ case "cjs":
505
+ return await copyTargetAssets("cjs", pkg);
506
+ default:
507
+ return await copyTargetAssets("esm", pkg) || await copyTargetAssets("cjs", pkg);
508
+ }
509
+ };
510
+
511
+ // src/actions/cycle.ts
512
+ var cycle = () => {
513
+ const rules = [`"'import/no-cycle': [1, { maxDepth: 6 }]"`, `"'import/no-internal-modules': ['off']"`];
514
+ return runSteps("Cycle", [["yarn", ["eslint", ...rules.map((rule) => ["--rule", rule]).flat(), "--cache", "."]]]);
515
+ };
516
+
517
+ // src/actions/dead.ts
518
+ var dead = () => {
519
+ return runSteps("Dead", [["yarn", ["ts-prune", "-p", "tsconfig.json"]]]);
520
+ };
521
+
522
+ // src/actions/deploy.ts
523
+ var deploy = () => {
524
+ return runSteps("Deploy [Patch]", [
525
+ ["yarn", "workspaces foreach --all version patch --deferred"],
526
+ ["yarn", "xy clean"],
527
+ ["yarn", "xy build"],
528
+ ["yarn", "xy cycle"],
529
+ ["yarn", "xy gen-docs"],
530
+ ["yarn", "version apply --all"],
531
+ ["yarn", "workspaces foreach -pt npm publish"]
532
+ ]);
533
+ };
534
+
535
+ // src/actions/deploy-major.ts
536
+ var deployMajor = () => {
537
+ return runSteps("Deploy [Major]", [
538
+ ["yarn", "workspaces foreach --all version major --deferred"],
539
+ ["yarn", "xy clean"],
540
+ ["yarn", "xy build"],
541
+ ["yarn", "xy cycle"],
542
+ ["yarn", "version apply --all"],
543
+ ["yarn", "workspaces foreach -pt npm publish"]
544
+ ]);
545
+ };
546
+
547
+ // src/actions/deploy-minor.ts
548
+ var deployMinor = () => {
549
+ return runSteps("Deploy [Minor]", [
550
+ ["yarn", "workspaces foreach --all version minor --deferred"],
551
+ ["yarn", "xy clean"],
552
+ ["yarn", "xy build"],
553
+ ["yarn", "xy cycle"],
554
+ ["yarn", "version apply --all"],
555
+ ["yarn", "workspaces foreach -pt npm publish"]
556
+ ]);
557
+ };
558
+
559
+ // src/actions/deploy-next.ts
560
+ var deployNext = () => {
561
+ return runSteps("Deploy [Next]", [
562
+ ["yarn", "workspaces foreach --all version minor --deferred"],
563
+ ["yarn", "xy clean"],
564
+ ["yarn", "xy build"],
565
+ ["yarn", "xy cycle"],
566
+ ["yarn", "version apply --all --prerelease"],
567
+ ["yarn", "workspaces foreach -pt npm publish --tag next"]
568
+ ]);
569
+ };
570
+
571
+ // src/actions/deps.ts
572
+ import chalk12 from "chalk";
573
+ var deps = ({ pkg, incremental }) => {
574
+ pkg ? depsPackage({ pkg }) : depsAll({ incremental });
575
+ return 0;
576
+ };
577
+ var depsPackage = ({ pkg }) => {
578
+ const steps = [["yarn", ["workspace", pkg, "run", "package-deps"]]];
579
+ return runSteps(`Deps [${pkg}]`, [...steps]);
580
+ };
581
+ var depsAll = ({ incremental, jobs }) => {
582
+ const start = Date.now();
583
+ const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
584
+ if (jobs) {
585
+ console.log(chalk12.blue(`Jobs set to [${jobs}]`));
586
+ }
587
+ const incrementalOptions = incremental ? ["--since", "-pA"] : ["-pA"];
588
+ const steps = [["yarn", ["workspaces", "foreach", ...jobsOptions, ...incrementalOptions, "run", "package-deps"]]];
589
+ const result = runSteps(`Deps${incremental ? "-Incremental" : ""} [All]`, [...steps]);
590
+ console.log(`${chalk12.gray("Dep checked in")} [${chalk12.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk12.gray("seconds")}`);
591
+ return result;
592
+ };
593
+
594
+ // src/actions/dupdeps.ts
595
+ import chalk13 from "chalk";
596
+ var dupdeps = () => {
597
+ console.log(chalk13.green("Checking all Dependencies for Duplicates"));
598
+ const allDependencies = parsedPackageJSON()?.dependencies;
599
+ const dependencies = Object.entries(allDependencies).map(([k]) => k);
600
+ return detectDuplicateDependencies(dependencies);
601
+ };
602
+
603
+ // src/actions/fix.ts
604
+ var fix = () => {
605
+ return runSteps("Fix", [["yarn", ["eslint", ".", "--fix", "--cache"]]]);
606
+ };
607
+
608
+ // src/actions/gen-docs.ts
609
+ var genDocs = ({ pkg, incremental }) => {
610
+ return pkg ? genDocsPackage({ pkg }) : genDocsAll({ incremental });
611
+ };
612
+ var genDocsPackage = ({ pkg }) => {
613
+ const steps = [["yarn", ["workspace", pkg, "run", "package-gen-docs"]]];
614
+ return runSteps(`GenDocs [${pkg}]`, [...steps]);
615
+ };
616
+ var genDocsAll = ({ incremental }) => {
617
+ const incrementalOptions = incremental ? ["--since", "-pA"] : ["-pA"];
618
+ const steps = [["yarn", ["workspaces", "foreach", ...incrementalOptions, "run", "package-gen-docs"]]];
619
+ return runSteps(`GenDocs [All${incremental ? "-Incremental" : ""}]`, [...steps]);
620
+ };
621
+
622
+ // src/actions/gitignore-gen.ts
623
+ var filename = ".gitignore";
624
+ var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
625
+
626
+ // src/actions/gitlint.ts
627
+ import chalk14 from "chalk";
628
+ import { sync } from "parse-git-config";
629
+ var gitlint = () => {
630
+ console.log(`
631
+ Gitlint Start [${process.cwd()}]
632
+ `);
633
+ let valid = 0;
634
+ let warnings = 0;
635
+ const errors = 0;
636
+ const gitConfig = sync();
637
+ const warn = (message) => {
638
+ console.warn(chalk14.yellow(`Warning: ${message}`));
639
+ warnings++;
640
+ };
641
+ if (gitConfig.core.ignorecase) {
642
+ warn("Please set core.ignorecase to FALSE in .git/config file [run yarn gitlint-fix]");
643
+ } else {
644
+ valid++;
645
+ }
646
+ if (gitConfig.core.autocrlf !== false) {
647
+ warn("Please set core.autocrlf to FALSE in .git/config file [run yarn gitlint-fix]");
648
+ } else {
649
+ valid++;
650
+ }
651
+ if (gitConfig.core.eol !== "lf") {
652
+ warn('Please set core.eol to "lf" in .git/config file [run yarn gitlint-fix]');
653
+ } else {
654
+ valid++;
655
+ }
656
+ const resultMessages = [];
657
+ if (valid > 0) {
658
+ resultMessages.push(chalk14.green(`Passed: ${valid}`));
659
+ }
660
+ if (warnings > 0) {
661
+ resultMessages.push(chalk14.yellow(`Warnings: ${warnings}`));
662
+ }
663
+ if (errors > 0) {
664
+ resultMessages.push(chalk14.red(` Errors: ${errors}`));
665
+ }
666
+ console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
667
+ `);
668
+ return warnings + errors === 0 ? 1 : 0;
669
+ };
670
+
671
+ // src/actions/gitlint-fix.ts
672
+ import chalk15 from "chalk";
673
+ import { execSync as execSync2 } from "child_process";
674
+ import { sync as sync2 } from "parse-git-config";
675
+ var gitlintFix = () => {
676
+ console.log(`
677
+ Gitlint Fix Start [${process.cwd()}]
678
+ `);
679
+ const gitConfig = sync2();
680
+ if (gitConfig.core.ignorecase) {
681
+ execSync2("git config core.ignorecase false", { stdio: "inherit" });
682
+ console.warn(chalk15.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
683
+ }
684
+ if (gitConfig.core.autocrlf !== false) {
685
+ execSync2("git config core.autocrlf false", { stdio: "inherit" });
686
+ console.warn(chalk15.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
687
+ }
688
+ if (gitConfig.core.eol !== "lf") {
689
+ execSync2("git config core.eol lf", { stdio: "inherit" });
690
+ console.warn(chalk15.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
691
+ }
692
+ return 1;
693
+ };
694
+
695
+ // src/actions/license.ts
696
+ import chalk16 from "chalk";
697
+ import { init } from "license-checker";
698
+ var license = async (pkg) => {
699
+ const workspaces = yarnWorkspaces();
700
+ const workspaceList = workspaces.filter(({ name }) => {
701
+ return pkg === void 0 || name === pkg;
702
+ });
703
+ const exclude = [
704
+ "MIT",
705
+ "MIT*",
706
+ "ISC",
707
+ "Apache-2.0",
708
+ "BSD",
709
+ "BSD*",
710
+ "BSD-2-Clause",
711
+ "BSD-3-Clause",
712
+ "CC-BY-4.0",
713
+ "Unlicense",
714
+ "CC-BY-3.0",
715
+ "CC0-1.0",
716
+ "LGPL-3.0-only",
717
+ "LGPL-3.0",
718
+ "LGPL-3.0-or-later",
719
+ "Python-2.0"
720
+ ];
721
+ console.log(chalk16.green("License Checker"));
722
+ return (await Promise.all(
723
+ workspaceList.map(({ location, name }) => {
724
+ return new Promise((resolve) => {
725
+ init({ production: true, start: location }, (error, packages) => {
726
+ if (error) {
727
+ console.error(chalk16.red(`License Checker [${name}] Error`));
728
+ console.error(chalk16.gray(error));
729
+ console.log("\n");
730
+ resolve(1);
731
+ } else {
732
+ console.log(chalk16.green(`License Checker [${name}]`));
733
+ let count = 0;
734
+ Object.entries(packages).forEach(([name2, info]) => {
735
+ const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
736
+ licenses.forEach((license2) => {
737
+ if (license2) {
738
+ if (license2[0] === "(" && license2[license2.length - 1] === ")") {
739
+ license2 = license2.substring(1, license2.length - 2);
740
+ }
741
+ const orLicenses = license2.split(" OR ");
742
+ let orLicenseFound = false;
743
+ orLicenses.forEach((orLicense) => {
744
+ if (exclude.includes(orLicense)) {
745
+ orLicenseFound = true;
746
+ }
747
+ });
748
+ if (!orLicenseFound) {
749
+ count++;
750
+ console.warn(chalk16.yellow(`${name2}: Package License not allowed [${license2}]`));
751
+ }
752
+ }
753
+ });
754
+ });
755
+ console.log("\n");
756
+ resolve(count);
757
+ }
758
+ });
759
+ });
760
+ })
761
+ )).reduce((prev, value) => prev || value, 0);
762
+ };
763
+
764
+ // src/actions/lint.ts
765
+ import chalk17 from "chalk";
766
+ import { ESLint } from "eslint";
767
+ var lintPackage = async ({ pkg }) => {
768
+ const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
769
+ if (!workspace) {
770
+ console.error(chalk17.red(`Unable to locate package [${chalk17.magenta(pkg)}]`));
771
+ process.exit(1);
772
+ }
773
+ const engine = new ESLint({ cache: true });
774
+ const lintResults = await engine.lintFiles(workspace.location);
775
+ console.log(lintResults);
776
+ const errorCount = lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
777
+ return errorCount;
778
+ };
779
+ var lintAll = async () => {
780
+ const engine = new ESLint({ cache: true });
781
+ const lintResults = await engine.lintFiles("./**/*.*");
782
+ console.log(lintResults);
783
+ const errorCount = lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
784
+ return errorCount;
785
+ };
786
+ var lint = async ({ pkg } = {}) => {
787
+ return pkg ? await lintPackage({ pkg }) : runSteps("Lint-Caching [All]", [["yarn", ["eslint", ".", "--cache"]]]);
788
+ };
789
+
790
+ // src/actions/lint-clean.ts
791
+ import { rmSync } from "fs";
792
+ var lintClean = () => {
793
+ console.log("Lint Clean [.eslintcache]");
794
+ const workspaces = yarnWorkspaces();
795
+ const result = workspaces.map(({ location, name }) => {
796
+ const dist = `${location}/.eslintcache`;
797
+ try {
798
+ rmSync(dist, { force: true, recursive: true });
799
+ return 0;
800
+ } catch (ex) {
801
+ const error = ex;
802
+ console.error(`Lint Clean [.eslintcache] Failed [${name}, ${error.message}]`);
803
+ return 1;
804
+ }
805
+ }).reduce((prev, result2) => prev || result2, 0);
806
+ return result || lint();
807
+ };
808
+
809
+ // src/actions/lint-profile.ts
810
+ var lintProfile = () => {
811
+ return runSteps("Lint Profile", [["yarn", ["xy", "lint"], { env: { ...process.env, TIMING: "1" } }]]);
812
+ };
813
+
814
+ // src/actions/npmignore-gen.ts
815
+ var filename2 = ".npmignore";
816
+ var npmignoreGen = (pkg) => generateIgnoreFiles(filename2, pkg);
817
+
818
+ // src/actions/package/clean-outputs.ts
819
+ import chalk18 from "chalk";
820
+ import { rmSync as rmSync2 } from "fs";
821
+ import path4 from "path";
822
+ var packageCleanOutputs = () => {
823
+ const pkg = process.env.INIT_CWD ?? ".";
824
+ const pkgName = process.env.npm_package_name;
825
+ console.log(chalk18.green(`Cleaning Outputs [${pkgName}]`));
826
+ const dist = path4.join(pkg, "dist");
827
+ rmSync2(dist, { force: true, recursive: true });
828
+ const build3 = path4.join(pkg, "build");
829
+ rmSync2(build3, { force: true, recursive: true });
830
+ return 0;
831
+ };
832
+
833
+ // src/actions/package/clean-typescript.ts
834
+ import chalk19 from "chalk";
835
+ import path5 from "path";
836
+ import { rimrafSync as rimrafSync3 } from "rimraf";
837
+ var packageCleanTypescript = () => {
838
+ const pkg = process.env.INIT_CWD ?? ".";
839
+ const pkgName = process.env.npm_package_name;
840
+ console.log(chalk19.green(`Cleaning Typescript [${pkgName}]`));
841
+ const buildInfo = path5.join(pkg, "*.tsbuildinfo");
842
+ rimrafSync3(buildInfo, { glob: true });
843
+ const tsConfig = path5.join(pkg, ".tsconfig.*");
844
+ rimrafSync3(tsConfig, { glob: true });
845
+ return 0;
846
+ };
847
+
848
+ // src/actions/package/clean.ts
849
+ var packageClean = () => {
850
+ return packageCleanOutputs() + packageCleanTypescript();
851
+ };
852
+
853
+ // src/actions/package/compile.ts
854
+ import commonjs from "@rollup/plugin-commonjs";
855
+ import typescript from "@rollup/plugin-typescript";
856
+ import { copyFile } from "fs/promises";
857
+ import { rollup } from "rollup";
858
+ import externalDeps from "rollup-plugin-exclude-dependencies-from-bundle";
859
+ var buildIt = async () => {
860
+ await (await rollup({
861
+ input: "src/index.ts",
862
+ logLevel: "debug",
863
+ perf: true,
864
+ plugins: [
865
+ commonjs(),
866
+ externalDeps(),
867
+ typescript({
868
+ declaration: true,
869
+ declarationMap: true,
870
+ emitDeclarationOnly: false,
871
+ exclude: ["src/**/*.spec.*", "dist", "docs"],
872
+ outDir: "dist",
873
+ rootDir: "src",
874
+ tsconfig: "tsconfig.json"
875
+ })
876
+ ]
877
+ })).write({
878
+ dir: "dist",
879
+ entryFileNames: (chunkInfo) => `${chunkInfo.name}.mjs`,
880
+ format: "esm",
881
+ sourcemap: true
882
+ });
883
+ await (await rollup({
884
+ input: "src/index.ts",
885
+ logLevel: "warn",
886
+ perf: true,
887
+ plugins: [
888
+ externalDeps(),
889
+ typescript({
890
+ declaration: true,
891
+ declarationMap: true,
892
+ emitDeclarationOnly: false,
893
+ exclude: ["src/**/*.spec.*", "dist", "docs"],
894
+ outDir: "dist",
895
+ rootDir: "src",
896
+ tsconfig: "tsconfig.json"
897
+ })
898
+ ]
899
+ })).write({
900
+ dir: "dist",
901
+ entryFileNames: (chunkInfo) => `${chunkInfo.name}.js`,
902
+ format: "cjs",
903
+ sourcemap: true
904
+ });
905
+ await copyFile("./dist/index.d.ts", "./dist/index.d.mts");
906
+ await copyFile("./dist/index.d.ts.map", "./dist/index.d.mts.map");
907
+ return 0;
908
+ };
909
+ var packageCompile = async () => {
910
+ return await buildIt();
911
+ };
912
+
913
+ // src/actions/package/copy-assets.ts
914
+ import chalk20 from "chalk";
915
+ import cpy2 from "cpy";
916
+ import path6 from "path/posix";
917
+ var copyTargetAssets2 = async (target, name, location) => {
918
+ try {
919
+ const values = await cpy2(
920
+ ["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
921
+ `../dist/${target}`,
922
+ {
923
+ cwd: path6.join(location, "src"),
924
+ parents: true
925
+ }
926
+ );
927
+ if (values.length > 0) {
928
+ console.log(chalk20.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
929
+ }
930
+ values.forEach((value) => {
931
+ console.log(`${value.split("/").pop()} => ./dist/${target}`);
932
+ });
933
+ return 0;
934
+ } catch (ex) {
935
+ const error = ex;
936
+ console.log(`Copy Assets Failed: ${name}: ${error.message}`);
937
+ return 1;
938
+ }
939
+ };
940
+ var packageCopyAssets = async ({ target }) => {
941
+ const pkg = process.env.INIT_CWD ?? "./";
942
+ const pkgName = process.env.npm_package_name ?? "Unknown";
943
+ switch (target) {
944
+ case "esm":
945
+ return await copyTargetAssets2("esm", pkgName, pkg);
946
+ case "cjs":
947
+ return await copyTargetAssets2("cjs", pkgName, pkg);
948
+ default:
949
+ return await copyTargetAssets2("esm", pkgName, pkg) || await copyTargetAssets2("cjs", pkgName, pkg);
950
+ }
951
+ };
952
+
953
+ // src/actions/package/deps.ts
954
+ import chalk21 from "chalk";
955
+ import depcheck, { special } from "depcheck";
956
+ import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
957
+ var packageDeps = async () => {
958
+ const pkg = process.env.INIT_CWD;
959
+ const pkgName = process.env.npm_package_name;
960
+ const rawIgnore = existsSync4(`${pkg}/.depcheckrc`) ? readFileSync3(`${pkg}/.depcheckrc`, { encoding: "utf8" }).replace("ignores:", '"ignores":') : void 0;
961
+ let ignoreMatches = [];
962
+ try {
963
+ ignoreMatches = rawIgnore ? JSON.parse(`{${rawIgnore}}`).ignores : [];
964
+ } catch (ex) {
965
+ const error = ex;
966
+ console.log(`${pkgName} [${error.message}] Failed to parse .depcheckrc [${rawIgnore}]`);
967
+ }
968
+ ignoreMatches.push("@xylabs/ts-scripts-yarn3");
969
+ ignoreMatches.push("@xylabs/tsconfig");
970
+ ignoreMatches.push("@xylabs/tsconfig-dom");
971
+ ignoreMatches.push("@xylabs/tsconfig-react");
972
+ ignoreMatches.push("@xylabs/tsconfig-jest");
973
+ ignoreMatches.push("typescript");
974
+ const unusedList = await Promise.all([
975
+ depcheck(`${pkg}/.`, { ignoreMatches, ignorePatterns: ["*.stories.*", "*.spec.*", "*.d.ts", "dist", ".*"] }),
976
+ depcheck(`${pkg}/.`, {
977
+ ignoreMatches,
978
+ ignorePatterns: ["*.ts", "*.d.ts", "dist", ".*"],
979
+ specials: [special.eslint, special.babel, special.bin, special.prettier, special.jest, special.mocha]
980
+ })
981
+ ]);
982
+ const unusedCode = unusedList[0];
983
+ const unusedTests = unusedList[1];
984
+ const unused = {
985
+ ...unusedCode,
986
+ /* we only reports the unused devDeps if both are not using it */
987
+ devDependencies: unusedTests.devDependencies.filter((value) => !!unusedCode.devDependencies.find((devValue) => devValue === value))
988
+ };
989
+ const errorCount = unused.dependencies.length + unused.devDependencies.length + Object.entries(unused.invalidDirs).length + Object.entries(unused.invalidFiles).length + Object.entries(unused.missing).length;
990
+ if (errorCount > 0) {
991
+ console.log(`Deps [${pkgName}]`);
992
+ } else {
993
+ console.log(`Deps [${pkgName}] - Ok`);
994
+ }
995
+ if (unused.dependencies.length) {
996
+ const message = [chalk21.yellow(`${unused.dependencies.length} Unused dependencies`)];
997
+ unused.dependencies.forEach((value) => message.push(chalk21.gray(` ${value}`)));
998
+ console.log(message.join("\n"));
999
+ }
1000
+ if (unused.devDependencies.length) {
1001
+ const message = [chalk21.yellow(`${unused.devDependencies.length} Unused devDependencies`)];
1002
+ unused.devDependencies.forEach((value) => message.push(chalk21.gray(` ${value}`)));
1003
+ console.log(message.join("\n"));
1004
+ }
1005
+ if (Object.entries(unused.invalidDirs).length) {
1006
+ Object.entries(unused.invalidDirs).forEach(([key, value]) => console.warn(chalk21.gray(`Invalid Dir: ${key}: ${value}`)));
1007
+ }
1008
+ if (Object.entries(unused.invalidFiles).length) {
1009
+ Object.entries(unused.invalidFiles).forEach(([key, value]) => console.warn(chalk21.gray(`Invalid File: ${key}: ${value}`)));
1010
+ }
1011
+ if (Object.entries(unusedCode.missing).length) {
1012
+ const message = [chalk21.yellow(`${Object.entries(unusedCode.missing).length} Missing dependencies`)];
1013
+ Object.entries(unusedCode.missing).forEach(([key, value]) => {
1014
+ message.push(`${key}`);
1015
+ message.push(chalk21.gray(` ${value.pop()}`));
1016
+ });
1017
+ console.log(chalk21.yellow(message.join("\n")));
1018
+ }
1019
+ if (Object.entries(unusedTests.missing).length) {
1020
+ const message = [chalk21.yellow(`${Object.entries(unusedTests.missing).length} Missing devDependencies`)];
1021
+ Object.entries(unusedTests.missing).forEach(([key, value]) => {
1022
+ message.push(`${key}`);
1023
+ message.push(chalk21.gray(` ${value.pop()}`));
1024
+ });
1025
+ console.log(chalk21.yellow(message.join("\n")));
1026
+ }
1027
+ checkResult(`Deps [${pkgName}]`, errorCount, "warn", false);
1028
+ return 0;
1029
+ };
1030
+
1031
+ // src/actions/package/gen-docs.ts
1032
+ import { existsSync as existsSync5 } from "node:fs";
1033
+ import path7 from "node:path";
1034
+ import chalk22 from "chalk";
1035
+ import { Application, ArgumentsReader, TSConfigReader, TypeDocReader } from "typedoc";
1036
+ var ExitCodes = {
1037
+ CompileError: 3,
1038
+ ExceptionThrown: 6,
1039
+ NoEntryPoints: 2,
1040
+ Ok: 0,
1041
+ OptionError: 1,
1042
+ OutputError: 5,
1043
+ ValidationError: 4
1044
+ };
1045
+ var packageGenDocs = async () => {
1046
+ const pkg = process.env.INIT_CWD;
1047
+ if (pkg) {
1048
+ if (!existsSync5(path7.join(pkg, "typedoc.json"))) {
1049
+ return;
1050
+ }
1051
+ }
1052
+ const app = new Application();
1053
+ app.options.addReader(new ArgumentsReader(0));
1054
+ app.options.addReader(new TypeDocReader());
1055
+ app.options.addReader(new TSConfigReader());
1056
+ app.options.addReader(new ArgumentsReader(300));
1057
+ app.bootstrap({
1058
+ entryPointStrategy: "resolve",
1059
+ entryPoints: [`${pkg}/src`],
1060
+ excludeExternals: true,
1061
+ json: `${pkg}/dist/docs.json`,
1062
+ logLevel: "Error",
1063
+ tsconfig: `${pkg}/tsconfig.json`
1064
+ });
1065
+ return await runTypeDoc(app);
1066
+ };
1067
+ var runTypeDoc = async (app) => {
1068
+ const pkgName = process.env.npm_package_name;
1069
+ if (app.options.getValue("version")) {
1070
+ console.log(app.toString());
1071
+ return ExitCodes.Ok;
1072
+ }
1073
+ if (app.options.getValue("showConfig")) {
1074
+ console.log(app.options.getRawValues());
1075
+ return ExitCodes.Ok;
1076
+ }
1077
+ if (app.logger.hasErrors()) {
1078
+ return ExitCodes.OptionError;
1079
+ }
1080
+ if (app.options.getValue("treatWarningsAsErrors") && app.logger.hasWarnings()) {
1081
+ return ExitCodes.OptionError;
1082
+ }
1083
+ if (app.options.getValue("entryPoints").length === 0) {
1084
+ app.logger.error("No entry points provided");
1085
+ return ExitCodes.NoEntryPoints;
1086
+ }
1087
+ if (app.options.getValue("watch")) {
1088
+ app.convertAndWatch(async (project2) => {
1089
+ const out = app.options.getValue("out");
1090
+ if (out) {
1091
+ await app.generateDocs(project2, out);
1092
+ }
1093
+ const json = app.options.getValue("json");
1094
+ if (json) {
1095
+ await app.generateJson(project2, json);
1096
+ }
1097
+ if (!out && !json) {
1098
+ await app.generateDocs(project2, "./docs");
1099
+ }
1100
+ });
1101
+ return ExitCodes.Ok;
1102
+ }
1103
+ const project = app.convert();
1104
+ if (!project) {
1105
+ return ExitCodes.CompileError;
1106
+ }
1107
+ if (app.options.getValue("treatWarningsAsErrors") && app.logger.hasWarnings()) {
1108
+ return ExitCodes.CompileError;
1109
+ }
1110
+ app.validate(project);
1111
+ if (app.logger.hasErrors()) {
1112
+ return ExitCodes.ValidationError;
1113
+ }
1114
+ if (app.options.getValue("treatWarningsAsErrors") && app.logger.hasWarnings()) {
1115
+ return ExitCodes.ValidationError;
1116
+ }
1117
+ if (app.options.getValue("emit") !== "none") {
1118
+ const out = app.options.getValue("out");
1119
+ if (out) {
1120
+ await app.generateDocs(project, out);
1121
+ }
1122
+ const json = app.options.getValue("json");
1123
+ if (json) {
1124
+ await app.generateJson(project, json);
1125
+ }
1126
+ if (!out && !json) {
1127
+ await app.generateDocs(project, "./docs");
1128
+ }
1129
+ if (app.logger.hasErrors()) {
1130
+ return ExitCodes.OutputError;
1131
+ }
1132
+ if (app.options.getValue("treatWarningsAsErrors") && app.logger.hasWarnings()) {
1133
+ return ExitCodes.OutputError;
1134
+ }
1135
+ }
1136
+ console.log(chalk22.green(`${pkgName} - Ok`));
1137
+ return ExitCodes.Ok;
1138
+ };
1139
+
1140
+ // src/actions/package/publint.ts
1141
+ import { promises as fs } from "fs";
1142
+ var packagePublint = async () => {
1143
+ const pkgDir = process.env.INIT_CWD;
1144
+ const pkg = JSON.parse(await fs.readFile(`${pkgDir}/package.json`, "utf8"));
1145
+ const { publint: publint2 } = await import("publint");
1146
+ const { messages } = await publint2({
1147
+ level: "warning",
1148
+ pkgDir,
1149
+ strict: true
1150
+ });
1151
+ const { formatMessage } = await import("publint/utils");
1152
+ messages.forEach((message) => {
1153
+ console.log(formatMessage(message, pkg));
1154
+ });
1155
+ return messages.length;
1156
+ };
1157
+
1158
+ // src/actions/package/recompile.ts
1159
+ var packageRecompile = async () => {
1160
+ return (await Promise.all([packageClean(), packageCompile()])).reduce((prev, value) => prev + value, 0);
1161
+ };
1162
+
1163
+ // src/actions/package/tsup.ts
1164
+ import merge from "lodash/merge";
1165
+ import { build as build2, defineConfig } from "tsup";
1166
+ var packageTsup = async () => {
1167
+ const options = defineConfig((options2) => {
1168
+ return merge(
1169
+ {},
1170
+ {
1171
+ bundle: true,
1172
+ cjsInterop: true,
1173
+ clean: false,
1174
+ dts: {
1175
+ entry: ["src/index.ts"]
1176
+ },
1177
+ entry: ["src/index.ts"],
1178
+ format: ["cjs", "esm"],
1179
+ sourcemap: true,
1180
+ splitting: false,
1181
+ tsconfig: "tsconfig.json"
1182
+ },
1183
+ options2
1184
+ );
1185
+ });
1186
+ console.log(`Options: ${JSON.stringify(options)}`);
1187
+ await build2(options);
1188
+ return 0;
1189
+ };
1190
+
1191
+ // src/actions/publint.ts
1192
+ var publint = async ({ verbose, pkg }) => {
1193
+ return pkg ? await publintPackage({ pkg, verbose }) : publintAll({ verbose });
1194
+ };
1195
+ var publintPackage = ({ verbose, pkg }) => {
1196
+ const verboseOptions = verbose ? ["-v"] : [];
1197
+ return runStepsAsync(`Publint [${pkg}]`, [["yarn", ["workspace", pkg, "run", "package-publint", ...verboseOptions]]]);
1198
+ };
1199
+ var publintAll = ({ verbose }) => {
1200
+ const verboseOptions = verbose ? ["-v"] : [];
1201
+ return runSteps("Publint", [["yarn", ["workspaces foreach -pA run package-publint", ...verboseOptions]]]);
1202
+ };
1203
+
1204
+ // src/actions/rebuild.ts
1205
+ var rebuild = ({ target }) => {
1206
+ return runSteps("Rebuild", [
1207
+ ["yarn", "xy clean"],
1208
+ ["yarn", target ? `xy build -t ${target}` : "xy build"]
1209
+ ]);
1210
+ };
1211
+
1212
+ // src/actions/recompile.ts
1213
+ import chalk23 from "chalk";
1214
+ var recompile = async ({ verbose, target, pkg, incremental }) => {
1215
+ return pkg ? await recompilePackage({ pkg, target, verbose }) : await recompileAll({ incremental, target, verbose });
1216
+ };
1217
+ var recompilePackage = ({ verbose, target, pkg }) => {
1218
+ const verboseOptions = verbose ? ["-v"] : [];
1219
+ const targetOptions = target ? ["-t", target] : [];
1220
+ return runStepsAsync(`Recompile [${pkg}]`, [["yarn", ["workspace", pkg, "run", "package-recompile", ...verboseOptions, ...targetOptions]]]);
1221
+ };
1222
+ var recompileAll = async ({ jobs, verbose, target, incremental }) => {
1223
+ const start = Date.now();
1224
+ const verboseOptions = verbose ? ["-v"] : [];
1225
+ const targetOptions = target ? ["-t", target] : [];
1226
+ const incrementalOptions = incremental ? ["--since", "-ptA"] : ["-ptA"];
1227
+ const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
1228
+ if (jobs) {
1229
+ console.log(chalk23.blue(`Jobs set to [${jobs}]`));
1230
+ }
1231
+ const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
1232
+ ["yarn", ["workspaces", "foreach", ...incrementalOptions, ...jobsOptions, "run", "package-recompile", ...verboseOptions, ...targetOptions]]
1233
+ ]);
1234
+ console.log(`${chalk23.gray("Recompiled in")} [${chalk23.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk23.gray("seconds")}`);
1235
+ return result;
1236
+ };
1237
+
1238
+ // src/actions/reinstall.ts
1239
+ import { closeSync, openSync, rmSync as rmSync3 } from "fs";
1240
+ var reinstall = () => {
1241
+ console.log("Reinstall [Clear Lock File]");
1242
+ closeSync(openSync("./yarn.lock", "w"));
1243
+ console.log("Reinstall [Clear Node Modules]");
1244
+ const workspaces = yarnWorkspaces();
1245
+ const result = workspaces.map(({ location, name }) => {
1246
+ const dist = `${location}/node_modules`;
1247
+ try {
1248
+ rmSync3(dist, { force: true, recursive: true });
1249
+ return 0;
1250
+ } catch (ex) {
1251
+ const error = ex;
1252
+ console.error(`Reinstall [Clear Node Modules] Failed [${name}, ${error.message}]`);
1253
+ return 1;
1254
+ }
1255
+ }).reduce((prev, result2) => prev || result2, 0);
1256
+ return result || runSteps("Reinstall", [["yarn", "install --network-timeout 10000"]]);
1257
+ };
1258
+
1259
+ // src/actions/relint.ts
1260
+ import { rmSync as rmSync4 } from "fs";
1261
+ var relint = () => {
1262
+ console.log("Relint - Cleaning [.eslintcache]");
1263
+ const workspaces = yarnWorkspaces();
1264
+ const result = workspaces.map(({ location, name }) => {
1265
+ const dist = `${location}/.eslintcache`;
1266
+ try {
1267
+ rmSync4(dist, { force: true, recursive: true });
1268
+ return 0;
1269
+ } catch (ex) {
1270
+ const error = ex;
1271
+ console.error(`Relint - Cleaning [.eslintcache] Failed [${name}, ${error.message}]`);
1272
+ return 1;
1273
+ }
1274
+ }).reduce((prev, result2) => prev || result2, 0);
1275
+ return result || runSteps("Relint", [["yarn", ["eslint", ".", "--cache"]]]);
1276
+ };
1277
+
1278
+ // src/actions/retest.ts
1279
+ var retest = () => {
1280
+ return runSteps("Test", [
1281
+ ["yarn", ["jest", "--clearCache"]],
1282
+ ["yarn", ["jest", "."]]
1283
+ ]);
1284
+ };
1285
+
1286
+ // src/actions/sonar.ts
1287
+ var sonar = () => {
1288
+ return runSteps("Sonar", [["yarn", ["eslint", "-c", "sonar.eslintrc", "."]]]);
1289
+ };
1290
+
1291
+ // src/actions/statics.ts
1292
+ import chalk24 from "chalk";
1293
+ var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/styles", "@mui/system"];
1294
+ var statics = () => {
1295
+ console.log(chalk24.green("Check Required Static Dependencies"));
1296
+ const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
1297
+ return detectDuplicateDependencies(statics2, DefaultDependencies);
1298
+ };
1299
+
1300
+ // src/actions/test.ts
1301
+ var test = () => {
1302
+ return runSteps("Test", [["yarn", ["jest", "."]]]);
1303
+ };
1304
+
1305
+ // src/actions/up.ts
1306
+ var up = () => {
1307
+ return runSteps("Up", [["yarn", "outdated"]]);
1308
+ };
1309
+
1310
+ // src/actions/updo.ts
1311
+ var updo = () => {
1312
+ return runSteps("Updo", [
1313
+ ["yarn", "install"],
1314
+ ["yarn", "upgrade-interactive"],
1315
+ ["yarn", "dedupe"]
1316
+ ]);
1317
+ };
1318
+
1319
+ // src/actions/upplug.ts
1320
+ var updateYarnPlugins = () => {
1321
+ return runSteps("Update Yarn Plugins", [
1322
+ ["yarn", ["plugin", "import", "https://mskelton.dev/yarn-outdated/v3"]],
1323
+ ["yarn", ["plugin", "import", "version"]],
1324
+ ["yarn", ["plugin", "import", "interactive-tools"]],
1325
+ ["yarn", ["plugin", "import", "workspace-tools"]]
1326
+ ]);
1327
+ };
1328
+
1329
+ // src/actions/upyarn.ts
1330
+ var updateYarnVersion = () => {
1331
+ return runSteps("Update Yarn Version", [["yarn", ["set", "version", "latest"]]]);
1332
+ };
1333
+
1334
+ // src/actions/yarn3only.ts
1335
+ var yarn3Only = () => {
1336
+ const [valid, version] = isYarnVersionOrGreater(3);
1337
+ if (!valid) {
1338
+ processEx(`Invalid Yarn version [${version}]`);
1339
+ }
1340
+ return 0;
1341
+ };
1342
+ export {
1343
+ build,
1344
+ clean,
1345
+ cleanAll,
1346
+ cleanDocs,
1347
+ cleanPackage,
1348
+ compile,
1349
+ compileAll,
1350
+ compilePackage,
1351
+ copyAssets,
1352
+ cycle,
1353
+ dead,
1354
+ deploy,
1355
+ deployMajor,
1356
+ deployMinor,
1357
+ deployNext,
1358
+ deps,
1359
+ depsAll,
1360
+ depsPackage,
1361
+ dupdeps,
1362
+ fix,
1363
+ genDocs,
1364
+ genDocsAll,
1365
+ genDocsPackage,
1366
+ gitignoreGen,
1367
+ gitlint,
1368
+ gitlintFix,
1369
+ license,
1370
+ lint,
1371
+ lintAll,
1372
+ lintClean,
1373
+ lintPackage,
1374
+ lintProfile,
1375
+ npmignoreGen,
1376
+ packageClean,
1377
+ packageCleanOutputs,
1378
+ packageCleanTypescript,
1379
+ packageCompile,
1380
+ packageCopyAssets,
1381
+ packageDeps,
1382
+ packageGenDocs,
1383
+ packagePublint,
1384
+ packageRecompile,
1385
+ packageTsup,
1386
+ publint,
1387
+ publintAll,
1388
+ publintPackage,
1389
+ rebuild,
1390
+ recompile,
1391
+ recompileAll,
1392
+ recompilePackage,
1393
+ reinstall,
1394
+ relint,
1395
+ retest,
1396
+ sonar,
1397
+ statics,
1398
+ test,
1399
+ up,
1400
+ updateYarnPlugins,
1401
+ updateYarnVersion,
1402
+ updo,
1403
+ yarn3Only
1404
+ };
1405
+ //# sourceMappingURL=index.mjs.map