Compare commits
No commits in common. "8d665a357662876136adb0da6e82951e1438680a" and "53e0f0569f0138bd8bf38472ac9d42e4130cbe4c" have entirely different histories.
8d665a3576
...
53e0f0569f
@ -22,5 +22,6 @@ child_process.exec ('git log -1 | grep \'\\[no publish\\]\'')
|
|||||||
console.log ('build not marked for deployment');
|
console.log ('build not marked for deployment');
|
||||||
process.exit (1);
|
process.exit (1);
|
||||||
}
|
}
|
||||||
else { child_process.execSync ('yarn publish'); }
|
else
|
||||||
|
child_process.execSync ('yarn publish');
|
||||||
});
|
});
|
||||||
|
@ -27,8 +27,5 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fs-extra": "^8.1.0",
|
"fs-extra": "^8.1.0",
|
||||||
"yargs": "^15.1.0"
|
"yargs": "^15.1.0"
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10.0.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const fs = require ('fs-extra');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param str
|
|
||||||
*/
|
|
||||||
function get_table_info (str) {
|
|
||||||
const lines = str.split (/\n/ug);
|
|
||||||
lines.splice (0, 2);
|
|
||||||
lines.splice (lines.length - 2, 2);
|
|
||||||
const name_line = lines.splice (0);
|
|
||||||
const { name } = (/<b>(?<name>\S)<\/b>/u).exec (name_line).groups;
|
|
||||||
const columns = [];
|
|
||||||
|
|
||||||
return { name, columns };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get all tables from a structure file
|
|
||||||
*
|
|
||||||
* @param {string} file path to the structure file
|
|
||||||
* @returns {Array<object>} tables
|
|
||||||
*/
|
|
||||||
async function get_tables (file) {
|
|
||||||
const lines = (await fs.readFile (file, 'utf-8')).split (/\n/gu);
|
|
||||||
const curr = [];
|
|
||||||
const tables = [];
|
|
||||||
for (const l of lines) {
|
|
||||||
if (curr.length > 0 || (/\S+ \[label=</u).test (l))
|
|
||||||
curr.push (l);
|
|
||||||
|
|
||||||
if ((/>\]/u).test (l)) {
|
|
||||||
tables.push (curr.join ('\n'));
|
|
||||||
curr.splice (0, curr.length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tables.map ((val) => get_table_info (val));
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { get_tables };
|
|
@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
|
||||||
* This file is part of snippeteer which is released under BSD-3-Clause.
|
|
||||||
* See file 'LICENSE' for full license details.
|
|
||||||
* Created by Timo Hocker <timo@scode.ovh>, January 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* eslint-disable no-sync */
|
|
||||||
/* eslint-disable no-console */
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const fs = require ('fs-extra');
|
|
||||||
const path = require ('path');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* copies the full template to a new folder named after arg[0]
|
|
||||||
*
|
|
||||||
* @param {string} folder folder to run in
|
|
||||||
* @param {Array} args function arguments
|
|
||||||
*/
|
|
||||||
function run (folder, args) {
|
|
||||||
const snip_folder_path = [ folder ];
|
|
||||||
if (args.length > 0)
|
|
||||||
snip_folder_path.push (args[0]);
|
|
||||||
const snip_folder = path.join (...snip_folder_path);
|
|
||||||
const template = path.join (__dirname, 'template');
|
|
||||||
if (!fs.existsSync (snip_folder))
|
|
||||||
fs.mkdir (snip_folder);
|
|
||||||
for (const f of fs.readdirSync (template)) {
|
|
||||||
fs.copy (
|
|
||||||
path.join (template, f),
|
|
||||||
path.join (snip_folder, f),
|
|
||||||
{
|
|
||||||
recursive: true,
|
|
||||||
filter: (src, dest) => !fs.existsSync (dest)
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* checks if the arguments meet the requirements
|
|
||||||
*
|
|
||||||
* @param {string} folder folder to run in
|
|
||||||
* @param {Array} args function arguments
|
|
||||||
* @returns {boolean} true if arguments match requirements
|
|
||||||
*/
|
|
||||||
function assert (folder, args) {
|
|
||||||
const tests = [
|
|
||||||
{
|
|
||||||
f: () => (args.length < 2),
|
|
||||||
reason: 'too many arguments'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
f: () => (args.length === 0 || typeof args[0] === 'string'),
|
|
||||||
reason: 'name is not a string'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
f: () => (args.length === 0 || (/^[a-z]+$/iu).test (args[0])),
|
|
||||||
reason: 'name can only contain [a-z]'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
f: () => (typeof folder === 'string'),
|
|
||||||
reason: 'cwd is not a folder (internal error)'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
f: () => (fs.existsSync (folder)),
|
|
||||||
reason: 'cwd does not exist (internal error)'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
f: () => (args.length === 1 || fs.readdirSync (folder).length === 0),
|
|
||||||
reason: 'folder is not empty'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
f: () => (args.length === 0
|
|
||||||
|| !fs.existsSync (path.join (folder, args[0]))),
|
|
||||||
reason: 'folder already exists'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
for (const test of tests) {
|
|
||||||
if (!test.f ()) {
|
|
||||||
console.log (test.reason);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { run, assert };
|
|
@ -8,8 +8,6 @@
|
|||||||
/* eslint-disable no-sync */
|
/* eslint-disable no-sync */
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const fs = require ('fs-extra');
|
const fs = require ('fs-extra');
|
||||||
const path = require ('path');
|
const path = require ('path');
|
||||||
|
|
||||||
@ -28,13 +26,12 @@ function run (folder, args) {
|
|||||||
: 'general'
|
: 'general'
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const f of fs.readdirSync (template)) {
|
for (const f of fs.readdirSync (template))
|
||||||
fs.copy (
|
fs.copy (
|
||||||
path.join (template, f),
|
path.join (template, f),
|
||||||
path.join (folder, f),
|
path.join (folder, f),
|
||||||
{ filter: (src, dest) => !fs.existsSync (dest) }
|
{ filter: (src, dest) => !fs.existsSync (dest) }
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,12 +51,11 @@ function assert (folder) {
|
|||||||
reason: 'cwd does not exist (internal error)'
|
reason: 'cwd does not exist (internal error)'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
for (const test of tests) {
|
for (const test of tests)
|
||||||
if (!test.f ()) {
|
if (!test.f ()) {
|
||||||
console.log (test.reason);
|
console.log (test.reason);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ const pkg = JSON.parse (fs.readFileSync ('package.json', 'utf-8'));
|
|||||||
fs.writeFileSync ('package.json', JSON.stringify (pkg, null, 2));
|
fs.writeFileSync ('package.json', JSON.stringify (pkg, null, 2));
|
||||||
|
|
||||||
child_process.execSync ('yarn lint', { stdio: 'inherit' });
|
child_process.execSync ('yarn lint', { stdio: 'inherit' });
|
||||||
if (typeof pkg.scripts !== 'undefined' && typeof pkg.scripts.test === 'string')
|
if (typeof pkg.scripts !=='undefined' && typeof pkg.scripts.test === 'string')
|
||||||
child_process.execSync ('yarn test', { stdio: 'inherit' });
|
child_process.execSync ('yarn test', { stdio: 'inherit' });
|
||||||
|
|
||||||
child_process.exec ('git log -1 | grep \'\\[no publish\\]\'')
|
child_process.exec ('git log -1 | grep \'\\[no publish\\]\'')
|
||||||
@ -22,5 +22,6 @@ child_process.exec ('git log -1 | grep \'\\[no publish\\]\'')
|
|||||||
console.log ('build not marked for deployment');
|
console.log ('build not marked for deployment');
|
||||||
process.exit (1);
|
process.exit (1);
|
||||||
}
|
}
|
||||||
else { child_process.execSync ('yarn publish'); }
|
else
|
||||||
|
child_process.execSync ('yarn publish');
|
||||||
});
|
});
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
/* eslint-disable no-sync */
|
/* eslint-disable no-sync */
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const fs = require ('fs-extra');
|
const fs = require ('fs-extra');
|
||||||
const path = require ('path');
|
const path = require ('path');
|
||||||
|
|
||||||
@ -59,12 +57,11 @@ function assert (folder, args) {
|
|||||||
reason: 'migration already exists'
|
reason: 'migration already exists'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
for (const test of tests) {
|
for (const test of tests)
|
||||||
if (!test.f ()) {
|
if (!test.f ()) {
|
||||||
console.log (test.reason);
|
console.log (test.reason);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
/* eslint-disable no-magic-numbers */
|
/* eslint-disable no-magic-numbers */
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* execute migration
|
* execute migration
|
||||||
*
|
*
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
/* eslint-disable no-sync */
|
/* eslint-disable no-sync */
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const fs = require ('fs-extra');
|
const fs = require ('fs-extra');
|
||||||
const path = require ('path');
|
const path = require ('path');
|
||||||
const child_process = require ('child_process');
|
const child_process = require ('child_process');
|
||||||
@ -28,7 +26,7 @@ async function run (folder, args) {
|
|||||||
const template = path.join (__dirname, 'template');
|
const template = path.join (__dirname, 'template');
|
||||||
if (!fs.existsSync (snip_folder))
|
if (!fs.existsSync (snip_folder))
|
||||||
fs.mkdir (snip_folder);
|
fs.mkdir (snip_folder);
|
||||||
for (const f of fs.readdirSync (template)) {
|
for (const f of fs.readdirSync (template))
|
||||||
fs.copy (
|
fs.copy (
|
||||||
path.join (template, f),
|
path.join (template, f),
|
||||||
path.join (snip_folder, f),
|
path.join (snip_folder, f),
|
||||||
@ -37,7 +35,6 @@ async function run (folder, args) {
|
|||||||
filter: (src, dest) => !fs.existsSync (dest)
|
filter: (src, dest) => !fs.existsSync (dest)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
child_process.execSync (
|
child_process.execSync (
|
||||||
'git init',
|
'git init',
|
||||||
@ -109,12 +106,11 @@ function assert (folder, args) {
|
|||||||
reason: 'folder already exists'
|
reason: 'folder already exists'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
for (const test of tests) {
|
for (const test of tests)
|
||||||
if (!test.f ()) {
|
if (!test.f ()) {
|
||||||
console.log (test.reason);
|
console.log (test.reason);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
/* eslint-disable no-sync */
|
/* eslint-disable no-sync */
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const fs = require ('fs-extra');
|
const fs = require ('fs-extra');
|
||||||
const path = require ('path');
|
const path = require ('path');
|
||||||
|
|
||||||
@ -59,12 +57,11 @@ function assert (folder, args) {
|
|||||||
reason: 'file already exists'
|
reason: 'file already exists'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
for (const test of tests) {
|
for (const test of tests)
|
||||||
if (!test.f ()) {
|
if (!test.f ()) {
|
||||||
console.log (test.reason);
|
console.log (test.reason);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
module.exports = function handler (req, res, next, opts) {
|
module.exports = function handler (req, res, next, opts) {
|
||||||
if (req.headers.example === 'abc')
|
if (req.headers.example === 'abc')
|
||||||
res.writeHead (1);
|
res.writeHead (1);
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
/* eslint-disable no-sync */
|
/* eslint-disable no-sync */
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const fs = require ('fs-extra');
|
const fs = require ('fs-extra');
|
||||||
const path = require ('path');
|
const path = require ('path');
|
||||||
|
|
||||||
@ -27,7 +25,7 @@ function run (folder, args) {
|
|||||||
const template = path.join (__dirname, 'template');
|
const template = path.join (__dirname, 'template');
|
||||||
if (!fs.existsSync (snip_folder))
|
if (!fs.existsSync (snip_folder))
|
||||||
fs.mkdir (snip_folder);
|
fs.mkdir (snip_folder);
|
||||||
for (const f of fs.readdirSync (template)) {
|
for (const f of fs.readdirSync (template))
|
||||||
fs.copy (
|
fs.copy (
|
||||||
path.join (template, f),
|
path.join (template, f),
|
||||||
path.join (snip_folder, f),
|
path.join (snip_folder, f),
|
||||||
@ -36,7 +34,6 @@ function run (folder, args) {
|
|||||||
filter: (src, dest) => !fs.existsSync (dest)
|
filter: (src, dest) => !fs.existsSync (dest)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,12 +75,11 @@ function assert (folder, args) {
|
|||||||
reason: 'folder already exists'
|
reason: 'folder already exists'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
for (const test of tests) {
|
for (const test of tests)
|
||||||
if (!test.f ()) {
|
if (!test.f ()) {
|
||||||
console.log (test.reason);
|
console.log (test.reason);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
/* eslint-disable no-sync */
|
/* eslint-disable no-sync */
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const fs = require ('fs-extra');
|
const fs = require ('fs-extra');
|
||||||
const path = require ('path');
|
const path = require ('path');
|
||||||
|
|
||||||
@ -27,7 +25,7 @@ function run (folder, args) {
|
|||||||
const template = path.join (__dirname, 'template');
|
const template = path.join (__dirname, 'template');
|
||||||
if (!fs.existsSync (snip_folder))
|
if (!fs.existsSync (snip_folder))
|
||||||
fs.mkdir (snip_folder);
|
fs.mkdir (snip_folder);
|
||||||
for (const f of fs.readdirSync (template)) {
|
for (const f of fs.readdirSync (template))
|
||||||
fs.copy (
|
fs.copy (
|
||||||
path.join (template, f),
|
path.join (template, f),
|
||||||
path.join (snip_folder, f),
|
path.join (snip_folder, f),
|
||||||
@ -36,7 +34,6 @@ function run (folder, args) {
|
|||||||
filter: (src, dest) => !fs.existsSync (dest)
|
filter: (src, dest) => !fs.existsSync (dest)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,12 +75,11 @@ function assert (folder, args) {
|
|||||||
reason: 'folder already exists'
|
reason: 'folder already exists'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
for (const test of tests) {
|
for (const test of tests)
|
||||||
if (!test.f ()) {
|
if (!test.f ()) {
|
||||||
console.log (test.reason);
|
console.log (test.reason);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user