@superhero/core 4.0.0-beta.8 → 4.0.2
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/README.md +2 -2
- package/index.js +21 -6
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -124,11 +124,11 @@ pass 4
|
|
|
124
124
|
---------------------------------------------------------------------------------------------------
|
|
125
125
|
file | line % | branch % | funcs % | uncovered lines
|
|
126
126
|
---------------------------------------------------------------------------------------------------
|
|
127
|
-
index.js | 74.
|
|
127
|
+
index.js | 74.21 | 67.03 | 74.51 | 19-24 97-100 121-123 131-136 139-141 185-190 201-2…
|
|
128
128
|
index.test.js | 100.00 | 100.00 | 100.00 |
|
|
129
129
|
worker.js | 100.00 | 100.00 | 100.00 |
|
|
130
130
|
---------------------------------------------------------------------------------------------------
|
|
131
|
-
all files | 77.
|
|
131
|
+
all files | 77.46 | 70.00 | 77.59 |
|
|
132
132
|
---------------------------------------------------------------------------------------------------
|
|
133
133
|
```
|
|
134
134
|
|
package/index.js
CHANGED
|
@@ -2,15 +2,27 @@ import os from 'node:os'
|
|
|
2
2
|
import cluster from 'node:cluster'
|
|
3
3
|
import EventEmitter from 'node:events'
|
|
4
4
|
import path from 'node:path'
|
|
5
|
+
import url from 'node:url'
|
|
5
6
|
import bootstrap from '@superhero/bootstrap'
|
|
6
|
-
import Config from '@superhero/config'
|
|
7
7
|
import Locate from '@superhero/locator'
|
|
8
8
|
import Log from '@superhero/log'
|
|
9
9
|
|
|
10
10
|
export default class Core
|
|
11
11
|
{
|
|
12
12
|
locate = new Locate
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
get config()
|
|
15
|
+
{
|
|
16
|
+
return this.locate.config
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
set config(_)
|
|
20
|
+
{
|
|
21
|
+
const error = new Error('Can not set the config (read-only) property')
|
|
22
|
+
error.code = 'E_CORE_CONFIG_SET'
|
|
23
|
+
error.cause = 'Alter the config instance through the bundled locator'
|
|
24
|
+
throw error
|
|
25
|
+
}
|
|
14
26
|
|
|
15
27
|
/**
|
|
16
28
|
* @param {string} branch The branch to use to add branch specific configurations.
|
|
@@ -19,7 +31,6 @@ export default class Core
|
|
|
19
31
|
{
|
|
20
32
|
this.branch = branch
|
|
21
33
|
this.basePath = this.locate.pathResolver.basePath // synchronize the base path.
|
|
22
|
-
this.locate.set('@superhero/config', this.config)
|
|
23
34
|
Core.#setupDestroyer(this)
|
|
24
35
|
}
|
|
25
36
|
|
|
@@ -214,8 +225,9 @@ export default class Core
|
|
|
214
225
|
|
|
215
226
|
// Forward the base path for the scoped path-resolver
|
|
216
227
|
// used by the locator and config services.
|
|
228
|
+
// OBS! this logic relies on that the locator and config
|
|
229
|
+
// services uses the same path-resolver.
|
|
217
230
|
this.locate.pathResolver.basePath = basePath
|
|
218
|
-
this.config.pathResolver.basePath = basePath
|
|
219
231
|
|
|
220
232
|
this.#eventlog.push({ type: 'basePath', basePath })
|
|
221
233
|
}
|
|
@@ -320,8 +332,11 @@ export default class Core
|
|
|
320
332
|
this.#isForked = true
|
|
321
333
|
|
|
322
334
|
// Set the worker execution script.
|
|
323
|
-
const
|
|
324
|
-
|
|
335
|
+
const
|
|
336
|
+
pwd = path.dirname(url.fileURLToPath(import.meta.url)),
|
|
337
|
+
primaryClusterConfig = this.config.find('core/cluster/primary', { exec: path.join(pwd, 'worker.js') })
|
|
338
|
+
|
|
339
|
+
cluster.setupPrimary(primaryClusterConfig)
|
|
325
340
|
|
|
326
341
|
for(let i = 0; i < forks; i++)
|
|
327
342
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superhero/core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Core functionalities for the superhero framework.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,10 +9,8 @@
|
|
|
9
9
|
".": "./index.js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@superhero/bootstrap": "^4.1.
|
|
13
|
-
"@superhero/
|
|
14
|
-
"@superhero/locator": "^4.2.0",
|
|
15
|
-
"@superhero/log": "^4.0.0"
|
|
12
|
+
"@superhero/bootstrap": "^4.1.1",
|
|
13
|
+
"@superhero/locator": "^4.2.2"
|
|
16
14
|
},
|
|
17
15
|
"scripts": {
|
|
18
16
|
"test": "node --trace-warnings --test --experimental-test-coverage"
|