@xylabs/ts-scripts-yarn3 6.2.0 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/actions/build.mjs +12 -1
  2. package/dist/actions/build.mjs.map +1 -1
  3. package/dist/actions/cycle.mjs +164 -21
  4. package/dist/actions/cycle.mjs.map +1 -1
  5. package/dist/actions/index.mjs +185 -85
  6. package/dist/actions/index.mjs.map +1 -1
  7. package/dist/actions/package/compile/compile.mjs +0 -1
  8. package/dist/actions/package/compile/compile.mjs.map +1 -1
  9. package/dist/actions/package/compile/compileTypes.mjs +0 -1
  10. package/dist/actions/package/compile/compileTypes.mjs.map +1 -1
  11. package/dist/actions/package/compile/index.mjs +0 -1
  12. package/dist/actions/package/compile/index.mjs.map +1 -1
  13. package/dist/actions/package/compile/packageCompileTsup.mjs +0 -1
  14. package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
  15. package/dist/actions/package/cycle.mjs +47 -0
  16. package/dist/actions/package/cycle.mjs.map +1 -0
  17. package/dist/actions/package/index.mjs +42 -1
  18. package/dist/actions/package/index.mjs.map +1 -1
  19. package/dist/actions/package/recompile.mjs +0 -1
  20. package/dist/actions/package/recompile.mjs.map +1 -1
  21. package/dist/bin/package/build-only.mjs +0 -1
  22. package/dist/bin/package/build-only.mjs.map +1 -1
  23. package/dist/bin/package/build.mjs +0 -1
  24. package/dist/bin/package/build.mjs.map +1 -1
  25. package/dist/bin/package/compile-only.mjs +0 -1
  26. package/dist/bin/package/compile-only.mjs.map +1 -1
  27. package/dist/bin/package/compile-tsup.mjs +0 -1
  28. package/dist/bin/package/compile-tsup.mjs.map +1 -1
  29. package/dist/bin/package/compile-types.mjs +0 -1
  30. package/dist/bin/package/compile-types.mjs.map +1 -1
  31. package/dist/bin/package/compile.mjs +0 -1
  32. package/dist/bin/package/compile.mjs.map +1 -1
  33. package/dist/bin/package/cycle.mjs +60 -0
  34. package/dist/bin/package/cycle.mjs.map +1 -0
  35. package/dist/bin/package/recompile.mjs +0 -1
  36. package/dist/bin/package/recompile.mjs.map +1 -1
  37. package/dist/bin/xy.mjs +125 -68
  38. package/dist/bin/xy.mjs.map +1 -1
  39. package/dist/index.d.ts +18 -2
  40. package/dist/index.mjs +198 -98
  41. package/dist/index.mjs.map +1 -1
  42. package/dist/xy/index.mjs +125 -68
  43. package/dist/xy/index.mjs.map +1 -1
  44. package/dist/xy/xy.mjs +125 -68
  45. package/dist/xy/xy.mjs.map +1 -1
  46. package/dist/xy/xyBuildCommands.mjs +12 -1
  47. package/dist/xy/xyBuildCommands.mjs.map +1 -1
  48. package/dist/xy/xyLintCommands.mjs +88 -42
  49. package/dist/xy/xyLintCommands.mjs.map +1 -1
  50. package/package.json +17 -15
@@ -150,9 +150,10 @@ var build = /* @__PURE__ */ __name(async ({ incremental, jobs, target, verbose,
150
150
  "yarn",
151
151
  [
152
152
  "xy",
153
- "lint",
153
+ "cycle",
154
154
  ...pkgOptions,
155
155
  ...verboseOptions,
156
+ ...jobsOptions,
156
157
  ...incrementalOptions
157
158
  ]
158
159
  ],
@@ -177,6 +178,16 @@ var build = /* @__PURE__ */ __name(async ({ incremental, jobs, target, verbose,
177
178
  ...jobsOptions,
178
179
  ...incrementalOptions
179
180
  ]
181
+ ],
182
+ [
183
+ "yarn",
184
+ [
185
+ "xy",
186
+ "lint",
187
+ ...pkgOptions,
188
+ ...verboseOptions,
189
+ ...incrementalOptions
190
+ ]
180
191
  ]
181
192
  ]);
182
193
  console.log(`${chalk4.gray("Built in")} [${chalk4.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk4.gray("seconds")}`);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/actions/build.ts","../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/runStepsAsync.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { runStepsAsync } from '../lib/index.ts'\n\nexport interface BuildParams {\n incremental?: boolean\n jobs?: number\n pkg?: string\n target?: 'esm' | 'cjs'\n verbose?: boolean\n}\n\nexport const build = async ({\n incremental, jobs, target, verbose, pkg,\n}: BuildParams) => {\n const start = Date.now()\n const pkgOptions = pkg ? [pkg] : [] // must go first\n const incrementalOptions = incremental ? ['-i'] : []\n const verboseOptions = verbose ? ['-v'] : []\n const targetOptions = target ? ['-t', target] : []\n const jobsOptions = jobs ? ['-j', `${jobs}`] : []\n if (jobs) {\n console.log(chalk.blue(`Jobs set to [${jobs}]`))\n }\n\n const result = await runStepsAsync(`Build${incremental ? '-Incremental' : ''} [${pkg ?? 'All'}]`, [\n ['yarn', ['xy', 'compile', ...pkgOptions, ...targetOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions, '--types', 'tsup']],\n ['yarn', ['xy', 'lint', ...pkgOptions, ...verboseOptions, ...incrementalOptions]],\n ['yarn', ['xy', 'publint', ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],\n ['yarn', ['xy', 'knip', ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],\n ])\n console.log(`${chalk.gray('Built 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 { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport type { ScriptStep } from './runSteps.ts'\nimport { safeExitAsync } from './safeExit.ts'\n\nexport const runStepAsync = (name: string, step: ScriptStep, exitOnFail = true, message?: string) => {\n return new Promise<number>((resolve) => {\n const [command, args, config] = step\n if (message) {\n console.log(chalk.gray(message))\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 spawn(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).on('close', (code) => {\n if (code) {\n console.error(\n chalk.red(\n `Command Exited With Non-Zero Result [${chalk.gray(code)}] | ${chalk.yellow(command)} ${chalk.white(\n Array.isArray(args) ? args.join(' ') : args,\n )}`,\n ),\n )\n checkResult(name, code, 'error', exitOnFail)\n resolve(code)\n } else {\n resolve(0)\n }\n })\n })\n}\n\nexport const runStepsAsync = async (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]) => {\n return await safeExitAsync(async () => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let result = 0\n for (const [i, step] of steps.entries()) {\n result += await runStepAsync(name, step, exitOnFail, messages?.[i])\n }\n return result\n })\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,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,QAAi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,WAAOD;EACT,CAAA;AACF,GAV6B;;;AN9BtB,IAAMG,QAAQ,8BAAO,EAC1BC,aAAaC,MAAMC,QAAQC,SAASC,IAAG,MAC3B;AACZ,QAAMC,QAAQC,KAAKC,IAAG;AACtB,QAAMC,aAAaJ,MAAM;IAACA;MAAO,CAAA;AACjC,QAAMK,qBAAqBT,cAAc;IAAC;MAAQ,CAAA;AAClD,QAAMU,iBAAiBP,UAAU;IAAC;MAAQ,CAAA;AAC1C,QAAMQ,gBAAgBT,SAAS;IAAC;IAAMA;MAAU,CAAA;AAChD,QAAMU,cAAcX,OAAO;IAAC;IAAM,GAAGA,IAAAA;MAAU,CAAA;AAC/C,MAAIA,MAAM;AACRY,YAAQC,IAAIC,OAAMC,KAAK,gBAAgBf,IAAAA,GAAO,CAAA;EAChD;AAEA,QAAMgB,SAAS,MAAMC,cAAc,QAAQlB,cAAc,iBAAiB,EAAA,KAAOI,OAAO,KAAA,KAAU;IAChG;MAAC;MAAQ;QAAC;QAAM;WAAcI;WAAeG;WAAkBD;WAAmBE;WAAgBH;QAAoB;QAAW;;;IACjI;MAAC;MAAQ;QAAC;QAAM;WAAWD;WAAeE;WAAmBD;;;IAC7D;MAAC;MAAQ;QAAC;QAAM;WAAcD;WAAeE;WAAmBE;WAAgBH;;;IAChF;MAAC;MAAQ;QAAC;QAAM;WAAWD;WAAeE;WAAmBE;WAAgBH;;;GAC9E;AACDI,UAAQC,IAAI,GAAGC,OAAMI,KAAK,UAAA,CAAA,KAAgBJ,OAAMK,UAAUd,KAAKC,IAAG,IAAKF,SAAS,KAAMgB,QAAQ,CAAA,CAAA,CAAA,KAAQN,OAAMI,KAAK,SAAA,CAAA,EAAY;AAC7H,SAAOF;AACT,GArBqB;","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","safeExitAsync","func","exitOnFail","result","process","exit","ex","processEx","spawn","existsSync","chalk","runStepAsync","name","step","exitOnFail","message","Promise","resolve","command","args","config","console","log","chalk","gray","argList","Array","isArray","split","existsSync","Error","spawn","env","FORCE_COLOR","process","shell","stdio","on","code","error","red","yellow","white","join","checkResult","runStepsAsync","steps","messages","safeExitAsync","pkgName","npm_package_name","green","result","i","entries","build","incremental","jobs","target","verbose","pkg","start","Date","now","pkgOptions","incrementalOptions","verboseOptions","targetOptions","jobsOptions","console","log","chalk","blue","result","runStepsAsync","gray","magenta","toFixed"]}
1
+ {"version":3,"sources":["../../src/actions/build.ts","../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/runStepsAsync.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { runStepsAsync } from '../lib/index.ts'\n\nexport interface BuildParams {\n incremental?: boolean\n jobs?: number\n pkg?: string\n target?: 'esm' | 'cjs'\n verbose?: boolean\n}\n\nexport const build = async ({\n incremental, jobs, target, verbose, pkg,\n}: BuildParams) => {\n const start = Date.now()\n const pkgOptions = pkg ? [pkg] : [] // must go first\n const incrementalOptions = incremental ? ['-i'] : []\n const verboseOptions = verbose ? ['-v'] : []\n const targetOptions = target ? ['-t', target] : []\n const jobsOptions = jobs ? ['-j', `${jobs}`] : []\n if (jobs) {\n console.log(chalk.blue(`Jobs set to [${jobs}]`))\n }\n\n const result = await runStepsAsync(`Build${incremental ? '-Incremental' : ''} [${pkg ?? 'All'}]`, [\n ['yarn', ['xy', 'compile', ...pkgOptions, ...targetOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions, '--types', 'tsup']],\n ['yarn', ['xy', 'cycle', ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],\n ['yarn', ['xy', 'publint', ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],\n ['yarn', ['xy', 'knip', ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],\n ['yarn', ['xy', 'lint', ...pkgOptions, ...verboseOptions, ...incrementalOptions]],\n ])\n console.log(`${chalk.gray('Built 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 { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport type { ScriptStep } from './runSteps.ts'\nimport { safeExitAsync } from './safeExit.ts'\n\nexport const runStepAsync = (name: string, step: ScriptStep, exitOnFail = true, message?: string) => {\n return new Promise<number>((resolve) => {\n const [command, args, config] = step\n if (message) {\n console.log(chalk.gray(message))\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 spawn(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).on('close', (code) => {\n if (code) {\n console.error(\n chalk.red(\n `Command Exited With Non-Zero Result [${chalk.gray(code)}] | ${chalk.yellow(command)} ${chalk.white(\n Array.isArray(args) ? args.join(' ') : args,\n )}`,\n ),\n )\n checkResult(name, code, 'error', exitOnFail)\n resolve(code)\n } else {\n resolve(0)\n }\n })\n })\n}\n\nexport const runStepsAsync = async (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]) => {\n return await safeExitAsync(async () => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let result = 0\n for (const [i, step] of steps.entries()) {\n result += await runStepAsync(name, step, exitOnFail, messages?.[i])\n }\n return result\n })\n}\n"],"mappings":";;;;AAAA,OAAOA,YAAW;;;ACAlB,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;IAChG;MAAC;MAAQ;QAAC;QAAM;WAAcI;WAAeG;WAAkBD;WAAmBE;WAAgBH;QAAoB;QAAW;;;IACjI;MAAC;MAAQ;QAAC;QAAM;WAAYD;WAAeE;WAAmBE;WAAgBH;;;IAC9E;MAAC;MAAQ;QAAC;QAAM;WAAcD;WAAeE;WAAmBE;WAAgBH;;;IAChF;MAAC;MAAQ;QAAC;QAAM;WAAWD;WAAeE;WAAmBE;WAAgBH;;;IAC7E;MAAC;MAAQ;QAAC;QAAM;WAAWD;WAAeE;WAAmBD;;;GAC9D;AACDI,UAAQC,IAAI,GAAGC,OAAMI,KAAK,UAAA,CAAA,KAAgBJ,OAAMK,UAAUd,KAAKC,IAAG,IAAKF,SAAS,KAAMgB,QAAQ,CAAA,CAAA,CAAA,KAAQN,OAAMI,KAAK,SAAA,CAAA,EAAY;AAC7H,SAAOF;AACT,GAtBqB;","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","safeExitAsync","func","exitOnFail","result","process","exit","ex","processEx","spawn","existsSync","chalk","runStepAsync","name","step","exitOnFail","message","Promise","resolve","command","args","config","console","log","chalk","gray","argList","Array","isArray","split","existsSync","Error","spawn","env","FORCE_COLOR","process","shell","stdio","on","code","error","red","yellow","white","join","checkResult","runStepsAsync","steps","messages","safeExitAsync","pkgName","npm_package_name","green","result","i","entries","build","incremental","jobs","target","verbose","pkg","start","Date","now","pkgOptions","incrementalOptions","verboseOptions","targetOptions","jobsOptions","console","log","chalk","blue","result","runStepsAsync","gray","magenta","toFixed"]}
@@ -2,31 +2,174 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/actions/cycle.ts
5
- import { ESLint } from "eslint";
6
- var cycle = /* @__PURE__ */ __name(async () => {
7
- const eslint = new ESLint({
8
- fix: false,
9
- overrideConfig: {
10
- rules: {
11
- "import-x/no-cycle": [
12
- "error",
13
- {
14
- maxDepth: 10
15
- }
16
- ]
5
+ import chalk4 from "chalk";
6
+
7
+ // src/lib/checkResult.ts
8
+ import chalk from "chalk";
9
+ var checkResult = /* @__PURE__ */ __name((name, result, level = "error", exitOnFail = false) => {
10
+ if (result) {
11
+ const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
12
+ const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
13
+ console[level](chalkFunc(`${name} had ${result} failures ${exiting}`));
14
+ if (exitOnFail) {
15
+ process.exit(result);
16
+ }
17
+ }
18
+ }, "checkResult");
19
+
20
+ // src/lib/processEx.ts
21
+ import chalk2 from "chalk";
22
+
23
+ // src/lib/withError.ts
24
+ var withError = /* @__PURE__ */ __name((ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
25
+ return predicate(ex) ? closure(ex) : void 0;
26
+ }, "withError");
27
+
28
+ // src/lib/withErrnoException.ts
29
+ var withErrnoException = /* @__PURE__ */ __name((ex, closure) => {
30
+ return withError(ex, closure, (ex2) => ex2.errno !== void 0);
31
+ }, "withErrnoException");
32
+
33
+ // src/lib/processEx.ts
34
+ var processEx = /* @__PURE__ */ __name((ex) => {
35
+ const error = typeof ex === "string" ? new Error(ex) : ex;
36
+ const exitCode = withErrnoException(error, (error2) => {
37
+ if (error2.code === "ENOENT") {
38
+ console.error(chalk2.red(`'${error2.path}' not found.`));
39
+ } else {
40
+ console.error(chalk2.red(`Errno: ${error2.code}`));
41
+ }
42
+ return error2.errno ?? -1;
43
+ }) ?? withError(error, (error2) => {
44
+ console.error(chalk2.red(`${error2.name}: ${error2.message}`));
45
+ return -1;
46
+ }) ?? (() => {
47
+ console.error(chalk2.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`));
48
+ return -1;
49
+ })();
50
+ process.exit(process.exitCode ?? exitCode);
51
+ }, "processEx");
52
+
53
+ // src/lib/safeExit.ts
54
+ var safeExit = /* @__PURE__ */ __name((func, exitOnFail = true) => {
55
+ try {
56
+ const result = func();
57
+ if (result && exitOnFail) {
58
+ process.exit(result);
59
+ }
60
+ return result;
61
+ } catch (ex) {
62
+ return processEx(ex);
63
+ }
64
+ }, "safeExit");
65
+
66
+ // src/lib/runSteps.ts
67
+ import { spawnSync } from "node:child_process";
68
+ import { existsSync } from "node:fs";
69
+ import chalk3 from "chalk";
70
+ var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages) => {
71
+ return safeExit(() => {
72
+ const pkgName = process.env.npm_package_name;
73
+ console.log(chalk3.green(`${name} [${pkgName}]`));
74
+ let totalStatus = 0;
75
+ for (const [i, [command, args, config]] of steps.entries()) {
76
+ if (messages?.[i]) {
77
+ console.log(chalk3.gray(messages?.[i]));
17
78
  }
79
+ const argList = Array.isArray(args) ? args : args.split(" ");
80
+ if (command === "node" && !existsSync(argList[0])) {
81
+ throw new Error(`File not found [${argList[0]}]`);
82
+ }
83
+ const status = spawnSync(command, Array.isArray(args) ? args : args.split(" "), {
84
+ ...config,
85
+ encoding: "utf8",
86
+ env: {
87
+ FORCE_COLOR: "3",
88
+ ...process.env
89
+ },
90
+ shell: true,
91
+ stdio: "inherit"
92
+ }).status ?? 0;
93
+ checkResult(name, status, "error", exitOnFail);
94
+ totalStatus += status ?? 0;
18
95
  }
96
+ return totalStatus;
97
+ }, !!exitOnFail);
98
+ }, "runSteps");
99
+
100
+ // src/actions/cycle.ts
101
+ var cycle = /* @__PURE__ */ __name(({ verbose, pkg, incremental, jobs } = {}) => {
102
+ return pkg ? cyclePackage({
103
+ pkg,
104
+ verbose
105
+ }) : cycleAll({
106
+ incremental,
107
+ verbose,
108
+ jobs
19
109
  });
20
- const results = await eslint.lintFiles([
21
- "src/**/*.ts*",
22
- "packages/**/src/**/*.ts*"
23
- ]);
24
- const formatter = await eslint.loadFormatter("stylish");
25
- const resultText = formatter.format(results);
26
- console.log(resultText);
27
- return results.length;
28
110
  }, "cycle");
111
+ var cyclePackage = /* @__PURE__ */ __name(({ pkg, verbose }) => {
112
+ const verboseOptions = verbose ? [
113
+ "--verbose"
114
+ ] : [
115
+ "--no-verbose"
116
+ ];
117
+ return runSteps(`Cycle [${pkg}]`, [
118
+ [
119
+ "yarn",
120
+ [
121
+ "workspace",
122
+ pkg,
123
+ "run",
124
+ "package-cycle",
125
+ ...verboseOptions
126
+ ]
127
+ ]
128
+ ]);
129
+ }, "cyclePackage");
130
+ var cycleAll = /* @__PURE__ */ __name(({ jobs, verbose, incremental }) => {
131
+ const start = Date.now();
132
+ const verboseOptions = verbose ? [
133
+ "--verbose"
134
+ ] : [
135
+ "--no-verbose"
136
+ ];
137
+ const incrementalOptions = incremental ? [
138
+ "--since",
139
+ "-Ap",
140
+ "--topological-dev"
141
+ ] : [
142
+ "--parallel",
143
+ "-Ap"
144
+ ];
145
+ const jobsOptions = jobs ? [
146
+ "-j",
147
+ `${jobs}`
148
+ ] : [];
149
+ if (jobs) {
150
+ console.log(chalk4.blue(`Jobs set to [${jobs}]`));
151
+ }
152
+ const result = runSteps(`Cycle${incremental ? "-Incremental" : ""} [All]`, [
153
+ [
154
+ "yarn",
155
+ [
156
+ "workspaces",
157
+ "foreach",
158
+ ...incrementalOptions,
159
+ ...jobsOptions,
160
+ ...verboseOptions,
161
+ "run",
162
+ "package-cycle",
163
+ ...verboseOptions
164
+ ]
165
+ ]
166
+ ]);
167
+ console.log(`${chalk4.gray("Cycles Checked in")} [${chalk4.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk4.gray("seconds")}`);
168
+ return result;
169
+ }, "cycleAll");
29
170
  export {
30
- cycle
171
+ cycle,
172
+ cycleAll,
173
+ cyclePackage
31
174
  };
32
175
  //# sourceMappingURL=cycle.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/actions/cycle.ts"],"sourcesContent":["import { ESLint } from 'eslint'\n\nexport const cycle = async () => {\n const eslint = new ESLint({\n fix: false,\n overrideConfig: { rules: { 'import-x/no-cycle': ['error', { maxDepth: 10 }] } },\n })\n const results = await eslint.lintFiles(['src/**/*.ts*', 'packages/**/src/**/*.ts*'])\n\n const formatter = await eslint.loadFormatter('stylish')\n const resultText = formatter.format(results)\n console.log(resultText)\n\n return results.length\n}\n"],"mappings":";;;;AAAA,SAASA,cAAc;AAEhB,IAAMC,QAAQ,mCAAA;AACnB,QAAMC,SAAS,IAAIC,OAAO;IACxBC,KAAK;IACLC,gBAAgB;MAAEC,OAAO;QAAE,qBAAqB;UAAC;UAAS;YAAEC,UAAU;UAAG;;MAAG;IAAE;EAChF,CAAA;AACA,QAAMC,UAAU,MAAMN,OAAOO,UAAU;IAAC;IAAgB;GAA2B;AAEnF,QAAMC,YAAY,MAAMR,OAAOS,cAAc,SAAA;AAC7C,QAAMC,aAAaF,UAAUG,OAAOL,OAAAA;AACpCM,UAAQC,IAAIH,UAAAA;AAEZ,SAAOJ,QAAQQ;AACjB,GAZqB;","names":["ESLint","cycle","eslint","ESLint","fix","overrideConfig","rules","maxDepth","results","lintFiles","formatter","loadFormatter","resultText","format","console","log","length"]}
1
+ {"version":3,"sources":["../../src/actions/cycle.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 } from '../lib/index.ts'\n\nexport interface CycleParams {\n incremental?: boolean\n jobs?: number\n pkg?: string\n verbose?: boolean\n}\n\ninterface CyclePackageParams {\n pkg: string\n verbose?: boolean\n}\n\nexport const cycle = ({\n verbose, pkg, incremental, jobs,\n}: CycleParams = {}) => {\n return pkg\n ? cyclePackage({ pkg, verbose })\n : cycleAll({\n incremental, verbose, jobs,\n })\n}\n\nexport const cyclePackage = ({ pkg, verbose }: CyclePackageParams) => {\n const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n return runSteps(\n `Cycle [${pkg}]`,\n [['yarn', ['workspace', pkg, 'run', 'package-cycle', ...verboseOptions]]],\n )\n}\n\nexport const cycleAll = ({\n jobs, verbose, incremental,\n}: CycleParams) => {\n const start = Date.now()\n const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n const incrementalOptions = incremental ? ['--since', '-Ap', '--topological-dev'] : ['--parallel', '-Ap']\n const jobsOptions = jobs ? ['-j', `${jobs}`] : []\n if (jobs) {\n console.log(chalk.blue(`Jobs set to [${jobs}]`))\n }\n\n const result = runSteps(`Cycle${incremental ? '-Incremental' : ''} [All]`, [\n ['yarn', ['workspaces',\n 'foreach',\n ...incrementalOptions,\n ...jobsOptions,\n ...verboseOptions,\n 'run',\n 'package-cycle',\n ...verboseOptions,\n ]],\n ])\n console.log(`${chalk.gray('Cycles 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 type { SpawnSyncOptionsWithBufferEncoding } from 'node:child_process'\nimport { spawnSync } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport { safeExit } from './safeExit.ts'\n\nexport type ScriptStep =\n | [/* command */ 'yarn' | 'node' | 'ts-node-script' | 'tsc' | 'jest', /* arg */ string | string[]]\n | [/* command */ string, /* arg */ string | string[], /* config */ SpawnSyncOptionsWithBufferEncoding]\n\nexport const runSteps = (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]): number => {\n return safeExit(() => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let totalStatus = 0\n for (const [i, [command, args, config]] of steps.entries()) {\n if (messages?.[i]) {\n console.log(chalk.gray(messages?.[i]))\n }\n const argList = Array.isArray(args) ? args : args.split(' ')\n if (command === 'node' && !existsSync(argList[0])) {\n throw new Error(`File not found [${argList[0]}]`)\n }\n const status\n = spawnSync(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n encoding: 'utf8',\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).status ?? 0\n checkResult(name, status, 'error', exitOnFail)\n totalStatus += status ?? 0\n }\n return totalStatus\n }, !!exitOnFail)\n}\n"],"mappings":";;;;AAAA,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,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,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K,gBAAgBb,IAAAA,GAAO,CAAA;EAChD;AAEA,QAAMc,SAASV,SAAS,QAAQL,cAAc,iBAAiB,EAAA,UAAY;IACzE;MAAC;MAAQ;QAAC;QACR;WACGS;WACAC;WACAN;QACH;QACA;WACGA;;;GAEN;AACDO,UAAQC,IAAI,GAAGC,OAAMG,KAAK,mBAAA,CAAA,KAAyBH,OAAMI,UAAUV,KAAKC,IAAG,IAAKF,SAAS,KAAMY,QAAQ,CAAA,CAAA,CAAA,KAAQL,OAAMG,KAAK,SAAA,CAAA,EAAY;AACtI,SAAOD;AACT,GAxBwB;","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","cycle","verbose","pkg","incremental","jobs","cyclePackage","cycleAll","verboseOptions","runSteps","start","Date","now","incrementalOptions","jobsOptions","console","log","chalk","blue","result","gray","magenta","toFixed"]}