@xylabs/ts-scripts-yarn3 7.4.20 → 7.4.22

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 (109) hide show
  1. package/dist/actions/claude-clean.mjs +71 -0
  2. package/dist/actions/claude-clean.mjs.map +1 -0
  3. package/dist/actions/claude-commands.mjs +11 -2
  4. package/dist/actions/claude-commands.mjs.map +1 -1
  5. package/dist/actions/claude-rules.mjs +27 -7
  6. package/dist/actions/claude-rules.mjs.map +1 -1
  7. package/dist/actions/claude-skills.mjs.map +1 -1
  8. package/dist/actions/dupdeps.mjs +3 -2
  9. package/dist/actions/dupdeps.mjs.map +1 -1
  10. package/dist/actions/gitignore.mjs +152 -0
  11. package/dist/actions/gitignore.mjs.map +1 -0
  12. package/dist/actions/index.mjs +392 -206
  13. package/dist/actions/index.mjs.map +1 -1
  14. package/dist/bin/xy.mjs +432 -226
  15. package/dist/bin/xy.mjs.map +1 -1
  16. package/dist/index.d.ts +11 -3
  17. package/dist/index.mjs +495 -282
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/lib/claudeMdTemplate.mjs +5 -1
  20. package/dist/lib/claudeMdTemplate.mjs.map +1 -1
  21. package/dist/lib/gitignoreTemplate.mjs +12 -0
  22. package/dist/lib/gitignoreTemplate.mjs.map +1 -0
  23. package/dist/lib/index.mjs +17 -3
  24. package/dist/lib/index.mjs.map +1 -1
  25. package/dist/xy/build/buildCommand.mjs +161 -0
  26. package/dist/xy/build/buildCommand.mjs.map +1 -0
  27. package/dist/xy/build/compileCommand.mjs +174 -0
  28. package/dist/xy/build/compileCommand.mjs.map +1 -0
  29. package/dist/xy/build/compileOnlyCommand.mjs +175 -0
  30. package/dist/xy/build/compileOnlyCommand.mjs.map +1 -0
  31. package/dist/xy/build/copyAssetsCommand.mjs +84 -0
  32. package/dist/xy/build/copyAssetsCommand.mjs.map +1 -0
  33. package/dist/xy/{build-commands → build}/index.mjs +45 -40
  34. package/dist/xy/build/index.mjs.map +1 -0
  35. package/dist/xy/build/rebuildCommand.mjs +114 -0
  36. package/dist/xy/build/rebuildCommand.mjs.map +1 -0
  37. package/dist/xy/build/recompileCommand.mjs +204 -0
  38. package/dist/xy/build/recompileCommand.mjs.map +1 -0
  39. package/dist/xy/common/claude/cleanCommand.mjs +79 -0
  40. package/dist/xy/common/claude/cleanCommand.mjs.map +1 -0
  41. package/dist/xy/common/claude/commandsCommand.mjs +11 -2
  42. package/dist/xy/common/claude/commandsCommand.mjs.map +1 -1
  43. package/dist/xy/common/claude/index.mjs +171 -69
  44. package/dist/xy/common/claude/index.mjs.map +1 -1
  45. package/dist/xy/common/claude/initCommand.mjs +38 -115
  46. package/dist/xy/common/claude/initCommand.mjs.map +1 -1
  47. package/dist/xy/common/claude/rulesCommand.mjs +27 -7
  48. package/dist/xy/common/claude/rulesCommand.mjs.map +1 -1
  49. package/dist/xy/common/claude/skillsCommand.mjs.map +1 -1
  50. package/dist/xy/common/gitignoreCommand.mjs +158 -0
  51. package/dist/xy/common/gitignoreCommand.mjs.map +1 -0
  52. package/dist/xy/common/index.mjs +304 -109
  53. package/dist/xy/common/index.mjs.map +1 -1
  54. package/dist/xy/index.mjs +432 -226
  55. package/dist/xy/index.mjs.map +1 -1
  56. package/dist/xy/install/dupdepsCommand.mjs +3 -2
  57. package/dist/xy/install/dupdepsCommand.mjs.map +1 -1
  58. package/dist/xy/install/index.mjs +3 -2
  59. package/dist/xy/install/index.mjs.map +1 -1
  60. package/dist/xy/xy.mjs +432 -226
  61. package/dist/xy/xy.mjs.map +1 -1
  62. package/package.json +2 -2
  63. package/templates/claude/CLAUDE-local.md +4 -0
  64. package/templates/claude/commands/xy-dead.md +5 -0
  65. package/templates/claude/{rules/xylabs-dependencies.md → commands/xy-deps.md} +7 -7
  66. package/templates/claude/commands/xy-dupdeps.md +5 -0
  67. package/templates/claude/commands/xy-gen-docs.md +5 -0
  68. package/templates/claude/commands/xy-gitignore.md +5 -0
  69. package/templates/claude/commands/xy-gitlint.md +5 -0
  70. package/templates/claude/commands/xy-license.md +5 -0
  71. package/templates/claude/commands/xy-lint-rules.md +44 -0
  72. package/templates/claude/commands/xy-recompile.md +5 -0
  73. package/templates/claude/commands/xy-reinstall.md +5 -0
  74. package/templates/claude/commands/xy-relint.md +5 -0
  75. package/templates/claude/commands/xy-retest.md +5 -0
  76. package/templates/claude/commands/xy-sonar.md +5 -0
  77. package/templates/claude/commands/xy-up.md +7 -0
  78. package/templates/claude/rules/xylabs-architecture.md +4 -7
  79. package/templates/claude/rules/xylabs-build.md +6 -11
  80. package/templates/claude/rules/xylabs-git-workflow.md +3 -5
  81. package/templates/claude/rules/xylabs-naming.md +4 -7
  82. package/templates/claude/rules/xylabs-style.md +14 -19
  83. package/templates/claude/skills/xylabs-e2e-setup/SKILL.md +16 -2
  84. package/templates/gitignore/template.gitignore +40 -0
  85. package/dist/actions/gitignore-gen.mjs +0 -88
  86. package/dist/actions/gitignore-gen.mjs.map +0 -1
  87. package/dist/xy/build-commands/build.mjs +0 -502
  88. package/dist/xy/build-commands/build.mjs.map +0 -1
  89. package/dist/xy/build-commands/index.mjs.map +0 -1
  90. package/dist/xy/common/gitignoreGenCommand.mjs +0 -98
  91. package/dist/xy/common/gitignoreGenCommand.mjs.map +0 -1
  92. package/templates/claude/commands/xylabs-deploy-major.md +0 -7
  93. package/templates/claude/commands/xylabs-deploy-minor.md +0 -7
  94. package/templates/claude/commands/xylabs-deploy.md +0 -7
  95. package/templates/claude/rules/xylabs-error-handling.md +0 -7
  96. package/templates/claude/rules/xylabs-frameworks.md +0 -8
  97. package/templates/claude/rules/xylabs-linting.md +0 -55
  98. package/templates/claude/rules/xylabs-typescript.md +0 -11
  99. /package/templates/claude/commands/{xylabs-build.md → xy-build.md} +0 -0
  100. /package/templates/claude/commands/{xylabs-clean.md → xy-clean.md} +0 -0
  101. /package/templates/claude/commands/{xylabs-compile.md → xy-compile.md} +0 -0
  102. /package/templates/claude/commands/{xylabs-cycle.md → xy-cycle.md} +0 -0
  103. /package/templates/claude/commands/{xylabs-deplint.md → xy-deplint.md} +0 -0
  104. /package/templates/claude/commands/{xylabs-fix.md → xy-fix.md} +0 -0
  105. /package/templates/claude/commands/{xylabs-knip.md → xy-knip.md} +0 -0
  106. /package/templates/claude/commands/{xylabs-lint.md → xy-lint.md} +0 -0
  107. /package/templates/claude/commands/{xylabs-publint.md → xy-publint.md} +0 -0
  108. /package/templates/claude/commands/{xylabs-rebuild.md → xy-rebuild.md} +0 -0
  109. /package/templates/claude/commands/{xylabs-test.md → xy-test.md} +0 -0
@@ -0,0 +1,174 @@
1
+ // src/lib/checkResult.ts
2
+ import chalk from "chalk";
3
+ var checkResult = (name, result, level = "error", exitOnFail = false) => {
4
+ if (result) {
5
+ const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
6
+ const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
7
+ console[level](chalkFunc(`${name} had ${result} failures ${exiting}`));
8
+ if (exitOnFail) {
9
+ process.exit(result);
10
+ }
11
+ }
12
+ };
13
+
14
+ // src/lib/processEx.ts
15
+ import chalk2 from "chalk";
16
+
17
+ // src/lib/withError.ts
18
+ var withError = (ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
19
+ return predicate(ex) ? closure(ex) : void 0;
20
+ };
21
+
22
+ // src/lib/withErrnoException.ts
23
+ var withErrnoException = (ex, closure) => {
24
+ return withError(ex, closure, (ex2) => ex2.errno !== void 0);
25
+ };
26
+
27
+ // src/lib/processEx.ts
28
+ var processEx = (ex) => {
29
+ const error = typeof ex === "string" ? new Error(ex) : ex;
30
+ const exitCode = withErrnoException(error, (error2) => {
31
+ if (error2.code === "ENOENT") {
32
+ console.error(chalk2.red(`'${error2.path}' not found.`));
33
+ } else {
34
+ console.error(chalk2.red(`Errno: ${error2.code}`));
35
+ }
36
+ return error2.errno ?? -1;
37
+ }) ?? withError(error, (error2) => {
38
+ console.error(chalk2.red(`${error2.name}: ${error2.message}`));
39
+ return -1;
40
+ }) ?? (() => {
41
+ console.error(chalk2.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`));
42
+ return -1;
43
+ })();
44
+ process.exit(process.exitCode ?? exitCode);
45
+ };
46
+
47
+ // src/lib/safeExit.ts
48
+ var safeExit = (func, exitOnFail = true) => {
49
+ try {
50
+ const result = func();
51
+ if (result && exitOnFail) {
52
+ process.exit(result);
53
+ }
54
+ return result;
55
+ } catch (ex) {
56
+ return processEx(ex);
57
+ }
58
+ };
59
+
60
+ // src/lib/runSteps.ts
61
+ import { spawnSync } from "child_process";
62
+ import { existsSync } from "fs";
63
+ import chalk3 from "chalk";
64
+ var runSteps = (name, steps, exitOnFail = true, messages) => {
65
+ return safeExit(() => {
66
+ const pkgName = process.env.npm_package_name;
67
+ console.log(chalk3.green(`${name} [${pkgName}]`));
68
+ let totalStatus = 0;
69
+ for (const [i, [command, args, config]] of steps.entries()) {
70
+ if (messages?.[i]) {
71
+ console.log(chalk3.gray(messages?.[i]));
72
+ }
73
+ const argList = Array.isArray(args) ? args : args.split(" ");
74
+ if (command === "node" && !existsSync(argList[0])) {
75
+ throw new Error(`File not found [${argList[0]}]`);
76
+ }
77
+ const status = spawnSync(command, Array.isArray(args) ? args : args.split(" "), {
78
+ ...config,
79
+ encoding: "utf8",
80
+ env: { FORCE_COLOR: "3", ...process.env },
81
+ shell: true,
82
+ stdio: "inherit"
83
+ }).status ?? 0;
84
+ checkResult(name, status, "error", exitOnFail);
85
+ totalStatus += status ?? 0;
86
+ }
87
+ return totalStatus;
88
+ }, !!exitOnFail);
89
+ };
90
+
91
+ // src/actions/compile.ts
92
+ import chalk4 from "chalk";
93
+ var compile = ({
94
+ verbose,
95
+ target,
96
+ pkg,
97
+ incremental,
98
+ publint,
99
+ jobs
100
+ }) => {
101
+ return pkg ? compilePackage({
102
+ pkg,
103
+ publint,
104
+ target,
105
+ verbose
106
+ }) : compileAll({
107
+ incremental,
108
+ publint,
109
+ target,
110
+ verbose,
111
+ jobs
112
+ });
113
+ };
114
+ var compilePackage = ({ target, pkg }) => {
115
+ const targetOptions = target ? ["-t", target] : [];
116
+ return runSteps(
117
+ `Compile [${pkg}]`,
118
+ [["yarn", ["workspace", pkg, "run", "package-compile", ...targetOptions]]]
119
+ );
120
+ };
121
+ var compileAll = ({
122
+ jobs,
123
+ verbose,
124
+ target,
125
+ incremental
126
+ }) => {
127
+ const start = Date.now();
128
+ const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
129
+ const targetOptions = target ? ["-t", target] : [];
130
+ const incrementalOptions = incremental ? ["--since", "-Ap", "--topological-dev"] : ["--parallel", "-Ap", "--topological-dev"];
131
+ const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
132
+ if (jobs) {
133
+ console.log(chalk4.blue(`Jobs set to [${jobs}]`));
134
+ }
135
+ const result = runSteps(`Compile${incremental ? "-Incremental" : ""} [All]`, [
136
+ ["yarn", [
137
+ "workspaces",
138
+ "foreach",
139
+ ...incrementalOptions,
140
+ ...jobsOptions,
141
+ ...verboseOptions,
142
+ "run",
143
+ "package-compile",
144
+ ...targetOptions
145
+ ]]
146
+ ]);
147
+ console.log(`${chalk4.gray("Compiled in")} [${chalk4.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk4.gray("seconds")}`);
148
+ return result;
149
+ };
150
+
151
+ // src/xy/build/compileCommand.ts
152
+ var compileCommand = {
153
+ command: "compile [package]",
154
+ describe: "Compile with Typescript & Copy Images",
155
+ builder: (yargs) => {
156
+ return yargs.positional("package", { describe: "Specific package to compile" });
157
+ },
158
+ handler: (argv) => {
159
+ if (argv.verbose) {
160
+ console.log(`Compiling: ${argv.package ?? "all"}`);
161
+ }
162
+ process.exitCode = compile({
163
+ incremental: !!argv.incremental,
164
+ jobs: argv.jobs,
165
+ pkg: argv.package,
166
+ target: argv.target,
167
+ verbose: !!argv.verbose
168
+ });
169
+ }
170
+ };
171
+ export {
172
+ compileCommand
173
+ };
174
+ //# sourceMappingURL=compileCommand.mjs.map
@@ -0,0 +1 @@
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/compile.ts","../../../src/xy/build/compileCommand.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 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' | 'npm' | 'vitest', /* 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 chalk from 'chalk'\n\nimport { runSteps } from '../lib/index.ts'\n\nexport interface CompileParams {\n incremental?: boolean\n jobs?: number\n pkg?: string\n publint?: boolean\n target?: 'esm' | 'cjs'\n verbose?: boolean\n}\n\ninterface CompilePackageParams {\n pkg: string\n publint?: boolean\n target?: 'esm' | 'cjs'\n verbose?: boolean\n}\n\nexport const compile = ({\n verbose, target, pkg, incremental, publint, jobs,\n}: CompileParams) => {\n return pkg\n ? compilePackage({\n pkg, publint, target, verbose,\n })\n : compileAll({\n incremental, publint, target, verbose, jobs,\n })\n}\n\nexport const compilePackage = ({ target, pkg }: CompilePackageParams) => {\n const targetOptions = target ? ['-t', target] : []\n\n return runSteps(\n `Compile [${pkg}]`,\n [['yarn', ['workspace', pkg, 'run', 'package-compile', ...targetOptions]]],\n )\n}\n\nexport const compileAll = ({\n jobs, verbose, target, incremental,\n}: CompileParams) => {\n const start = Date.now()\n const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n const targetOptions = target ? ['-t', target] : []\n const incrementalOptions = incremental ? ['--since', '-Ap', '--topological-dev'] : ['--parallel', '-Ap', '--topological-dev']\n const jobsOptions = jobs ? ['-j', `${jobs}`] : []\n if (jobs) {\n console.log(chalk.blue(`Jobs set to [${jobs}]`))\n }\n\n const result = runSteps(`Compile${incremental ? '-Incremental' : ''} [All]`, [\n ['yarn', ['workspaces',\n 'foreach',\n ...incrementalOptions,\n ...jobsOptions,\n ...verboseOptions,\n 'run',\n 'package-compile',\n ...targetOptions,\n ]],\n ])\n console.log(`${chalk.gray('Compiled in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`)\n return result\n}\n","import type { CommandModule } from 'yargs'\n\nimport { compile } from '../../actions/index.ts'\n\nexport const compileCommand: CommandModule = {\n command: 'compile [package]',\n describe: 'Compile with Typescript & Copy Images',\n builder: (yargs) => {\n return yargs.positional('package', { describe: 'Specific package to compile' })\n },\n handler: (argv) => {\n if (argv.verbose) {\n console.log(`Compiling: ${argv.package ?? 'all'}`)\n }\n process.exitCode = compile({\n incremental: !!argv.incremental,\n jobs: argv.jobs as number,\n pkg: argv.package as string,\n target: argv.target as 'esm' | 'cjs',\n verbose: !!argv.verb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R;AAAA,MACA,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACD,UAAQ,IAAI,GAAGA,OAAM,KAAK,aAAa,CAAC,KAAKA,OAAM,UAAU,KAAK,IAAI,IAAI,SAAS,KAAM,QAAQ,CAAC,CAAC,CAAC,KAAKA,OAAM,KAAK,SAAS,CAAC,EAAE;AAChI,SAAO;AACT;;;AC9DO,IAAM,iBAAgC;AAAA,EAC3C,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS,CAAC,UAAU;AAClB,WAAO,MAAM,WAAW,WAAW,EAAE,UAAU,8BAA8B,CAAC;AAAA,EAChF;AAAA,EACA,SAAS,CAAC,SAAS;AACjB,QAAI,KAAK,SAAS;AAChB,cAAQ,IAAI,cAAc,KAAK,WAAW,KAAK,EAAE;AAAA,IACnD;AACA,YAAQ,WAAW,QAAQ;AAAA,MACzB,aAAa,CAAC,CAAC,KAAK;AAAA,MACpB,MAAM,KAAK;AAAA,MACX,KAAK,KAAK;AAAA,MACV,QAAQ,KAAK;AAAA,MACb,SAAS,CAAC,CAAC,KAAK;AAAA,IAClB,CAAC;AAAA,EACH;AACF;","names":["chalk","ex","ex","error","chalk","chalk","chalk","chalk","chalk"]}
@@ -0,0 +1,175 @@
1
+ // src/lib/checkResult.ts
2
+ import chalk from "chalk";
3
+ var checkResult = (name, result, level = "error", exitOnFail = false) => {
4
+ if (result) {
5
+ const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
6
+ const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
7
+ console[level](chalkFunc(`${name} had ${result} failures ${exiting}`));
8
+ if (exitOnFail) {
9
+ process.exit(result);
10
+ }
11
+ }
12
+ };
13
+
14
+ // src/lib/processEx.ts
15
+ import chalk2 from "chalk";
16
+
17
+ // src/lib/withError.ts
18
+ var withError = (ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
19
+ return predicate(ex) ? closure(ex) : void 0;
20
+ };
21
+
22
+ // src/lib/withErrnoException.ts
23
+ var withErrnoException = (ex, closure) => {
24
+ return withError(ex, closure, (ex2) => ex2.errno !== void 0);
25
+ };
26
+
27
+ // src/lib/processEx.ts
28
+ var processEx = (ex) => {
29
+ const error = typeof ex === "string" ? new Error(ex) : ex;
30
+ const exitCode = withErrnoException(error, (error2) => {
31
+ if (error2.code === "ENOENT") {
32
+ console.error(chalk2.red(`'${error2.path}' not found.`));
33
+ } else {
34
+ console.error(chalk2.red(`Errno: ${error2.code}`));
35
+ }
36
+ return error2.errno ?? -1;
37
+ }) ?? withError(error, (error2) => {
38
+ console.error(chalk2.red(`${error2.name}: ${error2.message}`));
39
+ return -1;
40
+ }) ?? (() => {
41
+ console.error(chalk2.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`));
42
+ return -1;
43
+ })();
44
+ process.exit(process.exitCode ?? exitCode);
45
+ };
46
+
47
+ // src/lib/safeExit.ts
48
+ var safeExit = (func, exitOnFail = true) => {
49
+ try {
50
+ const result = func();
51
+ if (result && exitOnFail) {
52
+ process.exit(result);
53
+ }
54
+ return result;
55
+ } catch (ex) {
56
+ return processEx(ex);
57
+ }
58
+ };
59
+
60
+ // src/lib/runSteps.ts
61
+ import { spawnSync } from "child_process";
62
+ import { existsSync } from "fs";
63
+ import chalk3 from "chalk";
64
+ var runSteps = (name, steps, exitOnFail = true, messages) => {
65
+ return safeExit(() => {
66
+ const pkgName = process.env.npm_package_name;
67
+ console.log(chalk3.green(`${name} [${pkgName}]`));
68
+ let totalStatus = 0;
69
+ for (const [i, [command, args, config]] of steps.entries()) {
70
+ if (messages?.[i]) {
71
+ console.log(chalk3.gray(messages?.[i]));
72
+ }
73
+ const argList = Array.isArray(args) ? args : args.split(" ");
74
+ if (command === "node" && !existsSync(argList[0])) {
75
+ throw new Error(`File not found [${argList[0]}]`);
76
+ }
77
+ const status = spawnSync(command, Array.isArray(args) ? args : args.split(" "), {
78
+ ...config,
79
+ encoding: "utf8",
80
+ env: { FORCE_COLOR: "3", ...process.env },
81
+ shell: true,
82
+ stdio: "inherit"
83
+ }).status ?? 0;
84
+ checkResult(name, status, "error", exitOnFail);
85
+ totalStatus += status ?? 0;
86
+ }
87
+ return totalStatus;
88
+ }, !!exitOnFail);
89
+ };
90
+
91
+ // src/actions/compile.ts
92
+ import chalk4 from "chalk";
93
+ var compile = ({
94
+ verbose,
95
+ target,
96
+ pkg,
97
+ incremental,
98
+ publint,
99
+ jobs
100
+ }) => {
101
+ return pkg ? compilePackage({
102
+ pkg,
103
+ publint,
104
+ target,
105
+ verbose
106
+ }) : compileAll({
107
+ incremental,
108
+ publint,
109
+ target,
110
+ verbose,
111
+ jobs
112
+ });
113
+ };
114
+ var compilePackage = ({ target, pkg }) => {
115
+ const targetOptions = target ? ["-t", target] : [];
116
+ return runSteps(
117
+ `Compile [${pkg}]`,
118
+ [["yarn", ["workspace", pkg, "run", "package-compile", ...targetOptions]]]
119
+ );
120
+ };
121
+ var compileAll = ({
122
+ jobs,
123
+ verbose,
124
+ target,
125
+ incremental
126
+ }) => {
127
+ const start = Date.now();
128
+ const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
129
+ const targetOptions = target ? ["-t", target] : [];
130
+ const incrementalOptions = incremental ? ["--since", "-Ap", "--topological-dev"] : ["--parallel", "-Ap", "--topological-dev"];
131
+ const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
132
+ if (jobs) {
133
+ console.log(chalk4.blue(`Jobs set to [${jobs}]`));
134
+ }
135
+ const result = runSteps(`Compile${incremental ? "-Incremental" : ""} [All]`, [
136
+ ["yarn", [
137
+ "workspaces",
138
+ "foreach",
139
+ ...incrementalOptions,
140
+ ...jobsOptions,
141
+ ...verboseOptions,
142
+ "run",
143
+ "package-compile",
144
+ ...targetOptions
145
+ ]]
146
+ ]);
147
+ console.log(`${chalk4.gray("Compiled in")} [${chalk4.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk4.gray("seconds")}`);
148
+ return result;
149
+ };
150
+
151
+ // src/xy/build/compileOnlyCommand.ts
152
+ var compileOnlyCommand = {
153
+ command: "compile-only [package]",
154
+ describe: "Compile with Typescript & Copy Images (No Publint)",
155
+ builder: (yargs) => {
156
+ return yargs.positional("package", { describe: "Specific package to compile" });
157
+ },
158
+ handler: (argv) => {
159
+ if (argv.verbose) {
160
+ console.log(`Compiling: ${argv.package ?? "all"}`);
161
+ }
162
+ process.exitCode = compile({
163
+ incremental: !!argv.incremental,
164
+ jobs: argv.jobs,
165
+ pkg: argv.package,
166
+ publint: false,
167
+ target: argv.target,
168
+ verbose: !!argv.verbose
169
+ });
170
+ }
171
+ };
172
+ export {
173
+ compileOnlyCommand
174
+ };
175
+ //# sourceMappingURL=compileOnlyCommand.mjs.map
@@ -0,0 +1 @@
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/compile.ts","../../../src/xy/build/compileOnlyCommand.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 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' | 'npm' | 'vitest', /* 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 chalk from 'chalk'\n\nimport { runSteps } from '../lib/index.ts'\n\nexport interface CompileParams {\n incremental?: boolean\n jobs?: number\n pkg?: string\n publint?: boolean\n target?: 'esm' | 'cjs'\n verbose?: boolean\n}\n\ninterface CompilePackageParams {\n pkg: string\n publint?: boolean\n target?: 'esm' | 'cjs'\n verbose?: boolean\n}\n\nexport const compile = ({\n verbose, target, pkg, incremental, publint, jobs,\n}: CompileParams) => {\n return pkg\n ? compilePackage({\n pkg, publint, target, verbose,\n })\n : compileAll({\n incremental, publint, target, verbose, jobs,\n })\n}\n\nexport const compilePackage = ({ target, pkg }: CompilePackageParams) => {\n const targetOptions = target ? ['-t', target] : []\n\n return runSteps(\n `Compile [${pkg}]`,\n [['yarn', ['workspace', pkg, 'run', 'package-compile', ...targetOptions]]],\n )\n}\n\nexport const compileAll = ({\n jobs, verbose, target, incremental,\n}: CompileParams) => {\n const start = Date.now()\n const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n const targetOptions = target ? ['-t', target] : []\n const incrementalOptions = incremental ? ['--since', '-Ap', '--topological-dev'] : ['--parallel', '-Ap', '--topological-dev']\n const jobsOptions = jobs ? ['-j', `${jobs}`] : []\n if (jobs) {\n console.log(chalk.blue(`Jobs set to [${jobs}]`))\n }\n\n const result = runSteps(`Compile${incremental ? '-Incremental' : ''} [All]`, [\n ['yarn', ['workspaces',\n 'foreach',\n ...incrementalOptions,\n ...jobsOptions,\n ...verboseOptions,\n 'run',\n 'package-compile',\n ...targetOptions,\n ]],\n ])\n console.log(`${chalk.gray('Compiled in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`)\n return result\n}\n","import type { CommandModule } from 'yargs'\n\nimport { compile } from '../../actions/index.ts'\n\nexport const compileOnlyCommand: CommandModule = {\n command: 'compile-only [package]',\n describe: 'Compile with Typescript & Copy Images (No Publint)',\n builder: (yargs) => {\n return yargs.positional('package', { describe: 'Specific package to compile' })\n },\n handler: (argv) => {\n if (argv.verbose) {\n console.log(`Compiling: ${argv.package ?? 'all'}`)\n }\n process.exitCode = compile({\n incremental: !!argv.incremental,\n jobs: argv.jobs as number,\n pkg: argv.package as string,\n publint: false,\n target: argv.target as 'esm' | 'cjs',\n verbose: !!argv.verbose,\n })\n },\n}\n"],"mappings":";AAAA,OAAO,WAAW;AAEX,IAAM,cAAc,CAAC,MAAc,QAAgB,QAA0B,SAAS,aAAa,UAAU;AAClH,MAAI,QAAQ;AACV,UAAM,UAAU,aAAa,sBAAsB;AACnD,UAAM,YAAY,UAAU,UAAU,MAAM,MAAM,MAAM;AACxD,YAAQ,KAAK,EAAE,UAAU,GAAG,IAAI,QAAQ,MAAM,aAAa,OAAO,EAAE,CAAC;AACrE,QAAI,YAAY;AACd,cAAQ,KAAK,MAAM;AAAA,IACrB;AAAA,EACF;AACF;;;ACXA,OAAOA,YAAW;;;ACAX,IAAM,YAAY,CAEvB,IACA,SACA,YAAY,CAACC,QAAW,CAAC,CAACA,IAAG,QAAQ,CAAC,CAACA,IAAG,YACvC;AACH,SAAO,UAAU,EAAO,IAAI,QAAQ,EAAO,IAAI;AACjD;;;ACLO,IAAM,qBAAqB,CAChC,IAAa,YACV;AACH,SAAO,UAAa,IAAI,SAAS,CAACC,QAAiBA,IAA6B,UAAU,MAAS;AACrG;;;AFDO,IAAM,YAAY,CAAC,OAAgB;AACxC,QAAM,Q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ACV,SAAS;AAAA,MACT,QAAQ,KAAK;AAAA,MACb,SAAS,CAAC,CAAC,KAAK;AAAA,IAClB,CAAC;AAAA,EACH;AACF;","names":["chalk","ex","ex","error","chalk","chalk","chalk","chalk","chalk"]}
@@ -0,0 +1,84 @@
1
+ // src/lib/yarn/workspace/yarnWorkspaces.ts
2
+ import { spawnSync } from "child_process";
3
+ var yarnWorkspaces = () => {
4
+ const result = spawnSync("yarn", ["workspaces", "list", "--json", "--recursive"], { encoding: "utf8", shell: true });
5
+ if (result.error) {
6
+ throw result.error;
7
+ }
8
+ return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
9
+ return JSON.parse(item);
10
+ });
11
+ };
12
+
13
+ // src/actions/copy-assets.ts
14
+ import path from "path/posix";
15
+ import chalk from "chalk";
16
+ import cpy from "cpy";
17
+ var copyPackageTargetAssets = async (target, name, location) => {
18
+ try {
19
+ const values = await cpy(
20
+ ["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
21
+ `../dist/${target}`,
22
+ {
23
+ cwd: path.join(process.cwd(), location, "src"),
24
+ flat: false
25
+ }
26
+ );
27
+ for (const value of values) {
28
+ console.log(`${value.split("/").pop()} => ./dist/${target}`);
29
+ }
30
+ return 0;
31
+ } catch (reason) {
32
+ console.log(`Copy Failed: ${name}: ${reason}`);
33
+ return 1;
34
+ }
35
+ };
36
+ var copyTargetAssets = async (target, pkg) => {
37
+ const workspaces = yarnWorkspaces();
38
+ console.log(chalk.green(`Copying Assets [${target.toUpperCase()}]`));
39
+ const workspaceList = workspaces.filter(({ name }) => {
40
+ return pkg === void 0 || name === pkg;
41
+ });
42
+ if (workspaceList.length === 0) {
43
+ console.error(`Package not found [${pkg}]`);
44
+ } else {
45
+ const results = await Promise.all(
46
+ workspaceList.map(async (workspace) => {
47
+ const { location, name } = workspace;
48
+ return await copyPackageTargetAssets(target, name, location);
49
+ })
50
+ );
51
+ return results.reduce((prev, result) => prev || result, 0);
52
+ }
53
+ return 0;
54
+ };
55
+ var copyAssets = async ({ target, pkg }) => {
56
+ switch (target) {
57
+ case "esm": {
58
+ return await copyTargetAssets("esm", pkg);
59
+ }
60
+ case "cjs": {
61
+ return await copyTargetAssets("cjs", pkg);
62
+ }
63
+ default: {
64
+ return await copyTargetAssets("esm", pkg) || await copyTargetAssets("cjs", pkg);
65
+ }
66
+ }
67
+ };
68
+
69
+ // src/xy/build/copyAssetsCommand.ts
70
+ var copyAssetsCommand = {
71
+ command: "copy-assets [package]",
72
+ describe: "Copy Assets - Copy the assets from src to dist",
73
+ builder: (yargs) => {
74
+ return yargs.positional("package", { describe: "Specific package to copy assets" });
75
+ },
76
+ handler: async (argv) => {
77
+ if (argv.verbose) console.log(`Copying Assets: ${argv.package ?? "all"}`);
78
+ process.exitCode = await copyAssets({ target: argv.target });
79
+ }
80
+ };
81
+ export {
82
+ copyAssetsCommand
83
+ };
84
+ //# sourceMappingURL=copyAssetsCommand.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../../src/actions/copy-assets.ts","../../../src/xy/build/copyAssetsCommand.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import path from 'node:path/posix'\n\nimport chalk from 'chalk'\nimport cpy from 'cpy'\n\nimport { yarnWorkspaces } from '../lib/index.ts'\n\nexport interface CopyAssetsParams {\n pkg?: string\n target?: 'esm' | 'cjs'\n}\n\nconst copyPackageTargetAssets = async (target: 'esm' | 'cjs', name: string, location: string) => {\n try {\n const values = await cpy(\n ['**/*.jpg', '**/*.png', '**/*.gif', '**/*.svg', '**/*.webp', '**/*.sass', '**/*.scss', '**/*.gif', '**/*.css'],\n `../dist/${target}`,\n {\n cwd: path.join(process.cwd(), location, 'src'),\n flat: false,\n },\n )\n for (const value of values) {\n console.log(`${value.split('/').pop()} => ./dist/${target}`)\n }\n return 0\n } catch (reason) {\n console.log(`Copy Failed: ${name}: ${reason}`)\n return 1\n }\n}\n\nconst copyTargetAssets = async (target: 'esm' | 'cjs', pkg?: string) => {\n const workspaces = yarnWorkspaces()\n\n console.log(chalk.green(`Copying Assets [${target.toUpperCase()}]`))\n\n // finds the package or returns all if undefined\n const workspaceList = workspaces.filter(({ name }) => {\n return pkg === undefined || name === pkg\n })\n\n if (workspaceList.length === 0) {\n console.error(`Package not found [${pkg}]`)\n } else {\n const results = await Promise.all(\n workspaceList.map(async (workspace) => {\n const { location, name } = workspace\n return await copyPackageTargetAssets(target, name, location)\n }),\n )\n // eslint-disable-next-line unicorn/no-array-reduce\n return results.reduce((prev, result) => prev || result, 0)\n }\n return 0\n}\n\nexport const copyAssets = async ({ target, pkg }: CopyAssetsParams) => {\n switch (target) {\n case 'esm': {\n return await copyTargetAssets('esm', pkg)\n }\n case 'cjs': {\n return await copyTargetAssets('cjs', pkg)\n }\n default: {\n return (await copyTargetAssets('esm', pkg)) || (await copyTargetAssets('cjs', pkg))\n }\n }\n}\n","import type { CommandModule } from 'yargs'\n\nimport { copyAssets } from '../../actions/index.ts'\n\nexport const copyAssetsCommand: CommandModule = {\n command: 'copy-assets [package]',\n describe: 'Copy Assets - Copy the assets from src to dist',\n builder: (yargs) => {\n return yargs.positional('package', { describe: 'Specific package to copy assets' })\n },\n handler: async (argv) => {\n if (argv.verbose) console.log(`Copying Assets: ${argv.package ?? 'all'}`)\n process.exitCode = await copyAssets({ target: argv.target as 'esm' | 'cjs' })\n },\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAInB,IAAM,iBA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AACL,UAAM,UAAU,MAAM,QAAQ;AAAA,MAC5B,cAAc,IAAI,OAAO,cAAc;AACrC,cAAM,EAAE,UAAU,KAAK,IAAI;AAC3B,eAAO,MAAM,wBAAwB,QAAQ,MAAM,QAAQ;AAAA,MAC7D,CAAC;AAAA,IACH;AAEA,WAAO,QAAQ,OAAO,CAAC,MAAM,WAAW,QAAQ,QAAQ,CAAC;AAAA,EAC3D;AACA,SAAO;AACT;AAEO,IAAM,aAAa,OAAO,EAAE,QAAQ,IAAI,MAAwB;AACrE,UAAQ,QAAQ;AAAA,IACd,KAAK,OAAO;AACV,aAAO,MAAM,iBAAiB,OAAO,GAAG;AAAA,IAC1C;AAAA,IACA,KAAK,OAAO;AACV,aAAO,MAAM,iBAAiB,OAAO,GAAG;AAAA,IAC1C;AAAA,IACA,SAAS;AACP,aAAQ,MAAM,iBAAiB,OAAO,GAAG,KAAO,MAAM,iBAAiB,OAAO,GAAG;AAAA,IACnF;AAAA,EACF;AACF;;;ACjEO,IAAM,oBAAmC;AAAA,EAC9C,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS,CAAC,UAAU;AAClB,WAAO,MAAM,WAAW,WAAW,EAAE,UAAU,kCAAkC,CAAC;AAAA,EACpF;AAAA,EACA,SAAS,OAAO,SAAS;AACvB,QAAI,KAAK,QAAS,SAAQ,IAAI,mBAAmB,KAAK,WAAW,KAAK,EAAE;AACxE,YAAQ,WAAW,MAAM,WAAW,EAAE,QAAQ,KAAK,OAAwB,CAAC;AAAA,EAC9E;AACF;","names":[]}
@@ -386,18 +386,13 @@ var recompileAll = async ({
386
386
  return result;
387
387
  };
388
388
 
389
- // src/xy/param.ts
390
- var packagePositionalParam = (yargs) => {
391
- return yargs.positional("package", { describe: "Specific package to target", type: "string" });
392
- };
393
-
394
- // src/xy/build-commands/build.ts
389
+ // src/xy/build/buildCommand.ts
395
390
  var buildCommand = {
396
- builder: (yargs) => {
397
- return packagePositionalParam(yargs);
398
- },
399
391
  command: "build [package]",
400
392
  describe: "Build - Compile & Lint",
393
+ builder: (yargs) => {
394
+ return yargs.positional("package", { describe: "Specific package to build" });
395
+ },
401
396
  handler: async (argv) => {
402
397
  if (argv.verbose) {
403
398
  console.log(`Building: ${argv.package ?? "all"}`);
@@ -411,12 +406,14 @@ var buildCommand = {
411
406
  });
412
407
  }
413
408
  };
409
+
410
+ // src/xy/build/compileCommand.ts
414
411
  var compileCommand = {
415
- builder: (yargs) => {
416
- return packagePositionalParam(yargs);
417
- },
418
412
  command: "compile [package]",
419
413
  describe: "Compile with Typescript & Copy Images",
414
+ builder: (yargs) => {
415
+ return yargs.positional("package", { describe: "Specific package to compile" });
416
+ },
420
417
  handler: (argv) => {
421
418
  if (argv.verbose) {
422
419
  console.log(`Compiling: ${argv.package ?? "all"}`);
@@ -430,12 +427,14 @@ var compileCommand = {
430
427
  });
431
428
  }
432
429
  };
430
+
431
+ // src/xy/build/compileOnlyCommand.ts
433
432
  var compileOnlyCommand = {
434
- builder: (yargs) => {
435
- return packagePositionalParam(yargs);
436
- },
437
433
  command: "compile-only [package]",
438
434
  describe: "Compile with Typescript & Copy Images (No Publint)",
435
+ builder: (yargs) => {
436
+ return yargs.positional("package", { describe: "Specific package to compile" });
437
+ },
439
438
  handler: (argv) => {
440
439
  if (argv.verbose) {
441
440
  console.log(`Compiling: ${argv.package ?? "all"}`);
@@ -450,51 +449,57 @@ var compileOnlyCommand = {
450
449
  });
451
450
  }
452
451
  };
453
- var recompileCommand = {
452
+
453
+ // src/xy/build/copyAssetsCommand.ts
454
+ var copyAssetsCommand = {
455
+ command: "copy-assets [package]",
456
+ describe: "Copy Assets - Copy the assets from src to dist",
454
457
  builder: (yargs) => {
455
- return packagePositionalParam(yargs);
458
+ return yargs.positional("package", { describe: "Specific package to copy assets" });
456
459
  },
457
- command: "recompile [package]",
458
- describe: "Re-compile with Typescript & Copy Images",
459
460
  handler: async (argv) => {
460
- if (argv.verbose) {
461
- console.log(`Re-compiling: ${argv.package ?? "all"}`);
462
- }
463
- process.exitCode = await recompile({
464
- incremental: !!argv.incremental,
465
- jobs: argv.jobs,
466
- pkg: argv.package,
467
- target: argv.target,
468
- verbose: !!argv.verbose
469
- });
461
+ if (argv.verbose) console.log(`Copying Assets: ${argv.package ?? "all"}`);
462
+ process.exitCode = await copyAssets({ target: argv.target });
470
463
  }
471
464
  };
465
+
466
+ // src/xy/build/rebuildCommand.ts
472
467
  var rebuildCommand = {
473
- builder: (yargs) => {
474
- return packagePositionalParam(yargs);
475
- },
476
468
  command: "rebuild [package]",
477
469
  describe: "Rebuild - Clean, Compile & Lint",
470
+ builder: (yargs) => {
471
+ return yargs.positional("package", { describe: "Specific package to rebuild" });
472
+ },
478
473
  handler: (argv) => {
479
474
  if (argv.verbose) console.log(`Rebuilding: ${argv.package ?? "all"}`);
480
475
  process.exitCode = rebuild({ target: argv.target });
481
476
  }
482
477
  };
483
- var copyAssetsCommand = {
478
+
479
+ // src/xy/build/recompileCommand.ts
480
+ var recompileCommand = {
481
+ command: "recompile [package]",
482
+ describe: "Re-compile with Typescript & Copy Images",
484
483
  builder: (yargs) => {
485
- return packagePositionalParam(yargs);
484
+ return yargs.positional("package", { describe: "Specific package to re-compile" });
486
485
  },
487
- command: "copy-assets [package]",
488
- describe: "Copy Assets - Copy the assets from src to dist",
489
486
  handler: async (argv) => {
490
- if (argv.verbose) console.log(`Copying Assets: ${argv.package ?? "all"}`);
491
- process.exitCode = await copyAssets({ target: argv.target });
487
+ if (argv.verbose) {
488
+ console.log(`Re-compiling: ${argv.package ?? "all"}`);
489
+ }
490
+ process.exitCode = await recompile({
491
+ incremental: !!argv.incremental,
492
+ jobs: argv.jobs,
493
+ pkg: argv.package,
494
+ target: argv.target,
495
+ verbose: !!argv.verbose
496
+ });
492
497
  }
493
498
  };
494
499
 
495
- // src/xy/build-commands/index.ts
500
+ // src/xy/build/index.ts
496
501
  var xyBuildCommands = (args) => {
497
- return args.command(buildCommand).command(compileCommand).command(compileOnlyCommand).command(rebuildCommand).command(recompileCommand).command(copyAssetsCommand);
502
+ return args.command(buildCommand).command(compileCommand).command(compileOnlyCommand).command(recompileCommand).command(rebuildCommand).command(copyAssetsCommand);
498
503
  };
499
504
  export {
500
505
  xyBuildCommands