@gluhar/cli 2.0.0-dev.0

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 (293) hide show
  1. package/package.json +46 -0
  2. package/src/GlobalOptions.d.ts +8 -0
  3. package/src/GlobalOptions.d.ts.map +1 -0
  4. package/src/GlobalOptions.js +2 -0
  5. package/src/commands/blank/BlankOptions.d.ts +4 -0
  6. package/src/commands/blank/BlankOptions.d.ts.map +1 -0
  7. package/src/commands/blank/BlankOptions.js +2 -0
  8. package/src/commands/blank/blank.d.ts +3 -0
  9. package/src/commands/blank/blank.d.ts.map +1 -0
  10. package/src/commands/blank/blank.js +8 -0
  11. package/src/commands/blank/index.d.ts +4 -0
  12. package/src/commands/blank/index.d.ts.map +1 -0
  13. package/src/commands/blank/index.js +9 -0
  14. package/src/commands/blank/log.d.ts +2 -0
  15. package/src/commands/blank/log.d.ts.map +1 -0
  16. package/src/commands/blank/log.js +5 -0
  17. package/src/commands/build/BuildOptions.d.ts +4 -0
  18. package/src/commands/build/BuildOptions.d.ts.map +1 -0
  19. package/src/commands/build/BuildOptions.js +2 -0
  20. package/src/commands/build/build.d.ts +3 -0
  21. package/src/commands/build/build.d.ts.map +1 -0
  22. package/src/commands/build/build.js +22 -0
  23. package/src/commands/build/index.d.ts +4 -0
  24. package/src/commands/build/index.d.ts.map +1 -0
  25. package/src/commands/build/index.js +9 -0
  26. package/src/commands/build/log.d.ts +2 -0
  27. package/src/commands/build/log.d.ts.map +1 -0
  28. package/src/commands/build/log.js +5 -0
  29. package/src/commands/danka/DankaOptions.d.ts +4 -0
  30. package/src/commands/danka/DankaOptions.d.ts.map +1 -0
  31. package/src/commands/danka/DankaOptions.js +2 -0
  32. package/src/commands/danka/danka.d.ts +3 -0
  33. package/src/commands/danka/danka.d.ts.map +1 -0
  34. package/src/commands/danka/danka.js +8 -0
  35. package/src/commands/danka/index.d.ts +4 -0
  36. package/src/commands/danka/index.d.ts.map +1 -0
  37. package/src/commands/danka/index.js +9 -0
  38. package/src/commands/danka/log.d.ts +2 -0
  39. package/src/commands/danka/log.d.ts.map +1 -0
  40. package/src/commands/danka/log.js +5 -0
  41. package/src/commands/deinstall/DeinstallOptions.d.ts +4 -0
  42. package/src/commands/deinstall/DeinstallOptions.d.ts.map +1 -0
  43. package/src/commands/deinstall/DeinstallOptions.js +2 -0
  44. package/src/commands/deinstall/deinstall.d.ts +3 -0
  45. package/src/commands/deinstall/deinstall.d.ts.map +1 -0
  46. package/src/commands/deinstall/deinstall.js +21 -0
  47. package/src/commands/deinstall/index.d.ts +4 -0
  48. package/src/commands/deinstall/index.d.ts.map +1 -0
  49. package/src/commands/deinstall/index.js +9 -0
  50. package/src/commands/deinstall/log.d.ts +2 -0
  51. package/src/commands/deinstall/log.d.ts.map +1 -0
  52. package/src/commands/deinstall/log.js +5 -0
  53. package/src/commands/deploy/DeployOptions.d.ts +4 -0
  54. package/src/commands/deploy/DeployOptions.d.ts.map +1 -0
  55. package/src/commands/deploy/DeployOptions.js +2 -0
  56. package/src/commands/deploy/deploy.d.ts +3 -0
  57. package/src/commands/deploy/deploy.d.ts.map +1 -0
  58. package/src/commands/deploy/deploy.js +23 -0
  59. package/src/commands/deploy/index.d.ts +4 -0
  60. package/src/commands/deploy/index.d.ts.map +1 -0
  61. package/src/commands/deploy/index.js +9 -0
  62. package/src/commands/deploy/log.d.ts +2 -0
  63. package/src/commands/deploy/log.d.ts.map +1 -0
  64. package/src/commands/deploy/log.js +5 -0
  65. package/src/commands/generate/GenerateOptions.d.ts +8 -0
  66. package/src/commands/generate/GenerateOptions.d.ts.map +1 -0
  67. package/src/commands/generate/GenerateOptions.js +4 -0
  68. package/src/commands/generate/generate.d.ts +3 -0
  69. package/src/commands/generate/generate.d.ts.map +1 -0
  70. package/src/commands/generate/generate.js +22 -0
  71. package/src/commands/generate/generateCommand.d.ts +2 -0
  72. package/src/commands/generate/generateCommand.d.ts.map +1 -0
  73. package/src/commands/generate/generateCommand.js +36 -0
  74. package/src/commands/generate/generateProject.d.ts +3 -0
  75. package/src/commands/generate/generateProject.d.ts.map +1 -0
  76. package/src/commands/generate/generateProject.js +82 -0
  77. package/src/commands/generate/index.d.ts +4 -0
  78. package/src/commands/generate/index.d.ts.map +1 -0
  79. package/src/commands/generate/index.js +13 -0
  80. package/src/commands/generate/log.d.ts +2 -0
  81. package/src/commands/generate/log.d.ts.map +1 -0
  82. package/src/commands/generate/log.js +5 -0
  83. package/src/commands/index.d.ts +3 -0
  84. package/src/commands/index.d.ts.map +1 -0
  85. package/src/commands/index.js +21 -0
  86. package/src/commands/kiss/KissOptions.d.ts +4 -0
  87. package/src/commands/kiss/KissOptions.d.ts.map +1 -0
  88. package/src/commands/kiss/KissOptions.js +2 -0
  89. package/src/commands/kiss/index.d.ts +4 -0
  90. package/src/commands/kiss/index.d.ts.map +1 -0
  91. package/src/commands/kiss/index.js +9 -0
  92. package/src/commands/kiss/kiss.d.ts +3 -0
  93. package/src/commands/kiss/kiss.d.ts.map +1 -0
  94. package/src/commands/kiss/kiss.js +8 -0
  95. package/src/commands/kiss/log.d.ts +2 -0
  96. package/src/commands/kiss/log.d.ts.map +1 -0
  97. package/src/commands/kiss/log.js +5 -0
  98. package/src/commands/reinstall/ReinstallOptions.d.ts +4 -0
  99. package/src/commands/reinstall/ReinstallOptions.d.ts.map +1 -0
  100. package/src/commands/reinstall/ReinstallOptions.js +2 -0
  101. package/src/commands/reinstall/index.d.ts +4 -0
  102. package/src/commands/reinstall/index.d.ts.map +1 -0
  103. package/src/commands/reinstall/index.js +9 -0
  104. package/src/commands/reinstall/log.d.ts +2 -0
  105. package/src/commands/reinstall/log.d.ts.map +1 -0
  106. package/src/commands/reinstall/log.js +5 -0
  107. package/src/commands/reinstall/reinstall.d.ts +3 -0
  108. package/src/commands/reinstall/reinstall.d.ts.map +1 -0
  109. package/src/commands/reinstall/reinstall.js +14 -0
  110. package/src/commands/release/ReleaseOptions.d.ts +9 -0
  111. package/src/commands/release/ReleaseOptions.d.ts.map +1 -0
  112. package/src/commands/release/ReleaseOptions.js +2 -0
  113. package/src/commands/release/index.d.ts +4 -0
  114. package/src/commands/release/index.d.ts.map +1 -0
  115. package/src/commands/release/index.js +22 -0
  116. package/src/commands/release/log.d.ts +2 -0
  117. package/src/commands/release/log.d.ts.map +1 -0
  118. package/src/commands/release/log.js +5 -0
  119. package/src/commands/release/publish.d.ts +3 -0
  120. package/src/commands/release/publish.d.ts.map +1 -0
  121. package/src/commands/release/publish.js +18 -0
  122. package/src/commands/release/release.d.ts +3 -0
  123. package/src/commands/release/release.d.ts.map +1 -0
  124. package/src/commands/release/release.js +21 -0
  125. package/src/commands/release/tag.d.ts +23 -0
  126. package/src/commands/release/tag.d.ts.map +1 -0
  127. package/src/commands/release/tag.js +90 -0
  128. package/src/commands/version/VersionOptions.d.ts +7 -0
  129. package/src/commands/version/VersionOptions.d.ts.map +1 -0
  130. package/src/commands/version/VersionOptions.js +2 -0
  131. package/src/commands/version/getPreid.d.ts +2 -0
  132. package/src/commands/version/getPreid.d.ts.map +1 -0
  133. package/src/commands/version/getPreid.js +10 -0
  134. package/src/commands/version/index.d.ts +4 -0
  135. package/src/commands/version/index.d.ts.map +1 -0
  136. package/src/commands/version/index.js +12 -0
  137. package/src/commands/version/log.d.ts +2 -0
  138. package/src/commands/version/log.d.ts.map +1 -0
  139. package/src/commands/version/log.js +5 -0
  140. package/src/commands/version/pimpChangelogs.d.ts +2 -0
  141. package/src/commands/version/pimpChangelogs.d.ts.map +1 -0
  142. package/src/commands/version/pimpChangelogs.js +37 -0
  143. package/src/commands/version/version.d.ts +3 -0
  144. package/src/commands/version/version.d.ts.map +1 -0
  145. package/src/commands/version/version.js +32 -0
  146. package/src/constants.d.ts +4 -0
  147. package/src/constants.d.ts.map +1 -0
  148. package/src/constants.js +7 -0
  149. package/src/index.d.ts +3 -0
  150. package/src/index.d.ts.map +1 -0
  151. package/src/index.js +24 -0
  152. package/src/preAction.d.ts +3 -0
  153. package/src/preAction.d.ts.map +1 -0
  154. package/src/preAction.js +55 -0
  155. package/src/scripts/cmd/cd.d.ts +2 -0
  156. package/src/scripts/cmd/cd.d.ts.map +1 -0
  157. package/src/scripts/cmd/cd.js +15 -0
  158. package/src/scripts/cmd/executeBash.d.ts +10 -0
  159. package/src/scripts/cmd/executeBash.d.ts.map +1 -0
  160. package/src/scripts/cmd/executeBash.js +21 -0
  161. package/src/scripts/cmd/executeCmd.d.ts +9 -0
  162. package/src/scripts/cmd/executeCmd.d.ts.map +1 -0
  163. package/src/scripts/cmd/executeCmd.js +23 -0
  164. package/src/scripts/cmd/getBashOutput.d.ts +10 -0
  165. package/src/scripts/cmd/getBashOutput.d.ts.map +1 -0
  166. package/src/scripts/cmd/getBashOutput.js +19 -0
  167. package/src/scripts/cmd/getCmdOutput.d.ts +10 -0
  168. package/src/scripts/cmd/getCmdOutput.d.ts.map +1 -0
  169. package/src/scripts/cmd/getCmdOutput.js +26 -0
  170. package/src/scripts/cmd/index.d.ts +8 -0
  171. package/src/scripts/cmd/index.d.ts.map +1 -0
  172. package/src/scripts/cmd/index.js +25 -0
  173. package/src/scripts/cmd/log.d.ts +2 -0
  174. package/src/scripts/cmd/log.d.ts.map +1 -0
  175. package/src/scripts/cmd/log.js +5 -0
  176. package/src/scripts/cmd/parseArgs.d.ts +3 -0
  177. package/src/scripts/cmd/parseArgs.d.ts.map +1 -0
  178. package/src/scripts/cmd/parseArgs.js +41 -0
  179. package/src/scripts/cmd/parseBashArgs.d.ts +3 -0
  180. package/src/scripts/cmd/parseBashArgs.d.ts.map +1 -0
  181. package/src/scripts/cmd/parseBashArgs.js +16 -0
  182. package/src/scripts/cmd/types.d.ts +12 -0
  183. package/src/scripts/cmd/types.d.ts.map +1 -0
  184. package/src/scripts/cmd/types.js +2 -0
  185. package/src/scripts/filesystem/copyDir.d.ts +9 -0
  186. package/src/scripts/filesystem/copyDir.d.ts.map +1 -0
  187. package/src/scripts/filesystem/copyDir.js +26 -0
  188. package/src/scripts/filesystem/copyFiles.d.ts +11 -0
  189. package/src/scripts/filesystem/copyFiles.d.ts.map +1 -0
  190. package/src/scripts/filesystem/copyFiles.js +59 -0
  191. package/src/scripts/filesystem/findFile.d.ts +2 -0
  192. package/src/scripts/filesystem/findFile.d.ts.map +1 -0
  193. package/src/scripts/filesystem/findFile.js +24 -0
  194. package/src/scripts/filesystem/index.d.ts +10 -0
  195. package/src/scripts/filesystem/index.d.ts.map +1 -0
  196. package/src/scripts/filesystem/index.js +17 -0
  197. package/src/scripts/filesystem/loadJsonFile.d.ts +2 -0
  198. package/src/scripts/filesystem/loadJsonFile.d.ts.map +1 -0
  199. package/src/scripts/filesystem/loadJsonFile.js +18 -0
  200. package/src/scripts/filesystem/log.d.ts +2 -0
  201. package/src/scripts/filesystem/log.d.ts.map +1 -0
  202. package/src/scripts/filesystem/log.js +5 -0
  203. package/src/scripts/filesystem/readDirRecursive.d.ts +2 -0
  204. package/src/scripts/filesystem/readDirRecursive.d.ts.map +1 -0
  205. package/src/scripts/filesystem/readDirRecursive.js +16 -0
  206. package/src/scripts/git/branch/branchDelete.d.ts +6 -0
  207. package/src/scripts/git/branch/branchDelete.d.ts.map +1 -0
  208. package/src/scripts/git/branch/branchDelete.js +24 -0
  209. package/src/scripts/git/branch/branchExists.d.ts +5 -0
  210. package/src/scripts/git/branch/branchExists.d.ts.map +1 -0
  211. package/src/scripts/git/branch/branchExists.js +15 -0
  212. package/src/scripts/git/branch/checkout.d.ts +5 -0
  213. package/src/scripts/git/branch/checkout.d.ts.map +1 -0
  214. package/src/scripts/git/branch/checkout.js +15 -0
  215. package/src/scripts/git/branch/getCurrentBranch.d.ts +11 -0
  216. package/src/scripts/git/branch/getCurrentBranch.d.ts.map +1 -0
  217. package/src/scripts/git/branch/getCurrentBranch.js +28 -0
  218. package/src/scripts/git/commit.sh +1 -0
  219. package/src/scripts/git/getRepo.d.ts +2 -0
  220. package/src/scripts/git/getRepo.d.ts.map +1 -0
  221. package/src/scripts/git/getRepo.js +13 -0
  222. package/src/scripts/git/index.d.ts +28 -0
  223. package/src/scripts/git/index.d.ts.map +1 -0
  224. package/src/scripts/git/index.js +38 -0
  225. package/src/scripts/git/log.d.ts +2 -0
  226. package/src/scripts/git/log.d.ts.map +1 -0
  227. package/src/scripts/git/log.js +5 -0
  228. package/src/scripts/git/openPr.d.ts +2 -0
  229. package/src/scripts/git/openPr.d.ts.map +1 -0
  230. package/src/scripts/git/openPr.js +20 -0
  231. package/src/scripts/git/remoteStatus.d.ts +3 -0
  232. package/src/scripts/git/remoteStatus.d.ts.map +1 -0
  233. package/src/scripts/git/remoteStatus.js +22 -0
  234. package/src/scripts/git/tag/createTag.d.ts +18 -0
  235. package/src/scripts/git/tag/createTag.d.ts.map +1 -0
  236. package/src/scripts/git/tag/createTag.js +18 -0
  237. package/src/scripts/git/tag/deleteTag.d.ts +2 -0
  238. package/src/scripts/git/tag/deleteTag.d.ts.map +1 -0
  239. package/src/scripts/git/tag/deleteTag.js +13 -0
  240. package/src/scripts/git/tag/getTags.d.ts +2 -0
  241. package/src/scripts/git/tag/getTags.d.ts.map +1 -0
  242. package/src/scripts/git/tag/getTags.js +8 -0
  243. package/src/scripts/git/tag/pushAllTags.d.ts +2 -0
  244. package/src/scripts/git/tag/pushAllTags.d.ts.map +1 -0
  245. package/src/scripts/git/tag/pushAllTags.js +8 -0
  246. package/src/scripts/git/tag/renameTag.d.ts +2 -0
  247. package/src/scripts/git/tag/renameTag.d.ts.map +1 -0
  248. package/src/scripts/git/tag/renameTag.js +14 -0
  249. package/src/scripts/lerna/changed.d.ts +3 -0
  250. package/src/scripts/lerna/changed.d.ts.map +1 -0
  251. package/src/scripts/lerna/changed.js +13 -0
  252. package/src/scripts/lerna/constants.d.ts +5 -0
  253. package/src/scripts/lerna/constants.d.ts.map +1 -0
  254. package/src/scripts/lerna/constants.js +7 -0
  255. package/src/scripts/lerna/filterByDependency.d.ts +7 -0
  256. package/src/scripts/lerna/filterByDependency.d.ts.map +1 -0
  257. package/src/scripts/lerna/filterByDependency.js +18 -0
  258. package/src/scripts/lerna/getConfig.d.ts +3 -0
  259. package/src/scripts/lerna/getConfig.d.ts.map +1 -0
  260. package/src/scripts/lerna/getConfig.js +13 -0
  261. package/src/scripts/lerna/getDependencies.d.ts +9 -0
  262. package/src/scripts/lerna/getDependencies.d.ts.map +1 -0
  263. package/src/scripts/lerna/getDependencies.js +23 -0
  264. package/src/scripts/lerna/getDetails.d.ts +3 -0
  265. package/src/scripts/lerna/getDetails.d.ts.map +1 -0
  266. package/src/scripts/lerna/getDetails.js +38 -0
  267. package/src/scripts/lerna/index.d.ts +14 -0
  268. package/src/scripts/lerna/index.d.ts.map +1 -0
  269. package/src/scripts/lerna/index.js +19 -0
  270. package/src/scripts/lerna/list.sh +1 -0
  271. package/src/scripts/lerna/log.d.ts +2 -0
  272. package/src/scripts/lerna/log.d.ts.map +1 -0
  273. package/src/scripts/lerna/log.js +5 -0
  274. package/src/scripts/lerna/publish.sh +1 -0
  275. package/src/scripts/lerna/types.d.ts +62 -0
  276. package/src/scripts/lerna/types.d.ts.map +1 -0
  277. package/src/scripts/lerna/types.js +2 -0
  278. package/src/scripts/lerna/version.sh +2 -0
  279. package/src/utils/chalk.d.ts +4 -0
  280. package/src/utils/chalk.d.ts.map +1 -0
  281. package/src/utils/chalk.js +9 -0
  282. package/src/utils/common.d.ts +2 -0
  283. package/src/utils/common.d.ts.map +1 -0
  284. package/src/utils/common.js +5 -0
  285. package/src/utils/index.d.ts +4 -0
  286. package/src/utils/index.d.ts.map +1 -0
  287. package/src/utils/index.js +19 -0
  288. package/src/utils/inquirer.d.ts +5 -0
  289. package/src/utils/inquirer.d.ts.map +1 -0
  290. package/src/utils/inquirer.js +21 -0
  291. package/src/utils/logger.d.ts +9 -0
  292. package/src/utils/logger.d.ts.map +1 -0
  293. package/src/utils/logger.js +36 -0
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pimpChangelogs = void 0;
4
+ const log_1 = require("./log");
5
+ const glob_1 = require("glob");
6
+ const path_1 = require("path");
7
+ const fs_1 = require("fs");
8
+ const common_1 = require("../../utils/common");
9
+ const pimpChangelogs = async () => {
10
+ log_1.log.info("Pimping changelogs");
11
+ const g = (0, path_1.join)("packages", "**", "CHANGELOG.md");
12
+ const filePaths = await (0, glob_1.glob)(g);
13
+ const changelogs = filePaths.map((fp) => {
14
+ const changelog = (0, fs_1.readFileSync)(fp).toString();
15
+ const lines = changelog.split("\n").map((line) => {
16
+ if (line.substring(0, 2) === "* ") {
17
+ if (line.substring(0, 4) === "* **")
18
+ return `- ${line.substring(2).split("** ").map(common_1.capitalize).join("** ")}`;
19
+ return `- ${(0, common_1.capitalize)(line.substring(2))}`;
20
+ }
21
+ if (line.includes("**Note:**"))
22
+ return line.replace("**Note:**", "**📝 Note:**");
23
+ if (line.substring(0, 4) === "### ")
24
+ return line
25
+ .replace("### Features", "### 🚀 Enhancements")
26
+ .replace("### Bug Fixes", "### 🩹 Fixes")
27
+ .replace("### Chore", "### 🏡 Chore")
28
+ .replace("### Performance Improvements", "### 🔥 Performance");
29
+ return line;
30
+ });
31
+ return lines.join("\n");
32
+ });
33
+ await filePaths.forEach((file, idx) => {
34
+ (0, fs_1.writeFileSync)(file, changelogs[idx]);
35
+ });
36
+ };
37
+ exports.pimpChangelogs = pimpChangelogs;
@@ -0,0 +1,3 @@
1
+ import type { VersionOptions } from "./VersionOptions";
2
+ export declare const version: (options: VersionOptions) => Promise<void>;
3
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../../src/commands/version/version.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,eAAO,MAAM,OAAO,YAAmB,cAAc,kBAwBpD,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.version = void 0;
4
+ const lerna_1 = require("../../scripts/lerna");
5
+ const git_1 = require("../../scripts/git");
6
+ const log_1 = require("./log");
7
+ const getPreid_1 = require("./getPreid");
8
+ const pimpChangelogs_1 = require("./pimpChangelogs");
9
+ const version = async (options) => {
10
+ const { pre, dev, changelog, commit } = options;
11
+ lerna_1.lerna.version({
12
+ conventionalCommits: true,
13
+ conventionalGraduate: (!dev && !pre) || undefined,
14
+ conventionalPrerelease: !!dev || !!pre || undefined,
15
+ preid: dev ? "dev" : (0, getPreid_1.getPreid)(pre),
16
+ includeMergedTags: true,
17
+ gitTagVersion: false,
18
+ private: false,
19
+ push: false,
20
+ changelog,
21
+ });
22
+ if (changelog)
23
+ await (0, pimpChangelogs_1.pimpChangelogs)();
24
+ if (commit) {
25
+ log_1.log.info("Commit changes.");
26
+ const msg = commit === true ? "chore: Prepare Release" : commit;
27
+ git_1.git.commit({
28
+ m: msg,
29
+ });
30
+ }
31
+ };
32
+ exports.version = version;
@@ -0,0 +1,4 @@
1
+ export declare const PROGRAM_NAME: string;
2
+ export declare const VERSION: string;
3
+ export declare const CONFIG_FILE: string;
4
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,QAAsB,CAAC;AAChD,eAAO,MAAM,OAAO,QAAU,CAAC;AAC/B,eAAO,MAAM,WAAW,QAAyB,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONFIG_FILE = exports.VERSION = exports.PROGRAM_NAME = void 0;
4
+ const package_json_1 = require("../package.json");
5
+ exports.PROGRAM_NAME = Object.keys(package_json_1.bin)[0];
6
+ exports.VERSION = package_json_1.version;
7
+ exports.CONFIG_FILE = `${exports.PROGRAM_NAME}.json`;
package/src/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
package/src/index.js ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const commander_1 = require("commander");
8
+ const constants_1 = require("./constants");
9
+ const commands_1 = __importDefault(require("./commands"));
10
+ const preAction_1 = require("./preAction");
11
+ commander_1.program
12
+ .name(constants_1.PROGRAM_NAME)
13
+ .description("A collection of commands and scripts for helping running, building, deploying and assisting in developing with Gluhar UI, Vue, Nuxt, Tailwind & Sanity.")
14
+ .version(constants_1.VERSION, "-v, --version", "Output the version number.")
15
+ .helpOption("-h, --help", "Display help for a command.")
16
+ .option("-l, --log-level <level>", "Set log level.", "info")
17
+ .option("-lp, --log-prefix <prefixes...>", "Set log prefixes.")
18
+ .option("--ci", "Enable CI mode. Full logging and no prompts.", false)
19
+ .option("--cwd <path>", "The current working directory for the scripts.")
20
+ .usage("<command> [options]")
21
+ .hook("preAction", preAction_1.preAction)
22
+ .action(() => commander_1.program.outputHelp());
23
+ commands_1.default.forEach((cmd) => commander_1.program.addCommand(cmd));
24
+ commander_1.program.parse(process.argv);
@@ -0,0 +1,3 @@
1
+ import type { Command } from "commander";
2
+ export declare const preAction: (rootCmd: Command, actionCmd: Command) => void;
3
+ //# sourceMappingURL=preAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preAction.d.ts","sourceRoot":"","sources":["../../src/preAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8CzC,eAAO,MAAM,SAAS,YAAa,OAAO,aAAa,OAAO,SAiB7D,CAAC"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.preAction = void 0;
4
+ const utils_1 = require("./utils");
5
+ // import { getConfigOpt, setConfigOpt } from './config';
6
+ const cmd_1 = require("./scripts/cmd");
7
+ const constants_1 = require("./constants");
8
+ const getOptions = (command) => command.opts();
9
+ const log = (0, utils_1.logger)("cli");
10
+ // const loadConfig = (rootCmd: Command, actionCmd: Command) => {
11
+ // const config = getConfigOpt(actionCmd.name());
12
+ // setConfigOpt(config, rootCmd, actionCmd);
13
+ // };
14
+ const setupCi = (rootCmd, actionCmd) => {
15
+ const { ci } = getOptions(rootCmd);
16
+ const ciSource = rootCmd.getOptionValueSource("ci") ?? "implied";
17
+ if (ci) {
18
+ rootCmd.setOptionValueWithSource("yes", true, ciSource);
19
+ actionCmd.setOptionValueWithSource("yes", true, ciSource);
20
+ rootCmd.setOptionValueWithSource("logLevel", "verbose", ciSource);
21
+ rootCmd.setOptionValueWithSource("logPrefix", undefined, ciSource);
22
+ }
23
+ };
24
+ const setupLogging = (rootCmd) => {
25
+ const { logLevel, logPrefix } = getOptions(rootCmd);
26
+ (0, utils_1.init)(constants_1.PROGRAM_NAME, logLevel, logPrefix);
27
+ };
28
+ const setup = (rootCmd, actionCmd) => {
29
+ setupCi(rootCmd, actionCmd);
30
+ setupLogging(rootCmd);
31
+ };
32
+ const logCli = (actionCmd) => {
33
+ log.notice(`v${constants_1.VERSION}`);
34
+ log.verbose("Calling command:", actionCmd.name());
35
+ log.verbose("arguments:", actionCmd.args);
36
+ log.verbose("options:", getOptions(actionCmd));
37
+ log.verbose("cwd:", process.cwd());
38
+ };
39
+ const preAction = (rootCmd, actionCmd) => {
40
+ // setup logging before loadConfig, so we can get logging from loadConfig
41
+ setup(rootCmd, actionCmd);
42
+ const { cwd: initCwd } = getOptions(rootCmd);
43
+ if (initCwd)
44
+ cmd_1.cmd.cd(initCwd);
45
+ // loadConfig(rootCmd, actionCmd);
46
+ const { cwd: newCwd } = getOptions(rootCmd);
47
+ if (newCwd && newCwd !== initCwd)
48
+ cmd_1.cmd.cd(newCwd);
49
+ // setup logging after loadConfig so we apply options from config
50
+ setup(rootCmd, actionCmd);
51
+ logCli(actionCmd);
52
+ if (initCwd)
53
+ log.notice("from", initCwd);
54
+ };
55
+ exports.preAction = preAction;
@@ -0,0 +1,2 @@
1
+ export declare const cd: (path: string) => void;
2
+ //# sourceMappingURL=cd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cd.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/cd.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,EAAE,SAAU,MAAM,SAK9B,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.cd = void 0;
7
+ const shelljs_1 = __importDefault(require("shelljs"));
8
+ const log_1 = require("./log");
9
+ const cd = (path) => {
10
+ const oldDir = process.cwd();
11
+ shelljs_1.default.cd(path);
12
+ const newDir = process.cwd();
13
+ log_1.log.verbose(`cd ${path}: ${oldDir} -> ${newDir}`);
14
+ };
15
+ exports.cd = cd;
@@ -0,0 +1,10 @@
1
+ import type { Args } from './types';
2
+ /**
3
+ * Function that executes a bash script file in the same console from a given relative path. Can pass arguments/flags to the script.
4
+ * @param path A path to a bash script file, relative to one directory up: 'lerna/bootstrap'.
5
+ * @param args Option flags to pass to the script: { m: 'Message', msg: 'asdf' }.
6
+ * @param absolute Flag if you are providing an absolute path.
7
+ * @returns Executes the bash script file in the same stdio.
8
+ */
9
+ export declare const executeBash: (path: string, args?: Args, absolute?: boolean) => import("child_process").SpawnSyncReturns<Buffer>;
10
+ //# sourceMappingURL=executeBash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executeBash.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/executeBash.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,SAAU,MAAM,SAAS,IAAI,aAAa,OAAO,qDAQxE,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeBash = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const parseBashArgs_1 = require("./parseBashArgs");
6
+ /**
7
+ * Function that executes a bash script file in the same console from a given relative path. Can pass arguments/flags to the script.
8
+ * @param path A path to a bash script file, relative to one directory up: 'lerna/bootstrap'.
9
+ * @param args Option flags to pass to the script: { m: 'Message', msg: 'asdf' }.
10
+ * @param absolute Flag if you are providing an absolute path.
11
+ * @returns Executes the bash script file in the same stdio.
12
+ */
13
+ const executeBash = (path, args, absolute) => {
14
+ const bashArgs = (0, parseBashArgs_1.parseBashArgs)(path, args, absolute);
15
+ // TODO make stdio configurable
16
+ // TODO make an async option
17
+ return (0, child_process_1.spawnSync)('bash', bashArgs, {
18
+ stdio: 'inherit',
19
+ });
20
+ };
21
+ exports.executeBash = executeBash;
@@ -0,0 +1,9 @@
1
+ import type { Args } from './types';
2
+ /**
3
+ * Function that executes a bash script from string.
4
+ * @param cmd A one-line string of a bash command: 'npm install'.
5
+ * @param args Option flags to pass to the script: { m: 'Message', msg: 'asdf' }.
6
+ * @returns Executes the bash script in the same stdio.
7
+ */
8
+ export declare const executeCmd: (cmd: string, args?: Args) => import("child_process").SpawnSyncReturns<Buffer>;
9
+ //# sourceMappingURL=executeCmd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executeCmd.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/executeCmd.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAGpC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAS,MAAM,SAAS,IAAI,qDASlD,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeCmd = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const log_1 = require("./log");
6
+ const parseArgs_1 = require("./parseArgs");
7
+ /**
8
+ * Function that executes a bash script from string.
9
+ * @param cmd A one-line string of a bash command: 'npm install'.
10
+ * @param args Option flags to pass to the script: { m: 'Message', msg: 'asdf' }.
11
+ * @returns Executes the bash script in the same stdio.
12
+ */
13
+ const executeCmd = (cmd, args) => {
14
+ const cmdArgs = [cmd];
15
+ if (args) {
16
+ cmdArgs.push(...(0, parseArgs_1.parseArgs)(args));
17
+ }
18
+ const fullCmd = cmdArgs.join(' ');
19
+ log_1.log.verbose('executeCmd:', fullCmd);
20
+ return (0, child_process_1.spawnSync)(fullCmd, { stdio: 'inherit', shell: true });
21
+ };
22
+ exports.executeCmd = executeCmd;
23
+ // TODO make an async option
@@ -0,0 +1,10 @@
1
+ import type { Args } from './types';
2
+ /**
3
+ * Function that executes a bash script file from a given relative path and returns the output. Can pass arguments/flags to the script.
4
+ * @param cmd A path to a bash script file, relative to one directory up: 'lerna/bootstrap'.
5
+ * @param options Option flags to pass to the script: { m: 'Message', msg: 'asdf' }.
6
+ * @param absolute Flag if you are providing an absolute path.
7
+ * @returns The output of the bash file script as a string.
8
+ */
9
+ export declare const getBashOutput: (path: string, args?: Args, absolute?: boolean) => string;
10
+ //# sourceMappingURL=getBashOutput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBashOutput.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/getBashOutput.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,SAClB,MAAM,SACL,IAAI,aACA,OAAO,WAOnB,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBashOutput = void 0;
4
+ const log_1 = require("./log");
5
+ const parseBashArgs_1 = require("./parseBashArgs");
6
+ const getCmdOutput_1 = require("./getCmdOutput");
7
+ /**
8
+ * Function that executes a bash script file from a given relative path and returns the output. Can pass arguments/flags to the script.
9
+ * @param cmd A path to a bash script file, relative to one directory up: 'lerna/bootstrap'.
10
+ * @param options Option flags to pass to the script: { m: 'Message', msg: 'asdf' }.
11
+ * @param absolute Flag if you are providing an absolute path.
12
+ * @returns The output of the bash file script as a string.
13
+ */
14
+ const getBashOutput = (path, args, absolute) => {
15
+ log_1.log.verbose('getBashOutput:', args);
16
+ const bashArgs = (0, parseBashArgs_1.parseBashArgs)(path, args, absolute).join(' ');
17
+ return (0, getCmdOutput_1.getCmdOutput)(`bash ${bashArgs}`);
18
+ };
19
+ exports.getBashOutput = getBashOutput;
@@ -0,0 +1,10 @@
1
+ import type { Args } from './types';
2
+ /**
3
+ * A function that runs a bash script from a string and returns the output.
4
+ * Mainly used in js logic if you want the output of a bash script.
5
+ * @param cmd A one-line string of a bash command: 'npm install'.
6
+ * @param args Option flags to pass to the script: { m: 'Message', msg: 'asdf' }.
7
+ * @returns The output of the command as a string.
8
+ */
9
+ export declare const getCmdOutput: (cmd: string, args?: Args) => string;
10
+ //# sourceMappingURL=getCmdOutput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCmdOutput.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/getCmdOutput.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAGpC;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,QAAS,MAAM,SAAS,IAAI,WASpD,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCmdOutput = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const log_1 = require("./log");
6
+ const parseArgs_1 = require("./parseArgs");
7
+ /**
8
+ * A function that runs a bash script from a string and returns the output.
9
+ * Mainly used in js logic if you want the output of a bash script.
10
+ * @param cmd A one-line string of a bash command: 'npm install'.
11
+ * @param args Option flags to pass to the script: { m: 'Message', msg: 'asdf' }.
12
+ * @returns The output of the command as a string.
13
+ */
14
+ const getCmdOutput = (cmd, args) => {
15
+ const cmdArgs = [cmd];
16
+ if (args) {
17
+ cmdArgs.push(...(0, parseArgs_1.parseArgs)(args));
18
+ }
19
+ const fullCmd = cmdArgs.join(' ');
20
+ log_1.log.verbose('getCmdOutput:', fullCmd);
21
+ return (0, child_process_1.execSync)(fullCmd).toString().trim();
22
+ };
23
+ exports.getCmdOutput = getCmdOutput;
24
+ // TODO make an async option
25
+ // TODO get output from a script file?
26
+ // TODO maybe utilise the other two function instead of execSync?
@@ -0,0 +1,8 @@
1
+ export * from './executeBash';
2
+ export * from './executeCmd';
3
+ export * from './getCmdOutput';
4
+ export * from './getBashOutput';
5
+ export declare const cmd: {
6
+ cd: (path: string) => void;
7
+ };
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/index.ts"],"names":[],"mappings":"AAEA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAEhC,eAAO,MAAM,GAAG;;CAEf,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.cmd = void 0;
18
+ const cd_1 = require("./cd");
19
+ __exportStar(require("./executeBash"), exports);
20
+ __exportStar(require("./executeCmd"), exports);
21
+ __exportStar(require("./getCmdOutput"), exports);
22
+ __exportStar(require("./getBashOutput"), exports);
23
+ exports.cmd = {
24
+ cd: cd_1.cd,
25
+ };
@@ -0,0 +1,2 @@
1
+ export declare const log: import("../../utils").Logger;
2
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/log.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,4BAAgB,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.log = void 0;
4
+ const utils_1 = require("../../utils");
5
+ exports.log = (0, utils_1.logger)('cmd');
@@ -0,0 +1,3 @@
1
+ import type { Args } from "./types";
2
+ export declare const parseArgs: (args: Args) => string[];
3
+ //# sourceMappingURL=parseArgs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseArgs.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/parseArgs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAA+B,MAAM,SAAS,CAAC;AAQjE,eAAO,MAAM,SAAS,SAAU,IAAI,KAAG,MAAM,EAkC5C,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.parseArgs = void 0;
7
+ const humps_1 = __importDefault(require("humps"));
8
+ const hyphenize = (s) => humps_1.default.decamelize(s, { separator: "-" });
9
+ const hasValue = (arg) => {
10
+ return arg.value !== undefined;
11
+ };
12
+ const parseArgs = (args) => {
13
+ return Object.entries(args)
14
+ .map(([name, value]) => ({
15
+ name,
16
+ parsedName: hyphenize(name),
17
+ value,
18
+ parsedValue: JSON.stringify(value),
19
+ }))
20
+ .filter(hasValue)
21
+ .reduce((result, { name, parsedName, value, parsedValue }) => {
22
+ if (name.length > 1) {
23
+ result.push(`--${parsedName}`);
24
+ }
25
+ else {
26
+ result.push(`-${parsedName}`);
27
+ }
28
+ value.toString();
29
+ if (value !== true) {
30
+ let v = parsedValue;
31
+ if (v.length > 2 &&
32
+ v[0] === '"' &&
33
+ v[v.length - 1] === '"' &&
34
+ !v.includes(" "))
35
+ v = v.slice(1, -1);
36
+ result.push(v);
37
+ }
38
+ return result;
39
+ }, []);
40
+ };
41
+ exports.parseArgs = parseArgs;
@@ -0,0 +1,3 @@
1
+ import type { Args } from './types';
2
+ export declare const parseBashArgs: (path: string, args?: Args, absolute?: boolean) => string[];
3
+ //# sourceMappingURL=parseBashArgs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseBashArgs.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/parseBashArgs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAGpC,eAAO,MAAM,aAAa,SAClB,MAAM,SACL,IAAI,aACA,OAAO,aAanB,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseBashArgs = void 0;
4
+ const log_1 = require("./log");
5
+ const parseArgs_1 = require("./parseArgs");
6
+ const parseBashArgs = (path, args, absolute) => {
7
+ const filePath = path.endsWith('.sh') ? path : `${path}.sh`;
8
+ const absolutePath = !absolute ? `${__dirname}/../${filePath}` : filePath;
9
+ const flags = [absolutePath];
10
+ if (args) {
11
+ flags.push(...(0, parseArgs_1.parseArgs)(args));
12
+ }
13
+ log_1.log.verbose('executeBash:', flags.join(' '));
14
+ return flags;
15
+ };
16
+ exports.parseBashArgs = parseBashArgs;
@@ -0,0 +1,12 @@
1
+ export type ArgValue = string | number | boolean;
2
+ export type Args = Record<string, ArgValue | undefined>;
3
+ export interface ParsedArg {
4
+ name: string;
5
+ parsedName: string;
6
+ value: ArgValue | undefined;
7
+ parsedValue: string | undefined;
8
+ }
9
+ export type NotNullableProps<T> = {
10
+ [K in keyof T]: NonNullable<T[K]>;
11
+ };
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACjD,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC;AAExD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;KAC/B,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import { FileInfoUpdate } from "./copyFiles";
2
+ /**
3
+ * Function that copies all files recursively from one dir to another allowing to update their content in the process.
4
+ * @param sourcePath Directory of files to copy recursively.
5
+ * @param destinationPath Destination directory to place files.
6
+ * @param updateContent Optional function that updates the contents of each file.
7
+ */
8
+ export declare const copyDir: (sourcePath: string, destinationPath: string, updateFile?: FileInfoUpdate) => Promise<void>;
9
+ //# sourceMappingURL=copyDir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyDir.d.ts","sourceRoot":"","sources":["../../../../src/scripts/filesystem/copyDir.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,cAAc,EAAE,MAAM,aAAa,CAAC;AAGxD;;;;;GAKG;AACH,eAAO,MAAM,OAAO,eACN,MAAM,mBACD,MAAM,eACV,cAAc,kBAe5B,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.copyDir = void 0;
4
+ const path_1 = require("path");
5
+ const copyFiles_1 = require("./copyFiles");
6
+ const log_1 = require("./log");
7
+ /**
8
+ * Function that copies all files recursively from one dir to another allowing to update their content in the process.
9
+ * @param sourcePath Directory of files to copy recursively.
10
+ * @param destinationPath Destination directory to place files.
11
+ * @param updateContent Optional function that updates the contents of each file.
12
+ */
13
+ const copyDir = (sourcePath, destinationPath, updateFile) => {
14
+ log_1.log.verbose("copyDir", { sourcePath, destinationPath });
15
+ const glob = (0, path_1.join)(sourcePath, "**", "*.*");
16
+ return (0, copyFiles_1.copyFiles)([glob], (file) => {
17
+ const newDir = (0, path_1.join)(destinationPath, (0, path_1.relative)(sourcePath, file.dir));
18
+ log_1.log.verbose("copyDir file from", file.dir, "to", newDir);
19
+ const f = updateFile ? updateFile(file) : file;
20
+ return {
21
+ ...f,
22
+ dir: newDir,
23
+ };
24
+ });
25
+ };
26
+ exports.copyDir = copyDir;
@@ -0,0 +1,11 @@
1
+ import { type ParsedPath } from "path";
2
+ export interface FileInfo extends Omit<ParsedPath, "root"> {
3
+ name: string;
4
+ content: string;
5
+ encoding: BufferEncoding;
6
+ }
7
+ export type FileInfoUpdate = (fileInfo: FileInfo) => Partial<FileInfo>;
8
+ export declare const loadFiles: (globs: string[]) => Promise<FileInfo[]>;
9
+ export declare const updateFiles: (files: FileInfo[], update: FileInfoUpdate) => FileInfo[];
10
+ export declare const copyFiles: (globs: string[], update: FileInfoUpdate) => Promise<void>;
11
+ //# sourceMappingURL=copyFiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyFiles.d.ts","sourceRoot":"","sources":["../../../../src/scripts/filesystem/copyFiles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAA0B,MAAM,MAAM,CAAC;AAI/D,MAAM,WAAW,QAAS,SAAQ,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvE,eAAO,MAAM,SAAS,UAAiB,MAAM,EAAE,KAAG,OAAO,CAAC,QAAQ,EAAE,CAsBnE,CAAC;AAEF,eAAO,MAAM,WAAW,UACf,QAAQ,EAAE,UACT,cAAc,KACrB,QAAQ,EASV,CAAC;AAoBF,eAAO,MAAM,SAAS,UAAiB,MAAM,EAAE,UAAU,cAAc,kBAItE,CAAC"}