pipecraft 0.0.0-releaseit → 0.26.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/README.md +126 -108
- package/dist/cli/index.d.ts +69 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +94 -22
- package/dist/cli/index.js.map +1 -1
- package/dist/generators/init.tpl.d.ts +70 -0
- package/dist/generators/init.tpl.d.ts.map +1 -1
- package/dist/generators/init.tpl.js +100 -8
- package/dist/generators/init.tpl.js.map +1 -1
- package/dist/generators/workflows.tpl.d.ts +86 -0
- package/dist/generators/workflows.tpl.d.ts.map +1 -1
- package/dist/generators/workflows.tpl.js +101 -9
- package/dist/generators/workflows.tpl.js.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts +47 -0
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.js +72 -3
- package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.js +22 -2
- package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-release.yml.tpl.d.ts +18 -0
- package/dist/templates/actions/create-release.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/create-release.yml.tpl.js +141 -0
- package/dist/templates/actions/create-release.yml.tpl.js.map +1 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-tag.yml.tpl.js +22 -2
- package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts +70 -0
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.js +98 -2
- package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.js +22 -2
- package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.js +50 -7
- package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts +114 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js +479 -74
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js.map +1 -1
- package/dist/types/index.d.ts +231 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/ast-path-operations.d.ts.map +1 -1
- package/dist/utils/ast-path-operations.js +24 -11
- package/dist/utils/ast-path-operations.js.map +1 -1
- package/dist/utils/config.d.ts +63 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +71 -0
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/github-setup.d.ts +323 -2
- package/dist/utils/github-setup.d.ts.map +1 -1
- package/dist/utils/github-setup.js +551 -23
- package/dist/utils/github-setup.js.map +1 -1
- package/dist/utils/idempotency.d.ts +147 -7
- package/dist/utils/idempotency.d.ts.map +1 -1
- package/dist/utils/idempotency.js +143 -15
- package/dist/utils/idempotency.js.map +1 -1
- package/dist/utils/logger.d.ts +134 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +153 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/preflight.d.ts +223 -12
- package/dist/utils/preflight.d.ts.map +1 -1
- package/dist/utils/preflight.js +216 -16
- package/dist/utils/preflight.js.map +1 -1
- package/dist/utils/versioning.d.ts +160 -8
- package/dist/utils/versioning.d.ts.map +1 -1
- package/dist/utils/versioning.js +179 -15
- package/dist/utils/versioning.js.map +1 -1
- package/package.json +26 -5
- package/.claude/settings.local.json +0 -35
- package/.github/actions/calculate-version/action.yml +0 -106
- package/.github/actions/create-pr/action.yml +0 -122
- package/.github/actions/create-release/action.yml +0 -74
- package/.github/actions/create-tag/action.yml +0 -94
- package/.github/actions/detect-changes/action.yml +0 -62
- package/.github/actions/manage-branch/action.yml +0 -113
- package/.github/actions/promote-branch/action.yml +0 -352
- package/.github/example/workflows/job.analyze.code.yml +0 -26
- package/.github/example/workflows/job.analyze.docker.yml +0 -32
- package/.github/example/workflows/job.app.api.deploy.yml +0 -127
- package/.github/example/workflows/job.app.api.test.yml +0 -102
- package/.github/example/workflows/job.app.docs.deploy.yml +0 -40
- package/.github/example/workflows/job.app.docs.test.yml +0 -50
- package/.github/example/workflows/job.app.web.deploy.yml +0 -96
- package/.github/example/workflows/job.app.web.test.yml +0 -49
- package/.github/example/workflows/job.changes.yml +0 -82
- package/.github/example/workflows/job.create-pr.yml +0 -96
- package/.github/example/workflows/job.env-check.yml +0 -43
- package/.github/example/workflows/job.fast-forward.yml +0 -103
- package/.github/example/workflows/job.lint.yml +0 -64
- package/.github/example/workflows/job.pr-name.yml +0 -70
- package/.github/example/workflows/job.pr-squash-name.yml +0 -27
- package/.github/example/workflows/job.tag.yml +0 -38
- package/.github/example/workflows/job.version.yml +0 -99
- package/.github/example/workflows/lib.plugin-base.publish.yml +0 -59
- package/.github/example/workflows/pipe.yml +0 -178
- package/.github/example/workflows/scripts/fastforward.sh +0 -51
- package/.github/example/workflows/scripts/pipe-cleaner.sh +0 -70
- package/.github/scripts/fastforward.sh +0 -51
- package/.github/scripts/pipe-cleaner.sh +0 -70
- package/.github/workflows/pipeline.yml +0 -220
- package/.github/workflows/pr-title-check.yml +0 -70
- package/.github/workflows/publish.yml +0 -39
- package/.pipecraftrc.json +0 -78
- package/.release-it.cjs +0 -71
- package/PIPELINE_TESTING_PLAN.md +0 -499
- package/TRUNK_FLOW_PLAN.md +0 -401
- package/assets/logo_banner.png +0 -0
- package/assets/logo_banner.webp +0 -0
- package/docs/USER_JOURNEY_ERRORS.md +0 -352
- package/eslint.config.js +0 -77
- package/examples/basic-config.json +0 -41
- package/examples/monorepo-config.json +0 -49
- package/examples/usage.md +0 -289
- package/scripts/debug-workflows.sh +0 -339
- package/scripts/parse-pipeline.js +0 -29
- package/scripts/test-job-order.cjs +0 -140
- package/scripts/validate-pipeline.cjs +0 -379
- package/scripts/verify-job-order.sh +0 -30
- package/src/cli/index.ts +0 -414
- package/src/generators/init.tpl.ts +0 -126
- package/src/generators/workflows.tpl.ts +0 -80
- package/src/templates/actions/calculate-version.yml.tpl.ts +0 -124
- package/src/templates/actions/create-pr.yml.tpl.ts +0 -147
- package/src/templates/actions/create-tag.yml.tpl.ts +0 -112
- package/src/templates/actions/detect-changes.yml.tpl.ts +0 -87
- package/src/templates/actions/manage-branch.yml.tpl.ts +0 -132
- package/src/templates/actions/promote-branch.yml.tpl.ts +0 -364
- package/src/templates/workflows/pipeline-path-based.yml.tpl.ts +0 -706
- package/src/types/index.ts +0 -64
- package/src/utils/README-ast-path-operations.md +0 -390
- package/src/utils/ast-path-operations.ts +0 -581
- package/src/utils/config.ts +0 -64
- package/src/utils/github-setup.ts +0 -558
- package/src/utils/idempotency.ts +0 -215
- package/src/utils/preflight.ts +0 -306
- package/src/utils/versioning.ts +0 -244
- package/tests/README.md +0 -229
- package/tests/TEST_STRUCTURE.md +0 -256
- package/tests/act/run-act-tests.sh +0 -345
- package/tests/debugging/debug-utils.ts +0 -538
- package/tests/debugging/debug-workflow.test.ts +0 -339
- package/tests/debugging/debug-workflows.sh +0 -339
- package/tests/debugging/iterative-debug.ts +0 -652
- package/tests/debugging/run-debug-tests.sh +0 -431
- package/tests/fixtures/basic-config.json +0 -51
- package/tests/fixtures/invalid-config.json +0 -9
- package/tests/fixtures/pipeline-generated.yml +0 -235
- package/tests/fixtures/pipeline-preserve-comments.yml +0 -245
- package/tests/fixtures/pipeline-user-modified.yml +0 -245
- package/tests/fixtures/test-config.json +0 -58
- package/tests/github-live/README.md +0 -250
- package/tests/github-local/JOB_WORKFLOW_TESTS.md +0 -296
- package/tests/github-local/README.md +0 -240
- package/tests/github-local/run-all-tests.sh +0 -422
- package/tests/github-local/test-job-workflows.sh +0 -631
- package/tests/github-local/test-pipeline-workflow.sh +0 -440
- package/tests/integration/generators.test.ts +0 -578
- package/tests/integration/path-based-template.test.ts +0 -510
- package/tests/integration/simple-path-based.test.ts +0 -415
- package/tests/setup.ts +0 -56
- package/tests/unit/ast-path-operations-extended.test.ts +0 -302
- package/tests/unit/cli.test.ts +0 -541
- package/tests/unit/config-extended.test.ts +0 -412
- package/tests/unit/config.test.ts +0 -152
- package/tests/unit/github-setup.test.ts +0 -189
- package/tests/unit/idempotency-isolated.test.ts +0 -297
- package/tests/unit/job-order.test.ts +0 -157
- package/tests/unit/pipeline-path-based.test.ts +0 -511
- package/tests/unit/validate-pipeline.test.ts +0 -384
- package/tests/unit/versioning-extended.test.ts +0 -279
- package/tests/unit/versioning.test.ts +0 -241
- package/tsconfig.debug.json +0 -17
- package/tsconfig.json +0 -28
- package/vitest.config.ts +0 -51
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach } from 'vitest'
|
|
2
|
-
import { parseDocument, stringify } from 'yaml'
|
|
3
|
-
import {
|
|
4
|
-
setPathValue,
|
|
5
|
-
getPathValue,
|
|
6
|
-
ensurePathAndApply,
|
|
7
|
-
applyPathOperations,
|
|
8
|
-
createValueFromString,
|
|
9
|
-
createValueFromObject,
|
|
10
|
-
createValueFromArray,
|
|
11
|
-
PathOperationConfig
|
|
12
|
-
} from '../../src/utils/ast-path-operations'
|
|
13
|
-
|
|
14
|
-
describe('AST Path Operations - Extended Coverage', () => {
|
|
15
|
-
let doc: any
|
|
16
|
-
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
doc = parseDocument('name: test\njobs: {}', { keepSourceTokens: true })
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
describe('setPathValue', () => {
|
|
22
|
-
it('should handle nested path creation', () => {
|
|
23
|
-
setPathValue(doc.contents, 'jobs.test.runs-on', 'ubuntu-latest')
|
|
24
|
-
const result = doc.contents.get('jobs').get('test').get('runs-on')
|
|
25
|
-
expect(result).toBe('ubuntu-latest')
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('should apply commentBefore to node', () => {
|
|
29
|
-
setPathValue(doc.contents, 'jobs.test', { name: 'Test' }, doc, 'Test comment')
|
|
30
|
-
const jobNode = doc.contents.get('jobs').get('test')
|
|
31
|
-
expect(jobNode.commentBefore).toContain('Test comment')
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it('should handle setting value on existing path', () => {
|
|
35
|
-
setPathValue(doc.contents, 'name', 'updated')
|
|
36
|
-
expect(doc.contents.get('name')).toBe('updated')
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('should throw error when parent is not a map', () => {
|
|
40
|
-
doc = parseDocument('value: string', { keepSourceTokens: true })
|
|
41
|
-
expect(() => {
|
|
42
|
-
setPathValue(doc.contents, 'value.nested', 'test')
|
|
43
|
-
}).toThrow('Cannot set nested')
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
describe('getPathValue', () => {
|
|
48
|
-
it('should return null for non-existent path', () => {
|
|
49
|
-
const result = getPathValue(doc.contents, 'nonexistent.path')
|
|
50
|
-
expect(result).toBeNull()
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it('should return null for invalid parent node', () => {
|
|
54
|
-
doc = parseDocument('value: string', { keepSourceTokens: true })
|
|
55
|
-
const result = getPathValue(doc.contents, 'value.nested')
|
|
56
|
-
expect(result).toBeNull()
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('should retrieve nested values', () => {
|
|
60
|
-
setPathValue(doc.contents, 'jobs.test.name', 'Test Job')
|
|
61
|
-
const result = getPathValue(doc.contents, 'jobs.test.name')
|
|
62
|
-
expect(result).toBe('Test Job')
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('should handle single-level paths', () => {
|
|
66
|
-
const result = getPathValue(doc.contents, 'name')
|
|
67
|
-
expect(result).toBe('test')
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
describe('ensurePathAndApply', () => {
|
|
72
|
-
it('should handle "set" operation', () => {
|
|
73
|
-
const config: PathOperationConfig = {
|
|
74
|
-
path: 'jobs.build',
|
|
75
|
-
operation: 'set',
|
|
76
|
-
value: { 'runs-on': 'ubuntu-latest' }
|
|
77
|
-
}
|
|
78
|
-
ensurePathAndApply(doc.contents, config, doc)
|
|
79
|
-
expect(doc.contents.get('jobs').has('build')).toBe(true)
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
it('should handle "merge" operation on objects', () => {
|
|
83
|
-
setPathValue(doc.contents, 'env', { NODE_ENV: 'test' })
|
|
84
|
-
const config: PathOperationConfig = {
|
|
85
|
-
path: 'env',
|
|
86
|
-
operation: 'merge',
|
|
87
|
-
value: { DEBUG: 'true' }
|
|
88
|
-
}
|
|
89
|
-
ensurePathAndApply(doc.contents, config, doc)
|
|
90
|
-
const env = doc.contents.get('env')
|
|
91
|
-
expect(env.get('NODE_ENV')).toBe('test')
|
|
92
|
-
expect(env.get('DEBUG')).toBe('true')
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('should handle "merge" operation on arrays', () => {
|
|
96
|
-
setPathValue(doc.contents, 'branches', ['main', 'develop'])
|
|
97
|
-
const config: PathOperationConfig = {
|
|
98
|
-
path: 'branches',
|
|
99
|
-
operation: 'merge',
|
|
100
|
-
value: ['staging', 'develop'] // develop is duplicate
|
|
101
|
-
}
|
|
102
|
-
ensurePathAndApply(doc.contents, config, doc)
|
|
103
|
-
const branches = doc.contents.get('branches').toJSON()
|
|
104
|
-
expect(branches).toContain('main')
|
|
105
|
-
expect(branches).toContain('develop')
|
|
106
|
-
expect(branches).toContain('staging')
|
|
107
|
-
expect(branches.filter((b: string) => b === 'develop')).toHaveLength(1)
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
it('should handle "overwrite" operation', () => {
|
|
111
|
-
setPathValue(doc.contents, 'version', '1.0.0')
|
|
112
|
-
const config: PathOperationConfig = {
|
|
113
|
-
path: 'version',
|
|
114
|
-
operation: 'overwrite',
|
|
115
|
-
value: '2.0.0'
|
|
116
|
-
}
|
|
117
|
-
ensurePathAndApply(doc.contents, config, doc)
|
|
118
|
-
expect(doc.contents.get('version')).toBe('2.0.0')
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
it('should handle "preserve" operation', () => {
|
|
122
|
-
setPathValue(doc.contents, 'custom', 'user-value')
|
|
123
|
-
const config: PathOperationConfig = {
|
|
124
|
-
path: 'custom',
|
|
125
|
-
operation: 'preserve',
|
|
126
|
-
value: 'template-value'
|
|
127
|
-
}
|
|
128
|
-
ensurePathAndApply(doc.contents, config, doc)
|
|
129
|
-
expect(doc.contents.get('custom')).toBe('user-value')
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
it('should skip non-required paths that don\'t exist', () => {
|
|
133
|
-
const config: PathOperationConfig = {
|
|
134
|
-
path: 'optional.field',
|
|
135
|
-
operation: 'set',
|
|
136
|
-
value: 'test',
|
|
137
|
-
required: false
|
|
138
|
-
}
|
|
139
|
-
// Should not throw
|
|
140
|
-
ensurePathAndApply(doc.contents, config, doc)
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
it('should apply commentBefore from config', () => {
|
|
144
|
-
const config: PathOperationConfig = {
|
|
145
|
-
path: 'jobs.test',
|
|
146
|
-
operation: 'set',
|
|
147
|
-
value: { name: 'Test' },
|
|
148
|
-
commentBefore: 'Job comment'
|
|
149
|
-
}
|
|
150
|
-
ensurePathAndApply(doc.contents, config, doc)
|
|
151
|
-
const jobNode = doc.contents.get('jobs').get('test')
|
|
152
|
-
expect(jobNode.commentBefore).toContain('Job comment')
|
|
153
|
-
})
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
describe('applyPathOperations', () => {
|
|
157
|
-
it('should apply multiple operations in order', () => {
|
|
158
|
-
const operations: PathOperationConfig[] = [
|
|
159
|
-
{ path: 'jobs.build', operation: 'set', value: { name: 'Build' } },
|
|
160
|
-
{ path: 'jobs.test', operation: 'set', value: { name: 'Test' } },
|
|
161
|
-
{ path: 'jobs.deploy', operation: 'set', value: { name: 'Deploy' } }
|
|
162
|
-
]
|
|
163
|
-
applyPathOperations(doc.contents, operations, doc)
|
|
164
|
-
expect(doc.contents.get('jobs').get('build').get('name')).toBe('Build')
|
|
165
|
-
expect(doc.contents.get('jobs').get('test').get('name')).toBe('Test')
|
|
166
|
-
expect(doc.contents.get('jobs').get('deploy').get('name')).toBe('Deploy')
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
it('should handle empty operations array', () => {
|
|
170
|
-
applyPathOperations(doc.contents, [], doc)
|
|
171
|
-
// Should not throw
|
|
172
|
-
expect(doc.contents.get('name')).toBe('test')
|
|
173
|
-
})
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
describe('createValueFromString', () => {
|
|
177
|
-
it('should parse simple YAML string', () => {
|
|
178
|
-
const node = createValueFromString('name: Test Job')
|
|
179
|
-
const yaml = stringify(node)
|
|
180
|
-
expect(yaml).toContain('name: Test Job')
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
it('should handle context variable replacement', () => {
|
|
184
|
-
const context = { branch: 'develop' }
|
|
185
|
-
const node = createValueFromString('if: github.ref == \'${branch}\'', context)
|
|
186
|
-
const yaml = stringify(node)
|
|
187
|
-
// The function should process the template literal
|
|
188
|
-
expect(yaml).toBeDefined()
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
it('should handle multi-line YAML', () => {
|
|
192
|
-
const yamlStr = `
|
|
193
|
-
name: Multi-line
|
|
194
|
-
steps:
|
|
195
|
-
- uses: actions/checkout@v2
|
|
196
|
-
`
|
|
197
|
-
const node = createValueFromString(yamlStr)
|
|
198
|
-
const result = stringify(node)
|
|
199
|
-
expect(result).toContain('name: Multi-line')
|
|
200
|
-
expect(result).toContain('steps')
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
it('should parse with document context', () => {
|
|
204
|
-
const node = createValueFromString('runs-on: ubuntu-latest', undefined, doc)
|
|
205
|
-
expect(stringify(node)).toContain('ubuntu-latest')
|
|
206
|
-
})
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
describe('createValueFromObject', () => {
|
|
210
|
-
it('should convert object to YAML node', () => {
|
|
211
|
-
const obj = { name: 'Test', value: 123, enabled: true }
|
|
212
|
-
const node = createValueFromObject(obj)
|
|
213
|
-
const yaml = stringify(node)
|
|
214
|
-
expect(yaml).toContain('name: Test')
|
|
215
|
-
expect(yaml).toContain('value: 123')
|
|
216
|
-
expect(yaml).toContain('enabled: true')
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
it('should use document createNode if available', () => {
|
|
220
|
-
const obj = { key: 'value' }
|
|
221
|
-
const node = createValueFromObject(obj, doc)
|
|
222
|
-
expect(node).toBeDefined()
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
it('should handle nested objects', () => {
|
|
226
|
-
const obj = {
|
|
227
|
-
outer: {
|
|
228
|
-
inner: {
|
|
229
|
-
value: 'nested'
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
const node = createValueFromObject(obj)
|
|
234
|
-
const yaml = stringify(node)
|
|
235
|
-
expect(yaml).toContain('nested')
|
|
236
|
-
})
|
|
237
|
-
})
|
|
238
|
-
|
|
239
|
-
describe('createValueFromArray', () => {
|
|
240
|
-
it('should convert array to YAML sequence', () => {
|
|
241
|
-
const arr = ['item1', 'item2', 'item3']
|
|
242
|
-
const node = createValueFromArray(arr)
|
|
243
|
-
const yaml = stringify(node)
|
|
244
|
-
expect(yaml).toContain('item1')
|
|
245
|
-
expect(yaml).toContain('item2')
|
|
246
|
-
expect(yaml).toContain('item3')
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
it('should handle array of objects', () => {
|
|
250
|
-
const arr = [
|
|
251
|
-
{ name: 'step1' },
|
|
252
|
-
{ name: 'step2' }
|
|
253
|
-
]
|
|
254
|
-
const node = createValueFromArray(arr)
|
|
255
|
-
const yaml = stringify(node)
|
|
256
|
-
expect(yaml).toContain('step1')
|
|
257
|
-
expect(yaml).toContain('step2')
|
|
258
|
-
})
|
|
259
|
-
|
|
260
|
-
it('should handle empty array', () => {
|
|
261
|
-
const arr: any[] = []
|
|
262
|
-
const node = createValueFromArray(arr)
|
|
263
|
-
const yaml = stringify(node)
|
|
264
|
-
expect(yaml).toBe('[]\n')
|
|
265
|
-
})
|
|
266
|
-
})
|
|
267
|
-
|
|
268
|
-
describe('Edge cases and error handling', () => {
|
|
269
|
-
it('should handle deeply nested paths', () => {
|
|
270
|
-
setPathValue(doc.contents, 'a.b.c.d.e.f', 'deep')
|
|
271
|
-
const result = getPathValue(doc.contents, 'a.b.c.d.e.f')
|
|
272
|
-
expect(result).toBe('deep')
|
|
273
|
-
})
|
|
274
|
-
|
|
275
|
-
it('should handle special characters in values', () => {
|
|
276
|
-
setPathValue(doc.contents, 'message', 'Hello: World! @#$%')
|
|
277
|
-
expect(doc.contents.get('message')).toBe('Hello: World! @#$%')
|
|
278
|
-
})
|
|
279
|
-
|
|
280
|
-
it('should handle boolean values', () => {
|
|
281
|
-
setPathValue(doc.contents, 'enabled', true)
|
|
282
|
-
setPathValue(doc.contents, 'disabled', false)
|
|
283
|
-
expect(doc.contents.get('enabled')).toBe(true)
|
|
284
|
-
expect(doc.contents.get('disabled')).toBe(false)
|
|
285
|
-
})
|
|
286
|
-
|
|
287
|
-
it('should handle number values', () => {
|
|
288
|
-
setPathValue(doc.contents, 'port', 8080)
|
|
289
|
-
setPathValue(doc.contents, 'timeout', 3.14)
|
|
290
|
-
expect(doc.contents.get('port')).toBe(8080)
|
|
291
|
-
expect(doc.contents.get('timeout')).toBe(3.14)
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
it('should handle null values', () => {
|
|
295
|
-
setPathValue(doc.contents, 'nullable', null)
|
|
296
|
-
// YAML may represent null as undefined when retrieving
|
|
297
|
-
const value = doc.contents.get('nullable')
|
|
298
|
-
expect(value === null || value === undefined).toBe(true)
|
|
299
|
-
})
|
|
300
|
-
})
|
|
301
|
-
})
|
|
302
|
-
|