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