@cdklabs/cdk-cicd-wrapper 0.2.15 → 0.2.17
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/.eslintrc.js +1 -1
- package/.jsii +6 -6
- package/lib/code-pipeline/AppStage.js +1 -1
- package/lib/code-pipeline/CDKPipeline.js +1 -1
- package/lib/code-pipeline/PostDeployBuildStep.js +1 -1
- package/lib/code-pipeline/PreDeployBuildStep.js +1 -1
- package/lib/common/spi/ResourceContext.js +1 -1
- package/lib/common/types/BaseStackProvider.js +1 -1
- package/lib/common/types/DefaultStackProvider.js +1 -1
- package/lib/common/types/Types.js +2 -2
- package/lib/constructs/CodeCommitRepositoryConstruct.js +1 -1
- package/lib/constructs/CodeStarConnectionConstruct.js +1 -1
- package/lib/plugins/index.js +1 -1
- package/lib/plugins/optimization/DestroyEncryptionKeysOnDeletePlugin.js +1 -1
- package/lib/plugins/pipeline/GitHubPipelinePlugin.js +1 -1
- package/lib/plugins/security/AccessLogsForBucketPlugin.js +1 -1
- package/lib/plugins/security/DisablePublicIPAssignmentForEC2Plugin.js +1 -1
- package/lib/plugins/security/EncryptBucketOnTransitPlugin.js +1 -1
- package/lib/plugins/security/EncryptCloudWatchLogGroupsPlugin.js +1 -1
- package/lib/plugins/security/EncryptSNSTopicOnTransitPlugin.js +1 -1
- package/lib/plugins/security/LambdaDLQPlugin.js +1 -1
- package/lib/plugins/security/RotateEncryptionKeysPlugin.js +1 -1
- package/lib/plugins/utils/CodeArtifactPlugin.js +1 -1
- package/lib/resource-providers/CIDefinitionProvider.js +2 -2
- package/lib/resource-providers/CodeBuildFactoryProvider.js +2 -2
- package/lib/resource-providers/ComplianceBucketProvider.js +1 -1
- package/lib/resource-providers/EncryptionProvider.js +1 -1
- package/lib/resource-providers/HooksProvider.js +2 -2
- package/lib/resource-providers/LoggingProvider.js +1 -1
- package/lib/resource-providers/ParameterProvider.js +1 -1
- package/lib/resource-providers/PhaseCommandProvider.js +6 -6
- package/lib/resource-providers/ProxyProvider.js +1 -1
- package/lib/resource-providers/RepositoryProvider.js +4 -4
- package/lib/resource-providers/StageProvider.js +1 -1
- package/lib/resource-providers/VPCProvider.js +1 -1
- package/lib/stacks/CodeStarConnectRepositoryStack.js +1 -1
- package/lib/stacks/EncryptionStack.js +1 -1
- package/lib/stacks/PipelineBlueprint.js +2 -2
- package/lib/stacks/PostDeployExecutorStack.js +1 -1
- package/lib/stacks/SSMParameterStack.js +1 -1
- package/lib/stacks/compliance-bucket/ComplianceBucketStack.js +1 -1
- package/lib/stacks/vpc/ManagedVPCStack.js +1 -1
- package/lib/stacks/vpc/NoVPCStack.js +1 -1
- package/lib/stacks/vpc/VPCFromLookUpStack.js +1 -1
- package/lib/utils/ParameterResolver.js +1 -1
- package/node_modules/yaml/README.md +44 -11
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +1 -0
- package/node_modules/yaml/browser/dist/compose/compose-node.js +10 -0
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +14 -8
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +2 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +2 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +4 -0
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +1 -1
- package/node_modules/yaml/browser/dist/compose/util-map-includes.js +1 -5
- package/node_modules/yaml/browser/dist/doc/Document.js +3 -2
- package/node_modules/yaml/browser/dist/log.js +1 -4
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +7 -49
- package/node_modules/yaml/browser/dist/public-api.js +3 -0
- package/node_modules/yaml/browser/dist/schema/Schema.js +1 -2
- package/node_modules/yaml/browser/dist/schema/json/schema.js +1 -1
- package/node_modules/yaml/browser/dist/schema/tags.js +26 -13
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +2 -11
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +64 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +2 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +1 -1
- package/node_modules/yaml/browser/dist/stringify/stringify.js +6 -1
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +20 -11
- package/node_modules/yaml/browser/dist/util.js +1 -1
- package/node_modules/yaml/dist/compose/compose-collection.d.ts +4 -4
- package/node_modules/yaml/dist/compose/compose-doc.d.ts +6 -6
- package/node_modules/yaml/dist/compose/compose-doc.js +1 -0
- package/node_modules/yaml/dist/compose/compose-node.d.ts +8 -7
- package/node_modules/yaml/dist/compose/compose-node.js +10 -0
- package/node_modules/yaml/dist/compose/compose-scalar.d.ts +4 -4
- package/node_modules/yaml/dist/compose/compose-scalar.js +13 -7
- package/node_modules/yaml/dist/compose/composer.d.ts +7 -6
- package/node_modules/yaml/dist/compose/composer.js +2 -1
- package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +5 -5
- package/node_modules/yaml/dist/compose/resolve-block-map.js +2 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +5 -5
- package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +5 -5
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +2 -0
- package/node_modules/yaml/dist/compose/resolve-end.d.ts +2 -2
- package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -7
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +4 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +4 -4
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +2 -2
- package/node_modules/yaml/dist/compose/resolve-props.js +1 -1
- package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +1 -1
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +1 -1
- package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +2 -2
- package/node_modules/yaml/dist/compose/util-map-includes.d.ts +3 -3
- package/node_modules/yaml/dist/compose/util-map-includes.js +1 -5
- package/node_modules/yaml/dist/doc/Document.d.ts +11 -11
- package/node_modules/yaml/dist/doc/Document.js +3 -2
- package/node_modules/yaml/dist/doc/anchors.d.ts +2 -2
- package/node_modules/yaml/dist/doc/createNode.d.ts +4 -4
- package/node_modules/yaml/dist/doc/directives.d.ts +1 -1
- package/node_modules/yaml/dist/errors.d.ts +1 -1
- package/node_modules/yaml/dist/index.d.ts +21 -18
- package/node_modules/yaml/dist/log.js +4 -2
- package/node_modules/yaml/dist/nodes/Alias.d.ts +9 -8
- package/node_modules/yaml/dist/nodes/Collection.d.ts +4 -4
- package/node_modules/yaml/dist/nodes/Node.d.ts +15 -9
- package/node_modules/yaml/dist/nodes/Pair.d.ts +9 -8
- package/node_modules/yaml/dist/nodes/Scalar.d.ts +4 -3
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +10 -10
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +10 -10
- package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +3 -3
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +6 -48
- package/node_modules/yaml/dist/nodes/identity.d.ts +7 -7
- package/node_modules/yaml/dist/nodes/toJS.d.ts +2 -2
- package/node_modules/yaml/dist/options.d.ts +16 -10
- package/node_modules/yaml/dist/parse/cst-scalar.d.ts +4 -4
- package/node_modules/yaml/dist/parse/cst-stringify.d.ts +1 -1
- package/node_modules/yaml/dist/parse/cst-visit.d.ts +2 -2
- package/node_modules/yaml/dist/parse/cst.d.ts +4 -3
- package/node_modules/yaml/dist/parse/lexer.d.ts +1 -1
- package/node_modules/yaml/dist/parse/parser.d.ts +4 -4
- package/node_modules/yaml/dist/parse/parser.js +2 -1
- package/node_modules/yaml/dist/public-api.d.ts +6 -5
- package/node_modules/yaml/dist/public-api.js +3 -0
- package/node_modules/yaml/dist/schema/Schema.d.ts +4 -5
- package/node_modules/yaml/dist/schema/Schema.js +1 -2
- package/node_modules/yaml/dist/schema/common/map.d.ts +1 -1
- package/node_modules/yaml/dist/schema/common/null.d.ts +1 -1
- package/node_modules/yaml/dist/schema/common/seq.d.ts +1 -1
- package/node_modules/yaml/dist/schema/common/string.d.ts +1 -1
- package/node_modules/yaml/dist/schema/core/bool.d.ts +1 -1
- package/node_modules/yaml/dist/schema/core/float.d.ts +1 -1
- package/node_modules/yaml/dist/schema/core/int.d.ts +1 -1
- package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -1
- package/node_modules/yaml/dist/schema/json/schema.d.ts +1 -1
- package/node_modules/yaml/dist/schema/json/schema.js +1 -1
- package/node_modules/yaml/dist/schema/tags.d.ts +11 -3
- package/node_modules/yaml/dist/schema/tags.js +26 -13
- package/node_modules/yaml/dist/schema/types.d.ts +14 -12
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +6 -5
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +68 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +11 -17
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +7 -7
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +2 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +9 -9
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +1 -1
- package/node_modules/yaml/dist/stringify/stringify.d.ts +3 -3
- package/node_modules/yaml/dist/stringify/stringify.js +6 -1
- package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +2 -2
- package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +3 -3
- package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +1 -1
- package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +2 -2
- package/node_modules/yaml/dist/stringify/stringifyString.d.ts +2 -2
- package/node_modules/yaml/dist/stringify/stringifyString.js +20 -11
- package/node_modules/yaml/dist/util.d.ts +16 -12
- package/node_modules/yaml/dist/util.js +2 -2
- package/node_modules/yaml/dist/visit.d.ts +7 -7
- package/node_modules/yaml/package.json +4 -4
- package/package.json +13 -13
|
@@ -7,6 +7,7 @@ function composeDoc(options, directives, { offset, start, value, end }, onError)
|
|
|
7
7
|
const opts = Object.assign({ _directives: directives }, options);
|
|
8
8
|
const doc = new Document(undefined, opts);
|
|
9
9
|
const ctx = {
|
|
10
|
+
atKey: false,
|
|
10
11
|
atRoot: true,
|
|
11
12
|
directives: doc.directives,
|
|
12
13
|
options: doc.options,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Alias } from '../nodes/Alias.js';
|
|
2
|
+
import { isScalar } from '../nodes/identity.js';
|
|
2
3
|
import { composeCollection } from './compose-collection.js';
|
|
3
4
|
import { composeScalar } from './compose-scalar.js';
|
|
4
5
|
import { resolveEnd } from './resolve-end.js';
|
|
@@ -6,6 +7,7 @@ import { emptyScalarPosition } from './util-empty-scalar-position.js';
|
|
|
6
7
|
|
|
7
8
|
const CN = { composeNode, composeEmptyNode };
|
|
8
9
|
function composeNode(ctx, token, props, onError) {
|
|
10
|
+
const atKey = ctx.atKey;
|
|
9
11
|
const { spaceBefore, comment, anchor, tag } = props;
|
|
10
12
|
let node;
|
|
11
13
|
let isSrcToken = true;
|
|
@@ -41,6 +43,14 @@ function composeNode(ctx, token, props, onError) {
|
|
|
41
43
|
}
|
|
42
44
|
if (anchor && node.anchor === '')
|
|
43
45
|
onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
|
|
46
|
+
if (atKey &&
|
|
47
|
+
ctx.options.stringKeys &&
|
|
48
|
+
(!isScalar(node) ||
|
|
49
|
+
typeof node.value !== 'string' ||
|
|
50
|
+
(node.tag && node.tag !== 'tag:yaml.org,2002:str'))) {
|
|
51
|
+
const msg = 'With stringKeys, all keys must be strings';
|
|
52
|
+
onError(tag ?? token, 'NON_STRING_KEY', msg);
|
|
53
|
+
}
|
|
44
54
|
if (spaceBefore)
|
|
45
55
|
node.spaceBefore = true;
|
|
46
56
|
if (comment) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isScalar, SCALAR } from '../nodes/identity.js';
|
|
2
2
|
import { Scalar } from '../nodes/Scalar.js';
|
|
3
3
|
import { resolveBlockScalar } from './resolve-block-scalar.js';
|
|
4
4
|
import { resolveFlowScalar } from './resolve-flow-scalar.js';
|
|
@@ -10,11 +10,16 @@ function composeScalar(ctx, token, tagToken, onError) {
|
|
|
10
10
|
const tagName = tagToken
|
|
11
11
|
? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
|
|
12
12
|
: null;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
let tag;
|
|
14
|
+
if (ctx.options.stringKeys && ctx.atKey) {
|
|
15
|
+
tag = ctx.schema[SCALAR];
|
|
16
|
+
}
|
|
17
|
+
else if (tagName)
|
|
18
|
+
tag = findScalarTagByName(ctx.schema, value, tagName, tagToken, onError);
|
|
19
|
+
else if (token.type === 'scalar')
|
|
20
|
+
tag = findScalarTagByTest(ctx, value, token, onError);
|
|
21
|
+
else
|
|
22
|
+
tag = ctx.schema[SCALAR];
|
|
18
23
|
let scalar;
|
|
19
24
|
try {
|
|
20
25
|
const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
|
|
@@ -62,8 +67,9 @@ function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
|
62
67
|
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str');
|
|
63
68
|
return schema[SCALAR];
|
|
64
69
|
}
|
|
65
|
-
function findScalarTagByTest({ directives, schema }, value, token, onError) {
|
|
66
|
-
const tag = schema.tags.find(tag => tag.default && tag.
|
|
70
|
+
function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) {
|
|
71
|
+
const tag = schema.tags.find(tag => (tag.default === true || (atKey && tag.default === 'key')) &&
|
|
72
|
+
tag.test?.test(value)) || schema[SCALAR];
|
|
67
73
|
if (schema.compat) {
|
|
68
74
|
const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
|
|
69
75
|
schema[SCALAR];
|
|
@@ -50,12 +50,14 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
|
|
|
50
50
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
51
51
|
}
|
|
52
52
|
// key value
|
|
53
|
+
ctx.atKey = true;
|
|
53
54
|
const keyStart = keyProps.end;
|
|
54
55
|
const keyNode = key
|
|
55
56
|
? composeNode(ctx, key, keyProps, onError)
|
|
56
57
|
: composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
|
|
57
58
|
if (ctx.schema.compat)
|
|
58
59
|
flowIndentCheck(bm.indent, key, onError);
|
|
60
|
+
ctx.atKey = false;
|
|
59
61
|
if (mapIncludes(ctx, map.items, keyNode))
|
|
60
62
|
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
|
61
63
|
// value properties
|
|
@@ -7,6 +7,8 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, ta
|
|
|
7
7
|
const seq = new NodeClass(ctx.schema);
|
|
8
8
|
if (ctx.atRoot)
|
|
9
9
|
ctx.atRoot = false;
|
|
10
|
+
if (ctx.atKey)
|
|
11
|
+
ctx.atKey = false;
|
|
10
12
|
let offset = bs.offset;
|
|
11
13
|
let commentEnd = null;
|
|
12
14
|
for (const { start, value } of bs.items) {
|
|
@@ -18,6 +18,8 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
18
18
|
const atRoot = ctx.atRoot;
|
|
19
19
|
if (atRoot)
|
|
20
20
|
ctx.atRoot = false;
|
|
21
|
+
if (ctx.atKey)
|
|
22
|
+
ctx.atKey = false;
|
|
21
23
|
let offset = fc.offset + fc.start.source.length;
|
|
22
24
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
23
25
|
const collItem = fc.items[i];
|
|
@@ -97,12 +99,14 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
97
99
|
else {
|
|
98
100
|
// item is a key+value pair
|
|
99
101
|
// key value
|
|
102
|
+
ctx.atKey = true;
|
|
100
103
|
const keyStart = props.end;
|
|
101
104
|
const keyNode = key
|
|
102
105
|
? composeNode(ctx, key, props, onError)
|
|
103
106
|
: composeEmptyNode(ctx, keyStart, start, null, props, onError);
|
|
104
107
|
if (isBlock(key))
|
|
105
108
|
onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
|
|
109
|
+
ctx.atKey = false;
|
|
106
110
|
// value properties
|
|
107
111
|
const valueProps = resolveProps(sep ?? [], {
|
|
108
112
|
flow: fcName,
|
|
@@ -6,11 +6,7 @@ function mapIncludes(ctx, items, search) {
|
|
|
6
6
|
return false;
|
|
7
7
|
const isEqual = typeof uniqueKeys === 'function'
|
|
8
8
|
? uniqueKeys
|
|
9
|
-
: (a, b) => a === b ||
|
|
10
|
-
(isScalar(a) &&
|
|
11
|
-
isScalar(b) &&
|
|
12
|
-
a.value === b.value &&
|
|
13
|
-
!(a.value === '<<' && ctx.schema.merge));
|
|
9
|
+
: (a, b) => a === b || (isScalar(a) && isScalar(b) && a.value === b.value);
|
|
14
10
|
return items.some(pair => isEqual(pair.key, search));
|
|
15
11
|
}
|
|
16
12
|
|
|
@@ -35,6 +35,7 @@ class Document {
|
|
|
35
35
|
logLevel: 'warn',
|
|
36
36
|
prettyErrors: true,
|
|
37
37
|
strict: true,
|
|
38
|
+
stringKeys: false,
|
|
38
39
|
uniqueKeys: true,
|
|
39
40
|
version: '1.2'
|
|
40
41
|
}, options);
|
|
@@ -258,7 +259,7 @@ class Document {
|
|
|
258
259
|
this.directives.yaml.version = '1.1';
|
|
259
260
|
else
|
|
260
261
|
this.directives = new Directives({ version: '1.1' });
|
|
261
|
-
opt = {
|
|
262
|
+
opt = { resolveKnownTags: false, schema: 'yaml-1.1' };
|
|
262
263
|
break;
|
|
263
264
|
case '1.2':
|
|
264
265
|
case 'next':
|
|
@@ -266,7 +267,7 @@ class Document {
|
|
|
266
267
|
this.directives.yaml.version = version;
|
|
267
268
|
else
|
|
268
269
|
this.directives = new Directives({ version });
|
|
269
|
-
opt = {
|
|
270
|
+
opt = { resolveKnownTags: true, schema: 'core' };
|
|
270
271
|
break;
|
|
271
272
|
case null:
|
|
272
273
|
if (this.directives)
|
|
@@ -4,10 +4,7 @@ function debug(logLevel, ...messages) {
|
|
|
4
4
|
}
|
|
5
5
|
function warn(logLevel, warning) {
|
|
6
6
|
if (logLevel === 'debug' || logLevel === 'warn') {
|
|
7
|
-
|
|
8
|
-
process.emitWarning(warning);
|
|
9
|
-
else
|
|
10
|
-
console.warn(warning);
|
|
7
|
+
console.warn(warning);
|
|
11
8
|
}
|
|
12
9
|
}
|
|
13
10
|
|
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
import { warn } from '../log.js';
|
|
2
|
+
import { isMergeKey, addMergeToJSMap } from '../schema/yaml-1.1/merge.js';
|
|
2
3
|
import { createStringifyContext } from '../stringify/stringify.js';
|
|
3
|
-
import {
|
|
4
|
-
import { Scalar } from './Scalar.js';
|
|
4
|
+
import { isNode } from './identity.js';
|
|
5
5
|
import { toJS } from './toJS.js';
|
|
6
6
|
|
|
7
|
-
const MERGE_KEY = '<<';
|
|
8
7
|
function addPairToJSMap(ctx, map, { key, value }) {
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
else if (Array.isArray(value))
|
|
15
|
-
for (const it of value)
|
|
16
|
-
mergeToJSMap(ctx, map, it);
|
|
17
|
-
else
|
|
18
|
-
mergeToJSMap(ctx, map, value);
|
|
19
|
-
}
|
|
8
|
+
if (isNode(key) && key.addToJSMap)
|
|
9
|
+
key.addToJSMap(ctx, map, value);
|
|
10
|
+
// TODO: Should drop this special case for bare << handling
|
|
11
|
+
else if (isMergeKey(ctx, key))
|
|
12
|
+
addMergeToJSMap(ctx, map, value);
|
|
20
13
|
else {
|
|
21
14
|
const jsKey = toJS(key, '', ctx);
|
|
22
15
|
if (map instanceof Map) {
|
|
@@ -41,41 +34,6 @@ function addPairToJSMap(ctx, map, { key, value }) {
|
|
|
41
34
|
}
|
|
42
35
|
return map;
|
|
43
36
|
}
|
|
44
|
-
const isMergeKey = (key) => key === MERGE_KEY ||
|
|
45
|
-
(isScalar(key) &&
|
|
46
|
-
key.value === MERGE_KEY &&
|
|
47
|
-
(!key.type || key.type === Scalar.PLAIN));
|
|
48
|
-
// If the value associated with a merge key is a single mapping node, each of
|
|
49
|
-
// its key/value pairs is inserted into the current mapping, unless the key
|
|
50
|
-
// already exists in it. If the value associated with the merge key is a
|
|
51
|
-
// sequence, then this sequence is expected to contain mapping nodes and each
|
|
52
|
-
// of these nodes is merged in turn according to its order in the sequence.
|
|
53
|
-
// Keys in mapping nodes earlier in the sequence override keys specified in
|
|
54
|
-
// later mapping nodes. -- http://yaml.org/type/merge.html
|
|
55
|
-
function mergeToJSMap(ctx, map, value) {
|
|
56
|
-
const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
57
|
-
if (!isMap(source))
|
|
58
|
-
throw new Error('Merge sources must be maps or map aliases');
|
|
59
|
-
const srcMap = source.toJSON(null, ctx, Map);
|
|
60
|
-
for (const [key, value] of srcMap) {
|
|
61
|
-
if (map instanceof Map) {
|
|
62
|
-
if (!map.has(key))
|
|
63
|
-
map.set(key, value);
|
|
64
|
-
}
|
|
65
|
-
else if (map instanceof Set) {
|
|
66
|
-
map.add(key);
|
|
67
|
-
}
|
|
68
|
-
else if (!Object.prototype.hasOwnProperty.call(map, key)) {
|
|
69
|
-
Object.defineProperty(map, key, {
|
|
70
|
-
value,
|
|
71
|
-
writable: true,
|
|
72
|
-
enumerable: true,
|
|
73
|
-
configurable: true
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return map;
|
|
78
|
-
}
|
|
79
37
|
function stringifyKey(key, jsKey, ctx) {
|
|
80
38
|
if (jsKey === null)
|
|
81
39
|
return '';
|
|
@@ -2,6 +2,7 @@ import { Composer } from './compose/composer.js';
|
|
|
2
2
|
import { Document } from './doc/Document.js';
|
|
3
3
|
import { prettifyError, YAMLParseError } from './errors.js';
|
|
4
4
|
import { warn } from './log.js';
|
|
5
|
+
import { isDocument } from './nodes/identity.js';
|
|
5
6
|
import { LineCounter } from './parse/line-counter.js';
|
|
6
7
|
import { Parser } from './parse/parser.js';
|
|
7
8
|
|
|
@@ -93,6 +94,8 @@ function stringify(value, replacer, options) {
|
|
|
93
94
|
if (!keepUndefined)
|
|
94
95
|
return undefined;
|
|
95
96
|
}
|
|
97
|
+
if (isDocument(value) && !_replacer)
|
|
98
|
+
return value.toString(options);
|
|
96
99
|
return new Document(value, _replacer, options).toString(options);
|
|
97
100
|
}
|
|
98
101
|
|
|
@@ -12,10 +12,9 @@ class Schema {
|
|
|
12
12
|
: compat
|
|
13
13
|
? getTags(null, compat)
|
|
14
14
|
: null;
|
|
15
|
-
this.merge = !!merge;
|
|
16
15
|
this.name = (typeof schema === 'string' && schema) || 'core';
|
|
17
16
|
this.knownTags = resolveKnownTags ? coreKnownTags : {};
|
|
18
|
-
this.tags = getTags(customTags, this.name);
|
|
17
|
+
this.tags = getTags(customTags, this.name, merge);
|
|
19
18
|
this.toStringOptions = toStringDefaults ?? null;
|
|
20
19
|
Object.defineProperty(this, MAP, { value: map });
|
|
21
20
|
Object.defineProperty(this, SCALAR, { value: string });
|
|
@@ -8,6 +8,7 @@ import { int, intHex, intOct } from './core/int.js';
|
|
|
8
8
|
import { schema } from './core/schema.js';
|
|
9
9
|
import { schema as schema$1 } from './json/schema.js';
|
|
10
10
|
import { binary } from './yaml-1.1/binary.js';
|
|
11
|
+
import { merge } from './yaml-1.1/merge.js';
|
|
11
12
|
import { omap } from './yaml-1.1/omap.js';
|
|
12
13
|
import { pairs } from './yaml-1.1/pairs.js';
|
|
13
14
|
import { schema as schema$2 } from './yaml-1.1/schema.js';
|
|
@@ -33,6 +34,7 @@ const tagsByName = {
|
|
|
33
34
|
intOct,
|
|
34
35
|
intTime,
|
|
35
36
|
map,
|
|
37
|
+
merge,
|
|
36
38
|
null: nullTag,
|
|
37
39
|
omap,
|
|
38
40
|
pairs,
|
|
@@ -42,13 +44,20 @@ const tagsByName = {
|
|
|
42
44
|
};
|
|
43
45
|
const coreKnownTags = {
|
|
44
46
|
'tag:yaml.org,2002:binary': binary,
|
|
47
|
+
'tag:yaml.org,2002:merge': merge,
|
|
45
48
|
'tag:yaml.org,2002:omap': omap,
|
|
46
49
|
'tag:yaml.org,2002:pairs': pairs,
|
|
47
50
|
'tag:yaml.org,2002:set': set,
|
|
48
51
|
'tag:yaml.org,2002:timestamp': timestamp
|
|
49
52
|
};
|
|
50
|
-
function getTags(customTags, schemaName) {
|
|
51
|
-
|
|
53
|
+
function getTags(customTags, schemaName, addMergeTag) {
|
|
54
|
+
const schemaTags = schemas.get(schemaName);
|
|
55
|
+
if (schemaTags && !customTags) {
|
|
56
|
+
return addMergeTag && !schemaTags.includes(merge)
|
|
57
|
+
? schemaTags.concat(merge)
|
|
58
|
+
: schemaTags.slice();
|
|
59
|
+
}
|
|
60
|
+
let tags = schemaTags;
|
|
52
61
|
if (!tags) {
|
|
53
62
|
if (Array.isArray(customTags))
|
|
54
63
|
tags = [];
|
|
@@ -67,17 +76,21 @@ function getTags(customTags, schemaName) {
|
|
|
67
76
|
else if (typeof customTags === 'function') {
|
|
68
77
|
tags = customTags(tags.slice());
|
|
69
78
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const tagObj = tagsByName[tag];
|
|
74
|
-
if (tagObj)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
if (addMergeTag)
|
|
80
|
+
tags = tags.concat(merge);
|
|
81
|
+
return tags.reduce((tags, tag) => {
|
|
82
|
+
const tagObj = typeof tag === 'string' ? tagsByName[tag] : tag;
|
|
83
|
+
if (!tagObj) {
|
|
84
|
+
const tagName = JSON.stringify(tag);
|
|
85
|
+
const keys = Object.keys(tagsByName)
|
|
86
|
+
.map(key => JSON.stringify(key))
|
|
87
|
+
.join(', ');
|
|
88
|
+
throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
|
|
89
|
+
}
|
|
90
|
+
if (!tags.includes(tagObj))
|
|
91
|
+
tags.push(tagObj);
|
|
92
|
+
return tags;
|
|
93
|
+
}, []);
|
|
81
94
|
}
|
|
82
95
|
|
|
83
96
|
export { coreKnownTags, getTags };
|
|
@@ -14,10 +14,7 @@ const binary = {
|
|
|
14
14
|
* document.querySelector('#photo').src = URL.createObjectURL(blob)
|
|
15
15
|
*/
|
|
16
16
|
resolve(src, onError) {
|
|
17
|
-
if (typeof
|
|
18
|
-
return Buffer.from(src, 'base64');
|
|
19
|
-
}
|
|
20
|
-
else if (typeof atob === 'function') {
|
|
17
|
+
if (typeof atob === 'function') {
|
|
21
18
|
// On IE 11, atob() can't handle newlines
|
|
22
19
|
const str = atob(src.replace(/[\n\r]/g, ''));
|
|
23
20
|
const buffer = new Uint8Array(str.length);
|
|
@@ -33,13 +30,7 @@ const binary = {
|
|
|
33
30
|
stringify({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
34
31
|
const buf = value; // checked earlier by binary.identify()
|
|
35
32
|
let str;
|
|
36
|
-
if (typeof
|
|
37
|
-
str =
|
|
38
|
-
buf instanceof Buffer
|
|
39
|
-
? buf.toString('base64')
|
|
40
|
-
: Buffer.from(buf.buffer).toString('base64');
|
|
41
|
-
}
|
|
42
|
-
else if (typeof btoa === 'function') {
|
|
33
|
+
if (typeof btoa === 'function') {
|
|
43
34
|
let s = '';
|
|
44
35
|
for (let i = 0; i < buf.length; ++i)
|
|
45
36
|
s += String.fromCharCode(buf[i]);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { isScalar, isAlias, isSeq, isMap } from '../../nodes/identity.js';
|
|
2
|
+
import { Scalar } from '../../nodes/Scalar.js';
|
|
3
|
+
|
|
4
|
+
// If the value associated with a merge key is a single mapping node, each of
|
|
5
|
+
// its key/value pairs is inserted into the current mapping, unless the key
|
|
6
|
+
// already exists in it. If the value associated with the merge key is a
|
|
7
|
+
// sequence, then this sequence is expected to contain mapping nodes and each
|
|
8
|
+
// of these nodes is merged in turn according to its order in the sequence.
|
|
9
|
+
// Keys in mapping nodes earlier in the sequence override keys specified in
|
|
10
|
+
// later mapping nodes. -- http://yaml.org/type/merge.html
|
|
11
|
+
const MERGE_KEY = '<<';
|
|
12
|
+
const merge = {
|
|
13
|
+
identify: value => value === MERGE_KEY ||
|
|
14
|
+
(typeof value === 'symbol' && value.description === MERGE_KEY),
|
|
15
|
+
default: 'key',
|
|
16
|
+
tag: 'tag:yaml.org,2002:merge',
|
|
17
|
+
test: /^<<$/,
|
|
18
|
+
resolve: () => Object.assign(new Scalar(Symbol(MERGE_KEY)), {
|
|
19
|
+
addToJSMap: addMergeToJSMap
|
|
20
|
+
}),
|
|
21
|
+
stringify: () => MERGE_KEY
|
|
22
|
+
};
|
|
23
|
+
const isMergeKey = (ctx, key) => (merge.identify(key) ||
|
|
24
|
+
(isScalar(key) &&
|
|
25
|
+
(!key.type || key.type === Scalar.PLAIN) &&
|
|
26
|
+
merge.identify(key.value))) &&
|
|
27
|
+
ctx?.doc.schema.tags.some(tag => tag.tag === merge.tag && tag.default);
|
|
28
|
+
function addMergeToJSMap(ctx, map, value) {
|
|
29
|
+
value = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
30
|
+
if (isSeq(value))
|
|
31
|
+
for (const it of value.items)
|
|
32
|
+
mergeValue(ctx, map, it);
|
|
33
|
+
else if (Array.isArray(value))
|
|
34
|
+
for (const it of value)
|
|
35
|
+
mergeValue(ctx, map, it);
|
|
36
|
+
else
|
|
37
|
+
mergeValue(ctx, map, value);
|
|
38
|
+
}
|
|
39
|
+
function mergeValue(ctx, map, value) {
|
|
40
|
+
const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
41
|
+
if (!isMap(source))
|
|
42
|
+
throw new Error('Merge sources must be maps or map aliases');
|
|
43
|
+
const srcMap = source.toJSON(null, ctx, Map);
|
|
44
|
+
for (const [key, value] of srcMap) {
|
|
45
|
+
if (map instanceof Map) {
|
|
46
|
+
if (!map.has(key))
|
|
47
|
+
map.set(key, value);
|
|
48
|
+
}
|
|
49
|
+
else if (map instanceof Set) {
|
|
50
|
+
map.add(key);
|
|
51
|
+
}
|
|
52
|
+
else if (!Object.prototype.hasOwnProperty.call(map, key)) {
|
|
53
|
+
Object.defineProperty(map, key, {
|
|
54
|
+
value,
|
|
55
|
+
writable: true,
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return map;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { addMergeToJSMap, isMergeKey, merge };
|
|
@@ -6,6 +6,7 @@ import { binary } from './binary.js';
|
|
|
6
6
|
import { trueTag, falseTag } from './bool.js';
|
|
7
7
|
import { floatNaN, floatExp, float } from './float.js';
|
|
8
8
|
import { intBin, intOct, int, intHex } from './int.js';
|
|
9
|
+
import { merge } from './merge.js';
|
|
9
10
|
import { omap } from './omap.js';
|
|
10
11
|
import { pairs } from './pairs.js';
|
|
11
12
|
import { set } from './set.js';
|
|
@@ -26,6 +27,7 @@ const schema = [
|
|
|
26
27
|
floatExp,
|
|
27
28
|
float,
|
|
28
29
|
binary,
|
|
30
|
+
merge,
|
|
29
31
|
omap,
|
|
30
32
|
pairs,
|
|
31
33
|
set,
|
|
@@ -95,7 +95,7 @@ const timestamp = {
|
|
|
95
95
|
}
|
|
96
96
|
return new Date(date);
|
|
97
97
|
},
|
|
98
|
-
stringify: ({ value }) => value.toISOString().replace(/(
|
|
98
|
+
stringify: ({ value }) => value.toISOString().replace(/(T00:00:00)?\.000Z$/, '')
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
export { floatTime, intTime, timestamp };
|
|
@@ -54,7 +54,12 @@ function getTagObject(tags, item) {
|
|
|
54
54
|
let obj;
|
|
55
55
|
if (isScalar(item)) {
|
|
56
56
|
obj = item.value;
|
|
57
|
-
|
|
57
|
+
let match = tags.filter(t => t.identify?.(obj));
|
|
58
|
+
if (match.length > 1) {
|
|
59
|
+
const testMatch = match.filter(t => t.test);
|
|
60
|
+
if (testMatch.length > 0)
|
|
61
|
+
match = testMatch;
|
|
62
|
+
}
|
|
58
63
|
tagObj =
|
|
59
64
|
match.find(t => t.format === item.format) ?? match.find(t => !t.format);
|
|
60
65
|
}
|
|
@@ -219,23 +219,32 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
|
219
219
|
start = start.replace(/\n+/g, `$&${indent}`);
|
|
220
220
|
}
|
|
221
221
|
const indentSize = indent ? '2' : '1'; // root is at -1
|
|
222
|
-
|
|
222
|
+
// Leading | or > is added later
|
|
223
|
+
let header = (startWithSpace ? indentSize : '') + chomp;
|
|
223
224
|
if (comment) {
|
|
224
225
|
header += ' ' + commentString(comment.replace(/ ?[\r\n]+/g, ' '));
|
|
225
226
|
if (onComment)
|
|
226
227
|
onComment();
|
|
227
228
|
}
|
|
228
|
-
if (literal) {
|
|
229
|
-
|
|
230
|
-
|
|
229
|
+
if (!literal) {
|
|
230
|
+
const foldedValue = value
|
|
231
|
+
.replace(/\n+/g, '\n$&')
|
|
232
|
+
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
233
|
+
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
|
|
234
|
+
.replace(/\n+/g, `$&${indent}`);
|
|
235
|
+
let literalFallback = false;
|
|
236
|
+
const foldOptions = getFoldOptions(ctx, true);
|
|
237
|
+
if (blockQuote !== 'folded' && type !== Scalar.BLOCK_FOLDED) {
|
|
238
|
+
foldOptions.onOverflow = () => {
|
|
239
|
+
literalFallback = true;
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
const body = foldFlowLines(`${start}${foldedValue}${end}`, indent, FOLD_BLOCK, foldOptions);
|
|
243
|
+
if (!literalFallback)
|
|
244
|
+
return `>${header}\n${indent}${body}`;
|
|
231
245
|
}
|
|
232
|
-
value = value
|
|
233
|
-
|
|
234
|
-
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
235
|
-
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
|
|
236
|
-
.replace(/\n+/g, `$&${indent}`);
|
|
237
|
-
const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx, true));
|
|
238
|
-
return `${header}\n${indent}${body}`;
|
|
246
|
+
value = value.replace(/\n+/g, `$&${indent}`);
|
|
247
|
+
return `|${header}\n${indent}${start}${value}${end}`;
|
|
239
248
|
}
|
|
240
249
|
function plainString(item, ctx, onComment, onChompKeep) {
|
|
241
250
|
const { type, value } = item;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { createNode } from './doc/createNode.js';
|
|
2
2
|
export { debug, warn } from './log.js';
|
|
3
3
|
export { createPair } from './nodes/Pair.js';
|
|
4
|
-
export { findPair } from './nodes/YAMLMap.js';
|
|
5
4
|
export { toJS } from './nodes/toJS.js';
|
|
5
|
+
export { findPair } from './nodes/YAMLMap.js';
|
|
6
6
|
export { map as mapTag } from './schema/common/map.js';
|
|
7
7
|
export { seq as seqTag } from './schema/common/seq.js';
|
|
8
8
|
export { string as stringTag } from './schema/common/string.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ParsedNode } from '../nodes/Node
|
|
2
|
-
import type { BlockMap, BlockSequence, FlowCollection, SourceToken } from '../parse/cst
|
|
3
|
-
import type { ComposeContext, ComposeNode } from './compose-node
|
|
4
|
-
import type { ComposeErrorHandler } from './composer
|
|
1
|
+
import type { ParsedNode } from '../nodes/Node';
|
|
2
|
+
import type { BlockMap, BlockSequence, FlowCollection, SourceToken } from '../parse/cst';
|
|
3
|
+
import type { ComposeContext, ComposeNode } from './compose-node';
|
|
4
|
+
import type { ComposeErrorHandler } from './composer';
|
|
5
5
|
interface Props {
|
|
6
6
|
anchor: SourceToken | null;
|
|
7
7
|
tag: SourceToken | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Directives } from '../doc/directives
|
|
2
|
-
import { Document } from '../doc/Document
|
|
3
|
-
import type { ParsedNode } from '../nodes/Node
|
|
4
|
-
import type { DocumentOptions, ParseOptions, SchemaOptions } from '../options
|
|
5
|
-
import type * as CST from '../parse/cst
|
|
6
|
-
import type { ComposeErrorHandler } from './composer
|
|
1
|
+
import type { Directives } from '../doc/directives';
|
|
2
|
+
import { Document } from '../doc/Document';
|
|
3
|
+
import type { ParsedNode } from '../nodes/Node';
|
|
4
|
+
import type { DocumentOptions, ParseOptions, SchemaOptions } from '../options';
|
|
5
|
+
import type * as CST from '../parse/cst';
|
|
6
|
+
import type { ComposeErrorHandler } from './composer';
|
|
7
7
|
export declare function composeDoc<Contents extends ParsedNode = ParsedNode, Strict extends boolean = true>(options: ParseOptions & DocumentOptions & SchemaOptions, directives: Directives, { offset, start, value, end }: CST.Document, onError: ComposeErrorHandler): Document.Parsed<Contents, Strict>;
|
|
@@ -9,6 +9,7 @@ function composeDoc(options, directives, { offset, start, value, end }, onError)
|
|
|
9
9
|
const opts = Object.assign({ _directives: directives }, options);
|
|
10
10
|
const doc = new Document.Document(undefined, opts);
|
|
11
11
|
const ctx = {
|
|
12
|
+
atKey: false,
|
|
12
13
|
atRoot: true,
|
|
13
14
|
directives: doc.directives,
|
|
14
15
|
options: doc.options,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { Directives } from '../doc/directives
|
|
2
|
-
import type { ParsedNode } from '../nodes/Node
|
|
3
|
-
import type { ParseOptions } from '../options
|
|
4
|
-
import type { SourceToken, Token } from '../parse/cst
|
|
5
|
-
import type { Schema } from '../schema/Schema
|
|
6
|
-
import type { ComposeErrorHandler } from './composer
|
|
1
|
+
import type { Directives } from '../doc/directives';
|
|
2
|
+
import type { ParsedNode } from '../nodes/Node';
|
|
3
|
+
import type { ParseOptions } from '../options';
|
|
4
|
+
import type { SourceToken, Token } from '../parse/cst';
|
|
5
|
+
import type { Schema } from '../schema/Schema';
|
|
6
|
+
import type { ComposeErrorHandler } from './composer';
|
|
7
7
|
export interface ComposeContext {
|
|
8
|
+
atKey: boolean;
|
|
8
9
|
atRoot: boolean;
|
|
9
10
|
directives: Directives;
|
|
10
11
|
options: Readonly<Required<Omit<ParseOptions, 'lineCounter'>>>;
|
|
@@ -24,5 +25,5 @@ declare const CN: {
|
|
|
24
25
|
};
|
|
25
26
|
export type ComposeNode = typeof CN;
|
|
26
27
|
export declare function composeNode(ctx: ComposeContext, token: Token, props: Props, onError: ComposeErrorHandler): ParsedNode;
|
|
27
|
-
export declare function composeEmptyNode(ctx: ComposeContext, offset: number, before: Token[] | undefined, pos: number | null, { spaceBefore, comment, anchor, tag, end }: Props, onError: ComposeErrorHandler): import(
|
|
28
|
+
export declare function composeEmptyNode(ctx: ComposeContext, offset: number, before: Token[] | undefined, pos: number | null, { spaceBefore, comment, anchor, tag, end }: Props, onError: ComposeErrorHandler): import('../index').Scalar.Parsed;
|
|
28
29
|
export {};
|