-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from Will-create/main
Updated Html Parser and fix other unit tests
- Loading branch information
Showing
88 changed files
with
3,828 additions
and
817 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
run.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
./run.js/ | ||
./app/ | ||
./app/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/controllers/ : # | ||
/public/ : # | ||
/.bundleignore : H4sIAAAAAAAAE9PTLyrN08sq1ufS008sKIBRWgCG50NNGAAAAA== | ||
/app.bundle : H4sIAAAAAAAAE9NPzs8rKcrPyUktKtZXoA2wUlDm0i8oTcrJTKaVFQh79JJK81JyUjPT8/KLUmllj4dJsacjFLhaBoT4VBb5GVgUFxqWpgUbGFgUe3s6BYWnO7ubGvj5uYNV2dpy6ScWFEBdRxt3gZ0GAEXOJ6DRAQAA | ||
/controllers/default.js : H4sIAAAAAAAAE4VRTU/jMBA9O79iVqoUV6rSOxUHDnxcVqDdoD2sOLjJFAaccRjbhQry31HcNv2AZeXLjEfz3rz38LV1EnxB7IOxFk5hEbkK5FiP4S1Tv65vy3OdX56XMM0nu+EoTdWoaK0h1vkVWuvgjxNb5+NZprrxLBu2b65/lzCdR64t+mmDco9fgS2NQGtW1pkaTmFUzF29mmVK0QL0j82gqBwH5ADv7zD8LcgimwbXMGpUEC+NpVrnP8l74nugppdpOEAPCq0R02BA8bDdBcM1bMCTAqUEQxTuyy5T/VM3Z+VV0TzVJDqV4lzQeRvnlqrpo8/HabF0wdjiwhcvQgEvyKI+vnQCR3r23ECRjZBeeN/1tQoP4l4ARWZrjY/esX4DH6sKvT+BIBEnsDQ24gkc80GXLuu20ajDZLfRCDZu+c9sniPKKiWTqiGa1H0Twt/t6A7Ig+BzJMEaiDeIuzS+Nn5te2RL/KQPyQ5tc0fGDf3eNevvRLPHMyT8P2MP6T/b2n0Aqn2R41EDAAA= | ||
/public/ui.js : H4sIAAAAAAAAE0vOzyvOz0nVy8lP11APyS9JzNHLKlYI9VTXtAYA+drsIhsAAAA= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
exports.install = function() { | ||
ROUTE('GET /', function($) { | ||
$.plain('Hello World'); | ||
}); | ||
|
||
ROUTE('POST /bundles/merge/', function($) { | ||
var payload = $.body; | ||
if (!payload.content || !payload.filename) { | ||
$.invalid('Missing important body parameters filename and content'); | ||
return; | ||
} | ||
|
||
|
||
PATH.mkdir(PATH.root('public/js')); | ||
Total.Fs.writeFile(payload.filename, payload.content, function(err) { | ||
if (err) | ||
throw err; | ||
$.json({ success: true, value: payload.filename }); | ||
}); | ||
}); | ||
|
||
ROUTE('GET /bundles/remove/', function($) { | ||
var query = $.query; | ||
if (!query.filename) { | ||
$.invalid('[filename] is required in query parameters'); | ||
return; | ||
} | ||
|
||
PATH.unlink(query.filename, function(error) { | ||
if (error) { | ||
$.invalid(error); | ||
return; | ||
} | ||
|
||
|
||
$.json({ success: true, value: query.filename }); | ||
}); | ||
}); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('Total.js UI'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,23 @@ | ||
/* eslint-disable */ | ||
require('../../index'); | ||
require('../../test'); | ||
var worker = NEWTHREAD(); | ||
|
||
// Unpack bundle in bundles directory + download bundles from URL (we can add a test bundle to our CDN) | ||
// Merging files | ||
// Removing files | ||
|
||
// load web server and test app | ||
CONF.$imprint = false; | ||
F.http(); | ||
|
||
var url = 'http://localhost:8000/'; | ||
var filename = 'openreports.bundle'; | ||
var bundle_link = 'https://raw.githubusercontent.com/totaljs/flow/master/--bundles--/app.bundle'; | ||
|
||
CONF.$imprint = true; | ||
F.http({ release: true, port: 3000 }); | ||
ON('ready', function() { | ||
//console.log('READY'); | ||
DEBUG = true; | ||
setTimeout( function() { | ||
worker.postMessage(JSON.stringify({ ready: true })); | ||
setTimeout(process.exit, 1000); | ||
}, 3000); | ||
}); | ||
|
||
Test.push('Bundles', function(next) { | ||
// Test.print('String.slug()', [error]); | ||
var arr = []; | ||
|
||
arr.push(function(resume) { | ||
RESTBuilder.GET(url).exec(function(err, response) { | ||
console.log(err, response); | ||
Test.print('From local', err === null ? null : 'App is not successfully started '); | ||
PATH.unlink(PATH.root('bundles/' + filename), function() { | ||
F.restart(); | ||
resume() | ||
}); | ||
}); | ||
}); | ||
|
||
arr.push(function(resume) { | ||
resume(); | ||
}); | ||
|
||
arr.push(function(resume) { | ||
resume(); | ||
}); | ||
|
||
arr.async(function() { | ||
next(); | ||
}); | ||
}); | ||
|
||
setTimeout(() => Test.run(), 600); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* eslint-disable */ | ||
require('../../index'); | ||
require('../../test'); | ||
|
||
// Unpack bundle in bundles directory + download bundles from URL (we can add a test bundle to our CDN) | ||
// Merging files | ||
// Removing files | ||
|
||
// load web server and test app | ||
CONF.$imprint = true; | ||
|
||
var url = 'http://localhost:3000/'; | ||
var filename = 'app.bundle'; | ||
var bundle_link = 'https://raw.githubusercontent.com/totaljs/flow/master/--bundles--/app.bundle'; | ||
var trash = ['index.js.map', 'bundles/' + filename]; | ||
Test.push('Bundles', function(next) { | ||
var arr = []; | ||
|
||
arr.push(function(resume) { | ||
var app = PATH.root('app'); | ||
SHELL('cd ' + app + ' && ' + ' total5 bundle app && cp app.bundle ' + PATH.root('bundles/app.bundle'), function(err) { | ||
resume(); | ||
}); | ||
}); | ||
|
||
arr.push(async function(resume) { | ||
var child = NEWTHREAD('~./index.js'); | ||
child.on('message', function(msg) { | ||
RESTBuilder.GET(url).exec(function(err, response) { | ||
Test.print('From local', err === null ? null : 'App is not successfully started'); | ||
resume() | ||
}); | ||
}); | ||
}); | ||
|
||
arr.push(function(resume) { | ||
var file = 'console.log(window);'; | ||
var filename = PATH.root('/.src/public/js/--ui.js'); | ||
RESTBuilder.POST(url + 'bundles/merge', { filename: filename, content: file }).exec(function(err, res, out) { | ||
resume(); | ||
}); | ||
}); | ||
|
||
arr.push(function(resume) { | ||
RESTBuilder.GET(url + 'ui.js').callback(function(err, res, output) { | ||
Test.print('Test endpoint', err == null ? null : 'Failed to write merge file'); | ||
resume(); | ||
}); | ||
}); | ||
|
||
arr.push(function(resume) { | ||
PATH.unlink(PATH.root('bundles/' + filename), function() { | ||
PATH.exists(PATH.root('bundles/' + filename), function(exists) { | ||
Test.print('Remove bundle', !exists ? null : 'Failed to remove the bundle'); | ||
resume(); | ||
}); | ||
}); | ||
}); | ||
|
||
arr.push(function(resume) { | ||
RESTBuilder.GET(bundle_link).callback(function(err, response, output) { | ||
Test.print('Download bundle', err === null ? null : 'Failed to download bundle from CDN' + err); | ||
Total.Fs.writeFile(PATH.root('bundles/' + filename), output.response, function(error) { | ||
Test.print('Save bundle', err === null ? null : 'Failed to save the bundle file' + error); | ||
resume(); | ||
}); | ||
}); | ||
}); | ||
|
||
arr.push(async function(resume) { | ||
var child = NEWTHREAD('~./index.js'); | ||
child.on('message', function(msg) { | ||
// check if at least a known expected file like modules/cdn.js exists in the unpacked bundle | ||
PATH.exists(PATH.root('.src/modules/cdn.js'), function(exists) { | ||
Test.print('Successfully run downloaded bundle', exists ? null : 'Failed to run the downloaded bundle'); | ||
resume(); | ||
}); | ||
}); | ||
}); | ||
|
||
arr.push(function(resume) { | ||
trash.wait(function(item, next) { | ||
var path = PATH.root(item); | ||
PATH.unlink(path, NOOP); | ||
next(); | ||
}, function(err) { | ||
PATH.rmdir(PATH.root('.src'), function() { | ||
Test.print('Clean up', !err ? null : 'Failed to Clean up the trash'); | ||
resume(); | ||
}); | ||
}); | ||
}); | ||
|
||
arr.async(function() { | ||
next(); | ||
}); | ||
}); | ||
setTimeout(() => { | ||
Test.run(process.exit); | ||
}, 1000); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.