powerbi-visuals-tools 5.0.3 → 5.1.1

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
@@ -1,6 +1,15 @@
1
1
  # Change Log - PowerBI Visual Tools (pbiviz)
2
2
 
3
3
  This page contains information about changes to the PowerBI Visual Tools (pbiviz).
4
+ ## 5.1.1
5
+ * Updated crypto import to fix error in old Node versions
6
+
7
+ ## 5.1.0
8
+ * 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).
9
+ * 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.
10
+
11
+ ## 5.0.3
12
+ * Now option `--install-cert` is command. The new usage is `pbiviz install-cert` **⚠**
4
13
 
5
14
  ## 5.0.3
6
15
  * Now option `--install-cert` is command. New usage is `pbiviz install-cert`
@@ -20,6 +29,7 @@ This page contains information about changes to the PowerBI Visual Tools (pbiviz
20
29
  * Migrated to NodeJS 18.0 **⚠**
21
30
 
22
31
  ## 4.3.2
32
+ * `options` in `Visual.constructor()` is optional. It's made to match PowerBI interface and to support strict mode
23
33
  * LocalizationLoader has been moved to `powerbi-visuals-webpack-plugin`
24
34
 
25
35
  ## 4.3.1
@@ -36,8 +46,13 @@ This page contains information about changes to the PowerBI Visual Tools (pbiviz
36
46
  * Fixed vulnerabilities
37
47
  * Updated `powerbi-visuals-webpack-plugin` to 3.2.0
38
48
 
49
+
50
+ ### **⚠ BREAKING CHANGES**
39
51
  ## 4.1.0
40
- * Added loader to reduce localizations size. REQUIRES `powerbi-visuals-utils-formattingutils` version 5.1 and higher
52
+ * Added loader to reduce localizations size. REQUIRES `powerbi-visuals-utils-formattingutils` version 5.1 and higher.
53
+
54
+ Now loader deletes all unused in stringResources folder locales.
55
+
41
56
  * Fixed vulnerabilities
42
57
 
43
58
  ## 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
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Vnib4wwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAFif8
13
+ hxys2YLTIh9YkwEZNrF0Gj8PavHUltNTXThSrvUdIatWDVAdI+FYj+NfmEpsAdaj
14
+ Sk3dXzgO8S5b3X8LLwE7OqbzlpYFbSrbbOxRmL+LpoqaMyVUWsmdeAasPsT4xqRE
15
+ 7c49MFFWEXdrdIAsLDk0dUNsi5v5HWqrN5uu5WwFOm9zFDe0EntWEaiTy4RYoSkA
16
+ W3xPgXwYb896O9rSpRNul1Qim9vNJJc/kAqIDcsYh+Ufj57tY/GjFqnZ3ZtYoDH5
17
+ ho2J7Oj6D637MRsCo8fEnkB162C3JcuJ5ZYFifGGb/Xr7Xemz/9XcLs9rQbIKx4i
18
+ n/XSrKnsAoDcu0+VQA==
19
19
  -----END CERTIFICATE-----
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-case-declarations */
1
2
  /*
2
3
  * Power BI Visual CLI
3
4
  *
@@ -114,11 +115,8 @@ export async function createCertFile(config, open) {
114
115
  }
115
116
  break;
116
117
  case "win32":
117
- // eslint-disable-next-line no-case-declarations
118
- let passphrase = "";
119
118
  // for windows 7 and others
120
119
  // 6.1 - Windows 7
121
- // eslint-disable-next-line no-case-declarations
122
120
  const osVersion = os.release().split(".");
123
121
  if ((Number(osVersion[0]) === 6 && Number(osVersion[1]) === 1) || Number(osVersion[0]) < 6) {
124
122
  await removeCertFiles(certPath, keyPath, pfxPath);
@@ -140,7 +138,14 @@ export async function createCertFile(config, open) {
140
138
  }
141
139
  break;
142
140
  }
143
- passphrase = crypto.getRandomValues(new Uint32Array(1))[0].toString().substring(2);
141
+ let randomValues;
142
+ if (crypto.getRandomValues !== undefined) {
143
+ randomValues = crypto.getRandomValues(new Uint32Array(1));
144
+ }
145
+ else {
146
+ randomValues = crypto.webcrypto.getRandomValues(new Uint32Array(1));
147
+ }
148
+ const passphrase = randomValues[0].toString().substring(2);
144
149
  config.server.passphrase = passphrase;
145
150
  fs.writeFileSync(path.join(rootPath, confPath), JSON.stringify(config));
146
151
  // 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.1",
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",