@payloadcms/db-mongodb 3.0.0-alpha.46 → 3.0.0-alpha.47
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAoBvD,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAoBvD,eAAO,MAAM,eAAe,EAAE,eAoD7B,CAAA"}
|
package/dist/createMigration.js
CHANGED
|
@@ -31,7 +31,9 @@ export const createMigration = async function createMigration({ file, migrationN
|
|
|
31
31
|
const cleanPath = path.join(dirname, `../predefinedMigrations/${predefinedMigrationName}.js`);
|
|
32
32
|
// Check if predefined migration exists
|
|
33
33
|
if (fs.existsSync(cleanPath)) {
|
|
34
|
-
|
|
34
|
+
let migration = await eval(`${require ? 'require' : 'import'}(${cleanPath})`);
|
|
35
|
+
if ('default' in migration) migration = migration.default;
|
|
36
|
+
const { down, up } = migration;
|
|
35
37
|
migrationFileContent = migrationTemplate(up, down);
|
|
36
38
|
} else {
|
|
37
39
|
payload.logger.error({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { CreateMigration } from 'payload/database'\n\nimport fs from 'fs'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\n\nconst migrationTemplate = (upSQL?: string, downSQL?: string) => `import {\n MigrateUpArgs,\n MigrateDownArgs,\n} from \"@payloadcms/db-mongodb\";\n\nexport async function up({ payload }: MigrateUpArgs): Promise<void> {\n${upSQL ?? ` // Migration code`}\n};\n\nexport async function down({ payload }: MigrateDownArgs): Promise<void> {\n${downSQL ?? ` // Migration code`}\n};\n`\n\nexport const createMigration: CreateMigration = async function createMigration({\n file,\n migrationName,\n payload,\n}) {\n const filename = fileURLToPath(import.meta.url)\n const dirname = path.dirname(filename)\n\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n\n let migrationFileContent: string | undefined\n\n // Check for predefined migration.\n // Either passed in via --file or prefixed with @payloadcms/db-mongodb/\n if (file || migrationName?.startsWith('@payloadcms/db-mongodb/')) {\n if (!file) file = migrationName\n\n const predefinedMigrationName = file.replace('@payloadcms/db-mongodb/', '')\n migrationName = predefinedMigrationName\n const cleanPath = path.join(dirname, `../predefinedMigrations/${predefinedMigrationName}.js`)\n\n // Check if predefined migration exists\n if (fs.existsSync(cleanPath)) {\n
|
|
1
|
+
{"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { CreateMigration } from 'payload/database'\n\nimport fs from 'fs'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\n\nconst migrationTemplate = (upSQL?: string, downSQL?: string) => `import {\n MigrateUpArgs,\n MigrateDownArgs,\n} from \"@payloadcms/db-mongodb\";\n\nexport async function up({ payload }: MigrateUpArgs): Promise<void> {\n${upSQL ?? ` // Migration code`}\n};\n\nexport async function down({ payload }: MigrateDownArgs): Promise<void> {\n${downSQL ?? ` // Migration code`}\n};\n`\n\nexport const createMigration: CreateMigration = async function createMigration({\n file,\n migrationName,\n payload,\n}) {\n const filename = fileURLToPath(import.meta.url)\n const dirname = path.dirname(filename)\n\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n\n let migrationFileContent: string | undefined\n\n // Check for predefined migration.\n // Either passed in via --file or prefixed with @payloadcms/db-mongodb/\n if (file || migrationName?.startsWith('@payloadcms/db-mongodb/')) {\n if (!file) file = migrationName\n\n const predefinedMigrationName = file.replace('@payloadcms/db-mongodb/', '')\n migrationName = predefinedMigrationName\n const cleanPath = path.join(dirname, `../predefinedMigrations/${predefinedMigrationName}.js`)\n\n // Check if predefined migration exists\n if (fs.existsSync(cleanPath)) {\n let migration = await eval(`${require ? 'require' : 'import'}(${cleanPath})`)\n if ('default' in migration) migration = migration.default\n const { down, up } = migration\n\n migrationFileContent = migrationTemplate(up, down)\n } else {\n payload.logger.error({\n msg: `Canned migration ${predefinedMigrationName} not found.`,\n })\n process.exit(1)\n }\n } else {\n migrationFileContent = migrationTemplate()\n }\n\n const [yyymmdd, hhmmss] = new Date().toISOString().split('T')\n const formattedDate = yyymmdd.replace(/\\D/g, '')\n const formattedTime = hhmmss.split('.')[0].replace(/\\D/g, '')\n\n const timestamp = `${formattedDate}_${formattedTime}`\n\n const formattedName = migrationName?.replace(/\\W/g, '_')\n const fileName = migrationName ? `${timestamp}_${formattedName}.ts` : `${timestamp}_migration.ts`\n const filePath = `${dir}/${fileName}`\n fs.writeFileSync(filePath, migrationFileContent)\n payload.logger.info({ msg: `Migration created at ${filePath}` })\n}\n"],"names":["fs","path","fileURLToPath","migrationTemplate","upSQL","downSQL","createMigration","file","migrationName","payload","filename","url","dirname","dir","db","migrationDir","existsSync","mkdirSync","migrationFileContent","startsWith","predefinedMigrationName","replace","cleanPath","join","migration","eval","require","default","down","up","logger","error","msg","process","exit","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","formattedTime","timestamp","formattedName","fileName","filePath","writeFileSync","info"],"mappings":"AAAA,yDAAyD,GAGzD,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,aAAa,QAAQ,MAAK;AAEnC,MAAMC,oBAAoB,CAACC,OAAgBC,UAAqB,CAAC;;;;;;AAMjE,EAAED,SAAS,CAAC,mBAAmB,CAAC,CAAC;;;;AAIjC,EAAEC,WAAW,CAAC,mBAAmB,CAAC,CAAC;;AAEnC,CAAC;AAED,OAAO,MAAMC,kB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AE1D,MAAMqB,YAAY,CAAC,EAAEF,cAAc,CAAC,EAAEC,cAAc,CAAC;IAErD,MAAME,gBAAgBnC,eAAea,QAAQ,OAAO;IACpD,MAAMuB,WAAWpC,gBAAgB,CAAC,EAAEkC,UAAU,CAAC,EAAEC,cAAc,GAAG,CAAC,GAAG,CAAC,EAAED,UAAU,aAAa,CAAC;IACjG,MAAMG,WAAW,CAAC,EAAEhC,IAAI,CAAC,EAAE+B,SAAS,CAAC;IACrC5C,GAAG8C,aAAa,CAACD,UAAU3B;IAC3BT,QAAQqB,MAAM,CAACiB,IAAI,CAAC;QAAEf,KAAK,CAAC,qBAAqB,EAAEa,SAAS,CAAC;IAAC;AAChE,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/db-mongodb",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.47",
|
|
4
4
|
"description": "The officially supported MongoDB database adapter for Payload - Update 2",
|
|
5
5
|
"repository": "https://github.com/payloadcms/payload",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"mongodb": "4.17.1",
|
|
30
30
|
"mongodb-memory-server": "^9",
|
|
31
31
|
"@payloadcms/eslint-config": "1.1.1",
|
|
32
|
-
"payload": "3.0.0-alpha.
|
|
32
|
+
"payload": "3.0.0-alpha.47"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"payload": "3.0.0-alpha.
|
|
35
|
+
"payload": "3.0.0-alpha.47"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"registry": "https://registry.npmjs.org/"
|