How to use the yaml-ast-parser.load function in yaml-ast-parser

To help you get started, we’ve selected a few yaml-ast-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DavidWells / aws-profile-manager / app / utils / parseYamlAST.js View on Github external
export default function parseYamlAST(ymlPath) {
  try {
    const contents = fs.readFileSync(ymlPath, 'utf8')
    lineNumbers = [] // reset current AST line Numbers array
    window.CURRENT_AST = {} // reset current AST
    window.CURRENT_AST.PATH = ymlPath
    lineNumbers = getLineNumberInfo(contents)
    // console.log('lineNumbers', lineNumbers)

    const yamlAST = yaml.load(contents)
    const nullYamlValues = []
    const valueWithParent = []
    parseAST(yamlAST, valueWithParent, nullYamlValues)
    // console.log('nullYamlValues', nullYamlValues)
    // console.log('valueWithParent', valueWithParent)
    // console.log(window.CURRENT_AST)

    // TODO: Validate Yaml Fields
    // validateYamlFields(valueWithParent)
    return yamlAST
  } catch (e) {
    return e
  }
}
github AEB-labs / cruddl / src / schema / schema-builder.ts View on Github external
function parseYAMLSource(projectSource: ProjectSource, validationContext: ValidationContext): ParsedObjectProjectSource | undefined {
    const root: YAMLNode | undefined = load(projectSource.body);

    if (!root) {
        return undefined;
    }

    root.errors.forEach(error => {
        const severity = error.isWarning ? Severity.Warning : Severity.Error;
        const endPos = getLineEndPosition(error.mark.line + 1, projectSource);
        validationContext.addMessage(new ValidationMessage(severity, error.reason, new MessageLocation(projectSource, new SourcePosition(error.mark.position, error.mark.line + 1, error.mark.column + 1), endPos)));
    });

    if (root.errors.some(error => !error.isWarning)) {
        // returning undefined will lead to ignoring this source file in future steps
        return undefined;
    }
github threadheap / serverless-ide-vscode / packages / language-server / src / language-service / parser / index.ts View on Github external
return null
				}
			})
		}
	})

	const schemaWithAdditionalTags = Schema.create(
		Object.values(compiledTypeMap)
	)
	;(schemaWithAdditionalTags as any).compiledTypeMap = compiledTypeMap

	const additionalOptions: Yaml.LoadOptions = {
		schema: schemaWithAdditionalTags
	}

	return createJSONDocument(Yaml.load(text, additionalOptions), text)
}
github alibaba / serverless-vscode / src / diagnostics / ROSTemplateDiagnosticsProvider.ts View on Github external
private parse(text: string): ASTNode {
    return buildAstRecursively(undefined, Yaml.load(text));;
  }
github alibaba / serverless-vscode / src / hovers / ROSTemplateHoverProvider.ts View on Github external
private parse(text: string): ASTNode {
    return buildAstRecursively(undefined, Yaml.load(text));;
  }