console/patches/@tgriesser__schemats@7.0.1.patch

50 lines
2.1 KiB
Diff

diff --git a/bin/schemats.js b/bin/schemats.js
index f467148..c2e2059 100755
--- a/bin/schemats.js
+++ b/bin/schemats.js
@@ -41,6 +41,7 @@ let argv = yargs
.describe('o', 'output file name')
.describe('sqlite3', 'For sqlite3 dbs')
.describe('skipTables', 'tables to skip')
+ .describe('skipPrefix', 'tables to skip by their prefix')
.describe('customTypes', 'Mapping of custom types for a table column')
.describe('customHeader', 'Custom header to prefix the output file')
.help('h')
@@ -68,6 +69,9 @@ let argv = yargs
skipTables: typeof argv.skipTables === 'string'
? [argv.skipTables]
: argv.skipTables,
+ skipPrefix: typeof argv.skipPrefix === 'string'
+ ? [argv.skipPrefix]
+ : argv.skipPrefix,
});
fs.writeFileSync(argv.output, formattedOutput);
}
diff --git a/src/index.js b/src/index.js
index 27a7b2e..9f47d6e 100644
--- a/src/index.js
+++ b/src/index.js
@@ -40,10 +40,9 @@ function buildHeader(db, tables, schema, options) {
}
return `
/**
- * AUTO-GENERATED FILE @ ${getTime()} - DO NOT EDIT!
+ * AUTO-GENERATED FILE - DO NOT EDIT!
*
* This file was automatically generated by schemats v.${pkgVersion}
- * $ ${commands.join(' ')}
*
*/
@@ -79,6 +78,11 @@ async function typescriptOfSchema(db, tables = [], schema = null, options = {})
if ((_a = options.skipTables) === null || _a === void 0 ? void 0 : _a.length) {
tables = tables.filter(t => { var _a; return !((_a = options.skipTables) === null || _a === void 0 ? void 0 : _a.includes(t)); });
}
+
+ if (options.skipPrefix && options.skipPrefix.length > 0) {
+ tables = tables.filter(t => !options.skipPrefix.some(prefix => t.startsWith(prefix)));
+ }
+
const optionsObject = new options_1.default(options);
const enumTypes = typescript_1.generateEnumType(await db.getEnumTypes(schema), optionsObject);
const interfacePromises = tables.map(table => typescriptOfTable(db, table, schema, optionsObject));