Skip to content
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

🚧 WIP Integrate parcel and refactor to more pure Vue components #459

Draft
wants to merge 39 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ae69a91
Add parcel dependencies and run tasks
jaywon Mar 17, 2019
ed7270d
Convert custom environment parsing syntax for Post HTML syntax for va…
jaywon Mar 17, 2019
171e11f
Add parcel specific files/directories to .gitignore
jaywon Mar 17, 2019
c5174b1
Add .env example file to repo for self-documenting vars
jaywon Mar 17, 2019
b8e81e8
Merge branch 'develop' into chore/integrate-parcel
jaywon Mar 17, 2019
c1a52c0
:pencil2: Add .vscode directory to .gitignore
jaywon Mar 18, 2019
66d434b
:recycle: Create shared module for Vue EventBus singleton
jaywon Mar 18, 2019
e2ccd3c
Add global SCSS for starting to theme the application
jaywon Mar 18, 2019
c2d828f
:recycle: Refactor panel files into standard Vue Single File Component
jaywon Mar 18, 2019
3bff06d
:recycle: Refactor management pane to Vue Single File Component
jaywon Mar 18, 2019
a595939
:wrench: Add parcel build/run statements to watch entrypoints directory
jaywon Mar 18, 2019
3c72d1d
:heavy_plus_sign: Add Display components for migration/refactor
jaywon Mar 18, 2019
034d987
:fire: Delete display.css, migrated to Vue Display component
jaywon Mar 18, 2019
4394ae1
:recycle: Break out HudButton and HudButtons to their own components
jaywon Mar 20, 2019
7d4c1a8
:recycle: Break out Tab and Tabs to their own components
jaywon Mar 20, 2019
6ed9e7a
:recycle: Break out AlertAccordion to its own component
jaywon Mar 20, 2019
10b9211
:recycle: Refactor all modals into their own components
jaywon Mar 20, 2019
1ba51e7
:recycle: Break out ToolListItem to its own component
jaywon Mar 20, 2019
c99dd70
:recycle: Break out SiteTreeNode to its own component
jaywon Mar 20, 2019
5f1e77a
Uncomment Spectre css include for now, will evaluate spectre componen…
jaywon Mar 20, 2019
bb29d06
:recycle: Refactor display.html|css|js to a Vue Single Page Component…
jaywon Mar 20, 2019
f71b2be
:recycle: Refactor management.html|css|js to a Vue Single Page Compon…
jaywon Mar 20, 2019
8494797
:recycle: Stub out Drawer Single Page Component files for conversion
jaywon Mar 20, 2019
8b5ffe8
:fire: Remove manual vue dependencies in favor of parcel build from n…
jaywon Mar 20, 2019
641de54
:heavy_plus_sign: Add localforage import
jaywon Mar 20, 2019
165abc6
:recycle: Remove localforage script tag and clean up cruft
jaywon Mar 20, 2019
d8dcca3
Add TODO note for refactor
jaywon Mar 20, 2019
bcde54e
:recycle: Remove localforage script include and use ES6 import
jaywon Mar 20, 2019
440ea17
Add i18n compiled file to development environment since it's needed f…
jaywon Mar 22, 2019
098534d
:wrench: Change PostHTML delimiters to not conflict with Vue template…
jaywon Mar 22, 2019
74ee6d7
Refactor i18n interpolation and PostHTML delimiter syntax
jaywon Mar 22, 2019
7b8308d
:fire: Remove webpack dependencies and configuration
jaywon Mar 25, 2019
e9e34a1
:fire: Remove localforage downloaded copy for npm version
jaywon Mar 25, 2019
622c5da
:recycle: Convert display into entrypoint and associated files for ne…
jaywon Mar 25, 2019
47a4cad
:sparkles: Linter reformatting and minor cleanup
jaywon Mar 25, 2019
bbf848a
Add placeholder main file to start holding global styles
jaywon Mar 25, 2019
d795df9
:recycle: Conversion of all drawer related component
jaywon Mar 25, 2019
3dac5ee
:pencil2: Fix default locale in i18n init
jaywon Mar 25, 2019
1a327d3
:heavy_plus_sign: :heavy_minus_sign} Update node packages
jaywon Mar 27, 2019
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
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ZAP_HUD_FILES=https://zap
Copy link
Contributor

Choose a reason for hiding this comment

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

walking through the commits rn. haha. so this is where you set the variables to be pulled in by postHTML?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup! This file is just a template, for actual dev you would:

cp .env.example .env

And then edit for your environment. .env is in the .gitignore as often times this has values you don't want committed to repo. I added some copy in the README about it and @melsoriano will document in the wiki too.

ZAP_HUD_URL=https://targetdomain.com
ZAP_HUD_API=https://zap/api
ZAP_HUD_WS=https://zap/websocket
ZAP_HUD_TOOLS=http://zap/to/some/tool
ZAP_SHARED_SECRET=sometestsecret
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@
# JS
node_modules/
dist/
.cache
.env

# Visual Studio Code
.vscode
3,353 changes: 3,256 additions & 97 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
},
"scripts": {
"test": "ava",
"build": "webpack --config src/webpack/config.dev.js",
"dev": "parcel src/main/ZapHomeFiles/hud/display.html",
"build": "parcel build src/main/ZapHomeFiles/hud/*.html",
"lint": "xo",
"lint-staged": "lint-staged"
},
Expand Down Expand Up @@ -48,6 +49,8 @@
"ava": "^1.3.1",
"css-loader": "^2.1.1",
"lint-staged": "^8.1.5",
"parcel-bundler": "^1.12.2",
"posthtml-expressions": "^1.1.0",
"vue-loader": "^15.7.0",
"vue-style-loader": "^4.1.2",
"vue-template-compiler": "^2.6.9",
Expand Down
18 changes: 9 additions & 9 deletions src/main/zapHomeFiles/hud/display.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="<<ZAP_HUD_FILES>>?name=libraries/spectre.css"/>
<link rel="stylesheet" type="text/css" href="<<ZAP_HUD_FILES>>?name=libraries/spectre-icons.css"/>
<link rel="stylesheet" type="text/css" href="<<ZAP_HUD_FILES>>?name=display.css"/>
<link rel="stylesheet" type="text/css" href="{{ ZAP_HUD_FILES }}?name=libraries/spectre.css"/>
<link rel="stylesheet" type="text/css" href="{{ ZAP_HUD_FILES }}?name=libraries/spectre-icons.css"/>
<link rel="stylesheet" type="text/css" href="{{ ZAP_HUD_FILES }}?name=display.css"/>

<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=libraries/vue.js"></script>
<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=libraries/vue-i18n.js"></script>
<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=i18n.js"></script>
<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=utils.js"></script>
<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=display.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=libraries/vue.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=libraries/vue-i18n.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=i18n.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=utils.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=display.js"></script>
</head>

<body>
Expand Down Expand Up @@ -271,7 +271,7 @@
<div slot="footer">
<div><span class="errorMessages">{{errors}}</span></div>
<div class="float-left">
<button :class="{'btn': true, 'disabled': isAscanDisabled}" @click="ascanRequest"> {{ $t('message.history_ascan_request') }} <img src="<<ZAP_HUD_FILES>>?image=flame.png" /> </button>
<button :class="{'btn': true, 'disabled': isAscanDisabled}" @click="ascanRequest"> {{ $t('message.history_ascan_request') }} <img src="{{ ZAP_HUD_FILES }}?image=flame.png" /> </button>
</div>
<button class="btn btn-primary" @click="replay"> {{ $t('message.history_replay_console') }} </button>
<button class="btn" @click="replayInBrowser"> {{ $t('message.history_replay_browser') }} </button>
Expand Down
20 changes: 10 additions & 10 deletions src/main/zapHomeFiles/hud/drawer.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="<<ZAP_HUD_FILES>>?name=libraries/spectre.css"/>
<link rel="stylesheet" type="text/css" href="<<ZAP_HUD_FILES>>?name=libraries/spectre-icons.css"/>
<link rel="stylesheet" type="text/css" href="<<ZAP_HUD_FILES>>?name=drawer.css"/>
<link rel="stylesheet" type="text/css" href="{{ ZAP_HUD_FILES }}?name=libraries/spectre.css"/>
<link rel="stylesheet" type="text/css" href="{{ ZAP_HUD_FILES }}?name=libraries/spectre-icons.css"/>
<link rel="stylesheet" type="text/css" href="{{ ZAP_HUD_FILES }}?name=drawer.css"/>

<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=libraries/localforage.min.js"></script>
<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=libraries/vue.js"></script>
<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=libraries/vue-i18n.js"></script>
<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=i18n.js"></script>
<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=utils.js"></script>
<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=drawer.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=libraries/localforage.min.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=libraries/vue.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=libraries/vue-i18n.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=i18n.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=utils.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=drawer.js"></script>
</head>
<body>
<div id="app">
Expand Down Expand Up @@ -161,7 +161,7 @@
</template>

<template id="drawer-button-settings-template">
<drawer-button-template icon="<<ZAP_HUD_FILES>>?image=gear.png" @click="showHudSettings"></drawer-button-template>
<drawer-button-template icon="{{ ZAP_HUD_FILES }}?image=gear.png" @click="showHudSettings"></drawer-button-template>
</template>

<template id="drawer-button-showhide-template">
Expand Down
8 changes: 4 additions & 4 deletions src/main/zapHomeFiles/hud/growlerAlerts.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<html>
<head>
<script src="<<ZAP_HUD_FILES>>?name=libraries/alertify.js"></script>
<script src="<<ZAP_HUD_FILES>>?name=libraries/localforage.min.js"></script>
<script src="<<ZAP_HUD_FILES>>?name=utils.js"></script>
<script src="<<ZAP_HUD_FILES>>?name=growlerAlerts.js"></script>
<script src="{{ ZAP_HUD_FILES }}?name=libraries/alertify.js"></script>
<script src="{{ ZAP_HUD_FILES }}?name=libraries/localforage.min.js"></script>
<script src="{{ ZAP_HUD_FILES }}?name=utils.js"></script>
<script src="{{ ZAP_HUD_FILES }}?name=growlerAlerts.js"></script>
</head>
<body>

Expand Down
2 changes: 2 additions & 0 deletions src/main/zapHomeFiles/hud/libs/event-bus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Vue from 'vue';
export const EventBus = new Vue();
Copy link
Contributor

Choose a reason for hiding this comment

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

love this shared module

Copy link
Contributor

Choose a reason for hiding this comment

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

Because the events are registered in this external bus, they all need to be individually torn down:
e.g.

	beforeDestroy () {
		eventBus.$off('showSiteTreeModal')
	}

You could create a global mixin here, but I think that the difficulty you would face is that you will have to contort yourself to know which component is being destroyed. Probably better to tear them down in the individual components, because that way later contributors can SEE that they are being unregistered.

14 changes: 7 additions & 7 deletions src/main/zapHomeFiles/hud/management.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="<<ZAP_HUD_FILES>>?name=libraries/spectre.css"/>
<link rel="stylesheet" type="text/css" href="<<ZAP_HUD_FILES>>?name=management.css" />
<link rel="stylesheet" type="text/css" href="{{ ZAP_HUD_FILES }}?name=libraries/spectre.css"/>
<link rel="stylesheet" type="text/css" href="{{ ZAP_HUD_FILES }}?name=management.css" />

<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=libraries/vue.js"></script>
<script src="<<ZAP_HUD_FILES>>?name=libraries/localforage.min.js"></script>
<script src="<<ZAP_HUD_FILES>>?name=utils.js"></script>
<script src="<<ZAP_HUD_FILES>>?name=management.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=libraries/vue.js"></script>
<script src="{{ ZAP_HUD_FILES }}?name=libraries/localforage.min.js"></script>
<script src="{{ ZAP_HUD_FILES }}?name=utils.js"></script>
<script src="{{ ZAP_HUD_FILES }}?name=management.js"></script>
</head>
<body>
<div id="app">
Expand All @@ -15,7 +15,7 @@

<template id="welcome-screen-template">
<div class="welcome-div">
<img class="welcome-image" src='<<ZAP_HUD_FILES>>?image=hud-welcome.png'>
<img class="welcome-image" src='{{ ZAP_HUD_FILES }}?image=hud-welcome.png'>
<div class="tutorial-div">
<button class="btn btn-primary" @click="continueToTutorial"> Take the HUD Tutorial </button>
</div>
Expand Down
16 changes: 8 additions & 8 deletions src/main/zapHomeFiles/hud/panel.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="<<ZAP_HUD_FILES>>?name=libraries/spectre.css"/>
<link rel="stylesheet" type="text/css" href="<<ZAP_HUD_FILES>>?name=panel.css&amp;orientation=ORIENTATION" />
<link rel="stylesheet" type="text/css" href="{{ ZAP_HUD_FILES }}?name=libraries/spectre.css"/>
<link rel="stylesheet" type="text/css" href="{{ ZAP_HUD_FILES }}?name=panel.css&amp;orientation=ORIENTATION" />

<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=libraries/localforage.min.js"></script>
<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=libraries/vue.js"></script>
<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=utils.js"></script>
<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=panel.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=libraries/localforage.min.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=libraries/vue.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=utils.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=panel.js"></script>
</head>
<body>
<div id="app">
Expand All @@ -15,8 +15,8 @@

<template id="hud-buttons-template">
<div id="hud-buttons" :class="{'d-hide': !isVisible, 'd-visible': isVisible}">
<hud-button v-for="tool in tools" :key="tool.name" :label="tool.label" :icon="'<<ZAP_HUD_FILES>>?image=' + tool.icon" :data="tool.data" :name="tool.name"></hud-button>
<hud-button icon="<<ZAP_HUD_FILES>>?image=plus.png" name="add-tool"></hud-button>
<hud-button v-for="tool in tools" :key="tool.name" :label="tool.label" :icon="'{{ ZAP_HUD_FILES }}?image=' + tool.icon" :data="tool.data" :name="tool.name"></hud-button>
<hud-button icon="{{ ZAP_HUD_FILES }}?image=plus.png" name="add-tool"></hud-button>
</div>
</template>

Expand Down
14 changes: 14 additions & 0 deletions src/main/zapHomeFiles/hud/posthtml.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
plugins: {
"posthtml-expressions": {
locals: {
ZAP_HUD_FILES: process.env.ZAP_HUD_FILES,
Copy link
Contributor

Choose a reason for hiding this comment

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

whats the reason for the env var pattern here instead of just hard coding them?

Copy link
Contributor Author

@jaywon jaywon Mar 27, 2019

Choose a reason for hiding this comment

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

Parcel supports .env files by default and it will do variable substitution and logic evaluation throughout the app at build. Then PostHTML has it's own requirements for it's own posthtml-expressions plugin, which this config file is for handling it's own HTML interpolation which i wouldn't be able to do in a template with process.env w/o PostHTML (cuz only can be in JavaScript).

https://parceljs.org/env.html
https://github.com/posthtml/posthtml-expressions

Copy link
Contributor

Choose a reason for hiding this comment

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

@jaywon: fwiw each of those instances of it's own in #459 (comment) should be its own.

(I know it isn't particularly material here, but at some point I'm probably going to be running a grammar check against some of these repositories, so to the extent I can remind people to be aware of the distinction: it's => it is / its => possessive, there's a return on my investment.)

ZAP_HUD_URL: process.env.ZAP_HUD_URL,
ZAP_HUD_API: process.env.ZAP_HUD_API,
ZAP_HUD_WS: process.env.ZAP_HUD_WS,
ZAP_HUD_TOOLS: process.env.ZAP_HUD_TOOLS,
ZAP_SHARED_SECRET: process.env.ZAP_SHARED_SECRET
}
}
}
};
2 changes: 1 addition & 1 deletion src/main/zapHomeFiles/hud/websockettest.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<script type="text/javascript" src="<<ZAP_HUD_FILES>>?name=websockettest.js"></script>
<script type="text/javascript" src="{{ ZAP_HUD_FILES }}?name=websockettest.js"></script>
<title>Web Socket API Test Page</title>
</head>
<body>
Expand Down