Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CCI] Update js-yaml to v4.0.5 #3770

Merged
merged 3 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Remove the unused `renovate.json5` file ([3489](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3489))
- Allow selecting the Node.js binary using `NODE_HOME` and `OSD_NODE_HOME` ([3508](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3508))
- Bump `styled-components` from 5.3.5 to 5.3.9 ([#3678](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3678))
- Bump `js-yaml` from 3.14.0 to 4.1.0 ([#3770](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3770))
- Bump `oui` from `1.0.0` to `1.1.1` ([#3884](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3884))

### 🪛 Refactoring
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"inline-style": "^2.0.0",
"ip-cidr": "^2.1.0",
"joi": "^13.5.2",
"js-yaml": "^3.14.0",
"js-yaml": "^4.1.0",
"json-stable-stringify": "^1.0.1",
"json-stringify-safe": "5.0.1",
"lodash": "^4.17.21",
Expand Down Expand Up @@ -288,7 +288,7 @@
"@types/jest": "^27.4.0",
"@types/joi": "^13.4.2",
"@types/jquery": "^3.3.31",
"@types/js-yaml": "^3.11.1",
"@types/js-yaml": "^4.0.5",
"@types/json-stable-stringify": "^1.0.32",
"@types/json5": "^0.0.30",
"@types/license-checker": "15.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-apm-config-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@elastic/safer-lodash-set": "0.0.0",
"@osd/utils": "1.0.0",
"js-yaml": "^3.14.0",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/osd-apm-config-loader/src/utils/read_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
*/

import { readFileSync } from 'fs';
import { safeLoad } from 'js-yaml';
import { load } from 'js-yaml';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andreymyssak Can you explain this change a little? Is it just a method renaming, or are there functional differences between the behavior of the old safeLoad vs load?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just renaming, see safeLoad(), safeLoadAll(), safeDump() => load(), loadAll(), dump(). There's no mention of a breaking change in their behavior.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect, thanks for the link!


import { set } from '@elastic/safer-lodash-set';
import { isPlainObject } from 'lodash';
import { ensureDeepObject } from './ensure_deep_object';

const readYaml = (path: string) => safeLoad(readFileSync(path, 'utf8'));
const readYaml = (path: string) => load(readFileSync(path, 'utf8'));

function replaceEnvVarRefs(val: string) {
return val.replace(/\$\{(\w+)\}/g, (match, envVarName) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@osd/config-schema": "1.0.0",
"@osd/logging": "1.0.0",
"@osd/std": "1.0.0",
"js-yaml": "^3.14.0",
"js-yaml": "^4.1.0",
"load-json-file": "^6.2.0",
"lodash": "^4.17.21",
"moment": "^2.24.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/osd-config/src/raw/read_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
*/

import { readFileSync } from 'fs';
import { safeLoad } from 'js-yaml';
import { load } from 'js-yaml';

import { set } from '@elastic/safer-lodash-set';
import { isPlainObject } from 'lodash';
import { ensureDeepObject } from './ensure_deep_object';

const readYaml = (path: string) => safeLoad(readFileSync(path, 'utf8'));
const readYaml = (path: string) => load(readFileSync(path, 'utf8'));

function replaceEnvVarRefs(val: string) {
return val.replace(/\$\{(\w+)\}/g, (match, envVarName) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-optimizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"execa": "^4.0.2",
"fibers": "^5.0.3",
"jest-diff": "^27.5.1",
"js-yaml": "^3.14.0",
"js-yaml": "^4.1.0",
"json-stable-stringify": "^1.0.1",
"lmdb-store": "^1.6.11",
"normalize-path": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/osd-optimizer/src/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function readLimits(): Limits {
}
}

return yaml ? (Yaml.safeLoad(yaml) as any) : {};
return yaml ? (Yaml.load(yaml) as any) : {};
}

export function validateLimitsForAllBundles(log: ToolingLog, config: OptimizerConfig) {
Expand Down Expand Up @@ -109,6 +109,6 @@ export function updateBundleLimits(log: ToolingLog, config: OptimizerConfig) {
pageLoadAssetSize,
};

Fs.writeFileSync(LIMITS_PATH, Yaml.safeDump(newLimits));
Fs.writeFileSync(LIMITS_PATH, Yaml.dump(newLimits));
log.success(`wrote updated limits to ${LIMITS_PATH}`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import Del from 'del';

import * as Rx from 'rxjs';
import { map, filter, take } from 'rxjs/operators';
import { safeDump } from 'js-yaml';
import { dump } from 'js-yaml';
import { getConfigFromFiles } from '@osd/config';

const legacyConfig = follow('__fixtures__/reload_logging_config/opensearch_dashboards.test.yml');
Expand Down Expand Up @@ -89,7 +89,7 @@ function createConfigManager(configPath: string) {
return {
modify(fn: (input: Record<string, any>) => Record<string, any>) {
const oldContent = getConfigFromFiles([configPath]);
const yaml = safeDump(fn(oldContent));
const yaml = dump(fn(oldContent));
Fs.writeFileSync(configPath, yaml);
},
};
Expand Down
4 changes: 2 additions & 2 deletions src/dev/stylelint/lint_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@

import stylelint from 'stylelint';
import path from 'path';
import { safeLoad } from 'js-yaml';
import { load } from 'js-yaml';
import fs from 'fs';
import { createFailError } from '@osd/dev-utils';

// load the include globs from .stylelintrc.yml and convert them to regular expressions for filtering files
const stylelintPath = path.resolve(__dirname, '..', '..', '..', '.stylelintrc.yml');
const styleLintConfig = safeLoad(fs.readFileSync(stylelintPath));
const styleLintConfig = load(fs.readFileSync(stylelintPath));

/**
* Lints a list of files with eslint. eslint reports are written to the log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

import { accessSync, constants, readFileSync, statSync } from 'fs';
import { safeLoad } from 'js-yaml';
import { load } from 'js-yaml';
import { dirname, join } from 'path';
import { Observable } from 'rxjs';

Expand Down Expand Up @@ -78,7 +78,7 @@ export async function readTelemetryFile<T extends object>(
try {
if (isFileReadable(configPath)) {
const yaml = readFileSync(configPath);
const data = safeLoad(yaml.toString());
const data = load(yaml.toString());

// don't bother returning empty objects
if (Object.keys(data).length) {
Expand Down
4 changes: 2 additions & 2 deletions tasks/function_test_groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import { resolve } from 'path';

import execa from 'execa';
import grunt from 'grunt';
import { safeLoad } from 'js-yaml';
import { load } from 'js-yaml';

const JOBS_YAML = readFileSync(resolve(__dirname, '../.ci/jobs.yml'), 'utf8');
const TEST_TAGS = safeLoad(JOBS_YAML)
const TEST_TAGS = load(JOBS_YAML)
.JOB.filter((id) => id.startsWith('opensearch-dashboards-ciGroup'))
.map((id) => id.replace(/^opensearch-dashboards-/, ''));

Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3126,10 +3126,10 @@
resolved "https://registry.yarnpkg.com/@types/js-cookie/-/js-cookie-2.2.5.tgz#38dfaacae8623b37cc0b0d27398e574e3fc28b1e"
integrity sha512-cpmwBRcHJmmZx0OGU7aPVwGWGbs4iKwVYchk9iuMtxNCA2zorwdaTz4GkLgs2WGxiRZRFKnV1k6tRUHX7tBMxg==

"@types/js-yaml@^3.11.1":
version "3.12.7"
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.12.7.tgz#330c5d97a3500e9c903210d6e49f02964af04a0e"
integrity sha512-S6+8JAYTE1qdsc9HMVsfY7+SgSuUU/Tp6TYTmITW0PZxiyIMvol3Gy//y69Wkhs0ti4py5qgR3uZH6uz/DNzJQ==
"@types/js-yaml@^4.0.5":
version "4.0.5"
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.5.tgz#738dd390a6ecc5442f35e7f03fa1431353f7e138"
integrity sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA==

"@types/json-schema@*", "@types/json-schema@^7.0.3", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9":
version "7.0.11"
Expand Down Expand Up @@ -11234,14 +11234,14 @@ [email protected]:
dependencies:
esprima "^4.0.1"

[email protected]:
[email protected], js-yaml@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
dependencies:
argparse "^2.0.1"

js-yaml@^3.13.1, js-yaml@^3.14.0, js-yaml@~3.14.0:
js-yaml@^3.13.1, js-yaml@~3.14.0:
version "3.14.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537"
integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==
Expand Down