@payloadcms/figma 0.0.1-alpha.7 → 0.0.1-alpha.70
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 -6
- package/dist/api/control-plane.js +181 -72
- package/dist/api/figma-api.d.ts +22 -1
- package/dist/api/figma-api.js +78 -25
- package/dist/auth/callback-server.d.ts +19 -7
- package/dist/auth/callback-server.js +72 -30
- package/dist/auth/credentials.d.ts +21 -0
- package/dist/auth/credentials.js +21 -0
- package/dist/auth/crypto-utils.d.ts +28 -0
- package/dist/auth/crypto-utils.js +132 -21
- package/dist/auth/jwt-validator.d.ts +2 -1
- package/dist/auth/jwt-validator.js +2 -2
- package/dist/auth/oauth-flow.d.ts +19 -3
- package/dist/auth/oauth-flow.js +77 -22
- package/dist/auth/project-token.d.ts +32 -16
- package/dist/auth/project-token.js +171 -65
- package/dist/auth/refresh.d.ts +2 -1
- package/dist/auth/refresh.js +25 -12
- package/dist/auth/token-store-migration.d.ts +58 -0
- package/dist/auth/token-store-migration.js +156 -0
- package/dist/auth/token-store.d.ts +63 -97
- package/dist/auth/token-store.js +405 -122
- package/dist/auth/types.d.ts +35 -4
- package/dist/cli.js +93 -6
- package/dist/commands/bootstrap.d.ts +18 -0
- package/dist/commands/bootstrap.js +90 -0
- package/dist/commands/build-lambda-zip.d.ts +5 -0
- package/dist/commands/build-lambda-zip.js +19 -0
- package/dist/commands/debug.d.ts +8 -0
- package/dist/commands/debug.js +180 -0
- package/dist/commands/deploy.d.ts +9 -0
- package/dist/commands/deploy.js +180 -151
- package/dist/commands/dump-tokens.d.ts +12 -0
- package/dist/commands/dump-tokens.js +69 -0
- package/dist/commands/env.d.ts +13 -0
- package/dist/commands/env.js +88 -0
- package/dist/commands/init.d.ts +9 -5
- package/dist/commands/init.js +241 -148
- package/dist/commands/list-tokens.d.ts +3 -3
- package/dist/commands/list-tokens.js +24 -9
- package/dist/commands/login.d.ts +8 -1
- package/dist/commands/login.js +34 -16
- package/dist/commands/logout.d.ts +5 -4
- package/dist/commands/logout.js +77 -15
- package/dist/commands/upgrade.d.ts +5 -0
- package/dist/commands/upgrade.js +331 -0
- package/dist/config/oauth.d.ts +17 -11
- package/dist/config/oauth.js +38 -37
- package/dist/constants.d.ts +63 -18
- package/dist/constants.js +158 -18
- package/dist/db-content-api/generated/content-api-types.d.ts +3978 -0
- package/dist/db-content-api/generated/content-api-types.js +7 -0
- package/dist/db-content-api/index.d.ts +37 -0
- package/dist/db-content-api/index.js +923 -0
- package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
- package/dist/db-content-api/temp-utilities/slug.js +3 -0
- package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
- package/dist/db-content-api/temp-utilities/sorting.js +39 -0
- package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
- package/dist/db-content-api/temp-utilities/types.js +15 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +39 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +64 -0
- package/dist/db-content-api/utilities/auth.d.ts +30 -0
- package/dist/db-content-api/utilities/auth.js +84 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
- package/dist/db-content-api/utilities/data/castFieldValue.js +68 -0
- package/dist/db-content-api/utilities/data/index.d.ts +49 -0
- package/dist/db-content-api/utilities/data/index.js +301 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
- package/dist/db-content-api/utilities/data/stripFields.js +195 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +7 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +102 -0
- package/dist/db-content-api/utilities/joins.d.ts +53 -0
- package/dist/db-content-api/utilities/joins.js +139 -0
- package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
- package/dist/db-content-api/utilities/locale/index.js +21 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +74 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +42 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js +41 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +17 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +244 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +13 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +62 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +102 -0
- package/dist/db-content-api/utilities/where.d.ts +20 -0
- package/dist/db-content-api/utilities/where.js +108 -0
- package/dist/deploy/schedule-extract-plugin.d.ts +11 -0
- package/dist/deploy/schedule-extract-plugin.js +34 -0
- package/dist/endpoints/health.d.ts +3 -0
- package/dist/endpoints/health.js +11 -0
- package/dist/endpoints/schema.d.ts +3 -0
- package/dist/endpoints/schema.js +29 -0
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.js +3 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/lib/download-skill.d.ts +13 -0
- package/dist/lib/download-skill.js +79 -0
- package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatar/index.js +27 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +82 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.js +170 -0
- package/dist/oauth/components/LoginButton/index.js +144 -11
- package/dist/oauth/components/LoginButton/index.scss +75 -3
- package/dist/oauth/components/LogoutButton/index.js +19 -6
- package/dist/oauth/defaults.d.ts +3 -1
- package/dist/oauth/defaults.js +68 -10
- package/dist/oauth/endpoints/getLoginEndpoint.js +72 -77
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
- package/dist/oauth/endpoints/getMetaEndpoint.js +18 -3
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -2
- package/dist/oauth/index.js +27 -5
- package/dist/oauth/strategy/index.d.ts +0 -2
- package/dist/oauth/strategy/index.js +40 -17
- package/dist/oauth/types.d.ts +23 -6
- package/dist/oauth/utilities/establishSession.d.ts +23 -0
- package/dist/oauth/utilities/establishSession.js +82 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +24 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.js +28 -0
- package/dist/oauth/utilities/figmaHostnames.d.ts +3 -0
- package/dist/oauth/utilities/figmaHostnames.js +26 -0
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -1
- package/dist/oauth/utilities/getAuthorizeURL.js +57 -2
- package/dist/oauth/utilities/isAbsoluteURL.d.ts +2 -0
- package/dist/oauth/utilities/isAbsoluteURL.js +3 -0
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
- package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
- package/dist/oauth/utilities/refreshTokens.js +6 -3
- package/dist/plugin/auth-preflight.d.ts +8 -0
- package/dist/plugin/auth-preflight.js +20 -0
- package/dist/plugin/bootstrap-preflight.d.ts +23 -0
- package/dist/plugin/bootstrap-preflight.js +45 -0
- package/dist/plugin/build-config.d.ts +27 -15
- package/dist/plugin/build-config.js +327 -17
- package/dist/plugin/dev-cookie-names.d.ts +14 -0
- package/dist/plugin/dev-cookie-names.js +19 -0
- package/dist/storage-content-api/api-types.d.ts +168 -0
- package/dist/storage-content-api/api-types.js +6 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +43 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
- package/dist/storage-content-api/client.d.ts +6 -0
- package/dist/storage-content-api/client.js +39 -0
- package/dist/storage-content-api/generateURL.d.ts +7 -0
- package/dist/storage-content-api/generateURL.js +8 -0
- package/dist/storage-content-api/handleDelete.d.ts +8 -0
- package/dist/storage-content-api/handleDelete.js +17 -0
- package/dist/storage-content-api/handleUpload.d.ts +11 -0
- package/dist/storage-content-api/handleUpload.js +144 -0
- package/dist/storage-content-api/index.d.ts +5 -0
- package/dist/storage-content-api/index.js +31 -0
- package/dist/storage-content-api/staticHandler.d.ts +10 -0
- package/dist/storage-content-api/staticHandler.js +63 -0
- package/dist/storage-content-api/types.d.ts +10 -0
- package/dist/storage-content-api/types.js +3 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
- package/dist/storage-content-api/utilities/index.d.ts +3 -0
- package/dist/storage-content-api/utilities/index.js +4 -0
- package/dist/storage-content-api/utilities/parseClientUploadContext.d.ts +19 -0
- package/dist/storage-content-api/utilities/parseClientUploadContext.js +30 -0
- package/dist/templates/.env.example +5 -0
- package/dist/templates/README.md +19 -0
- package/dist/types/config.d.ts +2 -1
- package/dist/types/config.js +0 -2
- package/dist/types.d.ts +10 -1
- package/dist/utils/adapters/nextjs.d.ts +9 -0
- package/dist/utils/adapters/nextjs.js +64 -0
- package/dist/utils/adapters/nitro.d.ts +9 -0
- package/dist/utils/adapters/nitro.js +169 -0
- package/dist/utils/adapters/vite.d.ts +10 -0
- package/dist/utils/adapters/vite.js +33 -0
- package/dist/utils/asset-collection.d.ts +27 -6
- package/dist/utils/asset-collection.js +59 -30
- package/dist/utils/build-detection.d.ts +5 -11
- package/dist/utils/build-detection.js +74 -11
- package/dist/utils/build-lambda-zip.d.ts +16 -0
- package/dist/utils/build-lambda-zip.js +78 -0
- package/dist/utils/cache-bootstrap.d.ts +8 -0
- package/dist/utils/cache-bootstrap.js +18 -0
- package/dist/utils/config.js +1 -1
- package/dist/utils/deploy-adapter.d.ts +40 -0
- package/dist/utils/deploy-adapter.js +58 -0
- package/dist/utils/download-template.d.ts +9 -1
- package/dist/utils/download-template.js +24 -18
- package/dist/utils/env-management.d.ts +24 -7
- package/dist/utils/env-management.js +119 -64
- package/dist/utils/format-env-suffix.d.ts +12 -0
- package/dist/utils/format-env-suffix.js +13 -0
- package/dist/utils/formatter.js +23 -11
- package/dist/utils/fs-utils.d.ts +6 -0
- package/dist/utils/fs-utils.js +27 -0
- package/dist/utils/handle-upgrade.d.ts +9 -0
- package/dist/utils/handle-upgrade.js +41 -0
- package/dist/utils/lambda-config.d.ts +3 -1
- package/dist/utils/lambda-config.js +75 -78
- package/dist/utils/messages.d.ts +1 -2
- package/dist/utils/messages.js +39 -11
- package/dist/utils/package-manager.d.ts +24 -0
- package/dist/utils/package-manager.js +53 -0
- package/dist/utils/parse-template-spec.d.ts +12 -0
- package/dist/utils/parse-template-spec.js +62 -0
- package/dist/utils/payload-config-ast.d.ts +27 -6
- package/dist/utils/payload-config-ast.js +106 -58
- package/dist/utils/payload-config-finder.d.ts +2 -2
- package/dist/utils/payload-config-finder.js +48 -9
- package/dist/utils/payload-config-modifier.d.ts +1 -1
- package/dist/utils/payload-config-modifier.js +114 -66
- package/dist/utils/payload-package-check.d.ts +33 -2
- package/dist/utils/payload-package-check.js +129 -28
- package/dist/utils/project.d.ts +7 -2
- package/dist/utils/project.js +60 -32
- package/dist/utils/resolve-environment.d.ts +14 -0
- package/dist/utils/resolve-environment.js +31 -0
- package/dist/utils/s3-upload.d.ts +7 -2
- package/dist/utils/s3-upload.js +39 -6
- package/dist/utils/token-display.d.ts +5 -1
- package/dist/utils/token-display.js +49 -22
- package/dist/utils/typescript-validator.js +4 -6
- package/dist/utils/version-check.d.ts +3 -0
- package/dist/utils/version-check.js +38 -0
- package/package.json +44 -15
- 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,18 @@
|
|
|
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 { detectAdapter } from '../utils/deploy-adapter.js';
|
|
11
|
+
import { getEnvVar } from '../utils/env-management.js';
|
|
12
12
|
import * as log from '../utils/log.js';
|
|
13
13
|
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
14
|
import { isInProjectDirectory } from '../utils/project.js';
|
|
15
|
+
import { resolveEnvironment } from '../utils/resolve-environment.js';
|
|
17
16
|
import { uploadLambdaZip, uploadStaticAssets } from '../utils/s3-upload.js';
|
|
18
17
|
import { loginCommand } from './login.js';
|
|
19
18
|
/**
|
|
@@ -51,6 +50,17 @@ import { loginCommand } from './login.js';
|
|
|
51
50
|
*/ export async function deployCommand(options) {
|
|
52
51
|
const projectPath = process.cwd();
|
|
53
52
|
const spinner = p.spinner();
|
|
53
|
+
// Resolve project ID
|
|
54
|
+
let projectId = options.id;
|
|
55
|
+
if (!projectId) {
|
|
56
|
+
projectId = await getEnvVar(projectPath, 'FIGMA_PROJECT_ID') ?? undefined;
|
|
57
|
+
}
|
|
58
|
+
if (!projectId) {
|
|
59
|
+
p.log.error(pc.red('✗ Project ID not found. Run `@payloadcms/figma init` first, or use --id.'));
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
// Resolve environment name
|
|
63
|
+
const environmentName = options.env ?? await getEnvVar(projectPath, 'FIGMA_ENVIRONMENT_NAME') ?? undefined;
|
|
54
64
|
try {
|
|
55
65
|
// ===== PRE-FLIGHT CHECKS =====
|
|
56
66
|
// Check if in project directory
|
|
@@ -59,71 +69,71 @@ import { loginCommand } from './login.js';
|
|
|
59
69
|
p.note('Create a project or connect an existing one to Figma: npx @payloadcms/figma init', 'Tip');
|
|
60
70
|
process.exit(1);
|
|
61
71
|
}
|
|
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
72
|
// Check authentication
|
|
82
|
-
const tokenStore =
|
|
83
|
-
let
|
|
84
|
-
if (!
|
|
73
|
+
const tokenStore = getTokenStore();
|
|
74
|
+
let credential = await tryGetCredential(tokenStore);
|
|
75
|
+
if (!credential) {
|
|
85
76
|
p.log.message('Please log in to continue');
|
|
86
77
|
await loginCommand();
|
|
87
|
-
|
|
88
|
-
if (!
|
|
78
|
+
credential = await tryGetCredential(tokenStore);
|
|
79
|
+
if (!credential) {
|
|
89
80
|
p.log.error(pc.red('✗ Authentication failed'));
|
|
90
81
|
process.exit(1);
|
|
91
82
|
}
|
|
92
83
|
}
|
|
93
|
-
//
|
|
84
|
+
// Resolve tenant instance ID via bootstrap
|
|
85
|
+
spinner.start('Resolving deployment target...');
|
|
86
|
+
let tenantInstanceId;
|
|
94
87
|
try {
|
|
95
|
-
await
|
|
88
|
+
const bootstrapInfo = await getBootstrapInfo(credential, projectId);
|
|
89
|
+
const resolvedEnv = resolveEnvironment({
|
|
90
|
+
environmentName,
|
|
91
|
+
environments: bootstrapInfo.environments
|
|
92
|
+
});
|
|
93
|
+
tenantInstanceId = resolvedEnv.tenantInstanceId;
|
|
94
|
+
spinner.stop(pc.green(`✓ Target: ${resolvedEnv.name}`));
|
|
96
95
|
} catch (error) {
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
if (error instanceof ControlPlaneError && (error.statusCode === 404 || error.statusCode === 410)) {
|
|
97
|
+
spinner.stop(pc.red('✗ Project not found'));
|
|
98
|
+
p.log.error(pc.red(getProjectNotFoundMessage({
|
|
99
|
+
environment: getInfraEnvironment(),
|
|
100
|
+
projectId
|
|
101
|
+
})));
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
spinner.stop(pc.red('✗ Failed to resolve deployment target'));
|
|
105
|
+
p.log.error(error instanceof Error ? error.message : 'Unknown error');
|
|
106
|
+
process.exit(1);
|
|
99
107
|
}
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
//
|
|
108
|
+
// Signal buildFigmaConfig to extract schedules during build
|
|
109
|
+
process.env.FIGMA_EXTRACT_SCHEDULES = 'true';
|
|
110
|
+
// ===== BUILD =====
|
|
111
|
+
let buildInfo;
|
|
112
|
+
if (options.skipBuild) {
|
|
113
|
+
// User asserts build exists - verify it
|
|
114
|
+
spinner.start('Checking for build...');
|
|
115
|
+
buildInfo = await detectBuild(projectPath);
|
|
116
|
+
if (!buildInfo) {
|
|
117
|
+
spinner.stop(pc.red('✗ No build found'));
|
|
118
|
+
p.log.error('Use deploy without --skip-build to build first.');
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
spinner.stop(pc.green('✓ Build found'));
|
|
122
|
+
p.note([
|
|
123
|
+
`${pc.cyan('Build ID:')} ${buildInfo.buildId}`,
|
|
124
|
+
`${pc.cyan('Date:')} ${formatDate(buildInfo.timestamp)}`
|
|
125
|
+
].join('\n'), 'Build Details');
|
|
126
|
+
} else {
|
|
127
|
+
// Always build (no prompt)
|
|
106
128
|
const buildCmd = await getBuildCommand(projectPath);
|
|
107
129
|
if (!buildCmd) {
|
|
108
130
|
p.log.error('No build script found in package.json');
|
|
109
131
|
p.note('Add a build script to package.json: "build": "next build"', 'Tip');
|
|
110
132
|
process.exit(1);
|
|
111
133
|
}
|
|
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
134
|
const packageManager = await getPackageManager(projectPath);
|
|
125
135
|
const buildCommand = `${packageManager} run build`;
|
|
126
|
-
|
|
136
|
+
p.log.step(`Running ${buildCommand}...\n`);
|
|
127
137
|
try {
|
|
128
138
|
// Stream build output to user with formatting
|
|
129
139
|
const buildProcess = spawn(packageManager, [
|
|
@@ -139,20 +149,20 @@ import { loginCommand } from './login.js';
|
|
|
139
149
|
});
|
|
140
150
|
// Indent and dim output
|
|
141
151
|
buildProcess.stdout?.on('data', (data)=>{
|
|
142
|
-
const lines = data.toString().split(
|
|
152
|
+
const lines = data.toString().split(/\r?\n/);
|
|
143
153
|
lines.forEach((line)=>{
|
|
144
154
|
if (line.trim()) {
|
|
145
155
|
// eslint-disable-next-line no-console
|
|
146
|
-
console.log(pc.dim(` ${line}`));
|
|
156
|
+
console.log(pc.dim(` ${line}`));
|
|
147
157
|
}
|
|
148
158
|
});
|
|
149
159
|
});
|
|
150
160
|
buildProcess.stderr?.on('data', (data)=>{
|
|
151
|
-
const lines = data.toString().split(
|
|
161
|
+
const lines = data.toString().split(/\r?\n/);
|
|
152
162
|
lines.forEach((line)=>{
|
|
153
163
|
if (line.trim()) {
|
|
154
164
|
// eslint-disable-next-line no-console
|
|
155
|
-
console.log(pc.dim(` ${line}`));
|
|
165
|
+
console.log(pc.dim(` ${line}`));
|
|
156
166
|
}
|
|
157
167
|
});
|
|
158
168
|
});
|
|
@@ -170,130 +180,149 @@ import { loginCommand } from './login.js';
|
|
|
170
180
|
}
|
|
171
181
|
process.exit(1);
|
|
172
182
|
}
|
|
173
|
-
//
|
|
183
|
+
// Verify build output
|
|
174
184
|
buildInfo = await detectBuild(projectPath);
|
|
175
185
|
if (!buildInfo) {
|
|
176
|
-
p.log.error(pc.red('✗ Build completed but
|
|
177
|
-
p.note('Ensure
|
|
186
|
+
p.log.error(pc.red('✗ Build completed but build output not found'));
|
|
187
|
+
p.note('Ensure your build produces a valid output directory.', 'Check Build Configuration');
|
|
178
188
|
process.exit(1);
|
|
179
189
|
}
|
|
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
190
|
}
|
|
187
191
|
// ===== DEPLOYMENT PREPARATION =====
|
|
188
|
-
//
|
|
192
|
+
// Detect framework adapter
|
|
193
|
+
spinner.start('Detecting framework...');
|
|
194
|
+
const adapter = await detectAdapter(projectPath, options.adapter);
|
|
195
|
+
spinner.stop(pc.green(`✓ Detected ${adapter.name} adapter`));
|
|
196
|
+
// Collect pages and assets
|
|
197
|
+
spinner.start('Collecting assets...');
|
|
198
|
+
const pages = await adapter.collectPages(projectPath);
|
|
199
|
+
const assets = await adapter.collectAssets(projectPath);
|
|
200
|
+
spinner.stop(pc.green(`✓ ${pages.routes.length} pages, ${assets.routes.length} assets detected`));
|
|
201
|
+
// Create deployment package (if server adapter)
|
|
202
|
+
let zipPath = null;
|
|
203
|
+
let zipSize = 0;
|
|
189
204
|
spinner.start('Creating deployment package...');
|
|
190
205
|
try {
|
|
191
|
-
await
|
|
192
|
-
|
|
206
|
+
zipPath = await adapter.prepareLambdaBundle(projectPath);
|
|
207
|
+
if (zipPath) {
|
|
208
|
+
zipSize = await getFileSize(zipPath);
|
|
209
|
+
spinner.stop(pc.green(`✓ Deployment package created (${formatBytes(zipSize)})`));
|
|
210
|
+
} else {
|
|
211
|
+
spinner.stop(pc.green('✓ Static site — no server package needed'));
|
|
212
|
+
}
|
|
193
213
|
} catch (error) {
|
|
194
214
|
spinner.stop(pc.red('✗ Failed to create deployment package'));
|
|
195
215
|
throw error;
|
|
196
216
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
log.debug(`Lambda zip size: ${formatBytes(zipSize)}`);
|
|
204
|
-
log.debug(`Static assets: ${staticAssets.length} files`);
|
|
217
|
+
log.debug(`Adapter: ${adapter.name}`);
|
|
218
|
+
if (zipPath) {
|
|
219
|
+
log.debug(`Lambda zip size: ${formatBytes(zipSize)}`);
|
|
220
|
+
}
|
|
221
|
+
log.debug(`Pages: ${pages.routes.length} routes (${pages.uploadKeys.length} files)`);
|
|
222
|
+
log.debug(`Assets: ${assets.routes.length} files`);
|
|
205
223
|
// ===== DEPLOYMENT CONFIRMATION =====
|
|
206
224
|
if (!options.yes) {
|
|
207
225
|
p.note([
|
|
226
|
+
`${pc.cyan('Adapter:')} ${adapter.name}`,
|
|
208
227
|
`${pc.cyan('Build ID:')} ${buildInfo.buildId}`,
|
|
209
|
-
`${pc.cyan('
|
|
210
|
-
`${pc.cyan('
|
|
211
|
-
`${pc.cyan('
|
|
228
|
+
zipPath ? `${pc.cyan('Code size:')} ${formatBytes(zipSize)}` : `${pc.cyan('Code:')} No server`,
|
|
229
|
+
`${pc.cyan('Pages:')} ${pages.routes.length} routes (${pages.uploadKeys.length} files)`,
|
|
230
|
+
`${pc.cyan('Assets:')} ${assets.uploadKeys.length} files`
|
|
212
231
|
].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
232
|
}
|
|
222
233
|
// ===== DEPLOYMENT EXECUTION =====
|
|
223
234
|
// Step 1: Create deployment
|
|
224
235
|
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;
|
|
236
|
+
// Build pages payload from route → asset keys mapping
|
|
237
|
+
const pagesPayload = {};
|
|
238
|
+
for (const [route, assetKeys] of Object.entries(pages.routeAssetMap)){
|
|
239
|
+
pagesPayload[route] = {
|
|
240
|
+
assets: assetKeys
|
|
241
|
+
};
|
|
239
242
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
+
const createResponse = await createDeployment(credential, tenantInstanceId, {
|
|
244
|
+
adapter: adapter.name,
|
|
245
|
+
fallback: adapter.fallback,
|
|
246
|
+
pages: pagesPayload,
|
|
247
|
+
staticAssets: assets.uploadKeys
|
|
248
|
+
});
|
|
249
|
+
const deploymentId = createResponse.deploymentId;
|
|
250
|
+
const codeUploadUrl = createResponse.codeUploadUrl;
|
|
251
|
+
const staticAssetUploadUrls = createResponse.staticAssetUploadUrls;
|
|
252
|
+
const pageUploadUrls = createResponse.pageUploadUrls;
|
|
253
|
+
log.debug(`Deployment ID: ${deploymentId}`);
|
|
254
|
+
// Step 2: Upload code (skip for static sites)
|
|
255
|
+
if (zipPath) {
|
|
256
|
+
spinner.message(`Uploading code (${formatBytes(zipSize)})...`);
|
|
243
257
|
await uploadLambdaZip(zipPath, codeUploadUrl);
|
|
244
258
|
spinner.stop(pc.green(`✓ Code uploaded (${formatBytes(zipSize)})`));
|
|
245
|
-
} catch (error) {
|
|
246
|
-
spinner.stop(pc.red('✗ Failed to upload code'));
|
|
247
|
-
throw error;
|
|
248
259
|
}
|
|
249
|
-
// Step 3: Upload
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
260
|
+
// Step 3: Upload page assets
|
|
261
|
+
const totalUploadCount = pages.uploadKeys.length + assets.uploadKeys.length;
|
|
262
|
+
let totalUploaded = 0;
|
|
263
|
+
let totalFailed = 0;
|
|
264
|
+
let totalBytes = 0;
|
|
265
|
+
if (pages.uploadKeys.length > 0) {
|
|
266
|
+
spinner.start('Uploading pages...');
|
|
267
|
+
const pageResults = await uploadStaticAssets({
|
|
268
|
+
assetUrls: pageUploadUrls,
|
|
269
|
+
onProgress: (uploaded, total)=>{
|
|
270
|
+
spinner.message(`Uploading pages (${uploaded}/${total})...`);
|
|
271
|
+
},
|
|
272
|
+
pathMap: pages.pathMap,
|
|
273
|
+
projectPath
|
|
274
|
+
});
|
|
275
|
+
totalUploaded += pageResults.assetsUploaded;
|
|
276
|
+
totalFailed += pageResults.assetsFailed;
|
|
277
|
+
totalBytes += pageResults.totalBytesUploaded;
|
|
278
|
+
spinner.stop(pc.green(`✓ ${pageResults.assetsUploaded} page files uploaded`));
|
|
266
279
|
}
|
|
267
|
-
// Step 4:
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
await
|
|
271
|
-
|
|
280
|
+
// Step 4: Upload static assets
|
|
281
|
+
if (assets.uploadKeys.length > 0) {
|
|
282
|
+
spinner.start('Uploading assets...');
|
|
283
|
+
const assetResults = await uploadStaticAssets({
|
|
284
|
+
assetUrls: staticAssetUploadUrls,
|
|
285
|
+
onProgress: (uploaded, total)=>{
|
|
286
|
+
spinner.message(`Uploading assets (${uploaded}/${total})...`);
|
|
287
|
+
},
|
|
288
|
+
pathMap: assets.pathMap,
|
|
289
|
+
projectPath
|
|
272
290
|
});
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
291
|
+
totalUploaded += assetResults.assetsUploaded;
|
|
292
|
+
totalFailed += assetResults.assetsFailed;
|
|
293
|
+
totalBytes += assetResults.totalBytesUploaded;
|
|
294
|
+
spinner.stop(pc.green(`✓ ${assetResults.assetsUploaded} asset files uploaded`));
|
|
295
|
+
}
|
|
296
|
+
if (totalFailed > 0) {
|
|
297
|
+
p.log.warning(`${totalFailed}/${totalUploadCount} files failed to upload. Deployment may be incomplete.`);
|
|
298
|
+
} else if (totalUploaded > 0) {
|
|
299
|
+
p.log.success(pc.green(`✓ All files uploaded (${totalUploaded} files, ${formatBytes(totalBytes)})`));
|
|
277
300
|
}
|
|
301
|
+
// Step 4: Perform deployment
|
|
302
|
+
spinner.start('Performing deployment...');
|
|
303
|
+
const result = await performDeployment(credential, tenantInstanceId, {
|
|
304
|
+
deploymentId
|
|
305
|
+
});
|
|
306
|
+
const tenantDomains = result.tenantDomains ?? [];
|
|
307
|
+
spinner.stop(pc.green('✓ Deployment initiated'));
|
|
278
308
|
// TODO: Add deployment progress tracking
|
|
279
309
|
// Future: Poll deployment status and show progress
|
|
280
310
|
// API endpoint: GET /v1/tenant/{tenant_id}/deploy/{deployment_id}/status
|
|
281
311
|
// 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
|
|
312
|
+
if (tenantDomains.length > 0) {
|
|
313
|
+
p.log.step(`URL: ${pc.cyan(`https://${tenantDomains[0]}`)}`);
|
|
291
314
|
}
|
|
292
|
-
p.
|
|
315
|
+
p.log.step('This usually takes 2-3 minutes to complete.');
|
|
293
316
|
} catch (error) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
317
|
+
if (error instanceof ControlPlaneError) {
|
|
318
|
+
spinner.stop(pc.red(`✗ ${error.message}`));
|
|
319
|
+
if (error.statusCode) {
|
|
320
|
+
p.log.message(pc.dim(` HTTP ${error.statusCode}`));
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
324
|
+
spinner.stop(pc.red(`✗ ${message}`));
|
|
325
|
+
}
|
|
297
326
|
if (options.debug && error instanceof Error && error.stack) {
|
|
298
327
|
log.error(`Stack trace: ${error.stack}`);
|
|
299
328
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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>;
|
|
12
|
+
//# sourceMappingURL=dump-tokens.d.ts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
}
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=dump-tokens.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
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>;
|
|
13
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
}
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=env.js.map
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -4,18 +4,22 @@
|
|
|
4
4
|
export interface InitCommandOptions {
|
|
5
5
|
/** Enable debug mode */
|
|
6
6
|
debug?: boolean;
|
|
7
|
+
/** Figma environment name (e.g. 'production', 'staging') */
|
|
8
|
+
env?: string;
|
|
7
9
|
/** Force reconfiguration of existing project */
|
|
8
10
|
force?: boolean;
|
|
9
|
-
/**
|
|
11
|
+
/** Content System ID to use */
|
|
10
12
|
id?: string;
|
|
11
13
|
/** Project name (for scaffolding) */
|
|
12
14
|
name?: string;
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/** Skip Payload skill installation */
|
|
16
|
+
noSkill?: boolean;
|
|
17
|
+
/** npm dist-tag or explicit version for core payload packages (e.g. 'latest', 'canary', '3.40.0'); defaults to 'latest' */
|
|
18
|
+
payloadVersion?: string;
|
|
17
19
|
/** Skip authentication check (for testing/development) */
|
|
18
20
|
skipAuth?: boolean;
|
|
21
|
+
/** GitHub template override, e.g. "v3.80.0:website" or "owner/repo#ref:template-path" */
|
|
22
|
+
template?: string;
|
|
19
23
|
/** Skip prompts and use defaults where possible */
|
|
20
24
|
yes?: boolean;
|
|
21
25
|
}
|