@payloadcms/figma 0.0.1-alpha.6 → 0.0.1-alpha.60
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 +52 -6
- package/dist/api/control-plane.js +174 -72
- package/dist/api/figma-api.d.ts +22 -1
- package/dist/api/figma-api.js +78 -25
- package/dist/auth/callback-server.js +2 -1
- package/dist/auth/credentials.d.ts +21 -0
- package/dist/auth/credentials.js +21 -0
- package/dist/auth/crypto-utils.d.ts +6 -0
- package/dist/auth/crypto-utils.js +16 -14
- package/dist/auth/jwt-validator.d.ts +2 -1
- package/dist/auth/jwt-validator.js +2 -2
- package/dist/auth/oauth-flow.d.ts +17 -3
- package/dist/auth/oauth-flow.js +63 -16
- package/dist/auth/project-token.js +16 -11
- package/dist/auth/refresh.d.ts +2 -1
- package/dist/auth/refresh.js +25 -12
- package/dist/auth/token-store.d.ts +42 -1
- package/dist/auth/token-store.js +118 -14
- package/dist/auth/types.d.ts +17 -4
- package/dist/cli.js +68 -5
- 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 +176 -0
- package/dist/commands/deploy.d.ts +9 -0
- package/dist/commands/deploy.js +178 -151
- package/dist/commands/env.d.ts +13 -0
- package/dist/commands/env.js +88 -0
- package/dist/commands/init.d.ts +3 -5
- package/dist/commands/init.js +165 -148
- package/dist/commands/list-tokens.d.ts +3 -3
- package/dist/commands/list-tokens.js +22 -7
- package/dist/commands/login.d.ts +8 -1
- package/dist/commands/login.js +33 -15
- package/dist/commands/logout.d.ts +5 -4
- package/dist/commands/logout.js +56 -13
- package/dist/commands/upgrade.d.ts +5 -0
- package/dist/commands/upgrade.js +331 -0
- package/dist/config/oauth.d.ts +4 -14
- package/dist/config/oauth.js +18 -40
- package/dist/constants.d.ts +44 -19
- package/dist/constants.js +73 -20
- package/dist/db-content-api/README.md +98 -0
- package/dist/db-content-api/generated/content-api-types.d.ts +3972 -0
- package/dist/db-content-api/generated/content-api-types.js +7 -0
- package/dist/db-content-api/index.d.ts +21 -0
- package/dist/db-content-api/index.js +787 -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 +59 -0
- package/dist/db-content-api/utilities/auth.d.ts +30 -0
- package/dist/db-content-api/utilities/auth.js +81 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +59 -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 +284 -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/joins.d.ts +55 -0
- package/dist/db-content-api/utilities/joins.js +135 -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 +104 -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/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/index.js +50 -6
- package/dist/oauth/components/LoginButton/index.scss +50 -3
- package/dist/oauth/components/LogoutButton/index.js +5 -4
- package/dist/oauth/defaults.js +67 -10
- package/dist/oauth/endpoints/getLoginEndpoint.js +77 -24
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
- package/dist/oauth/index.js +40 -13
- package/dist/oauth/strategy/index.d.ts +0 -2
- package/dist/oauth/strategy/index.js +40 -17
- package/dist/oauth/types.d.ts +6 -6
- 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/build-config.d.ts +18 -15
- package/dist/plugin/build-config.js +213 -18
- 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 +42 -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 +36 -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 +56 -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 +2 -0
- package/dist/storage-content-api/utilities/index.js +3 -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 +8 -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 +14 -0
- package/dist/utils/build-lambda-zip.js +81 -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.js +3 -2
- 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 +87 -79
- package/dist/utils/messages.d.ts +1 -2
- package/dist/utils/messages.js +29 -11
- package/dist/utils/package-manager.d.ts +24 -0
- package/dist/utils/package-manager.js +53 -0
- package/dist/utils/payload-config-ast.d.ts +27 -6
- package/dist/utils/payload-config-ast.js +84 -54
- 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 +70 -11
- package/dist/utils/payload-package-check.d.ts +12 -1
- package/dist/utils/payload-package-check.js +63 -5
- package/dist/utils/project.d.ts +3 -2
- package/dist/utils/project.js +29 -15
- 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.js +11 -5
- 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 +29 -11
- 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
|
@@ -20,15 +20,18 @@ import * as log from './log.js';
|
|
|
20
20
|
log.debug(`Found import from: ${payloadImport.getModuleSpecifierValue()}`);
|
|
21
21
|
const moduleSpecifier = payloadImport.getModuleSpecifierValue();
|
|
22
22
|
const namedImports = payloadImport.getNamedImports();
|
|
23
|
-
//
|
|
24
|
-
|
|
23
|
+
// Determine which function name to look for based on the import source
|
|
24
|
+
// - From 'payload': look for buildConfig (needs migration)
|
|
25
|
+
// - From '@payloadcms/figma': look for buildFigmaConfig (already migrated)
|
|
26
|
+
const expectedFunctionName = moduleSpecifier === 'payload' ? 'buildConfig' : 'buildFigmaConfig';
|
|
27
|
+
const buildConfigImport = namedImports.find((ni)=>ni.getName() === expectedFunctionName);
|
|
25
28
|
if (!buildConfigImport) {
|
|
26
29
|
result.hasBuildConfig = false;
|
|
27
30
|
return result;
|
|
28
31
|
}
|
|
29
32
|
// Check for alias and get the actual name used in code
|
|
30
33
|
const aliasNode = buildConfigImport.getAliasNode();
|
|
31
|
-
const buildConfigName = aliasNode ? aliasNode.getText() :
|
|
34
|
+
const buildConfigName = aliasNode ? aliasNode.getText() : expectedFunctionName;
|
|
32
35
|
if (aliasNode) {
|
|
33
36
|
result.hasAlias = true;
|
|
34
37
|
}
|
|
@@ -109,6 +112,15 @@ import * as log from './log.js';
|
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
}
|
|
115
|
+
// Check for sharp property
|
|
116
|
+
const sharpProperty = configArg.getProperty('sharp');
|
|
117
|
+
if (sharpProperty) {
|
|
118
|
+
// Find the import source for sharp
|
|
119
|
+
const sharpImport = imports.find((imp)=>imp.getModuleSpecifierValue() === 'sharp' || imp.getNamedImports().some((ni)=>ni.getName() === 'sharp'));
|
|
120
|
+
result.sharpProperty = {
|
|
121
|
+
importSource: sharpImport?.getModuleSpecifierValue() || 'sharp'
|
|
122
|
+
};
|
|
123
|
+
}
|
|
112
124
|
// Check for figma property
|
|
113
125
|
const figmaProperty = configArg.getProperty('figma');
|
|
114
126
|
if (figmaProperty) {
|
|
@@ -240,7 +252,16 @@ import * as log from './log.js';
|
|
|
240
252
|
modified = true;
|
|
241
253
|
}
|
|
242
254
|
}
|
|
243
|
-
// 4.
|
|
255
|
+
// 4. Remove sharp property
|
|
256
|
+
if (detection.sharpProperty) {
|
|
257
|
+
const sharpProperty = configArg.getProperty('sharp');
|
|
258
|
+
if (sharpProperty) {
|
|
259
|
+
sharpProperty.remove();
|
|
260
|
+
changes.push('Removed sharp property');
|
|
261
|
+
modified = true;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// 5. Update buildConfig import
|
|
244
265
|
if (detection.needsImportChange) {
|
|
245
266
|
if (payloadImport) {
|
|
246
267
|
if (detection.hasOtherPayloadImports) {
|
|
@@ -258,19 +279,38 @@ import * as log from './log.js';
|
|
|
258
279
|
sourceFile.addImportDeclaration({
|
|
259
280
|
moduleSpecifier: '@payloadcms/figma',
|
|
260
281
|
namedImports: [
|
|
261
|
-
'
|
|
282
|
+
'buildFigmaConfig'
|
|
262
283
|
]
|
|
263
284
|
});
|
|
285
|
+
// Rename all usages of 'buildConfig' to 'buildFigmaConfig'
|
|
286
|
+
const identifiers = sourceFile.getDescendantsOfKind(SyntaxKind.Identifier);
|
|
287
|
+
identifiers.forEach((identifier)=>{
|
|
288
|
+
if (identifier.getText() === 'buildConfig') {
|
|
289
|
+
identifier.replaceWithText('buildFigmaConfig');
|
|
290
|
+
}
|
|
291
|
+
});
|
|
264
292
|
changes.push('Split buildConfig import to @payloadcms/figma');
|
|
265
293
|
} else {
|
|
266
|
-
// Replace entire import
|
|
294
|
+
// Replace entire import: change module specifier and rename all references
|
|
295
|
+
const buildConfigImport = payloadImport.getNamedImports().find((ni)=>ni.getName() === 'buildConfig');
|
|
296
|
+
if (buildConfigImport) {
|
|
297
|
+
// Change the import name
|
|
298
|
+
buildConfigImport.setName('buildFigmaConfig');
|
|
299
|
+
// Find and rename all usages of 'buildConfig' in the file
|
|
300
|
+
const identifiers = sourceFile.getDescendantsOfKind(SyntaxKind.Identifier);
|
|
301
|
+
identifiers.forEach((identifier)=>{
|
|
302
|
+
if (identifier.getText() === 'buildConfig') {
|
|
303
|
+
identifier.replaceWithText('buildFigmaConfig');
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
267
307
|
payloadImport.setModuleSpecifier('@payloadcms/figma');
|
|
268
308
|
changes.push('Changed buildConfig import to @payloadcms/figma');
|
|
269
309
|
}
|
|
270
310
|
modified = true;
|
|
271
311
|
}
|
|
272
312
|
}
|
|
273
|
-
//
|
|
313
|
+
// 6. Remove orphaned imports
|
|
274
314
|
// Re-fetch imports after each removal to avoid stale references
|
|
275
315
|
if (detection.dbProperty) {
|
|
276
316
|
const currentImports = sourceFile.getImportDeclarations();
|
|
@@ -290,6 +330,15 @@ import * as log from './log.js';
|
|
|
290
330
|
modified = true;
|
|
291
331
|
}
|
|
292
332
|
}
|
|
333
|
+
if (detection.sharpProperty) {
|
|
334
|
+
const currentImports = sourceFile.getImportDeclarations();
|
|
335
|
+
const sharpImport = currentImports.find((imp)=>imp.getModuleSpecifierValue() === 'sharp');
|
|
336
|
+
if (sharpImport) {
|
|
337
|
+
sharpImport.remove();
|
|
338
|
+
changes.push('Removed sharp import');
|
|
339
|
+
modified = true;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
293
342
|
return {
|
|
294
343
|
changes,
|
|
295
344
|
modified
|
|
@@ -301,15 +350,15 @@ import * as log from './log.js';
|
|
|
301
350
|
*/ export function addFigmaProperty(sourceFile, config) {
|
|
302
351
|
const changes = [];
|
|
303
352
|
let modified = false;
|
|
304
|
-
// Find
|
|
353
|
+
// Find buildFigmaConfig call (this function is only used with Figma configs)
|
|
305
354
|
const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
|
|
306
355
|
const buildConfigCall = callExpressions.find((ce)=>{
|
|
307
356
|
const expr = ce.getExpression();
|
|
308
357
|
const text = expr.getText();
|
|
309
|
-
return text === '
|
|
358
|
+
return text === 'buildFigmaConfig' || text.endsWith('.buildFigmaConfig');
|
|
310
359
|
});
|
|
311
360
|
if (!buildConfigCall) {
|
|
312
|
-
log.debug('No
|
|
361
|
+
log.debug('No buildFigmaConfig call found');
|
|
313
362
|
return {
|
|
314
363
|
changes: [],
|
|
315
364
|
modified: false
|
|
@@ -336,15 +385,14 @@ import * as log from './log.js';
|
|
|
336
385
|
};
|
|
337
386
|
}
|
|
338
387
|
// Add figma property
|
|
388
|
+
// contentSystemId is resolved automatically by buildFigmaConfig from env vars or bootstrap cache.
|
|
389
|
+
// useContentSystem defaults to true, so we only generate it when explicitly false.
|
|
390
|
+
const figmaObj = config.useContentSystem === false ? `{\nuseContentSystem: false,\n}` : '{}';
|
|
339
391
|
configArg.addPropertyAssignment({
|
|
340
392
|
name: 'figma',
|
|
341
|
-
initializer:
|
|
342
|
-
region: '${config.region}',
|
|
343
|
-
tenantId: '${config.tenantId}',
|
|
344
|
-
useContentSystem: ${config.useContentSystem},
|
|
345
|
-
}`
|
|
393
|
+
initializer: figmaObj
|
|
346
394
|
});
|
|
347
|
-
changes.push(`Added figma property (
|
|
395
|
+
changes.push(`Added figma property (contentSystemId: ${config.contentSystemId})`);
|
|
348
396
|
modified = true;
|
|
349
397
|
return {
|
|
350
398
|
changes,
|
|
@@ -352,60 +400,42 @@ import * as log from './log.js';
|
|
|
352
400
|
};
|
|
353
401
|
}
|
|
354
402
|
/**
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
|
|
358
|
-
|
|
403
|
+
* Remove the contentSystemId property from figma config object.
|
|
404
|
+
* Used during upgrade migration — contentSystemId is now resolved from bootstrap data.
|
|
405
|
+
*
|
|
406
|
+
* @returns true if the property was found and removed
|
|
407
|
+
*/ export function removeFigmaContentSystemId(sourceFile) {
|
|
359
408
|
const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
|
|
360
409
|
const buildConfigCall = callExpressions.find((ce)=>{
|
|
361
410
|
const expr = ce.getExpression();
|
|
362
411
|
const text = expr.getText();
|
|
363
|
-
return text === '
|
|
412
|
+
return text === 'buildFigmaConfig' || text.endsWith('.buildFigmaConfig');
|
|
364
413
|
});
|
|
365
414
|
if (!buildConfigCall) {
|
|
366
|
-
|
|
367
|
-
return null;
|
|
415
|
+
return false;
|
|
368
416
|
}
|
|
369
|
-
// Get config object argument
|
|
370
417
|
const configArg = buildConfigCall.getArguments()[0];
|
|
371
418
|
if (!configArg || !Node.isObjectLiteralExpression(configArg)) {
|
|
372
|
-
|
|
373
|
-
return null;
|
|
419
|
+
return false;
|
|
374
420
|
}
|
|
375
|
-
// Find figma property
|
|
376
421
|
const figmaProperty = configArg.getProperty('figma');
|
|
377
422
|
if (!figmaProperty || !Node.isPropertyAssignment(figmaProperty)) {
|
|
378
|
-
|
|
379
|
-
return null;
|
|
423
|
+
return false;
|
|
380
424
|
}
|
|
381
|
-
// Get initializer (the object value)
|
|
382
425
|
const initializer = figmaProperty.getInitializer();
|
|
383
426
|
if (!initializer || !Node.isObjectLiteralExpression(initializer)) {
|
|
384
|
-
|
|
385
|
-
return null;
|
|
386
|
-
}
|
|
387
|
-
// Extract values
|
|
388
|
-
const regionProp = initializer.getProperty('region');
|
|
389
|
-
const tenantIdProp = initializer.getProperty('tenantId');
|
|
390
|
-
const useContentSystemProp = initializer.getProperty('useContentSystem');
|
|
391
|
-
if (!regionProp || !tenantIdProp) {
|
|
392
|
-
log.debug('Missing required figma properties (region or tenantId)');
|
|
393
|
-
return null;
|
|
394
|
-
}
|
|
395
|
-
// Extract string values (remove quotes)
|
|
396
|
-
const region = Node.isPropertyAssignment(regionProp) ? regionProp.getInitializer()?.getText().replace(/['"]/g, '') : undefined;
|
|
397
|
-
const tenantId = Node.isPropertyAssignment(tenantIdProp) ? tenantIdProp.getInitializer()?.getText().replace(/['"]/g, '') : undefined;
|
|
398
|
-
const useContentSystem = Node.isPropertyAssignment(useContentSystemProp) ? useContentSystemProp.getInitializer()?.getText() === 'true' : true // Default to true if not specified
|
|
399
|
-
;
|
|
400
|
-
if (!region || !tenantId) {
|
|
401
|
-
log.debug('Could not extract region or tenantId values');
|
|
402
|
-
return null;
|
|
427
|
+
return false;
|
|
403
428
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
429
|
+
const contentSystemIdProp = initializer.getProperty('contentSystemId');
|
|
430
|
+
if (!contentSystemIdProp) {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
contentSystemIdProp.remove();
|
|
434
|
+
// Collapse empty object to avoid ts-morph whitespace artifacts
|
|
435
|
+
if (initializer.getProperties().length === 0) {
|
|
436
|
+
initializer.replaceWithText('{}');
|
|
437
|
+
}
|
|
438
|
+
return true;
|
|
409
439
|
}
|
|
410
440
|
|
|
411
441
|
//# sourceMappingURL=payload-config-ast.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Find the Payload config file using Payload's built-in finder
|
|
3
|
-
*
|
|
2
|
+
* Find the Payload config file using Payload's built-in finder when available,
|
|
3
|
+
* with fallback to simple file search for npx environments where payload isn't installed.
|
|
4
4
|
*
|
|
5
5
|
* @param projectPath - Absolute path to project directory
|
|
6
6
|
* @returns Absolute path to config file, or null if not found
|
|
@@ -1,26 +1,65 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import * as log from './log.js';
|
|
4
|
+
// Standard Payload config file names in priority order
|
|
5
|
+
const CONFIG_FILES = [
|
|
6
|
+
'payload.config.ts',
|
|
7
|
+
'payload.config.js',
|
|
8
|
+
'src/payload.config.ts',
|
|
9
|
+
'src/payload.config.js'
|
|
10
|
+
];
|
|
2
11
|
/**
|
|
3
|
-
* Find the Payload config file using Payload's built-in finder
|
|
4
|
-
*
|
|
12
|
+
* Find the Payload config file using Payload's built-in finder when available,
|
|
13
|
+
* with fallback to simple file search for npx environments where payload isn't installed.
|
|
5
14
|
*
|
|
6
15
|
* @param projectPath - Absolute path to project directory
|
|
7
16
|
* @returns Absolute path to config file, or null if not found
|
|
8
17
|
*/ export async function findPayloadConfig(projectPath) {
|
|
18
|
+
// First, try using Payload's official config finder (if payload is installed)
|
|
19
|
+
const configFromPayload = await findConfigWithPayload(projectPath);
|
|
20
|
+
if (configFromPayload) {
|
|
21
|
+
return configFromPayload;
|
|
22
|
+
}
|
|
23
|
+
// Fallback: Simple file search for standard config locations
|
|
24
|
+
// This works when running via npx before payload is installed
|
|
25
|
+
log.debug('Payload not available, using fallback config finder');
|
|
26
|
+
return findConfigFallback(projectPath);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Try to find config using Payload's findConfig function.
|
|
30
|
+
* Returns null if payload is not installed (dynamic import fails).
|
|
31
|
+
*/ async function findConfigWithPayload(projectPath) {
|
|
9
32
|
const originalCwd = process.cwd();
|
|
10
33
|
try {
|
|
34
|
+
// Dynamic import - will fail gracefully if payload is not installed
|
|
35
|
+
const { findConfig } = await import('payload/node');
|
|
11
36
|
// findConfig requires being in the project directory
|
|
12
37
|
process.chdir(projectPath);
|
|
13
|
-
// Use Payload's official config finder
|
|
14
38
|
const configPath = findConfig();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
39
|
+
return configPath || null;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
// payload not installed or other error - return null to use fallback
|
|
42
|
+
log.debug(`Could not use Payload findConfig: ${error instanceof Error ? error.message : 'unknown'}`);
|
|
19
43
|
return null;
|
|
20
44
|
} finally{
|
|
21
|
-
// Always restore original working directory
|
|
22
45
|
process.chdir(originalCwd);
|
|
23
46
|
}
|
|
24
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Fallback config finder that checks standard locations.
|
|
50
|
+
* Used when payload is not installed (e.g., running via npx).
|
|
51
|
+
*/ async function findConfigFallback(projectPath) {
|
|
52
|
+
for (const configFile of CONFIG_FILES){
|
|
53
|
+
const fullPath = path.join(projectPath, configFile);
|
|
54
|
+
try {
|
|
55
|
+
await fs.access(fullPath);
|
|
56
|
+
log.debug(`Found config at: ${fullPath}`);
|
|
57
|
+
return fullPath;
|
|
58
|
+
} catch {
|
|
59
|
+
// File doesn't exist, try next
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
25
64
|
|
|
26
65
|
//# sourceMappingURL=payload-config-finder.js.map
|
|
@@ -15,5 +15,5 @@ export declare function ensurePayloadFigmaConfig(projectPath: string, packageMan
|
|
|
15
15
|
/**
|
|
16
16
|
* Display manual configuration instructions
|
|
17
17
|
*/
|
|
18
|
-
export declare function displayManualInstructions(reason: string): void;
|
|
18
|
+
export declare function displayManualInstructions(reason: string, packageManager?: PackageManager): void;
|
|
19
19
|
//# sourceMappingURL=payload-config-modifier.d.ts.map
|
|
@@ -1,11 +1,13 @@
|
|
|
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, installPackage, uninstallPackage } from './payload-package-check.js';
|
|
8
|
+
import { checkPackageInstalled, getPayloadVersion, installPackage, uninstallPackage } 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
|
|
@@ -27,12 +29,16 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
27
29
|
};
|
|
28
30
|
}
|
|
29
31
|
log.debug(`Found config file: ${configPath}`);
|
|
32
|
+
// Get payload version to pin @payloadcms/* dependencies
|
|
33
|
+
const payloadVersion = await getPayloadVersion(projectPath);
|
|
34
|
+
log.debug(`Detected payload version: ${payloadVersion || 'unknown'}`);
|
|
30
35
|
// 2. Check/install @payloadcms/figma package
|
|
31
36
|
const isInstalled = await checkPackageInstalled(projectPath, '@payloadcms/figma');
|
|
32
37
|
if (!isInstalled) {
|
|
33
38
|
log.debug('@payloadcms/figma not installed, attempting installation...');
|
|
34
39
|
try {
|
|
35
|
-
await
|
|
40
|
+
const figmaVersion = await getOwnVersion();
|
|
41
|
+
await installPackage(projectPath, '@payloadcms/figma', packageManager, figmaVersion);
|
|
36
42
|
changes.push('Installed @payloadcms/figma');
|
|
37
43
|
modified = true;
|
|
38
44
|
log.debug('@payloadcms/figma installed successfully');
|
|
@@ -51,6 +57,10 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
51
57
|
// 3. Parse config with ts-morph
|
|
52
58
|
log.debug('Parsing config file with ts-morph...');
|
|
53
59
|
const project = new Project({
|
|
60
|
+
manipulationSettings: {
|
|
61
|
+
indentationText: IndentationText.TwoSpaces,
|
|
62
|
+
useTrailingCommas: true
|
|
63
|
+
},
|
|
54
64
|
skipAddingFilesFromTsConfig: true
|
|
55
65
|
});
|
|
56
66
|
const sourceFile = project.addSourceFileAtPath(configPath);
|
|
@@ -101,15 +111,64 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
101
111
|
}
|
|
102
112
|
// Save file if any modifications were made
|
|
103
113
|
if (modified) {
|
|
114
|
+
sourceFile.formatText({
|
|
115
|
+
indentSize: 2,
|
|
116
|
+
tabSize: 2
|
|
117
|
+
});
|
|
104
118
|
await sourceFile.save();
|
|
105
119
|
log.debug('Config file saved');
|
|
106
|
-
// 7.
|
|
120
|
+
// 7. Handle package management
|
|
107
121
|
const packagesToUninstall = [];
|
|
122
|
+
// Uninstall db adapter (buildFigmaConfig provides its own)
|
|
108
123
|
if (detection.dbProperty) {
|
|
109
124
|
packagesToUninstall.push(detection.dbProperty.importSource);
|
|
110
125
|
}
|
|
111
|
-
|
|
112
|
-
|
|
126
|
+
// Uninstall sharp (Figma infrastructure handles image processing)
|
|
127
|
+
if (detection.sharpProperty) {
|
|
128
|
+
packagesToUninstall.push('sharp');
|
|
129
|
+
}
|
|
130
|
+
// Ensure lexical is installed if user doesn't have a custom editor
|
|
131
|
+
// (buildFigmaConfig uses lexicalEditor() as default)
|
|
132
|
+
if (!detection.editorProperty) {
|
|
133
|
+
log.debug('No editor property detected - will ensure lexical is installed for default editor');
|
|
134
|
+
} else if (detection.editorProperty.isDefault) {
|
|
135
|
+
log.debug('Default lexicalEditor() detected - will ensure lexical is installed');
|
|
136
|
+
} else {
|
|
137
|
+
log.debug(`Custom editor detected (${detection.editorProperty.importSource}) - skipping lexical installation`);
|
|
138
|
+
}
|
|
139
|
+
if (!detection.editorProperty || detection.editorProperty.isDefault) {
|
|
140
|
+
log.debug('Checking if @payloadcms/richtext-lexical is installed...');
|
|
141
|
+
const hasLexical = await checkPackageInstalled(projectPath, '@payloadcms/richtext-lexical');
|
|
142
|
+
if (!hasLexical) {
|
|
143
|
+
log.debug('@payloadcms/richtext-lexical not found, installing...');
|
|
144
|
+
try {
|
|
145
|
+
await installPackage(projectPath, '@payloadcms/richtext-lexical', packageManager, payloadVersion);
|
|
146
|
+
changes.push('Installed @payloadcms/richtext-lexical (default editor)');
|
|
147
|
+
log.debug('Successfully installed @payloadcms/richtext-lexical');
|
|
148
|
+
} catch (error) {
|
|
149
|
+
log.debug(`Failed to install @payloadcms/richtext-lexical: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
150
|
+
// Don't fail on install error - user can install manually if needed
|
|
151
|
+
warnings.push('Could not install @payloadcms/richtext-lexical - you may need to install it manually');
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
log.debug('@payloadcms/richtext-lexical already installed, skipping');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Ensure cloud-storage is installed (required peer dependency for buildFigmaConfig)
|
|
158
|
+
log.debug('Checking if @payloadcms/plugin-cloud-storage is installed...');
|
|
159
|
+
const hasCloudStorage = await checkPackageInstalled(projectPath, '@payloadcms/plugin-cloud-storage');
|
|
160
|
+
if (!hasCloudStorage) {
|
|
161
|
+
log.debug('@payloadcms/plugin-cloud-storage not found, installing...');
|
|
162
|
+
try {
|
|
163
|
+
await installPackage(projectPath, '@payloadcms/plugin-cloud-storage', packageManager, payloadVersion);
|
|
164
|
+
changes.push('Installed @payloadcms/plugin-cloud-storage');
|
|
165
|
+
log.debug('Successfully installed @payloadcms/plugin-cloud-storage');
|
|
166
|
+
} catch (error) {
|
|
167
|
+
log.debug(`Failed to install @payloadcms/plugin-cloud-storage: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
168
|
+
warnings.push('Could not install @payloadcms/plugin-cloud-storage - you may need to install it manually');
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
log.debug('@payloadcms/plugin-cloud-storage already installed, skipping');
|
|
113
172
|
}
|
|
114
173
|
if (packagesToUninstall.length > 0) {
|
|
115
174
|
log.debug(`Uninstalling ${packagesToUninstall.length} orphaned packages...`);
|
|
@@ -135,7 +194,7 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
135
194
|
log.debug('Running TypeScript validation...');
|
|
136
195
|
const tsResult = await runTypeScriptCheck(projectPath, packageManager);
|
|
137
196
|
if (!tsResult.success && tsResult.errors.length > 0) {
|
|
138
|
-
warnings.push(
|
|
197
|
+
warnings.push(`TypeScript validation found issues - run '${getRunCommand(packageManager)} build' for details`);
|
|
139
198
|
log.debug(`TypeScript validation found ${tsResult.errors.length} issues`);
|
|
140
199
|
}
|
|
141
200
|
} else {
|
|
@@ -163,10 +222,10 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
163
222
|
}
|
|
164
223
|
/**
|
|
165
224
|
* Display manual configuration instructions
|
|
166
|
-
*/ export function displayManualInstructions(reason) {
|
|
225
|
+
*/ export function displayManualInstructions(reason, packageManager = 'npm') {
|
|
167
226
|
const leftLineWrap = (message)=>{
|
|
168
227
|
// Add '┌ ' prefix to first line, '│ ' to subsequent lines, and '└ ' to last line
|
|
169
|
-
return message.split(
|
|
228
|
+
return message.split(/\r?\n/).map((line, index, arr)=>{
|
|
170
229
|
if (index === 0) {
|
|
171
230
|
return `${pc.dim('┌ ')}${line}`;
|
|
172
231
|
} else if (index === arr.length - 1) {
|
|
@@ -185,7 +244,7 @@ ${pc.bold('Required changes:')}
|
|
|
185
244
|
|
|
186
245
|
1. Replace buildConfig import:
|
|
187
246
|
${pc.dim('- FROM: ')}${pc.cyan("import { buildConfig } from 'payload'")}
|
|
188
|
-
${pc.dim('- TO: ')}${pc.cyan("import {
|
|
247
|
+
${pc.dim('- TO: ')}${pc.cyan("import { buildFigmaConfig } from '@payloadcms/figma'")}
|
|
189
248
|
|
|
190
249
|
2. Remove these properties from buildConfig():
|
|
191
250
|
• db
|
|
@@ -193,7 +252,7 @@ ${pc.bold('Required changes:')}
|
|
|
193
252
|
• editor (if using default lexicalEditor())
|
|
194
253
|
|
|
195
254
|
3. Install package:
|
|
196
|
-
${pc.cyan(
|
|
255
|
+
${pc.cyan(`${getAddCommand(packageManager)} @payloadcms/figma`)}
|
|
197
256
|
|
|
198
257
|
Then run: ${pc.cyan('npx @payloadcms/figma init')}`);
|
|
199
258
|
// eslint-disable-next-line no-console
|
|
@@ -3,13 +3,24 @@ import type { PackageManager } from './package-manager.js';
|
|
|
3
3
|
* Check if a package is installed in dependencies (not devDependencies)
|
|
4
4
|
*/
|
|
5
5
|
export declare function checkPackageInstalled(projectPath: string, packageName: string): Promise<boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* Get the payload version from project's package.json (without range specifiers)
|
|
8
|
+
* Returns the clean version number (e.g., "3.71.1") or undefined if not found
|
|
9
|
+
*/
|
|
10
|
+
export declare function getPayloadVersion(projectPath: string): Promise<string | undefined>;
|
|
6
11
|
/**
|
|
7
12
|
* Install a package as a production dependency
|
|
13
|
+
* @param version - Version to install (without caret). Defaults to 'latest'.
|
|
8
14
|
*/
|
|
9
|
-
export declare function installPackage(projectPath: string, packageName: string, packageManager: PackageManager): Promise<void>;
|
|
15
|
+
export declare function installPackage(projectPath: string, packageName: string, packageManager: PackageManager, version?: string): Promise<void>;
|
|
10
16
|
/**
|
|
11
17
|
* Uninstall a package
|
|
12
18
|
* Does not throw on failure - orphaned package is better than broken config
|
|
13
19
|
*/
|
|
14
20
|
export declare function uninstallPackage(projectPath: string, packageName: string, packageManager: PackageManager): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Run an npm script from package.json
|
|
23
|
+
* Does not throw on failure - logs warning and continues
|
|
24
|
+
*/
|
|
25
|
+
export declare function runScript(projectPath: string, scriptName: string, packageManager: PackageManager): Promise<boolean>;
|
|
15
26
|
//# 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,14 +18,34 @@ 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') {
|
|
24
43
|
return new Promise((resolve, reject)=>{
|
|
25
44
|
const command = packageManager;
|
|
45
|
+
const packageSpec = packageName.endsWith('.tgz') ? packageName : `${packageName}@${version}`;
|
|
26
46
|
const args = [
|
|
27
47
|
'add',
|
|
28
|
-
|
|
48
|
+
packageSpec
|
|
29
49
|
];
|
|
30
50
|
// npm uses 'install' instead of 'add'
|
|
31
51
|
if (packageManager === 'npm') {
|
|
@@ -35,7 +55,6 @@ import * as log from './log.js';
|
|
|
35
55
|
let stderr = '';
|
|
36
56
|
const child = spawn(command, args, {
|
|
37
57
|
cwd: projectPath,
|
|
38
|
-
shell: true,
|
|
39
58
|
stdio: 'pipe'
|
|
40
59
|
});
|
|
41
60
|
// Capture stderr for debug logging
|
|
@@ -79,7 +98,6 @@ import * as log from './log.js';
|
|
|
79
98
|
log.debug(`Running: ${command} ${args.join(' ')} in ${projectPath}`);
|
|
80
99
|
const child = spawn(command, args, {
|
|
81
100
|
cwd: projectPath,
|
|
82
|
-
shell: true,
|
|
83
101
|
stdio: 'pipe'
|
|
84
102
|
});
|
|
85
103
|
child.on('close', (code)=>{
|
|
@@ -93,5 +111,45 @@ import * as log from './log.js';
|
|
|
93
111
|
});
|
|
94
112
|
});
|
|
95
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Run an npm script from package.json
|
|
116
|
+
* Does not throw on failure - logs warning and continues
|
|
117
|
+
*/ export async function runScript(projectPath, scriptName, packageManager) {
|
|
118
|
+
return new Promise((resolve)=>{
|
|
119
|
+
const command = packageManager;
|
|
120
|
+
// yarn doesn't need 'run' prefix, but it works with it too
|
|
121
|
+
const args = [
|
|
122
|
+
'run',
|
|
123
|
+
scriptName
|
|
124
|
+
];
|
|
125
|
+
log.debug(`Running script: ${command} ${args.join(' ')} in ${projectPath}`);
|
|
126
|
+
let stderr = '';
|
|
127
|
+
const child = spawn(command, args, {
|
|
128
|
+
cwd: projectPath,
|
|
129
|
+
stdio: 'pipe'
|
|
130
|
+
});
|
|
131
|
+
if (child.stderr) {
|
|
132
|
+
child.stderr.on('data', (data)=>{
|
|
133
|
+
stderr += data.toString();
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
child.on('error', (error)=>{
|
|
137
|
+
log.debug(`Failed to run script ${scriptName}: ${error.message}`);
|
|
138
|
+
resolve(false);
|
|
139
|
+
});
|
|
140
|
+
child.on('close', (code)=>{
|
|
141
|
+
if (code === 0) {
|
|
142
|
+
log.debug(`Successfully ran script: ${scriptName}`);
|
|
143
|
+
resolve(true);
|
|
144
|
+
} else {
|
|
145
|
+
log.debug(`Script ${scriptName} failed (exit code: ${code})`);
|
|
146
|
+
if (stderr) {
|
|
147
|
+
log.debug(`stderr: ${stderr}`);
|
|
148
|
+
}
|
|
149
|
+
resolve(false);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
96
154
|
|
|
97
155
|
//# sourceMappingURL=payload-package-check.js.map
|
package/dist/utils/project.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Project detection and scaffolding utilities
|
|
3
3
|
*/
|
|
4
4
|
import type { ProjectInfo } from '../types/config.js';
|
|
5
|
+
import type { PackageManager } from './package-manager.js';
|
|
5
6
|
/**
|
|
6
7
|
* Detect if current directory has a Payload project
|
|
7
8
|
*
|
|
@@ -22,7 +23,7 @@ export declare function validatePayloadVersion(version: string): boolean;
|
|
|
22
23
|
* @param projectPath - Path where to create the project
|
|
23
24
|
* @param projectName - Name for the project
|
|
24
25
|
*/
|
|
25
|
-
export declare function scaffoldProject(projectPath: string, projectName: string): Promise<void>;
|
|
26
|
+
export declare function scaffoldProject(projectPath: string, projectName: string, packageManager?: PackageManager): Promise<void>;
|
|
26
27
|
/**
|
|
27
28
|
* Initialize git repository after all setup is complete
|
|
28
29
|
*
|
|
@@ -38,7 +39,7 @@ export declare function initializeGitRepo(projectPath: string): void;
|
|
|
38
39
|
* @param packageManager - Package manager to use
|
|
39
40
|
* @returns Promise that resolves when installation completes
|
|
40
41
|
*/
|
|
41
|
-
export declare function installDependencies(projectPath: string, packageManager?:
|
|
42
|
+
export declare function installDependencies(projectPath: string, packageManager?: PackageManager): Promise<void>;
|
|
42
43
|
/**
|
|
43
44
|
* Check if required dependencies are installed
|
|
44
45
|
*
|