Compare commits

...

2 Commits

Author SHA1 Message Date
Bram Kragten 418327d6fe Fix js-yaml v5 default import in gallery build script
js-yaml v5 removed the ESM default export. The gallery page gatherer
imported it as a default, which crashed the gulp resource build and
cascaded into the lint, test, and all build CI jobs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 14:49:06 +02:00
Bram Kragten e637c0c583 Update dependency js-yaml to v5
js-yaml v5 is a major rewrite with breaking API and behavior changes.
This migrates our usage so behavior matches the YAML 1.1 semantics of
the PyYAML backend (the previous v4 default).

- Replace removed `DEFAULT_SCHEMA` with `YAML11_SCHEMA`. v5's new load
  default is `CORE_SCHEMA` (YAML 1.2), which parses `on`/`off`/`yes`/`no`
  as strings and drops merge keys (`<<`). `YAML11_SCHEMA` preserves the
  boolean semantics and `!!merge` we (and the backend) rely on.
- Pin the bare `load(paste)` calls in the automation and script editors
  to `YAML11_SCHEMA` for the same reason.
- Port the custom `!secret` tag from the removed `Type`/`Schema.extend()`
  API to `defineScalarTag()` + `Schema.withTags()`.
- Drop the removed `dump()` option `quotingType` (the v5 default
  `quoteStyle: "auto"` quotes only when needed and round-trips safely).
- Remove `@types/js-yaml`; v5 ships its own TypeScript types.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 14:33:36 +02:00
7 changed files with 28 additions and 28 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
import fs from "fs";
import { glob } from "glob";
import gulp from "gulp";
import yaml from "js-yaml";
import { load as loadYaml } from "js-yaml";
import { marked } from "marked";
import path from "path";
import paths from "../paths.cjs";
@@ -47,7 +47,7 @@ gulp.task("gather-gallery-pages", async function gatherPages() {
if (descriptionContent.startsWith("---")) {
const metadataEnd = descriptionContent.indexOf("---", 3);
metadata = yaml.load(descriptionContent.substring(3, metadataEnd));
metadata = loadYaml(descriptionContent.substring(3, metadataEnd));
descriptionContent = descriptionContent
.substring(metadataEnd + 3)
.trim();
+1 -2
View File
@@ -102,7 +102,7 @@
"home-assistant-js-websocket": "9.6.0",
"idb-keyval": "6.2.5",
"intl-messageformat": "11.2.8",
"js-yaml": "4.2.0",
"js-yaml": "5.0.0",
"leaflet": "1.9.4",
"leaflet-draw": "patch:leaflet-draw@npm%3A1.0.4#./.yarn/patches/leaflet-draw-npm-1.0.4-0ca0ebcf65.patch",
"leaflet.markercluster": "1.5.3",
@@ -154,7 +154,6 @@
"@types/color-name": "2.0.0",
"@types/culori": "4.0.1",
"@types/html-minifier-terser": "7.0.2",
"@types/js-yaml": "4.0.9",
"@types/leaflet": "1.9.21",
"@types/leaflet-draw": "1.0.13",
"@types/leaflet.markercluster": "1.5.6",
+2 -3
View File
@@ -1,5 +1,5 @@
import type { Schema } from "js-yaml";
import { DEFAULT_SCHEMA, dump, load } from "js-yaml";
import { dump, load, YAML11_SCHEMA } from "js-yaml";
import type { CSSResultGroup, PropertyValues } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
@@ -30,7 +30,7 @@ const isEmpty = (obj: Record<string, unknown>): boolean => {
export class HaYamlEditor extends LitElement {
@property() public value?: any;
@property({ attribute: false }) public yamlSchema: Schema = DEFAULT_SCHEMA;
@property({ attribute: false }) public yamlSchema: Schema = YAML11_SCHEMA;
@property({ attribute: false }) public defaultValue?: any;
@@ -70,7 +70,6 @@ export class HaYamlEditor extends LitElement {
this._yaml = !isEmpty(value)
? dump(value, {
schema: this.yamlSchema,
quotingType: '"',
noRefs: true,
})
: "";
@@ -1,5 +1,5 @@
import { mdiDotsVertical } from "@mdi/js";
import { DEFAULT_SCHEMA, Type } from "js-yaml";
import { defineScalarTag, YAML11_SCHEMA } from "js-yaml";
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
import { css, html, LitElement } from "lit";
import { customElement, property, query, state } from "lit/decorators";
@@ -47,12 +47,11 @@ const SUPPORTED_UI_TYPES = [
"schema",
];
const ADDON_YAML_SCHEMA = DEFAULT_SCHEMA.extend([
new Type("!secret", {
kind: "scalar",
construct: (data) => `!secret ${data}`,
}),
]);
const secretTag = defineScalarTag("!secret", {
resolve: (data) => `!secret ${data}`,
});
const ADDON_YAML_SCHEMA = YAML11_SCHEMA.withTags(secretTag);
const MASKED_FIELDS = ["password", "secret", "token"];
@@ -1,5 +1,5 @@
import type { HassEntity } from "home-assistant-js-websocket";
import { load } from "js-yaml";
import { load, YAML11_SCHEMA } from "js-yaml";
import type { CSSResultGroup } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, queryAll } from "lit/decorators";
@@ -224,7 +224,7 @@ export class HaManualAutomationEditor extends ManualEditorMixin<ManualAutomation
let loaded: any;
try {
loaded = load(paste);
loaded = load(paste, { schema: YAML11_SCHEMA });
} catch (_err: any) {
showEditorToast(this, {
message: this.hass.localize(
@@ -1,5 +1,5 @@
import { mdiHelpCircleOutline } from "@mdi/js";
import { load } from "js-yaml";
import { load, YAML11_SCHEMA } from "js-yaml";
import type { CSSResultGroup, PropertyValues } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, query, queryAll } from "lit/decorators";
@@ -197,7 +197,7 @@ export class HaManualScriptEditor extends ManualEditorMixin<ScriptConfig>(
let loaded: any;
try {
loaded = load(paste);
loaded = load(paste, { schema: YAML11_SCHEMA });
} catch (_err: any) {
showEditorToast(this, {
message: this.hass.localize(
+13 -10
View File
@@ -5550,13 +5550,6 @@ __metadata:
languageName: node
linkType: hard
"@types/js-yaml@npm:4.0.9":
version: 4.0.9
resolution: "@types/js-yaml@npm:4.0.9"
checksum: 10/a0ce595db8a987904badd21fc50f9f444cb73069f4b95a76cc222e0a17b3ff180669059c763ec314bc4c3ce284379177a9da80e83c5f650c6c1310cafbfaa8e6
languageName: node
linkType: hard
"@types/jsesc@npm:^2.5.0":
version: 2.5.1
resolution: "@types/jsesc@npm:2.5.1"
@@ -9763,7 +9756,6 @@ __metadata:
"@types/color-name": "npm:2.0.0"
"@types/culori": "npm:4.0.1"
"@types/html-minifier-terser": "npm:7.0.2"
"@types/js-yaml": "npm:4.0.9"
"@types/leaflet": "npm:1.9.21"
"@types/leaflet-draw": "npm:1.0.13"
"@types/leaflet.markercluster": "npm:1.5.6"
@@ -9819,7 +9811,7 @@ __metadata:
husky: "npm:9.1.7"
idb-keyval: "npm:6.2.5"
intl-messageformat: "npm:11.2.8"
js-yaml: "npm:4.2.0"
js-yaml: "npm:5.0.0"
jsdom: "npm:29.1.1"
jszip: "npm:3.10.1"
leaflet: "npm:1.9.4"
@@ -10762,7 +10754,18 @@ __metadata:
languageName: node
linkType: hard
"js-yaml@npm:4.2.0, js-yaml@npm:^4.1.0":
"js-yaml@npm:5.0.0":
version: 5.0.0
resolution: "js-yaml@npm:5.0.0"
dependencies:
argparse: "npm:^2.0.1"
bin:
js-yaml: bin/js-yaml.mjs
checksum: 10/51691da5a1b3894ffdd6ffe386d061fecf8769d135560dce8f3d3b7c5f7b167ec7fbe2c232c91135d58216b2f6ba215e85ac60fe569c46f0a9024f2ff6dec47e
languageName: node
linkType: hard
"js-yaml@npm:^4.1.0":
version: 4.2.0
resolution: "js-yaml@npm:4.2.0"
dependencies: