in lib/WebPackWrap.js [126:167]
async configureCustomVisualsWebpackPlugin(visualPackage, options, tsconfig) {
let pluginConfiguration = lodashCloneDeep(visualPackage.config);
//(?=\D*$) - positive look-ahead to find last version symbols and exclude any non-digit symbols after the version.
let regexFullVersion = /(?:\d+\.?){1,3}(?=\D*$)/;
let regexMinorVersion = /\d+(?:\.\d+)?/;
let apiVersionInstalled;
try {
apiVersionInstalled = (await exec('npm list powerbi-visuals-api version')).stdout.match(regexFullVersion)[0];
} catch (err) {
ConsoleWriter.warn(`"powerbi-visuals-api" is not installed`);
}
// if the powerbi-visual-api package wasn't installed
// install the powerbi-visual-api, with version from apiVersion in pbiviz.json
// or the latest API, if apiVersion is absent in pbiviz.json
if (!apiVersionInstalled || (typeof this.pbiviz.apiVersion !== "undefined" && this.pbiviz.apiVersion.match(regexMinorVersion)[0] != apiVersionInstalled.match(regexMinorVersion)[0])) {
ConsoleWriter.warn(`installed "powerbi-visuals-api" version - "${apiVersionInstalled}", is not match with the version specified in pbviz.json - "${this.pbiviz.apiVersion}".`);
await this.installAPIpackage();
}
// pluginConfiguration.env = await this.getEnvironmentDetails();
let api = WebPackGenerator.loadAPIPackage(visualPackage);
pluginConfiguration.apiVersion = api.version;
pluginConfiguration.capabilitiesSchema = api.schemas.capabilities;
pluginConfiguration.pbivizSchema = api.schemas.pbiviz;
pluginConfiguration.stringResourcesSchema = api.schemas.stringResources;
pluginConfiguration.dependenciesSchema = api.schemas.dependencies;
pluginConfiguration.customVisualID = `CustomVisual_${this.pbiviz.visual.guid}`.replace(/[^\w\s]/gi, '');
pluginConfiguration.devMode = (typeof options.devMode === "undefined") ? true : options.devMode;
pluginConfiguration.generatePbiviz = options.generatePbiviz;
pluginConfiguration.generateResources = options.generateResources;
pluginConfiguration.minifyJS = options.minifyJS;
const dependenciesPath = this.pbiviz.dependencies && path.join(process.cwd(), this.pbiviz.dependencies);
pluginConfiguration.dependencies = fs.existsSync(dependenciesPath) ? this.pbiviz.dependencies : null;
pluginConfiguration.modules = typeof tsconfig.compilerOptions.outDir !== "undefined";
pluginConfiguration.visualSourceLocation = path.posix.relative(config.build.precompileFolder, tsconfig.files[0]).replace(/(\.ts)x|\.ts/, "");
pluginConfiguration.pluginLocation = path.join(config.build.precompileFolder, "visualPlugin.ts");
pluginConfiguration.compression = options.compression;
return pluginConfiguration;
}