@xylabs/ts-scripts-yarn3 5.0.32 → 5.0.33

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 (152) hide show
  1. package/dist/actions/build.mjs.map +1 -1
  2. package/dist/actions/clean-docs.mjs.map +1 -1
  3. package/dist/actions/clean-eslint.mjs.map +1 -1
  4. package/dist/actions/clean-jest.mjs.map +1 -1
  5. package/dist/actions/clean.mjs.map +1 -1
  6. package/dist/actions/compile.mjs.map +1 -1
  7. package/dist/actions/copy-assets.mjs.map +1 -1
  8. package/dist/actions/cycle.mjs.map +1 -1
  9. package/dist/actions/dead.mjs.map +1 -1
  10. package/dist/actions/deploy-major.mjs.map +1 -1
  11. package/dist/actions/deploy-minor.mjs.map +1 -1
  12. package/dist/actions/deploy-next.mjs.map +1 -1
  13. package/dist/actions/deploy.mjs.map +1 -1
  14. package/dist/actions/deps.mjs.map +1 -1
  15. package/dist/actions/dupdeps.mjs.map +1 -1
  16. package/dist/actions/fix.mjs.map +1 -1
  17. package/dist/actions/gen-docs.mjs.map +1 -1
  18. package/dist/actions/gitignore-gen.mjs.map +1 -1
  19. package/dist/actions/gitlint-fix.mjs.map +1 -1
  20. package/dist/actions/gitlint.mjs.map +1 -1
  21. package/dist/actions/index.mjs.map +1 -1
  22. package/dist/actions/license.mjs.map +1 -1
  23. package/dist/actions/lint-clean.mjs.map +1 -1
  24. package/dist/actions/lint-profile.mjs.map +1 -1
  25. package/dist/actions/lint.mjs.map +1 -1
  26. package/dist/actions/npmignore-gen.mjs.map +1 -1
  27. package/dist/actions/package/clean-outputs.mjs.map +1 -1
  28. package/dist/actions/package/clean-typescript.mjs.map +1 -1
  29. package/dist/actions/package/clean.mjs.map +1 -1
  30. package/dist/actions/package/compile/buildEntries.mjs.map +1 -1
  31. package/dist/actions/package/compile/compile.mjs.map +1 -1
  32. package/dist/actions/package/compile/copyTypeFiles.mjs.map +1 -1
  33. package/dist/actions/package/compile/getCompilerOptions.mjs.map +1 -1
  34. package/dist/actions/package/compile/index.mjs.map +1 -1
  35. package/dist/actions/package/compile/inputs.mjs.map +1 -1
  36. package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -1
  37. package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -1
  38. package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
  39. package/dist/actions/package/copy-assets.mjs.map +1 -1
  40. package/dist/actions/package/deps.mjs.map +1 -1
  41. package/dist/actions/package/gen-docs.mjs.map +1 -1
  42. package/dist/actions/package/index.mjs.map +1 -1
  43. package/dist/actions/package/publint.mjs.map +1 -1
  44. package/dist/actions/package/recompile.mjs.map +1 -1
  45. package/dist/actions/publint.mjs.map +1 -1
  46. package/dist/actions/rebuild.mjs.map +1 -1
  47. package/dist/actions/recompile.mjs.map +1 -1
  48. package/dist/actions/reinstall.mjs.map +1 -1
  49. package/dist/actions/relint.mjs.map +1 -1
  50. package/dist/actions/retest.mjs.map +1 -1
  51. package/dist/actions/sonar.mjs.map +1 -1
  52. package/dist/actions/statics.mjs.map +1 -1
  53. package/dist/actions/test.mjs.map +1 -1
  54. package/dist/actions/up.mjs.map +1 -1
  55. package/dist/actions/updo.mjs.map +1 -1
  56. package/dist/actions/upplug.mjs.map +1 -1
  57. package/dist/actions/upyarn.mjs.map +1 -1
  58. package/dist/actions/yarn3only.mjs.map +1 -1
  59. package/dist/bin/build.mjs.map +1 -1
  60. package/dist/bin/clean.mjs.map +1 -1
  61. package/dist/bin/compile-only.mjs.map +1 -1
  62. package/dist/bin/compile.mjs.map +1 -1
  63. package/dist/bin/cycle.mjs.map +1 -1
  64. package/dist/bin/dead.mjs.map +1 -1
  65. package/dist/bin/deploy-major.mjs.map +1 -1
  66. package/dist/bin/deploy-minor.mjs.map +1 -1
  67. package/dist/bin/deploy-next.mjs.map +1 -1
  68. package/dist/bin/deploy.mjs.map +1 -1
  69. package/dist/bin/deps.mjs.map +1 -1
  70. package/dist/bin/fix.mjs.map +1 -1
  71. package/dist/bin/gen-docs.mjs.map +1 -1
  72. package/dist/bin/gitlint-fix.mjs.map +1 -1
  73. package/dist/bin/gitlint.mjs.map +1 -1
  74. package/dist/bin/license.mjs.map +1 -1
  75. package/dist/bin/lint-clean.mjs.map +1 -1
  76. package/dist/bin/lint-fast.mjs.map +1 -1
  77. package/dist/bin/lint-profile.mjs.map +1 -1
  78. package/dist/bin/lint.mjs.map +1 -1
  79. package/dist/bin/package/build-only.mjs.map +1 -1
  80. package/dist/bin/package/build.mjs.map +1 -1
  81. package/dist/bin/package/clean-outputs.mjs.map +1 -1
  82. package/dist/bin/package/clean-typescript.mjs.map +1 -1
  83. package/dist/bin/package/clean.mjs.map +1 -1
  84. package/dist/bin/package/compile-only.mjs.map +1 -1
  85. package/dist/bin/package/compile-tsup.mjs.map +1 -1
  86. package/dist/bin/package/compile.mjs.map +1 -1
  87. package/dist/bin/package/copy-assets-cjs.mjs.map +1 -1
  88. package/dist/bin/package/copy-assets-esm.mjs.map +1 -1
  89. package/dist/bin/package/deps.mjs.map +1 -1
  90. package/dist/bin/package/gen-docs.mjs.map +1 -1
  91. package/dist/bin/package/publint.mjs.map +1 -1
  92. package/dist/bin/package/recompile.mjs.map +1 -1
  93. package/dist/bin/publint.mjs.map +1 -1
  94. package/dist/bin/rebuild.mjs.map +1 -1
  95. package/dist/bin/recompile.mjs.map +1 -1
  96. package/dist/bin/reinstall.mjs.map +1 -1
  97. package/dist/bin/relint.mjs.map +1 -1
  98. package/dist/bin/sonar.mjs.map +1 -1
  99. package/dist/bin/test.mjs.map +1 -1
  100. package/dist/bin/up.mjs.map +1 -1
  101. package/dist/bin/updo.mjs.map +1 -1
  102. package/dist/bin/upplug.mjs.map +1 -1
  103. package/dist/bin/upyarn.mjs.map +1 -1
  104. package/dist/bin/xy-ts.mjs.map +1 -1
  105. package/dist/bin/xy.mjs.map +1 -1
  106. package/dist/bin/yarn3only.mjs.map +1 -1
  107. package/dist/index.mjs.map +1 -1
  108. package/dist/lib/checkResult.mjs.map +1 -1
  109. package/dist/lib/createBuildConfig.mjs.map +1 -1
  110. package/dist/lib/defaultBuildConfig.mjs.map +1 -1
  111. package/dist/lib/deleteGlob.mjs.map +1 -1
  112. package/dist/lib/dependencies/DuplicateDetector.mjs.map +1 -1
  113. package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +1 -1
  114. package/dist/lib/dependencies/index.mjs.map +1 -1
  115. package/dist/lib/file/ReadFileSyncOptions.mjs.map +1 -1
  116. package/dist/lib/file/constants.mjs.map +1 -1
  117. package/dist/lib/file/fileLines.mjs.map +1 -1
  118. package/dist/lib/file/index.mjs.map +1 -1
  119. package/dist/lib/file/tryReadFileSync.mjs.map +1 -1
  120. package/dist/lib/generateIgnoreFiles.mjs.map +1 -1
  121. package/dist/lib/index.mjs.map +1 -1
  122. package/dist/lib/jsonFormatters.mjs.map +1 -1
  123. package/dist/lib/loadConfig.mjs.map +1 -1
  124. package/dist/lib/parsedPackageJSON.mjs.map +1 -1
  125. package/dist/lib/processEx.mjs.map +1 -1
  126. package/dist/lib/runSteps.mjs.map +1 -1
  127. package/dist/lib/runStepsAsync.mjs.map +1 -1
  128. package/dist/lib/runXy.mjs.map +1 -1
  129. package/dist/lib/runXyWithWarning.mjs.map +1 -1
  130. package/dist/lib/safeExit.mjs.map +1 -1
  131. package/dist/lib/string/empty.mjs.map +1 -1
  132. package/dist/lib/string/index.mjs.map +1 -1
  133. package/dist/lib/string/union.mjs.map +1 -1
  134. package/dist/lib/withErrnoException.mjs.map +1 -1
  135. package/dist/lib/withError.mjs.map +1 -1
  136. package/dist/lib/yarn/index.mjs.map +1 -1
  137. package/dist/lib/yarn/isYarnVersionOrGreater.mjs.map +1 -1
  138. package/dist/lib/yarn/workspace/index.mjs.map +1 -1
  139. package/dist/lib/yarn/workspace/yarnWorkspace.mjs.map +1 -1
  140. package/dist/lib/yarn/workspace/yarnWorkspaces.mjs.map +1 -1
  141. package/dist/lib/yarn/yarnInitCwd.mjs.map +1 -1
  142. package/dist/loadPackageConfig.mjs.map +1 -1
  143. package/dist/xy/index.mjs.map +1 -1
  144. package/dist/xy/param.mjs.map +1 -1
  145. package/dist/xy/xy.mjs.map +1 -1
  146. package/dist/xy/xyBuildCommands.mjs.map +1 -1
  147. package/dist/xy/xyCommonCommands.mjs.map +1 -1
  148. package/dist/xy/xyDeployCommands.mjs.map +1 -1
  149. package/dist/xy/xyInstallCommands.mjs.map +1 -1
  150. package/dist/xy/xyLintCommands.mjs.map +1 -1
  151. package/dist/xy/xyParseOptions.mjs.map +1 -1
  152. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"sources":["deps.ts","checkResult.ts","processEx.ts","withError.ts","withErrnoException.ts","safeExit.ts","runSteps.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { runSteps, ScriptStep } from '../lib/index.ts'\n\nexport interface DepsParams {\n incremental?: boolean\n jobs?: number\n pkg?: string\n verbose?: boolean\n}\n\nexport interface DepsPackageParams { pkg: string }\n\nexport const deps = ({ pkg, incremental }: DepsParams) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n pkg ? depsPackage({ pkg }) : depsAll({ incremental })\n // returning 0 here since we never wants deps to be fatal\n return 0\n}\n\nexport const depsPackage = ({ pkg }: DepsPackageParams) => {\n const steps: ScriptStep[] = [['yarn', ['workspace', pkg, 'run', 'package-deps']]]\n\n return runSteps(`Deps [${pkg}]`, [...steps])\n}\n\nexport const depsAll = ({\n incremental, jobs, verbose,\n}: DepsParams) => {\n const start = Date.now()\n const jobsOptions = jobs ? ['-j', `${jobs}`] : []\n const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n if (jobs) {\n console.log(chalk.blue(`Jobs set to [${jobs}]`))\n }\n const incrementalOptions = incremental ? ['--since', '-pA'] : ['-pA']\n const steps: ScriptStep[] = [['yarn', ['workspaces', 'foreach', ...jobsOptions, ...incrementalOptions, ...verboseOptions, 'run', 'package-deps']]]\n\n const result = runSteps(`Deps${incremental ? '-Incremental' : ''} [All]`, [...steps])\n console.log(`${chalk.gray('Dep checked in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`)\n return result\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, SpawnSyncOptionsWithBufferEncoding } 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,OAAOA,YAAW;;;ACAlB,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,YAA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AAM+B,OAAO,wBAAC,EAAEC,KAAKC,YAAW,MAAc;AAEnDD,QAAME,YAAY;IAAEF;EAAI,CAAA,IAAKG,QAAQ;IAAEF;EAAY,CAAA;AAEnD,SAAO;AACT,GALoB;AAOb,IAAMC,cAAc,wBAAC,EAAEF,IAAG,MAAqB;AACpD,QAAMI,QAAsB;IAAC;MAAC;MAAQ;QAAC;QAAaJ;QAAK;QAAO;;;;AAEhE,SAAOK,SAAS,SAASL,GAAAA,KAAQ;OAAII;GAAM;AAC7C,GAJ2B;AAMpB,IAAMD,UAAU,wBAAC,EACtBF,aAAaK,MAAMC,QAAO,MACf;AACX,QAAMC,QAAQC,KAAKC,IAAG;AACtB,QAAMC,cAAcL,OAAO;IAAC;IAAM,GAAGA,IAAAA;MAAU,CAAA;AAC/C,QAAMM,iBAAiBL,UAAU;IAAC;MAAe;IAAC;;AAClD,MAAID,MAAM;AACRO,YAAQC,IAAIC,OAAMC,KAAK,gBAAgBV,IAAAA,GAAO,CAAA;EAChD;AACA,QAAMW,qBAAqBhB,cAAc;IAAC;IAAW;MAAS;IAAC;;AAC/D,QAAMG,QAAsB;IAAC;MAAC;MAAQ;QAAC;QAAc;WAAcO;WAAgBM;WAAuBL;QAAgB;QAAO;;;;AAEjI,QAAMM,SAASb,SAAS,OAAOJ,cAAc,iBAAiB,EAAA,UAAY;OAAIG;GAAM;AACpFS,UAAQC,IAAI,GAAGC,OAAMI,KAAK,gBAAA,CAAA,KAAsBJ,OAAMK,UAAUX,KAAKC,IAAG,IAAKF,SAAS,KAAMa,QAAQ,CAAA,CAAA,CAAA,KAAQN,OAAMI,KAAK,SAAA,CAAA,EAAY;AACnI,SAAOD;AACT,GAfuB;","names":["chalk","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","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","deps","pkg","incremental","depsPackage","depsAll","steps","runSteps","jobs","verbose","start","Date","now","jobsOptions","verboseOptions","console","log","chalk","blue","incrementalOptions","result","gray","magenta","toFixed"]}
1
+ {"version":3,"sources":["../../src/actions/deps.ts","../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/runSteps.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { runSteps, ScriptStep } from '../lib/index.ts'\n\nexport interface DepsParams {\n incremental?: boolean\n jobs?: number\n pkg?: string\n verbose?: boolean\n}\n\nexport interface DepsPackageParams { pkg: string }\n\nexport const deps = ({ pkg, incremental }: DepsParams) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n pkg ? depsPackage({ pkg }) : depsAll({ incremental })\n // returning 0 here since we never wants deps to be fatal\n return 0\n}\n\nexport const depsPackage = ({ pkg }: DepsPackageParams) => {\n const steps: ScriptStep[] = [['yarn', ['workspace', pkg, 'run', 'package-deps']]]\n\n return runSteps(`Deps [${pkg}]`, [...steps])\n}\n\nexport const depsAll = ({\n incremental, jobs, verbose,\n}: DepsParams) => {\n const start = Date.now()\n const jobsOptions = jobs ? ['-j', `${jobs}`] : []\n const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n if (jobs) {\n console.log(chalk.blue(`Jobs set to [${jobs}]`))\n }\n const incrementalOptions = incremental ? ['--since', '-pA'] : ['-pA']\n const steps: ScriptStep[] = [['yarn', ['workspaces', 'foreach', ...jobsOptions, ...incrementalOptions, ...verboseOptions, 'run', 'package-deps']]]\n\n const result = runSteps(`Deps${incremental ? '-Incremental' : ''} [All]`, [...steps])\n console.log(`${chalk.gray('Dep checked in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`)\n return result\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, SpawnSyncOptionsWithBufferEncoding } 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,OAAOA,YAAW;;;ACAlB,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,MAA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,GA1BwB;;;ANCjB,IAAM+B,OAAO,wBAAC,EAAEC,KAAKC,YAAW,MAAc;AAEnDD,QAAME,YAAY;IAAEF;EAAI,CAAA,IAAKG,QAAQ;IAAEF;EAAY,CAAA;AAEnD,SAAO;AACT,GALoB;AAOb,IAAMC,cAAc,wBAAC,EAAEF,IAAG,MAAqB;AACpD,QAAMI,QAAsB;IAAC;MAAC;MAAQ;QAAC;QAAaJ;QAAK;QAAO;;;;AAEhE,SAAOK,SAAS,SAASL,GAAAA,KAAQ;OAAII;GAAM;AAC7C,GAJ2B;AAMpB,IAAMD,UAAU,wBAAC,EACtBF,aAAaK,MAAMC,QAAO,MACf;AACX,QAAMC,QAAQC,KAAKC,IAAG;AACtB,QAAMC,cAAcL,OAAO;IAAC;IAAM,GAAGA,IAAAA;MAAU,CAAA;AAC/C,QAAMM,iBAAiBL,UAAU;IAAC;MAAe;IAAC;;AAClD,MAAID,MAAM;AACRO,YAAQC,IAAIC,OAAMC,KAAK,gBAAgBV,IAAAA,GAAO,CAAA;EAChD;AACA,QAAMW,qBAAqBhB,cAAc;IAAC;IAAW;MAAS;IAAC;;AAC/D,QAAMG,QAAsB;IAAC;MAAC;MAAQ;QAAC;QAAc;WAAcO;WAAgBM;WAAuBL;QAAgB;QAAO;;;;AAEjI,QAAMM,SAASb,SAAS,OAAOJ,cAAc,iBAAiB,EAAA,UAAY;OAAIG;GAAM;AACpFS,UAAQC,IAAI,GAAGC,OAAMI,KAAK,gBAAA,CAAA,KAAsBJ,OAAMK,UAAUX,KAAKC,IAAG,IAAKF,SAAS,KAAMa,QAAQ,CAAA,CAAA,CAAA,KAAQN,OAAMI,KAAK,SAAA,CAAA,EAAY;AACnI,SAAOD;AACT,GAfuB;","names":["chalk","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","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","deps","pkg","incremental","depsPackage","depsAll","steps","runSteps","jobs","verbose","start","Date","now","jobsOptions","verboseOptions","console","log","chalk","blue","incrementalOptions","result","gray","magenta","toFixed"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["dupdeps.ts","detectDuplicateDependencies.ts","processEx.ts","withError.ts","withErrnoException.ts","safeExit.ts","DuplicateDetector.ts","jsonFormatters.ts","parsedPackageJSON.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { detectDuplicateDependencies, parsedPackageJSON } from '../lib/index.ts'\n\nexport const dupdeps = () => {\n console.log(chalk.green('Checking all Dependencies for Duplicates'))\n\n const allDependencies = parsedPackageJSON()?.dependencies\n const dependencies = Object.entries(allDependencies).map(([k]) => k)\n\n return detectDuplicateDependencies(dependencies)\n}\n","import { execSync } from 'node:child_process'\n\nimport { safeExit } from '../safeExit.ts'\nimport { DuplicateDetector } from './DuplicateDetector.ts'\n\nexport const detectDuplicateDependencies = (depsFromPackageJSON?: string[], DefaultDependencies?: string[]) => {\n let exitCode = 0\n\n const dependencies = depsFromPackageJSON?.length ? depsFromPackageJSON : DefaultDependencies\n\n return safeExit(() => {\n if (dependencies) {\n for (const dependency of dependencies) {\n let output: string\n\n try {\n const cmd = `yarn why ${dependency} --json`\n output = execSync(cmd).toString()\n } catch (e) {\n console.error(`Error running yarn why: ${e}`)\n exitCode = 1\n continue\n }\n\n if (output) {\n exitCode = new DuplicateDetector(output, dependency).detect()\n } else {\n console.log(`${dependency} - N/A`)\n if (depsFromPackageJSON) {\n exitCode = 1\n console.log(`🚨 Library ${dependency} was requested in package.json but not found`)\n }\n }\n }\n return exitCode\n } else {\n console.log('🚨 No dependencies where passed')\n return exitCode\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 { EOL } from 'node:os'\n\nimport chalk from 'chalk'\n\nimport { multiLineToJSONArray } from '../jsonFormatters.ts'\n\ninterface ChildFields {\n descriptor: string\n locator: string\n}\n\nconst trimVirtualMeta = (value: string): string => {\n const virtualParts = value.split('virtual:')\n if (virtualParts.length > 1) {\n const hashParts = virtualParts[1].split('#')\n return virtualParts[0] + hashParts[1]\n } else {\n return value\n }\n}\n\nconst trimObjectDependencyVirtualMeta = (obj: Record<string, ChildFields>): Record<string, ChildFields> => {\n const resultObj: Record<string, ChildFields> = {}\n for (const [key, value] of Object.entries(obj)) {\n resultObj[trimVirtualMeta(key)] = {\n descriptor: trimVirtualMeta(value.descriptor),\n locator: trimVirtualMeta(value.locator),\n }\n }\n return resultObj\n}\n\nconst trimDependencyVirtualMeta = (dependencies: DependencyEntries): DependencyEntries => {\n return dependencies.map((dependency) => {\n return { children: trimObjectDependencyVirtualMeta(dependency.children), value: trimVirtualMeta(dependency.value) }\n })\n}\n\ninterface DependencyEntry {\n children: Record<string, ChildFields>\n value: string\n}\n\ntype DependencyEntries = DependencyEntry[]\n\ninterface Results {\n currentVersion: string | undefined\n dependency: string\n duplicateVersions: string[]\n}\n\nexport class DuplicateDetector {\n private dependency: string\n private dependencyEntries: DependencyEntries\n\n constructor(output: string, dependency: string) {\n this.dependency = dependency\n this.dependencyEntries = trimDependencyVirtualMeta(multiLineToJSONArray(output))\n }\n\n detect() {\n // eslint-disable-next-line unicorn/no-array-reduce\n const result = this.dependencyEntries.reduce(this.detectReducer, this.resultsFactory(this.dependency))\n if (result.duplicateVersions.length > 0) {\n console.log(chalk.yellow(`${EOL}Duplicates found for: ${this.dependency}`))\n const duplicateVersions = result.duplicateVersions.toString().replaceAll(',', `${EOL} `)\n console.log(chalk.grey(` ${duplicateVersions}`, EOL))\n return 1\n } else {\n console.log(`${this.dependency} - OK`)\n return 0\n }\n }\n\n private detectReducer(acc: Results, entry: DependencyEntry) {\n const version = Object.entries(entry.children).map(([k]) => k)[0]\n\n if (!acc.currentVersion) {\n acc.currentVersion = version\n return acc\n }\n\n if (acc.currentVersion && acc.currentVersion !== version && !version.includes('@virtual:')) {\n // if first duplicate, push the current version as the first duplicate\n if (acc.duplicateVersions.length === 0) {\n acc.duplicateVersions.push(acc.currentVersion)\n }\n acc.duplicateVersions.push(version)\n acc.duplicateVersions = [...new Set(acc.duplicateVersions)]\n }\n return acc\n }\n\n private resultsFactory = (dependency: string): Results => ({\n currentVersion: undefined, dependency, duplicateVersions: [],\n })\n}\n","export const multiLineToJSONArray = (output: string) => {\n const withCommas = output.replaceAll('\\r\\n', '').replaceAll('\\n', ',')\n const cleanCollection = withCommas.slice(0, Math.max(0, withCommas.length - 1))\n const collection = `[${cleanCollection}]`\n return JSON.parse(collection)\n}\n","import { readFileSync } from 'node:fs'\n\nexport const parsedPackageJSON = (path?: string) => {\n const pathToPackageJSON = path ?? process.env.npm_package_json ?? ''\n const packageJSON = readFileSync(pathToPackageJSON).toString()\n return JSON.parse(packageJSON)\n}\n"],"mappings":";;;;AAAA,OAAOA,YAAW;;;ACAlB,SAASC,gBAAgB;;;ACAzB,OAAOC,WAAW;;;ACAX,IAAMC,YAAY,wBAEvBC,IACAC,SACAC,YAAY,CAACF,QAAW,CAAC,CAACA,IAAGG,QAAQ,CAAC,CAACH,IAAGI,YAAQ;AAElD,SAAOF,UAAUF,EAAAA,IAAWC,QAAQD,EAAAA,IAAWK;AACjD,GAPyB;;;ACElB,IAAMC,qBAAqB,wBAChCC,IAAaC,YAAAA;AAEb,SAAOC,UAAaF,IAAIC,SAAS,CAACD,QAAiBA,IAA6BG,UAAUC,MAAAA;AAC5F,GAJkC;;;AFG3B,IAAMC,YAAY,wBAACC,OAAAA;AACxB,QAAMC,QAAQ,OAAOD,OAAO,WAAW,IAAIE,MAAMF,EAAAA,IAAMA;AACvD,QAAMG,WACFC,mBAAmBH,OAAO,CAACA,WAAAA;AAC3B,QAAIA,OAAMI,SAAS,UAAU;AAC3BC,cAAQL,MAAMM,MAAMC,IAAI,IAAIP,OAAMQ,IAAI,cAAc,CAAA;IACtD,OAAO;AACLH,cAAQL,MAAMM,MAAMC,IAAI,UAA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EtB,IAAMC,oBAAoB,wBAACC,SAAAA;AAChC,QAAMC,oBAAoBD,QAAQE,QAAQC,IAAIC,oBAAoB;AAClE,QAAMC,cAAcC,aAAaL,iBAAAA,EAAmBM,SAAQ;AAC5D,SAAOC,KAAKC,MAAMJ,WAAAA;AACpB,GAJiC;;;ARE1B,IAAMK,UAAU,6BAAA;AACrBC,UAAQC,IAAIC,OAAMC,MAAM,0CAAA,CAAA;AAExB,QAAMC,kBAAkBC,kBAAAA,GAAqBC;AAC7C,QAAMA,eAAeC,OAAOC,QAAQJ,eAAAA,EAAiBK,IAAI,CAAC,CAACC,CAAAA,MAAOA,CAAAA;AAElE,SAAOC,4BAA4BL,YAAAA;AACrC,GAPuB;","names":["chalk","execSync","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","EOL","chalk","multiLineToJSONArray","output","withCommas","replaceAll","cleanCollection","slice","Math","max","length","collection","JSON","parse","trimVirtualMeta","value","virtualParts","split","length","hashParts","trimObjectDependencyVirtualMeta","obj","resultObj","key","Object","entries","descriptor","locator","trimDependencyVirtualMeta","dependencies","map","dependency","children","DuplicateDetector","dependencyEntries","constructor","output","multiLineToJSONArray","detect","result","reduce","detectReducer","resultsFactory","duplicateVersions","console","log","chalk","yellow","EOL","toString","replaceAll","grey","acc","entry","version","k","currentVersion","includes","push","Set","undefined","detectDuplicateDependencies","depsFromPackageJSON","DefaultDependencies","exitCode","dependencies","length","safeExit","dependency","output","cmd","execSync","toString","e","console","error","DuplicateDetector","detect","log","readFileSync","parsedPackageJSON","path","pathToPackageJSON","process","env","npm_package_json","packageJSON","readFileSync","toString","JSON","parse","dupdeps","console","log","chalk","green","allDependencies","parsedPackageJSON","dependencies","Object","entries","map","k","detectDuplicateDependencies"]}
1
+ {"version":3,"sources":["../../src/actions/dupdeps.ts","../../src/lib/dependencies/detectDuplicateDependencies.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/dependencies/DuplicateDetector.ts","../../src/lib/jsonFormatters.ts","../../src/lib/parsedPackageJSON.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { detectDuplicateDependencies, parsedPackageJSON } from '../lib/index.ts'\n\nexport const dupdeps = () => {\n console.log(chalk.green('Checking all Dependencies for Duplicates'))\n\n const allDependencies = parsedPackageJSON()?.dependencies\n const dependencies = Object.entries(allDependencies).map(([k]) => k)\n\n return detectDuplicateDependencies(dependencies)\n}\n","import { execSync } from 'node:child_process'\n\nimport { safeExit } from '../safeExit.ts'\nimport { DuplicateDetector } from './DuplicateDetector.ts'\n\nexport const detectDuplicateDependencies = (depsFromPackageJSON?: string[], DefaultDependencies?: string[]) => {\n let exitCode = 0\n\n const dependencies = depsFromPackageJSON?.length ? depsFromPackageJSON : DefaultDependencies\n\n return safeExit(() => {\n if (dependencies) {\n for (const dependency of dependencies) {\n let output: string\n\n try {\n const cmd = `yarn why ${dependency} --json`\n output = execSync(cmd).toString()\n } catch (e) {\n console.error(`Error running yarn why: ${e}`)\n exitCode = 1\n continue\n }\n\n if (output) {\n exitCode = new DuplicateDetector(output, dependency).detect()\n } else {\n console.log(`${dependency} - N/A`)\n if (depsFromPackageJSON) {\n exitCode = 1\n console.log(`🚨 Library ${dependency} was requested in package.json but not found`)\n }\n }\n }\n return exitCode\n } else {\n console.log('🚨 No dependencies where passed')\n return exitCode\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 { EOL } from 'node:os'\n\nimport chalk from 'chalk'\n\nimport { multiLineToJSONArray } from '../jsonFormatters.ts'\n\ninterface ChildFields {\n descriptor: string\n locator: string\n}\n\nconst trimVirtualMeta = (value: string): string => {\n const virtualParts = value.split('virtual:')\n if (virtualParts.length > 1) {\n const hashParts = virtualParts[1].split('#')\n return virtualParts[0] + hashParts[1]\n } else {\n return value\n }\n}\n\nconst trimObjectDependencyVirtualMeta = (obj: Record<string, ChildFields>): Record<string, ChildFields> => {\n const resultObj: Record<string, ChildFields> = {}\n for (const [key, value] of Object.entries(obj)) {\n resultObj[trimVirtualMeta(key)] = {\n descriptor: trimVirtualMeta(value.descriptor),\n locator: trimVirtualMeta(value.locator),\n }\n }\n return resultObj\n}\n\nconst trimDependencyVirtualMeta = (dependencies: DependencyEntries): DependencyEntries => {\n return dependencies.map((dependency) => {\n return { children: trimObjectDependencyVirtualMeta(dependency.children), value: trimVirtualMeta(dependency.value) }\n })\n}\n\ninterface DependencyEntry {\n children: Record<string, ChildFields>\n value: string\n}\n\ntype DependencyEntries = DependencyEntry[]\n\ninterface Results {\n currentVersion: string | undefined\n dependency: string\n duplicateVersions: string[]\n}\n\nexport class DuplicateDetector {\n private dependency: string\n private dependencyEntries: DependencyEntries\n\n constructor(output: string, dependency: string) {\n this.dependency = dependency\n this.dependencyEntries = trimDependencyVirtualMeta(multiLineToJSONArray(output))\n }\n\n detect() {\n // eslint-disable-next-line unicorn/no-array-reduce\n const result = this.dependencyEntries.reduce(this.detectReducer, this.resultsFactory(this.dependency))\n if (result.duplicateVersions.length > 0) {\n console.log(chalk.yellow(`${EOL}Duplicates found for: ${this.dependency}`))\n const duplicateVersions = result.duplicateVersions.toString().replaceAll(',', `${EOL} `)\n console.log(chalk.grey(` ${duplicateVersions}`, EOL))\n return 1\n } else {\n console.log(`${this.dependency} - OK`)\n return 0\n }\n }\n\n private detectReducer(acc: Results, entry: DependencyEntry) {\n const version = Object.entries(entry.children).map(([k]) => k)[0]\n\n if (!acc.currentVersion) {\n acc.currentVersion = version\n return acc\n }\n\n if (acc.currentVersion && acc.currentVersion !== version && !version.includes('@virtual:')) {\n // if first duplicate, push the current version as the first duplicate\n if (acc.duplicateVersions.length === 0) {\n acc.duplicateVersions.push(acc.currentVersion)\n }\n acc.duplicateVersions.push(version)\n acc.duplicateVersions = [...new Set(acc.duplicateVersions)]\n }\n return acc\n }\n\n private resultsFactory = (dependency: string): Results => ({\n currentVersion: undefined, dependency, duplicateVersions: [],\n })\n}\n","export const multiLineToJSONArray = (output: string) => {\n const withCommas = output.replaceAll('\\r\\n', '').replaceAll('\\n', ',')\n const cleanCollection = withCommas.slice(0, Math.max(0, withCommas.length - 1))\n const collection = `[${cleanCollection}]`\n return JSON.parse(collection)\n}\n","import { readFileSync } from 'node:fs'\n\nexport const parsedPackageJSON = (path?: string) => {\n const pathToPackageJSON = path ?? process.env.npm_package_json ?? ''\n const packageJSON = readFileSync(pathToPackageJSON).toString()\n return JSON.parse(packageJSON)\n}\n"],"mappings":";;;;AAAA,OAAOA,YAAW;;;ACAlB,SAASC,gBAAgB;;;ACAzB,OAAOC,WAAW;;;ACAX,IAAMC,YAAY,wBAEvBC,IACAC,SACAC,YAAY,CAACF,QAAW,CAAC,CAACA,IAAGG,QAAQ,CAAC,CAACH,IAAGI,YAAQ;AAElD,SAAOF,UAAUF,EAAAA,IAAWC,QAAQD,EAAAA,IAAWK;AACjD,GAPyB;;;ACElB,IAAMC,qBAAqB,wBAChCC,IAAaC,YAAAA;AAEb,SAAOC,UAAaF,IAAIC,SAAS,CAACD,QAAiBA,IAA6BG,UAAUC,MAAAA;AAC5F,GAJkC;;;AFG3B,IAAMC,YAAY,wBAACC,OAAAA;AACxB,QAAMC,QAAQ,OAAOD,OAAO,WAAW,IAAIE,MAAMF,EAAAA,IAAMA;AACvD,QAAMG,WACFC,mBAAmBH,OAAO,CAACA,WAAAA;AAC3B,QAAIA,OAAMI,SAAS,UAAU;AAC3BC,cAAQL,MAAMM,MAAMC,IAAI,IAAIP,OAAMQ,IAAI,cAAc,CAAA;IACtD,OAAO;AACLH,cAAQL,MAAMM,MAAMC,IAAI,UAAUP,OAAMI,IAAI,EAAE,CAAA;IAChD;AACA,WAAOJ,OAAMS,SAAS;EACxB,CAAA,KACGC,UAAUV,OAAO,CAACA,WAAAA;AACnBK,YAAQL,MAAMM,MAAMC,IAAI,GAAGP,OAAMW,IAAI,KAAKX,OAAMY,OAAO,EAAE,CAAA;AACzD,WAAO;EACT,CAAA,MACI,MAAA;AACFP,YAAQL,MAAMM,MAAMC,IAAI,qBAAqBM,KAAKC,UAAUf,IAAI,MAAM,CAAA,CA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C;AAC7C,QAAMA,eAAeC,OAAOC,QAAQJ,eAAAA,EAAiBK,IAAI,CAAC,CAACC,CAAAA,MAAOA,CAAAA;AAElE,SAAOC,4BAA4BL,YAAAA;AACrC,GAPuB;","names":["chalk","execSync","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","EOL","chalk","multiLineToJSONArray","output","withCommas","replaceAll","cleanCollection","slice","Math","max","length","collection","JSON","parse","trimVirtualMeta","value","virtualParts","split","length","hashParts","trimObjectDependencyVirtualMeta","obj","resultObj","key","Object","entries","descriptor","locator","trimDependencyVirtualMeta","dependencies","map","dependency","children","DuplicateDetector","dependencyEntries","constructor","output","multiLineToJSONArray","detect","result","reduce","detectReducer","resultsFactory","duplicateVersions","console","log","chalk","yellow","EOL","toString","replaceAll","grey","acc","entry","version","k","currentVersion","includes","push","Set","undefined","detectDuplicateDependencies","depsFromPackageJSON","DefaultDependencies","exitCode","dependencies","length","safeExit","dependency","output","cmd","execSync","toString","e","console","error","DuplicateDetector","detect","log","readFileSync","parsedPackageJSON","path","pathToPackageJSON","process","env","npm_package_json","packageJSON","readFileSync","toString","JSON","parse","dupdeps","console","log","chalk","green","allDependencies","parsedPackageJSON","dependencies","Object","entries","map","k","detectDuplicateDependencies"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["checkResult.ts","processEx.ts","withError.ts","withErrnoException.ts","safeExit.ts","runSteps.ts","fix.ts"],"sourcesContent":["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, SpawnSyncOptionsWithBufferEncoding } 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","import { runSteps } from '../lib/index.ts'\n\nexport const fix = () => {\n return runSteps('Fix', [['yarn', ['eslint', '.', '--fix', '--cache']]])\n}\n"],"mappings":";;;;AAAA,OAAOA,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,CAAA;AACpE,QAAID,YAAY;AACdO,cAAQC,KAAKV,MAAAA;IACf;EACF;AACF,GAT2B;;;ACF3B,OAAOW,YAAW;;;ACAX,IAAMC,YAAY,wBAEvBC,IACAC,SACAC,YAAY,CAACF,QAAW,CAAC,CAACA,IAAGG,QAAQ,CAAC,CAACH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AACC,MAAcC,OAAqBC,aAAa,MAAMC,aAAAA;AAC7E,SAAOC,SAAS,MAAA;AACd,UAAMC,UAAUC,QAAQC,IAAIC;AAC5BC,YAAQC,IAAIC,OAAMC,MAAM,GAAGZ,IAAAA,KAASK,OAAAA,GAAU,CAAA;AAC9C,QAAIQ,cAAc;AAClB,eAAW,CAACC,GAAG,CAACC,SAASC,MAAMC,MAAAA,CAAO,KAAKhB,MAAMiB,QAAO,GAAI;AAC1D,UAAIf,WAAWW,CAAAA,GAAI;AACjBL,gBAAQC,IAAIC,OAAMQ,KAAKhB,WAAWW,CAAAA,CAAE,CAAA;MACtC;AACA,YAAMM,UAAUC,MAAMC,QAAQN,IAAAA,IAAQA,OAAOA,KAAKO,MAAM,GAAA;AACxD,UAAIR,YAAY,UAAU,CAACS,WAAWJ,QAAQ,CAAA,CAAE,GAAG;AACjD,cAAM,IAAIK,MAAM,mBAAmBL,QAAQ,CAAA,CAAE,GAAG;MAClD;AACA,YAAMM,SACFC,UAAUZ,SAASM,MAAMC,QAAQN,IAAAA,IAAQA,OAAOA,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;;;ACVjB,IAAM+B,MAAM,6BAAA;AACjB,SAAOC,SAAS,OAAO;IAAC;MAAC;MAAQ;QAAC;QAAU;QAAK;QAAS;;;GAAY;AACxE,GAFmB;","names":["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","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","fix","runSteps"]}
1
+ {"version":3,"sources":["../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/runSteps.ts","../../src/actions/fix.ts"],"sourcesContent":["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, SpawnSyncOptionsWithBufferEncoding } 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","import { runSteps } from '../lib/index.ts'\n\nexport const fix = () => {\n return runSteps('Fix', [['yarn', ['eslint', '.', '--fix', '--cache']]])\n}\n"],"mappings":";;;;AAAA,OAAOA,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,CAAA;AACpE,QAAID,YAAY;AACdO,cAAQC,KAAKV,MAAAA;IACf;EACF;AACF,GAT2B;;;ACF3B,OAAOW,YAAW;;;ACAX,IAAMC,YAAY,wBAEvBC,IACAC,SACAC,YAAY,CAACF,QAAW,CAAC,CAACA,IAAGG,QAAQ,CAAC,CAACH,IAAGI,YAAQ;AAElD,SAAOF,UAAUF,EAAAA,IAAWC,QAAQD,EAAAA,IAAWK;AACjD,GAPyB;;;ACElB,IAAMC,qBAAqB,wBAChCC,IAAaC,YAAAA;AAEb,SAAOC,UAAaF,IAAIC,SAAS,CAACD,QAAiBA,IAA6BG,UAAUC,MAAAA;AAC5F,GAJkC;;;AFG3B,IAAMC,YAAY,wBAACC,OAAAA;AACxB,QAAMC,QAAQ,OAAOD,OAAO,WAAW,IAAIE,MAAMF,EAAAA,IAAMA;AACvD,QAAMG,WACFC,mBAAmBH,OAAO,CAACA,WAAAA;AAC3B,QAAIA,OAAMI,SAAS,UAAU;AAC3BC,cAAQL,MAAMM,OAAMC,IAAI,IAAIP,OAAMQ,IAAI,cAAc,CAAA;IACtD,OAAO;AACLH,cAAQL,MAAMM,OAAMC,IAAI,UAAUP,OAAMI,IAAI,EAAE,CAAA;IAChD;AACA,WAAOJ,OAAMS,SAAS;EACxB,CAAA,KAC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A,YAAMM,SACFC,UAAUZ,SAASM,MAAMC,QAAQN,IAAAA,IAAQA,OAAOA,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;;;ACVjB,IAAM+B,MAAM,6BAAA;AACjB,SAAOC,SAAS,OAAO;IAAC;MAAC;MAAQ;QAAC;QAAU;QAAK;QAAS;;;GAAY;AACxE,GAFmB;","names":["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","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","fix","runSteps"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["checkResult.ts","processEx.ts","withError.ts","withErrnoException.ts","safeExit.ts","runSteps.ts","gen-docs.ts"],"sourcesContent":["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, SpawnSyncOptionsWithBufferEncoding } 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","import { runSteps, ScriptStep } from '../lib/index.ts'\n\nexport interface GenDocsParams {\n incremental?: boolean\n pkg?: string\n}\n\nexport interface GenDocsPackageParams { pkg: string }\n\nexport const genDocs = ({ pkg, incremental }: GenDocsParams) => {\n return pkg ? genDocsPackage({ pkg }) : genDocsAll({ incremental })\n}\n\nexport const genDocsPackage = ({ pkg }: GenDocsPackageParams) => {\n const steps: ScriptStep[] = [['yarn', ['workspace', pkg, 'run', 'package-gen-docs']]]\n\n return runSteps(`GenDocs [${pkg}]`, [...steps])\n}\n\nexport const genDocsAll = ({ incremental }: GenDocsParams) => {\n const incrementalOptions = incremental ? ['--since', '-pA'] : ['-pA']\n const steps: ScriptStep[] = [['yarn', ['workspaces', 'foreach', ...incrementalOptions, 'run', 'package-gen-docs']]]\n\n return runSteps(`GenDocs [All${incremental ? '-Incremental' : ''}]`, [...steps])\n}\n"],"mappings":";;;;AAAA,OAAOA,WAAW;AAEX,IAAMC,cAA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OAAO;MACT,CAAA,EAAGL,UAAU;AACfM,kBAAYhC,MAAM0B,QAAQ,SAASxB,UAAAA;AACnCW,qBAAea,UAAU;IAC3B;AACA,WAAOb;EACT,GAAG,CAAC,CAACX,UAAAA;AACP,GA1BwB;;;ACHjB,IAAM+B,UAAU,wBAAC,EAAEC,KAAKC,YAAW,MAAiB;AACzD,SAAOD,MAAME,eAAe;IAAEF;EAAI,CAAA,IAAKG,WAAW;IAAEF;EAAY,CAAA;AAClE,GAFuB;AAIhB,IAAMC,iBAAiB,wBAAC,EAAEF,IAAG,MAAwB;AAC1D,QAAMI,QAAsB;IAAC;MAAC;MAAQ;QAAC;QAAaJ;QAAK;QAAO;;;;AAEhE,SAAOK,SAAS,YAAYL,GAAAA,KAAQ;OAAII;GAAM;AAChD,GAJ8B;AAMvB,IAAMD,aAAa,wBAAC,EAAEF,YAAW,MAAiB;AACvD,QAAMK,qBAAqBL,cAAc;IAAC;IAAW;MAAS;IAAC;;AAC/D,QAAMG,QAAsB;IAAC;MAAC;MAAQ;QAAC;QAAc;WAAcE;QAAoB;QAAO;;;;AAE9F,SAAOD,SAAS,eAAeJ,cAAc,iBAAiB,EAAA,KAAO;OAAIG;GAAM;AACjF,GAL0B;","names":["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","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","genDocs","pkg","incremental","genDocsPackage","genDocsAll","steps","runSteps","incrementalOptions"]}
1
+ {"version":3,"sources":["../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/runSteps.ts","../../src/actions/gen-docs.ts"],"sourcesContent":["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, SpawnSyncOptionsWithBufferEncoding } 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","import { runSteps, ScriptStep } from '../lib/index.ts'\n\nexport interface GenDocsParams {\n incremental?: boolean\n pkg?: string\n}\n\nexport interface GenDocsPackageParams { pkg: string }\n\nexport const genDocs = ({ pkg, incremental }: GenDocsParams) => {\n return pkg ? genDocsPackage({ pkg }) : genDocsAll({ incremental })\n}\n\nexport const genDocsPackage = ({ pkg }: GenDocsPackageParams) => {\n const steps: ScriptStep[] = [['yarn', ['workspace', pkg, 'run', 'package-gen-docs']]]\n\n return runSteps(`GenDocs [${pkg}]`, [...steps])\n}\n\nexport const genDocsAll = ({ incremental }: GenDocsParams) => {\n const incrementalOptions = incremental ? ['--since', '-pA'] : ['-pA']\n const steps: ScriptStep[] = [['yarn', ['workspaces', 'foreach', ...incrementalOptions, 'run', 'package-gen-docs']]]\n\n return runSteps(`GenDocs [All${incremental ? '-Incremental' : ''}]`, [...steps])\n}\n"],"mappings":";;;;AAAA,OAAOA,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,CAAA;AACpE,QAAID,YAAY;AACdO,cAAQC,KAAKV,MAAAA;IACf;EACF;AACF,GAT2B;;;ACF3B,OAAOW,YAAW;;;ACAX,IAAMC,YAAY,wBAEvBC,IACAC,SACAC,YAAY,CAACF,QAAW,CAAC,CAACA,IAAGG,QAAQ,CAAC,CAACH,IAAGI,YAAQ;AAElD,SAAOF,UAAUF,EAAAA,IAAWC,QAAQD,EAAAA,IAAWK;AACjD,GAPyB;;;ACElB,IAAMC,qBAAqB,wBAChCC,IAAaC,YAAAA;AAEb,SAAOC,UAAaF,IAAIC,SAAS,CAACD,QAAiBA,IAA6BG,UAAUC,MAAAA;AAC5F,GAJkC;;;AFG3B,IAAMC,YAAY,wBAACC,OAAAA;AACxB,QAAMC,QAAQ,OAAOD,OAAO,WAAW,IAAIE,MAAMF,EAAAA,IAAMA;AACvD,QAAMG,WACFC,mBAAmBH,OAAO,CAACA,WAAAA;AAC3B,QAAIA,OAAMI,SAAS,UAAU;AAC3BC,cAA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,QAAQN,IAAAA,IAAQA,OAAOA,KAAKO,MAAM,GAAA;AACxD,UAAIR,YAAY,UAAU,CAACS,WAAWJ,QAAQ,CAAA,CAAE,GAAG;AACjD,cAAM,IAAIK,MAAM,mBAAmBL,QAAQ,CAAA,CAAE,GAAG;MAClD;AACA,YAAMM,SACFC,UAAUZ,SAASM,MAAMC,QAAQN,IAAAA,IAAQA,OAAOA,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;;;ACHjB,IAAM+B,UAAU,wBAAC,EAAEC,KAAKC,YAAW,MAAiB;AACzD,SAAOD,MAAME,eAAe;IAAEF;EAAI,CAAA,IAAKG,WAAW;IAAEF;EAAY,CAAA;AAClE,GAFuB;AAIhB,IAAMC,iBAAiB,wBAAC,EAAEF,IAAG,MAAwB;AAC1D,QAAMI,QAAsB;IAAC;MAAC;MAAQ;QAAC;QAAaJ;QAAK;QAAO;;;;AAEhE,SAAOK,SAAS,YAAYL,GAAAA,KAAQ;OAAII;GAAM;AAChD,GAJ8B;AAMvB,IAAMD,aAAa,wBAAC,EAAEF,YAAW,MAAiB;AACvD,QAAMK,qBAAqBL,cAAc;IAAC;IAAW;MAAS;IAAC;;AAC/D,QAAMG,QAAsB;IAAC;MAAC;MAAQ;QAAC;QAAc;WAAcE;QAAoB;QAAO;;;;AAE9F,SAAOD,SAAS,eAAeJ,cAAc,iBAAiB,EAAA,KAAO;OAAIG;GAAM;AACjF,GAL0B;","names":["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","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","genDocs","pkg","incremental","genDocsPackage","genDocsAll","steps","runSteps","incrementalOptions"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["constants.ts","fileLines.ts","empty.ts","union.ts","ReadFileSyncOptions.ts","generateIgnoreFiles.ts","yarnWorkspaces.ts","yarnWorkspace.ts","yarnInitCwd.ts","gitignore-gen.ts"],"sourcesContent":["export const WINDOWS_NEWLINE_REGEX = /\\r\\n/g\nexport const CROSS_PLATFORM_NEWLINE = '\\n'\n","import {\n existsSync, PathLike, readFileSync, WriteFileOptions,\n writeFileSync,\n} from 'node:fs'\n\nimport { notEmpty } from '../string/index.ts'\nimport { CROSS_PLATFORM_NEWLINE, WINDOWS_NEWLINE_REGEX } from './constants.ts'\nimport { defaultReadFileSyncOptions, ReadFileSyncOptions } from './ReadFileSyncOptions.ts'\n\nexport const readLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>\n existsSync(uri)\n ? readFileSync(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE)\n : []\n\nexport const readNonEmptyLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>\n readLines(uri, options).filter(notEmpty)\n\nexport const writeLines = (uri: PathLike, lines: string[], options: WriteFileOptions = defaultReadFileSyncOptions) => {\n const existing = existsSync(uri) ? readFileSync(uri, options) : undefined\n const desired = lines.join(CROSS_PLATFORM_NEWLINE)\n // Check if the file is different before writing\n if (existing !== desired) writeFileSync(uri, desired, options)\n}\n","export const empty = (value?: string | undefined): boolean => value?.trim().length === 0\nexport const notEmpty = (value?: string | undefined): boolean => !empty(value)\n","export const union = (a: string[], b: string[]): Set<string> => new Set([...new Set(a), ...new Set(b)])\n","export type ReadFileSyncOptions = BufferEncoding | {\n encoding: BufferEncoding\n flags?: string\n}\n\nexport const defaultReadFileSyncOptions: ReadFileSyncOptions = { encoding: 'utf8' }\n","import chalk from 'chalk'\n\nimport { readNonEmptyLines, writeLines } from './file/index.ts'\nimport { union } from './string/index.ts'\nimport {\n INIT_CWD, yarnWorkspace, yarnWorkspaces,\n} from './yarn/index.ts'\n\nconst localeCompare = (a: string, b: string) => a.localeCompare(b)\n\nconst mergeEntries = (a: string[], b: string[]): string[] => [...union(a, b)].sort(localeCompare)\n\nexport const generateIgnoreFiles = (filename: string, pkg?: string) => {\n console.log(chalk.green(`Generate ${filename} Files`))\n const cwd = INIT_CWD() ?? '.'\n const workspaces = pkg ? [yarnWorkspace(pkg)] : yarnWorkspaces()\n const readEntries = (location: string): string[] => readNonEmptyLines(`${location}/${filename}`)\n const writeEntries = (location: string, entries: string[]) => writeLines(`${location}/${filename}`, entries)\n const results = workspaces.map(({ location, name }) => {\n try {\n writeEntries(location, mergeEntries(readEntries(cwd), readEntries(location)))\n return 0\n } catch (ex) {\n const error = ex as Error\n console.error(`Generate ${filename} Files [${name}] [${error.message}]`)\n return 1\n }\n })\n const succeeded = results.every(result => result === 0)\n return succeeded ? 0 : 1\n}\n","import { spawnSync } from 'node:child_process'\n\nimport { 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 { 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","export const INIT_CWD = () => {\n if (!process.env.INIT_CWD) console.error('Missing INIT_CWD')\n return process.env.INIT_CWD\n}\n","import { generateIgnoreFiles } from '../lib/index.ts'\n\nconst filename = '.gitignore'\n\nexport const gitignoreGen = (pkg?: string) => generateIgnoreFiles(filename, pkg)\n"],"mappings":";;;;AAAO,IAAMA,wBAAwB;AAC9B,IAAMC,yBAAyB;;;ACDtC,SACEC,YAAsBC,cACtBC,qBACK;;;ACHA,IAAMC,QAAQ,wBAACC,UAAwCA,OAAOC,KAAAA,EAAOC,WAAW,GAAlE;AACd,IAAMC,WAAW,wBAACH,UAAwC,CAACD,MAAMC,KAAAA,GAAhD;;;ACDjB,IAAMI,QAAQ,wBAACC,GAAaC,MAA6B,oBAAIC,IAAI;KAAI,IAAIA,IAAIF,CAAAA;KAAO,IAAIE,IAAID,CAAAA;CAAG,GAAjF;;;ACKd,IAAME,6BAAkD;EAAEC,UAAU;AAAO;;;AHI3E,IAAMC,YAAY,wBAACC,KAAeC,UAA+BC,+BACtEC,WAAWH,GAAAA,IACPI,aAAaJ,KAAKC,OAAAA,EAASI,QAAQC,uBAAuBC,sBAAAA,EAAwBC,MAAMD,sBAAAA,IACxF,CAAA,GAHmB;AAKlB,IAAME,oBAAoB,wBAACT,KAAeC,UAA+BC,+BAC9EH,UAAUC,KAAKC,OAAAA,EAASS,OAAOC,QAAAA,GADA;AAG1B,IAAMC,aAAa,wBAACZ,KAAea,OAAiBZ,UAA4BC,+BAA0B;AAC/G,QAAMY,WAAWX,WAAWH,GAAAA,IAAOI,aAAaJ,KAAKC,OAAAA,IAAWc;AAChE,QAAMC,UAAUH,MAAMI,KAAKV,sBAAAA;AAE3B,MAAIO,aAAaE,QAASE,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SAAAA,EAAU,GAA3E;AACpB,QAAMc,eAAe,wBAACF,UAAkBG,YAAsBC,WAAW,GAAGJ,QAAAA,IAAYZ,SAAAA,IAAYe,OAAAA,GAA/E;AACrB,QAAME,UAAUT,WAAWU,IAAI,CAAC,EAAEN,UAAUO,KAAI,MAAE;AAChD,QAAI;AACFL,mBAAaF,UAAUhB,aAAae,YAAYL,GAAAA,GAAMK,YAAYC,QAAAA,CAAAA,CAAAA;AAClE,aAAO;IACT,SAASQ,IAAI;AACX,YAAMC,QAAQD;AACdlB,cAAQmB,MAAM,YAAYrB,SAAAA,WAAmBmB,IAAAA,MAAUE,MAAMC,OAAO,GAAG;AACvE,aAAO;IACT;EACF,CAAA;AACA,QAAMC,YAAYN,QAAQO,MAAMC,CAAAA,WAAUA,WAAW,CAAA;AACrD,SAAOF,YAAY,IAAI;AACzB,GAlBmC;;;AIVnC,IAAMG,WAAW;AAEV,IAAMC,eAAe,wBAACC,QAAiBC,oBAAoBH,UAAUE,GAAAA,GAAhD;","names":["WINDOWS_NEWLINE_REGEX","CROSS_PLATFORM_NEWLINE","existsSync","readFileSync","writeFileSync","empty","value","trim","length","notEmpty","union","a","b","Set","defaultReadFileSyncOptions","encoding","readLines","uri","options","defaultReadFileSyncOptions","existsSync","readFileSync","replace","WINDOWS_NEWLINE_REGEX","CROSS_PLATFORM_NEWLINE","split","readNonEmptyLines","filter","notEmpty","writeLines","lines","existing","undefined","desired","join","writeFileSync","chalk","spawnSync","yarnWorkspaces","result","spawnSync","encoding","shell","error","stdout","toString","split","slice","map","item","JSON","parse","yarnWorkspace","pkg","workspace","yarnWorkspaces","find","name","Error","INIT_CWD","process","env","console","error","localeCompare","a","b","mergeEntries","union","sort","generateIgnoreFiles","filename","pkg","console","log","chalk","green","cwd","INIT_CWD","workspaces","yarnWorkspace","yarnWorkspaces","readEntries","location","readNonEmptyLines","writeEntries","entries","writeLines","results","map","name","ex","error","message","succeeded","every","result","filename","gitignoreGen","pkg","generateIgnoreFiles"]}
1
+ {"version":3,"sources":["../../src/lib/file/constants.ts","../../src/lib/file/fileLines.ts","../../src/lib/string/empty.ts","../../src/lib/string/union.ts","../../src/lib/file/ReadFileSyncOptions.ts","../../src/lib/generateIgnoreFiles.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/lib/yarn/workspace/yarnWorkspace.ts","../../src/lib/yarn/yarnInitCwd.ts","../../src/actions/gitignore-gen.ts"],"sourcesContent":["export const WINDOWS_NEWLINE_REGEX = /\\r\\n/g\nexport const CROSS_PLATFORM_NEWLINE = '\\n'\n","import {\n existsSync, PathLike, readFileSync, WriteFileOptions,\n writeFileSync,\n} from 'node:fs'\n\nimport { notEmpty } from '../string/index.ts'\nimport { CROSS_PLATFORM_NEWLINE, WINDOWS_NEWLINE_REGEX } from './constants.ts'\nimport { defaultReadFileSyncOptions, ReadFileSyncOptions } from './ReadFileSyncOptions.ts'\n\nexport const readLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>\n existsSync(uri)\n ? readFileSync(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE)\n : []\n\nexport const readNonEmptyLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>\n readLines(uri, options).filter(notEmpty)\n\nexport const writeLines = (uri: PathLike, lines: string[], options: WriteFileOptions = defaultReadFileSyncOptions) => {\n const existing = existsSync(uri) ? readFileSync(uri, options) : undefined\n const desired = lines.join(CROSS_PLATFORM_NEWLINE)\n // Check if the file is different before writing\n if (existing !== desired) writeFileSync(uri, desired, options)\n}\n","export const empty = (value?: string | undefined): boolean => value?.trim().length === 0\nexport const notEmpty = (value?: string | undefined): boolean => !empty(value)\n","export const union = (a: string[], b: string[]): Set<string> => new Set([...new Set(a), ...new Set(b)])\n","export type ReadFileSyncOptions = BufferEncoding | {\n encoding: BufferEncoding\n flags?: string\n}\n\nexport const defaultReadFileSyncOptions: ReadFileSyncOptions = { encoding: 'utf8' }\n","import chalk from 'chalk'\n\nimport { readNonEmptyLines, writeLines } from './file/index.ts'\nimport { union } from './string/index.ts'\nimport {\n INIT_CWD, yarnWorkspace, yarnWorkspaces,\n} from './yarn/index.ts'\n\nconst localeCompare = (a: string, b: string) => a.localeCompare(b)\n\nconst mergeEntries = (a: string[], b: string[]): string[] => [...union(a, b)].sort(localeCompare)\n\nexport const generateIgnoreFiles = (filename: string, pkg?: string) => {\n console.log(chalk.green(`Generate ${filename} Files`))\n const cwd = INIT_CWD() ?? '.'\n const workspaces = pkg ? [yarnWorkspace(pkg)] : yarnWorkspaces()\n const readEntries = (location: string): string[] => readNonEmptyLines(`${location}/${filename}`)\n const writeEntries = (location: string, entries: string[]) => writeLines(`${location}/${filename}`, entries)\n const results = workspaces.map(({ location, name }) => {\n try {\n writeEntries(location, mergeEntries(readEntries(cwd), readEntries(location)))\n return 0\n } catch (ex) {\n const error = ex as Error\n console.error(`Generate ${filename} Files [${name}] [${error.message}]`)\n return 1\n }\n })\n const succeeded = results.every(result => result === 0)\n return succeeded ? 0 : 1\n}\n","import { spawnSync } from 'node:child_process'\n\nimport { 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 { 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","export const INIT_CWD = () => {\n if (!process.env.INIT_CWD) console.error('Missing INIT_CWD')\n return process.env.INIT_CWD\n}\n","import { generateIgnoreFiles } from '../lib/index.ts'\n\nconst filename = '.gitignore'\n\nexport const gitignoreGen = (pkg?: string) => generateIgnoreFiles(filename, pkg)\n"],"mappings":";;;;AAAO,IAAMA,wBAAwB;AAC9B,IAAMC,yBAAyB;;;ACDtC,SACEC,YAAsBC,cACtBC,qBACK;;;ACHA,IAAMC,QAAQ,wBAACC,UAAwCA,OAAOC,KAAAA,EAAOC,WAAW,GAAlE;AACd,IAAMC,WAAW,wBAACH,UAAwC,CAACD,MAAMC,KAAAA,GAAhD;;;ACDjB,IAAMI,QAAQ,wBAACC,GAAaC,MAA6B,oBAAIC,IAAI;KAAI,IAAIA,IAAIF,CAAAA;KAAO,IAAIE,IAAID,CAAAA;CAAG,GAAjF;;;ACKd,IAAME,6BAAkD;EAAEC,UAAU;AAAO;;;AHI3E,IAAMC,YAAY,wBAACC,KAAeC,UAA+BC,+BACtEC,WAAWH,GAAAA,IACPI,aAAaJ,KAAKC,OAAAA,EAASI,QAAQC,uBAAuBC,sBAAAA,EAAwBC,MAAMD,sBAAAA,IACxF,CAAA,GAHmB;AAKlB,IAAME,oBAAoB,wBAACT,KAAeC,UAA+BC,+BAC9EH,UAAUC,KAAKC,OAAAA,EAASS,OAAOC,QAAAA,GADA;AAG1B,IAAMC,aAAa,wBAACZ,KAAea,OAAiBZ,UAA4BC,+BAA0B;AAC/G,QAAMY,WAAWX,WAAWH,GAAAA,IAAOI,aAAaJ,KAAKC,OAAAA,IAAWc;AAChE,QAAMC,UAAUH,MAAMI,KAAKV,sBAAAA;AAE3B,MAAIO,aAAaE,QAASE,eAAclB,KAAKgB,SAASf,OAAAA;AACxD,GAL0B;;;AIjB1B,OAAOkB,WAAW;;;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,OA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K,YAAYC,QAAAA,CAAAA,CAAAA;AAClE,aAAO;IACT,SAASQ,IAAI;AACX,YAAMC,QAAQD;AACdlB,cAAQmB,MAAM,YAAYrB,SAAAA,WAAmBmB,IAAAA,MAAUE,MAAMC,OAAO,GAAG;AACvE,aAAO;IACT;EACF,CAAA;AACA,QAAMC,YAAYN,QAAQO,MAAMC,CAAAA,WAAUA,WAAW,CAAA;AACrD,SAAOF,YAAY,IAAI;AACzB,GAlBmC;;;AIVnC,IAAMG,WAAW;AAEV,IAAMC,eAAe,wBAACC,QAAiBC,oBAAoBH,UAAUE,GAAAA,GAAhD;","names":["WINDOWS_NEWLINE_REGEX","CROSS_PLATFORM_NEWLINE","existsSync","readFileSync","writeFileSync","empty","value","trim","length","notEmpty","union","a","b","Set","defaultReadFileSyncOptions","encoding","readLines","uri","options","defaultReadFileSyncOptions","existsSync","readFileSync","replace","WINDOWS_NEWLINE_REGEX","CROSS_PLATFORM_NEWLINE","split","readNonEmptyLines","filter","notEmpty","writeLines","lines","existing","undefined","desired","join","writeFileSync","chalk","spawnSync","yarnWorkspaces","result","spawnSync","encoding","shell","error","stdout","toString","split","slice","map","item","JSON","parse","yarnWorkspace","pkg","workspace","yarnWorkspaces","find","name","Error","INIT_CWD","process","env","console","error","localeCompare","a","b","mergeEntries","union","sort","generateIgnoreFiles","filename","pkg","console","log","chalk","green","cwd","INIT_CWD","workspaces","yarnWorkspace","yarnWorkspaces","readEntries","location","readNonEmptyLines","writeEntries","entries","writeLines","results","map","name","ex","error","message","succeeded","every","result","filename","gitignoreGen","pkg","generateIgnoreFiles"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["gitlint-fix.ts"],"sourcesContent":["import { execSync } from 'node:child_process'\n\nimport chalk from 'chalk'\nimport ParseGitConfig from 'parse-git-config'\n\nexport const gitlintFix = () => {\n console.log(`\\nGitlint Fix Start [${process.cwd()}]\\n`)\n\n const gitConfig = ParseGitConfig.sync()\n\n if (gitConfig.core.ignorecase) {\n execSync('git config core.ignorecase false', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.ignorecase to be false\\n'))\n }\n\n if (gitConfig.core.autocrlf !== false) {\n execSync('git config core.autocrlf false', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.autocrlf to be false\\n'))\n }\n\n if (gitConfig.core.eol !== 'lf') {\n execSync('git config core.eol lf', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.eol to be \"lf\"\\n'))\n }\n\n return 1\n}\n"],"mappings":";;;;AAAA,SAASA,gBAAgB;AAEzB,OAAOC,WAAW;AAClB,OAAOC,oBAAoB;AAEpB,IAAMC,aAAa,6BAAA;AACxBC,UAAQC,IAAI;qBAAwBC,QAAQC,IAAG,CAAA;CAAO;AAEtD,QAAMC,YAAYC,eAAeC,KAAI;AAErC,MAAIF,UAAUG,KAAKC,YAAY;AAC7BC,aAAS,oCAAoC;MAAEC,OAAO;IAAU,CAAA;AAChEV,YAAQW,KAAKC,MAAMC,OAAO,sDAAA,CAAA;EAC5B;AAEA,MAAIT,UAAUG,KAAKO,aAAa,OAAO;AACrCL,aAAS,kCAAkC;MAAEC,OAAO;IAAU,CAAA;AAC9DV,YAAQW,KAAKC,MAAMC,OAAO,oDAAA,CAAA;EAC5B;AAEA,MAAIT,UAAUG,KAAKQ,QAAQ,MAAM;AAC/BN,aAAS,0BAA0B;MAAEC,OAAO;IAAU,CAAA;AACtDV,YAAQW,KAAKC,MAAMC,OAAO,8CAAA,CAAA;EAC5B;AAEA,SAAO;AACT,GArB0B;","names":["execSync","chalk","ParseGitConfig","gitlintFix","console","log","process","cwd","gitConfig","ParseGitConfig","sync","core","ignorecase","execSync","stdio","warn","chalk","yellow","autocrlf","eol"]}
1
+ {"version":3,"sources":["../../src/actions/gitlint-fix.ts"],"sourcesContent":["import { execSync } from 'node:child_process'\n\nimport chalk from 'chalk'\nimport ParseGitConfig from 'parse-git-config'\n\nexport const gitlintFix = () => {\n console.log(`\\nGitlint Fix Start [${process.cwd()}]\\n`)\n\n const gitConfig = ParseGitConfig.sync()\n\n if (gitConfig.core.ignorecase) {\n execSync('git config core.ignorecase false', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.ignorecase to be false\\n'))\n }\n\n if (gitConfig.core.autocrlf !== false) {\n execSync('git config core.autocrlf false', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.autocrlf to be false\\n'))\n }\n\n if (gitConfig.core.eol !== 'lf') {\n execSync('git config core.eol lf', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.eol to be \"lf\"\\n'))\n }\n\n return 1\n}\n"],"mappings":";;;;AAAA,SAASA,gBAAgB;AAEzB,OAAOC,WAAW;AAClB,OAAOC,oBAAoB;AAEpB,IAAMC,aAAa,6BAAA;AACxBC,UAAQC,IAAI;qBAAwBC,QAAQC,IAAG,CAAA;CAAO;AAEtD,QAAMC,YAAYC,eAAeC,KAAI;AAErC,MAAIF,UAAUG,KAAKC,YAAY;AAC7BC,aAAS,oCAAoC;MAAEC,OAAO;IAAU,CAAA;AAChEV,YAAQW,KAAKC,MAAMC,OAAO,sDAAA,CAAA;EAC5B;AAEA,MAAIT,UAAUG,KAAKO,aAAa,OAAO;AACrCL,aAAS,kCAAkC;MAAEC,OAAO;IAAU,CAAA;AAC9DV,YAAQW,KAAKC,MAAMC,OAAO,oDAAA,CAAA;EAC5B;AAEA,MAAIT,UAAUG,KAAKQ,QAAQ,MAAM;AAC/BN,aAAS,0BAA0B;MAAEC,OAAO;IAAU,CAAA;AACtDV,YAAQW,KAAKC,MAAMC,OAAO,8CAAA,CAAA;EAC5B;AAEA,SAAO;AACT,GArB0B;","names":["execSync","chalk","ParseGitConfig","gitlintFix","console","log","process","cwd","gitConfig","ParseGitConfig","sync","core","ignorecase","execSync","stdio","warn","chalk","yellow","autocrlf","eol"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["gitlint.ts"],"sourcesContent":["import chalk from 'chalk'\nimport ParseGitConfig from 'parse-git-config'\n\nexport const gitlint = () => {\n console.log(`\\nGitlint Start [${process.cwd()}]\\n`)\n let valid = 0\n let warnings = 0\n const errors = 0\n const gitConfig = ParseGitConfig.sync()\n\n const warn = (message: string) => {\n console.warn(chalk.yellow(`Warning: ${message}`))\n warnings++\n }\n\n if (gitConfig.core.ignorecase) {\n warn('Please set core.ignorecase to FALSE in .git/config file [run yarn gitlint-fix]')\n } else {\n valid++\n }\n\n if (gitConfig.core.autocrlf === false) {\n valid++\n } else {\n warn('Please set core.autocrlf to FALSE in .git/config file [run yarn gitlint-fix]')\n }\n\n if (gitConfig.core.eol === 'lf') {\n valid++\n } else {\n warn('Please set core.eol to \"lf\" in .git/config file [run yarn gitlint-fix]')\n }\n\n const resultMessages: string[] = []\n if (valid > 0) {\n resultMessages.push(chalk.green(`Passed: ${valid}`))\n }\n if (warnings > 0) {\n resultMessages.push(chalk.yellow(`Warnings: ${warnings}`))\n }\n if (errors > 0) {\n resultMessages.push(chalk.red(` Errors: ${errors}`))\n }\n console.warn(`Gitlint Finish [ ${resultMessages.join(' | ')} ]\\n`)\n return warnings + errors === 0 ? 1 : 0\n}\n"],"mappings":";;;;AAAA,OAAOA,WAAW;AAClB,OAAOC,oBAAoB;AAEpB,IAAMC,UAAU,6BAAA;AACrBC,UAAQC,IAAI;iBAAoBC,QAAQC,IAAG,CAAA;CAAO;AAClD,MAAIC,QAAQ;AACZ,MAAIC,WAAW;AACf,QAAMC,SAAS;AACf,QAAMC,YAAYC,eAAeC,KAAI;AAErC,QAAMC,OAAO,wBAACC,YAAAA;AACZX,YAAQU,KAAKE,MAAMC,OAAO,YAAYF,OAAAA,EAAS,CAAA;AAC/CN;EACF,GAHa;AAKb,MAAIE,UAAUO,KAAKC,YAAY;AAC7BL,SAAK,gFAAA;EACP,OAAO;AACLN;EACF;AAEA,MAAIG,UAAUO,KAAKE,aAAa,OAAO;AACrCZ;EACF,OAAO;AACLM,SAAK,8EAAA;EACP;AAEA,MAAIH,UAAUO,KAAKG,QAAQ,MAAM;AAC/Bb;EACF,OAAO;AACLM,SAAK,wEAAA;EACP;AAEA,QAAMQ,iBAA2B,CAAA;AACjC,MAAId,QAAQ,GAAG;AACbc,mBAAeC,KAAKP,MAAMQ,MAAM,WAAWhB,KAAAA,EAAO,CAAA;EACpD;AACA,MAAIC,WAAW,GAAG;AAChBa,mBAAeC,KAAKP,MAAMC,OAAO,aAAaR,QAAAA,EAAU,CAAA;EAC1D;AACA,MAAIC,SAAS,GAAG;AACdY,mBAAeC,KAAKP,MAAMS,IAAI,YAAYf,MAAAA,EAAQ,CAAA;EACpD;AACAN,UAAQU,KAAK,oBAAoBQ,eAAeI,KAAK,KAAA,CAAA;CAAY;AACjE,SAAOjB,WAAWC,WAAW,IAAI,IAAI;AACvC,GA1CuB;","names":["chalk","ParseGitConfig","gitlint","console","log","process","cwd","valid","warnings","errors","gitConfig","ParseGitConfig","sync","warn","message","chalk","yellow","core","ignorecase","autocrlf","eol","resultMessages","push","green","red","join"]}
1
+ {"version":3,"sources":["../../src/actions/gitlint.ts"],"sourcesContent":["import chalk from 'chalk'\nimport ParseGitConfig from 'parse-git-config'\n\nexport const gitlint = () => {\n console.log(`\\nGitlint Start [${process.cwd()}]\\n`)\n let valid = 0\n let warnings = 0\n const errors = 0\n const gitConfig = ParseGitConfig.sync()\n\n const warn = (message: string) => {\n console.warn(chalk.yellow(`Warning: ${message}`))\n warnings++\n }\n\n if (gitConfig.core.ignorecase) {\n warn('Please set core.ignorecase to FALSE in .git/config file [run yarn gitlint-fix]')\n } else {\n valid++\n }\n\n if (gitConfig.core.autocrlf === false) {\n valid++\n } else {\n warn('Please set core.autocrlf to FALSE in .git/config file [run yarn gitlint-fix]')\n }\n\n if (gitConfig.core.eol === 'lf') {\n valid++\n } else {\n warn('Please set core.eol to \"lf\" in .git/config file [run yarn gitlint-fix]')\n }\n\n const resultMessages: string[] = []\n if (valid > 0) {\n resultMessages.push(chalk.green(`Passed: ${valid}`))\n }\n if (warnings > 0) {\n resultMessages.push(chalk.yellow(`Warnings: ${warnings}`))\n }\n if (errors > 0) {\n resultMessages.push(chalk.red(` Errors: ${errors}`))\n }\n console.warn(`Gitlint Finish [ ${resultMessages.join(' | ')} ]\\n`)\n return warnings + errors === 0 ? 1 : 0\n}\n"],"mappings":";;;;AAAA,OAAOA,WAAW;AAClB,OAAOC,oBAAoB;AAEpB,IAAMC,UAAU,6BAAA;AACrBC,UAAQC,IAAI;iBAAoBC,QAAQC,IAAG,CAAA;CAAO;AAClD,MAAIC,QAAQ;AACZ,MAAIC,WAAW;AACf,QAAMC,SAAS;AACf,QAAMC,YAAYC,eAAeC,KAAI;AAErC,QAAMC,OAAO,wBAACC,YAAAA;AACZX,YAAQU,KAAKE,MAAMC,OAAO,YAAYF,OAAAA,EAAS,CAAA;AAC/CN;EACF,GAHa;AAKb,MAAIE,UAAUO,KAAKC,YAAY;AAC7BL,SAAK,gFAAA;EACP,OAAO;AACLN;EACF;AAEA,MAAIG,UAAUO,KAAKE,aAAa,OAAO;AACrCZ;EACF,OAAO;AACLM,SAAK,8EAAA;EACP;AAEA,MAAIH,UAAUO,KAAKG,QAAQ,MAAM;AAC/Bb;EACF,OAAO;AACLM,SAAK,wEAAA;EACP;AAEA,QAAMQ,iBAA2B,CAAA;AACjC,MAAId,QAAQ,GAAG;AACbc,mBAAeC,KAAKP,MAAMQ,MAAM,WAAWhB,KAAAA,EAAO,CAAA;EACpD;AACA,MAAIC,WAAW,GAAG;AAChBa,mBAAeC,KAAKP,MAAMC,OAAO,aAAaR,QAAAA,EAAU,CAAA;EAC1D;AACA,MAAIC,SAAS,GAAG;AACdY,mBAAeC,KAAKP,MAAMS,IAAI,YAAYf,MAAAA,EAAQ,CAAA;EACpD;AACAN,UAAQU,KAAK,oBAAoBQ,eAAeI,KAAK,KAAA,CAAA;CAAY;AACjE,SAAOjB,WAAWC,WAAW,IAAI,IAAI;AACvC,GA1CuB;","names":["chalk","ParseGitConfig","gitlint","console","log","process","cwd","valid","warnings","errors","gitConfig","ParseGitConfig","sync","warn","message","chalk","yellow","core","ignorecase","autocrlf","eol","resultMessages","push","green","red","join"]}