@xylabs/ts-scripts-yarn3 6.0.8 → 6.1.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 +2 -2
- package/dist/actions/build.mjs.map +1 -1
- package/dist/actions/index.mjs +16 -2
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/knip.mjs +112 -0
- package/dist/actions/knip.mjs.map +1 -0
- package/dist/actions/relint.mjs.map +1 -1
- package/dist/bin/xy.mjs +22 -2
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +23 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types/actions/index.d.ts +1 -0
- package/dist/types/actions/index.d.ts.map +1 -1
- package/dist/types/actions/knip.d.ts +2 -0
- package/dist/types/actions/knip.d.ts.map +1 -0
- package/dist/types/actions/relint.d.ts.map +1 -1
- package/dist/types/xy/xyLintCommands.d.ts.map +1 -1
- package/dist/xy/index.mjs +22 -2
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +22 -2
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyBuildCommands.mjs +2 -2
- package/dist/xy/xyBuildCommands.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +20 -0
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +11 -5
- package/spec/yarn/workspace/tsconfig.json +0 -3
- package/src/actions/build.ts +0 -34
- package/src/actions/clean-docs.ts +0 -12
- package/src/actions/clean-eslint.ts +0 -15
- package/src/actions/clean-jest.ts +0 -7
- package/src/actions/clean.ts +0 -26
- package/src/actions/compile-types.ts +0 -67
- package/src/actions/compile.ts +0 -67
- package/src/actions/copy-assets.ts +0 -70
- package/src/actions/cycle.ts +0 -15
- package/src/actions/dead.ts +0 -5
- package/src/actions/deploy-major.ts +0 -11
- package/src/actions/deploy-minor.ts +0 -11
- package/src/actions/deploy-next.ts +0 -11
- package/src/actions/deploy.ts +0 -11
- package/src/actions/deps.ts +0 -43
- package/src/actions/dupdeps.ts +0 -12
- package/src/actions/fix.ts +0 -6
- package/src/actions/gen-docs.ts +0 -26
- package/src/actions/gitignore-gen.ts +0 -5
- package/src/actions/gitlint-fix.ts +0 -27
- package/src/actions/gitlint.ts +0 -46
- package/src/actions/index.ts +0 -37
- package/src/actions/license.ts +0 -81
- package/src/actions/lint.ts +0 -61
- package/src/actions/npmignore-gen.ts +0 -5
- package/src/actions/package/clean-outputs.ts +0 -18
- package/src/actions/package/clean-typescript.ts +0 -18
- package/src/actions/package/clean.ts +0 -6
- package/src/actions/package/compile/XyConfig.ts +0 -60
- package/src/actions/package/compile/buildEntries.ts +0 -22
- package/src/actions/package/compile/compile.ts +0 -21
- package/src/actions/package/compile/compileTypes.ts +0 -13
- package/src/actions/package/compile/copyTypeFiles.ts +0 -38
- package/src/actions/package/compile/deepMerge.ts +0 -33
- package/src/actions/package/compile/getCompilerOptions.ts +0 -30
- package/src/actions/package/compile/index.ts +0 -6
- package/src/actions/package/compile/inputs.ts +0 -6
- package/src/actions/package/compile/packageCompileTsc.ts +0 -67
- package/src/actions/package/compile/packageCompileTscTypes.ts +0 -68
- package/src/actions/package/compile/packageCompileTsup.ts +0 -154
- package/src/actions/package/copy-assets.ts +0 -46
- package/src/actions/package/deps.ts +0 -144
- package/src/actions/package/gen-docs.ts +0 -126
- package/src/actions/package/index.ts +0 -10
- package/src/actions/package/lint.ts +0 -86
- package/src/actions/package/publint.ts +0 -75
- package/src/actions/package/recompile.ts +0 -6
- package/src/actions/publint.ts +0 -26
- package/src/actions/rebuild.ts +0 -13
- package/src/actions/recompile.ts +0 -81
- package/src/actions/reinstall.ts +0 -29
- package/src/actions/relint.ts +0 -76
- package/src/actions/retest.ts +0 -8
- package/src/actions/sonar.ts +0 -5
- package/src/actions/statics.ts +0 -13
- package/src/actions/test.ts +0 -5
- package/src/actions/up.ts +0 -5
- package/src/actions/updo.ts +0 -9
- package/src/actions/upplug.ts +0 -10
- package/src/actions/upyarn.ts +0 -5
- package/src/actions/yarn3only.ts +0 -9
- package/src/bin/package/build-only.ts +0 -16
- package/src/bin/package/build.ts +0 -16
- package/src/bin/package/clean-outputs.ts +0 -5
- package/src/bin/package/clean-typescript.ts +0 -5
- package/src/bin/package/clean.ts +0 -12
- package/src/bin/package/compile-only.ts +0 -12
- package/src/bin/package/compile-tsup.ts +0 -12
- package/src/bin/package/compile-types.ts +0 -16
- package/src/bin/package/compile.ts +0 -16
- package/src/bin/package/copy-assets-cjs.ts +0 -12
- package/src/bin/package/copy-assets-esm.ts +0 -12
- package/src/bin/package/deps.ts +0 -12
- package/src/bin/package/fix.ts +0 -16
- package/src/bin/package/gen-docs.ts +0 -12
- package/src/bin/package/lint.ts +0 -16
- package/src/bin/package/publint.ts +0 -13
- package/src/bin/package/recompile.ts +0 -12
- package/src/bin/package/relint.ts +0 -16
- package/src/bin/xy.ts +0 -12
- package/src/index.ts +0 -4
- package/src/lib/checkResult.ts +0 -12
- package/src/lib/createBuildConfig.ts +0 -37
- package/src/lib/defaultBuildConfig.ts +0 -18
- package/src/lib/deleteGlob.ts +0 -13
- package/src/lib/dependencies/DuplicateDetector.ts +0 -97
- package/src/lib/dependencies/detectDuplicateDependencies.ts +0 -41
- package/src/lib/dependencies/index.ts +0 -2
- package/src/lib/file/ReadFileSyncOptions.ts +0 -6
- package/src/lib/file/constants.ts +0 -2
- package/src/lib/file/fileLines.ts +0 -25
- package/src/lib/file/index.ts +0 -4
- package/src/lib/file/tryReadFileSync.ts +0 -9
- package/src/lib/generateIgnoreFiles.ts +0 -31
- package/src/lib/index.ts +0 -20
- package/src/lib/jsonFormatters.ts +0 -6
- package/src/lib/loadConfig.ts +0 -19
- package/src/lib/parsedPackageJSON.ts +0 -7
- package/src/lib/processEx.ts +0 -27
- package/src/lib/runSteps.ts +0 -40
- package/src/lib/runStepsAsync.ts +0 -53
- package/src/lib/runXy.ts +0 -8
- package/src/lib/runXyWithWarning.ts +0 -9
- package/src/lib/safeExit.ts +0 -29
- package/src/lib/string/empty.ts +0 -2
- package/src/lib/string/index.ts +0 -2
- package/src/lib/string/union.ts +0 -1
- package/src/lib/withErrnoException.ts +0 -7
- package/src/lib/withError.ts +0 -8
- package/src/lib/yarn/index.ts +0 -3
- package/src/lib/yarn/isYarnVersionOrGreater.ts +0 -16
- package/src/lib/yarn/workspace/Workspace.ts +0 -4
- package/src/lib/yarn/workspace/index.ts +0 -3
- package/src/lib/yarn/workspace/yarnWorkspace.ts +0 -8
- package/src/lib/yarn/workspace/yarnWorkspaces.ts +0 -21
- package/src/lib/yarn/yarnInitCwd.ts +0 -4
- package/src/loadPackageConfig.ts +0 -13
- package/src/types.d.ts +0 -26
- package/src/xy/index.ts +0 -7
- package/src/xy/param.ts +0 -5
- package/src/xy/xy.ts +0 -20
- package/src/xy/xyBuildCommands.ts +0 -127
- package/src/xy/xyCommonCommands.ts +0 -167
- package/src/xy/xyDeployCommands.ts +0 -53
- package/src/xy/xyInstallCommands.ts +0 -80
- package/src/xy/xyLintCommands.ts +0 -92
- package/src/xy/xyParseOptions.ts +0 -58
- package/tsconfig.build.json +0 -29
- package/tsconfig.json +0 -4
- package/tsconfig.test.json +0 -4
- package/tsup.config.ts +0 -16
- package/types/node-cmd.d.ts +0 -1
- package/xy.config.ts +0 -3
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-statements */
|
|
2
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
3
|
-
import { cwd } from 'node:process'
|
|
4
|
-
|
|
5
|
-
import chalk from 'chalk'
|
|
6
|
-
import depcheck from 'depcheck'
|
|
7
|
-
const special = depcheck.special
|
|
8
|
-
|
|
9
|
-
import { checkResult } from '../../lib/index.ts'
|
|
10
|
-
|
|
11
|
-
const defaultIgnorePatterns = ['*.d.ts', 'dist', '.*', 'node_modules']
|
|
12
|
-
const defaultIgnoreDevDeps = [
|
|
13
|
-
'@xylabs/ts-scripts-yarn3',
|
|
14
|
-
'@xylabs/tsconfig',
|
|
15
|
-
'@xylabs/tsconfig-dom',
|
|
16
|
-
'@xylabs/tsconfig-react',
|
|
17
|
-
'typescript',
|
|
18
|
-
]
|
|
19
|
-
const defaultIgnoreDevPatterns = ['*.stories.*', '*.spec.*', 'spec', 'stories', 'tsconfig.json']
|
|
20
|
-
|
|
21
|
-
const reportUnused = (name: string, unused: depcheck.Results['dependencies']) => {
|
|
22
|
-
if (unused.length > 0) {
|
|
23
|
-
const message = [chalk.yellow(`${unused.length} Unused ${name}`)]
|
|
24
|
-
for (const value of unused) message.push(chalk.gray(` ${value}`))
|
|
25
|
-
console.log(message.join('\n'))
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const reportMissing = (name: string, missing: depcheck.Results['missing']) => {
|
|
30
|
-
if (Object.keys(missing).length > 0) {
|
|
31
|
-
const message = [chalk.yellow(`${Object.entries(missing).length} Missing ${name}`)]
|
|
32
|
-
for (const [key, value] of Object.entries(missing)) {
|
|
33
|
-
message.push(`${key}`, chalk.gray(` ${value.at(0)}`))
|
|
34
|
-
}
|
|
35
|
-
console.log(chalk.yellow(message.join('\n')))
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const analyzeDeps = async (pkg: string, ignoreMatches: string[]) => {
|
|
40
|
-
const packageContent = existsSync(`${pkg}/package.json`) ? JSON.parse(readFileSync(`${pkg}/package.json`, { encoding: 'utf8' })) : undefined
|
|
41
|
-
const [srcUnused, allUnused] = await Promise.all([
|
|
42
|
-
depcheck(`${pkg}/src`, {
|
|
43
|
-
ignoreMatches,
|
|
44
|
-
ignorePatterns: [...defaultIgnoreDevPatterns, ...defaultIgnorePatterns],
|
|
45
|
-
package: packageContent,
|
|
46
|
-
}),
|
|
47
|
-
depcheck(`${pkg}/.`, {
|
|
48
|
-
ignoreMatches: [...ignoreMatches, ...defaultIgnoreDevDeps],
|
|
49
|
-
ignorePatterns: [...defaultIgnorePatterns],
|
|
50
|
-
package: packageContent,
|
|
51
|
-
specials: [special.eslint, special.babel, special.bin, special.prettier, special.jest, special.mocha],
|
|
52
|
-
}),
|
|
53
|
-
])
|
|
54
|
-
|
|
55
|
-
const unusedDeps = srcUnused.dependencies
|
|
56
|
-
const unusedDevDeps = allUnused.devDependencies
|
|
57
|
-
const usedDeps = srcUnused.using
|
|
58
|
-
const usedDevDeps = allUnused.using
|
|
59
|
-
const missing = { ...srcUnused.missing, ...allUnused.missing }
|
|
60
|
-
const { invalidDirs, invalidFiles } = allUnused
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
invalidDirs, invalidFiles, missing, unusedDeps, unusedDevDeps, usedDeps, usedDevDeps,
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export const packageDeps = async () => {
|
|
68
|
-
const pkg = process.env.INIT_CWD ?? cwd()
|
|
69
|
-
const pkgName = process.env.npm_package_name
|
|
70
|
-
|
|
71
|
-
const packageContent = existsSync(`${pkg}/package.json`) ? JSON.parse(readFileSync(`${pkg}/package.json`, { encoding: 'utf8' })) : undefined
|
|
72
|
-
|
|
73
|
-
const rawIgnore
|
|
74
|
-
= existsSync(`${pkg}/.depcheckrc`) ? readFileSync(`${pkg}/.depcheckrc`, { encoding: 'utf8' }).replace('ignores:', '"ignores":') : undefined
|
|
75
|
-
let ignoreMatches: string[] = []
|
|
76
|
-
try {
|
|
77
|
-
ignoreMatches = rawIgnore ? (JSON.parse(`{${rawIgnore}}`).ignores as string[]) : []
|
|
78
|
-
} catch (ex) {
|
|
79
|
-
const error = ex as Error
|
|
80
|
-
console.log(`${pkgName} [${error.message}] Failed to parse .depcheckrc [${rawIgnore}]`)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const {
|
|
84
|
-
invalidDirs, invalidFiles, unusedDeps, unusedDevDeps, usedDeps, usedDevDeps, missing,
|
|
85
|
-
} = await analyzeDeps(pkg, ignoreMatches)
|
|
86
|
-
|
|
87
|
-
const declaredDeps = Object.keys(packageContent.dependencies ?? {})
|
|
88
|
-
const declaredPeerDeps = Object.keys(packageContent.peerDependencies ?? {})
|
|
89
|
-
const declaredDevDeps = Object.keys(packageContent.devDependencies ?? {})
|
|
90
|
-
|
|
91
|
-
const missingDeps = Object.keys(usedDeps).filter(
|
|
92
|
-
key => !declaredDeps.includes(key) && !declaredPeerDeps.includes(key) && !key.startsWith('@types/'),
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
const missingDevDeps = Object.keys(usedDevDeps).filter(key => !declaredDevDeps.includes(key) && !declaredDeps.includes(key))
|
|
96
|
-
|
|
97
|
-
const missingDepsObject: Record<string, string[]> = {}
|
|
98
|
-
for (const key of missingDeps) {
|
|
99
|
-
missingDepsObject[key] = missing[key] ?? [`devDep should be dep [${key}]`]
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const missingDevDepsObject: Record<string, string[]> = {}
|
|
103
|
-
for (const key of missingDevDeps) {
|
|
104
|
-
if (missing[key]) {
|
|
105
|
-
missingDevDepsObject[key] = missing[key]
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const errorCounts = [
|
|
110
|
-
unusedDeps.length,
|
|
111
|
-
unusedDevDeps.length,
|
|
112
|
-
Object.entries(invalidDirs).length,
|
|
113
|
-
Object.entries(invalidFiles).length,
|
|
114
|
-
Object.entries(missingDepsObject).length,
|
|
115
|
-
Object.entries(missingDevDepsObject).length,
|
|
116
|
-
]
|
|
117
|
-
|
|
118
|
-
const errorCount = errorCounts.reduce((prev, count) => prev + count, 0)
|
|
119
|
-
|
|
120
|
-
if (errorCount > 0) {
|
|
121
|
-
console.log(`Deps [${pkgName}] = (${JSON.stringify(errorCounts)})`)
|
|
122
|
-
} else {
|
|
123
|
-
console.log(`Deps [${pkgName}] - Ok`)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
reportUnused('dependencies', unusedDeps)
|
|
127
|
-
reportUnused('devDependencies', unusedDevDeps)
|
|
128
|
-
|
|
129
|
-
if (Object.entries(invalidDirs).length > 0) {
|
|
130
|
-
for (const [key, value] of Object.entries(invalidDirs)) console.warn(chalk.gray(`Invalid Dir: ${key}: ${value}`))
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (Object.entries(invalidFiles).length > 0) {
|
|
134
|
-
for (const [key, value] of Object.entries(invalidFiles)) console.warn(chalk.gray(`Invalid File: ${key}: ${value}`))
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
reportMissing('dependencies', missingDepsObject)
|
|
138
|
-
reportMissing('devDependencies', missingDevDepsObject)
|
|
139
|
-
|
|
140
|
-
checkResult(`Deps [${pkgName}]`, errorCount, 'warn', false)
|
|
141
|
-
|
|
142
|
-
// returning 0 here since we never want deps to be fatal
|
|
143
|
-
return 0
|
|
144
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/* eslint-disable complexity */
|
|
2
|
-
/* eslint-disable max-statements */
|
|
3
|
-
import { existsSync } from 'node:fs'
|
|
4
|
-
import path from 'node:path'
|
|
5
|
-
|
|
6
|
-
import chalk from 'chalk'
|
|
7
|
-
import {
|
|
8
|
-
Application, ArgumentsReader, TSConfigReader, TypeDocReader,
|
|
9
|
-
} from 'typedoc'
|
|
10
|
-
|
|
11
|
-
const ExitCodes = {
|
|
12
|
-
CompileError: 3,
|
|
13
|
-
ExceptionThrown: 6,
|
|
14
|
-
NoEntryPoints: 2,
|
|
15
|
-
Ok: 0,
|
|
16
|
-
OptionError: 1,
|
|
17
|
-
OutputError: 5,
|
|
18
|
-
ValidationError: 4,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const packageGenDocs = async () => {
|
|
22
|
-
const pkg = process.env.INIT_CWD
|
|
23
|
-
|
|
24
|
-
if (pkg && !existsSync(path.join(pkg, 'typedoc.json'))) {
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const app = await Application.bootstrap({
|
|
29
|
-
entryPointStrategy: 'merge',
|
|
30
|
-
entryPoints: [`${pkg}/src/**/*.ts`, `${pkg}/packages/*/dist/docs.json`],
|
|
31
|
-
excludeExternals: true,
|
|
32
|
-
json: `${pkg}/dist/docs.json`,
|
|
33
|
-
logLevel: 'Error',
|
|
34
|
-
tsconfig: `${pkg}/tsconfig.json`,
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
app.options.addReader(new ArgumentsReader(0))
|
|
38
|
-
app.options.addReader(new TypeDocReader())
|
|
39
|
-
app.options.addReader(new TSConfigReader())
|
|
40
|
-
app.options.addReader(new ArgumentsReader(300))
|
|
41
|
-
|
|
42
|
-
return await runTypeDoc(app)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const runTypeDoc = async (app: Application) => {
|
|
46
|
-
const pkgName = process.env.npm_package_name
|
|
47
|
-
if (app.options.getValue('version')) {
|
|
48
|
-
console.log(app.toString())
|
|
49
|
-
return ExitCodes.Ok
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (app.options.getValue('showConfig')) {
|
|
53
|
-
console.log(app.options.getRawValues())
|
|
54
|
-
return ExitCodes.Ok
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (app.logger.hasErrors()) {
|
|
58
|
-
return ExitCodes.OptionError
|
|
59
|
-
}
|
|
60
|
-
if (app.options.getValue('treatWarningsAsErrors') && app.logger.hasWarnings()) {
|
|
61
|
-
return ExitCodes.OptionError
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (app.options.getValue('entryPoints').length === 0) {
|
|
65
|
-
app.logger.error('No entry points provided')
|
|
66
|
-
return ExitCodes.NoEntryPoints
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (app.options.getValue('watch')) {
|
|
70
|
-
await app.convertAndWatch(async (project) => {
|
|
71
|
-
const out = app.options.getValue('out')
|
|
72
|
-
if (out) {
|
|
73
|
-
await app.generateDocs(project, out)
|
|
74
|
-
}
|
|
75
|
-
const json = app.options.getValue('json')
|
|
76
|
-
if (json) {
|
|
77
|
-
await app.generateJson(project, json)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (!out && !json) {
|
|
81
|
-
await app.generateDocs(project, './docs')
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
return ExitCodes.Ok
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const project = await app.convert()
|
|
88
|
-
if (!project) {
|
|
89
|
-
return ExitCodes.CompileError
|
|
90
|
-
}
|
|
91
|
-
if (app.options.getValue('treatWarningsAsErrors') && app.logger.hasWarnings()) {
|
|
92
|
-
return ExitCodes.CompileError
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
app.validate(project)
|
|
96
|
-
if (app.logger.hasErrors()) {
|
|
97
|
-
return ExitCodes.ValidationError
|
|
98
|
-
}
|
|
99
|
-
if (app.options.getValue('treatWarningsAsErrors') && app.logger.hasWarnings()) {
|
|
100
|
-
return ExitCodes.ValidationError
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (app.options.getValue('emit') !== 'none') {
|
|
104
|
-
const out = app.options.getValue('out')
|
|
105
|
-
if (out) {
|
|
106
|
-
await app.generateDocs(project, out)
|
|
107
|
-
}
|
|
108
|
-
const json = app.options.getValue('json')
|
|
109
|
-
if (json) {
|
|
110
|
-
await app.generateJson(project, json)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (!out && !json) {
|
|
114
|
-
await app.generateDocs(project, './docs')
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (app.logger.hasErrors()) {
|
|
118
|
-
return ExitCodes.OutputError
|
|
119
|
-
}
|
|
120
|
-
if (app.options.getValue('treatWarningsAsErrors') && app.logger.hasWarnings()) {
|
|
121
|
-
return ExitCodes.OutputError
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
console.log(chalk.green(`${pkgName} - Ok`))
|
|
125
|
-
return ExitCodes.Ok
|
|
126
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './clean.ts'
|
|
2
|
-
export * from './clean-outputs.ts'
|
|
3
|
-
export * from './clean-typescript.ts'
|
|
4
|
-
export * from './compile/index.ts'
|
|
5
|
-
export * from './copy-assets.ts'
|
|
6
|
-
export * from './deps.ts'
|
|
7
|
-
export * from './gen-docs.ts'
|
|
8
|
-
export * from './lint.ts'
|
|
9
|
-
export * from './publint.ts'
|
|
10
|
-
export * from './recompile.ts'
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { readdirSync } from 'node:fs'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import { cwd } from 'node:process'
|
|
4
|
-
import { pathToFileURL } from 'node:url'
|
|
5
|
-
|
|
6
|
-
import chalk from 'chalk'
|
|
7
|
-
import { ESLint } from 'eslint'
|
|
8
|
-
import { findUp } from 'find-up'
|
|
9
|
-
import picomatch from 'picomatch'
|
|
10
|
-
|
|
11
|
-
const dumpMessages = (lintResults: ESLint.LintResult[]) => {
|
|
12
|
-
const colors: ('white' | 'red' | 'yellow')[] = ['white', 'yellow', 'red']
|
|
13
|
-
const severity: string[] = ['none', 'warning', 'error']
|
|
14
|
-
|
|
15
|
-
for (const lintResult of lintResults) {
|
|
16
|
-
if (lintResult.messages.length > 0) {
|
|
17
|
-
console.log(chalk.gray(`\n${lintResult.filePath}`))
|
|
18
|
-
for (const message of lintResult.messages) {
|
|
19
|
-
console.log(
|
|
20
|
-
chalk.gray(`\t${message.line}:${message.column}`),
|
|
21
|
-
chalk[colors[message.severity]](`\t${severity[message.severity]}`),
|
|
22
|
-
chalk.white(`\t${message.message}`),
|
|
23
|
-
chalk.gray(`\t${message.ruleId}`),
|
|
24
|
-
)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function getRootESLintConfig() {
|
|
31
|
-
// Locate the root eslint.config.mjs
|
|
32
|
-
const configPath = await findUp('eslint.config.mjs')
|
|
33
|
-
|
|
34
|
-
if (!configPath) {
|
|
35
|
-
throw new Error('eslint.config.mjs not found in the monorepo')
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return pathToFileURL(configPath)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function getFiles(dir: string, ignoreFolders: string[]): string[] {
|
|
42
|
-
const currentDirectory = cwd()
|
|
43
|
-
const subDirectory = dir.split(currentDirectory)[1]
|
|
44
|
-
if (ignoreFolders.includes(subDirectory)) return []
|
|
45
|
-
return readdirSync(dir, { withFileTypes: true })
|
|
46
|
-
.flatMap((dirent) => {
|
|
47
|
-
const res = path.resolve(dir, dirent.name)
|
|
48
|
-
const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name
|
|
49
|
-
|
|
50
|
-
const ignoreMatchers = ignoreFolders.map(pattern => picomatch(pattern))
|
|
51
|
-
|
|
52
|
-
// Exclude ignored paths
|
|
53
|
-
if (ignoreMatchers.some(isMatch => isMatch(relativePath))) return []
|
|
54
|
-
|
|
55
|
-
return dirent.isDirectory()
|
|
56
|
-
? getFiles(res, ignoreFolders)
|
|
57
|
-
: [res]
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const packageLint = async (fix = false, verbose = false, cache = true) => {
|
|
62
|
-
const pkg = process.env.INIT_CWD
|
|
63
|
-
const configPath = await getRootESLintConfig()
|
|
64
|
-
const { default: eslintConfig } = await import(configPath.href)
|
|
65
|
-
|
|
66
|
-
// List of folders to ignore
|
|
67
|
-
const ignoreFolders = ['node_modules', 'dist', 'packages', '.git', 'build', '.yarn', '.vscode', '.github']
|
|
68
|
-
|
|
69
|
-
const engine = new ESLint({
|
|
70
|
-
baseConfig: [...eslintConfig], fix, warnIgnored: false, cache,
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
const files = getFiles(cwd(), ignoreFolders)
|
|
74
|
-
if (verbose) {
|
|
75
|
-
console.log(chalk.green(`Linting ${pkg} [files = ${files.length}]`))
|
|
76
|
-
}
|
|
77
|
-
const lintResults = await engine.lintFiles(files)
|
|
78
|
-
|
|
79
|
-
dumpMessages(lintResults)
|
|
80
|
-
|
|
81
|
-
if (fix) {
|
|
82
|
-
await ESLint.outputFixes(lintResults)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0)
|
|
86
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'node:fs'
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
import type { Message } from 'publint'
|
|
5
|
-
import sortPackageJson from 'sort-package-json'
|
|
6
|
-
|
|
7
|
-
export interface PackagePublintParams { verbose?: boolean }
|
|
8
|
-
|
|
9
|
-
export const packagePublint = async (params?: PackagePublintParams) => {
|
|
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
|
-
|
|
15
|
-
const pkg = JSON.parse(await fs.readFile(`${pkgDir}/package.json`, 'utf8'))
|
|
16
|
-
|
|
17
|
-
console.log(chalk.green(`Publint: ${pkg.name}`))
|
|
18
|
-
console.log(chalk.gray(pkgDir))
|
|
19
|
-
|
|
20
|
-
const { publint } = await import('publint')
|
|
21
|
-
|
|
22
|
-
const { messages } = await publint({
|
|
23
|
-
level: 'suggestion',
|
|
24
|
-
pkgDir,
|
|
25
|
-
strict: true,
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
// eslint-disable-next-line import-x/no-internal-modules
|
|
29
|
-
const { formatMessage } = await import('publint/utils')
|
|
30
|
-
|
|
31
|
-
const validMessage = (_message: Message): boolean => {
|
|
32
|
-
return true
|
|
33
|
-
/* try {
|
|
34
|
-
const value = getValueFromPath(pkg, message.path)
|
|
35
|
-
switch (message.code) {
|
|
36
|
-
case 'FILE_INVALID_FORMAT':
|
|
37
|
-
return !message.args?.actualFilePath?.includes('dist/browser') && !value?.includes('dist/browser')
|
|
38
|
-
case 'EXPORT_TYPES_INVALID_FORMAT':
|
|
39
|
-
return !`${value}`.includes('dist/browser')
|
|
40
|
-
default:
|
|
41
|
-
return true
|
|
42
|
-
}
|
|
43
|
-
} catch (ex) {
|
|
44
|
-
const error = ex as Error
|
|
45
|
-
console.error(chalk.red(`validMessage Excepted: ${error.message}`))
|
|
46
|
-
console.error(chalk.gray(JSON.stringify(error.stack)))
|
|
47
|
-
return true
|
|
48
|
-
} */
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// we filter out invalid file formats for the esm folder since it is intentionally done
|
|
52
|
-
const validMessages = messages.filter(validMessage)
|
|
53
|
-
for (const message of validMessages) {
|
|
54
|
-
switch (message.type) {
|
|
55
|
-
case 'error': {
|
|
56
|
-
console.error(chalk.red(`[${message.code}] ${formatMessage(message, pkg)}`))
|
|
57
|
-
break
|
|
58
|
-
}
|
|
59
|
-
case 'warning': {
|
|
60
|
-
console.warn(chalk.yellow(`[${message.code}] ${formatMessage(message, pkg)}`))
|
|
61
|
-
break
|
|
62
|
-
}
|
|
63
|
-
default: {
|
|
64
|
-
console.log(chalk.white(`[${message.code}] ${formatMessage(message, pkg)}`))
|
|
65
|
-
break
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (params?.verbose) {
|
|
71
|
-
console.log(chalk.gray(`Publint [Finish]: ${pkgDir} [${validMessages.length}]`))
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return validMessages.filter(message => message.type === 'error').length
|
|
75
|
-
}
|
package/src/actions/publint.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { runSteps, runStepsAsync } from '../lib/index.ts'
|
|
2
|
-
|
|
3
|
-
export interface PublintParams {
|
|
4
|
-
pkg?: string
|
|
5
|
-
verbose?: boolean
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface PublintPackageParams {
|
|
9
|
-
pkg: string
|
|
10
|
-
verbose?: boolean
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const publint = async ({ verbose, pkg }: PublintParams) => {
|
|
14
|
-
return pkg
|
|
15
|
-
? await publintPackage({ pkg, verbose })
|
|
16
|
-
: publintAll({ verbose })
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const publintPackage = ({ pkg }: PublintPackageParams) => {
|
|
20
|
-
return runStepsAsync(`Publint [${pkg}]`, [['yarn', ['workspace', pkg, 'run', 'package-publint']]])
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const publintAll = ({ verbose }: PublintParams) => {
|
|
24
|
-
const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']
|
|
25
|
-
return runSteps('Publint', [['yarn', ['workspaces', 'foreach', '-pA', ...verboseOptions, 'run', 'package-publint']]])
|
|
26
|
-
}
|
package/src/actions/rebuild.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { runSteps } from '../lib/index.ts'
|
|
2
|
-
|
|
3
|
-
export interface RebuildParams {
|
|
4
|
-
pkg?: string
|
|
5
|
-
target?: 'esm' | 'cjs'
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const rebuild = ({ target }: RebuildParams) => {
|
|
9
|
-
return runSteps('Rebuild', [
|
|
10
|
-
['yarn', 'xy clean'],
|
|
11
|
-
['yarn', target ? `xy build -t ${target}` : 'xy build'],
|
|
12
|
-
])
|
|
13
|
-
}
|
package/src/actions/recompile.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
|
|
3
|
-
import { runStepsAsync } from '../lib/index.ts'
|
|
4
|
-
|
|
5
|
-
export interface RecompileParams {
|
|
6
|
-
incremental?: boolean
|
|
7
|
-
jobs?: number
|
|
8
|
-
pkg?: string
|
|
9
|
-
target?: 'esm' | 'cjs'
|
|
10
|
-
verbose?: boolean
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface RecompilePackageParams {
|
|
14
|
-
pkg: string
|
|
15
|
-
target?: 'esm' | 'cjs'
|
|
16
|
-
verbose?: boolean
|
|
17
|
-
}
|
|
18
|
-
|
|
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
|
-
})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const recompilePackage = ({ target, pkg }: RecompilePackageParams) => {
|
|
32
|
-
const targetOptions = target ? ['-t', target] : []
|
|
33
|
-
|
|
34
|
-
return runStepsAsync(
|
|
35
|
-
`Recompile [${pkg}]`,
|
|
36
|
-
[['yarn', ['workspace', pkg, 'run', 'package-recompile', ...targetOptions]]],
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const recompileAll = async ({
|
|
41
|
-
jobs, verbose, target, incremental,
|
|
42
|
-
}: RecompileParams) => {
|
|
43
|
-
const start = Date.now()
|
|
44
|
-
const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']
|
|
45
|
-
const targetOptions = target ? ['-t', target] : []
|
|
46
|
-
const incrementalOptions = incremental
|
|
47
|
-
? ['--since', '-Apt', '--topological-dev']
|
|
48
|
-
: ['--parallel', '-Apt', '--topological-dev']
|
|
49
|
-
const jobsOptions = jobs ? ['-j', `${jobs}`] : []
|
|
50
|
-
if (jobs) {
|
|
51
|
-
console.log(chalk.blue(`Jobs set to [${jobs}]`))
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const result = await runStepsAsync(`Recompile${incremental ? '-Incremental' : ''} [All]`, [
|
|
55
|
-
['yarn',
|
|
56
|
-
[
|
|
57
|
-
'workspaces',
|
|
58
|
-
'foreach',
|
|
59
|
-
...incrementalOptions,
|
|
60
|
-
...jobsOptions,
|
|
61
|
-
...verboseOptions,
|
|
62
|
-
'run',
|
|
63
|
-
'package-clean',
|
|
64
|
-
...targetOptions],
|
|
65
|
-
],
|
|
66
|
-
['yarn',
|
|
67
|
-
[
|
|
68
|
-
'workspaces',
|
|
69
|
-
'foreach',
|
|
70
|
-
...incrementalOptions,
|
|
71
|
-
...jobsOptions,
|
|
72
|
-
...verboseOptions,
|
|
73
|
-
'run',
|
|
74
|
-
'package-compile',
|
|
75
|
-
...targetOptions]],
|
|
76
|
-
])
|
|
77
|
-
console.log(
|
|
78
|
-
`${chalk.gray('Recompiled in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`,
|
|
79
|
-
)
|
|
80
|
-
return result
|
|
81
|
-
}
|
package/src/actions/reinstall.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
closeSync, openSync, rmSync,
|
|
3
|
-
} from 'node:fs'
|
|
4
|
-
|
|
5
|
-
import { runSteps, yarnWorkspaces } from '../lib/index.ts'
|
|
6
|
-
|
|
7
|
-
export const reinstall = () => {
|
|
8
|
-
console.log('Reinstall [Clear Lock File]')
|
|
9
|
-
closeSync(openSync('./yarn.lock', 'w'))
|
|
10
|
-
|
|
11
|
-
console.log('Reinstall [Clear Node Modules]')
|
|
12
|
-
const workspaces = yarnWorkspaces()
|
|
13
|
-
const result = workspaces
|
|
14
|
-
.map(({ location, name }) => {
|
|
15
|
-
const dist = `${location}/node_modules`
|
|
16
|
-
try {
|
|
17
|
-
rmSync(dist, { force: true, recursive: true })
|
|
18
|
-
return 0
|
|
19
|
-
} catch (ex) {
|
|
20
|
-
const error = ex as Error
|
|
21
|
-
console.error(`Reinstall [Clear Node Modules] Failed [${name}, ${error.message}]`)
|
|
22
|
-
return 1
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
26
|
-
.reduce((prev, result) => prev || result, 0)
|
|
27
|
-
|
|
28
|
-
return result || runSteps('Reinstall', [['yarn', 'install --network-timeout 10000']])
|
|
29
|
-
}
|
package/src/actions/relint.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import type { ESLint } from 'eslint'
|
|
3
|
-
|
|
4
|
-
import { runSteps, yarnWorkspaces } from '../lib/index.ts'
|
|
5
|
-
|
|
6
|
-
export interface RelintParams {
|
|
7
|
-
incremental?: boolean
|
|
8
|
-
pkg?: string
|
|
9
|
-
verbose?: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface RelintPackageParams {
|
|
13
|
-
pkg: string
|
|
14
|
-
verbose?: boolean
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const dumpMessages = (lintResults: ESLint.LintResult[]) => {
|
|
18
|
-
const colors: ('white' | 'red' | 'yellow')[] = ['white', 'yellow', 'red']
|
|
19
|
-
const severity: string[] = ['none', 'warning', 'error']
|
|
20
|
-
|
|
21
|
-
for (const lintResult of lintResults) {
|
|
22
|
-
if (lintResult.messages.length > 0) {
|
|
23
|
-
console.log(chalk.gray(`${lintResult.filePath}`))
|
|
24
|
-
for (const message of lintResult.messages) {
|
|
25
|
-
console.log(
|
|
26
|
-
chalk.gray(`\t${message.line}:${message.column}`),
|
|
27
|
-
chalk[colors[message.severity]](`\t${severity[message.severity]}`),
|
|
28
|
-
chalk.white(`\t${message.message}`),
|
|
29
|
-
chalk.gray(`\t${message.ruleId}`),
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const relintPackage = ({ pkg }: RelintParams & Required<Pick<RelintParams, 'pkg'>>) => {
|
|
37
|
-
console.log(chalk.gray(`${'Relint'} [All-Packages]`))
|
|
38
|
-
const start = Date.now()
|
|
39
|
-
|
|
40
|
-
const result = runSteps('Relint [All-Packages]', [
|
|
41
|
-
['yarn', ['workspace',
|
|
42
|
-
pkg,
|
|
43
|
-
'run',
|
|
44
|
-
'package-relint',
|
|
45
|
-
]],
|
|
46
|
-
])
|
|
47
|
-
console.log(chalk.gray(`${'Relinted in'} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`))
|
|
48
|
-
return result
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export const relint = ({
|
|
52
|
-
pkg, verbose, incremental,
|
|
53
|
-
}: RelintParams = {}) => {
|
|
54
|
-
return pkg
|
|
55
|
-
? relintPackage({ pkg })
|
|
56
|
-
: relintAllPackages({ verbose, incremental })
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export const relintAllPackages = ({ verbose = true, incremental }: RelintParams = {}) => {
|
|
60
|
-
console.log(chalk.gray(`${'Relint'} [All-Packages]`))
|
|
61
|
-
const start = Date.now()
|
|
62
|
-
const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']
|
|
63
|
-
const incrementalOptions = incremental ? ['--since', '-Ap'] : ['--parallel', '-Ap']
|
|
64
|
-
|
|
65
|
-
const result = runSteps(`${'Relint'} [All-Packages]`, [
|
|
66
|
-
['yarn', ['workspaces',
|
|
67
|
-
'foreach',
|
|
68
|
-
...verboseOptions,
|
|
69
|
-
...incrementalOptions,
|
|
70
|
-
'run',
|
|
71
|
-
'package-relint',
|
|
72
|
-
]],
|
|
73
|
-
])
|
|
74
|
-
console.log(chalk.gray(`Relinted in [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`))
|
|
75
|
-
return result
|
|
76
|
-
}
|