From: Sumin Lim Date: Tue, 12 Sep 2017 05:18:42 +0000 (+0900) Subject: Add tpk packaging tools X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fdevel%2Fgcontext;p=platform%2Fupstream%2Fiotjs.git Add tpk packaging tools Change-Id: I2447a16af4f816e38e1f3fa6e2b4824a68f7e081 --- diff --git a/config/tizen/tpk-tools/README.md b/config/tizen/tpk-tools/README.md new file mode 100644 index 0000000..f429e25 --- /dev/null +++ b/config/tizen/tpk-tools/README.md @@ -0,0 +1,39 @@ +# Setting buildscript.sh for Tizen IoT.js app ceritifacation +1. Install & Launch Tizen-Studio (https://developer.tizen.org/development/tizen-studio/download) +2. Install Certification : + * Tools > PackageManager > Tizen SDK Tools > BaseLine SDK > Certificate Manager +3. Create a new profile +4. Set buildscript.sh file +Set [AUTHOR_NAME] and [PASSWORD] on buildscript.sh file +Use same 'author name' and 'password' with Cerification manager,Tizen Studio. + +```code +jsn-cli build sign ~/tizen-studio/tools/ide/bin/native-signing +~/tizen-studio/tools/certificate-generator/certificates/developer/tizen-developer-ca.cer +~/tizen-studio-data/keystore/author/[AUTHOR_NAME].p12 [PASSWORD] +~/tizen-studio/tools/certificate-generator/certificates/distributor/tizen-distributor-signer.p12 tizenpkcs12passfordsigner +~/tizen-studio/tools/certificate-generator/certificates/distributor/tizen-distributor-ca.cer +``` +# Create Tizen package using jsn-cli +```code +> cd cli +> npm install +> jsn-cli create package 'tizen.org.iotjs-pkg' +> cd tizen.org.iotjs-pkg +> jsn-cli create app tizen.org.iotjs-app +``` +* Implement your own app on '/res/tizen.org.iotjs-app/index.js' + +# Create a .tpk file +```code +> cp buildscript ./tizen.org.iotjs-pkg +> ./buildscript +``` + +# Send .tpk to the target device and Install +```code +> sdb push ./tizen.org.iotjs-pkg.tpk /tmp +> sdb shell +> pkgcmd -i -t tpk -p tizen.org.iotjs-pkg.tpk +``` + diff --git a/config/tizen/tpk-tools/buildscript.sh b/config/tizen/tpk-tools/buildscript.sh new file mode 100755 index 0000000..9bc167c --- /dev/null +++ b/config/tizen/tpk-tools/buildscript.sh @@ -0,0 +1 @@ +jsn-cli build sign ~/tizen-studio/tools/ide/bin/native-signing ~/tizen-studio/tools/certificate-generator/certificates/developer/tizen-developer-ca.cer ~/tizen-studio-data/keystore/author/[AUTHOR_NAME].p12 [PASSWORD] ~/tizen-studio/tools/certificate-generator/certificates/distributor/tizen-distributor-signer.p12 tizenpkcs12passfordsigner ~/tizen-studio/tools/certificate-generator/certificates/distributor/tizen-distributor-ca.cer diff --git a/config/tizen/tpk-tools/cli/bin/jsn-cli b/config/tizen/tpk-tools/cli/bin/jsn-cli new file mode 100755 index 0000000..de376d4 --- /dev/null +++ b/config/tizen/tpk-tools/cli/bin/jsn-cli @@ -0,0 +1,16 @@ +#!/usr/bin/env node + +var fs = require('fs'); +var path = require('path'); + +// get current path of execution +var execPath = process.cwd(); + +// get real path because it can be real bin file or symbolic link file +var binDir = path.dirname(fs.realpathSync(process.argv[1])); + +// change cwd +process.chdir(path.join(binDir, '..', 'lib')); + +// compile & execute +require('../lib/cli')(process.argv, execPath); diff --git a/config/tizen/tpk-tools/cli/buildscript.sh b/config/tizen/tpk-tools/cli/buildscript.sh new file mode 100755 index 0000000..d100ee1 --- /dev/null +++ b/config/tizen/tpk-tools/cli/buildscript.sh @@ -0,0 +1 @@ +jsn-cli build sign ~/tizen-studio/tools/ide/bin/native-signing ~/tizen-studio/tools/certificate-generator/certificates/developer/tizen-developer-ca.cer ~/tizen-studio-data/keystore/author/iotjs.p12 power7sumin ~/tizen-studio/tools/certificate-generator/certificates/distributor/tizen-distributor-signer.p12 tizenpkcs12passfordsigner ~/tizen-studio/tools/certificate-generator/certificates/distributor/tizen-distributor-ca.cer diff --git a/config/tizen/tpk-tools/cli/lib/build.js b/config/tizen/tpk-tools/cli/lib/build.js new file mode 100755 index 0000000..025165b --- /dev/null +++ b/config/tizen/tpk-tools/cli/lib/build.js @@ -0,0 +1,75 @@ +(function() { + 'use strict'; + + var fs = require('fs'); + var path = require('path'); + var Q = require('q'); + + var JsnError = require('./jsn_error'); + var shellUtil = require('./shell_util'); + + module.exports = build; + + // this module's build is meanging to package a tpk + function build(argv, parser) { + var needToSign = argv.args_[0] || 'nosign'; + switch(needToSign) { + case 'sign': + // current args_[0] is 'sign'. So remove it. + argv.args_.shift(); + return require('./sign')(argv, parser) + .then(function() {packageToTpk();}); + + case 'nosign': + return parser.parse() + .catch(function(err) { + throw new JsnError('Parsing manifest file has a problem: ' + + err.message); + }) + .then(function() { + packageToTpk(); + }); + + default: + throw new JsnError('Wrong parameters for build command'); + } + + function packageToTpk() { + var dotTpk = '.tpk'; + var dirToGoBack = process.cwd(); + + console.log('Building the package...'); + + // exist 'zip' command? + return shellUtil.shExec('which zip') + + .then(function() { + // cd to project directory + process.chdir(parser.get('exec_path')); + + var pkgIdTpk = parser.get('package').pkg_id + dotTpk; + + // if *.tpk file exists, delete it + return Q.denodeify(fs.stat)(pkgIdTpk) + .then(function(stats) { + shellUtil.shExec('rm ' + pkgIdTpk); + }, + function() { + // empty(if not, it is catrued by outer catch ) + }); + }) + + .then(function() { + var tpkFile = parser.get('package').pkg_id + dotTpk; + var output = '.' + path.sep + tpkFile; + var input = '.' + path.sep + '*'; + return shellUtil.shExec('zip -r ' + output + ' ' + input); + }) + + // cd to previous cwd; actually, doesn't need this + .then(function() { + process.chdir(dirToGoBack); + }); + } + } +}()); \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/lib/cli.js b/config/tizen/tpk-tools/cli/lib/cli.js new file mode 100755 index 0000000..0c0020d --- /dev/null +++ b/config/tizen/tpk-tools/cli/lib/cli.js @@ -0,0 +1,134 @@ +(function() { + 'use strict'; + + var fs = require('fs'); + var path = require('path'); + var Q = require('q'); + + var help = require('./help'); + + module.exports = cli; + + /** + * This program uses 'Promises'. + * Reference below links for detailed contents. + * Promises: http://www.html5rocks.com/en/tutorials/es6/promises/ + * q: https://github.com/kriskowal/q + */ + function cli(inputArgv, execPath) { + // verify inputArgv + var argv = getVerifiedArgv(inputArgv); + if (argv === null) { + help.printAll(); + return; + } + + argv.exec_path_ = execPath; + + // setup manifest parser + var parser = new (require('./parser'))(execPath); + + // process command + switch (argv.cmd_) { + case 'create': + return require('./create')(argv, parser) + .then( + function() { + console.log('Ok'); + }, + function(err) { + console.error(err.message); + help.printCreate(); + }); + + case 'list': + return require('./list')(argv, parser) + .then( + function() { + console.log('Ok'); + }, + function(err) { + console.error(err.message); + help.printList(); + }); + + case 'remove': + return require('./remove')(argv, parser) + .then( + function() { + console.log('Ok'); + }, + function(err) { + console.error(err.message); + help.printRemove(); + }); + + case 'sign': + return require('./sign')(argv, parser) + .then( + function() { + console.log('Ok'); + }, + function(err) { + console.error(err.message); + help.printSign(); + }); + + case 'build': + return require('./build')(argv, parser) + .then( + function() { + console.log('Ok'); + }, + function(err) { + console.error(err.message); + help.printBuild(); + }); + + case 'help': + default: + help.print(argv.args_[0]); + break; + } + + function getVerifiedArgv(inputArgv) { + if (inputArgv.length < 3) + return null; + + var cmd = inputArgv[2]; + var args = []; + switch (cmd) { + case 'create': + args.push(inputArgv[3]); + args.push(inputArgv[4]); + break; + + case 'remove': + args.push(inputArgv[3]); + break; + + case 'sign': + case 'build': + var len = inputArgv.length; + for (var i = 3; i < len; i+=1) + args[i-3] = inputArgv[i]; + break; + + case 'list': + break; + + case 'help': + args.push(inputArgv[3]); + break; + + default: + return null; + } + + return { + cmd_: cmd, + args_: args + }; + } + } +}()); \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/lib/create.js b/config/tizen/tpk-tools/cli/lib/create.js new file mode 100755 index 0000000..dc25e26 --- /dev/null +++ b/config/tizen/tpk-tools/cli/lib/create.js @@ -0,0 +1,238 @@ +(function() { + 'use strict'; + + var fs = require('fs'); + var path = require('path'); + var Q = require('q'); + var format = require('string-template'); + + var JsnError = require('./jsn_error'); + var shellUtil = require('./shell_util'); + + module.exports = create; + + function create(argv, parser) { + var manifestFile = 'tizen-manifest.xml'; + var iconFile = 'icon.png'; + + return Q.fcall(function() { + if (argv.args_[0] === undefined || argv.args_[1] === undefined) { + throw new JsnError('error: You should type proper parameters'); + } else { + var createType = argv.args_[0]; + console.log('Creating %s...', createType); + + switch (createType) { + case 'package': + var pkgId = argv.args_[1]; + return createPackage(pkgId, parser); + + case 'app': + var appId = argv.args_[1]; + return createApp(appId, parser); + + default: + throw new JsnError('error: You should type proper parameters'); + } + } + }); + + /** + * creates directory to be below directory structure + * [pkgid]/shared(dir) + * /res(dir) + * /bin(dir) + * /lib(dir) + * /res(dir) + * /icon.png(file) + * /tizen-manifest.xml(file) + */ + function createPackage(pkgId, parser) { + // Creating Package + var dirToCreate = path.join(parser.get('exec_path'), pkgId); + + // Checking directory to create package + + /** + * if the dir exists and the dir is not empty, exit program + * if the dir exists and the dir is empty, pass + * if the dir exists and the dir is file, exit program + * if there is no dir, create the dir + */ + return Q.denodeify(fs.stat)(dirToCreate) + .then( + function(stats) { + if (stats.isDirectory()) { + return Q.denodeify(fs.readdir)(dirToCreate) + .then(function(files) { + if (files.length > 0) + throw new JsnError(pkgId + ' is not empty directory'); + }); + } else { + throw new JsnError(pkgId + ' file exists.'); + } + }, + function() { + // Generating a new package dir : 'dirToCreate' + return Q.denodeify(fs.mkdir)(dirToCreate); + }) + + /** + * creates directories like below directory structure + * [pkgid]/shared + * /bin + * /lib + * /res + */ + .then(function() { + // Creating a new jsn project package + // Creating directories in project + var shExecPromises = ['shared', 'bin', 'lib', 'res'] + .map(function(dir) { + return 'mkdir ' + path.join(dirToCreate, dir); + }) + .map(shellUtil.shExec); + return Q.all(shExecPromises) + .catch(function(reason) { throw new JsnError(reason); }); + }) + + /** + * creates a 'res' directory under 'shared' directory + * [pkgid]/shared + * /res + */ + .then(function() { + // Creating directories in project/shared + return Q.denodeify(fs.mkdir)(path.join(dirToCreate, 'shared', 'res')); + }) + + /** + * copy icon from 'tizen-app-template' + * [pkgid]/res + * /icon.png + */ + .then(function() { + // Copying icon + var defaultIconPath = path.join('..', 'tizen-app-template', iconFile); + var iconCmd = 'cp ' + defaultIconPath + ' ' + + path.join(dirToCreate, 'shared', 'res', iconFile); + return shellUtil.shExec(iconCmd) + .catch(function(reason) { throw new JsnError(reason); }); + }) + + /** + * creates manifest file from 'tizen-app-template' + * [pkgid]/tizen-manifest.xml + */ + .then(function() { + // Creating manifest + var oriManifest = path.join('..', 'tizen-app-template', manifestFile); + return Q.denodeify(fs.readFile)(oriManifest); + }) + .then(function(data) { + var manifestContent = format(data.toString(), { pkgid: pkgId }); + var newManifest = path.join(parser.get('exec_path'), + pkgId, manifestFile); + return Q.denodeify(fs.writeFile)(newManifest, manifestContent) + .thenResolve(newManifest); + }) + + .catch(function(err) { + throw new JsnError('Creating package is failed: ' + err.message); + }); + } // createPackage + + /** + * creates directories to be below directory structure + * [pkgid]/shared(dir) + * /res(dir) + * /bin(dir) + * /[pkgid].[appid] + * /lib(dir) + * /res(dir) + * /[appid] + * /index.js + * /icon.png(file) + * /tizen-manifest.xml(file) - add 'ui-application' element + */ + function createApp(appId, parser) { + return parser.parse() + .catch(function(err) { + throw new JsnError('Parsing manifest file has a problem: ' + + err.message); + }) + + .then(function() { + // Creating a new appication + // Checking whether the 'appId' exists + var app = parser.getAppSync(appId); + if (app) { + throw new JsnError(appId + ' already exists'); + } + }) + + // add 'ui-application' element in manifest file + .then(function() { + // Addding element in manifest file + return parser.addUiAppInManifest(appId) + .catch(function(err) { throw err; }); + }) + + /** + * creates a bin file by copying and editing it + * [pkgid]/bin(dir) + * /[pkgid].[appid] + */ + .then(function() { + // Creating bin file + var pkgId = parser.get('package').pkg_id; + + var defaultBinPath = + path.join('..', 'tizen-app-template', 'pkgid.appid'); + return Q.denodeify(fs.readFile)(defaultBinPath) + .then(function(data) { + // edit format string by 'string-format' + var binContent = format(data.toString(), { appid: appId , pkgid: pkgId}); + var binPath = path.join(parser.get('exec_path'), 'bin', + parser.get('package').pkg_id + + '.' + appId); + return Q.denodeify(fs.writeFile)(binPath, binContent, + { mode: '0775' }); + }); + }) + + /** + * creates directory and file + * [pkgid]/res(dir) + * /[appid] + * /index.js + */ + .then(function() { + // Creating app directory + var appDir = path.join(parser.get('exec_path'), 'res', appId); + return Q.denodeify(fs.mkdir)(appDir); + }) + .then(function() { + // Creating index.js + var defaultIndexPath = + path.join('..', 'tizen-app-template', 'index.js'); + return Q.denodeify(fs.readFile)(defaultIndexPath) + .then(function(data) { + // edit format string by 'string-format' + var indexContent = format(data.toString(), { appid: appId }); + var indexPath = + path.join(path.join(parser.get('exec_path'), 'res', appId), + 'index.js'); + + return Q.denodeify(fs.writeFile)(indexPath, indexContent, + { mode: '0775' }); + }); + }) + + .catch(function(err) { + throw new JsnError('Creating app(' + appId + ') is failed: ' + + err.message); + }); + } // createApp + } // create +}()); diff --git a/config/tizen/tpk-tools/cli/lib/help.js b/config/tizen/tpk-tools/cli/lib/help.js new file mode 100644 index 0000000..1992026 --- /dev/null +++ b/config/tizen/tpk-tools/cli/lib/help.js @@ -0,0 +1,141 @@ +(function() { + 'use strict'; + + var CLI = 'jsn-cli'; + var CAUTION_EXECUTED = '%s command should be executed in project root ' + + 'where has tizen-manifest.xml'; + + var help = module.exports; + + help.printAll = function() { + help.printSummary(); + help.printCreate(); + help.printList(); + help.printRemove(); + help.printSign(); + help.printBuild(); + }; + + help.printSummary = function() { + var summary = 'jsn-cli: commandline tool for creating, signing and building package.\n'; + var usage = 'Usage: ' + CLI + ' [args0] [args1] ...'; + console.log(summary); + console.log(usage); + console.log('where is one of\n' + + '--------------------------\n' + + 'create\tCreate a pacakge or app\n' + + 'list\tList all apps in the package\n' + + 'sign\tSign the package\n' + + 'build\tBuild the package to tpk file\n' + + '--------------------------\n'); + console.log('Usage Example:'); + }; + + help.printCreate = function() { + var create = '$ ' + CLI + ' create (\'package\' or \'app\') (id)'; + var createEx1 = ' ex) ' + CLI + ' create package pkgid'; + var createEx2 = ' ex) ' + CLI + ' create app appid'; + console.log(create); + console.log(createEx1); + console.log(createEx2); + console.log(' !!! ' + CAUTION_EXECUTED, '"app"'); + }; + + help.printList = function() { + var list = '$ ' + CLI + ' list'; + console.log(''); + console.log(list); + console.log(' !!! ' + CAUTION_EXECUTED, '"list"'); + }; + + help.printRemove = function() { + var remove = '$ ' + CLI + ' remove (appid)'; + var removeEx = ' ex) ' + CLI + ' remove \'appid\''; + console.log(remove); + console.log(removeEx); + console.log(' !!! ' + CAUTION_EXECUTED, '"remove"'); + }; + + help.printSign = function() { + var sign = '$ ' + CLI + ' sign (signer) ' + + '(authorCAPath) (authorP12Path) (authorPwd) ' + + '(dist1P12Path) (dist1Pwd) (dist1CAPath) ' + + '[dist2P12Path, dist2Pwd, dist2CAPath, dist2RootPath]'; + var signExplain = ' (argv): mandatory\n [argv]: optional,' + + ' all [4 parameters] have to be put together'; + + var signer = '{SIGNER}'; + var authorCAPath ='{CA}.cer'; + var authorP12Path = '{AUTHOR NAME}.p12'; + var authorPwd = '{AUTHOR PASSWORD}'; + var dist1P12Path = '{DISTRIBUTOR}.p12'; + var dist1Pwd = '{DISTRIBUTOR_PW}'; + var dist1CAPath = '{CA_DISTRIBUTOR}.cer'; + + var signEx = ' ex) ' + CLI + ' sign ' + signer + ' ' + authorCAPath + + ' ' + authorP12Path + ' ' + authorPwd + ' ' + dist1P12Path + + ' ' + dist1Pwd + ' ' + dist1CAPath; + + console.log(''); + console.log(sign); + console.log(signExplain); + console.log(signEx); + console.log(' !!! ' + CAUTION_EXECUTED, '"sign"'); + }; + + help.printBuild = function() { + var buildDefault = '$ ' + CLI + ' build'; + var buildSign = '$ ' + CLI + ' build sign (signer) ' + + '(authorCAPath) (authorP12Path) (authorPwd) ' + + '(dist1P12Path) (dist1Pwd) (dist1CAPath) ' + + '[dist2P12Path, dist2Pwd, dist2CAPath, dist2RootPath]'; + var buildSignExplain = ' (argv): mandatory\n [argv]: optional,' + + ' all [4 parameters] have to be put together'; + + var signer = '{SIGNER}'; + var authorCAPath ='{CA}.cer'; + var authorP12Path = '{AUTHOR NAME}.p12'; + var authorPwd = '{AUTHOR PASSWORD}'; + var dist1P12Path = '{DISTRIBUTOR}.p12'; + var dist1Pwd = '{DISTRIBUTOR_PW}'; + var dist1CAPath = '{CA_DISTRIBUTOR}.cer'; + + var buildDefaultEx = 'ex) ' + CLI + ' build'; + var buildSignEx = 'ex) ' + CLI + ' build sign ' + signer + ' ' + + authorCAPath + ' ' + authorP12Path + ' ' + + authorPwd + ' ' + dist1P12Path + ' ' + + dist1Pwd + ' ' + dist1CAPath; + + console.log(''); + console.log(buildDefault); + console.log(buildSign); + console.log(buildSignExplain); + console.log(' ' + buildDefaultEx); + console.log(' ' + buildSignEx); + console.log(' !!!' + CAUTION_EXECUTED, '"build"'); + console.log(''); + }; + + help.print = function(cmd) { + switch(cmd) { + case 'create': + help.printCreate(); + break; + case 'list': + help.printList(); + break; + case 'remove': + help.printRemove(); + break; + case 'sign': + help.printSign(); + break; + case 'build': + help.printBuild(); + break; + default: + help.printAll(); + break; + } + }; +}()); \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/lib/jsn_error.js b/config/tizen/tpk-tools/cli/lib/jsn_error.js new file mode 100644 index 0000000..c276a6b --- /dev/null +++ b/config/tizen/tpk-tools/cli/lib/jsn_error.js @@ -0,0 +1,11 @@ +(function() { + 'use strict'; + + module.exports = function JsnError(message) { + Error.captureStackTrace(this, this.constructor.name); + this.name = this.constructor.name; + this.message = message; + }; + + require('util').inherits(module.exports, Error); +}()); \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/lib/list.js b/config/tizen/tpk-tools/cli/lib/list.js new file mode 100755 index 0000000..45507e9 --- /dev/null +++ b/config/tizen/tpk-tools/cli/lib/list.js @@ -0,0 +1,29 @@ +(function() { + 'use strict'; + + var path = require('path'); + var Q = require('q'); + + var JsnError = require('./jsn_error'); + module.exports = function(argv, parser) { + return parser.parse() + .catch(function(err) { + throw new JsnError('Parsing manifest file has a problem: ' + + err.message); + }) + .then(function() { + console.log('Listing apps'); + if (parser.get('parsed') && parser.get('has_app')) { + console.log('No.\tAppId\tAppType\tExec'); + var len = parser.get('apps').length; + for (var i = 0; i < len; i++) { + var app = parser.get('apps')[i]; + console.log((i+1) + '\t' + app.app_id + '\t' + app.type + + '\t' + app.exec); + } + } else { + console.log('There is no app'); + } + }); + }; +}()); \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/lib/parser.js b/config/tizen/tpk-tools/cli/lib/parser.js new file mode 100755 index 0000000..7b8f0da --- /dev/null +++ b/config/tizen/tpk-tools/cli/lib/parser.js @@ -0,0 +1,211 @@ +(function() { + 'use strict'; + + var fs = require('fs'); + var path = require('path'); + var et = require('elementtree'); + var pd = require('pretty-data').pd; + var Q = require('q'); + var format = require('string-template'); + + var JsnError = require('./jsn_error'); + + var MANIFEST_FILE = 'tizen-manifest.xml'; + + function Parser(execPath) { + this.exec_path = execPath; + this.manifest_path = ''; + this.has_package = false; + this.package = {}; + this.has_app = false; + this.apps = []; + + // parsed_ expresses done to parse + this.parsed = false; + + // ready_ expresses ready for parsing + this.ready = (function(this_) { + var maybeManifestPath = path.join(this_.exec_path, + MANIFEST_FILE); + var existManifest = (function(path) { + try { + return (fs.statSync(path)); + } catch(err) { + return false; + } + })(maybeManifestPath); + if (existManifest) { + this_.manifest_path = maybeManifestPath; + return true; + } else { + return false; + } + })(this); + } // Parser + + Parser.prototype = { + constructor: Parser, + set: function(key, val) { + this[key] = val; + }, + + get: function(key) { + return this[key]; + }, + + /** + * parses manifest file and its contents are parsed to Parser's + * members. this method returns a promise. + */ + parse: function() { + if (this.ready === false) { + return Q.fcall(function() { + throw new JsnError('\n Parser is not ready. ' + + 'Checks whether the manifest file exists'); + }); + } + + var self = this; + return Q.denodeify(fs.readFile)(self.manifest_path) + .then(function(data) { + var etree = et.parse(data.toString()); + + // parse package + var manifestElem = etree.getroot(); + if (manifestElem) { + var pack = { + pkg_id: manifestElem.get('package'), + pkg_version: manifestElem.get('version'), + api_version: manifestElem.get('api-version') + }; + self.package = pack; + self.has_package = true; + } else { + throw new JsnError('Can\'t get manifest element ' + + 'while parsing manifest file'); + } + + // parse apps + var uiAppElems = etree.findall('./ui-application'); + if (uiAppElems) { + var len = uiAppElems.length; + self.has_app = (len > 0) ? true : false; + for (var i = 0; i < len; i++) { + var uiApp = uiAppElems[i]; + var app = { + app_id: uiApp.get('appid'), + exec: uiApp.get('exec'), + type: uiApp.get('type') + }; + self.apps[i] = app; + } + } else { + throw new JsnError('Can\'t get any ui app elements ' + + 'while parsing manifest file'); + } + self.parsed = true; + }); + }, // parse + + addUiAppInManifest: function(appId) { + var self = this; + return Q.denodeify(fs.readFile)(self.manifest_path) + .then(function(data) { + var etree = et.parse(data.toString()); + var subElement = et.SubElement; + var root = etree.getroot(); + var uiAppElem = subElement(root, 'ui-application'); + uiAppElem.set('appid', appId); + uiAppElem.set('exec', self.package.pkg_id + '.' + appId); + uiAppElem.set('type', 'jsapp'); + uiAppElem.set('multiple', 'false'); + uiAppElem.set('taskmanage', 'true'); + uiAppElem.set('nodisplay', 'false'); + + var iconElem = subElement(uiAppElem, 'icon'); + iconElem.text = 'icon.png'; + var labelElem = subElement(uiAppElem, 'label'); + labelElem.text = appId; + + // print xml pretty + var xmlPretty = pd.xml(etree.write()); + return xmlPretty; + }) + + .then(function(xmlPretty) { + Q.denodeify(fs.writeFile)(self.manifest_path, xmlPretty); + }); + }, // addUiAppInManifest + + removeApp: function(appId) { + var self = this; + var app = self.getAppSync(appId); + + return Q.fcall(function() { + if (app === null) { // equals to ((=== null) or (=== undefined)) + throw new JsnError(appId + ' doesn\'t exist'); + } + }) + + .then(function() { + return Q.denodeify(fs.readFile)(self.manifest_path); + }) + + .then(function(data) { + var etree = et.parse(data.toString()); + var root = etree.getroot(); + var uiAppElems = root.findall('./ui-application'); + if (uiAppElems) { + var len = uiAppElems.length; + for (var i = 0; i < len; i++) { + var uiApp = uiAppElems[i]; + if (uiApp.get('appid') == appId) { + root.remove(uiApp); + var xmlPretty = pd.xml(etree.write()); + return xmlPretty; + } + } + } + throw new JsnError('Can\'t get valid ui-application element' + + 'while parsing mafniest file'); + }) + + .then(function(xmlPretty) { + Q.denodeify(fs.writeFile)(self.manifest_path, xmlPretty); + }) + + .then(function() { + var len = self.apps.length; + for (var i = 0; i < len; i++) { + var app = self.apps[i]; + if (app.app_id == appId) { + self.apps.splice(i, 1); + break; + } + } + self.has_app = (self.apps.length > 0) ? true : false; + }); + }, // removeApp + + // it is not async, so adds 'sync' to the its name + getAppSync: function(appId) { + if (!this.has_app) + return null; + var len = this.apps.length; + for (var i = 0; i < len; i++) { + var app = this.apps[i]; + if (app.app_id == appId) + return app; + } + return null; + } // getAppSync + }; + + /** + * This Parser module is a class. Parser contains actions such as parsing + * manifest file, and adding/removing 'ui-application' element. + * Parser does 'async' by 'Promises' with 'q'. + * (Reference to 'cli.js') + */ + module.exports = Parser; +}()); \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/lib/remove.js b/config/tizen/tpk-tools/cli/lib/remove.js new file mode 100755 index 0000000..375eece --- /dev/null +++ b/config/tizen/tpk-tools/cli/lib/remove.js @@ -0,0 +1,50 @@ +(function() { + 'use strict'; + + var path = require('path'); + var Q = require('q'); + + var shellUtil = require('./shell_util'); + var JsnError = require('./jsn_error'); + + module.exports = function(argv, parser) { + var appId = argv.args_[0]; + + return Q.fcall(function() { + if (appId === undefined) + throw new JsnError('error: You should type appid'); + + return parser.parse() + .catch(function(err) { + throw new JsnError('Parsing manifest file has a problem: ' + + err.message); + }); + }) + + .then(function() { + console.log('Removing app...'); + if (parser.get('parsed') && parser.get('has_app')) { + var app = parser.getAppSync(appId); + if (app === null) { + throw new JsnError('There is no app'); + } + + // Deleting directories & files + var execFileInBin = path.join(parser.get('exec_path'), + 'bin', app.exec); + var appDirInRes = path.join(parser.get('exec_path'), + 'res', app.app_id); + var shPromises = ['rm ' + execFileInBin, 'rm -rf ' + appDirInRes] + .map(shellUtil.shExec); + return Q.all(shPromises); + } else { + throw new JsnError('There is no app'); + } + }) + + .then(function() { + // Deleting ui-application element in manifest file + return parser.removeApp(appId); + }); + }; +}()); \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/lib/shell_util.js b/config/tizen/tpk-tools/cli/lib/shell_util.js new file mode 100644 index 0000000..e8a18fe --- /dev/null +++ b/config/tizen/tpk-tools/cli/lib/shell_util.js @@ -0,0 +1,18 @@ +(function() { + 'use strict'; + + var Q = require('q'); + var sh = require('shelljs'); + + var shellUtil = module.exports; + + // This is utility function for easing usage of shell script command. + shellUtil.shExec = function(cmd) { + var deferred = Q.defer(); + sh.exec(cmd, {async:true, silent:true}, function(code) { + if (code !== 0) deferred.reject(cmd + ' returns ' + code); + else deferred.resolve(code); + }); + return deferred.promise; + }; +}()); \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/lib/sign.js b/config/tizen/tpk-tools/cli/lib/sign.js new file mode 100644 index 0000000..4904527 --- /dev/null +++ b/config/tizen/tpk-tools/cli/lib/sign.js @@ -0,0 +1,122 @@ +(function() { + 'use strict'; + + var fs = require('fs'); + var path = require('path'); + var Q = require('q'); + + var JsnError = require('./jsn_error'); + var shellUtil = require('./shell_util'); + + module.exports = sign; + + /** + * Sign command should be executed before build command. + * If you execute sign command after build command, the sign command + * deletes the tpk file which created by build command. + */ + function sign(argv, parser) { + var argc = argv.args_.length; + var signCmdArray = []; // it will be used as command + + return Q.fcall(function() { + // if argc is not 11, argc's num is equal or greater than 7 minimally + if (argc !== 7 && argc !== 11) { + throw new JsnError( + 'error: You should type sign command with proper arguments'); + } + }) + + .then(function() { + /** + * argv.args_ are parameters for sign cmd + * sign cmd: + * [signer] [targetDir] [authorCAPath] [authorP12Path] [authorPwd] + * [dist1P12Path] [dist1Pwd] [dist1CAPath] + * [dist2P12Path] [dist2Pwd] [dist2CAPath] [dist2RootPath] + * if argc is not 11, + * fill them(11 - num of empty parameters) with ' ' (one space string) + */ + + // caution: targetDir is not from args_ + var targetDir = parser.get('exec_path'); + var signer = argv.args_[0]; + var authorCAPath = argv.args_[1]; + var authorP12Path = argv.args_[2]; + var authorPwd = argv.args_[3]; + var dist1P12Path = argv.args_[4]; + var dist1Pwd = argv.args_[5]; + var dist1CAPath = argv.args_[6]; + var dist2P12Path = argv.args_[7] || '" "'; + var dist2Pwd = argv.args_[8] || '" "'; + var dist2CAPath = argv.args_[9] || '" "'; + var dist2RootPath = argv.args_[10] || '" "'; + + // verify arguments for sign command by checking wheter files exist + var verifyArgv = [signer, targetDir, authorCAPath, authorP12Path, + dist1P12Path, dist1CAPath]; + if (argc === 11) { + verifyArgv = + verifyArgv.concat([dist2P12Path, dist2CAPath, dist2RootPath]); + } + + var promToExistFiles = verifyArgv.map(function(path) { + var deferred = Q.defer(); + fs.stat(path, function(err, stats) { + if (err) deferred.reject(err); + else deferred.resolve(stats); + }); + return deferred.promise; + }); + + return Q.all(promToExistFiles) + .then( + function() { + var signArgv = [signer, targetDir, authorCAPath, authorP12Path, + authorPwd, dist1P12Path, dist1Pwd, dist1CAPath]; + if (argc === 7) { + signArgv = signArgv.concat([dist2P12Path, dist2Pwd, + dist2CAPath, dist2RootPath]); + } + Array.prototype.push.apply(signCmdArray, signArgv); + }, function(err) { + throw new JsnError('Can\'t verify arguments: ' + err.message); + }); + }) + + .then(function() { + parser.parse(); + }) + .catch(function(err) { + throw new JsnError('Parsing manifest file has a problem: ' + + err.message); + }) + + /** + * if [*.tpk, author-signature.xml, .manifest.tmp, signature1.xml] + * exists, remove all of them + */ + .then(function() { + console.log('Signing package...'); + // Checking previous signing + var shExecPromises = ['*.tpk', 'author-signature.xml', + '.manifest.tmp', 'signature1.xml'] + .map(function(dir) { + return 'rm ' + path.join(parser.get('exec_path'), dir); + }) + .map(shellUtil.shExec); + return Q.all(shExecPromises) + // If above file doesn't exist, it can fail. But it needs to pass. + .fail(function() {}); + }) + + // try signing + .then(function() { + // Trying signing from 'signCmdArray[0]' + var signCmd = signCmdArray.join(' '); + return shellUtil.shExec(signCmd) + .catch(function() { throw new JsnError("Fail to sign packge"); + }); + }); + } +}()); \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/node_modules/.bin/shjs b/config/tizen/tpk-tools/cli/node_modules/.bin/shjs new file mode 120000 index 0000000..a044997 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/.bin/shjs @@ -0,0 +1 @@ +../shelljs/bin/shjs \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/.npmignore b/config/tizen/tpk-tools/cli/node_modules/elementtree/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/.travis.yml b/config/tizen/tpk-tools/cli/node_modules/elementtree/.travis.yml new file mode 100644 index 0000000..6f27c96 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/.travis.yml @@ -0,0 +1,10 @@ +language: node_js + +node_js: + - 0.6 + +script: make test + +notifications: + email: + - tomaz+travisci@tomaz.me diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/CHANGES.md b/config/tizen/tpk-tools/cli/node_modules/elementtree/CHANGES.md new file mode 100644 index 0000000..50d415d --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/CHANGES.md @@ -0,0 +1,39 @@ +elementtree v0.1.6 (in development) + +* Add support for CData elements. (#14) + [hermannpencole] + +elementtree v0.1.5 - 2012-11-14 + +* Fix a bug in the find() and findtext() method which could manifest itself + under some conditions. + [metagriffin] + +elementtree v0.1.4 - 2012-10-15 + +* Allow user to use namespaced attributes when using find* functions. + [Andrew Lunny] + +elementtree v0.1.3 - 2012-09-21 + +* Improve the output of text content in the tags (strip unnecessary line break + characters). + +[Darryl Pogue] + +elementtree v0.1.2 - 2012-09-04 + + * Allow user to pass 'indent' option to ElementTree.write method. If this + option is specified (e.g. {'indent': 4}). XML will be pretty printed. + [Darryl Pogue, Tomaz Muraus] + + * Bump sax dependency version. + +elementtree v0.1.1 - 2011-09-23 + + * Improve special character escaping. + [Ryan Phillips] + +elementtree v0.1.0 - 2011-09-05 + + * Initial release. diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/LICENSE.txt b/config/tizen/tpk-tools/cli/node_modules/elementtree/LICENSE.txt new file mode 100644 index 0000000..6b0b127 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/LICENSE.txt @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/Makefile b/config/tizen/tpk-tools/cli/node_modules/elementtree/Makefile new file mode 100755 index 0000000..ab7c4e0 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/Makefile @@ -0,0 +1,21 @@ +TESTS := \ + tests/test-simple.js + + + +PATH := ./node_modules/.bin:$(PATH) + +WHISKEY := $(shell bash -c 'PATH=$(PATH) type -p whiskey') + +default: test + +test: + NODE_PATH=`pwd`/lib/ ${WHISKEY} --scope-leaks --sequential --real-time --tests "${TESTS}" + +tap: + NODE_PATH=`pwd`/lib/ ${WHISKEY} --test-reporter tap --sequential --real-time --tests "${TESTS}" + +coverage: + NODE_PATH=`pwd`/lib/ ${WHISKEY} --sequential --coverage --coverage-reporter html --coverage-dir coverage_html --tests "${TESTS}" + +.PHONY: default test coverage tap scope diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/NOTICE b/config/tizen/tpk-tools/cli/node_modules/elementtree/NOTICE new file mode 100644 index 0000000..28ad70a --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/NOTICE @@ -0,0 +1,5 @@ +node-elementtree +Copyright (c) 2011, Rackspace, Inc. + +The ElementTree toolkit is Copyright (c) 1999-2007 by Fredrik Lundh + diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/README.md b/config/tizen/tpk-tools/cli/node_modules/elementtree/README.md new file mode 100644 index 0000000..738420c --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/README.md @@ -0,0 +1,141 @@ +node-elementtree +==================== + +node-elementtree is a [Node.js](http://nodejs.org) XML parser and serializer based upon the [Python ElementTree v1.3](http://effbot.org/zone/element-index.htm) module. + +Installation +==================== + + $ npm install elementtree + +Using the library +==================== + +For the usage refer to the Python ElementTree library documentation - [http://effbot.org/zone/element-index.htm#usage](http://effbot.org/zone/element-index.htm#usage). + +Supported XPath expressions in `find`, `findall` and `findtext` methods are listed on [http://effbot.org/zone/element-xpath.htm](http://effbot.org/zone/element-xpath.htm). + +Example 1 – Creating An XML Document +==================== + +This example shows how to build a valid XML document that can be published to +Atom Hopper. Atom Hopper is used internally as a bridge from products all the +way to collecting revenue, called “Usage.” MaaS and other products send similar +events to it every time user performs an action on a resource +(e.g. creates,updates or deletes). Below is an example of leveraging the API +to create a new XML document. + +```javascript +var et = require('elementtree'); +var XML = et.XML; +var ElementTree = et.ElementTree; +var element = et.Element; +var subElement = et.SubElement; + +var date, root, tenantId, serviceName, eventType, usageId, dataCenter, region, +checks, resourceId, category, startTime, resourceName, etree, xml; + +date = new Date(); + +root = element('entry'); +root.set('xmlns', 'http://www.w3.org/2005/Atom'); + +tenantId = subElement(root, 'TenantId'); +tenantId.text = '12345'; + +serviceName = subElement(root, 'ServiceName'); +serviceName.text = 'MaaS'; + +resourceId = subElement(root, 'ResourceID'); +resourceId.text = 'enAAAA'; + +usageId = subElement(root, 'UsageID'); +usageId.text = '550e8400-e29b-41d4-a716-446655440000'; + +eventType = subElement(root, 'EventType'); +eventType.text = 'create'; + +category = subElement(root, 'category'); +category.set('term', 'monitoring.entity.create'); + +dataCenter = subElement(root, 'DataCenter'); +dataCenter.text = 'global'; + +region = subElement(root, 'Region'); +region.text = 'global'; + +startTime = subElement(root, 'StartTime'); +startTime.text = date; + +resourceName = subElement(root, 'ResourceName'); +resourceName.text = 'entity'; + +etree = new ElementTree(root); +xml = etree.write({'xml_declaration': false}); +console.log(xml); +``` + +As you can see, both et.Element and et.SubElement are factory methods which +return a new instance of Element and SubElement class, respectively. +When you create a new element (tag) you can use set method to set an attribute. +To set the tag value, assign a value to the .text attribute. + +This example would output a document that looks like this: + +```xml + + 12345 + MaaS + enAAAA + 550e8400-e29b-41d4-a716-446655440000 + create + + global + global + Sun Apr 29 2012 16:37:32 GMT-0700 (PDT) + entity + +``` + +Example 2 – Parsing An XML Document +==================== + +This example shows how to parse an XML document and use simple XPath selectors. +For demonstration purposes, we will use the XML document located at +https://gist.github.com/2554343. + +Behind the scenes, node-elementtree uses Isaac’s sax library for parsing XML, +but the library has a concept of “parsers,” which means it’s pretty simple to +add support for a different parser. + +```javascript +var fs = require('fs'); + +var et = require('elementtree'); + +var XML = et.XML; +var ElementTree = et.ElementTree; +var element = et.Element; +var subElement = et.SubElement; + +var data, etree; + +data = fs.readFileSync('document.xml').toString(); +etree = et.parse(data); + +console.log(etree.findall('./entry/TenantId').length); // 2 +console.log(etree.findtext('./entry/ServiceName')); // MaaS +console.log(etree.findall('./entry/category')[0].get('term')); // monitoring.entity.create +console.log(etree.findall('*/category/[@term="monitoring.entity.update"]').length); // 1 +``` + +Build status +==================== + +[![Build Status](https://secure.travis-ci.org/racker/node-elementtree.png)](http://travis-ci.org/racker/node-elementtree) + + +License +==================== + +node-elementtree is distributed under the [Apache license](http://www.apache.org/licenses/LICENSE-2.0.html). diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/constants.js b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/constants.js new file mode 100644 index 0000000..b057faf --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/constants.js @@ -0,0 +1,20 @@ +/* + * Copyright 2011 Rackspace + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +var DEFAULT_PARSER = 'sax'; + +exports.DEFAULT_PARSER = DEFAULT_PARSER; diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/elementpath.js b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/elementpath.js new file mode 100644 index 0000000..2e93f47 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/elementpath.js @@ -0,0 +1,343 @@ +/** + * Copyright 2011 Rackspace + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +var sprintf = require('./sprintf').sprintf; + +var utils = require('./utils'); +var SyntaxError = require('./errors').SyntaxError; + +var _cache = {}; + +var RE = new RegExp( + "(" + + "'[^']*'|\"[^\"]*\"|" + + "::|" + + "//?|" + + "\\.\\.|" + + "\\(\\)|" + + "[/.*:\\[\\]\\(\\)@=])|" + + "((?:\\{[^}]+\\})?[^/\\[\\]\\(\\)@=\\s]+)|" + + "\\s+", 'g' +); + +var xpath_tokenizer = utils.findall.bind(null, RE); + +function prepare_tag(next, token) { + var tag = token[0]; + + function select(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + elem._children.forEach(function(e) { + if (e.tag === tag) { + rv.push(e); + } + }); + } + + return rv; + } + + return select; +} + +function prepare_star(next, token) { + function select(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + elem._children.forEach(function(e) { + rv.push(e); + }); + } + + return rv; + } + + return select; +} + +function prepare_dot(next, token) { + function select(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + rv.push(elem); + } + + return rv; + } + + return select; +} + +function prepare_iter(next, token) { + var tag; + token = next(); + + if (token[1] === '*') { + tag = '*'; + } + else if (!token[1]) { + tag = token[0] || ''; + } + else { + throw new SyntaxError(token); + } + + function select(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + elem.iter(tag, function(e) { + if (e !== elem) { + rv.push(e); + } + }); + } + + return rv; + } + + return select; +} + +function prepare_dot_dot(next, token) { + function select(context, result) { + var i, len, elem, rv = [], parent_map = context.parent_map; + + if (!parent_map) { + context.parent_map = parent_map = {}; + + context.root.iter(null, function(p) { + p._children.forEach(function(e) { + parent_map[e] = p; + }); + }); + } + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + + if (parent_map.hasOwnProperty(elem)) { + rv.push(parent_map[elem]); + } + } + + return rv; + } + + return select; +} + + +function prepare_predicate(next, token) { + var tag, key, value, select; + token = next(); + + if (token[1] === '@') { + // attribute + token = next(); + + if (token[1]) { + throw new SyntaxError(token, 'Invalid attribute predicate'); + } + + key = token[0]; + token = next(); + + if (token[1] === ']') { + select = function(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + + if (elem.get(key)) { + rv.push(elem); + } + } + + return rv; + }; + } + else if (token[1] === '=') { + value = next()[1]; + + if (value[0] === '"' || value[value.length - 1] === '\'') { + value = value.slice(1, value.length - 1); + } + else { + throw new SyntaxError(token, 'Ivalid comparison target'); + } + + token = next(); + select = function(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + + if (elem.get(key) === value) { + rv.push(elem); + } + } + + return rv; + }; + } + + if (token[1] !== ']') { + throw new SyntaxError(token, 'Invalid attribute predicate'); + } + } + else if (!token[1]) { + tag = token[0] || ''; + token = next(); + + if (token[1] !== ']') { + throw new SyntaxError(token, 'Invalid node predicate'); + } + + select = function(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + + if (elem.find(tag)) { + rv.push(elem); + } + } + + return rv; + }; + } + else { + throw new SyntaxError(null, 'Invalid predicate'); + } + + return select; +} + + + +var ops = { + "": prepare_tag, + "*": prepare_star, + ".": prepare_dot, + "..": prepare_dot_dot, + "//": prepare_iter, + "[": prepare_predicate, +}; + +function _SelectorContext(root) { + this.parent_map = null; + this.root = root; +} + +function findall(elem, path) { + var selector, result, i, len, token, value, select, context; + + if (_cache.hasOwnProperty(path)) { + selector = _cache[path]; + } + else { + // TODO: Use smarter cache purging approach + if (Object.keys(_cache).length > 100) { + _cache = {}; + } + + if (path.charAt(0) === '/') { + throw new SyntaxError(null, 'Cannot use absolute path on element'); + } + + result = xpath_tokenizer(path); + selector = []; + + function getToken() { + return result.shift(); + } + + token = getToken(); + while (true) { + var c = token[1] || ''; + value = ops[c](getToken, token); + + if (!value) { + throw new SyntaxError(null, sprintf('Invalid path: %s', path)); + } + + selector.push(value); + token = getToken(); + + if (!token) { + break; + } + else if (token[1] === '/') { + token = getToken(); + } + + if (!token) { + break; + } + } + + _cache[path] = selector; + } + + // Execute slector pattern + result = [elem]; + context = new _SelectorContext(elem); + + for (i = 0, len = selector.length; i < len; i++) { + select = selector[i]; + result = select(context, result); + } + + return result || []; +} + +function find(element, path) { + var resultElements = findall(element, path); + + if (resultElements && resultElements.length > 0) { + return resultElements[0]; + } + + return null; +} + +function findtext(element, path, defvalue) { + var resultElements = findall(element, path); + + if (resultElements && resultElements.length > 0) { + return resultElements[0].text; + } + + return defvalue; +} + + +exports.find = find; +exports.findall = findall; +exports.findtext = findtext; diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/elementtree.js b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/elementtree.js new file mode 100644 index 0000000..61d9276 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/elementtree.js @@ -0,0 +1,611 @@ +/** + * Copyright 2011 Rackspace + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +var sprintf = require('./sprintf').sprintf; + +var utils = require('./utils'); +var ElementPath = require('./elementpath'); +var TreeBuilder = require('./treebuilder').TreeBuilder; +var get_parser = require('./parser').get_parser; +var constants = require('./constants'); + +var element_ids = 0; + +function Element(tag, attrib) +{ + this._id = element_ids++; + this.tag = tag; + this.attrib = {}; + this.text = null; + this.tail = null; + this._children = []; + + if (attrib) { + this.attrib = utils.merge(this.attrib, attrib); + } +} + +Element.prototype.toString = function() +{ + return sprintf("", this.tag, this._id); +}; + +Element.prototype.makeelement = function(tag, attrib) +{ + return new Element(tag, attrib); +}; + +Element.prototype.len = function() +{ + return this._children.length; +}; + +Element.prototype.getItem = function(index) +{ + return this._children[index]; +}; + +Element.prototype.setItem = function(index, element) +{ + this._children[index] = element; +}; + +Element.prototype.delItem = function(index) +{ + this._children.splice(index, 1); +}; + +Element.prototype.getSlice = function(start, stop) +{ + return this._children.slice(start, stop); +}; + +Element.prototype.setSlice = function(start, stop, elements) +{ + var i; + var k = 0; + for (i = start; i < stop; i++, k++) { + this._children[i] = elements[k]; + } +}; + +Element.prototype.delSlice = function(start, stop) +{ + this._children.splice(start, stop - start); +}; + +Element.prototype.append = function(element) +{ + this._children.push(element); +}; + +Element.prototype.extend = function(elements) +{ + this._children.concat(elements); +}; + +Element.prototype.insert = function(index, element) +{ + this._children[index] = element; +}; + +Element.prototype.remove = function(element) +{ + this._children = this._children.filter(function(e) { + /* TODO: is this the right way to do this? */ + if (e._id === element._id) { + return false; + } + return true; + }); +}; + +Element.prototype.getchildren = function() { + return this._children; +}; + +Element.prototype.find = function(path) +{ + return ElementPath.find(this, path); +}; + +Element.prototype.findtext = function(path, defvalue) +{ + return ElementPath.findtext(this, path, defvalue); +}; + +Element.prototype.findall = function(path, defvalue) +{ + return ElementPath.findall(this, path, defvalue); +}; + +Element.prototype.clear = function() +{ + this.attrib = {}; + this._children = []; + this.text = null; + this.tail = null; +}; + +Element.prototype.get = function(key, defvalue) +{ + if (this.attrib[key] !== undefined) { + return this.attrib[key]; + } + else { + return defvalue; + } +}; + +Element.prototype.set = function(key, value) +{ + this.attrib[key] = value; +}; + +Element.prototype.keys = function() +{ + return Object.keys(this.attrib); +}; + +Element.prototype.items = function() +{ + return utils.items(this.attrib); +}; + +/* + * In python this uses a generator, but in v8 we don't have em, + * so we use a callback instead. + **/ +Element.prototype.iter = function(tag, callback) +{ + var self = this; + var i, child; + + if (tag === "*") { + tag = null; + } + + if (tag === null || this.tag === tag) { + callback(self); + } + + for (i = 0; i < this._children.length; i++) { + child = this._children[i]; + child.iter(tag, function(e) { + callback(e); + }); + } +}; + +Element.prototype.itertext = function(callback) +{ + this.iter(null, function(e) { + if (e.text) { + callback(e.text); + } + + if (e.tail) { + callback(e.tail); + } + }); +}; + + +function SubElement(parent, tag, attrib) { + var element = parent.makeelement(tag, attrib); + parent.append(element); + return element; +} + +function Comment(text) { + var element = new Element(Comment); + if (text) { + element.text = text; + } + return element; +} + +function CData(text) { + var element = new Element(CData); + if (text) { + element.text = text; + } + return element; +} + +function ProcessingInstruction(target, text) +{ + var element = new Element(ProcessingInstruction); + element.text = target; + if (text) { + element.text = element.text + " " + text; + } + return element; +} + +function QName(text_or_uri, tag) +{ + if (tag) { + text_or_uri = sprintf("{%s}%s", text_or_uri, tag); + } + this.text = text_or_uri; +} + +QName.prototype.toString = function() { + return this.text; +}; + +function ElementTree(element) +{ + this._root = element; +} + +ElementTree.prototype.getroot = function() { + return this._root; +}; + +ElementTree.prototype._setroot = function(element) { + this._root = element; +}; + +ElementTree.prototype.parse = function(source, parser) { + if (!parser) { + parser = get_parser(constants.DEFAULT_PARSER); + parser = new parser.XMLParser(new TreeBuilder()); + } + + parser.feed(source); + this._root = parser.close(); + return this._root; +}; + +ElementTree.prototype.iter = function(tag, callback) { + this._root.iter(tag, callback); +}; + +ElementTree.prototype.find = function(path) { + return this._root.find(path); +}; + +ElementTree.prototype.findtext = function(path, defvalue) { + return this._root.findtext(path, defvalue); +}; + +ElementTree.prototype.findall = function(path) { + return this._root.findall(path); +}; + +/** + * Unlike ElementTree, we don't write to a file, we return you a string. + */ +ElementTree.prototype.write = function(options) { + var sb = []; + options = utils.merge({ + encoding: 'utf-8', + xml_declaration: null, + default_namespace: null, + method: 'xml'}, options); + + if (options.xml_declaration !== false) { + sb.push("\n"); + } + + if (options.method === "text") { + _serialize_text(sb, self._root, encoding); + } + else { + var qnames, namespaces, indent, indent_string; + var x = _namespaces(this._root, options.encoding, options.default_namespace); + qnames = x[0]; + namespaces = x[1]; + + if (options.hasOwnProperty('indent')) { + indent = 0; + indent_string = new Array(options.indent + 1).join(' '); + } + else { + indent = false; + } + + if (options.method === "xml") { + _serialize_xml(function(data) { + sb.push(data); + }, this._root, options.encoding, qnames, namespaces, indent, indent_string); + } + else { + /* TODO: html */ + throw new Error("unknown serialization method "+ options.method); + } + } + + return sb.join(""); +}; + +var _namespace_map = { + /* "well-known" namespace prefixes */ + "http://www.w3.org/XML/1998/namespace": "xml", + "http://www.w3.org/1999/xhtml": "html", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#": "rdf", + "http://schemas.xmlsoap.org/wsdl/": "wsdl", + /* xml schema */ + "http://www.w3.org/2001/XMLSchema": "xs", + "http://www.w3.org/2001/XMLSchema-instance": "xsi", + /* dublic core */ + "http://purl.org/dc/elements/1.1/": "dc", +}; + +function register_namespace(prefix, uri) { + if (/ns\d+$/.test(prefix)) { + throw new Error('Prefix format reserved for internal use'); + } + + if (_namespace_map.hasOwnProperty(uri) && _namespace_map[uri] === prefix) { + delete _namespace_map[uri]; + } + + _namespace_map[uri] = prefix; +} + + +function _escape(text, encoding, isAttribute, isText) { + if (text) { + text = text.toString(); + text = text.replace(/&/g, '&'); + text = text.replace(//g, '>'); + if (!isText) { + text = text.replace(/\n/g, ' '); + text = text.replace(/\r/g, ' '); + } + if (isAttribute) { + text = text.replace(/"/g, '"'); + } + } + return text; +} + +/* TODO: benchmark single regex */ +function _escape_attrib(text, encoding) { + return _escape(text, encoding, true); +} + +function _escape_cdata(text, encoding) { + return _escape(text, encoding, false); +} + +function _escape_text(text, encoding) { + return _escape(text, encoding, false, true); +} + +function _namespaces(elem, encoding, default_namespace) { + var qnames = {}; + var namespaces = {}; + + if (default_namespace) { + namespaces[default_namespace] = ""; + } + + function encode(text) { + return text; + } + + function add_qname(qname) { + if (qname[0] === "{") { + var tmp = qname.substring(1).split("}", 2); + var uri = tmp[0]; + var tag = tmp[1]; + var prefix = namespaces[uri]; + + if (prefix === undefined) { + prefix = _namespace_map[uri]; + if (prefix === undefined) { + prefix = "ns" + Object.keys(namespaces).length; + } + if (prefix !== "xml") { + namespaces[uri] = prefix; + } + } + + if (prefix) { + qnames[qname] = sprintf("%s:%s", prefix, tag); + } + else { + qnames[qname] = tag; + } + } + else { + if (default_namespace) { + throw new Error('cannot use non-qualified names with default_namespace option'); + } + + qnames[qname] = qname; + } + } + + + elem.iter(null, function(e) { + var i; + var tag = e.tag; + var text = e.text; + var items = e.items(); + + if (tag instanceof QName && qnames[tag.text] === undefined) { + add_qname(tag.text); + } + else if (typeof(tag) === "string") { + add_qname(tag); + } + else if (tag !== null && tag !== Comment && tag !== CData && tag !== ProcessingInstruction) { + throw new Error('Invalid tag type for serialization: '+ tag); + } + + if (text instanceof QName && qnames[text.text] === undefined) { + add_qname(text.text); + } + + items.forEach(function(item) { + var key = item[0], + value = item[1]; + if (key instanceof QName) { + key = key.text; + } + + if (qnames[key] === undefined) { + add_qname(key); + } + + if (value instanceof QName && qnames[value.text] === undefined) { + add_qname(value.text); + } + }); + }); + return [qnames, namespaces]; +} + +function _serialize_xml(write, elem, encoding, qnames, namespaces, indent, indent_string) { + var tag = elem.tag; + var text = elem.text; + var items; + var i; + + var newlines = indent || (indent === 0); + write(Array(indent + 1).join(indent_string)); + + if (tag === Comment) { + write(sprintf("", _escape_cdata(text, encoding))); + } + else if (tag === ProcessingInstruction) { + write(sprintf("", _escape_cdata(text, encoding))); + } + else if (tag === CData) { + text = text || ''; + write(sprintf("", text)); + } + else { + tag = qnames[tag]; + if (tag === undefined) { + if (text) { + write(_escape_text(text, encoding)); + } + elem.iter(function(e) { + _serialize_xml(write, e, encoding, qnames, null, newlines ? indent + 1 : false, indent_string); + }); + } + else { + write("<" + tag); + items = elem.items(); + + if (items || namespaces) { + items.sort(); // lexical order + + items.forEach(function(item) { + var k = item[0], + v = item[1]; + + if (k instanceof QName) { + k = k.text; + } + + if (v instanceof QName) { + v = qnames[v.text]; + } + else { + v = _escape_attrib(v, encoding); + } + write(sprintf(" %s=\"%s\"", qnames[k], v)); + }); + + if (namespaces) { + items = utils.items(namespaces); + items.sort(function(a, b) { return a[1] < b[1]; }); + + items.forEach(function(item) { + var k = item[1], + v = item[0]; + + if (k) { + k = ':' + k; + } + + write(sprintf(" xmlns%s=\"%s\"", k, _escape_attrib(v, encoding))); + }); + } + } + + if (text || elem.len()) { + if (text && text.toString().match(/^\s*$/)) { + text = null; + } + + write(">"); + if (!text && newlines) { + write("\n"); + } + + if (text) { + write(_escape_text(text, encoding)); + } + elem._children.forEach(function(e) { + _serialize_xml(write, e, encoding, qnames, null, newlines ? indent + 1 : false, indent_string); + }); + + if (!text && indent) { + write(Array(indent + 1).join(indent_string)); + } + write(""); + } + else { + write(" />"); + } + } + } + + if (newlines) { + write("\n"); + } +} + +function parse(source, parser) { + var tree = new ElementTree(); + tree.parse(source, parser); + return tree; +} + +function tostring(element, options) { + return new ElementTree(element).write(options); +} + +exports.PI = ProcessingInstruction; +exports.Comment = Comment; +exports.CData = CData; +exports.ProcessingInstruction = ProcessingInstruction; +exports.SubElement = SubElement; +exports.QName = QName; +exports.ElementTree = ElementTree; +exports.ElementPath = ElementPath; +exports.Element = function(tag, attrib) { + return new Element(tag, attrib); +}; + +exports.XML = function(data) { + var et = new ElementTree(); + return et.parse(data); +}; + +exports.parse = parse; +exports.register_namespace = register_namespace; +exports.tostring = tostring; diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/errors.js b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/errors.js new file mode 100644 index 0000000..e8742be --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/errors.js @@ -0,0 +1,31 @@ +/** + * Copyright 2011 Rackspace + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +var util = require('util'); + +var sprintf = require('./sprintf').sprintf; + +function SyntaxError(token, msg) { + msg = msg || sprintf('Syntax Error at token %s', token.toString()); + this.token = token; + this.message = msg; + Error.call(this, msg); +} + +util.inherits(SyntaxError, Error); + +exports.SyntaxError = SyntaxError; diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/parser.js b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/parser.js new file mode 100644 index 0000000..7307ee4 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/parser.js @@ -0,0 +1,33 @@ +/* + * Copyright 2011 Rackspace + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/* TODO: support node-expat C++ module optionally */ + +var util = require('util'); +var parsers = require('./parsers/index'); + +function get_parser(name) { + if (name === 'sax') { + return parsers.sax; + } + else { + throw new Error('Invalid parser: ' + name); + } +} + + +exports.get_parser = get_parser; diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/parsers/index.js b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/parsers/index.js new file mode 100644 index 0000000..5eac5c8 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/parsers/index.js @@ -0,0 +1 @@ +exports.sax = require('./sax'); diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/parsers/sax.js b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/parsers/sax.js new file mode 100644 index 0000000..69b0a59 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/parsers/sax.js @@ -0,0 +1,56 @@ +var util = require('util'); + +var sax = require('sax'); + +var TreeBuilder = require('./../treebuilder').TreeBuilder; + +function XMLParser(target) { + this.parser = sax.parser(true); + + this.target = (target) ? target : new TreeBuilder(); + + this.parser.onopentag = this._handleOpenTag.bind(this); + this.parser.ontext = this._handleText.bind(this); + this.parser.oncdata = this._handleCdata.bind(this); + this.parser.ondoctype = this._handleDoctype.bind(this); + this.parser.oncomment = this._handleComment.bind(this); + this.parser.onclosetag = this._handleCloseTag.bind(this); + this.parser.onerror = this._handleError.bind(this); +} + +XMLParser.prototype._handleOpenTag = function(tag) { + this.target.start(tag.name, tag.attributes); +}; + +XMLParser.prototype._handleText = function(text) { + this.target.data(text); +}; + +XMLParser.prototype._handleCdata = function(text) { + this.target.data(text); +}; + +XMLParser.prototype._handleDoctype = function(text) { +}; + +XMLParser.prototype._handleComment = function(comment) { +}; + +XMLParser.prototype._handleCloseTag = function(tag) { + this.target.end(tag); +}; + +XMLParser.prototype._handleError = function(err) { + throw err; +}; + +XMLParser.prototype.feed = function(chunk) { + this.parser.write(chunk); +}; + +XMLParser.prototype.close = function() { + this.parser.close(); + return this.target.close(); +}; + +exports.XMLParser = XMLParser; diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/sprintf.js b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/sprintf.js new file mode 100644 index 0000000..f802c1b --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/sprintf.js @@ -0,0 +1,86 @@ +/* + * Copyright 2011 Rackspace + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +var cache = {}; + + +// Do any others need escaping? +var TO_ESCAPE = { + '\'': '\\\'', + '\n': '\\n' +}; + + +function populate(formatter) { + var i, type, + key = formatter, + prev = 0, + arg = 1, + builder = 'return \''; + + for (i = 0; i < formatter.length; i++) { + if (formatter[i] === '%') { + type = formatter[i + 1]; + + switch (type) { + case 's': + builder += formatter.slice(prev, i) + '\' + arguments[' + arg + '] + \''; + prev = i + 2; + arg++; + break; + case 'j': + builder += formatter.slice(prev, i) + '\' + JSON.stringify(arguments[' + arg + ']) + \''; + prev = i + 2; + arg++; + break; + case '%': + builder += formatter.slice(prev, i + 1); + prev = i + 2; + i++; + break; + } + + + } else if (TO_ESCAPE[formatter[i]]) { + builder += formatter.slice(prev, i) + TO_ESCAPE[formatter[i]]; + prev = i + 1; + } + } + + builder += formatter.slice(prev) + '\';'; + cache[key] = new Function(builder); +} + + +/** + * A fast version of sprintf(), which currently only supports the %s and %j. + * This caches a formatting function for each format string that is used, so + * you should only use this sprintf() will be called many times with a single + * format string and a limited number of format strings will ever be used (in + * general this means that format strings should be string literals). + * + * @param {String} formatter A format string. + * @param {...String} var_args Values that will be formatted by %s and %j. + * @return {String} The formatted output. + */ +exports.sprintf = function(formatter, var_args) { + if (!cache[formatter]) { + populate(formatter); + } + + return cache[formatter].apply(null, arguments); +}; diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/treebuilder.js b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/treebuilder.js new file mode 100644 index 0000000..393a98f --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/treebuilder.js @@ -0,0 +1,60 @@ +function TreeBuilder(element_factory) { + this._data = []; + this._elem = []; + this._last = null; + this._tail = null; + if (!element_factory) { + /* evil circular dep */ + element_factory = require('./elementtree').Element; + } + this._factory = element_factory; +} + +TreeBuilder.prototype.close = function() { + return this._last; +}; + +TreeBuilder.prototype._flush = function() { + if (this._data) { + if (this._last !== null) { + var text = this._data.join(""); + if (this._tail) { + this._last.tail = text; + } + else { + this._last.text = text; + } + } + this._data = []; + } +}; + +TreeBuilder.prototype.data = function(data) { + this._data.push(data); +}; + +TreeBuilder.prototype.start = function(tag, attrs) { + this._flush(); + var elem = this._factory(tag, attrs); + this._last = elem; + + if (this._elem.length) { + this._elem[this._elem.length - 1].append(elem); + } + + this._elem.push(elem); + + this._tail = null; +}; + +TreeBuilder.prototype.end = function(tag) { + this._flush(); + this._last = this._elem.pop(); + if (this._last.tag !== tag) { + throw new Error("end tag mismatch"); + } + this._tail = 1; + return this._last; +}; + +exports.TreeBuilder = TreeBuilder; diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/utils.js b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/utils.js new file mode 100644 index 0000000..b08a670 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/lib/utils.js @@ -0,0 +1,72 @@ +/** + * Copyright 2011 Rackspace + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** + * @param {Object} hash. + * @param {Array} ignored. + */ +function items(hash, ignored) { + ignored = ignored || null; + var k, rv = []; + + function is_ignored(key) { + if (!ignored || ignored.length === 0) { + return false; + } + + return ignored.indexOf(key); + } + + for (k in hash) { + if (hash.hasOwnProperty(k) && !(is_ignored(ignored))) { + rv.push([k, hash[k]]); + } + } + + return rv; +} + + +function findall(re, str) { + var match, matches = []; + + while ((match = re.exec(str))) { + matches.push(match); + } + + return matches; +} + +function merge(a, b) { + var c = {}, attrname; + + for (attrname in a) { + if (a.hasOwnProperty(attrname)) { + c[attrname] = a[attrname]; + } + } + for (attrname in b) { + if (b.hasOwnProperty(attrname)) { + c[attrname] = b[attrname]; + } + } + return c; +} + +exports.items = items; +exports.findall = findall; +exports.merge = merge; diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/package.json b/config/tizen/tpk-tools/cli/node_modules/elementtree/package.json new file mode 100644 index 0000000..77dd360 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/package.json @@ -0,0 +1,108 @@ +{ + "_args": [ + [ + { + "raw": "elementtree@0.1.6", + "scope": null, + "escapedName": "elementtree", + "name": "elementtree", + "rawSpec": "0.1.6", + "spec": "0.1.6", + "type": "version" + }, + "/home/sumin/iotjs-tpk/cli" + ] + ], + "_from": "elementtree@0.1.6", + "_id": "elementtree@0.1.6", + "_inCache": true, + "_location": "/elementtree", + "_npmUser": { + "name": "rphillips", + "email": "ryan@trolocsis.com" + }, + "_npmVersion": "1.3.24", + "_phantomChildren": {}, + "_requested": { + "raw": "elementtree@0.1.6", + "scope": null, + "escapedName": "elementtree", + "name": "elementtree", + "rawSpec": "0.1.6", + "spec": "0.1.6", + "type": "version" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/elementtree/-/elementtree-0.1.6.tgz", + "_shasum": "2ac4c46ea30516c8c4cbdb5e3ac7418e592de20c", + "_shrinkwrap": null, + "_spec": "elementtree@0.1.6", + "_where": "/home/sumin/iotjs-tpk/cli", + "author": { + "name": "Rackspace US, Inc." + }, + "bugs": { + "url": "https://github.com/racker/node-elementtree/issues" + }, + "contributors": [ + { + "name": "Paul Querna", + "email": "paul.querna@rackspace.com" + }, + { + "name": "Tomaz Muraus", + "email": "tomaz.muraus@rackspace.com" + } + ], + "dependencies": { + "sax": "0.3.5" + }, + "description": "XML Serialization and Parsing module based on Python's ElementTree.", + "devDependencies": { + "whiskey": "0.8.x" + }, + "directories": { + "lib": "lib" + }, + "dist": { + "shasum": "2ac4c46ea30516c8c4cbdb5e3ac7418e592de20c", + "tarball": "https://registry.npmjs.org/elementtree/-/elementtree-0.1.6.tgz" + }, + "engines": { + "node": ">= 0.4.0" + }, + "homepage": "https://github.com/racker/node-elementtree", + "keywords": [ + "xml", + "sax", + "parser", + "seralization", + "elementtree" + ], + "licenses": [ + { + "type": "Apache", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + } + ], + "main": "lib/elementtree.js", + "maintainers": [ + { + "name": "rphillips", + "email": "ryan@trolocsis.com" + } + ], + "name": "elementtree", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/racker/node-elementtree.git" + }, + "scripts": { + "test": "make test" + }, + "version": "0.1.6" +} diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/tests/data/xml1.xml b/config/tizen/tpk-tools/cli/node_modules/elementtree/tests/data/xml1.xml new file mode 100644 index 0000000..72c33ae --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/tests/data/xml1.xml @@ -0,0 +1,17 @@ + + + dd + test_object_1 + 4281c348eaf83e70ddce0e07221c3d28 + 14 + application/octetstream + 2009-02-03T05:26:32.612278 + + + test_object_2 + b039efe731ad111bc1b0ef221c3849d0 + 64 + application/octetstream + 2009-02-03T05:26:32.612278 + + diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/tests/data/xml2.xml b/config/tizen/tpk-tools/cli/node_modules/elementtree/tests/data/xml2.xml new file mode 100644 index 0000000..5f94bbd --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/tests/data/xml2.xml @@ -0,0 +1,14 @@ + + + + Hello World + + + + + + + + diff --git a/config/tizen/tpk-tools/cli/node_modules/elementtree/tests/test-simple.js b/config/tizen/tpk-tools/cli/node_modules/elementtree/tests/test-simple.js new file mode 100644 index 0000000..1fc04b8 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/elementtree/tests/test-simple.js @@ -0,0 +1,339 @@ +/** + * Copyright 2011 Rackspace + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +var fs = require('fs'); +var path = require('path'); + +var sprintf = require('./../lib/sprintf').sprintf; +var et = require('elementtree'); +var XML = et.XML; +var ElementTree = et.ElementTree; +var Element = et.Element; +var SubElement = et.SubElement; +var SyntaxError = require('./../lib/errors').SyntaxError; + +function readFile(name) { + return fs.readFileSync(path.join(__dirname, '/data/', name), 'utf8'); +} + +exports['test_simplest'] = function(test, assert) { + /* Ported from */ + var Element = et.Element; + var root = Element('root'); + root.append(Element('one')); + root.append(Element('two')); + root.append(Element('three')); + assert.equal(3, root.len()); + assert.equal('one', root.getItem(0).tag); + assert.equal('two', root.getItem(1).tag); + assert.equal('three', root.getItem(2).tag); + test.finish(); +}; + + +exports['test_attribute_values'] = function(test, assert) { + var XML = et.XML; + var root = XML(''); + assert.equal('Alpha', root.attrib['alpha']); + assert.equal('Beta', root.attrib['beta']); + assert.equal('Gamma', root.attrib['gamma']); + test.finish(); +}; + + +exports['test_findall'] = function(test, assert) { + var XML = et.XML; + var root = XML(''); + + assert.equal(root.findall("c").length, 1); + assert.equal(root.findall(".//c").length, 2); + assert.equal(root.findall(".//b").length, 3); + assert.equal(root.findall(".//b")[0]._children.length, 1); + assert.equal(root.findall(".//b")[1]._children.length, 0); + assert.equal(root.findall(".//b")[2]._children.length, 0); + assert.deepEqual(root.findall('.//b')[0], root.getchildren()[0]); + + test.finish(); +}; + +exports['test_find'] = function(test, assert) { + var a = Element('a'); + var b = SubElement(a, 'b'); + var c = SubElement(a, 'c'); + + assert.deepEqual(a.find('./b/..'), a); + test.finish(); +}; + +exports['test_elementtree_find_qname'] = function(test, assert) { + var tree = new et.ElementTree(XML('')); + assert.deepEqual(tree.find(new et.QName('c')), tree.getroot()._children[2]); + test.finish(); +}; + +exports['test_attrib_ns_clear'] = function(test, assert) { + var attribNS = '{http://foo/bar}x'; + + var par = Element('par'); + par.set(attribNS, 'a'); + var child = SubElement(par, 'child'); + child.set(attribNS, 'b'); + + assert.equal('a', par.get(attribNS)); + assert.equal('b', child.get(attribNS)); + + par.clear(); + assert.equal(null, par.get(attribNS)); + assert.equal('b', child.get(attribNS)); + test.finish(); +}; + +exports['test_create_tree_and_parse_simple'] = function(test, assert) { + var i = 0; + var e = new Element('bar', {}); + var expected = "\n" + + 'ponies'; + + SubElement(e, "blah", {a: 11}); + SubElement(e, "blah", {a: 12}); + var se = et.SubElement(e, "gag", {a: '13', b: 'abc'}); + se.text = 'ponies'; + + se.itertext(function(text) { + assert.equal(text, 'ponies'); + i++; + }); + + assert.equal(i, 1); + var etree = new ElementTree(e); + var xml = etree.write(); + assert.equal(xml, expected); + test.finish(); +}; + +exports['test_write_with_options'] = function(test, assert) { + var i = 0; + var e = new Element('bar', {}); + var expected1 = "\n" + + '\n' + + ' \n' + + ' test\n' + + ' \n' + + ' \n' + + ' ponies\n' + + '\n'; + var expected2 = "\n" + + '\n' + + ' \n' + + ' test\n' + + ' \n' + + ' \n' + + ' ponies\n' + + '\n'; + + var expected3 = "\n" + + '\n' + + ' \n' + + ' Hello World\n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' Test & Test & Test\n' + + ' \n' + + '\n'; + + var se1 = SubElement(e, "blah", {a: 11}); + var se2 = SubElement(se1, "baz", {d: 11}); + se2.text = 'test'; + SubElement(e, "blah", {a: 12}); + var se = et.SubElement(e, "gag", {a: '13', b: 'abc'}); + se.text = 'ponies'; + + se.itertext(function(text) { + assert.equal(text, 'ponies'); + i++; + }); + + assert.equal(i, 1); + var etree = new ElementTree(e); + var xml1 = etree.write({'indent': 4}); + var xml2 = etree.write({'indent': 2}); + assert.equal(xml1, expected1); + assert.equal(xml2, expected2); + + var file = readFile('xml2.xml'); + var etree2 = et.parse(file); + var xml3 = etree2.write({'indent': 4}); + assert.equal(xml3, expected3); + test.finish(); +}; + +exports['test_parse_and_find_2'] = function(test, assert) { + var data = readFile('xml1.xml'); + var etree = et.parse(data); + + assert.equal(etree.findall('./object').length, 2); + assert.equal(etree.findall('[@name]').length, 1); + assert.equal(etree.findall('[@name="test_container_1"]').length, 1); + assert.equal(etree.findall('[@name=\'test_container_1\']').length, 1); + assert.equal(etree.findall('./object')[0].findtext('name'), 'test_object_1'); + assert.equal(etree.findtext('./object/name'), 'test_object_1'); + assert.equal(etree.findall('.//bytes').length, 2); + assert.equal(etree.findall('*/bytes').length, 2); + assert.equal(etree.findall('*/foobar').length, 0); + + test.finish(); +}; + +exports['test_namespaced_attribute'] = function(test, assert) { + var data = readFile('xml1.xml'); + var etree = et.parse(data); + + assert.equal(etree.findall('*/bytes[@android:type="cool"]').length, 1); + + test.finish(); +} + +exports['test_syntax_errors'] = function(test, assert) { + var expressions = [ './/@bar', '[@bar', '[@foo=bar]', '[@', '/bar' ]; + var errCount = 0; + var data = readFile('xml1.xml'); + var etree = et.parse(data); + + expressions.forEach(function(expression) { + try { + etree.findall(expression); + } + catch (err) { + errCount++; + } + }); + + assert.equal(errCount, expressions.length); + test.finish(); +}; + +exports['test_register_namespace'] = function(test, assert){ + var prefix = 'TESTPREFIX'; + var namespace = 'http://seriously.unknown/namespace/URI'; + var errCount = 0; + + var etree = Element(sprintf('{%s}test', namespace)); + assert.equal(et.tostring(etree, { 'xml_declaration': false}), + sprintf('', namespace)); + + et.register_namespace(prefix, namespace); + var etree = Element(sprintf('{%s}test', namespace)); + assert.equal(et.tostring(etree, { 'xml_declaration': false}), + sprintf('<%s:test xmlns:%s="%s" />', prefix, prefix, namespace)); + + try { + et.register_namespace('ns25', namespace); + } + catch (err) { + errCount++; + } + + assert.equal(errCount, 1, 'Reserved prefix used, but exception was not thrown'); + test.finish(); +}; + +exports['test_tostring'] = function(test, assert) { + var a = Element('a'); + var b = SubElement(a, 'b'); + var c = SubElement(a, 'c'); + c.text = 543; + + assert.equal(et.tostring(a, { 'xml_declaration': false }), '543'); + assert.equal(et.tostring(c, { 'xml_declaration': false }), '543'); + test.finish(); +}; + +exports['test_escape'] = function(test, assert) { + var a = Element('a'); + var b = SubElement(a, 'b'); + b.text = '&&&&<>"\n\r'; + + assert.equal(et.tostring(a, { 'xml_declaration': false }), '&&&&<>\"\n\r'); + test.finish(); +}; + +exports['test_find_null'] = function(test, assert) { + var root = Element('root'); + var node = SubElement(root, 'node'); + var leaf = SubElement(node, 'leaf'); + leaf.text = 'ipsum'; + + assert.equal(root.find('node/leaf'), leaf); + assert.equal(root.find('no-such-node/leaf'), null); + test.finish(); +}; + +exports['test_findtext_null'] = function(test, assert) { + var root = Element('root'); + var node = SubElement(root, 'node'); + var leaf = SubElement(node, 'leaf'); + leaf.text = 'ipsum'; + + assert.equal(root.findtext('node/leaf'), 'ipsum'); + assert.equal(root.findtext('no-such-node/leaf'), null); + test.finish(); +}; + +exports['test_remove'] = function(test, assert) { + var root = Element('root'); + var node1 = SubElement(root, 'node1'); + var node2 = SubElement(root, 'node2'); + var node3 = SubElement(root, 'node3'); + + assert.equal(root.len(), 3); + + root.remove(node2); + + assert.equal(root.len(), 2); + assert.equal(root.getItem(0).tag, 'node1') + assert.equal(root.getItem(1).tag, 'node3') + + test.finish(); +}; + +exports['test_cdata_write'] = function(test, assert) { + var root, etree, xml, values, value, i; + + values = [ + 'if(0>1) then true;', + 'ponies hello', + '' + ]; + + for (i = 0; i < values.length; i++) { + value = values[i]; + + root = Element('root'); + root.append(et.CData(value)); + etree = new ElementTree(root); + xml = etree.write({'xml_declaration': false}); + + assert.equal(xml, sprintf('', value)); + } + + test.finish(); +}; diff --git a/config/tizen/tpk-tools/cli/node_modules/pretty-data/README.md b/config/tizen/tpk-tools/cli/node_modules/pretty-data/README.md new file mode 100644 index 0000000..5bec8d7 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/pretty-data/README.md @@ -0,0 +1,78 @@ +# pretty-data - Nodejs plugin + +nodejs plugin to **pretty-print** or **minify** +text in **XML**, **JSON**, **CSS** and **SQL** formats. + +**Version** - 0.40.0 + +**Copyright** (c) 2012 Vadim Kiryukhin ( vkiryukhin @ gmail.com ) + +**Home page:** [http://www.eslinstructor.net/pretty-data/](http://www.eslinstructor.net/pretty-data/) + +**License:** Dual licensed under +the MIT and GPL licenses: + +[http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php) + +[http://www.gnu.org/licenses/gpl.html](http://www.gnu.org/licenses/gpl.html) + +##Description + +* `pd.xml(data )` - pretty print XML; + +* `pd.json(data)` - pretty print JSON; + +* `pd.css(data )` - pretty print CSS; + +* `pd.sql(data )` - pretty print SQL; + +* `pd.xmlmin(data [, preserveComments]) ` - minify XML; + +* `pd.jsonmin(data)` - minify JSON text; + +* `pd.cssmin(data [, preserveComments] )` - minify CSS text; + +* `pd.sqlmin(data)` - minify JSON text; + +**PARAMETERS:** + +`@data` - String; XML, JSON, CSS or SQL text to beautify; + +`@preserveComments` - Bool (optional, used in npp.minxml and npp.mincss only); + Set this flag to true to prevent removing comments from @data; + +`@Return` - String; + + +**USAGE:** + +`var pd = require('pretty-data').pd; ` + +`var xml_pp = pd.xml(data); ` + +`var xml_min = pd.xmlmin(data [,true]);` + +`var json_pp = pd.json(data);` + +`var json_min = pd.jsonmin(data);` + +`var css_pp = pd.css(data); ` + +`var css_min = pd.cssmin(data [, true]);` + +`var sql_pp = pd.sql(data);` + +`var sql_min = pd.sqlmin(data);` + +**TEST:** + +`node ./test/test_xml + +`node ./test/test_json + +`node ./test/test_css + +`node ./test/test_sql + + + diff --git a/config/tizen/tpk-tools/cli/node_modules/pretty-data/package.json b/config/tizen/tpk-tools/cli/node_modules/pretty-data/package.json new file mode 100644 index 0000000..780f98a --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/pretty-data/package.json @@ -0,0 +1,96 @@ +{ + "_args": [ + [ + { + "raw": "pretty-data@0.40.0", + "scope": null, + "escapedName": "pretty-data", + "name": "pretty-data", + "rawSpec": "0.40.0", + "spec": "0.40.0", + "type": "version" + }, + "/home/sumin/iotjs-tpk/cli" + ] + ], + "_defaultsLoaded": true, + "_engineSupported": true, + "_from": "pretty-data@0.40.0", + "_id": "pretty-data@0.40.0", + "_inCache": true, + "_location": "/pretty-data", + "_nodeVersion": "v0.4.9", + "_npmVersion": "0.2.19", + "_phantomChildren": {}, + "_requested": { + "raw": "pretty-data@0.40.0", + "scope": null, + "escapedName": "pretty-data", + "name": "pretty-data", + "rawSpec": "0.40.0", + "spec": "0.40.0", + "type": "version" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/pretty-data/-/pretty-data-0.40.0.tgz", + "_shasum": "572aa8ea23467467ab94b6b5266a6fd9c8fddd72", + "_shrinkwrap": null, + "_spec": "pretty-data@0.40.0", + "_where": "/home/sumin/iotjs-tpk/cli", + "author": { + "name": "Vadim Kiryukhin", + "email": "vkiryukhin@gmail.com" + }, + "bugs": { + "url": "https://github.com/vkiryukhin/pretty-data/issues" + }, + "contributors": [ + { + "name": "Vadim Kiryukhin", + "email": "vkiryukhin@gmail.com" + } + ], + "dependencies": {}, + "description": "plugin to pretty-print or minify XML, JSON, CSS and SQL files", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "572aa8ea23467467ab94b6b5266a6fd9c8fddd72", + "tarball": "https://registry.npmjs.org/pretty-data/-/pretty-data-0.40.0.tgz" + }, + "engine": { + "node": ">=0.4.9" + }, + "engines": { + "node": "*" + }, + "files": [], + "homepage": "https://github.com/vkiryukhin/pretty-data#readme", + "keywords": [ + "pretty print", + "beautify", + "minify", + "XML", + "JSON", + "CSS", + "SQL" + ], + "license": "MIT", + "main": "./pretty-data", + "maintainers": [ + { + "name": "vkiryukhin", + "email": "vkiryukhin@gmail.com" + } + ], + "name": "pretty-data", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/vkiryukhin/pretty-data.git" + }, + "version": "0.40.0" +} diff --git a/config/tizen/tpk-tools/cli/node_modules/pretty-data/pretty-data.js b/config/tizen/tpk-tools/cli/node_modules/pretty-data/pretty-data.js new file mode 100644 index 0000000..0723e27 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/pretty-data/pretty-data.js @@ -0,0 +1,344 @@ +/** +* pretty-data - nodejs plugin to pretty-print or minify data in XML, JSON and CSS formats. +* +* Version - 0.40.0 +* Copyright (c) 2012 Vadim Kiryukhin +* vkiryukhin @ gmail.com +* http://www.eslinstructor.net/pretty-data/ +* +* Dual licensed under the MIT and GPL licenses: +* http://www.opensource.org/licenses/mit-license.php +* http://www.gnu.org/licenses/gpl.html +* +* pd.xml(data ) - pretty print XML; +* pd.json(data) - pretty print JSON; +* pd.css(data ) - pretty print CSS; +* pd.sql(data) - pretty print SQL; +* +* pd.xmlmin(data [, preserveComments] ) - minify XML; +* pd.jsonmin(data) - minify JSON; +* pd.cssmin(data [, preserveComments] ) - minify CSS; +* pd.sqlmin(data) - minify SQL; +* +* PARAMETERS: +* +* @data - String; XML, JSON, CSS or SQL text to beautify; +* @preserveComments - Bool (optional, used in minxml and mincss only); +* Set this flag to true to prevent removing comments from @text; +* @Return - String; +* +* USAGE: +* +* var pd = require('pretty-data').pd; +* +* var xml_pp = pd.xml(xml_text); +* var xml_min = pd.xmlmin(xml_text [,true]); +* var json_pp = pd.json(json_text); +* var json_min = pd.jsonmin(json_text); +* var css_pp = pd.css(css_text); +* var css_min = pd.cssmin(css_text [, true]); +* var sql_pp = pd.sql(sql_text); +* var sql_min = pd.sqlmin(sql_text); +* +* TEST: +* comp-name:pretty-data$ node ./test/test_xml +* comp-name:pretty-data$ node ./test/test_json +* comp-name:pretty-data$ node ./test/test_css +* comp-name:pretty-data$ node ./test/test_sql +*/ + + +function pp() { + this.shift = ['\n']; // array of shifts + this.step = ' ', // 2 spaces + maxdeep = 100, // nesting level + ix = 0; + + // initialize array with shifts // + for(ix=0;ix\s{0,}<") + .replace(/ or -1) { + str += this.shift[deep]+ar[ix]; + inComment = true; + // end comment or // + if(ar[ix].search(/-->/) > -1 || ar[ix].search(/\]>/) > -1 || ar[ix].search(/!DOCTYPE/) > -1 ) { + inComment = false; + } + } else + // end comment or // + if(ar[ix].search(/-->/) > -1 || ar[ix].search(/\]>/) > -1) { + str += ar[ix]; + inComment = false; + } else + // // + if( /^<\w/.exec(ar[ix-1]) && /^<\/\w/.exec(ar[ix]) && + /^<[\w:\-\.\,]+/.exec(ar[ix-1]) == /^<\/[\w:\-\.\,]+/.exec(ar[ix])[0].replace('/','')) { + str += ar[ix]; + if(!inComment) deep--; + } else + // // + if(ar[ix].search(/<\w/) > -1 && ar[ix].search(/<\//) == -1 && ar[ix].search(/\/>/) == -1 ) { + str = !inComment ? str += this.shift[deep++]+ar[ix] : str += ar[ix]; + } else + // ... // + if(ar[ix].search(/<\w/) > -1 && ar[ix].search(/<\//) > -1) { + str = !inComment ? str += this.shift[deep]+ar[ix] : str += ar[ix]; + } else + // // + if(ar[ix].search(/<\//) > -1) { + str = !inComment ? str += this.shift[--deep]+ar[ix] : str += ar[ix]; + } else + // // + if(ar[ix].search(/\/>/) > -1 ) { + str = !inComment ? str += this.shift[deep]+ar[ix] : str += ar[ix]; + } else + // // + if(ar[ix].search(/<\?/) > -1) { + str += this.shift[deep]+ar[ix]; + } else + // xmlns // + if( ar[ix].search(/xmlns\:/) > -1 || ar[ix].search(/xmlns\=/) > -1) { + str += this.shift[deep]+ar[ix]; + } + + else { + str += ar[ix]; + } + } + + return (str[0] == '\n') ? str.slice(1) : str; +} + +// ----------------------- JSON section ---------------------------------------------------- + +pp.prototype.json = function(text) { + + if ( typeof text === "string" ) { + return JSON.stringify(JSON.parse(text), null, this.step); + } + if ( typeof text === "object" ) { + return JSON.stringify(text, null, this.step); + } + return null; +} + +// ----------------------- CSS section ---------------------------------------------------- + +pp.prototype.css = function(text) { + + var ar = text.replace(/\s{1,}/g,' ') + .replace(/\{/g,"{~::~") + .replace(/\}/g,"~::~}~::~") + .replace(/\;/g,";~::~") + .replace(/\/\*/g,"~::~/*") + .replace(/\*\//g,"*/~::~") + .replace(/~::~\s{0,}~::~/g,"~::~") + .split('~::~'), + len = ar.length, + deep = 0, + str = '', + ix = 0; + + for(ix=0;ix/g,""); + return str.replace(/>\s{0,}<"); +} + +pp.prototype.jsonmin = function(text) { + + return text.replace(/\s{0,}\{\s{0,}/g,"{") + .replace(/\s{0,}\[$/g,"[") + .replace(/\[\s{0,}/g,"[") + .replace(/:\s{0,}\[/g,':[') + .replace(/\s{0,}\}\s{0,}/g,"}") + .replace(/\s{0,}\]\s{0,}/g,"]") + .replace(/\"\s{0,}\,/g,'",') + .replace(/\,\s{0,}\"/g,',"') + .replace(/\"\s{0,}:/g,'":') + .replace(/:\s{0,}\"/g,':"') + .replace(/:\s{0,}\[/g,':[') + .replace(/\,\s{0,}\[/g,',[') + .replace(/\,\s{2,}/g,', ') + .replace(/\]\s{0,},\s{0,}\[/g,'],['); +} + +pp.prototype.cssmin = function(text, preserveComments) { + + var str = preserveComments ? text + : text.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\//g,"") ; + return str.replace(/\s{1,}/g,' ') + .replace(/\{\s{1,}/g,"{") + .replace(/\}\s{1,}/g,"}") + .replace(/\;\s{1,}/g,";") + .replace(/\/\*\s{1,}/g,"/*") + .replace(/\*\/\s{1,}/g,"*/"); +} + +pp.prototype.sqlmin = function(text) { + return text.replace(/\s{1,}/g," ").replace(/\s{1,}\(/,"(").replace(/\s{1,}\)/,")"); +} + +// -------------------------------------------------------------------------------------------- + +exports.pd= new pp; + + + + + + + + + + diff --git a/config/tizen/tpk-tools/cli/node_modules/pretty-data/test/test_css.js b/config/tizen/tpk-tools/cli/node_modules/pretty-data/test/test_css.js new file mode 100644 index 0000000..d702415 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/pretty-data/test/test_css.js @@ -0,0 +1,12 @@ + +var css = '.headbg{margin:0 8px;display:none; }a:link,a:focus{ color:#00c }\n /* comment */ a:active{ color:red }', + pp_css = require('../pretty-data').pd.css(css), + pp_cssmin_com = require('../pretty-data').pd.cssmin(css,true), + pp_cssmin = require('../pretty-data').pd.cssmin(css); + +console.log('\n==============================================================================\n'); +console.log('\n/*------- Original CSS string: -------*/\n\n' + css + '\n'); +console.log('\n/*------- Beautified original CSS -------------*/\n\n' + pp_css + '\n'); +console.log('\n/*------- Minified original CSS with preserved comments: -------*/\n\n' + pp_cssmin_com + '\n'); +console.log('\n/*------- Minified original CSS with deleted comments: ---------*/\n\n' + pp_cssmin + '\n'); +console.log('\n===============================================================================\n'); diff --git a/config/tizen/tpk-tools/cli/node_modules/pretty-data/test/test_json.js b/config/tizen/tpk-tools/cli/node_modules/pretty-data/test/test_json.js new file mode 100644 index 0000000..8022c10 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/pretty-data/test/test_json.js @@ -0,0 +1,10 @@ + +var json = '{"menu":{"id": "file","value": \n[[1,2,3],[4,5,6] ],\n"popup":{"menuitem":[{"value": ["one","two"],\n"onclick":"CreateNewDoc()"},{"value":"Close","onclick":"CloseDoc()"}]}}}', + json_pp = require('../pretty-data').pd.json(json), + json_min = require('../pretty-data').pd.jsonmin(json); + +console.log('\n==============================================================================\n'); +console.log('\n/*------- Original JSON string: -------*/\n\n' + json + '\n'); +console.log('\n/*------- Beautified JSON: -------------*/\n\n' + json_pp + '\n'); +console.log('\n/*------- Minified JSON: ---------------*/\n\n' + json_min + '\n'); +console.log('\n===============================================================================\n'); diff --git a/config/tizen/tpk-tools/cli/node_modules/pretty-data/test/test_sql.js b/config/tizen/tpk-tools/cli/node_modules/pretty-data/test/test_sql.js new file mode 100644 index 0000000..35fa1f0 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/pretty-data/test/test_sql.js @@ -0,0 +1,10 @@ + +var sql = "select ca.proj_id as proj_id, ca.ca_name as proj_name, ca.ca_date_start as proj_start, ca.ca_date_end AS proj_end,\n(select COUNT(*) from rotations r \nwhere r.proj_id = proj_id and r.r_status = 'R' \ngroup by r.proj_id) r_count, \n(select count(*) from rotations r \nwhere r.proj_id = proj_id and r.channel_id = 24) r_rtb_count \nfrom projs ca, clients c, proj_auth caa \nwhere ca.client_id = 12345 and ca.client_id = c.client_id and ca_type = 'zzz' \nand c.agency_id = 0 and ca.client_id = NVL( caa.client_id, ca.client_id) \nand proj_id = NVL( caa.proj_id, proj_id) and caa.contact_id = 7890"; +var sql_pp = require('../pretty-data').pd.sql(sql); +var sql_min = require('../pretty-data').pd.sqlmin(sql); + +console.log('\n==============================================================================\n'); +console.log('\n/*------- Original SQL string: -------*/\n\n' + sql + '\n'); +console.log('\n/*------- Beautified SQL: -------------*/\n\n' + sql_pp + '\n'); +console.log('\n/*------- Minified SQL: ---------------*/\n\n' + sql_min + '\n'); +console.log('\n===============================================================================\n'); diff --git a/config/tizen/tpk-tools/cli/node_modules/pretty-data/test/test_xml.js b/config/tizen/tpk-tools/cli/node_modules/pretty-data/test/test_xml.js new file mode 100644 index 0000000..7ac1322 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/pretty-data/test/test_xml.js @@ -0,0 +1,12 @@ + +var xml = ' bbb ]]>', + pp_xml = require('../pretty-data').pd.xml(xml), + pp_xmlmin_com = require('../pretty-data').pd.xmlmin(xml,true), + pp_xmlmin = require('../pretty-data').pd.xmlmin(xml); + +console.log('\n==============================================================================\n'); +console.log('\n/*------- Original XML string: -------*/\n\n' + xml + '\n'); +console.log('\n/*------- Beautified XML -------------*/\n\n' + pp_xml + '\n'); +console.log('\n/*------- Minified XML with preserved comments: -------*/\n\n' + pp_xmlmin_com + '\n'); +console.log('\n/*------- Minified XML with deleted comments: ---------*/\n\n' + pp_xmlmin + '\n'); +console.log('\n===============================================================================\n'); diff --git a/config/tizen/tpk-tools/cli/node_modules/q/CHANGES.md b/config/tizen/tpk-tools/cli/node_modules/q/CHANGES.md new file mode 100644 index 0000000..cd351fd --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/q/CHANGES.md @@ -0,0 +1,786 @@ + +## 1.4.1 + + - Address an issue that prevented Q from being used as a ` + + diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/examples/test.xml b/config/tizen/tpk-tools/cli/node_modules/sax/examples/test.xml new file mode 100644 index 0000000..801292d --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/examples/test.xml @@ -0,0 +1,1254 @@ + + +]> + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + + Some Text + + + + + + + are ok in here. ]]> + + Pre-Text & Inlined text Post-text. +  + + \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/lib/sax.js b/config/tizen/tpk-tools/cli/node_modules/sax/lib/sax.js new file mode 100644 index 0000000..17fb08e --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/lib/sax.js @@ -0,0 +1,1006 @@ +// wrapper for non-node envs +;(function (sax) { + +sax.parser = function (strict, opt) { return new SAXParser(strict, opt) } +sax.SAXParser = SAXParser +sax.SAXStream = SAXStream +sax.createStream = createStream + +// When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns. +// When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)), +// since that's the earliest that a buffer overrun could occur. This way, checks are +// as rare as required, but as often as necessary to ensure never crossing this bound. +// Furthermore, buffers are only tested at most once per write(), so passing a very +// large string into write() might have undesirable effects, but this is manageable by +// the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme +// edge case, result in creating at most one complete copy of the string passed in. +// Set to Infinity to have unlimited buffers. +sax.MAX_BUFFER_LENGTH = 64 * 1024 + +var buffers = [ + "comment", "sgmlDecl", "textNode", "tagName", "doctype", + "procInstName", "procInstBody", "entity", "attribName", + "attribValue", "cdata", "script" +] + +sax.EVENTS = // for discoverability. + [ "text" + , "processinginstruction" + , "sgmldeclaration" + , "doctype" + , "comment" + , "attribute" + , "opentag" + , "closetag" + , "opencdata" + , "cdata" + , "closecdata" + , "error" + , "end" + , "ready" + , "script" + , "opennamespace" + , "closenamespace" + ] + +function SAXParser (strict, opt) { + if (!(this instanceof SAXParser)) return new SAXParser(strict, opt) + + var parser = this + clearBuffers(parser) + parser.q = parser.c = "" + parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH + parser.opt = opt || {} + parser.tagCase = parser.opt.lowercasetags ? "toLowerCase" : "toUpperCase" + parser.tags = [] + parser.closed = parser.closedRoot = parser.sawRoot = false + parser.tag = parser.error = null + parser.strict = !!strict + parser.noscript = !!(strict || parser.opt.noscript) + parser.state = S.BEGIN + parser.ENTITIES = Object.create(sax.ENTITIES) + parser.attribList = [] + + // namespaces form a prototype chain. + // it always points at the current tag, + // which protos to its parent tag. + if (parser.opt.xmlns) parser.ns = Object.create(rootNS) + + // mostly just for error reporting + parser.position = parser.line = parser.column = 0 + emit(parser, "onready") +} + +if (!Object.create) Object.create = function (o) { + function f () { this.__proto__ = o } + f.prototype = o + return new f +} + +if (!Object.getPrototypeOf) Object.getPrototypeOf = function (o) { + return o.__proto__ +} + +if (!Object.keys) Object.keys = function (o) { + var a = [] + for (var i in o) if (o.hasOwnProperty(i)) a.push(i) + return a +} + +function checkBufferLength (parser) { + var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10) + , maxActual = 0 + for (var i = 0, l = buffers.length; i < l; i ++) { + var len = parser[buffers[i]].length + if (len > maxAllowed) { + // Text/cdata nodes can get big, and since they're buffered, + // we can get here under normal conditions. + // Avoid issues by emitting the text node now, + // so at least it won't get any bigger. + switch (buffers[i]) { + case "textNode": + closeText(parser) + break + + case "cdata": + emitNode(parser, "oncdata", parser.cdata) + parser.cdata = "" + break + + case "script": + emitNode(parser, "onscript", parser.script) + parser.script = "" + break + + default: + error(parser, "Max buffer length exceeded: "+buffers[i]) + } + } + maxActual = Math.max(maxActual, len) + } + // schedule the next check for the earliest possible buffer overrun. + parser.bufferCheckPosition = (sax.MAX_BUFFER_LENGTH - maxActual) + + parser.position +} + +function clearBuffers (parser) { + for (var i = 0, l = buffers.length; i < l; i ++) { + parser[buffers[i]] = "" + } +} + +SAXParser.prototype = + { end: function () { end(this) } + , write: write + , resume: function () { this.error = null; return this } + , close: function () { return this.write(null) } + , end: function () { return this.write(null) } + } + +try { + var Stream = require("stream").Stream +} catch (ex) { + var Stream = function () {} +} + + +var streamWraps = sax.EVENTS.filter(function (ev) { + return ev !== "error" && ev !== "end" +}) + +function createStream (strict, opt) { + return new SAXStream(strict, opt) +} + +function SAXStream (strict, opt) { + if (!(this instanceof SAXStream)) return new SAXStream(strict, opt) + + Stream.apply(me) + + this._parser = new SAXParser(strict, opt) + this.writable = true + this.readable = true + + + var me = this + + this._parser.onend = function () { + me.emit("end") + } + + this._parser.onerror = function (er) { + me.emit("error", er) + + // if didn't throw, then means error was handled. + // go ahead and clear error, so we can write again. + me._parser.error = null + } + + streamWraps.forEach(function (ev) { + Object.defineProperty(me, "on" + ev, { + get: function () { return me._parser["on" + ev] }, + set: function (h) { + if (!h) { + me.removeAllListeners(ev) + return me._parser["on"+ev] = h + } + me.on(ev, h) + }, + enumerable: true, + configurable: false + }) + }) +} + +SAXStream.prototype = Object.create(Stream.prototype, + { constructor: { value: SAXStream } }) + +SAXStream.prototype.write = function (data) { + this._parser.write(data.toString()) + this.emit("data", data) + return true +} + +SAXStream.prototype.end = function (chunk) { + if (chunk && chunk.length) this._parser.write(chunk.toString()) + this._parser.end() + return true +} + +SAXStream.prototype.on = function (ev, handler) { + var me = this + if (!me._parser["on"+ev] && streamWraps.indexOf(ev) !== -1) { + me._parser["on"+ev] = function () { + var args = arguments.length === 1 ? [arguments[0]] + : Array.apply(null, arguments) + args.splice(0, 0, ev) + me.emit.apply(me, args) + } + } + + return Stream.prototype.on.call(me, ev, handler) +} + + + +// character classes and tokens +var whitespace = "\r\n\t " + // this really needs to be replaced with character classes. + // XML allows all manner of ridiculous numbers and digits. + , number = "0124356789" + , letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + // (Letter | "_" | ":") + , nameStart = letter+"_:" + , nameBody = nameStart+number+"-." + , quote = "'\"" + , entity = number+letter+"#" + , attribEnd = whitespace + ">" + , CDATA = "[CDATA[" + , DOCTYPE = "DOCTYPE" + , XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace" + , XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/" + , rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE } + +// turn all the string character sets into character class objects. +whitespace = charClass(whitespace) +number = charClass(number) +letter = charClass(letter) +nameStart = charClass(nameStart) +nameBody = charClass(nameBody) +quote = charClass(quote) +entity = charClass(entity) +attribEnd = charClass(attribEnd) + +function charClass (str) { + return str.split("").reduce(function (s, c) { + s[c] = true + return s + }, {}) +} + +function is (charclass, c) { + return charclass[c] +} + +function not (charclass, c) { + return !charclass[c] +} + +var S = 0 +sax.STATE = +{ BEGIN : S++ +, TEXT : S++ // general stuff +, TEXT_ENTITY : S++ // & and such. +, OPEN_WAKA : S++ // < +, SGML_DECL : S++ // +, SCRIPT : S++ // " + , expect : + [ [ "opentag", { name: "xml", attributes: {} } ] + , [ "opentag", { name: "script", attributes: {} } ] + , [ "text", "hello world" ] + , [ "closetag", "script" ] + , [ "closetag", "xml" ] + ] + , strict : false + , opt : { lowercasetags: true, noscript: true } + } + ) + +require(__dirname).test + ( { xml : "" + , expect : + [ [ "opentag", { name: "xml", attributes: {} } ] + , [ "opentag", { name: "script", attributes: {} } ] + , [ "opencdata", undefined ] + , [ "cdata", "hello world" ] + , [ "closecdata", undefined ] + , [ "closetag", "script" ] + , [ "closetag", "xml" ] + ] + , strict : false + , opt : { lowercasetags: true, noscript: true } + } + ) + diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/parser-position.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/parser-position.js new file mode 100644 index 0000000..e4a68b1 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/parser-position.js @@ -0,0 +1,28 @@ +var sax = require("../lib/sax"), + assert = require("assert") + +function testPosition(chunks, expectedEvents) { + var parser = sax.parser(); + expectedEvents.forEach(function(expectation) { + parser['on' + expectation[0]] = function() { + for (var prop in expectation[1]) { + assert.equal(parser[prop], expectation[1][prop]); + } + } + }); + chunks.forEach(function(chunk) { + parser.write(chunk); + }); +}; + +testPosition(['
abcdefgh
'], + [ ['opentag', { position: 5, startTagPosition: 1 }] + , ['text', { position: 19, startTagPosition: 14 }] + , ['closetag', { position: 19, startTagPosition: 14 }] + ]); + +testPosition(['
abcde','fgh
'], + [ ['opentag', { position: 5, startTagPosition: 1 }] + , ['text', { position: 19, startTagPosition: 14 }] + , ['closetag', { position: 19, startTagPosition: 14 }] + ]); diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/script.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/script.js new file mode 100644 index 0000000..464c051 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/script.js @@ -0,0 +1,12 @@ +require(__dirname).test({ + xml : "", + expect : [ + ["opentag", {"name": "HTML","attributes": {}}], + ["opentag", {"name": "HEAD","attributes": {}}], + ["opentag", {"name": "SCRIPT","attributes": {}}], + ["script", "if (1 < 0) { console.log('elo there'); }"], + ["closetag", "SCRIPT"], + ["closetag", "HEAD"], + ["closetag", "HTML"] + ] +}); diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/self-closing-child-strict.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/self-closing-child-strict.js new file mode 100644 index 0000000..ce9c045 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/self-closing-child-strict.js @@ -0,0 +1,40 @@ + +require(__dirname).test({ + xml : + ""+ + "" + + "" + + "" + + "" + + "=(|)" + + "" + + "", + expect : [ + ["opentag", { + "name": "root", + "attributes": {} + }], + ["opentag", { + "name": "child", + "attributes": {} + }], + ["opentag", { + "name": "haha", + "attributes": {} + }], + ["closetag", "haha"], + ["closetag", "child"], + ["opentag", { + "name": "monkey", + "attributes": {} + }], + ["text", "=(|)"], + ["closetag", "monkey"], + ["closetag", "root"], + ["end"], + ["ready"] + ], + strict : true, + opt : {} +}); + diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/self-closing-child.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/self-closing-child.js new file mode 100644 index 0000000..bc6b52b --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/self-closing-child.js @@ -0,0 +1,40 @@ + +require(__dirname).test({ + xml : + ""+ + "" + + "" + + "" + + "" + + "=(|)" + + "" + + "", + expect : [ + ["opentag", { + "name": "ROOT", + "attributes": {} + }], + ["opentag", { + "name": "CHILD", + "attributes": {} + }], + ["opentag", { + "name": "HAHA", + "attributes": {} + }], + ["closetag", "HAHA"], + ["closetag", "CHILD"], + ["opentag", { + "name": "MONKEY", + "attributes": {} + }], + ["text", "=(|)"], + ["closetag", "MONKEY"], + ["closetag", "ROOT"], + ["end"], + ["ready"] + ], + strict : false, + opt : {} +}); + diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/self-closing-tag.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/self-closing-tag.js new file mode 100644 index 0000000..b2c5736 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/self-closing-tag.js @@ -0,0 +1,25 @@ + +require(__dirname).test({ + xml : + " "+ + " "+ + " "+ + " "+ + "=(|) "+ + ""+ + " ", + expect : [ + ["opentag", {name:"ROOT", attributes:{}}], + ["opentag", {name:"HAHA", attributes:{}}], + ["closetag", "HAHA"], + ["opentag", {name:"HAHA", attributes:{}}], + ["closetag", "HAHA"], + // ["opentag", {name:"HAHA", attributes:{}}], + // ["closetag", "HAHA"], + ["opentag", {name:"MONKEY", attributes:{}}], + ["text", "=(|)"], + ["closetag", "MONKEY"], + ["closetag", "ROOT"] + ], + opt : { trim : true } +}); \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/stray-ending.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/stray-ending.js new file mode 100644 index 0000000..6b0aa7f --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/stray-ending.js @@ -0,0 +1,17 @@ +// stray ending tags should just be ignored in non-strict mode. +// https://github.com/isaacs/sax-js/issues/32 +require(__dirname).test + ( { xml : + "" + , expect : + [ [ "opentag", { name: "A", attributes: {} } ] + , [ "opentag", { name: "B", attributes: {} } ] + , [ "text", "" ] + , [ "closetag", "B" ] + , [ "closetag", "A" ] + ] + , strict : false + , opt : {} + } + ) + diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/trailing-non-whitespace.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/trailing-non-whitespace.js new file mode 100644 index 0000000..3e1fb2e --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/trailing-non-whitespace.js @@ -0,0 +1,17 @@ + +require(__dirname).test({ + xml : "Welcome, to monkey land", + expect : [ + ["opentag", { + "name": "SPAN", + "attributes": {} + }], + ["text", "Welcome,"], + ["closetag", "SPAN"], + ["text", " to monkey land"], + ["end"], + ["ready"] + ], + strict : false, + opt : {} +}); diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/unquoted.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/unquoted.js new file mode 100644 index 0000000..79f1d0b --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/unquoted.js @@ -0,0 +1,17 @@ +// unquoted attributes should be ok in non-strict mode +// https://github.com/isaacs/sax-js/issues/31 +require(__dirname).test + ( { xml : + "" + , expect : + [ [ "attribute", { name: "class", value: "test" } ] + , [ "attribute", { name: "hello", value: "world" } ] + , [ "opentag", { name: "SPAN", + attributes: { class: "test", hello: "world" } } ] + , [ "closetag", "SPAN" ] + ] + , strict : false + , opt : {} + } + ) + diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-issue-41.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-issue-41.js new file mode 100644 index 0000000..596d82b --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-issue-41.js @@ -0,0 +1,67 @@ +var t = require(__dirname) + + , xmls = // should be the same both ways. + [ "" + , "" ] + + , ex1 = + [ [ "opennamespace" + , { prefix: "a" + , uri: "http://ATTRIBUTE" + } + ] + , [ "attribute" + , { name: "xmlns:a" + , value: "http://ATTRIBUTE" + , prefix: "xmlns" + , local: "a" + , uri: "http://www.w3.org/2000/xmlns/" + } + ] + , [ "attribute" + , { name: "a:attr" + , local: "attr" + , prefix: "a" + , uri: "http://ATTRIBUTE" + , value: "value" + } + ] + , [ "opentag" + , { name: "parent" + , uri: "" + , prefix: "" + , local: "parent" + , attributes: + { "a:attr": + { name: "a:attr" + , local: "attr" + , prefix: "a" + , uri: "http://ATTRIBUTE" + , value: "value" + } + , "xmlns:a": + { name: "xmlns:a" + , local: "a" + , prefix: "xmlns" + , uri: "http://www.w3.org/2000/xmlns/" + , value: "http://ATTRIBUTE" + } + } + , ns: {"a": "http://ATTRIBUTE"} + } + ] + , ["closetag", "parent"] + , ["closenamespace", { prefix: "a", uri: "http://ATTRIBUTE" }] + ] + + // swap the order of elements 2 and 1 + , ex2 = [ex1[0], ex1[2], ex1[1]].concat(ex1.slice(3)) + , expected = [ex1, ex2] + +xmls.forEach(function (x, i) { + t.test({ xml: x + , expect: expected[i] + , strict: true + , opt: { xmlns: true } + }) +}) diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-rebinding.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-rebinding.js new file mode 100644 index 0000000..f464876 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-rebinding.js @@ -0,0 +1,59 @@ + +require(__dirname).test + ( { xml : + ""+ + ""+ + ""+ + ""+ + ""+ + "" + + , expect : + [ [ "opennamespace", { prefix: "x", uri: "x1" } ] + , [ "opennamespace", { prefix: "y", uri: "y1" } ] + , [ "attribute", { name: "xmlns:x", value: "x1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } ] + , [ "attribute", { name: "xmlns:y", value: "y1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "y" } ] + , [ "attribute", { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } ] + , [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ] + , [ "opentag", { name: "root", uri: "", prefix: "", local: "root", + attributes: { "xmlns:x": { name: "xmlns:x", value: "x1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } + , "xmlns:y": { name: "xmlns:y", value: "y1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "y" } + , "x:a": { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } + , "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } }, + ns: { x: 'x1', y: 'y1' } } ] + + , [ "opennamespace", { prefix: "x", uri: "x2" } ] + , [ "attribute", { name: "xmlns:x", value: "x2", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } ] + , [ "opentag", { name: "rebind", uri: "", prefix: "", local: "rebind", + attributes: { "xmlns:x": { name: "xmlns:x", value: "x2", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } }, + ns: { x: 'x2' } } ] + + , [ "attribute", { name: "x:a", value: "x2", uri: "x2", prefix: "x", local: "a" } ] + , [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ] + , [ "opentag", { name: "check", uri: "", prefix: "", local: "check", + attributes: { "x:a": { name: "x:a", value: "x2", uri: "x2", prefix: "x", local: "a" } + , "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } }, + ns: { x: 'x2' } } ] + + , [ "closetag", "check" ] + + , [ "closetag", "rebind" ] + , [ "closenamespace", { prefix: "x", uri: "x2" } ] + + , [ "attribute", { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } ] + , [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ] + , [ "opentag", { name: "check", uri: "", prefix: "", local: "check", + attributes: { "x:a": { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } + , "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } }, + ns: { x: 'x1', y: 'y1' } } ] + , [ "closetag", "check" ] + + , [ "closetag", "root" ] + , [ "closenamespace", { prefix: "x", uri: "x1" } ] + , [ "closenamespace", { prefix: "y", uri: "y1" } ] + ] + , strict : true + , opt : { xmlns: true } + } + ) + diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-strict.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-strict.js new file mode 100644 index 0000000..4ad615b --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-strict.js @@ -0,0 +1,71 @@ + +require(__dirname).test + ( { xml : + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + "" + + , expect : + [ [ "opentag", { name: "root", prefix: "", local: "root", uri: "", + attributes: {}, ns: {} } ] + + , [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ] + , [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "", + attributes: { "attr": { name: "attr", value: "normal", uri: "", prefix: "", local: "attr", uri: "" } }, + ns: {} } ] + , [ "closetag", "plain" ] + + , [ "opennamespace", { prefix: "", uri: "uri:default" } ] + + , [ "attribute", { name: "xmlns", value: "uri:default", prefix: "xmlns", local: "", uri: "http://www.w3.org/2000/xmlns/" } ] + , [ "opentag", { name: "ns1", prefix: "", local: "ns1", uri: "uri:default", + attributes: { "xmlns": { name: "xmlns", value: "uri:default", prefix: "xmlns", local: "", uri: "http://www.w3.org/2000/xmlns/" } }, + ns: { "": "uri:default" } } ] + + , [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "uri:default" } ] + , [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "uri:default", ns: { '': 'uri:default' }, + attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "uri:default" } } } ] + , [ "closetag", "plain" ] + + , [ "closetag", "ns1" ] + + , [ "closenamespace", { prefix: "", uri: "uri:default" } ] + + , [ "opennamespace", { prefix: "a", uri: "uri:nsa" } ] + + , [ "attribute", { name: "xmlns:a", value: "uri:nsa", prefix: "xmlns", local: "a", uri: "http://www.w3.org/2000/xmlns/" } ] + + , [ "opentag", { name: "ns2", prefix: "", local: "ns2", uri: "", + attributes: { "xmlns:a": { name: "xmlns:a", value: "uri:nsa", prefix: "xmlns", local: "a", uri: "http://www.w3.org/2000/xmlns/" } }, + ns: { a: "uri:nsa" } } ] + + , [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ] + , [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "", + attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } }, + ns: { a: 'uri:nsa' } } ] + , [ "closetag", "plain" ] + + , [ "attribute", { name: "a:attr", value: "namespaced", prefix: "a", local: "attr", uri: "uri:nsa" } ] + , [ "opentag", { name: "a:ns", prefix: "a", local: "ns", uri: "uri:nsa", + attributes: { "a:attr": { name: "a:attr", value: "namespaced", prefix: "a", local: "attr", uri: "uri:nsa" } }, + ns: { a: 'uri:nsa' } } ] + , [ "closetag", "a:ns" ] + + , [ "closetag", "ns2" ] + + , [ "closenamespace", { prefix: "a", uri: "uri:nsa" } ] + + , [ "closetag", "root" ] + ] + , strict : true + , opt : { xmlns: true } + } + ) + diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-unbound.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-unbound.js new file mode 100644 index 0000000..2944b87 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-unbound.js @@ -0,0 +1,15 @@ + +require(__dirname).test( + { strict : true + , opt : { xmlns: true } + , expect : + [ ["error", "Unbound namespace prefix: \"unbound\"\nLine: 0\nColumn: 28\nChar: >"] + + , [ "attribute", { name: "unbound:attr", value: "value", uri: "unbound", prefix: "unbound", local: "attr" } ] + , [ "opentag", { name: "root", uri: "", prefix: "", local: "root", + attributes: { "unbound:attr": { name: "unbound:attr", value: "value", uri: "unbound", prefix: "unbound", local: "attr" } }, + ns: {} } ] + , [ "closetag", "root" ] + ] + } +).write("") diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js new file mode 100644 index 0000000..16da771 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js @@ -0,0 +1,35 @@ +require(__dirname).test( + { xml : "" + , expect : + [ [ "attribute" + , { name: "xml:lang" + , local: "lang" + , prefix: "xml" + , uri: "http://www.w3.org/XML/1998/namespace" + , value: "en" + } + ] + , [ "opentag" + , { name: "root" + , uri: "" + , prefix: "" + , local: "root" + , attributes: + { "xml:lang": + { name: "xml:lang" + , local: "lang" + , prefix: "xml" + , uri: "http://www.w3.org/XML/1998/namespace" + , value: "en" + } + } + , ns: {} + } + ] + , ["closetag", "root"] + ] + , strict : true + , opt : { xmlns: true } + } +) + diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-xml-default-prefix.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-xml-default-prefix.js new file mode 100644 index 0000000..9a1ce1b --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-xml-default-prefix.js @@ -0,0 +1,20 @@ +require(__dirname).test( + { xml : "" + , expect : + [ + [ "opentag" + , { name: "xml:root" + , uri: "http://www.w3.org/XML/1998/namespace" + , prefix: "xml" + , local: "root" + , attributes: {} + , ns: {} + } + ] + , ["closetag", "xml:root"] + ] + , strict : true + , opt : { xmlns: true } + } +) + diff --git a/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-xml-default-redefine.js b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-xml-default-redefine.js new file mode 100644 index 0000000..1eba9c7 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/sax/test/xmlns-xml-default-redefine.js @@ -0,0 +1,40 @@ +require(__dirname).test( + { xml : "" + , expect : + [ ["error" + , "xml: prefix must be bound to http://www.w3.org/XML/1998/namespace\n" + + "Actual: ERROR\n" + + "Line: 0\nColumn: 27\nChar: '" + ] + , [ "attribute" + , { name: "xmlns:xml" + , local: "xml" + , prefix: "xmlns" + , uri: "http://www.w3.org/2000/xmlns/" + , value: "ERROR" + } + ] + , [ "opentag" + , { name: "xml:root" + , uri: "http://www.w3.org/XML/1998/namespace" + , prefix: "xml" + , local: "root" + , attributes: + { "xmlns:xml": + { name: "xmlns:xml" + , local: "xml" + , prefix: "xmlns" + , uri: "http://www.w3.org/2000/xmlns/" + , value: "ERROR" + } + } + , ns: {} + } + ] + , ["closetag", "xml:root"] + ] + , strict : true + , opt : { xmlns: true } + } +) + diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/.documentup.json b/config/tizen/tpk-tools/cli/node_modules/shelljs/.documentup.json new file mode 100644 index 0000000..57fe301 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/.documentup.json @@ -0,0 +1,6 @@ +{ + "name": "ShellJS", + "twitter": [ + "r2r" + ] +} diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/.jshintrc b/config/tizen/tpk-tools/cli/node_modules/shelljs/.jshintrc new file mode 100644 index 0000000..a80c559 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/.jshintrc @@ -0,0 +1,7 @@ +{ + "loopfunc": true, + "sub": true, + "undef": true, + "unused": true, + "node": true +} \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/.npmignore b/config/tizen/tpk-tools/cli/node_modules/shelljs/.npmignore new file mode 100644 index 0000000..6b20c38 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/.npmignore @@ -0,0 +1,2 @@ +test/ +tmp/ \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/.travis.yml b/config/tizen/tpk-tools/cli/node_modules/shelljs/.travis.yml new file mode 100644 index 0000000..1b3280a --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.10" + - "0.11" + - "0.12" + diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/LICENSE b/config/tizen/tpk-tools/cli/node_modules/shelljs/LICENSE new file mode 100644 index 0000000..1b35ee9 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2012, Artur Adib +All rights reserved. + +You may use this project under the terms of the New BSD license as follows: + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Artur Adib nor the + names of the contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL ARTUR ADIB BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/README.md b/config/tizen/tpk-tools/cli/node_modules/shelljs/README.md new file mode 100644 index 0000000..d08d13e --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/README.md @@ -0,0 +1,579 @@ +# ShellJS - Unix shell commands for Node.js [![Build Status](https://secure.travis-ci.org/arturadib/shelljs.png)](http://travis-ci.org/arturadib/shelljs) + +ShellJS is a portable **(Windows/Linux/OS X)** implementation of Unix shell commands on top of the Node.js API. You can use it to eliminate your shell script's dependency on Unix while still keeping its familiar and powerful commands. You can also install it globally so you can run it from outside Node projects - say goodbye to those gnarly Bash scripts! + +The project is [unit-tested](http://travis-ci.org/arturadib/shelljs) and battled-tested in projects like: + ++ [PDF.js](http://github.com/mozilla/pdf.js) - Firefox's next-gen PDF reader ++ [Firebug](http://getfirebug.com/) - Firefox's infamous debugger ++ [JSHint](http://jshint.com) - Most popular JavaScript linter ++ [Zepto](http://zeptojs.com) - jQuery-compatible JavaScript library for modern browsers ++ [Yeoman](http://yeoman.io/) - Web application stack and development tool ++ [Deployd.com](http://deployd.com) - Open source PaaS for quick API backend generation + +and [many more](https://npmjs.org/browse/depended/shelljs). + +Connect with [@r2r](http://twitter.com/r2r) on Twitter for questions, suggestions, etc. + +## Installing + +Via npm: + +```bash +$ npm install [-g] shelljs +``` + +If the global option `-g` is specified, the binary `shjs` will be installed. This makes it possible to +run ShellJS scripts much like any shell script from the command line, i.e. without requiring a `node_modules` folder: + +```bash +$ shjs my_script +``` + +You can also just copy `shell.js` into your project's directory, and `require()` accordingly. + + +## Examples + +### JavaScript + +```javascript +require('shelljs/global'); + +if (!which('git')) { + echo('Sorry, this script requires git'); + exit(1); +} + +// Copy files to release dir +mkdir('-p', 'out/Release'); +cp('-R', 'stuff/*', 'out/Release'); + +// Replace macros in each .js file +cd('lib'); +ls('*.js').forEach(function(file) { + sed('-i', 'BUILD_VERSION', 'v0.1.2', file); + sed('-i', /.*REMOVE_THIS_LINE.*\n/, '', file); + sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, cat('macro.js'), file); +}); +cd('..'); + +// Run external tool synchronously +if (exec('git commit -am "Auto-commit"').code !== 0) { + echo('Error: Git commit failed'); + exit(1); +} +``` + +### CoffeeScript + +```coffeescript +require 'shelljs/global' + +if not which 'git' + echo 'Sorry, this script requires git' + exit 1 + +# Copy files to release dir +mkdir '-p', 'out/Release' +cp '-R', 'stuff/*', 'out/Release' + +# Replace macros in each .js file +cd 'lib' +for file in ls '*.js' + sed '-i', 'BUILD_VERSION', 'v0.1.2', file + sed '-i', /.*REMOVE_THIS_LINE.*\n/, '', file + sed '-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, cat 'macro.js', file +cd '..' + +# Run external tool synchronously +if (exec 'git commit -am "Auto-commit"').code != 0 + echo 'Error: Git commit failed' + exit 1 +``` + +## Global vs. Local + +The example above uses the convenience script `shelljs/global` to reduce verbosity. If polluting your global namespace is not desirable, simply require `shelljs`. + +Example: + +```javascript +var shell = require('shelljs'); +shell.echo('hello world'); +``` + +## Make tool + +A convenience script `shelljs/make` is also provided to mimic the behavior of a Unix Makefile. In this case all shell objects are global, and command line arguments will cause the script to execute only the corresponding function in the global `target` object. To avoid redundant calls, target functions are executed only once per script. + +Example (CoffeeScript): + +```coffeescript +require 'shelljs/make' + +target.all = -> + target.bundle() + target.docs() + +target.bundle = -> + cd __dirname + mkdir 'build' + cd 'lib' + (cat '*.js').to '../build/output.js' + +target.docs = -> + cd __dirname + mkdir 'docs' + cd 'lib' + for file in ls '*.js' + text = grep '//@', file # extract special comments + text.replace '//@', '' # remove comment tags + text.to 'docs/my_docs.md' +``` + +To run the target `all`, call the above script without arguments: `$ node make`. To run the target `docs`: `$ node make docs`. + +You can also pass arguments to your targets by using the `--` separator. For example, to pass `arg1` and `arg2` to a target `bundle`, do `$ node make bundle -- arg1 arg2`: + +```javascript +require('shelljs/make'); + +target.bundle = function(argsArray) { + // argsArray = ['arg1', 'arg2'] + /* ... */ +} +``` + + + + + +## Command reference + + +All commands run synchronously, unless otherwise stated. + + +### cd('dir') +Changes to directory `dir` for the duration of the script + + +### pwd() +Returns the current directory. + + +### ls([options ,] path [,path ...]) +### ls([options ,] path_array) +Available options: + ++ `-R`: recursive ++ `-A`: all files (include files beginning with `.`, except for `.` and `..`) + +Examples: + +```javascript +ls('projs/*.js'); +ls('-R', '/users/me', '/tmp'); +ls('-R', ['/users/me', '/tmp']); // same as above +``` + +Returns array of files in the given path, or in current directory if no path provided. + + +### find(path [,path ...]) +### find(path_array) +Examples: + +```javascript +find('src', 'lib'); +find(['src', 'lib']); // same as above +find('.').filter(function(file) { return file.match(/\.js$/); }); +``` + +Returns array of all files (however deep) in the given paths. + +The main difference from `ls('-R', path)` is that the resulting file names +include the base directories, e.g. `lib/resources/file1` instead of just `file1`. + + +### cp([options ,] source [,source ...], dest) +### cp([options ,] source_array, dest) +Available options: + ++ `-f`: force ++ `-r, -R`: recursive + +Examples: + +```javascript +cp('file1', 'dir1'); +cp('-Rf', '/tmp/*', '/usr/local/*', '/home/tmp'); +cp('-Rf', ['/tmp/*', '/usr/local/*'], '/home/tmp'); // same as above +``` + +Copies files. The wildcard `*` is accepted. + + +### rm([options ,] file [, file ...]) +### rm([options ,] file_array) +Available options: + ++ `-f`: force ++ `-r, -R`: recursive + +Examples: + +```javascript +rm('-rf', '/tmp/*'); +rm('some_file.txt', 'another_file.txt'); +rm(['some_file.txt', 'another_file.txt']); // same as above +``` + +Removes files. The wildcard `*` is accepted. + + +### mv(source [, source ...], dest') +### mv(source_array, dest') +Available options: + ++ `f`: force + +Examples: + +```javascript +mv('-f', 'file', 'dir/'); +mv('file1', 'file2', 'dir/'); +mv(['file1', 'file2'], 'dir/'); // same as above +``` + +Moves files. The wildcard `*` is accepted. + + +### mkdir([options ,] dir [, dir ...]) +### mkdir([options ,] dir_array) +Available options: + ++ `p`: full path (will create intermediate dirs if necessary) + +Examples: + +```javascript +mkdir('-p', '/tmp/a/b/c/d', '/tmp/e/f/g'); +mkdir('-p', ['/tmp/a/b/c/d', '/tmp/e/f/g']); // same as above +``` + +Creates directories. + + +### test(expression) +Available expression primaries: + ++ `'-b', 'path'`: true if path is a block device ++ `'-c', 'path'`: true if path is a character device ++ `'-d', 'path'`: true if path is a directory ++ `'-e', 'path'`: true if path exists ++ `'-f', 'path'`: true if path is a regular file ++ `'-L', 'path'`: true if path is a symbolic link ++ `'-p', 'path'`: true if path is a pipe (FIFO) ++ `'-S', 'path'`: true if path is a socket + +Examples: + +```javascript +if (test('-d', path)) { /* do something with dir */ }; +if (!test('-f', path)) continue; // skip if it's a regular file +``` + +Evaluates expression using the available primaries and returns corresponding value. + + +### cat(file [, file ...]) +### cat(file_array) + +Examples: + +```javascript +var str = cat('file*.txt'); +var str = cat('file1', 'file2'); +var str = cat(['file1', 'file2']); // same as above +``` + +Returns a string containing the given file, or a concatenated string +containing the files if more than one file is given (a new line character is +introduced between each file). Wildcard `*` accepted. + + +### 'string'.to(file) + +Examples: + +```javascript +cat('input.txt').to('output.txt'); +``` + +Analogous to the redirection operator `>` in Unix, but works with JavaScript strings (such as +those returned by `cat`, `grep`, etc). _Like Unix redirections, `to()` will overwrite any existing file!_ + + +### 'string'.toEnd(file) + +Examples: + +```javascript +cat('input.txt').toEnd('output.txt'); +``` + +Analogous to the redirect-and-append operator `>>` in Unix, but works with JavaScript strings (such as +those returned by `cat`, `grep`, etc). + + +### sed([options ,] search_regex, replacement, file) +Available options: + ++ `-i`: Replace contents of 'file' in-place. _Note that no backups will be created!_ + +Examples: + +```javascript +sed('-i', 'PROGRAM_VERSION', 'v0.1.3', 'source.js'); +sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js'); +``` + +Reads an input string from `file` and performs a JavaScript `replace()` on the input +using the given search regex and replacement string or function. Returns the new string after replacement. + + +### grep([options ,] regex_filter, file [, file ...]) +### grep([options ,] regex_filter, file_array) +Available options: + ++ `-v`: Inverse the sense of the regex and print the lines not matching the criteria. + +Examples: + +```javascript +grep('-v', 'GLOBAL_VARIABLE', '*.js'); +grep('GLOBAL_VARIABLE', '*.js'); +``` + +Reads input string from given files and returns a string containing all lines of the +file that match the given `regex_filter`. Wildcard `*` accepted. + + +### which(command) + +Examples: + +```javascript +var nodeExec = which('node'); +``` + +Searches for `command` in the system's PATH. On Windows looks for `.exe`, `.cmd`, and `.bat` extensions. +Returns string containing the absolute path to the command. + + +### echo(string [,string ...]) + +Examples: + +```javascript +echo('hello world'); +var str = echo('hello world'); +``` + +Prints string to stdout, and returns string with additional utility methods +like `.to()`. + + +### pushd([options,] [dir | '-N' | '+N']) + +Available options: + ++ `-n`: Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated. + +Arguments: + ++ `dir`: Makes the current working directory be the top of the stack, and then executes the equivalent of `cd dir`. ++ `+N`: Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. ++ `-N`: Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. + +Examples: + +```javascript +// process.cwd() === '/usr' +pushd('/etc'); // Returns /etc /usr +pushd('+1'); // Returns /usr /etc +``` + +Save the current directory on the top of the directory stack and then cd to `dir`. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack. + +### popd([options,] ['-N' | '+N']) + +Available options: + ++ `-n`: Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated. + +Arguments: + ++ `+N`: Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero. ++ `-N`: Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero. + +Examples: + +```javascript +echo(process.cwd()); // '/usr' +pushd('/etc'); // '/etc /usr' +echo(process.cwd()); // '/etc' +popd(); // '/usr' +echo(process.cwd()); // '/usr' +``` + +When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack. + +### dirs([options | '+N' | '-N']) + +Available options: + ++ `-c`: Clears the directory stack by deleting all of the elements. + +Arguments: + ++ `+N`: Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero. ++ `-N`: Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero. + +Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified. + +See also: pushd, popd + + +### ln(options, source, dest) +### ln(source, dest) +Available options: + ++ `s`: symlink ++ `f`: force + +Examples: + +```javascript +ln('file', 'newlink'); +ln('-sf', 'file', 'existing'); +``` + +Links source to dest. Use -f to force the link, should dest already exist. + + +### exit(code) +Exits the current process with the given exit code. + +### env['VAR_NAME'] +Object containing environment variables (both getter and setter). Shortcut to process.env. + +### exec(command [, options] [, callback]) +Available options (all `false` by default): + ++ `async`: Asynchronous execution. Defaults to true if a callback is provided. ++ `silent`: Do not echo program output to console. + +Examples: + +```javascript +var version = exec('node --version', {silent:true}).output; + +var child = exec('some_long_running_process', {async:true}); +child.stdout.on('data', function(data) { + /* ... do something with data ... */ +}); + +exec('some_long_running_process', function(code, output) { + console.log('Exit code:', code); + console.log('Program output:', output); +}); +``` + +Executes the given `command` _synchronously_, unless otherwise specified. +When in synchronous mode returns the object `{ code:..., output:... }`, containing the program's +`output` (stdout + stderr) and its exit `code`. Otherwise returns the child process object, and +the `callback` gets the arguments `(code, output)`. + +**Note:** For long-lived processes, it's best to run `exec()` asynchronously as +the current synchronous implementation uses a lot of CPU. This should be getting +fixed soon. + + +### chmod(octal_mode || octal_string, file) +### chmod(symbolic_mode, file) + +Available options: + ++ `-v`: output a diagnostic for every file processed ++ `-c`: like verbose but report only when a change is made ++ `-R`: change files and directories recursively + +Examples: + +```javascript +chmod(755, '/Users/brandon'); +chmod('755', '/Users/brandon'); // same as above +chmod('u+x', '/Users/brandon'); +``` + +Alters the permissions of a file or directory by either specifying the +absolute permissions in octal form or expressing the changes in symbols. +This command tries to mimic the POSIX behavior as much as possible. +Notable exceptions: + ++ In symbolic modes, 'a-r' and '-r' are identical. No consideration is + given to the umask. ++ There is no "quiet" option since default behavior is to run silent. + + +## Non-Unix commands + + +### tempdir() + +Examples: + +```javascript +var tmp = tempdir(); // "/tmp" for most *nix platforms +``` + +Searches and returns string containing a writeable, platform-dependent temporary directory. +Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir). + + +### error() +Tests if error occurred in the last command. Returns `null` if no error occurred, +otherwise returns string explaining the error + + +## Configuration + + +### config.silent +Example: + +```javascript +var sh = require('shelljs'); +var silentState = sh.config.silent; // save old silent state +sh.config.silent = true; +/* ... */ +sh.config.silent = silentState; // restore old silent state +``` + +Suppresses all command output if `true`, except for `echo()` calls. +Default is `false`. + +### config.fatal +Example: + +```javascript +require('shelljs/global'); +config.fatal = true; +cp('this_file_does_not_exist', '/dev/null'); // dies here +/* more commands... */ +``` + +If `true` the script will die on errors. Default is `false`. diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/RELEASE.md b/config/tizen/tpk-tools/cli/node_modules/shelljs/RELEASE.md new file mode 100644 index 0000000..69ef3fb --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/RELEASE.md @@ -0,0 +1,9 @@ +# Release steps + +* Ensure master passes CI tests +* Bump version in package.json. Any breaking change or new feature should bump minor (or even major). Non-breaking changes or fixes can just bump patch. +* Update README manually if the changes are not documented in-code. If so, run `scripts/generate-docs.js` +* Commit +* `$ git tag ` (see `git tag -l` for latest) +* `$ git push origin master --tags` +* `$ npm publish .` diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/bin/shjs b/config/tizen/tpk-tools/cli/node_modules/shelljs/bin/shjs new file mode 100755 index 0000000..d239a7a --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/bin/shjs @@ -0,0 +1,51 @@ +#!/usr/bin/env node +require('../global'); + +if (process.argv.length < 3) { + console.log('ShellJS: missing argument (script name)'); + console.log(); + process.exit(1); +} + +var args, + scriptName = process.argv[2]; +env['NODE_PATH'] = __dirname + '/../..'; + +if (!scriptName.match(/\.js/) && !scriptName.match(/\.coffee/)) { + if (test('-f', scriptName + '.js')) + scriptName += '.js'; + if (test('-f', scriptName + '.coffee')) + scriptName += '.coffee'; +} + +if (!test('-f', scriptName)) { + console.log('ShellJS: script not found ('+scriptName+')'); + console.log(); + process.exit(1); +} + +args = process.argv.slice(3); + +for (var i = 0, l = args.length; i < l; i++) { + if (args[i][0] !== "-"){ + args[i] = '"' + args[i] + '"'; // fixes arguments with multiple words + } +} + +if (scriptName.match(/\.coffee$/)) { + // + // CoffeeScript + // + if (which('coffee')) { + exec('coffee ' + scriptName + ' ' + args.join(' '), { async: true }); + } else { + console.log('ShellJS: CoffeeScript interpreter not found'); + console.log(); + process.exit(1); + } +} else { + // + // JavaScript + // + exec('node ' + scriptName + ' ' + args.join(' '), { async: true }); +} diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/global.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/global.js new file mode 100644 index 0000000..97f0033 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/global.js @@ -0,0 +1,3 @@ +var shell = require('./shell.js'); +for (var cmd in shell) + global[cmd] = shell[cmd]; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/make.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/make.js new file mode 100644 index 0000000..f78b4cf --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/make.js @@ -0,0 +1,56 @@ +require('./global'); + +global.config.fatal = true; +global.target = {}; + +var args = process.argv.slice(2), + targetArgs, + dashesLoc = args.indexOf('--'); + +// split args, everything after -- if only for targets +if (dashesLoc > -1) { + targetArgs = args.slice(dashesLoc + 1, args.length); + args = args.slice(0, dashesLoc); +} + +// This ensures we only execute the script targets after the entire script has +// been evaluated +setTimeout(function() { + var t; + + if (args.length === 1 && args[0] === '--help') { + console.log('Available targets:'); + for (t in global.target) + console.log(' ' + t); + return; + } + + // Wrap targets to prevent duplicate execution + for (t in global.target) { + (function(t, oldTarget){ + + // Wrap it + global.target[t] = function() { + if (oldTarget.done) + return; + oldTarget.done = true; + return oldTarget.apply(oldTarget, arguments); + }; + + })(t, global.target[t]); + } + + // Execute desired targets + if (args.length > 0) { + args.forEach(function(arg) { + if (arg in global.target) + global.target[arg](targetArgs); + else { + console.log('no such target: ' + arg); + } + }); + } else if ('all' in global.target) { + global.target.all(targetArgs); + } + +}, 0); diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/package.json b/config/tizen/tpk-tools/cli/node_modules/shelljs/package.json new file mode 100644 index 0000000..23e5614 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/package.json @@ -0,0 +1,96 @@ +{ + "_args": [ + [ + { + "raw": "shelljs@0.5.3", + "scope": null, + "escapedName": "shelljs", + "name": "shelljs", + "rawSpec": "0.5.3", + "spec": "0.5.3", + "type": "version" + }, + "/home/sumin/iotjs-tpk/cli" + ] + ], + "_from": "shelljs@0.5.3", + "_id": "shelljs@0.5.3", + "_inCache": true, + "_location": "/shelljs", + "_nodeVersion": "1.2.0", + "_npmUser": { + "name": "artur", + "email": "arturadib@gmail.com" + }, + "_npmVersion": "2.5.1", + "_phantomChildren": {}, + "_requested": { + "raw": "shelljs@0.5.3", + "scope": null, + "escapedName": "shelljs", + "name": "shelljs", + "rawSpec": "0.5.3", + "spec": "0.5.3", + "type": "version" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.5.3.tgz", + "_shasum": "c54982b996c76ef0c1e6b59fbdc5825f5b713113", + "_shrinkwrap": null, + "_spec": "shelljs@0.5.3", + "_where": "/home/sumin/iotjs-tpk/cli", + "author": { + "name": "Artur Adib", + "email": "arturadib@gmail.com" + }, + "bin": { + "shjs": "./bin/shjs" + }, + "bugs": { + "url": "https://github.com/arturadib/shelljs/issues" + }, + "dependencies": {}, + "description": "Portable Unix shell commands for Node.js", + "devDependencies": { + "jshint": "~2.1.11" + }, + "directories": {}, + "dist": { + "shasum": "c54982b996c76ef0c1e6b59fbdc5825f5b713113", + "tarball": "https://registry.npmjs.org/shelljs/-/shelljs-0.5.3.tgz" + }, + "engines": { + "node": ">=0.8.0" + }, + "gitHead": "22d0975040b9b8234755dc6e692d6869436e8485", + "homepage": "http://github.com/arturadib/shelljs", + "keywords": [ + "unix", + "shell", + "makefile", + "make", + "jake", + "synchronous" + ], + "license": "BSD*", + "main": "./shell.js", + "maintainers": [ + { + "name": "artur", + "email": "arturadib@gmail.com" + } + ], + "name": "shelljs", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/arturadib/shelljs.git" + }, + "scripts": { + "test": "node scripts/run-tests" + }, + "version": "0.5.3" +} diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/scripts/generate-docs.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/scripts/generate-docs.js new file mode 100755 index 0000000..532fed9 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/scripts/generate-docs.js @@ -0,0 +1,21 @@ +#!/usr/bin/env node +require('../global'); + +echo('Appending docs to README.md'); + +cd(__dirname + '/..'); + +// Extract docs from shell.js +var docs = grep('//@', 'shell.js'); + +docs = docs.replace(/\/\/\@include (.+)/g, function(match, path) { + var file = path.match('.js$') ? path : path+'.js'; + return grep('//@', file); +}); + +// Remove '//@' +docs = docs.replace(/\/\/\@ ?/g, ''); +// Append docs to README +sed('-i', /## Command reference(.|\n)*/, '## Command reference\n\n' + docs, 'README.md'); + +echo('All done.'); diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/scripts/run-tests.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/scripts/run-tests.js new file mode 100755 index 0000000..f9d31e0 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/scripts/run-tests.js @@ -0,0 +1,50 @@ +#!/usr/bin/env node +require('../global'); + +var path = require('path'); + +var failed = false; + +// +// Lint +// +JSHINT_BIN = './node_modules/jshint/bin/jshint'; +cd(__dirname + '/..'); + +if (!test('-f', JSHINT_BIN)) { + echo('JSHint not found. Run `npm install` in the root dir first.'); + exit(1); +} + +if (exec(JSHINT_BIN + ' *.js test/*.js').code !== 0) { + failed = true; + echo('*** JSHINT FAILED! (return code != 0)'); + echo(); +} else { + echo('All JSHint tests passed'); + echo(); +} + +// +// Unit tests +// +cd(__dirname + '/../test'); +ls('*.js').forEach(function(file) { + echo('Running test:', file); + if (exec('node ' + file).code !== 123) { // 123 avoids false positives (e.g. premature exit) + failed = true; + echo('*** TEST FAILED! (missing exit code "123")'); + echo(); + } +}); + +if (failed) { + echo(); + echo('*******************************************************'); + echo('WARNING: Some tests did not pass!'); + echo('*******************************************************'); + exit(1); +} else { + echo(); + echo('All tests passed.'); +} diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/shell.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/shell.js new file mode 100644 index 0000000..bdeb559 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/shell.js @@ -0,0 +1,159 @@ +// +// ShellJS +// Unix shell commands on top of Node's API +// +// Copyright (c) 2012 Artur Adib +// http://github.com/arturadib/shelljs +// + +var common = require('./src/common'); + + +//@ +//@ All commands run synchronously, unless otherwise stated. +//@ + +//@include ./src/cd +var _cd = require('./src/cd'); +exports.cd = common.wrap('cd', _cd); + +//@include ./src/pwd +var _pwd = require('./src/pwd'); +exports.pwd = common.wrap('pwd', _pwd); + +//@include ./src/ls +var _ls = require('./src/ls'); +exports.ls = common.wrap('ls', _ls); + +//@include ./src/find +var _find = require('./src/find'); +exports.find = common.wrap('find', _find); + +//@include ./src/cp +var _cp = require('./src/cp'); +exports.cp = common.wrap('cp', _cp); + +//@include ./src/rm +var _rm = require('./src/rm'); +exports.rm = common.wrap('rm', _rm); + +//@include ./src/mv +var _mv = require('./src/mv'); +exports.mv = common.wrap('mv', _mv); + +//@include ./src/mkdir +var _mkdir = require('./src/mkdir'); +exports.mkdir = common.wrap('mkdir', _mkdir); + +//@include ./src/test +var _test = require('./src/test'); +exports.test = common.wrap('test', _test); + +//@include ./src/cat +var _cat = require('./src/cat'); +exports.cat = common.wrap('cat', _cat); + +//@include ./src/to +var _to = require('./src/to'); +String.prototype.to = common.wrap('to', _to); + +//@include ./src/toEnd +var _toEnd = require('./src/toEnd'); +String.prototype.toEnd = common.wrap('toEnd', _toEnd); + +//@include ./src/sed +var _sed = require('./src/sed'); +exports.sed = common.wrap('sed', _sed); + +//@include ./src/grep +var _grep = require('./src/grep'); +exports.grep = common.wrap('grep', _grep); + +//@include ./src/which +var _which = require('./src/which'); +exports.which = common.wrap('which', _which); + +//@include ./src/echo +var _echo = require('./src/echo'); +exports.echo = _echo; // don't common.wrap() as it could parse '-options' + +//@include ./src/dirs +var _dirs = require('./src/dirs').dirs; +exports.dirs = common.wrap("dirs", _dirs); +var _pushd = require('./src/dirs').pushd; +exports.pushd = common.wrap('pushd', _pushd); +var _popd = require('./src/dirs').popd; +exports.popd = common.wrap("popd", _popd); + +//@include ./src/ln +var _ln = require('./src/ln'); +exports.ln = common.wrap('ln', _ln); + +//@ +//@ ### exit(code) +//@ Exits the current process with the given exit code. +exports.exit = process.exit; + +//@ +//@ ### env['VAR_NAME'] +//@ Object containing environment variables (both getter and setter). Shortcut to process.env. +exports.env = process.env; + +//@include ./src/exec +var _exec = require('./src/exec'); +exports.exec = common.wrap('exec', _exec, {notUnix:true}); + +//@include ./src/chmod +var _chmod = require('./src/chmod'); +exports.chmod = common.wrap('chmod', _chmod); + + + +//@ +//@ ## Non-Unix commands +//@ + +//@include ./src/tempdir +var _tempDir = require('./src/tempdir'); +exports.tempdir = common.wrap('tempdir', _tempDir); + + +//@include ./src/error +var _error = require('./src/error'); +exports.error = _error; + + + +//@ +//@ ## Configuration +//@ + +exports.config = common.config; + +//@ +//@ ### config.silent +//@ Example: +//@ +//@ ```javascript +//@ var sh = require('shelljs'); +//@ var silentState = sh.config.silent; // save old silent state +//@ sh.config.silent = true; +//@ /* ... */ +//@ sh.config.silent = silentState; // restore old silent state +//@ ``` +//@ +//@ Suppresses all command output if `true`, except for `echo()` calls. +//@ Default is `false`. + +//@ +//@ ### config.fatal +//@ Example: +//@ +//@ ```javascript +//@ require('shelljs/global'); +//@ config.fatal = true; +//@ cp('this_file_does_not_exist', '/dev/null'); // dies here +//@ /* more commands... */ +//@ ``` +//@ +//@ If `true` the script will die on errors. Default is `false`. diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/cat.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/cat.js new file mode 100644 index 0000000..f6f4d25 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/cat.js @@ -0,0 +1,43 @@ +var common = require('./common'); +var fs = require('fs'); + +//@ +//@ ### cat(file [, file ...]) +//@ ### cat(file_array) +//@ +//@ Examples: +//@ +//@ ```javascript +//@ var str = cat('file*.txt'); +//@ var str = cat('file1', 'file2'); +//@ var str = cat(['file1', 'file2']); // same as above +//@ ``` +//@ +//@ Returns a string containing the given file, or a concatenated string +//@ containing the files if more than one file is given (a new line character is +//@ introduced between each file). Wildcard `*` accepted. +function _cat(options, files) { + var cat = ''; + + if (!files) + common.error('no paths given'); + + if (typeof files === 'string') + files = [].slice.call(arguments, 1); + // if it's array leave it as it is + + files = common.expand(files); + + files.forEach(function(file) { + if (!fs.existsSync(file)) + common.error('no such file or directory: ' + file); + + cat += fs.readFileSync(file, 'utf8') + '\n'; + }); + + if (cat[cat.length-1] === '\n') + cat = cat.substring(0, cat.length-1); + + return common.ShellString(cat); +} +module.exports = _cat; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/cd.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/cd.js new file mode 100644 index 0000000..230f432 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/cd.js @@ -0,0 +1,19 @@ +var fs = require('fs'); +var common = require('./common'); + +//@ +//@ ### cd('dir') +//@ Changes to directory `dir` for the duration of the script +function _cd(options, dir) { + if (!dir) + common.error('directory not specified'); + + if (!fs.existsSync(dir)) + common.error('no such file or directory: ' + dir); + + if (!fs.statSync(dir).isDirectory()) + common.error('not a directory: ' + dir); + + process.chdir(dir); +} +module.exports = _cd; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/chmod.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/chmod.js new file mode 100644 index 0000000..f288893 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/chmod.js @@ -0,0 +1,208 @@ +var common = require('./common'); +var fs = require('fs'); +var path = require('path'); + +var PERMS = (function (base) { + return { + OTHER_EXEC : base.EXEC, + OTHER_WRITE : base.WRITE, + OTHER_READ : base.READ, + + GROUP_EXEC : base.EXEC << 3, + GROUP_WRITE : base.WRITE << 3, + GROUP_READ : base.READ << 3, + + OWNER_EXEC : base.EXEC << 6, + OWNER_WRITE : base.WRITE << 6, + OWNER_READ : base.READ << 6, + + // Literal octal numbers are apparently not allowed in "strict" javascript. Using parseInt is + // the preferred way, else a jshint warning is thrown. + STICKY : parseInt('01000', 8), + SETGID : parseInt('02000', 8), + SETUID : parseInt('04000', 8), + + TYPE_MASK : parseInt('0770000', 8) + }; +})({ + EXEC : 1, + WRITE : 2, + READ : 4 +}); + +//@ +//@ ### chmod(octal_mode || octal_string, file) +//@ ### chmod(symbolic_mode, file) +//@ +//@ Available options: +//@ +//@ + `-v`: output a diagnostic for every file processed//@ +//@ + `-c`: like verbose but report only when a change is made//@ +//@ + `-R`: change files and directories recursively//@ +//@ +//@ Examples: +//@ +//@ ```javascript +//@ chmod(755, '/Users/brandon'); +//@ chmod('755', '/Users/brandon'); // same as above +//@ chmod('u+x', '/Users/brandon'); +//@ ``` +//@ +//@ Alters the permissions of a file or directory by either specifying the +//@ absolute permissions in octal form or expressing the changes in symbols. +//@ This command tries to mimic the POSIX behavior as much as possible. +//@ Notable exceptions: +//@ +//@ + In symbolic modes, 'a-r' and '-r' are identical. No consideration is +//@ given to the umask. +//@ + There is no "quiet" option since default behavior is to run silent. +function _chmod(options, mode, filePattern) { + if (!filePattern) { + if (options.length > 0 && options.charAt(0) === '-') { + // Special case where the specified file permissions started with - to subtract perms, which + // get picked up by the option parser as command flags. + // If we are down by one argument and options starts with -, shift everything over. + filePattern = mode; + mode = options; + options = ''; + } + else { + common.error('You must specify a file.'); + } + } + + options = common.parseOptions(options, { + 'R': 'recursive', + 'c': 'changes', + 'v': 'verbose' + }); + + if (typeof filePattern === 'string') { + filePattern = [ filePattern ]; + } + + var files; + + if (options.recursive) { + files = []; + common.expand(filePattern).forEach(function addFile(expandedFile) { + var stat = fs.lstatSync(expandedFile); + + if (!stat.isSymbolicLink()) { + files.push(expandedFile); + + if (stat.isDirectory()) { // intentionally does not follow symlinks. + fs.readdirSync(expandedFile).forEach(function (child) { + addFile(expandedFile + '/' + child); + }); + } + } + }); + } + else { + files = common.expand(filePattern); + } + + files.forEach(function innerChmod(file) { + file = path.resolve(file); + if (!fs.existsSync(file)) { + common.error('File not found: ' + file); + } + + // When recursing, don't follow symlinks. + if (options.recursive && fs.lstatSync(file).isSymbolicLink()) { + return; + } + + var perms = fs.statSync(file).mode; + var type = perms & PERMS.TYPE_MASK; + + var newPerms = perms; + + if (isNaN(parseInt(mode, 8))) { + // parse options + mode.split(',').forEach(function (symbolicMode) { + /*jshint regexdash:true */ + var pattern = /([ugoa]*)([=\+-])([rwxXst]*)/i; + var matches = pattern.exec(symbolicMode); + + if (matches) { + var applyTo = matches[1]; + var operator = matches[2]; + var change = matches[3]; + + var changeOwner = applyTo.indexOf('u') != -1 || applyTo === 'a' || applyTo === ''; + var changeGroup = applyTo.indexOf('g') != -1 || applyTo === 'a' || applyTo === ''; + var changeOther = applyTo.indexOf('o') != -1 || applyTo === 'a' || applyTo === ''; + + var changeRead = change.indexOf('r') != -1; + var changeWrite = change.indexOf('w') != -1; + var changeExec = change.indexOf('x') != -1; + var changeSticky = change.indexOf('t') != -1; + var changeSetuid = change.indexOf('s') != -1; + + var mask = 0; + if (changeOwner) { + mask |= (changeRead ? PERMS.OWNER_READ : 0) + (changeWrite ? PERMS.OWNER_WRITE : 0) + (changeExec ? PERMS.OWNER_EXEC : 0) + (changeSetuid ? PERMS.SETUID : 0); + } + if (changeGroup) { + mask |= (changeRead ? PERMS.GROUP_READ : 0) + (changeWrite ? PERMS.GROUP_WRITE : 0) + (changeExec ? PERMS.GROUP_EXEC : 0) + (changeSetuid ? PERMS.SETGID : 0); + } + if (changeOther) { + mask |= (changeRead ? PERMS.OTHER_READ : 0) + (changeWrite ? PERMS.OTHER_WRITE : 0) + (changeExec ? PERMS.OTHER_EXEC : 0); + } + + // Sticky bit is special - it's not tied to user, group or other. + if (changeSticky) { + mask |= PERMS.STICKY; + } + + switch (operator) { + case '+': + newPerms |= mask; + break; + + case '-': + newPerms &= ~mask; + break; + + case '=': + newPerms = type + mask; + + // According to POSIX, when using = to explicitly set the permissions, setuid and setgid can never be cleared. + if (fs.statSync(file).isDirectory()) { + newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms; + } + break; + } + + if (options.verbose) { + log(file + ' -> ' + newPerms.toString(8)); + } + + if (perms != newPerms) { + if (!options.verbose && options.changes) { + log(file + ' -> ' + newPerms.toString(8)); + } + fs.chmodSync(file, newPerms); + } + } + else { + common.error('Invalid symbolic mode change: ' + symbolicMode); + } + }); + } + else { + // they gave us a full number + newPerms = type + parseInt(mode, 8); + + // POSIX rules are that setuid and setgid can only be added using numeric form, but not cleared. + if (fs.statSync(file).isDirectory()) { + newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms; + } + + fs.chmodSync(file, newPerms); + } + }); +} +module.exports = _chmod; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/common.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/common.js new file mode 100644 index 0000000..d8c2312 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/common.js @@ -0,0 +1,203 @@ +var os = require('os'); +var fs = require('fs'); +var _ls = require('./ls'); + +// Module globals +var config = { + silent: false, + fatal: false +}; +exports.config = config; + +var state = { + error: null, + currentCmd: 'shell.js', + tempDir: null +}; +exports.state = state; + +var platform = os.type().match(/^Win/) ? 'win' : 'unix'; +exports.platform = platform; + +function log() { + if (!config.silent) + console.log.apply(this, arguments); +} +exports.log = log; + +// Shows error message. Throws unless _continue or config.fatal are true +function error(msg, _continue) { + if (state.error === null) + state.error = ''; + state.error += state.currentCmd + ': ' + msg + '\n'; + + if (msg.length > 0) + log(state.error); + + if (config.fatal) + process.exit(1); + + if (!_continue) + throw ''; +} +exports.error = error; + +// In the future, when Proxies are default, we can add methods like `.to()` to primitive strings. +// For now, this is a dummy function to bookmark places we need such strings +function ShellString(str) { + return str; +} +exports.ShellString = ShellString; + +// Returns {'alice': true, 'bob': false} when passed a dictionary, e.g.: +// parseOptions('-a', {'a':'alice', 'b':'bob'}); +function parseOptions(str, map) { + if (!map) + error('parseOptions() internal error: no map given'); + + // All options are false by default + var options = {}; + for (var letter in map) + options[map[letter]] = false; + + if (!str) + return options; // defaults + + if (typeof str !== 'string') + error('parseOptions() internal error: wrong str'); + + // e.g. match[1] = 'Rf' for str = '-Rf' + var match = str.match(/^\-(.+)/); + if (!match) + return options; + + // e.g. chars = ['R', 'f'] + var chars = match[1].split(''); + + chars.forEach(function(c) { + if (c in map) + options[map[c]] = true; + else + error('option not recognized: '+c); + }); + + return options; +} +exports.parseOptions = parseOptions; + +// Expands wildcards with matching (ie. existing) file names. +// For example: +// expand(['file*.js']) = ['file1.js', 'file2.js', ...] +// (if the files 'file1.js', 'file2.js', etc, exist in the current dir) +function expand(list) { + var expanded = []; + list.forEach(function(listEl) { + // Wildcard present on directory names ? + if(listEl.search(/\*[^\/]*\//) > -1 || listEl.search(/\*\*[^\/]*\//) > -1) { + var match = listEl.match(/^([^*]+\/|)(.*)/); + var root = match[1]; + var rest = match[2]; + var restRegex = rest.replace(/\*\*/g, ".*").replace(/\*/g, "[^\\/]*"); + restRegex = new RegExp(restRegex); + + _ls('-R', root).filter(function (e) { + return restRegex.test(e); + }).forEach(function(file) { + expanded.push(file); + }); + } + // Wildcard present on file names ? + else if (listEl.search(/\*/) > -1) { + _ls('', listEl).forEach(function(file) { + expanded.push(file); + }); + } else { + expanded.push(listEl); + } + }); + return expanded; +} +exports.expand = expand; + +// Normalizes _unlinkSync() across platforms to match Unix behavior, i.e. +// file can be unlinked even if it's read-only, see https://github.com/joyent/node/issues/3006 +function unlinkSync(file) { + try { + fs.unlinkSync(file); + } catch(e) { + // Try to override file permission + if (e.code === 'EPERM') { + fs.chmodSync(file, '0666'); + fs.unlinkSync(file); + } else { + throw e; + } + } +} +exports.unlinkSync = unlinkSync; + +// e.g. 'shelljs_a5f185d0443ca...' +function randomFileName() { + function randomHash(count) { + if (count === 1) + return parseInt(16*Math.random(), 10).toString(16); + else { + var hash = ''; + for (var i=0; i and/or '); + } else if (arguments.length > 3) { + sources = [].slice.call(arguments, 1, arguments.length - 1); + dest = arguments[arguments.length - 1]; + } else if (typeof sources === 'string') { + sources = [sources]; + } else if ('length' in sources) { + sources = sources; // no-op for array + } else { + common.error('invalid arguments'); + } + + var exists = fs.existsSync(dest), + stats = exists && fs.statSync(dest); + + // Dest is not existing dir, but multiple sources given + if ((!exists || !stats.isDirectory()) && sources.length > 1) + common.error('dest is not a directory (too many sources)'); + + // Dest is an existing file, but no -f given + if (exists && stats.isFile() && !options.force) + common.error('dest file already exists: ' + dest); + + if (options.recursive) { + // Recursive allows the shortcut syntax "sourcedir/" for "sourcedir/*" + // (see Github issue #15) + sources.forEach(function(src, i) { + if (src[src.length - 1] === '/') + sources[i] += '*'; + }); + + // Create dest + try { + fs.mkdirSync(dest, parseInt('0777', 8)); + } catch (e) { + // like Unix's cp, keep going even if we can't create dest dir + } + } + + sources = common.expand(sources); + + sources.forEach(function(src) { + if (!fs.existsSync(src)) { + common.error('no such file or directory: '+src, true); + return; // skip file + } + + // If here, src exists + if (fs.statSync(src).isDirectory()) { + if (!options.recursive) { + // Non-Recursive + common.log(src + ' is a directory (not copied)'); + } else { + // Recursive + // 'cp /a/source dest' should create 'source' in 'dest' + var newDest = path.join(dest, path.basename(src)), + checkDir = fs.statSync(src); + try { + fs.mkdirSync(newDest, checkDir.mode); + } catch (e) { + //if the directory already exists, that's okay + if (e.code !== 'EEXIST') { + common.error('dest file no such file or directory: ' + newDest, true); + throw e; + } + } + + cpdirSyncRecursive(src, newDest, {force: options.force}); + } + return; // done with dir + } + + // If here, src is a file + + // When copying to '/path/dir': + // thisDest = '/path/dir/file1' + var thisDest = dest; + if (fs.existsSync(dest) && fs.statSync(dest).isDirectory()) + thisDest = path.normalize(dest + '/' + path.basename(src)); + + if (fs.existsSync(thisDest) && !options.force) { + common.error('dest file already exists: ' + thisDest, true); + return; // skip file + } + + copyFileSync(src, thisDest); + }); // forEach(src) +} +module.exports = _cp; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/dirs.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/dirs.js new file mode 100644 index 0000000..58fae8b --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/dirs.js @@ -0,0 +1,191 @@ +var common = require('./common'); +var _cd = require('./cd'); +var path = require('path'); + +// Pushd/popd/dirs internals +var _dirStack = []; + +function _isStackIndex(index) { + return (/^[\-+]\d+$/).test(index); +} + +function _parseStackIndex(index) { + if (_isStackIndex(index)) { + if (Math.abs(index) < _dirStack.length + 1) { // +1 for pwd + return (/^-/).test(index) ? Number(index) - 1 : Number(index); + } else { + common.error(index + ': directory stack index out of range'); + } + } else { + common.error(index + ': invalid number'); + } +} + +function _actualDirStack() { + return [process.cwd()].concat(_dirStack); +} + +//@ +//@ ### pushd([options,] [dir | '-N' | '+N']) +//@ +//@ Available options: +//@ +//@ + `-n`: Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated. +//@ +//@ Arguments: +//@ +//@ + `dir`: Makes the current working directory be the top of the stack, and then executes the equivalent of `cd dir`. +//@ + `+N`: Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. +//@ + `-N`: Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. +//@ +//@ Examples: +//@ +//@ ```javascript +//@ // process.cwd() === '/usr' +//@ pushd('/etc'); // Returns /etc /usr +//@ pushd('+1'); // Returns /usr /etc +//@ ``` +//@ +//@ Save the current directory on the top of the directory stack and then cd to `dir`. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack. +function _pushd(options, dir) { + if (_isStackIndex(options)) { + dir = options; + options = ''; + } + + options = common.parseOptions(options, { + 'n' : 'no-cd' + }); + + var dirs = _actualDirStack(); + + if (dir === '+0') { + return dirs; // +0 is a noop + } else if (!dir) { + if (dirs.length > 1) { + dirs = dirs.splice(1, 1).concat(dirs); + } else { + return common.error('no other directory'); + } + } else if (_isStackIndex(dir)) { + var n = _parseStackIndex(dir); + dirs = dirs.slice(n).concat(dirs.slice(0, n)); + } else { + if (options['no-cd']) { + dirs.splice(1, 0, dir); + } else { + dirs.unshift(dir); + } + } + + if (options['no-cd']) { + dirs = dirs.slice(1); + } else { + dir = path.resolve(dirs.shift()); + _cd('', dir); + } + + _dirStack = dirs; + return _dirs(''); +} +exports.pushd = _pushd; + +//@ +//@ ### popd([options,] ['-N' | '+N']) +//@ +//@ Available options: +//@ +//@ + `-n`: Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated. +//@ +//@ Arguments: +//@ +//@ + `+N`: Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero. +//@ + `-N`: Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero. +//@ +//@ Examples: +//@ +//@ ```javascript +//@ echo(process.cwd()); // '/usr' +//@ pushd('/etc'); // '/etc /usr' +//@ echo(process.cwd()); // '/etc' +//@ popd(); // '/usr' +//@ echo(process.cwd()); // '/usr' +//@ ``` +//@ +//@ When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack. +function _popd(options, index) { + if (_isStackIndex(options)) { + index = options; + options = ''; + } + + options = common.parseOptions(options, { + 'n' : 'no-cd' + }); + + if (!_dirStack.length) { + return common.error('directory stack empty'); + } + + index = _parseStackIndex(index || '+0'); + + if (options['no-cd'] || index > 0 || _dirStack.length + index === 0) { + index = index > 0 ? index - 1 : index; + _dirStack.splice(index, 1); + } else { + var dir = path.resolve(_dirStack.shift()); + _cd('', dir); + } + + return _dirs(''); +} +exports.popd = _popd; + +//@ +//@ ### dirs([options | '+N' | '-N']) +//@ +//@ Available options: +//@ +//@ + `-c`: Clears the directory stack by deleting all of the elements. +//@ +//@ Arguments: +//@ +//@ + `+N`: Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero. +//@ + `-N`: Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero. +//@ +//@ Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified. +//@ +//@ See also: pushd, popd +function _dirs(options, index) { + if (_isStackIndex(options)) { + index = options; + options = ''; + } + + options = common.parseOptions(options, { + 'c' : 'clear' + }); + + if (options['clear']) { + _dirStack = []; + return _dirStack; + } + + var stack = _actualDirStack(); + + if (index) { + index = _parseStackIndex(index); + + if (index < 0) { + index = stack.length + index; + } + + common.log(stack[index]); + return stack[index]; + } + + common.log(stack.join(' ')); + + return stack; +} +exports.dirs = _dirs; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/echo.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/echo.js new file mode 100644 index 0000000..760ea84 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/echo.js @@ -0,0 +1,20 @@ +var common = require('./common'); + +//@ +//@ ### echo(string [,string ...]) +//@ +//@ Examples: +//@ +//@ ```javascript +//@ echo('hello world'); +//@ var str = echo('hello world'); +//@ ``` +//@ +//@ Prints string to stdout, and returns string with additional utility methods +//@ like `.to()`. +function _echo() { + var messages = [].slice.call(arguments, 0); + console.log.apply(this, messages); + return common.ShellString(messages.join(' ')); +} +module.exports = _echo; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/error.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/error.js new file mode 100644 index 0000000..cca3efb --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/error.js @@ -0,0 +1,10 @@ +var common = require('./common'); + +//@ +//@ ### error() +//@ Tests if error occurred in the last command. Returns `null` if no error occurred, +//@ otherwise returns string explaining the error +function error() { + return common.state.error; +}; +module.exports = error; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/exec.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/exec.js new file mode 100644 index 0000000..d259a9f --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/exec.js @@ -0,0 +1,216 @@ +var common = require('./common'); +var _tempDir = require('./tempdir'); +var _pwd = require('./pwd'); +var path = require('path'); +var fs = require('fs'); +var child = require('child_process'); + +// Hack to run child_process.exec() synchronously (sync avoids callback hell) +// Uses a custom wait loop that checks for a flag file, created when the child process is done. +// (Can't do a wait loop that checks for internal Node variables/messages as +// Node is single-threaded; callbacks and other internal state changes are done in the +// event loop). +function execSync(cmd, opts) { + var tempDir = _tempDir(); + var stdoutFile = path.resolve(tempDir+'/'+common.randomFileName()), + codeFile = path.resolve(tempDir+'/'+common.randomFileName()), + scriptFile = path.resolve(tempDir+'/'+common.randomFileName()), + sleepFile = path.resolve(tempDir+'/'+common.randomFileName()); + + var options = common.extend({ + silent: common.config.silent + }, opts); + + var previousStdoutContent = ''; + // Echoes stdout changes from running process, if not silent + function updateStdout() { + if (options.silent || !fs.existsSync(stdoutFile)) + return; + + var stdoutContent = fs.readFileSync(stdoutFile, 'utf8'); + // No changes since last time? + if (stdoutContent.length <= previousStdoutContent.length) + return; + + process.stdout.write(stdoutContent.substr(previousStdoutContent.length)); + previousStdoutContent = stdoutContent; + } + + function escape(str) { + return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0"); + } + + if (fs.existsSync(scriptFile)) common.unlinkSync(scriptFile); + if (fs.existsSync(stdoutFile)) common.unlinkSync(stdoutFile); + if (fs.existsSync(codeFile)) common.unlinkSync(codeFile); + + var execCommand = '"'+process.execPath+'" '+scriptFile; + var execOptions = { + env: process.env, + cwd: _pwd(), + maxBuffer: 20*1024*1024 + }; + + if (typeof child.execSync === 'function') { + var script = [ + "var child = require('child_process')", + " , fs = require('fs');", + "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: 20*1024*1024}, function(err) {", + " fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0');", + "});", + "var stdoutStream = fs.createWriteStream('"+escape(stdoutFile)+"');", + "childProcess.stdout.pipe(stdoutStream, {end: false});", + "childProcess.stderr.pipe(stdoutStream, {end: false});", + "childProcess.stdout.pipe(process.stdout);", + "childProcess.stderr.pipe(process.stderr);", + "var stdoutEnded = false, stderrEnded = false;", + "function tryClosing(){ if(stdoutEnded && stderrEnded){ stdoutStream.end(); } }", + "childProcess.stdout.on('end', function(){ stdoutEnded = true; tryClosing(); });", + "childProcess.stderr.on('end', function(){ stderrEnded = true; tryClosing(); });" + ].join('\n'); + + fs.writeFileSync(scriptFile, script); + + if (options.silent) { + execOptions.stdio = 'ignore'; + } else { + execOptions.stdio = [0, 1, 2]; + } + + // Welcome to the future + child.execSync(execCommand, execOptions); + } else { + cmd += ' > '+stdoutFile+' 2>&1'; // works on both win/unix + + var script = [ + "var child = require('child_process')", + " , fs = require('fs');", + "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: 20*1024*1024}, function(err) {", + " fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0');", + "});" + ].join('\n'); + + fs.writeFileSync(scriptFile, script); + + child.exec(execCommand, execOptions); + + // The wait loop + // sleepFile is used as a dummy I/O op to mitigate unnecessary CPU usage + // (tried many I/O sync ops, writeFileSync() seems to be only one that is effective in reducing + // CPU usage, though apparently not so much on Windows) + while (!fs.existsSync(codeFile)) { updateStdout(); fs.writeFileSync(sleepFile, 'a'); } + while (!fs.existsSync(stdoutFile)) { updateStdout(); fs.writeFileSync(sleepFile, 'a'); } + } + + // At this point codeFile exists, but it's not necessarily flushed yet. + // Keep reading it until it is. + var code = parseInt('', 10); + while (isNaN(code)) { + code = parseInt(fs.readFileSync(codeFile, 'utf8'), 10); + } + + var stdout = fs.readFileSync(stdoutFile, 'utf8'); + + // No biggie if we can't erase the files now -- they're in a temp dir anyway + try { common.unlinkSync(scriptFile); } catch(e) {} + try { common.unlinkSync(stdoutFile); } catch(e) {} + try { common.unlinkSync(codeFile); } catch(e) {} + try { common.unlinkSync(sleepFile); } catch(e) {} + + // some shell return codes are defined as errors, per http://tldp.org/LDP/abs/html/exitcodes.html + if (code === 1 || code === 2 || code >= 126) { + common.error('', true); // unix/shell doesn't really give an error message after non-zero exit codes + } + // True if successful, false if not + var obj = { + code: code, + output: stdout + }; + return obj; +} // execSync() + +// Wrapper around exec() to enable echoing output to console in real time +function execAsync(cmd, opts, callback) { + var output = ''; + + var options = common.extend({ + silent: common.config.silent + }, opts); + + var c = child.exec(cmd, {env: process.env, maxBuffer: 20*1024*1024}, function(err) { + if (callback) + callback(err ? err.code : 0, output); + }); + + c.stdout.on('data', function(data) { + output += data; + if (!options.silent) + process.stdout.write(data); + }); + + c.stderr.on('data', function(data) { + output += data; + if (!options.silent) + process.stdout.write(data); + }); + + return c; +} + +//@ +//@ ### exec(command [, options] [, callback]) +//@ Available options (all `false` by default): +//@ +//@ + `async`: Asynchronous execution. Defaults to true if a callback is provided. +//@ + `silent`: Do not echo program output to console. +//@ +//@ Examples: +//@ +//@ ```javascript +//@ var version = exec('node --version', {silent:true}).output; +//@ +//@ var child = exec('some_long_running_process', {async:true}); +//@ child.stdout.on('data', function(data) { +//@ /* ... do something with data ... */ +//@ }); +//@ +//@ exec('some_long_running_process', function(code, output) { +//@ console.log('Exit code:', code); +//@ console.log('Program output:', output); +//@ }); +//@ ``` +//@ +//@ Executes the given `command` _synchronously_, unless otherwise specified. +//@ When in synchronous mode returns the object `{ code:..., output:... }`, containing the program's +//@ `output` (stdout + stderr) and its exit `code`. Otherwise returns the child process object, and +//@ the `callback` gets the arguments `(code, output)`. +//@ +//@ **Note:** For long-lived processes, it's best to run `exec()` asynchronously as +//@ the current synchronous implementation uses a lot of CPU. This should be getting +//@ fixed soon. +function _exec(command, options, callback) { + if (!command) + common.error('must specify command'); + + // Callback is defined instead of options. + if (typeof options === 'function') { + callback = options; + options = { async: true }; + } + + // Callback is defined with options. + if (typeof options === 'object' && typeof callback === 'function') { + options.async = true; + } + + options = common.extend({ + silent: common.config.silent, + async: false + }, options); + + if (options.async) + return execAsync(command, options, callback); + else + return execSync(command, options); +} +module.exports = _exec; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/find.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/find.js new file mode 100644 index 0000000..d9eeec2 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/find.js @@ -0,0 +1,51 @@ +var fs = require('fs'); +var common = require('./common'); +var _ls = require('./ls'); + +//@ +//@ ### find(path [,path ...]) +//@ ### find(path_array) +//@ Examples: +//@ +//@ ```javascript +//@ find('src', 'lib'); +//@ find(['src', 'lib']); // same as above +//@ find('.').filter(function(file) { return file.match(/\.js$/); }); +//@ ``` +//@ +//@ Returns array of all files (however deep) in the given paths. +//@ +//@ The main difference from `ls('-R', path)` is that the resulting file names +//@ include the base directories, e.g. `lib/resources/file1` instead of just `file1`. +function _find(options, paths) { + if (!paths) + common.error('no path specified'); + else if (typeof paths === 'object') + paths = paths; // assume array + else if (typeof paths === 'string') + paths = [].slice.call(arguments, 1); + + var list = []; + + function pushFile(file) { + if (common.platform === 'win') + file = file.replace(/\\/g, '/'); + list.push(file); + } + + // why not simply do ls('-R', paths)? because the output wouldn't give the base dirs + // to get the base dir in the output, we need instead ls('-R', 'dir/*') for every directory + + paths.forEach(function(file) { + pushFile(file); + + if (fs.statSync(file).isDirectory()) { + _ls('-RA', file+'/*').forEach(function(subfile) { + pushFile(subfile); + }); + } + }); + + return list; +} +module.exports = _find; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/grep.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/grep.js new file mode 100644 index 0000000..00c7d6a --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/grep.js @@ -0,0 +1,52 @@ +var common = require('./common'); +var fs = require('fs'); + +//@ +//@ ### grep([options ,] regex_filter, file [, file ...]) +//@ ### grep([options ,] regex_filter, file_array) +//@ Available options: +//@ +//@ + `-v`: Inverse the sense of the regex and print the lines not matching the criteria. +//@ +//@ Examples: +//@ +//@ ```javascript +//@ grep('-v', 'GLOBAL_VARIABLE', '*.js'); +//@ grep('GLOBAL_VARIABLE', '*.js'); +//@ ``` +//@ +//@ Reads input string from given files and returns a string containing all lines of the +//@ file that match the given `regex_filter`. Wildcard `*` accepted. +function _grep(options, regex, files) { + options = common.parseOptions(options, { + 'v': 'inverse' + }); + + if (!files) + common.error('no paths given'); + + if (typeof files === 'string') + files = [].slice.call(arguments, 2); + // if it's array leave it as it is + + files = common.expand(files); + + var grep = ''; + files.forEach(function(file) { + if (!fs.existsSync(file)) { + common.error('no such file or directory: ' + file, true); + return; + } + + var contents = fs.readFileSync(file, 'utf8'), + lines = contents.split(/\r*\n/); + lines.forEach(function(line) { + var matched = line.match(regex); + if ((options.inverse && !matched) || (!options.inverse && matched)) + grep += line + '\n'; + }); + }); + + return common.ShellString(grep); +} +module.exports = _grep; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/ln.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/ln.js new file mode 100644 index 0000000..a7b9701 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/ln.js @@ -0,0 +1,53 @@ +var fs = require('fs'); +var path = require('path'); +var common = require('./common'); +var os = require('os'); + +//@ +//@ ### ln(options, source, dest) +//@ ### ln(source, dest) +//@ Available options: +//@ +//@ + `s`: symlink +//@ + `f`: force +//@ +//@ Examples: +//@ +//@ ```javascript +//@ ln('file', 'newlink'); +//@ ln('-sf', 'file', 'existing'); +//@ ``` +//@ +//@ Links source to dest. Use -f to force the link, should dest already exist. +function _ln(options, source, dest) { + options = common.parseOptions(options, { + 's': 'symlink', + 'f': 'force' + }); + + if (!source || !dest) { + common.error('Missing and/or '); + } + + source = path.resolve(process.cwd(), String(source)); + dest = path.resolve(process.cwd(), String(dest)); + + if (!fs.existsSync(source)) { + common.error('Source file does not exist', true); + } + + if (fs.existsSync(dest)) { + if (!options.force) { + common.error('Destination file exists', true); + } + + fs.unlinkSync(dest); + } + + if (options.symlink) { + fs.symlinkSync(source, dest, os.platform() === "win32" ? "junction" : null); + } else { + fs.linkSync(source, dest, os.platform() === "win32" ? "junction" : null); + } +} +module.exports = _ln; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/ls.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/ls.js new file mode 100644 index 0000000..3345db4 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/ls.js @@ -0,0 +1,126 @@ +var path = require('path'); +var fs = require('fs'); +var common = require('./common'); +var _cd = require('./cd'); +var _pwd = require('./pwd'); + +//@ +//@ ### ls([options ,] path [,path ...]) +//@ ### ls([options ,] path_array) +//@ Available options: +//@ +//@ + `-R`: recursive +//@ + `-A`: all files (include files beginning with `.`, except for `.` and `..`) +//@ +//@ Examples: +//@ +//@ ```javascript +//@ ls('projs/*.js'); +//@ ls('-R', '/users/me', '/tmp'); +//@ ls('-R', ['/users/me', '/tmp']); // same as above +//@ ``` +//@ +//@ Returns array of files in the given path, or in current directory if no path provided. +function _ls(options, paths) { + options = common.parseOptions(options, { + 'R': 'recursive', + 'A': 'all', + 'a': 'all_deprecated' + }); + + if (options.all_deprecated) { + // We won't support the -a option as it's hard to image why it's useful + // (it includes '.' and '..' in addition to '.*' files) + // For backwards compatibility we'll dump a deprecated message and proceed as before + common.log('ls: Option -a is deprecated. Use -A instead'); + options.all = true; + } + + if (!paths) + paths = ['.']; + else if (typeof paths === 'object') + paths = paths; // assume array + else if (typeof paths === 'string') + paths = [].slice.call(arguments, 1); + + var list = []; + + // Conditionally pushes file to list - returns true if pushed, false otherwise + // (e.g. prevents hidden files to be included unless explicitly told so) + function pushFile(file, query) { + // hidden file? + if (path.basename(file)[0] === '.') { + // not explicitly asking for hidden files? + if (!options.all && !(path.basename(query)[0] === '.' && path.basename(query).length > 1)) + return false; + } + + if (common.platform === 'win') + file = file.replace(/\\/g, '/'); + + list.push(file); + return true; + } + + paths.forEach(function(p) { + if (fs.existsSync(p)) { + var stats = fs.statSync(p); + // Simple file? + if (stats.isFile()) { + pushFile(p, p); + return; // continue + } + + // Simple dir? + if (stats.isDirectory()) { + // Iterate over p contents + fs.readdirSync(p).forEach(function(file) { + if (!pushFile(file, p)) + return; + + // Recursive? + if (options.recursive) { + var oldDir = _pwd(); + _cd('', p); + if (fs.statSync(file).isDirectory()) + list = list.concat(_ls('-R'+(options.all?'A':''), file+'/*')); + _cd('', oldDir); + } + }); + return; // continue + } + } + + // p does not exist - possible wildcard present + + var basename = path.basename(p); + var dirname = path.dirname(p); + // Wildcard present on an existing dir? (e.g. '/tmp/*.js') + if (basename.search(/\*/) > -1 && fs.existsSync(dirname) && fs.statSync(dirname).isDirectory) { + // Escape special regular expression chars + var regexp = basename.replace(/(\^|\$|\(|\)|<|>|\[|\]|\{|\}|\.|\+|\?)/g, '\\$1'); + // Translates wildcard into regex + regexp = '^' + regexp.replace(/\*/g, '.*') + '$'; + // Iterate over directory contents + fs.readdirSync(dirname).forEach(function(file) { + if (file.match(new RegExp(regexp))) { + if (!pushFile(path.normalize(dirname+'/'+file), basename)) + return; + + // Recursive? + if (options.recursive) { + var pp = dirname + '/' + file; + if (fs.lstatSync(pp).isDirectory()) + list = list.concat(_ls('-R'+(options.all?'A':''), pp+'/*')); + } // recursive + } // if file matches + }); // forEach + return; + } + + common.error('no such file or directory: ' + p, true); + }); + + return list; +} +module.exports = _ls; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/mkdir.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/mkdir.js new file mode 100644 index 0000000..5a7088f --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/mkdir.js @@ -0,0 +1,68 @@ +var common = require('./common'); +var fs = require('fs'); +var path = require('path'); + +// Recursively creates 'dir' +function mkdirSyncRecursive(dir) { + var baseDir = path.dirname(dir); + + // Base dir exists, no recursion necessary + if (fs.existsSync(baseDir)) { + fs.mkdirSync(dir, parseInt('0777', 8)); + return; + } + + // Base dir does not exist, go recursive + mkdirSyncRecursive(baseDir); + + // Base dir created, can create dir + fs.mkdirSync(dir, parseInt('0777', 8)); +} + +//@ +//@ ### mkdir([options ,] dir [, dir ...]) +//@ ### mkdir([options ,] dir_array) +//@ Available options: +//@ +//@ + `p`: full path (will create intermediate dirs if necessary) +//@ +//@ Examples: +//@ +//@ ```javascript +//@ mkdir('-p', '/tmp/a/b/c/d', '/tmp/e/f/g'); +//@ mkdir('-p', ['/tmp/a/b/c/d', '/tmp/e/f/g']); // same as above +//@ ``` +//@ +//@ Creates directories. +function _mkdir(options, dirs) { + options = common.parseOptions(options, { + 'p': 'fullpath' + }); + if (!dirs) + common.error('no paths given'); + + if (typeof dirs === 'string') + dirs = [].slice.call(arguments, 1); + // if it's array leave it as it is + + dirs.forEach(function(dir) { + if (fs.existsSync(dir)) { + if (!options.fullpath) + common.error('path already exists: ' + dir, true); + return; // skip dir + } + + // Base dir does not exist, and no -p option given + var baseDir = path.dirname(dir); + if (!fs.existsSync(baseDir) && !options.fullpath) { + common.error('no such file or directory: ' + baseDir, true); + return; // skip dir + } + + if (options.fullpath) + mkdirSyncRecursive(dir); + else + fs.mkdirSync(dir, parseInt('0777', 8)); + }); +} // mkdir +module.exports = _mkdir; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/mv.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/mv.js new file mode 100644 index 0000000..11f9607 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/mv.js @@ -0,0 +1,80 @@ +var fs = require('fs'); +var path = require('path'); +var common = require('./common'); + +//@ +//@ ### mv(source [, source ...], dest') +//@ ### mv(source_array, dest') +//@ Available options: +//@ +//@ + `f`: force +//@ +//@ Examples: +//@ +//@ ```javascript +//@ mv('-f', 'file', 'dir/'); +//@ mv('file1', 'file2', 'dir/'); +//@ mv(['file1', 'file2'], 'dir/'); // same as above +//@ ``` +//@ +//@ Moves files. The wildcard `*` is accepted. +function _mv(options, sources, dest) { + options = common.parseOptions(options, { + 'f': 'force' + }); + + // Get sources, dest + if (arguments.length < 3) { + common.error('missing and/or '); + } else if (arguments.length > 3) { + sources = [].slice.call(arguments, 1, arguments.length - 1); + dest = arguments[arguments.length - 1]; + } else if (typeof sources === 'string') { + sources = [sources]; + } else if ('length' in sources) { + sources = sources; // no-op for array + } else { + common.error('invalid arguments'); + } + + sources = common.expand(sources); + + var exists = fs.existsSync(dest), + stats = exists && fs.statSync(dest); + + // Dest is not existing dir, but multiple sources given + if ((!exists || !stats.isDirectory()) && sources.length > 1) + common.error('dest is not a directory (too many sources)'); + + // Dest is an existing file, but no -f given + if (exists && stats.isFile() && !options.force) + common.error('dest file already exists: ' + dest); + + sources.forEach(function(src) { + if (!fs.existsSync(src)) { + common.error('no such file or directory: '+src, true); + return; // skip file + } + + // If here, src exists + + // When copying to '/path/dir': + // thisDest = '/path/dir/file1' + var thisDest = dest; + if (fs.existsSync(dest) && fs.statSync(dest).isDirectory()) + thisDest = path.normalize(dest + '/' + path.basename(src)); + + if (fs.existsSync(thisDest) && !options.force) { + common.error('dest file already exists: ' + thisDest, true); + return; // skip file + } + + if (path.resolve(src) === path.dirname(path.resolve(thisDest))) { + common.error('cannot move to self: '+src, true); + return; // skip file + } + + fs.renameSync(src, thisDest); + }); // forEach(src) +} // mv +module.exports = _mv; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/popd.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/popd.js new file mode 100644 index 0000000..11ea24f --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/popd.js @@ -0,0 +1 @@ +// see dirs.js \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/pushd.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/pushd.js new file mode 100644 index 0000000..11ea24f --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/pushd.js @@ -0,0 +1 @@ +// see dirs.js \ No newline at end of file diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/pwd.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/pwd.js new file mode 100644 index 0000000..41727bb --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/pwd.js @@ -0,0 +1,11 @@ +var path = require('path'); +var common = require('./common'); + +//@ +//@ ### pwd() +//@ Returns the current directory. +function _pwd(options) { + var pwd = path.resolve(process.cwd()); + return common.ShellString(pwd); +} +module.exports = _pwd; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/rm.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/rm.js new file mode 100644 index 0000000..bd608cb --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/rm.js @@ -0,0 +1,163 @@ +var common = require('./common'); +var fs = require('fs'); + +// Recursively removes 'dir' +// Adapted from https://github.com/ryanmcgrath/wrench-js +// +// Copyright (c) 2010 Ryan McGrath +// Copyright (c) 2012 Artur Adib +// +// Licensed under the MIT License +// http://www.opensource.org/licenses/mit-license.php +function rmdirSyncRecursive(dir, force) { + var files; + + files = fs.readdirSync(dir); + + // Loop through and delete everything in the sub-tree after checking it + for(var i = 0; i < files.length; i++) { + var file = dir + "/" + files[i], + currFile = fs.lstatSync(file); + + if(currFile.isDirectory()) { // Recursive function back to the beginning + rmdirSyncRecursive(file, force); + } + + else if(currFile.isSymbolicLink()) { // Unlink symlinks + if (force || isWriteable(file)) { + try { + common.unlinkSync(file); + } catch (e) { + common.error('could not remove file (code '+e.code+'): ' + file, true); + } + } + } + + else // Assume it's a file - perhaps a try/catch belongs here? + if (force || isWriteable(file)) { + try { + common.unlinkSync(file); + } catch (e) { + common.error('could not remove file (code '+e.code+'): ' + file, true); + } + } + } + + // Now that we know everything in the sub-tree has been deleted, we can delete the main directory. + // Huzzah for the shopkeep. + + var result; + try { + // Retry on windows, sometimes it takes a little time before all the files in the directory are gone + var start = Date.now(); + while (true) { + try { + result = fs.rmdirSync(dir); + if (fs.existsSync(dir)) throw { code: "EAGAIN" } + break; + } catch(er) { + // In addition to error codes, also check if the directory still exists and loop again if true + if (process.platform === "win32" && (er.code === "ENOTEMPTY" || er.code === "EBUSY" || er.code === "EPERM" || er.code === "EAGAIN")) { + if (Date.now() - start > 1000) throw er; + } else if (er.code === "ENOENT") { + // Directory did not exist, deletion was successful + break; + } else { + throw er; + } + } + } + } catch(e) { + common.error('could not remove directory (code '+e.code+'): ' + dir, true); + } + + return result; +} // rmdirSyncRecursive + +// Hack to determine if file has write permissions for current user +// Avoids having to check user, group, etc, but it's probably slow +function isWriteable(file) { + var writePermission = true; + try { + var __fd = fs.openSync(file, 'a'); + fs.closeSync(__fd); + } catch(e) { + writePermission = false; + } + + return writePermission; +} + +//@ +//@ ### rm([options ,] file [, file ...]) +//@ ### rm([options ,] file_array) +//@ Available options: +//@ +//@ + `-f`: force +//@ + `-r, -R`: recursive +//@ +//@ Examples: +//@ +//@ ```javascript +//@ rm('-rf', '/tmp/*'); +//@ rm('some_file.txt', 'another_file.txt'); +//@ rm(['some_file.txt', 'another_file.txt']); // same as above +//@ ``` +//@ +//@ Removes files. The wildcard `*` is accepted. +function _rm(options, files) { + options = common.parseOptions(options, { + 'f': 'force', + 'r': 'recursive', + 'R': 'recursive' + }); + if (!files) + common.error('no paths given'); + + if (typeof files === 'string') + files = [].slice.call(arguments, 1); + // if it's array leave it as it is + + files = common.expand(files); + + files.forEach(function(file) { + if (!fs.existsSync(file)) { + // Path does not exist, no force flag given + if (!options.force) + common.error('no such file or directory: '+file, true); + + return; // skip file + } + + // If here, path exists + + var stats = fs.lstatSync(file); + if (stats.isFile() || stats.isSymbolicLink()) { + + // Do not check for file writing permissions + if (options.force) { + common.unlinkSync(file); + return; + } + + if (isWriteable(file)) + common.unlinkSync(file); + else + common.error('permission denied: '+file, true); + + return; + } // simple file + + // Path is an existing directory, but no -r flag given + if (stats.isDirectory() && !options.recursive) { + common.error('path is a directory', true); + return; // skip path + } + + // Recursively remove existing directory + if (stats.isDirectory() && options.recursive) { + rmdirSyncRecursive(file, options.force); + } + }); // forEach(file) +} // rm +module.exports = _rm; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/sed.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/sed.js new file mode 100644 index 0000000..65f7cb4 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/sed.js @@ -0,0 +1,43 @@ +var common = require('./common'); +var fs = require('fs'); + +//@ +//@ ### sed([options ,] search_regex, replacement, file) +//@ Available options: +//@ +//@ + `-i`: Replace contents of 'file' in-place. _Note that no backups will be created!_ +//@ +//@ Examples: +//@ +//@ ```javascript +//@ sed('-i', 'PROGRAM_VERSION', 'v0.1.3', 'source.js'); +//@ sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js'); +//@ ``` +//@ +//@ Reads an input string from `file` and performs a JavaScript `replace()` on the input +//@ using the given search regex and replacement string or function. Returns the new string after replacement. +function _sed(options, regex, replacement, file) { + options = common.parseOptions(options, { + 'i': 'inplace' + }); + + if (typeof replacement === 'string' || typeof replacement === 'function') + replacement = replacement; // no-op + else if (typeof replacement === 'number') + replacement = replacement.toString(); // fallback + else + common.error('invalid replacement string'); + + if (!file) + common.error('no file given'); + + if (!fs.existsSync(file)) + common.error('no such file or directory: ' + file); + + var result = fs.readFileSync(file, 'utf8').replace(regex, replacement); + if (options.inplace) + fs.writeFileSync(file, result, 'utf8'); + + return common.ShellString(result); +} +module.exports = _sed; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/tempdir.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/tempdir.js new file mode 100644 index 0000000..45953c2 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/tempdir.js @@ -0,0 +1,56 @@ +var common = require('./common'); +var os = require('os'); +var fs = require('fs'); + +// Returns false if 'dir' is not a writeable directory, 'dir' otherwise +function writeableDir(dir) { + if (!dir || !fs.existsSync(dir)) + return false; + + if (!fs.statSync(dir).isDirectory()) + return false; + + var testFile = dir+'/'+common.randomFileName(); + try { + fs.writeFileSync(testFile, ' '); + common.unlinkSync(testFile); + return dir; + } catch (e) { + return false; + } +} + + +//@ +//@ ### tempdir() +//@ +//@ Examples: +//@ +//@ ```javascript +//@ var tmp = tempdir(); // "/tmp" for most *nix platforms +//@ ``` +//@ +//@ Searches and returns string containing a writeable, platform-dependent temporary directory. +//@ Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir). +function _tempDir() { + var state = common.state; + if (state.tempDir) + return state.tempDir; // from cache + + state.tempDir = writeableDir(os.tempDir && os.tempDir()) || // node 0.8+ + writeableDir(process.env['TMPDIR']) || + writeableDir(process.env['TEMP']) || + writeableDir(process.env['TMP']) || + writeableDir(process.env['Wimp$ScrapDir']) || // RiscOS + writeableDir('C:\\TEMP') || // Windows + writeableDir('C:\\TMP') || // Windows + writeableDir('\\TEMP') || // Windows + writeableDir('\\TMP') || // Windows + writeableDir('/tmp') || + writeableDir('/var/tmp') || + writeableDir('/usr/tmp') || + writeableDir('.'); // last resort + + return state.tempDir; +} +module.exports = _tempDir; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/test.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/test.js new file mode 100644 index 0000000..8a4ac7d --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/test.js @@ -0,0 +1,85 @@ +var common = require('./common'); +var fs = require('fs'); + +//@ +//@ ### test(expression) +//@ Available expression primaries: +//@ +//@ + `'-b', 'path'`: true if path is a block device +//@ + `'-c', 'path'`: true if path is a character device +//@ + `'-d', 'path'`: true if path is a directory +//@ + `'-e', 'path'`: true if path exists +//@ + `'-f', 'path'`: true if path is a regular file +//@ + `'-L', 'path'`: true if path is a symboilc link +//@ + `'-p', 'path'`: true if path is a pipe (FIFO) +//@ + `'-S', 'path'`: true if path is a socket +//@ +//@ Examples: +//@ +//@ ```javascript +//@ if (test('-d', path)) { /* do something with dir */ }; +//@ if (!test('-f', path)) continue; // skip if it's a regular file +//@ ``` +//@ +//@ Evaluates expression using the available primaries and returns corresponding value. +function _test(options, path) { + if (!path) + common.error('no path given'); + + // hack - only works with unary primaries + options = common.parseOptions(options, { + 'b': 'block', + 'c': 'character', + 'd': 'directory', + 'e': 'exists', + 'f': 'file', + 'L': 'link', + 'p': 'pipe', + 'S': 'socket' + }); + + var canInterpret = false; + for (var key in options) + if (options[key] === true) { + canInterpret = true; + break; + } + + if (!canInterpret) + common.error('could not interpret expression'); + + if (options.link) { + try { + return fs.lstatSync(path).isSymbolicLink(); + } catch(e) { + return false; + } + } + + if (!fs.existsSync(path)) + return false; + + if (options.exists) + return true; + + var stats = fs.statSync(path); + + if (options.block) + return stats.isBlockDevice(); + + if (options.character) + return stats.isCharacterDevice(); + + if (options.directory) + return stats.isDirectory(); + + if (options.file) + return stats.isFile(); + + if (options.pipe) + return stats.isFIFO(); + + if (options.socket) + return stats.isSocket(); +} // test +module.exports = _test; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/to.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/to.js new file mode 100644 index 0000000..f029999 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/to.js @@ -0,0 +1,29 @@ +var common = require('./common'); +var fs = require('fs'); +var path = require('path'); + +//@ +//@ ### 'string'.to(file) +//@ +//@ Examples: +//@ +//@ ```javascript +//@ cat('input.txt').to('output.txt'); +//@ ``` +//@ +//@ Analogous to the redirection operator `>` in Unix, but works with JavaScript strings (such as +//@ those returned by `cat`, `grep`, etc). _Like Unix redirections, `to()` will overwrite any existing file!_ +function _to(options, file) { + if (!file) + common.error('wrong arguments'); + + if (!fs.existsSync( path.dirname(file) )) + common.error('no such file or directory: ' + path.dirname(file)); + + try { + fs.writeFileSync(file, this.toString(), 'utf8'); + } catch(e) { + common.error('could not write to file (code '+e.code+'): '+file, true); + } +} +module.exports = _to; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/toEnd.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/toEnd.js new file mode 100644 index 0000000..f6d099d --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/toEnd.js @@ -0,0 +1,29 @@ +var common = require('./common'); +var fs = require('fs'); +var path = require('path'); + +//@ +//@ ### 'string'.toEnd(file) +//@ +//@ Examples: +//@ +//@ ```javascript +//@ cat('input.txt').toEnd('output.txt'); +//@ ``` +//@ +//@ Analogous to the redirect-and-append operator `>>` in Unix, but works with JavaScript strings (such as +//@ those returned by `cat`, `grep`, etc). +function _toEnd(options, file) { + if (!file) + common.error('wrong arguments'); + + if (!fs.existsSync( path.dirname(file) )) + common.error('no such file or directory: ' + path.dirname(file)); + + try { + fs.appendFileSync(file, this.toString(), 'utf8'); + } catch(e) { + common.error('could not append to file (code '+e.code+'): '+file, true); + } +} +module.exports = _toEnd; diff --git a/config/tizen/tpk-tools/cli/node_modules/shelljs/src/which.js b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/which.js new file mode 100644 index 0000000..2822ecf --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/shelljs/src/which.js @@ -0,0 +1,83 @@ +var common = require('./common'); +var fs = require('fs'); +var path = require('path'); + +// Cross-platform method for splitting environment PATH variables +function splitPath(p) { + for (i=1;i<2;i++) {} + + if (!p) + return []; + + if (common.platform === 'win') + return p.split(';'); + else + return p.split(':'); +} + +function checkPath(path) { + return fs.existsSync(path) && fs.statSync(path).isDirectory() == false; +} + +//@ +//@ ### which(command) +//@ +//@ Examples: +//@ +//@ ```javascript +//@ var nodeExec = which('node'); +//@ ``` +//@ +//@ Searches for `command` in the system's PATH. On Windows looks for `.exe`, `.cmd`, and `.bat` extensions. +//@ Returns string containing the absolute path to the command. +function _which(options, cmd) { + if (!cmd) + common.error('must specify command'); + + var pathEnv = process.env.path || process.env.Path || process.env.PATH, + pathArray = splitPath(pathEnv), + where = null; + + // No relative/absolute paths provided? + if (cmd.search(/\//) === -1) { + // Search for command in PATH + pathArray.forEach(function(dir) { + if (where) + return; // already found it + + var attempt = path.resolve(dir + '/' + cmd); + if (checkPath(attempt)) { + where = attempt; + return; + } + + if (common.platform === 'win') { + var baseAttempt = attempt; + attempt = baseAttempt + '.exe'; + if (checkPath(attempt)) { + where = attempt; + return; + } + attempt = baseAttempt + '.cmd'; + if (checkPath(attempt)) { + where = attempt; + return; + } + attempt = baseAttempt + '.bat'; + if (checkPath(attempt)) { + where = attempt; + return; + } + } // if 'win' + }); + } + + // Command not found anywhere? + if (!checkPath(cmd) && !where) + return null; + + where = where || path.resolve(cmd); + + return common.ShellString(where); +} +module.exports = _which; diff --git a/config/tizen/tpk-tools/cli/node_modules/string-template/.npmignore b/config/tizen/tpk-tools/cli/node_modules/string-template/.npmignore new file mode 100644 index 0000000..f1250e5 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/string-template/.npmignore @@ -0,0 +1,4 @@ +support +test +examples +*.sock diff --git a/config/tizen/tpk-tools/cli/node_modules/string-template/.travis.yml b/config/tizen/tpk-tools/cli/node_modules/string-template/.travis.yml new file mode 100644 index 0000000..57c94b2 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/string-template/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - "0.10" +before_script: + - npm install + - npm install istanbul coveralls +script: npm run travis-test diff --git a/config/tizen/tpk-tools/cli/node_modules/string-template/LICENCE b/config/tizen/tpk-tools/cli/node_modules/string-template/LICENCE new file mode 100644 index 0000000..a5609a1 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/string-template/LICENCE @@ -0,0 +1,19 @@ +Copyright (c) 2013 Matt Esch. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/config/tizen/tpk-tools/cli/node_modules/string-template/Readme.md b/config/tizen/tpk-tools/cli/node_modules/string-template/Readme.md new file mode 100644 index 0000000..9b976e9 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/string-template/Readme.md @@ -0,0 +1,103 @@ +# string-template + +[![build status][1]][2] [![dependency status][3]][4] [![coverage report][9]][10] [![stability index][15]][16] + +[![npm stats][13]][14] + +[![browser support][5]][6] + + A simple string template function based on named or indexed arguments + +## Example + +```js +var format = require("string-template") +var greeting + +// Format using an object hash with keys matching [0-9a-zA-Z]+ + +greeting = format("Hello {name}, you have {count} unread messages", { + name: "Robert", + count: 12 +}) +// greeting -> "Hello Robert, you have 12 unread messages" + + +// Format using a number indexed array + +greeting = format("Hello {0}, you have {1} unread messages", ["Robert", 12]) +// greeting -> "Hello Robert, you have 12 unread messages" + + +// Format using optional arguments + +greeting = format("Hello {0}, you have {1} unread messages", + "Robert", + 12) +// greeting -> "Hello Robert, you have 12 unread messages" + + +// Escape {} pairs by using double {{}} + +var text = format("{{0}}") +// text -> "{0}" + +``` + +## Compiling templates + +`string-template` exposes two template compiling options for when you need the +additional performance. Arguments passed to the compiled template are of the +same structure as the main `string-template` function, so either a single +object/array or a list of arguments. + +```js +var compile = require("string-template/compile") + +var greetingTemplate = compile("Hello {0}, you have {1} unread messages") + +var greeting = greetingTemplate("Robert", 12) +// -> "Hello Robert, you have 12 unread messages" +``` + +Passing a truthy second argument to `compile` will opt into using `new Function` +to generate a function. The function returned contains a literal string +concatenation statement, interleaving the correct arguments you have passed in. + +```js +var compile = require("string-template/compile") + +var greetingTemplate = compile("Hello {0}, you have {1} unread messages", true) +// -> greetingTemplate generated using new Function + +var greeting = greetingTemplate(["Robert", 12]) +// -> "Hello Robert, you have 12 unread messages" +``` + +## Installation + +`npm install string-template` + +## Contributors + + - Matt-Esch + +## MIT Licenced + + [1]: https://secure.travis-ci.org/Matt-Esch/string-template.png + [2]: https://travis-ci.org/Matt-Esch/string-template + [3]: https://david-dm.org/Matt-Esch/string-template.png + [4]: https://david-dm.org/Matt-Esch/string-template + [5]: https://ci.testling.com/Matt-Esch/string-template.png + [6]: https://ci.testling.com/Matt-Esch/string-template + [9]: https://coveralls.io/repos/Matt-Esch/string-template/badge.png + [10]: https://coveralls.io/r/Matt-Esch/string-template + [13]: https://nodei.co/npm/string-template.png?downloads=true&stars=true + [14]: https://nodei.co/npm/string-template + [15]: http://hughsk.github.io/stability-badges/dist/unstable.svg + [16]: http://github.com/hughsk/stability-badges + + [7]: https://badge.fury.io/js/string-template.png + [8]: https://badge.fury.io/js/string-template + [11]: https://gemnasium.com/Matt-Esch/string-template.png + [12]: https://gemnasium.com/Matt-Esch/string-template diff --git a/config/tizen/tpk-tools/cli/node_modules/string-template/compile.js b/config/tizen/tpk-tools/cli/node_modules/string-template/compile.js new file mode 100644 index 0000000..18a48bf --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/string-template/compile.js @@ -0,0 +1,143 @@ +var template = require("./index") + +var whitespaceRegex = /["'\\\n\r\u2028\u2029]/g +var nargs = /\{[0-9a-zA-Z]+\}/g + +var replaceTemplate = +" var args\n" + +" var result\n" + +" if (arguments.length === 1 && typeof arguments[0] === \"object\") {\n" + +" args = arguments[0]\n" + +" } else {\n" + +" args = arguments" + +" }\n\n" + +" if (!args || !(\"hasOwnProperty\" in args)) {\n" + +" args = {}\n" + +" }\n\n" + +" return {0}" + +var literalTemplate = "\"{0}\"" +var argTemplate = "(result = args.hasOwnProperty(\"{0}\") ? " + + "args[\"{0}\"] : null, \n " + + "(result === null || result === undefined) ? \"\" : result)" + +module.exports = compile + +function compile(string, inline) { + var replacements = string.match(nargs) + var interleave = string.split(nargs) + var replace = [] + + for (var i = 0; i < interleave.length; i++) { + var current = interleave[i]; + var replacement = replacements[i]; + var escapeLeft = current.charAt(current.length - 1) + var escapeRight = (interleave[i + 1] || "").charAt(0) + + if (replacement) { + replacement = replacement.substring(1, replacement.length - 1) + } + + if (escapeLeft === "{" && escapeRight === "}") { + replace.push(current + replacement) + } else { + replace.push(current); + if (replacement) { + replace.push({ name: replacement }) + } + } + } + + var prev = [""] + + for (var j = 0; j < replace.length; j++) { + var curr = replace[j] + + if (String(curr) === curr) { + var top = prev[prev.length - 1] + + if (String(top) === top) { + prev[prev.length - 1] = top + curr + } else { + prev.push(curr) + } + } else { + prev.push(curr) + } + } + + replace = prev + + if (inline) { + for (var k = 0; k < replace.length; k++) { + var token = replace[k] + + if (String(token) === token) { + replace[k] = template(literalTemplate, escape(token)) + } else { + replace[k] = template(argTemplate, escape(token.name)) + } + } + + var replaceCode = replace.join(" +\n ") + var compiledSource = template(replaceTemplate, replaceCode) + return new Function(compiledSource) + } + + return function template() { + var args + + if (arguments.length === 1 && typeof arguments[0] === "object") { + args = arguments[0] + } else { + args = arguments + } + + if (!args || !("hasOwnProperty" in args)) { + args = {} + } + + var result = [] + + for (var i = 0; i < replace.length; i++) { + if (i % 2 === 0) { + result.push(replace[i]) + } else { + var argName = replace[i].name + var arg = args.hasOwnProperty(argName) ? args[argName] : null + if (arg !== null || arg !== undefined) { + result.push(arg) + } + } + } + + return result.join("") + } +} + +function escape(string) { + string = '' + string; + + return string.replace(whitespaceRegex, escapedWhitespace); +} + +function escapedWhitespace(character) { + // Escape all characters not included in SingleStringCharacters and + // DoubleStringCharacters on + // http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4 + switch (character) { + case '"': + case "'": + case '\\': + return '\\' + character + // Four possible LineTerminator characters need to be escaped: + case '\n': + return '\\n' + case '\r': + return '\\r' + case '\u2028': + return '\\u2028' + case '\u2029': + return '\\u2029' + } +} diff --git a/config/tizen/tpk-tools/cli/node_modules/string-template/index.js b/config/tizen/tpk-tools/cli/node_modules/string-template/index.js new file mode 100644 index 0000000..012cec2 --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/string-template/index.js @@ -0,0 +1,34 @@ +var nargs = /\{([0-9a-zA-Z]+)\}/g +var slice = Array.prototype.slice + +module.exports = template + +function template(string) { + var args + + if (arguments.length === 2 && typeof arguments[1] === "object") { + args = arguments[1] + } else { + args = slice.call(arguments, 1) + } + + if (!args || !args.hasOwnProperty) { + args = {} + } + + return string.replace(nargs, function replaceArg(match, i, index) { + var result + + if (string[index - 1] === "{" && + string[index + match.length] === "}") { + return i + } else { + result = args.hasOwnProperty(i) ? args[i] : null + if (result === null || result === undefined) { + return "" + } + + return result + } + }) +} diff --git a/config/tizen/tpk-tools/cli/node_modules/string-template/package.json b/config/tizen/tpk-tools/cli/node_modules/string-template/package.json new file mode 100644 index 0000000..5886ede --- /dev/null +++ b/config/tizen/tpk-tools/cli/node_modules/string-template/package.json @@ -0,0 +1,119 @@ +{ + "_args": [ + [ + { + "raw": "string-template@0.2.1", + "scope": null, + "escapedName": "string-template", + "name": "string-template", + "rawSpec": "0.2.1", + "spec": "0.2.1", + "type": "version" + }, + "/home/sumin/iotjs-tpk/cli" + ] + ], + "_from": "string-template@0.2.1", + "_id": "string-template@0.2.1", + "_inCache": true, + "_location": "/string-template", + "_nodeVersion": "0.10.32", + "_npmUser": { + "name": "mattesch", + "email": "matt@mattesch.info" + }, + "_npmVersion": "2.7.4", + "_phantomChildren": {}, + "_requested": { + "raw": "string-template@0.2.1", + "scope": null, + "escapedName": "string-template", + "name": "string-template", + "rawSpec": "0.2.1", + "spec": "0.2.1", + "type": "version" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/string-template/-/string-template-0.2.1.tgz", + "_shasum": "42932e598a352d01fc22ec3367d9d84eec6c9add", + "_shrinkwrap": null, + "_spec": "string-template@0.2.1", + "_where": "/home/sumin/iotjs-tpk/cli", + "author": { + "name": "Matt-Esch", + "email": "matt@mattesch.info" + }, + "bugs": { + "url": "https://github.com/Matt-Esch/string-template/issues", + "email": "matt@mattesch.info" + }, + "contributors": [ + { + "name": "Matt-Esch" + } + ], + "dependencies": {}, + "description": "A simple string template function based on named or indexed arguments", + "devDependencies": { + "tape": "~1.1.1" + }, + "directories": {}, + "dist": { + "shasum": "42932e598a352d01fc22ec3367d9d84eec6c9add", + "tarball": "https://registry.npmjs.org/string-template/-/string-template-0.2.1.tgz" + }, + "gitHead": "311a15c48344fe386ec139906efc382af22f33b6", + "homepage": "https://github.com/Matt-Esch/string-template", + "keywords": [ + "template", + "string", + "format", + "replace", + "arguments" + ], + "licenses": [ + { + "type": "MIT", + "url": "http://github.com/Matt-Esch/string-template/raw/master/LICENSE" + } + ], + "main": "index", + "maintainers": [ + { + "name": "mattesch", + "email": "matt@mattesch.info" + } + ], + "name": "string-template", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/Matt-Esch/string-template.git" + }, + "scripts": { + "cover": "istanbul cover --report none --print detail ./test/index.js", + "test": "node ./test/index.js", + "travis-test": "istanbul cover ./test/index.js && ((cat coverage/lcov.info | coveralls) || exit 0)", + "view-cover": "istanbul report html && google-chrome ./coverage/index.html" + }, + "testling": { + "files": "test/index.js", + "browsers": [ + "ie/8..latest", + "firefox/16..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2..latest" + ] + }, + "version": "0.2.1" +} diff --git a/config/tizen/tpk-tools/cli/package.json b/config/tizen/tpk-tools/cli/package.json new file mode 100644 index 0000000..b6db175 --- /dev/null +++ b/config/tizen/tpk-tools/cli/package.json @@ -0,0 +1,34 @@ +{ + "name": "jsn-cli", + "version": "0.1.0", + "preferGlobal": "true", + "description": "command-line interface for js native runtime", + "main": "jsn-cli", + "bin": { + "jsn-cli": "./bin/jsn-cli" + }, + "engines": { + "node": ">= 0.10.25" + }, + "dependencies": { + "elementtree": "0.1.6", + "pretty-data": "0.40.0", + "q": "1.4.1", + "shelljs": "0.5.3", + "string-template": "0.2.1" + }, + "author": { + "name": "Yongseop Kim", + "email": "yons.kim@samsung.com" + }, + "contributors": [ + { + "name": "Yongseop Kim", + "email": "yons.kim@samsung.com" + }, + { + "name": "Joonghyun Cho", + "email": "jh5.cho@samsung.com" + } + ] +} diff --git a/config/tizen/tpk-tools/cli/tizen-app-template/icon.png b/config/tizen/tpk-tools/cli/tizen-app-template/icon.png new file mode 100755 index 0000000..9765b1b Binary files /dev/null and b/config/tizen/tpk-tools/cli/tizen-app-template/icon.png differ diff --git a/config/tizen/tpk-tools/cli/tizen-app-template/index.js b/config/tizen/tpk-tools/cli/tizen-app-template/index.js new file mode 100755 index 0000000..e65e40c --- /dev/null +++ b/config/tizen/tpk-tools/cli/tizen-app-template/index.js @@ -0,0 +1,38 @@ +console.log("Hello, This is an iotjs.app on Tizen"); +console.log("Please, set date on your device before start, > date -s \"2017-MM-DD\" "); + + +var gcontext = require('gcontext'); +gcontext.init(); + +var https = require('https'); +var isRequest1Finished = false; +// 1. GET req +options = { + method: 'GET', + host: "httpbin.org", + path: '/user-agent', + headers: {'user-agent': 'iotjs'} +}; + +var getResponseHandler = function (res) { + var res_body = ''; + + console.log("statusCode:"+res.statusCode); + + var endHandler = function(){ + var response = JSON.parse(res_body); + console.log(response['user-agent']); + isRequest1Finished = true; + }; + res.on('end', endHandler); + + res.on('data', function(chunk){ + res_body += chunk.toString(); + }); +}; + +for (i = 0; i < 50; i++) { + https.get(options, getResponseHandler); +} +gcontext.uninit(); diff --git a/config/tizen/tpk-tools/cli/tizen-app-template/pkgid.appid b/config/tizen/tpk-tools/cli/tizen-app-template/pkgid.appid new file mode 100755 index 0000000..054bfe9 --- /dev/null +++ b/config/tizen/tpk-tools/cli/tizen-app-template/pkgid.appid @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +iotjs /opt/usr/home/owner/apps_rw/{pkgid}/res/{appid}/index.js diff --git a/config/tizen/tpk-tools/cli/tizen-app-template/tizen-manifest.xml b/config/tizen/tpk-tools/cli/tizen-app-template/tizen-manifest.xml new file mode 100755 index 0000000..3f79fa7 --- /dev/null +++ b/config/tizen/tpk-tools/cli/tizen-app-template/tizen-manifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/author-signature.xml b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/author-signature.xml new file mode 100644 index 0000000..b57e8d5 --- /dev/null +++ b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/author-signature.xml @@ -0,0 +1,74 @@ + + + + + + +1zmZfiVUlhHcMioUj3Fh8N1VrMrSIDabsib1faJ+svQ= + + + +Wh8+69+ns0t+IPANgzs+ZmxY3pHZHZjb4ZD9FSRJP1A= + + + +CfBPOs/yNozVCWXdNJgPj5564KAQGTTXzavekbo4tv0= + + + +1d0oEZHqPn+QzNzGIHwj9ODby6x9ggFs9uOsav6jPNs= + + + +jxD3m601uAX1pp1TCme05OMQVGScExlGZ6qaHSJ1tEw= + + + + + + +lpo8tUDs054eLlBQXiDPVDVKfw30ZZdtkRs1jd7H5K8= + + + +Rn1gUr+Oxlm4L3t1ReKq+QnEzrb6joVou4H2SeRcCnzr6mq5LrmwOYu2YDkBDQ2PWX6jxkJrRIrc +nRDTnEmD553DomkhSBWnZwxspj+PHP0fIsC7VkUxpnhec36/LVm6rkFTv9Nij9NwBKmIbD7QdBkq +IpQ0iRCvaZzKMdBpNXs= + + + + +MIIClDCCAXygAwIBAgIGAV4+hGehMA0GCSqGSIb3DQEBBQUAMFYxGjAYBgNVBAoMEVRpemVuIEFz +c29jaWF0aW9uMRowGAYDVQQLDBFUaXplbiBBc3NvY2lhdGlvbjEcMBoGA1UEAwwTVGl6ZW4gRGV2 +ZWxvcGVycyBDQTAeFw0xMjExMDEwMDAwMDBaFw0xOTAxMDEwMDAwMDBaMBAxDjAMBgNVBAMMBWth +bmdhMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCEoDh1k+4ojdpRMJ9UvZ5C4qfs3KKyOIhd +RJCahiiTaPlTDZwlfZKv5l9wKBboZjWm2DLgoXLpUclFgHFnRL0ANaQs9XZ+FqdtSzYNoDM3e6MX +M5DBFJwhnA+fP9py/V7TcB20Fv5fc3E7q3vyUid2eG59N7JYpjk+46FUaSM/IQIDAQABozIwMDAM +BgNVHRMBAf8EAjAAMAsGA1UdDwQEAwIHgDATBgNVHSUEDDAKBggrBgEFBQcDAzANBgkqhkiG9w0B +AQUFAAOCAQEAQb6rnntv/dcmiTgSCn5MxjUMqUKt4kU20tTBTUonLftmUlFC0JFfZksED8igTsmO +sWTVbIwFC9DaqDE3Vcr4GD0fKtjGI18oY42rG3j28GoJeIA0YKaYySvcgFKeLF7ZaAUtsifKitrH +COWpcbLOfm3u9ueWM9Z0NwvCp3+NEBPw4w5fgoEVL64U+rZXAYrSEabdR16lK17AZdQIqwcrhlOR +2KSgPj2WsqqZDyOF4s9W6wNsH5W2H6vMd2dNy1FLNb6QyY8CI0x3ranSwuLaZVLe9gfe+2ij6ooX +0R2LXaVK5UdHaWa+d6rJMVGQMHFdZ7fxdRizGOaZjIZ88q/2jA== + + +MIIDOTCCAiGgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMRowGAYDVQQKDBFUaXplbiBBc3NvY2lh +dGlvbjEaMBgGA1UECwwRVGl6ZW4gQXNzb2NpYXRpb24xHjAcBgNVBAMMFVRpemVuIERldmVsb3Bl +cnMgUm9vdDAeFw0xMjAxMDEwMDAwMDBaFw0yNzAxMDEwMDAwMDBaMFYxGjAYBgNVBAoMEVRpemVu +IEFzc29jaWF0aW9uMRowGAYDVQQLDBFUaXplbiBBc3NvY2lhdGlvbjEcMBoGA1UEAwwTVGl6ZW4g +RGV2ZWxvcGVycyBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANVGhRGmMIUyBA7o +PCz8Sxut6z6HNkF4oDIuzuKaMzRYPeWodwe9O0gmqAkToQHfwg2giRhE5GoPld0fq+OYMMwSasCu +g8dwODx1eDeSYVuOLWRxpAmbTXOsSFi6VoWeyaPEm18JBHvZBsU5YQtgZ6Kp7MqzvQg3pXOxtajj +vyHxiatJl+xXrHgcXC1wgyG3buty7u/Fi2mvKXJ0PRJcCjjK81dqe/Vr20sRUCrbk02zbm5ggFt/ +jIEhV8wbFRQpliobc7J4dSTKhFfrqGM8rdd54LYhD7gSI1CFSe16pUXfcVR7FhJztRaiGLnCrwBE +dyTZ248+D4L/qR/D0axb3jcCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOC +AQEAnOXXQ/1O/QTDHyrmQDtFziqPY3xWlJBqJtEqXiT7Y+Ljpe66e+Ee/OjQMlZe8gu21/8cKklH +95RxjopMWCVedXDUbWdvS2+CdyvVW/quT2E0tjqIzXDekUTYwwhlPWlGxvfj3VsxqSFq3p8Brl04 +1Gx5RKAGyKVsMfTLhbbwSWwApuBUxYfcNpKwLWGPXkysu+HctY03OKv4/xKBnVWiN8ex/Sgesi0M ++OBAOMdZMPK32uJBTeKFx1xZgTLIhk45V0hPOomPjZloiv0LSS11eyd451ufjW0iHRE7WlpR6EvI +W6TFyZgMpQq+kg4hWl2SBTf3s2VI8Ygz7gj8TMlClg== + + + + + \ No newline at end of file diff --git a/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/bin/tizen.org.iotjs-pkg.tizen.org.iotjs-app b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/bin/tizen.org.iotjs-pkg.tizen.org.iotjs-app new file mode 100755 index 0000000..b5b0c9f --- /dev/null +++ b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/bin/tizen.org.iotjs-pkg.tizen.org.iotjs-app @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +iotjs /opt/usr/home/owner/apps_rw/tizen.org.iotjs-pkg/res/tizen.org.iotjs-app/index.js diff --git a/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/buildscript.sh b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/buildscript.sh new file mode 100755 index 0000000..9bc167c --- /dev/null +++ b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/buildscript.sh @@ -0,0 +1 @@ +jsn-cli build sign ~/tizen-studio/tools/ide/bin/native-signing ~/tizen-studio/tools/certificate-generator/certificates/developer/tizen-developer-ca.cer ~/tizen-studio-data/keystore/author/[AUTHOR_NAME].p12 [PASSWORD] ~/tizen-studio/tools/certificate-generator/certificates/distributor/tizen-distributor-signer.p12 tizenpkcs12passfordsigner ~/tizen-studio/tools/certificate-generator/certificates/distributor/tizen-distributor-ca.cer diff --git a/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/res/tizen.org.iotjs-app/index.js b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/res/tizen.org.iotjs-app/index.js new file mode 100755 index 0000000..1c7a152 --- /dev/null +++ b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/res/tizen.org.iotjs-app/index.js @@ -0,0 +1,33 @@ +console.log("Hello, This is an iotjs.app on Tizen. Tizen-application, with App Framework will be prepared. "); + +/* +#!/usr/bin/env node +var app = require('tizen-application'); + +app.on('appcontrol', function(appcontrol) { + // Handle the launch request + console.log('[appcontrol] operation : ' + appcontrol.operation); +}); + +app.on('pause', function() { + // Take necessary actions when application becomes invisible. + console.log('[pause]'); +}); + +app.on('resume', function() { + // Take necessary actions when application becomes visible. + console.log('[resume]'); +}); + +app.on('terminate', function() { + // Release all resources. + console.log('[terminate]'); +}); + +app.start().then(function() { + // Initialize UI resources and application's data. + console.log('[started]'); +}).catch(function(e) { + console.log('Failed to start application : ' + e.message); +}); +*/ diff --git a/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/shared/res/icon.png b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/shared/res/icon.png new file mode 100755 index 0000000..9765b1b Binary files /dev/null and b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/shared/res/icon.png differ diff --git a/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/signature1.xml b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/signature1.xml new file mode 100644 index 0000000..f3b9eb2 --- /dev/null +++ b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/signature1.xml @@ -0,0 +1,76 @@ + + + + + + +8erGopu9KXbXFy1228zGv/bSeYCtwZzH8IuBFkPtPrk= + + + +1zmZfiVUlhHcMioUj3Fh8N1VrMrSIDabsib1faJ+svQ= + + + +Wh8+69+ns0t+IPANgzs+ZmxY3pHZHZjb4ZD9FSRJP1A= + + + +CfBPOs/yNozVCWXdNJgPj5564KAQGTTXzavekbo4tv0= + + + +1d0oEZHqPn+QzNzGIHwj9ODby6x9ggFs9uOsav6jPNs= + + + +jxD3m601uAX1pp1TCme05OMQVGScExlGZ6qaHSJ1tEw= + + + + + + +u/jU3U4Zm5ihTMSjKGlGYbWzDfRkGphPPHx3gJIYEJ4= + + + +l+qc5AaScgHqxs0qwZFsw1G2YZo1sGiCfTSDUFG10jRwXgDff88EpTsDtpWyk54EPKvLePSYo9+M +D7AMncUHy0t4JuezMQXKEdTtoDNMc2K8+sm550WwZPkLlIXa3EigSCngEljh5Gc1n6BOhQH8C0Dc +u7MYV7jhVHKujKT8m9s= + + + + +MIICmzCCAgQCCQDXI7WLdVZwiTANBgkqhkiG9w0BAQUFADCBjzELMAkGA1UEBhMCS1IxDjAMBgNV +BAgMBVN1d29uMQ4wDAYDVQQHDAVTdXdvbjEWMBQGA1UECgwNVGl6ZW4gVGVzdCBDQTEiMCAGA1UE +CwwZVGl6ZW4gRGlzdHJpYnV0b3IgVGVzdCBDQTEkMCIGA1UEAwwbVGl6ZW4gUHVibGljIERpc3Ry +aWJ1dG9yIENBMB4XDTEyMTAyOTEzMDMwNFoXDTIyMTAyNzEzMDMwNFowgZMxCzAJBgNVBAYTAktS +MQ4wDAYDVQQIDAVTdXdvbjEOMAwGA1UEBwwFU3V3b24xFjAUBgNVBAoMDVRpemVuIFRlc3QgQ0Ex +IjAgBgNVBAsMGVRpemVuIERpc3RyaWJ1dG9yIFRlc3QgQ0ExKDAmBgNVBAMMH1RpemVuIFB1Ymxp +YyBEaXN0cmlidXRvciBTaWduZXIwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALtMvlc5hENK +90ZdA+y66+Sy0enD1gpZDBh5T9RP0oRsptJv5jjNTseQbQi0SZOdOXb6J7iQdlBCtR343RpIEz8H +mrBy7mSY7mgwoU4EPpp4CTSUeAuKcmvrNOngTp5Hv7Ngf02TTHOLK3hZLpGayaDviyNZB5PdqQdB +hokKjzAzAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAvGp1gxxAIlFfhJH1efjb9BJK/rtRkbYn9+Ez +GEbEULg1svsgnyWisFimI3uFvgI/swzr1eKVY3Sc8MQ3+Fdy3EkbDZ2+WAubhcEkorTWjzWz2fL1 +vKaYjeIsuEX6TVRUugHWudPzcEuQRLQf8ibZWjbQdBmpeQYBMg5x+xKLCJc= + + +MIICtDCCAh2gAwIBAgIJAMDbehElPNKvMA0GCSqGSIb3DQEBBQUAMIGVMQswCQYDVQQGEwJLUjEO +MAwGA1UECAwFU3V3b24xDjAMBgNVBAcMBVN1d29uMRYwFAYDVQQKDA1UaXplbiBUZXN0IENBMSMw +IQYDVQQLDBpUVGl6ZW4gRGlzdHJpYnV0b3IgVGVzdCBDQTEpMCcGA1UEAwwgVGl6ZW4gUHVibGlj +IERpc3RyaWJ1dG9yIFJvb3QgQ0EwHhcNMTIxMDI5MTMwMjUwWhcNMjIxMDI3MTMwMjUwWjCBjzEL +MAkGA1UEBhMCS1IxDjAMBgNVBAgMBVN1d29uMQ4wDAYDVQQHDAVTdXdvbjEWMBQGA1UECgwNVGl6 +ZW4gVGVzdCBDQTEiMCAGA1UECwwZVGl6ZW4gRGlzdHJpYnV0b3IgVGVzdCBDQTEkMCIGA1UEAwwb +VGl6ZW4gUHVibGljIERpc3RyaWJ1dG9yIENBMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDe +OTS/3nXvkDEmsFCJIvRlQ3RKDcxdWJJp625pFqHdmoJBdV+x6jl1raGK2Y1sp2Gdvpjc/z92yzAp +bE/UVLPh/tRNZPeGhzU4ejDDm7kzdr2f7Ia0U98K+OoY12ucwg7TYNItj9is7Cj4blGfuMDzd2ah +2AgnCGlwNwV/pv+uVQIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACqJ +KO33YdoGudwanZIxMdXuxnnD9R6u72ltKk1S4zPfMJJv482CRGCI4FK6djhlsI4i0Lt1SVIJEed+ +yc3qckGm19dW+4xdlkekon7pViEBWuyHw8OWv3RXtTum1+PGHjBJ2eYY4ZKIpz73U/1NC16sTB/0 +VhfnkHwPltmrpYVe + + + + + \ No newline at end of file diff --git a/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/tizen-manifest.xml b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/tizen-manifest.xml new file mode 100644 index 0000000..49f2886 --- /dev/null +++ b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/tizen-manifest.xml @@ -0,0 +1,8 @@ + + + + icon.png + + + diff --git a/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/tizen.org.iotjs-pkg.tpk b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/tizen.org.iotjs-pkg.tpk new file mode 100644 index 0000000..75c8226 Binary files /dev/null and b/config/tizen/tpk-tools/sample_app/tizen.org.iotjs-pkg/tizen.org.iotjs-pkg.tpk differ