Skip to content

Commit

Permalink
Merge pull request #9 from halvardssm/remove-import-maps
Browse files Browse the repository at this point in the history
moved from import maps to deps.ts
  • Loading branch information
halvardssm authored Apr 30, 2020
2 parents c18fe57 + 5fec887 commit cdcde04
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 47 deletions.
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ DB_NAME=nessie

CONFIG_FILE=./tests/config/mysql.config.ts
DB_URL=postgres://${DB_USER}:${DB_PWD@localhost:${DB_PG_PORT}/${DB_NAME}
IMPORT_MAP=--unstable --importmap=import_map.json

migration-%:
deno run ${IMPORT_MAP} --allow-write --allow-read cli.ts make $* -c ${CONFIG_FILE}
deno run --allow-write --allow-read cli.ts make $* -c ${CONFIG_FILE}
migrate:
deno run ${IMPORT_MAP} --allow-net --allow-read cli.ts migrate -c ${CONFIG_FILE}
deno run --allow-net --allow-read cli.ts migrate -c ${CONFIG_FILE}
rollback:
deno run ${IMPORT_MAP} --allow-net --allow-read cli.ts rollback -c ${CONFIG_FILE}
deno run --allow-net --allow-read cli.ts rollback -c ${CONFIG_FILE}

test:
deno test ${IMPORT_MAP} --allow-write --allow-run
deno test --allow-write --allow-run
test-clean: db-all-restart sleeper test
sleeper:
sleep 30s
Expand Down
2 changes: 1 addition & 1 deletion cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Denomander from "denomander";
import { Denomander } from "./deps.ts";
import { _nessieConfig } from "./nessie.config.ts";
import { State } from "./cli/state.ts";

Expand Down
6 changes: 3 additions & 3 deletions cli/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
COL_FILE_NAME,
} from "./utils.ts";
import { State } from "./state.ts";
import { Client } from "mysql";
import { MySQLClient } from "../deps.ts";
import Schema from "../src/Schema.ts";

export class MySQL implements ClientI {
private state: State;
private client: Client;
private client: MySQLClient;

constructor(state: State, client: Client) {
constructor(state: State, client: MySQLClient) {
this.state = state;
this.client = client;
}
Expand Down
6 changes: 3 additions & 3 deletions cli/pgsql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import {
queryHandler,
} from "./utils.ts";
import Schema from "../src/Schema.ts";
import { Client } from "postgres";
import { PGClient } from "../deps.ts";
import { State } from "./state.ts";

const QUERY_TRIGGER_UPDATE_AT =
"CREATE OR REPLACE FUNCTION trigger_set_timestamp() RETURNS TRIGGER AS $$ BEGIN NEW.updated_at = now(); RETURN NEW; END; $$ language 'plpgsql';";

export class PGSQL implements ClientI {
private state: State;
private client: Client;
private client: PGClient;

constructor(state: State, client: Client) {
constructor(state: State, client: PGClient) {
this.state = state;
this.client = client;
}
Expand Down
6 changes: 3 additions & 3 deletions cli/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import {
queryHandler,
} from "./utils.ts";
import Schema from "../src/Schema.ts";
import { DB, save } from "sqlite";
import { SQLiteClient, save } from "../deps.ts";
import { State } from "./state.ts";

export class SQLite implements ClientI {
private state: State;
private client: DB;
private client: SQLiteClient;
private query: (query: string) => (any[] | undefined)[];

constructor(state: State, client: DB) {
constructor(state: State, client: SQLiteClient) {
this.state = state;
this.client = client;
this.query = (query: string) => [...client.query(query, [])];
Expand Down
12 changes: 6 additions & 6 deletions cli/state.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { _nessieConfig, nessieConfig } from "../nessie.config.ts";
import Denomander from "denomander";
import { Denomander } from "../deps.ts";
import {
Client as MySQLClient,
MySQLClient,
ClientConfig,
} from "mysql";
import { Client as PGClient } from "postgres";
import { open } from "sqlite";
PGClient,
open,
IConnectionParams,
} from "../deps.ts";
import { dbDialects } from "../mod.ts";
import { IConnectionParams } from "postgres/connection_params.ts";
import { PGSQL } from "./pgsql.ts";
import { ClientTypes, ClientI } from "./utils.ts";
import { MySQL } from "./mysql.ts";
Expand Down
4 changes: 1 addition & 3 deletions cli/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { _nessieConfig } from "../nessie.config.ts";
import { Client as MySQLClient } from "mysql";
import { Client as PGClient } from "postgres";
import { DB as SQLiteClient } from "sqlite";
import { MySQLClient, PGClient, SQLiteClient } from "../deps.ts";
import Schema from "../src/Schema.ts";
import { State } from "./state.ts";

Expand Down
19 changes: 19 additions & 0 deletions deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Denomander from "https://deno.land/x/[email protected]/mod.ts";

export { Denomander };
export {
Client as MySQLClient,
ClientConfig,
} from "https://deno.land/x/[email protected]/mod.ts";
export { Client as PGClient } from "https://deno.land/x/[email protected]/mod.ts";
export { IConnectionParams } from "https://deno.land/x/[email protected]/connection_params.ts";
export {
DB as SQLiteClient,
save,
open,
} from "https://deno.land/x/sqlite/mod.ts";
export {
assertEquals,
assert,
assertArrayContains,
} from "https://deno.land/[email protected]/testing/asserts.ts";
10 changes: 0 additions & 10 deletions import_map.json

This file was deleted.

3 changes: 1 addition & 2 deletions nessie.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { dbDialects } from "./mod.ts";
import { IConnectionParams } from "postgres/connection_params.ts";
import { ClientConfig } from "mysql";
import { IConnectionParams, ClientConfig } from "./deps.ts";

export interface nessieConnection {
host: string | "localhost" | "127.0.0.1";
Expand Down
2 changes: 1 addition & 1 deletion tests/column.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "std/testing/asserts.ts";
import { assertEquals } from "../deps.ts";
import { Column } from "../mod.ts";

const strings = [
Expand Down
2 changes: 0 additions & 2 deletions tests/config/migration.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export const runner = async (type: string, dialect: string) => {
cmd: [
"deno",
"run",
"--unstable",
"--importmap=import_map.json",
"--allow-net",
"--allow-read",
"--allow-write",
Expand Down
5 changes: 1 addition & 4 deletions tests/migration.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
assert,
assertArrayContains,
} from "std/testing/asserts.ts";
import { assert, assertArrayContains } from "../deps.ts";
import {
runner,
TYPE_MIGRATE,
Expand Down
2 changes: 1 addition & 1 deletion tests/schema.mysql.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Schema } from "../mod.ts";
import { assertEquals } from "std/testing/asserts.ts";
import { assertEquals } from "../deps.ts";

const strings = [
{
Expand Down
2 changes: 1 addition & 1 deletion tests/schema.pg.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Schema } from "../mod.ts";
import { assertEquals } from "std/testing/asserts.ts";
import { assertEquals } from "../deps.ts";

const strings = [
{
Expand Down
2 changes: 1 addition & 1 deletion tests/table.mysql.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "std/testing/asserts.ts";
import { assertEquals } from "../deps.ts";
import { Table } from "../mod.ts";

const mySqlStrings = [
Expand Down
2 changes: 1 addition & 1 deletion tests/table.pg.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "std/testing/asserts.ts";
import { assertEquals } from "../deps.ts";
import { Table } from "../mod.ts";

const pgStrings = [
Expand Down

0 comments on commit cdcde04

Please sign in to comment.