Modeled on UI Tour
npm install
npm run build
# or more verbosely
./node_modules/webpack/bin/webpack.js
./node_modules/webpack/bin/webpack.js --progress --colors --watch &
# will need restart if you add new files
npm build
- npm run open deploy/en-US/repair/index.html # will actually run recipes, for now.
- open console mode in devtools
heartbeat
- profit.
- give good value
- don't download or run things stupidly
- not gross
- don't repeat yourself (currently unmet)
- install doesn't need anything too wierd.
gem
,pip
,npm
- easy for ops
- 12 Steps
- end result a set of static files
- possible to test all recipes
- easy to test single recipes in isolation
Build using webpack
- this fails on the individual recipe debug
- fails on 'DRY' (unless GRL gets smarter at node)
-
git clone and fork
-
make a recipe in recipes
- copy
always.js
- or make a directory
- copy
-
remember that your paths to
common
and such are relative. -
it's okay to
require
newnode
packages, but these will be reviewed.
- tests in
/tests/recipes/<yourplace>
to mirror your structure. - run tests `npm run test:unit --karmafiles="test/**/*.js"
- attempt 100% code coverage
(tbd, will involve opening page to localhost:5000
with special args).
-
'leak' the object to test into
window
scope.window.yourthing = module.exports
-
In
karma
debug page (http://localhost:9876/debug.html), it should then be available on the command line to play with. -
it.todo
,it.only
andnpm run test:unit --karmafiles="test/path/yourfile.js"
are your friends. -
(when complete, remove the 'leak')
- Pack it to include all dependencies.
npm run webpack -- test/recipes/always recipe.packed.js
-
Include it in an
html
page. -
Debug as you will.
// parse the query string as JSON => args to modules.
http://localhost:8000/?{"phonehome":{"testing":true},"runner":{"alwaysRun":true},"personinfo":{"updateChannel":%20"nightly",%20"locale":%20"en-US"}}/
Interesting things are in window.heartbeat
or heartbeat
heartbeat.recipes[1].run({},{simulate: true})
heartbeat.personinfo.personinfo().then((d)=>heartbeat.recipes[1].shouldRun(d, null, {randomNumber:.000001})).then(heartbeat.actions.log, heartbeat.actions.log)
Make a pull-request against Mozilla/self-repair-server.
WARNING Even if you have privileges, please do not push to that repo directly. Pull-requests
- leave an audit trail
- allow 'revert'
Remember that things in setTimeout
are hard to catch. shouldRun
methods need to be robust to this, or they will break the runner.
try {
setTimeout(function (){throw Error("wut?")}, 0)
} catch (e) {
console.log("wont catch it!")
}
// wont catch!
/*** BUT ***/
setTimeout(function (){
try {
throw Error("wut?")
} catch (e) {
console.log("caught it!")
}
}, 0)
Catching a reject in your promise chain:
Promise.reject("No").then(
()=>{}, ()=>{return Promise.resolve('ok')}).then(
console.log
)
All locales are built at once, and put in deploy/%locale%
npm run prebuild # creates 'empty' directories in deploy
npm run build # creates the 'en-US' file.
https://self-repair.mozilla.org/en-US/repair/?{"runner":{"alwaysRun":true}}
For now, github issues at https://github.com/mozilla/self-repair-server/issues
- runs once per session, about 5 minutes after startup.
- because of issue #212, people who clear localStorage won't see heartbeat things. This includes users of some addons, and those with some privacy sensitive settings.