-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore main file. Add CLI for BigQuery schema generation.
- Loading branch information
Showing
5 changed files
with
83 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,5 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
|
||
tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { getBigQuerySchema } from "./helpers/bigquerySchema"; | ||
import { writeFile } from "./helpers/fs"; | ||
import { generateJSONSchema } from "./helpers/jsonSchema"; | ||
|
||
const writeBigQuerySchema = async (object: string, typesFilePath: string): Promise<void> => { | ||
const schema = await generateJSONSchema(object, typesFilePath); | ||
|
||
const bqSchema = await getBigQuerySchema(schema); | ||
writeFile(`./tmp/${object}_schema.json`, bqSchema); | ||
}; | ||
|
||
// Runs via CLI | ||
if (require.main === module) { | ||
if (process.argv.length !== 4) { | ||
throw new Error(`2 arguments are required, but the app received: ${JSON.stringify(process.argv.slice(2))}`); | ||
} | ||
|
||
writeBigQuerySchema(process.argv[2], process.argv[3]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters