From a2d4ed541432ccf2f31042729654b7ac45b13059 Mon Sep 17 00:00:00 2001 From: Antony Chan Date: Fri, 18 Aug 2023 14:23:36 -0700 Subject: [PATCH] Enable Github depend bot to scan for Javascript vulnerability Add a dummy javascript library dependencies file "package.json" and the book-keeping file "yarn.lock" to monitor the IRVisualizer tool for outdated dependencies. Activate Github's Dependbot notification for any security vulnerabilities and virus. Upgrade the JQuery library to v3.7.0 . --- package.json | 1 + src/irvisualizer/.eslintrc.js | 13 +++++ src/irvisualizer/.gitignore | 1 + src/irvisualizer/README.md | 58 +++++++++++++++++++ .../StmtToViz_dependencies.template.html | 2 +- src/irvisualizer/package.json | 29 ++++++++++ 6 files changed, 103 insertions(+), 1 deletion(-) create mode 120000 package.json create mode 100644 src/irvisualizer/.eslintrc.js create mode 100644 src/irvisualizer/.gitignore create mode 100644 src/irvisualizer/README.md create mode 100644 src/irvisualizer/package.json diff --git a/package.json b/package.json new file mode 120000 index 000000000000..c30d0ba92b5b --- /dev/null +++ b/package.json @@ -0,0 +1 @@ +src/irvisualizer/package.json \ No newline at end of file diff --git a/src/irvisualizer/.eslintrc.js b/src/irvisualizer/.eslintrc.js new file mode 100644 index 000000000000..5baa4115614e --- /dev/null +++ b/src/irvisualizer/.eslintrc.js @@ -0,0 +1,13 @@ +module.exports = { + "env": { + "browser": true, + }, + "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": "2017", + "sourceType": "module", + }, + "rules": { + "comma-dangle": ["error", "only-multiline"] + } +} \ No newline at end of file diff --git a/src/irvisualizer/.gitignore b/src/irvisualizer/.gitignore new file mode 100644 index 000000000000..c2658d7d1b31 --- /dev/null +++ b/src/irvisualizer/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/src/irvisualizer/README.md b/src/irvisualizer/README.md new file mode 100644 index 000000000000..0c9c5ef582ed --- /dev/null +++ b/src/irvisualizer/README.md @@ -0,0 +1,58 @@ +# Javascript toolchain for IRVisualizer: the single page web application + +## Features: + +* To trigger Github's online Dependabot alerts for security vulnerabilities. + +* To enable static analyzer for the Javascript/ES6 language. + +* To visualize the Halide IR and the assembly code interactively +with a web browser. + +## Usage: + +* Execute `yarn install` to scan for broken Javascript dependencies. + +* (To be completed) execute `yarn run lint` to scan the main script for potential syntax errors and + bugs. + +## Recommended Makefile build rules + +```make +ESBUILD=node_modules/.bin/esbuild +ESLINT=node_modules/.bin/eslint + +help: ## Display this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) + +all: depend build ## Download dependencies and build everything + +depend: ## Download Nodejs dependencies + yarn install + +watch: ## Debug mode, monitor file changes and then compile automatically + yarn run watch + +build: ## Release mode, optimize and minimize the Javascript file + yarn run build + +lint: ## Run static analyzer on the main javascript + yarn run lint + +.PHONY: depend watch build lint +``` + +## Development roadmap + +* [ ] Rename the extensions from `*.template.html` to `template/*.[js|css|html]`. + +* [ ] Modernize the main script to ES6. + +* [ ] Import all dependencies with the `import` statement, not via the ` + diff --git a/src/irvisualizer/package.json b/src/irvisualizer/package.json new file mode 100644 index 000000000000..3eddd4cb0eef --- /dev/null +++ b/src/irvisualizer/package.json @@ -0,0 +1,29 @@ +{ + "name": "halide-irvisualizer", + "description": "Halide IRVisualizer web toolchain", + "author": "Halide IRVisualizer workgroup", + "version": "0.0.1", + "private": true, + "repository": { + "type": "git", + "url": "" + }, + "scripts": { + "build": "esbuild StmtToViz_javascript.template.html --bundle --minify --sourcemap --outdir=build --target=es6", + "lint": "eslint StmtToViz_javascript.template.html", + "watch": "esbuild StmtToViz_javascript.template.html --bundle --watch --outdir=build" + }, + "dependencies": { + "@speed-highlight/core": "speed-highlight/core", + "bootstrap": "5.2.0", + "bootstrap-icons": "1.5.0", + "font-awesome": "4.1.0", + "jquery": "3.7.0", + "treeflex": "^2.0.1" + }, + "devDependencies": { + "esbuild": "^0.18.13", + "eslint": "^2.11.1", + "yarn": "^1.22.10" + } +}