@xylabs/ts-scripts-yarn3 6.3.4 → 6.4.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 +39 -87
- package/dist/actions/build.mjs.map +1 -1
- package/dist/actions/clean-docs.mjs +8 -22
- package/dist/actions/clean-docs.mjs.map +1 -1
- package/dist/actions/clean-eslint.mjs +5 -11
- package/dist/actions/clean-eslint.mjs.map +1 -1
- package/dist/actions/clean-jest.mjs +16 -29
- package/dist/actions/clean-jest.mjs.map +1 -1
- package/dist/actions/clean.mjs +32 -63
- package/dist/actions/clean.mjs.map +1 -1
- package/dist/actions/compile-types.mjs +45 -68
- package/dist/actions/compile-types.mjs.map +1 -1
- package/dist/actions/compile.mjs +50 -76
- package/dist/actions/compile.mjs.map +1 -1
- package/dist/actions/copy-assets.mjs +23 -38
- package/dist/actions/copy-assets.mjs.map +1 -1
- package/dist/actions/cycle.mjs +28 -57
- package/dist/actions/cycle.mjs.map +1 -1
- package/dist/actions/dead.mjs +16 -31
- package/dist/actions/dead.mjs.map +1 -1
- package/dist/actions/deplint.mjs +191 -0
- package/dist/actions/deplint.mjs.map +1 -0
- package/dist/actions/deploy-major.mjs +20 -41
- package/dist/actions/deploy-major.mjs.map +1 -1
- package/dist/actions/deploy-minor.mjs +20 -41
- package/dist/actions/deploy-minor.mjs.map +1 -1
- package/dist/actions/deploy-next.mjs +20 -41
- package/dist/actions/deploy-next.mjs.map +1 -1
- package/dist/actions/deploy.mjs +20 -41
- package/dist/actions/deploy.mjs.map +1 -1
- package/dist/actions/dupdeps.mjs +26 -37
- package/dist/actions/dupdeps.mjs.map +1 -1
- package/dist/actions/fix.mjs +36 -50
- package/dist/actions/fix.mjs.map +1 -1
- package/dist/actions/gen-docs.mjs +25 -65
- package/dist/actions/gen-docs.mjs.map +1 -1
- package/dist/actions/gitignore-gen.mjs +28 -44
- package/dist/actions/gitignore-gen.mjs.map +1 -1
- package/dist/actions/gitlint-fix.mjs +5 -14
- package/dist/actions/gitlint-fix.mjs.map +1 -1
- package/dist/actions/gitlint.mjs +4 -7
- package/dist/actions/gitlint.mjs.map +1 -1
- package/dist/actions/index.mjs +860 -1237
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/knip.mjs +16 -31
- package/dist/actions/knip.mjs.map +1 -1
- package/dist/actions/license.mjs +37 -51
- package/dist/actions/license.mjs.map +1 -1
- package/dist/actions/lint.mjs +33 -44
- package/dist/actions/lint.mjs.map +1 -1
- package/dist/actions/npmignore-gen.mjs +28 -44
- package/dist/actions/npmignore-gen.mjs.map +1 -1
- package/dist/actions/package/clean-outputs.mjs +6 -16
- package/dist/actions/package/clean-outputs.mjs.map +1 -1
- package/dist/actions/package/clean-typescript.mjs +6 -16
- package/dist/actions/package/clean-typescript.mjs.map +1 -1
- package/dist/actions/package/clean.mjs +12 -29
- package/dist/actions/package/clean.mjs.map +1 -1
- package/dist/actions/package/compile/buildEntries.mjs +7 -17
- package/dist/actions/package/compile/buildEntries.mjs.map +1 -1
- package/dist/actions/package/compile/compile.mjs +133 -169
- package/dist/actions/package/compile/compile.mjs.map +1 -1
- package/dist/actions/package/compile/compileTypes.mjs +43 -59
- package/dist/actions/package/compile/compileTypes.mjs.map +1 -1
- package/dist/actions/package/compile/copyTypeFiles.mjs +20 -23
- package/dist/actions/package/compile/copyTypeFiles.mjs.map +1 -1
- package/dist/actions/package/compile/deepMerge.mjs +0 -5
- package/dist/actions/package/compile/deepMerge.mjs.map +1 -1
- package/dist/actions/package/compile/getCompilerOptions.mjs +11 -10
- package/dist/actions/package/compile/getCompilerOptions.mjs.map +1 -1
- package/dist/actions/package/compile/index.mjs +133 -169
- package/dist/actions/package/compile/index.mjs.map +1 -1
- package/dist/actions/package/compile/inputs.mjs +3 -8
- package/dist/actions/package/compile/inputs.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsc.mjs +37 -52
- package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTscTypes.mjs +37 -52
- package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsup.mjs +127 -163
- package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
- package/dist/actions/package/copy-assets.mjs +12 -21
- package/dist/actions/package/copy-assets.mjs.map +1 -1
- package/dist/actions/package/cycle.mjs +5 -14
- package/dist/actions/package/cycle.mjs.map +1 -1
- package/dist/actions/package/gen-docs.mjs +11 -12
- package/dist/actions/package/gen-docs.mjs.map +1 -1
- package/dist/actions/package/index.mjs +191 -271
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/lint.mjs +16 -39
- package/dist/actions/package/lint.mjs.map +1 -1
- package/dist/actions/package/publint.mjs +4 -7
- package/dist/actions/package/publint.mjs.map +1 -1
- package/dist/actions/package/recompile.mjs +147 -197
- package/dist/actions/package/recompile.mjs.map +1 -1
- package/dist/actions/publint.mjs +37 -71
- package/dist/actions/publint.mjs.map +1 -1
- package/dist/actions/rebuild.mjs +17 -29
- package/dist/actions/rebuild.mjs.map +1 -1
- package/dist/actions/recompile.mjs +50 -67
- package/dist/actions/recompile.mjs.map +1 -1
- package/dist/actions/reinstall.mjs +25 -43
- package/dist/actions/reinstall.mjs.map +1 -1
- package/dist/actions/relint.mjs +40 -63
- package/dist/actions/relint.mjs.map +1 -1
- package/dist/actions/retest.mjs +17 -35
- package/dist/actions/retest.mjs.map +1 -1
- package/dist/actions/sonar.mjs +16 -32
- package/dist/actions/sonar.mjs.map +1 -1
- package/dist/actions/statics.mjs +27 -46
- package/dist/actions/statics.mjs.map +1 -1
- package/dist/actions/test.mjs +16 -30
- package/dist/actions/test.mjs.map +1 -1
- package/dist/actions/up.mjs +16 -27
- package/dist/actions/up.mjs.map +1 -1
- package/dist/actions/updo.mjs +18 -33
- package/dist/actions/updo.mjs.map +1 -1
- package/dist/actions/upplug.mjs +19 -53
- package/dist/actions/upplug.mjs.map +1 -1
- package/dist/actions/upyarn.mjs +16 -31
- package/dist/actions/upyarn.mjs.map +1 -1
- package/dist/actions/yarn3only.mjs +12 -23
- package/dist/actions/yarn3only.mjs.map +1 -1
- package/dist/bin/package/build-only.mjs +134 -172
- package/dist/bin/package/build-only.mjs.map +1 -1
- package/dist/bin/package/build.mjs +134 -172
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/clean-outputs.mjs +6 -15
- package/dist/bin/package/clean-outputs.mjs.map +1 -1
- package/dist/bin/package/clean-typescript.mjs +6 -15
- package/dist/bin/package/clean-typescript.mjs.map +1 -1
- package/dist/bin/package/clean.mjs +12 -28
- package/dist/bin/package/clean.mjs.map +1 -1
- package/dist/bin/package/compile-only.mjs +134 -172
- package/dist/bin/package/compile-only.mjs.map +1 -1
- package/dist/bin/package/compile-tsup.mjs +128 -165
- package/dist/bin/package/compile-tsup.mjs.map +1 -1
- package/dist/bin/package/compile-types.mjs +44 -61
- package/dist/bin/package/compile-types.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +134 -171
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/copy-assets-cjs.mjs +13 -23
- package/dist/bin/package/copy-assets-cjs.mjs.map +1 -1
- package/dist/bin/package/copy-assets-esm.mjs +13 -23
- package/dist/bin/package/copy-assets-esm.mjs.map +1 -1
- package/dist/bin/package/cycle.mjs +6 -16
- package/dist/bin/package/cycle.mjs.map +1 -1
- package/dist/bin/package/fix.mjs +16 -38
- package/dist/bin/package/fix.mjs.map +1 -1
- package/dist/bin/package/gen-docs.mjs +11 -11
- package/dist/bin/package/gen-docs.mjs.map +1 -1
- package/dist/bin/package/lint.mjs +16 -38
- package/dist/bin/package/lint.mjs.map +1 -1
- package/dist/bin/package/publint.mjs +4 -6
- package/dist/bin/package/publint.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +147 -196
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/package/relint.mjs +16 -38
- package/dist/bin/package/relint.mjs.map +1 -1
- package/dist/bin/xy.mjs +1082 -1233
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +1334 -1579
- package/dist/index.mjs.map +1 -1
- package/dist/lib/checkResult.mjs +2 -5
- package/dist/lib/checkResult.mjs.map +1 -1
- package/dist/lib/createBuildConfig.mjs +9 -24
- package/dist/lib/createBuildConfig.mjs.map +1 -1
- package/dist/lib/defaultBuildConfig.mjs +2 -6
- package/dist/lib/defaultBuildConfig.mjs.map +1 -1
- package/dist/lib/deleteGlob.mjs +3 -9
- package/dist/lib/deleteGlob.mjs.map +1 -1
- package/dist/lib/dependencies/DuplicateDetector.mjs +12 -23
- package/dist/lib/dependencies/DuplicateDetector.mjs.map +1 -1
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs +22 -33
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +1 -1
- package/dist/lib/dependencies/index.mjs +22 -33
- package/dist/lib/dependencies/index.mjs.map +1 -1
- package/dist/lib/file/ReadFileSyncOptions.mjs +1 -3
- package/dist/lib/file/ReadFileSyncOptions.mjs.map +1 -1
- package/dist/lib/file/constants.mjs.map +1 -1
- package/dist/lib/file/fileLines.mjs +12 -13
- package/dist/lib/file/fileLines.mjs.map +1 -1
- package/dist/lib/file/index.mjs +14 -15
- package/dist/lib/file/index.mjs.map +1 -1
- package/dist/lib/file/tryReadFileSync.mjs +3 -8
- package/dist/lib/file/tryReadFileSync.mjs.map +1 -1
- package/dist/lib/generateIgnoreFiles.mjs +27 -43
- package/dist/lib/generateIgnoreFiles.mjs.map +1 -1
- package/dist/lib/index.mjs +100 -154
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/jsonFormatters.mjs +2 -5
- package/dist/lib/jsonFormatters.mjs.map +1 -1
- package/dist/lib/loadConfig.mjs +4 -8
- package/dist/lib/loadConfig.mjs.map +1 -1
- package/dist/lib/parsedPackageJSON.mjs +2 -5
- package/dist/lib/parsedPackageJSON.mjs.map +1 -1
- package/dist/lib/processEx.mjs +6 -9
- package/dist/lib/processEx.mjs.map +1 -1
- package/dist/lib/runSteps.mjs +13 -19
- package/dist/lib/runSteps.mjs.map +1 -1
- package/dist/lib/runStepsAsync.mjs +22 -22
- package/dist/lib/runStepsAsync.mjs.map +1 -1
- package/dist/lib/runXy.mjs +19 -31
- package/dist/lib/runXy.mjs.map +1 -1
- package/dist/lib/runXyWithWarning.mjs +2 -5
- package/dist/lib/runXyWithWarning.mjs.map +1 -1
- package/dist/lib/safeExit.mjs +10 -13
- package/dist/lib/safeExit.mjs.map +1 -1
- package/dist/lib/string/empty.mjs +2 -5
- package/dist/lib/string/empty.mjs.map +1 -1
- package/dist/lib/string/index.mjs +3 -9
- package/dist/lib/string/index.mjs.map +1 -1
- package/dist/lib/string/union.mjs +1 -7
- package/dist/lib/string/union.mjs.map +1 -1
- package/dist/lib/withErrnoException.mjs +4 -7
- package/dist/lib/withErrnoException.mjs.map +1 -1
- package/dist/lib/withError.mjs +2 -5
- package/dist/lib/withError.mjs.map +1 -1
- package/dist/lib/yarn/index.mjs +11 -30
- package/dist/lib/yarn/index.mjs.map +1 -1
- package/dist/lib/yarn/isYarnVersionOrGreater.mjs +4 -15
- package/dist/lib/yarn/isYarnVersionOrGreater.mjs.map +1 -1
- package/dist/lib/yarn/workspace/index.mjs +5 -16
- package/dist/lib/yarn/workspace/index.mjs.map +1 -1
- package/dist/lib/yarn/workspace/yarnWorkspace.mjs +5 -16
- package/dist/lib/yarn/workspace/yarnWorkspace.mjs.map +1 -1
- package/dist/lib/yarn/workspace/yarnWorkspaces.mjs +3 -14
- package/dist/lib/yarn/workspace/yarnWorkspaces.mjs.map +1 -1
- package/dist/lib/yarn/yarnInitCwd.mjs +2 -5
- package/dist/lib/yarn/yarnInitCwd.mjs.map +1 -1
- package/dist/loadPackageConfig.mjs +3 -8
- package/dist/loadPackageConfig.mjs.map +1 -1
- package/dist/xy/index.mjs +1082 -1234
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/param.mjs +3 -8
- package/dist/xy/param.mjs.map +1 -1
- package/dist/xy/xy.mjs +1082 -1234
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyBuildCommands.mjs +276 -382
- package/dist/xy/xyBuildCommands.mjs.map +1 -1
- package/dist/xy/xyCommonCommands.mjs +251 -335
- package/dist/xy/xyCommonCommands.mjs.map +1 -1
- package/dist/xy/xyDeployCommands.mjs +84 -130
- package/dist/xy/xyDeployCommands.mjs.map +1 -1
- package/dist/xy/xyInstallCommands.mjs +145 -193
- package/dist/xy/xyInstallCommands.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +409 -288
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/dist/xy/xyParseOptions.mjs +4 -13
- package/dist/xy/xyParseOptions.mjs.map +1 -1
- package/package.json +5 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/runSteps.ts","../../src/actions/gen-docs.ts"],"sourcesContent":["import chalk from 'chalk'\n\nexport const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {\n if (result) {\n const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'\n const chalkFunc = level === 'error' ? chalk.red : chalk.yellow\n console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))\n if (exitOnFail) {\n process.exit(result)\n }\n }\n}\n","import chalk from 'chalk'\n\nimport { withErrnoException } from './withErrnoException.ts'\nimport { withError } from './withError.ts'\n\nexport const processEx = (ex: unknown) => {\n const error = typeof ex === 'string' ? new Error(ex) : ex\n const exitCode\n = withErrnoException(error, (error) => {\n if (error.code === 'ENOENT') {\n console.error(chalk.red(`'${error.path}' not found.`))\n } else {\n console.error(chalk.red(`Errno: ${error.code}`))\n }\n return error.errno ?? -1\n })\n ?? withError(error, (error) => {\n console.error(chalk.red(`${error.name}: ${error.message}`))\n return -1\n })\n ?? (() => {\n console.error(chalk.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`))\n return -1\n })()\n // This allows us to use a previously set exit code\n process.exit(process.exitCode ?? exitCode)\n}\n","export const withError = <T extends Error = Error>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ex: any,\n closure: (error: T) => number,\n predicate = (ex: T) => (!!ex.name && !!ex.message),\n) => {\n return predicate(ex as T) ? closure(ex as T) : undefined\n}\n","import { withError } from './withError.ts'\n\nexport const withErrnoException = <T extends NodeJS.ErrnoException = NodeJS.ErrnoException>(\n ex: unknown, closure: (error: T) => number,\n) => {\n return withError<T>(ex, closure, (ex: unknown) => (ex as NodeJS.ErrnoException).errno !== undefined)\n}\n","/** Catch child process a crash and returns the code */\n\nimport { processEx } from './processEx.ts'\n\nconst safeExit = (func: () => number, exitOnFail = true): number => {\n try {\n const result = func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nconst safeExitAsync = async (func: () => Promise<number>, exitOnFail = true): Promise<number> => {\n try {\n const result = await func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nexport { safeExit, safeExitAsync }\n","import type { SpawnSyncOptionsWithBufferEncoding } from 'node:child_process'\nimport { spawnSync } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport { safeExit } from './safeExit.ts'\n\nexport type ScriptStep =\n | [/* command */ 'yarn' | 'node' | 'ts-node-script' | 'tsc' | 'jest', /* arg */ string | string[]]\n | [/* command */ string, /* arg */ string | string[], /* config */ SpawnSyncOptionsWithBufferEncoding]\n\nexport const runSteps = (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]): number => {\n return safeExit(() => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let totalStatus = 0\n for (const [i, [command, args, config]] of steps.entries()) {\n if (messages?.[i]) {\n console.log(chalk.gray(messages?.[i]))\n }\n const argList = Array.isArray(args) ? args : args.split(' ')\n if (command === 'node' && !existsSync(argList[0])) {\n throw new Error(`File not found [${argList[0]}]`)\n }\n const status\n = spawnSync(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n encoding: 'utf8',\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).status ?? 0\n checkResult(name, status, 'error', exitOnFail)\n totalStatus += status ?? 0\n }\n return totalStatus\n }, !!exitOnFail)\n}\n","import type { ScriptStep } from '../lib/index.ts'\nimport { runSteps } from '../lib/index.ts'\n\nexport interface GenDocsParams {\n incremental?: boolean\n pkg?: string\n}\n\nexport interface GenDocsPackageParams { pkg: string }\n\nexport const genDocs = ({ pkg, incremental }: GenDocsParams) => {\n return pkg ? genDocsPackage({ pkg }) : genDocsAll({ incremental })\n}\n\nexport const genDocsPackage = ({ pkg }: GenDocsPackageParams) => {\n const steps: ScriptStep[] = [['yarn', ['workspace', pkg, 'run', 'package-gen-docs']]]\n\n return runSteps(`GenDocs [${pkg}]`, [...steps])\n}\n\nexport const genDocsAll = ({ incremental }: GenDocsParams) => {\n const incrementalOptions = incremental ? ['--since', '-pA'] : ['-pA']\n const steps: ScriptStep[] = [['yarn', ['workspaces', 'foreach', ...incrementalOptions, 'run', 'package-gen-docs']]]\n\n return runSteps(`GenDocs [All${incremental ? '-Incremental' : ''}]`, [...steps])\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/runSteps.ts","../../src/actions/gen-docs.ts"],"sourcesContent":["import chalk from 'chalk'\n\nexport const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {\n if (result) {\n const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'\n const chalkFunc = level === 'error' ? chalk.red : chalk.yellow\n console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))\n if (exitOnFail) {\n process.exit(result)\n }\n }\n}\n","import chalk from 'chalk'\n\nimport { withErrnoException } from './withErrnoException.ts'\nimport { withError } from './withError.ts'\n\nexport const processEx = (ex: unknown) => {\n const error = typeof ex === 'string' ? new Error(ex) : ex\n const exitCode\n = withErrnoException(error, (error) => {\n if (error.code === 'ENOENT') {\n console.error(chalk.red(`'${error.path}' not found.`))\n } else {\n console.error(chalk.red(`Errno: ${error.code}`))\n }\n return error.errno ?? -1\n })\n ?? withError(error, (error) => {\n console.error(chalk.red(`${error.name}: ${error.message}`))\n return -1\n })\n ?? (() => {\n console.error(chalk.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`))\n return -1\n })()\n // This allows us to use a previously set exit code\n process.exit(process.exitCode ?? exitCode)\n}\n","export const withError = <T extends Error = Error>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ex: any,\n closure: (error: T) => number,\n predicate = (ex: T) => (!!ex.name && !!ex.message),\n) => {\n return predicate(ex as T) ? closure(ex as T) : undefined\n}\n","import { withError } from './withError.ts'\n\nexport const withErrnoException = <T extends NodeJS.ErrnoException = NodeJS.ErrnoException>(\n ex: unknown, closure: (error: T) => number,\n) => {\n return withError<T>(ex, closure, (ex: unknown) => (ex as NodeJS.ErrnoException).errno !== undefined)\n}\n","/** Catch child process a crash and returns the code */\n\nimport { processEx } from './processEx.ts'\n\nconst safeExit = (func: () => number, exitOnFail = true): number => {\n try {\n const result = func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nconst safeExitAsync = async (func: () => Promise<number>, exitOnFail = true): Promise<number> => {\n try {\n const result = await func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nexport { safeExit, safeExitAsync }\n","import type { SpawnSyncOptionsWithBufferEncoding } from 'node:child_process'\nimport { spawnSync } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport { safeExit } from './safeExit.ts'\n\nexport type ScriptStep =\n | [/* command */ 'yarn' | 'node' | 'ts-node-script' | 'tsc' | 'jest', /* arg */ string | string[]]\n | [/* command */ string, /* arg */ string | string[], /* config */ SpawnSyncOptionsWithBufferEncoding]\n\nexport const runSteps = (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]): number => {\n return safeExit(() => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let totalStatus = 0\n for (const [i, [command, args, config]] of steps.entries()) {\n if (messages?.[i]) {\n console.log(chalk.gray(messages?.[i]))\n }\n const argList = Array.isArray(args) ? args : args.split(' ')\n if (command === 'node' && !existsSync(argList[0])) {\n throw new Error(`File not found [${argList[0]}]`)\n }\n const status\n = spawnSync(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n encoding: 'utf8',\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).status ?? 0\n checkResult(name, status, 'error', exitOnFail)\n totalStatus += status ?? 0\n }\n return totalStatus\n }, !!exitOnFail)\n}\n","import type { ScriptStep } from '../lib/index.ts'\nimport { runSteps } from '../lib/index.ts'\n\nexport interface GenDocsParams {\n incremental?: boolean\n pkg?: string\n}\n\nexport interface GenDocsPackageParams { pkg: string }\n\nexport const genDocs = ({ pkg, incremental }: GenDocsParams) => {\n return pkg ? genDocsPackage({ pkg }) : genDocsAll({ incremental })\n}\n\nexport const genDocsPackage = ({ pkg }: GenDocsPackageParams) => {\n const steps: ScriptStep[] = [['yarn', ['workspace', pkg, 'run', 'package-gen-docs']]]\n\n return runSteps(`GenDocs [${pkg}]`, [...steps])\n}\n\nexport const genDocsAll = ({ incremental }: GenDocsParams) => {\n const incrementalOptions = incremental ? ['--since', '-pA'] : ['-pA']\n const steps: ScriptStep[] = [['yarn', ['workspaces', 'foreach', ...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,OAAO;AAAA,MACT,CAAC,EAAE,UAAU;AACf,kBAAY,MAAM,QAAQ,SAAS,UAAU;AAC7C,qBAAe,UAAU;AAAA,IAC3B;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAC,UAAU;AACjB;;;AC7BO,IAAM,UAAU,CAAC,EAAE,KAAK,YAAY,MAAqB;AAC9D,SAAO,MAAM,eAAe,EAAE,IAAI,CAAC,IAAI,WAAW,EAAE,YAAY,CAAC;AACnE;AAEO,IAAM,iBAAiB,CAAC,EAAE,IAAI,MAA4B;AAC/D,QAAM,QAAsB,CAAC,CAAC,QAAQ,CAAC,aAAa,KAAK,OAAO,kBAAkB,CAAC,CAAC;AAEpF,SAAO,SAAS,YAAY,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;AAChD;AAEO,IAAM,aAAa,CAAC,EAAE,YAAY,MAAqB;AAC5D,QAAM,qBAAqB,cAAc,CAAC,WAAW,KAAK,IAAI,CAAC,KAAK;AACpE,QAAM,QAAsB,CAAC,CAAC,QAAQ,CAAC,cAAc,WAAW,GAAG,oBAAoB,OAAO,kBAAkB,CAAC,CAAC;AAElH,SAAO,SAAS,eAAe,cAAc,iBAAiB,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC;AACjF;","names":["chalk","ex","ex","error","chalk","chalk","chalk"]}
|
|
@@ -1,86 +1,70 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/lib/file/constants.ts
|
|
5
2
|
var WINDOWS_NEWLINE_REGEX = /\r\n/g;
|
|
6
3
|
var CROSS_PLATFORM_NEWLINE = "\n";
|
|
7
4
|
|
|
8
5
|
// src/lib/file/fileLines.ts
|
|
9
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
existsSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
writeFileSync
|
|
10
|
+
} from "node:fs";
|
|
10
11
|
|
|
11
12
|
// src/lib/string/empty.ts
|
|
12
|
-
var empty =
|
|
13
|
-
var notEmpty =
|
|
13
|
+
var empty = (value) => value?.trim().length === 0;
|
|
14
|
+
var notEmpty = (value) => !empty(value);
|
|
14
15
|
|
|
15
16
|
// src/lib/string/union.ts
|
|
16
|
-
var union =
|
|
17
|
-
...new Set(a),
|
|
18
|
-
...new Set(b)
|
|
19
|
-
]), "union");
|
|
17
|
+
var union = (a, b) => /* @__PURE__ */ new Set([...new Set(a), ...new Set(b)]);
|
|
20
18
|
|
|
21
19
|
// src/lib/file/ReadFileSyncOptions.ts
|
|
22
|
-
var defaultReadFileSyncOptions = {
|
|
23
|
-
encoding: "utf8"
|
|
24
|
-
};
|
|
20
|
+
var defaultReadFileSyncOptions = { encoding: "utf8" };
|
|
25
21
|
|
|
26
22
|
// src/lib/file/fileLines.ts
|
|
27
|
-
var readLines =
|
|
28
|
-
var readNonEmptyLines =
|
|
29
|
-
var writeLines =
|
|
23
|
+
var readLines = (uri, options = defaultReadFileSyncOptions) => existsSync(uri) ? readFileSync(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE) : [];
|
|
24
|
+
var readNonEmptyLines = (uri, options = defaultReadFileSyncOptions) => readLines(uri, options).filter(notEmpty);
|
|
25
|
+
var writeLines = (uri, lines, options = defaultReadFileSyncOptions) => {
|
|
30
26
|
const existing = existsSync(uri) ? readFileSync(uri, options) : void 0;
|
|
31
27
|
const desired = lines.join(CROSS_PLATFORM_NEWLINE);
|
|
32
28
|
if (existing !== desired) writeFileSync(uri, desired, options);
|
|
33
|
-
}
|
|
29
|
+
};
|
|
34
30
|
|
|
35
31
|
// src/lib/generateIgnoreFiles.ts
|
|
36
32
|
import chalk from "chalk";
|
|
37
33
|
|
|
38
34
|
// src/lib/yarn/workspace/yarnWorkspaces.ts
|
|
39
35
|
import { spawnSync } from "node:child_process";
|
|
40
|
-
var yarnWorkspaces =
|
|
41
|
-
const result = spawnSync("yarn", [
|
|
42
|
-
"workspaces",
|
|
43
|
-
"list",
|
|
44
|
-
"--json",
|
|
45
|
-
"--recursive"
|
|
46
|
-
], {
|
|
47
|
-
encoding: "utf8",
|
|
48
|
-
shell: true
|
|
49
|
-
});
|
|
36
|
+
var yarnWorkspaces = () => {
|
|
37
|
+
const result = spawnSync("yarn", ["workspaces", "list", "--json", "--recursive"], { encoding: "utf8", shell: true });
|
|
50
38
|
if (result.error) {
|
|
51
39
|
throw result.error;
|
|
52
40
|
}
|
|
53
41
|
return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
|
|
54
42
|
return JSON.parse(item);
|
|
55
43
|
});
|
|
56
|
-
}
|
|
44
|
+
};
|
|
57
45
|
|
|
58
46
|
// src/lib/yarn/workspace/yarnWorkspace.ts
|
|
59
|
-
var yarnWorkspace =
|
|
47
|
+
var yarnWorkspace = (pkg) => {
|
|
60
48
|
const workspace = yarnWorkspaces().find(({ name }) => name === pkg);
|
|
61
49
|
if (!workspace) throw new Error(`Workspace ${pkg} not found`);
|
|
62
50
|
return workspace;
|
|
63
|
-
}
|
|
51
|
+
};
|
|
64
52
|
|
|
65
53
|
// src/lib/yarn/yarnInitCwd.ts
|
|
66
|
-
var INIT_CWD =
|
|
54
|
+
var INIT_CWD = () => {
|
|
67
55
|
if (!process.env.INIT_CWD) console.error("Missing INIT_CWD");
|
|
68
56
|
return process.env.INIT_CWD;
|
|
69
|
-
}
|
|
57
|
+
};
|
|
70
58
|
|
|
71
59
|
// src/lib/generateIgnoreFiles.ts
|
|
72
|
-
var localeCompare =
|
|
73
|
-
var mergeEntries =
|
|
74
|
-
|
|
75
|
-
].sort(localeCompare), "mergeEntries");
|
|
76
|
-
var generateIgnoreFiles = /* @__PURE__ */ __name((filename2, pkg) => {
|
|
60
|
+
var localeCompare = (a, b) => a.localeCompare(b);
|
|
61
|
+
var mergeEntries = (a, b) => [...union(a, b)].sort(localeCompare);
|
|
62
|
+
var generateIgnoreFiles = (filename2, pkg) => {
|
|
77
63
|
console.log(chalk.green(`Generate ${filename2} Files`));
|
|
78
64
|
const cwd = INIT_CWD() ?? ".";
|
|
79
|
-
const workspaces = pkg ? [
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const readEntries = /* @__PURE__ */ __name((location) => readNonEmptyLines(`${location}/${filename2}`), "readEntries");
|
|
83
|
-
const writeEntries = /* @__PURE__ */ __name((location, entries) => writeLines(`${location}/${filename2}`, entries), "writeEntries");
|
|
65
|
+
const workspaces = pkg ? [yarnWorkspace(pkg)] : yarnWorkspaces();
|
|
66
|
+
const readEntries = (location) => readNonEmptyLines(`${location}/${filename2}`);
|
|
67
|
+
const writeEntries = (location, entries) => writeLines(`${location}/${filename2}`, entries);
|
|
84
68
|
const results = workspaces.map(({ location, name }) => {
|
|
85
69
|
try {
|
|
86
70
|
writeEntries(location, mergeEntries(readEntries(cwd), readEntries(location)));
|
|
@@ -93,11 +77,11 @@ var generateIgnoreFiles = /* @__PURE__ */ __name((filename2, pkg) => {
|
|
|
93
77
|
});
|
|
94
78
|
const succeeded = results.every((result) => result === 0);
|
|
95
79
|
return succeeded ? 0 : 1;
|
|
96
|
-
}
|
|
80
|
+
};
|
|
97
81
|
|
|
98
82
|
// src/actions/gitignore-gen.ts
|
|
99
83
|
var filename = ".gitignore";
|
|
100
|
-
var gitignoreGen =
|
|
84
|
+
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
101
85
|
export {
|
|
102
86
|
gitignoreGen
|
|
103
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/file/constants.ts","../../src/lib/file/fileLines.ts","../../src/lib/string/empty.ts","../../src/lib/string/union.ts","../../src/lib/file/ReadFileSyncOptions.ts","../../src/lib/generateIgnoreFiles.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/lib/yarn/workspace/yarnWorkspace.ts","../../src/lib/yarn/yarnInitCwd.ts","../../src/actions/gitignore-gen.ts"],"sourcesContent":["export const WINDOWS_NEWLINE_REGEX = /\\r\\n/g\nexport const CROSS_PLATFORM_NEWLINE = '\\n'\n","import type { PathLike, WriteFileOptions } from 'node:fs'\nimport {\n existsSync, readFileSync,\n writeFileSync,\n} from 'node:fs'\n\nimport { notEmpty } from '../string/index.ts'\nimport { CROSS_PLATFORM_NEWLINE, WINDOWS_NEWLINE_REGEX } from './constants.ts'\nimport type { ReadFileSyncOptions } from './ReadFileSyncOptions.ts'\nimport { defaultReadFileSyncOptions } from './ReadFileSyncOptions.ts'\n\nexport const readLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>\n existsSync(uri)\n ? readFileSync(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE)\n : []\n\nexport const readNonEmptyLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>\n readLines(uri, options).filter(notEmpty)\n\nexport const writeLines = (uri: PathLike, lines: string[], options: WriteFileOptions = defaultReadFileSyncOptions) => {\n const existing = existsSync(uri) ? readFileSync(uri, options) : undefined\n const desired = lines.join(CROSS_PLATFORM_NEWLINE)\n // Check if the file is different before writing\n if (existing !== desired) writeFileSync(uri, desired, options)\n}\n","export const empty = (value?: string | undefined): boolean => value?.trim().length === 0\nexport const notEmpty = (value?: string | undefined): boolean => !empty(value)\n","export const union = (a: string[], b: string[]): Set<string> => new Set([...new Set(a), ...new Set(b)])\n","export type ReadFileSyncOptions = BufferEncoding | {\n encoding: BufferEncoding\n flags?: string\n}\n\nexport const defaultReadFileSyncOptions: ReadFileSyncOptions = { encoding: 'utf8' }\n","import chalk from 'chalk'\n\nimport { readNonEmptyLines, writeLines } from './file/index.ts'\nimport { union } from './string/index.ts'\nimport {\n INIT_CWD, yarnWorkspace, yarnWorkspaces,\n} from './yarn/index.ts'\n\nconst localeCompare = (a: string, b: string) => a.localeCompare(b)\n\nconst mergeEntries = (a: string[], b: string[]): string[] => [...union(a, b)].sort(localeCompare)\n\nexport const generateIgnoreFiles = (filename: string, pkg?: string) => {\n console.log(chalk.green(`Generate ${filename} Files`))\n const cwd = INIT_CWD() ?? '.'\n const workspaces = pkg ? [yarnWorkspace(pkg)] : yarnWorkspaces()\n const readEntries = (location: string): string[] => readNonEmptyLines(`${location}/${filename}`)\n const writeEntries = (location: string, entries: string[]) => writeLines(`${location}/${filename}`, entries)\n const results = workspaces.map(({ location, name }) => {\n try {\n writeEntries(location, mergeEntries(readEntries(cwd), readEntries(location)))\n return 0\n } catch (ex) {\n const error = ex as Error\n console.error(`Generate ${filename} Files [${name}] [${error.message}]`)\n return 1\n }\n })\n const succeeded = results.every(result => result === 0)\n return succeeded ? 0 : 1\n}\n","import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { Workspace } from './Workspace.ts'\nimport { yarnWorkspaces } from './yarnWorkspaces.ts'\n\nexport const yarnWorkspace = (pkg: string): Workspace => {\n const workspace = yarnWorkspaces().find(({ name }) => name === pkg)\n if (!workspace) throw new Error(`Workspace ${pkg} not found`)\n return workspace\n}\n","export const INIT_CWD = () => {\n if (!process.env.INIT_CWD) console.error('Missing INIT_CWD')\n return process.env.INIT_CWD\n}\n","import { generateIgnoreFiles } from '../lib/index.ts'\n\nconst filename = '.gitignore'\n\nexport const gitignoreGen = (pkg?: string) => generateIgnoreFiles(filename, pkg)\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/lib/file/constants.ts","../../src/lib/file/fileLines.ts","../../src/lib/string/empty.ts","../../src/lib/string/union.ts","../../src/lib/file/ReadFileSyncOptions.ts","../../src/lib/generateIgnoreFiles.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/lib/yarn/workspace/yarnWorkspace.ts","../../src/lib/yarn/yarnInitCwd.ts","../../src/actions/gitignore-gen.ts"],"sourcesContent":["export const WINDOWS_NEWLINE_REGEX = /\\r\\n/g\nexport const CROSS_PLATFORM_NEWLINE = '\\n'\n","import type { PathLike, WriteFileOptions } from 'node:fs'\nimport {\n existsSync, readFileSync,\n writeFileSync,\n} from 'node:fs'\n\nimport { notEmpty } from '../string/index.ts'\nimport { CROSS_PLATFORM_NEWLINE, WINDOWS_NEWLINE_REGEX } from './constants.ts'\nimport type { ReadFileSyncOptions } from './ReadFileSyncOptions.ts'\nimport { defaultReadFileSyncOptions } from './ReadFileSyncOptions.ts'\n\nexport const readLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>\n existsSync(uri)\n ? readFileSync(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE)\n : []\n\nexport const readNonEmptyLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>\n readLines(uri, options).filter(notEmpty)\n\nexport const writeLines = (uri: PathLike, lines: string[], options: WriteFileOptions = defaultReadFileSyncOptions) => {\n const existing = existsSync(uri) ? readFileSync(uri, options) : undefined\n const desired = lines.join(CROSS_PLATFORM_NEWLINE)\n // Check if the file is different before writing\n if (existing !== desired) writeFileSync(uri, desired, options)\n}\n","export const empty = (value?: string | undefined): boolean => value?.trim().length === 0\nexport const notEmpty = (value?: string | undefined): boolean => !empty(value)\n","export const union = (a: string[], b: string[]): Set<string> => new Set([...new Set(a), ...new Set(b)])\n","export type ReadFileSyncOptions = BufferEncoding | {\n encoding: BufferEncoding\n flags?: string\n}\n\nexport const defaultReadFileSyncOptions: ReadFileSyncOptions = { encoding: 'utf8' }\n","import chalk from 'chalk'\n\nimport { readNonEmptyLines, writeLines } from './file/index.ts'\nimport { union } from './string/index.ts'\nimport {\n INIT_CWD, yarnWorkspace, yarnWorkspaces,\n} from './yarn/index.ts'\n\nconst localeCompare = (a: string, b: string) => a.localeCompare(b)\n\nconst mergeEntries = (a: string[], b: string[]): string[] => [...union(a, b)].sort(localeCompare)\n\nexport const generateIgnoreFiles = (filename: string, pkg?: string) => {\n console.log(chalk.green(`Generate ${filename} Files`))\n const cwd = INIT_CWD() ?? '.'\n const workspaces = pkg ? [yarnWorkspace(pkg)] : yarnWorkspaces()\n const readEntries = (location: string): string[] => readNonEmptyLines(`${location}/${filename}`)\n const writeEntries = (location: string, entries: string[]) => writeLines(`${location}/${filename}`, entries)\n const results = workspaces.map(({ location, name }) => {\n try {\n writeEntries(location, mergeEntries(readEntries(cwd), readEntries(location)))\n return 0\n } catch (ex) {\n const error = ex as Error\n console.error(`Generate ${filename} Files [${name}] [${error.message}]`)\n return 1\n }\n })\n const succeeded = results.every(result => result === 0)\n return succeeded ? 0 : 1\n}\n","import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { Workspace } from './Workspace.ts'\nimport { yarnWorkspaces } from './yarnWorkspaces.ts'\n\nexport const yarnWorkspace = (pkg: string): Workspace => {\n const workspace = yarnWorkspaces().find(({ name }) => name === pkg)\n if (!workspace) throw new Error(`Workspace ${pkg} not found`)\n return workspace\n}\n","export const INIT_CWD = () => {\n if (!process.env.INIT_CWD) console.error('Missing INIT_CWD')\n return process.env.INIT_CWD\n}\n","import { generateIgnoreFiles } from '../lib/index.ts'\n\nconst filename = '.gitignore'\n\nex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AAEV,IAAM,eAAe,CAAC,QAAiB,oBAAoB,UAAU,GAAG;","names":["filename"]}
|
|
@@ -1,35 +1,26 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/actions/gitlint-fix.ts
|
|
5
2
|
import { execSync } from "node:child_process";
|
|
6
3
|
import chalk from "chalk";
|
|
7
4
|
import ParseGitConfig from "parse-git-config";
|
|
8
|
-
var gitlintFix =
|
|
5
|
+
var gitlintFix = () => {
|
|
9
6
|
console.log(`
|
|
10
7
|
Gitlint Fix Start [${process.cwd()}]
|
|
11
8
|
`);
|
|
12
9
|
const gitConfig = ParseGitConfig.sync();
|
|
13
10
|
if (gitConfig.core.ignorecase) {
|
|
14
|
-
execSync("git config core.ignorecase false", {
|
|
15
|
-
stdio: "inherit"
|
|
16
|
-
});
|
|
11
|
+
execSync("git config core.ignorecase false", { stdio: "inherit" });
|
|
17
12
|
console.warn(chalk.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
18
13
|
}
|
|
19
14
|
if (gitConfig.core.autocrlf !== false) {
|
|
20
|
-
execSync("git config core.autocrlf false", {
|
|
21
|
-
stdio: "inherit"
|
|
22
|
-
});
|
|
15
|
+
execSync("git config core.autocrlf false", { stdio: "inherit" });
|
|
23
16
|
console.warn(chalk.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
24
17
|
}
|
|
25
18
|
if (gitConfig.core.eol !== "lf") {
|
|
26
|
-
execSync("git config core.eol lf", {
|
|
27
|
-
stdio: "inherit"
|
|
28
|
-
});
|
|
19
|
+
execSync("git config core.eol lf", { stdio: "inherit" });
|
|
29
20
|
console.warn(chalk.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
30
21
|
}
|
|
31
22
|
return 1;
|
|
32
|
-
}
|
|
23
|
+
};
|
|
33
24
|
export {
|
|
34
25
|
gitlintFix
|
|
35
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/actions/gitlint-fix.ts"],"sourcesContent":["import { execSync } from 'node:child_process'\n\nimport chalk from 'chalk'\nimport ParseGitConfig from 'parse-git-config'\n\nexport const gitlintFix = () => {\n console.log(`\\nGitlint Fix Start [${process.cwd()}]\\n`)\n\n const gitConfig = ParseGitConfig.sync()\n\n if (gitConfig.core.ignorecase) {\n execSync('git config core.ignorecase false', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.ignorecase to be false\\n'))\n }\n\n if (gitConfig.core.autocrlf !== false) {\n execSync('git config core.autocrlf false', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.autocrlf to be false\\n'))\n }\n\n if (gitConfig.core.eol !== 'lf') {\n execSync('git config core.eol lf', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.eol to be \"lf\"\\n'))\n }\n\n return 1\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/actions/gitlint-fix.ts"],"sourcesContent":["import { execSync } from 'node:child_process'\n\nimport chalk from 'chalk'\nimport ParseGitConfig from 'parse-git-config'\n\nexport const gitlintFix = () => {\n console.log(`\\nGitlint Fix Start [${process.cwd()}]\\n`)\n\n const gitConfig = ParseGitConfig.sync()\n\n if (gitConfig.core.ignorecase) {\n execSync('git config core.ignorecase false', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.ignorecase to be false\\n'))\n }\n\n if (gitConfig.core.autocrlf !== false) {\n execSync('git config core.autocrlf false', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.autocrlf to be false\\n'))\n }\n\n if (gitConfig.core.eol !== 'lf') {\n execSync('git config core.eol lf', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.eol to be \"lf\"\\n'))\n }\n\n return 1\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAEzB,OAAO,WAAW;AAClB,OAAO,oBAAoB;AAEpB,IAAM,aAAa,MAAM;AAC9B,UAAQ,IAAI;AAAA,qBAAwB,QAAQ,IAAI,CAAC;AAAA,CAAK;AAEtD,QAAM,YAAY,eAAe,KAAK;AAEtC,MAAI,UAAU,KAAK,YAAY;AAC7B,aAAS,oCAAoC,EAAE,OAAO,UAAU,CAAC;AACjE,YAAQ,KAAK,MAAM,OAAO,sDAAsD,CAAC;AAAA,EACnF;AAEA,MAAI,UAAU,KAAK,aAAa,OAAO;AACrC,aAAS,kCAAkC,EAAE,OAAO,UAAU,CAAC;AAC/D,YAAQ,KAAK,MAAM,OAAO,oDAAoD,CAAC;AAAA,EACjF;AAEA,MAAI,UAAU,KAAK,QAAQ,MAAM;AAC/B,aAAS,0BAA0B,EAAE,OAAO,UAAU,CAAC;AACvD,YAAQ,KAAK,MAAM,OAAO,8CAA8C,CAAC;AAAA,EAC3E;AAEA,SAAO;AACT;","names":[]}
|
package/dist/actions/gitlint.mjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/actions/gitlint.ts
|
|
5
2
|
import chalk from "chalk";
|
|
6
3
|
import ParseGitConfig from "parse-git-config";
|
|
7
|
-
var gitlint =
|
|
4
|
+
var gitlint = () => {
|
|
8
5
|
console.log(`
|
|
9
6
|
Gitlint Start [${process.cwd()}]
|
|
10
7
|
`);
|
|
@@ -12,10 +9,10 @@ Gitlint Start [${process.cwd()}]
|
|
|
12
9
|
let warnings = 0;
|
|
13
10
|
const errors = 0;
|
|
14
11
|
const gitConfig = ParseGitConfig.sync();
|
|
15
|
-
const warn =
|
|
12
|
+
const warn = (message) => {
|
|
16
13
|
console.warn(chalk.yellow(`Warning: ${message}`));
|
|
17
14
|
warnings++;
|
|
18
|
-
}
|
|
15
|
+
};
|
|
19
16
|
if (gitConfig.core.ignorecase) {
|
|
20
17
|
warn("Please set core.ignorecase to FALSE in .git/config file [run yarn gitlint-fix]");
|
|
21
18
|
} else {
|
|
@@ -44,7 +41,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
44
41
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
45
42
|
`);
|
|
46
43
|
return warnings + errors === 0 ? 1 : 0;
|
|
47
|
-
}
|
|
44
|
+
};
|
|
48
45
|
export {
|
|
49
46
|
gitlint
|
|
50
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/actions/gitlint.ts"],"sourcesContent":["import chalk from 'chalk'\nimport ParseGitConfig from 'parse-git-config'\n\nexport const gitlint = () => {\n console.log(`\\nGitlint Start [${process.cwd()}]\\n`)\n let valid = 0\n let warnings = 0\n const errors = 0\n const gitConfig = ParseGitConfig.sync()\n\n const warn = (message: string) => {\n console.warn(chalk.yellow(`Warning: ${message}`))\n warnings++\n }\n\n if (gitConfig.core.ignorecase) {\n warn('Please set core.ignorecase to FALSE in .git/config file [run yarn gitlint-fix]')\n } else {\n valid++\n }\n\n if (gitConfig.core.autocrlf === false) {\n valid++\n } else {\n warn('Please set core.autocrlf to FALSE in .git/config file [run yarn gitlint-fix]')\n }\n\n if (gitConfig.core.eol === 'lf') {\n valid++\n } else {\n warn('Please set core.eol to \"lf\" in .git/config file [run yarn gitlint-fix]')\n }\n\n const resultMessages: string[] = []\n if (valid > 0) {\n resultMessages.push(chalk.green(`Passed: ${valid}`))\n }\n if (warnings > 0) {\n resultMessages.push(chalk.yellow(`Warnings: ${warnings}`))\n }\n if (errors > 0) {\n resultMessages.push(chalk.red(` Errors: ${errors}`))\n }\n console.warn(`Gitlint Finish [ ${resultMessages.join(' | ')} ]\\n`)\n return warnings + errors === 0 ? 1 : 0\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/actions/gitlint.ts"],"sourcesContent":["import chalk from 'chalk'\nimport ParseGitConfig from 'parse-git-config'\n\nexport const gitlint = () => {\n console.log(`\\nGitlint Start [${process.cwd()}]\\n`)\n let valid = 0\n let warnings = 0\n const errors = 0\n const gitConfig = ParseGitConfig.sync()\n\n const warn = (message: string) => {\n console.warn(chalk.yellow(`Warning: ${message}`))\n warnings++\n }\n\n if (gitConfig.core.ignorecase) {\n warn('Please set core.ignorecase to FALSE in .git/config file [run yarn gitlint-fix]')\n } else {\n valid++\n }\n\n if (gitConfig.core.autocrlf === false) {\n valid++\n } else {\n warn('Please set core.autocrlf to FALSE in .git/config file [run yarn gitlint-fix]')\n }\n\n if (gitConfig.core.eol === 'lf') {\n valid++\n } else {\n warn('Please set core.eol to \"lf\" in .git/config file [run yarn gitlint-fix]')\n }\n\n const resultMessages: string[] = []\n if (valid > 0) {\n resultMessages.push(chalk.green(`Passed: ${valid}`))\n }\n if (warnings > 0) {\n resultMessages.push(chalk.yellow(`Warnings: ${warnings}`))\n }\n if (errors > 0) {\n resultMessages.push(chalk.red(` Errors: ${errors}`))\n }\n console.warn(`Gitlint Finish [ ${resultMessages.join(' | ')} ]\\n`)\n return warnings + errors === 0 ? 1 : 0\n}\n"],"mappings":";AAAA,OAAO,WAAW;AAClB,OAAO,oBAAoB;AAEpB,IAAM,UAAU,MAAM;AAC3B,UAAQ,IAAI;AAAA,iBAAoB,QAAQ,IAAI,CAAC;AAAA,CAAK;AAClD,MAAI,QAAQ;AACZ,MAAI,WAAW;AACf,QAAM,SAAS;AACf,QAAM,YAAY,eAAe,KAAK;AAEtC,QAAM,OAAO,CAAC,YAAoB;AAChC,YAAQ,KAAK,MAAM,OAAO,YAAY,OAAO,EAAE,CAAC;AAChD;AAAA,EACF;AAEA,MAAI,UAAU,KAAK,YAAY;AAC7B,SAAK,gFAAgF;AAAA,EACvF,OAAO;AACL;AAAA,EACF;AAEA,MAAI,UAAU,KAAK,aAAa,OAAO;AACrC;AAAA,EACF,OAAO;AACL,SAAK,8EAA8E;AAAA,EACrF;AAEA,MAAI,UAAU,KAAK,QAAQ,MAAM;AAC/B;AAAA,EACF,OAAO;AACL,SAAK,wEAAwE;AAAA,EAC/E;AAEA,QAAM,iBAA2B,CAAC;AAClC,MAAI,QAAQ,GAAG;AACb,mBAAe,KAAK,MAAM,MAAM,WAAW,KAAK,EAAE,CAAC;AAAA,EACrD;AACA,MAAI,WAAW,GAAG;AAChB,mBAAe,KAAK,MAAM,OAAO,aAAa,QAAQ,EAAE,CAAC;AAAA,EAC3D;AACA,MAAI,SAAS,GAAG;AACd,mBAAe,KAAK,MAAM,IAAI,YAAY,MAAM,EAAE,CAAC;AAAA,EACrD;AACA,UAAQ,KAAK,oBAAoB,eAAe,KAAK,KAAK,CAAC;AAAA,CAAM;AACjE,SAAO,WAAW,WAAW,IAAI,IAAI;AACvC;","names":[]}
|