powerbi-visuals-tools 5.0.3 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Changelog.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  This page contains information about changes to the PowerBI Visual Tools (pbiviz).
4
4
 
5
+ ## 5.1.0
6
+ * 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).
7
+ * 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.
8
+
9
+ ## 5.0.3
10
+ * Now option `--install-cert` is command. The new usage is `pbiviz install-cert` **⚠**
11
+
5
12
  ## 5.0.3
6
13
  * Now option `--install-cert` is command. New usage is `pbiviz install-cert`
7
14
  * Fixed bug with the incorrect detection of the installed API version
@@ -20,6 +27,7 @@ This page contains information about changes to the PowerBI Visual Tools (pbiviz
20
27
  * Migrated to NodeJS 18.0 **⚠**
21
28
 
22
29
  ## 4.3.2
30
+ * `options` in `Visual.constructor()` is optional. It's made to match PowerBI interface and to support strict mode
23
31
  * LocalizationLoader has been moved to `powerbi-visuals-webpack-plugin`
24
32
 
25
33
  ## 4.3.1
@@ -36,8 +44,13 @@ This page contains information about changes to the PowerBI Visual Tools (pbiviz
36
44
  * Fixed vulnerabilities
37
45
  * Updated `powerbi-visuals-webpack-plugin` to 3.2.0
38
46
 
47
+
48
+ ### **⚠ BREAKING CHANGES**
39
49
  ## 4.1.0
40
- * Added loader to reduce localizations size. REQUIRES `powerbi-visuals-utils-formattingutils` version 5.1 and higher
50
+ * Added loader to reduce localizations size. REQUIRES `powerbi-visuals-utils-formattingutils` version 5.1 and higher.
51
+
52
+ Now loader deletes all unused in stringResources folder locales.
53
+
41
54
  * Fixed vulnerabilities
42
55
 
43
56
  ## 4.0.9
package/bin/pbiviz.js CHANGED
@@ -44,9 +44,9 @@ const pbiviz = program
44
44
  pbiviz
45
45
  .command('new')
46
46
  .usage("<argument> [options]")
47
- .argument('<name>', 'name of new visual')
48
- .option('-f, --force', 'force creation (overwrites folder if exists)')
49
- .addOption(new Option('-t, --template [template]', 'use a specific template')
47
+ .argument('<name>', 'Name of new visual')
48
+ .option('-f, --force', 'Force creation (overwrites folder if exists)')
49
+ .addOption(new Option('-t, --template [template]', 'Use a specific template')
50
50
  .choices(['default', 'table', 'slicer', 'rvisual', 'rhtml', 'circlecard'])
51
51
  .default('default')
52
52
  )
@@ -71,9 +71,11 @@ pbiviz
71
71
  pbiviz
72
72
  .command('start')
73
73
  .usage('[options]')
74
- .option('-p, --port [port]', 'set the port listening on')
75
- .option('-d, --drop', 'drop outputs into output folder')
74
+ .option('-p, --port [port]', 'Set the port listening on')
75
+ .option('-d, --drop', 'Drop outputs into output folder')
76
76
  .option('--no-stats', "Doesn't generate statistics files")
77
+ .option('--skip-api', "Skips powerbi-visuals-api verifying")
78
+ .option('-l, --all-locales', "Keeps all locale files in the package. By default only used inside stringResources folder locales are included.")
77
79
  .action(async (options) => {
78
80
  CommandManager.start(options, rootPath);
79
81
  });
@@ -85,6 +87,8 @@ pbiviz
85
87
  .option('--no-pbiviz', "Doesn't produce a pbiviz file (must be used in conjunction with resources flag)")
86
88
  .option('--no-minify', "Doesn't minify the js in the package (useful for debugging)")
87
89
  .option('--no-stats', "Doesn't generate statistics files")
90
+ .option('--skip-api', "Skips powerbi-visuals-api verifying")
91
+ .option('-l, --all-locales', "Keeps all locale files in the package. By default only used inside stringResources folder locales are included.")
88
92
  .addOption(new Option('-c, --compression <compressionLevel>', "Enables compression of visual package")
89
93
  .choices(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'])
90
94
  .default('6')
@@ -1,28 +1,28 @@
1
1
  -----BEGIN PRIVATE KEY-----
2
- MIIEvAIBADANBgkqhk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2RWogd2/kwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEARQpD
13
+ lZRixXXot7qr1ygS1iSDm8CODWhQca8V1T80TPRFNlX3beQPkbCndsZBa/PoXN21
14
+ D2QBScsXgMaVEBB5FVmKAVXf/e2KoOUZ9Au8Oko9sKrzUalirM2YlqYbgwiAI0wR
15
+ 1rTBm+aNsP8xFVDyYrbFe60rtuhduFDvAWi2p9ywQdRuW5I5DyLMBuqOVWo7vn0I
16
+ 3hJ4FM3r4Lb/8LUrFVjxtLVMEqC1nlpt5FgyjpuN/adYICBQFqtHCiirXRoyfdL8
17
+ 7TZts6ychG5yhoB0fixYnExQfwIMeaqIKiuwqcZoRB2EjTKBTNBeXfxISNR6HPnq
18
+ a0Q0pHZGEGnT+S8mFA==
19
19
  -----END CERTIFICATE-----
@@ -28,7 +28,7 @@ import { exec as nodeExec } from 'child_process';
28
28
  import fs from 'fs-extra';
29
29
  import os from 'os';
30
30
  import path from 'path';
31
- import crypto from "crypto";
31
+ import crypto, { webcrypto } from "crypto";
32
32
  import { getRootPath, readJsonFromRoot } from './utils.js';
33
33
  import ConsoleWriter from './ConsoleWriter.js';
34
34
  const certSafePeriod = 1000 * 60 * 60 * 24; // 24 hours
@@ -140,7 +140,7 @@ export async function createCertFile(config, open) {
140
140
  }
141
141
  break;
142
142
  }
143
- passphrase = crypto.getRandomValues(new Uint32Array(1))[0].toString().substring(2);
143
+ passphrase = (crypto.getRandomValues || webcrypto.getRandomValues)(new Uint32Array(1))[0].toString().substring(2);
144
144
  config.server.passphrase = passphrase;
145
145
  fs.writeFileSync(path.join(rootPath, confPath), JSON.stringify(config));
146
146
  // for windows 8 / 8.1 / server 2012 R2 /
@@ -11,7 +11,9 @@ export default class CommandManager {
11
11
  minifyJS: false,
12
12
  minify: false,
13
13
  devServerPort: options.port,
14
- stats: options.stats
14
+ stats: options.stats,
15
+ skipApiCheck: options.skipApi,
16
+ allLocales: options.allLocales
15
17
  };
16
18
  const visualManager = new VisualManager(rootPath);
17
19
  await visualManager
@@ -31,7 +33,9 @@ export default class CommandManager {
31
33
  minifyJS: options.minify,
32
34
  minify: options.minify,
33
35
  compression: options.compression,
34
- stats: options.stats
36
+ stats: options.stats,
37
+ skipApiCheck: options.skipApi,
38
+ allLocales: options.allLocales
35
39
  };
36
40
  new VisualManager(rootPath)
37
41
  .prepareVisual()
@@ -52,7 +52,8 @@ export default class VisualManager {
52
52
  this.pbivizConfig = readJsonFromVisual(PBIVIZ_FILE, this.basePath);
53
53
  }
54
54
  else {
55
- throw new Error(PBIVIZ_FILE + ' not found. You must be in the root of a visual project to run this command.');
55
+ ConsoleWriter.error(PBIVIZ_FILE + ' not found. You must be in the root of a visual project to run this command.');
56
+ process.exit(1);
56
57
  }
57
58
  return this;
58
59
  }
@@ -9,7 +9,7 @@ import { exec as processExec } from 'child_process';
9
9
  import lodashCloneDeep from 'lodash.clonedeep';
10
10
  import ExtraWatchWebpackPlugin from 'extra-watch-webpack-plugin';
11
11
  import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
12
- import { PowerBICustomVisualsWebpackPlugin } from 'powerbi-visuals-webpack-plugin';
12
+ import { PowerBICustomVisualsWebpackPlugin, LocalizationLoader } from 'powerbi-visuals-webpack-plugin';
13
13
  import ConsoleWriter from './ConsoleWriter.js';
14
14
  import { resolveCertificate } from "./CertificateTools.js";
15
15
  import { readJsonFromRoot, readJsonFromVisual } from './utils.js';
@@ -33,12 +33,13 @@ export default class WebPackWrap {
33
33
  await fs.createFile(visualPluginFile);
34
34
  }
35
35
  static loadAPIPackage() {
36
- try {
37
- return import("file://" + path.join(process.cwd(), "node_modules", "powerbi-visuals-api", "index.js"));
38
- }
39
- catch (ex) {
40
- return null;
36
+ const apiPath = path.join(process.cwd(), "node_modules", "powerbi-visuals-api");
37
+ const doesAPIExist = fs.pathExistsSync(apiPath);
38
+ if (!doesAPIExist) {
39
+ ConsoleWriter.error(`Can't find powerbi-visuals-api package`);
40
+ process.exit(1);
41
41
  }
42
+ return import("file://" + path.join(apiPath, "index.js"));
42
43
  }
43
44
  async installAPIpackage() {
44
45
  const apiVersion = this.pbiviz.apiVersion ? `~${this.pbiviz.apiVersion}` : "latest";
@@ -115,45 +116,50 @@ export default class WebPackWrap {
115
116
  return env;
116
117
  }
117
118
  async configureCustomVisualsWebpackPlugin(visualPackage, options, tsconfig) {
118
- const pluginConfiguration = lodashCloneDeep(visualPackage.pbivizConfig);
119
- //(?=\D*$) - positive look-ahead to find last version symbols and exclude any non-digit symbols after the version.
120
- const regexFullVersion = /(?<=powerbi-visuals-api@)((?:\d+\.?){1,3})/g;
121
- const regexMinorVersion = /\d+(?:\.\d+)?/;
122
- let apiVersionInstalled;
123
- try {
124
- const subprocess = await exec('npm list powerbi-visuals-api version');
125
- apiVersionInstalled = subprocess.stdout.match(regexFullVersion)[0];
126
- }
127
- catch (err) {
128
- ConsoleWriter.warning(`"powerbi-visuals-api" is not installed`);
119
+ if (options.skipApiCheck) {
120
+ ConsoleWriter.warning(`Skipping API check. Tools started with --skipApi flag.`);
129
121
  }
130
- // if the powerbi-visual-api package wasn't installed
131
- // install the powerbi-visual-api, with version from apiVersion in pbiviz.json
132
- // or the latest API, if apiVersion is absent in pbiviz.json
133
- if (!apiVersionInstalled || !this.pbiviz.apiVersion || this.pbiviz.apiVersion.match(regexMinorVersion)[0] != apiVersionInstalled.match(regexMinorVersion)[0]) {
134
- ConsoleWriter.warning(`installed "powerbi-visuals-api" version - "${apiVersionInstalled}", is not match with the version specified in pbviz.json - "${this.pbiviz.apiVersion}".`);
135
- await this.installAPIpackage();
122
+ else {
123
+ await this.configureAPIVersion();
136
124
  }
137
- // pluginConfiguration.env = await this.getEnvironmentDetails();
138
125
  const api = await WebPackWrap.loadAPIPackage();
139
- pluginConfiguration.apiVersion = api.version;
140
- pluginConfiguration.capabilitiesSchema = api.schemas.capabilities;
141
- pluginConfiguration.pbivizSchema = api.schemas.pbiviz;
142
- pluginConfiguration.stringResourcesSchema = api.schemas.stringResources;
143
- pluginConfiguration.dependenciesSchema = api.schemas.dependencies;
144
- pluginConfiguration.customVisualID = `CustomVisual_${this.pbiviz.visual.guid}`.replace(/[^\w\s]/gi, '');
145
- pluginConfiguration.devMode = (typeof options.devMode === "undefined") ? true : options.devMode;
146
- pluginConfiguration.generatePbiviz = options.generatePbiviz;
147
- pluginConfiguration.generateResources = options.generateResources;
148
- pluginConfiguration.minifyJS = options.minifyJS;
149
126
  const dependenciesPath = this.pbiviz.dependencies && path.join(process.cwd(), this.pbiviz.dependencies);
150
- pluginConfiguration.dependencies = fs.existsSync(dependenciesPath) ? this.pbiviz.dependencies : null;
151
- pluginConfiguration.modules = typeof tsconfig.compilerOptions.outDir !== "undefined";
152
- pluginConfiguration.visualSourceLocation = path.posix.relative(config.build.precompileFolder, tsconfig.files[0]).replace(/(\.ts)x|\.ts/, "");
153
- pluginConfiguration.pluginLocation = path.join(config.build.precompileFolder, "visualPlugin.ts");
154
- pluginConfiguration.compression = options.compression;
127
+ let pluginConfiguration = {
128
+ ...lodashCloneDeep(visualPackage.pbivizConfig),
129
+ apiVersion: api.version,
130
+ capabilitiesSchema: api.schemas.capabilities,
131
+ pbivizSchema: api.schemas.pbiviz,
132
+ stringResourcesSchema: api.schemas.stringResources,
133
+ dependenciesSchema: api.schemas.dependencies,
134
+ customVisualID: `CustomVisual_${this.pbiviz.visual.guid}`.replace(/[^\w\s]/gi, ''),
135
+ devMode: options.devMode,
136
+ generatePbiviz: options.generatePbiviz,
137
+ generateResources: options.generateResources,
138
+ minifyJS: options.minifyJS,
139
+ dependencies: fs.existsSync(dependenciesPath) ? this.pbiviz.dependencies : null,
140
+ modules: typeof tsconfig.compilerOptions.outDir !== "undefined",
141
+ visualSourceLocation: path.posix.relative(config.build.precompileFolder, tsconfig.files[0]).replace(/(\.ts)x|\.ts/, ""),
142
+ pluginLocation: path.join(config.build.precompileFolder, "visualPlugin.ts"),
143
+ compression: options.compression
144
+ };
155
145
  return pluginConfiguration;
156
146
  }
147
+ async configureAPIVersion() {
148
+ //(?<=powerbi-visuals-api@) - positive look-behind to find version installed in visual and get 3 level version.
149
+ const regexFullVersion = /(?<=powerbi-visuals-api@)((?:\d+\.?){1,3})/g;
150
+ //get only first 2 parts of version
151
+ const regexMajorVersion = /\d+(?:\.\d+)?/;
152
+ const listResults = (await exec('npm list powerbi-visuals-api version')).stdout;
153
+ const installedAPIVersion = listResults.match(regexFullVersion)[0] ?? "not found";
154
+ const doesAPIExist = fs.pathExistsSync(path.join(process.cwd(), "node_modules", "powerbi-visuals-api"));
155
+ // if the powerbi-visual-api package wasn't installed install the powerbi-visual-api,
156
+ // with version from apiVersion in pbiviz.json or the latest API, if apiVersion is absent in pbiviz.json
157
+ const isAPIConfigured = doesAPIExist && installedAPIVersion && this.pbiviz.apiVersion;
158
+ if (!isAPIConfigured || this.pbiviz.apiVersion.match(regexMajorVersion)[0] != installedAPIVersion.match(regexMajorVersion)[0]) {
159
+ ConsoleWriter.warning(`installed "powerbi-visuals-api" version - "${installedAPIVersion}", is not match with the version specified in pbviz.json - "${this.pbiviz.apiVersion}".`);
160
+ await this.installAPIpackage();
161
+ }
162
+ }
157
163
  async appendPlugins(options, visualPackage, tsconfig) {
158
164
  const pluginConfiguration = await this.configureCustomVisualsWebpackPlugin(visualPackage, options, tsconfig);
159
165
  let statsFilename = config.build.stats.split("/").pop();
@@ -177,23 +183,27 @@ export default class WebPackWrap {
177
183
  }));
178
184
  }
179
185
  }
180
- async useLoader({ fast = false }) {
181
- let tsOptions = {};
182
- if (fast) {
183
- tsOptions = {
184
- transpileOnly: false,
185
- experimentalWatchApi: false
186
- };
187
- }
186
+ async configureLoaders({ fast = false, includeAllLocales = false }) {
188
187
  this.webpackConfig.module.rules.push({
189
188
  test: /(\.ts)x?$/,
190
189
  use: [
191
190
  {
192
191
  loader: "ts-loader",
193
- options: tsOptions
192
+ options: fast
193
+ ? {
194
+ transpileOnly: false,
195
+ experimentalWatchApi: false
196
+ }
197
+ : {}
194
198
  }
195
199
  ]
196
200
  });
201
+ if (!includeAllLocales) {
202
+ this.webpackConfig.module.rules.push({
203
+ test: /powerbiGlobalizeLocales\.js$/,
204
+ loader: LocalizationLoader
205
+ });
206
+ }
197
207
  }
198
208
  async prepareWebPackConfig(visualPackage, options, tsconfig) {
199
209
  this.webpackConfig = Object.assign({}, await import('./webpack.config.js')).default;
@@ -206,8 +216,9 @@ export default class WebPackWrap {
206
216
  await this.appendPlugins(options, visualPackage, tsconfig);
207
217
  await this.configureDevServer(visualPackage, options.devServerPort);
208
218
  await this.configureVisualPlugin(options, tsconfig, visualPackage);
209
- await this.useLoader({
210
- fast: options.fast
219
+ await this.configureLoaders({
220
+ fast: options.fast,
221
+ includeAllLocales: options.allLocales
211
222
  });
212
223
  return this.webpackConfig;
213
224
  }
@@ -228,7 +239,9 @@ export default class WebPackWrap {
228
239
  devServerPort: 8080,
229
240
  fast: false,
230
241
  compression: 0,
231
- stats: true
242
+ stats: true,
243
+ skipApiCheck: false,
244
+ allLocales: false
232
245
  }) {
233
246
  const tsconfig = readJsonFromVisual('tsconfig.json');
234
247
  this.pbiviz = readJsonFromVisual('pbiviz.json');
@@ -1,5 +1,4 @@
1
1
  import { getRootPath, readJsonFromRoot } from './utils.js';
2
- import { LocalizationLoader } from "powerbi-visuals-webpack-plugin";
3
2
  import MiniCssExtractPlugin from "mini-css-extract-plugin";
4
3
  import TerserPlugin from "terser-webpack-plugin";
5
4
  import path from "path";
@@ -62,10 +61,6 @@ const webpackConfig = {
62
61
  {
63
62
  test: /\.(woff|ttf|ico|woff2|jpg|jpeg|png|webp|gif|svg|eot)$/i,
64
63
  type: 'asset/inline'
65
- },
66
- {
67
- test: /powerbiGlobalizeLocales\.js$/,
68
- loader: LocalizationLoader
69
64
  }
70
65
  ]
71
66
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powerbi-visuals-tools",
3
- "version": "5.0.3",
3
+ "version": "5.1.0",
4
4
  "description": "Command line tool for creating and publishing visuals for Power BI",
5
5
  "main": "./bin/pbiviz.js",
6
6
  "type": "module",
@@ -36,7 +36,7 @@
36
36
  "buffer": "^6.0.3",
37
37
  "chalk": "^5.3.0",
38
38
  "commander": "^11.0.0",
39
- "compare-versions": "^6.0.0",
39
+ "compare-versions": "^6.1.0",
40
40
  "console-browserify": "^1.2.0",
41
41
  "constants-browserify": "^1.0.0",
42
42
  "crypto-browserify": "^3.12.0",
@@ -49,7 +49,7 @@
49
49
  "inline-source-map": "^0.6.2",
50
50
  "json-loader": "0.5.7",
51
51
  "jszip": "^3.10.1",
52
- "less": "^4.1.3",
52
+ "less": "^4.2.0",
53
53
  "less-loader": "^11.1.3",
54
54
  "lodash.clonedeep": "4.5.0",
55
55
  "lodash.defaults": "4.2.0",
@@ -79,9 +79,9 @@
79
79
  },
80
80
  "devDependencies": {
81
81
  "@typescript-eslint/eslint-plugin": "^5.62.0",
82
- "eslint": "^8.45.0",
82
+ "eslint": "^8.47.0",
83
83
  "eslint-plugin-powerbi-visuals": "^0.8.1",
84
- "jasmine": "5.0.2",
84
+ "jasmine": "5.1.0",
85
85
  "jasmine-spec-reporter": "7.0.0",
86
86
  "semver": "7.5.4",
87
87
  "tree-kill": "1.2.2",