@payloadcms/figma 0.0.1-alpha.8 → 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (470) hide show
  1. package/dist/api/control-plane.d.ts +56 -7
  2. package/dist/api/control-plane.js +188 -74
  3. package/dist/api/error-response.d.ts +36 -0
  4. package/dist/api/error-response.js +66 -0
  5. package/dist/api/figma-api.d.ts +24 -3
  6. package/dist/api/figma-api.js +110 -34
  7. package/dist/auth/browser.d.ts +0 -1
  8. package/dist/auth/browser.js +0 -2
  9. package/dist/auth/callback-server.d.ts +19 -8
  10. package/dist/auth/callback-server.js +72 -32
  11. package/dist/auth/credentials.d.ts +20 -0
  12. package/dist/auth/credentials.js +19 -0
  13. package/dist/auth/crypto-utils.d.ts +28 -1
  14. package/dist/auth/crypto-utils.js +132 -23
  15. package/dist/auth/jwt-validator.d.ts +23 -6
  16. package/dist/auth/jwt-validator.js +35 -9
  17. package/dist/auth/oauth-flow.d.ts +19 -4
  18. package/dist/auth/oauth-flow.js +151 -34
  19. package/dist/auth/paste-code.d.ts +33 -0
  20. package/dist/auth/paste-code.js +87 -0
  21. package/dist/auth/pkce.d.ts +0 -1
  22. package/dist/auth/pkce.js +0 -2
  23. package/dist/auth/project-token.d.ts +32 -17
  24. package/dist/auth/project-token.js +176 -68
  25. package/dist/auth/refresh.d.ts +2 -2
  26. package/dist/auth/refresh.js +25 -14
  27. package/dist/auth/token-store-migration.d.ts +57 -0
  28. package/dist/auth/token-store-migration.js +154 -0
  29. package/dist/auth/token-store.d.ts +63 -98
  30. package/dist/auth/token-store.js +405 -124
  31. package/dist/auth/types.d.ts +40 -6
  32. package/dist/auth/types.js +1 -3
  33. package/dist/cli.d.ts +0 -1
  34. package/dist/cli.js +102 -8
  35. package/dist/commands/bootstrap.d.ts +17 -0
  36. package/dist/commands/bootstrap.js +88 -0
  37. package/dist/commands/build-lambda-zip.d.ts +4 -0
  38. package/dist/commands/build-lambda-zip.js +17 -0
  39. package/dist/commands/debug.d.ts +7 -0
  40. package/dist/commands/debug.js +178 -0
  41. package/dist/commands/deploy.d.ts +11 -1
  42. package/dist/commands/deploy.js +193 -153
  43. package/dist/commands/dump-tokens.d.ts +11 -0
  44. package/dist/commands/dump-tokens.js +67 -0
  45. package/dist/commands/env.d.ts +12 -0
  46. package/dist/commands/env.js +86 -0
  47. package/dist/commands/init.d.ts +9 -6
  48. package/dist/commands/init.js +232 -152
  49. package/dist/commands/list-tokens.d.ts +3 -4
  50. package/dist/commands/list-tokens.js +24 -11
  51. package/dist/commands/login.d.ts +8 -2
  52. package/dist/commands/login.js +34 -18
  53. package/dist/commands/logout.d.ts +5 -5
  54. package/dist/commands/logout.js +77 -17
  55. package/dist/commands/upgrade.d.ts +4 -0
  56. package/dist/commands/upgrade.js +329 -0
  57. package/dist/commands/upload-schema.d.ts +8 -0
  58. package/dist/commands/upload-schema.js +91 -0
  59. package/dist/config/oauth.d.ts +17 -12
  60. package/dist/config/oauth.js +38 -39
  61. package/dist/constants.d.ts +63 -19
  62. package/dist/constants.js +158 -20
  63. package/dist/db-content-api/generated/content-api-types.d.ts +7574 -0
  64. package/dist/db-content-api/generated/content-api-types.js +5 -0
  65. package/dist/db-content-api/index.d.ts +37 -0
  66. package/dist/db-content-api/index.js +938 -0
  67. package/dist/db-content-api/temp-utilities/slug.d.ts +1 -0
  68. package/dist/db-content-api/temp-utilities/slug.js +1 -0
  69. package/dist/db-content-api/temp-utilities/sorting.d.ts +2 -0
  70. package/dist/db-content-api/temp-utilities/sorting.js +37 -0
  71. package/dist/db-content-api/temp-utilities/types.d.ts +21 -0
  72. package/dist/db-content-api/temp-utilities/types.js +13 -0
  73. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +38 -0
  74. package/dist/db-content-api/temp-utilities/unwrapDocument.js +62 -0
  75. package/dist/db-content-api/utilities/auth.d.ts +29 -0
  76. package/dist/db-content-api/utilities/auth.js +82 -0
  77. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +6 -0
  78. package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
  79. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +10 -0
  80. package/dist/db-content-api/utilities/data/castFieldValue.js +66 -0
  81. package/dist/db-content-api/utilities/data/index.d.ts +48 -0
  82. package/dist/db-content-api/utilities/data/index.js +299 -0
  83. package/dist/db-content-api/utilities/data/pointShape.d.ts +3 -0
  84. package/dist/db-content-api/utilities/data/pointShape.js +43 -0
  85. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +11 -0
  86. package/dist/db-content-api/utilities/data/removeVirtualFields.js +52 -0
  87. package/dist/db-content-api/utilities/data/richTextShape.d.ts +3 -0
  88. package/dist/db-content-api/utilities/data/richTextShape.js +56 -0
  89. package/dist/db-content-api/utilities/data/stripFields.d.ts +47 -0
  90. package/dist/db-content-api/utilities/data/stripFields.js +170 -0
  91. package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +22 -0
  92. package/dist/db-content-api/utilities/data/transformPublishedLocale.js +40 -0
  93. package/dist/db-content-api/utilities/data/validateRelationships.d.ts +6 -0
  94. package/dist/db-content-api/utilities/data/validateRelationships.js +100 -0
  95. package/dist/db-content-api/utilities/joins.d.ts +52 -0
  96. package/dist/db-content-api/utilities/joins.js +137 -0
  97. package/dist/db-content-api/utilities/locale/index.d.ts +9 -0
  98. package/dist/db-content-api/utilities/locale/index.js +19 -0
  99. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +10 -0
  100. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +71 -0
  101. package/dist/db-content-api/utilities/meta/buildMeta.d.ts +41 -0
  102. package/dist/db-content-api/utilities/meta/buildMeta.js +39 -0
  103. package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +16 -0
  104. package/dist/db-content-api/utilities/meta/buildPathTypes.js +243 -0
  105. package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +12 -0
  106. package/dist/db-content-api/utilities/meta/buildUniquePaths.js +60 -0
  107. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +9 -0
  108. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +100 -0
  109. package/dist/db-content-api/utilities/resolveBlocks.d.ts +19 -0
  110. package/dist/db-content-api/utilities/resolveBlocks.js +31 -0
  111. package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +55 -0
  112. package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +182 -0
  113. package/dist/db-content-api/utilities/where.d.ts +19 -0
  114. package/dist/db-content-api/utilities/where.js +106 -0
  115. package/dist/deploy/schedule-extract-plugin.d.ts +10 -0
  116. package/dist/deploy/schedule-extract-plugin.js +32 -0
  117. package/dist/endpoints/health.d.ts +2 -0
  118. package/dist/endpoints/health.js +9 -0
  119. package/dist/endpoints/schema.d.ts +2 -0
  120. package/dist/endpoints/schema.js +27 -0
  121. package/dist/exports/client.d.ts +2 -1
  122. package/dist/exports/client.js +2 -2
  123. package/dist/index.d.ts +2 -2
  124. package/dist/index.js +3 -3
  125. package/dist/lib/download-skill.d.ts +12 -0
  126. package/dist/lib/download-skill.js +77 -0
  127. package/dist/oauth/components/FigmaAvatar/index.d.ts +3 -0
  128. package/dist/oauth/components/FigmaAvatar/index.js +25 -0
  129. package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
  130. package/dist/oauth/components/FigmaAvatarCell/index.d.ts +4 -0
  131. package/dist/oauth/components/FigmaAvatarCell/index.js +23 -0
  132. package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
  133. package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +8 -0
  134. package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +35 -0
  135. package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
  136. package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +81 -0
  137. package/dist/oauth/components/LoginButton/iframeAutoLogin.js +168 -0
  138. package/dist/oauth/components/LoginButton/index.d.ts +0 -1
  139. package/dist/oauth/components/LoginButton/index.js +156 -18
  140. package/dist/oauth/components/LoginButton/index.scss +75 -3
  141. package/dist/oauth/components/LogoutButton/index.d.ts +0 -1
  142. package/dist/oauth/components/LogoutButton/index.js +20 -9
  143. package/dist/oauth/defaults.d.ts +3 -2
  144. package/dist/oauth/defaults.js +79 -12
  145. package/dist/oauth/endpoints/getLoginEndpoint.d.ts +0 -1
  146. package/dist/oauth/endpoints/getLoginEndpoint.js +87 -84
  147. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +0 -1
  148. package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -6
  149. package/dist/oauth/endpoints/getMetaEndpoint.d.ts +0 -1
  150. package/dist/oauth/endpoints/getMetaEndpoint.js +18 -5
  151. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +0 -1
  152. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -4
  153. package/dist/oauth/exports/client.d.ts +0 -1
  154. package/dist/oauth/exports/client.js +0 -2
  155. package/dist/oauth/hooks/afterLogout.d.ts +0 -1
  156. package/dist/oauth/hooks/afterLogout.js +0 -2
  157. package/dist/oauth/hooks/me.d.ts +0 -1
  158. package/dist/oauth/hooks/me.js +0 -2
  159. package/dist/oauth/hooks/refresh.d.ts +0 -1
  160. package/dist/oauth/hooks/refresh.js +2 -3
  161. package/dist/oauth/index.d.ts +0 -1
  162. package/dist/oauth/index.js +27 -7
  163. package/dist/oauth/strategy/index.d.ts +0 -3
  164. package/dist/oauth/strategy/index.js +55 -34
  165. package/dist/oauth/types.d.ts +23 -7
  166. package/dist/oauth/types.js +0 -2
  167. package/dist/oauth/utilities/buildUnauthorizedRedirect.d.ts +14 -0
  168. package/dist/oauth/utilities/buildUnauthorizedRedirect.js +28 -0
  169. package/dist/oauth/utilities/clearCookie.d.ts +0 -1
  170. package/dist/oauth/utilities/clearCookie.js +5 -3
  171. package/dist/oauth/utilities/createCookieOptions.d.ts +0 -1
  172. package/dist/oauth/utilities/createCookieOptions.js +9 -4
  173. package/dist/oauth/utilities/createDebugLogger.d.ts +0 -1
  174. package/dist/oauth/utilities/createDebugLogger.js +0 -2
  175. package/dist/oauth/utilities/establishSession.d.ts +22 -0
  176. package/dist/oauth/utilities/establishSession.js +80 -0
  177. package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +23 -0
  178. package/dist/oauth/utilities/exchangeCodeForAccessToken.js +26 -0
  179. package/dist/oauth/utilities/extractOrigin.d.ts +0 -1
  180. package/dist/oauth/utilities/extractOrigin.js +0 -2
  181. package/dist/oauth/utilities/figmaHostnames.d.ts +2 -0
  182. package/dist/oauth/utilities/figmaHostnames.js +24 -0
  183. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +0 -1
  184. package/dist/oauth/utilities/getAdminCollectionSlug.js +0 -2
  185. package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -2
  186. package/dist/oauth/utilities/getAuthorizeURL.js +57 -4
  187. package/dist/oauth/utilities/getCookieExpiration.d.ts +0 -1
  188. package/dist/oauth/utilities/getCookieExpiration.js +0 -2
  189. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +0 -1
  190. package/dist/oauth/utilities/getSecondsFromTokenExp.js +0 -2
  191. package/dist/oauth/utilities/getTokenExp.d.ts +0 -1
  192. package/dist/oauth/utilities/getTokenExp.js +0 -2
  193. package/dist/oauth/utilities/getUsernameField.d.ts +0 -1
  194. package/dist/oauth/utilities/getUsernameField.js +0 -2
  195. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +0 -1
  196. package/dist/oauth/utilities/hasUserTokenPropsChanged.js +0 -2
  197. package/dist/oauth/utilities/isAbsoluteURL.d.ts +1 -0
  198. package/dist/oauth/utilities/isAbsoluteURL.js +1 -0
  199. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +6 -0
  200. package/dist/oauth/utilities/isDuplicateKeyError.js +12 -0
  201. package/dist/oauth/utilities/mergeHeaders.d.ts +0 -1
  202. package/dist/oauth/utilities/mergeHeaders.js +0 -2
  203. package/dist/oauth/utilities/refreshTokens.d.ts +0 -1
  204. package/dist/oauth/utilities/refreshTokens.js +21 -13
  205. package/dist/oauth/utilities/withPartitionedCookie.d.ts +19 -0
  206. package/dist/oauth/utilities/withPartitionedCookie.js +26 -0
  207. package/dist/oauth/utils/getSearchParam.d.ts +17 -0
  208. package/dist/oauth/utils/getSearchParam.js +22 -0
  209. package/dist/plugin/adapter.d.ts +0 -1
  210. package/dist/plugin/adapter.js +0 -2
  211. package/dist/plugin/auth-preflight.d.ts +7 -0
  212. package/dist/plugin/auth-preflight.js +18 -0
  213. package/dist/plugin/bootstrap-preflight.d.ts +22 -0
  214. package/dist/plugin/bootstrap-preflight.js +43 -0
  215. package/dist/plugin/build-config.d.ts +27 -15
  216. package/dist/plugin/build-config.js +381 -18
  217. package/dist/plugin/dev-cookie-names.d.ts +13 -0
  218. package/dist/plugin/dev-cookie-names.js +17 -0
  219. package/dist/scss.d.js +2 -0
  220. package/dist/storage-content-api/api-types.d.ts +183 -0
  221. package/dist/storage-content-api/api-types.js +4 -0
  222. package/dist/storage-content-api/client-uploads/generate.d.ts +14 -0
  223. package/dist/storage-content-api/client-uploads/generate.js +69 -0
  224. package/dist/storage-content-api/client.d.ts +5 -0
  225. package/dist/storage-content-api/client.js +37 -0
  226. package/dist/storage-content-api/generateURL.d.ts +6 -0
  227. package/dist/storage-content-api/generateURL.js +6 -0
  228. package/dist/storage-content-api/handleDelete.d.ts +7 -0
  229. package/dist/storage-content-api/handleDelete.js +15 -0
  230. package/dist/storage-content-api/handleUpload.d.ts +10 -0
  231. package/dist/storage-content-api/handleUpload.js +162 -0
  232. package/dist/storage-content-api/index.d.ts +4 -0
  233. package/dist/storage-content-api/index.js +37 -0
  234. package/dist/storage-content-api/staticHandler.d.ts +9 -0
  235. package/dist/storage-content-api/staticHandler.js +61 -0
  236. package/dist/storage-content-api/types.d.ts +9 -0
  237. package/dist/storage-content-api/types.js +1 -0
  238. package/dist/storage-content-api/utilities/getSafeFilename.d.ts +11 -0
  239. package/dist/storage-content-api/utilities/getSafeFilename.js +59 -0
  240. package/dist/storage-content-api/utilities/index.d.ts +2 -0
  241. package/dist/storage-content-api/utilities/index.js +2 -0
  242. package/dist/storage-content-api/utilities/parseUploadReference.d.ts +17 -0
  243. package/dist/storage-content-api/utilities/parseUploadReference.js +27 -0
  244. package/dist/templates/.env.example +5 -0
  245. package/dist/templates/README.md +19 -0
  246. package/dist/types/config.d.ts +2 -2
  247. package/dist/types/config.js +0 -4
  248. package/dist/types.d.ts +10 -2
  249. package/dist/types.js +0 -2
  250. package/dist/utils/adapters/nextjs.d.ts +8 -0
  251. package/dist/utils/adapters/nextjs.js +61 -0
  252. package/dist/utils/adapters/nitro.d.ts +8 -0
  253. package/dist/utils/adapters/nitro.js +172 -0
  254. package/dist/utils/adapters/vite.d.ts +9 -0
  255. package/dist/utils/adapters/vite.js +31 -0
  256. package/dist/utils/asset-collection.d.ts +27 -7
  257. package/dist/utils/asset-collection.js +59 -32
  258. package/dist/utils/build-detection.d.ts +5 -12
  259. package/dist/utils/build-detection.js +74 -13
  260. package/dist/utils/build-lambda-zip.d.ts +25 -0
  261. package/dist/utils/build-lambda-zip.js +90 -0
  262. package/dist/utils/cache-bootstrap.d.ts +7 -0
  263. package/dist/utils/cache-bootstrap.js +16 -0
  264. package/dist/utils/config.d.ts +0 -1
  265. package/dist/utils/config.js +1 -3
  266. package/dist/utils/deploy-adapter.d.ts +45 -0
  267. package/dist/utils/deploy-adapter.js +56 -0
  268. package/dist/utils/download-template.d.ts +9 -2
  269. package/dist/utils/download-template.js +24 -20
  270. package/dist/utils/env-management.d.ts +24 -8
  271. package/dist/utils/env-management.js +119 -66
  272. package/dist/utils/format-env-suffix.d.ts +11 -0
  273. package/dist/utils/format-env-suffix.js +11 -0
  274. package/dist/utils/format.d.ts +0 -1
  275. package/dist/utils/format.js +0 -2
  276. package/dist/utils/formatter.d.ts +0 -1
  277. package/dist/utils/formatter.js +23 -13
  278. package/dist/utils/fs-utils.d.ts +12 -0
  279. package/dist/utils/fs-utils.js +55 -0
  280. package/dist/utils/git.d.ts +0 -1
  281. package/dist/utils/git.js +0 -2
  282. package/dist/utils/handle-upgrade.d.ts +8 -0
  283. package/dist/utils/handle-upgrade.js +39 -0
  284. package/dist/utils/is-debug.d.ts +0 -1
  285. package/dist/utils/is-debug.js +0 -2
  286. package/dist/utils/lambda-config.d.ts +3 -2
  287. package/dist/utils/lambda-config.js +75 -80
  288. package/dist/utils/load-payload-config.d.ts +9 -0
  289. package/dist/utils/load-payload-config.js +27 -0
  290. package/dist/utils/log.d.ts +0 -1
  291. package/dist/utils/log.js +0 -2
  292. package/dist/utils/messages.d.ts +1 -3
  293. package/dist/utils/messages.js +47 -13
  294. package/dist/utils/package-manager.d.ts +24 -1
  295. package/dist/utils/package-manager.js +53 -2
  296. package/dist/utils/parse-template-spec.d.ts +11 -0
  297. package/dist/utils/parse-template-spec.js +60 -0
  298. package/dist/utils/payload-config-ast.d.ts +27 -7
  299. package/dist/utils/payload-config-ast.js +106 -60
  300. package/dist/utils/payload-config-finder.d.ts +2 -3
  301. package/dist/utils/payload-config-finder.js +48 -11
  302. package/dist/utils/payload-config-modifier.d.ts +1 -2
  303. package/dist/utils/payload-config-modifier.js +114 -68
  304. package/dist/utils/payload-package-check.d.ts +28 -3
  305. package/dist/utils/payload-package-check.js +90 -31
  306. package/dist/utils/project.d.ts +8 -4
  307. package/dist/utils/project.js +63 -37
  308. package/dist/utils/resolve-environment.d.ts +13 -0
  309. package/dist/utils/resolve-environment.js +29 -0
  310. package/dist/utils/s3-upload.d.ts +7 -3
  311. package/dist/utils/s3-upload.js +44 -9
  312. package/dist/utils/token-display.d.ts +5 -2
  313. package/dist/utils/token-display.js +49 -24
  314. package/dist/utils/typescript-validator.d.ts +0 -1
  315. package/dist/utils/typescript-validator.js +4 -8
  316. package/dist/utils/version-check.d.ts +2 -0
  317. package/dist/utils/version-check.js +43 -0
  318. package/package.json +47 -16
  319. package/dist/api/control-plane.d.ts.map +0 -1
  320. package/dist/api/control-plane.js.map +0 -1
  321. package/dist/api/figma-api.d.ts.map +0 -1
  322. package/dist/api/figma-api.js.map +0 -1
  323. package/dist/auth/browser.d.ts.map +0 -1
  324. package/dist/auth/browser.js.map +0 -1
  325. package/dist/auth/callback-server.d.ts.map +0 -1
  326. package/dist/auth/callback-server.js.map +0 -1
  327. package/dist/auth/crypto-utils.d.ts.map +0 -1
  328. package/dist/auth/crypto-utils.js.map +0 -1
  329. package/dist/auth/jwt-validator.d.ts.map +0 -1
  330. package/dist/auth/jwt-validator.js.map +0 -1
  331. package/dist/auth/oauth-flow.d.ts.map +0 -1
  332. package/dist/auth/oauth-flow.js.map +0 -1
  333. package/dist/auth/pkce.d.ts.map +0 -1
  334. package/dist/auth/pkce.js.map +0 -1
  335. package/dist/auth/project-token.d.ts.map +0 -1
  336. package/dist/auth/project-token.js.map +0 -1
  337. package/dist/auth/refresh.d.ts.map +0 -1
  338. package/dist/auth/refresh.js.map +0 -1
  339. package/dist/auth/token-store.d.ts.map +0 -1
  340. package/dist/auth/token-store.js.map +0 -1
  341. package/dist/auth/types.d.ts.map +0 -1
  342. package/dist/auth/types.js.map +0 -1
  343. package/dist/cli.d.ts.map +0 -1
  344. package/dist/cli.js.map +0 -1
  345. package/dist/commands/deploy.d.ts.map +0 -1
  346. package/dist/commands/deploy.js.map +0 -1
  347. package/dist/commands/init.d.ts.map +0 -1
  348. package/dist/commands/init.js.map +0 -1
  349. package/dist/commands/list-tokens.d.ts.map +0 -1
  350. package/dist/commands/list-tokens.js.map +0 -1
  351. package/dist/commands/login.d.ts.map +0 -1
  352. package/dist/commands/login.js.map +0 -1
  353. package/dist/commands/logout.d.ts.map +0 -1
  354. package/dist/commands/logout.js.map +0 -1
  355. package/dist/config/oauth.d.ts.map +0 -1
  356. package/dist/config/oauth.js.map +0 -1
  357. package/dist/constants.d.ts.map +0 -1
  358. package/dist/constants.js.map +0 -1
  359. package/dist/exports/client.d.ts.map +0 -1
  360. package/dist/exports/client.js.map +0 -1
  361. package/dist/index.d.ts.map +0 -1
  362. package/dist/index.js.map +0 -1
  363. package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
  364. package/dist/oauth/components/LoginButton/index.js.map +0 -1
  365. package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
  366. package/dist/oauth/components/LogoutButton/index.js.map +0 -1
  367. package/dist/oauth/defaults.d.ts.map +0 -1
  368. package/dist/oauth/defaults.js.map +0 -1
  369. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
  370. package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
  371. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
  372. package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
  373. package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
  374. package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
  375. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
  376. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
  377. package/dist/oauth/exports/client.d.ts.map +0 -1
  378. package/dist/oauth/exports/client.js.map +0 -1
  379. package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
  380. package/dist/oauth/hooks/afterLogout.js.map +0 -1
  381. package/dist/oauth/hooks/me.d.ts.map +0 -1
  382. package/dist/oauth/hooks/me.js.map +0 -1
  383. package/dist/oauth/hooks/refresh.d.ts.map +0 -1
  384. package/dist/oauth/hooks/refresh.js.map +0 -1
  385. package/dist/oauth/index.d.ts.map +0 -1
  386. package/dist/oauth/index.js.map +0 -1
  387. package/dist/oauth/strategy/index.d.ts.map +0 -1
  388. package/dist/oauth/strategy/index.js.map +0 -1
  389. package/dist/oauth/types.d.ts.map +0 -1
  390. package/dist/oauth/types.js.map +0 -1
  391. package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
  392. package/dist/oauth/utilities/clearCookie.js.map +0 -1
  393. package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
  394. package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
  395. package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
  396. package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
  397. package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
  398. package/dist/oauth/utilities/extractOrigin.js.map +0 -1
  399. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
  400. package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
  401. package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
  402. package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
  403. package/dist/oauth/utilities/getAdminPath.js +0 -9
  404. package/dist/oauth/utilities/getAdminPath.js.map +0 -1
  405. package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
  406. package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
  407. package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
  408. package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
  409. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
  410. package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
  411. package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
  412. package/dist/oauth/utilities/getTokenExp.js.map +0 -1
  413. package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
  414. package/dist/oauth/utilities/getUsernameField.js.map +0 -1
  415. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
  416. package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
  417. package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
  418. package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
  419. package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
  420. package/dist/oauth/utilities/refreshTokens.js.map +0 -1
  421. package/dist/plugin/adapter.d.ts.map +0 -1
  422. package/dist/plugin/adapter.js.map +0 -1
  423. package/dist/plugin/build-config.d.ts.map +0 -1
  424. package/dist/plugin/build-config.js.map +0 -1
  425. package/dist/types/config.d.ts.map +0 -1
  426. package/dist/types/config.js.map +0 -1
  427. package/dist/types.d.ts.map +0 -1
  428. package/dist/types.js.map +0 -1
  429. package/dist/utils/asset-collection.d.ts.map +0 -1
  430. package/dist/utils/asset-collection.js.map +0 -1
  431. package/dist/utils/build-detection.d.ts.map +0 -1
  432. package/dist/utils/build-detection.js.map +0 -1
  433. package/dist/utils/config.d.ts.map +0 -1
  434. package/dist/utils/config.js.map +0 -1
  435. package/dist/utils/download-template.d.ts.map +0 -1
  436. package/dist/utils/download-template.js.map +0 -1
  437. package/dist/utils/env-management.d.ts.map +0 -1
  438. package/dist/utils/env-management.js.map +0 -1
  439. package/dist/utils/format.d.ts.map +0 -1
  440. package/dist/utils/format.js.map +0 -1
  441. package/dist/utils/formatter.d.ts.map +0 -1
  442. package/dist/utils/formatter.js.map +0 -1
  443. package/dist/utils/git.d.ts.map +0 -1
  444. package/dist/utils/git.js.map +0 -1
  445. package/dist/utils/is-debug.d.ts.map +0 -1
  446. package/dist/utils/is-debug.js.map +0 -1
  447. package/dist/utils/lambda-config.d.ts.map +0 -1
  448. package/dist/utils/lambda-config.js.map +0 -1
  449. package/dist/utils/log.d.ts.map +0 -1
  450. package/dist/utils/log.js.map +0 -1
  451. package/dist/utils/messages.d.ts.map +0 -1
  452. package/dist/utils/messages.js.map +0 -1
  453. package/dist/utils/package-manager.d.ts.map +0 -1
  454. package/dist/utils/package-manager.js.map +0 -1
  455. package/dist/utils/payload-config-ast.d.ts.map +0 -1
  456. package/dist/utils/payload-config-ast.js.map +0 -1
  457. package/dist/utils/payload-config-finder.d.ts.map +0 -1
  458. package/dist/utils/payload-config-finder.js.map +0 -1
  459. package/dist/utils/payload-config-modifier.d.ts.map +0 -1
  460. package/dist/utils/payload-config-modifier.js.map +0 -1
  461. package/dist/utils/payload-package-check.d.ts.map +0 -1
  462. package/dist/utils/payload-package-check.js.map +0 -1
  463. package/dist/utils/project.d.ts.map +0 -1
  464. package/dist/utils/project.js.map +0 -1
  465. package/dist/utils/s3-upload.d.ts.map +0 -1
  466. package/dist/utils/s3-upload.js.map +0 -1
  467. package/dist/utils/token-display.d.ts.map +0 -1
  468. package/dist/utils/token-display.js.map +0 -1
  469. package/dist/utils/typescript-validator.d.ts.map +0 -1
  470. package/dist/utils/typescript-validator.js.map +0 -1
@@ -4,18 +4,22 @@
4
4
  export interface InitCommandOptions {
5
5
  /** Enable debug mode */
6
6
  debug?: boolean;
7
+ /** Figma environment name (e.g. 'production', 'staging') */
8
+ env?: string;
7
9
  /** Force reconfiguration of existing project */
8
10
  force?: boolean;
9
- /** Tenant ID to use (optional - will prompt if not provided) */
11
+ /** Content System ID to use */
10
12
  id?: string;
11
13
  /** Project name (for scaffolding) */
12
14
  name?: string;
13
- /** Disable Content System (defaults to enabled) */
14
- noContentSystem?: boolean;
15
- /** AWS region for deployment (defaults to us-east-1) */
16
- region?: string;
15
+ /** Skip Payload skill installation */
16
+ noSkill?: boolean;
17
+ /** npm dist-tag or explicit version for core payload packages (e.g. 'canary', 'latest', '4.0.0-canary.16'); defaults to 'canary' */
18
+ payloadVersion?: string;
17
19
  /** Skip authentication check (for testing/development) */
18
20
  skipAuth?: boolean;
21
+ /** GitHub template override, e.g. "main:website" or "owner/repo#ref:template-path" */
22
+ template?: string;
19
23
  /** Skip prompts and use defaults where possible */
20
24
  yes?: boolean;
21
25
  }
@@ -31,4 +35,3 @@ export interface InitCommandOptions {
31
35
  * @param options - Command options
32
36
  */
33
37
  export declare function initCommand(options: InitCommandOptions): Promise<void>;
34
- //# sourceMappingURL=init.d.ts.map
@@ -2,30 +2,60 @@ 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, getTenantDetails } from '../api/control-plane.js';
5
+ import { ControlPlaneError, getBootstrapInfo } from '../api/control-plane.js';
6
6
  import { FigmaApiError } from '../api/figma-api.js';
7
- import { getValidAccessToken } from '../auth/oauth-flow.js';
7
+ import { tryGetCredential } from '../auth/oauth-flow.js';
8
8
  import { getValidProjectToken, ProjectTokenError } from '../auth/project-token.js';
9
- import { TokenStore } from '../auth/token-store.js';
9
+ import { getTokenStore } from '../auth/token-store.js';
10
+ import { getInfraEnvironment, getProjectNotFoundMessage } from '../constants.js';
11
+ import { downloadSkill } from '../lib/download-skill.js';
12
+ import { ensureGitignore } from '../utils/config.js';
13
+ import { addOrUpdateEnvVar } from '../utils/env-management.js';
10
14
  import { isDebug } from '../utils/is-debug.js';
15
+ import { applyLambdaModifications } from '../utils/lambda-config.js';
11
16
  import * as log from '../utils/log.js';
17
+ import { detectPackageManagerFromEnvironment, getRunCommand, resolvePackageManager } from '../utils/package-manager.js';
12
18
  import { displayManualInstructions, ensurePayloadFigmaConfig } from '../utils/payload-config-modifier.js';
13
19
  import { detectPayloadProject, hasRequiredDependencies, initializeGitRepo, installDependencies, isInProjectDirectory, scaffoldProject, validatePayloadVersion } from '../utils/project.js';
20
+ import { resolveEnvironment } from '../utils/resolve-environment.js';
21
+ import { checkForUpdates, getOwnVersion } from '../utils/version-check.js';
14
22
  import { loginCommand } from './login.js';
23
+ import { cacheAllEnvironments } from '../utils/cache-bootstrap.js';
24
+ import { DEFAULT_TEMPLATE_SOURCE } from '../utils/download-template.js';
25
+ import { parseTemplateSpec, TemplateSpecParseError } from '../utils/parse-template-spec.js';
26
+ async function maybeInstallPayloadSkill(args) {
27
+ if (args.noSkill) {
28
+ return;
29
+ }
30
+ const result = await downloadSkill({
31
+ projectDir: args.projectDir
32
+ });
33
+ if (result.ok) {
34
+ return;
35
+ }
36
+ if (result.reason === 'already-installed') {
37
+ return;
38
+ }
39
+ p.log.warn(pc.yellow(`⚠ Could not install Payload skill (${result.reason}${result.detail ? `: ${result.detail}` : ''}). Continuing.`));
40
+ }
15
41
  /**
16
- * Generate and store project token for a tenant
42
+ * Generate and store project token for a content system
17
43
  * Non-blocking - will show warning but not exit on failure
18
44
  * Only shows feedback if DEBUG mode is enabled, otherwise runs silently
19
45
  *
20
46
  * @param tokenStore - Token store instance
21
- * @param tenantId - Tenant ID to generate token for
47
+ * @param contentSystemId - Content System ID to generate token for
22
48
  * @param spinner - Clack spinner instance for status updates (only used in debug mode)
23
- */ async function generateProjectTokenWithFeedback(tokenStore, tenantId, spinner) {
49
+ */ async function generateProjectTokenWithFeedback(tokenStore, contentSystemId, spinner, projectInfo) {
24
50
  if (isDebug()) {
25
51
  spinner.start('Generating project token...');
26
52
  }
27
53
  try {
28
- const projectToken = await getValidProjectToken(tokenStore, tenantId);
54
+ const projectToken = await getValidProjectToken({
55
+ projectInfo,
56
+ tenantId: contentSystemId,
57
+ tokenStore
58
+ });
29
59
  if (isDebug()) {
30
60
  if (projectToken) {
31
61
  spinner.stop(pc.green('✓ Project token generated'));
@@ -58,108 +88,92 @@ import { loginCommand } from './login.js';
58
88
  *
59
89
  * @param options - Command options
60
90
  */ export async function initCommand(options) {
91
+ // Check for mismatched version (non-blocking)
92
+ const currentVersion = await getOwnVersion();
93
+ await checkForUpdates(currentVersion);
61
94
  // Check authentication
62
- const tokenStore = new TokenStore();
95
+ const tokenStore = getTokenStore();
63
96
  const s = p.spinner();
64
- let accessToken;
65
97
  if (options.skipAuth) {
66
98
  // Skip authentication for testing/development
67
99
  p.log.warn(pc.yellow('Skipping authentication (--skip-auth mode)'));
68
- accessToken = 'mock-access-token';
69
100
  } else {
70
- try {
71
- // Check for valid cached tokens first (no API call needed)
72
- if (tokenStore.hasValidTokens()) {
73
- // Use cached token silently - no spinner needed
74
- accessToken = tokenStore.getAccessToken();
75
- } else {
76
- // Need to refresh or authenticate - show spinner for API call
77
- s.start('Checking authentication...');
78
- const token = await getValidAccessToken(tokenStore);
79
- if (!token) {
80
- s.stop(pc.yellow('⚠ Not authenticated'));
81
- p.log.info('Authentication required to continue');
82
- // Prompt user to authenticate now
83
- const shouldAuth = await p.confirm({
84
- initialValue: true,
85
- message: 'Would you like to authenticate now?'
86
- });
87
- if (p.isCancel(shouldAuth) || !shouldAuth) {
88
- p.cancel('Operation cancelled');
89
- process.exit(0);
90
- }
91
- // Run login command
92
- await loginCommand();
93
- // Get token after auth
94
- const newToken = await getValidAccessToken(tokenStore);
95
- if (!newToken) {
96
- p.log.error('Authentication failed');
97
- process.exit(1);
98
- }
99
- accessToken = newToken;
100
- p.log.success(pc.green('✓ Authenticated'));
101
- } else {
102
- accessToken = token;
103
- s.stop(pc.green('✓ Authenticated'));
101
+ // Check for valid cached tokens first (no API call needed)
102
+ if (!tokenStore.hasValidOauthToken()) {
103
+ // Need to refresh or authenticate - show spinner for API call
104
+ s.start('Checking authentication...');
105
+ const credential = await tryGetCredential(tokenStore);
106
+ if (!credential) {
107
+ s.stop('Authentication required to continue');
108
+ await loginCommand({
109
+ showNextSteps: false
110
+ });
111
+ const newCredential = await tryGetCredential(tokenStore);
112
+ if (!newCredential) {
113
+ p.log.error('Authentication failed');
114
+ process.exit(1);
104
115
  }
116
+ } else {
117
+ s.stop(pc.green('✓ Authenticated'));
105
118
  }
106
- } catch (error) {
107
- s.stop(pc.red('✗ Authentication failed'));
108
- log.error(error instanceof Error ? error.message : 'Unknown error');
109
- p.note('Run `figma auth` to authenticate', 'Tip');
110
- process.exit(1);
111
119
  }
112
120
  }
113
121
  // Note: We no longer check for figma.config.json here
114
122
  // Instead, the AST detection will check if figma object already exists in payload.config.ts
115
123
  // and skip modification if it does (unless --force is used)
116
- // Step 3: Get CMS ID with retry loop
124
+ // Step 3: Get CMS Resource ID (required argument)
117
125
  log.debug('Configuring Project...');
118
- let tenantId = options.id;
119
- let selectedTenant;
120
- while(!selectedTenant){
121
- // Prompt for ID if not provided
122
- if (!tenantId) {
123
- const input = await p.text({
124
- message: 'Enter your CMS ID:',
125
- placeholder: 'tenant_abc123',
126
- validate: (value)=>{
127
- if (!value || typeof value !== 'string') {
128
- return 'CMS ID is required';
129
- }
130
- return undefined;
131
- }
132
- });
133
- if (p.isCancel(input)) {
134
- p.cancel('Operation cancelled');
135
- process.exit(0);
136
- }
137
- tenantId = input;
138
- }
139
- // Try to fetch tenant details
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
+ // Parse --template spec early so malformed values abort before any I/O
132
+ let templateSource;
133
+ if (options.template) {
140
134
  try {
141
- log.debug('Using mock Control Plane API (no real network calls)');
142
- selectedTenant = await getTenantDetails(accessToken, tenantId);
143
- log.debug(`Using: ${selectedTenant.domain}`);
135
+ templateSource = parseTemplateSpec(options.template);
144
136
  } catch (error) {
145
- p.log.error(pc.red('✗ Failed to fetch CMS details'));
146
- // Check if permission error (403)
147
- if (error instanceof ControlPlaneError && error.statusCode === 403) {
148
- p.log.error('You do not have permission to access the provided CMS ID. Please try again.');
149
- } else if (error instanceof ControlPlaneError && error.statusCode === 404) {
150
- p.log.error('Tenant ID not found. Verify the ID is correct.');
151
- } else {
152
- p.log.error(error instanceof Error ? error.message : 'Unknown error');
137
+ const message = error instanceof TemplateSpecParseError ? error.message : 'Invalid --template value';
138
+ p.log.error(pc.red(`✗ ${message}`));
139
+ p.note('Format: [<owner>/<repo>#]<ref>:<template-path>\n' + 'Examples:\n' + ' blank\n' + ' main:website\n' + ' myorg/payload-fork#feat-x:templates/custom', 'Template spec');
140
+ process.exit(1);
141
+ }
142
+ }
143
+ // Fetch bootstrap info (oauth creds + environments)
144
+ let bootstrapInfo = null;
145
+ let resolvedEnv = null;
146
+ let oauthClientId = null;
147
+ let oauthClientSecret = null;
148
+ if (!options.skipAuth) {
149
+ const credential = await tryGetCredential(tokenStore);
150
+ if (credential) {
151
+ try {
152
+ bootstrapInfo = await getBootstrapInfo(credential, cmsResourceId);
153
+ } catch (error) {
154
+ log.debug(`Control Plane Error: ${error.statusCode} - ${error.message}`);
155
+ if (error instanceof ControlPlaneError && (error.statusCode === 404 || error.statusCode === 410)) {
156
+ p.log.error(pc.red(getProjectNotFoundMessage({
157
+ environment: getInfraEnvironment(),
158
+ projectId: cmsResourceId
159
+ })));
160
+ process.exit(1);
161
+ }
162
+ const message = error instanceof Error ? error.message : 'Unknown error';
163
+ p.log.error(pc.red(`✗ Unable to fetch project info for "${cmsResourceId}"`));
164
+ p.log.error(pc.dim(`Details: ${message}`));
165
+ process.exit(1);
153
166
  }
154
- // Clear tenantId to prompt again
155
- tenantId = undefined;
156
- // Ask if they want to retry
157
- const shouldRetry = await p.confirm({
158
- initialValue: true,
159
- message: 'Would you like to try a different CMS ID?'
160
- });
161
- if (p.isCancel(shouldRetry) || !shouldRetry) {
162
- p.cancel('Operation cancelled');
167
+ try {
168
+ const envName = options.env ?? process.env.FIGMA_ENVIRONMENT_NAME ?? undefined;
169
+ resolvedEnv = resolveEnvironment({
170
+ environmentName: envName,
171
+ environments: bootstrapInfo.environments
172
+ });
173
+ oauthClientId = bootstrapInfo.oauthCredentials.oauthClientId;
174
+ oauthClientSecret = bootstrapInfo.oauthCredentials.oauthClientSecret;
175
+ } catch (error) {
176
+ p.log.error(pc.red(error instanceof Error ? error.message : 'Unknown error'));
163
177
  process.exit(1);
164
178
  }
165
179
  }
@@ -171,11 +185,12 @@ import { loginCommand } from './login.js';
171
185
  log.debug('Project directory detected');
172
186
  // Detect Payload
173
187
  const projectInfo = await detectPayloadProject();
188
+ const packageManager = await resolvePackageManager(process.cwd());
174
189
  if (projectInfo.hasPayload) {
175
190
  // Validate existing Payload version
176
191
  if (projectInfo.payloadVersion && !validatePayloadVersion(projectInfo.payloadVersion)) {
177
- p.log.warn(pc.yellow(`Payload version ${projectInfo.payloadVersion} detected. Version 3.x is required.`));
178
- p.note('Upgrade to Payload 3.x before continuing', 'Action Required');
192
+ p.log.warn(pc.yellow(`Payload version ${projectInfo.payloadVersion} detected. Version 4.x or newer is required.`));
193
+ p.note('Upgrade to Payload 4.x or newer before continuing', 'Action Required');
179
194
  process.exit(1);
180
195
  }
181
196
  p.log.success(pc.green(`✓ Payload ${projectInfo.payloadVersion || 'detected'}`));
@@ -190,19 +205,17 @@ import { loginCommand } from './login.js';
190
205
  });
191
206
  if (!p.isCancel(shouldInstall) && shouldInstall) {
192
207
  s.start('Installing dependencies...');
193
- await installDependencies(process.cwd(), projectInfo.packageManager || 'pnpm');
208
+ await installDependencies(process.cwd(), packageManager);
194
209
  s.stop(pc.green('✓ Dependencies installed'));
195
210
  }
196
211
  }
197
212
  s.start('Checking Payload configuration...');
198
- const modResult = await ensurePayloadFigmaConfig(process.cwd(), projectInfo.packageManager || 'pnpm', {
199
- region: options.region || 'us-east-1',
200
- tenantId: selectedTenant.id,
201
- useContentSystem: !options.noContentSystem
213
+ const modResult = await ensurePayloadFigmaConfig(process.cwd(), packageManager, {
214
+ contentSystemId: resolvedEnv?.contentSystemId ?? cmsResourceId
202
215
  });
203
216
  if (!modResult.success) {
204
217
  s.stop(pc.red('✗ Configuration check failed'));
205
- displayManualInstructions(modResult.error || 'Unknown error');
218
+ displayManualInstructions(modResult.error || 'Unknown error', packageManager);
206
219
  process.exit(1);
207
220
  }
208
221
  if (modResult.modified) {
@@ -219,62 +232,93 @@ import { loginCommand } from './login.js';
219
232
  p.log.warn(pc.yellow(`⚠ ${warning}`));
220
233
  });
221
234
  }
222
- } else {
223
- // Has package.json but no Payload - offer to add Payload
224
- p.log.warn(pc.yellow(' No Payload detected in this project'));
225
- const shouldAddPayload = await p.confirm({
226
- initialValue: true,
227
- message: 'Would you like to add Payload to this project?'
228
- });
229
- if (p.isCancel(shouldAddPayload)) {
230
- p.cancel('Operation cancelled');
231
- process.exit(0);
232
- }
233
- if (!shouldAddPayload) {
234
- p.log.error('Payload is required to use Figma CMS');
235
- process.exit(1);
235
+ // Write environment variables to .env file
236
+ try {
237
+ await addOrUpdateEnvVar(process.cwd(), 'FIGMA_PROJECT_ID', cmsResourceId);
238
+ await addOrUpdateEnvVar(process.cwd(), 'FIGMA_ENVIRONMENT_NAME', resolvedEnv?.name ?? 'production');
239
+ log.debug('Added FIGMA_PROJECT_ID and FIGMA_ENVIRONMENT_NAME to .env file');
240
+ const infraEnv = getInfraEnvironment();
241
+ if (infraEnv !== 'production') {
242
+ await addOrUpdateEnvVar(process.cwd(), 'FIGMA_INFRA_ENV', infraEnv);
243
+ log.debug(`Added FIGMA_INFRA_ENV=${infraEnv} to .env file`);
244
+ }
245
+ // Cache all environments in local encrypted store
246
+ if (bootstrapInfo && oauthClientId && oauthClientSecret) {
247
+ cacheAllEnvironments(tokenStore, cmsResourceId, bootstrapInfo);
248
+ }
249
+ } catch (error) {
250
+ p.log.warn(pc.yellow(`⚠ Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`));
236
251
  }
237
- // TODO: Add Payload to existing project (future enhancement)
238
- p.log.error('Adding Payload to existing projects is not yet supported');
239
- p.note('Create a new project or manually add Payload dependencies', 'Action Required');
252
+ } else {
253
+ p.log.warn(pc.yellow(' Payload was not detected in this project'));
254
+ p.note('Run this command in a directory without an existing project or in an existing Payload project.', 'Action Required');
240
255
  process.exit(1);
241
256
  }
257
+ // npm leaves node_modules in a transient state after a sequence of
258
+ // add/remove calls; a final install reconciles it so the project is
259
+ // immediately buildable.
260
+ s.start('Reconciling dependencies...');
261
+ try {
262
+ await installDependencies(process.cwd(), packageManager);
263
+ s.stop(pc.green('✓ Dependencies reconciled'));
264
+ } catch (error) {
265
+ s.stop(pc.red('✗ Failed to reconcile dependencies'));
266
+ log.error(error instanceof Error ? error.message : 'Unknown error');
267
+ process.exit(1);
268
+ }
269
+ // Apply Lambda modifications (run.sh, standalone output, lambda:buildzip script)
270
+ await applyLambdaModifications(process.cwd(), packageManager);
271
+ // Ensure .gitignore has required entries
272
+ await ensureGitignore(process.cwd(), [
273
+ '.env',
274
+ '.env.local',
275
+ 'lambda.zip'
276
+ ]);
277
+ await maybeInstallPayloadSkill({
278
+ noSkill: options.noSkill,
279
+ projectDir: process.cwd()
280
+ });
242
281
  // Generate project token (unless skipping auth)
243
- if (!options.skipAuth) {
244
- await generateProjectTokenWithFeedback(tokenStore, selectedTenant.id, s);
282
+ if (!options.skipAuth && resolvedEnv) {
283
+ await generateProjectTokenWithFeedback(tokenStore, resolvedEnv.contentSystemId, s, {
284
+ environmentName: resolvedEnv.name,
285
+ projectId: cmsResourceId
286
+ });
245
287
  }
246
288
  // Success message for existing project
247
289
  p.outro(pc.green('✓ Project initialized successfully!'));
248
290
  const nextSteps = [
249
- selectedTenant.status === 'provisioning' ? 'Wait for CMS provisioning to complete (check status with `@payloadcms/figma list`)' : undefined,
250
- 'Start development server: `pnpm dev`',
251
- `Access your CMS at: ${pc.cyan(`https://${selectedTenant.domain}`)}`
291
+ `Start development server: \`${getRunCommand(packageManager)} dev\``
252
292
  ].filter(Boolean);
253
293
  p.note(nextSteps.join('\n'), 'Next Steps');
254
294
  } else {
255
295
  // ===== NEW PROJECT FLOW =====
256
296
  // p.log.info('No project detected - Creating New Project')
257
- // Prompt for path
258
- const projectPathInput = await p.text({
259
- initialValue: './',
260
- message: 'Enter path to create project:',
261
- placeholder: './my-cms-project',
262
- validate: (value)=>{
263
- if (!value) {
264
- return 'Path is required';
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;
265
311
  }
266
- // Allow relative or absolute paths
267
- return undefined;
312
+ });
313
+ if (p.isCancel(projectPathInput)) {
314
+ p.cancel('Operation cancelled');
315
+ process.exit(0);
268
316
  }
269
- });
270
- if (p.isCancel(projectPathInput)) {
271
- p.cancel('Operation cancelled');
272
- process.exit(0);
317
+ projectPath = projectPathInput;
273
318
  }
274
- const projectPath = projectPathInput;
275
319
  const fullPath = path.resolve(process.cwd(), projectPath);
276
- // Get project name from path or prompt
277
- const projectName = options.name || path.basename(fullPath);
320
+ const projectName = path.basename(fullPath);
321
+ const packageManager = detectPackageManagerFromEnvironment();
278
322
  // Create directory
279
323
  try {
280
324
  await fs.mkdir(fullPath, {
@@ -285,12 +329,16 @@ import { loginCommand } from './login.js';
285
329
  process.exit(1);
286
330
  }
287
331
  // Scaffold project
288
- s.start('Downloading template from GitHub...');
332
+ const resolvedSource = {
333
+ ...DEFAULT_TEMPLATE_SOURCE,
334
+ ...templateSource
335
+ };
336
+ s.start(`Downloading template "${resolvedSource.templatePath}" from ` + `${resolvedSource.owner}/${resolvedSource.repo}@${resolvedSource.ref}...`);
289
337
  try {
290
- await scaffoldProject(fullPath, projectName);
338
+ await scaffoldProject(fullPath, projectName, packageManager, templateSource, options.payloadVersion);
291
339
  s.stop(pc.green('✓ Template downloaded'));
292
340
  s.start('Installing dependencies...');
293
- await installDependencies(fullPath, 'pnpm');
341
+ await installDependencies(fullPath, packageManager);
294
342
  s.stop(pc.green('✓ Dependencies installed'));
295
343
  } catch (error) {
296
344
  s.stop(pc.red('✗ Failed'));
@@ -299,14 +347,12 @@ import { loginCommand } from './login.js';
299
347
  }
300
348
  // Modify Payload configuration
301
349
  s.start('Checking Payload configuration...');
302
- const modResult = await ensurePayloadFigmaConfig(fullPath, 'pnpm', {
303
- region: options.region || 'us-east-1',
304
- tenantId: selectedTenant.id,
305
- useContentSystem: !options.noContentSystem
350
+ const modResult = await ensurePayloadFigmaConfig(fullPath, packageManager, {
351
+ contentSystemId: resolvedEnv?.contentSystemId ?? cmsResourceId
306
352
  });
307
353
  if (!modResult.success) {
308
354
  s.stop(pc.red('✗ Configuration check failed'));
309
- displayManualInstructions(modResult.error || 'Unknown error');
355
+ displayManualInstructions(modResult.error || 'Unknown error', packageManager);
310
356
  process.exit(1);
311
357
  }
312
358
  if (modResult.modified) {
@@ -323,9 +369,45 @@ import { loginCommand } from './login.js';
323
369
  p.log.warn(pc.yellow(`⚠ ${warning}`));
324
370
  });
325
371
  }
372
+ // Write environment variables to .env file
373
+ try {
374
+ await addOrUpdateEnvVar(fullPath, 'FIGMA_PROJECT_ID', cmsResourceId);
375
+ await addOrUpdateEnvVar(fullPath, 'FIGMA_ENVIRONMENT_NAME', resolvedEnv?.name ?? 'production');
376
+ log.debug('Added FIGMA_PROJECT_ID and FIGMA_ENVIRONMENT_NAME to .env file');
377
+ const infraEnv = getInfraEnvironment();
378
+ if (infraEnv !== 'production') {
379
+ await addOrUpdateEnvVar(fullPath, 'FIGMA_INFRA_ENV', infraEnv);
380
+ log.debug(`Added FIGMA_INFRA_ENV=${infraEnv} to .env file`);
381
+ }
382
+ // Cache all environments in local encrypted store
383
+ if (bootstrapInfo && oauthClientId && oauthClientSecret) {
384
+ cacheAllEnvironments(tokenStore, cmsResourceId, bootstrapInfo);
385
+ }
386
+ } catch (error) {
387
+ p.log.warn(pc.yellow(`⚠ Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`));
388
+ }
389
+ // npm leaves node_modules in a transient state after a sequence of
390
+ // add/remove calls; a final install reconciles it so the project is
391
+ // immediately buildable.
392
+ s.start('Reconciling dependencies...');
393
+ try {
394
+ await installDependencies(fullPath, packageManager);
395
+ s.stop(pc.green('✓ Dependencies reconciled'));
396
+ } catch (error) {
397
+ s.stop(pc.red('✗ Failed to reconcile dependencies'));
398
+ log.error(error instanceof Error ? error.message : 'Unknown error');
399
+ process.exit(1);
400
+ }
401
+ await maybeInstallPayloadSkill({
402
+ noSkill: options.noSkill,
403
+ projectDir: fullPath
404
+ });
326
405
  // Generate project token (unless skipping auth)
327
- if (!options.skipAuth) {
328
- await generateProjectTokenWithFeedback(tokenStore, selectedTenant.id, s);
406
+ if (!options.skipAuth && resolvedEnv) {
407
+ await generateProjectTokenWithFeedback(tokenStore, resolvedEnv.contentSystemId, s, {
408
+ environmentName: resolvedEnv.name,
409
+ projectId: cmsResourceId
410
+ });
329
411
  }
330
412
  // Initialize git repository (after all files including lock file are ready)
331
413
  initializeGitRepo(fullPath);
@@ -337,10 +419,8 @@ import { loginCommand } from './login.js';
337
419
  if (relativePath && relativePath !== '.') {
338
420
  nextSteps.push(`cd ${relativePath}`);
339
421
  }
340
- nextSteps.push('pnpm dev or follow directions in README.md', '', 'Documentation:', '- Getting Started: https://payloadcms.com/docs/getting-started/what-is-payload', '- Configuration: https://payloadcms.com/docs/configuration/overview');
422
+ nextSteps.push(`${getRunCommand(packageManager)} dev or follow directions in README.md`, '', 'Documentation:', '- Getting Started: https://payloadcms.com/docs/getting-started/what-is-payload', '- Configuration: https://payloadcms.com/docs/configuration/overview');
341
423
  p.note(nextSteps.join('\n'), 'Next Steps');
342
424
  p.outro(pc.green('✓ Done'));
343
425
  }
344
426
  }
345
-
346
- //# sourceMappingURL=init.js.map
@@ -2,6 +2,8 @@
2
2
  * Options for list-tokens command
3
3
  */
4
4
  export interface ListTokensCommandOptions {
5
+ /** Show all environments */
6
+ all?: boolean;
5
7
  /** Enable debug mode */
6
8
  debug?: boolean;
7
9
  }
@@ -9,8 +11,5 @@ export interface ListTokensCommandOptions {
9
11
  * Handle the `@payloadcms/figma list-tokens` command
10
12
  *
11
13
  * Displays stored token information including OAuth and project tokens.
12
- *
13
- * @param _options - Command options (unused)
14
14
  */
15
- export declare function listTokensCommand(_options?: ListTokensCommandOptions): void;
16
- //# sourceMappingURL=list-tokens.d.ts.map
15
+ export declare function listTokensCommand(options?: ListTokensCommandOptions): void;
@@ -1,25 +1,40 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import pc from 'picocolors';
3
- import { TokenStore } from '../auth/token-store.js';
3
+ import { getTokenStore } from '../auth/token-store.js';
4
+ import { getInfraEnvironment } from '../constants.js';
5
+ import { formatEnvSuffix } from '../utils/format-env-suffix.js';
4
6
  import { isDebug } from '../utils/is-debug.js';
5
7
  import { formatTimestamp, maskToken, showProjectTokens } from '../utils/token-display.js';
8
+ const ALL_ENVIRONMENTS = [
9
+ 'production',
10
+ 'staging'
11
+ ];
6
12
  /**
7
13
  * Handle the `@payloadcms/figma list-tokens` command
8
14
  *
9
15
  * Displays stored token information including OAuth and project tokens.
10
- *
11
- * @param _options - Command options (unused)
12
- */ export function listTokensCommand(_options = {}) {
13
- const tokenStore = new TokenStore();
14
- const tokens = tokenStore.getTokens();
16
+ */ export function listTokensCommand(options = {}) {
17
+ if (options.all) {
18
+ // Show detailed info for all environments
19
+ for (const env of ALL_ENVIRONMENTS){
20
+ showTokenDetails(env);
21
+ }
22
+ } else {
23
+ // Show detailed info for current environment only
24
+ showTokenDetails(getInfraEnvironment());
25
+ }
26
+ }
27
+ function showTokenDetails(env) {
28
+ const tokenStore = getTokenStore(env);
29
+ const tokens = tokenStore.getOauthInfo();
15
30
  if (!tokens) {
16
- p.log.warn(pc.yellow('No tokens found. Not authenticated.'));
31
+ p.log.warn(pc.yellow(`No tokens found${formatEnvSuffix(env, ' for ')}. Not authenticated.`));
17
32
  p.note(`Run ${pc.cyan('@payloadcms/figma login')} to authenticate`, 'Tip');
18
33
  return;
19
34
  }
20
- const isValid = tokenStore.hasValidTokens();
35
+ const isValid = tokenStore.hasValidOauthToken();
21
36
  const status = isValid ? pc.green('✓ Valid') : pc.red('✗ Expired');
22
- p.log.step(pc.bold('Stored Tokens'));
37
+ p.log.step(pc.bold(`Token Status${formatEnvSuffix(env, ' (', ')')}`));
23
38
  // Build OAuth token info display
24
39
  const lines = [
25
40
  `Status: ${status}`,
@@ -41,5 +56,3 @@ import { formatTimestamp, maskToken, showProjectTokens } from '../utils/token-di
41
56
  // Show project tokens if any exist
42
57
  showProjectTokens(tokenStore);
43
58
  }
44
-
45
- //# sourceMappingURL=list-tokens.js.map
@@ -1,8 +1,14 @@
1
+ type LoginArgs = {
2
+ /** Set this to show next steps after login
3
+ * @default true
4
+ */
5
+ showNextSteps: boolean;
6
+ };
1
7
  /**
2
8
  * Handle the `@payloadcms/figma login` command
3
9
  *
4
10
  * Authenticates the user with Figma OAuth2 and stores tokens locally.
5
11
  * If valid tokens already exist, shows an error message.
6
12
  */
7
- export declare function loginCommand(): Promise<void>;
8
- //# sourceMappingURL=login.d.ts.map
13
+ export declare function loginCommand(args?: LoginArgs): Promise<void>;
14
+ export {};