@payloadcms/figma 0.1.0-alpha.1 → 0.1.0-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/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 +10 -9
- package/dist/api/control-plane.js +27 -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 +20 -1
- package/dist/auth/token-store.js +47 -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 +235 -80
- 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/upgrade.js +65 -1
- 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 +6 -2
- package/dist/db-content-api/index.d.ts +1 -1
- package/dist/db-content-api/index.js +121 -72
- package/dist/db-content-api/utilities/data/index.js +8 -2
- 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/removeVirtualFields.d.ts +3 -11
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +12 -50
- 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.js +5 -1
- 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.js +9 -4
- 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 +2 -6
- package/dist/db-content-api/utilities/where.js +20 -9
- 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 +13 -3
- package/dist/plugin/build-config.js +181 -36
- 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 +9 -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 +3 -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/api-types.d.ts +3 -0
- package/dist/storage-content-api/buildBaseMediaResponseHeaders.d.ts +1 -0
- package/dist/storage-content-api/buildBaseMediaResponseHeaders.js +8 -0
- package/dist/storage-content-api/buildClientUploadFetchBackHeaders.d.ts +12 -0
- package/dist/storage-content-api/buildClientUploadFetchBackHeaders.js +26 -0
- package/dist/storage-content-api/buildMediaRequestHeaders.d.ts +1 -0
- package/dist/storage-content-api/buildMediaRequestHeaders.js +14 -0
- package/dist/storage-content-api/buildMediaResponseHeaders.d.ts +4 -0
- package/dist/storage-content-api/buildMediaResponseHeaders.js +52 -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 +33 -0
- package/dist/storage-content-api/getMediaType.d.ts +1 -0
- package/dist/storage-content-api/getMediaType.js +3 -0
- package/dist/storage-content-api/hasSupportedContentEncoding.d.ts +1 -0
- package/dist/storage-content-api/hasSupportedContentEncoding.js +6 -0
- package/dist/storage-content-api/index.js +1 -0
- package/dist/storage-content-api/mediaErrorResponse.d.ts +1 -0
- package/dist/storage-content-api/mediaErrorResponse.js +12 -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/shouldAttachMedia.d.ts +1 -0
- package/dist/storage-content-api/shouldAttachMedia.js +34 -0
- package/dist/storage-content-api/staticHandler.js +93 -25
- 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/env-management.d.ts +15 -0
- package/dist/utils/env-management.js +47 -0
- package/dist/utils/lambda-config.js +18 -23
- 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-config-ast.js +5 -2
- package/dist/utils/payload-generate.d.ts +10 -0
- package/dist/utils/payload-generate.js +59 -0
- package/dist/utils/payload-secret.d.ts +28 -0
- package/dist/utils/payload-secret.js +34 -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 +33 -7
- 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
|
@@ -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:
|
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
|
+
}
|
|
@@ -88,7 +88,10 @@ import * as log from './log.js';
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
// Check for secret property
|
|
91
|
+
// Check for secret property. The platform owns PAYLOAD_SECRET, so the
|
|
92
|
+
// scaffolded `secret: process.env.PAYLOAD_SECRET` line is stripped —
|
|
93
|
+
// `buildFigmaConfig` injects the value at runtime from the env var (in
|
|
94
|
+
// Lambda) or the TokenStore cache (local dev).
|
|
92
95
|
const secretProperty = configArg.getProperty('secret');
|
|
93
96
|
if (secretProperty) {
|
|
94
97
|
result.secretProperty = true;
|
|
@@ -252,7 +255,7 @@ import * as log from './log.js';
|
|
|
252
255
|
modified = true;
|
|
253
256
|
}
|
|
254
257
|
}
|
|
255
|
-
// 2. Remove secret property
|
|
258
|
+
// 2. Remove secret property (platform-managed)
|
|
256
259
|
if (detection.secretProperty) {
|
|
257
260
|
const secretProperty = configArg.getProperty('secret');
|
|
258
261
|
if (secretProperty) {
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AuthCredential } from '../auth/credentials.js';
|
|
2
|
+
import type { TokenStore } from '../auth/token-store.js';
|
|
3
|
+
import type { ProjectStoreScope } from '../auth/types.js';
|
|
4
|
+
export declare const PAYLOAD_SECRET_ENV_VAR = "PAYLOAD_SECRET";
|
|
5
|
+
interface EnsurePayloadSecretArgs {
|
|
6
|
+
credential: AuthCredential;
|
|
7
|
+
projectInfo: ProjectStoreScope;
|
|
8
|
+
/** Fetch the current platform value even when cached, preserving the cache on failure. */
|
|
9
|
+
refresh?: boolean;
|
|
10
|
+
tenantInstanceId: string;
|
|
11
|
+
tokenStore: TokenStore;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the tenant's PAYLOAD_SECRET and cache it in the encrypted
|
|
15
|
+
* TokenStore. The secret is intentionally NOT written to `.env`: keeping it
|
|
16
|
+
* only in the machine-scoped, AES-256-GCM-encrypted store avoids the
|
|
17
|
+
* plaintext-on-disk / accidental-exfiltration risks of a project-local file.
|
|
18
|
+
* `buildFigmaConfig` reads it back from the TokenStore at dev/build time.
|
|
19
|
+
*
|
|
20
|
+
* The Figma platform owns PAYLOAD_SECRET rotation; this helper never
|
|
21
|
+
* generates or mutates the value — it only fetches whatever the Control
|
|
22
|
+
* Plane currently returns and caches it.
|
|
23
|
+
*
|
|
24
|
+
* Non-fatal on failure: callers should catch and log rather than abort init,
|
|
25
|
+
* so the sinatra endpoint rollout can lag the CLI.
|
|
26
|
+
*/
|
|
27
|
+
export declare function ensurePayloadSecret({ credential, projectInfo, refresh, tenantInstanceId, tokenStore, }: EnsurePayloadSecretArgs): Promise<string>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getEnvironmentVariableByName } from '../api/control-plane.js';
|
|
2
|
+
import * as log from './log.js';
|
|
3
|
+
export const PAYLOAD_SECRET_ENV_VAR = 'PAYLOAD_SECRET';
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the tenant's PAYLOAD_SECRET and cache it in the encrypted
|
|
6
|
+
* TokenStore. The secret is intentionally NOT written to `.env`: keeping it
|
|
7
|
+
* only in the machine-scoped, AES-256-GCM-encrypted store avoids the
|
|
8
|
+
* plaintext-on-disk / accidental-exfiltration risks of a project-local file.
|
|
9
|
+
* `buildFigmaConfig` reads it back from the TokenStore at dev/build time.
|
|
10
|
+
*
|
|
11
|
+
* The Figma platform owns PAYLOAD_SECRET rotation; this helper never
|
|
12
|
+
* generates or mutates the value — it only fetches whatever the Control
|
|
13
|
+
* Plane currently returns and caches it.
|
|
14
|
+
*
|
|
15
|
+
* Non-fatal on failure: callers should catch and log rather than abort init,
|
|
16
|
+
* so the sinatra endpoint rollout can lag the CLI.
|
|
17
|
+
*/ export async function ensurePayloadSecret({ credential, projectInfo, refresh = false, tenantInstanceId, tokenStore }) {
|
|
18
|
+
const cached = tokenStore.getPayloadSecret({
|
|
19
|
+
projectInfo
|
|
20
|
+
});
|
|
21
|
+
if (cached && !refresh) {
|
|
22
|
+
return cached;
|
|
23
|
+
}
|
|
24
|
+
const secret = await getEnvironmentVariableByName(credential, tenantInstanceId, PAYLOAD_SECRET_ENV_VAR);
|
|
25
|
+
if (!secret) {
|
|
26
|
+
throw new Error('Control Plane returned an empty PAYLOAD_SECRET');
|
|
27
|
+
}
|
|
28
|
+
tokenStore.setPayloadSecret({
|
|
29
|
+
projectInfo,
|
|
30
|
+
secret
|
|
31
|
+
});
|
|
32
|
+
log.debug(`Cached PAYLOAD_SECRET for ${projectInfo.projectId}:${projectInfo.environmentName}`);
|
|
33
|
+
return secret;
|
|
34
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write init's pnpm-workspace.yaml: hoisted node linker (the Lambda runtime needs a
|
|
3
|
+
* flat node_modules) plus build approvals, migrating off the now-ignored package.json
|
|
4
|
+
* `pnpm.onlyBuiltDependencies`. Written for every project so an npx/npm scaffold still
|
|
5
|
+
* installs cleanly when the user later switches to pnpm.
|
|
6
|
+
*/
|
|
7
|
+
export declare function ensurePnpmWorkspace(projectPath: string): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Set each build `true` under `allowBuilds` and drop it from any `ignoredBuiltDependencies`
|
|
10
|
+
* denylist. Pure and idempotent. pnpm v11 reads approvals only from pnpm-workspace.yaml.
|
|
11
|
+
*/
|
|
12
|
+
export declare function upsertBuildApprovals(content: string, builds: string[]): string;
|
|
13
|
+
/** Set a top-level `key: value` scalar, replacing any existing one. Pure and idempotent. */
|
|
14
|
+
export declare function upsertTopLevelScalar(content: string, key: string, value: string): string;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
/** Fallback builds when package.json declares none. */ const DEFAULT_BUILDS = [
|
|
4
|
+
'sharp',
|
|
5
|
+
'esbuild',
|
|
6
|
+
'unrs-resolver'
|
|
7
|
+
];
|
|
8
|
+
/**
|
|
9
|
+
* Write init's pnpm-workspace.yaml: hoisted node linker (the Lambda runtime needs a
|
|
10
|
+
* flat node_modules) plus build approvals, migrating off the now-ignored package.json
|
|
11
|
+
* `pnpm.onlyBuiltDependencies`. Written for every project so an npx/npm scaffold still
|
|
12
|
+
* installs cleanly when the user later switches to pnpm.
|
|
13
|
+
*/ export async function ensurePnpmWorkspace(projectPath) {
|
|
14
|
+
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
15
|
+
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));
|
|
16
|
+
const pnpmField = packageJson.pnpm;
|
|
17
|
+
const configured = pnpmField?.onlyBuiltDependencies;
|
|
18
|
+
const builds = configured && configured.length > 0 ? configured : DEFAULT_BUILDS;
|
|
19
|
+
const workspacePath = path.join(projectPath, 'pnpm-workspace.yaml');
|
|
20
|
+
let yaml = '';
|
|
21
|
+
try {
|
|
22
|
+
yaml = await fs.readFile(workspacePath, 'utf-8');
|
|
23
|
+
} catch (error) {
|
|
24
|
+
// Rethrow on a present-but-unreadable file; the write below would clobber it.
|
|
25
|
+
if (error.code !== 'ENOENT') {
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
yaml = upsertTopLevelScalar(yaml, 'nodeLinker', 'hoisted');
|
|
30
|
+
yaml = upsertBuildApprovals(yaml, builds);
|
|
31
|
+
await fs.writeFile(workspacePath, yaml, 'utf-8');
|
|
32
|
+
if (pnpmField) {
|
|
33
|
+
delete pnpmField.onlyBuiltDependencies;
|
|
34
|
+
if (Object.keys(pnpmField).length === 0) {
|
|
35
|
+
delete packageJson.pnpm;
|
|
36
|
+
}
|
|
37
|
+
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n', 'utf-8');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Set each build `true` under `allowBuilds` and drop it from any `ignoredBuiltDependencies`
|
|
42
|
+
* denylist. Pure and idempotent. pnpm v11 reads approvals only from pnpm-workspace.yaml.
|
|
43
|
+
*/ export function upsertBuildApprovals(content, builds) {
|
|
44
|
+
const blocks = toTopLevelBlocks(content);
|
|
45
|
+
const ignored = blocks.find((block)=>block.key === 'ignoredBuiltDependencies');
|
|
46
|
+
if (ignored) {
|
|
47
|
+
ignored.lines = ignored.lines.filter((line, index)=>{
|
|
48
|
+
if (index === 0) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
const name = /^\s*-\s*'?([^'\s]+)'?\s*$/.exec(line)?.[1];
|
|
52
|
+
return !(name && builds.includes(name));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const allow = blocks.find((block)=>block.key === 'allowBuilds');
|
|
56
|
+
if (allow) {
|
|
57
|
+
for (const name of builds){
|
|
58
|
+
const pattern = new RegExp(`^\\s+'?${escapeRegExp(name)}'?:`);
|
|
59
|
+
const index = allow.lines.findIndex((line)=>pattern.test(line));
|
|
60
|
+
if (index >= 0) {
|
|
61
|
+
allow.lines[index] = ` ${name}: true`;
|
|
62
|
+
} else {
|
|
63
|
+
allow.lines.push(` ${name}: true`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
blocks.push({
|
|
68
|
+
key: 'allowBuilds',
|
|
69
|
+
lines: [
|
|
70
|
+
'allowBuilds:',
|
|
71
|
+
...builds.map((name)=>` ${name}: true`)
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const output = blocks.flatMap((block)=>block.lines).join('\n');
|
|
76
|
+
return output.endsWith('\n') ? output : `${output}\n`;
|
|
77
|
+
}
|
|
78
|
+
/** Set a top-level `key: value` scalar, replacing any existing one. Pure and idempotent. */ export function upsertTopLevelScalar(content, key, value) {
|
|
79
|
+
const blocks = toTopLevelBlocks(content);
|
|
80
|
+
const line = `${key}: ${value}`;
|
|
81
|
+
const existing = blocks.find((block)=>block.key === key);
|
|
82
|
+
if (existing) {
|
|
83
|
+
existing.lines = [
|
|
84
|
+
line
|
|
85
|
+
];
|
|
86
|
+
} else {
|
|
87
|
+
blocks.push({
|
|
88
|
+
key,
|
|
89
|
+
lines: [
|
|
90
|
+
line
|
|
91
|
+
]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
const output = blocks.flatMap((block)=>block.lines).join('\n');
|
|
95
|
+
return output.endsWith('\n') ? output : `${output}\n`;
|
|
96
|
+
}
|
|
97
|
+
function toTopLevelBlocks(content) {
|
|
98
|
+
const lines = content.length ? content.replace(/\n$/, '').split('\n') : [];
|
|
99
|
+
const blocks = [];
|
|
100
|
+
for (const line of lines){
|
|
101
|
+
const key = /^[^\s#]/.test(line) ? /^([^:]+):/.exec(line)?.[1] : undefined;
|
|
102
|
+
const current = blocks[blocks.length - 1];
|
|
103
|
+
if (key !== undefined) {
|
|
104
|
+
blocks.push({
|
|
105
|
+
key,
|
|
106
|
+
lines: [
|
|
107
|
+
line
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
} else if (current) {
|
|
111
|
+
current.lines.push(line);
|
|
112
|
+
} else {
|
|
113
|
+
blocks.push({
|
|
114
|
+
key: null,
|
|
115
|
+
lines: [
|
|
116
|
+
line
|
|
117
|
+
]
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return blocks;
|
|
122
|
+
}
|
|
123
|
+
function escapeRegExp(value) {
|
|
124
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
125
|
+
}
|
package/dist/utils/s3-upload.js
CHANGED
|
@@ -141,16 +141,19 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
|
|
|
141
141
|
const fsPath = pathMap?.[assetPath] ?? assetPath.replace(/^_next\//, '.next/');
|
|
142
142
|
const fullPath = path.join(projectPath, fsPath);
|
|
143
143
|
const signedUrl = assetUrls[assetPath];
|
|
144
|
-
|
|
144
|
+
const contentType = MIME_TYPES[path.extname(assetPath).toLowerCase()];
|
|
145
|
+
await uploadFile(fullPath, signedUrl, contentType);
|
|
145
146
|
results.assetsUploaded++;
|
|
146
147
|
// Track bytes uploaded
|
|
147
148
|
const stats = await fs.stat(fullPath);
|
|
148
149
|
results.totalBytesUploaded += stats.size;
|
|
149
150
|
// Report progress
|
|
150
151
|
onProgress?.(results.assetsUploaded, assetPaths.length);
|
|
152
|
+
return undefined;
|
|
151
153
|
} catch (error) {
|
|
152
154
|
results.assetsFailed++;
|
|
153
155
|
log.debug(`Failed to upload ${assetPath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
156
|
+
return undefined;
|
|
154
157
|
}
|
|
155
158
|
}));
|
|
156
159
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/figma",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.11",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -13,6 +13,16 @@
|
|
|
13
13
|
"import": "./dist/exports/client.js",
|
|
14
14
|
"types": "./dist/exports/client.d.ts",
|
|
15
15
|
"default": "./dist/exports/client.js"
|
|
16
|
+
},
|
|
17
|
+
"./next-image-loader": {
|
|
18
|
+
"import": "./dist/next/image-loader.js",
|
|
19
|
+
"types": "./dist/next/image-loader.d.ts",
|
|
20
|
+
"default": "./dist/next/image-loader.js"
|
|
21
|
+
},
|
|
22
|
+
"./views": {
|
|
23
|
+
"import": "./dist/exports/views.js",
|
|
24
|
+
"types": "./dist/exports/views.d.ts",
|
|
25
|
+
"default": "./dist/exports/views.js"
|
|
16
26
|
}
|
|
17
27
|
},
|
|
18
28
|
"main": "./dist/index.js",
|
|
@@ -28,12 +38,14 @@
|
|
|
28
38
|
],
|
|
29
39
|
"dependencies": {
|
|
30
40
|
"@clack/prompts": "^0.11.0",
|
|
41
|
+
"@cloudflare/workers-types": "5.20260716.1",
|
|
31
42
|
"@figma/rest-api-spec": "^0.34.0",
|
|
32
43
|
"@sindresorhus/slugify": "^3.0.0",
|
|
33
44
|
"archiver": "7.0.1",
|
|
34
45
|
"arg": "^5.0.2",
|
|
35
46
|
"conf": "^13.1.0",
|
|
36
47
|
"cross-spawn": "7.0.6",
|
|
48
|
+
"dotenv": "^16.4.5",
|
|
37
49
|
"env-paths": "^3.0.0",
|
|
38
50
|
"figures": "^6.1.0",
|
|
39
51
|
"jose": "6.0.12",
|
|
@@ -41,7 +53,10 @@
|
|
|
41
53
|
"open": "^10.2.0",
|
|
42
54
|
"openapi-fetch": "0.15.0",
|
|
43
55
|
"picocolors": "1.1.1",
|
|
44
|
-
"
|
|
56
|
+
"qs-esm": "^8.0.1",
|
|
57
|
+
"sanitize-filename": "^1.6.4",
|
|
58
|
+
"skills": "1.4.4",
|
|
59
|
+
"tar": "^7.5.21",
|
|
45
60
|
"terminal-link": "^5.0.0",
|
|
46
61
|
"ts-morph": "^21.0.1",
|
|
47
62
|
"uuid": "^10.0.0"
|
|
@@ -49,26 +64,35 @@
|
|
|
49
64
|
"devDependencies": {
|
|
50
65
|
"@payloadcms/eslint-config": "3.28.0",
|
|
51
66
|
"@payloadcms/eslint-plugin": "3.28.0",
|
|
52
|
-
"@payloadcms/next": "4.0.0-canary.
|
|
67
|
+
"@payloadcms/next": "4.0.0-canary.37",
|
|
68
|
+
"@payloadcms/plugin-cloud-storage": "4.0.0-canary.37",
|
|
69
|
+
"@payloadcms/richtext-lexical": "4.0.0-canary.37",
|
|
70
|
+
"@payloadcms/translations": "4.0.0-canary.37",
|
|
71
|
+
"@payloadcms/ui": "4.0.0-canary.37",
|
|
53
72
|
"@swc/cli": "0.7.7",
|
|
54
73
|
"@types/archiver": "7.0.0",
|
|
55
74
|
"@types/cross-spawn": "6.0.6",
|
|
56
75
|
"@types/jsonwebtoken": "^9.0.10",
|
|
57
76
|
"@types/node": "^24.0.0",
|
|
77
|
+
"@types/react": "^19",
|
|
58
78
|
"@types/uuid": "^8.3.4",
|
|
59
79
|
"copyfiles": "^2.4.1",
|
|
60
80
|
"eslint": "9.22.0",
|
|
61
|
-
"next": "^16.
|
|
81
|
+
"next": "^16.3.3",
|
|
62
82
|
"openapi-typescript": "^7.13.0",
|
|
83
|
+
"payload": "4.0.0-canary.37",
|
|
63
84
|
"rimraf": "^6.1.3",
|
|
64
85
|
"tsx": "4.20.6",
|
|
65
86
|
"typescript": "5.7.3",
|
|
66
87
|
"vitest": "4.0.15"
|
|
67
88
|
},
|
|
68
89
|
"peerDependencies": {
|
|
69
|
-
"@payloadcms/plugin-cloud-storage": ">=4.0.0-canary.
|
|
70
|
-
"@payloadcms/richtext-lexical": ">=4.0.0-canary.
|
|
71
|
-
"
|
|
90
|
+
"@payloadcms/plugin-cloud-storage": ">=4.0.0-canary.37 <4.0.0-internal",
|
|
91
|
+
"@payloadcms/richtext-lexical": ">=4.0.0-canary.37 <4.0.0-internal",
|
|
92
|
+
"@payloadcms/translations": ">=4.0.0-canary.37 <4.0.0-internal",
|
|
93
|
+
"@payloadcms/ui": ">=4.0.0-canary.37 <4.0.0-internal",
|
|
94
|
+
"payload": ">=4.0.0-canary.37 <4.0.0-internal",
|
|
95
|
+
"react": "^19.0.1 || ^19.1.2 || ^19.2.1"
|
|
72
96
|
},
|
|
73
97
|
"peerDependenciesMeta": {
|
|
74
98
|
"@payloadcms/plugin-cloud-storage": {
|
|
@@ -97,12 +121,14 @@
|
|
|
97
121
|
"generate:types": "tsx scripts/generate-types.ts",
|
|
98
122
|
"lint": "eslint .",
|
|
99
123
|
"lint:fix": "eslint . --fix",
|
|
124
|
+
"payload:cli": "tsx scripts/payload-cli.ts",
|
|
100
125
|
"start": "pnpm build && node ./bin/cli.js",
|
|
101
126
|
"test": "TEST_UNIT=true vitest run",
|
|
102
127
|
"test:int": "TEST_INT=true vitest run --config vitest.config.int.ts",
|
|
103
128
|
"test:int:watch": "TEST_INT=true vitest --config vitest.config.int.ts",
|
|
104
129
|
"test:e2e": "TEST_E2E=true vitest run --config vitest.config.e2e.ts",
|
|
105
130
|
"test:e2e:watch": "TEST_E2E=true vitest --config vitest.config.e2e.ts",
|
|
131
|
+
"test:types": "tsc --project tsconfig.imageSizeOptions.json",
|
|
106
132
|
"test:watch": "TEST_UNIT=true vitest"
|
|
107
133
|
}
|
|
108
134
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type DownloadSkillResult = {
|
|
2
|
-
detail?: string;
|
|
3
|
-
ok: false;
|
|
4
|
-
reason: 'already-installed' | 'empty-extract' | 'error' | 'fetch-failed';
|
|
5
|
-
} | {
|
|
6
|
-
ok: true;
|
|
7
|
-
};
|
|
8
|
-
export declare function downloadSkill(args: {
|
|
9
|
-
branch?: string;
|
|
10
|
-
debug?: boolean;
|
|
11
|
-
projectDir: string;
|
|
12
|
-
}): Promise<DownloadSkillResult>;
|