skuba 14.0.0-migrate-to-inquirer-20251031060542 → 14.0.0-replace-global-vars-20251117052457
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/config/eslint.js +1 -1
- package/config/prettier.d.ts +8 -4
- package/config/prettier.js +10 -2
- package/lib/cli/adapter/eslint.js +11 -45
- package/lib/cli/adapter/eslint.js.map +3 -3
- package/lib/cli/adapter/prettier.js +39 -67
- package/lib/cli/adapter/prettier.js.map +2 -2
- package/lib/cli/build/args.js +8 -42
- package/lib/cli/build/args.js.map +2 -2
- package/lib/cli/build/assets.d.ts +3 -2
- package/lib/cli/build/assets.js +28 -60
- package/lib/cli/build/assets.js.map +3 -3
- package/lib/cli/build/esbuild.js +21 -45
- package/lib/cli/build/esbuild.js.map +2 -2
- package/lib/cli/build/index.js +21 -55
- package/lib/cli/build/index.js.map +3 -3
- package/lib/cli/build/tsc.js +23 -61
- package/lib/cli/build/tsc.js.map +3 -3
- package/lib/cli/buildPackage/index.js +8 -32
- package/lib/cli/buildPackage/index.js.map +1 -1
- package/lib/cli/configure/analyseConfiguration.js +16 -50
- package/lib/cli/configure/analyseConfiguration.js.map +2 -2
- package/lib/cli/configure/analyseDependencies.d.ts +1 -1
- package/lib/cli/configure/analyseDependencies.js +25 -59
- package/lib/cli/configure/analyseDependencies.js.map +3 -3
- package/lib/cli/configure/analysis/diff.js +5 -39
- package/lib/cli/configure/analysis/diff.js.map +3 -3
- package/lib/cli/configure/analysis/files.js +8 -42
- package/lib/cli/configure/analysis/files.js.map +2 -2
- package/lib/cli/configure/analysis/git.js +12 -46
- package/lib/cli/configure/analysis/git.js.map +2 -2
- package/lib/cli/configure/analysis/package.d.ts +2 -3
- package/lib/cli/configure/analysis/package.js +10 -45
- package/lib/cli/configure/analysis/package.js.map +3 -3
- package/lib/cli/configure/analysis/project.js +18 -50
- package/lib/cli/configure/analysis/project.js.map +2 -2
- package/lib/cli/configure/dependencies/index.js +7 -35
- package/lib/cli/configure/dependencies/index.js.map +1 -1
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +4 -28
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +1 -1
- package/lib/cli/configure/dependencies/seekKoala.js +4 -28
- package/lib/cli/configure/dependencies/seekKoala.js.map +1 -1
- package/lib/cli/configure/dependencies/skuba.js +4 -28
- package/lib/cli/configure/dependencies/skuba.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDeps.js +2 -26
- package/lib/cli/configure/dependencies/skubaDeps.js.map +1 -1
- package/lib/cli/configure/dependencies/skubaDive.js +4 -29
- package/lib/cli/configure/dependencies/skubaDive.js.map +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.d.ts +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.js +35 -60
- package/lib/cli/configure/ensureTemplateCompletion.js.map +3 -3
- package/lib/cli/configure/getEntryPoint.d.ts +1 -1
- package/lib/cli/configure/getEntryPoint.js +14 -48
- package/lib/cli/configure/getEntryPoint.js.map +3 -3
- package/lib/cli/configure/getProjectType.d.ts +1 -1
- package/lib/cli/configure/getProjectType.js +14 -35
- package/lib/cli/configure/getProjectType.js.map +2 -2
- package/lib/cli/configure/index.js +50 -84
- package/lib/cli/configure/index.js.map +3 -3
- package/lib/cli/configure/modules/eslint.js +10 -34
- package/lib/cli/configure/modules/eslint.js.map +1 -1
- package/lib/cli/configure/modules/ignore.js +8 -32
- package/lib/cli/configure/modules/ignore.js.map +1 -1
- package/lib/cli/configure/modules/index.js +18 -44
- package/lib/cli/configure/modules/index.js.map +2 -2
- package/lib/cli/configure/modules/nodemon.js +4 -28
- package/lib/cli/configure/modules/nodemon.js.map +1 -1
- package/lib/cli/configure/modules/package.js +10 -34
- package/lib/cli/configure/modules/package.js.map +1 -1
- package/lib/cli/configure/modules/prettier.js +11 -35
- package/lib/cli/configure/modules/prettier.js.map +1 -1
- package/lib/cli/configure/modules/renovate.js +17 -40
- package/lib/cli/configure/modules/renovate.js.map +2 -2
- package/lib/cli/configure/modules/serverless.js +2 -26
- package/lib/cli/configure/modules/serverless.js.map +1 -1
- package/lib/cli/configure/modules/tslint.js +4 -28
- package/lib/cli/configure/modules/tslint.js.map +1 -1
- package/lib/cli/configure/processing/configFile.js +3 -39
- package/lib/cli/configure/processing/configFile.js.map +1 -1
- package/lib/cli/configure/processing/deleteFiles.js +2 -26
- package/lib/cli/configure/processing/deleteFiles.js.map +1 -1
- package/lib/cli/configure/processing/javascript.js +2 -27
- package/lib/cli/configure/processing/javascript.js.map +1 -1
- package/lib/cli/configure/processing/json.js +6 -31
- package/lib/cli/configure/processing/json.js.map +1 -1
- package/lib/cli/configure/processing/loadFiles.js +2 -26
- package/lib/cli/configure/processing/loadFiles.js.map +1 -1
- package/lib/cli/configure/processing/module.js +4 -28
- package/lib/cli/configure/processing/module.js.map +1 -1
- package/lib/cli/configure/processing/package.d.ts +1 -67
- package/lib/cli/configure/processing/package.js +8 -45
- package/lib/cli/configure/processing/package.js.map +3 -3
- package/lib/cli/configure/processing/prettier.js +4 -38
- package/lib/cli/configure/processing/prettier.js.map +2 -2
- package/lib/cli/configure/processing/record.js +5 -41
- package/lib/cli/configure/processing/record.js.map +2 -2
- package/lib/cli/configure/processing/typescript.js +26 -63
- package/lib/cli/configure/processing/typescript.js.map +2 -2
- package/lib/cli/configure/types.d.ts +15 -4
- package/lib/cli/configure/types.js +0 -16
- package/lib/cli/configure/types.js.map +3 -3
- package/lib/cli/format/index.js +20 -54
- package/lib/cli/format/index.js.map +3 -3
- package/lib/cli/help/index.js +6 -30
- package/lib/cli/help/index.js.map +1 -1
- package/lib/cli/init/getConfig.d.ts +1 -1
- package/lib/cli/init/getConfig.js +76 -104
- package/lib/cli/init/getConfig.js.map +3 -3
- package/lib/cli/init/git.js +16 -51
- package/lib/cli/init/git.js.map +2 -2
- package/lib/cli/init/index.js +67 -98
- package/lib/cli/init/index.js.map +2 -2
- package/lib/cli/init/prompts.js +21 -42
- package/lib/cli/init/prompts.js.map +1 -1
- package/lib/cli/init/types.js +7 -41
- package/lib/cli/init/types.js.map +1 -1
- package/lib/cli/init/validation.js +2 -30
- package/lib/cli/init/validation.js.map +1 -1
- package/lib/cli/init/writePackageJson.js +8 -42
- package/lib/cli/init/writePackageJson.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/eslint.js +3 -37
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/index.js +11 -45
- package/lib/cli/lint/annotate/buildkite/index.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/internal.js +3 -37
- package/lib/cli/lint/annotate/buildkite/internal.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/prettier.js +3 -37
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/buildkite/tsc.js +3 -37
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +1 -1
- package/lib/cli/lint/annotate/github/eslint.js +2 -26
- package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/github/index.js +11 -45
- package/lib/cli/lint/annotate/github/index.js.map +1 -1
- package/lib/cli/lint/annotate/github/internal.js +2 -26
- package/lib/cli/lint/annotate/github/internal.js.map +1 -1
- package/lib/cli/lint/annotate/github/prettier.js +2 -26
- package/lib/cli/lint/annotate/github/prettier.js.map +1 -1
- package/lib/cli/lint/annotate/github/tsc.js +4 -28
- package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
- package/lib/cli/lint/annotate/index.js +6 -30
- package/lib/cli/lint/annotate/index.js.map +1 -1
- package/lib/cli/lint/autofix.js +37 -73
- package/lib/cli/lint/autofix.js.map +1 -1
- package/lib/cli/lint/eslint.js +16 -51
- package/lib/cli/lint/eslint.js.map +3 -3
- package/lib/cli/lint/external.js +19 -51
- package/lib/cli/lint/external.js.map +2 -2
- package/lib/cli/lint/index.js +26 -52
- package/lib/cli/lint/index.js.map +2 -2
- package/lib/cli/lint/internal.js +20 -52
- package/lib/cli/lint/internal.js.map +3 -3
- package/lib/cli/lint/internalLints/detectBadCodeowners.js +8 -33
- package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +1 -1
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +12 -48
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +3 -3
- package/lib/cli/lint/internalLints/patchRenovateConfig.js +21 -55
- package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +33 -66
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/index.d.ts +1 -1
- package/lib/cli/lint/internalLints/upgrade/index.js +23 -56
- package/lib/cli/lint/internalLints/upgrade/index.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js +4 -28
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js +11 -45
- package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js +6 -30
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js +37 -65
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js +11 -46
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js +4 -28
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +23 -59
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js +4 -28
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js +11 -46
- package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js +6 -30
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js +11 -46
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchApiTokenFromEnvironment.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js +11 -46
- package/lib/cli/lint/internalLints/upgrade/patches/12.3.0/patchDockerfileSyntaxDirective.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js +4 -28
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js +11 -46
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.0/patchDockerfileCIVariable.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js +29 -67
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js +10 -34
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js +11 -45
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.d.ts +4 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js +18 -63
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js +15 -50
- package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/index.d.ts +2 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/index.js +11 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/index.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.d.ts +5 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.js +72 -0
- package/lib/cli/lint/internalLints/upgrade/patches/12.5.0/rewriteGlobalVars.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js +17 -51
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js +10 -34
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js +10 -44
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js +12 -46
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js +4 -28
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js +15 -49
- package/lib/cli/lint/internalLints/upgrade/patches/8.0.0/patchPnpmPackageManager.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js +11 -45
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js +10 -39
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js +11 -45
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/moveNpmrcMounts.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js +11 -45
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js +13 -47
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerImages.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js +4 -28
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js +11 -45
- package/lib/cli/lint/internalLints/upgrade/patches/9.0.1/patchPnpmDockerImages.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js +4 -28
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js +8 -32
- package/lib/cli/lint/internalLints/upgrade/patches/9.1.0/upgradeNode.js.map +1 -1
- package/lib/cli/lint/prettier.js +15 -50
- package/lib/cli/lint/prettier.js.map +3 -3
- package/lib/cli/lint/tsc.js +4 -28
- package/lib/cli/lint/tsc.js.map +1 -1
- package/lib/cli/lint/types.js +0 -16
- package/lib/cli/lint/types.js.map +3 -3
- package/lib/cli/migrate/index.js +10 -34
- package/lib/cli/migrate/index.js.map +1 -1
- package/lib/cli/migrate/nodeVersion/checks.js +24 -61
- package/lib/cli/migrate/nodeVersion/checks.js.map +2 -2
- package/lib/cli/migrate/nodeVersion/index.js +25 -55
- package/lib/cli/migrate/nodeVersion/index.js.map +2 -2
- package/lib/cli/node/index.js +20 -57
- package/lib/cli/node/index.js.map +3 -3
- package/lib/cli/release/index.js +4 -28
- package/lib/cli/release/index.js.map +1 -1
- package/lib/cli/start/index.js +16 -50
- package/lib/cli/start/index.js.map +3 -3
- package/lib/cli/test/index.js +4 -44
- package/lib/cli/test/index.js.map +2 -2
- package/lib/cli/version/index.js +6 -30
- package/lib/cli/version/index.js.map +1 -1
- package/lib/eslint.d.js +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +6 -46
- package/lib/index.js.map +2 -2
- package/lib/skuba.js +26 -45
- package/lib/skuba.js.map +3 -3
- package/lib/utils/args.js +6 -43
- package/lib/utils/args.js.map +2 -2
- package/lib/utils/command.js +4 -42
- package/lib/utils/command.js.map +3 -3
- package/lib/utils/copy.js +20 -57
- package/lib/utils/copy.js.map +2 -2
- package/lib/utils/dir.js +32 -72
- package/lib/utils/dir.js.map +2 -2
- package/lib/utils/env.js +2 -26
- package/lib/utils/env.js.map +1 -1
- package/lib/utils/error.js +10 -47
- package/lib/utils/error.js.map +1 -1
- package/lib/utils/exec.d.ts +3 -2
- package/lib/utils/exec.js +24 -62
- package/lib/utils/exec.js.map +3 -3
- package/lib/utils/fs.js +6 -40
- package/lib/utils/fs.js.map +3 -3
- package/lib/utils/help.js +6 -30
- package/lib/utils/help.js.map +1 -1
- package/lib/utils/logging.d.ts +9 -10
- package/lib/utils/logging.js +11 -48
- package/lib/utils/logging.js.map +3 -3
- package/lib/utils/logo.js +28 -59
- package/lib/utils/logo.js.map +3 -3
- package/lib/utils/manifest.d.ts +3 -2
- package/lib/utils/manifest.js +8 -48
- package/lib/utils/manifest.js.map +3 -3
- package/lib/utils/npmrc.js +2 -26
- package/lib/utils/npmrc.js.map +1 -1
- package/lib/utils/packageManager.js +12 -49
- package/lib/utils/packageManager.js.map +2 -2
- package/lib/utils/port.js +4 -39
- package/lib/utils/port.js.map +2 -2
- package/lib/utils/sleep.js +2 -26
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/template.js +18 -55
- package/lib/utils/template.js.map +3 -3
- package/lib/utils/validation.js +2 -31
- package/lib/utils/validation.js.map +1 -1
- package/lib/utils/version.js +9 -46
- package/lib/utils/version.js.map +2 -2
- package/lib/utils/wait.js +7 -32
- package/lib/utils/wait.js.map +1 -1
- package/lib/utils/worker.d.ts +3 -3
- package/lib/utils/worker.js +10 -35
- package/lib/utils/worker.js.map +1 -1
- package/lib/wrapper/function-arguments.d.js +0 -1
- package/lib/wrapper/functionHandler.js +18 -49
- package/lib/wrapper/functionHandler.js.map +2 -2
- package/lib/wrapper/http.d.ts +0 -6
- package/lib/wrapper/http.js +8 -51
- package/lib/wrapper/http.js.map +3 -3
- package/lib/wrapper/index.js +6 -7
- package/lib/wrapper/index.js.map +1 -1
- package/lib/wrapper/main.js +8 -42
- package/lib/wrapper/main.js.map +3 -3
- package/lib/wrapper/requestListener.js +13 -46
- package/lib/wrapper/requestListener.js.map +3 -3
- package/lib/wrapper/server.d.ts +7 -0
- package/lib/wrapper/server.js +11 -0
- package/lib/wrapper/server.js.map +7 -0
- package/package.json +17 -24
- package/template/base/_.prettierrc.js +1 -1
- package/template/base/_eslint.config.js +1 -1
- package/template/base/_pnpm-workspace.yaml +3 -2
- package/template/base/vitest.config.ts +25 -0
- package/template/express-rest-api/package.json +2 -1
- package/template/express-rest-api/skuba.template.js +1 -1
- package/template/express-rest-api/src/app.test.ts +1 -0
- package/template/greeter/package.json +4 -3
- package/template/greeter/skuba.template.js +1 -1
- package/template/greeter/src/app.test.ts +3 -1
- package/template/koa-rest-api/package.json +2 -1
- package/template/koa-rest-api/skuba.template.js +1 -1
- package/template/koa-rest-api/src/api/jobs/getJobs.test.ts +2 -0
- package/template/koa-rest-api/src/api/jobs/postJob.test.ts +2 -0
- package/template/koa-rest-api/src/app.test.ts +2 -0
- package/template/koa-rest-api/src/framework/server.test.ts +2 -2
- package/template/koa-rest-api/src/framework/validation.test.ts +2 -0
- package/template/koa-rest-api/src/testing/metrics.ts +2 -0
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +15 -3
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +11 -9
- package/template/lambda-sqs-worker-cdk/package.json +6 -5
- package/template/lambda-sqs-worker-cdk/skuba.template.js +1 -1
- package/template/lambda-sqs-worker-cdk/src/app.test.ts +22 -13
- package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +1 -0
- package/template/lambda-sqs-worker-cdk/src/framework/validation.test.ts +33 -31
- package/template/lambda-sqs-worker-cdk/src/services/jobScorer.test.ts +8 -2
- package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.test.ts +3 -2
- package/template/lambda-sqs-worker-cdk/src/testing/services.ts +4 -3
- package/template/oss-npm-package/_package.json +1 -0
- package/template/oss-npm-package/skuba.template.js +1 -1
- package/template/oss-npm-package/src/index.test.ts +2 -0
- package/template/private-npm-package/_package.json +1 -0
- package/template/private-npm-package/skuba.template.js +1 -1
- package/template/private-npm-package/src/index.test.ts +2 -0
- package/config/jest.js +0 -1
- package/jest/moduleNameMapper.js +0 -64
- package/jest/transform.js +0 -62
- package/jest/tsConfig.js +0 -26
- package/jest-preset.js +0 -37
- package/lib/api/jest/index.d.ts +0 -15
- package/lib/api/jest/index.js +0 -59
- package/lib/api/jest/index.js.map +0 -7
- package/lib/cli/configure/modules/jest.d.ts +0 -2
- package/lib/cli/configure/modules/jest.js +0 -86
- package/lib/cli/configure/modules/jest.js.map +0 -7
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.d.ts +0 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js +0 -144
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +0 -7
- package/lib/cli/test/reporters/github/annotations.d.ts +0 -9
- package/lib/cli/test/reporters/github/annotations.js +0 -102
- package/lib/cli/test/reporters/github/annotations.js.map +0 -7
- package/lib/cli/test/reporters/github/index.d.ts +0 -5
- package/lib/cli/test/reporters/github/index.js +0 -74
- package/lib/cli/test/reporters/github/index.js.map +0 -7
- package/template/base/jest.config.ts +0 -19
- package/template/base/jest.setup.ts +0 -3
package/config/eslint.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { default } from 'eslint-config-skuba';
|
package/config/prettier.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare const config: {
|
|
2
|
+
singleQuote: boolean;
|
|
3
|
+
tabWidth: number;
|
|
4
|
+
trailingComma: 'all';
|
|
5
|
+
plugins: ['prettier-plugin-packagejson'];
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default config;
|
package/config/prettier.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @see https://prettier.io/docs/configuration
|
|
3
|
+
* @satisfies {import('prettier').Config}
|
|
4
|
+
*/
|
|
5
|
+
const config = {
|
|
2
6
|
singleQuote: true,
|
|
3
7
|
tabWidth: 2,
|
|
4
8
|
trailingComma: 'all',
|
|
5
|
-
plugins: [
|
|
9
|
+
plugins: [
|
|
10
|
+
new URL(import.meta.resolve('prettier-plugin-packagejson')).pathname,
|
|
11
|
+
],
|
|
6
12
|
};
|
|
13
|
+
|
|
14
|
+
export default config;
|
|
@@ -1,50 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var eslint_exports = {};
|
|
30
|
-
__export(eslint_exports, {
|
|
31
|
-
runESLint: () => runESLint
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(eslint_exports);
|
|
34
|
-
var import_path = __toESM(require("path"));
|
|
35
|
-
var import_chalk = __toESM(require("chalk"));
|
|
36
|
-
var import_eslint = require("eslint");
|
|
37
|
-
var import_logging = require("../../utils/logging.js");
|
|
1
|
+
import { styleText } from "node:util";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { loadESLint } from "eslint";
|
|
4
|
+
import { pluralise } from "../../utils/logging.js";
|
|
38
5
|
const symbolForResult = (result) => {
|
|
39
6
|
if (result.errorCount) {
|
|
40
|
-
return
|
|
7
|
+
return styleText("red", "\u25CB");
|
|
41
8
|
}
|
|
42
|
-
return result.warningCount ?
|
|
9
|
+
return result.warningCount ? styleText("yellow", "\u25CD") : styleText("green", "\u25CB");
|
|
43
10
|
};
|
|
44
11
|
const runESLint = async (mode, logger, overrideConfigFile) => {
|
|
45
12
|
logger.debug("Initialising ESLint...");
|
|
46
13
|
const cwd = process.cwd();
|
|
47
|
-
const ESLint = await
|
|
14
|
+
const ESLint = await loadESLint({ useFlatConfig: true });
|
|
48
15
|
const engine = new ESLint({
|
|
49
16
|
cache: true,
|
|
50
17
|
fix: mode === "format",
|
|
@@ -69,7 +36,7 @@ const runESLint = async (mode, logger, overrideConfigFile) => {
|
|
|
69
36
|
}
|
|
70
37
|
const end = process.hrtime.bigint();
|
|
71
38
|
logger.plain(
|
|
72
|
-
`Processed ${
|
|
39
|
+
`Processed ${pluralise(results.length, "file")} in ${logger.timing(
|
|
73
40
|
start,
|
|
74
41
|
end
|
|
75
42
|
)}.`
|
|
@@ -78,7 +45,7 @@ const runESLint = async (mode, logger, overrideConfigFile) => {
|
|
|
78
45
|
const warnings = [];
|
|
79
46
|
let fixable = false;
|
|
80
47
|
for (const result of results) {
|
|
81
|
-
const relativePath =
|
|
48
|
+
const relativePath = path.relative(cwd, result.filePath);
|
|
82
49
|
if (result.fixableErrorCount + result.fixableWarningCount) {
|
|
83
50
|
fixable = true;
|
|
84
51
|
}
|
|
@@ -118,8 +85,7 @@ const lintFiles = async (engine) => {
|
|
|
118
85
|
throw error;
|
|
119
86
|
}
|
|
120
87
|
};
|
|
121
|
-
|
|
122
|
-
0 && (module.exports = {
|
|
88
|
+
export {
|
|
123
89
|
runESLint
|
|
124
|
-
}
|
|
90
|
+
};
|
|
125
91
|
//# sourceMappingURL=eslint.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/adapter/eslint.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import { styleText } from 'node:util';\nimport path from 'path';\n\nimport { type ESLint, type Linter, loadESLint } from 'eslint';\n\nimport { type Logger, pluralise } from '../../utils/logging.js';\n\nconst symbolForResult = (result: ESLint.LintResult) => {\n if (result.errorCount) {\n return styleText('red', '\u25CB');\n }\n\n return result.warningCount\n ? styleText('yellow', '\u25CD')\n : styleText('green', '\u25CB');\n};\n\nexport interface ESLintResult {\n messages: Linter.LintMessage[];\n filePath: string;\n}\n\nexport interface ESLintOutput {\n errors: ESLintResult[];\n fixable: boolean;\n ok: boolean;\n output: string;\n warnings: ESLintResult[];\n}\n\nexport const runESLint = async (\n mode: 'format' | 'lint',\n logger: Logger,\n overrideConfigFile?: string,\n): Promise<ESLintOutput> => {\n logger.debug('Initialising ESLint...');\n\n const cwd = process.cwd();\n\n const ESLint = await loadESLint({ useFlatConfig: true });\n const engine = new ESLint({\n cache: true,\n fix: mode === 'format',\n overrideConfigFile,\n overrideConfig: {\n linterOptions: {\n reportUnusedDisableDirectives: true,\n },\n },\n });\n\n logger.debug('Processing files...');\n\n const start = process.hrtime.bigint();\n\n const [formatter, { type, results }] = await Promise.all([\n engine.loadFormatter(),\n lintFiles(engine),\n ]);\n\n if (type === 'no-config') {\n logger.plain(\n 'skuba could not find an eslint config file. Do you need to run format or configure?',\n );\n return { ok: false, fixable: false, errors: [], warnings: [], output: '' };\n }\n\n const end = process.hrtime.bigint();\n\n logger.plain(\n `Processed ${pluralise(results.length, 'file')} in ${logger.timing(\n start,\n end,\n )}.`,\n );\n\n const errors: ESLintResult[] = [];\n const warnings: ESLintResult[] = [];\n let fixable = false;\n\n for (const result of results) {\n const relativePath = path.relative(cwd, result.filePath);\n if (result.fixableErrorCount + result.fixableWarningCount) {\n fixable = true;\n }\n\n if (result.errorCount) {\n errors.push({\n filePath: relativePath,\n messages: result.messages,\n });\n }\n\n if (result.warningCount) {\n warnings.push({\n filePath: relativePath,\n messages: result.messages,\n });\n }\n\n logger.debug(symbolForResult(result), relativePath);\n }\n\n const ok = errors.length === 0;\n\n await ESLint.outputFixes(results);\n\n const output = await formatter.format(\n results,\n engine.getRulesMetaForResults(results),\n );\n\n if (output) {\n logger.plain(output);\n }\n\n return { errors, fixable, ok, output, warnings };\n};\n\nconst lintFiles = async (engine: ESLint) => {\n try {\n const result = await engine.lintFiles([]);\n return { type: 'results', results: result } as const;\n } catch (error) {\n if (\n error instanceof Error &&\n error.message === 'Could not find config file.'\n ) {\n return { type: 'no-config', results: undefined } as const;\n }\n throw error;\n }\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAC1B,OAAO,UAAU;AAEjB,SAAmC,kBAAkB;AAErD,SAAsB,iBAAiB;AAEvC,MAAM,kBAAkB,CAAC,WAA8B;AACrD,MAAI,OAAO,YAAY;AACrB,WAAO,UAAU,OAAO,QAAG;AAAA,EAC7B;AAEA,SAAO,OAAO,eACV,UAAU,UAAU,QAAG,IACvB,UAAU,SAAS,QAAG;AAC5B;AAeO,MAAM,YAAY,OACvB,MACA,QACA,uBAC0B;AAC1B,SAAO,MAAM,wBAAwB;AAErC,QAAM,MAAM,QAAQ,IAAI;AAExB,QAAM,SAAS,MAAM,WAAW,EAAE,eAAe,KAAK,CAAC;AACvD,QAAM,SAAS,IAAI,OAAO;AAAA,IACxB,OAAO;AAAA,IACP,KAAK,SAAS;AAAA,IACd;AAAA,IACA,gBAAgB;AAAA,MACd,eAAe;AAAA,QACb,+BAA+B;AAAA,MACjC;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO,MAAM,qBAAqB;AAElC,QAAM,QAAQ,QAAQ,OAAO,OAAO;AAEpC,QAAM,CAAC,WAAW,EAAE,MAAM,QAAQ,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,IACvD,OAAO,cAAc;AAAA,IACrB,UAAU,MAAM;AAAA,EAClB,CAAC;AAED,MAAI,SAAS,aAAa;AACxB,WAAO;AAAA,MACL;AAAA,IACF;AACA,WAAO,EAAE,IAAI,OAAO,SAAS,OAAO,QAAQ,CAAC,GAAG,UAAU,CAAC,GAAG,QAAQ,GAAG;AAAA,EAC3E;AAEA,QAAM,MAAM,QAAQ,OAAO,OAAO;AAElC,SAAO;AAAA,IACL,aAAa,UAAU,QAAQ,QAAQ,MAAM,CAAC,OAAO,OAAO;AAAA,MAC1D;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,SAAyB,CAAC;AAChC,QAAM,WAA2B,CAAC;AAClC,MAAI,UAAU;AAEd,aAAW,UAAU,SAAS;AAC5B,UAAM,eAAe,KAAK,SAAS,KAAK,OAAO,QAAQ;AACvD,QAAI,OAAO,oBAAoB,OAAO,qBAAqB;AACzD,gBAAU;AAAA,IACZ;AAEA,QAAI,OAAO,YAAY;AACrB,aAAO,KAAK;AAAA,QACV,UAAU;AAAA,QACV,UAAU,OAAO;AAAA,MACnB,CAAC;AAAA,IACH;AAEA,QAAI,OAAO,cAAc;AACvB,eAAS,KAAK;AAAA,QACZ,UAAU;AAAA,QACV,UAAU,OAAO;AAAA,MACnB,CAAC;AAAA,IACH;AAEA,WAAO,MAAM,gBAAgB,MAAM,GAAG,YAAY;AAAA,EACpD;AAEA,QAAM,KAAK,OAAO,WAAW;AAE7B,QAAM,OAAO,YAAY,OAAO;AAEhC,QAAM,SAAS,MAAM,UAAU;AAAA,IAC7B;AAAA,IACA,OAAO,uBAAuB,OAAO;AAAA,EACvC;AAEA,MAAI,QAAQ;AACV,WAAO,MAAM,MAAM;AAAA,EACrB;AAEA,SAAO,EAAE,QAAQ,SAAS,IAAI,QAAQ,SAAS;AACjD;AAEA,MAAM,YAAY,OAAO,WAAmB;AAC1C,MAAI;AACF,UAAM,SAAS,MAAM,OAAO,UAAU,CAAC,CAAC;AACxC,WAAO,EAAE,MAAM,WAAW,SAAS,OAAO;AAAA,EAC5C,SAAS,OAAO;AACd,QACE,iBAAiB,SACjB,MAAM,YAAY,+BAClB;AACA,aAAO,EAAE,MAAM,aAAa,SAAS,OAAU;AAAA,IACjD;AACA,UAAM;AAAA,EACR;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,49 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var prettier_exports = {};
|
|
30
|
-
__export(prettier_exports, {
|
|
31
|
-
formatOrLintFile: () => formatOrLintFile,
|
|
32
|
-
inferParser: () => inferParser,
|
|
33
|
-
runPrettier: () => runPrettier
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(prettier_exports);
|
|
36
|
-
var import_path = __toESM(require("path"));
|
|
37
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
38
|
-
var import_prettier = require("prettier");
|
|
39
|
-
var import_dir = require("../../utils/dir.js");
|
|
40
|
-
var import_logging = require("../../utils/logging.js");
|
|
41
|
-
var import_manifest = require("../../utils/manifest.js");
|
|
42
|
-
var import_package = require("../configure/processing/package.js");
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import {
|
|
4
|
+
check,
|
|
5
|
+
format,
|
|
6
|
+
getSupportInfo,
|
|
7
|
+
resolveConfig
|
|
8
|
+
} from "prettier";
|
|
9
|
+
import { crawlDirectory } from "../../utils/dir.js";
|
|
10
|
+
import { pluralise } from "../../utils/logging.js";
|
|
11
|
+
import { getConsumerManifest } from "../../utils/manifest.js";
|
|
12
|
+
import {
|
|
13
|
+
formatPackage,
|
|
14
|
+
parsePackage
|
|
15
|
+
} from "../configure/processing/package.js";
|
|
43
16
|
let languages;
|
|
44
17
|
const inferParser = async (filepath) => {
|
|
45
|
-
const filename =
|
|
46
|
-
languages ??= (await
|
|
18
|
+
const filename = path.basename(filepath).toLowerCase();
|
|
19
|
+
languages ??= (await getSupportInfo()).languages;
|
|
47
20
|
const firstLanguage = languages.find(
|
|
48
21
|
(language) => language.extensions?.some((extension) => filename.endsWith(extension)) || language.filenames?.some((name) => name.toLowerCase() === filename)
|
|
49
22
|
);
|
|
@@ -53,12 +26,12 @@ const isPackageJsonOk = async ({
|
|
|
53
26
|
data,
|
|
54
27
|
filepath
|
|
55
28
|
}) => {
|
|
56
|
-
if (
|
|
29
|
+
if (path.basename(filepath) !== "package.json") {
|
|
57
30
|
return true;
|
|
58
31
|
}
|
|
59
32
|
try {
|
|
60
|
-
const packageJson =
|
|
61
|
-
return !packageJson || await
|
|
33
|
+
const packageJson = parsePackage(data);
|
|
34
|
+
return !packageJson || await formatPackage(packageJson) === data;
|
|
62
35
|
} catch {
|
|
63
36
|
}
|
|
64
37
|
return true;
|
|
@@ -67,7 +40,7 @@ const formatOrLintFile = async ({ data, filepath, options }, mode, result) => {
|
|
|
67
40
|
if (mode === "lint") {
|
|
68
41
|
let ok;
|
|
69
42
|
try {
|
|
70
|
-
ok = await
|
|
43
|
+
ok = await check(data, options) && await isPackageJsonOk({ data, filepath });
|
|
71
44
|
} catch (err) {
|
|
72
45
|
result?.errored.push({ err, filepath });
|
|
73
46
|
return;
|
|
@@ -79,16 +52,16 @@ const formatOrLintFile = async ({ data, filepath, options }, mode, result) => {
|
|
|
79
52
|
}
|
|
80
53
|
let formatted;
|
|
81
54
|
try {
|
|
82
|
-
formatted = await
|
|
55
|
+
formatted = await format(data, options);
|
|
83
56
|
} catch (err) {
|
|
84
57
|
result?.errored.push({ err, filepath });
|
|
85
58
|
return;
|
|
86
59
|
}
|
|
87
60
|
try {
|
|
88
|
-
if (
|
|
89
|
-
const packageJson =
|
|
61
|
+
if (path.basename(filepath) === "package.json") {
|
|
62
|
+
const packageJson = parsePackage(formatted);
|
|
90
63
|
if (packageJson) {
|
|
91
|
-
formatted = await
|
|
64
|
+
formatted = await formatPackage(packageJson);
|
|
92
65
|
}
|
|
93
66
|
}
|
|
94
67
|
} catch {
|
|
@@ -102,18 +75,18 @@ const formatOrLintFile = async ({ data, filepath, options }, mode, result) => {
|
|
|
102
75
|
const runPrettier = async (mode, logger, cwd = process.cwd()) => {
|
|
103
76
|
logger.debug("Initialising Prettier...");
|
|
104
77
|
const start = process.hrtime.bigint();
|
|
105
|
-
const manifest = await
|
|
106
|
-
const directory = manifest ?
|
|
78
|
+
const manifest = await getConsumerManifest(cwd);
|
|
79
|
+
const directory = manifest ? path.dirname(manifest.path) : cwd;
|
|
107
80
|
logger.debug(
|
|
108
81
|
manifest ? "Detected project root:" : "Detected working directory:",
|
|
109
82
|
directory
|
|
110
83
|
);
|
|
111
84
|
logger.debug("Discovering files...");
|
|
112
|
-
const relativeFilepaths = await
|
|
85
|
+
const relativeFilepaths = await crawlDirectory(directory, [
|
|
113
86
|
".gitignore",
|
|
114
87
|
".prettierignore"
|
|
115
88
|
]);
|
|
116
|
-
logger.debug(`Discovered ${
|
|
89
|
+
logger.debug(`Discovered ${pluralise(relativeFilepaths.length, "file")}.`);
|
|
117
90
|
const result = {
|
|
118
91
|
count: relativeFilepaths.length,
|
|
119
92
|
errored: [],
|
|
@@ -122,9 +95,9 @@ const runPrettier = async (mode, logger, cwd = process.cwd()) => {
|
|
|
122
95
|
};
|
|
123
96
|
logger.debug(mode === "format" ? "Formatting" : "Linting", "files...");
|
|
124
97
|
for (const relativeFilepath of relativeFilepaths) {
|
|
125
|
-
const filepath =
|
|
98
|
+
const filepath = path.relative(
|
|
126
99
|
process.cwd(),
|
|
127
|
-
|
|
100
|
+
path.join(directory, relativeFilepath)
|
|
128
101
|
);
|
|
129
102
|
const parser = await inferParser(filepath);
|
|
130
103
|
logger.debug(filepath);
|
|
@@ -134,8 +107,8 @@ const runPrettier = async (mode, logger, cwd = process.cwd()) => {
|
|
|
134
107
|
continue;
|
|
135
108
|
}
|
|
136
109
|
const [config, data] = await Promise.all([
|
|
137
|
-
|
|
138
|
-
|
|
110
|
+
resolveConfig(filepath),
|
|
111
|
+
fs.promises.readFile(filepath, "utf-8")
|
|
139
112
|
]);
|
|
140
113
|
const file = {
|
|
141
114
|
data,
|
|
@@ -144,24 +117,24 @@ const runPrettier = async (mode, logger, cwd = process.cwd()) => {
|
|
|
144
117
|
};
|
|
145
118
|
const formatted = await formatOrLintFile(file, mode, result);
|
|
146
119
|
if (typeof formatted === "string") {
|
|
147
|
-
await
|
|
120
|
+
await fs.promises.writeFile(filepath, formatted);
|
|
148
121
|
}
|
|
149
122
|
}
|
|
150
123
|
const end = process.hrtime.bigint();
|
|
151
124
|
logger.plain(
|
|
152
|
-
`Processed ${
|
|
125
|
+
`Processed ${pluralise(
|
|
153
126
|
result.count - result.unparsed.length,
|
|
154
127
|
"file"
|
|
155
128
|
)} in ${logger.timing(start, end)}.`
|
|
156
129
|
);
|
|
157
130
|
if (result.touched.length) {
|
|
158
|
-
logger.plain(`Formatted ${
|
|
131
|
+
logger.plain(`Formatted ${pluralise(result.touched.length, "file")}:`);
|
|
159
132
|
for (const filepath of result.touched) {
|
|
160
133
|
logger.warn(filepath);
|
|
161
134
|
}
|
|
162
135
|
}
|
|
163
136
|
if (result.errored.length) {
|
|
164
|
-
logger.plain(`Flagged ${
|
|
137
|
+
logger.plain(`Flagged ${pluralise(result.errored.length, "file")}:`);
|
|
165
138
|
for (const { err, filepath } of result.errored) {
|
|
166
139
|
logger.warn(
|
|
167
140
|
filepath,
|
|
@@ -171,10 +144,9 @@ const runPrettier = async (mode, logger, cwd = process.cwd()) => {
|
|
|
171
144
|
}
|
|
172
145
|
return { ok: result.errored.length === 0, result };
|
|
173
146
|
};
|
|
174
|
-
|
|
175
|
-
0 && (module.exports = {
|
|
147
|
+
export {
|
|
176
148
|
formatOrLintFile,
|
|
177
149
|
inferParser,
|
|
178
150
|
runPrettier
|
|
179
|
-
}
|
|
151
|
+
};
|
|
180
152
|
//# sourceMappingURL=prettier.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/adapter/prettier.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport {\n type Options,\n type SupportLanguage,\n check,\n format,\n getSupportInfo,\n resolveConfig,\n} from 'prettier';\n\nimport { crawlDirectory } from '../../utils/dir.js';\nimport { type Logger, pluralise } from '../../utils/logging.js';\nimport { getConsumerManifest } from '../../utils/manifest.js';\nimport {\n formatPackage,\n parsePackage,\n} from '../configure/processing/package.js';\n\nlet languages: SupportLanguage[] | undefined;\n\n/**\n * Infers a parser for the specified filepath.\n *\n * This is a cut-down version of Prettier's built-in function of the same name;\n * ours operates purely on the `filepath` string and does not perform file I/O.\n * Prettier's internal `getInterpreter` function can open a file to read the\n * shebang, and its file descriptor usage can throw warnings on worker threads:\n *\n * ```console\n * Warning: File descriptor 123 closed but not opened in unmanaged mode\n * at Object.closeSync (node:fs:530:11)\n * at Object.closeSync (node_modules/graceful-fs/graceful-fs.js:74:20)\n * ...\n * ```\n *\n * References:\n *\n * - https://github.com/prettier/prettier/blob/2.4.1/src/main/options.js#L167\n * - seek-oss/skuba#659\n */\nexport const inferParser = async (\n filepath: string,\n): Promise<string | undefined> => {\n const filename = path.basename(filepath).toLowerCase();\n\n languages ??= (await getSupportInfo()).languages;\n\n const firstLanguage = languages.find(\n (language) =>\n language.extensions?.some((extension) => filename.endsWith(extension)) ||\n language.filenames?.some((name) => name.toLowerCase() === filename),\n );\n\n return firstLanguage?.parsers[0];\n};\n\nconst isPackageJsonOk = async ({\n data,\n filepath,\n}: {\n data: string;\n filepath: string;\n}): Promise<boolean> => {\n if (path.basename(filepath) !== 'package.json') {\n return true;\n }\n\n try {\n const packageJson = parsePackage(data);\n\n return !packageJson || (await formatPackage(packageJson)) === data;\n } catch {\n // Be more lenient about our custom formatting and don't throw if it errors.\n }\n\n return true;\n};\n\ninterface File {\n data: string;\n options: Options;\n filepath: string;\n}\n\ninterface Result {\n count: number;\n errored: Array<{ err?: unknown; filepath: string }>;\n touched: string[];\n unparsed: string[];\n}\n\nexport const formatOrLintFile = async (\n { data, filepath, options }: File,\n mode: 'format' | 'lint',\n result: Result | null,\n): Promise<string | undefined> => {\n if (mode === 'lint') {\n let ok: boolean;\n try {\n ok =\n (await check(data, options)) &&\n (await isPackageJsonOk({ data, filepath }));\n } catch (err) {\n result?.errored.push({ err, filepath });\n return;\n }\n\n if (!ok) {\n result?.errored.push({ filepath });\n }\n\n return;\n }\n\n let formatted: string;\n try {\n formatted = await format(data, options);\n } catch (err) {\n result?.errored.push({ err, filepath });\n return;\n }\n\n // Perform additional formatting (i.e. sorting) on a `package.json` manifest.\n try {\n if (path.basename(filepath) === 'package.json') {\n const packageJson = parsePackage(formatted);\n if (packageJson) {\n formatted = await formatPackage(packageJson);\n }\n }\n } catch {\n // Be more lenient about our custom formatting and don't throw if it errors.\n }\n\n if (formatted === data) {\n return;\n }\n\n result?.touched.push(filepath);\n return formatted;\n};\n\nexport interface PrettierOutput {\n ok: boolean;\n result: Result;\n}\n\n/**\n * Formats/lints files with Prettier.\n *\n * Prettier doesn't provide a higher-level Node.js API that replicates the\n * behaviour of its CLI, so we have to plumb together its lower-level functions.\n * On the other hand, this affords more flexibility in how we track and report\n * on progress and results.\n */\nexport const runPrettier = async (\n mode: 'format' | 'lint',\n logger: Logger,\n cwd = process.cwd(),\n): Promise<PrettierOutput> => {\n logger.debug('Initialising Prettier...');\n\n const start = process.hrtime.bigint();\n\n const manifest = await getConsumerManifest(cwd);\n\n const directory = manifest ? path.dirname(manifest.path) : cwd;\n\n logger.debug(\n manifest ? 'Detected project root:' : 'Detected working directory:',\n directory,\n );\n\n logger.debug('Discovering files...');\n\n // Match Prettier's opinion of respecting `.gitignore`.\n // This avoids exhibiting different behaviour than a Prettier IDE integration,\n // though it may present headaches if `.gitignore` and `.prettierignore` rules\n // conflict.\n const relativeFilepaths = await crawlDirectory(directory, [\n '.gitignore',\n '.prettierignore',\n ]);\n\n logger.debug(`Discovered ${pluralise(relativeFilepaths.length, 'file')}.`);\n\n const result: Result = {\n count: relativeFilepaths.length,\n errored: [],\n touched: [],\n unparsed: [],\n };\n\n logger.debug(mode === 'format' ? 'Formatting' : 'Linting', 'files...');\n\n for (const relativeFilepath of relativeFilepaths) {\n // Use relative paths to keep log output cleaner, particularly in the common\n // case where we are executing against the current working directory.\n const filepath = path.relative(\n process.cwd(),\n path.join(directory, relativeFilepath),\n );\n\n // Infer parser upfront so we can skip unsupported files.\n const parser = await inferParser(filepath);\n\n logger.debug(filepath);\n logger.debug(' parser:', parser ?? '-');\n\n if (!parser) {\n result.unparsed.push(filepath);\n continue;\n }\n\n const [config, data] = await Promise.all([\n resolveConfig(filepath),\n fs.promises.readFile(filepath, 'utf-8'),\n ]);\n\n const file: File = {\n data,\n filepath,\n options: { ...config, filepath },\n };\n\n const formatted = await formatOrLintFile(file, mode, result);\n\n if (typeof formatted === 'string') {\n await fs.promises.writeFile(filepath, formatted);\n }\n }\n\n const end = process.hrtime.bigint();\n\n logger.plain(\n `Processed ${pluralise(\n result.count - result.unparsed.length,\n 'file',\n )} in ${logger.timing(start, end)}.`,\n );\n\n if (result.touched.length) {\n logger.plain(`Formatted ${pluralise(result.touched.length, 'file')}:`);\n for (const filepath of result.touched) {\n logger.warn(filepath);\n }\n }\n\n if (result.errored.length) {\n logger.plain(`Flagged ${pluralise(result.errored.length, 'file')}:`);\n for (const { err, filepath } of result.errored) {\n logger.warn(\n filepath,\n ...(typeof err === 'string' || err instanceof Error\n ? [String(err)]\n : []),\n );\n }\n }\n\n return { ok: result.errored.length === 0, result };\n};\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AAEjB,OAAO,QAAQ;AACf;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,sBAAsB;AAC/B,SAAsB,iBAAiB;AACvC,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,IAAI;AAsBG,MAAM,cAAc,OACzB,aACgC;AAChC,QAAM,WAAW,KAAK,SAAS,QAAQ,EAAE,YAAY;AAErD,iBAAe,MAAM,eAAe,GAAG;AAEvC,QAAM,gBAAgB,UAAU;AAAA,IAC9B,CAAC,aACC,SAAS,YAAY,KAAK,CAAC,cAAc,SAAS,SAAS,SAAS,CAAC,KACrE,SAAS,WAAW,KAAK,CAAC,SAAS,KAAK,YAAY,MAAM,QAAQ;AAAA,EACtE;AAEA,SAAO,eAAe,QAAQ,CAAC;AACjC;AAEA,MAAM,kBAAkB,OAAO;AAAA,EAC7B;AAAA,EACA;AACF,MAGwB;AACtB,MAAI,KAAK,SAAS,QAAQ,MAAM,gBAAgB;AAC9C,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,cAAc,aAAa,IAAI;AAErC,WAAO,CAAC,eAAgB,MAAM,cAAc,WAAW,MAAO;AAAA,EAChE,QAAQ;AAAA,EAER;AAEA,SAAO;AACT;AAeO,MAAM,mBAAmB,OAC9B,EAAE,MAAM,UAAU,QAAQ,GAC1B,MACA,WACgC;AAChC,MAAI,SAAS,QAAQ;AACnB,QAAI;AACJ,QAAI;AACF,WACG,MAAM,MAAM,MAAM,OAAO,KACzB,MAAM,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAAA,IAC7C,SAAS,KAAK;AACZ,cAAQ,QAAQ,KAAK,EAAE,KAAK,SAAS,CAAC;AACtC;AAAA,IACF;AAEA,QAAI,CAAC,IAAI;AACP,cAAQ,QAAQ,KAAK,EAAE,SAAS,CAAC;AAAA,IACnC;AAEA;AAAA,EACF;AAEA,MAAI;AACJ,MAAI;AACF,gBAAY,MAAM,OAAO,MAAM,OAAO;AAAA,EACxC,SAAS,KAAK;AACZ,YAAQ,QAAQ,KAAK,EAAE,KAAK,SAAS,CAAC;AACtC;AAAA,EACF;AAGA,MAAI;AACF,QAAI,KAAK,SAAS,QAAQ,MAAM,gBAAgB;AAC9C,YAAM,cAAc,aAAa,SAAS;AAC1C,UAAI,aAAa;AACf,oBAAY,MAAM,cAAc,WAAW;AAAA,MAC7C;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AAEA,MAAI,cAAc,MAAM;AACtB;AAAA,EACF;AAEA,UAAQ,QAAQ,KAAK,QAAQ;AAC7B,SAAO;AACT;AAeO,MAAM,cAAc,OACzB,MACA,QACA,MAAM,QAAQ,IAAI,MACU;AAC5B,SAAO,MAAM,0BAA0B;AAEvC,QAAM,QAAQ,QAAQ,OAAO,OAAO;AAEpC,QAAM,WAAW,MAAM,oBAAoB,GAAG;AAE9C,QAAM,YAAY,WAAW,KAAK,QAAQ,SAAS,IAAI,IAAI;AAE3D,SAAO;AAAA,IACL,WAAW,2BAA2B;AAAA,IACtC;AAAA,EACF;AAEA,SAAO,MAAM,sBAAsB;AAMnC,QAAM,oBAAoB,MAAM,eAAe,WAAW;AAAA,IACxD;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO,MAAM,cAAc,UAAU,kBAAkB,QAAQ,MAAM,CAAC,GAAG;AAEzE,QAAM,SAAiB;AAAA,IACrB,OAAO,kBAAkB;AAAA,IACzB,SAAS,CAAC;AAAA,IACV,SAAS,CAAC;AAAA,IACV,UAAU,CAAC;AAAA,EACb;AAEA,SAAO,MAAM,SAAS,WAAW,eAAe,WAAW,UAAU;AAErE,aAAW,oBAAoB,mBAAmB;AAGhD,UAAM,WAAW,KAAK;AAAA,MACpB,QAAQ,IAAI;AAAA,MACZ,KAAK,KAAK,WAAW,gBAAgB;AAAA,IACvC;AAGA,UAAM,SAAS,MAAM,YAAY,QAAQ;AAEzC,WAAO,MAAM,QAAQ;AACrB,WAAO,MAAM,aAAa,UAAU,GAAG;AAEvC,QAAI,CAAC,QAAQ;AACX,aAAO,SAAS,KAAK,QAAQ;AAC7B;AAAA,IACF;AAEA,UAAM,CAAC,QAAQ,IAAI,IAAI,MAAM,QAAQ,IAAI;AAAA,MACvC,cAAc,QAAQ;AAAA,MACtB,GAAG,SAAS,SAAS,UAAU,OAAO;AAAA,IACxC,CAAC;AAED,UAAM,OAAa;AAAA,MACjB;AAAA,MACA;AAAA,MACA,SAAS,EAAE,GAAG,QAAQ,SAAS;AAAA,IACjC;AAEA,UAAM,YAAY,MAAM,iBAAiB,MAAM,MAAM,MAAM;AAE3D,QAAI,OAAO,cAAc,UAAU;AACjC,YAAM,GAAG,SAAS,UAAU,UAAU,SAAS;AAAA,IACjD;AAAA,EACF;AAEA,QAAM,MAAM,QAAQ,OAAO,OAAO;AAElC,SAAO;AAAA,IACL,aAAa;AAAA,MACX,OAAO,QAAQ,OAAO,SAAS;AAAA,MAC/B;AAAA,IACF,CAAC,OAAO,OAAO,OAAO,OAAO,GAAG,CAAC;AAAA,EACnC;AAEA,MAAI,OAAO,QAAQ,QAAQ;AACzB,WAAO,MAAM,aAAa,UAAU,OAAO,QAAQ,QAAQ,MAAM,CAAC,GAAG;AACrE,eAAW,YAAY,OAAO,SAAS;AACrC,aAAO,KAAK,QAAQ;AAAA,IACtB;AAAA,EACF;AAEA,MAAI,OAAO,QAAQ,QAAQ;AACzB,WAAO,MAAM,WAAW,UAAU,OAAO,QAAQ,QAAQ,MAAM,CAAC,GAAG;AACnE,eAAW,EAAE,KAAK,SAAS,KAAK,OAAO,SAAS;AAC9C,aAAO;AAAA,QACL;AAAA,QACA,GAAI,OAAO,QAAQ,YAAY,eAAe,QAC1C,CAAC,OAAO,GAAG,CAAC,IACZ,CAAC;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,IAAI,OAAO,QAAQ,WAAW,GAAG,OAAO;AACnD;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/lib/cli/build/args.js
CHANGED
|
@@ -1,40 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var args_exports = {};
|
|
30
|
-
__export(args_exports, {
|
|
31
|
-
parseTscArgs: () => parseTscArgs
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(args_exports);
|
|
34
|
-
var import_path = __toESM(require("path"));
|
|
35
|
-
var import_minimist = __toESM(require("minimist"));
|
|
1
|
+
import path from "path";
|
|
2
|
+
import minimist from "minimist";
|
|
36
3
|
const parseTscArgs = (args) => {
|
|
37
|
-
const argv = (
|
|
4
|
+
const argv = minimist(args, {
|
|
38
5
|
alias: { b: "build", p: "project" },
|
|
39
6
|
boolean: "build",
|
|
40
7
|
string: "project"
|
|
@@ -43,7 +10,7 @@ const parseTscArgs = (args) => {
|
|
|
43
10
|
return {
|
|
44
11
|
basename,
|
|
45
12
|
dirname,
|
|
46
|
-
pathname:
|
|
13
|
+
pathname: path.join(dirname, basename),
|
|
47
14
|
build: Boolean(argv.build),
|
|
48
15
|
project: argv.project
|
|
49
16
|
};
|
|
@@ -57,8 +24,8 @@ const parseTscProject = (project) => {
|
|
|
57
24
|
}
|
|
58
25
|
if (project.toLocaleLowerCase().endsWith(".json")) {
|
|
59
26
|
return {
|
|
60
|
-
basename:
|
|
61
|
-
dirname:
|
|
27
|
+
basename: path.basename(project),
|
|
28
|
+
dirname: path.dirname(project)
|
|
62
29
|
};
|
|
63
30
|
}
|
|
64
31
|
return {
|
|
@@ -66,8 +33,7 @@ const parseTscProject = (project) => {
|
|
|
66
33
|
dirname: project
|
|
67
34
|
};
|
|
68
35
|
};
|
|
69
|
-
|
|
70
|
-
0 && (module.exports = {
|
|
36
|
+
export {
|
|
71
37
|
parseTscArgs
|
|
72
|
-
}
|
|
38
|
+
};
|
|
73
39
|
//# sourceMappingURL=args.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/build/args.ts"],
|
|
4
4
|
"sourcesContent": ["import path from 'path';\n\nimport minimist from 'minimist';\n\nexport const parseTscArgs = (args: string[]) => {\n const argv = minimist<{\n build: boolean | undefined;\n project: string | undefined;\n }>(args, {\n alias: { b: 'build', p: 'project' },\n boolean: 'build',\n string: 'project',\n });\n\n const { basename, dirname } = parseTscProject(argv.project);\n\n return {\n basename,\n dirname,\n pathname: path.join(dirname, basename),\n\n build: Boolean(argv.build),\n project: argv.project,\n };\n};\n\nconst parseTscProject = (project: string | undefined) => {\n if (!project) {\n return {\n basename: 'tsconfig.build.json',\n dirname: process.cwd(),\n };\n }\n\n if (project.toLocaleLowerCase().endsWith('.json')) {\n return {\n basename: path.basename(project),\n dirname: path.dirname(project),\n };\n }\n\n return {\n basename: 'tsconfig.json',\n dirname: project,\n };\n};\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AAEjB,OAAO,cAAc;AAEd,MAAM,eAAe,CAAC,SAAmB;AAC9C,QAAM,OAAO,SAGV,MAAM;AAAA,IACP,OAAO,EAAE,GAAG,SAAS,GAAG,UAAU;AAAA,IAClC,SAAS;AAAA,IACT,QAAQ;AAAA,EACV,CAAC;AAED,QAAM,EAAE,UAAU,QAAQ,IAAI,gBAAgB,KAAK,OAAO;AAE1D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU,KAAK,KAAK,SAAS,QAAQ;AAAA,IAErC,OAAO,QAAQ,KAAK,KAAK;AAAA,IACzB,SAAS,KAAK;AAAA,EAChB;AACF;AAEA,MAAM,kBAAkB,CAAC,YAAgC;AACvD,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,MACL,UAAU;AAAA,MACV,SAAS,QAAQ,IAAI;AAAA,IACvB;AAAA,EACF;AAEA,MAAI,QAAQ,kBAAkB,EAAE,SAAS,OAAO,GAAG;AACjD,WAAO;AAAA,MACL,UAAU,KAAK,SAAS,OAAO;AAAA,MAC/B,SAAS,KAAK,QAAQ,OAAO;AAAA,IAC/B;AAAA,EACF;AAEA,SAAO;AAAA,IACL,UAAU;AAAA,IACV,SAAS;AAAA,EACX;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { styleText } from 'node:util';
|
|
2
2
|
import { type Logger } from '../../utils/logging.js';
|
|
3
|
+
type StyleColor = Parameters<typeof styleText>[0];
|
|
3
4
|
export declare const copyAssets: (destinationDir: string, logger?: Logger) => Promise<void>;
|
|
4
5
|
interface CopyAssetsConfig {
|
|
5
6
|
outDir: string;
|
|
6
7
|
name: string;
|
|
7
|
-
prefixColor:
|
|
8
|
+
prefixColor: StyleColor;
|
|
8
9
|
}
|
|
9
10
|
export declare const copyAssetsConcurrently: (configs: CopyAssetsConfig[]) => Promise<void>;
|
|
10
11
|
export {};
|
package/lib/cli/build/assets.js
CHANGED
|
@@ -1,62 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var assets_exports = {};
|
|
30
|
-
__export(assets_exports, {
|
|
31
|
-
copyAssets: () => copyAssets,
|
|
32
|
-
copyAssetsConcurrently: () => copyAssetsConcurrently
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(assets_exports);
|
|
35
|
-
var import_path = __toESM(require("path"));
|
|
36
|
-
var import_chalk = __toESM(require("chalk"));
|
|
37
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
38
|
-
var import_copy = require("../../utils/copy.js");
|
|
39
|
-
var import_dir = require("../../utils/dir.js");
|
|
40
|
-
var import_logging = require("../../utils/logging.js");
|
|
41
|
-
var import_manifest = require("../../utils/manifest.js");
|
|
42
|
-
const copyAssets = async (destinationDir, logger = import_logging.log) => {
|
|
43
|
-
const manifest = await (0, import_manifest.getManifestProperties)("assets");
|
|
1
|
+
import { styleText } from "node:util";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import { copyFile } from "../../utils/copy.js";
|
|
5
|
+
import { buildPatternToFilepathMap, crawlDirectory } from "../../utils/dir.js";
|
|
6
|
+
import { createLogger, log } from "../../utils/logging.js";
|
|
7
|
+
import {
|
|
8
|
+
getEntryPointFromManifest,
|
|
9
|
+
getManifestProperties
|
|
10
|
+
} from "../../utils/manifest.js";
|
|
11
|
+
const copyAssets = async (destinationDir, logger = log) => {
|
|
12
|
+
const manifest = await getManifestProperties("assets");
|
|
44
13
|
if (!manifest?.value) {
|
|
45
14
|
return;
|
|
46
15
|
}
|
|
47
|
-
const entryPoint = await
|
|
16
|
+
const entryPoint = await getEntryPointFromManifest();
|
|
48
17
|
if (!entryPoint) {
|
|
49
18
|
return;
|
|
50
19
|
}
|
|
51
|
-
const pathSegments = entryPoint.split(
|
|
20
|
+
const pathSegments = entryPoint.split(path.sep);
|
|
52
21
|
const srcDir = pathSegments.length > 1 && pathSegments[0] || "";
|
|
53
|
-
const resolvedSrcDir =
|
|
54
|
-
const resolvedDestinationDir =
|
|
55
|
-
|
|
22
|
+
const resolvedSrcDir = path.resolve(path.dirname(manifest.path), srcDir);
|
|
23
|
+
const resolvedDestinationDir = path.resolve(
|
|
24
|
+
path.dirname(manifest.path),
|
|
56
25
|
destinationDir
|
|
57
26
|
);
|
|
58
|
-
const allFiles = await
|
|
59
|
-
const filesByPattern =
|
|
27
|
+
const allFiles = await crawlDirectory(resolvedSrcDir);
|
|
28
|
+
const filesByPattern = buildPatternToFilepathMap(manifest.value, allFiles, {
|
|
60
29
|
cwd: resolvedSrcDir,
|
|
61
30
|
dot: true
|
|
62
31
|
});
|
|
@@ -66,13 +35,13 @@ const copyAssets = async (destinationDir, logger = import_logging.log) => {
|
|
|
66
35
|
await Promise.all(
|
|
67
36
|
matchedFiles.map(async (filename) => {
|
|
68
37
|
logger.subtle(`Copying ${filename}`);
|
|
69
|
-
await
|
|
70
|
-
|
|
38
|
+
await fs.promises.mkdir(
|
|
39
|
+
path.dirname(path.join(resolvedDestinationDir, filename)),
|
|
71
40
|
{ recursive: true }
|
|
72
41
|
);
|
|
73
|
-
await
|
|
74
|
-
|
|
75
|
-
|
|
42
|
+
await copyFile(
|
|
43
|
+
path.join(resolvedSrcDir, filename),
|
|
44
|
+
path.join(resolvedDestinationDir, filename),
|
|
76
45
|
{ processors: [] }
|
|
77
46
|
);
|
|
78
47
|
})
|
|
@@ -87,17 +56,16 @@ const copyAssetsConcurrently = async (configs) => {
|
|
|
87
56
|
configs.map(
|
|
88
57
|
async ({ outDir, name, prefixColor }) => copyAssets(
|
|
89
58
|
outDir,
|
|
90
|
-
|
|
59
|
+
createLogger({
|
|
91
60
|
debug: false,
|
|
92
|
-
prefixes: [
|
|
61
|
+
prefixes: [styleText(prefixColor, `${name.padEnd(maxNameLength)} \u2502`)]
|
|
93
62
|
})
|
|
94
63
|
)
|
|
95
64
|
)
|
|
96
65
|
);
|
|
97
66
|
};
|
|
98
|
-
|
|
99
|
-
0 && (module.exports = {
|
|
67
|
+
export {
|
|
100
68
|
copyAssets,
|
|
101
69
|
copyAssetsConcurrently
|
|
102
|
-
}
|
|
70
|
+
};
|
|
103
71
|
//# sourceMappingURL=assets.js.map
|