Skip to content

Commit 2cdaaac

Browse files
author
Victoria
committed
clean up local testing environment
1 parent 8431e0a commit 2cdaaac

4 files changed

Lines changed: 13 additions & 25 deletions

File tree

local_testing/Readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Local testing
22

3-
Viewing `ExampleApp/local_testing/test.html` in your browser will allow you to test without using the [App Creator](https://www.cloudflare.com/apps/developer/app-creator )
3+
1. Run `npm run build`
4+
2. Add any additional scripts or css files to the head of **`test.html`** .
5+
3. View `./<ExampleApp>/local_testing/test.html` in your browser to allow you to test offline and without using the [App Creator](https://www.cloudflare.com/apps/developer/app-creator)
46

5-
* Please modify **`window.INSTALL_OPTIONS`** in `ExampleApp/local_testing/local.js` to edit the default **`INSTALL_OPTIONS`** that will be tested. There should be a default value for every option in `install.json`
7+
Note The default values in **`install.json`** will be used.

local_testing/test.html

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
<!DOCTYPE HTML>
22
<html>
33
<head>
4-
<script>
5-
var CloudflareApps = {}
6-
</script>
7-
8-
94
<script src="../dist/bundle.js"></script>
5+
<!-- Add any other source files you wish to test locally here -->
106
<link rel="stylesheet" href="../source/app.css">
11-
<script src="../source/app.js"></script>
12-
<!-- <script src="../test/test.js"></script> -->
7+
<script src="../source/app.js"></script>
138
</head>
149
<body>
1510
<p>Example Body Text </p>

main.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var INSTALL_JSON = require('./install.json');
2+
window.CloudflareApps = {}
23

34
// Scripts to enable local testing with CloudflareApps' methods
45
// For more details see https://www.cloudflare.com/apps/developer/docs/create-an-app/environment
@@ -9,20 +10,9 @@ require("./node_modules/@cloudflare-apps/environment/lib/restrict.js")
910
require("./node_modules/@cloudflare-apps/environment/lib/selector.js")
1011

1112
// Assign INSTALL_OPTIONS to the default options in install.json
12-
window.INSTALL = CloudflareApps
13+
window.INSTALL = window.CloudflareApps
1314
window.INSTALL_PROPERTIES = INSTALL_JSON.options.properties
14-
var installDefaultArr = Object.keys(INSTALL_PROPERTIES).map((property) => { let obj = {}; obj[property] = INSTALL_PROPERTIES[property].default; return obj })
15-
window.INSTALL_OPTIONS = installDefaultArr.reduce((el, acum) => Object.assign(acum, el))
16-
const c = '/source/app.js'
17-
// require('.' + c)
18-
19-
// Assign scripts for html doc
20-
var installScripts = INSTALL_JSON.resources.body.filter((src) => src.type === 'script')
21-
let mChar = ''
22-
installScripts.forEach((script) =>{
23-
const newStr = script.src.replace(/^./, (firstChar) => {
24-
console.log(firstChar); mChar = firstChar; return'';
25-
})
26-
//require requires there be a hard coded string (e.g. '.')
27-
require('.' + newStr)
15+
var installDefaultArr = Object.keys(INSTALL_PROPERTIES).map((property) => {
16+
let obj = {}; obj[property] = INSTALL_PROPERTIES[property].default; return obj;
2817
})
18+
window.INSTALL_OPTIONS = installDefaultArr.reduce((el, acum) => Object.assign(acum, el))

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"lint": "standard --fix ./source/**/*.js || true",
88
"start": "webpack-cli",
99
"test": "mocha",
10-
"build": "webpack"
10+
"build": "webpack",
11+
"dev": "webpack --mode development"
1112
},
1213
"private": true,
1314
"repository": {

0 commit comments

Comments
 (0)