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.
- package/Changelog.md +7 -0
- package/README.md +1 -1
- package/bin/pbiviz.js +55 -36
- package/certs/PowerBICustomVisualTest_private.key +26 -26
- package/certs/PowerBICustomVisualTest_public.crt +17 -17
- package/config.json +27 -34
- package/lib/CertificateTools.js +119 -143
- package/lib/CommandManager.js +52 -0
- package/lib/ConsoleWriter.js +63 -85
- package/lib/TemplateFetcher.js +23 -30
- package/lib/VisualGenerator.js +42 -56
- package/lib/VisualManager.js +193 -0
- package/lib/WebPackWrap.js +96 -145
- package/lib/utils.js +21 -13
- package/lib/webpack.config.js +47 -56
- package/package.json +20 -12
- package/spec/clean-tests.js +1 -1
- package/spec/e2e/pbivizCertSpec.js +14 -13
- package/spec/e2e/pbivizInfoSpec.js +7 -10
- package/spec/e2e/pbivizNewSpec.js +53 -65
- package/spec/e2e/pbivizPackageSpec.js +86 -90
- package/spec/e2e/pbivizStartSpec.js +6 -7
- package/spec/e2e/pbivizWebpackVerSpec.js +14 -16
- package/spec/e2e/{utils.js → testUtils.js} +9 -12
- package/spec/helpers/FileSystem.js +18 -18
- package/spec/jasmine-runner.js +5 -5
- package/src/CertificateTools.ts +431 -0
- package/src/CommandManager.ts +78 -0
- package/src/ConsoleWriter.ts +206 -0
- package/src/TemplateFetcher.ts +122 -0
- package/src/VisualGenerator.ts +236 -0
- package/src/VisualManager.ts +220 -0
- package/src/WebPackWrap.ts +299 -0
- package/src/utils.ts +41 -0
- package/src/webpack.config.ts +144 -0
- package/templates/pbiviz-json-template.js +2 -2
- package/templates/pbiviz.json.template +1 -1
- package/templates/plugin-ts-template.js +1 -1
- package/templates/visuals/default/.eslintignore +5 -0
- package/templates/visuals/default/.eslintrc.js +20 -0
- package/templates/visuals/default/package.json +9 -8
- package/templates/visuals/default/pbiviz.json +3 -2
- package/templates/visuals/default/tsconfig.json +2 -2
- package/templates/visuals/rhtml/.eslintignore +5 -0
- package/templates/visuals/rhtml/.eslintrc.js +20 -0
- package/templates/visuals/rhtml/package.json +7 -6
- package/templates/visuals/rhtml/pbiviz.json +2 -1
- package/templates/visuals/rvisual/.eslintignore +5 -0
- package/templates/visuals/rvisual/.eslintrc.js +20 -0
- package/templates/visuals/rvisual/package.json +5 -4
- package/templates/visuals/slicer/.eslintignore +5 -0
- package/templates/visuals/slicer/.eslintrc.js +20 -0
- package/templates/visuals/slicer/package.json +8 -7
- package/templates/visuals/table/.eslintignore +5 -0
- package/templates/visuals/table/.eslintrc.js +20 -0
- package/templates/visuals/table/package.json +8 -7
- package/templates/visuals/table/tsconfig.json +4 -0
- package/tsconfig.json +22 -0
- package/bin/pbiviz-info.js +0 -54
- package/bin/pbiviz-new.js +0 -82
- package/bin/pbiviz-package.js +0 -122
- package/bin/pbiviz-start.js +0 -142
- package/lib/CommandHelpManager.js +0 -51
- package/lib/VisualPackage.js +0 -118
- package/templates/visuals/default/tslint.json +0 -9
- package/templates/visuals/rhtml/tslint.json +0 -9
- package/templates/visuals/rvisual/tslint.json +0 -9
- package/templates/visuals/slicer/tslint.json +0 -9
- package/templates/visuals/table/tslint.json +0 -9
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-useless-escape */
|
|
1
2
|
/*
|
|
2
3
|
* Power BI Visual CLI
|
|
3
4
|
*
|
|
@@ -26,25 +27,25 @@
|
|
|
26
27
|
|
|
27
28
|
"use strict";
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const writeMetadata = require("./utils").writeMetadata;
|
|
30
|
+
import fs from 'fs-extra';
|
|
31
|
+
import path from 'path';
|
|
32
|
+
import async from 'async';
|
|
33
|
+
import JSZip from 'jszip';
|
|
34
|
+
import lodashIsEqual from 'lodash.isequal';
|
|
35
|
+
import FileSystem from '../helpers/FileSystem.js';
|
|
36
|
+
import { writeMetadata } from "./testUtils.js";
|
|
37
37
|
|
|
38
38
|
const tempPath = FileSystem.getTempPath();
|
|
39
39
|
const startPath = process.cwd();
|
|
40
40
|
|
|
41
41
|
describe("E2E - pbiviz package", () => {
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const visualName = 'visualname';
|
|
44
|
+
const visualPath = path.join(tempPath, visualName);
|
|
45
45
|
let visualPbiviz = {};
|
|
46
46
|
|
|
47
47
|
beforeEach(() => {
|
|
48
|
+
process.chdir(startPath);
|
|
48
49
|
FileSystem.resetTempDirectory();
|
|
49
50
|
process.chdir(tempPath);
|
|
50
51
|
FileSystem.runPbiviz('new', visualName);
|
|
@@ -56,10 +57,6 @@ describe("E2E - pbiviz package", () => {
|
|
|
56
57
|
visualPbiviz = JSON.parse(fs.readFileSync(path.join(visualPath, 'pbiviz.json'), { encoding: "utf8" }));
|
|
57
58
|
});
|
|
58
59
|
|
|
59
|
-
afterEach(() => {
|
|
60
|
-
process.chdir(startPath);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
60
|
afterAll(() => {
|
|
64
61
|
process.chdir(startPath);
|
|
65
62
|
FileSystem.deleteTempDirectory();
|
|
@@ -94,61 +91,61 @@ describe("E2E - pbiviz package", () => {
|
|
|
94
91
|
});
|
|
95
92
|
|
|
96
93
|
it("Should create a pbiviz file and no resources folder with no flags", () => {
|
|
94
|
+
let error;
|
|
97
95
|
FileSystem.runPbiviz('package');
|
|
98
96
|
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
const pbivizPath = path.join(visualPath, 'dist', visualPbiviz.visual.guid + "." + visualPbiviz.visual.version + '.pbiviz');
|
|
98
|
+
const resourcesPath = path.join(visualPath, 'dist', 'resources');
|
|
101
99
|
|
|
102
|
-
let resourcesError;
|
|
103
100
|
try {
|
|
104
101
|
fs.accessSync(resourcesPath);
|
|
105
102
|
} catch (e) {
|
|
106
|
-
|
|
103
|
+
error = e
|
|
107
104
|
}
|
|
105
|
+
expect(error).toBeDefined();
|
|
106
|
+
expect(error.code).toBe('ENOENT');
|
|
108
107
|
|
|
109
|
-
expect(resourcesError).toBeDefined();
|
|
110
|
-
expect(resourcesError.code).toBe('ENOENT');
|
|
111
108
|
expect(fs.statSync(pbivizPath).isFile()).toBe(true);
|
|
112
109
|
});
|
|
113
110
|
|
|
114
111
|
it("Should create a pbiviz file and resource folder with --resources flag", () => {
|
|
115
|
-
FileSystem.runPbiviz('package',
|
|
112
|
+
FileSystem.runPbiviz('package', undefined, '--resources');
|
|
116
113
|
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
const pbivizPath = path.join(visualPath, 'dist', visualPbiviz.visual.guid + "." + visualPbiviz.visual.version + '.pbiviz');
|
|
115
|
+
const resourcesPath = path.join(visualPath, 'dist', 'resources');
|
|
119
116
|
|
|
120
117
|
expect(fs.statSync(pbivizPath).isFile()).toBe(true);
|
|
121
118
|
expect(fs.statSync(resourcesPath).isDirectory()).toBe(true);
|
|
122
119
|
});
|
|
123
120
|
|
|
124
121
|
it("Should not create pbiviz file with --no-pbiviz flag", () => {
|
|
125
|
-
|
|
122
|
+
let error
|
|
123
|
+
FileSystem.runPbiviz('package', undefined, '--no-pbiviz --resources');
|
|
126
124
|
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
const pbivizPath = path.join(visualPath, 'dist', visualPbiviz.visual.guid + "." + visualPbiviz.visual.version + '.pbiviz');
|
|
126
|
+
const resourcesPath = path.join(visualPath, 'dist', 'resources');
|
|
129
127
|
|
|
130
|
-
let pbivizError;
|
|
131
128
|
try {
|
|
132
129
|
fs.accessSync(pbivizPath);
|
|
133
130
|
} catch (e) {
|
|
134
|
-
|
|
131
|
+
error = e
|
|
135
132
|
}
|
|
133
|
+
expect(error).toBeDefined();
|
|
134
|
+
expect(error.code).toBe('ENOENT');
|
|
136
135
|
|
|
137
|
-
expect(pbivizError).toBeDefined();
|
|
138
|
-
expect(pbivizError.code).toBe('ENOENT');
|
|
139
136
|
expect(fs.statSync(resourcesPath).isDirectory()).toBe(true);
|
|
140
137
|
});
|
|
141
138
|
|
|
142
139
|
it("Should correctly generate pbiviz file", (done) => {
|
|
143
140
|
FileSystem.runPbiviz('package');
|
|
144
141
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
142
|
+
const visualConfig = fs.readJsonSync(path.join(visualPath, 'pbiviz.json')).visual;
|
|
143
|
+
const visualCapabilities = fs.readJsonSync(path.join(visualPath, 'capabilities.json'));
|
|
144
|
+
const pbivizPath = path.join(visualPath, 'dist', visualPbiviz.visual.guid + "." + visualPbiviz.visual.version + '.pbiviz');
|
|
145
|
+
const pbivizResourcePath = `resources/${visualConfig.guid}.pbiviz.json`;
|
|
149
146
|
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
const zipContents = fs.readFileSync(pbivizPath);
|
|
148
|
+
const jszip = new JSZip();
|
|
152
149
|
jszip.loadAsync(zipContents)
|
|
153
150
|
.then((zip) => {
|
|
154
151
|
async.parallel([
|
|
@@ -156,7 +153,7 @@ describe("E2E - pbiviz package", () => {
|
|
|
156
153
|
(next) => {
|
|
157
154
|
zip.file('package.json').async('string')
|
|
158
155
|
.then((content) => {
|
|
159
|
-
|
|
156
|
+
const data = JSON.parse(content);
|
|
160
157
|
expect(data.resources.length).toBe(1);
|
|
161
158
|
expect(data.resources[0].file).toBe(pbivizResourcePath);
|
|
162
159
|
expect(data.visual).toEqual(visualConfig);
|
|
@@ -168,7 +165,7 @@ describe("E2E - pbiviz package", () => {
|
|
|
168
165
|
(next) => {
|
|
169
166
|
zip.file(pbivizResourcePath).async('string')
|
|
170
167
|
.then((content) => {
|
|
171
|
-
|
|
168
|
+
const data = JSON.parse(content);
|
|
172
169
|
expect(data.visual).toEqual(visualConfig);
|
|
173
170
|
expect(data.capabilities).toEqual(visualCapabilities);
|
|
174
171
|
expect(data.content.js).toBeDefined();
|
|
@@ -189,19 +186,19 @@ describe("E2E - pbiviz package", () => {
|
|
|
189
186
|
});
|
|
190
187
|
|
|
191
188
|
it("Should correctly generate resources folder", () => {
|
|
192
|
-
FileSystem.runPbiviz('package',
|
|
189
|
+
FileSystem.runPbiviz('package', undefined, '--no-pbiviz --resources');
|
|
193
190
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
191
|
+
const visualConfig = fs.readJsonSync(path.join(visualPath, 'pbiviz.json')).visual;
|
|
192
|
+
const visualCapabilities = fs.readJsonSync(path.join(visualPath, 'capabilities.json'));
|
|
193
|
+
const resourcesPath = path.join(visualPath, 'dist', 'resources');
|
|
194
|
+
const pbivizPath = path.join(resourcesPath, visualPbiviz.visual.guid + '.pbiviz.json');
|
|
198
195
|
|
|
199
196
|
expect(fs.statSync(resourcesPath).isDirectory()).toBe(true);
|
|
200
197
|
expect(fs.statSync(path.join(resourcesPath, 'visual.prod.js')).isFile()).toBe(true);
|
|
201
198
|
expect(fs.statSync(path.join(resourcesPath, 'visual.prod.css')).isFile()).toBe(true);
|
|
202
199
|
expect(fs.statSync(pbivizPath).isFile()).toBe(true);
|
|
203
200
|
|
|
204
|
-
|
|
201
|
+
const pbiviz = fs.readJsonSync(pbivizPath);
|
|
205
202
|
expect(pbiviz.visual).toEqual(visualConfig);
|
|
206
203
|
expect(pbiviz.capabilities).toEqual(visualCapabilities);
|
|
207
204
|
expect(pbiviz.content.js).toBeDefined();
|
|
@@ -212,41 +209,41 @@ describe("E2E - pbiviz package", () => {
|
|
|
212
209
|
// tets can't check the minification, because in input the plugin gets minified version,
|
|
213
210
|
// plugin can't create two version js file for compare
|
|
214
211
|
xit("Should minify assets by default", () => {
|
|
215
|
-
FileSystem.runPbiviz('package',
|
|
212
|
+
FileSystem.runPbiviz('package', undefined, '--resources --no-pbiviz');
|
|
216
213
|
|
|
217
|
-
|
|
214
|
+
const js = fs.statSync(path.join(visualPath, 'dist', 'resources', 'visual.js'));
|
|
218
215
|
|
|
219
|
-
|
|
216
|
+
const prodJs = fs.statSync(path.join(visualPath, 'dist', 'resources', 'visual.prod.js'));
|
|
220
217
|
|
|
221
218
|
expect(js.size).toBeGreaterThan(prodJs.size);
|
|
222
219
|
});
|
|
223
220
|
|
|
224
221
|
it("Should skip minification with --no-minify flag", () => {
|
|
225
|
-
FileSystem.runPbiviz('package',
|
|
222
|
+
FileSystem.runPbiviz('package', undefined, '--resources --no-pbiviz --no-minify');
|
|
226
223
|
|
|
227
|
-
|
|
224
|
+
const js = fs.statSync(path.join(visualPath, 'dist', 'resources', 'visual.js'));
|
|
228
225
|
|
|
229
|
-
|
|
226
|
+
const prodJs = fs.statSync(path.join(visualPath, 'dist', 'resources', 'visual.prod.js'));
|
|
230
227
|
|
|
231
228
|
expect(js.size).toBe(prodJs.size);
|
|
232
229
|
});
|
|
233
230
|
|
|
234
231
|
it("Should set all versions in metadata equal", (done) => {
|
|
235
|
-
|
|
232
|
+
const visualVersion = "1.2.3.4";
|
|
236
233
|
|
|
237
|
-
|
|
238
|
-
|
|
234
|
+
const pbivizJsonPath = path.join(visualPath, 'pbiviz.json');
|
|
235
|
+
const pbiviz = fs.readJsonSync(pbivizJsonPath);
|
|
239
236
|
pbiviz.visual.version = visualVersion;
|
|
240
237
|
fs.writeFileSync(pbivizJsonPath, JSON.stringify(pbiviz));
|
|
241
238
|
FileSystem.runCMDCommand('npm i', visualPath);
|
|
242
239
|
FileSystem.runPbiviz('package');
|
|
243
240
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
241
|
+
const visualConfig = fs.readJsonSync(path.join(visualPath, 'pbiviz.json')).visual;
|
|
242
|
+
const pbivizPath = path.join(visualPath, 'dist', visualPbiviz.visual.guid + "." + pbiviz.visual.version + '.pbiviz');
|
|
243
|
+
const pbivizResourcePath = `resources/${visualConfig.guid}.pbiviz.json`;
|
|
247
244
|
|
|
248
|
-
|
|
249
|
-
|
|
245
|
+
const zipContents = fs.readFileSync(pbivizPath);
|
|
246
|
+
const jszip = new JSZip();
|
|
250
247
|
jszip.loadAsync(zipContents)
|
|
251
248
|
.then((zip) => {
|
|
252
249
|
async.parallel([
|
|
@@ -254,7 +251,7 @@ describe("E2E - pbiviz package", () => {
|
|
|
254
251
|
next => {
|
|
255
252
|
zip.file('package.json').async('string')
|
|
256
253
|
.then((content) => {
|
|
257
|
-
|
|
254
|
+
const data = JSON.parse(content);
|
|
258
255
|
expect(data.visual.version).toEqual(visualVersion);
|
|
259
256
|
expect(data.version).toEqual(visualVersion);
|
|
260
257
|
next();
|
|
@@ -265,7 +262,7 @@ describe("E2E - pbiviz package", () => {
|
|
|
265
262
|
next => {
|
|
266
263
|
zip.file(pbivizResourcePath).async('string')
|
|
267
264
|
.then((content) => {
|
|
268
|
-
|
|
265
|
+
const data = JSON.parse(content);
|
|
269
266
|
expect(data.visual.version).toEqual(visualVersion);
|
|
270
267
|
next();
|
|
271
268
|
})
|
|
@@ -308,7 +305,7 @@ describe("E2E - pbiviz package", () => {
|
|
|
308
305
|
return writeJsonPromise('pbiviz.json', pbivizJson);
|
|
309
306
|
})
|
|
310
307
|
.then(() =>
|
|
311
|
-
FileSystem.runPbiviz('package',
|
|
308
|
+
FileSystem.runPbiviz('package', undefined, '--no-pbiviz --no-minify --resources')
|
|
312
309
|
)
|
|
313
310
|
.then(() =>
|
|
314
311
|
readJsonPromise(path.join(visualPath, 'dist', 'resources', visualPbiviz.visual.guid + '.pbiviz.json'))
|
|
@@ -359,7 +356,7 @@ describe("E2E - pbiviz package", () => {
|
|
|
359
356
|
.then(() => writeJsonPromise('stringResources/ru-RU/resources.resjson', ResJsonRuLocalization))
|
|
360
357
|
]))
|
|
361
358
|
.then(() =>
|
|
362
|
-
FileSystem.runPbiviz('package',
|
|
359
|
+
FileSystem.runPbiviz('package', undefined, '--no-pbiviz --no-minify --resources')
|
|
363
360
|
)
|
|
364
361
|
.then(() =>
|
|
365
362
|
readJsonPromise(path.join(visualPath, 'dist', 'resources', visualPbiviz.visual.guid + '.pbiviz.json'))
|
|
@@ -430,7 +427,7 @@ describe("E2E - pbiviz package", () => {
|
|
|
430
427
|
return writeJsonPromise('pbiviz.json', pbivizJson);
|
|
431
428
|
})
|
|
432
429
|
.then(() =>
|
|
433
|
-
FileSystem.runPbiviz('package',
|
|
430
|
+
FileSystem.runPbiviz('package', undefined, '--no-pbiviz --no-minify --resources')
|
|
434
431
|
)
|
|
435
432
|
.then(() => readJsonPromise(path.join(visualPath, 'dist', 'resources', visualPbiviz.visual.guid + '.pbiviz.json')))
|
|
436
433
|
.then((pbivizJson) => {
|
|
@@ -457,12 +454,11 @@ describe("E2E - pbiviz package", () => {
|
|
|
457
454
|
FileSystem.runPbiviz('package', '--no-stats');
|
|
458
455
|
const statisticFilePath = path.join(visualPath, 'webpack.statistics.prod.html');
|
|
459
456
|
try {
|
|
460
|
-
fs.statSync(statisticFilePath).isFile();
|
|
457
|
+
expect(fs.statSync(statisticFilePath).isFile()).toBe(false);
|
|
461
458
|
} catch (error) {
|
|
462
459
|
expect(error).not.toBeNull();
|
|
463
460
|
}
|
|
464
461
|
});
|
|
465
|
-
|
|
466
462
|
});
|
|
467
463
|
|
|
468
464
|
function mkDirPromise(path) {
|
|
@@ -502,7 +498,7 @@ function testMissingScript(fname) {
|
|
|
502
498
|
try {
|
|
503
499
|
FileSystem.runPbiviz('package');
|
|
504
500
|
} catch (e) {
|
|
505
|
-
error = e
|
|
501
|
+
error = e
|
|
506
502
|
}
|
|
507
503
|
expect(error).toBeDefined();
|
|
508
504
|
expect(error.status).toBe(1);
|
|
@@ -511,7 +507,7 @@ function testMissingScript(fname) {
|
|
|
511
507
|
|
|
512
508
|
function testErrorInDependencies() {
|
|
513
509
|
let error;
|
|
514
|
-
|
|
510
|
+
const invalidDependencies = [
|
|
515
511
|
{
|
|
516
512
|
invalidPropertyName: "ddd"
|
|
517
513
|
}
|
|
@@ -536,10 +532,10 @@ function testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, re
|
|
|
536
532
|
|
|
537
533
|
FileSystem.runPbiviz('package');
|
|
538
534
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
535
|
+
const visualConfig = fs.readJsonSync(path.join(visualPath, 'pbiviz.json')).visual;
|
|
536
|
+
const visualCapabilities = fs.readJsonSync(path.join(visualPath, 'capabilities.json'));
|
|
537
|
+
const pbivizPath = path.join(visualPath, 'dist', visualName + '.pbiviz');
|
|
538
|
+
const pbivizResourcePath = `resources/${visualConfig.guid}.pbiviz.json`;
|
|
543
539
|
|
|
544
540
|
visualCapabilities.dataViewMappings[0].scriptResult.script.scriptSourceDefault = scriptSourceDefault;
|
|
545
541
|
|
|
@@ -548,8 +544,8 @@ function testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, re
|
|
|
548
544
|
dependencies = fs.readJsonSync(path.join(visualPath, 'dependencies.json'));
|
|
549
545
|
}
|
|
550
546
|
|
|
551
|
-
|
|
552
|
-
|
|
547
|
+
const zipContents = fs.readFileSync(pbivizPath);
|
|
548
|
+
const jszip = new JSZip();
|
|
553
549
|
jszip.loadAsync(zipContents)
|
|
554
550
|
.then((zip) => {
|
|
555
551
|
async.parallel([
|
|
@@ -557,7 +553,7 @@ function testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, re
|
|
|
557
553
|
(next) => {
|
|
558
554
|
zip.file('package.json').async('string')
|
|
559
555
|
.then((content) => {
|
|
560
|
-
|
|
556
|
+
const data = JSON.parse(content);
|
|
561
557
|
expect(data.resources.length).toBe(1);
|
|
562
558
|
expect(data.resources[0].file).toBe(pbivizResourcePath);
|
|
563
559
|
expect(data.visual).toEqual(visualConfig);
|
|
@@ -569,7 +565,7 @@ function testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, re
|
|
|
569
565
|
(next) => {
|
|
570
566
|
zip.file(pbivizResourcePath).async('string')
|
|
571
567
|
.then((content) => {
|
|
572
|
-
|
|
568
|
+
const data = JSON.parse(content);
|
|
573
569
|
expect(data.visual).toEqual(visualConfig);
|
|
574
570
|
expect(data.capabilities).toEqual(visualCapabilities);
|
|
575
571
|
expect(data.content.js).toBeDefined();
|
|
@@ -593,8 +589,8 @@ function testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, re
|
|
|
593
589
|
// new tools doesn't support R visuals build. coming soon
|
|
594
590
|
xdescribe("E2E - pbiviz package for R Visual template", () => {
|
|
595
591
|
|
|
596
|
-
|
|
597
|
-
|
|
592
|
+
const visualName = 'visualname';
|
|
593
|
+
const visualPath = path.join(tempPath, visualName);
|
|
598
594
|
|
|
599
595
|
beforeEach(() => {
|
|
600
596
|
FileSystem.resetTempDirectory();
|
|
@@ -622,14 +618,14 @@ xdescribe("E2E - pbiviz package for R Visual template", () => {
|
|
|
622
618
|
});
|
|
623
619
|
|
|
624
620
|
it("Should correctly generate pbiviz file for R Visual template - no dependencies file", (done) => {
|
|
625
|
-
|
|
626
|
-
|
|
621
|
+
const scriptSourceDefault = fs.readFileSync(path.join(visualPath, 'script.r')).toString();
|
|
622
|
+
const removeDependencies = true;
|
|
627
623
|
testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, removeDependencies);
|
|
628
624
|
});
|
|
629
625
|
|
|
630
626
|
it("Should correctly generate pbiviz file for R Visual template", (done) => {
|
|
631
|
-
|
|
632
|
-
|
|
627
|
+
const scriptSourceDefault = fs.readFileSync(path.join(visualPath, 'script.r')).toString();
|
|
628
|
+
const removeDependencies = false;
|
|
633
629
|
testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, removeDependencies);
|
|
634
630
|
});
|
|
635
631
|
});
|
|
@@ -637,13 +633,13 @@ xdescribe("E2E - pbiviz package for R Visual template", () => {
|
|
|
637
633
|
// new tools doesn't support R visuals build. coming soon
|
|
638
634
|
xdescribe("E2E - pbiviz package for R HTML template", () => {
|
|
639
635
|
|
|
640
|
-
|
|
641
|
-
|
|
636
|
+
const visualName = 'visualname';
|
|
637
|
+
const visualPath = path.join(tempPath, visualName);
|
|
642
638
|
|
|
643
639
|
function getScriptSourceDefault() {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
640
|
+
const FlattenScriptContent = fs.readFileSync(path.join(visualPath, 'r_files/flatten_HTML.r')).toString();
|
|
641
|
+
const scriptContent = fs.readFileSync(path.join(visualPath, 'script.r')).toString();
|
|
642
|
+
const pattern = "source('./r_files/flatten_HTML.r')";
|
|
647
643
|
return scriptContent.replace(pattern, FlattenScriptContent);
|
|
648
644
|
}
|
|
649
645
|
|
|
@@ -677,14 +673,14 @@ xdescribe("E2E - pbiviz package for R HTML template", () => {
|
|
|
677
673
|
});
|
|
678
674
|
|
|
679
675
|
it("Should correctly generate pbiviz file for R HTML template - no dependencies file", (done) => {
|
|
680
|
-
|
|
681
|
-
|
|
676
|
+
const scriptSourceDefault = getScriptSourceDefault();
|
|
677
|
+
const removeDependencies = true;
|
|
682
678
|
testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, removeDependencies);
|
|
683
679
|
});
|
|
684
680
|
|
|
685
681
|
it("Should correctly generate pbiviz file for R HTML template", (done) => {
|
|
686
|
-
|
|
687
|
-
|
|
682
|
+
const scriptSourceDefault = getScriptSourceDefault();
|
|
683
|
+
const removeDependencies = false;
|
|
688
684
|
testPbivizPackage(done, visualPath, visualName, scriptSourceDefault, removeDependencies);
|
|
689
685
|
});
|
|
690
686
|
});
|
|
@@ -26,13 +26,12 @@
|
|
|
26
26
|
|
|
27
27
|
"use strict";
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const createFolder = require("../../lib/utils").createFolder;
|
|
29
|
+
import fs from 'fs-extra';
|
|
30
|
+
import path from 'path';
|
|
31
|
+
import async from 'async';
|
|
32
|
+
import FileSystem from '../helpers/FileSystem.js';
|
|
33
|
+
import { writeMetadata } from "./testUtils.js";
|
|
34
|
+
import { download, createFolder } from "../../lib/utils.js";
|
|
36
35
|
|
|
37
36
|
const tempPath = FileSystem.getTempPath();
|
|
38
37
|
const startPath = process.cwd();
|
|
@@ -26,12 +26,11 @@
|
|
|
26
26
|
|
|
27
27
|
"use strict";
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const semver = require('semver');
|
|
29
|
+
import fs from 'fs-extra';
|
|
30
|
+
import path from 'path';
|
|
31
|
+
import semver from 'semver';
|
|
32
|
+
import FileSystem from '../helpers/FileSystem.js';
|
|
33
|
+
import { writeMetadata } from "./testUtils.js";
|
|
35
34
|
|
|
36
35
|
const tempPath = FileSystem.getTempPath();
|
|
37
36
|
const startPath = process.cwd();
|
|
@@ -57,11 +56,10 @@ describe("E2E - webpack tools", () => {
|
|
|
57
56
|
FileSystem.deleteTempDirectory();
|
|
58
57
|
});
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
packageJson.dependencies
|
|
63
|
-
|
|
64
|
-
};
|
|
59
|
+
const removeApi = () => {
|
|
60
|
+
const packageJson = fs.readJsonSync(path.join(visualPath, 'package.json'));
|
|
61
|
+
delete packageJson.dependencies["powerbi-visuals-api"];
|
|
62
|
+
|
|
65
63
|
fs.writeJsonSync(path.join(visualPath, 'package.json'), packageJson);
|
|
66
64
|
|
|
67
65
|
fs.removeSync(path.join(visualPath, "node_modules", "powerbi-visuals-api"));
|
|
@@ -70,28 +68,28 @@ describe("E2E - webpack tools", () => {
|
|
|
70
68
|
it("Should not add empty dependencies option into visual config", () => {
|
|
71
69
|
FileSystem.runPbiviz('package');
|
|
72
70
|
|
|
73
|
-
|
|
71
|
+
const packageJson = fs.readJsonSync(path.join(visualPath, '.tmp/drop/pbiviz.json'));
|
|
74
72
|
expect(packageJson.dependencies).not.toBeDefined();
|
|
75
73
|
});
|
|
76
74
|
|
|
77
75
|
it("Should install the latest powerbi-visual-api if apiVersion is undefined", () => {
|
|
78
|
-
|
|
76
|
+
const pbivizJson = fs.readJsonSync(path.join(visualPath, 'pbiviz.json'));
|
|
79
77
|
pbivizJson.apiVersion = null;
|
|
80
78
|
fs.writeJsonSync(path.join(visualPath, 'pbiviz.json'), pbivizJson);
|
|
81
79
|
|
|
82
80
|
removeApi();
|
|
83
81
|
FileSystem.runPbiviz('package');
|
|
84
82
|
|
|
85
|
-
|
|
83
|
+
const packageJson = fs.readJsonSync(path.join(visualPath, 'package.json'));
|
|
86
84
|
expect(packageJson.dependencies["powerbi-visuals-api"]).toBeDefined();
|
|
87
85
|
});
|
|
88
86
|
|
|
89
87
|
it("Should install powerbi-visual-api with version from pbiviz.json on 'pbiviz start/package'", () => {
|
|
90
|
-
|
|
88
|
+
const pbivizJson = fs.readJsonSync(path.join(visualPath, 'pbiviz.json'));
|
|
91
89
|
removeApi();
|
|
92
90
|
FileSystem.runPbiviz('package');
|
|
93
91
|
|
|
94
|
-
|
|
92
|
+
const packageJson = fs.readJsonSync(path.join(visualPath, 'package.json'));
|
|
95
93
|
expect(packageJson.dependencies["powerbi-visuals-api"]).toBeDefined();
|
|
96
94
|
expect(semver.major(pbivizJson.apiVersion))
|
|
97
95
|
.toBe(semver.major(packageJson.dependencies["powerbi-visuals-api"].replace(/\^|\~/, ""))); // eslint-disable-line no-useless-escape
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
|
|
27
27
|
"use strict";
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
import path from "path";
|
|
30
|
+
import fs from 'fs-extra';
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
export const readdirSyncRecursive = (baseDir) => {
|
|
33
|
+
const read = (dir) => {
|
|
34
34
|
let results = [];
|
|
35
|
-
|
|
35
|
+
const list = fs.readdirSync(dir);
|
|
36
36
|
list.forEach((file) => {
|
|
37
37
|
file = dir + '/' + file;
|
|
38
|
-
|
|
38
|
+
const stat = fs.statSync(file);
|
|
39
39
|
if (stat && stat.isDirectory()) {
|
|
40
40
|
/* Recurse into a subdirectory */
|
|
41
41
|
results = results.concat(read(file));
|
|
@@ -49,15 +49,12 @@ let readdirSyncRecursive = (baseDir) => {
|
|
|
49
49
|
return read(baseDir);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
export const writeMetadata = (visualPath) => {
|
|
53
|
+
const pbivizJSONFile = path.join(visualPath, '/pbiviz.json');
|
|
54
|
+
const pbiviz = fs.readJSONSync(pbivizJSONFile);
|
|
55
55
|
pbiviz.visual.description = "description";
|
|
56
56
|
pbiviz.visual.supportUrl = "supportUrl";
|
|
57
57
|
pbiviz.author.name = "Microsoft";
|
|
58
58
|
pbiviz.author.email = "pbicvsupport";
|
|
59
59
|
fs.writeJSONSync(pbivizJSONFile, pbiviz);
|
|
60
60
|
};
|
|
61
|
-
|
|
62
|
-
module.exports.readdirSyncRecursive = readdirSyncRecursive;
|
|
63
|
-
module.exports.writeMetadata = writeMetadata;
|
|
@@ -26,21 +26,23 @@
|
|
|
26
26
|
|
|
27
27
|
"use strict";
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
import fs from 'fs-extra';
|
|
30
|
+
import path from 'path';
|
|
31
|
+
import childProcess from 'child_process';
|
|
32
|
+
import treeKill from 'tree-kill';
|
|
33
|
+
import { getRootPath } from '../../lib/utils.js';
|
|
34
|
+
|
|
35
|
+
const rootPath = getRootPath();
|
|
36
|
+
const TEMP_DIR = path.join(rootPath, 'spec/.tmp');
|
|
37
|
+
const BIN_PATH = path.join(rootPath, 'bin/pbiviz.js');
|
|
38
|
+
const TEMPLATE_PATH = path.join(rootPath, 'templates');
|
|
39
|
+
|
|
40
|
+
export default class FileSystem {
|
|
39
41
|
static expectFileToExist(fileName) {
|
|
40
42
|
return new Promise((resolve, reject) => {
|
|
41
|
-
fs.
|
|
43
|
+
fs.existsSync(fileName, (exist) => {
|
|
42
44
|
if (exist) {
|
|
43
|
-
resolve();
|
|
45
|
+
resolve(true);
|
|
44
46
|
} else {
|
|
45
47
|
reject(new Error(`File ${fileName} was expected to exist but not found...`));
|
|
46
48
|
}
|
|
@@ -62,12 +64,12 @@ class FileSystem {
|
|
|
62
64
|
|
|
63
65
|
static expectFileToMatch(fileName, regEx) {
|
|
64
66
|
return FileSystem.readFile(fileName)
|
|
65
|
-
.then(content => {
|
|
67
|
+
.then((content) => {
|
|
66
68
|
if (typeof regEx == 'string') {
|
|
67
|
-
if (content.indexOf(regEx) == -1) {
|
|
69
|
+
if ((content).indexOf(regEx) == -1) {
|
|
68
70
|
throw new Error(`File "${fileName}" did not contain "${regEx}"...`);
|
|
69
71
|
}
|
|
70
|
-
} else if (!content.match(regEx)) {
|
|
72
|
+
} else if (!(content).match(regEx)) {
|
|
71
73
|
throw new Error(`File "${fileName}" did not contain "${regEx}"...`);
|
|
72
74
|
}
|
|
73
75
|
});
|
|
@@ -168,6 +170,4 @@ class FileSystem {
|
|
|
168
170
|
});
|
|
169
171
|
}
|
|
170
172
|
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
module.exports = FileSystem;
|
|
173
|
+
}
|
package/spec/jasmine-runner.js
CHANGED
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
|
|
27
27
|
"use strict";
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
import jasmine from 'jasmine';
|
|
30
|
+
import { SpecReporter } from 'jasmine-spec-reporter';
|
|
31
31
|
|
|
32
|
-
let jrunner = new
|
|
33
|
-
jrunner.configureDefaultReporter({ print: () => {} });
|
|
34
|
-
|
|
32
|
+
let jrunner = new jasmine();
|
|
33
|
+
jrunner.configureDefaultReporter({ print: () => {} });
|
|
34
|
+
jrunner.addReporter(new SpecReporter());
|
|
35
35
|
jrunner.loadConfigFile();
|
|
36
36
|
jrunner.execute();
|