masterrecord 0.2.2 → 0.2.4

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.
Files changed (2) hide show
  1. package/Migrations/cli.js +23 -3
  2. package/package.json +2 -2
package/Migrations/cli.js CHANGED
@@ -1,14 +1,25 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // version 0.0.5
3
+ // version 0.0.6
4
4
  // https://docs.microsoft.com/en-us/ef/ef6/modeling/code-first/migrations/
5
5
  // how to add environment variables on cli call example - master=development masterrecord add-migration auth authContext
6
6
 
7
7
  const { program } = require('commander');
8
8
  let fs = require('fs');
9
9
  let path = require('path');
10
+ const Module = require('module');
11
+ // Alias require('masterrecord') to this global package so project files don't need a local install
12
+ const __MASTERRECORD_ROOT__ = path.join(__dirname, '..');
13
+ const __ORIGINAL_REQUIRE__ = Module.prototype.require;
14
+ Module.prototype.require = function(request) {
15
+ if (request === 'masterrecord') {
16
+ return __ORIGINAL_REQUIRE__.call(this, __MASTERRECORD_ROOT__);
17
+ }
18
+ return __ORIGINAL_REQUIRE__.call(this, request);
19
+ };
10
20
  var Migration = require('./migrations');
11
21
  var globSearch = require("glob");
22
+ const pkg = require(path.join(__dirname, '..', 'package.json'));
12
23
 
13
24
 
14
25
  const [,, ...args] = process.argv
@@ -16,9 +27,12 @@ const [,, ...args] = process.argv
16
27
 
17
28
 
18
29
  program
19
- .version('0.0.3')
30
+ .version(pkg.version, '-v, --version')
20
31
  .description('A ORM framework that facilitates the creation and use of business objects whose data requires persistent storage to a database');
21
32
 
33
+ // Support legacy '-V' as an alias to print version
34
+ program.option('-V', 'output the version');
35
+
22
36
  // Instructions : to run command you must go to main project folder is located and run the command using the context file name.
23
37
  program
24
38
  .command('enable-migrations <contextFileName>')
@@ -275,4 +289,10 @@ program
275
289
 
276
290
 
277
291
 
278
- program.parse(process.argv);
292
+ program.parse(process.argv);
293
+
294
+ // Handle manual '-V' alias
295
+ const opts = program.opts();
296
+ if (opts && opts.V) {
297
+ console.log(pkg.version);
298
+ }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "sync-mysql2" : "^1.0.6",
9
9
  "app-root-path": "^3.1.0"
10
10
  },
11
- "version": "0.2.2",
11
+ "version": "0.2.4",
12
12
  "description": "An Object-relational mapping for the Master framework. Master Record connects classes to relational database tables to establish a database with almost zero-configuration ",
13
13
  "homepage": "https://github.com/Tailor/MasterRecord#readme",
14
14
  "repository": {
@@ -22,6 +22,6 @@
22
22
  "author": "Alexander Rich",
23
23
  "license": "ISC",
24
24
  "bin": {
25
- "masterrecord": "./migrations/cli.js"
25
+ "masterrecord": "./Migrations/cli.js"
26
26
  }
27
27
  }