Skip to content

Commit

Permalink
esModuleInterop: true
Browse files Browse the repository at this point in the history
  • Loading branch information
semd committed Jun 13, 2024
1 parent 3a71031 commit 939a908
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@
* 2.0.
*/

import { join as joinPath } from 'path';
import type { InputTypes } from '../../common';
import { resolve as resolvePath } from 'path';
import type { InputType } from '../../common';
import { ensureDirSync, createSync, readSync } from '../util';

export function createAgentInput(specificDataStreamDir: string, inputTypes: InputTypes[]): void {
const agentDir = joinPath(specificDataStreamDir, 'agent', 'stream');
const agentTemplatesDir = joinPath(__dirname, '../templates/agent');
export function createAgentInput(specificDataStreamDir: string, inputTypes: InputType[]): void {
const agentDir = resolvePath(specificDataStreamDir, 'agent', 'stream');
const agentTemplatesDir = resolvePath(__dirname, '../templates/agent');
ensureDirSync(agentDir);

// Load common options that exists for all .yml.hbs files, to be merged with each specific input file
const commonFilePath = joinPath(agentTemplatesDir, 'common.yml.hbs');
const commonFilePath = resolvePath(agentTemplatesDir, 'common.yml.hbs');
const commonFile = readSync(commonFilePath);

for (const inputType of inputTypes) {
const inputTypeFilePath = joinPath(
const inputTypeFilePath = resolvePath(
agentTemplatesDir,
`${inputType.replaceAll('-', '_')}.yml.hbs`
);
const inputTypeFile = readSync(inputTypeFilePath);

const combinedContents = `${inputTypeFile}\n${commonFile}`;

const destinationFilePath = joinPath(agentDir, `${inputType}.yml.hbs`);
const destinationFilePath = resolvePath(agentDir, `${inputType}.yml.hbs`);
createSync(destinationFilePath, combinedContents);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import nunjucks from 'nunjucks';
import { join as joinPath } from 'path';
import { resolve as resolvePath } from 'path';
import type { DataStream } from '../../common';
import { copySync, createSync, ensureDirSync, listDirSync } from '../util';

Expand All @@ -16,7 +16,7 @@ export function createDatastream(
dataStream: DataStream
): void {
const dataStreamName = dataStream.name;
const pipelineDir = joinPath(specificDataStreamDir, 'elasticsearch', 'ingest_pipeline');
const pipelineDir = resolvePath(specificDataStreamDir, 'elasticsearch', 'ingest_pipeline');
const title = dataStream.title;
const description = dataStream.description;

Expand Down Expand Up @@ -57,16 +57,16 @@ export function createDatastream(
data_streams: dataStreams,
});

createSync(joinPath(specificDataStreamDir, 'manifest.yml'), finalManifest);
createSync(resolvePath(specificDataStreamDir, 'manifest.yml'), finalManifest);
}

function createDataStreamFolders(specificDataStreamDir: string, pipelineDir: string): void {
const dataStreamTemplatesDir = joinPath(__dirname, '../templates/data_stream');
const dataStreamTemplatesDir = resolvePath(__dirname, '../templates/data_stream');
const items = listDirSync(dataStreamTemplatesDir);

for (const item of items) {
const s = joinPath(dataStreamTemplatesDir, item);
const d = joinPath(specificDataStreamDir, item);
const s = resolvePath(dataStreamTemplatesDir, item);
const d = resolvePath(specificDataStreamDir, item);
copySync(s, d);
}

Expand All @@ -79,18 +79,18 @@ function createPipelineTests(
packageName: string,
dataStreamName: string
): void {
const pipelineTestTemplatesDir = joinPath(__dirname, '../templates/pipeline_tests');
const pipelineTestsDir = joinPath(specificDataStreamDir, '_dev/test/pipeline');
const pipelineTestTemplatesDir = resolvePath(__dirname, '../templates/pipeline_tests');
const pipelineTestsDir = resolvePath(specificDataStreamDir, '_dev/test/pipeline');
ensureDirSync(pipelineTestsDir);
const items = listDirSync(pipelineTestTemplatesDir);
for (const item of items) {
const s = joinPath(pipelineTestTemplatesDir, item);
const d = joinPath(pipelineTestsDir, item.replaceAll('_', '-'));
const s = resolvePath(pipelineTestTemplatesDir, item);
const d = resolvePath(pipelineTestsDir, item.replaceAll('_', '-'));
copySync(s, d);
}
const formattedPackageName = packageName.replace(/_/g, '-');
const formattedDataStreamName = dataStreamName.replace(/_/g, '-');
const testFileName = joinPath(
const testFileName = resolvePath(
pipelineTestsDir,
`test-${formattedPackageName}-${formattedDataStreamName}.log`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* 2.0.
*/

import { join as joinPath } from 'path';
import { resolve as resolvePath } from 'path';
import nunjucks from 'nunjucks';
import type { Integration } from '../../common';
import { ensureDirSync, createSync } from '../util';

export function createPackageSystemTests(integrationDir: string, integration: Integration) {
const systemTestsDockerDir = joinPath(integrationDir, '_dev/deploy/docker/');
const systemTestsSamplesDir = joinPath(systemTestsDockerDir, 'sample_logs');
const systemTestsDockerDir = resolvePath(integrationDir, '_dev/deploy/docker/');
const systemTestsSamplesDir = resolvePath(systemTestsDockerDir, 'sample_logs');
ensureDirSync(systemTestsSamplesDir);

const streamVersion = '0.13.0';
Expand All @@ -22,7 +22,7 @@ export function createPackageSystemTests(integrationDir: string, integration: In
const packageName = integration.name.replace(/_/g, '-');
const dataStreamName = stream.name.replace(/_/g, '-');

const systemTestFileName = joinPath(
const systemTestFileName = resolvePath(
systemTestsSamplesDir,
`test-${packageName}-${dataStreamName}.log`
);
Expand All @@ -48,6 +48,6 @@ export function createPackageSystemTests(integrationDir: string, integration: In
docker_compose_version: dockerComposeVersion,
});

const dockerComposeFileName = joinPath(systemTestsDockerDir, 'docker-compose.yml');
const dockerComposeFileName = resolvePath(systemTestsDockerDir, 'docker-compose.yml');
createSync(dockerComposeFileName, renderedDockerCompose);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { join as joinPath } from 'path';
import { resolve as resolvePath } from 'path';
import yaml from 'js-yaml';
import { createSync } from '../util';

export function createPipeline(specificDataStreamDir: string, pipeline: object): void {
const filePath = joinPath(specificDataStreamDir, 'elasticsearch/ingest_pipeline/default.yml');
const filePath = resolvePath(specificDataStreamDir, 'elasticsearch/ingest_pipeline/default.yml');
const yamlContent = `---\n${yaml.dump(pipeline, { sortKeys: false })}`;
createSync(filePath, yamlContent);
}
5 changes: 4 additions & 1 deletion x-pack/plugins/integration_assistant/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types"
"outDir": "target/types",
"esModuleInterop": true
},
"assets": ["**/*.njk"],
"include": [
"index.ts",
"server/**/*",
"server/**/*.njk",
"common/**/*",
"public/**/*",
"__jest__/**/*",
Expand Down

0 comments on commit 939a908

Please sign in to comment.