velocious 1.0.63 → 1.0.65
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/bin/velocious.js
CHANGED
package/package.json
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import Configuration from "./configuration.js"
|
|
2
|
+
import envSense from "env-sense/src/use-env-sense.js"
|
|
3
|
+
import fileExists from "./utils/file-exists.js"
|
|
2
4
|
|
|
3
5
|
const configurationResolver = async (args) => {
|
|
4
6
|
if (Configuration.current(false)) {
|
|
@@ -6,8 +8,17 @@ const configurationResolver = async (args) => {
|
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
const directory = args.directory || process.cwd()
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
let configurationPrePath = `${directory}/src/config/configuration`
|
|
12
|
+
const configurationPathForNode = `${configurationPrePath}.node.js`
|
|
13
|
+
const configurationPathDefault = `${configurationPrePath}.js`
|
|
14
|
+
const {isServer} = envSense()
|
|
15
|
+
let configuration, configurationPath
|
|
16
|
+
|
|
17
|
+
if (isServer && await fileExists(configurationPathForNode)) {
|
|
18
|
+
configurationPath = configurationPathForNode
|
|
19
|
+
} else {
|
|
20
|
+
configurationPath = configurationPathDefault
|
|
21
|
+
}
|
|
11
22
|
|
|
12
23
|
try {
|
|
13
24
|
const configurationImport = await import(configurationPath)
|
|
@@ -390,24 +390,26 @@ class VelociousDatabaseRecord {
|
|
|
390
390
|
const isNewRecord = this.isNewRecord()
|
|
391
391
|
let result
|
|
392
392
|
|
|
393
|
-
await this.
|
|
393
|
+
await this.constructor._getConfiguration().ensureConnections(async () => {
|
|
394
|
+
await this._runValidations()
|
|
394
395
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
396
|
+
await this.constructor.transaction(async () => {
|
|
397
|
+
// If any belongs-to-relationships was saved, then updated-at should still be set on this record.
|
|
398
|
+
const {savedCount} = await this._autoSaveBelongsToRelationships()
|
|
398
399
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
400
|
+
if (this.isPersisted()) {
|
|
401
|
+
// If any has-many-relationships will be saved, then updated-at should still be set on this record.
|
|
402
|
+
const autoSaveHasManyrelationships = this._autoSaveHasManyAndHasOneRelationshipsToSave()
|
|
402
403
|
|
|
403
|
-
|
|
404
|
-
|
|
404
|
+
if (this._hasChanges() || savedCount > 0 || autoSaveHasManyrelationships.length > 0) {
|
|
405
|
+
result = await this._updateRecordWithChanges()
|
|
406
|
+
}
|
|
407
|
+
} else {
|
|
408
|
+
result = await this._createNewRecord()
|
|
405
409
|
}
|
|
406
|
-
} else {
|
|
407
|
-
result = await this._createNewRecord()
|
|
408
|
-
}
|
|
409
410
|
|
|
410
|
-
|
|
411
|
+
await this._autoSaveHasManyAndHasOneRelationships({isNewRecord})
|
|
412
|
+
})
|
|
411
413
|
})
|
|
412
414
|
|
|
413
415
|
return result
|
|
@@ -23,7 +23,7 @@ export default class TestFilesFinder {
|
|
|
23
23
|
return this.foundFiles
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
findingPromisesLength
|
|
26
|
+
findingPromisesLength() { return Object.keys(this.findingPromises).length }
|
|
27
27
|
|
|
28
28
|
async waitForFindingPromises() {
|
|
29
29
|
while (this.findingPromisesLength() > 0) {
|
|
@@ -90,7 +90,7 @@ export default class TestFilesFinder {
|
|
|
90
90
|
return true
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
} else if (file.match(/-(spec|test)\.js
|
|
93
|
+
} else if (file.match(/-(spec|test)\.(m|)js$/)) {
|
|
94
94
|
return true
|
|
95
95
|
}
|
|
96
96
|
|