1 | "use strict";
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
8 | */
|
---|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
10 | exports.setupBrowserTarget = exports.BUILD_TIMEOUT = exports.BASE_OPTIONS = exports.DEV_SERVER_BUILDER_INFO = exports.describeBuilder = void 0;
|
---|
11 | const fs_1 = require("fs");
|
---|
12 | const browser_1 = require("../../browser");
|
---|
13 | const setup_1 = require("../../browser/tests/setup");
|
---|
14 | var testing_1 = require("../../testing");
|
---|
15 | Object.defineProperty(exports, "describeBuilder", { enumerable: true, get: function () { return testing_1.describeBuilder; } });
|
---|
16 | exports.DEV_SERVER_BUILDER_INFO = Object.freeze({
|
---|
17 | name: '@angular-devkit/build-angular:dev-server',
|
---|
18 | schemaPath: __dirname + '/../schema.json',
|
---|
19 | });
|
---|
20 | /**
|
---|
21 | * Contains all required dev-server builder fields.
|
---|
22 | * The port is also set to zero to ensure a free port is used for each test which
|
---|
23 | * supports parallel test execution.
|
---|
24 | */
|
---|
25 | exports.BASE_OPTIONS = Object.freeze({
|
---|
26 | browserTarget: 'test:build',
|
---|
27 | port: 0,
|
---|
28 | });
|
---|
29 | /**
|
---|
30 | * Maximum time for single build/rebuild
|
---|
31 | * This accounts for CI variability.
|
---|
32 | */
|
---|
33 | exports.BUILD_TIMEOUT = 15000;
|
---|
34 | /**
|
---|
35 | * Cached browser builder option schema
|
---|
36 | */
|
---|
37 | let browserSchema = undefined;
|
---|
38 | /**
|
---|
39 | * Adds a `build` target to a builder test harness for the browser builder with the base options
|
---|
40 | * used by the browser builder tests.
|
---|
41 | *
|
---|
42 | * @param harness The builder harness to use when setting up the browser builder target
|
---|
43 | * @param extraOptions The additional options that should be used when executing the target.
|
---|
44 | */
|
---|
45 | function setupBrowserTarget(harness, extraOptions) {
|
---|
46 | if (!browserSchema) {
|
---|
47 | browserSchema = JSON.parse(fs_1.readFileSync(setup_1.BROWSER_BUILDER_INFO.schemaPath, 'utf8'));
|
---|
48 | }
|
---|
49 | harness.withBuilderTarget('build', browser_1.buildWebpackBrowser, {
|
---|
50 | ...setup_1.BASE_OPTIONS,
|
---|
51 | ...extraOptions,
|
---|
52 | }, {
|
---|
53 | builderName: setup_1.BROWSER_BUILDER_INFO.name,
|
---|
54 | optionSchema: browserSchema,
|
---|
55 | });
|
---|
56 | }
|
---|
57 | exports.setupBrowserTarget = setupBrowserTarget;
|
---|