@payloadcms/figma 0.0.1-alpha.9 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/control-plane.d.ts +56 -7
- package/dist/api/control-plane.js +188 -74
- package/dist/api/error-response.d.ts +36 -0
- package/dist/api/error-response.js +66 -0
- package/dist/api/figma-api.d.ts +24 -3
- package/dist/api/figma-api.js +110 -34
- package/dist/auth/browser.d.ts +0 -1
- package/dist/auth/browser.js +0 -2
- package/dist/auth/callback-server.d.ts +19 -8
- package/dist/auth/callback-server.js +72 -32
- package/dist/auth/credentials.d.ts +20 -0
- package/dist/auth/credentials.js +19 -0
- package/dist/auth/crypto-utils.d.ts +28 -1
- package/dist/auth/crypto-utils.js +132 -23
- package/dist/auth/jwt-validator.d.ts +23 -6
- package/dist/auth/jwt-validator.js +35 -9
- package/dist/auth/oauth-flow.d.ts +19 -4
- package/dist/auth/oauth-flow.js +151 -34
- package/dist/auth/paste-code.d.ts +33 -0
- package/dist/auth/paste-code.js +87 -0
- package/dist/auth/pkce.d.ts +0 -1
- package/dist/auth/pkce.js +0 -2
- package/dist/auth/project-token.d.ts +32 -17
- package/dist/auth/project-token.js +176 -68
- package/dist/auth/refresh.d.ts +2 -2
- package/dist/auth/refresh.js +25 -14
- package/dist/auth/token-store-migration.d.ts +57 -0
- package/dist/auth/token-store-migration.js +154 -0
- package/dist/auth/token-store.d.ts +63 -98
- package/dist/auth/token-store.js +405 -124
- package/dist/auth/types.d.ts +40 -6
- package/dist/auth/types.js +1 -3
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +102 -8
- package/dist/commands/bootstrap.d.ts +17 -0
- package/dist/commands/bootstrap.js +88 -0
- package/dist/commands/build-lambda-zip.d.ts +4 -0
- package/dist/commands/build-lambda-zip.js +17 -0
- package/dist/commands/debug.d.ts +7 -0
- package/dist/commands/debug.js +178 -0
- package/dist/commands/deploy.d.ts +11 -1
- package/dist/commands/deploy.js +193 -153
- package/dist/commands/dump-tokens.d.ts +11 -0
- package/dist/commands/dump-tokens.js +67 -0
- package/dist/commands/env.d.ts +12 -0
- package/dist/commands/env.js +86 -0
- package/dist/commands/init.d.ts +9 -6
- package/dist/commands/init.js +232 -152
- package/dist/commands/list-tokens.d.ts +3 -4
- package/dist/commands/list-tokens.js +24 -11
- package/dist/commands/login.d.ts +8 -2
- package/dist/commands/login.js +34 -18
- package/dist/commands/logout.d.ts +5 -5
- package/dist/commands/logout.js +77 -17
- package/dist/commands/upgrade.d.ts +4 -0
- package/dist/commands/upgrade.js +329 -0
- package/dist/commands/upload-schema.d.ts +8 -0
- package/dist/commands/upload-schema.js +91 -0
- package/dist/config/oauth.d.ts +17 -12
- package/dist/config/oauth.js +38 -39
- package/dist/constants.d.ts +63 -19
- package/dist/constants.js +158 -20
- package/dist/db-content-api/generated/content-api-types.d.ts +8215 -0
- package/dist/db-content-api/generated/content-api-types.js +5 -0
- package/dist/db-content-api/index.d.ts +40 -0
- package/dist/db-content-api/index.js +883 -0
- package/dist/db-content-api/temp-utilities/slug.d.ts +1 -0
- package/dist/db-content-api/temp-utilities/slug.js +1 -0
- package/dist/db-content-api/temp-utilities/sorting.d.ts +2 -0
- package/dist/db-content-api/temp-utilities/sorting.js +37 -0
- package/dist/db-content-api/temp-utilities/types.d.ts +21 -0
- package/dist/db-content-api/temp-utilities/types.js +13 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +38 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +62 -0
- package/dist/db-content-api/utilities/auth.d.ts +29 -0
- package/dist/db-content-api/utilities/auth.js +82 -0
- package/dist/db-content-api/utilities/clientVersionHeaders.d.ts +7 -0
- package/dist/db-content-api/utilities/clientVersionHeaders.js +15 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +6 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
- package/dist/db-content-api/utilities/data/atomicOperations.d.ts +16 -0
- package/dist/db-content-api/utilities/data/atomicOperations.js +48 -0
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +10 -0
- package/dist/db-content-api/utilities/data/castFieldValue.js +66 -0
- package/dist/db-content-api/utilities/data/convertRelationshipIds.d.ts +25 -0
- package/dist/db-content-api/utilities/data/convertRelationshipIds.js +109 -0
- package/dist/db-content-api/utilities/data/index.d.ts +48 -0
- package/dist/db-content-api/utilities/data/index.js +315 -0
- package/dist/db-content-api/utilities/data/isLocaleMap.d.ts +10 -0
- package/dist/db-content-api/utilities/data/isLocaleMap.js +13 -0
- package/dist/db-content-api/utilities/data/pointShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/pointShape.js +43 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +11 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +52 -0
- package/dist/db-content-api/utilities/data/resolveFieldLocalization.d.ts +18 -0
- package/dist/db-content-api/utilities/data/resolveFieldLocalization.js +21 -0
- package/dist/db-content-api/utilities/data/richTextShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/richTextShape.js +56 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +47 -0
- package/dist/db-content-api/utilities/data/stripFields.js +170 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +22 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +40 -0
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +6 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +107 -0
- package/dist/db-content-api/utilities/joins.d.ts +50 -0
- package/dist/db-content-api/utilities/joins.js +124 -0
- package/dist/db-content-api/utilities/locale/index.d.ts +9 -0
- package/dist/db-content-api/utilities/locale/index.js +19 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +9 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +100 -0
- package/dist/db-content-api/utilities/resolveBlocks.d.ts +19 -0
- package/dist/db-content-api/utilities/resolveBlocks.js +31 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +72 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +264 -0
- package/dist/db-content-api/utilities/where.d.ts +9 -0
- package/dist/db-content-api/utilities/where.js +95 -0
- package/dist/deploy/schedule-extract-plugin.d.ts +10 -0
- package/dist/deploy/schedule-extract-plugin.js +32 -0
- package/dist/endpoints/health.d.ts +2 -0
- package/dist/endpoints/health.js +9 -0
- package/dist/endpoints/schema.d.ts +2 -0
- package/dist/endpoints/schema.js +27 -0
- package/dist/exports/client.d.ts +2 -1
- package/dist/exports/client.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/lib/download-skill.d.ts +12 -0
- package/dist/lib/download-skill.js +77 -0
- package/dist/oauth/components/FigmaAvatar/index.d.ts +3 -0
- package/dist/oauth/components/FigmaAvatar/index.js +25 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +23 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +8 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +35 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +81 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.js +168 -0
- package/dist/oauth/components/LoginButton/index.d.ts +0 -1
- package/dist/oauth/components/LoginButton/index.js +156 -18
- package/dist/oauth/components/LoginButton/index.scss +75 -3
- package/dist/oauth/components/LogoutButton/index.d.ts +0 -1
- package/dist/oauth/components/LogoutButton/index.js +20 -9
- package/dist/oauth/defaults.d.ts +3 -2
- package/dist/oauth/defaults.js +79 -12
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +87 -84
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -6
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js +18 -5
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -4
- package/dist/oauth/exports/client.d.ts +0 -1
- package/dist/oauth/exports/client.js +0 -2
- package/dist/oauth/hooks/afterLogout.d.ts +0 -1
- package/dist/oauth/hooks/afterLogout.js +0 -2
- package/dist/oauth/hooks/me.d.ts +0 -1
- package/dist/oauth/hooks/me.js +0 -2
- package/dist/oauth/hooks/refresh.d.ts +0 -1
- package/dist/oauth/hooks/refresh.js +2 -3
- package/dist/oauth/index.d.ts +0 -1
- package/dist/oauth/index.js +27 -7
- package/dist/oauth/strategy/index.d.ts +0 -3
- package/dist/oauth/strategy/index.js +55 -34
- package/dist/oauth/types.d.ts +23 -7
- package/dist/oauth/types.js +0 -2
- package/dist/oauth/utilities/buildUnauthorizedRedirect.d.ts +14 -0
- package/dist/oauth/utilities/buildUnauthorizedRedirect.js +28 -0
- package/dist/oauth/utilities/clearCookie.d.ts +0 -1
- package/dist/oauth/utilities/clearCookie.js +5 -3
- package/dist/oauth/utilities/createCookieOptions.d.ts +0 -1
- package/dist/oauth/utilities/createCookieOptions.js +9 -4
- package/dist/oauth/utilities/createDebugLogger.d.ts +0 -1
- package/dist/oauth/utilities/createDebugLogger.js +0 -2
- package/dist/oauth/utilities/establishSession.d.ts +22 -0
- package/dist/oauth/utilities/establishSession.js +80 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +23 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.js +26 -0
- package/dist/oauth/utilities/extractOrigin.d.ts +0 -1
- package/dist/oauth/utilities/extractOrigin.js +0 -2
- package/dist/oauth/utilities/figmaHostnames.d.ts +2 -0
- package/dist/oauth/utilities/figmaHostnames.js +24 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js +0 -2
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -2
- package/dist/oauth/utilities/getAuthorizeURL.js +57 -4
- package/dist/oauth/utilities/getCookieExpiration.d.ts +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js +0 -2
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js +0 -2
- package/dist/oauth/utilities/getTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getTokenExp.js +0 -2
- package/dist/oauth/utilities/getUsernameField.d.ts +0 -1
- package/dist/oauth/utilities/getUsernameField.js +0 -2
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js +0 -2
- package/dist/oauth/utilities/isAbsoluteURL.d.ts +1 -0
- package/dist/oauth/utilities/isAbsoluteURL.js +1 -0
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +6 -0
- package/dist/oauth/utilities/isDuplicateKeyError.js +12 -0
- package/dist/oauth/utilities/mergeHeaders.d.ts +0 -1
- package/dist/oauth/utilities/mergeHeaders.js +0 -2
- package/dist/oauth/utilities/refreshTokens.d.ts +0 -1
- package/dist/oauth/utilities/refreshTokens.js +21 -13
- package/dist/oauth/utilities/withPartitionedCookie.d.ts +19 -0
- package/dist/oauth/utilities/withPartitionedCookie.js +26 -0
- package/dist/oauth/utils/getSearchParam.d.ts +17 -0
- package/dist/oauth/utils/getSearchParam.js +22 -0
- package/dist/plugin/adapter.d.ts +0 -1
- package/dist/plugin/adapter.js +0 -2
- package/dist/plugin/auth-preflight.d.ts +7 -0
- package/dist/plugin/auth-preflight.js +18 -0
- package/dist/plugin/bootstrap-preflight.d.ts +22 -0
- package/dist/plugin/bootstrap-preflight.js +43 -0
- package/dist/plugin/build-config.d.ts +27 -15
- package/dist/plugin/build-config.js +380 -16
- package/dist/plugin/dev-cookie-names.d.ts +13 -0
- package/dist/plugin/dev-cookie-names.js +17 -0
- package/dist/scss.d.js +2 -0
- package/dist/storage-content-api/api-types.d.ts +183 -0
- package/dist/storage-content-api/api-types.js +4 -0
- package/dist/storage-content-api/client-uploads/generate.d.ts +14 -0
- package/dist/storage-content-api/client-uploads/generate.js +69 -0
- package/dist/storage-content-api/client.d.ts +5 -0
- package/dist/storage-content-api/client.js +37 -0
- package/dist/storage-content-api/generateURL.d.ts +6 -0
- package/dist/storage-content-api/generateURL.js +6 -0
- package/dist/storage-content-api/handleDelete.d.ts +7 -0
- package/dist/storage-content-api/handleDelete.js +15 -0
- package/dist/storage-content-api/handleUpload.d.ts +10 -0
- package/dist/storage-content-api/handleUpload.js +162 -0
- package/dist/storage-content-api/index.d.ts +4 -0
- package/dist/storage-content-api/index.js +37 -0
- package/dist/storage-content-api/staticHandler.d.ts +9 -0
- package/dist/storage-content-api/staticHandler.js +61 -0
- package/dist/storage-content-api/types.d.ts +9 -0
- package/dist/storage-content-api/types.js +1 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +11 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +59 -0
- package/dist/storage-content-api/utilities/index.d.ts +2 -0
- package/dist/storage-content-api/utilities/index.js +2 -0
- package/dist/storage-content-api/utilities/parseUploadReference.d.ts +17 -0
- package/dist/storage-content-api/utilities/parseUploadReference.js +27 -0
- package/dist/templates/.env.example +5 -0
- package/dist/templates/README.md +19 -0
- package/dist/types/config.d.ts +2 -2
- package/dist/types/config.js +0 -4
- package/dist/types.d.ts +10 -2
- package/dist/types.js +0 -2
- package/dist/utils/adapters/nextjs.d.ts +8 -0
- package/dist/utils/adapters/nextjs.js +61 -0
- package/dist/utils/adapters/nitro.d.ts +8 -0
- package/dist/utils/adapters/nitro.js +172 -0
- package/dist/utils/adapters/vite.d.ts +9 -0
- package/dist/utils/adapters/vite.js +31 -0
- package/dist/utils/asset-collection.d.ts +27 -7
- package/dist/utils/asset-collection.js +59 -32
- package/dist/utils/build-detection.d.ts +5 -12
- package/dist/utils/build-detection.js +74 -13
- package/dist/utils/build-lambda-zip.d.ts +25 -0
- package/dist/utils/build-lambda-zip.js +90 -0
- package/dist/utils/cache-bootstrap.d.ts +7 -0
- package/dist/utils/cache-bootstrap.js +16 -0
- package/dist/utils/config.d.ts +0 -1
- package/dist/utils/config.js +1 -3
- package/dist/utils/deploy-adapter.d.ts +45 -0
- package/dist/utils/deploy-adapter.js +56 -0
- package/dist/utils/download-template.d.ts +9 -2
- package/dist/utils/download-template.js +24 -20
- package/dist/utils/env-management.d.ts +24 -8
- package/dist/utils/env-management.js +119 -66
- package/dist/utils/format-env-suffix.d.ts +11 -0
- package/dist/utils/format-env-suffix.js +11 -0
- package/dist/utils/format.d.ts +0 -1
- package/dist/utils/format.js +0 -2
- package/dist/utils/formatter.d.ts +0 -1
- package/dist/utils/formatter.js +23 -13
- package/dist/utils/fs-utils.d.ts +12 -0
- package/dist/utils/fs-utils.js +55 -0
- package/dist/utils/git.d.ts +0 -1
- package/dist/utils/git.js +0 -2
- package/dist/utils/handle-upgrade.d.ts +8 -0
- package/dist/utils/handle-upgrade.js +39 -0
- package/dist/utils/is-debug.d.ts +0 -1
- package/dist/utils/is-debug.js +0 -2
- package/dist/utils/lambda-config.d.ts +3 -2
- package/dist/utils/lambda-config.js +75 -80
- package/dist/utils/load-payload-config.d.ts +9 -0
- package/dist/utils/load-payload-config.js +27 -0
- package/dist/utils/log.d.ts +0 -1
- package/dist/utils/log.js +0 -2
- package/dist/utils/messages.d.ts +1 -3
- package/dist/utils/messages.js +47 -13
- package/dist/utils/package-manager.d.ts +24 -1
- package/dist/utils/package-manager.js +53 -2
- package/dist/utils/parse-template-spec.d.ts +11 -0
- package/dist/utils/parse-template-spec.js +60 -0
- package/dist/utils/payload-config-ast.d.ts +27 -7
- package/dist/utils/payload-config-ast.js +106 -60
- package/dist/utils/payload-config-finder.d.ts +2 -3
- package/dist/utils/payload-config-finder.js +48 -11
- package/dist/utils/payload-config-modifier.d.ts +1 -2
- package/dist/utils/payload-config-modifier.js +114 -68
- package/dist/utils/payload-package-check.d.ts +28 -3
- package/dist/utils/payload-package-check.js +90 -31
- package/dist/utils/project.d.ts +8 -4
- package/dist/utils/project.js +63 -37
- package/dist/utils/resolve-environment.d.ts +13 -0
- package/dist/utils/resolve-environment.js +29 -0
- package/dist/utils/s3-upload.d.ts +7 -3
- package/dist/utils/s3-upload.js +44 -9
- package/dist/utils/token-display.d.ts +5 -2
- package/dist/utils/token-display.js +49 -24
- package/dist/utils/typescript-validator.d.ts +0 -1
- package/dist/utils/typescript-validator.js +4 -8
- package/dist/utils/version-check.d.ts +2 -0
- package/dist/utils/version-check.js +43 -0
- package/package.json +47 -16
- package/dist/api/control-plane.d.ts.map +0 -1
- package/dist/api/control-plane.js.map +0 -1
- package/dist/api/figma-api.d.ts.map +0 -1
- package/dist/api/figma-api.js.map +0 -1
- package/dist/auth/browser.d.ts.map +0 -1
- package/dist/auth/browser.js.map +0 -1
- package/dist/auth/callback-server.d.ts.map +0 -1
- package/dist/auth/callback-server.js.map +0 -1
- package/dist/auth/crypto-utils.d.ts.map +0 -1
- package/dist/auth/crypto-utils.js.map +0 -1
- package/dist/auth/jwt-validator.d.ts.map +0 -1
- package/dist/auth/jwt-validator.js.map +0 -1
- package/dist/auth/oauth-flow.d.ts.map +0 -1
- package/dist/auth/oauth-flow.js.map +0 -1
- package/dist/auth/pkce.d.ts.map +0 -1
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/project-token.d.ts.map +0 -1
- package/dist/auth/project-token.js.map +0 -1
- package/dist/auth/refresh.d.ts.map +0 -1
- package/dist/auth/refresh.js.map +0 -1
- package/dist/auth/token-store.d.ts.map +0 -1
- package/dist/auth/token-store.js.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list-tokens.d.ts.map +0 -1
- package/dist/commands/list-tokens.js.map +0 -1
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js.map +0 -1
- package/dist/config/oauth.d.ts.map +0 -1
- package/dist/config/oauth.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/exports/client.d.ts.map +0 -1
- package/dist/exports/client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LoginButton/index.js.map +0 -1
- package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LogoutButton/index.js.map +0 -1
- package/dist/oauth/defaults.d.ts.map +0 -1
- package/dist/oauth/defaults.js.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
- package/dist/oauth/exports/client.d.ts.map +0 -1
- package/dist/oauth/exports/client.js.map +0 -1
- package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
- package/dist/oauth/hooks/afterLogout.js.map +0 -1
- package/dist/oauth/hooks/me.d.ts.map +0 -1
- package/dist/oauth/hooks/me.js.map +0 -1
- package/dist/oauth/hooks/refresh.d.ts.map +0 -1
- package/dist/oauth/hooks/refresh.js.map +0 -1
- package/dist/oauth/index.d.ts.map +0 -1
- package/dist/oauth/index.js.map +0 -1
- package/dist/oauth/strategy/index.d.ts.map +0 -1
- package/dist/oauth/strategy/index.js.map +0 -1
- package/dist/oauth/types.d.ts.map +0 -1
- package/dist/oauth/types.js.map +0 -1
- package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
- package/dist/oauth/utilities/clearCookie.js.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
- package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
- package/dist/oauth/utilities/extractOrigin.js.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
- package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
- package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminPath.js +0 -9
- package/dist/oauth/utilities/getAdminPath.js.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
- package/dist/oauth/utilities/getUsernameField.js.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
- package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
- package/dist/oauth/utilities/refreshTokens.js.map +0 -1
- package/dist/plugin/adapter.d.ts.map +0 -1
- package/dist/plugin/adapter.js.map +0 -1
- package/dist/plugin/build-config.d.ts.map +0 -1
- package/dist/plugin/build-config.js.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/asset-collection.d.ts.map +0 -1
- package/dist/utils/asset-collection.js.map +0 -1
- package/dist/utils/build-detection.d.ts.map +0 -1
- package/dist/utils/build-detection.js.map +0 -1
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/download-template.d.ts.map +0 -1
- package/dist/utils/download-template.js.map +0 -1
- package/dist/utils/env-management.d.ts.map +0 -1
- package/dist/utils/env-management.js.map +0 -1
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/formatter.d.ts.map +0 -1
- package/dist/utils/formatter.js.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/is-debug.d.ts.map +0 -1
- package/dist/utils/is-debug.js.map +0 -1
- package/dist/utils/lambda-config.d.ts.map +0 -1
- package/dist/utils/lambda-config.js.map +0 -1
- package/dist/utils/log.d.ts.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/messages.d.ts.map +0 -1
- package/dist/utils/messages.js.map +0 -1
- package/dist/utils/package-manager.d.ts.map +0 -1
- package/dist/utils/package-manager.js.map +0 -1
- package/dist/utils/payload-config-ast.d.ts.map +0 -1
- package/dist/utils/payload-config-ast.js.map +0 -1
- package/dist/utils/payload-config-finder.d.ts.map +0 -1
- package/dist/utils/payload-config-finder.js.map +0 -1
- package/dist/utils/payload-config-modifier.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.js.map +0 -1
- package/dist/utils/payload-package-check.d.ts.map +0 -1
- package/dist/utils/payload-package-check.js.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/project.js.map +0 -1
- package/dist/utils/s3-upload.d.ts.map +0 -1
- package/dist/utils/s3-upload.js.map +0 -1
- package/dist/utils/token-display.d.ts.map +0 -1
- package/dist/utils/token-display.js.map +0 -1
- package/dist/utils/typescript-validator.d.ts.map +0 -1
- package/dist/utils/typescript-validator.js.map +0 -1
|
@@ -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,11 +241,9 @@ ${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
|
|
200
248
|
console.log(message);
|
|
201
249
|
}
|
|
202
|
-
|
|
203
|
-
//# sourceMappingURL=payload-config-modifier.js.map
|
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
import type { PackageManager } from './package-manager.js';
|
|
2
|
+
export type PackageSpec = {
|
|
3
|
+
name: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
};
|
|
6
|
+
export type UninstallResult = {
|
|
7
|
+
failedPackages: string[];
|
|
8
|
+
success: boolean;
|
|
9
|
+
};
|
|
2
10
|
/**
|
|
3
11
|
* Check if a package is installed in dependencies (not devDependencies)
|
|
4
12
|
*/
|
|
5
13
|
export declare function checkPackageInstalled(projectPath: string, packageName: string): Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Get the payload version from project's package.json (without range specifiers)
|
|
16
|
+
* Returns the clean version number (e.g., "3.71.1") or undefined if not found
|
|
17
|
+
*/
|
|
18
|
+
export declare function getPayloadVersion(projectPath: string): Promise<string | undefined>;
|
|
6
19
|
/**
|
|
7
20
|
* Install a package as a production dependency
|
|
21
|
+
* @param version - Version to install (without caret). Defaults to 'latest'.
|
|
22
|
+
*/
|
|
23
|
+
export declare function installPackage(projectPath: string, packageName: string, packageManager: PackageManager, version?: string): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Install multiple packages as production dependencies in a single package-manager call.
|
|
26
|
+
* No-op when packages is empty. Throws on failure with exit code and truncated stderr.
|
|
8
27
|
*/
|
|
9
|
-
export declare function
|
|
28
|
+
export declare function installPackages(projectPath: string, packages: PackageSpec[], packageManager: PackageManager): Promise<void>;
|
|
10
29
|
/**
|
|
11
30
|
* Uninstall a package
|
|
12
31
|
* Does not throw on failure - orphaned package is better than broken config
|
|
13
32
|
*/
|
|
14
|
-
export declare function uninstallPackage(projectPath: string, packageName: string, packageManager: PackageManager): Promise<
|
|
15
|
-
|
|
33
|
+
export declare function uninstallPackage(projectPath: string, packageName: string, packageManager: PackageManager): Promise<UninstallResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Uninstall multiple packages in a single package-manager call.
|
|
36
|
+
* No-op when packageNames is empty. Does not throw — orphaned packages are
|
|
37
|
+
* preferable to a crash mid-config-rewrite. Returns a success flag so callers
|
|
38
|
+
* can avoid claiming "Uninstalled X" when the package manager actually failed.
|
|
39
|
+
*/
|
|
40
|
+
export declare function uninstallPackages(projectPath: string, packageNames: string[], packageManager: PackageManager): Promise<UninstallResult>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import spawn from 'cross-spawn';
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import * as log from './log.js';
|
|
@@ -18,27 +18,58 @@ import * as log from './log.js';
|
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the payload version from project's package.json (without range specifiers)
|
|
23
|
+
* Returns the clean version number (e.g., "3.71.1") or undefined if not found
|
|
24
|
+
*/ export async function getPayloadVersion(projectPath) {
|
|
25
|
+
try {
|
|
26
|
+
const pkgJsonPath = path.join(projectPath, 'package.json');
|
|
27
|
+
const pkgJsonContent = await fs.readFile(pkgJsonPath, 'utf-8');
|
|
28
|
+
const pkgJson = JSON.parse(pkgJsonContent);
|
|
29
|
+
const rawVersion = pkgJson.dependencies?.payload || pkgJson.devDependencies?.payload;
|
|
30
|
+
if (!rawVersion) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
// Strip range specifiers (^, ~, >=, etc.) to get clean version
|
|
34
|
+
return rawVersion.replace(/^[\^~>=<]+/, '');
|
|
35
|
+
} catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
21
39
|
/**
|
|
22
40
|
* Install a package as a production dependency
|
|
23
|
-
|
|
41
|
+
* @param version - Version to install (without caret). Defaults to 'latest'.
|
|
42
|
+
*/ export async function installPackage(projectPath, packageName, packageManager, version = 'latest') {
|
|
43
|
+
return installPackages(projectPath, [
|
|
44
|
+
{
|
|
45
|
+
name: packageName,
|
|
46
|
+
version
|
|
47
|
+
}
|
|
48
|
+
], packageManager);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Install multiple packages as production dependencies in a single package-manager call.
|
|
52
|
+
* No-op when packages is empty. Throws on failure with exit code and truncated stderr.
|
|
53
|
+
*/ export async function installPackages(projectPath, packages, packageManager) {
|
|
54
|
+
if (packages.length === 0) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
24
57
|
return new Promise((resolve, reject)=>{
|
|
25
58
|
const command = packageManager;
|
|
59
|
+
const packageSpecs = packages.map(({ name, version })=>name.endsWith('.tgz') ? name : `${name}@${version ?? 'latest'}`);
|
|
60
|
+
const installVerb = packageManager === 'npm' ? 'install' : 'add';
|
|
61
|
+
// -E pins exact version
|
|
26
62
|
const args = [
|
|
27
|
-
|
|
28
|
-
|
|
63
|
+
installVerb,
|
|
64
|
+
'-E',
|
|
65
|
+
...packageSpecs
|
|
29
66
|
];
|
|
30
|
-
// npm uses 'install' instead of 'add'
|
|
31
|
-
if (packageManager === 'npm') {
|
|
32
|
-
args[0] = 'install';
|
|
33
|
-
}
|
|
34
67
|
log.debug(`Running: ${command} ${args.join(' ')} in ${projectPath}`);
|
|
35
68
|
let stderr = '';
|
|
36
69
|
const child = spawn(command, args, {
|
|
37
70
|
cwd: projectPath,
|
|
38
|
-
shell: true,
|
|
39
71
|
stdio: 'pipe'
|
|
40
72
|
});
|
|
41
|
-
// Capture stderr for debug logging
|
|
42
73
|
if (child.stderr) {
|
|
43
74
|
child.stderr.on('data', (data)=>{
|
|
44
75
|
stderr += data.toString();
|
|
@@ -50,15 +81,17 @@ import * as log from './log.js';
|
|
|
50
81
|
});
|
|
51
82
|
child.on('close', (code)=>{
|
|
52
83
|
if (code === 0) {
|
|
53
|
-
log.debug(`Successfully installed ${
|
|
84
|
+
log.debug(`Successfully installed ${packageSpecs.join(', ')}`);
|
|
54
85
|
resolve();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
reject(new Error(`Failed to install ${packageName}`));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
log.debug(`Batched install failed (exit code: ${code})`);
|
|
89
|
+
if (stderr) {
|
|
90
|
+
log.debug(`stderr: ${stderr}`);
|
|
61
91
|
}
|
|
92
|
+
const truncatedStderr = stderr.trim().slice(-500);
|
|
93
|
+
const detail = truncatedStderr ? `\n${truncatedStderr}` : '';
|
|
94
|
+
reject(new Error(`Failed to install: ${packageSpecs.join(', ')} (exit code ${code})${detail}`));
|
|
62
95
|
});
|
|
63
96
|
});
|
|
64
97
|
}
|
|
@@ -66,32 +99,58 @@ import * as log from './log.js';
|
|
|
66
99
|
* Uninstall a package
|
|
67
100
|
* Does not throw on failure - orphaned package is better than broken config
|
|
68
101
|
*/ export async function uninstallPackage(projectPath, packageName, packageManager) {
|
|
102
|
+
return uninstallPackages(projectPath, [
|
|
103
|
+
packageName
|
|
104
|
+
], packageManager);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Uninstall multiple packages in a single package-manager call.
|
|
108
|
+
* No-op when packageNames is empty. Does not throw — orphaned packages are
|
|
109
|
+
* preferable to a crash mid-config-rewrite. Returns a success flag so callers
|
|
110
|
+
* can avoid claiming "Uninstalled X" when the package manager actually failed.
|
|
111
|
+
*/ export async function uninstallPackages(projectPath, packageNames, packageManager) {
|
|
112
|
+
if (packageNames.length === 0) {
|
|
113
|
+
return {
|
|
114
|
+
failedPackages: [],
|
|
115
|
+
success: true
|
|
116
|
+
};
|
|
117
|
+
}
|
|
69
118
|
return new Promise((resolve)=>{
|
|
70
119
|
const command = packageManager;
|
|
71
120
|
const args = [
|
|
72
|
-
'remove',
|
|
73
|
-
|
|
121
|
+
packageManager === 'npm' ? 'uninstall' : 'remove',
|
|
122
|
+
...packageNames
|
|
74
123
|
];
|
|
75
|
-
// npm uses 'uninstall' instead of 'remove'
|
|
76
|
-
if (packageManager === 'npm') {
|
|
77
|
-
args[0] = 'uninstall';
|
|
78
|
-
}
|
|
79
124
|
log.debug(`Running: ${command} ${args.join(' ')} in ${projectPath}`);
|
|
80
125
|
const child = spawn(command, args, {
|
|
81
126
|
cwd: projectPath,
|
|
82
|
-
shell: true,
|
|
83
127
|
stdio: 'pipe'
|
|
84
128
|
});
|
|
129
|
+
child.on('error', (error)=>{
|
|
130
|
+
log.debug(`Spawn error for ${command}: ${error.message}`);
|
|
131
|
+
resolve({
|
|
132
|
+
failedPackages: [
|
|
133
|
+
...packageNames
|
|
134
|
+
],
|
|
135
|
+
success: false
|
|
136
|
+
});
|
|
137
|
+
});
|
|
85
138
|
child.on('close', (code)=>{
|
|
86
139
|
if (code === 0) {
|
|
87
|
-
log.debug(`Successfully uninstalled ${
|
|
88
|
-
|
|
89
|
-
|
|
140
|
+
log.debug(`Successfully uninstalled ${packageNames.join(', ')}`);
|
|
141
|
+
resolve({
|
|
142
|
+
failedPackages: [],
|
|
143
|
+
success: true
|
|
144
|
+
});
|
|
145
|
+
return;
|
|
90
146
|
}
|
|
91
|
-
|
|
92
|
-
resolve(
|
|
147
|
+
log.debug(`Batched uninstall failed (exit code: ${code}), continuing anyway`);
|
|
148
|
+
resolve({
|
|
149
|
+
failedPackages: [
|
|
150
|
+
...packageNames
|
|
151
|
+
],
|
|
152
|
+
success: false
|
|
153
|
+
});
|
|
93
154
|
});
|
|
94
155
|
});
|
|
95
156
|
}
|
|
96
|
-
|
|
97
|
-
//# sourceMappingURL=payload-package-check.js.map
|
package/dist/utils/project.d.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Project detection and scaffolding utilities
|
|
3
3
|
*/
|
|
4
4
|
import type { ProjectInfo } from '../types/config.js';
|
|
5
|
+
import type { TemplateSource } from './download-template.js';
|
|
6
|
+
import type { PackageManager } from './package-manager.js';
|
|
5
7
|
/**
|
|
6
8
|
* Detect if current directory has a Payload project
|
|
7
9
|
*
|
|
@@ -10,7 +12,7 @@ import type { ProjectInfo } from '../types/config.js';
|
|
|
10
12
|
*/
|
|
11
13
|
export declare function detectPayloadProject(projectPath?: string): Promise<ProjectInfo>;
|
|
12
14
|
/**
|
|
13
|
-
* Validate Payload version (must be
|
|
15
|
+
* Validate Payload version (must be 4.x or newer)
|
|
14
16
|
*
|
|
15
17
|
* @param version - Version string from package.json
|
|
16
18
|
* @returns True if version is valid
|
|
@@ -21,8 +23,11 @@ export declare function validatePayloadVersion(version: string): boolean;
|
|
|
21
23
|
*
|
|
22
24
|
* @param projectPath - Path where to create the project
|
|
23
25
|
* @param projectName - Name for the project
|
|
26
|
+
* @param packageManager - Package manager to use
|
|
27
|
+
* @param templateSource - Optional template source override
|
|
28
|
+
* @param payloadVersion - npm dist-tag or explicit version for core payload packages (default 'canary')
|
|
24
29
|
*/
|
|
25
|
-
export declare function scaffoldProject(projectPath: string, projectName: string): Promise<void>;
|
|
30
|
+
export declare function scaffoldProject(projectPath: string, projectName: string, packageManager?: PackageManager, templateSource?: Partial<TemplateSource>, payloadVersion?: string): Promise<void>;
|
|
26
31
|
/**
|
|
27
32
|
* Initialize git repository after all setup is complete
|
|
28
33
|
*
|
|
@@ -38,7 +43,7 @@ export declare function initializeGitRepo(projectPath: string): void;
|
|
|
38
43
|
* @param packageManager - Package manager to use
|
|
39
44
|
* @returns Promise that resolves when installation completes
|
|
40
45
|
*/
|
|
41
|
-
export declare function installDependencies(projectPath: string, packageManager?:
|
|
46
|
+
export declare function installDependencies(projectPath: string, packageManager?: PackageManager): Promise<void>;
|
|
42
47
|
/**
|
|
43
48
|
* Check if required dependencies are installed
|
|
44
49
|
*
|
|
@@ -55,4 +60,3 @@ export declare function hasRequiredDependencies(projectPath: string): Promise<bo
|
|
|
55
60
|
* @returns True if in project directory
|
|
56
61
|
*/
|
|
57
62
|
export declare function isInProjectDirectory(projectPath?: string): Promise<boolean>;
|
|
58
|
-
//# sourceMappingURL=project.d.ts.map
|