Project init fixes
This commit is contained in:
parent
df46ca8c93
commit
d7fd7546bb
|
@ -370,7 +370,7 @@ class Push {
|
|||
const repo = await nodegit.Repository.open(this.opts.workspace);
|
||||
const head = await repo.getHeadCommit();
|
||||
|
||||
if (version.gitCommit !== head.sha())
|
||||
if (head && version.gitCommit !== head.sha())
|
||||
await this.updateVersion('gitCommit', head.sha());
|
||||
}
|
||||
|
||||
|
|
|
@ -57,11 +57,10 @@ class Version {
|
|||
);
|
||||
|
||||
let newVersion;
|
||||
|
||||
if (lastNumber)
|
||||
newVersion = Math.max(
|
||||
parseInt(number),
|
||||
parseInt(lastNumber)
|
||||
parseInt(number) || 0,
|
||||
parseInt(lastNumber) || 0
|
||||
) + 1;
|
||||
else
|
||||
newVersion = 1;
|
||||
|
|
22
myvc.js
22
myvc.js
|
@ -39,7 +39,9 @@ class MyVC {
|
|||
help: 'h'
|
||||
},
|
||||
boolean: [
|
||||
'd', 'v', 'h'
|
||||
'debug',
|
||||
'version',
|
||||
'help'
|
||||
],
|
||||
default: {
|
||||
workspace: process.cwd()
|
||||
|
@ -75,7 +77,19 @@ class MyVC {
|
|||
process.exit(0);
|
||||
}
|
||||
|
||||
const commandOpts = this.getopts(command.localOpts);
|
||||
const allOpts = Object.assign({}, baseOpts);
|
||||
for (const key in command.localOpts) {
|
||||
const baseValue = baseOpts[key];
|
||||
const cmdValue = command.localOpts[key];
|
||||
if (Array.isArray(baseValue))
|
||||
allOpts[key] = baseValue.concat(cmdValue);
|
||||
else if (typeof baseValue == 'object')
|
||||
allOpts[key] = Object.assign({}, baseValue, cmdValue);
|
||||
else
|
||||
allOpts[key] = cmdValue;
|
||||
}
|
||||
|
||||
const commandOpts = this.getopts(allOpts);
|
||||
Object.assign(opts, commandOpts);
|
||||
|
||||
const operandToOpt = command.usage.operand;
|
||||
|
@ -227,6 +241,7 @@ class MyVC {
|
|||
|
||||
if (!schema)
|
||||
await conn.query(`CREATE DATABASE ??`, [opts.versionSchema]);
|
||||
await conn.query(`USE ??`, [opts.versionSchema]);
|
||||
|
||||
const [[res]] = await conn.query(
|
||||
`SELECT COUNT(*) > 0 tableExists
|
||||
|
@ -239,10 +254,7 @@ class MyVC {
|
|||
if (!res.tableExists) {
|
||||
const structure = await fs.readFile(`${__dirname}/structure.sql`, 'utf8');
|
||||
await conn.query(structure);
|
||||
return null;
|
||||
}
|
||||
|
||||
await conn.query(`USE ??`, [opts.versionSchema]);
|
||||
}
|
||||
|
||||
return this.conn;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "myvc",
|
||||
"version": "1.3.9",
|
||||
"version": "1.3.10",
|
||||
"author": "Verdnatura Levante SL",
|
||||
"description": "MySQL Version Control",
|
||||
"license": "GPL-3.0",
|
||||
|
|
|
@ -3,7 +3,8 @@ CREATE TABLE `version` (
|
|||
`code` VARCHAR(255) NOT NULL,
|
||||
`number` CHAR(11) NULL DEFAULT NULL,
|
||||
`gitCommit` VARCHAR(255) NULL DEFAULT NULL,
|
||||
`updated` DATETIME NOT NULL DEFAULT NULL
|
||||
`updated` DATETIME NOT NULL,
|
||||
`lastNumber` CHAR(11) NULL DEFAULT NULL
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
ALTER TABLE `version`
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
"type": "git"
|
||||
},
|
||||
"dependencies": {
|
||||
"myvc": "^1.3.9"
|
||||
"myvc": "^1.3.10"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue