@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
package/src/actions/sonar.ts
DELETED
package/src/actions/statics.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
|
|
3
|
-
import { detectDuplicateDependencies, parsedPackageJSON } from '../lib/index.ts'
|
|
4
|
-
|
|
5
|
-
const DefaultDependencies = ['axios', '@xylabs/pixel', 'react', 'graphql', 'react-router', '@mui/material', '@mui/system']
|
|
6
|
-
|
|
7
|
-
export const statics = () => {
|
|
8
|
-
console.log(chalk.green('Check Required Static Dependencies'))
|
|
9
|
-
|
|
10
|
-
const statics = parsedPackageJSON()?.xy?.deps?.statics
|
|
11
|
-
|
|
12
|
-
return detectDuplicateDependencies(statics, DefaultDependencies)
|
|
13
|
-
}
|
package/src/actions/test.ts
DELETED
package/src/actions/up.ts
DELETED
package/src/actions/updo.ts
DELETED
package/src/actions/upplug.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { runSteps } from '../lib/index.ts'
|
|
2
|
-
|
|
3
|
-
export const updateYarnPlugins = () => {
|
|
4
|
-
return runSteps('Update Yarn Plugins', [
|
|
5
|
-
['yarn', ['plugin', 'import', 'https://mskelton.dev/yarn-outdated/v3']],
|
|
6
|
-
['yarn', ['plugin', 'import', 'version']],
|
|
7
|
-
['yarn', ['plugin', 'import', 'interactive-tools']],
|
|
8
|
-
['yarn', ['plugin', 'import', 'workspace-tools']],
|
|
9
|
-
])
|
|
10
|
-
}
|
package/src/actions/upyarn.ts
DELETED
package/src/actions/yarn3only.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packageCompile } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packageCompile({ verbose: true, publint: false })
|
|
8
|
-
.then((value) => {
|
|
9
|
-
if (value) {
|
|
10
|
-
process.exit(value)
|
|
11
|
-
}
|
|
12
|
-
})
|
|
13
|
-
.catch((reason) => {
|
|
14
|
-
console.error(chalk.red(reason))
|
|
15
|
-
process.exit(-1)
|
|
16
|
-
})
|
package/src/bin/package/build.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packageCompile } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packageCompile({ verbose: false, publint: true })
|
|
8
|
-
.then((value) => {
|
|
9
|
-
if (value) {
|
|
10
|
-
process.exit(value)
|
|
11
|
-
}
|
|
12
|
-
})
|
|
13
|
-
.catch((reason) => {
|
|
14
|
-
console.error(chalk.red(reason))
|
|
15
|
-
process.exit(-1)
|
|
16
|
-
})
|
package/src/bin/package/clean.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packageCompile } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packageCompile({ verbose: true, publint: false })
|
|
8
|
-
.then(value => (process.exitCode = value))
|
|
9
|
-
.catch((reason) => {
|
|
10
|
-
console.error(chalk.red(reason))
|
|
11
|
-
process.exitCode = 1
|
|
12
|
-
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packageCompileTsup } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packageCompileTsup({ verbose: true })
|
|
8
|
-
.then(value => (process.exitCode = value))
|
|
9
|
-
.catch((reason) => {
|
|
10
|
-
console.error(chalk.red(reason))
|
|
11
|
-
process.exitCode = 1
|
|
12
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packageCompileTypes } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packageCompileTypes({ verbose: true })
|
|
8
|
-
.then((value) => {
|
|
9
|
-
if (value) {
|
|
10
|
-
process.exit(value)
|
|
11
|
-
}
|
|
12
|
-
})
|
|
13
|
-
.catch((reason) => {
|
|
14
|
-
console.error(chalk.red(reason))
|
|
15
|
-
process.exit(-1)
|
|
16
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packageCompile } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packageCompile({ verbose: false })
|
|
8
|
-
.then((value) => {
|
|
9
|
-
if (value) {
|
|
10
|
-
process.exit(value)
|
|
11
|
-
}
|
|
12
|
-
})
|
|
13
|
-
.catch((reason) => {
|
|
14
|
-
console.error(chalk.red(reason))
|
|
15
|
-
process.exit(-1)
|
|
16
|
-
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packageCopyAssets } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packageCopyAssets({ target: 'cjs' })
|
|
8
|
-
.then(value => (process.exitCode = value))
|
|
9
|
-
.catch((reason) => {
|
|
10
|
-
console.error(chalk.red(reason))
|
|
11
|
-
process.exitCode = 1
|
|
12
|
-
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packageCopyAssets } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packageCopyAssets({ target: 'esm' })
|
|
8
|
-
.then(value => (process.exitCode = value))
|
|
9
|
-
.catch((reason) => {
|
|
10
|
-
console.error(chalk.red(reason))
|
|
11
|
-
process.exitCode = 1
|
|
12
|
-
})
|
package/src/bin/package/deps.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packageDeps } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packageDeps()
|
|
8
|
-
.then(value => (process.exitCode = value))
|
|
9
|
-
.catch((ex: Error) => {
|
|
10
|
-
console.error(`Deps Failed: ${chalk.red(ex)}`)
|
|
11
|
-
process.exitCode = 0
|
|
12
|
-
})
|
package/src/bin/package/fix.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packageLint } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packageLint(true)
|
|
8
|
-
.then((value) => {
|
|
9
|
-
if (value) {
|
|
10
|
-
process.exit(value)
|
|
11
|
-
}
|
|
12
|
-
})
|
|
13
|
-
.catch((reason) => {
|
|
14
|
-
console.error(chalk.red(reason))
|
|
15
|
-
process.exit(-1)
|
|
16
|
-
})
|
package/src/bin/package/lint.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packageLint } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packageLint()
|
|
8
|
-
.then((value) => {
|
|
9
|
-
if (value) {
|
|
10
|
-
process.exit(value)
|
|
11
|
-
}
|
|
12
|
-
})
|
|
13
|
-
.catch((reason) => {
|
|
14
|
-
console.error(chalk.red(reason))
|
|
15
|
-
process.exit(-1)
|
|
16
|
-
})
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packagePublint } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packagePublint()
|
|
8
|
-
.then(value => (process.exitCode = value))
|
|
9
|
-
.catch((ex: Error) => {
|
|
10
|
-
console.error(`Publint Failed: ${chalk.red(ex)}`)
|
|
11
|
-
console.error(chalk.gray(ex.stack))
|
|
12
|
-
process.exitCode = -1
|
|
13
|
-
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packageRecompile } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packageRecompile()
|
|
8
|
-
.then(value => (process.exitCode = value))
|
|
9
|
-
.catch((reason) => {
|
|
10
|
-
console.error(chalk.red(reason))
|
|
11
|
-
process.exitCode = 1
|
|
12
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { packageLint } from '../../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
packageLint(false, false, true)
|
|
8
|
-
.then((value) => {
|
|
9
|
-
if (value) {
|
|
10
|
-
process.exit(value)
|
|
11
|
-
}
|
|
12
|
-
})
|
|
13
|
-
.catch((reason) => {
|
|
14
|
-
console.error(chalk.red(reason))
|
|
15
|
-
process.exit(-1)
|
|
16
|
-
})
|
package/src/bin/xy.ts
DELETED
package/src/index.ts
DELETED
package/src/lib/checkResult.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
|
|
3
|
-
export const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {
|
|
4
|
-
if (result) {
|
|
5
|
-
const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'
|
|
6
|
-
const chalkFunc = level === 'error' ? chalk.red : chalk.yellow
|
|
7
|
-
console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))
|
|
8
|
-
if (exitOnFail) {
|
|
9
|
-
process.exit(result)
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs'
|
|
2
|
-
|
|
3
|
-
import { defaultBuildConfig } from './defaultBuildConfig.ts'
|
|
4
|
-
|
|
5
|
-
const getGeneralTypescriptConfig = (location: string) => {
|
|
6
|
-
let generalConfig: string | undefined
|
|
7
|
-
try {
|
|
8
|
-
generalConfig = readFileSync(`${location}/tsconfig.json`, { encoding: 'utf8' })
|
|
9
|
-
} catch {
|
|
10
|
-
return false
|
|
11
|
-
}
|
|
12
|
-
return JSON.parse(generalConfig)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const createBuildConfig = (
|
|
16
|
-
location: string,
|
|
17
|
-
module: 'ESNext' | 'CommonJS',
|
|
18
|
-
target: 'ESNext' | 'ES6',
|
|
19
|
-
outDirSuffix: string,
|
|
20
|
-
): Record<string, unknown> | undefined => {
|
|
21
|
-
const generalConfigObject = getGeneralTypescriptConfig(location)
|
|
22
|
-
if (generalConfigObject === false) {
|
|
23
|
-
return undefined
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
...generalConfigObject,
|
|
27
|
-
compilerOptions: {
|
|
28
|
-
...defaultBuildConfig.compilerOptions,
|
|
29
|
-
...generalConfigObject.compilerOptions,
|
|
30
|
-
module,
|
|
31
|
-
outDir: `./${generalConfigObject.compilerOptions?.outDir ?? 'dist'}/${outDirSuffix}`,
|
|
32
|
-
target,
|
|
33
|
-
},
|
|
34
|
-
exclude: [...(generalConfigObject.exclude ?? []), ...defaultBuildConfig.exclude],
|
|
35
|
-
include: [...(generalConfigObject.include ?? []), ...defaultBuildConfig.include],
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const defaultBuildConfig = {
|
|
2
|
-
compilerOptions: {
|
|
3
|
-
rootDir: 'src',
|
|
4
|
-
rootDirs: ['package.json'],
|
|
5
|
-
},
|
|
6
|
-
exclude: [
|
|
7
|
-
'**/build',
|
|
8
|
-
'**/dist',
|
|
9
|
-
'**/node_modules',
|
|
10
|
-
'**/*.spec.*',
|
|
11
|
-
'**/*.spec',
|
|
12
|
-
'**/*.stories.*',
|
|
13
|
-
'**/*.example.*',
|
|
14
|
-
'**/spec/*',
|
|
15
|
-
'**/stories/*',
|
|
16
|
-
],
|
|
17
|
-
include: ['src'],
|
|
18
|
-
}
|
package/src/lib/deleteGlob.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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,97 +0,0 @@
|
|
|
1
|
-
import { EOL } from 'node:os'
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
|
|
5
|
-
import { multiLineToJSONArray } from '../jsonFormatters.ts'
|
|
6
|
-
|
|
7
|
-
interface ChildFields {
|
|
8
|
-
descriptor: string
|
|
9
|
-
locator: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const trimVirtualMeta = (value: string): string => {
|
|
13
|
-
const virtualParts = value.split('virtual:')
|
|
14
|
-
if (virtualParts.length > 1) {
|
|
15
|
-
const hashParts = virtualParts[1].split('#')
|
|
16
|
-
return virtualParts[0] + hashParts[1]
|
|
17
|
-
} else {
|
|
18
|
-
return value
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const trimObjectDependencyVirtualMeta = (obj: Record<string, ChildFields>): Record<string, ChildFields> => {
|
|
23
|
-
const resultObj: Record<string, ChildFields> = {}
|
|
24
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
25
|
-
resultObj[trimVirtualMeta(key)] = {
|
|
26
|
-
descriptor: trimVirtualMeta(value.descriptor),
|
|
27
|
-
locator: trimVirtualMeta(value.locator),
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return resultObj
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const trimDependencyVirtualMeta = (dependencies: DependencyEntries): DependencyEntries => {
|
|
34
|
-
return dependencies.map((dependency) => {
|
|
35
|
-
return { children: trimObjectDependencyVirtualMeta(dependency.children), value: trimVirtualMeta(dependency.value) }
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface DependencyEntry {
|
|
40
|
-
children: Record<string, ChildFields>
|
|
41
|
-
value: string
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
type DependencyEntries = DependencyEntry[]
|
|
45
|
-
|
|
46
|
-
interface Results {
|
|
47
|
-
currentVersion: string | undefined
|
|
48
|
-
dependency: string
|
|
49
|
-
duplicateVersions: string[]
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export class DuplicateDetector {
|
|
53
|
-
private dependency: string
|
|
54
|
-
private dependencyEntries: DependencyEntries
|
|
55
|
-
|
|
56
|
-
constructor(output: string, dependency: string) {
|
|
57
|
-
this.dependency = dependency
|
|
58
|
-
this.dependencyEntries = trimDependencyVirtualMeta(multiLineToJSONArray(output))
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
detect() {
|
|
62
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
63
|
-
const result = this.dependencyEntries.reduce(this.detectReducer, this.resultsFactory(this.dependency))
|
|
64
|
-
if (result.duplicateVersions.length > 0) {
|
|
65
|
-
console.log(chalk.yellow(`${EOL}Duplicates found for: ${this.dependency}`))
|
|
66
|
-
const duplicateVersions = result.duplicateVersions.toString().replaceAll(',', `${EOL} `)
|
|
67
|
-
console.log(chalk.grey(` ${duplicateVersions}`, EOL))
|
|
68
|
-
return 1
|
|
69
|
-
} else {
|
|
70
|
-
console.log(`${this.dependency} - OK`)
|
|
71
|
-
return 0
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
private detectReducer(acc: Results, entry: DependencyEntry) {
|
|
76
|
-
const version = Object.entries(entry.children).map(([k]) => k)[0]
|
|
77
|
-
|
|
78
|
-
if (!acc.currentVersion) {
|
|
79
|
-
acc.currentVersion = version
|
|
80
|
-
return acc
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (acc.currentVersion && acc.currentVersion !== version && !version.includes('@virtual:')) {
|
|
84
|
-
// if first duplicate, push the current version as the first duplicate
|
|
85
|
-
if (acc.duplicateVersions.length === 0) {
|
|
86
|
-
acc.duplicateVersions.push(acc.currentVersion)
|
|
87
|
-
}
|
|
88
|
-
acc.duplicateVersions.push(version)
|
|
89
|
-
acc.duplicateVersions = [...new Set(acc.duplicateVersions)]
|
|
90
|
-
}
|
|
91
|
-
return acc
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
private resultsFactory = (dependency: string): Results => ({
|
|
95
|
-
currentVersion: undefined, dependency, duplicateVersions: [],
|
|
96
|
-
})
|
|
97
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'node:child_process'
|
|
2
|
-
|
|
3
|
-
import { safeExit } from '../safeExit.ts'
|
|
4
|
-
import { DuplicateDetector } from './DuplicateDetector.ts'
|
|
5
|
-
|
|
6
|
-
export const detectDuplicateDependencies = (depsFromPackageJSON?: string[], DefaultDependencies?: string[]) => {
|
|
7
|
-
let exitCode = 0
|
|
8
|
-
|
|
9
|
-
const dependencies = depsFromPackageJSON?.length ? depsFromPackageJSON : DefaultDependencies
|
|
10
|
-
|
|
11
|
-
return safeExit(() => {
|
|
12
|
-
if (dependencies) {
|
|
13
|
-
for (const dependency of dependencies) {
|
|
14
|
-
let output: string
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
const cmd = `yarn why ${dependency} --json`
|
|
18
|
-
output = execSync(cmd).toString()
|
|
19
|
-
} catch (e) {
|
|
20
|
-
console.error(`Error running yarn why: ${e}`)
|
|
21
|
-
exitCode = 1
|
|
22
|
-
continue
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (output) {
|
|
26
|
-
exitCode = new DuplicateDetector(output, dependency).detect()
|
|
27
|
-
} else {
|
|
28
|
-
console.log(`${dependency} - N/A`)
|
|
29
|
-
if (depsFromPackageJSON) {
|
|
30
|
-
exitCode = 1
|
|
31
|
-
console.log(`🚨 Library ${dependency} was requested in package.json but not found`)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return exitCode
|
|
36
|
-
} else {
|
|
37
|
-
console.log('🚨 No dependencies where passed')
|
|
38
|
-
return exitCode
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { PathLike, WriteFileOptions } from 'node:fs'
|
|
2
|
-
import {
|
|
3
|
-
existsSync, readFileSync,
|
|
4
|
-
writeFileSync,
|
|
5
|
-
} from 'node:fs'
|
|
6
|
-
|
|
7
|
-
import { notEmpty } from '../string/index.ts'
|
|
8
|
-
import { CROSS_PLATFORM_NEWLINE, WINDOWS_NEWLINE_REGEX } from './constants.ts'
|
|
9
|
-
import type { ReadFileSyncOptions } from './ReadFileSyncOptions.ts'
|
|
10
|
-
import { defaultReadFileSyncOptions } from './ReadFileSyncOptions.ts'
|
|
11
|
-
|
|
12
|
-
export const readLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>
|
|
13
|
-
existsSync(uri)
|
|
14
|
-
? readFileSync(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE)
|
|
15
|
-
: []
|
|
16
|
-
|
|
17
|
-
export const readNonEmptyLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>
|
|
18
|
-
readLines(uri, options).filter(notEmpty)
|
|
19
|
-
|
|
20
|
-
export const writeLines = (uri: PathLike, lines: string[], options: WriteFileOptions = defaultReadFileSyncOptions) => {
|
|
21
|
-
const existing = existsSync(uri) ? readFileSync(uri, options) : undefined
|
|
22
|
-
const desired = lines.join(CROSS_PLATFORM_NEWLINE)
|
|
23
|
-
// Check if the file is different before writing
|
|
24
|
-
if (existing !== desired) writeFileSync(uri, desired, options)
|
|
25
|
-
}
|
package/src/lib/file/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { PathLike } from 'node:fs'
|
|
2
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
3
|
-
|
|
4
|
-
import type { ReadFileSyncOptions } from './ReadFileSyncOptions.ts'
|
|
5
|
-
import { defaultReadFileSyncOptions } from './ReadFileSyncOptions.ts'
|
|
6
|
-
|
|
7
|
-
export const tryReadFileSync = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string | undefined => {
|
|
8
|
-
return existsSync(uri) ? readFileSync(uri, options) : undefined
|
|
9
|
-
}
|