@crombolo/schema 0.19.0 → 0.21.0
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 +3 -3
- package/src/workflows.ts +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Schema-as-code for crombolo: TOML document, media and member type definitions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@crombolo/core": "0.
|
|
32
|
-
"@crombolo/data": "0.
|
|
31
|
+
"@crombolo/core": "0.21.0",
|
|
32
|
+
"@crombolo/data": "0.21.0"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/workflows.ts
CHANGED
|
@@ -29,6 +29,7 @@ const WORKFLOW_KEYS = [
|
|
|
29
29
|
'comments',
|
|
30
30
|
'unpublish',
|
|
31
31
|
'on-change',
|
|
32
|
+
'scheduling',
|
|
32
33
|
] as const
|
|
33
34
|
const APPLIES_KEYS = ['branches', 'content-types'] as const
|
|
34
35
|
const STAGE_KEYS = [
|
|
@@ -126,6 +127,7 @@ export function parseWorkflow(file: string, source: string): ParseResult<SchemaW
|
|
|
126
127
|
comments: choice(r, t, 'comments', path, WORKFLOW_COMMENTS, 'optional'),
|
|
127
128
|
unpublish: r.bool(t, 'unpublish', path, false),
|
|
128
129
|
onChange: choice(r, t, 'on-change', path, WORKFLOW_ON_CHANGE, 'keep'),
|
|
130
|
+
...(r.bool(t, 'scheduling', path, false) ? { scheduling: true } : {}),
|
|
129
131
|
stages: r.tables(root.stage, 'stage').map((s, i) => stage(r, s, `stage[${i}]`)),
|
|
130
132
|
}
|
|
131
133
|
if (r.problems.length === 0)
|
|
@@ -136,7 +138,10 @@ export function parseWorkflow(file: string, source: string): ParseResult<SchemaW
|
|
|
136
138
|
const str = (value: string) => JSON.stringify(value)
|
|
137
139
|
const list = (values: readonly string[]) => `[${values.map(str).join(', ')}]`
|
|
138
140
|
|
|
139
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* A workflow as canonical TOML: a fixed key order, defaults written out, except
|
|
143
|
+
* `scheduling`, written only when on so files and versions from before it are unchanged.
|
|
144
|
+
*/
|
|
140
145
|
export function writeWorkflow(workflow: SchemaWorkflow): string {
|
|
141
146
|
const out = ['[workflow]']
|
|
142
147
|
if (workflow.key) out.push(`key = ${str(workflow.key)}`)
|
|
@@ -150,6 +155,7 @@ export function writeWorkflow(workflow: SchemaWorkflow): string {
|
|
|
150
155
|
`unpublish = ${workflow.unpublish}`,
|
|
151
156
|
`on-change = ${str(workflow.onChange)}`,
|
|
152
157
|
)
|
|
158
|
+
if (workflow.scheduling) out.push('scheduling = true')
|
|
153
159
|
for (const s of workflow.stages) {
|
|
154
160
|
out.push('', '[[stage]]', `alias = ${str(s.alias)}`)
|
|
155
161
|
if (s.name !== undefined) out.push(`name = ${str(s.name)}`)
|