@payloadcms/figma 0.0.1-alpha.20 → 0.0.1-alpha.22
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 +2 -3
- package/dist/api/control-plane.js.map +1 -1
- package/dist/auth/project-token.d.ts.map +1 -1
- package/dist/auth/project-token.js +2 -1
- package/dist/auth/project-token.js.map +1 -1
- package/dist/auth/token-store.d.ts +10 -0
- package/dist/auth/token-store.d.ts.map +1 -1
- package/dist/auth/token-store.js +17 -0
- package/dist/auth/token-store.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +7 -30
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/init.d.ts +1 -5
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +28 -17
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list-tokens.js +2 -2
- package/dist/commands/list-tokens.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +2 -2
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +2 -2
- package/dist/commands/logout.js.map +1 -1
- package/dist/db-adapter.d.ts.map +1 -1
- package/dist/db-adapter.js +1 -1
- package/dist/db-adapter.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/oauth/components/LogoutButton/index.d.ts.map +1 -1
- package/dist/oauth/components/LogoutButton/index.js +0 -1
- package/dist/oauth/components/LogoutButton/index.js.map +1 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
- package/dist/oauth/strategy/index.d.ts.map +1 -1
- package/dist/oauth/strategy/index.js.map +1 -1
- package/dist/oauth/types.d.ts +1 -1
- package/dist/oauth/types.d.ts.map +1 -1
- package/dist/oauth/types.js.map +1 -1
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +1 -1
- package/dist/oauth/utilities/createCookieOptions.js.map +1 -1
- package/dist/plugin/build-config.d.ts +18 -2
- package/dist/plugin/build-config.d.ts.map +1 -1
- package/dist/plugin/build-config.js +10 -5
- package/dist/plugin/build-config.js.map +1 -1
- package/dist/utils/env-management.d.ts +4 -11
- package/dist/utils/env-management.d.ts.map +1 -1
- package/dist/utils/env-management.js +46 -79
- package/dist/utils/env-management.js.map +1 -1
- package/dist/utils/messages.d.ts.map +1 -1
- package/dist/utils/messages.js +5 -7
- package/dist/utils/messages.js.map +1 -1
- package/dist/utils/payload-config-ast.d.ts +16 -2
- package/dist/utils/payload-config-ast.d.ts.map +1 -1
- package/dist/utils/payload-config-ast.js +58 -27
- package/dist/utils/payload-config-ast.js.map +1 -1
- package/dist/utils/payload-config-modifier.js +1 -1
- package/dist/utils/payload-config-modifier.js.map +1 -1
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +1 -3
- package/dist/utils/project.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/oauth/utilities/createCookieOptions.ts"],"sourcesContent":["import type { CollectionConfig
|
|
1
|
+
{"version":3,"sources":["../../../src/oauth/utilities/createCookieOptions.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport type { CookieOptions, PluginOptions } from '../types.js'\n\ninterface Args {\n collection: CollectionConfig\n headers: Headers\n pluginOptions: PluginOptions\n}\n\nexport const createCookieOptions = ({\n collection,\n headers,\n pluginOptions,\n}: Args): CookieOptions => {\n let cookieOptions: CookieOptions = {\n domain: undefined,\n httpOnly: true,\n path: '/',\n sameSite: undefined,\n secure: false,\n }\n\n if (typeof collection.auth === 'object' && typeof collection.auth.cookies === 'object') {\n const { domain, sameSite, secure } = collection.auth.cookies\n if (typeof secure === 'boolean') {\n cookieOptions.secure = secure\n }\n if (typeof sameSite === 'string') {\n cookieOptions.sameSite = sameSite as 'Lax'\n }\n if (typeof domain === 'string') {\n cookieOptions.domain = domain\n }\n }\n\n if (typeof collection.auth === 'object' && typeof collection.auth.cookies === 'object') {\n if (collection.auth.cookies.secure) {\n cookieOptions.secure = true\n }\n if (collection.auth.cookies.sameSite) {\n cookieOptions.sameSite =\n typeof collection.auth.cookies.sameSite === 'string'\n ? collection.auth.cookies.sameSite\n : 'Lax'\n }\n if (collection.auth.cookies.domain) {\n cookieOptions.domain = collection.auth.cookies.domain\n }\n }\n\n if (typeof pluginOptions.createCookieOptions === 'function') {\n cookieOptions = pluginOptions.createCookieOptions({\n collection,\n cookieOptions,\n headers,\n })\n }\n\n return cookieOptions\n}\n"],"names":["createCookieOptions","collection","headers","pluginOptions","cookieOptions","domain","undefined","httpOnly","path","sameSite","secure","auth","cookies"],"mappings":"AAUA,OAAO,MAAMA,sBAAsB,CAAC,EAClCC,UAAU,EACVC,OAAO,EACPC,aAAa,EACR;IACL,IAAIC,gBAA+B;QACjCC,QAAQC;QACRC,UAAU;QACVC,MAAM;QACNC,UAAUH;QACVI,QAAQ;IACV;IAEA,IAAI,OAAOT,WAAWU,IAAI,KAAK,YAAY,OAAOV,WAAWU,IAAI,CAACC,OAAO,KAAK,UAAU;QACtF,MAAM,EAAEP,MAAM,EAAEI,QAAQ,EAAEC,MAAM,EAAE,GAAGT,WAAWU,IAAI,CAACC,OAAO;QAC5D,IAAI,OAAOF,WAAW,WAAW;YAC/BN,cAAcM,MAAM,GAAGA;QACzB;QACA,IAAI,OAAOD,aAAa,UAAU;YAChCL,cAAcK,QAAQ,GAAGA;QAC3B;QACA,IAAI,OAAOJ,WAAW,UAAU;YAC9BD,cAAcC,MAAM,GAAGA;QACzB;IACF;IAEA,IAAI,OAAOJ,WAAWU,IAAI,KAAK,YAAY,OAAOV,WAAWU,IAAI,CAACC,OAAO,KAAK,UAAU;QACtF,IAAIX,WAAWU,IAAI,CAACC,OAAO,CAACF,MAAM,EAAE;YAClCN,cAAcM,MAAM,GAAG;QACzB;QACA,IAAIT,WAAWU,IAAI,CAACC,OAAO,CAACH,QAAQ,EAAE;YACpCL,cAAcK,QAAQ,GACpB,OAAOR,WAAWU,IAAI,CAACC,OAAO,CAACH,QAAQ,KAAK,WACxCR,WAAWU,IAAI,CAACC,OAAO,CAACH,QAAQ,GAChC;QACR;QACA,IAAIR,WAAWU,IAAI,CAACC,OAAO,CAACP,MAAM,EAAE;YAClCD,cAAcC,MAAM,GAAGJ,WAAWU,IAAI,CAACC,OAAO,CAACP,MAAM;QACvD;IACF;IAEA,IAAI,OAAOF,cAAcH,mBAAmB,KAAK,YAAY;QAC3DI,gBAAgBD,cAAcH,mBAAmB,CAAC;YAChDC;YACAG;YACAF;QACF;IACF;IAEA,OAAOE;AACT,EAAC"}
|
|
@@ -10,22 +10,38 @@ import type { Config, SanitizedConfig } from 'payload';
|
|
|
10
10
|
* @example
|
|
11
11
|
* // Minimal config
|
|
12
12
|
* const config: FigmaConfig = {
|
|
13
|
+
* figma: {
|
|
14
|
+
* contentSystemId: process.env.FIGMA_CONTENT_SYSTEM_ID!
|
|
15
|
+
* },
|
|
13
16
|
* collections: [...]
|
|
14
17
|
* }
|
|
15
18
|
*
|
|
16
19
|
* @example
|
|
17
20
|
* // With custom editor
|
|
18
21
|
* const config: FigmaConfig = {
|
|
22
|
+
* figma: {
|
|
23
|
+
* contentSystemId: process.env.FIGMA_CONTENT_SYSTEM_ID!
|
|
24
|
+
* },
|
|
19
25
|
* collections: [...],
|
|
20
26
|
* editor: lexicalEditor({ features: [...] })
|
|
21
27
|
* }
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Disable Content System (use custom db)
|
|
31
|
+
* const config: FigmaConfig = {
|
|
32
|
+
* figma: {
|
|
33
|
+
* contentSystemId: process.env.FIGMA_CONTENT_SYSTEM_ID!,
|
|
34
|
+
* useContentSystem: false
|
|
35
|
+
* },
|
|
36
|
+
* db: mongooseAdapter({ url: process.env.DATABASE_URI }),
|
|
37
|
+
* collections: [...]
|
|
38
|
+
* }
|
|
22
39
|
*/
|
|
23
40
|
export type FigmaConfig = {
|
|
24
41
|
editor?: Config['editor'];
|
|
25
42
|
} & {
|
|
26
43
|
figma: {
|
|
27
44
|
contentSystemId: string;
|
|
28
|
-
region: string;
|
|
29
45
|
useContentSystem?: boolean;
|
|
30
46
|
};
|
|
31
47
|
} & Omit<Config, 'db' | 'editor' | 'secret'> & Partial<Pick<Config, 'db'>>;
|
|
@@ -39,5 +55,5 @@ export type FigmaConfig = {
|
|
|
39
55
|
* @param config - Payload configuration (db and secret omitted, editor optional)
|
|
40
56
|
* @returns Promise<SanitizedConfig> - Built Payload configuration
|
|
41
57
|
*/
|
|
42
|
-
export declare function
|
|
58
|
+
export declare function buildFigmaConfig(config: FigmaConfig): Promise<SanitizedConfig>;
|
|
43
59
|
//# sourceMappingURL=build-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-config.d.ts","sourceRoot":"","sources":["../../src/plugin/build-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAWtD
|
|
1
|
+
{"version":3,"file":"build-config.d.ts","sourceRoot":"","sources":["../../src/plugin/build-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAWtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;CAC1B,GAAG;IACF,KAAK,EAAE;QACL,eAAe,EAAE,MAAM,CAAA;QACvB,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAC3B,CAAA;CACF,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,QAAQ,CAAC,GAC1C,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;AAE7B;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAsEpF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
2
2
|
import { buildConfig as payloadBuildConfig } from 'payload';
|
|
3
3
|
import { getValidProjectToken } from '../auth/project-token.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getTokenStore } from '../auth/token-store.js';
|
|
5
5
|
import { contentAPIAdapter } from '../db-adapter.js';
|
|
6
6
|
import { health } from '../endpoints/health.js';
|
|
7
7
|
import { oAuth2Plugin } from '../oauth/index.js';
|
|
@@ -14,11 +14,16 @@ import { oAuth2Plugin } from '../oauth/index.js';
|
|
|
14
14
|
*
|
|
15
15
|
* @param config - Payload configuration (db and secret omitted, editor optional)
|
|
16
16
|
* @returns Promise<SanitizedConfig> - Built Payload configuration
|
|
17
|
-
*/ export async function
|
|
17
|
+
*/ export async function buildFigmaConfig(config) {
|
|
18
|
+
// Validate required environment variable
|
|
19
|
+
if (!config.figma.contentSystemId) {
|
|
20
|
+
throw new Error('FIGMA_CONTENT_SYSTEM_ID is required. ' + 'Ensure your .env file contains: FIGMA_CONTENT_SYSTEM_ID=your-content-system-id');
|
|
21
|
+
}
|
|
22
|
+
const contentSystemId = config.figma.contentSystemId;
|
|
18
23
|
let projectToken = '';
|
|
19
24
|
if (!process.env.FIGMA_CONTENT_API_ACCESS_KEY) {
|
|
20
|
-
const tokenStore =
|
|
21
|
-
const retrievedToken = await getValidProjectToken(tokenStore,
|
|
25
|
+
const tokenStore = getTokenStore();
|
|
26
|
+
const retrievedToken = await getValidProjectToken(tokenStore, contentSystemId);
|
|
22
27
|
if (retrievedToken) {
|
|
23
28
|
projectToken = retrievedToken;
|
|
24
29
|
}
|
|
@@ -32,7 +37,7 @@ import { oAuth2Plugin } from '../oauth/index.js';
|
|
|
32
37
|
// TODO: - cms-tenants-001-staging needs to be dynamic in the future
|
|
33
38
|
db: config.figma.useContentSystem !== false ? contentAPIAdapter({
|
|
34
39
|
contentApiKey: process.env.FIGMA_CONTENT_API_ACCESS_KEY,
|
|
35
|
-
contentApiUrl: process.env.FIGMA_CONTENT_API_URL ||
|
|
40
|
+
contentApiUrl: process.env.FIGMA_CONTENT_API_URL || 'https://us-east-1.cms-tenants-001-staging.figmacontentstaging.com',
|
|
36
41
|
contentSystemId: config.figma.contentSystemId,
|
|
37
42
|
projectToken
|
|
38
43
|
}) : config.db,
|
|
@@ -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 { getValidProjectToken } from '../auth/project-token.js'\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 { getTokenStore } 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 * figma: {\n * contentSystemId: process.env.FIGMA_CONTENT_SYSTEM_ID!\n * },\n * collections: [...]\n * }\n *\n * @example\n * // With custom editor\n * const config: FigmaConfig = {\n * figma: {\n * contentSystemId: process.env.FIGMA_CONTENT_SYSTEM_ID!\n * },\n * collections: [...],\n * editor: lexicalEditor({ features: [...] })\n * }\n *\n * @example\n * // Disable Content System (use custom db)\n * const config: FigmaConfig = {\n * figma: {\n * contentSystemId: process.env.FIGMA_CONTENT_SYSTEM_ID!,\n * useContentSystem: false\n * },\n * db: mongooseAdapter({ url: process.env.DATABASE_URI }),\n * collections: [...]\n * }\n */\nexport type FigmaConfig = {\n editor?: Config['editor']\n} & {\n figma: {\n contentSystemId: 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 buildFigmaConfig(config: FigmaConfig): Promise<SanitizedConfig> {\n // Validate required environment variable\n if (!config.figma.contentSystemId) {\n throw new Error(\n 'FIGMA_CONTENT_SYSTEM_ID is required. ' +\n 'Ensure your .env file contains: FIGMA_CONTENT_SYSTEM_ID=your-content-system-id',\n )\n }\n\n const contentSystemId = config.figma.contentSystemId\n\n let projectToken = ''\n\n if (!process.env.FIGMA_CONTENT_API_ACCESS_KEY) {\n const tokenStore = getTokenStore()\n const retrievedToken = await getValidProjectToken(tokenStore, contentSystemId)\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://us-east-1.cms-tenants-001-staging.figmacontentstaging.com',\n contentSystemId: config.figma.contentSystemId,\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","getTokenStore","contentAPIAdapter","health","oAuth2Plugin","buildFigmaConfig","config","figma","contentSystemId","Error","projectToken","process","env","FIGMA_CONTENT_API_ACCESS_KEY","tokenStore","retrievedToken","configWithFigmaDefaults","custom","db","useContentSystem","contentApiKey","contentApiUrl","FIGMA_CONTENT_API_URL","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,aAAa,QAAQ,yBAAwB;AACtD,SAASC,iBAAiB,QAAQ,mBAAkB;AACpD,SAASC,MAAM,QAAQ,yBAAwB;AAC/C,SAASC,YAAY,QAAQ,oBAAmB;AAkDhD;;;;;;;;;CASC,GACD,OAAO,eAAeC,iBAAiBC,MAAmB;IACxD,yCAAyC;IACzC,IAAI,CAACA,OAAOC,KAAK,CAACC,eAAe,EAAE;QACjC,MAAM,IAAIC,MACR,0CACE;IAEN;IAEA,MAAMD,kBAAkBF,OAAOC,KAAK,CAACC,eAAe;IAEpD,IAAIE,eAAe;IAEnB,IAAI,CAACC,QAAQC,GAAG,CAACC,4BAA4B,EAAE;QAC7C,MAAMC,aAAab;QACnB,MAAMc,iBAAiB,MAAMf,qBAAqBc,YAAYN;QAC9D,IAAIO,gBAAgB;YAClBL,eAAeK;QACjB;IACF;IAEA,qDAAqD;IACrD,MAAMC,0BAAkC;QACtC,GAAGV,MAAM;QACTW,QAAQ;YACNV,OAAOD,OAAOC,KAAK,IAAI,CAAC;QAC1B;QACA,oEAAoE;QACpEW,IACEZ,OAAOC,KAAK,CAACY,gBAAgB,KAAK,QAC9BjB,kBAAkB;YAChBkB,eAAeT,QAAQC,GAAG,CAACC,4BAA4B;YACvDQ,eACEV,QAAQC,GAAG,CAACU,qBAAqB,IACjC;YACFd,iBAAiBF,OAAOC,KAAK,CAACC,eAAe;YAC7CE;QACF,KACAJ,OAAOY,EAAE;QACfK,QAAQjB,OAAOiB,MAAM,IAAI1B;QACzB2B,WAAW;eAAKlB,OAAOkB,SAAS,IAAI,EAAE;YAAGrB;SAAO;QAChDsB,QAAQ;QACR,8CAA8C;QAC9CC,SAAS;eACHpB,OAAOoB,OAAO,IAAI,EAAE;YACxBtB,aAAa;gBACXuB,aAAa;oBACX;wBACEC,MAAM;wBACN,4DAA4D;wBAC5DC,wBAAwB;4BACtBC,eAAe;4BACfC,eAAe;wBACjB;wBACAC,UAAUrB,QAAQC,GAAG,CAACqB,qBAAqB;wBAC3CC,cAAcvB,QAAQC,GAAG,CAACuB,yBAAyB;wBACnDC,kBAAkB;wBAClBC,OAAO;4BAAC;yBAAoB;wBAC5BC,OAAO;wBACPC,eAAe;oBACjB;iBACD;gBACDC,OAAO,CAAC,CAAC7B,QAAQC,GAAG,CAAC6B,KAAK;gBAC1BC,UAAU;YACZ;SACD;IACH;IAEA,oCAAoC;IACpC,OAAO,MAAM3C,mBAAmBiB;AAClC"}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @returns 24-character hexadecimal string
|
|
5
|
-
*/
|
|
6
|
-
export declare function generateSecret(): string;
|
|
7
|
-
/**
|
|
8
|
-
* Manage environment files for a new project
|
|
9
|
-
*
|
|
10
|
-
* Creates .env from .env.example (if exists) and populates PAYLOAD_SECRET
|
|
2
|
+
* Add or update an environment variable in .env file
|
|
11
3
|
*
|
|
12
4
|
* @param projectPath - Path to project directory
|
|
13
|
-
* @
|
|
5
|
+
* @param key - Environment variable name
|
|
6
|
+
* @param value - Environment variable value
|
|
14
7
|
*/
|
|
15
|
-
export declare function
|
|
8
|
+
export declare function addOrUpdateEnvVar(projectPath: string, key: string, value: string): Promise<void>;
|
|
16
9
|
//# sourceMappingURL=env-management.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-management.d.ts","sourceRoot":"","sources":["../../src/utils/env-management.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env-management.d.ts","sourceRoot":"","sources":["../../src/utils/env-management.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAmEf"}
|
|
@@ -1,97 +1,64 @@
|
|
|
1
|
-
import { randomBytes } from 'crypto';
|
|
2
1
|
import fs from 'fs/promises';
|
|
3
2
|
import path from 'path';
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @returns 24-character hexadecimal string
|
|
8
|
-
*/ export function generateSecret() {
|
|
9
|
-
return randomBytes(32).toString('hex').slice(0, 24);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Sanitize and process environment file contents
|
|
13
|
-
*
|
|
14
|
-
* @param contents - Raw .env file contents
|
|
15
|
-
* @param payloadSecret - Secret to use for PAYLOAD_SECRET
|
|
16
|
-
* @returns Processed .env contents
|
|
17
|
-
*/ function sanitizeEnv(contents, payloadSecret) {
|
|
18
|
-
const lines = contents.split('\n');
|
|
19
|
-
const seenKeys = new Set();
|
|
20
|
-
const processedLines = [];
|
|
21
|
-
for (const line of lines){
|
|
22
|
-
// Skip empty lines and comments
|
|
23
|
-
if (!line.trim() || line.trim().startsWith('#')) {
|
|
24
|
-
processedLines.push(line);
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
// Skip lines without =
|
|
28
|
-
if (!line.includes('=')) {
|
|
29
|
-
processedLines.push(line);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const [key] = line.split('=');
|
|
33
|
-
const trimmedKey = key.trim();
|
|
34
|
-
// Skip duplicate keys
|
|
35
|
-
if (seenKeys.has(trimmedKey)) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
seenKeys.add(trimmedKey);
|
|
39
|
-
// Replace PAYLOAD_SECRET with actual value
|
|
40
|
-
if (trimmedKey === 'PAYLOAD_SECRET' || trimmedKey === 'PAYLOAD_SECRET_KEY') {
|
|
41
|
-
processedLines.push(`PAYLOAD_SECRET=${payloadSecret}`);
|
|
42
|
-
} else {
|
|
43
|
-
processedLines.push(line);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
// Add PAYLOAD_SECRET if not present
|
|
47
|
-
if (!seenKeys.has('PAYLOAD_SECRET') && !seenKeys.has('PAYLOAD_SECRET_KEY')) {
|
|
48
|
-
processedLines.push(`PAYLOAD_SECRET=${payloadSecret}`);
|
|
49
|
-
}
|
|
50
|
-
return processedLines.join('\n');
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Manage environment files for a new project
|
|
54
|
-
*
|
|
55
|
-
* Creates .env from .env.example (if exists) and populates PAYLOAD_SECRET
|
|
4
|
+
* Add or update an environment variable in .env file
|
|
56
5
|
*
|
|
57
6
|
* @param projectPath - Path to project directory
|
|
58
|
-
* @
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const envExamplePath = path.join(projectPath, '.env.example');
|
|
7
|
+
* @param key - Environment variable name
|
|
8
|
+
* @param value - Environment variable value
|
|
9
|
+
*/ export async function addOrUpdateEnvVar(projectPath, key, value) {
|
|
62
10
|
const envPath = path.join(projectPath, '.env');
|
|
63
11
|
try {
|
|
64
|
-
|
|
65
|
-
let envExampleContents = '';
|
|
66
|
-
try {
|
|
67
|
-
envExampleContents = await fs.readFile(envExamplePath, 'utf-8');
|
|
68
|
-
} catch {
|
|
69
|
-
// No .env.example, create minimal .env
|
|
70
|
-
envExampleContents = '';
|
|
71
|
-
}
|
|
72
|
-
// Check if .env already exists
|
|
12
|
+
let contents = '';
|
|
73
13
|
let envExists = false;
|
|
14
|
+
// Try to read existing .env file
|
|
74
15
|
try {
|
|
75
|
-
await fs.
|
|
16
|
+
contents = await fs.readFile(envPath, 'utf-8');
|
|
76
17
|
envExists = true;
|
|
77
18
|
} catch {
|
|
78
|
-
// .env doesn't exist
|
|
19
|
+
// .env doesn't exist, will create it
|
|
79
20
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
//
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const sanitized = sanitizeEnv(existingContents, payloadSecret);
|
|
89
|
-
await fs.writeFile(envPath, sanitized, 'utf-8');
|
|
21
|
+
const lines = contents.split('\n');
|
|
22
|
+
const seenKeys = new Set();
|
|
23
|
+
const processedLines = [];
|
|
24
|
+
let keyUpdated = false;
|
|
25
|
+
for (const line of lines){
|
|
26
|
+
// Skip empty lines at start if file didn't exist
|
|
27
|
+
if (!envExists && !line.trim()) {
|
|
28
|
+
continue;
|
|
90
29
|
}
|
|
30
|
+
// Preserve empty lines and comments
|
|
31
|
+
if (!line.trim() || line.trim().startsWith('#')) {
|
|
32
|
+
processedLines.push(line);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
// Skip lines without =
|
|
36
|
+
if (!line.includes('=')) {
|
|
37
|
+
processedLines.push(line);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const [lineKey] = line.split('=');
|
|
41
|
+
const trimmedKey = lineKey.trim();
|
|
42
|
+
// Skip duplicate keys (keep first occurrence)
|
|
43
|
+
if (seenKeys.has(trimmedKey)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
seenKeys.add(trimmedKey);
|
|
47
|
+
// Update or keep the line
|
|
48
|
+
if (trimmedKey === key) {
|
|
49
|
+
processedLines.push(`${key}=${value}`);
|
|
50
|
+
keyUpdated = true;
|
|
51
|
+
} else {
|
|
52
|
+
processedLines.push(line);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Add key if not present
|
|
56
|
+
if (!keyUpdated) {
|
|
57
|
+
processedLines.push(`${key}=${value}`);
|
|
91
58
|
}
|
|
92
|
-
|
|
59
|
+
await fs.writeFile(envPath, processedLines.join('\n'), 'utf-8');
|
|
93
60
|
} catch (error) {
|
|
94
|
-
throw new Error(`Failed to
|
|
61
|
+
throw new Error(`Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
95
62
|
}
|
|
96
63
|
}
|
|
97
64
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/env-management.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/utils/env-management.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\n/**\n * Add or update an environment variable in .env file\n *\n * @param projectPath - Path to project directory\n * @param key - Environment variable name\n * @param value - Environment variable value\n */\nexport async function addOrUpdateEnvVar(\n projectPath: string,\n key: string,\n value: string,\n): Promise<void> {\n const envPath = path.join(projectPath, '.env')\n\n try {\n let contents = ''\n let envExists = false\n\n // Try to read existing .env file\n try {\n contents = await fs.readFile(envPath, 'utf-8')\n envExists = true\n } catch {\n // .env doesn't exist, will create it\n }\n\n const lines = contents.split('\\n')\n const seenKeys = new Set<string>()\n const processedLines: string[] = []\n let keyUpdated = false\n\n for (const line of lines) {\n // Skip empty lines at start if file didn't exist\n if (!envExists && !line.trim()) {\n continue\n }\n\n // Preserve empty lines and comments\n if (!line.trim() || line.trim().startsWith('#')) {\n processedLines.push(line)\n continue\n }\n\n // Skip lines without =\n if (!line.includes('=')) {\n processedLines.push(line)\n continue\n }\n\n const [lineKey] = line.split('=')\n const trimmedKey = lineKey.trim()\n\n // Skip duplicate keys (keep first occurrence)\n if (seenKeys.has(trimmedKey)) {\n continue\n }\n seenKeys.add(trimmedKey)\n\n // Update or keep the line\n if (trimmedKey === key) {\n processedLines.push(`${key}=${value}`)\n keyUpdated = true\n } else {\n processedLines.push(line)\n }\n }\n\n // Add key if not present\n if (!keyUpdated) {\n processedLines.push(`${key}=${value}`)\n }\n\n await fs.writeFile(envPath, processedLines.join('\\n'), 'utf-8')\n } catch (error) {\n throw new Error(\n `Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n}\n"],"names":["fs","path","addOrUpdateEnvVar","projectPath","key","value","envPath","join","contents","envExists","readFile","lines","split","seenKeys","Set","processedLines","keyUpdated","line","trim","startsWith","push","includes","lineKey","trimmedKey","has","add","writeFile","error","Error","message"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB;;;;;;CAMC,GACD,OAAO,eAAeC,kBACpBC,WAAmB,EACnBC,GAAW,EACXC,KAAa;IAEb,MAAMC,UAAUL,KAAKM,IAAI,CAACJ,aAAa;IAEvC,IAAI;QACF,IAAIK,WAAW;QACf,IAAIC,YAAY;QAEhB,iCAAiC;QACjC,IAAI;YACFD,WAAW,MAAMR,GAAGU,QAAQ,CAACJ,SAAS;YACtCG,YAAY;QACd,EAAE,OAAM;QACN,qCAAqC;QACvC;QAEA,MAAME,QAAQH,SAASI,KAAK,CAAC;QAC7B,MAAMC,WAAW,IAAIC;QACrB,MAAMC,iBAA2B,EAAE;QACnC,IAAIC,aAAa;QAEjB,KAAK,MAAMC,QAAQN,MAAO;YACxB,iDAAiD;YACjD,IAAI,CAACF,aAAa,CAACQ,KAAKC,IAAI,IAAI;gBAC9B;YACF;YAEA,oCAAoC;YACpC,IAAI,CAACD,KAAKC,IAAI,MAAMD,KAAKC,IAAI,GAAGC,UAAU,CAAC,MAAM;gBAC/CJ,eAAeK,IAAI,CAACH;gBACpB;YACF;YAEA,uBAAuB;YACvB,IAAI,CAACA,KAAKI,QAAQ,CAAC,MAAM;gBACvBN,eAAeK,IAAI,CAACH;gBACpB;YACF;YAEA,MAAM,CAACK,QAAQ,GAAGL,KAAKL,KAAK,CAAC;YAC7B,MAAMW,aAAaD,QAAQJ,IAAI;YAE/B,8CAA8C;YAC9C,IAAIL,SAASW,GAAG,CAACD,aAAa;gBAC5B;YACF;YACAV,SAASY,GAAG,CAACF;YAEb,0BAA0B;YAC1B,IAAIA,eAAenB,KAAK;gBACtBW,eAAeK,IAAI,CAAC,GAAGhB,IAAI,CAAC,EAAEC,OAAO;gBACrCW,aAAa;YACf,OAAO;gBACLD,eAAeK,IAAI,CAACH;YACtB;QACF;QAEA,yBAAyB;QACzB,IAAI,CAACD,YAAY;YACfD,eAAeK,IAAI,CAAC,GAAGhB,IAAI,CAAC,EAAEC,OAAO;QACvC;QAEA,MAAML,GAAG0B,SAAS,CAACpB,SAASS,eAAeR,IAAI,CAAC,OAAO;IACzD,EAAE,OAAOoB,OAAO;QACd,MAAM,IAAIC,MACR,CAAC,4BAA4B,EAAED,iBAAiBC,QAAQD,MAAME,OAAO,GAAG,iBAAiB;IAE7F;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/utils/messages.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,wBAAgB,WAAW,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/utils/messages.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,wBAAgB,WAAW,IAAI,IAAI,CAyClC;AASD,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAG,MAAM,CAiBzF;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAO3C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAgBpF;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|
package/dist/utils/messages.js
CHANGED
|
@@ -29,16 +29,14 @@ export function helpMessage() {
|
|
|
29
29
|
|
|
30
30
|
${pc.bold('INIT COMMAND')}
|
|
31
31
|
|
|
32
|
-
${pc.cyan('@payloadcms/figma init --id <
|
|
33
|
-
${pc.cyan('@payloadcms/figma init')}
|
|
34
|
-
${pc.cyan('@payloadcms/figma init --
|
|
35
|
-
${pc.cyan('@payloadcms/figma init --force')} Force reconfiguration of existing project
|
|
36
|
-
${pc.cyan('@payloadcms/figma init --skip-auth')} Skip authentication (testing only)
|
|
32
|
+
${pc.cyan('@payloadcms/figma init --id <content-system-id>')} Initialize project with Content System ID
|
|
33
|
+
${pc.cyan('@payloadcms/figma init --force')} Force reconfiguration of existing project
|
|
34
|
+
${pc.cyan('@payloadcms/figma init --skip-auth')} Skip authentication (testing only)
|
|
37
35
|
|
|
38
36
|
${pc.bold('DEPLOY COMMAND')}
|
|
39
37
|
|
|
40
|
-
${pc.cyan('@payloadcms/figma deploy')}
|
|
41
|
-
${pc.dim('--yes, -y')}
|
|
38
|
+
${pc.cyan('@payloadcms/figma deploy --id <tenant-id>')} Deploy your project to Figma
|
|
39
|
+
${pc.dim('--yes, -y')} Skip confirmation prompts
|
|
42
40
|
|
|
43
41
|
${pc.bold('DOCUMENTATION')}
|
|
44
42
|
|
|
@@ -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/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 <
|
|
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 <content-system-id>')} Initialize project with Content System ID\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 --id <tenant-id>')} 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,mDAAmD;MAC7D,EAAET,GAAGS,IAAI,CAAC,kCAAkC;MAC5C,EAAET,GAAGS,IAAI,CAAC,sCAAsC;;EAEpD,EAAET,GAAGI,IAAI,CAAC,kBAAkB;;MAExB,EAAEJ,GAAGS,IAAI,CAAC,6CAA6C;MACvD,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,18 +1,33 @@
|
|
|
1
1
|
import type { SourceFile } from 'ts-morph';
|
|
2
|
+
/**
|
|
3
|
+
* Result of detecting what changes are needed in a payload config file
|
|
4
|
+
*/
|
|
2
5
|
export type DetectionResult = {
|
|
6
|
+
/** Database adapter configuration if present */
|
|
3
7
|
dbProperty?: {
|
|
8
|
+
/** Name of the adapter function (e.g., 'mongooseAdapter', 'postgresAdapter') */
|
|
4
9
|
adapter: string;
|
|
10
|
+
/** NPM package the adapter is imported from (e.g., '@payloadcms/db-mongodb') */
|
|
5
11
|
importSource: string;
|
|
6
12
|
};
|
|
13
|
+
/** Editor configuration if present */
|
|
7
14
|
editorProperty?: {
|
|
15
|
+
/** NPM package the editor is imported from (e.g., '@payloadcms/richtext-lexical') */
|
|
8
16
|
importSource: string;
|
|
17
|
+
/** Whether this is a default editor with no custom configuration */
|
|
9
18
|
isDefault: boolean;
|
|
10
19
|
};
|
|
20
|
+
/** Whether the config already has a `figma` property */
|
|
11
21
|
figmaObjectExists: boolean;
|
|
22
|
+
/** Whether buildConfig/buildFigmaConfig uses an import alias (e.g., 'buildConfig as createConfig') */
|
|
12
23
|
hasAlias: boolean;
|
|
24
|
+
/** Whether a buildConfig or buildFigmaConfig call was found (undefined if not checked) */
|
|
13
25
|
hasBuildConfig?: boolean;
|
|
26
|
+
/** Whether there are other imports from 'payload' besides buildConfig (e.g., types) */
|
|
14
27
|
hasOtherPayloadImports: boolean;
|
|
28
|
+
/** Whether the import needs to be changed from 'payload' to '@payloadcms/figma' */
|
|
15
29
|
needsImportChange: boolean;
|
|
30
|
+
/** Whether a `secret` property exists in the config */
|
|
16
31
|
secretProperty?: boolean;
|
|
17
32
|
};
|
|
18
33
|
/**
|
|
@@ -30,8 +45,7 @@ export type ASTModificationResult = {
|
|
|
30
45
|
export declare function applyModifications(sourceFile: SourceFile, detection: DetectionResult): ASTModificationResult;
|
|
31
46
|
export type FigmaPropertyConfig = {
|
|
32
47
|
contentSystemId: string;
|
|
33
|
-
|
|
34
|
-
useContentSystem: boolean;
|
|
48
|
+
useContentSystem?: boolean;
|
|
35
49
|
};
|
|
36
50
|
/**
|
|
37
51
|
* Add figma property to buildConfig if it doesn't exist
|
|
@@ -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;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,
|
|
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;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,gDAAgD;IAChD,UAAU,CAAC,EAAE;QACX,gFAAgF;QAChF,OAAO,EAAE,MAAM,CAAA;QACf,gFAAgF;QAChF,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,sCAAsC;IACtC,cAAc,CAAC,EAAE;QACf,qFAAqF;QACrF,YAAY,EAAE,MAAM,CAAA;QACpB,oEAAoE;QACpE,SAAS,EAAE,OAAO,CAAA;KACnB,CAAA;IACD,wDAAwD;IACxD,iBAAiB,EAAE,OAAO,CAAA;IAC1B,sGAAsG;IACtG,QAAQ,EAAE,OAAO,CAAA;IACjB,0FAA0F;IAC1F,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,uFAAuF;IACvF,sBAAsB,EAAE,OAAO,CAAA;IAC/B,mFAAmF;IACnF,iBAAiB,EAAE,OAAO,CAAA;IAC1B,uDAAuD;IACvD,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,eAAe,CAqJ7E;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,CAwKvB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,mBAAmB,GAC1B,qBAAqB,CAqDvB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,mBAAmB,GAAG,IAAI,CA4ElF"}
|