@xylabs/ts-scripts-yarn3 6.0.9 → 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 +10 -4
- 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,31 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
|
|
3
|
-
import { readNonEmptyLines, writeLines } from './file/index.ts'
|
|
4
|
-
import { union } from './string/index.ts'
|
|
5
|
-
import {
|
|
6
|
-
INIT_CWD, yarnWorkspace, yarnWorkspaces,
|
|
7
|
-
} from './yarn/index.ts'
|
|
8
|
-
|
|
9
|
-
const localeCompare = (a: string, b: string) => a.localeCompare(b)
|
|
10
|
-
|
|
11
|
-
const mergeEntries = (a: string[], b: string[]): string[] => [...union(a, b)].sort(localeCompare)
|
|
12
|
-
|
|
13
|
-
export const generateIgnoreFiles = (filename: string, pkg?: string) => {
|
|
14
|
-
console.log(chalk.green(`Generate ${filename} Files`))
|
|
15
|
-
const cwd = INIT_CWD() ?? '.'
|
|
16
|
-
const workspaces = pkg ? [yarnWorkspace(pkg)] : yarnWorkspaces()
|
|
17
|
-
const readEntries = (location: string): string[] => readNonEmptyLines(`${location}/${filename}`)
|
|
18
|
-
const writeEntries = (location: string, entries: string[]) => writeLines(`${location}/${filename}`, entries)
|
|
19
|
-
const results = workspaces.map(({ location, name }) => {
|
|
20
|
-
try {
|
|
21
|
-
writeEntries(location, mergeEntries(readEntries(cwd), readEntries(location)))
|
|
22
|
-
return 0
|
|
23
|
-
} catch (ex) {
|
|
24
|
-
const error = ex as Error
|
|
25
|
-
console.error(`Generate ${filename} Files [${name}] [${error.message}]`)
|
|
26
|
-
return 1
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
const succeeded = results.every(result => result === 0)
|
|
30
|
-
return succeeded ? 0 : 1
|
|
31
|
-
}
|
package/src/lib/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export * from './checkResult.ts'
|
|
2
|
-
export * from './createBuildConfig.ts'
|
|
3
|
-
export * from './defaultBuildConfig.ts'
|
|
4
|
-
export * from './deleteGlob.ts'
|
|
5
|
-
export * from './dependencies/index.ts'
|
|
6
|
-
export * from './file/index.ts'
|
|
7
|
-
export * from './generateIgnoreFiles.ts'
|
|
8
|
-
export * from './jsonFormatters.ts'
|
|
9
|
-
export * from './loadConfig.ts'
|
|
10
|
-
export * from './parsedPackageJSON.ts'
|
|
11
|
-
export * from './processEx.ts'
|
|
12
|
-
export * from './runSteps.ts'
|
|
13
|
-
export * from './runStepsAsync.ts'
|
|
14
|
-
export * from './runXy.ts'
|
|
15
|
-
export * from './runXyWithWarning.ts'
|
|
16
|
-
export * from './safeExit.ts'
|
|
17
|
-
export * from './string/index.ts'
|
|
18
|
-
export * from './withErrnoException.ts'
|
|
19
|
-
export * from './withError.ts'
|
|
20
|
-
export * from './yarn/index.ts'
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export const multiLineToJSONArray = (output: string) => {
|
|
2
|
-
const withCommas = output.replaceAll('\r\n', '').replaceAll('\n', ',')
|
|
3
|
-
const cleanCollection = withCommas.slice(0, Math.max(0, withCommas.length - 1))
|
|
4
|
-
const collection = `[${cleanCollection}]`
|
|
5
|
-
return JSON.parse(collection)
|
|
6
|
-
}
|
package/src/lib/loadConfig.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import { cosmiconfig } from 'cosmiconfig'
|
|
3
|
-
import deepmerge from 'deepmerge'
|
|
4
|
-
|
|
5
|
-
let config: Record<string, unknown>
|
|
6
|
-
|
|
7
|
-
export const loadConfig = async <T extends object>(params?: T): Promise<T> => {
|
|
8
|
-
if (config) {
|
|
9
|
-
return deepmerge(config, params ?? {}) as T
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const cosmicConfigResult = await cosmiconfig('xy', { cache: true }).search()
|
|
13
|
-
config = cosmicConfigResult?.config
|
|
14
|
-
const configFilePath = cosmicConfigResult?.filepath
|
|
15
|
-
if (configFilePath) {
|
|
16
|
-
console.log(chalk.gray(`Loading config from ${configFilePath}`))
|
|
17
|
-
}
|
|
18
|
-
return deepmerge(config, params ?? {}) as T
|
|
19
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs'
|
|
2
|
-
|
|
3
|
-
export const parsedPackageJSON = (path?: string) => {
|
|
4
|
-
const pathToPackageJSON = path ?? process.env.npm_package_json ?? ''
|
|
5
|
-
const packageJSON = readFileSync(pathToPackageJSON).toString()
|
|
6
|
-
return JSON.parse(packageJSON)
|
|
7
|
-
}
|
package/src/lib/processEx.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
|
|
3
|
-
import { withErrnoException } from './withErrnoException.ts'
|
|
4
|
-
import { withError } from './withError.ts'
|
|
5
|
-
|
|
6
|
-
export const processEx = (ex: unknown) => {
|
|
7
|
-
const error = typeof ex === 'string' ? new Error(ex) : ex
|
|
8
|
-
const exitCode
|
|
9
|
-
= withErrnoException(error, (error) => {
|
|
10
|
-
if (error.code === 'ENOENT') {
|
|
11
|
-
console.error(chalk.red(`'${error.path}' not found.`))
|
|
12
|
-
} else {
|
|
13
|
-
console.error(chalk.red(`Errno: ${error.code}`))
|
|
14
|
-
}
|
|
15
|
-
return error.errno ?? -1
|
|
16
|
-
})
|
|
17
|
-
?? withError(error, (error) => {
|
|
18
|
-
console.error(chalk.red(`${error.name}: ${error.message}`))
|
|
19
|
-
return -1
|
|
20
|
-
})
|
|
21
|
-
?? (() => {
|
|
22
|
-
console.error(chalk.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`))
|
|
23
|
-
return -1
|
|
24
|
-
})()
|
|
25
|
-
// This allows us to use a previously set exit code
|
|
26
|
-
process.exit(process.exitCode ?? exitCode)
|
|
27
|
-
}
|
package/src/lib/runSteps.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { SpawnSyncOptionsWithBufferEncoding } from 'node:child_process'
|
|
2
|
-
import { spawnSync } from 'node:child_process'
|
|
3
|
-
import { existsSync } from 'node:fs'
|
|
4
|
-
|
|
5
|
-
import chalk from 'chalk'
|
|
6
|
-
|
|
7
|
-
import { checkResult } from './checkResult.ts'
|
|
8
|
-
import { safeExit } from './safeExit.ts'
|
|
9
|
-
|
|
10
|
-
export type ScriptStep =
|
|
11
|
-
| [/* command */ 'yarn' | 'node' | 'ts-node-script' | 'tsc' | 'jest', /* arg */ string | string[]]
|
|
12
|
-
| [/* command */ string, /* arg */ string | string[], /* config */ SpawnSyncOptionsWithBufferEncoding]
|
|
13
|
-
|
|
14
|
-
export const runSteps = (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]): number => {
|
|
15
|
-
return safeExit(() => {
|
|
16
|
-
const pkgName = process.env.npm_package_name
|
|
17
|
-
console.log(chalk.green(`${name} [${pkgName}]`))
|
|
18
|
-
let totalStatus = 0
|
|
19
|
-
for (const [i, [command, args, config]] of steps.entries()) {
|
|
20
|
-
if (messages?.[i]) {
|
|
21
|
-
console.log(chalk.gray(messages?.[i]))
|
|
22
|
-
}
|
|
23
|
-
const argList = Array.isArray(args) ? args : args.split(' ')
|
|
24
|
-
if (command === 'node' && !existsSync(argList[0])) {
|
|
25
|
-
throw new Error(`File not found [${argList[0]}]`)
|
|
26
|
-
}
|
|
27
|
-
const status
|
|
28
|
-
= spawnSync(command, Array.isArray(args) ? args : args.split(' '), {
|
|
29
|
-
...config,
|
|
30
|
-
encoding: 'utf8',
|
|
31
|
-
env: { FORCE_COLOR: '3', ...process.env },
|
|
32
|
-
shell: true,
|
|
33
|
-
stdio: 'inherit',
|
|
34
|
-
}).status ?? 0
|
|
35
|
-
checkResult(name, status, 'error', exitOnFail)
|
|
36
|
-
totalStatus += status ?? 0
|
|
37
|
-
}
|
|
38
|
-
return totalStatus
|
|
39
|
-
}, !!exitOnFail)
|
|
40
|
-
}
|
package/src/lib/runStepsAsync.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process'
|
|
2
|
-
import { existsSync } from 'node:fs'
|
|
3
|
-
|
|
4
|
-
import chalk from 'chalk'
|
|
5
|
-
|
|
6
|
-
import { checkResult } from './checkResult.ts'
|
|
7
|
-
import type { ScriptStep } from './runSteps.ts'
|
|
8
|
-
import { safeExitAsync } from './safeExit.ts'
|
|
9
|
-
|
|
10
|
-
export const runStepAsync = (name: string, step: ScriptStep, exitOnFail = true, message?: string) => {
|
|
11
|
-
return new Promise<number>((resolve) => {
|
|
12
|
-
const [command, args, config] = step
|
|
13
|
-
if (message) {
|
|
14
|
-
console.log(chalk.gray(message))
|
|
15
|
-
}
|
|
16
|
-
const argList = Array.isArray(args) ? args : args.split(' ')
|
|
17
|
-
if (command === 'node' && !existsSync(argList[0])) {
|
|
18
|
-
throw new Error(`File not found [${argList[0]}]`)
|
|
19
|
-
}
|
|
20
|
-
spawn(command, Array.isArray(args) ? args : args.split(' '), {
|
|
21
|
-
...config,
|
|
22
|
-
env: { FORCE_COLOR: '3', ...process.env },
|
|
23
|
-
shell: true,
|
|
24
|
-
stdio: 'inherit',
|
|
25
|
-
}).on('close', (code) => {
|
|
26
|
-
if (code) {
|
|
27
|
-
console.error(
|
|
28
|
-
chalk.red(
|
|
29
|
-
`Command Exited With Non-Zero Result [${chalk.gray(code)}] | ${chalk.yellow(command)} ${chalk.white(
|
|
30
|
-
Array.isArray(args) ? args.join(' ') : args,
|
|
31
|
-
)}`,
|
|
32
|
-
),
|
|
33
|
-
)
|
|
34
|
-
checkResult(name, code, 'error', exitOnFail)
|
|
35
|
-
resolve(code)
|
|
36
|
-
} else {
|
|
37
|
-
resolve(0)
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const runStepsAsync = async (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]) => {
|
|
44
|
-
return await safeExitAsync(async () => {
|
|
45
|
-
const pkgName = process.env.npm_package_name
|
|
46
|
-
console.log(chalk.green(`${name} [${pkgName}]`))
|
|
47
|
-
let result = 0
|
|
48
|
-
for (const [i, step] of steps.entries()) {
|
|
49
|
-
result += await runStepAsync(name, step, exitOnFail, messages?.[i])
|
|
50
|
-
}
|
|
51
|
-
return result
|
|
52
|
-
})
|
|
53
|
-
}
|
package/src/lib/runXy.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
|
|
3
|
-
export const runXyWithWarning = (command: string) => {
|
|
4
|
-
const commandString = `yarn ${command}`
|
|
5
|
-
const commandXyString = `yarn xy ${command}`
|
|
6
|
-
console.warn(chalk.yellow(`WARNING: [${chalk.white(commandString)}] is deprecated for XY Labs Scripts.`))
|
|
7
|
-
console.warn(chalk.gray(`Did you mean [${chalk.magenta(commandXyString)}]?`))
|
|
8
|
-
return 1
|
|
9
|
-
}
|
package/src/lib/safeExit.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/** Catch child process a crash and returns the code */
|
|
2
|
-
|
|
3
|
-
import { processEx } from './processEx.ts'
|
|
4
|
-
|
|
5
|
-
const safeExit = (func: () => number, exitOnFail = true): number => {
|
|
6
|
-
try {
|
|
7
|
-
const result = func()
|
|
8
|
-
if (result && exitOnFail) {
|
|
9
|
-
process.exit(result)
|
|
10
|
-
}
|
|
11
|
-
return result
|
|
12
|
-
} catch (ex) {
|
|
13
|
-
return processEx(ex)
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const safeExitAsync = async (func: () => Promise<number>, exitOnFail = true): Promise<number> => {
|
|
18
|
-
try {
|
|
19
|
-
const result = await func()
|
|
20
|
-
if (result && exitOnFail) {
|
|
21
|
-
process.exit(result)
|
|
22
|
-
}
|
|
23
|
-
return result
|
|
24
|
-
} catch (ex) {
|
|
25
|
-
return processEx(ex)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { safeExit, safeExitAsync }
|
package/src/lib/string/empty.ts
DELETED
package/src/lib/string/index.ts
DELETED
package/src/lib/string/union.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const union = (a: string[], b: string[]): Set<string> => new Set([...new Set(a), ...new Set(b)])
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { withError } from './withError.ts'
|
|
2
|
-
|
|
3
|
-
export const withErrnoException = <T extends NodeJS.ErrnoException = NodeJS.ErrnoException>(
|
|
4
|
-
ex: unknown, closure: (error: T) => number,
|
|
5
|
-
) => {
|
|
6
|
-
return withError<T>(ex, closure, (ex: unknown) => (ex as NodeJS.ErrnoException).errno !== undefined)
|
|
7
|
-
}
|
package/src/lib/withError.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export const withError = <T extends Error = Error>(
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
|
-
ex: any,
|
|
4
|
-
closure: (error: T) => number,
|
|
5
|
-
predicate = (ex: T) => (!!ex.name && !!ex.message),
|
|
6
|
-
) => {
|
|
7
|
-
return predicate(ex as T) ? closure(ex as T) : undefined
|
|
8
|
-
}
|
package/src/lib/yarn/index.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process'
|
|
2
|
-
|
|
3
|
-
export const isYarnVersionOrGreater = (major: number, minor?: number, patch?: number): [boolean, string] => {
|
|
4
|
-
const result = spawnSync('yarn', ['-v'], { encoding: 'utf8', shell: true })
|
|
5
|
-
const version = result.stdout.toString().replaceAll('\n', '')
|
|
6
|
-
const versionNumbers = version.split('.').map(ver => Number.parseInt(ver))
|
|
7
|
-
const majorDelta = versionNumbers[0] - major
|
|
8
|
-
const minorDelta = versionNumbers[1] - (minor ?? versionNumbers[1])
|
|
9
|
-
const patchDelta = versionNumbers[2] - (patch ?? versionNumbers[2])
|
|
10
|
-
|
|
11
|
-
const majorOk = majorDelta >= 0
|
|
12
|
-
const minorOk = majorDelta > 0 || minorDelta >= 0
|
|
13
|
-
const patchOk = majorDelta > 0 || minorDelta > 0 || patchDelta >= 0
|
|
14
|
-
|
|
15
|
-
return [majorOk && minorOk && patchOk, version]
|
|
16
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Workspace } from './Workspace.ts'
|
|
2
|
-
import { yarnWorkspaces } from './yarnWorkspaces.ts'
|
|
3
|
-
|
|
4
|
-
export const yarnWorkspace = (pkg: string): Workspace => {
|
|
5
|
-
const workspace = yarnWorkspaces().find(({ name }) => name === pkg)
|
|
6
|
-
if (!workspace) throw new Error(`Workspace ${pkg} not found`)
|
|
7
|
-
return workspace
|
|
8
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process'
|
|
2
|
-
|
|
3
|
-
import type { Workspace } from './Workspace.ts'
|
|
4
|
-
|
|
5
|
-
export const yarnWorkspaces = (): Workspace[] => {
|
|
6
|
-
const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })
|
|
7
|
-
if (result.error) {
|
|
8
|
-
throw result.error
|
|
9
|
-
}
|
|
10
|
-
return (
|
|
11
|
-
result.stdout
|
|
12
|
-
.toString()
|
|
13
|
-
// NOTE: This probably doesn't work on Windows
|
|
14
|
-
// TODO: Replace /r/n with /n first
|
|
15
|
-
.split('\n')
|
|
16
|
-
.slice(0, -1)
|
|
17
|
-
.map((item) => {
|
|
18
|
-
return JSON.parse(item)
|
|
19
|
-
})
|
|
20
|
-
)
|
|
21
|
-
}
|
package/src/loadPackageConfig.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises'
|
|
2
|
-
|
|
3
|
-
import type { PackageJson } from 'types-package-json'
|
|
4
|
-
|
|
5
|
-
export type PackageJsonEx = PackageJson & { type: 'module' | 'commonjs' }
|
|
6
|
-
|
|
7
|
-
export const loadPackageConfig = async () => {
|
|
8
|
-
const pkg = process.env.INIT_CWD
|
|
9
|
-
|
|
10
|
-
const pkgConfig = await readFile(`${pkg}/package.json`, { encoding: 'utf8' })
|
|
11
|
-
|
|
12
|
-
return JSON.parse(pkgConfig) as PackageJsonEx
|
|
13
|
-
}
|
package/src/types.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
declare module 'rollup-plugin-exclude-dependencies-from-bundle'
|
|
2
|
-
declare module '@haensl/rollup-plugin-local-resolve'
|
|
3
|
-
declare module 'rollup-plugin-progress'
|
|
4
|
-
|
|
5
|
-
declare module 'eslint-plugin-import' {
|
|
6
|
-
const configs: Linter.Plugin
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare module 'eslint-plugin-workspaces' {
|
|
10
|
-
const configs: Linter.Plugin
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare module 'eslint-plugin-unicorn' {
|
|
14
|
-
const configs: {
|
|
15
|
-
'all': unknown
|
|
16
|
-
'flat/all': unknown
|
|
17
|
-
'flat/recommended': unknown
|
|
18
|
-
'recommended': unknown
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare module 'markdown-eslint-parser' {}
|
|
23
|
-
|
|
24
|
-
declare module 'eslint-plugin-md' {
|
|
25
|
-
const configs: Linter.Plugin
|
|
26
|
-
}
|
package/src/xy/index.ts
DELETED
package/src/xy/param.ts
DELETED
package/src/xy/xy.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
|
|
3
|
-
import { xyBuildCommands } from './xyBuildCommands.ts'
|
|
4
|
-
import { xyCommonCommands } from './xyCommonCommands.ts'
|
|
5
|
-
import { xyDeployCommands } from './xyDeployCommands.ts'
|
|
6
|
-
import { xyInstallCommands } from './xyInstallCommands.ts'
|
|
7
|
-
import { xyLintCommands } from './xyLintCommands.ts'
|
|
8
|
-
import { xyParseOptions } from './xyParseOptions.ts'
|
|
9
|
-
|
|
10
|
-
export const xy = async () => {
|
|
11
|
-
const options = xyParseOptions()
|
|
12
|
-
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options)))))
|
|
13
|
-
.demandCommand(1)
|
|
14
|
-
.command('*', '', () => {
|
|
15
|
-
console.error(chalk.yellow(`Command not found [${chalk.magenta(process.argv[2])}]`))
|
|
16
|
-
console.log(chalk.gray('Try \'yarn xy --help\' for list of commands'))
|
|
17
|
-
})
|
|
18
|
-
.version()
|
|
19
|
-
.help().argv
|
|
20
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import type { Argv } from 'yargs'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
build, compile, compileTypes, copyAssets, rebuild, recompile,
|
|
5
|
-
} from '../actions/index.ts'
|
|
6
|
-
|
|
7
|
-
export const xyBuildCommands = (args: Argv) => {
|
|
8
|
-
return args
|
|
9
|
-
.command(
|
|
10
|
-
'build [package]',
|
|
11
|
-
'Build - Compile & Lint',
|
|
12
|
-
(yargs) => {
|
|
13
|
-
return yargs.positional('package', { describe: 'Specific package to build' })
|
|
14
|
-
},
|
|
15
|
-
async (argv) => {
|
|
16
|
-
if (argv.verbose) {
|
|
17
|
-
console.log(`Building: ${argv.package ?? 'all'}`)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
process.exitCode = await build({
|
|
21
|
-
incremental: !!argv.incremental,
|
|
22
|
-
jobs: argv.jobs as number,
|
|
23
|
-
pkg: argv.package as string,
|
|
24
|
-
target: argv.target as 'esm' | 'cjs',
|
|
25
|
-
verbose: !!argv.verbose,
|
|
26
|
-
})
|
|
27
|
-
},
|
|
28
|
-
)
|
|
29
|
-
.command(
|
|
30
|
-
'compile [package]',
|
|
31
|
-
'Compile with Typescript & Copy Images',
|
|
32
|
-
(yargs) => {
|
|
33
|
-
return yargs.positional('package', { describe: 'Specific package to compile' })
|
|
34
|
-
},
|
|
35
|
-
(argv) => {
|
|
36
|
-
if (argv.verbose) {
|
|
37
|
-
console.log(`Compiling: ${argv.package ?? 'all'}`)
|
|
38
|
-
}
|
|
39
|
-
process.exitCode = compile({
|
|
40
|
-
incremental: !!argv.incremental,
|
|
41
|
-
jobs: argv.jobs as number,
|
|
42
|
-
pkg: argv.package as string,
|
|
43
|
-
target: argv.target as 'esm' | 'cjs',
|
|
44
|
-
verbose: !!argv.verbose,
|
|
45
|
-
})
|
|
46
|
-
},
|
|
47
|
-
)
|
|
48
|
-
.command(
|
|
49
|
-
'compile-types [package]',
|
|
50
|
-
'Compile types with Typescript',
|
|
51
|
-
(yargs) => {
|
|
52
|
-
return yargs.positional('package', { describe: 'Specific package to compile' })
|
|
53
|
-
},
|
|
54
|
-
(argv) => {
|
|
55
|
-
if (argv.verbose) {
|
|
56
|
-
console.log(`Compiling: ${argv.package ?? 'all'}`)
|
|
57
|
-
}
|
|
58
|
-
process.exitCode = compileTypes({
|
|
59
|
-
incremental: !!argv.incremental,
|
|
60
|
-
jobs: argv.jobs as number,
|
|
61
|
-
pkg: argv.package as string,
|
|
62
|
-
verbose: !!argv.verbose,
|
|
63
|
-
})
|
|
64
|
-
},
|
|
65
|
-
)
|
|
66
|
-
.command(
|
|
67
|
-
'compile-only [package]',
|
|
68
|
-
'Compile with Typescript & Copy Images (No Publint)',
|
|
69
|
-
(yargs) => {
|
|
70
|
-
return yargs.positional('package', { describe: 'Specific package to compile' })
|
|
71
|
-
},
|
|
72
|
-
(argv) => {
|
|
73
|
-
if (argv.verbose) {
|
|
74
|
-
console.log(`Compiling: ${argv.package ?? 'all'}`)
|
|
75
|
-
}
|
|
76
|
-
process.exitCode = compile({
|
|
77
|
-
incremental: !!argv.incremental,
|
|
78
|
-
jobs: argv.jobs as number,
|
|
79
|
-
pkg: argv.package as string,
|
|
80
|
-
publint: false,
|
|
81
|
-
target: argv.target as 'esm' | 'cjs',
|
|
82
|
-
verbose: !!argv.verbose,
|
|
83
|
-
})
|
|
84
|
-
},
|
|
85
|
-
)
|
|
86
|
-
.command(
|
|
87
|
-
'recompile [package]',
|
|
88
|
-
'Re-compile with Typescript & Copy Images',
|
|
89
|
-
(yargs) => {
|
|
90
|
-
return yargs.positional('package', { describe: 'Specific package to re-compile' })
|
|
91
|
-
},
|
|
92
|
-
async (argv) => {
|
|
93
|
-
if (argv.verbose) {
|
|
94
|
-
console.log(`Re-compiling: ${argv.package ?? 'all'}`)
|
|
95
|
-
}
|
|
96
|
-
process.exitCode = await recompile({
|
|
97
|
-
incremental: !!argv.incremental,
|
|
98
|
-
jobs: argv.jobs as number,
|
|
99
|
-
pkg: argv.package as string,
|
|
100
|
-
target: argv.target as 'esm' | 'cjs',
|
|
101
|
-
verbose: !!argv.verbose,
|
|
102
|
-
})
|
|
103
|
-
},
|
|
104
|
-
)
|
|
105
|
-
.command(
|
|
106
|
-
'rebuild [package]',
|
|
107
|
-
'Rebuild - Clean, Compile & Lint',
|
|
108
|
-
(yargs) => {
|
|
109
|
-
return yargs.positional('package', { describe: 'Specific package to rebuild' })
|
|
110
|
-
},
|
|
111
|
-
(argv) => {
|
|
112
|
-
if (argv.verbose) console.log(`Rebuilding: ${argv.package ?? 'all'}`)
|
|
113
|
-
process.exitCode = rebuild({ target: argv.target as 'esm' | 'cjs' })
|
|
114
|
-
},
|
|
115
|
-
)
|
|
116
|
-
.command(
|
|
117
|
-
'copy-assets [package]',
|
|
118
|
-
'Copy Assets - Copy the assets from src to dist',
|
|
119
|
-
(yargs) => {
|
|
120
|
-
return yargs.positional('package', { describe: 'Specific package to copy assets' })
|
|
121
|
-
},
|
|
122
|
-
async (argv) => {
|
|
123
|
-
if (argv.verbose) console.log(`Copying Assets: ${argv.package ?? 'all'}`)
|
|
124
|
-
process.exitCode = await copyAssets({ target: argv.target as 'esm' | 'cjs' })
|
|
125
|
-
},
|
|
126
|
-
)
|
|
127
|
-
}
|