velocious 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +12 -2
  2. package/bin/velocious.mjs +3 -3
  3. package/index.mjs +5 -1
  4. package/package.json +4 -3
  5. package/peak_flow.yml +5 -2
  6. package/spec/cli/commands/db/create-spec.mjs +25 -0
  7. package/spec/cli/commands/db/migrate-spec.mjs +37 -0
  8. package/spec/cli/commands/destroy/migration-spec.mjs +15 -0
  9. package/spec/cli/commands/generate/migration-spec.mjs +18 -0
  10. package/spec/cli/commands/init-spec.mjs +19 -0
  11. package/spec/cli/commands/test/test-files-finder-spec.mjs +12 -0
  12. package/spec/database/drivers/mysql/connection-spec.mjs +2 -2
  13. package/spec/dummy/dummy-directory.mjs +11 -0
  14. package/spec/dummy/index.mjs +18 -24
  15. package/spec/dummy/src/config/configuration.example.mjs +19 -0
  16. package/spec/dummy/src/config/configuration.peakflow.mjs +20 -0
  17. package/spec/dummy/src/database/migrations/20230728075328-create-projects.mjs +11 -0
  18. package/spec/dummy/src/database/migrations/20230728075329-create-tasks.mjs +13 -0
  19. package/spec/http-server/client-spec.mjs +3 -13
  20. package/src/application.mjs +6 -12
  21. package/src/cli/base-command.mjs +11 -0
  22. package/src/cli/commands/db/create.mjs +44 -8
  23. package/src/cli/commands/db/migrate.mjs +58 -0
  24. package/src/cli/commands/destroy/migration.mjs +35 -0
  25. package/src/cli/commands/generate/migration.mjs +31 -7
  26. package/src/cli/commands/init.mjs +60 -0
  27. package/src/cli/commands/test/index.mjs +14 -0
  28. package/src/cli/commands/test/test-files-finder.mjs +99 -0
  29. package/src/cli/commands/test/test-runner.mjs +19 -0
  30. package/src/cli/index.mjs +36 -16
  31. package/src/configuration-resolver.mjs +26 -0
  32. package/src/configuration.mjs +24 -2
  33. package/src/database/drivers/base.mjs +8 -0
  34. package/src/database/drivers/mysql/index.mjs +25 -0
  35. package/src/database/drivers/mysql/sql/create-database.mjs +4 -0
  36. package/src/database/drivers/mysql/sql/create-table.mjs +4 -0
  37. package/src/database/drivers/sqlite/options.mjs +17 -0
  38. package/src/database/drivers/sqlite/query-parser.mjs +25 -0
  39. package/src/database/drivers/sqlite/sql/create-database.mjs +4 -0
  40. package/src/database/drivers/sqlite/sql/create-table.mjs +4 -0
  41. package/src/database/drivers/sqlite/sql/delete.mjs +19 -0
  42. package/src/database/drivers/sqlite/sql/insert.mjs +29 -0
  43. package/src/database/drivers/sqlite/sql/update.mjs +31 -0
  44. package/src/database/drivers/sqlite-expo/index.mjs +100 -0
  45. package/src/database/drivers/sqlite-expo/query.mjs +9 -0
  46. package/src/database/handler.mjs +0 -4
  47. package/src/database/migration/index.mjs +15 -2
  48. package/src/database/pool/index.mjs +87 -18
  49. package/src/database/query/base.mjs +11 -0
  50. package/src/database/query/create-database-base.mjs +20 -0
  51. package/src/database/query/create-table-base.mjs +69 -0
  52. package/src/database/query/delete-base.mjs +4 -10
  53. package/src/database/query/from-plain.mjs +3 -5
  54. package/src/database/query/from-table.mjs +2 -2
  55. package/src/database/record/index.mjs +1 -1
  56. package/src/database/table-data/index.mjs +83 -0
  57. package/src/http-server/worker-handler/worker-thread.mjs +17 -8
  58. package/src/routes/resolver.mjs +3 -1
  59. package/src/spec/index.mjs +5 -0
  60. package/src/templates/configuration.mjs +17 -0
  61. package/src/templates/generate-migration.mjs +11 -0
  62. package/src/templates/routes.mjs +11 -0
  63. package/src/utils/file-exists.mjs +13 -0
  64. package/spec/cli/generate/migration-spec.mjs +0 -9
  65. package/spec/dummy/src/config/database.example.mjs +0 -15
  66. package/spec/dummy/src/config/database.peakflow.mjs +0 -15
  67. package/spec/dummy/src/database/migrations/001-create-tasks.mjs +0 -12
@@ -0,0 +1,100 @@
1
+ import Base from "../base.mjs"
2
+ import CreateDatabase from "../sqlite/sql/create-database.mjs"
3
+ import CreateTable from "../sqlite/sql/create-table.mjs"
4
+ import Delete from "../sqlite/sql/delete.mjs"
5
+ import {digg} from "diggerize"
6
+ import Insert from "../sqlite/sql/insert.mjs"
7
+ import Options from "../sqlite/options.mjs"
8
+ import query from "./query.mjs"
9
+ import QueryParser from "../sqlite/query-parser.mjs"
10
+ import * as SQLite from "expo-sqlite"
11
+ import Update from "../sqlite/sql/update.mjs"
12
+
13
+ export default class VelociousDatabaseDriversMysql extends Base{
14
+ async connect() {
15
+ const connection = await SQLite.openDatabaseAsync(digg(this.connectArgs(), "name"))
16
+
17
+ this.connection = connection
18
+ }
19
+
20
+ disconnect() {
21
+ this.connection.end()
22
+ }
23
+
24
+ connectArgs() {
25
+ const args = this.getArgs()
26
+ const connectArgs = []
27
+ const forward = ["database", "host", "password"]
28
+
29
+ for (const forwardValue of forward) {
30
+ if (forwardValue in args) connectArgs[forwardValue] = digg(args, forwardValue)
31
+ }
32
+
33
+ if ("username" in args) connectArgs["user"] = args["username"]
34
+
35
+ return connectArgs
36
+ }
37
+
38
+ async close() {
39
+ await this.connection.end()
40
+ this.connection = undefined
41
+ }
42
+
43
+ createDatabaseSql(databaseName, args) {
44
+ const createArgs = Object.assign({databaseName, driver: this}, args)
45
+ const createDatabase = new CreateDatabase(createArgs)
46
+
47
+ return createDatabase.toSql()
48
+ }
49
+
50
+ createTableSql(tableData) {
51
+ const createArgs = Object.assign({tableData, driver: this})
52
+ const createTable = new CreateTable(createArgs)
53
+
54
+ return createTable.toSql()
55
+ }
56
+
57
+ async query(sql) {
58
+ return await query(this.connection, sql)
59
+ }
60
+
61
+ queryToSql(query) {
62
+ return new QueryParser({query}).toSql()
63
+ }
64
+
65
+ quote(string) {
66
+ if (!this.connection) throw new Error("Can't escape before connected")
67
+
68
+ return this.connection.escape(string)
69
+ }
70
+
71
+ quoteColumn(string) {
72
+ return `\`${string}\``
73
+ }
74
+
75
+ deleteSql({tableName, conditions}) {
76
+ const deleteInstruction = new Delete({conditions, driver: this, tableName})
77
+
78
+ return deleteInstruction.toSql()
79
+ }
80
+
81
+ insertSql({tableName, data}) {
82
+ const insert = new Insert({driver: this, tableName, data})
83
+
84
+ return insert.toSql()
85
+ }
86
+
87
+ options() {
88
+ if (!this._options) {
89
+ this._options = new Options({driver: this})
90
+ }
91
+
92
+ return this._options
93
+ }
94
+
95
+ updateSql({conditions, data, tableName}) {
96
+ const update = new Update({conditions, data, driver: this, tableName})
97
+
98
+ return update.toSql()
99
+ }
100
+ }
@@ -0,0 +1,9 @@
1
+ export default async function query(connection, sql) {
2
+ const rows = []
3
+
4
+ for await (const entry of connection.getEachAsync(sql)) {
5
+ rows.push(entry)
6
+ }
7
+
8
+ return rows
9
+ }
@@ -1,8 +1,4 @@
1
1
  export default class VelociousDatabaseHandler {
2
- constructor() {
3
- console.log("stub")
4
- }
5
-
6
2
  clone() {
7
3
  const newHandler = new VelociousDatabaseHandler()
8
4
 
@@ -1,5 +1,18 @@
1
+ import TableData from "../table-data/index.mjs"
2
+
1
3
  export default class VelociousDatabaseMigration {
2
- createTable(tableName, callback) {
3
- throw new Error("stub")
4
+ constructor({configuration}) {
5
+ this.configuration = configuration
6
+ }
7
+
8
+ async createTable(tableName, callback) {
9
+ const tableData = new TableData(tableName)
10
+
11
+ callback(tableData)
12
+
13
+ const databasePool = this.configuration.databasePool
14
+ const sql = databasePool.createTableSql(tableData)
15
+
16
+ await databasePool.query(sql)
4
17
  }
5
18
  }
@@ -1,43 +1,112 @@
1
+ import {AsyncLocalStorage} from "node:async_hooks"
1
2
  import Configuration from "../../configuration.mjs"
2
3
  import {digg} from "diggerize"
3
4
 
4
- export default class VelociousDatabasePool {
5
+ const asyncLocalStorage = new AsyncLocalStorage()
6
+ let idSeq = 0
7
+
8
+ class VelociousDatabasePool {
5
9
  static current() {
6
10
  if (!global.velociousDatabasePool) global.velociousDatabasePool = new VelociousDatabasePool()
7
11
 
8
12
  return global.velociousDatabasePool
9
13
  }
10
14
 
11
- async connect() {
12
- if (this.connection) {
13
- console.warn("DatabasePoool#connect: Already connected")
14
- } else {
15
- this.connection = await this.spawnConnection()
15
+ constructor(args = {}) {
16
+ this.configuration = args.configuration || Configuration.current()
17
+ this.connections = []
18
+ this.connectionsInUse = {}
19
+ }
16
20
 
17
- if (!this.connection) throw new Error("spawnConnection didn't set a connection")
21
+ checkin = (connection) => {
22
+ const id = connection.getIdSeq()
18
23
 
19
- await this.connection.connect()
24
+ if (id in this.connectionsInUse) {
25
+ delete this.connectionsInUse[id]
20
26
  }
27
+
28
+ connection.setIdSeq(undefined)
29
+
30
+ this.connections.push(connection)
21
31
  }
22
32
 
23
- isConnected = () => Boolean(this.connection)
33
+ async checkout() {
34
+ let connection = this.connections.shift()
24
35
 
25
- singleConnection() {
26
- if (!this.connection) throw new Error("Not connected")
36
+ if (!connection) {
37
+ connection = await this.spawnConnection()
38
+ }
27
39
 
28
- return this.connection
40
+ if (connection.getIdSeq() !== undefined) throw new Error(`Connection already has an ID-seq - is it in use? ${connection.getIdSeq()}`)
41
+
42
+ const id = idSeq++
43
+
44
+ connection.setIdSeq(id)
45
+ this.connectionsInUse[id] = connection
46
+
47
+ return connection
48
+ }
49
+
50
+ getConfiguration = () => digg(this, "configuration", "database", "default", "master")
51
+
52
+ setCurrent() {
53
+ global.velociousDatabasePool = this
29
54
  }
30
55
 
31
56
  async spawnConnection() {
32
- const databaseConfigPath = `${Configuration.current().directory}/src/config/database.mjs`
33
- const {databaseConfiguration} = await import(databaseConfigPath)
34
- const config = databaseConfiguration()
35
- const defaultConfig = digg(config, "default", "master")
36
- const driverPath = `../drivers/${digg(defaultConfig, "type")}/index.mjs`
57
+ const defaultConfig = this.getConfiguration()
58
+ const connection = await this.spawnConnectionWithConfiguration(defaultConfig)
59
+
60
+ return connection
61
+ }
62
+
63
+ async spawnConnectionWithConfiguration(config) {
64
+ const driverPath = `../drivers/${digg(config, "type")}/index.mjs`
37
65
  const DriverClassImport = await import(driverPath)
38
66
  const DriverClass = DriverClassImport.default
39
- const connection = new DriverClass(defaultConfig)
67
+ const connection = new DriverClass(config)
68
+
69
+ await connection.connect()
40
70
 
41
71
  return connection
42
72
  }
73
+
74
+ async withConnection(callback) {
75
+ const connection = await this.checkout()
76
+ const id = connection.getIdSeq()
77
+
78
+ await asyncLocalStorage.run(id, async () => {
79
+ try {
80
+ await callback()
81
+ } finally {
82
+ this.checkin(connection)
83
+ }
84
+ })
85
+ }
86
+
87
+ getCurrentConnection() {
88
+ const id = asyncLocalStorage.getStore()
89
+
90
+ if (id === undefined) {
91
+ throw new Error("ID hasn't been set for this async context")
92
+ }
93
+
94
+ if (!(id in this.connectionsInUse)) {
95
+ throw new Error(`Connection ${id} doesn't exist any more - has it been checked in again?`)
96
+ }
97
+
98
+ return this.connectionsInUse[id]
99
+ }
100
+ }
101
+
102
+ const forwardMethods = ["createTableSql", "deleteSql", "insertSql", "query", "quote", "updateSql"]
103
+
104
+ for (const forwardMethod of forwardMethods) {
105
+ VelociousDatabasePool.prototype[forwardMethod] = function(...args) {
106
+ const connection = this.getCurrentConnection()
107
+
108
+ return connection[forwardMethod](...args)
109
+ }
43
110
  }
111
+
112
+ export default VelociousDatabasePool
@@ -0,0 +1,11 @@
1
+ export default class VelociousDatabaseQueryBase {
2
+ constructor({driver}) {
3
+ this.driver = driver
4
+ }
5
+
6
+ getOptions = () => this.driver?.options()
7
+
8
+ toSql() {
9
+ throw new Error("'toSql' wasn't implemented")
10
+ }
11
+ }
@@ -0,0 +1,20 @@
1
+ import QueryBase from "./base.mjs"
2
+
3
+ export default class VelociousDatabaseQueryCreateDatabaseBase extends QueryBase {
4
+ constructor({driver, databaseName, ifNotExists}) {
5
+ super({driver})
6
+ this.databaseName = databaseName
7
+ this.ifNotExists = ifNotExists
8
+ }
9
+
10
+ toSql() {
11
+ const {databaseName} = this
12
+ let sql = "CREATE DATABASE"
13
+
14
+ if (this.ifNotExists) sql += " IF NOT EXISTS"
15
+
16
+ sql += ` ${databaseName}`
17
+
18
+ return sql
19
+ }
20
+ }
@@ -0,0 +1,69 @@
1
+ import QueryBase from "./base.mjs"
2
+
3
+ export default class VelociousDatabaseQueryCreateTableBase extends QueryBase {
4
+ constructor({driver, ifNotExists, tableData}) {
5
+ super({driver})
6
+ this.ifNotExists = ifNotExists
7
+ this.tableData = tableData
8
+ }
9
+
10
+ toSql() {
11
+ const {tableData} = this
12
+ let sql = "CREATE TABLE"
13
+
14
+ if (this.ifNotExists || tableData.getIfNotExists()) sql += " IF NOT EXISTS"
15
+
16
+ sql += ` ${tableData.getName()} (`
17
+
18
+ let columnCount = 0
19
+
20
+ for (const column of tableData.getColumns()) {
21
+ columnCount++
22
+
23
+ let maxlength = column.args.maxlength
24
+ let type = column.args.type
25
+
26
+ if (type == "string") {
27
+ type = "varchar"
28
+ maxlength ||= 255
29
+ }
30
+
31
+ if (columnCount > 1) sql += ", "
32
+
33
+ sql += `${this.driver.quoteColumn(column.name)} ${type}`
34
+
35
+ if (maxlength !== undefined) sql += `(${maxlength})`
36
+
37
+ if (column.args.autoIncrement) sql += " AUTO_INCREMENT"
38
+ if (column.args.primaryKey) sql += " PRIMARY KEY"
39
+ }
40
+
41
+ for (const index of tableData.getIndexes()) {
42
+ sql += ","
43
+
44
+ if (index.getUnique()) {
45
+ sql += " UNIQUE"
46
+ }
47
+
48
+ sql += " INDEX"
49
+
50
+ if (index.getName()) {
51
+ sql += ` ${index.getName()}`
52
+ }
53
+
54
+ sql += " ("
55
+
56
+ index.getColumns().forEach((column, columnIndex) => {
57
+ if (columnIndex > 0) sql += ", "
58
+
59
+ sql += this.driver.quoteColumn(column.name)
60
+ })
61
+
62
+ sql += ")"
63
+ }
64
+
65
+ sql += ")"
66
+
67
+ return sql
68
+ }
69
+ }
@@ -1,15 +1,9 @@
1
- export default class VelociousDatabaseQueryDeleteBase {
1
+ import QueryBase from "./base.mjs"
2
+
3
+ export default class VelociousDatabaseQueryDeleteBase extends QueryBase {
2
4
  constructor({conditions, driver, tableName}) {
5
+ super({driver})
3
6
  this.conditions = conditions
4
- this.driver = driver
5
7
  this.tableName = tableName
6
8
  }
7
-
8
- getOptions() {
9
- return this.driver.options()
10
- }
11
-
12
- toSql() {
13
- throw new Error("'toSql' wasn't implemented")
14
- }
15
9
  }
@@ -1,12 +1,10 @@
1
1
  import FromBase from "./from-base.mjs"
2
2
 
3
3
  export default class VelociousDatabaseQueryFromPlain extends FromBase {
4
- constructor({plain}) {
5
- super()
4
+ constructor({driver, plain}) {
5
+ super({driver})
6
6
  this.plain = plain
7
7
  }
8
8
 
9
- toSql() {
10
- return this.plain
11
- }
9
+ toSql = () => this.plain
12
10
  }
@@ -1,8 +1,8 @@
1
1
  import FromBase from "./from-base.mjs"
2
2
 
3
3
  export default class VelociousDatabaseQueryFromTable extends FromBase {
4
- constructor({tableName}) {
5
- super()
4
+ constructor({driver, tableName}) {
5
+ super({driver})
6
6
  this.tableName = tableName
7
7
  }
8
8
 
@@ -6,7 +6,7 @@ import RecordNotFoundError from "./record-not-found-error.mjs"
6
6
 
7
7
  export default class VelociousDatabaseRecord {
8
8
  static connection() {
9
- const connection = DatabasePool.current().singleConnection()
9
+ const connection = DatabasePool.current().getCurrentConnection()
10
10
 
11
11
  if (!connection) throw new Error("No connection?")
12
12
 
@@ -0,0 +1,83 @@
1
+ class TableColumn {
2
+ constructor(name, args) {
3
+ this.args = args
4
+ this.name = name
5
+ }
6
+ }
7
+
8
+ class TableIndex {
9
+ constructor(columns, args) {
10
+ this.args = args
11
+ this.columns = columns
12
+ }
13
+
14
+ getColumns = () => this.columns
15
+ getName = () => this.args.name
16
+ getUnique = () => Boolean(this.args.unique)
17
+ }
18
+
19
+ class TableReference {
20
+ constructor(name, args) {
21
+ this.args = args
22
+ this.name = name
23
+ }
24
+ }
25
+
26
+ export default class TableData {
27
+ _columns = []
28
+ _indexes = []
29
+ _references = []
30
+
31
+ constructor(name, args = {}) {
32
+ this.args = args
33
+ this._name = name
34
+ }
35
+
36
+ getColumns = () => this._columns
37
+ getName = () => this._name
38
+ getIfNotExists = () => this.args.ifNotExists
39
+ getIndexes = () => this._indexes
40
+ getReferences = () => this._references
41
+
42
+ bigint(name, args = {}) {
43
+ const columnArgs = Object.assign({type: "bigint"}, args)
44
+ const column = new TableColumn(name, columnArgs)
45
+
46
+ this._columns.push(column)
47
+ }
48
+
49
+ references(name, args = {}) {
50
+ const columnName = `${name}_id`
51
+ const indexName = `index_on_${columnName}`
52
+ const reference = new TableReference(name, args)
53
+ const columnArgs = Object.assign({type: "bigint"}, args)
54
+ const column = new TableColumn(columnName, columnArgs)
55
+ const index = new TableIndex([column], {name: indexName})
56
+
57
+ this._columns.push(column)
58
+ this._indexes.push(index)
59
+ this._references.push(reference)
60
+ }
61
+
62
+ string(name, args) {
63
+ const columnArgs = Object.assign({type: "string"}, args)
64
+ const column = new TableColumn(name, columnArgs)
65
+
66
+ this._columns.push(column)
67
+ }
68
+
69
+ text(name, args) {
70
+ const columnArgs = Object.assign({type: "text"}, args)
71
+ const column = new TableColumn(name, columnArgs)
72
+
73
+ this._columns.push(column)
74
+ }
75
+
76
+ timestamps() {
77
+ const createdAtColumn = new TableColumn("created_at", {type: "datetime"})
78
+ const updatedAtColumn = new TableColumn("updated_at", {type: "datetime"})
79
+
80
+ this._columns.push(createdAtColumn)
81
+ this._columns.push(updatedAtColumn)
82
+ }
83
+ }
@@ -7,26 +7,35 @@ import logger from "../../logger.mjs"
7
7
 
8
8
  export default class VelociousHttpServerWorkerHandlerWorkerThread {
9
9
  constructor({parentPort, workerData}) {
10
- const {debug, directory, workerCount} = digs(workerData, "debug", "directory", "workerCount")
10
+ const {workerCount} = digs(workerData, "workerCount")
11
11
 
12
- this.application = new Application({debug, directory})
13
- this.databasePool = DatabasePool.current()
14
12
  this.clients = {}
15
- this.configuration = this.application.configuration
16
13
  this.parentPort = parentPort
14
+ this.workerData = workerData
17
15
  this.workerCount = workerCount
18
16
 
19
17
  parentPort.on("message", errorLogger(this.onCommand))
20
18
 
21
- logger(this, `Worker ${workerCount} started`)
22
-
23
- this.application.initialize().then(() => {
24
- this.databasePool.connect().then(() => {
19
+ this.initialize().then(() => {
20
+ this.application.initialize().then(() => {
21
+ logger(this, `Worker ${workerCount} started`)
25
22
  parentPort.postMessage({command: "started"})
26
23
  })
27
24
  })
28
25
  }
29
26
 
27
+ async initialize() {
28
+ const {debug, directory} = digs(this.workerData, "debug", "directory")
29
+ const configurationPath = `${this.workerData.directory}/src/config/configuration.mjs`
30
+ const configurationImport = await import(configurationPath)
31
+ const configuration = configurationImport.default
32
+
33
+ this.application = new Application({configuration, debug, directory})
34
+
35
+ this.configuration = configuration
36
+ this.configuration.setCurrent()
37
+ }
38
+
30
39
  onCommand = (data) => {
31
40
  logger(this, `Worker ${this.workerCount} received command`, data)
32
41
 
@@ -35,7 +35,9 @@ export default class VelociousRoutesResolver {
35
35
  throw new Error(`Missing action on controller: ${this.params.controller}#${this.params.action}`)
36
36
  }
37
37
 
38
- await controllerInstance[this.params.action]()
38
+ await this.configuration.getDatabasePool().withConnection(async () => {
39
+ await controllerInstance[this.params.action]()
40
+ })
39
41
 
40
42
  return
41
43
  }
@@ -0,0 +1,5 @@
1
+ export default class VelocuiousSpec {
2
+ static describe(description) {
3
+ throw new Error("stub", description)
4
+ }
5
+ }
@@ -0,0 +1,17 @@
1
+ import {Configuration} from "velocious"
2
+
3
+ const configuration = new Configuration({
4
+ database: {
5
+ default: {
6
+ master: {
7
+ type: "mysql",
8
+ host: "mariadb",
9
+ username: "username",
10
+ password: "password",
11
+ database: "database"
12
+ }
13
+ }
14
+ }
15
+ })
16
+
17
+ export default configuration
@@ -0,0 +1,11 @@
1
+ import {Database} from "velocious"
2
+
3
+ export default class __MIGRATION_NAME__ extends Database.Migration {
4
+ async up() {
5
+ await this.connection().execute("...")
6
+ }
7
+
8
+ async down() {
9
+ await this.connection().execute("...")
10
+ }
11
+ }
@@ -0,0 +1,11 @@
1
+ import {Routes} from "velocious"
2
+
3
+ const routes = new Routes()
4
+
5
+ routes.draw((route) => {
6
+ route.resources("tasks", (route) => {
7
+ route.get("users")
8
+ })
9
+ })
10
+
11
+ export default {routes}
@@ -0,0 +1,13 @@
1
+ import fs from "node:fs/promises"
2
+
3
+ const fileExists = async (path) => {
4
+ try {
5
+ await fs.access(path)
6
+
7
+ return true
8
+ } catch (error) {
9
+ return false
10
+ }
11
+ }
12
+
13
+ export default fileExists
@@ -1,9 +0,0 @@
1
- import Cli from "../../../src/cli/index.mjs"
2
-
3
- describe("Cli - generate - migration", () => {
4
- it("generates a new migration", async () => {
5
- const cli = new Cli()
6
-
7
- await cli.execute({args: ["g:migration", "create_tasks"]})
8
- })
9
- })
@@ -1,15 +0,0 @@
1
- const databaseConfiguration = () => {
2
- return {
3
- "default": {
4
- "master": {
5
- "type": "mysql",
6
- "host": "mariadb",
7
- "username": "username",
8
- "password": "password",
9
- "database": "velocious_test"
10
- }
11
- }
12
- }
13
- }
14
-
15
- export {databaseConfiguration}
@@ -1,15 +0,0 @@
1
- const databaseConfiguration = () => {
2
- return {
3
- "default": {
4
- "master": {
5
- "type": "mysql",
6
- "host": "mariadb",
7
- "username": "peakflow",
8
- "password": "password",
9
- "database": "velocious_test"
10
- }
11
- }
12
- }
13
- }
14
-
15
- export {databaseConfiguration}