powerbi-visuals-tools 5.0.2 → 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 +18 -1
- package/bin/pbiviz.js +18 -9
- package/certs/PowerBICustomVisualTest_private.key +26 -26
- package/certs/PowerBICustomVisualTest_public.crt +17 -17
- package/lib/CertificateTools.js +4 -4
- package/lib/CommandManager.js +10 -2
- package/lib/VisualManager.js +2 -1
- package/lib/WebPackWrap.js +64 -51
- package/lib/webpack.config.js +0 -5
- package/package.json +5 -5
package/Changelog.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
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
|
+
|
|
12
|
+
## 5.0.3
|
|
13
|
+
* Now option `--install-cert` is command. New usage is `pbiviz install-cert`
|
|
14
|
+
* Fixed bug with the incorrect detection of the installed API version
|
|
15
|
+
|
|
5
16
|
## 5.0.2
|
|
6
17
|
* Implemented common solution for webpack loaders on different environments
|
|
7
18
|
|
|
@@ -16,6 +27,7 @@ This page contains information about changes to the PowerBI Visual Tools (pbiviz
|
|
|
16
27
|
* Migrated to NodeJS 18.0 **⚠**
|
|
17
28
|
|
|
18
29
|
## 4.3.2
|
|
30
|
+
* `options` in `Visual.constructor()` is optional. It's made to match PowerBI interface and to support strict mode
|
|
19
31
|
* LocalizationLoader has been moved to `powerbi-visuals-webpack-plugin`
|
|
20
32
|
|
|
21
33
|
## 4.3.1
|
|
@@ -32,8 +44,13 @@ This page contains information about changes to the PowerBI Visual Tools (pbiviz
|
|
|
32
44
|
* Fixed vulnerabilities
|
|
33
45
|
* Updated `powerbi-visuals-webpack-plugin` to 3.2.0
|
|
34
46
|
|
|
47
|
+
|
|
48
|
+
### **⚠ BREAKING CHANGES**
|
|
35
49
|
## 4.1.0
|
|
36
|
-
* 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
|
+
|
|
37
54
|
* Fixed vulnerabilities
|
|
38
55
|
|
|
39
56
|
## 4.0.9
|
package/bin/pbiviz.js
CHANGED
|
@@ -27,19 +27,16 @@
|
|
|
27
27
|
|
|
28
28
|
"use strict";
|
|
29
29
|
|
|
30
|
-
import { createCertificate } from "../lib/CertificateTools.js";
|
|
31
30
|
import ConsoleWriter from '../lib/ConsoleWriter.js';
|
|
32
31
|
import CommandManager from '../lib/CommandManager.js';
|
|
33
32
|
import { readJsonFromRoot } from '../lib/utils.js';
|
|
34
|
-
import {
|
|
33
|
+
import { program, Option } from 'commander';
|
|
35
34
|
|
|
36
35
|
const npmPackage = readJsonFromRoot('package.json');
|
|
37
36
|
const rootPath = process.cwd();
|
|
38
|
-
const program = new Command();
|
|
39
37
|
|
|
40
38
|
const pbiviz = program
|
|
41
39
|
.version(npmPackage.version)
|
|
42
|
-
.option('--install-cert', 'Creates and installs localhost certificate', createCertificate)
|
|
43
40
|
.showHelpAfterError('Run "pbiviz help" for usage instructions.')
|
|
44
41
|
.addHelpText('beforeAll', ConsoleWriter.info(`${npmPackage.name} version - ${npmPackage.version}`))
|
|
45
42
|
.addHelpText('before', ConsoleWriter.getLogoVisualization());
|
|
@@ -47,9 +44,9 @@ const pbiviz = program
|
|
|
47
44
|
pbiviz
|
|
48
45
|
.command('new')
|
|
49
46
|
.usage("<argument> [options]")
|
|
50
|
-
.argument('<name>', '
|
|
51
|
-
.option('-f, --force', '
|
|
52
|
-
.addOption(new Option('-t, --template [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')
|
|
53
50
|
.choices(['default', 'table', 'slicer', 'rvisual', 'rhtml', 'circlecard'])
|
|
54
51
|
.default('default')
|
|
55
52
|
)
|
|
@@ -59,16 +56,26 @@ pbiviz
|
|
|
59
56
|
|
|
60
57
|
pbiviz
|
|
61
58
|
.command('info')
|
|
59
|
+
.description('Displays visual info')
|
|
62
60
|
.action(() => {
|
|
63
61
|
CommandManager.info(rootPath);
|
|
64
62
|
});
|
|
63
|
+
|
|
64
|
+
pbiviz
|
|
65
|
+
.command('install-cert')
|
|
66
|
+
.description('Creates and installs localhost certificate')
|
|
67
|
+
.action(() => {
|
|
68
|
+
CommandManager.installCert();
|
|
69
|
+
});
|
|
65
70
|
|
|
66
71
|
pbiviz
|
|
67
72
|
.command('start')
|
|
68
73
|
.usage('[options]')
|
|
69
|
-
.option('-p, --port [port]', '
|
|
70
|
-
.option('-d, --drop', '
|
|
74
|
+
.option('-p, --port [port]', 'Set the port listening on')
|
|
75
|
+
.option('-d, --drop', 'Drop outputs into output folder')
|
|
71
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.")
|
|
72
79
|
.action(async (options) => {
|
|
73
80
|
CommandManager.start(options, rootPath);
|
|
74
81
|
});
|
|
@@ -80,6 +87,8 @@ pbiviz
|
|
|
80
87
|
.option('--no-pbiviz', "Doesn't produce a pbiviz file (must be used in conjunction with resources flag)")
|
|
81
88
|
.option('--no-minify', "Doesn't minify the js in the package (useful for debugging)")
|
|
82
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.")
|
|
83
92
|
.addOption(new Option('-c, --compression <compressionLevel>', "Enables compression of visual package")
|
|
84
93
|
.choices(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'])
|
|
85
94
|
.default('6')
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
-----BEGIN PRIVATE KEY-----
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
+
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
2
|
+
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDEKuHsNka9n8H9
|
|
3
|
+
28W1ARv0lBkZYfQMxNK7IOSWopNp+l2w13ns3/Uz6IMB7iRqSCR8i8p0vQHatZP+
|
|
4
|
+
0o8QY2NkMgaRiXlSH48GxmaRfhdTaPv0r2WTB7jibl3c5xEunjL3cvO2F8qVh+8S
|
|
5
|
+
SybpY2v4RCqHCAg2o2ZyAkXJk+Rkh/TIOcmQzbQk8SLkuFIPBAXObS8SxZ03/VXJ
|
|
6
|
+
x+5iYYqC28TJAkHh8ZSknpkIRCDfV5RzRkwWXvP70aY0Mm1T7rETBh9yDlThZbg5
|
|
7
|
+
9WWYcyqZUn0PgNmM/VWw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mkX4XU2j7
|
|
7
|
+
9K9lkwe44m5d3OcRLp4y93LzthfKlYfvEksm6WNr+EQqhwgINqNmcgJFyZPkZIf0
|
|
8
|
+
yDnJkM20JPEi5LhSDwQFzm0vEsWdN/1VycfuYmGKgtvEyQJB4fGUpJ6ZCEQg31eU
|
|
9
|
+
c0ZMFl7z+9GmNDJtU+6xEwYfcg5U4WW4OfVlmHMqmVJ9D4DZjP1VsAGFg9ev1/N9
|
|
10
|
+
gRWBTGxawDb/AhXIbWefGi3AHfYV2q6VU9lMRUKTjwIDAQABo1MwUTAdBgNVHQ4E
|
|
11
|
+
FgQU3LMs3hmPwHpL5sqTzN2RWogd2/kwHwYDVR0jBBgwFoAU3LMs3hmPwHpL5sqT
|
|
12
|
+
zN2RWogd2/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-----
|
package/lib/CertificateTools.js
CHANGED
|
@@ -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 /
|
|
@@ -221,7 +221,7 @@ async function getCertFile(config, silent) {
|
|
|
221
221
|
return pfx;
|
|
222
222
|
}
|
|
223
223
|
if (!silent) {
|
|
224
|
-
ConsoleWriter.info('Certificate not found. Call `pbiviz
|
|
224
|
+
ConsoleWriter.info('Certificate not found. Call `pbiviz install-cert` command to create the new certificate');
|
|
225
225
|
}
|
|
226
226
|
return null;
|
|
227
227
|
}
|
|
@@ -323,7 +323,7 @@ export async function resolveCertificate() {
|
|
|
323
323
|
await createCertFile(config, true);
|
|
324
324
|
if (!(await getCertFile(config, true))) {
|
|
325
325
|
ConsoleWriter.error('Certificate wasn\'t created');
|
|
326
|
-
throw new Error("Call `pbiviz
|
|
326
|
+
throw new Error("Call `pbiviz install-cert` command to create the new certificate");
|
|
327
327
|
}
|
|
328
328
|
else {
|
|
329
329
|
if (config.server.passphrase) {
|
package/lib/CommandManager.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createCertificate } from './CertificateTools.js';
|
|
1
2
|
import ConsoleWriter from './ConsoleWriter.js';
|
|
2
3
|
import VisualManager from './VisualManager.js';
|
|
3
4
|
export default class CommandManager {
|
|
@@ -10,7 +11,9 @@ export default class CommandManager {
|
|
|
10
11
|
minifyJS: false,
|
|
11
12
|
minify: false,
|
|
12
13
|
devServerPort: options.port,
|
|
13
|
-
stats: options.stats
|
|
14
|
+
stats: options.stats,
|
|
15
|
+
skipApiCheck: options.skipApi,
|
|
16
|
+
allLocales: options.allLocales
|
|
14
17
|
};
|
|
15
18
|
const visualManager = new VisualManager(rootPath);
|
|
16
19
|
await visualManager
|
|
@@ -30,7 +33,9 @@ export default class CommandManager {
|
|
|
30
33
|
minifyJS: options.minify,
|
|
31
34
|
minify: options.minify,
|
|
32
35
|
compression: options.compression,
|
|
33
|
-
stats: options.stats
|
|
36
|
+
stats: options.stats,
|
|
37
|
+
skipApiCheck: options.skipApi,
|
|
38
|
+
allLocales: options.allLocales
|
|
34
39
|
};
|
|
35
40
|
new VisualManager(rootPath)
|
|
36
41
|
.prepareVisual()
|
|
@@ -49,4 +54,7 @@ export default class CommandManager {
|
|
|
49
54
|
.prepareVisual()
|
|
50
55
|
.displayInfo();
|
|
51
56
|
}
|
|
57
|
+
static async installCert() {
|
|
58
|
+
await createCertificate();
|
|
59
|
+
}
|
|
52
60
|
}
|
package/lib/VisualManager.js
CHANGED
|
@@ -52,7 +52,8 @@ export default class VisualManager {
|
|
|
52
52
|
this.pbivizConfig = readJsonFromVisual(PBIVIZ_FILE, this.basePath);
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
|
-
|
|
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
|
}
|
package/lib/WebPackWrap.js
CHANGED
|
@@ -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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
const regexFullVersion = /(?:\d+\.?){1,3}(?=\D*$)/;
|
|
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];
|
|
119
|
+
if (options.skipApiCheck) {
|
|
120
|
+
ConsoleWriter.warning(`Skipping API check. Tools started with --skipApi flag.`);
|
|
126
121
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
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
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
|
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:
|
|
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.
|
|
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');
|
package/lib/webpack.config.js
CHANGED
|
@@ -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
|
+
"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.
|
|
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.
|
|
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.
|
|
82
|
+
"eslint": "^8.47.0",
|
|
83
83
|
"eslint-plugin-powerbi-visuals": "^0.8.1",
|
|
84
|
-
"jasmine": "5.0
|
|
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",
|