@payloadcms/figma 0.0.1-alpha.7 → 0.0.1-alpha.71
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 +150 -12
- package/dist/oauth/components/LoginButton/index.scss +75 -3
- package/dist/oauth/components/LogoutButton/index.js +20 -7
- 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
|
@@ -9,9 +9,9 @@ import * as log from './log.js';
|
|
|
9
9
|
hasOtherPayloadImports: false,
|
|
10
10
|
needsImportChange: false
|
|
11
11
|
};
|
|
12
|
-
// Find buildConfig import
|
|
12
|
+
// Find buildConfig import — prefer @payloadcms/figma (already migrated) over payload
|
|
13
13
|
const imports = sourceFile.getImportDeclarations();
|
|
14
|
-
const payloadImport = imports.find((imp)=>imp.getModuleSpecifierValue() === '
|
|
14
|
+
const payloadImport = imports.find((imp)=>imp.getModuleSpecifierValue() === '@payloadcms/figma') || imports.find((imp)=>imp.getModuleSpecifierValue() === 'payload');
|
|
15
15
|
if (!payloadImport) {
|
|
16
16
|
log.debug('No payload or @payloadcms/figma import found');
|
|
17
17
|
result.hasBuildConfig = false;
|
|
@@ -20,15 +20,18 @@ import * as log from './log.js';
|
|
|
20
20
|
log.debug(`Found import from: ${payloadImport.getModuleSpecifierValue()}`);
|
|
21
21
|
const moduleSpecifier = payloadImport.getModuleSpecifierValue();
|
|
22
22
|
const namedImports = payloadImport.getNamedImports();
|
|
23
|
-
//
|
|
24
|
-
|
|
23
|
+
// Determine which function name to look for based on the import source
|
|
24
|
+
// - From 'payload': look for buildConfig (needs migration)
|
|
25
|
+
// - From '@payloadcms/figma': look for buildFigmaConfig (already migrated)
|
|
26
|
+
const expectedFunctionName = moduleSpecifier === 'payload' ? 'buildConfig' : 'buildFigmaConfig';
|
|
27
|
+
const buildConfigImport = namedImports.find((ni)=>ni.getName() === expectedFunctionName);
|
|
25
28
|
if (!buildConfigImport) {
|
|
26
29
|
result.hasBuildConfig = false;
|
|
27
30
|
return result;
|
|
28
31
|
}
|
|
29
32
|
// Check for alias and get the actual name used in code
|
|
30
33
|
const aliasNode = buildConfigImport.getAliasNode();
|
|
31
|
-
const buildConfigName = aliasNode ? aliasNode.getText() :
|
|
34
|
+
const buildConfigName = aliasNode ? aliasNode.getText() : expectedFunctionName;
|
|
32
35
|
if (aliasNode) {
|
|
33
36
|
result.hasAlias = true;
|
|
34
37
|
}
|
|
@@ -109,6 +112,15 @@ import * as log from './log.js';
|
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
}
|
|
115
|
+
// Check for sharp property
|
|
116
|
+
const sharpProperty = configArg.getProperty('sharp');
|
|
117
|
+
if (sharpProperty) {
|
|
118
|
+
// Find the import source for sharp
|
|
119
|
+
const sharpImport = imports.find((imp)=>imp.getModuleSpecifierValue() === 'sharp' || imp.getNamedImports().some((ni)=>ni.getName() === 'sharp'));
|
|
120
|
+
result.sharpProperty = {
|
|
121
|
+
importSource: sharpImport?.getModuleSpecifierValue() || 'sharp'
|
|
122
|
+
};
|
|
123
|
+
}
|
|
112
124
|
// Check for figma property
|
|
113
125
|
const figmaProperty = configArg.getProperty('figma');
|
|
114
126
|
if (figmaProperty) {
|
|
@@ -145,9 +157,27 @@ import * as log from './log.js';
|
|
|
145
157
|
// Remove duplicates and sort in reverse order to avoid position shifts
|
|
146
158
|
const uniqueRanges = Array.from(new Set(ranges.map((r)=>JSON.stringify(r)))).map((r)=>JSON.parse(r));
|
|
147
159
|
uniqueRanges.sort((a, b)=>b[0] - a[0]);
|
|
148
|
-
// Remove each comment range
|
|
160
|
+
// Remove each comment range, extending to the full line when the comment is the only content
|
|
149
161
|
for (const [pos, end] of uniqueRanges){
|
|
150
|
-
sourceFile.
|
|
162
|
+
const fullText = sourceFile.getFullText();
|
|
163
|
+
let removeStart = pos;
|
|
164
|
+
let removeEnd = end;
|
|
165
|
+
// Find the start of the line containing this comment
|
|
166
|
+
let lineStart = pos;
|
|
167
|
+
while(lineStart > 0 && fullText[lineStart - 1] !== '\n'){
|
|
168
|
+
lineStart--;
|
|
169
|
+
}
|
|
170
|
+
const beforeComment = fullText.substring(lineStart, pos);
|
|
171
|
+
const nextNewline = fullText.indexOf('\n', end);
|
|
172
|
+
const afterComment = fullText.substring(end, nextNewline === -1 ? fullText.length : nextNewline);
|
|
173
|
+
// If the comment is the only content on this line, remove the entire line
|
|
174
|
+
if (beforeComment.trim() === '' && afterComment.trim() === '') {
|
|
175
|
+
removeStart = lineStart > 0 ? lineStart - 1 : lineStart;
|
|
176
|
+
if (nextNewline !== -1) {
|
|
177
|
+
removeEnd = nextNewline + 1;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
sourceFile.removeText(removeStart, removeEnd);
|
|
151
181
|
}
|
|
152
182
|
return true;
|
|
153
183
|
}
|
|
@@ -240,7 +270,16 @@ import * as log from './log.js';
|
|
|
240
270
|
modified = true;
|
|
241
271
|
}
|
|
242
272
|
}
|
|
243
|
-
// 4.
|
|
273
|
+
// 4. Remove sharp property
|
|
274
|
+
if (detection.sharpProperty) {
|
|
275
|
+
const sharpProperty = configArg.getProperty('sharp');
|
|
276
|
+
if (sharpProperty) {
|
|
277
|
+
sharpProperty.remove();
|
|
278
|
+
changes.push('Removed sharp property');
|
|
279
|
+
modified = true;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
// 5. Update buildConfig import
|
|
244
283
|
if (detection.needsImportChange) {
|
|
245
284
|
if (payloadImport) {
|
|
246
285
|
if (detection.hasOtherPayloadImports) {
|
|
@@ -258,19 +297,38 @@ import * as log from './log.js';
|
|
|
258
297
|
sourceFile.addImportDeclaration({
|
|
259
298
|
moduleSpecifier: '@payloadcms/figma',
|
|
260
299
|
namedImports: [
|
|
261
|
-
'
|
|
300
|
+
'buildFigmaConfig'
|
|
262
301
|
]
|
|
263
302
|
});
|
|
303
|
+
// Rename all usages of 'buildConfig' to 'buildFigmaConfig'
|
|
304
|
+
const identifiers = sourceFile.getDescendantsOfKind(SyntaxKind.Identifier);
|
|
305
|
+
identifiers.forEach((identifier)=>{
|
|
306
|
+
if (identifier.getText() === 'buildConfig') {
|
|
307
|
+
identifier.replaceWithText('buildFigmaConfig');
|
|
308
|
+
}
|
|
309
|
+
});
|
|
264
310
|
changes.push('Split buildConfig import to @payloadcms/figma');
|
|
265
311
|
} else {
|
|
266
|
-
// Replace entire import
|
|
312
|
+
// Replace entire import: change module specifier and rename all references
|
|
313
|
+
const buildConfigImport = payloadImport.getNamedImports().find((ni)=>ni.getName() === 'buildConfig');
|
|
314
|
+
if (buildConfigImport) {
|
|
315
|
+
// Change the import name
|
|
316
|
+
buildConfigImport.setName('buildFigmaConfig');
|
|
317
|
+
// Find and rename all usages of 'buildConfig' in the file
|
|
318
|
+
const identifiers = sourceFile.getDescendantsOfKind(SyntaxKind.Identifier);
|
|
319
|
+
identifiers.forEach((identifier)=>{
|
|
320
|
+
if (identifier.getText() === 'buildConfig') {
|
|
321
|
+
identifier.replaceWithText('buildFigmaConfig');
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}
|
|
267
325
|
payloadImport.setModuleSpecifier('@payloadcms/figma');
|
|
268
326
|
changes.push('Changed buildConfig import to @payloadcms/figma');
|
|
269
327
|
}
|
|
270
328
|
modified = true;
|
|
271
329
|
}
|
|
272
330
|
}
|
|
273
|
-
//
|
|
331
|
+
// 6. Remove orphaned imports
|
|
274
332
|
// Re-fetch imports after each removal to avoid stale references
|
|
275
333
|
if (detection.dbProperty) {
|
|
276
334
|
const currentImports = sourceFile.getImportDeclarations();
|
|
@@ -290,6 +348,15 @@ import * as log from './log.js';
|
|
|
290
348
|
modified = true;
|
|
291
349
|
}
|
|
292
350
|
}
|
|
351
|
+
if (detection.sharpProperty) {
|
|
352
|
+
const currentImports = sourceFile.getImportDeclarations();
|
|
353
|
+
const sharpImport = currentImports.find((imp)=>imp.getModuleSpecifierValue() === 'sharp');
|
|
354
|
+
if (sharpImport) {
|
|
355
|
+
sharpImport.remove();
|
|
356
|
+
changes.push('Removed sharp import');
|
|
357
|
+
modified = true;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
293
360
|
return {
|
|
294
361
|
changes,
|
|
295
362
|
modified
|
|
@@ -301,15 +368,15 @@ import * as log from './log.js';
|
|
|
301
368
|
*/ export function addFigmaProperty(sourceFile, config) {
|
|
302
369
|
const changes = [];
|
|
303
370
|
let modified = false;
|
|
304
|
-
// Find
|
|
371
|
+
// Find buildFigmaConfig call (this function is only used with Figma configs)
|
|
305
372
|
const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
|
|
306
373
|
const buildConfigCall = callExpressions.find((ce)=>{
|
|
307
374
|
const expr = ce.getExpression();
|
|
308
375
|
const text = expr.getText();
|
|
309
|
-
return text === '
|
|
376
|
+
return text === 'buildFigmaConfig' || text.endsWith('.buildFigmaConfig');
|
|
310
377
|
});
|
|
311
378
|
if (!buildConfigCall) {
|
|
312
|
-
log.debug('No
|
|
379
|
+
log.debug('No buildFigmaConfig call found');
|
|
313
380
|
return {
|
|
314
381
|
changes: [],
|
|
315
382
|
modified: false
|
|
@@ -336,15 +403,14 @@ import * as log from './log.js';
|
|
|
336
403
|
};
|
|
337
404
|
}
|
|
338
405
|
// Add figma property
|
|
406
|
+
// contentSystemId is resolved automatically by buildFigmaConfig from env vars or bootstrap cache.
|
|
407
|
+
// useContentSystem defaults to true, so we only generate it when explicitly false.
|
|
408
|
+
const figmaObj = config.useContentSystem === false ? `{\nuseContentSystem: false,\n}` : '{}';
|
|
339
409
|
configArg.addPropertyAssignment({
|
|
340
410
|
name: 'figma',
|
|
341
|
-
initializer:
|
|
342
|
-
region: '${config.region}',
|
|
343
|
-
tenantId: '${config.tenantId}',
|
|
344
|
-
useContentSystem: ${config.useContentSystem},
|
|
345
|
-
}`
|
|
411
|
+
initializer: figmaObj
|
|
346
412
|
});
|
|
347
|
-
changes.push(`Added figma property (
|
|
413
|
+
changes.push(`Added figma property (contentSystemId: ${config.contentSystemId})`);
|
|
348
414
|
modified = true;
|
|
349
415
|
return {
|
|
350
416
|
changes,
|
|
@@ -352,60 +418,42 @@ import * as log from './log.js';
|
|
|
352
418
|
};
|
|
353
419
|
}
|
|
354
420
|
/**
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
|
|
358
|
-
|
|
421
|
+
* Remove the contentSystemId property from figma config object.
|
|
422
|
+
* Used during upgrade migration — contentSystemId is now resolved from bootstrap data.
|
|
423
|
+
*
|
|
424
|
+
* @returns true if the property was found and removed
|
|
425
|
+
*/ export function removeFigmaContentSystemId(sourceFile) {
|
|
359
426
|
const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
|
|
360
427
|
const buildConfigCall = callExpressions.find((ce)=>{
|
|
361
428
|
const expr = ce.getExpression();
|
|
362
429
|
const text = expr.getText();
|
|
363
|
-
return text === '
|
|
430
|
+
return text === 'buildFigmaConfig' || text.endsWith('.buildFigmaConfig');
|
|
364
431
|
});
|
|
365
432
|
if (!buildConfigCall) {
|
|
366
|
-
|
|
367
|
-
return null;
|
|
433
|
+
return false;
|
|
368
434
|
}
|
|
369
|
-
// Get config object argument
|
|
370
435
|
const configArg = buildConfigCall.getArguments()[0];
|
|
371
436
|
if (!configArg || !Node.isObjectLiteralExpression(configArg)) {
|
|
372
|
-
|
|
373
|
-
return null;
|
|
437
|
+
return false;
|
|
374
438
|
}
|
|
375
|
-
// Find figma property
|
|
376
439
|
const figmaProperty = configArg.getProperty('figma');
|
|
377
440
|
if (!figmaProperty || !Node.isPropertyAssignment(figmaProperty)) {
|
|
378
|
-
|
|
379
|
-
return null;
|
|
441
|
+
return false;
|
|
380
442
|
}
|
|
381
|
-
// Get initializer (the object value)
|
|
382
443
|
const initializer = figmaProperty.getInitializer();
|
|
383
444
|
if (!initializer || !Node.isObjectLiteralExpression(initializer)) {
|
|
384
|
-
|
|
385
|
-
return null;
|
|
386
|
-
}
|
|
387
|
-
// Extract values
|
|
388
|
-
const regionProp = initializer.getProperty('region');
|
|
389
|
-
const tenantIdProp = initializer.getProperty('tenantId');
|
|
390
|
-
const useContentSystemProp = initializer.getProperty('useContentSystem');
|
|
391
|
-
if (!regionProp || !tenantIdProp) {
|
|
392
|
-
log.debug('Missing required figma properties (region or tenantId)');
|
|
393
|
-
return null;
|
|
394
|
-
}
|
|
395
|
-
// Extract string values (remove quotes)
|
|
396
|
-
const region = Node.isPropertyAssignment(regionProp) ? regionProp.getInitializer()?.getText().replace(/['"]/g, '') : undefined;
|
|
397
|
-
const tenantId = Node.isPropertyAssignment(tenantIdProp) ? tenantIdProp.getInitializer()?.getText().replace(/['"]/g, '') : undefined;
|
|
398
|
-
const useContentSystem = Node.isPropertyAssignment(useContentSystemProp) ? useContentSystemProp.getInitializer()?.getText() === 'true' : true // Default to true if not specified
|
|
399
|
-
;
|
|
400
|
-
if (!region || !tenantId) {
|
|
401
|
-
log.debug('Could not extract region or tenantId values');
|
|
402
|
-
return null;
|
|
445
|
+
return false;
|
|
403
446
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
447
|
+
const contentSystemIdProp = initializer.getProperty('contentSystemId');
|
|
448
|
+
if (!contentSystemIdProp) {
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
contentSystemIdProp.remove();
|
|
452
|
+
// Collapse empty object to avoid ts-morph whitespace artifacts
|
|
453
|
+
if (initializer.getProperties().length === 0) {
|
|
454
|
+
initializer.replaceWithText('{}');
|
|
455
|
+
}
|
|
456
|
+
return true;
|
|
409
457
|
}
|
|
410
458
|
|
|
411
459
|
//# sourceMappingURL=payload-config-ast.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Find the Payload config file using Payload's built-in finder
|
|
3
|
-
*
|
|
2
|
+
* Find the Payload config file using Payload's built-in finder when available,
|
|
3
|
+
* with fallback to simple file search for npx environments where payload isn't installed.
|
|
4
4
|
*
|
|
5
5
|
* @param projectPath - Absolute path to project directory
|
|
6
6
|
* @returns Absolute path to config file, or null if not found
|
|
@@ -1,26 +1,65 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import * as log from './log.js';
|
|
4
|
+
// Standard Payload config file names in priority order
|
|
5
|
+
const CONFIG_FILES = [
|
|
6
|
+
'payload.config.ts',
|
|
7
|
+
'payload.config.js',
|
|
8
|
+
'src/payload.config.ts',
|
|
9
|
+
'src/payload.config.js'
|
|
10
|
+
];
|
|
2
11
|
/**
|
|
3
|
-
* Find the Payload config file using Payload's built-in finder
|
|
4
|
-
*
|
|
12
|
+
* Find the Payload config file using Payload's built-in finder when available,
|
|
13
|
+
* with fallback to simple file search for npx environments where payload isn't installed.
|
|
5
14
|
*
|
|
6
15
|
* @param projectPath - Absolute path to project directory
|
|
7
16
|
* @returns Absolute path to config file, or null if not found
|
|
8
17
|
*/ export async function findPayloadConfig(projectPath) {
|
|
18
|
+
// First, try using Payload's official config finder (if payload is installed)
|
|
19
|
+
const configFromPayload = await findConfigWithPayload(projectPath);
|
|
20
|
+
if (configFromPayload) {
|
|
21
|
+
return configFromPayload;
|
|
22
|
+
}
|
|
23
|
+
// Fallback: Simple file search for standard config locations
|
|
24
|
+
// This works when running via npx before payload is installed
|
|
25
|
+
log.debug('Payload not available, using fallback config finder');
|
|
26
|
+
return findConfigFallback(projectPath);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Try to find config using Payload's findConfig function.
|
|
30
|
+
* Returns null if payload is not installed (dynamic import fails).
|
|
31
|
+
*/ async function findConfigWithPayload(projectPath) {
|
|
9
32
|
const originalCwd = process.cwd();
|
|
10
33
|
try {
|
|
34
|
+
// Dynamic import - will fail gracefully if payload is not installed
|
|
35
|
+
const { findConfig } = await import('payload/node');
|
|
11
36
|
// findConfig requires being in the project directory
|
|
12
37
|
process.chdir(projectPath);
|
|
13
|
-
// Use Payload's official config finder
|
|
14
38
|
const configPath = findConfig();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
39
|
+
return configPath || null;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
// payload not installed or other error - return null to use fallback
|
|
42
|
+
log.debug(`Could not use Payload findConfig: ${error instanceof Error ? error.message : 'unknown'}`);
|
|
19
43
|
return null;
|
|
20
44
|
} finally{
|
|
21
|
-
// Always restore original working directory
|
|
22
45
|
process.chdir(originalCwd);
|
|
23
46
|
}
|
|
24
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Fallback config finder that checks standard locations.
|
|
50
|
+
* Used when payload is not installed (e.g., running via npx).
|
|
51
|
+
*/ async function findConfigFallback(projectPath) {
|
|
52
|
+
for (const configFile of CONFIG_FILES){
|
|
53
|
+
const fullPath = path.join(projectPath, configFile);
|
|
54
|
+
try {
|
|
55
|
+
await fs.access(fullPath);
|
|
56
|
+
log.debug(`Found config at: ${fullPath}`);
|
|
57
|
+
return fullPath;
|
|
58
|
+
} catch {
|
|
59
|
+
// File doesn't exist, try next
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
25
64
|
|
|
26
65
|
//# sourceMappingURL=payload-config-finder.js.map
|
|
@@ -15,5 +15,5 @@ export declare function ensurePayloadFigmaConfig(projectPath: string, packageMan
|
|
|
15
15
|
/**
|
|
16
16
|
* Display manual configuration instructions
|
|
17
17
|
*/
|
|
18
|
-
export declare function displayManualInstructions(reason: string): void;
|
|
18
|
+
export declare function displayManualInstructions(reason: string, packageManager?: PackageManager): void;
|
|
19
19
|
//# sourceMappingURL=payload-config-modifier.d.ts.map
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import pc from 'picocolors';
|
|
2
|
-
import { Project } from 'ts-morph';
|
|
2
|
+
import { IndentationText, Project } from 'ts-morph';
|
|
3
3
|
import { formatFile } from './formatter.js';
|
|
4
4
|
import * as log from './log.js';
|
|
5
|
+
import { getAddCommand, getRunCommand } from './package-manager.js';
|
|
5
6
|
import { addFigmaProperty, applyModifications, detectRequiredChanges } from './payload-config-ast.js';
|
|
6
7
|
import { findPayloadConfig } from './payload-config-finder.js';
|
|
7
|
-
import { checkPackageInstalled,
|
|
8
|
+
import { checkPackageInstalled, getPayloadVersion, installPackages, uninstallPackages } from './payload-package-check.js';
|
|
8
9
|
import { runTypeScriptCheck } from './typescript-validator.js';
|
|
10
|
+
import { getOwnVersion } from './version-check.js';
|
|
9
11
|
/**
|
|
10
12
|
* Main orchestrator for payload config modification
|
|
11
13
|
* Checks package, detects needed changes, applies modifications
|
|
12
14
|
*/ export async function ensurePayloadFigmaConfig(projectPath, packageManager, figmaConfig) {
|
|
13
15
|
const changes = [];
|
|
14
16
|
const warnings = [];
|
|
15
|
-
let
|
|
17
|
+
let astModified = false;
|
|
16
18
|
try {
|
|
17
19
|
log.debug(`Starting payload config modification for: ${projectPath}`);
|
|
18
|
-
// 1. Find config file
|
|
19
20
|
const configPath = await findPayloadConfig(projectPath);
|
|
20
21
|
if (!configPath) {
|
|
21
22
|
log.debug(`Config file not found in: ${projectPath}`);
|
|
@@ -27,44 +28,28 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
log.debug(`Found config file: ${configPath}`);
|
|
30
|
-
//
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
await installPackage(projectPath, '@payloadcms/figma', packageManager);
|
|
36
|
-
changes.push('Installed @payloadcms/figma');
|
|
37
|
-
modified = true;
|
|
38
|
-
log.debug('@payloadcms/figma installed successfully');
|
|
39
|
-
} catch (error) {
|
|
40
|
-
log.debug(`Failed to install @payloadcms/figma: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
41
|
-
return {
|
|
42
|
-
changes: [],
|
|
43
|
-
error: 'Failed to install @payloadcms/figma',
|
|
44
|
-
modified: false,
|
|
45
|
-
success: false
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
log.debug('@payloadcms/figma already installed');
|
|
50
|
-
}
|
|
51
|
-
// 3. Parse config with ts-morph
|
|
31
|
+
// Pin @payloadcms/* packages to the project's payload version when possible.
|
|
32
|
+
const payloadVersion = await getPayloadVersion(projectPath);
|
|
33
|
+
log.debug(`Detected payload version: ${payloadVersion || 'unknown'}`);
|
|
34
|
+
// Parse first so a malformed config fails fast before we touch node_modules.
|
|
52
35
|
log.debug('Parsing config file with ts-morph...');
|
|
53
36
|
const project = new Project({
|
|
37
|
+
manipulationSettings: {
|
|
38
|
+
indentationText: IndentationText.TwoSpaces,
|
|
39
|
+
useTrailingCommas: true
|
|
40
|
+
},
|
|
54
41
|
skipAddingFilesFromTsConfig: true
|
|
55
42
|
});
|
|
56
43
|
const sourceFile = project.addSourceFileAtPath(configPath);
|
|
57
|
-
// 4. Detect required changes
|
|
58
44
|
log.debug('Detecting required changes...');
|
|
59
45
|
const detection = detectRequiredChanges(sourceFile);
|
|
60
46
|
log.debug(`Detection results: needsImportChange=${detection.needsImportChange}, hasAlias=${detection.hasAlias}, hasBuildConfig=${detection.hasBuildConfig}`);
|
|
61
|
-
// Handle failure modes
|
|
62
47
|
if (detection.hasAlias) {
|
|
63
48
|
log.debug('Config uses import alias (e.g., buildConfig as X)');
|
|
64
49
|
return {
|
|
65
50
|
changes,
|
|
66
51
|
error: 'Config uses import alias - manual modification required',
|
|
67
|
-
modified,
|
|
52
|
+
modified: false,
|
|
68
53
|
success: false
|
|
69
54
|
};
|
|
70
55
|
}
|
|
@@ -73,25 +58,95 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
73
58
|
return {
|
|
74
59
|
changes,
|
|
75
60
|
error: 'Config structure not recognized (no buildConfig call found)',
|
|
76
|
-
modified,
|
|
61
|
+
modified: false,
|
|
77
62
|
success: false
|
|
78
63
|
};
|
|
79
64
|
}
|
|
80
|
-
//
|
|
65
|
+
// Compute the full install/uninstall diff up front so each can run as a
|
|
66
|
+
// single package-manager call. npm leaves node_modules transient between
|
|
67
|
+
// back-to-back calls, which causes generate:importmap to silently miss
|
|
68
|
+
// subpath components — batching avoids that intermediate state.
|
|
69
|
+
const packagesToInstall = [];
|
|
70
|
+
const packagesToUninstall = [];
|
|
71
|
+
const figmaInstalled = await checkPackageInstalled(projectPath, '@payloadcms/figma');
|
|
72
|
+
if (!figmaInstalled) {
|
|
73
|
+
const figmaVersion = await getOwnVersion();
|
|
74
|
+
packagesToInstall.push({
|
|
75
|
+
name: '@payloadcms/figma',
|
|
76
|
+
changeMessage: 'Installed @payloadcms/figma',
|
|
77
|
+
version: figmaVersion
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const editorIsDefault = !detection.editorProperty || detection.editorProperty.isDefault;
|
|
81
|
+
if (editorIsDefault) {
|
|
82
|
+
const hasLexical = await checkPackageInstalled(projectPath, '@payloadcms/richtext-lexical');
|
|
83
|
+
if (!hasLexical) {
|
|
84
|
+
packagesToInstall.push({
|
|
85
|
+
name: '@payloadcms/richtext-lexical',
|
|
86
|
+
changeMessage: 'Installed @payloadcms/richtext-lexical (default editor)',
|
|
87
|
+
version: payloadVersion
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
log.debug(`Custom editor detected (${detection.editorProperty?.importSource}) - skipping lexical installation`);
|
|
92
|
+
}
|
|
93
|
+
const hasCloudStorage = await checkPackageInstalled(projectPath, '@payloadcms/plugin-cloud-storage');
|
|
94
|
+
if (!hasCloudStorage) {
|
|
95
|
+
packagesToInstall.push({
|
|
96
|
+
name: '@payloadcms/plugin-cloud-storage',
|
|
97
|
+
changeMessage: 'Installed @payloadcms/plugin-cloud-storage',
|
|
98
|
+
version: payloadVersion
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (detection.dbProperty) {
|
|
102
|
+
packagesToUninstall.push(detection.dbProperty.importSource);
|
|
103
|
+
}
|
|
104
|
+
if (detection.sharpProperty) {
|
|
105
|
+
packagesToUninstall.push('sharp');
|
|
106
|
+
}
|
|
107
|
+
if (packagesToInstall.length > 0) {
|
|
108
|
+
log.debug(`Installing ${packagesToInstall.length} packages in a single operation: ${packagesToInstall.map((p)=>p.name).join(', ')}`);
|
|
109
|
+
try {
|
|
110
|
+
await installPackages(projectPath, packagesToInstall.map(({ name, version })=>({
|
|
111
|
+
name,
|
|
112
|
+
version
|
|
113
|
+
})), packageManager);
|
|
114
|
+
for (const { changeMessage } of packagesToInstall){
|
|
115
|
+
changes.push(changeMessage);
|
|
116
|
+
}
|
|
117
|
+
} catch (error) {
|
|
118
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
119
|
+
log.debug(`Batched install failed: ${errorMessage}`);
|
|
120
|
+
const figmaInBatch = packagesToInstall.some((p)=>p.name === '@payloadcms/figma');
|
|
121
|
+
if (figmaInBatch) {
|
|
122
|
+
// Without @payloadcms/figma the rewritten config would import a
|
|
123
|
+
// missing package, so abort before touching the file.
|
|
124
|
+
return {
|
|
125
|
+
changes: [],
|
|
126
|
+
error: 'Failed to install @payloadcms/figma',
|
|
127
|
+
modified: false,
|
|
128
|
+
success: false
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
// Lexical and cloud-storage are non-fatal — payload still loads without
|
|
132
|
+
// them, so warn (with package names) and continue.
|
|
133
|
+
const failedNames = packagesToInstall.map((p)=>p.name).join(', ');
|
|
134
|
+
warnings.push(`Could not install dependencies (${failedNames}) — install them manually. Details: ${errorMessage}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
81
137
|
log.debug('Applying modifications...');
|
|
82
138
|
const modResult = applyModifications(sourceFile, detection);
|
|
83
139
|
if (modResult.modified) {
|
|
84
140
|
changes.push(...modResult.changes);
|
|
85
|
-
|
|
141
|
+
astModified = true;
|
|
86
142
|
log.debug(`Applied ${modResult.changes.length} modifications`);
|
|
87
143
|
}
|
|
88
|
-
// 6. Add figma property if config provided and doesn't exist
|
|
89
144
|
if (figmaConfig && !detection.figmaObjectExists) {
|
|
90
145
|
log.debug('Adding figma property to buildConfig...');
|
|
91
146
|
const figmaResult = addFigmaProperty(sourceFile, figmaConfig);
|
|
92
147
|
if (figmaResult.modified) {
|
|
93
148
|
changes.push(...figmaResult.changes);
|
|
94
|
-
|
|
149
|
+
astModified = true;
|
|
95
150
|
log.debug(`Added figma property`);
|
|
96
151
|
} else {
|
|
97
152
|
log.debug('Figma property not added (may already exist)');
|
|
@@ -99,46 +154,39 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
99
154
|
} else if (detection.figmaObjectExists) {
|
|
100
155
|
log.debug('Figma property already exists, skipping');
|
|
101
156
|
}
|
|
102
|
-
|
|
103
|
-
|
|
157
|
+
if (astModified) {
|
|
158
|
+
sourceFile.formatText({
|
|
159
|
+
indentSize: 2,
|
|
160
|
+
tabSize: 2
|
|
161
|
+
});
|
|
104
162
|
await sourceFile.save();
|
|
105
163
|
log.debug('Config file saved');
|
|
106
|
-
// 7. Uninstall orphaned packages
|
|
107
|
-
const packagesToUninstall = [];
|
|
108
|
-
if (detection.dbProperty) {
|
|
109
|
-
packagesToUninstall.push(detection.dbProperty.importSource);
|
|
110
|
-
}
|
|
111
|
-
if (detection.editorProperty?.isDefault) {
|
|
112
|
-
packagesToUninstall.push(detection.editorProperty.importSource);
|
|
113
|
-
}
|
|
114
|
-
if (packagesToUninstall.length > 0) {
|
|
115
|
-
log.debug(`Uninstalling ${packagesToUninstall.length} orphaned packages...`);
|
|
116
|
-
}
|
|
117
|
-
for (const pkg of packagesToUninstall){
|
|
118
|
-
try {
|
|
119
|
-
await uninstallPackage(projectPath, pkg, packageManager);
|
|
120
|
-
changes.push(`Uninstalled ${pkg}`);
|
|
121
|
-
log.debug(`Uninstalled ${pkg}`);
|
|
122
|
-
} catch (error) {
|
|
123
|
-
log.debug(`Failed to uninstall ${pkg}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
124
|
-
// Don't fail on uninstall errors - orphaned package is better than broken config
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
// 8. Format file
|
|
128
164
|
log.debug('Formatting config file...');
|
|
129
165
|
const formatResult = await formatFile(configPath, packageManager);
|
|
130
166
|
if (!formatResult.success && formatResult.warning) {
|
|
131
167
|
warnings.push(formatResult.warning);
|
|
132
168
|
log.debug(`Formatting warning: ${formatResult.warning}`);
|
|
133
169
|
}
|
|
134
|
-
// 9. Run TypeScript validation
|
|
135
170
|
log.debug('Running TypeScript validation...');
|
|
136
171
|
const tsResult = await runTypeScriptCheck(projectPath, packageManager);
|
|
137
172
|
if (!tsResult.success && tsResult.errors.length > 0) {
|
|
138
|
-
warnings.push(
|
|
173
|
+
warnings.push(`TypeScript validation found issues - run '${getRunCommand(packageManager)} build' for details`);
|
|
139
174
|
log.debug(`TypeScript validation found ${tsResult.errors.length} issues`);
|
|
140
175
|
}
|
|
141
|
-
}
|
|
176
|
+
}
|
|
177
|
+
if (packagesToUninstall.length > 0) {
|
|
178
|
+
log.debug(`Uninstalling ${packagesToUninstall.length} orphaned packages: ${packagesToUninstall.join(', ')}`);
|
|
179
|
+
const uninstallResult = await uninstallPackages(projectPath, packagesToUninstall, packageManager);
|
|
180
|
+
if (uninstallResult.success) {
|
|
181
|
+
for (const pkg of packagesToUninstall){
|
|
182
|
+
changes.push(`Uninstalled ${pkg}`);
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
warnings.push(`Could not uninstall ${uninstallResult.failedPackages.join(', ')} — they may remain as orphaned dependencies in package.json`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const modified = astModified || changes.length > 0;
|
|
189
|
+
if (!modified) {
|
|
142
190
|
log.debug('No modifications needed - config already correct');
|
|
143
191
|
}
|
|
144
192
|
log.debug('Payload config modification completed successfully');
|
|
@@ -156,17 +204,17 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
156
204
|
return {
|
|
157
205
|
changes,
|
|
158
206
|
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
159
|
-
modified,
|
|
207
|
+
modified: astModified,
|
|
160
208
|
success: false
|
|
161
209
|
};
|
|
162
210
|
}
|
|
163
211
|
}
|
|
164
212
|
/**
|
|
165
213
|
* Display manual configuration instructions
|
|
166
|
-
*/ export function displayManualInstructions(reason) {
|
|
214
|
+
*/ export function displayManualInstructions(reason, packageManager = 'npm') {
|
|
167
215
|
const leftLineWrap = (message)=>{
|
|
168
216
|
// Add '┌ ' prefix to first line, '│ ' to subsequent lines, and '└ ' to last line
|
|
169
|
-
return message.split(
|
|
217
|
+
return message.split(/\r?\n/).map((line, index, arr)=>{
|
|
170
218
|
if (index === 0) {
|
|
171
219
|
return `${pc.dim('┌ ')}${line}`;
|
|
172
220
|
} else if (index === arr.length - 1) {
|
|
@@ -185,7 +233,7 @@ ${pc.bold('Required changes:')}
|
|
|
185
233
|
|
|
186
234
|
1. Replace buildConfig import:
|
|
187
235
|
${pc.dim('- FROM: ')}${pc.cyan("import { buildConfig } from 'payload'")}
|
|
188
|
-
${pc.dim('- TO: ')}${pc.cyan("import {
|
|
236
|
+
${pc.dim('- TO: ')}${pc.cyan("import { buildFigmaConfig } from '@payloadcms/figma'")}
|
|
189
237
|
|
|
190
238
|
2. Remove these properties from buildConfig():
|
|
191
239
|
• db
|
|
@@ -193,7 +241,7 @@ ${pc.bold('Required changes:')}
|
|
|
193
241
|
• editor (if using default lexicalEditor())
|
|
194
242
|
|
|
195
243
|
3. Install package:
|
|
196
|
-
${pc.cyan(
|
|
244
|
+
${pc.cyan(`${getAddCommand(packageManager)} @payloadcms/figma`)}
|
|
197
245
|
|
|
198
246
|
Then run: ${pc.cyan('npx @payloadcms/figma init')}`);
|
|
199
247
|
// eslint-disable-next-line no-console
|