Comparing version 2017.2.20 to 2017.2.28
240
lib.db.js
@@ -580,6 +580,7 @@ /* | ||
local.dbTableDict[this.name] = this; | ||
this.dbRowCount = 0; | ||
this.dbRowList = []; | ||
this.isDirty = null; | ||
this.idIndexList = [{ name: '_id', dict: {} }]; | ||
this.ttl = 0; | ||
this.ttlLast = 0; | ||
}; | ||
@@ -591,22 +592,25 @@ | ||
*/ | ||
var self, tmp; | ||
self = this; | ||
if (!self.isDirty) { | ||
var dbRow, ii, list, ttl; | ||
ttl = Date.now(); | ||
if (!(this.isDirty || | ||
// cleanup ttl every minute | ||
(this.ttl && this.ttlLast + this.ttl < ttl))) { | ||
return; | ||
} | ||
self.isDirty = null; | ||
this.isDirty = null; | ||
this.ttlLast = ttl; | ||
// cleanup dbRowList | ||
self.dbRowList = self.dbRowList.filter(function (dbRow) { | ||
return !dbRow.$meta.isRemoved; | ||
}); | ||
// cleanup idIndexList | ||
self.idIndexList.forEach(function (dict, ii) { | ||
tmp = dict.dict; | ||
dict = self.idIndexList[ii].dict = {}; | ||
Object.keys(tmp).forEach(function (id) { | ||
if (!tmp[id].$meta.isRemoved) { | ||
dict[id] = tmp[id]; | ||
} | ||
}); | ||
}); | ||
list = this.dbRowList; | ||
this.dbRowList = []; | ||
// optimization - for-loop | ||
for (ii = 0; ii < list.length; ii += 1) { | ||
dbRow = list[ii]; | ||
// cleanup ttl | ||
if (this.ttl && dbRow.$meta.ttl < ttl) { | ||
this._crudRemoveOneById(dbRow); | ||
// cleanup isRemoved | ||
} else if (!dbRow.$meta.isRemoved) { | ||
this.dbRowList.push(dbRow); | ||
} | ||
} | ||
}; | ||
@@ -618,3 +622,2 @@ | ||
*/ | ||
this._cleanup(); | ||
return local.dbRowListGetManyByQuery(this.dbRowList, local.normalizeDict(query)); | ||
@@ -627,7 +630,6 @@ }; | ||
*/ | ||
var id, result, self; | ||
self = this; | ||
var id, result; | ||
idDict = local.normalizeDict(idDict); | ||
result = null; | ||
self.idIndexList.some(function (idIndex) { | ||
this.idIndexList.some(function (idIndex) { | ||
id = idDict[idIndex.name]; | ||
@@ -637,5 +639,2 @@ // optimization - hasOwnProperty | ||
result = idIndex.dict[id]; | ||
result = result.$meta.isRemoved | ||
? null | ||
: result; | ||
return result; | ||
@@ -647,9 +646,12 @@ } | ||
local._DbTable.prototype._crudRemoveOneById = function (idDict) { | ||
local._DbTable.prototype._crudRemoveOneById = function (idDict, circularList) { | ||
/* | ||
* this function will remove the dbRow from the dbTable with the given idDict | ||
*/ | ||
var existing, id, result, self; | ||
var id, result, self; | ||
if (!idDict) { | ||
return null; | ||
} | ||
self = this; | ||
idDict = local.normalizeDict(idDict); | ||
circularList = circularList || [idDict]; | ||
result = null; | ||
@@ -659,18 +661,19 @@ self.idIndexList.forEach(function (idIndex) { | ||
// optimization - hasOwnProperty | ||
if (idIndex.dict.hasOwnProperty(id)) { | ||
existing = idIndex.dict[id]; | ||
if (!existing.$meta.isRemoved) { | ||
result = result || existing; | ||
// decrement dbRowCount | ||
self.dbRowCount -= 1; | ||
// optimization - soft-delete | ||
existing.$meta.isRemoved = true; | ||
self.isDirty = true; | ||
// recurse | ||
self._crudRemoveOneById(existing); | ||
} | ||
if (!idIndex.dict.hasOwnProperty(id)) { | ||
return; | ||
} | ||
result = idIndex.dict[id]; | ||
delete idIndex.dict[id]; | ||
// optimization - soft-delete | ||
result.$meta.isRemoved = true; | ||
self.isDirty = true; | ||
if (circularList.indexOf(result) >= 0) { | ||
return; | ||
} | ||
circularList.push(result); | ||
// recurse | ||
self._crudRemoveOneById(result, circularList); | ||
}); | ||
// persist | ||
self._persist(); | ||
this._persist(); | ||
return result; | ||
@@ -684,4 +687,3 @@ }; | ||
*/ | ||
var existing, id, normalize, timeNow, self; | ||
self = this; | ||
var existing, id, normalize, timeNow; | ||
normalize = function (dbRow) { | ||
@@ -715,8 +717,6 @@ /* | ||
// remove existing dbRow | ||
existing = self._crudRemoveOneById(dbRow) || dbRow; | ||
existing = this._crudRemoveOneById(dbRow) || dbRow; | ||
// init meta | ||
dbRow.$meta = {}; | ||
// increment dbRowCount | ||
self.dbRowCount += 1; | ||
self.idIndexList.forEach(function (idIndex) { | ||
dbRow.$meta = { isRemoved: null, ttl: this.ttl + Date.now() }; | ||
this.idIndexList.forEach(function (idIndex) { | ||
// auto-set id | ||
@@ -730,5 +730,5 @@ id = local.dbRowSetId(existing, idIndex); | ||
// update dbRowList | ||
self.dbRowList.push(dbRow); | ||
this.dbRowList.push(dbRow); | ||
// persist | ||
self._persist(); | ||
this._persist(); | ||
return dbRow; | ||
@@ -745,7 +745,6 @@ }; | ||
*/ | ||
var id, result, self; | ||
self = this; | ||
var id, result; | ||
dbRow = local.jsonCopy(local.normalizeDict(dbRow)); | ||
result = null; | ||
self.idIndexList.some(function (idIndex) { | ||
this.idIndexList.some(function (idIndex) { | ||
id = dbRow[idIndex.name]; | ||
@@ -755,19 +754,15 @@ // optimization - hasOwnProperty | ||
result = idIndex.dict[id]; | ||
result = result.$meta.isRemoved | ||
? null | ||
: result; | ||
if (result) { | ||
// remove existing dbRow | ||
self._crudRemoveOneById(result); | ||
// update dbRow | ||
dbRow._timeCreated = undefined; | ||
result = local.objectSetOverride(result, dbRow, Infinity); | ||
return true; | ||
} | ||
return true; | ||
} | ||
}); | ||
if (result) { | ||
// replace dbRow | ||
result = self._crudSetOneById(result); | ||
if (!result) { | ||
return result; | ||
} | ||
// remove existing dbRow | ||
this._crudRemoveOneById(result); | ||
// update dbRow | ||
dbRow._timeCreated = undefined; | ||
local.objectSetOverride(result, dbRow, Infinity); | ||
// replace dbRow | ||
result = this._crudSetOneById(result); | ||
return result; | ||
@@ -805,3 +800,4 @@ }; | ||
*/ | ||
return local.setTimeoutOnError(onError, null, this.dbRowCount); | ||
this._cleanup(); | ||
return local.setTimeoutOnError(onError, null, this.dbRowList.length); | ||
}; | ||
@@ -813,2 +809,3 @@ | ||
*/ | ||
this._cleanup(); | ||
return local.setTimeoutOnError( | ||
@@ -826,2 +823,3 @@ onError, | ||
var self; | ||
this._cleanup(); | ||
self = this; | ||
@@ -840,2 +838,3 @@ return local.setTimeoutOnError(onError, null, local.dbRowProject( | ||
var result; | ||
this._cleanup(); | ||
options = local.normalizeDict(options); | ||
@@ -877,2 +876,3 @@ // get dbRow's with the given options.query | ||
*/ | ||
this._cleanup(); | ||
return local.setTimeoutOnError(onError, null, local.dbRowProject( | ||
@@ -887,9 +887,11 @@ this._crudGetOneById(idDict) | ||
*/ | ||
var result, self; | ||
self = this; | ||
self._cleanup(); | ||
self.dbRowList.some(function (dbRow) { | ||
result = local.dbRowListGetManyByQuery([dbRow], query)[0]; | ||
return result; | ||
}); | ||
var ii, result; | ||
this._cleanup(); | ||
// optimization - for-loop | ||
for (ii = 0; ii < this.dbRowList.length; ii += 1) { | ||
result = local.dbRowListGetManyByQuery([this.dbRowList[ii]], query)[0]; | ||
if (result) { | ||
break; | ||
} | ||
} | ||
return local.setTimeoutOnError(onError, null, local.dbRowProject(result)); | ||
@@ -1026,6 +1028,7 @@ }; | ||
*/ | ||
var result, self; | ||
var ii, result, self; | ||
this._cleanup(); | ||
self = this; | ||
self._cleanup(); | ||
result = ''; | ||
result += self.name + ' ttlSet ' + self.ttl + '\n'; | ||
self.idIndexList.forEach(function (idIndex) { | ||
@@ -1037,6 +1040,7 @@ result += self.name + ' idIndexCreate ' + JSON.stringify({ | ||
}); | ||
self.dbRowList.forEach(function (dbRow) { | ||
// optimization - for-loop | ||
for (ii = 0; ii < self.dbRowList.length; ii += 1) { | ||
result += self.name + ' dbRowSet ' + | ||
JSON.stringify(local.dbRowProject(dbRow)) + '\n'; | ||
}); | ||
JSON.stringify(local.dbRowProject(self.dbRowList[ii])) + '\n'; | ||
} | ||
return local.setTimeoutOnError(onError, null, result.trim()); | ||
@@ -1049,4 +1053,3 @@ }; | ||
*/ | ||
var idIndex, name, self; | ||
self = this; | ||
var dbRow, idIndex, ii, name; | ||
options = local.normalizeDict(options); | ||
@@ -1059,3 +1062,3 @@ name = String(options.name); | ||
// remove existing idIndex | ||
self.idIndexRemove(options); | ||
this.idIndexRemove(options); | ||
// init idIndex | ||
@@ -1067,5 +1070,7 @@ idIndex = { | ||
}; | ||
self.idIndexList.push(idIndex); | ||
Object.keys(self.idIndexList[0].dict).forEach(function (dbRow) { | ||
dbRow = self.idIndexList[0].dict[dbRow]; | ||
this.idIndexList.push(idIndex); | ||
// populate idIndex with dbRowList | ||
// optimization - for-loop | ||
for (ii = 0; ii < this.dbRowList.length; ii += 1) { | ||
dbRow = this.dbRowList[ii]; | ||
// auto-set id | ||
@@ -1075,5 +1080,5 @@ if (!dbRow.$meta.isRemoved) { | ||
} | ||
}); | ||
} | ||
// persist | ||
self._persist(); | ||
this._persist(); | ||
return local.setTimeoutOnError(onError); | ||
@@ -1086,14 +1091,31 @@ }; | ||
*/ | ||
var name, self; | ||
self = this; | ||
var name; | ||
options = local.normalizeDict(options); | ||
name = String(options.name); | ||
self.idIndexList = self.idIndexList.filter(function (idIndex) { | ||
this.idIndexList = this.idIndexList.filter(function (idIndex) { | ||
return idIndex.name !== name || idIndex.name === '_id'; | ||
}); | ||
// persist | ||
self._persist(); | ||
this._persist(); | ||
return local.setTimeoutOnError(onError); | ||
}; | ||
local._DbTable.prototype.ttlSet = function (ttl, onError) { | ||
/* | ||
* this function will set the ttl in milliseconds | ||
*/ | ||
var ii; | ||
// set ttl in milliseconds | ||
this.ttl = ttl; | ||
// update dbRowList | ||
ttl += Date.now(); | ||
// optimization - for-loop | ||
for (ii = 0; ii < this.dbRowList.length; ii += 1) { | ||
this.dbRowList[ii].$meta.ttl = ttl; | ||
} | ||
// persist | ||
this._persist(); | ||
return local.setTimeoutOnError(onError); | ||
}; | ||
local.dbCrudRemoveAll = function (onError) { | ||
@@ -1156,19 +1178,19 @@ /* | ||
) { | ||
try { | ||
// jslint-hack | ||
local.nop(match0); | ||
switch (match2) { | ||
case 'dbRowSet': | ||
dbTable = local.dbTableCreateOne({ isLoaded: true, name: match1 }); | ||
dbTable.crudSetOneById(JSON.parse(match3)); | ||
break; | ||
case 'idIndexCreate': | ||
dbTable = local.dbTableCreateOne({ isLoaded: true, name: match1 }); | ||
dbTable.idIndexCreate(JSON.parse(match3)); | ||
break; | ||
default: | ||
throw new Error('dbImport - invalid operation - ' + match0); | ||
} | ||
} catch (errorCaught) { | ||
local.onErrorDefault(errorCaught); | ||
// jslint-hack | ||
local.nop(match0); | ||
switch (match2) { | ||
case 'dbRowSet': | ||
dbTable = local.dbTableCreateOne({ isLoaded: true, name: match1 }); | ||
dbTable.crudSetOneById(JSON.parse(match3)); | ||
break; | ||
case 'idIndexCreate': | ||
dbTable = local.dbTableCreateOne({ isLoaded: true, name: match1 }); | ||
dbTable.idIndexCreate(JSON.parse(match3)); | ||
break; | ||
case 'ttlSet': | ||
dbTable = local.dbTableCreateOne({ isLoaded: true, name: match1 }); | ||
dbTable.ttlSet(JSON.parse(match3)); | ||
break; | ||
default: | ||
local.onErrorDefault(new Error('dbImport - invalid operation - ' + match0)); | ||
} | ||
@@ -1175,0 +1197,0 @@ }); |
@@ -78,2 +78,6 @@ #!/usr/bin/env node | ||
}); | ||
if (response && (response.statusCode < 200 || response.statusCode >= 300)) { | ||
error = error || new Error(response.statusCode); | ||
console.error(String(response.data)); | ||
} | ||
// debug response | ||
@@ -104,6 +108,2 @@ console.error(new Date().toISOString() + ' http-response ' + JSON.stringify({ | ||
response = _response; | ||
if (response.statusCode < 200 || response.statusCode > 299) { | ||
onError2(new Error(response.statusCode)); | ||
return; | ||
} | ||
chunkList = []; | ||
@@ -361,3 +361,2 @@ response | ||
responseJson: {}, | ||
responseText: '', | ||
sha: options.sha, | ||
@@ -364,0 +363,0 @@ url: options.url |
@@ -1,1 +0,1 @@ | ||
{"author":"kai zhu <kaizhu256@gmail.com>","bin":{"utility2":"lib.utility2.sh","utility2-github-crud":"lib.github_crud.js","utility2-istanbul":"lib.istanbul.js","utility2-jslint":"lib.jslint.js","utility2-uglifyjs":"lib.uglifyjs.js"},"description":"this zero-dependency package will run dynamic browser-tests with coverage (via electron and istanbul)","devDependencies":{"electron-lite":"kaizhu256/node-electron-lite#alpha"},"engines":{"node":">=4.0"},"homepage":"https://github.com/kaizhu256/node-utility2","keywords":["atom","atom-shell","browser","build","busybox","ci","code-coverage","continuous-integration","cover","coverage","docker","electron","headless","headless-browser","instrument","istanbul","jscover","jscoverage","phantom","phantomjs","slimer","slimerjs","test","travis","travis-ci","utility2","web"],"license":"MIT","main":"lib.utility2.js","name":"busybox2","nameAlias":"utility2","nameOriginal":"utility2","os":["darwin","linux"],"repository":{"type":"git","url":"https://github.com/kaizhu256/node-utility2.git"},"scripts":{"build-ci":"./lib.utility2.sh shRun shReadmeBuild","env":"env","example.sh":"./lib.utility2.sh shRunScreenCapture shReadmeTestSh example.sh","heroku-postbuild":"./lib.utility2.sh shRun shDeployHeroku","postinstall":"if [ -f lib.utility2.npm-scripts.sh ]; then ./lib.utility2.npm-scripts.sh postinstall; fi","publish-alias":"VERSION=$(npm info $npm_package_name version); for ALIAS in busybox busybox2 busyweb; do utility2 shRun shNpmPublish $ALIAS $VERSION; utility2 shRun shNpmTestPublished $ALIAS || exit $?; done","start":"export PORT=${PORT:-8080} && if [ -f assets.app.js ]; then node assets.app.js; return; fi && export npm_config_mode_auto_restart=1 && ./lib.utility2.sh shRun shIstanbulCover test.js","test":"export PORT=$(./lib.utility2.sh shServerPortRandom) && export PORT_REPL=$(./lib.utility2.sh shServerPortRandom) && export npm_config_mode_auto_restart=1 && ./lib.utility2.sh test test.js","test-all":"npm test --mode-coverage=all"},"version":"2017.2.20"} | ||
{"author":"kai zhu <kaizhu256@gmail.com>","bin":{"utility2":"lib.utility2.sh","utility2-github-crud":"lib.github_crud.js","utility2-istanbul":"lib.istanbul.js","utility2-jslint":"lib.jslint.js","utility2-uglifyjs":"lib.uglifyjs.js"},"description":"the zero-dependency swiss-army-knife for building, testing, and deploying webapps","devDependencies":{"electron-lite":"kaizhu256/node-electron-lite#alpha"},"engines":{"node":">=4.0"},"homepage":"https://github.com/kaizhu256/node-utility2","keywords":["browser","build","busybox","ci","code-coverage","continuous-integration","deploy","docker","electron","headless-browser","istanbul","jscover","jscoverage","phantomjs","slimerjs","swiss-army-knife","test","test-coverage","travis","travis-ci","utility2","webapp"],"license":"MIT","main":"lib.utility2.js","name":"busybox2","nameAlias":"utility2","nameOriginal":"utility2","os":["darwin","linux"],"repository":{"type":"git","url":"https://github.com/kaizhu256/node-utility2.git"},"scripts":{"build-ci":"./lib.utility2.sh shRun shReadmeBuild","env":"env","example.sh":"./lib.utility2.sh shRunScreenCapture shReadmeTestSh example.sh","heroku-postbuild":"./lib.utility2.sh shRun shDeployHeroku","postinstall":"if [ -f lib.utility2.npm-scripts.sh ]; then ./lib.utility2.npm-scripts.sh postinstall; fi","publish-alias":"VERSION=$(npm info $npm_package_name version); for ALIAS in apidocs busybox busybox2 busyweb test-lite; do ./lib.utility2.sh shRun shNpmPublishAs . $ALIAS $VERSION; ./lib.utility2.sh shRun shNpmTestPublished $ALIAS || exit $?; done","start":"export PORT=${PORT:-8080} && if [ -f assets.app.js ]; then node assets.app.js; return; fi && export npm_config_mode_auto_restart=1 && ./lib.utility2.sh shRun shIstanbulCover test.js","test":"export PORT=$(./lib.utility2.sh shServerPortRandom) && export PORT_REPL=$(./lib.utility2.sh shServerPortRandom) && export npm_config_mode_auto_restart=1 && ./lib.utility2.sh test test.js","test-all":"npm test --mode-coverage=all"},"version":"2017.2.28"} |
263
README.md
utility2 | ||
======== | ||
this zero-dependency package will run dynamic browser-tests with coverage (via electron and istanbul) | ||
the zero-dependency swiss-army-knife for building, testing, and deploying webapps | ||
@@ -32,2 +32,5 @@ [![travis-ci.org build-status](https://api.travis-ci.org/kaizhu256/node-utility2.svg)](https://travis-ci.org/kaizhu256/node-utility2) [![istanbul-coverage](https://kaizhu256.github.io/node-utility2/build..alpha..travis-ci.org/coverage.badge.svg)](https://kaizhu256.github.io/node-utility2/build..alpha..travis-ci.org/coverage.html/index.html) | ||
#### todo | ||
- split function buildApiDoc into file lib.apidoc.js | ||
- split function testRun into file lib.test.js | ||
- rename test.js -> test.$npm_package_nameAlias.js | ||
- add utility2.middlewareLimit | ||
@@ -37,8 +40,12 @@ - add server stress test using electron | ||
#### change since 4460ca51 | ||
- npm publish 2017.2.20 | ||
- add field nameOriginal to package.json | ||
- do not cover rollups | ||
- merge shell-function shNpmPublishAlias into shNpmPublish | ||
- normalize example.html | ||
#### change since 345e02c6 | ||
- npm publish 2017.2.28 | ||
- build - add publish build-branch | ||
- build - auto-clean build if commit-message is CLEAN_BUILD | ||
- build - auto-tag branch in master build-branch | ||
- README.md - normalize browser-script in example.js | ||
- promote utility2 plug in README.md, api-doc, code-coverage, rollup, test-coverage | ||
- lib.db.js - add ttl-cache | ||
- lib.utility2.js - revamp function buildApiDoc | ||
- lib.utility2.sh - revamp shell-function shNpmPublish | ||
- none | ||
@@ -80,3 +87,3 @@ | ||
#### to run this example, follow the instruction in the script below | ||
- [example.sh](https://kaizhu256.github.io/node-utility2/build/example.sh) | ||
- [example.sh](https://kaizhu256.github.io/node-utility2/build..beta..travis-ci.org/example.sh) | ||
```shell | ||
@@ -100,3 +107,3 @@ # example.sh | ||
#### output from electron | ||
#### output from browser | ||
![screen-capture](https://kaizhu256.github.io/node-utility2/build/screen-capture.testExampleSh.browser..png) | ||
@@ -113,3 +120,3 @@ | ||
#### to run this example, follow the instruction in the script below | ||
- [example.js](https://kaizhu256.github.io/node-utility2/build/example.js) | ||
- [example.js](https://kaizhu256.github.io/node-utility2/build..beta..travis-ci.org/example.js) | ||
```javascript | ||
@@ -249,4 +256,38 @@ /* | ||
local.testRunBrowser = function (event) { | ||
switch (event.currentTarget.id) { | ||
if (!event || (event && | ||
event.currentTarget && | ||
event.currentTarget.className && | ||
event.currentTarget.className.includes && | ||
event.currentTarget.className.includes('onreset'))) { | ||
// reset output | ||
Array.from( | ||
document.querySelectorAll('body > .resettable') | ||
).forEach(function (element) { | ||
switch (element.tagName) { | ||
case 'INPUT': | ||
case 'TEXTAREA': | ||
element.value = ''; | ||
break; | ||
default: | ||
element.textContent = ''; | ||
} | ||
}); | ||
} | ||
switch (event && event.currentTarget && event.currentTarget.id) { | ||
case 'testRunButton1': | ||
// show tests | ||
if (document.querySelector('#testReportDiv1').style.display === 'none') { | ||
document.querySelector('#testReportDiv1').style.display = 'block'; | ||
document.querySelector('#testRunButton1').textContent = | ||
'hide internal test'; | ||
local.modeTest = true; | ||
local.testRunDefault(local); | ||
// hide tests | ||
} else { | ||
document.querySelector('#testReportDiv1').style.display = 'none'; | ||
document.querySelector('#testRunButton1').textContent = 'run internal test'; | ||
} | ||
break; | ||
// custom-case | ||
case 'testRunButton2': | ||
// run tests | ||
@@ -260,8 +301,3 @@ local.modeTest = true; | ||
} | ||
// reset stdout | ||
document.querySelector('#outputTextareaStdout1').value = ''; | ||
if (!document.querySelector('#inputTextarea1')) { | ||
return; | ||
} | ||
// try to JSON.stringify #inputTextarea1 | ||
// try to JSON.stringify #inputTextareaEval1 | ||
try { | ||
@@ -271,3 +307,3 @@ document.querySelector('#outputPreJsonStringify1').textContent = ''; | ||
local.jsonStringifyOrdered( | ||
JSON.parse(document.querySelector('#inputTextarea1').value), | ||
JSON.parse(document.querySelector('#inputTextareaEval1').value), | ||
null, | ||
@@ -278,8 +314,9 @@ 4 | ||
} | ||
// jslint #inputTextarea1 | ||
// jslint #inputTextareaEval1 | ||
local.jslint.errorText = ''; | ||
if (document.querySelector('#inputTextarea1').value.indexOf('/*jslint') >= 0) { | ||
if (document.querySelector('#inputTextareaEval1').value | ||
.indexOf('/*jslint') >= 0) { | ||
local.jslint.jslintAndPrint( | ||
document.querySelector('#inputTextarea1').value, | ||
'inputTextarea1.js' | ||
document.querySelector('#inputTextareaEval1').value, | ||
'inputTextareaEval1.js' | ||
); | ||
@@ -293,3 +330,3 @@ } | ||
try { | ||
delete local.global.__coverage__['/inputTextarea1.js']; | ||
delete local.global.__coverage__['/inputTextareaEval1.js']; | ||
} catch (ignore) { | ||
@@ -300,10 +337,9 @@ } | ||
/*jslint evil: true*/ | ||
document.querySelector('#outputTextareaIstanbul1').value = ''; | ||
document.querySelector('#outputTextareaIstanbul1').value = | ||
document.querySelector('#outputTextarea1').value = | ||
local.istanbul.instrumentSync( | ||
document.querySelector('#inputTextarea1').value, | ||
'/inputTextarea1.js' | ||
document.querySelector('#inputTextareaEval1').value, | ||
'/inputTextareaEval1.js' | ||
); | ||
eval(document.querySelector('#outputTextareaIstanbul1').value); | ||
document.querySelector('.istanbulCoverageDiv').innerHTML = | ||
eval(document.querySelector('#outputTextarea1').value); | ||
document.querySelector('#coverageReportDiv1').innerHTML = | ||
local.istanbul.coverageReportCreate({ | ||
@@ -315,18 +351,35 @@ coverage: window.__coverage__ | ||
} | ||
// scroll stdout to bottom | ||
document.querySelector('#outputTextareaStdout1').scrollTop = | ||
document.querySelector('#outputTextareaStdout1').scrollHeight; | ||
} | ||
if (document.querySelector('#inputTextareaEval1') && (!event || (event && | ||
event.currentTarget && | ||
event.currentTarget.className && | ||
event.currentTarget.className.includes && | ||
event.currentTarget.className.includes('oneval')))) { | ||
// try to eval input-code | ||
try { | ||
/*jslint evil: true*/ | ||
eval(document.querySelector('#inputTextareaEval1').value); | ||
} catch (errorCaught) { | ||
console.error(errorCaught.stack); | ||
} | ||
} | ||
}; | ||
// log stderr and stdout to #outputTextareaStdout1 | ||
['error', 'log'].forEach(function (key) { | ||
console['_' + key] = console[key]; | ||
console[key + '_original'] = console[key]; | ||
console[key] = function () { | ||
console['_' + key].apply(console, arguments); | ||
(document.querySelector('#outputTextareaStdout1') || { value: '' }).value += | ||
Array.from(arguments).map(function (arg) { | ||
return typeof arg === 'string' | ||
? arg | ||
: JSON.stringify(arg, null, 4); | ||
}).join(' ') + '\n'; | ||
var element; | ||
console[key + '_original'].apply(console, arguments); | ||
element = document.querySelector('#outputTextareaStdout1'); | ||
if (!element) { | ||
return; | ||
} | ||
// append text to #outputTextareaStdout1 | ||
element.value += Array.from(arguments).map(function (arg) { | ||
return typeof arg === 'string' | ||
? arg | ||
: JSON.stringify(arg, null, 4); | ||
}).join(' ') + '\n'; | ||
// scroll textarea to bottom | ||
element.scrollTop = element.scrollHeight; | ||
}; | ||
@@ -341,3 +394,3 @@ }); | ||
// run tests | ||
local.testRunBrowser({ currentTarget: { id: 'default' } }); | ||
local.testRunBrowser(); | ||
break; | ||
@@ -382,2 +435,6 @@ | ||
}\n\ | ||
.utility2FooterDiv {\n\ | ||
margin-top: 20px;\n\ | ||
text-align: center;\n\ | ||
}\n\ | ||
</style>\n\ | ||
@@ -393,3 +450,3 @@ <style>\n\ | ||
font-family: monospace;\n\ | ||
height: 15rem;\n\ | ||
height: 10rem;\n\ | ||
width: 100%;\n\ | ||
@@ -404,25 +461,27 @@ }\n\ | ||
<!-- utility2-comment\n\ | ||
<div id="ajaxProgressDiv1" style="background: #d00; height: 2px; left: 0; margin: 0; padding: 0; position: fixed; top: 0; transition: background 0.5s, width 1.5s; width: 25%;"></div>\n\ | ||
<div id="ajaxProgressDiv1" style="background: #d00; height: 2px; left: 0; margin: 0; padding: 0; position: fixed; top: 0; transition: background 0.5s, width 1.5s; width: 25%;"></div>\n\ | ||
utility2-comment -->\n\ | ||
<h1>\n\ | ||
<h1>\n\ | ||
<!-- utility2-comment\n\ | ||
<a\n\ | ||
{{#if env.npm_package_homepage}}\n\ | ||
href="{{env.npm_package_homepage}}"\n\ | ||
{{/if env.npm_package_homepage}}\n\ | ||
target="_blank"\n\ | ||
>\n\ | ||
<a\n\ | ||
{{#if env.npm_package_homepage}}\n\ | ||
href="{{env.npm_package_homepage}}"\n\ | ||
{{/if env.npm_package_homepage}}\n\ | ||
target="_blank"\n\ | ||
>\n\ | ||
utility2-comment -->\n\ | ||
{{env.npm_package_nameAlias}} v{{env.npm_package_version}}\n\ | ||
{{env.npm_package_nameAlias}} v{{env.npm_package_version}}\n\ | ||
<!-- utility2-comment\n\ | ||
</a>\n\ | ||
</a>\n\ | ||
utility2-comment -->\n\ | ||
</h1>\n\ | ||
<h3>{{env.npm_package_description}}</h3>\n\ | ||
</h1>\n\ | ||
<h3>{{env.npm_package_description}}</h3>\n\ | ||
<!-- utility2-comment\n\ | ||
<h4><a download href="assets.app.js">download standalone app</a></h4>\n\ | ||
<h4><a download href="assets.app.js">download standalone app</a></h4>\n\ | ||
utility2-comment -->\n\ | ||
\n\ | ||
<label>edit or paste script below to cover and test</label>\n\ | ||
<textarea class="onkeyup" id="inputTextarea1">\n\ | ||
\n\ | ||
\n\ | ||
<label>edit or paste script below to cover and test</label>\n\ | ||
<textarea class="oneval onkeyup onreset" id="inputTextareaEval1">\n\ | ||
// remove comment below to disable jslint\n\ | ||
@@ -480,31 +539,35 @@ /*jslint\n\ | ||
</textarea>\n\ | ||
<pre id="outputPreJsonStringify1"></pre>\n\ | ||
<pre id="outputPreJslint1"></pre>\n\ | ||
<label>instrumented-code</label>\n\ | ||
<textarea id="outputTextareaIstanbul1" readonly></textarea>\n\ | ||
<label>stderr and stdout</label>\n\ | ||
<textarea id="outputTextareaStdout1" readonly></textarea>\n\ | ||
<button class="onclick" id="testRunButton1">run internal test</button><br>\n\ | ||
<div id="testReportDiv1" style="display: none;"></div>\n\ | ||
<h2>coverage-report</h2>\n\ | ||
<div class="istanbulCoverageDiv"></div>\n\ | ||
<pre id="outputPreJsonStringify1"></pre>\n\ | ||
<pre id="outputPreJslint1"></pre>\n\ | ||
<label>instrumented-code</label>\n\ | ||
<textarea class="resettable" id="outputTextarea1" readonly></textarea>\n\ | ||
<label>stderr and stdout</label>\n\ | ||
<textarea class="resettable" id="outputTextareaStdout1" readonly></textarea>\n\ | ||
<button class="onclick onreset" id="testRunButton2">run internal test</button><br>\n\ | ||
<div class="resettable" id="testReportDiv1" style="display: none;"></div>\n\ | ||
<div id="coverageReportDiv1" class="resettable"></div>\n\ | ||
<!-- utility2-comment\n\ | ||
{{#if isRollup}}\n\ | ||
<script src="assets.app.js"></script>\n\ | ||
{{#unless isRollup}}\n\ | ||
{{#if isRollup}}\n\ | ||
<script src="assets.app.js"></script>\n\ | ||
{{#unless isRollup}}\n\ | ||
utility2-comment -->\n\ | ||
<script src="assets.utility2.lib.istanbul.js"></script>\n\ | ||
<script src="assets.utility2.lib.jslint.js"></script>\n\ | ||
<script src="assets.utility2.lib.db.js"></script>\n\ | ||
<script src="assets.utility2.lib.sjcl.js"></script>\n\ | ||
<script src="assets.utility2.lib.uglifyjs.js"></script>\n\ | ||
<script src="assets.utility2.js"></script>\n\ | ||
<script src="jsonp.utility2._stateInit?callback=window.utility2._stateInit"></script>\n\ | ||
<script>window.utility2.onResetBefore.counter += 1;</script>\n\ | ||
<script src="assets.example.js"></script>\n\ | ||
<script src="assets.test.js"></script>\n\ | ||
<script>window.utility2.onResetBefore();</script>\n\ | ||
<script src="assets.utility2.lib.istanbul.js"></script>\n\ | ||
<script src="assets.utility2.lib.jslint.js"></script>\n\ | ||
<script src="assets.utility2.lib.db.js"></script>\n\ | ||
<script src="assets.utility2.lib.sjcl.js"></script>\n\ | ||
<script src="assets.utility2.lib.uglifyjs.js"></script>\n\ | ||
<script src="assets.utility2.js"></script>\n\ | ||
<script src="jsonp.utility2._stateInit?callback=window.utility2._stateInit"></script>\n\ | ||
<script>window.utility2.onResetBefore.counter += 1;</script>\n\ | ||
<script src="assets.example.js"></script>\n\ | ||
<script src="assets.test.js"></script>\n\ | ||
<script>window.utility2.onResetBefore();</script>\n\ | ||
<!-- utility2-comment\n\ | ||
{{/if isRollup}}\n\ | ||
{{/if isRollup}}\n\ | ||
utility2-comment -->\n\ | ||
<div class="utility2FooterDiv">\n\ | ||
[ this app was created with\n\ | ||
<a href="https://github.com/kaizhu256/node-utility2" target="_blank">utility2</a>\n\ | ||
]\n\ | ||
</div>\n\ | ||
</body>\n\ | ||
@@ -599,3 +662,3 @@ </html>\n\ | ||
}, | ||
"description": "this zero-dependency package will run dynamic browser-tests with coverage (via electron and istanbul)", | ||
"description": "the zero-dependency swiss-army-knife for building, testing, and deploying webapps", | ||
"devDependencies": { | ||
@@ -609,4 +672,2 @@ "electron-lite": "kaizhu256/node-electron-lite#alpha" | ||
"keywords": [ | ||
"atom", | ||
"atom-shell", | ||
"browser", | ||
@@ -618,21 +679,18 @@ "build", | ||
"continuous-integration", | ||
"cover", | ||
"coverage", | ||
"deploy", | ||
"docker", | ||
"electron", | ||
"headless", | ||
"headless-browser", | ||
"instrument", | ||
"istanbul", | ||
"jscover", | ||
"jscoverage", | ||
"phantom", | ||
"phantomjs", | ||
"slimer", | ||
"slimerjs", | ||
"swiss-army-knife", | ||
"test", | ||
"test-coverage", | ||
"travis", | ||
"travis-ci", | ||
"utility2", | ||
"web" | ||
"webapp" | ||
], | ||
@@ -658,3 +716,3 @@ "license": "MIT", | ||
"postinstall": "if [ -f lib.utility2.npm-scripts.sh ]; then ./lib.utility2.npm-scripts.sh postinstall; fi", | ||
"publish-alias": "VERSION=$(npm info $npm_package_name version); for ALIAS in busybox busybox2 busyweb; do utility2 shRun shNpmPublish $ALIAS $VERSION; utility2 shRun shNpmTestPublished $ALIAS || exit $?; done", | ||
"publish-alias": "VERSION=$(npm info $npm_package_name version); for ALIAS in apidocs busybox busybox2 busyweb test-lite; do ./lib.utility2.sh shRun shNpmPublishAs . $ALIAS $VERSION; ./lib.utility2.sh shRun shNpmTestPublished $ALIAS || exit $?; done", | ||
"start": "export PORT=${PORT:-8080} && if [ -f assets.app.js ]; then node assets.app.js; return; fi && export npm_config_mode_auto_restart=1 && ./lib.utility2.sh shRun shIstanbulCover test.js", | ||
@@ -664,3 +722,3 @@ "test": "export PORT=$(./lib.utility2.sh shServerPortRandom) && export PORT_REPL=$(./lib.utility2.sh shServerPortRandom) && export npm_config_mode_auto_restart=1 && ./lib.utility2.sh test test.js", | ||
}, | ||
"version": "2017.2.20" | ||
"version": "2017.2.28" | ||
} | ||
@@ -808,4 +866,2 @@ ``` | ||
. ./lib.utility2.sh && shInit | ||
# cleanup github-gh-pages dir | ||
# export BUILD_GITHUB_UPLOAD_PRE_SH="rm -fr build" | ||
# init github-gh-pages commit-limit | ||
@@ -822,3 +878,13 @@ export COMMIT_LIMIT=20 | ||
shBuildCiDefault | ||
git tag "$npm_package_version" | ||
git push "git@github.com:$GITHUB_REPO.git" "$npm_package_version" || true | ||
;; | ||
publish) | ||
printf "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > "$HOME/.npmrc" | ||
export CI_BRANCH=alpha | ||
shNpmPublishAs | ||
shBuildCiDefault | ||
npm run publish-alias | ||
git push "git@github.com:$GITHUB_REPO.git" publish:beta | ||
;; | ||
esac | ||
@@ -899,1 +965,6 @@ # docker build | ||
``` | ||
# misc | ||
- this package was created with [utility2](https://github.com/kaizhu256/node-utility2) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
2225292
37801
946
32
89