@payloadcms/figma 0.0.1-alpha.4 → 0.0.1-alpha.40

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 (269) hide show
  1. package/dist/api/control-plane.d.ts +22 -1
  2. package/dist/api/control-plane.d.ts.map +1 -1
  3. package/dist/api/control-plane.js +55 -22
  4. package/dist/api/control-plane.js.map +1 -1
  5. package/dist/api/figma-api.d.ts.map +1 -1
  6. package/dist/api/figma-api.js +45 -26
  7. package/dist/api/figma-api.js.map +1 -1
  8. package/dist/auth/callback-server.d.ts.map +1 -1
  9. package/dist/auth/callback-server.js +2 -1
  10. package/dist/auth/callback-server.js.map +1 -1
  11. package/dist/auth/crypto-utils.d.ts.map +1 -1
  12. package/dist/auth/crypto-utils.js +5 -5
  13. package/dist/auth/crypto-utils.js.map +1 -1
  14. package/dist/auth/jwt-validator.d.ts +2 -1
  15. package/dist/auth/jwt-validator.d.ts.map +1 -1
  16. package/dist/auth/jwt-validator.js +2 -2
  17. package/dist/auth/jwt-validator.js.map +1 -1
  18. package/dist/auth/oauth-flow.d.ts +1 -1
  19. package/dist/auth/oauth-flow.d.ts.map +1 -1
  20. package/dist/auth/oauth-flow.js +9 -8
  21. package/dist/auth/oauth-flow.js.map +1 -1
  22. package/dist/auth/project-token.d.ts.map +1 -1
  23. package/dist/auth/project-token.js +9 -4
  24. package/dist/auth/project-token.js.map +1 -1
  25. package/dist/auth/refresh.d.ts.map +1 -1
  26. package/dist/auth/refresh.js +14 -9
  27. package/dist/auth/refresh.js.map +1 -1
  28. package/dist/auth/token-store.d.ts +10 -0
  29. package/dist/auth/token-store.d.ts.map +1 -1
  30. package/dist/auth/token-store.js +20 -0
  31. package/dist/auth/token-store.js.map +1 -1
  32. package/dist/cli.d.ts.map +1 -1
  33. package/dist/cli.js +31 -0
  34. package/dist/cli.js.map +1 -1
  35. package/dist/commands/build-lambda-zip.d.ts +5 -0
  36. package/dist/commands/build-lambda-zip.d.ts.map +1 -0
  37. package/dist/commands/build-lambda-zip.js +19 -0
  38. package/dist/commands/build-lambda-zip.js.map +1 -0
  39. package/dist/commands/deploy.d.ts +4 -0
  40. package/dist/commands/deploy.d.ts.map +1 -1
  41. package/dist/commands/deploy.js +71 -129
  42. package/dist/commands/deploy.js.map +1 -1
  43. package/dist/commands/init.d.ts +1 -5
  44. package/dist/commands/init.d.ts.map +1 -1
  45. package/dist/commands/init.js +94 -85
  46. package/dist/commands/init.js.map +1 -1
  47. package/dist/commands/list-tokens.d.ts.map +1 -1
  48. package/dist/commands/list-tokens.js +6 -3
  49. package/dist/commands/list-tokens.js.map +1 -1
  50. package/dist/commands/login.d.ts +8 -1
  51. package/dist/commands/login.d.ts.map +1 -1
  52. package/dist/commands/login.js +21 -11
  53. package/dist/commands/login.js.map +1 -1
  54. package/dist/commands/logout.js +2 -2
  55. package/dist/commands/logout.js.map +1 -1
  56. package/dist/config/oauth.d.ts +4 -14
  57. package/dist/config/oauth.d.ts.map +1 -1
  58. package/dist/config/oauth.js +19 -40
  59. package/dist/config/oauth.js.map +1 -1
  60. package/dist/constants.d.ts +26 -18
  61. package/dist/constants.d.ts.map +1 -1
  62. package/dist/constants.js +34 -20
  63. package/dist/constants.js.map +1 -1
  64. package/dist/db-content-api/README.md +98 -0
  65. package/dist/db-content-api/generated/content-api-types.d.ts +3848 -0
  66. package/dist/db-content-api/generated/content-api-types.d.ts.map +1 -0
  67. package/dist/db-content-api/generated/content-api-types.js +7 -0
  68. package/dist/db-content-api/generated/content-api-types.js.map +1 -0
  69. package/dist/db-content-api/index.d.ts +18 -0
  70. package/dist/db-content-api/index.d.ts.map +1 -0
  71. package/dist/db-content-api/index.js +571 -0
  72. package/dist/db-content-api/index.js.map +1 -0
  73. package/dist/db-content-api/temp-utilities/pagination.d.ts +13 -0
  74. package/dist/db-content-api/temp-utilities/pagination.d.ts.map +1 -0
  75. package/dist/db-content-api/temp-utilities/pagination.js +45 -0
  76. package/dist/db-content-api/temp-utilities/pagination.js.map +1 -0
  77. package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
  78. package/dist/db-content-api/temp-utilities/slug.d.ts.map +1 -0
  79. package/dist/db-content-api/temp-utilities/slug.js +3 -0
  80. package/dist/db-content-api/temp-utilities/slug.js.map +1 -0
  81. package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
  82. package/dist/db-content-api/temp-utilities/sorting.d.ts.map +1 -0
  83. package/dist/db-content-api/temp-utilities/sorting.js +32 -0
  84. package/dist/db-content-api/temp-utilities/sorting.js.map +1 -0
  85. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +4 -0
  86. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts.map +1 -0
  87. package/dist/db-content-api/temp-utilities/unwrapDocument.js +53 -0
  88. package/dist/db-content-api/temp-utilities/unwrapDocument.js.map +1 -0
  89. package/dist/db-content-api/utilities/auth.d.ts +30 -0
  90. package/dist/db-content-api/utilities/auth.d.ts.map +1 -0
  91. package/dist/db-content-api/utilities/auth.js +81 -0
  92. package/dist/db-content-api/utilities/auth.js.map +1 -0
  93. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
  94. package/dist/db-content-api/utilities/data/applyDefaults.d.ts.map +1 -0
  95. package/dist/db-content-api/utilities/data/applyDefaults.js +59 -0
  96. package/dist/db-content-api/utilities/data/applyDefaults.js.map +1 -0
  97. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
  98. package/dist/db-content-api/utilities/data/castFieldValue.d.ts.map +1 -0
  99. package/dist/db-content-api/utilities/data/castFieldValue.js +66 -0
  100. package/dist/db-content-api/utilities/data/castFieldValue.js.map +1 -0
  101. package/dist/db-content-api/utilities/data/index.d.ts +30 -0
  102. package/dist/db-content-api/utilities/data/index.d.ts.map +1 -0
  103. package/dist/db-content-api/utilities/data/index.js +173 -0
  104. package/dist/db-content-api/utilities/data/index.js.map +1 -0
  105. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
  106. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts.map +1 -0
  107. package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
  108. package/dist/db-content-api/utilities/data/removeVirtualFields.js.map +1 -0
  109. package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
  110. package/dist/db-content-api/utilities/data/stripFields.d.ts.map +1 -0
  111. package/dist/db-content-api/utilities/data/stripFields.js +195 -0
  112. package/dist/db-content-api/utilities/data/stripFields.js.map +1 -0
  113. package/dist/db-content-api/utilities/joins.d.ts +55 -0
  114. package/dist/db-content-api/utilities/joins.d.ts.map +1 -0
  115. package/dist/db-content-api/utilities/joins.js +136 -0
  116. package/dist/db-content-api/utilities/joins.js.map +1 -0
  117. package/dist/db-content-api/utilities/where.d.ts +12 -0
  118. package/dist/db-content-api/utilities/where.d.ts.map +1 -0
  119. package/dist/db-content-api/utilities/where.js +107 -0
  120. package/dist/db-content-api/utilities/where.js.map +1 -0
  121. package/dist/endpoints/health.d.ts +3 -0
  122. package/dist/endpoints/health.d.ts.map +1 -0
  123. package/dist/endpoints/health.js +11 -0
  124. package/dist/endpoints/health.js.map +1 -0
  125. package/dist/exports/client.d.ts +4 -0
  126. package/dist/exports/client.d.ts.map +1 -0
  127. package/dist/exports/client.js +5 -0
  128. package/dist/exports/client.js.map +1 -0
  129. package/dist/index.d.ts +2 -1
  130. package/dist/index.d.ts.map +1 -1
  131. package/dist/index.js +3 -1
  132. package/dist/index.js.map +1 -1
  133. package/dist/oauth/components/LoginButton/index.d.ts.map +1 -1
  134. package/dist/oauth/components/LoginButton/index.js +50 -6
  135. package/dist/oauth/components/LoginButton/index.js.map +1 -1
  136. package/dist/oauth/components/LoginButton/index.scss +50 -3
  137. package/dist/oauth/components/LogoutButton/index.d.ts.map +1 -1
  138. package/dist/oauth/components/LogoutButton/index.js +0 -1
  139. package/dist/oauth/components/LogoutButton/index.js.map +1 -1
  140. package/dist/oauth/defaults.d.ts.map +1 -1
  141. package/dist/oauth/defaults.js +29 -5
  142. package/dist/oauth/defaults.js.map +1 -1
  143. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
  144. package/dist/oauth/endpoints/getLoginEndpoint.js +4 -4
  145. package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
  146. package/dist/oauth/index.d.ts.map +1 -1
  147. package/dist/oauth/index.js +42 -7
  148. package/dist/oauth/index.js.map +1 -1
  149. package/dist/oauth/strategy/index.d.ts +0 -2
  150. package/dist/oauth/strategy/index.d.ts.map +1 -1
  151. package/dist/oauth/strategy/index.js +38 -15
  152. package/dist/oauth/strategy/index.js.map +1 -1
  153. package/dist/oauth/types.d.ts +6 -6
  154. package/dist/oauth/types.d.ts.map +1 -1
  155. package/dist/oauth/types.js.map +1 -1
  156. package/dist/oauth/utilities/createCookieOptions.d.ts.map +1 -1
  157. package/dist/oauth/utilities/createCookieOptions.js.map +1 -1
  158. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
  159. package/dist/oauth/utilities/isDuplicateKeyError.d.ts.map +1 -0
  160. package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
  161. package/dist/oauth/utilities/isDuplicateKeyError.js.map +1 -0
  162. package/dist/oauth/utilities/refreshTokens.d.ts.map +1 -1
  163. package/dist/oauth/utilities/refreshTokens.js +1 -1
  164. package/dist/oauth/utilities/refreshTokens.js.map +1 -1
  165. package/dist/plugin/build-config.d.ts +21 -4
  166. package/dist/plugin/build-config.d.ts.map +1 -1
  167. package/dist/plugin/build-config.js +114 -8
  168. package/dist/plugin/build-config.js.map +1 -1
  169. package/dist/storage-content-api/api-types.d.ts +161 -0
  170. package/dist/storage-content-api/api-types.d.ts.map +1 -0
  171. package/dist/storage-content-api/api-types.js +6 -0
  172. package/dist/storage-content-api/api-types.js.map +1 -0
  173. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
  174. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts.map +1 -0
  175. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +42 -0
  176. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js.map +1 -0
  177. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
  178. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts.map +1 -0
  179. package/dist/storage-content-api/client-uploads/generateSignedURL.js +31 -0
  180. package/dist/storage-content-api/client-uploads/generateSignedURL.js.map +1 -0
  181. package/dist/storage-content-api/client.d.ts +6 -0
  182. package/dist/storage-content-api/client.d.ts.map +1 -0
  183. package/dist/storage-content-api/client.js +36 -0
  184. package/dist/storage-content-api/client.js.map +1 -0
  185. package/dist/storage-content-api/generateURL.d.ts +7 -0
  186. package/dist/storage-content-api/generateURL.d.ts.map +1 -0
  187. package/dist/storage-content-api/generateURL.js +7 -0
  188. package/dist/storage-content-api/generateURL.js.map +1 -0
  189. package/dist/storage-content-api/handleDelete.d.ts +8 -0
  190. package/dist/storage-content-api/handleDelete.d.ts.map +1 -0
  191. package/dist/storage-content-api/handleDelete.js +15 -0
  192. package/dist/storage-content-api/handleDelete.js.map +1 -0
  193. package/dist/storage-content-api/handleUpload.d.ts +11 -0
  194. package/dist/storage-content-api/handleUpload.d.ts.map +1 -0
  195. package/dist/storage-content-api/handleUpload.js +136 -0
  196. package/dist/storage-content-api/handleUpload.js.map +1 -0
  197. package/dist/storage-content-api/index.d.ts +5 -0
  198. package/dist/storage-content-api/index.d.ts.map +1 -0
  199. package/dist/storage-content-api/index.js +31 -0
  200. package/dist/storage-content-api/index.js.map +1 -0
  201. package/dist/storage-content-api/staticHandler.d.ts +10 -0
  202. package/dist/storage-content-api/staticHandler.d.ts.map +1 -0
  203. package/dist/storage-content-api/staticHandler.js +55 -0
  204. package/dist/storage-content-api/staticHandler.js.map +1 -0
  205. package/dist/storage-content-api/types.d.ts +10 -0
  206. package/dist/storage-content-api/types.d.ts.map +1 -0
  207. package/dist/storage-content-api/types.js +3 -0
  208. package/dist/storage-content-api/types.js.map +1 -0
  209. package/dist/templates/README.md +19 -0
  210. package/dist/types.d.ts +1 -0
  211. package/dist/types.d.ts.map +1 -1
  212. package/dist/types.js.map +1 -1
  213. package/dist/utils/asset-collection.d.ts +3 -6
  214. package/dist/utils/asset-collection.d.ts.map +1 -1
  215. package/dist/utils/asset-collection.js +10 -34
  216. package/dist/utils/asset-collection.js.map +1 -1
  217. package/dist/utils/build-lambda-zip.d.ts +14 -0
  218. package/dist/utils/build-lambda-zip.d.ts.map +1 -0
  219. package/dist/utils/build-lambda-zip.js +81 -0
  220. package/dist/utils/build-lambda-zip.js.map +1 -0
  221. package/dist/utils/config.js +1 -1
  222. package/dist/utils/config.js.map +1 -1
  223. package/dist/utils/env-management.d.ts +9 -8
  224. package/dist/utils/env-management.d.ts.map +1 -1
  225. package/dist/utils/env-management.js +73 -74
  226. package/dist/utils/env-management.js.map +1 -1
  227. package/dist/utils/formatter.d.ts.map +1 -1
  228. package/dist/utils/formatter.js +3 -5
  229. package/dist/utils/formatter.js.map +1 -1
  230. package/dist/utils/lambda-config.d.ts +3 -1
  231. package/dist/utils/lambda-config.d.ts.map +1 -1
  232. package/dist/utils/lambda-config.js +13 -21
  233. package/dist/utils/lambda-config.js.map +1 -1
  234. package/dist/utils/messages.d.ts.map +1 -1
  235. package/dist/utils/messages.js +8 -7
  236. package/dist/utils/messages.js.map +1 -1
  237. package/dist/utils/payload-config-ast.d.ts +22 -3
  238. package/dist/utils/payload-config-ast.d.ts.map +1 -1
  239. package/dist/utils/payload-config-ast.js +89 -31
  240. package/dist/utils/payload-config-ast.js.map +1 -1
  241. package/dist/utils/payload-config-finder.d.ts +2 -2
  242. package/dist/utils/payload-config-finder.d.ts.map +1 -1
  243. package/dist/utils/payload-config-finder.js +48 -9
  244. package/dist/utils/payload-config-finder.js.map +1 -1
  245. package/dist/utils/payload-config-modifier.d.ts.map +1 -1
  246. package/dist/utils/payload-config-modifier.js +54 -6
  247. package/dist/utils/payload-config-modifier.js.map +1 -1
  248. package/dist/utils/payload-package-check.d.ts +12 -1
  249. package/dist/utils/payload-package-check.d.ts.map +1 -1
  250. package/dist/utils/payload-package-check.js +63 -5
  251. package/dist/utils/payload-package-check.js.map +1 -1
  252. package/dist/utils/project.d.ts.map +1 -1
  253. package/dist/utils/project.js +8 -5
  254. package/dist/utils/project.js.map +1 -1
  255. package/dist/utils/s3-upload.d.ts +0 -1
  256. package/dist/utils/s3-upload.d.ts.map +1 -1
  257. package/dist/utils/s3-upload.js +10 -3
  258. package/dist/utils/s3-upload.js.map +1 -1
  259. package/dist/utils/token-display.d.ts.map +1 -1
  260. package/dist/utils/token-display.js +11 -5
  261. package/dist/utils/token-display.js.map +1 -1
  262. package/dist/utils/typescript-validator.d.ts.map +1 -1
  263. package/dist/utils/typescript-validator.js +4 -6
  264. package/dist/utils/typescript-validator.js.map +1 -1
  265. package/dist/utils/version-check.d.ts +3 -0
  266. package/dist/utils/version-check.d.ts.map +1 -0
  267. package/dist/utils/version-check.js +38 -0
  268. package/dist/utils/version-check.js.map +1 -0
  269. package/package.json +31 -7
@@ -0,0 +1,31 @@
1
+ import { createStorageClient } from './client.js';
2
+ import { getGenerateURL } from './generateURL.js';
3
+ import { getHandleDelete } from './handleDelete.js';
4
+ import { getHandleUpload } from './handleUpload.js';
5
+ import { getHandler } from './staticHandler.js';
6
+ export function contentApiStorageAdapter(config) {
7
+ return ({ collection, prefix })=>{
8
+ const client = createStorageClient(config);
9
+ const baseUrl = config.baseUrl;
10
+ return {
11
+ name: 'content-api',
12
+ generateURL: getGenerateURL({
13
+ baseUrl
14
+ }),
15
+ handleDelete: getHandleDelete({
16
+ client
17
+ }),
18
+ handleUpload: getHandleUpload({
19
+ client,
20
+ collection,
21
+ prefix
22
+ }),
23
+ staticHandler: getHandler({
24
+ client,
25
+ collection
26
+ })
27
+ };
28
+ };
29
+ }
30
+
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/storage-content-api/index.ts"],"sourcesContent":["import type { Adapter, GeneratedAdapter } from '@payloadcms/plugin-cloud-storage/types'\n\nimport type { StorageClientConfig } from './types.js'\n\nimport { createStorageClient } from './client.js'\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport type { StorageClientConfig } from './types.js'\n\nexport function contentApiStorageAdapter(config: StorageClientConfig): Adapter {\n return ({ collection, prefix }): GeneratedAdapter => {\n const client = createStorageClient(config)\n const baseUrl = config.baseUrl\n\n return {\n name: 'content-api',\n generateURL: getGenerateURL({ baseUrl }),\n handleDelete: getHandleDelete({ client }),\n handleUpload: getHandleUpload({ client, collection, prefix }),\n staticHandler: getHandler({ client, collection }),\n }\n }\n}\n"],"names":["createStorageClient","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","contentApiStorageAdapter","config","collection","prefix","client","baseUrl","name","generateURL","handleDelete","handleUpload","staticHandler"],"mappings":"AAIA,SAASA,mBAAmB,QAAQ,cAAa;AACjD,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAI/C,OAAO,SAASC,yBAAyBC,MAA2B;IAClE,OAAO,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QAC5B,MAAMC,SAAST,oBAAoBM;QACnC,MAAMI,UAAUJ,OAAOI,OAAO;QAE9B,OAAO;YACLC,MAAM;YACNC,aAAaX,eAAe;gBAAES;YAAQ;YACtCG,cAAcX,gBAAgB;gBAAEO;YAAO;YACvCK,cAAcX,gBAAgB;gBAAEM;gBAAQF;gBAAYC;YAAO;YAC3DO,eAAeX,WAAW;gBAAEK;gBAAQF;YAAW;QACjD;IACF;AACF"}
@@ -0,0 +1,10 @@
1
+ import type { StaticHandler } from '@payloadcms/plugin-cloud-storage/types';
2
+ import type { CollectionConfig } from 'payload';
3
+ import type { StorageClient } from './client.js';
4
+ type Args = {
5
+ client: StorageClient;
6
+ collection: CollectionConfig;
7
+ };
8
+ export declare const getHandler: ({ client, collection }: Args) => StaticHandler;
9
+ export {};
10
+ //# sourceMappingURL=staticHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staticHandler.d.ts","sourceRoot":"","sources":["../../src/storage-content-api/staticHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAK/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,aAAa,CAAA;IACrB,UAAU,EAAE,gBAAgB,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,UAAU,2BAA4B,IAAI,KAAG,aAuCzD,CAAA"}
@@ -0,0 +1,55 @@
1
+ import { getFilePrefix } from '@payloadcms/plugin-cloud-storage/utilities';
2
+ import path from 'path';
3
+ export const getHandler = ({ client, collection })=>{
4
+ return async (req, { params: { clientUploadContext, filename } })=>{
5
+ try {
6
+ const prefix = await getFilePrefix({
7
+ clientUploadContext,
8
+ collection,
9
+ filename,
10
+ req
11
+ });
12
+ const key = path.posix.join(prefix, filename);
13
+ const { data, error } = await client.POST('/api/v0/uploads/download/sign', {
14
+ body: {
15
+ expiresIn: 7200,
16
+ filename: key
17
+ }
18
+ });
19
+ if (error || !data) {
20
+ req.payload.logger.error(`Failed to get signed download URL: ${JSON.stringify(error)}`);
21
+ return new Response('Internal Server Error', {
22
+ status: 500
23
+ });
24
+ }
25
+ // Fetch file bytes from S3 (required for Payload's image processing)
26
+ const fileResponse = await fetch(data.url);
27
+ if (!fileResponse.ok) {
28
+ req.payload.logger.error(`S3 fetch failed: ${fileResponse.status} ${fileResponse.statusText}`);
29
+ return new Response('Failed to fetch file from storage', {
30
+ status: 502
31
+ });
32
+ }
33
+ const contentType = fileResponse.headers.get('content-type') || 'application/octet-stream';
34
+ const contentLength = fileResponse.headers.get('content-length');
35
+ return new Response(fileResponse.body, {
36
+ headers: {
37
+ 'Content-Type': contentType,
38
+ ...contentLength && {
39
+ 'Content-Length': contentLength
40
+ }
41
+ }
42
+ });
43
+ } catch (err) {
44
+ req.payload.logger.error({
45
+ err,
46
+ msg: 'Error in staticHandler'
47
+ });
48
+ return new Response('Internal Server Error', {
49
+ status: 500
50
+ });
51
+ }
52
+ };
53
+ };
54
+
55
+ //# sourceMappingURL=staticHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/storage-content-api/staticHandler.ts"],"sourcesContent":["import type { StaticHandler } from '@payloadcms/plugin-cloud-storage/types'\nimport type { CollectionConfig } from 'payload'\n\nimport { getFilePrefix } from '@payloadcms/plugin-cloud-storage/utilities'\nimport path from 'path'\n\nimport type { StorageClient } from './client.js'\n\ntype Args = {\n client: StorageClient\n collection: CollectionConfig\n}\n\nexport const getHandler = ({ client, collection }: Args): StaticHandler => {\n return async (req, { params: { clientUploadContext, filename } }) => {\n try {\n const prefix = await getFilePrefix({ clientUploadContext, collection, filename, req })\n const key = path.posix.join(prefix, filename)\n\n const { data, error } = await client.POST('/api/v0/uploads/download/sign', {\n body: { expiresIn: 7200, filename: key },\n })\n\n if (error || !data) {\n req.payload.logger.error(`Failed to get signed download URL: ${JSON.stringify(error)}`)\n return new Response('Internal Server Error', { status: 500 })\n }\n\n // Fetch file bytes from S3 (required for Payload's image processing)\n const fileResponse = await fetch(data.url)\n\n if (!fileResponse.ok) {\n req.payload.logger.error(\n `S3 fetch failed: ${fileResponse.status} ${fileResponse.statusText}`,\n )\n return new Response('Failed to fetch file from storage', { status: 502 })\n }\n\n const contentType = fileResponse.headers.get('content-type') || 'application/octet-stream'\n const contentLength = fileResponse.headers.get('content-length')\n\n return new Response(fileResponse.body, {\n headers: {\n 'Content-Type': contentType,\n ...(contentLength && { 'Content-Length': contentLength }),\n },\n })\n } catch (err) {\n req.payload.logger.error({ err, msg: 'Error in staticHandler' })\n return new Response('Internal Server Error', { status: 500 })\n }\n }\n}\n"],"names":["getFilePrefix","path","getHandler","client","collection","req","params","clientUploadContext","filename","prefix","key","posix","join","data","error","POST","body","expiresIn","payload","logger","JSON","stringify","Response","status","fileResponse","fetch","url","ok","statusText","contentType","headers","get","contentLength","err","msg"],"mappings":"AAGA,SAASA,aAAa,QAAQ,6CAA4C;AAC1E,OAAOC,UAAU,OAAM;AASvB,OAAO,MAAMC,aAAa,CAAC,EAAEC,MAAM,EAAEC,UAAU,EAAQ;IACrD,OAAO,OAAOC,KAAK,EAAEC,QAAQ,EAAEC,mBAAmB,EAAEC,QAAQ,EAAE,EAAE;QAC9D,IAAI;YACF,MAAMC,SAAS,MAAMT,cAAc;gBAAEO;gBAAqBH;gBAAYI;gBAAUH;YAAI;YACpF,MAAMK,MAAMT,KAAKU,KAAK,CAACC,IAAI,CAACH,QAAQD;YAEpC,MAAM,EAAEK,IAAI,EAAEC,KAAK,EAAE,GAAG,MAAMX,OAAOY,IAAI,CAAC,iCAAiC;gBACzEC,MAAM;oBAAEC,WAAW;oBAAMT,UAAUE;gBAAI;YACzC;YAEA,IAAII,SAAS,CAACD,MAAM;gBAClBR,IAAIa,OAAO,CAACC,MAAM,CAACL,KAAK,CAAC,CAAC,mCAAmC,EAAEM,KAAKC,SAAS,CAACP,QAAQ;gBACtF,OAAO,IAAIQ,SAAS,yBAAyB;oBAAEC,QAAQ;gBAAI;YAC7D;YAEA,qEAAqE;YACrE,MAAMC,eAAe,MAAMC,MAAMZ,KAAKa,GAAG;YAEzC,IAAI,CAACF,aAAaG,EAAE,EAAE;gBACpBtB,IAAIa,OAAO,CAACC,MAAM,CAACL,KAAK,CACtB,CAAC,iBAAiB,EAAEU,aAAaD,MAAM,CAAC,CAAC,EAAEC,aAAaI,UAAU,EAAE;gBAEtE,OAAO,IAAIN,SAAS,qCAAqC;oBAAEC,QAAQ;gBAAI;YACzE;YAEA,MAAMM,cAAcL,aAAaM,OAAO,CAACC,GAAG,CAAC,mBAAmB;YAChE,MAAMC,gBAAgBR,aAAaM,OAAO,CAACC,GAAG,CAAC;YAE/C,OAAO,IAAIT,SAASE,aAAaR,IAAI,EAAE;gBACrCc,SAAS;oBACP,gBAAgBD;oBAChB,GAAIG,iBAAiB;wBAAE,kBAAkBA;oBAAc,CAAC;gBAC1D;YACF;QACF,EAAE,OAAOC,KAAK;YACZ5B,IAAIa,OAAO,CAACC,MAAM,CAACL,KAAK,CAAC;gBAAEmB;gBAAKC,KAAK;YAAyB;YAC9D,OAAO,IAAIZ,SAAS,yBAAyB;gBAAEC,QAAQ;YAAI;QAC7D;IACF;AACF,EAAC"}
@@ -0,0 +1,10 @@
1
+ import type { AuthMode } from '../db-content-api/utilities/auth.js';
2
+ export type StorageClientConfig = {
3
+ auth: AuthMode;
4
+ baseUrl: string;
5
+ contentSystemId: string;
6
+ } | {
7
+ baseUrl: string;
8
+ contentApiKey: string;
9
+ };
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/storage-content-api/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAA;AAEnE,MAAM,MAAM,mBAAmB,GAC3B;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,MAAM,CAAA;CACxB,GACD;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/storage-content-api/types.ts"],"sourcesContent":["import type { AuthMode } from '../db-content-api/utilities/auth.js'\n\nexport type StorageClientConfig =\n | {\n auth: AuthMode\n baseUrl: string\n contentSystemId: string\n }\n | { baseUrl: string; contentApiKey: string }\n"],"names":[],"mappings":"AAEA,WAM8C"}
@@ -0,0 +1,19 @@
1
+ # {{PROJECT_NAME}}
2
+
3
+ A Payload project configured for running on Figma infrastructure.
4
+
5
+ ## Getting Started
6
+
7
+ pnpm dev
8
+
9
+ Open http://localhost:3000/admin to access the admin panel.
10
+
11
+ ## Deployment
12
+
13
+ npx @payloadcms/figma deploy
14
+
15
+ Deploys to Figma infrastructure.
16
+
17
+ ## Resources
18
+
19
+ - [Payload Docs](https://payloadcms.com/docs)
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type arg from 'arg';
2
2
  export interface Args extends arg.Spec {
3
3
  '--debug': BooleanConstructor;
4
+ '--env': StringConstructor;
4
5
  '--force': BooleanConstructor;
5
6
  '--help': BooleanConstructor;
6
7
  '--list': BooleanConstructor;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAE1B,MAAM,WAAW,IAAK,SAAQ,GAAG,CAAC,IAAI;IACpC,SAAS,EAAE,kBAAkB,CAAA;IAC7B,SAAS,EAAE,kBAAkB,CAAA;IAC7B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,UAAU,EAAE,kBAAkB,CAAA;IAC9B,OAAO,EAAE,kBAAkB,CAAA;IAI3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAEtC,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,cAAc,CAAA;AAE1D,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,QAAQ;IAC3C,IAAI,EAAE,SAAS,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,IAAI,EAAE,QAAQ,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,UAAU,QAAQ;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;CAC9B;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AAE5D,MAAM,MAAM,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,iBAAiB,CAAA;AAExF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,CAAA;AAE5C,MAAM,MAAM,cAAc,GAAG;IAC3B,iBAAiB,EAAE,OAAO,CAAA;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,EAAE,OAAO,CAAA;IACjB,sBAAsB,EAAE,OAAO,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,WAAW,EAAE,IAAI,GAAG,MAAM,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,CAAA;AAEjD,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,WAAW,GAAG,mBAAmB,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAE1B,MAAM,WAAW,IAAK,SAAQ,GAAG,CAAC,IAAI;IACpC,SAAS,EAAE,kBAAkB,CAAA;IAC7B,OAAO,EAAE,iBAAiB,CAAA;IAC1B,SAAS,EAAE,kBAAkB,CAAA;IAC7B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,UAAU,EAAE,kBAAkB,CAAA;IAC9B,OAAO,EAAE,kBAAkB,CAAA;IAI3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAEtC,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,cAAc,CAAA;AAE1D,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,QAAQ;IAC3C,IAAI,EAAE,SAAS,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,IAAI,EAAE,QAAQ,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,UAAU,QAAQ;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;CAC9B;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AAE5D,MAAM,MAAM,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,iBAAiB,CAAA;AAExF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,CAAA;AAE5C,MAAM,MAAM,cAAc,GAAG;IAC3B,iBAAiB,EAAE,OAAO,CAAA;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,EAAE,OAAO,CAAA;IACjB,sBAAsB,EAAE,OAAO,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,WAAW,EAAE,IAAI,GAAG,MAAM,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,CAAA;AAEjD,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,WAAW,GAAG,mBAAmB,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type arg from 'arg'\n\nexport interface Args extends arg.Spec {\n '--debug': BooleanConstructor\n '--force': BooleanConstructor\n '--help': BooleanConstructor\n '--list': BooleanConstructor\n '--logout': BooleanConstructor\n '--yes': BooleanConstructor\n\n // Aliases\n\n '-f': string\n '-h': string\n '-y': string\n}\n\nexport type CliArgs = arg.Result<Args>\n\nexport type ProjectTemplate = GitTemplate | PluginTemplate\n\nexport type ProjectExample = {\n name: string\n url: string\n}\n\n/**\n * Template that is cloned verbatim from a git repo\n * Performs .env manipulation based upon input\n */\nexport interface GitTemplate extends Template {\n type: 'starter'\n url: string\n}\n\n/**\n * Type specifically for the plugin template\n * No .env manipulation is done\n */\nexport interface PluginTemplate extends Template {\n type: 'plugin'\n url: string\n}\n\ninterface Template {\n description?: string\n name: string\n type: ProjectTemplate['type']\n}\n\nexport type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn'\n\nexport type DbType = 'd1-sqlite' | 'mongodb' | 'postgres' | 'sqlite' | 'vercel-postgres'\n\nexport type DbDetails = {\n dbUri?: string\n type: DbType\n}\n\nexport type EditorType = 'lexical' | 'slate'\n\nexport type NextAppDetails = {\n hasTopLevelLayout: boolean\n isPayloadInstalled?: boolean\n isSrcDir: boolean\n isSupportedNextVersion: boolean\n nextAppDir?: string\n nextConfigPath?: string\n nextConfigType?: NextConfigType\n nextVersion: null | string\n}\n\nexport type NextConfigType = 'cjs' | 'esm' | 'ts'\n\nexport type StorageAdapterType = 'localDisk' | 'r2Storage' | 'vercelBlobStorage'\n"],"names":[],"mappings":"AA0EA,WAAgF"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type arg from 'arg'\n\nexport interface Args extends arg.Spec {\n '--debug': BooleanConstructor\n '--env': StringConstructor\n '--force': BooleanConstructor\n '--help': BooleanConstructor\n '--list': BooleanConstructor\n '--logout': BooleanConstructor\n '--yes': BooleanConstructor\n\n // Aliases\n\n '-f': string\n '-h': string\n '-y': string\n}\n\nexport type CliArgs = arg.Result<Args>\n\nexport type ProjectTemplate = GitTemplate | PluginTemplate\n\nexport type ProjectExample = {\n name: string\n url: string\n}\n\n/**\n * Template that is cloned verbatim from a git repo\n * Performs .env manipulation based upon input\n */\nexport interface GitTemplate extends Template {\n type: 'starter'\n url: string\n}\n\n/**\n * Type specifically for the plugin template\n * No .env manipulation is done\n */\nexport interface PluginTemplate extends Template {\n type: 'plugin'\n url: string\n}\n\ninterface Template {\n description?: string\n name: string\n type: ProjectTemplate['type']\n}\n\nexport type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn'\n\nexport type DbType = 'd1-sqlite' | 'mongodb' | 'postgres' | 'sqlite' | 'vercel-postgres'\n\nexport type DbDetails = {\n dbUri?: string\n type: DbType\n}\n\nexport type EditorType = 'lexical' | 'slate'\n\nexport type NextAppDetails = {\n hasTopLevelLayout: boolean\n isPayloadInstalled?: boolean\n isSrcDir: boolean\n isSupportedNextVersion: boolean\n nextAppDir?: string\n nextConfigPath?: string\n nextConfigType?: NextConfigType\n nextVersion: null | string\n}\n\nexport type NextConfigType = 'cjs' | 'esm' | 'ts'\n\nexport type StorageAdapterType = 'localDisk' | 'r2Storage' | 'vercelBlobStorage'\n"],"names":[],"mappings":"AA2EA,WAAgF"}
@@ -16,15 +16,12 @@ export declare function getFileSize(filePath: string): Promise<number>;
16
16
  */
17
17
  export declare function collectStaticAssets(projectPath: string): Promise<string[]>;
18
18
  /**
19
- * Create Lambda deployment zip using build_for_lambda.sh
19
+ * Create Lambda deployment zip
20
20
  *
21
- * This script:
22
- * - Copies static files to standalone build
23
- * - Creates lambda.zip from .next/standalone/
24
- * - Places zip at project root
21
+ * Uses cross-platform Node.js implementation instead of shell script.
25
22
  *
26
23
  * @param projectPath - Path to project root
27
- * @throws Error if script missing or execution fails
24
+ * @throws Error if build missing or zip creation fails
28
25
  */
29
26
  export declare function createLambdaZip(projectPath: string): Promise<void>;
30
27
  //# sourceMappingURL=asset-collection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asset-collection.d.ts","sourceRoot":"","sources":["../../src/utils/asset-collection.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnE;AAgDD;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAchF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBxE"}
1
+ {"version":3,"file":"asset-collection.d.ts","sourceRoot":"","sources":["../../src/utils/asset-collection.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnE;AAgDD;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBhF;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAExE"}
@@ -1,9 +1,7 @@
1
- import { exec } from 'child_process';
2
1
  import fs from 'fs/promises';
3
2
  import path from 'path';
4
- import { promisify } from 'util';
3
+ import { buildLambdaZip } from './build-lambda-zip.js';
5
4
  import * as log from './log.js';
6
- const execAsync = promisify(exec);
7
5
  // Maximum file size for static assets (S3 limitation)
8
6
  const MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB
9
7
  ;
@@ -75,43 +73,21 @@ const MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB
75
73
  return [];
76
74
  }
77
75
  const files = await collectFiles(staticDir, projectPath);
78
- // Convert .next/static to _next/static (Next.js convention)
79
- return files.map((file)=>file.replace(/^\.next\//, '_next/'));
76
+ // Normalize paths to forward slashes (cross-platform) and convert prefix
77
+ return files.map((file)=>{
78
+ const normalized = file.split(path.sep).join('/');
79
+ return normalized.replace(/^\.next\//, '_next/');
80
+ });
80
81
  }
81
82
  /**
82
- * Create Lambda deployment zip using build_for_lambda.sh
83
+ * Create Lambda deployment zip
83
84
  *
84
- * This script:
85
- * - Copies static files to standalone build
86
- * - Creates lambda.zip from .next/standalone/
87
- * - Places zip at project root
85
+ * Uses cross-platform Node.js implementation instead of shell script.
88
86
  *
89
87
  * @param projectPath - Path to project root
90
- * @throws Error if script missing or execution fails
88
+ * @throws Error if build missing or zip creation fails
91
89
  */ export async function createLambdaZip(projectPath) {
92
- const scriptPath = path.join(projectPath, 'build_for_lambda.sh');
93
- // Check if script exists
94
- try {
95
- await fs.stat(scriptPath);
96
- } catch {
97
- throw new Error('build_for_lambda.sh not found. Run init command to set up project.');
98
- }
99
- // Execute script
100
- try {
101
- await execAsync('./build_for_lambda.sh', {
102
- cwd: projectPath
103
- });
104
- } catch (error) {
105
- const message = error instanceof Error ? error.message : 'Unknown error';
106
- throw new Error(`Failed to create Lambda zip: ${message}`);
107
- }
108
- // Verify zip was created
109
- const zipPath = path.join(projectPath, 'lambda.zip');
110
- try {
111
- await fs.stat(zipPath);
112
- } catch {
113
- throw new Error('lambda.zip was not created by build_for_lambda.sh');
114
- }
90
+ await buildLambdaZip(projectPath);
115
91
  }
116
92
 
117
93
  //# sourceMappingURL=asset-collection.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/asset-collection.ts"],"sourcesContent":["import { exec } from 'child_process'\nimport fs from 'fs/promises'\nimport path from 'path'\nimport { promisify } from 'util'\n\nimport * as log from './log.js'\n\nconst execAsync = promisify(exec)\n\n// Maximum file size for static assets (S3 limitation)\nconst MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB\n\n/**\n * Get file size in bytes\n *\n * @param filePath - Absolute path to file\n * @returns File size in bytes\n */\nexport async function getFileSize(filePath: string): Promise<number> {\n const stats = await fs.stat(filePath)\n return stats.size\n}\n\n/**\n * Recursively collect files from a directory\n *\n * Excludes files larger than 50MB (S3 limitation).\n * Warns user when files are excluded due to size.\n *\n * @param dir - Directory to scan\n * @param baseDir - Base directory for relative paths\n * @returns Array of relative file paths\n */\nasync function collectFiles(dir: string, baseDir: string): Promise<string[]> {\n const files: string[] = []\n\n try {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n // Recursively collect from subdirectories\n const subFiles = await collectFiles(fullPath, baseDir)\n files.push(...subFiles)\n } else if (entry.isFile()) {\n // Check file size before adding\n const stats = await fs.stat(fullPath)\n if (stats.size <= MAX_ASSET_SIZE) {\n // Add relative path from base directory\n const relativePath = path.relative(baseDir, fullPath)\n files.push(relativePath)\n } else {\n // Warn user about skipped files\n const sizeMB = (stats.size / (1024 * 1024)).toFixed(2)\n const relativePath = path.relative(baseDir, fullPath)\n log.warning(`Skipping large asset: ${relativePath} (${sizeMB}MB exceeds 50MB limit)`)\n }\n }\n }\n } catch {\n // Directory doesn't exist or not accessible\n return []\n }\n\n return files\n}\n\n/**\n * Collect all static asset paths from .next/static\n *\n * Returns paths relative to project root, formatted for S3:\n * - `.next/static/chunks/main.js` → `_next/static/chunks/main.js`\n *\n * @param projectPath - Path to project root\n * @returns Array of static asset paths (using _next prefix)\n */\nexport async function collectStaticAssets(projectPath: string): Promise<string[]> {\n const staticDir = path.join(projectPath, '.next', 'static')\n\n try {\n await fs.stat(staticDir)\n } catch {\n // No static directory\n return []\n }\n\n const files = await collectFiles(staticDir, projectPath)\n\n // Convert .next/static to _next/static (Next.js convention)\n return files.map((file) => file.replace(/^\\.next\\//, '_next/'))\n}\n\n/**\n * Create Lambda deployment zip using build_for_lambda.sh\n *\n * This script:\n * - Copies static files to standalone build\n * - Creates lambda.zip from .next/standalone/\n * - Places zip at project root\n *\n * @param projectPath - Path to project root\n * @throws Error if script missing or execution fails\n */\nexport async function createLambdaZip(projectPath: string): Promise<void> {\n const scriptPath = path.join(projectPath, 'build_for_lambda.sh')\n\n // Check if script exists\n try {\n await fs.stat(scriptPath)\n } catch {\n throw new Error('build_for_lambda.sh not found. Run init command to set up project.')\n }\n\n // Execute script\n try {\n await execAsync('./build_for_lambda.sh', { cwd: projectPath })\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Unknown error'\n throw new Error(`Failed to create Lambda zip: ${message}`)\n }\n\n // Verify zip was created\n const zipPath = path.join(projectPath, 'lambda.zip')\n try {\n await fs.stat(zipPath)\n } catch {\n throw new Error('lambda.zip was not created by build_for_lambda.sh')\n }\n}\n"],"names":["exec","fs","path","promisify","log","execAsync","MAX_ASSET_SIZE","getFileSize","filePath","stats","stat","size","collectFiles","dir","baseDir","files","entries","readdir","withFileTypes","entry","fullPath","join","name","isDirectory","subFiles","push","isFile","relativePath","relative","sizeMB","toFixed","warning","collectStaticAssets","projectPath","staticDir","map","file","replace","createLambdaZip","scriptPath","Error","cwd","error","message","zipPath"],"mappings":"AAAA,SAASA,IAAI,QAAQ,gBAAe;AACpC,OAAOC,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AACvB,SAASC,SAAS,QAAQ,OAAM;AAEhC,YAAYC,SAAS,WAAU;AAE/B,MAAMC,YAAYF,UAAUH;AAE5B,sDAAsD;AACtD,MAAMM,iBAAiB,KAAK,OAAO,KAAK,OAAO;;AAE/C;;;;;CAKC,GACD,OAAO,eAAeC,YAAYC,QAAgB;IAChD,MAAMC,QAAQ,MAAMR,GAAGS,IAAI,CAACF;IAC5B,OAAOC,MAAME,IAAI;AACnB;AAEA;;;;;;;;;CASC,GACD,eAAeC,aAAaC,GAAW,EAAEC,OAAe;IACtD,MAAMC,QAAkB,EAAE;IAE1B,IAAI;QACF,MAAMC,UAAU,MAAMf,GAAGgB,OAAO,CAACJ,KAAK;YAAEK,eAAe;QAAK;QAE5D,KAAK,MAAMC,SAASH,QAAS;YAC3B,MAAMI,WAAWlB,KAAKmB,IAAI,CAACR,KAAKM,MAAMG,IAAI;YAE1C,IAAIH,MAAMI,WAAW,IAAI;gBACvB,0CAA0C;gBAC1C,MAAMC,WAAW,MAAMZ,aAAaQ,UAAUN;gBAC9CC,MAAMU,IAAI,IAAID;YAChB,OAAO,IAAIL,MAAMO,MAAM,IAAI;gBACzB,gCAAgC;gBAChC,MAAMjB,QAAQ,MAAMR,GAAGS,IAAI,CAACU;gBAC5B,IAAIX,MAAME,IAAI,IAAIL,gBAAgB;oBAChC,wCAAwC;oBACxC,MAAMqB,eAAezB,KAAK0B,QAAQ,CAACd,SAASM;oBAC5CL,MAAMU,IAAI,CAACE;gBACb,OAAO;oBACL,gCAAgC;oBAChC,MAAME,SAAS,AAACpB,CAAAA,MAAME,IAAI,GAAI,CAAA,OAAO,IAAG,CAAC,EAAGmB,OAAO,CAAC;oBACpD,MAAMH,eAAezB,KAAK0B,QAAQ,CAACd,SAASM;oBAC5ChB,IAAI2B,OAAO,CAAC,CAAC,sBAAsB,EAAEJ,aAAa,EAAE,EAAEE,OAAO,sBAAsB,CAAC;gBACtF;YACF;QACF;IACF,EAAE,OAAM;QACN,4CAA4C;QAC5C,OAAO,EAAE;IACX;IAEA,OAAOd;AACT;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAeiB,oBAAoBC,WAAmB;IAC3D,MAAMC,YAAYhC,KAAKmB,IAAI,CAACY,aAAa,SAAS;IAElD,IAAI;QACF,MAAMhC,GAAGS,IAAI,CAACwB;IAChB,EAAE,OAAM;QACN,sBAAsB;QACtB,OAAO,EAAE;IACX;IAEA,MAAMnB,QAAQ,MAAMH,aAAasB,WAAWD;IAE5C,4DAA4D;IAC5D,OAAOlB,MAAMoB,GAAG,CAAC,CAACC,OAASA,KAAKC,OAAO,CAAC,aAAa;AACvD;AAEA;;;;;;;;;;CAUC,GACD,OAAO,eAAeC,gBAAgBL,WAAmB;IACvD,MAAMM,aAAarC,KAAKmB,IAAI,CAACY,aAAa;IAE1C,yBAAyB;IACzB,IAAI;QACF,MAAMhC,GAAGS,IAAI,CAAC6B;IAChB,EAAE,OAAM;QACN,MAAM,IAAIC,MAAM;IAClB;IAEA,iBAAiB;IACjB,IAAI;QACF,MAAMnC,UAAU,yBAAyB;YAAEoC,KAAKR;QAAY;IAC9D,EAAE,OAAOS,OAAO;QACd,MAAMC,UAAUD,iBAAiBF,QAAQE,MAAMC,OAAO,GAAG;QACzD,MAAM,IAAIH,MAAM,CAAC,6BAA6B,EAAEG,SAAS;IAC3D;IAEA,yBAAyB;IACzB,MAAMC,UAAU1C,KAAKmB,IAAI,CAACY,aAAa;IACvC,IAAI;QACF,MAAMhC,GAAGS,IAAI,CAACkC;IAChB,EAAE,OAAM;QACN,MAAM,IAAIJ,MAAM;IAClB;AACF"}
1
+ {"version":3,"sources":["../../src/utils/asset-collection.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\nimport { buildLambdaZip } from './build-lambda-zip.js'\nimport * as log from './log.js'\n\n// Maximum file size for static assets (S3 limitation)\nconst MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB\n\n/**\n * Get file size in bytes\n *\n * @param filePath - Absolute path to file\n * @returns File size in bytes\n */\nexport async function getFileSize(filePath: string): Promise<number> {\n const stats = await fs.stat(filePath)\n return stats.size\n}\n\n/**\n * Recursively collect files from a directory\n *\n * Excludes files larger than 50MB (S3 limitation).\n * Warns user when files are excluded due to size.\n *\n * @param dir - Directory to scan\n * @param baseDir - Base directory for relative paths\n * @returns Array of relative file paths\n */\nasync function collectFiles(dir: string, baseDir: string): Promise<string[]> {\n const files: string[] = []\n\n try {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n // Recursively collect from subdirectories\n const subFiles = await collectFiles(fullPath, baseDir)\n files.push(...subFiles)\n } else if (entry.isFile()) {\n // Check file size before adding\n const stats = await fs.stat(fullPath)\n if (stats.size <= MAX_ASSET_SIZE) {\n // Add relative path from base directory\n const relativePath = path.relative(baseDir, fullPath)\n files.push(relativePath)\n } else {\n // Warn user about skipped files\n const sizeMB = (stats.size / (1024 * 1024)).toFixed(2)\n const relativePath = path.relative(baseDir, fullPath)\n log.warning(`Skipping large asset: ${relativePath} (${sizeMB}MB exceeds 50MB limit)`)\n }\n }\n }\n } catch {\n // Directory doesn't exist or not accessible\n return []\n }\n\n return files\n}\n\n/**\n * Collect all static asset paths from .next/static\n *\n * Returns paths relative to project root, formatted for S3:\n * - `.next/static/chunks/main.js` → `_next/static/chunks/main.js`\n *\n * @param projectPath - Path to project root\n * @returns Array of static asset paths (using _next prefix)\n */\nexport async function collectStaticAssets(projectPath: string): Promise<string[]> {\n const staticDir = path.join(projectPath, '.next', 'static')\n\n try {\n await fs.stat(staticDir)\n } catch {\n // No static directory\n return []\n }\n\n const files = await collectFiles(staticDir, projectPath)\n\n // Normalize paths to forward slashes (cross-platform) and convert prefix\n return files.map((file) => {\n const normalized = file.split(path.sep).join('/')\n return normalized.replace(/^\\.next\\//, '_next/')\n })\n}\n\n/**\n * Create Lambda deployment zip\n *\n * Uses cross-platform Node.js implementation instead of shell script.\n *\n * @param projectPath - Path to project root\n * @throws Error if build missing or zip creation fails\n */\nexport async function createLambdaZip(projectPath: string): Promise<void> {\n await buildLambdaZip(projectPath)\n}\n"],"names":["fs","path","buildLambdaZip","log","MAX_ASSET_SIZE","getFileSize","filePath","stats","stat","size","collectFiles","dir","baseDir","files","entries","readdir","withFileTypes","entry","fullPath","join","name","isDirectory","subFiles","push","isFile","relativePath","relative","sizeMB","toFixed","warning","collectStaticAssets","projectPath","staticDir","map","file","normalized","split","sep","replace","createLambdaZip"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,SAASC,cAAc,QAAQ,wBAAuB;AACtD,YAAYC,SAAS,WAAU;AAE/B,sDAAsD;AACtD,MAAMC,iBAAiB,KAAK,OAAO,KAAK,OAAO;;AAE/C;;;;;CAKC,GACD,OAAO,eAAeC,YAAYC,QAAgB;IAChD,MAAMC,QAAQ,MAAMP,GAAGQ,IAAI,CAACF;IAC5B,OAAOC,MAAME,IAAI;AACnB;AAEA;;;;;;;;;CASC,GACD,eAAeC,aAAaC,GAAW,EAAEC,OAAe;IACtD,MAAMC,QAAkB,EAAE;IAE1B,IAAI;QACF,MAAMC,UAAU,MAAMd,GAAGe,OAAO,CAACJ,KAAK;YAAEK,eAAe;QAAK;QAE5D,KAAK,MAAMC,SAASH,QAAS;YAC3B,MAAMI,WAAWjB,KAAKkB,IAAI,CAACR,KAAKM,MAAMG,IAAI;YAE1C,IAAIH,MAAMI,WAAW,IAAI;gBACvB,0CAA0C;gBAC1C,MAAMC,WAAW,MAAMZ,aAAaQ,UAAUN;gBAC9CC,MAAMU,IAAI,IAAID;YAChB,OAAO,IAAIL,MAAMO,MAAM,IAAI;gBACzB,gCAAgC;gBAChC,MAAMjB,QAAQ,MAAMP,GAAGQ,IAAI,CAACU;gBAC5B,IAAIX,MAAME,IAAI,IAAIL,gBAAgB;oBAChC,wCAAwC;oBACxC,MAAMqB,eAAexB,KAAKyB,QAAQ,CAACd,SAASM;oBAC5CL,MAAMU,IAAI,CAACE;gBACb,OAAO;oBACL,gCAAgC;oBAChC,MAAME,SAAS,AAACpB,CAAAA,MAAME,IAAI,GAAI,CAAA,OAAO,IAAG,CAAC,EAAGmB,OAAO,CAAC;oBACpD,MAAMH,eAAexB,KAAKyB,QAAQ,CAACd,SAASM;oBAC5Cf,IAAI0B,OAAO,CAAC,CAAC,sBAAsB,EAAEJ,aAAa,EAAE,EAAEE,OAAO,sBAAsB,CAAC;gBACtF;YACF;QACF;IACF,EAAE,OAAM;QACN,4CAA4C;QAC5C,OAAO,EAAE;IACX;IAEA,OAAOd;AACT;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAeiB,oBAAoBC,WAAmB;IAC3D,MAAMC,YAAY/B,KAAKkB,IAAI,CAACY,aAAa,SAAS;IAElD,IAAI;QACF,MAAM/B,GAAGQ,IAAI,CAACwB;IAChB,EAAE,OAAM;QACN,sBAAsB;QACtB,OAAO,EAAE;IACX;IAEA,MAAMnB,QAAQ,MAAMH,aAAasB,WAAWD;IAE5C,yEAAyE;IACzE,OAAOlB,MAAMoB,GAAG,CAAC,CAACC;QAChB,MAAMC,aAAaD,KAAKE,KAAK,CAACnC,KAAKoC,GAAG,EAAElB,IAAI,CAAC;QAC7C,OAAOgB,WAAWG,OAAO,CAAC,aAAa;IACzC;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,eAAeC,gBAAgBR,WAAmB;IACvD,MAAM7B,eAAe6B;AACvB"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Build Lambda deployment zip using pure Node.js
3
+ *
4
+ * Cross-platform replacement for build_for_lambda.sh:
5
+ * 1. Copies .next/static to .next/standalone/.next/static
6
+ * 2. Copies run.sh to .next/standalone/run.sh
7
+ * 3. Copies public/ to .next/standalone/public/ (if exists)
8
+ * 4. Creates lambda.zip from .next/standalone/
9
+ *
10
+ * @param projectPath - Path to project root
11
+ * @throws Error if standalone directory missing or zip creation fails
12
+ */
13
+ export declare function buildLambdaZip(projectPath: string): Promise<void>;
14
+ //# sourceMappingURL=build-lambda-zip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-lambda-zip.d.ts","sourceRoot":"","sources":["../../src/utils/build-lambda-zip.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BvE"}
@@ -0,0 +1,81 @@
1
+ import archiver from 'archiver';
2
+ import { createWriteStream } from 'fs';
3
+ import fs from 'fs/promises';
4
+ import path from 'path';
5
+ /**
6
+ * Build Lambda deployment zip using pure Node.js
7
+ *
8
+ * Cross-platform replacement for build_for_lambda.sh:
9
+ * 1. Copies .next/static to .next/standalone/.next/static
10
+ * 2. Copies run.sh to .next/standalone/run.sh
11
+ * 3. Copies public/ to .next/standalone/public/ (if exists)
12
+ * 4. Creates lambda.zip from .next/standalone/
13
+ *
14
+ * @param projectPath - Path to project root
15
+ * @throws Error if standalone directory missing or zip creation fails
16
+ */ export async function buildLambdaZip(projectPath) {
17
+ const standalonePath = path.join(projectPath, '.next', 'standalone');
18
+ const staticPath = path.join(projectPath, '.next', 'static');
19
+ const publicPath = path.join(projectPath, 'public');
20
+ const runShPath = path.join(projectPath, 'run.sh');
21
+ const zipPath = path.join(projectPath, 'lambda.zip');
22
+ if (!await isDirectory(standalonePath)) {
23
+ throw new Error('Standalone build not found at .next/standalone. ' + 'Ensure next.config.js has output: "standalone" and run build first.');
24
+ }
25
+ if (await isDirectory(staticPath)) {
26
+ const destStatic = path.join(standalonePath, '.next', 'static');
27
+ await copyDirectory(staticPath, destStatic);
28
+ }
29
+ try {
30
+ await fs.copyFile(runShPath, path.join(standalonePath, 'run.sh'));
31
+ } catch {
32
+ // run.sh may not exist in all setups
33
+ }
34
+ if (await isDirectory(publicPath)) {
35
+ const destPublic = path.join(standalonePath, 'public');
36
+ await copyDirectory(publicPath, destPublic);
37
+ }
38
+ await createZip(standalonePath, zipPath);
39
+ }
40
+ async function isDirectory(dirPath) {
41
+ try {
42
+ const stats = await fs.stat(dirPath);
43
+ return stats.isDirectory();
44
+ } catch {
45
+ return false;
46
+ }
47
+ }
48
+ async function copyDirectory(src, dest) {
49
+ await fs.mkdir(dest, {
50
+ recursive: true
51
+ });
52
+ const entries = await fs.readdir(src, {
53
+ withFileTypes: true
54
+ });
55
+ for (const entry of entries){
56
+ const srcPath = path.join(src, entry.name);
57
+ const destPath = path.join(dest, entry.name);
58
+ if (entry.isDirectory()) {
59
+ await copyDirectory(srcPath, destPath);
60
+ } else {
61
+ await fs.copyFile(srcPath, destPath);
62
+ }
63
+ }
64
+ }
65
+ function createZip(sourceDir, zipPath) {
66
+ return new Promise((resolve, reject)=>{
67
+ const output = createWriteStream(zipPath);
68
+ const archive = archiver('zip', {
69
+ zlib: {
70
+ level: 9
71
+ }
72
+ });
73
+ output.on('close', ()=>resolve());
74
+ archive.on('error', (err)=>reject(err));
75
+ archive.pipe(output);
76
+ archive.directory(sourceDir, false);
77
+ void archive.finalize();
78
+ });
79
+ }
80
+
81
+ //# sourceMappingURL=build-lambda-zip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/build-lambda-zip.ts"],"sourcesContent":["import archiver from 'archiver'\nimport { createWriteStream } from 'fs'\nimport fs from 'fs/promises'\nimport path from 'path'\n\n/**\n * Build Lambda deployment zip using pure Node.js\n *\n * Cross-platform replacement for build_for_lambda.sh:\n * 1. Copies .next/static to .next/standalone/.next/static\n * 2. Copies run.sh to .next/standalone/run.sh\n * 3. Copies public/ to .next/standalone/public/ (if exists)\n * 4. Creates lambda.zip from .next/standalone/\n *\n * @param projectPath - Path to project root\n * @throws Error if standalone directory missing or zip creation fails\n */\nexport async function buildLambdaZip(projectPath: string): Promise<void> {\n const standalonePath = path.join(projectPath, '.next', 'standalone')\n const staticPath = path.join(projectPath, '.next', 'static')\n const publicPath = path.join(projectPath, 'public')\n const runShPath = path.join(projectPath, 'run.sh')\n const zipPath = path.join(projectPath, 'lambda.zip')\n\n if (!(await isDirectory(standalonePath))) {\n throw new Error(\n 'Standalone build not found at .next/standalone. ' +\n 'Ensure next.config.js has output: \"standalone\" and run build first.',\n )\n }\n\n if (await isDirectory(staticPath)) {\n const destStatic = path.join(standalonePath, '.next', 'static')\n await copyDirectory(staticPath, destStatic)\n }\n\n try {\n await fs.copyFile(runShPath, path.join(standalonePath, 'run.sh'))\n } catch {\n // run.sh may not exist in all setups\n }\n\n if (await isDirectory(publicPath)) {\n const destPublic = path.join(standalonePath, 'public')\n await copyDirectory(publicPath, destPublic)\n }\n\n await createZip(standalonePath, zipPath)\n}\n\nasync function isDirectory(dirPath: string): Promise<boolean> {\n try {\n const stats = await fs.stat(dirPath)\n return stats.isDirectory()\n } catch {\n return false\n }\n}\n\nasync function copyDirectory(src: string, dest: string): Promise<void> {\n await fs.mkdir(dest, { recursive: true })\n const entries = await fs.readdir(src, { withFileTypes: true })\n\n for (const entry of entries) {\n const srcPath = path.join(src, entry.name)\n const destPath = path.join(dest, entry.name)\n\n if (entry.isDirectory()) {\n await copyDirectory(srcPath, destPath)\n } else {\n await fs.copyFile(srcPath, destPath)\n }\n }\n}\n\nfunction createZip(sourceDir: string, zipPath: string): Promise<void> {\n return new Promise((resolve, reject) => {\n const output = createWriteStream(zipPath)\n const archive = archiver('zip', { zlib: { level: 9 } })\n\n output.on('close', () => resolve())\n archive.on('error', (err) => reject(err))\n\n archive.pipe(output)\n archive.directory(sourceDir, false)\n\n void archive.finalize()\n })\n}\n"],"names":["archiver","createWriteStream","fs","path","buildLambdaZip","projectPath","standalonePath","join","staticPath","publicPath","runShPath","zipPath","isDirectory","Error","destStatic","copyDirectory","copyFile","destPublic","createZip","dirPath","stats","stat","src","dest","mkdir","recursive","entries","readdir","withFileTypes","entry","srcPath","name","destPath","sourceDir","Promise","resolve","reject","output","archive","zlib","level","on","err","pipe","directory","finalize"],"mappings":"AAAA,OAAOA,cAAc,WAAU;AAC/B,SAASC,iBAAiB,QAAQ,KAAI;AACtC,OAAOC,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB;;;;;;;;;;;CAWC,GACD,OAAO,eAAeC,eAAeC,WAAmB;IACtD,MAAMC,iBAAiBH,KAAKI,IAAI,CAACF,aAAa,SAAS;IACvD,MAAMG,aAAaL,KAAKI,IAAI,CAACF,aAAa,SAAS;IACnD,MAAMI,aAAaN,KAAKI,IAAI,CAACF,aAAa;IAC1C,MAAMK,YAAYP,KAAKI,IAAI,CAACF,aAAa;IACzC,MAAMM,UAAUR,KAAKI,IAAI,CAACF,aAAa;IAEvC,IAAI,CAAE,MAAMO,YAAYN,iBAAkB;QACxC,MAAM,IAAIO,MACR,qDACE;IAEN;IAEA,IAAI,MAAMD,YAAYJ,aAAa;QACjC,MAAMM,aAAaX,KAAKI,IAAI,CAACD,gBAAgB,SAAS;QACtD,MAAMS,cAAcP,YAAYM;IAClC;IAEA,IAAI;QACF,MAAMZ,GAAGc,QAAQ,CAACN,WAAWP,KAAKI,IAAI,CAACD,gBAAgB;IACzD,EAAE,OAAM;IACN,qCAAqC;IACvC;IAEA,IAAI,MAAMM,YAAYH,aAAa;QACjC,MAAMQ,aAAad,KAAKI,IAAI,CAACD,gBAAgB;QAC7C,MAAMS,cAAcN,YAAYQ;IAClC;IAEA,MAAMC,UAAUZ,gBAAgBK;AAClC;AAEA,eAAeC,YAAYO,OAAe;IACxC,IAAI;QACF,MAAMC,QAAQ,MAAMlB,GAAGmB,IAAI,CAACF;QAC5B,OAAOC,MAAMR,WAAW;IAC1B,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,eAAeG,cAAcO,GAAW,EAAEC,IAAY;IACpD,MAAMrB,GAAGsB,KAAK,CAACD,MAAM;QAAEE,WAAW;IAAK;IACvC,MAAMC,UAAU,MAAMxB,GAAGyB,OAAO,CAACL,KAAK;QAAEM,eAAe;IAAK;IAE5D,KAAK,MAAMC,SAASH,QAAS;QAC3B,MAAMI,UAAU3B,KAAKI,IAAI,CAACe,KAAKO,MAAME,IAAI;QACzC,MAAMC,WAAW7B,KAAKI,IAAI,CAACgB,MAAMM,MAAME,IAAI;QAE3C,IAAIF,MAAMjB,WAAW,IAAI;YACvB,MAAMG,cAAce,SAASE;QAC/B,OAAO;YACL,MAAM9B,GAAGc,QAAQ,CAACc,SAASE;QAC7B;IACF;AACF;AAEA,SAASd,UAAUe,SAAiB,EAAEtB,OAAe;IACnD,OAAO,IAAIuB,QAAQ,CAACC,SAASC;QAC3B,MAAMC,SAASpC,kBAAkBU;QACjC,MAAM2B,UAAUtC,SAAS,OAAO;YAAEuC,MAAM;gBAAEC,OAAO;YAAE;QAAE;QAErDH,OAAOI,EAAE,CAAC,SAAS,IAAMN;QACzBG,QAAQG,EAAE,CAAC,SAAS,CAACC,MAAQN,OAAOM;QAEpCJ,QAAQK,IAAI,CAACN;QACbC,QAAQM,SAAS,CAACX,WAAW;QAE7B,KAAKK,QAAQO,QAAQ;IACvB;AACF"}
@@ -19,7 +19,7 @@ const GITIGNORE_FILENAME = '.gitignore';
19
19
  }
20
20
  }
21
21
  // Parse existing entries
22
- const existingLines = existingContent.split('\n').filter((line)=>line.trim());
22
+ const existingLines = existingContent.split(/\r?\n/).filter((line)=>line.trim());
23
23
  const existingSet = new Set(existingLines);
24
24
  // Add new entries that don't exist
25
25
  const newEntries = entries.filter((entry)=>!existingSet.has(entry));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/config.ts"],"sourcesContent":["/**\n * Configuration file management utilities\n */\n\nimport fs from 'fs/promises'\nimport path from 'path'\n\nconst GITIGNORE_FILENAME = '.gitignore'\n\n/**\n * Ensure .gitignore exists and optionally add entries\n *\n * @param projectPath - Path to project directory\n * @param entries - Optional entries to add to .gitignore\n */\nexport async function ensureGitignore(projectPath: string, entries: string[] = []): Promise<void> {\n const gitignorePath = path.join(projectPath, GITIGNORE_FILENAME)\n\n let existingContent = ''\n try {\n existingContent = await fs.readFile(gitignorePath, 'utf-8')\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {\n throw new Error(`Failed to read ${GITIGNORE_FILENAME}: ${(error as Error).message}`)\n }\n }\n\n // Parse existing entries\n const existingLines = existingContent.split('\\n').filter((line) => line.trim())\n const existingSet = new Set(existingLines)\n\n // Add new entries that don't exist\n const newEntries = entries.filter((entry) => !existingSet.has(entry))\n\n if (newEntries.length > 0) {\n const newContent = existingContent\n ? `${existingContent.trimEnd()}\\n\\n# Figma CMS\\n${newEntries.join('\\n')}\\n`\n : `# Figma CMS\\n${newEntries.join('\\n')}\\n`\n\n await fs.writeFile(gitignorePath, newContent, 'utf-8')\n }\n}\n"],"names":["fs","path","GITIGNORE_FILENAME","ensureGitignore","projectPath","entries","gitignorePath","join","existingContent","readFile","error","code","Error","message","existingLines","split","filter","line","trim","existingSet","Set","newEntries","entry","has","length","newContent","trimEnd","writeFile"],"mappings":"AAAA;;CAEC,GAED,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,MAAMC,qBAAqB;AAE3B;;;;;CAKC,GACD,OAAO,eAAeC,gBAAgBC,WAAmB,EAAEC,UAAoB,EAAE;IAC/E,MAAMC,gBAAgBL,KAAKM,IAAI,CAACH,aAAaF;IAE7C,IAAIM,kBAAkB;IACtB,IAAI;QACFA,kBAAkB,MAAMR,GAAGS,QAAQ,CAACH,eAAe;IACrD,EAAE,OAAOI,OAAO;QACd,IAAI,AAACA,MAAgCC,IAAI,KAAK,UAAU;YACtD,MAAM,IAAIC,MAAM,CAAC,eAAe,EAAEV,mBAAmB,EAAE,EAAE,AAACQ,MAAgBG,OAAO,EAAE;QACrF;IACF;IAEA,yBAAyB;IACzB,MAAMC,gBAAgBN,gBAAgBO,KAAK,CAAC,MAAMC,MAAM,CAAC,CAACC,OAASA,KAAKC,IAAI;IAC5E,MAAMC,cAAc,IAAIC,IAAIN;IAE5B,mCAAmC;IACnC,MAAMO,aAAahB,QAAQW,MAAM,CAAC,CAACM,QAAU,CAACH,YAAYI,GAAG,CAACD;IAE9D,IAAID,WAAWG,MAAM,GAAG,GAAG;QACzB,MAAMC,aAAajB,kBACf,GAAGA,gBAAgBkB,OAAO,GAAG,iBAAiB,EAAEL,WAAWd,IAAI,CAAC,MAAM,EAAE,CAAC,GACzE,CAAC,aAAa,EAAEc,WAAWd,IAAI,CAAC,MAAM,EAAE,CAAC;QAE7C,MAAMP,GAAG2B,SAAS,CAACrB,eAAemB,YAAY;IAChD;AACF"}
1
+ {"version":3,"sources":["../../src/utils/config.ts"],"sourcesContent":["/**\n * Configuration file management utilities\n */\n\nimport fs from 'fs/promises'\nimport path from 'path'\n\nconst GITIGNORE_FILENAME = '.gitignore'\n\n/**\n * Ensure .gitignore exists and optionally add entries\n *\n * @param projectPath - Path to project directory\n * @param entries - Optional entries to add to .gitignore\n */\nexport async function ensureGitignore(projectPath: string, entries: string[] = []): Promise<void> {\n const gitignorePath = path.join(projectPath, GITIGNORE_FILENAME)\n\n let existingContent = ''\n try {\n existingContent = await fs.readFile(gitignorePath, 'utf-8')\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {\n throw new Error(`Failed to read ${GITIGNORE_FILENAME}: ${(error as Error).message}`)\n }\n }\n\n // Parse existing entries\n const existingLines = existingContent.split(/\\r?\\n/).filter((line) => line.trim())\n const existingSet = new Set(existingLines)\n\n // Add new entries that don't exist\n const newEntries = entries.filter((entry) => !existingSet.has(entry))\n\n if (newEntries.length > 0) {\n const newContent = existingContent\n ? `${existingContent.trimEnd()}\\n\\n# Figma CMS\\n${newEntries.join('\\n')}\\n`\n : `# Figma CMS\\n${newEntries.join('\\n')}\\n`\n\n await fs.writeFile(gitignorePath, newContent, 'utf-8')\n }\n}\n"],"names":["fs","path","GITIGNORE_FILENAME","ensureGitignore","projectPath","entries","gitignorePath","join","existingContent","readFile","error","code","Error","message","existingLines","split","filter","line","trim","existingSet","Set","newEntries","entry","has","length","newContent","trimEnd","writeFile"],"mappings":"AAAA;;CAEC,GAED,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,MAAMC,qBAAqB;AAE3B;;;;;CAKC,GACD,OAAO,eAAeC,gBAAgBC,WAAmB,EAAEC,UAAoB,EAAE;IAC/E,MAAMC,gBAAgBL,KAAKM,IAAI,CAACH,aAAaF;IAE7C,IAAIM,kBAAkB;IACtB,IAAI;QACFA,kBAAkB,MAAMR,GAAGS,QAAQ,CAACH,eAAe;IACrD,EAAE,OAAOI,OAAO;QACd,IAAI,AAACA,MAAgCC,IAAI,KAAK,UAAU;YACtD,MAAM,IAAIC,MAAM,CAAC,eAAe,EAAEV,mBAAmB,EAAE,EAAE,AAACQ,MAAgBG,OAAO,EAAE;QACrF;IACF;IAEA,yBAAyB;IACzB,MAAMC,gBAAgBN,gBAAgBO,KAAK,CAAC,SAASC,MAAM,CAAC,CAACC,OAASA,KAAKC,IAAI;IAC/E,MAAMC,cAAc,IAAIC,IAAIN;IAE5B,mCAAmC;IACnC,MAAMO,aAAahB,QAAQW,MAAM,CAAC,CAACM,QAAU,CAACH,YAAYI,GAAG,CAACD;IAE9D,IAAID,WAAWG,MAAM,GAAG,GAAG;QACzB,MAAMC,aAAajB,kBACf,GAAGA,gBAAgBkB,OAAO,GAAG,iBAAiB,EAAEL,WAAWd,IAAI,CAAC,MAAM,EAAE,CAAC,GACzE,CAAC,aAAa,EAAEc,WAAWd,IAAI,CAAC,MAAM,EAAE,CAAC;QAE7C,MAAMP,GAAG2B,SAAS,CAACrB,eAAemB,YAAY;IAChD;AACF"}
@@ -1,16 +1,17 @@
1
1
  /**
2
- * Generate a cryptographically secure secret for PAYLOAD_SECRET
2
+ * Get an environment variable value from .env file
3
3
  *
4
- * @returns 24-character hexadecimal string
4
+ * @param projectPath - Path to project directory
5
+ * @param key - Environment variable name to retrieve
6
+ * @returns The value if found, null otherwise
5
7
  */
6
- export declare function generateSecret(): string;
8
+ export declare function getEnvVar(projectPath: string, key: string): Promise<null | string>;
7
9
  /**
8
- * Manage environment files for a new project
9
- *
10
- * Creates .env from .env.example (if exists) and populates PAYLOAD_SECRET
10
+ * Add or update an environment variable in .env file
11
11
  *
12
12
  * @param projectPath - Path to project directory
13
- * @returns The generated payload secret
13
+ * @param key - Environment variable name
14
+ * @param value - Environment variable value
14
15
  */
15
- export declare function manageEnvFiles(projectPath: string): Promise<string>;
16
+ export declare function addOrUpdateEnvVar(projectPath: string, key: string, value: string): Promise<void>;
16
17
  //# sourceMappingURL=env-management.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"env-management.d.ts","sourceRoot":"","sources":["../../src/utils/env-management.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAoDD;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA8CzE"}
1
+ {"version":3,"file":"env-management.d.ts","sourceRoot":"","sources":["../../src/utils/env-management.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CA+BxF;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAmEf"}