@xylabs/ts-scripts-yarn3 4.0.0-rc.9 → 4.0.1

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 (198) hide show
  1. package/dist/actions/build.mjs.map +1 -1
  2. package/dist/actions/clean-docs.mjs +14 -4
  3. package/dist/actions/clean-docs.mjs.map +1 -1
  4. package/dist/actions/clean-eslint.mjs +16 -4
  5. package/dist/actions/clean-eslint.mjs.map +1 -1
  6. package/dist/actions/clean-jest.mjs.map +1 -1
  7. package/dist/actions/clean.mjs.map +1 -1
  8. package/dist/actions/compile.mjs +3 -2
  9. package/dist/actions/compile.mjs.map +1 -1
  10. package/dist/actions/copy-assets.mjs.map +1 -1
  11. package/dist/actions/cycle.mjs +25 -110
  12. package/dist/actions/cycle.mjs.map +1 -1
  13. package/dist/actions/dead.mjs.map +1 -1
  14. package/dist/actions/deploy-major.mjs.map +1 -1
  15. package/dist/actions/deploy-minor.mjs.map +1 -1
  16. package/dist/actions/deploy-next.mjs.map +1 -1
  17. package/dist/actions/deploy.mjs.map +1 -1
  18. package/dist/actions/deps.mjs.map +1 -1
  19. package/dist/actions/dupdeps.mjs +3 -2
  20. package/dist/actions/dupdeps.mjs.map +1 -1
  21. package/dist/actions/fix.mjs.map +1 -1
  22. package/dist/actions/gen-docs.mjs.map +1 -1
  23. package/dist/actions/gitignore-gen.mjs.map +1 -1
  24. package/dist/actions/index.mjs +300 -77
  25. package/dist/actions/index.mjs.map +1 -1
  26. package/dist/actions/license.mjs.map +1 -1
  27. package/dist/actions/lint-clean.mjs.map +1 -1
  28. package/dist/actions/lint-profile.mjs.map +1 -1
  29. package/dist/actions/lint.mjs.map +1 -1
  30. package/dist/actions/npmignore-gen.mjs.map +1 -1
  31. package/dist/actions/package/clean-outputs.mjs +16 -2
  32. package/dist/actions/package/clean-outputs.mjs.map +1 -1
  33. package/dist/actions/package/clean-typescript.mjs +16 -2
  34. package/dist/actions/package/clean-typescript.mjs.map +1 -1
  35. package/dist/actions/package/clean.mjs +17 -4
  36. package/dist/actions/package/clean.mjs.map +1 -1
  37. package/dist/actions/package/compile/buildEntries.mjs.map +1 -1
  38. package/dist/actions/package/compile/compile.mjs +221 -16
  39. package/dist/actions/package/compile/compile.mjs.map +1 -1
  40. package/dist/actions/package/compile/copyTypeFiles.mjs.map +1 -1
  41. package/dist/actions/package/compile/getCompilerOptions.mjs +145 -8
  42. package/dist/actions/package/compile/getCompilerOptions.mjs.map +1 -1
  43. package/dist/actions/package/compile/index.mjs +221 -16
  44. package/dist/actions/package/compile/index.mjs.map +1 -1
  45. package/dist/actions/package/compile/packageCompileTsc.mjs +148 -8
  46. package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -1
  47. package/dist/actions/package/compile/packageCompileTscTypes.mjs +145 -8
  48. package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -1
  49. package/dist/actions/package/compile/packageCompileTsup.mjs +235 -3
  50. package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
  51. package/dist/actions/package/copy-assets.mjs.map +1 -1
  52. package/dist/actions/package/deps.mjs.map +1 -1
  53. package/dist/actions/package/gen-docs.mjs.map +1 -1
  54. package/dist/actions/package/index.mjs +289 -71
  55. package/dist/actions/package/index.mjs.map +1 -1
  56. package/dist/actions/package/publint.mjs +3 -0
  57. package/dist/actions/package/publint.mjs.map +1 -1
  58. package/dist/actions/package/recompile.mjs +262 -44
  59. package/dist/actions/package/recompile.mjs.map +1 -1
  60. package/dist/actions/publint.mjs.map +1 -1
  61. package/dist/actions/rebuild.mjs.map +1 -1
  62. package/dist/actions/recompile.mjs.map +1 -1
  63. package/dist/actions/reinstall.mjs.map +1 -1
  64. package/dist/actions/relint.mjs.map +1 -1
  65. package/dist/actions/retest.mjs.map +1 -1
  66. package/dist/actions/sonar.mjs.map +1 -1
  67. package/dist/actions/statics.mjs +3 -2
  68. package/dist/actions/statics.mjs.map +1 -1
  69. package/dist/actions/test.mjs.map +1 -1
  70. package/dist/actions/up.mjs.map +1 -1
  71. package/dist/actions/updo.mjs.map +1 -1
  72. package/dist/actions/upplug.mjs.map +1 -1
  73. package/dist/actions/upyarn.mjs.map +1 -1
  74. package/dist/actions/yarn3only.mjs.map +1 -1
  75. package/dist/bin/package/clean-outputs.mjs +14 -2
  76. package/dist/bin/package/clean-outputs.mjs.map +1 -1
  77. package/dist/bin/package/clean-typescript.mjs +14 -2
  78. package/dist/bin/package/clean-typescript.mjs.map +1 -1
  79. package/dist/bin/package/clean.mjs +15 -4
  80. package/dist/bin/package/clean.mjs.map +1 -1
  81. package/dist/bin/package/compile-only.mjs +223 -18
  82. package/dist/bin/package/compile-only.mjs.map +1 -1
  83. package/dist/bin/package/compile-tsup.mjs +235 -5
  84. package/dist/bin/package/compile-tsup.mjs.map +1 -1
  85. package/dist/bin/package/compile.mjs +223 -18
  86. package/dist/bin/package/compile.mjs.map +1 -1
  87. package/dist/bin/package/copy-assets-cjs.mjs.map +1 -1
  88. package/dist/bin/package/copy-assets-esm.mjs.map +1 -1
  89. package/dist/bin/package/deps.mjs.map +1 -1
  90. package/dist/bin/package/gen-docs.mjs.map +1 -1
  91. package/dist/bin/package/publint.mjs +3 -0
  92. package/dist/bin/package/publint.mjs.map +1 -1
  93. package/dist/bin/package/recompile.mjs +242 -26
  94. package/dist/bin/package/recompile.mjs.map +1 -1
  95. package/dist/bin/xy-ts.mjs +52 -32
  96. package/dist/bin/xy-ts.mjs.map +1 -1
  97. package/dist/bin/xy.mjs +52 -32
  98. package/dist/bin/xy.mjs.map +1 -1
  99. package/dist/index.d.ts +11 -9
  100. package/dist/index.mjs +313 -89
  101. package/dist/index.mjs.map +1 -1
  102. package/dist/lib/createBuildConfig.mjs.map +1 -1
  103. package/dist/lib/defaultBuildConfig.mjs.map +1 -1
  104. package/dist/lib/deleteGlob.mjs +19 -0
  105. package/dist/lib/deleteGlob.mjs.map +1 -0
  106. package/dist/lib/dependencies/DuplicateDetector.mjs +3 -2
  107. package/dist/lib/dependencies/DuplicateDetector.mjs.map +1 -1
  108. package/dist/lib/dependencies/detectDuplicateDependencies.mjs +3 -2
  109. package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +1 -1
  110. package/dist/lib/dependencies/index.mjs +3 -2
  111. package/dist/lib/dependencies/index.mjs.map +1 -1
  112. package/dist/lib/file/ReadFileSyncOptions.mjs.map +1 -1
  113. package/dist/lib/file/fileLines.mjs.map +1 -1
  114. package/dist/lib/file/index.mjs.map +1 -1
  115. package/dist/lib/file/tryReadFileSync.mjs.map +1 -1
  116. package/dist/lib/generateIgnoreFiles.mjs.map +1 -1
  117. package/dist/lib/index.mjs +160 -5
  118. package/dist/lib/index.mjs.map +1 -1
  119. package/dist/lib/loadConfig.mjs +143 -3
  120. package/dist/lib/loadConfig.mjs.map +1 -1
  121. package/dist/lib/processEx.mjs.map +1 -1
  122. package/dist/lib/runSteps.mjs.map +1 -1
  123. package/dist/lib/runStepsAsync.mjs.map +1 -1
  124. package/dist/lib/runXy.mjs.map +1 -1
  125. package/dist/lib/safeExit.mjs.map +1 -1
  126. package/dist/lib/withErrnoException.mjs.map +1 -1
  127. package/dist/lib/yarn/index.mjs.map +1 -1
  128. package/dist/lib/yarn/workspace/index.mjs.map +1 -1
  129. package/dist/lib/yarn/workspace/yarnWorkspace.mjs.map +1 -1
  130. package/dist/lib/yarn/workspace/yarnWorkspaces.mjs.map +1 -1
  131. package/dist/loadPackageConfig.mjs.map +1 -1
  132. package/dist/xy/index.mjs +52 -32
  133. package/dist/xy/index.mjs.map +1 -1
  134. package/dist/xy/param.mjs.map +1 -1
  135. package/dist/xy/xy.mjs +52 -32
  136. package/dist/xy/xy.mjs.map +1 -1
  137. package/dist/xy/xyBuildCommands.mjs +3 -2
  138. package/dist/xy/xyBuildCommands.mjs.map +1 -1
  139. package/dist/xy/xyCommonCommands.mjs +14 -4
  140. package/dist/xy/xyCommonCommands.mjs.map +1 -1
  141. package/dist/xy/xyDeployCommands.mjs.map +1 -1
  142. package/dist/xy/xyInstallCommands.mjs +3 -2
  143. package/dist/xy/xyInstallCommands.mjs.map +1 -1
  144. package/dist/xy/xyLintCommands.mjs +30 -22
  145. package/dist/xy/xyLintCommands.mjs.map +1 -1
  146. package/dist/xy/xyParseOptions.mjs.map +1 -1
  147. package/package.json +53 -55
  148. package/src/actions/build.ts +3 -1
  149. package/src/actions/clean-docs.ts +2 -3
  150. package/src/actions/clean-eslint.ts +3 -2
  151. package/src/actions/clean.ts +3 -1
  152. package/src/actions/compile.ts +13 -3
  153. package/src/actions/cycle.ts +15 -4
  154. package/src/actions/deps.ts +6 -5
  155. package/src/actions/gen-docs.ts +3 -4
  156. package/src/actions/package/clean-outputs.ts +3 -2
  157. package/src/actions/package/clean-typescript.ts +3 -2
  158. package/src/actions/package/compile/XyConfig.ts +5 -13
  159. package/src/actions/package/compile/buildEntries.ts +1 -1
  160. package/src/actions/package/compile/compile.ts +3 -1
  161. package/src/actions/package/compile/copyTypeFiles.ts +1 -1
  162. package/src/actions/package/compile/getCompilerOptions.ts +10 -8
  163. package/src/actions/package/compile/packageCompileTsc.ts +11 -6
  164. package/src/actions/package/compile/packageCompileTscTypes.ts +5 -3
  165. package/src/actions/package/compile/packageCompileTsup.ts +10 -8
  166. package/src/actions/package/copy-assets.ts +1 -3
  167. package/src/actions/package/deps.ts +6 -2
  168. package/src/actions/package/gen-docs.ts +3 -1
  169. package/src/actions/package/publint.ts +8 -5
  170. package/src/actions/publint.ts +3 -1
  171. package/src/actions/recompile.ts +47 -9
  172. package/src/actions/reinstall.ts +3 -1
  173. package/src/lib/defaultBuildConfig.ts +11 -1
  174. package/src/lib/deleteGlob.ts +13 -0
  175. package/src/lib/dependencies/DuplicateDetector.ts +4 -4
  176. package/src/lib/file/ReadFileSyncOptions.ts +4 -1
  177. package/src/lib/file/fileLines.ts +9 -3
  178. package/src/lib/file/tryReadFileSync.ts +4 -2
  179. package/src/lib/generateIgnoreFiles.ts +3 -1
  180. package/src/lib/index.ts +1 -0
  181. package/src/lib/loadConfig.ts +3 -4
  182. package/src/lib/runSteps.ts +2 -1
  183. package/src/lib/runStepsAsync.ts +1 -1
  184. package/src/lib/runXy.ts +4 -1
  185. package/src/lib/withErrnoException.ts +3 -1
  186. package/src/lib/yarn/workspace/yarnWorkspace.ts +1 -1
  187. package/src/lib/yarn/workspace/yarnWorkspaces.ts +1 -1
  188. package/src/loadPackageConfig.ts +1 -1
  189. package/src/types.d.ts +23 -0
  190. package/src/xy/param.ts +2 -4
  191. package/src/xy/xyBuildCommands.ts +10 -20
  192. package/src/xy/xyCommonCommands.ts +4 -2
  193. package/src/xy/xyDeployCommands.ts +4 -2
  194. package/src/xy/xyInstallCommands.ts +5 -5
  195. package/src/xy/xyLintCommands.ts +6 -4
  196. package/src/xy/xyParseOptions.ts +3 -2
  197. package/tsup.config.ts +2 -6
  198. package/xy.config.ts +1 -5
@@ -1,14 +1,15 @@
1
1
  import path from 'node:path'
2
2
 
3
3
  import chalk from 'chalk'
4
- import { rimrafSync } from 'rimraf'
4
+
5
+ import { deleteGlob } from '../lib/index.ts'
5
6
 
6
7
  export const cleanESLint = () => {
7
8
  const pkg = process.env.INIT_CWD ?? '.'
8
9
  const pkgName = process.env.npm_package_name
9
10
  console.log(chalk.green(`Cleaning ESLint [${pkgName}]`))
10
11
 
11
- rimrafSync(path.join(pkg, '.eslintcache'), { glob: true })
12
+ deleteGlob(path.join(pkg, '.eslintcache'))
12
13
 
13
14
  return 0
14
15
  }
@@ -11,7 +11,9 @@ export interface CleanPackageParams {
11
11
  }
12
12
 
13
13
  export const clean = async ({ verbose, pkg }: CleanParams) => {
14
- return pkg ? await cleanPackage({ pkg, verbose }) : cleanAll({ verbose })
14
+ return pkg
15
+ ? await cleanPackage({ pkg, verbose })
16
+ : cleanAll({ verbose })
15
17
  }
16
18
 
17
19
  export const cleanPackage = ({ pkg }: CleanPackageParams) => {
@@ -18,8 +18,16 @@ interface CompilePackageParams {
18
18
  verbose?: boolean
19
19
  }
20
20
 
21
- export const compile = ({ verbose, target, pkg, incremental, publint }: CompileParams) => {
22
- return pkg ? compilePackage({ pkg, publint, target, verbose }) : compileAll({ incremental, publint, target, verbose })
21
+ export const compile = ({
22
+ verbose, target, pkg, incremental, publint, jobs,
23
+ }: CompileParams) => {
24
+ return pkg
25
+ ? compilePackage({
26
+ pkg, publint, target, verbose,
27
+ })
28
+ : compileAll({
29
+ incremental, publint, target, verbose, jobs,
30
+ })
23
31
  }
24
32
 
25
33
  export const compilePackage = ({ target, pkg }: CompilePackageParams) => {
@@ -28,7 +36,9 @@ export const compilePackage = ({ target, pkg }: CompilePackageParams) => {
28
36
  return runSteps(`Compile [${pkg}]`, [['yarn', ['workspace', pkg, 'run', 'package-compile', ...targetOptions]]])
29
37
  }
30
38
 
31
- export const compileAll = ({ jobs, verbose, target, incremental }: CompileParams) => {
39
+ export const compileAll = ({
40
+ jobs, verbose, target, incremental,
41
+ }: CompileParams) => {
32
42
  const start = Date.now()
33
43
  const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']
34
44
  const targetOptions = target ? ['-t', target] : []
@@ -1,6 +1,17 @@
1
- import { runSteps } from '../lib/index.ts'
1
+ import { cwd } from 'node:process'
2
2
 
3
- export const cycle = () => {
4
- const rules = ['"\'import/no-cycle\': [1, { maxDepth: 6 }]"', "\"'import/no-internal-modules': ['off']\""]
5
- return runSteps('Cycle', [['yarn', ['eslint', ...rules.flatMap(rule => ['--rule', rule]), '--cache', '.']]])
3
+ import { ESLint } from 'eslint'
4
+
5
+ export const cycle = async () => {
6
+ const eslint = new ESLint({
7
+ fix: false,
8
+ overrideConfig: { rules: { 'import-x/no-cycle': ['error', { maxDepth: 10 }] } },
9
+ })
10
+ const results = await eslint.lintFiles(['src/**/*.ts*', 'packages/**/src/**/*.ts*'])
11
+
12
+ const formatter = await eslint.loadFormatter('stylish')
13
+ const resultText = formatter.format(results, { cwd: cwd(), rulesMeta: {} })
14
+ console.log(resultText)
15
+
16
+ return results.length
6
17
  }
@@ -1,6 +1,7 @@
1
1
  import chalk from 'chalk'
2
2
 
3
- import { runSteps, ScriptStep } from '../lib/index.ts'
3
+ import type { ScriptStep } from '../lib/index.ts'
4
+ import { runSteps } from '../lib/index.ts'
4
5
 
5
6
  export interface DepsParams {
6
7
  incremental?: boolean
@@ -9,9 +10,7 @@ export interface DepsParams {
9
10
  verbose?: boolean
10
11
  }
11
12
 
12
- export interface DepsPackageParams {
13
- pkg: string
14
- }
13
+ export interface DepsPackageParams { pkg: string }
15
14
 
16
15
  export const deps = ({ pkg, incremental }: DepsParams) => {
17
16
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
@@ -26,7 +25,9 @@ export const depsPackage = ({ pkg }: DepsPackageParams) => {
26
25
  return runSteps(`Deps [${pkg}]`, [...steps])
27
26
  }
28
27
 
29
- export const depsAll = ({ incremental, jobs, verbose }: DepsParams) => {
28
+ export const depsAll = ({
29
+ incremental, jobs, verbose,
30
+ }: DepsParams) => {
30
31
  const start = Date.now()
31
32
  const jobsOptions = jobs ? ['-j', `${jobs}`] : []
32
33
  const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']
@@ -1,13 +1,12 @@
1
- import { runSteps, ScriptStep } from '../lib/index.ts'
1
+ import type { ScriptStep } from '../lib/index.ts'
2
+ import { runSteps } from '../lib/index.ts'
2
3
 
3
4
  export interface GenDocsParams {
4
5
  incremental?: boolean
5
6
  pkg?: string
6
7
  }
7
8
 
8
- export interface GenDocsPackageParams {
9
- pkg: string
10
- }
9
+ export interface GenDocsPackageParams { pkg: string }
11
10
 
12
11
  export const genDocs = ({ pkg, incremental }: GenDocsParams) => {
13
12
  return pkg ? genDocsPackage({ pkg }) : genDocsAll({ incremental })
@@ -1,7 +1,8 @@
1
1
  import path from 'node:path'
2
2
 
3
3
  import chalk from 'chalk'
4
- import { rimraf } from 'rimraf'
4
+
5
+ import { deleteGlob } from '../../lib/index.ts'
5
6
 
6
7
  export const packageCleanOutputs = async () => {
7
8
  const pkg = process.env.INIT_CWD ?? '.'
@@ -9,7 +10,7 @@ export const packageCleanOutputs = async () => {
9
10
  const folders: string[] = [path.join(pkg, 'dist'), path.join(pkg, 'build'), path.join(pkg, 'docs')]
10
11
  console.log(chalk.green(`Cleaning Outputs [${pkgName}]`))
11
12
 
12
- await Promise.all(folders.map(folder => rimraf(folder)))
13
+ await Promise.all(folders.map(folder => deleteGlob(folder)))
13
14
 
14
15
  return 0
15
16
  }
@@ -1,7 +1,8 @@
1
1
  import path from 'node:path'
2
2
 
3
3
  import chalk from 'chalk'
4
- import { rimraf } from 'rimraf'
4
+
5
+ import { deleteGlob } from '../../lib/index.ts'
5
6
 
6
7
  export const packageCleanTypescript = async () => {
7
8
  const pkg = process.env.INIT_CWD ?? '.'
@@ -9,7 +10,7 @@ export const packageCleanTypescript = async () => {
9
10
  console.log(chalk.green(`Cleaning Typescript [${pkgName}]`))
10
11
  const files: string[] = [path.join(pkg, '*.tsbuildinfo'), path.join(pkg, '.tsconfig.*'), path.join(pkg, '.eslintcache')]
11
12
 
12
- await Promise.all(files.map(file => rimraf(file)))
13
+ await Promise.all(files.map(file => deleteGlob(file)))
13
14
 
14
15
  return 0
15
16
  }
@@ -1,4 +1,4 @@
1
- import { Options } from 'tsup'
1
+ import type { Options } from 'tsup'
2
2
 
3
3
  export type EntryMode = 'all' | 'single' | 'auto' | 'platform'
4
4
 
@@ -44,14 +44,10 @@ export type PackageCompileTsupConfig = CompileConfig & {
44
44
  mode?: 'tsup'
45
45
  neutral?: Record<string, Options | boolean>
46
46
  node?: Record<string, Options | boolean>
47
- tsup?: {
48
- options?: Options
49
- }
47
+ tsup?: { options?: Options }
50
48
  }
51
49
 
52
- export type PackageCompileTscConfig = CompileConfig & {
53
- mode: 'tsc'
54
- }
50
+ export type PackageCompileTscConfig = CompileConfig & { mode: 'tsc' }
55
51
 
56
52
  export interface XyConfigBase {
57
53
  compile?: CompileConfig
@@ -61,12 +57,8 @@ export interface XyConfigBase {
61
57
  verbose?: boolean
62
58
  }
63
59
 
64
- export interface XyTsupConfig extends XyConfigBase {
65
- compile?: PackageCompileTsupConfig
66
- }
60
+ export interface XyTsupConfig extends XyConfigBase { compile?: PackageCompileTsupConfig }
67
61
 
68
- export interface XyTscConfig extends XyConfigBase {
69
- compile?: PackageCompileTscConfig
70
- }
62
+ export interface XyTscConfig extends XyConfigBase { compile?: PackageCompileTscConfig }
71
63
 
72
64
  export type XyConfig = XyTsupConfig | XyTscConfig
@@ -1,5 +1,5 @@
1
1
  import { getAllInputs2 } from './inputs.ts'
2
- import { EntryMode } from './XyConfig.ts'
2
+ import type { EntryMode } from './XyConfig.ts'
3
3
 
4
4
  export const buildEntries = (folder: string, entryMode?: EntryMode, verbose = false) => {
5
5
  switch (entryMode) {
@@ -4,7 +4,9 @@ import { loadConfig } from '../../../lib/index.ts'
4
4
  import { packagePublint } from '../publint.ts'
5
5
  import { packageCompileTsc } from './packageCompileTsc.ts'
6
6
  import { packageCompileTsup } from './packageCompileTsup.ts'
7
- import { XyConfig, XyTscConfig, XyTsupConfig } from './XyConfig.ts'
7
+ import type {
8
+ XyConfig, XyTscConfig, XyTsupConfig,
9
+ } from './XyConfig.ts'
8
10
 
9
11
  export const packageCompile = async (inConfig: XyConfig = {}): Promise<number> => {
10
12
  const pkg = process.env.INIT_CWD
@@ -1,7 +1,7 @@
1
1
  import { copyFile, readdir } from 'node:fs/promises'
2
2
 
3
3
  import { Mutex } from 'async-mutex'
4
- import { TsConfigCompilerOptions } from 'tsc-prog'
4
+ import type { TsConfigCompilerOptions } from 'tsc-prog'
5
5
 
6
6
  const copyFileMutex = new Mutex()
7
7
 
@@ -1,15 +1,17 @@
1
1
  import { createRequire } from 'node:module'
2
2
 
3
- // eslint-disable-next-line import/no-internal-modules
4
- import merge from 'lodash/merge.js'
5
- import { TsConfig } from 'tsc-prog'
6
- import { CompilerOptions, findConfigFile, readConfigFile, sys } from 'typescript'
3
+ import deepmerge from 'deepmerge'
4
+ import type { TsConfig } from 'tsc-prog'
5
+ import type { CompilerOptions } from 'typescript'
6
+ import {
7
+ findConfigFile, readConfigFile, sys,
8
+ } from 'typescript'
7
9
 
8
10
  const getNested = (config: TsConfig): CompilerOptions => {
9
11
  if (config.extends) {
10
12
  const require = createRequire(import.meta.url)
11
13
  const opts = require(config.extends)
12
- return { ...getNested(opts), ...config.compilerOptions } as CompilerOptions
14
+ return deepmerge(getNested(opts), config.compilerOptions ?? {}) as CompilerOptions
13
15
  }
14
16
 
15
17
  return config.compilerOptions as CompilerOptions
@@ -20,9 +22,9 @@ export const getCompilerOptionsJSONFollowExtends = (filename: string): CompilerO
20
22
  return getNested(config)
21
23
  }
22
24
 
23
- export const getCompilerOptions = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json'): CompilerOptions => {
25
+ export const getCompilerOptions = (options: CompilerOptions = {}, tsconfig: string = 'tsconfig.json'): CompilerOptions => {
24
26
  const configFileName = findConfigFile('./', sys.fileExists, tsconfig)
25
- const configFileCompilerOptions = configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : undefined
27
+ const configFileCompilerOptions = (configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : undefined) ?? {}
26
28
 
27
- return merge({}, configFileCompilerOptions, options)
29
+ return deepmerge(configFileCompilerOptions, options)
28
30
  }
@@ -1,20 +1,23 @@
1
1
  import { cwd } from 'node:process'
2
2
 
3
3
  import chalk from 'chalk'
4
- import { createProgramFromConfig, TsConfigCompilerOptions } from 'tsc-prog'
5
- import {
4
+ import type { TsConfigCompilerOptions } from 'tsc-prog'
5
+ import { createProgramFromConfig } from 'tsc-prog'
6
+ import type {
6
7
  CompilerOptions,
7
- DiagnosticCategory,
8
8
  FormatDiagnosticsHost,
9
+ LineAndCharacter,
10
+ } from 'typescript'
11
+ import {
12
+ DiagnosticCategory,
9
13
  formatDiagnosticsWithColorAndContext,
10
14
  getLineAndCharacterOfPosition,
11
15
  getPreEmitDiagnostics,
12
- LineAndCharacter,
13
16
  } from 'typescript'
14
17
 
15
18
  import { packagePublint } from '../publint.ts'
16
19
  import { getCompilerOptions } from './getCompilerOptions.ts'
17
- import { XyTscConfig } from './XyConfig.ts'
20
+ import type { XyTscConfig } from './XyConfig.ts'
18
21
 
19
22
  export const packageCompileTsc = async (noEmit?: boolean, config?: XyTscConfig, compilerOptionsParam?: CompilerOptions): Promise<number> => {
20
23
  const pkg = process.env.INIT_CWD ?? cwd()
@@ -52,7 +55,9 @@ export const packageCompileTsc = async (noEmit?: boolean, config?: XyTscConfig,
52
55
  const results = getPreEmitDiagnostics(program)
53
56
 
54
57
  for (const diag of results) {
55
- const lineAndChar: LineAndCharacter = diag.file ? getLineAndCharacterOfPosition(diag.file, diag.start ?? 0) : { character: 0, line: 0 }
58
+ const lineAndChar: LineAndCharacter = diag.file
59
+ ? getLineAndCharacterOfPosition(diag.file, diag.start ?? 0)
60
+ : { character: 0, line: 0 }
56
61
  console.log(chalk.cyan(`${diag.file?.fileName}:${lineAndChar.line + 1}:${lineAndChar.character + 1}`))
57
62
  console.log(formatDiagnosticsWithColorAndContext([diag], formatHost))
58
63
  }
@@ -1,12 +1,14 @@
1
1
  import { cwd } from 'node:process'
2
2
 
3
3
  import chalk from 'chalk'
4
- import { createProgramFromConfig, TsConfigCompilerOptions } from 'tsc-prog'
5
- import { CompilerOptions, DiagnosticCategory } from 'typescript'
4
+ import type { TsConfigCompilerOptions } from 'tsc-prog'
5
+ import { createProgramFromConfig } from 'tsc-prog'
6
+ import type { CompilerOptions } from 'typescript'
7
+ import { DiagnosticCategory } from 'typescript'
6
8
 
7
9
  import { buildEntries } from './buildEntries.ts'
8
10
  import { getCompilerOptions } from './getCompilerOptions.ts'
9
- import { XyConfig } from './XyConfig.ts'
11
+ import type { XyConfig } from './XyConfig.ts'
10
12
 
11
13
  export const packageCompileTscTypes = (
12
14
  folder: string = 'src',
@@ -1,11 +1,13 @@
1
1
  import type { Loader } from 'esbuild'
2
- import { build, defineConfig, Options } from 'tsup'
2
+ import type { Options } from 'tsup'
3
+ import { build, defineConfig } from 'tsup'
3
4
 
4
5
  import { packagePublint } from '../publint.ts'
5
6
  import { buildEntries } from './buildEntries.ts'
6
- import { EntryMode, XyTsupConfig } from './XyConfig.ts'
7
+ import { packageCompileTscTypes } from './packageCompileTscTypes.ts'
8
+ import type { EntryMode, XyTsupConfig } from './XyConfig.ts'
7
9
 
8
- const compileFolder = async (folder: string, entryMode: EntryMode = 'single', options?: Options, _verbose?: boolean) => {
10
+ const compileFolder = async (folder: string, entryMode: EntryMode = 'single', options?: Options, verbose?: boolean) => {
9
11
  const outDir = options?.outDir ?? 'dist'
10
12
  const entry = buildEntries(folder, entryMode)
11
13
  const optionsResult = defineConfig({
@@ -17,7 +19,7 @@ const compileFolder = async (folder: string, entryMode: EntryMode = 'single', op
17
19
  format: ['esm'],
18
20
  outDir,
19
21
  silent: true,
20
- sourcemap: true,
22
+ sourcemap: false,
21
23
  splitting: false,
22
24
  tsconfig: 'tsconfig.json',
23
25
  ...options,
@@ -32,9 +34,7 @@ const compileFolder = async (folder: string, entryMode: EntryMode = 'single', op
32
34
  ).flat()
33
35
 
34
36
  await Promise.all(optionsList.map(options => build(options)))
35
- // packageCompileTscTypes(folder, { verbose }, { outDir })
36
-
37
- return 0
37
+ return packageCompileTscTypes(folder, { verbose }, { outDir })
38
38
  }
39
39
 
40
40
  export const packageCompileTsup = async (config?: XyTsupConfig) => {
@@ -49,7 +49,9 @@ export const packageCompileTsup = async (config?: XyTsupConfig) => {
49
49
  const compileForBrowser = compile?.browser ?? { src: {} }
50
50
  const compileForNeutral = compile?.neutral ?? { src: {} }
51
51
 
52
- const standardLoaders: Record<string, Loader> = { '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' }
52
+ const standardLoaders: Record<string, Loader> = {
53
+ '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy',
54
+ }
53
55
  const standardOptions: Options = {
54
56
  bundle: true,
55
57
  format: ['esm'],
@@ -3,9 +3,7 @@ import path from 'node:path/posix'
3
3
  import chalk from 'chalk'
4
4
  import cpy from 'cpy'
5
5
 
6
- export interface PackageCopyAssetsParams {
7
- target?: 'esm' | 'cjs'
8
- }
6
+ export interface PackageCopyAssetsParams { target?: 'esm' | 'cjs' }
9
7
 
10
8
  const copyTargetAssets = async (target: 'esm' | 'cjs', name: string, location: string) => {
11
9
  try {
@@ -60,7 +60,9 @@ const analyzeDeps = async (pkg: string, ignoreMatches: string[]) => {
60
60
  const missing = { ...srcUnused.missing, ...allUnused.missing }
61
61
  const { invalidDirs, invalidFiles } = allUnused
62
62
 
63
- return { invalidDirs, invalidFiles, missing, unusedDeps, unusedDevDeps, usedDeps, usedDevDeps }
63
+ return {
64
+ invalidDirs, invalidFiles, missing, unusedDeps, unusedDevDeps, usedDeps, usedDevDeps,
65
+ }
64
66
  }
65
67
 
66
68
  export const packageDeps = async () => {
@@ -79,7 +81,9 @@ export const packageDeps = async () => {
79
81
  console.log(`${pkgName} [${error.message}] Failed to parse .depcheckrc [${rawIgnore}]`)
80
82
  }
81
83
 
82
- const { invalidDirs, invalidFiles, unusedDeps, unusedDevDeps, usedDeps, usedDevDeps, missing } = await analyzeDeps(pkg, ignoreMatches)
84
+ const {
85
+ invalidDirs, invalidFiles, unusedDeps, unusedDevDeps, usedDeps, usedDevDeps, missing,
86
+ } = await analyzeDeps(pkg, ignoreMatches)
83
87
 
84
88
  const declaredDeps = Object.keys(packageContent.dependencies ?? {})
85
89
  const declaredPeerDeps = Object.keys(packageContent.peerDependencies ?? {})
@@ -4,7 +4,9 @@ import { existsSync } from 'node:fs'
4
4
  import path from 'node:path'
5
5
 
6
6
  import chalk from 'chalk'
7
- import { Application, ArgumentsReader, TSConfigReader, TypeDocReader } from 'typedoc'
7
+ import {
8
+ Application, ArgumentsReader, TSConfigReader, TypeDocReader,
9
+ } from 'typedoc'
8
10
 
9
11
  const ExitCodes = {
10
12
  CompileError: 3,
@@ -1,14 +1,17 @@
1
1
  import { promises as fs } from 'node:fs'
2
2
 
3
3
  import chalk from 'chalk'
4
- import { Message } from 'publint'
4
+ import type { Message } from 'publint'
5
+ import sortPackageJson from 'sort-package-json'
5
6
 
6
- export interface PackagePublintParams {
7
- verbose?: boolean
8
- }
7
+ export interface PackagePublintParams { verbose?: boolean }
9
8
 
10
9
  export const packagePublint = async (params?: PackagePublintParams) => {
11
10
  const pkgDir = process.env.INIT_CWD
11
+
12
+ const sortedPkg = sortPackageJson(await fs.readFile(`${pkgDir}/package.json`, 'utf8'))
13
+ await fs.writeFile(`${pkgDir}/package.json`, sortedPkg)
14
+
12
15
  const pkg = JSON.parse(await fs.readFile(`${pkgDir}/package.json`, 'utf8'))
13
16
 
14
17
  console.log(chalk.green(`Publint: ${pkg.name}`))
@@ -22,7 +25,7 @@ export const packagePublint = async (params?: PackagePublintParams) => {
22
25
  strict: true,
23
26
  })
24
27
 
25
- // eslint-disable-next-line import/no-internal-modules
28
+ // eslint-disable-next-line import-x/no-internal-modules
26
29
  const { formatMessage } = await import('publint/utils')
27
30
 
28
31
  const validMessage = (_message: Message): boolean => {
@@ -11,7 +11,9 @@ export interface PublintPackageParams {
11
11
  }
12
12
 
13
13
  export const publint = async ({ verbose, pkg }: PublintParams) => {
14
- return pkg ? await publintPackage({ pkg, verbose }) : publintAll({ verbose })
14
+ return pkg
15
+ ? await publintPackage({ pkg, verbose })
16
+ : publintAll({ verbose })
15
17
  }
16
18
 
17
19
  export const publintPackage = ({ pkg }: PublintPackageParams) => {
@@ -16,31 +16,69 @@ export interface RecompilePackageParams {
16
16
  verbose?: boolean
17
17
  }
18
18
 
19
- export const recompile = async ({ verbose, target, pkg, incremental }: RecompileParams) => {
20
- return pkg ? await recompilePackage({ pkg, target, verbose }) : await recompileAll({ incremental, target, verbose })
19
+ export const recompile = async ({
20
+ verbose, target, pkg, incremental,
21
+ }: RecompileParams) => {
22
+ return pkg
23
+ ? await recompilePackage({
24
+ pkg, target, verbose,
25
+ })
26
+ : await recompileAll({
27
+ incremental, target, verbose,
28
+ })
21
29
  }
22
30
 
23
- export const recompilePackage = ({ verbose, target, pkg }: RecompilePackageParams) => {
31
+ export const recompilePackage = ({
32
+ verbose, target, pkg,
33
+ }: RecompilePackageParams) => {
24
34
  const targetOptions = target ? ['-t', target] : []
25
35
  const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']
26
36
 
27
- return runStepsAsync(`Recompile [${pkg}]`, [['yarn', ['workspace', pkg, ...verboseOptions, 'run', 'package-recompile', ...targetOptions]]])
37
+ return runStepsAsync(
38
+ `Recompile [${pkg}]`,
39
+ [['yarn', ['workspace', pkg, ...verboseOptions, 'run', 'package-recompile', ...targetOptions]]],
40
+ )
28
41
  }
29
42
 
30
- export const recompileAll = async ({ jobs, verbose, target, incremental }: RecompileParams) => {
43
+ export const recompileAll = async ({
44
+ jobs, verbose, target, incremental,
45
+ }: RecompileParams) => {
31
46
  const start = Date.now()
32
47
  const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']
33
48
  const targetOptions = target ? ['-t', target] : []
34
- const incrementalOptions = incremental ? ['--since', '-Apt', '--topological-dev'] : ['--parallel', '-Apt', '--topological-dev']
49
+ const incrementalOptions = incremental
50
+ ? ['--since', '-Apt', '--topological-dev']
51
+ : ['--parallel', '-Apt', '--topological-dev']
35
52
  const jobsOptions = jobs ? ['-j', `${jobs}`] : []
36
53
  if (jobs) {
37
54
  console.log(chalk.blue(`Jobs set to [${jobs}]`))
38
55
  }
39
56
 
40
57
  const result = await runStepsAsync(`Recompile${incremental ? '-Incremental' : ''} [All]`, [
41
- ['yarn', ['workspaces', 'foreach', ...incrementalOptions, ...jobsOptions, ...verboseOptions, 'run', 'package-clean', ...targetOptions]],
42
- ['yarn', ['workspaces', 'foreach', ...incrementalOptions, ...jobsOptions, ...verboseOptions, 'run', 'package-compile', ...targetOptions]],
58
+ ['yarn',
59
+ [
60
+ 'workspaces',
61
+ 'foreach',
62
+ ...incrementalOptions,
63
+ ...jobsOptions,
64
+ ...verboseOptions,
65
+ 'run',
66
+ 'package-clean',
67
+ ...targetOptions],
68
+ ],
69
+ ['yarn',
70
+ [
71
+ 'workspaces',
72
+ 'foreach',
73
+ ...incrementalOptions,
74
+ ...jobsOptions,
75
+ ...verboseOptions,
76
+ 'run',
77
+ 'package-compile',
78
+ ...targetOptions]],
43
79
  ])
44
- console.log(`${chalk.gray('Recompiled in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`)
80
+ console.log(
81
+ `${chalk.gray('Recompiled in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`,
82
+ )
45
83
  return result
46
84
  }
@@ -1,4 +1,6 @@
1
- import { closeSync, openSync, rmSync } from 'node:fs'
1
+ import {
2
+ closeSync, openSync, rmSync,
3
+ } from 'node:fs'
2
4
 
3
5
  import { runSteps, yarnWorkspaces } from '../lib/index.ts'
4
6
 
@@ -3,6 +3,16 @@ export const defaultBuildConfig = {
3
3
  rootDir: 'src',
4
4
  rootDirs: ['package.json'],
5
5
  },
6
- exclude: ['**/build', '**/dist', '**/node_modules', '**/*.spec.*', '**/*.spec', '**/*.stories.*', '**/*.example.*', '**/spec/*', '**/stories/*'],
6
+ exclude: [
7
+ '**/build',
8
+ '**/dist',
9
+ '**/node_modules',
10
+ '**/*.spec.*',
11
+ '**/*.spec',
12
+ '**/*.stories.*',
13
+ '**/*.example.*',
14
+ '**/spec/*',
15
+ '**/stories/*',
16
+ ],
7
17
  include: ['src'],
8
18
  }
@@ -0,0 +1,13 @@
1
+ import fs from 'node:fs'
2
+
3
+ import { glob } from 'glob'
4
+
5
+ export const deleteGlob = (globPath: string) => {
6
+ // Find all files matching the glob pattern
7
+ const files = glob.sync(globPath)
8
+
9
+ // Remove each file or directory
10
+ for (const file of files) {
11
+ fs.rmSync(file, { recursive: true, force: true })
12
+ }
13
+ }
@@ -1,8 +1,6 @@
1
1
  import { EOL } from 'node:os'
2
2
 
3
3
  import chalk from 'chalk'
4
- // eslint-disable-next-line import/no-internal-modules
5
- import uniq from 'lodash/uniq.js'
6
4
 
7
5
  import { multiLineToJSONArray } from '../jsonFormatters.ts'
8
6
 
@@ -88,10 +86,12 @@ export class DuplicateDetector {
88
86
  acc.duplicateVersions.push(acc.currentVersion)
89
87
  }
90
88
  acc.duplicateVersions.push(version)
91
- acc.duplicateVersions = uniq(acc.duplicateVersions)
89
+ acc.duplicateVersions = [...new Set(acc.duplicateVersions)]
92
90
  }
93
91
  return acc
94
92
  }
95
93
 
96
- private resultsFactory = (dependency: string): Results => ({ currentVersion: undefined, dependency, duplicateVersions: [] })
94
+ private resultsFactory = (dependency: string): Results => ({
95
+ currentVersion: undefined, dependency, duplicateVersions: [],
96
+ })
97
97
  }
@@ -1,3 +1,6 @@
1
- export type ReadFileSyncOptions = BufferEncoding | { encoding: BufferEncoding; flags?: string }
1
+ export type ReadFileSyncOptions = BufferEncoding | {
2
+ encoding: BufferEncoding
3
+ flags?: string
4
+ }
2
5
 
3
6
  export const defaultReadFileSyncOptions: ReadFileSyncOptions = { encoding: 'utf8' }
@@ -1,11 +1,17 @@
1
- import { existsSync, PathLike, readFileSync, WriteFileOptions, writeFileSync } from 'node:fs'
1
+ import type { PathLike, WriteFileOptions } from 'node:fs'
2
+ import {
3
+ existsSync, readFileSync, writeFileSync,
4
+ } from 'node:fs'
2
5
 
3
6
  import { notEmpty } from '../string/index.ts'
4
7
  import { CROSS_PLATFORM_NEWLINE, WINDOWS_NEWLINE_REGEX } from './constants.ts'
5
- import { defaultReadFileSyncOptions, ReadFileSyncOptions } from './ReadFileSyncOptions.ts'
8
+ import type { ReadFileSyncOptions } from './ReadFileSyncOptions.ts'
9
+ import { defaultReadFileSyncOptions } from './ReadFileSyncOptions.ts'
6
10
 
7
11
  export const readLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>
8
- existsSync(uri) ? readFileSync(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE) : []
12
+ existsSync(uri)
13
+ ? readFileSync(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE)
14
+ : []
9
15
 
10
16
  export const readNonEmptyLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>
11
17
  readLines(uri, options).filter(notEmpty)