Skip to content

Commit

Permalink
feat: Add support to mongo v5 (#91)
Browse files Browse the repository at this point in the history
* Support for mongo v5
  • Loading branch information
gustawdaniel authored Aug 4, 2023
1 parent 2413295 commit 6c6e2bb
Show file tree
Hide file tree
Showing 5 changed files with 2,145 additions and 2,719 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ migrations
migrations.json
*.log
coverage
distexamples
distexamples
.idea
2 changes: 1 addition & 1 deletion __tests__/down.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
MigrationModel,
mongoConnect,
} from '../lib/database';
import { MigrationInterface } from '../lib/MigrationInterface';
import { MigrationInterface } from '../lib';
import { loadMigrationFile } from '../lib/migrations';
import { configMock } from './__mocks__/config.mock';
import { connectionMock } from './__mocks__/connection.mock';
Expand Down
10 changes: 5 additions & 5 deletions lib/commands/status.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cliTable from 'cli-table';
import CliTable from 'cli-table';
import { Config, processConfig } from '../config';
import {
getAppliedMigrations,
Expand All @@ -11,7 +11,7 @@ interface CommandStatusOptions {
config: Config;
}

export const status = async (opts: CommandStatusOptions) => {
export const status = async (opts: CommandStatusOptions): Promise<void> => {
const { uri, database, options, migrationsCollection, migrationsDir } =
processConfig(opts.config);
const connection = await mongoConnect(uri, database, options);
Expand All @@ -27,13 +27,13 @@ export const status = async (opts: CommandStatusOptions) => {
) === undefined
);

const table = new cliTable({
const table = new CliTable({
head: ['Migration', 'Status', 'Timestamp'],
colWidths: [100, 200],
});

appliedMigrations.map((migration: MigrationModel) => {
table.push([migration.className, 'up', migration.timestamp.toString()]);
table.push([migration.className, 'up', String(migration.timestamp)]);
});

notAppliedMigrations.map((migration: MigrationObject) => {
Expand All @@ -42,6 +42,6 @@ export const status = async (opts: CommandStatusOptions) => {

console.log(table.toString());
} finally {
connection.client.close();
await connection.client.close();
}
};
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.1",
"@semantic-release/npm": "^9.0.0",
"@semantic-release/npm": "^10.0.4",
"@semantic-release/release-notes-generator": "^10.0.3",
"@types/cli-table": "^0.3.1",
"@types/commander": "^2.12.2",
Expand All @@ -40,7 +40,7 @@
"husky": "^8.0.3",
"jest": "^29.5.0",
"lint-staged": "^12.3.2",
"mongodb": "^4.3.1",
"mongodb": "^5.7.0",
"prettier": "^2.5.1",
"rimraf": "^4.4.0",
"rollup": "^2.66.1",
Expand All @@ -49,7 +49,7 @@
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-typescript2": "^0.31.1",
"semantic-release": "^19.0.2",
"semantic-release": "^21.0.7",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
Expand All @@ -62,7 +62,7 @@
"ora": "^5.4.1"
},
"peerDependencies": {
"mongodb": "4.x.x"
"mongodb": "4.x.x || 5.x.x"
},
"lint-staged": {
"*.{ts,js}": [
Expand Down
Loading

0 comments on commit 6c6e2bb

Please sign in to comment.