@verdnatura/myt 1.5.14 → 1.5.15

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.
@@ -1,6 +1,7 @@
1
1
  versionSchema: myt
2
2
  versionDigits: 5
3
3
  maxOldVersions: 20
4
+ mockDate: false
4
5
  sumViews: true
5
6
  schemas:
6
7
  - myt
package/myt-push.js CHANGED
@@ -321,16 +321,26 @@ class Push extends Command {
321
321
  const oldSum = engine.getShaSum(type, schema, name);
322
322
  const isEqual = newSql == oldSql;
323
323
 
324
+ let statusMsg;
325
+ if (exists && !oldSql)
326
+ statusMsg = '[+]'.green;
327
+ else if (!exists)
328
+ statusMsg = '[-]'.red;
329
+ else
330
+ statusMsg = '[·]'.yellow;
331
+
324
332
  let actionMsg;
325
- if ((exists && isEqual) || (!exists && !oldSql))
333
+ if (isEqual)
326
334
  actionMsg = '[I]'.blue;
327
- else if (exists)
328
- actionMsg = '[+]'.green;
329
335
  else
330
- actionMsg = '[-]'.red;
336
+ actionMsg = '[A]'.green;
331
337
 
332
338
  const typeMsg = `[${change.type.abbr}]`[change.type.color];
333
- console.log('', actionMsg.bold, typeMsg.bold, change.fullName);
339
+ console.log('',
340
+ (statusMsg + actionMsg).bold,
341
+ typeMsg.bold,
342
+ change.fullName
343
+ );
334
344
 
335
345
  if (!isEqual) {
336
346
  const scapedSchema = SqlString.escapeId(schema, true);
@@ -475,7 +485,7 @@ class Push extends Command {
475
485
 
476
486
  return routines.sort((a, b) => {
477
487
  if (b.mark != a.mark)
478
- return b.mark == '-' ? 1 : -1;
488
+ return b.mark == '-' ? -1 : 1;
479
489
 
480
490
  if (b.type.name !== a.type.name) {
481
491
  if (b.type.name == 'VIEW')
package/myt-run.js CHANGED
@@ -6,6 +6,7 @@ const fs = require('fs-extra');
6
6
  const path = require('path');
7
7
  const Server = require('./lib/server');
8
8
  const connExt = require('./lib/conn');
9
+ const SqlString = require('sqlstring');
9
10
 
10
11
  /**
11
12
  * Builds the database image and runs a container. It only rebuilds the
@@ -152,6 +153,20 @@ class Run extends Command {
152
153
  await connExt.queryFromFile(conn, `${triggersPath}/${triggerFile}`);
153
154
  }
154
155
 
156
+ // Mock date functions
157
+
158
+ console.log('Mocking date functions.');
159
+ const mockDateScript = path.join(dumpDir, 'mockDate.sql');
160
+
161
+ if (opts.mockDate) {
162
+ if (!await fs.pathExists(mockDateScript))
163
+ throw new Error(`Date mock enabled but mock script does not exist: ${mockDateScript}`);
164
+
165
+ let sql = await fs.readFile(mockDateScript, 'utf8');
166
+ sql = sql.replace(/@mockDate/g, SqlString.escape(opts.mockDate));
167
+ await connExt.multiQuery(conn, sql);
168
+ }
169
+
155
170
  return server;
156
171
  }
157
172
  }
package/myt.js CHANGED
@@ -120,8 +120,8 @@ class Myt {
120
120
  const wsPackageJson = require(wsPackageFile);
121
121
  try {
122
122
  depVersion = wsPackageJson
123
- .dependencies
124
- .myt.match(versionRegex);
123
+ .dependencies[packageJson.name]
124
+ .match(versionRegex);
125
125
  } catch (e) {}
126
126
  }
127
127
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdnatura/myt",
3
- "version": "1.5.14",
3
+ "version": "1.5.15",
4
4
  "author": "Verdnatura Levante SL",
5
5
  "description": "MySQL version control",
6
6
  "license": "GPL-3.0",