@toa.io/boot 1.0.0-alpha.292 → 1.0.0-alpha.294
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/CHANGELOG.md +16 -0
- package/package.json +8 -8
- package/src/manifest.js +19 -35
- package/src/manifest.test.js +38 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-alpha.294](https://github.com/toa-io/toa/compare/v1.0.0-alpha.293...v1.0.0-alpha.294) (2026-09-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @toa.io/boot
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [1.0.0-alpha.293](https://github.com/toa-io/toa/compare/v1.0.0-alpha.292...v1.0.0-alpha.293) (2026-09-07)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @toa.io/boot
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [1.0.0-alpha.292](https://github.com/toa-io/toa/compare/v1.0.0-alpha.291...v1.0.0-alpha.292) (2026-09-07)
|
|
7
23
|
|
|
8
24
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/boot",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.294",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Toa Boot",
|
|
6
6
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@toa.io/atomicity": "1.0.0-alpha.
|
|
25
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
26
|
-
"@toa.io/definitions": "1.0.0-alpha.
|
|
24
|
+
"@toa.io/atomicity": "1.0.0-alpha.293",
|
|
25
|
+
"@toa.io/core": "1.0.0-alpha.293",
|
|
26
|
+
"@toa.io/definitions": "1.0.0-alpha.294",
|
|
27
27
|
"@toa.io/generic": "1.0.0-alpha.292",
|
|
28
|
-
"@toa.io/norm": "1.0.0-alpha.
|
|
29
|
-
"@toa.io/schemas": "1.0.0-alpha.
|
|
28
|
+
"@toa.io/norm": "1.0.0-alpha.294",
|
|
29
|
+
"@toa.io/schemas": "1.0.0-alpha.293",
|
|
30
30
|
"clone-deep": "4.0.1",
|
|
31
31
|
"dotenv": "17.4.2",
|
|
32
|
-
"openspan": "1.0.0-alpha.
|
|
32
|
+
"openspan": "1.0.0-alpha.293"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "50b2b596a46a4d639d9f198f834d70c190f0a3c6"
|
|
35
35
|
}
|
package/src/manifest.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import clone from 'clone-deep'
|
|
2
|
-
import {
|
|
2
|
+
import { existsSync } from 'node:fs'
|
|
3
|
+
import { readFile } from 'node:fs/promises'
|
|
4
|
+
import { basename, join } from 'node:path'
|
|
3
5
|
import { merge } from '@toa.io/generic'
|
|
4
|
-
import { component as load,
|
|
6
|
+
import { component as load, revive, NORMALIZED } from '@toa.io/norm'
|
|
5
7
|
import { Locator } from '@toa.io/core'
|
|
6
8
|
|
|
7
9
|
import { span } from './span.js'
|
|
@@ -11,41 +13,9 @@ export const manifest = async (path, options = {}) => {
|
|
|
11
13
|
|
|
12
14
|
const manifest = await span(
|
|
13
15
|
{ name: `manifest ${basename(path)}`, attributes: { path } },
|
|
14
|
-
async () => await
|
|
16
|
+
async () => await read(path)
|
|
15
17
|
)
|
|
16
18
|
|
|
17
|
-
if (options?.bindings !== undefined) {
|
|
18
|
-
if ('operations' in manifest) {
|
|
19
|
-
for (const operation of Object.values(manifest.operations)) {
|
|
20
|
-
operation.bindings = options.bindings
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let asyncBinding
|
|
25
|
-
|
|
26
|
-
for (const binding of options.bindings) {
|
|
27
|
-
const { properties } = (await definition(binding)).module
|
|
28
|
-
|
|
29
|
-
if (properties?.async === true) {
|
|
30
|
-
asyncBinding = binding
|
|
31
|
-
break
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (asyncBinding === undefined)
|
|
36
|
-
throw new Error('Bindings override must contain at least one async binding')
|
|
37
|
-
|
|
38
|
-
if ('events' in manifest) {
|
|
39
|
-
for (const event of Object.values(manifest.events)) event.binding = asyncBinding
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if ('receivers' in manifest) {
|
|
43
|
-
for (const receiver of Object.values(manifest.receivers)) {
|
|
44
|
-
if (receiver.source === undefined) receiver.binding = asyncBinding
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
19
|
if (manifest.extensions === undefined) manifest.extensions = {}
|
|
50
20
|
|
|
51
21
|
if (options.extensions !== undefined) {
|
|
@@ -62,4 +32,18 @@ export const manifest = async (path, options = {}) => {
|
|
|
62
32
|
return manifest
|
|
63
33
|
}
|
|
64
34
|
|
|
35
|
+
/**
|
|
36
|
+
* What the build wrote, where it wrote one. An image carries the manifest a build normalised;
|
|
37
|
+
* a workspace has no such file and is read as it always was.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} path
|
|
40
|
+
*/
|
|
41
|
+
async function read(path) {
|
|
42
|
+
const file = join(path, NORMALIZED)
|
|
43
|
+
|
|
44
|
+
if (!existsSync(file)) return await load(path)
|
|
45
|
+
|
|
46
|
+
return revive(JSON.parse(await readFile(file, 'utf8')), path)
|
|
47
|
+
}
|
|
48
|
+
|
|
65
49
|
const DEFAULTS = {}
|
package/src/manifest.test.js
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import { it, mock } from 'node:test'
|
|
2
2
|
import assert from 'node:assert/strict'
|
|
3
3
|
|
|
4
|
+
import { mkdtemp, writeFile } from 'node:fs/promises'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
import { tmpdir } from 'node:os'
|
|
4
7
|
import { generate } from 'randomstring'
|
|
5
8
|
|
|
9
|
+
const NORMALIZED = 'manifest.toa.json'
|
|
10
|
+
|
|
11
|
+
let normalised = 0
|
|
12
|
+
|
|
6
13
|
mock.module('@toa.io/norm', {
|
|
7
14
|
namedExports: {
|
|
8
|
-
component: () =>
|
|
9
|
-
|
|
15
|
+
component: () => {
|
|
16
|
+
normalised++
|
|
17
|
+
|
|
18
|
+
return mockComponent()
|
|
19
|
+
},
|
|
20
|
+
definition: async () => ({ module: {} }),
|
|
21
|
+
revive: (declared, path) => ({ ...declared, path }),
|
|
22
|
+
NORMALIZED
|
|
10
23
|
}
|
|
11
24
|
})
|
|
12
25
|
|
|
@@ -22,6 +35,29 @@ it('should not modify options', async () => {
|
|
|
22
35
|
assert.deepStrictEqual(options.extensions.length, 2)
|
|
23
36
|
})
|
|
24
37
|
|
|
38
|
+
it('should normalize a component the build did not', async () => {
|
|
39
|
+
const before = normalised
|
|
40
|
+
|
|
41
|
+
await manifest(path)
|
|
42
|
+
|
|
43
|
+
assert.strictEqual(normalised, before + 1)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('should read what the build wrote, and not normalize', async () => {
|
|
47
|
+
const root = await mkdtemp(join(tmpdir(), 'toa-manifest-test'))
|
|
48
|
+
const declared = { name: 'tasks', namespace: 'todos', operations: { compute: {} } }
|
|
49
|
+
|
|
50
|
+
await writeFile(join(root, NORMALIZED), JSON.stringify(declared))
|
|
51
|
+
|
|
52
|
+
const before = normalised
|
|
53
|
+
const read = await manifest(root)
|
|
54
|
+
|
|
55
|
+
assert.strictEqual(normalised, before, 'the component was normalized')
|
|
56
|
+
assert.strictEqual(read.path, root)
|
|
57
|
+
assert.deepStrictEqual(read.operations, declared.operations)
|
|
58
|
+
assert.strictEqual(read.locator.id, 'todos.tasks')
|
|
59
|
+
})
|
|
60
|
+
|
|
25
61
|
function mockComponent() {
|
|
26
62
|
return { name: generate(), namespace: generate() }
|
|
27
63
|
}
|