From 0339160a0b625a3e05e6dcdd3c4c642599cbab4e Mon Sep 17 00:00:00 2001 From: Otavio Jacobi Date: Wed, 4 Sep 2024 13:53:39 -0300 Subject: [PATCH] Remove not necessary 'import = require' syntax for js-yaml Change-type: patch --- npm-shrinkwrap.json | 18 +++++++++--------- src/commands/release/index.ts | 4 ++-- src/utils/compose_ts.ts | 9 ++++----- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index b5be4abf..482c693f 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -3894,9 +3894,9 @@ } }, "node_modules/@types/node": { - "version": "20.16.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.3.tgz", - "integrity": "sha512-/wdGiWRkMOm53gAsSyFMXFZHbVg7C6CbkrzHNpaHoYfsUWPg7m6ZRKtvQjgvQ9i8WT540a3ydRlRQbxjY30XxQ==", + "version": "20.16.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.4.tgz", + "integrity": "sha512-ioyQ1zK9aGEomJ45zz8S8IdzElyxhvP1RVWnPrXDf6wFaUb+kk1tEcVVJkF7RPGM0VWI7cp5U57oCPIn5iN1qg==", "dependencies": { "undici-types": "~6.19.2" } @@ -5681,9 +5681,9 @@ } }, "node_modules/balena-sdk/node_modules/@types/node": { - "version": "18.19.48", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.48.tgz", - "integrity": "sha512-7WevbG4ekUcRQSZzOwxWgi5dZmTak7FaxXDoW7xVxPBmKx1rTzfmRLkeCgJzcbBnOV2dkhAPc8cCeT6agocpjg==", + "version": "18.19.49", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.49.tgz", + "integrity": "sha512-ALCeIR6n0nQ7j0FUF1ycOhrp6+XutJWqEu/vtdEqXFUQwkBfgUA5cEg3ZNmjWGF/ZYA/FcF9QMkL55Ar0O6UrA==", "dependencies": { "undici-types": "~5.26.4" } @@ -14324,9 +14324,9 @@ } }, "node_modules/patch-package/node_modules/yaml": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", - "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.1.tgz", + "integrity": "sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==", "bin": { "yaml": "bin.mjs" }, diff --git a/src/commands/release/index.ts b/src/commands/release/index.ts index a73a8d31..a05d02a6 100644 --- a/src/commands/release/index.ts +++ b/src/commands/release/index.ts @@ -20,7 +20,7 @@ import Command from '../../command'; import * as cf from '../../utils/common-flags'; import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy'; import type * as BalenaSdk from 'balena-sdk'; -import jsyaml = require('js-yaml'); +import * as yaml from 'js-yaml'; import { tryAsInteger } from '../../utils/validation'; import { jsonInfo } from '../../utils/messages'; @@ -82,7 +82,7 @@ export default class ReleaseCmd extends Command { $select: 'composition', }); - console.log(jsyaml.dump(release.composition)); + console.log(yaml.dump(release.composition)); } async showReleaseInfo( diff --git a/src/utils/compose_ts.ts b/src/utils/compose_ts.ts index 8cb9ae5b..c1c130a4 100644 --- a/src/utils/compose_ts.ts +++ b/src/utils/compose_ts.ts @@ -19,7 +19,7 @@ import type { BalenaSDK } from 'balena-sdk'; import type { TransposeOptions } from '@balena/compose/dist/emulate'; import type * as Dockerode from 'dockerode'; import { promises as fs } from 'fs'; -import jsyaml = require('js-yaml'); +import * as yaml from 'js-yaml'; import * as _ from 'lodash'; import * as path from 'path'; import type { @@ -180,7 +180,6 @@ async function mergeDevComposeOverlay( interface ComposeObj { services?: object; } - const yaml = await import('js-yaml'); const loadObj = (inputStr: string): ComposeObj => (yaml.load(inputStr) || {}) as ComposeObj; try { @@ -659,7 +658,7 @@ async function loadBuildMetatada( if (metadataPath.endsWith('json')) { buildMetadata = JSON.parse(rawString); } else { - buildMetadata = require('js-yaml').load(rawString); + buildMetadata = yaml.load(rawString) as MultiBuild.ParsedBalenaYml; } } catch (err) { throw new ExpectedError( @@ -944,7 +943,7 @@ async function parseRegistrySecrets( const multiBuild = await import('@balena/compose/dist/multibuild'); const registrySecrets = new multiBuild.RegistrySecretValidator().validateRegistrySecrets( - isYaml ? require('js-yaml').load(raw) : JSON.parse(raw), + isYaml ? yaml.load(raw) : JSON.parse(raw), ); multiBuild.addCanonicalDockerHubEntry(registrySecrets); return registrySecrets; @@ -1494,7 +1493,7 @@ async function getContractContent( let asJson; try { - asJson = jsyaml.load(fileContentAsString); + asJson = yaml.load(fileContentAsString); } catch (err) { throw new ExpectedError( `Error parsing file "${filePath}":\n ${err.message}`,