@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/init.js
CHANGED
|
@@ -2,30 +2,61 @@ import * as p from '@clack/prompts';
|
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import pc from 'picocolors';
|
|
5
|
-
import { ControlPlaneError,
|
|
5
|
+
import { ControlPlaneError, getBootstrapInfo } from '../api/control-plane.js';
|
|
6
6
|
import { FigmaApiError } from '../api/figma-api.js';
|
|
7
|
-
import {
|
|
7
|
+
import { tryGetCredential } from '../auth/oauth-flow.js';
|
|
8
8
|
import { getValidProjectToken, ProjectTokenError } from '../auth/project-token.js';
|
|
9
|
-
import {
|
|
9
|
+
import { getTokenStore } from '../auth/token-store.js';
|
|
10
|
+
import { getInfraEnvironment, getProjectNotFoundMessage } from '../constants.js';
|
|
11
|
+
import { downloadSkill } from '../lib/download-skill.js';
|
|
12
|
+
import { ensureGitignore } from '../utils/config.js';
|
|
13
|
+
import { addOrUpdateEnvVar } from '../utils/env-management.js';
|
|
10
14
|
import { isDebug } from '../utils/is-debug.js';
|
|
15
|
+
import { applyLambdaModifications } from '../utils/lambda-config.js';
|
|
11
16
|
import * as log from '../utils/log.js';
|
|
17
|
+
import { detectPackageManagerFromEnvironment, getRunCommand, resolvePackageManager } from '../utils/package-manager.js';
|
|
12
18
|
import { displayManualInstructions, ensurePayloadFigmaConfig } from '../utils/payload-config-modifier.js';
|
|
19
|
+
import { runScript } from '../utils/payload-package-check.js';
|
|
13
20
|
import { detectPayloadProject, hasRequiredDependencies, initializeGitRepo, installDependencies, isInProjectDirectory, scaffoldProject, validatePayloadVersion } from '../utils/project.js';
|
|
21
|
+
import { resolveEnvironment } from '../utils/resolve-environment.js';
|
|
22
|
+
import { checkForUpdates, getOwnVersion } from '../utils/version-check.js';
|
|
14
23
|
import { loginCommand } from './login.js';
|
|
24
|
+
import { cacheAllEnvironments } from '../utils/cache-bootstrap.js';
|
|
25
|
+
import { DEFAULT_TEMPLATE_SOURCE } from '../utils/download-template.js';
|
|
26
|
+
import { parseTemplateSpec, TemplateSpecParseError } from '../utils/parse-template-spec.js';
|
|
27
|
+
async function maybeInstallPayloadSkill(args) {
|
|
28
|
+
if (args.noSkill) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const result = await downloadSkill({
|
|
32
|
+
projectDir: args.projectDir
|
|
33
|
+
});
|
|
34
|
+
if (result.ok) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (result.reason === 'already-installed') {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
p.log.warn(pc.yellow(`⚠ Could not install Payload skill (${result.reason}${result.detail ? `: ${result.detail}` : ''}). Continuing.`));
|
|
41
|
+
}
|
|
15
42
|
/**
|
|
16
|
-
* Generate and store project token for a
|
|
43
|
+
* Generate and store project token for a content system
|
|
17
44
|
* Non-blocking - will show warning but not exit on failure
|
|
18
45
|
* Only shows feedback if DEBUG mode is enabled, otherwise runs silently
|
|
19
46
|
*
|
|
20
47
|
* @param tokenStore - Token store instance
|
|
21
|
-
* @param
|
|
48
|
+
* @param contentSystemId - Content System ID to generate token for
|
|
22
49
|
* @param spinner - Clack spinner instance for status updates (only used in debug mode)
|
|
23
|
-
*/ async function generateProjectTokenWithFeedback(tokenStore,
|
|
50
|
+
*/ async function generateProjectTokenWithFeedback(tokenStore, contentSystemId, spinner, projectInfo) {
|
|
24
51
|
if (isDebug()) {
|
|
25
52
|
spinner.start('Generating project token...');
|
|
26
53
|
}
|
|
27
54
|
try {
|
|
28
|
-
const projectToken = await getValidProjectToken(
|
|
55
|
+
const projectToken = await getValidProjectToken({
|
|
56
|
+
projectInfo,
|
|
57
|
+
tenantId: contentSystemId,
|
|
58
|
+
tokenStore
|
|
59
|
+
});
|
|
29
60
|
if (isDebug()) {
|
|
30
61
|
if (projectToken) {
|
|
31
62
|
spinner.stop(pc.green('✓ Project token generated'));
|
|
@@ -58,108 +89,92 @@ import { loginCommand } from './login.js';
|
|
|
58
89
|
*
|
|
59
90
|
* @param options - Command options
|
|
60
91
|
*/ export async function initCommand(options) {
|
|
92
|
+
// Check for mismatched version (non-blocking)
|
|
93
|
+
const currentVersion = await getOwnVersion();
|
|
94
|
+
await checkForUpdates(currentVersion);
|
|
61
95
|
// Check authentication
|
|
62
|
-
const tokenStore =
|
|
96
|
+
const tokenStore = getTokenStore();
|
|
63
97
|
const s = p.spinner();
|
|
64
|
-
let accessToken;
|
|
65
98
|
if (options.skipAuth) {
|
|
66
99
|
// Skip authentication for testing/development
|
|
67
100
|
p.log.warn(pc.yellow('Skipping authentication (--skip-auth mode)'));
|
|
68
|
-
accessToken = 'mock-access-token';
|
|
69
101
|
} else {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
initialValue: true,
|
|
85
|
-
message: 'Would you like to authenticate now?'
|
|
86
|
-
});
|
|
87
|
-
if (p.isCancel(shouldAuth) || !shouldAuth) {
|
|
88
|
-
p.cancel('Operation cancelled');
|
|
89
|
-
process.exit(0);
|
|
90
|
-
}
|
|
91
|
-
// Run login command
|
|
92
|
-
await loginCommand();
|
|
93
|
-
// Get token after auth
|
|
94
|
-
const newToken = await getValidAccessToken(tokenStore);
|
|
95
|
-
if (!newToken) {
|
|
96
|
-
p.log.error('Authentication failed');
|
|
97
|
-
process.exit(1);
|
|
98
|
-
}
|
|
99
|
-
accessToken = newToken;
|
|
100
|
-
p.log.success(pc.green('✓ Authenticated'));
|
|
101
|
-
} else {
|
|
102
|
-
accessToken = token;
|
|
103
|
-
s.stop(pc.green('✓ Authenticated'));
|
|
102
|
+
// Check for valid cached tokens first (no API call needed)
|
|
103
|
+
if (!tokenStore.hasValidOauthToken()) {
|
|
104
|
+
// Need to refresh or authenticate - show spinner for API call
|
|
105
|
+
s.start('Checking authentication...');
|
|
106
|
+
const credential = await tryGetCredential(tokenStore);
|
|
107
|
+
if (!credential) {
|
|
108
|
+
s.stop('Authentication required to continue');
|
|
109
|
+
await loginCommand({
|
|
110
|
+
showNextSteps: false
|
|
111
|
+
});
|
|
112
|
+
const newCredential = await tryGetCredential(tokenStore);
|
|
113
|
+
if (!newCredential) {
|
|
114
|
+
p.log.error('Authentication failed');
|
|
115
|
+
process.exit(1);
|
|
104
116
|
}
|
|
117
|
+
} else {
|
|
118
|
+
s.stop(pc.green('✓ Authenticated'));
|
|
105
119
|
}
|
|
106
|
-
} catch (error) {
|
|
107
|
-
s.stop(pc.red('✗ Authentication failed'));
|
|
108
|
-
log.error(error instanceof Error ? error.message : 'Unknown error');
|
|
109
|
-
p.note('Run `figma auth` to authenticate', 'Tip');
|
|
110
|
-
process.exit(1);
|
|
111
120
|
}
|
|
112
121
|
}
|
|
113
122
|
// Note: We no longer check for figma.config.json here
|
|
114
123
|
// Instead, the AST detection will check if figma object already exists in payload.config.ts
|
|
115
124
|
// and skip modification if it does (unless --force is used)
|
|
116
|
-
// Step 3: Get CMS ID
|
|
125
|
+
// Step 3: Get CMS Resource ID (required argument)
|
|
117
126
|
log.debug('Configuring Project...');
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
validate: (value)=>{
|
|
127
|
-
if (!value || typeof value !== 'string') {
|
|
128
|
-
return 'CMS ID is required';
|
|
129
|
-
}
|
|
130
|
-
return undefined;
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
if (p.isCancel(input)) {
|
|
134
|
-
p.cancel('Operation cancelled');
|
|
135
|
-
process.exit(0);
|
|
136
|
-
}
|
|
137
|
-
tenantId = input;
|
|
138
|
-
}
|
|
139
|
-
// Try to fetch tenant details
|
|
127
|
+
if (!options.id) {
|
|
128
|
+
p.log.error('CMS Resource ID is required. Use --id <cms-resource-id>');
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
const cmsResourceId = options.id;
|
|
132
|
+
// Parse --template spec early so malformed values abort before any I/O
|
|
133
|
+
let templateSource;
|
|
134
|
+
if (options.template) {
|
|
140
135
|
try {
|
|
141
|
-
|
|
142
|
-
selectedTenant = await getTenantDetails(accessToken, tenantId);
|
|
143
|
-
log.debug(`Using: ${selectedTenant.domain}`);
|
|
136
|
+
templateSource = parseTemplateSpec(options.template);
|
|
144
137
|
} catch (error) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
138
|
+
const message = error instanceof TemplateSpecParseError ? error.message : 'Invalid --template value';
|
|
139
|
+
p.log.error(pc.red(`✗ ${message}`));
|
|
140
|
+
p.note('Format: [<owner>/<repo>#]<ref>:<template-path>\n' + 'Examples:\n' + ' blank\n' + ' v3.80.0:website\n' + ' myorg/payload-fork#feat-x:templates/custom', 'Template spec');
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Fetch bootstrap info (oauth creds + environments)
|
|
145
|
+
let bootstrapInfo = null;
|
|
146
|
+
let resolvedEnv = null;
|
|
147
|
+
let oauthClientId = null;
|
|
148
|
+
let oauthClientSecret = null;
|
|
149
|
+
if (!options.skipAuth) {
|
|
150
|
+
const credential = await tryGetCredential(tokenStore);
|
|
151
|
+
if (credential) {
|
|
152
|
+
try {
|
|
153
|
+
bootstrapInfo = await getBootstrapInfo(credential, cmsResourceId);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
log.debug(`Control Plane Error: ${error.statusCode} - ${error.message}`);
|
|
156
|
+
if (error instanceof ControlPlaneError && (error.statusCode === 404 || error.statusCode === 410)) {
|
|
157
|
+
p.log.error(pc.red(getProjectNotFoundMessage({
|
|
158
|
+
environment: getInfraEnvironment(),
|
|
159
|
+
projectId: cmsResourceId
|
|
160
|
+
})));
|
|
161
|
+
process.exit(1);
|
|
162
|
+
}
|
|
163
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
164
|
+
p.log.error(pc.red(`✗ Unable to fetch project info for "${cmsResourceId}"`));
|
|
165
|
+
p.log.error(pc.dim(`Details: ${message}`));
|
|
166
|
+
process.exit(1);
|
|
153
167
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
168
|
+
try {
|
|
169
|
+
const envName = options.env ?? process.env.FIGMA_ENVIRONMENT_NAME ?? undefined;
|
|
170
|
+
resolvedEnv = resolveEnvironment({
|
|
171
|
+
environmentName: envName,
|
|
172
|
+
environments: bootstrapInfo.environments
|
|
173
|
+
});
|
|
174
|
+
oauthClientId = bootstrapInfo.oauthCredentials.oauthClientId;
|
|
175
|
+
oauthClientSecret = bootstrapInfo.oauthCredentials.oauthClientSecret;
|
|
176
|
+
} catch (error) {
|
|
177
|
+
p.log.error(pc.red(error instanceof Error ? error.message : 'Unknown error'));
|
|
163
178
|
process.exit(1);
|
|
164
179
|
}
|
|
165
180
|
}
|
|
@@ -171,6 +186,7 @@ import { loginCommand } from './login.js';
|
|
|
171
186
|
log.debug('Project directory detected');
|
|
172
187
|
// Detect Payload
|
|
173
188
|
const projectInfo = await detectPayloadProject();
|
|
189
|
+
const packageManager = await resolvePackageManager(process.cwd());
|
|
174
190
|
if (projectInfo.hasPayload) {
|
|
175
191
|
// Validate existing Payload version
|
|
176
192
|
if (projectInfo.payloadVersion && !validatePayloadVersion(projectInfo.payloadVersion)) {
|
|
@@ -190,19 +206,17 @@ import { loginCommand } from './login.js';
|
|
|
190
206
|
});
|
|
191
207
|
if (!p.isCancel(shouldInstall) && shouldInstall) {
|
|
192
208
|
s.start('Installing dependencies...');
|
|
193
|
-
await installDependencies(process.cwd(),
|
|
209
|
+
await installDependencies(process.cwd(), packageManager);
|
|
194
210
|
s.stop(pc.green('✓ Dependencies installed'));
|
|
195
211
|
}
|
|
196
212
|
}
|
|
197
213
|
s.start('Checking Payload configuration...');
|
|
198
|
-
const modResult = await ensurePayloadFigmaConfig(process.cwd(),
|
|
199
|
-
|
|
200
|
-
tenantId: selectedTenant.id,
|
|
201
|
-
useContentSystem: !options.noContentSystem
|
|
214
|
+
const modResult = await ensurePayloadFigmaConfig(process.cwd(), packageManager, {
|
|
215
|
+
contentSystemId: resolvedEnv?.contentSystemId ?? cmsResourceId
|
|
202
216
|
});
|
|
203
217
|
if (!modResult.success) {
|
|
204
218
|
s.stop(pc.red('✗ Configuration check failed'));
|
|
205
|
-
displayManualInstructions(modResult.error || 'Unknown error');
|
|
219
|
+
displayManualInstructions(modResult.error || 'Unknown error', packageManager);
|
|
206
220
|
process.exit(1);
|
|
207
221
|
}
|
|
208
222
|
if (modResult.modified) {
|
|
@@ -219,62 +233,98 @@ import { loginCommand } from './login.js';
|
|
|
219
233
|
p.log.warn(pc.yellow(`⚠ ${warning}`));
|
|
220
234
|
});
|
|
221
235
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
+
// Write environment variables to .env file
|
|
237
|
+
try {
|
|
238
|
+
await addOrUpdateEnvVar(process.cwd(), 'FIGMA_PROJECT_ID', cmsResourceId);
|
|
239
|
+
await addOrUpdateEnvVar(process.cwd(), 'FIGMA_ENVIRONMENT_NAME', resolvedEnv?.name ?? 'production');
|
|
240
|
+
log.debug('Added FIGMA_PROJECT_ID and FIGMA_ENVIRONMENT_NAME to .env file');
|
|
241
|
+
const infraEnv = getInfraEnvironment();
|
|
242
|
+
if (infraEnv !== 'production') {
|
|
243
|
+
await addOrUpdateEnvVar(process.cwd(), 'FIGMA_INFRA_ENV', infraEnv);
|
|
244
|
+
log.debug(`Added FIGMA_INFRA_ENV=${infraEnv} to .env file`);
|
|
245
|
+
}
|
|
246
|
+
// Cache all environments in local encrypted store
|
|
247
|
+
if (bootstrapInfo && oauthClientId && oauthClientSecret) {
|
|
248
|
+
cacheAllEnvironments(tokenStore, cmsResourceId, bootstrapInfo);
|
|
249
|
+
}
|
|
250
|
+
} catch (error) {
|
|
251
|
+
p.log.warn(pc.yellow(`⚠ Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
236
252
|
}
|
|
237
|
-
|
|
238
|
-
p.log.
|
|
239
|
-
p.note('
|
|
253
|
+
} else {
|
|
254
|
+
p.log.warn(pc.yellow('⚠ Payload was not detected in this project'));
|
|
255
|
+
p.note('Run this command in a directory without an existing project or in an existing Payload project.', 'Action Required');
|
|
256
|
+
process.exit(1);
|
|
257
|
+
}
|
|
258
|
+
// npm leaves node_modules in a transient state after a sequence of
|
|
259
|
+
// add/remove calls; without a final `install` the subprocess that runs
|
|
260
|
+
// generate:importmap silently misses @payloadcms/figma subpath components.
|
|
261
|
+
s.start('Reconciling dependencies...');
|
|
262
|
+
try {
|
|
263
|
+
await installDependencies(process.cwd(), packageManager);
|
|
264
|
+
s.stop(pc.green('✓ Dependencies reconciled'));
|
|
265
|
+
} catch (error) {
|
|
266
|
+
s.stop(pc.red('✗ Failed to reconcile dependencies before generate:importmap'));
|
|
267
|
+
log.error(error instanceof Error ? error.message : 'Unknown error');
|
|
240
268
|
process.exit(1);
|
|
241
269
|
}
|
|
270
|
+
// Generate import map to prevent errors on first dev run
|
|
271
|
+
const importMapResult = await runScript(process.cwd(), 'generate:importmap', packageManager);
|
|
272
|
+
if (!importMapResult) {
|
|
273
|
+
p.log.warn(pc.yellow('⚠ Import map generation failed — it will be generated on first dev run'));
|
|
274
|
+
}
|
|
275
|
+
// Apply Lambda modifications (run.sh, standalone output, lambda:buildzip script)
|
|
276
|
+
await applyLambdaModifications(process.cwd(), packageManager);
|
|
277
|
+
// Ensure .gitignore has required entries
|
|
278
|
+
await ensureGitignore(process.cwd(), [
|
|
279
|
+
'.env',
|
|
280
|
+
'.env.local',
|
|
281
|
+
'lambda.zip'
|
|
282
|
+
]);
|
|
283
|
+
await maybeInstallPayloadSkill({
|
|
284
|
+
noSkill: options.noSkill,
|
|
285
|
+
projectDir: process.cwd()
|
|
286
|
+
});
|
|
242
287
|
// Generate project token (unless skipping auth)
|
|
243
|
-
if (!options.skipAuth) {
|
|
244
|
-
await generateProjectTokenWithFeedback(tokenStore,
|
|
288
|
+
if (!options.skipAuth && resolvedEnv) {
|
|
289
|
+
await generateProjectTokenWithFeedback(tokenStore, resolvedEnv.contentSystemId, s, {
|
|
290
|
+
environmentName: resolvedEnv.name,
|
|
291
|
+
projectId: cmsResourceId
|
|
292
|
+
});
|
|
245
293
|
}
|
|
246
294
|
// Success message for existing project
|
|
247
295
|
p.outro(pc.green('✓ Project initialized successfully!'));
|
|
248
296
|
const nextSteps = [
|
|
249
|
-
|
|
250
|
-
'Start development server: `pnpm dev`',
|
|
251
|
-
`Access your CMS at: ${pc.cyan(`https://${selectedTenant.domain}`)}`
|
|
297
|
+
`Start development server: \`${getRunCommand(packageManager)} dev\``
|
|
252
298
|
].filter(Boolean);
|
|
253
299
|
p.note(nextSteps.join('\n'), 'Next Steps');
|
|
254
300
|
} else {
|
|
255
301
|
// ===== NEW PROJECT FLOW =====
|
|
256
302
|
// p.log.info('No project detected - Creating New Project')
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
303
|
+
let projectPath;
|
|
304
|
+
if (options.name) {
|
|
305
|
+
projectPath = options.name;
|
|
306
|
+
} else {
|
|
307
|
+
const projectPathInput = await p.text({
|
|
308
|
+
initialValue: './',
|
|
309
|
+
message: 'Enter path to create project:',
|
|
310
|
+
placeholder: './my-cms-project',
|
|
311
|
+
validate: (value)=>{
|
|
312
|
+
if (!value) {
|
|
313
|
+
return 'Path is required';
|
|
314
|
+
}
|
|
315
|
+
// Allow relative or absolute paths
|
|
316
|
+
return undefined;
|
|
265
317
|
}
|
|
266
|
-
|
|
267
|
-
|
|
318
|
+
});
|
|
319
|
+
if (p.isCancel(projectPathInput)) {
|
|
320
|
+
p.cancel('Operation cancelled');
|
|
321
|
+
process.exit(0);
|
|
268
322
|
}
|
|
269
|
-
|
|
270
|
-
if (p.isCancel(projectPathInput)) {
|
|
271
|
-
p.cancel('Operation cancelled');
|
|
272
|
-
process.exit(0);
|
|
323
|
+
projectPath = projectPathInput;
|
|
273
324
|
}
|
|
274
|
-
const projectPath = projectPathInput;
|
|
275
325
|
const fullPath = path.resolve(process.cwd(), projectPath);
|
|
276
|
-
|
|
277
|
-
const
|
|
326
|
+
const projectName = path.basename(fullPath);
|
|
327
|
+
const packageManager = detectPackageManagerFromEnvironment();
|
|
278
328
|
// Create directory
|
|
279
329
|
try {
|
|
280
330
|
await fs.mkdir(fullPath, {
|
|
@@ -285,12 +335,16 @@ import { loginCommand } from './login.js';
|
|
|
285
335
|
process.exit(1);
|
|
286
336
|
}
|
|
287
337
|
// Scaffold project
|
|
288
|
-
|
|
338
|
+
const resolvedSource = {
|
|
339
|
+
...DEFAULT_TEMPLATE_SOURCE,
|
|
340
|
+
...templateSource
|
|
341
|
+
};
|
|
342
|
+
s.start(`Downloading template "${resolvedSource.templatePath}" from ` + `${resolvedSource.owner}/${resolvedSource.repo}@${resolvedSource.ref}...`);
|
|
289
343
|
try {
|
|
290
|
-
await scaffoldProject(fullPath, projectName);
|
|
344
|
+
await scaffoldProject(fullPath, projectName, packageManager, templateSource, options.payloadVersion);
|
|
291
345
|
s.stop(pc.green('✓ Template downloaded'));
|
|
292
346
|
s.start('Installing dependencies...');
|
|
293
|
-
await installDependencies(fullPath,
|
|
347
|
+
await installDependencies(fullPath, packageManager);
|
|
294
348
|
s.stop(pc.green('✓ Dependencies installed'));
|
|
295
349
|
} catch (error) {
|
|
296
350
|
s.stop(pc.red('✗ Failed'));
|
|
@@ -299,14 +353,12 @@ import { loginCommand } from './login.js';
|
|
|
299
353
|
}
|
|
300
354
|
// Modify Payload configuration
|
|
301
355
|
s.start('Checking Payload configuration...');
|
|
302
|
-
const modResult = await ensurePayloadFigmaConfig(fullPath,
|
|
303
|
-
|
|
304
|
-
tenantId: selectedTenant.id,
|
|
305
|
-
useContentSystem: !options.noContentSystem
|
|
356
|
+
const modResult = await ensurePayloadFigmaConfig(fullPath, packageManager, {
|
|
357
|
+
contentSystemId: resolvedEnv?.contentSystemId ?? cmsResourceId
|
|
306
358
|
});
|
|
307
359
|
if (!modResult.success) {
|
|
308
360
|
s.stop(pc.red('✗ Configuration check failed'));
|
|
309
|
-
displayManualInstructions(modResult.error || 'Unknown error');
|
|
361
|
+
displayManualInstructions(modResult.error || 'Unknown error', packageManager);
|
|
310
362
|
process.exit(1);
|
|
311
363
|
}
|
|
312
364
|
if (modResult.modified) {
|
|
@@ -323,9 +375,50 @@ import { loginCommand } from './login.js';
|
|
|
323
375
|
p.log.warn(pc.yellow(`⚠ ${warning}`));
|
|
324
376
|
});
|
|
325
377
|
}
|
|
378
|
+
// Write environment variables to .env file
|
|
379
|
+
try {
|
|
380
|
+
await addOrUpdateEnvVar(fullPath, 'FIGMA_PROJECT_ID', cmsResourceId);
|
|
381
|
+
await addOrUpdateEnvVar(fullPath, 'FIGMA_ENVIRONMENT_NAME', resolvedEnv?.name ?? 'production');
|
|
382
|
+
log.debug('Added FIGMA_PROJECT_ID and FIGMA_ENVIRONMENT_NAME to .env file');
|
|
383
|
+
const infraEnv = getInfraEnvironment();
|
|
384
|
+
if (infraEnv !== 'production') {
|
|
385
|
+
await addOrUpdateEnvVar(fullPath, 'FIGMA_INFRA_ENV', infraEnv);
|
|
386
|
+
log.debug(`Added FIGMA_INFRA_ENV=${infraEnv} to .env file`);
|
|
387
|
+
}
|
|
388
|
+
// Cache all environments in local encrypted store
|
|
389
|
+
if (bootstrapInfo && oauthClientId && oauthClientSecret) {
|
|
390
|
+
cacheAllEnvironments(tokenStore, cmsResourceId, bootstrapInfo);
|
|
391
|
+
}
|
|
392
|
+
} catch (error) {
|
|
393
|
+
p.log.warn(pc.yellow(`⚠ Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
394
|
+
}
|
|
395
|
+
// npm leaves node_modules in a transient state after a sequence of
|
|
396
|
+
// add/remove calls; without a final `install` the subprocess that runs
|
|
397
|
+
// generate:importmap silently misses @payloadcms/figma subpath components.
|
|
398
|
+
s.start('Reconciling dependencies...');
|
|
399
|
+
try {
|
|
400
|
+
await installDependencies(fullPath, packageManager);
|
|
401
|
+
s.stop(pc.green('✓ Dependencies reconciled'));
|
|
402
|
+
} catch (error) {
|
|
403
|
+
s.stop(pc.red('✗ Failed to reconcile dependencies before generate:importmap'));
|
|
404
|
+
log.error(error instanceof Error ? error.message : 'Unknown error');
|
|
405
|
+
process.exit(1);
|
|
406
|
+
}
|
|
407
|
+
// Generate import map to prevent errors on first dev run
|
|
408
|
+
const importMapResult = await runScript(fullPath, 'generate:importmap', packageManager);
|
|
409
|
+
if (!importMapResult) {
|
|
410
|
+
p.log.warn(pc.yellow('⚠ Import map generation failed — it will be generated on first dev run'));
|
|
411
|
+
}
|
|
412
|
+
await maybeInstallPayloadSkill({
|
|
413
|
+
noSkill: options.noSkill,
|
|
414
|
+
projectDir: fullPath
|
|
415
|
+
});
|
|
326
416
|
// Generate project token (unless skipping auth)
|
|
327
|
-
if (!options.skipAuth) {
|
|
328
|
-
await generateProjectTokenWithFeedback(tokenStore,
|
|
417
|
+
if (!options.skipAuth && resolvedEnv) {
|
|
418
|
+
await generateProjectTokenWithFeedback(tokenStore, resolvedEnv.contentSystemId, s, {
|
|
419
|
+
environmentName: resolvedEnv.name,
|
|
420
|
+
projectId: cmsResourceId
|
|
421
|
+
});
|
|
329
422
|
}
|
|
330
423
|
// Initialize git repository (after all files including lock file are ready)
|
|
331
424
|
initializeGitRepo(fullPath);
|
|
@@ -337,7 +430,7 @@ import { loginCommand } from './login.js';
|
|
|
337
430
|
if (relativePath && relativePath !== '.') {
|
|
338
431
|
nextSteps.push(`cd ${relativePath}`);
|
|
339
432
|
}
|
|
340
|
-
nextSteps.push(
|
|
433
|
+
nextSteps.push(`${getRunCommand(packageManager)} dev or follow directions in README.md`, '', 'Documentation:', '- Getting Started: https://payloadcms.com/docs/getting-started/what-is-payload', '- Configuration: https://payloadcms.com/docs/configuration/overview');
|
|
341
434
|
p.note(nextSteps.join('\n'), 'Next Steps');
|
|
342
435
|
p.outro(pc.green('✓ Done'));
|
|
343
436
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Options for list-tokens command
|
|
3
3
|
*/
|
|
4
4
|
export interface ListTokensCommandOptions {
|
|
5
|
+
/** Show all environments */
|
|
6
|
+
all?: boolean;
|
|
5
7
|
/** Enable debug mode */
|
|
6
8
|
debug?: boolean;
|
|
7
9
|
}
|
|
@@ -9,8 +11,6 @@ export interface ListTokensCommandOptions {
|
|
|
9
11
|
* Handle the `@payloadcms/figma list-tokens` command
|
|
10
12
|
*
|
|
11
13
|
* Displays stored token information including OAuth and project tokens.
|
|
12
|
-
*
|
|
13
|
-
* @param _options - Command options (unused)
|
|
14
14
|
*/
|
|
15
|
-
export declare function listTokensCommand(
|
|
15
|
+
export declare function listTokensCommand(options?: ListTokensCommandOptions): void;
|
|
16
16
|
//# sourceMappingURL=list-tokens.d.ts.map
|
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
import * as p from '@clack/prompts';
|
|
2
2
|
import pc from 'picocolors';
|
|
3
|
-
import {
|
|
3
|
+
import { getTokenStore } from '../auth/token-store.js';
|
|
4
|
+
import { getInfraEnvironment } from '../constants.js';
|
|
5
|
+
import { formatEnvSuffix } from '../utils/format-env-suffix.js';
|
|
4
6
|
import { isDebug } from '../utils/is-debug.js';
|
|
5
7
|
import { formatTimestamp, maskToken, showProjectTokens } from '../utils/token-display.js';
|
|
8
|
+
const ALL_ENVIRONMENTS = [
|
|
9
|
+
'production',
|
|
10
|
+
'staging'
|
|
11
|
+
];
|
|
6
12
|
/**
|
|
7
13
|
* Handle the `@payloadcms/figma list-tokens` command
|
|
8
14
|
*
|
|
9
15
|
* Displays stored token information including OAuth and project tokens.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
*/ export function listTokensCommand(options = {}) {
|
|
17
|
+
if (options.all) {
|
|
18
|
+
// Show detailed info for all environments
|
|
19
|
+
for (const env of ALL_ENVIRONMENTS){
|
|
20
|
+
showTokenDetails(env);
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
// Show detailed info for current environment only
|
|
24
|
+
showTokenDetails(getInfraEnvironment());
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function showTokenDetails(env) {
|
|
28
|
+
const tokenStore = getTokenStore(env);
|
|
29
|
+
const tokens = tokenStore.getOauthInfo();
|
|
15
30
|
if (!tokens) {
|
|
16
|
-
p.log.warn(pc.yellow(
|
|
31
|
+
p.log.warn(pc.yellow(`No tokens found${formatEnvSuffix(env, ' for ')}. Not authenticated.`));
|
|
17
32
|
p.note(`Run ${pc.cyan('@payloadcms/figma login')} to authenticate`, 'Tip');
|
|
18
33
|
return;
|
|
19
34
|
}
|
|
20
|
-
const isValid = tokenStore.
|
|
35
|
+
const isValid = tokenStore.hasValidOauthToken();
|
|
21
36
|
const status = isValid ? pc.green('✓ Valid') : pc.red('✗ Expired');
|
|
22
|
-
p.log.step(pc.bold('
|
|
37
|
+
p.log.step(pc.bold(`Token Status${formatEnvSuffix(env, ' (', ')')}`));
|
|
23
38
|
// Build OAuth token info display
|
|
24
39
|
const lines = [
|
|
25
40
|
`Status: ${status}`,
|
package/dist/commands/login.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
type LoginArgs = {
|
|
2
|
+
/** Set this to show next steps after login
|
|
3
|
+
* @default true
|
|
4
|
+
*/
|
|
5
|
+
showNextSteps: boolean;
|
|
6
|
+
};
|
|
1
7
|
/**
|
|
2
8
|
* Handle the `@payloadcms/figma login` command
|
|
3
9
|
*
|
|
4
10
|
* Authenticates the user with Figma OAuth2 and stores tokens locally.
|
|
5
11
|
* If valid tokens already exist, shows an error message.
|
|
6
12
|
*/
|
|
7
|
-
export declare function loginCommand(): Promise<void>;
|
|
13
|
+
export declare function loginCommand(args?: LoginArgs): Promise<void>;
|
|
14
|
+
export {};
|
|
8
15
|
//# sourceMappingURL=login.d.ts.map
|