@payloadcms/figma 0.1.0-alpha.1 → 0.1.0-alpha.11

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 (321) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/{utils → adapters}/asset-collection.d.ts +17 -3
  3. package/dist/adapters/asset-collection.js +242 -0
  4. package/dist/{utils → adapters}/build-lambda-zip.d.ts +8 -7
  5. package/dist/adapters/build-lambda-zip.js +111 -0
  6. package/dist/adapters/configureNextjsCache.d.ts +8 -0
  7. package/dist/adapters/configureNextjsCache.js +55 -0
  8. package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.d.ts +1 -0
  9. package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.js +15 -0
  10. package/dist/adapters/deploy-output/inspectNextjsOutput.d.ts +12 -0
  11. package/dist/adapters/deploy-output/inspectNextjsOutput.js +28 -0
  12. package/dist/adapters/deploy-output/inspectNitroOutput.d.ts +9 -0
  13. package/dist/adapters/deploy-output/inspectNitroOutput.js +13 -0
  14. package/dist/adapters/deploy-output/isFile.d.ts +1 -0
  15. package/dist/adapters/deploy-output/isFile.js +4 -0
  16. package/dist/adapters/deploy-output/readJson.d.ts +1 -0
  17. package/dist/adapters/deploy-output/readJson.js +9 -0
  18. package/dist/adapters/deploy-output/resolveNitroOutputLayout.d.ts +8 -0
  19. package/dist/adapters/deploy-output/resolveNitroOutputLayout.js +16 -0
  20. package/dist/adapters/deploy-output/resolveOutputPath.d.ts +2 -0
  21. package/dist/adapters/deploy-output/resolveOutputPath.js +9 -0
  22. package/dist/adapters/deploy-output/resolveWithin.d.ts +1 -0
  23. package/dist/adapters/deploy-output/resolveWithin.js +12 -0
  24. package/dist/adapters/fs-utils.d.ts +39 -0
  25. package/dist/adapters/fs-utils.js +135 -0
  26. package/dist/adapters/index.d.ts +4 -0
  27. package/dist/adapters/index.js +3 -0
  28. package/dist/adapters/lambda-runtime/nextjs-cache.d.ts +40 -0
  29. package/dist/adapters/lambda-runtime/nextjs-cache.js +174 -0
  30. package/dist/adapters/nextjs.d.ts +12 -0
  31. package/dist/adapters/nextjs.js +67 -0
  32. package/dist/adapters/nitro.d.ts +8 -0
  33. package/dist/adapters/nitro.js +193 -0
  34. package/dist/adapters/secret-files.d.ts +25 -0
  35. package/dist/adapters/secret-files.js +50 -0
  36. package/dist/adapters/types.d.ts +42 -0
  37. package/dist/adapters/types.js +1 -0
  38. package/dist/{utils/adapters → adapters}/vite.d.ts +2 -2
  39. package/dist/adapters/vite.js +33 -0
  40. package/dist/api/check-project-subdomain-availability.d.ts +12 -0
  41. package/dist/api/check-project-subdomain-availability.js +32 -0
  42. package/dist/api/control-plane-error.d.ts +6 -0
  43. package/dist/api/control-plane-error.js +8 -0
  44. package/dist/api/control-plane-fetch.d.ts +7 -0
  45. package/dist/api/control-plane-fetch.js +37 -0
  46. package/dist/api/control-plane.d.ts +10 -9
  47. package/dist/api/control-plane.js +27 -48
  48. package/dist/api/create-project.d.ts +18 -0
  49. package/dist/api/create-project.js +37 -0
  50. package/dist/api/list-project-workspaces.d.ts +8 -0
  51. package/dist/api/list-project-workspaces.js +28 -0
  52. package/dist/api/project-resource-type.d.ts +1 -0
  53. package/dist/api/project-resource-type.js +1 -0
  54. package/dist/auth/headless-oauth-flow.d.ts +23 -0
  55. package/dist/auth/headless-oauth-flow.js +69 -0
  56. package/dist/auth/oauth-flow.d.ts +2 -0
  57. package/dist/auth/oauth-flow.js +13 -8
  58. package/dist/auth/token-store.d.ts +20 -1
  59. package/dist/auth/token-store.js +47 -0
  60. package/dist/auth/types.d.ts +12 -0
  61. package/dist/cli.d.ts +39 -0
  62. package/dist/cli.js +71 -36
  63. package/dist/commands/bootstrap.js +2 -1
  64. package/dist/commands/build-lambda-zip.js +1 -1
  65. package/dist/commands/deploy.d.ts +12 -0
  66. package/dist/commands/deploy.js +63 -25
  67. package/dist/commands/detect-project-resource-type.d.ts +3 -0
  68. package/dist/commands/detect-project-resource-type.js +28 -0
  69. package/dist/commands/init.d.ts +2 -2
  70. package/dist/commands/init.js +235 -80
  71. package/dist/commands/login.d.ts +11 -1
  72. package/dist/commands/login.js +66 -4
  73. package/dist/commands/prompt-to-create-project/format-project-subdomain.d.ts +1 -0
  74. package/dist/commands/prompt-to-create-project/format-project-subdomain.js +3 -0
  75. package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.d.ts +1 -0
  76. package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.js +7 -0
  77. package/dist/commands/prompt-to-create-project/get-default-project-name.d.ts +1 -0
  78. package/dist/commands/prompt-to-create-project/get-default-project-name.js +13 -0
  79. package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.d.ts +7 -0
  80. package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.js +32 -0
  81. package/dist/commands/prompt-to-create-project/resolve-project-region.d.ts +8 -0
  82. package/dist/commands/prompt-to-create-project/resolve-project-region.js +27 -0
  83. package/dist/commands/prompt-to-create-project/resolve-project-subdomain.d.ts +9 -0
  84. package/dist/commands/prompt-to-create-project/resolve-project-subdomain.js +54 -0
  85. package/dist/commands/prompt-to-create-project/resolve-text-input.d.ts +9 -0
  86. package/dist/commands/prompt-to-create-project/resolve-text-input.js +23 -0
  87. package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.d.ts +12 -0
  88. package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.js +36 -0
  89. package/dist/commands/prompt-to-create-project/validate-subdomain.d.ts +1 -0
  90. package/dist/commands/prompt-to-create-project/validate-subdomain.js +9 -0
  91. package/dist/commands/prompt-to-create-project.d.ts +24 -0
  92. package/dist/commands/prompt-to-create-project.js +69 -0
  93. package/dist/commands/setup-agent.d.ts +12 -0
  94. package/dist/commands/setup-agent.js +123 -0
  95. package/dist/commands/upgrade.js +65 -1
  96. package/dist/commands/write-project-configuration.d.ts +12 -0
  97. package/dist/commands/write-project-configuration.js +16 -0
  98. package/dist/db-content-api/generated/content-api-types.d.ts +6 -2
  99. package/dist/db-content-api/index.d.ts +1 -1
  100. package/dist/db-content-api/index.js +121 -72
  101. package/dist/db-content-api/utilities/data/index.js +8 -2
  102. package/dist/db-content-api/utilities/data/injectGlobalType.d.ts +6 -0
  103. package/dist/db-content-api/utilities/data/injectGlobalType.js +11 -0
  104. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +3 -11
  105. package/dist/db-content-api/utilities/data/removeVirtualFields.js +12 -50
  106. package/dist/db-content-api/utilities/isRecord.d.ts +9 -0
  107. package/dist/db-content-api/utilities/isRecord.js +19 -0
  108. package/dist/db-content-api/utilities/joins.js +5 -1
  109. package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.d.ts +10 -0
  110. package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.js +95 -0
  111. package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.d.ts +9 -0
  112. package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.js +112 -0
  113. package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +9 -4
  114. package/dist/db-content-api/utilities/schema/getDocumentSchema.d.ts +3 -0
  115. package/dist/db-content-api/utilities/schema/getDocumentSchema.js +24 -0
  116. package/dist/db-content-api/utilities/where.d.ts +2 -6
  117. package/dist/db-content-api/utilities/where.js +20 -9
  118. package/dist/exports/client.d.ts +2 -0
  119. package/dist/exports/client.js +2 -0
  120. package/dist/exports/views.d.ts +1 -0
  121. package/dist/exports/views.js +1 -0
  122. package/dist/imageSizeOptions.d.ts +23 -0
  123. package/dist/imageSizeOptions.js +26 -0
  124. package/dist/index.d.ts +2 -0
  125. package/dist/index.js +2 -0
  126. package/dist/lib/write-agent-config.d.ts +12 -0
  127. package/dist/lib/write-agent-config.js +52 -0
  128. package/dist/next/image-loader.d.ts +6 -0
  129. package/dist/next/image-loader.js +14 -0
  130. package/dist/oauth/components/LoginButton/index.js +66 -19
  131. package/dist/oauth/components/LoginButton/index.scss +121 -15
  132. package/dist/oauth/defaults.js +4 -1
  133. package/dist/oauth/endpoints/getLoginEndpoint.js +5 -2
  134. package/dist/oauth/index.js +8 -7
  135. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +1 -1
  136. package/dist/oauth/utilities/getAuthorizeURL.d.ts +1 -0
  137. package/dist/oauth/utilities/getAuthorizeURL.js +5 -1
  138. package/dist/plugin/build-config.d.ts +13 -3
  139. package/dist/plugin/build-config.js +181 -36
  140. package/dist/plugin/cache-revalidation-hooks.d.ts +6 -0
  141. package/dist/plugin/cache-revalidation-hooks.js +69 -0
  142. package/dist/plugin/cloud-limits/CloudLimitModal/index.d.ts +9 -0
  143. package/dist/plugin/cloud-limits/CloudLimitModal/index.js +66 -0
  144. package/dist/plugin/cloud-limits/CloudLimitModal/index.scss +56 -0
  145. package/dist/plugin/cloud-limits/CloudLimitProvider/index.d.ts +4 -0
  146. package/dist/plugin/cloud-limits/CloudLimitProvider/index.js +110 -0
  147. package/dist/plugin/cloud-limits/LimitReachedView/index.css +14 -0
  148. package/dist/plugin/cloud-limits/LimitReachedView/index.d.ts +4 -0
  149. package/dist/plugin/cloud-limits/LimitReachedView/index.js +52 -0
  150. package/dist/plugin/cloud-limits/SlugRegistryContext/index.d.ts +7 -0
  151. package/dist/plugin/cloud-limits/SlugRegistryContext/index.js +3 -0
  152. package/dist/plugin/cloud-limits/SlugTracker/index.d.ts +1 -0
  153. package/dist/plugin/cloud-limits/SlugTracker/index.js +27 -0
  154. package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.d.ts +3 -0
  155. package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.js +30 -0
  156. package/dist/plugin/cloud-limits/routes.d.ts +2 -0
  157. package/dist/plugin/cloud-limits/routes.js +4 -0
  158. package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.d.ts +9 -0
  159. package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.js +28 -0
  160. package/dist/plugin/cloud-limits/shared.d.ts +10 -0
  161. package/dist/plugin/cloud-limits/shared.js +52 -0
  162. package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.d.ts +2 -0
  163. package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.js +134 -0
  164. package/dist/plugin/cloud-limits/utilities/toasts.d.ts +4 -0
  165. package/dist/plugin/cloud-limits/utilities/toasts.js +19 -0
  166. package/dist/plugin/make-permission-access/make-permission-access.d.ts +8 -0
  167. package/dist/plugin/make-permission-access/make-permission-access.js +24 -0
  168. package/dist/plugin/sandbox-upload-fetch.d.ts +32 -0
  169. package/dist/plugin/sandbox-upload-fetch.js +53 -0
  170. package/dist/skills/deploy-to-figma/SKILL.md +234 -0
  171. package/dist/skills/deploy-to-figma/references/cli-reference.md +146 -0
  172. package/dist/storage-content-api/api-types.d.ts +3 -0
  173. package/dist/storage-content-api/buildBaseMediaResponseHeaders.d.ts +1 -0
  174. package/dist/storage-content-api/buildBaseMediaResponseHeaders.js +8 -0
  175. package/dist/storage-content-api/buildClientUploadFetchBackHeaders.d.ts +12 -0
  176. package/dist/storage-content-api/buildClientUploadFetchBackHeaders.js +26 -0
  177. package/dist/storage-content-api/buildMediaRequestHeaders.d.ts +1 -0
  178. package/dist/storage-content-api/buildMediaRequestHeaders.js +14 -0
  179. package/dist/storage-content-api/buildMediaResponseHeaders.d.ts +4 -0
  180. package/dist/storage-content-api/buildMediaResponseHeaders.js +52 -0
  181. package/dist/storage-content-api/client-uploads/generate.js +2 -1
  182. package/dist/storage-content-api/getDownloadResponseHeaderPolicy.d.ts +11 -0
  183. package/dist/storage-content-api/getDownloadResponseHeaderPolicy.js +33 -0
  184. package/dist/storage-content-api/getMediaType.d.ts +1 -0
  185. package/dist/storage-content-api/getMediaType.js +3 -0
  186. package/dist/storage-content-api/hasSupportedContentEncoding.d.ts +1 -0
  187. package/dist/storage-content-api/hasSupportedContentEncoding.js +6 -0
  188. package/dist/storage-content-api/index.js +1 -0
  189. package/dist/storage-content-api/mediaErrorResponse.d.ts +1 -0
  190. package/dist/storage-content-api/mediaErrorResponse.js +12 -0
  191. package/dist/storage-content-api/resolveDownloadResponseHeaders.d.ts +5 -0
  192. package/dist/storage-content-api/resolveDownloadResponseHeaders.js +13 -0
  193. package/dist/storage-content-api/shouldAttachMedia.d.ts +1 -0
  194. package/dist/storage-content-api/shouldAttachMedia.js +34 -0
  195. package/dist/storage-content-api/staticHandler.js +93 -25
  196. package/dist/storage-content-api/types.d.ts +4 -1
  197. package/dist/translations/ar.d.ts +12 -0
  198. package/dist/translations/ar.js +12 -0
  199. package/dist/translations/az.d.ts +12 -0
  200. package/dist/translations/az.js +12 -0
  201. package/dist/translations/bg.d.ts +12 -0
  202. package/dist/translations/bg.js +12 -0
  203. package/dist/translations/bnBd.d.ts +12 -0
  204. package/dist/translations/bnBd.js +12 -0
  205. package/dist/translations/bnIn.d.ts +12 -0
  206. package/dist/translations/bnIn.js +12 -0
  207. package/dist/translations/ca.d.ts +12 -0
  208. package/dist/translations/ca.js +12 -0
  209. package/dist/translations/cs.d.ts +12 -0
  210. package/dist/translations/cs.js +12 -0
  211. package/dist/translations/da.d.ts +12 -0
  212. package/dist/translations/da.js +12 -0
  213. package/dist/translations/de.d.ts +12 -0
  214. package/dist/translations/de.js +12 -0
  215. package/dist/translations/en.d.ts +12 -0
  216. package/dist/translations/en.js +12 -0
  217. package/dist/translations/es.d.ts +12 -0
  218. package/dist/translations/es.js +12 -0
  219. package/dist/translations/et.d.ts +12 -0
  220. package/dist/translations/et.js +12 -0
  221. package/dist/translations/fa.d.ts +12 -0
  222. package/dist/translations/fa.js +12 -0
  223. package/dist/translations/fr.d.ts +12 -0
  224. package/dist/translations/fr.js +12 -0
  225. package/dist/translations/he.d.ts +12 -0
  226. package/dist/translations/he.js +12 -0
  227. package/dist/translations/hr.d.ts +12 -0
  228. package/dist/translations/hr.js +12 -0
  229. package/dist/translations/hu.d.ts +12 -0
  230. package/dist/translations/hu.js +12 -0
  231. package/dist/translations/hy.d.ts +12 -0
  232. package/dist/translations/hy.js +12 -0
  233. package/dist/translations/id.d.ts +12 -0
  234. package/dist/translations/id.js +12 -0
  235. package/dist/translations/index.d.ts +533 -0
  236. package/dist/translations/index.js +90 -0
  237. package/dist/translations/is.d.ts +12 -0
  238. package/dist/translations/is.js +12 -0
  239. package/dist/translations/it.d.ts +12 -0
  240. package/dist/translations/it.js +12 -0
  241. package/dist/translations/ja.d.ts +12 -0
  242. package/dist/translations/ja.js +12 -0
  243. package/dist/translations/ko.d.ts +12 -0
  244. package/dist/translations/ko.js +12 -0
  245. package/dist/translations/lt.d.ts +12 -0
  246. package/dist/translations/lt.js +12 -0
  247. package/dist/translations/lv.d.ts +12 -0
  248. package/dist/translations/lv.js +12 -0
  249. package/dist/translations/my.d.ts +12 -0
  250. package/dist/translations/my.js +12 -0
  251. package/dist/translations/nb.d.ts +12 -0
  252. package/dist/translations/nb.js +12 -0
  253. package/dist/translations/nl.d.ts +12 -0
  254. package/dist/translations/nl.js +12 -0
  255. package/dist/translations/pl.d.ts +12 -0
  256. package/dist/translations/pl.js +12 -0
  257. package/dist/translations/pt.d.ts +12 -0
  258. package/dist/translations/pt.js +12 -0
  259. package/dist/translations/ro.d.ts +12 -0
  260. package/dist/translations/ro.js +12 -0
  261. package/dist/translations/rs.d.ts +12 -0
  262. package/dist/translations/rs.js +12 -0
  263. package/dist/translations/rsLatin.d.ts +12 -0
  264. package/dist/translations/rsLatin.js +12 -0
  265. package/dist/translations/ru.d.ts +12 -0
  266. package/dist/translations/ru.js +12 -0
  267. package/dist/translations/sk.d.ts +12 -0
  268. package/dist/translations/sk.js +12 -0
  269. package/dist/translations/sl.d.ts +12 -0
  270. package/dist/translations/sl.js +12 -0
  271. package/dist/translations/sv.d.ts +12 -0
  272. package/dist/translations/sv.js +12 -0
  273. package/dist/translations/ta.d.ts +12 -0
  274. package/dist/translations/ta.js +12 -0
  275. package/dist/translations/th.d.ts +12 -0
  276. package/dist/translations/th.js +12 -0
  277. package/dist/translations/tr.d.ts +12 -0
  278. package/dist/translations/tr.js +12 -0
  279. package/dist/translations/uk.d.ts +12 -0
  280. package/dist/translations/uk.js +12 -0
  281. package/dist/translations/vi.d.ts +12 -0
  282. package/dist/translations/vi.js +12 -0
  283. package/dist/translations/zh.d.ts +12 -0
  284. package/dist/translations/zh.js +12 -0
  285. package/dist/translations/zhTw.d.ts +12 -0
  286. package/dist/translations/zhTw.js +12 -0
  287. package/dist/types.d.ts +11 -0
  288. package/dist/utils/assert-never.d.ts +1 -0
  289. package/dist/utils/assert-never.js +3 -0
  290. package/dist/utils/build-detection.d.ts +6 -1
  291. package/dist/utils/build-detection.js +68 -89
  292. package/dist/utils/deploy-adapter.d.ts +3 -35
  293. package/dist/utils/deploy-adapter.js +25 -14
  294. package/dist/utils/env-management.d.ts +15 -0
  295. package/dist/utils/env-management.js +47 -0
  296. package/dist/utils/lambda-config.js +18 -23
  297. package/dist/utils/messages.js +24 -3
  298. package/dist/utils/next-image-loader-config.d.ts +2 -0
  299. package/dist/utils/next-image-loader-config.js +63 -0
  300. package/dist/utils/next-image-loader-file.d.ts +2 -0
  301. package/dist/utils/next-image-loader-file.js +11 -0
  302. package/dist/utils/payload-config-ast.js +5 -2
  303. package/dist/utils/payload-generate.d.ts +10 -0
  304. package/dist/utils/payload-generate.js +59 -0
  305. package/dist/utils/payload-secret.d.ts +28 -0
  306. package/dist/utils/payload-secret.js +34 -0
  307. package/dist/utils/pnpm-builds.d.ts +14 -0
  308. package/dist/utils/pnpm-builds.js +125 -0
  309. package/dist/utils/s3-upload.js +4 -1
  310. package/package.json +33 -7
  311. package/dist/lib/download-skill.d.ts +0 -12
  312. package/dist/lib/download-skill.js +0 -77
  313. package/dist/utils/adapters/nextjs.d.ts +0 -8
  314. package/dist/utils/adapters/nextjs.js +0 -61
  315. package/dist/utils/adapters/nitro.d.ts +0 -8
  316. package/dist/utils/adapters/nitro.js +0 -172
  317. package/dist/utils/adapters/vite.js +0 -31
  318. package/dist/utils/asset-collection.js +0 -144
  319. package/dist/utils/build-lambda-zip.js +0 -90
  320. package/dist/utils/fs-utils.d.ts +0 -12
  321. package/dist/utils/fs-utils.js +0 -55
@@ -1,13 +1,15 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import spawn from 'cross-spawn';
3
+ import path from 'path';
3
4
  import pc from 'picocolors';
4
- import { ControlPlaneError, createDeployment, getBootstrapInfo, performDeployment } from '../api/control-plane.js';
5
+ import { getFileSize } from '../adapters/asset-collection.js';
6
+ import { LAMBDA_MAX_UNZIPPED_BYTES } from '../adapters/build-lambda-zip.js';
7
+ import { createDeployment, getBootstrapInfo, performDeployment } from '../api/control-plane.js';
8
+ import { ControlPlaneError } from '../api/control-plane-error.js';
5
9
  import { tryGetCredential } from '../auth/oauth-flow.js';
6
10
  import { getTokenStore } from '../auth/token-store.js';
7
11
  import { getInfraEnvironment, getProjectNotFoundMessage } from '../constants.js';
8
- import { getFileSize } from '../utils/asset-collection.js';
9
12
  import { detectBuild, getBuildCommand } from '../utils/build-detection.js';
10
- import { LAMBDA_MAX_UNZIPPED_BYTES } from '../utils/build-lambda-zip.js';
11
13
  import { detectAdapter } from '../utils/deploy-adapter.js';
12
14
  import { getEnvVar } from '../utils/env-management.js';
13
15
  import * as log from '../utils/log.js';
@@ -15,7 +17,10 @@ import { getPackageManager } from '../utils/package-manager.js';
15
17
  import { isInProjectDirectory } from '../utils/project.js';
16
18
  import { resolveEnvironment } from '../utils/resolve-environment.js';
17
19
  import { uploadLambdaZip, uploadStaticAssets } from '../utils/s3-upload.js';
20
+ import { detectProjectResourceType } from './detect-project-resource-type.js';
18
21
  import { loginCommand } from './login.js';
22
+ import { promptToCreateProject } from './prompt-to-create-project.js';
23
+ import { writeProjectConfiguration } from './write-project-configuration.js';
19
24
  /**
20
25
  * Format bytes to human-readable string
21
26
  */ function formatBytes(bytes) {
@@ -51,23 +56,14 @@ import { loginCommand } from './login.js';
51
56
  */ export async function deployCommand(options) {
52
57
  const projectPath = process.cwd();
53
58
  const spinner = p.spinner();
54
- // Resolve project ID
55
- let projectId = options.id;
56
- if (!projectId) {
57
- projectId = await getEnvVar(projectPath, 'FIGMA_PROJECT_ID') ?? undefined;
58
- }
59
- if (!projectId) {
60
- p.log.error(pc.red('✗ Project ID not found. Run `@payloadcms/figma init` first, or use --id.'));
61
- process.exit(1);
62
- }
63
59
  // Resolve environment name
64
60
  const environmentName = options.env ?? await getEnvVar(projectPath, 'FIGMA_ENVIRONMENT_NAME') ?? undefined;
65
61
  try {
66
62
  // ===== PRE-FLIGHT CHECKS =====
67
- // Check if in project directory
68
- if (!await isInProjectDirectory(projectPath)) {
69
- p.log.error(pc.red("✗ 'deploy' command is not available outside of a Payload project."));
70
- p.note('Create a project or connect an existing one to Figma: npx @payloadcms/figma init', 'Tip');
63
+ // Building requires package.json, but --skip-build can deploy a prebuilt artifact directly.
64
+ if (!options.skipBuild && !await isInProjectDirectory(projectPath)) {
65
+ p.log.error(pc.red('✗ Cannot build because package.json was not found in this directory.'));
66
+ p.note('Run from a package directory, or deploy prebuilt output with --skip-build --output <path>.', 'Tip');
71
67
  process.exit(1);
72
68
  }
73
69
  // Check authentication
@@ -75,13 +71,38 @@ import { loginCommand } from './login.js';
75
71
  let credential = await tryGetCredential(tokenStore);
76
72
  if (!credential) {
77
73
  p.log.message('Please log in to continue');
78
- await loginCommand();
74
+ await loginCommand({
75
+ openBrowserWithoutPrompt: options.yes
76
+ });
79
77
  credential = await tryGetCredential(tokenStore);
80
78
  if (!credential) {
81
79
  p.log.error(pc.red('✗ Authentication failed'));
82
80
  process.exit(1);
83
81
  }
84
82
  }
83
+ // Resolve or create the CMS project.
84
+ let projectId = options.id;
85
+ if (!projectId) {
86
+ projectId = await getEnvVar(projectPath, 'FIGMA_PROJECT_ID') ?? undefined;
87
+ }
88
+ const isProjectCreated = !projectId;
89
+ if (!projectId) {
90
+ const resourceType = options.adapter === 'vite' ? 'vite' : options.adapter ? 'payload' : await detectProjectResourceType(projectPath);
91
+ const project = await promptToCreateProject({
92
+ credential,
93
+ inputs: {
94
+ name: options.name,
95
+ description: options.description,
96
+ region: options.region,
97
+ subdomain: options.subdomain,
98
+ workspacePlanKey: options.workspace
99
+ },
100
+ nonInteractive: options.yes,
101
+ projectPath,
102
+ resourceType
103
+ });
104
+ projectId = project.id;
105
+ }
85
106
  // Resolve tenant instance ID via bootstrap
86
107
  spinner.start('Resolving deployment target...');
87
108
  let tenantInstanceId;
@@ -92,6 +113,14 @@ import { loginCommand } from './login.js';
92
113
  environments: bootstrapInfo.environments
93
114
  });
94
115
  tenantInstanceId = resolvedEnv.tenantInstanceId;
116
+ await writeProjectConfiguration({
117
+ bootstrapInfo,
118
+ environmentName: resolvedEnv.name,
119
+ projectDir: projectPath,
120
+ projectId,
121
+ shouldWriteEnvironmentVariables: isProjectCreated,
122
+ tokenStore
123
+ });
95
124
  spinner.stop(pc.green(`✓ Target: ${resolvedEnv.name}`));
96
125
  } catch (error) {
97
126
  if (error instanceof ControlPlaneError && (error.statusCode === 404 || error.statusCode === 410)) {
@@ -110,13 +139,18 @@ import { loginCommand } from './login.js';
110
139
  process.env.FIGMA_EXTRACT_SCHEDULES = 'true';
111
140
  // ===== BUILD =====
112
141
  let buildInfo;
142
+ const buildOptions = {
143
+ adapter: options.adapter,
144
+ output: options.output
145
+ };
113
146
  if (options.skipBuild) {
114
147
  // User asserts build exists - verify it
115
148
  spinner.start('Checking for build...');
116
- buildInfo = await detectBuild(projectPath);
149
+ buildInfo = await detectBuild(projectPath, buildOptions);
117
150
  if (!buildInfo) {
118
151
  spinner.stop(pc.red('✗ No build found'));
119
- p.log.error('Use deploy without --skip-build to build first.');
152
+ p.log.error(getMissingBuildMessage(projectPath, options));
153
+ p.note('Use deploy without --skip-build to build first.', 'Tip');
120
154
  process.exit(1);
121
155
  }
122
156
  spinner.stop(pc.green('✓ Build found'));
@@ -182,9 +216,9 @@ import { loginCommand } from './login.js';
182
216
  process.exit(1);
183
217
  }
184
218
  // Verify build output
185
- buildInfo = await detectBuild(projectPath);
219
+ buildInfo = await detectBuild(projectPath, buildOptions);
186
220
  if (!buildInfo) {
187
- p.log.error(pc.red('✗ Build completed but build output not found'));
221
+ p.log.error(pc.red(`✗ ${getMissingBuildMessage(projectPath, options)}`));
188
222
  p.note('Ensure your build produces a valid output directory.', 'Check Build Configuration');
189
223
  process.exit(1);
190
224
  }
@@ -192,12 +226,12 @@ import { loginCommand } from './login.js';
192
226
  // ===== DEPLOYMENT PREPARATION =====
193
227
  // Detect framework adapter
194
228
  spinner.start('Detecting framework...');
195
- const adapter = await detectAdapter(projectPath, options.adapter);
229
+ const adapter = await detectAdapter(projectPath, options.adapter, options.output);
196
230
  spinner.stop(pc.green(`✓ Detected ${adapter.name} adapter`));
197
231
  // Collect pages and assets
198
232
  spinner.start('Collecting assets...');
199
- const pages = await adapter.collectPages(projectPath);
200
- const assets = await adapter.collectAssets(projectPath);
233
+ const pages = await adapter.collectPages(projectPath, options.output);
234
+ const assets = await adapter.collectAssets(projectPath, options.output);
201
235
  spinner.stop(pc.green(`✓ ${pages.routes.length} pages, ${assets.routes.length} assets detected`));
202
236
  // Create deployment package (if server adapter)
203
237
  let zipPath = null;
@@ -205,7 +239,7 @@ import { loginCommand } from './login.js';
205
239
  let unzippedBytes = 0;
206
240
  spinner.start('Creating deployment package...');
207
241
  try {
208
- const bundle = await adapter.prepareLambdaBundle(projectPath);
242
+ const bundle = await adapter.prepareLambdaBundle(projectPath, options.output);
209
243
  if (bundle) {
210
244
  zipPath = bundle.zipPath;
211
245
  unzippedBytes = bundle.unzippedBytes;
@@ -342,3 +376,7 @@ import { loginCommand } from './login.js';
342
376
  process.exit(1);
343
377
  }
344
378
  }
379
+ function getMissingBuildMessage(projectPath, options) {
380
+ const location = options.output ? ` at ${path.resolve(projectPath, options.output)}` : '';
381
+ return options.adapter ? `No ${options.adapter} build found${location}.` : `No supported build found${location}.`;
382
+ }
@@ -0,0 +1,3 @@
1
+ import type { ProjectResourceType } from '../api/project-resource-type.js';
2
+ /** Detect whether project provisioning should use static Vite or Payload infrastructure. */
3
+ export declare function detectProjectResourceType(projectPath?: string): Promise<ProjectResourceType>;
@@ -0,0 +1,28 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ /** Detect whether project provisioning should use static Vite or Payload infrastructure. */ export async function detectProjectResourceType(projectPath = process.cwd()) {
4
+ try {
5
+ const content = await fs.readFile(path.join(projectPath, 'package.json'), 'utf-8');
6
+ const packageJson = JSON.parse(content);
7
+ const dependencies = {
8
+ ...packageJson.dependencies,
9
+ ...packageJson.devDependencies
10
+ };
11
+ if (dependencies.payload) {
12
+ return 'payload';
13
+ }
14
+ if (dependencies.vite || Object.values(packageJson.scripts ?? {}).some((script)=>/\bvite\b/.test(script))) {
15
+ return 'vite';
16
+ }
17
+ } catch (error) {
18
+ if (error.code !== 'ENOENT') {
19
+ return 'payload';
20
+ }
21
+ }
22
+ try {
23
+ await fs.access(path.join(projectPath, 'index.html'));
24
+ return 'vite';
25
+ } catch {
26
+ return 'payload';
27
+ }
28
+ }
@@ -12,8 +12,8 @@ export interface InitCommandOptions {
12
12
  id?: string;
13
13
  /** Project name (for scaffolding) */
14
14
  name?: string;
15
- /** Skip Payload skill installation */
16
- noSkill?: boolean;
15
+ /** Skip writing AI agent config files (AGENTS.md, CLAUDE.md) */
16
+ noAgent?: boolean;
17
17
  /** npm dist-tag or explicit version for core payload packages (e.g. 'canary', 'latest', '4.0.0-canary.16'); defaults to 'canary' */
18
18
  payloadVersion?: string;
19
19
  /** Skip authentication check (for testing/development) */
@@ -2,41 +2,115 @@ import * as p from '@clack/prompts';
2
2
  import fs from 'fs/promises';
3
3
  import path from 'path';
4
4
  import pc from 'picocolors';
5
- import { ControlPlaneError, getBootstrapInfo } from '../api/control-plane.js';
5
+ import { getBootstrapInfo } from '../api/control-plane.js';
6
+ import { ControlPlaneError } from '../api/control-plane-error.js';
6
7
  import { FigmaApiError } from '../api/figma-api.js';
7
8
  import { tryGetCredential } from '../auth/oauth-flow.js';
8
9
  import { getValidProjectToken, ProjectTokenError } from '../auth/project-token.js';
9
10
  import { getTokenStore } from '../auth/token-store.js';
10
11
  import { getInfraEnvironment, getProjectNotFoundMessage } from '../constants.js';
11
- import { downloadSkill } from '../lib/download-skill.js';
12
+ import { writeAgentConfigFiles } from '../lib/write-agent-config.js';
12
13
  import { ensureGitignore } from '../utils/config.js';
13
- import { addOrUpdateEnvVar } from '../utils/env-management.js';
14
+ import { addOrUpdateEnvVar, commentOutEnvVar, removeEnvVar } from '../utils/env-management.js';
14
15
  import { isDebug } from '../utils/is-debug.js';
15
16
  import { applyLambdaModifications } from '../utils/lambda-config.js';
16
17
  import * as log from '../utils/log.js';
17
18
  import { detectPackageManagerFromEnvironment, getRunCommand, resolvePackageManager } from '../utils/package-manager.js';
18
19
  import { displayManualInstructions, ensurePayloadFigmaConfig } from '../utils/payload-config-modifier.js';
20
+ import { generateImportMap, generateTypes } from '../utils/payload-generate.js';
21
+ import { ensurePnpmWorkspace } from '../utils/pnpm-builds.js';
19
22
  import { detectPayloadProject, hasRequiredDependencies, initializeGitRepo, installDependencies, isInProjectDirectory, scaffoldProject, validatePayloadVersion } from '../utils/project.js';
20
23
  import { resolveEnvironment } from '../utils/resolve-environment.js';
21
24
  import { checkForUpdates, getOwnVersion } from '../utils/version-check.js';
25
+ import { detectProjectResourceType } from './detect-project-resource-type.js';
22
26
  import { loginCommand } from './login.js';
27
+ import { promptToCreateProject } from './prompt-to-create-project.js';
28
+ import { writeProjectConfiguration } from './write-project-configuration.js';
23
29
  import { cacheAllEnvironments } from '../utils/cache-bootstrap.js';
24
30
  import { DEFAULT_TEMPLATE_SOURCE } from '../utils/download-template.js';
25
31
  import { parseTemplateSpec, TemplateSpecParseError } from '../utils/parse-template-spec.js';
26
- async function maybeInstallPayloadSkill(args) {
27
- if (args.noSkill) {
32
+ import { ensurePayloadSecret } from '../utils/payload-secret.js';
33
+ async function removePayloadSecretFromEnv(projectDir) {
34
+ // New-project flow: the scaffold owns .env, so any PAYLOAD_SECRET carried
35
+ // over from a template is not a value the developer set. Remove it
36
+ // outright to keep the scaffolded file clean.
37
+ const removed = await removeEnvVar(projectDir, 'PAYLOAD_SECRET');
38
+ if (!removed) {
28
39
  return;
29
40
  }
30
- const result = await downloadSkill({
31
- projectDir: args.projectDir
32
- });
33
- if (result.ok) {
41
+ p.log.warn(pc.yellow('⚠ Removed PAYLOAD_SECRET from .env. The Figma platform owns this value; a local ' + 'copy would silently diverge from the deployed secret and cause encrypted data ' + '(API keys, auth tokens) to fail decryption in production.'));
42
+ }
43
+ async function commentOutPayloadSecretInEnv(projectDir) {
44
+ // Existing-project flow: the developer's .env may hold a PAYLOAD_SECRET
45
+ // they need for another system or environment. Comment out rather than
46
+ // delete so the value survives and they can uncomment / relocate it.
47
+ const changed = await commentOutEnvVar(projectDir, 'PAYLOAD_SECRET', 'disabled by @payloadcms/figma: platform owns PAYLOAD_SECRET');
48
+ if (!changed) {
34
49
  return;
35
50
  }
36
- if (result.reason === 'already-installed') {
51
+ p.log.warn(pc.yellow('⚠ Commented out PAYLOAD_SECRET in .env. The Figma platform owns this value; a ' + 'local copy would silently diverge from the deployed secret and cause encrypted ' + 'data (API keys, auth tokens) to fail decryption in production.'));
52
+ }
53
+ async function maybeEnsurePayloadSecret(args) {
54
+ if (!args.credential || !args.resolvedEnv) {
55
+ return false;
56
+ }
57
+ try {
58
+ await ensurePayloadSecret({
59
+ credential: args.credential,
60
+ projectInfo: {
61
+ environmentName: args.resolvedEnv.name,
62
+ projectId: args.cmsResourceId
63
+ },
64
+ tenantInstanceId: args.resolvedEnv.tenantInstanceId,
65
+ tokenStore: args.tokenStore,
66
+ // Re-init is the explicit recovery path after platform secret rotation.
67
+ refresh: true
68
+ });
69
+ log.debug('PAYLOAD_SECRET cached in TokenStore');
70
+ return true;
71
+ } catch (err) {
72
+ // Preserve the existing cache and .env fallback until a refresh succeeds.
73
+ const message = err instanceof Error ? err.message : 'Unknown error';
74
+ p.log.warn(pc.yellow(`⚠ Could not fetch PAYLOAD_SECRET (${message}). Existing secrets were preserved. Re-run init to retry.`));
75
+ return false;
76
+ }
77
+ }
78
+ async function maybeWriteAgentConfigFiles(args) {
79
+ if (args.noAgent) {
37
80
  return;
38
81
  }
39
- p.log.warn(pc.yellow(`⚠ Could not install Payload skill (${result.reason}${result.detail ? `: ${result.detail}` : ''}). Continuing.`));
82
+ try {
83
+ await writeAgentConfigFiles({
84
+ projectDir: args.projectDir
85
+ });
86
+ } catch (err) {
87
+ p.log.warn(pc.yellow(`⚠ Could not write AI agent config (${err instanceof Error ? err.message : String(err)}). Continuing.`));
88
+ }
89
+ }
90
+ /** Generate the admin import map and Payload types so the scaffold builds clean. */ async function runProjectCodegen(args) {
91
+ await runPayloadGenerate({
92
+ ...args,
93
+ artifact: 'import map',
94
+ command: 'generate:importmap',
95
+ generate: generateImportMap
96
+ });
97
+ await runPayloadGenerate({
98
+ ...args,
99
+ artifact: 'types',
100
+ command: 'generate:types',
101
+ generate: generateTypes
102
+ });
103
+ }
104
+ /** Non-fatal: on failure, warn with the command to run later. */ async function runPayloadGenerate(args) {
105
+ args.spinner.start(`Generating ${args.artifact}...`);
106
+ const result = await args.generate(args.projectDir);
107
+ const capitalized = args.artifact.charAt(0).toUpperCase() + args.artifact.slice(1);
108
+ if (result.ok) {
109
+ args.spinner.stop(pc.green(`✓ ${capitalized} generated`));
110
+ return;
111
+ }
112
+ args.spinner.stop(pc.yellow(`⚠ Could not generate ${args.artifact}`));
113
+ p.log.warn(pc.yellow(`Run '${getRunCommand(args.packageManager)} ${args.command}' later. ${result.error}`));
40
114
  }
41
115
  /**
42
116
  * Generate and store project token for a content system
@@ -94,6 +168,7 @@ async function maybeInstallPayloadSkill(args) {
94
168
  // Check authentication
95
169
  const tokenStore = getTokenStore();
96
170
  const s = p.spinner();
171
+ let credential = null;
97
172
  if (options.skipAuth) {
98
173
  // Skip authentication for testing/development
99
174
  p.log.warn(pc.yellow('Skipping authentication (--skip-auth mode)'));
@@ -102,14 +177,14 @@ async function maybeInstallPayloadSkill(args) {
102
177
  if (!tokenStore.hasValidOauthToken()) {
103
178
  // Need to refresh or authenticate - show spinner for API call
104
179
  s.start('Checking authentication...');
105
- const credential = await tryGetCredential(tokenStore);
180
+ credential = await tryGetCredential(tokenStore);
106
181
  if (!credential) {
107
182
  s.stop('Authentication required to continue');
108
183
  await loginCommand({
109
184
  showNextSteps: false
110
185
  });
111
- const newCredential = await tryGetCredential(tokenStore);
112
- if (!newCredential) {
186
+ credential = await tryGetCredential(tokenStore);
187
+ if (!credential) {
113
188
  p.log.error('Authentication failed');
114
189
  process.exit(1);
115
190
  }
@@ -118,16 +193,12 @@ async function maybeInstallPayloadSkill(args) {
118
193
  }
119
194
  }
120
195
  }
196
+ if (!options.skipAuth && !credential) {
197
+ credential = await tryGetCredential(tokenStore);
198
+ }
121
199
  // Note: We no longer check for figma.config.json here
122
200
  // Instead, the AST detection will check if figma object already exists in payload.config.ts
123
201
  // and skip modification if it does (unless --force is used)
124
- // Step 3: Get CMS Resource ID (required argument)
125
- log.debug('Configuring Project...');
126
- if (!options.id) {
127
- p.log.error('CMS Resource ID is required. Use --id <cms-resource-id>');
128
- process.exit(1);
129
- }
130
- const cmsResourceId = options.id;
131
202
  // Parse --template spec early so malformed values abort before any I/O
132
203
  let templateSource;
133
204
  if (options.template) {
@@ -140,13 +211,95 @@ async function maybeInstallPayloadSkill(args) {
140
211
  process.exit(1);
141
212
  }
142
213
  }
214
+ // Step 3: Resolve or create the CMS project
215
+ log.debug('Configuring Project...');
216
+ const hasPackageJson = await isInProjectDirectory();
217
+ const resourceType = await detectProjectResourceType();
218
+ const isInProject = hasPackageJson || resourceType === 'vite';
219
+ let projectDirectory = process.cwd();
220
+ if (isInProject && resourceType !== 'vite' && !options.id) {
221
+ const projectInfo = await detectPayloadProject();
222
+ if (!projectInfo.hasPayload) {
223
+ p.log.warn(pc.yellow('⚠ Payload was not detected in this project'));
224
+ p.note('Run this command in a directory without an existing project or in an existing Payload project.', 'Action Required');
225
+ process.exit(1);
226
+ }
227
+ if (projectInfo.payloadVersion && !validatePayloadVersion(projectInfo.payloadVersion)) {
228
+ p.log.warn(pc.yellow(`Payload version ${projectInfo.payloadVersion} detected. Version 4.x or newer is required.`));
229
+ p.note('Upgrade to Payload 4.x or newer before continuing', 'Action Required');
230
+ process.exit(1);
231
+ }
232
+ }
233
+ if (!isInProject) {
234
+ let projectPath;
235
+ if (options.name) {
236
+ projectPath = options.name;
237
+ } else {
238
+ const projectPathInput = await p.text({
239
+ initialValue: './',
240
+ message: 'Enter path to create project:',
241
+ placeholder: './my-cms-project',
242
+ validate: (value)=>{
243
+ if (!value) {
244
+ return 'Path is required';
245
+ }
246
+ return undefined;
247
+ }
248
+ });
249
+ if (p.isCancel(projectPathInput)) {
250
+ p.cancel('Operation cancelled');
251
+ process.exit(0);
252
+ }
253
+ projectPath = projectPathInput;
254
+ }
255
+ projectDirectory = path.resolve(process.cwd(), projectPath);
256
+ const projectName = path.basename(projectDirectory);
257
+ const packageManager = detectPackageManagerFromEnvironment();
258
+ try {
259
+ await fs.mkdir(projectDirectory, {
260
+ recursive: true
261
+ });
262
+ } catch (error) {
263
+ p.log.error(`Failed to create directory: ${error instanceof Error ? error.message : 'Unknown error'}`);
264
+ process.exit(1);
265
+ }
266
+ const resolvedSource = {
267
+ ...DEFAULT_TEMPLATE_SOURCE,
268
+ ...templateSource
269
+ };
270
+ s.start(`Downloading template "${resolvedSource.templatePath}" from ` + `${resolvedSource.owner}/${resolvedSource.repo}@${resolvedSource.ref}...`);
271
+ try {
272
+ await scaffoldProject(projectDirectory, projectName, packageManager, templateSource, options.payloadVersion);
273
+ s.stop(pc.green('✓ Template downloaded'));
274
+ s.start('Installing dependencies...');
275
+ await installDependencies(projectDirectory, packageManager);
276
+ s.stop(pc.green('✓ Dependencies installed'));
277
+ } catch (error) {
278
+ s.stop(pc.red('✗ Failed'));
279
+ log.error(error instanceof Error ? error.message : 'Unknown error');
280
+ process.exit(1);
281
+ }
282
+ }
283
+ let cmsResourceId = options.id;
284
+ if (!cmsResourceId) {
285
+ if (!credential) {
286
+ p.log.error('Authentication is required to create a project');
287
+ process.exit(1);
288
+ }
289
+ const createdProject = await promptToCreateProject({
290
+ credential,
291
+ projectPath: projectDirectory,
292
+ resourceType
293
+ });
294
+ cmsResourceId = createdProject.id;
295
+ await addOrUpdateEnvVar(projectDirectory, 'FIGMA_PROJECT_ID', cmsResourceId);
296
+ }
143
297
  // Fetch bootstrap info (oauth creds + environments)
144
298
  let bootstrapInfo = null;
145
299
  let resolvedEnv = null;
146
300
  let oauthClientId = null;
147
301
  let oauthClientSecret = null;
148
302
  if (!options.skipAuth) {
149
- const credential = await tryGetCredential(tokenStore);
150
303
  if (credential) {
151
304
  try {
152
305
  bootstrapInfo = await getBootstrapInfo(credential, cmsResourceId);
@@ -178,8 +331,29 @@ async function maybeInstallPayloadSkill(args) {
178
331
  }
179
332
  }
180
333
  }
181
- // Step 4: Detect or scaffold Payload project
182
- const isInProject = await isInProjectDirectory();
334
+ // Step 4: Detect or scaffold project
335
+ if (isInProject && resourceType === 'vite') {
336
+ try {
337
+ await writeProjectConfiguration({
338
+ bootstrapInfo,
339
+ environmentName: resolvedEnv?.name ?? 'production',
340
+ projectDir: process.cwd(),
341
+ projectId: cmsResourceId,
342
+ tokenStore
343
+ });
344
+ } catch (error) {
345
+ p.log.error(error instanceof Error ? error.message : 'Failed to configure project');
346
+ process.exit(1);
347
+ }
348
+ await maybeEnsurePayloadSecret({
349
+ cmsResourceId,
350
+ credential,
351
+ resolvedEnv,
352
+ tokenStore
353
+ });
354
+ p.outro(pc.green('✓ Vite project initialized successfully!'));
355
+ return;
356
+ }
183
357
  if (isInProject) {
184
358
  // ===== EXISTING PROJECT FLOW =====
185
359
  log.debug('Project directory detected');
@@ -194,6 +368,9 @@ async function maybeInstallPayloadSkill(args) {
194
368
  process.exit(1);
195
369
  }
196
370
  p.log.success(pc.green(`✓ Payload ${projectInfo.payloadVersion || 'detected'}`));
371
+ // Approvals must exist before any install: pnpm v11 aborts on unapproved
372
+ // build scripts, and re-init runs against an existing install.
373
+ await ensurePnpmWorkspace(process.cwd());
197
374
  // Check dependencies
198
375
  s.start('Checking dependencies...');
199
376
  const hasDeps = await hasRequiredDependencies(process.cwd());
@@ -249,6 +426,15 @@ async function maybeInstallPayloadSkill(args) {
249
426
  } catch (error) {
250
427
  p.log.warn(pc.yellow(`⚠ Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`));
251
428
  }
429
+ const secretCached = await maybeEnsurePayloadSecret({
430
+ cmsResourceId,
431
+ credential,
432
+ resolvedEnv,
433
+ tokenStore
434
+ });
435
+ if (secretCached) {
436
+ await commentOutPayloadSecretInEnv(process.cwd());
437
+ }
252
438
  } else {
253
439
  p.log.warn(pc.yellow('⚠ Payload was not detected in this project'));
254
440
  p.note('Run this command in a directory without an existing project or in an existing Payload project.', 'Action Required');
@@ -266,7 +452,7 @@ async function maybeInstallPayloadSkill(args) {
266
452
  log.error(error instanceof Error ? error.message : 'Unknown error');
267
453
  process.exit(1);
268
454
  }
269
- // Apply Lambda modifications (run.sh, standalone output, lambda:buildzip script)
455
+ // Apply Lambda modifications (run.sh, Next.js config, lambda:buildzip script)
270
456
  await applyLambdaModifications(process.cwd(), packageManager);
271
457
  // Ensure .gitignore has required entries
272
458
  await ensureGitignore(process.cwd(), [
@@ -274,8 +460,13 @@ async function maybeInstallPayloadSkill(args) {
274
460
  '.env.local',
275
461
  'lambda.zip'
276
462
  ]);
277
- await maybeInstallPayloadSkill({
278
- noSkill: options.noSkill,
463
+ await runProjectCodegen({
464
+ packageManager,
465
+ projectDir: process.cwd(),
466
+ spinner: s
467
+ });
468
+ await maybeWriteAgentConfigFiles({
469
+ noAgent: options.noAgent,
279
470
  projectDir: process.cwd()
280
471
  });
281
472
  // Generate project token (unless skipping auth)
@@ -293,58 +484,8 @@ async function maybeInstallPayloadSkill(args) {
293
484
  p.note(nextSteps.join('\n'), 'Next Steps');
294
485
  } else {
295
486
  // ===== NEW PROJECT FLOW =====
296
- // p.log.info('No project detected - Creating New Project')
297
- let projectPath;
298
- if (options.name) {
299
- projectPath = options.name;
300
- } else {
301
- const projectPathInput = await p.text({
302
- initialValue: './',
303
- message: 'Enter path to create project:',
304
- placeholder: './my-cms-project',
305
- validate: (value)=>{
306
- if (!value) {
307
- return 'Path is required';
308
- }
309
- // Allow relative or absolute paths
310
- return undefined;
311
- }
312
- });
313
- if (p.isCancel(projectPathInput)) {
314
- p.cancel('Operation cancelled');
315
- process.exit(0);
316
- }
317
- projectPath = projectPathInput;
318
- }
319
- const fullPath = path.resolve(process.cwd(), projectPath);
320
- const projectName = path.basename(fullPath);
487
+ const fullPath = projectDirectory;
321
488
  const packageManager = detectPackageManagerFromEnvironment();
322
- // Create directory
323
- try {
324
- await fs.mkdir(fullPath, {
325
- recursive: true
326
- });
327
- } catch (error) {
328
- p.log.error(`Failed to create directory: ${error instanceof Error ? error.message : 'Unknown error'}`);
329
- process.exit(1);
330
- }
331
- // Scaffold project
332
- const resolvedSource = {
333
- ...DEFAULT_TEMPLATE_SOURCE,
334
- ...templateSource
335
- };
336
- s.start(`Downloading template "${resolvedSource.templatePath}" from ` + `${resolvedSource.owner}/${resolvedSource.repo}@${resolvedSource.ref}...`);
337
- try {
338
- await scaffoldProject(fullPath, projectName, packageManager, templateSource, options.payloadVersion);
339
- s.stop(pc.green('✓ Template downloaded'));
340
- s.start('Installing dependencies...');
341
- await installDependencies(fullPath, packageManager);
342
- s.stop(pc.green('✓ Dependencies installed'));
343
- } catch (error) {
344
- s.stop(pc.red('✗ Failed'));
345
- log.error(error instanceof Error ? error.message : 'Unknown error');
346
- process.exit(1);
347
- }
348
489
  // Modify Payload configuration
349
490
  s.start('Checking Payload configuration...');
350
491
  const modResult = await ensurePayloadFigmaConfig(fullPath, packageManager, {
@@ -386,6 +527,15 @@ async function maybeInstallPayloadSkill(args) {
386
527
  } catch (error) {
387
528
  p.log.warn(pc.yellow(`⚠ Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`));
388
529
  }
530
+ const secretCached = await maybeEnsurePayloadSecret({
531
+ cmsResourceId,
532
+ credential,
533
+ resolvedEnv,
534
+ tokenStore
535
+ });
536
+ if (secretCached) {
537
+ await removePayloadSecretFromEnv(fullPath);
538
+ }
389
539
  // npm leaves node_modules in a transient state after a sequence of
390
540
  // add/remove calls; a final install reconciles it so the project is
391
541
  // immediately buildable.
@@ -398,8 +548,13 @@ async function maybeInstallPayloadSkill(args) {
398
548
  log.error(error instanceof Error ? error.message : 'Unknown error');
399
549
  process.exit(1);
400
550
  }
401
- await maybeInstallPayloadSkill({
402
- noSkill: options.noSkill,
551
+ await runProjectCodegen({
552
+ packageManager,
553
+ projectDir: fullPath,
554
+ spinner: s
555
+ });
556
+ await maybeWriteAgentConfigFiles({
557
+ noAgent: options.noAgent,
403
558
  projectDir: fullPath
404
559
  });
405
560
  // Generate project token (unless skipping auth)