@payloadcms/figma 0.1.0-alpha.0 → 0.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/dist/{utils → adapters}/asset-collection.d.ts +17 -3
- package/dist/adapters/asset-collection.js +242 -0
- package/dist/{utils → adapters}/build-lambda-zip.d.ts +8 -7
- package/dist/adapters/build-lambda-zip.js +111 -0
- package/dist/adapters/configureNextjsCache.d.ts +8 -0
- package/dist/adapters/configureNextjsCache.js +55 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.d.ts +1 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.js +15 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput.d.ts +12 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput.js +28 -0
- package/dist/adapters/deploy-output/inspectNitroOutput.d.ts +9 -0
- package/dist/adapters/deploy-output/inspectNitroOutput.js +13 -0
- package/dist/adapters/deploy-output/isFile.d.ts +1 -0
- package/dist/adapters/deploy-output/isFile.js +4 -0
- package/dist/adapters/deploy-output/readJson.d.ts +1 -0
- package/dist/adapters/deploy-output/readJson.js +9 -0
- package/dist/adapters/deploy-output/resolveNitroOutputLayout.d.ts +8 -0
- package/dist/adapters/deploy-output/resolveNitroOutputLayout.js +16 -0
- package/dist/adapters/deploy-output/resolveOutputPath.d.ts +2 -0
- package/dist/adapters/deploy-output/resolveOutputPath.js +9 -0
- package/dist/adapters/deploy-output/resolveWithin.d.ts +1 -0
- package/dist/adapters/deploy-output/resolveWithin.js +12 -0
- package/dist/adapters/fs-utils.d.ts +39 -0
- package/dist/adapters/fs-utils.js +135 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/lambda-runtime/nextjs-cache.d.ts +40 -0
- package/dist/adapters/lambda-runtime/nextjs-cache.js +174 -0
- package/dist/adapters/nextjs.d.ts +12 -0
- package/dist/adapters/nextjs.js +67 -0
- package/dist/adapters/nitro.d.ts +8 -0
- package/dist/adapters/nitro.js +193 -0
- package/dist/adapters/secret-files.d.ts +25 -0
- package/dist/adapters/secret-files.js +50 -0
- package/dist/adapters/types.d.ts +42 -0
- package/dist/adapters/types.js +1 -0
- package/dist/{utils/adapters → adapters}/vite.d.ts +2 -2
- package/dist/adapters/vite.js +33 -0
- package/dist/api/check-project-subdomain-availability.d.ts +12 -0
- package/dist/api/check-project-subdomain-availability.js +32 -0
- package/dist/api/control-plane-error.d.ts +6 -0
- package/dist/api/control-plane-error.js +8 -0
- package/dist/api/control-plane-fetch.d.ts +7 -0
- package/dist/api/control-plane-fetch.js +37 -0
- package/dist/api/control-plane.d.ts +1 -9
- package/dist/api/control-plane.js +2 -48
- package/dist/api/create-project.d.ts +18 -0
- package/dist/api/create-project.js +37 -0
- package/dist/api/list-project-workspaces.d.ts +8 -0
- package/dist/api/list-project-workspaces.js +28 -0
- package/dist/api/project-resource-type.d.ts +1 -0
- package/dist/api/project-resource-type.js +1 -0
- package/dist/auth/headless-oauth-flow.d.ts +23 -0
- package/dist/auth/headless-oauth-flow.js +69 -0
- package/dist/auth/oauth-flow.d.ts +2 -0
- package/dist/auth/oauth-flow.js +13 -8
- package/dist/auth/token-store.d.ts +4 -1
- package/dist/auth/token-store.js +14 -0
- package/dist/auth/types.d.ts +12 -0
- package/dist/cli.d.ts +39 -0
- package/dist/cli.js +71 -36
- package/dist/commands/bootstrap.js +2 -1
- package/dist/commands/build-lambda-zip.js +1 -1
- package/dist/commands/deploy.d.ts +12 -0
- package/dist/commands/deploy.js +63 -25
- package/dist/commands/detect-project-resource-type.d.ts +3 -0
- package/dist/commands/detect-project-resource-type.js +28 -0
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.js +164 -79
- package/dist/commands/login.d.ts +11 -1
- package/dist/commands/login.js +66 -4
- package/dist/commands/prompt-to-create-project/format-project-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-project-subdomain.js +3 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.js +7 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.js +13 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.d.ts +7 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.js +32 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.d.ts +8 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.js +27 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.js +54 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.js +23 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.d.ts +12 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.js +36 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.js +9 -0
- package/dist/commands/prompt-to-create-project.d.ts +24 -0
- package/dist/commands/prompt-to-create-project.js +69 -0
- package/dist/commands/setup-agent.d.ts +12 -0
- package/dist/commands/setup-agent.js +123 -0
- package/dist/commands/write-project-configuration.d.ts +12 -0
- package/dist/commands/write-project-configuration.js +16 -0
- package/dist/db-content-api/generated/content-api-types.d.ts +661 -16
- package/dist/db-content-api/index.d.ts +3 -0
- package/dist/db-content-api/index.js +155 -161
- package/dist/db-content-api/utilities/clientVersionHeaders.d.ts +7 -0
- package/dist/db-content-api/utilities/clientVersionHeaders.js +15 -0
- package/dist/db-content-api/utilities/data/atomicOperations.d.ts +16 -0
- package/dist/db-content-api/utilities/data/atomicOperations.js +48 -0
- package/dist/db-content-api/utilities/data/convertRelationshipIds.d.ts +25 -0
- package/dist/db-content-api/utilities/data/convertRelationshipIds.js +109 -0
- package/dist/db-content-api/utilities/data/index.js +73 -57
- package/dist/db-content-api/utilities/data/injectGlobalType.d.ts +6 -0
- package/dist/db-content-api/utilities/data/injectGlobalType.js +11 -0
- package/dist/db-content-api/utilities/data/isLocaleMap.d.ts +10 -0
- package/dist/db-content-api/utilities/data/isLocaleMap.js +13 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +3 -11
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +12 -50
- package/dist/db-content-api/utilities/data/resolveFieldLocalization.d.ts +18 -0
- package/dist/db-content-api/utilities/data/resolveFieldLocalization.js +21 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +19 -12
- package/dist/db-content-api/utilities/isRecord.d.ts +9 -0
- package/dist/db-content-api/utilities/isRecord.js +19 -0
- package/dist/db-content-api/utilities/joins.d.ts +6 -8
- package/dist/db-content-api/utilities/joins.js +13 -22
- package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.js +95 -0
- package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.d.ts +9 -0
- package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.js +112 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +21 -4
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +118 -36
- package/dist/db-content-api/utilities/schema/getDocumentSchema.d.ts +3 -0
- package/dist/db-content-api/utilities/schema/getDocumentSchema.js +24 -0
- package/dist/db-content-api/utilities/where.d.ts +3 -17
- package/dist/db-content-api/utilities/where.js +21 -21
- package/dist/exports/client.d.ts +2 -0
- package/dist/exports/client.js +2 -0
- package/dist/exports/views.d.ts +1 -0
- package/dist/exports/views.js +1 -0
- package/dist/imageSizeOptions.d.ts +23 -0
- package/dist/imageSizeOptions.js +26 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/write-agent-config.d.ts +12 -0
- package/dist/lib/write-agent-config.js +52 -0
- package/dist/next/image-loader.d.ts +6 -0
- package/dist/next/image-loader.js +14 -0
- package/dist/oauth/components/LoginButton/index.js +66 -19
- package/dist/oauth/components/LoginButton/index.scss +121 -15
- package/dist/oauth/defaults.js +4 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +5 -2
- package/dist/oauth/index.js +8 -7
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +1 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +1 -0
- package/dist/oauth/utilities/getAuthorizeURL.js +5 -1
- package/dist/plugin/build-config.d.ts +4 -2
- package/dist/plugin/build-config.js +95 -31
- package/dist/plugin/cache-revalidation-hooks.d.ts +6 -0
- package/dist/plugin/cache-revalidation-hooks.js +69 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.d.ts +8 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.js +66 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.scss +56 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.d.ts +4 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.js +110 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.css +14 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.d.ts +4 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.js +52 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.d.ts +7 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.js +3 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.d.ts +1 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.js +27 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.d.ts +2 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.js +30 -0
- package/dist/plugin/cloud-limits/routes.d.ts +2 -0
- package/dist/plugin/cloud-limits/routes.js +4 -0
- package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.d.ts +9 -0
- package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.js +28 -0
- package/dist/plugin/cloud-limits/shared.d.ts +10 -0
- package/dist/plugin/cloud-limits/shared.js +52 -0
- package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.d.ts +2 -0
- package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.js +134 -0
- package/dist/plugin/cloud-limits/utilities/toasts.d.ts +4 -0
- package/dist/plugin/cloud-limits/utilities/toasts.js +19 -0
- package/dist/plugin/make-permission-access/make-permission-access.d.ts +8 -0
- package/dist/plugin/make-permission-access/make-permission-access.js +24 -0
- package/dist/plugin/sandbox-upload-fetch.d.ts +32 -0
- package/dist/plugin/sandbox-upload-fetch.js +53 -0
- package/dist/skills/deploy-to-figma/SKILL.md +234 -0
- package/dist/skills/deploy-to-figma/references/cli-reference.md +146 -0
- package/dist/storage-content-api/client-uploads/generate.js +2 -1
- package/dist/storage-content-api/getDownloadResponseHeaderPolicy.d.ts +11 -0
- package/dist/storage-content-api/getDownloadResponseHeaderPolicy.js +27 -0
- package/dist/storage-content-api/index.js +1 -0
- package/dist/storage-content-api/resolveDownloadResponseHeaders.d.ts +5 -0
- package/dist/storage-content-api/resolveDownloadResponseHeaders.js +13 -0
- package/dist/storage-content-api/staticHandler.js +2 -1
- package/dist/storage-content-api/types.d.ts +4 -1
- package/dist/translations/ar.d.ts +12 -0
- package/dist/translations/ar.js +12 -0
- package/dist/translations/az.d.ts +12 -0
- package/dist/translations/az.js +12 -0
- package/dist/translations/bg.d.ts +12 -0
- package/dist/translations/bg.js +12 -0
- package/dist/translations/bnBd.d.ts +12 -0
- package/dist/translations/bnBd.js +12 -0
- package/dist/translations/bnIn.d.ts +12 -0
- package/dist/translations/bnIn.js +12 -0
- package/dist/translations/ca.d.ts +12 -0
- package/dist/translations/ca.js +12 -0
- package/dist/translations/cs.d.ts +12 -0
- package/dist/translations/cs.js +12 -0
- package/dist/translations/da.d.ts +12 -0
- package/dist/translations/da.js +12 -0
- package/dist/translations/de.d.ts +12 -0
- package/dist/translations/de.js +12 -0
- package/dist/translations/en.d.ts +12 -0
- package/dist/translations/en.js +12 -0
- package/dist/translations/es.d.ts +12 -0
- package/dist/translations/es.js +12 -0
- package/dist/translations/et.d.ts +12 -0
- package/dist/translations/et.js +12 -0
- package/dist/translations/fa.d.ts +12 -0
- package/dist/translations/fa.js +12 -0
- package/dist/translations/fr.d.ts +12 -0
- package/dist/translations/fr.js +12 -0
- package/dist/translations/he.d.ts +12 -0
- package/dist/translations/he.js +12 -0
- package/dist/translations/hr.d.ts +12 -0
- package/dist/translations/hr.js +12 -0
- package/dist/translations/hu.d.ts +12 -0
- package/dist/translations/hu.js +12 -0
- package/dist/translations/hy.d.ts +12 -0
- package/dist/translations/hy.js +12 -0
- package/dist/translations/id.d.ts +12 -0
- package/dist/translations/id.js +12 -0
- package/dist/translations/index.d.ts +533 -0
- package/dist/translations/index.js +90 -0
- package/dist/translations/is.d.ts +12 -0
- package/dist/translations/is.js +12 -0
- package/dist/translations/it.d.ts +12 -0
- package/dist/translations/it.js +12 -0
- package/dist/translations/ja.d.ts +12 -0
- package/dist/translations/ja.js +12 -0
- package/dist/translations/ko.d.ts +12 -0
- package/dist/translations/ko.js +12 -0
- package/dist/translations/lt.d.ts +12 -0
- package/dist/translations/lt.js +12 -0
- package/dist/translations/lv.d.ts +12 -0
- package/dist/translations/lv.js +12 -0
- package/dist/translations/my.d.ts +12 -0
- package/dist/translations/my.js +12 -0
- package/dist/translations/nb.d.ts +12 -0
- package/dist/translations/nb.js +12 -0
- package/dist/translations/nl.d.ts +12 -0
- package/dist/translations/nl.js +12 -0
- package/dist/translations/pl.d.ts +12 -0
- package/dist/translations/pl.js +12 -0
- package/dist/translations/pt.d.ts +12 -0
- package/dist/translations/pt.js +12 -0
- package/dist/translations/ro.d.ts +12 -0
- package/dist/translations/ro.js +12 -0
- package/dist/translations/rs.d.ts +12 -0
- package/dist/translations/rs.js +12 -0
- package/dist/translations/rsLatin.d.ts +12 -0
- package/dist/translations/rsLatin.js +12 -0
- package/dist/translations/ru.d.ts +12 -0
- package/dist/translations/ru.js +12 -0
- package/dist/translations/sk.d.ts +12 -0
- package/dist/translations/sk.js +12 -0
- package/dist/translations/sl.d.ts +12 -0
- package/dist/translations/sl.js +12 -0
- package/dist/translations/sv.d.ts +12 -0
- package/dist/translations/sv.js +12 -0
- package/dist/translations/ta.d.ts +12 -0
- package/dist/translations/ta.js +12 -0
- package/dist/translations/th.d.ts +12 -0
- package/dist/translations/th.js +12 -0
- package/dist/translations/tr.d.ts +12 -0
- package/dist/translations/tr.js +12 -0
- package/dist/translations/uk.d.ts +12 -0
- package/dist/translations/uk.js +12 -0
- package/dist/translations/vi.d.ts +12 -0
- package/dist/translations/vi.js +12 -0
- package/dist/translations/zh.d.ts +12 -0
- package/dist/translations/zh.js +12 -0
- package/dist/translations/zhTw.d.ts +12 -0
- package/dist/translations/zhTw.js +12 -0
- package/dist/types.d.ts +11 -0
- package/dist/utils/assert-never.d.ts +1 -0
- package/dist/utils/assert-never.js +3 -0
- package/dist/utils/build-detection.d.ts +6 -1
- package/dist/utils/build-detection.js +68 -89
- package/dist/utils/deploy-adapter.d.ts +3 -35
- package/dist/utils/deploy-adapter.js +25 -14
- package/dist/utils/lambda-config.js +18 -23
- package/dist/utils/load-payload-config.d.ts +2 -2
- package/dist/utils/messages.js +24 -3
- package/dist/utils/next-image-loader-config.d.ts +2 -0
- package/dist/utils/next-image-loader-config.js +63 -0
- package/dist/utils/next-image-loader-file.d.ts +2 -0
- package/dist/utils/next-image-loader-file.js +11 -0
- package/dist/utils/payload-generate.d.ts +10 -0
- package/dist/utils/payload-generate.js +59 -0
- package/dist/utils/pnpm-builds.d.ts +14 -0
- package/dist/utils/pnpm-builds.js +125 -0
- package/dist/utils/s3-upload.js +4 -1
- package/package.json +31 -7
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +0 -10
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +0 -71
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +0 -41
- package/dist/db-content-api/utilities/meta/buildMeta.js +0 -39
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +0 -16
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +0 -243
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +0 -12
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +0 -60
- package/dist/lib/download-skill.d.ts +0 -12
- package/dist/lib/download-skill.js +0 -77
- package/dist/utils/adapters/nextjs.d.ts +0 -8
- package/dist/utils/adapters/nextjs.js +0 -61
- package/dist/utils/adapters/nitro.d.ts +0 -8
- package/dist/utils/adapters/nitro.js +0 -172
- package/dist/utils/adapters/vite.js +0 -31
- package/dist/utils/asset-collection.js +0 -144
- package/dist/utils/build-lambda-zip.js +0 -90
- package/dist/utils/fs-utils.d.ts +0 -12
- package/dist/utils/fs-utils.js +0 -55
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TokenStore } from './token-store.js';
|
|
2
|
+
export interface StartHeadlessOAuthFlowResult {
|
|
3
|
+
authorizationUrl: string;
|
|
4
|
+
expiresAt: number;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class HeadlessOAuthFlowError extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/** Start OAuth without a callback listener so another process can resume it. */
|
|
11
|
+
export declare function startHeadlessOAuthFlow(tokenStore: TokenStore, options?: {
|
|
12
|
+
now?: number;
|
|
13
|
+
}): StartHeadlessOAuthFlowResult;
|
|
14
|
+
/** Complete a previously started headless OAuth flow and store its tokens. */
|
|
15
|
+
export declare function completeHeadlessOAuthFlow({ callbackUrl, now, sessionId, tokenStore, }: {
|
|
16
|
+
callbackUrl: string;
|
|
17
|
+
now?: number;
|
|
18
|
+
sessionId: string;
|
|
19
|
+
tokenStore: TokenStore;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
tokens: import("./types.js").FigmaTokens;
|
|
22
|
+
userId: string | undefined;
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { getOAuthConfig } from '../config/oauth.js';
|
|
3
|
+
import { buildAuthorizationUrl } from './browser.js';
|
|
4
|
+
import { parsePastedCode } from './paste-code.js';
|
|
5
|
+
import { generatePKCEPair } from './pkce.js';
|
|
6
|
+
import { exchangeCodeForTokens } from './refresh.js';
|
|
7
|
+
const HEADLESS_OAUTH_SESSION_TTL_MS = 10 * 60 * 1000;
|
|
8
|
+
export class HeadlessOAuthFlowError extends Error {
|
|
9
|
+
constructor(message){
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'HeadlessOAuthFlowError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Start OAuth without a callback listener so another process can resume it. */ export function startHeadlessOAuthFlow(tokenStore, options = {}) {
|
|
15
|
+
const oauthConfig = getOAuthConfig();
|
|
16
|
+
const { codeChallenge, codeChallengeMethod, codeVerifier } = generatePKCEPair();
|
|
17
|
+
const now = options.now ?? Date.now();
|
|
18
|
+
const session = {
|
|
19
|
+
id: crypto.randomBytes(32).toString('base64url'),
|
|
20
|
+
clientId: oauthConfig.clientId,
|
|
21
|
+
codeVerifier,
|
|
22
|
+
expiresAt: now + HEADLESS_OAUTH_SESSION_TTL_MS,
|
|
23
|
+
redirectUri: oauthConfig.redirectUri,
|
|
24
|
+
state: crypto.randomBytes(32).toString('base64url')
|
|
25
|
+
};
|
|
26
|
+
tokenStore.setHeadlessOAuthSession(session);
|
|
27
|
+
return {
|
|
28
|
+
authorizationUrl: buildAuthorizationUrl({
|
|
29
|
+
authorizationUrl: oauthConfig.authorizationUrl,
|
|
30
|
+
clientId: session.clientId,
|
|
31
|
+
codeChallenge,
|
|
32
|
+
codeChallengeMethod,
|
|
33
|
+
redirectUri: session.redirectUri,
|
|
34
|
+
scopes: oauthConfig.scopes,
|
|
35
|
+
state: session.state
|
|
36
|
+
}),
|
|
37
|
+
expiresAt: session.expiresAt,
|
|
38
|
+
sessionId: session.id
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Complete a previously started headless OAuth flow and store its tokens. */ export async function completeHeadlessOAuthFlow({ callbackUrl, now = Date.now(), sessionId, tokenStore }) {
|
|
42
|
+
const session = tokenStore.getHeadlessOAuthSession();
|
|
43
|
+
if (!session) {
|
|
44
|
+
throw new HeadlessOAuthFlowError('No pending login found. Start login again with --headless.');
|
|
45
|
+
}
|
|
46
|
+
if (session.id !== sessionId) {
|
|
47
|
+
throw new HeadlessOAuthFlowError('Login session does not match. Start login again with --headless.');
|
|
48
|
+
}
|
|
49
|
+
if (now >= session.expiresAt) {
|
|
50
|
+
tokenStore.clearHeadlessOAuthSession();
|
|
51
|
+
throw new HeadlessOAuthFlowError('Login session expired. Start login again with --headless.');
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
try {
|
|
55
|
+
new URL(callbackUrl);
|
|
56
|
+
} catch {
|
|
57
|
+
throw new HeadlessOAuthFlowError('Paste the full redirected URL so the login state can be verified.');
|
|
58
|
+
}
|
|
59
|
+
const code = parsePastedCode(callbackUrl, session.state);
|
|
60
|
+
const tokens = await exchangeCodeForTokens(code, session.codeVerifier, session.redirectUri, session.clientId);
|
|
61
|
+
tokenStore.setTokens(tokens);
|
|
62
|
+
return {
|
|
63
|
+
tokens,
|
|
64
|
+
userId: tokens.userId
|
|
65
|
+
};
|
|
66
|
+
} finally{
|
|
67
|
+
tokenStore.clearHeadlessOAuthSession();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -16,6 +16,8 @@ export interface OAuthFlowOptions {
|
|
|
16
16
|
clientId?: string;
|
|
17
17
|
/** Callback server fallback ports to try after port */
|
|
18
18
|
fallbackPorts?: number[];
|
|
19
|
+
/** Open the browser without asking for confirmation */
|
|
20
|
+
openBrowserWithoutPrompt?: boolean;
|
|
19
21
|
/** First callback server port to try */
|
|
20
22
|
port?: number;
|
|
21
23
|
/** Redirect URI (defaults to config) */
|
package/dist/auth/oauth-flow.js
CHANGED
|
@@ -54,7 +54,7 @@ import { exchangeCodeForTokens, refreshAccessToken, TokenRefreshError } from './
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
// REAL OAUTH IMPLEMENTATION
|
|
57
|
-
const { clientId = oauthConfig.clientId, fallbackPorts, port, redirectUri = oauthConfig.redirectUri, scopes = oauthConfig.scopes, timeoutMs = 120000 } = options;
|
|
57
|
+
const { clientId = oauthConfig.clientId, fallbackPorts, openBrowserWithoutPrompt = false, port, redirectUri = oauthConfig.redirectUri, scopes = oauthConfig.scopes, timeoutMs = 120000 } = options;
|
|
58
58
|
// Generate PKCE pair for enhanced security
|
|
59
59
|
const { codeChallenge, codeChallengeMethod, codeVerifier } = generatePKCEPair();
|
|
60
60
|
// Generate random state for CSRF protection
|
|
@@ -85,13 +85,18 @@ import { exchangeCodeForTokens, refreshAccessToken, TokenRefreshError } from './
|
|
|
85
85
|
scopes,
|
|
86
86
|
state
|
|
87
87
|
});
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
// Ask interactive callers before opening a browser. Automated callers have
|
|
89
|
+
// already accepted defaults with -y, so proceed directly to authorization.
|
|
90
|
+
let shouldOpenBrowser = openBrowserWithoutPrompt;
|
|
91
|
+
if (!openBrowserWithoutPrompt) {
|
|
92
|
+
const browserConfirmation = await p.confirm({
|
|
93
|
+
initialValue: true,
|
|
94
|
+
message: 'Open browser to authenticate with Figma?'
|
|
95
|
+
});
|
|
96
|
+
if (p.isCancel(browserConfirmation)) {
|
|
97
|
+
throw new OAuthFlowError('Authentication cancelled by user');
|
|
98
|
+
}
|
|
99
|
+
shouldOpenBrowser = browserConfirmation;
|
|
95
100
|
}
|
|
96
101
|
let browserOpened = false;
|
|
97
102
|
if (shouldOpenBrowser) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Environment } from '../constants.js';
|
|
2
|
-
import type { BootstrapData, FigmaTokens, ProjectStoreScope, ProjectToken, TokenStoreConfig } from './types.js';
|
|
2
|
+
import type { BootstrapData, FigmaTokens, HeadlessOAuthSession, ProjectStoreScope, ProjectToken, TokenStoreConfig } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Get the singleton TokenStore instance for an environment.
|
|
5
5
|
*/
|
|
@@ -23,6 +23,9 @@ export declare class TokenStore {
|
|
|
23
23
|
getOauthInfo(): FigmaTokens | null;
|
|
24
24
|
setTokens(tokens: FigmaTokens): void;
|
|
25
25
|
clearTokens(): void;
|
|
26
|
+
getHeadlessOAuthSession(): HeadlessOAuthSession | null;
|
|
27
|
+
setHeadlessOAuthSession(session: HeadlessOAuthSession): void;
|
|
28
|
+
clearHeadlessOAuthSession(): void;
|
|
26
29
|
hasValidOauthToken(): boolean;
|
|
27
30
|
isOauthExpired(): boolean;
|
|
28
31
|
getCurrentOauthToken(): null | string;
|
package/dist/auth/token-store.js
CHANGED
|
@@ -186,11 +186,25 @@ const PROJECT_STORE_SCHEMA_VERSION = 1;
|
|
|
186
186
|
clearTokens() {
|
|
187
187
|
this.oauthConfig.delete('accessToken');
|
|
188
188
|
this.oauthConfig.delete('expiresAt');
|
|
189
|
+
this.oauthConfig.delete('headlessOAuthSession');
|
|
189
190
|
this.oauthConfig.delete('refreshToken');
|
|
190
191
|
this.oauthConfig.delete('scopes');
|
|
191
192
|
this.oauthConfig.delete('tokenType');
|
|
192
193
|
this.oauthConfig.delete('userId');
|
|
193
194
|
}
|
|
195
|
+
getHeadlessOAuthSession() {
|
|
196
|
+
return this.safeGet({
|
|
197
|
+
config: this.oauthConfig,
|
|
198
|
+
key: 'headlessOAuthSession'
|
|
199
|
+
}) ?? null;
|
|
200
|
+
}
|
|
201
|
+
setHeadlessOAuthSession(session) {
|
|
202
|
+
this.oauthConfig.set('_schemaVersion', OAUTH_STORE_SCHEMA_VERSION);
|
|
203
|
+
this.oauthConfig.set('headlessOAuthSession', session);
|
|
204
|
+
}
|
|
205
|
+
clearHeadlessOAuthSession() {
|
|
206
|
+
this.oauthConfig.delete('headlessOAuthSession');
|
|
207
|
+
}
|
|
194
208
|
hasValidOauthToken() {
|
|
195
209
|
const tokens = this.getOauthInfo();
|
|
196
210
|
if (!tokens) {
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -32,6 +32,18 @@ export interface FigmaTokens {
|
|
|
32
32
|
/** Figma user ID string */
|
|
33
33
|
userId?: string;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Temporary state for a resumable OAuth login. Stored encrypted on the machine
|
|
37
|
+
* that generated the PKCE verifier and removed after completion or expiry.
|
|
38
|
+
*/
|
|
39
|
+
export interface HeadlessOAuthSession {
|
|
40
|
+
clientId: string;
|
|
41
|
+
codeVerifier: string;
|
|
42
|
+
expiresAt: number;
|
|
43
|
+
id: string;
|
|
44
|
+
redirectUri: string;
|
|
45
|
+
state: string;
|
|
46
|
+
}
|
|
35
47
|
/**
|
|
36
48
|
* Raw token response from Figma OAuth2 token endpoint
|
|
37
49
|
* Response from POST https://api.figma.com/v1/oauth/token
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
export declare const cliArgSpec: {
|
|
2
|
+
readonly '--adapter': StringConstructor;
|
|
3
|
+
readonly '--all': BooleanConstructor;
|
|
4
|
+
readonly '--callback-url': StringConstructor;
|
|
5
|
+
readonly '--complete': StringConstructor;
|
|
6
|
+
readonly '--debug': BooleanConstructor;
|
|
7
|
+
readonly '--description': StringConstructor;
|
|
8
|
+
readonly '--dry-run': BooleanConstructor;
|
|
9
|
+
readonly '--env': StringConstructor;
|
|
10
|
+
readonly '--force': BooleanConstructor;
|
|
11
|
+
readonly '--global': BooleanConstructor;
|
|
12
|
+
readonly '--headless': BooleanConstructor;
|
|
13
|
+
readonly '--help': BooleanConstructor;
|
|
14
|
+
readonly '--id': StringConstructor;
|
|
15
|
+
readonly '--infra-env': StringConstructor;
|
|
16
|
+
readonly '--json': BooleanConstructor;
|
|
17
|
+
readonly '--name': StringConstructor;
|
|
18
|
+
readonly '--no-agent': BooleanConstructor;
|
|
19
|
+
readonly '--output': StringConstructor;
|
|
20
|
+
readonly '--payload-version': StringConstructor;
|
|
21
|
+
readonly '--project': BooleanConstructor;
|
|
22
|
+
readonly '--region': StringConstructor;
|
|
23
|
+
readonly '--skip-auth': BooleanConstructor;
|
|
24
|
+
readonly '--skip-build': BooleanConstructor;
|
|
25
|
+
readonly '--skip-size-check': BooleanConstructor;
|
|
26
|
+
readonly '--subdomain': StringConstructor;
|
|
27
|
+
readonly '--template': StringConstructor;
|
|
28
|
+
readonly '--version': BooleanConstructor;
|
|
29
|
+
readonly '--workspace': StringConstructor;
|
|
30
|
+
readonly '--yes': BooleanConstructor;
|
|
31
|
+
readonly '--environment': "--env";
|
|
32
|
+
readonly '-e': "--env";
|
|
33
|
+
readonly '-f': "--force";
|
|
34
|
+
readonly '-h': "--help";
|
|
35
|
+
readonly '-n': "--name";
|
|
36
|
+
readonly '-t': "--template";
|
|
37
|
+
readonly '-v': "--version";
|
|
38
|
+
readonly '-y': "--yes";
|
|
39
|
+
};
|
|
1
40
|
/**
|
|
2
41
|
* Entrypoint for bin/cli.js
|
|
3
42
|
*/
|
package/dist/cli.js
CHANGED
|
@@ -11,10 +11,51 @@ import { initCommand } from './commands/init.js';
|
|
|
11
11
|
import { listTokensCommand } from './commands/list-tokens.js';
|
|
12
12
|
import { loginCommand } from './commands/login.js';
|
|
13
13
|
import { logoutCommand } from './commands/logout.js';
|
|
14
|
+
import { setupAgentCommand } from './commands/setup-agent.js';
|
|
14
15
|
import { upgradeCommand } from './commands/upgrade.js';
|
|
15
16
|
import { uploadSchemaCommand } from './commands/upload-schema.js';
|
|
16
17
|
import { setInfraEnvironment } from './constants.js';
|
|
17
18
|
import { helpMessage } from './utils/messages.js';
|
|
19
|
+
export const cliArgSpec = {
|
|
20
|
+
'--adapter': String,
|
|
21
|
+
'--all': Boolean,
|
|
22
|
+
'--callback-url': String,
|
|
23
|
+
'--complete': String,
|
|
24
|
+
'--debug': Boolean,
|
|
25
|
+
'--description': String,
|
|
26
|
+
'--dry-run': Boolean,
|
|
27
|
+
'--env': String,
|
|
28
|
+
'--force': Boolean,
|
|
29
|
+
'--global': Boolean,
|
|
30
|
+
'--headless': Boolean,
|
|
31
|
+
'--help': Boolean,
|
|
32
|
+
'--id': String,
|
|
33
|
+
'--infra-env': String,
|
|
34
|
+
'--json': Boolean,
|
|
35
|
+
'--name': String,
|
|
36
|
+
'--no-agent': Boolean,
|
|
37
|
+
'--output': String,
|
|
38
|
+
'--payload-version': String,
|
|
39
|
+
'--project': Boolean,
|
|
40
|
+
'--region': String,
|
|
41
|
+
'--skip-auth': Boolean,
|
|
42
|
+
'--skip-build': Boolean,
|
|
43
|
+
'--skip-size-check': Boolean,
|
|
44
|
+
'--subdomain': String,
|
|
45
|
+
'--template': String,
|
|
46
|
+
'--version': Boolean,
|
|
47
|
+
'--workspace': String,
|
|
48
|
+
'--yes': Boolean,
|
|
49
|
+
// Aliases
|
|
50
|
+
'--environment': '--env',
|
|
51
|
+
'-e': '--env',
|
|
52
|
+
'-f': '--force',
|
|
53
|
+
'-h': '--help',
|
|
54
|
+
'-n': '--name',
|
|
55
|
+
'-t': '--template',
|
|
56
|
+
'-v': '--version',
|
|
57
|
+
'-y': '--yes'
|
|
58
|
+
};
|
|
18
59
|
/**
|
|
19
60
|
* Entrypoint for bin/cli.js
|
|
20
61
|
*/ export async function main() {
|
|
@@ -31,39 +72,7 @@ class Main {
|
|
|
31
72
|
args;
|
|
32
73
|
constructor(){
|
|
33
74
|
// @ts-expect-error bad typings
|
|
34
|
-
this.args = arg({
|
|
35
|
-
// Hidden flag — intentionally not displayed in help output yet.
|
|
36
|
-
// Auto-detection covers most cases; this is an escape hatch for testing.
|
|
37
|
-
// May expose in help text once multi-framework support is public.
|
|
38
|
-
'--adapter': String,
|
|
39
|
-
'--all': Boolean,
|
|
40
|
-
'--debug': Boolean,
|
|
41
|
-
'--dry-run': Boolean,
|
|
42
|
-
'--env': String,
|
|
43
|
-
'--force': Boolean,
|
|
44
|
-
'--help': Boolean,
|
|
45
|
-
'--id': String,
|
|
46
|
-
'--infra-env': String,
|
|
47
|
-
'--json': Boolean,
|
|
48
|
-
'--name': String,
|
|
49
|
-
'--no-skill': Boolean,
|
|
50
|
-
'--payload-version': String,
|
|
51
|
-
'--skip-auth': Boolean,
|
|
52
|
-
'--skip-build': Boolean,
|
|
53
|
-
'--skip-size-check': Boolean,
|
|
54
|
-
'--template': String,
|
|
55
|
-
'--version': Boolean,
|
|
56
|
-
'--yes': Boolean,
|
|
57
|
-
// Aliases
|
|
58
|
-
'--environment': '--env',
|
|
59
|
-
'-e': '--env',
|
|
60
|
-
'-f': '--force',
|
|
61
|
-
'-h': '--help',
|
|
62
|
-
'-n': '--name',
|
|
63
|
-
'-t': '--template',
|
|
64
|
-
'-v': '--version',
|
|
65
|
-
'-y': '--yes'
|
|
66
|
-
}, {
|
|
75
|
+
this.args = arg(cliArgSpec, {
|
|
67
76
|
permissive: true
|
|
68
77
|
});
|
|
69
78
|
// Set debug flag globally
|
|
@@ -105,7 +114,16 @@ class Main {
|
|
|
105
114
|
helpMessage();
|
|
106
115
|
process.exit(0);
|
|
107
116
|
}
|
|
108
|
-
//
|
|
117
|
+
// JSON and debug commands output plain text — skip styled intro.
|
|
118
|
+
if (subcommand === 'login' && this.args['--json']) {
|
|
119
|
+
await loginCommand({
|
|
120
|
+
callbackUrl: this.args['--callback-url'],
|
|
121
|
+
completeSessionId: this.args['--complete'],
|
|
122
|
+
headless: this.args['--headless'],
|
|
123
|
+
json: true
|
|
124
|
+
});
|
|
125
|
+
process.exit(0);
|
|
126
|
+
}
|
|
109
127
|
if (subcommand === 'debug') {
|
|
110
128
|
await debugCommand();
|
|
111
129
|
process.exit(0);
|
|
@@ -133,11 +151,17 @@ class Main {
|
|
|
133
151
|
case 'deploy':
|
|
134
152
|
await deployCommand({
|
|
135
153
|
id: this.args['--id'],
|
|
154
|
+
name: this.args['--name'],
|
|
136
155
|
adapter: this.args['--adapter'],
|
|
137
156
|
debug: this.args['--debug'],
|
|
157
|
+
description: this.args['--description'],
|
|
138
158
|
env: this.args['--env'],
|
|
159
|
+
output: this.args['--output'],
|
|
160
|
+
region: this.args['--region'],
|
|
139
161
|
skipBuild: this.args['--skip-build'],
|
|
140
162
|
skipSizeCheck: this.args['--skip-size-check'],
|
|
163
|
+
subdomain: this.args['--subdomain'],
|
|
164
|
+
workspace: this.args['--workspace'],
|
|
141
165
|
yes: this.args['--yes']
|
|
142
166
|
});
|
|
143
167
|
break;
|
|
@@ -153,7 +177,7 @@ class Main {
|
|
|
153
177
|
debug: this.args['--debug'],
|
|
154
178
|
env: this.args['--env'],
|
|
155
179
|
force: this.args['--force'],
|
|
156
|
-
|
|
180
|
+
noAgent: this.args['--no-agent'],
|
|
157
181
|
payloadVersion: this.args['--payload-version'],
|
|
158
182
|
skipAuth: this.args['--skip-auth'],
|
|
159
183
|
template: this.args['--template']
|
|
@@ -166,7 +190,11 @@ class Main {
|
|
|
166
190
|
});
|
|
167
191
|
break;
|
|
168
192
|
case 'login':
|
|
169
|
-
await loginCommand(
|
|
193
|
+
await loginCommand({
|
|
194
|
+
callbackUrl: this.args['--callback-url'],
|
|
195
|
+
completeSessionId: this.args['--complete'],
|
|
196
|
+
headless: this.args['--headless']
|
|
197
|
+
});
|
|
170
198
|
break;
|
|
171
199
|
case 'logout':
|
|
172
200
|
await logoutCommand({
|
|
@@ -174,6 +202,13 @@ class Main {
|
|
|
174
202
|
debug: this.args['--debug']
|
|
175
203
|
});
|
|
176
204
|
break;
|
|
205
|
+
case 'setup-agent':
|
|
206
|
+
await setupAgentCommand({
|
|
207
|
+
global: this.args['--global'],
|
|
208
|
+
project: this.args['--project'],
|
|
209
|
+
yes: this.args['--yes']
|
|
210
|
+
});
|
|
211
|
+
break;
|
|
177
212
|
case 'upgrade':
|
|
178
213
|
await upgradeCommand({
|
|
179
214
|
isDryRun: this.args['--dry-run']
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as p from '@clack/prompts';
|
|
2
2
|
import pc from 'picocolors';
|
|
3
|
-
import {
|
|
3
|
+
import { getBootstrapInfo } from '../api/control-plane.js';
|
|
4
|
+
import { ControlPlaneError } from '../api/control-plane-error.js';
|
|
4
5
|
import { getValidCredential } from '../auth/oauth-flow.js';
|
|
5
6
|
import { getTokenStore } from '../auth/token-store.js';
|
|
6
7
|
import { getInfraEnvironment } from '../constants.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as p from '@clack/prompts';
|
|
2
2
|
import pc from 'picocolors';
|
|
3
|
-
import { buildLambdaZip } from '../
|
|
3
|
+
import { buildLambdaZip } from '../adapters/build-lambda-zip.js';
|
|
4
4
|
/**
|
|
5
5
|
* Build Lambda deployment zip from current directory
|
|
6
6
|
*/ export async function buildLambdaZipCommand() {
|
|
@@ -7,14 +7,26 @@ export interface DeployCommandOptions {
|
|
|
7
7
|
adapter?: AdapterName;
|
|
8
8
|
/** Enable debug mode */
|
|
9
9
|
debug?: boolean;
|
|
10
|
+
/** Description used when creating an uninitialized project */
|
|
11
|
+
description?: string;
|
|
10
12
|
/** Figma environment name (e.g. 'production', 'staging') */
|
|
11
13
|
env?: string;
|
|
12
14
|
/** CMS Resource ID (overrides FIGMA_PROJECT_ID) */
|
|
13
15
|
id?: string;
|
|
16
|
+
/** Name used when creating an uninitialized project */
|
|
17
|
+
name?: string;
|
|
18
|
+
/** Exact framework build output root */
|
|
19
|
+
output?: string;
|
|
20
|
+
/** Region used when creating an uninitialized project */
|
|
21
|
+
region?: string;
|
|
14
22
|
/** Skip the build step (use existing build) */
|
|
15
23
|
skipBuild?: boolean;
|
|
16
24
|
/** Skip the client-side unzipped bundle size pre-flight check */
|
|
17
25
|
skipSizeCheck?: boolean;
|
|
26
|
+
/** Subdomain used when creating an uninitialized project */
|
|
27
|
+
subdomain?: string;
|
|
28
|
+
/** Workspace plan key used when creating an uninitialized project */
|
|
29
|
+
workspace?: string;
|
|
18
30
|
/** Skip confirmation prompts */
|
|
19
31
|
yes?: boolean;
|
|
20
32
|
}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import * as p from '@clack/prompts';
|
|
2
2
|
import spawn from 'cross-spawn';
|
|
3
|
+
import path from 'path';
|
|
3
4
|
import pc from 'picocolors';
|
|
4
|
-
import {
|
|
5
|
+
import { getFileSize } from '../adapters/asset-collection.js';
|
|
6
|
+
import { LAMBDA_MAX_UNZIPPED_BYTES } from '../adapters/build-lambda-zip.js';
|
|
7
|
+
import { createDeployment, getBootstrapInfo, performDeployment } from '../api/control-plane.js';
|
|
8
|
+
import { ControlPlaneError } from '../api/control-plane-error.js';
|
|
5
9
|
import { tryGetCredential } from '../auth/oauth-flow.js';
|
|
6
10
|
import { getTokenStore } from '../auth/token-store.js';
|
|
7
11
|
import { getInfraEnvironment, getProjectNotFoundMessage } from '../constants.js';
|
|
8
|
-
import { getFileSize } from '../utils/asset-collection.js';
|
|
9
12
|
import { detectBuild, getBuildCommand } from '../utils/build-detection.js';
|
|
10
|
-
import { LAMBDA_MAX_UNZIPPED_BYTES } from '../utils/build-lambda-zip.js';
|
|
11
13
|
import { detectAdapter } from '../utils/deploy-adapter.js';
|
|
12
14
|
import { getEnvVar } from '../utils/env-management.js';
|
|
13
15
|
import * as log from '../utils/log.js';
|
|
@@ -15,7 +17,10 @@ import { getPackageManager } from '../utils/package-manager.js';
|
|
|
15
17
|
import { isInProjectDirectory } from '../utils/project.js';
|
|
16
18
|
import { resolveEnvironment } from '../utils/resolve-environment.js';
|
|
17
19
|
import { uploadLambdaZip, uploadStaticAssets } from '../utils/s3-upload.js';
|
|
20
|
+
import { detectProjectResourceType } from './detect-project-resource-type.js';
|
|
18
21
|
import { loginCommand } from './login.js';
|
|
22
|
+
import { promptToCreateProject } from './prompt-to-create-project.js';
|
|
23
|
+
import { writeProjectConfiguration } from './write-project-configuration.js';
|
|
19
24
|
/**
|
|
20
25
|
* Format bytes to human-readable string
|
|
21
26
|
*/ function formatBytes(bytes) {
|
|
@@ -51,23 +56,14 @@ import { loginCommand } from './login.js';
|
|
|
51
56
|
*/ export async function deployCommand(options) {
|
|
52
57
|
const projectPath = process.cwd();
|
|
53
58
|
const spinner = p.spinner();
|
|
54
|
-
// Resolve project ID
|
|
55
|
-
let projectId = options.id;
|
|
56
|
-
if (!projectId) {
|
|
57
|
-
projectId = await getEnvVar(projectPath, 'FIGMA_PROJECT_ID') ?? undefined;
|
|
58
|
-
}
|
|
59
|
-
if (!projectId) {
|
|
60
|
-
p.log.error(pc.red('✗ Project ID not found. Run `@payloadcms/figma init` first, or use --id.'));
|
|
61
|
-
process.exit(1);
|
|
62
|
-
}
|
|
63
59
|
// Resolve environment name
|
|
64
60
|
const environmentName = options.env ?? await getEnvVar(projectPath, 'FIGMA_ENVIRONMENT_NAME') ?? undefined;
|
|
65
61
|
try {
|
|
66
62
|
// ===== PRE-FLIGHT CHECKS =====
|
|
67
|
-
//
|
|
68
|
-
if (!await isInProjectDirectory(projectPath)) {
|
|
69
|
-
p.log.error(pc.red(
|
|
70
|
-
p.note('
|
|
63
|
+
// Building requires package.json, but --skip-build can deploy a prebuilt artifact directly.
|
|
64
|
+
if (!options.skipBuild && !await isInProjectDirectory(projectPath)) {
|
|
65
|
+
p.log.error(pc.red('✗ Cannot build because package.json was not found in this directory.'));
|
|
66
|
+
p.note('Run from a package directory, or deploy prebuilt output with --skip-build --output <path>.', 'Tip');
|
|
71
67
|
process.exit(1);
|
|
72
68
|
}
|
|
73
69
|
// Check authentication
|
|
@@ -75,13 +71,38 @@ import { loginCommand } from './login.js';
|
|
|
75
71
|
let credential = await tryGetCredential(tokenStore);
|
|
76
72
|
if (!credential) {
|
|
77
73
|
p.log.message('Please log in to continue');
|
|
78
|
-
await loginCommand(
|
|
74
|
+
await loginCommand({
|
|
75
|
+
openBrowserWithoutPrompt: options.yes
|
|
76
|
+
});
|
|
79
77
|
credential = await tryGetCredential(tokenStore);
|
|
80
78
|
if (!credential) {
|
|
81
79
|
p.log.error(pc.red('✗ Authentication failed'));
|
|
82
80
|
process.exit(1);
|
|
83
81
|
}
|
|
84
82
|
}
|
|
83
|
+
// Resolve or create the CMS project.
|
|
84
|
+
let projectId = options.id;
|
|
85
|
+
if (!projectId) {
|
|
86
|
+
projectId = await getEnvVar(projectPath, 'FIGMA_PROJECT_ID') ?? undefined;
|
|
87
|
+
}
|
|
88
|
+
const isProjectCreated = !projectId;
|
|
89
|
+
if (!projectId) {
|
|
90
|
+
const resourceType = options.adapter === 'vite' ? 'vite' : options.adapter ? 'payload' : await detectProjectResourceType(projectPath);
|
|
91
|
+
const project = await promptToCreateProject({
|
|
92
|
+
credential,
|
|
93
|
+
inputs: {
|
|
94
|
+
name: options.name,
|
|
95
|
+
description: options.description,
|
|
96
|
+
region: options.region,
|
|
97
|
+
subdomain: options.subdomain,
|
|
98
|
+
workspacePlanKey: options.workspace
|
|
99
|
+
},
|
|
100
|
+
nonInteractive: options.yes,
|
|
101
|
+
projectPath,
|
|
102
|
+
resourceType
|
|
103
|
+
});
|
|
104
|
+
projectId = project.id;
|
|
105
|
+
}
|
|
85
106
|
// Resolve tenant instance ID via bootstrap
|
|
86
107
|
spinner.start('Resolving deployment target...');
|
|
87
108
|
let tenantInstanceId;
|
|
@@ -92,6 +113,14 @@ import { loginCommand } from './login.js';
|
|
|
92
113
|
environments: bootstrapInfo.environments
|
|
93
114
|
});
|
|
94
115
|
tenantInstanceId = resolvedEnv.tenantInstanceId;
|
|
116
|
+
await writeProjectConfiguration({
|
|
117
|
+
bootstrapInfo,
|
|
118
|
+
environmentName: resolvedEnv.name,
|
|
119
|
+
projectDir: projectPath,
|
|
120
|
+
projectId,
|
|
121
|
+
shouldWriteEnvironmentVariables: isProjectCreated,
|
|
122
|
+
tokenStore
|
|
123
|
+
});
|
|
95
124
|
spinner.stop(pc.green(`✓ Target: ${resolvedEnv.name}`));
|
|
96
125
|
} catch (error) {
|
|
97
126
|
if (error instanceof ControlPlaneError && (error.statusCode === 404 || error.statusCode === 410)) {
|
|
@@ -110,13 +139,18 @@ import { loginCommand } from './login.js';
|
|
|
110
139
|
process.env.FIGMA_EXTRACT_SCHEDULES = 'true';
|
|
111
140
|
// ===== BUILD =====
|
|
112
141
|
let buildInfo;
|
|
142
|
+
const buildOptions = {
|
|
143
|
+
adapter: options.adapter,
|
|
144
|
+
output: options.output
|
|
145
|
+
};
|
|
113
146
|
if (options.skipBuild) {
|
|
114
147
|
// User asserts build exists - verify it
|
|
115
148
|
spinner.start('Checking for build...');
|
|
116
|
-
buildInfo = await detectBuild(projectPath);
|
|
149
|
+
buildInfo = await detectBuild(projectPath, buildOptions);
|
|
117
150
|
if (!buildInfo) {
|
|
118
151
|
spinner.stop(pc.red('✗ No build found'));
|
|
119
|
-
p.log.error(
|
|
152
|
+
p.log.error(getMissingBuildMessage(projectPath, options));
|
|
153
|
+
p.note('Use deploy without --skip-build to build first.', 'Tip');
|
|
120
154
|
process.exit(1);
|
|
121
155
|
}
|
|
122
156
|
spinner.stop(pc.green('✓ Build found'));
|
|
@@ -182,9 +216,9 @@ import { loginCommand } from './login.js';
|
|
|
182
216
|
process.exit(1);
|
|
183
217
|
}
|
|
184
218
|
// Verify build output
|
|
185
|
-
buildInfo = await detectBuild(projectPath);
|
|
219
|
+
buildInfo = await detectBuild(projectPath, buildOptions);
|
|
186
220
|
if (!buildInfo) {
|
|
187
|
-
p.log.error(pc.red(
|
|
221
|
+
p.log.error(pc.red(`✗ ${getMissingBuildMessage(projectPath, options)}`));
|
|
188
222
|
p.note('Ensure your build produces a valid output directory.', 'Check Build Configuration');
|
|
189
223
|
process.exit(1);
|
|
190
224
|
}
|
|
@@ -192,12 +226,12 @@ import { loginCommand } from './login.js';
|
|
|
192
226
|
// ===== DEPLOYMENT PREPARATION =====
|
|
193
227
|
// Detect framework adapter
|
|
194
228
|
spinner.start('Detecting framework...');
|
|
195
|
-
const adapter = await detectAdapter(projectPath, options.adapter);
|
|
229
|
+
const adapter = await detectAdapter(projectPath, options.adapter, options.output);
|
|
196
230
|
spinner.stop(pc.green(`✓ Detected ${adapter.name} adapter`));
|
|
197
231
|
// Collect pages and assets
|
|
198
232
|
spinner.start('Collecting assets...');
|
|
199
|
-
const pages = await adapter.collectPages(projectPath);
|
|
200
|
-
const assets = await adapter.collectAssets(projectPath);
|
|
233
|
+
const pages = await adapter.collectPages(projectPath, options.output);
|
|
234
|
+
const assets = await adapter.collectAssets(projectPath, options.output);
|
|
201
235
|
spinner.stop(pc.green(`✓ ${pages.routes.length} pages, ${assets.routes.length} assets detected`));
|
|
202
236
|
// Create deployment package (if server adapter)
|
|
203
237
|
let zipPath = null;
|
|
@@ -205,7 +239,7 @@ import { loginCommand } from './login.js';
|
|
|
205
239
|
let unzippedBytes = 0;
|
|
206
240
|
spinner.start('Creating deployment package...');
|
|
207
241
|
try {
|
|
208
|
-
const bundle = await adapter.prepareLambdaBundle(projectPath);
|
|
242
|
+
const bundle = await adapter.prepareLambdaBundle(projectPath, options.output);
|
|
209
243
|
if (bundle) {
|
|
210
244
|
zipPath = bundle.zipPath;
|
|
211
245
|
unzippedBytes = bundle.unzippedBytes;
|
|
@@ -342,3 +376,7 @@ import { loginCommand } from './login.js';
|
|
|
342
376
|
process.exit(1);
|
|
343
377
|
}
|
|
344
378
|
}
|
|
379
|
+
function getMissingBuildMessage(projectPath, options) {
|
|
380
|
+
const location = options.output ? ` at ${path.resolve(projectPath, options.output)}` : '';
|
|
381
|
+
return options.adapter ? `No ${options.adapter} build found${location}.` : `No supported build found${location}.`;
|
|
382
|
+
}
|