Skip to content
Open
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: 1 addition & 1 deletion docs/codeql/codeql-overview/system-requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ For extraction of compiled languages on Windows:

For TypeScript extraction on all platforms:

- Node.js 14 or higher must be installed and available on the ``PATH`` as ``node``.
- Node.js 16.20.0 or higher must be installed and available on the ``PATH`` as ``node``.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the minimum version that the updated typescript package requires. I've tested locally with this Node.js version and things seem to work.


For Python extraction:

Expand Down
6 changes: 5 additions & 1 deletion javascript/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ codeql_pack(
"//javascript/extractor:tools-extractor",
"//javascript/resources",
],
zips = {"//javascript/extractor/lib/typescript": "tools"},
arch_overrides = ["tools/typescript-parser-wrapper/node_modules/@typescript"],
zips = {
"//javascript/extractor/lib/typescript": "tools",
"//javascript/extractor/lib/typescript:native": "tools/typescript-parser-wrapper/node_modules/@typescript",
},
)
58 changes: 49 additions & 9 deletions javascript/extractor/lib/typescript/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
# Builds a zip file of the compiled typscript-parser-wrapper and its dependencies.
load("//misc/bazel:os.bzl", "codeql_platform_select")

DISTRIBUTION = codeql_platform_select(
linux64 = "linux64",
linux_arm64 = "linux-arm64",
osx64 = "osx64",
win64 = "win64",
)

# Keep the JavaScript API common, but ship native executables in the arch package.
genrule(
name = "typescript",
name = "build",
srcs = [
"tsconfig.json",
"package.json",
"package-lock.json",
"package-runtime.mjs",
] + glob(["src/**"]),
outs = ["javascript.zip"],
cmd = "\n".join([
outs = [
"javascript.zip",
"native.zip",
],
cmd = "DISTRIBUTION=" + DISTRIBUTION + "\n" + "\n".join([
# the original working directory is not preserved anywhere, but needs to be accessible, as
# all paths are relative to this
# unfortunately, we need to change the working directory to run npm.
Expand All @@ -25,20 +38,35 @@ genrule(
"rm -rf $(RULEDIR)/inputs",
"cp -L -R $$(dirname $(execpath package.json)) $(RULEDIR)/inputs",
"cd $(RULEDIR)/inputs",
"$$NPM install",
"$$NPM ci",
"$$NPM run build",
"rm -rf node_modules",
# Install again with only runtime deps
"$$NPM install --prod",
"$$NPM ci --omit=dev --omit=optional --ignore-scripts",
# Optional dependencies are host-filtered even with --force. Install the
# selected packages explicitly, retaining the lockfile's
# versions/integrities.
"$$NPM install --omit=dev --ignore-scripts --no-save --force $$(node package-runtime.mjs packages $$DISTRIBUTION)",
# Copy native binaries into `native/` and remove the explicitly
# installed native packages from `node_modules`.
"node package-runtime.mjs stage $$DISTRIBUTION",
"mv node_modules build/",
# Node needs the ESM package boundary in the installed wrapper too.
"cp package.json build/",
"mkdir -p typescript-parser-wrapper",
"mv build/* typescript-parser-wrapper",
"OUT=$$BAZEL_ROOT/$@",
"OUT=$$BAZEL_ROOT/$(execpath javascript.zip)",
"NATIVE_OUT=$$BAZEL_ROOT/$(execpath native.zip)",
"case $$OSTYPE in",
" cygwin|msys|win32) OUT=$$(cygpath -w $$OUT);;",
" cygwin|msys|win32) OUT=$$(cygpath -w $$OUT); NATIVE_OUT=$$(cygpath -w $$NATIVE_OUT);;",
"esac",
"",
"$$BAZEL_ROOT/$(execpath @bazel_tools//tools/zip:zipper) cC $$OUT $$(find typescript-parser-wrapper -name '*' -print)",
# Use response files to stay below Windows' command-line length limit.
"find typescript-parser-wrapper -print > wrapper-files",
"$$BAZEL_ROOT/$(execpath @bazel_tools//tools/zip:zipper) cC $$OUT @wrapper-files",
"cd native",
"find typescript-* -print > native-files",
"$$BAZEL_ROOT/$(execpath @bazel_tools//tools/zip:zipper) cC $$NATIVE_OUT @native-files",
"rm -rf $$TEMP",
]),
tools = [
Expand All @@ -48,3 +76,15 @@ genrule(
],
visibility = ["//visibility:public"],
)

filegroup(
name = "typescript",
srcs = ["javascript.zip"],
visibility = ["//visibility:public"],
)

filegroup(
name = "native",
srcs = ["native.zip"],
visibility = ["//visibility:public"],
)
Loading
Loading