-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit eec9f99
Showing
13 changed files
with
1,115 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.sqlite | ||
node_modules | ||
dist | ||
!master.sqlite |
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 @@ | ||
nvm use 9 |
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,33 @@ | ||
{ | ||
"name": "mikeworks-sql", | ||
"version": "0.0.0", | ||
"description": "Mike.Works SQL Fundamentals Course", | ||
"main": "index.js", | ||
"repository": "https://github.com/mike-north/sql-fundamentals.git", | ||
"author": "Mike North <michael.l.north@gmail.com> (https://mike.works)", | ||
"license": "NOLICENSE", | ||
"private": true, | ||
"engines": { | ||
"node": ">= 9" | ||
}, | ||
"scripts": { | ||
"start": "scripty", | ||
"build": "scripty" | ||
}, | ||
"dependencies": { | ||
"chalk": "^2.3.0", | ||
"commander": "^2.11.0", | ||
"debug": "^3.1.0", | ||
"express": "^4.16.2", | ||
"sqlite3": "^3.1.13", | ||
"scripty": "^1.7.2" | ||
}, | ||
"devDependencies": { | ||
"@types/chalk": "^2.2.0", | ||
"@types/commander": "^2.11.0", | ||
"@types/debug": "0.0.30", | ||
"@types/node": "^8.0.53", | ||
"@types/sqlite3": "^3.1.1", | ||
"typescript": "^2.6.1" | ||
} | ||
} |
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,2 @@ | ||
#!/bin/bash | ||
tsc |
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,3 @@ | ||
#!/bin/bash | ||
npm run build | ||
node dist/index.js |
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,5 @@ | ||
import { join } from "path"; | ||
|
||
export const PROJECT_ROOT = join(__dirname, '..'); | ||
export const MASTER_DB_NAME = 'master.sqlite'; | ||
export const MASTER_DB_FILE = join(PROJECT_ROOT, MASTER_DB_NAME); |
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,22 @@ | ||
import { promisify } from "util"; | ||
import * as path from "path"; | ||
import * as fs from "fs"; | ||
import * as debug from 'debug'; | ||
import { PROJECT_ROOT, MASTER_DB_FILE } from "../constants"; | ||
import { dbPath } from "./utils"; | ||
|
||
const copyFile = promisify(fs.copyFile); | ||
const exists = promisify(fs.exists); | ||
|
||
const log = debug('db:setup'); | ||
|
||
export async function initializeDb(dbName = 'dev') { | ||
let pth = dbPath(dbName); | ||
let doesExist = await exists(pth); | ||
if (!doesExist) { | ||
log(`Database ${dbName} was not found at ${pth}... creating it now`); | ||
await await copyFile(MASTER_DB_FILE, pth); | ||
} else { | ||
log(`Database ${dbName} was found at ${pth}...`); | ||
} | ||
} |
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,4 @@ | ||
import * as path from 'path'; | ||
import { PROJECT_ROOT } from "../constants"; | ||
|
||
export const dbPath = (name: string) => path.join(PROJECT_ROOT, `${name}.sqlite`); |
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,15 @@ | ||
import { existsSync } from "fs"; | ||
import * as commander from 'commander'; | ||
import { PROJECT_ROOT } from "./constants"; | ||
import { initializeDb } from "./db/setup"; | ||
import chalk from 'chalk'; | ||
|
||
const pkg = require('../package.json'); | ||
|
||
const app = commander | ||
.version(pkg.version) | ||
.parse(process.argv); | ||
|
||
(async function main() { | ||
await initializeDb('dev'); | ||
}()) |
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,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es2017", | ||
"inlineSourceMap": true, | ||
"moduleResolution": "node", | ||
"outDir": "dist", | ||
"strict": true, | ||
"allowJs": true | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
Oops, something went wrong.