Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/devextreme/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules
/testing/LastSuiteTime.txt
/dotnet_packages
/build/bundle-templates/dx.custom.js
/build/.vectormap-node-tmp
/js/__internal/core/localization/default_messages.ts
/js/__internal/core/localization/cldr-data
/js/__internal/grids/__docs__/artifacts
Expand Down
89 changes: 52 additions & 37 deletions packages/devextreme/build/gulp/vectormap.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,64 @@ const compressionPipes = require('./compression-pipes.js');
const VECTORMAP_UTILS_PATH = 'js/viz/vector_map.utils';
const VECTORMAP_UTILS_RESULT_PATH = path.join(context.RESULT_JS_PATH, 'vectormap-utils');
const VECTORMAP_DATA_RESULT_PATH = path.join(context.RESULT_JS_PATH, 'vectormap-data');
const VECTORMAP_NODE_TMP_PATH = 'build/.vectormap-node-tmp';

function transformFileName(fileName) {
return path.join(VECTORMAP_UTILS_PATH, fileName) + '.js';
}

gulp.task('vectormap-utils', function() {
return merge(
createVectorMapUtilsStream('browser', '.debug', false),
createVectorMapUtilsStream('browser', '', true),
createVectorMapUtilsStream('node', '', false)
createBrowserVectorMapUtilsStream('.debug', false),
createBrowserVectorMapUtilsStream('', true),
);
});
Comment thread
pharret31 marked this conversation as resolved.

gulp.task('vectormap-data', gulp.series('vectormap-utils', function() {
const stream = merge();
const processFiles = require(path.join('../..', VECTORMAP_UTILS_RESULT_PATH, 'dx.vectormaputils.node.js')).processFiles;
function buildNodeUtilsForDataGeneration() {
const settings = require(path.join('../..', VECTORMAP_UTILS_PATH, '_settings.json'));
const part = settings['node'];
return gulp.src(settings.commonFiles.concat(part.files).map(transformFileName))
.pipe(concat(part.fileName + '.js'))
.pipe(headerPipes.useStrict())
.pipe(gulp.dest(VECTORMAP_NODE_TMP_PATH));
}

if(!fs.existsSync(VECTORMAP_DATA_RESULT_PATH)) {
fs.mkdirSync(VECTORMAP_DATA_RESULT_PATH);
}
function cleanNodeUtils() {
fs.rmSync(VECTORMAP_NODE_TMP_PATH, { recursive: true, force: true });
}

gulp.task('vectormap-data', gulp.series(buildNodeUtilsForDataGeneration, function generateDataAndCleanup() {
try {
const stream = merge();
const processFiles = require(path.join('../..', VECTORMAP_NODE_TMP_PATH, 'dx.vectormaputils.node.js')).processFiles;

processFiles('build/vectormap-sources', {
output: VECTORMAP_DATA_RESULT_PATH,
settings: 'build/vectormap-sources/_settings.js'
}, function() {
const files = fs.readdirSync(VECTORMAP_DATA_RESULT_PATH);

files.forEach(file => {
const data = fs.readFileSync(path.join(VECTORMAP_DATA_RESULT_PATH, file), 'utf8');

stream.add(
gulp.src('build/gulp/vectormapdata-template.jst')
.pipe(template({ data: data }))
.pipe(rename(file))
.pipe(headerPipes.useStrict())
.pipe(gulp.dest(VECTORMAP_DATA_RESULT_PATH))
);
if(!fs.existsSync(VECTORMAP_DATA_RESULT_PATH)) {
fs.mkdirSync(VECTORMAP_DATA_RESULT_PATH);
}

processFiles('build/vectormap-sources', {
output: VECTORMAP_DATA_RESULT_PATH,
settings: 'build/vectormap-sources/_settings.js'
}, function() {
const files = fs.readdirSync(VECTORMAP_DATA_RESULT_PATH);

files.forEach(file => {
const data = fs.readFileSync(path.join(VECTORMAP_DATA_RESULT_PATH, file), 'utf8');

stream.add(
gulp.src('build/gulp/vectormapdata-template.jst')
.pipe(template({ data: data }))
.pipe(rename(file))
.pipe(headerPipes.useStrict())
.pipe(gulp.dest(VECTORMAP_DATA_RESULT_PATH))
);
});
});
});
return stream;
return stream.on('end', cleanNodeUtils).on('error', cleanNodeUtils);
} catch(e) {
cleanNodeUtils();
throw e;
}
}));

function patchVectorMapUtilsStream(stream, isMinify) {
Expand All @@ -67,20 +85,17 @@ function patchVectorMapUtilsStream(stream, isMinify) {
.pipe(gulp.dest(VECTORMAP_UTILS_RESULT_PATH));
}

function createVectorMapUtilsStream(name, suffix, isMinify) {
function createBrowserVectorMapUtilsStream(suffix, isMinify) {
const settings = require(path.join('../..', VECTORMAP_UTILS_PATH, '_settings.json'));
const part = settings[name];
const part = settings['browser'];
const stream = gulp.src(settings.commonFiles.concat(part.files).map(transformFileName))
.pipe(concat(part.fileName + suffix + '.js'));

if(name === 'browser') {
return stream.pipe(tap(file => {
patchVectorMapUtilsStream(gulp.src('build/gulp/vectormaputils-template.jst')
.pipe(template({ data: file.contents }))
.pipe(rename(path.basename(file.path))), isMinify);
}));
}
return patchVectorMapUtilsStream(stream, isMinify);
return stream.pipe(tap(file => {
patchVectorMapUtilsStream(gulp.src('build/gulp/vectormaputils-template.jst')
.pipe(template({ data: file.contents }))
.pipe(rename(path.basename(file.path))), isMinify);
}));
Comment thread
pharret31 marked this conversation as resolved.
}
Comment thread
pharret31 marked this conversation as resolved.

gulp.task('vectormap', gulp.series('vectormap-utils', 'vectormap-data'));
3 changes: 1 addition & 2 deletions packages/devextreme/ports.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"qunit": "20060",
"vectormap-utils-tester": "20061"
"qunit": "20060"
}
2 changes: 1 addition & 1 deletion packages/devextreme/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@
"{projectRoot}/build/gulp/vectormap.js"
],
"outputs": [
"{projectRoot}/artifacts/js/vectormap-utils",
"{projectRoot}/artifacts/js/vectormap-data"
]
Comment thread
pharret31 marked this conversation as resolved.
},
Expand Down Expand Up @@ -732,7 +733,6 @@
"{projectRoot}/build/gulp/vendor.js"
],
"outputs": [
"{projectRoot}/artifacts/js/vectormap-utils",
"{projectRoot}/artifacts/js/cldr"
]
},
Expand Down
78 changes: 0 additions & 78 deletions packages/devextreme/testing/helpers/vectormaputils-tester.js

This file was deleted.

37 changes: 0 additions & 37 deletions packages/devextreme/testing/runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
parseNumber,
readBodyText,
readFormBody,
resolveNodePath,
safeDecodeURIComponent,
safeReadFile,
splitCommaList,
Expand All @@ -35,7 +34,6 @@ import { createVectorMapService } from './lib/vectormap';
import {
sendHtml,
sendJson,
sendJsonText,
sendNotFound,
sendText,
sendXml,
Expand Down Expand Up @@ -77,9 +75,6 @@ const RUN_FLAGS = {

const PORTS = loadPorts(path.join(PACKAGE_ROOT, 'ports.json'));
const QUNIT_PORT = Number(PORTS.qunit);
const VECTOR_MAP_TESTER_PORT = Number(PORTS['vectormap-utils-tester']);

const PATH_TO_NODE = resolveNodePath();

const logger = createRunnerLogger(RAW_LOG_FILENAME);
const templates = createTemplateRenderer(TEMPLATES_ROOT, escapeHtml);
Expand All @@ -100,10 +95,7 @@ const resultsReporter = createResultsReporter({
});
const vectorMapService = createVectorMapService({
packageRoot: PACKAGE_ROOT,
testingRoot: TESTING_ROOT,
vectorDataDirectory: VECTOR_DATA_DIRECTORY,
vectorMapTesterPort: VECTOR_MAP_TESTER_PORT,
pathToNode: PATH_TO_NODE,
});
const staticFiles = createStaticFileService({
escapeHtml,
Expand Down Expand Up @@ -312,35 +304,6 @@ async function handleRequest(req: http.IncomingMessage, res: http.ServerResponse
return;
}

if (req.method === 'GET') {
const parseBufferMatch = /^\/TestVectorMapData\/ParseBuffer\/(.+)$/i.exec(pathname);
if (parseBufferMatch) {
const id = safeDecodeURIComponent(parseBufferMatch[1]);
const responseText = await vectorMapService.redirectRequestToVectorMapNodeServer('parse-buffer', id);
sendJsonText(res, responseText);
return;
}
}

if (req.method === 'GET') {
const readAndParseMatch = /^\/TestVectorMapData\/ReadAndParse\/(.+)$/i.exec(pathname);
if (readAndParseMatch) {
const id = safeDecodeURIComponent(readAndParseMatch[1]);
const responseText = await vectorMapService.redirectRequestToVectorMapNodeServer('read-and-parse', id);
sendJsonText(res, responseText);
return;
}
}

if (req.method === 'GET') {
const executeConsoleAppMatch = /^\/TestVectorMapData\/ExecuteConsoleApp(?:\/(.*))?$/i.exec(pathname);
if (executeConsoleAppMatch) {
const result = vectorMapService.executeVectorMapConsoleApp(requestUrl.searchParams);
sendJson(res, result);
return;
}
}

if (staticFiles.tryServeStatic(req, res, pathname, requestUrl.searchParams)) {
return;
}
Expand Down
7 changes: 0 additions & 7 deletions packages/devextreme/testing/runner/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,9 @@ export interface VectorMapDataItem {
expected: string;
}

export interface VectorMapOutputItem {
file: string;
variable: string | null;
content: JsonValue;
}

export interface PortsMap {
[key: string]: number | string;
qunit: number | string;
'vectormap-utils-tester': number | string;
}

export type TemplateVarValue = JsonValue | bigint | undefined;
Expand Down
3 changes: 1 addition & 2 deletions packages/devextreme/testing/runner/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ export function loadPorts(filePath: string): PortsMap {
throw new Error(`Invalid ports definition: ${filePath}`);
}

if (!isPortValue(parsed.qunit) || !isPortValue(parsed['vectormap-utils-tester'])) {
if (!isPortValue(parsed.qunit)) {
throw new Error(`Required ports are missing in ${filePath}`);
}

const portsMap: PortsMap = {
qunit: parsed.qunit,
'vectormap-utils-tester': parsed['vectormap-utils-tester'],
};

Object.entries(parsed).forEach(([key, value]) => {
Expand Down
Loading
Loading