@payloadcms/figma 0.0.1-alpha.8 → 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/control-plane.d.ts +56 -7
- package/dist/api/control-plane.js +188 -74
- package/dist/api/error-response.d.ts +36 -0
- package/dist/api/error-response.js +66 -0
- package/dist/api/figma-api.d.ts +24 -3
- package/dist/api/figma-api.js +110 -34
- package/dist/auth/browser.d.ts +0 -1
- package/dist/auth/browser.js +0 -2
- package/dist/auth/callback-server.d.ts +19 -8
- package/dist/auth/callback-server.js +72 -32
- package/dist/auth/credentials.d.ts +20 -0
- package/dist/auth/credentials.js +19 -0
- package/dist/auth/crypto-utils.d.ts +28 -1
- package/dist/auth/crypto-utils.js +132 -23
- package/dist/auth/jwt-validator.d.ts +23 -6
- package/dist/auth/jwt-validator.js +35 -9
- package/dist/auth/oauth-flow.d.ts +19 -4
- package/dist/auth/oauth-flow.js +151 -34
- package/dist/auth/paste-code.d.ts +33 -0
- package/dist/auth/paste-code.js +87 -0
- package/dist/auth/pkce.d.ts +0 -1
- package/dist/auth/pkce.js +0 -2
- package/dist/auth/project-token.d.ts +32 -17
- package/dist/auth/project-token.js +176 -68
- package/dist/auth/refresh.d.ts +2 -2
- package/dist/auth/refresh.js +25 -14
- package/dist/auth/token-store-migration.d.ts +57 -0
- package/dist/auth/token-store-migration.js +154 -0
- package/dist/auth/token-store.d.ts +63 -98
- package/dist/auth/token-store.js +405 -124
- package/dist/auth/types.d.ts +40 -6
- package/dist/auth/types.js +1 -3
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +102 -8
- package/dist/commands/bootstrap.d.ts +17 -0
- package/dist/commands/bootstrap.js +88 -0
- package/dist/commands/build-lambda-zip.d.ts +4 -0
- package/dist/commands/build-lambda-zip.js +17 -0
- package/dist/commands/debug.d.ts +7 -0
- package/dist/commands/debug.js +178 -0
- package/dist/commands/deploy.d.ts +11 -1
- package/dist/commands/deploy.js +193 -153
- package/dist/commands/dump-tokens.d.ts +11 -0
- package/dist/commands/dump-tokens.js +67 -0
- package/dist/commands/env.d.ts +12 -0
- package/dist/commands/env.js +86 -0
- package/dist/commands/init.d.ts +9 -6
- package/dist/commands/init.js +232 -152
- package/dist/commands/list-tokens.d.ts +3 -4
- package/dist/commands/list-tokens.js +24 -11
- package/dist/commands/login.d.ts +8 -2
- package/dist/commands/login.js +34 -18
- package/dist/commands/logout.d.ts +5 -5
- package/dist/commands/logout.js +77 -17
- package/dist/commands/upgrade.d.ts +4 -0
- package/dist/commands/upgrade.js +329 -0
- package/dist/commands/upload-schema.d.ts +8 -0
- package/dist/commands/upload-schema.js +91 -0
- package/dist/config/oauth.d.ts +17 -12
- package/dist/config/oauth.js +38 -39
- package/dist/constants.d.ts +63 -19
- package/dist/constants.js +158 -20
- package/dist/db-content-api/generated/content-api-types.d.ts +7574 -0
- package/dist/db-content-api/generated/content-api-types.js +5 -0
- package/dist/db-content-api/index.d.ts +37 -0
- package/dist/db-content-api/index.js +938 -0
- package/dist/db-content-api/temp-utilities/slug.d.ts +1 -0
- package/dist/db-content-api/temp-utilities/slug.js +1 -0
- package/dist/db-content-api/temp-utilities/sorting.d.ts +2 -0
- package/dist/db-content-api/temp-utilities/sorting.js +37 -0
- package/dist/db-content-api/temp-utilities/types.d.ts +21 -0
- package/dist/db-content-api/temp-utilities/types.js +13 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +38 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +62 -0
- package/dist/db-content-api/utilities/auth.d.ts +29 -0
- package/dist/db-content-api/utilities/auth.js +82 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +6 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +10 -0
- package/dist/db-content-api/utilities/data/castFieldValue.js +66 -0
- package/dist/db-content-api/utilities/data/index.d.ts +48 -0
- package/dist/db-content-api/utilities/data/index.js +299 -0
- package/dist/db-content-api/utilities/data/pointShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/pointShape.js +43 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +11 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +52 -0
- package/dist/db-content-api/utilities/data/richTextShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/richTextShape.js +56 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +47 -0
- package/dist/db-content-api/utilities/data/stripFields.js +170 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +22 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +40 -0
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +6 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +100 -0
- package/dist/db-content-api/utilities/joins.d.ts +52 -0
- package/dist/db-content-api/utilities/joins.js +137 -0
- package/dist/db-content-api/utilities/locale/index.d.ts +9 -0
- package/dist/db-content-api/utilities/locale/index.js +19 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +71 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +41 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js +39 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +16 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +243 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +12 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +60 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +9 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +100 -0
- package/dist/db-content-api/utilities/resolveBlocks.d.ts +19 -0
- package/dist/db-content-api/utilities/resolveBlocks.js +31 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +55 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +182 -0
- package/dist/db-content-api/utilities/where.d.ts +19 -0
- package/dist/db-content-api/utilities/where.js +106 -0
- package/dist/deploy/schedule-extract-plugin.d.ts +10 -0
- package/dist/deploy/schedule-extract-plugin.js +32 -0
- package/dist/endpoints/health.d.ts +2 -0
- package/dist/endpoints/health.js +9 -0
- package/dist/endpoints/schema.d.ts +2 -0
- package/dist/endpoints/schema.js +27 -0
- package/dist/exports/client.d.ts +2 -1
- package/dist/exports/client.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/lib/download-skill.d.ts +12 -0
- package/dist/lib/download-skill.js +77 -0
- package/dist/oauth/components/FigmaAvatar/index.d.ts +3 -0
- package/dist/oauth/components/FigmaAvatar/index.js +25 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +23 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +8 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +35 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +81 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.js +168 -0
- package/dist/oauth/components/LoginButton/index.d.ts +0 -1
- package/dist/oauth/components/LoginButton/index.js +156 -18
- package/dist/oauth/components/LoginButton/index.scss +75 -3
- package/dist/oauth/components/LogoutButton/index.d.ts +0 -1
- package/dist/oauth/components/LogoutButton/index.js +20 -9
- package/dist/oauth/defaults.d.ts +3 -2
- package/dist/oauth/defaults.js +79 -12
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +87 -84
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -6
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js +18 -5
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -4
- package/dist/oauth/exports/client.d.ts +0 -1
- package/dist/oauth/exports/client.js +0 -2
- package/dist/oauth/hooks/afterLogout.d.ts +0 -1
- package/dist/oauth/hooks/afterLogout.js +0 -2
- package/dist/oauth/hooks/me.d.ts +0 -1
- package/dist/oauth/hooks/me.js +0 -2
- package/dist/oauth/hooks/refresh.d.ts +0 -1
- package/dist/oauth/hooks/refresh.js +2 -3
- package/dist/oauth/index.d.ts +0 -1
- package/dist/oauth/index.js +27 -7
- package/dist/oauth/strategy/index.d.ts +0 -3
- package/dist/oauth/strategy/index.js +55 -34
- package/dist/oauth/types.d.ts +23 -7
- package/dist/oauth/types.js +0 -2
- package/dist/oauth/utilities/buildUnauthorizedRedirect.d.ts +14 -0
- package/dist/oauth/utilities/buildUnauthorizedRedirect.js +28 -0
- package/dist/oauth/utilities/clearCookie.d.ts +0 -1
- package/dist/oauth/utilities/clearCookie.js +5 -3
- package/dist/oauth/utilities/createCookieOptions.d.ts +0 -1
- package/dist/oauth/utilities/createCookieOptions.js +9 -4
- package/dist/oauth/utilities/createDebugLogger.d.ts +0 -1
- package/dist/oauth/utilities/createDebugLogger.js +0 -2
- package/dist/oauth/utilities/establishSession.d.ts +22 -0
- package/dist/oauth/utilities/establishSession.js +80 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +23 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.js +26 -0
- package/dist/oauth/utilities/extractOrigin.d.ts +0 -1
- package/dist/oauth/utilities/extractOrigin.js +0 -2
- package/dist/oauth/utilities/figmaHostnames.d.ts +2 -0
- package/dist/oauth/utilities/figmaHostnames.js +24 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js +0 -2
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -2
- package/dist/oauth/utilities/getAuthorizeURL.js +57 -4
- package/dist/oauth/utilities/getCookieExpiration.d.ts +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js +0 -2
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js +0 -2
- package/dist/oauth/utilities/getTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getTokenExp.js +0 -2
- package/dist/oauth/utilities/getUsernameField.d.ts +0 -1
- package/dist/oauth/utilities/getUsernameField.js +0 -2
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js +0 -2
- package/dist/oauth/utilities/isAbsoluteURL.d.ts +1 -0
- package/dist/oauth/utilities/isAbsoluteURL.js +1 -0
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +6 -0
- package/dist/oauth/utilities/isDuplicateKeyError.js +12 -0
- package/dist/oauth/utilities/mergeHeaders.d.ts +0 -1
- package/dist/oauth/utilities/mergeHeaders.js +0 -2
- package/dist/oauth/utilities/refreshTokens.d.ts +0 -1
- package/dist/oauth/utilities/refreshTokens.js +21 -13
- package/dist/oauth/utilities/withPartitionedCookie.d.ts +19 -0
- package/dist/oauth/utilities/withPartitionedCookie.js +26 -0
- package/dist/oauth/utils/getSearchParam.d.ts +17 -0
- package/dist/oauth/utils/getSearchParam.js +22 -0
- package/dist/plugin/adapter.d.ts +0 -1
- package/dist/plugin/adapter.js +0 -2
- package/dist/plugin/auth-preflight.d.ts +7 -0
- package/dist/plugin/auth-preflight.js +18 -0
- package/dist/plugin/bootstrap-preflight.d.ts +22 -0
- package/dist/plugin/bootstrap-preflight.js +43 -0
- package/dist/plugin/build-config.d.ts +27 -15
- package/dist/plugin/build-config.js +381 -18
- package/dist/plugin/dev-cookie-names.d.ts +13 -0
- package/dist/plugin/dev-cookie-names.js +17 -0
- package/dist/scss.d.js +2 -0
- package/dist/storage-content-api/api-types.d.ts +183 -0
- package/dist/storage-content-api/api-types.js +4 -0
- package/dist/storage-content-api/client-uploads/generate.d.ts +14 -0
- package/dist/storage-content-api/client-uploads/generate.js +69 -0
- package/dist/storage-content-api/client.d.ts +5 -0
- package/dist/storage-content-api/client.js +37 -0
- package/dist/storage-content-api/generateURL.d.ts +6 -0
- package/dist/storage-content-api/generateURL.js +6 -0
- package/dist/storage-content-api/handleDelete.d.ts +7 -0
- package/dist/storage-content-api/handleDelete.js +15 -0
- package/dist/storage-content-api/handleUpload.d.ts +10 -0
- package/dist/storage-content-api/handleUpload.js +162 -0
- package/dist/storage-content-api/index.d.ts +4 -0
- package/dist/storage-content-api/index.js +37 -0
- package/dist/storage-content-api/staticHandler.d.ts +9 -0
- package/dist/storage-content-api/staticHandler.js +61 -0
- package/dist/storage-content-api/types.d.ts +9 -0
- package/dist/storage-content-api/types.js +1 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +11 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +59 -0
- package/dist/storage-content-api/utilities/index.d.ts +2 -0
- package/dist/storage-content-api/utilities/index.js +2 -0
- package/dist/storage-content-api/utilities/parseUploadReference.d.ts +17 -0
- package/dist/storage-content-api/utilities/parseUploadReference.js +27 -0
- package/dist/templates/.env.example +5 -0
- package/dist/templates/README.md +19 -0
- package/dist/types/config.d.ts +2 -2
- package/dist/types/config.js +0 -4
- package/dist/types.d.ts +10 -2
- package/dist/types.js +0 -2
- package/dist/utils/adapters/nextjs.d.ts +8 -0
- package/dist/utils/adapters/nextjs.js +61 -0
- package/dist/utils/adapters/nitro.d.ts +8 -0
- package/dist/utils/adapters/nitro.js +172 -0
- package/dist/utils/adapters/vite.d.ts +9 -0
- package/dist/utils/adapters/vite.js +31 -0
- package/dist/utils/asset-collection.d.ts +27 -7
- package/dist/utils/asset-collection.js +59 -32
- package/dist/utils/build-detection.d.ts +5 -12
- package/dist/utils/build-detection.js +74 -13
- package/dist/utils/build-lambda-zip.d.ts +25 -0
- package/dist/utils/build-lambda-zip.js +90 -0
- package/dist/utils/cache-bootstrap.d.ts +7 -0
- package/dist/utils/cache-bootstrap.js +16 -0
- package/dist/utils/config.d.ts +0 -1
- package/dist/utils/config.js +1 -3
- package/dist/utils/deploy-adapter.d.ts +45 -0
- package/dist/utils/deploy-adapter.js +56 -0
- package/dist/utils/download-template.d.ts +9 -2
- package/dist/utils/download-template.js +24 -20
- package/dist/utils/env-management.d.ts +24 -8
- package/dist/utils/env-management.js +119 -66
- package/dist/utils/format-env-suffix.d.ts +11 -0
- package/dist/utils/format-env-suffix.js +11 -0
- package/dist/utils/format.d.ts +0 -1
- package/dist/utils/format.js +0 -2
- package/dist/utils/formatter.d.ts +0 -1
- package/dist/utils/formatter.js +23 -13
- package/dist/utils/fs-utils.d.ts +12 -0
- package/dist/utils/fs-utils.js +55 -0
- package/dist/utils/git.d.ts +0 -1
- package/dist/utils/git.js +0 -2
- package/dist/utils/handle-upgrade.d.ts +8 -0
- package/dist/utils/handle-upgrade.js +39 -0
- package/dist/utils/is-debug.d.ts +0 -1
- package/dist/utils/is-debug.js +0 -2
- package/dist/utils/lambda-config.d.ts +3 -2
- package/dist/utils/lambda-config.js +75 -80
- package/dist/utils/load-payload-config.d.ts +9 -0
- package/dist/utils/load-payload-config.js +27 -0
- package/dist/utils/log.d.ts +0 -1
- package/dist/utils/log.js +0 -2
- package/dist/utils/messages.d.ts +1 -3
- package/dist/utils/messages.js +47 -13
- package/dist/utils/package-manager.d.ts +24 -1
- package/dist/utils/package-manager.js +53 -2
- package/dist/utils/parse-template-spec.d.ts +11 -0
- package/dist/utils/parse-template-spec.js +60 -0
- package/dist/utils/payload-config-ast.d.ts +27 -7
- package/dist/utils/payload-config-ast.js +106 -60
- package/dist/utils/payload-config-finder.d.ts +2 -3
- package/dist/utils/payload-config-finder.js +48 -11
- package/dist/utils/payload-config-modifier.d.ts +1 -2
- package/dist/utils/payload-config-modifier.js +114 -68
- package/dist/utils/payload-package-check.d.ts +28 -3
- package/dist/utils/payload-package-check.js +90 -31
- package/dist/utils/project.d.ts +8 -4
- package/dist/utils/project.js +63 -37
- package/dist/utils/resolve-environment.d.ts +13 -0
- package/dist/utils/resolve-environment.js +29 -0
- package/dist/utils/s3-upload.d.ts +7 -3
- package/dist/utils/s3-upload.js +44 -9
- package/dist/utils/token-display.d.ts +5 -2
- package/dist/utils/token-display.js +49 -24
- package/dist/utils/typescript-validator.d.ts +0 -1
- package/dist/utils/typescript-validator.js +4 -8
- package/dist/utils/version-check.d.ts +2 -0
- package/dist/utils/version-check.js +43 -0
- package/package.json +47 -16
- package/dist/api/control-plane.d.ts.map +0 -1
- package/dist/api/control-plane.js.map +0 -1
- package/dist/api/figma-api.d.ts.map +0 -1
- package/dist/api/figma-api.js.map +0 -1
- package/dist/auth/browser.d.ts.map +0 -1
- package/dist/auth/browser.js.map +0 -1
- package/dist/auth/callback-server.d.ts.map +0 -1
- package/dist/auth/callback-server.js.map +0 -1
- package/dist/auth/crypto-utils.d.ts.map +0 -1
- package/dist/auth/crypto-utils.js.map +0 -1
- package/dist/auth/jwt-validator.d.ts.map +0 -1
- package/dist/auth/jwt-validator.js.map +0 -1
- package/dist/auth/oauth-flow.d.ts.map +0 -1
- package/dist/auth/oauth-flow.js.map +0 -1
- package/dist/auth/pkce.d.ts.map +0 -1
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/project-token.d.ts.map +0 -1
- package/dist/auth/project-token.js.map +0 -1
- package/dist/auth/refresh.d.ts.map +0 -1
- package/dist/auth/refresh.js.map +0 -1
- package/dist/auth/token-store.d.ts.map +0 -1
- package/dist/auth/token-store.js.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list-tokens.d.ts.map +0 -1
- package/dist/commands/list-tokens.js.map +0 -1
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js.map +0 -1
- package/dist/config/oauth.d.ts.map +0 -1
- package/dist/config/oauth.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/exports/client.d.ts.map +0 -1
- package/dist/exports/client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LoginButton/index.js.map +0 -1
- package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LogoutButton/index.js.map +0 -1
- package/dist/oauth/defaults.d.ts.map +0 -1
- package/dist/oauth/defaults.js.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
- package/dist/oauth/exports/client.d.ts.map +0 -1
- package/dist/oauth/exports/client.js.map +0 -1
- package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
- package/dist/oauth/hooks/afterLogout.js.map +0 -1
- package/dist/oauth/hooks/me.d.ts.map +0 -1
- package/dist/oauth/hooks/me.js.map +0 -1
- package/dist/oauth/hooks/refresh.d.ts.map +0 -1
- package/dist/oauth/hooks/refresh.js.map +0 -1
- package/dist/oauth/index.d.ts.map +0 -1
- package/dist/oauth/index.js.map +0 -1
- package/dist/oauth/strategy/index.d.ts.map +0 -1
- package/dist/oauth/strategy/index.js.map +0 -1
- package/dist/oauth/types.d.ts.map +0 -1
- package/dist/oauth/types.js.map +0 -1
- package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
- package/dist/oauth/utilities/clearCookie.js.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
- package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
- package/dist/oauth/utilities/extractOrigin.js.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
- package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
- package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminPath.js +0 -9
- package/dist/oauth/utilities/getAdminPath.js.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
- package/dist/oauth/utilities/getUsernameField.js.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
- package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
- package/dist/oauth/utilities/refreshTokens.js.map +0 -1
- package/dist/plugin/adapter.d.ts.map +0 -1
- package/dist/plugin/adapter.js.map +0 -1
- package/dist/plugin/build-config.d.ts.map +0 -1
- package/dist/plugin/build-config.js.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/asset-collection.d.ts.map +0 -1
- package/dist/utils/asset-collection.js.map +0 -1
- package/dist/utils/build-detection.d.ts.map +0 -1
- package/dist/utils/build-detection.js.map +0 -1
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/download-template.d.ts.map +0 -1
- package/dist/utils/download-template.js.map +0 -1
- package/dist/utils/env-management.d.ts.map +0 -1
- package/dist/utils/env-management.js.map +0 -1
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/formatter.d.ts.map +0 -1
- package/dist/utils/formatter.js.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/is-debug.d.ts.map +0 -1
- package/dist/utils/is-debug.js.map +0 -1
- package/dist/utils/lambda-config.d.ts.map +0 -1
- package/dist/utils/lambda-config.js.map +0 -1
- package/dist/utils/log.d.ts.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/messages.d.ts.map +0 -1
- package/dist/utils/messages.js.map +0 -1
- package/dist/utils/package-manager.d.ts.map +0 -1
- package/dist/utils/package-manager.js.map +0 -1
- package/dist/utils/payload-config-ast.d.ts.map +0 -1
- package/dist/utils/payload-config-ast.js.map +0 -1
- package/dist/utils/payload-config-finder.d.ts.map +0 -1
- package/dist/utils/payload-config-finder.js.map +0 -1
- package/dist/utils/payload-config-modifier.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.js.map +0 -1
- package/dist/utils/payload-package-check.d.ts.map +0 -1
- package/dist/utils/payload-package-check.js.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/project.js.map +0 -1
- package/dist/utils/s3-upload.d.ts.map +0 -1
- package/dist/utils/s3-upload.js.map +0 -1
- package/dist/utils/token-display.d.ts.map +0 -1
- package/dist/utils/token-display.js.map +0 -1
- package/dist/utils/typescript-validator.d.ts.map +0 -1
- package/dist/utils/typescript-validator.js.map +0 -1
package/dist/commands/deploy.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as p from '@clack/prompts';
|
|
2
|
-
import
|
|
3
|
-
import path from 'path';
|
|
2
|
+
import spawn from 'cross-spawn';
|
|
4
3
|
import pc from 'picocolors';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { collectStaticAssets, createLambdaZip, getFileSize } from '../utils/asset-collection.js';
|
|
4
|
+
import { ControlPlaneError, createDeployment, getBootstrapInfo, performDeployment } from '../api/control-plane.js';
|
|
5
|
+
import { tryGetCredential } from '../auth/oauth-flow.js';
|
|
6
|
+
import { getTokenStore } from '../auth/token-store.js';
|
|
7
|
+
import { getInfraEnvironment, getProjectNotFoundMessage } from '../constants.js';
|
|
8
|
+
import { getFileSize } from '../utils/asset-collection.js';
|
|
11
9
|
import { detectBuild, getBuildCommand } from '../utils/build-detection.js';
|
|
10
|
+
import { LAMBDA_MAX_UNZIPPED_BYTES } from '../utils/build-lambda-zip.js';
|
|
11
|
+
import { detectAdapter } from '../utils/deploy-adapter.js';
|
|
12
|
+
import { getEnvVar } from '../utils/env-management.js';
|
|
12
13
|
import * as log from '../utils/log.js';
|
|
13
14
|
import { getPackageManager } from '../utils/package-manager.js';
|
|
14
|
-
import { readFigmaConfig } from '../utils/payload-config-ast.js';
|
|
15
|
-
import { findPayloadConfig } from '../utils/payload-config-finder.js';
|
|
16
15
|
import { isInProjectDirectory } from '../utils/project.js';
|
|
16
|
+
import { resolveEnvironment } from '../utils/resolve-environment.js';
|
|
17
17
|
import { uploadLambdaZip, uploadStaticAssets } from '../utils/s3-upload.js';
|
|
18
18
|
import { loginCommand } from './login.js';
|
|
19
19
|
/**
|
|
@@ -51,6 +51,17 @@ import { loginCommand } from './login.js';
|
|
|
51
51
|
*/ export async function deployCommand(options) {
|
|
52
52
|
const projectPath = process.cwd();
|
|
53
53
|
const spinner = p.spinner();
|
|
54
|
+
// Resolve project ID
|
|
55
|
+
let projectId = options.id;
|
|
56
|
+
if (!projectId) {
|
|
57
|
+
projectId = await getEnvVar(projectPath, 'FIGMA_PROJECT_ID') ?? undefined;
|
|
58
|
+
}
|
|
59
|
+
if (!projectId) {
|
|
60
|
+
p.log.error(pc.red('✗ Project ID not found. Run `@payloadcms/figma init` first, or use --id.'));
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
// Resolve environment name
|
|
64
|
+
const environmentName = options.env ?? await getEnvVar(projectPath, 'FIGMA_ENVIRONMENT_NAME') ?? undefined;
|
|
54
65
|
try {
|
|
55
66
|
// ===== PRE-FLIGHT CHECKS =====
|
|
56
67
|
// Check if in project directory
|
|
@@ -59,71 +70,71 @@ import { loginCommand } from './login.js';
|
|
|
59
70
|
p.note('Create a project or connect an existing one to Figma: npx @payloadcms/figma init', 'Tip');
|
|
60
71
|
process.exit(1);
|
|
61
72
|
}
|
|
62
|
-
// Find and read payload config
|
|
63
|
-
const configPath = await findPayloadConfig(projectPath);
|
|
64
|
-
if (!configPath) {
|
|
65
|
-
p.log.error(pc.red('✗ payload.config.ts not found'));
|
|
66
|
-
p.note('Run npx @payloadcms/figma init to configure your project.', 'Tip');
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
// Parse config with ts-morph
|
|
70
|
-
const project = new Project({
|
|
71
|
-
skipAddingFilesFromTsConfig: true
|
|
72
|
-
});
|
|
73
|
-
const sourceFile = project.addSourceFileAtPath(configPath);
|
|
74
|
-
// Read figma configuration from buildConfig
|
|
75
|
-
const config = readFigmaConfig(sourceFile);
|
|
76
|
-
if (!config || !config.tenantId) {
|
|
77
|
-
p.log.error(pc.red('✗ No figma configuration found in payload.config.ts'));
|
|
78
|
-
p.note('Run npx @payloadcms/figma init to configure your project.', 'Tip');
|
|
79
|
-
process.exit(1);
|
|
80
|
-
}
|
|
81
73
|
// Check authentication
|
|
82
|
-
const tokenStore =
|
|
83
|
-
let
|
|
84
|
-
if (!
|
|
74
|
+
const tokenStore = getTokenStore();
|
|
75
|
+
let credential = await tryGetCredential(tokenStore);
|
|
76
|
+
if (!credential) {
|
|
85
77
|
p.log.message('Please log in to continue');
|
|
86
78
|
await loginCommand();
|
|
87
|
-
|
|
88
|
-
if (!
|
|
79
|
+
credential = await tryGetCredential(tokenStore);
|
|
80
|
+
if (!credential) {
|
|
89
81
|
p.log.error(pc.red('✗ Authentication failed'));
|
|
90
82
|
process.exit(1);
|
|
91
83
|
}
|
|
92
84
|
}
|
|
93
|
-
//
|
|
85
|
+
// Resolve tenant instance ID via bootstrap
|
|
86
|
+
spinner.start('Resolving deployment target...');
|
|
87
|
+
let tenantInstanceId;
|
|
94
88
|
try {
|
|
95
|
-
await
|
|
89
|
+
const bootstrapInfo = await getBootstrapInfo(credential, projectId);
|
|
90
|
+
const resolvedEnv = resolveEnvironment({
|
|
91
|
+
environmentName,
|
|
92
|
+
environments: bootstrapInfo.environments
|
|
93
|
+
});
|
|
94
|
+
tenantInstanceId = resolvedEnv.tenantInstanceId;
|
|
95
|
+
spinner.stop(pc.green(`✓ Target: ${resolvedEnv.name}`));
|
|
96
96
|
} catch (error) {
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
if (error instanceof ControlPlaneError && (error.statusCode === 404 || error.statusCode === 410)) {
|
|
98
|
+
spinner.stop(pc.red('✗ Project not found'));
|
|
99
|
+
p.log.error(pc.red(getProjectNotFoundMessage({
|
|
100
|
+
environment: getInfraEnvironment(),
|
|
101
|
+
projectId
|
|
102
|
+
})));
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
spinner.stop(pc.red('✗ Failed to resolve deployment target'));
|
|
106
|
+
p.log.error(error instanceof Error ? error.message : 'Unknown error');
|
|
107
|
+
process.exit(1);
|
|
99
108
|
}
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
//
|
|
109
|
+
// Signal buildFigmaConfig to extract schedules during build
|
|
110
|
+
process.env.FIGMA_EXTRACT_SCHEDULES = 'true';
|
|
111
|
+
// ===== BUILD =====
|
|
112
|
+
let buildInfo;
|
|
113
|
+
if (options.skipBuild) {
|
|
114
|
+
// User asserts build exists - verify it
|
|
115
|
+
spinner.start('Checking for build...');
|
|
116
|
+
buildInfo = await detectBuild(projectPath);
|
|
117
|
+
if (!buildInfo) {
|
|
118
|
+
spinner.stop(pc.red('✗ No build found'));
|
|
119
|
+
p.log.error('Use deploy without --skip-build to build first.');
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
spinner.stop(pc.green('✓ Build found'));
|
|
123
|
+
p.note([
|
|
124
|
+
`${pc.cyan('Build ID:')} ${buildInfo.buildId}`,
|
|
125
|
+
`${pc.cyan('Date:')} ${formatDate(buildInfo.timestamp)}`
|
|
126
|
+
].join('\n'), 'Build Details');
|
|
127
|
+
} else {
|
|
128
|
+
// Always build (no prompt)
|
|
106
129
|
const buildCmd = await getBuildCommand(projectPath);
|
|
107
130
|
if (!buildCmd) {
|
|
108
131
|
p.log.error('No build script found in package.json');
|
|
109
132
|
p.note('Add a build script to package.json: "build": "next build"', 'Tip');
|
|
110
133
|
process.exit(1);
|
|
111
134
|
}
|
|
112
|
-
// Prompt to run build
|
|
113
|
-
if (!options.yes) {
|
|
114
|
-
const shouldBuild = await p.confirm({
|
|
115
|
-
initialValue: true,
|
|
116
|
-
message: `Build command found in package.json. Run it?`
|
|
117
|
-
});
|
|
118
|
-
if (p.isCancel(shouldBuild) || !shouldBuild) {
|
|
119
|
-
p.log.message('Cancelling deployment...');
|
|
120
|
-
process.exit(0);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
// Run build
|
|
124
135
|
const packageManager = await getPackageManager(projectPath);
|
|
125
136
|
const buildCommand = `${packageManager} run build`;
|
|
126
|
-
|
|
137
|
+
p.log.step(`Running ${buildCommand}...\n`);
|
|
127
138
|
try {
|
|
128
139
|
// Stream build output to user with formatting
|
|
129
140
|
const buildProcess = spawn(packageManager, [
|
|
@@ -139,20 +150,20 @@ import { loginCommand } from './login.js';
|
|
|
139
150
|
});
|
|
140
151
|
// Indent and dim output
|
|
141
152
|
buildProcess.stdout?.on('data', (data)=>{
|
|
142
|
-
const lines = data.toString().split(
|
|
153
|
+
const lines = data.toString().split(/\r?\n/);
|
|
143
154
|
lines.forEach((line)=>{
|
|
144
155
|
if (line.trim()) {
|
|
145
156
|
// eslint-disable-next-line no-console
|
|
146
|
-
console.log(pc.dim(` ${line}`));
|
|
157
|
+
console.log(pc.dim(` ${line}`));
|
|
147
158
|
}
|
|
148
159
|
});
|
|
149
160
|
});
|
|
150
161
|
buildProcess.stderr?.on('data', (data)=>{
|
|
151
|
-
const lines = data.toString().split(
|
|
162
|
+
const lines = data.toString().split(/\r?\n/);
|
|
152
163
|
lines.forEach((line)=>{
|
|
153
164
|
if (line.trim()) {
|
|
154
165
|
// eslint-disable-next-line no-console
|
|
155
|
-
console.log(pc.dim(` ${line}`));
|
|
166
|
+
console.log(pc.dim(` ${line}`));
|
|
156
167
|
}
|
|
157
168
|
});
|
|
158
169
|
});
|
|
@@ -170,135 +181,164 @@ import { loginCommand } from './login.js';
|
|
|
170
181
|
}
|
|
171
182
|
process.exit(1);
|
|
172
183
|
}
|
|
173
|
-
//
|
|
184
|
+
// Verify build output
|
|
174
185
|
buildInfo = await detectBuild(projectPath);
|
|
175
186
|
if (!buildInfo) {
|
|
176
|
-
p.log.error(pc.red('✗ Build completed but
|
|
177
|
-
p.note('Ensure
|
|
187
|
+
p.log.error(pc.red('✗ Build completed but build output not found'));
|
|
188
|
+
p.note('Ensure your build produces a valid output directory.', 'Check Build Configuration');
|
|
178
189
|
process.exit(1);
|
|
179
190
|
}
|
|
180
|
-
} else {
|
|
181
|
-
spinner.stop(pc.green('✓ Build found'));
|
|
182
|
-
p.note([
|
|
183
|
-
`${pc.cyan('Build ID:')} ${buildInfo.buildId}`,
|
|
184
|
-
`${pc.cyan('Date:')} ${formatDate(buildInfo.timestamp)}`
|
|
185
|
-
].join('\n'), 'Build Details');
|
|
186
191
|
}
|
|
187
192
|
// ===== DEPLOYMENT PREPARATION =====
|
|
188
|
-
//
|
|
193
|
+
// Detect framework adapter
|
|
194
|
+
spinner.start('Detecting framework...');
|
|
195
|
+
const adapter = await detectAdapter(projectPath, options.adapter);
|
|
196
|
+
spinner.stop(pc.green(`✓ Detected ${adapter.name} adapter`));
|
|
197
|
+
// Collect pages and assets
|
|
198
|
+
spinner.start('Collecting assets...');
|
|
199
|
+
const pages = await adapter.collectPages(projectPath);
|
|
200
|
+
const assets = await adapter.collectAssets(projectPath);
|
|
201
|
+
spinner.stop(pc.green(`✓ ${pages.routes.length} pages, ${assets.routes.length} assets detected`));
|
|
202
|
+
// Create deployment package (if server adapter)
|
|
203
|
+
let zipPath = null;
|
|
204
|
+
let zipSize = 0;
|
|
205
|
+
let unzippedBytes = 0;
|
|
189
206
|
spinner.start('Creating deployment package...');
|
|
190
207
|
try {
|
|
191
|
-
await
|
|
192
|
-
|
|
208
|
+
const bundle = await adapter.prepareLambdaBundle(projectPath);
|
|
209
|
+
if (bundle) {
|
|
210
|
+
zipPath = bundle.zipPath;
|
|
211
|
+
unzippedBytes = bundle.unzippedBytes;
|
|
212
|
+
zipSize = await getFileSize(zipPath);
|
|
213
|
+
spinner.stop(pc.green(`✓ Deployment package created (${formatBytes(zipSize)} zipped, ${formatBytes(unzippedBytes)} unzipped)`));
|
|
214
|
+
} else {
|
|
215
|
+
spinner.stop(pc.green('✓ Static site — no server package needed'));
|
|
216
|
+
}
|
|
193
217
|
} catch (error) {
|
|
194
218
|
spinner.stop(pc.red('✗ Failed to create deployment package'));
|
|
195
219
|
throw error;
|
|
196
220
|
}
|
|
197
|
-
//
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
221
|
+
// Pre-flight: fail fast before the long upload when the unzipped bundle exceeds
|
|
222
|
+
// AWS Lambda's limit. The server enforces this too (and now returns a clear
|
|
223
|
+
// message), so --skip-size-check is a safe escape hatch if this client-side
|
|
224
|
+
// value ever drifts below the real limit.
|
|
225
|
+
if (zipPath && !options.skipSizeCheck && unzippedBytes >= LAMBDA_MAX_UNZIPPED_BYTES) {
|
|
226
|
+
spinner.stop(pc.red(`✗ Unzipped deployment size (${formatBytes(unzippedBytes)}) is at or over the ${formatBytes(LAMBDA_MAX_UNZIPPED_BYTES)} limit.`));
|
|
227
|
+
p.note('Reduce your deployment size (remove unused dependencies or large assets) and try again.\n' + 'To bypass this client-side check, re-run with --skip-size-check.', 'Deployment too large');
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
log.debug(`Adapter: ${adapter.name}`);
|
|
231
|
+
if (zipPath) {
|
|
232
|
+
log.debug(`Lambda zip size: ${formatBytes(zipSize)}`);
|
|
233
|
+
}
|
|
234
|
+
log.debug(`Pages: ${pages.routes.length} routes (${pages.uploadKeys.length} files)`);
|
|
235
|
+
log.debug(`Assets: ${assets.routes.length} files`);
|
|
205
236
|
// ===== DEPLOYMENT CONFIRMATION =====
|
|
206
237
|
if (!options.yes) {
|
|
207
238
|
p.note([
|
|
239
|
+
`${pc.cyan('Adapter:')} ${adapter.name}`,
|
|
208
240
|
`${pc.cyan('Build ID:')} ${buildInfo.buildId}`,
|
|
209
|
-
`${pc.cyan('
|
|
210
|
-
`${pc.cyan('
|
|
211
|
-
`${pc.cyan('
|
|
241
|
+
zipPath ? `${pc.cyan('Code size:')} ${formatBytes(zipSize)} zipped, ${formatBytes(unzippedBytes)} unzipped` : `${pc.cyan('Code:')} No server`,
|
|
242
|
+
`${pc.cyan('Pages:')} ${pages.routes.length} routes (${pages.uploadKeys.length} files)`,
|
|
243
|
+
`${pc.cyan('Assets:')} ${assets.uploadKeys.length} files`
|
|
212
244
|
].join('\n'), 'Details');
|
|
213
|
-
const shouldDeploy = await p.confirm({
|
|
214
|
-
initialValue: true,
|
|
215
|
-
message: 'Deploy this build to Figma?'
|
|
216
|
-
});
|
|
217
|
-
if (p.isCancel(shouldDeploy) || !shouldDeploy) {
|
|
218
|
-
p.log.message('Cancelling deployment...');
|
|
219
|
-
process.exit(0);
|
|
220
|
-
}
|
|
221
245
|
}
|
|
222
246
|
// ===== DEPLOYMENT EXECUTION =====
|
|
223
247
|
// Step 1: Create deployment
|
|
224
248
|
spinner.start('Creating deployment...');
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
});
|
|
232
|
-
deploymentId = createResponse.deploymentId;
|
|
233
|
-
codeUploadUrl = createResponse.codeUploadUrl;
|
|
234
|
-
staticAssetUploadUrls = createResponse.staticAssetUploadUrls;
|
|
235
|
-
log.debug(`Deployment ID: ${deploymentId}`);
|
|
236
|
-
} catch (error) {
|
|
237
|
-
spinner.stop(pc.red('✗ Failed to create deployment'));
|
|
238
|
-
throw error;
|
|
249
|
+
// Build pages payload from route → asset keys mapping
|
|
250
|
+
const pagesPayload = {};
|
|
251
|
+
for (const [route, assetKeys] of Object.entries(pages.routeAssetMap)){
|
|
252
|
+
pagesPayload[route] = {
|
|
253
|
+
assets: assetKeys
|
|
254
|
+
};
|
|
239
255
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
256
|
+
const createResponse = await createDeployment(credential, tenantInstanceId, {
|
|
257
|
+
adapter: adapter.name,
|
|
258
|
+
fallback: adapter.fallback,
|
|
259
|
+
pages: pagesPayload,
|
|
260
|
+
staticAssets: assets.uploadKeys
|
|
261
|
+
});
|
|
262
|
+
const deploymentId = createResponse.deploymentId;
|
|
263
|
+
const codeUploadUrl = createResponse.codeUploadUrl;
|
|
264
|
+
const staticAssetUploadUrls = createResponse.staticAssetUploadUrls;
|
|
265
|
+
const pageUploadUrls = createResponse.pageUploadUrls;
|
|
266
|
+
log.debug(`Deployment ID: ${deploymentId}`);
|
|
267
|
+
// Step 2: Upload code (skip for static sites)
|
|
268
|
+
if (zipPath) {
|
|
269
|
+
spinner.message(`Uploading code (${formatBytes(zipSize)})...`);
|
|
243
270
|
await uploadLambdaZip(zipPath, codeUploadUrl);
|
|
244
271
|
spinner.stop(pc.green(`✓ Code uploaded (${formatBytes(zipSize)})`));
|
|
245
|
-
} catch (error) {
|
|
246
|
-
spinner.stop(pc.red('✗ Failed to upload code'));
|
|
247
|
-
throw error;
|
|
248
272
|
}
|
|
249
|
-
// Step 3: Upload
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
273
|
+
// Step 3: Upload page assets
|
|
274
|
+
const totalUploadCount = pages.uploadKeys.length + assets.uploadKeys.length;
|
|
275
|
+
let totalUploaded = 0;
|
|
276
|
+
let totalFailed = 0;
|
|
277
|
+
let totalBytes = 0;
|
|
278
|
+
if (pages.uploadKeys.length > 0) {
|
|
279
|
+
spinner.start('Uploading pages...');
|
|
280
|
+
const pageResults = await uploadStaticAssets({
|
|
281
|
+
assetUrls: pageUploadUrls,
|
|
282
|
+
onProgress: (uploaded, total)=>{
|
|
283
|
+
spinner.message(`Uploading pages (${uploaded}/${total})...`);
|
|
284
|
+
},
|
|
285
|
+
pathMap: pages.pathMap,
|
|
286
|
+
projectPath
|
|
287
|
+
});
|
|
288
|
+
totalUploaded += pageResults.assetsUploaded;
|
|
289
|
+
totalFailed += pageResults.assetsFailed;
|
|
290
|
+
totalBytes += pageResults.totalBytesUploaded;
|
|
291
|
+
spinner.stop(pc.green(`✓ ${pageResults.assetsUploaded} page files uploaded`));
|
|
266
292
|
}
|
|
267
|
-
// Step 4:
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
await
|
|
271
|
-
|
|
293
|
+
// Step 4: Upload static assets
|
|
294
|
+
if (assets.uploadKeys.length > 0) {
|
|
295
|
+
spinner.start('Uploading assets...');
|
|
296
|
+
const assetResults = await uploadStaticAssets({
|
|
297
|
+
assetUrls: staticAssetUploadUrls,
|
|
298
|
+
onProgress: (uploaded, total)=>{
|
|
299
|
+
spinner.message(`Uploading assets (${uploaded}/${total})...`);
|
|
300
|
+
},
|
|
301
|
+
pathMap: assets.pathMap,
|
|
302
|
+
projectPath
|
|
272
303
|
});
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
304
|
+
totalUploaded += assetResults.assetsUploaded;
|
|
305
|
+
totalFailed += assetResults.assetsFailed;
|
|
306
|
+
totalBytes += assetResults.totalBytesUploaded;
|
|
307
|
+
spinner.stop(pc.green(`✓ ${assetResults.assetsUploaded} asset files uploaded`));
|
|
308
|
+
}
|
|
309
|
+
if (totalFailed > 0) {
|
|
310
|
+
p.log.warning(`${totalFailed}/${totalUploadCount} files failed to upload. Deployment may be incomplete.`);
|
|
311
|
+
} else if (totalUploaded > 0) {
|
|
312
|
+
p.log.success(pc.green(`✓ All files uploaded (${totalUploaded} files, ${formatBytes(totalBytes)})`));
|
|
277
313
|
}
|
|
314
|
+
// Step 4: Perform deployment
|
|
315
|
+
spinner.start('Performing deployment...');
|
|
316
|
+
const result = await performDeployment(credential, tenantInstanceId, {
|
|
317
|
+
deploymentId
|
|
318
|
+
});
|
|
319
|
+
const tenantDomains = result.tenantDomains ?? [];
|
|
320
|
+
spinner.stop(pc.green('✓ Deployment initiated'));
|
|
278
321
|
// TODO: Add deployment progress tracking
|
|
279
322
|
// Future: Poll deployment status and show progress
|
|
280
323
|
// API endpoint: GET /v1/tenant/{tenant_id}/deploy/{deployment_id}/status
|
|
281
324
|
// Success output
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
try {
|
|
285
|
-
const tenant = await getTenantDetails(accessToken, config.tenantId);
|
|
286
|
-
if (tenant.domain) {
|
|
287
|
-
p.log.message(`View: ${pc.cyan(`https://${tenant.domain}/`)}`);
|
|
288
|
-
}
|
|
289
|
-
} catch {
|
|
290
|
-
// Non-critical - just skip URL display
|
|
325
|
+
if (tenantDomains.length > 0) {
|
|
326
|
+
p.log.step(`URL: ${pc.cyan(`https://${tenantDomains[0]}`)}`);
|
|
291
327
|
}
|
|
292
|
-
p.
|
|
328
|
+
p.log.step('This usually takes 2-3 minutes to complete.');
|
|
293
329
|
} catch (error) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
330
|
+
if (error instanceof ControlPlaneError) {
|
|
331
|
+
spinner.stop(pc.red(`✗ ${error.message}`));
|
|
332
|
+
if (error.statusCode) {
|
|
333
|
+
p.log.message(pc.dim(` HTTP ${error.statusCode}`));
|
|
334
|
+
}
|
|
335
|
+
} else {
|
|
336
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
337
|
+
spinner.stop(pc.red(`✗ ${message}`));
|
|
338
|
+
}
|
|
297
339
|
if (options.debug && error instanceof Error && error.stack) {
|
|
298
340
|
log.error(`Stack trace: ${error.stack}`);
|
|
299
341
|
}
|
|
300
342
|
process.exit(1);
|
|
301
343
|
}
|
|
302
344
|
}
|
|
303
|
-
|
|
304
|
-
//# sourceMappingURL=deploy.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handle the `@payloadcms/figma dump-tokens` command
|
|
3
|
+
*
|
|
4
|
+
* Exports decrypted versions of encrypted token store files in
|
|
5
|
+
* `oauth/` and `projects/` subdirectories (new structure) plus any legacy
|
|
6
|
+
* per-env directories from older package versions. Creates
|
|
7
|
+
* `.decrypted.json` files next to each encrypted `.json` file.
|
|
8
|
+
*
|
|
9
|
+
* Skips the `payloadcms-figma-crypto.json` salt file at the root.
|
|
10
|
+
*/
|
|
11
|
+
export declare function dumpTokensCommand(): Promise<void>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import envPaths from 'env-paths';
|
|
3
|
+
import fsSync from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import pc from 'picocolors';
|
|
6
|
+
import { deriveEncryptionKey, exportDecryptedStoreFiles } from '../auth/crypto-utils.js';
|
|
7
|
+
/**
|
|
8
|
+
* Handle the `@payloadcms/figma dump-tokens` command
|
|
9
|
+
*
|
|
10
|
+
* Exports decrypted versions of encrypted token store files in
|
|
11
|
+
* `oauth/` and `projects/` subdirectories (new structure) plus any legacy
|
|
12
|
+
* per-env directories from older package versions. Creates
|
|
13
|
+
* `.decrypted.json` files next to each encrypted `.json` file.
|
|
14
|
+
*
|
|
15
|
+
* Skips the `payloadcms-figma-crypto.json` salt file at the root.
|
|
16
|
+
*/ export async function dumpTokensCommand() {
|
|
17
|
+
const encryptionKey = deriveEncryptionKey();
|
|
18
|
+
const newRoot = envPaths('payloadcms-figma').config;
|
|
19
|
+
const stagingLegacyRoot = envPaths('payloadcms-figma-staging').config;
|
|
20
|
+
const candidateDirs = [
|
|
21
|
+
path.join(newRoot, 'oauth'),
|
|
22
|
+
path.join(newRoot, 'projects'),
|
|
23
|
+
stagingLegacyRoot
|
|
24
|
+
];
|
|
25
|
+
const targetDirs = Array.from(new Set(candidateDirs)).filter((dir)=>fsSync.existsSync(dir));
|
|
26
|
+
if (targetDirs.length === 0) {
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.log('No token store directories found.');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
console.log(pc.yellow('⚠ dump-tokens writes DECRYPTED token files to disk.'));
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.log('Target directories:');
|
|
35
|
+
for (const dir of targetDirs){
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
37
|
+
console.log(` ${dir}`);
|
|
38
|
+
}
|
|
39
|
+
// eslint-disable-next-line no-console
|
|
40
|
+
console.log('');
|
|
41
|
+
const confirmed = await p.confirm({
|
|
42
|
+
initialValue: false,
|
|
43
|
+
message: 'Continue? Remember to delete the decrypted files after use.'
|
|
44
|
+
});
|
|
45
|
+
if (p.isCancel(confirmed) || !confirmed) {
|
|
46
|
+
// eslint-disable-next-line no-console
|
|
47
|
+
console.log('Cancelled.');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const decryptedFiles = [];
|
|
51
|
+
for (const dir of targetDirs){
|
|
52
|
+
decryptedFiles.push(...exportDecryptedStoreFiles(dir, encryptionKey));
|
|
53
|
+
}
|
|
54
|
+
if (decryptedFiles.length === 0) {
|
|
55
|
+
// eslint-disable-next-line no-console
|
|
56
|
+
console.log('No encrypted files could be decrypted with the current machine key.');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// eslint-disable-next-line no-console
|
|
60
|
+
console.log(`\nCreated ${decryptedFiles.length} decrypted file(s):`);
|
|
61
|
+
for (const file of decryptedFiles){
|
|
62
|
+
// eslint-disable-next-line no-console
|
|
63
|
+
console.log(` ${file}`);
|
|
64
|
+
}
|
|
65
|
+
// eslint-disable-next-line no-console
|
|
66
|
+
console.log('\nNote: These files contain sensitive tokens. Delete after use.');
|
|
67
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface EnvCommandOptions {
|
|
2
|
+
/** Environment name to switch to (skips interactive prompt) */
|
|
3
|
+
name?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Handle the `@payloadcms/figma env [name]` command
|
|
7
|
+
*
|
|
8
|
+
* If name is provided, switches directly. Otherwise lists available
|
|
9
|
+
* environments with an interactive picker.
|
|
10
|
+
* Updates FIGMA_ENVIRONMENT_NAME in .env and caches all bootstrap data.
|
|
11
|
+
*/
|
|
12
|
+
export declare function envCommand(options: EnvCommandOptions): Promise<void>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import pc from 'picocolors';
|
|
3
|
+
import { getBootstrapInfo } from '../api/control-plane.js';
|
|
4
|
+
import { getValidCredential } from '../auth/oauth-flow.js';
|
|
5
|
+
import { getTokenStore } from '../auth/token-store.js';
|
|
6
|
+
import { cacheAllEnvironments } from '../utils/cache-bootstrap.js';
|
|
7
|
+
import { addOrUpdateEnvVar, getEnvVar } from '../utils/env-management.js';
|
|
8
|
+
import * as log from '../utils/log.js';
|
|
9
|
+
/**
|
|
10
|
+
* Handle the `@payloadcms/figma env [name]` command
|
|
11
|
+
*
|
|
12
|
+
* If name is provided, switches directly. Otherwise lists available
|
|
13
|
+
* environments with an interactive picker.
|
|
14
|
+
* Updates FIGMA_ENVIRONMENT_NAME in .env and caches all bootstrap data.
|
|
15
|
+
*/ export async function envCommand(options) {
|
|
16
|
+
const cwd = process.cwd();
|
|
17
|
+
const projectId = await getEnvVar(cwd, 'FIGMA_PROJECT_ID');
|
|
18
|
+
if (!projectId) {
|
|
19
|
+
p.log.error(pc.red('No project configured. Run `@payloadcms/figma init` first.'));
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
const currentEnv = await getEnvVar(cwd, 'FIGMA_ENVIRONMENT_NAME');
|
|
23
|
+
// Authenticate
|
|
24
|
+
const tokenStore = getTokenStore();
|
|
25
|
+
const credential = await getValidCredential(tokenStore);
|
|
26
|
+
if (!credential) {
|
|
27
|
+
p.log.error(pc.red('Not authenticated. Run `@payloadcms/figma login` first.'));
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
// Fetch available environments
|
|
31
|
+
const spinner = p.spinner();
|
|
32
|
+
spinner.start('Fetching environments...');
|
|
33
|
+
let environments;
|
|
34
|
+
try {
|
|
35
|
+
const bootstrapInfo = await getBootstrapInfo(credential, projectId);
|
|
36
|
+
environments = bootstrapInfo.environments;
|
|
37
|
+
cacheAllEnvironments(tokenStore, projectId, bootstrapInfo);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
spinner.stop(pc.red('✗ Failed to fetch environments'));
|
|
40
|
+
p.log.error(pc.dim(`Details: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
if (environments.length === 0) {
|
|
44
|
+
spinner.stop(pc.red('✗ No environments found'));
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
spinner.stop(pc.green(`✓ ${environments.length} environment(s) available`));
|
|
48
|
+
// Resolve target environment
|
|
49
|
+
let targetName;
|
|
50
|
+
if (options.name) {
|
|
51
|
+
const match = environments.find((e)=>e.name === options.name);
|
|
52
|
+
if (!match) {
|
|
53
|
+
const available = environments.map((e)=>e.name).join(', ');
|
|
54
|
+
p.log.error(pc.red(`Unknown environment: ${options.name}`));
|
|
55
|
+
p.log.message(`Available: ${available}`);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
targetName = match.name;
|
|
59
|
+
} else if (environments.length === 1) {
|
|
60
|
+
targetName = environments[0].name;
|
|
61
|
+
p.log.message(`Only one environment available: ${pc.cyan(targetName)}`);
|
|
62
|
+
} else {
|
|
63
|
+
const selected = await p.select({
|
|
64
|
+
message: 'Select an environment',
|
|
65
|
+
options: environments.map((env)=>({
|
|
66
|
+
hint: env.name === currentEnv ? 'current' : undefined,
|
|
67
|
+
label: env.name,
|
|
68
|
+
value: env.name
|
|
69
|
+
}))
|
|
70
|
+
});
|
|
71
|
+
if (p.isCancel(selected)) {
|
|
72
|
+
p.cancel('Cancelled');
|
|
73
|
+
process.exit(0);
|
|
74
|
+
}
|
|
75
|
+
targetName = selected;
|
|
76
|
+
}
|
|
77
|
+
if (targetName === currentEnv) {
|
|
78
|
+
p.log.message(`Already on ${pc.cyan(targetName)}`);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
// Update .env
|
|
82
|
+
await addOrUpdateEnvVar(cwd, 'FIGMA_ENVIRONMENT_NAME', targetName);
|
|
83
|
+
log.debug(`Updated FIGMA_ENVIRONMENT_NAME to ${targetName}`);
|
|
84
|
+
p.log.success(pc.green(`✓ Switched to ${pc.cyan(targetName)}`));
|
|
85
|
+
p.log.message(pc.dim('Restart your dev server to apply the change.'));
|
|
86
|
+
}
|