#4036 Project renamed to Myt
This commit is contained in:
parent
313655ea12
commit
d8a5133436
40
README.md
40
README.md
|
@ -1,4 +1,4 @@
|
|||
# MyVC (MySQL Version Control)
|
||||
# Myt - MySQL and MariaDB version control using Git
|
||||
|
||||
Utilities to ease the maintenance of MySQL or MariaDB database versioning using
|
||||
a Git repository.
|
||||
|
@ -16,23 +16,23 @@ development, so any help is welcomed! Feel free to contribute.
|
|||
It's recommended to install the package globally.
|
||||
|
||||
```text
|
||||
# npm install -g myvc
|
||||
$ myvc <command>
|
||||
# npm install -g myt
|
||||
$ myt <command>
|
||||
```
|
||||
|
||||
You can also install locally and use the *npx* command to execute it.
|
||||
|
||||
```text
|
||||
$ npm install myvc
|
||||
$ npx myvc <command>
|
||||
$ npm install myt
|
||||
$ npx myt <command>
|
||||
```
|
||||
|
||||
## How to use
|
||||
|
||||
Execute *myvc* with the desired command.
|
||||
Execute *myt* with the desired command.
|
||||
|
||||
```text
|
||||
$ [npx] myvc [-w|--workspace <string>] [-r|--remote <string>] [-d|--debug]
|
||||
$ [npx] myt [-w|--workspace <string>] [-r|--remote <string>] [-d|--debug]
|
||||
[-h|--help] <command> [<args>]
|
||||
```
|
||||
|
||||
|
@ -60,10 +60,10 @@ Each command can have its own specific commandline options.
|
|||
First of all you have to initalize the workspace.
|
||||
|
||||
```text
|
||||
$ myvc init
|
||||
$ myt init
|
||||
```
|
||||
|
||||
Now you can configure MyVC using *myvc.config.yml* file, located at the root of
|
||||
Now you can configure Myt using *myt.config.yml* file, located at the root of
|
||||
your workspace. This file should include the project codename and schemas/tables
|
||||
wich are exported when you use *pull* or *dump* commands.
|
||||
|
||||
|
@ -88,7 +88,7 @@ Once the basic configuration is done, routines can be imported from the
|
|||
database into the project, it is recommended to use the *production* remote.
|
||||
|
||||
```text
|
||||
$ myvc pull production
|
||||
$ myt pull production
|
||||
```
|
||||
|
||||
From now on, you can use the project as if it were a standard git repository
|
||||
|
@ -96,7 +96,7 @@ From now on, you can use the project as if it were a standard git repository
|
|||
desired remote.
|
||||
|
||||
```text
|
||||
$ myvc push [<remote>] [--commit]
|
||||
$ myt push [<remote>] [--commit]
|
||||
```
|
||||
|
||||
### Routines
|
||||
|
@ -157,7 +157,7 @@ You can create your local fixture and structure files.
|
|||
Initializes an empty workspace.
|
||||
|
||||
```text
|
||||
$ myvc init
|
||||
$ myt init
|
||||
```
|
||||
|
||||
### pull
|
||||
|
@ -165,7 +165,7 @@ $ myvc init
|
|||
Incorporates database routine changes into workspace.
|
||||
|
||||
```text
|
||||
$ myvc pull [remote] [-f|--force] [-c|--checkout] [-u|--update] [-s|--sums]
|
||||
$ myt pull [remote] [-f|--force] [-c|--checkout] [-u|--update] [-s|--sums]
|
||||
```
|
||||
|
||||
When *--checkout* option is provided, it does the following before export:
|
||||
|
@ -178,7 +178,7 @@ When *--checkout* option is provided, it does the following before export:
|
|||
Applies versions and routine changes into database.
|
||||
|
||||
```text
|
||||
$ myvc push [<remote>] [-f|--force] [-c|--commit] [-s|--sums]
|
||||
$ myt push [<remote>] [-f|--force] [-c|--commit] [-s|--sums]
|
||||
```
|
||||
|
||||
Commit is saved into database only if *--commit* option is provided, it
|
||||
|
@ -192,7 +192,7 @@ Creates a new version folder, when name is not specified it generates a random
|
|||
name mixing a color with a plant name.
|
||||
|
||||
```text
|
||||
$ myvc version [<name>]
|
||||
$ myt version [<name>]
|
||||
```
|
||||
|
||||
### clean
|
||||
|
@ -200,7 +200,7 @@ $ myvc version [<name>]
|
|||
Cleans all already applied versions older than *maxOldVersions*.
|
||||
|
||||
```text
|
||||
$ myvc clean
|
||||
$ myt clean
|
||||
```
|
||||
|
||||
## Local server commands
|
||||
|
@ -211,7 +211,7 @@ Exports database structure and fixtures from remote into hidden files located
|
|||
in *dump* folder. If no remote is specified *production* is used.
|
||||
|
||||
```text
|
||||
$ myvc dump [<remote>]
|
||||
$ myt dump [<remote>]
|
||||
```
|
||||
|
||||
### fixtures
|
||||
|
@ -220,7 +220,7 @@ Exports local database fixtures into *dump/fixtures.sql* files. If no remote is
|
|||
specified *local* is used.
|
||||
|
||||
```text
|
||||
$ myvc fixtures [<remote>]
|
||||
$ myt fixtures [<remote>]
|
||||
```
|
||||
|
||||
### run
|
||||
|
@ -230,7 +230,7 @@ when fixtures have been modified or when the day on which the image was built
|
|||
is different to today.
|
||||
|
||||
```text
|
||||
$ myvc run [-c|--ci] [-r|--random]
|
||||
$ myt run [-c|--ci] [-r|--random]
|
||||
```
|
||||
|
||||
### start
|
||||
|
@ -241,7 +241,7 @@ mind that when you do not rebuild the docker you may be using an outdated
|
|||
version of it.
|
||||
|
||||
```text
|
||||
$ myvc start
|
||||
$ myt start
|
||||
```
|
||||
|
||||
## Why
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
versionSchema: myvc
|
||||
versionSchema: myt
|
||||
versionDigits: 5
|
||||
maxOldVersions: 30
|
||||
schemas:
|
||||
- myvc
|
||||
- myt
|
||||
fixtures:
|
||||
myvc:
|
||||
myt:
|
||||
- version
|
||||
- versionLog
|
||||
|
|
4
cli.js
4
cli.js
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const MyVC = require('./myvc');
|
||||
new MyVC().run();
|
||||
const Myt = require('./myt');
|
||||
new Myt().run();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Base class for MyVC commands.
|
||||
* Base class for Myt commands.
|
||||
*/
|
||||
module.exports = class MyVCCommand {
|
||||
module.exports = class MytCommand {
|
||||
get usage() {
|
||||
return {};
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ module.exports = class MyVCCommand {
|
|||
return {};
|
||||
}
|
||||
|
||||
async run(myvc, opts) {
|
||||
async run(myt, opts) {
|
||||
throw new Error('run command not defined');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ const fs = require('fs-extra');
|
|||
const Exporter = require('./exporter');
|
||||
|
||||
module.exports = class ExporterEngine {
|
||||
constructor(conn, myvcDir) {
|
||||
constructor(conn, mytDir) {
|
||||
this.conn = conn;
|
||||
this.pullFile = `${myvcDir}/.pullinfo.json`;
|
||||
this.pullFile = `${mytDir}/.pullinfo.json`;
|
||||
this.exporters = [];
|
||||
this.exporterMap = {};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
const MyVC = require('./myvc');
|
||||
const Myt = require('./myt');
|
||||
const Command = require('./lib/command');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
|
@ -17,15 +17,15 @@ class Clean extends Command {
|
|||
}
|
||||
};
|
||||
|
||||
async run(myvc, opts) {
|
||||
await myvc.dbConnect();
|
||||
const version = await myvc.fetchDbVersion() || {};
|
||||
async run(myt, opts) {
|
||||
await myt.dbConnect();
|
||||
const version = await myt.fetchDbVersion() || {};
|
||||
const number = version.number;
|
||||
|
||||
const oldVersions = [];
|
||||
const versionDirs = await fs.readdir(opts.versionsDir);
|
||||
for (const versionDir of versionDirs) {
|
||||
const dirVersion = myvc.parseVersionDir(versionDir);
|
||||
const dirVersion = myt.parseVersionDir(versionDir);
|
||||
if (!dirVersion) continue;
|
||||
|
||||
if (parseInt(dirVersion.number) < parseInt(number))
|
||||
|
@ -49,4 +49,4 @@ class Clean extends Command {
|
|||
module.exports = Clean;
|
||||
|
||||
if (require.main === module)
|
||||
new MyVC().run(Clean);
|
||||
new Myt().run(Clean);
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
const MyVC = require('./myvc');
|
||||
const Myt = require('./myt');
|
||||
const Command = require('./lib/command');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
|
||||
class Dump extends Command {
|
||||
static usage = {
|
||||
|
@ -16,8 +15,8 @@ class Dump extends Command {
|
|||
}
|
||||
};
|
||||
|
||||
async run(myvc, opts) {
|
||||
const dumpStream = await myvc.initDump('.dump.sql');
|
||||
async run(myt, opts) {
|
||||
const dumpStream = await myt.initDump('.dump.sql');
|
||||
|
||||
console.log('Dumping structure.');
|
||||
let dumpArgs = [
|
||||
|
@ -30,10 +29,10 @@ class Dump extends Command {
|
|||
'--databases'
|
||||
];
|
||||
dumpArgs = dumpArgs.concat(opts.schemas);
|
||||
await myvc.runDump('docker-dump.sh', dumpArgs, dumpStream);
|
||||
await myt.runDump('docker-dump.sh', dumpArgs, dumpStream);
|
||||
|
||||
console.log('Dumping fixtures.');
|
||||
await myvc.dumpFixtures(dumpStream, opts.fixtures);
|
||||
await myt.dumpFixtures(dumpStream, opts.fixtures);
|
||||
|
||||
console.log('Dumping privileges.');
|
||||
const privs = opts.privileges;
|
||||
|
@ -48,14 +47,14 @@ class Dump extends Command {
|
|||
args = args.concat(['mysql'], privs.tables);
|
||||
|
||||
await dumpStream.write('USE `mysql`;\n', 'utf8');
|
||||
await myvc.runDump('mysqldump', args, dumpStream);
|
||||
await myt.runDump('mysqldump', args, dumpStream);
|
||||
}
|
||||
|
||||
await dumpStream.end();
|
||||
|
||||
console.log('Saving version.');
|
||||
await myvc.dbConnect();
|
||||
const version = await myvc.fetchDbVersion();
|
||||
await myt.dbConnect();
|
||||
const version = await myt.fetchDbVersion();
|
||||
if (version) {
|
||||
await fs.writeFile(
|
||||
`${opts.dumpDir}/.dump.json`,
|
||||
|
@ -68,5 +67,5 @@ class Dump extends Command {
|
|||
module.exports = Dump;
|
||||
|
||||
if (require.main === module)
|
||||
new MyVC().run(Dump);
|
||||
new Myt().run(Dump);
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
const MyVC = require('./myvc');
|
||||
const Myt = require('./myt');
|
||||
const Command = require('./lib/command');
|
||||
|
||||
class Fixtures extends Command {
|
||||
|
@ -14,9 +14,9 @@ class Fixtures extends Command {
|
|||
}
|
||||
};
|
||||
|
||||
async run(myvc, opts) {
|
||||
const dumpStream = await myvc.initDump('fixtures.sql');
|
||||
await myvc.dumpFixtures(dumpStream, opts.localFixtures, true);
|
||||
async run(myt, opts) {
|
||||
const dumpStream = await myt.initDump('fixtures.sql');
|
||||
await myt.dumpFixtures(dumpStream, opts.localFixtures, true);
|
||||
await dumpStream.end();
|
||||
}
|
||||
}
|
||||
|
@ -24,5 +24,5 @@ class Fixtures extends Command {
|
|||
module.exports = Fixtures;
|
||||
|
||||
if (require.main === module)
|
||||
new MyVC().run(Fixtures);
|
||||
new Myt().run(Fixtures);
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
const MyVC = require('./myvc');
|
||||
const Myt = require('./myt');
|
||||
const Command = require('./lib/command');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
|
@ -8,11 +8,11 @@ class Init extends Command {
|
|||
description: 'Initialize an empty workspace'
|
||||
};
|
||||
|
||||
async run(myvc, opts) {
|
||||
async run(myt, opts) {
|
||||
const templateDir = `${__dirname}/template`;
|
||||
const templates = await fs.readdir(templateDir);
|
||||
for (let template of templates) {
|
||||
const dst = `${opts.myvcDir}/${template}`;
|
||||
const dst = `${opts.mytDir}/${template}`;
|
||||
if (!await fs.pathExists(dst))
|
||||
await fs.copy(`${templateDir}/${template}`, dst);
|
||||
}
|
||||
|
@ -22,4 +22,4 @@ class Init extends Command {
|
|||
module.exports = Init;
|
||||
|
||||
if (require.main === module)
|
||||
new MyVC().run(Init);
|
||||
new Myt().run(Init);
|
|
@ -1,9 +1,10 @@
|
|||
|
||||
const MyVC = require('./myvc');
|
||||
const Myt = require('./myt');
|
||||
const Command = require('./lib/command');
|
||||
const fs = require('fs-extra');
|
||||
const nodegit = require('nodegit');
|
||||
const ExporterEngine = require('./lib/exporter-engine');
|
||||
|
||||
class Pull extends Command {
|
||||
static usage = {
|
||||
description: 'Incorporate database routine changes into workspace',
|
||||
|
@ -31,9 +32,9 @@ class Pull extends Command {
|
|||
]
|
||||
};
|
||||
|
||||
async run(myvc, opts) {
|
||||
const conn = await myvc.dbConnect();
|
||||
const repo = await myvc.openRepo();
|
||||
async run(myt, opts) {
|
||||
const conn = await myt.dbConnect();
|
||||
const repo = await myt.openRepo();
|
||||
|
||||
if (!opts.force) {
|
||||
async function hasChanges(diff) {
|
||||
|
@ -51,14 +52,14 @@ class Pull extends Command {
|
|||
|
||||
// Check for unstaged changes
|
||||
|
||||
const unstagedDiff = await myvc.getUnstaged(repo);
|
||||
const unstagedDiff = await myt.getUnstaged(repo);
|
||||
|
||||
if (await hasChanges(unstagedDiff))
|
||||
throw new Error('You have unstaged changes, save them before pull');
|
||||
|
||||
// Check for staged changes
|
||||
|
||||
const stagedDiff = await myvc.getStaged(repo);
|
||||
const stagedDiff = await myt.getStaged(repo);
|
||||
|
||||
if (await hasChanges(stagedDiff))
|
||||
throw new Error('You have staged changes, save them before pull');
|
||||
|
@ -67,15 +68,15 @@ class Pull extends Command {
|
|||
// Checkout to remote commit
|
||||
|
||||
if (opts.checkout) {
|
||||
const version = await myvc.fetchDbVersion();
|
||||
const version = await myt.fetchDbVersion();
|
||||
|
||||
if (version && version.gitCommit) {
|
||||
const now = parseInt(new Date().toJSON());
|
||||
const branchName = `myvc-pull_${now}`;
|
||||
const branchName = `myt-pull_${now}`;
|
||||
console.log(`Creating branch '${branchName}' from database commit.`);
|
||||
const commit = await repo.getCommit(version.gitCommit);
|
||||
const branch = await nodegit.Branch.create(repo,
|
||||
`myvc-pull_${now}`, commit, () => {});
|
||||
`myt-pull_${now}`, commit, () => {});
|
||||
await repo.checkoutBranch(branch);
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +85,7 @@ class Pull extends Command {
|
|||
|
||||
console.log(`Incorporating routine changes.`);
|
||||
|
||||
const engine = new ExporterEngine(conn, opts.myvcDir);
|
||||
const engine = new ExporterEngine(conn, opts.mytDir);
|
||||
await engine.init();
|
||||
const shaSums = engine.shaSums;
|
||||
|
||||
|
@ -125,4 +126,4 @@ class Pull extends Command {
|
|||
module.exports = Pull;
|
||||
|
||||
if (require.main === module)
|
||||
new MyVC().run(Pull);
|
||||
new Myt().run(Pull);
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
const MyVC = require('./myvc');
|
||||
const Myt = require('./myt');
|
||||
const Command = require('./lib/command');
|
||||
const fs = require('fs-extra');
|
||||
const nodegit = require('nodegit');
|
||||
|
@ -32,8 +32,8 @@ class Push extends Command {
|
|||
]
|
||||
};
|
||||
|
||||
async run(myvc, opts) {
|
||||
const conn = await myvc.dbConnect();
|
||||
async run(myt, opts) {
|
||||
const conn = await myt.dbConnect();
|
||||
this.conn = conn;
|
||||
|
||||
if (opts.remote == 'local')
|
||||
|
@ -42,14 +42,14 @@ class Push extends Command {
|
|||
// Obtain exclusive lock
|
||||
|
||||
const [[row]] = await conn.query(
|
||||
`SELECT GET_LOCK('myvc_push', 30) getLock`);
|
||||
`SELECT GET_LOCK('myt_push', 30) getLock`);
|
||||
|
||||
if (!row.getLock) {
|
||||
let isUsed = 0;
|
||||
|
||||
if (row.getLock == 0) {
|
||||
const [[row]] = await conn.query(
|
||||
`SELECT IS_USED_LOCK('myvc_push') isUsed`);
|
||||
`SELECT IS_USED_LOCK('myt_push') isUsed`);
|
||||
isUsed = row.isUsed;
|
||||
}
|
||||
|
||||
|
@ -57,11 +57,11 @@ class Push extends Command {
|
|||
}
|
||||
|
||||
async function releaseLock() {
|
||||
await conn.query(`DO RELEASE_LOCK('myvc_push')`);
|
||||
await conn.query(`DO RELEASE_LOCK('myt_push')`);
|
||||
}
|
||||
|
||||
try {
|
||||
await this.push(myvc, opts, conn);
|
||||
await this.push(myt, opts, conn);
|
||||
} catch(err) {
|
||||
try {
|
||||
await releaseLock();
|
||||
|
@ -74,12 +74,12 @@ class Push extends Command {
|
|||
await releaseLock();
|
||||
}
|
||||
|
||||
async push(myvc, opts, conn) {
|
||||
const pushConn = await myvc.createConnection();
|
||||
async push(myt, opts, conn) {
|
||||
const pushConn = await myt.createConnection();
|
||||
|
||||
// Get database version
|
||||
|
||||
const version = await myvc.fetchDbVersion() || {};
|
||||
const version = await myt.fetchDbVersion() || {};
|
||||
|
||||
console.log(
|
||||
`Database information:`
|
||||
|
@ -148,7 +148,7 @@ class Push extends Command {
|
|||
if (versionDir == 'README.md')
|
||||
continue;
|
||||
|
||||
const dirVersion = myvc.parseVersionDir(versionDir);
|
||||
const dirVersion = myt.parseVersionDir(versionDir);
|
||||
if (!dirVersion) {
|
||||
logVersion('[?????]'.yellow, versionDir,
|
||||
`Wrong directory name.`
|
||||
|
@ -214,7 +214,7 @@ class Push extends Command {
|
|||
|
||||
let err;
|
||||
try {
|
||||
await myvc.queryFromFile(pushConn,
|
||||
await myt.queryFromFile(pushConn,
|
||||
`${scriptsDir}/${script}`);
|
||||
} catch (e) {
|
||||
err = e;
|
||||
|
@ -258,7 +258,7 @@ class Push extends Command {
|
|||
const gitExists = await fs.pathExists(`${opts.workspace}/.git`);
|
||||
|
||||
let nRoutines = 0;
|
||||
let changes = await myvc.changedRoutines(version.gitCommit);
|
||||
let changes = await myt.changedRoutines(version.gitCommit);
|
||||
changes = this.parseChanges(changes);
|
||||
|
||||
const routines = [];
|
||||
|
@ -283,7 +283,7 @@ class Push extends Command {
|
|||
);
|
||||
}
|
||||
|
||||
const engine = new ExporterEngine(conn, opts.myvcDir);
|
||||
const engine = new ExporterEngine(conn, opts.mytDir);
|
||||
await engine.init();
|
||||
|
||||
async function finalize() {
|
||||
|
@ -328,7 +328,7 @@ class Push extends Command {
|
|||
if (change.type.name === 'VIEW')
|
||||
await pushConn.query(`USE ${scapedSchema}`);
|
||||
|
||||
await myvc.multiQuery(pushConn, newSql);
|
||||
await myt.multiQuery(pushConn, newSql);
|
||||
|
||||
if (change.isRoutine) {
|
||||
await conn.query(
|
||||
|
@ -472,4 +472,4 @@ class Routine {
|
|||
module.exports = Push;
|
||||
|
||||
if (require.main === module)
|
||||
new MyVC().run(Push);
|
||||
new Myt().run(Push);
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
const MyVC = require('./myvc');
|
||||
const Myt = require('./myt');
|
||||
const Command = require('./lib/command');
|
||||
const Push = require('./myvc-push');
|
||||
const Push = require('./myt-push');
|
||||
const docker = require('./lib/docker');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
|
@ -33,7 +33,7 @@ class Run extends Command {
|
|||
]
|
||||
};
|
||||
|
||||
async run(myvc, opts) {
|
||||
async run(myt, opts) {
|
||||
const dumpDir = opts.dumpDir;
|
||||
const serverDir = path.join(__dirname, 'server');
|
||||
|
||||
|
@ -47,14 +47,14 @@ class Run extends Command {
|
|||
serverDockerfile = path.join(serverDir, 'Dockerfile.base');
|
||||
|
||||
await docker.build(__dirname, {
|
||||
tag: 'myvc/base',
|
||||
tag: 'myt/base',
|
||||
file: serverDockerfile
|
||||
}, opts.debug);
|
||||
|
||||
// Build myvc server image
|
||||
// Build myt server image
|
||||
|
||||
await docker.build(__dirname, {
|
||||
tag: 'myvc/server',
|
||||
tag: 'myt/server',
|
||||
file: path.join(serverDir, 'Dockerfile.server')
|
||||
}, opts.debug);
|
||||
|
||||
|
@ -67,7 +67,7 @@ class Run extends Command {
|
|||
const day = pad(today.getDate());
|
||||
const stamp = `${year}-${month}-${day}`;
|
||||
|
||||
await docker.build(opts.myvcDir, {
|
||||
await docker.build(opts.mytDir, {
|
||||
tag: opts.code,
|
||||
file: path.join(serverDir, 'Dockerfile.dump'),
|
||||
buildArg: `STAMP=${stamp}`
|
||||
|
@ -127,7 +127,7 @@ class Run extends Command {
|
|||
commit: true,
|
||||
dbConfig
|
||||
});
|
||||
await myvc.runCommand(Push, opts);
|
||||
await myt.runCommand(Push, opts);
|
||||
|
||||
// Apply fixtures
|
||||
|
||||
|
@ -138,7 +138,7 @@ class Run extends Command {
|
|||
// Create triggers
|
||||
|
||||
console.log('Creating triggers.');
|
||||
const conn = await myvc.createConnection();
|
||||
const conn = await myt.createConnection();
|
||||
|
||||
for (const schema of opts.schemas) {
|
||||
const triggersPath = `${opts.routinesDir}/${schema}/triggers`;
|
||||
|
@ -147,7 +147,7 @@ class Run extends Command {
|
|||
|
||||
const triggersDir = await fs.readdir(triggersPath);
|
||||
for (const triggerFile of triggersDir)
|
||||
await myvc.queryFromFile(conn, `${triggersPath}/${triggerFile}`);
|
||||
await myt.queryFromFile(conn, `${triggersPath}/${triggerFile}`);
|
||||
}
|
||||
|
||||
return server;
|
||||
|
@ -157,4 +157,4 @@ class Run extends Command {
|
|||
module.exports = Run;
|
||||
|
||||
if (require.main === module)
|
||||
new MyVC().run(Run);
|
||||
new Myt().run(Run);
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
const MyVC = require('./myvc');
|
||||
const Myt = require('./myt');
|
||||
const Command = require('./lib/command');
|
||||
const Container = require('./lib/docker').Container;
|
||||
const Server = require('./lib/server');
|
||||
const Run = require('./myvc-run');
|
||||
const Run = require('./myt-run');
|
||||
|
||||
/**
|
||||
* Does the minium effort to start the database container, if it doesn't
|
||||
|
@ -16,7 +16,7 @@ class Start extends Command {
|
|||
description: 'Start local database server container'
|
||||
};
|
||||
|
||||
async run(myvc, opts) {
|
||||
async run(myt, opts) {
|
||||
const ct = new Container(opts.code);
|
||||
let status;
|
||||
|
||||
|
@ -26,7 +26,7 @@ class Start extends Command {
|
|||
});
|
||||
} catch (err) {
|
||||
const run = new Run()
|
||||
return await run.run(myvc, opts);
|
||||
return await run.run(myt, opts);
|
||||
}
|
||||
|
||||
switch (status) {
|
||||
|
@ -48,4 +48,4 @@ class Start extends Command {
|
|||
module.exports = Start;
|
||||
|
||||
if (require.main === module)
|
||||
new MyVC().run(Start);
|
||||
new Myt().run(Start);
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
const MyVC = require('./myvc');
|
||||
const Myt = require('./myt');
|
||||
const Command = require('./lib/command');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
|
@ -27,12 +27,12 @@ class Version extends Command {
|
|||
}
|
||||
};
|
||||
|
||||
async run(myvc, opts) {
|
||||
async run(myt, opts) {
|
||||
let newVersionDir;
|
||||
|
||||
// Fetch last version number
|
||||
|
||||
const conn = await myvc.dbConnect();
|
||||
const conn = await myt.dbConnect();
|
||||
|
||||
try {
|
||||
await conn.query('START TRANSACTION');
|
||||
|
@ -75,7 +75,7 @@ class Version extends Command {
|
|||
const versionNames = new Set();
|
||||
const versionDirs = await fs.readdir(opts.versionsDir);
|
||||
for (const versionDir of versionDirs) {
|
||||
const dirVersion = myvc.parseVersionDir(versionDir);
|
||||
const dirVersion = myt.parseVersionDir(versionDir);
|
||||
if (!dirVersion) continue;
|
||||
versionNames.add(dirVersion.name);
|
||||
}
|
||||
|
@ -216,4 +216,4 @@ const plants = [
|
|||
module.exports = Version;
|
||||
|
||||
if (require.main === module)
|
||||
new MyVC().run(Version);
|
||||
new Myt().run(Version);
|
|
@ -13,7 +13,7 @@ const camelToSnake = require('./lib/util').camelToSnake;
|
|||
const docker = require('./lib/docker');
|
||||
const Command = require('./lib/command');
|
||||
|
||||
class MyVC {
|
||||
class Myt {
|
||||
get usage() {
|
||||
return {
|
||||
description: 'Utility for database versioning',
|
||||
|
@ -51,7 +51,7 @@ class MyVC {
|
|||
|
||||
async run(CommandClass) {
|
||||
console.log(
|
||||
'MyVC (MySQL Version Control)'.green,
|
||||
'Myt'.green,
|
||||
`v${packageJson.version}`.magenta
|
||||
);
|
||||
|
||||
|
@ -72,7 +72,7 @@ class MyVC {
|
|||
if (!/^[a-z]+$/.test(commandName))
|
||||
throw new Error (`Invalid command name '${commandName}'`);
|
||||
|
||||
const commandFile = path.join(__dirname, `myvc-${commandName}.js`);
|
||||
const commandFile = path.join(__dirname, `myt-${commandName}.js`);
|
||||
|
||||
if (!await fs.pathExists(commandFile))
|
||||
throw new Error (`Unknown command '${commandName}'`);
|
||||
|
@ -126,7 +126,7 @@ class MyVC {
|
|||
try {
|
||||
depVersion = wsPackageJson
|
||||
.dependencies
|
||||
.myvc.match(versionRegex);
|
||||
.myt.match(versionRegex);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
|
@ -137,11 +137,11 @@ class MyVC {
|
|||
depVersion[1] === myVersion[1] &&
|
||||
depVersion[2] === myVersion[2];
|
||||
if (!isSameVersion)
|
||||
throw new Error(`MyVC version differs a lot from package.json, please run 'npm i' first to install the proper version.`);
|
||||
throw new Error(`Myt version differs a lot from package.json, please run 'npm i' first to install the proper version.`);
|
||||
|
||||
const isSameMinor = depVersion[3] === myVersion[3];
|
||||
if (!isSameMinor)
|
||||
console.warn(`Warning! MyVC minor version differs from package.json, maybe you shoud run 'npm i' to install the proper version.`.yellow);
|
||||
console.warn(`Warning! Myt minor version differs from package.json, maybe you shoud run 'npm i' to install the proper version.`.yellow);
|
||||
}
|
||||
|
||||
// Load method
|
||||
|
@ -178,9 +178,9 @@ class MyVC {
|
|||
async load(opts) {
|
||||
// Configuration file
|
||||
|
||||
const config = require(`${__dirname}/assets/myvc.default.yml`);
|
||||
const config = require(`${__dirname}/assets/myt.default.yml`);
|
||||
|
||||
const configFile = 'myvc.config.yml';
|
||||
const configFile = 'myt.config.yml';
|
||||
const configPath = path.join(opts.workspace, configFile);
|
||||
if (await fs.pathExists(configPath))
|
||||
Object.assign(config, require(configPath));
|
||||
|
@ -188,12 +188,12 @@ class MyVC {
|
|||
Object.assign(opts, config);
|
||||
opts.configFile = configFile;
|
||||
|
||||
if (!opts.myvcDir)
|
||||
opts.myvcDir = path.join(opts.workspace, opts.subdir || '');
|
||||
if (!opts.mytDir)
|
||||
opts.mytDir = path.join(opts.workspace, opts.subdir || '');
|
||||
|
||||
opts.routinesDir = path.join(opts.myvcDir, 'routines');
|
||||
opts.versionsDir = path.join(opts.myvcDir, 'versions');
|
||||
opts.dumpDir = path.join(opts.myvcDir, 'dump');
|
||||
opts.routinesDir = path.join(opts.mytDir, 'routines');
|
||||
opts.versionsDir = path.join(opts.mytDir, 'versions');
|
||||
opts.dumpDir = path.join(opts.mytDir, 'dump');
|
||||
|
||||
// Database configuration
|
||||
|
||||
|
@ -201,7 +201,7 @@ class MyVC {
|
|||
let iniFile = 'db.ini';
|
||||
|
||||
if (opts.remote) {
|
||||
iniDir = `${opts.myvcDir}/remotes`;
|
||||
iniDir = `${opts.mytDir}/remotes`;
|
||||
iniFile = `${opts.remote}.ini`;
|
||||
}
|
||||
const iniPath = path.join(iniDir, iniFile);
|
||||
|
@ -226,7 +226,7 @@ class MyVC {
|
|||
};
|
||||
if (iniConfig.ssl_ca) {
|
||||
dbConfig.ssl = {
|
||||
ca: await fs.readFile(`${opts.myvcDir}/${iniConfig.ssl_ca}`),
|
||||
ca: await fs.readFile(`${opts.mytDir}/${iniConfig.ssl_ca}`),
|
||||
rejectUnauthorized: iniConfig.ssl_verify_server_cert != undefined
|
||||
}
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ class MyVC {
|
|||
const dumpStream = await fs.createWriteStream(dumpPath);
|
||||
|
||||
await docker.build(__dirname, {
|
||||
tag: 'myvc/client',
|
||||
tag: 'myt/client',
|
||||
file: path.join(__dirname, 'server', 'Dockerfile.client')
|
||||
}, this.opts.debug);
|
||||
|
||||
|
@ -469,15 +469,15 @@ class MyVC {
|
|||
]
|
||||
};
|
||||
const commandArgs = [command].concat(myArgs, args);
|
||||
await docker.run('myvc/client', commandArgs, {
|
||||
await docker.run('myt/client', commandArgs, {
|
||||
addHost: 'host.docker.internal:host-gateway',
|
||||
volume: `${this.opts.myvcDir}:/workspace`,
|
||||
volume: `${this.opts.mytDir}:/workspace`,
|
||||
rm: true
|
||||
}, execOptions);
|
||||
}
|
||||
|
||||
showHelp(opts, usage, command) {
|
||||
const prefix = `${'Usage:'.gray} [npx] myvc`;
|
||||
const prefix = `${'Usage:'.gray} [npx] myt`;
|
||||
|
||||
if (command) {
|
||||
let log = [prefix, command.blue];
|
||||
|
@ -640,7 +640,7 @@ for (const tokenId in tokens) {
|
|||
tokenIndex.set(token.start[0], token);
|
||||
}
|
||||
|
||||
module.exports = MyVC;
|
||||
module.exports = Myt;
|
||||
|
||||
if (require.main === module)
|
||||
new MyVC().run();
|
||||
new Myt().run();
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "myvc",
|
||||
"version": "1.5.0",
|
||||
"name": "@verdnatura/myt",
|
||||
"version": "1.5.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "myvc",
|
||||
"version": "1.5.0",
|
||||
"name": "@verdnatura/myt",
|
||||
"version": "1.5.2",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@sqltools/formatter": "^1.2.3",
|
||||
|
@ -21,6 +21,7 @@
|
|||
"sha.js": "^2.4.11"
|
||||
},
|
||||
"bin": {
|
||||
"myt": "cli.js",
|
||||
"myv": "cli.js",
|
||||
"myvc": "cli.js"
|
||||
}
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
{
|
||||
"name": "myvc",
|
||||
"version": "1.5.0",
|
||||
"name": "@verdnatura/myt",
|
||||
"version": "1.5.2",
|
||||
"author": "Verdnatura Levante SL",
|
||||
"description": "MySQL Version Control",
|
||||
"description": "MySQL and MariaDB version control using Git",
|
||||
"license": "GPL-3.0",
|
||||
"bin": {
|
||||
"myt": "cli.js",
|
||||
"myvc": "cli.js",
|
||||
"myv": "cli.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/verdnatura/myvc.git"
|
||||
"url": "https://github.com/verdnatura/myt.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sqltools/formatter": "^1.2.3",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM myvc/server
|
||||
FROM myt/server
|
||||
|
||||
USER root
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM myvc/base
|
||||
FROM myt/base
|
||||
|
||||
USER root
|
||||
ENV MYSQL_ROOT_PASSWORD root
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
code: my-db
|
||||
schemas:
|
||||
- myvc
|
||||
- myt
|
||||
- my_db
|
||||
fixtures:
|
||||
myvc:
|
||||
myt:
|
||||
- version
|
||||
- versionLog
|
||||
my_db:
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
"type": "git"
|
||||
},
|
||||
"dependencies": {
|
||||
"myvc": "^1.5.0"
|
||||
"myt": "^1.5.2"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue