@xylabs/ts-scripts-yarn3 7.0.2 → 7.1.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 (270) hide show
  1. package/dist/actions/build.mjs +39 -87
  2. package/dist/actions/build.mjs.map +1 -1
  3. package/dist/actions/clean-docs.mjs +8 -22
  4. package/dist/actions/clean-docs.mjs.map +1 -1
  5. package/dist/actions/clean-eslint.mjs +5 -11
  6. package/dist/actions/clean-eslint.mjs.map +1 -1
  7. package/dist/actions/clean-jest.mjs +16 -29
  8. package/dist/actions/clean-jest.mjs.map +1 -1
  9. package/dist/actions/clean.mjs +32 -63
  10. package/dist/actions/clean.mjs.map +1 -1
  11. package/dist/actions/compile.mjs +50 -76
  12. package/dist/actions/compile.mjs.map +1 -1
  13. package/dist/actions/copy-assets.mjs +23 -38
  14. package/dist/actions/copy-assets.mjs.map +1 -1
  15. package/dist/actions/cycle.mjs +28 -57
  16. package/dist/actions/cycle.mjs.map +1 -1
  17. package/dist/actions/dead.mjs +16 -31
  18. package/dist/actions/dead.mjs.map +1 -1
  19. package/dist/actions/deplint/checkPackage/checkPackage.mjs +48 -71
  20. package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
  21. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +5 -5
  22. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -1
  23. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +9 -5
  24. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -1
  25. package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +5 -5
  26. package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -1
  27. package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +0 -4
  28. package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +1 -1
  29. package/dist/actions/deplint/checkPackage/index.mjs +48 -71
  30. package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
  31. package/dist/actions/deplint/deplint.mjs +61 -86
  32. package/dist/actions/deplint/deplint.mjs.map +1 -1
  33. package/dist/actions/deplint/findFiles.mjs +4 -20
  34. package/dist/actions/deplint/findFiles.mjs.map +1 -1
  35. package/dist/actions/deplint/findFilesByGlob.mjs +1 -8
  36. package/dist/actions/deplint/findFilesByGlob.mjs.map +1 -1
  37. package/dist/actions/deplint/getBasePackageName.mjs +0 -4
  38. package/dist/actions/deplint/getBasePackageName.mjs.map +1 -1
  39. package/dist/actions/deplint/getDependenciesFromPackageJson.mjs +0 -4
  40. package/dist/actions/deplint/getDependenciesFromPackageJson.mjs.map +1 -1
  41. package/dist/actions/deplint/getExternalImportsFromFiles.mjs +12 -24
  42. package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -1
  43. package/dist/actions/deplint/getImportsFromFile.mjs +9 -16
  44. package/dist/actions/deplint/getImportsFromFile.mjs.map +1 -1
  45. package/dist/actions/deplint/index.mjs +61 -86
  46. package/dist/actions/deplint/index.mjs.map +1 -1
  47. package/dist/actions/deploy-major.mjs +26 -57
  48. package/dist/actions/deploy-major.mjs.map +1 -1
  49. package/dist/actions/deploy-minor.mjs +26 -57
  50. package/dist/actions/deploy-minor.mjs.map +1 -1
  51. package/dist/actions/deploy-next.mjs +26 -57
  52. package/dist/actions/deploy-next.mjs.map +1 -1
  53. package/dist/actions/deploy.mjs +26 -57
  54. package/dist/actions/deploy.mjs.map +1 -1
  55. package/dist/actions/dupdeps.mjs +26 -37
  56. package/dist/actions/dupdeps.mjs.map +1 -1
  57. package/dist/actions/fix.mjs +36 -54
  58. package/dist/actions/fix.mjs.map +1 -1
  59. package/dist/actions/gen-docs.mjs +25 -65
  60. package/dist/actions/gen-docs.mjs.map +1 -1
  61. package/dist/actions/gitignore-gen.mjs +28 -44
  62. package/dist/actions/gitignore-gen.mjs.map +1 -1
  63. package/dist/actions/gitlint-fix.mjs +5 -14
  64. package/dist/actions/gitlint-fix.mjs.map +1 -1
  65. package/dist/actions/gitlint.mjs +4 -7
  66. package/dist/actions/gitlint.mjs.map +1 -1
  67. package/dist/actions/index.mjs +705 -1251
  68. package/dist/actions/index.mjs.map +1 -1
  69. package/dist/actions/knip.mjs +16 -31
  70. package/dist/actions/knip.mjs.map +1 -1
  71. package/dist/actions/license.mjs +37 -51
  72. package/dist/actions/license.mjs.map +1 -1
  73. package/dist/actions/lint.mjs +33 -48
  74. package/dist/actions/lint.mjs.map +1 -1
  75. package/dist/actions/npmignore-gen.mjs +28 -44
  76. package/dist/actions/npmignore-gen.mjs.map +1 -1
  77. package/dist/actions/package/clean-outputs.mjs +6 -16
  78. package/dist/actions/package/clean-outputs.mjs.map +1 -1
  79. package/dist/actions/package/clean-typescript.mjs +6 -16
  80. package/dist/actions/package/clean-typescript.mjs.map +1 -1
  81. package/dist/actions/package/clean.mjs +12 -29
  82. package/dist/actions/package/clean.mjs.map +1 -1
  83. package/dist/actions/package/compile/buildEntries.mjs +19 -34
  84. package/dist/actions/package/compile/buildEntries.mjs.map +1 -1
  85. package/dist/actions/package/compile/compile.mjs +165 -195
  86. package/dist/actions/package/compile/compile.mjs.map +1 -1
  87. package/dist/actions/package/compile/copyTypeFiles.mjs +20 -23
  88. package/dist/actions/package/compile/copyTypeFiles.mjs.map +1 -1
  89. package/dist/actions/package/compile/deepMerge.mjs +0 -5
  90. package/dist/actions/package/compile/deepMerge.mjs.map +1 -1
  91. package/dist/actions/package/compile/getCompilerOptions.mjs +2 -5
  92. package/dist/actions/package/compile/getCompilerOptions.mjs.map +1 -1
  93. package/dist/actions/package/compile/index.mjs +165 -195
  94. package/dist/actions/package/compile/index.mjs.map +1 -1
  95. package/dist/actions/package/compile/inputs.mjs +15 -25
  96. package/dist/actions/package/compile/inputs.mjs.map +1 -1
  97. package/dist/actions/package/compile/packageCompileTsc.mjs +25 -17
  98. package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -1
  99. package/dist/actions/package/compile/packageCompileTscTypes.mjs +19 -36
  100. package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -1
  101. package/dist/actions/package/compile/packageCompileTsup.mjs +160 -185
  102. package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
  103. package/dist/actions/package/copy-assets.mjs +12 -21
  104. package/dist/actions/package/copy-assets.mjs.map +1 -1
  105. package/dist/actions/package/cycle.mjs +5 -14
  106. package/dist/actions/package/cycle.mjs.map +1 -1
  107. package/dist/actions/package/gen-docs.mjs +11 -12
  108. package/dist/actions/package/gen-docs.mjs.map +1 -1
  109. package/dist/actions/package/index.mjs +236 -308
  110. package/dist/actions/package/index.mjs.map +1 -1
  111. package/dist/actions/package/lint.mjs +16 -39
  112. package/dist/actions/package/lint.mjs.map +1 -1
  113. package/dist/actions/package/publint.mjs +13 -14
  114. package/dist/actions/package/publint.mjs.map +1 -1
  115. package/dist/actions/package/recompile.mjs +179 -223
  116. package/dist/actions/package/recompile.mjs.map +1 -1
  117. package/dist/actions/publint.mjs +37 -71
  118. package/dist/actions/publint.mjs.map +1 -1
  119. package/dist/actions/rebuild.mjs +17 -29
  120. package/dist/actions/rebuild.mjs.map +1 -1
  121. package/dist/actions/recompile.mjs +50 -67
  122. package/dist/actions/recompile.mjs.map +1 -1
  123. package/dist/actions/reinstall.mjs +25 -43
  124. package/dist/actions/reinstall.mjs.map +1 -1
  125. package/dist/actions/relint.mjs +40 -63
  126. package/dist/actions/relint.mjs.map +1 -1
  127. package/dist/actions/retest.mjs +17 -35
  128. package/dist/actions/retest.mjs.map +1 -1
  129. package/dist/actions/sonar.mjs +16 -32
  130. package/dist/actions/sonar.mjs.map +1 -1
  131. package/dist/actions/statics.mjs +27 -46
  132. package/dist/actions/statics.mjs.map +1 -1
  133. package/dist/actions/test.mjs +16 -30
  134. package/dist/actions/test.mjs.map +1 -1
  135. package/dist/actions/up.mjs +16 -27
  136. package/dist/actions/up.mjs.map +1 -1
  137. package/dist/actions/updo.mjs +18 -33
  138. package/dist/actions/updo.mjs.map +1 -1
  139. package/dist/actions/upplug.mjs +19 -53
  140. package/dist/actions/upplug.mjs.map +1 -1
  141. package/dist/actions/upyarn.mjs +16 -31
  142. package/dist/actions/upyarn.mjs.map +1 -1
  143. package/dist/actions/yarn3only.mjs +12 -23
  144. package/dist/actions/yarn3only.mjs.map +1 -1
  145. package/dist/bin/package/build-only.mjs +165 -194
  146. package/dist/bin/package/build-only.mjs.map +1 -1
  147. package/dist/bin/package/build.mjs +166 -197
  148. package/dist/bin/package/build.mjs.map +1 -1
  149. package/dist/bin/package/clean-outputs.mjs +6 -15
  150. package/dist/bin/package/clean-outputs.mjs.map +1 -1
  151. package/dist/bin/package/clean-typescript.mjs +6 -15
  152. package/dist/bin/package/clean-typescript.mjs.map +1 -1
  153. package/dist/bin/package/clean.mjs +12 -28
  154. package/dist/bin/package/clean.mjs.map +1 -1
  155. package/dist/bin/package/compile-only.mjs +165 -194
  156. package/dist/bin/package/compile-only.mjs.map +1 -1
  157. package/dist/bin/package/compile-tsup.mjs +160 -184
  158. package/dist/bin/package/compile-tsup.mjs.map +1 -1
  159. package/dist/bin/package/compile.mjs +165 -194
  160. package/dist/bin/package/compile.mjs.map +1 -1
  161. package/dist/bin/package/copy-assets-cjs.mjs +13 -23
  162. package/dist/bin/package/copy-assets-cjs.mjs.map +1 -1
  163. package/dist/bin/package/copy-assets-esm.mjs +13 -23
  164. package/dist/bin/package/copy-assets-esm.mjs.map +1 -1
  165. package/dist/bin/package/cycle.mjs +5 -13
  166. package/dist/bin/package/cycle.mjs.map +1 -1
  167. package/dist/bin/package/fix.mjs +16 -38
  168. package/dist/bin/package/fix.mjs.map +1 -1
  169. package/dist/bin/package/gen-docs.mjs +11 -11
  170. package/dist/bin/package/gen-docs.mjs.map +1 -1
  171. package/dist/bin/package/lint.mjs +16 -38
  172. package/dist/bin/package/lint.mjs.map +1 -1
  173. package/dist/bin/package/publint.mjs +13 -13
  174. package/dist/bin/package/publint.mjs.map +1 -1
  175. package/dist/bin/package/recompile.mjs +179 -222
  176. package/dist/bin/package/recompile.mjs.map +1 -1
  177. package/dist/bin/package/relint.mjs +16 -38
  178. package/dist/bin/package/relint.mjs.map +1 -1
  179. package/dist/bin/xy.mjs +932 -1266
  180. package/dist/bin/xy.mjs.map +1 -1
  181. package/dist/index.mjs +1191 -1612
  182. package/dist/index.mjs.map +1 -1
  183. package/dist/lib/checkResult.mjs +2 -5
  184. package/dist/lib/checkResult.mjs.map +1 -1
  185. package/dist/lib/createBuildConfig.mjs +9 -24
  186. package/dist/lib/createBuildConfig.mjs.map +1 -1
  187. package/dist/lib/defaultBuildConfig.mjs +2 -6
  188. package/dist/lib/defaultBuildConfig.mjs.map +1 -1
  189. package/dist/lib/deleteGlob.mjs +3 -9
  190. package/dist/lib/deleteGlob.mjs.map +1 -1
  191. package/dist/lib/dependencies/DuplicateDetector.mjs +12 -23
  192. package/dist/lib/dependencies/DuplicateDetector.mjs.map +1 -1
  193. package/dist/lib/dependencies/detectDuplicateDependencies.mjs +22 -33
  194. package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +1 -1
  195. package/dist/lib/dependencies/index.mjs +22 -33
  196. package/dist/lib/dependencies/index.mjs.map +1 -1
  197. package/dist/lib/file/ReadFileSyncOptions.mjs +1 -3
  198. package/dist/lib/file/ReadFileSyncOptions.mjs.map +1 -1
  199. package/dist/lib/file/constants.mjs.map +1 -1
  200. package/dist/lib/file/fileLines.mjs +12 -13
  201. package/dist/lib/file/fileLines.mjs.map +1 -1
  202. package/dist/lib/file/index.mjs +14 -15
  203. package/dist/lib/file/index.mjs.map +1 -1
  204. package/dist/lib/file/tryReadFileSync.mjs +3 -8
  205. package/dist/lib/file/tryReadFileSync.mjs.map +1 -1
  206. package/dist/lib/generateIgnoreFiles.mjs +27 -43
  207. package/dist/lib/generateIgnoreFiles.mjs.map +1 -1
  208. package/dist/lib/index.mjs +99 -157
  209. package/dist/lib/index.mjs.map +1 -1
  210. package/dist/lib/jsonFormatters.mjs +2 -5
  211. package/dist/lib/jsonFormatters.mjs.map +1 -1
  212. package/dist/lib/loadConfig.mjs +3 -11
  213. package/dist/lib/loadConfig.mjs.map +1 -1
  214. package/dist/lib/parsedPackageJSON.mjs +2 -5
  215. package/dist/lib/parsedPackageJSON.mjs.map +1 -1
  216. package/dist/lib/processEx.mjs +6 -9
  217. package/dist/lib/processEx.mjs.map +1 -1
  218. package/dist/lib/runSteps.mjs +13 -19
  219. package/dist/lib/runSteps.mjs.map +1 -1
  220. package/dist/lib/runStepsAsync.mjs +22 -22
  221. package/dist/lib/runStepsAsync.mjs.map +1 -1
  222. package/dist/lib/runXy.mjs +19 -31
  223. package/dist/lib/runXy.mjs.map +1 -1
  224. package/dist/lib/runXyWithWarning.mjs +2 -5
  225. package/dist/lib/runXyWithWarning.mjs.map +1 -1
  226. package/dist/lib/safeExit.mjs +10 -13
  227. package/dist/lib/safeExit.mjs.map +1 -1
  228. package/dist/lib/string/empty.mjs +2 -5
  229. package/dist/lib/string/empty.mjs.map +1 -1
  230. package/dist/lib/string/index.mjs +3 -9
  231. package/dist/lib/string/index.mjs.map +1 -1
  232. package/dist/lib/string/union.mjs +1 -7
  233. package/dist/lib/string/union.mjs.map +1 -1
  234. package/dist/lib/withErrnoException.mjs +4 -7
  235. package/dist/lib/withErrnoException.mjs.map +1 -1
  236. package/dist/lib/withError.mjs +2 -5
  237. package/dist/lib/withError.mjs.map +1 -1
  238. package/dist/lib/yarn/index.mjs +11 -30
  239. package/dist/lib/yarn/index.mjs.map +1 -1
  240. package/dist/lib/yarn/isYarnVersionOrGreater.mjs +4 -15
  241. package/dist/lib/yarn/isYarnVersionOrGreater.mjs.map +1 -1
  242. package/dist/lib/yarn/workspace/index.mjs +5 -16
  243. package/dist/lib/yarn/workspace/index.mjs.map +1 -1
  244. package/dist/lib/yarn/workspace/yarnWorkspace.mjs +5 -16
  245. package/dist/lib/yarn/workspace/yarnWorkspace.mjs.map +1 -1
  246. package/dist/lib/yarn/workspace/yarnWorkspaces.mjs +3 -14
  247. package/dist/lib/yarn/workspace/yarnWorkspaces.mjs.map +1 -1
  248. package/dist/lib/yarn/yarnInitCwd.mjs +2 -5
  249. package/dist/lib/yarn/yarnInitCwd.mjs.map +1 -1
  250. package/dist/loadPackageConfig.mjs +3 -8
  251. package/dist/loadPackageConfig.mjs.map +1 -1
  252. package/dist/xy/index.mjs +932 -1267
  253. package/dist/xy/index.mjs.map +1 -1
  254. package/dist/xy/param.mjs +3 -9
  255. package/dist/xy/param.mjs.map +1 -1
  256. package/dist/xy/xy.mjs +932 -1267
  257. package/dist/xy/xy.mjs.map +1 -1
  258. package/dist/xy/xyBuildCommands.mjs +228 -320
  259. package/dist/xy/xyBuildCommands.mjs.map +1 -1
  260. package/dist/xy/xyCommonCommands.mjs +251 -336
  261. package/dist/xy/xyCommonCommands.mjs.map +1 -1
  262. package/dist/xy/xyDeployCommands.mjs +99 -161
  263. package/dist/xy/xyDeployCommands.mjs.map +1 -1
  264. package/dist/xy/xyInstallCommands.mjs +145 -193
  265. package/dist/xy/xyInstallCommands.mjs.map +1 -1
  266. package/dist/xy/xyLintCommands.mjs +302 -403
  267. package/dist/xy/xyLintCommands.mjs.map +1 -1
  268. package/dist/xy/xyParseOptions.mjs +2 -5
  269. package/dist/xy/xyParseOptions.mjs.map +1 -1
  270. package/package.json +8 -9
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/deplint/deplint.ts","../../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../../src/lib/yarn/workspace/yarnWorkspace.ts","../../../src/actions/deplint/findFilesByGlob.ts","../../../src/actions/deplint/findFiles.ts","../../../src/actions/deplint/getDependenciesFromPackageJson.ts","../../../src/actions/deplint/getImportsFromFile.ts","../../../src/actions/deplint/getBasePackageName.ts","../../../src/actions/deplint/getExternalImportsFromFiles.ts","../../../src/actions/deplint/checkPackage/getUnlistedDependencies.ts","../../../src/actions/deplint/checkPackage/getUnlistedDevDependencies.ts","../../../src/actions/deplint/checkPackage/getUnusedDependencies.ts","../../../src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts","../../../src/actions/deplint/checkPackage/checkPackage.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { yarnWorkspace, yarnWorkspaces } from '../../lib/index.ts'\nimport type { CheckPackageOptions } from './checkPackage/index.ts'\nimport { checkPackage } from './checkPackage/index.ts'\n\nexport interface DepLintOptions extends CheckPackageOptions {\n pkg?: string\n}\n\nexport const deplint = ({\n pkg, deps, devDeps, peerDeps, verbose,\n}: DepLintOptions) => {\n let totalErrors = 0\n\n if (pkg === undefined) {\n const workspaces = yarnWorkspaces()\n\n console.info('Deplint Started...')\n\n for (const workspace of workspaces) {\n totalErrors += checkPackage({\n ...workspace, deps, devDeps, peerDeps, verbose,\n })\n }\n } else {\n const { location, name } = yarnWorkspace(pkg)\n\n console.info(`Running Deplint for ${name}`)\n totalErrors += checkPackage({\n name, location, devDeps, deps, peerDeps, verbose,\n })\n }\n\n if (totalErrors > 0) {\n console.warn(`Deplint: Found ${chalk.red(totalErrors)} dependency problems. ${chalk.red('✖')}`)\n } else {\n console.info(`Deplint: Found no dependency problems. ${chalk.green('✔')}`)\n }\n return 0\n}\n","import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { Workspace } from './Workspace.ts'\nimport { yarnWorkspaces } from './yarnWorkspaces.ts'\n\nexport const yarnWorkspace = (pkg: string): Workspace => {\n const workspace = yarnWorkspaces().find(({ name }) => name === pkg)\n if (!workspace) throw new Error(`Workspace ${pkg} not found`)\n return workspace\n}\n","import { globSync } from 'glob'\n\nexport function findFilesByGlob(cwd: string, pattern: string) {\n return globSync(pattern, { cwd, absolute: true })\n}\n","import { findFilesByGlob } from './findFilesByGlob.ts'\n\nexport function findFiles(path: string) {\n const allSourceInclude = ['./src/**/*.{ts,tsx}']\n const allDistInclude = ['./dist/**/*.d.ts', './dist/**/*.{mjs,js,cjs}']\n const srcFiles = allSourceInclude.flatMap(pattern => findFilesByGlob(path, pattern))\n const distFiles = allDistInclude.flatMap(pattern => findFilesByGlob(path, pattern))\n\n return { srcFiles, distFiles }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nexport function getDependenciesFromPackageJson(packageJsonPath: string) {\n const packageJsonFullPath = path.resolve(packageJsonPath)\n const rawContent = fs.readFileSync(packageJsonFullPath, 'utf8')\n const packageJson = JSON.parse(rawContent)\n\n const dependencies = packageJson.dependencies\n ? Object.keys(packageJson.dependencies)\n : []\n\n const devDependencies = packageJson.devDependencies\n ? Object.keys(packageJson.devDependencies)\n : []\n\n const peerDependencies = packageJson.peerDependencies\n ? Object.keys(packageJson.peerDependencies)\n : []\n\n return {\n dependencies, devDependencies, peerDependencies,\n }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport ts from 'typescript'\n\nimport { getBasePackageName } from './getBasePackageName.ts'\n\nexport function getImportsFromFile(filePath: string, importPaths: Record<string, string[]>, typeImportPaths: Record<string, string[]>) {\n const sourceCode = fs.readFileSync(filePath, 'utf8')\n\n const isMjsFile = filePath.endsWith('.mjs')\n\n const sourceFile = ts.createSourceFile(\n path.basename(filePath),\n sourceCode,\n ts.ScriptTarget.Latest,\n true,\n isMjsFile ? ts.ScriptKind.JS : undefined,\n )\n\n const imports: string[] = []\n const typeImports: string[] = []\n\n const isDeclarationFile = filePath.endsWith('.d.ts')\n\n function visit(node: ts.Node) {\n if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {\n const moduleSpecifier = (node.moduleSpecifier)?.getFullText()\n const isTypeImport = ts.isImportDeclaration(node) ? (node.importClause?.isTypeOnly ?? false) : false\n if (typeof moduleSpecifier === 'string') {\n const trimmed = moduleSpecifier.replaceAll(\"'\", '').replaceAll('\"', '').trim()\n // we are determining if the type import is being imported in an exported d.ts file\n if (isTypeImport || isDeclarationFile) {\n typeImports.push(trimmed)\n } else {\n imports.push(trimmed)\n }\n }\n } else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {\n const [arg] = node.arguments\n if (ts.isStringLiteral(arg)) {\n const trimmed = arg.text\n imports.push(trimmed)\n }\n }\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n\n const importsStartsWithExcludes = ['.', '#', 'node:']\n\n const cleanedImports = imports.filter(imp => !importsStartsWithExcludes.some(exc => imp.startsWith(exc))).map(getBasePackageName)\n const cleanedTypeImports = typeImports.filter(imp => !importsStartsWithExcludes.some(exc => imp.startsWith(exc))).map(getBasePackageName)\n\n for (const imp of cleanedImports) {\n importPaths[imp] = importPaths[imp] ?? []\n importPaths[imp].push(filePath)\n }\n\n for (const imp of cleanedTypeImports) {\n typeImportPaths[imp] = typeImportPaths[imp] ?? []\n typeImportPaths[imp].push(filePath)\n }\n\n return [cleanedImports, cleanedTypeImports]\n}\n","export function getBasePackageName(importName: string) {\n const importNameScrubbed = importName.replaceAll('\"', '').trim()\n if (importNameScrubbed.startsWith('@')) {\n const parts = importNameScrubbed.split('/')\n return parts.length >= 2 ? `${parts[0]}/${parts[1]}` : importNameScrubbed\n }\n return importNameScrubbed.split('/')[0]\n}\n","import type { CheckSourceParams } from './checkPackage/index.ts'\nimport { getImportsFromFile } from './getImportsFromFile.ts'\n\nconst internalImportPrefixes = ['.', '#', 'node:']\n\nconst removeInternalImports = (imports: string[]) => {\n return imports.filter(imp => !internalImportPrefixes.some(prefix => imp.startsWith(prefix)))\n}\n\nexport function getExternalImportsFromFiles({ srcFiles, distFiles }: { distFiles: string []; srcFiles: string[] }): CheckSourceParams {\n const srcImportPaths: Record<string, string[]> = {}\n const distImportPaths: Record<string, string[]> = {}\n const distTypeImportPaths: Record<string, string[]> = {}\n for (const path of srcFiles) getImportsFromFile(path, srcImportPaths, srcImportPaths).flat()\n const distTypeFiles = distFiles.filter(file => file.endsWith('.d.ts') || file.endsWith('.d.cts') || file.endsWith('.d.mts'))\n const distCodeFiles = distFiles.filter(file => !(file.endsWith('.d.ts') || file.endsWith('.d.cts') || file.endsWith('.d.mts')))\n for (const path of distCodeFiles) getImportsFromFile(path, distImportPaths, distImportPaths).flat()\n for (const path of distTypeFiles) getImportsFromFile(path, distTypeImportPaths, distTypeImportPaths).flat()\n const srcImports = Object.keys(srcImportPaths)\n const distImports = Object.keys(distImportPaths)\n const distTypeImports = Object.keys(distTypeImportPaths)\n\n const externalSrcImports = removeInternalImports(srcImports)\n const externalDistImports = removeInternalImports(distImports)\n const externalDistTypeImports = removeInternalImports(distTypeImports)\n\n return {\n srcImports,\n srcImportPaths,\n externalSrcImports,\n distImports,\n distImportPaths,\n externalDistImports,\n externalDistTypeImports,\n }\n}\n","import { builtinModules } from 'node:module'\n\nimport chalk from 'chalk'\n\nimport type { Workspace } from '../../../lib/index.ts'\nimport type { CheckPackageParams, CheckSourceParams } from './checkPackageTypes.ts'\n\nexport function getUnlistedDependencies(\n { name, location }: Workspace,\n { dependencies, peerDependencies }: CheckPackageParams,\n {\n externalDistImports, externalDistTypeImports, distImportPaths,\n }: CheckSourceParams,\n) {\n let unlistedDependencies = 0\n\n for (const imp of externalDistImports) {\n if (!dependencies.includes(imp)\n && imp !== name\n && !dependencies.includes(`@types/${imp}`)\n && !peerDependencies.includes(imp)\n && !peerDependencies.includes(`@types/${imp}`)\n && !builtinModules.includes(imp)\n && !builtinModules.includes(`@types/${imp}`)) {\n unlistedDependencies++\n console.log(`[${chalk.blue(name)}] Missing dependency in package.json: ${chalk.red(imp)}`)\n console.log(` ${distImportPaths[imp].join('\\n ')}`)\n }\n }\n\n for (const imp of externalDistTypeImports) {\n if (!dependencies.includes(imp)\n && imp !== name\n && dependencies.includes(`@types/${imp}`)\n && !peerDependencies.includes(imp)\n && peerDependencies.includes(`@types/${imp}`)\n && !builtinModules.includes(imp)\n && builtinModules.includes(`@types/${imp}`)) {\n unlistedDependencies++\n console.log(`[${chalk.blue(name)}] Missing dependency in package.json: ${chalk.red(imp)}`)\n console.log(` ${distImportPaths[imp].join('\\n ')}`)\n }\n }\n\n if (unlistedDependencies > 0) {\n const packageLocation = `${location}/package.json`\n console.log(` ${chalk.yellow(packageLocation)}\\n`)\n }\n return unlistedDependencies\n}\n","import { builtinModules } from 'node:module'\n\nimport chalk from 'chalk'\n\nimport type { Workspace } from '../../../lib/index.ts'\nimport type { CheckPackageParams, CheckSourceParams } from './checkPackageTypes.ts'\n\nexport function getUnlistedDevDependencies(\n { name, location }: Workspace,\n {\n devDependencies, dependencies, peerDependencies,\n }: CheckPackageParams,\n {\n srcImportPaths, externalSrcImports, distImports,\n }: CheckSourceParams,\n) {\n let unlistedDevDependencies = 0\n for (const imp of externalSrcImports) {\n if (!distImports.includes(imp)\n && imp !== name\n && !dependencies.includes(imp)\n && !dependencies.includes(`@types/${imp}`)\n && !peerDependencies.includes(imp)\n && !peerDependencies.includes(`@types/${imp}`)\n && !devDependencies.includes(imp)\n && !devDependencies.includes(`@types/${imp}`)\n && !builtinModules.includes(imp)\n ) {\n unlistedDevDependencies++\n console.log(`[${chalk.blue(name)}] Missing devDependency in package.json: ${chalk.red(imp)}`)\n console.log(` ${srcImportPaths[imp].join('\\n ')}`)\n }\n }\n if (unlistedDevDependencies > 0) {\n const packageLocation = `${location}/package.json`\n console.log(` ${chalk.yellow(packageLocation)}\\n`)\n }\n return unlistedDevDependencies\n}\n","import chalk from 'chalk'\n\nimport type { Workspace } from '../../../lib/index.ts'\nimport type { CheckPackageParams, CheckSourceParams } from './checkPackageTypes.ts'\n\nexport function getUnusedDependencies(\n { name, location }: Workspace,\n { dependencies }: CheckPackageParams,\n {\n externalDistImports,\n externalDistTypeImports,\n externalSrcImports,\n }: CheckSourceParams,\n) {\n let unusedDependencies = 0\n for (const dep of dependencies) {\n if (!externalDistImports.includes(dep)\n && !externalDistImports.includes(dep.replace(/^@types\\//, ''))\n && !externalDistTypeImports.includes(dep)\n && !externalDistTypeImports.includes(dep.replace(/^@types\\//, ''))) {\n unusedDependencies++\n if (externalSrcImports.includes(dep)) {\n console.log(`[${chalk.blue(name)}] dependency should be devDependency in package.json: ${chalk.red(dep)}`)\n } else {\n console.log(`[${chalk.blue(name)}] Unused dependency in package.json: ${chalk.red(dep)}`)\n }\n }\n }\n if (unusedDependencies > 0) {\n const packageLocation = `${location}/package.json`\n console.log(` ${chalk.yellow(packageLocation)}\\n`)\n }\n return unusedDependencies\n}\n","import chalk from 'chalk'\n\nimport type { Workspace } from '../../../lib/index.ts'\nimport type { CheckPackageParams, CheckSourceParams } from './checkPackageTypes.ts'\n\nexport function getUnusedPeerDependencies(\n { name, location }: Workspace,\n { peerDependencies, dependencies }: CheckPackageParams,\n { externalDistImports, externalDistTypeImports }: CheckSourceParams,\n) {\n let unusedDependencies = 0\n for (const dep of peerDependencies) {\n if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\\//, ''))\n && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\\//, ''))) {\n unusedDependencies++\n if (dependencies.includes(dep)) {\n console.log(`[${chalk.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk.red(dep)}`)\n } else {\n console.log(`[${chalk.blue(name)}] Unused peerDependency in package.json: ${chalk.red(dep)}`)\n }\n }\n }\n if (unusedDependencies > 0) {\n const packageLocation = `${location}/package.json`\n console.log(` ${chalk.yellow(packageLocation)}\\n`)\n }\n return unusedDependencies\n}\n","import type { Workspace } from '../../../lib/index.ts'\nimport { findFiles } from '../findFiles.ts'\nimport { getDependenciesFromPackageJson } from '../getDependenciesFromPackageJson.ts'\nimport { getExternalImportsFromFiles } from '../getExternalImportsFromFiles.ts'\nimport { getUnlistedDependencies } from './getUnlistedDependencies.ts'\nimport { getUnlistedDevDependencies } from './getUnlistedDevDependencies.ts'\nimport { getUnusedDependencies } from './getUnusedDependencies.ts'\nimport { getUnusedPeerDependencies } from './getUnusedPeerDependencies.ts'\n\nexport interface CheckPackageOptions {\n deps?: boolean\n devDeps?: boolean\n peerDeps?: boolean\n verbose?: boolean\n}\n\nexport function checkPackage({\n name, location, deps = false, devDeps = false, peerDeps = false, verbose = false,\n}: CheckPackageOptions & Workspace) {\n const { srcFiles, distFiles } = findFiles(location)\n if (verbose) {\n console.info(`Checking package: ${name} at ${location}`)\n console.info(`Source files: ${srcFiles.length}, Distribution files: ${distFiles.length}`)\n for (const file of srcFiles) {\n console.info(`Source file: ${file}`)\n }\n for (const file of distFiles) {\n console.info(`Distribution file: ${file}`)\n }\n }\n const checkDeps = deps || !(deps || devDeps || peerDeps)\n const checkDevDeps = devDeps || !(deps || devDeps || peerDeps)\n const checkPeerDeps = peerDeps // || !(deps || devDeps || peerDeps)\n const sourceParams = getExternalImportsFromFiles({ srcFiles, distFiles })\n\n const packageParams = getDependenciesFromPackageJson(`${location}/package.json`)\n\n const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0\n const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0\n const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0\n const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0\n\n const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedPeerDependencies\n return totalErrors\n}\n"],"mappings":";;;;AAAA,OAAOA,YAAW;;;ACAlB,SAASC,iBAAiB;AAInB,IAAMC,iBAAiB,6BAAA;AAC5B,QAAMC,SAASC,UAAU,QAAQ;IAAC;IAAc;IAAQ;IAAU;KAAgB;IAAEC,UAAU;IAAQC,OAAO;EAAK,CAAA;AAClH,MAAIH,OAAOI,OAAO;AAChB,UAAMJ,OAAOI;EACf;AACA,SACEJ,OAAOK,O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AElB,MAAIL,QAAQM,QAAW;AACrB,UAAMC,aAAaC,eAAAA;AAEnBC,YAAQC,KAAK,oBAAA;AAEb,eAAWC,aAAaJ,YAAY;AAClCF,qBAAeO,aAAa;QAC1B,GAAGD;QAAWV;QAAMC;QAASC;QAAUC;MACzC,CAAA;IACF;EACF,OAAO;AACL,UAAM,EAAES,UAAUC,KAAI,IAAKC,cAAcf,GAAAA;AAEzCS,YAAQC,KAAK,uBAAuBI,IAAAA,EAAM;AAC1CT,mBAAeO,aAAa;MAC1BE;MAAMD;MAAUX;MAASD;MAAME;MAAUC;IAC3C,CAAA;EACF;AAEA,MAAIC,cAAc,GAAG;AACnBI,YAAQO,KAAK,kBAAkBC,OAAMC,IAAIb,WAAAA,CAAAA,yBAAqCY,OAAMC,IAAI,QAAA,CAAA,EAAM;EAChG,OAAO;AACLT,YAAQC,KAAK,0CAA0CO,OAAME,MAAM,QAAA,CAAA,EAAM;EAC3E;AACA,SAAO;AACT,GA9BuB;","names":["chalk","spawnSync","yarnWorkspaces","result","spawnSync","encoding","shell","error","stdout","toString","split","slice","map","item","JSON","parse","yarnWorkspace","pkg","workspace","yarnWorkspaces","find","name","Error","globSync","findFilesByGlob","cwd","pattern","globSync","absolute","findFiles","path","allSourceInclude","allDistInclude","srcFiles","flatMap","pattern","findFilesByGlob","distFiles","fs","path","getDependenciesFromPackageJson","packageJsonPath","packageJsonFullPath","path","resolve","rawContent","fs","readFileSync","packageJson","JSON","parse","dependencies","Object","keys","devDependencies","peerDependencies","fs","path","ts","getBasePackageName","importName","importNameScrubbed","replaceAll","trim","startsWith","parts","split","length","getImportsFromFile","filePath","importPaths","typeImportPaths","sourceCode","fs","readFileSync","isMjsFile","endsWith","sourceFile","ts","createSourceFile","path","basename","ScriptTarget","Latest","ScriptKind","JS","undefined","imports","typeImports","isDeclarationFile","visit","node","isImportDeclaration","isExportDeclaration","moduleSpecifier","getFullText","isTypeImport","importClause","isTypeOnly","trimmed","replaceAll","trim","push","isCallExpression","expression","kind","SyntaxKind","ImportKeyword","arg","arguments","isStringLiteral","text","forEachChild","importsStartsWithExcludes","cleanedImports","filter","imp","some","exc","startsWith","map","getBasePackageName","cleanedTypeImports","internalImportPrefixes","removeInternalImports","imports","filter","imp","some","prefix","startsWith","getExternalImportsFromFiles","srcFiles","distFiles","srcImportPaths","distImportPaths","distTypeImportPaths","path","getImportsFromFile","flat","distTypeFiles","file","endsWith","distCodeFiles","srcImports","Object","keys","distImports","distTypeImports","externalSrcImports","externalDistImports","externalDistTypeImports","builtinModules","chalk","getUnlistedDependencies","name","location","dependencies","peerDependencies","externalDistImports","externalDistTypeImports","distImportPaths","unlistedDependencies","imp","includes","builtinModules","console","log","chalk","blue","red","join","packageLocation","yellow","builtinModules","chalk","getUnlistedDevDependencies","name","location","devDependencies","dependencies","peerDependencies","srcImportPaths","externalSrcImports","distImports","unlistedDevDependencies","imp","includes","builtinModules","console","log","chalk","blue","red","join","packageLocation","yellow","chalk","getUnusedDependencies","name","location","dependencies","externalDistImports","externalDistTypeImports","externalSrcImports","unusedDependencies","dep","includes","replace","console","log","chalk","blue","red","packageLocation","yellow","chalk","getUnusedPeerDependencies","name","location","peerDependencies","dependencies","externalDistImports","externalDistTypeImports","unusedDependencies","dep","includes","replace","console","log","chalk","blue","red","packageLocation","yellow","checkPackage","name","location","deps","devDeps","peerDeps","verbose","srcFiles","distFiles","findFiles","console","info","length","file","checkDeps","checkDevDeps","checkPeerDeps","sourceParams","getExternalImportsFromFiles","packageParams","getDependenciesFromPackageJson","unlistedDependencies","getUnlistedDependencies","unusedDependencies","getUnusedDependencies","unlistedDevDependencies","getUnlistedDevDependencies","unusedPeerDependencies","getUnusedPeerDependencies","totalErrors","deplint","pkg","deps","devDeps","peerDeps","verbose","totalErrors","undefined","workspaces","yarnWorkspaces","console","info","workspace","checkPackage","location","name","yarnWorkspace","warn","chalk","red","green"]}
1
+ {"version":3,"sources":["../../../src/actions/deplint/deplint.ts","../../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../../src/lib/yarn/workspace/yarnWorkspace.ts","../../../src/actions/deplint/findFilesByGlob.ts","../../../src/actions/deplint/findFiles.ts","../../../src/actions/deplint/getDependenciesFromPackageJson.ts","../../../src/actions/deplint/getImportsFromFile.ts","../../../src/actions/deplint/getBasePackageName.ts","../../../src/actions/deplint/getExternalImportsFromFiles.ts","../../../src/actions/deplint/checkPackage/getUnlistedDependencies.ts","../../../src/actions/deplint/checkPackage/getUnlistedDevDependencies.ts","../../../src/actions/deplint/checkPackage/getUnusedDependencies.ts","../../../src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts","../../../src/actions/deplint/checkPackage/checkPackage.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { yarnWorkspace, yarnWorkspaces } from '../../lib/index.ts'\nimport type { CheckPackageOptions } from './checkPackage/index.ts'\nimport { checkPackage } from './checkPackage/index.ts'\n\nexport interface DepLintOptions extends CheckPackageOptions {\n pkg?: string\n}\n\nexport const deplint = ({\n pkg, deps, devDeps, peerDeps, verbose,\n}: DepLintOptions) => {\n let totalErrors = 0\n\n if (pkg === undefined) {\n const workspaces = yarnWorkspaces()\n\n console.info('Deplint Started...')\n\n for (const workspace of workspaces) {\n totalErrors += checkPackage({\n ...workspace, deps, devDeps, peerDeps, verbose,\n })\n }\n } else {\n const { location, name } = yarnWorkspace(pkg)\n\n console.info(`Running Deplint for ${name}`)\n totalErrors += checkPackage({\n name, location, devDeps, deps, peerDeps, verbose,\n })\n }\n\n if (totalErrors > 0) {\n console.warn(`Deplint: Found ${chalk.red(totalErrors)} dependency problems. ${chalk.red('✖')}`)\n } else {\n console.info(`Deplint: Found no dependency problems. ${chalk.green('✔')}`)\n }\n return 0\n}\n","import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { Workspace } from './Workspace.ts'\nimport { yarnWorkspaces } from './yarnWorkspaces.ts'\n\nexport const yarnWorkspace = (pkg: string): Workspace => {\n const workspace = yarnWorkspaces().find(({ name }) => name === pkg)\n if (!workspace) throw new Error(`Workspace ${pkg} not found`)\n return workspace\n}\n","import { globSync } from 'glob'\n\nexport function findFilesByGlob(cwd: string, pattern: string) {\n return globSync(pattern, { cwd, absolute: true })\n}\n","import { findFilesByGlob } from './findFilesByGlob.ts'\n\nexport function findFiles(path: string) {\n const allSourceInclude = ['./src/**/*.{ts,tsx}']\n const allDistInclude = ['./dist/**/*.d.ts', './dist/**/*.{mjs,js,cjs}']\n const srcFiles = allSourceInclude.flatMap(pattern => findFilesByGlob(path, pattern))\n const distFiles = allDistInclude.flatMap(pattern => findFilesByGlob(path, pattern))\n\n return { srcFiles, distFiles }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nexport function getDependenciesFromPackageJson(packageJsonPath: string) {\n const packageJsonFullPath = path.resolve(packageJsonPath)\n const rawContent = fs.readFileSync(packageJsonFullPath, 'utf8')\n const packageJson = JSON.parse(rawContent)\n\n const dependencies = packageJson.dependencies\n ? Object.keys(packageJson.dependencies)\n : []\n\n const devDependencies = packageJson.devDependencies\n ? Object.keys(packageJson.devDependencies)\n : []\n\n const peerDependencies = packageJson.peerDependencies\n ? Object.keys(packageJson.peerDependencies)\n : []\n\n return {\n dependencies, devDependencies, peerDependencies,\n }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport ts from 'typescript'\n\nimport { getBasePackageName } from './getBasePackageName.ts'\n\nexport function getImportsFromFile(filePath: string, importPaths: Record<string, string[]>, typeImportPaths: Record<string, string[]>) {\n const sourceCode = fs.readFileSync(filePath, 'utf8')\n\n const isMjsFile = filePath.endsWith('.mjs')\n\n const sourceFile = ts.createSourceFile(\n path.basename(filePath),\n sourceCode,\n ts.ScriptTarget.Latest,\n true,\n isMjsFile ? ts.ScriptKind.JS : undefined,\n )\n\n const imports: string[] = []\n const typeImports: string[] = []\n\n const isDeclarationFile = filePath.endsWith('.d.ts')\n\n function visit(node: ts.Node) {\n if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {\n const moduleSpecifier = (node.moduleSpecifier)?.getFullText()\n const isTypeImport = ts.isImportDeclaration(node) ? (node.importClause?.isTypeOnly ?? false) : false\n if (typeof moduleSpecifier === 'string') {\n const trimmed = moduleSpecifier.replaceAll(\"'\", '').replaceAll('\"', '').trim()\n // we are determining if the type import is being imported in an exported d.ts file\n if (isTypeImport || isDeclarationFile) {\n typeImports.push(trimmed)\n } else {\n imports.push(trimmed)\n }\n }\n } else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {\n const [arg] = node.arguments\n if (ts.isStringLiteral(arg)) {\n const trimmed = arg.text\n imports.push(trimmed)\n }\n }\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n\n const importsStartsWithExcludes = ['.', '#', 'node:']\n\n const cleanedImports = imports.filter(imp => !importsStartsWithExcludes.some(exc => imp.startsWith(exc))).map(getBasePackageName)\n const cleanedTypeImports = typeImports.filter(imp => !importsStartsWithExcludes.some(exc => imp.startsWith(exc))).map(getBasePackageName)\n\n for (const imp of cleanedImports) {\n importPaths[imp] = importPaths[imp] ?? []\n importPaths[imp].push(filePath)\n }\n\n for (const imp of cleanedTypeImports) {\n typeImportPaths[imp] = typeImportPaths[imp] ?? []\n typeImportPaths[imp].push(filePath)\n }\n\n return [cleanedImports, cleanedTypeImports]\n}\n","export function getBasePackageName(importName: string) {\n const importNameScrubbed = importName.replaceAll('\"', '').trim()\n if (importNameScrubbed.startsWith('@')) {\n const parts = importNameScrubbed.split('/')\n return parts.length >= 2 ? `${parts[0]}/${parts[1]}` : importNameScrubbed\n }\n return importNameScrubbed.split('/')[0]\n}\n","import type { CheckSourceParams } from './checkPackage/index.ts'\nimport { getImportsFromFile } from './getImportsFromFile.ts'\n\nconst internalImportPrefixes = ['.', '#', 'node:']\n\nconst removeInternalImports = (imports: string[]) => {\n return imports.filter(imp => !internalImportPrefixes.some(prefix => imp.startsWith(prefix)))\n}\n\nexport function getExternalImportsFromFiles({ srcFiles, distFiles }: { distFiles: string []; srcFiles: string[] }): CheckSourceParams {\n const srcImportPaths: Record<string, string[]> = {}\n const distImportPaths: Record<string, string[]> = {}\n const distTypeImportPaths: Record<string, string[]> = {}\n for (const path of srcFiles) getImportsFromFile(path, srcImportPaths, srcImportPaths).flat()\n const distTypeFiles = distFiles.filter(file => file.endsWith('.d.ts') || file.endsWith('.d.cts') || file.endsWith('.d.mts'))\n const distCodeFiles = distFiles.filter(file => !(file.endsWith('.d.ts') || file.endsWith('.d.cts') || file.endsWith('.d.mts')))\n for (const path of distCodeFiles) getImportsFromFile(path, distImportPaths, distImportPaths).flat()\n for (const path of distTypeFiles) getImportsFromFile(path, distTypeImportPaths, distTypeImportPaths).flat()\n const srcImports = Object.keys(srcImportPaths)\n const distImports = Object.keys(distImportPaths)\n const distTypeImports = Object.keys(distTypeImportPaths)\n\n const externalSrcImports = removeInternalImports(srcImports)\n const externalDistImports = removeInternalImports(distImports)\n const externalDistTypeImports = removeInternalImports(distTypeImports)\n\n return {\n srcImports,\n srcImportPaths,\n externalSrcImports,\n distImports,\n distImportPaths,\n externalDistImports,\n externalDistTypeImports,\n }\n}\n","import { builtinModules } from 'node:module'\n\nimport chalk from 'chalk'\n\nimport type { Workspace } from '../../../lib/index.ts'\nimport type { CheckPackageParams, CheckSourceParams } from './checkPackageTypes.ts'\n\nexport function getUnlistedDependencies(\n { name, location }: Workspace,\n { dependencies, peerDependencies }: CheckPackageParams,\n {\n externalDistImports, externalDistTypeImports, distImportPaths,\n }: CheckSourceParams,\n) {\n let unlistedDependencies = 0\n\n for (const imp of externalDistImports) {\n if (!dependencies.includes(imp)\n && imp !== name\n && !dependencies.includes(`@types/${imp}`)\n && !peerDependencies.includes(imp)\n && !peerDependencies.includes(`@types/${imp}`)\n && !builtinModules.includes(imp)\n && !builtinModules.includes(`@types/${imp}`)) {\n unlistedDependencies++\n console.log(`[${chalk.blue(name)}] Missing dependency in package.json: ${chalk.red(imp)}`)\n console.log(` ${distImportPaths[imp].join('\\n ')}`)\n }\n }\n\n for (const imp of externalDistTypeImports) {\n if (!dependencies.includes(imp)\n && imp !== name\n && dependencies.includes(`@types/${imp}`)\n && !peerDependencies.includes(imp)\n && peerDependencies.includes(`@types/${imp}`)\n && !builtinModules.includes(imp)\n && builtinModules.includes(`@types/${imp}`)) {\n unlistedDependencies++\n console.log(`[${chalk.blue(name)}] Missing dependency in package.json: ${chalk.red(imp)}`)\n console.log(` ${distImportPaths[imp].join('\\n ')}`)\n }\n }\n\n if (unlistedDependencies > 0) {\n const packageLocation = `${location}/package.json`\n console.log(` ${chalk.yellow(packageLocation)}\\n`)\n }\n return unlistedDependencies\n}\n","import { builtinModules } from 'node:module'\n\nimport chalk from 'chalk'\n\nimport type { Workspace } from '../../../lib/index.ts'\nimport type { CheckPackageParams, CheckSourceParams } from './checkPackageTypes.ts'\n\nexport function getUnlistedDevDependencies(\n { name, location }: Workspace,\n {\n devDependencies, dependencies, peerDependencies,\n }: CheckPackageParams,\n {\n srcImportPaths, externalSrcImports, distImports,\n }: CheckSourceParams,\n) {\n let unlistedDevDependencies = 0\n for (const imp of externalSrcImports) {\n if (!distImports.includes(imp)\n && imp !== name\n && !dependencies.includes(imp)\n && !dependencies.includes(`@types/${imp}`)\n && !peerDependencies.includes(imp)\n && !peerDependencies.includes(`@types/${imp}`)\n && !devDependencies.includes(imp)\n && !devDependencies.includes(`@types/${imp}`)\n && !builtinModules.includes(imp)\n ) {\n unlistedDevDependencies++\n console.log(`[${chalk.blue(name)}] Missing devDependency in package.json: ${chalk.red(imp)}`)\n console.log(` ${srcImportPaths[imp].join('\\n ')}`)\n }\n }\n if (unlistedDevDependencies > 0) {\n const packageLocation = `${location}/package.json`\n console.log(` ${chalk.yellow(packageLocation)}\\n`)\n }\n return unlistedDevDependencies\n}\n","import chalk from 'chalk'\n\nimport type { Workspace } from '../../../lib/index.ts'\nimport type { CheckPackageParams, CheckSourceParams } from './checkPackageTypes.ts'\n\nexport function getUnusedDependencies(\n { name, location }: Workspace,\n { dependencies }: CheckPackageParams,\n {\n externalDistImports,\n externalDistTypeImports,\n externalSrcImports,\n }: CheckSourceParams,\n) {\n let unusedDependencies = 0\n for (const dep of dependencies) {\n if (!externalDistImports.includes(dep)\n && !externalDistImports.includes(dep.replace(/^@types\\//, ''))\n && !externalDistTypeImports.includes(dep)\n && !externalDistTypeImports.includes(dep.replace(/^@types\\//, ''))) {\n unusedDependencies++\n if (externalSrcImports.includes(dep)) {\n console.log(`[${chalk.blue(name)}] dependency should be devDependency in package.json: ${chalk.red(dep)}`)\n } else {\n console.log(`[${chalk.blue(name)}] Unused dependency in package.json: ${chalk.red(dep)}`)\n }\n }\n }\n if (unusedDependencies > 0) {\n const packageLocation = `${location}/package.json`\n console.log(` ${chalk.yellow(packageLocation)}\\n`)\n }\n return unusedDependencies\n}\n","import chalk from 'chalk'\n\nimport type { Workspace } from '../../../lib/index.ts'\nimport type { CheckPackageParams, CheckSourceParams } from './checkPackageTypes.ts'\n\nexport function getUnusedPeerDependencies(\n { name, location }: Workspace,\n { peerDependencies, dependencies }: CheckPackageParams,\n { externalDistImports, externalDistTypeImports }: CheckSourceParams,\n) {\n let unusedDependencies = 0\n for (const dep of peerDependencies) {\n if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\\//, ''))\n && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\\//, ''))) {\n unusedDependencies++\n if (dependencies.includes(dep)) {\n console.log(`[${chalk.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk.red(dep)}`)\n } else {\n console.log(`[${chalk.blue(name)}] Unused peerDependency in package.json: ${chalk.red(dep)}`)\n }\n }\n }\n if (unusedDependencies > 0) {\n const packageLocation = `${location}/package.json`\n console.log(` ${chalk.yellow(packageLocation)}\\n`)\n }\n return unusedDependencies\n}\n","import type { Workspace } from '../../../lib/index.ts'\nimport { findFiles } from '../findFiles.ts'\nimport { getDependenciesFromPackageJson } from '../getDependenciesFromPackageJson.ts'\nimport { getExternalImportsFromFiles } from '../getExternalImportsFromFiles.ts'\nimport { getUnlistedDependencies } from './getUnlistedDependencies.ts'\nimport { getUnlistedDevDependencies } from './getUnlistedDevDependencies.ts'\nimport { getUnusedDependencies } from './getUnusedDependencies.ts'\nimport { getUnusedPeerDependencies } from './getUnusedPeerDependencies.ts'\n\nexport interface CheckPackageOptions {\n deps?: boolean\n devDeps?: boolean\n peerDeps?: boolean\n verbose?: boolean\n}\n\nexport function checkPackage({\n name, location, deps = false, devDeps = false, peerDeps = false, verbose = false,\n}: CheckPackageOptions & Workspace) {\n const { srcFiles, distFiles } = findFiles(location)\n if (verbose) {\n console.info(`Checking package: ${name} at ${location}`)\n console.info(`Source files: ${srcFiles.length}, Distribution files: ${distFiles.length}`)\n for (const file of srcFiles) {\n console.info(`Source file: ${file}`)\n }\n for (const file of distFiles) {\n console.info(`Distribution file: ${file}`)\n }\n }\n const checkDeps = deps || !(deps || devDeps || peerDeps)\n const checkDevDeps = devDeps || !(deps || devDeps || peerDeps)\n const checkPeerDeps = peerDeps // || !(deps || devDeps || peerDeps)\n const sourceParams = getExternalImportsFromFiles({ srcFiles, distFiles })\n\n const packageParams = getDependenciesFromPackageJson(`${location}/package.json`)\n\n const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0\n const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0\n const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0\n const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0\n\n const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedPeerDependencies\n return totalErrors\n}\n"],"mappings":";AAAA,OAAOA,YAAW;;;ACAlB,SAAS,iBAAiB;AAInB,IAAM,iBAAiB,MAAmB;AAC/C,QAAM,SAAS,UAAU,QAAQ,CAAC,cAAc,QAAQ,UAAU,aAAa,GAAG,EAAE,UAAU,QAAQ,OAAO,KAAK,CAAC;AACnH,MAAI,OAAO,OAAO;AAChB,UAAM,OAAO;AAAA,EACf;AACA,SACE,OAAO,OACJ,SAAS,EAGT,MAAM,IAAI,EACV,MAAM,GAAG,EAAE,EACX,IAAI,CAAC,SAAS;AACb,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,CAAC;AAEP;;;ACjBO,IAAM,gBAAgB,CAAC,QAA2B;AACvD,QAAM,YAAY,eAAe,EAAE,KAAK,CAAC,EAAE,KAAK,MAAM,SAAS,GAAG;AAClE,MAAI,CAAC,UAAW,OAAM,IAAI,MAAM,aAAa,GAAG,YAAY;AAC5D,SAAO;AACT;;;ACPA,SAAS,gBAAgB;AAElB,SAAS,gBAAgB,KAAa,SAAiB;AAC5D,SAAO,SAAS,SAAS,EAAE,KAAK,UAAU,KAAK,CAAC;AAClD;;;ACFO,SAAS,UAAUC,OAAc;AACtC,QAAM,mBAAmB,CAAC,qBAAqB;AAC/C,QAAM,iBAAiB,CAAC,oBAAoB,0BAA0B;AACtE,QAAM,WAAW,iBAAiB,QAAQ,aAAW,gBAAgBA,OAAM,OAAO,CAAC;AACnF,QAAM,YAAY,eAAe,QAAQ,aAAW,gBAAgBA,OAAM,OAAO,CAAC;AAElF,SAAO,EAAE,UAAU,UAAU;AAC/B;;;ACTA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEV,SAAS,+BAA+B,iBAAyB;AACtE,QAAM,sBAAsB,KAAK,QAAQ,eAAe;AACxD,QAAM,aAAa,GAAG,aAAa,qBAAqB,MAAM;AAC9D,QAAM,cAAc,KAAK,MAAM,UAAU;AAE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mBAAe,aAAa;AAAA,MAC1B;AAAA,MAAM;AAAA,MAAU;AAAA,MAAS;AAAA,MAAM;AAAA,MAAU;AAAA,IAC3C,CAAC;AAAA,EACH;AAEA,MAAI,cAAc,GAAG;AACnB,YAAQ,KAAK,kBAAkBC,OAAM,IAAI,WAAW,CAAC,yBAAyBA,OAAM,IAAI,QAAG,CAAC,EAAE;AAAA,EAChG,OAAO;AACL,YAAQ,KAAK,0CAA0CA,OAAM,MAAM,QAAG,CAAC,EAAE;AAAA,EAC3E;AACA,SAAO;AACT;","names":["chalk","path","fs","path","fs","path","path","builtinModules","chalk","chalk","chalk","chalk"]}
@@ -1,12 +1,9 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
1
  // src/actions/deploy-major.ts
5
2
  import { readFileSync } from "fs";
6
3
 
7
4
  // src/lib/checkResult.ts
8
5
  import chalk from "chalk";
9
- var checkResult = /* @__PURE__ */ __name((name, result, level = "error", exitOnFail = false) => {
6
+ var checkResult = (name, result, level = "error", exitOnFail = false) => {
10
7
  if (result) {
11
8
  const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
12
9
  const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
@@ -15,23 +12,23 @@ var checkResult = /* @__PURE__ */ __name((name, result, level = "error", exitOnF
15
12
  process.exit(result);
16
13
  }
17
14
  }
18
- }, "checkResult");
15
+ };
19
16
 
20
17
  // src/lib/processEx.ts
21
18
  import chalk2 from "chalk";
22
19
 
23
20
  // src/lib/withError.ts
24
- var withError = /* @__PURE__ */ __name((ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
21
+ var withError = (ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
25
22
  return predicate(ex) ? closure(ex) : void 0;
26
- }, "withError");
23
+ };
27
24
 
28
25
  // src/lib/withErrnoException.ts
29
- var withErrnoException = /* @__PURE__ */ __name((ex, closure) => {
26
+ var withErrnoException = (ex, closure) => {
30
27
  return withError(ex, closure, (ex2) => ex2.errno !== void 0);
31
- }, "withErrnoException");
28
+ };
32
29
 
33
30
  // src/lib/processEx.ts
34
- var processEx = /* @__PURE__ */ __name((ex) => {
31
+ var processEx = (ex) => {
35
32
  const error = typeof ex === "string" ? new Error(ex) : ex;
36
33
  const exitCode = withErrnoException(error, (error2) => {
37
34
  if (error2.code === "ENOENT") {
@@ -48,10 +45,10 @@ var processEx = /* @__PURE__ */ __name((ex) => {
48
45
  return -1;
49
46
  })();
50
47
  process.exit(process.exitCode ?? exitCode);
51
- }, "processEx");
48
+ };
52
49
 
53
50
  // src/lib/safeExit.ts
54
- var safeExit = /* @__PURE__ */ __name((func, exitOnFail = true) => {
51
+ var safeExit = (func, exitOnFail = true) => {
55
52
  try {
56
53
  const result = func();
57
54
  if (result && exitOnFail) {
@@ -61,33 +58,25 @@ var safeExit = /* @__PURE__ */ __name((func, exitOnFail = true) => {
61
58
  } catch (ex) {
62
59
  return processEx(ex);
63
60
  }
64
- }, "safeExit");
61
+ };
65
62
 
66
63
  // src/lib/yarn/workspace/yarnWorkspaces.ts
67
64
  import { spawnSync } from "child_process";
68
- var yarnWorkspaces = /* @__PURE__ */ __name(() => {
69
- const result = spawnSync("yarn", [
70
- "workspaces",
71
- "list",
72
- "--json",
73
- "--recursive"
74
- ], {
75
- encoding: "utf8",
76
- shell: true
77
- });
65
+ var yarnWorkspaces = () => {
66
+ const result = spawnSync("yarn", ["workspaces", "list", "--json", "--recursive"], { encoding: "utf8", shell: true });
78
67
  if (result.error) {
79
68
  throw result.error;
80
69
  }
81
70
  return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
82
71
  return JSON.parse(item);
83
72
  });
84
- }, "yarnWorkspaces");
73
+ };
85
74
 
86
75
  // src/lib/runSteps.ts
87
76
  import { spawnSync as spawnSync2 } from "child_process";
88
77
  import { existsSync } from "fs";
89
78
  import chalk3 from "chalk";
90
- var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages) => {
79
+ var runSteps = (name, steps, exitOnFail = true, messages) => {
91
80
  return safeExit(() => {
92
81
  const pkgName = process.env.npm_package_name;
93
82
  console.log(chalk3.green(`${name} [${pkgName}]`));
@@ -103,10 +92,7 @@ var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages)
103
92
  const status = spawnSync2(command, Array.isArray(args) ? args : args.split(" "), {
104
93
  ...config,
105
94
  encoding: "utf8",
106
- env: {
107
- FORCE_COLOR: "3",
108
- ...process.env
109
- },
95
+ env: { FORCE_COLOR: "3", ...process.env },
110
96
  shell: true,
111
97
  stdio: "inherit"
112
98
  }).status ?? 0;
@@ -115,48 +101,31 @@ var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages)
115
101
  }
116
102
  return totalStatus;
117
103
  }, !!exitOnFail);
118
- }, "runSteps");
104
+ };
119
105
 
120
106
  // src/actions/deploy-major.ts
121
- var privatePackageExcludeList = /* @__PURE__ */ __name(() => {
107
+ var privatePackageExcludeList = () => {
122
108
  const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
123
109
  workspace,
124
- JSON.parse(readFileSync(`${workspace.location}/package.json`, {
125
- encoding: "utf8"
126
- }))
110
+ JSON.parse(readFileSync(`${workspace.location}/package.json`, { encoding: "utf8" }))
127
111
  ]);
128
112
  const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
129
113
  const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
130
114
  return excludeList;
131
- }, "privatePackageExcludeList");
132
- var deployMajor = /* @__PURE__ */ __name(() => {
115
+ };
116
+ var deployMajor = () => {
133
117
  const excludeList = privatePackageExcludeList();
134
118
  if (excludeList.length > 0) {
135
119
  console.log("Excluding private packages from deployment:", excludeList);
136
120
  }
137
121
  return runSteps("Deploy [Major]", [
138
- [
139
- "yarn",
140
- "workspaces foreach --all version major --deferred"
141
- ],
142
- [
143
- "yarn",
144
- "xy clean"
145
- ],
146
- [
147
- "yarn",
148
- "xy build"
149
- ],
150
- [
151
- "yarn",
152
- "version apply --all"
153
- ],
154
- [
155
- "yarn",
156
- `workspaces foreach --all ${excludeList.join(" ")} --parallel npm publish`
157
- ]
122
+ ["yarn", "workspaces foreach --all version major --deferred"],
123
+ ["yarn", "xy clean"],
124
+ ["yarn", "xy build"],
125
+ ["yarn", "version apply --all"],
126
+ ["yarn", `workspaces foreach --all ${excludeList.join(" ")} --parallel npm publish`]
158
127
  ]);
159
- }, "deployMajor");
128
+ };
160
129
  export {
161
130
  deployMajor
162
131
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/actions/deploy-major.ts","../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/lib/runSteps.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\n\nimport type { Workspace } from '../lib/index.ts'\nimport { runSteps, yarnWorkspaces } from '../lib/index.ts'\n\nconst privatePackageExcludeList = () => {\n const possibleDeployablePackages: [Workspace, { private?: boolean }][] = yarnWorkspaces().map(workspace => [workspace,\n JSON.parse(readFileSync(`${workspace.location}/package.json`, { encoding: 'utf8' })) as object])\n\n const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace)\n const excludeList = privatePackages.map(workspace => `--exclude ${workspace.name}`)\n return excludeList\n}\n\nexport const deployMajor = () => {\n const excludeList = privatePackageExcludeList()\n if (excludeList.length > 0) {\n console.log('Excluding private packages from deployment:', excludeList)\n }\n return runSteps('Deploy [Major]', [\n ['yarn', 'workspaces foreach --all version major --deferred'],\n ['yarn', 'xy clean'],\n ['yarn', 'xy build'],\n ['yarn', 'version apply --all'],\n ['yarn', `workspaces foreach --all ${excludeList.join(' ')} --parallel npm publish`],\n ])\n}\n","import chalk from 'chalk'\n\nexport const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {\n if (result) {\n const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'\n const chalkFunc = level === 'error' ? chalk.red : chalk.yellow\n console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))\n if (exitOnFail) {\n process.exit(result)\n }\n }\n}\n","import chalk from 'chalk'\n\nimport { withErrnoException } from './withErrnoException.ts'\nimport { withError } from './withError.ts'\n\nexport const processEx = (ex: unknown) => {\n const error = typeof ex === 'string' ? new Error(ex) : ex\n const exitCode\n = withErrnoException(error, (error) => {\n if (error.code === 'ENOENT') {\n console.error(chalk.red(`'${error.path}' not found.`))\n } else {\n console.error(chalk.red(`Errno: ${error.code}`))\n }\n return error.errno ?? -1\n })\n ?? withError(error, (error) => {\n console.error(chalk.red(`${error.name}: ${error.message}`))\n return -1\n })\n ?? (() => {\n console.error(chalk.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`))\n return -1\n })()\n // This allows us to use a previously set exit code\n process.exit(process.exitCode ?? exitCode)\n}\n","export const withError = <T extends Error = Error>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ex: any,\n closure: (error: T) => number,\n predicate = (ex: T) => (!!ex.name && !!ex.message),\n) => {\n return predicate(ex as T) ? closure(ex as T) : undefined\n}\n","import { withError } from './withError.ts'\n\nexport const withErrnoException = <T extends NodeJS.ErrnoException = NodeJS.ErrnoException>(\n ex: unknown, closure: (error: T) => number,\n) => {\n return withError<T>(ex, closure, (ex: unknown) => (ex as NodeJS.ErrnoException).errno !== undefined)\n}\n","/** Catch child process a crash and returns the code */\n\nimport { processEx } from './processEx.ts'\n\nconst safeExit = (func: () => number, exitOnFail = true): number => {\n try {\n const result = func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nconst safeExitAsync = async (func: () => Promise<number>, exitOnFail = true): Promise<number> => {\n try {\n const result = await func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nexport { safeExit, safeExitAsync }\n","import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { SpawnSyncOptionsWithBufferEncoding } from 'node:child_process'\nimport { spawnSync } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport { safeExit } from './safeExit.ts'\n\nexport type ScriptStep\n = | [/* command */ 'yarn' | 'node' | 'ts-node-script' | 'tsc' | 'jest', /* arg */ string | string[]]\n | [/* command */ string, /* arg */ string | string[], /* config */ SpawnSyncOptionsWithBufferEncoding]\n\nexport const runSteps = (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]): number => {\n return safeExit(() => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let totalStatus = 0\n for (const [i, [command, args, config]] of steps.entries()) {\n if (messages?.[i]) {\n console.log(chalk.gray(messages?.[i]))\n }\n const argList = Array.isArray(args) ? args : args.split(' ')\n if (command === 'node' && !existsSync(argList[0])) {\n throw new Error(`File not found [${argList[0]}]`)\n }\n const status\n = spawnSync(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n encoding: 'utf8',\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).status ?? 0\n checkResult(name, status, 'error', exitOnFail)\n totalStatus += status ?? 0\n }\n return totalStatus\n }, !!exitOnFail)\n}\n"],"mappings":";;;;AAAA,SAASA,oBAAoB;;;ACA7B,OAAOC,WAAW;AAEX,IAAMC,cAAc,wBAACC,MAAcC,QAAgBC,QAA0B,SAASC,aAAa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2B;","names":["readFileSync","chalk","checkResult","name","result","level","exitOnFail","exiting","chalkFunc","chalk","red","yellow","console","process","exit","chalk","withError","ex","closure","predicate","name","message","undefined","withErrnoException","ex","closure","withError","errno","undefined","processEx","ex","error","Error","exitCode","withErrnoException","code","console","chalk","red","path","errno","withError","name","message","JSON","stringify","process","exit","safeExit","func","exitOnFail","result","process","exit","ex","processEx","spawnSync","yarnWorkspaces","result","spawnSync","encoding","shell","error","stdout","toString","split","slice","map","item","JSON","parse","spawnSync","existsSync","chalk","runSteps","name","steps","exitOnFail","messages","safeExit","pkgName","process","env","npm_package_name","console","log","chalk","green","totalStatus","i","command","args","config","entries","gray","argList","Array","isArray","split","existsSync","Error","status","spawnSync","encoding","FORCE_COLOR","shell","stdio","checkResult","privatePackageExcludeList","possibleDeployablePackages","yarnWorkspaces","map","workspace","JSON","parse","readFileSync","location","encoding","privatePackages","filter","_","pkg","private","excludeList","name","deployMajor","length","console","log","runSteps","join"]}
1
+ {"version":3,"sources":["../../src/actions/deploy-major.ts","../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/lib/runSteps.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\n\nimport type { Workspace } from '../lib/index.ts'\nimport { runSteps, yarnWorkspaces } from '../lib/index.ts'\n\nconst privatePackageExcludeList = () => {\n const possibleDeployablePackages: [Workspace, { private?: boolean }][] = yarnWorkspaces().map(workspace => [workspace,\n JSON.parse(readFileSync(`${workspace.location}/package.json`, { encoding: 'utf8' })) as object])\n\n const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace)\n const excludeList = privatePackages.map(workspace => `--exclude ${workspace.name}`)\n return excludeList\n}\n\nexport const deployMajor = () => {\n const excludeList = privatePackageExcludeList()\n if (excludeList.length > 0) {\n console.log('Excluding private packages from deployment:', excludeList)\n }\n return runSteps('Deploy [Major]', [\n ['yarn', 'workspaces foreach --all version major --deferred'],\n ['yarn', 'xy clean'],\n ['yarn', 'xy build'],\n ['yarn', 'version apply --all'],\n ['yarn', `workspaces foreach --all ${excludeList.join(' ')} --parallel npm publish`],\n ])\n}\n","import chalk from 'chalk'\n\nexport const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {\n if (result) {\n const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'\n const chalkFunc = level === 'error' ? chalk.red : chalk.yellow\n console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))\n if (exitOnFail) {\n process.exit(result)\n }\n }\n}\n","import chalk from 'chalk'\n\nimport { withErrnoException } from './withErrnoException.ts'\nimport { withError } from './withError.ts'\n\nexport const processEx = (ex: unknown) => {\n const error = typeof ex === 'string' ? new Error(ex) : ex\n const exitCode\n = withErrnoException(error, (error) => {\n if (error.code === 'ENOENT') {\n console.error(chalk.red(`'${error.path}' not found.`))\n } else {\n console.error(chalk.red(`Errno: ${error.code}`))\n }\n return error.errno ?? -1\n })\n ?? withError(error, (error) => {\n console.error(chalk.red(`${error.name}: ${error.message}`))\n return -1\n })\n ?? (() => {\n console.error(chalk.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`))\n return -1\n })()\n // This allows us to use a previously set exit code\n process.exit(process.exitCode ?? exitCode)\n}\n","export const withError = <T extends Error = Error>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ex: any,\n closure: (error: T) => number,\n predicate = (ex: T) => (!!ex.name && !!ex.message),\n) => {\n return predicate(ex as T) ? closure(ex as T) : undefined\n}\n","import { withError } from './withError.ts'\n\nexport const withErrnoException = <T extends NodeJS.ErrnoException = NodeJS.ErrnoException>(\n ex: unknown, closure: (error: T) => number,\n) => {\n return withError<T>(ex, closure, (ex: unknown) => (ex as NodeJS.ErrnoException).errno !== undefined)\n}\n","/** Catch child process a crash and returns the code */\n\nimport { processEx } from './processEx.ts'\n\nconst safeExit = (func: () => number, exitOnFail = true): number => {\n try {\n const result = func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nconst safeExitAsync = async (func: () => Promise<number>, exitOnFail = true): Promise<number> => {\n try {\n const result = await func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nexport { safeExit, safeExitAsync }\n","import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { SpawnSyncOptionsWithBufferEncoding } from 'node:child_process'\nimport { spawnSync } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport { safeExit } from './safeExit.ts'\n\nexport type ScriptStep\n = | [/* command */ 'yarn' | 'node' | 'ts-node-script' | 'tsc' | 'jest', /* arg */ string | string[]]\n | [/* command */ string, /* arg */ string | string[], /* config */ SpawnSyncOptionsWithBufferEncoding]\n\nexport const runSteps = (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]): number => {\n return safeExit(() => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let totalStatus = 0\n for (const [i, [command, args, config]] of steps.entries()) {\n if (messages?.[i]) {\n console.log(chalk.gray(messages?.[i]))\n }\n const argList = Array.isArray(args) ? args : args.split(' ')\n if (command === 'node' && !existsSync(argList[0])) {\n throw new Error(`File not found [${argList[0]}]`)\n }\n const status\n = spawnSync(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n encoding: 'utf8',\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).status ?? 0\n checkResult(name, status, 'error', exitOnFail)\n totalStatus += status ?? 0\n }\n return totalStatus\n }, !!exitOnFail)\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;;;ACA7B,OAAO,WAAW;AAEX,IAAM,cAAc,CAAC,MAAc,QAAgB,QAA0B,SAAS,aAAa,UAAU;AAClH,MAAI,QAAQ;AACV,UAAM,UAAU,aAAa,sBAAsB;AACnD,UAAM,YAAY,UAAU,UAAU,MAAM,MAAM,MAAM;AACxD,YAAQ,KAAK,EAAE,UAAU,GAAG,IAAI,QAAQ,MAAM,aAAa,OAAO,EAAE,CAAC;AACrE,QAAI,YAAY;AACd,cAAQ,KAAK,MAAM;AAAA,IACrB;AAAA,EACF;AACF;;;ACXA,OAAOA,YAAW;;;ACAX,IAAM,YAAY,CAEvB,IACA,SACA,YAAY,CAACC,QAAW,CAAC,CAACA,IAAG,QAAQ,CAAC,CAACA,IAAG,YACvC;AACH,SAAO,UAAU,EAAO,IAAI,QAAQ,EAAO,IAAI;AACjD;;;ACLO,IAAM,qBAAqB,CAChC,IAAa,YACV;AACH,SAAO,UAAa,IAAI,SAAS,CAACC,QAAiBA,IAA6B,UAAU,MAAS;AACrG;;;AFDO,IAAM,YAAY,CAAC,OAAgB;AACxC,QAAM,QAAQ,OAAO,OAAO,WAAW,IAAI,MAAM,EAAE,IAAI;AACvD,QAAM,WACF,mBAAmB,OAAO,CAACC,WAAU;AACrC,QAAIA,OAAM,SAAS,UAAU;AAC3B,cAAQ,MAAMC,OAAM,IAAI,IAAID,OAAM,IAAI,cAAc,CAAC;AAAA,IACvD,OAAO;AACL,cAAQ,MAAMC,OAAM,IAAI,UAAUD,OAAM,IAAI,EAAE,CAAC;AAAA,IACjD;AACA,WAAOA,OAAM,SAAS;AAAA,EACxB,CAAC,KACE,UAAU,OAAO,CAACA,WAAU;AAC7B,YAAQ,MAAMC,OAAM,IAAI,GAAGD,OAAM,IAAI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AAU;AAAA,IACnB,CAAC,QAAQ,qBAAqB;AAAA,IAC9B,CAAC,QAAQ,4BAA4B,YAAY,KAAK,GAAG,CAAC,yBAAyB;AAAA,EACrF,CAAC;AACH;","names":["chalk","ex","ex","error","chalk","spawnSync","chalk","chalk","spawnSync"]}
@@ -1,12 +1,9 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
1
  // src/actions/deploy-minor.ts
5
2
  import { readFileSync } from "fs";
6
3
 
7
4
  // src/lib/checkResult.ts
8
5
  import chalk from "chalk";
9
- var checkResult = /* @__PURE__ */ __name((name, result, level = "error", exitOnFail = false) => {
6
+ var checkResult = (name, result, level = "error", exitOnFail = false) => {
10
7
  if (result) {
11
8
  const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
12
9
  const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
@@ -15,23 +12,23 @@ var checkResult = /* @__PURE__ */ __name((name, result, level = "error", exitOnF
15
12
  process.exit(result);
16
13
  }
17
14
  }
18
- }, "checkResult");
15
+ };
19
16
 
20
17
  // src/lib/processEx.ts
21
18
  import chalk2 from "chalk";
22
19
 
23
20
  // src/lib/withError.ts
24
- var withError = /* @__PURE__ */ __name((ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
21
+ var withError = (ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
25
22
  return predicate(ex) ? closure(ex) : void 0;
26
- }, "withError");
23
+ };
27
24
 
28
25
  // src/lib/withErrnoException.ts
29
- var withErrnoException = /* @__PURE__ */ __name((ex, closure) => {
26
+ var withErrnoException = (ex, closure) => {
30
27
  return withError(ex, closure, (ex2) => ex2.errno !== void 0);
31
- }, "withErrnoException");
28
+ };
32
29
 
33
30
  // src/lib/processEx.ts
34
- var processEx = /* @__PURE__ */ __name((ex) => {
31
+ var processEx = (ex) => {
35
32
  const error = typeof ex === "string" ? new Error(ex) : ex;
36
33
  const exitCode = withErrnoException(error, (error2) => {
37
34
  if (error2.code === "ENOENT") {
@@ -48,10 +45,10 @@ var processEx = /* @__PURE__ */ __name((ex) => {
48
45
  return -1;
49
46
  })();
50
47
  process.exit(process.exitCode ?? exitCode);
51
- }, "processEx");
48
+ };
52
49
 
53
50
  // src/lib/safeExit.ts
54
- var safeExit = /* @__PURE__ */ __name((func, exitOnFail = true) => {
51
+ var safeExit = (func, exitOnFail = true) => {
55
52
  try {
56
53
  const result = func();
57
54
  if (result && exitOnFail) {
@@ -61,33 +58,25 @@ var safeExit = /* @__PURE__ */ __name((func, exitOnFail = true) => {
61
58
  } catch (ex) {
62
59
  return processEx(ex);
63
60
  }
64
- }, "safeExit");
61
+ };
65
62
 
66
63
  // src/lib/yarn/workspace/yarnWorkspaces.ts
67
64
  import { spawnSync } from "child_process";
68
- var yarnWorkspaces = /* @__PURE__ */ __name(() => {
69
- const result = spawnSync("yarn", [
70
- "workspaces",
71
- "list",
72
- "--json",
73
- "--recursive"
74
- ], {
75
- encoding: "utf8",
76
- shell: true
77
- });
65
+ var yarnWorkspaces = () => {
66
+ const result = spawnSync("yarn", ["workspaces", "list", "--json", "--recursive"], { encoding: "utf8", shell: true });
78
67
  if (result.error) {
79
68
  throw result.error;
80
69
  }
81
70
  return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
82
71
  return JSON.parse(item);
83
72
  });
84
- }, "yarnWorkspaces");
73
+ };
85
74
 
86
75
  // src/lib/runSteps.ts
87
76
  import { spawnSync as spawnSync2 } from "child_process";
88
77
  import { existsSync } from "fs";
89
78
  import chalk3 from "chalk";
90
- var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages) => {
79
+ var runSteps = (name, steps, exitOnFail = true, messages) => {
91
80
  return safeExit(() => {
92
81
  const pkgName = process.env.npm_package_name;
93
82
  console.log(chalk3.green(`${name} [${pkgName}]`));
@@ -103,10 +92,7 @@ var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages)
103
92
  const status = spawnSync2(command, Array.isArray(args) ? args : args.split(" "), {
104
93
  ...config,
105
94
  encoding: "utf8",
106
- env: {
107
- FORCE_COLOR: "3",
108
- ...process.env
109
- },
95
+ env: { FORCE_COLOR: "3", ...process.env },
110
96
  shell: true,
111
97
  stdio: "inherit"
112
98
  }).status ?? 0;
@@ -115,48 +101,31 @@ var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages)
115
101
  }
116
102
  return totalStatus;
117
103
  }, !!exitOnFail);
118
- }, "runSteps");
104
+ };
119
105
 
120
106
  // src/actions/deploy-minor.ts
121
- var privatePackageExcludeList = /* @__PURE__ */ __name(() => {
107
+ var privatePackageExcludeList = () => {
122
108
  const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
123
109
  workspace,
124
- JSON.parse(readFileSync(`${workspace.location}/package.json`, {
125
- encoding: "utf8"
126
- }))
110
+ JSON.parse(readFileSync(`${workspace.location}/package.json`, { encoding: "utf8" }))
127
111
  ]);
128
112
  const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
129
113
  const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
130
114
  return excludeList;
131
- }, "privatePackageExcludeList");
132
- var deployMinor = /* @__PURE__ */ __name(() => {
115
+ };
116
+ var deployMinor = () => {
133
117
  const excludeList = privatePackageExcludeList();
134
118
  if (excludeList.length > 0) {
135
119
  console.log("Excluding private packages from deployment:", excludeList);
136
120
  }
137
121
  return runSteps("Deploy [Minor]", [
138
- [
139
- "yarn",
140
- "workspaces foreach --all version minor --deferred"
141
- ],
142
- [
143
- "yarn",
144
- "xy clean"
145
- ],
146
- [
147
- "yarn",
148
- "xy build"
149
- ],
150
- [
151
- "yarn",
152
- "version apply --all"
153
- ],
154
- [
155
- "yarn",
156
- `workspaces foreach --all ${excludeList.join(" ")} --parallel npm publish`
157
- ]
122
+ ["yarn", "workspaces foreach --all version minor --deferred"],
123
+ ["yarn", "xy clean"],
124
+ ["yarn", "xy build"],
125
+ ["yarn", "version apply --all"],
126
+ ["yarn", `workspaces foreach --all ${excludeList.join(" ")} --parallel npm publish`]
158
127
  ]);
159
- }, "deployMinor");
128
+ };
160
129
  export {
161
130
  deployMinor
162
131
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/actions/deploy-minor.ts","../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/lib/runSteps.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\n\nimport type { Workspace } from '../lib/index.ts'\nimport { runSteps, yarnWorkspaces } from '../lib/index.ts'\n\nconst privatePackageExcludeList = () => {\n const possibleDeployablePackages: [Workspace, { private?: boolean }][] = yarnWorkspaces().map(workspace => [workspace,\n JSON.parse(readFileSync(`${workspace.location}/package.json`, { encoding: 'utf8' })) as object])\n\n const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace)\n const excludeList = privatePackages.map(workspace => `--exclude ${workspace.name}`)\n return excludeList\n}\n\nexport const deployMinor = () => {\n const excludeList = privatePackageExcludeList()\n if (excludeList.length > 0) {\n console.log('Excluding private packages from deployment:', excludeList)\n }\n return runSteps('Deploy [Minor]', [\n ['yarn', 'workspaces foreach --all version minor --deferred'],\n ['yarn', 'xy clean'],\n ['yarn', 'xy build'],\n ['yarn', 'version apply --all'],\n ['yarn', `workspaces foreach --all ${excludeList.join(' ')} --parallel npm publish`],\n ])\n}\n","import chalk from 'chalk'\n\nexport const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {\n if (result) {\n const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'\n const chalkFunc = level === 'error' ? chalk.red : chalk.yellow\n console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))\n if (exitOnFail) {\n process.exit(result)\n }\n }\n}\n","import chalk from 'chalk'\n\nimport { withErrnoException } from './withErrnoException.ts'\nimport { withError } from './withError.ts'\n\nexport const processEx = (ex: unknown) => {\n const error = typeof ex === 'string' ? new Error(ex) : ex\n const exitCode\n = withErrnoException(error, (error) => {\n if (error.code === 'ENOENT') {\n console.error(chalk.red(`'${error.path}' not found.`))\n } else {\n console.error(chalk.red(`Errno: ${error.code}`))\n }\n return error.errno ?? -1\n })\n ?? withError(error, (error) => {\n console.error(chalk.red(`${error.name}: ${error.message}`))\n return -1\n })\n ?? (() => {\n console.error(chalk.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`))\n return -1\n })()\n // This allows us to use a previously set exit code\n process.exit(process.exitCode ?? exitCode)\n}\n","export const withError = <T extends Error = Error>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ex: any,\n closure: (error: T) => number,\n predicate = (ex: T) => (!!ex.name && !!ex.message),\n) => {\n return predicate(ex as T) ? closure(ex as T) : undefined\n}\n","import { withError } from './withError.ts'\n\nexport const withErrnoException = <T extends NodeJS.ErrnoException = NodeJS.ErrnoException>(\n ex: unknown, closure: (error: T) => number,\n) => {\n return withError<T>(ex, closure, (ex: unknown) => (ex as NodeJS.ErrnoException).errno !== undefined)\n}\n","/** Catch child process a crash and returns the code */\n\nimport { processEx } from './processEx.ts'\n\nconst safeExit = (func: () => number, exitOnFail = true): number => {\n try {\n const result = func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nconst safeExitAsync = async (func: () => Promise<number>, exitOnFail = true): Promise<number> => {\n try {\n const result = await func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nexport { safeExit, safeExitAsync }\n","import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { SpawnSyncOptionsWithBufferEncoding } from 'node:child_process'\nimport { spawnSync } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport { safeExit } from './safeExit.ts'\n\nexport type ScriptStep\n = | [/* command */ 'yarn' | 'node' | 'ts-node-script' | 'tsc' | 'jest', /* arg */ string | string[]]\n | [/* command */ string, /* arg */ string | string[], /* config */ SpawnSyncOptionsWithBufferEncoding]\n\nexport const runSteps = (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]): number => {\n return safeExit(() => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let totalStatus = 0\n for (const [i, [command, args, config]] of steps.entries()) {\n if (messages?.[i]) {\n console.log(chalk.gray(messages?.[i]))\n }\n const argList = Array.isArray(args) ? args : args.split(' ')\n if (command === 'node' && !existsSync(argList[0])) {\n throw new Error(`File not found [${argList[0]}]`)\n }\n const status\n = spawnSync(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n encoding: 'utf8',\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).status ?? 0\n checkResult(name, status, 'error', exitOnFail)\n totalStatus += status ?? 0\n }\n return totalStatus\n }, !!exitOnFail)\n}\n"],"mappings":";;;;AAAA,SAASA,oBAAoB;;;ACA7B,OAAOC,WAAW;AAEX,IAAMC,cAAc,wBAACC,MAAcC,QAAgBC,QAA0B,SAASC,aAAa,UAAK;AAC7G,MAAIF,QAAQ;AACV,UAAMG,UAAUD,aAAa,sBAAsB;AACnD,UAAME,YAAYH,UAAU,UAAUI,MAAMC,MAAMD,MAAME;AACxDC,YAAQP,KAAAA,EAAOG,UAAU,GAAGL,IAAAA,QAAYC,MAAAA,aAAmBG,OAAAA,EAAS,CAA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AAOA,KAAKO,MAAM,GAAA,GAAM;QACjE,GAAGN;QACHW,UAAU;QACVrB,KAAK;UAAEsB,aAAa;UAAK,GAAGvB,QAAQC;QAAI;QACxCuB,OAAO;QACPC,OAAO;MACT,CAAA,EAAGL,UAAU;AACfM,kBAAYhC,MAAM0B,QAAQ,SAASxB,UAAAA;AACnCW,qBAAea,UAAU;IAC3B;AACA,WAAOb;EACT,GAAG,CAAC,CAACX,UAAAA;AACP,GA1BwB;;;APRxB,IAAM+B,4BAA4B,6BAAA;AAChC,QAAMC,6BAAmEC,eAAAA,EAAiBC,IAAIC,CAAAA,cAAa;IAACA;IAC1GC,KAAKC,MAAMC,aAAa,GAAGH,UAAUI,QAAQ,iBAAiB;MAAEC,UAAU;IAAO,CAAA,CAAA;GAAc;AAEjG,QAAMC,kBAAkBT,2BAA2BU,OAAO,CAAC,CAACC,GAAGC,GAAAA,MAASA,IAAIC,OAAO,EAAEX,IAAI,CAAC,CAACC,SAAAA,MAAeA,SAAAA;AAC1G,QAAMW,cAAcL,gBAAgBP,IAAIC,CAAAA,cAAa,aAAaA,UAAUY,IAAI,EAAE;AAClF,SAAOD;AACT,GAPkC;AAS3B,IAAME,cAAc,6BAAA;AACzB,QAAMF,cAAcf,0BAAAA;AACpB,MAAIe,YAAYG,SAAS,GAAG;AAC1BC,YAAQC,IAAI,+CAA+CL,WAAAA;EAC7D;AACA,SAAOM,SAAS,kBAAkB;IAChC;MAAC;MAAQ;;IACT;MAAC;MAAQ;;IACT;MAAC;MAAQ;;IACT;MAAC;MAAQ;;IACT;MAAC;MAAQ,4BAA4BN,YAAYO,KAAK,GAAA,CAAA;;GACvD;AACH,GAZ2B;","names":["readFileSync","chalk","checkResult","name","result","level","exitOnFail","exiting","chalkFunc","chalk","red","yellow","console","process","exit","chalk","withError","ex","closure","predicate","name","message","undefined","withErrnoException","ex","closure","withError","errno","undefined","processEx","ex","error","Error","exitCode","withErrnoException","code","console","chalk","red","path","errno","withError","name","message","JSON","stringify","process","exit","safeExit","func","exitOnFail","result","process","exit","ex","processEx","spawnSync","yarnWorkspaces","result","spawnSync","encoding","shell","error","stdout","toString","split","slice","map","item","JSON","parse","spawnSync","existsSync","chalk","runSteps","name","steps","exitOnFail","messages","safeExit","pkgName","process","env","npm_package_name","console","log","chalk","green","totalStatus","i","command","args","config","entries","gray","argList","Array","isArray","split","existsSync","Error","status","spawnSync","encoding","FORCE_COLOR","shell","stdio","checkResult","privatePackageExcludeList","possibleDeployablePackages","yarnWorkspaces","map","workspace","JSON","parse","readFileSync","location","encoding","privatePackages","filter","_","pkg","private","excludeList","name","deployMinor","length","console","log","runSteps","join"]}
1
+ {"version":3,"sources":["../../src/actions/deploy-minor.ts","../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/lib/runSteps.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\n\nimport type { Workspace } from '../lib/index.ts'\nimport { runSteps, yarnWorkspaces } from '../lib/index.ts'\n\nconst privatePackageExcludeList = () => {\n const possibleDeployablePackages: [Workspace, { private?: boolean }][] = yarnWorkspaces().map(workspace => [workspace,\n JSON.parse(readFileSync(`${workspace.location}/package.json`, { encoding: 'utf8' })) as object])\n\n const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace)\n const excludeList = privatePackages.map(workspace => `--exclude ${workspace.name}`)\n return excludeList\n}\n\nexport const deployMinor = () => {\n const excludeList = privatePackageExcludeList()\n if (excludeList.length > 0) {\n console.log('Excluding private packages from deployment:', excludeList)\n }\n return runSteps('Deploy [Minor]', [\n ['yarn', 'workspaces foreach --all version minor --deferred'],\n ['yarn', 'xy clean'],\n ['yarn', 'xy build'],\n ['yarn', 'version apply --all'],\n ['yarn', `workspaces foreach --all ${excludeList.join(' ')} --parallel npm publish`],\n ])\n}\n","import chalk from 'chalk'\n\nexport const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {\n if (result) {\n const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'\n const chalkFunc = level === 'error' ? chalk.red : chalk.yellow\n console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))\n if (exitOnFail) {\n process.exit(result)\n }\n }\n}\n","import chalk from 'chalk'\n\nimport { withErrnoException } from './withErrnoException.ts'\nimport { withError } from './withError.ts'\n\nexport const processEx = (ex: unknown) => {\n const error = typeof ex === 'string' ? new Error(ex) : ex\n const exitCode\n = withErrnoException(error, (error) => {\n if (error.code === 'ENOENT') {\n console.error(chalk.red(`'${error.path}' not found.`))\n } else {\n console.error(chalk.red(`Errno: ${error.code}`))\n }\n return error.errno ?? -1\n })\n ?? withError(error, (error) => {\n console.error(chalk.red(`${error.name}: ${error.message}`))\n return -1\n })\n ?? (() => {\n console.error(chalk.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`))\n return -1\n })()\n // This allows us to use a previously set exit code\n process.exit(process.exitCode ?? exitCode)\n}\n","export const withError = <T extends Error = Error>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ex: any,\n closure: (error: T) => number,\n predicate = (ex: T) => (!!ex.name && !!ex.message),\n) => {\n return predicate(ex as T) ? closure(ex as T) : undefined\n}\n","import { withError } from './withError.ts'\n\nexport const withErrnoException = <T extends NodeJS.ErrnoException = NodeJS.ErrnoException>(\n ex: unknown, closure: (error: T) => number,\n) => {\n return withError<T>(ex, closure, (ex: unknown) => (ex as NodeJS.ErrnoException).errno !== undefined)\n}\n","/** Catch child process a crash and returns the code */\n\nimport { processEx } from './processEx.ts'\n\nconst safeExit = (func: () => number, exitOnFail = true): number => {\n try {\n const result = func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nconst safeExitAsync = async (func: () => Promise<number>, exitOnFail = true): Promise<number> => {\n try {\n const result = await func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nexport { safeExit, safeExitAsync }\n","import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { SpawnSyncOptionsWithBufferEncoding } from 'node:child_process'\nimport { spawnSync } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport { safeExit } from './safeExit.ts'\n\nexport type ScriptStep\n = | [/* command */ 'yarn' | 'node' | 'ts-node-script' | 'tsc' | 'jest', /* arg */ string | string[]]\n | [/* command */ string, /* arg */ string | string[], /* config */ SpawnSyncOptionsWithBufferEncoding]\n\nexport const runSteps = (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]): number => {\n return safeExit(() => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let totalStatus = 0\n for (const [i, [command, args, config]] of steps.entries()) {\n if (messages?.[i]) {\n console.log(chalk.gray(messages?.[i]))\n }\n const argList = Array.isArray(args) ? args : args.split(' ')\n if (command === 'node' && !existsSync(argList[0])) {\n throw new Error(`File not found [${argList[0]}]`)\n }\n const status\n = spawnSync(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n encoding: 'utf8',\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).status ?? 0\n checkResult(name, status, 'error', exitOnFail)\n totalStatus += status ?? 0\n }\n return totalStatus\n }, !!exitOnFail)\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;;;ACA7B,OAAO,WAAW;AAEX,IAAM,cAAc,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