├── .bowerrc
├── .gitignore
├── .npmignore
├── README.md
├── build
└── catproject.json
├── catcli.js
├── chromext
├── CatIcon.jpg
├── TupacCatIcon.jpg
├── background.js
├── cat-icon-128.png
├── cat-icon-16.png
├── cat-icon-32.png
├── cat-icon-48.png
├── consoleBackground.jpg
├── contentcss.css
├── contentscript.js
├── contentscript_fake.js
├── icon.png
├── jquery-1.7.2.min.js
├── manifest.json
├── popup.html
└── popup.js
├── how-to.txt
├── package.json
├── postinstall.js
├── precatinstall.js
├── resources
├── cat.json
├── catproject.json
├── images
│ ├── Logo48x48-01.png
│ ├── cat-empty.xcf
│ ├── catjsyoutube-s.png
│ ├── catjsyoutube.png
│ ├── gtac.jpg
│ └── velocity.jpg
└── log.properties
├── settings.json
├── src
├── libraries
│ ├── bower.json
│ ├── bowerutils.bat
│ ├── canvg
│ │ └── canvg.min.js
│ ├── cat
│ │ ├── Cat.js
│ │ ├── CatSettings.js
│ │ ├── Gruntfile.js
│ │ ├── config
│ │ │ └── catconfig.json
│ │ ├── core
│ │ │ ├── Config.js
│ │ │ ├── Errors.js
│ │ │ ├── Ext
│ │ │ │ ├── AssertUtils.js
│ │ │ │ └── ChaiUtils.js
│ │ │ ├── manager
│ │ │ │ ├── client.js
│ │ │ │ ├── controller.js
│ │ │ │ └── statecontroller.js
│ │ │ ├── plugins
│ │ │ │ ├── JQHelper.js
│ │ │ │ └── Simulate.js
│ │ │ ├── test
│ │ │ │ ├── TestActions.js
│ │ │ │ ├── TestManager.js
│ │ │ │ └── TestQueue.js
│ │ │ ├── ui
│ │ │ │ └── Status.js
│ │ │ └── utils
│ │ │ │ ├── AJAX.js
│ │ │ │ ├── IFrame.js
│ │ │ │ ├── Loader.js
│ │ │ │ ├── Request.js
│ │ │ │ ├── Scrap.js
│ │ │ │ ├── Signal.js
│ │ │ │ ├── Storage.js
│ │ │ │ ├── TestsDB.js
│ │ │ │ └── Utils.js
│ │ ├── css
│ │ │ ├── cat.css
│ │ │ └── less
│ │ │ │ ├── app.less
│ │ │ │ └── lesshat.less
│ │ ├── lessbuilder.js
│ │ ├── package.json
│ │ ├── plugins
│ │ │ ├── angular
│ │ │ │ └── angular.js
│ │ │ ├── deviceinfo
│ │ │ │ └── deviceinfo.js
│ │ │ ├── dom
│ │ │ │ └── dom.js
│ │ │ ├── enyo
│ │ │ │ └── enyo.js
│ │ │ ├── jqm
│ │ │ │ └── jqm.js
│ │ │ ├── jquery
│ │ │ │ └── jquery.js
│ │ │ ├── screenshot
│ │ │ │ └── screenshot.js
│ │ │ ├── sencha
│ │ │ │ └── sencha.js
│ │ │ ├── testdata
│ │ │ │ └── testdata.js
│ │ │ └── wait
│ │ │ │ └── wait.js
│ │ └── target
│ │ │ ├── cat.css
│ │ │ ├── cat.js
│ │ │ └── cat.json
│ ├── chai
│ │ └── chai.js
│ ├── flyer
│ │ ├── flyer.js
│ │ └── flyer.min.js
│ ├── html2canvas
│ │ ├── html2canvas.min.js
│ │ └── html2canvas.svg.min.js
│ ├── jasmine
│ │ └── lib
│ │ │ ├── catjs-jasmine-boot.js
│ │ │ ├── jasmine-boot.js
│ │ │ ├── jasmine-console.js
│ │ │ ├── jasmine-html.js
│ │ │ ├── jasmine-spec-runner.html
│ │ │ ├── jasmine-tap-reporter.js
│ │ │ ├── jasmine.css
│ │ │ ├── jasmine.js
│ │ │ └── jasmine_favicon.png
│ ├── js.utils
│ │ ├── lib
│ │ │ └── domReady.js
│ │ └── target
│ │ │ ├── jsutils-min-all.js
│ │ │ ├── jsutils-min.js
│ │ │ └── jsutils-require-min.js
│ ├── jspath
│ │ └── lib
│ │ │ └── jspath.js
│ ├── manifest.json
│ ├── q
│ │ └── q.min.js
│ ├── requirejs
│ │ └── require.js
│ ├── resemble
│ │ └── resemble.js
│ ├── tmr
│ │ └── target
│ │ │ ├── tmr-base-min.js
│ │ │ ├── tmr-mapper-min.js
│ │ │ ├── tmr-min-all.js
│ │ │ ├── tmr-min.js
│ │ │ └── tmr-require-min.js
│ └── underscore
│ │ ├── underscore-min.js
│ │ ├── underscore-min.map
│ │ └── underscore.js
├── module
│ ├── CAT.js
│ ├── CATCli.js
│ ├── CATDebug.js
│ ├── CATGlob.js
│ ├── Cache.js
│ ├── Console.js
│ ├── Flow.js
│ ├── Properties.js
│ ├── Watch.js
│ ├── analytics
│ │ └── analytics.js
│ ├── common
│ │ ├── Library.js
│ │ └── parser
│ │ │ ├── Comment.js
│ │ │ └── Parser.js
│ ├── config
│ │ ├── CATConfig.js
│ │ ├── manifest
│ │ │ └── manifest.js
│ │ └── project
│ │ │ ├── Action.js
│ │ │ ├── Config.js
│ │ │ ├── Extension.js
│ │ │ ├── Filter.js
│ │ │ └── Task.js
│ ├── extension
│ │ ├── Base.js
│ │ ├── inject
│ │ │ ├── action.js
│ │ │ ├── build
│ │ │ │ ├── cache.js
│ │ │ │ ├── manager.js
│ │ │ │ └── user.js
│ │ │ └── parser
│ │ │ │ ├── replaceInfo.js
│ │ │ │ └── singleLine.js
│ │ ├── loader
│ │ │ └── action.js
│ │ ├── manager
│ │ │ └── action.js
│ │ ├── phantomjs
│ │ │ ├── action.js
│ │ │ └── phantom-bridge.js
│ │ ├── runner
│ │ │ ├── action.js
│ │ │ └── runner.js
│ │ ├── scan
│ │ │ └── action.js
│ │ ├── spawn
│ │ │ └── action.js
│ │ └── webserver
│ │ │ ├── action.js
│ │ │ ├── rest
│ │ │ ├── assert.js
│ │ │ ├── config.js
│ │ │ ├── deviceinfo.js
│ │ │ ├── entity
│ │ │ │ ├── Assert.js
│ │ │ │ ├── Params.js
│ │ │ │ └── Reporter.js
│ │ │ ├── helpers
│ │ │ │ └── colors.js
│ │ │ ├── runner.js
│ │ │ ├── scrap
│ │ │ │ ├── TestConfig.js
│ │ │ │ └── scrap.js
│ │ │ └── screenshot.js
│ │ │ └── web-server.js
│ ├── info
│ │ ├── Base.js
│ │ ├── Info.js
│ │ └── entity
│ │ │ ├── Device.js
│ │ │ ├── Deviceinfo.js
│ │ │ ├── Generic.js
│ │ │ └── Screenshot.js
│ ├── plugin
│ │ ├── Base.js
│ │ ├── autotest.js
│ │ ├── clean.js
│ │ ├── console.js
│ │ ├── copy.js
│ │ ├── fileparse.js
│ │ ├── libraries.js
│ │ ├── minify.js
│ │ ├── phantomjs.js
│ │ ├── runner.js
│ │ ├── sample.js
│ │ ├── scrap.js
│ │ ├── scrap
│ │ │ ├── Cache.js
│ │ │ ├── Context.js
│ │ │ ├── Scrap.js
│ │ │ ├── ScrapConfigItem.js
│ │ │ ├── ScrapEnum.js
│ │ │ ├── ScrapItem.js
│ │ │ ├── ScrapUtils.js
│ │ │ ├── parser
│ │ │ │ ├── CommonParser.js
│ │ │ │ ├── Parser.js
│ │ │ │ ├── SimpleParser.js
│ │ │ │ └── SimpleSingleParser.js
│ │ │ └── printer
│ │ │ │ ├── Generic.js
│ │ │ │ ├── Jasmine.js
│ │ │ │ └── Printer.js
│ │ ├── server
│ │ │ └── standalone.js
│ │ ├── spawn.js
│ │ └── webserver.js
│ ├── project
│ │ ├── Project.js
│ │ ├── init
│ │ │ ├── commandInit.js
│ │ │ ├── init.js
│ │ │ └── projects
│ │ │ │ ├── base
│ │ │ │ ├── Gruntfile.js
│ │ │ │ ├── package.json
│ │ │ │ ├── phantom
│ │ │ │ │ └── phantomjs-script.js
│ │ │ │ └── plugins
│ │ │ │ │ └── custom-plugin.js
│ │ │ │ ├── cat
│ │ │ │ └── catproject.json
│ │ │ │ ├── example
│ │ │ │ ├── app
│ │ │ │ │ ├── app.css
│ │ │ │ │ ├── app.js
│ │ │ │ │ ├── index.html
│ │ │ │ │ └── lib
│ │ │ │ │ │ └── jquery.js
│ │ │ │ └── catproject.json
│ │ │ │ └── server
│ │ │ │ └── catproject.json
│ │ └── src
│ │ │ ├── common
│ │ │ └── README.txt
│ │ │ └── config
│ │ │ └── testdata.json
│ ├── testunit
│ │ └── TestManager.js
│ └── utils
│ │ ├── Code.js
│ │ ├── ExtUtils.js
│ │ ├── RegExp.js
│ │ ├── SysUtils.js
│ │ ├── TemplateUtils.js
│ │ ├── Uglify.js
│ │ ├── Utils.js
│ │ ├── entity
│ │ ├── BaseEntity.js
│ │ ├── Entity.js
│ │ └── jasmine
│ │ │ ├── Jasmine.js
│ │ │ └── Row.js
│ │ └── fs
│ │ ├── Config.js
│ │ ├── JSON.js
│ │ └── MetaData.js
├── plugins
│ ├── Behavior.js
│ ├── scrap-angular.js
│ ├── scrap-common.js
│ ├── scrap-deviceinfo.js
│ ├── scrap-dom.js
│ ├── scrap-enyo.js
│ ├── scrap-jasmine.js
│ ├── scrap-jqm.js
│ ├── scrap-jquery.js
│ ├── scrap-mock.js
│ ├── scrap-screenshot.js
│ ├── scrap-sencha.js
│ ├── scrap-wait.js
│ └── utils
│ │ ├── DelayManagerUtils.js
│ │ ├── ExpressionUtils.js
│ │ └── Utils.js
└── template
│ └── scrap
│ ├── _assert_call.tpl
│ ├── _assert_call_obsolete.tpl
│ ├── _cat_call.tpl
│ ├── _cat_embed_js.tpl
│ ├── _func.tpl
│ ├── _func_declare.tpl
│ ├── _func_manager.tpl
│ ├── _func_snippet.tpl
│ ├── _func_user.tpl
│ ├── _import_css.tpl
│ ├── _import_js.tpl
│ ├── _require_globals_snippet.tpl
│ └── _require_js.tpl
└── test
├── core-tests
├── app-example
│ ├── cat-project
│ │ ├── Gruntfile.js
│ │ ├── catproject.json
│ │ ├── package.json
│ │ ├── phantom
│ │ │ └── phantomjs-script.js
│ │ ├── plugins
│ │ │ └── custom-plugin.js
│ │ └── src
│ │ │ ├── common
│ │ │ └── README.txt
│ │ │ └── config
│ │ │ ├── cat.json
│ │ │ └── testdata.json
│ └── index.html
├── common.js
├── test-init.js
├── test-run.js
└── test-server.js
└── test.js
/.bowerrc:
--------------------------------------------------------------------------------
1 | {
2 | "directory" : "../libraries/"
3 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | tmp
3 | .idea
4 | .cat
5 | .DS_Store
6 | *.log
7 | _cat_md.json
8 | build/target
9 | build/src
10 | *.xml
11 | test/enyo/cat-project/
12 | test/sencha/cat-project/
13 | test/init-test/cat-project/
14 | test/catjs_example/cat-project/
15 | test/jqm/cat-project/
16 | test/sencha-kitchen-sink/cat-project/
17 | settings.json~
18 | package.json~
19 | test/test-apps-master/
20 | test/catjs-test-apps.zip
21 | .bower.json
22 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | *.txt
2 | *.log
3 | .idea
4 | .cat
5 | .DS_Store
6 | *.log
7 | how-to.txt
8 | chromext
9 | resources/images
10 | test/test-apps-master/
11 | test/catjs-test-apps.zip
--------------------------------------------------------------------------------
/catcli.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | 'use strict';
4 |
5 | var pjson = require('./package.json');
6 |
7 | console.log("[catjs] version: " + pjson.version);
8 | console.log("[catjs] path: " + __dirname);
9 |
10 | require("./src/module/CATCli.js").init({dirname:__dirname});
11 |
--------------------------------------------------------------------------------
/chromext/CatIcon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/chromext/CatIcon.jpg
--------------------------------------------------------------------------------
/chromext/TupacCatIcon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/chromext/TupacCatIcon.jpg
--------------------------------------------------------------------------------
/chromext/background.js:
--------------------------------------------------------------------------------
1 | /*
2 | chrome.tabs.getSelected(null, function(tab) {
3 | chrome.tabs.sendRequest(tab.id, {greeting: "hello"}, function(response) {
4 | console.log(response.farewell);
5 | });
6 | });
7 | */
--------------------------------------------------------------------------------
/chromext/cat-icon-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/chromext/cat-icon-128.png
--------------------------------------------------------------------------------
/chromext/cat-icon-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/chromext/cat-icon-16.png
--------------------------------------------------------------------------------
/chromext/cat-icon-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/chromext/cat-icon-32.png
--------------------------------------------------------------------------------
/chromext/cat-icon-48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/chromext/cat-icon-48.png
--------------------------------------------------------------------------------
/chromext/consoleBackground.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/chromext/consoleBackground.jpg
--------------------------------------------------------------------------------
/chromext/contentcss.css:
--------------------------------------------------------------------------------
1 |
2 | .catLogConsole{position:absolute;left:500px;top:10px;width:400px;height:250px;z-index:999999;border:1px solid #555;overflow:hidden;-moz-box-shadow: 5px 5px 5px #ccc;-webkit-box-shadow: 5px 5px 5px #ccc;box-shadow: 5px 5px 5px #ccc;}
3 | .catLogBackground{width:100%;height:250px;background-color:rgba(255, 255, 255, 0.5);z-index:10;}
4 | .catLogConsoleTitle{position:absolute;left:0;top:0;width:100%;z-index:100;height:25px;background-color:rgba(59,89,153, 0.7);color:#fff;font-weight:bold;line-height:24px;font-family:arial;text-indent:10px;cursor:move;}
5 | /*.catLogConsole > div{position:absolute;left:1px;top:26px;width:296px;height:220px;border:1px solid red;}*/
6 | .catLogConsole > div#logConsole{width:100%;padding:0 5px;position:absolute;top:30px;left:0;overflow-y:auto;max-height:212px;z-index:50;}
7 | .catLogConsole ol{
8 | padding:0;margin:0;
9 | background-color:#ccc;
10 | /*background:url('chrome-extension://__MSG_@@extension_id__/consoleBackground.jpg') repeat-y left top;*/
11 | }/*background-color:#ccc;*/
12 | .catLogConsole ol li{background: #fff;margin-left:30px;padding-left:10px;list-style:decimal outside !important;border-bottom:1px solid #f1f1f1;}
13 | /*.catLogConsole ol li span{display:block;background-color:#f0f;}*/
14 | .catLogConsole ol li p{margin:0px; padding:3px 0;}
--------------------------------------------------------------------------------
/chromext/contentscript_fake.js:
--------------------------------------------------------------------------------
1 | console.log("extension test.... FAKE");
2 |
3 |
--------------------------------------------------------------------------------
/chromext/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/chromext/icon.png
--------------------------------------------------------------------------------
/chromext/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Scrap Extension",
3 | "version": "1.0",
4 | "manifest_version": 2,
5 | "description": "CAT extension",
6 | "permissions": ["tabs", "http://127.0.0.1:8080/*"],
7 | "browser_action": {
8 | "default_icon": "cat-icon-16.png",
9 | "default_popup": "popup.html"
10 | },
11 | "icons" : {
12 | "16" : "cat-icon-16.png",
13 | "48" : "cat-icon-48.png",
14 | "128" : "cat-icon-128.png"
15 | }
16 | }
--------------------------------------------------------------------------------
/chromext/popup.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Getting Started Extension's Popup
5 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | CAT - Ninja testing
32 |
33 |
34 |
35 |
36 | Select test #
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | Test cannot run on this page...
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/chromext/popup.js:
--------------------------------------------------------------------------------
1 |
2 | // Add links to allLinks and visibleLinks, sort and show them. send_links.js is
3 | // injected into all frames of the active tab, so this listener may be called
4 | // multiple times.
5 | chrome.extension.onRequest.addListener(
6 | function(data) {
7 | switch(data.requestId){
8 | case 1:
9 | if(data.console!=null){
10 | document.getElementById("showConsole").checked = data.console;
11 | }
12 | chrome.tabs.getSelected(null, function(tab) {
13 | chrome.tabs.sendRequest(tab.id,
14 | {"getStepsInfo": true},
15 | function readResponse() {}
16 | );
17 | });
18 | break;
19 | case 2:
20 | var steps = data.steps.split(",");
21 | var currentStep = data.currentStep;
22 |
23 | console.log("popup currentStep>>", currentStep)
24 |
25 | if(!currentStep || currentStep=="" || currentStep.length==0){
26 | currentStep = steps[0];
27 | };
28 | var msg = data.msg;
29 | document.getElementById("canRun").innerHTML = msg;
30 | document.getElementById("canRun").style.color = "#999";
31 | document.getElementById("btnGo").disabled = false;
32 | // clear all drop-down nodes - reset
33 | var dropdown = document.getElementById("testSelection");
34 | while ( dropdown.firstChild ) {
35 | dropdown.removeChild( dropdown.firstChild )
36 | }
37 | // add new nodes
38 | for(var i=0;i= 0.10.0"
31 | },
32 | "main": "src/module/CAT",
33 | "bin": {
34 | "catcli": "catcli.js"
35 | },
36 | "scripts": {
37 | "test": "node ./test/test.js",
38 | "postinstall": "node postinstall.js"
39 | },
40 | "dependencies": {
41 | "mobilerunner": "latest",
42 | "fs.extra": "~1.2.1",
43 | "typedas": "~1.0.0",
44 | "log": "~1.4.0",
45 | "nopt": "~2.2.0",
46 | "properties": "~0.3.3",
47 | "line-reader": "~0.2.3",
48 | "string-format": "~0.2.1",
49 | "js-beautify": "~1.4.0",
50 | "watch": "~0.8.0",
51 | "date-format-lite": "~0.1.5",
52 | "line-by-line": "~0.1.1",
53 | "underscore": "~1.5.1",
54 | "minimatch": "~0.2.12",
55 | "uglify-js": "~2.4.0",
56 | "express": "~3.4.4",
57 | "test-model-reporter": "~0.1.83",
58 | "js.utils": "~0.2.01",
59 | "require-mapper": "~0.0.3",
60 | "glob": "~3.2.7",
61 | "my-ip": "~1.1.0",
62 | "json-lint": "~0.1.0",
63 | "prompt": "~0.2.12",
64 | "jetty": "~0.2.1",
65 | "winston": "~0.7.2",
66 | "wrench": "~1.5.8",
67 | "contribute": "~0.0.3",
68 | "colors": "~0.6.2",
69 | "autonpm": "~0.1.2",
70 | "faker": "~2.0.1",
71 | "stripcolorcodes": "^0.1.0",
72 | "express-useragent": "^0.1.2",
73 | "jshint": "~2.6.3"
74 | },
75 | "devDependencies": {
76 | "less": "^1.7.5"
77 | },
78 | "keywords": [
79 | "runner",
80 | "catrunner",
81 | "annotation",
82 | "app",
83 | "mobile",
84 | "html5",
85 | "test",
86 | "testing",
87 | "unit",
88 | "automation",
89 | "ui",
90 | "jquery",
91 | "sencha",
92 | "chai",
93 | "enyo"
94 | ],
95 | "contributors": [
96 | "Arik Lewin (https://github.com/lastboy)"
97 | ],
98 | "license": "Apache-2.0"
99 | }
100 |
--------------------------------------------------------------------------------
/postinstall.js:
--------------------------------------------------------------------------------
1 | console.log("\n\n ^ ^");
2 | console.log(" |\\ /|");
3 | console.log(" | \\ _ _ _ _ _ / |");
4 | console.log(" / \\");
5 | console.log(" \\ /");
6 | console.log(" | <#> <#> |");
7 | console.log(" | * |");
8 | console.log(" | | |");
9 | console.log(" \\ \\/ \\/ /");
10 | console.log(" \\ _ _ _ _ _ _ / \n");
11 |
12 | console.log(" _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _");
13 | console.log(" ");
14 | console.log(" Get a free cool catjs T-Shirt \n");
15 | console.log(" email us at cat.js.team@gmail.com ")
16 | console.log(" with your email address and size ");
17 | console.log("_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n\n");
18 |
--------------------------------------------------------------------------------
/precatinstall.js:
--------------------------------------------------------------------------------
1 | var childProcess,
2 | settingConfig,
3 | settingFailed = false,
4 | connectionFailed = false,
5 | os = require("os");
6 |
7 | function _processIt(command, args, opt, callback) {
8 |
9 | var childProcess = require("child_process"),
10 | process;
11 |
12 | if (childProcess) {
13 | if (os.platform() === "win32") {
14 | args.unshift(command);
15 | args.unshift("/c");
16 | command = "cmd";
17 | }
18 | process = childProcess.spawn(command, args, opt);
19 |
20 | process.stderr.on('data', function (err) {
21 | console.log('child process exited with errors, ' + err);
22 | });
23 |
24 | process.on('close', function (code) {
25 | if (code !== 0) {
26 | console.log('child process exited with code ' + code);
27 | } else {
28 | if (callback) {
29 | callback.call(this);
30 | }
31 |
32 | }
33 | });
34 | }
35 | }
36 |
37 | function _testConnection(host, callback) {
38 | require('dns').resolve(host, function (err) {
39 | if (err) {
40 | // failed to connect
41 | connectionFailed = true;
42 | console.error("Test connection to: ", host ,"failed with errors. Check your cable and your proxy settings", err);
43 | }
44 | else {
45 | //connected
46 |
47 | }
48 |
49 | if (callback) {
50 | callback.call(this, err);
51 | }
52 | });
53 | }
54 |
55 | function _isProxy() {
56 | return settingConfig.proxy.enable;
57 | }
58 |
59 | function _getProxyURL() {
60 | var host = settingConfig.proxy.base.host,
61 | port = settingConfig.proxy.base.port;
62 |
63 | return (_isProxy() ? ['"',"http://", host, ":", port, '"'].join("") : undefined);
64 | }
65 |
66 | settingConfig = require('fs').readFileSync("settings.json");
67 | if (settingConfig) {
68 | try {
69 | settingConfig = JSON.parse(settingConfig);
70 | } catch (e) {
71 | console.error("Failed to parse setting.json content. ", e);
72 | settingFailed = true;
73 | }
74 | }
75 |
76 | function _process() {
77 |
78 | _testConnection("www.google.com", function() {
79 | _testConnection("www.npmjs.org", function() {
80 |
81 | });
82 | });
83 |
84 |
85 | }
86 |
87 | if (!settingFailed) {
88 |
89 | if (_isProxy()) {
90 | _processIt("npm", ["config", "set", "proxy", _getProxyURL()], undefined, function() {
91 | _processIt("npm", ["config", "set", "https-proxy", _getProxyURL()], undefined, function() {
92 | _processIt("git", ["config", "http.proxy", _getProxyURL()], undefined, function() {
93 | _process();
94 | });
95 | });
96 | });
97 |
98 | } else {
99 | _processIt("npm", ["config", "delete", "proxy"], undefined, function() {
100 | _processIt("npm", ["config", "delete", "https-proxy"], undefined, function() {
101 | _processIt("git", ["config", "--unset", "http.proxy"], undefined, function() {
102 | _process();
103 | });
104 | });
105 | });
106 |
107 |
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/resources/cat.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "template": {
4 | "path": "src/template/project/"
5 | },
6 | "libraries" : {
7 | "path": "src/libraries/"
8 | }
9 | },
10 |
11 | "plugins" : [
12 | "src/module/plugin/",
13 | "src/plugins/"
14 | ],
15 |
16 | "extensions" : [
17 | {
18 | "name": "manager",
19 | "impl": "src/module/extension/manager/action.js"
20 | },
21 | {
22 | "name": "webserver",
23 | "impl": "src/module/extension/webserver/action.js"
24 | },
25 | {
26 | "name": "runner",
27 | "impl": "src/module/extension/runner/action.js"
28 | },
29 | {
30 | "name": "phantomjs",
31 | "impl": "src/module/extension/phantomjs/action.js"
32 | }, {
33 | "name": "spawn",
34 | "impl": "src/module/extension/spawn/action.js"
35 | },
36 | {
37 | "name": "scan",
38 | "impl": "src/module/extension/scan/action.js"
39 | },
40 | {
41 | "name": "clean",
42 | "impl": "src/module/extension/clean/action.js"
43 | },
44 | {
45 | "name": "inject",
46 | "impl": "src/module/extension/inject/action.js"
47 | },
48 | {
49 | "name": "loader",
50 | "impl": "src/module/extension/loader/action.js",
51 | "phase": "init"
52 | }
53 | ]
54 | }
--------------------------------------------------------------------------------
/resources/images/Logo48x48-01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/resources/images/Logo48x48-01.png
--------------------------------------------------------------------------------
/resources/images/cat-empty.xcf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/resources/images/cat-empty.xcf
--------------------------------------------------------------------------------
/resources/images/catjsyoutube-s.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/resources/images/catjsyoutube-s.png
--------------------------------------------------------------------------------
/resources/images/catjsyoutube.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/resources/images/catjsyoutube.png
--------------------------------------------------------------------------------
/resources/images/gtac.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/resources/images/gtac.jpg
--------------------------------------------------------------------------------
/resources/images/velocity.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/resources/images/velocity.jpg
--------------------------------------------------------------------------------
/resources/log.properties:
--------------------------------------------------------------------------------
1 | ###################### Log Messages ##########################
2 |
3 | # general
4 | cat.mdata.file.not.exists = "{0} CAT Meta Data file does not exists"
5 | cat.file.failed = "{0} Failed to load file {1}, it might not exists or empty. {2}"
6 | cat.file.copy.failed = "{0} Failed to copy file: '{1}' {2}"
7 |
8 | #flow
9 | cat.flow.base = "{0} {1} \n"
10 |
11 | # debug
12 | cat.mdata.write = "{0} CAT metadata file saved successfully "
13 | cat.mdata.read = "{0} CAT metadata file loaded successfully "
14 | cat.source.project.file.create = "{0} Source file '{1}' created"
15 | cat.source.project.file.exists = "{0} Source file '{1}' exists"
16 | cat.project.resource.exists = "{0} Project's resource '{1}' already exists"
17 |
18 | # arguments
19 | cat.arguments.missing = "{0} Argument {1} is required for the functionality "
20 | cat.arguments.type = "{0} expected argument of type {1}"
21 | cat.arguments = "{0} unsupported argument type {1}"
22 |
23 | # general errors
24 | cat.error = "{0} error occurred {1}"
25 | cat.error.config.ext = "{0} No valid extension '{1}' - Check your spelling"
26 | cat.error.config = "{0} No valid configuration"
27 | cat.error.config.missing = "{0} No valid configuration, missing '{1}' entry"
28 | cat.error.config.loader = "{0} error occured, probably not valid cat project [catproject.json]; {1}"
29 | cat.error.class = "{0} Failed to load required class: {1}"
30 | cat.error.interface = "{0} No valid interface '{1}' was found"
31 | cat.error.require.module = "{0} failed to load module {1}"
32 | cat.error.scrap.file.type.not.supported = "{0} Scrap of file type: '{1}' is not supported"
33 | cat.error.scrap.property.required = "{0} Scrap is ignored, the property: {1} is required"
34 |
35 | #project
36 | cat.project.config.not.valid = "{0} Project configuration is not valid"
37 | cat.project.property.default.value = "{0} No value received for property '{1}' setting default value to: '{2}'"
38 | cat.project.env.failed = "{0} failed to load CAT environment variables, check that resources/cat.json file loaded and that env entry exists"
39 |
40 | # extensions
41 | cat.ext.apply.warn = "{0} 'Apply' already executed, might be a duplication declaration see, dependencies and plugin sections of task: {1}"
42 | cat.ext.spawn.phantomjs.log = "{0} phantomjs spawn listener data of type {1}, {2}"
43 | cat.ext.webserver.start = "{0} Server started"
44 | cat.ext.webserver.stop = "{0} Server stopped"
45 |
46 | # configuration
47 | cat.config.interface = "{0} Extension, {1} has no valid interface: '{}'"
48 | cat.config.task.ext.not.found = "{0} No valid extension '{1}' was found"
49 | cat.config.task.ext.missing = "{0} Skipping task: {1}, cannot find configuration for ext: {1} Probably missing entry, see resources/cat.json file"
50 |
51 | #plugin
52 | cat.plugin.libraries.config.missing = "{0} missing configuration for loading library: {1}"
53 |
54 | # scrap
55 | cat.scrap.validation.close = "{0} Closing Scrap block but with no opening sign";
56 | cat.scrap.single.properties = "{0} Expecting object structure: {key: [attrName], value: [boolean]} when adding single values to a scrap"
57 |
58 | #utils
59 | cat.utils.resolver.warn = "{0} the object was partially resolved, check your query: {1}"
60 | cat.utils.copy.object.array.warn = "{0} Copy property:'{1}' failed; Array type was expected but got type: {2}"
--------------------------------------------------------------------------------
/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "proxy": {
3 | "enable": false,
4 | "base": {
5 | "host": "proxy.address",
6 | "port": "port"
7 | },
8 | "http": {
9 |
10 | },
11 | "https": {
12 |
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/libraries/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "catjs",
3 | "version": "0.0.1",
4 | "homepage": "https://github.com/catjsteam/catjs",
5 | "authors": [
6 | "arik "
7 | ],
8 | "description": "catjs dependencies",
9 | "license": "MIT",
10 | "ignore": [
11 | "**/.*",
12 | "node_modules",
13 | "bower_components",
14 | "build",
15 | "test",
16 | "tests"
17 | ],
18 | "dependencies": {
19 | "chai": "~1.9.2",
20 | "jspath": "~0.2.12",
21 | "requirejs": "~2.1.15",
22 | "underscore": "~1.7.0",
23 | "tmr": "https://github.com/lastboy/test-unit-reporter.git",
24 | "js.utils": "https://github.com/lastboy/js.utils.git"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/libraries/bowerutils.bat:
--------------------------------------------------------------------------------
1 | bower %1 %2
--------------------------------------------------------------------------------
/src/libraries/cat/CatSettings.js:
--------------------------------------------------------------------------------
1 | function _catjs_settings() {
2 |
3 | // aliases
4 | _cat.core.alias("manager");
5 | _cat.core.alias("manager.wait", _cat.core.manager.statecontroller.wait);
6 | _cat.core.alias("manager.resolve", _cat.core.manager.statecontroller.resolve);
7 | _cat.core.alias("manager.defer", _cat.core.manager.statecontroller.defer);
8 | _cat.core.alias("plugin.get", _cat.core.plugin);
9 | _cat.core.alias("testdata", _cat.utils.TestsDB);
10 | _cat.core.alias("ui.console", _cat.core.ui.console);
11 |
12 | }
13 |
14 | if (typeof exports !== "object") {
15 |
16 | _catjs_settings();
17 |
18 | }
--------------------------------------------------------------------------------
/src/libraries/cat/config/catconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "_comment": {
3 | "description": "This is the cat test project (for the specification see catjs docs)",
4 | "tests": "Put in here all of the test scenarios that you wish to run. Enabled only if run-mode set to tests",
5 | "scenarios": "Declare your scenarios in here and execute them using the 'tests' property",
6 | "run-mode": {
7 | "all": "Execute all available tests (ignores 'tests' and 'scenarios' properties)",
8 | "tests": "Executes only the tests specified in the 'tests' property"
9 | },
10 | "ui": "Set to true in case you wish to enable catjs ui widget",
11 | "report": "In case you wish to get a report data set its 'disable' property to false. Currently catjs supports the junit XML format",
12 | "test-failure-timeout": "This is a timeout for failing the tests in case of general application malfunction. Set the timeout in seconds. "
13 | },
14 |
15 | "name": "{{project.name}}",
16 | "ip": "{{project.getServerMonitoringHost()}}",
17 | "port": "{{project.getServerMonitoringPort()}}",
18 | "protocol": "{{project.getServerMonitoringProtocol()}}",
19 | "context": "{{project.info.appcontext}}",
20 | "tests":[
21 | {"name" : "general"}
22 | ],
23 | "scenarios" : {
24 | "general" : {
25 | "tests" : []
26 | }
27 | },
28 | "ui": true,
29 | "report": {
30 | "format": ["console", "junit"],
31 | "disable": false
32 | },
33 | "assert": {
34 | "errors": true
35 | },
36 | "run-mode": "tests",
37 | "run-test-delay": 500,
38 | "test-failure-timeout": 20,
39 | "auto-override": true
40 | }
--------------------------------------------------------------------------------
/src/libraries/cat/core/Errors.js:
--------------------------------------------------------------------------------
1 | /**
2 | * General error handling for the hosted application
3 | * @type {_cat.core.errors}
4 | */
5 | _cat.core.errors = function () {
6 |
7 | var _originalErrorListener,
8 | _listeners = [];
9 |
10 | if (window.onerror) {
11 | _originalErrorListener = window.onerror;
12 | }
13 |
14 | window.onerror = function(message, filename, lineno, colno, error) {
15 |
16 | var me = this;
17 |
18 | // call super
19 | if (_originalErrorListener) {
20 | _originalErrorListener.call(this, message, filename, lineno, colno, error);
21 | }
22 |
23 | // print the error
24 | _listeners.forEach(function(listener) {
25 | listener.call(me, message, filename, lineno, colno, error);
26 | });
27 |
28 | if (console && console.error) {
29 | console.error(("line, col: [" + lineno + " , " + colno + "]"), ("message: " + message), (" url: " + filename), " \nerror: ", error);
30 | }
31 | };
32 |
33 | return {
34 |
35 | listen: function(listener) {
36 | _listeners.push(listener);
37 | }
38 | };
39 |
40 | }();
--------------------------------------------------------------------------------
/src/libraries/cat/core/Ext/AssertUtils.js:
--------------------------------------------------------------------------------
1 | _cat.utils.assert = function () {
2 |
3 |
4 | function _sendTestResult(data) {
5 |
6 | var config = _cat.core.getConfig();
7 |
8 | if (config) {
9 | _cat.utils.AJAX.sendRequestAsync({
10 | url: _cat.core.TestManager.generateAssertCall(config, data)
11 | });
12 | }
13 | }
14 |
15 | return {
16 |
17 | /**
18 | * Send assert message to the UI and/or to catjs server
19 | *
20 | * @param config
21 | * name {String} The test name
22 | * displayName {String} The test display name
23 | * status {String} The status of the test (success | failure)
24 | * message {String} The assert message
25 | * success {Boolean} Whether the test succeeded or not
26 | * ui {Boolean} Display the assert data in catjs UI
27 | * send {Boolean} Send the assert data to the server
28 | */
29 | create: function (config) {
30 |
31 | if (!config) {
32 | return;
33 | }
34 |
35 | var testdata,
36 | total, failed, passed, tests;
37 |
38 | if (config.status && config.message && config.name && config.displayName) {
39 |
40 |
41 | testdata = _cat.core.TestManager.addTestData({
42 | name: config.name,
43 | type: config.type,
44 | displayName: config.displayName,
45 | status: config.status,
46 | message: config.message,
47 | success: (("success" in config && config.success) ? true : false),
48 | reportFormats: config.send
49 |
50 | });
51 |
52 | if (config.ui) {
53 | total = _cat.core.TestManager.getTestCount();
54 | passed = _cat.core.TestManager.getTestSucceededCount();
55 | failed = total - passed;
56 | tests = (_cat.core.TestManager.getSummaryInfo().assert.total || "?");
57 | _cat.core.ui.setContent({
58 | style: ( (testdata.getStatus() === "success") ? "color:green" : "color:red" ),
59 | header: testdata.getDisplayName(),
60 | desc: testdata.getMessage(),
61 | tips: {tests: tests ,passed: (!isNaN(passed) ? passed : "?"), failed: (!isNaN(failed) ? failed : "?"), total: (!isNaN(total) ? total: "?")},
62 | elementType : ( (testdata.getStatus() === "success") ? "listImageCheck" : "listImageCross" )
63 | });
64 | }
65 |
66 | // TODO parse report formats : consider api for getConsole; getJUnit ...
67 | if (config.send) {
68 | _sendTestResult(testdata);
69 | }
70 | }
71 | }
72 |
73 | };
74 |
75 | }();
--------------------------------------------------------------------------------
/src/libraries/cat/core/plugins/Simulate.js:
--------------------------------------------------------------------------------
1 | _cat.utils.plugins.simulate = function() {
2 |
3 | var _module = {
4 |
5 | drag: function(opt) {
6 |
7 | _cat.utils.Utils.prepareProps(
8 | {
9 | global: {
10 | obj: opt
11 | },
12 | props: [
13 | {
14 | key: "element",
15 | require: true
16 | },
17 | {
18 | key: "target"
19 | },
20 | {
21 | key: "offset",
22 | default: {x:0, y:0}
23 | },
24 | {
25 | key: "cords",
26 | default: false
27 | },
28 | {
29 | key: "steps",
30 | default: {delay: 0, count: 1}
31 | }
32 | ]
33 | });
34 |
35 | _cat.plugins.dom.fire("mouseenter", {"element": opt.element});
36 | _cat.plugins.dom.fire("mousedown", {"element": opt.element});
37 | _cat.plugins.dom.fire("mousemove", opt);
38 | _cat.plugins.dom.fire("mouseup", {"element": opt.element});
39 | }
40 | };
41 |
42 | return _module;
43 |
44 | }();
--------------------------------------------------------------------------------
/src/libraries/cat/core/test/TestQueue.js:
--------------------------------------------------------------------------------
1 | _cat.core.TestQueue = function () {
2 |
3 | var _Queue = function (key) {
4 |
5 | this.key = key;
6 | this.items = [];
7 | },
8 | _queue = {},
9 | _module;
10 |
11 | _Queue.prototype.empty = function () {
12 | return (this.key ? false : true);
13 | };
14 |
15 | _Queue.prototype.add = function (config) {
16 | this.items.push(config);
17 | };
18 |
19 | _Queue.prototype.all = function () {
20 | return this.items;
21 | };
22 |
23 | _Queue.prototype.first = function () {
24 | return (this.size() > 0 ? this.items[0] : undefined);
25 | };
26 |
27 | _Queue.prototype.deleteFirst = function () {
28 | if (this.size() > 0) {
29 | this.items.shift();
30 | }
31 | };
32 |
33 | _Queue.prototype.delete = function (idx) {
34 | if (this.size() > 0) {
35 | this.items.splice(idx, 1);
36 | }
37 | };
38 |
39 | _Queue.prototype.deleteAll = function () {
40 | if (this.size() > 0) {
41 | this.items = [];
42 | }
43 | };
44 |
45 | _Queue.prototype.size = function () {
46 | return this.items.length;
47 | };
48 |
49 | _module = {
50 |
51 | isEmpty: function () {
52 | return _cat.utils.Utils.isEmpty(_queue);
53 | },
54 |
55 | get: function (scrap) {
56 | var index,
57 | queue,
58 | found;
59 |
60 | index = (scrap ? scrap.index : -1);
61 | if (index > -1) {
62 | queue = _queue[index];
63 | }
64 | return (queue ? queue : new _Queue());
65 | },
66 |
67 | add: function (key, config) {
68 | var queue = _module.get(config);
69 |
70 | if (!_queue[key]) {
71 | queue = _queue[key] = new _Queue();
72 | }
73 | queue.add(config);
74 | }
75 | };
76 |
77 | return _module;
78 | };
--------------------------------------------------------------------------------
/src/libraries/cat/core/utils/IFrame.js:
--------------------------------------------------------------------------------
1 | _cat.utils.iframe = function() {
2 | var _module = {
3 |
4 | rootWindow: function() {
5 |
6 | function _getTopWindow(parentarg) {
7 | if (!parentarg) {
8 | parentarg = window;
9 | }
10 | parentarg = parentarg.parent;
11 | if(window.top !== parentarg) {
12 | _getTopWindow(parentarg);
13 | }
14 | return parentarg;
15 | }
16 |
17 | if(window.top === window.self) {
18 |
19 | return window.top;
20 |
21 | } else {
22 |
23 | return _getTopWindow();
24 | }
25 | },
26 |
27 | catroot: function(win) {
28 |
29 | var carroot;
30 |
31 | if (_module.isIframe(win) ){
32 | carroot = _module.rootWindow();
33 | if (carroot && carroot._cat) {
34 | return carroot._cat;
35 | }
36 | }
37 |
38 | return undefined;
39 | },
40 |
41 | isIframe : function(win) {
42 | win = (win || window);
43 | try {
44 | return win !== win.top;
45 | } catch (e) {
46 | return true;
47 | }
48 | }
49 | };
50 |
51 | return _module;
52 | }();
--------------------------------------------------------------------------------
/src/libraries/cat/core/utils/Loader.js:
--------------------------------------------------------------------------------
1 | _cat.utils.Loader = function () {
2 |
3 | var _libslength = 0,
4 | _ready = 0,
5 | _module = {
6 |
7 | require: function (file, callback) {
8 |
9 | function _css(file) {
10 | var node = document.createElement('link'),
11 | head = (document.head || document);
12 |
13 | node.rel = 'stylesheet';
14 | node.type = 'text/css';
15 | node.href = file;
16 |
17 | node.onload = function() {
18 | _ready++;
19 | if (_ready === _libslength) {
20 | if (callback && callback.call) {
21 | callback.call(this);
22 | }
23 | }
24 | };
25 |
26 | document.head.appendChild(node);
27 | }
28 |
29 | function _js(file) {
30 | var node = document.createElement('script'),
31 | head = (document.head || document);
32 |
33 | node.type = "text/javascript";
34 | node.src = file;
35 | node.onload = function() {
36 | _ready++;
37 | if (_ready === _libslength) {
38 | if (callback && callback.call) {
39 | callback.call(this);
40 | }
41 | }
42 | };
43 |
44 | head.appendChild(node);
45 | }
46 |
47 | var jsfile_extension = /(.js)$/i,
48 | cssfile_extension = /(.css)$/i;
49 |
50 | if (jsfile_extension.test(file)) {
51 | _js(file);
52 |
53 | } else if (cssfile_extension.test(file)) {
54 | _css(file);
55 |
56 | } else {
57 | console.warn("[catjs] no valid file was found ", (file || "NA"));
58 | }
59 | },
60 |
61 | requires: function () {
62 |
63 | var index = 0;
64 |
65 | return function (files, callback) {
66 | _libslength = files.length;
67 |
68 | if (!_libslength) {
69 | return undefined;
70 | }
71 |
72 | index += 1;
73 | _module.require(files[index - 1], ((index === files.length) ? callback : undefined));
74 |
75 | if (index === files.length) {
76 | index = 0;
77 |
78 | } else {
79 | _module.requires(files, callback);
80 | }
81 | };
82 |
83 | }()
84 |
85 | };
86 |
87 | return _module;
88 |
89 | }();
90 |
91 |
92 | //Utilities.requires(["cat.css", "cat.js", "chai.js"], function(){
93 | // //Call the init function in the loaded file.
94 | // console.log("generation done");
95 | //})
96 |
--------------------------------------------------------------------------------
/src/libraries/cat/core/utils/Request.js:
--------------------------------------------------------------------------------
1 | _cat.utils.Request = function () {
2 |
3 | return {
4 |
5 | /**
6 | * Generates request for catjs monitoring server
7 | *
8 | * @param config {Object} The main object
9 | * service {String} The service url name
10 | * params {Object} Request parameters
11 | * cache {Boolean} Enable url cache
12 | *
13 | * @returns {*}
14 | */
15 | generate: function(config) {
16 |
17 | var service = config.service,
18 | paramsarg = config.params,
19 | params = [],
20 | key, param, counter= 0,
21 | uri;
22 |
23 | function getURI() {
24 | var catconfig,
25 | method, ip, port,
26 | uri;
27 |
28 | catconfig = _cat.core.getConfig();
29 | if (catconfig) {
30 | method = catconfig.getMethod();
31 | ip = catconfig.getIp();
32 | port = catconfig.getPort();
33 |
34 | uri = [method, "://", ip, ":", port, "/", service].join("");
35 | }
36 |
37 | return uri;
38 | }
39 |
40 | function _addKey(params, key, param) {
41 | params.push(key);
42 | params.push("=");
43 | params.push(param);
44 | }
45 |
46 | if ("cache" in config && params) {
47 | params.cache = (new Date()).toUTCString();
48 | }
49 |
50 | for (key in paramsarg) {
51 | if (paramsarg.hasOwnProperty(key)) {
52 | param = paramsarg[key];
53 | if (param) {
54 | if (counter === 0) {
55 | params.push("?");
56 | } else {
57 | params.push("&");
58 | }
59 | _addKey(params, key, param);
60 | counter++;
61 | }
62 | }
63 | }
64 |
65 | uri = getURI();
66 | if (!uri) {
67 | _cat.core.log.error("[catjs request] Failed to resolve catjs server address");
68 |
69 | return undefined;
70 | }
71 |
72 | return [uri, params.join("")].join("");
73 |
74 | }
75 |
76 | };
77 |
78 | }();
79 |
--------------------------------------------------------------------------------
/src/libraries/cat/core/utils/Scrap.js:
--------------------------------------------------------------------------------
1 | _cat.utils.scrap = function() {
2 |
3 | return {
4 |
5 | isStandalone: function(scrap) {
6 | var standalone = ("$standalone" in scrap ? scrap.$standalone : undefined);
7 | return standalone;
8 | }
9 |
10 |
11 | };
12 |
13 | }();
--------------------------------------------------------------------------------
/src/libraries/cat/core/utils/Signal.js:
--------------------------------------------------------------------------------
1 | _cat.utils.Signal = function () {
2 |
3 | var _funcmap = { };
4 |
5 | return {
6 |
7 | register: function(arr) {
8 | if (arr) {
9 | arr.forEach(function(item) {
10 | _funcmap[item.signal] = item.impl;
11 | });
12 | }
13 |
14 | },
15 |
16 | send: function (flag, opt) {
17 |
18 | if (flag && _funcmap[flag]) {
19 | _funcmap[flag].call(this, opt);
20 | }
21 |
22 | }
23 |
24 | };
25 |
26 | }();
--------------------------------------------------------------------------------
/src/libraries/cat/core/utils/Storage.js:
--------------------------------------------------------------------------------
1 | _cat.utils.Storage = function () {
2 |
3 | var _catjsLocal, _catjsSession;
4 |
5 | function _getStorage(type) {
6 | if (type) {
7 | return window[_enum[type]];
8 | }
9 | }
10 |
11 | function _base(type) {
12 | if (!type) {
13 | console.warning("[CAT] Storage; 'type' argument is not valid");
14 | }
15 |
16 | return _getStorage(type);
17 | }
18 |
19 | var _enum = {
20 | guid : "cat.core.guid",
21 | session: "sessionStorage",
22 | local: "localStorage"
23 | },
24 | _storageEnum = {
25 | CURRENT_SCENARIO: "current.scenario",
26 | SESSION: "session",
27 | LOCAL: "local"
28 | },
29 | _module;
30 |
31 | function _init() {
32 | var localStorage = _getStorage("local"),
33 | sessionStorage = _getStorage("session");
34 |
35 | if (sessionStorage.catjs) {
36 | _catjsSession = JSON.parse(sessionStorage.catjs);
37 | }
38 | if (localStorage.catjs) {
39 | _catjsLocal = JSON.parse(localStorage.catjs);
40 | }
41 | }
42 |
43 | _init();
44 |
45 | _module = {
46 |
47 |
48 | /**
49 | * Set value to a storage
50 | *
51 | * @param key The key to be stored
52 | * @param value The value to set
53 | * @param type session | local
54 | */
55 | set: function(key, value, type) {
56 |
57 | var storage = _base(type);
58 | if (storage) {
59 | if (!_catjsSession) {
60 | _catjsSession = {};
61 | }
62 | _catjsSession[key] = value;
63 | storage.catjs = JSON.stringify(_catjsSession);
64 | }
65 | },
66 |
67 | /**
68 | * Get value from the storage
69 | *
70 | * @param key
71 | * @param type session | local
72 | */
73 | get: function(key, type) {
74 |
75 | var storage = _base(type);
76 | if (storage) {
77 | if (!storage.catjs) {
78 | return undefined;
79 | }
80 |
81 | _catjsSession = JSON.parse(storage.catjs);
82 | if (!_catjsSession) {
83 | return undefined;
84 | }
85 |
86 | return _catjsSession[key];
87 | }
88 |
89 | },
90 |
91 | getGUID: function() {
92 |
93 | var guid = _module.get(_enum.guid, _storageEnum.SESSION);
94 |
95 | if (!guid) {
96 | guid =_cat.utils.Utils.generateGUID();
97 | _module.set(_enum.guid, guid, _storageEnum.SESSION);
98 | }
99 |
100 | return guid;
101 |
102 | },
103 |
104 | enum: _storageEnum
105 |
106 | };
107 |
108 | return _module;
109 | }();
--------------------------------------------------------------------------------
/src/libraries/cat/lessbuilder.js:
--------------------------------------------------------------------------------
1 | var _fs = require("fs.extra"),
2 | _less = require("less"),
3 | _name = "cat",
4 | _parser = new(_less.Parser)({
5 | paths: [
6 | './css/less'
7 | ]
8 | }),
9 | content;
10 |
11 | function _clean() {
12 | var path = "./css/" + _name +".css";
13 | if (_fs.existsSync(path)) {
14 | _fs.unlinkSync(path);
15 | }
16 | }
17 |
18 | function _generate() {
19 | _clean();
20 |
21 | content = require("fs").readFileSync('./css/less/app.less', "utf8");
22 | _parser.parse(content, function (e, model) {
23 | if (e) {
24 | console.error("error occured while parsing the content: ",e);
25 | }
26 | _fs.writeFileSync( "./css/" + _name +".css", model.toCSS({ compress: true }) );
27 | });
28 | }
29 |
30 | _generate();
--------------------------------------------------------------------------------
/src/libraries/cat/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "cat-library",
3 | "description": "CAT Test Library",
4 | "version": "0.1.0",
5 | "author": {
6 | "name": "arik",
7 | "email": "arik.levine@hp.com"
8 | },
9 | "licenses": [
10 | {
11 | "type": "MIT",
12 | "url": "https://github.com/arik/grunt-plugin/blob/master/LICENSE-MIT"
13 | }
14 | ],
15 | "main": "Gruntfile.js",
16 | "engines": {
17 | "node": ">= 0.8.0"
18 | },
19 | "dependencies": {
20 | "grunt-contrib-uglify": "~0.2.2",
21 | "grunt-contrib-concat": "~0.3.0",
22 | "grunt-contrib-jshint": "~0.1.1",
23 | "grunt-contrib-clean": "~0.4.0",
24 | "grunt": "~0.4.1",
25 | "hooker": "~0.2.3",
26 | "grunt-contrib-copy": "~0.4.1",
27 | "grunt-contrib-cssmin": "~0.7.0"
28 | },
29 | "peerDependencies": {}
30 | }
31 |
--------------------------------------------------------------------------------
/src/libraries/cat/plugins/deviceinfo/deviceinfo.js:
--------------------------------------------------------------------------------
1 | _cat.plugins.deviceinfo = function () {
2 |
3 |
4 |
5 | return {
6 |
7 | actions: {
8 |
9 |
10 | deviceinfo: function (interval) {
11 | if (typeof interval === "undefined") {
12 | interval = true;
13 | }
14 |
15 | var url = "catjsdeviceinfo://interval=" + interval + "&deviceId=" + _cat.core.guid(),
16 | iframe = document.createElement("IFRAME");
17 |
18 | iframe.setAttribute("src", url);
19 | document.documentElement.appendChild(iframe);
20 | iframe.parentNode.removeChild(iframe);
21 | iframe = null;
22 | }
23 | }
24 |
25 |
26 | };
27 |
28 | }();
29 |
--------------------------------------------------------------------------------
/src/libraries/cat/plugins/enyo/enyo.js:
--------------------------------------------------------------------------------
1 | _cat.plugins.enyo = function () {
2 |
3 | var _me;
4 |
5 | function _noValidMessgae(method) {
6 | return ["[cat enyo plugin] ", method, "call failed, no valid argument(s)"].join("");
7 | }
8 |
9 | function _genericAPI(element, name) {
10 | if (name) {
11 | if (!element) {
12 | _cat.core.log.info("[catjs enyo plugin]", _noValidMessgae("next"));
13 | }
14 | if (element[name]) {
15 | element[name]();
16 | } else {
17 | _cat.core.log.info("[catjs enyo plugin] No valid method was found, '" + name + "'");
18 | }
19 | }
20 | }
21 |
22 | _me = {
23 |
24 | actions: {
25 |
26 |
27 | waterfall: function (element, eventName) {
28 | if (!element || !eventName) {
29 | _cat.core.log.info("[catjs enyo plugin]", _noValidMessgae("waterfall"));
30 | }
31 |
32 | try {
33 | element.waterfall('ontap');
34 | } catch (e) {
35 | // ignore
36 | }
37 | },
38 |
39 | setSelected: function (element, name, idx, eventname) {
40 | eventname = (eventname || "ontap");
41 | if (element) {
42 | _me.actions.waterfall(element.parent, eventname);
43 | if (name && (idx !== undefined)) {
44 | setTimeout(function () {
45 | element.setSelected(element.$[name + '_' + idx]);
46 | }, 600);
47 | }
48 | setTimeout(function () {
49 | element.$[name + '_' + idx].waterfall(eventname);
50 | }, 900);
51 | }
52 | },
53 |
54 | next: function (element) {
55 | _genericAPI(element, "next");
56 | }
57 | }
58 |
59 | };
60 |
61 | return _me;
62 | }();
63 |
--------------------------------------------------------------------------------
/src/libraries/cat/plugins/screenshot/screenshot.js:
--------------------------------------------------------------------------------
1 | _cat.plugins.screenshot = function () {
2 |
3 |
4 |
5 | return {
6 |
7 | actions: {
8 |
9 |
10 | screenshot: function (scrapName) {
11 |
12 | var url = "catjsgetscreenshot://scrapName=" + scrapName + "&deviceId=" + _cat.core.guid(),
13 | iframe = document.createElement("IFRAME");
14 |
15 | iframe.setAttribute("src", url);
16 | document.documentElement.appendChild(iframe);
17 | iframe.parentNode.removeChild(iframe);
18 | iframe = null;
19 | }
20 | }
21 |
22 |
23 | };
24 |
25 | }();
26 |
--------------------------------------------------------------------------------
/src/libraries/cat/plugins/testdata/testdata.js:
--------------------------------------------------------------------------------
1 | _cat.plugins.testdata = function () {
2 |
3 | var _module = {
4 |
5 | actions: {
6 |
7 | }
8 | };
9 |
10 | (function() {
11 | var testdb = _cat.utils.TestsDB,
12 | key;
13 |
14 | for (key in testdb) {
15 | if (testdb.hasOwnProperty(key)) {
16 | _module.actions[key] = _cat.utils.TestsDB[key];
17 | }
18 | }
19 |
20 | })();
21 |
22 | return _module;
23 |
24 | }();
25 |
--------------------------------------------------------------------------------
/src/libraries/cat/plugins/wait/wait.js:
--------------------------------------------------------------------------------
1 | _cat.plugins.wait = function () {
2 |
3 | var _module = {
4 |
5 | utils: function () {
6 |
7 |
8 |
9 | }(),
10 |
11 | actions: {
12 |
13 |
14 |
15 | }
16 | };
17 |
18 | return _module;
19 |
20 | }();
21 |
--------------------------------------------------------------------------------
/src/libraries/cat/target/cat.json:
--------------------------------------------------------------------------------
1 | {
2 | "_comment": {
3 | "description": "This is the cat test project (for the specification see catjs docs)",
4 | "tests": "Put in here all of the test scenarios that you wish to run. Enabled only if run-mode set to tests",
5 | "scenarios": "Declare your scenarios in here and execute them using the 'tests' property",
6 | "run-mode": {
7 | "all": "Execute all available tests (ignores 'tests' and 'scenarios' properties)",
8 | "tests": "Executes only the tests specified in the 'tests' property"
9 | },
10 | "ui": "Set to true in case you wish to enable catjs ui widget",
11 | "report": "In case you wish to get a report data set its 'disable' property to false. Currently catjs supports the junit XML format",
12 | "test-failure-timeout": "This is a timeout for failing the tests in case of general application malfunction. Set the timeout in seconds. "
13 | },
14 |
15 | "name": "{{project.name}}",
16 | "ip": "{{project.getServerMonitoringHost()}}",
17 | "port": "{{project.getServerMonitoringPort()}}",
18 | "protocol": "{{project.getServerMonitoringProtocol()}}",
19 | "context": "{{project.info.appcontext}}",
20 | "tests":[
21 | {"name" : "general"}
22 | ],
23 | "scenarios" : {
24 | "general" : {
25 | "tests" : []
26 | }
27 | },
28 | "ui": true,
29 | "report": {
30 | "format": ["console", "junit"],
31 | "disable": false
32 | },
33 | "assert": {
34 | "errors": true
35 | },
36 | "run-mode": "tests",
37 | "run-test-delay": 500,
38 | "test-failure-timeout": 20,
39 | "auto-override": true
40 | }
--------------------------------------------------------------------------------
/src/libraries/jasmine/lib/catjs-jasmine-boot.js:
--------------------------------------------------------------------------------
1 | /**
2 | Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
3 |
4 | If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
5 |
6 | The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
7 |
8 | [jasmine-gem]: http://github.com/pivotal/jasmine-gem
9 | */
10 |
11 | (function () {
12 |
13 | /**
14 | * ## Require & Instantiate
15 | *
16 | * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
17 | */
18 | window.jasmine = jasmineRequire.core(jasmineRequire);
19 |
20 |
21 | /**
22 | * Create the Jasmine environment. This is used to run all specs in a project.
23 | */
24 | var env = jasmine.getEnv();
25 |
26 | /**
27 | * ## The Global Interface
28 | *
29 | * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
30 | */
31 | var jasmineInterface = jasmineRequire.interface(jasmine, env);
32 |
33 | /**
34 | * Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
35 | */
36 | if (typeof window == "undefined" && typeof exports == "object") {
37 | extend(exports, jasmineInterface);
38 | } else {
39 | extend(window, jasmineInterface);
40 | }
41 |
42 | /**
43 | * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
44 | */
45 | env.addReporter(new _larrymyers_jasmine_reporter.jasmineReporters.TapReporter());
46 | env.addReporter(jasmineInterface.jsApiReporter);
47 |
48 |
49 | window.onload = function () {
50 |
51 | env.execute();
52 | };
53 |
54 | /**
55 | * Helper function for readability above.
56 | */
57 | function extend(destination, source) {
58 | for (var property in source) destination[property] = source[property];
59 | return destination;
60 | }
61 |
62 | }());
63 |
--------------------------------------------------------------------------------
/src/libraries/jasmine/lib/jasmine-spec-runner.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Jasmine Spec Runner v2.1.2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/libraries/jasmine/lib/jasmine_favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/src/libraries/jasmine/lib/jasmine_favicon.png
--------------------------------------------------------------------------------
/src/libraries/js.utils/target/jsutils-min.js:
--------------------------------------------------------------------------------
1 | var underscore,_jsutilsModuleArray=function(){var e={};return{internal:function(t){e=t},cleanupArray:function(t){var n=[];return t&&e._.isArray(t)&&t.forEach(function(e){e!==null&&e!==undefined&&n.push(e)}),n},removeArrayItemByValue:function(t,n){var r=[],i=0;return t&&e._.isArray(t)&&t.forEach(function(e){e!==n&&e!==null&&e!==undefined&&r.push(e),i++}),r}}}();if(typeof exports!="undefined")typeof module!="undefined"&&module.exports&&(_jsutilsModuleArray.internal({_:underscore}),module.exports=_jsutilsModuleArray);else var jsutilsArrayModule=function(e){return _jsutilsModuleArray.internal({_:_}),_jsutilsModuleArray}(underscore);var _jsutilsModuleObject=function(){var e={};return{internal:function(t){e=t},contains:function(t,n){var r;if(t)for(r in t)if(e._.isObject(n)||e._.isArray(n)){if(JSON.stringify(t[r])===JSON.stringify(n))return!0}else if(t[r]===n)return!0;return!1},copy:function(t,n,r){var i,s,o=this,u=0,a=0,f;r=r||!1;if(t&&n)for(i in t)if(t.hasOwnProperty(i)){s=n[i];if(e._.isArray(t[i])){if(!s)n[i]=t[i];else if(e._.isArray(s)){e.arrayutils.cleanupArray(t[i]);if(r)n[i]=t[i];else{a=n[i].length;for(u=0;u 100000) {
31 | _fs.renameSync(logfilepath, [_logsfolder, "/CAT_", (new Date()).format("YYYY_MM_DD_mm_ss"), ".log"].join(""));
32 | }
33 | }
34 |
35 | log = new _Log('debug', _fs.createWriteStream(logfilepath, {
36 | flags: 'a',
37 | encoding: null,
38 | mode: 0777
39 | }));
40 |
41 | log.info("\n\n[CAT] Initial LOG -----------------------------------------------------------------------");
42 | log.info("[CAT] Initial CAT process: " + process.pid);
43 | global.CAT._log = log;
44 |
45 | }
46 | return global.CAT._log;
47 | },
48 | get: function(key) {
49 | if (global.CAT) {
50 | return (key in global.CAT ? global.CAT[key] : undefined);
51 | }
52 | },
53 | delete: function(key) {
54 | if (global.CAT) {
55 | if (key in global.CAT) {
56 | delete global.CAT[key];
57 | }
58 | }
59 | },
60 | set: function(key, value) {
61 | if (global.CAT &&
62 | key &&
63 | (value !== undefined && value !== null) ) {
64 | global.CAT[key] = value;
65 | }
66 | },
67 |
68 | init: function() {
69 | _logsfolder = _sysutils.createSystemFolder("logs");
70 | }
71 | };
72 |
73 | }
74 | })();
75 |
76 | module.exports = global.CAT;
77 |
--------------------------------------------------------------------------------
/src/module/Console.js:
--------------------------------------------------------------------------------
1 | module.exports = function() {
2 |
3 | return console;
4 |
5 | }();
--------------------------------------------------------------------------------
/src/module/Flow.js:
--------------------------------------------------------------------------------
1 | var _fs = require("fs"),
2 | _global = catrequire("cat.global"),
3 | _fileName = [_global.get("home").working.path, "logs/cat.flow.log"].join("/"),
4 | _date = require("date-format-lite"),
5 | _props = catrequire("cat.props");
6 |
7 | /**
8 | * Persist a property style data (key=value) to a file named .cat
9 | *
10 | * @type {module.exports}
11 | */
12 | module.exports = function () {
13 |
14 | function _store(data, option) {
15 | option = (option || "appendFileSync");
16 | try {
17 | if (option) {
18 | _fs[option](_fileName, data, "utf8");
19 | }
20 | } catch (e) {
21 | console.log("[catcli flow] ", e);
22 | }
23 | }
24 |
25 | function _load() {
26 | try {
27 | if (_fs.existsSync(_fileName)) {
28 | return _fs.readFileSync(_fileName, "utf8");
29 | }
30 | } catch (e) {
31 | console.log("[catcli flow] ", e);
32 | }
33 |
34 | return undefined;
35 | }
36 |
37 |
38 | return {
39 |
40 | init: function() {
41 | _store("\n -------------------------- CAT Flow ---------------------------------------------- \n");
42 | },
43 |
44 | /**
45 | * Append new line comprised of the key, value [key=value\n]
46 | *
47 | * @param key
48 | * @param value
49 | */
50 | log: function (config) {
51 | var now = (new Date()).format("YYYY-MM-DD hh:mm:ss"),
52 | msg = config.msg,
53 | propkey = ("cat.flow.base" || config.propkey);
54 |
55 |
56 | _store(_props.get(propkey).format(now, msg));
57 | }
58 | };
59 |
60 | }();
--------------------------------------------------------------------------------
/src/module/Properties.js:
--------------------------------------------------------------------------------
1 | var _properties = require("properties"),
2 | _global = require("./CATGlob.js"),
3 | _log = _global.log();
4 |
5 | /**
6 | * Loading property file for internal use
7 | * Currently support only log.properties for log messages.
8 | *
9 | * TODO load property files according to a given path
10 | *
11 | * @type {module.exports}
12 | */
13 | module.exports = function () {
14 |
15 | var config = {
16 | comment: "# ",
17 | separator: " = ",
18 | sections: false
19 | }, properties;
20 |
21 |
22 | return {
23 |
24 | init: function (callback) {
25 | _properties.load([cathome, "resources/log.properties"].join("/"),
26 | config,
27 | callback);
28 |
29 | },
30 |
31 | all: ( (global && global.CAT) ? global.CAT.props : undefined ),
32 |
33 | get: function (key) {
34 | if (key) {
35 | return global.CAT.props[key];
36 | }
37 |
38 | return undefined;
39 | }
40 |
41 | };
42 | }();
--------------------------------------------------------------------------------
/src/module/Watch.js:
--------------------------------------------------------------------------------
1 | var _watch = require("watch"),
2 | _cat = catrequire("cat"),
3 | _fs = require("fs");
4 |
5 | module.exports = function () {
6 |
7 | var _apply = function(config) {
8 | _cat.watch(config);
9 | };
10 |
11 | return {
12 |
13 | init: function (path) {
14 |
15 | var me = this;
16 | path = (path || "/home/arik/dev/projects/cat/test/test-project");
17 |
18 | if (path) {
19 | _watch.createMonitor(path, function (monitor) {
20 |
21 | console.log(" -- > " + process.getuid());
22 |
23 | // monitor.files['./**/*.js'];
24 |
25 | monitor.on("created", function (f, stat) {
26 | // Handle new files
27 | if (f && !_fs.existsSync(f)){
28 | _apply({impl: new me.createWatch({file: f, stat: stat, "crud": "c"})});
29 | }
30 | });
31 |
32 | monitor.on("changed", function (f, curr, prev) {
33 | // Handle file changes
34 | if (curr.mtime - prev.mtime) {
35 | _apply({impl: new me.createWatch({file: f, "crud": "u"})});
36 | }
37 | });
38 |
39 | monitor.on("removed", function (f, stat) {
40 | // Handle removed files
41 | if (f && _fs.existsSync(f)){
42 | _apply({impl: new me.createWatch({file: f, stat: stat, "crud": "d"})});
43 | }
44 | });
45 |
46 | });
47 | }
48 | },
49 |
50 | /**
51 | * Create a Watch class
52 | *
53 | * @param config The initial configuration
54 | */
55 | createWatch: function(config) {
56 |
57 | this.config = config;
58 |
59 | if (config) {
60 | this.file = config.file;
61 | this.stat = config.stat;
62 | this.crud = config.crud;
63 | }
64 |
65 | this.get = function(key) {
66 | return (key ? this[key] : undefined);
67 | };
68 |
69 | this.getConfig = function() {
70 | return this.config;
71 | };
72 | }
73 | };
74 |
75 | }();
--------------------------------------------------------------------------------
/src/module/analytics/analytics.js:
--------------------------------------------------------------------------------
1 | var contribute = require("contribute"),
2 | config = {
3 | "googleId" : 'UA-51686739-1',
4 | "googleSite" : 'https://github.com/catjsteam/catjs'
5 | };
6 |
7 |
8 | contribute.init(config);
9 |
10 | exports.updateAnalytics = function(catCommand, projectName) {
11 | var label,
12 | action,
13 | page;
14 |
15 | label = catCommand.task ? catCommand.task.join(", ") : "undefined_task";
16 | action = (catCommand.argv && catCommand.argv.original) ? catCommand.argv.original.join("/") : "undefined_args";
17 | page = projectName + "/" + label + "/" + action;
18 |
19 | contribute.trackPage('catjs', page);
20 | };
--------------------------------------------------------------------------------
/src/module/common/parser/Parser.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | module.exports = function() {
4 |
5 | return {
6 |
7 | get: function(parser) {
8 | return require("./" + parser);
9 | }
10 | };
11 |
12 | }();
--------------------------------------------------------------------------------
/src/module/config/project/Action.js:
--------------------------------------------------------------------------------
1 | var _log = catrequire("cat.global").log(),
2 | _typedas = require("typedas"),
3 | _Filter = require("./Filter.js");
4 |
5 | /**
6 | * (Plugin) Action configuration class
7 | *
8 | * @param config The configuration:
9 | * data - the configuration data
10 | * global - The global data configuration
11 | * emitter - The emitter reference
12 | * @returns {*}
13 | * @constructor
14 | */
15 | module.exports = function (config) {
16 |
17 | var filters,
18 | me = this,
19 | data, emitter, global, catconfig;
20 |
21 | this.filters = [];
22 |
23 | function _init() {
24 | data = config.data;
25 | emitter = config.emitter;
26 | global = config.global;
27 | catconfig = config.catconfig;
28 | }
29 |
30 | if (config) {
31 |
32 | _init();
33 |
34 | if (data) {
35 |
36 | this.name = data.name;
37 | this.type = data.type;
38 | this.to = data.to;
39 | this.from = data.from;
40 | this.dependency = data.dependency;
41 | this.data = data;
42 |
43 | /**
44 | * Apply Action
45 | *
46 | * @param internalConfig The CAT internal configuration
47 | */
48 | this.apply = function(config) {
49 | var target = (me.type || me.name),
50 | internalConfig = config.internalConfig,
51 | bol = true;
52 |
53 | // actually the running dependency
54 | me.dependencyTarget = config.dependency;
55 |
56 | _log.info("[CAT] running target: " + target);
57 |
58 | // Load action per type
59 | if (target) {
60 | _log.debug("[Action] Instantiating action: " + target);
61 | try {
62 | me.ref = catconfig.pluginLookup(target);
63 | if (me.ref) {
64 |
65 | me.action = new me.ref();
66 |
67 | if (me.ref.validate) {
68 | bol = me.ref.validate(me, config);
69 | if (!bol) {
70 | _log.warning("[CAT Action] plugin validation failed, the plugin might not function as expected ");
71 | }
72 | }
73 | }
74 | if (me.action) {
75 | // todo call dataInit
76 | // todo impl the dependencyTarget validation within the plugins; Give an array of supported
77 |
78 | // Action initialization
79 | me.action.init({data: me, emitter: emitter, global: global, internalConfig: internalConfig});
80 | }
81 | } catch (e) {
82 | _log.error("[CAT Action] action type not found or failed to load module ", e);
83 | }
84 | }
85 |
86 | return me;
87 | };
88 |
89 |
90 | // go over the filter configuration
91 | filters = (data.filters || undefined);
92 | if (filters) {
93 | filters.forEach(function (item) {
94 | if (item) {
95 | me.filters.push(new _Filter(item));
96 | }
97 | });
98 | }
99 |
100 |
101 | } else {
102 | _log.warning("[CAT Action] No valid data configuration");
103 | }
104 | }
105 |
106 | return this;
107 |
108 | };
109 |
--------------------------------------------------------------------------------
/src/module/config/project/Extension.js:
--------------------------------------------------------------------------------
1 | var _global = catrequire("cat.global"),
2 | _log = _global.log(),
3 | _props = catrequire("cat.props"),
4 | _fs = require("fs.extra"),
5 | _utils = catrequire("cat.utils");
6 |
7 | /**
8 | * Extension configuration class
9 | *
10 | * @param config The configuration:
11 | * data - the configuration data
12 | * global - The global data configuration
13 | * emitter - The emitter reference
14 | * @returns {*}
15 | * @constructor
16 | */
17 | module.exports = function (config) {
18 |
19 | var me = this,
20 | data, emitter, global, catconfig;
21 |
22 |
23 | function _init() {
24 | data = config.data;
25 | emitter = config.emitter;
26 | global = config.global;
27 | catconfig = config.catconfig;
28 | }
29 |
30 | if (config) {
31 |
32 | _init();
33 |
34 | if (data) {
35 |
36 | this.name = data.name;
37 | this.type = data.type;
38 | this.path = data.path;
39 | this.data = data;
40 |
41 | /**
42 | * Apply Extension
43 | *
44 | * @param internalConfig The CAT internal configuration
45 | */
46 | this.apply = function(internalConfig) {
47 | var extensionobj,
48 | path,
49 | project = internalConfig.externalConfig.project,
50 | projectInfo = project.info,
51 | targetFolder = projectInfo.target;
52 |
53 | if (me.type) {
54 | extensionobj = internalConfig.getExtension(me.type);
55 | if (extensionobj) {
56 | extensionobj = extensionobj.ref;
57 | // in case the extension has no path defined get the defaults
58 | path = (me.path || targetFolder);
59 | if (extensionobj) {
60 | if (internalConfig.isWatch()) {
61 | if (!extensionobj.watch) {
62 | _log.warning(_props.get("cat.error.interface").format("[extension config]", "watch"));
63 | } else {
64 | extensionobj.watch({path: path, internalConfig: internalConfig});
65 | }
66 | } else {
67 | if (!extensionobj.apply) {
68 | _log.warning(_props.get("cat.error.interface").format("[extension config]", "apply"));
69 | } else {
70 | extensionobj.apply({path: path, internalConfig: internalConfig});
71 | }
72 | }
73 | }
74 | }
75 |
76 | }
77 | };
78 |
79 | } else {
80 | _log.warning("[Extension] No valid data configuration");
81 | }
82 | }
83 |
84 | return this;
85 |
86 | };
87 |
--------------------------------------------------------------------------------
/src/module/config/project/Filter.js:
--------------------------------------------------------------------------------
1 | var _path = require("path");
2 |
3 | module.exports = function (config) {
4 |
5 | var me = this;
6 |
7 | if (config) {
8 | this.type = (config.type || "*"); // * || file || folder
9 | this.pattern = (config.pattern || undefined);
10 | this.exclude = (config.exclude || undefined);
11 |
12 | this.apply = function (callback) {
13 | return callback.call(this, me);
14 | };
15 |
16 |
17 | }
18 |
19 | };
--------------------------------------------------------------------------------
/src/module/extension/inject/build/cache.js:
--------------------------------------------------------------------------------
1 | var _Scrap = catrequire("cat.common.scrap"),
2 | _scrapEnum = _Scrap.getScrapEnum(),
3 | _tplutils = catrequire("cat.tpl.utils"),
4 | _extutils = catrequire("cat.ext.utils"),
5 | _project = catrequire("cat.project");
6 |
7 |
8 | module.exports = function (scraps, sourcefile, targetfile) {
9 |
10 | var cacheOutput = [], cacheIncludeOutput = [],
11 | projectTarget = _project.getInfo("target"),
12 | catinfo;
13 |
14 | scraps.forEach(function (scrap) {
15 |
16 | var printer,
17 | runat,
18 | managerout,
19 | pkgname,
20 | engine = scrap.$getEngine(),
21 | args = scrap.get("arguments"),
22 | scrapvar,
23 | catsourceinfo;
24 |
25 | if (engine === _scrapEnum.engines.JS ||
26 | engine === _scrapEnum.engines.HTML_EMBED_JS) {
27 |
28 | runat = scrap.get("run@");
29 | catsourceinfo = _extutils.getCATInfo({scrap: scrap, file: sourcefile, basepath: projectTarget});
30 | pkgname = catsourceinfo.pkgName;
31 | scrap.set("pkgName", pkgname);
32 |
33 | pkgname = [pkgname, "cat"].join("$$");
34 | scrapvar = ["{ scrap:", JSON.stringify(scrap.serialize()), "}"].join("");
35 |
36 | if (runat) {
37 | managerout = _tplutils.template({
38 | name: "scrap/_func_manager",
39 | data: {
40 | name: pkgname,
41 | runat: runat
42 | }
43 | }
44 | );
45 | }
46 |
47 | if (managerout) {
48 | cacheIncludeOutput.push(managerout);
49 | }
50 |
51 | cacheIncludeOutput.push(_tplutils.template({
52 | name: "scrap/_func_declare",
53 | data: {
54 | name: pkgname,
55 | scrap: scrapvar,
56 | type: "scrap"
57 | }
58 | }
59 | ));
60 |
61 | printer = scrap.printer;
62 | cacheOutput.push(_tplutils.template({
63 | name: "scrap/_func",
64 | data: {
65 | name: pkgname,
66 | arguments: (args ? ( args.join ? args.join(",") : args) : undefined),
67 | output: printer.generate()}
68 | }
69 | ));
70 |
71 |
72 | }
73 | });
74 |
75 | catinfo = _extutils.getCATInfo({file: targetfile});
76 |
77 |
78 | return {
79 | include: {
80 | output: cacheIncludeOutput.join(""),
81 | file: catinfo.includeFile
82 | },
83 | cache: {
84 | output: cacheOutput.join(""),
85 | file: catinfo.file
86 | }
87 | };
88 |
89 | };
--------------------------------------------------------------------------------
/src/module/extension/inject/build/manager.js:
--------------------------------------------------------------------------------
1 | var _generateUserFileInfo = require("./user.js"),
2 | _generateCATFileInfo = require("./cache.js");
3 |
4 | module.exports = function() {
5 |
6 | return {
7 |
8 | getUser: function(scraps, sourcefile, targetfile) {
9 | return _generateUserFileInfo(scraps, sourcefile, targetfile);
10 | },
11 |
12 | getCache: function(scraps, sourcefile, targetfile) {
13 | return _generateCATFileInfo(scraps, sourcefile, targetfile).cache;
14 | },
15 |
16 | getIncludeCache: function(scraps, sourcefile, targetfile) {
17 | return _generateCATFileInfo(scraps, sourcefile, targetfile).include;
18 | }
19 |
20 | };
21 |
22 | }();
--------------------------------------------------------------------------------
/src/module/extension/inject/build/user.js:
--------------------------------------------------------------------------------
1 | var _Scrap = catrequire("cat.common.scrap"),
2 | _scrapEnum = _Scrap.getScrapEnum(),
3 | _tplutils = catrequire("cat.tpl.utils"),
4 | _extutils = catrequire("cat.ext.utils"),
5 | _project = catrequire("cat.project");
6 |
7 | module.exports = function (scraps, sourcefile, targetfile) {
8 |
9 | /* @Obsolete - user code is being refactored [WIP]
10 |
11 |
12 | var outputjs = [],
13 | projectTarget = _project.getInfo("target");
14 |
15 | scraps.forEach(function (scrap) {
16 | var out,
17 | engine = scrap.$getEngine(),
18 | pkgName;
19 |
20 | if (engine === _scrapEnum.engines.JS ||
21 | engine === _scrapEnum.engines.HTML_EMBED_JS) {
22 |
23 | pkgName = _extutils.getUserInfo({scrap: scrap, file: sourcefile, basepath: projectTarget}).pkgName;
24 | scrap.set("pkgName", pkgName);
25 |
26 | out = _tplutils.template({
27 | name: "scrap/_func_user",
28 | data: {name: _extutils.getUserInfo({scrap: scrap, file: sourcefile, basepath: projectTarget}).pkgName,
29 | func: "" }
30 | }
31 | );
32 |
33 | outputjs.push(out);
34 |
35 | }
36 | });
37 |
38 | return {
39 | output: outputjs.join(""),
40 | file: _extutils.getUserInfo({file: targetfile}).file
41 | };
42 |
43 | */
44 | };
45 |
--------------------------------------------------------------------------------
/src/module/extension/inject/parser/replaceInfo.js:
--------------------------------------------------------------------------------
1 | var _Scrap = catrequire("cat.common.scrap"),
2 | _scrapEnum = _Scrap.getScrapEnum();
3 |
4 | /**
5 | * Process replace info
6 | */
7 | module.exports = function(config) {
8 |
9 | var markDefault = {
10 | prefix: "/*",
11 | suffix: "*/"
12 | }, mark,
13 | lines = config.lines,
14 | line = config.line,
15 | scraplcl = config.scraplcl,
16 | lineNumber = config.lineNumber,
17 | replaceinfo = config.replaceinfo,
18 | engine = scraplcl.$getEngine();
19 |
20 | if (scraplcl.$getBehavior()) {
21 |
22 | if (engine === _scrapEnum.engines.JS) {
23 | // JS file type call
24 | mark = markDefault;
25 |
26 | } else if (engine === _scrapEnum.engines.JS_EMBED_INSERT) {
27 | // Embed Javascript block for JS file
28 | mark = markDefault;
29 |
30 | } else if (engine === _scrapEnum.engines.HTML_EMBED_JS) {
31 | // Embed Javascript block for HTML file
32 | mark = markDefault;
33 |
34 | }
35 |
36 | return replaceinfo.apply({lines: lines, line: line, row: lineNumber, mark: mark});
37 | }
38 |
39 | return undefined;
40 | };
--------------------------------------------------------------------------------
/src/module/extension/loader/action.js:
--------------------------------------------------------------------------------
1 | var _fs = require('fs.extra'),
2 | _path = require('path'),
3 | _global = catrequire("cat.global"),
4 | _log = _global.log(),
5 | _utils = catrequire("cat.props"),
6 | _typedas = require("typedas"),
7 | _props = catrequire("cat.props"),
8 | _basePlugin = require("./../Base.js"),
9 | _watch = require("watch");
10 |
11 | /**
12 | * Dependency Loader extension for CAT
13 | * Mode set to 'init' the loader's 'apply' is being executed before the plugin
14 | *
15 | * @type {module.exports}
16 | */
17 | module.exports = _basePlugin.ext(function () {
18 |
19 | var _me = this,
20 |
21 | /**
22 | * Load CAT external extensions according to the given path
23 | *
24 | * @param dirs The reference directories
25 | */
26 | _load = function (dirs) {
27 | var path;
28 |
29 | if (_typedas.isArray(dirs)) {
30 | dirs.forEach(function (dir) {
31 | if (dir) {
32 | try {
33 | if (_fs.existsSync(dir)) {
34 | path = _path.resolve(dir) + "/";
35 | _me.getProject().addPluginLocations([path]);
36 | }
37 | } catch (e) {
38 | _log.warning("[CAT Loader] Skip, No valid directory was found: '" + dir + "'");
39 | }
40 | }
41 | });
42 | } else {
43 | _log.warning(_props.get("cat.arguments.type").format("[CAT loader]", "Array"));
44 | }
45 | },
46 |
47 | _module = {
48 |
49 | /**
50 | * Apply the load extension
51 | *
52 | * @param config
53 | * path - The base path to scan from
54 | */
55 | apply: function (config) {
56 |
57 | var dirs = (config ? config.path : undefined),
58 | emitter = _me.getEmitter();
59 |
60 | _me.apply(config);
61 |
62 | if (!dirs) {
63 | _utils.error(_props.get("cat.error.config").format("[CAT loader]"));
64 | }
65 | _load(dirs);
66 |
67 | emitter.emit("job.done", {status: "done"});
68 |
69 | },
70 |
71 | /**
72 | * Plugin initialization
73 | * Use base initializer
74 | *
75 | * @param config The passed arguments
76 | * project - The project configuration object
77 | * grunt - The grunt handle
78 | * emitter - The emitter handle
79 | *
80 | * @param ext The extension properties
81 | */
82 | init: function (config, ext) {
83 | _me.initialize(config, ext);
84 |
85 | },
86 |
87 | getPhase: function () {
88 | return _me.getPhase();
89 | }
90 |
91 | };
92 |
93 | return _module;
94 | });
--------------------------------------------------------------------------------
/src/module/extension/manager/action.js:
--------------------------------------------------------------------------------
1 | var _fs = require('fs.extra'),
2 | _path = require('path'),
3 | _global = catrequire("cat.global"),
4 | _log = _global.log(),
5 | _process = require('child_process'),
6 | _basePlugin = require("./../Base.js");
7 |
8 | /**
9 | * Manager extension for CAT
10 | * A default extension for running plugins
11 | *
12 | * Any plugin that needs to be dependent on general extension with no special
13 | * services can hook to this implementation
14 | *
15 | * @type {module.exports}
16 | */
17 | module.exports = _basePlugin.ext(function () {
18 |
19 | var _me = this,
20 |
21 | _module = {
22 |
23 | watch: function(config) {
24 |
25 | },
26 |
27 | /**
28 | * Apply the manager extension
29 | *
30 | * @param config
31 | * command - command to run
32 | * options - spawn options
33 | */
34 | apply: function (config) {
35 |
36 | //_me.getEmitter().emit("job.done", {status: "done"});
37 | },
38 |
39 | /**
40 | * Plugin initialization
41 | *
42 | * @param config The passed arguments
43 | * project - The project configuration object
44 | * grunt - The grunt handle
45 | * emitter - The emitter handle
46 | *
47 | * @param ext The extension properties
48 | */
49 | init: function (config, ext) {
50 | _me.initialize(config, ext);
51 |
52 | }
53 | };
54 |
55 | return _module;
56 | });
--------------------------------------------------------------------------------
/src/module/extension/phantomjs/action.js:
--------------------------------------------------------------------------------
1 | var _fs = require('fs.extra'),
2 | _path = require('path'),
3 | _global = catrequire("cat.global"),
4 | _log = _global.log(),
5 | _utils = catrequire("cat.utils"),
6 | _typedas = require("typedas"),
7 | _props = catrequire("cat.props"),
8 | _basePlugin = require("./../Base.js"),
9 | _phantomBridge = require("./phantom-bridge.js");
10 |
11 | /**
12 | * Clean extension for CAT
13 | *
14 | * @type {module.exports}
15 | */
16 | module.exports = _basePlugin.ext(function () {
17 |
18 | var _me = this,
19 |
20 | _module = {
21 |
22 | watch: function() {
23 |
24 | },
25 |
26 | /**
27 | * Apply the clean extension.
28 | *
29 | * @param config
30 | * path - The base path to clean from
31 | */
32 | apply: function (config) {
33 |
34 | var dirs = (config ? config.path : undefined),
35 | error = "[Scan Ext] no valid configuration for 'apply' functionality",
36 | emitter = _me.getEmitter();
37 |
38 | _me.apply(config);
39 |
40 | if (!dirs) {
41 | _utils.error(error);
42 | }
43 |
44 | _me.getEmitter().emit("phantomjs", {thiz: _me, phantomjs: _phantomBridge});
45 |
46 | },
47 |
48 | /**
49 | * Plugin initialization
50 | *
51 | * @param config The passed arguments
52 | * project - The project configuration object
53 | * grunt - The grunt handle
54 | * emitter - The emitter handle
55 | *
56 | * @param ext The extension properties
57 | */
58 | init: function (config, ext) {
59 | _me.initialize(config, ext);
60 |
61 | }
62 | };
63 |
64 | return _module;
65 |
66 | });
--------------------------------------------------------------------------------
/src/module/extension/runner/action.js:
--------------------------------------------------------------------------------
1 | var _path = require('path'),
2 | _global = catrequire("cat.global"),
3 | _log = _global.log(),
4 | _props = catrequire("cat.props"),
5 | _utils = catrequire("cat.utils"),
6 | _basePlugin = require("./../Base.js"),
7 | _runner = require("./runner.js");
8 |
9 | /**
10 | * Clean extension for CAT
11 | *
12 | * @type {module.exports}
13 | */
14 | module.exports = _basePlugin.ext(function () {
15 |
16 | var _me = this,
17 |
18 | _module = {
19 |
20 | watch: function() {
21 |
22 | },
23 |
24 | /**
25 | * Apply the clean extension.
26 | *
27 | * @param config
28 | * path - The base path to clean from
29 | */
30 | apply: function (config) {
31 |
32 | var dirs = (config ? config.path : undefined),
33 | error = "[Scan Ext] no valid configuration for 'apply' functionality",
34 | emitter = _me.getEmitter();
35 |
36 | _me.apply(config);
37 |
38 | if (!dirs) {
39 | _utils.error(error);
40 | }
41 |
42 | emitter.emit("runner", {thiz: _me, runner: _runner});
43 |
44 | },
45 |
46 | /**
47 | * Plugin initialization
48 | *
49 | * @param config The passed arguments
50 | * project - The project configuration object
51 | * grunt - The grunt handle
52 | * emitter - The emitter handle
53 | *
54 | * @param ext The extension properties
55 | */
56 | init: function (config, ext) {
57 | _me.initialize(config, ext);
58 |
59 | }
60 | };
61 |
62 | return _module;
63 |
64 | });
--------------------------------------------------------------------------------
/src/module/extension/spawn/action.js:
--------------------------------------------------------------------------------
1 | var _fs = require('fs.extra'),
2 | _path = require('path'),
3 | _global = catrequire("cat.global"),
4 | _log = _global.log(),
5 | _process = require('child_process'),
6 | _basePlugin = require("./../Base.js");
7 |
8 | /**
9 | * Spawn extension for CAT
10 | *
11 | * @type {module.exports}
12 | */
13 | module.exports = _basePlugin.ext(function () {
14 |
15 | var _me = this,
16 |
17 | _module = {
18 |
19 | watch: function(config) {
20 | this.apply(config);
21 | },
22 |
23 | /**
24 | * Apply the spawn extension
25 | *
26 | * @param config
27 | * command - command to run
28 | * options - spawn options
29 | */
30 | apply: function (config) {
31 | _me.getEmitter().emit("spawn.exec", {spawn: _process.spawn});
32 | },
33 |
34 | /**
35 | * Plugin initialization
36 | *
37 | * @param config The passed arguments
38 | * project - The project configuration object
39 | * grunt - The grunt handle
40 | * emitter - The emitter handle
41 | *
42 | * @param ext The extension properties
43 | */
44 | init: function (config, ext) {
45 | _me.initialize(config, ext);
46 |
47 | }
48 | };
49 |
50 | return _module;
51 | });
--------------------------------------------------------------------------------
/src/module/extension/webserver/action.js:
--------------------------------------------------------------------------------
1 | var _path = require('path'),
2 | _global = catrequire("cat.global"),
3 | _log = _global.log(),
4 | _props = catrequire("cat.props"),
5 | _utils = catrequire("cat.utils"),
6 | _basePlugin = require("./../Base.js"),
7 | _webserver = require("./web-server.js");
8 |
9 | /**
10 | * Clean extension for CAT
11 | *
12 | * @type {module.exports}
13 | */
14 | module.exports = _basePlugin.ext(function () {
15 |
16 | var _me = this,
17 |
18 | _module = {
19 |
20 | watch: function() {
21 |
22 | },
23 |
24 | /**
25 | * Apply the clean extension.
26 | *
27 | * @param config
28 | * path - The base path to clean from
29 | */
30 | apply: function (config) {
31 |
32 | var dirs = (config ? config.path : undefined),
33 | error = "[Scan Ext] no valid configuration for 'apply' functionality",
34 | emitter = _me.getEmitter();
35 |
36 | _me.apply(config);
37 |
38 | if (!dirs) {
39 | _utils.error(error);
40 | }
41 |
42 | emitter.emit("webserver", {thiz: _me, webserver: _webserver});
43 |
44 | },
45 |
46 | /**
47 | * Plugin initialization
48 | *
49 | * @param config The passed arguments
50 | * project - The project configuration object
51 | * grunt - The grunt handle
52 | * emitter - The emitter handle
53 | *
54 | * @param ext The extension properties
55 | */
56 | init: function (config, ext) {
57 | _me.initialize(config, ext);
58 |
59 | }
60 | };
61 |
62 | return _module;
63 |
64 | });
--------------------------------------------------------------------------------
/src/module/extension/webserver/rest/config.js:
--------------------------------------------------------------------------------
1 | var _global = catrequire("cat.global"),
2 | _log = _global.log(),
3 | _fs = require("fs"),
4 | _catcli = (catrequire ? catrequire("cat.cli") : null),
5 | _configs;
6 |
7 | function _read() {
8 |
9 | // read configuration
10 | var path = require("path"),
11 | configPath,
12 | data,
13 | project, sourceFolder;
14 |
15 | if (_catcli) {
16 | project = _catcli.getProject();
17 | if (project) {
18 | try {
19 | sourceFolder = project.getInfo("source");
20 | configPath = path.join(sourceFolder, "/config/cat.json");
21 |
22 | } catch (e) {
23 | _log.error("[catjs server (config module)] Failed to load cat.json test project, No CAT test project is available.", e);
24 | }
25 | } else {
26 | _log.error("[catjs server (config module)] Failed to load cat.json test project, No CAT project is available.");
27 | }
28 | }
29 |
30 | if (configPath && _fs.existsSync(configPath)) {
31 | data = _fs.readFileSync(configPath, 'utf8');
32 | return JSON.parse(data);
33 | }
34 |
35 | return undefined;
36 | }
37 |
38 | function _Configs() {
39 | this.configs = {};
40 | }
41 |
42 | _Configs.prototype.set = function(config) {
43 | this.configs[config.id] = config;
44 | };
45 |
46 | _Configs.prototype.get = function(key) {
47 | return (this.configs ? this.configs[key] : undefined);
48 | };
49 |
50 | _Configs.prototype.destroy = function() {
51 | this.configs = {};
52 | };
53 |
54 | _configs = new _Configs();
55 |
56 |
57 | module.exports = function () {
58 |
59 | return {
60 |
61 | /**
62 | * @deprecated Use the post method since we need the running project cat.json test project (runtime)
63 | *
64 | * Load the local project cat.json file
65 | *
66 | * @returns {*}
67 | */
68 | get: function () {
69 | return _read();
70 | },
71 |
72 | post: function (req, res) {
73 |
74 | var status = false,
75 | id;
76 |
77 | // store the incoming test project
78 | if (req.body) {
79 | _configs.set(req.body);
80 | id = req.body.id;
81 | status = true;
82 | }
83 |
84 | return {
85 | id: id,
86 | config: _configs,
87 | response: res,
88 | status: status
89 | }
90 | },
91 |
92 | /**
93 | *
94 | * @param config {Object}
95 | * id {String} test id
96 | * config {Object} The incoming configuration
97 | * response {Object} HTTP Response
98 | * status {Boolean} The response status
99 | */
100 | response: function(config) {
101 |
102 | var res = config.response,
103 | catjsconfig = config.config,
104 | id = config.id,
105 | status = config.status,
106 | currentIndex = config.currentIndex;
107 |
108 | res.setHeader('Content-Type', 'text/javascript;charset=UTF-8');
109 | if (status) {
110 | res.send('{"status": "ready", "currentIndex" : ' + currentIndex + ' }');
111 |
112 | } else {
113 | res.send('{"status": "error", "error":{ msg:"request body is not valid, check your cat.json file" }}, "currentIndex": 0');
114 | }
115 | },
116 |
117 |
118 | getConfig: function(id) {
119 | return _configs.get(id);
120 | }
121 | };
122 |
123 | }();
--------------------------------------------------------------------------------
/src/module/extension/webserver/rest/deviceinfo.js:
--------------------------------------------------------------------------------
1 | var _global = catrequire("cat.global"),
2 | _log = _global.log(),
3 | _catinfo = catrequire("cat.info"),
4 | _useragent = require('express-useragent'),
5 | _utils = catrequire("cat.utils"),
6 | _fs = require("fs");
7 |
8 |
9 |
10 | /**
11 | * Initial settings
12 | * - Loading colors module
13 | * - Loading cat configuration
14 | */
15 | function init() {
16 |
17 |
18 | }
19 |
20 |
21 | // Initialization
22 | init();
23 |
24 |
25 | exports.post = function (req, res) {
26 |
27 | var deviceinfo,
28 | deviceName,
29 | _userAgent,
30 | deviceName, deviceId,
31 | saveScreenshot,
32 | ua,
33 | ismobile;
34 |
35 | _userAgent = function (req) {
36 |
37 | var source = req.headers['user-agent'],
38 | us;
39 | if (source) {
40 | us = _useragent.parse(source);
41 | }
42 | if (req.body.deviceType) {
43 | us.isMobile = true;
44 | us.isAndroid = (req.body.deviceType === "android");
45 | us.isiOS = (req.body.deviceType === "iOS");
46 | us.Version = req.body.deviceType;
47 | }
48 |
49 | return us;
50 | }
51 |
52 | ua = _userAgent(req);
53 | ismobile = ("isMobile" in ua && _utils.getProperty(ua, "isMobile"));
54 |
55 |
56 | deviceinfo = JSON.stringify(req.body);
57 | console.log("got device info : " + deviceinfo);
58 | _catinfo.set({
59 | id: req.body.deviceId,
60 | device: (ismobile ? "device" : "browser"),
61 | model : (_utils.getProperty(ua, "Version")),
62 | type: (ismobile ? _utils.getProperty(ua, "Platform") : _utils.getProperty(ua, "Browser")),
63 | entity: "deviceinfo",
64 | data: deviceinfo
65 | });
66 |
67 |
68 | res.setHeader('Content-Type', 'text/javascript;charset=UTF-8');
69 | res.send('{"deviceinfo": "save",' +
70 |
71 | '"deviceName" : "' + deviceName + '",' +
72 | '"deviceId" : "' + deviceId + '",' +
73 | '}');
74 |
75 | };
76 |
77 |
--------------------------------------------------------------------------------
/src/module/extension/webserver/rest/entity/Assert.js:
--------------------------------------------------------------------------------
1 | var Params = require("./Params.js"),
2 | Assert = function(config) {
3 |
4 | this._params = new Params(config);
5 |
6 | };
7 |
8 | Assert.prototype.getParams = function() {
9 | return this._params;
10 | };
11 |
12 | module.exports = Assert;
--------------------------------------------------------------------------------
/src/module/extension/webserver/rest/entity/Params.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | module.exports = function(config) {
4 |
5 | var me = this;
6 |
7 | function _init(params) {
8 | var key;
9 |
10 | for (key in params) {
11 | if (params.hasOwnProperty(key)) {
12 | me[key] = params[key];
13 | }
14 | }
15 | }
16 |
17 | if (!config) {
18 | return undefined;
19 | }
20 |
21 | if ("params" in config && config.params) {
22 | _init(config.params);
23 | }
24 |
25 | };
--------------------------------------------------------------------------------
/src/module/extension/webserver/rest/helpers/colors.js:
--------------------------------------------------------------------------------
1 | var _colors = require('colors'),
2 | Colors = function () {
3 |
4 | this._colors;
5 | this._colorsArray = ['blue', 'yellow', 'cyan', 'magenta', 'grey', 'green'];
6 | this._colorCell = {};
7 | this._colorIndex = -1;
8 | };
9 |
10 | /**
11 | * Remove the color from the pool according to the test id
12 | */
13 | Colors.prototype.deleteColor = function (id) {
14 |
15 | if (id !== undefined && typeof this._colorCell[id] !== "undefined") {
16 | delete this._colorCell[id];
17 | }
18 | };
19 |
20 | Colors.prototype.setCurrentTheme = function (id) {
21 | _colors.setTheme({'current': this._colorsArray[this.getColorIndex(id)]});
22 | };
23 |
24 | Colors.prototype.setTheme = function (opt) {
25 | _colors.setTheme({'current': opt.color});
26 | };
27 |
28 | /**
29 | * Get color index
30 | *
31 | * @param id {String} The id of the running test
32 | * @returns {*}
33 | */
34 | Colors.prototype.getColorIndex = function (id) {
35 |
36 | if (id !== undefined && typeof this._colorCell[id] !== "undefined") {
37 | return this._colorCell[id];
38 | }
39 |
40 | this._colorIndex++;
41 | if (this._colorIndex > this._colorsArray.length - 1) {
42 | this._colorIndex = 0;
43 | }
44 |
45 | if (id !== undefined) {
46 | this._colorCell[id] = this._colorIndex;
47 | }
48 | return this._colorIndex;
49 |
50 | };
51 |
52 | module.exports = Colors;
--------------------------------------------------------------------------------
/src/module/extension/webserver/rest/runner.js:
--------------------------------------------------------------------------------
1 | var _global = catrequire("cat.global"),
2 | _log = _global.log();
3 |
4 |
5 | module.exports = function() {
6 |
7 | return {
8 |
9 | get: function(req, res) {
10 |
11 |
12 |
13 | }
14 |
15 | };
16 |
17 | }();
--------------------------------------------------------------------------------
/src/module/extension/webserver/rest/scrap/TestConfig.js:
--------------------------------------------------------------------------------
1 | var _utils = catrequire("cat.utils");
2 |
3 | function TestConfig(config) {
4 |
5 | var me = this;
6 |
7 | this.tests = config.tests;
8 | this.request = config.request;
9 | this.testsmap = {};
10 |
11 | this.tests.forEach(function(test) {
12 | var pathmatch = true;
13 | if (test) {
14 | if (test.path) {
15 | pathmatch = _utils.pathMatch(me.request, test.path);
16 | }
17 | if (!pathmatch) {
18 | test.skip = true;
19 | } else {
20 | test.skip = false;
21 | }
22 |
23 | me.testsmap[test.index] = test;
24 | }
25 | });
26 |
27 | this.scrapReadyIndex = 0;
28 | this.resQueue = {}
29 | }
30 |
31 | TestConfig.prototype.skip = function() {
32 | var index = this.getIndex(),
33 | test = this.testsmap[index];
34 |
35 | return (test ? test.skip : false);
36 | };
37 |
38 | TestConfig.prototype.getTests = function() {
39 | return this.tests;
40 | };
41 |
42 | TestConfig.prototype.getTest = function(idx) {
43 | return this.testsmap[idx];
44 | };
45 |
46 | TestConfig.prototype.setToQueue = function(idx) {
47 | this.resQueue[idx] = 1;
48 | };
49 |
50 | TestConfig.prototype.remove = function(idx) {
51 | this.resQueue[idx] = undefined;
52 | };
53 |
54 | TestConfig.prototype.getTests = function() {
55 | return this.tests;
56 | };
57 |
58 | TestConfig.prototype.next = function() {
59 | this.scrapReadyIndex++;
60 | };
61 |
62 | TestConfig.prototype.getIndex = function() {
63 | return this.scrapReadyIndex;
64 | };
65 |
66 | TestConfig.prototype.setIndex = function(idx) {
67 | this.scrapReadyIndex = idx;
68 | };
69 |
70 | TestConfig.prototype.isInQueue = function(idx) {
71 | if (this.resQueue[idx]) {
72 | return true;
73 | }
74 | return false;
75 | };
76 |
77 |
78 | module.exports = TestConfig;
--------------------------------------------------------------------------------
/src/module/extension/webserver/rest/screenshot.js:
--------------------------------------------------------------------------------
1 | var _global = catrequire("cat.global"),
2 | _log = _global.log(),
3 | _catinfo = catrequire("cat.info"),
4 | _useragent = require('express-useragent'),
5 | _fs = require("fs"),
6 | _utils = catrequire("cat.utils"),
7 | _date = require("date-format-lite");
8 |
9 |
10 | exports.post = function (req, res) {
11 |
12 | var pic,
13 | scrapName,
14 | _userAgent,
15 | deviceName, deviceId,
16 | save,
17 | ua,
18 | ismobile;
19 |
20 |
21 | save = function (data) {
22 | var filename;
23 |
24 | if (scrapName.indexOf("_$$_") === 0) {
25 | scrapName = scrapName.substring(4);
26 | filename = scrapName;
27 |
28 | } else {
29 | scrapName = [scrapName, "_", (new Date()).format("hh_mm_ss_S")].join("");
30 | filename = [scrapName, deviceName ,deviceId ].join("_");
31 | }
32 |
33 | _catinfo.set({
34 | id: deviceId,
35 | device: (ismobile ? "device" : "browser"),
36 | model : _utils.getProperty(ua, "Version"),
37 | type: (ismobile ? _utils.getProperty(ua, "platform") : _utils.getProperty(ua, "Browser")),
38 | entity: "screenshot",
39 | filename: filename,
40 | data: data
41 | });
42 |
43 | res.setHeader('Content-Type', 'text/javascript;charset=UTF-8');
44 | res.send('{"screenshot": "save",' +
45 | '"scrapName" : "' + scrapName + '",' +
46 | '"deviceName" : "' + deviceName + '",' +
47 | '"deviceId" : "' + deviceId + '",' +
48 | '}');
49 | };
50 |
51 |
52 | _userAgent = function (req) {
53 |
54 | var source = req.headers['user-agent'],
55 | us;
56 | if (source) {
57 | us = _useragent.parse(source);
58 | }
59 | if (req.body.deviceType) {
60 | us.isMobile = true;
61 | us.isAndroid = (req.body.deviceType === "android");
62 | us.isiOS = (req.body.deviceType === "iOS");
63 | us.Version = req.body.deviceType;
64 |
65 | }
66 |
67 | return us;
68 | };
69 |
70 | ua = _userAgent(req);
71 | ismobile = _utils.getProperty(ua, "isMobile");
72 | scrapName = req.body.scrapName;
73 | deviceName = req.body.deviceName;
74 | deviceId = req.body.deviceId;
75 |
76 | // get the screenshot and convert to base64
77 | pic = (req.body.pic);
78 | pic = pic.replace(new RegExp('\n| ', 'g'), '');
79 |
80 | save(pic);
81 |
82 | };
83 |
84 |
--------------------------------------------------------------------------------
/src/module/info/Info.js:
--------------------------------------------------------------------------------
1 | var _BaseInfo = require("./Base.js"),
2 | _baseinfo = new _BaseInfo(),
3 | _utils = catrequire("cat.utils");
4 |
5 | module.exports = function () {
6 |
7 | return {
8 |
9 | /**
10 | * Set the incoming data to the proper report file by its entity
11 | *
12 | * @param config
13 | * id {String} The test id
14 | * device {String} The target device ["device" | "browser"]
15 | * type {String} The device type e.g. android, ios, chrome, etc...
16 | * entity {String} The test entity ["info" | "test" | "junit"]
17 | * data {Object} The data to be saved in the target report file
18 | */
19 | set: function (config) {
20 |
21 |
22 | if (!config) {
23 | return undefined;
24 | }
25 |
26 | _utils.prepareProps({
27 | global: {obj: config},
28 | props: [
29 | {key: "id", require: true},
30 | {key: "device", require: true},
31 | {key: "type", require: true},
32 | {key: "entity", require: true},
33 | {key: "model"},
34 | {key: "filename"},
35 | {key: "data"}
36 | ]
37 | });
38 |
39 | _baseinfo.updateFS({
40 | id: config.id,
41 | device: config.device,
42 | type: config.type,
43 | entity: config.entity,
44 | data: config.data,
45 | filename: config.filename,
46 | model : config.model
47 | });
48 |
49 |
50 | }
51 |
52 | };
53 |
54 | }();
--------------------------------------------------------------------------------
/src/module/info/entity/Device.js:
--------------------------------------------------------------------------------
1 | var _utils = catrequire("cat.utils"),
2 | _JSONUtils = catrequire("cat.jsonutils"),
3 | _nodeutil = require("util"),
4 | _fs = require("fs"),
5 | _Generic = require("./Generic.js"),
6 | _generic = new _Generic();
7 |
8 | _generic.setProto("init", function() {
9 | this.read();
10 | });
11 |
12 | module.exports = _generic;
--------------------------------------------------------------------------------
/src/module/info/entity/Deviceinfo.js:
--------------------------------------------------------------------------------
1 | var _utils = catrequire("cat.utils"),
2 | _JSONUtils = catrequire("cat.jsonutils"),
3 | _nodeutil = require("util"),
4 | _fs = require("fs"),
5 | _Generic = require("./Generic.js"),
6 | _generic = new _Generic();
7 |
8 | _generic.setProto("write", function() {
9 | //this.read();
10 |
11 | });
12 |
13 |
14 | _generic.setProto("add", function(record) {
15 | var filepath = this.filename;
16 | _fs.readFile(filepath, 'utf8', function (err, data) {
17 | var dataArr, dataStr, recordObj;
18 | if (err) {
19 | dataArr = [];
20 | } else {
21 | dataArr = JSON.parse(data);
22 | }
23 | recordObj = JSON.parse(record);
24 | dataArr.push(recordObj);
25 | dataStr = JSON.stringify(dataArr, null, 4);
26 | _fs.writeFile(filepath, dataStr, function (err) {
27 | if (err) {
28 | console.log("deviceinfo error");
29 | } else {
30 | console.log("deviceinfo saved");
31 | }
32 |
33 | });
34 |
35 | });
36 | });
37 |
38 | module.exports = _generic;
--------------------------------------------------------------------------------
/src/module/info/entity/Generic.js:
--------------------------------------------------------------------------------
1 | var _utils = catrequire("cat.utils"),
2 | _JSONUtils = catrequire("cat.jsonutils"),
3 | _ = require("underscore"),
4 | _fs = require("fs");
5 |
6 | module.exports = function() {
7 |
8 | function _Record(config) {
9 |
10 | if (!config) {
11 | return undefined;
12 | }
13 |
14 | var me = this;
15 |
16 | this.filename = _utils.getProp({key: "filename", obj: config});
17 | this.data = (config.data || {});
18 |
19 | this.init();
20 |
21 | }
22 |
23 | _Record.prototype.init = function() {
24 |
25 | };
26 |
27 | _Record.prototype.add = function(record) {
28 | if (_.isArray(record) && _.isArray(this.data)) {
29 | this.data = this.data.concat(record);
30 | } else {
31 | this.data = record;
32 | }
33 | };
34 |
35 | _Record.prototype.put = function(key, record) {
36 | if (_.isObject(this.data)) {
37 | this.data[key] = record;
38 | }
39 | };
40 |
41 | _Record.prototype.set = function(record) {
42 | this.data = record;
43 | };
44 |
45 | _Record.prototype.read = function() {
46 |
47 | var content = _JSONUtils.read({
48 | filename: this.filename
49 | });
50 |
51 | if (content) {
52 | content = JSON.parse(content);
53 | this.add(content);
54 | }
55 | };
56 |
57 | _Record.prototype.write = function() {
58 |
59 | var content = (_.isString(this.data) ? this.data : JSON.stringify(this.data));
60 |
61 | _JSONUtils.write({
62 | filename: this.filename,
63 | content: content,
64 | opt: {mode: 0777}
65 | });
66 |
67 | };
68 |
69 | return {
70 |
71 | setProto: function(key, value) {
72 | _Record.prototype[key] = value;
73 | },
74 |
75 | /**
76 | * If the file does not exists it will be created
77 | * The data will append to the array data object
78 | *
79 | * @param filename
80 | * @param data
81 | * @param write
82 | */
83 | update: function(filename, data, write) {
84 |
85 | var record;
86 |
87 | record = new _Record({
88 | filename: filename
89 | });
90 |
91 | write = (write === undefined ? true : write);
92 | if (data) {
93 | record.add(data);
94 | }
95 | if (write) {
96 | record.write();
97 | }
98 |
99 | return record;
100 | }
101 |
102 | };
103 | };
--------------------------------------------------------------------------------
/src/module/info/entity/Screenshot.js:
--------------------------------------------------------------------------------
1 | var _utils = catrequire("cat.utils"),
2 | _fs = require("fs"),
3 | _Generic = require("./Generic.js"),
4 | _generic = new _Generic(),
5 | _log = catrequire("cat.global").log();
6 |
7 | _generic.setProto("write", function() {
8 | //this.read();
9 |
10 | });
11 |
12 |
13 | _generic.setProto("add", function(record) {
14 |
15 | var imageBuffer = new Buffer(record, 'base64');
16 |
17 | _fs.writeFile(this.filename, imageBuffer, function (err) {
18 | if (err) {
19 | _utils.error("[Scrap Plugin] failed to save screenshot: ", this.filename, " error: ", err);
20 | } else {
21 | _log.info("[catjs screenshot entity] Screenshot saved: " + this.filename);
22 | }
23 |
24 | });
25 | });
26 |
27 | module.exports = _generic;
--------------------------------------------------------------------------------
/src/module/plugin/clean.js:
--------------------------------------------------------------------------------
1 | var _catglobal = catrequire("cat.global"),
2 | _log = _catglobal.log(),
3 | _path = require("path"),
4 | _props = catrequire("cat.props"),
5 | _basePlugin = catrequire("cat.plugin.base"),
6 | _utils = catrequire("cat.utils"),
7 | _fs = require("fs.extra"),
8 | _typedas = require("typedas");
9 |
10 | module.exports = _basePlugin.ext(function () {
11 |
12 | function _rm(src) {
13 |
14 | var stats;
15 |
16 | if (!src) {
17 | return undefined;
18 | }
19 |
20 | src = _utils.globmatch({src: src});
21 |
22 | if (src) {
23 | src.forEach(function(item) {
24 |
25 | if (item && _fs.existsSync(item)) {
26 | stats = _fs.lstatSync(item);
27 | try {
28 | if (stats.isDirectory()) {
29 | _fs.rmrfSync(item);
30 |
31 | } else if (stats.isFile()) {
32 | _fs.unlinkSync(item);
33 |
34 | }
35 | } catch(e) {
36 | _log.error("[CAT clean plugin] failed with errors: ", e);
37 | }
38 | }
39 | });
40 | }
41 | }
42 |
43 | var _emitter,
44 | _global,
45 | _data,
46 | _internalConfig,
47 | _project,
48 | _me = this;
49 |
50 | return {
51 |
52 | /**
53 | * Initial plugin function
54 | *
55 | * @param config The configuration:
56 | * data - The configuration data
57 | * emitter - The emitter reference
58 | * global - The global data configuration
59 | * internalConfig - CAT internal configuration
60 | */
61 | init: function (config) {
62 |
63 | var src,
64 | extensionParams,
65 | errors = ["[libraries plugin] No valid configuration"];
66 |
67 | if (!config) {
68 | _log.error(errors[1]);
69 | _me.setDisabled(true);
70 | }
71 |
72 | _emitter = config.emitter;
73 | _global = config.global;
74 | _data = config.data;
75 | _internalConfig = config.internalConfig;
76 | _project = (_internalConfig ? _internalConfig.getProject() : undefined);
77 |
78 | // initial data binding to 'this'
79 | _me.dataInit(_data);
80 | extensionParams = _data.data;
81 |
82 | if (config && extensionParams) {
83 |
84 | src = ("src" in extensionParams && extensionParams.src);
85 |
86 | if (src) {
87 | if (_typedas.isArray(src)) {
88 | src.forEach(function(item) {
89 | _rm(item);
90 | });
91 |
92 | } else if(_typedas.isString(src)) {
93 | _rm(src);
94 |
95 | } else {
96 | _log.error("[CAT clean plugin] 'src' was found but not valid");
97 | }
98 |
99 | } else {
100 | _log.error("[CAT clean plugin] 'src' property is required ");
101 | }
102 |
103 | // done processing notification for the next task to take place
104 | _emitter.emit("job.done", {status: "done"});
105 |
106 | }
107 | },
108 | /**
109 | * Validate the plugin
110 | *
111 | * dependencies {Array} The array of the supported dependencies types
112 | *
113 | * @returns {{dependencies: Array}}
114 | */
115 | validate: function() {
116 | return { dependencies: ["manager"]};
117 | }
118 |
119 | };
120 |
121 | });
--------------------------------------------------------------------------------
/src/module/plugin/console.js:
--------------------------------------------------------------------------------
1 | var _catglobal = catrequire("cat.global"),
2 | _log = _catglobal.log(),
3 | _path = require("path"),
4 | _props = catrequire("cat.props"),
5 | _basePlugin = catrequire("cat.plugin.base"),
6 | _utils = catrequire("cat.utils"),
7 | _fs = require("fs.extra"),
8 | _typedas = require("typedas");
9 |
10 | module.exports = _basePlugin.ext(function () {
11 |
12 | var _data,
13 | _internalConfig,
14 | _project,
15 | _me = this;
16 |
17 | return {
18 |
19 | /**
20 | * Initial plugin function
21 | *
22 | * @param config The configuration:
23 | * data - The configuration data
24 | * emitter - The emitter reference
25 | * global - The global data configuration
26 | * internalConfig - CAT internal configuration
27 | */
28 | init: function (config) {
29 |
30 | var extensionParams,
31 | message,
32 | method;
33 |
34 | _data = config.data;
35 | _internalConfig = config.internalConfig;
36 | _project = (_internalConfig ? _internalConfig.getProject() : undefined);
37 |
38 | _me.dataInit(_data);
39 | extensionParams = _data.data;
40 |
41 | if (config && extensionParams) {
42 |
43 | message = ("message" in extensionParams && extensionParams.message);
44 | method = ("method" in extensionParams && extensionParams.method);
45 |
46 | _utils.log((method || "log"), message);
47 |
48 | }
49 | },
50 |
51 | /**
52 | * Validate the plugin
53 | *
54 | * dependencies {Array} The array of the supported dependencies types
55 | *
56 | * @returns {{dependencies: Array}}
57 | */
58 | validate: function() {
59 | return { dependencies: ["manager"]};
60 | }
61 |
62 | };
63 |
64 | });
--------------------------------------------------------------------------------
/src/module/plugin/sample.js:
--------------------------------------------------------------------------------
1 | var _catglobal = catrequire("cat.global"),
2 | _log = _catglobal.log(),
3 | _path = require("path"),
4 | _props = catrequire("cat.props"),
5 | _basePlugin = catrequire("cat.plugin.base"),
6 | _utils = catrequire("cat.utils"),
7 | _fs = require("fs.extra"),
8 | _typedas = require("typedas");
9 |
10 | module.exports = _basePlugin.ext(function () {
11 |
12 | var _emitter,
13 | _global,
14 | _data,
15 | _internalConfig,
16 | _project,
17 | _me = this;
18 |
19 | return {
20 |
21 | /**
22 | * Initial plugin function
23 | *
24 | * @param config The configuration:
25 | * data - The configuration data
26 | * emitter - The emitter reference
27 | * global - The global data configuration
28 | * internalConfig - CAT internal configuration
29 | */
30 | init: function (config) {
31 |
32 | var customAttribute,
33 | extensionParams,
34 | errors = ["[libraries plugin] No valid configuration"];
35 |
36 | if (!config) {
37 | _log.error(errors[1]);
38 | _me.setDisabled(true);
39 | }
40 |
41 | _emitter = config.emitter;
42 | _global = config.global;
43 | _data = config.data;
44 | _internalConfig = config.internalConfig;
45 | _project = (_internalConfig ? _internalConfig.getProject() : undefined);
46 |
47 | // initial data binding to 'this'
48 | _me.dataInit(_data);
49 | extensionParams = _data.data;
50 |
51 | if (config && extensionParams) {
52 |
53 | customAttribute = extensionParams.customAttribute;
54 |
55 | // Your code in here ...
56 |
57 | console.log("[sample test init] Running Project: ", _project.name);
58 | console.log("[sample test Init] External attributes named, customAttribute = '" + customAttribute + "'");
59 |
60 |
61 | // done processing notification for the next task to take place
62 | _emitter.emit("job.done", {status: "done"});
63 |
64 | }
65 | },
66 | /**
67 | * Validate the plugin
68 | *
69 | * dependencies {Array} The array of the supported dependencies types
70 | *
71 | * @returns {{dependencies: Array}}
72 | */
73 | validate: function() {
74 | return { dependencies: ["manager"]};
75 | }
76 |
77 | };
78 |
79 | });
--------------------------------------------------------------------------------
/src/module/plugin/scrap/Cache.js:
--------------------------------------------------------------------------------
1 | var _global = catrequire("cat.global");
2 |
3 |
4 | module.exports = function() {
5 |
6 | var _module = {
7 |
8 | set: function(key, value) {
9 |
10 | var cache;
11 | if (_global.get("scraps") === undefined) {
12 | cache = {};
13 | _global.set("scraps", cache);
14 | } else {
15 | cache = _global.get("scraps");
16 | }
17 |
18 | cache[key] = value;
19 | _global.set("scraps", cache);
20 | },
21 |
22 | get: function(key) {
23 | var cache = _global.get("scraps"),
24 | value;
25 | if (cache) {
26 | value = cache[key];
27 | }
28 | return value;
29 |
30 | },
31 |
32 | destroy: function() {
33 | _global.delete("scraps");
34 | }
35 |
36 | };
37 |
38 | return _module;
39 |
40 | }();
--------------------------------------------------------------------------------
/src/module/plugin/scrap/Context.js:
--------------------------------------------------------------------------------
1 |
2 | var _log = catrequire("cat.global").log(),
3 | _clazz;
4 |
5 |
6 | /**
7 | * Scrap context class
8 | * The context data is passed between the annotation's scrap
9 | */
10 | _clazz = function () {
11 |
12 | this.$$context = {};
13 |
14 | };
15 |
16 | _clazz.prototype.set = function (key, value) {
17 | if (key) {
18 | this.$$context[key] = value;
19 | }
20 | };
21 |
22 | _clazz.prototype.get = function (key) {
23 | if (key) {
24 | return this.$$context[key];
25 | }
26 | return undefined;
27 | };
28 |
29 | _clazz.prototype.destroy = function() {
30 | this.$$context = {};
31 | };
32 |
33 | module.exports = _clazz;
--------------------------------------------------------------------------------
/src/module/plugin/scrap/ScrapConfigItem.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Scrap configuration item class
3 | * properties:
4 | * value - the config value
5 | * sign - the sign value ('!' '=')
6 | *
7 | * @type {module.exports}
8 | */
9 |
10 | var _typedas = require("typedas");
11 |
12 | module.exports = function () {
13 |
14 |
15 | function ScrapConfigItem(config) {
16 |
17 | this.$$classType = "ScrapConfigItem";
18 | if (config) {
19 | this.config = config;
20 | }
21 |
22 | }
23 |
24 | ScrapConfigItem.prototype.get = function(key) {
25 | return (this.config ? this.config[key] : undefined);
26 | };
27 |
28 | ScrapConfigItem.prototype.getValue = function() {
29 | return this.get("value");
30 | };
31 |
32 | ScrapConfigItem.prototype.getSign = function() {
33 | return this.get("sign");
34 | };
35 |
36 | return {
37 |
38 | create: function(config) {
39 | return (new ScrapConfigItem(config));
40 | },
41 |
42 | instanceOf: function(obj) {
43 | return (obj && _typedas.isObject(obj) && ("$$classType" in obj) && obj["$$classType"] ? true : false);
44 | }
45 |
46 | };
47 |
48 | }();
--------------------------------------------------------------------------------
/src/module/plugin/scrap/ScrapEnum.js:
--------------------------------------------------------------------------------
1 | var _utils = catrequire("cat.utils");
2 |
3 | module.exports = function () {
4 |
5 | var _baseEnum = {
6 | "_info": {
7 | start: {
8 | line: -1,
9 | col: -1
10 | },
11 | end: {
12 | line: -1,
13 | col: -1
14 | }
15 | }
16 | }, _enum = {
17 |
18 | multiopen:"[",
19 | multiclose:"]",
20 | open: "@[",
21 | close: "]@",
22 | single: "@@",
23 | name: "scrap",
24 |
25 | "injectinfo": _baseEnum["_info"],
26 | "scrapinfo": _baseEnum["_info"],
27 |
28 | // single type scrap item, cannot accept more than one value
29 | singleTypes: ["name"],
30 |
31 | // supported file types
32 | fileTypes: ["js", "html", "*"],
33 |
34 | /*
35 | * js - javascript
36 | * htmlijs - html import javascript
37 | * htmlejs - html embed javascript
38 | */
39 | engines: {
40 | JS: "js",
41 | HTML_IMPORT_JS: "htmlijs",
42 | HTML_EMBED_JS: "htmlejs",
43 | HTML_EMBED_INSERT: "stringinsert",
44 | JS_EMBED_INSERT: "stringjsinsert"
45 | },
46 |
47 | // default file type
48 | defaultFileType: "js"
49 | };
50 |
51 |
52 | return {
53 |
54 | getScrapEnum: function (key, obj) {
55 |
56 | _utils.copyObjProps(_enum[key], obj);
57 |
58 | return obj;
59 | },
60 |
61 | /**
62 | * single line scrap @@scrap[Name (optional)][.. @@[scrap property]@[scrap value]]
63 | * e.g. @@scrap@@import@cat.test.js
64 | * @@scrapTest@@code@console.log('test')
65 | *
66 | * @returns {String} The single line scrap enum (@@scrap)
67 | */
68 | getSingleLineEnum: function() {
69 | return [_enum.single, _enum.name].join("");
70 | },
71 |
72 | scrapEnum: _enum
73 |
74 |
75 |
76 | };
77 |
78 | }();
--------------------------------------------------------------------------------
/src/module/plugin/scrap/parser/CommonParser.js:
--------------------------------------------------------------------------------
1 | var _regutils = catrequire("cat.regexp.utils");
2 |
3 | module.exports = function () {
4 |
5 | return {
6 |
7 | /**
8 | * Interpret the name of the scrap.
9 | * Syntax
10 | * ! Stop/fail the script
11 | *
12 | *
13 | * @param name
14 | */
15 | parseName: function (name) {
16 |
17 | var match = _regutils.getMatch(name, "^(.*)([!=@])(.*)$"),
18 | actualname = name, sign, value;
19 |
20 | if (match) {
21 | actualname = match[1];
22 | sign = match[2];
23 | value = match[3];
24 | }
25 |
26 | return {
27 | name: actualname,
28 | sign: sign,
29 | hint: value
30 | };
31 | }
32 | };
33 |
34 | }();
--------------------------------------------------------------------------------
/src/module/plugin/scrap/parser/Parser.js:
--------------------------------------------------------------------------------
1 | var _parsers = [];
2 |
3 | (function(){
4 | var parsers = [
5 | "SimpleParser",
6 | "SimpleSingleParser"
7 | ];
8 |
9 | parsers.forEach(function(parser) {
10 | _parsers.push(require(["./",parser].join("")));
11 | });
12 |
13 | })();
14 |
15 | /**
16 | * TODO create a base class
17 | *
18 | * @type {module.exports}
19 | */
20 | module.exports = function() {
21 |
22 | return {
23 |
24 | parse: function(scrapCommentBlock) {
25 |
26 | var scraps = [],
27 | scrap;
28 |
29 | _parsers.forEach(function(parser){
30 | if (parser) {
31 | scrap = parser.parse(scrapCommentBlock);
32 | if (scrap) {
33 | scraps = scraps.concat(scrap);
34 | }
35 | }
36 | });
37 |
38 | return scraps;
39 |
40 | }
41 | };
42 |
43 | }();
--------------------------------------------------------------------------------
/src/module/plugin/scrap/printer/Generic.js:
--------------------------------------------------------------------------------
1 | var Printer = require("./Printer");
2 |
3 | module.exports = function() {
4 |
5 | return Printer;
6 |
7 | }();
--------------------------------------------------------------------------------
/src/module/plugin/scrap/printer/Jasmine.js:
--------------------------------------------------------------------------------
1 | var Printer = require("./Printer"),
2 | _ = require("underscore"),
3 | _entityutils = catrequire("cat.entity"),
4 | _jsutils = require("js.utils");
5 |
6 |
7 | module.exports = function () {
8 |
9 |
10 | var _Printer = function () {
11 | var key;
12 |
13 | this._printer = new Printer();
14 |
15 | for (key in this._printer) {
16 | if (this._printer.hasOwnProperty(key)) {
17 | this[key] = this._printer[key];
18 | }
19 | }
20 |
21 | this.generate = function () {
22 |
23 | if (_jsutils.Object.empty(this.output)) {
24 | return undefined;
25 | }
26 |
27 | var order = (this.enum.ORDER in this.output ? this.output[this.enum.ORDER] : undefined),
28 | me = this,
29 | jasmine = _entityutils.getEntity("jasmine"), scrapName;
30 |
31 | if (order) {
32 | order.forEach(function (item) {
33 | var cell, key, out;
34 |
35 | function getScrapValue(key) {
36 |
37 | var scrap = me.scrap.impl;
38 | if (scrap) {
39 | return (scrap.config ? scrap.get(key) : (_.isArray(scrap[key]) ? scrap[key][0] : scrap[key]));
40 | }
41 |
42 | return undefined;
43 | }
44 |
45 | if (item) {
46 | cell = item.cell;
47 | key = item.key;
48 | if (key in me.spec) {
49 | out = (key in me.output ? me.output[key] : undefined);
50 | if (out) {
51 | out = out[cell];
52 | if (out) {
53 | scrapName = getScrapValue("name");
54 | if (scrapName) {
55 | jasmine.add({
56 | name: key,
57 | scrapname: getScrapValue("name"),
58 | data: out
59 | });
60 | }
61 | }
62 | }
63 | }
64 | }
65 |
66 | });
67 |
68 | //jasmine.flush();
69 | }
70 | };
71 |
72 | this.spec = {"describe": 1, "it": 1, "xdescribe": 1, "xit": 1};
73 |
74 | };
75 |
76 |
77 | return _Printer;
78 |
79 |
80 | }();
--------------------------------------------------------------------------------
/src/module/plugin/server/standalone.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = function() {
3 |
4 |
5 | function _isCatProjectExists() {
6 |
7 | }
8 |
9 | return {
10 |
11 | init: function(config) {
12 |
13 |
14 |
15 | }
16 |
17 | };
18 |
19 | }();
--------------------------------------------------------------------------------
/src/module/project/Project.js:
--------------------------------------------------------------------------------
1 | var _fsconfig = require("./../utils/fs/Config.js"),
2 | _Config = catrequire("cat.common.config"),
3 | _global = catrequire("cat.global"),
4 | _utils = catrequire("cat.utils"),
5 | _props = catrequire("cat.props"),
6 | _fs = require("fs.extra"),
7 | _log = _global.log(),
8 | _path = require("path"),
9 | _console = require("./../Console"),
10 | _project,
11 |
12 | /**
13 | * Project configuration loader
14 | *
15 | * @param config The passed arguments
16 | * path - The path of the project
17 | * emitter - The emitter to be used for the project
18 | */
19 | _loader = function (config) {
20 |
21 |
22 | function _loadProject(callback) {
23 |
24 | if (!callback) {
25 | _console.log("[CAT Project] Missing callback for the project loader ");
26 | }
27 |
28 | try {
29 | // Loading catproject.json file > data
30 | (new _fsconfig(path, callback));
31 | } catch (e) {
32 | _console.log("[CAT Project] error occured, probably not valid cat project [catproject.json]: ");
33 | }
34 | }
35 |
36 | var msg = ["[Project] config argument is not valid",
37 | "[Project] Data is not valid, expecting data of type Array",
38 | "[Project] Loading project: "],
39 | path, emitter,
40 | callback = (config && ("callback" in config) ? config.callback : undefined),
41 | baseCallback = function (data) {
42 | if (data) {
43 | try {
44 | _project = new _Config({data: data, emitter: emitter});
45 |
46 | } catch (e) {
47 | throw Error(e);
48 | }
49 |
50 | } else {
51 | _log.error(msg[1]);
52 | }
53 | };
54 |
55 | if (!config) {
56 | _log.error(msg[0]);
57 | throw msg[0];
58 | }
59 |
60 | path = (config.path || ".");
61 | emitter = config.emitter;
62 |
63 | if (path) {
64 | path = _path.join(path, "catproject.json");
65 |
66 | // Load the project according to the given configuration
67 | _loadProject((callback || baseCallback));
68 | }
69 | return _project;
70 | };
71 |
72 | module.exports = function () {
73 |
74 | var _me;
75 |
76 | _me = {
77 | load: _loader,
78 |
79 | getProject: function() {
80 | return _project;
81 | },
82 |
83 | getInfo: function(key) {
84 | return _project.getInfo(key);
85 | },
86 |
87 | /**
88 | *
89 | * @param config
90 | * path {String} The path to load the project
91 | * data {String} The data to be updated
92 | */
93 | update: function(config) {
94 |
95 | var callback = function(data) {
96 | if (_project) {
97 | _project.update({data:data});
98 | }
99 | }, data, path;
100 |
101 | if (config) {
102 | data = ("data" in config && config.data ? config.data : undefined);
103 | path = ("path" in config && config.path ? config.path : undefined);
104 | }
105 |
106 | if (data) {
107 | callback(data);
108 | } else {
109 | if (callback && path) {
110 | _me.load({
111 | callback: callback,
112 | path: path
113 | });
114 | }
115 | }
116 |
117 | }
118 | };
119 |
120 | return _me;
121 | }();
--------------------------------------------------------------------------------
/src/module/project/init/projects/base/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "cat-test",
3 | "description": "Cat test project",
4 | "version": "0.1.0",
5 | "author": {
6 | "name": "arik",
7 | "email": "lewin.arik@gmail.com"
8 | },
9 | "main": "Gruntfile.js",
10 | "engines": {
11 | "node": ">= 0.8.0"
12 | },
13 | "dependencies": {
14 | "grunt": "~0.4.1",
15 | "hooker": "~0.2.3"
16 | },
17 | "peerDependencies": {}
18 | }
19 |
--------------------------------------------------------------------------------
/src/module/project/init/projects/base/phantom/phantomjs-script.js:
--------------------------------------------------------------------------------
1 | var _system = require('system'),
2 | _page = require('webpage').create(),
3 | _url = _system.args[1];
4 |
5 | _page.open( _url, function (status) {
6 |
7 | var hasPhantomjs;
8 | console.log("[phantom] opening url: ", _url );
9 |
10 | if (status !== 'success') {
11 | console.log('FAIL to load the address, status:', status);
12 |
13 | } else {
14 | _page.evaluate(function () {
15 | hasPhantomjs = true;
16 | });
17 |
18 | setTimeout(function () {
19 | console.log("render...");
20 | _page.render('app-view.png');
21 | phantom.exit();
22 | }, 2000);
23 |
24 | }
25 |
26 |
27 | });
--------------------------------------------------------------------------------
/src/module/project/init/projects/base/plugins/custom-plugin.js:
--------------------------------------------------------------------------------
1 | var _Scrap = catrequire("cat.common.scrap"),
2 | _utils = catrequire("cat.utils");
3 |
4 | module.exports = function () {
5 |
6 | return {
7 |
8 | init: function () {
9 |
10 |
11 | // init scrap plugin code in here
12 |
13 |
14 | /**
15 | * Sample for custom annotation
16 | *
17 | * properties:
18 | * name - sample
19 | * single - false
20 | * singleton - 1[default -1]
21 | * $type - js
22 | */
23 | _Scrap.add({name: "sample",
24 | single: false,
25 | singleton: 1,
26 | func: function (config) {
27 | var sample,
28 | me = this;
29 |
30 | sample = this.get("sample");
31 | me.print("console.log('CAT... Custom annotation sample sample:', '" + sample + "'); _catjs.manager.resolve();");
32 | }});
33 |
34 | },
35 |
36 | apply: function () {
37 | // apply scrap plugin code in here
38 |
39 | },
40 |
41 | getType: function () {
42 | return "custom-plugin";
43 | }
44 | };
45 |
46 | };
--------------------------------------------------------------------------------
/src/module/project/init/projects/cat/catproject.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "{{name}}",
3 |
4 | "source": "src/",
5 | "target": "target/",
6 | "cattarget": "{{cattarget}}",
7 | "jshint": {
8 | "opt": {
9 | "evil": true,
10 | "strict": false,
11 | "curly": true,
12 | "eqeqeq": true,
13 | "immed": false,
14 | "latedef": true,
15 | "newcap": false,
16 | "noarg": true,
17 | "sub": true,
18 | "undef": true,
19 | "boss": true,
20 | "eqnull": true,
21 | "node": true,
22 | "es5": false
23 | },
24 | "globals": {
25 |
26 | }
27 | },
28 |
29 | "analytics" : "{{analytics}}",
30 | "apppath": "{{appath}}",
31 | "server": {
32 | "host": "{{server.host}}",
33 | "port": "{{server.port}}",
34 | "protocol": "{{server.protocol}}",
35 | "services": {
36 | "static-pages": true
37 | }
38 | },
39 |
40 | "plugins": [
41 |
42 | ],
43 |
44 | "tasks": [
45 |
46 | ]
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/module/project/init/projects/example/app/app.css:
--------------------------------------------------------------------------------
1 | HTML, BODY {
2 | color: #444444;
3 | font-family: Tahoma;
4 | margin: 0px;
5 | padding: 4px;
6 | }
7 |
8 | #description {
9 | font-size: 12px;
10 | font-weight: bold;
11 | padding: 6px 0px 0px 6px;
12 | }
13 |
14 | #description, #testbtn {
15 | margin: 4px;
16 | float:left;
17 | }
--------------------------------------------------------------------------------
/src/module/project/init/projects/example/app/app.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | /**
4 | * When the document is ready assign a listener to the test button
5 | */
6 | $( document ).ready(function() {
7 | var testButton = $("#testbtn"),
8 | description = $("#description"),
9 | counter = 0;
10 |
11 | /*
12 | This is a simple scrap that test the button's click event functionality
13 | You can repeat the scrap on cat-project/src/config/cat.json
14 | @[scrap
15 | @@name testButtonClick
16 | @@context testButton
17 | @@assert ok(testButton[0], "No valid test element button")
18 | @@code testButton.click()
19 | @@code testButton.click()
20 | @@code testButton.click()
21 | ]@
22 | */
23 |
24 | if (testButton) {
25 | testButton.on("click", function () {
26 | description = $("#description");
27 | if (description) {
28 | counter++;
29 | description.html("Clicks +" + counter);
30 | }
31 |
32 | /*
33 | This is a simple scrap testing the test button click functionality
34 |
35 | @[scrap
36 | @@name testButtonListener
37 | @@standalone true
38 | @@context[
39 | counter
40 | description
41 | ]
42 | @@log "Description: ", description.text().trim()
43 | @@assert ok((counter < 3), "More then 2 clicks is too much...")
44 | ]@
45 | */
46 | });
47 | }
48 |
49 | });
50 |
--------------------------------------------------------------------------------
/src/module/project/init/projects/example/app/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CAT Example
4 |
5 |
6 |
7 |
8 |
9 |
16 |
17 |
18 |
19 |
20 |
21 | CAT Example Application
22 |
23 | CAT Example Application
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/module/project/init/projects/example/catproject.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "{{name}}",
3 |
4 | "source": "src/",
5 | "target": "target/",
6 | "cattarget": "{{cattarget}}",
7 |
8 | "analytics": "{{analytics}}",
9 | "apppath": "{{appath}}",
10 |
11 | "server": {
12 | "host": "{{server.host}}",
13 | "port": "{{server.port}}",
14 | "protocol": "{{server.protocol}}",
15 | "services": {
16 | "static-pages": true
17 | }
18 | },
19 |
20 | "runner": {
21 | "run": {
22 | "devices": [
23 | {
24 | "type": "localpc",
25 | "runner": {
26 | "name": "chrome",
27 | "address": "/index.html"
28 | }
29 | },
30 | {
31 | "type": "localpc",
32 | "disable": true,
33 | "runner": {
34 | "name": "firefox",
35 | "address": "/index.html"
36 | }
37 | },
38 | {
39 | "type": "android",
40 | "disable": true,
41 | "id": "all",
42 | "runner": {
43 | "name": "apk"
44 | }
45 | }
46 |
47 | ]
48 | }
49 | },
50 |
51 | "plugins": [
52 |
53 | ],
54 |
55 | "tasks": [
56 |
57 | ]
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/module/project/init/projects/server/catproject.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "{{server.name}}",
3 |
4 | "server": {
5 | "host": "{{server.host}}",
6 | "port": "{{server.port}}",
7 | "protocol": "{{server.protocol}}",
8 | "services": {
9 | "static-pages": false
10 | }
11 | },
12 |
13 | "plugins": [
14 |
15 | ],
16 |
17 | "tasks": [
18 |
19 | ]
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/module/project/src/common/README.txt:
--------------------------------------------------------------------------------
1 | In this folder any JavaScript files will be included for CAT's node and/or application logic layer.
--------------------------------------------------------------------------------
/src/module/project/src/config/testdata.json:
--------------------------------------------------------------------------------
1 | {
2 | "_comment": "This is a test data JSON file, put in here any test data you wish to integrate with your tests (see the docs for more information)"
3 | }
--------------------------------------------------------------------------------
/src/module/testunit/TestManager.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/catjsteam/catjs/512435fbfa5cf32689de55d5c588ade52e5274fd/src/module/testunit/TestManager.js
--------------------------------------------------------------------------------
/src/module/utils/Code.js:
--------------------------------------------------------------------------------
1 | var _underscore = require("underscore");
2 |
3 | module.exports = function() {
4 |
5 | return {
6 |
7 | /**
8 | * Prepare code based on line break.
9 | * Looking for character ";" at the end if not exists it will be added
10 | * and each line will be trimmed.
11 | *
12 | * @param codeRows
13 | */
14 | prepareCode: function (codeRows) {
15 |
16 | var row,
17 | size = (codeRows && _underscore.isArray(codeRows) ? codeRows.length : 0),
18 | idx = 0;
19 |
20 | function _row(row, ref, idx) {
21 | var rowTrimmed;
22 |
23 | if (row) {
24 | rowTrimmed = (row.trim ? row.trim() : row);
25 | if (rowTrimmed.charAt(rowTrimmed.length - 1) !== ";") {
26 | if (idx !== undefined) {
27 | ref[idx] += ";";
28 | } else {
29 | ref += ";"
30 | }
31 | }
32 |
33 | if (idx !== undefined) {
34 | ref[idx] = convertTestDataRegExp(ref[idx]);
35 | } else {
36 | ref = convertTestDataRegExp(ref);
37 | }
38 |
39 | }
40 | return ref;
41 | }
42 |
43 | function convertTestDataRegExp(codeRows) {
44 | var patt = new RegExp("(.*)@d\\.(.*)(.*\\))", "g");
45 |
46 |
47 | while (codeRows.match(patt)) {
48 | codeRows = codeRows.replace(patt, "$1_cat.utils.TestsDB.$2$3");
49 | }
50 | return codeRows;
51 | }
52 |
53 | if (size) {
54 | for (; idx < size; idx++) {
55 | row = codeRows[idx];
56 | row = (row.trim ? row.trim() : row);
57 | codeRows = _row(row, codeRows, idx);
58 | }
59 | } else {
60 | codeRows = (codeRows.trim ? codeRows.trim() : codeRows);
61 | codeRows = _row(codeRows, codeRows);
62 | }
63 | return codeRows;
64 | },
65 |
66 | /**
67 | * Remove double quotes from a given code snippet
68 | *
69 | * @param code {String} code representation
70 | * @returns {*}
71 | */
72 | cleanDoubleQuotes: function(code) {
73 |
74 | if (!code || !code.split) {
75 | return code;
76 | }
77 |
78 | return code.split("\"").join("");
79 |
80 | }
81 | };
82 |
83 | }();
--------------------------------------------------------------------------------
/src/module/utils/ExtUtils.js:
--------------------------------------------------------------------------------
1 | var _fs = require("fs.extra"),
2 | _global = catrequire("cat.global"),
3 | _log = _global.log(),
4 | _props = catrequire("cat.props"),
5 | _path = require("path");
6 |
7 |
8 | module.exports = function () {
9 |
10 | return {
11 |
12 | /**
13 | * Get the info for CAT internal generated source file name
14 | *
15 | * @param config The passed configuration
16 | * scrap - The scrap object
17 | * file - The file path [optional]
18 | * basepath - The base path to be cut off the file path
19 | *
20 | * @return {*} The pkgname and the target file name to be saved
21 | */
22 | getCATInfo: function (config) {
23 |
24 | if (!config) {
25 | return undefined;
26 | }
27 |
28 | var file = config.file,
29 | scrap = config.scrap,
30 | basepath = config.basepath,
31 | fileName = _path.basename(file, ".js"),
32 | path,
33 | pkgName,
34 | newFile,
35 | newHeaderFile;
36 |
37 | function _getFile(prefix) {
38 | return _path.join(_path.dirname(file), fileName.replace(fileName, [prefix, fileName].join("_")));
39 | }
40 |
41 | if (!file) {
42 | _log.warning("[CAT extutils] No valid file was found, scrap info:" + (scrap || ""));
43 | return undefined;
44 | }
45 |
46 | path = _path.dirname(file);
47 | if (basepath) {
48 | path = path.replace(basepath, "");
49 | }
50 | if (path.indexOf("/") === 0) {
51 | path = path.substring(1);
52 | }
53 |
54 | newFile = _getFile("_cat");
55 | newHeaderFile = _getFile("_cat_header");
56 | pkgName = (scrap ? [path.split("/").join("."), fileName, scrap.get("name")].join(".") : undefined);
57 |
58 | return {
59 | pkgName: pkgName,
60 | file: newFile,
61 | includeFile: newHeaderFile
62 | };
63 |
64 | },
65 |
66 | /**
67 | * Get the info for CAT User generated source file name
68 | *
69 | * @param config The passed configuration
70 | * scrap - The scrap object
71 | * file - The file path [optional]
72 | * basepath - The base path to be cut off the file path
73 | *
74 | * @return {*} The pkgname and the target file name to be saved
75 | */
76 | getUserInfo: function (config) {
77 |
78 | if (!config) {
79 | return undefined;
80 | }
81 | var file = config.file,
82 | scrap = config.scrap,
83 | basepath = config.basepath,
84 | fileName = _path.basename(file, ".js"),
85 | path,
86 | pkgName;
87 |
88 | path = _path.dirname(file);
89 | if (basepath) {
90 | path = path.replace(basepath, "");
91 | }
92 | if (path.indexOf("/") === 0) {
93 | path = path.substring(1);
94 | }
95 | pkgName = (scrap ? [path.split("/").join("."), fileName, scrap.get("name")].join(".") : undefined);
96 |
97 | return {
98 | pkgName: pkgName,
99 | file: (file ? file : undefined)
100 | };
101 |
102 | }
103 |
104 | };
105 |
106 | }();
--------------------------------------------------------------------------------
/src/module/utils/RegExp.js:
--------------------------------------------------------------------------------
1 | var _typedas = require("typedas"),
2 | _global = catrequire("cat.global"),
3 | _log = _global.log(),
4 | _props = catrequire("cat.props");
5 |
6 | module.exports = function () {
7 |
8 |
9 | return {
10 |
11 | preparePattern: function (pattern) {
12 | if (pattern) {
13 | pattern = pattern.split("[").join("\\[");
14 | }
15 |
16 | return pattern;
17 | },
18 |
19 | getMatchedValue: function (str, pattern, flags) {
20 |
21 | var value = this.getMatch(str, pattern, flags);
22 | if (value) {
23 | value = value[1];
24 | value = value.trim();
25 | }
26 |
27 | if (!value) {
28 | value = undefined;
29 | }
30 |
31 | return value;
32 | },
33 |
34 | getMatch: function (str, pattern, flags) {
35 |
36 | if (!pattern || !str) {
37 | return undefined;
38 | }
39 | var regexp = new RegExp(pattern, (flags || "")),
40 | value;
41 |
42 | if (str) {
43 | value = str.match(regexp);
44 | }
45 |
46 | return value;
47 | },
48 |
49 | replace: function(str, find, replace, flags) {
50 | var reg = new RegExp(find, flags);
51 | if (reg) {
52 | return str.replace(reg, replace);
53 | }
54 |
55 | return str;
56 | }
57 |
58 | };
59 |
60 | }();
--------------------------------------------------------------------------------
/src/module/utils/SysUtils.js:
--------------------------------------------------------------------------------
1 | var _fs = require("fs.extra"),
2 | _path = require("path");
3 |
4 | /**
5 | * CatJS System Utilities
6 | *
7 | * @type {module.exports}
8 | */
9 | module.exports = function () {
10 |
11 | var _module = {
12 |
13 | getFoldersCount: function(path) {
14 |
15 | var counter= 0,
16 | folders = ( (path && path.split) ? path.split(_path.sep) : undefined);
17 |
18 | if (folders) {
19 | folders.forEach(function(item) {
20 | if (item) {
21 | counter++;
22 | }
23 | })
24 |
25 | }
26 |
27 | return counter;
28 | },
29 |
30 | /**
31 | * Grant permission to a path with folder offset
32 | * e.g. /home/myhome/test offet:2 will apply chmod only for myhome/test folders
33 | *
34 | * @param path {String} The path
35 | * @param mode {Number} The mode e.g. 0777
36 | * @param offset {Number} The offset of the folders to grant permission. From the end of the path
37 | */
38 | chmodSyncOffset: function (path, mode, offset) {
39 | var folders = ((path && path.split) ? path.split(_path.sep) : undefined), patharr,
40 | i = 0, size = offset + 1;
41 |
42 | if (folders) {
43 | for (; i < size; i++) {
44 | patharr = folders.slice(0, (folders.length - i));
45 | path = patharr.join(_path.sep);
46 |
47 | try {
48 | _fs.chmodSync(path, mode);
49 | } catch(e) {
50 | console.warn("[catjs utils chmodSyncOffset] failed to grant permissions: ", e);
51 | }
52 | }
53 | } else {
54 | console.warn("[catjs utils chmodSyncOffset] failed to grant permissions: path is not valid '", path, "'");
55 | }
56 | },
57 |
58 | getCatProjectPath: function() {
59 | var global = catrequire("cat.global"),
60 | workpath = global.get("home").working.path;
61 | return workpath;
62 | },
63 |
64 | /**
65 | * Create the basic skeleton system folders (e.g. logs, cache .. etc)
66 | *
67 | * @param folder
68 | * @param verify {Boolean} Make sure that the path includes "cat-project"
69 | * @returns {*}
70 | */
71 | createSystemFolder: function (folder, verify) {
72 |
73 |
74 | var catprojectpath = _module.getCatProjectPath(),
75 | targetfolder = _path.join(catprojectpath, folder),
76 | pathitems;
77 |
78 | if (verify === undefined) {
79 | verify = false;
80 | }
81 | if (verify) {
82 | pathitems = catprojectpath.split(_path.sep);
83 | if ( !(catprojectpath && pathitems && pathitems[pathitems.length-1] === "cat-project") ) {
84 | return undefined;
85 | }
86 | }
87 |
88 | // create log folder
89 | if (!_fs.existsSync(targetfolder)) {
90 | _fs.mkdirSync(targetfolder, 0777);
91 | _fs.chmodSync(targetfolder, 0777);
92 | }
93 |
94 | return targetfolder;
95 | }
96 | };
97 |
98 | return _module;
99 |
100 | }();
--------------------------------------------------------------------------------
/src/module/utils/TemplateUtils.js:
--------------------------------------------------------------------------------
1 | var _ = require("underscore"),
2 | _fs = require("fs.extra"),
3 | _global = catrequire("cat.global"),
4 | _log = _global.log(),
5 | _props = catrequire("cat.props"),
6 | _path = require("path");
7 |
8 | // underscore settings for like mustache parametrization style {{foo}}
9 | _.templateSettings = {
10 | interpolate : /\{\{(.+?)\}\}/g
11 | };
12 |
13 | module.exports = function () {
14 |
15 | var _cache = {};
16 |
17 | return {
18 |
19 | underscore: _,
20 |
21 | /**
22 | * Load template file content of tpl type
23 | * Note: No need for the extension on the file name
24 | *
25 | * @param name The name of the template e.g. /scraps/test
26 | * @param path The full path where the templates exists (optional) e.g. /home/../test
27 | * @returns {*}
28 | */
29 | readTemplateFile: function (name, path) {
30 | var content,
31 | file = (path ? [path,name].join(".") : [cathome, ,"/src/template/", name].join("/"));
32 |
33 | file = _path.normalize(file);
34 |
35 | try {
36 | file = [file, "tpl"].join(".");
37 | content = _cache[file];
38 | if (!content) {
39 | content = _fs.readFileSync(file, "utf8");
40 | }
41 |
42 | // cache the file content
43 | _cache[file] = content;
44 |
45 | } catch (e) {
46 | _log.warning(_props.get("cat.file.failed").format("[inject ext]", file, e));
47 | }
48 |
49 | return content;
50 | },
51 |
52 | /**
53 | * Load and compile template with underscore
54 | *
55 | * @param config The params:
56 | * name The name of the template e.g. /scraps/test (optional in case content exists)
57 | * path The full path where the templates exists (optional) e.g. /home/../test.tpl
58 | * content The string content instead of the file content (optional in case name exists & overrides the file content)
59 | * data The data object properties (see underscore template)
60 | */
61 | template: function(config){
62 | if (!config) {
63 | return undefined;
64 | }
65 | var name = config.name,
66 | path = config.path,
67 | data = config.data,
68 | content = config.content,
69 | funcTpl = (content || this.readTemplateFile(name, path)),
70 | template = _.template(funcTpl);
71 |
72 | if (template) {
73 | return template(data);
74 | }
75 | }
76 | };
77 |
78 | }();
--------------------------------------------------------------------------------
/src/module/utils/Uglify.js:
--------------------------------------------------------------------------------
1 | var _uglify= require("uglify-js"),
2 | _global = catrequire("cat.global"),
3 | _log = _global.log(),
4 | _props = catrequire("cat.props"),
5 | _utils = catrequire("cat.utils");
6 |
7 | module.exports = function() {
8 |
9 | function _code(config) {
10 |
11 | if (!config) {
12 | _log.warning(_props.get("cat.arguments.missing").format("[uglify utils]", "config"));
13 | return undefined;
14 | }
15 |
16 | var code = config.code,
17 | streamoptDefault = {
18 | semicolons: false
19 | },
20 | streamoptArg = config.streamopt,
21 | streamopt,
22 | stream,
23 | ast;
24 |
25 | if (code) {
26 | ast = _uglify.parse(code);
27 |
28 | if (streamopt) {
29 | streamopt = _utils.copyObjProps(streamoptDefault, streamoptArg, false);
30 | } else {
31 | streamopt = streamoptDefault;
32 | }
33 |
34 | stream = _uglify.OutputStream(streamopt);
35 | ast.print(stream);
36 | code = stream.toString();
37 |
38 | } else {
39 | _log.warning(_props.get("cat.arguments.missing").format("[uglify utils]", "config.code"));
40 | }
41 |
42 | return {code: code, ast:ast};
43 | }
44 |
45 | return {
46 |
47 | /**
48 | * Get one line code snippet w/o semicolon by default,
49 | * use the stream options to change it.
50 | *
51 | * @param config
52 | * code: The code snippet
53 | * streamopt: The uglifyjs stream options
54 | *
55 | * @return {string} The code snippet representation
56 | */
57 | getCodeSnippet: function(config) {
58 |
59 | var baseCode = _code(config);
60 | return (baseCode ? baseCode.code : undefined);
61 | },
62 |
63 | /**
64 | * Get the actual javascript object that was interpreted out of the code snippet
65 | *
66 | * @param config
67 | * code: The code snippet
68 | * streamopt: The uglifyjs stream options
69 | *
70 | * @returns {*} The object interpreted out of the code snippet
71 | */
72 | getActualSnippet: function(config) {
73 |
74 | var code = _code(config),
75 | interpretedCode;
76 | if (code && code.code) {
77 | interpretedCode = JSON.parse(code.code);
78 | }
79 |
80 | return interpretedCode;
81 | },
82 |
83 | /**
84 | * TODO better job on the walk to get a function and expression call
85 | *
86 | * @param config
87 | */
88 | walk: function(config) {
89 | var call_expression = null, walker = new _uglify.TreeWalker(function(node, descend){
90 | if (node instanceof _uglify.AST_Call) {
91 | var tmp = call_expression;
92 | call_expression = node;
93 | descend();
94 | call_expression = tmp;
95 | return true; // prevent descending again
96 | }
97 | if (node instanceof _uglify.AST_String && call_expression) {
98 | console.log("Found string: %s at %d,%d", node.getValue(),
99 | node.start.line, node.start.col);
100 | }
101 | }), baseCode = _code(config);
102 |
103 | if (baseCode.ast) {
104 | baseCode.ast.walk(walker);
105 | }
106 | }
107 |
108 | };
109 |
110 | }();
--------------------------------------------------------------------------------
/src/module/utils/entity/BaseEntity.js:
--------------------------------------------------------------------------------
1 | var _utils = catrequire("cat.utils");
2 |
3 | module.exports = function(config) {
4 |
5 | var me = this,
6 | key;
7 |
8 | if (!config) {
9 | throw new Error('[catjs Row class] config argument is not valid ');
10 | }
11 | _utils.prepareProps({
12 | global: {obj: config},
13 | props: [
14 | {key: "name", require: true},
15 | {key: "scrapname", require: true},
16 | {key: "data", require: true}
17 | ]
18 | });
19 |
20 | if (config) {
21 | for (key in config) {
22 | if (config.hasOwnProperty(key)) {
23 | me[key] = config[key];
24 | }
25 | }
26 | }
27 | };
--------------------------------------------------------------------------------
/src/module/utils/entity/Entity.js:
--------------------------------------------------------------------------------
1 | var _catglobal = catrequire("cat.global"),
2 | _log = _catglobal.log();
3 |
4 | module.exports = function() {
5 |
6 | var _globalsmap = {};
7 |
8 | return {
9 |
10 | /**
11 | *
12 | * @param config
13 | * entity {function} The entity reference function
14 | * name {String} Unique global map key;
15 | */
16 | entity: function(config) {
17 | var key = config.name,
18 | entity = config.fn,
19 | printer = config.printer;
20 |
21 | if (_globalsmap[key]) {
22 | _log.warn("[catjs Scrap] Override an existing global functionality: ", key);
23 | }
24 | _globalsmap[key] = new entity({printer: printer});
25 |
26 | return _globalsmap[key];
27 | },
28 |
29 | getEntity: function(key) {
30 | return _globalsmap[key];
31 | }
32 |
33 | };
34 |
35 | }();
--------------------------------------------------------------------------------
/src/module/utils/entity/jasmine/Row.js:
--------------------------------------------------------------------------------
1 | var _BaseEntity = require("./../BaseEntity.js");
2 |
3 |
4 | function Row(config) {
5 |
6 | var me = this,
7 | key;
8 |
9 | _BaseEntity.call(this, config);
10 | }
11 |
12 | module.exports = Row;
--------------------------------------------------------------------------------
/src/module/utils/fs/Config.js:
--------------------------------------------------------------------------------
1 | var _fs = require('fs'),
2 | _log = catrequire("cat.global").log(),
3 | _utils = catrequire("cat.utils"),
4 | _props = catrequire("cat.props"),
5 | _jsonlint = require("json-lint");
6 |
7 |
8 |
9 | /**
10 | * Configuration Module
11 | * Loading JSON configuration
12 | *
13 | * e.g. new require('Config.js')
14 | *
15 | * @type {module.exports}
16 | */
17 | module.exports = function () {
18 |
19 | /**
20 | * Configuration functionality
21 | *
22 | * @param file The JSON file to be loaded
23 | * @param callback The function to be called when the loading completed
24 | * Call back parameters: this Assigned to the module
25 | * json The JSON stream data
26 | */
27 | return function (file, callback) {
28 |
29 | var get = function (file, callback) {
30 | var me = this,
31 | json, jsonlint;
32 |
33 | try {
34 | json = _fs.readFileSync(file, "utf8");
35 | if (callback) {
36 |
37 | jsonlint = _jsonlint( json, {} );
38 | if ( jsonlint.error ) {
39 | _utils.error(["CAT project loader] catproject.json load with errors: \n ", jsonlint.error,
40 | " \n at line: ", jsonlint.line,
41 | " \n character: ", jsonlint.character,
42 | " \n "].join(""));
43 | }
44 |
45 | json = JSON.parse(json);
46 | callback.call(me, json);
47 | }
48 |
49 | } catch(e) {
50 | _utils.error(_props.get("cat.error.config.loader").format("[Config Project Loader]", e));
51 | throw e;
52 | }
53 | };
54 |
55 | return get(file, callback);
56 | };
57 |
58 | }();
--------------------------------------------------------------------------------
/src/module/utils/fs/JSON.js:
--------------------------------------------------------------------------------
1 | var _fs = require("fs"),
2 | _path = require("path"),
3 | _beautify = require('js-beautify').js_beautify,
4 | _global = catrequire("cat.global"),
5 | _log = _global.log(),
6 | _utils = catrequire("cat.utils"),
7 | _props = catrequire("cat.props");
8 |
9 | module.exports = function () {
10 |
11 | return {
12 |
13 | /**
14 | *
15 | * @param config {Object}
16 | * filename {String} The file name
17 | * content {String} The file content
18 | * opt Object
19 | * encoding String | Null default = 'utf8'
20 | * mode Number default = 438 (aka 0666 in Octal)
21 | * flag String default = 'w'
22 | *
23 | */
24 | write: function (config) {
25 |
26 | var content, filename, opt, extname;
27 |
28 | if (!config) {
29 | return undefined;
30 | }
31 |
32 | content = _utils.getProp({key: "content", obj: config});
33 | filename = _utils.getProp({key: "filename", obj: config});
34 | opt = _utils.getProp({key: "opt", obj: config});
35 | extname = _path.extname(filename);
36 | if (extname === ".json") {
37 | content = _beautify(content, { indent_size: 2 });
38 | }
39 |
40 | try {
41 | _fs.writeFileSync(filename, content, opt);
42 |
43 | } catch(e) {
44 | _utils.error(_props.get("cat.error").format("[cat mdata]", e));
45 | }
46 |
47 | },
48 |
49 | /**
50 | *
51 | * @param config {Object}
52 | * filename {String} The file name
53 | *
54 | */
55 | read: function (config) {
56 |
57 | var content, filename;
58 |
59 | if (!config) {
60 | return undefined;
61 | }
62 |
63 | filename = _utils.getProp({key: "filename", obj: config});
64 |
65 | try {
66 | if (_fs.existsSync(filename)) {
67 | content = _fs.readFileSync(filename, "utf8");
68 |
69 | }
70 | } catch (e) {
71 | _utils.error(_props.get("cat.error").format("[cat mdata]", e));
72 | }
73 |
74 | return content;
75 | },
76 |
77 | readAsync: function (config) {
78 |
79 | var callback, filename;
80 |
81 | if (!config) {
82 | return undefined;
83 | }
84 |
85 | callback = _utils.getProp({key: "callback", obj: config});
86 | filename = _utils.getProp({key: "filename", obj: config});
87 |
88 | if (_fs.existsSync(filename)) {
89 | _fs.readFile(filename, function(err, data) {
90 | if (err) {
91 | _utils.error(_props.get("cat.error").format("[cat mdata]", err));
92 | } else {
93 | _log.debug(_props.get("cat.mdata.read").format("[cat mdata]"));
94 | }
95 | callback.call({data: data});
96 | });
97 |
98 | } else {
99 | _log.warning(_props.get("cat.mdata.file.not.exists").format("[cat mdata]"));
100 | callback.call({data: null});
101 | }
102 |
103 | }
104 | };
105 |
106 | }();
--------------------------------------------------------------------------------
/src/plugins/Behavior.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 |
3 | cat: {
4 |
5 | comment: function (lines, mark) {
6 |
7 | var newlines = [], counter = 0;
8 |
9 | function _getValue(obj, key) {
10 | if (key in obj && obj[key]) {
11 | return obj[key];
12 | }
13 | return;
14 | }
15 |
16 | if (lines) {
17 |
18 | if (mark) {
19 |
20 | lines.forEach(function (line) {
21 |
22 | if (counter === 0) {
23 | newlines[counter] = _getValue(mark, "prefix") + lines[counter];
24 |
25 | }
26 |
27 | if (counter === lines.length - 1) {
28 | newlines[counter] = lines[counter] + _getValue(mark, "suffix");
29 |
30 | }
31 |
32 | if (counter > 0 && counter < lines.length - 1) {
33 | newlines[counter] = lines[counter];
34 | }
35 |
36 | newlines[counter] += "\n";
37 | counter++;
38 | });
39 |
40 | } else {
41 | newlines = newlines.concat(lines);
42 |
43 | }
44 | }
45 |
46 | return newlines;
47 | }
48 | }
49 | };
50 |
--------------------------------------------------------------------------------
/src/plugins/scrap-angular.js:
--------------------------------------------------------------------------------
1 | var _Scrap = catrequire("cat.common.scrap"),
2 | _codeutils = catrequire("cat.code.utils"),
3 | _scraputils = require("./utils/Utils"),
4 | _delayManagerUtils = require("./utils/DelayManagerUtils");
5 |
6 | var tipNum = 1;
7 | module.exports = function () {
8 |
9 | return {
10 |
11 | init: function (config) {
12 |
13 | /**
14 | * Annotation for jquery library
15 | *
16 | * properties:
17 | * name - jquery
18 | * single - false
19 | * singleton - 1[default -1]
20 | * $type - js
21 | */
22 | _Scrap.add({name: "angular",
23 | single: false,
24 |
25 | func: function (config) {
26 |
27 | var angularRows,
28 | me = this,
29 | tempCommand,
30 |
31 | generate = function (angularRow) {
32 |
33 | var angularItem, api, match;
34 |
35 | angularRow = _codeutils.prepareCode(angularRow);
36 |
37 | if (angularRow && angularRow.join) {
38 | angularItem = angularRow.join("\n");
39 |
40 | } else {
41 | angularItem = angularRow;
42 | }
43 |
44 | if (angularItem) {
45 |
46 | api = [
47 | {
48 | api: "trigger"
49 | },
50 | {
51 | api: "setText"
52 | },
53 | {
54 | api: "require"
55 | }
56 | ];
57 |
58 | match = _scraputils.match(angularItem, api);
59 | if (match) {
60 |
61 | tempCommand = [
62 | '_cat.core.plugin("angular").actions.',
63 | match
64 | ];
65 |
66 | return tempCommand.join("");
67 | }
68 |
69 | }
70 |
71 | return undefined;
72 | },
73 | scrapConf = me.config,
74 | scrap = scrapConf,
75 | dm;
76 |
77 | angularRows = this.get("angular");
78 |
79 | dm = new _delayManagerUtils({
80 | scrap: me
81 | });
82 |
83 | if (angularRows) {
84 |
85 | dm.add({
86 | rows:angularRows,
87 | args: [
88 | "scrapName: 'angular'"
89 | ],
90 | type: "angular"
91 |
92 | }, function(row) {
93 | return generate(row);
94 | });
95 | }
96 |
97 | dm.dispose();
98 |
99 | }
100 |
101 | });
102 |
103 | config.emitter.emit("job.done", {status: "done"});
104 |
105 | },
106 |
107 | apply: function () {
108 |
109 | },
110 |
111 | getType: function () {
112 | return "scrap-angular";
113 | }
114 | };
115 |
116 | };
--------------------------------------------------------------------------------
/src/plugins/scrap-deviceinfo.js:
--------------------------------------------------------------------------------
1 | var _Scrap = catrequire("cat.common.scrap"),
2 | _codeutils = catrequire("cat.code.utils"),
3 | _scraputils = require("./utils/Utils"),
4 | _delayManagerUtils = require("./utils/DelayManagerUtils");
5 |
6 | var tipNum = 1;
7 | module.exports = function () {
8 |
9 | return {
10 |
11 | init: function (config) {
12 |
13 | /**
14 | * Annotation for deviceinfo library
15 | *
16 | * properties:
17 | * name - deviceinfo
18 | * single - false
19 | * singleton - 1[default -1]
20 | * $type - js
21 | */
22 | _Scrap.add({name: "deviceinfo",
23 | single: false,
24 |
25 | func: function (config) {
26 |
27 | var deviceinfoRows,
28 | me = this,
29 |
30 |
31 | generate = function (deviceinfoRow) {
32 |
33 | var deviceinfo,
34 | tempCommand,
35 | api, match;
36 |
37 | deviceinfoRow = _codeutils.prepareCode(deviceinfoRow);
38 |
39 | if (deviceinfoRow && deviceinfoRow.join) {
40 | deviceinfo = deviceinfoRow.join("\n");
41 | } else {
42 | deviceinfo = deviceinfoRow;
43 | }
44 |
45 | if (deviceinfo) {
46 |
47 | api = [
48 | {
49 | api: "deviceinfo",
50 | apiname: "deviceinfo"
51 | }
52 | ];
53 |
54 | match = _scraputils.match(deviceinfo, api);
55 | if (match) {
56 |
57 | tempCommand = [
58 | '_cat.core.plugin("deviceinfo").actions.',
59 | match
60 | ];
61 |
62 | return tempCommand.join("");
63 | }
64 | }
65 |
66 | return undefined;
67 | },
68 |
69 |
70 | scrapConf = me.config,
71 | scrap = scrapConf,
72 | dm;
73 |
74 | deviceinfoRows = this.get("deviceinfo");
75 | dm = new _delayManagerUtils({
76 | scrap: me
77 | });
78 |
79 | if (deviceinfoRows) {
80 |
81 | dm.add({
82 | rows: deviceinfoRows,
83 | args: [
84 | "scrapName: 'deviceinfo'"
85 | ],
86 | type: "deviceinfo"
87 |
88 | }, function (row) {
89 | return generate(row);
90 | });
91 | }
92 |
93 | dm.dispose();
94 | }
95 | });
96 |
97 | config.emitter.emit("job.done", {status: "done"});
98 |
99 | },
100 |
101 | apply: function () {
102 |
103 | },
104 |
105 | getType: function () {
106 | return "scrap-deviceinfo";
107 | }
108 | };
109 |
110 | };
--------------------------------------------------------------------------------
/src/plugins/scrap-dom.js:
--------------------------------------------------------------------------------
1 | var _Scrap = catrequire("cat.common.scrap"),
2 | _codeutils = catrequire("cat.code.utils"),
3 | _scraputils = require("./utils/Utils"),
4 | _delayManagerUtils = require("./utils/DelayManagerUtils");
5 |
6 | module.exports = function () {
7 |
8 | return {
9 |
10 | init: function (config) {
11 |
12 | /**
13 | * Annotation for jqm library
14 | *
15 | * properties:
16 | * name - jqm
17 | * single - false
18 | * singleton - 1[default -1]
19 | * $type - js
20 | */
21 | _Scrap.add({name: "dom",
22 | single: false,
23 |
24 | func: function (config) {
25 | var domRows,
26 | dom,
27 | me = this,
28 | dm,
29 | tempCommand,
30 | generate = function (domRow) {
31 |
32 | var dom, api, match;
33 |
34 | domRow = _codeutils.prepareCode(domRow);
35 |
36 | if (domRow && domRow.join) {
37 | dom = domRow.join("\n");
38 |
39 | } else {
40 | dom = domRow;
41 | }
42 |
43 | if (dom) {
44 |
45 | api = [
46 | {
47 | api: "listen"
48 | },
49 | {
50 | api: "fire"
51 | },
52 | {
53 | api: "select"
54 | },
55 | {
56 | api: "snapshot"
57 | }
58 | ];
59 |
60 | match = _scraputils.match(dom, api);
61 | if (match) {
62 |
63 | tempCommand = [
64 | '_cat.core.plugin("dom").actions.',
65 | match
66 | ];
67 |
68 | return tempCommand.join("");
69 | }
70 |
71 | }
72 |
73 | return undefined;
74 | };
75 |
76 | domRows = this.get("dom");
77 |
78 | dm = new _delayManagerUtils({
79 | scrap: me
80 | });
81 |
82 | if (domRows) {
83 |
84 | dm.add({
85 | rows:domRows,
86 | args: [
87 | "scrapName: 'dom'"
88 | ],
89 | type: "dom"
90 |
91 | }, function(row) {
92 | return generate(row);
93 | });
94 | }
95 |
96 | dm.dispose();
97 | }
98 | });
99 |
100 | config.emitter.emit("job.done", {status: "done"});
101 |
102 | },
103 |
104 | apply: function () {
105 |
106 | },
107 |
108 | getType: function () {
109 | return "scrap-dom";
110 | }
111 | };
112 |
113 | };
--------------------------------------------------------------------------------
/src/plugins/scrap-jasmine.js:
--------------------------------------------------------------------------------
1 | var _JasmineCollector = catrequire("cat.entity.jasmine"),
2 | _Entity = catrequire("cat.entity"),
3 | _jasmine,
4 | _Scrap = catrequire("cat.common.scrap"),
5 | _utils = catrequire("cat.utils"),
6 | _scraputils = require("./utils/Utils");
7 |
8 | module.exports = function () {
9 |
10 | return {
11 |
12 | init: function (config) {
13 |
14 | _jasmine = _Entity.entity({
15 | name: "jasmine",
16 | fn: _JasmineCollector,
17 | printer: "user"
18 | });
19 |
20 | /**
21 | * Annotation for Jasmine describe
22 | *
23 | * properties:
24 | * name - describe
25 | * single - true
26 | * singleton - 1[default -1]
27 | * $type - js
28 | */
29 | _Scrap.add({name: "describe",
30 | single: false,
31 | singleton: -1,
32 | func: function (config) {
33 |
34 | // exclude from auto test
35 | this.set("auto", false);
36 |
37 | var describeRow,
38 | me = this,
39 | scrap = me.config;
40 |
41 | describeRow = this.get("describe");
42 | if (describeRow) {
43 | me.jasminePrint({scrap: {scrap: scrap, type: "describe"}, line: describeRow});
44 | }
45 |
46 | }
47 | });
48 |
49 | /**
50 | * Annotation for Jasmine describe
51 | *
52 | * properties:
53 | * name - describe
54 | * single - true
55 | * singleton - 1[default -1]
56 | * $type - js
57 | */
58 | _Scrap.add({name: "it",
59 | single: false,
60 | singleton: -1,
61 | func: function (config) {
62 |
63 | // exclude from auto test
64 | this.set("auto", false);
65 |
66 | var itRow,
67 | me = this,
68 | scrap = me.config;
69 |
70 | itRow = this.get("it");
71 | if (itRow) {
72 |
73 | me.jasminePrint({scrap: {scrap: scrap, type: "it"}, line: itRow});
74 | }
75 |
76 | }
77 | });
78 |
79 | config.emitter.emit("job.done", {status: "done"});
80 |
81 | },
82 |
83 | apply: function () {
84 |
85 | },
86 |
87 | getType: function () {
88 | return "scrap-jasmine";
89 | }
90 | };
91 |
92 | };
--------------------------------------------------------------------------------
/src/plugins/scrap-mock.js:
--------------------------------------------------------------------------------
1 | var _Scrap = catrequire("cat.common.scrap"),
2 | _codeutils = catrequire("cat.code.utils"),
3 | _scraputils = require("./utils/Utils"),
4 | _Faker = require('Faker');
5 |
6 |
7 | module.exports = function () {
8 |
9 | return {
10 |
11 | init: function (config) {
12 |
13 | /**
14 | * Annotation for mock library
15 | *
16 | * properties:
17 | * name - mock
18 | * single - false
19 | * singleton - 1[default -1]
20 | * $type - js
21 | */
22 | _Scrap.add({name: "mock",
23 | single: false,
24 |
25 | func: function (config) {
26 | var mockRows,
27 | mock,
28 | me = this,
29 | validcode = false;
30 |
31 | mockRows = this.get("mock");
32 |
33 | if (mockRows) {
34 | mockRows = _codeutils.prepareCode(mockRows);
35 | mock = mockRows.join("\n");
36 |
37 |
38 | if (mock) {
39 |
40 | var args, mockCode = (mock).match(/equal\((.*)\);/);
41 |
42 | if (mockCode) {
43 |
44 | // split the args, parseInt the args that are numbers
45 | mockCode[1] = mockCode[1].replace(/ /g,"");
46 | args = mockCode[1].split(",");
47 |
48 | me.print("if (" + args[0] + "===" + args[1] + ") { console.log(" + args[2] + "); } else { console.log(" + args[3] + "); }");
49 |
50 | me.print("console.log(tests_db);");
51 |
52 |
53 | } else {
54 | mockCode = (mock).match(/set\((.*)\);/);
55 |
56 | if (mockCode) {
57 |
58 | mockCode[1] = mockCode[1].replace(/ /g,"");
59 | args = mockCode[1].split(",");
60 |
61 | me.print(args[0] + "=" + args[1] + ";");
62 |
63 | } else {
64 |
65 | mockCode = (mock).match(/get\((.*)\);/);
66 |
67 | if (mockCode) {
68 |
69 | mockCode[1] = mockCode[1].replace(/ /g,"");
70 | args = mockCode[1].split(",");
71 |
72 | me.print(args[1] + "=" + args[0] + ";");
73 |
74 |
75 | }
76 | }
77 | }
78 |
79 | }
80 | }
81 | }
82 | });
83 | config.emitter.emit("job.done", {status: "done"});
84 | },
85 |
86 | apply: function () {
87 |
88 | },
89 |
90 | getType: function () {
91 | return "scrap-mock";
92 | }
93 | };
94 |
95 | };
--------------------------------------------------------------------------------
/src/plugins/scrap-screenshot.js:
--------------------------------------------------------------------------------
1 | var _Scrap = catrequire("cat.common.scrap"),
2 | _utils = catrequire("cat.utils"),
3 | _scraputils = require("./utils/Utils"),
4 | _delayManagerUtils = require("./utils/DelayManagerUtils");
5 |
6 | var tipNum = 1;
7 | module.exports = function () {
8 |
9 | return {
10 |
11 | init: function (config) {
12 |
13 | /**
14 | * Annotation for screenshot library
15 | *
16 | * properties:
17 | * name - screenshot
18 | * single - false
19 | * singleton - 1[default -1]
20 | * $type - js
21 | */
22 | _Scrap.add({name: "screenshot",
23 | single: false,
24 |
25 | func: function (config) {
26 |
27 | var screenshotRows,
28 | me = this,
29 |
30 | scrapConf = me.config,
31 | scrap = scrapConf,
32 | dm;
33 |
34 | screenshotRows = this.get("screenshot");
35 | dm = new _delayManagerUtils({
36 | scrap: me
37 | });
38 |
39 | if (screenshotRows) {
40 | scrap = scrapConf;
41 |
42 | dm.add({
43 | rows:screenshotRows,
44 | args: [
45 | "scrapName: 'screenshot'"
46 | ],
47 | type: "screenshot"
48 |
49 | }, function(row) {
50 | var screenshotCommand = '_cat.core.plugin("screenshot").actions.screenshot("' + scrap.name[0] + '");';
51 | return screenshotCommand;
52 | });
53 | }
54 |
55 | dm.dispose();
56 | }
57 | });
58 |
59 | config.emitter.emit("job.done", {status: "done"});
60 |
61 | },
62 |
63 | apply: function () {
64 |
65 | },
66 |
67 | getType: function () {
68 | return "scrap-screenshot";
69 | }
70 | };
71 |
72 | };
--------------------------------------------------------------------------------
/src/plugins/utils/ExpressionUtils.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = function () {
3 |
4 |
5 | return {
6 |
7 | uicontent: function(config) {
8 | var scrap = config.scrap,
9 | rows = config.rows;
10 |
11 | return [
12 | "_cat.core.ui.setContent(",
13 | ["{style: 'color:#0080FF', header: '", (scrap.name || "'NA'"), "', desc: '", rows, "',tips: ''}"].join(""),
14 | ");"
15 | ].join("")
16 | },
17 |
18 | assert: function() {
19 |
20 | return [
21 | "_cat.utils.chai.assert(",
22 | "context",
23 | ");"
24 | ].join("");
25 |
26 |
27 | }
28 | };
29 |
30 | }();
31 |
--------------------------------------------------------------------------------
/src/template/scrap/_assert_call.tpl:
--------------------------------------------------------------------------------
1 | return _cat.utils.chai.assert({ scrap: context.scrap, code: {{code}} })
2 |
--------------------------------------------------------------------------------
/src/template/scrap/_assert_call_obsolete.tpl:
--------------------------------------------------------------------------------
1 | var assertObj = { code:{{expression}}, fail:{{fail}}, scrap:_cat.core.getVar(pkgName).scrap, args:_args };
2 |
3 | _cat.core.manager.controller.invoke({ commands: [
4 | {
5 | "command" : "_cat.utils.chai.assert(",
6 | "args" : "context",
7 | "end" : ");"
8 | }
9 | ], context: assertObj});
10 |
--------------------------------------------------------------------------------
/src/template/scrap/_cat_call.tpl:
--------------------------------------------------------------------------------
1 | if (typeof _cat !== "undefined") {_cat.core.action(this, {{param1}});}
--------------------------------------------------------------------------------
/src/template/scrap/_cat_embed_js.tpl:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/template/scrap/_func.tpl:
--------------------------------------------------------------------------------
1 | _cat.core.define("{{name}}", function({{arguments}}) {
2 |
3 | var pkgName = "{{name}}",
4 | _argsrefs = arguments,
5 | _argsnames = "{{arguments}}",
6 | _args = {},
7 | _ipkg = _cat.core.getVar(pkgName),
8 | _thisargs = this.get(pkgName),
9 | _def = (_thisargs && "def" in _thisargs ? _thisargs.def : undefined),
10 | _done = (_thisargs && "done" in _thisargs ? _thisargs.done : undefined),
11 | context,
12 | _counter=0,
13 | _catConfig = _cat.core.getConfig(),
14 | _delay = _catConfig.getTestDelay(),
15 | _supportedDelay = function(type, delay) {
16 | return _catConfig.isAnnotationDelaySupported(type, delay);
17 | };
18 |
19 | if (_args) {
20 | _argsnames = _argsnames.split(",");
21 | _argsnames.forEach(function(arg) {
22 | _args[arg] = _argsrefs[_counter];
23 | _counter++;
24 | });
25 | }
26 |
27 | context = {scrap : _ipkg.scrap, args : _args};
28 |
29 | /* test content in here */
30 | {{output}}
31 |
32 | _cat.core.manager.controller.state().wait({
33 | delay: 0,
34 | steps: 0,
35 | match: undefined,
36 | callback: function() {
37 | if (_done) {
38 | _done.call(this);
39 | }
40 | }
41 | });
42 |
43 | });
44 |
--------------------------------------------------------------------------------
/src/template/scrap/_func_declare.tpl:
--------------------------------------------------------------------------------
1 | _cat.core.declare('{{name}}',{{scrap}}, '{{type}}');
--------------------------------------------------------------------------------
/src/template/scrap/_func_manager.tpl:
--------------------------------------------------------------------------------
1 | _cat.core.setManager("{{runat}}", "{{name}}");
--------------------------------------------------------------------------------
/src/template/scrap/_func_snippet.tpl:
--------------------------------------------------------------------------------
1 |
2 | /* {{comment}} */
3 | {{code}}
--------------------------------------------------------------------------------
/src/template/scrap/_func_user.tpl:
--------------------------------------------------------------------------------
1 | _cat.core.define("{{name}}", function() {
2 |
3 | var pkgName = "{{name}}";
4 |
5 | return {
6 |
7 | /**
8 | * Init functionality for scrap {{name}}
9 | *
10 | * @param content CAT Context object
11 | */
12 | init: function(context) {
13 |
14 | }
15 | };
16 |
17 | }());
--------------------------------------------------------------------------------
/src/template/scrap/_import_css.tpl:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/template/scrap/_import_js.tpl:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/template/scrap/_require_globals_snippet.tpl:
--------------------------------------------------------------------------------
1 | if (typeof {{handle}} !== "undefined") {
2 | window["{{exports}}"] = {{handle}};
3 | }
4 |
--------------------------------------------------------------------------------
/src/template/scrap/_require_js.tpl:
--------------------------------------------------------------------------------
1 | /**
2 | * {{comment}}
3 | */
4 | require.config({{config}});
5 | require({{require}}, function({{requirerefs}}) {
6 |
7 | {{globals}}
8 |
9 | _cat.utils.Loader.requires({{cssfiles}});
10 |
11 | if (_cat) {
12 | _cat.core.init({ "catjspath": "{{catjspath}}" });
13 | }
14 |
15 | });
--------------------------------------------------------------------------------
/test/core-tests/app-example/cat-project/catproject.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "app-example-test",
3 |
4 | "source": "src/",
5 | "target": "target/",
6 | "cattarget": "./",
7 | "jshint": {
8 | "opt": {
9 | "evil": true,
10 | "strict": false,
11 | "curly": true,
12 | "eqeqeq": true,
13 | "immed": false,
14 | "latedef": true,
15 | "newcap": false,
16 | "noarg": true,
17 | "sub": true,
18 | "undef": true,
19 | "boss": true,
20 | "eqnull": true,
21 | "node": true,
22 | "es5": false
23 | },
24 | "globals": {
25 |
26 | }
27 | },
28 |
29 | "runner": {
30 | "run": {
31 | "devices": [
32 | {
33 | "disable": false,
34 | "type": "androidBrowser",
35 | "id": "all",
36 | "runner": {
37 | "name": "chrome",
38 | "address": ""
39 | }
40 | }
41 | ]
42 | },
43 | "server": {
44 | "host" : "www.google.com",
45 | "port" : "80"
46 | }
47 | },
48 |
49 | "analytics" : "N",
50 | "apppath": "./..",
51 | "server": {
52 | "host": "localhost",
53 | "port": "8089",
54 | "protocol": "http",
55 | "services": {
56 | "static-pages": true
57 | }
58 | },
59 |
60 | "plugins": [
61 |
62 | ],
63 |
64 | "tasks": [
65 |
66 | ]
67 |
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/test/core-tests/app-example/cat-project/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "cat-test",
3 | "description": "Cat test project",
4 | "version": "0.1.0",
5 | "author": {
6 | "name": "arik",
7 | "email": "lewin.arik@gmail.com"
8 | },
9 | "main": "Gruntfile.js",
10 | "engines": {
11 | "node": ">= 0.8.0"
12 | },
13 | "dependencies": {
14 | "grunt": "~0.4.1",
15 | "hooker": "~0.2.3"
16 | },
17 | "peerDependencies": {}
18 | }
19 |
--------------------------------------------------------------------------------
/test/core-tests/app-example/cat-project/phantom/phantomjs-script.js:
--------------------------------------------------------------------------------
1 | var _system = require('system'),
2 | _page = require('webpage').create(),
3 | _url = _system.args[1];
4 |
5 | _page.open( _url, function (status) {
6 |
7 | var hasPhantomjs;
8 | console.log("[phantom] opening url: ", _url );
9 |
10 | if (status !== 'success') {
11 | console.log('FAIL to load the address, status:', status);
12 |
13 | } else {
14 | _page.evaluate(function () {
15 | hasPhantomjs = true;
16 | });
17 |
18 | setTimeout(function () {
19 | console.log("render...");
20 | _page.render('app-view.png');
21 | phantom.exit();
22 | }, 2000);
23 |
24 | }
25 |
26 |
27 | });
--------------------------------------------------------------------------------
/test/core-tests/app-example/cat-project/plugins/custom-plugin.js:
--------------------------------------------------------------------------------
1 | var _Scrap = catrequire("cat.common.scrap"),
2 | _utils = catrequire("cat.utils");
3 |
4 | module.exports = function () {
5 |
6 | return {
7 |
8 | init: function () {
9 |
10 |
11 | // init scrap plugin code in here
12 |
13 |
14 | /**
15 | * Sample for custom annotation
16 | *
17 | * properties:
18 | * name - sample
19 | * single - false
20 | * singleton - 1[default -1]
21 | * $type - js
22 | */
23 | _Scrap.add({name: "sample",
24 | single: false,
25 | singleton: 1,
26 | func: function (config) {
27 | var sample,
28 | me = this;
29 |
30 | sample = this.get("sample");
31 | me.print("console.log('CAT... Custom annotation sample sample:', '" + sample + "'); _catjs.manager.resolve();");
32 | }});
33 |
34 | },
35 |
36 | apply: function () {
37 | // apply scrap plugin code in here
38 |
39 | },
40 |
41 | getType: function () {
42 | return "custom-plugin";
43 | }
44 | };
45 |
46 | };
--------------------------------------------------------------------------------
/test/core-tests/app-example/cat-project/src/common/README.txt:
--------------------------------------------------------------------------------
1 | In this folder any JavaScript files will be included for CAT's node and/or application logic layer.
--------------------------------------------------------------------------------
/test/core-tests/app-example/cat-project/src/config/cat.json:
--------------------------------------------------------------------------------
1 | {
2 | "_comment": {
3 | "description": "This is the cat test project (for the specification see catjs docs)",
4 | "tests": "Put in here all of the test scenarios that you wish to run. Enabled only if run-mode set to tests",
5 | "scenarios": "Declare your scenarios in here and execute them using the 'tests' property",
6 | "run-mode": {
7 | "all": "Execute all available tests (ignores 'tests' and 'scenarios' properties)",
8 | "tests": "Executes only the tests specified in the 'tests' property"
9 | },
10 | "ui": "Set to true in case you wish to enable catjs ui widget",
11 | "report": "In case you wish to get a report data set its 'disable' property to false. Currently catjs supports the junit XML format",
12 | "test-failure-timeout": "This is a timeout for failing the tests in case of general application malfunction. Set the timeout in seconds. "
13 | },
14 | "name": "app-example-test",
15 | "ip": "localhost",
16 | "port": "8089",
17 | "protocol": "http",
18 | "context": "",
19 | "tests": [{
20 | "name": "general"
21 | }],
22 | "scenarios": {
23 | "general": {
24 | "tests": [{
25 | "name": "fooTest"
26 | }]
27 | }
28 | },
29 | "ui": true,
30 | "report": {
31 | "format": ["console", "junit"],
32 | "disable": false
33 | },
34 | "assert": {
35 | "errors": true
36 | },
37 | "run-mode": "tests",
38 | "run-test-delay": 500,
39 | "test-failure-timeout": 20,
40 | "auto-override": true
41 | }
--------------------------------------------------------------------------------
/test/core-tests/app-example/cat-project/src/config/testdata.json:
--------------------------------------------------------------------------------
1 | {
2 | "_comment": "This is a test data JSON file, put in here any test data you wish to integrate with your tests (see the docs for more information)"
3 | }
--------------------------------------------------------------------------------
/test/core-tests/app-example/index.html:
--------------------------------------------------------------------------------
1 |
8 |
9 | test
10 |
11 |
--------------------------------------------------------------------------------
/test/core-tests/test-init.js:
--------------------------------------------------------------------------------
1 | var common = require("./common.js");
2 |
3 | common.init("./../..");
4 | common.createCatProject({
5 | appath: "./../app-example",
6 | testname: "test-init",
7 | port: "8088",
8 | callback: function() {
9 | common.run({
10 | tasks: ["t@clean", "t@init", "t@scrap", "t@inject", "t@autotest", "t@server.start", "t@runner.start"],
11 | callback: function() {
12 |
13 | }
14 | });
15 | }
16 | });
17 |
--------------------------------------------------------------------------------
/test/core-tests/test-run.js:
--------------------------------------------------------------------------------
1 | var common = require("./common.js");
2 |
3 | common.init("./../..");
4 |
5 | common.run({
6 | tasks: ["t@wipe", "t@init", "t@scrap", "t@inject", "t@autotest", "t@server.start", "t@runner.start"],
7 | callback: function () {
8 |
9 | }
10 | });
11 |
--------------------------------------------------------------------------------
/test/core-tests/test-server.js:
--------------------------------------------------------------------------------
1 | var common = require("./common.js");
2 |
3 | common.init("./../..");
4 | common.standaloneServer({
5 |
6 | });
--------------------------------------------------------------------------------