@payloadcms/figma 0.0.1-alpha.5 → 0.0.1-alpha.50

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 (326) hide show
  1. package/dist/api/control-plane.d.ts +31 -1
  2. package/dist/api/control-plane.js +137 -67
  3. package/dist/api/figma-api.d.ts +20 -0
  4. package/dist/api/figma-api.js +77 -21
  5. package/dist/auth/callback-server.js +2 -1
  6. package/dist/auth/crypto-utils.js +5 -5
  7. package/dist/auth/jwt-validator.d.ts +2 -1
  8. package/dist/auth/jwt-validator.js +2 -2
  9. package/dist/auth/oauth-flow.d.ts +1 -1
  10. package/dist/auth/oauth-flow.js +15 -11
  11. package/dist/auth/project-token.js +11 -6
  12. package/dist/auth/refresh.d.ts +2 -1
  13. package/dist/auth/refresh.js +25 -12
  14. package/dist/auth/token-store.d.ts +40 -1
  15. package/dist/auth/token-store.js +65 -5
  16. package/dist/auth/types.d.ts +17 -4
  17. package/dist/cli.js +54 -6
  18. package/dist/commands/build-lambda-zip.d.ts +5 -0
  19. package/dist/commands/build-lambda-zip.js +19 -0
  20. package/dist/commands/debug.d.ts +8 -0
  21. package/dist/commands/debug.js +161 -0
  22. package/dist/commands/deploy.d.ts +6 -0
  23. package/dist/commands/deploy.js +94 -126
  24. package/dist/commands/env.d.ts +13 -0
  25. package/dist/commands/env.js +88 -0
  26. package/dist/commands/init.d.ts +3 -5
  27. package/dist/commands/init.js +118 -94
  28. package/dist/commands/list-tokens.d.ts +3 -3
  29. package/dist/commands/list-tokens.js +22 -7
  30. package/dist/commands/login.d.ts +8 -1
  31. package/dist/commands/login.js +30 -12
  32. package/dist/commands/logout.d.ts +5 -4
  33. package/dist/commands/logout.js +56 -13
  34. package/dist/config/oauth.d.ts +4 -14
  35. package/dist/config/oauth.js +18 -40
  36. package/dist/constants.d.ts +36 -19
  37. package/dist/constants.js +58 -20
  38. package/dist/db-content-api/README.md +98 -0
  39. package/dist/db-content-api/generated/content-api-types.d.ts +3746 -0
  40. package/dist/db-content-api/generated/content-api-types.js +7 -0
  41. package/dist/db-content-api/index.d.ts +20 -0
  42. package/dist/db-content-api/index.js +702 -0
  43. package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
  44. package/dist/db-content-api/temp-utilities/slug.js +3 -0
  45. package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
  46. package/dist/db-content-api/temp-utilities/sorting.js +32 -0
  47. package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
  48. package/dist/db-content-api/temp-utilities/types.js +15 -0
  49. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +34 -0
  50. package/dist/db-content-api/temp-utilities/unwrapDocument.js +53 -0
  51. package/dist/db-content-api/utilities/auth.d.ts +30 -0
  52. package/dist/db-content-api/utilities/auth.js +81 -0
  53. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
  54. package/dist/db-content-api/utilities/data/applyDefaults.js +59 -0
  55. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
  56. package/dist/db-content-api/utilities/data/castFieldValue.js +69 -0
  57. package/dist/db-content-api/utilities/data/index.d.ts +42 -0
  58. package/dist/db-content-api/utilities/data/index.js +211 -0
  59. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
  60. package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
  61. package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
  62. package/dist/db-content-api/utilities/data/stripFields.js +195 -0
  63. package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
  64. package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
  65. package/dist/db-content-api/utilities/joins.d.ts +55 -0
  66. package/dist/db-content-api/utilities/joins.js +136 -0
  67. package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
  68. package/dist/db-content-api/utilities/locale/index.js +21 -0
  69. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
  70. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +66 -0
  71. package/dist/db-content-api/utilities/meta/buildMeta.d.ts +37 -0
  72. package/dist/db-content-api/utilities/meta/buildMeta.js +33 -0
  73. package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +13 -0
  74. package/dist/db-content-api/utilities/meta/buildPathTypes.js +181 -0
  75. package/dist/db-content-api/utilities/where.d.ts +20 -0
  76. package/dist/db-content-api/utilities/where.js +127 -0
  77. package/dist/endpoints/health.d.ts +3 -0
  78. package/dist/endpoints/health.js +11 -0
  79. package/dist/endpoints/schema.d.ts +3 -0
  80. package/dist/endpoints/schema.js +29 -0
  81. package/dist/exports/client.d.ts +3 -0
  82. package/dist/exports/client.js +3 -0
  83. package/dist/index.d.ts +2 -1
  84. package/dist/index.js +3 -1
  85. package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
  86. package/dist/oauth/components/FigmaAvatar/index.js +27 -0
  87. package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
  88. package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
  89. package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
  90. package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
  91. package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
  92. package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
  93. package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
  94. package/dist/oauth/components/LoginButton/index.js +50 -6
  95. package/dist/oauth/components/LoginButton/index.scss +50 -3
  96. package/dist/oauth/components/LogoutButton/index.js +5 -4
  97. package/dist/oauth/defaults.js +67 -10
  98. package/dist/oauth/endpoints/getLoginEndpoint.js +69 -24
  99. package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
  100. package/dist/oauth/index.js +40 -5
  101. package/dist/oauth/strategy/index.d.ts +0 -2
  102. package/dist/oauth/strategy/index.js +40 -17
  103. package/dist/oauth/types.d.ts +6 -6
  104. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
  105. package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
  106. package/dist/oauth/utilities/refreshTokens.js +3 -3
  107. package/dist/plugin/build-config.d.ts +21 -14
  108. package/dist/plugin/build-config.js +208 -17
  109. package/dist/storage-content-api/api-types.d.ts +168 -0
  110. package/dist/storage-content-api/api-types.js +6 -0
  111. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
  112. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +42 -0
  113. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
  114. package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
  115. package/dist/storage-content-api/client.d.ts +6 -0
  116. package/dist/storage-content-api/client.js +36 -0
  117. package/dist/storage-content-api/generateURL.d.ts +7 -0
  118. package/dist/storage-content-api/generateURL.js +8 -0
  119. package/dist/storage-content-api/handleDelete.d.ts +8 -0
  120. package/dist/storage-content-api/handleDelete.js +17 -0
  121. package/dist/storage-content-api/handleUpload.d.ts +11 -0
  122. package/dist/storage-content-api/handleUpload.js +144 -0
  123. package/dist/storage-content-api/index.d.ts +5 -0
  124. package/dist/storage-content-api/index.js +31 -0
  125. package/dist/storage-content-api/staticHandler.d.ts +10 -0
  126. package/dist/storage-content-api/staticHandler.js +56 -0
  127. package/dist/storage-content-api/types.d.ts +10 -0
  128. package/dist/storage-content-api/types.js +3 -0
  129. package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
  130. package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
  131. package/dist/storage-content-api/utilities/index.d.ts +2 -0
  132. package/dist/storage-content-api/utilities/index.js +3 -0
  133. package/dist/templates/.env.example +5 -0
  134. package/dist/templates/README.md +19 -0
  135. package/dist/types/config.d.ts +2 -1
  136. package/dist/types/config.js +0 -2
  137. package/dist/types.d.ts +3 -1
  138. package/dist/utils/asset-collection.d.ts +3 -6
  139. package/dist/utils/asset-collection.js +10 -34
  140. package/dist/utils/build-lambda-zip.d.ts +14 -0
  141. package/dist/utils/build-lambda-zip.js +81 -0
  142. package/dist/utils/cache-bootstrap.d.ts +8 -0
  143. package/dist/utils/cache-bootstrap.js +18 -0
  144. package/dist/utils/config.js +1 -1
  145. package/dist/utils/env-management.d.ts +16 -7
  146. package/dist/utils/env-management.js +85 -64
  147. package/dist/utils/format-env-suffix.d.ts +12 -0
  148. package/dist/utils/format-env-suffix.js +13 -0
  149. package/dist/utils/formatter.js +3 -5
  150. package/dist/utils/lambda-config.d.ts +3 -1
  151. package/dist/utils/lambda-config.js +38 -32
  152. package/dist/utils/messages.d.ts +1 -1
  153. package/dist/utils/messages.js +22 -8
  154. package/dist/utils/package-manager.d.ts +24 -0
  155. package/dist/utils/package-manager.js +53 -0
  156. package/dist/utils/payload-config-ast.d.ts +22 -3
  157. package/dist/utils/payload-config-ast.js +96 -31
  158. package/dist/utils/payload-config-finder.d.ts +2 -2
  159. package/dist/utils/payload-config-finder.js +48 -9
  160. package/dist/utils/payload-config-modifier.d.ts +1 -1
  161. package/dist/utils/payload-config-modifier.js +58 -9
  162. package/dist/utils/payload-package-check.d.ts +12 -1
  163. package/dist/utils/payload-package-check.js +63 -5
  164. package/dist/utils/project.d.ts +3 -2
  165. package/dist/utils/project.js +15 -7
  166. package/dist/utils/resolve-environment.d.ts +14 -0
  167. package/dist/utils/resolve-environment.js +28 -0
  168. package/dist/utils/s3-upload.d.ts +0 -1
  169. package/dist/utils/s3-upload.js +10 -3
  170. package/dist/utils/token-display.js +11 -5
  171. package/dist/utils/typescript-validator.js +4 -6
  172. package/dist/utils/version-check.d.ts +3 -0
  173. package/dist/utils/version-check.js +38 -0
  174. package/package.json +29 -10
  175. package/dist/api/control-plane.d.ts.map +0 -1
  176. package/dist/api/control-plane.js.map +0 -1
  177. package/dist/api/figma-api.d.ts.map +0 -1
  178. package/dist/api/figma-api.js.map +0 -1
  179. package/dist/auth/browser.d.ts.map +0 -1
  180. package/dist/auth/browser.js.map +0 -1
  181. package/dist/auth/callback-server.d.ts.map +0 -1
  182. package/dist/auth/callback-server.js.map +0 -1
  183. package/dist/auth/crypto-utils.d.ts.map +0 -1
  184. package/dist/auth/crypto-utils.js.map +0 -1
  185. package/dist/auth/jwt-validator.d.ts.map +0 -1
  186. package/dist/auth/jwt-validator.js.map +0 -1
  187. package/dist/auth/oauth-flow.d.ts.map +0 -1
  188. package/dist/auth/oauth-flow.js.map +0 -1
  189. package/dist/auth/pkce.d.ts.map +0 -1
  190. package/dist/auth/pkce.js.map +0 -1
  191. package/dist/auth/project-token.d.ts.map +0 -1
  192. package/dist/auth/project-token.js.map +0 -1
  193. package/dist/auth/refresh.d.ts.map +0 -1
  194. package/dist/auth/refresh.js.map +0 -1
  195. package/dist/auth/token-store.d.ts.map +0 -1
  196. package/dist/auth/token-store.js.map +0 -1
  197. package/dist/auth/types.d.ts.map +0 -1
  198. package/dist/auth/types.js.map +0 -1
  199. package/dist/cli.d.ts.map +0 -1
  200. package/dist/cli.js.map +0 -1
  201. package/dist/commands/deploy.d.ts.map +0 -1
  202. package/dist/commands/deploy.js.map +0 -1
  203. package/dist/commands/init.d.ts.map +0 -1
  204. package/dist/commands/init.js.map +0 -1
  205. package/dist/commands/list-tokens.d.ts.map +0 -1
  206. package/dist/commands/list-tokens.js.map +0 -1
  207. package/dist/commands/login.d.ts.map +0 -1
  208. package/dist/commands/login.js.map +0 -1
  209. package/dist/commands/logout.d.ts.map +0 -1
  210. package/dist/commands/logout.js.map +0 -1
  211. package/dist/config/oauth.d.ts.map +0 -1
  212. package/dist/config/oauth.js.map +0 -1
  213. package/dist/constants.d.ts.map +0 -1
  214. package/dist/constants.js.map +0 -1
  215. package/dist/exports/client.d.ts.map +0 -1
  216. package/dist/exports/client.js.map +0 -1
  217. package/dist/index.d.ts.map +0 -1
  218. package/dist/index.js.map +0 -1
  219. package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
  220. package/dist/oauth/components/LoginButton/index.js.map +0 -1
  221. package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
  222. package/dist/oauth/components/LogoutButton/index.js.map +0 -1
  223. package/dist/oauth/defaults.d.ts.map +0 -1
  224. package/dist/oauth/defaults.js.map +0 -1
  225. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
  226. package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
  227. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
  228. package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
  229. package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
  230. package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
  231. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
  232. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
  233. package/dist/oauth/exports/client.d.ts.map +0 -1
  234. package/dist/oauth/exports/client.js.map +0 -1
  235. package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
  236. package/dist/oauth/hooks/afterLogout.js.map +0 -1
  237. package/dist/oauth/hooks/me.d.ts.map +0 -1
  238. package/dist/oauth/hooks/me.js.map +0 -1
  239. package/dist/oauth/hooks/refresh.d.ts.map +0 -1
  240. package/dist/oauth/hooks/refresh.js.map +0 -1
  241. package/dist/oauth/index.d.ts.map +0 -1
  242. package/dist/oauth/index.js.map +0 -1
  243. package/dist/oauth/strategy/index.d.ts.map +0 -1
  244. package/dist/oauth/strategy/index.js.map +0 -1
  245. package/dist/oauth/types.d.ts.map +0 -1
  246. package/dist/oauth/types.js.map +0 -1
  247. package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
  248. package/dist/oauth/utilities/clearCookie.js.map +0 -1
  249. package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
  250. package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
  251. package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
  252. package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
  253. package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
  254. package/dist/oauth/utilities/extractOrigin.js.map +0 -1
  255. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
  256. package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
  257. package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
  258. package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
  259. package/dist/oauth/utilities/getAdminPath.js +0 -9
  260. package/dist/oauth/utilities/getAdminPath.js.map +0 -1
  261. package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
  262. package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
  263. package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
  264. package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
  265. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
  266. package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
  267. package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
  268. package/dist/oauth/utilities/getTokenExp.js.map +0 -1
  269. package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
  270. package/dist/oauth/utilities/getUsernameField.js.map +0 -1
  271. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
  272. package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
  273. package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
  274. package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
  275. package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
  276. package/dist/oauth/utilities/refreshTokens.js.map +0 -1
  277. package/dist/plugin/adapter.d.ts.map +0 -1
  278. package/dist/plugin/adapter.js.map +0 -1
  279. package/dist/plugin/build-config.d.ts.map +0 -1
  280. package/dist/plugin/build-config.js.map +0 -1
  281. package/dist/types/config.d.ts.map +0 -1
  282. package/dist/types/config.js.map +0 -1
  283. package/dist/types.d.ts.map +0 -1
  284. package/dist/types.js.map +0 -1
  285. package/dist/utils/asset-collection.d.ts.map +0 -1
  286. package/dist/utils/asset-collection.js.map +0 -1
  287. package/dist/utils/build-detection.d.ts.map +0 -1
  288. package/dist/utils/build-detection.js.map +0 -1
  289. package/dist/utils/config.d.ts.map +0 -1
  290. package/dist/utils/config.js.map +0 -1
  291. package/dist/utils/download-template.d.ts.map +0 -1
  292. package/dist/utils/download-template.js.map +0 -1
  293. package/dist/utils/env-management.d.ts.map +0 -1
  294. package/dist/utils/env-management.js.map +0 -1
  295. package/dist/utils/format.d.ts.map +0 -1
  296. package/dist/utils/format.js.map +0 -1
  297. package/dist/utils/formatter.d.ts.map +0 -1
  298. package/dist/utils/formatter.js.map +0 -1
  299. package/dist/utils/git.d.ts.map +0 -1
  300. package/dist/utils/git.js.map +0 -1
  301. package/dist/utils/is-debug.d.ts.map +0 -1
  302. package/dist/utils/is-debug.js.map +0 -1
  303. package/dist/utils/lambda-config.d.ts.map +0 -1
  304. package/dist/utils/lambda-config.js.map +0 -1
  305. package/dist/utils/log.d.ts.map +0 -1
  306. package/dist/utils/log.js.map +0 -1
  307. package/dist/utils/messages.d.ts.map +0 -1
  308. package/dist/utils/messages.js.map +0 -1
  309. package/dist/utils/package-manager.d.ts.map +0 -1
  310. package/dist/utils/package-manager.js.map +0 -1
  311. package/dist/utils/payload-config-ast.d.ts.map +0 -1
  312. package/dist/utils/payload-config-ast.js.map +0 -1
  313. package/dist/utils/payload-config-finder.d.ts.map +0 -1
  314. package/dist/utils/payload-config-finder.js.map +0 -1
  315. package/dist/utils/payload-config-modifier.d.ts.map +0 -1
  316. package/dist/utils/payload-config-modifier.js.map +0 -1
  317. package/dist/utils/payload-package-check.d.ts.map +0 -1
  318. package/dist/utils/payload-package-check.js.map +0 -1
  319. package/dist/utils/project.d.ts.map +0 -1
  320. package/dist/utils/project.js.map +0 -1
  321. package/dist/utils/s3-upload.d.ts.map +0 -1
  322. package/dist/utils/s3-upload.js.map +0 -1
  323. package/dist/utils/token-display.d.ts.map +0 -1
  324. package/dist/utils/token-display.js.map +0 -1
  325. package/dist/utils/typescript-validator.d.ts.map +0 -1
  326. package/dist/utils/typescript-validator.js.map +0 -1
@@ -20,15 +20,18 @@ import * as log from './log.js';
20
20
  log.debug(`Found import from: ${payloadImport.getModuleSpecifierValue()}`);
21
21
  const moduleSpecifier = payloadImport.getModuleSpecifierValue();
22
22
  const namedImports = payloadImport.getNamedImports();
23
- // Check if buildConfig is imported
24
- const buildConfigImport = namedImports.find((ni)=>ni.getName() === 'buildConfig');
23
+ // Determine which function name to look for based on the import source
24
+ // - From 'payload': look for buildConfig (needs migration)
25
+ // - From '@payloadcms/figma': look for buildFigmaConfig (already migrated)
26
+ const expectedFunctionName = moduleSpecifier === 'payload' ? 'buildConfig' : 'buildFigmaConfig';
27
+ const buildConfigImport = namedImports.find((ni)=>ni.getName() === expectedFunctionName);
25
28
  if (!buildConfigImport) {
26
29
  result.hasBuildConfig = false;
27
30
  return result;
28
31
  }
29
32
  // Check for alias and get the actual name used in code
30
33
  const aliasNode = buildConfigImport.getAliasNode();
31
- const buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig';
34
+ const buildConfigName = aliasNode ? aliasNode.getText() : expectedFunctionName;
32
35
  if (aliasNode) {
33
36
  result.hasAlias = true;
34
37
  }
@@ -109,6 +112,15 @@ import * as log from './log.js';
109
112
  }
110
113
  }
111
114
  }
115
+ // Check for sharp property
116
+ const sharpProperty = configArg.getProperty('sharp');
117
+ if (sharpProperty) {
118
+ // Find the import source for sharp
119
+ const sharpImport = imports.find((imp)=>imp.getModuleSpecifierValue() === 'sharp' || imp.getNamedImports().some((ni)=>ni.getName() === 'sharp'));
120
+ result.sharpProperty = {
121
+ importSource: sharpImport?.getModuleSpecifierValue() || 'sharp'
122
+ };
123
+ }
112
124
  // Check for figma property
113
125
  const figmaProperty = configArg.getProperty('figma');
114
126
  if (figmaProperty) {
@@ -240,7 +252,16 @@ import * as log from './log.js';
240
252
  modified = true;
241
253
  }
242
254
  }
243
- // 4. Update buildConfig import
255
+ // 4. Remove sharp property
256
+ if (detection.sharpProperty) {
257
+ const sharpProperty = configArg.getProperty('sharp');
258
+ if (sharpProperty) {
259
+ sharpProperty.remove();
260
+ changes.push('Removed sharp property');
261
+ modified = true;
262
+ }
263
+ }
264
+ // 5. Update buildConfig import
244
265
  if (detection.needsImportChange) {
245
266
  if (payloadImport) {
246
267
  if (detection.hasOtherPayloadImports) {
@@ -258,19 +279,38 @@ import * as log from './log.js';
258
279
  sourceFile.addImportDeclaration({
259
280
  moduleSpecifier: '@payloadcms/figma',
260
281
  namedImports: [
261
- 'buildConfig'
282
+ 'buildFigmaConfig'
262
283
  ]
263
284
  });
285
+ // Rename all usages of 'buildConfig' to 'buildFigmaConfig'
286
+ const identifiers = sourceFile.getDescendantsOfKind(SyntaxKind.Identifier);
287
+ identifiers.forEach((identifier)=>{
288
+ if (identifier.getText() === 'buildConfig') {
289
+ identifier.replaceWithText('buildFigmaConfig');
290
+ }
291
+ });
264
292
  changes.push('Split buildConfig import to @payloadcms/figma');
265
293
  } else {
266
- // Replace entire import
294
+ // Replace entire import: change module specifier and rename all references
295
+ const buildConfigImport = payloadImport.getNamedImports().find((ni)=>ni.getName() === 'buildConfig');
296
+ if (buildConfigImport) {
297
+ // Change the import name
298
+ buildConfigImport.setName('buildFigmaConfig');
299
+ // Find and rename all usages of 'buildConfig' in the file
300
+ const identifiers = sourceFile.getDescendantsOfKind(SyntaxKind.Identifier);
301
+ identifiers.forEach((identifier)=>{
302
+ if (identifier.getText() === 'buildConfig') {
303
+ identifier.replaceWithText('buildFigmaConfig');
304
+ }
305
+ });
306
+ }
267
307
  payloadImport.setModuleSpecifier('@payloadcms/figma');
268
308
  changes.push('Changed buildConfig import to @payloadcms/figma');
269
309
  }
270
310
  modified = true;
271
311
  }
272
312
  }
273
- // 5. Remove orphaned imports
313
+ // 6. Remove orphaned imports
274
314
  // Re-fetch imports after each removal to avoid stale references
275
315
  if (detection.dbProperty) {
276
316
  const currentImports = sourceFile.getImportDeclarations();
@@ -290,6 +330,15 @@ import * as log from './log.js';
290
330
  modified = true;
291
331
  }
292
332
  }
333
+ if (detection.sharpProperty) {
334
+ const currentImports = sourceFile.getImportDeclarations();
335
+ const sharpImport = currentImports.find((imp)=>imp.getModuleSpecifierValue() === 'sharp');
336
+ if (sharpImport) {
337
+ sharpImport.remove();
338
+ changes.push('Removed sharp import');
339
+ modified = true;
340
+ }
341
+ }
293
342
  return {
294
343
  changes,
295
344
  modified
@@ -301,15 +350,15 @@ import * as log from './log.js';
301
350
  */ export function addFigmaProperty(sourceFile, config) {
302
351
  const changes = [];
303
352
  let modified = false;
304
- // Find buildConfig call
353
+ // Find buildFigmaConfig call (this function is only used with Figma configs)
305
354
  const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
306
355
  const buildConfigCall = callExpressions.find((ce)=>{
307
356
  const expr = ce.getExpression();
308
357
  const text = expr.getText();
309
- return text === 'buildConfig' || text.endsWith('.buildConfig');
358
+ return text === 'buildFigmaConfig' || text.endsWith('.buildFigmaConfig');
310
359
  });
311
360
  if (!buildConfigCall) {
312
- log.debug('No buildConfig call found');
361
+ log.debug('No buildFigmaConfig call found');
313
362
  return {
314
363
  changes: [],
315
364
  modified: false
@@ -336,15 +385,19 @@ import * as log from './log.js';
336
385
  };
337
386
  }
338
387
  // Add figma property
388
+ // Note: useContentSystem is optional and defaults to true, so we don't generate it during init
389
+ // contentSystemId is stored in .env file and referenced via process.env with non-null assertion
390
+ const figmaObj = config.useContentSystem === false ? `{
391
+ contentSystemId: process.env.FIGMA_CONTENT_API_CONTENT_SYSTEM_ID!,
392
+ useContentSystem: false,
393
+ }` : `{
394
+ contentSystemId: process.env.FIGMA_CONTENT_API_CONTENT_SYSTEM_ID!,
395
+ }`;
339
396
  configArg.addPropertyAssignment({
340
397
  name: 'figma',
341
- initializer: `{
342
- region: '${config.region}',
343
- tenantId: '${config.tenantId}',
344
- useContentSystem: ${config.useContentSystem},
345
- }`
398
+ initializer: figmaObj
346
399
  });
347
- changes.push(`Added figma property (region: ${config.region}, tenantId: ${config.tenantId}, useContentSystem: ${config.useContentSystem})`);
400
+ changes.push(`Added figma property (contentSystemId: ${config.contentSystemId})`);
348
401
  modified = true;
349
402
  return {
350
403
  changes,
@@ -355,15 +408,15 @@ import * as log from './log.js';
355
408
  * Read figma configuration from payload.config.ts
356
409
  * Returns the figma object if it exists, null otherwise
357
410
  */ export function readFigmaConfig(sourceFile) {
358
- // Find buildConfig call
411
+ // Find buildFigmaConfig call (this function is only used with Figma configs)
359
412
  const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
360
413
  const buildConfigCall = callExpressions.find((ce)=>{
361
414
  const expr = ce.getExpression();
362
415
  const text = expr.getText();
363
- return text === 'buildConfig' || text.endsWith('.buildConfig');
416
+ return text === 'buildFigmaConfig' || text.endsWith('.buildFigmaConfig');
364
417
  });
365
418
  if (!buildConfigCall) {
366
- log.debug('No buildConfig call found');
419
+ log.debug('No buildFigmaConfig call found');
367
420
  return null;
368
421
  }
369
422
  // Get config object argument
@@ -385,25 +438,37 @@ import * as log from './log.js';
385
438
  return null;
386
439
  }
387
440
  // Extract values
388
- const regionProp = initializer.getProperty('region');
389
- const tenantIdProp = initializer.getProperty('tenantId');
441
+ const contentSystemIdProp = initializer.getProperty('contentSystemId');
390
442
  const useContentSystemProp = initializer.getProperty('useContentSystem');
391
- if (!regionProp || !tenantIdProp) {
392
- log.debug('Missing required figma properties (region or tenantId)');
443
+ if (!contentSystemIdProp) {
444
+ log.debug('Missing required figma property: contentSystemId');
393
445
  return null;
394
446
  }
395
- // Extract string values (remove quotes)
396
- const region = Node.isPropertyAssignment(regionProp) ? regionProp.getInitializer()?.getText().replace(/['"]/g, '') : undefined;
397
- const tenantId = Node.isPropertyAssignment(tenantIdProp) ? tenantIdProp.getInitializer()?.getText().replace(/['"]/g, '') : undefined;
398
- const useContentSystem = Node.isPropertyAssignment(useContentSystemProp) ? useContentSystemProp.getInitializer()?.getText() === 'true' : true // Default to true if not specified
447
+ // Extract contentSystemId - support both literal strings and env var references
448
+ let contentSystemId;
449
+ if (Node.isPropertyAssignment(contentSystemIdProp)) {
450
+ const initializer = contentSystemIdProp.getInitializer();
451
+ const text = initializer?.getText() || '';
452
+ // Support both patterns:
453
+ // 1. Literal string: 'cms_abc123' or "cms_abc123"
454
+ // 2. Environment variable: process.env.FIGMA_CONTENT_API_CONTENT_SYSTEM_ID
455
+ if (text.includes('process.env.FIGMA_CONTENT_API_CONTENT_SYSTEM_ID')) {
456
+ // For env var reference, return a marker that indicates it's from env
457
+ // The actual value will be read at runtime
458
+ contentSystemId = 'process.env.FIGMA_CONTENT_API_CONTENT_SYSTEM_ID';
459
+ } else {
460
+ // Remove quotes for literal strings
461
+ contentSystemId = text.replace(/['"]/g, '');
462
+ }
463
+ }
464
+ const useContentSystem = Node.isPropertyAssignment(useContentSystemProp) ? useContentSystemProp.getInitializer()?.getText() === 'true' : undefined // Optional: undefined if not specified
399
465
  ;
400
- if (!region || !tenantId) {
401
- log.debug('Could not extract region or tenantId values');
466
+ if (!contentSystemId) {
467
+ log.debug('Could not extract contentSystemId value');
402
468
  return null;
403
469
  }
404
470
  return {
405
- region,
406
- tenantId,
471
+ contentSystemId,
407
472
  useContentSystem
408
473
  };
409
474
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Find the Payload config file using Payload's built-in finder
3
- * Changes to project directory temporarily and restores afterward
2
+ * Find the Payload config file using Payload's built-in finder when available,
3
+ * with fallback to simple file search for npx environments where payload isn't installed.
4
4
  *
5
5
  * @param projectPath - Absolute path to project directory
6
6
  * @returns Absolute path to config file, or null if not found
@@ -1,26 +1,65 @@
1
- import { findConfig } from 'payload/node';
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import * as log from './log.js';
4
+ // Standard Payload config file names in priority order
5
+ const CONFIG_FILES = [
6
+ 'payload.config.ts',
7
+ 'payload.config.js',
8
+ 'src/payload.config.ts',
9
+ 'src/payload.config.js'
10
+ ];
2
11
  /**
3
- * Find the Payload config file using Payload's built-in finder
4
- * Changes to project directory temporarily and restores afterward
12
+ * Find the Payload config file using Payload's built-in finder when available,
13
+ * with fallback to simple file search for npx environments where payload isn't installed.
5
14
  *
6
15
  * @param projectPath - Absolute path to project directory
7
16
  * @returns Absolute path to config file, or null if not found
8
17
  */ export async function findPayloadConfig(projectPath) {
18
+ // First, try using Payload's official config finder (if payload is installed)
19
+ const configFromPayload = await findConfigWithPayload(projectPath);
20
+ if (configFromPayload) {
21
+ return configFromPayload;
22
+ }
23
+ // Fallback: Simple file search for standard config locations
24
+ // This works when running via npx before payload is installed
25
+ log.debug('Payload not available, using fallback config finder');
26
+ return findConfigFallback(projectPath);
27
+ }
28
+ /**
29
+ * Try to find config using Payload's findConfig function.
30
+ * Returns null if payload is not installed (dynamic import fails).
31
+ */ async function findConfigWithPayload(projectPath) {
9
32
  const originalCwd = process.cwd();
10
33
  try {
34
+ // Dynamic import - will fail gracefully if payload is not installed
35
+ const { findConfig } = await import('payload/node');
11
36
  // findConfig requires being in the project directory
12
37
  process.chdir(projectPath);
13
- // Use Payload's official config finder
14
38
  const configPath = findConfig();
15
- // Wrap in Promise.resolve to satisfy async requirement
16
- return await Promise.resolve(configPath || null);
17
- } catch {
18
- // Config not found or error occurred
39
+ return configPath || null;
40
+ } catch (error) {
41
+ // payload not installed or other error - return null to use fallback
42
+ log.debug(`Could not use Payload findConfig: ${error instanceof Error ? error.message : 'unknown'}`);
19
43
  return null;
20
44
  } finally{
21
- // Always restore original working directory
22
45
  process.chdir(originalCwd);
23
46
  }
24
47
  }
48
+ /**
49
+ * Fallback config finder that checks standard locations.
50
+ * Used when payload is not installed (e.g., running via npx).
51
+ */ async function findConfigFallback(projectPath) {
52
+ for (const configFile of CONFIG_FILES){
53
+ const fullPath = path.join(projectPath, configFile);
54
+ try {
55
+ await fs.access(fullPath);
56
+ log.debug(`Found config at: ${fullPath}`);
57
+ return fullPath;
58
+ } catch {
59
+ // File doesn't exist, try next
60
+ }
61
+ }
62
+ return null;
63
+ }
25
64
 
26
65
  //# sourceMappingURL=payload-config-finder.js.map
@@ -15,5 +15,5 @@ export declare function ensurePayloadFigmaConfig(projectPath: string, packageMan
15
15
  /**
16
16
  * Display manual configuration instructions
17
17
  */
18
- export declare function displayManualInstructions(reason: string): void;
18
+ export declare function displayManualInstructions(reason: string, packageManager?: PackageManager): void;
19
19
  //# sourceMappingURL=payload-config-modifier.d.ts.map
@@ -2,9 +2,10 @@ import pc from 'picocolors';
2
2
  import { Project } from 'ts-morph';
3
3
  import { formatFile } from './formatter.js';
4
4
  import * as log from './log.js';
5
+ import { getAddCommand, getRunCommand } from './package-manager.js';
5
6
  import { addFigmaProperty, applyModifications, detectRequiredChanges } from './payload-config-ast.js';
6
7
  import { findPayloadConfig } from './payload-config-finder.js';
7
- import { checkPackageInstalled, installPackage, uninstallPackage } from './payload-package-check.js';
8
+ import { checkPackageInstalled, getPayloadVersion, installPackage, uninstallPackage } from './payload-package-check.js';
8
9
  import { runTypeScriptCheck } from './typescript-validator.js';
9
10
  /**
10
11
  * Main orchestrator for payload config modification
@@ -27,6 +28,9 @@ import { runTypeScriptCheck } from './typescript-validator.js';
27
28
  };
28
29
  }
29
30
  log.debug(`Found config file: ${configPath}`);
31
+ // Get payload version to pin @payloadcms/* dependencies
32
+ const payloadVersion = await getPayloadVersion(projectPath);
33
+ log.debug(`Detected payload version: ${payloadVersion || 'unknown'}`);
30
34
  // 2. Check/install @payloadcms/figma package
31
35
  const isInstalled = await checkPackageInstalled(projectPath, '@payloadcms/figma');
32
36
  if (!isInstalled) {
@@ -103,13 +107,58 @@ import { runTypeScriptCheck } from './typescript-validator.js';
103
107
  if (modified) {
104
108
  await sourceFile.save();
105
109
  log.debug('Config file saved');
106
- // 7. Uninstall orphaned packages
110
+ // 7. Handle package management
107
111
  const packagesToUninstall = [];
112
+ // Uninstall db adapter (buildFigmaConfig provides its own)
108
113
  if (detection.dbProperty) {
109
114
  packagesToUninstall.push(detection.dbProperty.importSource);
110
115
  }
111
- if (detection.editorProperty?.isDefault) {
112
- packagesToUninstall.push(detection.editorProperty.importSource);
116
+ // Uninstall sharp (Figma infrastructure handles image processing)
117
+ if (detection.sharpProperty) {
118
+ packagesToUninstall.push('sharp');
119
+ }
120
+ // Ensure lexical is installed if user doesn't have a custom editor
121
+ // (buildFigmaConfig uses lexicalEditor() as default)
122
+ if (!detection.editorProperty) {
123
+ log.debug('No editor property detected - will ensure lexical is installed for default editor');
124
+ } else if (detection.editorProperty.isDefault) {
125
+ log.debug('Default lexicalEditor() detected - will ensure lexical is installed');
126
+ } else {
127
+ log.debug(`Custom editor detected (${detection.editorProperty.importSource}) - skipping lexical installation`);
128
+ }
129
+ if (!detection.editorProperty || detection.editorProperty.isDefault) {
130
+ log.debug('Checking if @payloadcms/richtext-lexical is installed...');
131
+ const hasLexical = await checkPackageInstalled(projectPath, '@payloadcms/richtext-lexical');
132
+ if (!hasLexical) {
133
+ log.debug('@payloadcms/richtext-lexical not found, installing...');
134
+ try {
135
+ await installPackage(projectPath, '@payloadcms/richtext-lexical', packageManager, payloadVersion);
136
+ changes.push('Installed @payloadcms/richtext-lexical (default editor)');
137
+ log.debug('Successfully installed @payloadcms/richtext-lexical');
138
+ } catch (error) {
139
+ log.debug(`Failed to install @payloadcms/richtext-lexical: ${error instanceof Error ? error.message : 'Unknown error'}`);
140
+ // Don't fail on install error - user can install manually if needed
141
+ warnings.push('Could not install @payloadcms/richtext-lexical - you may need to install it manually');
142
+ }
143
+ } else {
144
+ log.debug('@payloadcms/richtext-lexical already installed, skipping');
145
+ }
146
+ }
147
+ // Ensure cloud-storage is installed (required peer dependency for buildFigmaConfig)
148
+ log.debug('Checking if @payloadcms/plugin-cloud-storage is installed...');
149
+ const hasCloudStorage = await checkPackageInstalled(projectPath, '@payloadcms/plugin-cloud-storage');
150
+ if (!hasCloudStorage) {
151
+ log.debug('@payloadcms/plugin-cloud-storage not found, installing...');
152
+ try {
153
+ await installPackage(projectPath, '@payloadcms/plugin-cloud-storage', packageManager, payloadVersion);
154
+ changes.push('Installed @payloadcms/plugin-cloud-storage');
155
+ log.debug('Successfully installed @payloadcms/plugin-cloud-storage');
156
+ } catch (error) {
157
+ log.debug(`Failed to install @payloadcms/plugin-cloud-storage: ${error instanceof Error ? error.message : 'Unknown error'}`);
158
+ warnings.push('Could not install @payloadcms/plugin-cloud-storage - you may need to install it manually');
159
+ }
160
+ } else {
161
+ log.debug('@payloadcms/plugin-cloud-storage already installed, skipping');
113
162
  }
114
163
  if (packagesToUninstall.length > 0) {
115
164
  log.debug(`Uninstalling ${packagesToUninstall.length} orphaned packages...`);
@@ -135,7 +184,7 @@ import { runTypeScriptCheck } from './typescript-validator.js';
135
184
  log.debug('Running TypeScript validation...');
136
185
  const tsResult = await runTypeScriptCheck(projectPath, packageManager);
137
186
  if (!tsResult.success && tsResult.errors.length > 0) {
138
- warnings.push("TypeScript validation found issues - run 'pnpm build' for details");
187
+ warnings.push(`TypeScript validation found issues - run '${getRunCommand(packageManager)} build' for details`);
139
188
  log.debug(`TypeScript validation found ${tsResult.errors.length} issues`);
140
189
  }
141
190
  } else {
@@ -163,10 +212,10 @@ import { runTypeScriptCheck } from './typescript-validator.js';
163
212
  }
164
213
  /**
165
214
  * Display manual configuration instructions
166
- */ export function displayManualInstructions(reason) {
215
+ */ export function displayManualInstructions(reason, packageManager = 'npm') {
167
216
  const leftLineWrap = (message)=>{
168
217
  // Add '┌ ' prefix to first line, '│ ' to subsequent lines, and '└ ' to last line
169
- return message.split('\n').map((line, index, arr)=>{
218
+ return message.split(/\r?\n/).map((line, index, arr)=>{
170
219
  if (index === 0) {
171
220
  return `${pc.dim('┌ ')}${line}`;
172
221
  } else if (index === arr.length - 1) {
@@ -185,7 +234,7 @@ ${pc.bold('Required changes:')}
185
234
 
186
235
  1. Replace buildConfig import:
187
236
  ${pc.dim('- FROM: ')}${pc.cyan("import { buildConfig } from 'payload'")}
188
- ${pc.dim('- TO: ')}${pc.cyan("import { buildConfig } from '@payloadcms/figma'")}
237
+ ${pc.dim('- TO: ')}${pc.cyan("import { buildFigmaConfig } from '@payloadcms/figma'")}
189
238
 
190
239
  2. Remove these properties from buildConfig():
191
240
  • db
@@ -193,7 +242,7 @@ ${pc.bold('Required changes:')}
193
242
  • editor (if using default lexicalEditor())
194
243
 
195
244
  3. Install package:
196
- ${pc.cyan('pnpm add @payloadcms/figma')}
245
+ ${pc.cyan(`${getAddCommand(packageManager)} @payloadcms/figma`)}
197
246
 
198
247
  Then run: ${pc.cyan('npx @payloadcms/figma init')}`);
199
248
  // eslint-disable-next-line no-console
@@ -3,13 +3,24 @@ import type { PackageManager } from './package-manager.js';
3
3
  * Check if a package is installed in dependencies (not devDependencies)
4
4
  */
5
5
  export declare function checkPackageInstalled(projectPath: string, packageName: string): Promise<boolean>;
6
+ /**
7
+ * Get the payload version from project's package.json (without range specifiers)
8
+ * Returns the clean version number (e.g., "3.71.1") or undefined if not found
9
+ */
10
+ export declare function getPayloadVersion(projectPath: string): Promise<string | undefined>;
6
11
  /**
7
12
  * Install a package as a production dependency
13
+ * @param version - Version to install (without caret). Defaults to 'latest'.
8
14
  */
9
- export declare function installPackage(projectPath: string, packageName: string, packageManager: PackageManager): Promise<void>;
15
+ export declare function installPackage(projectPath: string, packageName: string, packageManager: PackageManager, version?: string): Promise<void>;
10
16
  /**
11
17
  * Uninstall a package
12
18
  * Does not throw on failure - orphaned package is better than broken config
13
19
  */
14
20
  export declare function uninstallPackage(projectPath: string, packageName: string, packageManager: PackageManager): Promise<void>;
21
+ /**
22
+ * Run an npm script from package.json
23
+ * Does not throw on failure - logs warning and continues
24
+ */
25
+ export declare function runScript(projectPath: string, scriptName: string, packageManager: PackageManager): Promise<boolean>;
15
26
  //# sourceMappingURL=payload-package-check.d.ts.map
@@ -1,4 +1,4 @@
1
- import { spawn } from 'child_process';
1
+ import spawn from 'cross-spawn';
2
2
  import fs from 'fs/promises';
3
3
  import path from 'path';
4
4
  import * as log from './log.js';
@@ -18,14 +18,34 @@ import * as log from './log.js';
18
18
  return false;
19
19
  }
20
20
  }
21
+ /**
22
+ * Get the payload version from project's package.json (without range specifiers)
23
+ * Returns the clean version number (e.g., "3.71.1") or undefined if not found
24
+ */ export async function getPayloadVersion(projectPath) {
25
+ try {
26
+ const pkgJsonPath = path.join(projectPath, 'package.json');
27
+ const pkgJsonContent = await fs.readFile(pkgJsonPath, 'utf-8');
28
+ const pkgJson = JSON.parse(pkgJsonContent);
29
+ const rawVersion = pkgJson.dependencies?.payload || pkgJson.devDependencies?.payload;
30
+ if (!rawVersion) {
31
+ return undefined;
32
+ }
33
+ // Strip range specifiers (^, ~, >=, etc.) to get clean version
34
+ return rawVersion.replace(/^[\^~>=<]+/, '');
35
+ } catch {
36
+ return undefined;
37
+ }
38
+ }
21
39
  /**
22
40
  * Install a package as a production dependency
23
- */ export async function installPackage(projectPath, packageName, packageManager) {
41
+ * @param version - Version to install (without caret). Defaults to 'latest'.
42
+ */ export async function installPackage(projectPath, packageName, packageManager, version = 'latest') {
24
43
  return new Promise((resolve, reject)=>{
25
44
  const command = packageManager;
45
+ const packageSpec = `${packageName}@${version}`;
26
46
  const args = [
27
47
  'add',
28
- packageName
48
+ packageSpec
29
49
  ];
30
50
  // npm uses 'install' instead of 'add'
31
51
  if (packageManager === 'npm') {
@@ -35,7 +55,6 @@ import * as log from './log.js';
35
55
  let stderr = '';
36
56
  const child = spawn(command, args, {
37
57
  cwd: projectPath,
38
- shell: true,
39
58
  stdio: 'pipe'
40
59
  });
41
60
  // Capture stderr for debug logging
@@ -79,7 +98,6 @@ import * as log from './log.js';
79
98
  log.debug(`Running: ${command} ${args.join(' ')} in ${projectPath}`);
80
99
  const child = spawn(command, args, {
81
100
  cwd: projectPath,
82
- shell: true,
83
101
  stdio: 'pipe'
84
102
  });
85
103
  child.on('close', (code)=>{
@@ -93,5 +111,45 @@ import * as log from './log.js';
93
111
  });
94
112
  });
95
113
  }
114
+ /**
115
+ * Run an npm script from package.json
116
+ * Does not throw on failure - logs warning and continues
117
+ */ export async function runScript(projectPath, scriptName, packageManager) {
118
+ return new Promise((resolve)=>{
119
+ const command = packageManager;
120
+ // yarn doesn't need 'run' prefix, but it works with it too
121
+ const args = [
122
+ 'run',
123
+ scriptName
124
+ ];
125
+ log.debug(`Running script: ${command} ${args.join(' ')} in ${projectPath}`);
126
+ let stderr = '';
127
+ const child = spawn(command, args, {
128
+ cwd: projectPath,
129
+ stdio: 'pipe'
130
+ });
131
+ if (child.stderr) {
132
+ child.stderr.on('data', (data)=>{
133
+ stderr += data.toString();
134
+ });
135
+ }
136
+ child.on('error', (error)=>{
137
+ log.debug(`Failed to run script ${scriptName}: ${error.message}`);
138
+ resolve(false);
139
+ });
140
+ child.on('close', (code)=>{
141
+ if (code === 0) {
142
+ log.debug(`Successfully ran script: ${scriptName}`);
143
+ resolve(true);
144
+ } else {
145
+ log.debug(`Script ${scriptName} failed (exit code: ${code})`);
146
+ if (stderr) {
147
+ log.debug(`stderr: ${stderr}`);
148
+ }
149
+ resolve(false);
150
+ }
151
+ });
152
+ });
153
+ }
96
154
 
97
155
  //# sourceMappingURL=payload-package-check.js.map
@@ -2,6 +2,7 @@
2
2
  * Project detection and scaffolding utilities
3
3
  */
4
4
  import type { ProjectInfo } from '../types/config.js';
5
+ import type { PackageManager } from './package-manager.js';
5
6
  /**
6
7
  * Detect if current directory has a Payload project
7
8
  *
@@ -22,7 +23,7 @@ export declare function validatePayloadVersion(version: string): boolean;
22
23
  * @param projectPath - Path where to create the project
23
24
  * @param projectName - Name for the project
24
25
  */
25
- export declare function scaffoldProject(projectPath: string, projectName: string): Promise<void>;
26
+ export declare function scaffoldProject(projectPath: string, projectName: string, packageManager?: PackageManager): Promise<void>;
26
27
  /**
27
28
  * Initialize git repository after all setup is complete
28
29
  *
@@ -38,7 +39,7 @@ export declare function initializeGitRepo(projectPath: string): void;
38
39
  * @param packageManager - Package manager to use
39
40
  * @returns Promise that resolves when installation completes
40
41
  */
41
- export declare function installDependencies(projectPath: string, packageManager?: 'npm' | 'pnpm' | 'yarn'): Promise<void>;
42
+ export declare function installDependencies(projectPath: string, packageManager?: PackageManager): Promise<void>;
42
43
  /**
43
44
  * Check if required dependencies are installed
44
45
  *