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
package/lib/webpack.config.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { getRootPath, readJsonFromRoot } from './utils.js';
|
|
2
|
+
import { LocalizationLoader } from "powerbi-visuals-webpack-plugin";
|
|
3
|
+
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
|
4
|
+
import TerserPlugin from "terser-webpack-plugin";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import webpack from "webpack";
|
|
7
|
+
const config = readJsonFromRoot("/config.json");
|
|
8
|
+
const webpackConfig = {
|
|
9
9
|
entry: {
|
|
10
10
|
'visual.js': ['./src/visual.ts']
|
|
11
11
|
},
|
|
@@ -36,7 +36,7 @@ module.exports = {
|
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
test: /\.json$/,
|
|
39
|
-
loader:
|
|
39
|
+
loader: 'json-loader',
|
|
40
40
|
type: "javascript/auto"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
@@ -46,13 +46,13 @@ module.exports = {
|
|
|
46
46
|
loader: MiniCssExtractPlugin.loader
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
|
-
loader:
|
|
49
|
+
loader: 'css-loader'
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
|
-
loader:
|
|
52
|
+
loader: 'less-loader',
|
|
53
53
|
options: {
|
|
54
54
|
lessOptions: {
|
|
55
|
-
paths: [path.resolve(
|
|
55
|
+
paths: [path.resolve(getRootPath(), 'node_modules')]
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -62,55 +62,46 @@ module.exports = {
|
|
|
62
62
|
test: /\.(woff|ttf|ico|woff2|jpg|jpeg|png|webp|gif|svg|eot)$/i,
|
|
63
63
|
type: 'asset/inline'
|
|
64
64
|
},
|
|
65
|
-
{
|
|
65
|
+
{
|
|
66
66
|
test: /powerbiGlobalizeLocales\.js$/,
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
loader: LocalizationLoader
|
|
70
|
-
}
|
|
71
|
-
]
|
|
67
|
+
loader: LocalizationLoader
|
|
72
68
|
}
|
|
73
69
|
]
|
|
74
70
|
},
|
|
75
71
|
externals: {
|
|
76
|
-
"powerbi-visuals-api": 'null'
|
|
77
|
-
"fakeDefine": 'false',
|
|
78
|
-
"corePowerbiObject": "Function('return this.powerbi')()",
|
|
79
|
-
"realWindow": "Function('return this')()"
|
|
72
|
+
"powerbi-visuals-api": 'null'
|
|
80
73
|
},
|
|
81
74
|
resolve: {
|
|
82
75
|
extensions: ['.tsx', '.ts', '.jsx', '.js', '.css'],
|
|
83
76
|
fallback: {
|
|
84
|
-
assert:
|
|
85
|
-
buffer:
|
|
86
|
-
console:
|
|
87
|
-
constants:
|
|
88
|
-
crypto:
|
|
89
|
-
domain:
|
|
90
|
-
events:
|
|
91
|
-
http:
|
|
92
|
-
https:
|
|
93
|
-
os:
|
|
94
|
-
path:
|
|
95
|
-
punycode:
|
|
96
|
-
process:
|
|
97
|
-
querystring:
|
|
98
|
-
stream:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
vm: require.resolve("vm-browserify/"),
|
|
113
|
-
zlib: require.resolve("browserify-zlib/")
|
|
77
|
+
assert: path.resolve("../node-modules/assert/"),
|
|
78
|
+
buffer: path.resolve("../node-modules/buffer/"),
|
|
79
|
+
console: path.resolve("../node-modules/console-browserify/"),
|
|
80
|
+
constants: path.resolve("../node-modules/constants-browserify/"),
|
|
81
|
+
crypto: path.resolve("../node-modules/crypto-browserify/"),
|
|
82
|
+
domain: path.resolve("../node-modules/domain-browser/"),
|
|
83
|
+
events: path.resolve("../node-modules/events/"),
|
|
84
|
+
http: path.resolve("../node-modules/stream-http/"),
|
|
85
|
+
https: path.resolve("../node-modules/https-browserify/"),
|
|
86
|
+
os: path.resolve("../node-modules/os-browserify/"),
|
|
87
|
+
path: path.resolve("../node-modules/path-browserify/"),
|
|
88
|
+
punycode: path.resolve("../node-modules/punycode/"),
|
|
89
|
+
process: path.resolve("../node-modules/process/"),
|
|
90
|
+
querystring: path.resolve("../node-modules/querystring-es3/"),
|
|
91
|
+
stream: path.resolve("../node-modules/stream-browserify/"),
|
|
92
|
+
_stream_duplex: path.resolve("../node-modules/readable-stream/"),
|
|
93
|
+
_stream_passthrough: path.resolve("../node-modules/readable-stream/"),
|
|
94
|
+
_stream_readable: path.resolve("../node-modules/readable-stream/"),
|
|
95
|
+
_stream_transform: path.resolve("../node-modules/readable-stream/"),
|
|
96
|
+
_stream_writable: path.resolve("../node-modules/readable-stream/"),
|
|
97
|
+
string_decoder: path.resolve("../node-modules/string_decoder/"),
|
|
98
|
+
sys: path.resolve("../node-modules/util/"),
|
|
99
|
+
timers: path.resolve("../node-modules/timers-browserify/"),
|
|
100
|
+
tty: path.resolve("../node-modules/tty-browserify/"),
|
|
101
|
+
url: path.resolve("../node-modules/url/"),
|
|
102
|
+
util: path.resolve("../node-modules/util/"),
|
|
103
|
+
vm: path.resolve("../node-modules/vm-browserify/"),
|
|
104
|
+
zlib: path.resolve("../node-modules/browserify-zlib/")
|
|
114
105
|
}
|
|
115
106
|
},
|
|
116
107
|
output: {
|
|
@@ -132,11 +123,11 @@ module.exports = {
|
|
|
132
123
|
"cache-control": "public, max-age=0"
|
|
133
124
|
}
|
|
134
125
|
},
|
|
126
|
+
watchOptions: {
|
|
127
|
+
ignored: ['node_modules/**']
|
|
128
|
+
},
|
|
135
129
|
plugins: [
|
|
136
130
|
new webpack.ProvidePlugin({
|
|
137
|
-
$: 'jquery',
|
|
138
|
-
jQuery: 'jquery',
|
|
139
|
-
d3: 'd3',
|
|
140
131
|
Buffer: ["buffer", "Buffer"],
|
|
141
132
|
process: "process/browser"
|
|
142
133
|
}),
|
|
@@ -146,4 +137,4 @@ module.exports = {
|
|
|
146
137
|
})
|
|
147
138
|
]
|
|
148
139
|
};
|
|
149
|
-
|
|
140
|
+
export default webpackConfig;
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "powerbi-visuals-tools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Command line tool for creating and publishing visuals for Power BI",
|
|
5
|
-
"main": "./
|
|
5
|
+
"main": "./bin/pbiviz.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"pbiviz": "node ./bin/pbiviz.js",
|
|
10
|
+
"start": "npm run pbiviz start",
|
|
11
|
+
"test": "npm run build && npm run clean-tests && npm run lint && npm run jasmine",
|
|
9
12
|
"jasmine": "node spec/jasmine-runner.js",
|
|
10
13
|
"jasmine-inspect": "node --inspect spec/jasmine-runner.js",
|
|
11
|
-
"lint": "eslint
|
|
14
|
+
"lint": "npx eslint . --ext .ts,.tsx",
|
|
12
15
|
"clean-tests": "node spec/clean-tests.js",
|
|
13
16
|
"debug-tests": "npm run clean-tests && npm run lint && npm run jasmine-inspect"
|
|
14
17
|
},
|
|
@@ -26,22 +29,25 @@
|
|
|
26
29
|
},
|
|
27
30
|
"homepage": "https://github.com/Microsoft/PowerBI-visuals-tools#readme",
|
|
28
31
|
"dependencies": {
|
|
32
|
+
"@typescript-eslint/parser": "^5.62.0",
|
|
29
33
|
"assert": "^2.0.0",
|
|
30
34
|
"async": "^3.2.4",
|
|
31
35
|
"browserify-zlib": "^0.2.0",
|
|
32
36
|
"buffer": "^6.0.3",
|
|
33
|
-
"chalk": "3.0
|
|
34
|
-
"commander": "
|
|
35
|
-
"compare-versions": "^
|
|
37
|
+
"chalk": "^5.3.0",
|
|
38
|
+
"commander": "^11.0.0",
|
|
39
|
+
"compare-versions": "^6.0.0",
|
|
36
40
|
"console-browserify": "^1.2.0",
|
|
37
41
|
"constants-browserify": "^1.0.0",
|
|
38
42
|
"crypto-browserify": "^3.12.0",
|
|
39
43
|
"css-loader": "^6.8.1",
|
|
40
44
|
"domain-browser": "^4.22.0",
|
|
41
45
|
"events": "^3.3.0",
|
|
46
|
+
"terser-webpack-plugin": "^5.3.9",
|
|
42
47
|
"extra-watch-webpack-plugin": "^1.0.3",
|
|
43
48
|
"fs-extra": "^11.1.1",
|
|
44
49
|
"https-browserify": "^1.0.0",
|
|
50
|
+
"inline-source-map": "^0.6.2",
|
|
45
51
|
"json-loader": "0.5.7",
|
|
46
52
|
"jszip": "^3.10.1",
|
|
47
53
|
"less": "^4.1.3",
|
|
@@ -66,9 +72,8 @@
|
|
|
66
72
|
"typescript": "^4.9.5",
|
|
67
73
|
"url": "^0.11.1",
|
|
68
74
|
"util": "^0.12.5",
|
|
69
|
-
"uuid": "9.0.0",
|
|
70
75
|
"vm-browserify": "^1.1.2",
|
|
71
|
-
"webpack": "^5.88.
|
|
76
|
+
"webpack": "^5.88.2",
|
|
72
77
|
"webpack-bundle-analyzer": "4.9.0",
|
|
73
78
|
"webpack-dev-server": "^4.15.1"
|
|
74
79
|
},
|
|
@@ -77,12 +82,15 @@
|
|
|
77
82
|
"jasmine": "5.0.2",
|
|
78
83
|
"jasmine-spec-reporter": "7.0.0",
|
|
79
84
|
"semver": "7.5.4",
|
|
80
|
-
"tree-kill": "1.2.2"
|
|
85
|
+
"tree-kill": "1.2.2",
|
|
86
|
+
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
87
|
+
"eslint-plugin-powerbi-visuals": "^0.8.1",
|
|
88
|
+
"webpack-cli": "^5.1.4"
|
|
81
89
|
},
|
|
82
90
|
"optionalDependencies": {
|
|
83
91
|
"fsevents": "*"
|
|
84
92
|
},
|
|
85
93
|
"engines": {
|
|
86
|
-
"node": ">=
|
|
94
|
+
"node": ">=18.0.0"
|
|
87
95
|
}
|
|
88
96
|
}
|
package/spec/clean-tests.js
CHANGED
|
@@ -26,28 +26,29 @@
|
|
|
26
26
|
|
|
27
27
|
"use strict";
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
import fs from 'fs-extra';
|
|
30
|
+
import path from 'path';
|
|
31
|
+
import { getRootPath, readJsonFromRoot } from '../../lib/utils.js';
|
|
32
|
+
import { createCertFile } from '../../lib/CertificateTools.js';
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
const config = readJsonFromRoot('config.json');
|
|
35
35
|
|
|
36
36
|
describe("E2E - pbiviz --install-cert", () => {
|
|
37
37
|
beforeEach((done) => {
|
|
38
|
-
|
|
38
|
+
createCertFile(config, false).then(done);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
describe("pbiviz", () => {
|
|
42
42
|
it("pbiviz --install-cert command should generate certificate", (done) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
const rootPath = getRootPath();
|
|
44
|
+
const certPath = path.join(rootPath, config.server.certificate);
|
|
45
|
+
const keyPath = path.join(rootPath, config.server.privateKey);
|
|
46
|
+
const pfxPath = path.join(rootPath, config.server.pfx);
|
|
47
|
+
const certExists = fs.existsSync(certPath);
|
|
48
|
+
const keyExists = fs.existsSync(keyPath);
|
|
49
|
+
const pfxExists = fs.existsSync(pfxPath);
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
const result = (certExists && keyExists) || pfxExists;
|
|
51
52
|
|
|
52
53
|
expect(result).toBeTruthy();
|
|
53
54
|
done();
|
|
@@ -26,21 +26,21 @@
|
|
|
26
26
|
|
|
27
27
|
"use strict";
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
import fs from 'fs-extra';
|
|
30
|
+
import path from 'path';
|
|
31
|
+
import FileSystem from '../helpers/FileSystem.js';
|
|
32
|
+
import { writeMetadata } from "./testUtils.js";
|
|
33
33
|
|
|
34
34
|
const tempPath = FileSystem.getTempPath();
|
|
35
35
|
const startPath = process.cwd();
|
|
36
|
-
const writeMetadata = require("./utils").writeMetadata;
|
|
37
36
|
|
|
38
37
|
describe("E2E - pbiviz info", () => {
|
|
39
38
|
|
|
40
|
-
const visualName = '
|
|
39
|
+
const visualName = 'myvisualname';
|
|
41
40
|
const visualPath = path.join(tempPath, visualName);
|
|
42
41
|
|
|
43
42
|
beforeEach(() => {
|
|
43
|
+
process.chdir(startPath);
|
|
44
44
|
FileSystem.resetTempDirectory();
|
|
45
45
|
process.chdir(tempPath);
|
|
46
46
|
FileSystem.runPbiviz('new', visualName);
|
|
@@ -49,10 +49,6 @@ describe("E2E - pbiviz info", () => {
|
|
|
49
49
|
writeMetadata(visualPath);
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
afterEach(() => {
|
|
53
|
-
process.chdir(startPath);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
52
|
afterAll(() => {
|
|
57
53
|
process.chdir(startPath);
|
|
58
54
|
FileSystem.deleteTempDirectory();
|
|
@@ -71,6 +67,7 @@ describe("E2E - pbiviz info", () => {
|
|
|
71
67
|
expect(error).toBeDefined();
|
|
72
68
|
expect(error.status).toBe(1);
|
|
73
69
|
expect(error.message).toContain("Error: pbiviz.json not found. You must be in the root of a visual project to run this command");
|
|
70
|
+
|
|
74
71
|
});
|
|
75
72
|
|
|
76
73
|
it("Should output visual info", () => {
|
|
@@ -26,20 +26,19 @@
|
|
|
26
26
|
|
|
27
27
|
"use strict";
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
const createFolder = require("../../lib/utils").createFolder;
|
|
38
|
-
const config = require("../../config.json");
|
|
39
|
-
|
|
29
|
+
import fs from 'fs-extra';
|
|
30
|
+
import path from 'path';
|
|
31
|
+
import { promises as fsPromises } from "fs";
|
|
32
|
+
import FileSystem from '../helpers/FileSystem.js';
|
|
33
|
+
import { writeMetadata, readdirSyncRecursive } from "./testUtils.js";
|
|
34
|
+
import { download, createFolder, readJsonFromRoot } from "../../lib/utils.js";
|
|
35
|
+
|
|
36
|
+
const config = readJsonFromRoot('config.json');
|
|
40
37
|
const tempPath = FileSystem.getTempPath();
|
|
41
38
|
const templatePath = FileSystem.getTemplatePath();
|
|
42
39
|
const startPath = process.cwd();
|
|
40
|
+
const visualName = 'visualName';
|
|
41
|
+
const visualPath = path.join(tempPath, visualName);
|
|
43
42
|
|
|
44
43
|
describe("E2E - pbiviz new", () => {
|
|
45
44
|
|
|
@@ -53,37 +52,34 @@ describe("E2E - pbiviz new", () => {
|
|
|
53
52
|
});
|
|
54
53
|
|
|
55
54
|
afterAll(() => {
|
|
56
|
-
process.chdir(startPath);
|
|
57
55
|
FileSystem.deleteTempDirectory();
|
|
58
56
|
});
|
|
59
57
|
|
|
60
58
|
it("Should generate new visual with default template", () => {
|
|
61
|
-
|
|
62
|
-
let template = 'default';
|
|
63
|
-
let visualPath = path.join(tempPath, visualName);
|
|
59
|
+
const template = 'default';
|
|
64
60
|
|
|
65
61
|
FileSystem.runPbiviz('new', visualName, ' -t default');
|
|
66
62
|
|
|
67
63
|
writeMetadata(visualPath);
|
|
68
64
|
|
|
69
65
|
//check base dir
|
|
70
|
-
|
|
66
|
+
const stat = fs.statSync(visualPath);
|
|
71
67
|
expect(stat.isDirectory()).toBe(true);
|
|
72
68
|
|
|
73
69
|
//check contents
|
|
74
|
-
|
|
75
|
-
expectedFiles.concat(
|
|
70
|
+
const expectedFiles = readdirSyncRecursive(path.join(templatePath, 'visuals', template));
|
|
71
|
+
expectedFiles.concat(readdirSyncRecursive(path.join(templatePath, 'visuals', '_global')));
|
|
76
72
|
expectedFiles.push('/pbiviz.json');
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
const visualFiles = readdirSyncRecursive(visualPath);
|
|
74
|
+
const fileDiff = [expectedFiles, visualFiles].reduce((a, b) => a.filter(c => !b.includes(c)));
|
|
79
75
|
expect(fileDiff.length).toBe(0);
|
|
80
76
|
|
|
81
77
|
// check exists node_modules directory
|
|
82
|
-
|
|
78
|
+
const nodeModulesDirStat = fs.statSync(path.join(visualPath, "node_modules"));
|
|
83
79
|
expect(nodeModulesDirStat.isDirectory()).toBe(true);
|
|
84
80
|
|
|
85
81
|
//check pbiviz.json config file
|
|
86
|
-
|
|
82
|
+
const visualConfig = fs.readJsonSync(path.join(visualPath, 'pbiviz.json')).visual;
|
|
87
83
|
expect(visualConfig.name).toBe(visualName);
|
|
88
84
|
expect(visualConfig.displayName).toBe(visualName);
|
|
89
85
|
expect(visualConfig.guid).toBeDefined();
|
|
@@ -92,7 +88,7 @@ describe("E2E - pbiviz new", () => {
|
|
|
92
88
|
});
|
|
93
89
|
|
|
94
90
|
describe(`Should download 'Circlecard' visual archive from the repo`, () => {
|
|
95
|
-
|
|
91
|
+
const template = 'circlecard';
|
|
96
92
|
|
|
97
93
|
it(`Verifiy size`, async () => {
|
|
98
94
|
const folder = createFolder(template);
|
|
@@ -108,6 +104,33 @@ describe("E2E - pbiviz new", () => {
|
|
|
108
104
|
|
|
109
105
|
describe('Should generate new visual using specified template', () => {
|
|
110
106
|
|
|
107
|
+
function testGeneratedVisualByTemplateName(template) {
|
|
108
|
+
FileSystem.runPbiviz('new', visualName, `--template ${template}`);
|
|
109
|
+
if (template !== 'circlecard') {
|
|
110
|
+
FileSystem.runCMDCommand('npm i', visualPath, startPath);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//check base dir exists
|
|
114
|
+
const stat = fs.statSync(visualPath);
|
|
115
|
+
expect(stat.isDirectory()).toBe(true);
|
|
116
|
+
|
|
117
|
+
//read pbiviz json generated in visual
|
|
118
|
+
const pbivizJson = fs.readJsonSync(path.join(visualPath, 'pbiviz.json'));
|
|
119
|
+
|
|
120
|
+
//check pbiviz.json config file
|
|
121
|
+
const visualConfig = pbivizJson.visual;
|
|
122
|
+
if (template === 'circlecard') {
|
|
123
|
+
expect(visualConfig.name).toBe('reactCircleCard');
|
|
124
|
+
expect(visualConfig.displayName).toBe('ReactCircleCard');
|
|
125
|
+
} else {
|
|
126
|
+
expect(visualConfig.name).toBe(visualName);
|
|
127
|
+
expect(visualConfig.displayName).toBe(visualName);
|
|
128
|
+
}
|
|
129
|
+
expect(visualConfig.guid).toBeDefined();
|
|
130
|
+
expect(visualConfig.guid).toMatch(/^[a-zA-Z0-9]+$/g);
|
|
131
|
+
expect(visualConfig.guid.substr(0, visualName.length)).toBe(visualName);
|
|
132
|
+
}
|
|
133
|
+
|
|
111
134
|
it('table', () => {
|
|
112
135
|
const template = 'table';
|
|
113
136
|
|
|
@@ -137,55 +160,23 @@ describe("E2E - pbiviz new", () => {
|
|
|
137
160
|
|
|
138
161
|
testGeneratedVisualByTemplateName(template);
|
|
139
162
|
});
|
|
140
|
-
|
|
141
|
-
function testGeneratedVisualByTemplateName(template) {
|
|
142
|
-
let visualName = 'visualname',
|
|
143
|
-
visualPath = path.join(tempPath, visualName);
|
|
144
|
-
|
|
145
|
-
FileSystem.runPbiviz('new', visualName, `--template ${template}`);
|
|
146
|
-
if (template !== 'circlecard') {
|
|
147
|
-
FileSystem.runCMDCommand('npm i', visualPath, startPath);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
//check base dir exists
|
|
151
|
-
let stat = fs.statSync(visualPath);
|
|
152
|
-
expect(stat.isDirectory()).toBe(true);
|
|
153
|
-
|
|
154
|
-
//read pbiviz json generated in visual
|
|
155
|
-
let pbivizJson = fs.readJsonSync(path.join(visualPath, 'pbiviz.json'));
|
|
156
|
-
|
|
157
|
-
//check pbiviz.json config file
|
|
158
|
-
let visualConfig = pbivizJson.visual;
|
|
159
|
-
if (template === 'circlecard') {
|
|
160
|
-
expect(visualConfig.name).toBe('reactCircleCard');
|
|
161
|
-
expect(visualConfig.displayName).toBe('ReactCircleCard');
|
|
162
|
-
} else {
|
|
163
|
-
expect(visualConfig.name).toBe(visualName);
|
|
164
|
-
expect(visualConfig.displayName).toBe(visualName);
|
|
165
|
-
}
|
|
166
|
-
expect(visualConfig.guid).toBeDefined();
|
|
167
|
-
expect(visualConfig.guid).toMatch(/^[a-zA-Z0-9]+$/g);
|
|
168
|
-
expect(visualConfig.guid.substr(0, visualName.length)).toBe(visualName);
|
|
169
|
-
}
|
|
170
163
|
});
|
|
171
164
|
|
|
172
165
|
it("Should convert multi-word visual name to camelCase", () => {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
FileSystem.runPbiviz('new', visualDisplayName);
|
|
166
|
+
const visualDisplayName = 'Visual Name';
|
|
167
|
+
FileSystem.runPbiviz('new', `"${visualDisplayName}"`);
|
|
176
168
|
|
|
177
|
-
|
|
178
|
-
let stat = fs.statSync(visualPath);
|
|
169
|
+
const stat = fs.statSync(visualPath);
|
|
179
170
|
expect(stat.isDirectory()).toBe(true);
|
|
180
171
|
|
|
181
|
-
|
|
172
|
+
const visualConfig = fs.readJsonSync(path.join(visualPath, 'pbiviz.json')).visual;
|
|
182
173
|
expect(visualConfig.name).toBe(visualName);
|
|
183
174
|
expect(visualConfig.displayName).toBe(visualDisplayName);
|
|
184
175
|
});
|
|
185
176
|
|
|
186
177
|
it("Should throw error if the visual name invalid", () => {
|
|
187
|
-
let invalidVisualName = '12test';
|
|
188
178
|
let error;
|
|
179
|
+
let invalidVisualName = '12test';
|
|
189
180
|
try {
|
|
190
181
|
FileSystem.runPbiviz('new', invalidVisualName);
|
|
191
182
|
}
|
|
@@ -215,9 +206,7 @@ describe("E2E - pbiviz new", () => {
|
|
|
215
206
|
});
|
|
216
207
|
|
|
217
208
|
it("Should throw error if the visual already exists", () => {
|
|
218
|
-
let visualName = 'visualname';
|
|
219
209
|
let error;
|
|
220
|
-
|
|
221
210
|
FileSystem.runPbiviz('new', visualName);
|
|
222
211
|
|
|
223
212
|
try {
|
|
@@ -228,12 +217,11 @@ describe("E2E - pbiviz new", () => {
|
|
|
228
217
|
|
|
229
218
|
expect(error).toBeDefined();
|
|
230
219
|
expect(error.status).toBe(1);
|
|
220
|
+
|
|
231
221
|
});
|
|
232
222
|
|
|
233
223
|
it("Should overwrite existing visual with force flag", () => {
|
|
234
|
-
|
|
235
|
-
let visualPath = path.join(tempPath, visualName);
|
|
236
|
-
let visualTestFilePath = path.join(visualPath, 'testFile.txt');
|
|
224
|
+
const visualTestFilePath = path.join(visualPath, 'testFile.txt');
|
|
237
225
|
let visualNewError, testFileError1, testFileError2;
|
|
238
226
|
|
|
239
227
|
FileSystem.runPbiviz('new', visualName);
|