velocious 1.0.90 → 1.0.92

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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "velocious": "bin/velocious.js"
4
4
  },
5
5
  "name": "velocious",
6
- "version": "1.0.90",
6
+ "version": "1.0.92",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "lint": "eslint",
@@ -1,30 +1,7 @@
1
- import Application from "../../application.js"
2
1
  import BaseCommand from "../base-command.js"
3
2
 
4
3
  export default class VelociousCliCommandsServer extends BaseCommand{
5
4
  async execute() {
6
- this.databasePool = this.getConfiguration().getDatabasePool()
7
- this.newConfiguration = Object.assign({}, this.databasePool.getConfiguration())
8
- this.databaseConnection = await this.databasePool.spawnConnectionWithConfiguration(this.newConfiguration)
9
-
10
- await this.databaseConnection.connect()
11
-
12
- const {parsedProcessArgs} = this.args
13
- const host = parsedProcessArgs.h || parsedProcessArgs.host || "127.0.0.1"
14
- const port = parsedProcessArgs.p || parsedProcessArgs.port || 3006
15
- const application = new Application({
16
- configuration: this.getConfiguration(),
17
- httpServer: {
18
- host,
19
- port
20
- },
21
- type: "server"
22
- })
23
- const environment = this.getConfiguration().getEnvironment()
24
-
25
- await application.initialize()
26
- await application.startHttpServer()
27
- console.log(`Started Velocious HTTP server on ${host}:${port} in ${environment} environment`)
28
- await application.wait()
5
+ return await this.getConfiguration().getEnvironmentHandler().cliCommandsServer(this)
29
6
  }
30
7
  }
@@ -1,33 +1,7 @@
1
1
  import BaseCommand from "../base-command.js"
2
- import TestFilesFinder from "../../testing/test-files-finder.js"
3
- import TestRunner from "../../testing/test-runner.js"
4
2
 
5
3
  export default class VelociousCliCommandsTest extends BaseCommand {
6
4
  async execute() {
7
- this.getConfiguration().setEnvironment("test")
8
-
9
- const directory = process.env.VELOCIOUS_TEST_DIR || this.directory()
10
- const testFilesFinder = new TestFilesFinder({directory, processArgs: this.processArgs})
11
- const testFiles = await testFilesFinder.findTestFiles()
12
- const testRunner = new TestRunner({configuration: this.getConfiguration(), testFiles})
13
-
14
- await testRunner.prepare()
15
-
16
- if (testRunner.getTestsCount() === 0) {
17
- throw new Error("No tests has been found")
18
- }
19
-
20
- await testRunner.run()
21
-
22
- if (testRunner.isFailed()) {
23
- console.error(`\nTest run failed with ${testRunner.getFailedTests()} failed tests and ${testRunner.getSuccessfulTests()} successfull`)
24
- process.exit(1)
25
- } else if (testRunner.areAnyTestsFocussed()) {
26
- console.error(`\nFocussed run with ${testRunner.getFailedTests()} failed tests and ${testRunner.getSuccessfulTests()} successfull`)
27
- process.exit(1)
28
- } else {
29
- console.log(`\nTest run succeeded with ${testRunner.getSuccessfulTests()} successful tests`)
30
- process.exit(0)
31
- }
5
+ return await this.getConfiguration().getEnvironmentHandler().cliCommandsTest(this)
32
6
  }
33
7
  }
@@ -31,6 +31,14 @@ export default class VelociousEnvironmentsHandlerBrowser extends Base {
31
31
  throw new Error("Unsupported on browser")
32
32
  }
33
33
 
34
+ async cliCommandsServer(_command) { // eslint-disable-line no-unused-vars
35
+ throw new Error("Unsupported on browser")
36
+ }
37
+
38
+ async cliCommandsTest(_command) { // eslint-disable-line no-unused-vars
39
+ throw new Error("Unsupported on browser")
40
+ }
41
+
34
42
  /**
35
43
  * @returns {object}
36
44
  */
@@ -0,0 +1,30 @@
1
+ import Application from "../../../../application.js"
2
+ import BaseCommand from "../../../../cli/base-command.js"
3
+
4
+ export default class VelociousCliCommandsServer extends BaseCommand{
5
+ async execute() {
6
+ this.databasePool = this.getConfiguration().getDatabasePool()
7
+ this.newConfiguration = Object.assign({}, this.databasePool.getConfiguration())
8
+ this.databaseConnection = await this.databasePool.spawnConnectionWithConfiguration(this.newConfiguration)
9
+
10
+ await this.databaseConnection.connect()
11
+
12
+ const {parsedProcessArgs} = this.args
13
+ const host = parsedProcessArgs.h || parsedProcessArgs.host || "127.0.0.1"
14
+ const port = parsedProcessArgs.p || parsedProcessArgs.port || 3006
15
+ const application = new Application({
16
+ configuration: this.getConfiguration(),
17
+ httpServer: {
18
+ host,
19
+ port
20
+ },
21
+ type: "server"
22
+ })
23
+ const environment = this.getConfiguration().getEnvironment()
24
+
25
+ await application.initialize()
26
+ await application.startHttpServer()
27
+ console.log(`Started Velocious HTTP server on ${host}:${port} in ${environment} environment`)
28
+ await application.wait()
29
+ }
30
+ }
@@ -0,0 +1,33 @@
1
+ import BaseCommand from "../../../../cli/base-command.js"
2
+ import TestFilesFinder from "../../../../testing/test-files-finder.js"
3
+ import TestRunner from "../../../../testing/test-runner.js"
4
+
5
+ export default class VelociousCliCommandsTest extends BaseCommand {
6
+ async execute() {
7
+ this.getConfiguration().setEnvironment("test")
8
+
9
+ const directory = process.env.VELOCIOUS_TEST_DIR || this.directory()
10
+ const testFilesFinder = new TestFilesFinder({directory, processArgs: this.processArgs})
11
+ const testFiles = await testFilesFinder.findTestFiles()
12
+ const testRunner = new TestRunner({configuration: this.getConfiguration(), testFiles})
13
+
14
+ await testRunner.prepare()
15
+
16
+ if (testRunner.getTestsCount() === 0) {
17
+ throw new Error("No tests has been found")
18
+ }
19
+
20
+ await testRunner.run()
21
+
22
+ if (testRunner.isFailed()) {
23
+ console.error(`\nTest run failed with ${testRunner.getFailedTests()} failed tests and ${testRunner.getSuccessfulTests()} successfull`)
24
+ process.exit(1)
25
+ } else if (testRunner.areAnyTestsFocussed()) {
26
+ console.error(`\nFocussed run with ${testRunner.getFailedTests()} failed tests and ${testRunner.getSuccessfulTests()} successfull`)
27
+ process.exit(1)
28
+ } else {
29
+ console.log(`\nTest run succeeded with ${testRunner.getSuccessfulTests()} successful tests`)
30
+ process.exit(0)
31
+ }
32
+ }
33
+ }
@@ -3,6 +3,8 @@ import CliCommandsDestroyMigration from "./node/cli/commands/destroy/migration.j
3
3
  import CliCommandsInit from "./node/cli/commands/init.js"
4
4
  import CliCommandsGenerateMigration from "./node/cli/commands/generate/migration.js"
5
5
  import CliCommandsGenerateModel from "./node/cli/commands/generate/model.js"
6
+ import CliCommandsServer from "./node/cli/commands/server.js"
7
+ import CliCommandsTest from "./node/cli/commands/test.js"
6
8
  import {dirname} from "path"
7
9
  import {fileURLToPath} from "url"
8
10
  import fs from "fs/promises"
@@ -62,6 +64,14 @@ export default class VelociousEnvironmentHandlerNode extends Base{
62
64
  return await this.forwardCommand(command, CliCommandsGenerateModel)
63
65
  }
64
66
 
67
+ async cliCommandsServer(command) {
68
+ return await this.forwardCommand(command, CliCommandsServer)
69
+ }
70
+
71
+ async cliCommandsTest(command) {
72
+ return await this.forwardCommand(command, CliCommandsTest)
73
+ }
74
+
65
75
  /**
66
76
  * @param {Array<string>} commandParts
67
77
  * @template T extends import ("./base-command.js").default