@xylabs/ts-scripts-yarn3 4.0.0-rc.8 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/build.mjs.map +1 -1
- package/dist/actions/clean-docs.mjs +14 -4
- package/dist/actions/clean-docs.mjs.map +1 -1
- package/dist/actions/clean-eslint.mjs +16 -4
- package/dist/actions/clean-eslint.mjs.map +1 -1
- package/dist/actions/clean-jest.mjs.map +1 -1
- package/dist/actions/clean.mjs.map +1 -1
- package/dist/actions/compile.mjs +3 -2
- package/dist/actions/compile.mjs.map +1 -1
- package/dist/actions/copy-assets.mjs.map +1 -1
- package/dist/actions/cycle.mjs +25 -110
- package/dist/actions/cycle.mjs.map +1 -1
- package/dist/actions/dead.mjs.map +1 -1
- package/dist/actions/deploy-major.mjs.map +1 -1
- package/dist/actions/deploy-minor.mjs.map +1 -1
- package/dist/actions/deploy-next.mjs.map +1 -1
- package/dist/actions/deploy.mjs.map +1 -1
- package/dist/actions/deps.mjs.map +1 -1
- package/dist/actions/dupdeps.mjs +3 -2
- package/dist/actions/dupdeps.mjs.map +1 -1
- package/dist/actions/fix.mjs.map +1 -1
- package/dist/actions/gen-docs.mjs.map +1 -1
- package/dist/actions/gitignore-gen.mjs.map +1 -1
- package/dist/actions/index.mjs +227 -56
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/license.mjs.map +1 -1
- package/dist/actions/lint-clean.mjs.map +1 -1
- package/dist/actions/lint-profile.mjs.map +1 -1
- package/dist/actions/lint.mjs.map +1 -1
- package/dist/actions/npmignore-gen.mjs.map +1 -1
- package/dist/actions/package/clean-outputs.mjs +16 -2
- package/dist/actions/package/clean-outputs.mjs.map +1 -1
- package/dist/actions/package/clean-typescript.mjs +16 -2
- package/dist/actions/package/clean-typescript.mjs.map +1 -1
- package/dist/actions/package/clean.mjs +17 -4
- package/dist/actions/package/clean.mjs.map +1 -1
- package/dist/actions/package/compile/buildEntries.mjs.map +1 -1
- package/dist/actions/package/compile/compile.mjs +151 -11
- package/dist/actions/package/compile/compile.mjs.map +1 -1
- package/dist/actions/package/compile/copyTypeFiles.mjs.map +1 -1
- package/dist/actions/package/compile/getCompilerOptions.mjs +145 -8
- package/dist/actions/package/compile/getCompilerOptions.mjs.map +1 -1
- package/dist/actions/package/compile/index.mjs +151 -11
- package/dist/actions/package/compile/index.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsc.mjs +148 -8
- package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTscTypes.mjs +145 -8
- package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsup.mjs +3 -0
- package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
- package/dist/actions/package/copy-assets.mjs.map +1 -1
- package/dist/actions/package/deps.mjs.map +1 -1
- package/dist/actions/package/gen-docs.mjs.map +1 -1
- package/dist/actions/package/index.mjs +205 -52
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/publint.mjs +3 -0
- package/dist/actions/package/publint.mjs.map +1 -1
- package/dist/actions/package/recompile.mjs +192 -39
- package/dist/actions/package/recompile.mjs.map +1 -1
- package/dist/actions/publint.mjs.map +1 -1
- package/dist/actions/rebuild.mjs.map +1 -1
- package/dist/actions/recompile.mjs +14 -1
- package/dist/actions/recompile.mjs.map +1 -1
- package/dist/actions/reinstall.mjs.map +1 -1
- package/dist/actions/relint.mjs.map +1 -1
- package/dist/actions/retest.mjs.map +1 -1
- package/dist/actions/sonar.mjs.map +1 -1
- package/dist/actions/statics.mjs +3 -2
- package/dist/actions/statics.mjs.map +1 -1
- package/dist/actions/test.mjs.map +1 -1
- package/dist/actions/up.mjs.map +1 -1
- package/dist/actions/updo.mjs.map +1 -1
- package/dist/actions/upplug.mjs.map +1 -1
- package/dist/actions/upyarn.mjs.map +1 -1
- package/dist/actions/yarn3only.mjs.map +1 -1
- package/dist/bin/package/clean-outputs.mjs +14 -2
- package/dist/bin/package/clean-outputs.mjs.map +1 -1
- package/dist/bin/package/clean-typescript.mjs +14 -2
- package/dist/bin/package/clean-typescript.mjs.map +1 -1
- package/dist/bin/package/clean.mjs +15 -4
- package/dist/bin/package/clean.mjs.map +1 -1
- package/dist/bin/package/compile-only.mjs +151 -11
- package/dist/bin/package/compile-only.mjs.map +1 -1
- package/dist/bin/package/compile-tsup.mjs +3 -0
- package/dist/bin/package/compile-tsup.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +151 -11
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/copy-assets-cjs.mjs.map +1 -1
- package/dist/bin/package/copy-assets-esm.mjs.map +1 -1
- package/dist/bin/package/deps.mjs.map +1 -1
- package/dist/bin/package/gen-docs.mjs.map +1 -1
- package/dist/bin/package/publint.mjs +3 -0
- package/dist/bin/package/publint.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +170 -19
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/xy-ts.mjs +66 -33
- package/dist/bin/xy-ts.mjs.map +1 -1
- package/dist/bin/xy.mjs +66 -33
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +11 -9
- package/dist/index.mjs +230 -58
- package/dist/index.mjs.map +1 -1
- package/dist/lib/createBuildConfig.mjs.map +1 -1
- package/dist/lib/defaultBuildConfig.mjs.map +1 -1
- package/dist/lib/deleteGlob.mjs +19 -0
- package/dist/lib/deleteGlob.mjs.map +1 -0
- package/dist/lib/dependencies/DuplicateDetector.mjs +3 -2
- package/dist/lib/dependencies/DuplicateDetector.mjs.map +1 -1
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs +3 -2
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +1 -1
- package/dist/lib/dependencies/index.mjs +3 -2
- package/dist/lib/dependencies/index.mjs.map +1 -1
- package/dist/lib/file/ReadFileSyncOptions.mjs.map +1 -1
- package/dist/lib/file/fileLines.mjs.map +1 -1
- package/dist/lib/file/index.mjs.map +1 -1
- package/dist/lib/file/tryReadFileSync.mjs.map +1 -1
- package/dist/lib/generateIgnoreFiles.mjs.map +1 -1
- package/dist/lib/index.mjs +160 -5
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/loadConfig.mjs +143 -3
- package/dist/lib/loadConfig.mjs.map +1 -1
- package/dist/lib/processEx.mjs.map +1 -1
- package/dist/lib/runSteps.mjs.map +1 -1
- package/dist/lib/runStepsAsync.mjs.map +1 -1
- package/dist/lib/runXy.mjs.map +1 -1
- package/dist/lib/safeExit.mjs.map +1 -1
- package/dist/lib/withErrnoException.mjs.map +1 -1
- package/dist/lib/yarn/index.mjs.map +1 -1
- package/dist/lib/yarn/workspace/index.mjs.map +1 -1
- package/dist/lib/yarn/workspace/yarnWorkspace.mjs.map +1 -1
- package/dist/lib/yarn/workspace/yarnWorkspaces.mjs.map +1 -1
- package/dist/loadPackageConfig.mjs.map +1 -1
- package/dist/xy/index.mjs +66 -33
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/param.mjs.map +1 -1
- package/dist/xy/xy.mjs +66 -33
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyBuildCommands.mjs +17 -3
- package/dist/xy/xyBuildCommands.mjs.map +1 -1
- package/dist/xy/xyCommonCommands.mjs +14 -4
- package/dist/xy/xyCommonCommands.mjs.map +1 -1
- package/dist/xy/xyDeployCommands.mjs.map +1 -1
- package/dist/xy/xyInstallCommands.mjs +3 -2
- package/dist/xy/xyInstallCommands.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +30 -22
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/dist/xy/xyParseOptions.mjs.map +1 -1
- package/package.json +53 -55
- package/src/actions/build.ts +3 -1
- package/src/actions/clean-docs.ts +2 -3
- package/src/actions/clean-eslint.ts +3 -2
- package/src/actions/clean.ts +3 -1
- package/src/actions/compile.ts +13 -3
- package/src/actions/cycle.ts +15 -4
- package/src/actions/deps.ts +6 -5
- package/src/actions/gen-docs.ts +3 -4
- package/src/actions/package/clean-outputs.ts +3 -2
- package/src/actions/package/clean-typescript.ts +3 -2
- package/src/actions/package/compile/XyConfig.ts +5 -13
- package/src/actions/package/compile/buildEntries.ts +1 -1
- package/src/actions/package/compile/compile.ts +3 -1
- package/src/actions/package/compile/copyTypeFiles.ts +1 -1
- package/src/actions/package/compile/getCompilerOptions.ts +10 -8
- package/src/actions/package/compile/packageCompileTsc.ts +11 -6
- package/src/actions/package/compile/packageCompileTscTypes.ts +5 -3
- package/src/actions/package/compile/packageCompileTsup.ts +6 -3
- package/src/actions/package/copy-assets.ts +1 -3
- package/src/actions/package/deps.ts +6 -2
- package/src/actions/package/gen-docs.ts +3 -1
- package/src/actions/package/publint.ts +8 -5
- package/src/actions/publint.ts +3 -1
- package/src/actions/recompile.ts +47 -8
- package/src/actions/reinstall.ts +3 -1
- package/src/lib/defaultBuildConfig.ts +11 -1
- package/src/lib/deleteGlob.ts +13 -0
- package/src/lib/dependencies/DuplicateDetector.ts +4 -4
- package/src/lib/file/ReadFileSyncOptions.ts +4 -1
- package/src/lib/file/fileLines.ts +9 -3
- package/src/lib/file/tryReadFileSync.ts +4 -2
- package/src/lib/generateIgnoreFiles.ts +3 -1
- package/src/lib/index.ts +1 -0
- package/src/lib/loadConfig.ts +3 -4
- package/src/lib/runSteps.ts +2 -1
- package/src/lib/runStepsAsync.ts +1 -1
- package/src/lib/runXy.ts +4 -1
- package/src/lib/withErrnoException.ts +3 -1
- package/src/lib/yarn/workspace/yarnWorkspace.ts +1 -1
- package/src/lib/yarn/workspace/yarnWorkspaces.ts +1 -1
- package/src/loadPackageConfig.ts +1 -1
- package/src/types.d.ts +23 -0
- package/src/xy/param.ts +2 -4
- package/src/xy/xyBuildCommands.ts +10 -20
- package/src/xy/xyCommonCommands.ts +4 -2
- package/src/xy/xyDeployCommands.ts +4 -2
- package/src/xy/xyInstallCommands.ts +5 -5
- package/src/xy/xyLintCommands.ts +6 -4
- package/src/xy/xyParseOptions.ts +3 -2
- package/tsup.config.ts +2 -6
- 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
|
-
|
|
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
|
-
|
|
12
|
+
deleteGlob(path.join(pkg, '.eslintcache'))
|
|
12
13
|
|
|
13
14
|
return 0
|
|
14
15
|
}
|
package/src/actions/clean.ts
CHANGED
|
@@ -11,7 +11,9 @@ export interface CleanPackageParams {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const clean = async ({ verbose, pkg }: CleanParams) => {
|
|
14
|
-
return pkg
|
|
14
|
+
return pkg
|
|
15
|
+
? await cleanPackage({ pkg, verbose })
|
|
16
|
+
: cleanAll({ verbose })
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export const cleanPackage = ({ pkg }: CleanPackageParams) => {
|
package/src/actions/compile.ts
CHANGED
|
@@ -18,8 +18,16 @@ interface CompilePackageParams {
|
|
|
18
18
|
verbose?: boolean
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export const compile = ({
|
|
22
|
-
|
|
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 = ({
|
|
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] : []
|
package/src/actions/cycle.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cwd } from 'node:process'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
}
|
package/src/actions/deps.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
|
|
3
|
-
import {
|
|
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 = ({
|
|
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']
|
package/src/actions/gen-docs.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
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 =>
|
|
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
|
-
|
|
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 =>
|
|
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
|
|
@@ -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 {
|
|
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,15 +1,17 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
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
|
|
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 {
|
|
5
|
-
import {
|
|
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,9 +1,10 @@
|
|
|
1
1
|
import type { Loader } from 'esbuild'
|
|
2
|
-
import {
|
|
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 type { EntryMode, XyTsupConfig } from './XyConfig.ts'
|
|
7
8
|
|
|
8
9
|
const compileFolder = async (folder: string, entryMode: EntryMode = 'single', options?: Options, _verbose?: boolean) => {
|
|
9
10
|
const outDir = options?.outDir ?? 'dist'
|
|
@@ -49,7 +50,9 @@ export const packageCompileTsup = async (config?: XyTsupConfig) => {
|
|
|
49
50
|
const compileForBrowser = compile?.browser ?? { src: {} }
|
|
50
51
|
const compileForNeutral = compile?.neutral ?? { src: {} }
|
|
51
52
|
|
|
52
|
-
const standardLoaders: Record<string, Loader> = {
|
|
53
|
+
const standardLoaders: Record<string, Loader> = {
|
|
54
|
+
'.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy',
|
|
55
|
+
}
|
|
53
56
|
const standardOptions: Options = {
|
|
54
57
|
bundle: true,
|
|
55
58
|
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 {
|
|
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 {
|
|
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 {
|
|
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 => {
|
package/src/actions/publint.ts
CHANGED
|
@@ -11,7 +11,9 @@ export interface PublintPackageParams {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const publint = async ({ verbose, pkg }: PublintParams) => {
|
|
14
|
-
return pkg
|
|
14
|
+
return pkg
|
|
15
|
+
? await publintPackage({ pkg, verbose })
|
|
16
|
+
: publintAll({ verbose })
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export const publintPackage = ({ pkg }: PublintPackageParams) => {
|
package/src/actions/recompile.ts
CHANGED
|
@@ -16,30 +16,69 @@ export interface RecompilePackageParams {
|
|
|
16
16
|
verbose?: boolean
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const recompile = async ({
|
|
20
|
-
|
|
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 = ({
|
|
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(
|
|
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 ({
|
|
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
|
|
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',
|
|
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]],
|
|
42
79
|
])
|
|
43
|
-
console.log(
|
|
80
|
+
console.log(
|
|
81
|
+
`${chalk.gray('Recompiled in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`,
|
|
82
|
+
)
|
|
44
83
|
return result
|
|
45
84
|
}
|
package/src/actions/reinstall.ts
CHANGED
|
@@ -3,6 +3,16 @@ export const defaultBuildConfig = {
|
|
|
3
3
|
rootDir: 'src',
|
|
4
4
|
rootDirs: ['package.json'],
|
|
5
5
|
},
|
|
6
|
-
exclude: [
|
|
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 =
|
|
89
|
+
acc.duplicateVersions = [...new Set(acc.duplicateVersions)]
|
|
92
90
|
}
|
|
93
91
|
return acc
|
|
94
92
|
}
|
|
95
93
|
|
|
96
|
-
private resultsFactory = (dependency: string): Results => ({
|
|
94
|
+
private resultsFactory = (dependency: string): Results => ({
|
|
95
|
+
currentVersion: undefined, dependency, duplicateVersions: [],
|
|
96
|
+
})
|
|
97
97
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export type ReadFileSyncOptions = BufferEncoding | {
|
|
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 {
|
|
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 {
|
|
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)
|
|
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)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PathLike } from 'node:fs'
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
+
import type { ReadFileSyncOptions } from './ReadFileSyncOptions.ts'
|
|
5
|
+
import { defaultReadFileSyncOptions } from './ReadFileSyncOptions.ts'
|
|
4
6
|
|
|
5
7
|
export const tryReadFileSync = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string | undefined => {
|
|
6
8
|
return existsSync(uri) ? readFileSync(uri, options) : undefined
|
|
@@ -2,7 +2,9 @@ import chalk from 'chalk'
|
|
|
2
2
|
|
|
3
3
|
import { readNonEmptyLines, writeLines } from './file/index.ts'
|
|
4
4
|
import { union } from './string/index.ts'
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
INIT_CWD, yarnWorkspace, yarnWorkspaces,
|
|
7
|
+
} from './yarn/index.ts'
|
|
6
8
|
|
|
7
9
|
const mergeEntries = (a: string[], b: string[]): string[] => [...union(a, b)].sort()
|
|
8
10
|
|