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