yamlctl 0.1.0 → 0.1.1

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 CHANGED
@@ -3,14 +3,13 @@
3
3
  [![CI](https://github.com/devpro/yamlctl/actions/workflows/ci.yml/badge.svg)](https://github.com/devpro/yamlctl/actions/workflows/ci.yml)
4
4
  [![npm](https://img.shields.io/npm/v/yamlctl)](https://www.npmjs.com/package/yamlctl)
5
5
 
6
- `yamlctl` reads and edits YAML data files entry by entry, and checks every change against the file's JSON Schema before writing it.
6
+ Edit YAML files from the command line.
7
7
 
8
- It is made for YAML files that are data rather than code, a list of projects, servers or rules, kept in git and read by Terraform, Ansible or anything else,
9
- and updated by a pipeline from another system: a CMDB, a service catalog, a spreadsheet export.
8
+ ## Key
10
9
 
11
10
  - **Kubectl-like**: `yamlctl project list`, `yamlctl project get checkout_api`, `yamlctl project set checkout_api name="Checkout API"`.
12
11
  - **Checked**: a field that does not exist, a value outside its allowed list, or a reference to a missing entry is refused, and the file is left as it was.
13
- - **Typed by the schema**: `005217217997` stays a string where the schema says string, where a plain YAML write would turn it into a number.
12
+ - **Typed by the schema**: a string stays a file even if it looks like a number.
14
13
  - **Careful with the file**: comments, order and every entry not named stay exactly as they were, and a command changing nothing writes nothing.
15
14
  - **Nothing to configure**: the schema is the one the file already names for an editor.
16
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yamlctl",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Read and edit YAML data files from the command line, entry by entry, every change checked against the file's JSON Schema",
5
5
  "keywords": [
6
6
  "yaml",
package/src/schema.js CHANGED
@@ -63,8 +63,9 @@ function pointerKeys(fragment, pointer) {
63
63
  const isNull = (schema) => schema?.type === 'null' || (Array.isArray(schema?.type) && schema.type.length === 1 && schema.type[0] === 'null');
64
64
 
65
65
  export class Schema {
66
- // `uri` defaults to an address of its own for a schema built in memory, which resolves a fragment reference and nothing else.
67
- constructor(root, uri = 'urn:yamlctl:inline') {
66
+ // `uri` defaults to an address of its own for a schema built in memory.
67
+ // It has a path, unlike a `urn:`, since a URL parser following the WHATWG standard refuses to resolve a relative reference against an opaque one, and the reference would then be dropped rather than reported as missing.
68
+ constructor(root, uri = 'yamlctl:/inline') {
68
69
  this.root = root;
69
70
  this.uri = uri;
70
71
  this.path = displayUri(uri);