diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 123e5931..c863621d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,8 @@ jobs: GH_TOKEN: ${{secrets.GH_TOKEN}} steps: - uses: actions/checkout@v2 + with: + ref: ${{ vars.BRANCH_NAME }} - name: Add config details run: | git config --global user.name ${{secrets.NAME}} diff --git a/Changelog.md b/Changelog.md index 7c19c25d..9ae55360 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,8 @@ # Change Log - PowerBI Visual Tools (pbiviz) This page contains information about changes to the PowerBI Visual Tools (pbiviz). +## 5.1.1 +* Updated crypto import to fix error in old Node versions ## 5.1.0 * New flag `--skip-api` to skip verifying api version. It might produce different errors in visual, so use it only in some specific cases (ex. installing something during the build process brakes packages managed by monorepo managers). diff --git a/package-lock.json b/package-lock.json index 75546945..7f3b4932 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "powerbi-visuals-tools", - "version": "5.1.0", + "version": "5.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "powerbi-visuals-tools", - "version": "5.1.0", + "version": "5.1.1", "license": "MIT", "dependencies": { "@typescript-eslint/parser": "^5.62.0", diff --git a/package.json b/package.json index b51f1257..026c5bd7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "powerbi-visuals-tools", - "version": "5.1.0", + "version": "5.1.1", "description": "Command line tool for creating and publishing visuals for Power BI", "main": "./bin/pbiviz.js", "type": "module", diff --git a/src/CertificateTools.ts b/src/CertificateTools.ts index 19fde662..a2736818 100644 --- a/src/CertificateTools.ts +++ b/src/CertificateTools.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-case-declarations */ /* * Power BI Visual CLI * @@ -30,7 +31,7 @@ import { exec as nodeExec } from 'child_process'; import fs from 'fs-extra'; import os from 'os'; import path from 'path'; -import crypto, { webcrypto } from "crypto" +import crypto from "crypto" import { getRootPath, readJsonFromRoot } from './utils.js'; import ConsoleWriter from './ConsoleWriter.js'; @@ -134,11 +135,8 @@ export async function createCertFile(config, open) { } break; case "win32": - // eslint-disable-next-line no-case-declarations - let passphrase = ""; // for windows 7 and others // 6.1 - Windows 7 - // eslint-disable-next-line no-case-declarations const osVersion = os.release().split("."); if ((Number(osVersion[0]) === 6 && Number(osVersion[1]) === 1) || Number(osVersion[0]) < 6) { await removeCertFiles(certPath, keyPath, pfxPath); @@ -160,7 +158,13 @@ export async function createCertFile(config, open) { } break; } - passphrase = (crypto.getRandomValues || webcrypto.getRandomValues)(new Uint32Array(1))[0].toString().substring(2); + let randomValues: Uint32Array; + if(crypto.getRandomValues !== undefined){ + randomValues = crypto.getRandomValues(new Uint32Array(1)); + } else { + randomValues = crypto.webcrypto.getRandomValues(new Uint32Array(1)); + } + const passphrase = randomValues[0].toString().substring(2); config.server.passphrase = passphrase; fs.writeFileSync(path.join(rootPath, confPath), JSON.stringify(config)); // for windows 8 / 8.1 / server 2012 R2 /