powerbi-visuals-tools 6.1.3 → 7.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 (48) hide show
  1. package/.eslintrc.json +21 -0
  2. package/CVClientLA.md +85 -0
  3. package/Changelog.md +9 -0
  4. package/package.json +11 -35
  5. package/certs/blank +0 -0
  6. package/lib/CertificateTools.js +0 -262
  7. package/lib/CommandManager.js +0 -75
  8. package/lib/ConsoleWriter.js +0 -188
  9. package/lib/FeatureManager.js +0 -43
  10. package/lib/LintValidator.js +0 -61
  11. package/lib/Package.js +0 -46
  12. package/lib/TemplateFetcher.js +0 -111
  13. package/lib/Visual.js +0 -29
  14. package/lib/VisualGenerator.js +0 -221
  15. package/lib/VisualManager.js +0 -316
  16. package/lib/WebPackWrap.js +0 -268
  17. package/lib/features/APIVersion.js +0 -16
  18. package/lib/features/AdvancedEditMode.js +0 -12
  19. package/lib/features/AllowInteractions.js +0 -12
  20. package/lib/features/AnalyticsPane.js +0 -17
  21. package/lib/features/BaseFeature.js +0 -9
  22. package/lib/features/Bookmarks.js +0 -12
  23. package/lib/features/ColorPalette.js +0 -12
  24. package/lib/features/ConditionalFormatting.js +0 -12
  25. package/lib/features/ContextMenu.js +0 -12
  26. package/lib/features/DrillDown.js +0 -16
  27. package/lib/features/FeatureTypes.js +0 -23
  28. package/lib/features/FetchMoreData.js +0 -22
  29. package/lib/features/FileDownload.js +0 -12
  30. package/lib/features/FormatPane.js +0 -12
  31. package/lib/features/HighContrast.js +0 -12
  32. package/lib/features/HighlightData.js +0 -12
  33. package/lib/features/KeyboardNavigation.js +0 -12
  34. package/lib/features/LandingPage.js +0 -12
  35. package/lib/features/LaunchURL.js +0 -12
  36. package/lib/features/LocalStorage.js +0 -12
  37. package/lib/features/Localizations.js +0 -12
  38. package/lib/features/ModalDialog.js +0 -12
  39. package/lib/features/RenderingEvents.js +0 -13
  40. package/lib/features/SelectionAcrossVisuals.js +0 -12
  41. package/lib/features/SyncSlicer.js +0 -12
  42. package/lib/features/Tooltips.js +0 -12
  43. package/lib/features/TotalSubTotal.js +0 -12
  44. package/lib/features/VisualVersion.js +0 -12
  45. package/lib/features/WarningIcon.js +0 -12
  46. package/lib/features/index.js +0 -28
  47. package/lib/utils.js +0 -43
  48. package/lib/webpack.config.js +0 -148
package/.eslintrc.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "env": {
3
+ "es6": true,
4
+ "node": true
5
+ },
6
+ "parser": "@typescript-eslint/parser",
7
+ "extends": "eslint:recommended",
8
+ "plugins": [
9
+ "@typescript-eslint"
10
+ ],
11
+ "parserOptions": {
12
+ "ecmaVersion": 2023,
13
+ "sourceType": "module",
14
+ "project": "tsconfig.json",
15
+ "tsconfigRootDir": "."
16
+ },
17
+ "rules": {
18
+ "no-unused-vars": "off",
19
+ "@typescript-eslint/no-unused-vars": "error"
20
+ }
21
+ }
package/CVClientLA.md ADDED
@@ -0,0 +1,85 @@
1
+ **POWER BI CUSTOM VISUALS – STANDARD VISUALIZATION LICENSE TERMS**
2
+
3
+ These license terms are an agreement between you and the visualization developer. Please read them.
4
+ They apply to the visualization for Power BI you download from the Public AppSource store, including any updates
5
+ or supplements for the visualization (the “Visualization”), unless the Visualization comes with separate
6
+ terms, in which case those terms apply.
7
+
8
+ **BY DOWNLOADING OR USING THE VISUALIZATION, OR ATTEMPTING TO DO ANY OF THESE, YOU
9
+ ACCEPT THESE TERMS. IF YOU DO NOT ACCEPT THEM, YOU HAVE NO RIGHT TO AND MUST NOT
10
+ DOWNLOAD OR USE THE VISUALIZATION.**
11
+
12
+ **The Visualization developer means the entity licensing the Visualization to you, as identified in the
13
+ Public AppSource store.**
14
+
15
+ **If you comply with these license terms, you have the rights below.**
16
+
17
+ 1. **INSTALLATION AND USE RIGHTS.** You may install and use any number of copies of the Visualization
18
+ for use with a product or service that supports the Power BI visual interface.
19
+
20
+ 2. **INTERNET-BASED SERVICES.**
21
+ **a. Consent for Internet-Based or Wireless Services.** The Visualization connects to computer systems
22
+ over the Internet, which may include via a wireless network. Using the Visualization operates as your
23
+ consent to the transmission of standard device information (including but not limited to technical
24
+ information about your device, system and Visualization software, and peripherals) for internet-based
25
+ or wireless services.
26
+ **b. Misuse of Internet-based Services.** You may not use any Internet-based service in any way that could
27
+ harm it or impair anyone else’s use of it or the wireless network. You may not use the service to try to
28
+ gain unauthorized access to any service, data, account or network by any means.
29
+ 3. **SCOPE OF LICENSE.** The Visualization is licensed, not sold. This agreement only gives you some rights
30
+ to use the Visualization. Visualization developer reserves all other rights. Unless applicable law gives you
31
+ more rights despite this limitation, you may use the Visualization only as expressly permitted in this
32
+ agreement. You may not
33
+ • work around any technical limitations in the Visualization; or
34
+ • reverse engineer, decompile or disassemble the Visualization, except and only to the extent that
35
+ applicable law expressly permits, despite this limitation.
36
+ 4. **DOCUMENTATION.** If documentation is provided with the Visualization, you may copy and use the
37
+ documentation for personal reference purposes.
38
+ 5. **TECHNOLOGY AND EXPORT RESTRICTIONS.** The Visualization may be subject to United States or
39
+ international technology control or export laws and regulations. You must comply with all domestic and
40
+ international export laws and regulations that apply to the technology used or supported by the
41
+ Visualization. These laws include restrictions on destinations, end users and end use. For information on
42
+ Microsoft branded products, see www.microsoft.com/exporting.
43
+ 6. **SUPPORT SERVICES.** Microsoft is not responsible for providing support services for the Visualization. If
44
+ Microsoft is the Visualization developer, it may provide support services, but is not obligated to do so
45
+ under this agreement. Contact the Visualization developer to determine what support services are
46
+ available.
47
+ 7. **ENTIRE AGREEMENT.** This agreement, any applicable Visualization developer privacy policy, and the
48
+ terms for supplements and updates are the entire agreement between you and Visualization developer
49
+ for the Visualization. If Microsoft is the Visualization developer, this agreement does not change the
50
+ terms of your relationship with Microsoft with regard to Power BI, Microsoft Office, the Public AppSource store, or
51
+ any other Microsoft product or service (which is governed by the software license terms that
52
+ accompanied, or terms of use that are associated with, the applicable product or service).
53
+ 8. **APPLICABLE LAW.**
54
+ a. **United States. If you acquired the Visualization in the United States, Washington state law governs
55
+ the interpretation of this agreement and applies to claims for breach of it, regardless of conflict of
56
+ laws principles. The laws of the state where you live govern all other claims, including claims under
57
+ state consumer protection laws, unfair competition laws, and in tort.**
58
+ b. **Outside the United States. If you acquired the Visualization in any other country, the laws of that
59
+ country apply.**
60
+
61
+ 9. **LEGAL EFFECT.** This agreement describes certain legal rights. You may have other rights under the
62
+ laws of your state or country. This agreement does not change your rights under the laws of your state
63
+ or country if the laws of your state or country do not permit it to do so.
64
+ 10. **DISCLAIMER OF WARRANTY. TO THE FULLEST EXTENT PERMITTED BY LAW, (A) THE VISUALIZATION
65
+ IS LICENSED "AS-IS," "WITH ALL FAULTS," AND "AS AVAILABLE" AND YOU BEAR ALL RISK OF USING IT;
66
+ (B) THE VISUALIZATION DEVELOPER, ON BEHALF OF ITSELF, MICROSOFT (IF MICROSOFT IS NOT THE
67
+ VISUALIZATION DEVELOPER), AND EACH OF OUR RESPECTIVE AFFILIATES, VENDORS, AGENTS AND
68
+ SUPPLIERS, GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS IN RELATION TO THE
69
+ VISUALIZATION; (C) YOU MAY HAVE ADDITIONAL CONSUMER RIGHTS UNDER YOUR LOCAL LAWS
70
+ THAT THIS AGREEMENT CANNOT CHANGE; AND (D) VISUALIZATION DEVELOPER AND MICROSOFT
71
+ EXCLUDE ANY IMPLIED WARRANTIES OR CONDITIONS, INCLUDING THOSE OF MERCHANTABILITY,
72
+ FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.**
73
+ 11. **LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. TO THE EXTENT NOT PROHIBITED
74
+ BY LAW, YOU CAN RECOVER FROM THE VISUALIZATION DEVELOPER ONLY DIRECT DAMAGES UP TO
75
+ THE AMOUNT YOU PAID FOR THE VISUALIZATION OR $1.00, WHICHEVER IS GREATER. YOU WILL NOT,
76
+ AND WAIVE ANY RIGHT TO, SEEK TO RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL,
77
+ LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES FROM THE VISUALIZATION DEVELOPER.**
78
+ **This limitation applies to
79
+ • anything related to the Visualization or services made available through the Visualization; and
80
+ • claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence,
81
+ or other tort to the extent permitted by applicable law.
82
+ It also applies even if
83
+ • repair, replacement or a refund for the Visualization does not fully compensate you for any losses;
84
+ or
85
+ • Visualization developer knew or should have known about the possibility of the damages.**
package/Changelog.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  This page contains information about changes to the PowerBI Visual Tools (pbiviz).
4
4
 
5
+ ## 7.0.0
6
+ * **BREAKING CHANGE**: Removed Node.js polyfills from webpack configuration for improved security and reduced bundle size. Node.js modules (crypto, buffer, stream, etc.) are no longer automatically available in the browser environment.
7
+ * Removed browserify polyfill packages from dependencies (assert, buffer, crypto-browserify, console-browserify, constants-browserify, domain-browser, events, https-browserify, os-browserify, path-browserify, process, punycode, querystring-es3, readable-stream, stream-browserify, stream-http, string_decoder, timers-browserify, tty-browserify, url, util, vm-browserify, browserify-zlib)
8
+ * **Action Required**: Review your visual code for Node.js module usage and remove them or update to browser-compatible alternatives
9
+
10
+ ## 6.2.0
11
+ * Changed source map generation to `inline-source-map`. It includes source maps into the end of file instead of separate one. It's required because of latest changes in Power BI that forbids loading `.map` files.
12
+ * Updated packages
13
+
5
14
  ## 6.1.2
6
15
  * Fixed issue with `process/browser` not being resolved correctly in webpack config
7
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powerbi-visuals-tools",
3
- "version": "6.1.3",
3
+ "version": "7.0.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",
@@ -29,59 +29,35 @@
29
29
  "homepage": "https://github.com/Microsoft/PowerBI-visuals-tools#readme",
30
30
  "dependencies": {
31
31
  "@typescript-eslint/parser": "^8.32.1",
32
- "assert": "^2.1.0",
33
32
  "async": "^3.2.6",
34
- "browserify-zlib": "^0.2.0",
35
- "buffer": "^6.0.3",
36
33
  "chalk": "^5.4.1",
37
34
  "commander": "^13.1.0",
38
35
  "compare-versions": "^6.1.1",
39
- "console-browserify": "^1.2.0",
40
- "constants-browserify": "^1.0.0",
41
- "crypto-browserify": "^3.12.1",
42
36
  "css-loader": "^7.1.2",
43
- "domain-browser": "^5.7.0",
44
- "eslint-plugin-powerbi-visuals": "^1.0.0",
45
- "events": "^3.3.0",
37
+ "eslint-plugin-powerbi-visuals": "1.1.0",
46
38
  "extra-watch-webpack-plugin": "^1.0.3",
47
- "fs-extra": "^11.3.0",
48
- "https-browserify": "^1.0.0",
39
+ "fs-extra": "^11.3.2",
49
40
  "inline-source-map": "^0.6.3",
50
41
  "json-loader": "0.5.7",
51
42
  "jszip": "^3.10.1",
52
- "less": "^4.3.0",
43
+ "less": "^4.4.1",
53
44
  "less-loader": "^12.3.0",
54
45
  "lodash.clonedeep": "4.5.0",
55
46
  "lodash.defaults": "4.2.0",
56
47
  "lodash.isequal": "4.5.0",
57
48
  "lodash.ismatch": "^4.4.0",
58
- "mini-css-extract-plugin": "^2.9.2",
59
- "os-browserify": "^0.3.0",
60
- "path-browserify": "^1.0.1",
61
- "powerbi-visuals-api": "~5.3.0",
49
+ "mini-css-extract-plugin": "^2.9.4",
62
50
  "powerbi-visuals-webpack-plugin": "^4.3.1",
63
- "process": "^0.11.10",
64
- "punycode": "^2.3.1",
65
- "querystring-es3": "^0.2.1",
66
- "readable-stream": "^4.7.0",
67
- "stream-browserify": "^3.0.0",
68
- "stream-http": "^3.2.0",
69
- "string_decoder": "^1.3.0",
70
51
  "terser-webpack-plugin": "^5.3.14",
71
- "timers-browserify": "^2.0.12",
72
- "ts-loader": "^9.5.2",
73
- "tty-browserify": "^0.0.1",
74
- "typescript": "^5.8.3",
75
- "url": "^0.11.4",
76
- "util": "^0.12.5",
77
- "vm-browserify": "^1.1.2",
78
- "webpack": "^5.99.8",
52
+ "ts-loader": "^9.5.4",
53
+ "typescript": "^5.9.3",
54
+ "webpack": "^5.102.0",
79
55
  "webpack-bundle-analyzer": "4.10.2",
80
- "webpack-dev-server": "^5.2.1"
56
+ "webpack-dev-server": "^5.2.2"
81
57
  },
82
58
  "devDependencies": {
83
- "@typescript-eslint/eslint-plugin": "^8.32.1",
84
- "eslint": "^9.29.0",
59
+ "@typescript-eslint/eslint-plugin": "^8.45.0",
60
+ "eslint": "^9.36.0",
85
61
  "jasmine": "5.3.1",
86
62
  "jasmine-spec-reporter": "7.0.0",
87
63
  "semver": "7.7.2",
package/certs/blank DELETED
File without changes
@@ -1,262 +0,0 @@
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
- "use strict";
27
- import { exec as nodeExec } from 'child_process';
28
- import fs from 'fs-extra';
29
- import os from 'os';
30
- import path from 'path';
31
- import crypto from "crypto";
32
- import { readJsonFromRoot } from './utils.js';
33
- import ConsoleWriter from './ConsoleWriter.js';
34
- const certSafePeriod = 1000 * 60 * 60 * 24; // 24 hours
35
- const config = await readJsonFromRoot('config.json');
36
- const pathToCertFolder = path.join(os.homedir(), config.server.certificateFolder);
37
- const secretFilesPath = {
38
- certPath: path.join(pathToCertFolder, config.server.certificate),
39
- keyPath: path.join(pathToCertFolder, config.server.privateKey),
40
- pfxPath: path.join(pathToCertFolder, config.server.pfx),
41
- passphrasePath: path.join(pathToCertFolder, config.server.passphrase)
42
- };
43
- function exec(command, options, callback) {
44
- return new Promise((resolve, reject) => {
45
- const defaultCallback = (err, stdout, stderr) => {
46
- if (err) {
47
- reject(stderr);
48
- }
49
- resolve(stdout);
50
- };
51
- nodeExec(command, options, callback ? callback : defaultCallback);
52
- });
53
- }
54
- export async function createCertificate() {
55
- const certPath = await getCertFile(true);
56
- if (!certPath) {
57
- ConsoleWriter.error("Certificate not found. The new certificate will be generated");
58
- await createCertFile(true);
59
- }
60
- else {
61
- await openCertFile();
62
- }
63
- }
64
- export async function createCertFile(open = false) {
65
- ConsoleWriter.info(`Generating a new certificate...`);
66
- const subject = "localhost";
67
- const keyLength = 2048;
68
- const validPeriod = 365;
69
- const { certPath, keyPath, pfxPath } = secretFilesPath;
70
- const openCmds = {
71
- linux: 'openssl',
72
- darwin: 'openssl',
73
- win32: 'pwsh'
74
- };
75
- let startCmd = openCmds[os.platform()];
76
- if (!startCmd) {
77
- ConsoleWriter.error(['Unknown platform. Please place a custom-generated certificate in:', certPath]);
78
- return;
79
- }
80
- try {
81
- let createCertCommand = "";
82
- let passphrase = "";
83
- fs.ensureDirSync(path.dirname(certPath));
84
- switch (os.platform()) {
85
- case "linux":
86
- case "darwin":
87
- createCertCommand =
88
- ` req -newkey rsa:${keyLength}` +
89
- ` -nodes` +
90
- ` -keyout ${keyPath}` +
91
- ` -x509 ` +
92
- ` -days ${validPeriod} ` +
93
- ` -out ${certPath} ` +
94
- ` -subj "/CN=${subject}"`;
95
- await Promise.all([
96
- removeCertFiles(certPath, keyPath),
97
- exec(`${startCmd} ${createCertCommand}`)
98
- ]);
99
- if (await fs.exists(certPath)) {
100
- ConsoleWriter.info(`Certificate generated. Location is ${certPath}`);
101
- if (open) {
102
- await openCertFile();
103
- }
104
- }
105
- break;
106
- case "win32":
107
- passphrase = getRandomValues()[0].toString().substring(2);
108
- createCertCommand = `$cert = ('Cert:\\CurrentUser\\My\\' + (` +
109
- ` New-SelfSignedCertificate ` +
110
- ` -DnsName localhost ` +
111
- ` -Type Custom ` +
112
- ` -Subject 'CN=${subject}' ` +
113
- ` -KeyAlgorithm RSA ` +
114
- ` -KeyLength ${keyLength} ` +
115
- ` -KeyExportPolicy Exportable ` +
116
- ` -CertStoreLocation Cert:\\CurrentUser\\My ` +
117
- ` -NotAfter (get-date).AddDays(${validPeriod}) ` +
118
- ` | select Thumbprint | ` +
119
- ` ForEach-Object { $_.Thumbprint.ToString() }).toString()); ` +
120
- ` Export-PfxCertificate -Cert $cert` +
121
- ` -FilePath '${pfxPath}' ` +
122
- ` -Password (ConvertTo-SecureString -String '${passphrase}' -Force -AsPlainText)`;
123
- await Promise.all([
124
- removeCertFiles(certPath, keyPath, pfxPath),
125
- exec(`${startCmd} -Command "${createCertCommand}"`),
126
- savePassphrase(passphrase)
127
- ]);
128
- if (await fs.exists(pfxPath)) {
129
- ConsoleWriter.info(`Certificate generated. Location is ${pfxPath}. Passphrase is ${passphrase}`);
130
- }
131
- break;
132
- default:
133
- ConsoleWriter.error('Unknown platform');
134
- break;
135
- }
136
- }
137
- catch (e) {
138
- if (e && e.message && e.message.indexOf("'openssl' is not recognized as an internal or external command") > 0) {
139
- ConsoleWriter.warning('Create certificate error:');
140
- ConsoleWriter.warning('OpenSSL is not installed or not available from command line');
141
- ConsoleWriter.info('Install OpenSSL from https://www.openssl.org or https://wiki.openssl.org/index.php/Binaries');
142
- ConsoleWriter.info('and try again');
143
- ConsoleWriter.info('Read more at');
144
- ConsoleWriter.info('https://github.com/Microsoft/PowerBI-visuals/blob/master/tools/CreateCertificate.md#manual');
145
- }
146
- else {
147
- ConsoleWriter.error(['Create certificate error:', e]);
148
- }
149
- }
150
- }
151
- async function getCertFile(silent = false) {
152
- const { certPath, pfxPath, passphrasePath } = secretFilesPath;
153
- if (await fs.exists(certPath)) {
154
- return certPath;
155
- }
156
- if (await fs.exists(pfxPath)) {
157
- if (!silent && await fs.exists(passphrasePath)) {
158
- const passphrase = await fs.readFile(passphrasePath, 'utf8');
159
- ConsoleWriter.info(`Use '${passphrase}' passphrase to install PFX certificate.`);
160
- }
161
- return pfxPath;
162
- }
163
- if (!silent) {
164
- ConsoleWriter.info('Certificate not found. Call `pbiviz install-cert` command to create the new certificate');
165
- }
166
- return null;
167
- }
168
- async function openCertFile() {
169
- const openCmds = {
170
- linux: 'xdg-open',
171
- darwin: 'open',
172
- win32: 'powershell start'
173
- };
174
- const startCmd = openCmds[os.platform()];
175
- const certPath = await getCertFile();
176
- try {
177
- if (!startCmd || !certPath) {
178
- throw new Error();
179
- }
180
- await exec(`${startCmd} "${certPath}"`);
181
- }
182
- catch (e) {
183
- ConsoleWriter.info(['Certificate path:', certPath]);
184
- }
185
- }
186
- export async function removeCertFiles(...paths) {
187
- paths.forEach(async (path) => {
188
- try {
189
- await fs.unlink(path);
190
- }
191
- catch (e) {
192
- if (!e.message.indexOf("no such file or directory")) {
193
- throw e;
194
- }
195
- }
196
- });
197
- }
198
- export async function resolveCertificate() {
199
- const options = {};
200
- const { certPath, keyPath, pfxPath, passphrasePath } = secretFilesPath;
201
- const isCertificateValid = await verifyCertFile(keyPath, certPath, pfxPath, passphrasePath);
202
- if (!isCertificateValid) {
203
- await createCertFile();
204
- }
205
- if (await fs.exists(passphrasePath)) {
206
- options.passphrase = await fs.readFile(passphrasePath, 'utf8');
207
- }
208
- if (await fs.exists(keyPath)) {
209
- options.key = await fs.readFile(keyPath);
210
- }
211
- if (await fs.exists(certPath)) {
212
- options.cert = await fs.readFile(certPath);
213
- }
214
- if (await fs.exists(pfxPath)) {
215
- options.pfx = await fs.readFile(pfxPath);
216
- }
217
- return options;
218
- }
219
- export async function verifyCertFile(keyPath, certPath, pfxPath, passphrasePath) {
220
- let verifyCertDate = false;
221
- try {
222
- let endDateStr;
223
- if (os.platform() === "win32") {
224
- if (!fs.existsSync(pfxPath) || !fs.existsSync(passphrasePath)) {
225
- throw new Error('PFX or passphrase file not found');
226
- }
227
- const passphrase = await fs.readFile(passphrasePath, 'utf8');
228
- const command = `(New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("${pfxPath}",'${passphrase}')).NotAfter.ToString('yyyy-MM-dd HH:mm:ss')`;
229
- const certStr = await exec(command, { shell: 'powershell.exe' });
230
- endDateStr = certStr.trim();
231
- }
232
- else if (os.platform() === "linux" || os.platform() === "darwin") {
233
- if (!(await fs.exists(certPath))) {
234
- throw new Error('Certificate file not found');
235
- }
236
- endDateStr = await exec(`openssl x509 -enddate -noout -in ${certPath} | cut -d = -f 2`);
237
- }
238
- const endDate = Date.parse(endDateStr);
239
- verifyCertDate = (endDate - Date.now()) > certSafePeriod;
240
- if (verifyCertDate) {
241
- ConsoleWriter.info(`Certificate is valid.`);
242
- }
243
- else {
244
- throw new Error('Certificate is invalid');
245
- }
246
- }
247
- catch (err) {
248
- ConsoleWriter.warning(`Certificate verification error: ${err}`);
249
- removeCertFiles(certPath, keyPath, pfxPath, passphrasePath);
250
- }
251
- return verifyCertDate;
252
- }
253
- const getRandomValues = () => {
254
- if (crypto.getRandomValues !== undefined) {
255
- return crypto.getRandomValues(new Uint32Array(1));
256
- }
257
- return crypto.webcrypto.getRandomValues(new Uint32Array(1));
258
- };
259
- const savePassphrase = async (passphrase) => {
260
- const { passphrasePath } = secretFilesPath;
261
- await fs.writeFileSync(passphrasePath, passphrase);
262
- };
@@ -1,75 +0,0 @@
1
- import { createCertificate } from './CertificateTools.js';
2
- import ConsoleWriter from './ConsoleWriter.js';
3
- import VisualManager from './VisualManager.js';
4
- export default class CommandManager {
5
- static async start(options, rootPath) {
6
- const webpackOptions = {
7
- devMode: true,
8
- devtool: "eval-source-map",
9
- generateResources: true,
10
- generatePbiviz: false,
11
- minifyJS: false,
12
- minify: false,
13
- devServerPort: options.port,
14
- stats: options.stats,
15
- skipApiCheck: options.skipApi,
16
- allLocales: options.allLocales,
17
- pbivizFile: options.pbivizFile,
18
- };
19
- const visualManager = new VisualManager(rootPath);
20
- await visualManager.prepareVisual(options.pbivizFile);
21
- await visualManager.validateVisual();
22
- await visualManager.initializeWebpack(webpackOptions);
23
- visualManager.startWebpackServer(options.drop);
24
- }
25
- static async lint(options, rootPath) {
26
- const visualManager = new VisualManager(rootPath);
27
- await visualManager.prepareVisual();
28
- await visualManager.runLintValidation(options);
29
- }
30
- static async package(options, rootPath) {
31
- if (!options.pbiviz && !options.resources) {
32
- ConsoleWriter.error('Nothing to build. Cannot use --no-pbiviz without --resources');
33
- process.exit(1);
34
- }
35
- const webpackOptions = {
36
- devMode: false,
37
- generateResources: options.resources,
38
- generatePbiviz: options.pbiviz,
39
- minifyJS: options.minify,
40
- minify: options.minify,
41
- compression: options.compression,
42
- stats: options.stats,
43
- skipApiCheck: options.skipApi,
44
- allLocales: options.allLocales,
45
- pbivizFile: options.pbivizFile,
46
- certificationAudit: options.certificationAudit,
47
- certificationFix: options.certificationFix,
48
- };
49
- const lintOptions = {
50
- verbose: options.verbose,
51
- fix: options.fix,
52
- };
53
- const visualManager = new VisualManager(rootPath);
54
- const visual = await visualManager.prepareVisual(options.pbivizFile);
55
- await visual.runLintValidation(lintOptions);
56
- await visual.validateVisual(options.verbose);
57
- await visual.initializeWebpack(webpackOptions)
58
- .then(manager => manager.generatePackage(options.verbose));
59
- }
60
- static new({ force, template }, name, rootPath) {
61
- const generateOptions = {
62
- force: force,
63
- template: template
64
- };
65
- VisualManager.createVisual(rootPath, name, generateOptions);
66
- }
67
- static async info(rootPath) {
68
- const visualManager = new VisualManager(rootPath);
69
- await visualManager.prepareVisual();
70
- await visualManager.displayInfo();
71
- }
72
- static async installCert() {
73
- await createCertificate();
74
- }
75
- }