@toa.io/norm 1.0.0-alpha.254 → 1.0.0-alpha.256
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 +12 -0
- package/package.json +2 -2
- package/src/.context/schema.yaml +23 -3
- package/src/context.js +2 -2
- package/test/context/complete.fixtures.js +0 -1
- package/test/context/dereference.fixtures.js +0 -1
- package/test/context/normalize.fixtures.js +0 -1
- package/test/context/validate.fixtures.js +0 -1
- package/test/context/validate.test.js +12 -6
- package/types/context/declaration.d.ts +11 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [1.0.0-alpha.256](https://github.com/toa-io/toa/compare/v1.0.0-alpha.255...v1.0.0-alpha.256) (2026-08-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add toa mono and discover components at components/* ([787a111](https://github.com/toa-io/toa/commit/787a111c8f83e56ebc734801c97106c585d034ea))
|
|
12
|
+
* deploy a single mono image with toa deploy --mono ([a7f14f9](https://github.com/toa-io/toa/commit/a7f14f9877a280e9c74d16c195028b35d74fb15a))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/norm",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.256",
|
|
4
4
|
"description": "Toa declarations normalization and validation",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"@toa.io/schemas": "1.0.0-alpha.254",
|
|
26
26
|
"@toa.io/yaml": "1.0.0-alpha.254"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "a8990df97f971060686bd70a965f78e98070a983"
|
|
29
29
|
}
|
package/src/.context/schema.yaml
CHANGED
|
@@ -10,9 +10,6 @@ properties:
|
|
|
10
10
|
pattern: ^([a-zA-Z]+([_a-zA-Z0-9]*[a-zA-Z0-9]+)?)(-([a-zA-Z]+([_a-zA-Z0-9]*[a-zA-Z0-9]+)?))*$
|
|
11
11
|
description:
|
|
12
12
|
type: string
|
|
13
|
-
packages:
|
|
14
|
-
type: string
|
|
15
|
-
default: components/*
|
|
16
13
|
build:
|
|
17
14
|
type: object
|
|
18
15
|
properties:
|
|
@@ -66,6 +63,29 @@ properties:
|
|
|
66
63
|
type: string
|
|
67
64
|
pattern: ^([a-zA-Z]+([_a-zA-Z0-9]*[a-zA-Z0-9]+)?)(\.([a-zA-Z]+([_a-zA-Z0-9]*[a-zA-Z0-9]+)?))$
|
|
68
65
|
required: [name, components]
|
|
66
|
+
mono:
|
|
67
|
+
type: object
|
|
68
|
+
additionalProperties: false
|
|
69
|
+
properties:
|
|
70
|
+
replicas:
|
|
71
|
+
type: integer
|
|
72
|
+
minimum: 1
|
|
73
|
+
resources:
|
|
74
|
+
type: object
|
|
75
|
+
additionalProperties: false
|
|
76
|
+
properties:
|
|
77
|
+
cpu:
|
|
78
|
+
type: array
|
|
79
|
+
items:
|
|
80
|
+
type: string
|
|
81
|
+
minItems: 2
|
|
82
|
+
maxItems: 2
|
|
83
|
+
memory:
|
|
84
|
+
type: array
|
|
85
|
+
items:
|
|
86
|
+
type: string
|
|
87
|
+
minItems: 2
|
|
88
|
+
maxItems: 2
|
|
69
89
|
annotations:
|
|
70
90
|
type: object
|
|
71
91
|
required: [runtime, name, registry]
|
package/src/context.js
CHANGED
|
@@ -19,7 +19,6 @@ const {
|
|
|
19
19
|
const context = async (root, environment = process.env.TOA_ENV) => {
|
|
20
20
|
const path = resolve(root, CONTEXT)
|
|
21
21
|
const context = /** @type {toa.norm.Context} */ await load(path)
|
|
22
|
-
const pattern = resolve(root, context.packages)
|
|
23
22
|
|
|
24
23
|
context.environment = environment
|
|
25
24
|
|
|
@@ -29,7 +28,7 @@ const context = async (root, environment = process.env.TOA_ENV) => {
|
|
|
29
28
|
|
|
30
29
|
validate(context)
|
|
31
30
|
|
|
32
|
-
const paths = await glob(
|
|
31
|
+
const paths = await glob(resolve(root, COMPONENTS))
|
|
33
32
|
|
|
34
33
|
context.components = await Promise.all(paths.map(component))
|
|
35
34
|
context.dependencies = await dependencies(context)
|
|
@@ -41,5 +40,6 @@ const context = async (root, environment = process.env.TOA_ENV) => {
|
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
const CONTEXT = 'context.toa.yaml'
|
|
43
|
+
const COMPONENTS = 'components/*'
|
|
44
44
|
|
|
45
45
|
exports.context = context
|
|
@@ -66,13 +66,19 @@ it('should require name as label', () => {
|
|
|
66
66
|
expect(() => validate(context)).not.toThrow(/pattern/)
|
|
67
67
|
})
|
|
68
68
|
|
|
69
|
-
it('should set default packages location', () => {
|
|
70
|
-
delete context.packages
|
|
71
|
-
expect(() => validate(context)).not.toThrow()
|
|
72
|
-
expect(context.packages).toBe('components/*')
|
|
73
|
-
})
|
|
74
|
-
|
|
75
69
|
it('should require registry url', () => {
|
|
76
70
|
delete context.registry
|
|
77
71
|
expect(() => validate(context)).toThrow(/required/)
|
|
78
72
|
})
|
|
73
|
+
|
|
74
|
+
it('should allow mono replicas and resources', () => {
|
|
75
|
+
context.mono = {
|
|
76
|
+
replicas: 2,
|
|
77
|
+
resources: {
|
|
78
|
+
cpu: ['200m', '2'],
|
|
79
|
+
memory: ['256Mi', '2Gi']
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
expect(() => validate(context)).not.toThrow()
|
|
84
|
+
})
|
|
@@ -5,13 +5,23 @@ interface Composition {
|
|
|
5
5
|
components: string[]
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
export interface Resources {
|
|
9
|
+
cpu?: [string, string]
|
|
10
|
+
memory?: [string, string]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface Mono {
|
|
14
|
+
replicas?: number
|
|
15
|
+
resources?: Resources
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
export interface Declaration {
|
|
9
19
|
name: string
|
|
10
20
|
description?: string
|
|
11
21
|
version?: string
|
|
12
22
|
runtime?: Runtime | string
|
|
13
23
|
registry?: Registry | string
|
|
14
|
-
packages?: string
|
|
15
24
|
compositions?: Composition[]
|
|
25
|
+
mono?: Mono
|
|
16
26
|
annotations?: Record<string, object>
|
|
17
27
|
}
|