pgroll 0.0.4 → 0.0.6

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.
@@ -4,14 +4,14 @@ const tslib_1 = require("tslib");
4
4
  const process = tslib_1.__importStar(require("node:process"));
5
5
  const commander_1 = require("commander");
6
6
  const postgres_1 = tslib_1.__importDefault(require("postgres"));
7
- const index_1 = require("@/index");
8
7
  const utils_1 = require("./utils");
8
+ const index_1 = require("./index");
9
9
  const program = new commander_1.Command();
10
10
  let migrator;
11
11
  program
12
12
  .version('0.0.1')
13
13
  .description('Database migration tool')
14
- .option('-d, --migrationDir <filepath>', 'Specify migration directory(Default: ./migration)')
14
+ .option('-d, --migrationDir <filepath>', 'Specify migration directory(Default: ./migrations)')
15
15
  .hook('preAction', cmd => {
16
16
  const opts = cmd.opts();
17
17
  migrator = new index_1.Migrator((0, postgres_1.default)(), opts.migrationDir);
@@ -23,6 +23,7 @@ program
23
23
  try {
24
24
  yield migrator.up({ eventHandler: console.log });
25
25
  console.log('Migrations up completed successfully.');
26
+ process.exit(0);
26
27
  }
27
28
  catch (error) {
28
29
  console.error('Error during migrations up:', error);
@@ -36,6 +37,7 @@ program
36
37
  try {
37
38
  yield migrator.down({ eventHandler: console.log });
38
39
  console.log('Migrations down completed successfully.');
40
+ process.exit(0);
39
41
  }
40
42
  catch (error) {
41
43
  console.error('Error during migrations down:', error);
@@ -50,6 +52,7 @@ program
50
52
  const result = (0, utils_1.createFile)(migrator.migrationsDir, fileName);
51
53
  for (const f of result)
52
54
  console.log(`Successfully created migration files: ${f}`);
55
+ process.exit(0);
53
56
  });
54
57
  program
55
58
  .command('go')
@@ -63,6 +66,7 @@ program
63
66
  }
64
67
  try {
65
68
  yield migrator.go(parsedVersion, { eventHandler: console.log });
69
+ process.exit(0);
66
70
  }
67
71
  catch (error) {
68
72
  console.error('Error during migrations:', error);
@@ -1,5 +1,5 @@
1
1
  import { ReservedSql, Sql } from 'postgres';
2
- import { Direction } from '@/utils';
2
+ import { Direction } from './utils';
3
3
  interface Option {
4
4
  eventHandler: (info: string) => void;
5
5
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Migrator = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
6
- const utils_1 = require("@/utils");
6
+ const utils_1 = require("./utils");
7
7
  class Migrator {
8
8
  constructor(dbClient, migrationsDir = '') {
9
9
  Object.defineProperty(this, "dbClient", {
@@ -2,14 +2,14 @@ import { __awaiter } from "tslib";
2
2
  import * as process from 'node:process';
3
3
  import { Command } from 'commander';
4
4
  import postgres from 'postgres';
5
- import { Migrator } from '@/index';
6
5
  import { createFile } from './utils';
6
+ import { Migrator } from './index';
7
7
  const program = new Command();
8
8
  let migrator;
9
9
  program
10
10
  .version('0.0.1')
11
11
  .description('Database migration tool')
12
- .option('-d, --migrationDir <filepath>', 'Specify migration directory(Default: ./migration)')
12
+ .option('-d, --migrationDir <filepath>', 'Specify migration directory(Default: ./migrations)')
13
13
  .hook('preAction', cmd => {
14
14
  const opts = cmd.opts();
15
15
  migrator = new Migrator(postgres(), opts.migrationDir);
@@ -21,6 +21,7 @@ program
21
21
  try {
22
22
  yield migrator.up({ eventHandler: console.log });
23
23
  console.log('Migrations up completed successfully.');
24
+ process.exit(0);
24
25
  }
25
26
  catch (error) {
26
27
  console.error('Error during migrations up:', error);
@@ -34,6 +35,7 @@ program
34
35
  try {
35
36
  yield migrator.down({ eventHandler: console.log });
36
37
  console.log('Migrations down completed successfully.');
38
+ process.exit(0);
37
39
  }
38
40
  catch (error) {
39
41
  console.error('Error during migrations down:', error);
@@ -48,6 +50,7 @@ program
48
50
  const result = createFile(migrator.migrationsDir, fileName);
49
51
  for (const f of result)
50
52
  console.log(`Successfully created migration files: ${f}`);
53
+ process.exit(0);
51
54
  });
52
55
  program
53
56
  .command('go')
@@ -61,6 +64,7 @@ program
61
64
  }
62
65
  try {
63
66
  yield migrator.go(parsedVersion, { eventHandler: console.log });
67
+ process.exit(0);
64
68
  }
65
69
  catch (error) {
66
70
  console.error('Error during migrations:', error);
@@ -1,5 +1,5 @@
1
1
  import { ReservedSql, Sql } from 'postgres';
2
- import { Direction } from '@/utils';
2
+ import { Direction } from './utils';
3
3
  interface Option {
4
4
  eventHandler: (info: string) => void;
5
5
  }
@@ -1,6 +1,6 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import path from 'node:path';
3
- import { getMigrationFiles } from '@/utils';
3
+ import { getMigrationFiles } from './utils';
4
4
  export class Migrator {
5
5
  constructor(dbClient, migrationsDir = '') {
6
6
  Object.defineProperty(this, "dbClient", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgroll",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Postgres migration tool",
5
5
  "main": "dist/cjs/src/index.js",
6
6
  "module": "dist/esm/src/index.js",