-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Create js_run_devserver target in macro #92
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,31 +9,23 @@ _attrs = dicts.add(js_binary_lib.attrs, { | |
), | ||
}) | ||
|
||
# Do the opposite of _to_manifest_path in | ||
# https://github.com/bazelbuild/rules_nodejs/blob/8b5d27400db51e7027fe95ae413eeabea4856f8e/nodejs/toolchain.bzl#L50 | ||
# to get back to the short_path. | ||
# TODO: fix toolchain so we don't have to do this | ||
def _target_tool_short_path(path): | ||
return ("../" + path[len("external/"):]) if path.startswith("external/") else path | ||
|
||
def _impl(ctx): | ||
cypress_bin = _target_tool_short_path(ctx.toolchains["@aspect_rules_cypress//cypress:toolchain_type"].cypressinfo.target_tool_path) | ||
cypress_bin = ctx.toolchains["@aspect_rules_cypress//cypress:toolchain_type"].cypressinfo.target_tool_path | ||
cypress_files = ctx.toolchains["@aspect_rules_cypress//cypress:toolchain_type"].cypressinfo.tool_files | ||
|
||
files = ctx.files.data[:] + cypress_files + ctx.files.browsers | ||
|
||
if ctx.attr.chdir: | ||
cypress_bin = "/".join([".." for _ in ctx.attr.chdir.split("/")] + [cypress_bin]) | ||
# TODO: Augment rules_js to expose JS__EXECROOT before setting fixed_env. Then use that variable. | ||
execroot = "$$( realpath \"$${BASH_SOURCE[0]}\" | sed -E 's/^(.*\\/execroot\\/[^/]+).*/\\1/')" | ||
cypress_run_binary = "/".join([execroot, cypress_bin]) | ||
|
||
launcher = js_binary_lib.create_launcher( | ||
ctx, | ||
log_prefix_rule_set = "aspect_rules_cypess", | ||
log_prefix_rule = "cypress_node_test", | ||
fixed_args = ctx.attr.fixed_args, | ||
fixed_env = { | ||
"CYPRESS_RUN_BINARY": cypress_bin, | ||
"HOME": "$$TEST_TMPDIR", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did we set |
||
"XDG_CONFIG_HOME": "$$TEST_TMPDIR", | ||
"CYPRESS_RUN_BINARY": cypress_run_binary, | ||
}, | ||
) | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ if (isNaN(port)) { | |
} | ||
|
||
app.get("/", (req, res) => { | ||
res.type('html'); | ||
res.send(` | ||
<html> | ||
<body> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Dep on realpath not great and it will also escape the sandbox this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably augment rules_js to support what you want here instead of this line