@payloadcms/figma 0.0.1-alpha.1 → 0.0.1-alpha.11
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.map +1 -1
- package/dist/api/control-plane.js +11 -16
- package/dist/api/control-plane.js.map +1 -1
- package/dist/api/figma-api.js +3 -3
- package/dist/api/figma-api.js.map +1 -1
- package/dist/auth/jwt-validator.js.map +1 -1
- package/dist/auth/oauth-flow.d.ts.map +1 -1
- package/dist/auth/oauth-flow.js +3 -6
- package/dist/auth/oauth-flow.js.map +1 -1
- package/dist/auth/project-token.d.ts.map +1 -1
- package/dist/auth/project-token.js +1 -4
- package/dist/auth/project-token.js.map +1 -1
- package/dist/auth/refresh.d.ts.map +1 -1
- package/dist/auth/refresh.js +19 -28
- package/dist/auth/refresh.js.map +1 -1
- package/dist/auth/types.d.ts +1 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/cli.js +1 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +17 -10
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +21 -85
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list-tokens.d.ts +1 -1
- package/dist/commands/list-tokens.d.ts.map +1 -1
- package/dist/commands/list-tokens.js +6 -5
- package/dist/commands/list-tokens.js.map +1 -1
- package/dist/commands/login.d.ts +2 -11
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +4 -7
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts +1 -1
- package/dist/commands/logout.js +1 -1
- package/dist/commands/logout.js.map +1 -1
- package/dist/db-adapter.d.ts +17 -0
- package/dist/db-adapter.d.ts.map +1 -0
- package/dist/db-adapter.js +757 -0
- package/dist/db-adapter.js.map +1 -0
- package/dist/endpoints/health.d.ts +3 -0
- package/dist/endpoints/health.d.ts.map +1 -0
- package/dist/endpoints/health.js +11 -0
- package/dist/endpoints/health.js.map +1 -0
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +4 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/oauth/components/LoginButton/index.d.ts +9 -0
- package/dist/oauth/components/LoginButton/index.d.ts.map +1 -0
- package/dist/oauth/components/LoginButton/index.js +52 -0
- package/dist/oauth/components/LoginButton/index.js.map +1 -0
- package/dist/oauth/components/LoginButton/index.scss +10 -0
- package/dist/oauth/components/LogoutButton/index.d.ts +7 -0
- package/dist/oauth/components/LogoutButton/index.d.ts.map +1 -0
- package/dist/oauth/components/LogoutButton/index.js +67 -0
- package/dist/oauth/components/LogoutButton/index.js.map +1 -0
- package/dist/oauth/components/LogoutButton/index.scss +10 -0
- package/dist/oauth/defaults.d.ts +10 -0
- package/dist/oauth/defaults.d.ts.map +1 -0
- package/dist/oauth/defaults.js +91 -0
- package/dist/oauth/defaults.js.map +1 -0
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts +13 -0
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -0
- package/dist/oauth/endpoints/getLoginEndpoint.js +237 -0
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -0
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +12 -0
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +1 -0
- package/dist/oauth/endpoints/getLogoutEndpoint.js +99 -0
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +1 -0
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts +13 -0
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +1 -0
- package/dist/oauth/endpoints/getMetaEndpoint.js +25 -0
- package/dist/oauth/endpoints/getMetaEndpoint.js.map +1 -0
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +13 -0
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +1 -0
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +21 -0
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +1 -0
- package/dist/oauth/exports/client.d.ts +3 -0
- package/dist/oauth/exports/client.d.ts.map +1 -0
- package/dist/oauth/exports/client.js +4 -0
- package/dist/oauth/exports/client.js.map +1 -0
- package/dist/oauth/hooks/afterLogout.d.ts +8 -0
- package/dist/oauth/hooks/afterLogout.d.ts.map +1 -0
- package/dist/oauth/hooks/afterLogout.js +27 -0
- package/dist/oauth/hooks/afterLogout.js.map +1 -0
- package/dist/oauth/hooks/me.d.ts +5 -0
- package/dist/oauth/hooks/me.d.ts.map +1 -0
- package/dist/oauth/hooks/me.js +55 -0
- package/dist/oauth/hooks/me.js.map +1 -0
- package/dist/oauth/hooks/refresh.d.ts +8 -0
- package/dist/oauth/hooks/refresh.d.ts.map +1 -0
- package/dist/oauth/hooks/refresh.js +91 -0
- package/dist/oauth/hooks/refresh.js.map +1 -0
- package/dist/oauth/index.d.ts +4 -0
- package/dist/oauth/index.d.ts.map +1 -0
- package/dist/oauth/index.js +222 -0
- package/dist/oauth/index.js.map +1 -0
- package/dist/oauth/strategy/index.d.ts +54 -0
- package/dist/oauth/strategy/index.d.ts.map +1 -0
- package/dist/oauth/strategy/index.js +280 -0
- package/dist/oauth/strategy/index.js.map +1 -0
- package/dist/oauth/types.d.ts +192 -0
- package/dist/oauth/types.d.ts.map +1 -0
- package/dist/oauth/types.js +3 -0
- package/dist/oauth/types.js.map +1 -0
- package/dist/oauth/utilities/clearCookie.d.ts +9 -0
- package/dist/oauth/utilities/clearCookie.d.ts.map +1 -0
- package/dist/oauth/utilities/clearCookie.js +21 -0
- package/dist/oauth/utilities/clearCookie.js.map +1 -0
- package/dist/oauth/utilities/createCookieOptions.d.ts +10 -0
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +1 -0
- package/dist/oauth/utilities/createCookieOptions.js +42 -0
- package/dist/oauth/utilities/createCookieOptions.js.map +1 -0
- package/dist/oauth/utilities/createDebugLogger.d.ts +4 -0
- package/dist/oauth/utilities/createDebugLogger.d.ts.map +1 -0
- package/dist/oauth/utilities/createDebugLogger.js +16 -0
- package/dist/oauth/utilities/createDebugLogger.js.map +1 -0
- package/dist/oauth/utilities/extractOrigin.d.ts +2 -0
- package/dist/oauth/utilities/extractOrigin.d.ts.map +1 -0
- package/dist/oauth/utilities/extractOrigin.js +12 -0
- package/dist/oauth/utilities/extractOrigin.js.map +1 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +3 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +1 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.js +18 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.js.map +1 -0
- package/dist/oauth/utilities/getAdminPath.d.ts +8 -0
- package/dist/oauth/utilities/getAdminPath.d.ts.map +1 -0
- package/dist/oauth/utilities/getAdminPath.js +9 -0
- package/dist/oauth/utilities/getAdminPath.js.map +1 -0
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +17 -0
- package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +1 -0
- package/dist/oauth/utilities/getAuthorizeURL.js +45 -0
- package/dist/oauth/utilities/getAuthorizeURL.js.map +1 -0
- package/dist/oauth/utilities/getCookieExpiration.d.ts +4 -0
- package/dist/oauth/utilities/getCookieExpiration.d.ts.map +1 -0
- package/dist/oauth/utilities/getCookieExpiration.js +11 -0
- package/dist/oauth/utilities/getCookieExpiration.js.map +1 -0
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +2 -0
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +1 -0
- package/dist/oauth/utilities/getSecondsFromTokenExp.js +7 -0
- package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +1 -0
- package/dist/oauth/utilities/getTokenExp.d.ts +6 -0
- package/dist/oauth/utilities/getTokenExp.d.ts.map +1 -0
- package/dist/oauth/utilities/getTokenExp.js +20 -0
- package/dist/oauth/utilities/getTokenExp.js.map +1 -0
- package/dist/oauth/utilities/getUsernameField.d.ts +9 -0
- package/dist/oauth/utilities/getUsernameField.d.ts.map +1 -0
- package/dist/oauth/utilities/getUsernameField.js +20 -0
- package/dist/oauth/utilities/getUsernameField.js.map +1 -0
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +8 -0
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +1 -0
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js +25 -0
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +1 -0
- package/dist/oauth/utilities/mergeHeaders.d.ts +2 -0
- package/dist/oauth/utilities/mergeHeaders.d.ts.map +1 -0
- package/dist/oauth/utilities/mergeHeaders.js +37 -0
- package/dist/oauth/utilities/mergeHeaders.js.map +1 -0
- package/dist/oauth/utilities/refreshTokens.d.ts +16 -0
- package/dist/oauth/utilities/refreshTokens.d.ts.map +1 -0
- package/dist/oauth/utilities/refreshTokens.js +67 -0
- package/dist/oauth/utilities/refreshTokens.js.map +1 -0
- package/dist/plugin/build-config.d.ts +7 -1
- package/dist/plugin/build-config.d.ts.map +1 -1
- package/dist/plugin/build-config.js +53 -3
- package/dist/plugin/build-config.js.map +1 -1
- package/dist/types/config.d.ts +0 -11
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +1 -1
- package/dist/types/config.js.map +1 -1
- package/dist/utils/config.d.ts +0 -22
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +0 -46
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/messages.js +11 -11
- package/dist/utils/messages.js.map +1 -1
- package/dist/utils/payload-config-ast.d.ts +17 -1
- package/dist/utils/payload-config-ast.d.ts.map +1 -1
- package/dist/utils/payload-config-ast.js +166 -14
- package/dist/utils/payload-config-ast.js.map +1 -1
- package/dist/utils/payload-config-modifier.d.ts +2 -1
- package/dist/utils/payload-config-modifier.d.ts.map +1 -1
- package/dist/utils/payload-config-modifier.js +50 -79
- package/dist/utils/payload-config-modifier.js.map +1 -1
- package/dist/utils/payload-package-check.d.ts.map +1 -1
- package/dist/utils/payload-package-check.js +14 -33
- package/dist/utils/payload-package-check.js.map +1 -1
- package/dist/utils/project.d.ts +1 -1
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +3 -5
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/s3-upload.d.ts.map +1 -1
- package/dist/utils/s3-upload.js +3 -8
- package/dist/utils/s3-upload.js.map +1 -1
- package/dist/utils/token-display.d.ts.map +1 -1
- package/dist/utils/token-display.js +3 -2
- package/dist/utils/token-display.js.map +1 -1
- package/package.json +9 -3
- package/dist/api/control-plane.spec.d.ts +0 -2
- package/dist/api/control-plane.spec.d.ts.map +0 -1
- package/dist/api/control-plane.spec.js +0 -296
- package/dist/api/control-plane.spec.js.map +0 -1
- package/dist/api/figma-api.spec.d.ts +0 -14
- package/dist/api/figma-api.spec.d.ts.map +0 -1
- package/dist/api/figma-api.spec.js +0 -201
- package/dist/api/figma-api.spec.js.map +0 -1
- package/dist/auth/__tests__/fixtures.d.ts +0 -26
- package/dist/auth/__tests__/fixtures.d.ts.map +0 -1
- package/dist/auth/__tests__/fixtures.js +0 -67
- package/dist/auth/__tests__/fixtures.js.map +0 -1
- package/dist/auth/__tests__/mocks.d.ts +0 -33
- package/dist/auth/__tests__/mocks.d.ts.map +0 -1
- package/dist/auth/__tests__/mocks.js +0 -63
- package/dist/auth/__tests__/mocks.js.map +0 -1
- package/dist/auth/callback-server.spec.d.ts +0 -2
- package/dist/auth/callback-server.spec.d.ts.map +0 -1
- package/dist/auth/callback-server.spec.js +0 -85
- package/dist/auth/callback-server.spec.js.map +0 -1
- package/dist/auth/crypto-utils.spec.d.ts +0 -2
- package/dist/auth/crypto-utils.spec.d.ts.map +0 -1
- package/dist/auth/crypto-utils.spec.js +0 -36
- package/dist/auth/crypto-utils.spec.js.map +0 -1
- package/dist/auth/jwt-validator.spec.d.ts +0 -10
- package/dist/auth/jwt-validator.spec.d.ts.map +0 -1
- package/dist/auth/jwt-validator.spec.js +0 -236
- package/dist/auth/jwt-validator.spec.js.map +0 -1
- package/dist/auth/oauth-flow.spec.d.ts +0 -2
- package/dist/auth/oauth-flow.spec.d.ts.map +0 -1
- package/dist/auth/oauth-flow.spec.js +0 -134
- package/dist/auth/oauth-flow.spec.js.map +0 -1
- package/dist/auth/pkce.spec.d.ts +0 -2
- package/dist/auth/pkce.spec.d.ts.map +0 -1
- package/dist/auth/pkce.spec.js +0 -32
- package/dist/auth/pkce.spec.js.map +0 -1
- package/dist/auth/project-token.spec.d.ts +0 -2
- package/dist/auth/project-token.spec.d.ts.map +0 -1
- package/dist/auth/project-token.spec.js +0 -332
- package/dist/auth/project-token.spec.js.map +0 -1
- package/dist/auth/refresh.spec.d.ts +0 -2
- package/dist/auth/refresh.spec.d.ts.map +0 -1
- package/dist/auth/refresh.spec.js +0 -105
- package/dist/auth/refresh.spec.js.map +0 -1
- package/dist/auth/token-store.spec.d.ts +0 -2
- package/dist/auth/token-store.spec.d.ts.map +0 -1
- package/dist/auth/token-store.spec.js +0 -276
- package/dist/auth/token-store.spec.js.map +0 -1
- package/dist/commands/__tests__/test-utils.d.ts +0 -28
- package/dist/commands/__tests__/test-utils.d.ts.map +0 -1
- package/dist/commands/__tests__/test-utils.js +0 -34
- package/dist/commands/__tests__/test-utils.js.map +0 -1
- package/dist/commands/deploy.spec.d.ts +0 -2
- package/dist/commands/deploy.spec.d.ts.map +0 -1
- package/dist/commands/deploy.spec.js +0 -18
- package/dist/commands/deploy.spec.js.map +0 -1
- package/dist/commands/init.spec.d.ts +0 -2
- package/dist/commands/init.spec.d.ts.map +0 -1
- package/dist/commands/init.spec.js +0 -283
- package/dist/commands/init.spec.js.map +0 -1
- package/dist/plugin/build-config.spec.d.ts +0 -2
- package/dist/plugin/build-config.spec.d.ts.map +0 -1
- package/dist/plugin/build-config.spec.js +0 -72
- package/dist/plugin/build-config.spec.js.map +0 -1
- package/dist/utils/asset-collection.spec.d.ts +0 -2
- package/dist/utils/asset-collection.spec.d.ts.map +0 -1
- package/dist/utils/asset-collection.spec.js +0 -155
- package/dist/utils/asset-collection.spec.js.map +0 -1
- package/dist/utils/build-detection.spec.d.ts +0 -2
- package/dist/utils/build-detection.spec.d.ts.map +0 -1
- package/dist/utils/build-detection.spec.js +0 -110
- package/dist/utils/build-detection.spec.js.map +0 -1
- package/dist/utils/config.spec.d.ts +0 -2
- package/dist/utils/config.spec.d.ts.map +0 -1
- package/dist/utils/config.spec.js +0 -167
- package/dist/utils/config.spec.js.map +0 -1
- package/dist/utils/download-template.spec.d.ts +0 -2
- package/dist/utils/download-template.spec.d.ts.map +0 -1
- package/dist/utils/download-template.spec.js +0 -76
- package/dist/utils/download-template.spec.js.map +0 -1
- package/dist/utils/env-management.spec.d.ts +0 -2
- package/dist/utils/env-management.spec.d.ts.map +0 -1
- package/dist/utils/env-management.spec.js +0 -123
- package/dist/utils/env-management.spec.js.map +0 -1
- package/dist/utils/git.spec.d.ts +0 -2
- package/dist/utils/git.spec.d.ts.map +0 -1
- package/dist/utils/git.spec.js +0 -99
- package/dist/utils/git.spec.js.map +0 -1
- package/dist/utils/lambda-config.spec.d.ts +0 -2
- package/dist/utils/lambda-config.spec.d.ts.map +0 -1
- package/dist/utils/lambda-config.spec.js +0 -141
- package/dist/utils/lambda-config.spec.js.map +0 -1
- package/dist/utils/payload-config-ast.spec.d.ts +0 -2
- package/dist/utils/payload-config-ast.spec.d.ts.map +0 -1
- package/dist/utils/payload-config-ast.spec.js +0 -303
- package/dist/utils/payload-config-ast.spec.js.map +0 -1
- package/dist/utils/payload-config-modifier.int.spec.d.ts +0 -2
- package/dist/utils/payload-config-modifier.int.spec.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.int.spec.js +0 -116
- package/dist/utils/payload-config-modifier.int.spec.js.map +0 -1
- package/dist/utils/payload-config-modifier.spec.d.ts +0 -2
- package/dist/utils/payload-config-modifier.spec.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.spec.js +0 -162
- package/dist/utils/payload-config-modifier.spec.js.map +0 -1
- package/dist/utils/payload-package-check.spec.d.ts +0 -2
- package/dist/utils/payload-package-check.spec.d.ts.map +0 -1
- package/dist/utils/payload-package-check.spec.js +0 -148
- package/dist/utils/payload-package-check.spec.js.map +0 -1
- package/dist/utils/project.spec.d.ts +0 -2
- package/dist/utils/project.spec.d.ts.map +0 -1
- package/dist/utils/project.spec.js +0 -222
- package/dist/utils/project.spec.js.map +0 -1
- package/dist/utils/s3-upload.spec.d.ts +0 -2
- package/dist/utils/s3-upload.spec.d.ts.map +0 -1
- package/dist/utils/s3-upload.spec.js +0 -140
- package/dist/utils/s3-upload.spec.js.map +0 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
2
2
|
import { buildConfig as payloadBuildConfig } from 'payload';
|
|
3
|
-
import {
|
|
3
|
+
import { getValidProjectToken } from '../auth/project-token.js';
|
|
4
|
+
import { TokenStore } from '../auth/token-store.js';
|
|
5
|
+
import { contentAPIAdapter } from '../db-adapter.js';
|
|
6
|
+
import { health } from '../endpoints/health.js';
|
|
7
|
+
import { oAuth2Plugin } from '../oauth/index.js';
|
|
4
8
|
/**
|
|
5
9
|
* Figma platform wrapper for Payload's buildConfig.
|
|
6
10
|
* Automatically injects:
|
|
@@ -11,12 +15,58 @@ import { figmaContentSystem } from './adapter.js';
|
|
|
11
15
|
* @param config - Payload configuration (db and secret omitted, editor optional)
|
|
12
16
|
* @returns Promise<SanitizedConfig> - Built Payload configuration
|
|
13
17
|
*/ export async function buildConfig(config) {
|
|
18
|
+
let projectToken = '';
|
|
19
|
+
if (!process.env.FIGMA_CONTENT_API_ACCESS_KEY) {
|
|
20
|
+
const retrievedToken = await getValidProjectToken(new TokenStore(), config.figma.tenantId);
|
|
21
|
+
if (retrievedToken) {
|
|
22
|
+
projectToken = retrievedToken;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
14
25
|
// Build complete config with Figma platform defaults
|
|
15
26
|
const configWithFigmaDefaults = {
|
|
16
27
|
...config,
|
|
17
|
-
|
|
28
|
+
custom: {
|
|
29
|
+
figma: config.figma || {}
|
|
30
|
+
},
|
|
31
|
+
// TODO: - cms-tenants-001-staging needs to be dynamic in the future
|
|
32
|
+
db: config.figma.useContentSystem !== false ? contentAPIAdapter({
|
|
33
|
+
contentApiKey: process.env.FIGMA_CONTENT_API_ACCESS_KEY,
|
|
34
|
+
contentApiUrl: process.env.FIGMA_CONTENT_API_URL || `https://${config.figma.region}.cms-tenants-001-staging.figmacontentstaging.com`,
|
|
35
|
+
contentSystemId: config.figma.tenantId,
|
|
36
|
+
projectToken
|
|
37
|
+
}) : config.db,
|
|
18
38
|
editor: config.editor ?? lexicalEditor(),
|
|
19
|
-
|
|
39
|
+
endpoints: [
|
|
40
|
+
...config.endpoints ?? [],
|
|
41
|
+
health
|
|
42
|
+
],
|
|
43
|
+
secret: 'MY_SECRET',
|
|
44
|
+
// Add oauth to plugins if not already present
|
|
45
|
+
plugins: [
|
|
46
|
+
...config.plugins ?? [],
|
|
47
|
+
oAuth2Plugin({
|
|
48
|
+
collections: [
|
|
49
|
+
{
|
|
50
|
+
slug: 'users',
|
|
51
|
+
// Use adapter because Figma app doesn't support OIDC scopes
|
|
52
|
+
authorizationURLParams: {
|
|
53
|
+
response_mode: 'query',
|
|
54
|
+
response_type: 'code'
|
|
55
|
+
},
|
|
56
|
+
clientID: process.env.FIGMA_OAUTH_CLIENT_ID,
|
|
57
|
+
clientSecret: process.env.FIGMA_OAUTH_CLIENT_SECRET,
|
|
58
|
+
identityMetadata: 'https://staging.figma.com/.well-known/openid-configuration',
|
|
59
|
+
scope: [
|
|
60
|
+
'current_user:read'
|
|
61
|
+
],
|
|
62
|
+
token: 'id_token',
|
|
63
|
+
usernameField: 'email'
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
debug: !!process.env.DEBUG,
|
|
67
|
+
disabled: false
|
|
68
|
+
})
|
|
69
|
+
]
|
|
20
70
|
};
|
|
21
71
|
// Delegate to Payload's buildConfig
|
|
22
72
|
return await payloadBuildConfig(configWithFigmaDefaults);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin/build-config.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload'\n\nimport { lexicalEditor } from '@payloadcms/richtext-lexical'\nimport { buildConfig as payloadBuildConfig } from 'payload'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/plugin/build-config.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload'\n\nimport { lexicalEditor } from '@payloadcms/richtext-lexical'\nimport { buildConfig as payloadBuildConfig } from 'payload'\n\nimport { getValidProjectToken } from '../auth/project-token.js'\nimport { TokenStore } from '../auth/token-store.js'\nimport { contentAPIAdapter } from '../db-adapter.js'\nimport { health } from '../endpoints/health.js'\nimport { oAuth2Plugin } from '../oauth/index.js'\n\n/**\n * Configuration type for Payload projects on the Figma platform.\n *\n * Differences from standard Payload Config:\n * - `db`: Omitted (auto-injected by Figma platform)\n * - `secret`: Omitted (auto-injected by Figma platform)\n * - `editor`: Optional (defaults to lexicalEditor() if not provided)\n *\n * @example\n * // Minimal config\n * const config: FigmaConfig = {\n * collections: [...]\n * }\n *\n * @example\n * // With custom editor\n * const config: FigmaConfig = {\n * collections: [...],\n * editor: lexicalEditor({ features: [...] })\n * }\n */\nexport type FigmaConfig = {\n editor?: Config['editor']\n} & {\n figma: {\n region: string\n tenantId: string\n useContentSystem?: boolean\n }\n} & Omit<Config, 'db' | 'editor' | 'secret'> &\n Partial<Pick<Config, 'db'>>\n\n/**\n * Figma platform wrapper for Payload's buildConfig.\n * Automatically injects:\n * - Figma database adapter\n * - Secret (platform-provided)\n * - Default lexicalEditor (if no custom editor specified)\n *\n * @param config - Payload configuration (db and secret omitted, editor optional)\n * @returns Promise<SanitizedConfig> - Built Payload configuration\n */\nexport async function buildConfig(config: FigmaConfig): Promise<SanitizedConfig> {\n let projectToken = ''\n\n if (!process.env.FIGMA_CONTENT_API_ACCESS_KEY) {\n const retrievedToken = await getValidProjectToken(new TokenStore(), config.figma.tenantId)\n if (retrievedToken) {\n projectToken = retrievedToken\n }\n }\n\n // Build complete config with Figma platform defaults\n const configWithFigmaDefaults: Config = {\n ...config,\n custom: {\n figma: config.figma || {},\n },\n // TODO: - cms-tenants-001-staging needs to be dynamic in the future\n db:\n config.figma.useContentSystem !== false\n ? contentAPIAdapter({\n contentApiKey: process.env.FIGMA_CONTENT_API_ACCESS_KEY!,\n contentApiUrl:\n process.env.FIGMA_CONTENT_API_URL ||\n `https://${config.figma.region}.cms-tenants-001-staging.figmacontentstaging.com`,\n contentSystemId: config.figma.tenantId,\n projectToken,\n })\n : config.db!,\n editor: config.editor ?? lexicalEditor(),\n endpoints: [...(config.endpoints ?? []), health],\n secret: 'MY_SECRET',\n // Add oauth to plugins if not already present\n plugins: [\n ...(config.plugins ?? []),\n oAuth2Plugin({\n collections: [\n {\n slug: 'users',\n // Use adapter because Figma app doesn't support OIDC scopes\n authorizationURLParams: {\n response_mode: 'query',\n response_type: 'code',\n },\n clientID: process.env.FIGMA_OAUTH_CLIENT_ID!,\n clientSecret: process.env.FIGMA_OAUTH_CLIENT_SECRET,\n identityMetadata: 'https://staging.figma.com/.well-known/openid-configuration',\n scope: ['current_user:read'],\n token: 'id_token', // Adapter creates JWT id_token from Figma user info\n usernameField: 'email',\n },\n ],\n debug: !!process.env.DEBUG,\n disabled: false,\n }),\n ],\n }\n\n // Delegate to Payload's buildConfig\n return await payloadBuildConfig(configWithFigmaDefaults)\n}\n"],"names":["lexicalEditor","buildConfig","payloadBuildConfig","getValidProjectToken","TokenStore","contentAPIAdapter","health","oAuth2Plugin","config","projectToken","process","env","FIGMA_CONTENT_API_ACCESS_KEY","retrievedToken","figma","tenantId","configWithFigmaDefaults","custom","db","useContentSystem","contentApiKey","contentApiUrl","FIGMA_CONTENT_API_URL","region","contentSystemId","editor","endpoints","secret","plugins","collections","slug","authorizationURLParams","response_mode","response_type","clientID","FIGMA_OAUTH_CLIENT_ID","clientSecret","FIGMA_OAUTH_CLIENT_SECRET","identityMetadata","scope","token","usernameField","debug","DEBUG","disabled"],"mappings":"AAEA,SAASA,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,eAAeC,kBAAkB,QAAQ,UAAS;AAE3D,SAASC,oBAAoB,QAAQ,2BAA0B;AAC/D,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,iBAAiB,QAAQ,mBAAkB;AACpD,SAASC,MAAM,QAAQ,yBAAwB;AAC/C,SAASC,YAAY,QAAQ,oBAAmB;AAkChD;;;;;;;;;CASC,GACD,OAAO,eAAeN,YAAYO,MAAmB;IACnD,IAAIC,eAAe;IAEnB,IAAI,CAACC,QAAQC,GAAG,CAACC,4BAA4B,EAAE;QAC7C,MAAMC,iBAAiB,MAAMV,qBAAqB,IAAIC,cAAcI,OAAOM,KAAK,CAACC,QAAQ;QACzF,IAAIF,gBAAgB;YAClBJ,eAAeI;QACjB;IACF;IAEA,qDAAqD;IACrD,MAAMG,0BAAkC;QACtC,GAAGR,MAAM;QACTS,QAAQ;YACNH,OAAON,OAAOM,KAAK,IAAI,CAAC;QAC1B;QACA,oEAAoE;QACpEI,IACEV,OAAOM,KAAK,CAACK,gBAAgB,KAAK,QAC9Bd,kBAAkB;YAChBe,eAAeV,QAAQC,GAAG,CAACC,4BAA4B;YACvDS,eACEX,QAAQC,GAAG,CAACW,qBAAqB,IACjC,CAAC,QAAQ,EAAEd,OAAOM,KAAK,CAACS,MAAM,CAAC,gDAAgD,CAAC;YAClFC,iBAAiBhB,OAAOM,KAAK,CAACC,QAAQ;YACtCN;QACF,KACAD,OAAOU,EAAE;QACfO,QAAQjB,OAAOiB,MAAM,IAAIzB;QACzB0B,WAAW;eAAKlB,OAAOkB,SAAS,IAAI,EAAE;YAAGpB;SAAO;QAChDqB,QAAQ;QACR,8CAA8C;QAC9CC,SAAS;eACHpB,OAAOoB,OAAO,IAAI,EAAE;YACxBrB,aAAa;gBACXsB,aAAa;oBACX;wBACEC,MAAM;wBACN,4DAA4D;wBAC5DC,wBAAwB;4BACtBC,eAAe;4BACfC,eAAe;wBACjB;wBACAC,UAAUxB,QAAQC,GAAG,CAACwB,qBAAqB;wBAC3CC,cAAc1B,QAAQC,GAAG,CAAC0B,yBAAyB;wBACnDC,kBAAkB;wBAClBC,OAAO;4BAAC;yBAAoB;wBAC5BC,OAAO;wBACPC,eAAe;oBACjB;iBACD;gBACDC,OAAO,CAAC,CAAChC,QAAQC,GAAG,CAACgC,KAAK;gBAC1BC,UAAU;YACZ;SACD;IACH;IAEA,oCAAoC;IACpC,OAAO,MAAM1C,mBAAmBc;AAClC"}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Figma CMS Configuration Types
|
|
3
3
|
*/
|
|
4
|
-
/**
|
|
5
|
-
* Configuration stored in figma.config.json
|
|
6
|
-
*/
|
|
7
|
-
export interface FigmaConfig {
|
|
8
|
-
/** Domain for the CMS instance */
|
|
9
|
-
domain: string;
|
|
10
|
-
/** Optional custom subdomain */
|
|
11
|
-
subdomain?: string;
|
|
12
|
-
/** Tenant ID from Control Plane */
|
|
13
|
-
tenantId: string;
|
|
14
|
-
}
|
|
15
4
|
/**
|
|
16
5
|
* Tenant instance from Control Plane API
|
|
17
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAA;IACd,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,yCAAyC;IACzC,UAAU,EAAE,KAAK,GAAG,MAAM,GAAG,WAAW,CAAA;IACxC,oBAAoB;IACpB,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,cAAc,CAAA;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,UAAU,EAAE,OAAO,CAAA;IACnB,iDAAiD;IACjD,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;IACxC,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,mCAAmC;IACnC,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB"}
|
package/dist/types/config.js
CHANGED
package/dist/types/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/config.ts"],"sourcesContent":["/**\n * Figma CMS Configuration Types\n */\n\n/**\n *
|
|
1
|
+
{"version":3,"sources":["../../src/types/config.ts"],"sourcesContent":["/**\n * Figma CMS Configuration Types\n */\n\n/**\n * Tenant instance from Control Plane API\n */\nexport interface Tenant {\n /** Creation timestamp */\n createdAt?: string\n /** Domain name (e.g., my-cms.figmacms.com) */\n domain: string\n /** Unique tenant ID */\n id: string\n /** Parent ID */\n parentId: string\n /** Parent type (team, org, workspace) */\n parentType: 'org' | 'team' | 'workspace'\n /** Tenant status */\n status: 'active' | 'inactive' | 'provisioning'\n}\n\n/**\n * Project information from detection\n */\nexport interface ProjectInfo {\n /** Whether Payload is installed */\n hasPayload: boolean\n /** Package manager detected (npm, pnpm, yarn) */\n packageManager?: 'npm' | 'pnpm' | 'yarn'\n /** Project root path */\n path: string\n /** Payload version if installed */\n payloadVersion?: string\n}\n"],"names":[],"mappings":"AAAA;;CAEC,GAED;;CAEC,GAgBD;;CAEC,GACD,WASC"}
|
package/dist/utils/config.d.ts
CHANGED
|
@@ -1,28 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration file management utilities
|
|
3
3
|
*/
|
|
4
|
-
import type { FigmaConfig } from '../types/config.js';
|
|
5
|
-
/**
|
|
6
|
-
* Read figma.config.json from the current directory
|
|
7
|
-
*
|
|
8
|
-
* @param projectPath - Path to project directory (defaults to cwd)
|
|
9
|
-
* @returns Parsed configuration or null if not found
|
|
10
|
-
*/
|
|
11
|
-
export declare function readFigmaConfig(projectPath?: string): Promise<FigmaConfig | null>;
|
|
12
|
-
/**
|
|
13
|
-
* Write figma.config.json to the current directory
|
|
14
|
-
*
|
|
15
|
-
* @param config - Configuration to write
|
|
16
|
-
* @param projectPath - Path to project directory (defaults to cwd)
|
|
17
|
-
*/
|
|
18
|
-
export declare function writeFigmaConfig(config: FigmaConfig, projectPath?: string): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Check if figma.config.json exists
|
|
21
|
-
*
|
|
22
|
-
* @param projectPath - Path to project directory (defaults to cwd)
|
|
23
|
-
* @returns True if config file exists
|
|
24
|
-
*/
|
|
25
|
-
export declare function hasFigmaConfig(projectPath?: string): Promise<boolean>;
|
|
26
4
|
/**
|
|
27
5
|
* Ensure .gitignore exists and optionally add entries
|
|
28
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BhG"}
|
package/dist/utils/config.js
CHANGED
|
@@ -2,53 +2,7 @@
|
|
|
2
2
|
* Configuration file management utilities
|
|
3
3
|
*/ import fs from 'fs/promises';
|
|
4
4
|
import path from 'path';
|
|
5
|
-
const CONFIG_FILENAME = 'figma.config.json';
|
|
6
5
|
const GITIGNORE_FILENAME = '.gitignore';
|
|
7
|
-
/**
|
|
8
|
-
* Read figma.config.json from the current directory
|
|
9
|
-
*
|
|
10
|
-
* @param projectPath - Path to project directory (defaults to cwd)
|
|
11
|
-
* @returns Parsed configuration or null if not found
|
|
12
|
-
*/ export async function readFigmaConfig(projectPath = process.cwd()) {
|
|
13
|
-
const configPath = path.join(projectPath, CONFIG_FILENAME);
|
|
14
|
-
try {
|
|
15
|
-
const content = await fs.readFile(configPath, 'utf-8');
|
|
16
|
-
return JSON.parse(content);
|
|
17
|
-
} catch (error) {
|
|
18
|
-
if (error.code === 'ENOENT') {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
throw new Error(`Failed to read ${CONFIG_FILENAME}: ${error.message}`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Write figma.config.json to the current directory
|
|
26
|
-
*
|
|
27
|
-
* @param config - Configuration to write
|
|
28
|
-
* @param projectPath - Path to project directory (defaults to cwd)
|
|
29
|
-
*/ export async function writeFigmaConfig(config, projectPath = process.cwd()) {
|
|
30
|
-
const configPath = path.join(projectPath, CONFIG_FILENAME);
|
|
31
|
-
try {
|
|
32
|
-
const content = JSON.stringify(config, null, 2);
|
|
33
|
-
await fs.writeFile(configPath, content + '\n', 'utf-8');
|
|
34
|
-
} catch (error) {
|
|
35
|
-
throw new Error(`Failed to write ${CONFIG_FILENAME}: ${error.message}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Check if figma.config.json exists
|
|
40
|
-
*
|
|
41
|
-
* @param projectPath - Path to project directory (defaults to cwd)
|
|
42
|
-
* @returns True if config file exists
|
|
43
|
-
*/ export async function hasFigmaConfig(projectPath = process.cwd()) {
|
|
44
|
-
const configPath = path.join(projectPath, CONFIG_FILENAME);
|
|
45
|
-
try {
|
|
46
|
-
await fs.access(configPath);
|
|
47
|
-
return true;
|
|
48
|
-
} catch {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
6
|
/**
|
|
53
7
|
* Ensure .gitignore exists and optionally add entries
|
|
54
8
|
*
|
package/dist/utils/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/config.ts"],"sourcesContent":["/**\n * Configuration file management utilities\n */\n\nimport fs from 'fs/promises'\nimport path from 'path'\n\
|
|
1
|
+
{"version":3,"sources":["../../src/utils/config.ts"],"sourcesContent":["/**\n * Configuration file management utilities\n */\n\nimport fs from 'fs/promises'\nimport path from 'path'\n\nconst GITIGNORE_FILENAME = '.gitignore'\n\n/**\n * Ensure .gitignore exists and optionally add entries\n *\n * @param projectPath - Path to project directory\n * @param entries - Optional entries to add to .gitignore\n */\nexport async function ensureGitignore(projectPath: string, entries: string[] = []): Promise<void> {\n const gitignorePath = path.join(projectPath, GITIGNORE_FILENAME)\n\n let existingContent = ''\n try {\n existingContent = await fs.readFile(gitignorePath, 'utf-8')\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {\n throw new Error(`Failed to read ${GITIGNORE_FILENAME}: ${(error as Error).message}`)\n }\n }\n\n // Parse existing entries\n const existingLines = existingContent.split('\\n').filter((line) => line.trim())\n const existingSet = new Set(existingLines)\n\n // Add new entries that don't exist\n const newEntries = entries.filter((entry) => !existingSet.has(entry))\n\n if (newEntries.length > 0) {\n const newContent = existingContent\n ? `${existingContent.trimEnd()}\\n\\n# Figma CMS\\n${newEntries.join('\\n')}\\n`\n : `# Figma CMS\\n${newEntries.join('\\n')}\\n`\n\n await fs.writeFile(gitignorePath, newContent, 'utf-8')\n }\n}\n"],"names":["fs","path","GITIGNORE_FILENAME","ensureGitignore","projectPath","entries","gitignorePath","join","existingContent","readFile","error","code","Error","message","existingLines","split","filter","line","trim","existingSet","Set","newEntries","entry","has","length","newContent","trimEnd","writeFile"],"mappings":"AAAA;;CAEC,GAED,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,MAAMC,qBAAqB;AAE3B;;;;;CAKC,GACD,OAAO,eAAeC,gBAAgBC,WAAmB,EAAEC,UAAoB,EAAE;IAC/E,MAAMC,gBAAgBL,KAAKM,IAAI,CAACH,aAAaF;IAE7C,IAAIM,kBAAkB;IACtB,IAAI;QACFA,kBAAkB,MAAMR,GAAGS,QAAQ,CAACH,eAAe;IACrD,EAAE,OAAOI,OAAO;QACd,IAAI,AAACA,MAAgCC,IAAI,KAAK,UAAU;YACtD,MAAM,IAAIC,MAAM,CAAC,eAAe,EAAEV,mBAAmB,EAAE,EAAE,AAACQ,MAAgBG,OAAO,EAAE;QACrF;IACF;IAEA,yBAAyB;IACzB,MAAMC,gBAAgBN,gBAAgBO,KAAK,CAAC,MAAMC,MAAM,CAAC,CAACC,OAASA,KAAKC,IAAI;IAC5E,MAAMC,cAAc,IAAIC,IAAIN;IAE5B,mCAAmC;IACnC,MAAMO,aAAahB,QAAQW,MAAM,CAAC,CAACM,QAAU,CAACH,YAAYI,GAAG,CAACD;IAE9D,IAAID,WAAWG,MAAM,GAAG,GAAG;QACzB,MAAMC,aAAajB,kBACf,GAAGA,gBAAgBkB,OAAO,GAAG,iBAAiB,EAAEL,WAAWd,IAAI,CAAC,MAAM,EAAE,CAAC,GACzE,CAAC,aAAa,EAAEc,WAAWd,IAAI,CAAC,MAAM,EAAE,CAAC;QAE7C,MAAMP,GAAG2B,SAAS,CAACrB,eAAemB,YAAY;IAChD;AACF"}
|
package/dist/utils/messages.js
CHANGED
|
@@ -6,7 +6,7 @@ export function helpMessage() {
|
|
|
6
6
|
console.log(`
|
|
7
7
|
${pc.bold('USAGE')}
|
|
8
8
|
|
|
9
|
-
${pc.dim('payloadcms
|
|
9
|
+
${pc.dim('@payloadcms/figma <command> [options]')}
|
|
10
10
|
|
|
11
11
|
${pc.bold('COMMANDS')}
|
|
12
12
|
|
|
@@ -23,21 +23,21 @@ export function helpMessage() {
|
|
|
23
23
|
|
|
24
24
|
${pc.bold('AUTHENTICATION')}
|
|
25
25
|
|
|
26
|
-
${pc.cyan('payloadcms
|
|
27
|
-
${pc.cyan('payloadcms
|
|
28
|
-
${pc.cyan('payloadcms
|
|
26
|
+
${pc.cyan('@payloadcms/figma login')} Authenticate with Figma
|
|
27
|
+
${pc.cyan('@payloadcms/figma logout')} Clear all tokens (with confirmation)
|
|
28
|
+
${pc.cyan('@payloadcms/figma list-tokens')} Display stored OAuth and project tokens
|
|
29
29
|
|
|
30
30
|
${pc.bold('INIT COMMAND')}
|
|
31
31
|
|
|
32
|
-
${pc.cyan('payloadcms
|
|
33
|
-
${pc.cyan('payloadcms
|
|
34
|
-
${pc.cyan('payloadcms
|
|
35
|
-
${pc.cyan('payloadcms
|
|
36
|
-
${pc.cyan('payloadcms
|
|
32
|
+
${pc.cyan('@payloadcms/figma init --id <cms-id>')} Initialize project with CMS ID
|
|
33
|
+
${pc.cyan('@payloadcms/figma init')} Initialize (prompts for CMS ID)
|
|
34
|
+
${pc.cyan('@payloadcms/figma init --name my-cms')} Specify project name for new projects
|
|
35
|
+
${pc.cyan('@payloadcms/figma init --force')} Force reconfiguration of existing project
|
|
36
|
+
${pc.cyan('@payloadcms/figma init --skip-auth')} Skip authentication (testing only)
|
|
37
37
|
|
|
38
38
|
${pc.bold('DEPLOY COMMAND')}
|
|
39
39
|
|
|
40
|
-
${pc.cyan('payloadcms
|
|
40
|
+
${pc.cyan('@payloadcms/figma deploy')} Deploy your project to Figma
|
|
41
41
|
${pc.dim('--yes, -y')} Skip confirmation prompts
|
|
42
42
|
|
|
43
43
|
${pc.bold('DOCUMENTATION')}
|
|
@@ -86,7 +86,7 @@ ${pc.bold('To continue:')}
|
|
|
86
86
|
|
|
87
87
|
It is recommended to do this from your IDE if your app has existing file references.
|
|
88
88
|
|
|
89
|
-
Once moved, rerun the payloadcms
|
|
89
|
+
Once moved, rerun the @payloadcms/figma command again.
|
|
90
90
|
`;
|
|
91
91
|
}
|
|
92
92
|
export function feedbackOutro() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/messages.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport path from 'path'\nimport pc from 'picocolors'\nimport terminalLink from 'terminal-link'\n\nimport type { PackageManager } from '../types.js'\n\nconst header = (message: string): string => pc.bold(message)\n\nexport function helpMessage(): void {\n console.log(`\n ${pc.bold('USAGE')}\n\n ${pc.dim('payloadcms
|
|
1
|
+
{"version":3,"sources":["../../src/utils/messages.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport path from 'path'\nimport pc from 'picocolors'\nimport terminalLink from 'terminal-link'\n\nimport type { PackageManager } from '../types.js'\n\nconst header = (message: string): string => pc.bold(message)\n\nexport function helpMessage(): void {\n console.log(`\n ${pc.bold('USAGE')}\n\n ${pc.dim('@payloadcms/figma <command> [options]')}\n\n ${pc.bold('COMMANDS')}\n\n ${pc.cyan('login')} Authenticate with Figma OAuth2\n ${pc.cyan('logout')} Clear all stored tokens\n ${pc.cyan('list-tokens')} Show stored token information\n ${pc.cyan('init')} Initialize a Figma CMS project\n ${pc.cyan('deploy')} Deploy your project to Figma\n\n ${pc.bold('OPTIONS')}\n\n ${pc.dim('-h, --help Show help')}\n ${pc.dim('--debug Enable debug logging')}\n\n ${pc.bold('AUTHENTICATION')}\n\n ${pc.cyan('@payloadcms/figma login')} Authenticate with Figma\n ${pc.cyan('@payloadcms/figma logout')} Clear all tokens (with confirmation)\n ${pc.cyan('@payloadcms/figma list-tokens')} Display stored OAuth and project tokens\n\n ${pc.bold('INIT COMMAND')}\n\n ${pc.cyan('@payloadcms/figma init --id <cms-id>')} Initialize project with CMS ID\n ${pc.cyan('@payloadcms/figma init')} Initialize (prompts for CMS ID)\n ${pc.cyan('@payloadcms/figma init --name my-cms')} Specify project name for new projects\n ${pc.cyan('@payloadcms/figma init --force')} Force reconfiguration of existing project\n ${pc.cyan('@payloadcms/figma init --skip-auth')} Skip authentication (testing only)\n\n ${pc.bold('DEPLOY COMMAND')}\n\n ${pc.cyan('@payloadcms/figma deploy')} Deploy your project to Figma\n ${pc.dim('--yes, -y')} Skip confirmation prompts\n\n ${pc.bold('DOCUMENTATION')}\n\n ${createTerminalLink('Getting Started', 'https://payloadcms.com/docs/getting-started/what-is-payload')}\n ${createTerminalLink('Figma CMS Docs', 'https://www.figma.com/developers/api')}\n`)\n}\n\n// Create terminalLink with fallback for unsupported terminals\nfunction createTerminalLink(text: string, url: string) {\n return terminalLink(text, url, {\n fallback: (text, url) => `${text}: ${url}`,\n })\n}\n\nexport function successMessage(projectDir: string, packageManager: PackageManager): string {\n const relativePath = path.relative(process.cwd(), projectDir)\n return `\n${header('Launch Application:')}\n\n - cd ./${relativePath}\n - ${packageManager === 'npm' ? 'npm run' : packageManager} dev or follow directions in README.md\n\n${header('Documentation:')}\n\n - ${createTerminalLink(\n 'Getting Started',\n 'https://payloadcms.com/docs/getting-started/what-is-payload',\n )}\n - ${createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview')}\n\n`\n}\n\nexport function successfulNextInit(): string {\n return `- ${createTerminalLink(\n 'Getting Started',\n 'https://payloadcms.com/docs/getting-started/what-is-payload',\n )}\n- ${createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview')}\n`\n}\n\nexport function moveMessage(args: { nextAppDir: string; projectDir: string }): string {\n const relativeAppDir = path.relative(process.cwd(), args.nextAppDir)\n return `\n${header('Next Steps:')}\n\nPayload does not support a top-level layout.tsx file in the app directory.\n\n${pc.bold('To continue:')}\n\n- Create a new directory in ./${relativeAppDir} such as ./${relativeAppDir}/${pc.bold('(app)')}\n- Move all files from ./${relativeAppDir} into that directory\n\nIt is recommended to do this from your IDE if your app has existing file references.\n\nOnce moved, rerun the @payloadcms/figma command again.\n`\n}\n\nexport function feedbackOutro(): string {\n return `${pc.bgCyan(pc.black(' Have feedback? '))} Visit us on ${createTerminalLink('GitHub', 'https://github.com/payloadcms/payload')}.`\n}\n"],"names":["path","pc","terminalLink","header","message","bold","helpMessage","console","log","dim","cyan","createTerminalLink","text","url","fallback","successMessage","projectDir","packageManager","relativePath","relative","process","cwd","successfulNextInit","moveMessage","args","relativeAppDir","nextAppDir","feedbackOutro","bgCyan","black"],"mappings":"AAAA,6BAA6B,GAC7B,OAAOA,UAAU,OAAM;AACvB,OAAOC,QAAQ,aAAY;AAC3B,OAAOC,kBAAkB,gBAAe;AAIxC,MAAMC,SAAS,CAACC,UAA4BH,GAAGI,IAAI,CAACD;AAEpD,OAAO,SAASE;IACdC,QAAQC,GAAG,CAAC,CAAC;EACb,EAAEP,GAAGI,IAAI,CAAC,SAAS;;MAEf,EAAEJ,GAAGQ,GAAG,CAAC,yCAAyC;;EAEtD,EAAER,GAAGI,IAAI,CAAC,YAAY;;MAElB,EAAEJ,GAAGS,IAAI,CAAC,SAAS;MACnB,EAAET,GAAGS,IAAI,CAAC,UAAU;MACpB,EAAET,GAAGS,IAAI,CAAC,eAAe;MACzB,EAAET,GAAGS,IAAI,CAAC,QAAQ;MAClB,EAAET,GAAGS,IAAI,CAAC,UAAU;;EAExB,EAAET,GAAGI,IAAI,CAAC,WAAW;;MAEjB,EAAEJ,GAAGQ,GAAG,CAAC,iCAAiC;MAC1C,EAAER,GAAGQ,GAAG,CAAC,4CAA4C;;EAEzD,EAAER,GAAGI,IAAI,CAAC,kBAAkB;;MAExB,EAAEJ,GAAGS,IAAI,CAAC,2BAA2B;MACrC,EAAET,GAAGS,IAAI,CAAC,4BAA4B;MACtC,EAAET,GAAGS,IAAI,CAAC,iCAAiC;;EAE/C,EAAET,GAAGI,IAAI,CAAC,gBAAgB;;MAEtB,EAAEJ,GAAGS,IAAI,CAAC,wCAAwC;MAClD,EAAET,GAAGS,IAAI,CAAC,0BAA0B;MACpC,EAAET,GAAGS,IAAI,CAAC,wCAAwC;MAClD,EAAET,GAAGS,IAAI,CAAC,kCAAkC;MAC5C,EAAET,GAAGS,IAAI,CAAC,sCAAsC;;EAEpD,EAAET,GAAGI,IAAI,CAAC,kBAAkB;;MAExB,EAAEJ,GAAGS,IAAI,CAAC,4BAA4B;MACtC,EAAET,GAAGQ,GAAG,CAAC,aAAa;;EAE1B,EAAER,GAAGI,IAAI,CAAC,iBAAiB;;MAEvB,EAAEM,mBAAmB,mBAAmB,+DAA+D;MACvG,EAAEA,mBAAmB,kBAAkB,wCAAwC;AACrF,CAAC;AACD;AAEA,8DAA8D;AAC9D,SAASA,mBAAmBC,IAAY,EAAEC,GAAW;IACnD,OAAOX,aAAaU,MAAMC,KAAK;QAC7BC,UAAU,CAACF,MAAMC,MAAQ,GAAGD,KAAK,EAAE,EAAEC,KAAK;IAC5C;AACF;AAEA,OAAO,SAASE,eAAeC,UAAkB,EAAEC,cAA8B;IAC/E,MAAMC,eAAelB,KAAKmB,QAAQ,CAACC,QAAQC,GAAG,IAAIL;IAClD,OAAO,CAAC;AACV,EAAEb,OAAO,uBAAuB;;SAEvB,EAAEe,aAAa;IACpB,EAAED,mBAAmB,QAAQ,YAAYA,eAAe;;AAE5D,EAAEd,OAAO,kBAAkB;;IAEvB,EAAEQ,mBACF,mBACA,+DACA;IACA,EAAEA,mBAAmB,iBAAiB,sDAAsD;;AAEhG,CAAC;AACD;AAEA,OAAO,SAASW;IACd,OAAO,CAAC,EAAE,EAAEX,mBACV,mBACA,+DACA;EACF,EAAEA,mBAAmB,iBAAiB,sDAAsD;AAC9F,CAAC;AACD;AAEA,OAAO,SAASY,YAAYC,IAAgD;IAC1E,MAAMC,iBAAiBzB,KAAKmB,QAAQ,CAACC,QAAQC,GAAG,IAAIG,KAAKE,UAAU;IACnE,OAAO,CAAC;AACV,EAAEvB,OAAO,eAAe;;;;AAIxB,EAAEF,GAAGI,IAAI,CAAC,gBAAgB;;8BAEI,EAAEoB,eAAe,WAAW,EAAEA,eAAe,CAAC,EAAExB,GAAGI,IAAI,CAAC,SAAS;wBACvE,EAAEoB,eAAe;;;;;AAKzC,CAAC;AACD;AAEA,OAAO,SAASE;IACd,OAAO,GAAG1B,GAAG2B,MAAM,CAAC3B,GAAG4B,KAAK,CAAC,qBAAqB,aAAa,EAAElB,mBAAmB,UAAU,yCAAyC,CAAC,CAAC;AAC3I"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { SourceFile } from 'ts-morph';
|
|
2
2
|
export type DetectionResult = {
|
|
3
|
-
buildConfigNotFound?: boolean;
|
|
4
3
|
dbProperty?: {
|
|
5
4
|
adapter: string;
|
|
6
5
|
importSource: string;
|
|
@@ -9,7 +8,9 @@ export type DetectionResult = {
|
|
|
9
8
|
importSource: string;
|
|
10
9
|
isDefault: boolean;
|
|
11
10
|
};
|
|
11
|
+
figmaObjectExists: boolean;
|
|
12
12
|
hasAlias: boolean;
|
|
13
|
+
hasBuildConfig?: boolean;
|
|
13
14
|
hasOtherPayloadImports: boolean;
|
|
14
15
|
needsImportChange: boolean;
|
|
15
16
|
secretProperty?: boolean;
|
|
@@ -27,4 +28,19 @@ export type ASTModificationResult = {
|
|
|
27
28
|
* Modifies the AST in memory - caller must call sourceFile.save()
|
|
28
29
|
*/
|
|
29
30
|
export declare function applyModifications(sourceFile: SourceFile, detection: DetectionResult): ASTModificationResult;
|
|
31
|
+
export type FigmaPropertyConfig = {
|
|
32
|
+
region: string;
|
|
33
|
+
tenantId: string;
|
|
34
|
+
useContentSystem: boolean;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Add figma property to buildConfig if it doesn't exist
|
|
38
|
+
* Modifies the AST in memory - caller must call sourceFile.save()
|
|
39
|
+
*/
|
|
40
|
+
export declare function addFigmaProperty(sourceFile: SourceFile, config: FigmaPropertyConfig): ASTModificationResult;
|
|
41
|
+
/**
|
|
42
|
+
* Read figma configuration from payload.config.ts
|
|
43
|
+
* Returns the figma object if it exists, null otherwise
|
|
44
|
+
*/
|
|
45
|
+
export declare function readFigmaConfig(sourceFile: SourceFile): FigmaPropertyConfig | null;
|
|
30
46
|
//# sourceMappingURL=payload-config-ast.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload-config-ast.d.ts","sourceRoot":"","sources":["../../src/utils/payload-config-ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"payload-config-ast.d.ts","sourceRoot":"","sources":["../../src/utils/payload-config-ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAM1C,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE;QACX,OAAO,EAAE,MAAM,CAAA;QACf,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,cAAc,CAAC,EAAE;QACf,YAAY,EAAE,MAAM,CAAA;QACpB,SAAS,EAAE,OAAO,CAAA;KACnB,CAAA;IACD,iBAAiB,EAAE,OAAO,CAAA;IAC1B,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,sBAAsB,EAAE,OAAO,CAAA;IAC/B,iBAAiB,EAAE,OAAO,CAAA;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,eAAe,CAiJ7E;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AA0CD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,eAAe,GACzB,qBAAqB,CAyJvB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,mBAAmB,GAC1B,qBAAqB,CA+CvB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,mBAAmB,GAAG,IAAI,CA0ElF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Node, SyntaxKind } from 'ts-morph';
|
|
2
|
-
import { isDebug } from './is-debug.js';
|
|
3
2
|
import * as log from './log.js';
|
|
4
3
|
/**
|
|
5
4
|
* Detect what changes are needed in the payload config file
|
|
6
5
|
*/ export function detectRequiredChanges(sourceFile) {
|
|
7
6
|
const result = {
|
|
7
|
+
figmaObjectExists: false,
|
|
8
8
|
hasAlias: false,
|
|
9
9
|
hasOtherPayloadImports: false,
|
|
10
10
|
needsImportChange: false
|
|
@@ -13,21 +13,17 @@ import * as log from './log.js';
|
|
|
13
13
|
const imports = sourceFile.getImportDeclarations();
|
|
14
14
|
const payloadImport = imports.find((imp)=>imp.getModuleSpecifierValue() === 'payload' || imp.getModuleSpecifierValue() === '@payloadcms/figma');
|
|
15
15
|
if (!payloadImport) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
result.buildConfigNotFound = true;
|
|
16
|
+
log.debug('No payload or @payloadcms/figma import found');
|
|
17
|
+
result.hasBuildConfig = false;
|
|
20
18
|
return result;
|
|
21
19
|
}
|
|
22
|
-
|
|
23
|
-
log.debug(`Found import from: ${payloadImport.getModuleSpecifierValue()}`);
|
|
24
|
-
}
|
|
20
|
+
log.debug(`Found import from: ${payloadImport.getModuleSpecifierValue()}`);
|
|
25
21
|
const moduleSpecifier = payloadImport.getModuleSpecifierValue();
|
|
26
22
|
const namedImports = payloadImport.getNamedImports();
|
|
27
23
|
// Check if buildConfig is imported
|
|
28
24
|
const buildConfigImport = namedImports.find((ni)=>ni.getName() === 'buildConfig');
|
|
29
25
|
if (!buildConfigImport) {
|
|
30
|
-
result.
|
|
26
|
+
result.hasBuildConfig = false;
|
|
31
27
|
return result;
|
|
32
28
|
}
|
|
33
29
|
// Check for alias and get the actual name used in code
|
|
@@ -65,7 +61,7 @@ import * as log from './log.js';
|
|
|
65
61
|
});
|
|
66
62
|
}
|
|
67
63
|
if (!buildConfigCall) {
|
|
68
|
-
result.
|
|
64
|
+
result.hasBuildConfig = false;
|
|
69
65
|
return result;
|
|
70
66
|
}
|
|
71
67
|
// Get config object
|
|
@@ -113,23 +109,67 @@ import * as log from './log.js';
|
|
|
113
109
|
}
|
|
114
110
|
}
|
|
115
111
|
}
|
|
112
|
+
// Check for figma property
|
|
113
|
+
const figmaProperty = configArg.getProperty('figma');
|
|
114
|
+
if (figmaProperty) {
|
|
115
|
+
result.figmaObjectExists = true;
|
|
116
|
+
}
|
|
116
117
|
return result;
|
|
117
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Remove all comments
|
|
121
|
+
* @returns true if any comments were removed
|
|
122
|
+
*/ function removeAllComments(sourceFile) {
|
|
123
|
+
const ranges = [];
|
|
124
|
+
// Recursively collect comments from node and ALL children (including tokens)
|
|
125
|
+
const collectComments = (node)=>{
|
|
126
|
+
node.getLeadingCommentRanges().forEach((range)=>{
|
|
127
|
+
ranges.push([
|
|
128
|
+
range.getPos(),
|
|
129
|
+
range.getEnd()
|
|
130
|
+
]);
|
|
131
|
+
});
|
|
132
|
+
node.getTrailingCommentRanges().forEach((range)=>{
|
|
133
|
+
ranges.push([
|
|
134
|
+
range.getPos(),
|
|
135
|
+
range.getEnd()
|
|
136
|
+
]);
|
|
137
|
+
});
|
|
138
|
+
// Process ALL children including token nodes (commas, braces, etc.)
|
|
139
|
+
node.getChildren().forEach(collectComments);
|
|
140
|
+
};
|
|
141
|
+
collectComments(sourceFile);
|
|
142
|
+
if (ranges.length === 0) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
// Remove duplicates and sort in reverse order to avoid position shifts
|
|
146
|
+
const uniqueRanges = Array.from(new Set(ranges.map((r)=>JSON.stringify(r)))).map((r)=>JSON.parse(r));
|
|
147
|
+
uniqueRanges.sort((a, b)=>b[0] - a[0]);
|
|
148
|
+
// Remove each comment range
|
|
149
|
+
for (const [pos, end] of uniqueRanges){
|
|
150
|
+
sourceFile.removeText(pos, end);
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
118
154
|
/**
|
|
119
155
|
* Apply modifications to the source file based on detection result
|
|
120
156
|
* Modifies the AST in memory - caller must call sourceFile.save()
|
|
121
157
|
*/ export function applyModifications(sourceFile, detection) {
|
|
122
158
|
const changes = [];
|
|
123
159
|
let modified = false;
|
|
124
|
-
if (detection.
|
|
125
|
-
|
|
126
|
-
log.debug(`Skipping modifications: buildConfigNotFound=${detection.buildConfigNotFound}, hasAlias=${detection.hasAlias}`);
|
|
127
|
-
}
|
|
160
|
+
if (detection.hasBuildConfig === false || detection.hasAlias) {
|
|
161
|
+
log.debug(`Skipping modifications: hasBuildConfig=${detection.hasBuildConfig}, hasAlias=${detection.hasAlias}`);
|
|
128
162
|
return {
|
|
129
163
|
changes: [],
|
|
130
164
|
modified: false
|
|
131
165
|
};
|
|
132
166
|
}
|
|
167
|
+
// 1. Remove all comments FIRST (before AST modifications that might shift positions)
|
|
168
|
+
const hadComments = removeAllComments(sourceFile);
|
|
169
|
+
if (hadComments) {
|
|
170
|
+
changes.push('Removed comments');
|
|
171
|
+
modified = true;
|
|
172
|
+
}
|
|
133
173
|
// Find the import declarations
|
|
134
174
|
const imports = sourceFile.getImportDeclarations();
|
|
135
175
|
const payloadImport = imports.find((imp)=>imp.getModuleSpecifierValue() === 'payload');
|
|
@@ -255,5 +295,117 @@ import * as log from './log.js';
|
|
|
255
295
|
modified
|
|
256
296
|
};
|
|
257
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* Add figma property to buildConfig if it doesn't exist
|
|
300
|
+
* Modifies the AST in memory - caller must call sourceFile.save()
|
|
301
|
+
*/ export function addFigmaProperty(sourceFile, config) {
|
|
302
|
+
const changes = [];
|
|
303
|
+
let modified = false;
|
|
304
|
+
// Find buildConfig call
|
|
305
|
+
const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
|
|
306
|
+
const buildConfigCall = callExpressions.find((ce)=>{
|
|
307
|
+
const expr = ce.getExpression();
|
|
308
|
+
const text = expr.getText();
|
|
309
|
+
return text === 'buildConfig' || text.endsWith('.buildConfig');
|
|
310
|
+
});
|
|
311
|
+
if (!buildConfigCall) {
|
|
312
|
+
log.debug('No buildConfig call found');
|
|
313
|
+
return {
|
|
314
|
+
changes: [],
|
|
315
|
+
modified: false
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
// Get config object argument
|
|
319
|
+
const configArg = buildConfigCall.getArguments()[0];
|
|
320
|
+
if (!configArg || !Node.isObjectLiteralExpression(configArg)) {
|
|
321
|
+
log.debug('buildConfig argument is not an object literal');
|
|
322
|
+
return {
|
|
323
|
+
changes: [],
|
|
324
|
+
modified: false
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
// Check if figma property already exists
|
|
328
|
+
const existingFigmaProperty = configArg.getProperty('figma');
|
|
329
|
+
if (existingFigmaProperty) {
|
|
330
|
+
log.debug('figma property already exists, skipping');
|
|
331
|
+
return {
|
|
332
|
+
changes: [
|
|
333
|
+
'Skipped: figma property already exists'
|
|
334
|
+
],
|
|
335
|
+
modified: false
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
// Add figma property
|
|
339
|
+
configArg.addPropertyAssignment({
|
|
340
|
+
name: 'figma',
|
|
341
|
+
initializer: `{
|
|
342
|
+
region: '${config.region}',
|
|
343
|
+
tenantId: '${config.tenantId}',
|
|
344
|
+
useContentSystem: ${config.useContentSystem},
|
|
345
|
+
}`
|
|
346
|
+
});
|
|
347
|
+
changes.push(`Added figma property (region: ${config.region}, tenantId: ${config.tenantId}, useContentSystem: ${config.useContentSystem})`);
|
|
348
|
+
modified = true;
|
|
349
|
+
return {
|
|
350
|
+
changes,
|
|
351
|
+
modified
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Read figma configuration from payload.config.ts
|
|
356
|
+
* Returns the figma object if it exists, null otherwise
|
|
357
|
+
*/ export function readFigmaConfig(sourceFile) {
|
|
358
|
+
// Find buildConfig call
|
|
359
|
+
const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
|
|
360
|
+
const buildConfigCall = callExpressions.find((ce)=>{
|
|
361
|
+
const expr = ce.getExpression();
|
|
362
|
+
const text = expr.getText();
|
|
363
|
+
return text === 'buildConfig' || text.endsWith('.buildConfig');
|
|
364
|
+
});
|
|
365
|
+
if (!buildConfigCall) {
|
|
366
|
+
log.debug('No buildConfig call found');
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
// Get config object argument
|
|
370
|
+
const configArg = buildConfigCall.getArguments()[0];
|
|
371
|
+
if (!configArg || !Node.isObjectLiteralExpression(configArg)) {
|
|
372
|
+
log.debug('buildConfig argument is not an object literal');
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
// Find figma property
|
|
376
|
+
const figmaProperty = configArg.getProperty('figma');
|
|
377
|
+
if (!figmaProperty || !Node.isPropertyAssignment(figmaProperty)) {
|
|
378
|
+
log.debug('No figma property found in buildConfig');
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
381
|
+
// Get initializer (the object value)
|
|
382
|
+
const initializer = figmaProperty.getInitializer();
|
|
383
|
+
if (!initializer || !Node.isObjectLiteralExpression(initializer)) {
|
|
384
|
+
log.debug('figma property is not an object literal');
|
|
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;
|
|
403
|
+
}
|
|
404
|
+
return {
|
|
405
|
+
region,
|
|
406
|
+
tenantId,
|
|
407
|
+
useContentSystem
|
|
408
|
+
};
|
|
409
|
+
}
|
|
258
410
|
|
|
259
411
|
//# sourceMappingURL=payload-config-ast.js.map
|