Skip to content

Commit

Permalink
Fix for beta version of PAC validation (#486)
Browse files Browse the repository at this point in the history
* Implemented verbose flag

* Updated packages

* Fixed changelog and feature severity
  • Loading branch information
AleksSavelev authored Oct 10, 2023
1 parent a818a9a commit e8b378b
Show file tree
Hide file tree
Showing 8 changed files with 287 additions and 241 deletions.
5 changes: 3 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# 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.2.0
* Integrated PAC validation

## 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).
* New flag `--all-locales` to disable optimization using localization loader. It's recommended not to use this flag because all locales take a huge amount of package size. If you need just a few of them follow [this guide](https://learn.microsoft.com/en-us/power-bi/developer/visuals/localization?tabs=English#step-5---add-a-resources-file-for-each-language). In this case, only declared in stringResources locales will be added to your visual package.
Expand Down
1 change: 1 addition & 0 deletions bin/pbiviz.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pbiviz
.option('--no-stats', "Doesn't generate statistics files")
.option('--skip-api', "Skips powerbi-visuals-api verifying")
.option('-l, --all-locales', "Keeps all locale files in the package. By default only used inside stringResources folder locales are included.")
.option('-v, --verbose', "Enables verbose logging")
.addOption(new Option('-c, --compression <compressionLevel>', "Enables compression of visual package")
.choices(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'])
.default('6')
Expand Down
437 changes: 237 additions & 200 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powerbi-visuals-tools",
"version": "5.2.0-beta.2",
"version": "5.2.0",
"description": "Command line tool for creating and publishing visuals for Power BI",
"main": "./bin/pbiviz.js",
"type": "module",
Expand Down Expand Up @@ -29,8 +29,8 @@
},
"homepage": "https://github.com/Microsoft/PowerBI-visuals-tools#readme",
"dependencies": {
"@typescript-eslint/parser": "^5.62.0",
"assert": "^2.0.0",
"@typescript-eslint/parser": "^6.7.5",
"assert": "^2.1.0",
"async": "^3.2.4",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
Expand Down Expand Up @@ -68,19 +68,19 @@
"string_decoder": "^1.3.0",
"terser-webpack-plugin": "^5.3.9",
"timers-browserify": "^2.0.12",
"ts-loader": "^9.4.4",
"ts-loader": "^9.5.0",
"tty-browserify": "^0.0.1",
"typescript": "^4.9.5",
"url": "^0.11.1",
"url": "^0.11.3",
"util": "^0.12.5",
"vm-browserify": "^1.1.2",
"webpack": "^5.88.2",
"webpack-bundle-analyzer": "4.9.0",
"webpack-bundle-analyzer": "4.9.1",
"webpack-dev-server": "^4.15.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.62.0",
"eslint": "^8.47.0",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"eslint": "^8.51.0",
"eslint-plugin-powerbi-visuals": "^0.8.1",
"jasmine": "5.1.0",
"jasmine-spec-reporter": "7.0.0",
Expand Down
33 changes: 17 additions & 16 deletions src/CommandManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@ import VisualManager from './VisualManager.js';
import { WebpackOptions } from './WebPackWrap.js';

interface StartOptions {
port: number,
stats: boolean,
drop: boolean,
skipApi: boolean
allLocales: boolean
port: number;
stats: boolean;
drop: boolean;
skipApi: boolean;
allLocales: boolean;
}

interface PackageOptions {
pbiviz: boolean,
resources: boolean,
minify: boolean,
compression: number,
stats: boolean,
skipApi: boolean
allLocales: boolean
pbiviz: boolean;
resources: boolean;
minify: boolean;
compression: number;
stats: boolean;
skipApi: boolean;
allLocales: boolean;
verbose: boolean;
}

interface NewOptions {
force: boolean,
template: string
force: boolean;
template: string;
}

export default class CommandManager {
Expand Down Expand Up @@ -69,9 +70,9 @@ export default class CommandManager {
}
new VisualManager(rootPath)
.prepareVisual()
.validateVisual()
.validateVisual(options.verbose)
.initializeWebpack(webpackOptions)
.then(visualManager => visualManager.generatePackage())
.then(visualManager => visualManager.generatePackage(options.verbose))
}

public static new({ force, template }: NewOptions, name: string, rootPath: string) {
Expand Down
32 changes: 19 additions & 13 deletions src/VisualManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ export default class VisualManager {
return this;
}

public generatePackage() {
public generatePackage(verbose: boolean = false) {
const callback = (err: Error, stats: Stats) => {
this.createPackageInstance();
const logs = this.validatePackage();
this.outputResults(logs);
this.outputResults(logs, verbose);
this.parseCompilationResults(err, stats)
}
this.compiler.run(callback);
Expand Down Expand Up @@ -134,10 +134,10 @@ export default class VisualManager {
}
}

public validateVisual() {
public validateVisual(verbose: boolean = false) {
this.featureManager = new FeatureManager()
const { status, logs } = this.featureManager.validate(Stage.PreBuild, this.visual);
this.outputResults(logs);
this.outputResults(logs, verbose);
if(status === Status.Error){
process.exit(1);
}
Expand All @@ -152,17 +152,23 @@ export default class VisualManager {
return logs;
}

public outputResults({ errors, deprecation, warnings, info }: Logs) {
const featuresTotalLog = {
errors: `Visual doesn't support some features required for all custom visuals:`,
public outputResults({ errors, deprecation, warnings, info }: Logs, verbose: boolean) {
const headerMessage = {
error: `Visual doesn't support some features required for all custom visuals:`,
deprecation: `Some features are going to be required soon, please update the visual:`,
warn: `Visual doesn't support some features recommended for all custom visuals:`,
info: `Visual can be improved by adding some features:`
warning: `Visual doesn't support some features recommended for all custom visuals:`,
verboseInfo: `Visual can be improved by adding some features:`,
shortInfo: `Visual can be improved by adding ${info.length} more optional features.`
};
this.outputLogsWithHeadMessage(featuresTotalLog.errors, errors, Severity.Error);
this.outputLogsWithHeadMessage(featuresTotalLog.deprecation, deprecation, Severity.Deprecation);
this.outputLogsWithHeadMessage(featuresTotalLog.warn, warnings, Severity.Warning);
this.outputLogsWithHeadMessage(featuresTotalLog.info, info, Severity.Info);

this.outputLogsWithHeadMessage(headerMessage.error, errors, Severity.Error);
this.outputLogsWithHeadMessage(headerMessage.deprecation, deprecation, Severity.Deprecation);
this.outputLogsWithHeadMessage(headerMessage.warning, warnings, Severity.Warning);

const verboseSuggestion = 'Run `pbiviz package` with --verbose flag to see more details.';
const headerInfoMessage = headerMessage[verbose ? "verboseInfo" : "shortInfo"]
const infoLogs = (!info.length || verbose) ? info : [verboseSuggestion];
this.outputLogsWithHeadMessage(headerInfoMessage, infoLogs, Severity.Info);
}

public displayInfo() {
Expand Down
2 changes: 1 addition & 1 deletion src/features/ESLint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Severity, Stage, VisualFeatureType } from "./FeatureTypes.js";
export default class ESLint implements BaseFeature {
public static featureName = "ESLint"
public static documentationLink = "https://github.com/microsoft/eslint-plugin-powerbi-visuals";
public static severity = Severity.Error
public static severity = Severity.Warning
public static stage = Stage.PreBuild
public static visualFeatureType = VisualFeatureType.All
public static errorMessage = `${this.featureName} - ${this.documentationLink}`
Expand Down
2 changes: 1 addition & 1 deletion src/features/TotalSubTotal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class TotalSubTotal implements BaseFeature {
public static documentationLink = "https://learn.microsoft.com/en-us/power-bi/developer/visuals/total-subtotal-api"
public static severity = Severity.Warning
public static stage = Stage.PostBuild
public static visualFeatureType = VisualFeatureType.Matrix | VisualFeatureType.NonSlicer | VisualFeatureType.Slicer
public static visualFeatureType = VisualFeatureType.Matrix
public static errorMessage = `${this.featureName} - ${this.documentationLink}`

static isSupported(packageInstance: Package) {
Expand Down

0 comments on commit e8b378b

Please sign in to comment.