@payloadcms/db-mongodb 3.0.3-canary.5abb7d5 → 3.1.1-canary.952fd26

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,SAAS,CAAA;AAqBrE,eAAO,MAAM,eAAe,EAAE,eAmC7B,CAAA"}
1
+ {"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,SAAS,CAAA;AAqBrE,eAAO,MAAM,eAAe,EAAE,eAuC7B,CAAA"}
@@ -15,7 +15,7 @@ export async function down({ payload, req }: MigrateDownArgs): Promise<void> {
15
15
  ${downSQL ?? ` // Migration code`}
16
16
  }
17
17
  `;
18
- export const createMigration = async function createMigration({ file, migrationName, payload }) {
18
+ export const createMigration = async function createMigration({ file, migrationName, payload, skipEmpty }) {
19
19
  const filename = fileURLToPath(import.meta.url);
20
20
  const dirname = path.dirname(filename);
21
21
  const dir = payload.db.migrationDir;
@@ -36,7 +36,9 @@ export const createMigration = async function createMigration({ file, migrationN
36
36
  const formattedName = migrationName?.replace(/\W/g, '_');
37
37
  const fileName = migrationName ? `${timestamp}_${formattedName}.ts` : `${timestamp}_migration.ts`;
38
38
  const filePath = `${dir}/${fileName}`;
39
- fs.writeFileSync(filePath, migrationFileContent);
39
+ if (!skipEmpty) {
40
+ fs.writeFileSync(filePath, migrationFileContent);
41
+ }
40
42
  writeMigrationIndex({
41
43
  migrationsDir: payload.db.migrationDir
42
44
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["import type { CreateMigration, MigrationTemplateArgs } from 'payload'\n\nimport fs from 'fs'\nimport path from 'path'\nimport { getPredefinedMigration, writeMigrationIndex } from 'payload'\nimport { fileURLToPath } from 'url'\n\nconst migrationTemplate = ({ downSQL, imports, upSQL }: MigrationTemplateArgs): string => `import {\n MigrateDownArgs,\n MigrateUpArgs,\n} from '@payloadcms/db-mongodb'\n${imports ?? ''}\nexport async function up({ payload, req }: MigrateUpArgs): Promise<void> {\n${upSQL ?? ` // Migration code`}\n}\n\nexport async function down({ payload, req }: 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 const predefinedMigration = await getPredefinedMigration({\n dirname,\n file,\n migrationName,\n payload,\n })\n\n const migrationFileContent = migrationTemplate(predefinedMigration)\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\n writeMigrationIndex({ migrationsDir: payload.db.migrationDir })\n\n payload.logger.info({ msg: `Migration created at ${filePath}` })\n}\n"],"names":["fs","path","getPredefinedMigration","writeMigrationIndex","fileURLToPath","migrationTemplate","downSQL","imports","upSQL","createMigration","file","migrationName","payload","filename","url","dirname","dir","db","migrationDir","existsSync","mkdirSync","predefinedMigration","migrationFileContent","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","timestamp","formattedName","fileName","filePath","writeFileSync","migrationsDir","logger","info","msg"],"mappings":"AAEA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,sBAAsB,EAAEC,mBAAmB,QAAQ,UAAS;AACrE,SAASC,aA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,YAAY;IAAC;IAE7DN,QAAQyB,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK,CAAC,qBAAqB,EAAEL,SAAS,CAAC;IAAC;AAChE,EAAC"}
1
+ {"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["import type { CreateMigration, MigrationTemplateArgs } from 'payload'\n\nimport fs from 'fs'\nimport path from 'path'\nimport { getPredefinedMigration, writeMigrationIndex } from 'payload'\nimport { fileURLToPath } from 'url'\n\nconst migrationTemplate = ({ downSQL, imports, upSQL }: MigrationTemplateArgs): string => `import {\n MigrateDownArgs,\n MigrateUpArgs,\n} from '@payloadcms/db-mongodb'\n${imports ?? ''}\nexport async function up({ payload, req }: MigrateUpArgs): Promise<void> {\n${upSQL ?? ` // Migration code`}\n}\n\nexport async function down({ payload, req }: MigrateDownArgs): Promise<void> {\n${downSQL ?? ` // Migration code`}\n}\n`\n\nexport const createMigration: CreateMigration = async function createMigration({\n file,\n migrationName,\n payload,\n skipEmpty,\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 const predefinedMigration = await getPredefinedMigration({\n dirname,\n file,\n migrationName,\n payload,\n })\n\n const migrationFileContent = migrationTemplate(predefinedMigration)\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\n if (!skipEmpty) {\n fs.writeFileSync(filePath, migrationFileContent)\n }\n\n writeMigrationIndex({ migrationsDir: payload.db.migrationDir })\n\n payload.logger.info({ msg: `Migration created at ${filePath}` })\n}\n"],"names":["fs","path","getPredefinedMigration","writeMigrationIndex","fileURLToPath","migrationTemplate","downSQL","imports","upSQL","createMigration","file","migrationName","payload","skipEmpty","filename","url","dirname","dir","db","migrationDir","existsSync","mkdirSync","predefinedMigration","migrationFileContent","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","timestamp","formattedName","fileName","filePath","writeFileSync","migrationsDir","logger","info","msg"],"mappings":"AAEA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,sBAAsB,EAAEC,mBAAmB,QAAQ,UAAS;AACrE,SAASC,aAAa,QAAQ,MAAK;AAEnC,MAAMC,oBAAoB,CAAC,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAyB,GAAa,CAAC;;;;AAI3F,EAAED,WAAW,GAAG;;AAEhB,EAAEC,SAAS,CAAC,mBAAmB,CAAC,CAAC;;;;AAIjC,EAAEF,WAAW,CAAC,mBAAmB,CAAC,CAAC;;AAEnC,CAAC;AAED,OAAO,MAAMG,kBAAmC,eAAeA,gBAAgB,EAC7EC,IAAI,EACJC,aAAa,EACbC,OAAO,EACPC,SAAS,EACV;IACC,MAAMC,WAAWV,cAAc,YAAYW,GAAG;IAC9C,MAAMC,UAAUf,KAAKe,OAAO,CAACF;IAE7B,MAAMG,MAAML,QAAQM,EAAE,CAACC,YAAY;IACnC,IAAI,CAACnB,GAAGoB,UAAU,CAACH,MAAM;QACvBjB,GAAGqB,SAAS,CAACJ;IACf;IACA,MAAMK,sBAAsB,MAAMpB,uBAAuB;QACvDc;QACAN;QACAC;QACAC;IACF;IAEA,MAAMW,uBAAuBlB,kBAAkBiB;IAE/C,MAAM,CAACE,SAASC,OAAO,GAAG,IAAIC,OAAOC,WAAW,GAAGC,KAAK,CAAC;IACzD,MAAMC,gBAAgBL,QAAQM,OAAO,CAAC,OAAO;IAC7C,MAAMC,gBAAgBN,OAAOG,KAAK,CAAC,IAAI,CAAC,EAAE,CAACE,OAAO,CAAC,OAAO;IAE1D,MAAME,YAAY,CAAC,EAAEH,cAAc,CAAC,EAAEE,cAAc,CAAC;IAErD,MAAME,gBAAgBtB,eAAemB,QAAQ,OAAO;IACpD,MAAMI,WAAWvB,gBAAgB,CAAC,EAAEqB,UAAU,CAAC,EAAEC,cAAc,GAAG,CAAC,GAAG,CAAC,EAAED,UAAU,aAAa,CAAC;IACjG,MAAMG,WAAW,CAAC,EAAElB,IAAI,CAAC,EAAEiB,SAAS,CAAC;IAErC,IAAI,CAACrB,WAAW;QACdb,GAAGoC,aAAa,CAACD,UAAUZ;IAC7B;IAEApB,oBAAoB;QAAEkC,eAAezB,QAAQM,EAAE,CAACC,YAAY;IAAC;IAE7DP,QAAQ0B,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK,CAAC,qBAAqB,EAAEL,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.3-canary.5abb7d5",
3
+ "version": "3.1.1-canary.952fd26",
4
4
  "description": "The officially supported MongoDB database adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -49,10 +49,10 @@
49
49
  "mongodb": "6.10.0",
50
50
  "mongodb-memory-server": "^9",
51
51
  "@payloadcms/eslint-config": "3.0.0",
52
- "payload": "3.0.3-canary.5abb7d5"
52
+ "payload": "3.1.1-canary.952fd26"
53
53
  },
54
54
  "peerDependencies": {
55
- "payload": "3.0.3-canary.5abb7d5"
55
+ "payload": "3.1.1-canary.952fd26"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "pnpm build:types && pnpm build:swc",