skuba 0.0.0-master-20231002013336 → 0.0.0-master-20240206001217

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.
Files changed (221) hide show
  1. package/README.md +3 -3
  2. package/jest/transform.test.ts +3 -1
  3. package/lib/api/jest/index.d.ts +3 -3
  4. package/lib/api/jest/index.js +19 -1
  5. package/lib/api/jest/index.js.map +2 -2
  6. package/lib/api/net/compose.js +2 -1
  7. package/lib/api/net/compose.js.map +2 -2
  8. package/lib/cli/adapter/prettier.d.ts +1 -1
  9. package/lib/cli/adapter/prettier.js +11 -10
  10. package/lib/cli/adapter/prettier.js.map +2 -2
  11. package/lib/cli/build/index.js +0 -2
  12. package/lib/cli/build/index.js.map +2 -2
  13. package/lib/cli/buildPackage.js +0 -2
  14. package/lib/cli/buildPackage.js.map +2 -2
  15. package/lib/cli/configure/analyseConfiguration.d.ts +2 -0
  16. package/lib/cli/configure/analyseConfiguration.js.map +2 -2
  17. package/lib/cli/configure/getEntryPoint.js +1 -1
  18. package/lib/cli/configure/getEntryPoint.js.map +2 -2
  19. package/lib/cli/configure/getProjectType.d.ts +1 -1
  20. package/lib/cli/configure/getProjectType.js +6 -3
  21. package/lib/cli/configure/getProjectType.js.map +2 -2
  22. package/lib/cli/configure/index.js +11 -12
  23. package/lib/cli/configure/index.js.map +2 -2
  24. package/lib/cli/configure/modules/index.js +0 -2
  25. package/lib/cli/configure/modules/index.js.map +2 -2
  26. package/lib/cli/configure/modules/package.d.ts +1 -1
  27. package/lib/cli/configure/modules/package.js +2 -1
  28. package/lib/cli/configure/modules/package.js.map +2 -2
  29. package/lib/cli/configure/patchRenovateConfig.d.ts +2 -1
  30. package/lib/cli/configure/patchRenovateConfig.js +36 -21
  31. package/lib/cli/configure/patchRenovateConfig.js.map +2 -2
  32. package/lib/cli/configure/types.d.ts +2 -0
  33. package/lib/cli/configure/types.js.map +1 -1
  34. package/lib/cli/configure/upgrade/index.d.ts +15 -0
  35. package/lib/cli/configure/upgrade/index.js +130 -0
  36. package/lib/cli/configure/upgrade/index.js.map +7 -0
  37. package/lib/cli/configure/{addEmptyExports.d.ts → upgrade/patches/7.3.1/addEmptyExports.d.ts} +2 -2
  38. package/lib/cli/configure/{addEmptyExports.js → upgrade/patches/7.3.1/addEmptyExports.js} +15 -11
  39. package/lib/cli/configure/upgrade/patches/7.3.1/addEmptyExports.js.map +7 -0
  40. package/lib/cli/configure/upgrade/patches/7.3.1/index.d.ts +2 -0
  41. package/lib/cli/configure/upgrade/patches/7.3.1/index.js +55 -0
  42. package/lib/cli/configure/upgrade/patches/7.3.1/index.js.map +7 -0
  43. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.d.ts +2 -0
  44. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js +94 -0
  45. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js.map +7 -0
  46. package/lib/cli/configure/upgrade/patches/7.3.1/patchDockerfile.d.ts +2 -0
  47. package/lib/cli/configure/{patchDockerfile.js → upgrade/patches/7.3.1/patchDockerfile.js} +18 -12
  48. package/lib/cli/configure/upgrade/patches/7.3.1/patchDockerfile.js.map +7 -0
  49. package/lib/cli/configure/upgrade/patches/7.3.1/patchServerListener.d.ts +2 -0
  50. package/lib/cli/configure/{patchServerListener.js → upgrade/patches/7.3.1/patchServerListener.js} +18 -14
  51. package/lib/cli/configure/upgrade/patches/7.3.1/patchServerListener.js.map +7 -0
  52. package/lib/cli/format.js +7 -14
  53. package/lib/cli/format.js.map +2 -2
  54. package/lib/cli/init/getConfig.d.ts +7 -5
  55. package/lib/cli/init/getConfig.js +61 -34
  56. package/lib/cli/init/getConfig.js.map +2 -2
  57. package/lib/cli/init/git.d.ts +2 -1
  58. package/lib/cli/init/git.js +2 -9
  59. package/lib/cli/init/git.js.map +2 -2
  60. package/lib/cli/init/index.d.ts +1 -1
  61. package/lib/cli/init/index.js +19 -10
  62. package/lib/cli/init/index.js.map +2 -2
  63. package/lib/cli/init/prompts.d.ts +26 -3
  64. package/lib/cli/init/prompts.js +10 -2
  65. package/lib/cli/init/prompts.js.map +2 -2
  66. package/lib/cli/init/types.d.ts +120 -27
  67. package/lib/cli/init/types.js +30 -35
  68. package/lib/cli/init/types.js.map +2 -2
  69. package/lib/cli/init/writePackageJson.d.ts +6 -0
  70. package/lib/cli/init/writePackageJson.js.map +2 -2
  71. package/lib/cli/lint/annotate/buildkite/index.d.ts +2 -1
  72. package/lib/cli/lint/annotate/buildkite/index.js +5 -3
  73. package/lib/cli/lint/annotate/buildkite/index.js.map +2 -2
  74. package/lib/cli/lint/annotate/buildkite/internal.d.ts +2 -0
  75. package/lib/cli/lint/annotate/buildkite/internal.js +45 -0
  76. package/lib/cli/lint/annotate/buildkite/internal.js.map +7 -0
  77. package/lib/cli/lint/annotate/github/index.d.ts +2 -1
  78. package/lib/cli/lint/annotate/github/index.js +4 -2
  79. package/lib/cli/lint/annotate/github/index.js.map +2 -2
  80. package/lib/cli/lint/annotate/github/internal.d.ts +3 -0
  81. package/lib/cli/lint/annotate/github/internal.js +36 -0
  82. package/lib/cli/lint/annotate/github/internal.js.map +7 -0
  83. package/lib/cli/lint/annotate/index.d.ts +4 -3
  84. package/lib/cli/lint/annotate/index.js +9 -3
  85. package/lib/cli/lint/annotate/index.js.map +2 -2
  86. package/lib/cli/lint/autofix.d.ts +3 -1
  87. package/lib/cli/lint/autofix.js +36 -59
  88. package/lib/cli/lint/autofix.js.map +3 -3
  89. package/lib/cli/lint/external.d.ts +6 -1
  90. package/lib/cli/lint/external.js +6 -29
  91. package/lib/cli/lint/external.js.map +2 -2
  92. package/lib/cli/lint/index.d.ts +2 -1
  93. package/lib/cli/lint/index.js +46 -14
  94. package/lib/cli/lint/index.js.map +2 -2
  95. package/lib/cli/lint/internal.d.ts +12 -1
  96. package/lib/cli/lint/internal.js +55 -19
  97. package/lib/cli/lint/internal.js.map +3 -3
  98. package/lib/cli/lint/internalLints/deleteFiles.d.ts +3 -0
  99. package/lib/cli/lint/internalLints/deleteFiles.js +102 -0
  100. package/lib/cli/lint/internalLints/deleteFiles.js.map +7 -0
  101. package/lib/cli/lint/internalLints/noSkubaTemplateJs.d.ts +3 -0
  102. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +75 -0
  103. package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +7 -0
  104. package/lib/cli/lint/internalLints/refreshConfigFiles.d.ts +11 -0
  105. package/lib/cli/lint/internalLints/refreshConfigFiles.js +147 -0
  106. package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +7 -0
  107. package/lib/cli/test/index.js +0 -2
  108. package/lib/cli/test/index.js.map +2 -2
  109. package/lib/skuba.d.ts +1 -1
  110. package/lib/skuba.js.map +1 -1
  111. package/lib/utils/error.d.ts +30 -10
  112. package/lib/utils/error.js +10 -20
  113. package/lib/utils/error.js.map +2 -2
  114. package/lib/utils/exec.d.ts +2 -1
  115. package/lib/utils/exec.js +3 -2
  116. package/lib/utils/exec.js.map +2 -2
  117. package/lib/utils/logging.d.ts +2 -0
  118. package/lib/utils/logging.js +1 -0
  119. package/lib/utils/logging.js.map +2 -2
  120. package/lib/utils/logo.js +6 -10
  121. package/lib/utils/logo.js.map +3 -3
  122. package/lib/utils/manifest.d.ts +4 -4
  123. package/lib/utils/manifest.js +10 -10
  124. package/lib/utils/manifest.js.map +2 -2
  125. package/lib/utils/npmrc.d.ts +1 -0
  126. package/lib/utils/npmrc.js +29 -0
  127. package/lib/utils/npmrc.js.map +7 -0
  128. package/lib/utils/packageManager.d.ts +24 -0
  129. package/lib/utils/packageManager.js +97 -0
  130. package/lib/utils/packageManager.js.map +7 -0
  131. package/lib/utils/template.d.ts +46 -13
  132. package/lib/utils/template.js +17 -15
  133. package/lib/utils/template.js.map +2 -2
  134. package/lib/utils/worker.d.ts +1 -0
  135. package/lib/wrapper/http.d.ts +1 -0
  136. package/package.json +50 -47
  137. package/template/base/_.dockerignore +0 -1
  138. package/template/base/_.eslintignore +1 -0
  139. package/template/base/_.gitignore +1 -1
  140. package/template/base/_.npmrc +8 -0
  141. package/template/express-rest-api/.buildkite/pipeline.yml +16 -12
  142. package/template/express-rest-api/.gantry/dev.yml +3 -0
  143. package/template/express-rest-api/.nvmrc +1 -1
  144. package/template/express-rest-api/Dockerfile +6 -12
  145. package/template/express-rest-api/Dockerfile.dev-deps +8 -7
  146. package/template/express-rest-api/README.md +12 -12
  147. package/template/express-rest-api/docker-compose.yml +0 -10
  148. package/template/express-rest-api/gantry.apply.yml +5 -0
  149. package/template/express-rest-api/gantry.build.yml +1 -2
  150. package/template/express-rest-api/package.json +4 -4
  151. package/template/express-rest-api/skuba.template.js +1 -0
  152. package/template/greeter/.buildkite/pipeline.yml +15 -11
  153. package/template/greeter/.nvmrc +1 -1
  154. package/template/greeter/Dockerfile +8 -7
  155. package/template/greeter/README.md +9 -9
  156. package/template/greeter/docker-compose.yml +0 -10
  157. package/template/greeter/package.json +3 -3
  158. package/template/greeter/skuba.template.js +1 -0
  159. package/template/koa-rest-api/.buildkite/pipeline.yml +16 -12
  160. package/template/koa-rest-api/.gantry/dev.yml +3 -0
  161. package/template/koa-rest-api/.nvmrc +1 -1
  162. package/template/koa-rest-api/Dockerfile +6 -12
  163. package/template/koa-rest-api/Dockerfile.dev-deps +8 -7
  164. package/template/koa-rest-api/README.md +12 -12
  165. package/template/koa-rest-api/docker-compose.yml +0 -10
  166. package/template/koa-rest-api/gantry.apply.yml +5 -0
  167. package/template/koa-rest-api/gantry.build.yml +1 -2
  168. package/template/koa-rest-api/package.json +10 -8
  169. package/template/koa-rest-api/skuba.template.js +1 -0
  170. package/template/koa-rest-api/src/app.test.ts +8 -4
  171. package/template/koa-rest-api/src/framework/validation.test.ts +48 -15
  172. package/template/koa-rest-api/src/framework/validation.ts +31 -8
  173. package/template/koa-rest-api/src/testing/types.ts +16 -4
  174. package/template/lambda-sqs-worker/.buildkite/pipeline.yml +25 -18
  175. package/template/lambda-sqs-worker/.nvmrc +1 -1
  176. package/template/lambda-sqs-worker/Dockerfile +8 -8
  177. package/template/lambda-sqs-worker/README.md +14 -14
  178. package/template/lambda-sqs-worker/_.npmrc +12 -0
  179. package/template/lambda-sqs-worker/docker-compose.yml +0 -15
  180. package/template/lambda-sqs-worker/package.json +6 -7
  181. package/template/lambda-sqs-worker/serverless.yml +5 -2
  182. package/template/lambda-sqs-worker/skuba.template.js +1 -0
  183. package/template/lambda-sqs-worker/src/framework/validation.test.ts +1 -1
  184. package/template/lambda-sqs-worker/src/hooks.ts +1 -2
  185. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +46 -21
  186. package/template/lambda-sqs-worker-cdk/.nvmrc +1 -1
  187. package/template/lambda-sqs-worker-cdk/Dockerfile +11 -9
  188. package/template/lambda-sqs-worker-cdk/cdk.json +12 -6
  189. package/template/lambda-sqs-worker-cdk/docker-compose.yml +0 -15
  190. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +1590 -228
  191. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +23 -3
  192. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +128 -15
  193. package/template/lambda-sqs-worker-cdk/package.json +9 -7
  194. package/template/lambda-sqs-worker-cdk/shared/context-types.ts +1 -0
  195. package/template/lambda-sqs-worker-cdk/skuba.template.js +1 -0
  196. package/template/lambda-sqs-worker-cdk/src/app.ts +14 -1
  197. package/template/lambda-sqs-worker-cdk/src/postHook.ts +154 -0
  198. package/template/lambda-sqs-worker-cdk/src/preHook.ts +95 -0
  199. package/template/oss-npm-package/.github/workflows/release.yml +10 -7
  200. package/template/oss-npm-package/.github/workflows/validate.yml +10 -7
  201. package/template/oss-npm-package/.nvmrc +1 -1
  202. package/template/oss-npm-package/.releaserc +16 -0
  203. package/template/oss-npm-package/README.md +18 -18
  204. package/template/oss-npm-package/_package.json +3 -2
  205. package/template/oss-npm-package/skuba.template.js +1 -0
  206. package/template/private-npm-package/.nvmrc +1 -1
  207. package/template/private-npm-package/.releaserc +16 -0
  208. package/template/private-npm-package/README.md +18 -18
  209. package/template/private-npm-package/_package.json +3 -3
  210. package/template/private-npm-package/skuba.template.js +1 -0
  211. package/lib/cli/configure/addEmptyExports.js.map +0 -7
  212. package/lib/cli/configure/modules/tsconfig.d.ts +0 -2
  213. package/lib/cli/configure/modules/tsconfig.js +0 -87
  214. package/lib/cli/configure/modules/tsconfig.js.map +0 -7
  215. package/lib/cli/configure/patchDockerfile.d.ts +0 -1
  216. package/lib/cli/configure/patchDockerfile.js.map +0 -7
  217. package/lib/cli/configure/patchServerListener.d.ts +0 -3
  218. package/lib/cli/configure/patchServerListener.js.map +0 -7
  219. package/lib/cli/configure/refreshIgnoreFiles.d.ts +0 -3
  220. package/lib/cli/configure/refreshIgnoreFiles.js +0 -78
  221. package/lib/cli/configure/refreshIgnoreFiles.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/init/getConfig.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\n\nimport { copyFiles } from '../../utils/copy';\nimport { isErrorWithCode } from '../../utils/error';\nimport { log } from '../../utils/logging';\nimport { getRandomPort } from '../../utils/port';\nimport {\n TEMPLATE_CONFIG_FILENAME,\n TEMPLATE_DIR,\n TemplateConfig,\n} from '../../utils/template';\n\nimport { downloadGitHubTemplate } from './git';\nimport {\n BASE_PROMPT_PROPS,\n type BaseFields,\n GIT_PATH_PROMPT,\n SHOULD_CONTINUE_PROMPT,\n TEMPLATE_PROMPT,\n} from './prompts';\nimport { type InitConfig, InitConfigInput } from './types';\n\nimport { Form, type FormChoice } from 'enquirer';\n\nexport const runForm = <T = Record<string, string>>(props: {\n choices: Readonly<FormChoice[]>;\n message: string;\n name: string;\n}) => {\n const { message, name } = props;\n\n const choices = props.choices.map((choice) => ({\n ...choice,\n validate: (value: string | undefined) => {\n if (!value || value === '' || value === choice.initial) {\n return 'Form is not complete';\n }\n\n return choice.validate?.(value) ?? true;\n },\n }));\n\n const form = new Form<T>({\n choices,\n message,\n name,\n validate: async (values) => {\n const results = await Promise.all(\n choices.map((choice) => choice.validate(values[choice.name])),\n );\n\n return (\n results.find((result) => typeof result === 'string') ??\n results.every((result) => result === true)\n );\n },\n });\n\n return form.run();\n};\n\nconst confirmShouldContinue = async (choices: Readonly<FormChoice[]>) => {\n const fieldsList = choices.map((choice) => choice.message);\n\n log.newline();\n log.plain('This template uses the following information:');\n log.newline();\n fieldsList.forEach((message) => log.subtle(`- ${message}`));\n\n log.newline();\n const result = await SHOULD_CONTINUE_PROMPT.run();\n\n return result === 'yes';\n};\n\nconst createDirectory = async (dir: string) => {\n try {\n await fs.promises.mkdir(dir);\n } catch (err) {\n if (isErrorWithCode(err, 'EEXIST')) {\n log.err(`The directory '${dir}' already exists.`);\n process.exit(1);\n }\n\n throw err;\n }\n};\n\nconst cloneTemplate = async (templateName: string, destinationDir: string) => {\n if (templateName.startsWith('github:')) {\n const gitHubPath = templateName.slice('github:'.length);\n return downloadGitHubTemplate(gitHubPath, destinationDir);\n }\n\n const templateDir = path.join(TEMPLATE_DIR, templateName);\n\n await copyFiles({\n // assume built-in templates have no extraneous files\n include: () => true,\n sourceRoot: templateDir,\n destinationRoot: destinationDir,\n processors: [],\n // built-in templates have files like _package.json\n stripUnderscorePrefix: true,\n });\n};\n\nconst getTemplateName = async () => {\n const templateSelection = await TEMPLATE_PROMPT.run();\n\n if (templateSelection === 'github \u2192') {\n const gitHubPath = await GIT_PATH_PROMPT.run();\n return `github:${gitHubPath}`;\n }\n\n return templateSelection;\n};\n\nconst generatePlaceholders = (choices: FormChoice[]) =>\n Object.fromEntries(\n choices.map(({ name }) => [name, `<%- ${name} %>`] as const),\n );\n\nexport const getTemplateConfig = (dir: string): TemplateConfig => {\n const templateConfigPath = path.join(dir, TEMPLATE_CONFIG_FILENAME);\n\n try {\n /* eslint-disable-next-line @typescript-eslint/no-var-requires */\n const templateConfig = require(templateConfigPath) as unknown;\n\n return TemplateConfig.check(templateConfig);\n } catch (err) {\n if (isErrorWithCode(err, 'MODULE_NOT_FOUND')) {\n return {\n entryPoint: undefined,\n fields: [],\n type: undefined,\n };\n }\n\n throw err;\n }\n};\n\nconst baseToTemplateData = async ({\n ownerName,\n platformName,\n repoName,\n}: BaseFields) => {\n const [orgName, teamName] = ownerName.split('/');\n\n const port = String(await getRandomPort());\n\n if (!orgName) {\n throw new Error(`Invalid format for owner name: ${ownerName}`);\n }\n\n return {\n orgName,\n ownerName,\n repoName,\n // Use standalone username in `teamName` contexts\n teamName: teamName ?? orgName,\n\n port,\n\n platformName,\n lambdaCdkArchitecture: platformName === 'amd64' ? 'X86_64' : 'ARM_64',\n lambdaServerlessArchitecture:\n platformName === 'amd64' ? 'x86_64' : platformName,\n };\n};\n\nexport const configureFromPrompt = async (): Promise<InitConfig> => {\n const { ownerName, platformName, repoName } =\n await runForm<BaseFields>(BASE_PROMPT_PROPS);\n log.plain(chalk.cyan(repoName), 'by', chalk.cyan(ownerName));\n\n const templateData = await baseToTemplateData({\n ownerName,\n platformName,\n repoName,\n });\n\n const destinationDir = repoName;\n\n await createDirectory(destinationDir);\n\n log.newline();\n const templateName = await getTemplateName();\n\n await cloneTemplate(templateName, destinationDir);\n\n const { entryPoint, fields, noSkip, type } = getTemplateConfig(\n path.join(process.cwd(), destinationDir),\n );\n\n if (fields.length === 0) {\n return {\n destinationDir,\n entryPoint,\n templateComplete: true,\n templateData,\n templateName,\n type,\n };\n }\n\n const shouldContinue = noSkip ? true : await confirmShouldContinue(fields);\n\n if (shouldContinue) {\n log.newline();\n const customAnswers = await runForm({\n choices: fields,\n message: chalk.bold(`Complete ${chalk.cyan(templateName)}:`),\n name: 'customAnswers',\n });\n\n return {\n destinationDir,\n entryPoint,\n templateComplete: true,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n }\n\n log.newline();\n log.warn(`Resume this later with ${chalk.bold('yarn skuba configure')}.`);\n\n const customAnswers = generatePlaceholders(fields);\n\n return {\n destinationDir,\n entryPoint,\n templateComplete: false,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n};\n\nconst configureFromPipe = async (): Promise<InitConfig> => {\n let text = '';\n\n await new Promise((resolve) =>\n process.stdin\n .on('data', (chunk) => (text += chunk.toString()))\n .once('end', resolve),\n );\n\n text = text.trim();\n\n if (text === '') {\n log.err('No data from stdin.');\n process.exit(1);\n }\n\n let value: unknown;\n\n try {\n value = JSON.parse(text) as unknown;\n } catch {\n log.err('Invalid JSON from stdin.');\n process.exit(1);\n }\n\n const result = InitConfigInput.validate(value);\n\n if (!result.success) {\n log.err('Invalid data from stdin:');\n log.err(result.message);\n process.exit(1);\n }\n\n const { destinationDir, templateComplete, templateName } = result.value;\n\n const templateData = {\n ...(await baseToTemplateData(result.value.templateData)),\n ...result.value.templateData,\n };\n\n await createDirectory(destinationDir);\n\n await cloneTemplate(templateName, destinationDir);\n\n const { entryPoint, fields, noSkip, type } = getTemplateConfig(\n path.join(process.cwd(), destinationDir),\n );\n\n if (!templateComplete) {\n if (noSkip) {\n log.err('Templating for', log.bold(templateName), 'cannot be skipped.');\n process.exit(1);\n }\n\n return {\n ...result.value,\n entryPoint,\n templateData: {\n ...templateData,\n ...generatePlaceholders(fields),\n },\n type,\n };\n }\n\n const required = fields.map(({ name }) => name);\n\n const provided = new Set(Object.keys(templateData));\n\n const missing = required.filter((name) => !provided.has(name));\n\n if (missing.length > 0) {\n log.err('This template uses the following information:');\n log.newline();\n missing.forEach((name) => log.err(`- ${name}`));\n process.exit(1);\n }\n\n return {\n ...result.value,\n entryPoint,\n templateData,\n type,\n };\n};\n\nexport const getConfig = () =>\n process.stdin.isTTY ? configureFromPrompt() : configureFromPipe();\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,m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Ae;AAAA,IACnB,GAAI,MAAM,mBAAmB,OAAO,MAAM,YAAY;AAAA,IACtD,GAAG,OAAO,MAAM;AAAA,EAClB;AAEA,QAAM,gBAAgB,cAAc;AAEpC,QAAM,cAAc,cAAc,cAAc;AAEhD,QAAM,EAAE,YAAY,QAAQ,QAAQ,KAAK,IAAI;AAAA,IAC3C,YAAAD,QAAK,KAAK,QAAQ,IAAI,GAAG,cAAc;AAAA,EACzC;AAEA,MAAI,CAAC,kBAAkB;AACrB,QAAI,QAAQ;AACV,yBAAI,IAAI,kBAAkB,mBAAI,KAAK,YAAY,GAAG,oBAAoB;AACtE,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,WAAO;AAAA,MACL,GAAG,OAAO;AAAA,MACV;AAAA,MACA,cAAc;AAAA,QACZ,GAAG;AAAA,QACH,GAAG,qBAAqB,MAAM;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,WAAW,OAAO,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI;AAE9C,QAAM,WAAW,IAAI,IAAI,OAAO,KAAK,YAAY,CAAC;AAElD,QAAM,UAAU,SAAS,OAAO,CAAC,SAAS,CAAC,SAAS,IAAI,IAAI,CAAC;AAE7D,MAAI,QAAQ,SAAS,GAAG;AACtB,uBAAI,IAAI,+CAA+C;AACvD,uBAAI,QAAQ;AACZ,YAAQ,QAAQ,CAAC,SAAS,mBAAI,IAAI,KAAK,IAAI,EAAE,CAAC;AAC9C,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,SAAO;AAAA,IACL,GAAG,OAAO;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,YAAY,MACvB,QAAQ,MAAM,QAAQ,oBAAoB,IAAI,kBAAkB;",
4
+ "sourcesContent": ["import path from 'path';\n\nimport chalk from 'chalk';\nimport { Form, type FormChoice } from 'enquirer';\nimport fs from 'fs-extra';\n\nimport { copyFiles } from '../../utils/copy';\nimport { isErrorWithCode } from '../../utils/error';\nimport { log } from '../../utils/logging';\nimport {\n DEFAULT_PACKAGE_MANAGER,\n configForPackageManager,\n} from '../../utils/packageManager';\nimport { getRandomPort } from '../../utils/port';\nimport {\n TEMPLATE_CONFIG_FILENAME,\n TEMPLATE_DIR,\n type TemplateConfig,\n templateConfigSchema,\n} from '../../utils/template';\n\nimport { downloadGitHubTemplate } from './git';\nimport {\n BASE_PROMPT_PROPS,\n type BaseFields,\n type Choice,\n GIT_PATH_PROMPT,\n SHOULD_CONTINUE_PROMPT,\n TEMPLATE_PROMPT,\n} from './prompts';\nimport { type InitConfig, initConfigInputSchema } from './types';\n\nexport const runForm = <T = Record<string, string>>(props: {\n choices: Readonly<Choice[]>;\n message: string;\n name: string;\n}) => {\n const { message, name } = props;\n\n const choices = props.choices.map((choice) => ({\n ...choice,\n validate: (value: string | undefined) => {\n if (\n !value ||\n value === '' ||\n (value === choice.initial && !choice.allowInitial)\n ) {\n return 'Form is not complete';\n }\n\n return choice.validate?.(value) ?? true;\n },\n }));\n\n const form = new Form<T>({\n choices,\n message,\n name,\n validate: async (values) => {\n const results = await Promise.all(\n choices.map((choice) => choice.validate(values[choice.name])),\n );\n\n return (\n results.find((result) => typeof result === 'string') ??\n results.every((result) => result === true)\n );\n },\n });\n\n return form.run();\n};\n\nconst confirmShouldContinue = async (choices: Readonly<FormChoice[]>) => {\n const fieldsList = choices.map((choice) => choice.message);\n\n log.newline();\n log.plain('This template uses the following information:');\n log.newline();\n fieldsList.forEach((message) => log.subtle(`- ${message}`));\n\n log.newline();\n const result = await SHOULD_CONTINUE_PROMPT.run();\n\n return result === 'yes';\n};\n\nconst createDirectory = async (dir: string) => {\n try {\n await fs.promises.mkdir(dir);\n } catch (err) {\n if (isErrorWithCode(err, 'EEXIST')) {\n log.err(`The directory '${dir}' already exists.`);\n process.exit(1);\n }\n\n throw err;\n }\n};\n\nconst cloneTemplate = async (\n templateName: string,\n destinationDir: string,\n): Promise<TemplateConfig> => {\n const isCustomTemplate = templateName.startsWith('github:');\n\n if (isCustomTemplate) {\n const gitHubPath = templateName.slice('github:'.length);\n\n await downloadGitHubTemplate(gitHubPath, destinationDir);\n } else {\n const templateDir = path.join(TEMPLATE_DIR, templateName);\n\n await copyFiles({\n // assume built-in templates have no extraneous files\n include: () => true,\n sourceRoot: templateDir,\n destinationRoot: destinationDir,\n processors: [],\n // built-in templates have files like _package.json\n stripUnderscorePrefix: true,\n });\n }\n\n const templateConfig = getTemplateConfig(\n path.join(process.cwd(), destinationDir),\n );\n\n if (isCustomTemplate) {\n log.newline();\n log.warn(\n 'You may need to run',\n log.bold(\n configForPackageManager(templateConfig.packageManager).exec,\n 'skuba',\n 'configure',\n ),\n 'once this is done.',\n );\n }\n\n return templateConfig;\n};\n\nconst getTemplateName = async () => {\n const templateSelection = await TEMPLATE_PROMPT.run();\n\n if (templateSelection === 'github \u2192') {\n const gitHubPath = await GIT_PATH_PROMPT.run();\n return `github:${gitHubPath}`;\n }\n\n return templateSelection;\n};\n\nconst generatePlaceholders = (choices: FormChoice[]) =>\n Object.fromEntries(\n choices.map(({ name }) => [name, `<%- ${name} %>`] as const),\n );\n\nexport const getTemplateConfig = (dir: string): TemplateConfig => {\n const templateConfigPath = path.join(dir, TEMPLATE_CONFIG_FILENAME);\n\n try {\n /* eslint-disable-next-line @typescript-eslint/no-var-requires */\n const templateConfig = require(templateConfigPath) as unknown;\n\n return templateConfigSchema.parse(templateConfig);\n } catch (err) {\n if (isErrorWithCode(err, 'MODULE_NOT_FOUND')) {\n return {\n entryPoint: undefined,\n fields: [],\n packageManager: DEFAULT_PACKAGE_MANAGER,\n type: undefined,\n };\n }\n\n throw err;\n }\n};\n\nconst baseToTemplateData = async ({\n ownerName,\n platformName,\n repoName,\n defaultBranch,\n}: BaseFields) => {\n const [orgName, teamName] = ownerName.split('/');\n\n const port = String(await getRandomPort());\n\n if (!orgName) {\n throw new Error(`Invalid format for owner name: ${ownerName}`);\n }\n\n return {\n orgName,\n ownerName,\n repoName,\n defaultBranch,\n // Use standalone username in `teamName` contexts\n teamName: teamName ?? orgName,\n\n port,\n\n platformName,\n lambdaCdkArchitecture: platformName === 'amd64' ? 'X86_64' : 'ARM_64',\n lambdaServerlessArchitecture:\n platformName === 'amd64' ? 'x86_64' : platformName,\n };\n};\n\nexport const configureFromPrompt = async (): Promise<InitConfig> => {\n const { ownerName, platformName, repoName, defaultBranch } =\n await runForm<BaseFields>(BASE_PROMPT_PROPS);\n log.plain(chalk.cyan(repoName), 'by', chalk.cyan(ownerName));\n\n const templateData = await baseToTemplateData({\n ownerName,\n platformName,\n repoName,\n defaultBranch,\n });\n\n const destinationDir = repoName;\n\n await createDirectory(destinationDir);\n\n log.newline();\n const templateName = await getTemplateName();\n\n const { entryPoint, fields, noSkip, packageManager, type } =\n await cloneTemplate(templateName, destinationDir);\n\n if (fields.length === 0) {\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: true,\n templateData,\n templateName,\n type,\n };\n }\n\n const shouldContinue = noSkip ? true : await confirmShouldContinue(fields);\n\n if (shouldContinue) {\n log.newline();\n const customAnswers = await runForm({\n choices: fields,\n message: chalk.bold(`Complete ${chalk.cyan(templateName)}:`),\n name: 'customAnswers',\n });\n\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: true,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n }\n\n log.newline();\n log.warn(\n `Resume this later with ${chalk.bold(\n configForPackageManager(packageManager).exec,\n 'skuba configure',\n )}.`,\n );\n\n const customAnswers = generatePlaceholders(fields);\n\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: false,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n};\n\nconst configureFromPipe = async (): Promise<InitConfig> => {\n let text = '';\n\n await new Promise((resolve) =>\n process.stdin\n .on('data', (chunk) => (text += chunk.toString()))\n .once('end', resolve),\n );\n\n text = text.trim();\n\n if (text === '') {\n log.err('No data from stdin.');\n process.exit(1);\n }\n\n let value: unknown;\n\n try {\n value = JSON.parse(text) as unknown;\n } catch {\n log.err('Invalid JSON from stdin.');\n process.exit(1);\n }\n\n const result = initConfigInputSchema.safeParse(value);\n\n if (!result.success) {\n log.err('Invalid data from stdin:');\n log.err(result.error);\n process.exit(1);\n }\n\n const { destinationDir, templateComplete, templateName } = result.data;\n\n const templateData = {\n ...(await baseToTemplateData(result.data.templateData)),\n ...result.data.templateData,\n };\n\n await createDirectory(destinationDir);\n\n const { entryPoint, fields, noSkip, packageManager, type } =\n await cloneTemplate(templateName, destinationDir);\n\n if (!templateComplete) {\n if (noSkip) {\n log.err('Templating for', log.bold(templateName), 'cannot be skipped.');\n process.exit(1);\n }\n\n return {\n ...result.data,\n entryPoint,\n packageManager,\n templateData: {\n ...templateData,\n ...generatePlaceholders(fields),\n },\n type,\n };\n }\n\n const required = fields.map(({ name }) => name);\n\n const provided = new Set(Object.keys(templateData));\n\n const missing = required.filter((name) => !provided.has(name));\n\n if (missing.length > 0) {\n log.err('This template uses the following information:');\n log.newline();\n missing.forEach((name) => log.err(`- ${name}`));\n process.exit(1);\n }\n\n return {\n ...result.data,\n entryPoint,\n packageManager,\n templateData,\n type,\n };\n};\n\nexport const getConfig = () =>\n process.stdin.isTTY ? configureFromPrompt() : configureFromPipe();\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,mBAAkB;AAClB,sBAAsC;AACtC,sBAAe;AAEf,kBAA0B;AAC1B,mBAAgC;AAChC,qBAAoB;AACpB,4BAGO;AACP,kBAA8B;AAC9B,sBAKO;AAEP,iBAAuC;AACvC,qBAOO;AACP,mBAAuD;AAEhD,MAAM,UAAU,CAA6B,UAI9C;AACJ,QAAM,EAAE,SAAS,KAAK,IAAI;AAE1B,QAAM,UAAU,MAAM,QAAQ,IAAI,CAAC,YAAY;AAAA,IAC7C,GAAG;AAAA,IACH,UAAU,CAAC,UA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ubProject {
2
2
  orgName: string;
3
3
  repoName: string;
4
+ defaultBranch: string;
4
5
  }
5
- export declare const initialiseRepo: (dir: string, { orgName, repoName }: GitHubProject) => Promise<void>;
6
+ export declare const initialiseRepo: (dir: string, { orgName, repoName, defaultBranch }: GitHubProject) => Promise<void>;
6
7
  export declare const downloadGitHubTemplate: (gitHubPath: string, destinationDir: string) => Promise<void>;
7
8
  export {};
@@ -38,10 +38,9 @@ var import_isomorphic_git = __toESM(require("isomorphic-git"));
38
38
  var import_simple_git = __toESM(require("simple-git"));
39
39
  var Git = __toESM(require("../../api/git"));
40
40
  var import_logging = require("../../utils/logging");
41
- const initialiseRepo = async (dir, { orgName, repoName }) => {
41
+ const initialiseRepo = async (dir, { orgName, repoName, defaultBranch }) => {
42
42
  await import_isomorphic_git.default.init({
43
- // TODO: support main as an alternative.
44
- defaultBranch: "master",
43
+ defaultBranch,
45
44
  dir,
46
45
  fs: import_fs_extra.default
47
46
  });
@@ -67,12 +66,6 @@ const downloadGitHubTemplate = async (gitHubPath, destinationDir) => {
67
66
  force: true,
68
67
  recursive: true
69
68
  });
70
- import_logging.log.newline();
71
- import_logging.log.warn(
72
- "You may need to run",
73
- import_logging.log.bold("yarn skuba configure"),
74
- "once this is done."
75
- );
76
69
  };
77
70
  // Annotate the CommonJS export names for ESM import in node:
78
71
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/init/git.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport git from 'isomorphic-git';\nimport simpleGit from 'simple-git';\n\nimport * as Git from '../../api/git';\nimport { log } from '../../utils/logging';\n\ninterface GitHubProject {\n orgName: string;\n repoName: string;\n}\n\nexport const initialiseRepo = async (\n dir: string,\n { orgName, repoName }: GitHubProject,\n) => {\n await git.init({\n // TODO: support main as an alternative.\n defaultBranch: 'master',\n dir,\n fs,\n });\n\n await Git.commit({\n dir,\n message: 'Initial commit',\n });\n\n await git.addRemote({\n dir,\n fs,\n remote: 'origin',\n url: `git@github.com:${orgName}/${repoName}.git`,\n });\n};\n\nexport const downloadGitHubTemplate = async (\n gitHubPath: string,\n destinationDir: string,\n) => {\n log.newline();\n log.plain('Downloading', log.bold(gitHubPath), 'from GitHub...');\n\n await simpleGit().clone(`git@github.com:${gitHubPath}.git`, destinationDir, [\n '--depth=1',\n '--quiet',\n ]);\n\n await fs.promises.rm(path.join(destinationDir, '.git'), {\n force: true,\n recursive: true,\n });\n\n log.newline();\n log.warn(\n 'You may need to run',\n log.bold('yarn skuba configure'),\n 'once this is done.',\n );\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,4BAAgB;AAChB,wBAAsB;AAEtB,UAAqB;AACrB,qBAAoB;AAOb,MAAM,iBAAiB,OAC5B,KACA,EAAE,SAAS,SAAS,MACjB;AACH,QAAM,sBAAAA,QAAI,KAAK;AAAA;AAAA,IAEb,eAAe;AAAA,IACf;AAAA,IACA,oBAAAC;AAAA,EACF,CAAC;AAED,QAAM,IAAI,OAAO;AAAA,IACf;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AAED,QAAM,sBAAAD,QAAI,UAAU;AAAA,IAClB;AAAA,IACA,oBAAAC;AAAA,IACA,QAAQ;AAAA,IACR,KAAK,kBAAkB,OAAO,IAAI,QAAQ;AAAA,EAC5C,CAAC;AACH;AAEO,MAAM,yBAAyB,OACpC,YACA,mBACG;AACH,qBAAI,QAAQ;AACZ,qBAAI,MAAM,eAAe,mBAAI,KAAK,UAAU,GAAG,gBAAgB;AAE/D,YAAM,kBAAAC,SAAU,EAAE,MAAM,kBAAkB,UAAU,QAAQ,gBAAgB;AAAA,IAC1E;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,gBAAAD,QAAG,SAAS,GAAG,YAAAE,QAAK,KAAK,gBAAgB,MAAM,GAAG;AAAA,IACtD,OAAO;AAAA,IACP,WAAW;AAAA,EACb,CAAC;AAED,qBAAI,QAAQ;AACZ,qBAAI;AAAA,IACF;AAAA,IACA,mBAAI,KAAK,sBAAsB;AAAA,IAC/B;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport git from 'isomorphic-git';\nimport simpleGit from 'simple-git';\n\nimport * as Git from '../../api/git';\nimport { log } from '../../utils/logging';\n\ninterface GitHubProject {\n orgName: string;\n repoName: string;\n defaultBranch: string;\n}\n\nexport const initialiseRepo = async (\n dir: string,\n { orgName, repoName, defaultBranch }: GitHubProject,\n) => {\n await git.init({\n defaultBranch,\n dir,\n fs,\n });\n\n await Git.commit({\n dir,\n message: 'Initial commit',\n });\n\n await git.addRemote({\n dir,\n fs,\n remote: 'origin',\n url: `git@github.com:${orgName}/${repoName}.git`,\n });\n};\n\nexport const downloadGitHubTemplate = async (\n gitHubPath: string,\n destinationDir: string,\n) => {\n log.newline();\n log.plain('Downloading', log.bold(gitHubPath), 'from GitHub...');\n\n await simpleGit().clone(`git@github.com:${gitHubPath}.git`, destinationDir, [\n '--depth=1',\n '--quiet',\n ]);\n\n await fs.promises.rm(path.join(destinationDir, '.git'), {\n force: true,\n recursive: true,\n });\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,4BAAgB;AAChB,wBAAsB;AAEtB,UAAqB;AACrB,qBAAoB;AAQb,MAAM,iBAAiB,OAC5B,KACA,EAAE,SAAS,UAAU,cAAc,MAChC;AACH,QAAM,sBAAAA,QAAI,KAAK;AAAA,IACb;AAAA,IACA;AAAA,IACA,oBAAAC;AAAA,EACF,CAAC;AAED,QAAM,IAAI,OAAO;AAAA,IACf;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AAED,QAAM,sBAAAD,QAAI,UAAU;AAAA,IAClB;AAAA,IACA,oBAAAC;AAAA,IACA,QAAQ;AAAA,IACR,KAAK,kBAAkB,OAAO,IAAI,QAAQ;AAAA,EAC5C,CAAC;AACH;AAEO,MAAM,yBAAyB,OACpC,YACA,mBACG;AACH,qBAAI,QAAQ;AACZ,qBAAI,MAAM,eAAe,mBAAI,KAAK,UAAU,GAAG,gBAAgB;AAE/D,YAAM,kBAAAC,SAAU,EAAE,MAAM,kBAAkB,UAAU,QAAQ,gBAAgB;AAAA,IAC1E;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,gBAAAD,QAAG,SAAS,GAAG,YAAAE,QAAK,KAAK,gBAAgB,MAAM,GAAG;AAAA,IACtD,OAAO;AAAA,IACP,WAAW;AAAA,EACb,CAAC;AACH;",
6
6
  "names": ["git", "fs", "simpleGit", "path"]
7
7
  }
@@ -1 +1 @@
1
- export declare const init: () => Promise<void>;
1
+ export declare const init: (args?: string[]) => Promise<void>;
@@ -32,28 +32,35 @@ __export(init_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(init_exports);
34
34
  var import_path = __toESM(require("path"));
35
+ var import_util = require("util");
35
36
  var import_git = require("../../api/git");
37
+ var import_args = require("../../utils/args");
36
38
  var import_copy = require("../../utils/copy");
37
39
  var import_dir = require("../../utils/dir");
38
40
  var import_exec = require("../../utils/exec");
39
41
  var import_logging = require("../../utils/logging");
40
42
  var import_logo = require("../../utils/logo");
41
43
  var import_template = require("../../utils/template");
44
+ var import_prettier = require("../adapter/prettier");
42
45
  var import_patchRenovateConfig = require("../configure/patchRenovateConfig");
43
46
  var import_getConfig = require("./getConfig");
44
47
  var import_git2 = require("./git");
45
48
  var import_writePackageJson = require("./writePackageJson");
46
- const init = async () => {
49
+ const init = async (args = process.argv.slice(2)) => {
50
+ const opts = {
51
+ debug: (0, import_args.hasDebugFlag)(args)
52
+ };
47
53
  const skubaVersionInfo = await (0, import_logo.showLogoAndVersionInfo)();
48
- await (0, import_exec.ensureCommands)("yarn");
49
54
  const {
50
55
  destinationDir,
51
56
  entryPoint,
57
+ packageManager,
52
58
  templateComplete,
53
59
  templateData,
54
60
  templateName,
55
61
  type
56
62
  } = await (0, import_getConfig.getConfig)();
63
+ await (0, import_exec.ensureCommands)(packageManager);
57
64
  const include = await (0, import_dir.createInclusionFilter)([
58
65
  import_path.default.join(destinationDir, ".gitignore"),
59
66
  import_path.default.join(import_template.BASE_TEMPLATE_DIR, "_.gitignore")
@@ -88,18 +95,19 @@ const init = async () => {
88
95
  const exec = (0, import_exec.createExec)({
89
96
  cwd: destinationDir,
90
97
  stdio: "pipe",
91
- streamStdio: "yarn"
98
+ streamStdio: packageManager
92
99
  });
93
100
  import_logging.log.newline();
94
101
  await (0, import_git2.initialiseRepo)(destinationDir, templateData);
95
- await (0, import_patchRenovateConfig.tryPatchRenovateConfig)(destinationDir);
102
+ await (0, import_patchRenovateConfig.tryPatchRenovateConfig)("format", destinationDir);
96
103
  const skubaSlug = `skuba@${skubaVersionInfo.local}`;
97
104
  let depsInstalled = false;
98
105
  try {
99
- await exec("yarn", "add", "--dev", skubaSlug);
106
+ await exec(packageManager, "add", "-D", skubaSlug);
107
+ await (0, import_prettier.runPrettier)("format", (0, import_logging.createLogger)(opts.debug), destinationDir);
100
108
  depsInstalled = true;
101
- await exec("npx", "yarn-deduplicate", "--strategy=highest");
102
- } catch {
109
+ } catch (err) {
110
+ import_logging.log.warn((0, import_util.inspect)(err));
103
111
  }
104
112
  await (0, import_git.commitAllChanges)({
105
113
  dir: destinationDir,
@@ -121,10 +129,11 @@ const init = async () => {
121
129
  import_logging.log.newline();
122
130
  import_logging.log.plain("Then, resume initialisation:");
123
131
  import_logging.log.ok("cd", destinationDir);
124
- import_logging.log.ok("yarn add --dev", skubaSlug);
132
+ import_logging.log.ok(packageManager, "add", "-D", skubaSlug);
133
+ import_logging.log.ok(packageManager, "run", "format");
125
134
  import_logging.log.ok("git add --all");
126
135
  import_logging.log.ok("git commit --message", `'Pin ${skubaSlug}'`);
127
- import_logging.log.ok("git push --set-upstream origin master");
136
+ import_logging.log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);
128
137
  import_logging.log.newline();
129
138
  process.exitCode = 1;
130
139
  return;
@@ -136,7 +145,7 @@ const init = async () => {
136
145
  import_logging.log.newline();
137
146
  import_logging.log.plain("Then, push your local changes:");
138
147
  import_logging.log.ok("cd", destinationDir);
139
- import_logging.log.ok("git push --set-upstream origin master");
148
+ import_logging.log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);
140
149
  import_logging.log.newline();
141
150
  };
142
151
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/init/index.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport { commitAllChanges } from '../../api/git';\nimport { copyFiles, createEjsRenderer } from '../../utils/copy';\nimport { createInclusionFilter } from '../../utils/dir';\nimport { createExec, ensureCommands } from '../../utils/exec';\nimport { log } from '../../utils/logging';\nimport { showLogoAndVersionInfo } from '../../utils/logo';\nimport {\n BASE_TEMPLATE_DIR,\n ensureTemplateConfigDeletion,\n} from '../../utils/template';\nimport { tryPatchRenovateConfig } from '../configure/patchRenovateConfig';\n\nimport { getConfig } from './getConfig';\nimport { initialiseRepo } from './git';\nimport { writePackageJson } from './writePackageJson';\n\nexport const init = async () => {\n const skubaVersionInfo = await showLogoAndVersionInfo();\n\n await ensureCommands('yarn');\n\n const {\n destinationDir,\n entryPoint,\n templateComplete,\n templateData,\n templateName,\n type,\n } = await getConfig();\n\n const include = await createInclusionFilter([\n path.join(destinationDir, '.gitignore'),\n path.join(BASE_TEMPLATE_DIR, '_.gitignore'),\n ]);\n\n const processors = [createEjsRenderer(templateData)];\n\n await copyFiles({\n sourceRoot: BASE_TEMPLATE_DIR,\n destinationRoot: destinationDir,\n include,\n // prefer template-specific files\n overwrite: false,\n processors,\n // base template has files like _.eslintrc.js\n stripUnderscorePrefix: true,\n });\n\n await copyFiles({\n sourceRoot: destinationDir,\n destinationRoot: destinationDir,\n include,\n processors,\n });\n\n await Promise.all([\n templateComplete\n ? ensureTemplateConfigDeletion(destinationDir)\n : Promise.resolve(),\n\n writePackageJson({\n cwd: destinationDir,\n entryPoint,\n template: templateName,\n type,\n version: skubaVersionInfo.local,\n }),\n ]);\n\n const exec = createExec({\n cwd: destinationDir,\n stdio: 'pipe',\n streamStdio: 'yarn',\n });\n\n log.newline();\n await initialiseRepo(destinationDir, templateData);\n\n // Patch in a baseline Renovate preset based on the configured Git owner.\n await tryPatchRenovateConfig(destinationDir);\n\n const skubaSlug = `skuba@${skubaVersionInfo.local}`;\n\n let depsInstalled = false;\n try {\n await exec('yarn', 'add', '--dev', skubaSlug);\n depsInstalled = true;\n await exec('npx', 'yarn-deduplicate', '--strategy=highest');\n } catch {}\n\n await commitAllChanges({\n dir: destinationDir,\n message: `Clone ${templateName}`,\n });\n\n const logGitHubRepoCreation = () => {\n log.plain(\n 'Next, create an empty',\n log.bold(`${templateData.orgName}/${templateData.repoName}`),\n 'repository:',\n );\n log.ok('https://github.com/new');\n };\n\n if (!depsInstalled) {\n log.newline();\n log.warn(log.bold('\u2717 Failed to install dependencies.'));\n\n log.newline();\n logGitHubRepoCreation();\n\n log.newline();\n log.plain('Then, resume initialisation:');\n log.ok('cd', destinationDir);\n log.ok('yarn add --dev', skubaSlug);\n log.ok('git add --all');\n log.ok('git commit --message', `'Pin ${skubaSlug}'`);\n log.ok('git push --set-upstream origin master');\n\n log.newline();\n process.exitCode = 1;\n return;\n }\n\n log.newline();\n log.ok(log.bold('\u2714 Project initialised!'));\n\n log.newline();\n logGitHubRepoCreation();\n\n log.newline();\n log.plain('Then, push your local changes:');\n log.ok('cd', destinationDir);\n log.ok('git push --set-upstream origin master');\n\n log.newline();\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,iBAAiC;AACjC,kBAA6C;AAC7C,iBAAsC;AACt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AAQ,OAAO,SAAS,SAAS;AAC5C,oBAAgB;AAChB,UAAM,KAAK,OAAO,oBAAoB,oBAAoB;AAAA,EAC5D,QAAQ;AAAA,EAAC;AAET,YAAM,6BAAiB;AAAA,IACrB,KAAK;AAAA,IACL,SAAS,SAAS,YAAY;AAAA,EAChC,CAAC;AAED,QAAM,wBAAwB,MAAM;AAClC,uBAAI;AAAA,MACF;AAAA,MACA,mBAAI,KAAK,GAAG,aAAa,OAAO,IAAI,aAAa,QAAQ,EAAE;AAAA,MAC3D;AAAA,IACF;AACA,uBAAI,GAAG,wBAAwB;AAAA,EACjC;AAEA,MAAI,CAAC,eAAe;AAClB,uBAAI,QAAQ;AACZ,uBAAI,KAAK,mBAAI,KAAK,wCAAmC,CAAC;AAEtD,uBAAI,QAAQ;AACZ,0BAAsB;AAEtB,uBAAI,QAAQ;AACZ,uBAAI,MAAM,8BAA8B;AACxC,uBAAI,GAAG,MAAM,cAAc;AAC3B,uBAAI,GAAG,kBAAkB,SAAS;AAClC,uBAAI,GAAG,eAAe;AACtB,uBAAI,GAAG,wBAAwB,QAAQ,SAAS,GAAG;AACnD,uBAAI,GAAG,uCAAuC;AAE9C,uBAAI,QAAQ;AACZ,YAAQ,WAAW;AACnB;AAAA,EACF;AAEA,qBAAI,QAAQ;AACZ,qBAAI,GAAG,mBAAI,KAAK,6BAAwB,CAAC;AAEzC,qBAAI,QAAQ;AACZ,wBAAsB;AAEtB,qBAAI,QAAQ;AACZ,qBAAI,MAAM,gCAAgC;AAC1C,qBAAI,GAAG,MAAM,cAAc;AAC3B,qBAAI,GAAG,uCAAuC;AAE9C,qBAAI,QAAQ;AACd;",
4
+ "sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { commitAllChanges } from '../../api/git';\nimport { hasDebugFlag } from '../../utils/args';\nimport { copyFiles, createEjsRenderer } from '../../utils/copy';\nimport { createInclusionFilter } from '../../utils/dir';\nimport { createExec, ensureCommands } from '../../utils/exec';\nimport { createLogger, log } from '../../utils/logging';\nimport { showLogoAndVersionInfo } from '../../utils/logo';\nimport {\n BASE_TEMPLATE_DIR,\n ensureTemplateConfigDeletion,\n} from '../../utils/template';\nimport { runPrettier } from '../adapter/prettier';\nimport { tryPatchRenovateConfig } from '../configure/patchRenovateConfig';\n\nimport { getConfig } from './getConfig';\nimport { initialiseRepo } from './git';\nimport type { Input } from './types';\nimport { writePackageJson } from './writePackageJson';\n\nexport const init = async (args = process.argv.slice(2)) => {\n const opts: Input = {\n debug: hasDebugFlag(args),\n };\n\n const skubaVersionInfo = await showLogoAndVersionInfo();\n\n const {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete,\n templateData,\n templateName,\n type,\n } = await getConfig();\n\n await ensureCommands(packageManager);\n\n const include = await createInclusionFilter([\n path.join(destinationDir, '.gitignore'),\n path.join(BASE_TEMPLATE_DIR, '_.gitignore'),\n ]);\n\n const processors = [createEjsRenderer(templateData)];\n\n await copyFiles({\n sourceRoot: BASE_TEMPLATE_DIR,\n destinationRoot: destinationDir,\n include,\n // prefer template-specific files\n overwrite: false,\n processors,\n // base template has files like _.eslintrc.js\n stripUnderscorePrefix: true,\n });\n\n await copyFiles({\n sourceRoot: destinationDir,\n destinationRoot: destinationDir,\n include,\n processors,\n });\n\n await Promise.all([\n templateComplete\n ? ensureTemplateConfigDeletion(destinationDir)\n : Promise.resolve(),\n\n writePackageJson({\n cwd: destinationDir,\n entryPoint,\n template: templateName,\n type,\n version: skubaVersionInfo.local,\n }),\n ]);\n\n const exec = createExec({\n cwd: destinationDir,\n stdio: 'pipe',\n streamStdio: packageManager,\n });\n\n log.newline();\n await initialiseRepo(destinationDir, templateData);\n\n // Patch in a baseline Renovate preset based on the configured Git owner.\n await tryPatchRenovateConfig('format', destinationDir);\n\n const skubaSlug = `skuba@${skubaVersionInfo.local}`;\n\n let depsInstalled = false;\n try {\n // The `-D` shorthand is portable across our package managers.\n await exec(packageManager, 'add', '-D', skubaSlug);\n\n // Templating can initially leave certain files in an unformatted state;\n // consider a Markdown table with columns sized based on content length.\n await runPrettier('format', createLogger(opts.debug), destinationDir);\n\n depsInstalled = true;\n } catch (err) {\n log.warn(inspect(err));\n }\n\n await commitAllChanges({\n dir: destinationDir,\n message: `Clone ${templateName}`,\n });\n\n const logGitHubRepoCreation = () => {\n log.plain(\n 'Next, create an empty',\n log.bold(`${templateData.orgName}/${templateData.repoName}`),\n 'repository:',\n );\n log.ok('https://github.com/new');\n };\n\n if (!depsInstalled) {\n log.newline();\n log.warn(log.bold('\u2717 Failed to install dependencies.'));\n\n log.newline();\n logGitHubRepoCreation();\n\n log.newline();\n log.plain('Then, resume initialisation:');\n log.ok('cd', destinationDir);\n // The `-D` shorthand is portable across our package managers.\n log.ok(packageManager, 'add', '-D', skubaSlug);\n log.ok(packageManager, 'run', 'format');\n log.ok('git add --all');\n log.ok('git commit --message', `'Pin ${skubaSlug}'`);\n log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);\n\n log.newline();\n process.exitCode = 1;\n return;\n }\n\n log.newline();\n log.ok(log.bold('\u2714 Project initialised!'));\n\n log.newline();\n logGitHubRepoCreation();\n\n log.newline();\n log.plain('Then, push your local changes:');\n log.ok('cd', destinationDir);\n log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);\n\n log.newline();\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,iBAAiC;AACjC,kBAA6B;AAC7B,kBAA6C;AAC7C,iBAAsC;AACtC,kBAA2C;AAC3C,qBAAkC;AAClC,kBAAuC;AACvC,sBAGO;AACP,sBAA4B;AAC5B,iCAAuC;AAEvC,uBAA0B;AAC1B,IAAAA,cAA+B;AAE/B,8BAAiC;AAE1B,MAAM,OAAO,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAM;AAC1D,QAAM,OAAc;AAAA,IAClB,WAAO,0BAAa,IAAI;AAAA,EAC1B;AAEA,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SAAK,qBAAQ,GAAG,CAAC;AAAA,EACvB;AAEA,YAAM,6BAAiB;AAAA,IACrB,KAAK;AAAA,IACL,SAAS,SAAS,YAAY;AAAA,EAChC,CAAC;AAED,QAAM,wBAAwB,MAAM;AAClC,uBAAI;AAAA,MACF;AAAA,MACA,mBAAI,KAAK,GAAG,aAAa,OAAO,IAAI,aAAa,QAAQ,EAAE;AAAA,MAC3D;AAAA,IACF;AACA,uBAAI,GAAG,wBAAwB;AAAA,EACjC;AAEA,MAAI,CAAC,eAAe;AAClB,uBAAI,QAAQ;AACZ,uBAAI,KAAK,mBAAI,KAAK,wCAAmC,CAAC;AAEtD,uBAAI,QAAQ;AACZ,0BAAsB;AAEtB,uBAAI,QAAQ;AACZ,uBAAI,MAAM,8BAA8B;AACxC,uBAAI,GAAG,MAAM,cAAc;AAE3B,uBAAI,GAAG,gBAAgB,OAAO,MAAM,SAAS;AAC7C,uBAAI,GAAG,gBAAgB,OAAO,QAAQ;AACtC,uBAAI,GAAG,eAAe;AACtB,uBAAI,GAAG,wBAAwB,QAAQ,SAAS,GAAG;AACnD,uBAAI,GAAG,kCAAkC,aAAa,aAAa,EAAE;AAErE,uBAAI,QAAQ;AACZ,YAAQ,WAAW;AACnB;AAAA,EACF;AAEA,qBAAI,QAAQ;AACZ,qBAAI,GAAG,mBAAI,KAAK,6BAAwB,CAAC;AAEzC,qBAAI,QAAQ;AACZ,wBAAsB;AAEtB,qBAAI,QAAQ;AACZ,qBAAI,MAAM,gCAAgC;AAC1C,qBAAI,GAAG,MAAM,cAAc;AAC3B,qBAAI,GAAG,kCAAkC,aAAa,aAAa,EAAE;AAErE,qBAAI,QAAQ;AACd;",
6
6
  "names": ["import_git", "path"]
7
7
  }
@@ -1,5 +1,14 @@
1
+ /// <reference path="../../../src/enquirer.d.ts" />
2
+ import { type FormChoice, Input, Select } from 'enquirer';
1
3
  import { type Platform } from './validation';
2
- import { Input, Select } from 'enquirer';
4
+ export type Choice = FormChoice & {
5
+ /**
6
+ * Whether the user is allowed to skip field entry and use the initial value.
7
+ *
8
+ * Defaults to `false`.
9
+ */
10
+ allowInitial?: boolean;
11
+ };
3
12
  export type BaseFields = Record<(typeof BASE_CHOICES)[number]['name'], string> & {
4
13
  platformName: Platform;
5
14
  };
@@ -16,8 +25,15 @@ declare const BASE_CHOICES: readonly [{
16
25
  }, {
17
26
  readonly name: "platformName";
18
27
  readonly message: "Platform";
19
- readonly initial: string;
28
+ readonly initial: "arm64";
29
+ readonly allowInitial: true;
20
30
  readonly validate: (value: unknown) => string | true;
31
+ }, {
32
+ readonly name: "defaultBranch";
33
+ readonly message: "Default Branch";
34
+ readonly initial: "main";
35
+ readonly allowInitial: true;
36
+ readonly validate: (value: unknown) => true | "required";
21
37
  }];
22
38
  export declare const BASE_PROMPT_PROPS: {
23
39
  choices: readonly [{
@@ -33,8 +49,15 @@ export declare const BASE_PROMPT_PROPS: {
33
49
  }, {
34
50
  readonly name: "platformName";
35
51
  readonly message: "Platform";
36
- readonly initial: string;
52
+ readonly initial: "arm64";
53
+ readonly allowInitial: true;
37
54
  readonly validate: (value: unknown) => string | true;
55
+ }, {
56
+ readonly name: "defaultBranch";
57
+ readonly message: "Default Branch";
58
+ readonly initial: "main";
59
+ readonly allowInitial: true;
60
+ readonly validate: (value: unknown) => true | "required";
38
61
  }];
39
62
  message: string;
40
63
  name: string;
@@ -24,10 +24,10 @@ __export(prompts_exports, {
24
24
  TEMPLATE_PROMPT: () => TEMPLATE_PROMPT
25
25
  });
26
26
  module.exports = __toCommonJS(prompts_exports);
27
+ var import_enquirer = require("enquirer");
27
28
  var import_fs_extra = require("fs-extra");
28
29
  var import_template = require("../../utils/template");
29
30
  var import_validation = require("./validation");
30
- var import_enquirer = require("enquirer");
31
31
  const BASE_CHOICES = [
32
32
  {
33
33
  name: "ownerName",
@@ -62,8 +62,16 @@ const BASE_CHOICES = [
62
62
  {
63
63
  name: "platformName",
64
64
  message: "Platform",
65
- initial: import_validation.PLATFORM_OPTIONS,
65
+ initial: "arm64",
66
+ allowInitial: true,
66
67
  validate: (value) => (0, import_validation.isPlatform)(value) || `must be ${import_validation.PLATFORM_OPTIONS}`
68
+ },
69
+ {
70
+ name: "defaultBranch",
71
+ message: "Default Branch",
72
+ initial: "main",
73
+ allowInitial: true,
74
+ validate: (value) => typeof value === "string" && value.length > 0 ? true : "required"
67
75
  }
68
76
  ];
69
77
  const BASE_PROMPT_PROPS = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/init/prompts.ts"],
4
- "sourcesContent": ["import { pathExists } from 'fs-extra';\n\nimport { TEMPLATE_NAMES_WITH_BYO } from '../../utils/template';\n\nimport {\n PLATFORM_OPTIONS,\n type Platform,\n isGitHubOrg,\n isGitHubRepo,\n isGitHubTeam,\n isPlatform,\n} from './validation';\n\nimport { Input, Select } from 'enquirer';\n\nexport type BaseFields = Record<\n (typeof BASE_CHOICES)[number]['name'],\n string\n> & {\n platformName: Platform;\n};\n\nconst BASE_CHOICES = [\n {\n name: 'ownerName',\n message: 'Owner',\n initial: 'SEEK-Jobs/my-team',\n validate: (value: unknown) => {\n if (typeof value !== 'string') {\n return 'required';\n }\n\n const [org, team] = value.split('/');\n\n if (!org || !isGitHubOrg(org)) {\n return 'fails GitHub validation';\n }\n\n return (\n team === undefined || isGitHubTeam(team) || 'fails GitHub validation'\n );\n },\n },\n {\n name: 'repoName',\n message: 'Repo',\n initial: 'my-repo',\n validate: async (value: unknown) => {\n if (typeof value !== 'string') {\n return 'required';\n }\n\n if (!isGitHubRepo(value)) {\n return 'fails GitHub validation';\n }\n\n const exists = await pathExists(value);\n\n return !exists || `'${value}' is an existing directory`;\n },\n },\n {\n name: 'platformName',\n message: 'Platform',\n initial: PLATFORM_OPTIONS,\n validate: (value: unknown) =>\n isPlatform(value) || `must be ${PLATFORM_OPTIONS}`,\n },\n] as const;\n\nexport const BASE_PROMPT_PROPS = {\n choices: BASE_CHOICES,\n message: 'For starters, some project details:',\n name: 'baseAnswers',\n};\n\nexport const SHOULD_CONTINUE_PROMPT = new Select({\n choices: ['yes', 'no'] as const,\n message: 'Fill this in now?',\n name: 'shouldContinue',\n});\n\nexport const GIT_PATH_PROMPT = new Input({\n message: 'Git path',\n name: 'gitPath',\n initial: 'seek-oss/skuba',\n validate: (value) => /[^/]+\\/[^/]+/.test(value) || 'Path is not valid',\n});\n\nexport const TEMPLATE_PROMPT = new Select({\n choices: TEMPLATE_NAMES_WITH_BYO,\n message: 'Select a template:',\n name: 'templateName',\n});\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA2B;AAE3B,sBAAwC;AAExC,wBAOO;AAEP,sBAA8B;AAS9B,MAAM,eAAe;AAAA,EACnB;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,UAAU,CAAC,UAAmB;AAC5B,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO;AAAA,MACT;AAEA,YAAM,CAAC,KAAK,IAAI,IAAI,MAAM,MAAM,GAAG;AAEnC,UAAI,CAAC,OAAO,KAAC,+BAAY,GAAG,GAAG;AAC7B,eAAO;AAAA,MACT;AAEA,aACE,SAAS,cAAa,gCAAa,IAAI,KAAK;AAAA,IAEhD;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,UAAU,OAAO,UAAmB;AAClC,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO;AAAA,MACT;AAEA,UAAI,KAAC,gCAAa,KAAK,GAAG;AACxB,eAAO;AAAA,MACT;AAEA,YAAM,SAAS,UAAM,4BAAW,KAAK;AAErC,aAAO,CAAC,UAAU,IAAI,KAAK;AAAA,IAC7B;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,UAAU,CAAC,cACT,8BAAW,KAAK,KAAK,WAAW,kCAAgB;AAAA,EACpD;AACF;AAEO,MAAM,oBAAoB;AAAA,EAC/B,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AACR;AAEO,MAAM,yBAAyB,IAAI,uBAAO;AAAA,EAC/C,SAAS,CAAC,OAAO,IAAI;AAAA,EACrB,SAAS;AAAA,EACT,MAAM;AACR,CAAC;AAEM,MAAM,kBAAkB,IAAI,sBAAM;AAAA,EACvC,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,UAAU,eAAe,KAAK,KAAK,KAAK;AACrD,CAAC;AAEM,MAAM,kBAAkB,IAAI,uBAAO;AAAA,EACxC,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AACR,CAAC;",
4
+ "sourcesContent": ["import { type FormChoice, Input, Select } from 'enquirer';\nimport { pathExists } from 'fs-extra';\n\nimport { TEMPLATE_NAMES_WITH_BYO } from '../../utils/template';\n\nimport {\n PLATFORM_OPTIONS,\n type Platform,\n isGitHubOrg,\n isGitHubRepo,\n isGitHubTeam,\n isPlatform,\n} from './validation';\n\nexport type Choice = FormChoice & {\n /**\n * Whether the user is allowed to skip field entry and use the initial value.\n *\n * Defaults to `false`.\n */\n allowInitial?: boolean;\n};\n\nexport type BaseFields = Record<\n (typeof BASE_CHOICES)[number]['name'],\n string\n> & {\n platformName: Platform;\n};\n\nconst BASE_CHOICES = [\n {\n name: 'ownerName',\n message: 'Owner',\n initial: 'SEEK-Jobs/my-team',\n validate: (value: unknown) => {\n if (typeof value !== 'string') {\n return 'required';\n }\n\n const [org, team] = value.split('/');\n\n if (!org || !isGitHubOrg(org)) {\n return 'fails GitHub validation';\n }\n\n return (\n team === undefined || isGitHubTeam(team) || 'fails GitHub validation'\n );\n },\n },\n {\n name: 'repoName',\n message: 'Repo',\n initial: 'my-repo',\n validate: async (value: unknown) => {\n if (typeof value !== 'string') {\n return 'required';\n }\n\n if (!isGitHubRepo(value)) {\n return 'fails GitHub validation';\n }\n\n const exists = await pathExists(value);\n\n return !exists || `'${value}' is an existing directory`;\n },\n },\n {\n name: 'platformName',\n message: 'Platform',\n initial: 'arm64',\n allowInitial: true,\n validate: (value: unknown) =>\n isPlatform(value) || `must be ${PLATFORM_OPTIONS}`,\n },\n {\n name: 'defaultBranch',\n message: 'Default Branch',\n initial: 'main',\n allowInitial: true,\n validate: (value: unknown) =>\n typeof value === 'string' && value.length > 0 ? true : 'required',\n },\n] as const;\n\nexport const BASE_PROMPT_PROPS = {\n choices: BASE_CHOICES,\n message: 'For starters, some project details:',\n name: 'baseAnswers',\n};\n\nexport const SHOULD_CONTINUE_PROMPT = new Select({\n choices: ['yes', 'no'] as const,\n message: 'Fill this in now?',\n name: 'shouldContinue',\n});\n\nexport const GIT_PATH_PROMPT = new Input({\n message: 'Git path',\n name: 'gitPath',\n initial: 'seek-oss/skuba',\n validate: (value) => /[^/]+\\/[^/]+/.test(value) || 'Path is not valid',\n});\n\nexport const TEMPLATE_PROMPT = new Select({\n choices: TEMPLATE_NAMES_WITH_BYO,\n message: 'Select a template:',\n name: 'templateName',\n});\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA+C;AAC/C,sBAA2B;AAE3B,sBAAwC;AAExC,wBAOO;AAkBP,MAAM,eAAe;AAAA,EACnB;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,UAAU,CAAC,UAAmB;AAC5B,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO;AAAA,MACT;AAEA,YAAM,CAAC,KAAK,IAAI,IAAI,MAAM,MAAM,GAAG;AAEnC,UAAI,CAAC,OAAO,KAAC,+BAAY,GAAG,GAAG;AAC7B,eAAO;AAAA,MACT;AAEA,aACE,SAAS,cAAa,gCAAa,IAAI,KAAK;AAAA,IAEhD;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,UAAU,OAAO,UAAmB;AAClC,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO;AAAA,MACT;AAEA,UAAI,KAAC,gCAAa,KAAK,GAAG;AACxB,eAAO;AAAA,MACT;AAEA,YAAM,SAAS,UAAM,4BAAW,KAAK;AAErC,aAAO,CAAC,UAAU,IAAI,KAAK;AAAA,IAC7B;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,cAAc;AAAA,IACd,UAAU,CAAC,cACT,8BAAW,KAAK,KAAK,WAAW,kCAAgB;AAAA,EACpD;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,cAAc;AAAA,IACd,UAAU,CAAC,UACT,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,OAAO;AAAA,EAC3D;AACF;AAEO,MAAM,oBAAoB;AAAA,EAC/B,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AACR;AAEO,MAAM,yBAAyB,IAAI,uBAAO;AAAA,EAC/C,SAAS,CAAC,OAAO,IAAI;AAAA,EACrB,SAAS;AAAA,EACT,MAAM;AACR,CAAC;AAEM,MAAM,kBAAkB,IAAI,sBAAM;AAAA,EACvC,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,UAAU,eAAe,KAAK,KAAK,KAAK;AACrD,CAAC;AAEM,MAAM,kBAAkB,IAAI,uBAAO;AAAA,EACxC,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AACR,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,28 +1,121 @@
1
- import * as t from 'runtypes';
2
- export type InitConfigInput = t.Static<typeof InitConfigInput>;
3
- export declare const InitConfigInput: t.Record<{
4
- destinationDir: t.String;
5
- templateComplete: t.Boolean;
6
- templateData: t.Intersect<[t.Record<{
7
- ownerName: t.String;
8
- repoName: t.String;
9
- platformName: t.Union<[t.Literal<"amd64">, t.Literal<"arm64">]>;
10
- }, false>, t.Dictionary<t.String, string>]>;
11
- templateName: t.String;
12
- }, false>;
13
- export type InitConfig = t.Static<typeof InitConfig>;
14
- declare const InitConfig: t.Record<{
15
- templateData: t.Intersect<[t.Record<{
16
- ownerName: t.String;
17
- repoName: t.String;
18
- orgName: t.String;
19
- teamName: t.String;
20
- port: t.String;
21
- }, false>, t.Dictionary<t.String, string>]>;
22
- entryPoint: t.Optional<t.String>;
23
- type: t.Optional<t.Union<[t.Literal<"application">, t.Literal<"package">]>>;
24
- destinationDir: t.String;
25
- templateComplete: t.Boolean;
26
- templateName: t.String;
27
- }, false>;
1
+ import { z } from 'zod';
2
+ export interface Input {
3
+ /**
4
+ * Whether to enable verbose debug logging.
5
+ *
6
+ * Defaults to `false`.
7
+ */
8
+ debug: boolean;
9
+ }
10
+ export type InitConfigInput = z.infer<typeof initConfigInputSchema>;
11
+ export declare const initConfigInputSchema: z.ZodObject<{
12
+ destinationDir: z.ZodString;
13
+ templateComplete: z.ZodBoolean;
14
+ templateData: z.ZodObject<{
15
+ ownerName: z.ZodString;
16
+ repoName: z.ZodString;
17
+ platformName: z.ZodUnion<[z.ZodLiteral<"amd64">, z.ZodLiteral<"arm64">]>;
18
+ defaultBranch: z.ZodString;
19
+ }, "strip", z.ZodString, z.objectOutputType<{
20
+ ownerName: z.ZodString;
21
+ repoName: z.ZodString;
22
+ platformName: z.ZodUnion<[z.ZodLiteral<"amd64">, z.ZodLiteral<"arm64">]>;
23
+ defaultBranch: z.ZodString;
24
+ }, z.ZodString, "strip">, z.objectInputType<{
25
+ ownerName: z.ZodString;
26
+ repoName: z.ZodString;
27
+ platformName: z.ZodUnion<[z.ZodLiteral<"amd64">, z.ZodLiteral<"arm64">]>;
28
+ defaultBranch: z.ZodString;
29
+ }, z.ZodString, "strip">>;
30
+ templateName: z.ZodString;
31
+ }, "strip", z.ZodTypeAny, {
32
+ templateName: string;
33
+ destinationDir: string;
34
+ templateComplete: boolean;
35
+ templateData: {
36
+ defaultBranch: string;
37
+ repoName: string;
38
+ ownerName: string;
39
+ platformName: "arm64" | "amd64";
40
+ } & {
41
+ [k: string]: string;
42
+ };
43
+ }, {
44
+ templateName: string;
45
+ destinationDir: string;
46
+ templateComplete: boolean;
47
+ templateData: {
48
+ defaultBranch: string;
49
+ repoName: string;
50
+ ownerName: string;
51
+ platformName: "arm64" | "amd64";
52
+ } & {
53
+ [k: string]: string;
54
+ };
55
+ }>;
56
+ export type InitConfig = z.infer<typeof initConfigSchema>;
57
+ declare const initConfigSchema: z.ZodObject<{
58
+ templateName: z.ZodString;
59
+ destinationDir: z.ZodString;
60
+ templateComplete: z.ZodBoolean;
61
+ templateData: z.ZodObject<{
62
+ ownerName: z.ZodString;
63
+ repoName: z.ZodString;
64
+ defaultBranch: z.ZodString;
65
+ orgName: z.ZodString;
66
+ teamName: z.ZodString;
67
+ port: z.ZodString;
68
+ }, "strip", z.ZodString, z.objectOutputType<{
69
+ ownerName: z.ZodString;
70
+ repoName: z.ZodString;
71
+ defaultBranch: z.ZodString;
72
+ orgName: z.ZodString;
73
+ teamName: z.ZodString;
74
+ port: z.ZodString;
75
+ }, z.ZodString, "strip">, z.objectInputType<{
76
+ ownerName: z.ZodString;
77
+ repoName: z.ZodString;
78
+ defaultBranch: z.ZodString;
79
+ orgName: z.ZodString;
80
+ teamName: z.ZodString;
81
+ port: z.ZodString;
82
+ }, z.ZodString, "strip">>;
83
+ entryPoint: z.ZodOptional<z.ZodString>;
84
+ packageManager: z.ZodDefault<z.ZodEnum<["pnpm", "yarn"]>>;
85
+ type: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"application">, z.ZodLiteral<"package">]>>;
86
+ }, "strip", z.ZodTypeAny, {
87
+ packageManager: "yarn" | "pnpm";
88
+ templateName: string;
89
+ destinationDir: string;
90
+ templateComplete: boolean;
91
+ templateData: {
92
+ port: string;
93
+ defaultBranch: string;
94
+ orgName: string;
95
+ repoName: string;
96
+ ownerName: string;
97
+ teamName: string;
98
+ } & {
99
+ [k: string]: string;
100
+ };
101
+ entryPoint?: string | undefined;
102
+ type?: "package" | "application" | undefined;
103
+ }, {
104
+ templateName: string;
105
+ destinationDir: string;
106
+ templateComplete: boolean;
107
+ templateData: {
108
+ port: string;
109
+ defaultBranch: string;
110
+ orgName: string;
111
+ repoName: string;
112
+ ownerName: string;
113
+ teamName: string;
114
+ } & {
115
+ [k: string]: string;
116
+ };
117
+ entryPoint?: string | undefined;
118
+ packageManager?: "yarn" | "pnpm" | undefined;
119
+ type?: "package" | "application" | undefined;
120
+ }>;
28
121
  export {};
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,49 +15,46 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var types_exports = {};
30
20
  __export(types_exports, {
31
- InitConfigInput: () => InitConfigInput
21
+ initConfigInputSchema: () => initConfigInputSchema
32
22
  });
33
23
  module.exports = __toCommonJS(types_exports);
34
- var t = __toESM(require("runtypes"));
24
+ var import_zod = require("zod");
35
25
  var import_manifest = require("../../utils/manifest");
36
- const INIT_CONFIG_INPUT_FIELDS = {
37
- destinationDir: t.String,
38
- templateComplete: t.Boolean,
39
- templateData: t.Record({
40
- ownerName: t.String,
41
- repoName: t.String,
42
- platformName: t.Union(t.Literal("amd64"), t.Literal("arm64"))
43
- }).And(t.Dictionary(t.String, t.String)),
44
- templateName: t.String
45
- };
46
- const InitConfigInput = t.Record(INIT_CONFIG_INPUT_FIELDS);
47
- const InitConfig = t.Record({
48
- ...INIT_CONFIG_INPUT_FIELDS,
49
- templateData: t.Record({
50
- ownerName: t.String,
51
- repoName: t.String,
26
+ var import_packageManager = require("../../utils/packageManager");
27
+ const initConfigInputSchema = import_zod.z.object({
28
+ destinationDir: import_zod.z.string(),
29
+ templateComplete: import_zod.z.boolean(),
30
+ templateData: import_zod.z.object({
31
+ ownerName: import_zod.z.string(),
32
+ repoName: import_zod.z.string(),
33
+ platformName: import_zod.z.union([import_zod.z.literal("amd64"), import_zod.z.literal("arm64")]),
34
+ defaultBranch: import_zod.z.string()
35
+ }).catchall(import_zod.z.string()),
36
+ templateName: import_zod.z.string()
37
+ });
38
+ const initConfigSchema = initConfigInputSchema.omit({
39
+ templateData: true
40
+ }).extend({
41
+ templateData: import_zod.z.object({
42
+ ownerName: import_zod.z.string(),
43
+ repoName: import_zod.z.string(),
44
+ defaultBranch: import_zod.z.string(),
52
45
  // Derived from ownerName
53
- orgName: t.String,
54
- teamName: t.String,
46
+ // TODO: use zod to transform `InitConfigInput` -> `InitConfig`?
47
+ orgName: import_zod.z.string(),
48
+ teamName: import_zod.z.string(),
55
49
  // Generated by init command
56
- port: t.String
57
- }).And(t.Dictionary(t.String, t.String)),
58
- entryPoint: t.String.optional(),
59
- type: import_manifest.ProjectType.optional()
50
+ port: import_zod.z.string()
51
+ }).catchall(import_zod.z.string()),
52
+ entryPoint: import_zod.z.string().optional(),
53
+ packageManager: import_packageManager.packageManagerSchema,
54
+ type: import_manifest.projectTypeSchema.optional()
60
55
  });
61
56
  // Annotate the CommonJS export names for ESM import in node:
62
57
  0 && (module.exports = {
63
- InitConfigInput
58
+ initConfigInputSchema
64
59
  });
65
60
  //# sourceMappingURL=types.js.map