Remove not necessary 'import = require' syntax for js-yaml

Change-type: patch
This commit is contained in:
Otavio Jacobi 2024-09-04 13:53:39 -03:00
parent 0591f5edbd
commit 0339160a0b
3 changed files with 15 additions and 16 deletions

18
npm-shrinkwrap.json generated
View File

@ -3894,9 +3894,9 @@
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "20.16.3", "version": "20.16.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.3.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.4.tgz",
"integrity": "sha512-/wdGiWRkMOm53gAsSyFMXFZHbVg7C6CbkrzHNpaHoYfsUWPg7m6ZRKtvQjgvQ9i8WT540a3ydRlRQbxjY30XxQ==", "integrity": "sha512-ioyQ1zK9aGEomJ45zz8S8IdzElyxhvP1RVWnPrXDf6wFaUb+kk1tEcVVJkF7RPGM0VWI7cp5U57oCPIn5iN1qg==",
"dependencies": { "dependencies": {
"undici-types": "~6.19.2" "undici-types": "~6.19.2"
} }
@ -5681,9 +5681,9 @@
} }
}, },
"node_modules/balena-sdk/node_modules/@types/node": { "node_modules/balena-sdk/node_modules/@types/node": {
"version": "18.19.48", "version": "18.19.49",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.48.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.49.tgz",
"integrity": "sha512-7WevbG4ekUcRQSZzOwxWgi5dZmTak7FaxXDoW7xVxPBmKx1rTzfmRLkeCgJzcbBnOV2dkhAPc8cCeT6agocpjg==", "integrity": "sha512-ALCeIR6n0nQ7j0FUF1ycOhrp6+XutJWqEu/vtdEqXFUQwkBfgUA5cEg3ZNmjWGF/ZYA/FcF9QMkL55Ar0O6UrA==",
"dependencies": { "dependencies": {
"undici-types": "~5.26.4" "undici-types": "~5.26.4"
} }
@ -14324,9 +14324,9 @@
} }
}, },
"node_modules/patch-package/node_modules/yaml": { "node_modules/patch-package/node_modules/yaml": {
"version": "2.5.0", "version": "2.5.1",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.1.tgz",
"integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", "integrity": "sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==",
"bin": { "bin": {
"yaml": "bin.mjs" "yaml": "bin.mjs"
}, },

View File

@ -20,7 +20,7 @@ import Command from '../../command';
import * as cf from '../../utils/common-flags'; import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy'; import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import type * as BalenaSdk from 'balena-sdk'; import type * as BalenaSdk from 'balena-sdk';
import jsyaml = require('js-yaml'); import * as yaml from 'js-yaml';
import { tryAsInteger } from '../../utils/validation'; import { tryAsInteger } from '../../utils/validation';
import { jsonInfo } from '../../utils/messages'; import { jsonInfo } from '../../utils/messages';
@ -82,7 +82,7 @@ export default class ReleaseCmd extends Command {
$select: 'composition', $select: 'composition',
}); });
console.log(jsyaml.dump(release.composition)); console.log(yaml.dump(release.composition));
} }
async showReleaseInfo( async showReleaseInfo(

View File

@ -19,7 +19,7 @@ import type { BalenaSDK } from 'balena-sdk';
import type { TransposeOptions } from '@balena/compose/dist/emulate'; import type { TransposeOptions } from '@balena/compose/dist/emulate';
import type * as Dockerode from 'dockerode'; import type * as Dockerode from 'dockerode';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import jsyaml = require('js-yaml'); import * as yaml from 'js-yaml';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as path from 'path'; import * as path from 'path';
import type { import type {
@ -180,7 +180,6 @@ async function mergeDevComposeOverlay(
interface ComposeObj { interface ComposeObj {
services?: object; services?: object;
} }
const yaml = await import('js-yaml');
const loadObj = (inputStr: string): ComposeObj => const loadObj = (inputStr: string): ComposeObj =>
(yaml.load(inputStr) || {}) as ComposeObj; (yaml.load(inputStr) || {}) as ComposeObj;
try { try {
@ -659,7 +658,7 @@ async function loadBuildMetatada(
if (metadataPath.endsWith('json')) { if (metadataPath.endsWith('json')) {
buildMetadata = JSON.parse(rawString); buildMetadata = JSON.parse(rawString);
} else { } else {
buildMetadata = require('js-yaml').load(rawString); buildMetadata = yaml.load(rawString) as MultiBuild.ParsedBalenaYml;
} }
} catch (err) { } catch (err) {
throw new ExpectedError( throw new ExpectedError(
@ -944,7 +943,7 @@ async function parseRegistrySecrets(
const multiBuild = await import('@balena/compose/dist/multibuild'); const multiBuild = await import('@balena/compose/dist/multibuild');
const registrySecrets = const registrySecrets =
new multiBuild.RegistrySecretValidator().validateRegistrySecrets( new multiBuild.RegistrySecretValidator().validateRegistrySecrets(
isYaml ? require('js-yaml').load(raw) : JSON.parse(raw), isYaml ? yaml.load(raw) : JSON.parse(raw),
); );
multiBuild.addCanonicalDockerHubEntry(registrySecrets); multiBuild.addCanonicalDockerHubEntry(registrySecrets);
return registrySecrets; return registrySecrets;
@ -1494,7 +1493,7 @@ async function getContractContent(
let asJson; let asJson;
try { try {
asJson = jsyaml.load(fileContentAsString); asJson = yaml.load(fileContentAsString);
} catch (err) { } catch (err) {
throw new ExpectedError( throw new ExpectedError(
`Error parsing file "${filePath}":\n ${err.message}`, `Error parsing file "${filePath}":\n ${err.message}`,