@cbnventures/nova 0.31.1 → 0.32.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/build/package.json +5 -6
- package/build/scaffold-versions.json +828 -0
- package/build/src/cli/generate/github/workflows-blueprint.d.ts +3 -3
- package/build/src/cli/generate/github/workflows-blueprint.d.ts.map +1 -1
- package/build/src/cli/generate/github/workflows-blueprint.js +47 -69
- package/build/src/cli/generate/github/workflows-blueprint.js.map +1 -1
- package/build/src/cli/generate/must-haves/ignore-files.d.ts +5 -0
- package/build/src/cli/generate/must-haves/ignore-files.d.ts.map +1 -0
- package/build/src/cli/generate/must-haves/ignore-files.js +77 -0
- package/build/src/cli/generate/must-haves/ignore-files.js.map +1 -0
- package/build/src/cli/index.js +65 -68
- package/build/src/cli/index.js.map +1 -1
- package/build/src/cli/recipe/index.d.ts.map +1 -1
- package/build/src/cli/recipe/index.js +9 -2
- package/build/src/cli/recipe/index.js.map +1 -1
- package/build/src/cli/recipe/miscellaneous/fix-markdown-tables.d.ts.map +1 -1
- package/build/src/cli/recipe/miscellaneous/fix-markdown-tables.js +0 -1
- package/build/src/cli/recipe/miscellaneous/fix-markdown-tables.js.map +1 -1
- package/build/src/cli/recipe/miscellaneous/remove-operating-system-files.d.ts +9 -0
- package/build/src/cli/recipe/miscellaneous/remove-operating-system-files.d.ts.map +1 -0
- package/build/src/cli/recipe/miscellaneous/remove-operating-system-files.js +173 -0
- package/build/src/cli/recipe/miscellaneous/remove-operating-system-files.js.map +1 -0
- package/build/src/cli/recipe/package-json/normalize-tooling.d.ts.map +1 -1
- package/build/src/cli/recipe/package-json/normalize-tooling.js +65 -28
- package/build/src/cli/recipe/package-json/normalize-tooling.js.map +1 -1
- package/build/src/cli/scaffold/app/apple.d.ts +5 -0
- package/build/src/cli/scaffold/app/apple.d.ts.map +1 -1
- package/build/src/cli/scaffold/app/apple.js +91 -0
- package/build/src/cli/scaffold/app/apple.js.map +1 -1
- package/build/src/cli/scaffold/app/astro.d.ts.map +1 -1
- package/build/src/cli/scaffold/app/astro.js +6 -5
- package/build/src/cli/scaffold/app/astro.js.map +1 -1
- package/build/src/cli/scaffold/app/discord-bot.js +2 -2
- package/build/src/cli/scaffold/app/discord-bot.js.map +1 -1
- package/build/src/cli/scaffold/app/expressjs.js +2 -2
- package/build/src/cli/scaffold/app/expressjs.js.map +1 -1
- package/build/src/cli/scaffold/app/nextjs.js +2 -2
- package/build/src/cli/scaffold/app/nextjs.js.map +1 -1
- package/build/src/cli/scaffold/app/vite.d.ts.map +1 -1
- package/build/src/cli/scaffold/app/vite.js +13 -12
- package/build/src/cli/scaffold/app/vite.js.map +1 -1
- package/build/src/cli/scaffold/docs/docusaurus.js +2 -2
- package/build/src/cli/scaffold/docs/docusaurus.js.map +1 -1
- package/build/src/cli/scaffold/package/homebridge.d.ts.map +1 -1
- package/build/src/cli/scaffold/package/homebridge.js +2 -1
- package/build/src/cli/scaffold/package/homebridge.js.map +1 -1
- package/build/src/cli/scaffold/starter/base.d.ts.map +1 -1
- package/build/src/cli/scaffold/starter/base.js.map +1 -1
- package/build/src/cli/scaffold/tool/serverless.d.ts +6 -0
- package/build/src/cli/scaffold/tool/serverless.d.ts.map +1 -0
- package/build/src/cli/scaffold/tool/serverless.js +43 -0
- package/build/src/cli/scaffold/tool/serverless.js.map +1 -0
- package/build/src/cli/utility/changelog.d.ts.map +1 -1
- package/build/src/cli/utility/changelog.js +57 -5
- package/build/src/cli/utility/changelog.js.map +1 -1
- package/build/src/cli/utility/configure.d.ts +22 -1
- package/build/src/cli/utility/configure.d.ts.map +1 -1
- package/build/src/cli/utility/configure.js +1995 -247
- package/build/src/cli/utility/configure.js.map +1 -1
- package/build/src/cli/utility/run-workspaces.d.ts +10 -0
- package/build/src/cli/utility/run-workspaces.d.ts.map +1 -0
- package/build/src/cli/utility/run-workspaces.js +48 -0
- package/build/src/cli/utility/run-workspaces.js.map +1 -0
- package/build/src/lib/corepack.d.ts +2 -1
- package/build/src/lib/corepack.d.ts.map +1 -1
- package/build/src/lib/corepack.js +21 -0
- package/build/src/lib/corepack.js.map +1 -1
- package/build/src/lib/docker-packaging.d.ts +7 -0
- package/build/src/lib/docker-packaging.d.ts.map +1 -0
- package/build/src/{cli/generate/docker-image/index.js → lib/docker-packaging.js} +22 -96
- package/build/src/lib/docker-packaging.js.map +1 -0
- package/build/src/lib/ignore-files.d.ts +5 -0
- package/build/src/lib/ignore-files.d.ts.map +1 -0
- package/build/src/lib/ignore-files.js +77 -0
- package/build/src/lib/ignore-files.js.map +1 -0
- package/build/src/lib/item.d.ts +3 -1
- package/build/src/lib/item.d.ts.map +1 -1
- package/build/src/lib/item.js +21 -0
- package/build/src/lib/item.js.map +1 -1
- package/build/src/lib/nova-config.d.ts +3 -1
- package/build/src/lib/nova-config.d.ts.map +1 -1
- package/build/src/lib/nova-config.js +163 -11
- package/build/src/lib/nova-config.js.map +1 -1
- package/build/src/lib/package-scripts.d.ts +11 -0
- package/build/src/lib/package-scripts.d.ts.map +1 -0
- package/build/src/lib/package-scripts.js +227 -0
- package/build/src/lib/package-scripts.js.map +1 -0
- package/build/src/lib/regex.d.ts +3 -1
- package/build/src/lib/regex.d.ts.map +1 -1
- package/build/src/lib/regex.js +5 -3
- package/build/src/lib/regex.js.map +1 -1
- package/build/src/lib/run-scripts.d.ts +0 -1
- package/build/src/lib/run-scripts.d.ts.map +1 -1
- package/build/src/lib/run-scripts.js +9 -12
- package/build/src/lib/run-scripts.js.map +1 -1
- package/build/src/lib/run-workspaces-cache.d.ts +7 -0
- package/build/src/lib/run-workspaces-cache.d.ts.map +1 -0
- package/build/src/lib/run-workspaces-cache.js +168 -0
- package/build/src/lib/run-workspaces-cache.js.map +1 -0
- package/build/src/lib/run-workspaces.d.ts +18 -0
- package/build/src/lib/run-workspaces.d.ts.map +1 -0
- package/build/src/lib/run-workspaces.js +782 -0
- package/build/src/lib/run-workspaces.js.map +1 -0
- package/build/src/lib/scaffold-presentation.d.ts.map +1 -1
- package/build/src/lib/scaffold-presentation.js.map +1 -1
- package/build/src/lib/scaffold-versions.d.ts +4 -0
- package/build/src/lib/scaffold-versions.d.ts.map +1 -0
- package/build/src/lib/scaffold-versions.js +17 -0
- package/build/src/lib/scaffold-versions.js.map +1 -0
- package/build/src/lib/scaffold.d.ts.map +1 -1
- package/build/src/lib/scaffold.js +133 -130
- package/build/src/lib/scaffold.js.map +1 -1
- package/build/src/lib/transpile.d.ts.map +1 -1
- package/build/src/lib/transpile.js +4 -3
- package/build/src/lib/transpile.js.map +1 -1
- package/build/src/lib/type-check.d.ts +2 -1
- package/build/src/lib/type-check.d.ts.map +1 -1
- package/build/src/lib/type-check.js +22 -4
- package/build/src/lib/type-check.js.map +1 -1
- package/build/src/lib/type-declaration-engine.d.ts.map +1 -1
- package/build/src/lib/type-declaration-engine.js +57 -30
- package/build/src/lib/type-declaration-engine.js.map +1 -1
- package/build/src/lib/utility.d.ts +2 -2
- package/build/src/lib/utility.d.ts.map +1 -1
- package/build/src/lib/utility.js +28 -5
- package/build/src/lib/utility.js.map +1 -1
- package/build/src/presets/eslint/index.d.ts +1 -0
- package/build/src/presets/eslint/index.d.ts.map +1 -1
- package/build/src/presets/eslint/index.js +1 -0
- package/build/src/presets/eslint/index.js.map +1 -1
- package/build/src/presets/eslint/nova-rules.d.ts +4 -0
- package/build/src/presets/eslint/nova-rules.d.ts.map +1 -0
- package/build/src/{rules → presets}/eslint/nova-rules.js +48 -48
- package/build/src/presets/eslint/nova-rules.js.map +1 -0
- package/build/src/rules/eslint/index.d.ts +0 -1
- package/build/src/rules/eslint/index.d.ts.map +1 -1
- package/build/src/rules/eslint/index.js +0 -1
- package/build/src/rules/eslint/index.js.map +1 -1
- package/build/src/rules/eslint/jsdoc/require-jsdoc-body.d.ts.map +1 -1
- package/build/src/rules/eslint/jsdoc/require-jsdoc-body.js +2 -1
- package/build/src/rules/eslint/jsdoc/require-jsdoc-body.js.map +1 -1
- package/build/src/rules/eslint/jsdoc/require-jsdoc-hierarchy.d.ts.map +1 -1
- package/build/src/rules/eslint/jsdoc/require-jsdoc-hierarchy.js +7 -5
- package/build/src/rules/eslint/jsdoc/require-jsdoc-hierarchy.js.map +1 -1
- package/build/src/rules/eslint/jsdoc/require-jsdoc-presence.d.ts.map +1 -1
- package/build/src/rules/eslint/jsdoc/require-jsdoc-presence.js +3 -2
- package/build/src/rules/eslint/jsdoc/require-jsdoc-presence.js.map +1 -1
- package/build/src/rules/eslint/jsdoc/require-jsdoc-returns.d.ts +2 -1
- package/build/src/rules/eslint/jsdoc/require-jsdoc-returns.d.ts.map +1 -1
- package/build/src/rules/eslint/jsdoc/require-jsdoc-returns.js +87 -1
- package/build/src/rules/eslint/jsdoc/require-jsdoc-returns.js.map +1 -1
- package/build/src/rules/vitest/dotenv/register.js +1 -1
- package/build/src/rules/vitest/dotenv/register.js.map +1 -1
- package/build/src/rules/vitest/dotenv/rules.js +2 -2
- package/build/src/rules/vitest/dotenv/rules.js.map +1 -1
- package/build/src/rules/vitest/frontmatter/register.js +1 -1
- package/build/src/rules/vitest/frontmatter/register.js.map +1 -1
- package/build/src/rules/vitest/frontmatter/rules.js +2 -2
- package/build/src/rules/vitest/frontmatter/rules.js.map +1 -1
- package/build/src/rules/vitest/index.d.ts +2 -1
- package/build/src/rules/vitest/index.d.ts.map +1 -1
- package/build/src/rules/vitest/index.js +1 -0
- package/build/src/rules/vitest/index.js.map +1 -1
- package/build/src/rules/vitest/internal/active-vitest.d.ts +5 -0
- package/build/src/rules/vitest/internal/active-vitest.d.ts.map +1 -0
- package/build/src/rules/vitest/internal/active-vitest.js.map +1 -0
- package/build/src/rules/vitest/internal/is-enabled.d.ts +3 -0
- package/build/src/rules/vitest/internal/is-enabled.d.ts.map +1 -0
- package/build/src/rules/vitest/{enable.js → internal/is-enabled.js} +1 -1
- package/build/src/rules/vitest/internal/is-enabled.js.map +1 -0
- package/build/src/rules/vitest/link/register.js +1 -1
- package/build/src/rules/vitest/link/register.js.map +1 -1
- package/build/src/rules/vitest/link/rules.js +2 -2
- package/build/src/rules/vitest/link/rules.js.map +1 -1
- package/build/src/rules/vitest/markdown-table/register.js +1 -1
- package/build/src/rules/vitest/markdown-table/register.js.map +1 -1
- package/build/src/rules/vitest/markdown-table/rules.js +2 -2
- package/build/src/rules/vitest/markdown-table/rules.js.map +1 -1
- package/build/src/rules/vitest/package-scripts/register.d.ts +3 -0
- package/build/src/rules/vitest/package-scripts/register.d.ts.map +1 -0
- package/build/src/rules/vitest/package-scripts/register.js +23 -0
- package/build/src/rules/vitest/package-scripts/register.js.map +1 -0
- package/build/src/rules/vitest/package-scripts/rules.d.ts +3 -0
- package/build/src/rules/vitest/package-scripts/rules.d.ts.map +1 -0
- package/build/src/rules/vitest/package-scripts/rules.js +28 -0
- package/build/src/rules/vitest/package-scripts/rules.js.map +1 -0
- package/build/src/rules/vitest/terminology/register.js +1 -1
- package/build/src/rules/vitest/terminology/register.js.map +1 -1
- package/build/src/rules/vitest/terminology/rules.js +2 -2
- package/build/src/rules/vitest/terminology/rules.js.map +1 -1
- package/build/src/rules/vitest/type-declarations/register.js +1 -1
- package/build/src/rules/vitest/type-declarations/register.js.map +1 -1
- package/build/src/rules/vitest/type-declarations/rules.d.ts.map +1 -1
- package/build/src/rules/vitest/type-declarations/rules.js +50 -21
- package/build/src/rules/vitest/type-declarations/rules.js.map +1 -1
- package/build/src/types/cli/generate/github/workflows-blueprint.d.ts +1 -15
- package/build/src/types/cli/generate/must-haves/ignore-files.d.ts +56 -0
- package/build/src/types/cli/index.d.ts +23 -7
- package/build/src/types/cli/recipe/index.d.ts +2 -1
- package/build/src/types/cli/recipe/miscellaneous/fix-markdown-tables.d.ts +4 -4
- package/build/src/types/cli/recipe/miscellaneous/remove-operating-system-files.d.ts +134 -0
- package/build/src/types/cli/recipe/package-json/normalize-tooling.d.ts +33 -17
- package/build/src/types/cli/scaffold/app/apple.d.ts +59 -0
- package/build/src/types/cli/scaffold/app/astro.d.ts +2 -3
- package/build/src/types/cli/scaffold/app/discord-bot.d.ts +1 -2
- package/build/src/types/cli/scaffold/app/expressjs.d.ts +2 -2
- package/build/src/types/cli/scaffold/app/nextjs.d.ts +2 -2
- package/build/src/types/cli/scaffold/app/vite.d.ts +2 -2
- package/build/src/types/cli/scaffold/docs/docusaurus.d.ts +4 -4
- package/build/src/types/cli/scaffold/package/homebridge.d.ts +1 -2
- package/build/src/types/cli/scaffold/tool/serverless.d.ts +51 -0
- package/build/src/types/cli/utility/changelog.d.ts +15 -3
- package/build/src/types/cli/utility/configure.d.ts +847 -78
- package/build/src/types/cli/utility/run-recipes.d.ts +2 -2
- package/build/src/types/cli/utility/run-workspaces.d.ts +57 -0
- package/build/src/types/lib/corepack.d.ts +19 -0
- package/build/src/types/lib/docker-packaging.d.ts +69 -0
- package/build/src/types/lib/env-managed-set.d.ts +2 -2
- package/build/src/types/lib/env-status.d.ts +2 -2
- package/build/src/types/lib/ignore-files.d.ts +86 -0
- package/build/src/types/lib/item.d.ts +25 -1
- package/build/src/types/lib/nova-config.d.ts +375 -102
- package/build/src/types/lib/package-scripts.d.ts +172 -0
- package/build/src/types/lib/regex.d.ts +7 -0
- package/build/src/types/lib/run-scripts.d.ts +10 -12
- package/build/src/types/lib/run-workspaces-cache.d.ts +259 -0
- package/build/src/types/lib/run-workspaces.d.ts +664 -0
- package/build/src/types/lib/scaffold-presentation.d.ts +6 -4
- package/build/src/types/lib/scaffold-versions.d.ts +30 -0
- package/build/src/types/lib/scaffold.d.ts +54 -37
- package/build/src/types/lib/transpile.d.ts +12 -4
- package/build/src/types/lib/type-check.d.ts +20 -3
- package/build/src/types/lib/type-declaration-engine.d.ts +54 -12
- package/build/src/types/lib/utility.d.ts +14 -0
- package/build/src/types/presets/eslint/nova-rules.d.ts +10 -0
- package/build/src/types/rules/eslint/jsdoc/require-jsdoc-body.d.ts +2 -0
- package/build/src/types/rules/eslint/jsdoc/require-jsdoc-hierarchy.d.ts +4 -0
- package/build/src/types/rules/eslint/jsdoc/require-jsdoc-presence.d.ts +2 -0
- package/build/src/types/rules/eslint/jsdoc/require-jsdoc-returns.d.ts +71 -0
- package/build/src/types/rules/vitest/index.d.ts +56 -0
- package/build/src/types/rules/vitest/internal/active-vitest.d.ts +31 -0
- package/build/src/types/rules/vitest/internal/is-enabled.d.ts +12 -0
- package/build/src/types/rules/vitest/package-scripts/register.d.ts +41 -0
- package/build/src/types/rules/vitest/package-scripts/rules.d.ts +24 -0
- package/build/src/types/rules/vitest/type-declarations/rules.d.ts +8 -0
- package/build/src/types/shared.d.ts +589 -155
- package/build/src/types/tests/cli/generate/github/workflows-blueprint-publish-parity.test.d.ts +8 -8
- package/build/src/types/tests/cli/generate/github/workflows-blueprint.test.d.ts +2 -2
- package/build/src/types/tests/cli/generate/must-haves/ignore-files.test.d.ts +46 -0
- package/build/src/types/tests/cli/index.test.d.ts +57 -24
- package/build/src/types/tests/cli/recipe/miscellaneous/remove-operating-system-files.test.d.ts +84 -0
- package/build/src/types/tests/cli/recipe/package-json/normalize-tooling.test.d.ts +36 -0
- package/build/src/types/tests/cli/scaffold/app/apple.test.d.ts +99 -0
- package/build/src/types/tests/cli/scaffold/starter/base.test.d.ts +9 -9
- package/build/src/types/tests/cli/scaffold/tool/serverless.test.d.ts +98 -0
- package/build/src/types/tests/cli/utility/changelog.test.d.ts +27 -27
- package/build/src/types/tests/cli/utility/configure.test.d.ts +237 -1
- package/build/src/types/tests/cli/utility/run-workspaces.test.d.ts +193 -0
- package/build/src/types/tests/cli/utility/type-check.test.d.ts +13 -0
- package/build/src/types/tests/lib/docker-packaging.test.d.ts +43 -0
- package/build/src/types/tests/lib/ignore-files.test.d.ts +69 -0
- package/build/src/types/tests/lib/item.test.d.ts +7 -0
- package/build/src/types/tests/lib/nova-config-ignore-files.test.d.ts +46 -0
- package/build/src/types/tests/lib/nova-config-run-workspaces-cache.test.d.ts +31 -0
- package/build/src/types/tests/lib/nova-config.test.d.ts +1 -29
- package/build/src/types/tests/lib/package-scripts.test.d.ts +32 -0
- package/build/src/types/tests/lib/utility.test.d.ts +23 -0
- package/build/src/types/tests/lib/workflow-templates.test.d.ts +0 -12
- package/build/src/types/tests/presets/eslint/nova-rules.test.d.ts +45 -0
- package/build/src/types/tests/rules/vitest/internal/active-vitest.test.d.ts +56 -0
- package/build/src/types/tests/rules/vitest/internal/is-enabled.test.d.ts +27 -0
- package/build/src/types/tests/rules/vitest/package-scripts.test.d.ts +6 -0
- package/build/src/types/tests/scaffold-output-contract.test.d.ts +37 -15
- package/build/src/types/tests/scaffold-version-catalog.test.d.ts +101 -0
- package/build/src/types/tests/scaffold-version-drift.test.d.ts +9 -3
- package/build/src/types/tests/since-version.test.d.ts +3 -1
- package/build/src/types/tests/tsconfig-presets.test.d.ts +6 -2
- package/build/src/types/tests/type-declarations.test.d.ts +198 -105
- package/build/templates/generators/must-haves/ignore-files/cloudflare-astro.assetsignore +5 -0
- package/build/templates/generators/must-haves/{gitignore → ignore-files}/gitignore +0 -5
- package/build/templates/scaffold/app/android/eslint.config.mts +1 -1
- package/build/templates/scaffold/app/android/package.json +10 -10
- package/build/templates/scaffold/app/android/vitest.config.mts +1 -0
- package/build/templates/scaffold/app/apple/package.json +13 -12
- package/build/templates/scaffold/app/apple/project.yml +5 -6
- package/build/templates/scaffold/app/apple/scripts/run-apple.mjs +114 -0
- package/build/templates/scaffold/app/astro/eslint.config.mts +1 -1
- package/build/templates/scaffold/app/astro/package.json +15 -15
- package/build/templates/scaffold/app/astro/tsconfig.tests.json +2 -1
- package/build/templates/scaffold/app/astro/vitest.config.mts +1 -0
- package/build/templates/scaffold/app/discord-bot/eslint.config.mts +1 -1
- package/build/templates/scaffold/app/discord-bot/package.json +14 -14
- package/build/templates/scaffold/app/express/eslint.config.mts +1 -1
- package/build/templates/scaffold/app/express/package.json +15 -15
- package/build/templates/scaffold/app/nextjs/eslint.config.mts +1 -1
- package/build/templates/scaffold/app/nextjs/package.json +17 -17
- package/build/templates/scaffold/app/nextjs/tsconfig.tests.json +2 -1
- package/build/templates/scaffold/app/nextjs/vitest.config.mts +1 -0
- package/build/templates/scaffold/app/vite/eslint.config.mts +1 -1
- package/build/templates/scaffold/app/vite/package.json +13 -13
- package/build/templates/scaffold/app/vite/vitest.config.mts +1 -0
- package/build/templates/scaffold/docs/docusaurus/eslint.config.mts +1 -1
- package/build/templates/scaffold/docs/docusaurus/package.json +22 -22
- package/build/templates/scaffold/package/github-action/eslint.config.mts +1 -1
- package/build/templates/scaffold/package/github-action/package.json +15 -16
- package/build/templates/scaffold/package/homebridge/bin/repl.mjs +33 -0
- package/build/templates/scaffold/package/homebridge/bin/test-api.mjs +33 -0
- package/build/templates/scaffold/package/homebridge/eslint.config.mts +1 -1
- package/build/templates/scaffold/package/homebridge/package.json +23 -14
- package/build/templates/scaffold/package/homebridge/src/cli/presentation.ts +65 -0
- package/build/templates/scaffold/package/homebridge/src/cli/repl.ts +51 -0
- package/build/templates/scaffold/package/homebridge/src/cli/test-api.ts +134 -0
- package/build/templates/scaffold/package/homebridge/src/types/cli/presentation.d.ts +21 -0
- package/build/templates/scaffold/package/homebridge/src/types/cli/repl.d.ts +12 -0
- package/build/templates/scaffold/package/homebridge/src/types/cli/test-api.d.ts +38 -0
- package/build/templates/scaffold/package/homebridge/tsconfig.tests.json +2 -1
- package/build/templates/scaffold/package/homebridge/vitest.config.mts +1 -0
- package/build/templates/scaffold/package/pfsense/eslint.config.mts +1 -1
- package/build/templates/scaffold/package/pfsense/package.json +11 -11
- package/build/templates/scaffold/package/pfsense/vitest.config.mts +1 -0
- package/build/templates/scaffold/starter/base/eslint.config.mts +1 -1
- package/build/templates/scaffold/starter/base/tests/project.test.ts +8 -0
- package/build/templates/scaffold/{app/cloudflare-workers → tool/serverless}/vitest.config.mts +3 -2
- package/build/templates/scaffold-options/app/android-native/app/build.gradle.kts +3 -3
- package/build/templates/scaffold-options/app/android-native/gradle/libs.versions.toml +10 -10
- package/build/templates/scaffold-options/app/android-native/gradle/wrapper/gradle-wrapper.properties +2 -2
- package/build/templates/scaffold-options/app/android-native/settings.gradle.kts +1 -1
- package/build/templates/{generators → scaffold-options}/docker-image/astro-node/Dockerfile +2 -2
- package/build/templates/{generators → scaffold-options}/docker-image/container-native/Dockerfile +1 -1
- package/build/templates/{generators → scaffold-options}/docker-image/nextjs-standalone/Dockerfile +2 -2
- package/build/templates/{generators → scaffold-options}/docker-image/node/Dockerfile +2 -2
- package/build/templates/{generators → scaffold-options}/docker-image/static-site/Dockerfile +2 -2
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/eslint.config.mts +66 -0
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/package.json +67 -0
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/types/worker/index.d.ts +19 -0
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/types/worker/index.test.d.ts +6 -0
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/index.test.ts +23 -0
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/index.ts +28 -0
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/tsconfig.cli.json +26 -0
- package/build/templates/{scaffold/app/docker-image → scaffold-options/tool/serverless/cloudflare-workers}/tsconfig.tests.json +2 -0
- package/build/templates/{scaffold/app → scaffold-options/tool/serverless}/cloudflare-workers/tsconfig.worker.json +10 -3
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/wrangler.build.toml +3 -0
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/wrangler.toml +3 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/api/index.test.ts +23 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/api/index.ts +20 -0
- package/build/templates/{scaffold/package/node-cli → scaffold-options/tool/serverless/vercel-functions}/eslint.config.mts +5 -3
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/package.json +66 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/api/index.d.ts +8 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/api/index.test.d.ts +6 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/tsconfig.cli.json +26 -0
- package/build/templates/{scaffold/package/node-cli/tsconfig.source.json → scaffold-options/tool/serverless/vercel-functions/tsconfig.functions.json} +5 -3
- package/build/templates/{scaffold/package/node-cli → scaffold-options/tool/serverless/vercel-functions}/tsconfig.tests.json +1 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/vercel.json +3 -0
- package/package.json +5 -6
- package/build/src/cli/generate/docker-image/index.d.ts +0 -9
- package/build/src/cli/generate/docker-image/index.d.ts.map +0 -1
- package/build/src/cli/generate/docker-image/index.js.map +0 -1
- package/build/src/cli/generate/must-haves/gitignore.d.ts +0 -5
- package/build/src/cli/generate/must-haves/gitignore.d.ts.map +0 -1
- package/build/src/cli/generate/must-haves/gitignore.js +0 -61
- package/build/src/cli/generate/must-haves/gitignore.js.map +0 -1
- package/build/src/cli/scaffold/app/cloudflare-workers.d.ts +0 -5
- package/build/src/cli/scaffold/app/cloudflare-workers.d.ts.map +0 -1
- package/build/src/cli/scaffold/app/cloudflare-workers.js +0 -14
- package/build/src/cli/scaffold/app/cloudflare-workers.js.map +0 -1
- package/build/src/cli/scaffold/app/docker-image.d.ts +0 -6
- package/build/src/cli/scaffold/app/docker-image.d.ts.map +0 -1
- package/build/src/cli/scaffold/app/docker-image.js +0 -93
- package/build/src/cli/scaffold/app/docker-image.js.map +0 -1
- package/build/src/cli/scaffold/package/node-cli.d.ts +0 -5
- package/build/src/cli/scaffold/package/node-cli.d.ts.map +0 -1
- package/build/src/cli/scaffold/package/node-cli.js +0 -14
- package/build/src/cli/scaffold/package/node-cli.js.map +0 -1
- package/build/src/rules/eslint/nova-rules.d.ts +0 -4
- package/build/src/rules/eslint/nova-rules.d.ts.map +0 -1
- package/build/src/rules/eslint/nova-rules.js.map +0 -1
- package/build/src/rules/vitest/active-vitest.d.ts +0 -5
- package/build/src/rules/vitest/active-vitest.d.ts.map +0 -1
- package/build/src/rules/vitest/active-vitest.js.map +0 -1
- package/build/src/rules/vitest/enable.d.ts +0 -3
- package/build/src/rules/vitest/enable.d.ts.map +0 -1
- package/build/src/rules/vitest/enable.js.map +0 -1
- package/build/src/types/cli/generate/docker-image/index.d.ts +0 -105
- package/build/src/types/cli/generate/must-haves/gitignore.d.ts +0 -48
- package/build/src/types/cli/scaffold/app/cloudflare-workers.d.ts +0 -27
- package/build/src/types/cli/scaffold/app/docker-image.d.ts +0 -47
- package/build/src/types/cli/scaffold/package/node-cli.d.ts +0 -22
- package/build/src/types/rules/eslint/nova-rules.d.ts +0 -10
- package/build/src/types/rules/vitest/active-vitest.d.ts +0 -31
- package/build/src/types/rules/vitest/enable.d.ts +0 -12
- package/build/src/types/tests/cli/generate/docker-image.test.d.ts +0 -43
- package/build/src/types/tests/cli/generate/must-haves/gitignore.test.d.ts +0 -27
- package/build/src/types/tests/cli/scaffold/app/cloudflare-workers.test.d.ts +0 -85
- package/build/src/types/tests/rules/eslint/nova-rules.test.d.ts +0 -45
- package/build/src/types/tests/rules/vitest/active-vitest.test.d.ts +0 -56
- package/build/src/types/tests/rules/vitest/enable.test.d.ts +0 -27
- package/build/templates/generators/github/workflows/check-sponsor-gated-issues/base.yml +0 -54
- package/build/templates/generators/github/workflows/check-sponsor-gated-issues/triggers/issue-comment.yml +0 -5
- package/build/templates/generators/github/workflows/check-sponsor-gated-issues/triggers/issues.yml +0 -5
- package/build/templates/generators/github/workflows/lock-inactive-issues/base.yml +0 -45
- package/build/templates/generators/github/workflows/lock-inactive-issues/triggers/schedule-daily.yml +0 -5
- package/build/templates/generators/github/workflows/lock-inactive-issues/triggers/schedule-monthly.yml +0 -5
- package/build/templates/generators/github/workflows/lock-inactive-issues/triggers/schedule-weekly.yml +0 -5
- package/build/templates/generators/github/workflows/publish/base.yml +0 -61
- package/build/templates/generators/github/workflows/publish/targets/cloudflare-pages-docusaurus.yml +0 -29
- package/build/templates/generators/github/workflows/publish/targets/cloudflare-workers.yml +0 -36
- package/build/templates/generators/github/workflows/publish/targets/docker-hub.yml +0 -48
- package/build/templates/generators/github/workflows/publish/targets/ghcr.yml +0 -48
- package/build/templates/generators/github/workflows/publish/targets/github-action.yml +0 -122
- package/build/templates/generators/github/workflows/publish/targets/github-packages.yml +0 -85
- package/build/templates/generators/github/workflows/publish/targets/github-pages-docusaurus.yml +0 -44
- package/build/templates/generators/github/workflows/publish/targets/npm.yml +0 -61
- package/build/templates/generators/github/workflows/publish/targets/vercel-nextjs.yml +0 -45
- package/build/templates/generators/github/workflows/publish/triggers/release.yml +0 -5
- package/build/templates/generators/github/workflows/publish/triggers/workflow-run-any.yml +0 -7
- package/build/templates/generators/github/workflows/publish/triggers/workflow-run-failure.yml +0 -8
- package/build/templates/generators/github/workflows/publish/triggers/workflow-run-success.yml +0 -8
- package/build/templates/scaffold/app/android/tests/project.test.ts +0 -24
- package/build/templates/scaffold/app/astro/tests/project.test.ts +0 -24
- package/build/templates/scaffold/app/cloudflare-workers/eslint.config.mts +0 -42
- package/build/templates/scaffold/app/cloudflare-workers/package.json +0 -37
- package/build/templates/scaffold/app/cloudflare-workers/src/index.ts +0 -30
- package/build/templates/scaffold/app/cloudflare-workers/src/types/index.d.ts +0 -19
- package/build/templates/scaffold/app/cloudflare-workers/tests/project.test.ts +0 -24
- package/build/templates/scaffold/app/cloudflare-workers/tsconfig.tests.json +0 -20
- package/build/templates/scaffold/app/cloudflare-workers/wrangler.toml +0 -3
- package/build/templates/scaffold/app/discord-bot/tests/project.test.ts +0 -24
- package/build/templates/scaffold/app/docker-image/eslint.config.mts +0 -41
- package/build/templates/scaffold/app/docker-image/package.json +0 -33
- package/build/templates/scaffold/app/docker-image/tests/project.test.ts +0 -24
- package/build/templates/scaffold/app/docker-image/vitest.config.mts +0 -15
- package/build/templates/scaffold/app/express/tests/project.test.ts +0 -24
- package/build/templates/scaffold/app/nextjs/tests/project.test.ts +0 -24
- package/build/templates/scaffold/app/vite/tests/project.test.ts +0 -24
- package/build/templates/scaffold/package/homebridge/tests/project.test.ts +0 -24
- package/build/templates/scaffold/package/node-cli/package.json +0 -47
- package/build/templates/scaffold/package/node-cli/tsconfig.config.json +0 -17
- package/build/templates/scaffold/package/node-cli/vitest.config.mts +0 -18
- package/build/templates/scaffold/package/pfsense/tests/project.test.ts +0 -56
- package/build/templates/scaffold/package/pfsense/tests/types/project.test.d.ts +0 -6
- /package/build/src/rules/vitest/{active-vitest.js → internal/active-vitest.js} +0 -0
- /package/build/templates/{generators → scaffold-options}/docker-image/astro-node/compose.yml +0 -0
- /package/build/templates/{generators → scaffold-options}/docker-image/background-service/compose.yml +0 -0
- /package/build/templates/{generators → scaffold-options}/docker-image/container-native/compose.yml +0 -0
- /package/build/templates/{generators → scaffold-options}/docker-image/http-service/compose.yml +0 -0
- /package/build/templates/{generators → scaffold-options}/docker-image/nextjs-standalone/compose.yml +0 -0
- /package/build/templates/{generators → scaffold-options}/docker-image/static-site/compose.yml +0 -0
- /package/build/templates/{scaffold/package/node-cli → scaffold-options/package/node-cli-core}/bin/cli.mjs +0 -0
- /package/build/templates/{scaffold/package/node-cli → scaffold-options/package/node-cli-core}/src/index.ts +0 -0
- /package/build/templates/{scaffold/package/node-cli → scaffold-options/package/node-cli-core}/src/program.ts +0 -0
- /package/build/templates/{scaffold/package/node-cli → scaffold-options/package/node-cli-core}/src/status.test.ts +0 -0
- /package/build/templates/{scaffold/package/node-cli → scaffold-options/package/node-cli-core}/src/status.ts +0 -0
- /package/build/templates/{scaffold/package/node-cli → scaffold-options/package/node-cli-core}/src/types/program.d.ts +0 -0
- /package/build/templates/{scaffold/package/node-cli → scaffold-options/package/node-cli-core}/src/types/status.d.ts +0 -0
- /package/build/templates/{scaffold/app → scaffold-options/tool/serverless}/cloudflare-workers/tsconfig.config.json +0 -0
- /package/build/templates/{scaffold/app/docker-image → scaffold-options/tool/serverless/vercel-functions}/tsconfig.config.json +0 -0
|
@@ -7,11 +7,12 @@ import { libEnvManagedSet } from '../../lib/env-managed-set.js';
|
|
|
7
7
|
import { libEnvNamespace } from '../../lib/env-namespace.js';
|
|
8
8
|
import { libEnvReconcile } from '../../lib/env-reconcile.js';
|
|
9
9
|
import { libEnvStatus } from '../../lib/env-status.js';
|
|
10
|
-
import {
|
|
10
|
+
import { getSupportedIgnoreFileBundles, isSupportedIgnoreFileConfigPath, } from '../../lib/ignore-files.js';
|
|
11
|
+
import { libItemAllowedAgents, libItemAllowedPoliciesByRole, libItemAllowedRecipes, libItemOperatingSystemFilePatterns, libItemOperatingSystemFilesByPlatform, libItemRecipesByCategory, libItemSyncRoles, libItemValidEntityRoles, } from '../../lib/item.js';
|
|
11
12
|
import { Runner as LibNovaConfig } from '../../lib/nova-config.js';
|
|
12
|
-
import { LIB_REGEX_LINEBREAK_CRLF_OR_LF, LIB_REGEX_PATTERN_EMAIL_SIMPLE, LIB_REGEX_PATTERN_ENV_VAR_KEY, LIB_REGEX_PATTERN_SLUG_SCOPED, LIB_REGEX_PATTERN_SLUG_SIMPLE, LIB_REGEX_PATTERN_YML_EXTENSION, } from '../../lib/regex.js';
|
|
13
|
+
import { LIB_REGEX_LINEBREAK_CRLF_OR_LF, LIB_REGEX_PATTERN_EMAIL_SIMPLE, LIB_REGEX_PATTERN_ENV_VAR_KEY, LIB_REGEX_PATTERN_GITHUB_LABEL_COLOR, LIB_REGEX_PATTERN_SLUG_SCOPED, LIB_REGEX_PATTERN_SLUG_SIMPLE, LIB_REGEX_PATTERN_YML_EXTENSION, } from '../../lib/regex.js';
|
|
13
14
|
import { Runner as LibReleaseHistory } from '../../lib/release-history.js';
|
|
14
|
-
import { discoverPathsWithFile, pathExists, resolveTemplatePath } from '../../lib/utility.js';
|
|
15
|
+
import { discoverPathsWithFile, isPlainObject, pathExists, resolveTemplatePath, } from '../../lib/utility.js';
|
|
15
16
|
import { libWorkflowTemplatesMetadata } from '../../lib/workflow-templates.js';
|
|
16
17
|
import { Logger } from '../../toolkit/index.js';
|
|
17
18
|
export class Runner {
|
|
@@ -73,12 +74,125 @@ export class Runner {
|
|
|
73
74
|
await novaConfig.save(isReplaceFile);
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
77
|
+
static getOptionalBooleanInitial(value) {
|
|
78
|
+
if (value === undefined) {
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
return (value === true) ? 1 : 2;
|
|
82
|
+
}
|
|
83
|
+
static isBooleanRecordInput(value) {
|
|
84
|
+
if (typeof value !== 'string') {
|
|
85
|
+
return 'Enter a JSON object with boolean values.';
|
|
86
|
+
}
|
|
87
|
+
const trimmed = value.trim();
|
|
88
|
+
if (trimmed === '') {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const parsed = JSON.parse(trimmed);
|
|
93
|
+
if (isPlainObject(parsed) === false
|
|
94
|
+
|| Object.values(parsed).some((entry) => typeof entry !== 'boolean') === true) {
|
|
95
|
+
return 'Enter a JSON object whose values are true or false.';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return 'Enter valid JSON, for example {"displayName":true}.';
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
static isIgnoreFilePathInput(value) {
|
|
104
|
+
if (typeof value !== 'string') {
|
|
105
|
+
return 'Enter a project-relative ignore-file path.';
|
|
106
|
+
}
|
|
107
|
+
const trimmed = value.trim();
|
|
108
|
+
if (isSupportedIgnoreFileConfigPath(trimmed) === false) {
|
|
109
|
+
return 'Use a project-relative path ending in .gitignore, .dockerignore, or .assetsignore.';
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
76
113
|
static isNonEmptyLiteralInput(value) {
|
|
77
114
|
if (typeof value === 'string' && value.trim() !== '') {
|
|
78
115
|
return true;
|
|
79
116
|
}
|
|
80
117
|
return 'This field is required.';
|
|
81
118
|
}
|
|
119
|
+
static isOptionalNonnegativeIntegerInput(value) {
|
|
120
|
+
if (typeof value !== 'string') {
|
|
121
|
+
return 'Enter a whole number or leave the field blank.';
|
|
122
|
+
}
|
|
123
|
+
const trimmed = value.trim();
|
|
124
|
+
if (trimmed === '') {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
const parsed = Number.parseInt(trimmed, 10);
|
|
128
|
+
if (Number.isInteger(parsed) === false
|
|
129
|
+
|| parsed < 0
|
|
130
|
+
|| `${parsed}` !== trimmed) {
|
|
131
|
+
return 'Enter a whole number greater than or equal to zero.';
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
static isStringArrayInput(value) {
|
|
136
|
+
if (typeof value !== 'string') {
|
|
137
|
+
return 'Enter a JSON array of strings.';
|
|
138
|
+
}
|
|
139
|
+
const trimmed = value.trim();
|
|
140
|
+
if (trimmed === '') {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
const parsed = JSON.parse(trimmed);
|
|
145
|
+
if (Array.isArray(parsed) === false
|
|
146
|
+
|| parsed.some((entry) => typeof entry !== 'string') === true) {
|
|
147
|
+
return 'Enter a JSON array whose entries are strings.';
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return 'Enter valid JSON, for example ["main","release/*"].';
|
|
152
|
+
}
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
static isStringRecordInput(value) {
|
|
156
|
+
if (typeof value !== 'string') {
|
|
157
|
+
return 'Enter a JSON object with string values.';
|
|
158
|
+
}
|
|
159
|
+
const trimmed = value.trim();
|
|
160
|
+
if (trimmed === '') {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const parsed = JSON.parse(trimmed);
|
|
165
|
+
if (isPlainObject(parsed) === false
|
|
166
|
+
|| Object.values(parsed).some((entry) => typeof entry !== 'string') === true) {
|
|
167
|
+
return 'Enter a JSON object whose values are strings.';
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return 'Enter valid JSON, for example {"NODE_VERSION":"24"}.';
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
static parseBooleanRecordInput(value) {
|
|
176
|
+
const trimmed = value.trim();
|
|
177
|
+
if (trimmed === '') {
|
|
178
|
+
return {};
|
|
179
|
+
}
|
|
180
|
+
return JSON.parse(trimmed);
|
|
181
|
+
}
|
|
182
|
+
static parseStringArrayInput(value) {
|
|
183
|
+
const trimmed = value.trim();
|
|
184
|
+
if (trimmed === '') {
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
return JSON.parse(trimmed);
|
|
188
|
+
}
|
|
189
|
+
static parseStringRecordInput(value) {
|
|
190
|
+
const trimmed = value.trim();
|
|
191
|
+
if (trimmed === '') {
|
|
192
|
+
return {};
|
|
193
|
+
}
|
|
194
|
+
return JSON.parse(trimmed);
|
|
195
|
+
}
|
|
82
196
|
static async promptFlow(config) {
|
|
83
197
|
const category = {
|
|
84
198
|
project: {
|
|
@@ -99,7 +213,7 @@ export class Runner {
|
|
|
99
213
|
github: {
|
|
100
214
|
label: 'GitHub',
|
|
101
215
|
description: 'Configure GitHub repository settings, recipes, and policies.',
|
|
102
|
-
handler: Runner['
|
|
216
|
+
handler: Runner['promptGithubMenu'],
|
|
103
217
|
},
|
|
104
218
|
workflows: {
|
|
105
219
|
label: 'Workflows',
|
|
@@ -121,16 +235,21 @@ export class Runner {
|
|
|
121
235
|
description: 'Review workspace packages, assigning roles and policies.',
|
|
122
236
|
handler: Runner['promptWorkspaces'],
|
|
123
237
|
},
|
|
124
|
-
|
|
125
|
-
label: '
|
|
126
|
-
description: 'Manage project-specific
|
|
127
|
-
handler: Runner['
|
|
238
|
+
ignoreFiles: {
|
|
239
|
+
label: 'Ignore Files',
|
|
240
|
+
description: 'Manage project-specific physical ignore-file patterns.',
|
|
241
|
+
handler: Runner['promptIgnoreFiles'],
|
|
128
242
|
},
|
|
129
243
|
agents: {
|
|
130
244
|
label: 'AI Tools',
|
|
131
245
|
description: 'Select the AI tools (Claude Code, Codex) to generate conventions for.',
|
|
132
246
|
handler: Runner['promptAgents'],
|
|
133
247
|
},
|
|
248
|
+
recipes: {
|
|
249
|
+
label: 'Recipes',
|
|
250
|
+
description: 'Configure every recipe category, toggle, and recipe-specific setting.',
|
|
251
|
+
handler: Runner['promptRecipes'],
|
|
252
|
+
},
|
|
134
253
|
environment: {
|
|
135
254
|
label: 'Environment',
|
|
136
255
|
description: 'Manage environment variables and secrets, prefixes, and GitHub provisioning.',
|
|
@@ -1017,74 +1136,47 @@ export class Runner {
|
|
|
1017
1136
|
const recipesOutputResult = recipesOutput['result'];
|
|
1018
1137
|
const githubRecipesInput = {
|
|
1019
1138
|
'sync-actions': {
|
|
1139
|
+
...((existingRecipes !== undefined && existingRecipes['sync-actions'] !== undefined) ? existingRecipes['sync-actions'] : {}),
|
|
1020
1140
|
enabled: recipesOutputResult.githubRecipeSyncActions,
|
|
1021
1141
|
},
|
|
1022
1142
|
'sync-features': {
|
|
1143
|
+
...((existingRecipes !== undefined && existingRecipes['sync-features'] !== undefined) ? existingRecipes['sync-features'] : {}),
|
|
1023
1144
|
enabled: recipesOutputResult.githubRecipeSyncFeatures,
|
|
1024
1145
|
},
|
|
1025
1146
|
'sync-identity': {
|
|
1147
|
+
...((existingRecipes !== undefined && existingRecipes['sync-identity'] !== undefined) ? existingRecipes['sync-identity'] : {}),
|
|
1026
1148
|
enabled: recipesOutputResult.githubRecipeSyncIdentity,
|
|
1027
1149
|
},
|
|
1028
1150
|
'sync-labels': {
|
|
1151
|
+
...((existingRecipes !== undefined && existingRecipes['sync-labels'] !== undefined) ? existingRecipes['sync-labels'] : {}),
|
|
1029
1152
|
enabled: recipesOutputResult.githubRecipeSyncLabels,
|
|
1030
1153
|
},
|
|
1031
1154
|
'sync-policies': {
|
|
1155
|
+
...((existingRecipes !== undefined && existingRecipes['sync-policies'] !== undefined) ? existingRecipes['sync-policies'] : {}),
|
|
1032
1156
|
enabled: recipesOutputResult.githubRecipeSyncPolicies,
|
|
1033
1157
|
},
|
|
1034
1158
|
'sync-rulesets': {
|
|
1159
|
+
...((existingRecipes !== undefined && existingRecipes['sync-rulesets'] !== undefined) ? existingRecipes['sync-rulesets'] : {}),
|
|
1035
1160
|
enabled: recipesOutputResult.githubRecipeSyncRulesets,
|
|
1036
1161
|
},
|
|
1037
1162
|
'sync-security': {
|
|
1163
|
+
...((existingRecipes !== undefined && existingRecipes['sync-security'] !== undefined) ? existingRecipes['sync-security'] : {}),
|
|
1038
1164
|
enabled: recipesOutputResult.githubRecipeSyncSecurity,
|
|
1039
1165
|
},
|
|
1040
1166
|
};
|
|
1041
1167
|
const existingTopics = github['topics'];
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1044
|
-
const topicsValue = (existingTopics !== undefined) ? existingTopics : [];
|
|
1045
|
-
const topicsInitial = (existingTopics !== undefined) ? 1 : 0;
|
|
1046
|
-
const topicsOutput = await Runner.promptWithCancel({
|
|
1047
|
-
type: 'select',
|
|
1168
|
+
const topicsTextOutput = await Runner.promptWithCancel({
|
|
1169
|
+
type: 'text',
|
|
1048
1170
|
name: 'githubTopics',
|
|
1049
|
-
message: 'GitHub topics (
|
|
1050
|
-
|
|
1051
|
-
{
|
|
1052
|
-
title: 'Skip (don\'t sync this field)',
|
|
1053
|
-
value: 'skip',
|
|
1054
|
-
},
|
|
1055
|
-
{
|
|
1056
|
-
title: topicsTitle,
|
|
1057
|
-
value: topicsValue,
|
|
1058
|
-
},
|
|
1059
|
-
],
|
|
1060
|
-
initial: topicsInitial,
|
|
1171
|
+
message: 'GitHub topics (comma-separated; blank unsets)',
|
|
1172
|
+
initial: (existingTopics !== undefined) ? existingTopics.join(', ') : '',
|
|
1061
1173
|
});
|
|
1062
|
-
if (
|
|
1174
|
+
if (topicsTextOutput['cancelled'] === true) {
|
|
1063
1175
|
return 'back';
|
|
1064
1176
|
}
|
|
1065
|
-
const
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
if (existingTopics !== undefined && existingTopics.length > 0) {
|
|
1069
|
-
githubTopicsInput = existingTopics;
|
|
1070
|
-
}
|
|
1071
|
-
else {
|
|
1072
|
-
const topicsTextOutput = await Runner.promptWithCancel({
|
|
1073
|
-
type: 'text',
|
|
1074
|
-
name: 'githubOwner',
|
|
1075
|
-
message: 'Topics (comma-separated)',
|
|
1076
|
-
initial: '',
|
|
1077
|
-
});
|
|
1078
|
-
if (topicsTextOutput['cancelled'] === true) {
|
|
1079
|
-
return 'back';
|
|
1080
|
-
}
|
|
1081
|
-
const rawTopics = topicsTextOutput['result'].githubOwner;
|
|
1082
|
-
const parsedTopics = rawTopics.split(',').map((t) => t.trim()).filter((t) => t !== '');
|
|
1083
|
-
if (parsedTopics.length > 0) {
|
|
1084
|
-
githubTopicsInput = parsedTopics;
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1177
|
+
const rawTopics = topicsTextOutput['result'].githubTopics;
|
|
1178
|
+
const parsedTopics = rawTopics.split(',').map((topic) => topic.trim()).filter((topic) => topic !== '');
|
|
1179
|
+
const githubTopicsInput = (parsedTopics.length > 0) ? parsedTopics : undefined;
|
|
1088
1180
|
const existingFeatures = github['features'];
|
|
1089
1181
|
let featuresIssuesInitial = 0;
|
|
1090
1182
|
if (existingFeatures !== undefined && existingFeatures['issues'] !== undefined) {
|
|
@@ -1587,106 +1679,1314 @@ export class Runner {
|
|
|
1587
1679
|
}).info('GitHub settings updated.');
|
|
1588
1680
|
return 'back';
|
|
1589
1681
|
}
|
|
1590
|
-
static async
|
|
1591
|
-
const
|
|
1592
|
-
const
|
|
1593
|
-
const
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1682
|
+
static async promptGithubActions(config) {
|
|
1683
|
+
const github = config['github'] ?? {};
|
|
1684
|
+
const existing = github['actions'] ?? {};
|
|
1685
|
+
const output = await Runner.promptWithCancel([
|
|
1686
|
+
{
|
|
1687
|
+
type: 'select',
|
|
1688
|
+
name: 'enabled',
|
|
1689
|
+
message: 'Enable GitHub Actions?',
|
|
1690
|
+
choices: [
|
|
1691
|
+
{
|
|
1692
|
+
title: 'Unset',
|
|
1693
|
+
value: 'unset',
|
|
1694
|
+
},
|
|
1695
|
+
{
|
|
1696
|
+
title: 'Enable',
|
|
1697
|
+
value: true,
|
|
1698
|
+
},
|
|
1699
|
+
{
|
|
1700
|
+
title: 'Disable',
|
|
1701
|
+
value: false,
|
|
1702
|
+
},
|
|
1703
|
+
],
|
|
1704
|
+
initial: Runner.getOptionalBooleanInitial(existing['enabled']),
|
|
1705
|
+
},
|
|
1706
|
+
{
|
|
1707
|
+
type: 'select',
|
|
1708
|
+
name: 'allowedActions',
|
|
1709
|
+
message: 'Which actions may workflows use?',
|
|
1710
|
+
choices: [
|
|
1711
|
+
{
|
|
1712
|
+
title: 'Unset',
|
|
1713
|
+
value: 'unset',
|
|
1714
|
+
},
|
|
1715
|
+
{
|
|
1716
|
+
title: 'All actions',
|
|
1717
|
+
value: 'all',
|
|
1718
|
+
},
|
|
1719
|
+
{
|
|
1720
|
+
title: 'Local actions only',
|
|
1721
|
+
value: 'local-only',
|
|
1722
|
+
},
|
|
1723
|
+
{
|
|
1724
|
+
title: 'Selected actions',
|
|
1725
|
+
value: 'selected',
|
|
1726
|
+
},
|
|
1727
|
+
],
|
|
1728
|
+
initial: (existing['allowedActions'] === undefined) ? 0 : ([
|
|
1729
|
+
'all',
|
|
1730
|
+
'local-only',
|
|
1731
|
+
'selected',
|
|
1732
|
+
].indexOf(existing['allowedActions']) + 1),
|
|
1733
|
+
},
|
|
1734
|
+
{
|
|
1735
|
+
type: 'select',
|
|
1736
|
+
name: 'shaPinningRequired',
|
|
1737
|
+
message: 'Require actions to use full commit SHAs?',
|
|
1738
|
+
choices: [
|
|
1739
|
+
{
|
|
1740
|
+
title: 'Unset',
|
|
1741
|
+
value: 'unset',
|
|
1742
|
+
},
|
|
1743
|
+
{
|
|
1744
|
+
title: 'Require',
|
|
1745
|
+
value: true,
|
|
1746
|
+
},
|
|
1747
|
+
{
|
|
1748
|
+
title: 'Do not require',
|
|
1749
|
+
value: false,
|
|
1750
|
+
},
|
|
1751
|
+
],
|
|
1752
|
+
initial: Runner.getOptionalBooleanInitial(existing['shaPinningRequired']),
|
|
1753
|
+
},
|
|
1754
|
+
{
|
|
1755
|
+
type: 'select',
|
|
1756
|
+
name: 'selectedActionsGithubOwned',
|
|
1757
|
+
message: 'Allow GitHub-owned actions?',
|
|
1758
|
+
choices: [
|
|
1759
|
+
{
|
|
1760
|
+
title: 'Unset',
|
|
1761
|
+
value: 'unset',
|
|
1762
|
+
},
|
|
1763
|
+
{
|
|
1764
|
+
title: 'Allow',
|
|
1765
|
+
value: true,
|
|
1766
|
+
},
|
|
1767
|
+
{
|
|
1768
|
+
title: 'Do not allow',
|
|
1769
|
+
value: false,
|
|
1770
|
+
},
|
|
1771
|
+
],
|
|
1772
|
+
initial: Runner.getOptionalBooleanInitial((existing['selectedActions'] !== undefined) ? existing['selectedActions']['githubOwned'] : undefined),
|
|
1773
|
+
},
|
|
1774
|
+
{
|
|
1775
|
+
type: 'select',
|
|
1776
|
+
name: 'selectedActionsVerified',
|
|
1777
|
+
message: 'Allow verified Marketplace actions?',
|
|
1778
|
+
choices: [
|
|
1779
|
+
{
|
|
1780
|
+
title: 'Unset',
|
|
1781
|
+
value: 'unset',
|
|
1782
|
+
},
|
|
1783
|
+
{
|
|
1784
|
+
title: 'Allow',
|
|
1785
|
+
value: true,
|
|
1786
|
+
},
|
|
1787
|
+
{
|
|
1788
|
+
title: 'Do not allow',
|
|
1789
|
+
value: false,
|
|
1790
|
+
},
|
|
1791
|
+
],
|
|
1792
|
+
initial: Runner.getOptionalBooleanInitial((existing['selectedActions'] !== undefined) ? existing['selectedActions']['verified'] : undefined),
|
|
1793
|
+
},
|
|
1794
|
+
{
|
|
1795
|
+
type: 'text',
|
|
1796
|
+
name: 'selectedActionsPatterns',
|
|
1797
|
+
message: 'Additional allowed action patterns (comma-separated; blank unsets)',
|
|
1798
|
+
initial: (existing['selectedActions'] !== undefined && existing['selectedActions']['patterns'] !== undefined) ? existing['selectedActions']['patterns'].join(', ') : '',
|
|
1799
|
+
},
|
|
1800
|
+
{
|
|
1801
|
+
type: 'select',
|
|
1802
|
+
name: 'defaultWorkflowPermissions',
|
|
1803
|
+
message: 'Default workflow token permissions',
|
|
1804
|
+
choices: [
|
|
1805
|
+
{
|
|
1806
|
+
title: 'Unset',
|
|
1807
|
+
value: 'unset',
|
|
1808
|
+
},
|
|
1809
|
+
{
|
|
1810
|
+
title: 'Read',
|
|
1811
|
+
value: 'read',
|
|
1812
|
+
},
|
|
1813
|
+
{
|
|
1814
|
+
title: 'Write',
|
|
1815
|
+
value: 'write',
|
|
1816
|
+
},
|
|
1817
|
+
],
|
|
1818
|
+
initial: (existing['defaultWorkflowPermissions'] === undefined) ? 0 : ([
|
|
1819
|
+
'read',
|
|
1820
|
+
'write',
|
|
1821
|
+
].indexOf(existing['defaultWorkflowPermissions']) + 1),
|
|
1822
|
+
},
|
|
1823
|
+
{
|
|
1824
|
+
type: 'select',
|
|
1825
|
+
name: 'canApprovePullRequestReviews',
|
|
1826
|
+
message: 'Allow workflows to approve pull requests?',
|
|
1827
|
+
choices: [
|
|
1828
|
+
{
|
|
1829
|
+
title: 'Unset',
|
|
1830
|
+
value: 'unset',
|
|
1831
|
+
},
|
|
1832
|
+
{
|
|
1833
|
+
title: 'Allow',
|
|
1834
|
+
value: true,
|
|
1835
|
+
},
|
|
1836
|
+
{
|
|
1837
|
+
title: 'Do not allow',
|
|
1838
|
+
value: false,
|
|
1839
|
+
},
|
|
1840
|
+
],
|
|
1841
|
+
initial: Runner.getOptionalBooleanInitial(existing['canApprovePullRequestReviews']),
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
type: 'text',
|
|
1845
|
+
name: 'artifactRetentionDays',
|
|
1846
|
+
message: 'Artifact retention days (blank unsets)',
|
|
1847
|
+
initial: (existing['artifactRetentionDays'] !== undefined) ? `${existing['artifactRetentionDays']}` : '',
|
|
1848
|
+
validate: Runner['isOptionalNonnegativeIntegerInput'],
|
|
1849
|
+
},
|
|
1850
|
+
]);
|
|
1851
|
+
if (output['cancelled'] === true) {
|
|
1852
|
+
return 'back';
|
|
1602
1853
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1854
|
+
const outputResult = output['result'];
|
|
1855
|
+
const selectedActions = {};
|
|
1856
|
+
if (typeof outputResult.selectedActionsGithubOwned === 'boolean') {
|
|
1857
|
+
selectedActions.githubOwned = outputResult.selectedActionsGithubOwned;
|
|
1605
1858
|
}
|
|
1606
|
-
if (
|
|
1607
|
-
|
|
1859
|
+
if (typeof outputResult.selectedActionsVerified === 'boolean') {
|
|
1860
|
+
selectedActions.verified = outputResult.selectedActionsVerified;
|
|
1608
1861
|
}
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
}
|
|
1862
|
+
const patterns = (typeof outputResult.selectedActionsPatterns === 'string') ? outputResult.selectedActionsPatterns.split(',').map((pattern) => pattern.trim()).filter((pattern) => pattern !== '') : [];
|
|
1863
|
+
if (patterns.length > 0) {
|
|
1864
|
+
selectedActions.patterns = patterns;
|
|
1613
1865
|
}
|
|
1614
|
-
|
|
1615
|
-
|
|
1866
|
+
const artifactRetentionDaysRaw = (typeof outputResult.artifactRetentionDays === 'string') ? outputResult.artifactRetentionDays.trim() : '';
|
|
1867
|
+
const actions = {};
|
|
1868
|
+
if (typeof outputResult.enabled === 'boolean') {
|
|
1869
|
+
actions.enabled = outputResult.enabled;
|
|
1616
1870
|
}
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
{
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
value:
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1871
|
+
if (outputResult.allowedActions === 'all'
|
|
1872
|
+
|| outputResult.allowedActions === 'local-only'
|
|
1873
|
+
|| outputResult.allowedActions === 'selected') {
|
|
1874
|
+
actions.allowedActions = outputResult.allowedActions;
|
|
1875
|
+
}
|
|
1876
|
+
if (typeof outputResult.shaPinningRequired === 'boolean') {
|
|
1877
|
+
actions.shaPinningRequired = outputResult.shaPinningRequired;
|
|
1878
|
+
}
|
|
1879
|
+
if (Object.keys(selectedActions).length > 0) {
|
|
1880
|
+
actions.selectedActions = selectedActions;
|
|
1881
|
+
}
|
|
1882
|
+
if (outputResult.defaultWorkflowPermissions === 'read' || outputResult.defaultWorkflowPermissions === 'write') {
|
|
1883
|
+
actions.defaultWorkflowPermissions = outputResult.defaultWorkflowPermissions;
|
|
1884
|
+
}
|
|
1885
|
+
if (typeof outputResult.canApprovePullRequestReviews === 'boolean') {
|
|
1886
|
+
actions.canApprovePullRequestReviews = outputResult.canApprovePullRequestReviews;
|
|
1887
|
+
}
|
|
1888
|
+
if (artifactRetentionDaysRaw !== '') {
|
|
1889
|
+
const artifactRetentionDays = Number.parseInt(artifactRetentionDaysRaw, 10);
|
|
1890
|
+
actions.artifactRetentionDays = artifactRetentionDays;
|
|
1891
|
+
}
|
|
1892
|
+
if (Object.keys(actions).length > 0) {
|
|
1893
|
+
github.actions = actions;
|
|
1894
|
+
}
|
|
1895
|
+
else {
|
|
1896
|
+
Reflect.deleteProperty(github, 'actions');
|
|
1897
|
+
}
|
|
1898
|
+
Object.assign(config, { github });
|
|
1899
|
+
return 'back';
|
|
1900
|
+
}
|
|
1901
|
+
static async promptGithubLabels(config) {
|
|
1902
|
+
const labels = (config['github'] !== undefined && config['github']['labels'] !== undefined) ? config['github']['labels'].map((label) => ({ ...label })) : [];
|
|
1903
|
+
while (true) {
|
|
1904
|
+
const choices = [];
|
|
1905
|
+
for (let labelIndex = 0; labelIndex < labels.length; labelIndex += 1) {
|
|
1906
|
+
const choiceLabel = labels[labelIndex];
|
|
1907
|
+
if (choiceLabel === undefined) {
|
|
1908
|
+
continue;
|
|
1909
|
+
}
|
|
1910
|
+
const description = (choiceLabel['description'] === undefined) ? `#${choiceLabel['color']}` : `#${choiceLabel['color']} — ${choiceLabel['description']}`;
|
|
1911
|
+
choices.push({
|
|
1912
|
+
title: `${chalk.yellow.bold('[EDIT]')} ${choiceLabel['name']}`,
|
|
1913
|
+
description,
|
|
1914
|
+
value: `edit:${labelIndex}`,
|
|
1915
|
+
});
|
|
1916
|
+
if (labelIndex > 0) {
|
|
1917
|
+
choices.push({
|
|
1918
|
+
title: `${chalk.blue.bold('[MOVE UP]')} ${choiceLabel['name']}`,
|
|
1919
|
+
description: 'Move this label earlier in the generated order.',
|
|
1920
|
+
value: `move-up:${labelIndex}`,
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
if (labelIndex < labels.length - 1) {
|
|
1924
|
+
choices.push({
|
|
1925
|
+
title: `${chalk.blue.bold('[MOVE DOWN]')} ${choiceLabel['name']}`,
|
|
1926
|
+
description: 'Move this label later in the generated order.',
|
|
1927
|
+
value: `move-down:${labelIndex}`,
|
|
1928
|
+
});
|
|
1929
|
+
}
|
|
1930
|
+
choices.push({
|
|
1931
|
+
title: `${chalk.red.bold('[REMOVE]')} ${choiceLabel['name']}`,
|
|
1932
|
+
description: 'Delete this managed label.',
|
|
1933
|
+
value: `remove:${labelIndex}`,
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
choices.push({
|
|
1937
|
+
title: 'Add a label',
|
|
1938
|
+
description: 'Append a managed repository label.',
|
|
1939
|
+
value: 'add',
|
|
1940
|
+
});
|
|
1941
|
+
choices.push({
|
|
1942
|
+
title: 'Back',
|
|
1943
|
+
description: 'Return to GitHub settings.',
|
|
1944
|
+
value: 'back',
|
|
1945
|
+
});
|
|
1946
|
+
const menuOutput = await Runner.promptWithCancel({
|
|
1947
|
+
type: 'select',
|
|
1948
|
+
name: 'action',
|
|
1949
|
+
message: (labels.length > 0) ? 'Select a label to manage.' : 'No labels configured. Choose an option.',
|
|
1950
|
+
choices,
|
|
1951
|
+
});
|
|
1952
|
+
if (menuOutput['cancelled'] === true || menuOutput['result'].action === 'back') {
|
|
1953
|
+
const github = config['github'] ?? {};
|
|
1954
|
+
github.labels = labels;
|
|
1955
|
+
Object.assign(config, { github });
|
|
1956
|
+
return 'back';
|
|
1957
|
+
}
|
|
1958
|
+
const action = menuOutput['result'].action;
|
|
1959
|
+
if (action.startsWith('move-up:') === true || action.startsWith('move-down:') === true) {
|
|
1960
|
+
const actionPrefix = (action.startsWith('move-up:') === true) ? 'move-up:' : 'move-down:';
|
|
1961
|
+
const moveLabelIndex = Number.parseInt(action.slice(actionPrefix.length), 10);
|
|
1962
|
+
const destinationIndex = (actionPrefix === 'move-up:') ? moveLabelIndex - 1 : moveLabelIndex + 1;
|
|
1963
|
+
const moveLabel = labels[moveLabelIndex];
|
|
1964
|
+
if (moveLabel !== undefined
|
|
1965
|
+
&& destinationIndex >= 0
|
|
1966
|
+
&& destinationIndex < labels.length) {
|
|
1967
|
+
labels.splice(moveLabelIndex, 1);
|
|
1968
|
+
labels.splice(destinationIndex, 0, moveLabel);
|
|
1969
|
+
}
|
|
1970
|
+
continue;
|
|
1971
|
+
}
|
|
1972
|
+
if (action === 'add' || action.startsWith('edit:') === true) {
|
|
1973
|
+
const editLabelIndex = (action === 'add') ? -1 : Number.parseInt(action.slice('edit:'.length), 10);
|
|
1974
|
+
const editableLabel = (editLabelIndex >= 0) ? labels[editLabelIndex] : undefined;
|
|
1975
|
+
const formOutput = await Runner.promptWithCancel([
|
|
1976
|
+
{
|
|
1977
|
+
type: 'text',
|
|
1978
|
+
name: 'name',
|
|
1979
|
+
message: 'Label name',
|
|
1980
|
+
initial: (editableLabel !== undefined) ? editableLabel['name'] : '',
|
|
1981
|
+
validate: Runner['isNonEmptyLiteralInput'],
|
|
1982
|
+
},
|
|
1983
|
+
{
|
|
1984
|
+
type: 'text',
|
|
1985
|
+
name: 'color',
|
|
1986
|
+
message: 'Label color (six hexadecimal characters, without #)',
|
|
1987
|
+
initial: (editableLabel !== undefined) ? editableLabel['color'] : '',
|
|
1988
|
+
validate: (value) => (typeof value === 'string' && LIB_REGEX_PATTERN_GITHUB_LABEL_COLOR.test(value.trim()) === true) ? true : 'Enter exactly six hexadecimal characters.',
|
|
1989
|
+
},
|
|
1990
|
+
{
|
|
1991
|
+
type: 'text',
|
|
1992
|
+
name: 'description',
|
|
1993
|
+
message: 'Label description (blank unsets)',
|
|
1994
|
+
initial: (editableLabel !== undefined && editableLabel['description'] !== undefined) ? editableLabel['description'] : '',
|
|
1995
|
+
validate: (value) => (typeof value === 'string' && value.length <= 100) ? true : 'Use 100 characters or fewer.',
|
|
1996
|
+
},
|
|
1997
|
+
]);
|
|
1998
|
+
if (formOutput['cancelled'] === true) {
|
|
1999
|
+
continue;
|
|
2000
|
+
}
|
|
2001
|
+
const label = {
|
|
2002
|
+
name: formOutput['result'].name.trim(),
|
|
2003
|
+
color: formOutput['result'].color.trim(),
|
|
2004
|
+
...((formOutput['result'].description.trim() !== '') ? { description: formOutput['result'].description.trim() } : {}),
|
|
2005
|
+
};
|
|
2006
|
+
if (editLabelIndex >= 0) {
|
|
2007
|
+
Reflect.set(labels, editLabelIndex, label);
|
|
2008
|
+
}
|
|
2009
|
+
else {
|
|
2010
|
+
labels.push(label);
|
|
2011
|
+
}
|
|
2012
|
+
continue;
|
|
2013
|
+
}
|
|
2014
|
+
if (action.startsWith('remove:') === true) {
|
|
2015
|
+
const removeLabelIndex = Number.parseInt(action.slice('remove:'.length), 10);
|
|
2016
|
+
const removeLabel = labels[removeLabelIndex];
|
|
2017
|
+
if (removeLabel === undefined) {
|
|
2018
|
+
continue;
|
|
2019
|
+
}
|
|
2020
|
+
const removeOutput = await Runner.promptWithCancel({
|
|
2021
|
+
type: 'confirm',
|
|
2022
|
+
name: 'confirm',
|
|
2023
|
+
message: `Remove label "${removeLabel['name']}"?`,
|
|
2024
|
+
initial: false,
|
|
2025
|
+
});
|
|
2026
|
+
if (removeOutput['cancelled'] === false && removeOutput['result'].confirm === true) {
|
|
2027
|
+
labels.splice(removeLabelIndex, 1);
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
static async promptGithubMenu(config) {
|
|
2033
|
+
const choices = [
|
|
2034
|
+
{
|
|
2035
|
+
title: 'Identity, features, issue fields, and recipe toggles',
|
|
2036
|
+
description: 'Edit repository identity and the common guided fields.',
|
|
2037
|
+
value: 'basics',
|
|
2038
|
+
},
|
|
2039
|
+
{
|
|
2040
|
+
title: 'Actions',
|
|
2041
|
+
description: 'Edit action permissions, allow-lists, and retention.',
|
|
2042
|
+
value: 'actions',
|
|
2043
|
+
},
|
|
2044
|
+
{
|
|
2045
|
+
title: 'Labels',
|
|
2046
|
+
description: 'Add, edit, remove, and order repository labels.',
|
|
2047
|
+
value: 'labels',
|
|
2048
|
+
},
|
|
2049
|
+
{
|
|
2050
|
+
title: 'Policies',
|
|
2051
|
+
description: 'Edit merge behavior and repository-wide policies.',
|
|
2052
|
+
value: 'policies',
|
|
2053
|
+
},
|
|
2054
|
+
{
|
|
2055
|
+
title: 'Rulesets',
|
|
2056
|
+
description: 'Edit the complete default-branch ruleset.',
|
|
2057
|
+
value: 'rulesets',
|
|
2058
|
+
},
|
|
2059
|
+
{
|
|
2060
|
+
title: 'Security',
|
|
2061
|
+
description: 'Edit repository security feature toggles.',
|
|
2062
|
+
value: 'security',
|
|
2063
|
+
},
|
|
2064
|
+
{
|
|
2065
|
+
title: 'Back',
|
|
2066
|
+
description: 'Return to the category selection.',
|
|
2067
|
+
value: 'back',
|
|
2068
|
+
},
|
|
2069
|
+
];
|
|
2070
|
+
while (true) {
|
|
2071
|
+
const output = await Runner.promptWithCancel({
|
|
2072
|
+
type: 'select',
|
|
2073
|
+
name: 'section',
|
|
2074
|
+
message: 'Select GitHub settings to manage.',
|
|
2075
|
+
choices,
|
|
2076
|
+
});
|
|
2077
|
+
if (output['cancelled'] === true || output['result'].section === 'back') {
|
|
2078
|
+
return 'back';
|
|
2079
|
+
}
|
|
2080
|
+
const section = output['result'].section;
|
|
2081
|
+
if (section === 'basics') {
|
|
2082
|
+
await Runner.promptGithub(config);
|
|
2083
|
+
}
|
|
2084
|
+
else if (section === 'actions') {
|
|
2085
|
+
await Runner.promptGithubActions(config);
|
|
2086
|
+
}
|
|
2087
|
+
else if (section === 'labels') {
|
|
2088
|
+
await Runner.promptGithubLabels(config);
|
|
2089
|
+
}
|
|
2090
|
+
else if (section === 'policies') {
|
|
2091
|
+
await Runner.promptGithubPolicies(config);
|
|
2092
|
+
}
|
|
2093
|
+
else if (section === 'rulesets') {
|
|
2094
|
+
await Runner.promptGithubRulesets(config);
|
|
2095
|
+
}
|
|
2096
|
+
else if (section === 'security') {
|
|
2097
|
+
await Runner.promptGithubSecurity(config);
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
static async promptGithubPolicies(config) {
|
|
2102
|
+
const github = config['github'] ?? {};
|
|
2103
|
+
const existing = github['policies'] ?? {};
|
|
2104
|
+
const output = await Runner.promptWithCancel([
|
|
2105
|
+
{
|
|
2106
|
+
type: 'select',
|
|
2107
|
+
name: 'visibility',
|
|
2108
|
+
message: 'Repository visibility',
|
|
2109
|
+
choices: [
|
|
2110
|
+
{
|
|
2111
|
+
title: 'Unset',
|
|
2112
|
+
value: 'unset',
|
|
2113
|
+
},
|
|
2114
|
+
{
|
|
2115
|
+
title: 'Public',
|
|
2116
|
+
value: 'public',
|
|
2117
|
+
},
|
|
2118
|
+
{
|
|
2119
|
+
title: 'Private',
|
|
2120
|
+
value: 'private',
|
|
2121
|
+
},
|
|
2122
|
+
{
|
|
2123
|
+
title: 'Internal',
|
|
2124
|
+
value: 'internal',
|
|
2125
|
+
},
|
|
2126
|
+
],
|
|
2127
|
+
initial: (existing['visibility'] === undefined) ? 0 : ([
|
|
2128
|
+
'public',
|
|
2129
|
+
'private',
|
|
2130
|
+
'internal',
|
|
2131
|
+
].indexOf(existing['visibility']) + 1),
|
|
2132
|
+
},
|
|
2133
|
+
{
|
|
2134
|
+
type: 'text',
|
|
2135
|
+
name: 'defaultBranch',
|
|
2136
|
+
message: 'Default branch (blank unsets)',
|
|
2137
|
+
initial: existing['defaultBranch'] ?? '',
|
|
2138
|
+
},
|
|
2139
|
+
{
|
|
2140
|
+
type: 'select',
|
|
2141
|
+
name: 'merge',
|
|
2142
|
+
message: 'Allow merge commits?',
|
|
2143
|
+
choices: [
|
|
2144
|
+
{
|
|
2145
|
+
title: 'Unset',
|
|
2146
|
+
value: 'unset',
|
|
2147
|
+
},
|
|
2148
|
+
{
|
|
2149
|
+
title: 'Allow',
|
|
2150
|
+
value: true,
|
|
2151
|
+
},
|
|
2152
|
+
{
|
|
2153
|
+
title: 'Do not allow',
|
|
2154
|
+
value: false,
|
|
2155
|
+
},
|
|
2156
|
+
],
|
|
2157
|
+
initial: Runner.getOptionalBooleanInitial((existing['mergeMethods'] !== undefined) ? existing['mergeMethods']['merge'] : undefined),
|
|
2158
|
+
},
|
|
2159
|
+
{
|
|
2160
|
+
type: 'select',
|
|
2161
|
+
name: 'squash',
|
|
2162
|
+
message: 'Allow squash merges?',
|
|
2163
|
+
choices: [
|
|
2164
|
+
{
|
|
2165
|
+
title: 'Unset',
|
|
2166
|
+
value: 'unset',
|
|
2167
|
+
},
|
|
2168
|
+
{
|
|
2169
|
+
title: 'Allow',
|
|
2170
|
+
value: true,
|
|
2171
|
+
},
|
|
2172
|
+
{
|
|
2173
|
+
title: 'Do not allow',
|
|
2174
|
+
value: false,
|
|
2175
|
+
},
|
|
2176
|
+
],
|
|
2177
|
+
initial: Runner.getOptionalBooleanInitial((existing['mergeMethods'] !== undefined) ? existing['mergeMethods']['squash'] : undefined),
|
|
2178
|
+
},
|
|
2179
|
+
{
|
|
2180
|
+
type: 'select',
|
|
2181
|
+
name: 'rebase',
|
|
2182
|
+
message: 'Allow rebase merges?',
|
|
2183
|
+
choices: [
|
|
2184
|
+
{
|
|
2185
|
+
title: 'Unset',
|
|
2186
|
+
value: 'unset',
|
|
2187
|
+
},
|
|
2188
|
+
{
|
|
2189
|
+
title: 'Allow',
|
|
2190
|
+
value: true,
|
|
2191
|
+
},
|
|
2192
|
+
{
|
|
2193
|
+
title: 'Do not allow',
|
|
2194
|
+
value: false,
|
|
2195
|
+
},
|
|
2196
|
+
],
|
|
2197
|
+
initial: Runner.getOptionalBooleanInitial((existing['mergeMethods'] !== undefined) ? existing['mergeMethods']['rebase'] : undefined),
|
|
2198
|
+
},
|
|
2199
|
+
{
|
|
2200
|
+
type: 'select',
|
|
2201
|
+
name: 'mergeCommitTitle',
|
|
2202
|
+
message: 'Merge-commit title source',
|
|
2203
|
+
choices: [
|
|
2204
|
+
{
|
|
2205
|
+
title: 'Unset',
|
|
2206
|
+
value: 'unset',
|
|
2207
|
+
},
|
|
2208
|
+
{
|
|
2209
|
+
title: 'Pull request title',
|
|
2210
|
+
value: 'pull-request-title',
|
|
2211
|
+
},
|
|
2212
|
+
{
|
|
2213
|
+
title: 'Merge message',
|
|
2214
|
+
value: 'merge-message',
|
|
2215
|
+
},
|
|
2216
|
+
],
|
|
2217
|
+
initial: (existing['mergeCommit'] === undefined || existing['mergeCommit']['title'] === undefined) ? 0 : ([
|
|
2218
|
+
'pull-request-title',
|
|
2219
|
+
'merge-message',
|
|
2220
|
+
].indexOf(existing['mergeCommit']['title']) + 1),
|
|
2221
|
+
},
|
|
2222
|
+
{
|
|
2223
|
+
type: 'select',
|
|
2224
|
+
name: 'mergeCommitMessage',
|
|
2225
|
+
message: 'Merge-commit message source',
|
|
2226
|
+
choices: [
|
|
2227
|
+
{
|
|
2228
|
+
title: 'Unset',
|
|
2229
|
+
value: 'unset',
|
|
2230
|
+
},
|
|
2231
|
+
{
|
|
2232
|
+
title: 'Pull request body',
|
|
2233
|
+
value: 'pull-request-body',
|
|
2234
|
+
},
|
|
2235
|
+
{
|
|
2236
|
+
title: 'Pull request title',
|
|
2237
|
+
value: 'pull-request-title',
|
|
2238
|
+
},
|
|
2239
|
+
{
|
|
2240
|
+
title: 'Blank',
|
|
2241
|
+
value: 'blank',
|
|
2242
|
+
},
|
|
2243
|
+
],
|
|
2244
|
+
initial: (existing['mergeCommit'] === undefined || existing['mergeCommit']['message'] === undefined) ? 0 : ([
|
|
2245
|
+
'pull-request-body',
|
|
2246
|
+
'pull-request-title',
|
|
2247
|
+
'blank',
|
|
2248
|
+
].indexOf(existing['mergeCommit']['message']) + 1),
|
|
2249
|
+
},
|
|
2250
|
+
{
|
|
2251
|
+
type: 'select',
|
|
2252
|
+
name: 'squashMergeTitle',
|
|
2253
|
+
message: 'Squash-merge title source',
|
|
2254
|
+
choices: [
|
|
2255
|
+
{
|
|
2256
|
+
title: 'Unset',
|
|
2257
|
+
value: 'unset',
|
|
2258
|
+
},
|
|
2259
|
+
{
|
|
2260
|
+
title: 'Pull request title',
|
|
2261
|
+
value: 'pull-request-title',
|
|
2262
|
+
},
|
|
2263
|
+
{
|
|
2264
|
+
title: 'Commit or pull request title',
|
|
2265
|
+
value: 'commit-or-pull-request-title',
|
|
2266
|
+
},
|
|
2267
|
+
],
|
|
2268
|
+
initial: (existing['squashMerge'] === undefined || existing['squashMerge']['title'] === undefined) ? 0 : ([
|
|
2269
|
+
'pull-request-title',
|
|
2270
|
+
'commit-or-pull-request-title',
|
|
2271
|
+
].indexOf(existing['squashMerge']['title']) + 1),
|
|
2272
|
+
},
|
|
2273
|
+
{
|
|
2274
|
+
type: 'select',
|
|
2275
|
+
name: 'squashMergeMessage',
|
|
2276
|
+
message: 'Squash-merge message source',
|
|
2277
|
+
choices: [
|
|
2278
|
+
{
|
|
2279
|
+
title: 'Unset',
|
|
2280
|
+
value: 'unset',
|
|
2281
|
+
},
|
|
2282
|
+
{
|
|
2283
|
+
title: 'Pull request body',
|
|
2284
|
+
value: 'pull-request-body',
|
|
2285
|
+
},
|
|
2286
|
+
{
|
|
2287
|
+
title: 'Commit messages',
|
|
2288
|
+
value: 'commit-messages',
|
|
2289
|
+
},
|
|
2290
|
+
{
|
|
2291
|
+
title: 'Blank',
|
|
2292
|
+
value: 'blank',
|
|
2293
|
+
},
|
|
2294
|
+
],
|
|
2295
|
+
initial: (existing['squashMerge'] === undefined || existing['squashMerge']['message'] === undefined) ? 0 : ([
|
|
2296
|
+
'pull-request-body',
|
|
2297
|
+
'commit-messages',
|
|
2298
|
+
'blank',
|
|
2299
|
+
].indexOf(existing['squashMerge']['message']) + 1),
|
|
2300
|
+
},
|
|
2301
|
+
...[
|
|
2302
|
+
'autoDeleteHeadBranch',
|
|
2303
|
+
'autoMerge',
|
|
2304
|
+
'allowUpdateBranch',
|
|
2305
|
+
'webCommitSignoffRequired',
|
|
2306
|
+
].map((name) => ({
|
|
2307
|
+
type: 'select',
|
|
2308
|
+
name,
|
|
2309
|
+
message: ({
|
|
2310
|
+
autoDeleteHeadBranch: 'Automatically delete merged head branches?',
|
|
2311
|
+
autoMerge: 'Allow automatic merging?',
|
|
2312
|
+
allowUpdateBranch: 'Allow updating pull request branches?',
|
|
2313
|
+
webCommitSignoffRequired: 'Require signoff for web commits?',
|
|
2314
|
+
})[name],
|
|
2315
|
+
choices: [
|
|
2316
|
+
{
|
|
2317
|
+
title: 'Unset',
|
|
2318
|
+
value: 'unset',
|
|
2319
|
+
},
|
|
2320
|
+
{
|
|
2321
|
+
title: 'Enable',
|
|
2322
|
+
value: true,
|
|
2323
|
+
},
|
|
2324
|
+
{
|
|
2325
|
+
title: 'Disable',
|
|
2326
|
+
value: false,
|
|
2327
|
+
},
|
|
2328
|
+
],
|
|
2329
|
+
initial: Runner.getOptionalBooleanInitial(existing[name]),
|
|
2330
|
+
})),
|
|
2331
|
+
]);
|
|
2332
|
+
if (output['cancelled'] === true) {
|
|
2333
|
+
return 'back';
|
|
2334
|
+
}
|
|
2335
|
+
const outputResult = output['result'];
|
|
2336
|
+
const mergeMethods = {};
|
|
2337
|
+
const mergeCommit = {};
|
|
2338
|
+
const squashMerge = {};
|
|
2339
|
+
const policies = {};
|
|
2340
|
+
if (outputResult.visibility === 'public'
|
|
2341
|
+
|| outputResult.visibility === 'private'
|
|
2342
|
+
|| outputResult.visibility === 'internal') {
|
|
2343
|
+
policies.visibility = outputResult.visibility;
|
|
2344
|
+
}
|
|
2345
|
+
if (typeof outputResult.defaultBranch === 'string' && outputResult.defaultBranch.trim() !== '') {
|
|
2346
|
+
policies.defaultBranch = outputResult.defaultBranch.trim();
|
|
2347
|
+
}
|
|
2348
|
+
if (typeof outputResult.merge === 'boolean') {
|
|
2349
|
+
mergeMethods.merge = outputResult.merge;
|
|
2350
|
+
}
|
|
2351
|
+
if (typeof outputResult.squash === 'boolean') {
|
|
2352
|
+
mergeMethods.squash = outputResult.squash;
|
|
2353
|
+
}
|
|
2354
|
+
if (typeof outputResult.rebase === 'boolean') {
|
|
2355
|
+
mergeMethods.rebase = outputResult.rebase;
|
|
2356
|
+
}
|
|
2357
|
+
if (Object.keys(mergeMethods).length > 0) {
|
|
2358
|
+
policies.mergeMethods = mergeMethods;
|
|
2359
|
+
}
|
|
2360
|
+
if (outputResult.mergeCommitTitle === 'pull-request-title' || outputResult.mergeCommitTitle === 'merge-message') {
|
|
2361
|
+
mergeCommit.title = outputResult.mergeCommitTitle;
|
|
2362
|
+
}
|
|
2363
|
+
if (outputResult.mergeCommitMessage === 'pull-request-body'
|
|
2364
|
+
|| outputResult.mergeCommitMessage === 'pull-request-title'
|
|
2365
|
+
|| outputResult.mergeCommitMessage === 'blank') {
|
|
2366
|
+
mergeCommit.message = outputResult.mergeCommitMessage;
|
|
2367
|
+
}
|
|
2368
|
+
if (Object.keys(mergeCommit).length > 0) {
|
|
2369
|
+
policies.mergeCommit = mergeCommit;
|
|
2370
|
+
}
|
|
2371
|
+
if (outputResult.squashMergeTitle === 'pull-request-title' || outputResult.squashMergeTitle === 'commit-or-pull-request-title') {
|
|
2372
|
+
squashMerge.title = outputResult.squashMergeTitle;
|
|
2373
|
+
}
|
|
2374
|
+
if (outputResult.squashMergeMessage === 'pull-request-body'
|
|
2375
|
+
|| outputResult.squashMergeMessage === 'commit-messages'
|
|
2376
|
+
|| outputResult.squashMergeMessage === 'blank') {
|
|
2377
|
+
squashMerge.message = outputResult.squashMergeMessage;
|
|
2378
|
+
}
|
|
2379
|
+
if (Object.keys(squashMerge).length > 0) {
|
|
2380
|
+
policies.squashMerge = squashMerge;
|
|
2381
|
+
}
|
|
2382
|
+
if (typeof outputResult.autoDeleteHeadBranch === 'boolean') {
|
|
2383
|
+
policies.autoDeleteHeadBranch = outputResult.autoDeleteHeadBranch;
|
|
2384
|
+
}
|
|
2385
|
+
if (typeof outputResult.autoMerge === 'boolean') {
|
|
2386
|
+
policies.autoMerge = outputResult.autoMerge;
|
|
2387
|
+
}
|
|
2388
|
+
if (typeof outputResult.allowUpdateBranch === 'boolean') {
|
|
2389
|
+
policies.allowUpdateBranch = outputResult.allowUpdateBranch;
|
|
2390
|
+
}
|
|
2391
|
+
if (typeof outputResult.webCommitSignoffRequired === 'boolean') {
|
|
2392
|
+
policies.webCommitSignoffRequired = outputResult.webCommitSignoffRequired;
|
|
2393
|
+
}
|
|
2394
|
+
if (Object.keys(policies).length > 0) {
|
|
2395
|
+
github.policies = policies;
|
|
2396
|
+
}
|
|
2397
|
+
else {
|
|
2398
|
+
Reflect.deleteProperty(github, 'policies');
|
|
2399
|
+
}
|
|
2400
|
+
Object.assign(config, { github });
|
|
2401
|
+
return 'back';
|
|
2402
|
+
}
|
|
2403
|
+
static async promptGithubRulesets(config) {
|
|
2404
|
+
const github = config['github'] ?? {};
|
|
2405
|
+
const existingRulesets = github['rulesets'] ?? {};
|
|
2406
|
+
const existing = existingRulesets['defaultBranch'] ?? {};
|
|
2407
|
+
const output = await Runner.promptWithCancel([
|
|
2408
|
+
{
|
|
2409
|
+
type: 'select',
|
|
2410
|
+
name: 'enforcement',
|
|
2411
|
+
message: 'Default-branch ruleset enforcement',
|
|
2412
|
+
choices: [
|
|
2413
|
+
{
|
|
2414
|
+
title: 'Unset',
|
|
2415
|
+
value: 'unset',
|
|
2416
|
+
},
|
|
2417
|
+
{
|
|
2418
|
+
title: 'Active',
|
|
2419
|
+
value: 'active',
|
|
2420
|
+
},
|
|
2421
|
+
{
|
|
2422
|
+
title: 'Disabled',
|
|
2423
|
+
value: 'disabled',
|
|
2424
|
+
},
|
|
2425
|
+
{
|
|
2426
|
+
title: 'Evaluate',
|
|
2427
|
+
value: 'evaluate',
|
|
2428
|
+
},
|
|
2429
|
+
],
|
|
2430
|
+
initial: (existing['enforcement'] === undefined) ? 0 : ([
|
|
2431
|
+
'active',
|
|
2432
|
+
'disabled',
|
|
2433
|
+
'evaluate',
|
|
2434
|
+
].indexOf(existing['enforcement']) + 1),
|
|
2435
|
+
},
|
|
2436
|
+
...[
|
|
2437
|
+
'blockDeletions',
|
|
2438
|
+
'blockForcePushes',
|
|
2439
|
+
'requireLinearHistory',
|
|
2440
|
+
'requireSignedCommits',
|
|
2441
|
+
'requirePullRequest',
|
|
2442
|
+
].map((name) => ({
|
|
2443
|
+
type: 'select',
|
|
2444
|
+
name,
|
|
2445
|
+
message: ({
|
|
2446
|
+
blockDeletions: 'Block branch deletions?',
|
|
2447
|
+
blockForcePushes: 'Block force pushes?',
|
|
2448
|
+
requireLinearHistory: 'Require linear history?',
|
|
2449
|
+
requireSignedCommits: 'Require signed commits?',
|
|
2450
|
+
requirePullRequest: 'Require pull requests?',
|
|
2451
|
+
})[name],
|
|
2452
|
+
choices: [
|
|
2453
|
+
{
|
|
2454
|
+
title: 'Unset',
|
|
2455
|
+
value: 'unset',
|
|
2456
|
+
},
|
|
2457
|
+
{
|
|
2458
|
+
title: 'Enable',
|
|
2459
|
+
value: true,
|
|
2460
|
+
},
|
|
2461
|
+
{
|
|
2462
|
+
title: 'Disable',
|
|
2463
|
+
value: false,
|
|
2464
|
+
},
|
|
2465
|
+
],
|
|
2466
|
+
initial: Runner.getOptionalBooleanInitial(existing[name]),
|
|
2467
|
+
})),
|
|
2468
|
+
{
|
|
2469
|
+
type: 'multiselect',
|
|
2470
|
+
name: 'allowedMergeMethods',
|
|
2471
|
+
message: 'Allowed pull-request merge methods',
|
|
2472
|
+
choices: [
|
|
2473
|
+
{
|
|
2474
|
+
title: 'Merge',
|
|
2475
|
+
value: 'merge',
|
|
2476
|
+
selected: existing['allowedMergeMethods'] !== undefined && existing['allowedMergeMethods'].includes('merge'),
|
|
2477
|
+
},
|
|
2478
|
+
{
|
|
2479
|
+
title: 'Squash',
|
|
2480
|
+
value: 'squash',
|
|
2481
|
+
selected: existing['allowedMergeMethods'] !== undefined && existing['allowedMergeMethods'].includes('squash'),
|
|
2482
|
+
},
|
|
2483
|
+
{
|
|
2484
|
+
title: 'Rebase',
|
|
2485
|
+
value: 'rebase',
|
|
2486
|
+
selected: existing['allowedMergeMethods'] !== undefined && existing['allowedMergeMethods'].includes('rebase'),
|
|
2487
|
+
},
|
|
2488
|
+
],
|
|
2489
|
+
hint: '- Space to select. Return to submit. Selecting none unsets the field',
|
|
2490
|
+
},
|
|
2491
|
+
...[
|
|
2492
|
+
'dismissStaleReviews',
|
|
2493
|
+
'requireCodeOwnerReview',
|
|
2494
|
+
'requireLastPushApproval',
|
|
2495
|
+
].map((name) => ({
|
|
2496
|
+
type: 'select',
|
|
2497
|
+
name,
|
|
2498
|
+
message: ({
|
|
2499
|
+
dismissStaleReviews: 'Dismiss stale pull-request reviews?',
|
|
2500
|
+
requireCodeOwnerReview: 'Require code-owner review?',
|
|
2501
|
+
requireLastPushApproval: 'Require approval after the latest push?',
|
|
2502
|
+
})[name],
|
|
2503
|
+
choices: [
|
|
2504
|
+
{
|
|
2505
|
+
title: 'Unset',
|
|
2506
|
+
value: 'unset',
|
|
2507
|
+
},
|
|
2508
|
+
{
|
|
2509
|
+
title: 'Enable',
|
|
2510
|
+
value: true,
|
|
2511
|
+
},
|
|
2512
|
+
{
|
|
2513
|
+
title: 'Disable',
|
|
2514
|
+
value: false,
|
|
2515
|
+
},
|
|
2516
|
+
],
|
|
2517
|
+
initial: Runner.getOptionalBooleanInitial(existing[name]),
|
|
2518
|
+
})),
|
|
2519
|
+
{
|
|
2520
|
+
type: 'text',
|
|
2521
|
+
name: 'requiredApprovals',
|
|
2522
|
+
message: 'Required approving reviews (blank unsets)',
|
|
2523
|
+
initial: (existing['requiredApprovals'] === undefined) ? '' : `${existing['requiredApprovals']}`,
|
|
2524
|
+
validate: Runner['isOptionalNonnegativeIntegerInput'],
|
|
2525
|
+
},
|
|
2526
|
+
{
|
|
2527
|
+
type: 'select',
|
|
2528
|
+
name: 'requireConversationResolution',
|
|
2529
|
+
message: 'Require conversation resolution?',
|
|
2530
|
+
choices: [
|
|
2531
|
+
{
|
|
2532
|
+
title: 'Unset',
|
|
2533
|
+
value: 'unset',
|
|
2534
|
+
},
|
|
2535
|
+
{
|
|
2536
|
+
title: 'Enable',
|
|
2537
|
+
value: true,
|
|
2538
|
+
},
|
|
2539
|
+
{
|
|
2540
|
+
title: 'Disable',
|
|
2541
|
+
value: false,
|
|
2542
|
+
},
|
|
2543
|
+
],
|
|
2544
|
+
initial: Runner.getOptionalBooleanInitial(existing['requireConversationResolution']),
|
|
2545
|
+
},
|
|
2546
|
+
{
|
|
2547
|
+
type: 'text',
|
|
2548
|
+
name: 'requiredStatusChecks',
|
|
2549
|
+
message: 'Required status checks (comma-separated; blank unsets)',
|
|
2550
|
+
initial: (existing['requiredStatusChecks'] === undefined) ? '' : existing['requiredStatusChecks'].join(', '),
|
|
2551
|
+
},
|
|
2552
|
+
{
|
|
2553
|
+
type: 'select',
|
|
2554
|
+
name: 'requireBranchesToBeUpToDate',
|
|
2555
|
+
message: 'Require branches to be up to date?',
|
|
2556
|
+
choices: [
|
|
2557
|
+
{
|
|
2558
|
+
title: 'Unset',
|
|
2559
|
+
value: 'unset',
|
|
2560
|
+
},
|
|
2561
|
+
{
|
|
2562
|
+
title: 'Enable',
|
|
2563
|
+
value: true,
|
|
2564
|
+
},
|
|
2565
|
+
{
|
|
2566
|
+
title: 'Disable',
|
|
2567
|
+
value: false,
|
|
2568
|
+
},
|
|
2569
|
+
],
|
|
2570
|
+
initial: Runner.getOptionalBooleanInitial(existing['requireBranchesToBeUpToDate']),
|
|
2571
|
+
},
|
|
2572
|
+
]);
|
|
2573
|
+
if (output['cancelled'] === true) {
|
|
2574
|
+
return 'back';
|
|
2575
|
+
}
|
|
2576
|
+
const outputResult = output['result'];
|
|
2577
|
+
const allowedMergeMethods = [];
|
|
2578
|
+
const defaultBranch = {};
|
|
2579
|
+
if (outputResult.enforcement === 'active'
|
|
2580
|
+
|| outputResult.enforcement === 'disabled'
|
|
2581
|
+
|| outputResult.enforcement === 'evaluate') {
|
|
2582
|
+
defaultBranch.enforcement = outputResult.enforcement;
|
|
2583
|
+
}
|
|
2584
|
+
for (const mergeMethod of ((Array.isArray(outputResult.allowedMergeMethods) === true) ? outputResult.allowedMergeMethods : [])) {
|
|
2585
|
+
if (mergeMethod === 'merge'
|
|
2586
|
+
|| mergeMethod === 'squash'
|
|
2587
|
+
|| mergeMethod === 'rebase') {
|
|
2588
|
+
allowedMergeMethods.push(mergeMethod);
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
for (const booleanKey of [
|
|
2592
|
+
'blockDeletions',
|
|
2593
|
+
'blockForcePushes',
|
|
2594
|
+
'requireLinearHistory',
|
|
2595
|
+
'requireSignedCommits',
|
|
2596
|
+
'requirePullRequest',
|
|
2597
|
+
'dismissStaleReviews',
|
|
2598
|
+
'requireCodeOwnerReview',
|
|
2599
|
+
'requireLastPushApproval',
|
|
2600
|
+
'requireConversationResolution',
|
|
2601
|
+
'requireBranchesToBeUpToDate',
|
|
2602
|
+
]) {
|
|
2603
|
+
if (typeof outputResult[booleanKey] === 'boolean') {
|
|
2604
|
+
Reflect.set(defaultBranch, booleanKey, outputResult[booleanKey]);
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
if (allowedMergeMethods.length > 0) {
|
|
2608
|
+
defaultBranch.allowedMergeMethods = allowedMergeMethods;
|
|
2609
|
+
}
|
|
2610
|
+
const requiredApprovalsRaw = (typeof outputResult.requiredApprovals === 'string') ? outputResult.requiredApprovals.trim() : '';
|
|
2611
|
+
if (requiredApprovalsRaw !== '') {
|
|
2612
|
+
const requiredApprovals = Number.parseInt(requiredApprovalsRaw, 10);
|
|
2613
|
+
defaultBranch.requiredApprovals = requiredApprovals;
|
|
2614
|
+
}
|
|
2615
|
+
const requiredStatusChecks = (typeof outputResult.requiredStatusChecks === 'string') ? outputResult.requiredStatusChecks.split(',').map((statusCheck) => statusCheck.trim()).filter((statusCheck) => statusCheck !== '') : [];
|
|
2616
|
+
if (requiredStatusChecks.length > 0) {
|
|
2617
|
+
defaultBranch.requiredStatusChecks = requiredStatusChecks;
|
|
2618
|
+
}
|
|
2619
|
+
if (Object.keys(defaultBranch).length > 0) {
|
|
2620
|
+
const rulesets = { defaultBranch };
|
|
2621
|
+
github.rulesets = rulesets;
|
|
2622
|
+
}
|
|
2623
|
+
else {
|
|
2624
|
+
Reflect.deleteProperty(github, 'rulesets');
|
|
2625
|
+
}
|
|
2626
|
+
Object.assign(config, { github });
|
|
2627
|
+
return 'back';
|
|
2628
|
+
}
|
|
2629
|
+
static async promptGithubSecurity(config) {
|
|
2630
|
+
const github = config['github'] ?? {};
|
|
2631
|
+
const existing = github['security'] ?? {};
|
|
2632
|
+
const output = await Runner.promptWithCancel([
|
|
2633
|
+
'vulnerabilityAlerts',
|
|
2634
|
+
'dependabotSecurityUpdates',
|
|
2635
|
+
'secretScanning',
|
|
2636
|
+
'pushProtection',
|
|
2637
|
+
].map((name) => ({
|
|
2638
|
+
type: 'select',
|
|
2639
|
+
name,
|
|
2640
|
+
message: ({
|
|
2641
|
+
vulnerabilityAlerts: 'Enable dependency vulnerability alerts?',
|
|
2642
|
+
dependabotSecurityUpdates: 'Enable Dependabot security updates?',
|
|
2643
|
+
secretScanning: 'Enable secret scanning?',
|
|
2644
|
+
pushProtection: 'Enable secret-scanning push protection?',
|
|
2645
|
+
})[name],
|
|
2646
|
+
choices: [
|
|
2647
|
+
{
|
|
2648
|
+
title: 'Unset',
|
|
2649
|
+
value: 'unset',
|
|
2650
|
+
},
|
|
2651
|
+
{
|
|
2652
|
+
title: 'Enable',
|
|
2653
|
+
value: true,
|
|
2654
|
+
},
|
|
2655
|
+
{
|
|
2656
|
+
title: 'Disable',
|
|
2657
|
+
value: false,
|
|
2658
|
+
},
|
|
2659
|
+
],
|
|
2660
|
+
initial: Runner.getOptionalBooleanInitial(existing[name]),
|
|
2661
|
+
})));
|
|
2662
|
+
if (output['cancelled'] === true) {
|
|
2663
|
+
return 'back';
|
|
2664
|
+
}
|
|
2665
|
+
const outputResult = output['result'];
|
|
2666
|
+
const security = {};
|
|
2667
|
+
for (const securityKey of [
|
|
2668
|
+
'vulnerabilityAlerts',
|
|
2669
|
+
'dependabotSecurityUpdates',
|
|
2670
|
+
'secretScanning',
|
|
2671
|
+
'pushProtection',
|
|
2672
|
+
]) {
|
|
2673
|
+
if (typeof outputResult[securityKey] === 'boolean') {
|
|
2674
|
+
Reflect.set(security, securityKey, outputResult[securityKey]);
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
if (Object.keys(security).length > 0) {
|
|
2678
|
+
github.security = security;
|
|
2679
|
+
}
|
|
2680
|
+
else {
|
|
2681
|
+
Reflect.deleteProperty(github, 'security');
|
|
2682
|
+
}
|
|
2683
|
+
Object.assign(config, { github });
|
|
2684
|
+
return 'back';
|
|
2685
|
+
}
|
|
2686
|
+
static async promptReadMe(config) {
|
|
2687
|
+
const existingReadMe = config['readme'];
|
|
2688
|
+
const existingBadges = (existingReadMe !== undefined) ? (existingReadMe['badges'] ?? []) : [];
|
|
2689
|
+
const hasExplicitBadges = (existingReadMe !== undefined) ? existingReadMe['badges'] !== undefined : false;
|
|
2690
|
+
const suggestedBadges = [];
|
|
2691
|
+
const project = config['project'];
|
|
2692
|
+
const platforms = (project !== undefined) ? project['platforms'] : undefined;
|
|
2693
|
+
const urls = config['urls'];
|
|
2694
|
+
const github = config['github'];
|
|
2695
|
+
const fundSources = (urls !== undefined) ? (urls['fundSources'] ?? []) : [];
|
|
2696
|
+
if (platforms !== undefined && platforms.includes('homebridge') === true) {
|
|
2697
|
+
suggestedBadges.push('homebridge');
|
|
2698
|
+
}
|
|
2699
|
+
if (urls !== undefined && urls['npm'] !== undefined) {
|
|
2700
|
+
suggestedBadges.push('npm-version', 'npm-downloads');
|
|
2701
|
+
}
|
|
2702
|
+
if (urls !== undefined && urls['docker'] !== undefined) {
|
|
2703
|
+
suggestedBadges.push('docker-pulls', 'docker-image-size');
|
|
2704
|
+
}
|
|
2705
|
+
if (github !== undefined) {
|
|
2706
|
+
if (github['owner'] !== undefined && github['repo'] !== undefined) {
|
|
2707
|
+
suggestedBadges.push('github-release', 'github-top-language', 'github-license');
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
if (fundSources.length > 0) {
|
|
2711
|
+
suggestedBadges.push('funding');
|
|
2712
|
+
}
|
|
2713
|
+
const selectedBadges = (hasExplicitBadges === true) ? existingBadges : suggestedBadges;
|
|
2714
|
+
const badgesOutput = await Runner.promptWithCancel({
|
|
2715
|
+
type: 'multiselect',
|
|
2716
|
+
name: 'readMeBadges',
|
|
2717
|
+
message: 'README badges in generated order (space to select)',
|
|
2718
|
+
choices: [
|
|
2719
|
+
{
|
|
2720
|
+
title: 'Homebridge Verified',
|
|
2721
|
+
value: 'homebridge-verified',
|
|
2722
|
+
selected: selectedBadges.includes('homebridge-verified'),
|
|
2723
|
+
},
|
|
2724
|
+
{
|
|
2725
|
+
title: 'Homebridge',
|
|
2726
|
+
value: 'homebridge',
|
|
2727
|
+
selected: selectedBadges.includes('homebridge'),
|
|
2728
|
+
},
|
|
2729
|
+
{
|
|
2730
|
+
title: 'npm Version (requires urls.npm)',
|
|
2731
|
+
value: 'npm-version',
|
|
2732
|
+
selected: selectedBadges.includes('npm-version'),
|
|
2733
|
+
},
|
|
2734
|
+
{
|
|
2735
|
+
title: 'npm Downloads (requires urls.npm)',
|
|
2736
|
+
value: 'npm-downloads',
|
|
2737
|
+
selected: selectedBadges.includes('npm-downloads'),
|
|
2738
|
+
},
|
|
2739
|
+
{
|
|
2740
|
+
title: 'Docker Pulls (requires urls.docker)',
|
|
2741
|
+
value: 'docker-pulls',
|
|
2742
|
+
selected: selectedBadges.includes('docker-pulls'),
|
|
2743
|
+
},
|
|
2744
|
+
{
|
|
2745
|
+
title: 'Docker Image Size (requires urls.docker)',
|
|
2746
|
+
value: 'docker-image-size',
|
|
2747
|
+
selected: selectedBadges.includes('docker-image-size'),
|
|
2748
|
+
},
|
|
2749
|
+
{
|
|
2750
|
+
title: 'GitHub Release (requires github owner and repo)',
|
|
2751
|
+
value: 'github-release',
|
|
2752
|
+
selected: selectedBadges.includes('github-release'),
|
|
2753
|
+
},
|
|
2754
|
+
{
|
|
2755
|
+
title: 'GitHub Top Language (requires github owner and repo)',
|
|
2756
|
+
value: 'github-top-language',
|
|
2757
|
+
selected: selectedBadges.includes('github-top-language'),
|
|
2758
|
+
},
|
|
2759
|
+
{
|
|
2760
|
+
title: 'GitHub License (requires github owner and repo)',
|
|
2761
|
+
value: 'github-license',
|
|
2762
|
+
selected: selectedBadges.includes('github-license'),
|
|
2763
|
+
},
|
|
2764
|
+
{
|
|
2765
|
+
title: 'Funding (requires urls.fundSources)',
|
|
2766
|
+
value: 'funding',
|
|
2767
|
+
selected: selectedBadges.includes('funding'),
|
|
2768
|
+
},
|
|
2769
|
+
],
|
|
2770
|
+
hint: '- Space to select. Return to submit',
|
|
2771
|
+
});
|
|
2772
|
+
if (badgesOutput['cancelled'] === true) {
|
|
2773
|
+
return 'back';
|
|
2774
|
+
}
|
|
2775
|
+
const badges = badgesOutput['result'].readMeBadges ?? [];
|
|
2776
|
+
Object.assign(config, {
|
|
2777
|
+
readme: { badges },
|
|
2778
|
+
});
|
|
2779
|
+
Logger.customize({
|
|
2780
|
+
name: 'Runner.promptReadMe',
|
|
2781
|
+
purpose: 'updated',
|
|
2782
|
+
padTop: 1,
|
|
2783
|
+
padBottom: 1,
|
|
2784
|
+
}).info('README settings updated.');
|
|
2785
|
+
return 'back';
|
|
2786
|
+
}
|
|
2787
|
+
static async promptMiscellaneousRecipes(entries) {
|
|
2788
|
+
const existingEntry = (entries !== undefined) ? entries['remove-operating-system-files'] : undefined;
|
|
2789
|
+
const enabledOutput = await Runner.promptWithCancel({
|
|
2790
|
+
type: 'confirm',
|
|
2791
|
+
name: 'enabled',
|
|
2792
|
+
message: 'Enable remove-operating-system-files?',
|
|
2793
|
+
initial: existingEntry !== undefined && existingEntry['enabled'] === true,
|
|
2794
|
+
});
|
|
2795
|
+
if (enabledOutput['cancelled'] === true) {
|
|
2796
|
+
return undefined;
|
|
2797
|
+
}
|
|
2798
|
+
const settings = {};
|
|
2799
|
+
const platforms = Object.keys(libItemOperatingSystemFilesByPlatform);
|
|
2800
|
+
for (const platform of platforms) {
|
|
2801
|
+
const existingPlatformSettings = (existingEntry !== undefined && existingEntry['settings'] !== undefined) ? existingEntry['settings'][platform] : undefined;
|
|
2802
|
+
const supportedFileNames = libItemOperatingSystemFilesByPlatform[platform];
|
|
2803
|
+
const fileSettings = {};
|
|
2804
|
+
if (supportedFileNames.length === 0) {
|
|
2805
|
+
Reflect.set(settings, platform, fileSettings);
|
|
2806
|
+
continue;
|
|
2807
|
+
}
|
|
2808
|
+
const selectedFileNames = supportedFileNames.filter((supportedFileName) => existingPlatformSettings !== undefined && Reflect.get(existingPlatformSettings, supportedFileName) === true);
|
|
2809
|
+
const fileOutput = await Runner.promptWithCancel({
|
|
2810
|
+
type: 'multiselect',
|
|
2811
|
+
name: 'fileNames',
|
|
2812
|
+
message: `${platform} files to remove (space to select)`,
|
|
2813
|
+
choices: supportedFileNames.map((supportedFileName) => ({
|
|
2814
|
+
title: libItemOperatingSystemFilePatterns[supportedFileName],
|
|
2815
|
+
description: supportedFileName,
|
|
2816
|
+
value: supportedFileName,
|
|
2817
|
+
selected: selectedFileNames.includes(supportedFileName),
|
|
2818
|
+
})),
|
|
2819
|
+
hint: '- Space to select. Return to submit',
|
|
2820
|
+
});
|
|
2821
|
+
if (fileOutput['cancelled'] === true) {
|
|
2822
|
+
return undefined;
|
|
2823
|
+
}
|
|
2824
|
+
for (const supportedFileName of supportedFileNames) {
|
|
2825
|
+
Reflect.set(fileSettings, supportedFileName, fileOutput['result'].fileNames.includes(supportedFileName));
|
|
2826
|
+
}
|
|
2827
|
+
Reflect.set(settings, platform, fileSettings);
|
|
2828
|
+
}
|
|
2829
|
+
const entry = {
|
|
2830
|
+
enabled: enabledOutput['result'].enabled,
|
|
2831
|
+
settings,
|
|
2832
|
+
};
|
|
2833
|
+
return {
|
|
2834
|
+
'remove-operating-system-files': entry,
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
2837
|
+
static async promptRecipeEntries(entries, allowedRecipeNames, label) {
|
|
2838
|
+
const existingEntries = entries ?? {};
|
|
2839
|
+
const enabledRecipes = allowedRecipeNames.filter((recipeName) => existingEntries[recipeName] !== undefined && existingEntries[recipeName]['enabled'] === true);
|
|
2840
|
+
const enabledOutput = await Runner.promptWithCancel({
|
|
2841
|
+
type: 'multiselect',
|
|
2842
|
+
name: 'enabledRecipes',
|
|
2843
|
+
message: `${label} recipes to enable (space to select)`,
|
|
2844
|
+
choices: allowedRecipeNames.map((recipeName) => ({
|
|
2845
|
+
title: recipeName,
|
|
2846
|
+
value: recipeName,
|
|
2847
|
+
selected: enabledRecipes.includes(recipeName),
|
|
2848
|
+
})),
|
|
2849
|
+
hint: '- Space to select. Return to submit',
|
|
2850
|
+
});
|
|
2851
|
+
if (enabledOutput['cancelled'] === true) {
|
|
2852
|
+
return undefined;
|
|
2853
|
+
}
|
|
2854
|
+
const settingsRecipes = allowedRecipeNames.filter((recipeName) => existingEntries[recipeName] !== undefined && existingEntries[recipeName]['settings'] !== undefined);
|
|
2855
|
+
const settingsOutput = await Runner.promptWithCancel({
|
|
2856
|
+
type: 'multiselect',
|
|
2857
|
+
name: 'settingsRecipes',
|
|
2858
|
+
message: `${label} recipes with custom settings (space to select)`,
|
|
2859
|
+
choices: allowedRecipeNames.map((recipeName) => ({
|
|
2860
|
+
title: recipeName,
|
|
2861
|
+
value: recipeName,
|
|
2862
|
+
selected: settingsRecipes.includes(recipeName),
|
|
2863
|
+
})),
|
|
2864
|
+
hint: '- Space to select. Return to submit',
|
|
2865
|
+
});
|
|
2866
|
+
if (settingsOutput['cancelled'] === true) {
|
|
2867
|
+
return undefined;
|
|
2868
|
+
}
|
|
2869
|
+
const settingsByRecipe = {};
|
|
2870
|
+
for (const recipeName of settingsOutput['result'].settingsRecipes) {
|
|
2871
|
+
const existingSettings = (existingEntries[recipeName] !== undefined && existingEntries[recipeName]['settings'] !== undefined) ? existingEntries[recipeName]['settings'] : {};
|
|
2872
|
+
const recipeSettingsOutput = await Runner.promptWithCancel({
|
|
2873
|
+
type: 'text',
|
|
2874
|
+
name: 'recipeSettings',
|
|
2875
|
+
message: `${recipeName} boolean settings as JSON`,
|
|
2876
|
+
initial: JSON.stringify(existingSettings),
|
|
2877
|
+
validate: Runner['isBooleanRecordInput'],
|
|
2878
|
+
});
|
|
2879
|
+
if (recipeSettingsOutput['cancelled'] === true) {
|
|
2880
|
+
return undefined;
|
|
2881
|
+
}
|
|
2882
|
+
Reflect.set(settingsByRecipe, recipeName, Runner.parseBooleanRecordInput(recipeSettingsOutput['result'].recipeSettings));
|
|
2883
|
+
}
|
|
2884
|
+
const nextEntries = {};
|
|
2885
|
+
for (const recipeName of allowedRecipeNames) {
|
|
2886
|
+
const entry = {
|
|
2887
|
+
enabled: enabledOutput['result'].enabledRecipes.includes(recipeName),
|
|
2888
|
+
};
|
|
2889
|
+
const recipeSettings = settingsByRecipe[recipeName] ?? {};
|
|
2890
|
+
if (Object.keys(recipeSettings).length > 0) {
|
|
2891
|
+
entry.settings = recipeSettings;
|
|
2892
|
+
}
|
|
2893
|
+
Reflect.set(nextEntries, recipeName, entry);
|
|
2894
|
+
}
|
|
2895
|
+
return nextEntries;
|
|
2896
|
+
}
|
|
2897
|
+
static async promptRecipes(config) {
|
|
2898
|
+
const recipes = (config['recipes'] !== undefined) ? { ...config['recipes'] } : {};
|
|
2899
|
+
const packageJsonRecipes = (recipes['package-json'] !== undefined) ? { ...recipes['package-json'] } : {};
|
|
2900
|
+
const targetPaths = Object.keys(config['workspaces'] ?? {});
|
|
2901
|
+
for (const workspacePath of Object.keys(packageJsonRecipes)) {
|
|
2902
|
+
if (targetPaths.includes(workspacePath) === false) {
|
|
2903
|
+
targetPaths.push(workspacePath);
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
targetPaths.sort((pathA, pathB) => pathA.localeCompare(pathB));
|
|
2907
|
+
while (true) {
|
|
2908
|
+
const choices = [
|
|
2909
|
+
{
|
|
2910
|
+
title: 'GitHub',
|
|
2911
|
+
description: 'Repository synchronization recipes.',
|
|
2912
|
+
value: 'github',
|
|
2913
|
+
},
|
|
2914
|
+
{
|
|
2915
|
+
title: 'License',
|
|
2916
|
+
description: 'License-file recipes.',
|
|
2917
|
+
value: 'license',
|
|
2918
|
+
},
|
|
2919
|
+
{
|
|
2920
|
+
title: 'Miscellaneous',
|
|
2921
|
+
description: 'Project cleanup recipes.',
|
|
2922
|
+
value: 'miscellaneous',
|
|
2923
|
+
},
|
|
2924
|
+
{
|
|
2925
|
+
title: 'README',
|
|
2926
|
+
description: 'README generation recipes.',
|
|
2927
|
+
value: 'read-me',
|
|
2928
|
+
},
|
|
2929
|
+
];
|
|
2930
|
+
for (const workspacePath of targetPaths) {
|
|
2931
|
+
choices.push({
|
|
2932
|
+
title: `Package JSON: ${workspacePath}`,
|
|
2933
|
+
description: 'Package metadata and normalization recipes.',
|
|
2934
|
+
value: `package-json:${workspacePath}`,
|
|
2935
|
+
});
|
|
2936
|
+
}
|
|
2937
|
+
choices.push({
|
|
2938
|
+
title: 'Back',
|
|
2939
|
+
description: 'Return to the category selection.',
|
|
2940
|
+
value: 'back',
|
|
2941
|
+
});
|
|
2942
|
+
const menuOutput = await Runner.promptWithCancel({
|
|
2943
|
+
type: 'select',
|
|
2944
|
+
name: 'target',
|
|
2945
|
+
message: 'Select a recipe category to manage.',
|
|
2946
|
+
choices,
|
|
2947
|
+
});
|
|
2948
|
+
if (menuOutput['cancelled'] === true || menuOutput['result'].target === 'back') {
|
|
2949
|
+
Reflect.set(recipes, 'package-json', packageJsonRecipes);
|
|
2950
|
+
Object.assign(config, { recipes });
|
|
2951
|
+
return 'back';
|
|
2952
|
+
}
|
|
2953
|
+
const target = menuOutput['result'].target;
|
|
2954
|
+
let entries = recipes['read-me'];
|
|
2955
|
+
let allowedRecipeNames = libItemRecipesByCategory['read-me'];
|
|
2956
|
+
let label = 'README';
|
|
2957
|
+
if (target.startsWith('package-json:') === true) {
|
|
2958
|
+
const workspacePath = target.slice('package-json:'.length);
|
|
2959
|
+
entries = packageJsonRecipes[workspacePath];
|
|
2960
|
+
allowedRecipeNames = libItemRecipesByCategory['package-json'];
|
|
2961
|
+
label = `Package JSON (${workspacePath})`;
|
|
2962
|
+
const workspaceEntries = await Runner.promptRecipeEntries(entries, allowedRecipeNames, label);
|
|
2963
|
+
if (workspaceEntries !== undefined) {
|
|
2964
|
+
Reflect.set(packageJsonRecipes, workspacePath, workspaceEntries);
|
|
2965
|
+
}
|
|
2966
|
+
continue;
|
|
2967
|
+
}
|
|
2968
|
+
if (target === 'miscellaneous') {
|
|
2969
|
+
const miscellaneousEntries = await Runner.promptMiscellaneousRecipes(recipes['miscellaneous']);
|
|
2970
|
+
if (miscellaneousEntries !== undefined) {
|
|
2971
|
+
Reflect.set(recipes, 'miscellaneous', miscellaneousEntries);
|
|
2972
|
+
}
|
|
2973
|
+
continue;
|
|
2974
|
+
}
|
|
2975
|
+
if (target === 'github') {
|
|
2976
|
+
entries = recipes['github'];
|
|
2977
|
+
allowedRecipeNames = libItemRecipesByCategory['github'];
|
|
2978
|
+
label = 'GitHub';
|
|
2979
|
+
}
|
|
2980
|
+
else if (target === 'license') {
|
|
2981
|
+
entries = recipes['license'];
|
|
2982
|
+
allowedRecipeNames = libItemRecipesByCategory['license'];
|
|
2983
|
+
label = 'License';
|
|
2984
|
+
}
|
|
2985
|
+
const categoryEntries = await Runner.promptRecipeEntries(entries, allowedRecipeNames, label);
|
|
2986
|
+
if (categoryEntries !== undefined) {
|
|
2987
|
+
Reflect.set(recipes, target, categoryEntries);
|
|
2988
|
+
}
|
|
1678
2989
|
}
|
|
1679
|
-
const badges = badgesOutput['result'].readMeBadges ?? [];
|
|
1680
|
-
Object.assign(config, {
|
|
1681
|
-
readme: { badges },
|
|
1682
|
-
});
|
|
1683
|
-
Logger.customize({
|
|
1684
|
-
name: 'Runner.promptReadMe',
|
|
1685
|
-
purpose: 'updated',
|
|
1686
|
-
padTop: 1,
|
|
1687
|
-
padBottom: 1,
|
|
1688
|
-
}).info('README settings updated.');
|
|
1689
|
-
return 'back';
|
|
1690
2990
|
}
|
|
1691
2991
|
static async promptUrls(config) {
|
|
1692
2992
|
const existingUrls = config['urls'];
|
|
@@ -1905,7 +3205,40 @@ export class Runner {
|
|
|
1905
3205
|
for (const configWorkflow of configWorkflows) {
|
|
1906
3206
|
const clonedWorkflow = { ...configWorkflow };
|
|
1907
3207
|
if (Array.isArray(configWorkflow['triggers']) === true) {
|
|
1908
|
-
clonedWorkflow.triggers =
|
|
3208
|
+
clonedWorkflow.triggers = configWorkflow['triggers'].map((trigger) => {
|
|
3209
|
+
if (typeof trigger === 'string') {
|
|
3210
|
+
return trigger;
|
|
3211
|
+
}
|
|
3212
|
+
const clonedTrigger = { ...trigger };
|
|
3213
|
+
if (trigger['branches'] !== undefined) {
|
|
3214
|
+
clonedTrigger.branches = [...trigger['branches']];
|
|
3215
|
+
}
|
|
3216
|
+
if (trigger['paths'] !== undefined) {
|
|
3217
|
+
clonedTrigger.paths = [...trigger['paths']];
|
|
3218
|
+
}
|
|
3219
|
+
if (trigger['tags'] !== undefined) {
|
|
3220
|
+
clonedTrigger.tags = [...trigger['tags']];
|
|
3221
|
+
}
|
|
3222
|
+
if (trigger['workflows'] !== undefined) {
|
|
3223
|
+
clonedTrigger.workflows = [...trigger['workflows']];
|
|
3224
|
+
}
|
|
3225
|
+
return clonedTrigger;
|
|
3226
|
+
});
|
|
3227
|
+
}
|
|
3228
|
+
if (configWorkflow['build'] !== undefined) {
|
|
3229
|
+
clonedWorkflow.build = [...configWorkflow['build']];
|
|
3230
|
+
}
|
|
3231
|
+
if (configWorkflow['deploy'] !== undefined) {
|
|
3232
|
+
clonedWorkflow.deploy = configWorkflow['deploy'].map((target) => {
|
|
3233
|
+
const clonedTarget = { ...target };
|
|
3234
|
+
if (target['after'] !== undefined) {
|
|
3235
|
+
clonedTarget.after = [...target['after']];
|
|
3236
|
+
}
|
|
3237
|
+
if (target['with'] !== undefined) {
|
|
3238
|
+
clonedTarget.with = { ...target['with'] };
|
|
3239
|
+
}
|
|
3240
|
+
return clonedTarget;
|
|
3241
|
+
});
|
|
1909
3242
|
}
|
|
1910
3243
|
if (configWorkflow['with'] !== undefined) {
|
|
1911
3244
|
clonedWorkflow.with = { ...configWorkflow['with'] };
|
|
@@ -1921,7 +3254,46 @@ export class Runner {
|
|
|
1921
3254
|
const normalizedWorkflows = workflows.map((workflow) => {
|
|
1922
3255
|
const normalizedWorkflow = { ...workflow };
|
|
1923
3256
|
if (Array.isArray(workflow['triggers']) === true && workflow['triggers'].length > 0) {
|
|
1924
|
-
normalizedWorkflow.triggers =
|
|
3257
|
+
normalizedWorkflow.triggers = workflow['triggers'].map((trigger) => {
|
|
3258
|
+
if (typeof trigger === 'string') {
|
|
3259
|
+
return trigger;
|
|
3260
|
+
}
|
|
3261
|
+
const clonedTrigger = { ...trigger };
|
|
3262
|
+
if (trigger['branches'] !== undefined) {
|
|
3263
|
+
clonedTrigger.branches = [...trigger['branches']];
|
|
3264
|
+
}
|
|
3265
|
+
if (trigger['paths'] !== undefined) {
|
|
3266
|
+
clonedTrigger.paths = [...trigger['paths']];
|
|
3267
|
+
}
|
|
3268
|
+
if (trigger['tags'] !== undefined) {
|
|
3269
|
+
clonedTrigger.tags = [...trigger['tags']];
|
|
3270
|
+
}
|
|
3271
|
+
if (trigger['workflows'] !== undefined) {
|
|
3272
|
+
clonedTrigger.workflows = [...trigger['workflows']];
|
|
3273
|
+
}
|
|
3274
|
+
return clonedTrigger;
|
|
3275
|
+
});
|
|
3276
|
+
}
|
|
3277
|
+
if (workflow['build'] !== undefined && workflow['build'].length > 0) {
|
|
3278
|
+
normalizedWorkflow.build = [...workflow['build']];
|
|
3279
|
+
}
|
|
3280
|
+
else {
|
|
3281
|
+
Reflect.deleteProperty(normalizedWorkflow, 'build');
|
|
3282
|
+
}
|
|
3283
|
+
if (workflow['deploy'] !== undefined && workflow['deploy'].length > 0) {
|
|
3284
|
+
normalizedWorkflow.deploy = workflow['deploy'].map((target) => {
|
|
3285
|
+
const clonedTarget = { ...target };
|
|
3286
|
+
if (target['after'] !== undefined) {
|
|
3287
|
+
clonedTarget.after = [...target['after']];
|
|
3288
|
+
}
|
|
3289
|
+
if (target['with'] !== undefined) {
|
|
3290
|
+
clonedTarget.with = { ...target['with'] };
|
|
3291
|
+
}
|
|
3292
|
+
return clonedTarget;
|
|
3293
|
+
});
|
|
3294
|
+
}
|
|
3295
|
+
else {
|
|
3296
|
+
Reflect.deleteProperty(normalizedWorkflow, 'deploy');
|
|
1925
3297
|
}
|
|
1926
3298
|
if (workflow['with'] !== undefined && Object.keys(workflow['with']).length > 0) {
|
|
1927
3299
|
normalizedWorkflow.with = { ...workflow['with'] };
|
|
@@ -2089,16 +3461,6 @@ export class Runner {
|
|
|
2089
3461
|
const existingSuffix = (workflow !== undefined && typeof workflow['name'] === 'string') ? workflow['name'] : '';
|
|
2090
3462
|
const existingTriggers = (workflow !== undefined && Array.isArray(workflow['triggers']) === true) ? workflow['triggers'] : [];
|
|
2091
3463
|
const existingTriggerNames = existingTriggers.map((trigger) => (typeof trigger === 'string') ? trigger : trigger['name']);
|
|
2092
|
-
const existingUpstreamWorkflows = [];
|
|
2093
|
-
for (const trigger of existingTriggers) {
|
|
2094
|
-
if (typeof trigger !== 'string' && Array.isArray(trigger['workflows']) === true) {
|
|
2095
|
-
for (const upstream of trigger['workflows']) {
|
|
2096
|
-
if (existingUpstreamWorkflows.includes(upstream) === false) {
|
|
2097
|
-
existingUpstreamWorkflows.push(upstream);
|
|
2098
|
-
}
|
|
2099
|
-
}
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
3464
|
const existingTargets = (workflow !== undefined && Array.isArray(workflow['deploy']) === true) ? workflow['deploy'] : [];
|
|
2103
3465
|
const existingScopes = (workflow !== undefined && Array.isArray(workflow['build']) === true) ? workflow['build'] : [];
|
|
2104
3466
|
const templateChoices = libWorkflowTemplatesMetadata.map((entry) => ({
|
|
@@ -2106,6 +3468,13 @@ export class Runner {
|
|
|
2106
3468
|
description: entry['description'],
|
|
2107
3469
|
value: entry['name'],
|
|
2108
3470
|
}));
|
|
3471
|
+
if (existingTemplate !== '' && templateChoices.some((choice) => choice['value'] === existingTemplate) === false) {
|
|
3472
|
+
templateChoices.unshift({
|
|
3473
|
+
title: existingTemplate,
|
|
3474
|
+
description: 'Keep the existing custom workflow template.',
|
|
3475
|
+
value: existingTemplate,
|
|
3476
|
+
});
|
|
3477
|
+
}
|
|
2109
3478
|
let templateInitialIndex = 0;
|
|
2110
3479
|
if (existingTemplate !== '') {
|
|
2111
3480
|
const foundIndex = templateChoices.findIndex((choice) => choice['value'] === existingTemplate);
|
|
@@ -2161,17 +3530,29 @@ export class Runner {
|
|
|
2161
3530
|
const selectedSuffix = (typeof suffixOutputResultValue.suffix === 'string') ? suffixOutputResultValue.suffix.trim() : '';
|
|
2162
3531
|
const triggersDir = join(resolveTemplatePath(import.meta.url, 'generators/github/workflows'), selectedTemplate, 'triggers');
|
|
2163
3532
|
const triggersDirExists = await pathExists(triggersDir);
|
|
3533
|
+
const triggerChoices = [];
|
|
2164
3534
|
let selectedTriggers = [];
|
|
2165
3535
|
if (triggersDirExists === true) {
|
|
2166
3536
|
const triggersFiles = (await fs.readdir(triggersDir)).filter((file) => file.endsWith('.yml'));
|
|
2167
|
-
|
|
3537
|
+
triggerChoices.push(...triggersFiles.map((file) => {
|
|
2168
3538
|
const triggerName = file.replace(LIB_REGEX_PATTERN_YML_EXTENSION, '');
|
|
2169
3539
|
return {
|
|
2170
3540
|
title: triggerName,
|
|
2171
3541
|
value: triggerName,
|
|
2172
3542
|
selected: existingTriggerNames.includes(triggerName),
|
|
2173
3543
|
};
|
|
2174
|
-
});
|
|
3544
|
+
}));
|
|
3545
|
+
}
|
|
3546
|
+
for (const existingTriggerName of existingTriggerNames) {
|
|
3547
|
+
if (triggerChoices.some((choice) => choice['value'] === existingTriggerName) === false) {
|
|
3548
|
+
triggerChoices.push({
|
|
3549
|
+
title: existingTriggerName,
|
|
3550
|
+
value: existingTriggerName,
|
|
3551
|
+
selected: true,
|
|
3552
|
+
});
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
if (triggerChoices.length > 0) {
|
|
2175
3556
|
const triggersOutput = await Runner.promptWithCancel({
|
|
2176
3557
|
type: 'multiselect',
|
|
2177
3558
|
name: 'triggers',
|
|
@@ -2198,41 +3579,101 @@ export class Runner {
|
|
|
2198
3579
|
};
|
|
2199
3580
|
}
|
|
2200
3581
|
}
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
3582
|
+
const advancedTriggerChoices = selectedTriggers.map((triggerName) => ({
|
|
3583
|
+
title: triggerName,
|
|
3584
|
+
value: triggerName,
|
|
3585
|
+
selected: existingTriggers.some((trigger) => typeof trigger !== 'string' && trigger['name'] === triggerName),
|
|
3586
|
+
}));
|
|
3587
|
+
let advancedTriggerNames = [];
|
|
3588
|
+
if (advancedTriggerChoices.length > 0) {
|
|
3589
|
+
const advancedTriggersOutput = await Runner.promptWithCancel({
|
|
3590
|
+
type: 'multiselect',
|
|
3591
|
+
name: 'advancedTriggers',
|
|
3592
|
+
message: 'Select triggers that need branch, path, tag, or workflow filters.',
|
|
3593
|
+
choices: advancedTriggerChoices,
|
|
3594
|
+
hint: '- Space to select. Return to submit',
|
|
3595
|
+
});
|
|
3596
|
+
if (advancedTriggersOutput['cancelled'] === true) {
|
|
3597
|
+
return {
|
|
3598
|
+
action: 'back',
|
|
3599
|
+
};
|
|
3600
|
+
}
|
|
3601
|
+
const advancedTriggersOutputResultValue = advancedTriggersOutput['result'];
|
|
3602
|
+
advancedTriggerNames = advancedTriggersOutputResultValue.advancedTriggers;
|
|
3603
|
+
}
|
|
3604
|
+
const resolvedTriggers = [];
|
|
3605
|
+
for (const selectedTrigger of selectedTriggers) {
|
|
3606
|
+
if (advancedTriggerNames.includes(selectedTrigger) === false) {
|
|
3607
|
+
resolvedTriggers.push(selectedTrigger);
|
|
3608
|
+
continue;
|
|
3609
|
+
}
|
|
3610
|
+
const existingTrigger = existingTriggers.find((trigger) => typeof trigger !== 'string' && trigger['name'] === selectedTrigger);
|
|
3611
|
+
const triggerFilterOutput = await Runner.promptWithCancel([
|
|
3612
|
+
{
|
|
3613
|
+
type: 'text',
|
|
3614
|
+
name: 'branches',
|
|
3615
|
+
message: `${selectedTrigger} branch filters as a JSON array (blank unsets)`,
|
|
3616
|
+
initial: (existingTrigger !== undefined && existingTrigger['branches'] !== undefined) ? JSON.stringify(existingTrigger['branches']) : '',
|
|
3617
|
+
validate: Runner['isStringArrayInput'],
|
|
3618
|
+
},
|
|
3619
|
+
{
|
|
3620
|
+
type: 'text',
|
|
3621
|
+
name: 'paths',
|
|
3622
|
+
message: `${selectedTrigger} path filters as a JSON array (blank unsets)`,
|
|
3623
|
+
initial: (existingTrigger !== undefined && existingTrigger['paths'] !== undefined) ? JSON.stringify(existingTrigger['paths']) : '',
|
|
3624
|
+
validate: Runner['isStringArrayInput'],
|
|
3625
|
+
},
|
|
3626
|
+
{
|
|
3627
|
+
type: 'text',
|
|
3628
|
+
name: 'tags',
|
|
3629
|
+
message: `${selectedTrigger} tag filters as a JSON array (blank unsets)`,
|
|
3630
|
+
initial: (existingTrigger !== undefined && existingTrigger['tags'] !== undefined) ? JSON.stringify(existingTrigger['tags']) : '',
|
|
3631
|
+
validate: Runner['isStringArrayInput'],
|
|
3632
|
+
},
|
|
3633
|
+
{
|
|
3634
|
+
type: 'text',
|
|
3635
|
+
name: 'workflows',
|
|
3636
|
+
message: `${selectedTrigger} upstream workflows as a JSON array (blank unsets)`,
|
|
3637
|
+
initial: (existingTrigger !== undefined && existingTrigger['workflows'] !== undefined) ? JSON.stringify(existingTrigger['workflows']) : '',
|
|
3638
|
+
validate: Runner['isStringArrayInput'],
|
|
3639
|
+
},
|
|
3640
|
+
]);
|
|
3641
|
+
if (triggerFilterOutput['cancelled'] === true) {
|
|
2209
3642
|
return {
|
|
2210
|
-
|
|
2211
|
-
value: upstreamWorkflowKey,
|
|
2212
|
-
selected: existingUpstreamWorkflows.includes(upstreamWorkflowKey),
|
|
3643
|
+
action: 'back',
|
|
2213
3644
|
};
|
|
2214
|
-
});
|
|
2215
|
-
if (upstreamWorkflowChoices.length > 0) {
|
|
2216
|
-
const upstreamWorkflowsOutput = await Runner.promptWithCancel({
|
|
2217
|
-
type: 'multiselect',
|
|
2218
|
-
name: 'upstreamWorkflows',
|
|
2219
|
-
message: 'Select upstream workflows that can start this workflow.',
|
|
2220
|
-
choices: upstreamWorkflowChoices,
|
|
2221
|
-
});
|
|
2222
|
-
if (upstreamWorkflowsOutput['cancelled'] === true) {
|
|
2223
|
-
return {
|
|
2224
|
-
action: 'back',
|
|
2225
|
-
};
|
|
2226
|
-
}
|
|
2227
|
-
const upstreamWorkflowsOutputResultValue = upstreamWorkflowsOutput['result'];
|
|
2228
|
-
selectedUpstreamWorkflows = (Array.isArray(upstreamWorkflowsOutputResultValue.upstreamWorkflows) === true && upstreamWorkflowsOutputResultValue.upstreamWorkflows.length > 0) ? upstreamWorkflowsOutputResultValue.upstreamWorkflows : undefined;
|
|
2229
3645
|
}
|
|
3646
|
+
const triggerFilterOutputResult = triggerFilterOutput['result'];
|
|
3647
|
+
const branches = Runner.parseStringArrayInput(triggerFilterOutputResult.branches);
|
|
3648
|
+
const paths = Runner.parseStringArrayInput(triggerFilterOutputResult.paths);
|
|
3649
|
+
const tags = Runner.parseStringArrayInput(triggerFilterOutputResult.tags);
|
|
3650
|
+
const triggerWorkflows = Runner.parseStringArrayInput(triggerFilterOutputResult.workflows);
|
|
3651
|
+
const triggerObject = {
|
|
3652
|
+
name: selectedTrigger,
|
|
3653
|
+
...((branches.length > 0) ? { branches } : {}),
|
|
3654
|
+
...((paths.length > 0) ? { paths } : {}),
|
|
3655
|
+
...((tags.length > 0) ? { tags } : {}),
|
|
3656
|
+
...((triggerWorkflows.length > 0) ? { workflows: triggerWorkflows } : {}),
|
|
3657
|
+
};
|
|
3658
|
+
resolvedTriggers.push(triggerObject);
|
|
2230
3659
|
}
|
|
2231
3660
|
const matchedMetadata = libWorkflowTemplatesMetadata.find((entry) => entry['name'] === selectedTemplate);
|
|
2232
3661
|
const workspaceKeys = Object.keys(config['workspaces'] ?? {});
|
|
2233
|
-
const selectedTargets =
|
|
2234
|
-
|
|
2235
|
-
|
|
3662
|
+
const selectedTargets = existingTargets.map((target) => ({
|
|
3663
|
+
...target,
|
|
3664
|
+
...((target['after'] !== undefined) ? { after: [...target['after']] } : {}),
|
|
3665
|
+
...((target['with'] !== undefined) ? { with: { ...target['with'] } } : {}),
|
|
3666
|
+
}));
|
|
3667
|
+
if ((matchedMetadata !== undefined
|
|
3668
|
+
&& matchedMetadata['supportsTargets'] === true)
|
|
3669
|
+
|| selectedTargets.length > 0) {
|
|
3670
|
+
const availableTargetTypes = (matchedMetadata !== undefined) ? Object.keys(matchedMetadata['targets'] ?? {}) : [];
|
|
3671
|
+
const existingTargetTypes = selectedTargets.map((target) => target['to']);
|
|
3672
|
+
for (const existingTargetType of existingTargetTypes) {
|
|
3673
|
+
if (availableTargetTypes.includes(existingTargetType) === false) {
|
|
3674
|
+
availableTargetTypes.push(existingTargetType);
|
|
3675
|
+
}
|
|
3676
|
+
}
|
|
2236
3677
|
while (true) {
|
|
2237
3678
|
const targetMenuChoices = [];
|
|
2238
3679
|
for (let i = 0; i < selectedTargets.length; i += 1) {
|
|
@@ -2317,6 +3758,12 @@ export class Runner {
|
|
|
2317
3758
|
title: workspaceKey,
|
|
2318
3759
|
value: workspaceKey,
|
|
2319
3760
|
}));
|
|
3761
|
+
if (targetToEdit !== undefined && targetWorkingDirChoices.some((choice) => choice['value'] === targetToEdit['path']) === false) {
|
|
3762
|
+
targetWorkingDirChoices.unshift({
|
|
3763
|
+
title: targetToEdit['path'],
|
|
3764
|
+
value: targetToEdit['path'],
|
|
3765
|
+
});
|
|
3766
|
+
}
|
|
2320
3767
|
const targetWorkingDirOutput = await Runner.promptWithCancel({
|
|
2321
3768
|
type: 'select',
|
|
2322
3769
|
name: 'targetWorkingDir',
|
|
@@ -2370,6 +3817,17 @@ export class Runner {
|
|
|
2370
3817
|
const targetNeedsOutputResultValue = targetNeedsOutput['result'];
|
|
2371
3818
|
selectedTargetNeeds = (Array.isArray(targetNeedsOutputResultValue.targetNeeds) === true && targetNeedsOutputResultValue.targetNeeds.length > 0) ? targetNeedsOutputResultValue.targetNeeds : undefined;
|
|
2372
3819
|
}
|
|
3820
|
+
const targetSettingsOutput = await Runner.promptWithCancel({
|
|
3821
|
+
type: 'text',
|
|
3822
|
+
name: 'targetSettings',
|
|
3823
|
+
message: 'Target settings as a JSON object (blank unsets)',
|
|
3824
|
+
initial: (targetToEdit !== undefined && targetToEdit['with'] !== undefined) ? JSON.stringify(targetToEdit['with']) : '',
|
|
3825
|
+
validate: Runner['isStringRecordInput'],
|
|
3826
|
+
});
|
|
3827
|
+
if (targetSettingsOutput['cancelled'] === true) {
|
|
3828
|
+
continue;
|
|
3829
|
+
}
|
|
3830
|
+
const targetSettings = Runner.parseStringRecordInput(targetSettingsOutput['result'].targetSettings);
|
|
2373
3831
|
const newTarget = {
|
|
2374
3832
|
to: selectedTargetType,
|
|
2375
3833
|
path: selectedTargetWorkingDir,
|
|
@@ -2377,6 +3835,9 @@ export class Runner {
|
|
|
2377
3835
|
if (selectedTargetNeeds !== undefined) {
|
|
2378
3836
|
Reflect.set(newTarget, 'after', selectedTargetNeeds);
|
|
2379
3837
|
}
|
|
3838
|
+
if (Object.keys(targetSettings).length > 0) {
|
|
3839
|
+
newTarget.with = targetSettings;
|
|
3840
|
+
}
|
|
2380
3841
|
if (targetEditIndex >= 0) {
|
|
2381
3842
|
Reflect.set(selectedTargets, targetEditIndex, newTarget);
|
|
2382
3843
|
}
|
|
@@ -2387,10 +3848,16 @@ export class Runner {
|
|
|
2387
3848
|
}
|
|
2388
3849
|
}
|
|
2389
3850
|
}
|
|
2390
|
-
let selectedScopes = [];
|
|
3851
|
+
let selectedScopes = [...existingScopes];
|
|
2391
3852
|
if (matchedMetadata !== undefined && matchedMetadata['supportsScopes'] === true) {
|
|
2392
3853
|
const lockedPaths = new Set(selectedTargets.map((selectedTarget) => selectedTarget['path']));
|
|
2393
|
-
const
|
|
3854
|
+
const scopeCandidates = [...workspaceKeys];
|
|
3855
|
+
for (const existingScope of existingScopes) {
|
|
3856
|
+
if (scopeCandidates.includes(existingScope) === false) {
|
|
3857
|
+
scopeCandidates.push(existingScope);
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
const extraWorkspaceKeys = scopeCandidates.filter((workspaceKey) => lockedPaths.has(workspaceKey) === false);
|
|
2394
3861
|
selectedScopes = [...lockedPaths];
|
|
2395
3862
|
if (extraWorkspaceKeys.length > 0) {
|
|
2396
3863
|
const scopeChoices = extraWorkspaceKeys.map((workspaceKey) => ({
|
|
@@ -2418,7 +3885,7 @@ export class Runner {
|
|
|
2418
3885
|
}
|
|
2419
3886
|
}
|
|
2420
3887
|
}
|
|
2421
|
-
const settings = {};
|
|
3888
|
+
const settings = (workflow !== undefined && workflow['with'] !== undefined) ? { ...workflow['with'] } : {};
|
|
2422
3889
|
if (matchedMetadata !== undefined) {
|
|
2423
3890
|
const mergedVariables = { ...matchedMetadata['variables'] };
|
|
2424
3891
|
const variableNameToTargetWorkingDir = {};
|
|
@@ -2502,17 +3969,28 @@ export class Runner {
|
|
|
2502
3969
|
if (settingValue !== '' && isDefaultRootWorkingDir === false) {
|
|
2503
3970
|
Reflect.set(settings, variableName, settingValue);
|
|
2504
3971
|
}
|
|
3972
|
+
else {
|
|
3973
|
+
Reflect.deleteProperty(settings, variableName);
|
|
3974
|
+
}
|
|
2505
3975
|
}
|
|
2506
3976
|
}
|
|
2507
|
-
const
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
}
|
|
2514
|
-
return trigger;
|
|
3977
|
+
const reviewedSettingsOutput = await Runner.promptWithCancel({
|
|
3978
|
+
type: 'text',
|
|
3979
|
+
name: 'reviewedSettings',
|
|
3980
|
+
message: 'Review all workflow settings as a JSON object (blank unsets)',
|
|
3981
|
+
initial: (Object.keys(settings).length > 0) ? JSON.stringify(settings) : '',
|
|
3982
|
+
validate: Runner['isStringRecordInput'],
|
|
2515
3983
|
});
|
|
3984
|
+
if (reviewedSettingsOutput['cancelled'] === true) {
|
|
3985
|
+
return {
|
|
3986
|
+
action: 'back',
|
|
3987
|
+
};
|
|
3988
|
+
}
|
|
3989
|
+
const reviewedSettings = Runner.parseStringRecordInput(reviewedSettingsOutput['result'].reviewedSettings);
|
|
3990
|
+
for (const settingName of Object.keys(settings)) {
|
|
3991
|
+
Reflect.deleteProperty(settings, settingName);
|
|
3992
|
+
}
|
|
3993
|
+
Object.assign(settings, reviewedSettings);
|
|
2516
3994
|
const resolvedWorkflow = {
|
|
2517
3995
|
template: selectedTemplate,
|
|
2518
3996
|
name: selectedSuffix,
|
|
@@ -2550,24 +4028,23 @@ export class Runner {
|
|
|
2550
4028
|
const confirmOutputResult = confirmOutput['result'];
|
|
2551
4029
|
return confirmOutputResult.confirm;
|
|
2552
4030
|
}
|
|
2553
|
-
static async promptGitignore(config) {
|
|
2554
|
-
const
|
|
2555
|
-
const
|
|
2556
|
-
|
|
4031
|
+
static async promptGitignore(config, targetPath) {
|
|
4032
|
+
const existingIgnoreFiles = config['ignoreFiles'] ?? {};
|
|
4033
|
+
const existing = existingIgnoreFiles[targetPath];
|
|
4034
|
+
const bundles = (existing === undefined) ? getSupportedIgnoreFileBundles(targetPath) : existing['bundles'];
|
|
4035
|
+
const excludes = (existing === undefined || existing['patterns'] === undefined) ? [] : [...existing['patterns']];
|
|
4036
|
+
if (existing === undefined && targetPath === './.gitignore') {
|
|
2557
4037
|
const imported = await Runner.importGitignoreExcludes();
|
|
2558
4038
|
excludes.push(...imported);
|
|
2559
4039
|
}
|
|
2560
4040
|
const sync = () => {
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
}
|
|
2568
|
-
else {
|
|
2569
|
-
Reflect.deleteProperty(config, 'gitignore');
|
|
2570
|
-
}
|
|
4041
|
+
Reflect.set(existingIgnoreFiles, targetPath, {
|
|
4042
|
+
bundles: [...bundles],
|
|
4043
|
+
patterns: [...excludes],
|
|
4044
|
+
});
|
|
4045
|
+
Object.assign(config, {
|
|
4046
|
+
ignoreFiles: existingIgnoreFiles,
|
|
4047
|
+
});
|
|
2571
4048
|
return;
|
|
2572
4049
|
};
|
|
2573
4050
|
while (true) {
|
|
@@ -2596,7 +4073,7 @@ export class Runner {
|
|
|
2596
4073
|
}
|
|
2597
4074
|
choices.push({
|
|
2598
4075
|
title: 'Add a pattern',
|
|
2599
|
-
description:
|
|
4076
|
+
description: `Add a new pattern to "${targetPath}".`,
|
|
2600
4077
|
value: {
|
|
2601
4078
|
kind: 'add',
|
|
2602
4079
|
},
|
|
@@ -2716,6 +4193,133 @@ export class Runner {
|
|
|
2716
4193
|
}
|
|
2717
4194
|
}
|
|
2718
4195
|
}
|
|
4196
|
+
static async promptIgnoreFileBundles(config, targetPath) {
|
|
4197
|
+
const ignoreFiles = config['ignoreFiles'] ?? {};
|
|
4198
|
+
const existing = ignoreFiles[targetPath];
|
|
4199
|
+
const supportedBundles = getSupportedIgnoreFileBundles(targetPath);
|
|
4200
|
+
const output = await Runner.promptWithCancel({
|
|
4201
|
+
type: 'multiselect',
|
|
4202
|
+
name: 'bundles',
|
|
4203
|
+
message: `Nova bundles for "${targetPath}" (space to select)`,
|
|
4204
|
+
choices: supportedBundles.map((bundle) => ({
|
|
4205
|
+
title: bundle,
|
|
4206
|
+
value: bundle,
|
|
4207
|
+
selected: (existing === undefined) ? true : existing['bundles'].includes(bundle),
|
|
4208
|
+
})),
|
|
4209
|
+
hint: '- Space to select. Return to submit',
|
|
4210
|
+
});
|
|
4211
|
+
if (output['cancelled'] === true) {
|
|
4212
|
+
return false;
|
|
4213
|
+
}
|
|
4214
|
+
const selectedBundles = output['result'].bundles;
|
|
4215
|
+
Reflect.set(ignoreFiles, targetPath, {
|
|
4216
|
+
bundles: selectedBundles,
|
|
4217
|
+
...((existing !== undefined && existing['patterns'] !== undefined) ? { patterns: [...existing['patterns']] } : {}),
|
|
4218
|
+
});
|
|
4219
|
+
Object.assign(config, { ignoreFiles });
|
|
4220
|
+
return true;
|
|
4221
|
+
}
|
|
4222
|
+
static async promptIgnoreFiles(config) {
|
|
4223
|
+
const ignoreFiles = config['ignoreFiles'] ?? {};
|
|
4224
|
+
Object.assign(config, { ignoreFiles });
|
|
4225
|
+
while (true) {
|
|
4226
|
+
const paths = Object.keys(ignoreFiles).sort((pathA, pathB) => pathA.localeCompare(pathB));
|
|
4227
|
+
const choices = [];
|
|
4228
|
+
for (const path of paths) {
|
|
4229
|
+
const entry = ignoreFiles[path];
|
|
4230
|
+
if (entry === undefined) {
|
|
4231
|
+
continue;
|
|
4232
|
+
}
|
|
4233
|
+
const patternCount = (entry['patterns'] !== undefined) ? entry['patterns'].length : 0;
|
|
4234
|
+
choices.push({
|
|
4235
|
+
title: `${chalk.cyan.bold('[BUNDLES]')} ${path}`,
|
|
4236
|
+
description: entry['bundles'].join(', ') || 'No Nova bundles selected.',
|
|
4237
|
+
value: `bundles:${path}`,
|
|
4238
|
+
});
|
|
4239
|
+
choices.push({
|
|
4240
|
+
title: `${chalk.yellow.bold('[PATTERNS]')} ${path}`,
|
|
4241
|
+
description: `${patternCount} project pattern(s).`,
|
|
4242
|
+
value: `patterns:${path}`,
|
|
4243
|
+
});
|
|
4244
|
+
choices.push({
|
|
4245
|
+
title: `${chalk.red.bold('[REMOVE]')} ${path}`,
|
|
4246
|
+
description: 'Stop generating this physical ignore file.',
|
|
4247
|
+
value: `remove:${path}`,
|
|
4248
|
+
});
|
|
4249
|
+
}
|
|
4250
|
+
choices.push({
|
|
4251
|
+
title: 'Add an ignore file',
|
|
4252
|
+
description: 'Add a project-relative .gitignore, .dockerignore, or .assetsignore path.',
|
|
4253
|
+
value: 'add',
|
|
4254
|
+
});
|
|
4255
|
+
choices.push({
|
|
4256
|
+
title: 'Back',
|
|
4257
|
+
description: 'Return to the category selection.',
|
|
4258
|
+
value: 'back',
|
|
4259
|
+
});
|
|
4260
|
+
const menuOutput = await Runner.promptWithCancel({
|
|
4261
|
+
type: 'select',
|
|
4262
|
+
name: 'action',
|
|
4263
|
+
message: (paths.length > 0) ? 'Select an ignore file to manage.' : 'No ignore files configured. Choose an option.',
|
|
4264
|
+
choices,
|
|
4265
|
+
});
|
|
4266
|
+
if (menuOutput['cancelled'] === true || menuOutput['result'].action === 'back') {
|
|
4267
|
+
if (Object.keys(ignoreFiles).length === 0) {
|
|
4268
|
+
Reflect.deleteProperty(config, 'ignoreFiles');
|
|
4269
|
+
}
|
|
4270
|
+
return 'back';
|
|
4271
|
+
}
|
|
4272
|
+
const action = menuOutput['result'].action;
|
|
4273
|
+
if (action === 'add') {
|
|
4274
|
+
const pathOutput = await Runner.promptWithCancel({
|
|
4275
|
+
type: 'text',
|
|
4276
|
+
name: 'path',
|
|
4277
|
+
message: 'Project-relative ignore-file path',
|
|
4278
|
+
initial: './.gitignore',
|
|
4279
|
+
validate: Runner['isIgnoreFilePathInput'],
|
|
4280
|
+
});
|
|
4281
|
+
if (pathOutput['cancelled'] === true) {
|
|
4282
|
+
continue;
|
|
4283
|
+
}
|
|
4284
|
+
const addedTargetPath = pathOutput['result'].path.trim();
|
|
4285
|
+
if (ignoreFiles[addedTargetPath] !== undefined) {
|
|
4286
|
+
Logger.customize({
|
|
4287
|
+
name: 'Runner.promptIgnoreFiles',
|
|
4288
|
+
purpose: 'duplicate',
|
|
4289
|
+
padTop: 1,
|
|
4290
|
+
padBottom: 1,
|
|
4291
|
+
}).error(`Ignore file "${addedTargetPath}" is already configured.`);
|
|
4292
|
+
continue;
|
|
4293
|
+
}
|
|
4294
|
+
await Runner.promptIgnoreFileBundles(config, addedTargetPath);
|
|
4295
|
+
continue;
|
|
4296
|
+
}
|
|
4297
|
+
const separatorIndex = action.indexOf(':');
|
|
4298
|
+
const selectedTargetPath = (separatorIndex >= 0) ? action.slice(separatorIndex + 1) : '';
|
|
4299
|
+
if (selectedTargetPath === '' || ignoreFiles[selectedTargetPath] === undefined) {
|
|
4300
|
+
continue;
|
|
4301
|
+
}
|
|
4302
|
+
if (action.startsWith('bundles:') === true) {
|
|
4303
|
+
await Runner.promptIgnoreFileBundles(config, selectedTargetPath);
|
|
4304
|
+
continue;
|
|
4305
|
+
}
|
|
4306
|
+
if (action.startsWith('patterns:') === true) {
|
|
4307
|
+
await Runner.promptGitignore(config, selectedTargetPath);
|
|
4308
|
+
continue;
|
|
4309
|
+
}
|
|
4310
|
+
if (action.startsWith('remove:') === true) {
|
|
4311
|
+
const removeOutput = await Runner.promptWithCancel({
|
|
4312
|
+
type: 'confirm',
|
|
4313
|
+
name: 'confirm',
|
|
4314
|
+
message: `Remove ignore file "${selectedTargetPath}"?`,
|
|
4315
|
+
initial: false,
|
|
4316
|
+
});
|
|
4317
|
+
if (removeOutput['cancelled'] === false && removeOutput['result'].confirm === true) {
|
|
4318
|
+
Reflect.deleteProperty(ignoreFiles, selectedTargetPath);
|
|
4319
|
+
}
|
|
4320
|
+
}
|
|
4321
|
+
}
|
|
4322
|
+
}
|
|
2719
4323
|
static async promptAgents(config) {
|
|
2720
4324
|
const existing = (Array.isArray(config['agents']) === true) ? config['agents'] : [];
|
|
2721
4325
|
const choices = libItemAllowedAgents.map((allowedAgent) => ({
|
|
@@ -2728,7 +4332,6 @@ export class Runner {
|
|
|
2728
4332
|
name: 'agents',
|
|
2729
4333
|
message: 'AI tools to generate conventions for',
|
|
2730
4334
|
choices,
|
|
2731
|
-
min: 1,
|
|
2732
4335
|
});
|
|
2733
4336
|
if (agentsOutput['cancelled'] === true) {
|
|
2734
4337
|
return 'back';
|
|
@@ -2771,12 +4374,11 @@ export class Runner {
|
|
|
2771
4374
|
const environment = (config['environment'] !== undefined) ? config['environment'] : {};
|
|
2772
4375
|
const projectScope = environment['project'];
|
|
2773
4376
|
const workspacesGroup = (environment['workspaces'] !== undefined) ? environment['workspaces'] : {};
|
|
4377
|
+
const workflowsGroup = (environment['workflows'] !== undefined) ? environment['workflows'] : {};
|
|
2774
4378
|
const workspaces = (config['workspaces'] !== undefined) ? config['workspaces'] : {};
|
|
2775
4379
|
const appPaths = [];
|
|
2776
4380
|
for (const workspaceEntry of Object.entries(workspaces)) {
|
|
2777
|
-
if ((workspaceEntry[
|
|
2778
|
-
|| workspaceEntry[0] === './')
|
|
2779
|
-
&& appPaths.includes(workspaceEntry[0]) === false) {
|
|
4381
|
+
if (appPaths.includes(workspaceEntry[0]) === false) {
|
|
2780
4382
|
appPaths.push(workspaceEntry[0]);
|
|
2781
4383
|
}
|
|
2782
4384
|
}
|
|
@@ -2810,6 +4412,30 @@ export class Runner {
|
|
|
2810
4412
|
},
|
|
2811
4413
|
});
|
|
2812
4414
|
}
|
|
4415
|
+
const workflowNames = [];
|
|
4416
|
+
for (const workflow of config['workflows'] ?? []) {
|
|
4417
|
+
if (workflowNames.includes(workflow['name']) === false) {
|
|
4418
|
+
workflowNames.push(workflow['name']);
|
|
4419
|
+
}
|
|
4420
|
+
}
|
|
4421
|
+
for (const workflowName of Object.keys(workflowsGroup)) {
|
|
4422
|
+
if (workflowNames.includes(workflowName) === false) {
|
|
4423
|
+
workflowNames.push(workflowName);
|
|
4424
|
+
}
|
|
4425
|
+
}
|
|
4426
|
+
for (const workflowName of workflowNames) {
|
|
4427
|
+
const workflowScope = workflowsGroup[workflowName];
|
|
4428
|
+
const workflowSummary = (workflowScope !== undefined) ? workflowScope['prefix'] : 'Not configured yet.';
|
|
4429
|
+
choices.push({
|
|
4430
|
+
title: `Workflow: ${workflowName}`,
|
|
4431
|
+
description: workflowSummary,
|
|
4432
|
+
value: {
|
|
4433
|
+
kind: 'scope',
|
|
4434
|
+
scope: 'workflow',
|
|
4435
|
+
workflowName,
|
|
4436
|
+
},
|
|
4437
|
+
});
|
|
4438
|
+
}
|
|
2813
4439
|
choices.push({
|
|
2814
4440
|
title: 'View GitHub status',
|
|
2815
4441
|
description: 'Read-only classification of every managed key on GitHub.',
|
|
@@ -2854,6 +4480,13 @@ export class Runner {
|
|
|
2854
4480
|
continue;
|
|
2855
4481
|
}
|
|
2856
4482
|
if (menuOutputResultValue.action['kind'] === 'scope') {
|
|
4483
|
+
if (menuOutputResultValue.action['scope'] === 'workflow') {
|
|
4484
|
+
const workflowName = menuOutputResultValue.action['workflowName'] ?? '';
|
|
4485
|
+
if (workflowName !== '') {
|
|
4486
|
+
await Runner.promptEnvironmentWorkflow(config, workflowName);
|
|
4487
|
+
}
|
|
4488
|
+
continue;
|
|
4489
|
+
}
|
|
2857
4490
|
await Runner.promptEnvironmentScope(config, {
|
|
2858
4491
|
scope: menuOutputResultValue.action['scope'],
|
|
2859
4492
|
appPath: menuOutputResultValue.action['appPath'],
|
|
@@ -2861,6 +4494,43 @@ export class Runner {
|
|
|
2861
4494
|
}
|
|
2862
4495
|
}
|
|
2863
4496
|
}
|
|
4497
|
+
static async promptEnvironmentWorkflow(config, workflowName) {
|
|
4498
|
+
const environment = config['environment'] ?? {};
|
|
4499
|
+
const workflows = environment['workflows'] ?? {};
|
|
4500
|
+
const existing = workflows[workflowName];
|
|
4501
|
+
const prefixOutput = await Runner.promptWithCancel({
|
|
4502
|
+
type: 'text',
|
|
4503
|
+
name: 'prefix',
|
|
4504
|
+
message: `Prefix for workflow "${workflowName}" (blank removes it)`,
|
|
4505
|
+
initial: (existing !== undefined) ? existing['prefix'] : '',
|
|
4506
|
+
});
|
|
4507
|
+
if (prefixOutput['cancelled'] === true) {
|
|
4508
|
+
return 'back';
|
|
4509
|
+
}
|
|
4510
|
+
const prefix = prefixOutput['result'].prefix.trim();
|
|
4511
|
+
if (prefix === '') {
|
|
4512
|
+
Reflect.deleteProperty(workflows, workflowName);
|
|
4513
|
+
}
|
|
4514
|
+
else {
|
|
4515
|
+
Reflect.set(workflows, workflowName, { prefix });
|
|
4516
|
+
}
|
|
4517
|
+
const nextEnvironment = {
|
|
4518
|
+
...environment,
|
|
4519
|
+
};
|
|
4520
|
+
if (Object.keys(workflows).length > 0) {
|
|
4521
|
+
nextEnvironment.workflows = workflows;
|
|
4522
|
+
}
|
|
4523
|
+
else {
|
|
4524
|
+
Reflect.deleteProperty(nextEnvironment, 'workflows');
|
|
4525
|
+
}
|
|
4526
|
+
if (Object.keys(nextEnvironment).length > 0) {
|
|
4527
|
+
Object.assign(config, { environment: nextEnvironment });
|
|
4528
|
+
}
|
|
4529
|
+
else {
|
|
4530
|
+
Reflect.deleteProperty(config, 'environment');
|
|
4531
|
+
}
|
|
4532
|
+
return 'back';
|
|
4533
|
+
}
|
|
2864
4534
|
static async readLocalFilledKeys(config) {
|
|
2865
4535
|
const environment = config['environment'] ?? {};
|
|
2866
4536
|
const workspaces = environment['workspaces'] ?? {};
|
|
@@ -3339,54 +5009,132 @@ export class Runner {
|
|
|
3339
5009
|
}).error((error instanceof Error) ? error.message : 'Unable to validate the configured version strategy.');
|
|
3340
5010
|
return 'back';
|
|
3341
5011
|
}
|
|
5012
|
+
let strategyInput = currentStrategy;
|
|
3342
5013
|
if (lockedStrategy !== undefined) {
|
|
3343
5014
|
Logger.customize({
|
|
3344
5015
|
name: 'Runner.promptSettings',
|
|
3345
5016
|
purpose: 'locked',
|
|
3346
5017
|
}).info(`Version strategy cannot be changed — this repo has existing "${lockedStrategy}" release history.`);
|
|
5018
|
+
}
|
|
5019
|
+
else {
|
|
5020
|
+
const strategyChoices = [
|
|
5021
|
+
{
|
|
5022
|
+
title: 'SemVer',
|
|
5023
|
+
description: 'Semantic versioning (major.minor.patch).',
|
|
5024
|
+
value: 'semver',
|
|
5025
|
+
},
|
|
5026
|
+
{
|
|
5027
|
+
title: 'CalVer',
|
|
5028
|
+
description: 'Calendar versioning (YYYY.MM.MICRO).',
|
|
5029
|
+
value: 'calver',
|
|
5030
|
+
},
|
|
5031
|
+
];
|
|
5032
|
+
const strategyInitial = strategyChoices.findIndex((choice) => choice['value'] === currentStrategy);
|
|
5033
|
+
const strategyOutput = await Runner.promptWithCancel({
|
|
5034
|
+
type: 'select',
|
|
5035
|
+
name: 'versionStrategy',
|
|
5036
|
+
message: 'Select version strategy.',
|
|
5037
|
+
choices: strategyChoices,
|
|
5038
|
+
initial: (strategyInitial !== -1) ? strategyInitial : 0,
|
|
5039
|
+
});
|
|
5040
|
+
if (strategyOutput['cancelled'] === true) {
|
|
5041
|
+
return 'back';
|
|
5042
|
+
}
|
|
5043
|
+
const strategyOutputResult = strategyOutput['result'];
|
|
5044
|
+
strategyInput = strategyOutputResult.versionStrategy;
|
|
5045
|
+
}
|
|
5046
|
+
const lockStepVersioningInitial = settings['lockStepVersioning'] ?? false;
|
|
5047
|
+
const lockStepVersioningOutput = await Runner.promptWithCancel({
|
|
5048
|
+
type: 'confirm',
|
|
5049
|
+
name: 'lockStepVersioning',
|
|
5050
|
+
message: 'Keep every non-freezable workspace on one shared version?',
|
|
5051
|
+
initial: lockStepVersioningInitial,
|
|
5052
|
+
});
|
|
5053
|
+
if (lockStepVersioningOutput['cancelled'] === true) {
|
|
3347
5054
|
return 'back';
|
|
3348
5055
|
}
|
|
3349
|
-
const
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
5056
|
+
const lockStepVersioningOutputResult = lockStepVersioningOutput['result'];
|
|
5057
|
+
const runWorkspacesSettings = settings['runWorkspaces'];
|
|
5058
|
+
const existingCache = (runWorkspacesSettings === undefined || runWorkspacesSettings['cache'] === undefined) ? {} : runWorkspacesSettings['cache'];
|
|
5059
|
+
const cacheEnabledInitial = existingCache['enabled'] ?? true;
|
|
5060
|
+
const cacheEnabledOutput = await Runner.promptWithCancel({
|
|
5061
|
+
type: 'confirm',
|
|
5062
|
+
name: 'cacheEnabled',
|
|
5063
|
+
message: 'Use verified local caching for workspace tasks?',
|
|
5064
|
+
initial: cacheEnabledInitial,
|
|
5065
|
+
});
|
|
5066
|
+
if (cacheEnabledOutput['cancelled'] === true) {
|
|
5067
|
+
return 'back';
|
|
5068
|
+
}
|
|
5069
|
+
const cacheEnabledOutputResult = cacheEnabledOutput['result'];
|
|
5070
|
+
const cacheDirectoryInitial = existingCache['directory'] ?? './node_modules/.cache/nova/run-workspaces';
|
|
5071
|
+
const cacheDirectoryOutput = await Runner.promptWithCancel({
|
|
5072
|
+
type: 'text',
|
|
5073
|
+
name: 'cacheDirectory',
|
|
5074
|
+
message: 'Project-relative workspace cache directory:',
|
|
5075
|
+
initial: cacheDirectoryInitial,
|
|
5076
|
+
validate: (value) => {
|
|
5077
|
+
if (typeof value === 'string' && value.trim().length > 0) {
|
|
5078
|
+
return true;
|
|
5079
|
+
}
|
|
5080
|
+
return 'Enter a project-relative cache directory.';
|
|
3359
5081
|
},
|
|
3360
|
-
];
|
|
3361
|
-
const strategyInitial = strategyChoices.findIndex((choice) => choice['value'] === currentStrategy);
|
|
3362
|
-
const strategyOutput = await Runner.promptWithCancel({
|
|
3363
|
-
type: 'select',
|
|
3364
|
-
name: 'versionStrategy',
|
|
3365
|
-
message: 'Select version strategy.',
|
|
3366
|
-
choices: strategyChoices,
|
|
3367
|
-
initial: (strategyInitial !== -1) ? strategyInitial : 0,
|
|
3368
5082
|
});
|
|
3369
|
-
if (
|
|
5083
|
+
if (cacheDirectoryOutput['cancelled'] === true) {
|
|
3370
5084
|
return 'back';
|
|
3371
5085
|
}
|
|
3372
|
-
const
|
|
3373
|
-
const
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
5086
|
+
const cacheDirectoryOutputResult = cacheDirectoryOutput['result'];
|
|
5087
|
+
const cacheDirectory = cacheDirectoryOutputResult.cacheDirectory.trim();
|
|
5088
|
+
const cacheScriptsInitial = (existingCache['scripts'] ?? [
|
|
5089
|
+
'build',
|
|
5090
|
+
'check',
|
|
5091
|
+
]).join(', ');
|
|
5092
|
+
const cacheScriptsOutput = await Runner.promptWithCancel({
|
|
5093
|
+
type: 'text',
|
|
5094
|
+
name: 'cacheScripts',
|
|
5095
|
+
message: 'Cacheable workspace scripts (comma-separated):',
|
|
5096
|
+
initial: cacheScriptsInitial,
|
|
5097
|
+
validate: (value) => {
|
|
5098
|
+
if (typeof value === 'string'
|
|
5099
|
+
&& value.split(',').some((script) => script.trim().length > 0) === true) {
|
|
5100
|
+
return true;
|
|
5101
|
+
}
|
|
5102
|
+
return 'Enter at least one script name.';
|
|
5103
|
+
},
|
|
5104
|
+
});
|
|
5105
|
+
if (cacheScriptsOutput['cancelled'] === true) {
|
|
5106
|
+
return 'back';
|
|
3382
5107
|
}
|
|
5108
|
+
const cacheScriptsOutputResult = cacheScriptsOutput['result'];
|
|
5109
|
+
const cacheScripts = [...new Set(cacheScriptsOutputResult.cacheScripts.split(',').map((script) => script.trim()).filter((script) => script.length > 0))].sort();
|
|
5110
|
+
const runWorkspaces = {
|
|
5111
|
+
...settings['runWorkspaces'],
|
|
5112
|
+
cache: {
|
|
5113
|
+
...existingCache,
|
|
5114
|
+
directory: cacheDirectory,
|
|
5115
|
+
enabled: cacheEnabledOutputResult.cacheEnabled,
|
|
5116
|
+
scripts: cacheScripts,
|
|
5117
|
+
},
|
|
5118
|
+
};
|
|
5119
|
+
const updatedSettings = {
|
|
5120
|
+
...settings,
|
|
5121
|
+
lockStepVersioning: lockStepVersioningOutputResult.lockStepVersioning,
|
|
5122
|
+
runWorkspaces,
|
|
5123
|
+
versionStrategy: strategyInput,
|
|
5124
|
+
};
|
|
5125
|
+
Object.assign(config, {
|
|
5126
|
+
settings: updatedSettings,
|
|
5127
|
+
});
|
|
3383
5128
|
return 'back';
|
|
3384
5129
|
}
|
|
3385
5130
|
static async promptWorkspaces(config) {
|
|
3386
5131
|
const workspaces = (config['workspaces'] !== undefined) ? { ...(config['workspaces']) } : {};
|
|
3387
5132
|
const recipes = (config['recipes'] !== undefined) ? { ...(config['recipes']) } : {};
|
|
3388
5133
|
const packageJsonRecipes = (recipes['package-json'] !== undefined) ? { ...(recipes['package-json']) } : {};
|
|
3389
|
-
const
|
|
5134
|
+
const scaffoldTemplateRoot = resolveTemplatePath(import.meta.url, 'scaffold');
|
|
5135
|
+
const rawWorkspacePaths = await discoverPathsWithFile('package.json', 'forward', {
|
|
5136
|
+
excludeRoots: [scaffoldTemplateRoot],
|
|
5137
|
+
});
|
|
3390
5138
|
const workspacePaths = rawWorkspacePaths.map((rawWorkspacePath) => {
|
|
3391
5139
|
const currentWorkingDirectory = process.cwd();
|
|
3392
5140
|
const relativePath = relative(currentWorkingDirectory, rawWorkspacePath);
|