@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
|
@@ -20,15 +20,18 @@ import * as log from './log.js';
|
|
|
20
20
|
log.debug(`Found import from: ${payloadImport.getModuleSpecifierValue()}`);
|
|
21
21
|
const moduleSpecifier = payloadImport.getModuleSpecifierValue();
|
|
22
22
|
const namedImports = payloadImport.getNamedImports();
|
|
23
|
-
//
|
|
24
|
-
|
|
23
|
+
// Determine which function name to look for based on the import source
|
|
24
|
+
// - From 'payload': look for buildConfig (needs migration)
|
|
25
|
+
// - From '@payloadcms/figma': look for buildFigmaConfig (already migrated)
|
|
26
|
+
const expectedFunctionName = moduleSpecifier === 'payload' ? 'buildConfig' : 'buildFigmaConfig';
|
|
27
|
+
const buildConfigImport = namedImports.find((ni)=>ni.getName() === expectedFunctionName);
|
|
25
28
|
if (!buildConfigImport) {
|
|
26
29
|
result.hasBuildConfig = false;
|
|
27
30
|
return result;
|
|
28
31
|
}
|
|
29
32
|
// Check for alias and get the actual name used in code
|
|
30
33
|
const aliasNode = buildConfigImport.getAliasNode();
|
|
31
|
-
const buildConfigName = aliasNode ? aliasNode.getText() :
|
|
34
|
+
const buildConfigName = aliasNode ? aliasNode.getText() : expectedFunctionName;
|
|
32
35
|
if (aliasNode) {
|
|
33
36
|
result.hasAlias = true;
|
|
34
37
|
}
|
|
@@ -109,6 +112,15 @@ import * as log from './log.js';
|
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
}
|
|
115
|
+
// Check for sharp property
|
|
116
|
+
const sharpProperty = configArg.getProperty('sharp');
|
|
117
|
+
if (sharpProperty) {
|
|
118
|
+
// Find the import source for sharp
|
|
119
|
+
const sharpImport = imports.find((imp)=>imp.getModuleSpecifierValue() === 'sharp' || imp.getNamedImports().some((ni)=>ni.getName() === 'sharp'));
|
|
120
|
+
result.sharpProperty = {
|
|
121
|
+
importSource: sharpImport?.getModuleSpecifierValue() || 'sharp'
|
|
122
|
+
};
|
|
123
|
+
}
|
|
112
124
|
// Check for figma property
|
|
113
125
|
const figmaProperty = configArg.getProperty('figma');
|
|
114
126
|
if (figmaProperty) {
|
|
@@ -240,7 +252,16 @@ import * as log from './log.js';
|
|
|
240
252
|
modified = true;
|
|
241
253
|
}
|
|
242
254
|
}
|
|
243
|
-
// 4.
|
|
255
|
+
// 4. Remove sharp property
|
|
256
|
+
if (detection.sharpProperty) {
|
|
257
|
+
const sharpProperty = configArg.getProperty('sharp');
|
|
258
|
+
if (sharpProperty) {
|
|
259
|
+
sharpProperty.remove();
|
|
260
|
+
changes.push('Removed sharp property');
|
|
261
|
+
modified = true;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// 5. Update buildConfig import
|
|
244
265
|
if (detection.needsImportChange) {
|
|
245
266
|
if (payloadImport) {
|
|
246
267
|
if (detection.hasOtherPayloadImports) {
|
|
@@ -258,19 +279,38 @@ import * as log from './log.js';
|
|
|
258
279
|
sourceFile.addImportDeclaration({
|
|
259
280
|
moduleSpecifier: '@payloadcms/figma',
|
|
260
281
|
namedImports: [
|
|
261
|
-
'
|
|
282
|
+
'buildFigmaConfig'
|
|
262
283
|
]
|
|
263
284
|
});
|
|
285
|
+
// Rename all usages of 'buildConfig' to 'buildFigmaConfig'
|
|
286
|
+
const identifiers = sourceFile.getDescendantsOfKind(SyntaxKind.Identifier);
|
|
287
|
+
identifiers.forEach((identifier)=>{
|
|
288
|
+
if (identifier.getText() === 'buildConfig') {
|
|
289
|
+
identifier.replaceWithText('buildFigmaConfig');
|
|
290
|
+
}
|
|
291
|
+
});
|
|
264
292
|
changes.push('Split buildConfig import to @payloadcms/figma');
|
|
265
293
|
} else {
|
|
266
|
-
// Replace entire import
|
|
294
|
+
// Replace entire import: change module specifier and rename all references
|
|
295
|
+
const buildConfigImport = payloadImport.getNamedImports().find((ni)=>ni.getName() === 'buildConfig');
|
|
296
|
+
if (buildConfigImport) {
|
|
297
|
+
// Change the import name
|
|
298
|
+
buildConfigImport.setName('buildFigmaConfig');
|
|
299
|
+
// Find and rename all usages of 'buildConfig' in the file
|
|
300
|
+
const identifiers = sourceFile.getDescendantsOfKind(SyntaxKind.Identifier);
|
|
301
|
+
identifiers.forEach((identifier)=>{
|
|
302
|
+
if (identifier.getText() === 'buildConfig') {
|
|
303
|
+
identifier.replaceWithText('buildFigmaConfig');
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
267
307
|
payloadImport.setModuleSpecifier('@payloadcms/figma');
|
|
268
308
|
changes.push('Changed buildConfig import to @payloadcms/figma');
|
|
269
309
|
}
|
|
270
310
|
modified = true;
|
|
271
311
|
}
|
|
272
312
|
}
|
|
273
|
-
//
|
|
313
|
+
// 6. Remove orphaned imports
|
|
274
314
|
// Re-fetch imports after each removal to avoid stale references
|
|
275
315
|
if (detection.dbProperty) {
|
|
276
316
|
const currentImports = sourceFile.getImportDeclarations();
|
|
@@ -290,6 +330,15 @@ import * as log from './log.js';
|
|
|
290
330
|
modified = true;
|
|
291
331
|
}
|
|
292
332
|
}
|
|
333
|
+
if (detection.sharpProperty) {
|
|
334
|
+
const currentImports = sourceFile.getImportDeclarations();
|
|
335
|
+
const sharpImport = currentImports.find((imp)=>imp.getModuleSpecifierValue() === 'sharp');
|
|
336
|
+
if (sharpImport) {
|
|
337
|
+
sharpImport.remove();
|
|
338
|
+
changes.push('Removed sharp import');
|
|
339
|
+
modified = true;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
293
342
|
return {
|
|
294
343
|
changes,
|
|
295
344
|
modified
|
|
@@ -301,15 +350,15 @@ import * as log from './log.js';
|
|
|
301
350
|
*/ export function addFigmaProperty(sourceFile, config) {
|
|
302
351
|
const changes = [];
|
|
303
352
|
let modified = false;
|
|
304
|
-
// Find
|
|
353
|
+
// Find buildFigmaConfig call (this function is only used with Figma configs)
|
|
305
354
|
const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
|
|
306
355
|
const buildConfigCall = callExpressions.find((ce)=>{
|
|
307
356
|
const expr = ce.getExpression();
|
|
308
357
|
const text = expr.getText();
|
|
309
|
-
return text === '
|
|
358
|
+
return text === 'buildFigmaConfig' || text.endsWith('.buildFigmaConfig');
|
|
310
359
|
});
|
|
311
360
|
if (!buildConfigCall) {
|
|
312
|
-
log.debug('No
|
|
361
|
+
log.debug('No buildFigmaConfig call found');
|
|
313
362
|
return {
|
|
314
363
|
changes: [],
|
|
315
364
|
modified: false
|
|
@@ -336,15 +385,19 @@ import * as log from './log.js';
|
|
|
336
385
|
};
|
|
337
386
|
}
|
|
338
387
|
// Add figma property
|
|
388
|
+
// Note: useContentSystem is optional and defaults to true, so we don't generate it during init
|
|
389
|
+
// contentSystemId is stored in .env file and referenced via process.env with non-null assertion
|
|
390
|
+
const figmaObj = config.useContentSystem === false ? `{
|
|
391
|
+
contentSystemId: process.env.FIGMA_CONTENT_API_CONTENT_SYSTEM_ID!,
|
|
392
|
+
useContentSystem: false,
|
|
393
|
+
}` : `{
|
|
394
|
+
contentSystemId: process.env.FIGMA_CONTENT_API_CONTENT_SYSTEM_ID!,
|
|
395
|
+
}`;
|
|
339
396
|
configArg.addPropertyAssignment({
|
|
340
397
|
name: 'figma',
|
|
341
|
-
initializer:
|
|
342
|
-
region: '${config.region}',
|
|
343
|
-
tenantId: '${config.tenantId}',
|
|
344
|
-
useContentSystem: ${config.useContentSystem},
|
|
345
|
-
}`
|
|
398
|
+
initializer: figmaObj
|
|
346
399
|
});
|
|
347
|
-
changes.push(`Added figma property (
|
|
400
|
+
changes.push(`Added figma property (contentSystemId: ${config.contentSystemId})`);
|
|
348
401
|
modified = true;
|
|
349
402
|
return {
|
|
350
403
|
changes,
|
|
@@ -355,15 +408,15 @@ import * as log from './log.js';
|
|
|
355
408
|
* Read figma configuration from payload.config.ts
|
|
356
409
|
* Returns the figma object if it exists, null otherwise
|
|
357
410
|
*/ export function readFigmaConfig(sourceFile) {
|
|
358
|
-
// Find
|
|
411
|
+
// Find buildFigmaConfig call (this function is only used with Figma configs)
|
|
359
412
|
const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
|
|
360
413
|
const buildConfigCall = callExpressions.find((ce)=>{
|
|
361
414
|
const expr = ce.getExpression();
|
|
362
415
|
const text = expr.getText();
|
|
363
|
-
return text === '
|
|
416
|
+
return text === 'buildFigmaConfig' || text.endsWith('.buildFigmaConfig');
|
|
364
417
|
});
|
|
365
418
|
if (!buildConfigCall) {
|
|
366
|
-
log.debug('No
|
|
419
|
+
log.debug('No buildFigmaConfig call found');
|
|
367
420
|
return null;
|
|
368
421
|
}
|
|
369
422
|
// Get config object argument
|
|
@@ -385,25 +438,37 @@ import * as log from './log.js';
|
|
|
385
438
|
return null;
|
|
386
439
|
}
|
|
387
440
|
// Extract values
|
|
388
|
-
const
|
|
389
|
-
const tenantIdProp = initializer.getProperty('tenantId');
|
|
441
|
+
const contentSystemIdProp = initializer.getProperty('contentSystemId');
|
|
390
442
|
const useContentSystemProp = initializer.getProperty('useContentSystem');
|
|
391
|
-
if (!
|
|
392
|
-
log.debug('Missing required figma
|
|
443
|
+
if (!contentSystemIdProp) {
|
|
444
|
+
log.debug('Missing required figma property: contentSystemId');
|
|
393
445
|
return null;
|
|
394
446
|
}
|
|
395
|
-
// Extract
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
447
|
+
// Extract contentSystemId - support both literal strings and env var references
|
|
448
|
+
let contentSystemId;
|
|
449
|
+
if (Node.isPropertyAssignment(contentSystemIdProp)) {
|
|
450
|
+
const initializer = contentSystemIdProp.getInitializer();
|
|
451
|
+
const text = initializer?.getText() || '';
|
|
452
|
+
// Support both patterns:
|
|
453
|
+
// 1. Literal string: 'cms_abc123' or "cms_abc123"
|
|
454
|
+
// 2. Environment variable: process.env.FIGMA_CONTENT_API_CONTENT_SYSTEM_ID
|
|
455
|
+
if (text.includes('process.env.FIGMA_CONTENT_API_CONTENT_SYSTEM_ID')) {
|
|
456
|
+
// For env var reference, return a marker that indicates it's from env
|
|
457
|
+
// The actual value will be read at runtime
|
|
458
|
+
contentSystemId = 'process.env.FIGMA_CONTENT_API_CONTENT_SYSTEM_ID';
|
|
459
|
+
} else {
|
|
460
|
+
// Remove quotes for literal strings
|
|
461
|
+
contentSystemId = text.replace(/['"]/g, '');
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
const useContentSystem = Node.isPropertyAssignment(useContentSystemProp) ? useContentSystemProp.getInitializer()?.getText() === 'true' : undefined // Optional: undefined if not specified
|
|
399
465
|
;
|
|
400
|
-
if (!
|
|
401
|
-
log.debug('Could not extract
|
|
466
|
+
if (!contentSystemId) {
|
|
467
|
+
log.debug('Could not extract contentSystemId value');
|
|
402
468
|
return null;
|
|
403
469
|
}
|
|
404
470
|
return {
|
|
405
|
-
|
|
406
|
-
tenantId,
|
|
471
|
+
contentSystemId,
|
|
407
472
|
useContentSystem
|
|
408
473
|
};
|
|
409
474
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Find the Payload config file using Payload's built-in finder
|
|
3
|
-
*
|
|
2
|
+
* Find the Payload config file using Payload's built-in finder when available,
|
|
3
|
+
* with fallback to simple file search for npx environments where payload isn't installed.
|
|
4
4
|
*
|
|
5
5
|
* @param projectPath - Absolute path to project directory
|
|
6
6
|
* @returns Absolute path to config file, or null if not found
|
|
@@ -1,26 +1,65 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import * as log from './log.js';
|
|
4
|
+
// Standard Payload config file names in priority order
|
|
5
|
+
const CONFIG_FILES = [
|
|
6
|
+
'payload.config.ts',
|
|
7
|
+
'payload.config.js',
|
|
8
|
+
'src/payload.config.ts',
|
|
9
|
+
'src/payload.config.js'
|
|
10
|
+
];
|
|
2
11
|
/**
|
|
3
|
-
* Find the Payload config file using Payload's built-in finder
|
|
4
|
-
*
|
|
12
|
+
* Find the Payload config file using Payload's built-in finder when available,
|
|
13
|
+
* with fallback to simple file search for npx environments where payload isn't installed.
|
|
5
14
|
*
|
|
6
15
|
* @param projectPath - Absolute path to project directory
|
|
7
16
|
* @returns Absolute path to config file, or null if not found
|
|
8
17
|
*/ export async function findPayloadConfig(projectPath) {
|
|
18
|
+
// First, try using Payload's official config finder (if payload is installed)
|
|
19
|
+
const configFromPayload = await findConfigWithPayload(projectPath);
|
|
20
|
+
if (configFromPayload) {
|
|
21
|
+
return configFromPayload;
|
|
22
|
+
}
|
|
23
|
+
// Fallback: Simple file search for standard config locations
|
|
24
|
+
// This works when running via npx before payload is installed
|
|
25
|
+
log.debug('Payload not available, using fallback config finder');
|
|
26
|
+
return findConfigFallback(projectPath);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Try to find config using Payload's findConfig function.
|
|
30
|
+
* Returns null if payload is not installed (dynamic import fails).
|
|
31
|
+
*/ async function findConfigWithPayload(projectPath) {
|
|
9
32
|
const originalCwd = process.cwd();
|
|
10
33
|
try {
|
|
34
|
+
// Dynamic import - will fail gracefully if payload is not installed
|
|
35
|
+
const { findConfig } = await import('payload/node');
|
|
11
36
|
// findConfig requires being in the project directory
|
|
12
37
|
process.chdir(projectPath);
|
|
13
|
-
// Use Payload's official config finder
|
|
14
38
|
const configPath = findConfig();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
39
|
+
return configPath || null;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
// payload not installed or other error - return null to use fallback
|
|
42
|
+
log.debug(`Could not use Payload findConfig: ${error instanceof Error ? error.message : 'unknown'}`);
|
|
19
43
|
return null;
|
|
20
44
|
} finally{
|
|
21
|
-
// Always restore original working directory
|
|
22
45
|
process.chdir(originalCwd);
|
|
23
46
|
}
|
|
24
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Fallback config finder that checks standard locations.
|
|
50
|
+
* Used when payload is not installed (e.g., running via npx).
|
|
51
|
+
*/ async function findConfigFallback(projectPath) {
|
|
52
|
+
for (const configFile of CONFIG_FILES){
|
|
53
|
+
const fullPath = path.join(projectPath, configFile);
|
|
54
|
+
try {
|
|
55
|
+
await fs.access(fullPath);
|
|
56
|
+
log.debug(`Found config at: ${fullPath}`);
|
|
57
|
+
return fullPath;
|
|
58
|
+
} catch {
|
|
59
|
+
// File doesn't exist, try next
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
25
64
|
|
|
26
65
|
//# sourceMappingURL=payload-config-finder.js.map
|
|
@@ -15,5 +15,5 @@ export declare function ensurePayloadFigmaConfig(projectPath: string, packageMan
|
|
|
15
15
|
/**
|
|
16
16
|
* Display manual configuration instructions
|
|
17
17
|
*/
|
|
18
|
-
export declare function displayManualInstructions(reason: string): void;
|
|
18
|
+
export declare function displayManualInstructions(reason: string, packageManager?: PackageManager): void;
|
|
19
19
|
//# sourceMappingURL=payload-config-modifier.d.ts.map
|
|
@@ -2,9 +2,10 @@ import pc from 'picocolors';
|
|
|
2
2
|
import { Project } from 'ts-morph';
|
|
3
3
|
import { formatFile } from './formatter.js';
|
|
4
4
|
import * as log from './log.js';
|
|
5
|
+
import { getAddCommand, getRunCommand } from './package-manager.js';
|
|
5
6
|
import { addFigmaProperty, applyModifications, detectRequiredChanges } from './payload-config-ast.js';
|
|
6
7
|
import { findPayloadConfig } from './payload-config-finder.js';
|
|
7
|
-
import { checkPackageInstalled, installPackage, uninstallPackage } from './payload-package-check.js';
|
|
8
|
+
import { checkPackageInstalled, getPayloadVersion, installPackage, uninstallPackage } from './payload-package-check.js';
|
|
8
9
|
import { runTypeScriptCheck } from './typescript-validator.js';
|
|
9
10
|
/**
|
|
10
11
|
* Main orchestrator for payload config modification
|
|
@@ -27,6 +28,9 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
log.debug(`Found config file: ${configPath}`);
|
|
31
|
+
// Get payload version to pin @payloadcms/* dependencies
|
|
32
|
+
const payloadVersion = await getPayloadVersion(projectPath);
|
|
33
|
+
log.debug(`Detected payload version: ${payloadVersion || 'unknown'}`);
|
|
30
34
|
// 2. Check/install @payloadcms/figma package
|
|
31
35
|
const isInstalled = await checkPackageInstalled(projectPath, '@payloadcms/figma');
|
|
32
36
|
if (!isInstalled) {
|
|
@@ -103,13 +107,58 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
103
107
|
if (modified) {
|
|
104
108
|
await sourceFile.save();
|
|
105
109
|
log.debug('Config file saved');
|
|
106
|
-
// 7.
|
|
110
|
+
// 7. Handle package management
|
|
107
111
|
const packagesToUninstall = [];
|
|
112
|
+
// Uninstall db adapter (buildFigmaConfig provides its own)
|
|
108
113
|
if (detection.dbProperty) {
|
|
109
114
|
packagesToUninstall.push(detection.dbProperty.importSource);
|
|
110
115
|
}
|
|
111
|
-
|
|
112
|
-
|
|
116
|
+
// Uninstall sharp (Figma infrastructure handles image processing)
|
|
117
|
+
if (detection.sharpProperty) {
|
|
118
|
+
packagesToUninstall.push('sharp');
|
|
119
|
+
}
|
|
120
|
+
// Ensure lexical is installed if user doesn't have a custom editor
|
|
121
|
+
// (buildFigmaConfig uses lexicalEditor() as default)
|
|
122
|
+
if (!detection.editorProperty) {
|
|
123
|
+
log.debug('No editor property detected - will ensure lexical is installed for default editor');
|
|
124
|
+
} else if (detection.editorProperty.isDefault) {
|
|
125
|
+
log.debug('Default lexicalEditor() detected - will ensure lexical is installed');
|
|
126
|
+
} else {
|
|
127
|
+
log.debug(`Custom editor detected (${detection.editorProperty.importSource}) - skipping lexical installation`);
|
|
128
|
+
}
|
|
129
|
+
if (!detection.editorProperty || detection.editorProperty.isDefault) {
|
|
130
|
+
log.debug('Checking if @payloadcms/richtext-lexical is installed...');
|
|
131
|
+
const hasLexical = await checkPackageInstalled(projectPath, '@payloadcms/richtext-lexical');
|
|
132
|
+
if (!hasLexical) {
|
|
133
|
+
log.debug('@payloadcms/richtext-lexical not found, installing...');
|
|
134
|
+
try {
|
|
135
|
+
await installPackage(projectPath, '@payloadcms/richtext-lexical', packageManager, payloadVersion);
|
|
136
|
+
changes.push('Installed @payloadcms/richtext-lexical (default editor)');
|
|
137
|
+
log.debug('Successfully installed @payloadcms/richtext-lexical');
|
|
138
|
+
} catch (error) {
|
|
139
|
+
log.debug(`Failed to install @payloadcms/richtext-lexical: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
140
|
+
// Don't fail on install error - user can install manually if needed
|
|
141
|
+
warnings.push('Could not install @payloadcms/richtext-lexical - you may need to install it manually');
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
log.debug('@payloadcms/richtext-lexical already installed, skipping');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Ensure cloud-storage is installed (required peer dependency for buildFigmaConfig)
|
|
148
|
+
log.debug('Checking if @payloadcms/plugin-cloud-storage is installed...');
|
|
149
|
+
const hasCloudStorage = await checkPackageInstalled(projectPath, '@payloadcms/plugin-cloud-storage');
|
|
150
|
+
if (!hasCloudStorage) {
|
|
151
|
+
log.debug('@payloadcms/plugin-cloud-storage not found, installing...');
|
|
152
|
+
try {
|
|
153
|
+
await installPackage(projectPath, '@payloadcms/plugin-cloud-storage', packageManager, payloadVersion);
|
|
154
|
+
changes.push('Installed @payloadcms/plugin-cloud-storage');
|
|
155
|
+
log.debug('Successfully installed @payloadcms/plugin-cloud-storage');
|
|
156
|
+
} catch (error) {
|
|
157
|
+
log.debug(`Failed to install @payloadcms/plugin-cloud-storage: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
158
|
+
warnings.push('Could not install @payloadcms/plugin-cloud-storage - you may need to install it manually');
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
log.debug('@payloadcms/plugin-cloud-storage already installed, skipping');
|
|
113
162
|
}
|
|
114
163
|
if (packagesToUninstall.length > 0) {
|
|
115
164
|
log.debug(`Uninstalling ${packagesToUninstall.length} orphaned packages...`);
|
|
@@ -135,7 +184,7 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
135
184
|
log.debug('Running TypeScript validation...');
|
|
136
185
|
const tsResult = await runTypeScriptCheck(projectPath, packageManager);
|
|
137
186
|
if (!tsResult.success && tsResult.errors.length > 0) {
|
|
138
|
-
warnings.push(
|
|
187
|
+
warnings.push(`TypeScript validation found issues - run '${getRunCommand(packageManager)} build' for details`);
|
|
139
188
|
log.debug(`TypeScript validation found ${tsResult.errors.length} issues`);
|
|
140
189
|
}
|
|
141
190
|
} else {
|
|
@@ -163,10 +212,10 @@ import { runTypeScriptCheck } from './typescript-validator.js';
|
|
|
163
212
|
}
|
|
164
213
|
/**
|
|
165
214
|
* Display manual configuration instructions
|
|
166
|
-
*/ export function displayManualInstructions(reason) {
|
|
215
|
+
*/ export function displayManualInstructions(reason, packageManager = 'npm') {
|
|
167
216
|
const leftLineWrap = (message)=>{
|
|
168
217
|
// Add '┌ ' prefix to first line, '│ ' to subsequent lines, and '└ ' to last line
|
|
169
|
-
return message.split(
|
|
218
|
+
return message.split(/\r?\n/).map((line, index, arr)=>{
|
|
170
219
|
if (index === 0) {
|
|
171
220
|
return `${pc.dim('┌ ')}${line}`;
|
|
172
221
|
} else if (index === arr.length - 1) {
|
|
@@ -185,7 +234,7 @@ ${pc.bold('Required changes:')}
|
|
|
185
234
|
|
|
186
235
|
1. Replace buildConfig import:
|
|
187
236
|
${pc.dim('- FROM: ')}${pc.cyan("import { buildConfig } from 'payload'")}
|
|
188
|
-
${pc.dim('- TO: ')}${pc.cyan("import {
|
|
237
|
+
${pc.dim('- TO: ')}${pc.cyan("import { buildFigmaConfig } from '@payloadcms/figma'")}
|
|
189
238
|
|
|
190
239
|
2. Remove these properties from buildConfig():
|
|
191
240
|
• db
|
|
@@ -193,7 +242,7 @@ ${pc.bold('Required changes:')}
|
|
|
193
242
|
• editor (if using default lexicalEditor())
|
|
194
243
|
|
|
195
244
|
3. Install package:
|
|
196
|
-
${pc.cyan(
|
|
245
|
+
${pc.cyan(`${getAddCommand(packageManager)} @payloadcms/figma`)}
|
|
197
246
|
|
|
198
247
|
Then run: ${pc.cyan('npx @payloadcms/figma init')}`);
|
|
199
248
|
// eslint-disable-next-line no-console
|
|
@@ -3,13 +3,24 @@ import type { PackageManager } from './package-manager.js';
|
|
|
3
3
|
* Check if a package is installed in dependencies (not devDependencies)
|
|
4
4
|
*/
|
|
5
5
|
export declare function checkPackageInstalled(projectPath: string, packageName: string): Promise<boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* Get the payload version from project's package.json (without range specifiers)
|
|
8
|
+
* Returns the clean version number (e.g., "3.71.1") or undefined if not found
|
|
9
|
+
*/
|
|
10
|
+
export declare function getPayloadVersion(projectPath: string): Promise<string | undefined>;
|
|
6
11
|
/**
|
|
7
12
|
* Install a package as a production dependency
|
|
13
|
+
* @param version - Version to install (without caret). Defaults to 'latest'.
|
|
8
14
|
*/
|
|
9
|
-
export declare function installPackage(projectPath: string, packageName: string, packageManager: PackageManager): Promise<void>;
|
|
15
|
+
export declare function installPackage(projectPath: string, packageName: string, packageManager: PackageManager, version?: string): Promise<void>;
|
|
10
16
|
/**
|
|
11
17
|
* Uninstall a package
|
|
12
18
|
* Does not throw on failure - orphaned package is better than broken config
|
|
13
19
|
*/
|
|
14
20
|
export declare function uninstallPackage(projectPath: string, packageName: string, packageManager: PackageManager): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Run an npm script from package.json
|
|
23
|
+
* Does not throw on failure - logs warning and continues
|
|
24
|
+
*/
|
|
25
|
+
export declare function runScript(projectPath: string, scriptName: string, packageManager: PackageManager): Promise<boolean>;
|
|
15
26
|
//# sourceMappingURL=payload-package-check.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import spawn from 'cross-spawn';
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import * as log from './log.js';
|
|
@@ -18,14 +18,34 @@ import * as log from './log.js';
|
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the payload version from project's package.json (without range specifiers)
|
|
23
|
+
* Returns the clean version number (e.g., "3.71.1") or undefined if not found
|
|
24
|
+
*/ export async function getPayloadVersion(projectPath) {
|
|
25
|
+
try {
|
|
26
|
+
const pkgJsonPath = path.join(projectPath, 'package.json');
|
|
27
|
+
const pkgJsonContent = await fs.readFile(pkgJsonPath, 'utf-8');
|
|
28
|
+
const pkgJson = JSON.parse(pkgJsonContent);
|
|
29
|
+
const rawVersion = pkgJson.dependencies?.payload || pkgJson.devDependencies?.payload;
|
|
30
|
+
if (!rawVersion) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
// Strip range specifiers (^, ~, >=, etc.) to get clean version
|
|
34
|
+
return rawVersion.replace(/^[\^~>=<]+/, '');
|
|
35
|
+
} catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
21
39
|
/**
|
|
22
40
|
* Install a package as a production dependency
|
|
23
|
-
|
|
41
|
+
* @param version - Version to install (without caret). Defaults to 'latest'.
|
|
42
|
+
*/ export async function installPackage(projectPath, packageName, packageManager, version = 'latest') {
|
|
24
43
|
return new Promise((resolve, reject)=>{
|
|
25
44
|
const command = packageManager;
|
|
45
|
+
const packageSpec = `${packageName}@${version}`;
|
|
26
46
|
const args = [
|
|
27
47
|
'add',
|
|
28
|
-
|
|
48
|
+
packageSpec
|
|
29
49
|
];
|
|
30
50
|
// npm uses 'install' instead of 'add'
|
|
31
51
|
if (packageManager === 'npm') {
|
|
@@ -35,7 +55,6 @@ import * as log from './log.js';
|
|
|
35
55
|
let stderr = '';
|
|
36
56
|
const child = spawn(command, args, {
|
|
37
57
|
cwd: projectPath,
|
|
38
|
-
shell: true,
|
|
39
58
|
stdio: 'pipe'
|
|
40
59
|
});
|
|
41
60
|
// Capture stderr for debug logging
|
|
@@ -79,7 +98,6 @@ import * as log from './log.js';
|
|
|
79
98
|
log.debug(`Running: ${command} ${args.join(' ')} in ${projectPath}`);
|
|
80
99
|
const child = spawn(command, args, {
|
|
81
100
|
cwd: projectPath,
|
|
82
|
-
shell: true,
|
|
83
101
|
stdio: 'pipe'
|
|
84
102
|
});
|
|
85
103
|
child.on('close', (code)=>{
|
|
@@ -93,5 +111,45 @@ import * as log from './log.js';
|
|
|
93
111
|
});
|
|
94
112
|
});
|
|
95
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Run an npm script from package.json
|
|
116
|
+
* Does not throw on failure - logs warning and continues
|
|
117
|
+
*/ export async function runScript(projectPath, scriptName, packageManager) {
|
|
118
|
+
return new Promise((resolve)=>{
|
|
119
|
+
const command = packageManager;
|
|
120
|
+
// yarn doesn't need 'run' prefix, but it works with it too
|
|
121
|
+
const args = [
|
|
122
|
+
'run',
|
|
123
|
+
scriptName
|
|
124
|
+
];
|
|
125
|
+
log.debug(`Running script: ${command} ${args.join(' ')} in ${projectPath}`);
|
|
126
|
+
let stderr = '';
|
|
127
|
+
const child = spawn(command, args, {
|
|
128
|
+
cwd: projectPath,
|
|
129
|
+
stdio: 'pipe'
|
|
130
|
+
});
|
|
131
|
+
if (child.stderr) {
|
|
132
|
+
child.stderr.on('data', (data)=>{
|
|
133
|
+
stderr += data.toString();
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
child.on('error', (error)=>{
|
|
137
|
+
log.debug(`Failed to run script ${scriptName}: ${error.message}`);
|
|
138
|
+
resolve(false);
|
|
139
|
+
});
|
|
140
|
+
child.on('close', (code)=>{
|
|
141
|
+
if (code === 0) {
|
|
142
|
+
log.debug(`Successfully ran script: ${scriptName}`);
|
|
143
|
+
resolve(true);
|
|
144
|
+
} else {
|
|
145
|
+
log.debug(`Script ${scriptName} failed (exit code: ${code})`);
|
|
146
|
+
if (stderr) {
|
|
147
|
+
log.debug(`stderr: ${stderr}`);
|
|
148
|
+
}
|
|
149
|
+
resolve(false);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
96
154
|
|
|
97
155
|
//# sourceMappingURL=payload-package-check.js.map
|
package/dist/utils/project.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Project detection and scaffolding utilities
|
|
3
3
|
*/
|
|
4
4
|
import type { ProjectInfo } from '../types/config.js';
|
|
5
|
+
import type { PackageManager } from './package-manager.js';
|
|
5
6
|
/**
|
|
6
7
|
* Detect if current directory has a Payload project
|
|
7
8
|
*
|
|
@@ -22,7 +23,7 @@ export declare function validatePayloadVersion(version: string): boolean;
|
|
|
22
23
|
* @param projectPath - Path where to create the project
|
|
23
24
|
* @param projectName - Name for the project
|
|
24
25
|
*/
|
|
25
|
-
export declare function scaffoldProject(projectPath: string, projectName: string): Promise<void>;
|
|
26
|
+
export declare function scaffoldProject(projectPath: string, projectName: string, packageManager?: PackageManager): Promise<void>;
|
|
26
27
|
/**
|
|
27
28
|
* Initialize git repository after all setup is complete
|
|
28
29
|
*
|
|
@@ -38,7 +39,7 @@ export declare function initializeGitRepo(projectPath: string): void;
|
|
|
38
39
|
* @param packageManager - Package manager to use
|
|
39
40
|
* @returns Promise that resolves when installation completes
|
|
40
41
|
*/
|
|
41
|
-
export declare function installDependencies(projectPath: string, packageManager?:
|
|
42
|
+
export declare function installDependencies(projectPath: string, packageManager?: PackageManager): Promise<void>;
|
|
42
43
|
/**
|
|
43
44
|
* Check if required dependencies are installed
|
|
44
45
|
*
|