Skip to content
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
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Change Log - PowerBI Visual Tools (pbiviz)

This page contains information about changes to the PowerBI Visual Tools (pbiviz).
## 7.2.0
* Added a pre-build validation that fails with an error when the visual version contains parts with leading zeros (rejected by the Power BI marketplace package acceptance check).

## 7.1.2
Comment thread
Demonkratiy marked this conversation as resolved.
* Npm audit fixes.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powerbi-visuals-tools",
"version": "7.1.2",
"version": "7.2.0",
"description": "Command line tool for creating and publishing visuals for Power BI",
"main": "./bin/pbiviz.js",
"type": "module",
Expand Down
44 changes: 43 additions & 1 deletion spec/unit/FeatureManagerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const config = await readJsonFromRoot('config.json');

describe("Features", () => {
describe("Visual", () => {
const { APIVersion, VisualVersion, AuthorInfo } = features;
const { APIVersion, VisualVersion, VisualVersionLeadingZeros, AuthorInfo } = features;
it("Should support API Version", () => {
const Visual = {
doesAPIVersionMatch: (minVersion) => {
Expand All @@ -58,6 +58,48 @@ describe("Features", () => {
expect(VisualVersion.isSupported(Visual)).toBeTrue;
});

describe("VisualVersionLeadingZeros", () => {
it("Should support when version has no leading zeros", () => {
const capabilities = {};
const visualConfig = {
visual: { version: "1.16.345.1" },
apiVersion: "5.3.0"
};
const visual = new Visual(capabilities, visualConfig);
expect(VisualVersionLeadingZeros.isSupported(visual)).toBeTrue();
});

it("Should support when version parts are single zeros", () => {
const capabilities = {};
const visualConfig = {
visual: { version: "1.0.0.0" },
apiVersion: "5.3.0"
};
const visual = new Visual(capabilities, visualConfig);
expect(VisualVersionLeadingZeros.isSupported(visual)).toBeTrue();
});

it("Should not support when a version part has a leading zero", () => {
const capabilities = {};
const visualConfig = {
visual: { version: "1.16.0345.1" },
apiVersion: "5.3.0"
};
const visual = new Visual(capabilities, visualConfig);
expect(VisualVersionLeadingZeros.isSupported(visual)).toBeFalse();
});

it("Should not support when multiple version parts have leading zeros", () => {
const capabilities = {};
const visualConfig = {
visual: { version: "01.02.03.04" },
apiVersion: "5.3.0"
};
const visual = new Visual(capabilities, visualConfig);
expect(VisualVersionLeadingZeros.isSupported(visual)).toBeFalse();
});
});

describe("AuthorInfo", () => {
it("Should support when author object is defined", () => {
const capabilities = {};
Expand Down
4 changes: 4 additions & 0 deletions src/Visual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export class Visual {
return this.visualVersion.split(".").length === length
}

public hasVisualVersionLeadingZeros() {
return this.visualVersion.split(".").some(part => /^0\d+/.test(part));
}

public isAuthorDefined() {
const author = this.config?.author;
const emailRegex = /^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/;
Expand Down
16 changes: 16 additions & 0 deletions src/features/VisualVersionLeadingZeros.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Visual } from "../Visual.js";
import BaseFeature from "./BaseFeature.js";
import { Severity, Stage, VisualFeatureType } from "./FeatureTypes.js";

export default class VisualVersionLeadingZeros implements BaseFeature {
public static featureName = "Visual version leading zeros"
public static errorMessage = `${this.featureName} - version parts must not contain leading zeros (e.g. use 1.2.3.4 instead of 1.2.03.4). Update the pbiviz.json file. Versions with leading zeros are rejected by the Power BI marketplace package acceptance check.`
public static severity = Severity.Error
public static stage = Stage.PreBuild
public static visualFeatureType = VisualFeatureType.All
public static certificationRequired = true

static isSupported(visual: Visual) {
return !visual.hasVisualVersionLeadingZeros()
}
}
3 changes: 2 additions & 1 deletion src/features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import TotalSubTotal from './TotalSubTotal.js'
import WarningIcon from './WarningIcon.js'
import APIVersion from './APIVersion.js'
import VisualVersion from './VisualVersion.js'
import VisualVersionLeadingZeros from './VisualVersionLeadingZeros.js'

export {
AdvancedEditMode, AllowInteractions, AnalyticsPane, Bookmarks,
Expand All @@ -34,5 +35,5 @@ export {
HighlightData, KeyboardNavigation, LandingPage, LaunchURL,
Localizations, LocalStorage, ModalDialog, RenderingEvents,
SelectionAcrossVisuals, SyncSlicer, Tooltips, TotalSubTotal,
WarningIcon, APIVersion, VisualVersion, AuthorInfo
WarningIcon, APIVersion, VisualVersion, VisualVersionLeadingZeros, AuthorInfo
}
Loading