@payloadcms/figma 0.0.1-alpha.0
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 +11 -0
- package/bin/cli.js +4 -0
- package/dist/api/control-plane.d.ts +124 -0
- package/dist/api/control-plane.d.ts.map +1 -0
- package/dist/api/control-plane.js +245 -0
- package/dist/api/control-plane.js.map +1 -0
- package/dist/api/control-plane.spec.d.ts +2 -0
- package/dist/api/control-plane.spec.d.ts.map +1 -0
- package/dist/api/control-plane.spec.js +296 -0
- package/dist/api/control-plane.spec.js.map +1 -0
- package/dist/api/figma-api.d.ts +31 -0
- package/dist/api/figma-api.d.ts.map +1 -0
- package/dist/api/figma-api.js +169 -0
- package/dist/api/figma-api.js.map +1 -0
- package/dist/api/figma-api.spec.d.ts +14 -0
- package/dist/api/figma-api.spec.d.ts.map +1 -0
- package/dist/api/figma-api.spec.js +201 -0
- package/dist/api/figma-api.spec.js.map +1 -0
- package/dist/auth/__tests__/fixtures.d.ts +26 -0
- package/dist/auth/__tests__/fixtures.d.ts.map +1 -0
- package/dist/auth/__tests__/fixtures.js +67 -0
- package/dist/auth/__tests__/fixtures.js.map +1 -0
- package/dist/auth/__tests__/mocks.d.ts +33 -0
- package/dist/auth/__tests__/mocks.d.ts.map +1 -0
- package/dist/auth/__tests__/mocks.js +63 -0
- package/dist/auth/__tests__/mocks.js.map +1 -0
- package/dist/auth/browser.d.ts +31 -0
- package/dist/auth/browser.d.ts.map +1 -0
- package/dist/auth/browser.js +41 -0
- package/dist/auth/browser.js.map +1 -0
- package/dist/auth/callback-server.d.ts +61 -0
- package/dist/auth/callback-server.d.ts.map +1 -0
- package/dist/auth/callback-server.js +168 -0
- package/dist/auth/callback-server.js.map +1 -0
- package/dist/auth/callback-server.spec.d.ts +2 -0
- package/dist/auth/callback-server.spec.d.ts.map +1 -0
- package/dist/auth/callback-server.spec.js +85 -0
- package/dist/auth/callback-server.spec.js.map +1 -0
- package/dist/auth/crypto-utils.d.ts +33 -0
- package/dist/auth/crypto-utils.d.ts.map +1 -0
- package/dist/auth/crypto-utils.js +96 -0
- package/dist/auth/crypto-utils.js.map +1 -0
- package/dist/auth/crypto-utils.spec.d.ts +2 -0
- package/dist/auth/crypto-utils.spec.d.ts.map +1 -0
- package/dist/auth/crypto-utils.spec.js +36 -0
- package/dist/auth/crypto-utils.spec.js.map +1 -0
- package/dist/auth/jwt-validator.d.ts +41 -0
- package/dist/auth/jwt-validator.d.ts.map +1 -0
- package/dist/auth/jwt-validator.js +113 -0
- package/dist/auth/jwt-validator.js.map +1 -0
- package/dist/auth/jwt-validator.spec.d.ts +10 -0
- package/dist/auth/jwt-validator.spec.d.ts.map +1 -0
- package/dist/auth/jwt-validator.spec.js +236 -0
- package/dist/auth/jwt-validator.spec.js.map +1 -0
- package/dist/auth/oauth-flow.d.ts +62 -0
- package/dist/auth/oauth-flow.d.ts.map +1 -0
- package/dist/auth/oauth-flow.js +172 -0
- package/dist/auth/oauth-flow.js.map +1 -0
- package/dist/auth/oauth-flow.spec.d.ts +2 -0
- package/dist/auth/oauth-flow.spec.d.ts.map +1 -0
- package/dist/auth/oauth-flow.spec.js +134 -0
- package/dist/auth/oauth-flow.spec.js.map +1 -0
- package/dist/auth/pages/error.html +85 -0
- package/dist/auth/pages/success.html +74 -0
- package/dist/auth/pkce.d.ts +51 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +71 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/pkce.spec.d.ts +2 -0
- package/dist/auth/pkce.spec.d.ts.map +1 -0
- package/dist/auth/pkce.spec.js +32 -0
- package/dist/auth/pkce.spec.js.map +1 -0
- package/dist/auth/project-token.d.ts +47 -0
- package/dist/auth/project-token.d.ts.map +1 -0
- package/dist/auth/project-token.js +134 -0
- package/dist/auth/project-token.js.map +1 -0
- package/dist/auth/project-token.spec.d.ts +2 -0
- package/dist/auth/project-token.spec.d.ts.map +1 -0
- package/dist/auth/project-token.spec.js +332 -0
- package/dist/auth/project-token.spec.js.map +1 -0
- package/dist/auth/refresh.d.ts +35 -0
- package/dist/auth/refresh.d.ts.map +1 -0
- package/dist/auth/refresh.js +149 -0
- package/dist/auth/refresh.js.map +1 -0
- package/dist/auth/refresh.spec.d.ts +2 -0
- package/dist/auth/refresh.spec.d.ts.map +1 -0
- package/dist/auth/refresh.spec.js +105 -0
- package/dist/auth/refresh.spec.js.map +1 -0
- package/dist/auth/token-store.d.ts +110 -0
- package/dist/auth/token-store.d.ts.map +1 -0
- package/dist/auth/token-store.js +188 -0
- package/dist/auth/token-store.js.map +1 -0
- package/dist/auth/token-store.spec.d.ts +2 -0
- package/dist/auth/token-store.spec.d.ts.map +1 -0
- package/dist/auth/token-store.spec.js +276 -0
- package/dist/auth/token-store.spec.js.map +1 -0
- package/dist/auth/types.d.ts +197 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +6 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +108 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/__tests__/test-utils.d.ts +28 -0
- package/dist/commands/__tests__/test-utils.d.ts.map +1 -0
- package/dist/commands/__tests__/test-utils.js +34 -0
- package/dist/commands/__tests__/test-utils.js.map +1 -0
- package/dist/commands/deploy.d.ts +16 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +297 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/deploy.spec.d.ts +2 -0
- package/dist/commands/deploy.spec.d.ts.map +1 -0
- package/dist/commands/deploy.spec.js +18 -0
- package/dist/commands/deploy.spec.js.map +1 -0
- package/dist/commands/init.d.ts +30 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +410 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/init.spec.d.ts +2 -0
- package/dist/commands/init.spec.d.ts.map +1 -0
- package/dist/commands/init.spec.js +283 -0
- package/dist/commands/init.spec.js.map +1 -0
- package/dist/commands/list-tokens.d.ts +16 -0
- package/dist/commands/list-tokens.d.ts.map +1 -0
- package/dist/commands/list-tokens.js +44 -0
- package/dist/commands/list-tokens.js.map +1 -0
- package/dist/commands/login.d.ts +17 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +69 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +16 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +43 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/config/oauth.d.ts +19 -0
- package/dist/config/oauth.d.ts.map +1 -0
- package/dist/config/oauth.js +43 -0
- package/dist/config/oauth.js.map +1 -0
- package/dist/constants.d.ts +27 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +27 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin/adapter.d.ts +5 -0
- package/dist/plugin/adapter.d.ts.map +1 -0
- package/dist/plugin/adapter.js +139 -0
- package/dist/plugin/adapter.js.map +1 -0
- package/dist/plugin/build-config.d.ts +37 -0
- package/dist/plugin/build-config.d.ts.map +1 -0
- package/dist/plugin/build-config.js +25 -0
- package/dist/plugin/build-config.js.map +1 -0
- package/dist/plugin/build-config.spec.d.ts +2 -0
- package/dist/plugin/build-config.spec.d.ts.map +1 -0
- package/dist/plugin/build-config.spec.js +72 -0
- package/dist/plugin/build-config.spec.js.map +1 -0
- package/dist/types/config.d.ts +45 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +9 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types.d.ts +60 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/asset-collection.d.ts +30 -0
- package/dist/utils/asset-collection.d.ts.map +1 -0
- package/dist/utils/asset-collection.js +117 -0
- package/dist/utils/asset-collection.js.map +1 -0
- package/dist/utils/asset-collection.spec.d.ts +2 -0
- package/dist/utils/asset-collection.spec.d.ts.map +1 -0
- package/dist/utils/asset-collection.spec.js +155 -0
- package/dist/utils/asset-collection.spec.js.map +1 -0
- package/dist/utils/build-detection.d.ts +32 -0
- package/dist/utils/build-detection.d.ts.map +1 -0
- package/dist/utils/build-detection.js +55 -0
- package/dist/utils/build-detection.js.map +1 -0
- package/dist/utils/build-detection.spec.d.ts +2 -0
- package/dist/utils/build-detection.spec.d.ts.map +1 -0
- package/dist/utils/build-detection.spec.js +110 -0
- package/dist/utils/build-detection.spec.js.map +1 -0
- package/dist/utils/config.d.ts +33 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +78 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/config.spec.d.ts +2 -0
- package/dist/utils/config.spec.d.ts.map +1 -0
- package/dist/utils/config.spec.js +167 -0
- package/dist/utils/config.spec.js.map +1 -0
- package/dist/utils/download-template.d.ts +15 -0
- package/dist/utils/download-template.d.ts.map +1 -0
- package/dist/utils/download-template.js +74 -0
- package/dist/utils/download-template.js.map +1 -0
- package/dist/utils/download-template.spec.d.ts +2 -0
- package/dist/utils/download-template.spec.d.ts.map +1 -0
- package/dist/utils/download-template.spec.js +76 -0
- package/dist/utils/download-template.spec.js.map +1 -0
- package/dist/utils/env-management.d.ts +16 -0
- package/dist/utils/env-management.d.ts.map +1 -0
- package/dist/utils/env-management.js +98 -0
- package/dist/utils/env-management.js.map +1 -0
- package/dist/utils/env-management.spec.d.ts +2 -0
- package/dist/utils/env-management.spec.d.ts.map +1 -0
- package/dist/utils/env-management.spec.js +123 -0
- package/dist/utils/env-management.spec.js.map +1 -0
- package/dist/utils/format.d.ts +23 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +49 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/formatter.d.ts +11 -0
- package/dist/utils/formatter.d.ts.map +1 -0
- package/dist/utils/formatter.js +47 -0
- package/dist/utils/formatter.js.map +1 -0
- package/dist/utils/git.d.ts +15 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +92 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/git.spec.d.ts +2 -0
- package/dist/utils/git.spec.d.ts.map +1 -0
- package/dist/utils/git.spec.js +99 -0
- package/dist/utils/git.spec.js.map +1 -0
- package/dist/utils/is-debug.d.ts +6 -0
- package/dist/utils/is-debug.d.ts.map +1 -0
- package/dist/utils/is-debug.js +8 -0
- package/dist/utils/is-debug.js.map +1 -0
- package/dist/utils/lambda-config.d.ts +7 -0
- package/dist/utils/lambda-config.d.ts.map +1 -0
- package/dist/utils/lambda-config.js +144 -0
- package/dist/utils/lambda-config.js.map +1 -0
- package/dist/utils/lambda-config.spec.d.ts +2 -0
- package/dist/utils/lambda-config.spec.d.ts.map +1 -0
- package/dist/utils/lambda-config.spec.js +141 -0
- package/dist/utils/lambda-config.spec.js.map +1 -0
- package/dist/utils/log.d.ts +6 -0
- package/dist/utils/log.d.ts.map +1 -0
- package/dist/utils/log.js +22 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/messages.d.ts +10 -0
- package/dist/utils/messages.d.ts.map +1 -0
- package/dist/utils/messages.js +96 -0
- package/dist/utils/messages.js.map +1 -0
- package/dist/utils/package-manager.d.ts +12 -0
- package/dist/utils/package-manager.d.ts.map +1 -0
- package/dist/utils/package-manager.js +37 -0
- package/dist/utils/package-manager.js.map +1 -0
- package/dist/utils/payload-config-ast.d.ts +30 -0
- package/dist/utils/payload-config-ast.d.ts.map +1 -0
- package/dist/utils/payload-config-ast.js +259 -0
- package/dist/utils/payload-config-ast.js.map +1 -0
- package/dist/utils/payload-config-ast.spec.d.ts +2 -0
- package/dist/utils/payload-config-ast.spec.d.ts.map +1 -0
- package/dist/utils/payload-config-ast.spec.js +303 -0
- package/dist/utils/payload-config-ast.spec.js.map +1 -0
- package/dist/utils/payload-config-finder.d.ts +9 -0
- package/dist/utils/payload-config-finder.d.ts.map +1 -0
- package/dist/utils/payload-config-finder.js +26 -0
- package/dist/utils/payload-config-finder.js.map +1 -0
- package/dist/utils/payload-config-modifier.d.ts +18 -0
- package/dist/utils/payload-config-modifier.d.ts.map +1 -0
- package/dist/utils/payload-config-modifier.int.spec.d.ts +2 -0
- package/dist/utils/payload-config-modifier.int.spec.d.ts.map +1 -0
- package/dist/utils/payload-config-modifier.int.spec.js +116 -0
- package/dist/utils/payload-config-modifier.int.spec.js.map +1 -0
- package/dist/utils/payload-config-modifier.js +232 -0
- package/dist/utils/payload-config-modifier.js.map +1 -0
- package/dist/utils/payload-config-modifier.spec.d.ts +2 -0
- package/dist/utils/payload-config-modifier.spec.d.ts.map +1 -0
- package/dist/utils/payload-config-modifier.spec.js +162 -0
- package/dist/utils/payload-config-modifier.spec.js.map +1 -0
- package/dist/utils/payload-package-check.d.ts +15 -0
- package/dist/utils/payload-package-check.d.ts.map +1 -0
- package/dist/utils/payload-package-check.js +116 -0
- package/dist/utils/payload-package-check.js.map +1 -0
- package/dist/utils/payload-package-check.spec.d.ts +2 -0
- package/dist/utils/payload-package-check.spec.d.ts.map +1 -0
- package/dist/utils/payload-package-check.spec.js +148 -0
- package/dist/utils/payload-package-check.spec.js.map +1 -0
- package/dist/utils/project.d.ts +58 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +252 -0
- package/dist/utils/project.js.map +1 -0
- package/dist/utils/project.spec.d.ts +2 -0
- package/dist/utils/project.spec.d.ts.map +1 -0
- package/dist/utils/project.spec.js +222 -0
- package/dist/utils/project.spec.js.map +1 -0
- package/dist/utils/s3-upload.d.ts +43 -0
- package/dist/utils/s3-upload.d.ts.map +1 -0
- package/dist/utils/s3-upload.js +128 -0
- package/dist/utils/s3-upload.js.map +1 -0
- package/dist/utils/s3-upload.spec.d.ts +2 -0
- package/dist/utils/s3-upload.spec.d.ts.map +1 -0
- package/dist/utils/s3-upload.spec.js +140 -0
- package/dist/utils/s3-upload.spec.js.map +1 -0
- package/dist/utils/token-display.d.ts +14 -0
- package/dist/utils/token-display.d.ts.map +1 -0
- package/dist/utils/token-display.js +62 -0
- package/dist/utils/token-display.js.map +1 -0
- package/dist/utils/typescript-validator.d.ts +11 -0
- package/dist/utils/typescript-validator.d.ts.map +1 -0
- package/dist/utils/typescript-validator.js +58 -0
- package/dist/utils/typescript-validator.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { Node, SyntaxKind } from 'ts-morph';
|
|
2
|
+
import { isDebug } from './is-debug.js';
|
|
3
|
+
import * as log from './log.js';
|
|
4
|
+
/**
|
|
5
|
+
* Detect what changes are needed in the payload config file
|
|
6
|
+
*/ export function detectRequiredChanges(sourceFile) {
|
|
7
|
+
const result = {
|
|
8
|
+
hasAlias: false,
|
|
9
|
+
hasOtherPayloadImports: false,
|
|
10
|
+
needsImportChange: false
|
|
11
|
+
};
|
|
12
|
+
// Find buildConfig import
|
|
13
|
+
const imports = sourceFile.getImportDeclarations();
|
|
14
|
+
const payloadImport = imports.find((imp)=>imp.getModuleSpecifierValue() === 'payload' || imp.getModuleSpecifierValue() === '@payloadcms/figma');
|
|
15
|
+
if (!payloadImport) {
|
|
16
|
+
if (isDebug()) {
|
|
17
|
+
log.debug('No payload or @payloadcms/figma import found');
|
|
18
|
+
}
|
|
19
|
+
result.buildConfigNotFound = true;
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
if (isDebug()) {
|
|
23
|
+
log.debug(`Found import from: ${payloadImport.getModuleSpecifierValue()}`);
|
|
24
|
+
}
|
|
25
|
+
const moduleSpecifier = payloadImport.getModuleSpecifierValue();
|
|
26
|
+
const namedImports = payloadImport.getNamedImports();
|
|
27
|
+
// Check if buildConfig is imported
|
|
28
|
+
const buildConfigImport = namedImports.find((ni)=>ni.getName() === 'buildConfig');
|
|
29
|
+
if (!buildConfigImport) {
|
|
30
|
+
result.buildConfigNotFound = true;
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
// Check for alias and get the actual name used in code
|
|
34
|
+
const aliasNode = buildConfigImport.getAliasNode();
|
|
35
|
+
const buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig';
|
|
36
|
+
if (aliasNode) {
|
|
37
|
+
result.hasAlias = true;
|
|
38
|
+
}
|
|
39
|
+
// Check if import needs change
|
|
40
|
+
if (moduleSpecifier === 'payload') {
|
|
41
|
+
result.needsImportChange = true;
|
|
42
|
+
// Check if there are other imports from payload
|
|
43
|
+
if (namedImports.length > 1) {
|
|
44
|
+
result.hasOtherPayloadImports = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Find buildConfig call in export default
|
|
48
|
+
// First try to find export default with the buildConfig call
|
|
49
|
+
const exportAssignment = sourceFile.getFirstDescendantByKind(SyntaxKind.ExportAssignment);
|
|
50
|
+
let buildConfigCall = null;
|
|
51
|
+
if (exportAssignment) {
|
|
52
|
+
// Look for buildConfig call in the export default
|
|
53
|
+
const callExpressions = exportAssignment.getDescendantsOfKind(SyntaxKind.CallExpression);
|
|
54
|
+
buildConfigCall = callExpressions.find((ce)=>{
|
|
55
|
+
const expr = ce.getExpression();
|
|
56
|
+
return expr.getText() === buildConfigName;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// If not found in export default, search all call expressions
|
|
60
|
+
if (!buildConfigCall) {
|
|
61
|
+
const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
|
|
62
|
+
buildConfigCall = callExpressions.find((ce)=>{
|
|
63
|
+
const expr = ce.getExpression();
|
|
64
|
+
return expr.getText() === buildConfigName;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (!buildConfigCall) {
|
|
68
|
+
result.buildConfigNotFound = true;
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
// Get config object
|
|
72
|
+
const configArg = buildConfigCall.getArguments()[0];
|
|
73
|
+
if (!configArg || !Node.isObjectLiteralExpression(configArg)) {
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
// Check for db property
|
|
77
|
+
const dbProperty = configArg.getProperty('db');
|
|
78
|
+
if (dbProperty) {
|
|
79
|
+
const dbValue = dbProperty.getChildrenOfKind(SyntaxKind.CallExpression)[0];
|
|
80
|
+
if (dbValue) {
|
|
81
|
+
const adapterName = dbValue.getExpression().getText();
|
|
82
|
+
// Find the import source for this adapter
|
|
83
|
+
const adapterImport = imports.find((imp)=>imp.getNamedImports().some((ni)=>ni.getName() === adapterName));
|
|
84
|
+
if (adapterImport) {
|
|
85
|
+
result.dbProperty = {
|
|
86
|
+
adapter: adapterName,
|
|
87
|
+
importSource: adapterImport.getModuleSpecifierValue()
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Check for secret property
|
|
93
|
+
const secretProperty = configArg.getProperty('secret');
|
|
94
|
+
if (secretProperty) {
|
|
95
|
+
result.secretProperty = true;
|
|
96
|
+
}
|
|
97
|
+
// Check for editor property
|
|
98
|
+
const editorProperty = configArg.getProperty('editor');
|
|
99
|
+
if (editorProperty) {
|
|
100
|
+
const editorValue = editorProperty.getChildrenOfKind(SyntaxKind.CallExpression)[0];
|
|
101
|
+
if (editorValue) {
|
|
102
|
+
const editorName = editorValue.getExpression().getText();
|
|
103
|
+
// Find the import source
|
|
104
|
+
const editorImport = imports.find((imp)=>imp.getNamedImports().some((ni)=>ni.getName() === editorName));
|
|
105
|
+
if (editorImport && editorName === 'lexicalEditor') {
|
|
106
|
+
// Check if it has arguments
|
|
107
|
+
const args = editorValue.getArguments();
|
|
108
|
+
const isDefault = args.length === 0;
|
|
109
|
+
result.editorProperty = {
|
|
110
|
+
importSource: editorImport.getModuleSpecifierValue(),
|
|
111
|
+
isDefault
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Apply modifications to the source file based on detection result
|
|
120
|
+
* Modifies the AST in memory - caller must call sourceFile.save()
|
|
121
|
+
*/ export function applyModifications(sourceFile, detection) {
|
|
122
|
+
const changes = [];
|
|
123
|
+
let modified = false;
|
|
124
|
+
if (detection.buildConfigNotFound || detection.hasAlias) {
|
|
125
|
+
if (isDebug()) {
|
|
126
|
+
log.debug(`Skipping modifications: buildConfigNotFound=${detection.buildConfigNotFound}, hasAlias=${detection.hasAlias}`);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
changes: [],
|
|
130
|
+
modified: false
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// Find the import declarations
|
|
134
|
+
const imports = sourceFile.getImportDeclarations();
|
|
135
|
+
const payloadImport = imports.find((imp)=>imp.getModuleSpecifierValue() === 'payload');
|
|
136
|
+
// Get the buildConfig name (could be aliased)
|
|
137
|
+
let buildConfigName = 'buildConfig';
|
|
138
|
+
if (payloadImport) {
|
|
139
|
+
const buildConfigImport = payloadImport.getNamedImports().find((ni)=>ni.getName() === 'buildConfig');
|
|
140
|
+
if (buildConfigImport) {
|
|
141
|
+
const aliasNode = buildConfigImport.getAliasNode();
|
|
142
|
+
buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig';
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Find buildConfig call in export default (prefer export default)
|
|
146
|
+
const exportAssignment = sourceFile.getFirstDescendantByKind(SyntaxKind.ExportAssignment);
|
|
147
|
+
let buildConfigCall = null;
|
|
148
|
+
if (exportAssignment) {
|
|
149
|
+
const callExpressions = exportAssignment.getDescendantsOfKind(SyntaxKind.CallExpression);
|
|
150
|
+
buildConfigCall = callExpressions.find((ce)=>{
|
|
151
|
+
const expr = ce.getExpression();
|
|
152
|
+
return expr.getText() === buildConfigName;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
// If not found in export default, search all call expressions
|
|
156
|
+
if (!buildConfigCall) {
|
|
157
|
+
const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression);
|
|
158
|
+
buildConfigCall = callExpressions.find((ce)=>{
|
|
159
|
+
const expr = ce.getExpression();
|
|
160
|
+
return expr.getText() === buildConfigName;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (!buildConfigCall) {
|
|
164
|
+
return {
|
|
165
|
+
changes: [],
|
|
166
|
+
modified: false
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
const configArg = buildConfigCall.getArguments()[0];
|
|
170
|
+
if (!configArg || !Node.isObjectLiteralExpression(configArg)) {
|
|
171
|
+
return {
|
|
172
|
+
changes: [],
|
|
173
|
+
modified: false
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
// 1. Remove db property
|
|
177
|
+
if (detection.dbProperty) {
|
|
178
|
+
const dbProperty = configArg.getProperty('db');
|
|
179
|
+
if (dbProperty) {
|
|
180
|
+
dbProperty.remove();
|
|
181
|
+
changes.push('Removed db property');
|
|
182
|
+
modified = true;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// 2. Remove secret property
|
|
186
|
+
if (detection.secretProperty) {
|
|
187
|
+
const secretProperty = configArg.getProperty('secret');
|
|
188
|
+
if (secretProperty) {
|
|
189
|
+
secretProperty.remove();
|
|
190
|
+
changes.push('Removed secret property');
|
|
191
|
+
modified = true;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// 3. Remove editor if default
|
|
195
|
+
if (detection.editorProperty?.isDefault) {
|
|
196
|
+
const editorProperty = configArg.getProperty('editor');
|
|
197
|
+
if (editorProperty) {
|
|
198
|
+
editorProperty.remove();
|
|
199
|
+
changes.push('Removed default editor property');
|
|
200
|
+
modified = true;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// 4. Update buildConfig import
|
|
204
|
+
if (detection.needsImportChange) {
|
|
205
|
+
if (payloadImport) {
|
|
206
|
+
if (detection.hasOtherPayloadImports) {
|
|
207
|
+
// Remove buildConfig from payload import, add new figma import
|
|
208
|
+
const namedImports = payloadImport.getNamedImports();
|
|
209
|
+
const buildConfigImport = namedImports.find((ni)=>ni.getName() === 'buildConfig');
|
|
210
|
+
if (buildConfigImport) {
|
|
211
|
+
buildConfigImport.remove();
|
|
212
|
+
// If payload import is now empty, remove it
|
|
213
|
+
if (payloadImport.getNamedImports().length === 0) {
|
|
214
|
+
payloadImport.remove();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// Add new import at the top
|
|
218
|
+
sourceFile.addImportDeclaration({
|
|
219
|
+
moduleSpecifier: '@payloadcms/figma',
|
|
220
|
+
namedImports: [
|
|
221
|
+
'buildConfig'
|
|
222
|
+
]
|
|
223
|
+
});
|
|
224
|
+
changes.push('Split buildConfig import to @payloadcms/figma');
|
|
225
|
+
} else {
|
|
226
|
+
// Replace entire import
|
|
227
|
+
payloadImport.setModuleSpecifier('@payloadcms/figma');
|
|
228
|
+
changes.push('Changed buildConfig import to @payloadcms/figma');
|
|
229
|
+
}
|
|
230
|
+
modified = true;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// 5. Remove orphaned imports
|
|
234
|
+
// Re-fetch imports after each removal to avoid stale references
|
|
235
|
+
if (detection.dbProperty) {
|
|
236
|
+
const currentImports = sourceFile.getImportDeclarations();
|
|
237
|
+
const dbImport = currentImports.find((imp)=>imp.getModuleSpecifierValue() === detection.dbProperty?.importSource);
|
|
238
|
+
if (dbImport) {
|
|
239
|
+
dbImport.remove();
|
|
240
|
+
changes.push(`Removed ${detection.dbProperty.adapter} import`);
|
|
241
|
+
modified = true;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (detection.editorProperty?.isDefault) {
|
|
245
|
+
const currentImports = sourceFile.getImportDeclarations();
|
|
246
|
+
const editorImport = currentImports.find((imp)=>imp.getModuleSpecifierValue() === detection.editorProperty?.importSource);
|
|
247
|
+
if (editorImport) {
|
|
248
|
+
editorImport.remove();
|
|
249
|
+
changes.push('Removed lexicalEditor import');
|
|
250
|
+
modified = true;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
changes,
|
|
255
|
+
modified
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
//# sourceMappingURL=payload-config-ast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/payload-config-ast.ts"],"sourcesContent":["import type { SourceFile } from 'ts-morph'\n\nimport { Node, SyntaxKind } from 'ts-morph'\n\nimport { isDebug } from './is-debug.js'\nimport * as log from './log.js'\n\nexport type DetectionResult = {\n buildConfigNotFound?: boolean\n dbProperty?: {\n adapter: string\n importSource: string\n }\n editorProperty?: {\n importSource: string\n isDefault: boolean\n }\n hasAlias: boolean\n hasOtherPayloadImports: boolean\n needsImportChange: boolean\n secretProperty?: boolean\n}\n\n/**\n * Detect what changes are needed in the payload config file\n */\nexport function detectRequiredChanges(sourceFile: SourceFile): DetectionResult {\n const result: DetectionResult = {\n hasAlias: false,\n hasOtherPayloadImports: false,\n needsImportChange: false,\n }\n\n // Find buildConfig import\n const imports = sourceFile.getImportDeclarations()\n const payloadImport = imports.find(\n (imp) =>\n imp.getModuleSpecifierValue() === 'payload' ||\n imp.getModuleSpecifierValue() === '@payloadcms/figma',\n )\n\n if (!payloadImport) {\n if (isDebug()) {\n log.debug('No payload or @payloadcms/figma import found')\n }\n result.buildConfigNotFound = true\n return result\n }\n\n if (isDebug()) {\n log.debug(`Found import from: ${payloadImport.getModuleSpecifierValue()}`)\n }\n\n const moduleSpecifier = payloadImport.getModuleSpecifierValue()\n const namedImports = payloadImport.getNamedImports()\n\n // Check if buildConfig is imported\n const buildConfigImport = namedImports.find((ni) => ni.getName() === 'buildConfig')\n\n if (!buildConfigImport) {\n result.buildConfigNotFound = true\n return result\n }\n\n // Check for alias and get the actual name used in code\n const aliasNode = buildConfigImport.getAliasNode()\n const buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig'\n if (aliasNode) {\n result.hasAlias = true\n }\n\n // Check if import needs change\n if (moduleSpecifier === 'payload') {\n result.needsImportChange = true\n\n // Check if there are other imports from payload\n if (namedImports.length > 1) {\n result.hasOtherPayloadImports = true\n }\n }\n\n // Find buildConfig call in export default\n // First try to find export default with the buildConfig call\n const exportAssignment = sourceFile.getFirstDescendantByKind(SyntaxKind.ExportAssignment)\n let buildConfigCall = null\n\n if (exportAssignment) {\n // Look for buildConfig call in the export default\n const callExpressions = exportAssignment.getDescendantsOfKind(SyntaxKind.CallExpression)\n buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n return expr.getText() === buildConfigName\n })\n }\n\n // If not found in export default, search all call expressions\n if (!buildConfigCall) {\n const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)\n buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n return expr.getText() === buildConfigName\n })\n }\n\n if (!buildConfigCall) {\n result.buildConfigNotFound = true\n return result\n }\n\n // Get config object\n const configArg = buildConfigCall.getArguments()[0]\n if (!configArg || !Node.isObjectLiteralExpression(configArg)) {\n return result\n }\n\n // Check for db property\n const dbProperty = configArg.getProperty('db')\n if (dbProperty) {\n const dbValue = dbProperty.getChildrenOfKind(SyntaxKind.CallExpression)[0]\n if (dbValue) {\n const adapterName = dbValue.getExpression().getText()\n\n // Find the import source for this adapter\n const adapterImport = imports.find((imp) =>\n imp.getNamedImports().some((ni) => ni.getName() === adapterName),\n )\n\n if (adapterImport) {\n result.dbProperty = {\n adapter: adapterName,\n importSource: adapterImport.getModuleSpecifierValue(),\n }\n }\n }\n }\n\n // Check for secret property\n const secretProperty = configArg.getProperty('secret')\n if (secretProperty) {\n result.secretProperty = true\n }\n\n // Check for editor property\n const editorProperty = configArg.getProperty('editor')\n if (editorProperty) {\n const editorValue = editorProperty.getChildrenOfKind(SyntaxKind.CallExpression)[0]\n if (editorValue) {\n const editorName = editorValue.getExpression().getText()\n\n // Find the import source\n const editorImport = imports.find((imp) =>\n imp.getNamedImports().some((ni) => ni.getName() === editorName),\n )\n\n if (editorImport && editorName === 'lexicalEditor') {\n // Check if it has arguments\n const args = editorValue.getArguments()\n const isDefault = args.length === 0\n\n result.editorProperty = {\n importSource: editorImport.getModuleSpecifierValue(),\n isDefault,\n }\n }\n }\n }\n\n return result\n}\n\nexport type ASTModificationResult = {\n changes: string[]\n modified: boolean\n}\n\n/**\n * Apply modifications to the source file based on detection result\n * Modifies the AST in memory - caller must call sourceFile.save()\n */\nexport function applyModifications(\n sourceFile: SourceFile,\n detection: DetectionResult,\n): ASTModificationResult {\n const changes: string[] = []\n let modified = false\n\n if (detection.buildConfigNotFound || detection.hasAlias) {\n if (isDebug()) {\n log.debug(\n `Skipping modifications: buildConfigNotFound=${detection.buildConfigNotFound}, hasAlias=${detection.hasAlias}`,\n )\n }\n return { changes: [], modified: false }\n }\n\n // Find the import declarations\n const imports = sourceFile.getImportDeclarations()\n const payloadImport = imports.find((imp) => imp.getModuleSpecifierValue() === 'payload')\n\n // Get the buildConfig name (could be aliased)\n let buildConfigName = 'buildConfig'\n if (payloadImport) {\n const buildConfigImport = payloadImport\n .getNamedImports()\n .find((ni) => ni.getName() === 'buildConfig')\n if (buildConfigImport) {\n const aliasNode = buildConfigImport.getAliasNode()\n buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig'\n }\n }\n\n // Find buildConfig call in export default (prefer export default)\n const exportAssignment = sourceFile.getFirstDescendantByKind(SyntaxKind.ExportAssignment)\n let buildConfigCall = null\n\n if (exportAssignment) {\n const callExpressions = exportAssignment.getDescendantsOfKind(SyntaxKind.CallExpression)\n buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n return expr.getText() === buildConfigName\n })\n }\n\n // If not found in export default, search all call expressions\n if (!buildConfigCall) {\n const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)\n buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n return expr.getText() === buildConfigName\n })\n }\n\n if (!buildConfigCall) {\n return { changes: [], modified: false }\n }\n\n const configArg = buildConfigCall.getArguments()[0]\n if (!configArg || !Node.isObjectLiteralExpression(configArg)) {\n return { changes: [], modified: false }\n }\n\n // 1. Remove db property\n if (detection.dbProperty) {\n const dbProperty = configArg.getProperty('db')\n if (dbProperty) {\n dbProperty.remove()\n changes.push('Removed db property')\n modified = true\n }\n }\n\n // 2. Remove secret property\n if (detection.secretProperty) {\n const secretProperty = configArg.getProperty('secret')\n if (secretProperty) {\n secretProperty.remove()\n changes.push('Removed secret property')\n modified = true\n }\n }\n\n // 3. Remove editor if default\n if (detection.editorProperty?.isDefault) {\n const editorProperty = configArg.getProperty('editor')\n if (editorProperty) {\n editorProperty.remove()\n changes.push('Removed default editor property')\n modified = true\n }\n }\n\n // 4. Update buildConfig import\n if (detection.needsImportChange) {\n if (payloadImport) {\n if (detection.hasOtherPayloadImports) {\n // Remove buildConfig from payload import, add new figma import\n const namedImports = payloadImport.getNamedImports()\n const buildConfigImport = namedImports.find((ni) => ni.getName() === 'buildConfig')\n if (buildConfigImport) {\n buildConfigImport.remove()\n\n // If payload import is now empty, remove it\n if (payloadImport.getNamedImports().length === 0) {\n payloadImport.remove()\n }\n }\n\n // Add new import at the top\n sourceFile.addImportDeclaration({\n moduleSpecifier: '@payloadcms/figma',\n namedImports: ['buildConfig'],\n })\n\n changes.push('Split buildConfig import to @payloadcms/figma')\n } else {\n // Replace entire import\n payloadImport.setModuleSpecifier('@payloadcms/figma')\n changes.push('Changed buildConfig import to @payloadcms/figma')\n }\n modified = true\n }\n }\n\n // 5. Remove orphaned imports\n // Re-fetch imports after each removal to avoid stale references\n if (detection.dbProperty) {\n const currentImports = sourceFile.getImportDeclarations()\n const dbImport = currentImports.find(\n (imp) => imp.getModuleSpecifierValue() === detection.dbProperty?.importSource,\n )\n if (dbImport) {\n dbImport.remove()\n changes.push(`Removed ${detection.dbProperty.adapter} import`)\n modified = true\n }\n }\n\n if (detection.editorProperty?.isDefault) {\n const currentImports = sourceFile.getImportDeclarations()\n const editorImport = currentImports.find(\n (imp) => imp.getModuleSpecifierValue() === detection.editorProperty?.importSource,\n )\n if (editorImport) {\n editorImport.remove()\n changes.push('Removed lexicalEditor import')\n modified = true\n }\n }\n\n return { changes, modified }\n}\n"],"names":["Node","SyntaxKind","isDebug","log","detectRequiredChanges","sourceFile","result","hasAlias","hasOtherPayloadImports","needsImportChange","imports","getImportDeclarations","payloadImport","find","imp","getModuleSpecifierValue","debug","buildConfigNotFound","moduleSpecifier","namedImports","getNamedImports","buildConfigImport","ni","getName","aliasNode","getAliasNode","buildConfigName","getText","length","exportAssignment","getFirstDescendantByKind","ExportAssignment","buildConfigCall","callExpressions","getDescendantsOfKind","CallExpression","ce","expr","getExpression","configArg","getArguments","isObjectLiteralExpression","dbProperty","getProperty","dbValue","getChildrenOfKind","adapterName","adapterImport","some","adapter","importSource","secretProperty","editorProperty","editorValue","editorName","editorImport","args","isDefault","applyModifications","detection","changes","modified","remove","push","addImportDeclaration","setModuleSpecifier","currentImports","dbImport"],"mappings":"AAEA,SAASA,IAAI,EAAEC,UAAU,QAAQ,WAAU;AAE3C,SAASC,OAAO,QAAQ,gBAAe;AACvC,YAAYC,SAAS,WAAU;AAkB/B;;CAEC,GACD,OAAO,SAASC,sBAAsBC,UAAsB;IAC1D,MAAMC,SAA0B;QAC9BC,UAAU;QACVC,wBAAwB;QACxBC,mBAAmB;IACrB;IAEA,0BAA0B;IAC1B,MAAMC,UAAUL,WAAWM,qBAAqB;IAChD,MAAMC,gBAAgBF,QAAQG,IAAI,CAChC,CAACC,MACCA,IAAIC,uBAAuB,OAAO,aAClCD,IAAIC,uBAAuB,OAAO;IAGtC,IAAI,CAACH,eAAe;QAClB,IAAIV,WAAW;YACbC,IAAIa,KAAK,CAAC;QACZ;QACAV,OAAOW,mBAAmB,GAAG;QAC7B,OAAOX;IACT;IAEA,IAAIJ,WAAW;QACbC,IAAIa,KAAK,CAAC,CAAC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,CAACS,KAAOA,GAAGC,OAAO,OAAO;gBACrE,IAAIF,mBAAmB;oBACrBA,kBAAkByC,MAAM;oBAExB,4CAA4C;oBAC5C,IAAIlD,cAAcQ,eAAe,GAAGQ,MAAM,KAAK,GAAG;wBAChDhB,cAAckD,MAAM;oBACtB;gBACF;gBAEA,4BAA4B;gBAC5BzD,WAAW2D,oBAAoB,CAAC;oBAC9B9C,iBAAiB;oBACjBC,cAAc;wBAAC;qBAAc;gBAC/B;gBAEAyC,QAAQG,IAAI,CAAC;YACf,OAAO;gBACL,wBAAwB;gBACxBnD,cAAcqD,kBAAkB,CAAC;gBACjCL,QAAQG,IAAI,CAAC;YACf;YACAF,WAAW;QACb;IACF;IAEA,6BAA6B;IAC7B,gEAAgE;IAChE,IAAIF,UAAUjB,UAAU,EAAE;QACxB,MAAMwB,iBAAiB7D,WAAWM,qBAAqB;QACvD,MAAMwD,WAAWD,eAAerD,IAAI,CAClC,CAACC,MAAQA,IAAIC,uBAAuB,OAAO4C,UAAUjB,UAAU,EAAEQ;QAEnE,IAAIiB,UAAU;YACZA,SAASL,MAAM;YACfF,QAAQG,IAAI,CAAC,CAAC,QAAQ,EAAEJ,UAAUjB,UAAU,CAACO,OAAO,CAAC,OAAO,CAAC;YAC7DY,WAAW;QACb;IACF;IAEA,IAAIF,UAAUP,cAAc,EAAEK,WAAW;QACvC,MAAMS,iBAAiB7D,WAAWM,qBAAqB;QACvD,MAAM4C,eAAeW,eAAerD,IAAI,CACtC,CAACC,MAAQA,IAAIC,uBAAuB,OAAO4C,UAAUP,cAAc,EAAEF;QAEvE,IAAIK,cAAc;YAChBA,aAAaO,MAAM;YACnBF,QAAQG,IAAI,CAAC;YACbF,WAAW;QACb;IACF;IAEA,OAAO;QAAED;QAASC;IAAS;AAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payload-config-ast.spec.d.ts","sourceRoot":"","sources":["../../src/utils/payload-config-ast.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { Project } from 'ts-morph';
|
|
2
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
3
|
+
import { applyModifications, detectRequiredChanges } from './payload-config-ast.js';
|
|
4
|
+
describe('payload-config-ast - detection', ()=>{
|
|
5
|
+
let project;
|
|
6
|
+
beforeEach(()=>{
|
|
7
|
+
project = new Project({
|
|
8
|
+
useInMemoryFileSystem: true
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
describe('detectRequiredChanges', ()=>{
|
|
12
|
+
it('should detect buildConfig from payload needs change', ()=>{
|
|
13
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
14
|
+
import { buildConfig } from 'payload'
|
|
15
|
+
|
|
16
|
+
export default buildConfig({
|
|
17
|
+
db: mongooseAdapter({ url: 'mongodb://localhost' }),
|
|
18
|
+
secret: 'test-secret',
|
|
19
|
+
})
|
|
20
|
+
`.trim());
|
|
21
|
+
const result = detectRequiredChanges(sourceFile);
|
|
22
|
+
expect(result.needsImportChange).toBe(true);
|
|
23
|
+
expect(result.hasOtherPayloadImports).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
it('should detect buildConfig from @payloadcms/figma already correct', ()=>{
|
|
26
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
27
|
+
import { buildConfig } from '@payloadcms/figma'
|
|
28
|
+
|
|
29
|
+
export default buildConfig({
|
|
30
|
+
collections: [],
|
|
31
|
+
})
|
|
32
|
+
`.trim());
|
|
33
|
+
const result = detectRequiredChanges(sourceFile);
|
|
34
|
+
expect(result.needsImportChange).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
it('should detect buildConfig alias and find the aliased call', ()=>{
|
|
37
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
38
|
+
import { buildConfig as createConfig } from 'payload'
|
|
39
|
+
|
|
40
|
+
export default createConfig({})
|
|
41
|
+
`.trim());
|
|
42
|
+
const result = detectRequiredChanges(sourceFile);
|
|
43
|
+
expect(result.hasAlias).toBe(true);
|
|
44
|
+
expect(result.needsImportChange).toBe(true);
|
|
45
|
+
expect(result.buildConfigNotFound).toBeUndefined();
|
|
46
|
+
});
|
|
47
|
+
it('should detect other payload imports to preserve', ()=>{
|
|
48
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
49
|
+
import { buildConfig, CollectionConfig } from 'payload'
|
|
50
|
+
|
|
51
|
+
export default buildConfig({})
|
|
52
|
+
`.trim());
|
|
53
|
+
const result = detectRequiredChanges(sourceFile);
|
|
54
|
+
expect(result.needsImportChange).toBe(true);
|
|
55
|
+
expect(result.hasOtherPayloadImports).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
it('should detect db property with mongoose adapter', ()=>{
|
|
58
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
59
|
+
import { buildConfig } from 'payload'
|
|
60
|
+
import { mongooseAdapter } from '@payloadcms/db-mongodb'
|
|
61
|
+
|
|
62
|
+
export default buildConfig({
|
|
63
|
+
db: mongooseAdapter({ url: 'mongodb://localhost' }),
|
|
64
|
+
})
|
|
65
|
+
`.trim());
|
|
66
|
+
const result = detectRequiredChanges(sourceFile);
|
|
67
|
+
expect(result.dbProperty).toBeDefined();
|
|
68
|
+
expect(result.dbProperty?.adapter).toBe('mongooseAdapter');
|
|
69
|
+
expect(result.dbProperty?.importSource).toBe('@payloadcms/db-mongodb');
|
|
70
|
+
});
|
|
71
|
+
it('should detect db property with postgres adapter', ()=>{
|
|
72
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
73
|
+
import { buildConfig } from 'payload'
|
|
74
|
+
import { postgresAdapter } from '@payloadcms/db-postgres'
|
|
75
|
+
|
|
76
|
+
export default buildConfig({
|
|
77
|
+
db: postgresAdapter({ pool: {} }),
|
|
78
|
+
})
|
|
79
|
+
`.trim());
|
|
80
|
+
const result = detectRequiredChanges(sourceFile);
|
|
81
|
+
expect(result.dbProperty).toBeDefined();
|
|
82
|
+
expect(result.dbProperty?.adapter).toBe('postgresAdapter');
|
|
83
|
+
expect(result.dbProperty?.importSource).toBe('@payloadcms/db-postgres');
|
|
84
|
+
});
|
|
85
|
+
it('should detect secret property', ()=>{
|
|
86
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
87
|
+
import { buildConfig } from 'payload'
|
|
88
|
+
|
|
89
|
+
export default buildConfig({
|
|
90
|
+
secret: 'test-secret-123',
|
|
91
|
+
})
|
|
92
|
+
`.trim());
|
|
93
|
+
const result = detectRequiredChanges(sourceFile);
|
|
94
|
+
expect(result.secretProperty).toBe(true);
|
|
95
|
+
});
|
|
96
|
+
it('should detect default editor with lexicalEditor no args', ()=>{
|
|
97
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
98
|
+
import { buildConfig } from 'payload'
|
|
99
|
+
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
100
|
+
|
|
101
|
+
export default buildConfig({
|
|
102
|
+
editor: lexicalEditor(),
|
|
103
|
+
})
|
|
104
|
+
`.trim());
|
|
105
|
+
const result = detectRequiredChanges(sourceFile);
|
|
106
|
+
expect(result.editorProperty).toBeDefined();
|
|
107
|
+
expect(result.editorProperty?.isDefault).toBe(true);
|
|
108
|
+
expect(result.editorProperty?.importSource).toBe('@payloadcms/richtext-lexical');
|
|
109
|
+
});
|
|
110
|
+
it('should detect custom editor with lexicalEditor args', ()=>{
|
|
111
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
112
|
+
import { buildConfig } from 'payload'
|
|
113
|
+
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
114
|
+
|
|
115
|
+
export default buildConfig({
|
|
116
|
+
editor: lexicalEditor({ features: [] }),
|
|
117
|
+
})
|
|
118
|
+
`.trim());
|
|
119
|
+
const result = detectRequiredChanges(sourceFile);
|
|
120
|
+
expect(result.editorProperty).toBeDefined();
|
|
121
|
+
expect(result.editorProperty?.isDefault).toBe(false);
|
|
122
|
+
});
|
|
123
|
+
it('should return null when buildConfig call not found', ()=>{
|
|
124
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
125
|
+
import { buildConfig } from 'payload'
|
|
126
|
+
|
|
127
|
+
const config = { collections: [] }
|
|
128
|
+
`.trim());
|
|
129
|
+
const result = detectRequiredChanges(sourceFile);
|
|
130
|
+
expect(result.buildConfigNotFound).toBe(true);
|
|
131
|
+
});
|
|
132
|
+
it('should prefer buildConfig call in export default over other calls', ()=>{
|
|
133
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
134
|
+
import { buildConfig } from 'payload'
|
|
135
|
+
import { mongooseAdapter } from '@payloadcms/db-mongodb'
|
|
136
|
+
|
|
137
|
+
// Some other buildConfig call that should be ignored
|
|
138
|
+
const otherConfig = buildConfig({ collections: [] })
|
|
139
|
+
|
|
140
|
+
export default buildConfig({
|
|
141
|
+
db: mongooseAdapter({ url: 'mongodb://localhost' }),
|
|
142
|
+
secret: 'test-secret',
|
|
143
|
+
})
|
|
144
|
+
`.trim());
|
|
145
|
+
const result = detectRequiredChanges(sourceFile);
|
|
146
|
+
// Should find the export default buildConfig call with db property
|
|
147
|
+
expect(result.buildConfigNotFound).toBeUndefined();
|
|
148
|
+
expect(result.dbProperty).toBeDefined();
|
|
149
|
+
expect(result.dbProperty?.adapter).toBe('mongooseAdapter');
|
|
150
|
+
expect(result.secretProperty).toBe(true);
|
|
151
|
+
});
|
|
152
|
+
it('should detect aliased buildConfig in export default', ()=>{
|
|
153
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
154
|
+
import { buildConfig as createConfig } from 'payload'
|
|
155
|
+
import { postgresAdapter } from '@payloadcms/db-postgres'
|
|
156
|
+
|
|
157
|
+
export default createConfig({
|
|
158
|
+
db: postgresAdapter({ pool: {} }),
|
|
159
|
+
})
|
|
160
|
+
`.trim());
|
|
161
|
+
const result = detectRequiredChanges(sourceFile);
|
|
162
|
+
expect(result.hasAlias).toBe(true);
|
|
163
|
+
expect(result.buildConfigNotFound).toBeUndefined();
|
|
164
|
+
expect(result.dbProperty).toBeDefined();
|
|
165
|
+
expect(result.dbProperty?.adapter).toBe('postgresAdapter');
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
describe('applyModifications', ()=>{
|
|
169
|
+
it('should remove db property', ()=>{
|
|
170
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
171
|
+
import { buildConfig } from 'payload'
|
|
172
|
+
import { mongooseAdapter } from '@payloadcms/db-mongodb'
|
|
173
|
+
|
|
174
|
+
export default buildConfig({
|
|
175
|
+
db: mongooseAdapter({ url: 'mongodb://localhost' }),
|
|
176
|
+
collections: [],
|
|
177
|
+
})
|
|
178
|
+
`.trim());
|
|
179
|
+
const detection = detectRequiredChanges(sourceFile);
|
|
180
|
+
const { changes, modified } = applyModifications(sourceFile, detection);
|
|
181
|
+
expect(modified).toBe(true);
|
|
182
|
+
expect(changes).toContain('Removed db property');
|
|
183
|
+
expect(sourceFile.getFullText()).not.toContain('db:');
|
|
184
|
+
});
|
|
185
|
+
it('should remove secret property', ()=>{
|
|
186
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
187
|
+
import { buildConfig } from 'payload'
|
|
188
|
+
|
|
189
|
+
export default buildConfig({
|
|
190
|
+
secret: 'test-secret',
|
|
191
|
+
collections: [],
|
|
192
|
+
})
|
|
193
|
+
`.trim());
|
|
194
|
+
const detection = detectRequiredChanges(sourceFile);
|
|
195
|
+
const { changes, modified } = applyModifications(sourceFile, detection);
|
|
196
|
+
expect(modified).toBe(true);
|
|
197
|
+
expect(changes).toContain('Removed secret property');
|
|
198
|
+
expect(sourceFile.getFullText()).not.toContain('secret:');
|
|
199
|
+
});
|
|
200
|
+
it('should remove default editor property', ()=>{
|
|
201
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
202
|
+
import { buildConfig } from 'payload'
|
|
203
|
+
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
204
|
+
|
|
205
|
+
export default buildConfig({
|
|
206
|
+
editor: lexicalEditor(),
|
|
207
|
+
collections: [],
|
|
208
|
+
})
|
|
209
|
+
`.trim());
|
|
210
|
+
const detection = detectRequiredChanges(sourceFile);
|
|
211
|
+
const { changes, modified } = applyModifications(sourceFile, detection);
|
|
212
|
+
expect(modified).toBe(true);
|
|
213
|
+
expect(changes).toContain('Removed default editor property');
|
|
214
|
+
expect(sourceFile.getFullText()).not.toContain('editor:');
|
|
215
|
+
});
|
|
216
|
+
it('should preserve custom editor', ()=>{
|
|
217
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
218
|
+
import { buildConfig } from 'payload'
|
|
219
|
+
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
220
|
+
|
|
221
|
+
export default buildConfig({
|
|
222
|
+
editor: lexicalEditor({ features: [] }),
|
|
223
|
+
collections: [],
|
|
224
|
+
})
|
|
225
|
+
`.trim());
|
|
226
|
+
const detection = detectRequiredChanges(sourceFile);
|
|
227
|
+
applyModifications(sourceFile, detection);
|
|
228
|
+
expect(sourceFile.getFullText()).toContain('editor:');
|
|
229
|
+
});
|
|
230
|
+
it('should replace buildConfig import when no other payload imports', ()=>{
|
|
231
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
232
|
+
import { buildConfig } from 'payload'
|
|
233
|
+
|
|
234
|
+
export default buildConfig({})
|
|
235
|
+
`.trim());
|
|
236
|
+
const detection = detectRequiredChanges(sourceFile);
|
|
237
|
+
const { changes, modified } = applyModifications(sourceFile, detection);
|
|
238
|
+
expect(modified).toBe(true);
|
|
239
|
+
expect(changes).toContain('Changed buildConfig import to @payloadcms/figma');
|
|
240
|
+
expect(sourceFile.getFullText()).toContain("from '@payloadcms/figma'");
|
|
241
|
+
expect(sourceFile.getFullText()).not.toContain("from 'payload'");
|
|
242
|
+
});
|
|
243
|
+
it('should split buildConfig import when other payload imports exist', ()=>{
|
|
244
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
245
|
+
import { buildConfig, CollectionConfig } from 'payload'
|
|
246
|
+
|
|
247
|
+
export default buildConfig({})
|
|
248
|
+
`.trim());
|
|
249
|
+
const detection = detectRequiredChanges(sourceFile);
|
|
250
|
+
const { changes, modified } = applyModifications(sourceFile, detection);
|
|
251
|
+
expect(modified).toBe(true);
|
|
252
|
+
expect(changes).toContain('Split buildConfig import to @payloadcms/figma');
|
|
253
|
+
const fullText = sourceFile.getFullText();
|
|
254
|
+
expect(fullText).toMatch(/import\s*\{\s*CollectionConfig\s*\}\s*from\s*['"]payload['"]/);
|
|
255
|
+
expect(fullText).toMatch(/import\s*\{\s*buildConfig\s*\}\s*from\s*['"]@payloadcms\/figma['"]/);
|
|
256
|
+
});
|
|
257
|
+
it('should remove db adapter import', ()=>{
|
|
258
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
259
|
+
import { buildConfig } from 'payload'
|
|
260
|
+
import { mongooseAdapter } from '@payloadcms/db-mongodb'
|
|
261
|
+
|
|
262
|
+
export default buildConfig({
|
|
263
|
+
db: mongooseAdapter({ url: 'mongodb://localhost' }),
|
|
264
|
+
})
|
|
265
|
+
`.trim());
|
|
266
|
+
const detection = detectRequiredChanges(sourceFile);
|
|
267
|
+
const { changes, modified } = applyModifications(sourceFile, detection);
|
|
268
|
+
expect(modified).toBe(true);
|
|
269
|
+
expect(changes).toContain('Removed mongooseAdapter import');
|
|
270
|
+
expect(sourceFile.getFullText()).not.toContain('@payloadcms/db-mongodb');
|
|
271
|
+
});
|
|
272
|
+
it('should remove lexicalEditor import when default', ()=>{
|
|
273
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
274
|
+
import { buildConfig } from 'payload'
|
|
275
|
+
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
276
|
+
|
|
277
|
+
export default buildConfig({
|
|
278
|
+
editor: lexicalEditor(),
|
|
279
|
+
})
|
|
280
|
+
`.trim());
|
|
281
|
+
const detection = detectRequiredChanges(sourceFile);
|
|
282
|
+
const { changes, modified } = applyModifications(sourceFile, detection);
|
|
283
|
+
expect(modified).toBe(true);
|
|
284
|
+
expect(changes).toContain('Removed lexicalEditor import');
|
|
285
|
+
expect(sourceFile.getFullText()).not.toContain('@payloadcms/richtext-lexical');
|
|
286
|
+
});
|
|
287
|
+
it('should track modified flag correctly when no changes needed', ()=>{
|
|
288
|
+
const sourceFile = project.createSourceFile('test.ts', `
|
|
289
|
+
import { buildConfig } from '@payloadcms/figma'
|
|
290
|
+
|
|
291
|
+
export default buildConfig({
|
|
292
|
+
collections: [],
|
|
293
|
+
})
|
|
294
|
+
`.trim());
|
|
295
|
+
const detection = detectRequiredChanges(sourceFile);
|
|
296
|
+
const { changes, modified } = applyModifications(sourceFile, detection);
|
|
297
|
+
expect(modified).toBe(false);
|
|
298
|
+
expect(changes).toHaveLength(0);
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
//# sourceMappingURL=payload-config-ast.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/payload-config-ast.spec.ts"],"sourcesContent":["import { Project } from 'ts-morph'\nimport { beforeEach, describe, expect, it } from 'vitest'\n\nimport { applyModifications, detectRequiredChanges } from './payload-config-ast.js'\n\ndescribe('payload-config-ast - detection', () => {\n let project: Project\n\n beforeEach(() => {\n project = new Project({ useInMemoryFileSystem: true })\n })\n\n describe('detectRequiredChanges', () => {\n it('should detect buildConfig from payload needs change', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\n\nexport default buildConfig({\n db: mongooseAdapter({ url: 'mongodb://localhost' }),\n secret: 'test-secret',\n})\n `.trim(),\n )\n\n const result = detectRequiredChanges(sourceFile)\n\n expect(result.needsImportChange).toBe(true)\n expect(result.hasOtherPayloadImports).toBe(false)\n })\n\n it('should detect buildConfig from @payloadcms/figma already correct', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from '@payloadcms/figma'\n\nexport default buildConfig({\n collections: [],\n})\n `.trim(),\n )\n\n const result = detectRequiredChanges(sourceFile)\n\n expect(result.needsImportChange).toBe(false)\n })\n\n it('should detect buildConfig alias and find the aliased call', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig as createConfig } from 'payload'\n\nexport default createConfig({})\n `.trim(),\n )\n\n const result = detectRequiredChanges(sourceFile)\n\n expect(result.hasAlias).toBe(true)\n expect(result.needsImportChange).toBe(true)\n expect(result.buildConfigNotFound).toBeUndefined()\n })\n\n it('should detect other payload imports to preserve', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig, CollectionConfig } from 'payload'\n\nexport default buildConfig({})\n `.trim(),\n )\n\n const result = detectRequiredChanges(sourceFile)\n\n expect(result.needsImportChange).toBe(true)\n expect(result.hasOtherPayloadImports).toBe(true)\n })\n\n it('should detect db property with mongoose adapter', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\nimport { mongooseAdapter } from '@payloadcms/db-mongodb'\n\nexport default buildConfig({\n db: mongooseAdapter({ url: 'mongodb://localhost' }),\n})\n `.trim(),\n )\n\n const result = detectRequiredChanges(sourceFile)\n\n expect(result.dbProperty).toBeDefined()\n expect(result.dbProperty?.adapter).toBe('mongooseAdapter')\n expect(result.dbProperty?.importSource).toBe('@payloadcms/db-mongodb')\n })\n\n it('should detect db property with postgres adapter', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\nimport { postgresAdapter } from '@payloadcms/db-postgres'\n\nexport default buildConfig({\n db: postgresAdapter({ pool: {} }),\n})\n `.trim(),\n )\n\n const result = detectRequiredChanges(sourceFile)\n\n expect(result.dbProperty).toBeDefined()\n expect(result.dbProperty?.adapter).toBe('postgresAdapter')\n expect(result.dbProperty?.importSource).toBe('@payloadcms/db-postgres')\n })\n\n it('should detect secret property', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\n\nexport default buildConfig({\n secret: 'test-secret-123',\n})\n `.trim(),\n )\n\n const result = detectRequiredChanges(sourceFile)\n\n expect(result.secretProperty).toBe(true)\n })\n\n it('should detect default editor with lexicalEditor no args', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\nimport { lexicalEditor } from '@payloadcms/richtext-lexical'\n\nexport default buildConfig({\n editor: lexicalEditor(),\n})\n `.trim(),\n )\n\n const result = detectRequiredChanges(sourceFile)\n\n expect(result.editorProperty).toBeDefined()\n expect(result.editorProperty?.isDefault).toBe(true)\n expect(result.editorProperty?.importSource).toBe('@payloadcms/richtext-lexical')\n })\n\n it('should detect custom editor with lexicalEditor args', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\nimport { lexicalEditor } from '@payloadcms/richtext-lexical'\n\nexport default buildConfig({\n editor: lexicalEditor({ features: [] }),\n})\n `.trim(),\n )\n\n const result = detectRequiredChanges(sourceFile)\n\n expect(result.editorProperty).toBeDefined()\n expect(result.editorProperty?.isDefault).toBe(false)\n })\n\n it('should return null when buildConfig call not found', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\n\nconst config = { collections: [] }\n `.trim(),\n )\n\n const result = detectRequiredChanges(sourceFile)\n\n expect(result.buildConfigNotFound).toBe(true)\n })\n\n it('should prefer buildConfig call in export default over other calls', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\nimport { mongooseAdapter } from '@payloadcms/db-mongodb'\n\n// Some other buildConfig call that should be ignored\nconst otherConfig = buildConfig({ collections: [] })\n\nexport default buildConfig({\n db: mongooseAdapter({ url: 'mongodb://localhost' }),\n secret: 'test-secret',\n})\n `.trim(),\n )\n\n const result = detectRequiredChanges(sourceFile)\n\n // Should find the export default buildConfig call with db property\n expect(result.buildConfigNotFound).toBeUndefined()\n expect(result.dbProperty).toBeDefined()\n expect(result.dbProperty?.adapter).toBe('mongooseAdapter')\n expect(result.secretProperty).toBe(true)\n })\n\n it('should detect aliased buildConfig in export default', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig as createConfig } from 'payload'\nimport { postgresAdapter } from '@payloadcms/db-postgres'\n\nexport default createConfig({\n db: postgresAdapter({ pool: {} }),\n})\n `.trim(),\n )\n\n const result = detectRequiredChanges(sourceFile)\n\n expect(result.hasAlias).toBe(true)\n expect(result.buildConfigNotFound).toBeUndefined()\n expect(result.dbProperty).toBeDefined()\n expect(result.dbProperty?.adapter).toBe('postgresAdapter')\n })\n })\n\n describe('applyModifications', () => {\n it('should remove db property', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\nimport { mongooseAdapter } from '@payloadcms/db-mongodb'\n\nexport default buildConfig({\n db: mongooseAdapter({ url: 'mongodb://localhost' }),\n collections: [],\n})\n `.trim(),\n )\n\n const detection = detectRequiredChanges(sourceFile)\n const { changes, modified } = applyModifications(sourceFile, detection)\n\n expect(modified).toBe(true)\n expect(changes).toContain('Removed db property')\n expect(sourceFile.getFullText()).not.toContain('db:')\n })\n\n it('should remove secret property', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\n\nexport default buildConfig({\n secret: 'test-secret',\n collections: [],\n})\n `.trim(),\n )\n\n const detection = detectRequiredChanges(sourceFile)\n const { changes, modified } = applyModifications(sourceFile, detection)\n\n expect(modified).toBe(true)\n expect(changes).toContain('Removed secret property')\n expect(sourceFile.getFullText()).not.toContain('secret:')\n })\n\n it('should remove default editor property', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\nimport { lexicalEditor } from '@payloadcms/richtext-lexical'\n\nexport default buildConfig({\n editor: lexicalEditor(),\n collections: [],\n})\n `.trim(),\n )\n\n const detection = detectRequiredChanges(sourceFile)\n const { changes, modified } = applyModifications(sourceFile, detection)\n\n expect(modified).toBe(true)\n expect(changes).toContain('Removed default editor property')\n expect(sourceFile.getFullText()).not.toContain('editor:')\n })\n\n it('should preserve custom editor', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\nimport { lexicalEditor } from '@payloadcms/richtext-lexical'\n\nexport default buildConfig({\n editor: lexicalEditor({ features: [] }),\n collections: [],\n})\n `.trim(),\n )\n\n const detection = detectRequiredChanges(sourceFile)\n applyModifications(sourceFile, detection)\n\n expect(sourceFile.getFullText()).toContain('editor:')\n })\n\n it('should replace buildConfig import when no other payload imports', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\n\nexport default buildConfig({})\n `.trim(),\n )\n\n const detection = detectRequiredChanges(sourceFile)\n const { changes, modified } = applyModifications(sourceFile, detection)\n\n expect(modified).toBe(true)\n expect(changes).toContain('Changed buildConfig import to @payloadcms/figma')\n expect(sourceFile.getFullText()).toContain(\"from '@payloadcms/figma'\")\n expect(sourceFile.getFullText()).not.toContain(\"from 'payload'\")\n })\n\n it('should split buildConfig import when other payload imports exist', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig, CollectionConfig } from 'payload'\n\nexport default buildConfig({})\n `.trim(),\n )\n\n const detection = detectRequiredChanges(sourceFile)\n const { changes, modified } = applyModifications(sourceFile, detection)\n\n expect(modified).toBe(true)\n expect(changes).toContain('Split buildConfig import to @payloadcms/figma')\n const fullText = sourceFile.getFullText()\n expect(fullText).toMatch(/import\\s*\\{\\s*CollectionConfig\\s*\\}\\s*from\\s*['\"]payload['\"]/)\n expect(fullText).toMatch(/import\\s*\\{\\s*buildConfig\\s*\\}\\s*from\\s*['\"]@payloadcms\\/figma['\"]/)\n })\n\n it('should remove db adapter import', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\nimport { mongooseAdapter } from '@payloadcms/db-mongodb'\n\nexport default buildConfig({\n db: mongooseAdapter({ url: 'mongodb://localhost' }),\n})\n `.trim(),\n )\n\n const detection = detectRequiredChanges(sourceFile)\n const { changes, modified } = applyModifications(sourceFile, detection)\n\n expect(modified).toBe(true)\n expect(changes).toContain('Removed mongooseAdapter import')\n expect(sourceFile.getFullText()).not.toContain('@payloadcms/db-mongodb')\n })\n\n it('should remove lexicalEditor import when default', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from 'payload'\nimport { lexicalEditor } from '@payloadcms/richtext-lexical'\n\nexport default buildConfig({\n editor: lexicalEditor(),\n})\n `.trim(),\n )\n\n const detection = detectRequiredChanges(sourceFile)\n const { changes, modified } = applyModifications(sourceFile, detection)\n\n expect(modified).toBe(true)\n expect(changes).toContain('Removed lexicalEditor import')\n expect(sourceFile.getFullText()).not.toContain('@payloadcms/richtext-lexical')\n })\n\n it('should track modified flag correctly when no changes needed', () => {\n const sourceFile = project.createSourceFile(\n 'test.ts',\n `\nimport { buildConfig } from '@payloadcms/figma'\n\nexport default buildConfig({\n collections: [],\n})\n `.trim(),\n )\n\n const detection = detectRequiredChanges(sourceFile)\n const { changes, modified } = applyModifications(sourceFile, detection)\n\n expect(modified).toBe(false)\n expect(changes).toHaveLength(0)\n })\n })\n})\n"],"names":["Project","beforeEach","describe","expect","it","applyModifications","detectRequiredChanges","project","useInMemoryFileSystem","sourceFile","createSourceFile","trim","result","needsImportChange","toBe","hasOtherPayloadImports","hasAlias","buildConfigNotFound","toBeUndefined","dbProperty","toBeDefined","adapter","importSource","secretProperty","editorProperty","isDefault","detection","changes","modified","toContain","getFullText","not","fullText","toMatch","toHaveLength"],"mappings":"AAAA,SAASA,OAAO,QAAQ,WAAU;AAClC,SAASC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAEzD,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ,0BAAyB;AAEnFJ,SAAS,kCAAkC;IACzC,IAAIK;IAEJN,WAAW;QACTM,UAAU,IAAIP,QAAQ;YAAEQ,uBAAuB;QAAK;IACtD;IAEAN,SAAS,yBAAyB;QAChC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wB,SAASO,YAAY,CAAC;QAC/B;IACF;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find the Payload config file using Payload's built-in finder
|
|
3
|
+
* Changes to project directory temporarily and restores afterward
|
|
4
|
+
*
|
|
5
|
+
* @param projectPath - Absolute path to project directory
|
|
6
|
+
* @returns Absolute path to config file, or null if not found
|
|
7
|
+
*/
|
|
8
|
+
export declare function findPayloadConfig(projectPath: string): Promise<null | string>;
|
|
9
|
+
//# sourceMappingURL=payload-config-finder.d.ts.map
|