powerbi-visuals-tools 4.3.3 → 5.0.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.
Files changed (69) hide show
  1. package/Changelog.md +7 -0
  2. package/README.md +1 -1
  3. package/bin/pbiviz.js +55 -36
  4. package/certs/PowerBICustomVisualTest_private.key +26 -26
  5. package/certs/PowerBICustomVisualTest_public.crt +17 -17
  6. package/config.json +27 -34
  7. package/lib/CertificateTools.js +119 -143
  8. package/lib/CommandManager.js +52 -0
  9. package/lib/ConsoleWriter.js +63 -85
  10. package/lib/TemplateFetcher.js +23 -30
  11. package/lib/VisualGenerator.js +42 -56
  12. package/lib/VisualManager.js +193 -0
  13. package/lib/WebPackWrap.js +96 -145
  14. package/lib/utils.js +21 -13
  15. package/lib/webpack.config.js +47 -56
  16. package/package.json +20 -12
  17. package/spec/clean-tests.js +1 -1
  18. package/spec/e2e/pbivizCertSpec.js +14 -13
  19. package/spec/e2e/pbivizInfoSpec.js +7 -10
  20. package/spec/e2e/pbivizNewSpec.js +53 -65
  21. package/spec/e2e/pbivizPackageSpec.js +86 -90
  22. package/spec/e2e/pbivizStartSpec.js +6 -7
  23. package/spec/e2e/pbivizWebpackVerSpec.js +14 -16
  24. package/spec/e2e/{utils.js → testUtils.js} +9 -12
  25. package/spec/helpers/FileSystem.js +18 -18
  26. package/spec/jasmine-runner.js +5 -5
  27. package/src/CertificateTools.ts +431 -0
  28. package/src/CommandManager.ts +78 -0
  29. package/src/ConsoleWriter.ts +206 -0
  30. package/src/TemplateFetcher.ts +122 -0
  31. package/src/VisualGenerator.ts +236 -0
  32. package/src/VisualManager.ts +220 -0
  33. package/src/WebPackWrap.ts +299 -0
  34. package/src/utils.ts +41 -0
  35. package/src/webpack.config.ts +144 -0
  36. package/templates/pbiviz-json-template.js +2 -2
  37. package/templates/pbiviz.json.template +1 -1
  38. package/templates/plugin-ts-template.js +1 -1
  39. package/templates/visuals/default/.eslintignore +5 -0
  40. package/templates/visuals/default/.eslintrc.js +20 -0
  41. package/templates/visuals/default/package.json +9 -8
  42. package/templates/visuals/default/pbiviz.json +3 -2
  43. package/templates/visuals/default/tsconfig.json +2 -2
  44. package/templates/visuals/rhtml/.eslintignore +5 -0
  45. package/templates/visuals/rhtml/.eslintrc.js +20 -0
  46. package/templates/visuals/rhtml/package.json +7 -6
  47. package/templates/visuals/rhtml/pbiviz.json +2 -1
  48. package/templates/visuals/rvisual/.eslintignore +5 -0
  49. package/templates/visuals/rvisual/.eslintrc.js +20 -0
  50. package/templates/visuals/rvisual/package.json +5 -4
  51. package/templates/visuals/slicer/.eslintignore +5 -0
  52. package/templates/visuals/slicer/.eslintrc.js +20 -0
  53. package/templates/visuals/slicer/package.json +8 -7
  54. package/templates/visuals/table/.eslintignore +5 -0
  55. package/templates/visuals/table/.eslintrc.js +20 -0
  56. package/templates/visuals/table/package.json +8 -7
  57. package/templates/visuals/table/tsconfig.json +4 -0
  58. package/tsconfig.json +22 -0
  59. package/bin/pbiviz-info.js +0 -54
  60. package/bin/pbiviz-new.js +0 -82
  61. package/bin/pbiviz-package.js +0 -122
  62. package/bin/pbiviz-start.js +0 -142
  63. package/lib/CommandHelpManager.js +0 -51
  64. package/lib/VisualPackage.js +0 -118
  65. package/templates/visuals/default/tslint.json +0 -9
  66. package/templates/visuals/rhtml/tslint.json +0 -9
  67. package/templates/visuals/rvisual/tslint.json +0 -9
  68. package/templates/visuals/slicer/tslint.json +0 -9
  69. package/templates/visuals/table/tslint.json +0 -9
@@ -0,0 +1,431 @@
1
+ /*
2
+ * Power BI Visual CLI
3
+ *
4
+ * Copyright (c) Microsoft Corporation
5
+ * All rights reserved.
6
+ * MIT License
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the ""Software""), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in
16
+ * all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ * THE SOFTWARE.
25
+ */
26
+
27
+ "use strict";
28
+
29
+ import { exec as nodeExec } from 'child_process';
30
+ import fs from 'fs-extra';
31
+ import os from 'os';
32
+ import path from 'path';
33
+ import crypto from "crypto"
34
+ import { getRootPath, readJsonFromRoot } from './utils.js';
35
+ import ConsoleWriter from './ConsoleWriter.js';
36
+
37
+ const certSafePeriod = 1000 * 60 * 60 * 24; // 24 hours
38
+ const rootPath = getRootPath();
39
+ const confPath = '/config.json';
40
+
41
+ interface CertificateOptions {
42
+ passphrase?: string;
43
+ cert?: string;
44
+ key?: string;
45
+ pfx?: string;
46
+ certificate?: string;
47
+ privateKey?: string;
48
+ }
49
+
50
+ function exec(command, callback?): Promise<string> {
51
+ return new Promise((resolve, reject) => {
52
+ nodeExec(command, callback ? callback : (err, stdout: string, stderr) => {
53
+ if (err) {
54
+ reject(stderr);
55
+ }
56
+ resolve(stdout);
57
+ });
58
+ });
59
+
60
+ }
61
+
62
+ export async function createCertificate() {
63
+ const config = readJsonFromRoot('config.json');
64
+ const certPath = await getCertFile(config, true);
65
+
66
+ if (!certPath) {
67
+ ConsoleWriter.error("Certificate not found. The new certificate will be generated");
68
+ await createCertFile(config, true);
69
+ } else {
70
+ await openCertFile(config);
71
+ }
72
+ }
73
+
74
+ export async function createCertFile(config, open) {
75
+ ConsoleWriter.info(`Generating a new certificate...`);
76
+ const subject = "localhost";
77
+ const keyLength = 2048;
78
+ const algorithm = "sha256";
79
+ const validPeriod = 365;
80
+
81
+ if (typeof open === 'undefined') {
82
+ open = false;
83
+ }
84
+
85
+ const certPath = path.join(rootPath, config.server.certificate);
86
+ const keyPath = path.join(rootPath, config.server.privateKey);
87
+ const pfxPath = path.join(rootPath, config.server.pfx);
88
+
89
+ const openCmds = {
90
+ linux: 'openssl',
91
+ darwin: 'openssl',
92
+ win32: 'powershell'
93
+ };
94
+ let startCmd = openCmds[os.platform()];
95
+
96
+ if (startCmd) {
97
+ try {
98
+ let createCertCommand = "";
99
+ switch (os.platform()) {
100
+ case "linux":
101
+ await removeCertFiles(certPath, keyPath);
102
+ createCertCommand =
103
+ ` req -newkey rsa:${keyLength}` +
104
+ ` -nodes` +
105
+ ` -keyout ${keyPath}` +
106
+ ` -x509 ` +
107
+ ` -days ${validPeriod} ` +
108
+ ` -out ${certPath} ` +
109
+ ` -subj "/CN=${subject}"`;
110
+ await exec(`${startCmd} ${createCertCommand}`);
111
+ if (await fs.exists(certPath)) {
112
+ ConsoleWriter.info(`Certificate generated. Location is ${certPath}`);
113
+ if (open) {
114
+ await openCertFile(config);
115
+ }
116
+ }
117
+ break;
118
+ case "darwin":
119
+ await removeCertFiles(certPath, keyPath);
120
+ createCertCommand =
121
+ ` req -newkey rsa:${keyLength}` +
122
+ ` -nodes` +
123
+ ` -keyout ${keyPath}` +
124
+ ` -x509 ` +
125
+ ` -days ${validPeriod} ` +
126
+ ` -out ${certPath} ` +
127
+ ` -subj "/CN=${subject}"`;
128
+ await exec(`${startCmd} ${createCertCommand}`);
129
+ if (await fs.exists(certPath)) {
130
+ ConsoleWriter.info(`Certificate generated. Location is ${certPath}`);
131
+ if (open) {
132
+ await openCertFile(config);
133
+ }
134
+ }
135
+ break;
136
+ case "win32":
137
+ // eslint-disable-next-line no-case-declarations
138
+ let passphrase = "";
139
+ // for windows 7 and others
140
+ // 6.1 - Windows 7
141
+ // eslint-disable-next-line no-case-declarations
142
+ const osVersion = os.release().split(".");
143
+ if ((Number(osVersion[0]) === 6 && Number(osVersion[1]) === 1) || Number(osVersion[0]) < 6) {
144
+ await removeCertFiles(certPath, keyPath, pfxPath);
145
+ startCmd = "openssl";
146
+ createCertCommand =
147
+ ` req -newkey rsa:${keyLength}` +
148
+ ` -nodes` +
149
+ ` -keyout ${keyPath}` +
150
+ ` -x509 ` +
151
+ ` -days ${validPeriod} ` +
152
+ ` -out ${certPath} ` +
153
+ ` -subj "/CN=${subject}"`;
154
+ await exec(`${startCmd} ${createCertCommand}`);
155
+ if (await fs.exists(certPath)) {
156
+ ConsoleWriter.info(`Certificate generated. Location is ${certPath}`);
157
+ if (open) {
158
+ await openCertFile(config);
159
+ }
160
+ }
161
+ break;
162
+ }
163
+ passphrase = crypto.getRandomValues(new Uint32Array(1))[0].toString().substring(2);
164
+ config.server.passphrase = passphrase;
165
+ fs.writeFileSync(path.join(rootPath, confPath), JSON.stringify(config));
166
+ // for windows 8 / 8.1 / server 2012 R2 /
167
+ if (Number(osVersion[0]) === 6 && (Number(osVersion[1]) === 2 || Number(osVersion[1]) === 3)) {
168
+ // for 10
169
+ createCertCommand = `$cert = ('Cert:\\CurrentUser\\My\\' + (` +
170
+ ` New-SelfSignedCertificate ` +
171
+ ` -DnsName localhost ` +
172
+ ` -CertStoreLocation Cert:\\CurrentUser\\My ` +
173
+ ` | select Thumbprint | ` +
174
+ ` ForEach-Object { $_.Thumbprint.ToString() }).toString()); ` +
175
+ ` Export-PfxCertificate -Cert $cert` +
176
+ ` -FilePath '${pfxPath}' ` +
177
+ ` -Password (ConvertTo-SecureString -String '${passphrase}' -Force -AsPlainText)`;
178
+
179
+ await exec(`${startCmd} "${createCertCommand}"`);
180
+ } else {
181
+ // for window 10 / server 2016
182
+ createCertCommand = `$cert = ('Cert:\\CurrentUser\\My\\' + (` +
183
+ ` New-SelfSignedCertificate ` +
184
+ ` -DnsName localhost ` +
185
+ ` -HashAlgorithm ${algorithm} ` +
186
+ ` -Type Custom ` +
187
+ ` -Subject ${subject} ` +
188
+ ` -KeyAlgorithm RSA ` +
189
+ ` -KeyLength ${keyLength} ` +
190
+ ` -KeyExportPolicy Exportable ` +
191
+ ` -CertStoreLocation Cert:\\CurrentUser\\My ` +
192
+ ` -NotAfter (get-date).AddDays(${validPeriod}) ` +
193
+ ` | select Thumbprint | ` +
194
+ ` ForEach-Object { $_.Thumbprint.ToString() }).toString()); ` +
195
+ ` Export-PfxCertificate -Cert $cert` +
196
+ ` -FilePath '${pfxPath}' ` +
197
+ ` -Password (ConvertTo-SecureString -String '${passphrase}' -Force -AsPlainText)`;
198
+
199
+ await exec(`${startCmd} "${createCertCommand}"`);
200
+ }
201
+ if (await fs.exists(pfxPath)) {
202
+ ConsoleWriter.info(`Certificate generated. Location is ${pfxPath}. Passphrase is '${passphrase}'`);
203
+ }
204
+ break;
205
+ default:
206
+ ConsoleWriter.error('Unknown platform');
207
+ }
208
+ } catch (e) {
209
+ if (e && e.message && e.message.indexOf("'openssl' is not recognized as an internal or external command") > 0) {
210
+ ConsoleWriter.warning('Create certificate error:');
211
+ ConsoleWriter.warning('OpenSSL is not installed or not available from command line');
212
+ ConsoleWriter.info('Install OpenSSL from https://www.openssl.org or https://wiki.openssl.org/index.php/Binaries');
213
+ ConsoleWriter.info('and try again');
214
+
215
+ ConsoleWriter.info('Read more at');
216
+ ConsoleWriter.info('https://github.com/Microsoft/PowerBI-visuals/blob/master/tools/CreateCertificate.md#manual');
217
+ } else {
218
+ ConsoleWriter.error(['Create certificate error:', e]);
219
+ }
220
+ }
221
+ } else {
222
+ ConsoleWriter.error(['Unknown platform. Please place a custom-generated certificate in:', certPath]);
223
+ }
224
+ }
225
+
226
+ async function getCertFile(config, silent?) {
227
+ if (typeof silent === "undefined") {
228
+ silent = false;
229
+ }
230
+ const cert = path.join(rootPath, config.server.certificate);
231
+ const pfx = path.join(rootPath, config.server.pfx);
232
+
233
+ if (await fs.exists(cert)) {
234
+ return cert;
235
+ }
236
+ if (await fs.exists(pfx)) {
237
+ if (config.server.passphrase) {
238
+ if (!silent) {
239
+ ConsoleWriter.info(`Use '${config.server.passphrase}' passphrase to install PFX certificate.`);
240
+ }
241
+ }
242
+ return pfx;
243
+ }
244
+
245
+ if (!silent) {
246
+ ConsoleWriter.info('Certificate not found. Call `pbiviz --install-cert` command to create the new certificate');
247
+ }
248
+ return null;
249
+ }
250
+
251
+ async function openCertFile(config) {
252
+ const certPath = await getCertFile(config);
253
+
254
+ if (!certPath) {
255
+ return null;
256
+ }
257
+
258
+ const openCmds = {
259
+ linux: 'xdg-open',
260
+ darwin: 'open',
261
+ win32: 'powershell start'
262
+ };
263
+ const startCmd = openCmds[os.platform()];
264
+ if (startCmd) {
265
+ try {
266
+ await exec(`${startCmd} "${certPath}"`);
267
+ } catch (e) {
268
+ ConsoleWriter.info(['Certificate path:', certPath]);
269
+ }
270
+ } else {
271
+ ConsoleWriter.info(['Certificate path:', certPath]);
272
+ }
273
+ }
274
+
275
+ export async function removeCertFiles(certPath, keyPath, pfxPath?) {
276
+ try {
277
+ await fs.unlink(certPath);
278
+ } catch (e) {
279
+ if (!e.message.indexOf("no such file or directory")) {
280
+ throw e;
281
+ }
282
+ }
283
+ try {
284
+ await fs.unlink(keyPath);
285
+ } catch (e) {
286
+ if (!e.message.indexOf("no such file or directory")) {
287
+ throw e;
288
+ }
289
+ }
290
+ try {
291
+ await fs.unlink(pfxPath);
292
+ } catch (e) {
293
+ if (!e.message.indexOf("no such file or directory")) {
294
+ throw e;
295
+ }
296
+ }
297
+ }
298
+
299
+ async function getGlobalPbivizCerts(config) {
300
+ const options: CertificateOptions = {};
301
+ try {
302
+ const location = (await exec('npm ls -g powerbi-visuals-tools')).split("\n")[0];
303
+ const certPath = path.join(location, "node_modules", "powerbi-visuals-tools", config.server.certificate);
304
+ const keyPath = path.join(location, "node_modules", "powerbi-visuals-tools", config.server.privateKey);
305
+ const pfxPath = path.join(location, "node_modules", "powerbi-visuals-tools", config.server.pfx);
306
+ const globalPbivizConfig = path.join(location, "node_modules", "powerbi-visuals-tools", "config.json");
307
+ options.passphrase = fs.existsSync(globalPbivizConfig) && fs.readJSONSync(globalPbivizConfig).server.passphrase;
308
+
309
+ const CertFileVerified = await verifyCertFile(keyPath, certPath, pfxPath, options.passphrase);
310
+
311
+ options.cert = fs.existsSync(certPath) && certPath;
312
+ options.key = fs.existsSync(keyPath) && keyPath;
313
+ options.pfx = fs.existsSync(pfxPath) && CertFileVerified && pfxPath;
314
+ }
315
+ catch (err) {
316
+ ConsoleWriter.warning(`Global certificate error: ${err}`);
317
+ }
318
+ if (!options.cert && !options.pfx) {
319
+ ConsoleWriter.warning(`Global instance of valid pbiviz certificate not found.`);
320
+ }
321
+ return options;
322
+ }
323
+
324
+ export async function resolveCertificate() {
325
+ const config = readJsonFromRoot('config.json');
326
+ const options: CertificateOptions = {};
327
+ const keyPath = path.join(rootPath, config.server.privateKey);
328
+ const certPath = path.join(rootPath, config.server.certificate);
329
+ const pfxPath = path.join(rootPath, config.server.pfx);
330
+
331
+ if (config.server.passphrase) {
332
+ options.passphrase = config.server.passphrase;
333
+ }
334
+ if (await fs.exists(keyPath)) {
335
+ options.key = await fs.readFile(keyPath);
336
+ }
337
+ if (await fs.exists(certPath)) {
338
+ options.cert = await fs.readFile(certPath);
339
+ }
340
+ if (await fs.exists(pfxPath)) {
341
+ options.pfx = await fs.readFile(pfxPath);
342
+ }
343
+
344
+ const CertFileVerified = await verifyCertFile(keyPath, certPath, pfxPath, options.passphrase);
345
+
346
+ if ((!options.cert && !options.pfx) || !CertFileVerified) {
347
+ ConsoleWriter.warning("Local valid certificate not found.");
348
+ ConsoleWriter.info("Checking global instance of pbiviz certificate...");
349
+ const globalPbivizOptions = await getGlobalPbivizCerts(config);
350
+
351
+ if (!globalPbivizOptions.cert && !globalPbivizOptions.pfx) {
352
+ await createCertFile(config, true);
353
+ if (!(await getCertFile(config, true))) {
354
+ ConsoleWriter.error('Certificate wasn\'t created');
355
+ throw new Error("Call `pbiviz --install-cert` command to create the new certificate");
356
+ }
357
+ else {
358
+ if (config.server.passphrase) {
359
+ options.passphrase = config.server.passphrase;
360
+ }
361
+ if (await fs.exists(keyPath)) {
362
+ options.key = await fs.readFile(keyPath);
363
+ }
364
+ if (await fs.exists(certPath)) {
365
+ options.cert = await fs.readFile(certPath);
366
+ }
367
+ if (await fs.exists(pfxPath)) {
368
+ options.pfx = await fs.readFile(pfxPath);
369
+ }
370
+ }
371
+ }
372
+ else {
373
+ // copy certs to local instance
374
+ ConsoleWriter.info("Copy server certificate from global instance of pbiviz...");
375
+ if (globalPbivizOptions.cert) {
376
+ await fs.copyFile(globalPbivizOptions.cert, path.join(rootPath, config.server.certificate));
377
+ options.certificate = config.server.certificate;
378
+ }
379
+ if (globalPbivizOptions.key) {
380
+ await fs.copyFile(globalPbivizOptions.key, path.join(rootPath, config.server.privateKey));
381
+ options.privateKey = config.server.privateKey;
382
+ }
383
+ if (globalPbivizOptions.pfx) {
384
+ await fs.copyFile(globalPbivizOptions.pfx, path.join(rootPath, config.server.pfx));
385
+ // need to pass whole file instead path to file
386
+ options.pfx = await fs.readFile(path.join(rootPath, config.server.pfx));
387
+ options.passphrase = globalPbivizOptions.passphrase;
388
+ // eslint-disable-next-line require-atomic-updates
389
+ config.server.passphrase = globalPbivizOptions.passphrase;
390
+ }
391
+ await fs.writeFile(path.join(rootPath, confPath), JSON.stringify(config));
392
+ }
393
+ }
394
+ return options;
395
+ }
396
+
397
+ export async function verifyCertFile(keyPath, certPath, pfxPath, passphrase) {
398
+ let verifyCertDate;
399
+ try {
400
+ let endDateStr;
401
+
402
+ // For Windows OS:
403
+ if (os.platform() === "win32") {
404
+ if (!fs.existsSync(pfxPath) || !passphrase) {
405
+ return false;
406
+ }
407
+ const certStr = await exec(`powershell.exe (New-Object System.Security.Cryptography.X509Certificates.X509Certificate2('${pfxPath}','${passphrase}')).NotAfter.ToString('yyyy-MM-dd HH:mm:ss')`);
408
+ endDateStr = certStr.trim();
409
+ }
410
+ // For Linux and Mac/darwin OS:
411
+ else if (os.platform() === "linux" || os.platform() === "darwin") {
412
+ if (!fs.existsSync(certPath)) {
413
+ return false;
414
+ }
415
+ endDateStr = await exec(`openssl x509 -enddate -noout -in ${certPath} | cut -d = -f 2`);
416
+ }
417
+
418
+ const endDate = Date.parse(endDateStr);
419
+ verifyCertDate = (endDate - Date.now()) > certSafePeriod;
420
+ if (verifyCertDate) {
421
+ ConsoleWriter.info(`Certificate is valid.`);
422
+ } else {
423
+ ConsoleWriter.warning(`Certificate is invalid!`);
424
+ removeCertFiles(certPath, keyPath, pfxPath);
425
+ }
426
+ } catch (err) {
427
+ ConsoleWriter.warning(`Certificate verification error: ${err}`);
428
+ removeCertFiles(certPath, keyPath, pfxPath);
429
+ }
430
+ return verifyCertDate;
431
+ }
@@ -0,0 +1,78 @@
1
+
2
+ import ConsoleWriter from './ConsoleWriter.js';
3
+ import VisualManager from './VisualManager.js';
4
+ import { WebpackOptions } from './WebPackWrap.js';
5
+
6
+ interface StartOptions {
7
+ port: number,
8
+ stats: boolean,
9
+ drop: boolean
10
+ }
11
+
12
+ interface PackageOptions {
13
+ pbiviz: boolean,
14
+ resources: boolean,
15
+ minify: boolean,
16
+ compression: number,
17
+ stats: boolean,
18
+ }
19
+
20
+ interface NewOptions {
21
+ force: boolean,
22
+ template: string
23
+ }
24
+
25
+ export default class CommandManager {
26
+ public static async start(options: StartOptions, rootPath: string) {
27
+ const webpackOptions: WebpackOptions = {
28
+ devMode: true,
29
+ devtool: "source-map",
30
+ generateResources: true,
31
+ generatePbiviz: false,
32
+ minifyJS: false,
33
+ minify: false,
34
+ devServerPort: options.port,
35
+ stats: options.stats
36
+ }
37
+ const visualManager = new VisualManager(rootPath)
38
+ await visualManager
39
+ .prepareVisual()
40
+ .initializeWebpack(webpackOptions)
41
+ visualManager.startWebpackServer(options.drop)
42
+ }
43
+
44
+ public static async package(options: PackageOptions, rootPath: string) {
45
+ if (!options.pbiviz && !options.resources) {
46
+ ConsoleWriter.error('Nothing to build. Cannot use --no-pbiviz without --resources');
47
+ process.exit(1);
48
+ }
49
+
50
+ const webpackOptions = {
51
+ devMode: false,
52
+ generateResources: options.resources,
53
+ generatePbiviz: options.pbiviz,
54
+ minifyJS: options.minify,
55
+ minify: options.minify,
56
+ compression: options.compression,
57
+ stats: options.stats
58
+ }
59
+ new VisualManager(rootPath)
60
+ .prepareVisual()
61
+ .initializeWebpack(webpackOptions)
62
+ .then(visualManager => visualManager.generatePackage())
63
+ }
64
+
65
+ public static new({ force, template }: NewOptions, name: string, rootPath: string) {
66
+ const generateOptions = {
67
+ force: force,
68
+ template: template
69
+ };
70
+ VisualManager.createVisual(rootPath, name, generateOptions)
71
+ }
72
+
73
+ public static info(rootPath: string) {
74
+ new VisualManager(rootPath)
75
+ .prepareVisual()
76
+ .displayInfo();
77
+ }
78
+ }