Skip to content

Commit

Permalink
[src/dev/build] typescript-ify and convert tests to jest
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Jul 21, 2020
1 parent c3bd7ae commit ecaa965
Show file tree
Hide file tree
Showing 93 changed files with 2,413 additions and 2,266 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@
"@types/accept": "3.1.1",
"@types/angular": "^1.6.56",
"@types/angular-mocks": "^1.7.0",
"@types/archiver": "^3.1.0",
"@types/babel__core": "^7.1.2",
"@types/bluebird": "^3.1.1",
"@types/boom": "^7.2.0",
Expand Down Expand Up @@ -397,6 +398,7 @@
"@types/testing-library__react-hooks": "^3.1.0",
"@types/type-detect": "^4.0.1",
"@types/uuid": "^3.4.4",
"@types/vinyl": "^2.0.4",
"@types/vinyl-fs": "^2.4.11",
"@types/zen-observable": "^0.8.0",
"@typescript-eslint/eslint-plugin": "^2.34.0",
Expand Down Expand Up @@ -473,6 +475,7 @@
"license-checker": "^16.0.0",
"listr": "^0.14.1",
"load-grunt-config": "^3.0.1",
"load-json-file": "^6.2.0",
"mocha": "^7.1.1",
"mock-fs": "^4.12.0",
"mock-http-server": "1.3.0",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"normalize-path": "^3.0.0",
"moment": "^2.24.0",
"rxjs": "^6.5.5",
"strip-ansi": "^6.0.0",
"tree-kill": "^1.2.2",
"tslib": "^2.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-dev-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

export { withProcRunner, ProcRunner } from './proc_runner';
export * from './tooling_log';
export { createAbsolutePathSerializer } from './serializers';
export * from './serializers';
export {
CA_CERT_PATH,
ES_KEY_PATH,
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-dev-utils/src/serializers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
* under the License.
*/

export { createAbsolutePathSerializer } from './absolute_path_serializer';
export * from './absolute_path_serializer';
export * from './strip_ansi_serializer';
27 changes: 27 additions & 0 deletions packages/kbn-dev-utils/src/serializers/strip_ansi_serializer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import stripAnsi from 'strip-ansi';

export function createStripAnsiSerializer() {
return {
test: (value: any) => typeof value === 'string' && stripAnsi(value) !== value,
serialize: stripAnsi,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export * from './run';
export * from './src/index';
1 change: 1 addition & 0 deletions packages/kbn-pm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"include": [
"./index.d.ts",
"./src/**/*.ts",
"./dist/*.d.ts",
],
Expand Down
240 changes: 120 additions & 120 deletions src/dev/build/args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,148 +29,148 @@ const fn = (...subArgs: string[]) => {

it('renders help if `--help` passed', () => {
expect(fn('--help')).toMatchInlineSnapshot(`
Object {
"log": "undefined",
"showHelp": true,
"unknownFlags": Array [],
}
`);
Object {
"log": "<ToolingLog>",
"showHelp": true,
"unknownFlags": Array [],
}
`);
});

it('build default and oss dist for current platform, without packages, by default', () => {
expect(fn()).toMatchInlineSnapshot(`
Object {
"buildArgs": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerPackage": false,
"createDockerUbiPackage": false,
"createRpmPackage": false,
"downloadFreshNode": true,
"isRelease": false,
"targetAllPlatforms": false,
"versionQualifier": "",
},
"log": "<ToolingLog>",
"showHelp": false,
"unknownFlags": Array [],
}
`);
Object {
"buildArgs": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerPackage": false,
"createDockerUbiPackage": false,
"createRpmPackage": false,
"downloadFreshNode": true,
"isRelease": false,
"targetAllPlatforms": false,
"versionQualifier": "",
},
"log": "<ToolingLog>",
"showHelp": false,
"unknownFlags": Array [],
}
`);
});

it('builds packages if --all-platforms is passed', () => {
expect(fn('--all-platforms')).toMatchInlineSnapshot(`
Object {
"buildArgs": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": true,
"createDockerPackage": true,
"createDockerUbiPackage": true,
"createRpmPackage": true,
"downloadFreshNode": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
},
"log": "<ToolingLog>",
"showHelp": false,
"unknownFlags": Array [],
}
`);
Object {
"buildArgs": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": true,
"createDockerPackage": true,
"createDockerUbiPackage": true,
"createRpmPackage": true,
"downloadFreshNode": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
},
"log": "<ToolingLog>",
"showHelp": false,
"unknownFlags": Array [],
}
`);
});

it('limits packages if --rpm passed with --all-platforms', () => {
expect(fn('--all-platforms', '--rpm')).toMatchInlineSnapshot(`
Object {
"buildArgs": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerPackage": false,
"createDockerUbiPackage": false,
"createRpmPackage": true,
"downloadFreshNode": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
},
"log": "<ToolingLog>",
"showHelp": false,
"unknownFlags": Array [],
}
`);
Object {
"buildArgs": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerPackage": false,
"createDockerUbiPackage": false,
"createRpmPackage": true,
"downloadFreshNode": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
},
"log": "<ToolingLog>",
"showHelp": false,
"unknownFlags": Array [],
}
`);
});

it('limits packages if --deb passed with --all-platforms', () => {
expect(fn('--all-platforms', '--deb')).toMatchInlineSnapshot(`
Object {
"buildArgs": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": true,
"createDockerPackage": false,
"createDockerUbiPackage": false,
"createRpmPackage": false,
"downloadFreshNode": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
},
"log": "<ToolingLog>",
"showHelp": false,
"unknownFlags": Array [],
}
`);
Object {
"buildArgs": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": true,
"createDockerPackage": false,
"createDockerUbiPackage": false,
"createRpmPackage": false,
"downloadFreshNode": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
},
"log": "<ToolingLog>",
"showHelp": false,
"unknownFlags": Array [],
}
`);
});

it('limits packages if --docker passed with --all-platforms', () => {
expect(fn('--all-platforms', '--docker')).toMatchInlineSnapshot(`
Object {
"buildArgs": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerPackage": true,
"createDockerUbiPackage": true,
"createRpmPackage": false,
"downloadFreshNode": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
},
"log": "<ToolingLog>",
"showHelp": false,
"unknownFlags": Array [],
}
`);
Object {
"buildArgs": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerPackage": true,
"createDockerUbiPackage": true,
"createRpmPackage": false,
"downloadFreshNode": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
},
"log": "<ToolingLog>",
"showHelp": false,
"unknownFlags": Array [],
}
`);
});

it('limits packages if --docker passed with --skip-docker-ubi and --all-platforms', () => {
expect(fn('--all-platforms', '--docker', '--skip-docker-ubi')).toMatchInlineSnapshot(`
Object {
"buildArgs": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerPackage": true,
"createDockerUbiPackage": false,
"createRpmPackage": false,
"downloadFreshNode": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
},
"log": "<ToolingLog>",
"showHelp": false,
"unknownFlags": Array [],
}
`);
Object {
"buildArgs": Object {
"buildDefaultDist": true,
"buildOssDist": true,
"createArchives": true,
"createDebPackage": false,
"createDockerPackage": true,
"createDockerUbiPackage": false,
"createRpmPackage": false,
"downloadFreshNode": true,
"isRelease": false,
"targetAllPlatforms": true,
"versionQualifier": "",
},
"log": "<ToolingLog>",
"showHelp": false,
"unknownFlags": Array [],
}
`);
});
Loading

0 comments on commit ecaa965

Please sign in to comment.