create-payload-app 4.0.0-internal.a2d053c → 4.0.0-internal.a5acc33

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.
@@ -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,CA8DtE,CAAA;AAEV;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAEjE;AAED;;GAEG;AACH,wB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AAI,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;;;;;IAKvB,CAAC;QACDC,aAAa;IACf;IACAQ,WAAW;QACTV,aAAa;QACbC,gBAAgB,IAAM;QACtBC,aAAa;IACf;IACAS,WAAW;QACTX,aAAa;QACbC,gBAAgB,IAAM,CAAC;;;IAGvB,CAAC;QACDC,aAAa;IACf;IACAU,WAAW;QACTZ,aAAa;QACbC,gBAAgB,IAAM,CAAC;;;;;;;;;;;;IAYvB,CAAC;QACDC,aAAa;IACf;IACAW,mBAAmB;QACjBb,aAAa;QACbC,gBAAgB,IAAM,CAAC;;;;;IAKvB,CAAC;QACDC,aAAa;IACf;AACF,EAAU;AAEV;;CAEC,GACD,OAAO,SAASY,iBAAiBC,OAAwB;IACvD,OAAOhB,iBAAiB,CAACgB,QAAQ,CAACb,WAAW;AAC/C;AAEA;;CAEC,GACD,OAAO,SAASc,iBAAiBD,OAAwB;IACvD,OAAOhB,iBAAiB,CAACgB,QAAQ,CAACf,WAAW;AAC/C;AAEA;;CAEC,GACD,OAAO,SAASiB,sBAAsBF,OAAuB;IAC3D,OAAOR,sBAAsB,CAACQ,QAAQ,CAACb,WAAW;AACpD;AAEA;;CAEC,GACD,OAAO,SAASgB,sBAAsBH,OAAuB;IAC3D,OAAOR,sBAAsB,CAACQ,QAAQ,CAACf,WAAW;AACpD"}
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"],"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AOlB,iBAAiB,CAACkB,QAAQ,CAACf,WAAW;AAC/C;AAEA;;CAEC,GACD,OAAO,SAASgB,iBAAiBD,OAAwB;IACvD,OAAOlB,iBAAiB,CAACkB,QAAQ,CAACjB,WAAW;AAC/C;AAEA;;CAEC,GACD,OAAO,SAASmB,sBAAsBF,OAAuB;IAC3D,OAAOV,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;AAMjE,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
+ {"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
- if (transformed.dependencies.sharp) {
93
- delete transformed.dependencies.sharp;
94
- debug('[AST] Removed sharp dependency');
95
- } else {
96
- debug('[AST] Sharp dependency not found (already absent)');
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 { getDbPackageName, getStoragePackageName } 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 if (transformed.dependencies.sharp) {\n delete transformed.dependencies.sharp\n debug('[AST] Removed sharp dependency')\n } else {\n debug('[AST] Sharp dependency not found (already absent)')\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","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","sharp","addDependencies","removeDependencies","dependencyGroup","packageName","name"],"mappings":"AAAA,YAAYA,QAAQ,KAAI;AAIxB,SAASC,KAAK,QAAQ,qBAAoB;AAC1C,SAASC,gBAAgB,EAAEC,qBAAqB,QAAQ,sBAAqB;AAC7E,SAASC,qBAAqB,EAAEC,oBAAoB,QAAQ,aAAY;AAkBxE;;CAEC,GACD,OAAO,SAASC,kBAAkBC,QAAgB,EAAEC,OAAoC;IACtFP,MAAM,CAAC,6BAA6B,EAAEM,UAAU;IAEhD,MAAME,WAAWC,mBAAmB;QAAEH;QAAUC;IAAQ;IACxDR,GAAGW,aAAa,CAACF,SAASF,QAAQ,EAAEE,SAASG,OAAO;IAEpDX,MAAM;AACR;AAEA,OAAO,SAASS,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,E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AMC,eAAehC,QAAQ8B,kBAAkB,CAAE;gBACpD,OAAOvB,WAAW,CAACwB,gBAAgB,CAACC,YAAY;YAClD;QACF;IACF;IAEA,sBAAsB;IACtB,IAAIhC,QAAQgC,WAAW,EAAE;QACvBvC,MAAM,CAAC,+BAA+B,EAAEO,QAAQgC,WAAW,EAAE;QAC7DzB,YAAY0B,IAAI,GAAGjC,QAAQgC,WAAW;IACxC;IAEA,OAAOzB;AACT"}
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;IAA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AA;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,CA0JvB;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,GAAG,oBAAoB,CAkExE;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"}
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 plugins
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 plugins needed');
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 plugins array
291
- const pluginsPropertyRaw = objLiteral.getProperty('plugins');
292
- let pluginsProperty = pluginsPropertyRaw?.asKind(SyntaxKind.PropertyAssignment);
293
- // Check if it's a shorthand property (e.g., `plugins` referencing an imported variable)
294
- const shorthandProperty = pluginsPropertyRaw?.asKind(SyntaxKind.ShorthandPropertyAssignment);
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 plugins property, converting to long form with spread');
297
- // Get the identifier name (usually 'plugins')
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: plugins: [...plugins, newAdapter]
304
+ // Create new property with spread operator: storage: [...storage, newAdapter]
305
305
  objLiteral.insertPropertyAssignment(insertIndex, {
306
- name: 'plugins',
306
+ name: 'storage',
307
307
  initializer: `[...${identifierName}]`
308
308
  });
309
- pluginsProperty = objLiteral.getProperty('plugins')?.asKind(SyntaxKind.PropertyAssignment);
309
+ storageProperty = objLiteral.getProperty('storage')?.asKind(SyntaxKind.PropertyAssignment);
310
310
  modifications.push({
311
311
  type: 'property-added',
312
- description: `Converted shorthand plugins property to array with spread syntax`
312
+ description: `Converted shorthand storage property to array with spread syntax`
313
313
  });
314
- } else if (!pluginsProperty) {
315
- debug('[AST] Creating new plugins array');
316
- // Create plugins array
317
- objLiteral.addPropertyAssignment({
318
- name: 'plugins',
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
- pluginsProperty = objLiteral.getProperty('plugins')?.asKind(SyntaxKind.PropertyAssignment);
324
+ storageProperty = objLiteral.getProperty('storage')?.asKind(SyntaxKind.PropertyAssignment);
322
325
  modifications.push({
323
326
  type: 'property-added',
324
- description: `Created plugins array`
327
+ description: `Created storage array`
325
328
  });
326
329
  } else {
327
- debug('[AST] Reusing existing plugins array');
330
+ debug('[AST] Reusing existing storage array');
328
331
  }
329
- if (!pluginsProperty) {
332
+ if (!storageProperty) {
330
333
  return {
331
334
  error: formatError({
332
- actual: 'Failed to create or find plugins property',
335
+ actual: 'Failed to create or find storage property',
333
336
  context: 'storage adapter configuration',
334
- expected: 'plugins array property',
335
- technicalDetails: 'Could not create or access plugins property'
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 = pluginsProperty.getInitializer();
345
+ const initializer = storageProperty.getInitializer();
343
346
  if (!initializer || initializer.getKind() !== SyntaxKind.ArrayLiteralExpression) {
344
347
  return {
345
348
  error: formatError({
346
- actual: 'plugins property is not an array',
349
+ actual: 'storage property is not an array',
347
350
  context: 'storage adapter configuration',
348
- expected: 'plugins: [...]',
349
- technicalDetails: 'plugins property must be an array literal expression'
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 pluginsArray = initializer.asKindOrThrow(SyntaxKind.ArrayLiteralExpression);
359
+ const storageArray = initializer.asKindOrThrow(SyntaxKind.ArrayLiteralExpression);
357
360
  // Add storage adapter call
358
361
  const configText = config.configTemplate();
359
362
  if (configText) {
360
- pluginsArray.addElement(configText);
363
+ storageArray.addElement(configText);
361
364
  modifications.push({
362
365
  type: 'property-added',
363
- description: `Added ${adapter} to plugins array`
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 import
377
- const { removedIndex } = removeImportDeclaration({
378
- moduleSpecifier: 'sharp',
379
- sourceFile
380
- });
381
- if (removedIndex !== undefined) {
382
- modifications.push({
383
- type: 'import-removed',
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,
@@ -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 { 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"],"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","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"],"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,i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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":"AAAA,SAASA,QAAQ,QAAQ,gBAAe;AACxC,OAAOC,UAAU,OAAM;AACvB,SAEEC,OAAO,EACPC,SAAS,EAETC,UAAU,QACL,WAAU;AAajB,SAASC,KAAK,QAAQ,qBAAoB;AAC1C,SACEC,iBAAiB,EACjBC,sBAAsB,EACtBC,yBAAyB,EACzBC,sBAAsB,QACjB,sBAAqB;AAC5B,SACEC,oBAAoB,EACpBC,sBAAsB,EACtBC,WAAW,EACXC,uBAAuB,QAClB,aAAY;AAEnB,OAAO,SAASC,6BAA6BC,UAAsB;IACjEV,MAAM,CAAC,4CAA4C,EAAEU,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,OAASA,KAAKC,OAAO,OAAO;IAErC,MAAMC,YAAYJ,uBAAuBK;IACzC,MAAMC,kBAAkBF,YAAYA,UAAUG,OAAO,KAAK;IAE1DxB,MAAM,CAAC,iCAAiC,EAAEuB,iBAAiB;IAE3D,+DAA+D;IAC/D,MAAME,kBAAkBf,WACrBgB,oBAAoB,CAAC3B,WAAW4B,cAAc,EAC9Cb,IAAI,CAAC,CAACc;QACL,MAAMC,aAAaD,KAAKE,aAAa;QACrC,OAAOD,WAAWL,O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F;AACF;AAEA;;;CAGC,GACD,SAASyF,uBAAuB,EAAE5E,UAAU,EAA2C;IACrF,MAAMmH,iBAAiBnH,WAAWJ,WAAW,CAAC,WAAWC,OAAO/C,WAAWgD,kBAAkB;IAC7F,MAAMsH,eAAeD,gBAAgBE,qBAAqBvK,WAAW4C,uBAAuB;IAC5F,MAAM4H,uBAAuBF,cACzBxH,YAAY,iBACZC,OAAO/C,WAAWgD,kBAAkB;IACxC,MAAMyH,oBAAoBD,sBAAsBD,qBAC9CvK,WAAWuD,sBAAsB;IAGnC,IAAI,CAAC8G,kBAAkB,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"}
@@ -38,6 +38,7 @@ const runPayloadServerFn = createServerFn({ method: 'POST' })
38
38
  config: await getConfig(),
39
39
  importMap: await getImportMap(),
40
40
  name: data.name,
41
+ requestURL: data.requestURL,
41
42
  })
42
43
  })
43
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-payload-app",
3
- "version": "4.0.0-internal.a2d053c",
3
+ "version": "4.0.0-internal.a5acc33",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "license": "MIT",
6
6
  "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",