Files
klz-cables.com/.pnpm-store/v10/files/b4/2c16c51ed324a087d555800ee5e0a28cffeec6cc78ec1d509d1653a5efa484f933e2e7e5f481ddb837c68b7ec87f38475fcd95ea142d8d6d6ad154a39522fd
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

1 line
5.0 KiB
Plaintext

{"version":3,"sources":["../../../src/database/migrations/getPredefinedMigration.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\n\nimport type { Payload } from '../../index.js'\nimport type { MigrationTemplateArgs } from '../types.js'\n\nimport { dynamicImport } from '../../utilities/dynamicImport.js'\n\n/**\n * Get predefined migration 'up', 'down' and 'imports'.\n *\n * Supports two import methods:\n * 1. @payloadcms/db-* packages: Loads from adapter's predefinedMigrations folder directly (no package.json export needed)\n * Example: `--file @payloadcms/db-mongodb/relationships-v2-v3`\n * 2. Any other package/path: Uses dynamic import via package.json exports or absolute file paths\n * Example: `--file @payloadcms/plugin-seo/someMigration` or `--file /absolute/path/to/migration.ts`\n */\nexport const getPredefinedMigration = async ({\n dirname,\n file,\n migrationName: migrationNameArg,\n payload,\n}: {\n dirname: string\n file?: string\n migrationName?: string\n payload: Payload\n}): Promise<MigrationTemplateArgs> => {\n const importPath = file ?? migrationNameArg\n\n // Path 1: @payloadcms/db-* adapters - load directly from predefinedMigrations folder\n // These don't need package.json exports; files are resolved relative to adapter's dirname\n if (importPath?.startsWith('@payloadcms/db-')) {\n const migrationName = importPath.split('/').slice(2).join('/')\n let cleanPath = path.join(dirname, `./predefinedMigrations/${migrationName}`)\n if (fs.existsSync(`${cleanPath}.mjs`)) {\n cleanPath = `${cleanPath}.mjs`\n } else if (fs.existsSync(`${cleanPath}.js`)) {\n cleanPath = `${cleanPath}.js`\n } else if (fs.existsSync(`${cleanPath}.ts`)) {\n // Support .ts in development when running from source\n cleanPath = `${cleanPath}.ts`\n } else {\n payload.logger.error({\n msg: `Canned migration ${migrationName} not found.`,\n })\n process.exit(1)\n }\n cleanPath = cleanPath.replaceAll('\\\\', '/')\n try {\n const { downSQL, dynamic, imports, upSQL } =\n await dynamicImport<MigrationTemplateArgs>(cleanPath)\n return {\n downSQL,\n dynamic,\n imports,\n upSQL,\n }\n } catch (err) {\n payload.logger.error({\n err,\n msg: `Error loading predefined migration ${migrationName}`,\n })\n process.exit(1)\n }\n } else if (importPath) {\n // Path 2: Any other package or file path - use dynamic import\n // Supports: package.json exports (e.g. @payloadcms/plugin-seo/migration) or absolute file paths\n try {\n const { downSQL, dynamic, imports, upSQL } =\n await dynamicImport<MigrationTemplateArgs>(importPath)\n return {\n downSQL,\n dynamic,\n imports,\n upSQL,\n }\n } catch (_err) {\n if (importPath?.includes('/')) {\n // We can assume that the intent was to import a file, thus we throw an error.\n throw new Error(`Error importing migration file from ${importPath}`)\n }\n // Silently fail. If the migration cannot be imported, it will be created as a blank migration and the import path will be used as the migration name.\n return {}\n }\n }\n return {}\n}\n"],"names":["fs","path","dynamicImport","getPredefinedMigration","dirname","file","migrationName","migrationNameArg","payload","importPath","startsWith","split","slice","join","cleanPath","existsSync","logger","error","msg","process","exit","replaceAll","downSQL","dynamic","imports","upSQL","err","_err","includes","Error"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AAKvB,SAASC,aAAa,QAAQ,mCAAkC;AAEhE;;;;;;;;CAQC,GACD,OAAO,MAAMC,yBAAyB,OAAO,EAC3CC,OAAO,EACPC,IAAI,EACJC,eAAeC,gBAAgB,EAC/BC,OAAO,EAMR;IACC,MAAMC,aAAaJ,QAAQE;IAE3B,qFA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