@payloadcms/figma 0.0.1-alpha.5 → 0.0.1-alpha.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/control-plane.d.ts +31 -1
- package/dist/api/control-plane.js +137 -67
- package/dist/api/figma-api.d.ts +20 -0
- package/dist/api/figma-api.js +77 -21
- package/dist/auth/callback-server.js +2 -1
- package/dist/auth/crypto-utils.js +5 -5
- package/dist/auth/jwt-validator.d.ts +2 -1
- package/dist/auth/jwt-validator.js +2 -2
- package/dist/auth/oauth-flow.d.ts +1 -1
- package/dist/auth/oauth-flow.js +15 -11
- package/dist/auth/project-token.js +11 -6
- package/dist/auth/refresh.d.ts +2 -1
- package/dist/auth/refresh.js +25 -12
- package/dist/auth/token-store.d.ts +40 -1
- package/dist/auth/token-store.js +65 -5
- package/dist/auth/types.d.ts +17 -4
- package/dist/cli.js +54 -6
- package/dist/commands/build-lambda-zip.d.ts +5 -0
- package/dist/commands/build-lambda-zip.js +19 -0
- package/dist/commands/debug.d.ts +8 -0
- package/dist/commands/debug.js +161 -0
- package/dist/commands/deploy.d.ts +6 -0
- package/dist/commands/deploy.js +94 -126
- package/dist/commands/env.d.ts +13 -0
- package/dist/commands/env.js +88 -0
- package/dist/commands/init.d.ts +3 -5
- package/dist/commands/init.js +118 -94
- package/dist/commands/list-tokens.d.ts +3 -3
- package/dist/commands/list-tokens.js +22 -7
- package/dist/commands/login.d.ts +8 -1
- package/dist/commands/login.js +30 -12
- package/dist/commands/logout.d.ts +5 -4
- package/dist/commands/logout.js +56 -13
- package/dist/config/oauth.d.ts +4 -14
- package/dist/config/oauth.js +18 -40
- package/dist/constants.d.ts +36 -19
- package/dist/constants.js +58 -20
- package/dist/db-content-api/README.md +98 -0
- package/dist/db-content-api/generated/content-api-types.d.ts +3746 -0
- package/dist/db-content-api/generated/content-api-types.js +7 -0
- package/dist/db-content-api/index.d.ts +20 -0
- package/dist/db-content-api/index.js +702 -0
- package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
- package/dist/db-content-api/temp-utilities/slug.js +3 -0
- package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
- package/dist/db-content-api/temp-utilities/sorting.js +32 -0
- package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
- package/dist/db-content-api/temp-utilities/types.js +15 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +34 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +53 -0
- package/dist/db-content-api/utilities/auth.d.ts +30 -0
- package/dist/db-content-api/utilities/auth.js +81 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +59 -0
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
- package/dist/db-content-api/utilities/data/castFieldValue.js +69 -0
- package/dist/db-content-api/utilities/data/index.d.ts +42 -0
- package/dist/db-content-api/utilities/data/index.js +211 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
- package/dist/db-content-api/utilities/data/stripFields.js +195 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
- package/dist/db-content-api/utilities/joins.d.ts +55 -0
- package/dist/db-content-api/utilities/joins.js +136 -0
- package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
- package/dist/db-content-api/utilities/locale/index.js +21 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +66 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +37 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js +33 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +13 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +181 -0
- package/dist/db-content-api/utilities/where.d.ts +20 -0
- package/dist/db-content-api/utilities/where.js +127 -0
- package/dist/endpoints/health.d.ts +3 -0
- package/dist/endpoints/health.js +11 -0
- package/dist/endpoints/schema.d.ts +3 -0
- package/dist/endpoints/schema.js +29 -0
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.js +3 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatar/index.js +27 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/components/LoginButton/index.js +50 -6
- package/dist/oauth/components/LoginButton/index.scss +50 -3
- package/dist/oauth/components/LogoutButton/index.js +5 -4
- package/dist/oauth/defaults.js +67 -10
- package/dist/oauth/endpoints/getLoginEndpoint.js +69 -24
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
- package/dist/oauth/index.js +40 -5
- package/dist/oauth/strategy/index.d.ts +0 -2
- package/dist/oauth/strategy/index.js +40 -17
- package/dist/oauth/types.d.ts +6 -6
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
- package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
- package/dist/oauth/utilities/refreshTokens.js +3 -3
- package/dist/plugin/build-config.d.ts +21 -14
- package/dist/plugin/build-config.js +208 -17
- package/dist/storage-content-api/api-types.d.ts +168 -0
- package/dist/storage-content-api/api-types.js +6 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +42 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
- package/dist/storage-content-api/client.d.ts +6 -0
- package/dist/storage-content-api/client.js +36 -0
- package/dist/storage-content-api/generateURL.d.ts +7 -0
- package/dist/storage-content-api/generateURL.js +8 -0
- package/dist/storage-content-api/handleDelete.d.ts +8 -0
- package/dist/storage-content-api/handleDelete.js +17 -0
- package/dist/storage-content-api/handleUpload.d.ts +11 -0
- package/dist/storage-content-api/handleUpload.js +144 -0
- package/dist/storage-content-api/index.d.ts +5 -0
- package/dist/storage-content-api/index.js +31 -0
- package/dist/storage-content-api/staticHandler.d.ts +10 -0
- package/dist/storage-content-api/staticHandler.js +56 -0
- package/dist/storage-content-api/types.d.ts +10 -0
- package/dist/storage-content-api/types.js +3 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
- package/dist/storage-content-api/utilities/index.d.ts +2 -0
- package/dist/storage-content-api/utilities/index.js +3 -0
- package/dist/templates/.env.example +5 -0
- package/dist/templates/README.md +19 -0
- package/dist/types/config.d.ts +2 -1
- package/dist/types/config.js +0 -2
- package/dist/types.d.ts +3 -1
- package/dist/utils/asset-collection.d.ts +3 -6
- package/dist/utils/asset-collection.js +10 -34
- package/dist/utils/build-lambda-zip.d.ts +14 -0
- package/dist/utils/build-lambda-zip.js +81 -0
- package/dist/utils/cache-bootstrap.d.ts +8 -0
- package/dist/utils/cache-bootstrap.js +18 -0
- package/dist/utils/config.js +1 -1
- package/dist/utils/env-management.d.ts +16 -7
- package/dist/utils/env-management.js +85 -64
- package/dist/utils/format-env-suffix.d.ts +12 -0
- package/dist/utils/format-env-suffix.js +13 -0
- package/dist/utils/formatter.js +3 -5
- package/dist/utils/lambda-config.d.ts +3 -1
- package/dist/utils/lambda-config.js +38 -32
- package/dist/utils/messages.d.ts +1 -1
- package/dist/utils/messages.js +22 -8
- package/dist/utils/package-manager.d.ts +24 -0
- package/dist/utils/package-manager.js +53 -0
- package/dist/utils/payload-config-ast.d.ts +22 -3
- package/dist/utils/payload-config-ast.js +96 -31
- package/dist/utils/payload-config-finder.d.ts +2 -2
- package/dist/utils/payload-config-finder.js +48 -9
- package/dist/utils/payload-config-modifier.d.ts +1 -1
- package/dist/utils/payload-config-modifier.js +58 -9
- package/dist/utils/payload-package-check.d.ts +12 -1
- package/dist/utils/payload-package-check.js +63 -5
- package/dist/utils/project.d.ts +3 -2
- package/dist/utils/project.js +15 -7
- package/dist/utils/resolve-environment.d.ts +14 -0
- package/dist/utils/resolve-environment.js +28 -0
- package/dist/utils/s3-upload.d.ts +0 -1
- package/dist/utils/s3-upload.js +10 -3
- package/dist/utils/token-display.js +11 -5
- package/dist/utils/typescript-validator.js +4 -6
- package/dist/utils/version-check.d.ts +3 -0
- package/dist/utils/version-check.js +38 -0
- package/package.json +29 -10
- package/dist/api/control-plane.d.ts.map +0 -1
- package/dist/api/control-plane.js.map +0 -1
- package/dist/api/figma-api.d.ts.map +0 -1
- package/dist/api/figma-api.js.map +0 -1
- package/dist/auth/browser.d.ts.map +0 -1
- package/dist/auth/browser.js.map +0 -1
- package/dist/auth/callback-server.d.ts.map +0 -1
- package/dist/auth/callback-server.js.map +0 -1
- package/dist/auth/crypto-utils.d.ts.map +0 -1
- package/dist/auth/crypto-utils.js.map +0 -1
- package/dist/auth/jwt-validator.d.ts.map +0 -1
- package/dist/auth/jwt-validator.js.map +0 -1
- package/dist/auth/oauth-flow.d.ts.map +0 -1
- package/dist/auth/oauth-flow.js.map +0 -1
- package/dist/auth/pkce.d.ts.map +0 -1
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/project-token.d.ts.map +0 -1
- package/dist/auth/project-token.js.map +0 -1
- package/dist/auth/refresh.d.ts.map +0 -1
- package/dist/auth/refresh.js.map +0 -1
- package/dist/auth/token-store.d.ts.map +0 -1
- package/dist/auth/token-store.js.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list-tokens.d.ts.map +0 -1
- package/dist/commands/list-tokens.js.map +0 -1
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js.map +0 -1
- package/dist/config/oauth.d.ts.map +0 -1
- package/dist/config/oauth.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/exports/client.d.ts.map +0 -1
- package/dist/exports/client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LoginButton/index.js.map +0 -1
- package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LogoutButton/index.js.map +0 -1
- package/dist/oauth/defaults.d.ts.map +0 -1
- package/dist/oauth/defaults.js.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
- package/dist/oauth/exports/client.d.ts.map +0 -1
- package/dist/oauth/exports/client.js.map +0 -1
- package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
- package/dist/oauth/hooks/afterLogout.js.map +0 -1
- package/dist/oauth/hooks/me.d.ts.map +0 -1
- package/dist/oauth/hooks/me.js.map +0 -1
- package/dist/oauth/hooks/refresh.d.ts.map +0 -1
- package/dist/oauth/hooks/refresh.js.map +0 -1
- package/dist/oauth/index.d.ts.map +0 -1
- package/dist/oauth/index.js.map +0 -1
- package/dist/oauth/strategy/index.d.ts.map +0 -1
- package/dist/oauth/strategy/index.js.map +0 -1
- package/dist/oauth/types.d.ts.map +0 -1
- package/dist/oauth/types.js.map +0 -1
- package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
- package/dist/oauth/utilities/clearCookie.js.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
- package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
- package/dist/oauth/utilities/extractOrigin.js.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
- package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
- package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminPath.js +0 -9
- package/dist/oauth/utilities/getAdminPath.js.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
- package/dist/oauth/utilities/getUsernameField.js.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
- package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
- package/dist/oauth/utilities/refreshTokens.js.map +0 -1
- package/dist/plugin/adapter.d.ts.map +0 -1
- package/dist/plugin/adapter.js.map +0 -1
- package/dist/plugin/build-config.d.ts.map +0 -1
- package/dist/plugin/build-config.js.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/asset-collection.d.ts.map +0 -1
- package/dist/utils/asset-collection.js.map +0 -1
- package/dist/utils/build-detection.d.ts.map +0 -1
- package/dist/utils/build-detection.js.map +0 -1
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/download-template.d.ts.map +0 -1
- package/dist/utils/download-template.js.map +0 -1
- package/dist/utils/env-management.d.ts.map +0 -1
- package/dist/utils/env-management.js.map +0 -1
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/formatter.d.ts.map +0 -1
- package/dist/utils/formatter.js.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/is-debug.d.ts.map +0 -1
- package/dist/utils/is-debug.js.map +0 -1
- package/dist/utils/lambda-config.d.ts.map +0 -1
- package/dist/utils/lambda-config.js.map +0 -1
- package/dist/utils/log.d.ts.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/messages.d.ts.map +0 -1
- package/dist/utils/messages.js.map +0 -1
- package/dist/utils/package-manager.d.ts.map +0 -1
- package/dist/utils/package-manager.js.map +0 -1
- package/dist/utils/payload-config-ast.d.ts.map +0 -1
- package/dist/utils/payload-config-ast.js.map +0 -1
- package/dist/utils/payload-config-finder.d.ts.map +0 -1
- package/dist/utils/payload-config-finder.js.map +0 -1
- package/dist/utils/payload-config-modifier.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.js.map +0 -1
- package/dist/utils/payload-package-check.d.ts.map +0 -1
- package/dist/utils/payload-package-check.js.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/project.js.map +0 -1
- package/dist/utils/s3-upload.d.ts.map +0 -1
- package/dist/utils/s3-upload.js.map +0 -1
- package/dist/utils/token-display.d.ts.map +0 -1
- package/dist/utils/token-display.js.map +0 -1
- package/dist/utils/typescript-validator.d.ts.map +0 -1
- package/dist/utils/typescript-validator.js.map +0 -1
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Get an environment variable value from .env file (async)
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
4
|
+
* @param projectPath - Path to project directory
|
|
5
|
+
* @param key - Environment variable name to retrieve
|
|
6
|
+
* @returns The value if found, null otherwise
|
|
5
7
|
*/
|
|
6
|
-
export declare function
|
|
8
|
+
export declare function getEnvVar(projectPath: string, key: string): Promise<null | string>;
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
10
|
+
* Get an environment variable value from .env file (sync)
|
|
9
11
|
*
|
|
10
|
-
*
|
|
12
|
+
* @param projectPath - Path to project directory
|
|
13
|
+
* @param key - Environment variable name to retrieve
|
|
14
|
+
* @returns The value if found, null otherwise
|
|
15
|
+
*/
|
|
16
|
+
export declare function getEnvVarSync(projectPath: string, key: string): null | string;
|
|
17
|
+
/**
|
|
18
|
+
* Add or update an environment variable in .env file
|
|
11
19
|
*
|
|
12
20
|
* @param projectPath - Path to project directory
|
|
13
|
-
* @
|
|
21
|
+
* @param key - Environment variable name
|
|
22
|
+
* @param value - Environment variable value
|
|
14
23
|
*/
|
|
15
|
-
export declare function
|
|
24
|
+
export declare function addOrUpdateEnvVar(projectPath: string, key: string, value: string): Promise<void>;
|
|
16
25
|
//# sourceMappingURL=env-management.d.ts.map
|
|
@@ -1,97 +1,118 @@
|
|
|
1
|
-
import { randomBytes } from 'crypto';
|
|
2
1
|
import fs from 'fs/promises';
|
|
2
|
+
import fsSync from 'node:fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/ export function generateSecret() {
|
|
9
|
-
return randomBytes(32).toString('hex').slice(0, 24);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Sanitize and process environment file contents
|
|
13
|
-
*
|
|
14
|
-
* @param contents - Raw .env file contents
|
|
15
|
-
* @param payloadSecret - Secret to use for PAYLOAD_SECRET
|
|
16
|
-
* @returns Processed .env contents
|
|
17
|
-
*/ function sanitizeEnv(contents, payloadSecret) {
|
|
18
|
-
const lines = contents.split('\n');
|
|
19
|
-
const seenKeys = new Set();
|
|
20
|
-
const processedLines = [];
|
|
5
|
+
* Parse .env file contents and extract value for a key
|
|
6
|
+
*/ function parseEnvValue(contents, key) {
|
|
7
|
+
const lines = contents.split(/\r?\n/);
|
|
21
8
|
for (const line of lines){
|
|
22
9
|
// Skip empty lines and comments
|
|
23
10
|
if (!line.trim() || line.trim().startsWith('#')) {
|
|
24
|
-
processedLines.push(line);
|
|
25
11
|
continue;
|
|
26
12
|
}
|
|
27
13
|
// Skip lines without =
|
|
28
14
|
if (!line.includes('=')) {
|
|
29
|
-
processedLines.push(line);
|
|
30
15
|
continue;
|
|
31
16
|
}
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
seenKeys.add(trimmedKey);
|
|
39
|
-
// Replace PAYLOAD_SECRET with actual value
|
|
40
|
-
if (trimmedKey === 'PAYLOAD_SECRET' || trimmedKey === 'PAYLOAD_SECRET_KEY') {
|
|
41
|
-
processedLines.push(`PAYLOAD_SECRET=${payloadSecret}`);
|
|
42
|
-
} else {
|
|
43
|
-
processedLines.push(line);
|
|
17
|
+
const equalsIndex = line.indexOf('=');
|
|
18
|
+
const lineKey = line.substring(0, equalsIndex).trim();
|
|
19
|
+
if (lineKey === key) {
|
|
20
|
+
return line.substring(equalsIndex + 1);
|
|
44
21
|
}
|
|
45
22
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get an environment variable value from .env file (async)
|
|
27
|
+
*
|
|
28
|
+
* @param projectPath - Path to project directory
|
|
29
|
+
* @param key - Environment variable name to retrieve
|
|
30
|
+
* @returns The value if found, null otherwise
|
|
31
|
+
*/ export async function getEnvVar(projectPath, key) {
|
|
32
|
+
const envPath = path.join(projectPath, '.env');
|
|
33
|
+
try {
|
|
34
|
+
const contents = await fs.readFile(envPath, 'utf-8');
|
|
35
|
+
return parseEnvValue(contents, key);
|
|
36
|
+
} catch {
|
|
37
|
+
// File doesn't exist or can't be read
|
|
38
|
+
return null;
|
|
49
39
|
}
|
|
50
|
-
return processedLines.join('\n');
|
|
51
40
|
}
|
|
52
41
|
/**
|
|
53
|
-
*
|
|
42
|
+
* Get an environment variable value from .env file (sync)
|
|
54
43
|
*
|
|
55
|
-
*
|
|
44
|
+
* @param projectPath - Path to project directory
|
|
45
|
+
* @param key - Environment variable name to retrieve
|
|
46
|
+
* @returns The value if found, null otherwise
|
|
47
|
+
*/ export function getEnvVarSync(projectPath, key) {
|
|
48
|
+
const envPath = path.join(projectPath, '.env');
|
|
49
|
+
try {
|
|
50
|
+
const contents = fsSync.readFileSync(envPath, 'utf-8');
|
|
51
|
+
return parseEnvValue(contents, key);
|
|
52
|
+
} catch {
|
|
53
|
+
// File doesn't exist or can't be read
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Add or update an environment variable in .env file
|
|
56
59
|
*
|
|
57
60
|
* @param projectPath - Path to project directory
|
|
58
|
-
* @
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const envExamplePath = path.join(projectPath, '.env.example');
|
|
61
|
+
* @param key - Environment variable name
|
|
62
|
+
* @param value - Environment variable value
|
|
63
|
+
*/ export async function addOrUpdateEnvVar(projectPath, key, value) {
|
|
62
64
|
const envPath = path.join(projectPath, '.env');
|
|
63
65
|
try {
|
|
64
|
-
|
|
65
|
-
let envExampleContents = '';
|
|
66
|
-
try {
|
|
67
|
-
envExampleContents = await fs.readFile(envExamplePath, 'utf-8');
|
|
68
|
-
} catch {
|
|
69
|
-
// No .env.example, create minimal .env
|
|
70
|
-
envExampleContents = '';
|
|
71
|
-
}
|
|
72
|
-
// Check if .env already exists
|
|
66
|
+
let contents = '';
|
|
73
67
|
let envExists = false;
|
|
68
|
+
// Try to read existing .env file
|
|
74
69
|
try {
|
|
75
|
-
await fs.
|
|
70
|
+
contents = await fs.readFile(envPath, 'utf-8');
|
|
76
71
|
envExists = true;
|
|
77
72
|
} catch {
|
|
78
|
-
// .env doesn't exist
|
|
73
|
+
// .env doesn't exist, will create it
|
|
79
74
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
//
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
const lines = contents.split(/\r?\n/);
|
|
76
|
+
const seenKeys = new Set();
|
|
77
|
+
const processedLines = [];
|
|
78
|
+
let keyUpdated = false;
|
|
79
|
+
for (const line of lines){
|
|
80
|
+
// Skip empty lines at start if file didn't exist
|
|
81
|
+
if (!envExists && !line.trim()) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
// Preserve empty lines and comments
|
|
85
|
+
if (!line.trim() || line.trim().startsWith('#')) {
|
|
86
|
+
processedLines.push(line);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
// Skip lines without =
|
|
90
|
+
if (!line.includes('=')) {
|
|
91
|
+
processedLines.push(line);
|
|
92
|
+
continue;
|
|
90
93
|
}
|
|
94
|
+
const [lineKey] = line.split('=');
|
|
95
|
+
const trimmedKey = lineKey.trim();
|
|
96
|
+
// Skip duplicate keys (keep first occurrence)
|
|
97
|
+
if (seenKeys.has(trimmedKey)) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
seenKeys.add(trimmedKey);
|
|
101
|
+
// Update or keep the line
|
|
102
|
+
if (trimmedKey === key) {
|
|
103
|
+
processedLines.push(`${key}=${value}`);
|
|
104
|
+
keyUpdated = true;
|
|
105
|
+
} else {
|
|
106
|
+
processedLines.push(line);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Add key if not present
|
|
110
|
+
if (!keyUpdated) {
|
|
111
|
+
processedLines.push(`${key}=${value}`);
|
|
91
112
|
}
|
|
92
|
-
|
|
113
|
+
await fs.writeFile(envPath, processedLines.join('\n'), 'utf-8');
|
|
93
114
|
} catch (error) {
|
|
94
|
-
throw new Error(`Failed to
|
|
115
|
+
throw new Error(`Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
95
116
|
}
|
|
96
117
|
}
|
|
97
118
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Environment } from '../constants.js';
|
|
2
|
+
/**
|
|
3
|
+
* Format environment suffix for user-facing messages.
|
|
4
|
+
* Returns empty string for production (default), suffix for other environments.
|
|
5
|
+
*
|
|
6
|
+
* @param env - The environment
|
|
7
|
+
* @param prefix - Prefix before environment name (default: ' to ')
|
|
8
|
+
* @param suffix - Suffix after environment name (default: '')
|
|
9
|
+
* @returns Formatted string or empty string for production
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatEnvSuffix(env: Environment, prefix?: string, suffix?: string): string;
|
|
12
|
+
//# sourceMappingURL=format-env-suffix.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format environment suffix for user-facing messages.
|
|
3
|
+
* Returns empty string for production (default), suffix for other environments.
|
|
4
|
+
*
|
|
5
|
+
* @param env - The environment
|
|
6
|
+
* @param prefix - Prefix before environment name (default: ' to ')
|
|
7
|
+
* @param suffix - Suffix after environment name (default: '')
|
|
8
|
+
* @returns Formatted string or empty string for production
|
|
9
|
+
*/ export function formatEnvSuffix(env, prefix = ' to ', suffix = '') {
|
|
10
|
+
return env !== 'production' ? `${prefix}${env}${suffix}` : '';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=format-env-suffix.js.map
|
package/dist/utils/formatter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import spawn from 'cross-spawn';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
/**
|
|
4
4
|
* Format file with Prettier
|
|
@@ -6,15 +6,13 @@ import path from 'path';
|
|
|
6
6
|
*/ export async function formatFile(filePath, packageManager) {
|
|
7
7
|
return new Promise((resolve)=>{
|
|
8
8
|
try {
|
|
9
|
-
const
|
|
9
|
+
const child = spawn(packageManager, [
|
|
10
10
|
'exec',
|
|
11
11
|
'prettier',
|
|
12
12
|
'--write',
|
|
13
13
|
filePath
|
|
14
|
-
]
|
|
15
|
-
const child = spawn(packageManager, args, {
|
|
14
|
+
], {
|
|
16
15
|
cwd: path.dirname(filePath),
|
|
17
|
-
shell: true,
|
|
18
16
|
stdio: 'pipe'
|
|
19
17
|
});
|
|
20
18
|
child.on('close', (code)=>{
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { PackageManager } from './package-manager.js';
|
|
1
2
|
/**
|
|
2
3
|
* Apply Lambda-specific modifications to a Payload project
|
|
3
4
|
*
|
|
4
5
|
* @param projectPath - Path to project directory
|
|
6
|
+
* @param packageManager - Package manager to use in scripts (defaults to 'npm')
|
|
5
7
|
*/
|
|
6
|
-
export declare function applyLambdaModifications(projectPath: string): Promise<void>;
|
|
8
|
+
export declare function applyLambdaModifications(projectPath: string, packageManager?: PackageManager): Promise<void>;
|
|
7
9
|
//# sourceMappingURL=lambda-config.d.ts.map
|
|
@@ -7,30 +7,19 @@ const RUN_SH_CONTENT = `#!/bin/bash -x
|
|
|
7
7
|
|
|
8
8
|
NODE_ENV=production exec node server.js
|
|
9
9
|
`;
|
|
10
|
-
const BUILD_FOR_LAMBDA_SH_CONTENT = `#!/bin/bash
|
|
11
|
-
|
|
12
|
-
cp -r .next/static .next/standalone/.next/static
|
|
13
|
-
cp run.sh .next/standalone/run.sh
|
|
14
|
-
cd .next/standalone
|
|
15
|
-
zip -r --symlinks lambda.zip .
|
|
16
|
-
mv lambda.zip ../..
|
|
17
|
-
`;
|
|
18
10
|
/**
|
|
19
11
|
* Apply Lambda-specific modifications to a Payload project
|
|
20
12
|
*
|
|
21
13
|
* @param projectPath - Path to project directory
|
|
22
|
-
|
|
14
|
+
* @param packageManager - Package manager to use in scripts (defaults to 'npm')
|
|
15
|
+
*/ export async function applyLambdaModifications(projectPath, packageManager = 'npm') {
|
|
23
16
|
// 1. Create run.sh
|
|
24
17
|
const runShPath = path.join(projectPath, 'run.sh');
|
|
25
18
|
await fs.writeFile(runShPath, RUN_SH_CONTENT, 'utf-8');
|
|
26
|
-
await fs.chmod(runShPath, 0o755);
|
|
27
|
-
// 2.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
await fs.chmod(buildShPath, 0o755);
|
|
31
|
-
// 3. Modify next config to add standalone output
|
|
32
|
-
await addStandaloneToNextConfig(projectPath);
|
|
33
|
-
// 4. Create/update .npmrc
|
|
19
|
+
await fs.chmod(runShPath, 0o755);
|
|
20
|
+
// 2. Modify next config to add standalone output and eslint ignore
|
|
21
|
+
await addNextConfigProperties(projectPath);
|
|
22
|
+
// 3. Create/update .npmrc
|
|
34
23
|
const npmrcPath = path.join(projectPath, '.npmrc');
|
|
35
24
|
let npmrcContent = '';
|
|
36
25
|
try {
|
|
@@ -43,8 +32,8 @@ mv lambda.zip ../..
|
|
|
43
32
|
npmrcContent += 'node-linker=hoisted\n';
|
|
44
33
|
await fs.writeFile(npmrcPath, npmrcContent, 'utf-8');
|
|
45
34
|
}
|
|
46
|
-
//
|
|
47
|
-
await addLambdaBuildScript(projectPath);
|
|
35
|
+
// 4. Add lambda:buildzip script to package.json
|
|
36
|
+
await addLambdaBuildScript(projectPath, packageManager);
|
|
48
37
|
}
|
|
49
38
|
/**
|
|
50
39
|
* Find the Next.js config file (next.config.js or next.config.mjs)
|
|
@@ -67,13 +56,18 @@ mv lambda.zip ../..
|
|
|
67
56
|
throw new Error('Could not find next.config.js or next.config.mjs');
|
|
68
57
|
}
|
|
69
58
|
/**
|
|
70
|
-
* Add
|
|
71
|
-
|
|
59
|
+
* Add required Next.js config properties using AST parsing
|
|
60
|
+
* - output: 'standalone' (for Lambda deployment)
|
|
61
|
+
* - eslint: { ignoreDuringBuilds: true } (allow builds with lint errors)
|
|
62
|
+
*/ async function addNextConfigProperties(projectPath) {
|
|
72
63
|
const nextConfigPath = await findNextConfigPath(projectPath);
|
|
73
64
|
const content = await fs.readFile(nextConfigPath, 'utf-8');
|
|
74
|
-
// Check
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
// Check which properties already exist
|
|
66
|
+
const hasOutput = content.includes('output:');
|
|
67
|
+
const hasEslint = content.includes('eslint:');
|
|
68
|
+
// Early exit if both already configured
|
|
69
|
+
if (hasOutput && hasEslint) {
|
|
70
|
+
return;
|
|
77
71
|
}
|
|
78
72
|
const ast = parseModule(content, {
|
|
79
73
|
loc: true
|
|
@@ -114,30 +108,42 @@ mv lambda.zip ../..
|
|
|
114
108
|
throw new Error(`Could not find Next.js config object in ${path.basename(nextConfigPath)}. ` + `Expected either 'export default { ... }' or 'export default wrapper(configVar, ...)'`);
|
|
115
109
|
}
|
|
116
110
|
const { loc } = targetObjectExpression;
|
|
117
|
-
const lines = content.split(
|
|
118
|
-
//
|
|
111
|
+
const lines = content.split(/\r?\n/);
|
|
112
|
+
// Build insertion string based on what's missing
|
|
113
|
+
const parts = [];
|
|
114
|
+
if (!hasOutput) {
|
|
115
|
+
parts.push("output: 'standalone',");
|
|
116
|
+
}
|
|
117
|
+
if (!hasEslint) {
|
|
118
|
+
parts.push(`eslint: {
|
|
119
|
+
ignoreDuringBuilds: true,
|
|
120
|
+
},`);
|
|
121
|
+
}
|
|
122
|
+
const insertString = '\n ' + parts.join('\n ');
|
|
123
|
+
// Insert after opening brace
|
|
119
124
|
const insertLine = loc.start.line - 1;
|
|
120
|
-
const insertColumn = loc.start.column + 1
|
|
121
|
-
;
|
|
122
|
-
// Find the content of the line with the opening brace
|
|
125
|
+
const insertColumn = loc.start.column + 1;
|
|
123
126
|
const targetLine = lines[insertLine];
|
|
124
127
|
if (!targetLine) {
|
|
125
128
|
throw new Error(`Could not find target line in ${path.basename(nextConfigPath)}`);
|
|
126
129
|
}
|
|
127
|
-
lines[insertLine] = targetLine.slice(0, insertColumn) +
|
|
130
|
+
lines[insertLine] = targetLine.slice(0, insertColumn) + insertString + targetLine.slice(insertColumn);
|
|
128
131
|
const modifiedContent = lines.join('\n');
|
|
129
132
|
await fs.writeFile(nextConfigPath, modifiedContent, 'utf-8');
|
|
130
133
|
}
|
|
131
134
|
/**
|
|
132
135
|
* Add lambda:buildzip script to package.json
|
|
133
|
-
*/ async function addLambdaBuildScript(projectPath) {
|
|
136
|
+
*/ async function addLambdaBuildScript(projectPath, packageManager) {
|
|
134
137
|
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
135
138
|
const content = await fs.readFile(packageJsonPath, 'utf-8');
|
|
136
139
|
const packageJson = JSON.parse(content);
|
|
137
140
|
if (!packageJson.scripts) {
|
|
138
141
|
packageJson.scripts = {};
|
|
139
142
|
}
|
|
140
|
-
|
|
143
|
+
// Use package manager's run and exec commands
|
|
144
|
+
const runCmd = packageManager === 'npm' ? 'npm run' : packageManager;
|
|
145
|
+
const execCmd = packageManager === 'npm' ? 'npx' : `${packageManager} exec`;
|
|
146
|
+
packageJson.scripts['lambda:buildzip'] = `${runCmd} build && ${execCmd} payloadcms-figma build-lambda-zip`;
|
|
141
147
|
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n', 'utf-8');
|
|
142
148
|
}
|
|
143
149
|
|
package/dist/utils/messages.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PackageManager } from '
|
|
1
|
+
import type { PackageManager } from './package-manager.js';
|
|
2
2
|
export declare function helpMessage(): void;
|
|
3
3
|
export declare function successMessage(projectDir: string, packageManager: PackageManager): string;
|
|
4
4
|
export declare function successfulNextInit(): string;
|
package/dist/utils/messages.js
CHANGED
|
@@ -14,31 +14,45 @@ export function helpMessage() {
|
|
|
14
14
|
${pc.cyan('logout')} Clear all stored tokens
|
|
15
15
|
${pc.cyan('list-tokens')} Show stored token information
|
|
16
16
|
${pc.cyan('init')} Initialize a Figma CMS project
|
|
17
|
+
${pc.cyan('debug')} Show debug info for troubleshooting
|
|
18
|
+
${pc.cyan('env')} Switch active environment
|
|
17
19
|
${pc.cyan('deploy')} Deploy your project to Figma
|
|
20
|
+
${pc.cyan('build-lambda-zip')} Build Lambda deployment zip
|
|
18
21
|
|
|
19
22
|
${pc.bold('OPTIONS')}
|
|
20
23
|
|
|
21
24
|
${pc.dim('-h, --help Show help')}
|
|
25
|
+
${pc.dim('-v, --version Show CLI version')}
|
|
22
26
|
${pc.dim('--debug Enable debug logging')}
|
|
23
27
|
|
|
24
28
|
${pc.bold('AUTHENTICATION')}
|
|
25
29
|
|
|
26
30
|
${pc.cyan('@payloadcms/figma login')} Authenticate with Figma
|
|
27
|
-
${pc.cyan('@payloadcms/figma logout')} Clear
|
|
31
|
+
${pc.cyan('@payloadcms/figma logout')} Clear tokens for current environment
|
|
28
32
|
${pc.cyan('@payloadcms/figma list-tokens')} Display stored OAuth and project tokens
|
|
29
33
|
|
|
30
34
|
${pc.bold('INIT COMMAND')}
|
|
31
35
|
|
|
32
|
-
${pc.cyan('@payloadcms/figma init --id <cms-id>')}
|
|
33
|
-
${pc.cyan('@payloadcms/figma init')}
|
|
34
|
-
${pc.
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
${pc.cyan('@payloadcms/figma init --id <cms-resource-id>')} Initialize project
|
|
37
|
+
${pc.cyan('@payloadcms/figma init --id <id> --env staging')} Initialize for specific environment
|
|
38
|
+
${pc.dim('--force')} Force reconfiguration of existing project
|
|
39
|
+
|
|
40
|
+
${pc.bold('ENV COMMAND')}
|
|
41
|
+
|
|
42
|
+
${pc.cyan('@payloadcms/figma env')} List and switch environments
|
|
43
|
+
${pc.cyan('@payloadcms/figma env production')} Switch to a named environment
|
|
37
44
|
|
|
38
45
|
${pc.bold('DEPLOY COMMAND')}
|
|
39
46
|
|
|
40
|
-
${pc.cyan('@payloadcms/figma deploy')}
|
|
41
|
-
${pc.dim('--
|
|
47
|
+
${pc.cyan('@payloadcms/figma deploy')} Deploy your project to Figma
|
|
48
|
+
${pc.dim('--id <project-id>')} Override FIGMA_PROJECT_ID
|
|
49
|
+
${pc.dim('--env <environment>')} Override FIGMA_ENVIRONMENT_NAME
|
|
50
|
+
${pc.dim('--yes, -y')} Skip confirmation prompts
|
|
51
|
+
${pc.dim('--skip-build')} Skip building and use existing build
|
|
52
|
+
|
|
53
|
+
${pc.bold('GLOBAL OPTIONS')}
|
|
54
|
+
|
|
55
|
+
${pc.dim('--infra-env <env>')} Target infrastructure (production or staging)
|
|
42
56
|
|
|
43
57
|
${pc.bold('DOCUMENTATION')}
|
|
44
58
|
|
|
@@ -9,4 +9,28 @@ export type PackageManager = 'npm' | 'pnpm' | 'yarn';
|
|
|
9
9
|
* @returns Detected package manager, defaults to npm
|
|
10
10
|
*/
|
|
11
11
|
export declare function getPackageManager(projectDir: string): Promise<PackageManager>;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve package manager for a project directory.
|
|
14
|
+
* Checks lockfiles first, falls back to environment detection.
|
|
15
|
+
*
|
|
16
|
+
* @param projectDir - Project directory to check
|
|
17
|
+
* @returns Resolved package manager
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolvePackageManager(projectDir: string): Promise<PackageManager>;
|
|
20
|
+
/**
|
|
21
|
+
* Detect package manager from npm_config_user_agent environment variable.
|
|
22
|
+
* Set automatically by npm/pnpm/yarn when running via npx/pnpm dlx/yarn dlx.
|
|
23
|
+
*
|
|
24
|
+
* @returns Detected package manager, defaults to npm
|
|
25
|
+
*/
|
|
26
|
+
export declare function detectPackageManagerFromEnvironment(): PackageManager;
|
|
27
|
+
/**
|
|
28
|
+
* Get the run command prefix for a package manager.
|
|
29
|
+
* npm needs "npm run", pnpm/yarn can run scripts directly.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getRunCommand(packageManager: PackageManager): string;
|
|
32
|
+
/**
|
|
33
|
+
* Get the add/install command for a package manager.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getAddCommand(packageManager: PackageManager): string;
|
|
12
36
|
//# sourceMappingURL=package-manager.d.ts.map
|
|
@@ -23,6 +23,59 @@ import path from 'path';
|
|
|
23
23
|
return 'npm';
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Resolve package manager for a project directory.
|
|
28
|
+
* Checks lockfiles first, falls back to environment detection.
|
|
29
|
+
*
|
|
30
|
+
* @param projectDir - Project directory to check
|
|
31
|
+
* @returns Resolved package manager
|
|
32
|
+
*/ export async function resolvePackageManager(projectDir) {
|
|
33
|
+
const fromLockfile = await getPackageManager(projectDir);
|
|
34
|
+
if (fromLockfile !== 'npm') {
|
|
35
|
+
return fromLockfile;
|
|
36
|
+
}
|
|
37
|
+
// Check if there's actually a package-lock.json (explicit npm choice)
|
|
38
|
+
if (await fileExists(path.join(projectDir, 'package-lock.json'))) {
|
|
39
|
+
return 'npm';
|
|
40
|
+
}
|
|
41
|
+
// No lockfile found — check environment
|
|
42
|
+
return detectPackageManagerFromEnvironment();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Detect package manager from npm_config_user_agent environment variable.
|
|
46
|
+
* Set automatically by npm/pnpm/yarn when running via npx/pnpm dlx/yarn dlx.
|
|
47
|
+
*
|
|
48
|
+
* @returns Detected package manager, defaults to npm
|
|
49
|
+
*/ export function detectPackageManagerFromEnvironment() {
|
|
50
|
+
const userAgent = process.env.npm_config_user_agent;
|
|
51
|
+
if (!userAgent) {
|
|
52
|
+
return 'npm';
|
|
53
|
+
}
|
|
54
|
+
if (userAgent.startsWith('pnpm/')) {
|
|
55
|
+
return 'pnpm';
|
|
56
|
+
}
|
|
57
|
+
if (userAgent.startsWith('yarn/')) {
|
|
58
|
+
return 'yarn';
|
|
59
|
+
}
|
|
60
|
+
return 'npm';
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get the run command prefix for a package manager.
|
|
64
|
+
* npm needs "npm run", pnpm/yarn can run scripts directly.
|
|
65
|
+
*/ export function getRunCommand(packageManager) {
|
|
66
|
+
return packageManager === 'npm' ? 'npm run' : packageManager;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the add/install command for a package manager.
|
|
70
|
+
*/ export function getAddCommand(packageManager) {
|
|
71
|
+
if (packageManager === 'npm') {
|
|
72
|
+
return 'npm install';
|
|
73
|
+
}
|
|
74
|
+
if (packageManager === 'pnpm') {
|
|
75
|
+
return 'pnpm add';
|
|
76
|
+
}
|
|
77
|
+
return 'yarn add';
|
|
78
|
+
}
|
|
26
79
|
/**
|
|
27
80
|
* Check if file exists
|
|
28
81
|
*/ async function fileExists(filePath) {
|
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
import type { SourceFile } from 'ts-morph';
|
|
2
|
+
/**
|
|
3
|
+
* Result of detecting what changes are needed in a payload config file
|
|
4
|
+
*/
|
|
2
5
|
export type DetectionResult = {
|
|
6
|
+
/** Database adapter configuration if present */
|
|
3
7
|
dbProperty?: {
|
|
8
|
+
/** Name of the adapter function (e.g., 'mongooseAdapter', 'postgresAdapter') */
|
|
4
9
|
adapter: string;
|
|
10
|
+
/** NPM package the adapter is imported from (e.g., '@payloadcms/db-mongodb') */
|
|
5
11
|
importSource: string;
|
|
6
12
|
};
|
|
13
|
+
/** Editor configuration if present */
|
|
7
14
|
editorProperty?: {
|
|
15
|
+
/** NPM package the editor is imported from (e.g., '@payloadcms/richtext-lexical') */
|
|
8
16
|
importSource: string;
|
|
17
|
+
/** Whether this is a default editor with no custom configuration */
|
|
9
18
|
isDefault: boolean;
|
|
10
19
|
};
|
|
20
|
+
/** Whether the config already has a `figma` property */
|
|
11
21
|
figmaObjectExists: boolean;
|
|
22
|
+
/** Whether buildConfig/buildFigmaConfig uses an import alias (e.g., 'buildConfig as createConfig') */
|
|
12
23
|
hasAlias: boolean;
|
|
24
|
+
/** Whether a buildConfig or buildFigmaConfig call was found (undefined if not checked) */
|
|
13
25
|
hasBuildConfig?: boolean;
|
|
26
|
+
/** Whether there are other imports from 'payload' besides buildConfig (e.g., types) */
|
|
14
27
|
hasOtherPayloadImports: boolean;
|
|
28
|
+
/** Whether the import needs to be changed from 'payload' to '@payloadcms/figma' */
|
|
15
29
|
needsImportChange: boolean;
|
|
30
|
+
/** Whether a `secret` property exists in the config */
|
|
16
31
|
secretProperty?: boolean;
|
|
32
|
+
/** Sharp configuration if present */
|
|
33
|
+
sharpProperty?: {
|
|
34
|
+
/** NPM package sharp is imported from (always 'sharp') */
|
|
35
|
+
importSource: string;
|
|
36
|
+
};
|
|
17
37
|
};
|
|
18
38
|
/**
|
|
19
39
|
* Detect what changes are needed in the payload config file
|
|
@@ -29,9 +49,8 @@ export type ASTModificationResult = {
|
|
|
29
49
|
*/
|
|
30
50
|
export declare function applyModifications(sourceFile: SourceFile, detection: DetectionResult): ASTModificationResult;
|
|
31
51
|
export type FigmaPropertyConfig = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
useContentSystem: boolean;
|
|
52
|
+
contentSystemId: string;
|
|
53
|
+
useContentSystem?: boolean;
|
|
35
54
|
};
|
|
36
55
|
/**
|
|
37
56
|
* Add figma property to buildConfig if it doesn't exist
|