create-payload-app 4.0.0-internal.2a3c3bc → 4.0.0-internal.2d11d2e
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/lib/ast/adapter-config.d.ts +2 -0
- package/dist/lib/ast/adapter-config.d.ts.map +1 -1
- package/dist/lib/ast/adapter-config.js +6 -0
- package/dist/lib/ast/adapter-config.js.map +1 -1
- package/dist/lib/ast/package-json.d.ts.map +1 -1
- package/dist/lib/ast/package-json.js +11 -6
- package/dist/lib/ast/package-json.js.map +1 -1
- package/dist/lib/ast/payload-config.d.ts.map +1 -1
- package/dist/lib/ast/payload-config.js +101 -55
- package/dist/lib/ast/payload-config.js.map +1 -1
- package/dist/lib/ast/types.d.ts +1 -1
- package/dist/lib/ast/types.d.ts.map +1 -1
- package/dist/lib/ast/types.js.map +1 -1
- package/dist/lib/configure-payload-config.js +1 -1
- package/dist/lib/configure-payload-config.js.map +1 -1
- package/dist/lib/download-example.js.map +1 -1
- package/dist/lib/download-template.js.map +1 -1
- package/dist/template/src/app/(payload)/admin/importMap.js +4 -5
- package/dist/template-tanstack/routes/_payload/api.$.ts +1 -1
- package/dist/template-tanstack/routes/_payload/importMap.js +5 -5
- package/dist/template-tanstack/routes/_payload/server.functions.ts +2 -5
- package/package.json +17 -19
|
@@ -21,6 +21,8 @@ export declare const DB_ADAPTER_CONFIG: Record<DatabaseAdapter, DatabaseAdapterC
|
|
|
21
21
|
* Storage adapter configurations
|
|
22
22
|
*/
|
|
23
23
|
export declare const STORAGE_ADAPTER_CONFIG: Record<StorageAdapter, StorageAdapterConfig>;
|
|
24
|
+
export declare const SHARP_TRANSFORMER_PACKAGE = "@payloadcms/transformer-sharp";
|
|
25
|
+
export declare const SHARP_TRANSFORMER_NAME = "sharpTransformer";
|
|
24
26
|
/**
|
|
25
27
|
* Helper to get database adapter package name
|
|
26
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-config.d.ts","sourceRoot":"","sources":["../../../src/lib/ast/adapter-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEjE,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAA;IAC1C,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,EAAE,IAAI,GAAG,MAAM,CAAA;IAC1B,cAAc,EAAE,MAAM,IAAI,GAAG,MAAM,CAAA;IACnC,WAAW,EAAE,IAAI,GAAG,MAAM,CAAA;CAC3B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,eAAe,EAAE,qBAAqB,CA0CnE,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,cAAc,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"adapter-config.d.ts","sourceRoot":"","sources":["../../../src/lib/ast/adapter-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEjE,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAA;IAC1C,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,EAAE,IAAI,GAAG,MAAM,CAAA;IAC1B,cAAc,EAAE,MAAM,IAAI,GAAG,MAAM,CAAA;IACnC,WAAW,EAAE,IAAI,GAAG,MAAM,CAAA;CAC3B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,eAAe,EAAE,qBAAqB,CA0CnE,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,cAAc,EAAE,oBAAoB,CAkEtE,CAAA;AAEV,eAAO,MAAM,yBAAyB,kCAAkC,CAAA;AAExE,eAAO,MAAM,sBAAsB,qBAAqB,CAAA;AAExD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAEjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAEjE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,GAAG,MAAM,CAE5E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,GAAG,MAAM,CAE5E"}
|
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
media: true,
|
|
68
68
|
},
|
|
69
69
|
bucket: process.env.GCS_BUCKET || '',
|
|
70
|
+
options: {
|
|
71
|
+
apiEndpoint: process.env.GCS_ENDPOINT,
|
|
72
|
+
projectId: process.env.GCS_PROJECT_ID,
|
|
73
|
+
},
|
|
70
74
|
})`,
|
|
71
75
|
packageName: '@payloadcms/storage-gcs'
|
|
72
76
|
},
|
|
@@ -111,6 +115,8 @@
|
|
|
111
115
|
packageName: '@payloadcms/storage-vercel-blob'
|
|
112
116
|
}
|
|
113
117
|
};
|
|
118
|
+
export const SHARP_TRANSFORMER_PACKAGE = '@payloadcms/transformer-sharp';
|
|
119
|
+
export const SHARP_TRANSFORMER_NAME = 'sharpTransformer';
|
|
114
120
|
/**
|
|
115
121
|
* Helper to get database adapter package name
|
|
116
122
|
*/ export function getDbPackageName(adapter) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/ast/adapter-config.ts"],"sourcesContent":["/**\n * Centralized adapter configuration\n * Shared across all AST transformation and test files\n */\n\nimport type { DatabaseAdapter, StorageAdapter } from './types.js'\n\nexport type DatabaseAdapterConfig = {\n adapterName: string\n configTemplate: (envVar: string) => string\n packageName: string\n}\n\nexport type StorageAdapterConfig = {\n adapterName: null | string\n configTemplate: () => null | string\n packageName: null | string\n}\n\n/**\n * Database adapter configurations\n */\nexport const DB_ADAPTER_CONFIG: Record<DatabaseAdapter, DatabaseAdapterConfig> = {\n 'd1-sqlite': {\n adapterName: 'sqliteD1Adapter',\n configTemplate: () => `sqliteD1Adapter({\n binding: cloudflare.env.D1,\n})`,\n packageName: '@payloadcms/db-d1-sqlite',\n },\n mongodb: {\n adapterName: 'mongooseAdapter',\n configTemplate: (envVar: string) => `mongooseAdapter({\n url: process.env.${envVar} || '',\n})`,\n packageName: '@payloadcms/db-mongodb',\n },\n postgres: {\n adapterName: 'postgresAdapter',\n configTemplate: (envVar: string) => `postgresAdapter({\n pool: {\n connectionString: process.env.${envVar} || '',\n },\n})`,\n packageName: '@payloadcms/db-postgres',\n },\n sqlite: {\n adapterName: 'sqliteAdapter',\n configTemplate: () => `sqliteAdapter({\n client: {\n url: process.env.DATABASE_URL || '',\n },\n})`,\n packageName: '@payloadcms/db-sqlite',\n },\n 'vercel-postgres': {\n adapterName: 'vercelPostgresAdapter',\n configTemplate: () => `vercelPostgresAdapter({\n pool: {\n connectionString: process.env.POSTGRES_URL || '',\n },\n})`,\n packageName: '@payloadcms/db-vercel-postgres',\n },\n} as const\n\n/**\n * Storage adapter configurations\n */\nexport const STORAGE_ADAPTER_CONFIG: Record<StorageAdapter, StorageAdapterConfig> = {\n azureStorage: {\n adapterName: 'azureStorage',\n configTemplate: () => `azureStorage({\n collections: {\n media: true,\n },\n connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING || '',\n containerName: process.env.AZURE_STORAGE_CONTAINER_NAME || '',\n })`,\n packageName: '@payloadcms/storage-azure',\n },\n gcsStorage: {\n adapterName: 'gcsStorage',\n configTemplate: () => `gcsStorage({\n collections: {\n media: true,\n },\n bucket: process.env.GCS_BUCKET || '',\n })`,\n packageName: '@payloadcms/storage-gcs',\n },\n localDisk: {\n adapterName: null,\n configTemplate: () => null,\n packageName: null,\n },\n r2Storage: {\n adapterName: 'r2Storage',\n configTemplate: () => `r2Storage({\n bucket: cloudflare.env.R2,\n collections: { media: true },\n })`,\n packageName: '@payloadcms/storage-r2',\n },\n s3Storage: {\n adapterName: 's3Storage',\n configTemplate: () => `s3Storage({\n collections: {\n media: true,\n },\n bucket: process.env.S3_BUCKET || '',\n config: {\n credentials: {\n accessKeyId: process.env.S3_ACCESS_KEY_ID || '',\n secretAccessKey: process.env.S3_SECRET_ACCESS_KEY || '',\n },\n region: process.env.S3_REGION || '',\n },\n })`,\n packageName: '@payloadcms/storage-s3',\n },\n vercelBlobStorage: {\n adapterName: 'vercelBlobStorage',\n configTemplate: () => `vercelBlobStorage({\n collections: {\n media: true,\n },\n token: process.env.BLOB_READ_WRITE_TOKEN || '',\n })`,\n packageName: '@payloadcms/storage-vercel-blob',\n },\n} as const\n\n/**\n * Helper to get database adapter package name\n */\nexport function getDbPackageName(adapter: DatabaseAdapter): string {\n return DB_ADAPTER_CONFIG[adapter].packageName\n}\n\n/**\n * Helper to get database adapter name\n */\nexport function getDbAdapterName(adapter: DatabaseAdapter): string {\n return DB_ADAPTER_CONFIG[adapter].adapterName\n}\n\n/**\n * Helper to get storage adapter package name\n */\nexport function getStoragePackageName(adapter: StorageAdapter): null | string {\n return STORAGE_ADAPTER_CONFIG[adapter].packageName\n}\n\n/**\n * Helper to get storage adapter name\n */\nexport function getStorageAdapterName(adapter: StorageAdapter): null | string {\n return STORAGE_ADAPTER_CONFIG[adapter].adapterName\n}\n"],"names":["DB_ADAPTER_CONFIG","adapterName","configTemplate","packageName","mongodb","envVar","postgres","sqlite","STORAGE_ADAPTER_CONFIG","azureStorage","gcsStorage","localDisk","r2Storage","s3Storage","vercelBlobStorage","getDbPackageName","adapter","getDbAdapterName","getStoragePackageName","getStorageAdapterName"],"mappings":"AAAA;;;CAGC,GAgBD;;CAEC,GACD,OAAO,MAAMA,oBAAoE;IAC/E,aAAa;QACXC,aAAa;QACbC,gBAAgB,IAAM,CAAC;;EAEzB,CAAC;QACCC,aAAa;IACf;IACAC,SAAS;QACPH,aAAa;QACbC,gBAAgB,CAACG,SAAmB,CAAC;mBACtB,EAAEA,OAAO;EAC1B,CAAC;QACCF,aAAa;IACf;IACAG,UAAU;QACRL,aAAa;QACbC,gBAAgB,CAACG,SAAmB,CAAC;;kCAEP,EAAEA,OAAO;;EAEzC,CAAC;QACCF,aAAa;IACf;IACAI,QAAQ;QACNN,aAAa;QACbC,gBAAgB,IAAM,CAAC;;;;EAIzB,CAAC;QACCC,aAAa;IACf;IACA,mBAAmB;QACjBF,aAAa;QACbC,gBAAgB,IAAM,CAAC;;;;EAIzB,CAAC;QACCC,aAAa;IACf;AACF,EAAU;AAEV;;CAEC,GACD,OAAO,MAAMK,yBAAuE;IAClFC,cAAc;QACZR,aAAa;QACbC,gBAAgB,IAAM,CAAC;;;;;;IAMvB,CAAC;QACDC,aAAa;IACf;IACAO,YAAY;QACVT,aAAa;QACbC,gBAAgB,IAAM,CAAC
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/ast/adapter-config.ts"],"sourcesContent":["/**\n * Centralized adapter configuration\n * Shared across all AST transformation and test files\n */\n\nimport type { DatabaseAdapter, StorageAdapter } from './types.js'\n\nexport type DatabaseAdapterConfig = {\n adapterName: string\n configTemplate: (envVar: string) => string\n packageName: string\n}\n\nexport type StorageAdapterConfig = {\n adapterName: null | string\n configTemplate: () => null | string\n packageName: null | string\n}\n\n/**\n * Database adapter configurations\n */\nexport const DB_ADAPTER_CONFIG: Record<DatabaseAdapter, DatabaseAdapterConfig> = {\n 'd1-sqlite': {\n adapterName: 'sqliteD1Adapter',\n configTemplate: () => `sqliteD1Adapter({\n binding: cloudflare.env.D1,\n})`,\n packageName: '@payloadcms/db-d1-sqlite',\n },\n mongodb: {\n adapterName: 'mongooseAdapter',\n configTemplate: (envVar: string) => `mongooseAdapter({\n url: process.env.${envVar} || '',\n})`,\n packageName: '@payloadcms/db-mongodb',\n },\n postgres: {\n adapterName: 'postgresAdapter',\n configTemplate: (envVar: string) => `postgresAdapter({\n pool: {\n connectionString: process.env.${envVar} || '',\n },\n})`,\n packageName: '@payloadcms/db-postgres',\n },\n sqlite: {\n adapterName: 'sqliteAdapter',\n configTemplate: () => `sqliteAdapter({\n client: {\n url: process.env.DATABASE_URL || '',\n },\n})`,\n packageName: '@payloadcms/db-sqlite',\n },\n 'vercel-postgres': {\n adapterName: 'vercelPostgresAdapter',\n configTemplate: () => `vercelPostgresAdapter({\n pool: {\n connectionString: process.env.POSTGRES_URL || '',\n },\n})`,\n packageName: '@payloadcms/db-vercel-postgres',\n },\n} as const\n\n/**\n * Storage adapter configurations\n */\nexport const STORAGE_ADAPTER_CONFIG: Record<StorageAdapter, StorageAdapterConfig> = {\n azureStorage: {\n adapterName: 'azureStorage',\n configTemplate: () => `azureStorage({\n collections: {\n media: true,\n },\n connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING || '',\n containerName: process.env.AZURE_STORAGE_CONTAINER_NAME || '',\n })`,\n packageName: '@payloadcms/storage-azure',\n },\n gcsStorage: {\n adapterName: 'gcsStorage',\n configTemplate: () => `gcsStorage({\n collections: {\n media: true,\n },\n bucket: process.env.GCS_BUCKET || '',\n options: {\n apiEndpoint: process.env.GCS_ENDPOINT,\n projectId: process.env.GCS_PROJECT_ID,\n },\n })`,\n packageName: '@payloadcms/storage-gcs',\n },\n localDisk: {\n adapterName: null,\n configTemplate: () => null,\n packageName: null,\n },\n r2Storage: {\n adapterName: 'r2Storage',\n configTemplate: () => `r2Storage({\n bucket: cloudflare.env.R2,\n collections: { media: true },\n })`,\n packageName: '@payloadcms/storage-r2',\n },\n s3Storage: {\n adapterName: 's3Storage',\n configTemplate: () => `s3Storage({\n collections: {\n media: true,\n },\n bucket: process.env.S3_BUCKET || '',\n config: {\n credentials: {\n accessKeyId: process.env.S3_ACCESS_KEY_ID || '',\n secretAccessKey: process.env.S3_SECRET_ACCESS_KEY || '',\n },\n region: process.env.S3_REGION || '',\n },\n })`,\n packageName: '@payloadcms/storage-s3',\n },\n vercelBlobStorage: {\n adapterName: 'vercelBlobStorage',\n configTemplate: () => `vercelBlobStorage({\n collections: {\n media: true,\n },\n token: process.env.BLOB_READ_WRITE_TOKEN || '',\n })`,\n packageName: '@payloadcms/storage-vercel-blob',\n },\n} as const\n\nexport const SHARP_TRANSFORMER_PACKAGE = '@payloadcms/transformer-sharp'\n\nexport const SHARP_TRANSFORMER_NAME = 'sharpTransformer'\n\n/**\n * Helper to get database adapter package name\n */\nexport function getDbPackageName(adapter: DatabaseAdapter): string {\n return DB_ADAPTER_CONFIG[adapter].packageName\n}\n\n/**\n * Helper to get database adapter name\n */\nexport function getDbAdapterName(adapter: DatabaseAdapter): string {\n return DB_ADAPTER_CONFIG[adapter].adapterName\n}\n\n/**\n * Helper to get storage adapter package name\n */\nexport function getStoragePackageName(adapter: StorageAdapter): null | string {\n return STORAGE_ADAPTER_CONFIG[adapter].packageName\n}\n\n/**\n * Helper to get storage adapter name\n */\nexport function getStorageAdapterName(adapter: StorageAdapter): null | string {\n return STORAGE_ADAPTER_CONFIG[adapter].adapterName\n}\n"],"names":["DB_ADAPTER_CONFIG","adapterName","configTemplate","packageName","mongodb","envVar","postgres","sqlite","STORAGE_ADAPTER_CONFIG","azureStorage","gcsStorage","localDisk","r2Storage","s3Storage","vercelBlobStorage","SHARP_TRANSFORMER_PACKAGE","SHARP_TRANSFORMER_NAME","getDbPackageName","adapter","getDbAdapterName","getStoragePackageName","getStorageAdapterName"],"mappings":"AAAA;;;CAGC,GAgBD;;CAEC,GACD,OAAO,MAAMA,oBAAoE;IAC/E,aAAa;QACXC,aAAa;QACbC,gBAAgB,IAAM,CAAC;;EAEzB,CAAC;QACCC,aAAa;IACf;IACAC,SAAS;QACPH,aAAa;QACbC,gBAAgB,CAACG,SAAmB,CAAC;mBACtB,EAAEA,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sBAAsB,CAACU,QAAQ,CAACf,WAAW;AACpD;AAEA;;CAEC,GACD,OAAO,SAASkB,sBAAsBH,OAAuB;IAC3D,OAAOV,sBAAsB,CAACU,QAAQ,CAACjB,WAAW;AACpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../../src/lib/ast/package-json.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../../src/lib/ast/package-json.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAUjE,KAAK,2BAA2B,GAAG;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,cAAc,CAAC,EAAE,cAAc,CAAA;CAChC,CAAA;AASD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,2BAA2B,GAAG,IAAI,CAO9F;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,2BAA2B,CAAA;CACrC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAQxC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import { debug } from '../../utils/log.js';
|
|
3
|
-
import { getDbPackageName, getStoragePackageName } from './adapter-config.js';
|
|
3
|
+
import { getDbPackageName, getStoragePackageName, SHARP_TRANSFORMER_PACKAGE } from './adapter-config.js';
|
|
4
4
|
import { ALL_DATABASE_ADAPTERS, ALL_STORAGE_ADAPTERS } from './types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Main orchestration function
|
|
@@ -89,11 +89,16 @@ function parsePackageJson(filePath) {
|
|
|
89
89
|
transformed.dependencies = {
|
|
90
90
|
...transformed.dependencies
|
|
91
91
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
for (const sharpPackage of [
|
|
93
|
+
'sharp',
|
|
94
|
+
SHARP_TRANSFORMER_PACKAGE
|
|
95
|
+
]){
|
|
96
|
+
if (transformed.dependencies[sharpPackage]) {
|
|
97
|
+
delete transformed.dependencies[sharpPackage];
|
|
98
|
+
debug(`[AST] Removed ${sharpPackage} dependency`);
|
|
99
|
+
} else {
|
|
100
|
+
debug(`[AST] ${sharpPackage} dependency not found (already absent)`);
|
|
101
|
+
}
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
if (options.addDependencies) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/ast/package-json.ts"],"sourcesContent":["import * as fs from 'fs'\n\nimport type { DatabaseAdapter, StorageAdapter } from './types.js'\n\nimport { debug } from '../../utils/log.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/ast/package-json.ts"],"sourcesContent":["import * as fs from 'fs'\n\nimport type { DatabaseAdapter, StorageAdapter } from './types.js'\n\nimport { debug } from '../../utils/log.js'\nimport {\n getDbPackageName,\n getStoragePackageName,\n SHARP_TRANSFORMER_PACKAGE,\n} from './adapter-config.js'\nimport { ALL_DATABASE_ADAPTERS, ALL_STORAGE_ADAPTERS } from './types.js'\n\ntype PackageJsonTransformOptions = {\n addDependencies?: Record<string, string>\n databaseAdapter?: DatabaseAdapter\n packageName?: string\n removeDependencies?: string[]\n removeSharp?: boolean\n storageAdapter?: StorageAdapter\n}\n\ntype PackageJsonStructure = {\n [key: string]: unknown\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n name?: string\n}\n\n/**\n * Main orchestration function\n */\nexport function updatePackageJson(filePath: string, options: PackageJsonTransformOptions): void {\n debug(`[AST] Updating package.json: ${filePath}`)\n\n const prepared = preparePackageJson({ filePath, options })\n fs.writeFileSync(prepared.filePath, prepared.content)\n\n debug('[AST] ✓ package.json updated successfully')\n}\n\nexport function preparePackageJson({\n filePath,\n options,\n}: {\n filePath: string\n options: PackageJsonTransformOptions\n}): { content: string; filePath: string } {\n const pkg = parsePackageJson(filePath)\n const transformed = transformPackageJson(pkg, options)\n\n return {\n content: `${JSON.stringify(transformed, null, 2)}\\n`,\n filePath,\n }\n}\n\n// Helper functions\n\nfunction parsePackageJson(filePath: string): PackageJsonStructure {\n const content = fs.readFileSync(filePath, 'utf-8')\n return JSON.parse(content)\n}\n\n/**\n * Transforms the package.json based upon provided options\n */\nfunction transformPackageJson(\n pkg: PackageJsonStructure,\n options: PackageJsonTransformOptions,\n): PackageJsonStructure {\n const transformed = { ...pkg }\n\n // Update database adapter\n if (options.databaseAdapter) {\n debug(`[AST] Updating package.json database adapter to: ${options.databaseAdapter}`)\n\n transformed.dependencies = { ...transformed.dependencies }\n\n const removedAdapters: string[] = []\n ALL_DATABASE_ADAPTERS.forEach((adapter) => {\n const pkgName = getDbPackageName(adapter)\n if (transformed.dependencies![pkgName]) {\n removedAdapters.push(pkgName)\n }\n delete transformed.dependencies![pkgName]\n })\n\n if (removedAdapters.length > 0) {\n debug(`[AST] Removed old adapter packages: ${removedAdapters.join(', ')}`)\n }\n\n // Add new adapter\n const dbAdapterPackageName = getDbPackageName(options.databaseAdapter)\n const payloadVersion = transformed.dependencies?.payload || '^3.0.0'\n transformed.dependencies[dbAdapterPackageName] = payloadVersion\n\n debug(`[AST] Added adapter package: ${dbAdapterPackageName}`)\n }\n\n // Update storage adapter\n if (options.storageAdapter) {\n debug(`[AST] Updating package.json storage adapter to: ${options.storageAdapter}`)\n\n transformed.dependencies = { ...transformed.dependencies }\n\n const removedAdapters: string[] = []\n ALL_STORAGE_ADAPTERS.forEach((adapter) => {\n const pkgName = getStoragePackageName(adapter)\n if (pkgName && transformed.dependencies![pkgName]) {\n removedAdapters.push(pkgName)\n }\n if (pkgName) {\n delete transformed.dependencies![pkgName]\n }\n })\n\n if (removedAdapters.length > 0) {\n debug(`[AST] Removed old storage adapter packages: ${removedAdapters.join(', ')}`)\n }\n\n // Add new storage adapter (if not localDisk)\n const storagePackageName = getStoragePackageName(options.storageAdapter)\n if (storagePackageName) {\n const payloadVersion = transformed.dependencies?.payload || '^3.0.0'\n transformed.dependencies[storagePackageName] = payloadVersion\n debug(`[AST] Added storage adapter package: ${storagePackageName}`)\n } else {\n debug(`[AST] Storage adapter is localDisk, no package needed`)\n }\n }\n\n // Remove sharp\n if (options.removeSharp && transformed.dependencies) {\n transformed.dependencies = { ...transformed.dependencies }\n for (const sharpPackage of ['sharp', SHARP_TRANSFORMER_PACKAGE]) {\n if (transformed.dependencies[sharpPackage]) {\n delete transformed.dependencies[sharpPackage]\n debug(`[AST] Removed ${sharpPackage} dependency`)\n } else {\n debug(`[AST] ${sharpPackage} dependency not found (already absent)`)\n }\n }\n }\n\n if (options.addDependencies) {\n transformed.dependencies = {\n ...transformed.dependencies,\n ...options.addDependencies,\n }\n }\n\n if (options.removeDependencies) {\n for (const dependencyGroup of ['dependencies', 'devDependencies'] as const) {\n if (!transformed[dependencyGroup]) {\n continue\n }\n\n transformed[dependencyGroup] = { ...transformed[dependencyGroup] }\n for (const packageName of options.removeDependencies) {\n delete transformed[dependencyGroup][packageName]\n }\n }\n }\n\n // Update package name\n if (options.packageName) {\n debug(`[AST] Updated package name to: ${options.packageName}`)\n transformed.name = options.packageName\n }\n\n return transformed\n}\n"],"names":["fs","debug","getDbPackageName","getStoragePackageName","SHARP_TRANSFORMER_PACKAGE","ALL_DATABASE_ADAPTERS","ALL_STORAGE_ADAPTERS","updatePackageJson","filePath","options","prepared","preparePackageJson","writeFileSync","content","pkg","parsePackageJson","transformed","transformPackageJson","JSON","stringify","readFileSync","parse","databaseAdapter","dependencies","removedAdapters","forEach","adapter","pkgName","push","length","join","dbAdapterPackageName","payloadVersion","payload","storageAdapter","storagePackageName","removeSharp","sharpPackage","addDependencies","removeDependencies","dependencyGroup","packageName","name"],"mappings":"AAAA,YAAYA,QAAQ,KAAI;AAIxB,SAASC,KAAK,QAAQ,qBAAoB;AAC1C,SACEC,gBAAgB,EAChBC,qBAAqB,EACrBC,yBAAyB,QACpB,sBAAqB;AAC5B,SAASC,qBAAqB,EAAEC,oBAAoB,QAAQ,aAAY;AAkBxE;;CAEC,GACD,OAAO,SAASC,kBAAkBC,QAAgB,EAAEC,OAAoC;IACtFR,MAAM,CAAC,6BAA6B,EAAEO,UAAU;IAEhD,MAAME,WAAWC,mBAAmB;QAAEH;QAAUC;IAAQ;IACxDT,GAAGY,aAAa,CAACF,SAASF,QAAQ,EAAEE,SAASG,OAAO;IAEpDZ,MAAM;AACR;AAEA,OAAO,SAASU,mBAAmB,EACjCH,QAAQ,EACRC,OAAO,EAIR;IACC,MAAMK,MAAMC,iBAAiBP;IAC7B,MAAMQ,cAAcC,qBAAqBH,KAAKL;IAE9C,OAAO;QACLI,SAAS,GAAGK,KAAKC,SAAS,CAACH,aAAa,MAAM,GAAG,EAAE,CAAC;QACpDR;IACF;AACF;AAEA,mBAAmB;AAEnB,SAASO,iBAAiBP,QAAgB;IACxC,MAAMK,UAAUb,GAAGoB,YAAY,CAACZ,UAAU;IAC1C,OAAOU,KAAKG,KAAK,CAACR;AACpB;AAEA;;CAEC,GACD,SAASI,qBACPH,GAAyB,EACzBL,OAAoC;IAEpC,MAAMO,cAAc;QAAE,GAAGF,GAAG;IAAC;IAE7B,0BAA0B;IAC1B,IAAIL,QAAQa,eAAe,EAAE;QAC3BrB,MAAM,CAAC,iDAAiD,EAAEQ,QAAQa,eAAe,EAAE;QAEnFN,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Y0B,IAAI,GAAGjC,QAAQgC,WAAW;IACxC;IAEA,OAAOzB;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload-config.d.ts","sourceRoot":"","sources":["../../../src/lib/ast/payload-config.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"payload-config.d.ts","sourceRoot":"","sources":["../../../src/lib/ast/payload-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EAEf,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,WAAW,EACZ,MAAM,YAAY,CAAA;AAgBnB,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,UAAU,GAAG,eAAe,CA4JpF;AAED,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,UAA2B,EAC3B,UAAU,GACX,EAAE;IACD,OAAO,EAAE,eAAe,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,UAAU,CAAA;CACvB,GAAG,oBAAoB,CA+HvB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,UAAU,GACX,EAAE;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,EAAE,UAAU,CAAA;CACvB,GAAG,oBAAoB,CA6JvB;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,GAAG,oBAAoB,CA4ExE;AAED,gGAAgG;AAChG,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAoBvE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,WAAW,CA+BrE;AAED,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,CAsDtB;AAED,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,WAAW,CAAC,CAyItB"}
|
|
@@ -2,7 +2,7 @@ import { execSync } from 'child_process';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { Project, QuoteKind, SyntaxKind } from 'ts-morph';
|
|
4
4
|
import { debug } from '../../utils/log.js';
|
|
5
|
-
import { DB_ADAPTER_CONFIG, STORAGE_ADAPTER_CONFIG } from './adapter-config.js';
|
|
5
|
+
import { DB_ADAPTER_CONFIG, SHARP_TRANSFORMER_NAME, SHARP_TRANSFORMER_PACKAGE, STORAGE_ADAPTER_CONFIG } from './adapter-config.js';
|
|
6
6
|
import { addImportDeclaration, cleanupOrphanedImports, formatError, removeImportDeclaration } from './utils.js';
|
|
7
7
|
export function detectPayloadConfigStructure(sourceFile) {
|
|
8
8
|
debug(`[AST] Detecting payload config structure in ${sourceFile.getFilePath()}`);
|
|
@@ -248,9 +248,9 @@ export function addStorageAdapter({ adapter, sourceFile }) {
|
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
250
|
const config = STORAGE_ADAPTER_CONFIG[adapter];
|
|
251
|
-
// Local disk doesn't need any imports or
|
|
251
|
+
// Local disk doesn't need any imports or storage adapters
|
|
252
252
|
if (adapter === 'localDisk') {
|
|
253
|
-
debug('[AST] localDisk storage adapter - no imports or
|
|
253
|
+
debug('[AST] localDisk storage adapter - no imports or storage adapters needed');
|
|
254
254
|
return {
|
|
255
255
|
modifications: [],
|
|
256
256
|
modified: false,
|
|
@@ -287,80 +287,83 @@ export function addStorageAdapter({ adapter, sourceFile }) {
|
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
289
|
const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);
|
|
290
|
-
// Find or create
|
|
291
|
-
const
|
|
292
|
-
let
|
|
293
|
-
// Check if it's a shorthand property (e.g., `
|
|
294
|
-
const shorthandProperty =
|
|
290
|
+
// Find or create storage array
|
|
291
|
+
const storagePropertyRaw = objLiteral.getProperty('storage');
|
|
292
|
+
let storageProperty = storagePropertyRaw?.asKind(SyntaxKind.PropertyAssignment);
|
|
293
|
+
// Check if it's a shorthand property (e.g., `storage` referencing an imported variable)
|
|
294
|
+
const shorthandProperty = storagePropertyRaw?.asKind(SyntaxKind.ShorthandPropertyAssignment);
|
|
295
295
|
if (shorthandProperty) {
|
|
296
|
-
debug('[AST] Found shorthand
|
|
297
|
-
// Get the identifier name (usually '
|
|
296
|
+
debug('[AST] Found shorthand storage property, converting to long form with spread');
|
|
297
|
+
// Get the identifier name (usually 'storage')
|
|
298
298
|
const identifierName = shorthandProperty.getName();
|
|
299
299
|
// Find insert position before removing
|
|
300
300
|
const allProperties = objLiteral.getProperties();
|
|
301
301
|
const insertIndex = allProperties.indexOf(shorthandProperty);
|
|
302
302
|
// Remove the shorthand property
|
|
303
303
|
shorthandProperty.remove();
|
|
304
|
-
// Create new property with spread operator:
|
|
304
|
+
// Create new property with spread operator: storage: [...storage, newAdapter]
|
|
305
305
|
objLiteral.insertPropertyAssignment(insertIndex, {
|
|
306
|
-
name: '
|
|
306
|
+
name: 'storage',
|
|
307
307
|
initializer: `[...${identifierName}]`
|
|
308
308
|
});
|
|
309
|
-
|
|
309
|
+
storageProperty = objLiteral.getProperty('storage')?.asKind(SyntaxKind.PropertyAssignment);
|
|
310
310
|
modifications.push({
|
|
311
311
|
type: 'property-added',
|
|
312
|
-
description: `Converted shorthand
|
|
312
|
+
description: `Converted shorthand storage property to array with spread syntax`
|
|
313
313
|
});
|
|
314
|
-
} else if (!
|
|
315
|
-
debug('[AST] Creating new
|
|
316
|
-
//
|
|
317
|
-
objLiteral.
|
|
318
|
-
|
|
314
|
+
} else if (!storageProperty) {
|
|
315
|
+
debug('[AST] Creating new storage array');
|
|
316
|
+
// Insert after the last property, not after trailing comments, which would produce `},,`
|
|
317
|
+
const propertiesWithComments = objLiteral.getPropertiesWithComments();
|
|
318
|
+
const lastProperty = objLiteral.getProperties().at(-1);
|
|
319
|
+
const insertIndex = lastProperty ? propertiesWithComments.indexOf(lastProperty) + 1 : 0;
|
|
320
|
+
objLiteral.insertPropertyAssignment(insertIndex, {
|
|
321
|
+
name: 'storage',
|
|
319
322
|
initializer: '[]'
|
|
320
323
|
});
|
|
321
|
-
|
|
324
|
+
storageProperty = objLiteral.getProperty('storage')?.asKind(SyntaxKind.PropertyAssignment);
|
|
322
325
|
modifications.push({
|
|
323
326
|
type: 'property-added',
|
|
324
|
-
description: `Created
|
|
327
|
+
description: `Created storage array`
|
|
325
328
|
});
|
|
326
329
|
} else {
|
|
327
|
-
debug('[AST] Reusing existing
|
|
330
|
+
debug('[AST] Reusing existing storage array');
|
|
328
331
|
}
|
|
329
|
-
if (!
|
|
332
|
+
if (!storageProperty) {
|
|
330
333
|
return {
|
|
331
334
|
error: formatError({
|
|
332
|
-
actual: 'Failed to create or find
|
|
335
|
+
actual: 'Failed to create or find storage property',
|
|
333
336
|
context: 'storage adapter configuration',
|
|
334
|
-
expected: '
|
|
335
|
-
technicalDetails: 'Could not create or access
|
|
337
|
+
expected: 'storage array property',
|
|
338
|
+
technicalDetails: 'Could not create or access storage property'
|
|
336
339
|
}),
|
|
337
340
|
modifications: [],
|
|
338
341
|
modified: false,
|
|
339
342
|
success: false
|
|
340
343
|
};
|
|
341
344
|
}
|
|
342
|
-
const initializer =
|
|
345
|
+
const initializer = storageProperty.getInitializer();
|
|
343
346
|
if (!initializer || initializer.getKind() !== SyntaxKind.ArrayLiteralExpression) {
|
|
344
347
|
return {
|
|
345
348
|
error: formatError({
|
|
346
|
-
actual: '
|
|
349
|
+
actual: 'storage property is not an array',
|
|
347
350
|
context: 'storage adapter configuration',
|
|
348
|
-
expected: '
|
|
349
|
-
technicalDetails: '
|
|
351
|
+
expected: 'storage: [...]',
|
|
352
|
+
technicalDetails: 'storage property must be an array literal expression'
|
|
350
353
|
}),
|
|
351
354
|
modifications: [],
|
|
352
355
|
modified: false,
|
|
353
356
|
success: false
|
|
354
357
|
};
|
|
355
358
|
}
|
|
356
|
-
const
|
|
359
|
+
const storageArray = initializer.asKindOrThrow(SyntaxKind.ArrayLiteralExpression);
|
|
357
360
|
// Add storage adapter call
|
|
358
361
|
const configText = config.configTemplate();
|
|
359
362
|
if (configText) {
|
|
360
|
-
|
|
363
|
+
storageArray.addElement(configText);
|
|
361
364
|
modifications.push({
|
|
362
365
|
type: 'property-added',
|
|
363
|
-
description: `Added ${adapter} to
|
|
366
|
+
description: `Added ${adapter} to storage array`
|
|
364
367
|
});
|
|
365
368
|
}
|
|
366
369
|
debug(`[AST] ✓ Storage adapter ${adapter} added successfully`);
|
|
@@ -373,16 +376,21 @@ export function addStorageAdapter({ adapter, sourceFile }) {
|
|
|
373
376
|
export function removeSharp(sourceFile) {
|
|
374
377
|
debug('[AST] Removing sharp import and property');
|
|
375
378
|
const modifications = [];
|
|
376
|
-
// Remove
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
description: `Removed import from 'sharp'`
|
|
379
|
+
// Remove imports
|
|
380
|
+
for (const moduleSpecifier of [
|
|
381
|
+
'sharp',
|
|
382
|
+
SHARP_TRANSFORMER_PACKAGE
|
|
383
|
+
]){
|
|
384
|
+
const { removedIndex } = removeImportDeclaration({
|
|
385
|
+
moduleSpecifier,
|
|
386
|
+
sourceFile
|
|
385
387
|
});
|
|
388
|
+
if (removedIndex !== undefined) {
|
|
389
|
+
modifications.push({
|
|
390
|
+
type: 'import-removed',
|
|
391
|
+
description: `Removed import from '${moduleSpecifier}'`
|
|
392
|
+
});
|
|
393
|
+
}
|
|
386
394
|
}
|
|
387
395
|
// Find and remove sharp property from buildConfig
|
|
388
396
|
const detection = detectPayloadConfigStructure(sourceFile);
|
|
@@ -429,6 +437,15 @@ export function removeSharp(sourceFile) {
|
|
|
429
437
|
} else {
|
|
430
438
|
debug('[AST] Sharp property not found (already absent)');
|
|
431
439
|
}
|
|
440
|
+
if (removeSharpTransformer({
|
|
441
|
+
objLiteral
|
|
442
|
+
})) {
|
|
443
|
+
modifications.push({
|
|
444
|
+
type: 'property-removed',
|
|
445
|
+
description: `Removed ${SHARP_TRANSFORMER_NAME} from upload transformers`
|
|
446
|
+
});
|
|
447
|
+
debug(`[AST] ✓ ${SHARP_TRANSFORMER_NAME} removed from upload transformers`);
|
|
448
|
+
}
|
|
432
449
|
return {
|
|
433
450
|
modifications,
|
|
434
451
|
modified: modifications.length > 0,
|
|
@@ -484,7 +501,7 @@ export function removeSharp(sourceFile) {
|
|
|
484
501
|
};
|
|
485
502
|
}
|
|
486
503
|
export async function writeTransformedFile(sourceFile, options = {}) {
|
|
487
|
-
const {
|
|
504
|
+
const { formatWithOxfmt = true, validateStructure: shouldValidate = true } = options;
|
|
488
505
|
debug(`[AST] Writing transformed file: ${sourceFile.getFilePath()}`);
|
|
489
506
|
// Validate if requested
|
|
490
507
|
if (shouldValidate) {
|
|
@@ -501,27 +518,27 @@ export async function writeTransformedFile(sourceFile, options = {}) {
|
|
|
501
518
|
// Write file
|
|
502
519
|
debug('[AST] Writing file to disk');
|
|
503
520
|
await sourceFile.save();
|
|
504
|
-
// Format with
|
|
505
|
-
if (
|
|
506
|
-
debug('[AST] Running
|
|
521
|
+
// Format with oxfmt if requested
|
|
522
|
+
if (formatWithOxfmt) {
|
|
523
|
+
debug('[AST] Running oxfmt formatting via CLI');
|
|
507
524
|
try {
|
|
508
525
|
// Detect project directory (go up from file until we find package.json or use dirname)
|
|
509
526
|
const projectDir = path.dirname(filePath);
|
|
510
|
-
// Run
|
|
511
|
-
const
|
|
512
|
-
debug(`[AST] Executing: ${
|
|
513
|
-
execSync(
|
|
527
|
+
// Run oxfmt via CLI (avoids Jest/ESM compatibility issues)
|
|
528
|
+
const oxfmtCmd = `npx oxfmt "${filePath}"`;
|
|
529
|
+
debug(`[AST] Executing: ${oxfmtCmd}`);
|
|
530
|
+
execSync(oxfmtCmd, {
|
|
514
531
|
cwd: projectDir,
|
|
515
532
|
stdio: 'pipe'
|
|
516
533
|
});
|
|
517
|
-
debug('[AST] ✓
|
|
534
|
+
debug('[AST] ✓ Oxfmt formatting successful');
|
|
518
535
|
} catch (error) {
|
|
519
|
-
// Log but don't fail if
|
|
520
|
-
debug(`[AST] ⚠
|
|
536
|
+
// Log but don't fail if oxfmt fails (might not be installed)
|
|
537
|
+
debug(`[AST] ⚠ Oxfmt formatting failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
521
538
|
debug('[AST] Continuing with unformatted output');
|
|
522
539
|
}
|
|
523
540
|
} else {
|
|
524
|
-
debug('[AST] Skipping
|
|
541
|
+
debug('[AST] Skipping oxfmt formatting (disabled)');
|
|
525
542
|
}
|
|
526
543
|
debug('[AST] ✓ File written successfully');
|
|
527
544
|
return {
|
|
@@ -635,7 +652,7 @@ export async function configurePayloadConfig(filePath, options = {}) {
|
|
|
635
652
|
}
|
|
636
653
|
// Write transformed file with validation and formatting
|
|
637
654
|
return await writeTransformedFile(sourceFile, {
|
|
638
|
-
|
|
655
|
+
formatWithOxfmt: options.formatWithOxfmt,
|
|
639
656
|
validateStructure: options.validateStructure ?? true
|
|
640
657
|
});
|
|
641
658
|
} catch (error) {
|
|
@@ -651,5 +668,34 @@ export async function configurePayloadConfig(filePath, options = {}) {
|
|
|
651
668
|
};
|
|
652
669
|
}
|
|
653
670
|
}
|
|
671
|
+
/**
|
|
672
|
+
* Removes `sharpTransformer()` from `upload.transformers`, then removes `transformers`
|
|
673
|
+
* and `upload` if they become empty. Returns true if anything was removed.
|
|
674
|
+
*/ function removeSharpTransformer({ objLiteral }) {
|
|
675
|
+
const uploadProperty = objLiteral.getProperty('upload')?.asKind(SyntaxKind.PropertyAssignment);
|
|
676
|
+
const uploadObject = uploadProperty?.getInitializerIfKind(SyntaxKind.ObjectLiteralExpression);
|
|
677
|
+
const transformersProperty = uploadObject?.getProperty('transformers')?.asKind(SyntaxKind.PropertyAssignment);
|
|
678
|
+
const transformersArray = transformersProperty?.getInitializerIfKind(SyntaxKind.ArrayLiteralExpression);
|
|
679
|
+
if (!uploadProperty || !uploadObject || !transformersProperty || !transformersArray) {
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
682
|
+
const sharpTransformerIndexes = transformersArray.getElements().flatMap((element, index)=>element.asKind(SyntaxKind.CallExpression)?.getExpression().getText() === SHARP_TRANSFORMER_NAME ? [
|
|
683
|
+
index
|
|
684
|
+
] : []);
|
|
685
|
+
if (sharpTransformerIndexes.length === 0) {
|
|
686
|
+
return false;
|
|
687
|
+
}
|
|
688
|
+
// Remove from the end so earlier indexes stay valid
|
|
689
|
+
for (const index of sharpTransformerIndexes.reverse()){
|
|
690
|
+
transformersArray.removeElement(index);
|
|
691
|
+
}
|
|
692
|
+
if (transformersArray.getElements().length === 0) {
|
|
693
|
+
transformersProperty.remove();
|
|
694
|
+
}
|
|
695
|
+
if (uploadObject.getProperties().length === 0) {
|
|
696
|
+
uploadProperty.remove();
|
|
697
|
+
}
|
|
698
|
+
return true;
|
|
699
|
+
}
|
|
654
700
|
|
|
655
701
|
//# sourceMappingURL=payload-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/ast/payload-config.ts"],"sourcesContent":["import { execSync } from 'child_process'\nimport path from 'path'\nimport { Project, QuoteKind, type SourceFile, SyntaxKind } from 'ts-morph'\n\nimport type {\n ConfigureOptions,\n DatabaseAdapter,\n DetectionResult,\n Modification,\n StorageAdapter,\n TransformationResult,\n WriteOptions,\n WriteResult,\n} from './types.js'\n\nimport { debug } from '../../utils/log.js'\nimport { DB_ADAPTER_CONFIG, STORAGE_ADAPTER_CONFIG } from './adapter-config.js'\nimport {\n addImportDeclaration,\n cleanupOrphanedImports,\n formatError,\n removeImportDeclaration,\n} from './utils.js'\n\nexport function detectPayloadConfigStructure(sourceFile: SourceFile): DetectionResult {\n debug(`[AST] Detecting payload config structure in ${sourceFile.getFilePath()}`)\n\n // First find the actual name being used (might be aliased)\n const payloadImport = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === 'payload')\n\n const buildConfigImportSpec = payloadImport\n ?.getNamedImports()\n .find((spec) => spec.getName() === 'buildConfig')\n\n const aliasNode = buildConfigImportSpec?.getAliasNode()\n const buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig'\n\n debug(`[AST] Looking for function call: ${buildConfigName}`)\n\n // Find buildConfig call expression (using actual name in code)\n const buildConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((call) => {\n const expression = call.getExpression()\n return expression.getText() === buildConfigName\n })\n\n if (!buildConfigCall) {\n debug(`[AST] ✗ ${buildConfigName} call not found`)\n return {\n error: formatError({\n actual: `No ${buildConfigName} call found in file`,\n context: 'buildConfig call',\n expected: `export default ${buildConfigName}({ ... })`,\n technicalDetails: `Could not find CallExpression with identifier \"${buildConfigName}\"`,\n }),\n success: false,\n }\n }\n\n debug(`[AST] ✓ ${buildConfigName} call found`)\n\n // Get import statements\n const importStatements = sourceFile.getImportDeclarations()\n debug(`[AST] Found ${importStatements.length} import statements`)\n\n // Find db property if it exists\n const configObject = buildConfigCall.getArguments()[0]\n let dbProperty\n if (configObject && configObject.getKind() === SyntaxKind.ObjectLiteralExpression) {\n dbProperty = configObject\n .asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n .getProperty('db')\n ?.asKind(SyntaxKind.PropertyAssignment)\n }\n\n debug(`[AST] db property: ${dbProperty ? '✓ found' : '✗ not found'}`)\n\n // Find plugins array if it exists\n let pluginsArray\n if (configObject && configObject.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n const pluginsProperty = objLiteral.getProperty('plugins')\n\n // Handle PropertyAssignment (e.g., plugins: [...])\n const propertyAssignment = pluginsProperty?.asKind(SyntaxKind.PropertyAssignment)\n if (propertyAssignment) {\n const initializer = propertyAssignment.getInitializer()\n if (initializer?.getKind() === SyntaxKind.ArrayLiteralExpression) {\n pluginsArray = initializer.asKind(SyntaxKind.ArrayLiteralExpression)\n }\n }\n // For ShorthandPropertyAssignment (e.g., plugins), we can't get the array directly\n // but we'll detect it in addStorageAdapter\n }\n\n debug(`[AST] plugins array: ${pluginsArray ? '✓ found' : '✗ not found'}`)\n\n // Find all buildConfig calls for edge case detection (using actual name)\n const allBuildConfigCalls = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((call) => {\n const expression = call.getExpression()\n return expression.getText() === buildConfigName\n })\n\n const hasImportAlias = !!aliasNode\n\n // Check for other Payload imports\n const payloadImports = payloadImport?.getNamedImports() || []\n const hasOtherPayloadImports =\n payloadImports.length > 1 || payloadImports.some((imp) => imp.getName() !== 'buildConfig')\n\n // Track database adapter imports\n let dbAdapterImportInfo\n for (const [, config] of Object.entries(DB_ADAPTER_CONFIG)) {\n const importDecl = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === config.packageName)\n\n if (importDecl) {\n const namedImports = importDecl.getNamedImports()\n dbAdapterImportInfo = {\n hasOtherImports: namedImports.length > 1,\n importDeclaration: importDecl,\n packageName: config.packageName,\n }\n break\n }\n }\n\n // Track storage adapter imports\n const storageAdapterImports = []\n for (const [, config] of Object.entries(STORAGE_ADAPTER_CONFIG)) {\n if (!config.packageName || !config.adapterName) {\n continue\n }\n\n const importDecl = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === config.packageName)\n\n if (importDecl) {\n const namedImports = importDecl.getNamedImports()\n storageAdapterImports.push({\n hasOtherImports: namedImports.length > 1,\n importDeclaration: importDecl,\n packageName: config.packageName,\n })\n }\n }\n\n const needsManualIntervention = hasImportAlias || allBuildConfigCalls.length > 2\n\n debug(\n `[AST] Edge cases: alias=${hasImportAlias}, multiple=${allBuildConfigCalls.length > 1}, otherImports=${hasOtherPayloadImports}, manual=${needsManualIntervention}`,\n )\n\n return {\n edgeCases: {\n hasImportAlias,\n hasOtherPayloadImports,\n multipleBuildConfigCalls: allBuildConfigCalls.length > 1,\n needsManualIntervention,\n },\n importSources: {\n dbAdapter: dbAdapterImportInfo,\n storage: storageAdapterImports.length > 0 ? storageAdapterImports : undefined,\n },\n sourceFile,\n structures: {\n buildConfigCall,\n dbProperty,\n importStatements,\n pluginsArray,\n },\n success: true,\n }\n}\n\nexport function addDatabaseAdapter({\n adapter,\n envVarName = 'DATABASE_URL',\n sourceFile,\n}: {\n adapter: DatabaseAdapter\n envVarName?: string\n sourceFile: SourceFile\n}): TransformationResult {\n debug(`[AST] Adding database adapter: ${adapter} (envVar: ${envVarName})`)\n\n const modifications: Modification[] = []\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const { buildConfigCall, dbProperty } = detection.structures\n const config = DB_ADAPTER_CONFIG[adapter]\n\n // Remove old db adapter imports and track position for replacement\n const oldAdapters = Object.values(DB_ADAPTER_CONFIG)\n const removedAdapters: string[] = []\n let importInsertIndex: number | undefined\n oldAdapters.forEach((oldConfig) => {\n if (oldConfig.packageName !== config.packageName) {\n const { removedIndex } = removeImportDeclaration({\n moduleSpecifier: oldConfig.packageName,\n sourceFile,\n })\n if (removedIndex !== undefined) {\n // Use the first removed adapter's position\n if (importInsertIndex === undefined) {\n importInsertIndex = removedIndex\n }\n removedAdapters.push(oldConfig.packageName)\n modifications.push({\n type: 'import-removed',\n description: `Removed import from '${oldConfig.packageName}'`,\n })\n }\n }\n })\n\n if (removedAdapters.length > 0) {\n debug(`[AST] Removed old adapter imports: ${removedAdapters.join(', ')}`)\n }\n\n // Add new import at the position of the removed one (or default position)\n addImportDeclaration({\n insertIndex: importInsertIndex,\n moduleSpecifier: config.packageName,\n namedImports: [config.adapterName],\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: { ${config.adapterName} } from '${config.packageName}'`,\n })\n\n // Add special imports for specific adapters\n if (adapter === 'd1-sqlite') {\n debug('[AST] Adding special import: ./db/migrations')\n addImportDeclaration({\n defaultImport: 'migrations',\n moduleSpecifier: './db/migrations',\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: migrations from './db/migrations'`,\n })\n }\n\n // Get config object\n const configObject = buildConfigCall.getArguments()[0]\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n error: formatError({\n actual: 'buildConfig has no object literal argument',\n context: 'database adapter configuration',\n expected: 'buildConfig({ ... })',\n technicalDetails: 'buildConfig call must have an object literal as first argument',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n\n const newDbCode = `db: ${config.configTemplate(envVarName)}`\n\n if (dbProperty) {\n // Replace existing db property\n // NOTE: Using replaceWithText() instead of remove() + insertPropertyAssignment()\n // to avoid double comma issues. When remove() is called, ts-morph doesn't always\n // clean up trailing commas correctly, which can result in syntax like \"},,\" when\n // inserting a new property at that position. replaceWithText() preserves the\n // surrounding punctuation correctly.\n debug(`[AST] Replacing existing db property`)\n dbProperty.replaceWithText(newDbCode)\n modifications.push({\n type: 'property-added',\n description: `Replaced db property with ${adapter} adapter`,\n })\n } else {\n // No existing db property - insert at end\n const insertIndex = objLiteral.getProperties().length\n debug(`[AST] Adding db property at index ${insertIndex}`)\n objLiteral.insertPropertyAssignment(insertIndex, {\n name: 'db',\n initializer: config.configTemplate(envVarName),\n })\n modifications.push({\n type: 'property-added',\n description: `Added db property with ${adapter} adapter`,\n })\n }\n\n debug(`[AST] ✓ Database adapter ${adapter} added successfully`)\n\n return {\n modifications,\n modified: true,\n success: true,\n }\n}\n\nexport function addStorageAdapter({\n adapter,\n sourceFile,\n}: {\n adapter: StorageAdapter\n sourceFile: SourceFile\n}): TransformationResult {\n debug(`[AST] Adding storage adapter: ${adapter}`)\n\n const modifications: Modification[] = []\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const config = STORAGE_ADAPTER_CONFIG[adapter]\n\n // Local disk doesn't need any imports or plugins\n if (adapter === 'localDisk') {\n debug('[AST] localDisk storage adapter - no imports or plugins needed')\n return {\n modifications: [],\n modified: false,\n success: true,\n }\n }\n\n // Add import\n if (config.packageName && config.adapterName) {\n addImportDeclaration({\n moduleSpecifier: config.packageName,\n namedImports: [config.adapterName],\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: { ${config.adapterName} } from '${config.packageName}'`,\n })\n }\n\n const { buildConfigCall } = detection.structures\n const configObject = buildConfigCall.getArguments()[0]\n\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n error: formatError({\n actual: 'buildConfig has no object literal argument',\n context: 'storage adapter configuration',\n expected: 'buildConfig({ ... })',\n technicalDetails: 'buildConfig call must have an object literal as first argument',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n\n // Find or create plugins array\n const pluginsPropertyRaw = objLiteral.getProperty('plugins')\n let pluginsProperty = pluginsPropertyRaw?.asKind(SyntaxKind.PropertyAssignment)\n\n // Check if it's a shorthand property (e.g., `plugins` referencing an imported variable)\n const shorthandProperty = pluginsPropertyRaw?.asKind(SyntaxKind.ShorthandPropertyAssignment)\n\n if (shorthandProperty) {\n debug('[AST] Found shorthand plugins property, converting to long form with spread')\n // Get the identifier name (usually 'plugins')\n const identifierName = shorthandProperty.getName()\n\n // Find insert position before removing\n const allProperties = objLiteral.getProperties()\n const insertIndex = allProperties.indexOf(shorthandProperty)\n\n // Remove the shorthand property\n shorthandProperty.remove()\n\n // Create new property with spread operator: plugins: [...plugins, newAdapter]\n objLiteral.insertPropertyAssignment(insertIndex, {\n name: 'plugins',\n initializer: `[...${identifierName}]`,\n })\n\n pluginsProperty = objLiteral.getProperty('plugins')?.asKind(SyntaxKind.PropertyAssignment)\n modifications.push({\n type: 'property-added',\n description: `Converted shorthand plugins property to array with spread syntax`,\n })\n } else if (!pluginsProperty) {\n debug('[AST] Creating new plugins array')\n // Create plugins array\n objLiteral.addPropertyAssignment({\n name: 'plugins',\n initializer: '[]',\n })\n pluginsProperty = objLiteral.getProperty('plugins')?.asKind(SyntaxKind.PropertyAssignment)\n modifications.push({\n type: 'property-added',\n description: `Created plugins array`,\n })\n } else {\n debug('[AST] Reusing existing plugins array')\n }\n\n if (!pluginsProperty) {\n return {\n error: formatError({\n actual: 'Failed to create or find plugins property',\n context: 'storage adapter configuration',\n expected: 'plugins array property',\n technicalDetails: 'Could not create or access plugins property',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const initializer = pluginsProperty.getInitializer()\n if (!initializer || initializer.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n return {\n error: formatError({\n actual: 'plugins property is not an array',\n context: 'storage adapter configuration',\n expected: 'plugins: [...]',\n technicalDetails: 'plugins property must be an array literal expression',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const pluginsArray = initializer.asKindOrThrow(SyntaxKind.ArrayLiteralExpression)\n\n // Add storage adapter call\n const configText = config.configTemplate()\n if (configText) {\n pluginsArray.addElement(configText)\n modifications.push({\n type: 'property-added',\n description: `Added ${adapter} to plugins array`,\n })\n }\n\n debug(`[AST] ✓ Storage adapter ${adapter} added successfully`)\n\n return {\n modifications,\n modified: true,\n success: true,\n }\n}\n\nexport function removeSharp(sourceFile: SourceFile): TransformationResult {\n debug('[AST] Removing sharp import and property')\n\n const modifications: Modification[] = []\n\n // Remove import\n const { removedIndex } = removeImportDeclaration({ moduleSpecifier: 'sharp', sourceFile })\n if (removedIndex !== undefined) {\n modifications.push({\n type: 'import-removed',\n description: `Removed import from 'sharp'`,\n })\n }\n\n // Find and remove sharp property from buildConfig\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n // If detection failed but we removed import, still count as partial success\n if (modifications.length > 0) {\n return {\n modifications,\n modified: true,\n success: true,\n warnings: ['Could not detect config structure to remove sharp property'],\n }\n }\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const { buildConfigCall } = detection.structures\n const configObject = buildConfigCall.getArguments()[0]\n\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n modifications,\n modified: modifications.length > 0,\n success: true,\n warnings: ['buildConfig has no object literal argument - could not remove sharp property'],\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n const sharpProperty = objLiteral.getProperty('sharp')\n\n if (sharpProperty) {\n sharpProperty.remove()\n modifications.push({\n type: 'property-removed',\n description: `Removed sharp property from config`,\n })\n debug('[AST] ✓ Sharp property removed from config')\n } else {\n debug('[AST] Sharp property not found (already absent)')\n }\n\n return {\n modifications,\n modified: modifications.length > 0,\n success: true,\n }\n}\n\n/** This shouldn't be necessary once the templates are updated. Can't hurt to keep in, though */\nexport function removeCommentMarkers(sourceFile: SourceFile): SourceFile {\n // Get the full text and replace comment markers\n let text = sourceFile.getFullText()\n\n // Remove inline comment markers from imports\n text = text.replace(/\\s*\\/\\/\\s*database-adapter-import\\s*$/gm, '')\n text = text.replace(/\\s*\\/\\/\\s*storage-adapter-import-placeholder\\s*$/gm, '')\n\n // Remove standalone comment lines\n text = text.replace(/^\\s*\\/\\/\\s*database-adapter-config-start\\s*\\n/gm, '')\n text = text.replace(/^\\s*\\/\\/\\s*database-adapter-config-end\\s*\\n/gm, '')\n text = text.replace(/^\\s*\\/\\/\\s*storage-adapter-placeholder\\s*\\n/gm, '')\n\n // Also remove the placeholder line from template (storage-adapter-import-placeholder at top)\n text = text.replace(/^\\/\\/\\s*storage-adapter-import-placeholder\\s*\\n/gm, '')\n\n // Replace the entire source file content\n sourceFile.replaceWithText(text)\n\n return sourceFile\n}\n\n/**\n * Validates payload config structure has required elements after transformation.\n * Checks that buildConfig() call exists and has a db property configured.\n */\nexport function validateStructure(sourceFile: SourceFile): WriteResult {\n debug('[AST] Validating payload config structure')\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success) {\n debug('[AST] ✗ Validation failed: detection unsuccessful')\n return {\n error: detection.error,\n success: false,\n }\n }\n\n const { structures } = detection\n\n // Validate db property exists\n if (!structures?.dbProperty) {\n debug('[AST] ✗ Validation failed: db property missing')\n return {\n error: formatError({\n actual: 'No db property found',\n context: 'database configuration',\n expected: 'buildConfig must have a db property',\n technicalDetails: 'PropertyAssignment with name \"db\" not found in buildConfig object',\n }),\n success: false,\n }\n }\n\n debug('[AST] ✓ Validation passed')\n return { success: true }\n}\n\nexport async function writeTransformedFile(\n sourceFile: SourceFile,\n options: WriteOptions = {},\n): Promise<WriteResult> {\n const { formatWithPrettier = true, validateStructure: shouldValidate = true } = options\n\n debug(`[AST] Writing transformed file: ${sourceFile.getFilePath()}`)\n\n // Validate if requested\n if (shouldValidate) {\n const validation = validateStructure(sourceFile)\n if (!validation.success) {\n return validation\n }\n }\n\n // Get file path and save to disk\n const filePath = sourceFile.getFilePath()\n\n // Format with ts-morph before saving (fixes trailing commas, indentation)\n debug('[AST] Formatting with ts-morph')\n sourceFile.formatText()\n\n // Write file\n debug('[AST] Writing file to disk')\n await sourceFile.save()\n\n // Format with prettier if requested\n if (formatWithPrettier) {\n debug('[AST] Running prettier formatting via CLI')\n try {\n // Detect project directory (go up from file until we find package.json or use dirname)\n const projectDir = path.dirname(filePath)\n\n // Run prettier via CLI (avoids Jest/ESM compatibility issues)\n const prettierCmd = `npx prettier --write \"${filePath}\"`\n\n debug(`[AST] Executing: ${prettierCmd}`)\n execSync(prettierCmd, {\n cwd: projectDir,\n stdio: 'pipe', // Suppress output\n })\n debug('[AST] ✓ Prettier formatting successful')\n } catch (error) {\n // Log but don't fail if prettier fails (might not be installed)\n debug(\n `[AST] ⚠ Prettier formatting failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n debug('[AST] Continuing with unformatted output')\n }\n } else {\n debug('[AST] Skipping prettier formatting (disabled)')\n }\n\n debug('[AST] ✓ File written successfully')\n\n return { success: true }\n}\n\nexport async function configurePayloadConfig(\n filePath: string,\n options: ConfigureOptions = {},\n): Promise<WriteResult> {\n debug(`[AST] Configuring payload config: ${filePath}`)\n debug(\n `[AST] Options: db=${options.db?.type}, storage=${options.storage}, removeSharp=${options.removeSharp}`,\n )\n\n const allModifications: Modification[] = []\n const allWarnings: string[] = []\n\n try {\n // Create Project and load source file with proper settings\n const project = new Project({\n manipulationSettings: {\n quoteKind: QuoteKind.Single,\n },\n })\n let sourceFile = project.addSourceFileAtPath(filePath)\n\n // Run detection\n const detection = detectPayloadConfigStructure(sourceFile)\n if (!detection.success) {\n return detection\n }\n\n // Apply transformations based on options\n if (options.db) {\n debug('[AST] Applying database adapter transformation')\n const result = addDatabaseAdapter({\n adapter: options.db.type,\n envVarName: options.db.envVarName,\n sourceFile,\n })\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n if (options.storage) {\n debug('[AST] Applying storage adapter transformation')\n const result = addStorageAdapter({ adapter: options.storage, sourceFile })\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n if (options.removeSharp) {\n debug('[AST] Applying sharp removal')\n const result = removeSharp(sourceFile)\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n // Remove comment markers from template\n sourceFile = removeCommentMarkers(sourceFile)\n\n // Cleanup orphaned imports after all transformations\n debug('[AST] Cleaning up orphaned imports')\n\n // Cleanup database adapter imports if db was removed\n for (const [, config] of Object.entries(DB_ADAPTER_CONFIG)) {\n if (options.db && config.packageName !== DB_ADAPTER_CONFIG[options.db.type].packageName) {\n const cleanup = cleanupOrphanedImports({\n importNames: [config.adapterName],\n moduleSpecifier: config.packageName,\n sourceFile,\n })\n if (cleanup.removed.length > 0) {\n cleanup.removed.forEach((importName) => {\n allModifications.push({\n type: 'import-removed',\n description: `Cleaned up unused import '${importName}' from '${config.packageName}'`,\n })\n })\n }\n }\n }\n\n // Log summary of modifications\n if (allModifications.length > 0) {\n debug(`[AST] Applied ${allModifications.length} modification(s):`)\n allModifications.forEach((mod) => {\n debug(`[AST] - ${mod.type}: ${mod.description}`)\n })\n }\n\n if (allWarnings.length > 0) {\n debug(`[AST] ${allWarnings.length} warning(s):`)\n allWarnings.forEach((warning) => {\n debug(`[AST] - ${warning}`)\n })\n }\n\n // Write transformed file with validation and formatting\n return await writeTransformedFile(sourceFile, {\n formatWithPrettier: options.formatWithPrettier,\n validateStructure: options.validateStructure ?? true,\n })\n } catch (error) {\n debug(`[AST] ✗ Configuration failed: ${error instanceof Error ? error.message : String(error)}`)\n return {\n error: formatError({\n actual: error instanceof Error ? error.message : String(error),\n context: 'configurePayloadConfig',\n expected: 'Successful file transformation',\n technicalDetails: error instanceof Error ? error.stack || error.message : String(error),\n }),\n success: false,\n }\n }\n}\n"],"names":["execSync","path","Project","QuoteKind","SyntaxKind","debug","DB_ADAPTER_CONFIG","STORAGE_ADAPTER_CONFIG","addImportDeclaration","cleanupOrphanedImports","formatError","removeImportDeclaration","detectPayloadConfigStructure","sourceFile","getFilePath","payloadImport","getImportDeclarations","find","imp","getModuleSpecifierValue","buildConfigImportSpec","getNamedImports","spec","getName","aliasNode","getAliasNode","buildConfigName","getText","buildConfigCall","getDescendantsOfKind","CallExpression","call","expression","getExpression","error","actual","context","expected","technicalDetails","success","importStatements","length","configObject","getArguments","dbProperty","getKind","ObjectLiteralExpression","asKindOrThrow","getProperty","asKind","PropertyAssignment","pluginsArray","objLiteral","pluginsProperty","propertyAssignment","initializer","getInitializer","ArrayLiteralExpression","allBuildConfigCalls","filter","hasImportAlias","payloadImports","hasOtherPayloadImports","some","dbAdapterImportInfo","config","Object","entries","importDecl","packageName","namedImports","hasOtherImports","importDeclaration","storageAdapterImports","adapterName","push","needsManualIntervention","edgeCases","multipleBuildConfigCalls","importSources","dbAdapter","storage","undefined","structures","addDatabaseAdapter","adapter","envVarName","modifications","detection","modified","oldAdapters","values","removedAdapters","importInsertIndex","forEach","oldConfig","removedIndex","moduleSpecifier","type","description","join","insertIndex","defaultImport","newDbCode","configTemplate","replaceWithText","getProperties","insertPropertyAssignment","name","addStorageAdapter","pluginsPropertyRaw","shorthandProperty","ShorthandPropertyAssignment","identifierName","allProperties","indexOf","remove","addPropertyAssignment","configText","addElement","removeSharp","warnings","sharpProperty","removeCommentMarkers","text","getFullText","replace","validateStructure","writeTransformedFile","options","formatWithPrettier","shouldValidate","validation","filePath","formatText","save","projectDir","dirname","prettierCmd","cwd","stdio","Error","message","configurePayloadConfig","db","allModifications","allWarnings","project","manipulationSettings","quoteKind","Single","addSourceFileAtPath","result","cleanup","importNames","removed","importName","mod","warning","String","stack"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAe;AACxC,OAAOC,UAAU,OAAM;AACvB,SAASC,OAAO,EAAEC,SAAS,EAAmBC,UAAU,QAAQ,WAAU;AAa1E,SAASC,KAAK,QAAQ,qBAAoB;AAC1C,SAASC,iBAAiB,EAAEC,sBAAsB,QAAQ,sBAAqB;AAC/E,SACEC,oBAAoB,EACpBC,sBAAsB,EACtBC,WAAW,EACXC,uBAAuB,QAClB,aAAY;AAEnB,OAAO,SAASC,6BAA6BC,UAAsB;IACjER,MAAM,CAAC,4CAA4C,EAAEQ,WAAWC,WAAW,IAAI;IAE/E,2DAA2D;IAC3D,MAAMC,gBAAgBF,WACnBG,qBAAqB,GACrBC,IAAI,CAAC,CAACC,MAAQA,IAAIC,uBAAuB,OAAO;IAEnD,MAAMC,wBAAwBL,eAC1BM,kBACDJ,KAAK,CAACK,OA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C,aAAa,CAAC,0BAA0B,EAAEyD,WAAW,QAAQ,EAAE3F,OAAOI,WAAW,CAAC,CAAC,CAAC;wBACtF;oBACF;gBACF;YACF;QACF;QAEA,+BAA+B;QAC/B,IAAI4E,iBAAiBxG,MAAM,GAAG,GAAG;YAC/BpC,MAAM,CAAC,cAAc,EAAE4I,iBAAiBxG,MAAM,CAAC,iBAAiB,CAAC;YACjEwG,iBAAiBnD,OAAO,CAAC,CAAC+D;gBACxBxJ,MAAM,CAAC,UAAU,EAAEwJ,IAAI3D,IAAI,CAAC,EAAE,EAAE2D,IAAI1D,WAAW,EAAE;YACnD;QACF;QAEA,IAAI+C,YAAYzG,MAAM,GAAG,GAAG;YAC1BpC,MAAM,CAAC,MAAM,EAAE6I,YAAYzG,MAAM,CAAC,YAAY,CAAC;YAC/CyG,YAAYpD,OAAO,CAAC,CAACgE;gBACnBzJ,MAAM,CAAC,UAAU,EAAEyJ,SAAS;YAC9B;QACF;QAEA,wDAAwD;QACxD,OAAO,MAAM9B,qBAAqBnH,YAAY;YAC5CqH,oBAAoBD,QAAQC,kBAAkB;YAC9CH,mBAAmBE,QAAQF,iBAAiB,IAAI;QAClD;IACF,EAAE,OAAO7F,OAAO;QACd7B,MAAM,CAAC,8BAA8B,EAAE6B,iBAAiB2G,QAAQ3G,MAAM4G,OAAO,GAAGiB,OAAO7H,QAAQ;QAC/F,OAAO;YACLA,OAAOxB,YAAY;gBACjByB,QAAQD,iBAAiB2G,QAAQ3G,MAAM4G,OAAO,GAAGiB,OAAO7H;gBACxDE,SAAS;gBACTC,UAAU;gBACVC,kBAAkBJ,iBAAiB2G,QAAQ3G,MAAM8H,KAAK,IAAI9H,MAAM4G,OAAO,GAAGiB,OAAO7H;YACnF;YACAK,SAAS;QACX;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/ast/payload-config.ts"],"sourcesContent":["import { execSync } from 'child_process'\nimport path from 'path'\nimport {\n type ObjectLiteralExpression,\n Project,\n QuoteKind,\n type SourceFile,\n SyntaxKind,\n} from 'ts-morph'\n\nimport type {\n ConfigureOptions,\n DatabaseAdapter,\n DetectionResult,\n Modification,\n StorageAdapter,\n TransformationResult,\n WriteOptions,\n WriteResult,\n} from './types.js'\n\nimport { debug } from '../../utils/log.js'\nimport {\n DB_ADAPTER_CONFIG,\n SHARP_TRANSFORMER_NAME,\n SHARP_TRANSFORMER_PACKAGE,\n STORAGE_ADAPTER_CONFIG,\n} from './adapter-config.js'\nimport {\n addImportDeclaration,\n cleanupOrphanedImports,\n formatError,\n removeImportDeclaration,\n} from './utils.js'\n\nexport function detectPayloadConfigStructure(sourceFile: SourceFile): DetectionResult {\n debug(`[AST] Detecting payload config structure in ${sourceFile.getFilePath()}`)\n\n // First find the actual name being used (might be aliased)\n const payloadImport = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === 'payload')\n\n const buildConfigImportSpec = payloadImport\n ?.getNamedImports()\n .find((spec) => spec.getName() === 'buildConfig')\n\n const aliasNode = buildConfigImportSpec?.getAliasNode()\n const buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig'\n\n debug(`[AST] Looking for function call: ${buildConfigName}`)\n\n // Find buildConfig call expression (using actual name in code)\n const buildConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((call) => {\n const expression = call.getExpression()\n return expression.getText() === buildConfigName\n })\n\n if (!buildConfigCall) {\n debug(`[AST] ✗ ${buildConfigName} call not found`)\n return {\n error: formatError({\n actual: `No ${buildConfigName} call found in file`,\n context: 'buildConfig call',\n expected: `export default ${buildConfigName}({ ... })`,\n technicalDetails: `Could not find CallExpression with identifier \"${buildConfigName}\"`,\n }),\n success: false,\n }\n }\n\n debug(`[AST] ✓ ${buildConfigName} call found`)\n\n // Get import statements\n const importStatements = sourceFile.getImportDeclarations()\n debug(`[AST] Found ${importStatements.length} import statements`)\n\n // Find db property if it exists\n const configObject = buildConfigCall.getArguments()[0]\n let dbProperty\n if (configObject && configObject.getKind() === SyntaxKind.ObjectLiteralExpression) {\n dbProperty = configObject\n .asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n .getProperty('db')\n ?.asKind(SyntaxKind.PropertyAssignment)\n }\n\n debug(`[AST] db property: ${dbProperty ? '✓ found' : '✗ not found'}`)\n\n // Find plugins array if it exists\n let pluginsArray\n if (configObject && configObject.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n const pluginsProperty = objLiteral.getProperty('plugins')\n\n // Handle PropertyAssignment (e.g., plugins: [...])\n const propertyAssignment = pluginsProperty?.asKind(SyntaxKind.PropertyAssignment)\n if (propertyAssignment) {\n const initializer = propertyAssignment.getInitializer()\n if (initializer?.getKind() === SyntaxKind.ArrayLiteralExpression) {\n pluginsArray = initializer.asKind(SyntaxKind.ArrayLiteralExpression)\n }\n }\n // For ShorthandPropertyAssignment (e.g., plugins), we can't get the array directly\n // but we'll detect it in addStorageAdapter\n }\n\n debug(`[AST] plugins array: ${pluginsArray ? '✓ found' : '✗ not found'}`)\n\n // Find all buildConfig calls for edge case detection (using actual name)\n const allBuildConfigCalls = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((call) => {\n const expression = call.getExpression()\n return expression.getText() === buildConfigName\n })\n\n const hasImportAlias = !!aliasNode\n\n // Check for other Payload imports\n const payloadImports = payloadImport?.getNamedImports() || []\n const hasOtherPayloadImports =\n payloadImports.length > 1 || payloadImports.some((imp) => imp.getName() !== 'buildConfig')\n\n // Track database adapter imports\n let dbAdapterImportInfo\n for (const [, config] of Object.entries(DB_ADAPTER_CONFIG)) {\n const importDecl = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === config.packageName)\n\n if (importDecl) {\n const namedImports = importDecl.getNamedImports()\n dbAdapterImportInfo = {\n hasOtherImports: namedImports.length > 1,\n importDeclaration: importDecl,\n packageName: config.packageName,\n }\n break\n }\n }\n\n // Track storage adapter imports\n const storageAdapterImports = []\n for (const [, config] of Object.entries(STORAGE_ADAPTER_CONFIG)) {\n if (!config.packageName || !config.adapterName) {\n continue\n }\n\n const importDecl = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getModuleSpecifierValue() === config.packageName)\n\n if (importDecl) {\n const namedImports = importDecl.getNamedImports()\n storageAdapterImports.push({\n hasOtherImports: namedImports.length > 1,\n importDeclaration: importDecl,\n packageName: config.packageName,\n })\n }\n }\n\n const needsManualIntervention = hasImportAlias || allBuildConfigCalls.length > 2\n\n debug(\n `[AST] Edge cases: alias=${hasImportAlias}, multiple=${allBuildConfigCalls.length > 1}, otherImports=${hasOtherPayloadImports}, manual=${needsManualIntervention}`,\n )\n\n return {\n edgeCases: {\n hasImportAlias,\n hasOtherPayloadImports,\n multipleBuildConfigCalls: allBuildConfigCalls.length > 1,\n needsManualIntervention,\n },\n importSources: {\n dbAdapter: dbAdapterImportInfo,\n storage: storageAdapterImports.length > 0 ? storageAdapterImports : undefined,\n },\n sourceFile,\n structures: {\n buildConfigCall,\n dbProperty,\n importStatements,\n pluginsArray,\n },\n success: true,\n }\n}\n\nexport function addDatabaseAdapter({\n adapter,\n envVarName = 'DATABASE_URL',\n sourceFile,\n}: {\n adapter: DatabaseAdapter\n envVarName?: string\n sourceFile: SourceFile\n}): TransformationResult {\n debug(`[AST] Adding database adapter: ${adapter} (envVar: ${envVarName})`)\n\n const modifications: Modification[] = []\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const { buildConfigCall, dbProperty } = detection.structures\n const config = DB_ADAPTER_CONFIG[adapter]\n\n // Remove old db adapter imports and track position for replacement\n const oldAdapters = Object.values(DB_ADAPTER_CONFIG)\n const removedAdapters: string[] = []\n let importInsertIndex: number | undefined\n oldAdapters.forEach((oldConfig) => {\n if (oldConfig.packageName !== config.packageName) {\n const { removedIndex } = removeImportDeclaration({\n moduleSpecifier: oldConfig.packageName,\n sourceFile,\n })\n if (removedIndex !== undefined) {\n // Use the first removed adapter's position\n if (importInsertIndex === undefined) {\n importInsertIndex = removedIndex\n }\n removedAdapters.push(oldConfig.packageName)\n modifications.push({\n type: 'import-removed',\n description: `Removed import from '${oldConfig.packageName}'`,\n })\n }\n }\n })\n\n if (removedAdapters.length > 0) {\n debug(`[AST] Removed old adapter imports: ${removedAdapters.join(', ')}`)\n }\n\n // Add new import at the position of the removed one (or default position)\n addImportDeclaration({\n insertIndex: importInsertIndex,\n moduleSpecifier: config.packageName,\n namedImports: [config.adapterName],\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: { ${config.adapterName} } from '${config.packageName}'`,\n })\n\n // Add special imports for specific adapters\n if (adapter === 'd1-sqlite') {\n debug('[AST] Adding special import: ./db/migrations')\n addImportDeclaration({\n defaultImport: 'migrations',\n moduleSpecifier: './db/migrations',\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: migrations from './db/migrations'`,\n })\n }\n\n // Get config object\n const configObject = buildConfigCall.getArguments()[0]\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n error: formatError({\n actual: 'buildConfig has no object literal argument',\n context: 'database adapter configuration',\n expected: 'buildConfig({ ... })',\n technicalDetails: 'buildConfig call must have an object literal as first argument',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n\n const newDbCode = `db: ${config.configTemplate(envVarName)}`\n\n if (dbProperty) {\n // Replace existing db property\n // NOTE: Using replaceWithText() instead of remove() + insertPropertyAssignment()\n // to avoid double comma issues. When remove() is called, ts-morph doesn't always\n // clean up trailing commas correctly, which can result in syntax like \"},,\" when\n // inserting a new property at that position. replaceWithText() preserves the\n // surrounding punctuation correctly.\n debug(`[AST] Replacing existing db property`)\n dbProperty.replaceWithText(newDbCode)\n modifications.push({\n type: 'property-added',\n description: `Replaced db property with ${adapter} adapter`,\n })\n } else {\n // No existing db property - insert at end\n const insertIndex = objLiteral.getProperties().length\n debug(`[AST] Adding db property at index ${insertIndex}`)\n objLiteral.insertPropertyAssignment(insertIndex, {\n name: 'db',\n initializer: config.configTemplate(envVarName),\n })\n modifications.push({\n type: 'property-added',\n description: `Added db property with ${adapter} adapter`,\n })\n }\n\n debug(`[AST] ✓ Database adapter ${adapter} added successfully`)\n\n return {\n modifications,\n modified: true,\n success: true,\n }\n}\n\nexport function addStorageAdapter({\n adapter,\n sourceFile,\n}: {\n adapter: StorageAdapter\n sourceFile: SourceFile\n}): TransformationResult {\n debug(`[AST] Adding storage adapter: ${adapter}`)\n\n const modifications: Modification[] = []\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const config = STORAGE_ADAPTER_CONFIG[adapter]\n\n // Local disk doesn't need any imports or storage adapters\n if (adapter === 'localDisk') {\n debug('[AST] localDisk storage adapter - no imports or storage adapters needed')\n return {\n modifications: [],\n modified: false,\n success: true,\n }\n }\n\n // Add import\n if (config.packageName && config.adapterName) {\n addImportDeclaration({\n moduleSpecifier: config.packageName,\n namedImports: [config.adapterName],\n sourceFile,\n })\n modifications.push({\n type: 'import-added',\n description: `Added import: { ${config.adapterName} } from '${config.packageName}'`,\n })\n }\n\n const { buildConfigCall } = detection.structures\n const configObject = buildConfigCall.getArguments()[0]\n\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n error: formatError({\n actual: 'buildConfig has no object literal argument',\n context: 'storage adapter configuration',\n expected: 'buildConfig({ ... })',\n technicalDetails: 'buildConfig call must have an object literal as first argument',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n\n // Find or create storage array\n const storagePropertyRaw = objLiteral.getProperty('storage')\n let storageProperty = storagePropertyRaw?.asKind(SyntaxKind.PropertyAssignment)\n\n // Check if it's a shorthand property (e.g., `storage` referencing an imported variable)\n const shorthandProperty = storagePropertyRaw?.asKind(SyntaxKind.ShorthandPropertyAssignment)\n\n if (shorthandProperty) {\n debug('[AST] Found shorthand storage property, converting to long form with spread')\n // Get the identifier name (usually 'storage')\n const identifierName = shorthandProperty.getName()\n\n // Find insert position before removing\n const allProperties = objLiteral.getProperties()\n const insertIndex = allProperties.indexOf(shorthandProperty)\n\n // Remove the shorthand property\n shorthandProperty.remove()\n\n // Create new property with spread operator: storage: [...storage, newAdapter]\n objLiteral.insertPropertyAssignment(insertIndex, {\n name: 'storage',\n initializer: `[...${identifierName}]`,\n })\n\n storageProperty = objLiteral.getProperty('storage')?.asKind(SyntaxKind.PropertyAssignment)\n modifications.push({\n type: 'property-added',\n description: `Converted shorthand storage property to array with spread syntax`,\n })\n } else if (!storageProperty) {\n debug('[AST] Creating new storage array')\n // Insert after the last property, not after trailing comments, which would produce `},,`\n const propertiesWithComments = objLiteral.getPropertiesWithComments()\n const lastProperty = objLiteral.getProperties().at(-1)\n const insertIndex = lastProperty ? propertiesWithComments.indexOf(lastProperty) + 1 : 0\n objLiteral.insertPropertyAssignment(insertIndex, {\n name: 'storage',\n initializer: '[]',\n })\n storageProperty = objLiteral.getProperty('storage')?.asKind(SyntaxKind.PropertyAssignment)\n modifications.push({\n type: 'property-added',\n description: `Created storage array`,\n })\n } else {\n debug('[AST] Reusing existing storage array')\n }\n\n if (!storageProperty) {\n return {\n error: formatError({\n actual: 'Failed to create or find storage property',\n context: 'storage adapter configuration',\n expected: 'storage array property',\n technicalDetails: 'Could not create or access storage property',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const initializer = storageProperty.getInitializer()\n if (!initializer || initializer.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n return {\n error: formatError({\n actual: 'storage property is not an array',\n context: 'storage adapter configuration',\n expected: 'storage: [...]',\n technicalDetails: 'storage property must be an array literal expression',\n }),\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const storageArray = initializer.asKindOrThrow(SyntaxKind.ArrayLiteralExpression)\n\n // Add storage adapter call\n const configText = config.configTemplate()\n if (configText) {\n storageArray.addElement(configText)\n modifications.push({\n type: 'property-added',\n description: `Added ${adapter} to storage array`,\n })\n }\n\n debug(`[AST] ✓ Storage adapter ${adapter} added successfully`)\n\n return {\n modifications,\n modified: true,\n success: true,\n }\n}\n\nexport function removeSharp(sourceFile: SourceFile): TransformationResult {\n debug('[AST] Removing sharp import and property')\n\n const modifications: Modification[] = []\n\n // Remove imports\n for (const moduleSpecifier of ['sharp', SHARP_TRANSFORMER_PACKAGE]) {\n const { removedIndex } = removeImportDeclaration({ moduleSpecifier, sourceFile })\n if (removedIndex !== undefined) {\n modifications.push({\n type: 'import-removed',\n description: `Removed import from '${moduleSpecifier}'`,\n })\n }\n }\n\n // Find and remove sharp property from buildConfig\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success || !detection.structures) {\n // If detection failed but we removed import, still count as partial success\n if (modifications.length > 0) {\n return {\n modifications,\n modified: true,\n success: true,\n warnings: ['Could not detect config structure to remove sharp property'],\n }\n }\n return {\n error: detection.error,\n modifications: [],\n modified: false,\n success: false,\n }\n }\n\n const { buildConfigCall } = detection.structures\n const configObject = buildConfigCall.getArguments()[0]\n\n if (!configObject || configObject.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return {\n modifications,\n modified: modifications.length > 0,\n success: true,\n warnings: ['buildConfig has no object literal argument - could not remove sharp property'],\n }\n }\n\n const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)\n const sharpProperty = objLiteral.getProperty('sharp')\n\n if (sharpProperty) {\n sharpProperty.remove()\n modifications.push({\n type: 'property-removed',\n description: `Removed sharp property from config`,\n })\n debug('[AST] ✓ Sharp property removed from config')\n } else {\n debug('[AST] Sharp property not found (already absent)')\n }\n\n if (removeSharpTransformer({ objLiteral })) {\n modifications.push({\n type: 'property-removed',\n description: `Removed ${SHARP_TRANSFORMER_NAME} from upload transformers`,\n })\n debug(`[AST] ✓ ${SHARP_TRANSFORMER_NAME} removed from upload transformers`)\n }\n\n return {\n modifications,\n modified: modifications.length > 0,\n success: true,\n }\n}\n\n/** This shouldn't be necessary once the templates are updated. Can't hurt to keep in, though */\nexport function removeCommentMarkers(sourceFile: SourceFile): SourceFile {\n // Get the full text and replace comment markers\n let text = sourceFile.getFullText()\n\n // Remove inline comment markers from imports\n text = text.replace(/\\s*\\/\\/\\s*database-adapter-import\\s*$/gm, '')\n text = text.replace(/\\s*\\/\\/\\s*storage-adapter-import-placeholder\\s*$/gm, '')\n\n // Remove standalone comment lines\n text = text.replace(/^\\s*\\/\\/\\s*database-adapter-config-start\\s*\\n/gm, '')\n text = text.replace(/^\\s*\\/\\/\\s*database-adapter-config-end\\s*\\n/gm, '')\n text = text.replace(/^\\s*\\/\\/\\s*storage-adapter-placeholder\\s*\\n/gm, '')\n\n // Also remove the placeholder line from template (storage-adapter-import-placeholder at top)\n text = text.replace(/^\\/\\/\\s*storage-adapter-import-placeholder\\s*\\n/gm, '')\n\n // Replace the entire source file content\n sourceFile.replaceWithText(text)\n\n return sourceFile\n}\n\n/**\n * Validates payload config structure has required elements after transformation.\n * Checks that buildConfig() call exists and has a db property configured.\n */\nexport function validateStructure(sourceFile: SourceFile): WriteResult {\n debug('[AST] Validating payload config structure')\n\n const detection = detectPayloadConfigStructure(sourceFile)\n\n if (!detection.success) {\n debug('[AST] ✗ Validation failed: detection unsuccessful')\n return {\n error: detection.error,\n success: false,\n }\n }\n\n const { structures } = detection\n\n // Validate db property exists\n if (!structures?.dbProperty) {\n debug('[AST] ✗ Validation failed: db property missing')\n return {\n error: formatError({\n actual: 'No db property found',\n context: 'database configuration',\n expected: 'buildConfig must have a db property',\n technicalDetails: 'PropertyAssignment with name \"db\" not found in buildConfig object',\n }),\n success: false,\n }\n }\n\n debug('[AST] ✓ Validation passed')\n return { success: true }\n}\n\nexport async function writeTransformedFile(\n sourceFile: SourceFile,\n options: WriteOptions = {},\n): Promise<WriteResult> {\n const { formatWithOxfmt = true, validateStructure: shouldValidate = true } = options\n\n debug(`[AST] Writing transformed file: ${sourceFile.getFilePath()}`)\n\n // Validate if requested\n if (shouldValidate) {\n const validation = validateStructure(sourceFile)\n if (!validation.success) {\n return validation\n }\n }\n\n // Get file path and save to disk\n const filePath = sourceFile.getFilePath()\n\n // Format with ts-morph before saving (fixes trailing commas, indentation)\n debug('[AST] Formatting with ts-morph')\n sourceFile.formatText()\n\n // Write file\n debug('[AST] Writing file to disk')\n await sourceFile.save()\n\n // Format with oxfmt if requested\n if (formatWithOxfmt) {\n debug('[AST] Running oxfmt formatting via CLI')\n try {\n // Detect project directory (go up from file until we find package.json or use dirname)\n const projectDir = path.dirname(filePath)\n\n // Run oxfmt via CLI (avoids Jest/ESM compatibility issues)\n const oxfmtCmd = `npx oxfmt \"${filePath}\"`\n\n debug(`[AST] Executing: ${oxfmtCmd}`)\n execSync(oxfmtCmd, {\n cwd: projectDir,\n stdio: 'pipe', // Suppress output\n })\n debug('[AST] ✓ Oxfmt formatting successful')\n } catch (error) {\n // Log but don't fail if oxfmt fails (might not be installed)\n debug(\n `[AST] ⚠ Oxfmt formatting failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n debug('[AST] Continuing with unformatted output')\n }\n } else {\n debug('[AST] Skipping oxfmt formatting (disabled)')\n }\n\n debug('[AST] ✓ File written successfully')\n\n return { success: true }\n}\n\nexport async function configurePayloadConfig(\n filePath: string,\n options: ConfigureOptions = {},\n): Promise<WriteResult> {\n debug(`[AST] Configuring payload config: ${filePath}`)\n debug(\n `[AST] Options: db=${options.db?.type}, storage=${options.storage}, removeSharp=${options.removeSharp}`,\n )\n\n const allModifications: Modification[] = []\n const allWarnings: string[] = []\n\n try {\n // Create Project and load source file with proper settings\n const project = new Project({\n manipulationSettings: {\n quoteKind: QuoteKind.Single,\n },\n })\n let sourceFile = project.addSourceFileAtPath(filePath)\n\n // Run detection\n const detection = detectPayloadConfigStructure(sourceFile)\n if (!detection.success) {\n return detection\n }\n\n // Apply transformations based on options\n if (options.db) {\n debug('[AST] Applying database adapter transformation')\n const result = addDatabaseAdapter({\n adapter: options.db.type,\n envVarName: options.db.envVarName,\n sourceFile,\n })\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n if (options.storage) {\n debug('[AST] Applying storage adapter transformation')\n const result = addStorageAdapter({ adapter: options.storage, sourceFile })\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n if (options.removeSharp) {\n debug('[AST] Applying sharp removal')\n const result = removeSharp(sourceFile)\n\n if (!result.success) {\n return {\n error: result.error,\n success: false,\n }\n }\n\n allModifications.push(...result.modifications)\n if (result.warnings) {\n allWarnings.push(...result.warnings)\n }\n }\n\n // Remove comment markers from template\n sourceFile = removeCommentMarkers(sourceFile)\n\n // Cleanup orphaned imports after all transformations\n debug('[AST] Cleaning up orphaned imports')\n\n // Cleanup database adapter imports if db was removed\n for (const [, config] of Object.entries(DB_ADAPTER_CONFIG)) {\n if (options.db && config.packageName !== DB_ADAPTER_CONFIG[options.db.type].packageName) {\n const cleanup = cleanupOrphanedImports({\n importNames: [config.adapterName],\n moduleSpecifier: config.packageName,\n sourceFile,\n })\n if (cleanup.removed.length > 0) {\n cleanup.removed.forEach((importName) => {\n allModifications.push({\n type: 'import-removed',\n description: `Cleaned up unused import '${importName}' from '${config.packageName}'`,\n })\n })\n }\n }\n }\n\n // Log summary of modifications\n if (allModifications.length > 0) {\n debug(`[AST] Applied ${allModifications.length} modification(s):`)\n allModifications.forEach((mod) => {\n debug(`[AST] - ${mod.type}: ${mod.description}`)\n })\n }\n\n if (allWarnings.length > 0) {\n debug(`[AST] ${allWarnings.length} warning(s):`)\n allWarnings.forEach((warning) => {\n debug(`[AST] - ${warning}`)\n })\n }\n\n // Write transformed file with validation and formatting\n return await writeTransformedFile(sourceFile, {\n formatWithOxfmt: options.formatWithOxfmt,\n validateStructure: options.validateStructure ?? true,\n })\n } catch (error) {\n debug(`[AST] ✗ Configuration failed: ${error instanceof Error ? error.message : String(error)}`)\n return {\n error: formatError({\n actual: error instanceof Error ? error.message : String(error),\n context: 'configurePayloadConfig',\n expected: 'Successful file transformation',\n technicalDetails: error instanceof Error ? error.stack || error.message : String(error),\n }),\n success: false,\n }\n }\n}\n\n/**\n * Removes `sharpTransformer()` from `upload.transformers`, then removes `transformers`\n * and `upload` if they become empty. Returns true if anything was removed.\n */\nfunction removeSharpTransformer({ objLiteral }: { objLiteral: ObjectLiteralExpression }): boolean {\n const uploadProperty = objLiteral.getProperty('upload')?.asKind(SyntaxKind.PropertyAssignment)\n const uploadObject = uploadProperty?.getInitializerIfKind(SyntaxKind.ObjectLiteralExpression)\n const transformersProperty = uploadObject\n ?.getProperty('transformers')\n ?.asKind(SyntaxKind.PropertyAssignment)\n const transformersArray = transformersProperty?.getInitializerIfKind(\n SyntaxKind.ArrayLiteralExpression,\n )\n\n if (!uploadProperty || !uploadObject || !transformersProperty || !transformersArray) {\n return false\n }\n\n const sharpTransformerIndexes = transformersArray\n .getElements()\n .flatMap((element, index) =>\n element.asKind(SyntaxKind.CallExpression)?.getExpression().getText() ===\n SHARP_TRANSFORMER_NAME\n ? [index]\n : [],\n )\n\n if (sharpTransformerIndexes.length === 0) {\n return false\n }\n\n // Remove from the end so earlier indexes stay valid\n for (const index of sharpTransformerIndexes.reverse()) {\n transformersArray.removeElement(index)\n }\n\n if (transformersArray.getElements().length === 0) {\n transformersProperty.remove()\n }\n\n if (uploadObject.getProperties().length === 0) {\n uploadProperty.remove()\n }\n\n return true\n}\n"],"names":["execSync","path","Project","QuoteKind","SyntaxKind","debug","DB_ADAPTER_CONFIG","SHARP_TRANSFORMER_NAME","SHARP_TRANSFORMER_PACKAGE","STORAGE_ADAPTER_CONFIG","addImportDeclaration","cleanupOrphanedImports","formatError","removeImportDeclaration","detectPayloadConfigStructure","sourceFile","getFilePath","payloadImport","getImportDeclarations","find","imp","getModuleSpecifierValue","buildConfigImportSpec","getNamedImports","spec","getName","aliasNode","getAliasNode","buildConfigName","getText","buildConfigCall","getDescendantsOfKind","CallExpression","call","expression","getExpression","error","actual","context","expected","technicalDetails","success","importStatements","length","configObject","getArguments","dbProperty","getKind","ObjectLiteralExpression","asKindOrThrow","getProperty","asKind","PropertyAssignment","pluginsArray","objLiteral","pluginsProperty","propertyAssignment","initializer","getInitializer","ArrayLiteralExpression","allBuildConfigCalls","filter","hasImportAlias","payloadImports","hasOtherPayloadImports","some","dbAdapterImportInfo","config","Object","entries","importDecl","packageName","namedImports","hasOtherImports","importDeclaration","storageAdapterImports","adapterName","push","needsManualIntervention","edgeCases","multipleBuildConfigCalls","importSources","dbAdapter","storage","undefined","structures","addDatabaseAdapter","adapter","envVarName","modifications","detection","modified","oldAdapters","values","removedAdapters","importInsertIndex","forEach","oldConfig","removedIndex","moduleSpecifier","type","description","join","insertIndex","defaultImport","newDbCode","configTemplate","replaceWithText","getProperties","insertPropertyAssignment","name","addStorageAdapter","storagePropertyRaw","storageProperty","shorthandProperty","ShorthandPropertyAssignment","identifierName","allProperties","indexOf","remove","propertiesWithComments","getPropertiesWithComments","lastProperty","at","storageArray","configText","addElement","removeSharp","warnings","sharpProperty","removeSharpTransformer","removeCommentMarkers","text","getFullText","replace","validateStructure","writeTransformedFile","options","formatWithOxfmt","shouldValidate","validation","filePath","formatText","save","projectDir","dirname","oxfmtCmd","cwd","stdio","Error","message","configurePayloadConfig","db","allModifications","allWarnings","project","manipulationSettings","quoteKind","Single","addSourceFileAtPath","result","cleanup","importNames","removed","importName","mod","warning","String","stack","uploadProperty","uploadObject","getInitializerIfKind","transformersProperty","transformersArray","sharpTransformerIndexes","getElements","flatMap","element","index","reverse","removeElement"],"mappings":"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AAkB,CAACC,gBAAgB,CAACE,wBAAwB,CAACC,mBAAmB;QACnF,OAAO;IACT;IAEA,MAAMC,0BAA0BD,kBAC7BE,WAAW,GACXC,OAAO,CAAC,CAACC,SAASC,QACjBD,QAAQ9H,MAAM,CAAC/C,WAAW4B,cAAc,GAAGG,gBAAgBN,cAC3DtB,yBACI;YAAC2K;SAAM,GACP,EAAE;IAGV,IAAIJ,wBAAwBnI,MAAM,KAAK,GAAG;QACxC,OAAO;IACT;IAEA,oDAAoD;IACpD,KAAK,MAAMuI,SAASJ,wBAAwBK,OAAO,GAAI;QACrDN,kBAAkBO,aAAa,CAACF;IAClC;IAEA,IAAIL,kBAAkBE,WAAW,GAAGpI,MAAM,KAAK,GAAG;QAChDiI,qBAAqBrD,MAAM;IAC7B;IAEA,IAAImD,aAAa9D,aAAa,GAAGjE,MAAM,KAAK,GAAG;QAC7C8H,eAAelD,MAAM;IACvB;IAEA,OAAO;AACT"}
|
package/dist/lib/ast/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/ast/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACX,MAAM,UAAU,CAAA;AAGjB,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,M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AAO,CAAC,EAAE,cAAc,CAAA;CACzB,GAAG,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/ast/types.ts"],"sourcesContent":["import type {\n ArrayLiteralExpression,\n CallExpression,\n ImportDeclaration,\n PropertyAssignment,\n SourceFile,\n} from 'ts-morph'\n\n// Result types for import utility functions\nexport type ImportRemovalResult = {\n removedIndex?: number\n sourceFile: SourceFile\n}\n\nexport type NamedImportRemovalResult = {\n fullyRemoved: boolean\n index?: number\n sourceFile: SourceFile\n}\n\nexport type ImportCleanupResult = {\n kept: string[]\n removed: string[]\n sourceFile: SourceFile\n}\n\nexport type DetectionError = {\n debugInfo?: Record<string, unknown>\n technicalDetails: string\n userMessage: string\n}\n\nexport type PayloadConfigStructures = {\n buildConfigCall: CallExpression\n dbProperty?: PropertyAssignment\n importStatements: ImportDeclaration[]\n pluginsArray?: ArrayLiteralExpression\n}\n\n/**\n * Detection result with edge case tracking and import source information\n */\nexport type DetectionResult = {\n /** Edge case flags */\n edgeCases?: {\n /** Import uses an alias (e.g., import { buildConfig as bc }) */\n hasImportAlias: boolean\n /** Other Payload imports exist (e.g., CollectionConfig) */\n hasOtherPayloadImports: boolean\n /** Multiple buildConfig calls found in file */\n multipleBuildConfigCalls: boolean\n /** Needs manual intervention (can't be automatically handled) */\n needsManualIntervention: boolean\n }\n error?: DetectionError\n /** Import source tracking */\n importSources?: {\n /** Current database adapter import info */\n dbAdapter?: {\n hasOtherImports: boolean\n importDeclaration: ImportDeclaration\n packageName: string\n }\n /** Current storage adapter import info */\n storage?: Array<{\n hasOtherImports: boolean\n importDeclaration: ImportDeclaration\n packageName: string\n }>\n }\n /** Source file reference */\n sourceFile?: SourceFile\n /** Detected structures */\n structures?: PayloadConfigStructures\n success: boolean\n}\n\n/**\n * Tracks a single modification made to the AST\n */\nexport type Modification = {\n description: string\n location?: {\n column: number\n line: number\n }\n type:\n | 'function-renamed'\n | 'import-added'\n | 'import-modified'\n | 'import-removed'\n | 'property-added'\n | 'property-removed'\n}\n\n/**\n * Result of transformation operations\n */\nexport type TransformationResult = {\n error?: DetectionError\n modifications: Modification[]\n modified: boolean\n success: boolean\n warnings?: string[]\n}\n\n/**\n * Final result after writing to disk\n */\nexport type ModificationResult = {\n error?: DetectionError\n filePath: string\n formatted?: boolean\n modifications: Modification[]\n success: boolean\n warnings?: string[]\n}\nexport type DatabaseAdapter = (typeof ALL_DATABASE_ADAPTERS)[number]\n\nexport const ALL_DATABASE_ADAPTERS = [\n 'mongodb',\n 'postgres',\n 'sqlite',\n 'vercel-postgres',\n 'd1-sqlite',\n] as const\n\nexport const ALL_STORAGE_ADAPTERS = [\n 'azureStorage',\n 'gcsStorage',\n 'localDisk',\n 'r2Storage',\n 's3Storage',\n 'vercelBlobStorage',\n] as const\n\nexport type StorageAdapter = (typeof ALL_STORAGE_ADAPTERS)[number]\n\nexport type TransformOptions = {\n databaseAdapter?: {\n envVarName?: string\n type: DatabaseAdapter\n }\n removeSharp?: boolean\n storageAdapter?: {\n type: StorageAdapter\n }\n}\n\nexport type WriteOptions = {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/ast/types.ts"],"sourcesContent":["import type {\n ArrayLiteralExpression,\n CallExpression,\n ImportDeclaration,\n PropertyAssignment,\n SourceFile,\n} from 'ts-morph'\n\n// Result types for import utility functions\nexport type ImportRemovalResult = {\n removedIndex?: number\n sourceFile: SourceFile\n}\n\nexport type NamedImportRemovalResult = {\n fullyRemoved: boolean\n index?: number\n sourceFile: SourceFile\n}\n\nexport type ImportCleanupResult = {\n kept: string[]\n removed: string[]\n sourceFile: SourceFile\n}\n\nexport type DetectionError = {\n debugInfo?: Record<string, unknown>\n technicalDetails: string\n userMessage: string\n}\n\nexport type PayloadConfigStructures = {\n buildConfigCall: CallExpression\n dbProperty?: PropertyAssignment\n importStatements: ImportDeclaration[]\n pluginsArray?: ArrayLiteralExpression\n}\n\n/**\n * Detection result with edge case tracking and import source information\n */\nexport type DetectionResult = {\n /** Edge case flags */\n edgeCases?: {\n /** Import uses an alias (e.g., import { buildConfig as bc }) */\n hasImportAlias: boolean\n /** Other Payload imports exist (e.g., CollectionConfig) */\n hasOtherPayloadImports: boolean\n /** Multiple buildConfig calls found in file */\n multipleBuildConfigCalls: boolean\n /** Needs manual intervention (can't be automatically handled) */\n needsManualIntervention: boolean\n }\n error?: DetectionError\n /** Import source tracking */\n importSources?: {\n /** Current database adapter import info */\n dbAdapter?: {\n hasOtherImports: boolean\n importDeclaration: ImportDeclaration\n packageName: string\n }\n /** Current storage adapter import info */\n storage?: Array<{\n hasOtherImports: boolean\n importDeclaration: ImportDeclaration\n packageName: string\n }>\n }\n /** Source file reference */\n sourceFile?: SourceFile\n /** Detected structures */\n structures?: PayloadConfigStructures\n success: boolean\n}\n\n/**\n * Tracks a single modification made to the AST\n */\nexport type Modification = {\n description: string\n location?: {\n column: number\n line: number\n }\n type:\n | 'function-renamed'\n | 'import-added'\n | 'import-modified'\n | 'import-removed'\n | 'property-added'\n | 'property-removed'\n}\n\n/**\n * Result of transformation operations\n */\nexport type TransformationResult = {\n error?: DetectionError\n modifications: Modification[]\n modified: boolean\n success: boolean\n warnings?: string[]\n}\n\n/**\n * Final result after writing to disk\n */\nexport type ModificationResult = {\n error?: DetectionError\n filePath: string\n formatted?: boolean\n modifications: Modification[]\n success: boolean\n warnings?: string[]\n}\nexport type DatabaseAdapter = (typeof ALL_DATABASE_ADAPTERS)[number]\n\nexport const ALL_DATABASE_ADAPTERS = [\n 'mongodb',\n 'postgres',\n 'sqlite',\n 'vercel-postgres',\n 'd1-sqlite',\n] as const\n\nexport const ALL_STORAGE_ADAPTERS = [\n 'azureStorage',\n 'gcsStorage',\n 'localDisk',\n 'r2Storage',\n 's3Storage',\n 'vercelBlobStorage',\n] as const\n\nexport type StorageAdapter = (typeof ALL_STORAGE_ADAPTERS)[number]\n\nexport type TransformOptions = {\n databaseAdapter?: {\n envVarName?: string\n type: DatabaseAdapter\n }\n removeSharp?: boolean\n storageAdapter?: {\n type: StorageAdapter\n }\n}\n\nexport type WriteOptions = {\n formatWithOxfmt?: boolean\n validateStructure?: boolean\n}\n\nexport type WriteResult = {\n error?: DetectionError\n success: boolean\n}\n\nexport type ConfigureOptions = {\n db?: {\n envVarName?: string\n type: DatabaseAdapter\n }\n removeSharp?: boolean\n storage?: StorageAdapter\n} & WriteOptions\n"],"names":["ALL_DATABASE_ADAPTERS","ALL_STORAGE_ADAPTERS"],"mappings":"AAuHA,OAAO,MAAMA,wBAAwB;IACnC;IACA;IACA;IACA;IACA;CACD,CAAS;AAEV,OAAO,MAAMC,uBAAuB;IAClC;IACA;IACA;IACA;IACA;IACA;CACD,CAAS"}
|
|
@@ -54,7 +54,7 @@ import { configurePayloadConfig as configurePayloadConfigAST } from './ast/paylo
|
|
|
54
54
|
type: args.dbType,
|
|
55
55
|
envVarName
|
|
56
56
|
},
|
|
57
|
-
|
|
57
|
+
formatWithOxfmt: true,
|
|
58
58
|
removeSharp: args.sharp === false,
|
|
59
59
|
storage: args.storageAdapter,
|
|
60
60
|
validateStructure: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/configure-payload-config.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport globby from 'globby'\nimport path from 'path'\n\nimport type { DbType, StorageAdapterType } from '../types.js'\n\nimport { warning } from '../utils/log.js'\nimport { updatePackageJson } from './ast/package-json.js'\nimport { configurePayloadConfig as configurePayloadConfigAST } from './ast/payload-config.js'\n\n/** Get default env var name for db type */\nfunction getEnvVarName(dbType: DbType, customEnvName?: string): string {\n if (customEnvName) {\n return customEnvName\n }\n // Default env var names per adapter type\n if (dbType === 'vercel-postgres') {\n return 'POSTGRES_URL'\n }\n return 'DATABASE_URL'\n}\n\n/** Update payload config with necessary imports and adapters */\nexport async function configurePayloadConfig(args: {\n dbType?: DbType\n envNames?: {\n dbUri: string\n }\n packageJsonName?: string\n projectDirOrConfigPath: { payloadConfigPath: string } | { projectDir: string }\n sharp?: boolean\n storageAdapter?: StorageAdapterType\n}): Promise<void> {\n if (!args.dbType) {\n return\n }\n\n // Update package.json\n const packageJsonPath =\n 'projectDir' in args.projectDirOrConfigPath &&\n path.resolve(args.projectDirOrConfigPath.projectDir, 'package.json')\n\n if (packageJsonPath && fse.existsSync(packageJsonPath)) {\n try {\n updatePackageJson(packageJsonPath, {\n databaseAdapter: args.dbType,\n packageName: args.packageJsonName,\n removeSharp: args.sharp === false,\n storageAdapter: args.storageAdapter,\n })\n } catch (err: unknown) {\n warning(`Unable to configure Payload in package.json`)\n warning(err instanceof Error ? err.message : '')\n }\n }\n\n // Update payload.config.ts\n try {\n let payloadConfigPath: string | undefined\n if (!('payloadConfigPath' in args.projectDirOrConfigPath)) {\n payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: args.projectDirOrConfigPath.projectDir,\n })\n )?.[0]\n } else {\n payloadConfigPath = args.projectDirOrConfigPath.payloadConfigPath\n }\n\n if (!payloadConfigPath) {\n warning('Unable to update payload.config.ts with plugins. Could not find payload.config.ts.')\n return\n }\n\n const envVarName = getEnvVarName(args.dbType, args.envNames?.dbUri)\n\n const result = await configurePayloadConfigAST(payloadConfigPath, {\n db: {\n type: args.dbType,\n envVarName,\n },\n
|
|
1
|
+
{"version":3,"sources":["../../src/lib/configure-payload-config.ts"],"sourcesContent":["import fse from 'fs-extra'\nimport globby from 'globby'\nimport path from 'path'\n\nimport type { DbType, StorageAdapterType } from '../types.js'\n\nimport { warning } from '../utils/log.js'\nimport { updatePackageJson } from './ast/package-json.js'\nimport { configurePayloadConfig as configurePayloadConfigAST } from './ast/payload-config.js'\n\n/** Get default env var name for db type */\nfunction getEnvVarName(dbType: DbType, customEnvName?: string): string {\n if (customEnvName) {\n return customEnvName\n }\n // Default env var names per adapter type\n if (dbType === 'vercel-postgres') {\n return 'POSTGRES_URL'\n }\n return 'DATABASE_URL'\n}\n\n/** Update payload config with necessary imports and adapters */\nexport async function configurePayloadConfig(args: {\n dbType?: DbType\n envNames?: {\n dbUri: string\n }\n packageJsonName?: string\n projectDirOrConfigPath: { payloadConfigPath: string } | { projectDir: string }\n sharp?: boolean\n storageAdapter?: StorageAdapterType\n}): Promise<void> {\n if (!args.dbType) {\n return\n }\n\n // Update package.json\n const packageJsonPath =\n 'projectDir' in args.projectDirOrConfigPath &&\n path.resolve(args.projectDirOrConfigPath.projectDir, 'package.json')\n\n if (packageJsonPath && fse.existsSync(packageJsonPath)) {\n try {\n updatePackageJson(packageJsonPath, {\n databaseAdapter: args.dbType,\n packageName: args.packageJsonName,\n removeSharp: args.sharp === false,\n storageAdapter: args.storageAdapter,\n })\n } catch (err: unknown) {\n warning(`Unable to configure Payload in package.json`)\n warning(err instanceof Error ? err.message : '')\n }\n }\n\n // Update payload.config.ts\n try {\n let payloadConfigPath: string | undefined\n if (!('payloadConfigPath' in args.projectDirOrConfigPath)) {\n payloadConfigPath = (\n await globby('**/payload.config.ts', {\n absolute: true,\n cwd: args.projectDirOrConfigPath.projectDir,\n })\n )?.[0]\n } else {\n payloadConfigPath = args.projectDirOrConfigPath.payloadConfigPath\n }\n\n if (!payloadConfigPath) {\n warning('Unable to update payload.config.ts with plugins. Could not find payload.config.ts.')\n return\n }\n\n const envVarName = getEnvVarName(args.dbType, args.envNames?.dbUri)\n\n const result = await configurePayloadConfigAST(payloadConfigPath, {\n db: {\n type: args.dbType,\n envVarName,\n },\n formatWithOxfmt: true,\n removeSharp: args.sharp === false,\n storage: args.storageAdapter,\n validateStructure: false,\n })\n\n if (!result.success && result.error) {\n warning(`Unable to update payload.config.ts: ${result.error.userMessage}`)\n }\n } catch (err: unknown) {\n warning(\n `Unable to update payload.config.ts with plugins: ${err instanceof Error ? err.message : ''}`,\n )\n }\n}\n"],"names":["fse","globby","path","warning","updatePackageJson","configurePayloadConfig","configurePayloadConfigAST","getEnvVarName","dbType","customEnvName","args","packageJsonPath","projectDirOrConfigPath","resolve","projectDir","existsSync","databaseAdapter","packageName","packageJsonName","removeSharp","sharp","storageAdapter","err","Error","message","payloadConfigPath","absolute","cwd","envVarName","envNames","dbUri","result","db","type","formatWithOxfmt","storage","validateStructure","success","error","userMessage"],"mappings":"AAAA,OAAOA,SAAS,WAAU;AAC1B,OAAOC,YAAY,SAAQ;AAC3B,OAAOC,UAAU,OAAM;AAIvB,SAASC,OAAO,QAAQ,kBAAiB;AACzC,SAASC,iBAAiB,QAAQ,wBAAuB;AACzD,SAASC,0BAA0BC,yBAAyB,QAAQ,0BAAyB;AAE7F,yCAAyC,GACzC,SAASC,cAAcC,MAAc,EAAEC,aAAsB;IAC3D,IAAIA,eAAe;QACjB,OAAOA;IACT;IACA,yCAAyC;IACzC,IAAID,WAAW,mBAAmB;QAChC,OAAO;IACT;IACA,OAAO;AACT;AAEA,8DAA8D,GAC9D,OAAO,eAAeH,uBAAuBK,IAS5C;IACC,IAAI,CAACA,KAAKF,MAAM,EAAE;QAChB;IACF;IAEA,sBAAsB;IACtB,MAAMG,kBACJ,gBAAgBD,KAAKE,sBAAsB,IAC3CV,KAAKW,OAAO,CAACH,KAAKE,sBAAsB,CAACE,UAAU,EAAE;IAEvD,IAAIH,mBAAmBX,IAAIe,UAAU,CAACJ,kBAAkB;QACtD,IAAI;YACFP,kBAAkBO,iBAAiB;gBACjCK,iBAAiBN,KAAKF,MAAM;gBAC5BS,aAAaP,KAAKQ,eAAe;gBACjCC,aAAaT,KAAKU,KAAK,KAAK;gBAC5BC,gBAAgBX,KAAKW,cAAc;YACrC;QACF,EAAE,OAAOC,KAAc;YACrBnB,QAAQ,CAAC,2CAA2C,CAAC;YACrDA,QAAQmB,eAAeC,QAAQD,IAAIE,OAAO,GAAG;QAC/C;IACF;IAEA,2BAA2B;IAC3B,IAAI;QACF,IAAIC;QACJ,IAAI,CAAE,CAAA,uBAAuBf,KAAKE,sBAAsB,AAAD,GAAI;YACzDa,oBACE,CAAA,MAAMxB,OAAO,wBAAwB;gBACnCyB,UAAU;gBACVC,KAAKjB,KAAKE,sBAAsB,CAACE,UAAU;YAC7C,EAAC,GACA,CAAC,EAAE;QACR,OAAO;YACLW,oBAAoBf,KAAKE,sBAAsB,CAACa,iBAAiB;QACnE;QAEA,IAAI,CAACA,mBAAmB;YACtBtB,QAAQ;YACR;QACF;QAEA,MAAMyB,aAAarB,cAAcG,KAAKF,MAAM,EAAEE,KAAKmB,QAAQ,EAAEC;QAE7D,MAAMC,SAAS,MAAMzB,0BAA0BmB,mBAAmB;YAChEO,IAAI;gBACFC,MAAMvB,KAAKF,MAAM;gBACjBoB;YACF;YACAM,iBAAiB;YACjBf,aAAaT,KAAKU,KAAK,KAAK;YAC5Be,SAASzB,KAAKW,cAAc;YAC5Be,mBAAmB;QACrB;QAEA,IAAI,CAACL,OAAOM,OAAO,IAAIN,OAAOO,KAAK,EAAE;YACnCnC,QAAQ,CAAC,oCAAoC,EAAE4B,OAAOO,KAAK,CAACC,WAAW,EAAE;QAC3E;IACF,EAAE,OAAOjB,KAAc;QACrBnB,QACE,CAAC,iDAAiD,EAAEmB,eAAeC,QAAQD,IAAIE,OAAO,GAAG,IAAI;IAEjG;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/download-example.ts"],"sourcesContent":["import { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream/promises'\nimport { x } from 'tar'\n\nimport type { ProjectExample } from '../types.js'\n\nimport { debug as debugLog } from '../utils/log.js'\n\nexport async function downloadExample({\n debug,\n example,\n projectDir,\n}: {\n debug?: boolean\n example: ProjectExample\n projectDir: string\n}) {\n const branchOrTag = example.url.split('#')?.[1] || 'latest'\n const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branchOrTag}`\n const filter = `payload-${branchOrTag.replace(/^v/, '')}/examples/${example.name}/`\n\n if (debug) {\n debugLog(`Using example url: ${example.url}`)\n debugLog(`Codeload url: ${url}`)\n debugLog(`Filter: ${filter}`)\n }\n\n await pipeline(\n await downloadTarStream(url),\n x({\n cwd: projectDir,\n filter: (p) => p.includes(filter),\n strip: 2 + example.name.split('/').length,\n }),\n )\n}\n\nasync function downloadTarStream(url: string) {\n const res = await fetch(url)\n\n if (!res.body) {\n throw new Error(`Failed to download: ${url}`)\n }\n\n return Readable.from(res.body
|
|
1
|
+
{"version":3,"sources":["../../src/lib/download-example.ts"],"sourcesContent":["import { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream/promises'\nimport { x } from 'tar'\n\nimport type { ProjectExample } from '../types.js'\n\nimport { debug as debugLog } from '../utils/log.js'\n\nexport async function downloadExample({\n debug,\n example,\n projectDir,\n}: {\n debug?: boolean\n example: ProjectExample\n projectDir: string\n}) {\n const branchOrTag = example.url.split('#')?.[1] || 'latest'\n const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branchOrTag}`\n const filter = `payload-${branchOrTag.replace(/^v/, '')}/examples/${example.name}/`\n\n if (debug) {\n debugLog(`Using example url: ${example.url}`)\n debugLog(`Codeload url: ${url}`)\n debugLog(`Filter: ${filter}`)\n }\n\n await pipeline(\n await downloadTarStream(url),\n x({\n cwd: projectDir,\n filter: (p) => p.includes(filter),\n strip: 2 + example.name.split('/').length,\n }),\n )\n}\n\nasync function downloadTarStream(url: string) {\n const res = await fetch(url)\n\n if (!res.body) {\n throw new Error(`Failed to download: ${url}`)\n }\n\n return Readable.from(res.body)\n}\n"],"names":["Readable","pipeline","x","debug","debugLog","downloadExample","example","projectDir","branchOrTag","url","split","filter","replace","name","downloadTarStream","cwd","p","includes","strip","length","res","fetch","body","Error","from"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAa;AACtC,SAASC,QAAQ,QAAQ,uBAAsB;AAC/C,SAASC,CAAC,QAAQ,MAAK;AAIvB,SAASC,SAASC,QAAQ,QAAQ,kBAAiB;AAEnD,OAAO,eAAeC,gBAAgB,EACpCF,KAAK,EACLG,OAAO,EACPC,UAAU,EAKX;IACC,MAAMC,cAAcF,QAAQG,GAAG,CAACC,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI;IACnD,MAAMD,MAAM,CAAC,sDAAsD,EAAED,aAAa;IAClF,MAAMG,SAAS,CAAC,QAAQ,EAAEH,YAAYI,OAAO,CAAC,MAAM,IAAI,UAAU,EAAEN,QAAQO,IAAI,CAAC,CAAC,CAAC;IAEnF,IAAIV,OAAO;QACTC,SAAS,CAAC,mBAAmB,EAAEE,QAAQG,GAAG,EAAE;QAC5CL,SAAS,CAAC,cAAc,EAAEK,KAAK;QAC/BL,SAAS,CAAC,QAAQ,EAAEO,QAAQ;IAC9B;IAEA,MAAMV,SACJ,MAAMa,kBAAkBL,MACxBP,EAAE;QACAa,KAAKR;QACLI,QAAQ,CAACK,IAAMA,EAAEC,QAAQ,CAACN;QAC1BO,OAAO,IAAIZ,QAAQO,IAAI,CAACH,KAAK,CAAC,KAAKS,MAAM;IAC3C;AAEJ;AAEA,eAAeL,kBAAkBL,GAAW;IAC1C,MAAMW,MAAM,MAAMC,MAAMZ;IAExB,IAAI,CAACW,IAAIE,IAAI,EAAE;QACb,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAEd,KAAK;IAC9C;IAEA,OAAOT,SAASwB,IAAI,CAACJ,IAAIE,IAAI;AAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/download-template.ts"],"sourcesContent":["import { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream/promises'\nimport { x } from 'tar'\n\nimport type { ProjectTemplate } from '../types.js'\n\nimport { debug as debugLog } from '../utils/log.js'\n\nexport async function downloadTemplate({\n debug,\n projectDir,\n template,\n}: {\n debug?: boolean\n projectDir: string\n template: ProjectTemplate\n}) {\n const branchOrTag = template.url.split('#')?.[1] || 'latest'\n const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branchOrTag}`\n const filter = `payload-${branchOrTag.replace(/^v/, '').replaceAll('/', '-')}/templates/${template.name}/`\n\n if (debug) {\n debugLog(`Using template url: ${template.url}`)\n debugLog(`Codeload url: ${url}`)\n debugLog(`Filter: ${filter}`)\n }\n\n await pipeline(\n await downloadTarStream(url),\n x({\n cwd: projectDir,\n filter: (p) => p.includes(filter),\n strip: 2 + template.name.split('/').length,\n }),\n )\n}\n\nasync function downloadTarStream(url: string) {\n const res = await fetch(url)\n\n if (!res.body) {\n throw new Error(`Failed to download: ${url}`)\n }\n\n return Readable.from(res.body
|
|
1
|
+
{"version":3,"sources":["../../src/lib/download-template.ts"],"sourcesContent":["import { Readable } from 'node:stream'\nimport { pipeline } from 'node:stream/promises'\nimport { x } from 'tar'\n\nimport type { ProjectTemplate } from '../types.js'\n\nimport { debug as debugLog } from '../utils/log.js'\n\nexport async function downloadTemplate({\n debug,\n projectDir,\n template,\n}: {\n debug?: boolean\n projectDir: string\n template: ProjectTemplate\n}) {\n const branchOrTag = template.url.split('#')?.[1] || 'latest'\n const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branchOrTag}`\n const filter = `payload-${branchOrTag.replace(/^v/, '').replaceAll('/', '-')}/templates/${template.name}/`\n\n if (debug) {\n debugLog(`Using template url: ${template.url}`)\n debugLog(`Codeload url: ${url}`)\n debugLog(`Filter: ${filter}`)\n }\n\n await pipeline(\n await downloadTarStream(url),\n x({\n cwd: projectDir,\n filter: (p) => p.includes(filter),\n strip: 2 + template.name.split('/').length,\n }),\n )\n}\n\nasync function downloadTarStream(url: string) {\n const res = await fetch(url)\n\n if (!res.body) {\n throw new Error(`Failed to download: ${url}`)\n }\n\n return Readable.from(res.body)\n}\n"],"names":["Readable","pipeline","x","debug","debugLog","downloadTemplate","projectDir","template","branchOrTag","url","split","filter","replace","replaceAll","name","downloadTarStream","cwd","p","includes","strip","length","res","fetch","body","Error","from"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAa;AACtC,SAASC,QAAQ,QAAQ,uBAAsB;AAC/C,SAASC,CAAC,QAAQ,MAAK;AAIvB,SAASC,SAASC,QAAQ,QAAQ,kBAAiB;AAEnD,OAAO,eAAeC,iBAAiB,EACrCF,KAAK,EACLG,UAAU,EACVC,QAAQ,EAKT;IACC,MAAMC,cAAcD,SAASE,GAAG,CAACC,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI;IACpD,MAAMD,MAAM,CAAC,sDAAsD,EAAED,aAAa;IAClF,MAAMG,SAAS,CAAC,QAAQ,EAAEH,YAAYI,OAAO,CAAC,MAAM,IAAIC,UAAU,CAAC,KAAK,KAAK,WAAW,EAAEN,SAASO,IAAI,CAAC,CAAC,CAAC;IAE1G,IAAIX,OAAO;QACTC,SAAS,CAAC,oBAAoB,EAAEG,SAASE,GAAG,EAAE;QAC9CL,SAAS,CAAC,cAAc,EAAEK,KAAK;QAC/BL,SAAS,CAAC,QAAQ,EAAEO,QAAQ;IAC9B;IAEA,MAAMV,SACJ,MAAMc,kBAAkBN,MACxBP,EAAE;QACAc,KAAKV;QACLK,QAAQ,CAACM,IAAMA,EAAEC,QAAQ,CAACP;QAC1BQ,OAAO,IAAIZ,SAASO,IAAI,CAACJ,KAAK,CAAC,KAAKU,MAAM;IAC5C;AAEJ;AAEA,eAAeL,kBAAkBN,GAAW;IAC1C,MAAMY,MAAM,MAAMC,MAAMb;IAExB,IAAI,CAACY,IAAIE,IAAI,EAAE;QACb,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAEf,KAAK;IAC9C;IAEA,OAAOT,SAASyB,IAAI,CAACJ,IAAIE,IAAI;AAC/B"}
|
|
@@ -9,8 +9,8 @@ import { CollectionCards as CollectionCards_ab83ff7e88da8d3530831f296ec4756a } f
|
|
|
9
9
|
import { CollectionQueryWidget as CollectionQueryWidget_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
|
|
10
10
|
import { QueryPresetsWhereField as QueryPresetsWhereField_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
|
|
11
11
|
import { CollectionQuerySortField as CollectionQuerySortField_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { ActivityWidget as ActivityWidget_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
|
|
13
|
+
import { CollectionFilter as CollectionFilter_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
|
|
14
14
|
|
|
15
15
|
/** @type import('payload').ImportMap */
|
|
16
16
|
export const importMap = {
|
|
@@ -28,7 +28,6 @@ export const importMap = {
|
|
|
28
28
|
'@payloadcms/ui#QueryPresetsWhereField': QueryPresetsWhereField_3817bf644402e67bfe6577f60ef982de,
|
|
29
29
|
'@payloadcms/ui#CollectionQuerySortField':
|
|
30
30
|
CollectionQuerySortField_3817bf644402e67bfe6577f60ef982de,
|
|
31
|
-
'@payloadcms/ui/rsc#
|
|
32
|
-
'@payloadcms/ui#
|
|
33
|
-
RecentlyViewedCollectionsField_3817bf644402e67bfe6577f60ef982de,
|
|
31
|
+
'@payloadcms/ui/rsc#ActivityWidget': ActivityWidget_ab83ff7e88da8d3530831f296ec4756a,
|
|
32
|
+
'@payloadcms/ui#CollectionFilter': CollectionFilter_3817bf644402e67bfe6577f60ef982de,
|
|
34
33
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. MODIFY AT YOUR OWN RISK. */
|
|
2
|
-
import { payloadApiHandlers } from '@payloadcms/tanstack-start/
|
|
2
|
+
import { payloadApiHandlers } from '@payloadcms/tanstack-start/routes'
|
|
3
3
|
import { createFileRoute } from '@tanstack/react-router'
|
|
4
4
|
|
|
5
5
|
export const Route = createFileRoute('/_payload/api/$')({
|
|
@@ -8,8 +8,8 @@ import { CollectionCards as CollectionCards_ab83ff7e88da8d3530831f296ec4756a } f
|
|
|
8
8
|
import { CollectionQueryWidget as CollectionQueryWidget_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
|
|
9
9
|
import { QueryPresetsWhereField as QueryPresetsWhereField_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
|
|
10
10
|
import { CollectionQuerySortField as CollectionQuerySortField_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { ActivityWidget as ActivityWidget_ab83ff7e88da8d3530831f296ec4756a } from '@payloadcms/ui/rsc'
|
|
12
|
+
import { CollectionFilter as CollectionFilter_3817bf644402e67bfe6577f60ef982de } from '@payloadcms/ui'
|
|
13
13
|
|
|
14
14
|
/** @type import('payload').ImportMap */
|
|
15
15
|
export const importMap = {
|
|
@@ -26,7 +26,7 @@ export const importMap = {
|
|
|
26
26
|
'@payloadcms/ui#QueryPresetsWhereField': QueryPresetsWhereField_3817bf644402e67bfe6577f60ef982de,
|
|
27
27
|
'@payloadcms/ui#CollectionQuerySortField':
|
|
28
28
|
CollectionQuerySortField_3817bf644402e67bfe6577f60ef982de,
|
|
29
|
-
'@payloadcms/ui/rsc#
|
|
30
|
-
'@payloadcms/ui#
|
|
31
|
-
|
|
29
|
+
'@payloadcms/ui/rsc#ActivityWidget': ActivityWidget_ab83ff7e88da8d3530831f296ec4756a,
|
|
30
|
+
'@payloadcms/ui#CollectionFilter':
|
|
31
|
+
CollectionFilter_3817bf644402e67bfe6577f60ef982de,
|
|
32
32
|
}
|
|
@@ -33,16 +33,13 @@ const runPayloadServerFn = createServerFn({ method: 'POST' })
|
|
|
33
33
|
.validator((args: ServerFunctionClientArgs): ServerFunctionClientArgs => args)
|
|
34
34
|
.handler(async ({ data }) => {
|
|
35
35
|
const { handleServerFunctions } = await import('@payloadcms/tanstack-start/server')
|
|
36
|
-
|
|
36
|
+
return handleServerFunctions({
|
|
37
37
|
args: data.args,
|
|
38
38
|
config: await getConfig(),
|
|
39
39
|
importMap: await getImportMap(),
|
|
40
40
|
name: data.name,
|
|
41
|
+
requestURL: data.requestURL,
|
|
41
42
|
})
|
|
42
|
-
|
|
43
|
-
// TanStack validates the adapter-sanitized result at the server-function boundary.
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
-
return result as any
|
|
46
43
|
})
|
|
47
44
|
|
|
48
45
|
export const serverFunctionHandler = createServerFunctionClient({
|
package/package.json
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-payload-app",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.2d11d2e",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "https://github.com/payloadcms/payload.git",
|
|
8
|
-
"directory": "packages/create-payload-app"
|
|
9
|
-
},
|
|
10
5
|
"license": "MIT",
|
|
11
6
|
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
|
|
12
7
|
"maintainers": [
|
|
@@ -16,8 +11,21 @@
|
|
|
16
11
|
"url": "https://payloadcms.com"
|
|
17
12
|
}
|
|
18
13
|
],
|
|
19
|
-
"
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/payloadcms/payload.git",
|
|
17
|
+
"directory": "packages/create-payload-app"
|
|
18
|
+
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"create-payload-app": "bin/cli.js"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"package.json",
|
|
24
|
+
"dist",
|
|
25
|
+
"bin"
|
|
26
|
+
],
|
|
20
27
|
"type": "module",
|
|
28
|
+
"sideEffects": false,
|
|
21
29
|
"exports": {
|
|
22
30
|
"./types": {
|
|
23
31
|
"import": "./src/types.ts",
|
|
@@ -39,14 +47,6 @@
|
|
|
39
47
|
"types": "./src/utils/*"
|
|
40
48
|
}
|
|
41
49
|
},
|
|
42
|
-
"bin": {
|
|
43
|
-
"create-payload-app": "bin/cli.js"
|
|
44
|
-
},
|
|
45
|
-
"files": [
|
|
46
|
-
"package.json",
|
|
47
|
-
"dist",
|
|
48
|
-
"bin"
|
|
49
|
-
],
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@clack/prompts": "^0.7.0",
|
|
52
52
|
"@sindresorhus/slugify": "^1.1.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"figures": "^6.1.0",
|
|
60
60
|
"fs-extra": "^9.0.1",
|
|
61
61
|
"globby": "11.1.0",
|
|
62
|
-
"
|
|
62
|
+
"oxfmt": "^0.73.0",
|
|
63
63
|
"tar": "^7.5.22",
|
|
64
64
|
"terminal-link": "^2.1.1",
|
|
65
65
|
"ts-morph": "^28.0.0"
|
|
@@ -70,15 +70,13 @@
|
|
|
70
70
|
"@types/node": "24.12.3"
|
|
71
71
|
},
|
|
72
72
|
"engines": {
|
|
73
|
-
"node": ">=24.
|
|
73
|
+
"node": ">=24.22.1"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"build": "pnpm pack-template-files && pnpm typecheck && pnpm build:swc",
|
|
77
77
|
"build:debug": "pnpm build",
|
|
78
78
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
79
79
|
"clean": "rimraf -g {dist,*.tsbuildinfo}",
|
|
80
|
-
"lint": "eslint .",
|
|
81
|
-
"lint:fix": "eslint . --fix",
|
|
82
80
|
"pack-template-files": "node --no-deprecation --import @swc-node/register/esm-register src/scripts/pack-template-files.ts",
|
|
83
81
|
"test": "vitest --run",
|
|
84
82
|
"typecheck": "tsc"
|