@payloadcms/figma 0.0.1-alpha.7 → 0.0.1-alpha.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/control-plane.d.ts +56 -6
- package/dist/api/control-plane.js +181 -72
- package/dist/api/figma-api.d.ts +22 -1
- package/dist/api/figma-api.js +78 -25
- package/dist/auth/callback-server.d.ts +19 -7
- package/dist/auth/callback-server.js +72 -30
- package/dist/auth/credentials.d.ts +21 -0
- package/dist/auth/credentials.js +21 -0
- package/dist/auth/crypto-utils.d.ts +28 -0
- package/dist/auth/crypto-utils.js +132 -21
- package/dist/auth/jwt-validator.d.ts +2 -1
- package/dist/auth/jwt-validator.js +2 -2
- package/dist/auth/oauth-flow.d.ts +19 -3
- package/dist/auth/oauth-flow.js +77 -22
- package/dist/auth/project-token.d.ts +32 -16
- package/dist/auth/project-token.js +171 -65
- package/dist/auth/refresh.d.ts +2 -1
- package/dist/auth/refresh.js +25 -12
- package/dist/auth/token-store-migration.d.ts +58 -0
- package/dist/auth/token-store-migration.js +156 -0
- package/dist/auth/token-store.d.ts +63 -97
- package/dist/auth/token-store.js +405 -122
- package/dist/auth/types.d.ts +35 -4
- package/dist/cli.js +93 -6
- package/dist/commands/bootstrap.d.ts +18 -0
- package/dist/commands/bootstrap.js +90 -0
- package/dist/commands/build-lambda-zip.d.ts +5 -0
- package/dist/commands/build-lambda-zip.js +19 -0
- package/dist/commands/debug.d.ts +8 -0
- package/dist/commands/debug.js +180 -0
- package/dist/commands/deploy.d.ts +9 -0
- package/dist/commands/deploy.js +180 -151
- package/dist/commands/dump-tokens.d.ts +12 -0
- package/dist/commands/dump-tokens.js +69 -0
- package/dist/commands/env.d.ts +13 -0
- package/dist/commands/env.js +88 -0
- package/dist/commands/init.d.ts +9 -5
- package/dist/commands/init.js +241 -148
- package/dist/commands/list-tokens.d.ts +3 -3
- package/dist/commands/list-tokens.js +24 -9
- package/dist/commands/login.d.ts +8 -1
- package/dist/commands/login.js +34 -16
- package/dist/commands/logout.d.ts +5 -4
- package/dist/commands/logout.js +77 -15
- package/dist/commands/upgrade.d.ts +5 -0
- package/dist/commands/upgrade.js +331 -0
- package/dist/config/oauth.d.ts +17 -11
- package/dist/config/oauth.js +38 -37
- package/dist/constants.d.ts +63 -18
- package/dist/constants.js +158 -18
- package/dist/db-content-api/generated/content-api-types.d.ts +3978 -0
- package/dist/db-content-api/generated/content-api-types.js +7 -0
- package/dist/db-content-api/index.d.ts +37 -0
- package/dist/db-content-api/index.js +923 -0
- package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
- package/dist/db-content-api/temp-utilities/slug.js +3 -0
- package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
- package/dist/db-content-api/temp-utilities/sorting.js +39 -0
- package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
- package/dist/db-content-api/temp-utilities/types.js +15 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +39 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +64 -0
- package/dist/db-content-api/utilities/auth.d.ts +30 -0
- package/dist/db-content-api/utilities/auth.js +84 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
- package/dist/db-content-api/utilities/data/castFieldValue.js +68 -0
- package/dist/db-content-api/utilities/data/index.d.ts +49 -0
- package/dist/db-content-api/utilities/data/index.js +301 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
- package/dist/db-content-api/utilities/data/stripFields.js +195 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +7 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +102 -0
- package/dist/db-content-api/utilities/joins.d.ts +53 -0
- package/dist/db-content-api/utilities/joins.js +139 -0
- package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
- package/dist/db-content-api/utilities/locale/index.js +21 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +74 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +42 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js +41 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +17 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +244 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +13 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +62 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +102 -0
- package/dist/db-content-api/utilities/where.d.ts +20 -0
- package/dist/db-content-api/utilities/where.js +108 -0
- package/dist/deploy/schedule-extract-plugin.d.ts +11 -0
- package/dist/deploy/schedule-extract-plugin.js +34 -0
- package/dist/endpoints/health.d.ts +3 -0
- package/dist/endpoints/health.js +11 -0
- package/dist/endpoints/schema.d.ts +3 -0
- package/dist/endpoints/schema.js +29 -0
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.js +3 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/lib/download-skill.d.ts +13 -0
- package/dist/lib/download-skill.js +79 -0
- package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatar/index.js +27 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +82 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.js +170 -0
- package/dist/oauth/components/LoginButton/index.js +144 -11
- package/dist/oauth/components/LoginButton/index.scss +75 -3
- package/dist/oauth/components/LogoutButton/index.js +19 -6
- package/dist/oauth/defaults.d.ts +3 -1
- package/dist/oauth/defaults.js +68 -10
- package/dist/oauth/endpoints/getLoginEndpoint.js +72 -77
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
- package/dist/oauth/endpoints/getMetaEndpoint.js +18 -3
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -2
- package/dist/oauth/index.js +27 -5
- package/dist/oauth/strategy/index.d.ts +0 -2
- package/dist/oauth/strategy/index.js +40 -17
- package/dist/oauth/types.d.ts +23 -6
- package/dist/oauth/utilities/establishSession.d.ts +23 -0
- package/dist/oauth/utilities/establishSession.js +82 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +24 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.js +28 -0
- package/dist/oauth/utilities/figmaHostnames.d.ts +3 -0
- package/dist/oauth/utilities/figmaHostnames.js +26 -0
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -1
- package/dist/oauth/utilities/getAuthorizeURL.js +57 -2
- package/dist/oauth/utilities/isAbsoluteURL.d.ts +2 -0
- package/dist/oauth/utilities/isAbsoluteURL.js +3 -0
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
- package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
- package/dist/oauth/utilities/refreshTokens.js +6 -3
- package/dist/plugin/auth-preflight.d.ts +8 -0
- package/dist/plugin/auth-preflight.js +20 -0
- package/dist/plugin/bootstrap-preflight.d.ts +23 -0
- package/dist/plugin/bootstrap-preflight.js +45 -0
- package/dist/plugin/build-config.d.ts +27 -15
- package/dist/plugin/build-config.js +327 -17
- package/dist/plugin/dev-cookie-names.d.ts +14 -0
- package/dist/plugin/dev-cookie-names.js +19 -0
- package/dist/storage-content-api/api-types.d.ts +168 -0
- package/dist/storage-content-api/api-types.js +6 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +43 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
- package/dist/storage-content-api/client.d.ts +6 -0
- package/dist/storage-content-api/client.js +39 -0
- package/dist/storage-content-api/generateURL.d.ts +7 -0
- package/dist/storage-content-api/generateURL.js +8 -0
- package/dist/storage-content-api/handleDelete.d.ts +8 -0
- package/dist/storage-content-api/handleDelete.js +17 -0
- package/dist/storage-content-api/handleUpload.d.ts +11 -0
- package/dist/storage-content-api/handleUpload.js +144 -0
- package/dist/storage-content-api/index.d.ts +5 -0
- package/dist/storage-content-api/index.js +31 -0
- package/dist/storage-content-api/staticHandler.d.ts +10 -0
- package/dist/storage-content-api/staticHandler.js +63 -0
- package/dist/storage-content-api/types.d.ts +10 -0
- package/dist/storage-content-api/types.js +3 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
- package/dist/storage-content-api/utilities/index.d.ts +3 -0
- package/dist/storage-content-api/utilities/index.js +4 -0
- package/dist/storage-content-api/utilities/parseClientUploadContext.d.ts +19 -0
- package/dist/storage-content-api/utilities/parseClientUploadContext.js +30 -0
- package/dist/templates/.env.example +5 -0
- package/dist/templates/README.md +19 -0
- package/dist/types/config.d.ts +2 -1
- package/dist/types/config.js +0 -2
- package/dist/types.d.ts +10 -1
- package/dist/utils/adapters/nextjs.d.ts +9 -0
- package/dist/utils/adapters/nextjs.js +64 -0
- package/dist/utils/adapters/nitro.d.ts +9 -0
- package/dist/utils/adapters/nitro.js +169 -0
- package/dist/utils/adapters/vite.d.ts +10 -0
- package/dist/utils/adapters/vite.js +33 -0
- package/dist/utils/asset-collection.d.ts +27 -6
- package/dist/utils/asset-collection.js +59 -30
- package/dist/utils/build-detection.d.ts +5 -11
- package/dist/utils/build-detection.js +74 -11
- package/dist/utils/build-lambda-zip.d.ts +16 -0
- package/dist/utils/build-lambda-zip.js +78 -0
- package/dist/utils/cache-bootstrap.d.ts +8 -0
- package/dist/utils/cache-bootstrap.js +18 -0
- package/dist/utils/config.js +1 -1
- package/dist/utils/deploy-adapter.d.ts +40 -0
- package/dist/utils/deploy-adapter.js +58 -0
- package/dist/utils/download-template.d.ts +9 -1
- package/dist/utils/download-template.js +24 -18
- package/dist/utils/env-management.d.ts +24 -7
- package/dist/utils/env-management.js +119 -64
- package/dist/utils/format-env-suffix.d.ts +12 -0
- package/dist/utils/format-env-suffix.js +13 -0
- package/dist/utils/formatter.js +23 -11
- package/dist/utils/fs-utils.d.ts +6 -0
- package/dist/utils/fs-utils.js +27 -0
- package/dist/utils/handle-upgrade.d.ts +9 -0
- package/dist/utils/handle-upgrade.js +41 -0
- package/dist/utils/lambda-config.d.ts +3 -1
- package/dist/utils/lambda-config.js +75 -78
- package/dist/utils/messages.d.ts +1 -2
- package/dist/utils/messages.js +39 -11
- package/dist/utils/package-manager.d.ts +24 -0
- package/dist/utils/package-manager.js +53 -0
- package/dist/utils/parse-template-spec.d.ts +12 -0
- package/dist/utils/parse-template-spec.js +62 -0
- package/dist/utils/payload-config-ast.d.ts +27 -6
- package/dist/utils/payload-config-ast.js +106 -58
- package/dist/utils/payload-config-finder.d.ts +2 -2
- package/dist/utils/payload-config-finder.js +48 -9
- package/dist/utils/payload-config-modifier.d.ts +1 -1
- package/dist/utils/payload-config-modifier.js +114 -66
- package/dist/utils/payload-package-check.d.ts +33 -2
- package/dist/utils/payload-package-check.js +129 -28
- package/dist/utils/project.d.ts +7 -2
- package/dist/utils/project.js +60 -32
- package/dist/utils/resolve-environment.d.ts +14 -0
- package/dist/utils/resolve-environment.js +31 -0
- package/dist/utils/s3-upload.d.ts +7 -2
- package/dist/utils/s3-upload.js +39 -6
- package/dist/utils/token-display.d.ts +5 -1
- package/dist/utils/token-display.js +49 -22
- package/dist/utils/typescript-validator.js +4 -6
- package/dist/utils/version-check.d.ts +3 -0
- package/dist/utils/version-check.js +38 -0
- package/package.json +44 -15
- package/dist/api/control-plane.d.ts.map +0 -1
- package/dist/api/control-plane.js.map +0 -1
- package/dist/api/figma-api.d.ts.map +0 -1
- package/dist/api/figma-api.js.map +0 -1
- package/dist/auth/browser.d.ts.map +0 -1
- package/dist/auth/browser.js.map +0 -1
- package/dist/auth/callback-server.d.ts.map +0 -1
- package/dist/auth/callback-server.js.map +0 -1
- package/dist/auth/crypto-utils.d.ts.map +0 -1
- package/dist/auth/crypto-utils.js.map +0 -1
- package/dist/auth/jwt-validator.d.ts.map +0 -1
- package/dist/auth/jwt-validator.js.map +0 -1
- package/dist/auth/oauth-flow.d.ts.map +0 -1
- package/dist/auth/oauth-flow.js.map +0 -1
- package/dist/auth/pkce.d.ts.map +0 -1
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/project-token.d.ts.map +0 -1
- package/dist/auth/project-token.js.map +0 -1
- package/dist/auth/refresh.d.ts.map +0 -1
- package/dist/auth/refresh.js.map +0 -1
- package/dist/auth/token-store.d.ts.map +0 -1
- package/dist/auth/token-store.js.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list-tokens.d.ts.map +0 -1
- package/dist/commands/list-tokens.js.map +0 -1
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js.map +0 -1
- package/dist/config/oauth.d.ts.map +0 -1
- package/dist/config/oauth.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/exports/client.d.ts.map +0 -1
- package/dist/exports/client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LoginButton/index.js.map +0 -1
- package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LogoutButton/index.js.map +0 -1
- package/dist/oauth/defaults.d.ts.map +0 -1
- package/dist/oauth/defaults.js.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
- package/dist/oauth/exports/client.d.ts.map +0 -1
- package/dist/oauth/exports/client.js.map +0 -1
- package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
- package/dist/oauth/hooks/afterLogout.js.map +0 -1
- package/dist/oauth/hooks/me.d.ts.map +0 -1
- package/dist/oauth/hooks/me.js.map +0 -1
- package/dist/oauth/hooks/refresh.d.ts.map +0 -1
- package/dist/oauth/hooks/refresh.js.map +0 -1
- package/dist/oauth/index.d.ts.map +0 -1
- package/dist/oauth/index.js.map +0 -1
- package/dist/oauth/strategy/index.d.ts.map +0 -1
- package/dist/oauth/strategy/index.js.map +0 -1
- package/dist/oauth/types.d.ts.map +0 -1
- package/dist/oauth/types.js.map +0 -1
- package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
- package/dist/oauth/utilities/clearCookie.js.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
- package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
- package/dist/oauth/utilities/extractOrigin.js.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
- package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
- package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminPath.js +0 -9
- package/dist/oauth/utilities/getAdminPath.js.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
- package/dist/oauth/utilities/getUsernameField.js.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
- package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
- package/dist/oauth/utilities/refreshTokens.js.map +0 -1
- package/dist/plugin/adapter.d.ts.map +0 -1
- package/dist/plugin/adapter.js.map +0 -1
- package/dist/plugin/build-config.d.ts.map +0 -1
- package/dist/plugin/build-config.js.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/asset-collection.d.ts.map +0 -1
- package/dist/utils/asset-collection.js.map +0 -1
- package/dist/utils/build-detection.d.ts.map +0 -1
- package/dist/utils/build-detection.js.map +0 -1
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/download-template.d.ts.map +0 -1
- package/dist/utils/download-template.js.map +0 -1
- package/dist/utils/env-management.d.ts.map +0 -1
- package/dist/utils/env-management.js.map +0 -1
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/formatter.d.ts.map +0 -1
- package/dist/utils/formatter.js.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/is-debug.d.ts.map +0 -1
- package/dist/utils/is-debug.js.map +0 -1
- package/dist/utils/lambda-config.d.ts.map +0 -1
- package/dist/utils/lambda-config.js.map +0 -1
- package/dist/utils/log.d.ts.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/messages.d.ts.map +0 -1
- package/dist/utils/messages.js.map +0 -1
- package/dist/utils/package-manager.d.ts.map +0 -1
- package/dist/utils/package-manager.js.map +0 -1
- package/dist/utils/payload-config-ast.d.ts.map +0 -1
- package/dist/utils/payload-config-ast.js.map +0 -1
- package/dist/utils/payload-config-finder.d.ts.map +0 -1
- package/dist/utils/payload-config-finder.js.map +0 -1
- package/dist/utils/payload-config-modifier.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.js.map +0 -1
- package/dist/utils/payload-package-check.d.ts.map +0 -1
- package/dist/utils/payload-package-check.js.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/project.js.map +0 -1
- package/dist/utils/s3-upload.d.ts.map +0 -1
- package/dist/utils/s3-upload.js.map +0 -1
- package/dist/utils/token-display.d.ts.map +0 -1
- package/dist/utils/token-display.js.map +0 -1
- package/dist/utils/typescript-validator.d.ts.map +0 -1
- package/dist/utils/typescript-validator.js.map +0 -1
|
@@ -1,15 +1,46 @@
|
|
|
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<
|
|
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>;
|
|
41
|
+
/**
|
|
42
|
+
* Run an npm script from package.json
|
|
43
|
+
* Does not throw on failure - logs warning and continues
|
|
44
|
+
*/
|
|
45
|
+
export declare function runScript(projectPath: string, scriptName: string, packageManager: PackageManager): Promise<boolean>;
|
|
15
46
|
//# sourceMappingURL=payload-package-check.d.ts.map
|
|
@@ -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,30 +99,98 @@ 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 ${
|
|
140
|
+
log.debug(`Successfully uninstalled ${packageNames.join(', ')}`);
|
|
141
|
+
resolve({
|
|
142
|
+
failedPackages: [],
|
|
143
|
+
success: true
|
|
144
|
+
});
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
log.debug(`Batched uninstall failed (exit code: ${code}), continuing anyway`);
|
|
148
|
+
resolve({
|
|
149
|
+
failedPackages: [
|
|
150
|
+
...packageNames
|
|
151
|
+
],
|
|
152
|
+
success: false
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Run an npm script from package.json
|
|
159
|
+
* Does not throw on failure - logs warning and continues
|
|
160
|
+
*/ export async function runScript(projectPath, scriptName, packageManager) {
|
|
161
|
+
return new Promise((resolve)=>{
|
|
162
|
+
const command = packageManager;
|
|
163
|
+
// yarn doesn't need 'run' prefix, but it works with it too
|
|
164
|
+
const args = [
|
|
165
|
+
'run',
|
|
166
|
+
scriptName
|
|
167
|
+
];
|
|
168
|
+
log.debug(`Running script: ${command} ${args.join(' ')} in ${projectPath}`);
|
|
169
|
+
let stderr = '';
|
|
170
|
+
const child = spawn(command, args, {
|
|
171
|
+
cwd: projectPath,
|
|
172
|
+
stdio: 'pipe'
|
|
173
|
+
});
|
|
174
|
+
if (child.stderr) {
|
|
175
|
+
child.stderr.on('data', (data)=>{
|
|
176
|
+
stderr += data.toString();
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
child.on('error', (error)=>{
|
|
180
|
+
log.debug(`Failed to run script ${scriptName}: ${error.message}`);
|
|
181
|
+
resolve(false);
|
|
182
|
+
});
|
|
183
|
+
child.on('close', (code)=>{
|
|
184
|
+
if (code === 0) {
|
|
185
|
+
log.debug(`Successfully ran script: ${scriptName}`);
|
|
186
|
+
resolve(true);
|
|
88
187
|
} else {
|
|
89
|
-
log.debug(`
|
|
188
|
+
log.debug(`Script ${scriptName} failed (exit code: ${code})`);
|
|
189
|
+
if (stderr) {
|
|
190
|
+
log.debug(`stderr: ${stderr}`);
|
|
191
|
+
}
|
|
192
|
+
resolve(false);
|
|
90
193
|
}
|
|
91
|
-
// Always resolve, even on error
|
|
92
|
-
resolve();
|
|
93
194
|
});
|
|
94
195
|
});
|
|
95
196
|
}
|
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
|
*
|
|
@@ -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 'latest')
|
|
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
|
*
|
package/dist/utils/project.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Project detection and scaffolding utilities
|
|
3
|
-
*/ import
|
|
3
|
+
*/ import spawn from 'cross-spawn';
|
|
4
4
|
import fs from 'fs/promises';
|
|
5
5
|
import path from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
6
7
|
import { ensureGitignore } from './config.js';
|
|
7
8
|
import { downloadTemplateFromGitHub } from './download-template.js';
|
|
8
|
-
import { manageEnvFiles } from './env-management.js';
|
|
9
9
|
import { tryInitRepoAndCommit } from './git.js';
|
|
10
10
|
import { applyLambdaModifications } from './lambda-config.js';
|
|
11
|
+
import { getRunCommand } from './package-manager.js';
|
|
12
|
+
import { getOwnVersion } from './version-check.js';
|
|
11
13
|
/**
|
|
12
14
|
* Detect if current directory has a Payload project
|
|
13
15
|
*
|
|
@@ -65,49 +67,62 @@ import { applyLambdaModifications } from './lambda-config.js';
|
|
|
65
67
|
return majorVersion === 3;
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
68
|
-
*
|
|
70
|
+
* Resolve a package version from an npm dist-tag or an explicit version.
|
|
69
71
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
* A value matching a published dist-tag (e.g. 'latest', 'canary') resolves to
|
|
73
|
+
* that tag's concrete version. Any other value is treated as an explicit version
|
|
74
|
+
* and verified against the registry.
|
|
75
|
+
*
|
|
76
|
+
* @param packageName - Package name to look up
|
|
77
|
+
* @param versionOrTag - npm dist-tag or explicit semver version; defaults to 'latest'
|
|
78
|
+
* @returns The concrete version string to pin
|
|
79
|
+
*/ async function resolvePackageVersion(packageName, versionOrTag = 'latest') {
|
|
80
|
+
const distTagsResponse = await fetch(`https://registry.npmjs.org/-/package/${packageName}/dist-tags`);
|
|
81
|
+
if (!distTagsResponse.ok) {
|
|
82
|
+
throw new Error(`Failed to fetch versions for ${packageName}: ${distTagsResponse.statusText}`);
|
|
83
|
+
}
|
|
84
|
+
const distTags = await distTagsResponse.json();
|
|
85
|
+
const tagged = distTags[versionOrTag];
|
|
86
|
+
if (typeof tagged === 'string') {
|
|
87
|
+
return tagged;
|
|
76
88
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
89
|
+
// Not a dist-tag — treat as an explicit version and verify it's published.
|
|
90
|
+
const versionResponse = await fetch(`https://registry.npmjs.org/${packageName}/${versionOrTag}`);
|
|
91
|
+
if (versionResponse.ok) {
|
|
92
|
+
return versionOrTag;
|
|
80
93
|
}
|
|
81
|
-
|
|
94
|
+
throw new Error(`No "${versionOrTag}" version or dist-tag published for ${packageName}. Available dist-tags: ${Object.keys(distTags).join(', ')}`);
|
|
82
95
|
}
|
|
83
96
|
/**
|
|
84
97
|
* Replace workspace versions in package.json with actual versions
|
|
85
98
|
*
|
|
86
99
|
* @param packageJson - Package JSON object to update
|
|
87
|
-
* @param
|
|
88
|
-
*/ function replaceWorkspaceVersions(packageJson,
|
|
100
|
+
* @param coreVersion - Resolved core Payload version to use
|
|
101
|
+
*/ function replaceWorkspaceVersions(packageJson, coreVersion, figmaVersion) {
|
|
89
102
|
const deps = packageJson.dependencies;
|
|
90
103
|
if (!deps) {
|
|
91
104
|
return;
|
|
92
105
|
}
|
|
93
106
|
for (const [key, value] of Object.entries(deps)){
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
107
|
+
if (key === '@payloadcms/figma') {
|
|
108
|
+
deps[key] = figmaVersion;
|
|
109
|
+
} else if (typeof value === 'string' && value.startsWith('workspace:')) {
|
|
110
|
+
deps[key] = coreVersion;
|
|
97
111
|
} else if (key === 'payload' || key.startsWith('@payloadcms/')) {
|
|
98
|
-
deps[key] =
|
|
112
|
+
deps[key] = coreVersion;
|
|
99
113
|
}
|
|
100
114
|
}
|
|
101
|
-
// Also handle devDependencies if present
|
|
102
115
|
const devDeps = packageJson.devDependencies;
|
|
103
116
|
if (!devDeps) {
|
|
104
117
|
return;
|
|
105
118
|
}
|
|
106
119
|
for (const [key, value] of Object.entries(devDeps)){
|
|
107
|
-
if (
|
|
108
|
-
devDeps[key] =
|
|
120
|
+
if (key === '@payloadcms/figma') {
|
|
121
|
+
devDeps[key] = figmaVersion;
|
|
122
|
+
} else if (typeof value === 'string' && value.startsWith('workspace:')) {
|
|
123
|
+
devDeps[key] = coreVersion;
|
|
109
124
|
} else if (key === 'payload' || key.startsWith('@payloadcms/')) {
|
|
110
|
-
devDeps[key] =
|
|
125
|
+
devDeps[key] = coreVersion;
|
|
111
126
|
}
|
|
112
127
|
}
|
|
113
128
|
}
|
|
@@ -116,18 +131,24 @@ import { applyLambdaModifications } from './lambda-config.js';
|
|
|
116
131
|
*
|
|
117
132
|
* @param projectPath - Path where to create the project
|
|
118
133
|
* @param projectName - Name for the project
|
|
119
|
-
|
|
134
|
+
* @param packageManager - Package manager to use
|
|
135
|
+
* @param templateSource - Optional template source override
|
|
136
|
+
* @param payloadVersion - npm dist-tag or explicit version for core payload packages (default 'latest')
|
|
137
|
+
*/ export async function scaffoldProject(projectPath, projectName, packageManager = 'npm', templateSource, payloadVersion = 'latest') {
|
|
120
138
|
// Create project directory if it doesn't exist
|
|
121
139
|
await fs.mkdir(projectPath, {
|
|
122
140
|
recursive: true
|
|
123
141
|
});
|
|
124
142
|
// Download template from GitHub
|
|
125
|
-
await downloadTemplateFromGitHub(projectPath);
|
|
143
|
+
await downloadTemplateFromGitHub(projectPath, templateSource);
|
|
126
144
|
// Apply Lambda modifications BEFORE updating package.json
|
|
127
145
|
// This ensures we don't overwrite version replacements
|
|
128
|
-
await applyLambdaModifications(projectPath);
|
|
129
|
-
//
|
|
130
|
-
const
|
|
146
|
+
await applyLambdaModifications(projectPath, packageManager);
|
|
147
|
+
// Resolve core Payload version from the selected dist-tag or version; figma uses CLI version
|
|
148
|
+
const [coreVersion, figmaVersion] = await Promise.all([
|
|
149
|
+
resolvePackageVersion('payload', payloadVersion),
|
|
150
|
+
getOwnVersion()
|
|
151
|
+
]);
|
|
131
152
|
// Delete any existing lock files from template (they reference workspace:* versions)
|
|
132
153
|
// This ensures pnpm install creates a fresh lock file with actual versions
|
|
133
154
|
const lockFiles = [
|
|
@@ -149,16 +170,24 @@ import { applyLambdaModifications } from './lambda-config.js';
|
|
|
149
170
|
const packageJson = JSON.parse(packageJsonContent);
|
|
150
171
|
packageJson.name = projectName;
|
|
151
172
|
// Replace workspace:* versions with actual versions
|
|
152
|
-
replaceWorkspaceVersions(packageJson,
|
|
173
|
+
replaceWorkspaceVersions(packageJson, coreVersion, figmaVersion);
|
|
153
174
|
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n', 'utf-8');
|
|
154
|
-
// Manage environment files (generate PAYLOAD_SECRET)
|
|
155
|
-
await manageEnvFiles(projectPath);
|
|
156
175
|
// Ensure .gitignore has required entries
|
|
176
|
+
// Note: .env file is created by init command with FIGMA_CONTENT_API_CONTENT_SYSTEM_ID
|
|
157
177
|
await ensureGitignore(projectPath, [
|
|
158
178
|
'.env',
|
|
159
179
|
'.env.local',
|
|
160
180
|
'lambda.zip'
|
|
161
181
|
]);
|
|
182
|
+
// Replace README with Figma-specific version
|
|
183
|
+
const readmeTemplatePath = fileURLToPath(new URL('../templates/README.md', import.meta.url));
|
|
184
|
+
let readmeContent = await fs.readFile(readmeTemplatePath, 'utf-8');
|
|
185
|
+
readmeContent = readmeContent.replace(/\{\{PROJECT_NAME\}\}/g, projectName);
|
|
186
|
+
readmeContent = readmeContent.replace(/\{\{RUN_COMMAND\}\}/g, getRunCommand(packageManager));
|
|
187
|
+
await fs.writeFile(path.join(projectPath, 'README.md'), readmeContent, 'utf-8');
|
|
188
|
+
// Copy .env.example template
|
|
189
|
+
const envExampleTemplatePath = fileURLToPath(new URL('../templates/.env.example', import.meta.url));
|
|
190
|
+
await fs.copyFile(envExampleTemplatePath, path.join(projectPath, '.env.example'));
|
|
162
191
|
}
|
|
163
192
|
/**
|
|
164
193
|
* Initialize git repository after all setup is complete
|
|
@@ -181,7 +210,6 @@ import { applyLambdaModifications } from './lambda-config.js';
|
|
|
181
210
|
'install'
|
|
182
211
|
], {
|
|
183
212
|
cwd: projectPath,
|
|
184
|
-
shell: true,
|
|
185
213
|
stdio: 'pipe'
|
|
186
214
|
});
|
|
187
215
|
let stdout = '';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BootstrapEnvironment } from '../api/control-plane.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve which environment to use from the bootstrap response.
|
|
4
|
+
*
|
|
5
|
+
* - Single environment: auto-select (environmentName optional, validated if provided)
|
|
6
|
+
* - Multiple environments: environmentName required, must match
|
|
7
|
+
*
|
|
8
|
+
* @throws Error if resolution fails (with available environment names)
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveEnvironment(params: {
|
|
11
|
+
environmentName?: string;
|
|
12
|
+
environments: BootstrapEnvironment[];
|
|
13
|
+
}): BootstrapEnvironment;
|
|
14
|
+
//# sourceMappingURL=resolve-environment.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve which environment to use from the bootstrap response.
|
|
3
|
+
*
|
|
4
|
+
* - Single environment: auto-select (environmentName optional, validated if provided)
|
|
5
|
+
* - Multiple environments: environmentName required, must match
|
|
6
|
+
*
|
|
7
|
+
* @throws Error if resolution fails (with available environment names)
|
|
8
|
+
*/ export function resolveEnvironment(params) {
|
|
9
|
+
const { environmentName, environments } = params;
|
|
10
|
+
if (environments.length === 0) {
|
|
11
|
+
throw new Error('No environments found for this project.');
|
|
12
|
+
}
|
|
13
|
+
if (environments.length === 1) {
|
|
14
|
+
if (environmentName && environments[0].name !== environmentName) {
|
|
15
|
+
throw new Error(`Environment "${environmentName}" not found. Available: ${environments[0].name}`);
|
|
16
|
+
}
|
|
17
|
+
return environments[0];
|
|
18
|
+
}
|
|
19
|
+
// Multiple environments — name required
|
|
20
|
+
const availableNames = environments.map((e)=>e.name).join(', ');
|
|
21
|
+
if (!environmentName) {
|
|
22
|
+
throw new Error(`Multiple environments available. Use --env to specify one: ${availableNames}`);
|
|
23
|
+
}
|
|
24
|
+
const matched = environments.find((e)=>e.name === environmentName);
|
|
25
|
+
if (!matched) {
|
|
26
|
+
throw new Error(`Environment "${environmentName}" not found. Available: ${availableNames}`);
|
|
27
|
+
}
|
|
28
|
+
return matched;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=resolve-environment.js.map
|
|
@@ -18,7 +18,6 @@ export interface UploadResults {
|
|
|
18
18
|
*
|
|
19
19
|
* @param filePath - Absolute path to file to upload
|
|
20
20
|
* @param signedUrl - Signed S3 upload URL
|
|
21
|
-
* @param contentType - MIME type (optional)
|
|
22
21
|
* @throws Error if upload fails after retries
|
|
23
22
|
*/
|
|
24
23
|
export declare function uploadFile(filePath: string, signedUrl: string, contentType?: string): Promise<void>;
|
|
@@ -39,5 +38,11 @@ export declare function uploadLambdaZip(zipPath: string, signedUrl: string): Pro
|
|
|
39
38
|
* @param onProgress - Optional callback for progress updates (uploaded, total)
|
|
40
39
|
* @returns Upload results with counts
|
|
41
40
|
*/
|
|
42
|
-
export declare function uploadStaticAssets(
|
|
41
|
+
export declare function uploadStaticAssets(params: {
|
|
42
|
+
assetUrls: Record<string, string>;
|
|
43
|
+
onProgress?: (uploaded: number, total: number) => void;
|
|
44
|
+
/** Map of S3 key → relative filesystem path (overrides default _next/ → .next/ resolution) */
|
|
45
|
+
pathMap?: Record<string, string>;
|
|
46
|
+
projectPath: string;
|
|
47
|
+
}): Promise<UploadResults>;
|
|
43
48
|
//# sourceMappingURL=s3-upload.d.ts.map
|
package/dist/utils/s3-upload.js
CHANGED
|
@@ -11,6 +11,37 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
|
|
|
11
11
|
*/ function sleep(ms) {
|
|
12
12
|
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
13
13
|
}
|
|
14
|
+
/** Common MIME types for web assets, keyed by file extension */ const MIME_TYPES = {
|
|
15
|
+
'.avif': 'image/avif',
|
|
16
|
+
'.css': 'text/css',
|
|
17
|
+
'.csv': 'text/csv',
|
|
18
|
+
'.eot': 'application/vnd.ms-fontobject',
|
|
19
|
+
'.gif': 'image/gif',
|
|
20
|
+
'.html': 'text/html',
|
|
21
|
+
'.ico': 'image/x-icon',
|
|
22
|
+
'.jpeg': 'image/jpeg',
|
|
23
|
+
'.jpg': 'image/jpeg',
|
|
24
|
+
'.js': 'application/javascript',
|
|
25
|
+
'.json': 'application/json',
|
|
26
|
+
'.map': 'application/json',
|
|
27
|
+
'.meta': 'application/json',
|
|
28
|
+
'.mjs': 'application/javascript',
|
|
29
|
+
'.mp4': 'video/mp4',
|
|
30
|
+
'.otf': 'font/otf',
|
|
31
|
+
'.pdf': 'application/pdf',
|
|
32
|
+
'.png': 'image/png',
|
|
33
|
+
'.rsc': 'text/x-component',
|
|
34
|
+
'.svg': 'image/svg+xml',
|
|
35
|
+
'.ttf': 'font/ttf',
|
|
36
|
+
'.txt': 'text/plain',
|
|
37
|
+
'.wasm': 'application/wasm',
|
|
38
|
+
'.webm': 'video/webm',
|
|
39
|
+
'.webp': 'image/webp',
|
|
40
|
+
'.woff': 'font/woff',
|
|
41
|
+
'.woff2': 'font/woff2',
|
|
42
|
+
'.xml': 'application/xml',
|
|
43
|
+
'.zip': 'application/zip'
|
|
44
|
+
};
|
|
14
45
|
/**
|
|
15
46
|
* Check if a signed URL is a mock URL
|
|
16
47
|
*/ function isMockUrl(signedUrl) {
|
|
@@ -23,7 +54,6 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
|
|
|
23
54
|
*
|
|
24
55
|
* @param filePath - Absolute path to file to upload
|
|
25
56
|
* @param signedUrl - Signed S3 upload URL
|
|
26
|
-
* @param contentType - MIME type (optional)
|
|
27
57
|
* @throws Error if upload fails after retries
|
|
28
58
|
*/ export async function uploadFile(filePath, signedUrl, contentType) {
|
|
29
59
|
// Skip actual upload for mock URLs
|
|
@@ -45,10 +75,12 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
|
|
|
45
75
|
let lastError = null;
|
|
46
76
|
for(let attempt = 0; attempt < MAX_RETRIES; attempt++){
|
|
47
77
|
try {
|
|
78
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
79
|
+
const determinedContentType = contentType ?? MIME_TYPES[ext];
|
|
48
80
|
const response = await fetch(signedUrl, {
|
|
49
81
|
body: fileBuffer,
|
|
50
|
-
headers:
|
|
51
|
-
'Content-Type':
|
|
82
|
+
headers: determinedContentType ? {
|
|
83
|
+
'Content-Type': determinedContentType
|
|
52
84
|
} : {},
|
|
53
85
|
method: 'PUT'
|
|
54
86
|
});
|
|
@@ -83,7 +115,8 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
|
|
|
83
115
|
* @param assetUrls - Map of asset paths to signed URLs
|
|
84
116
|
* @param onProgress - Optional callback for progress updates (uploaded, total)
|
|
85
117
|
* @returns Upload results with counts
|
|
86
|
-
*/ export async function uploadStaticAssets(
|
|
118
|
+
*/ export async function uploadStaticAssets(params) {
|
|
119
|
+
const { assetUrls, onProgress, pathMap, projectPath } = params;
|
|
87
120
|
const results = {
|
|
88
121
|
assetsFailed: 0,
|
|
89
122
|
assetsUploaded: 0,
|
|
@@ -100,8 +133,8 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
|
|
|
100
133
|
const batch = assetPaths.slice(i, i + CONCURRENCY);
|
|
101
134
|
await Promise.all(batch.map(async (assetPath)=>{
|
|
102
135
|
try {
|
|
103
|
-
//
|
|
104
|
-
const fsPath = assetPath.replace(/^_next\//, '.next/');
|
|
136
|
+
// Resolve filesystem path: use pathMap if available, else default _next/ → .next/
|
|
137
|
+
const fsPath = pathMap?.[assetPath] ?? assetPath.replace(/^_next\//, '.next/');
|
|
105
138
|
const fullPath = path.join(projectPath, fsPath);
|
|
106
139
|
const signedUrl = assetUrls[assetPath];
|
|
107
140
|
await uploadFile(fullPath, signedUrl);
|
|
@@ -8,7 +8,11 @@ export declare function maskToken(token: string): string;
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function formatTimestamp(timestamp: number): string;
|
|
10
10
|
/**
|
|
11
|
-
* Show
|
|
11
|
+
* Show the project token for the current project + environment scope.
|
|
12
|
+
*
|
|
13
|
+
* Resolves `projectId` and `environmentName` from env vars
|
|
14
|
+
* (`FIGMA_PROJECT_ID`, `FIGMA_ENVIRONMENT_NAME`) — the *user's* project
|
|
15
|
+
* environment, which is independent of the infra env (production/staging).
|
|
12
16
|
*/
|
|
13
17
|
export declare function showProjectTokens(tokenStore: TokenStore): void;
|
|
14
18
|
//# sourceMappingURL=token-display.d.ts.map
|