Skip to content

Commit

Permalink
Merge remote-tracking branch 'prashantswami/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	package-lock.json
#	package.json
  • Loading branch information
seppevs committed Jan 29, 2025
2 parents 64b5a1f + 8156b4b commit b08b924
Show file tree
Hide file tree
Showing 9 changed files with 3,123 additions and 4,049 deletions.
7 changes: 4 additions & 3 deletions bin/migrate-mongo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#! /usr/bin/env node

const program = require("commander");
const _ = require("lodash");
const _isEmpty = require("lodash.isempty");
const _values = require("lodash.values");
const Table = require("cli-table3");
const migrateMongo = require("../lib/migrate-mongo");
const pkgjson = require("../package.json");
Expand All @@ -21,7 +22,7 @@ function printStatusTable(statusItems) {
return migrateMongo.config.read().then(config => {
const useFileHash = config.useFileHash === true;
const table = new Table({ head: useFileHash ? ["Filename", "Hash", "Applied At"] : ["Filename", "Applied At"]});
statusItems.forEach(item => table.push(_.values(item)));
statusItems.forEach(item => table.push(_values(item)));
console.log(table.toString());
})

Expand Down Expand Up @@ -123,6 +124,6 @@ program

program.parse(process.argv);

if (_.isEmpty(program.rawArgs)) {
if (_isEmpty(program.rawArgs)) {
program.outputHelp();
}
4 changes: 2 additions & 2 deletions lib/actions/down.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const _ = require("lodash");
const _last = require("lodash.last");
const { promisify } = require("util");
const fnArgs = require('fn-args');

Expand All @@ -11,7 +11,7 @@ module.exports = async (db, client) => {
const downgraded = [];
const statusItems = await status(db);
const appliedItems = statusItems.filter(item => item.appliedAt !== "PENDING");
const lastAppliedItem = _.last(appliedItems);
const lastAppliedItem = _last(appliedItems);

if (lastAppliedItem) {
try {
Expand Down
4 changes: 2 additions & 2 deletions lib/actions/status.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { find } = require("lodash");
const _find = require("lodash.find");
const migrationsDir = require("../env/migrationsDir");
const config = require("../env/config");

Expand All @@ -20,7 +20,7 @@ module.exports = async db => {
fileHash = await migrationsDir.loadFileHash(fileName);
findTest = { fileName, fileHash };
}
const itemInLog = find(changelog, findTest);
const itemInLog = _find(changelog, findTest);
const appliedAt = itemInLog ? itemInLog.appliedAt.toJSON() : "PENDING";
return useFileHash ? { fileName, fileHash, appliedAt } : { fileName, appliedAt };
}));
Expand Down
4 changes: 2 additions & 2 deletions lib/actions/up.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const _ = require("lodash");
const _filter = require("lodash.filter");
const pEachSeries = require("p-each-series");
const { promisify } = require("util");
const fnArgs = require('fn-args');
Expand All @@ -10,7 +10,7 @@ const hasCallback = require('../utils/has-callback');

module.exports = async (db, client) => {
const statusItems = await status(db);
const pendingItems = _.filter(statusItems, { appliedAt: "PENDING" });
const pendingItems = _filter(statusItems, { appliedAt: "PENDING" });
const migrated = [];

const migrateItem = async item => {
Expand Down
4 changes: 2 additions & 2 deletions lib/env/config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const fs = require("fs-extra");
const path = require("path");
const url = require("url");
const { get } = require("lodash");
const _get = require("lodash.get");
const moduleLoader = require('../utils/module-loader');

const DEFAULT_CONFIG_FILE_NAME = "migrate-mongo-config.js";

let customConfigContent = null;

function getConfigPath() {
const fileOptionValue = get(global.options, "file");
const fileOptionValue = _get(global.options, "file");
if (!fileOptionValue) {
return path.join(process.cwd(), DEFAULT_CONFIG_FILE_NAME);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/env/database.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const { MongoClient } = require("mongodb");
const _ = require("lodash");
const _get = require("lodash.get");
const config = require("./config");

module.exports = {
async connect() {
const configContent = await config.read();
const url = _.get(configContent, "mongodb.url");
const databaseName = _.get(configContent, "mongodb.databaseName");
const options = _.get(configContent, "mongodb.options");
const url = _get(configContent, "mongodb.url");
const databaseName = _get(configContent, "mongodb.databaseName");
const options = _get(configContent, "mongodb.options");

if (!url) {
throw new Error("No `url` defined in config file!");
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/has-callback.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const fnArgs = require('fn-args');
const { last } = require('lodash');
const _last = require('lodash.last');

module.exports = (func) => {

const argNames = fnArgs(func);
const lastArgName = last(argNames);
const lastArgName = _last(argNames);

return [
'callback',
Expand Down
Loading

0 comments on commit b08b924

Please sign in to comment.