@datadog/datadog-ci 3.3.0 → 3.4.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/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/dora/__tests__/deployment.test.js +2 -0
- package/dist/commands/dora/__tests__/deployment.test.js.map +1 -1
- package/dist/commands/dora/api.js +3 -0
- package/dist/commands/dora/api.js.map +1 -1
- package/dist/commands/dora/deployment.d.ts +1 -0
- package/dist/commands/dora/deployment.js +8 -1
- package/dist/commands/dora/deployment.js.map +1 -1
- package/dist/commands/dora/interfaces.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js +2 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js.map +1 -1
- package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js +4 -0
- package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js.map +1 -1
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +3 -0
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.js.map +1 -1
- package/dist/commands/lambda/__tests__/instrument.test.js +7 -0
- package/dist/commands/lambda/__tests__/instrument.test.js.map +1 -1
- package/dist/commands/lambda/__tests__/uninstrument.test.js +3 -0
- package/dist/commands/lambda/__tests__/uninstrument.test.js.map +1 -1
- package/dist/commands/lambda/constants.d.ts +3 -0
- package/dist/commands/lambda/constants.js +5 -2
- package/dist/commands/lambda/constants.js.map +1 -1
- package/dist/commands/lambda/functions/instrument.js +10 -0
- package/dist/commands/lambda/functions/instrument.js.map +1 -1
- package/dist/commands/lambda/functions/uninstrument.js +3 -0
- package/dist/commands/lambda/functions/uninstrument.js.map +1 -1
- package/dist/commands/lambda/instrument.d.ts +1 -0
- package/dist/commands/lambda/instrument.js +5 -2
- package/dist/commands/lambda/instrument.js.map +1 -1
- package/dist/commands/lambda/interfaces.d.ts +3 -0
- package/dist/commands/react-native/__tests__/codepush.test.js +35 -0
- package/dist/commands/react-native/__tests__/codepush.test.js.map +1 -1
- package/dist/commands/react-native/__tests__/utils.test.js +42 -0
- package/dist/commands/react-native/__tests__/utils.test.js.map +1 -1
- package/dist/commands/react-native/codepush.js +7 -2
- package/dist/commands/react-native/codepush.js.map +1 -1
- package/dist/commands/react-native/utils.d.ts +1 -0
- package/dist/commands/react-native/utils.js +5 -1
- package/dist/commands/react-native/utils.js.map +1 -1
- package/dist/commands/sbom/__tests__/payload.test.js +45 -15
- package/dist/commands/sbom/__tests__/payload.test.js.map +1 -1
- package/dist/commands/sbom/__tests__/validation.test.js +4 -0
- package/dist/commands/sbom/__tests__/validation.test.js.map +1 -1
- package/dist/commands/sbom/constants.d.ts +1 -2
- package/dist/commands/sbom/constants.js +2 -4
- package/dist/commands/sbom/constants.js.map +1 -1
- package/dist/commands/sbom/payload.js +69 -3
- package/dist/commands/sbom/payload.js.map +1 -1
- package/dist/commands/sbom/types.d.ts +13 -0
- package/dist/commands/span/__tests__/span.test.d.ts +1 -0
- package/dist/commands/span/__tests__/span.test.js +108 -0
- package/dist/commands/span/__tests__/span.test.js.map +1 -0
- package/dist/commands/span/cli.d.ts +1 -0
- package/dist/commands/span/cli.js +5 -0
- package/dist/commands/span/cli.js.map +1 -0
- package/dist/commands/span/span.d.ts +10 -0
- package/dist/commands/span/span.js +112 -0
- package/dist/commands/span/span.js.map +1 -0
- package/dist/commands/synthetics/__tests__/build-and-test.test.js +63 -105
- package/dist/commands/synthetics/__tests__/build-and-test.test.js.map +1 -1
- package/dist/commands/synthetics/build-and-test.d.ts +20 -3
- package/dist/commands/synthetics/build-and-test.js +180 -66
- package/dist/commands/synthetics/build-and-test.js.map +1 -1
- package/dist/commands/synthetics/run-tests-command.js +5 -2
- package/dist/commands/synthetics/run-tests-command.js.map +1 -1
- package/dist/commands/synthetics/utils/internal.d.ts +0 -2
- package/dist/commands/synthetics/utils/internal.js +1 -15
- package/dist/commands/synthetics/utils/internal.js.map +1 -1
- package/dist/commands/trace/__tests__/trace.test.js +3 -100
- package/dist/commands/trace/__tests__/trace.test.js.map +1 -1
- package/dist/commands/trace/helper.d.ts +16 -0
- package/dist/commands/trace/helper.js +123 -0
- package/dist/commands/trace/helper.js.map +1 -0
- package/dist/commands/trace/test-utils.d.ts +1 -0
- package/dist/commands/trace/test-utils.js +119 -0
- package/dist/commands/trace/test-utils.js.map +1 -0
- package/dist/commands/trace/trace.d.ts +2 -12
- package/dist/commands/trace/trace.js +14 -93
- package/dist/commands/trace/trace.js.map +1 -1
- package/dist/helpers/__tests__/flare.test.js +2 -1
- package/dist/helpers/__tests__/flare.test.js.map +1 -1
- package/dist/helpers/ci.d.ts +2 -2
- package/dist/helpers/flare.js +2 -1
- package/dist/helpers/flare.js.map +1 -1
- package/dist/helpers/interfaces.d.ts +2 -3
- package/dist/helpers/tags.d.ts +2 -0
- package/dist/helpers/tags.js +4 -1
- package/dist/helpers/tags.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,103 +8,84 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
9
|
});
|
|
33
10
|
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
const http = __importStar(require("http"));
|
|
39
|
-
const axios_1 = __importDefault(require("axios"));
|
|
40
12
|
const build_and_test_1 = require("../build-and-test");
|
|
41
13
|
const fixtures_1 = require("./fixtures");
|
|
42
14
|
const NODE_COMMAND = process.execPath;
|
|
43
|
-
describe('build-and-test -
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
15
|
+
describe('build-and-test - buildAssets', () => {
|
|
16
|
+
const tearDowns = [];
|
|
17
|
+
afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
for (let tearDown; (tearDown = tearDowns.pop());) {
|
|
19
|
+
yield tearDown();
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
// This httpClient function should be self-contained, as its body will be injected as a string in the build command.
|
|
23
|
+
const httpClient = () => {
|
|
24
|
+
const url = process.env.DATADOG_SYNTHETICS_REPORT_BUILD_URL;
|
|
25
|
+
if (!url) {
|
|
26
|
+
throw new Error('DATADOG_SYNTHETICS_REPORT_BUILD_URL is not set');
|
|
27
|
+
}
|
|
28
|
+
void fetch(url, {
|
|
29
|
+
method: 'POST',
|
|
30
|
+
headers: {
|
|
31
|
+
'Content-Type': 'application/json',
|
|
32
|
+
},
|
|
33
|
+
body: JSON.stringify({
|
|
34
|
+
outputDirectory: 'output-directory',
|
|
35
|
+
publicPath: 'prefix/',
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
};
|
|
48
39
|
test('alert when the build-plugin is not configured', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
40
|
// Given a build command without the build plugin configured
|
|
50
41
|
const MOCKED_BUILD_COMMAND_NOT_CONFIGURED = `${NODE_COMMAND} -e "console.log('build successful')"`;
|
|
51
42
|
// When calling spawnBuildPluginDevServer
|
|
52
|
-
const commandPromise = (0, build_and_test_1.
|
|
43
|
+
const commandPromise = (0, build_and_test_1.buildAssets)(MOCKED_BUILD_COMMAND_NOT_CONFIGURED, fixtures_1.mockReporter);
|
|
53
44
|
// Then it should throw when the command exits.
|
|
54
45
|
yield expect(commandPromise).rejects.toThrow(build_and_test_1.UnconfiguredBuildPluginError);
|
|
55
46
|
}));
|
|
56
|
-
test('
|
|
57
|
-
// Given a
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const httpDevServer = () => {
|
|
61
|
-
setTimeout(() => {
|
|
62
|
-
http
|
|
63
|
-
.createServer((_, res) => res
|
|
64
|
-
.writeHead(200, {
|
|
65
|
-
'Content-Type': 'application/json',
|
|
66
|
-
})
|
|
67
|
-
.end(JSON.stringify({
|
|
68
|
-
status: 'success',
|
|
69
|
-
publicPrefix: 'prefix2/',
|
|
70
|
-
})))
|
|
71
|
-
.listen(process.env.BUILD_PLUGINS_S8S_PORT);
|
|
72
|
-
}, 500);
|
|
73
|
-
};
|
|
74
|
-
const SERVER_IMPLEMENTATION = httpDevServer.toString().replace(/\n\s+/g, '');
|
|
75
|
-
const MOCKED_BUILD_COMMAND = `${NODE_COMMAND} -e "(${SERVER_IMPLEMENTATION})()"`;
|
|
47
|
+
test('advertise the right URL and returns the reported builds', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
// Given a build command which reports a build with a publicPath and an outputDirectory to the url advertised by DATADOG_SYNTHETICS_REPORT_BUILD_URL
|
|
49
|
+
const CLIENT_IMPLEMENTATION = httpClient.toString().replace(/\n\s+/g, '');
|
|
50
|
+
const MOCKED_BUILD_COMMAND = `${NODE_COMMAND} -e "(${CLIENT_IMPLEMENTATION})()"`;
|
|
76
51
|
// When calling spawnBuildPluginDevServer
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
yield command.stop();
|
|
88
|
-
}));
|
|
89
|
-
test('should wait for dev server even if the build fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
-
// Set up axios response sequence
|
|
91
|
-
jest
|
|
92
|
-
.spyOn(axios_1.default, 'get')
|
|
93
|
-
.mockRejectedValueOnce({ code: 'ECONNREFUSED' }) // First attempt: connection refused
|
|
94
|
-
.mockResolvedValueOnce({ data: { status: 'fail' } }) // Second attempt: build failed
|
|
95
|
-
.mockResolvedValueOnce({ data: { status: 'success', publicPrefix: 'prefix3/' } }); // Third attempt: success
|
|
96
|
-
// Setup isAxiosError for ECONNREFUSED error
|
|
97
|
-
jest.spyOn(axios_1.default, 'isAxiosError').mockImplementation((error) => {
|
|
98
|
-
return error && error.code === 'ECONNREFUSED';
|
|
99
|
-
});
|
|
100
|
-
// When calling spawnBuildPluginDevServer with any command
|
|
101
|
-
const MOCKED_BUILD_COMMAND = `${NODE_COMMAND} -e "setTimeout(() => {}, 100000)"`;
|
|
102
|
-
const command = yield (0, build_and_test_1.spawnBuildPluginDevServer)(MOCKED_BUILD_COMMAND, fixtures_1.mockReporter);
|
|
103
|
-
// Then it should wait until the build succeeds
|
|
104
|
-
expect(command.devServerUrl).toBe('http://localhost:4000');
|
|
105
|
-
expect(command.publicPrefix).toBe('prefix3/');
|
|
106
|
-
// Verify the axios GET was called multiple times
|
|
107
|
-
expect(axios_1.default.get).toHaveBeenCalledTimes(3);
|
|
108
|
-
// Stop the command at the end of the test.
|
|
109
|
-
yield command.stop();
|
|
52
|
+
const { builds, devServerUrl, stop } = yield (0, build_and_test_1.buildAssets)(MOCKED_BUILD_COMMAND, fixtures_1.mockReporter);
|
|
53
|
+
tearDowns.push(stop);
|
|
54
|
+
// Then it should return the devServerUrl and the path prefix.
|
|
55
|
+
expect(devServerUrl).toMatch(/\/_datadog-ci_\/build$/);
|
|
56
|
+
expect(builds).toEqual([
|
|
57
|
+
{
|
|
58
|
+
outputDirectory: 'output-directory',
|
|
59
|
+
publicPath: 'prefix/',
|
|
60
|
+
},
|
|
61
|
+
]);
|
|
110
62
|
}));
|
|
111
|
-
test('
|
|
112
|
-
//
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
63
|
+
test('rejects malformed builds', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
// Given the devServer to which to report builds
|
|
65
|
+
const CLIENT_IMPLEMENTATION = httpClient.toString().replace(/\n\s+/g, '');
|
|
66
|
+
const MOCKED_BUILD_COMMAND = `${NODE_COMMAND} -e "(${CLIENT_IMPLEMENTATION})()"`;
|
|
67
|
+
const { devServerUrl, stop } = yield (0, build_and_test_1.buildAssets)(MOCKED_BUILD_COMMAND, fixtures_1.mockReporter);
|
|
68
|
+
tearDowns.push(stop);
|
|
69
|
+
// When sending a malformed build
|
|
70
|
+
const correctPayload = {
|
|
71
|
+
method: 'POST',
|
|
72
|
+
headers: {
|
|
73
|
+
'Content-Type': 'application/json',
|
|
74
|
+
},
|
|
75
|
+
body: {
|
|
76
|
+
outputDirectory: 'output-directory',
|
|
77
|
+
publicPath: 'prefix/',
|
|
119
78
|
},
|
|
120
79
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
yield expect(commandPromise).rejects.toThrow('Dev server returned error: 500 Internal Server Error');
|
|
80
|
+
const [missingOutputDirectory, missingPublicPath] = yield Promise.all([
|
|
81
|
+
fetch(devServerUrl, Object.assign(Object.assign({}, correctPayload), { body: JSON.stringify(Object.assign(Object.assign({}, correctPayload.body), { outputDirectory: undefined })) })),
|
|
82
|
+
fetch(devServerUrl, Object.assign(Object.assign({}, correctPayload), { body: JSON.stringify(Object.assign(Object.assign({}, correctPayload.body), { publicPath: undefined })) })),
|
|
83
|
+
]);
|
|
84
|
+
// Then it should reject the malformed builds reported.
|
|
85
|
+
expect(missingOutputDirectory.status).toBe(500);
|
|
86
|
+
expect(yield missingOutputDirectory.text()).toBe(`Internal Server Error: ${build_and_test_1.MalformedBuildError.message}`);
|
|
87
|
+
expect(missingPublicPath.status).toBe(500);
|
|
88
|
+
expect(yield missingPublicPath.text()).toBe(`Internal Server Error: ${build_and_test_1.MalformedBuildError.message}`);
|
|
131
89
|
}));
|
|
132
90
|
});
|
|
133
91
|
//# sourceMappingURL=build-and-test.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-and-test.test.js","sourceRoot":"","sources":["../../../../src/commands/synthetics/__tests__/build-and-test.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-and-test.test.js","sourceRoot":"","sources":["../../../../src/commands/synthetics/__tests__/build-and-test.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sDAAgG;AAEhG,yCAAuC;AAEvC,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAA;AAErC,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,MAAM,SAAS,GAA4B,EAAE,CAAA;IAC7C,SAAS,CAAC,GAAS,EAAE;QACnB,KAA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Ac,CAAC,IAAI,KAAE,UAAU,EAAE,SAAS,IAAE,IACrE;SACH,CAAC,CAAA;QAEF,uDAAuD;QACvD,MAAM,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC/C,MAAM,CAAC,MAAM,sBAAsB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,0BAA0B,oCAAmB,CAAC,OAAO,EAAE,CAAC,CAAA;QAEzG,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC1C,MAAM,CAAC,MAAM,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,0BAA0B,oCAAmB,CAAC,OAAO,EAAE,CAAC,CAAA;IACtG,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as http from 'http';
|
|
1
3
|
import { MainReporter } from './interfaces';
|
|
2
|
-
|
|
4
|
+
interface ReportedBuild {
|
|
5
|
+
outputDirectory: string;
|
|
6
|
+
publicPath: string;
|
|
7
|
+
}
|
|
3
8
|
export declare const UnconfiguredBuildPluginError: Error;
|
|
4
|
-
export declare const
|
|
9
|
+
export declare const MalformedBuildError: Error;
|
|
10
|
+
declare const routeVerbs: readonly ["get", "post", "put", "patch", "delete"];
|
|
11
|
+
type RouteVerb = typeof routeVerbs[number];
|
|
12
|
+
export type Routes = Record<string, {
|
|
13
|
+
[key in RouteVerb]?: (req: http.IncomingMessage, res: http.ServerResponse) => Promise<void>;
|
|
14
|
+
}>;
|
|
15
|
+
export type RequestHandlerOptions = {
|
|
16
|
+
builds: ReportedBuild[];
|
|
17
|
+
root?: string;
|
|
18
|
+
routes?: Routes;
|
|
19
|
+
};
|
|
20
|
+
export declare const buildAssets: (buildCommand: string, reporter: MainReporter) => Promise<{
|
|
21
|
+
builds: ReportedBuild[];
|
|
5
22
|
devServerUrl: string;
|
|
6
|
-
publicPrefix: string;
|
|
7
23
|
stop: () => Promise<void>;
|
|
8
24
|
}>;
|
|
25
|
+
export {};
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,95 +31,186 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
32
|
});
|
|
10
33
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
35
|
+
exports.buildAssets = exports.MalformedBuildError = exports.UnconfiguredBuildPluginError = void 0;
|
|
16
36
|
const child_process_1 = require("child_process");
|
|
17
37
|
const events_1 = require("events");
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
38
|
+
const fs_1 = require("fs");
|
|
39
|
+
const http = __importStar(require("http"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const REPORT_BUILD_PATHNAME = '/_datadog-ci_/build';
|
|
21
42
|
exports.UnconfiguredBuildPluginError = new Error(`
|
|
22
43
|
We couldn't detect the Datadog Build plugins within your build. Did you add it?
|
|
23
44
|
If not, you can learn more about it here: https://github.com/DataDog/build-plugins#readme
|
|
24
45
|
`);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
46
|
+
exports.MalformedBuildError = new Error(`Invalid payload. Expected payload is {\"outputDirectory\": string, \"publicPath\": string}`);
|
|
47
|
+
const MIME_TYPES = {
|
|
48
|
+
default: 'application/octet-stream',
|
|
49
|
+
html: 'text/html; charset=UTF-8',
|
|
50
|
+
js: 'application/javascript',
|
|
51
|
+
css: 'text/css',
|
|
52
|
+
png: 'image/png',
|
|
53
|
+
jpg: 'image/jpg',
|
|
54
|
+
gif: 'image/gif',
|
|
55
|
+
ico: 'image/x-icon',
|
|
56
|
+
svg: 'image/svg+xml',
|
|
57
|
+
};
|
|
58
|
+
const isMIMEType = (mime) => {
|
|
59
|
+
return Object.keys(MIME_TYPES).includes(mime);
|
|
60
|
+
};
|
|
61
|
+
const routeVerbs = ['get', 'post', 'put', 'patch', 'delete'];
|
|
62
|
+
const isRouteVerb = (verb) => {
|
|
63
|
+
return routeVerbs.includes(verb);
|
|
64
|
+
};
|
|
65
|
+
const fileExists = (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
try {
|
|
67
|
+
yield fs_1.promises.access(filePath);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
catch (_a) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const prepareFile = (root = process.cwd(), builds, requestUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
const staticPath = path.isAbsolute(root) ? root : path.resolve(process.cwd(), root);
|
|
76
|
+
for (const build of builds) {
|
|
77
|
+
if (requestUrl.startsWith(build.publicPath)) {
|
|
78
|
+
const url = new URL(requestUrl, 'http://127.0.0.1');
|
|
79
|
+
const filePath = path.join(path.resolve(staticPath, build.outputDirectory), // absolute path to the assets directory
|
|
80
|
+
path.relative(build.publicPath, url.pathname), // relative path to the file
|
|
81
|
+
url.pathname.endsWith('/') ? 'index.html' : '' // add index.html if the path ends with a slash
|
|
82
|
+
);
|
|
83
|
+
// Verify path is within the intended directory
|
|
84
|
+
const directDescendant = filePath.startsWith(path.resolve(staticPath, build.outputDirectory));
|
|
85
|
+
// Check if the file exists (only if it's withing the intended directory)
|
|
86
|
+
const found = directDescendant && (yield fileExists(filePath));
|
|
87
|
+
if (directDescendant && found) {
|
|
31
88
|
return {
|
|
32
|
-
|
|
33
|
-
|
|
89
|
+
found: true,
|
|
90
|
+
ext: path.extname(filePath).substring(1).toLowerCase(),
|
|
91
|
+
content: yield fs_1.promises.readFile(filePath, { encoding: 'utf-8' }),
|
|
34
92
|
};
|
|
35
93
|
}
|
|
36
94
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
found: false,
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
const getRequestHandler = ({ builds, root, routes }) => (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
+
var _b, _c;
|
|
102
|
+
try {
|
|
103
|
+
// Handle routes.
|
|
104
|
+
const route = routes === null || routes === void 0 ? void 0 : routes[req.url || '/'];
|
|
105
|
+
if (route) {
|
|
106
|
+
const verb = (_c = (_b = req.method) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : '';
|
|
107
|
+
if (isRouteVerb(verb)) {
|
|
108
|
+
const handler = route[verb];
|
|
109
|
+
if (handler) {
|
|
110
|
+
yield handler(req, res);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
44
113
|
}
|
|
45
|
-
// Otherwise ignore errors and continue polling in case the dev server is still starting
|
|
46
114
|
}
|
|
47
|
-
|
|
115
|
+
// Fallback to files.
|
|
116
|
+
const file = yield prepareFile(root, builds, req.url || '/');
|
|
117
|
+
if (file.found) {
|
|
118
|
+
const mimeType = isMIMEType(file.ext) ? MIME_TYPES[file.ext] : MIME_TYPES.default;
|
|
119
|
+
res.writeHead(200, { 'Content-Type': mimeType });
|
|
120
|
+
res.end(file.content);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
res.writeHead(404);
|
|
124
|
+
res.end();
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
128
|
+
res.writeHead(500, { 'Content-Type': MIME_TYPES.html });
|
|
129
|
+
res.end(`Internal Server Error: ${errorMessage}`);
|
|
130
|
+
}
|
|
48
131
|
});
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
132
|
+
const getRequestBody = (req) => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
+
const chunks = [];
|
|
134
|
+
req.on('data', (chunk) => chunks.push(chunk));
|
|
135
|
+
yield (0, events_1.once)(req, 'end');
|
|
136
|
+
return chunks.join('');
|
|
54
137
|
});
|
|
55
|
-
const
|
|
56
|
-
const
|
|
138
|
+
const getReportedBuild = (payload) => {
|
|
139
|
+
const reportedBuild = JSON.parse(payload);
|
|
140
|
+
if ('outputDirectory' in reportedBuild &&
|
|
141
|
+
typeof reportedBuild.outputDirectory === 'string' &&
|
|
142
|
+
'publicPath' in reportedBuild &&
|
|
143
|
+
typeof reportedBuild.publicPath === 'string') {
|
|
144
|
+
return reportedBuild;
|
|
145
|
+
}
|
|
146
|
+
throw exports.MalformedBuildError;
|
|
147
|
+
};
|
|
148
|
+
const spawnDevServer = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
|
+
const builds = [];
|
|
150
|
+
const requestHandler = getRequestHandler({
|
|
151
|
+
builds,
|
|
152
|
+
root: process.cwd(),
|
|
153
|
+
routes: {
|
|
154
|
+
[REPORT_BUILD_PATHNAME]: {
|
|
155
|
+
post: (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
+
const body = yield getRequestBody(req);
|
|
157
|
+
const reportedBuild = getReportedBuild(body);
|
|
158
|
+
builds.push(reportedBuild);
|
|
159
|
+
res.end();
|
|
160
|
+
}),
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
165
|
+
const server = http.createServer(requestHandler);
|
|
166
|
+
server.listen();
|
|
167
|
+
yield (0, events_1.once)(server, 'listening');
|
|
168
|
+
return { builds, server, url: getBuildReportUrl(server) };
|
|
169
|
+
});
|
|
170
|
+
const buildAssets = (buildCommand, reporter) => __awaiter(void 0, void 0, void 0, function* () {
|
|
171
|
+
var _d, _e, _f, _g;
|
|
172
|
+
const { builds, server, url } = yield spawnDevServer();
|
|
57
173
|
// Spawn the build command process with the BUILD_PLUGINS_S8S_PORT environment variable.
|
|
58
174
|
const buildCommandProcess = (0, child_process_1.spawn)(buildCommand, [], {
|
|
59
|
-
env: {
|
|
60
|
-
shell: true,
|
|
175
|
+
env: Object.assign({ DATADOG_SYNTHETICS_REPORT_BUILD_URL: url }, process.env),
|
|
176
|
+
shell: (_e = (_d = process.env.SHELL) !== null && _d !== void 0 ? _d : process.env.ComSpec) !== null && _e !== void 0 ? _e : true,
|
|
61
177
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
buildCommandExited,
|
|
69
|
-
]);
|
|
70
|
-
controller.abort();
|
|
71
|
-
if (buildCommandReturnValue === undefined) {
|
|
72
|
-
yield killBuildCommand(buildCommandProcess, buildCommandExited);
|
|
73
|
-
throw new Error('Unexpected state: buildCommandReturnValue is undefined');
|
|
74
|
-
}
|
|
75
|
-
if (buildCommandReturnValue.readiness === 'buildCommandExited') {
|
|
76
|
-
reporter.error(exports.UnconfiguredBuildPluginError.message);
|
|
77
|
-
yield killBuildCommand(buildCommandProcess, buildCommandExited);
|
|
178
|
+
(_f = buildCommandProcess.stdout) === null || _f === void 0 ? void 0 : _f.pipe(process.stdout);
|
|
179
|
+
(_g = buildCommandProcess.stderr) === null || _g === void 0 ? void 0 : _g.pipe(process.stderr);
|
|
180
|
+
// Wait for the build command to finish
|
|
181
|
+
yield (0, events_1.once)(buildCommandProcess, 'close');
|
|
182
|
+
if (builds.length === 0) {
|
|
183
|
+
yield stopDevServer(server);
|
|
78
184
|
throw exports.UnconfiguredBuildPluginError;
|
|
79
185
|
}
|
|
80
|
-
if (buildCommandReturnValue.readiness === 'buildCommandErrored') {
|
|
81
|
-
reporter.error(buildCommandReturnValue.error.message);
|
|
82
|
-
yield killBuildCommand(buildCommandProcess, buildCommandExited);
|
|
83
|
-
throw buildCommandReturnValue.error;
|
|
84
|
-
}
|
|
85
|
-
const { publicPrefix = '' } = buildCommandReturnValue;
|
|
86
186
|
// Once the build server is ready, return its URL with the advertised public prefix to run the tests against it.
|
|
87
187
|
return {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
stop: () => __awaiter(void 0, void 0, void 0, function* () { return
|
|
188
|
+
builds,
|
|
189
|
+
devServerUrl: url,
|
|
190
|
+
stop: () => __awaiter(void 0, void 0, void 0, function* () { return stopDevServer(server); }),
|
|
91
191
|
};
|
|
92
192
|
});
|
|
93
|
-
exports.
|
|
94
|
-
const
|
|
95
|
-
var _a
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
(
|
|
100
|
-
|
|
193
|
+
exports.buildAssets = buildAssets;
|
|
194
|
+
const getBuildReportUrl = (server) => {
|
|
195
|
+
var _a;
|
|
196
|
+
// net.Server can be listening on a named pipe, in which case the address is a string
|
|
197
|
+
// or not listening yet, in which case the address is null, which we cast to the 'undefined' string
|
|
198
|
+
// to meet the same condition as if it was a named pipe, and throw.
|
|
199
|
+
const serverAddress = (_a = server.address()) !== null && _a !== void 0 ? _a : 'undefined';
|
|
200
|
+
if (typeof serverAddress === 'string') {
|
|
201
|
+
throw new Error('Server address is not valid');
|
|
202
|
+
}
|
|
203
|
+
const url = new URL(serverAddress.family === 'IPv6'
|
|
204
|
+
? `http://[${serverAddress.address}]:${serverAddress.port}`
|
|
205
|
+
: `http://${serverAddress.address}:${serverAddress.port}`);
|
|
206
|
+
url.pathname = REPORT_BUILD_PATHNAME;
|
|
207
|
+
return url.href;
|
|
208
|
+
};
|
|
209
|
+
const stopDevServer = (server) => __awaiter(void 0, void 0, void 0, function* () {
|
|
210
|
+
if (server.listening) {
|
|
211
|
+
const serverClosed = (0, events_1.once)(server, 'close');
|
|
212
|
+
server.close();
|
|
213
|
+
yield serverClosed;
|
|
214
|
+
}
|
|
101
215
|
});
|
|
102
216
|
//# sourceMappingURL=build-and-test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-and-test.js","sourceRoot":"","sources":["../../../src/commands/synthetics/build-and-test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-and-test.js","sourceRoot":"","sources":["../../../src/commands/synthetics/build-and-test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;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A"}
|
|
@@ -132,12 +132,15 @@ class RunTestsCommand extends base_command_1.BaseCommand {
|
|
|
132
132
|
this.reporter.error('The `buildCommand` option is required for the `build-and-test` command.');
|
|
133
133
|
return 1;
|
|
134
134
|
}
|
|
135
|
-
const {
|
|
135
|
+
const { builds, devServerUrl, stop } = yield (0, build_and_test_1.buildAssets)(this.config.buildCommand, this.reporter);
|
|
136
136
|
this.tearDowns.push(stop);
|
|
137
|
+
const resourceUrlSubstitutionRegexes = builds.map(
|
|
138
|
+
// All of the resources matching the publicPath prefix will be redirected to the dev server.
|
|
139
|
+
(build) => `.*${build.publicPath}|${devServerUrl}/${build.publicPath}`);
|
|
137
140
|
this.config = (0, deep_extend_1.default)(this.config, {
|
|
138
141
|
tunnel: true,
|
|
139
142
|
defaultTestOverrides: {
|
|
140
|
-
resourceUrlSubstitutionRegexes
|
|
143
|
+
resourceUrlSubstitutionRegexes,
|
|
141
144
|
},
|
|
142
145
|
});
|
|
143
146
|
}
|