Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions bazel/http-server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ ts_project(
"//bazel:node_modules/@types/browser-sync",
"//bazel:node_modules/@types/node",
"//bazel:node_modules/@types/send",
"//bazel:node_modules/@types/yargs",
"//bazel:node_modules/browser-sync",
"//bazel:node_modules/send",
"//bazel:node_modules/yargs",
],
)

Expand Down
6 changes: 3 additions & 3 deletions bazel/http-server/index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ def _http_server_rule_impl(ctx):
args += "--root-paths '%s' " % root

if ctx.attr.history_api_fallback:
args += "--history-api-fallback=true "
args += "--history-api-fallback "

if ctx.attr.enable_dev_ui:
args += "--enable-dev-ui=true "
args += "--enable-dev-ui "

if ctx.attr.relax_cors:
args += "--relax-cors=true "
args += "--relax-cors "

for variable_name in ctx.attr.environment_variables:
args += "--environment-variables '%s' " % variable_name
Expand Down
63 changes: 43 additions & 20 deletions bazel/http-server/main.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,56 @@
* found in the LICENSE file at https://angular.io/license
*/

import yargs from 'yargs';
import {parseArgs} from 'node:util';
import assert from 'node:assert';

import {HttpServer} from './server.mjs';
import {setupBazelWatcherSupport} from './ibazel.mjs';

const {values} = parseArgs({
args: process.argv.slice(2),
strict: true,
allowNegative: true,
options: {
port: {
type: 'string',
default: '4200',
},
'history-api-fallback': {
type: 'boolean',
default: false,
},
'root-paths': {
type: 'string',
multiple: true,
default: ['./'],
},
'environment-variables': {
type: 'string',
multiple: true,
default: [],
},
'enable-dev-ui': {
type: 'boolean',
default: false,
},
'relax-cors': {
type: 'boolean',
default: false,
},
},
});

const {
rootPaths,
historyApiFallback,
enableDevUi,
environmentVariables,
'root-paths': rootPaths,
'history-api-fallback': historyApiFallback,
'enable-dev-ui': enableDevUi,
'environment-variables': environmentVariables,
port: cliPort,
relaxCors,
} = yargs(process.argv.slice(2))
.strict()
.option('port', {
type: 'number',
default: 4200,
})
.option('historyApiFallback', {type: 'boolean', default: false})
.option('rootPaths', {type: 'array', string: true, default: ['']})
.option('environmentVariables', {type: 'array', string: true, default: []})
.option('enableDevUi', {type: 'boolean', default: false})
.option('relaxCors', {type: 'boolean', default: false})
.parseSync();

let port = cliPort;
'relax-cors': relaxCors,
} = values;

let port = Number(cliPort);
// Process environment port always overrides the CLI, or rule attribute-specified port.
if (process.env.PORT !== undefined) {
port = Number(process.env.PORT);
Expand Down
1 change: 1 addition & 0 deletions bazel/http-server/test/server-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ async function runTest() {
// Wait for server to be ready, regardless of status code (404/200 or else)
await waitOn({
resources: [`http-get://${serverHost}`],
timeout: 20_000,
headers: {
'accept': 'text/html',
},
Expand Down
2 changes: 0 additions & 2 deletions bazel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
"@types/send": "1.2.1",
"@types/wait-on": "^5.3.4",
"@types/source-map-support": "0.5.10",
"@types/yargs": "17.0.35",
"browser-sync": "3.0.4",
"get-tsconfig": "4.13.0",
"piscina": "^5.0.0",
"send": "1.2.1",
"true-case-path": "2.2.1",
"typescript": "5.9.3",
"wait-on": "^9.0.0",
"yargs": "18.0.0",
"protractor": "7.0.0",
"semver": "7.7.3",
"selenium-webdriver": "4.39.0",
Expand Down
6 changes: 0 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading