mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Upgrade js-yaml to 4.X (#3623)
This commit is contained in:
1 parent
fcb3010033
commit
5998b4ca84
17 files changed
+90
-57
No files matched your search
@@ -25,7 +25,7 @@ import React from "react";
|
||||
import path from "path";
|
||||
import fs from "fs-extra";
|
||||
import {Select, GroupSelectOption, SelectOption} from "../select";
|
||||
import jsYaml from "js-yaml";
|
||||
import yaml from "js-yaml";
|
||||
import { observable, makeObservable } from "mobx";
|
||||
import { observer } from "mobx-react";
|
||||
import { cssNames } from "../../utils";
|
||||
@@ -101,15 +101,14 @@ export class CreateResource extends React.Component<Props> {
|
||||
return null;
|
||||
}
|
||||
|
||||
// skip empty documents if "---" pasted at the beginning or end
|
||||
const resources = jsYaml.safeLoadAll(this.data).filter(Boolean);
|
||||
// skip empty documents
|
||||
const resources = yaml.loadAll(this.data).filter(Boolean);
|
||||
const createdResources: string[] = [];
|
||||
|
||||
if (resources.length === 0) {
|
||||
return void logger.info("Nothing to create");
|
||||
}
|
||||
|
||||
const createdResources: string[] = [];
|
||||
|
||||
for (const result of await Promise.allSettled(resources.map(resourceApplierApi.update))) {
|
||||
if (result.status === "fulfilled") {
|
||||
createdResources.push(result.value.metadata.name);
|
||||
|
||||
@@ -72,13 +72,13 @@ export class EditResource extends React.Component<Props> {
|
||||
return draft;
|
||||
}
|
||||
|
||||
return yaml.safeDump(this.resource.toPlainObject()); // dump resource first time
|
||||
return yaml.dump(this.resource.toPlainObject()); // dump resource first time
|
||||
}
|
||||
|
||||
@action
|
||||
saveDraft(draft: string | object) {
|
||||
if (typeof draft === "object") {
|
||||
draft = draft ? yaml.safeDump(draft) : undefined;
|
||||
draft = draft ? yaml.dump(draft) : undefined;
|
||||
}
|
||||
|
||||
editResourceStore.setData(this.tabId, {
|
||||
@@ -99,8 +99,8 @@ export class EditResource extends React.Component<Props> {
|
||||
}
|
||||
|
||||
const store = editResourceStore.getStore(this.tabId);
|
||||
const currentVersion = yaml.safeLoad(this.draft);
|
||||
const firstVersion = yaml.safeLoad(editResourceStore.getData(this.tabId).firstDraft ?? this.draft);
|
||||
const currentVersion = yaml.load(this.draft);
|
||||
const firstVersion = yaml.load(editResourceStore.getData(this.tabId).firstDraft ?? this.draft);
|
||||
const patches = createPatch(firstVersion, currentVersion);
|
||||
const updatedResource = await store.patch(this.resource, patches);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
import MonacoEditor, {monaco} from "react-monaco-editor";
|
||||
import React from "react";
|
||||
import jsYaml from "js-yaml";
|
||||
import yaml from "js-yaml";
|
||||
import { observable, makeObservable } from "mobx";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { dockStore, TabId } from "./dock.store";
|
||||
@@ -63,14 +63,14 @@ export class EditorPanel extends React.Component<Props> {
|
||||
editorDidMount = (editor: monaco.editor.IStandaloneCodeEditor) => {
|
||||
this.editor = editor;
|
||||
const model = monacoModelsManager.getModel(this.props.tabId);
|
||||
|
||||
|
||||
model.setValue(this.props.value ?? "");
|
||||
this.editor.setModel(model);
|
||||
};
|
||||
|
||||
validate(value: string) {
|
||||
try {
|
||||
jsYaml.safeLoadAll(value);
|
||||
yaml.loadAll(value);
|
||||
this.yamlError = "";
|
||||
} catch (err) {
|
||||
this.yamlError = err.toString();
|
||||
|
||||
Reference in new issue
Block a user