@storyous/mongodb 1.7.4 → 1.8.1
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.
|
@@ -5,8 +5,10 @@ import { Logger } from 'winston';
|
|
|
5
5
|
* @param {string} directory Path to directory where migrations are
|
|
6
6
|
* @param {boolean} continueOnError If app crashes on error or continue
|
|
7
7
|
* @param {boolean} safeMigration Do not allow to rewrite all migrations with empty array
|
|
8
|
+
* @param {string} fileType specifies the file extension type to check in the migration folder
|
|
8
9
|
*/
|
|
9
|
-
export default function runMigrations(logger: Logger, directory: string, { continueOnError, safeMigration, }: {
|
|
10
|
+
export default function runMigrations(logger: Logger, directory: string, { continueOnError, safeMigration, fileType, }: {
|
|
10
11
|
continueOnError?: boolean | undefined;
|
|
11
12
|
safeMigration?: boolean | undefined;
|
|
13
|
+
fileType?: string | undefined;
|
|
12
14
|
}): Promise<void>;
|
|
@@ -11,13 +11,22 @@ const MigrationsStore_1 = __importDefault(require("./MigrationsStore"));
|
|
|
11
11
|
* @param {string} directory Path to directory where migrations are
|
|
12
12
|
* @param {boolean} continueOnError If app crashes on error or continue
|
|
13
13
|
* @param {boolean} safeMigration Do not allow to rewrite all migrations with empty array
|
|
14
|
+
* @param {string} fileType specifies the file extension type to check in the migration folder
|
|
14
15
|
*/
|
|
15
|
-
async function runMigrations(logger, directory, { continueOnError = false, safeMigration = true, }) {
|
|
16
|
+
async function runMigrations(logger, directory, { continueOnError = false, safeMigration = true, fileType = 'js', }) {
|
|
16
17
|
return new Promise((resolve, reject) => {
|
|
17
18
|
(0, migrate_1.load)({
|
|
18
19
|
stateStore: new MigrationsStore_1.default(logger, directory, safeMigration),
|
|
19
20
|
migrationsDirectory: directory,
|
|
20
|
-
filterFunction: (file) =>
|
|
21
|
+
filterFunction: ((file) => {
|
|
22
|
+
if (fileType === 'js') {
|
|
23
|
+
return file.endsWith('.js');
|
|
24
|
+
}
|
|
25
|
+
if (fileType === 'ts') {
|
|
26
|
+
return file.endsWith('.ts') && !file.endsWith('.d.ts');
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}),
|
|
21
30
|
}, (err, set) => {
|
|
22
31
|
if (err) {
|
|
23
32
|
logger.error('Migrations did not run due to error', err);
|
|
@@ -47,4 +56,4 @@ async function runMigrations(logger, directory, { continueOnError = false, safeM
|
|
|
47
56
|
});
|
|
48
57
|
}
|
|
49
58
|
exports.default = runMigrations;
|
|
50
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
59
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVuTWlncmF0aW9ucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInJ1bk1pZ3JhdGlvbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSxxQ0FBNkM7QUFFN0Msd0VBQWdEO0FBRWhEOzs7Ozs7O0dBT0c7QUFDWSxLQUFLLFVBQVUsYUFBYSxDQUN2QyxNQUFjLEVBQ2QsU0FBaUIsRUFDakIsRUFDSSxlQUFlLEdBQUcsS0FBSyxFQUN2QixhQUFhLEdBQUcsSUFBSSxFQUNwQixRQUFRLEdBQUcsSUFBSSxHQUNsQjtJQUVELE9BQU8sSUFBSSxPQUFPLENBQU8sQ0FBQyxPQUFPLEVBQUUsTUFBTSxFQUFFLEVBQUU7UUFDekMsSUFBQSxjQUFJLEVBQ0E7WUFDSSxVQUFVLEVBQUUsSUFBSSx5QkFBZSxDQUFDLE1BQU0sRUFBRSxTQUFTLEVBQUUsYUFBYSxDQUFDO1lBQ2pFLG1CQUFtQixFQUFFLFNBQVM7WUFDOUIsY0FBYyxFQUFFLENBQUMsQ0FBQyxJQUFZLEVBQUUsRUFBRTtnQkFDOUIsSUFBSSxRQUFRLEtBQUssSUFBSSxFQUFFO29CQUNuQixPQUFPLElBQUksQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLENBQUM7aUJBQy9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FO3dCQUNsQixNQUFNLENBQUMsS0FBSyxDQUFDLENBQUM7d0JBQ2QsT0FBTztxQkFDVjtpQkFDSjtxQkFBTTtvQkFDSCxNQUFNLENBQUMsSUFBSSxDQUFDLDZCQUE2QixDQUFDLENBQUM7aUJBQzlDO2dCQUVELE9BQU8sRUFBRSxDQUFDO1lBQ2QsQ0FBQyxDQUFDLENBQUM7UUFDUCxDQUFDLENBQUMsQ0FBQztJQUNYLENBQUMsQ0FBQyxDQUFDO0FBQ1AsQ0FBQztBQXRERCxnQ0FzREMifQ==
|
|
@@ -8,6 +8,7 @@ import MigrationsStore from './MigrationsStore';
|
|
|
8
8
|
* @param {string} directory Path to directory where migrations are
|
|
9
9
|
* @param {boolean} continueOnError If app crashes on error or continue
|
|
10
10
|
* @param {boolean} safeMigration Do not allow to rewrite all migrations with empty array
|
|
11
|
+
* @param {string} fileType specifies the file extension type to check in the migration folder
|
|
11
12
|
*/
|
|
12
13
|
export default async function runMigrations (
|
|
13
14
|
logger: Logger,
|
|
@@ -15,6 +16,7 @@ export default async function runMigrations (
|
|
|
15
16
|
{
|
|
16
17
|
continueOnError = false,
|
|
17
18
|
safeMigration = true,
|
|
19
|
+
fileType = 'js',
|
|
18
20
|
},
|
|
19
21
|
) {
|
|
20
22
|
return new Promise<void>((resolve, reject) => {
|
|
@@ -22,7 +24,15 @@ export default async function runMigrations (
|
|
|
22
24
|
{
|
|
23
25
|
stateStore: new MigrationsStore(logger, directory, safeMigration),
|
|
24
26
|
migrationsDirectory: directory,
|
|
25
|
-
filterFunction: (file: string) =>
|
|
27
|
+
filterFunction: ((file: string) => {
|
|
28
|
+
if (fileType === 'js') {
|
|
29
|
+
return file.endsWith('.js');
|
|
30
|
+
}
|
|
31
|
+
if (fileType === 'ts') {
|
|
32
|
+
return file.endsWith('.ts') && !file.endsWith('.d.ts');
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}),
|
|
26
36
|
},
|
|
27
37
|
(err: Error | null, set: MigrationSet) => {
|
|
28
38
|
if (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyous/mongodb",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://github.com/Storyous/mono-utils#readme",
|
|
6
6
|
"license": "ISC",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"mongodb": ">=4 <5"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "366ce4c335c01057f52cb01b4481821df7205129"
|
|
50
50
|
}
|