@xylabs/ts-scripts-yarn3 7.1.7 → 7.1.8

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 (38) hide show
  1. package/dist/actions/deplint/checkPackage/checkPackage.mjs +12 -1
  2. package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
  3. package/dist/actions/deplint/checkPackage/index.mjs +12 -1
  4. package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
  5. package/dist/actions/deplint/deplint.mjs +12 -1
  6. package/dist/actions/deplint/deplint.mjs.map +1 -1
  7. package/dist/actions/deplint/getExternalImportsFromFiles.mjs +12 -1
  8. package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -1
  9. package/dist/actions/deplint/getImportsFromFile.mjs +14 -2
  10. package/dist/actions/deplint/getImportsFromFile.mjs.map +1 -1
  11. package/dist/actions/deplint/index.mjs +12 -1
  12. package/dist/actions/deplint/index.mjs.map +1 -1
  13. package/dist/actions/gitignore-gen.mjs +1 -1
  14. package/dist/actions/gitignore-gen.mjs.map +1 -1
  15. package/dist/actions/index.mjs +39 -23
  16. package/dist/actions/index.mjs.map +1 -1
  17. package/dist/actions/npmignore-gen.mjs +1 -1
  18. package/dist/actions/npmignore-gen.mjs.map +1 -1
  19. package/dist/actions/relint.mjs +26 -21
  20. package/dist/actions/relint.mjs.map +1 -1
  21. package/dist/bin/xy.mjs +39 -23
  22. package/dist/bin/xy.mjs.map +1 -1
  23. package/dist/index.d.ts +5 -3
  24. package/dist/index.mjs +39 -23
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/lib/generateIgnoreFiles.mjs +1 -1
  27. package/dist/lib/generateIgnoreFiles.mjs.map +1 -1
  28. package/dist/lib/index.mjs +1 -1
  29. package/dist/lib/index.mjs.map +1 -1
  30. package/dist/xy/index.mjs +39 -23
  31. package/dist/xy/index.mjs.map +1 -1
  32. package/dist/xy/xy.mjs +39 -23
  33. package/dist/xy/xy.mjs.map +1 -1
  34. package/dist/xy/xyCommonCommands.mjs +1 -1
  35. package/dist/xy/xyCommonCommands.mjs.map +1 -1
  36. package/dist/xy/xyLintCommands.mjs +38 -22
  37. package/dist/xy/xyLintCommands.mjs.map +1 -1
  38. package/package.json +13 -13
@@ -58,7 +58,7 @@ var INIT_CWD = () => {
58
58
 
59
59
  // src/lib/generateIgnoreFiles.ts
60
60
  var localeCompare = (a, b) => a.localeCompare(b);
61
- var mergeEntries = (a, b) => [...union(a, b)].sort(localeCompare);
61
+ var mergeEntries = (a, b) => [...union(a, b)].toSorted(localeCompare);
62
62
  var generateIgnoreFiles = (filename2, pkg) => {
63
63
  console.log(chalk.green(`Generate ${filename2} Files`));
64
64
  const cwd = INIT_CWD() ?? ".";
@@ -1 +1 @@
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/npmignore-gen.ts"],"sourcesContent":["export const WINDOWS_NEWLINE_REGEX = /\\r\\n/g\nexport const CROSS_PLATFORM_NEWLINE = '\\n'\n","import type { PathLike, WriteFileOptions } from 'node:fs'\nimport {\n existsSync, readFileSync,\n writeFileSync,\n} from 'node:fs'\n\nimport { notEmpty } from '../string/index.ts'\nimport { CROSS_PLATFORM_NEWLINE, WINDOWS_NEWLINE_REGEX } from './constants.ts'\nimport type { ReadFileSyncOptions } from './ReadFileSyncOptions.ts'\nimport { defaultReadFileSyncOptions } 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 type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { Workspace } from './Workspace.ts'\nimport { yarnWorkspaces } from './yarnWorkspaces.ts'\n\nexport const yarnWorkspace = (pkg: string): Workspace => {\n const workspace = yarnWorkspaces().find(({ name }) => name === pkg)\n if (!workspace) throw new Error(`Workspace ${pkg} not found`)\n return workspace\n}\n","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 = '.npmignore'\n\nexport const npmignoreGen = (pkg?: string) => generateIgnoreFiles(filename, pkg)\n"],"mappings":";AAAO,IAAM,wBAAwB;AAC9B,IAAM,yBAAyB;;;ACAtC;AAAA,EACE;AAAA,EAAY;AAAA,EACZ;AAAA,OACK;;;ACJA,IAAM,QAAQ,CAAC,UAAwC,OAAO,KAAK,EAAE,WAAW;AAChF,IAAM,WAAW,CAAC,UAAwC,CAAC,MAAM,KAAK;;;ACDtE,IAAM,QAAQ,CAAC,GAAa,MAA6B,oBAAI,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC;;;ACK/F,IAAM,6BAAkD,EAAE,UAAU,OAAO;;;AHM3E,IAAM,YAAY,CAAC,KAAe,UAA+B,+BACtE,WAAW,GAAG,IACV,aAAa,KAAK,OAAO,EAAE,QAAQ,uBAAuB,sBAAsB,EAAE,MAAM,sBAAsB,IAC9G,CAAC;AAEA,IAAM,oBAAoB,CAAC,KAAe,UAA+B,+BAC9E,UAAU,KAAK,OAAO,EA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AG,CAAC,IAAI,eAAe;AAC/D,QAAM,cAAc,CAAC,aAA+B,kBAAkB,GAAG,QAAQ,IAAIA,SAAQ,EAAE;AAC/F,QAAM,eAAe,CAAC,UAAkB,YAAsB,WAAW,GAAG,QAAQ,IAAIA,SAAQ,IAAI,OAAO;AAC3G,QAAM,UAAU,WAAW,IAAI,CAAC,EAAE,UAAU,KAAK,MAAM;AACrD,QAAI;AACF,mBAAa,UAAU,aAAa,YAAY,GAAG,GAAG,YAAY,QAAQ,CAAC,CAAC;AAC5E,aAAO;AAAA,IACT,SAAS,IAAI;AACX,YAAM,QAAQ;AACd,cAAQ,MAAM,YAAYA,SAAQ,WAAW,IAAI,MAAM,MAAM,OAAO,GAAG;AACvE,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACD,QAAM,YAAY,QAAQ,MAAM,YAAU,WAAW,CAAC;AACtD,SAAO,YAAY,IAAI;AACzB;;;AI5BA,IAAM,WAAW;AAEV,IAAM,eAAe,CAAC,QAAiB,oBAAoB,UAAU,GAAG;","names":["filename"]}
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/npmignore-gen.ts"],"sourcesContent":["export const WINDOWS_NEWLINE_REGEX = /\\r\\n/g\nexport const CROSS_PLATFORM_NEWLINE = '\\n'\n","import type { PathLike, WriteFileOptions } from 'node:fs'\nimport {\n existsSync, readFileSync,\n writeFileSync,\n} from 'node:fs'\n\nimport { notEmpty } from '../string/index.ts'\nimport { CROSS_PLATFORM_NEWLINE, WINDOWS_NEWLINE_REGEX } from './constants.ts'\nimport type { ReadFileSyncOptions } from './ReadFileSyncOptions.ts'\nimport { defaultReadFileSyncOptions } 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)].toSorted(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 type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { Workspace } from './Workspace.ts'\nimport { yarnWorkspaces } from './yarnWorkspaces.ts'\n\nexport const yarnWorkspace = (pkg: string): Workspace => {\n const workspace = yarnWorkspaces().find(({ name }) => name === pkg)\n if (!workspace) throw new Error(`Workspace ${pkg} not found`)\n return workspace\n}\n","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 = '.npmignore'\n\nexport const npmignoreGen = (pkg?: string) => generateIgnoreFiles(filename, pkg)\n"],"mappings":";AAAO,IAAM,wBAAwB;AAC9B,IAAM,yBAAyB;;;ACAtC;AAAA,EACE;AAAA,EAAY;AAAA,EACZ;AAAA,OACK;;;ACJA,IAAM,QAAQ,CAAC,UAAwC,OAAO,KAAK,EAAE,WAAW;AAChF,IAAM,WAAW,CAAC,UAAwC,CAAC,MAAM,KAAK;;;ACDtE,IAAM,QAAQ,CAAC,GAAa,MAA6B,oBAAI,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC;;;ACK/F,IAAM,6BAAkD,EAAE,UAAU,OAAO;;;AHM3E,IAAM,YAAY,CAAC,KAAe,UAA+B,+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a;AAE7F,IAAM,sBAAsB,CAACA,WAAkB,QAAiB;AACrE,UAAQ,IAAI,MAAM,MAAM,YAAYA,SAAQ,QAAQ,CAAC;AACrD,QAAM,MAAM,SAAS,KAAK;AAC1B,QAAM,aAAa,MAAM,CAAC,cAAc,GAAG,CAAC,IAAI,eAAe;AAC/D,QAAM,cAAc,CAAC,aAA+B,kBAAkB,GAAG,QAAQ,IAAIA,SAAQ,EAAE;AAC/F,QAAM,eAAe,CAAC,UAAkB,YAAsB,WAAW,GAAG,QAAQ,IAAIA,SAAQ,IAAI,OAAO;AAC3G,QAAM,UAAU,WAAW,IAAI,CAAC,EAAE,UAAU,KAAK,MAAM;AACrD,QAAI;AACF,mBAAa,UAAU,aAAa,YAAY,GAAG,GAAG,YAAY,QAAQ,CAAC,CAAC;AAC5E,aAAO;AAAA,IACT,SAAS,IAAI;AACX,YAAM,QAAQ;AACd,cAAQ,MAAM,YAAYA,SAAQ,WAAW,IAAI,MAAM,MAAM,OAAO,GAAG;AACvE,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACD,QAAM,YAAY,QAAQ,MAAM,YAAU,WAAW,CAAC;AACtD,SAAO,YAAY,IAAI;AACzB;;;AI5BA,IAAM,WAAW;AAEV,IAAM,eAAe,CAAC,QAAiB,oBAAoB,UAAU,GAAG;","names":["filename"]}
@@ -92,43 +92,48 @@ var runSteps = (name, steps, exitOnFail = true, messages) => {
92
92
  };
93
93
 
94
94
  // src/actions/relint.ts
95
- var relintPackage = ({ pkg }) => {
96
- console.log(chalk4.gray(`${"Relint"} [All-Packages]`));
95
+ var relintPackage = ({
96
+ pkg,
97
+ fix,
98
+ verbose
99
+ }) => {
100
+ console.log(chalk4.gray(`${fix ? "Fix" : "Lint"} [${pkg}]`));
97
101
  const start = Date.now();
98
- const result = runSteps("Relint [All-Packages]", [
102
+ const result = runSteps(`${fix ? "Fix" : "Lint"} [${pkg}]`, [
99
103
  ["yarn", [
100
104
  "workspace",
101
105
  pkg,
102
106
  "run",
103
- "package-relint"
107
+ fix ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
104
108
  ]]
105
109
  ]);
106
- console.log(chalk4.gray(`${"Relinted in"} [${chalk4.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk4.gray("seconds")}`));
110
+ console.log(chalk4.gray(`${fix ? "Fixed in" : "Linted in"} [${chalk4.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk4.gray("seconds")}`));
107
111
  return result;
108
112
  };
109
113
  var relint = ({
110
114
  pkg,
111
115
  verbose,
112
- incremental
116
+ incremental,
117
+ fix
113
118
  } = {}) => {
114
- return pkg ? relintPackage({ pkg }) : relintAllPackages({ verbose, incremental });
119
+ return pkg === void 0 ? relintAllPackages({
120
+ verbose,
121
+ incremental,
122
+ fix
123
+ }) : relintPackage({
124
+ pkg,
125
+ fix,
126
+ verbose
127
+ });
115
128
  };
116
- var relintAllPackages = ({ verbose = false, incremental } = {}) => {
117
- console.log(chalk4.gray(`${"Relint"} [All-Packages]`));
129
+ var relintAllPackages = ({ fix = false } = {}) => {
130
+ console.log(chalk4.gray(`${fix ? "Fix" : "Lint"} [All-Packages]`));
118
131
  const start = Date.now();
119
- const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
120
- const incrementalOptions = incremental ? ["--since", "-Ap"] : ["--parallel", "-Ap"];
121
- const result = runSteps(`${"Relint"} [All-Packages]`, [
122
- ["yarn", [
123
- "workspaces",
124
- "foreach",
125
- ...verboseOptions,
126
- ...incrementalOptions,
127
- "run",
128
- "package-relint"
129
- ]]
132
+ const fixOptions = fix ? ["--fix"] : [];
133
+ const result = runSteps(`${fix ? "Fix" : "Lint"} [All-Packages]`, [
134
+ ["yarn", ["eslint", ...fixOptions]]
130
135
  ]);
131
- console.log(chalk4.gray(`Relinted in [${chalk4.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk4.gray("seconds")}`));
136
+ console.log(chalk4.gray(`${fix ? "Fixed in" : "Linted in"} [${chalk4.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk4.gray("seconds")}`));
132
137
  return result;
133
138
  };
134
139
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/actions/relint.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 RelintParams {\n incremental?: boolean\n pkg?: string\n verbose?: boolean\n}\n\nexport interface RelintPackageParams {\n pkg: string\n verbose?: boolean\n}\n\nexport const relintPackage = ({ pkg }: RelintParams & Required<Pick<RelintParams, 'pkg'>>) => {\n console.log(chalk.gray(`${'Relint'} [All-Packages]`))\n const start = Date.now()\n\n const result = runSteps('Relint [All-Packages]', [\n ['yarn', ['workspace',\n pkg,\n 'run',\n 'package-relint',\n ]],\n ])\n console.log(chalk.gray(`${'Relinted in'} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`))\n return result\n}\n\nexport const relint = ({\n pkg, verbose, incremental,\n}: RelintParams = {}) => {\n return pkg\n ? relintPackage({ pkg })\n : relintAllPackages({ verbose, incremental })\n}\n\nexport const relintAllPackages = ({ verbose = false, incremental }: RelintParams = {}) => {\n console.log(chalk.gray(`${'Relint'} [All-Packages]`))\n const start = Date.now()\n const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n const incrementalOptions = incremental ? ['--since', '-Ap'] : ['--parallel', '-Ap']\n\n const result = runSteps(`${'Relint'} [All-Packages]`, [\n ['yarn', ['workspaces',\n 'foreach',\n ...verboseOptions,\n ...incrementalOptions,\n 'run',\n 'package-relint',\n ]],\n ])\n console.log(chalk.gray(`Relinted 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,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,OAAOC,YAAW;;;AC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AAIA,OAAM,KAAK,GAAG,aAAa,KAAKA,OAAM,UAAU,KAAK,IAAI,IAAI,SAAS,KAAM,QAAQ,CAAC,CAAC,CAAC,KAAKA,OAAM,KAAK,SAAS,CAAC,EAAE,CAAC;AAChI,SAAO;AACT;AAEO,IAAM,SAAS,CAAC;AAAA,EACrB;AAAA,EAAK;AAAA,EAAS;AAChB,IAAkB,CAAC,MAAM;AACvB,SAAO,MACH,cAAc,EAAE,IAAI,CAAC,IACrB,kBAAkB,EAAE,SAAS,YAAY,CAAC;AAChD;AAEO,IAAM,oBAAoB,CAAC,EAAE,UAAU,OAAO,YAAY,IAAkB,CAAC,MAAM;AACxF,UAAQ,IAAIA,OAAM,KAAK,GAAG,QAAQ,iBAAiB,CAAC;AACpD,QAAM,QAAQ,KAAK,IAAI;AACvB,QAAM,iBAAiB,UAAU,CAAC,WAAW,IAAI,CAAC,cAAc;AAChE,QAAM,qBAAqB,cAAc,CAAC,WAAW,KAAK,IAAI,CAAC,cAAc,KAAK;AAElF,QAAM,SAAS,SAAS,GAAG,QAAQ,oBAAoB;AAAA,IACrD,CAAC,QAAQ;AAAA,MAAC;AAAA,MACR;AAAA,MACA,GAAG;AAAA,MACH,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACD,UAAQ,IAAIA,OAAM,KAAK,gBAAgBA,OAAM,UAAU,KAAK,IAAI,IAAI,SAAS,KAAM,QAAQ,CAAC,CAAC,CAAC,KAAKA,OAAM,KAAK,SAAS,CAAC,EAAE,CAAC;AAC3H,SAAO;AACT;","names":["chalk","chalk","ex","ex","error","chalk","chalk","chalk","chalk"]}
1
+ {"version":3,"sources":["../../src/actions/relint.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 RelintParams {\n cache?: boolean\n fix?: boolean\n incremental?: boolean\n pkg?: string\n verbose?: boolean\n}\n\nexport interface RelintPackageParams {\n pkg: string\n verbose?: boolean\n}\n\nexport const relintPackage = ({\n pkg, fix, verbose,\n}: RelintParams & Required<Pick<RelintParams, 'pkg'>>) => {\n console.log(chalk.gray(`${fix ? 'Fix' : 'Lint'} [${pkg}]`))\n const start = Date.now()\n\n const result = runSteps(`${fix ? 'Fix' : 'Lint'} [${pkg}]`, [\n ['yarn', ['workspace',\n pkg,\n 'run',\n fix ? 'package-fix' : verbose ? 'package-lint-verbose' : 'package-lint',\n ]],\n ])\n console.log(chalk.gray(`${fix ? 'Fixed in' : 'Linted in'} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`))\n return result\n}\n\nexport const relint = ({\n pkg, verbose, incremental, fix,\n}: RelintParams = {}) => {\n return pkg === undefined\n ? relintAllPackages({\n verbose, incremental, fix,\n })\n : relintPackage({\n pkg, fix, verbose,\n })\n}\n\nexport const relintAllPackages = ({ fix = false }: RelintParams = {}) => {\n console.log(chalk.gray(`${fix ? 'Fix' : 'Lint'} [All-Packages]`))\n const start = Date.now()\n // const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n // const incrementalOptions = incremental ? ['--since', '-Ap'] : ['--parallel', '-Ap']\n const fixOptions = fix ? ['--fix'] : []\n\n const result = runSteps(`${fix ? 'Fix' : 'Lint'} [All-Packages]`, [\n ['yarn', ['eslint', ...fixOptions]],\n ])\n console.log(chalk.gray(`${fix ? 'Fixed in' : 'Linted 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,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,OAAOC,YAAW;;;ACAX,IAAM,YAAY,CAEvB,IACA,SACA,YAAY,CAACC,QAAW,CAAC,CAACA,IAAG,QAAQ,CAAC,CAACA,IAAG,YACvC;AACH,SAAO,UAAU,EAAO,IAAI,QAAQ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AK,GAAG,MAAM,aAAa,WAAW,KAAKA,OAAM,UAAU,KAAK,IAAI,IAAI,SAAS,KAAM,QAAQ,CAAC,CAAC,CAAC,KAAKA,OAAM,KAAK,SAAS,CAAC,EAAE,CAAC;AACjJ,SAAO;AACT;AAEO,IAAM,SAAS,CAAC;AAAA,EACrB;AAAA,EAAK;AAAA,EAAS;AAAA,EAAa;AAC7B,IAAkB,CAAC,MAAM;AACvB,SAAO,QAAQ,SACX,kBAAkB;AAAA,IAChB;AAAA,IAAS;AAAA,IAAa;AAAA,EACxB,CAAC,IACD,cAAc;AAAA,IACZ;AAAA,IAAK;AAAA,IAAK;AAAA,EACZ,CAAC;AACP;AAEO,IAAM,oBAAoB,CAAC,EAAE,MAAM,MAAM,IAAkB,CAAC,MAAM;AACvE,UAAQ,IAAIA,OAAM,KAAK,GAAG,MAAM,QAAQ,MAAM,iBAAiB,CAAC;AAChE,QAAM,QAAQ,KAAK,IAAI;AAGvB,QAAM,aAAa,MAAM,CAAC,OAAO,IAAI,CAAC;AAEtC,QAAM,SAAS,SAAS,GAAG,MAAM,QAAQ,MAAM,oBAAoB;AAAA,IACjE,CAAC,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC;AAAA,EACpC,CAAC;AACD,UAAQ,IAAIA,OAAM,KAAK,GAAG,MAAM,aAAa,WAAW,KAAKA,OAAM,UAAU,KAAK,IAAI,IAAI,SAAS,KAAM,QAAQ,CAAC,CAAC,CAAC,KAAKA,OAAM,KAAK,SAAS,CAAC,EAAE,CAAC;AACjJ,SAAO;AACT;","names":["chalk","chalk","ex","ex","error","chalk","chalk","chalk","chalk"]}
package/dist/bin/xy.mjs CHANGED
@@ -276,7 +276,7 @@ var INIT_CWD = () => {
276
276
 
277
277
  // src/lib/generateIgnoreFiles.ts
278
278
  var localeCompare = (a, b) => a.localeCompare(b);
279
- var mergeEntries = (a, b) => [...union(a, b)].sort(localeCompare);
279
+ var mergeEntries = (a, b) => [...union(a, b)].toSorted(localeCompare);
280
280
  var generateIgnoreFiles = (filename3, pkg) => {
281
281
  console.log(chalk4.green(`Generate ${filename3} Files`));
282
282
  const cwd = INIT_CWD() ?? ".";
@@ -652,6 +652,17 @@ function getBasePackageName(importName) {
652
652
  }
653
653
 
654
654
  // src/actions/deplint/getImportsFromFile.ts
655
+ function isTypeOnlyImportClause(clause) {
656
+ if (clause === void 0) {
657
+ return false;
658
+ }
659
+ if ("phaseModifier" in clause) {
660
+ const mod = clause.phaseModifier;
661
+ const kind = typeof mod === "number" ? mod : mod?.kind;
662
+ return kind === ts.SyntaxKind.TypeKeyword;
663
+ }
664
+ return clause.isTypeOnly;
665
+ }
655
666
  function getImportsFromFile(filePath, importPaths, typeImportPaths) {
656
667
  const sourceCode = fs3.readFileSync(filePath, "utf8");
657
668
  const isMjsFile = filePath.endsWith(".mjs");
@@ -668,7 +679,7 @@ function getImportsFromFile(filePath, importPaths, typeImportPaths) {
668
679
  function visit(node) {
669
680
  if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
670
681
  const moduleSpecifier = node.moduleSpecifier?.getFullText();
671
- const isTypeImport = ts.isImportDeclaration(node) ? node.importClause?.isTypeOnly ?? false : false;
682
+ const isTypeImport = ts.isImportDeclaration(node) ? isTypeOnlyImportClause(node.importClause) : false;
672
683
  if (typeof moduleSpecifier === "string") {
673
684
  const trimmed = moduleSpecifier.replaceAll("'", "").replaceAll('"', "").trim();
674
685
  if (isTypeImport || isDeclarationFile) {
@@ -1357,43 +1368,48 @@ var reinstall = () => {
1357
1368
 
1358
1369
  // src/actions/relint.ts
1359
1370
  import chalk22 from "chalk";
1360
- var relintPackage = ({ pkg }) => {
1361
- console.log(chalk22.gray(`${"Relint"} [All-Packages]`));
1371
+ var relintPackage = ({
1372
+ pkg,
1373
+ fix: fix2,
1374
+ verbose
1375
+ }) => {
1376
+ console.log(chalk22.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
1362
1377
  const start = Date.now();
1363
- const result = runSteps("Relint [All-Packages]", [
1378
+ const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
1364
1379
  ["yarn", [
1365
1380
  "workspace",
1366
1381
  pkg,
1367
1382
  "run",
1368
- "package-relint"
1383
+ fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
1369
1384
  ]]
1370
1385
  ]);
1371
- console.log(chalk22.gray(`${"Relinted in"} [${chalk22.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk22.gray("seconds")}`));
1386
+ console.log(chalk22.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk22.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk22.gray("seconds")}`));
1372
1387
  return result;
1373
1388
  };
1374
1389
  var relint = ({
1375
1390
  pkg,
1376
1391
  verbose,
1377
- incremental
1392
+ incremental,
1393
+ fix: fix2
1378
1394
  } = {}) => {
1379
- return pkg ? relintPackage({ pkg }) : relintAllPackages({ verbose, incremental });
1395
+ return pkg === void 0 ? relintAllPackages({
1396
+ verbose,
1397
+ incremental,
1398
+ fix: fix2
1399
+ }) : relintPackage({
1400
+ pkg,
1401
+ fix: fix2,
1402
+ verbose
1403
+ });
1380
1404
  };
1381
- var relintAllPackages = ({ verbose = false, incremental } = {}) => {
1382
- console.log(chalk22.gray(`${"Relint"} [All-Packages]`));
1405
+ var relintAllPackages = ({ fix: fix2 = false } = {}) => {
1406
+ console.log(chalk22.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
1383
1407
  const start = Date.now();
1384
- const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
1385
- const incrementalOptions = incremental ? ["--since", "-Ap"] : ["--parallel", "-Ap"];
1386
- const result = runSteps(`${"Relint"} [All-Packages]`, [
1387
- ["yarn", [
1388
- "workspaces",
1389
- "foreach",
1390
- ...verboseOptions,
1391
- ...incrementalOptions,
1392
- "run",
1393
- "package-relint"
1394
- ]]
1408
+ const fixOptions = fix2 ? ["--fix"] : [];
1409
+ const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
1410
+ ["yarn", ["eslint", ...fixOptions]]
1395
1411
  ]);
1396
- console.log(chalk22.gray(`Relinted in [${chalk22.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk22.gray("seconds")}`));
1412
+ console.log(chalk22.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk22.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk22.gray("seconds")}`));
1397
1413
  return result;
1398
1414
  };
1399
1415