quick-erd
Version:
quick and easy text-based ERD + code generator for migration, query, typescript types and orm entity
57 lines (56 loc) • 1.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.erd_file = exports.public_dir = exports.port = void 0;
const fs_1 = require("fs");
const path_1 = require("path");
exports.port = +process.env.PORT || 8520;
{
for (let i = 2; i < process.argv.length; i++) {
const arg = process.argv[i];
if (arg == '-p' || arg == '--port') {
exports.port = +process.argv[++i];
if (!exports.port) {
console.error('Invalid port: ' + process.argv[i]);
process.exit(1);
}
}
}
}
exports.public_dir = (0, path_1.join)(__dirname, '..', '..', 'build');
{
const file = (0, path_1.join)(exports.public_dir, 'index.html');
if (!(0, fs_1.existsSync)(file)) {
console.error('Could not locate public directory');
process.exit(1);
}
}
exports.erd_file = '';
{
const files = [
/* in current directory */
'erd.txt',
/* in ts-liveview db project */
'db/erd.txt',
/* in case it is put into the docs directory */
'docs/erd.txt',
'../docs/erd.txt',
];
for (const file of files) {
if ((0, fs_1.existsSync)(file)) {
exports.erd_file = file;
break;
}
}
for (let i = 2; i < process.argv.length; i++) {
const file = process.argv[i];
if (file.includes('erd.txt') || (0, fs_1.existsSync)(file)) {
exports.erd_file = file;
break;
}
}
if (!exports.erd_file) {
console.error('Missing erd.txt file');
console.error('Please specify it in the argument.');
process.exit(1);
}
}