@payloadcms/figma 0.1.0-alpha.0 → 0.1.0-alpha.10
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/LICENSE.md +1 -1
- package/dist/{utils → adapters}/asset-collection.d.ts +17 -3
- package/dist/adapters/asset-collection.js +242 -0
- package/dist/{utils → adapters}/build-lambda-zip.d.ts +8 -7
- package/dist/adapters/build-lambda-zip.js +111 -0
- package/dist/adapters/configureNextjsCache.d.ts +8 -0
- package/dist/adapters/configureNextjsCache.js +55 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.d.ts +1 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.js +15 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput.d.ts +12 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput.js +28 -0
- package/dist/adapters/deploy-output/inspectNitroOutput.d.ts +9 -0
- package/dist/adapters/deploy-output/inspectNitroOutput.js +13 -0
- package/dist/adapters/deploy-output/isFile.d.ts +1 -0
- package/dist/adapters/deploy-output/isFile.js +4 -0
- package/dist/adapters/deploy-output/readJson.d.ts +1 -0
- package/dist/adapters/deploy-output/readJson.js +9 -0
- package/dist/adapters/deploy-output/resolveNitroOutputLayout.d.ts +8 -0
- package/dist/adapters/deploy-output/resolveNitroOutputLayout.js +16 -0
- package/dist/adapters/deploy-output/resolveOutputPath.d.ts +2 -0
- package/dist/adapters/deploy-output/resolveOutputPath.js +9 -0
- package/dist/adapters/deploy-output/resolveWithin.d.ts +1 -0
- package/dist/adapters/deploy-output/resolveWithin.js +12 -0
- package/dist/adapters/fs-utils.d.ts +39 -0
- package/dist/adapters/fs-utils.js +135 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/lambda-runtime/nextjs-cache.d.ts +40 -0
- package/dist/adapters/lambda-runtime/nextjs-cache.js +174 -0
- package/dist/adapters/nextjs.d.ts +12 -0
- package/dist/adapters/nextjs.js +67 -0
- package/dist/adapters/nitro.d.ts +8 -0
- package/dist/adapters/nitro.js +193 -0
- package/dist/adapters/secret-files.d.ts +25 -0
- package/dist/adapters/secret-files.js +50 -0
- package/dist/adapters/types.d.ts +42 -0
- package/dist/adapters/types.js +1 -0
- package/dist/{utils/adapters → adapters}/vite.d.ts +2 -2
- package/dist/adapters/vite.js +33 -0
- package/dist/api/check-project-subdomain-availability.d.ts +12 -0
- package/dist/api/check-project-subdomain-availability.js +32 -0
- package/dist/api/control-plane-error.d.ts +6 -0
- package/dist/api/control-plane-error.js +8 -0
- package/dist/api/control-plane-fetch.d.ts +7 -0
- package/dist/api/control-plane-fetch.js +37 -0
- package/dist/api/control-plane.d.ts +1 -9
- package/dist/api/control-plane.js +2 -48
- package/dist/api/create-project.d.ts +18 -0
- package/dist/api/create-project.js +37 -0
- package/dist/api/list-project-workspaces.d.ts +8 -0
- package/dist/api/list-project-workspaces.js +28 -0
- package/dist/api/project-resource-type.d.ts +1 -0
- package/dist/api/project-resource-type.js +1 -0
- package/dist/auth/headless-oauth-flow.d.ts +23 -0
- package/dist/auth/headless-oauth-flow.js +69 -0
- package/dist/auth/oauth-flow.d.ts +2 -0
- package/dist/auth/oauth-flow.js +13 -8
- package/dist/auth/token-store.d.ts +4 -1
- package/dist/auth/token-store.js +14 -0
- package/dist/auth/types.d.ts +12 -0
- package/dist/cli.d.ts +39 -0
- package/dist/cli.js +71 -36
- package/dist/commands/bootstrap.js +2 -1
- package/dist/commands/build-lambda-zip.js +1 -1
- package/dist/commands/deploy.d.ts +12 -0
- package/dist/commands/deploy.js +63 -25
- package/dist/commands/detect-project-resource-type.d.ts +3 -0
- package/dist/commands/detect-project-resource-type.js +28 -0
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.js +164 -79
- package/dist/commands/login.d.ts +11 -1
- package/dist/commands/login.js +66 -4
- package/dist/commands/prompt-to-create-project/format-project-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-project-subdomain.js +3 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.js +7 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.js +13 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.d.ts +7 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.js +32 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.d.ts +8 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.js +27 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.js +54 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.js +23 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.d.ts +12 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.js +36 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.js +9 -0
- package/dist/commands/prompt-to-create-project.d.ts +24 -0
- package/dist/commands/prompt-to-create-project.js +69 -0
- package/dist/commands/setup-agent.d.ts +12 -0
- package/dist/commands/setup-agent.js +123 -0
- package/dist/commands/write-project-configuration.d.ts +12 -0
- package/dist/commands/write-project-configuration.js +16 -0
- package/dist/db-content-api/generated/content-api-types.d.ts +661 -16
- package/dist/db-content-api/index.d.ts +3 -0
- package/dist/db-content-api/index.js +155 -161
- package/dist/db-content-api/utilities/clientVersionHeaders.d.ts +7 -0
- package/dist/db-content-api/utilities/clientVersionHeaders.js +15 -0
- package/dist/db-content-api/utilities/data/atomicOperations.d.ts +16 -0
- package/dist/db-content-api/utilities/data/atomicOperations.js +48 -0
- package/dist/db-content-api/utilities/data/convertRelationshipIds.d.ts +25 -0
- package/dist/db-content-api/utilities/data/convertRelationshipIds.js +109 -0
- package/dist/db-content-api/utilities/data/index.js +73 -57
- package/dist/db-content-api/utilities/data/injectGlobalType.d.ts +6 -0
- package/dist/db-content-api/utilities/data/injectGlobalType.js +11 -0
- package/dist/db-content-api/utilities/data/isLocaleMap.d.ts +10 -0
- package/dist/db-content-api/utilities/data/isLocaleMap.js +13 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +3 -11
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +12 -50
- package/dist/db-content-api/utilities/data/resolveFieldLocalization.d.ts +18 -0
- package/dist/db-content-api/utilities/data/resolveFieldLocalization.js +21 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +19 -12
- package/dist/db-content-api/utilities/isRecord.d.ts +9 -0
- package/dist/db-content-api/utilities/isRecord.js +19 -0
- package/dist/db-content-api/utilities/joins.d.ts +6 -8
- package/dist/db-content-api/utilities/joins.js +13 -22
- package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.js +95 -0
- package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.d.ts +9 -0
- package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.js +112 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +21 -4
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +118 -36
- package/dist/db-content-api/utilities/schema/getDocumentSchema.d.ts +3 -0
- package/dist/db-content-api/utilities/schema/getDocumentSchema.js +24 -0
- package/dist/db-content-api/utilities/where.d.ts +3 -17
- package/dist/db-content-api/utilities/where.js +21 -21
- package/dist/exports/client.d.ts +2 -0
- package/dist/exports/client.js +2 -0
- package/dist/exports/views.d.ts +1 -0
- package/dist/exports/views.js +1 -0
- package/dist/imageSizeOptions.d.ts +23 -0
- package/dist/imageSizeOptions.js +26 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/write-agent-config.d.ts +12 -0
- package/dist/lib/write-agent-config.js +52 -0
- package/dist/next/image-loader.d.ts +6 -0
- package/dist/next/image-loader.js +14 -0
- package/dist/oauth/components/LoginButton/index.js +66 -19
- package/dist/oauth/components/LoginButton/index.scss +121 -15
- package/dist/oauth/defaults.js +4 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +5 -2
- package/dist/oauth/index.js +8 -7
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +1 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +1 -0
- package/dist/oauth/utilities/getAuthorizeURL.js +5 -1
- package/dist/plugin/build-config.d.ts +4 -2
- package/dist/plugin/build-config.js +95 -31
- package/dist/plugin/cache-revalidation-hooks.d.ts +6 -0
- package/dist/plugin/cache-revalidation-hooks.js +69 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.d.ts +8 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.js +66 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.scss +56 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.d.ts +4 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.js +110 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.css +14 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.d.ts +4 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.js +52 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.d.ts +7 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.js +3 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.d.ts +1 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.js +27 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.d.ts +2 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.js +30 -0
- package/dist/plugin/cloud-limits/routes.d.ts +2 -0
- package/dist/plugin/cloud-limits/routes.js +4 -0
- package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.d.ts +9 -0
- package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.js +28 -0
- package/dist/plugin/cloud-limits/shared.d.ts +10 -0
- package/dist/plugin/cloud-limits/shared.js +52 -0
- package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.d.ts +2 -0
- package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.js +134 -0
- package/dist/plugin/cloud-limits/utilities/toasts.d.ts +4 -0
- package/dist/plugin/cloud-limits/utilities/toasts.js +19 -0
- package/dist/plugin/make-permission-access/make-permission-access.d.ts +8 -0
- package/dist/plugin/make-permission-access/make-permission-access.js +24 -0
- package/dist/plugin/sandbox-upload-fetch.d.ts +32 -0
- package/dist/plugin/sandbox-upload-fetch.js +53 -0
- package/dist/skills/deploy-to-figma/SKILL.md +234 -0
- package/dist/skills/deploy-to-figma/references/cli-reference.md +146 -0
- package/dist/storage-content-api/client-uploads/generate.js +2 -1
- package/dist/storage-content-api/getDownloadResponseHeaderPolicy.d.ts +11 -0
- package/dist/storage-content-api/getDownloadResponseHeaderPolicy.js +27 -0
- package/dist/storage-content-api/index.js +1 -0
- package/dist/storage-content-api/resolveDownloadResponseHeaders.d.ts +5 -0
- package/dist/storage-content-api/resolveDownloadResponseHeaders.js +13 -0
- package/dist/storage-content-api/staticHandler.js +2 -1
- package/dist/storage-content-api/types.d.ts +4 -1
- package/dist/translations/ar.d.ts +12 -0
- package/dist/translations/ar.js +12 -0
- package/dist/translations/az.d.ts +12 -0
- package/dist/translations/az.js +12 -0
- package/dist/translations/bg.d.ts +12 -0
- package/dist/translations/bg.js +12 -0
- package/dist/translations/bnBd.d.ts +12 -0
- package/dist/translations/bnBd.js +12 -0
- package/dist/translations/bnIn.d.ts +12 -0
- package/dist/translations/bnIn.js +12 -0
- package/dist/translations/ca.d.ts +12 -0
- package/dist/translations/ca.js +12 -0
- package/dist/translations/cs.d.ts +12 -0
- package/dist/translations/cs.js +12 -0
- package/dist/translations/da.d.ts +12 -0
- package/dist/translations/da.js +12 -0
- package/dist/translations/de.d.ts +12 -0
- package/dist/translations/de.js +12 -0
- package/dist/translations/en.d.ts +12 -0
- package/dist/translations/en.js +12 -0
- package/dist/translations/es.d.ts +12 -0
- package/dist/translations/es.js +12 -0
- package/dist/translations/et.d.ts +12 -0
- package/dist/translations/et.js +12 -0
- package/dist/translations/fa.d.ts +12 -0
- package/dist/translations/fa.js +12 -0
- package/dist/translations/fr.d.ts +12 -0
- package/dist/translations/fr.js +12 -0
- package/dist/translations/he.d.ts +12 -0
- package/dist/translations/he.js +12 -0
- package/dist/translations/hr.d.ts +12 -0
- package/dist/translations/hr.js +12 -0
- package/dist/translations/hu.d.ts +12 -0
- package/dist/translations/hu.js +12 -0
- package/dist/translations/hy.d.ts +12 -0
- package/dist/translations/hy.js +12 -0
- package/dist/translations/id.d.ts +12 -0
- package/dist/translations/id.js +12 -0
- package/dist/translations/index.d.ts +533 -0
- package/dist/translations/index.js +90 -0
- package/dist/translations/is.d.ts +12 -0
- package/dist/translations/is.js +12 -0
- package/dist/translations/it.d.ts +12 -0
- package/dist/translations/it.js +12 -0
- package/dist/translations/ja.d.ts +12 -0
- package/dist/translations/ja.js +12 -0
- package/dist/translations/ko.d.ts +12 -0
- package/dist/translations/ko.js +12 -0
- package/dist/translations/lt.d.ts +12 -0
- package/dist/translations/lt.js +12 -0
- package/dist/translations/lv.d.ts +12 -0
- package/dist/translations/lv.js +12 -0
- package/dist/translations/my.d.ts +12 -0
- package/dist/translations/my.js +12 -0
- package/dist/translations/nb.d.ts +12 -0
- package/dist/translations/nb.js +12 -0
- package/dist/translations/nl.d.ts +12 -0
- package/dist/translations/nl.js +12 -0
- package/dist/translations/pl.d.ts +12 -0
- package/dist/translations/pl.js +12 -0
- package/dist/translations/pt.d.ts +12 -0
- package/dist/translations/pt.js +12 -0
- package/dist/translations/ro.d.ts +12 -0
- package/dist/translations/ro.js +12 -0
- package/dist/translations/rs.d.ts +12 -0
- package/dist/translations/rs.js +12 -0
- package/dist/translations/rsLatin.d.ts +12 -0
- package/dist/translations/rsLatin.js +12 -0
- package/dist/translations/ru.d.ts +12 -0
- package/dist/translations/ru.js +12 -0
- package/dist/translations/sk.d.ts +12 -0
- package/dist/translations/sk.js +12 -0
- package/dist/translations/sl.d.ts +12 -0
- package/dist/translations/sl.js +12 -0
- package/dist/translations/sv.d.ts +12 -0
- package/dist/translations/sv.js +12 -0
- package/dist/translations/ta.d.ts +12 -0
- package/dist/translations/ta.js +12 -0
- package/dist/translations/th.d.ts +12 -0
- package/dist/translations/th.js +12 -0
- package/dist/translations/tr.d.ts +12 -0
- package/dist/translations/tr.js +12 -0
- package/dist/translations/uk.d.ts +12 -0
- package/dist/translations/uk.js +12 -0
- package/dist/translations/vi.d.ts +12 -0
- package/dist/translations/vi.js +12 -0
- package/dist/translations/zh.d.ts +12 -0
- package/dist/translations/zh.js +12 -0
- package/dist/translations/zhTw.d.ts +12 -0
- package/dist/translations/zhTw.js +12 -0
- package/dist/types.d.ts +11 -0
- package/dist/utils/assert-never.d.ts +1 -0
- package/dist/utils/assert-never.js +3 -0
- package/dist/utils/build-detection.d.ts +6 -1
- package/dist/utils/build-detection.js +68 -89
- package/dist/utils/deploy-adapter.d.ts +3 -35
- package/dist/utils/deploy-adapter.js +25 -14
- package/dist/utils/lambda-config.js +18 -23
- package/dist/utils/load-payload-config.d.ts +2 -2
- package/dist/utils/messages.js +24 -3
- package/dist/utils/next-image-loader-config.d.ts +2 -0
- package/dist/utils/next-image-loader-config.js +63 -0
- package/dist/utils/next-image-loader-file.d.ts +2 -0
- package/dist/utils/next-image-loader-file.js +11 -0
- package/dist/utils/payload-generate.d.ts +10 -0
- package/dist/utils/payload-generate.js +59 -0
- package/dist/utils/pnpm-builds.d.ts +14 -0
- package/dist/utils/pnpm-builds.js +125 -0
- package/dist/utils/s3-upload.js +4 -1
- package/package.json +31 -7
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +0 -10
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +0 -71
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +0 -41
- package/dist/db-content-api/utilities/meta/buildMeta.js +0 -39
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +0 -16
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +0 -243
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +0 -12
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +0 -60
- package/dist/lib/download-skill.d.ts +0 -12
- package/dist/lib/download-skill.js +0 -77
- package/dist/utils/adapters/nextjs.d.ts +0 -8
- package/dist/utils/adapters/nextjs.js +0 -61
- package/dist/utils/adapters/nitro.d.ts +0 -8
- package/dist/utils/adapters/nitro.js +0 -172
- package/dist/utils/adapters/vite.js +0 -31
- package/dist/utils/asset-collection.js +0 -144
- package/dist/utils/build-lambda-zip.js +0 -90
- package/dist/utils/fs-utils.d.ts +0 -12
- package/dist/utils/fs-utils.js +0 -55
package/dist/types.d.ts
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
import type arg from 'arg';
|
|
2
2
|
export interface Args extends arg.Spec {
|
|
3
|
+
'--adapter': StringConstructor;
|
|
4
|
+
'--callback-url': StringConstructor;
|
|
5
|
+
'--complete': StringConstructor;
|
|
3
6
|
'--debug': BooleanConstructor;
|
|
7
|
+
'--description': StringConstructor;
|
|
4
8
|
'--dry-run': BooleanConstructor;
|
|
5
9
|
'--env': StringConstructor;
|
|
6
10
|
'--environment': string;
|
|
7
11
|
'--force': BooleanConstructor;
|
|
12
|
+
'--global': BooleanConstructor;
|
|
13
|
+
'--headless': BooleanConstructor;
|
|
8
14
|
'--help': BooleanConstructor;
|
|
9
15
|
'--id': StringConstructor;
|
|
10
16
|
'--infra-env': StringConstructor;
|
|
11
17
|
'--list': BooleanConstructor;
|
|
12
18
|
'--logout': BooleanConstructor;
|
|
13
19
|
'--name': StringConstructor;
|
|
20
|
+
'--output': StringConstructor;
|
|
21
|
+
'--project': BooleanConstructor;
|
|
22
|
+
'--region': StringConstructor;
|
|
23
|
+
'--subdomain': StringConstructor;
|
|
14
24
|
'--template': StringConstructor;
|
|
25
|
+
'--workspace': StringConstructor;
|
|
15
26
|
'--yes': BooleanConstructor;
|
|
16
27
|
'-e': string;
|
|
17
28
|
'-f': string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function assertNever(x: never): never;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AdapterName } from './deploy-adapter.js';
|
|
1
2
|
/**
|
|
2
3
|
* Information about a detected build
|
|
3
4
|
*/
|
|
@@ -11,11 +12,15 @@ export interface BuildInfo {
|
|
|
11
12
|
/** Build timestamp */
|
|
12
13
|
timestamp: Date;
|
|
13
14
|
}
|
|
15
|
+
export interface DetectBuildOptions {
|
|
16
|
+
adapter?: AdapterName;
|
|
17
|
+
output?: string;
|
|
18
|
+
}
|
|
14
19
|
/**
|
|
15
20
|
* Detect a valid build across supported frameworks.
|
|
16
21
|
* Tries NextJS, then Nitro, then Vite. Returns the first match.
|
|
17
22
|
*/
|
|
18
|
-
export declare function detectBuild(projectPath: string): Promise<BuildInfo | null>;
|
|
23
|
+
export declare function detectBuild(projectPath: string, options: DetectBuildOptions): Promise<BuildInfo | null>;
|
|
19
24
|
/**
|
|
20
25
|
* Get the build command from package.json
|
|
21
26
|
*
|
|
@@ -1,103 +1,82 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { inspectNextjsOutput } from '../adapters/deploy-output/inspectNextjsOutput.js';
|
|
4
|
+
import { inspectNitroOutput } from '../adapters/deploy-output/inspectNitroOutput.js';
|
|
5
|
+
import { resolveOutputPath } from '../adapters/deploy-output/resolveOutputPath.js';
|
|
6
|
+
import { assertNever } from './assert-never.js';
|
|
3
7
|
/**
|
|
4
8
|
* Detect a valid build across supported frameworks.
|
|
5
9
|
* Tries NextJS, then Nitro, then Vite. Returns the first match.
|
|
6
|
-
*/ export async function detectBuild(projectPath) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (viteBuild) {
|
|
20
|
-
return viteBuild;
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Detect NextJS standalone build (.next/standalone/server.js + .next/BUILD_ID)
|
|
26
|
-
*/ async function detectNextjsBuild(projectPath) {
|
|
27
|
-
try {
|
|
28
|
-
const serverPath = path.join(projectPath, '.next', 'standalone', 'server.js');
|
|
29
|
-
const serverStat = await fs.stat(serverPath);
|
|
30
|
-
const buildIdPath = path.join(projectPath, '.next', 'BUILD_ID');
|
|
31
|
-
const buildId = (await fs.readFile(buildIdPath, 'utf-8')).trim();
|
|
32
|
-
const lambdaZipPath = path.join(projectPath, 'lambda.zip');
|
|
33
|
-
let hasLambdaZip = false;
|
|
34
|
-
try {
|
|
35
|
-
await fs.stat(lambdaZipPath);
|
|
36
|
-
hasLambdaZip = true;
|
|
37
|
-
} catch {
|
|
38
|
-
hasLambdaZip = false;
|
|
10
|
+
*/ export async function detectBuild(projectPath, options) {
|
|
11
|
+
const adapters = options.adapter ? [
|
|
12
|
+
options.adapter
|
|
13
|
+
] : [
|
|
14
|
+
'nextjs',
|
|
15
|
+
'nitro',
|
|
16
|
+
'vite'
|
|
17
|
+
];
|
|
18
|
+
for (const adapter of adapters){
|
|
19
|
+
const outputPath = resolveOutputPath(projectPath, adapter, options.output);
|
|
20
|
+
const build = await detectAdapterBuild(projectPath, adapter, outputPath);
|
|
21
|
+
if (build) {
|
|
22
|
+
return build;
|
|
39
23
|
}
|
|
40
|
-
return {
|
|
41
|
-
buildId,
|
|
42
|
-
hasLambdaZip,
|
|
43
|
-
path: '.next/standalone',
|
|
44
|
-
timestamp: serverStat.mtime
|
|
45
|
-
};
|
|
46
|
-
} catch {
|
|
47
|
-
return null;
|
|
48
24
|
}
|
|
25
|
+
return null;
|
|
49
26
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
27
|
+
async function detectAdapterBuild(projectPath, adapter, outputPath) {
|
|
28
|
+
switch(adapter){
|
|
29
|
+
case 'nextjs':
|
|
30
|
+
{
|
|
31
|
+
const layout = await inspectNextjsOutput(outputPath);
|
|
32
|
+
if (!layout) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const stat = await fs.stat(layout.serverEntryPath);
|
|
36
|
+
return {
|
|
37
|
+
buildId: layout.buildId,
|
|
38
|
+
hasLambdaZip: await hasLambdaZip(projectPath),
|
|
39
|
+
path: path.relative(projectPath, layout.standalonePath),
|
|
40
|
+
timestamp: stat.mtime
|
|
41
|
+
};
|
|
63
42
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
43
|
+
case 'nitro':
|
|
44
|
+
{
|
|
45
|
+
const layout = await inspectNitroOutput(outputPath);
|
|
46
|
+
if (!layout) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const stat = await fs.stat(layout.serverEntryPath);
|
|
50
|
+
return {
|
|
51
|
+
buildId: layout.buildId ?? stat.mtime.toISOString(),
|
|
52
|
+
hasLambdaZip: await hasLambdaZip(projectPath),
|
|
53
|
+
path: path.relative(projectPath, outputPath),
|
|
54
|
+
timestamp: stat.mtime
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
case 'vite':
|
|
58
|
+
{
|
|
59
|
+
try {
|
|
60
|
+
const stat = await fs.stat(path.join(outputPath, 'index.html'));
|
|
61
|
+
if (!stat.isFile()) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
buildId: stat.mtime.toISOString(),
|
|
66
|
+
hasLambdaZip: false,
|
|
67
|
+
path: path.relative(projectPath, outputPath),
|
|
68
|
+
timestamp: stat.mtime
|
|
69
|
+
};
|
|
70
|
+
} catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
default:
|
|
75
|
+
assertNever(adapter);
|
|
83
76
|
}
|
|
84
77
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
* Build ID is mtime of index.html as ISO string. No server, so hasLambdaZip is always false.
|
|
88
|
-
*/ async function detectViteBuild(projectPath) {
|
|
89
|
-
try {
|
|
90
|
-
const indexPath = path.join(projectPath, 'dist', 'index.html');
|
|
91
|
-
const indexStat = await fs.stat(indexPath);
|
|
92
|
-
return {
|
|
93
|
-
buildId: indexStat.mtime.toISOString(),
|
|
94
|
-
hasLambdaZip: false,
|
|
95
|
-
path: 'dist',
|
|
96
|
-
timestamp: indexStat.mtime
|
|
97
|
-
};
|
|
98
|
-
} catch {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
78
|
+
async function hasLambdaZip(projectPath) {
|
|
79
|
+
return fs.stat(path.join(projectPath, 'lambda.zip')).then(()=>true).catch(()=>false);
|
|
101
80
|
}
|
|
102
81
|
/**
|
|
103
82
|
* Get the build command from package.json
|
|
@@ -1,37 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
pathMap: Record<string, string>;
|
|
4
|
-
/** Route → S3 upload keys for that route (e.g., { "/products": ["products.html", "products.rsc"] }) */
|
|
5
|
-
routeAssetMap: Record<string, string[]>;
|
|
6
|
-
/** Route paths for the manifest pages array (e.g., ["/products", "/blog"]) */
|
|
7
|
-
routes: string[];
|
|
8
|
-
/** S3 keys to upload (e.g., ["products.html", "products.rsc", "products.meta"]) */
|
|
9
|
-
uploadKeys: string[];
|
|
10
|
-
}
|
|
11
|
-
export interface AssetCollection {
|
|
12
|
-
/** S3 key → relative filesystem path from project root */
|
|
13
|
-
pathMap: Record<string, string>;
|
|
14
|
-
/** Route paths for the manifest assets array (e.g., ["/favicon.ico"]) */
|
|
15
|
-
routes: string[];
|
|
16
|
-
/** S3 keys to upload (same as routes for assets, without leading slash) */
|
|
17
|
-
uploadKeys: string[];
|
|
18
|
-
}
|
|
19
|
-
export type AdapterName = 'nextjs' | 'nitro' | 'vite';
|
|
20
|
-
export interface LambdaBundle {
|
|
21
|
-
/** Total size in bytes of the bundle contents before compression. */
|
|
22
|
-
unzippedBytes: number;
|
|
23
|
-
/** Absolute path to the built lambda.zip. */
|
|
24
|
-
zipPath: string;
|
|
25
|
-
}
|
|
26
|
-
export interface DeployAdapter {
|
|
27
|
-
collectAssets(projectPath: string): Promise<AssetCollection>;
|
|
28
|
-
collectPages(projectPath: string): Promise<PageCollection>;
|
|
29
|
-
/** SPA fallback path (e.g., "/index.html"). Undefined for SSR/SSG apps. */
|
|
30
|
-
fallback?: string;
|
|
31
|
-
name: AdapterName;
|
|
32
|
-
/** Assembles and zips the server bundle. Returns the bundle, or null if no server (e.g., Vite SPA). */
|
|
33
|
-
prepareLambdaBundle(projectPath: string): Promise<LambdaBundle | null>;
|
|
34
|
-
}
|
|
1
|
+
import type { AdapterName, DeployAdapter } from '../adapters/types.js';
|
|
2
|
+
export type { AdapterLogger, AdapterName, AssetCollection, DeployAdapter, LambdaBundle, PageCollection, PrepareLambdaBundleOptions, } from '../adapters/types.js';
|
|
35
3
|
/**
|
|
36
4
|
* Auto-detect the framework adapter based on build output.
|
|
37
5
|
*
|
|
@@ -42,4 +10,4 @@ export interface DeployAdapter {
|
|
|
42
10
|
* @param projectPath - Path to project root
|
|
43
11
|
* @param override - Explicit adapter name from --adapter flag
|
|
44
12
|
*/
|
|
45
|
-
export declare function detectAdapter(projectPath: string, override?: AdapterName): Promise<DeployAdapter>;
|
|
13
|
+
export declare function detectAdapter(projectPath: string, override?: AdapterName, output?: string): Promise<DeployAdapter>;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { inspectNextjsOutput } from '../adapters/deploy-output/inspectNextjsOutput.js';
|
|
4
|
+
import { inspectNitroOutput } from '../adapters/deploy-output/inspectNitroOutput.js';
|
|
5
|
+
import { resolveOutputPath } from '../adapters/deploy-output/resolveOutputPath.js';
|
|
6
|
+
import * as log from './log.js';
|
|
7
|
+
const adapterLogger = {
|
|
8
|
+
info: log.info,
|
|
9
|
+
warning: log.warning
|
|
10
|
+
};
|
|
3
11
|
/**
|
|
4
12
|
* Auto-detect the framework adapter based on build output.
|
|
5
13
|
*
|
|
@@ -9,40 +17,43 @@ import path from 'path';
|
|
|
9
17
|
*
|
|
10
18
|
* @param projectPath - Path to project root
|
|
11
19
|
* @param override - Explicit adapter name from --adapter flag
|
|
12
|
-
*/ export async function detectAdapter(projectPath, override) {
|
|
20
|
+
*/ export async function detectAdapter(projectPath, override, output) {
|
|
13
21
|
if (override) {
|
|
14
22
|
return loadAdapter(override);
|
|
15
23
|
}
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const hasViteDist = await exists(path.join(projectPath, 'dist', 'index.html'));
|
|
19
|
-
if (hasNext) {
|
|
24
|
+
const nextOutput = resolveOutputPath(projectPath, 'nextjs', output);
|
|
25
|
+
if (await inspectNextjsOutput(nextOutput)) {
|
|
20
26
|
return loadAdapter('nextjs');
|
|
21
27
|
}
|
|
22
|
-
|
|
28
|
+
const nitroOutput = resolveOutputPath(projectPath, 'nitro', output);
|
|
29
|
+
if (await inspectNitroOutput(nitroOutput)) {
|
|
23
30
|
return loadAdapter('nitro');
|
|
24
31
|
}
|
|
25
|
-
|
|
32
|
+
const viteOutput = resolveOutputPath(projectPath, 'vite', output);
|
|
33
|
+
if (await exists(path.join(viteOutput, 'index.html'))) {
|
|
26
34
|
return loadAdapter('vite');
|
|
27
35
|
}
|
|
28
|
-
|
|
36
|
+
const location = output ? ` in ${path.resolve(projectPath, output)}` : '';
|
|
37
|
+
throw new Error(`Could not detect framework${location}. Expected Next.js BUILD_ID + standalone server, ` + 'Nitro server entry, or Vite index.html. ' + 'Use --adapter to specify explicitly.');
|
|
29
38
|
}
|
|
30
39
|
async function loadAdapter(name) {
|
|
31
40
|
switch(name){
|
|
32
41
|
case 'nextjs':
|
|
33
42
|
{
|
|
34
|
-
const mod = await import('
|
|
35
|
-
return mod.
|
|
43
|
+
const mod = await import('../adapters/nextjs.js');
|
|
44
|
+
return new mod.NextjsAdapter({
|
|
45
|
+
logger: adapterLogger
|
|
46
|
+
});
|
|
36
47
|
}
|
|
37
48
|
case 'nitro':
|
|
38
49
|
{
|
|
39
|
-
const mod = await import('
|
|
40
|
-
return mod.
|
|
50
|
+
const mod = await import('../adapters/nitro.js');
|
|
51
|
+
return new mod.NitroAdapter();
|
|
41
52
|
}
|
|
42
53
|
case 'vite':
|
|
43
54
|
{
|
|
44
|
-
const mod = await import('
|
|
45
|
-
return mod.
|
|
55
|
+
const mod = await import('../adapters/vite.js');
|
|
56
|
+
return new mod.ViteAdapter();
|
|
46
57
|
}
|
|
47
58
|
}
|
|
48
59
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { IndentationText, Node, Project, SyntaxKind } from 'ts-morph';
|
|
4
|
+
import { addFigmaImageLoaderConfig } from './next-image-loader-config.js';
|
|
5
|
+
import { writeFigmaImageLoaderFile } from './next-image-loader-file.js';
|
|
6
|
+
import { ensurePnpmWorkspace } from './pnpm-builds.js';
|
|
4
7
|
const RUN_SH_CONTENT = `#!/bin/bash -x
|
|
5
8
|
|
|
6
9
|
[ ! -d '/tmp/cache' ] && mkdir -p /tmp/cache
|
|
@@ -17,23 +20,13 @@ NODE_ENV=production exec node server.js
|
|
|
17
20
|
const runShPath = path.join(projectPath, 'run.sh');
|
|
18
21
|
await fs.writeFile(runShPath, RUN_SH_CONTENT, 'utf-8');
|
|
19
22
|
await fs.chmod(runShPath, 0o755);
|
|
20
|
-
// 2.
|
|
23
|
+
// 2. Add Next.js-specific configuration.
|
|
21
24
|
await addNextConfigProperties(projectPath);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
let npmrcContent = '';
|
|
25
|
-
try {
|
|
26
|
-
npmrcContent = await fs.readFile(npmrcPath, 'utf-8');
|
|
27
|
-
} catch {
|
|
28
|
-
// File doesn't exist, start fresh
|
|
29
|
-
}
|
|
30
|
-
if (!npmrcContent.includes('node-linker=hoisted')) {
|
|
31
|
-
npmrcContent += npmrcContent && !npmrcContent.endsWith('\n') ? '\n' : '';
|
|
32
|
-
npmrcContent += 'node-linker=hoisted\n';
|
|
33
|
-
await fs.writeFile(npmrcPath, npmrcContent, 'utf-8');
|
|
34
|
-
}
|
|
35
|
-
// 4. Add lambda:buildzip script to package.json
|
|
25
|
+
await writeFigmaImageLoaderFile(projectPath);
|
|
26
|
+
// 3. Add lambda:buildzip script to package.json
|
|
36
27
|
await addLambdaBuildScript(projectPath, packageManager);
|
|
28
|
+
// 4. Write pnpm-workspace.yaml (hoisted linker + build approvals)
|
|
29
|
+
await ensurePnpmWorkspace(projectPath);
|
|
37
30
|
}
|
|
38
31
|
/**
|
|
39
32
|
* Find the Next.js config file, checking TS extensions first
|
|
@@ -58,6 +51,7 @@ NODE_ENV=production exec node server.js
|
|
|
58
51
|
/**
|
|
59
52
|
* Add required Next.js config properties using ts-morph AST parsing
|
|
60
53
|
* - output: 'standalone' (for Lambda deployment)
|
|
54
|
+
* - images.loader: 'custom' and images.loaderFile for Payload media
|
|
61
55
|
*/ async function addNextConfigProperties(projectPath) {
|
|
62
56
|
const nextConfigPath = await findNextConfigPath(projectPath);
|
|
63
57
|
const project = new Project({
|
|
@@ -75,15 +69,16 @@ NODE_ENV=production exec node server.js
|
|
|
75
69
|
if (!configObject) {
|
|
76
70
|
throw new Error(`Could not find Next.js config object in ${path.basename(nextConfigPath)}. ` + `Expected either 'export default { ... }' or 'export default wrapper(configVar, ...)'`);
|
|
77
71
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
if (configObject.getProperty('output') === undefined) {
|
|
73
|
+
configObject.addPropertyAssignment({
|
|
74
|
+
name: 'output',
|
|
75
|
+
initializer: "'standalone'"
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
addFigmaImageLoaderConfig(configObject);
|
|
79
|
+
if (!sourceFile.isSaved()) {
|
|
80
|
+
await sourceFile.save();
|
|
81
81
|
}
|
|
82
|
-
configObject.addPropertyAssignment({
|
|
83
|
-
name: 'output',
|
|
84
|
-
initializer: "'standalone'"
|
|
85
|
-
});
|
|
86
|
-
await sourceFile.save();
|
|
87
82
|
}
|
|
88
83
|
/**
|
|
89
84
|
* Find the config object literal from either:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SanitizedConfig } from 'payload';
|
|
2
2
|
/**
|
|
3
3
|
* Load a project's Payload config without initializing Payload or connecting to its database.
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@ import type { Config } from 'payload';
|
|
|
6
6
|
* project's Payload installation so this also works with strict package-manager layouts where
|
|
7
7
|
* tsx is not a direct dependency of @payloadcms/figma.
|
|
8
8
|
*/
|
|
9
|
-
export declare function loadPayloadConfig(projectPath: string): Promise<
|
|
9
|
+
export declare function loadPayloadConfig(projectPath: string): Promise<SanitizedConfig>;
|
package/dist/utils/messages.js
CHANGED
|
@@ -14,6 +14,7 @@ export function helpMessage() {
|
|
|
14
14
|
${pc.cyan('logout')} Clear all stored tokens
|
|
15
15
|
${pc.cyan('list-tokens')} Show stored token information
|
|
16
16
|
${pc.cyan('init')} Initialize a Figma CMS project
|
|
17
|
+
${pc.cyan('setup-agent')} Install or update the Figma deploy skill
|
|
17
18
|
${pc.cyan('bootstrap')} Print bootstrap info (tenant IDs, OAuth creds) for a project
|
|
18
19
|
${pc.cyan('debug')} Show debug info for troubleshooting
|
|
19
20
|
${pc.cyan('env')} Switch active environment
|
|
@@ -31,16 +32,20 @@ export function helpMessage() {
|
|
|
31
32
|
${pc.bold('AUTHENTICATION')}
|
|
32
33
|
|
|
33
34
|
${pc.cyan('@payloadcms/figma login')} Authenticate with Figma
|
|
35
|
+
${pc.cyan('@payloadcms/figma login --headless --json')} Start resumable login for agents
|
|
36
|
+
${pc.cyan('@payloadcms/figma login --complete <id> --callback-url <url>')} Complete resumable login
|
|
37
|
+
${pc.dim('--json')} Emit machine-readable login status
|
|
34
38
|
${pc.cyan('@payloadcms/figma logout')} Clear tokens for current environment
|
|
35
39
|
${pc.cyan('@payloadcms/figma list-tokens')} Display stored OAuth and project tokens
|
|
36
40
|
|
|
37
41
|
${pc.bold('INIT COMMAND')}
|
|
38
42
|
|
|
39
|
-
${pc.cyan('@payloadcms/figma init
|
|
43
|
+
${pc.cyan('@payloadcms/figma init')} Create and initialize project
|
|
44
|
+
${pc.cyan('@payloadcms/figma init --id <cms-resource-id>')} Connect existing project
|
|
40
45
|
${pc.cyan('@payloadcms/figma init --id <id> --env staging')} Initialize for specific environment
|
|
41
46
|
${pc.dim('--name, -n <name>')} Set project directory name (skips prompt)
|
|
42
47
|
${pc.dim('--force')} Force reconfiguration of existing project
|
|
43
|
-
${pc.dim('--no-
|
|
48
|
+
${pc.dim('--no-agent')} Skip writing AI agent config files (AGENTS.md, CLAUDE.md)
|
|
44
49
|
${pc.dim('--template, -t <spec>')} Override scaffold template (e.g. main:website, owner/repo#ref:path)
|
|
45
50
|
${pc.dim('--payload-version <tag|version>')} Core Payload npm dist-tag or version (default canary; e.g. latest, 4.0.0-canary.16)
|
|
46
51
|
|
|
@@ -58,11 +63,27 @@ export function helpMessage() {
|
|
|
58
63
|
${pc.bold('DEPLOY COMMAND')}
|
|
59
64
|
|
|
60
65
|
${pc.cyan('@payloadcms/figma deploy')} Deploy your project to Figma
|
|
66
|
+
${pc.dim(' Creates a project when not initialized')}
|
|
61
67
|
${pc.dim('--id <project-id>')} Override FIGMA_PROJECT_ID
|
|
62
68
|
${pc.dim('--env <environment>')} Override FIGMA_ENVIRONMENT_NAME
|
|
63
|
-
${pc.dim('--yes, -y')} Skip
|
|
69
|
+
${pc.dim('--yes, -y')} Skip prompts; use safe defaults for project creation
|
|
70
|
+
${pc.dim('--name <name>')} New project name (default: package/directory name)
|
|
71
|
+
${pc.dim('--description <description>')} New project description (default: <name> project)
|
|
72
|
+
${pc.dim('--subdomain <subdomain>')} New project subdomain (default: generated from name)
|
|
73
|
+
${pc.dim('--workspace <plan-key>')} Workspace plan key (default workspace if omitted)
|
|
74
|
+
${pc.dim('--region <region>')} New project region (default: us-east-1 non-interactively)
|
|
64
75
|
${pc.dim('--skip-build')} Skip building and use existing build
|
|
65
76
|
${pc.dim('--skip-size-check')} Skip the client-side bundle size check
|
|
77
|
+
${pc.dim('--adapter <nextjs|nitro|vite>')} Override framework detection
|
|
78
|
+
${pc.dim('--output <path>')} Exact framework build output root
|
|
79
|
+
|
|
80
|
+
${pc.bold('SETUP AGENT COMMAND')}
|
|
81
|
+
|
|
82
|
+
${pc.cyan('@payloadcms/figma setup-agent')} Prompt for global or project installation
|
|
83
|
+
${pc.cyan('@payloadcms/figma setup-agent --global')} Install/update globally
|
|
84
|
+
${pc.cyan('@payloadcms/figma setup-agent --project')} Install/update in the current project
|
|
85
|
+
${pc.dim('--yes, -y')} Skip skills installer prompts
|
|
86
|
+
${pc.dim('Non-interactive use requires --global or --project.')}
|
|
66
87
|
|
|
67
88
|
${pc.bold('UPGRADE COMMAND')}
|
|
68
89
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Node, SyntaxKind } from 'ts-morph';
|
|
2
|
+
import { FIGMA_IMAGE_LOADER_PATH } from './next-image-loader-file.js';
|
|
3
|
+
export function addFigmaImageLoaderConfig(configObject) {
|
|
4
|
+
const imagesProperty = configObject.getProperty('images');
|
|
5
|
+
if (!imagesProperty) {
|
|
6
|
+
configObject.addPropertyAssignment({
|
|
7
|
+
name: 'images',
|
|
8
|
+
initializer: `{
|
|
9
|
+
loader: 'custom',
|
|
10
|
+
loaderFile: '${FIGMA_IMAGE_LOADER_PATH}',
|
|
11
|
+
}`
|
|
12
|
+
});
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
let imagesValue;
|
|
16
|
+
if (Node.isPropertyAssignment(imagesProperty)) {
|
|
17
|
+
imagesValue = imagesProperty.getInitializer();
|
|
18
|
+
} else if (Node.isShorthandPropertyAssignment(imagesProperty)) {
|
|
19
|
+
imagesValue = imagesProperty.getNameNode();
|
|
20
|
+
}
|
|
21
|
+
const imagesObject = resolveLocalObjectLiteral(imagesValue);
|
|
22
|
+
if (!imagesObject) {
|
|
23
|
+
throw new Error('Figma could not add the image loader because it could not inspect the `images` configuration. ' + 'Define `images` as an object in this Next.js config file and rerun ' + '`npx @payloadcms/figma init`.');
|
|
24
|
+
}
|
|
25
|
+
const loaderProperty = imagesObject.getProperty('loader');
|
|
26
|
+
const loaderFileProperty = imagesObject.getProperty('loaderFile');
|
|
27
|
+
if (loaderProperty || loaderFileProperty) {
|
|
28
|
+
const isFigmaLoader = getStringPropertyValue(loaderProperty) === 'custom' && getStringPropertyValue(loaderFileProperty) === FIGMA_IMAGE_LOADER_PATH;
|
|
29
|
+
if (!isFigmaLoader) {
|
|
30
|
+
throw new Error('A custom Next.js image loader is already configured, so Figma left it unchanged. ' + 'Remove the existing images.loader and images.loaderFile settings and rerun ' + '`npx @payloadcms/figma init`.');
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
imagesObject.addPropertyAssignment({
|
|
35
|
+
name: 'loader',
|
|
36
|
+
initializer: "'custom'"
|
|
37
|
+
});
|
|
38
|
+
imagesObject.addPropertyAssignment({
|
|
39
|
+
name: 'loaderFile',
|
|
40
|
+
initializer: `'${FIGMA_IMAGE_LOADER_PATH}'`
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function resolveLocalObjectLiteral(node) {
|
|
44
|
+
if (Node.isObjectLiteralExpression(node)) {
|
|
45
|
+
return node;
|
|
46
|
+
}
|
|
47
|
+
if (!Node.isIdentifier(node)) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const sourceFile = node.getSourceFile();
|
|
51
|
+
for (const definition of node.getDefinitionNodes()){
|
|
52
|
+
if (Node.isVariableDeclaration(definition) && definition.getSourceFile() === sourceFile) {
|
|
53
|
+
return definition.getInitializerIfKind(SyntaxKind.ObjectLiteralExpression);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
function getStringPropertyValue(property) {
|
|
59
|
+
if (!property || !Node.isPropertyAssignment(property)) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return property.getInitializerIfKind(SyntaxKind.StringLiteral)?.getLiteralValue();
|
|
63
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export const FIGMA_IMAGE_LOADER_PATH = './figma-image-loader.ts';
|
|
4
|
+
const FIGMA_IMAGE_LOADER_CONTENT = `'use client'
|
|
5
|
+
|
|
6
|
+
// Generated by @payloadcms/figma. Do not edit.
|
|
7
|
+
export { figmaNextImageLoader as default } from '@payloadcms/figma/next-image-loader'
|
|
8
|
+
`;
|
|
9
|
+
export async function writeFigmaImageLoaderFile(projectPath) {
|
|
10
|
+
await fs.writeFile(path.join(projectPath, FIGMA_IMAGE_LOADER_PATH), FIGMA_IMAGE_LOADER_CONTENT);
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type PayloadGenerateResult = {
|
|
2
|
+
error: string;
|
|
3
|
+
ok: false;
|
|
4
|
+
} | {
|
|
5
|
+
ok: true;
|
|
6
|
+
};
|
|
7
|
+
/** Never throws. */
|
|
8
|
+
export declare function generateImportMap(projectPath: string): Promise<PayloadGenerateResult>;
|
|
9
|
+
/** Never throws. */
|
|
10
|
+
export declare function generateTypes(projectPath: string): Promise<PayloadGenerateResult>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import spawn from 'cross-spawn';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
// buildFigmaConfig throws without a resolvable environmentId/contentSystemId,
|
|
4
|
+
// which an unauthenticated init lacks. It reads these env vars before the
|
|
5
|
+
// bootstrap cache, so injecting them avoids the throw. Always inject the
|
|
6
|
+
// placeholder (not the real env) for deterministic behavior; the generated
|
|
7
|
+
// artifacts are ID-independent, so the value never affects output.
|
|
8
|
+
const GENERATE_PLACEHOLDER = 'figma-generate-placeholder';
|
|
9
|
+
/** Runs `payload <subcommand>` via the project's local binary. Never throws. */ function runPayloadGenerate(projectPath, subcommand) {
|
|
10
|
+
const bin = path.join(projectPath, 'node_modules', '.bin', 'payload');
|
|
11
|
+
return new Promise((resolve)=>{
|
|
12
|
+
const child = spawn(bin, [
|
|
13
|
+
subcommand
|
|
14
|
+
], {
|
|
15
|
+
cwd: projectPath,
|
|
16
|
+
env: {
|
|
17
|
+
...process.env,
|
|
18
|
+
FIGMA_CONTENT_API_CONTENT_SYSTEM_ID: GENERATE_PLACEHOLDER,
|
|
19
|
+
FIGMA_EID: GENERATE_PLACEHOLDER
|
|
20
|
+
},
|
|
21
|
+
stdio: 'pipe'
|
|
22
|
+
});
|
|
23
|
+
// Drain both pipes. An unread stdout buffer fills and blocks the child,
|
|
24
|
+
// hanging init; stdout also carries diagnostics on some failures.
|
|
25
|
+
let stderr = '';
|
|
26
|
+
let stdout = '';
|
|
27
|
+
child.stderr?.on('data', (data)=>{
|
|
28
|
+
stderr += data.toString();
|
|
29
|
+
});
|
|
30
|
+
child.stdout?.on('data', (data)=>{
|
|
31
|
+
stdout += data.toString();
|
|
32
|
+
});
|
|
33
|
+
child.on('close', (code)=>{
|
|
34
|
+
if (code === 0) {
|
|
35
|
+
resolve({
|
|
36
|
+
ok: true
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
const output = stderr.trim() || stdout.trim();
|
|
40
|
+
resolve({
|
|
41
|
+
error: output || `payload ${subcommand} exited with code ${code}`,
|
|
42
|
+
ok: false
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
child.on('error', (error)=>{
|
|
47
|
+
resolve({
|
|
48
|
+
error: error.message,
|
|
49
|
+
ok: false
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/** Never throws. */ export function generateImportMap(projectPath) {
|
|
55
|
+
return runPayloadGenerate(projectPath, 'generate:importmap');
|
|
56
|
+
}
|
|
57
|
+
/** Never throws. */ export function generateTypes(projectPath) {
|
|
58
|
+
return runPayloadGenerate(projectPath, 'generate:types');
|
|
59
|
+
}
|