@payloadcms/figma 0.1.0-internal.e071575 → 0.1.0-internal.fbdc0d3
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 +12 -9
- package/dist/api/control-plane.js +28 -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 +73 -0
- package/dist/auth/oauth-flow.d.ts +2 -0
- package/dist/auth/oauth-flow.js +30 -8
- package/dist/auth/refresh.js +12 -12
- package/dist/auth/requested-scopes.d.ts +1 -0
- package/dist/auth/requested-scopes.js +3 -0
- package/dist/auth/token-store.d.ts +20 -1
- package/dist/auth/token-store.js +47 -0
- package/dist/auth/types.d.ts +17 -3
- package/dist/cli.d.ts +39 -0
- package/dist/cli.js +71 -36
- package/dist/commands/bootstrap.js +5 -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/upload-schema.js +3 -4
- package/dist/commands/write-project-configuration.d.ts +12 -0
- package/dist/commands/write-project-configuration.js +16 -0
- package/dist/config/oauth.js +6 -1
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +0 -3
- 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 +250 -49
- 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 +22 -20
- package/dist/plugin/sandbox-upload-fetch.js +15 -21
- 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 +5 -2
- 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.d.ts +7 -3
- package/dist/storage-content-api/client-uploads/generate.js +22 -21
- package/dist/storage-content-api/copyFile.d.ts +16 -0
- package/dist/storage-content-api/copyFile.js +90 -0
- package/dist/storage-content-api/deleteFile.d.ts +8 -0
- package/dist/storage-content-api/deleteFile.js +18 -0
- 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/handleUpload.d.ts +1 -2
- package/dist/storage-content-api/handleUpload.js +13 -157
- 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 +17 -8
- 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.d.ts +2 -1
- package/dist/storage-content-api/staticHandler.js +87 -32
- package/dist/storage-content-api/types.d.ts +4 -1
- package/dist/storage-content-api/uploadFileData.d.ts +10 -0
- package/dist/storage-content-api/uploadFileData.js +145 -0
- 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/cache-bootstrap.js +1 -0
- 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/load-payload-config.js +1 -6
- 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.d.ts +5 -0
- package/dist/utils/payload-config-ast.js +73 -4
- package/dist/utils/payload-config-modifier.js +3 -0
- 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 -8
- package/dist/lib/download-skill.d.ts +0 -12
- package/dist/lib/download-skill.js +0 -77
- package/dist/storage-content-api/handleDelete.d.ts +0 -7
- package/dist/storage-content-api/handleDelete.js +0 -15
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +0 -11
- package/dist/storage-content-api/utilities/getSafeFilename.js +0 -59
- package/dist/storage-content-api/utilities/index.d.ts +0 -2
- package/dist/storage-content-api/utilities/index.js +0 -2
- package/dist/storage-content-api/utilities/parseUploadReference.d.ts +0 -17
- package/dist/storage-content-api/utilities/parseUploadReference.js +0 -27
- 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/commands/init.js
CHANGED
|
@@ -2,41 +2,115 @@ import * as p from '@clack/prompts';
|
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import pc from 'picocolors';
|
|
5
|
-
import {
|
|
5
|
+
import { getBootstrapInfo } from '../api/control-plane.js';
|
|
6
|
+
import { ControlPlaneError } from '../api/control-plane-error.js';
|
|
6
7
|
import { FigmaApiError } from '../api/figma-api.js';
|
|
7
8
|
import { tryGetCredential } from '../auth/oauth-flow.js';
|
|
8
9
|
import { getValidProjectToken, ProjectTokenError } from '../auth/project-token.js';
|
|
9
10
|
import { getTokenStore } from '../auth/token-store.js';
|
|
10
11
|
import { getInfraEnvironment, getProjectNotFoundMessage } from '../constants.js';
|
|
11
|
-
import {
|
|
12
|
+
import { writeAgentConfigFiles } from '../lib/write-agent-config.js';
|
|
12
13
|
import { ensureGitignore } from '../utils/config.js';
|
|
13
|
-
import { addOrUpdateEnvVar } from '../utils/env-management.js';
|
|
14
|
+
import { addOrUpdateEnvVar, commentOutEnvVar, removeEnvVar } from '../utils/env-management.js';
|
|
14
15
|
import { isDebug } from '../utils/is-debug.js';
|
|
15
16
|
import { applyLambdaModifications } from '../utils/lambda-config.js';
|
|
16
17
|
import * as log from '../utils/log.js';
|
|
17
18
|
import { detectPackageManagerFromEnvironment, getRunCommand, resolvePackageManager } from '../utils/package-manager.js';
|
|
18
19
|
import { displayManualInstructions, ensurePayloadFigmaConfig } from '../utils/payload-config-modifier.js';
|
|
20
|
+
import { generateImportMap, generateTypes } from '../utils/payload-generate.js';
|
|
21
|
+
import { ensurePnpmWorkspace } from '../utils/pnpm-builds.js';
|
|
19
22
|
import { detectPayloadProject, hasRequiredDependencies, initializeGitRepo, installDependencies, isInProjectDirectory, scaffoldProject, validatePayloadVersion } from '../utils/project.js';
|
|
20
23
|
import { resolveEnvironment } from '../utils/resolve-environment.js';
|
|
21
24
|
import { checkForUpdates, getOwnVersion } from '../utils/version-check.js';
|
|
25
|
+
import { detectProjectResourceType } from './detect-project-resource-type.js';
|
|
22
26
|
import { loginCommand } from './login.js';
|
|
27
|
+
import { promptToCreateProject } from './prompt-to-create-project.js';
|
|
28
|
+
import { writeProjectConfiguration } from './write-project-configuration.js';
|
|
23
29
|
import { cacheAllEnvironments } from '../utils/cache-bootstrap.js';
|
|
24
30
|
import { DEFAULT_TEMPLATE_SOURCE } from '../utils/download-template.js';
|
|
25
31
|
import { parseTemplateSpec, TemplateSpecParseError } from '../utils/parse-template-spec.js';
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
import { ensurePayloadSecret } from '../utils/payload-secret.js';
|
|
33
|
+
async function removePayloadSecretFromEnv(projectDir) {
|
|
34
|
+
// New-project flow: the scaffold owns .env, so any PAYLOAD_SECRET carried
|
|
35
|
+
// over from a template is not a value the developer set. Remove it
|
|
36
|
+
// outright to keep the scaffolded file clean.
|
|
37
|
+
const removed = await removeEnvVar(projectDir, 'PAYLOAD_SECRET');
|
|
38
|
+
if (!removed) {
|
|
28
39
|
return;
|
|
29
40
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
p.log.warn(pc.yellow('⚠ Removed PAYLOAD_SECRET from .env. The Figma platform owns this value; a local ' + 'copy would silently diverge from the deployed secret and cause encrypted data ' + '(API keys, auth tokens) to fail decryption in production.'));
|
|
42
|
+
}
|
|
43
|
+
async function commentOutPayloadSecretInEnv(projectDir) {
|
|
44
|
+
// Existing-project flow: the developer's .env may hold a PAYLOAD_SECRET
|
|
45
|
+
// they need for another system or environment. Comment out rather than
|
|
46
|
+
// delete so the value survives and they can uncomment / relocate it.
|
|
47
|
+
const changed = await commentOutEnvVar(projectDir, 'PAYLOAD_SECRET', 'disabled by @payloadcms/figma: platform owns PAYLOAD_SECRET');
|
|
48
|
+
if (!changed) {
|
|
34
49
|
return;
|
|
35
50
|
}
|
|
36
|
-
|
|
51
|
+
p.log.warn(pc.yellow('⚠ Commented out PAYLOAD_SECRET in .env. The Figma platform owns this value; a ' + 'local copy would silently diverge from the deployed secret and cause encrypted ' + 'data (API keys, auth tokens) to fail decryption in production.'));
|
|
52
|
+
}
|
|
53
|
+
async function maybeEnsurePayloadSecret(args) {
|
|
54
|
+
if (!args.credential || !args.resolvedEnv) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
await ensurePayloadSecret({
|
|
59
|
+
credential: args.credential,
|
|
60
|
+
projectInfo: {
|
|
61
|
+
environmentName: args.resolvedEnv.name,
|
|
62
|
+
projectId: args.cmsResourceId
|
|
63
|
+
},
|
|
64
|
+
tenantInstanceId: args.resolvedEnv.tenantInstanceId,
|
|
65
|
+
tokenStore: args.tokenStore,
|
|
66
|
+
// Re-init is the explicit recovery path after platform secret rotation.
|
|
67
|
+
refresh: true
|
|
68
|
+
});
|
|
69
|
+
log.debug('PAYLOAD_SECRET cached in TokenStore');
|
|
70
|
+
return true;
|
|
71
|
+
} catch (err) {
|
|
72
|
+
// Preserve the existing cache and .env fallback until a refresh succeeds.
|
|
73
|
+
const message = err instanceof Error ? err.message : 'Unknown error';
|
|
74
|
+
p.log.warn(pc.yellow(`⚠ Could not fetch PAYLOAD_SECRET (${message}). Existing secrets were preserved. Re-run init to retry.`));
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function maybeWriteAgentConfigFiles(args) {
|
|
79
|
+
if (args.noAgent) {
|
|
37
80
|
return;
|
|
38
81
|
}
|
|
39
|
-
|
|
82
|
+
try {
|
|
83
|
+
await writeAgentConfigFiles({
|
|
84
|
+
projectDir: args.projectDir
|
|
85
|
+
});
|
|
86
|
+
} catch (err) {
|
|
87
|
+
p.log.warn(pc.yellow(`⚠ Could not write AI agent config (${err instanceof Error ? err.message : String(err)}). Continuing.`));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** Generate the admin import map and Payload types so the scaffold builds clean. */ async function runProjectCodegen(args) {
|
|
91
|
+
await runPayloadGenerate({
|
|
92
|
+
...args,
|
|
93
|
+
artifact: 'import map',
|
|
94
|
+
command: 'generate:importmap',
|
|
95
|
+
generate: generateImportMap
|
|
96
|
+
});
|
|
97
|
+
await runPayloadGenerate({
|
|
98
|
+
...args,
|
|
99
|
+
artifact: 'types',
|
|
100
|
+
command: 'generate:types',
|
|
101
|
+
generate: generateTypes
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/** Non-fatal: on failure, warn with the command to run later. */ async function runPayloadGenerate(args) {
|
|
105
|
+
args.spinner.start(`Generating ${args.artifact}...`);
|
|
106
|
+
const result = await args.generate(args.projectDir);
|
|
107
|
+
const capitalized = args.artifact.charAt(0).toUpperCase() + args.artifact.slice(1);
|
|
108
|
+
if (result.ok) {
|
|
109
|
+
args.spinner.stop(pc.green(`✓ ${capitalized} generated`));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
args.spinner.stop(pc.yellow(`⚠ Could not generate ${args.artifact}`));
|
|
113
|
+
p.log.warn(pc.yellow(`Run '${getRunCommand(args.packageManager)} ${args.command}' later. ${result.error}`));
|
|
40
114
|
}
|
|
41
115
|
/**
|
|
42
116
|
* Generate and store project token for a content system
|
|
@@ -94,6 +168,7 @@ async function maybeInstallPayloadSkill(args) {
|
|
|
94
168
|
// Check authentication
|
|
95
169
|
const tokenStore = getTokenStore();
|
|
96
170
|
const s = p.spinner();
|
|
171
|
+
let credential = null;
|
|
97
172
|
if (options.skipAuth) {
|
|
98
173
|
// Skip authentication for testing/development
|
|
99
174
|
p.log.warn(pc.yellow('Skipping authentication (--skip-auth mode)'));
|
|
@@ -102,14 +177,14 @@ async function maybeInstallPayloadSkill(args) {
|
|
|
102
177
|
if (!tokenStore.hasValidOauthToken()) {
|
|
103
178
|
// Need to refresh or authenticate - show spinner for API call
|
|
104
179
|
s.start('Checking authentication...');
|
|
105
|
-
|
|
180
|
+
credential = await tryGetCredential(tokenStore);
|
|
106
181
|
if (!credential) {
|
|
107
182
|
s.stop('Authentication required to continue');
|
|
108
183
|
await loginCommand({
|
|
109
184
|
showNextSteps: false
|
|
110
185
|
});
|
|
111
|
-
|
|
112
|
-
if (!
|
|
186
|
+
credential = await tryGetCredential(tokenStore);
|
|
187
|
+
if (!credential) {
|
|
113
188
|
p.log.error('Authentication failed');
|
|
114
189
|
process.exit(1);
|
|
115
190
|
}
|
|
@@ -118,16 +193,12 @@ async function maybeInstallPayloadSkill(args) {
|
|
|
118
193
|
}
|
|
119
194
|
}
|
|
120
195
|
}
|
|
196
|
+
if (!options.skipAuth && !credential) {
|
|
197
|
+
credential = await tryGetCredential(tokenStore);
|
|
198
|
+
}
|
|
121
199
|
// Note: We no longer check for figma.config.json here
|
|
122
200
|
// Instead, the AST detection will check if figma object already exists in payload.config.ts
|
|
123
201
|
// and skip modification if it does (unless --force is used)
|
|
124
|
-
// Step 3: Get CMS Resource ID (required argument)
|
|
125
|
-
log.debug('Configuring Project...');
|
|
126
|
-
if (!options.id) {
|
|
127
|
-
p.log.error('CMS Resource ID is required. Use --id <cms-resource-id>');
|
|
128
|
-
process.exit(1);
|
|
129
|
-
}
|
|
130
|
-
const cmsResourceId = options.id;
|
|
131
202
|
// Parse --template spec early so malformed values abort before any I/O
|
|
132
203
|
let templateSource;
|
|
133
204
|
if (options.template) {
|
|
@@ -140,13 +211,95 @@ async function maybeInstallPayloadSkill(args) {
|
|
|
140
211
|
process.exit(1);
|
|
141
212
|
}
|
|
142
213
|
}
|
|
214
|
+
// Step 3: Resolve or create the CMS project
|
|
215
|
+
log.debug('Configuring Project...');
|
|
216
|
+
const hasPackageJson = await isInProjectDirectory();
|
|
217
|
+
const resourceType = await detectProjectResourceType();
|
|
218
|
+
const isInProject = hasPackageJson || resourceType === 'vite';
|
|
219
|
+
let projectDirectory = process.cwd();
|
|
220
|
+
if (isInProject && resourceType !== 'vite' && !options.id) {
|
|
221
|
+
const projectInfo = await detectPayloadProject();
|
|
222
|
+
if (!projectInfo.hasPayload) {
|
|
223
|
+
p.log.warn(pc.yellow('⚠ Payload was not detected in this project'));
|
|
224
|
+
p.note('Run this command in a directory without an existing project or in an existing Payload project.', 'Action Required');
|
|
225
|
+
process.exit(1);
|
|
226
|
+
}
|
|
227
|
+
if (projectInfo.payloadVersion && !validatePayloadVersion(projectInfo.payloadVersion)) {
|
|
228
|
+
p.log.warn(pc.yellow(`Payload version ${projectInfo.payloadVersion} detected. Version 4.x or newer is required.`));
|
|
229
|
+
p.note('Upgrade to Payload 4.x or newer before continuing', 'Action Required');
|
|
230
|
+
process.exit(1);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (!isInProject) {
|
|
234
|
+
let projectPath;
|
|
235
|
+
if (options.name) {
|
|
236
|
+
projectPath = options.name;
|
|
237
|
+
} else {
|
|
238
|
+
const projectPathInput = await p.text({
|
|
239
|
+
initialValue: './',
|
|
240
|
+
message: 'Enter path to create project:',
|
|
241
|
+
placeholder: './my-cms-project',
|
|
242
|
+
validate: (value)=>{
|
|
243
|
+
if (!value) {
|
|
244
|
+
return 'Path is required';
|
|
245
|
+
}
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
if (p.isCancel(projectPathInput)) {
|
|
250
|
+
p.cancel('Operation cancelled');
|
|
251
|
+
process.exit(0);
|
|
252
|
+
}
|
|
253
|
+
projectPath = projectPathInput;
|
|
254
|
+
}
|
|
255
|
+
projectDirectory = path.resolve(process.cwd(), projectPath);
|
|
256
|
+
const projectName = path.basename(projectDirectory);
|
|
257
|
+
const packageManager = detectPackageManagerFromEnvironment();
|
|
258
|
+
try {
|
|
259
|
+
await fs.mkdir(projectDirectory, {
|
|
260
|
+
recursive: true
|
|
261
|
+
});
|
|
262
|
+
} catch (error) {
|
|
263
|
+
p.log.error(`Failed to create directory: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
264
|
+
process.exit(1);
|
|
265
|
+
}
|
|
266
|
+
const resolvedSource = {
|
|
267
|
+
...DEFAULT_TEMPLATE_SOURCE,
|
|
268
|
+
...templateSource
|
|
269
|
+
};
|
|
270
|
+
s.start(`Downloading template "${resolvedSource.templatePath}" from ` + `${resolvedSource.owner}/${resolvedSource.repo}@${resolvedSource.ref}...`);
|
|
271
|
+
try {
|
|
272
|
+
await scaffoldProject(projectDirectory, projectName, packageManager, templateSource, options.payloadVersion);
|
|
273
|
+
s.stop(pc.green('✓ Template downloaded'));
|
|
274
|
+
s.start('Installing dependencies...');
|
|
275
|
+
await installDependencies(projectDirectory, packageManager);
|
|
276
|
+
s.stop(pc.green('✓ Dependencies installed'));
|
|
277
|
+
} catch (error) {
|
|
278
|
+
s.stop(pc.red('✗ Failed'));
|
|
279
|
+
log.error(error instanceof Error ? error.message : 'Unknown error');
|
|
280
|
+
process.exit(1);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
let cmsResourceId = options.id;
|
|
284
|
+
if (!cmsResourceId) {
|
|
285
|
+
if (!credential) {
|
|
286
|
+
p.log.error('Authentication is required to create a project');
|
|
287
|
+
process.exit(1);
|
|
288
|
+
}
|
|
289
|
+
const createdProject = await promptToCreateProject({
|
|
290
|
+
credential,
|
|
291
|
+
projectPath: projectDirectory,
|
|
292
|
+
resourceType
|
|
293
|
+
});
|
|
294
|
+
cmsResourceId = createdProject.id;
|
|
295
|
+
await addOrUpdateEnvVar(projectDirectory, 'FIGMA_PROJECT_ID', cmsResourceId);
|
|
296
|
+
}
|
|
143
297
|
// Fetch bootstrap info (oauth creds + environments)
|
|
144
298
|
let bootstrapInfo = null;
|
|
145
299
|
let resolvedEnv = null;
|
|
146
300
|
let oauthClientId = null;
|
|
147
301
|
let oauthClientSecret = null;
|
|
148
302
|
if (!options.skipAuth) {
|
|
149
|
-
const credential = await tryGetCredential(tokenStore);
|
|
150
303
|
if (credential) {
|
|
151
304
|
try {
|
|
152
305
|
bootstrapInfo = await getBootstrapInfo(credential, cmsResourceId);
|
|
@@ -178,8 +331,29 @@ async function maybeInstallPayloadSkill(args) {
|
|
|
178
331
|
}
|
|
179
332
|
}
|
|
180
333
|
}
|
|
181
|
-
// Step 4: Detect or scaffold
|
|
182
|
-
|
|
334
|
+
// Step 4: Detect or scaffold project
|
|
335
|
+
if (isInProject && resourceType === 'vite') {
|
|
336
|
+
try {
|
|
337
|
+
await writeProjectConfiguration({
|
|
338
|
+
bootstrapInfo,
|
|
339
|
+
environmentName: resolvedEnv?.name ?? 'production',
|
|
340
|
+
projectDir: process.cwd(),
|
|
341
|
+
projectId: cmsResourceId,
|
|
342
|
+
tokenStore
|
|
343
|
+
});
|
|
344
|
+
} catch (error) {
|
|
345
|
+
p.log.error(error instanceof Error ? error.message : 'Failed to configure project');
|
|
346
|
+
process.exit(1);
|
|
347
|
+
}
|
|
348
|
+
await maybeEnsurePayloadSecret({
|
|
349
|
+
cmsResourceId,
|
|
350
|
+
credential,
|
|
351
|
+
resolvedEnv,
|
|
352
|
+
tokenStore
|
|
353
|
+
});
|
|
354
|
+
p.outro(pc.green('✓ Vite project initialized successfully!'));
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
183
357
|
if (isInProject) {
|
|
184
358
|
// ===== EXISTING PROJECT FLOW =====
|
|
185
359
|
log.debug('Project directory detected');
|
|
@@ -194,6 +368,9 @@ async function maybeInstallPayloadSkill(args) {
|
|
|
194
368
|
process.exit(1);
|
|
195
369
|
}
|
|
196
370
|
p.log.success(pc.green(`✓ Payload ${projectInfo.payloadVersion || 'detected'}`));
|
|
371
|
+
// Approvals must exist before any install: pnpm v11 aborts on unapproved
|
|
372
|
+
// build scripts, and re-init runs against an existing install.
|
|
373
|
+
await ensurePnpmWorkspace(process.cwd());
|
|
197
374
|
// Check dependencies
|
|
198
375
|
s.start('Checking dependencies...');
|
|
199
376
|
const hasDeps = await hasRequiredDependencies(process.cwd());
|
|
@@ -249,6 +426,15 @@ async function maybeInstallPayloadSkill(args) {
|
|
|
249
426
|
} catch (error) {
|
|
250
427
|
p.log.warn(pc.yellow(`⚠ Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
251
428
|
}
|
|
429
|
+
const secretCached = await maybeEnsurePayloadSecret({
|
|
430
|
+
cmsResourceId,
|
|
431
|
+
credential,
|
|
432
|
+
resolvedEnv,
|
|
433
|
+
tokenStore
|
|
434
|
+
});
|
|
435
|
+
if (secretCached) {
|
|
436
|
+
await commentOutPayloadSecretInEnv(process.cwd());
|
|
437
|
+
}
|
|
252
438
|
} else {
|
|
253
439
|
p.log.warn(pc.yellow('⚠ Payload was not detected in this project'));
|
|
254
440
|
p.note('Run this command in a directory without an existing project or in an existing Payload project.', 'Action Required');
|
|
@@ -266,7 +452,7 @@ async function maybeInstallPayloadSkill(args) {
|
|
|
266
452
|
log.error(error instanceof Error ? error.message : 'Unknown error');
|
|
267
453
|
process.exit(1);
|
|
268
454
|
}
|
|
269
|
-
// Apply Lambda modifications (run.sh,
|
|
455
|
+
// Apply Lambda modifications (run.sh, Next.js config, lambda:buildzip script)
|
|
270
456
|
await applyLambdaModifications(process.cwd(), packageManager);
|
|
271
457
|
// Ensure .gitignore has required entries
|
|
272
458
|
await ensureGitignore(process.cwd(), [
|
|
@@ -274,8 +460,13 @@ async function maybeInstallPayloadSkill(args) {
|
|
|
274
460
|
'.env.local',
|
|
275
461
|
'lambda.zip'
|
|
276
462
|
]);
|
|
277
|
-
await
|
|
278
|
-
|
|
463
|
+
await runProjectCodegen({
|
|
464
|
+
packageManager,
|
|
465
|
+
projectDir: process.cwd(),
|
|
466
|
+
spinner: s
|
|
467
|
+
});
|
|
468
|
+
await maybeWriteAgentConfigFiles({
|
|
469
|
+
noAgent: options.noAgent,
|
|
279
470
|
projectDir: process.cwd()
|
|
280
471
|
});
|
|
281
472
|
// Generate project token (unless skipping auth)
|
|
@@ -293,58 +484,8 @@ async function maybeInstallPayloadSkill(args) {
|
|
|
293
484
|
p.note(nextSteps.join('\n'), 'Next Steps');
|
|
294
485
|
} else {
|
|
295
486
|
// ===== NEW PROJECT FLOW =====
|
|
296
|
-
|
|
297
|
-
let projectPath;
|
|
298
|
-
if (options.name) {
|
|
299
|
-
projectPath = options.name;
|
|
300
|
-
} else {
|
|
301
|
-
const projectPathInput = await p.text({
|
|
302
|
-
initialValue: './',
|
|
303
|
-
message: 'Enter path to create project:',
|
|
304
|
-
placeholder: './my-cms-project',
|
|
305
|
-
validate: (value)=>{
|
|
306
|
-
if (!value) {
|
|
307
|
-
return 'Path is required';
|
|
308
|
-
}
|
|
309
|
-
// Allow relative or absolute paths
|
|
310
|
-
return undefined;
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
if (p.isCancel(projectPathInput)) {
|
|
314
|
-
p.cancel('Operation cancelled');
|
|
315
|
-
process.exit(0);
|
|
316
|
-
}
|
|
317
|
-
projectPath = projectPathInput;
|
|
318
|
-
}
|
|
319
|
-
const fullPath = path.resolve(process.cwd(), projectPath);
|
|
320
|
-
const projectName = path.basename(fullPath);
|
|
487
|
+
const fullPath = projectDirectory;
|
|
321
488
|
const packageManager = detectPackageManagerFromEnvironment();
|
|
322
|
-
// Create directory
|
|
323
|
-
try {
|
|
324
|
-
await fs.mkdir(fullPath, {
|
|
325
|
-
recursive: true
|
|
326
|
-
});
|
|
327
|
-
} catch (error) {
|
|
328
|
-
p.log.error(`Failed to create directory: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
329
|
-
process.exit(1);
|
|
330
|
-
}
|
|
331
|
-
// Scaffold project
|
|
332
|
-
const resolvedSource = {
|
|
333
|
-
...DEFAULT_TEMPLATE_SOURCE,
|
|
334
|
-
...templateSource
|
|
335
|
-
};
|
|
336
|
-
s.start(`Downloading template "${resolvedSource.templatePath}" from ` + `${resolvedSource.owner}/${resolvedSource.repo}@${resolvedSource.ref}...`);
|
|
337
|
-
try {
|
|
338
|
-
await scaffoldProject(fullPath, projectName, packageManager, templateSource, options.payloadVersion);
|
|
339
|
-
s.stop(pc.green('✓ Template downloaded'));
|
|
340
|
-
s.start('Installing dependencies...');
|
|
341
|
-
await installDependencies(fullPath, packageManager);
|
|
342
|
-
s.stop(pc.green('✓ Dependencies installed'));
|
|
343
|
-
} catch (error) {
|
|
344
|
-
s.stop(pc.red('✗ Failed'));
|
|
345
|
-
log.error(error instanceof Error ? error.message : 'Unknown error');
|
|
346
|
-
process.exit(1);
|
|
347
|
-
}
|
|
348
489
|
// Modify Payload configuration
|
|
349
490
|
s.start('Checking Payload configuration...');
|
|
350
491
|
const modResult = await ensurePayloadFigmaConfig(fullPath, packageManager, {
|
|
@@ -386,6 +527,15 @@ async function maybeInstallPayloadSkill(args) {
|
|
|
386
527
|
} catch (error) {
|
|
387
528
|
p.log.warn(pc.yellow(`⚠ Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
388
529
|
}
|
|
530
|
+
const secretCached = await maybeEnsurePayloadSecret({
|
|
531
|
+
cmsResourceId,
|
|
532
|
+
credential,
|
|
533
|
+
resolvedEnv,
|
|
534
|
+
tokenStore
|
|
535
|
+
});
|
|
536
|
+
if (secretCached) {
|
|
537
|
+
await removePayloadSecretFromEnv(fullPath);
|
|
538
|
+
}
|
|
389
539
|
// npm leaves node_modules in a transient state after a sequence of
|
|
390
540
|
// add/remove calls; a final install reconciles it so the project is
|
|
391
541
|
// immediately buildable.
|
|
@@ -398,8 +548,13 @@ async function maybeInstallPayloadSkill(args) {
|
|
|
398
548
|
log.error(error instanceof Error ? error.message : 'Unknown error');
|
|
399
549
|
process.exit(1);
|
|
400
550
|
}
|
|
401
|
-
await
|
|
402
|
-
|
|
551
|
+
await runProjectCodegen({
|
|
552
|
+
packageManager,
|
|
553
|
+
projectDir: fullPath,
|
|
554
|
+
spinner: s
|
|
555
|
+
});
|
|
556
|
+
await maybeWriteAgentConfigFiles({
|
|
557
|
+
noAgent: options.noAgent,
|
|
403
558
|
projectDir: fullPath
|
|
404
559
|
});
|
|
405
560
|
// Generate project token (unless skipping auth)
|
package/dist/commands/login.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
type LoginArgs = {
|
|
2
|
+
/** Redirect URL returned by the browser for resumable login completion. */
|
|
3
|
+
callbackUrl?: string;
|
|
4
|
+
/** Pending resumable login session to complete. */
|
|
5
|
+
completeSessionId?: string;
|
|
6
|
+
/** Start a resumable login without waiting on stdin or a callback server. */
|
|
7
|
+
headless?: boolean;
|
|
8
|
+
/** Emit machine-readable output for resumable login. */
|
|
9
|
+
json?: boolean;
|
|
10
|
+
/** Open the browser without asking for confirmation. */
|
|
11
|
+
openBrowserWithoutPrompt?: boolean;
|
|
2
12
|
/** Set this to show next steps after login
|
|
3
13
|
* @default true
|
|
4
14
|
*/
|
|
5
|
-
showNextSteps
|
|
15
|
+
showNextSteps?: boolean;
|
|
6
16
|
};
|
|
7
17
|
/**
|
|
8
18
|
* Handle the `@payloadcms/figma login` command
|
package/dist/commands/login.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as p from '@clack/prompts';
|
|
2
2
|
import pc from 'picocolors';
|
|
3
3
|
import { CallbackError } from '../auth/callback-server.js';
|
|
4
|
+
import { completeHeadlessOAuthFlow, startHeadlessOAuthFlow } from '../auth/headless-oauth-flow.js';
|
|
4
5
|
import { executeOAuthFlow, getValidCredential, OAuthFlowError } from '../auth/oauth-flow.js';
|
|
5
6
|
import { getTokenStore } from '../auth/token-store.js';
|
|
6
7
|
import { getOAuthConfig } from '../config/oauth.js';
|
|
@@ -13,11 +14,47 @@ import * as log from '../utils/log.js';
|
|
|
13
14
|
* Authenticates the user with Figma OAuth2 and stores tokens locally.
|
|
14
15
|
* If valid tokens already exist, shows an error message.
|
|
15
16
|
*/ export async function loginCommand(args) {
|
|
16
|
-
const { showNextSteps } = args
|
|
17
|
-
showNextSteps: false
|
|
18
|
-
};
|
|
17
|
+
const { callbackUrl, completeSessionId, headless = false, json = false, openBrowserWithoutPrompt = false, showNextSteps = false } = args ?? {};
|
|
19
18
|
const env = getInfraEnvironment();
|
|
20
19
|
const tokenStore = getTokenStore(env);
|
|
20
|
+
if (headless && completeSessionId) {
|
|
21
|
+
throw new Error('Use either --headless or --complete, not both.');
|
|
22
|
+
}
|
|
23
|
+
if (completeSessionId) {
|
|
24
|
+
if (!callbackUrl) {
|
|
25
|
+
throw new Error('--callback-url is required with --complete.');
|
|
26
|
+
}
|
|
27
|
+
const result = await completeHeadlessOAuthFlow({
|
|
28
|
+
callbackUrl,
|
|
29
|
+
sessionId: completeSessionId,
|
|
30
|
+
tokenStore
|
|
31
|
+
});
|
|
32
|
+
reportHeadlessLoginCompleted({
|
|
33
|
+
json,
|
|
34
|
+
userId: result.userId
|
|
35
|
+
});
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (headless) {
|
|
39
|
+
try {
|
|
40
|
+
const credential = await getValidCredential(tokenStore);
|
|
41
|
+
if (credential) {
|
|
42
|
+
reportHeadlessLoginCompleted({
|
|
43
|
+
json,
|
|
44
|
+
userId: tokenStore.getOauthInfo()?.userId
|
|
45
|
+
});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
// Invalid cached credentials should start a new login session.
|
|
50
|
+
}
|
|
51
|
+
const result = startHeadlessOAuthFlow(tokenStore);
|
|
52
|
+
reportHeadlessLoginStarted({
|
|
53
|
+
json,
|
|
54
|
+
...result
|
|
55
|
+
});
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
21
58
|
// Check for existing valid tokens
|
|
22
59
|
try {
|
|
23
60
|
const existingCredential = await getValidCredential(tokenStore);
|
|
@@ -37,18 +74,43 @@ import * as log from '../utils/log.js';
|
|
|
37
74
|
}
|
|
38
75
|
// Start OAuth flow
|
|
39
76
|
await handleAuthentication({
|
|
77
|
+
openBrowserWithoutPrompt,
|
|
40
78
|
showNextSteps,
|
|
41
79
|
tokenStore
|
|
42
80
|
});
|
|
43
81
|
}
|
|
82
|
+
function reportHeadlessLoginStarted({ authorizationUrl, expiresAt, json, sessionId }) {
|
|
83
|
+
if (json) {
|
|
84
|
+
process.stdout.write(`${JSON.stringify({
|
|
85
|
+
authorizationUrl,
|
|
86
|
+
expiresAt,
|
|
87
|
+
sessionId,
|
|
88
|
+
status: 'authorization_required'
|
|
89
|
+
})}\n`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
p.log.step(`Open this URL to authenticate:\n\n ${authorizationUrl}`);
|
|
93
|
+
p.note(`After approving, copy the full redirected URL and run:\n` + `@payloadcms/figma login --complete ${sessionId} --callback-url '<redirect-url>'`, 'Complete login');
|
|
94
|
+
}
|
|
95
|
+
function reportHeadlessLoginCompleted({ json, userId }) {
|
|
96
|
+
if (json) {
|
|
97
|
+
process.stdout.write(`${JSON.stringify({
|
|
98
|
+
status: 'authenticated',
|
|
99
|
+
userId
|
|
100
|
+
})}\n`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
p.log.success(pc.green('✓ Logged in'));
|
|
104
|
+
}
|
|
44
105
|
/**
|
|
45
106
|
* Handle authentication flow
|
|
46
|
-
*/ async function handleAuthentication({ showNextSteps, tokenStore }) {
|
|
107
|
+
*/ async function handleAuthentication({ openBrowserWithoutPrompt, showNextSteps, tokenStore }) {
|
|
47
108
|
try {
|
|
48
109
|
// Execute OAuth flow
|
|
49
110
|
const oauthConfig = getOAuthConfig();
|
|
50
111
|
const result = await executeOAuthFlow(tokenStore, {
|
|
51
112
|
clientId: oauthConfig.clientId,
|
|
113
|
+
openBrowserWithoutPrompt,
|
|
52
114
|
redirectUri: oauthConfig.redirectUri,
|
|
53
115
|
scopes: oauthConfig.scopes
|
|
54
116
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatProjectSubdomain(value: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatUnavailableSubdomainReason(reason: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function formatUnavailableSubdomainReason(reason) {
|
|
2
|
+
if (reason === 'already_taken') {
|
|
3
|
+
return 'Subdomain is already taken. Choose another.';
|
|
4
|
+
}
|
|
5
|
+
const reasonDetail = reason ? `: ${reason.replaceAll('_', ' ')}` : '';
|
|
6
|
+
return `Subdomain is unavailable${reasonDetail}. Choose another.`;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDefaultProjectName(projectPath: string): Promise<string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export async function getDefaultProjectName(projectPath) {
|
|
4
|
+
try {
|
|
5
|
+
const packageJson = JSON.parse(await fs.readFile(path.join(projectPath, 'package.json'), 'utf-8'));
|
|
6
|
+
if (typeof packageJson.name === 'string' && packageJson.name.trim()) {
|
|
7
|
+
return packageJson.name.replace(/^@[^/]+\//, '');
|
|
8
|
+
}
|
|
9
|
+
} catch {
|
|
10
|
+
// Fall back to directory name.
|
|
11
|
+
}
|
|
12
|
+
return path.basename(path.resolve(projectPath)) || 'figma-project';
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AuthCredential } from '../../auth/credentials.js';
|
|
2
|
+
interface PromptForAvailableSubdomainArgs {
|
|
3
|
+
credential: AuthCredential;
|
|
4
|
+
initialValue: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function promptForAvailableSubdomain({ credential, initialValue, }: PromptForAvailableSubdomainArgs): Promise<string>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import pc from 'picocolors';
|
|
3
|
+
import { checkProjectSubdomainAvailability } from '../../api/check-project-subdomain-availability.js';
|
|
4
|
+
import { formatUnavailableSubdomainReason } from './format-unavailable-subdomain-reason.js';
|
|
5
|
+
import { validateSubdomain } from './validate-subdomain.js';
|
|
6
|
+
export async function promptForAvailableSubdomain({ credential, initialValue }) {
|
|
7
|
+
let nextInitialValue = initialValue;
|
|
8
|
+
while(true){
|
|
9
|
+
const promptedSubdomain = await p.text({
|
|
10
|
+
initialValue: nextInitialValue,
|
|
11
|
+
message: 'Project subdomain:',
|
|
12
|
+
validate: validateSubdomain
|
|
13
|
+
});
|
|
14
|
+
const subdomain = unwrapPrompt(promptedSubdomain).trim();
|
|
15
|
+
const availability = await checkProjectSubdomainAvailability({
|
|
16
|
+
credential,
|
|
17
|
+
subdomain
|
|
18
|
+
});
|
|
19
|
+
if (availability.available) {
|
|
20
|
+
return subdomain;
|
|
21
|
+
}
|
|
22
|
+
p.log.error(pc.red(formatUnavailableSubdomainReason(availability.reason)));
|
|
23
|
+
nextInitialValue = subdomain;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function unwrapPrompt(value) {
|
|
27
|
+
if (p.isCancel(value)) {
|
|
28
|
+
p.cancel('Operation cancelled');
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ProjectResourceType } from '../../api/project-resource-type.js';
|
|
2
|
+
interface ResolveProjectRegionArgs {
|
|
3
|
+
nonInteractive?: boolean;
|
|
4
|
+
resourceType: ProjectResourceType;
|
|
5
|
+
value?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function resolveProjectRegion({ nonInteractive, resourceType, value, }: ResolveProjectRegionArgs): Promise<string>;
|
|
8
|
+
export {};
|