2020-12-02 07:35:26 +00:00
|
|
|
|
2020-12-04 16:30:26 +00:00
|
|
|
const MyVC = require('./myvc');
|
2020-12-02 07:35:26 +00:00
|
|
|
const fs = require('fs-extra');
|
2020-12-04 10:53:11 +00:00
|
|
|
const nodegit = require('nodegit');
|
2020-12-04 09:15:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Pushes changes to remote.
|
|
|
|
*/
|
2020-12-02 07:35:26 +00:00
|
|
|
class Push {
|
2021-10-25 13:38:07 +00:00
|
|
|
get usage() {
|
|
|
|
return {
|
|
|
|
description: 'Apply changes into database',
|
|
|
|
params: {
|
|
|
|
force: 'Answer yes to all questions',
|
|
|
|
user: 'Update the user version instead, for shared databases'
|
|
|
|
},
|
|
|
|
operand: 'remote'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-10-23 13:20:35 +00:00
|
|
|
get localOpts() {
|
2020-12-02 07:35:26 +00:00
|
|
|
return {
|
2021-10-25 13:38:07 +00:00
|
|
|
boolean: {
|
2020-12-02 07:35:26 +00:00
|
|
|
force: 'f',
|
2020-12-04 09:15:29 +00:00
|
|
|
user: 'u'
|
2020-12-02 07:35:26 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
async run(myvc, opts) {
|
|
|
|
const conn = await myvc.dbConnect();
|
|
|
|
this.conn = conn;
|
|
|
|
|
2021-10-25 13:38:07 +00:00
|
|
|
// Obtain exclusive lock
|
|
|
|
|
|
|
|
const [[row]] = await conn.query(
|
|
|
|
`SELECT GET_LOCK('myvc_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`);
|
|
|
|
isUsed = row.isUsed;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error(`Cannot obtain exclusive lock, used by connection ${isUsed}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get database version
|
|
|
|
|
2020-12-02 07:35:26 +00:00
|
|
|
const version = await myvc.fetchDbVersion() || {};
|
|
|
|
|
|
|
|
console.log(
|
|
|
|
`Database information:`
|
|
|
|
+ `\n -> Version: ${version.number}`
|
|
|
|
+ `\n -> Commit: ${version.gitCommit}`
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!version.number)
|
2021-10-25 13:38:07 +00:00
|
|
|
version.number = String('0').padStart(opts.versionDigits, '0');
|
2020-12-05 21:50:45 +00:00
|
|
|
if (!/^[0-9]*$/.test(version.number))
|
|
|
|
throw new Error('Wrong database version');
|
2020-12-02 07:35:26 +00:00
|
|
|
|
|
|
|
if (opts.user) {
|
2021-10-16 06:44:19 +00:00
|
|
|
const user = await this.getDbUser();
|
2020-12-02 07:35:26 +00:00
|
|
|
let [[userVersion]] = await conn.query(
|
|
|
|
`SELECT number, gitCommit
|
|
|
|
FROM versionUser
|
|
|
|
WHERE code = ? AND user = ?`,
|
|
|
|
[opts.code, user]
|
|
|
|
);
|
|
|
|
userVersion = userVersion || {};
|
|
|
|
console.log(
|
|
|
|
`User information:`
|
|
|
|
+ `\n -> User: ${user}`
|
|
|
|
+ `\n -> Version: ${userVersion.number}`
|
|
|
|
+ `\n -> Commit: ${userVersion.gitCommit}`
|
|
|
|
);
|
|
|
|
|
|
|
|
if (userVersion.number > version.number)
|
2021-10-16 06:44:19 +00:00
|
|
|
version.number = userVersion.number;
|
|
|
|
if (userVersion.gitCommit && userVersion.gitCommit !== version.gitCommit)
|
|
|
|
version.gitCommit = userVersion.gitCommit;
|
2020-12-02 07:35:26 +00:00
|
|
|
}
|
|
|
|
|
2021-10-25 13:38:07 +00:00
|
|
|
// Prevent push to production by mistake
|
|
|
|
|
2020-12-04 16:30:26 +00:00
|
|
|
if (opts.remote == 'production') {
|
2020-12-02 07:35:26 +00:00
|
|
|
console.log(
|
|
|
|
'\n ( ( ) ( ( ) ) '
|
|
|
|
+ '\n )\\ ))\\ ) ( /( )\\ ) ( ))\\ ) ( /( ( /( '
|
|
|
|
+ '\n(()/(()/( )\\()|()/( ( )\\ ) /(()/( )\\()) )\\())'
|
|
|
|
+ '\n /(_))(_)|(_)\\ /(_)) )\\ (((_) ( )(_))(_)|(_)\\ ((_)\\ '
|
|
|
|
+ '\n(_))(_)) ((_|_))_ _ ((_))\\___(_(_()|__)) ((_) _((_)'
|
|
|
|
+ '\n| _ \\ _ \\ / _ \\| \\| | | ((/ __|_ _|_ _| / _ \\| \\| |'
|
|
|
|
+ '\n| _/ /| (_) | |) | |_| || (__ | | | | | (_) | . |'
|
|
|
|
+ '\n|_| |_|_\\ \\___/|___/ \\___/ \\___| |_| |___| \\___/|_|\\_|'
|
|
|
|
+ '\n'
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!opts.force) {
|
|
|
|
const readline = require('readline');
|
|
|
|
const rl = readline.createInterface({
|
|
|
|
input: process.stdin,
|
|
|
|
output: process.stdout
|
|
|
|
});
|
|
|
|
const answer = await new Promise(resolve => {
|
|
|
|
rl.question('Are you sure? (Default: no) [yes|no] ', resolve);
|
|
|
|
});
|
|
|
|
rl.close();
|
|
|
|
|
|
|
|
if (answer !== 'yes')
|
|
|
|
throw new Error('Changes aborted');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-25 13:38:07 +00:00
|
|
|
// Apply versions
|
|
|
|
|
2020-12-02 07:35:26 +00:00
|
|
|
console.log('Applying versions.');
|
2020-12-04 12:15:51 +00:00
|
|
|
const pushConn = await myvc.createConnection();
|
2020-12-02 07:35:26 +00:00
|
|
|
|
|
|
|
let nChanges = 0;
|
2021-10-25 13:38:07 +00:00
|
|
|
const versionsDir = `${opts.myvcDir}/versions`;
|
2020-12-02 07:35:26 +00:00
|
|
|
|
|
|
|
function logVersion(type, version, name) {
|
|
|
|
console.log('', type.bold, `[${version.bold}]`, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (await fs.pathExists(versionsDir)) {
|
|
|
|
const versionDirs = await fs.readdir(versionsDir);
|
|
|
|
|
|
|
|
for (const versionDir of versionDirs) {
|
|
|
|
if (versionDir == 'README.md')
|
|
|
|
continue;
|
|
|
|
|
2021-10-26 11:03:15 +00:00
|
|
|
const match = versionDir.match(/^([0-9]+)-([a-zA-Z0-9]+)?$/);
|
2020-12-02 07:35:26 +00:00
|
|
|
if (!match) {
|
|
|
|
logVersion('[W]'.yellow, '?????', versionDir);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-10-25 13:38:07 +00:00
|
|
|
const versionNumber = match[1];
|
2020-12-02 07:35:26 +00:00
|
|
|
const versionName = match[2];
|
|
|
|
|
2021-10-25 13:38:07 +00:00
|
|
|
if (versionNumber.length != version.number.length) {
|
|
|
|
logVersion('[W]'.yellow, '*****', versionDir);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (version.number >= versionNumber) {
|
|
|
|
logVersion('[I]'.blue, versionNumber, versionName);
|
2020-12-02 07:35:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-10-25 13:38:07 +00:00
|
|
|
logVersion('[+]'.green, versionNumber, versionName);
|
2020-12-02 07:35:26 +00:00
|
|
|
const scriptsDir = `${versionsDir}/${versionDir}`;
|
|
|
|
const scripts = await fs.readdir(scriptsDir);
|
|
|
|
|
|
|
|
for (const script of scripts) {
|
|
|
|
if (!/^[0-9]{2}-[a-zA-Z0-9_]+\.sql$/.test(script)) {
|
|
|
|
console.log(` - Ignoring wrong file name: ${script}`);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(` - ${script}`);
|
|
|
|
await this.queryFromFile(pushConn, `${scriptsDir}/${script}`);
|
|
|
|
nChanges++;
|
|
|
|
}
|
|
|
|
|
2021-10-25 13:38:07 +00:00
|
|
|
await this.updateVersion(nChanges, 'number', versionNumber);
|
2020-12-02 07:35:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-25 13:38:07 +00:00
|
|
|
// Apply routines
|
|
|
|
|
2020-12-02 07:35:26 +00:00
|
|
|
console.log('Applying changed routines.');
|
|
|
|
|
|
|
|
let nRoutines = 0;
|
|
|
|
let changes = await fs.pathExists(`${opts.workspace}/.git`)
|
|
|
|
? await myvc.changedRoutines(version.gitCommit)
|
|
|
|
: await myvc.cachedChanges();
|
2020-12-04 09:15:29 +00:00
|
|
|
changes = this.parseChanges(changes);
|
2020-12-02 07:35:26 +00:00
|
|
|
|
|
|
|
const routines = [];
|
|
|
|
for (const change of changes)
|
|
|
|
if (change.isRoutine)
|
2021-10-27 10:56:25 +00:00
|
|
|
routines.push([
|
|
|
|
change.schema,
|
|
|
|
change.name,
|
|
|
|
change.type.name
|
|
|
|
]);
|
2020-12-02 07:35:26 +00:00
|
|
|
|
|
|
|
if (routines.length) {
|
|
|
|
await conn.query(
|
|
|
|
`DROP TEMPORARY TABLE IF EXISTS tProcsPriv`
|
|
|
|
);
|
|
|
|
await conn.query(
|
|
|
|
`CREATE TEMPORARY TABLE tProcsPriv
|
|
|
|
ENGINE = MEMORY
|
|
|
|
SELECT * FROM mysql.procs_priv
|
2021-10-27 10:56:25 +00:00
|
|
|
WHERE (Db, Routine_name, Routine_type) IN (?)`,
|
2020-12-02 07:35:26 +00:00
|
|
|
[routines]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const change of changes) {
|
2021-10-25 13:38:07 +00:00
|
|
|
const fullPath = `${opts.myvcDir}/routines/${change.path}.sql`;
|
2020-12-04 09:15:29 +00:00
|
|
|
const exists = await fs.pathExists(fullPath);
|
2021-10-25 13:38:07 +00:00
|
|
|
|
2020-12-04 09:15:29 +00:00
|
|
|
const actionMsg = exists ? '[+]'.green : '[-]'.red;
|
2020-12-02 07:35:26 +00:00
|
|
|
const typeMsg = `[${change.type.abbr}]`[change.type.color];
|
|
|
|
console.log('', actionMsg.bold, typeMsg.bold, change.fullName);
|
|
|
|
|
2021-10-22 14:11:03 +00:00
|
|
|
try {
|
|
|
|
const scapedSchema = pushConn.escapeId(change.schema, true);
|
|
|
|
|
|
|
|
if (exists) {
|
2021-10-27 10:56:25 +00:00
|
|
|
if (change.type.name === 'VIEW')
|
2021-10-25 13:38:07 +00:00
|
|
|
await pushConn.query(`USE ${scapedSchema}`);
|
|
|
|
|
2021-10-22 14:11:03 +00:00
|
|
|
await this.queryFromFile(pushConn, `routines/${change.path}.sql`);
|
2021-10-25 13:38:07 +00:00
|
|
|
|
|
|
|
if (change.isRoutine) {
|
|
|
|
await conn.query(
|
|
|
|
`INSERT IGNORE INTO mysql.procs_priv
|
|
|
|
SELECT * FROM tProcsPriv
|
2021-10-27 10:56:25 +00:00
|
|
|
WHERE Db = ?
|
|
|
|
AND Routine_name = ?
|
|
|
|
AND Routine_type = ?`,
|
2021-10-25 13:38:07 +00:00
|
|
|
[change.schema, change.name, change.type.name]
|
|
|
|
);
|
|
|
|
}
|
2021-10-22 14:11:03 +00:00
|
|
|
} else {
|
|
|
|
const escapedName =
|
|
|
|
scapedSchema + '.' +
|
|
|
|
pushConn.escapeId(change.name, true);
|
|
|
|
|
|
|
|
const query = `DROP ${change.type.name} IF EXISTS ${escapedName}`;
|
|
|
|
await pushConn.query(query);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
if (err.sqlState)
|
|
|
|
console.warn('Warning:'.yellow, err.message);
|
|
|
|
else
|
|
|
|
throw err;
|
2020-12-02 07:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nRoutines++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (routines.length) {
|
2021-10-25 13:38:07 +00:00
|
|
|
await conn.query(`DROP TEMPORARY TABLE tProcsPriv`);
|
|
|
|
await conn.query('FLUSH PRIVILEGES');
|
2020-12-02 07:35:26 +00:00
|
|
|
}
|
|
|
|
|
2021-10-25 13:38:07 +00:00
|
|
|
// Update and release
|
|
|
|
|
2020-12-02 07:35:26 +00:00
|
|
|
await pushConn.end();
|
|
|
|
|
|
|
|
if (nRoutines > 0) {
|
|
|
|
console.log(` -> ${nRoutines} routines have changed.`);
|
|
|
|
} else
|
|
|
|
console.log(` -> No routines changed.`);
|
2021-10-16 06:44:19 +00:00
|
|
|
|
|
|
|
const repo = await nodegit.Repository.open(this.opts.workspace);
|
|
|
|
const head = await repo.getHeadCommit();
|
|
|
|
|
|
|
|
if (version.gitCommit !== head.sha())
|
|
|
|
await this.updateVersion(nRoutines, 'gitCommit', head.sha());
|
2021-10-25 13:38:07 +00:00
|
|
|
|
|
|
|
await conn.query(`DO RELEASE_LOCK('myvc_push')`);
|
2020-12-02 07:35:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:15:29 +00:00
|
|
|
parseChanges(changes) {
|
2020-12-02 07:35:26 +00:00
|
|
|
const routines = [];
|
2020-12-05 21:50:45 +00:00
|
|
|
if (changes)
|
|
|
|
for (const change of changes)
|
|
|
|
routines.push(new Routine(change));
|
2020-12-02 07:35:26 +00:00
|
|
|
return routines;
|
|
|
|
}
|
|
|
|
|
2021-10-16 06:44:19 +00:00
|
|
|
async getDbUser() {
|
|
|
|
const [[row]] = await this.conn.query('SELECT USER() `user`');
|
|
|
|
return row.user.substr(0, row.user.indexOf('@'));
|
|
|
|
}
|
|
|
|
|
2020-12-02 07:35:26 +00:00
|
|
|
async updateVersion(nChanges, column, value) {
|
|
|
|
if (nChanges == 0) return;
|
|
|
|
const {opts} = this;
|
|
|
|
|
|
|
|
column = this.conn.escapeId(column, true);
|
|
|
|
|
|
|
|
if (opts.user) {
|
2021-10-16 06:44:19 +00:00
|
|
|
const user = await this.getDbUser();
|
2020-12-02 07:35:26 +00:00
|
|
|
await this.conn.query(
|
|
|
|
`INSERT INTO versionUser
|
|
|
|
SET code = ?,
|
|
|
|
user = ?,
|
2021-10-23 13:20:35 +00:00
|
|
|
${column} = ?,
|
|
|
|
updated = NOW()
|
2020-12-02 07:35:26 +00:00
|
|
|
ON DUPLICATE KEY UPDATE
|
2021-10-23 13:20:35 +00:00
|
|
|
${column} = VALUES(${column}),
|
|
|
|
updated = VALUES(updated)`,
|
2020-12-02 07:35:26 +00:00
|
|
|
[
|
|
|
|
opts.code,
|
|
|
|
user,
|
|
|
|
value
|
|
|
|
]
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
await this.conn.query(
|
|
|
|
`INSERT INTO version
|
|
|
|
SET code = ?,
|
2021-10-23 13:20:35 +00:00
|
|
|
${column} = ?,
|
|
|
|
updated = NOW()
|
2020-12-02 07:35:26 +00:00
|
|
|
ON DUPLICATE KEY UPDATE
|
2021-10-23 13:20:35 +00:00
|
|
|
${column} = VALUES(${column}),
|
|
|
|
updated = VALUES(updated)`,
|
2020-12-02 07:35:26 +00:00
|
|
|
[
|
|
|
|
opts.code,
|
|
|
|
value
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Executes an SQL script.
|
|
|
|
*
|
|
|
|
* @param {String} file Path to the SQL script
|
|
|
|
* @returns {Array<Result>} The resultset
|
|
|
|
*/
|
|
|
|
async queryFromFile(conn, file) {
|
|
|
|
let results = [];
|
|
|
|
const stmts = this.querySplit(await fs.readFile(file, 'utf8'));
|
|
|
|
|
|
|
|
for (const stmt of stmts)
|
|
|
|
results = results.concat(await conn.query(stmt));
|
|
|
|
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Splits an SQL muti-query into a single-query array, it does an small
|
|
|
|
* parse to correctly handle the DELIMITER statement.
|
|
|
|
*
|
|
|
|
* @param {Array<String>} stmts The splitted SQL statements
|
|
|
|
*/
|
|
|
|
querySplit(sql) {
|
|
|
|
const stmts = [];
|
|
|
|
let i,
|
|
|
|
char,
|
|
|
|
token,
|
|
|
|
escaped,
|
|
|
|
stmtStart;
|
|
|
|
|
|
|
|
let delimiter = ';';
|
|
|
|
const delimiterRe = /\s*delimiter\s+(\S+)[^\S\r\n]*(?:\r?\n|\r)/yi;
|
|
|
|
|
|
|
|
function begins(str) {
|
|
|
|
let j;
|
|
|
|
for (j = 0; j < str.length; j++)
|
|
|
|
if (sql[i + j] != str[j])
|
|
|
|
return false;
|
|
|
|
i += j;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < sql.length;) {
|
|
|
|
stmtStart = i;
|
|
|
|
|
|
|
|
delimiterRe.lastIndex = i;
|
|
|
|
const match = sql.match(delimiterRe);
|
|
|
|
if (match) {
|
|
|
|
delimiter = match[1];
|
|
|
|
i += match[0].length;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (i < sql.length) {
|
|
|
|
char = sql[i];
|
|
|
|
|
|
|
|
if (token) {
|
|
|
|
if (!escaped && begins(token.end))
|
|
|
|
token = null;
|
|
|
|
else {
|
|
|
|
escaped = !escaped && token.escape(char);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (begins(delimiter)) break;
|
|
|
|
|
|
|
|
const tok = tokenIndex.get(char);
|
|
|
|
if (tok && begins(tok.start))
|
|
|
|
token = tok;
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const len = i - stmtStart - delimiter.length;
|
|
|
|
stmts.push(sql.substr(stmtStart, len));
|
|
|
|
}
|
|
|
|
|
|
|
|
const len = stmts.length;
|
|
|
|
if (len > 1 && /^\s*$/.test(stmts[len - 1]))
|
|
|
|
stmts.pop();
|
|
|
|
|
|
|
|
return stmts;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-04 09:15:29 +00:00
|
|
|
const typeMap = {
|
|
|
|
events: {
|
|
|
|
name: 'EVENT',
|
|
|
|
abbr: 'EVNT',
|
|
|
|
color: 'cyan'
|
|
|
|
},
|
|
|
|
functions: {
|
|
|
|
name: 'FUNCTION',
|
|
|
|
abbr: 'FUNC',
|
|
|
|
color: 'cyan'
|
|
|
|
},
|
|
|
|
procedures: {
|
|
|
|
name: 'PROCEDURE',
|
|
|
|
abbr: 'PROC',
|
|
|
|
color: 'yellow'
|
|
|
|
},
|
|
|
|
triggers: {
|
|
|
|
name: 'TRIGGER',
|
|
|
|
abbr: 'TRIG',
|
|
|
|
color: 'blue'
|
|
|
|
},
|
|
|
|
views: {
|
|
|
|
name: 'VIEW',
|
|
|
|
abbr: 'VIEW',
|
|
|
|
color: 'magenta'
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-10-25 13:38:07 +00:00
|
|
|
const routineTypes = new Set([
|
|
|
|
'FUNCTION',
|
|
|
|
'PROCEDURE'
|
|
|
|
]);
|
|
|
|
|
2020-12-04 09:15:29 +00:00
|
|
|
class Routine {
|
|
|
|
constructor(change) {
|
|
|
|
const path = change.path;
|
|
|
|
const split = path.split('/');
|
|
|
|
|
|
|
|
const schema = split[0];
|
|
|
|
const type = typeMap[split[1]];
|
|
|
|
const name = split[2];
|
|
|
|
|
|
|
|
Object.assign(this, {
|
|
|
|
path,
|
|
|
|
mark: change.mark,
|
|
|
|
type,
|
|
|
|
schema,
|
|
|
|
name,
|
|
|
|
fullName: `${schema}.${name}`,
|
2021-10-27 10:56:25 +00:00
|
|
|
isRoutine: routineTypes.has(type.name)
|
2020-12-04 09:15:29 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const tokens = {
|
|
|
|
string: {
|
|
|
|
start: '\'',
|
|
|
|
end: '\'',
|
|
|
|
escape: char => char == '\'' || char == '\\'
|
|
|
|
},
|
|
|
|
id: {
|
|
|
|
start: '`',
|
|
|
|
end: '`',
|
|
|
|
escape: char => char == '`'
|
|
|
|
},
|
|
|
|
multiComment: {
|
|
|
|
start: '/*',
|
|
|
|
end: '*/',
|
|
|
|
escape: () => false
|
|
|
|
},
|
|
|
|
singleComment: {
|
|
|
|
start: '-- ',
|
|
|
|
end: '\n',
|
|
|
|
escape: () => false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const tokenIndex = new Map();
|
|
|
|
for (const tokenId in tokens) {
|
|
|
|
const token = tokens[tokenId];
|
|
|
|
tokenIndex.set(token.start[0], token);
|
|
|
|
}
|
|
|
|
|
2020-12-02 07:35:26 +00:00
|
|
|
module.exports = Push;
|
|
|
|
|
|
|
|
if (require.main === module)
|
|
|
|
new MyVC().run(Push);
|