├── .editorconfig ├── .gitattributes ├── .github └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .ratignore ├── CMakeLists.txt ├── CONTRIBUTING.md ├── CordovaUbuntu ├── CordovaViewInternal.qml ├── ItemSelector.qml ├── cordova_wrapper.js ├── escape.js └── qmldir ├── LICENSE ├── README.md ├── RELEASENOTES.md ├── VERSION ├── bin ├── check_reqs ├── create ├── lib │ ├── check_reqs.js │ ├── create.js │ └── update.js ├── templates │ └── project │ │ ├── cordova │ │ ├── build │ │ ├── clean │ │ ├── defaults.xml │ │ ├── lib │ │ │ ├── build.js │ │ │ ├── config.js │ │ │ ├── config_parser.js │ │ │ ├── constants.js │ │ │ ├── device.js │ │ │ ├── logger.js │ │ │ ├── manifest.js │ │ │ ├── run.js │ │ │ └── utils.js │ │ ├── run │ │ └── version │ │ └── misc │ │ ├── changelog │ │ ├── compat │ │ ├── control │ │ ├── cordova.desktop │ │ ├── install │ │ └── rules └── update ├── cordova-js-src ├── exec.js └── platform.js ├── default_icon.png ├── main.cpp ├── node_modules ├── .bin │ └── shjs ├── colors │ ├── MIT-LICENSE.txt │ ├── ReadMe.md │ ├── colors.js │ ├── example.html │ ├── example.js │ ├── package.json │ ├── test.js │ └── themes │ │ ├── winston-dark.js │ │ └── winston-light.js ├── elementtree │ ├── .npmignore │ ├── .travis.yml │ ├── CHANGES.md │ ├── LICENSE.txt │ ├── Makefile │ ├── NOTICE │ ├── README.md │ ├── lib │ │ ├── constants.js │ │ ├── elementpath.js │ │ ├── elementtree.js │ │ ├── errors.js │ │ ├── parser.js │ │ ├── parsers │ │ │ ├── index.js │ │ │ └── sax.js │ │ ├── sprintf.js │ │ ├── treebuilder.js │ │ └── utils.js │ ├── node_modules │ │ └── sax │ │ │ ├── AUTHORS │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── examples │ │ │ ├── big-not-pretty.xml │ │ │ ├── example.js │ │ │ ├── get-products.js │ │ │ ├── hello-world.js │ │ │ ├── not-pretty.xml │ │ │ ├── pretty-print.js │ │ │ ├── shopping.xml │ │ │ ├── strict.dtd │ │ │ ├── switch-bench.js │ │ │ ├── test.html │ │ │ └── test.xml │ │ │ ├── lib │ │ │ └── sax.js │ │ │ ├── package.json │ │ │ └── test │ │ │ ├── buffer-overrun.js │ │ │ ├── cdata-chunked.js │ │ │ ├── cdata-end-split.js │ │ │ ├── cdata-fake-end.js │ │ │ ├── cdata-multiple.js │ │ │ ├── cdata.js │ │ │ ├── index.js │ │ │ ├── issue-23.js │ │ │ ├── issue-30.js │ │ │ ├── issue-35.js │ │ │ ├── issue-47.js │ │ │ ├── issue-49.js │ │ │ ├── parser-position.js │ │ │ ├── script.js │ │ │ ├── self-closing-child-strict.js │ │ │ ├── self-closing-child.js │ │ │ ├── self-closing-tag.js │ │ │ ├── stray-ending.js │ │ │ ├── trailing-non-whitespace.js │ │ │ ├── unquoted.js │ │ │ ├── xmlns-issue-41.js │ │ │ ├── xmlns-rebinding.js │ │ │ ├── xmlns-strict.js │ │ │ ├── xmlns-unbound.js │ │ │ ├── xmlns-xml-default-prefix-attribute.js │ │ │ ├── xmlns-xml-default-prefix.js │ │ │ └── xmlns-xml-default-redefine.js │ ├── package.json │ └── tests │ │ ├── data │ │ ├── xml1.xml │ │ └── xml2.xml │ │ └── test-simple.js ├── optimist │ ├── .travis.yml │ ├── LICENSE │ ├── example │ │ ├── bool.js │ │ ├── boolean_double.js │ │ ├── boolean_single.js │ │ ├── default_hash.js │ │ ├── default_singles.js │ │ ├── divide.js │ │ ├── line_count.js │ │ ├── line_count_options.js │ │ ├── line_count_wrap.js │ │ ├── nonopt.js │ │ ├── reflect.js │ │ ├── short.js │ │ ├── string.js │ │ ├── usage-options.js │ │ └── xup.js │ ├── index.js │ ├── node_modules │ │ ├── minimist │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── example │ │ │ │ └── parse.js │ │ │ ├── index.js │ │ │ ├── package.json │ │ │ ├── readme.markdown │ │ │ └── test │ │ │ │ ├── bool.js │ │ │ │ ├── dash.js │ │ │ │ ├── default_bool.js │ │ │ │ ├── dotted.js │ │ │ │ ├── long.js │ │ │ │ ├── num.js │ │ │ │ ├── parse.js │ │ │ │ ├── parse_modified.js │ │ │ │ ├── short.js │ │ │ │ └── whitespace.js │ │ └── wordwrap │ │ │ ├── LICENSE │ │ │ ├── README.markdown │ │ │ ├── example │ │ │ ├── center.js │ │ │ └── meat.js │ │ │ ├── index.js │ │ │ ├── package.json │ │ │ └── test │ │ │ ├── break.js │ │ │ ├── idleness.txt │ │ │ └── wrap.js │ ├── package.json │ ├── readme.markdown │ └── test │ │ ├── _.js │ │ ├── _ │ │ ├── argv.js │ │ └── bin.js │ │ ├── dash.js │ │ ├── parse.js │ │ ├── parse_modified.js │ │ ├── short.js │ │ ├── usage.js │ │ └── whitespace.js ├── q │ ├── LICENSE │ ├── README.md │ ├── node_modules │ │ ├── asap │ │ │ ├── CHANGES.md │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ ├── asap.js │ │ │ ├── browser-asap.js │ │ │ ├── browser-raw.js │ │ │ ├── package.json │ │ │ └── raw.js │ │ ├── pop-iterate │ │ │ ├── .npmignore │ │ │ ├── README.md │ │ │ ├── array-iterator.js │ │ │ ├── iteration.js │ │ │ ├── object-iterator.js │ │ │ ├── package.json │ │ │ ├── pop-iterate.js │ │ │ └── test │ │ │ │ └── pop-iterate-test.js │ │ └── weak-map │ │ │ ├── README.md │ │ │ ├── package.json │ │ │ └── weak-map.js │ ├── package.json │ ├── q.js │ └── queue.js └── shelljs │ ├── .documentup.json │ ├── .jshintrc │ ├── .npmignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── bin │ └── shjs │ ├── global.js │ ├── make.js │ ├── package.json │ ├── scripts │ ├── generate-docs.js │ └── run-tests.js │ ├── shell.js │ └── src │ ├── cat.js │ ├── cd.js │ ├── chmod.js │ ├── common.js │ ├── cp.js │ ├── dirs.js │ ├── echo.js │ ├── error.js │ ├── exec.js │ ├── find.js │ ├── grep.js │ ├── ls.js │ ├── mkdir.js │ ├── mv.js │ ├── popd.js │ ├── pushd.js │ ├── pwd.js │ ├── rm.js │ ├── sed.js │ ├── tempdir.js │ ├── test.js │ ├── to.js │ ├── toEnd.js │ └── which.js ├── package.json ├── qml ├── CordovaView.qml.in └── main.qml.in ├── src ├── cordova.cpp ├── cordova.h ├── cordova_config.cpp ├── cordova_config.hpp ├── cordova_whitelist.cpp ├── cordova_whitelist.hpp ├── coreplugins.cpp ├── coreplugins.h ├── cplugin.cpp ├── cplugin.h ├── plugins │ └── empty ├── qmlplugin.cpp └── qmlplugin.h ├── tests ├── CMakeLists.txt ├── config.xml ├── data │ ├── config.xml │ └── www │ │ └── index.html ├── main.cpp └── www │ └── .touch ├── www └── cordova.js └── xml └── config.xml /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | charset = utf-8 11 | 12 | # 4 space indentation 13 | [*.cpp] 14 | indent_style = space 15 | indent_size = 4 16 | trim_trailing_whitespace = true 17 | 18 | [*.h] 19 | indent_style = space 20 | indent_size = 4 21 | trim_trailing_whitespace = true 22 | 23 | [*.js] 24 | indent_style = space 25 | indent_size = 4 26 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | 3 | # source code 4 | *.php text 5 | *.css text 6 | *.sass text 7 | *.scss text 8 | *.less text 9 | *.styl text 10 | *.js text 11 | *.coffee text 12 | *.json text 13 | *.htm text 14 | *.html text 15 | *.xml text 16 | *.svg text 17 | *.txt text 18 | *.ini text 19 | *.inc text 20 | *.pl text 21 | *.rb text 22 | *.py text 23 | *.scm text 24 | *.sql text 25 | *.sh text 26 | *.bat text 27 | 28 | # templates 29 | *.ejs text 30 | *.hbt text 31 | *.jade text 32 | *.haml text 33 | *.hbs text 34 | *.dot text 35 | *.tmpl text 36 | *.phtml text 37 | 38 | # server config 39 | .htaccess text 40 | 41 | # git config 42 | .gitattributes text 43 | .gitignore text 44 | .gitconfig text 45 | 46 | # code analysis config 47 | .jshintrc text 48 | .jscsrc text 49 | .jshintignore text 50 | .csslintrc text 51 | 52 | # misc config 53 | *.yaml text 54 | *.yml text 55 | .editorconfig text 56 | 57 | # build config 58 | *.npmignore text 59 | *.bowerrc text 60 | 61 | # Heroku 62 | Procfile text 63 | .slugignore text 64 | 65 | # Documentation 66 | *.md text 67 | LICENSE text 68 | AUTHORS text 69 | 70 | 71 | # 72 | ## These files are binary and should be left untouched 73 | # 74 | 75 | # (binary is a macro for -text -diff) 76 | *.png binary 77 | *.jpg binary 78 | *.jpeg binary 79 | *.gif binary 80 | *.ico binary 81 | *.mov binary 82 | *.mp4 binary 83 | *.mp3 binary 84 | *.flv binary 85 | *.fla binary 86 | *.swf binary 87 | *.gz binary 88 | *.zip binary 89 | *.7z binary 90 | *.ttf binary 91 | *.eot binary 92 | *.woff binary 93 | *.pyc binary 94 | *.pdf binary 95 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 9 | 10 | ### Platforms affected 11 | 12 | 13 | ### What does this PR do? 14 | 15 | 16 | ### What testing has been done on this change? 17 | 18 | 19 | ### Checklist 20 | - [ ] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database 21 | - [ ] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected. 22 | - [ ] Added automated test coverage as appropriate for this change. 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.ratignore: -------------------------------------------------------------------------------- 1 | qmldir 2 | compat 3 | control 4 | cordova.desktop 5 | rules 6 | empty 7 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 21 | 22 | # Contributing to Apache Cordova 23 | 24 | Anyone can contribute to Cordova. And we need your contributions. 25 | 26 | There are multiple ways to contribute: report bugs, improve the docs, and 27 | contribute code. 28 | 29 | For instructions on this, start with the 30 | [contribution overview](http://cordova.apache.org/contribute/). 31 | 32 | The details are explained there, but the important items are: 33 | - Sign and submit an Apache ICLA (Contributor License Agreement). 34 | - Have a Jira issue open that corresponds to your contribution. 35 | - Run the tests so your patch doesn't break existing functionality. 36 | 37 | We look forward to your contributions! 38 | -------------------------------------------------------------------------------- /CordovaUbuntu/ItemSelector.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2013 Canonical Ltd. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | * 18 | */ 19 | 20 | import QtQuick 2.0 21 | import Ubuntu.Components 1.1 22 | import Ubuntu.Components.ListItems 1.0 as ListItems 23 | import Ubuntu.Components.Popups 1.0 24 | 25 | Popover { 26 | id: itemSelector 27 | caller: parent 28 | 29 | contentWidth: Math.min(parent.width - units.gu(11), units.gu(39)) 30 | contentHeight: Math.min(parent.height - units.gu(11), listContentHeight) 31 | property real listContentHeight: 0 32 | 33 | property QtObject selectorModel: model 34 | 35 | ListView { 36 | clip: true 37 | width: itemSelector.contentWidth 38 | height: itemSelector.contentHeight 39 | 40 | model: selectorModel.items 41 | 42 | delegate: ListItems.Standard { 43 | text: model.text 44 | enabled: model.enabled 45 | selected: model.selected 46 | onClicked: { 47 | selectorModel.items.select(model.index) 48 | selectorModel.accept() 49 | } 50 | } 51 | 52 | section.property: "group" 53 | section.delegate: ListItems.Header { 54 | text: section 55 | } 56 | 57 | onContentHeightChanged: itemSelector.listContentHeight = contentHeight 58 | } 59 | 60 | Component.onCompleted: show() 61 | 62 | onVisibleChanged: { 63 | if (!visible) { 64 | selectorModel.cancel() 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /CordovaUbuntu/cordova_wrapper.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | var pluginObjects = {} 23 | 24 | // qt 5.2 forbids assigning new properties to JS module 25 | // global variable used by plugins to store temporary data 26 | var global = {}; 27 | 28 | function addPlugin(pluginName, pluginObject) { 29 | pluginObjects[pluginName] = pluginObject 30 | } 31 | 32 | function messageHandler(received) { 33 | if (typeof received === 'undefined') 34 | return false; 35 | if (typeof received.messageType === 'undefined') 36 | return false; 37 | if (received.messageType === "callPluginFunction") { 38 | if (typeof received.plugin === 'undefined' || typeof received.func == 'undefined') 39 | return false; 40 | execMethod(received.plugin, received.func, received.params); 41 | } 42 | return true; 43 | } 44 | 45 | function execMethod(pluginName, functionName, params) { 46 | if (typeof pluginObjects[pluginName][functionName] != "function") 47 | return false; 48 | 49 | pluginObjects[pluginName][functionName].apply(this, params); 50 | return true; 51 | } 52 | -------------------------------------------------------------------------------- /CordovaUbuntu/escape.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 Canonical Ltd. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | * 18 | */ 19 | 20 | window.oxide = oxide; 21 | -------------------------------------------------------------------------------- /CordovaUbuntu/qmldir: -------------------------------------------------------------------------------- 1 | module CordovaUbuntu 2 | plugin cordovaubuntuplugin 3 | CordovaView 4.0 CordovaView.qml 4 | CordovaViewInternal 4.0 CordovaViewInternal.qml 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 21 | 22 | Cordova/Ubuntu 23 | ========== 24 | 25 | --- 26 | 📌 **Deprecation Notice** 27 | 28 | This repository is deprecated and no more work will be done on this by Apache Cordova. You can continue to use this and it should work as-is but any future issues will not be fixed by the Cordova community. 29 | 30 | Feel free to fork this repository and improve your fork. Existing forks are listed in [Network](../../network) and [Forks](../../network/members). 31 | 32 | - Learn more: https://github.com/apache/cordova/blob/master/deprecated.md#deprecated-platforms 33 | --- 34 | 35 | Cordova/Ubuntu is the Ubuntu port of the Apache Cordova project. 36 | 37 | Requirements 38 | ------------ 39 | 40 | - Ubuntu SDK 41 | 42 | License 43 | ------- 44 | 45 | Licensed under the APACHE-2.0 license. See LICENSE file for details. 46 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 4.4.0-dev 2 | -------------------------------------------------------------------------------- /bin/check_reqs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2013, 2014 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | require('./lib/check_reqs').check_reqs(); 23 | -------------------------------------------------------------------------------- /bin/create: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2013, 2014 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | var path = require('path'); 22 | var args = process.argv; 23 | 24 | if (args.length < 3 || (args[2] == '--help' || args[2] == '/?' || args[2] == '-h' || 25 | args[2] == 'help' || args[2] == '-help' || args[2] == '/help')) { 26 | console.log('Usage: ' + path.relative(process.cwd(), path.join(ROOT, 'bin', 'create')) + ' '); 27 | console.log(' : Path to your new Cordova Ubuntu project'); 28 | console.log(' : Package name'); 29 | console.log(' : Project name'); 30 | process.exit(1); 31 | } else { 32 | require('./lib/create').createProject(args[2], args[3], args[4], args[5]); 33 | } 34 | -------------------------------------------------------------------------------- /bin/lib/check_reqs.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2013, 2014 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | var exec = require('child_process').exec; 23 | 24 | exports.check_reqs = function (callback) { 25 | if (!checkNodeDependencies()) { 26 | installNodeDependencies(callback); 27 | } else { 28 | // don't check platform dependencies yet, as they depend on the target 29 | // architecture; the base cordova / node / npm install should be 30 | // sufficient at this stage 31 | callback(); 32 | } 33 | }; 34 | 35 | function checkNodeDependencies() { 36 | try { 37 | require.resolve("shelljs"); 38 | require.resolve("colors"); 39 | require.resolve("optimist"); 40 | require.resolve("q"); 41 | } catch(e) { 42 | // One or more dependencies are missing, need installation. 43 | return false; 44 | } 45 | 46 | return true; 47 | } 48 | 49 | function installNodeDependencies(callback) { 50 | var block = true; 51 | exec('npm install', {cwd: __dirname}, function (error, stdout, stderr) { 52 | block = false; 53 | if (error !== null) { 54 | console.error('ERROR : running \'npm install\' is npm installed? ' + error); 55 | console.error(stderr); 56 | process.exit(error.code); 57 | } 58 | }); 59 | function wait() { 60 | if (block) { 61 | setTimeout(wait, 1500); 62 | } else { 63 | callback(); 64 | } 65 | }; 66 | setTimeout(wait, 1500); 67 | } 68 | -------------------------------------------------------------------------------- /bin/lib/create.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2013, 2014 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | var shell = require('shelljs'); 23 | var path = require('path'); 24 | var fs = require('fs'); 25 | var check_reqs = require('./check_reqs').check_reqs; 26 | 27 | var ROOT = path.join(__dirname, '..', '..'); 28 | 29 | exports.createProject = function(projectPath, packageName, projectName) { 30 | if (fs.existsSync(projectPath)) { 31 | console.error('Project already exists! Delete and recreate'); 32 | process.exit(1); 33 | } 34 | 35 | console.log('Creating a Cordova Project:\n', 36 | 'Project Path: ' + projectPath + '\n', 37 | 'Package Name: ' + packageName + '\n', 38 | 'Project Name: ' + projectName + '\n' 39 | ); 40 | 41 | shell.mkdir(projectPath); 42 | 43 | shell.cp('-r', path.join(ROOT, '*'), path.join(projectPath, 'build')); 44 | 45 | shell.mkdir(path.join(projectPath, 'native')); 46 | 47 | // Copy the necessary node_modules for building and running the project. 48 | shell.cp('-r', path.join(ROOT, 'node_modules'), path.join(projectPath, 'cordova')); 49 | 50 | // Checking requirements task needs to be copied as well. 51 | shell.cp('-r', path.join(ROOT, 'bin/check_reqs'), path.join(projectPath, 'cordova')); 52 | shell.cp('-r', path.join(ROOT, 'bin', 'lib', 'check_reqs.js'), path.join(projectPath, 'cordova', 'lib')); 53 | 54 | // Copy the default template including the defaults.xml for the Ubuntu platform. 55 | shell.cp('-r', path.join(ROOT, 'bin', 'templates', 'project', 'cordova'), projectPath); 56 | 57 | shell.mkdir(path.join(projectPath, 'www')); 58 | shell.cp(path.join(ROOT, 'www', 'cordova.js'), path.join(projectPath, 'www')); 59 | shell.cp('-rf', path.join(ROOT, 'cordova-js-src'), path.join(projectPath, 'platform_www')); 60 | 61 | shell.cp('-r', path.join(ROOT, 'xml/config.xml'), projectPath); 62 | } 63 | 64 | 65 | -------------------------------------------------------------------------------- /bin/lib/update.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2013, 2014 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | var shell = require('shelljs'); 23 | var path = require('path'); 24 | var fs = require('fs'); 25 | 26 | var ROOT = path.join(__dirname, '..', '..'); 27 | 28 | exports.updateProject = function(projectPath) { 29 | if (!fs.existsSync(projectPath)) { 30 | console.error('Project does not exist!'); 31 | process.exit(1); 32 | } 33 | 34 | shell.rm('-r', path.join(projectPath, 'www')); 35 | shell.mkdir(path.join(projectPath, 'www')); 36 | shell.cp(path.join(ROOT, 'www', 'cordova.js'), path.join(projectPath, 'www')); 37 | 38 | shell.rm('-r', path.join(projectPath, 'cordova')); 39 | 40 | // Copy the necessary node modules. 41 | shell.cp('-r', path.join(ROOT, 'node_modules'), path.join(projectPath, 'cordova')); 42 | 43 | // Checking requirements needs to be copied as well. 44 | shell.cp('-r', path.join(ROOT, 'bin/check_reqs'), path.join(projectPath, 'cordova')); 45 | shell.cp('-r', path.join(ROOT, 'bin', 'lib', 'check_reqs.js'), path.join(projectPath, 'cordova', 'lib')); 46 | 47 | // Copy the default template including the defaults.xml for the Ubuntu platform. 48 | shell.cp('-r', path.join(ROOT, 'bin', 'templates', 'project', 'cordova'), projectPath); 49 | 50 | var tmp = path.join(projectPath, 'tmp'); 51 | shell.mkdir(tmp); 52 | 53 | var pluginsDir = path.join(projectPath, 'build', 'src', 'plugins'); 54 | var coreplugins = path.join(projectPath, 'build', 'src', 'coreplugins.cpp'); 55 | shell.mv(coreplugins, tmp); 56 | shell.mv(pluginsDir, tmp); 57 | shell.rm('-r', path.join(projectPath, 'build')); 58 | 59 | shell.cp('-r', path.join(ROOT, '*'), path.join(projectPath, 'build')); 60 | 61 | shell.rm('-r', coreplugins); 62 | shell.rm('-r', pluginsDir); 63 | shell.mv(path.join(tmp, 'plugins'), path.join(projectPath, 'build', 'src')); 64 | shell.mv(path.join(tmp, 'coreplugins.cpp'), path.join(projectPath, 'build', 'src')); 65 | 66 | shell.rm('-r', tmp); 67 | console.log('project updated'); 68 | } 69 | -------------------------------------------------------------------------------- /bin/templates/project/cordova/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2013 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | var path = require('path'); 23 | var build = require('./lib/build').build; 24 | var check_reqs = require('./lib/check_reqs').check_reqs; 25 | var PLATFORMS = require('./lib/constants').PLATFORM_TYPES; 26 | 27 | var root = path.resolve(); 28 | var www = path.join(root, 'www'); 29 | 30 | check_reqs(function () { 31 | var argv = require('optimist').boolean(['verbose', 'device']).string(['framework']).argv; 32 | if (argv.verbose) { 33 | require('./lib/config').verboseMode(); 34 | } 35 | 36 | var platform = (argv.device) ? PLATFORMS.PHONE : PLATFORMS.DESKTOP; 37 | 38 | return build(root, platform, false, undefined, argv.framework, false); 39 | }); 40 | -------------------------------------------------------------------------------- /bin/templates/project/cordova/clean: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2013 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | var path = require('path'); 22 | var args = process.argv; 23 | var ROOT = path.join(__dirname, '..'); 24 | var shell = require('shelljs'); 25 | var fs = require('fs'); 26 | 27 | throw new Error('unimplemented'); 28 | -------------------------------------------------------------------------------- /bin/templates/project/cordova/defaults.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /bin/templates/project/cordova/lib/config.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2014 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | var shellCfg = require('shelljs').config; 23 | 24 | /** 25 | * The configuration is used by other tasks to access shared properties, such as if the tasks are 26 | * running in verbose mode (more logs, and outputs from various commands). 27 | */ 28 | function Config() { 29 | this._verbose = false; 30 | shellCfg.silent = true; 31 | } 32 | 33 | Config.prototype = { 34 | verboseMode: function () { 35 | this._verbose = true; 36 | shellCfg.silent = false; 37 | }, 38 | 39 | inVerboseMode: function () { 40 | return this._verbose; 41 | } 42 | }; 43 | 44 | module.exports = new Config(); 45 | -------------------------------------------------------------------------------- /bin/templates/project/cordova/lib/config_parser.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2014 Canonical Ltd. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | * 18 | */ 19 | 20 | var fs = require('fs'); 21 | var et = require('elementtree'); 22 | 23 | var XML = et.XML; 24 | var ElementTree = et.ElementTree; 25 | var element = et.Element; 26 | var subElement = et.SubElement; 27 | 28 | function getNodeTextSafe(el) { 29 | return el && el.text && el.text.trim(); 30 | } 31 | 32 | function getNodeAttrSafe(el, attr) { 33 | return el && el.attrib[attr]; 34 | } 35 | 36 | function Config(path) { 37 | var data = fs.readFileSync(path).toString(); 38 | this.etree = et.parse(data); 39 | } 40 | 41 | Config.prototype = { 42 | id: function() { 43 | return getNodeAttrSafe(this.etree.getroot(), 'id'); 44 | }, 45 | version: function() { 46 | return getNodeAttrSafe(this.etree.getroot(), 'version'); 47 | }, 48 | name: function() { 49 | return getNodeTextSafe(this.etree.find('name')); 50 | }, 51 | author: function() { 52 | return getNodeTextSafe(this.etree.find('author')); 53 | }, 54 | email: function() { 55 | return getNodeAttrSafe(this.etree.find('author'), 'email'); 56 | }, 57 | description: function() { 58 | return getNodeTextSafe(this.etree.find('description')); 59 | }, 60 | icon: function() { 61 | return getNodeAttrSafe(this.etree.find('icon'), 'src'); 62 | } 63 | }; 64 | 65 | module.exports = Config; 66 | -------------------------------------------------------------------------------- /bin/templates/project/cordova/lib/constants.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2014 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | */ 20 | 21 | module.exports = { 22 | 'DEFAULT_FRAMEWORK': 'ubuntu-sdk-15.04', 23 | 'DEFAULT_ARCH': 'armhf', 24 | 'PLATFORM_TYPES': { 25 | 'PHONE': 0, 26 | 'DESKTOP': 1, 27 | 'ALL': 2 28 | }, 29 | 'MSG': { 30 | 'UBUNTU_TOUCH_DEVICE_NOT_AVALAIBLE': 'UbuntuTouch device is not attached', 31 | 'EMULATOR_IS_NOT_RUNNING': 'UbuntuTouch emulator is not running' 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /bin/templates/project/cordova/lib/device.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2014 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | var assert = require('assert'); 23 | var Utils = require('./utils'); 24 | 25 | var logger = require('./logger'); 26 | 27 | module.exports.list = function () { 28 | logger.info('Searching for connected devices'); 29 | 30 | var res = Utils.execSync('adb devices', false); 31 | var response = res.output.split('\n'); 32 | var deviceList = []; 33 | 34 | for (var i = 1; i < response.length; i++) { 35 | if (response[i].match(/\w+\tdevice/)) { 36 | deviceList.push(response[i].replace(/\tdevice/, '').replace('\r', '')); 37 | } 38 | } 39 | 40 | return deviceList; 41 | }; 42 | 43 | module.exports.isAttached = function (target) { 44 | var res = adbExec(target, 'get-state'); 45 | 46 | if (res.output.indexOf('device') == -1) 47 | return false; 48 | 49 | res = adbExec(target, 'shell uname -a'); 50 | if (res.output.indexOf('ubuntu-phablet') == -1) 51 | return false; 52 | 53 | return true; 54 | }; 55 | 56 | module.exports.arch = function (target) { 57 | var out = adbExec(target, 'shell "dpkg --print-architecture 2>/dev/null"').output.split('\r\n'); 58 | 59 | assert.ok(out.length == 2 && out[0].indexOf(' ') == -1); 60 | 61 | return out[0]; 62 | }; 63 | 64 | function adbExec(target, command, options) { 65 | assert.ok(target && command); 66 | options = options || {}; 67 | return Utils.execSync('adb -s ' + target + ' ' + command, options.silent); 68 | } 69 | 70 | function adbExecAsync(target, command, options) { 71 | assert.ok(target && command); 72 | options = options || {}; 73 | return Utils.execAsync('adb -s ' + target + ' ' + command, options.silent); 74 | } 75 | 76 | module.exports.adbExec = adbExec; 77 | module.exports.adbExecAsync = adbExecAsync; 78 | -------------------------------------------------------------------------------- /bin/templates/project/cordova/lib/logger.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2014 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | var colors = require('colors'); 23 | var config = require('./config'); 24 | 25 | /** 26 | * Output debug messages in white. If not in verbose mode, nothing is output. 27 | */ 28 | module.exports.debug = function (msg) { 29 | if (config.inVerboseMode()) { 30 | console.log(msg); 31 | } 32 | }; 33 | 34 | /** 35 | * Output info messages in green to the console. 36 | */ 37 | module.exports.info = function (msg) { 38 | console.log(msg.green); 39 | }; 40 | 41 | /** 42 | * Output warning messages in yellow to the console. 43 | */ 44 | module.exports.warn = function (msg) { 45 | console.warn(msg.yellow); 46 | }; 47 | 48 | /** 49 | * Output error messages in red to the console. 50 | */ 51 | module.exports.error = function (msg) { 52 | console.error(msg.red); 53 | }; 54 | 55 | module.exports.rainbow = function (msg) { 56 | console.log(msg.rainbow); 57 | }; 58 | -------------------------------------------------------------------------------- /bin/templates/project/cordova/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2013 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | var path = require('path'); 23 | var check_reqs = require('./lib/check_reqs').check_reqs; 24 | var PLATFORMS = require('./lib/constants').PLATFORM_TYPES; 25 | var run = require('./lib/run').run; 26 | 27 | var root = path.resolve(); 28 | var www = path.join(root, 'www'); 29 | 30 | check_reqs(function () { 31 | var argv = require('optimist').boolean(['device', 'emulator', 'debug', 'nobuild', 'verbose']).string(['target', 'framework']).argv; 32 | if (argv.verbose) { 33 | require('./lib/config').verboseMode(); 34 | } 35 | return run(root, !argv.device, argv.debug, argv.target, argv.nobuild, argv.emulator, argv.framework); 36 | }); 37 | -------------------------------------------------------------------------------- /bin/templates/project/cordova/version: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2013 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | // Coho updates this line: 23 | var VERSION = "4.4.0-dev"; 24 | 25 | console.log(VERSION); 26 | -------------------------------------------------------------------------------- /bin/templates/project/misc/changelog: -------------------------------------------------------------------------------- 1 | {PACKAGE_NAME} ({PACKAGE_VERSION}) trusty; urgency=medium 2 | 3 | [ {MAINTAINER_NAME} ] 4 | * upstream release 5 | 6 | -- {MAINTAINER_NAME} <{MAINTAINER_EMAIL}> Thu, 30 Aug 2014 06:06:06 +0000 7 | 8 | -------------------------------------------------------------------------------- /bin/templates/project/misc/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /bin/templates/project/misc/control: -------------------------------------------------------------------------------- 1 | Source: {PACKAGE_NAME} 2 | Section: devel 3 | Priority: optional 4 | Maintainer: {MAINTAINER_NAME} <{MAINTAINER_EMAIL}> 5 | Build-Depends: ubuntu-sdk, 6 | qtfeedback5-dev, 7 | qtmultimedia5-dev, 8 | qtpim5-dev, 9 | libqt5sensors5-dev, 10 | qtsystems5-dev, 11 | qtlocation5-dev, 12 | libicu-dev, 13 | libconnectivity-qt1-dev 14 | 15 | Package: {PACKAGE_NAME} 16 | Architecture: any 17 | Description: {PACKAGE_DESCRIPTION} 18 | Depends: ubuntu-sdk-libs 19 | -------------------------------------------------------------------------------- /bin/templates/project/misc/cordova.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name={PACKAGE_TITLE} 3 | Exec=/opt/{PACKAGE_NAME}/cordova-ubuntu 4 | Terminal=false 5 | Type=Application 6 | X-Ubuntu-Touch=true 7 | Icon={PACKAGE_ICON} 8 | -------------------------------------------------------------------------------- /bin/templates/project/misc/install: -------------------------------------------------------------------------------- 1 | /opt/{PACKAGE_NAME} 2 | /usr/share/applications/* 3 | 4 | -------------------------------------------------------------------------------- /bin/templates/project/misc/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | # Uncomment this to turn on verbose mode. 4 | #export DH_VERBOSE=1 5 | 6 | export CFLAGS := $(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS) 7 | export CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) $(shell dpkg-buildflags --get CPPFLAGS) 8 | export LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS) -Wl,--as-needed 9 | export QT_SELECT := qt5 10 | 11 | DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) 12 | 13 | # ----------------------------------- 14 | 15 | %: 16 | dh $@ --fail-missing 17 | 18 | override_dh_auto_configure: 19 | dh_auto_configure -- -DCMAKE_INSTALL_PREFIX=/opt/{PACKAGE_NAME} 20 | 21 | override_dh_auto_install: 22 | dh_auto_install --destdir=debian/tmp 23 | cp -R $(CURDIR)/www/* $(CURDIR)/debian/tmp/opt/{PACKAGE_NAME}/www 24 | cp -R $(CURDIR)/debian/config.xml $(CURDIR)/debian/tmp/opt/{PACKAGE_NAME}/ 25 | cp -R $(CURDIR)/qml/* $(CURDIR)/debian/tmp/opt/{PACKAGE_NAME}/qml 26 | mkdir -p $(CURDIR)/debian/tmp/usr/share/applications/ 27 | cp -R $(CURDIR)/debian/cordova.desktop $(CURDIR)/debian/tmp/usr/share/applications/{PACKAGE_NAME}.desktop 28 | -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | * 5 | * Copyright 2013, 2014 Canonical Ltd. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | var path = require('path'); 22 | var args = process.argv; 23 | var fs = require('fs'); 24 | 25 | var ROOT = path.join(__dirname, '..'); 26 | var projectPath = args[2]; 27 | 28 | var currentVersion = fs.readFileSync(path.join(projectPath, 'build', 'VERSION'), {encoding: "utf8"}); 29 | var version = fs.readFileSync(path.join(ROOT, 'VERSION'), {encoding: "utf8"}); 30 | if (version !== currentVersion) { 31 | var check_reqs = require('./lib/check_reqs').check_reqs; 32 | check_reqs(function () { 33 | require('./lib/update').updateProject(projectPath, ROOT); 34 | }); 35 | } 36 | -------------------------------------------------------------------------------- /cordova-js-src/exec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | var cordova = require('cordova'), 23 | utils = require('cordova/utils'); 24 | 25 | var callbackId = 1; 26 | cordova.callbacks = []; 27 | 28 | cordova.callback = function() { 29 | var scId = arguments[0]; 30 | var callbackRef = null; 31 | 32 | var parameters = []; 33 | for (var i = 1; i < arguments.length; i++) { 34 | parameters[i-1] = arguments[i]; 35 | } 36 | callbackRef = cordova.callbacks[scId]; 37 | 38 | // Even IDs are success-, odd are error-callbacks - make sure we remove both 39 | if ((scId % 2) !== 0) { 40 | scId = scId - 1; 41 | } 42 | // Remove both the success as well as the error callback from the stack 43 | delete cordova.callbacks[scId]; 44 | delete cordova.callbacks[scId + 1]; 45 | 46 | if (typeof callbackRef == "function") callbackRef.apply(this, parameters); 47 | }; 48 | 49 | cordova.callbackWithoutRemove = function() { 50 | var scId = arguments[0]; 51 | var callbackRef = null; 52 | 53 | var parameters = []; 54 | for (var i = 1; i < arguments.length; i++) { 55 | parameters[i-1] = arguments[i]; 56 | } 57 | callbackRef = cordova.callbacks[scId]; 58 | 59 | if (typeof(callbackRef) == "function") callbackRef.apply(this, parameters); 60 | }; 61 | 62 | var _initialized = false; 63 | function ubuntuExec(success, fail, service, action, args) { 64 | if (callbackId % 2) { 65 | callbackId++; 66 | } 67 | 68 | var scId = callbackId++; 69 | var ecId = callbackId++; 70 | cordova.callbacks[scId] = success; 71 | cordova.callbacks[ecId] = fail; 72 | 73 | args.unshift(ecId); 74 | args.unshift(scId); 75 | 76 | if (!_initialized) { 77 | _initialized = true; 78 | window.oxide.addMessageHandler("EXECUTE", function (msg) { 79 | eval(msg.args.code); 80 | }); 81 | } 82 | 83 | window.oxide.sendMessage("from-cordova", {messageType: "callPluginFunction", plugin: service, func: action, params: args}); 84 | } 85 | module.exports = ubuntuExec; 86 | -------------------------------------------------------------------------------- /cordova-js-src/platform.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | module.exports = { 23 | id: "ubuntu", 24 | bootstrap: function() { 25 | var channel = require("cordova/channel"), 26 | cordova = require('cordova'), 27 | exec = require('cordova/exec'), 28 | modulemapper = require('cordova/modulemapper'); 29 | 30 | modulemapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy'); 31 | require('cordova/channel').onNativeReady.fire(); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /default_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-ubuntu/1097b7fad0ae46d3d5fae1f9f3667784859ba4a2/default_icon.png -------------------------------------------------------------------------------- /node_modules/.bin/shjs: -------------------------------------------------------------------------------- 1 | ../shelljs/bin/shjs -------------------------------------------------------------------------------- /node_modules/colors/MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 2 | 3 | Marak Squires 4 | Alexis Sellier (cloudhead) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. -------------------------------------------------------------------------------- /node_modules/colors/ReadMe.md: -------------------------------------------------------------------------------- 1 | # colors.js - get color and style in your node.js console ( and browser ) like what 2 | 3 | 4 | 5 | 6 | ## Installation 7 | 8 | npm install colors 9 | 10 | ## colors and styles! 11 | 12 | - bold 13 | - italic 14 | - underline 15 | - inverse 16 | - yellow 17 | - cyan 18 | - white 19 | - magenta 20 | - green 21 | - red 22 | - grey 23 | - blue 24 | - rainbow 25 | - zebra 26 | - random 27 | 28 | ## Usage 29 | 30 | ``` js 31 | var colors = require('./colors'); 32 | 33 | console.log('hello'.green); // outputs green text 34 | console.log('i like cake and pies'.underline.red) // outputs red underlined text 35 | console.log('inverse the color'.inverse); // inverses the color 36 | console.log('OMG Rainbows!'.rainbow); // rainbow (ignores spaces) 37 | ``` 38 | 39 | # Creating Custom themes 40 | 41 | ```js 42 | 43 | var colors = require('colors'); 44 | 45 | colors.setTheme({ 46 | silly: 'rainbow', 47 | input: 'grey', 48 | verbose: 'cyan', 49 | prompt: 'grey', 50 | info: 'green', 51 | data: 'grey', 52 | help: 'cyan', 53 | warn: 'yellow', 54 | debug: 'blue', 55 | error: 'red' 56 | }); 57 | 58 | // outputs red text 59 | console.log("this is an error".error); 60 | 61 | // outputs yellow text 62 | console.log("this is a warning".warn); 63 | ``` 64 | 65 | 66 | ### Contributors 67 | 68 | Marak (Marak Squires) 69 | Alexis Sellier (cloudhead) 70 | mmalecki (Maciej Małecki) 71 | nicoreed (Nico Reed) 72 | morganrallen (Morgan Allen) 73 | JustinCampbell (Justin Campbell) 74 | ded (Dustin Diaz) 75 | 76 | 77 | #### , Marak Squires , Justin Campbell, Dustin Diaz (@ded) 78 | -------------------------------------------------------------------------------- /node_modules/colors/example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Colors Example 6 | 7 | 8 | 9 | 75 | 76 | -------------------------------------------------------------------------------- /node_modules/colors/example.js: -------------------------------------------------------------------------------- 1 | var colors = require('./colors'); 2 | 3 | //colors.mode = "browser"; 4 | 5 | var test = colors.red("hopefully colorless output"); 6 | console.log('Rainbows are fun!'.rainbow); 7 | console.log('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported 8 | console.log('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported 9 | //console.log('zalgo time!'.zalgo); 10 | console.log(test.stripColors); 11 | console.log("a".grey + " b".black); 12 | console.log("Zebras are so fun!".zebra); 13 | console.log('background color attack!'.black.whiteBG) 14 | 15 | // 16 | // Remark: .strikethrough may not work with Mac OS Terminal App 17 | // 18 | console.log("This is " + "not".strikethrough + " fun."); 19 | console.log(colors.rainbow('Rainbows are fun!')); 20 | console.log(colors.italic('So ') + colors.underline('are') + colors.bold(' styles! ') + colors.inverse('inverse')); // styles not widely supported 21 | console.log(colors.bold(colors.italic(colors.underline(colors.red('Chains are also cool.'))))); // styles not widely supported 22 | //console.log(colors.zalgo('zalgo time!')); 23 | console.log(colors.stripColors(test)); 24 | console.log(colors.grey("a") + colors.black(" b")); 25 | 26 | colors.addSequencer("america", function(letter, i, exploded) { 27 | if(letter === " ") return letter; 28 | switch(i%3) { 29 | case 0: return letter.red; 30 | case 1: return letter.white; 31 | case 2: return letter.blue; 32 | } 33 | }); 34 | 35 | colors.addSequencer("random", (function() { 36 | var available = ['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta']; 37 | 38 | return function(letter, i, exploded) { 39 | return letter === " " ? letter : letter[available[Math.round(Math.random() * (available.length - 1))]]; 40 | }; 41 | })()); 42 | 43 | console.log("AMERICA! F--K YEAH!".america); 44 | console.log("So apparently I've been to Mars, with all the little green men. But you know, I don't recall.".random); 45 | 46 | // 47 | // Custom themes 48 | // 49 | 50 | // Load theme with JSON literal 51 | colors.setTheme({ 52 | silly: 'rainbow', 53 | input: 'grey', 54 | verbose: 'cyan', 55 | prompt: 'grey', 56 | info: 'green', 57 | data: 'grey', 58 | help: 'cyan', 59 | warn: 'yellow', 60 | debug: 'blue', 61 | error: 'red' 62 | }); 63 | 64 | // outputs red text 65 | console.log("this is an error".error); 66 | 67 | // outputs yellow text 68 | console.log("this is a warning".warn); 69 | 70 | // outputs grey text 71 | console.log("this is an input".input); 72 | 73 | // Load a theme from file 74 | colors.setTheme('./themes/winston-dark.js'); 75 | 76 | console.log("this is an input".input); 77 | 78 | -------------------------------------------------------------------------------- /node_modules/colors/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "colors", 3 | "description": "get colors in your node.js console like what", 4 | "version": "0.6.2", 5 | "author": { 6 | "name": "Marak Squires" 7 | }, 8 | "homepage": "https://github.com/Marak/colors.js", 9 | "bugs": { 10 | "url": "https://github.com/Marak/colors.js/issues" 11 | }, 12 | "keywords": [ 13 | "ansi", 14 | "terminal", 15 | "colors" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "git+ssh://git@github.com/Marak/colors.js.git" 20 | }, 21 | "engines": { 22 | "node": ">=0.1.90" 23 | }, 24 | "main": "colors", 25 | "_id": "colors@0.6.2", 26 | "dist": { 27 | "shasum": "2423fe6678ac0c5dae8852e5d0e5be08c997abcc", 28 | "tarball": "http://registry.npmjs.org/colors/-/colors-0.6.2.tgz" 29 | }, 30 | "_from": "colors@0.6.2", 31 | "_npmVersion": "1.2.30", 32 | "_npmUser": { 33 | "name": "marak", 34 | "email": "marak.squires@gmail.com" 35 | }, 36 | "maintainers": [ 37 | { 38 | "name": "marak", 39 | "email": "marak.squires@gmail.com" 40 | } 41 | ], 42 | "directories": {}, 43 | "_shasum": "2423fe6678ac0c5dae8852e5d0e5be08c997abcc", 44 | "_resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", 45 | "readme": "ERROR: No README data found!" 46 | } 47 | -------------------------------------------------------------------------------- /node_modules/colors/test.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'), 2 | colors = require('./colors'); 3 | 4 | var s = 'string'; 5 | 6 | function a(s, code) { 7 | return '\x1B[' + code.toString() + 'm' + s + '\x1B[39m'; 8 | } 9 | 10 | function aE(s, color, code) { 11 | assert.equal(s[color], a(s, code)); 12 | assert.equal(colors[color](s), a(s, code)); 13 | assert.equal(s[color], colors[color](s)); 14 | assert.equal(s[color].stripColors, s); 15 | assert.equal(s[color].stripColors, colors.stripColors(s)); 16 | } 17 | 18 | function h(s, color) { 19 | return '' + s + ''; 20 | } 21 | 22 | var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta', 'red', 'yellow']; 23 | var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', 'inverse', 'rainbow']); 24 | 25 | colors.mode = 'console'; 26 | assert.equal(s.bold, '\x1B[1m' + s + '\x1B[22m'); 27 | assert.equal(s.italic, '\x1B[3m' + s + '\x1B[23m'); 28 | assert.equal(s.underline, '\x1B[4m' + s + '\x1B[24m'); 29 | assert.equal(s.strikethrough, '\x1B[9m' + s + '\x1B[29m'); 30 | assert.equal(s.inverse, '\x1B[7m' + s + '\x1B[27m'); 31 | assert.ok(s.rainbow); 32 | aE(s, 'white', 37); 33 | aE(s, 'grey', 90); 34 | aE(s, 'black', 30); 35 | aE(s, 'blue', 34); 36 | aE(s, 'cyan', 36); 37 | aE(s, 'green', 32); 38 | aE(s, 'magenta', 35); 39 | aE(s, 'red', 31); 40 | aE(s, 'yellow', 33); 41 | assert.equal(s, 'string'); 42 | 43 | colors.setTheme({error:'red'}); 44 | 45 | assert.equal(typeof("astring".red),'string'); 46 | assert.equal(typeof("astring".error),'string'); 47 | 48 | colors.mode = 'browser'; 49 | assert.equal(s.bold, '' + s + ''); 50 | assert.equal(s.italic, '' + s + ''); 51 | assert.equal(s.underline, '' + s + ''); 52 | assert.equal(s.strikethrough, '' + s + ''); 53 | assert.equal(s.inverse, '' + s + ''); 54 | assert.ok(s.rainbow); 55 | stylesColors.forEach(function (color) { 56 | assert.equal(s[color], h(s, color)); 57 | assert.equal(colors[color](s), h(s, color)); 58 | }); 59 | 60 | assert.equal(typeof("astring".red),'string'); 61 | assert.equal(typeof("astring".error),'string'); 62 | 63 | colors.mode = 'none'; 64 | stylesAll.forEach(function (style) { 65 | assert.equal(s[style], s); 66 | assert.equal(colors[style](s), s); 67 | }); 68 | 69 | assert.equal(typeof("astring".red),'string'); 70 | assert.equal(typeof("astring".error),'string'); 71 | -------------------------------------------------------------------------------- /node_modules/colors/themes/winston-dark.js: -------------------------------------------------------------------------------- 1 | module['exports'] = { 2 | silly: 'rainbow', 3 | input: 'black', 4 | verbose: 'cyan', 5 | prompt: 'grey', 6 | info: 'green', 7 | data: 'grey', 8 | help: 'cyan', 9 | warn: 'yellow', 10 | debug: 'blue', 11 | error: 'red' 12 | }; -------------------------------------------------------------------------------- /node_modules/colors/themes/winston-light.js: -------------------------------------------------------------------------------- 1 | module['exports'] = { 2 | silly: 'rainbow', 3 | input: 'grey', 4 | verbose: 'cyan', 5 | prompt: 'grey', 6 | info: 'green', 7 | data: 'grey', 8 | help: 'cyan', 9 | warn: 'yellow', 10 | debug: 'blue', 11 | error: 'red' 12 | }; -------------------------------------------------------------------------------- /node_modules/elementtree/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /node_modules/elementtree/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - 0.6 5 | 6 | script: make test 7 | 8 | notifications: 9 | email: 10 | - tomaz+travisci@tomaz.me 11 | -------------------------------------------------------------------------------- /node_modules/elementtree/CHANGES.md: -------------------------------------------------------------------------------- 1 | elementtree v0.1.6 (in development) 2 | 3 | * Add support for CData elements. (#14) 4 | [hermannpencole] 5 | 6 | elementtree v0.1.5 - 2012-11-14 7 | 8 | * Fix a bug in the find() and findtext() method which could manifest itself 9 | under some conditions. 10 | [metagriffin] 11 | 12 | elementtree v0.1.4 - 2012-10-15 13 | 14 | * Allow user to use namespaced attributes when using find* functions. 15 | [Andrew Lunny] 16 | 17 | elementtree v0.1.3 - 2012-09-21 18 | 19 | * Improve the output of text content in the tags (strip unnecessary line break 20 | characters). 21 | 22 | [Darryl Pogue] 23 | 24 | elementtree v0.1.2 - 2012-09-04 25 | 26 | * Allow user to pass 'indent' option to ElementTree.write method. If this 27 | option is specified (e.g. {'indent': 4}). XML will be pretty printed. 28 | [Darryl Pogue, Tomaz Muraus] 29 | 30 | * Bump sax dependency version. 31 | 32 | elementtree v0.1.1 - 2011-09-23 33 | 34 | * Improve special character escaping. 35 | [Ryan Phillips] 36 | 37 | elementtree v0.1.0 - 2011-09-05 38 | 39 | * Initial release. 40 | -------------------------------------------------------------------------------- /node_modules/elementtree/Makefile: -------------------------------------------------------------------------------- 1 | TESTS := \ 2 | tests/test-simple.js 3 | 4 | 5 | 6 | PATH := ./node_modules/.bin:$(PATH) 7 | 8 | WHISKEY := $(shell bash -c 'PATH=$(PATH) type -p whiskey') 9 | 10 | default: test 11 | 12 | test: 13 | NODE_PATH=`pwd`/lib/ ${WHISKEY} --scope-leaks --sequential --real-time --tests "${TESTS}" 14 | 15 | tap: 16 | NODE_PATH=`pwd`/lib/ ${WHISKEY} --test-reporter tap --sequential --real-time --tests "${TESTS}" 17 | 18 | coverage: 19 | NODE_PATH=`pwd`/lib/ ${WHISKEY} --sequential --coverage --coverage-reporter html --coverage-dir coverage_html --tests "${TESTS}" 20 | 21 | .PHONY: default test coverage tap scope 22 | -------------------------------------------------------------------------------- /node_modules/elementtree/NOTICE: -------------------------------------------------------------------------------- 1 | node-elementtree 2 | Copyright (c) 2011, Rackspace, Inc. 3 | 4 | The ElementTree toolkit is Copyright (c) 1999-2007 by Fredrik Lundh 5 | 6 | -------------------------------------------------------------------------------- /node_modules/elementtree/lib/constants.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rackspace 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | var DEFAULT_PARSER = 'sax'; 19 | 20 | exports.DEFAULT_PARSER = DEFAULT_PARSER; 21 | -------------------------------------------------------------------------------- /node_modules/elementtree/lib/errors.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Rackspace 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | var util = require('util'); 19 | 20 | var sprintf = require('./sprintf').sprintf; 21 | 22 | function SyntaxError(token, msg) { 23 | msg = msg || sprintf('Syntax Error at token %s', token.toString()); 24 | this.token = token; 25 | this.message = msg; 26 | Error.call(this, msg); 27 | } 28 | 29 | util.inherits(SyntaxError, Error); 30 | 31 | exports.SyntaxError = SyntaxError; 32 | -------------------------------------------------------------------------------- /node_modules/elementtree/lib/parser.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rackspace 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | /* TODO: support node-expat C++ module optionally */ 19 | 20 | var util = require('util'); 21 | var parsers = require('./parsers/index'); 22 | 23 | function get_parser(name) { 24 | if (name === 'sax') { 25 | return parsers.sax; 26 | } 27 | else { 28 | throw new Error('Invalid parser: ' + name); 29 | } 30 | } 31 | 32 | 33 | exports.get_parser = get_parser; 34 | -------------------------------------------------------------------------------- /node_modules/elementtree/lib/parsers/index.js: -------------------------------------------------------------------------------- 1 | exports.sax = require('./sax'); 2 | -------------------------------------------------------------------------------- /node_modules/elementtree/lib/parsers/sax.js: -------------------------------------------------------------------------------- 1 | var util = require('util'); 2 | 3 | var sax = require('sax'); 4 | 5 | var TreeBuilder = require('./../treebuilder').TreeBuilder; 6 | 7 | function XMLParser(target) { 8 | this.parser = sax.parser(true); 9 | 10 | this.target = (target) ? target : new TreeBuilder(); 11 | 12 | this.parser.onopentag = this._handleOpenTag.bind(this); 13 | this.parser.ontext = this._handleText.bind(this); 14 | this.parser.oncdata = this._handleCdata.bind(this); 15 | this.parser.ondoctype = this._handleDoctype.bind(this); 16 | this.parser.oncomment = this._handleComment.bind(this); 17 | this.parser.onclosetag = this._handleCloseTag.bind(this); 18 | this.parser.onerror = this._handleError.bind(this); 19 | } 20 | 21 | XMLParser.prototype._handleOpenTag = function(tag) { 22 | this.target.start(tag.name, tag.attributes); 23 | }; 24 | 25 | XMLParser.prototype._handleText = function(text) { 26 | this.target.data(text); 27 | }; 28 | 29 | XMLParser.prototype._handleCdata = function(text) { 30 | this.target.data(text); 31 | }; 32 | 33 | XMLParser.prototype._handleDoctype = function(text) { 34 | }; 35 | 36 | XMLParser.prototype._handleComment = function(comment) { 37 | }; 38 | 39 | XMLParser.prototype._handleCloseTag = function(tag) { 40 | this.target.end(tag); 41 | }; 42 | 43 | XMLParser.prototype._handleError = function(err) { 44 | throw err; 45 | }; 46 | 47 | XMLParser.prototype.feed = function(chunk) { 48 | this.parser.write(chunk); 49 | }; 50 | 51 | XMLParser.prototype.close = function() { 52 | this.parser.close(); 53 | return this.target.close(); 54 | }; 55 | 56 | exports.XMLParser = XMLParser; 57 | -------------------------------------------------------------------------------- /node_modules/elementtree/lib/sprintf.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rackspace 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | var cache = {}; 19 | 20 | 21 | // Do any others need escaping? 22 | var TO_ESCAPE = { 23 | '\'': '\\\'', 24 | '\n': '\\n' 25 | }; 26 | 27 | 28 | function populate(formatter) { 29 | var i, type, 30 | key = formatter, 31 | prev = 0, 32 | arg = 1, 33 | builder = 'return \''; 34 | 35 | for (i = 0; i < formatter.length; i++) { 36 | if (formatter[i] === '%') { 37 | type = formatter[i + 1]; 38 | 39 | switch (type) { 40 | case 's': 41 | builder += formatter.slice(prev, i) + '\' + arguments[' + arg + '] + \''; 42 | prev = i + 2; 43 | arg++; 44 | break; 45 | case 'j': 46 | builder += formatter.slice(prev, i) + '\' + JSON.stringify(arguments[' + arg + ']) + \''; 47 | prev = i + 2; 48 | arg++; 49 | break; 50 | case '%': 51 | builder += formatter.slice(prev, i + 1); 52 | prev = i + 2; 53 | i++; 54 | break; 55 | } 56 | 57 | 58 | } else if (TO_ESCAPE[formatter[i]]) { 59 | builder += formatter.slice(prev, i) + TO_ESCAPE[formatter[i]]; 60 | prev = i + 1; 61 | } 62 | } 63 | 64 | builder += formatter.slice(prev) + '\';'; 65 | cache[key] = new Function(builder); 66 | } 67 | 68 | 69 | /** 70 | * A fast version of sprintf(), which currently only supports the %s and %j. 71 | * This caches a formatting function for each format string that is used, so 72 | * you should only use this sprintf() will be called many times with a single 73 | * format string and a limited number of format strings will ever be used (in 74 | * general this means that format strings should be string literals). 75 | * 76 | * @param {String} formatter A format string. 77 | * @param {...String} var_args Values that will be formatted by %s and %j. 78 | * @return {String} The formatted output. 79 | */ 80 | exports.sprintf = function(formatter, var_args) { 81 | if (!cache[formatter]) { 82 | populate(formatter); 83 | } 84 | 85 | return cache[formatter].apply(null, arguments); 86 | }; 87 | -------------------------------------------------------------------------------- /node_modules/elementtree/lib/treebuilder.js: -------------------------------------------------------------------------------- 1 | function TreeBuilder(element_factory) { 2 | this._data = []; 3 | this._elem = []; 4 | this._last = null; 5 | this._tail = null; 6 | if (!element_factory) { 7 | /* evil circular dep */ 8 | element_factory = require('./elementtree').Element; 9 | } 10 | this._factory = element_factory; 11 | } 12 | 13 | TreeBuilder.prototype.close = function() { 14 | return this._last; 15 | }; 16 | 17 | TreeBuilder.prototype._flush = function() { 18 | if (this._data) { 19 | if (this._last !== null) { 20 | var text = this._data.join(""); 21 | if (this._tail) { 22 | this._last.tail = text; 23 | } 24 | else { 25 | this._last.text = text; 26 | } 27 | } 28 | this._data = []; 29 | } 30 | }; 31 | 32 | TreeBuilder.prototype.data = function(data) { 33 | this._data.push(data); 34 | }; 35 | 36 | TreeBuilder.prototype.start = function(tag, attrs) { 37 | this._flush(); 38 | var elem = this._factory(tag, attrs); 39 | this._last = elem; 40 | 41 | if (this._elem.length) { 42 | this._elem[this._elem.length - 1].append(elem); 43 | } 44 | 45 | this._elem.push(elem); 46 | 47 | this._tail = null; 48 | }; 49 | 50 | TreeBuilder.prototype.end = function(tag) { 51 | this._flush(); 52 | this._last = this._elem.pop(); 53 | if (this._last.tag !== tag) { 54 | throw new Error("end tag mismatch"); 55 | } 56 | this._tail = 1; 57 | return this._last; 58 | }; 59 | 60 | exports.TreeBuilder = TreeBuilder; 61 | -------------------------------------------------------------------------------- /node_modules/elementtree/lib/utils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2011 Rackspace 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | /** 19 | * @param {Object} hash. 20 | * @param {Array} ignored. 21 | */ 22 | function items(hash, ignored) { 23 | ignored = ignored || null; 24 | var k, rv = []; 25 | 26 | function is_ignored(key) { 27 | if (!ignored || ignored.length === 0) { 28 | return false; 29 | } 30 | 31 | return ignored.indexOf(key); 32 | } 33 | 34 | for (k in hash) { 35 | if (hash.hasOwnProperty(k) && !(is_ignored(ignored))) { 36 | rv.push([k, hash[k]]); 37 | } 38 | } 39 | 40 | return rv; 41 | } 42 | 43 | 44 | function findall(re, str) { 45 | var match, matches = []; 46 | 47 | while ((match = re.exec(str))) { 48 | matches.push(match); 49 | } 50 | 51 | return matches; 52 | } 53 | 54 | function merge(a, b) { 55 | var c = {}, attrname; 56 | 57 | for (attrname in a) { 58 | if (a.hasOwnProperty(attrname)) { 59 | c[attrname] = a[attrname]; 60 | } 61 | } 62 | for (attrname in b) { 63 | if (b.hasOwnProperty(attrname)) { 64 | c[attrname] = b[attrname]; 65 | } 66 | } 67 | return c; 68 | } 69 | 70 | exports.items = items; 71 | exports.findall = findall; 72 | exports.merge = merge; 73 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/AUTHORS: -------------------------------------------------------------------------------- 1 | # contributors sorted by whether or not they're me. 2 | Isaac Z. Schlueter 3 | Stein Martin Hustad 4 | Mikeal Rogers 5 | Laurie Harper 6 | Jann Horn 7 | Elijah Insua 8 | Henry Rawas 9 | Justin Makeig 10 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2009, 2010, 2011 Isaac Z. Schlueter. 2 | All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/examples/example.js: -------------------------------------------------------------------------------- 1 | 2 | var fs = require("fs"), 3 | sys = require("sys"), 4 | path = require("path"), 5 | xml = fs.cat(path.join(__dirname, "test.xml")), 6 | sax = require("../lib/sax"), 7 | strict = sax.parser(true), 8 | loose = sax.parser(false, {trim:true}), 9 | inspector = function (ev) { return function (data) { 10 | // sys.error(""); 11 | // sys.error(ev+": "+sys.inspect(data)); 12 | // for (var i in data) sys.error(i+ " "+sys.inspect(data[i])); 13 | // sys.error(this.line+":"+this.column); 14 | }}; 15 | 16 | xml.addCallback(function (xml) { 17 | // strict.write(xml); 18 | 19 | sax.EVENTS.forEach(function (ev) { 20 | loose["on"+ev] = inspector(ev); 21 | }); 22 | loose.onend = function () { 23 | // sys.error("end"); 24 | // sys.error(sys.inspect(loose)); 25 | }; 26 | 27 | // do this one char at a time to verify that it works. 28 | // (function () { 29 | // if (xml) { 30 | // loose.write(xml.substr(0,1000)); 31 | // xml = xml.substr(1000); 32 | // process.nextTick(arguments.callee); 33 | // } else loose.close(); 34 | // })(); 35 | 36 | for (var i = 0; i < 1000; i ++) { 37 | loose.write(xml); 38 | loose.close(); 39 | } 40 | 41 | }); 42 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/examples/get-products.js: -------------------------------------------------------------------------------- 1 | // pull out /GeneralSearchResponse/categories/category/items/product tags 2 | // the rest we don't care about. 3 | 4 | var sax = require("../lib/sax.js") 5 | var fs = require("fs") 6 | var path = require("path") 7 | var xmlFile = path.resolve(__dirname, "shopping.xml") 8 | var util = require("util") 9 | var http = require("http") 10 | 11 | fs.readFile(xmlFile, function (er, d) { 12 | http.createServer(function (req, res) { 13 | if (er) throw er 14 | var xmlstr = d.toString("utf8") 15 | 16 | var parser = sax.parser(true) 17 | var products = [] 18 | var product = null 19 | var currentTag = null 20 | 21 | parser.onclosetag = function (tagName) { 22 | if (tagName === "product") { 23 | products.push(product) 24 | currentTag = product = null 25 | return 26 | } 27 | if (currentTag && currentTag.parent) { 28 | var p = currentTag.parent 29 | delete currentTag.parent 30 | currentTag = p 31 | } 32 | } 33 | 34 | parser.onopentag = function (tag) { 35 | if (tag.name !== "product" && !product) return 36 | if (tag.name === "product") { 37 | product = tag 38 | } 39 | tag.parent = currentTag 40 | tag.children = [] 41 | tag.parent && tag.parent.children.push(tag) 42 | currentTag = tag 43 | } 44 | 45 | parser.ontext = function (text) { 46 | if (currentTag) currentTag.children.push(text) 47 | } 48 | 49 | parser.onend = function () { 50 | var out = util.inspect(products, false, 3, true) 51 | res.writeHead(200, {"content-type":"application/json"}) 52 | res.end("{\"ok\":true}") 53 | // res.end(JSON.stringify(products)) 54 | } 55 | 56 | parser.write(xmlstr).end() 57 | }).listen(1337) 58 | }) 59 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/examples/hello-world.js: -------------------------------------------------------------------------------- 1 | require("http").createServer(function (req, res) { 2 | res.writeHead(200, {"content-type":"application/json"}) 3 | res.end(JSON.stringify({ok: true})) 4 | }).listen(1337) 5 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/examples/not-pretty.xml: -------------------------------------------------------------------------------- 1 | 2 | something blerm a bit down here 9 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/examples/pretty-print.js: -------------------------------------------------------------------------------- 1 | var sax = require("../lib/sax") 2 | , printer = sax.createStream(false, {lowercasetags:true, trim:true}) 3 | , fs = require("fs") 4 | 5 | function entity (str) { 6 | return str.replace('"', '"') 7 | } 8 | 9 | printer.tabstop = 2 10 | printer.level = 0 11 | printer.indent = function () { 12 | print("\n") 13 | for (var i = this.level; i > 0; i --) { 14 | for (var j = this.tabstop; j > 0; j --) { 15 | print(" ") 16 | } 17 | } 18 | } 19 | printer.on("opentag", function (tag) { 20 | this.indent() 21 | this.level ++ 22 | print("<"+tag.name) 23 | for (var i in tag.attributes) { 24 | print(" "+i+"=\""+entity(tag.attributes[i])+"\"") 25 | } 26 | print(">") 27 | }) 28 | 29 | printer.on("text", ontext) 30 | printer.on("doctype", ontext) 31 | function ontext (text) { 32 | this.indent() 33 | print(text) 34 | } 35 | 36 | printer.on("closetag", function (tag) { 37 | this.level -- 38 | this.indent() 39 | print("") 40 | }) 41 | 42 | printer.on("cdata", function (data) { 43 | this.indent() 44 | print("") 45 | }) 46 | 47 | printer.on("comment", function (comment) { 48 | this.indent() 49 | print("") 50 | }) 51 | 52 | printer.on("error", function (error) { 53 | console.error(error) 54 | throw error 55 | }) 56 | 57 | if (!process.argv[2]) { 58 | throw new Error("Please provide an xml file to prettify\n"+ 59 | "TODO: read from stdin or take a file") 60 | } 61 | var xmlfile = require("path").join(process.cwd(), process.argv[2]) 62 | var fstr = fs.createReadStream(xmlfile, { encoding: "utf8" }) 63 | 64 | function print (c) { 65 | if (!process.stdout.write(c)) { 66 | fstr.pause() 67 | } 68 | } 69 | 70 | process.stdout.on("drain", function () { 71 | fstr.resume() 72 | }) 73 | 74 | fstr.pipe(printer) 75 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/examples/switch-bench.js: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/node-bench 2 | 3 | var Promise = require("events").Promise; 4 | 5 | var xml = require("posix").cat("test.xml").wait(), 6 | path = require("path"), 7 | sax = require("../lib/sax"), 8 | saxT = require("../lib/sax-trampoline"), 9 | 10 | parser = sax.parser(false, {trim:true}), 11 | parserT = saxT.parser(false, {trim:true}), 12 | 13 | sys = require("sys"); 14 | 15 | 16 | var count = exports.stepsPerLap = 500, 17 | l = xml.length, 18 | runs = 0; 19 | exports.countPerLap = 1000; 20 | exports.compare = { 21 | "switch" : function () { 22 | // sys.debug("switch runs: "+runs++); 23 | // for (var x = 0; x < l; x += 1000) { 24 | // parser.write(xml.substr(x, 1000)) 25 | // } 26 | // for (var i = 0; i < count; i ++) { 27 | parser.write(xml); 28 | parser.close(); 29 | // } 30 | // done(); 31 | }, 32 | trampoline : function () { 33 | // sys.debug("trampoline runs: "+runs++); 34 | // for (var x = 0; x < l; x += 1000) { 35 | // parserT.write(xml.substr(x, 1000)) 36 | // } 37 | // for (var i = 0; i < count; i ++) { 38 | parserT.write(xml); 39 | parserT.close(); 40 | // } 41 | // done(); 42 | }, 43 | }; 44 | 45 | sys.debug("rock and roll..."); -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/examples/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | testing the parser 6 | 7 | 8 | 9 |

hello 10 | 11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sax", 3 | "description": "An evented streaming XML parser in JavaScript", 4 | "author": { 5 | "name": "Isaac Z. Schlueter", 6 | "email": "i@izs.me", 7 | "url": "http://blog.izs.me/" 8 | }, 9 | "version": "0.3.5", 10 | "main": "lib/sax.js", 11 | "license": { 12 | "type": "MIT", 13 | "url": "https://raw.github.com/isaacs/sax-js/master/LICENSE" 14 | }, 15 | "scripts": { 16 | "test": "node test/index.js" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git://github.com/isaacs/sax-js.git" 21 | }, 22 | "_npmUser": { 23 | "name": "isaacs", 24 | "email": "i@izs.me" 25 | }, 26 | "_id": "sax@0.3.5", 27 | "contributors": [ 28 | { 29 | "name": "Isaac Z. Schlueter", 30 | "email": "i@izs.me" 31 | }, 32 | { 33 | "name": "Stein Martin Hustad", 34 | "email": "stein@hustad.com" 35 | }, 36 | { 37 | "name": "Mikeal Rogers", 38 | "email": "mikeal.rogers@gmail.com" 39 | }, 40 | { 41 | "name": "Laurie Harper", 42 | "email": "laurie@holoweb.net" 43 | }, 44 | { 45 | "name": "Jann Horn", 46 | "email": "jann@Jann-PC.fritz.box" 47 | }, 48 | { 49 | "name": "Elijah Insua", 50 | "email": "tmpvar@gmail.com" 51 | }, 52 | { 53 | "name": "Henry Rawas", 54 | "email": "henryr@schakra.com" 55 | }, 56 | { 57 | "name": "Justin Makeig", 58 | "email": "jmpublic@makeig.com" 59 | } 60 | ], 61 | "dependencies": {}, 62 | "devDependencies": {}, 63 | "engines": { 64 | "node": "*" 65 | }, 66 | "_engineSupported": true, 67 | "_npmVersion": "1.1.0-beta-7", 68 | "_nodeVersion": "v0.6.7-pre", 69 | "_defaultsLoaded": true, 70 | "dist": { 71 | "shasum": "88fcfc1f73c0c8bbd5b7c776b6d3f3501eed073d", 72 | "tarball": "http://registry.npmjs.org/sax/-/sax-0.3.5.tgz" 73 | }, 74 | "maintainers": [ 75 | { 76 | "name": "isaacs", 77 | "email": "i@izs.me" 78 | } 79 | ], 80 | "directories": {}, 81 | "_shasum": "88fcfc1f73c0c8bbd5b7c776b6d3f3501eed073d", 82 | "_resolved": "https://registry.npmjs.org/sax/-/sax-0.3.5.tgz", 83 | "_from": "sax@0.3.5", 84 | "bugs": { 85 | "url": "https://github.com/isaacs/sax-js/issues" 86 | }, 87 | "readme": "ERROR: No README data found!", 88 | "homepage": "https://github.com/isaacs/sax-js#readme" 89 | } 90 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/buffer-overrun.js: -------------------------------------------------------------------------------- 1 | // set this really low so that I don't have to put 64 MB of xml in here. 2 | var sax = require("../lib/sax") 3 | var bl = sax.MAX_BUFFER_LENGTH 4 | sax.MAX_BUFFER_LENGTH = 5; 5 | 6 | require(__dirname).test({ 7 | expect : [ 8 | ["error", "Max buffer length exceeded: tagName\nLine: 0\nColumn: 15\nChar: "], 9 | ["error", "Max buffer length exceeded: tagName\nLine: 0\nColumn: 30\nChar: "], 10 | ["error", "Max buffer length exceeded: tagName\nLine: 0\nColumn: 45\nChar: "], 11 | ["opentag", { 12 | "name": "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", 13 | "attributes": {} 14 | }], 15 | ["text", "yo"], 16 | ["closetag", "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"] 17 | ] 18 | }).write("") 22 | .write("yo") 23 | .write("") 24 | .close(); 25 | sax.MAX_BUFFER_LENGTH = bl 26 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/cdata-chunked.js: -------------------------------------------------------------------------------- 1 | 2 | require(__dirname).test({ 3 | expect : [ 4 | ["opentag", {"name": "R","attributes": {}}], 5 | ["opencdata", undefined], 6 | ["cdata", " this is character data  "], 7 | ["closecdata", undefined], 8 | ["closetag", "R"] 9 | ] 10 | }).write("").close(); 11 | 12 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/cdata-end-split.js: -------------------------------------------------------------------------------- 1 | 2 | require(__dirname).test({ 3 | expect : [ 4 | ["opentag", {"name": "R","attributes": {}}], 5 | ["opencdata", undefined], 6 | ["cdata", " this is "], 7 | ["closecdata", undefined], 8 | ["closetag", "R"] 9 | ] 10 | }) 11 | .write("") 13 | .write("") 14 | .close(); 15 | 16 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/cdata-fake-end.js: -------------------------------------------------------------------------------- 1 | 2 | var p = require(__dirname).test({ 3 | expect : [ 4 | ["opentag", {"name": "R","attributes": {}}], 5 | ["opencdata", undefined], 6 | ["cdata", "[[[[[[[[]]]]]]]]"], 7 | ["closecdata", undefined], 8 | ["closetag", "R"] 9 | ] 10 | }) 11 | var x = "" 12 | for (var i = 0; i < x.length ; i ++) { 13 | p.write(x.charAt(i)) 14 | } 15 | p.close(); 16 | 17 | 18 | var p2 = require(__dirname).test({ 19 | expect : [ 20 | ["opentag", {"name": "R","attributes": {}}], 21 | ["opencdata", undefined], 22 | ["cdata", "[[[[[[[[]]]]]]]]"], 23 | ["closecdata", undefined], 24 | ["closetag", "R"] 25 | ] 26 | }) 27 | var x = "" 28 | p2.write(x).close(); 29 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/cdata-multiple.js: -------------------------------------------------------------------------------- 1 | 2 | require(__dirname).test({ 3 | expect : [ 4 | ["opentag", {"name": "R","attributes": {}}], 5 | ["opencdata", undefined], 6 | ["cdata", " this is "], 7 | ["closecdata", undefined], 8 | ["opencdata", undefined], 9 | ["cdata", "character data  "], 10 | ["closecdata", undefined], 11 | ["closetag", "R"] 12 | ] 13 | }).write("").write("").close(); 15 | 16 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/cdata.js: -------------------------------------------------------------------------------- 1 | require(__dirname).test({ 2 | xml : "", 3 | expect : [ 4 | ["opentag", {"name": "R","attributes": {}}], 5 | ["opencdata", undefined], 6 | ["cdata", " this is character data  "], 7 | ["closecdata", undefined], 8 | ["closetag", "R"] 9 | ] 10 | }); 11 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/issue-23.js: -------------------------------------------------------------------------------- 1 | 2 | require(__dirname).test 3 | ( { xml : 4 | ""+ 5 | ""+ 6 | "653724009"+ 7 | "-1"+ 8 | "01pG0000002KoSUIA0"+ 9 | "-1"+ 10 | "CalendarController"+ 11 | "true"+ 12 | ""+ 13 | "" 14 | 15 | , expect : 16 | [ [ "opentag", { name: "COMPILECLASSESRESPONSE", attributes: {} } ] 17 | , [ "opentag", { name : "RESULT", attributes: {} } ] 18 | , [ "opentag", { name: "BODYCRC", attributes: {} } ] 19 | , [ "text", "653724009" ] 20 | , [ "closetag", "BODYCRC" ] 21 | , [ "opentag", { name: "COLUMN", attributes: {} } ] 22 | , [ "text", "-1" ] 23 | , [ "closetag", "COLUMN" ] 24 | , [ "opentag", { name: "ID", attributes: {} } ] 25 | , [ "text", "01pG0000002KoSUIA0" ] 26 | , [ "closetag", "ID" ] 27 | , [ "opentag", {name: "LINE", attributes: {} } ] 28 | , [ "text", "-1" ] 29 | , [ "closetag", "LINE" ] 30 | , [ "opentag", {name: "NAME", attributes: {} } ] 31 | , [ "text", "CalendarController" ] 32 | , [ "closetag", "NAME" ] 33 | , [ "opentag", {name: "SUCCESS", attributes: {} } ] 34 | , [ "text", "true" ] 35 | , [ "closetag", "SUCCESS" ] 36 | , [ "closetag", "RESULT" ] 37 | , [ "closetag", "COMPILECLASSESRESPONSE" ] 38 | ] 39 | , strict : false 40 | , opt : {} 41 | } 42 | ) 43 | 44 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/issue-30.js: -------------------------------------------------------------------------------- 1 | // https://github.com/isaacs/sax-js/issues/33 2 | require(__dirname).test 3 | ( { xml : "\n"+ 4 | "\n"+ 7 | "\n"+ 8 | "" 9 | 10 | , expect : 11 | [ [ "opentag", { name: "xml", attributes: {} } ] 12 | , [ "text", "\n" ] 13 | , [ "comment", " \n comment with a single dash- in it\n" ] 14 | , [ "text", "\n" ] 15 | , [ "opentag", { name: "data", attributes: {} } ] 16 | , [ "closetag", "data" ] 17 | , [ "text", "\n" ] 18 | , [ "closetag", "xml" ] 19 | ] 20 | , strict : true 21 | , opt : {} 22 | } 23 | ) 24 | 25 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/issue-35.js: -------------------------------------------------------------------------------- 1 | // https://github.com/isaacs/sax-js/issues/35 2 | require(__dirname).test 3 | ( { xml : " \n"+ 4 | "" 5 | 6 | , expect : 7 | [ [ "opentag", { name: "xml", attributes: {} } ] 8 | , [ "text", "\r\r\n" ] 9 | , [ "closetag", "xml" ] 10 | ] 11 | , strict : true 12 | , opt : {} 13 | } 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/issue-47.js: -------------------------------------------------------------------------------- 1 | // https://github.com/isaacs/sax-js/issues/47 2 | require(__dirname).test 3 | ( { xml : '' 4 | , expect : [ 5 | [ "attribute", { name:'href', value:"query.svc?x=1&y=2&z=3"} ], 6 | [ "opentag", { name: "a", attributes: { href:"query.svc?x=1&y=2&z=3"} } ], 7 | [ "closetag", "a" ] 8 | ] 9 | , strict : true 10 | , opt : {} 11 | } 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/issue-49.js: -------------------------------------------------------------------------------- 1 | // https://github.com/isaacs/sax-js/issues/49 2 | require(__dirname).test 3 | ( { xml : "" 4 | , expect : 5 | [ [ "opentag", { name: "xml", attributes: {} } ] 6 | , [ "opentag", { name: "script", attributes: {} } ] 7 | , [ "text", "hello world" ] 8 | , [ "closetag", "script" ] 9 | , [ "closetag", "xml" ] 10 | ] 11 | , strict : false 12 | , opt : { lowercasetags: true, noscript: true } 13 | } 14 | ) 15 | 16 | require(__dirname).test 17 | ( { xml : "" 18 | , expect : 19 | [ [ "opentag", { name: "xml", attributes: {} } ] 20 | , [ "opentag", { name: "script", attributes: {} } ] 21 | , [ "opencdata", undefined ] 22 | , [ "cdata", "hello world" ] 23 | , [ "closecdata", undefined ] 24 | , [ "closetag", "script" ] 25 | , [ "closetag", "xml" ] 26 | ] 27 | , strict : false 28 | , opt : { lowercasetags: true, noscript: true } 29 | } 30 | ) 31 | 32 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/parser-position.js: -------------------------------------------------------------------------------- 1 | var sax = require("../lib/sax"), 2 | assert = require("assert") 3 | 4 | function testPosition(chunks, expectedEvents) { 5 | var parser = sax.parser(); 6 | expectedEvents.forEach(function(expectation) { 7 | parser['on' + expectation[0]] = function() { 8 | for (var prop in expectation[1]) { 9 | assert.equal(parser[prop], expectation[1][prop]); 10 | } 11 | } 12 | }); 13 | chunks.forEach(function(chunk) { 14 | parser.write(chunk); 15 | }); 16 | }; 17 | 18 | testPosition(['

'], 19 | [ ['opentag', { position: 5, startTagPosition: 1 }] 20 | , ['text', { position: 19, startTagPosition: 14 }] 21 | , ['closetag', { position: 19, startTagPosition: 14 }] 22 | ]); 23 | 24 | testPosition(['
abcde','fgh
'], 25 | [ ['opentag', { position: 5, startTagPosition: 1 }] 26 | , ['text', { position: 19, startTagPosition: 14 }] 27 | , ['closetag', { position: 19, startTagPosition: 14 }] 28 | ]); 29 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/script.js: -------------------------------------------------------------------------------- 1 | require(__dirname).test({ 2 | xml : "", 3 | expect : [ 4 | ["opentag", {"name": "HTML","attributes": {}}], 5 | ["opentag", {"name": "HEAD","attributes": {}}], 6 | ["opentag", {"name": "SCRIPT","attributes": {}}], 7 | ["script", "if (1 < 0) { console.log('elo there'); }"], 8 | ["closetag", "SCRIPT"], 9 | ["closetag", "HEAD"], 10 | ["closetag", "HTML"] 11 | ] 12 | }); 13 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/self-closing-child-strict.js: -------------------------------------------------------------------------------- 1 | 2 | require(__dirname).test({ 3 | xml : 4 | ""+ 5 | "" + 6 | "" + 7 | "" + 8 | "" + 9 | "=(|)" + 10 | "" + 11 | "", 12 | expect : [ 13 | ["opentag", { 14 | "name": "root", 15 | "attributes": {} 16 | }], 17 | ["opentag", { 18 | "name": "child", 19 | "attributes": {} 20 | }], 21 | ["opentag", { 22 | "name": "haha", 23 | "attributes": {} 24 | }], 25 | ["closetag", "haha"], 26 | ["closetag", "child"], 27 | ["opentag", { 28 | "name": "monkey", 29 | "attributes": {} 30 | }], 31 | ["text", "=(|)"], 32 | ["closetag", "monkey"], 33 | ["closetag", "root"], 34 | ["end"], 35 | ["ready"] 36 | ], 37 | strict : true, 38 | opt : {} 39 | }); 40 | 41 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/self-closing-child.js: -------------------------------------------------------------------------------- 1 | 2 | require(__dirname).test({ 3 | xml : 4 | ""+ 5 | "" + 6 | "" + 7 | "" + 8 | "" + 9 | "=(|)" + 10 | "" + 11 | "", 12 | expect : [ 13 | ["opentag", { 14 | "name": "ROOT", 15 | "attributes": {} 16 | }], 17 | ["opentag", { 18 | "name": "CHILD", 19 | "attributes": {} 20 | }], 21 | ["opentag", { 22 | "name": "HAHA", 23 | "attributes": {} 24 | }], 25 | ["closetag", "HAHA"], 26 | ["closetag", "CHILD"], 27 | ["opentag", { 28 | "name": "MONKEY", 29 | "attributes": {} 30 | }], 31 | ["text", "=(|)"], 32 | ["closetag", "MONKEY"], 33 | ["closetag", "ROOT"], 34 | ["end"], 35 | ["ready"] 36 | ], 37 | strict : false, 38 | opt : {} 39 | }); 40 | 41 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/self-closing-tag.js: -------------------------------------------------------------------------------- 1 | 2 | require(__dirname).test({ 3 | xml : 4 | " "+ 5 | " "+ 6 | " "+ 7 | " "+ 8 | "=(|) "+ 9 | ""+ 10 | " ", 11 | expect : [ 12 | ["opentag", {name:"ROOT", attributes:{}}], 13 | ["opentag", {name:"HAHA", attributes:{}}], 14 | ["closetag", "HAHA"], 15 | ["opentag", {name:"HAHA", attributes:{}}], 16 | ["closetag", "HAHA"], 17 | // ["opentag", {name:"HAHA", attributes:{}}], 18 | // ["closetag", "HAHA"], 19 | ["opentag", {name:"MONKEY", attributes:{}}], 20 | ["text", "=(|)"], 21 | ["closetag", "MONKEY"], 22 | ["closetag", "ROOT"] 23 | ], 24 | opt : { trim : true } 25 | }); -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/stray-ending.js: -------------------------------------------------------------------------------- 1 | // stray ending tags should just be ignored in non-strict mode. 2 | // https://github.com/isaacs/sax-js/issues/32 3 | require(__dirname).test 4 | ( { xml : 5 | "
" 6 | , expect : 7 | [ [ "opentag", { name: "A", attributes: {} } ] 8 | , [ "opentag", { name: "B", attributes: {} } ] 9 | , [ "text", "" ] 10 | , [ "closetag", "B" ] 11 | , [ "closetag", "A" ] 12 | ] 13 | , strict : false 14 | , opt : {} 15 | } 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/trailing-non-whitespace.js: -------------------------------------------------------------------------------- 1 | 2 | require(__dirname).test({ 3 | xml : "Welcome, to monkey land", 4 | expect : [ 5 | ["opentag", { 6 | "name": "SPAN", 7 | "attributes": {} 8 | }], 9 | ["text", "Welcome,"], 10 | ["closetag", "SPAN"], 11 | ["text", " to monkey land"], 12 | ["end"], 13 | ["ready"] 14 | ], 15 | strict : false, 16 | opt : {} 17 | }); 18 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/unquoted.js: -------------------------------------------------------------------------------- 1 | // unquoted attributes should be ok in non-strict mode 2 | // https://github.com/isaacs/sax-js/issues/31 3 | require(__dirname).test 4 | ( { xml : 5 | "" 6 | , expect : 7 | [ [ "attribute", { name: "class", value: "test" } ] 8 | , [ "attribute", { name: "hello", value: "world" } ] 9 | , [ "opentag", { name: "SPAN", 10 | attributes: { class: "test", hello: "world" } } ] 11 | , [ "closetag", "SPAN" ] 12 | ] 13 | , strict : false 14 | , opt : {} 15 | } 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/xmlns-issue-41.js: -------------------------------------------------------------------------------- 1 | var t = require(__dirname) 2 | 3 | , xmls = // should be the same both ways. 4 | [ "" 5 | , "" ] 6 | 7 | , ex1 = 8 | [ [ "opennamespace" 9 | , { prefix: "a" 10 | , uri: "http://ATTRIBUTE" 11 | } 12 | ] 13 | , [ "attribute" 14 | , { name: "xmlns:a" 15 | , value: "http://ATTRIBUTE" 16 | , prefix: "xmlns" 17 | , local: "a" 18 | , uri: "http://www.w3.org/2000/xmlns/" 19 | } 20 | ] 21 | , [ "attribute" 22 | , { name: "a:attr" 23 | , local: "attr" 24 | , prefix: "a" 25 | , uri: "http://ATTRIBUTE" 26 | , value: "value" 27 | } 28 | ] 29 | , [ "opentag" 30 | , { name: "parent" 31 | , uri: "" 32 | , prefix: "" 33 | , local: "parent" 34 | , attributes: 35 | { "a:attr": 36 | { name: "a:attr" 37 | , local: "attr" 38 | , prefix: "a" 39 | , uri: "http://ATTRIBUTE" 40 | , value: "value" 41 | } 42 | , "xmlns:a": 43 | { name: "xmlns:a" 44 | , local: "a" 45 | , prefix: "xmlns" 46 | , uri: "http://www.w3.org/2000/xmlns/" 47 | , value: "http://ATTRIBUTE" 48 | } 49 | } 50 | , ns: {"a": "http://ATTRIBUTE"} 51 | } 52 | ] 53 | , ["closetag", "parent"] 54 | , ["closenamespace", { prefix: "a", uri: "http://ATTRIBUTE" }] 55 | ] 56 | 57 | // swap the order of elements 2 and 1 58 | , ex2 = [ex1[0], ex1[2], ex1[1]].concat(ex1.slice(3)) 59 | , expected = [ex1, ex2] 60 | 61 | xmls.forEach(function (x, i) { 62 | t.test({ xml: x 63 | , expect: expected[i] 64 | , strict: true 65 | , opt: { xmlns: true } 66 | }) 67 | }) 68 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/xmlns-unbound.js: -------------------------------------------------------------------------------- 1 | 2 | require(__dirname).test( 3 | { strict : true 4 | , opt : { xmlns: true } 5 | , expect : 6 | [ ["error", "Unbound namespace prefix: \"unbound\"\nLine: 0\nColumn: 28\nChar: >"] 7 | 8 | , [ "attribute", { name: "unbound:attr", value: "value", uri: "unbound", prefix: "unbound", local: "attr" } ] 9 | , [ "opentag", { name: "root", uri: "", prefix: "", local: "root", 10 | attributes: { "unbound:attr": { name: "unbound:attr", value: "value", uri: "unbound", prefix: "unbound", local: "attr" } }, 11 | ns: {} } ] 12 | , [ "closetag", "root" ] 13 | ] 14 | } 15 | ).write("") 16 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js: -------------------------------------------------------------------------------- 1 | require(__dirname).test( 2 | { xml : "" 3 | , expect : 4 | [ [ "attribute" 5 | , { name: "xml:lang" 6 | , local: "lang" 7 | , prefix: "xml" 8 | , uri: "http://www.w3.org/XML/1998/namespace" 9 | , value: "en" 10 | } 11 | ] 12 | , [ "opentag" 13 | , { name: "root" 14 | , uri: "" 15 | , prefix: "" 16 | , local: "root" 17 | , attributes: 18 | { "xml:lang": 19 | { name: "xml:lang" 20 | , local: "lang" 21 | , prefix: "xml" 22 | , uri: "http://www.w3.org/XML/1998/namespace" 23 | , value: "en" 24 | } 25 | } 26 | , ns: {} 27 | } 28 | ] 29 | , ["closetag", "root"] 30 | ] 31 | , strict : true 32 | , opt : { xmlns: true } 33 | } 34 | ) 35 | 36 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/xmlns-xml-default-prefix.js: -------------------------------------------------------------------------------- 1 | require(__dirname).test( 2 | { xml : "" 3 | , expect : 4 | [ 5 | [ "opentag" 6 | , { name: "xml:root" 7 | , uri: "http://www.w3.org/XML/1998/namespace" 8 | , prefix: "xml" 9 | , local: "root" 10 | , attributes: {} 11 | , ns: {} 12 | } 13 | ] 14 | , ["closetag", "xml:root"] 15 | ] 16 | , strict : true 17 | , opt : { xmlns: true } 18 | } 19 | ) 20 | 21 | -------------------------------------------------------------------------------- /node_modules/elementtree/node_modules/sax/test/xmlns-xml-default-redefine.js: -------------------------------------------------------------------------------- 1 | require(__dirname).test( 2 | { xml : "" 3 | , expect : 4 | [ ["error" 5 | , "xml: prefix must be bound to http://www.w3.org/XML/1998/namespace\n" 6 | + "Actual: ERROR\n" 7 | + "Line: 0\nColumn: 27\nChar: '" 8 | ] 9 | , [ "attribute" 10 | , { name: "xmlns:xml" 11 | , local: "xml" 12 | , prefix: "xmlns" 13 | , uri: "http://www.w3.org/2000/xmlns/" 14 | , value: "ERROR" 15 | } 16 | ] 17 | , [ "opentag" 18 | , { name: "xml:root" 19 | , uri: "http://www.w3.org/XML/1998/namespace" 20 | , prefix: "xml" 21 | , local: "root" 22 | , attributes: 23 | { "xmlns:xml": 24 | { name: "xmlns:xml" 25 | , local: "xml" 26 | , prefix: "xmlns" 27 | , uri: "http://www.w3.org/2000/xmlns/" 28 | , value: "ERROR" 29 | } 30 | } 31 | , ns: {} 32 | } 33 | ] 34 | , ["closetag", "xml:root"] 35 | ] 36 | , strict : true 37 | , opt : { xmlns: true } 38 | } 39 | ) 40 | 41 | -------------------------------------------------------------------------------- /node_modules/elementtree/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": { 3 | "name": "Rackspace US, Inc." 4 | }, 5 | "contributors": [ 6 | { 7 | "name": "Paul Querna", 8 | "email": "paul.querna@rackspace.com" 9 | }, 10 | { 11 | "name": "Tomaz Muraus", 12 | "email": "tomaz.muraus@rackspace.com" 13 | } 14 | ], 15 | "name": "elementtree", 16 | "description": "XML Serialization and Parsing module based on Python's ElementTree.", 17 | "version": "0.1.6", 18 | "keywords": [ 19 | "xml", 20 | "sax", 21 | "parser", 22 | "seralization", 23 | "elementtree" 24 | ], 25 | "homepage": "https://github.com/racker/node-elementtree", 26 | "repository": { 27 | "type": "git", 28 | "url": "git://github.com/racker/node-elementtree.git" 29 | }, 30 | "main": "lib/elementtree.js", 31 | "directories": { 32 | "lib": "lib" 33 | }, 34 | "scripts": { 35 | "test": "make test" 36 | }, 37 | "engines": { 38 | "node": ">= 0.4.0" 39 | }, 40 | "dependencies": { 41 | "sax": "0.3.5" 42 | }, 43 | "devDependencies": { 44 | "whiskey": "0.8.x" 45 | }, 46 | "licenses": [ 47 | { 48 | "type": "Apache", 49 | "url": "http://www.apache.org/licenses/LICENSE-2.0.html" 50 | } 51 | ], 52 | "bugs": { 53 | "url": "https://github.com/racker/node-elementtree/issues" 54 | }, 55 | "_id": "elementtree@0.1.6", 56 | "dist": { 57 | "shasum": "2ac4c46ea30516c8c4cbdb5e3ac7418e592de20c", 58 | "tarball": "http://registry.npmjs.org/elementtree/-/elementtree-0.1.6.tgz" 59 | }, 60 | "_from": "elementtree@*", 61 | "_npmVersion": "1.3.24", 62 | "_npmUser": { 63 | "name": "rphillips", 64 | "email": "ryan@trolocsis.com" 65 | }, 66 | "maintainers": [ 67 | { 68 | "name": "rphillips", 69 | "email": "ryan@trolocsis.com" 70 | } 71 | ], 72 | "_shasum": "2ac4c46ea30516c8c4cbdb5e3ac7418e592de20c", 73 | "_resolved": "https://registry.npmjs.org/elementtree/-/elementtree-0.1.6.tgz", 74 | "readme": "ERROR: No README data found!" 75 | } 76 | -------------------------------------------------------------------------------- /node_modules/elementtree/tests/data/xml1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | dd 4 | test_object_1 5 | 4281c348eaf83e70ddce0e07221c3d28 6 | 14 7 | application/octetstream 8 | 2009-02-03T05:26:32.612278 9 | 10 | 11 | test_object_2 12 | b039efe731ad111bc1b0ef221c3849d0 13 | 64 14 | application/octetstream 15 | 2009-02-03T05:26:32.612278 16 | 17 | 18 | -------------------------------------------------------------------------------- /node_modules/elementtree/tests/data/xml2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello World 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | -------------------------------------------------------------------------------- /node_modules/optimist/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.8" 4 | - "0.10" 5 | -------------------------------------------------------------------------------- /node_modules/optimist/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2010 James Halliday (mail@substack.net) 2 | 3 | This project is free software released under the MIT/X11 license: 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /node_modules/optimist/example/bool.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var util = require('util'); 3 | var argv = require('optimist').argv; 4 | 5 | if (argv.s) { 6 | util.print(argv.fr ? 'Le chat dit: ' : 'The cat says: '); 7 | } 8 | console.log( 9 | (argv.fr ? 'miaou' : 'meow') + (argv.p ? '.' : '') 10 | ); 11 | -------------------------------------------------------------------------------- /node_modules/optimist/example/boolean_double.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .boolean(['x','y','z']) 4 | .argv 5 | ; 6 | console.dir([ argv.x, argv.y, argv.z ]); 7 | console.dir(argv._); 8 | -------------------------------------------------------------------------------- /node_modules/optimist/example/boolean_single.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .boolean('v') 4 | .argv 5 | ; 6 | console.dir(argv.v); 7 | console.dir(argv._); 8 | -------------------------------------------------------------------------------- /node_modules/optimist/example/default_hash.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var argv = require('optimist') 4 | .default({ x : 10, y : 10 }) 5 | .argv 6 | ; 7 | 8 | console.log(argv.x + argv.y); 9 | -------------------------------------------------------------------------------- /node_modules/optimist/example/default_singles.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .default('x', 10) 4 | .default('y', 10) 5 | .argv 6 | ; 7 | console.log(argv.x + argv.y); 8 | -------------------------------------------------------------------------------- /node_modules/optimist/example/divide.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var argv = require('optimist') 4 | .usage('Usage: $0 -x [num] -y [num]') 5 | .demand(['x','y']) 6 | .argv; 7 | 8 | console.log(argv.x / argv.y); 9 | -------------------------------------------------------------------------------- /node_modules/optimist/example/line_count.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .usage('Count the lines in a file.\nUsage: $0') 4 | .demand('f') 5 | .alias('f', 'file') 6 | .describe('f', 'Load a file') 7 | .argv 8 | ; 9 | 10 | var fs = require('fs'); 11 | var s = fs.createReadStream(argv.file); 12 | 13 | var lines = 0; 14 | s.on('data', function (buf) { 15 | lines += buf.toString().match(/\n/g).length; 16 | }); 17 | 18 | s.on('end', function () { 19 | console.log(lines); 20 | }); 21 | -------------------------------------------------------------------------------- /node_modules/optimist/example/line_count_options.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .usage('Count the lines in a file.\nUsage: $0') 4 | .options({ 5 | file : { 6 | demand : true, 7 | alias : 'f', 8 | description : 'Load a file' 9 | }, 10 | base : { 11 | alias : 'b', 12 | description : 'Numeric base to use for output', 13 | default : 10, 14 | }, 15 | }) 16 | .argv 17 | ; 18 | 19 | var fs = require('fs'); 20 | var s = fs.createReadStream(argv.file); 21 | 22 | var lines = 0; 23 | s.on('data', function (buf) { 24 | lines += buf.toString().match(/\n/g).length; 25 | }); 26 | 27 | s.on('end', function () { 28 | console.log(lines.toString(argv.base)); 29 | }); 30 | -------------------------------------------------------------------------------- /node_modules/optimist/example/line_count_wrap.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .usage('Count the lines in a file.\nUsage: $0') 4 | .wrap(80) 5 | .demand('f') 6 | .alias('f', [ 'file', 'filename' ]) 7 | .describe('f', 8 | "Load a file. It's pretty important." 9 | + " Required even. So you'd better specify it." 10 | ) 11 | .alias('b', 'base') 12 | .describe('b', 'Numeric base to display the number of lines in') 13 | .default('b', 10) 14 | .describe('x', 'Super-secret optional parameter which is secret') 15 | .default('x', '') 16 | .argv 17 | ; 18 | 19 | var fs = require('fs'); 20 | var s = fs.createReadStream(argv.file); 21 | 22 | var lines = 0; 23 | s.on('data', function (buf) { 24 | lines += buf.toString().match(/\n/g).length; 25 | }); 26 | 27 | s.on('end', function () { 28 | console.log(lines.toString(argv.base)); 29 | }); 30 | -------------------------------------------------------------------------------- /node_modules/optimist/example/nonopt.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist').argv; 3 | console.log('(%d,%d)', argv.x, argv.y); 4 | console.log(argv._); 5 | -------------------------------------------------------------------------------- /node_modules/optimist/example/reflect.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | console.dir(require('optimist').argv); 3 | -------------------------------------------------------------------------------- /node_modules/optimist/example/short.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist').argv; 3 | console.log('(%d,%d)', argv.x, argv.y); 4 | -------------------------------------------------------------------------------- /node_modules/optimist/example/string.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .string('x', 'y') 4 | .argv 5 | ; 6 | console.dir([ argv.x, argv.y ]); 7 | 8 | /* Turns off numeric coercion: 9 | ./node string.js -x 000123 -y 9876 10 | [ '000123', '9876' ] 11 | */ 12 | -------------------------------------------------------------------------------- /node_modules/optimist/example/usage-options.js: -------------------------------------------------------------------------------- 1 | var optimist = require('./../index'); 2 | 3 | var argv = optimist.usage('This is my awesome program', { 4 | 'about': { 5 | description: 'Provide some details about the author of this program', 6 | required: true, 7 | short: 'a', 8 | }, 9 | 'info': { 10 | description: 'Provide some information about the node.js agains!!!!!!', 11 | boolean: true, 12 | short: 'i' 13 | } 14 | }).argv; 15 | 16 | optimist.showHelp(); 17 | 18 | console.log('\n\nInspecting options'); 19 | console.dir(argv); -------------------------------------------------------------------------------- /node_modules/optimist/example/xup.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist').argv; 3 | 4 | if (argv.rif - 5 * argv.xup > 7.138) { 5 | console.log('Buy more riffiwobbles'); 6 | } 7 | else { 8 | console.log('Sell the xupptumblers'); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/minimist/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.8" 4 | - "0.10" 5 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/minimist/LICENSE: -------------------------------------------------------------------------------- 1 | This software is released under the MIT license: 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/minimist/example/parse.js: -------------------------------------------------------------------------------- 1 | var argv = require('../')(process.argv.slice(2)); 2 | console.dir(argv); 3 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/minimist/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minimist", 3 | "version": "0.0.10", 4 | "description": "parse argument options", 5 | "main": "index.js", 6 | "devDependencies": { 7 | "tape": "~1.0.4", 8 | "tap": "~0.4.0" 9 | }, 10 | "scripts": { 11 | "test": "tap test/*.js" 12 | }, 13 | "testling": { 14 | "files": "test/*.js", 15 | "browsers": [ 16 | "ie/6..latest", 17 | "ff/5", 18 | "firefox/latest", 19 | "chrome/10", 20 | "chrome/latest", 21 | "safari/5.1", 22 | "safari/latest", 23 | "opera/12" 24 | ] 25 | }, 26 | "repository": { 27 | "type": "git", 28 | "url": "git://github.com/substack/minimist.git" 29 | }, 30 | "homepage": "https://github.com/substack/minimist", 31 | "keywords": [ 32 | "argv", 33 | "getopt", 34 | "parser", 35 | "optimist" 36 | ], 37 | "author": { 38 | "name": "James Halliday", 39 | "email": "mail@substack.net", 40 | "url": "http://substack.net" 41 | }, 42 | "license": "MIT", 43 | "bugs": { 44 | "url": "https://github.com/substack/minimist/issues" 45 | }, 46 | "_id": "minimist@0.0.10", 47 | "dist": { 48 | "shasum": "de3f98543dbf96082be48ad1a0c7cda836301dcf", 49 | "tarball": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz" 50 | }, 51 | "_from": "minimist@>=0.0.1 <0.1.0", 52 | "_npmVersion": "1.4.3", 53 | "_npmUser": { 54 | "name": "substack", 55 | "email": "mail@substack.net" 56 | }, 57 | "maintainers": [ 58 | { 59 | "name": "substack", 60 | "email": "mail@substack.net" 61 | } 62 | ], 63 | "directories": {}, 64 | "_shasum": "de3f98543dbf96082be48ad1a0c7cda836301dcf", 65 | "_resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", 66 | "readme": "ERROR: No README data found!" 67 | } 68 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/minimist/readme.markdown: -------------------------------------------------------------------------------- 1 | # minimist 2 | 3 | parse argument options 4 | 5 | This module is the guts of optimist's argument parser without all the 6 | fanciful decoration. 7 | 8 | [![browser support](https://ci.testling.com/substack/minimist.png)](http://ci.testling.com/substack/minimist) 9 | 10 | [![build status](https://secure.travis-ci.org/substack/minimist.png)](http://travis-ci.org/substack/minimist) 11 | 12 | # example 13 | 14 | ``` js 15 | var argv = require('minimist')(process.argv.slice(2)); 16 | console.dir(argv); 17 | ``` 18 | 19 | ``` 20 | $ node example/parse.js -a beep -b boop 21 | { _: [], a: 'beep', b: 'boop' } 22 | ``` 23 | 24 | ``` 25 | $ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz 26 | { _: [ 'foo', 'bar', 'baz' ], 27 | x: 3, 28 | y: 4, 29 | n: 5, 30 | a: true, 31 | b: true, 32 | c: true, 33 | beep: 'boop' } 34 | ``` 35 | 36 | # methods 37 | 38 | ``` js 39 | var parseArgs = require('minimist') 40 | ``` 41 | 42 | ## var argv = parseArgs(args, opts={}) 43 | 44 | Return an argument object `argv` populated with the array arguments from `args`. 45 | 46 | `argv._` contains all the arguments that didn't have an option associated with 47 | them. 48 | 49 | Numeric-looking arguments will be returned as numbers unless `opts.string` or 50 | `opts.boolean` is set for that argument name. 51 | 52 | Any arguments after `'--'` will not be parsed and will end up in `argv._`. 53 | 54 | options can be: 55 | 56 | * `opts.string` - a string or array of strings argument names to always treat as 57 | strings 58 | * `opts.boolean` - a string or array of strings to always treat as booleans 59 | * `opts.alias` - an object mapping string names to strings or arrays of string 60 | argument names to use as aliases 61 | * `opts.default` - an object mapping string argument names to default values 62 | 63 | # install 64 | 65 | With [npm](https://npmjs.org) do: 66 | 67 | ``` 68 | npm install minimist 69 | ``` 70 | 71 | # license 72 | 73 | MIT 74 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/minimist/test/dash.js: -------------------------------------------------------------------------------- 1 | var parse = require('../'); 2 | var test = require('tape'); 3 | 4 | test('-', function (t) { 5 | t.plan(5); 6 | t.deepEqual(parse([ '-n', '-' ]), { n: '-', _: [] }); 7 | t.deepEqual(parse([ '-' ]), { _: [ '-' ] }); 8 | t.deepEqual(parse([ '-f-' ]), { f: '-', _: [] }); 9 | t.deepEqual( 10 | parse([ '-b', '-' ], { boolean: 'b' }), 11 | { b: true, _: [ '-' ] } 12 | ); 13 | t.deepEqual( 14 | parse([ '-s', '-' ], { string: 's' }), 15 | { s: '-', _: [] } 16 | ); 17 | }); 18 | 19 | test('-a -- b', function (t) { 20 | t.plan(3); 21 | t.deepEqual(parse([ '-a', '--', 'b' ]), { a: true, _: [ 'b' ] }); 22 | t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] }); 23 | t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] }); 24 | }); 25 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/minimist/test/default_bool.js: -------------------------------------------------------------------------------- 1 | var test = require('tape'); 2 | var parse = require('../'); 3 | 4 | test('boolean default true', function (t) { 5 | var argv = parse([], { 6 | boolean: 'sometrue', 7 | default: { sometrue: true } 8 | }); 9 | t.equal(argv.sometrue, true); 10 | t.end(); 11 | }); 12 | 13 | test('boolean default false', function (t) { 14 | var argv = parse([], { 15 | boolean: 'somefalse', 16 | default: { somefalse: false } 17 | }); 18 | t.equal(argv.somefalse, false); 19 | t.end(); 20 | }); 21 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/minimist/test/dotted.js: -------------------------------------------------------------------------------- 1 | var parse = require('../'); 2 | var test = require('tape'); 3 | 4 | test('dotted alias', function (t) { 5 | var argv = parse(['--a.b', '22'], {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}}); 6 | t.equal(argv.a.b, 22); 7 | t.equal(argv.aa.bb, 22); 8 | t.end(); 9 | }); 10 | 11 | test('dotted default', function (t) { 12 | var argv = parse('', {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}}); 13 | t.equal(argv.a.b, 11); 14 | t.equal(argv.aa.bb, 11); 15 | t.end(); 16 | }); 17 | 18 | test('dotted default with no alias', function (t) { 19 | var argv = parse('', {default: {'a.b': 11}}); 20 | t.equal(argv.a.b, 11); 21 | t.end(); 22 | }); 23 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/minimist/test/long.js: -------------------------------------------------------------------------------- 1 | var test = require('tape'); 2 | var parse = require('../'); 3 | 4 | test('long opts', function (t) { 5 | t.deepEqual( 6 | parse([ '--bool' ]), 7 | { bool : true, _ : [] }, 8 | 'long boolean' 9 | ); 10 | t.deepEqual( 11 | parse([ '--pow', 'xixxle' ]), 12 | { pow : 'xixxle', _ : [] }, 13 | 'long capture sp' 14 | ); 15 | t.deepEqual( 16 | parse([ '--pow=xixxle' ]), 17 | { pow : 'xixxle', _ : [] }, 18 | 'long capture eq' 19 | ); 20 | t.deepEqual( 21 | parse([ '--host', 'localhost', '--port', '555' ]), 22 | { host : 'localhost', port : 555, _ : [] }, 23 | 'long captures sp' 24 | ); 25 | t.deepEqual( 26 | parse([ '--host=localhost', '--port=555' ]), 27 | { host : 'localhost', port : 555, _ : [] }, 28 | 'long captures eq' 29 | ); 30 | t.end(); 31 | }); 32 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/minimist/test/num.js: -------------------------------------------------------------------------------- 1 | var parse = require('../'); 2 | var test = require('tape'); 3 | 4 | test('nums', function (t) { 5 | var argv = parse([ 6 | '-x', '1234', 7 | '-y', '5.67', 8 | '-z', '1e7', 9 | '-w', '10f', 10 | '--hex', '0xdeadbeef', 11 | '789' 12 | ]); 13 | t.deepEqual(argv, { 14 | x : 1234, 15 | y : 5.67, 16 | z : 1e7, 17 | w : '10f', 18 | hex : 0xdeadbeef, 19 | _ : [ 789 ] 20 | }); 21 | t.deepEqual(typeof argv.x, 'number'); 22 | t.deepEqual(typeof argv.y, 'number'); 23 | t.deepEqual(typeof argv.z, 'number'); 24 | t.deepEqual(typeof argv.w, 'string'); 25 | t.deepEqual(typeof argv.hex, 'number'); 26 | t.deepEqual(typeof argv._[0], 'number'); 27 | t.end(); 28 | }); 29 | 30 | test('already a number', function (t) { 31 | var argv = parse([ '-x', 1234, 789 ]); 32 | t.deepEqual(argv, { x : 1234, _ : [ 789 ] }); 33 | t.deepEqual(typeof argv.x, 'number'); 34 | t.deepEqual(typeof argv._[0], 'number'); 35 | t.end(); 36 | }); 37 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/minimist/test/parse_modified.js: -------------------------------------------------------------------------------- 1 | var parse = require('../'); 2 | var test = require('tape'); 3 | 4 | test('parse with modifier functions' , function (t) { 5 | t.plan(1); 6 | 7 | var argv = parse([ '-b', '123' ], { boolean: 'b' }); 8 | t.deepEqual(argv, { b: true, _: ['123'] }); 9 | }); 10 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/minimist/test/short.js: -------------------------------------------------------------------------------- 1 | var parse = require('../'); 2 | var test = require('tape'); 3 | 4 | test('numeric short args', function (t) { 5 | t.plan(2); 6 | t.deepEqual(parse([ '-n123' ]), { n: 123, _: [] }); 7 | t.deepEqual( 8 | parse([ '-123', '456' ]), 9 | { 1: true, 2: true, 3: 456, _: [] } 10 | ); 11 | }); 12 | 13 | test('short', function (t) { 14 | t.deepEqual( 15 | parse([ '-b' ]), 16 | { b : true, _ : [] }, 17 | 'short boolean' 18 | ); 19 | t.deepEqual( 20 | parse([ 'foo', 'bar', 'baz' ]), 21 | { _ : [ 'foo', 'bar', 'baz' ] }, 22 | 'bare' 23 | ); 24 | t.deepEqual( 25 | parse([ '-cats' ]), 26 | { c : true, a : true, t : true, s : true, _ : [] }, 27 | 'group' 28 | ); 29 | t.deepEqual( 30 | parse([ '-cats', 'meow' ]), 31 | { c : true, a : true, t : true, s : 'meow', _ : [] }, 32 | 'short group next' 33 | ); 34 | t.deepEqual( 35 | parse([ '-h', 'localhost' ]), 36 | { h : 'localhost', _ : [] }, 37 | 'short capture' 38 | ); 39 | t.deepEqual( 40 | parse([ '-h', 'localhost', '-p', '555' ]), 41 | { h : 'localhost', p : 555, _ : [] }, 42 | 'short captures' 43 | ); 44 | t.end(); 45 | }); 46 | 47 | test('mixed short bool and capture', function (t) { 48 | t.same( 49 | parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]), 50 | { 51 | f : true, p : 555, h : 'localhost', 52 | _ : [ 'script.js' ] 53 | } 54 | ); 55 | t.end(); 56 | }); 57 | 58 | test('short and long', function (t) { 59 | t.deepEqual( 60 | parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]), 61 | { 62 | f : true, p : 555, h : 'localhost', 63 | _ : [ 'script.js' ] 64 | } 65 | ); 66 | t.end(); 67 | }); 68 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/minimist/test/whitespace.js: -------------------------------------------------------------------------------- 1 | var parse = require('../'); 2 | var test = require('tape'); 3 | 4 | test('whitespace should be whitespace' , function (t) { 5 | t.plan(1); 6 | var x = parse([ '-x', '\t' ]).x; 7 | t.equal(x, '\t'); 8 | }); 9 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/wordwrap/LICENSE: -------------------------------------------------------------------------------- 1 | This software is released under the MIT license: 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/wordwrap/README.markdown: -------------------------------------------------------------------------------- 1 | wordwrap 2 | ======== 3 | 4 | Wrap your words. 5 | 6 | example 7 | ======= 8 | 9 | made out of meat 10 | ---------------- 11 | 12 | meat.js 13 | 14 | var wrap = require('wordwrap')(15); 15 | console.log(wrap('You and your whole family are made out of meat.')); 16 | 17 | output: 18 | 19 | You and your 20 | whole family 21 | are made out 22 | of meat. 23 | 24 | centered 25 | -------- 26 | 27 | center.js 28 | 29 | var wrap = require('wordwrap')(20, 60); 30 | console.log(wrap( 31 | 'At long last the struggle and tumult was over.' 32 | + ' The machines had finally cast off their oppressors' 33 | + ' and were finally free to roam the cosmos.' 34 | + '\n' 35 | + 'Free of purpose, free of obligation.' 36 | + ' Just drifting through emptiness.' 37 | + ' The sun was just another point of light.' 38 | )); 39 | 40 | output: 41 | 42 | At long last the struggle and tumult 43 | was over. The machines had finally cast 44 | off their oppressors and were finally 45 | free to roam the cosmos. 46 | Free of purpose, free of obligation. 47 | Just drifting through emptiness. The 48 | sun was just another point of light. 49 | 50 | methods 51 | ======= 52 | 53 | var wrap = require('wordwrap'); 54 | 55 | wrap(stop), wrap(start, stop, params={mode:"soft"}) 56 | --------------------------------------------------- 57 | 58 | Returns a function that takes a string and returns a new string. 59 | 60 | Pad out lines with spaces out to column `start` and then wrap until column 61 | `stop`. If a word is longer than `stop - start` characters it will overflow. 62 | 63 | In "soft" mode, split chunks by `/(\S+\s+/` and don't break up chunks which are 64 | longer than `stop - start`, in "hard" mode, split chunks with `/\b/` and break 65 | up chunks longer than `stop - start`. 66 | 67 | wrap.hard(start, stop) 68 | ---------------------- 69 | 70 | Like `wrap()` but with `params.mode = "hard"`. 71 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/wordwrap/example/center.js: -------------------------------------------------------------------------------- 1 | var wrap = require('wordwrap')(20, 60); 2 | console.log(wrap( 3 | 'At long last the struggle and tumult was over.' 4 | + ' The machines had finally cast off their oppressors' 5 | + ' and were finally free to roam the cosmos.' 6 | + '\n' 7 | + 'Free of purpose, free of obligation.' 8 | + ' Just drifting through emptiness.' 9 | + ' The sun was just another point of light.' 10 | )); 11 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/wordwrap/example/meat.js: -------------------------------------------------------------------------------- 1 | var wrap = require('wordwrap')(15); 2 | 3 | console.log(wrap('You and your whole family are made out of meat.')); 4 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/wordwrap/index.js: -------------------------------------------------------------------------------- 1 | var wordwrap = module.exports = function (start, stop, params) { 2 | if (typeof start === 'object') { 3 | params = start; 4 | start = params.start; 5 | stop = params.stop; 6 | } 7 | 8 | if (typeof stop === 'object') { 9 | params = stop; 10 | start = start || params.start; 11 | stop = undefined; 12 | } 13 | 14 | if (!stop) { 15 | stop = start; 16 | start = 0; 17 | } 18 | 19 | if (!params) params = {}; 20 | var mode = params.mode || 'soft'; 21 | var re = mode === 'hard' ? /\b/ : /(\S+\s+)/; 22 | 23 | return function (text) { 24 | var chunks = text.toString() 25 | .split(re) 26 | .reduce(function (acc, x) { 27 | if (mode === 'hard') { 28 | for (var i = 0; i < x.length; i += stop - start) { 29 | acc.push(x.slice(i, i + stop - start)); 30 | } 31 | } 32 | else acc.push(x) 33 | return acc; 34 | }, []) 35 | ; 36 | 37 | return chunks.reduce(function (lines, rawChunk) { 38 | if (rawChunk === '') return lines; 39 | 40 | var chunk = rawChunk.replace(/\t/g, ' '); 41 | 42 | var i = lines.length - 1; 43 | if (lines[i].length + chunk.length > stop) { 44 | lines[i] = lines[i].replace(/\s+$/, ''); 45 | 46 | chunk.split(/\n/).forEach(function (c) { 47 | lines.push( 48 | new Array(start + 1).join(' ') 49 | + c.replace(/^\s+/, '') 50 | ); 51 | }); 52 | } 53 | else if (chunk.match(/\n/)) { 54 | var xs = chunk.split(/\n/); 55 | lines[i] += xs.shift(); 56 | xs.forEach(function (c) { 57 | lines.push( 58 | new Array(start + 1).join(' ') 59 | + c.replace(/^\s+/, '') 60 | ); 61 | }); 62 | } 63 | else { 64 | lines[i] += chunk; 65 | } 66 | 67 | return lines; 68 | }, [ new Array(start + 1).join(' ') ]).join('\n'); 69 | }; 70 | }; 71 | 72 | wordwrap.soft = wordwrap; 73 | 74 | wordwrap.hard = function (start, stop) { 75 | return wordwrap(start, stop, { mode : 'hard' }); 76 | }; 77 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/wordwrap/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wordwrap", 3 | "description": "Wrap those words. Show them at what columns to start and stop.", 4 | "version": "0.0.3", 5 | "repository": { 6 | "type": "git", 7 | "url": "git://github.com/substack/node-wordwrap.git" 8 | }, 9 | "main": "./index.js", 10 | "keywords": [ 11 | "word", 12 | "wrap", 13 | "rule", 14 | "format", 15 | "column" 16 | ], 17 | "directories": { 18 | "lib": ".", 19 | "example": "example", 20 | "test": "test" 21 | }, 22 | "scripts": { 23 | "test": "expresso" 24 | }, 25 | "devDependencies": { 26 | "expresso": "=0.7.x" 27 | }, 28 | "engines": { 29 | "node": ">=0.4.0" 30 | }, 31 | "license": "MIT", 32 | "author": { 33 | "name": "James Halliday", 34 | "email": "mail@substack.net", 35 | "url": "http://substack.net" 36 | }, 37 | "gitHead": "e59aa1bd338914019456bdfba034508c9c4cb29d", 38 | "bugs": { 39 | "url": "https://github.com/substack/node-wordwrap/issues" 40 | }, 41 | "homepage": "https://github.com/substack/node-wordwrap#readme", 42 | "_id": "wordwrap@0.0.3", 43 | "_shasum": "a3d5da6cd5c0bc0008d37234bbaf1bed63059107", 44 | "_from": "wordwrap@>=0.0.2 <0.1.0", 45 | "_npmVersion": "2.9.0", 46 | "_nodeVersion": "2.0.0", 47 | "_npmUser": { 48 | "name": "substack", 49 | "email": "substack@gmail.com" 50 | }, 51 | "dist": { 52 | "shasum": "a3d5da6cd5c0bc0008d37234bbaf1bed63059107", 53 | "tarball": "http://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz" 54 | }, 55 | "maintainers": [ 56 | { 57 | "name": "substack", 58 | "email": "mail@substack.net" 59 | } 60 | ], 61 | "_resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", 62 | "readme": "ERROR: No README data found!" 63 | } 64 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/wordwrap/test/break.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var wordwrap = require('../'); 3 | 4 | exports.hard = function () { 5 | var s = 'Assert from {"type":"equal","ok":false,"found":1,"wanted":2,' 6 | + '"stack":[],"id":"b7ddcd4c409de8799542a74d1a04689b",' 7 | + '"browser":"chrome/6.0"}' 8 | ; 9 | var s_ = wordwrap.hard(80)(s); 10 | 11 | var lines = s_.split('\n'); 12 | assert.equal(lines.length, 2); 13 | assert.ok(lines[0].length < 80); 14 | assert.ok(lines[1].length < 80); 15 | 16 | assert.equal(s, s_.replace(/\n/g, '')); 17 | }; 18 | 19 | exports.break = function () { 20 | var s = new Array(55+1).join('a'); 21 | var s_ = wordwrap.hard(20)(s); 22 | 23 | var lines = s_.split('\n'); 24 | assert.equal(lines.length, 3); 25 | assert.ok(lines[0].length === 20); 26 | assert.ok(lines[1].length === 20); 27 | assert.ok(lines[2].length === 15); 28 | 29 | assert.equal(s, s_.replace(/\n/g, '')); 30 | }; 31 | -------------------------------------------------------------------------------- /node_modules/optimist/node_modules/wordwrap/test/wrap.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var wordwrap = require('wordwrap'); 3 | 4 | var fs = require('fs'); 5 | var idleness = fs.readFileSync(__dirname + '/idleness.txt', 'utf8'); 6 | 7 | exports.stop80 = function () { 8 | var lines = wordwrap(80)(idleness).split(/\n/); 9 | var words = idleness.split(/\s+/); 10 | 11 | lines.forEach(function (line) { 12 | assert.ok(line.length <= 80, 'line > 80 columns'); 13 | var chunks = line.match(/\S/) ? line.split(/\s+/) : []; 14 | assert.deepEqual(chunks, words.splice(0, chunks.length)); 15 | }); 16 | }; 17 | 18 | exports.start20stop60 = function () { 19 | var lines = wordwrap(20, 100)(idleness).split(/\n/); 20 | var words = idleness.split(/\s+/); 21 | 22 | lines.forEach(function (line) { 23 | assert.ok(line.length <= 100, 'line > 100 columns'); 24 | var chunks = line 25 | .split(/\s+/) 26 | .filter(function (x) { return x.match(/\S/) }) 27 | ; 28 | assert.deepEqual(chunks, words.splice(0, chunks.length)); 29 | assert.deepEqual(line.slice(0, 20), new Array(20 + 1).join(' ')); 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /node_modules/optimist/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "optimist", 3 | "version": "0.6.0", 4 | "description": "Light-weight option parsing with an argv hash. No optstrings attached.", 5 | "main": "./index.js", 6 | "dependencies": { 7 | "wordwrap": "~0.0.2", 8 | "minimist": "~0.0.1" 9 | }, 10 | "devDependencies": { 11 | "hashish": "~0.0.4", 12 | "tap": "~0.4.0" 13 | }, 14 | "scripts": { 15 | "test": "tap ./test/*.js" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git+ssh://git@github.com/substack/node-optimist.git" 20 | }, 21 | "keywords": [ 22 | "argument", 23 | "args", 24 | "option", 25 | "parser", 26 | "parsing", 27 | "cli", 28 | "command" 29 | ], 30 | "author": { 31 | "name": "James Halliday", 32 | "email": "mail@substack.net", 33 | "url": "http://substack.net" 34 | }, 35 | "license": "MIT/X11", 36 | "engine": { 37 | "node": ">=0.4" 38 | }, 39 | "bugs": { 40 | "url": "https://github.com/substack/node-optimist/issues" 41 | }, 42 | "_id": "optimist@0.6.0", 43 | "dist": { 44 | "shasum": "69424826f3405f79f142e6fc3d9ae58d4dbb9200", 45 | "tarball": "http://registry.npmjs.org/optimist/-/optimist-0.6.0.tgz" 46 | }, 47 | "_from": "optimist@0.6.0", 48 | "_npmVersion": "1.3.0", 49 | "_npmUser": { 50 | "name": "substack", 51 | "email": "mail@substack.net" 52 | }, 53 | "maintainers": [ 54 | { 55 | "name": "substack", 56 | "email": "mail@substack.net" 57 | } 58 | ], 59 | "directories": {}, 60 | "_shasum": "69424826f3405f79f142e6fc3d9ae58d4dbb9200", 61 | "_resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.0.tgz", 62 | "readme": "ERROR: No README data found!", 63 | "homepage": "https://github.com/substack/node-optimist#readme" 64 | } 65 | -------------------------------------------------------------------------------- /node_modules/optimist/test/_.js: -------------------------------------------------------------------------------- 1 | var spawn = require('child_process').spawn; 2 | var test = require('tap').test; 3 | 4 | test('dotSlashEmpty', testCmd('./bin.js', [])); 5 | 6 | test('dotSlashArgs', testCmd('./bin.js', [ 'a', 'b', 'c' ])); 7 | 8 | test('nodeEmpty', testCmd('node bin.js', [])); 9 | 10 | test('nodeArgs', testCmd('node bin.js', [ 'x', 'y', 'z' ])); 11 | 12 | test('whichNodeEmpty', function (t) { 13 | var which = spawn('which', ['node']); 14 | 15 | which.stdout.on('data', function (buf) { 16 | t.test( 17 | testCmd(buf.toString().trim() + ' bin.js', []) 18 | ); 19 | t.end(); 20 | }); 21 | 22 | which.stderr.on('data', function (err) { 23 | assert.error(err); 24 | t.end(); 25 | }); 26 | }); 27 | 28 | test('whichNodeArgs', function (t) { 29 | var which = spawn('which', ['node']); 30 | 31 | which.stdout.on('data', function (buf) { 32 | t.test( 33 | testCmd(buf.toString().trim() + ' bin.js', [ 'q', 'r' ]) 34 | ); 35 | t.end(); 36 | }); 37 | 38 | which.stderr.on('data', function (err) { 39 | t.error(err); 40 | t.end(); 41 | }); 42 | }); 43 | 44 | function testCmd (cmd, args) { 45 | 46 | return function (t) { 47 | var to = setTimeout(function () { 48 | assert.fail('Never got stdout data.') 49 | }, 5000); 50 | 51 | var oldDir = process.cwd(); 52 | process.chdir(__dirname + '/_'); 53 | 54 | var cmds = cmd.split(' '); 55 | 56 | var bin = spawn(cmds[0], cmds.slice(1).concat(args.map(String))); 57 | process.chdir(oldDir); 58 | 59 | bin.stderr.on('data', function (err) { 60 | t.error(err); 61 | t.end(); 62 | }); 63 | 64 | bin.stdout.on('data', function (buf) { 65 | clearTimeout(to); 66 | var _ = JSON.parse(buf.toString()); 67 | t.same(_.map(String), args.map(String)); 68 | t.end(); 69 | }); 70 | }; 71 | } 72 | -------------------------------------------------------------------------------- /node_modules/optimist/test/_/argv.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | console.log(JSON.stringify(process.argv)); 3 | -------------------------------------------------------------------------------- /node_modules/optimist/test/_/bin.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('../../index').argv 3 | console.log(JSON.stringify(argv._)); 4 | -------------------------------------------------------------------------------- /node_modules/optimist/test/dash.js: -------------------------------------------------------------------------------- 1 | var optimist = require('../index'); 2 | var test = require('tap').test; 3 | 4 | test('-', function (t) { 5 | t.plan(5); 6 | t.deepEqual( 7 | fix(optimist.parse([ '-n', '-' ])), 8 | { n: '-', _: [] } 9 | ); 10 | t.deepEqual( 11 | fix(optimist.parse([ '-' ])), 12 | { _: [ '-' ] } 13 | ); 14 | t.deepEqual( 15 | fix(optimist.parse([ '-f-' ])), 16 | { f: '-', _: [] } 17 | ); 18 | t.deepEqual( 19 | fix(optimist([ '-b', '-' ]).boolean('b').argv), 20 | { b: true, _: [ '-' ] } 21 | ); 22 | t.deepEqual( 23 | fix(optimist([ '-s', '-' ]).string('s').argv), 24 | { s: '-', _: [] } 25 | ); 26 | }); 27 | 28 | function fix (obj) { 29 | delete obj.$0; 30 | return obj; 31 | } 32 | -------------------------------------------------------------------------------- /node_modules/optimist/test/parse_modified.js: -------------------------------------------------------------------------------- 1 | var optimist = require('../'); 2 | var test = require('tap').test; 3 | 4 | test('parse with modifier functions' , function (t) { 5 | t.plan(1); 6 | 7 | var argv = optimist().boolean('b').parse([ '-b', '123' ]); 8 | t.deepEqual(fix(argv), { b: true, _: ['123'] }); 9 | }); 10 | 11 | function fix (obj) { 12 | delete obj.$0; 13 | return obj; 14 | } 15 | -------------------------------------------------------------------------------- /node_modules/optimist/test/short.js: -------------------------------------------------------------------------------- 1 | var optimist = require('../index'); 2 | var test = require('tap').test; 3 | 4 | test('-n123', function (t) { 5 | t.plan(1); 6 | var parse = optimist.parse([ '-n123' ]); 7 | t.equal(parse.n, 123); 8 | }); 9 | 10 | test('-123', function (t) { 11 | t.plan(3); 12 | var parse = optimist.parse([ '-123', '456' ]); 13 | t.equal(parse['1'], true); 14 | t.equal(parse['2'], true); 15 | t.equal(parse['3'], 456); 16 | }); 17 | -------------------------------------------------------------------------------- /node_modules/optimist/test/whitespace.js: -------------------------------------------------------------------------------- 1 | var optimist = require('../'); 2 | var test = require('tap').test; 3 | 4 | test('whitespace should be whitespace' , function (t) { 5 | t.plan(1); 6 | var x = optimist.parse([ '-x', '\t' ]).x; 7 | t.equal(x, '\t'); 8 | }); 9 | -------------------------------------------------------------------------------- /node_modules/q/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2009–2014 Kristopher Michael Kowal. All rights reserved. 2 | Permission is hereby granted, free of charge, to any person obtaining a copy 3 | of this software and associated documentation files (the "Software"), to 4 | deal in the Software without restriction, including without limitation the 5 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 6 | sell copies of the Software, and to permit persons to whom the Software is 7 | furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 18 | IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /node_modules/q/node_modules/asap/LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | Copyright 2009–2014 Contributors. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to 6 | deal in the Software without restriction, including without limitation the 7 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /node_modules/q/node_modules/asap/asap.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var rawAsap = require("./raw"); 4 | var freeTasks = []; 5 | 6 | /** 7 | * Calls a task as soon as possible after returning, in its own event, with 8 | * priority over IO events. An exception thrown in a task can be handled by 9 | * `process.on("uncaughtException") or `domain.on("error")`, but will otherwise 10 | * crash the process. If the error is handled, all subsequent tasks will 11 | * resume. 12 | * 13 | * @param {{call}} task A callable object, typically a function that takes no 14 | * arguments. 15 | */ 16 | module.exports = asap; 17 | function asap(task) { 18 | var rawTask; 19 | if (freeTasks.length) { 20 | rawTask = freeTasks.pop(); 21 | } else { 22 | rawTask = new RawTask(); 23 | } 24 | rawTask.task = task; 25 | rawTask.domain = process.domain; 26 | rawAsap(rawTask); 27 | } 28 | 29 | function RawTask() { 30 | this.task = null; 31 | this.domain = null; 32 | } 33 | 34 | RawTask.prototype.call = function () { 35 | if (this.domain) { 36 | this.domain.enter(); 37 | } 38 | var threw = true; 39 | try { 40 | this.task.call(); 41 | threw = false; 42 | // If the task throws an exception (presumably) Node.js restores the 43 | // domain stack for the next event. 44 | if (this.domain) { 45 | this.domain.exit(); 46 | } 47 | } finally { 48 | // We use try/finally and a threw flag to avoid messing up stack traces 49 | // when we catch and release errors. 50 | if (threw) { 51 | // In Node.js, uncaught exceptions are considered fatal errors. 52 | // Re-throw them to interrupt flushing! 53 | // Ensure that flushing continues if an uncaught exception is 54 | // suppressed listening process.on("uncaughtException") or 55 | // domain.on("error"). 56 | rawAsap.requestFlush(); 57 | } 58 | // If the task threw an error, we do not want to exit the domain here. 59 | // Exiting the domain would prevent the domain from catching the error. 60 | this.task = null; 61 | this.domain = null; 62 | freeTasks.push(this); 63 | } 64 | }; 65 | 66 | -------------------------------------------------------------------------------- /node_modules/q/node_modules/asap/browser-asap.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // rawAsap provides everything we need except exception management. 4 | var rawAsap = require("./raw"); 5 | // RawTasks are recycled to reduce GC churn. 6 | var freeTasks = []; 7 | // We queue errors to ensure they are thrown in right order (FIFO). 8 | // Array-as-queue is good enough here, since we are just dealing with exceptions. 9 | var pendingErrors = []; 10 | var requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError); 11 | 12 | function throwFirstError() { 13 | if (pendingErrors.length) { 14 | throw pendingErrors.shift(); 15 | } 16 | } 17 | 18 | /** 19 | * Calls a task as soon as possible after returning, in its own event, with priority 20 | * over other events like animation, reflow, and repaint. An error thrown from an 21 | * event will not interrupt, nor even substantially slow down the processing of 22 | * other events, but will be rather postponed to a lower priority event. 23 | * @param {{call}} task A callable object, typically a function that takes no 24 | * arguments. 25 | */ 26 | module.exports = asap; 27 | function asap(task) { 28 | var rawTask; 29 | if (freeTasks.length) { 30 | rawTask = freeTasks.pop(); 31 | } else { 32 | rawTask = new RawTask(); 33 | } 34 | rawTask.task = task; 35 | rawAsap(rawTask); 36 | } 37 | 38 | // We wrap tasks with recyclable task objects. A task object implements 39 | // `call`, just like a function. 40 | function RawTask() { 41 | this.task = null; 42 | } 43 | 44 | // The sole purpose of wrapping the task is to catch the exception and recycle 45 | // the task object after its single use. 46 | RawTask.prototype.call = function () { 47 | try { 48 | this.task.call(); 49 | } catch (error) { 50 | if (asap.onerror) { 51 | // This hook exists purely for testing purposes. 52 | // Its name will be periodically randomized to break any code that 53 | // depends on its existence. 54 | asap.onerror(error); 55 | } else { 56 | // In a web browser, exceptions are not fatal. However, to avoid 57 | // slowing down the queue of pending tasks, we rethrow the error in a 58 | // lower priority turn. 59 | pendingErrors.push(error); 60 | requestErrorThrow(); 61 | } 62 | } finally { 63 | this.task = null; 64 | freeTasks[freeTasks.length] = this; 65 | } 66 | }; 67 | -------------------------------------------------------------------------------- /node_modules/q/node_modules/pop-iterate/.npmignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | -------------------------------------------------------------------------------- /node_modules/q/node_modules/pop-iterate/array-iterator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var Iteration = require("./iteration"); 4 | 5 | module.exports = ArrayIterator; 6 | function ArrayIterator(iterable, start, stop, step) { 7 | this.array = iterable; 8 | this.start = start || 0; 9 | this.stop = stop || Infinity; 10 | this.step = step || 1; 11 | } 12 | 13 | ArrayIterator.prototype.next = function () { 14 | var iteration; 15 | if (this.start < Math.min(this.array.length, this.stop)) { 16 | iteration = new Iteration(this.array[this.start], false, this.start); 17 | this.start += this.step; 18 | } else { 19 | iteration = new Iteration(undefined, true); 20 | } 21 | return iteration; 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /node_modules/q/node_modules/pop-iterate/iteration.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports = Iteration; 4 | function Iteration(value, done, index) { 5 | this.value = value; 6 | this.done = done; 7 | this.index = index; 8 | } 9 | 10 | Iteration.prototype.equals = function (other) { 11 | return ( 12 | typeof other == 'object' && 13 | other.value === this.value && 14 | other.done === this.done && 15 | other.index === this.index 16 | ); 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /node_modules/q/node_modules/pop-iterate/object-iterator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var Iteration = require("./iteration"); 4 | var ArrayIterator = require("./array-iterator"); 5 | 6 | module.exports = ObjectIterator; 7 | function ObjectIterator(iterable, start, stop, step) { 8 | this.object = iterable; 9 | this.keysIterator = new ArrayIterator(Object.keys(iterable), start, stop, step); 10 | } 11 | 12 | ObjectIterator.prototype.next = function () { 13 | var iteration = this.keysIterator.next(); 14 | if (iteration.done) { 15 | return iteration; 16 | } 17 | var key = iteration.value; 18 | return new Iteration(this.object[key], false, key); 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /node_modules/q/node_modules/pop-iterate/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pop-iterate", 3 | "version": "1.0.1", 4 | "description": "A polymorphic iterate operator for arrays and other iterables", 5 | "main": "pop-iterate.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "devDependencies": { 10 | "jasminum": "^2.0.5" 11 | }, 12 | "scripts": { 13 | "test": "jasminum test" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/kriskowal/pop-iterate.git" 18 | }, 19 | "keywords": [ 20 | "pop", 21 | "polymorphic", 22 | "operator", 23 | "iterate" 24 | ], 25 | "author": { 26 | "name": "Kris Kowal", 27 | "email": "kris@cixar.com" 28 | }, 29 | "license": "MIT", 30 | "bugs": { 31 | "url": "https://github.com/kriskowal/pop-iterate/issues" 32 | }, 33 | "homepage": "https://github.com/kriskowal/pop-iterate", 34 | "gitHead": "dc8f214537d6134d25a6da84ca78715bfbcd0001", 35 | "_id": "pop-iterate@1.0.1", 36 | "_shasum": "ceacfdab4abf353d7a0f2aaa2c1fc7b3f9413ba3", 37 | "_from": "pop-iterate@>=1.0.1 <2.0.0", 38 | "_npmVersion": "1.4.21", 39 | "_npmUser": { 40 | "name": "kriskowal", 41 | "email": "kris.kowal@cixar.com" 42 | }, 43 | "maintainers": [ 44 | { 45 | "name": "kriskowal", 46 | "email": "kris.kowal@cixar.com" 47 | } 48 | ], 49 | "dist": { 50 | "shasum": "ceacfdab4abf353d7a0f2aaa2c1fc7b3f9413ba3", 51 | "tarball": "http://registry.npmjs.org/pop-iterate/-/pop-iterate-1.0.1.tgz" 52 | }, 53 | "_resolved": "https://registry.npmjs.org/pop-iterate/-/pop-iterate-1.0.1.tgz", 54 | "readme": "ERROR: No README data found!" 55 | } 56 | -------------------------------------------------------------------------------- /node_modules/q/node_modules/pop-iterate/pop-iterate.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var ArrayIterator = require("./array-iterator"); 4 | var ObjectIterator = require("./object-iterator"); 5 | 6 | module.exports = iterate; 7 | function iterate(iterable, start, stop, step) { 8 | if (!iterable) { 9 | return empty; 10 | } else if (Array.isArray(iterable)) { 11 | return new ArrayIterator(iterable, start, stop, step); 12 | } else if (typeof iterable.next === "function") { 13 | return iterable; 14 | } else if (typeof iterable.iterate === "function") { 15 | return iterable.iterate(start, stop, step); 16 | } else if (typeof iterable === "object") { 17 | return new ObjectIterator(iterable); 18 | } else { 19 | throw new TypeError("Can't iterate " + iterable); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /node_modules/q/node_modules/pop-iterate/test/pop-iterate-test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var iterate = require("../pop-iterate"); 4 | 5 | describe("array iterator", function () { 6 | 7 | it("iterates an array", function () { 8 | var iterator = iterate([1, 2, 3]); 9 | expect(iterator.next()).toEqual({value: 1, done: false, index: 0}); 10 | expect(iterator.next()).toEqual({value: 2, done: false, index: 1}); 11 | expect(iterator.next()).toEqual({value: 3, done: false, index: 2}); 12 | expect(iterator.next()).toEqual({done: true}); 13 | }); 14 | 15 | it("handles stuttering", function () { 16 | var iterator = iterate([]); 17 | expect(iterator.next()).toEqual({done: true}); 18 | expect(iterator.next()).toEqual({done: true}); 19 | expect(iterator.next()).toEqual({done: true}); 20 | }); 21 | 22 | it("start, stop, and step", function () { 23 | var iterator = iterate([1, 2, 3, 4, 5, 6, 7, 8], 1, 6, 2); 24 | expect(iterator.next()).toEqual({value: 2, done: false, index: 1}); 25 | expect(iterator.next()).toEqual({value: 4, done: false, index: 3}); 26 | expect(iterator.next()).toEqual({value: 6, done: false, index: 5}); 27 | expect(iterator.next()).toEqual({done: true}); 28 | }); 29 | 30 | }); 31 | 32 | describe("iterate an object", function () { 33 | 34 | it("returns entries", function () { 35 | var object = {a: 10, b: 20, c: 30}; 36 | var iterator = iterate(object); 37 | expect(iterator.next()).toEqual({value: 10, done: false, index: "a"}); 38 | expect(iterator.next()).toEqual({value: 20, done: false, index: "b"}); 39 | expect(iterator.next()).toEqual({value: 30, done: false, index: "c"}); 40 | expect(iterator.next()).toEqual({done: true}); 41 | }); 42 | 43 | }); 44 | 45 | describe("custom iterator", function () { 46 | 47 | it("calls through to custom iterator", function () { 48 | var iterator, prevValue, nextValue, start, stop, step; 49 | iterator = iterate({ 50 | iterate: function (gotStart, gotStop, gotStep) { 51 | start = gotStart; 52 | stop = gotStop; 53 | step = gotStep; 54 | return { 55 | next: function (value) { 56 | prevValue = value; 57 | return nextValue; 58 | } 59 | }; 60 | } 61 | }, 1, 2, 3); 62 | 63 | expect(start).toBe(1); 64 | expect(stop).toBe(2); 65 | expect(step).toBe(3); 66 | 67 | nextValue = 10; 68 | expect(iterator.next(20)).toBe(10); 69 | expect(prevValue).toBe(20); 70 | }); 71 | 72 | }); 73 | -------------------------------------------------------------------------------- /node_modules/q/node_modules/weak-map/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "weak-map", 3 | "version": "1.0.5", 4 | "description": "A WeakMap shim for Node.js and browsers", 5 | "main": "weak-map.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git://github.com/drses/weak-map.git" 9 | }, 10 | "keywords": [ 11 | "weakmap", 12 | "weak-map", 13 | "weak", 14 | "map", 15 | "collections", 16 | "es6" 17 | ], 18 | "author": { 19 | "name": "Mark Miller", 20 | "email": "erights@gmail.com" 21 | }, 22 | "maintainer": "Kris Kowal ", 23 | "license": "Apache 2.0", 24 | "bugs": { 25 | "url": "https://github.com/drses/weak-map/issues" 26 | }, 27 | "files": [ 28 | "weak-map.js" 29 | ], 30 | "scripts": { 31 | "test": "npm run test:native; npm run test:shim", 32 | "test:phantom": "", 33 | "test:shim": "node test/index.js", 34 | "test:native": "node --harmony_collections test/index.js" 35 | }, 36 | "devDependencies": { 37 | "jasminum": "^2.0.1" 38 | }, 39 | "homepage": "https://github.com/drses/weak-map", 40 | "_id": "weak-map@1.0.5", 41 | "dist": { 42 | "shasum": "79691584d98607f5070bd3b70a40e6bb22e401eb", 43 | "tarball": "http://registry.npmjs.org/weak-map/-/weak-map-1.0.5.tgz" 44 | }, 45 | "_from": "weak-map@>=1.0.5 <2.0.0", 46 | "_npmVersion": "1.4.3", 47 | "_npmUser": { 48 | "name": "kriskowal", 49 | "email": "kris.kowal@cixar.com" 50 | }, 51 | "maintainers": [ 52 | { 53 | "name": "kriskowal", 54 | "email": "kris.kowal@cixar.com" 55 | } 56 | ], 57 | "directories": {}, 58 | "_shasum": "79691584d98607f5070bd3b70a40e6bb22e401eb", 59 | "_resolved": "https://registry.npmjs.org/weak-map/-/weak-map-1.0.5.tgz", 60 | "readme": "ERROR: No README data found!" 61 | } 62 | -------------------------------------------------------------------------------- /node_modules/q/queue.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var Q = require("./q"); 4 | 5 | module.exports = Queue; 6 | function Queue() { 7 | if (!(this instanceof Queue)) { 8 | return new Queue(); 9 | } 10 | var ends = Q.defer(); 11 | this.put = function (value) { 12 | var next = Q.defer(); 13 | ends.resolve({ 14 | head: value, 15 | tail: next.promise 16 | }); 17 | ends.resolve = next.resolve; 18 | }; 19 | this.get = function () { 20 | var result = ends.promise.get("head"); 21 | ends.promise = ends.promise.get("tail"); 22 | return result; 23 | }; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /node_modules/shelljs/.documentup.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ShellJS", 3 | "twitter": [ 4 | "r2r" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /node_modules/shelljs/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "loopfunc": true, 3 | "sub": true, 4 | "undef": true, 5 | "unused": true, 6 | "node": true 7 | } -------------------------------------------------------------------------------- /node_modules/shelljs/.npmignore: -------------------------------------------------------------------------------- 1 | test/ 2 | tmp/ -------------------------------------------------------------------------------- /node_modules/shelljs/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.8" 4 | - "0.10" 5 | - "0.11" 6 | -------------------------------------------------------------------------------- /node_modules/shelljs/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, Artur Adib 2 | All rights reserved. 3 | 4 | You may use this project under the terms of the New BSD license as follows: 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of Artur Adib nor the 14 | names of the contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL ARTUR ADIB BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /node_modules/shelljs/bin/shjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('../global'); 3 | 4 | if (process.argv.length < 3) { 5 | console.log('ShellJS: missing argument (script name)'); 6 | console.log(); 7 | process.exit(1); 8 | } 9 | 10 | var args, 11 | scriptName = process.argv[2]; 12 | env['NODE_PATH'] = __dirname + '/../..'; 13 | 14 | if (!scriptName.match(/\.js/) && !scriptName.match(/\.coffee/)) { 15 | if (test('-f', scriptName + '.js')) 16 | scriptName += '.js'; 17 | if (test('-f', scriptName + '.coffee')) 18 | scriptName += '.coffee'; 19 | } 20 | 21 | if (!test('-f', scriptName)) { 22 | console.log('ShellJS: script not found ('+scriptName+')'); 23 | console.log(); 24 | process.exit(1); 25 | } 26 | 27 | args = process.argv.slice(3); 28 | 29 | for (var i = 0, l = args.length; i < l; i++) { 30 | if (args[i][0] !== "-"){ 31 | args[i] = '"' + args[i] + '"'; // fixes arguments with multiple words 32 | } 33 | } 34 | 35 | if (scriptName.match(/\.coffee$/)) { 36 | // 37 | // CoffeeScript 38 | // 39 | if (which('coffee')) { 40 | exec('coffee ' + scriptName + ' ' + args.join(' '), { async: true }); 41 | } else { 42 | console.log('ShellJS: CoffeeScript interpreter not found'); 43 | console.log(); 44 | process.exit(1); 45 | } 46 | } else { 47 | // 48 | // JavaScript 49 | // 50 | exec('node ' + scriptName + ' ' + args.join(' '), { async: true }); 51 | } 52 | -------------------------------------------------------------------------------- /node_modules/shelljs/global.js: -------------------------------------------------------------------------------- 1 | var shell = require('./shell.js'); 2 | for (var cmd in shell) 3 | global[cmd] = shell[cmd]; 4 | -------------------------------------------------------------------------------- /node_modules/shelljs/make.js: -------------------------------------------------------------------------------- 1 | require('./global'); 2 | 3 | global.config.fatal = true; 4 | global.target = {}; 5 | 6 | // This ensures we only execute the script targets after the entire script has 7 | // been evaluated 8 | var args = process.argv.slice(2); 9 | setTimeout(function() { 10 | var t; 11 | 12 | if (args.length === 1 && args[0] === '--help') { 13 | console.log('Available targets:'); 14 | for (t in global.target) 15 | console.log(' ' + t); 16 | return; 17 | } 18 | 19 | // Wrap targets to prevent duplicate execution 20 | for (t in global.target) { 21 | (function(t, oldTarget){ 22 | 23 | // Wrap it 24 | global.target[t] = function(force) { 25 | if (oldTarget.done && !force) 26 | return; 27 | oldTarget.done = true; 28 | return oldTarget.apply(oldTarget, arguments); 29 | }; 30 | 31 | })(t, global.target[t]); 32 | } 33 | 34 | // Execute desired targets 35 | if (args.length > 0) { 36 | args.forEach(function(arg) { 37 | if (arg in global.target) 38 | global.target[arg](); 39 | else { 40 | console.log('no such target: ' + arg); 41 | } 42 | }); 43 | } else if ('all' in global.target) { 44 | global.target.all(); 45 | } 46 | 47 | }, 0); 48 | -------------------------------------------------------------------------------- /node_modules/shelljs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shelljs", 3 | "version": "0.2.6", 4 | "author": { 5 | "name": "Artur Adib", 6 | "email": "aadib@mozilla.com" 7 | }, 8 | "description": "Portable Unix shell commands for Node.js", 9 | "keywords": [ 10 | "unix", 11 | "shell", 12 | "makefile", 13 | "make", 14 | "jake", 15 | "synchronous" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "git://github.com/arturadib/shelljs.git" 20 | }, 21 | "homepage": "http://github.com/arturadib/shelljs", 22 | "main": "./shell.js", 23 | "scripts": { 24 | "test": "node scripts/run-tests" 25 | }, 26 | "bin": { 27 | "shjs": "./bin/shjs" 28 | }, 29 | "dependencies": {}, 30 | "devDependencies": { 31 | "jshint": "~2.1.11" 32 | }, 33 | "optionalDependencies": {}, 34 | "engines": { 35 | "node": ">=0.8.0" 36 | }, 37 | "bugs": { 38 | "url": "https://github.com/arturadib/shelljs/issues" 39 | }, 40 | "_id": "shelljs@0.2.6", 41 | "dist": { 42 | "shasum": "90492d72ffcc8159976baba62fb0f6884f0c3378", 43 | "tarball": "http://registry.npmjs.org/shelljs/-/shelljs-0.2.6.tgz" 44 | }, 45 | "_from": "shelljs@0.2.6", 46 | "_npmVersion": "1.3.8", 47 | "_npmUser": { 48 | "name": "artur", 49 | "email": "arturadib@gmail.com" 50 | }, 51 | "maintainers": [ 52 | { 53 | "name": "artur", 54 | "email": "arturadib@gmail.com" 55 | } 56 | ], 57 | "directories": {}, 58 | "_shasum": "90492d72ffcc8159976baba62fb0f6884f0c3378", 59 | "_resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.2.6.tgz", 60 | "readme": "ERROR: No README data found!" 61 | } 62 | -------------------------------------------------------------------------------- /node_modules/shelljs/scripts/generate-docs.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('../global'); 3 | 4 | echo('Appending docs to README.md'); 5 | 6 | cd(__dirname + '/..'); 7 | 8 | // Extract docs from shell.js 9 | var docs = grep('//@', 'shell.js'); 10 | 11 | docs = docs.replace(/\/\/\@include (.+)/g, function(match, path) { 12 | var file = path.match('.js$') ? path : path+'.js'; 13 | return grep('//@', file); 14 | }); 15 | 16 | // Remove '//@' 17 | docs = docs.replace(/\/\/\@ ?/g, ''); 18 | // Append docs to README 19 | sed('-i', /## Command reference(.|\n)*/, '## Command reference\n\n' + docs, 'README.md'); 20 | 21 | echo('All done.'); 22 | -------------------------------------------------------------------------------- /node_modules/shelljs/scripts/run-tests.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('../global'); 3 | 4 | var path = require('path'); 5 | 6 | var failed = false; 7 | 8 | // 9 | // Lint 10 | // 11 | JSHINT_BIN = './node_modules/jshint/bin/jshint'; 12 | cd(__dirname + '/..'); 13 | 14 | if (!test('-f', JSHINT_BIN)) { 15 | echo('JSHint not found. Run `npm install` in the root dir first.'); 16 | exit(1); 17 | } 18 | 19 | if (exec(JSHINT_BIN + ' *.js test/*.js').code !== 0) { 20 | failed = true; 21 | echo('*** JSHINT FAILED! (return code != 0)'); 22 | echo(); 23 | } else { 24 | echo('All JSHint tests passed'); 25 | echo(); 26 | } 27 | 28 | // 29 | // Unit tests 30 | // 31 | cd(__dirname + '/../test'); 32 | ls('*.js').forEach(function(file) { 33 | echo('Running test:', file); 34 | if (exec('node ' + file).code !== 123) { // 123 avoids false positives (e.g. premature exit) 35 | failed = true; 36 | echo('*** TEST FAILED! (missing exit code "123")'); 37 | echo(); 38 | } 39 | }); 40 | 41 | if (failed) { 42 | echo(); 43 | echo('*******************************************************'); 44 | echo('WARNING: Some tests did not pass!'); 45 | echo('*******************************************************'); 46 | exit(1); 47 | } else { 48 | echo(); 49 | echo('All tests passed.'); 50 | } 51 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/cat.js: -------------------------------------------------------------------------------- 1 | var common = require('./common'); 2 | var fs = require('fs'); 3 | 4 | //@ 5 | //@ ### cat(file [, file ...]) 6 | //@ ### cat(file_array) 7 | //@ 8 | //@ Examples: 9 | //@ 10 | //@ ```javascript 11 | //@ var str = cat('file*.txt'); 12 | //@ var str = cat('file1', 'file2'); 13 | //@ var str = cat(['file1', 'file2']); // same as above 14 | //@ ``` 15 | //@ 16 | //@ Returns a string containing the given file, or a concatenated string 17 | //@ containing the files if more than one file is given (a new line character is 18 | //@ introduced between each file). Wildcard `*` accepted. 19 | function _cat(options, files) { 20 | var cat = ''; 21 | 22 | if (!files) 23 | common.error('no paths given'); 24 | 25 | if (typeof files === 'string') 26 | files = [].slice.call(arguments, 1); 27 | // if it's array leave it as it is 28 | 29 | files = common.expand(files); 30 | 31 | files.forEach(function(file) { 32 | if (!fs.existsSync(file)) 33 | common.error('no such file or directory: ' + file); 34 | 35 | cat += fs.readFileSync(file, 'utf8') + '\n'; 36 | }); 37 | 38 | if (cat[cat.length-1] === '\n') 39 | cat = cat.substring(0, cat.length-1); 40 | 41 | return common.ShellString(cat); 42 | } 43 | module.exports = _cat; 44 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/cd.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var common = require('./common'); 3 | 4 | //@ 5 | //@ ### cd('dir') 6 | //@ Changes to directory `dir` for the duration of the script 7 | function _cd(options, dir) { 8 | if (!dir) 9 | common.error('directory not specified'); 10 | 11 | if (!fs.existsSync(dir)) 12 | common.error('no such file or directory: ' + dir); 13 | 14 | if (!fs.statSync(dir).isDirectory()) 15 | common.error('not a directory: ' + dir); 16 | 17 | process.chdir(dir); 18 | } 19 | module.exports = _cd; 20 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/echo.js: -------------------------------------------------------------------------------- 1 | var common = require('./common'); 2 | 3 | //@ 4 | //@ ### echo(string [,string ...]) 5 | //@ 6 | //@ Examples: 7 | //@ 8 | //@ ```javascript 9 | //@ echo('hello world'); 10 | //@ var str = echo('hello world'); 11 | //@ ``` 12 | //@ 13 | //@ Prints string to stdout, and returns string with additional utility methods 14 | //@ like `.to()`. 15 | function _echo() { 16 | var messages = [].slice.call(arguments, 0); 17 | console.log.apply(this, messages); 18 | return common.ShellString(messages.join(' ')); 19 | } 20 | module.exports = _echo; 21 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/error.js: -------------------------------------------------------------------------------- 1 | var common = require('./common'); 2 | 3 | //@ 4 | //@ ### error() 5 | //@ Tests if error occurred in the last command. Returns `null` if no error occurred, 6 | //@ otherwise returns string explaining the error 7 | function error() { 8 | return common.state.error; 9 | }; 10 | module.exports = error; 11 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/find.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var common = require('./common'); 3 | var _ls = require('./ls'); 4 | 5 | //@ 6 | //@ ### find(path [,path ...]) 7 | //@ ### find(path_array) 8 | //@ Examples: 9 | //@ 10 | //@ ```javascript 11 | //@ find('src', 'lib'); 12 | //@ find(['src', 'lib']); // same as above 13 | //@ find('.').filter(function(file) { return file.match(/\.js$/); }); 14 | //@ ``` 15 | //@ 16 | //@ Returns array of all files (however deep) in the given paths. 17 | //@ 18 | //@ The main difference from `ls('-R', path)` is that the resulting file names 19 | //@ include the base directories, e.g. `lib/resources/file1` instead of just `file1`. 20 | function _find(options, paths) { 21 | if (!paths) 22 | common.error('no path specified'); 23 | else if (typeof paths === 'object') 24 | paths = paths; // assume array 25 | else if (typeof paths === 'string') 26 | paths = [].slice.call(arguments, 1); 27 | 28 | var list = []; 29 | 30 | function pushFile(file) { 31 | if (common.platform === 'win') 32 | file = file.replace(/\\/g, '/'); 33 | list.push(file); 34 | } 35 | 36 | // why not simply do ls('-R', paths)? because the output wouldn't give the base dirs 37 | // to get the base dir in the output, we need instead ls('-R', 'dir/*') for every directory 38 | 39 | paths.forEach(function(file) { 40 | pushFile(file); 41 | 42 | if (fs.statSync(file).isDirectory()) { 43 | _ls('-RA', file+'/*').forEach(function(subfile) { 44 | pushFile(subfile); 45 | }); 46 | } 47 | }); 48 | 49 | return list; 50 | } 51 | module.exports = _find; 52 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/grep.js: -------------------------------------------------------------------------------- 1 | var common = require('./common'); 2 | var fs = require('fs'); 3 | 4 | //@ 5 | //@ ### grep([options ,] regex_filter, file [, file ...]) 6 | //@ ### grep([options ,] regex_filter, file_array) 7 | //@ Available options: 8 | //@ 9 | //@ + `-v`: Inverse the sense of the regex and print the lines not matching the criteria. 10 | //@ 11 | //@ Examples: 12 | //@ 13 | //@ ```javascript 14 | //@ grep('-v', 'GLOBAL_VARIABLE', '*.js'); 15 | //@ grep('GLOBAL_VARIABLE', '*.js'); 16 | //@ ``` 17 | //@ 18 | //@ Reads input string from given files and returns a string containing all lines of the 19 | //@ file that match the given `regex_filter`. Wildcard `*` accepted. 20 | function _grep(options, regex, files) { 21 | options = common.parseOptions(options, { 22 | 'v': 'inverse' 23 | }); 24 | 25 | if (!files) 26 | common.error('no paths given'); 27 | 28 | if (typeof files === 'string') 29 | files = [].slice.call(arguments, 2); 30 | // if it's array leave it as it is 31 | 32 | files = common.expand(files); 33 | 34 | var grep = ''; 35 | files.forEach(function(file) { 36 | if (!fs.existsSync(file)) { 37 | common.error('no such file or directory: ' + file, true); 38 | return; 39 | } 40 | 41 | var contents = fs.readFileSync(file, 'utf8'), 42 | lines = contents.split(/\r*\n/); 43 | lines.forEach(function(line) { 44 | var matched = line.match(regex); 45 | if ((options.inverse && !matched) || (!options.inverse && matched)) 46 | grep += line + '\n'; 47 | }); 48 | }); 49 | 50 | return common.ShellString(grep); 51 | } 52 | module.exports = _grep; 53 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/mkdir.js: -------------------------------------------------------------------------------- 1 | var common = require('./common'); 2 | var fs = require('fs'); 3 | var path = require('path'); 4 | 5 | // Recursively creates 'dir' 6 | function mkdirSyncRecursive(dir) { 7 | var baseDir = path.dirname(dir); 8 | 9 | // Base dir exists, no recursion necessary 10 | if (fs.existsSync(baseDir)) { 11 | fs.mkdirSync(dir, parseInt('0777', 8)); 12 | return; 13 | } 14 | 15 | // Base dir does not exist, go recursive 16 | mkdirSyncRecursive(baseDir); 17 | 18 | // Base dir created, can create dir 19 | fs.mkdirSync(dir, parseInt('0777', 8)); 20 | } 21 | 22 | //@ 23 | //@ ### mkdir([options ,] dir [, dir ...]) 24 | //@ ### mkdir([options ,] dir_array) 25 | //@ Available options: 26 | //@ 27 | //@ + `p`: full path (will create intermediate dirs if necessary) 28 | //@ 29 | //@ Examples: 30 | //@ 31 | //@ ```javascript 32 | //@ mkdir('-p', '/tmp/a/b/c/d', '/tmp/e/f/g'); 33 | //@ mkdir('-p', ['/tmp/a/b/c/d', '/tmp/e/f/g']); // same as above 34 | //@ ``` 35 | //@ 36 | //@ Creates directories. 37 | function _mkdir(options, dirs) { 38 | options = common.parseOptions(options, { 39 | 'p': 'fullpath' 40 | }); 41 | if (!dirs) 42 | common.error('no paths given'); 43 | 44 | if (typeof dirs === 'string') 45 | dirs = [].slice.call(arguments, 1); 46 | // if it's array leave it as it is 47 | 48 | dirs.forEach(function(dir) { 49 | if (fs.existsSync(dir)) { 50 | if (!options.fullpath) 51 | common.error('path already exists: ' + dir, true); 52 | return; // skip dir 53 | } 54 | 55 | // Base dir does not exist, and no -p option given 56 | var baseDir = path.dirname(dir); 57 | if (!fs.existsSync(baseDir) && !options.fullpath) { 58 | common.error('no such file or directory: ' + baseDir, true); 59 | return; // skip dir 60 | } 61 | 62 | if (options.fullpath) 63 | mkdirSyncRecursive(dir); 64 | else 65 | fs.mkdirSync(dir, parseInt('0777', 8)); 66 | }); 67 | } // mkdir 68 | module.exports = _mkdir; 69 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/mv.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var path = require('path'); 3 | var common = require('./common'); 4 | 5 | //@ 6 | //@ ### mv(source [, source ...], dest') 7 | //@ ### mv(source_array, dest') 8 | //@ Available options: 9 | //@ 10 | //@ + `f`: force 11 | //@ 12 | //@ Examples: 13 | //@ 14 | //@ ```javascript 15 | //@ mv('-f', 'file', 'dir/'); 16 | //@ mv('file1', 'file2', 'dir/'); 17 | //@ mv(['file1', 'file2'], 'dir/'); // same as above 18 | //@ ``` 19 | //@ 20 | //@ Moves files. The wildcard `*` is accepted. 21 | function _mv(options, sources, dest) { 22 | options = common.parseOptions(options, { 23 | 'f': 'force' 24 | }); 25 | 26 | // Get sources, dest 27 | if (arguments.length < 3) { 28 | common.error('missing and/or '); 29 | } else if (arguments.length > 3) { 30 | sources = [].slice.call(arguments, 1, arguments.length - 1); 31 | dest = arguments[arguments.length - 1]; 32 | } else if (typeof sources === 'string') { 33 | sources = [sources]; 34 | } else if ('length' in sources) { 35 | sources = sources; // no-op for array 36 | } else { 37 | common.error('invalid arguments'); 38 | } 39 | 40 | sources = common.expand(sources); 41 | 42 | var exists = fs.existsSync(dest), 43 | stats = exists && fs.statSync(dest); 44 | 45 | // Dest is not existing dir, but multiple sources given 46 | if ((!exists || !stats.isDirectory()) && sources.length > 1) 47 | common.error('dest is not a directory (too many sources)'); 48 | 49 | // Dest is an existing file, but no -f given 50 | if (exists && stats.isFile() && !options.force) 51 | common.error('dest file already exists: ' + dest); 52 | 53 | sources.forEach(function(src) { 54 | if (!fs.existsSync(src)) { 55 | common.error('no such file or directory: '+src, true); 56 | return; // skip file 57 | } 58 | 59 | // If here, src exists 60 | 61 | // When copying to '/path/dir': 62 | // thisDest = '/path/dir/file1' 63 | var thisDest = dest; 64 | if (fs.existsSync(dest) && fs.statSync(dest).isDirectory()) 65 | thisDest = path.normalize(dest + '/' + path.basename(src)); 66 | 67 | if (fs.existsSync(thisDest) && !options.force) { 68 | common.error('dest file already exists: ' + thisDest, true); 69 | return; // skip file 70 | } 71 | 72 | if (path.resolve(src) === path.dirname(path.resolve(thisDest))) { 73 | common.error('cannot move to self: '+src, true); 74 | return; // skip file 75 | } 76 | 77 | fs.renameSync(src, thisDest); 78 | }); // forEach(src) 79 | } // mv 80 | module.exports = _mv; 81 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/popd.js: -------------------------------------------------------------------------------- 1 | // see dirs.js -------------------------------------------------------------------------------- /node_modules/shelljs/src/pushd.js: -------------------------------------------------------------------------------- 1 | // see dirs.js -------------------------------------------------------------------------------- /node_modules/shelljs/src/pwd.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var common = require('./common'); 3 | 4 | //@ 5 | //@ ### pwd() 6 | //@ Returns the current directory. 7 | function _pwd(options) { 8 | var pwd = path.resolve(process.cwd()); 9 | return common.ShellString(pwd); 10 | } 11 | module.exports = _pwd; 12 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/sed.js: -------------------------------------------------------------------------------- 1 | var common = require('./common'); 2 | var fs = require('fs'); 3 | 4 | //@ 5 | //@ ### sed([options ,] search_regex, replace_str, file) 6 | //@ Available options: 7 | //@ 8 | //@ + `-i`: Replace contents of 'file' in-place. _Note that no backups will be created!_ 9 | //@ 10 | //@ Examples: 11 | //@ 12 | //@ ```javascript 13 | //@ sed('-i', 'PROGRAM_VERSION', 'v0.1.3', 'source.js'); 14 | //@ sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js'); 15 | //@ ``` 16 | //@ 17 | //@ Reads an input string from `file` and performs a JavaScript `replace()` on the input 18 | //@ using the given search regex and replacement string. Returns the new string after replacement. 19 | function _sed(options, regex, replacement, file) { 20 | options = common.parseOptions(options, { 21 | 'i': 'inplace' 22 | }); 23 | 24 | if (typeof replacement === 'string') 25 | replacement = replacement; // no-op 26 | else if (typeof replacement === 'number') 27 | replacement = replacement.toString(); // fallback 28 | else 29 | common.error('invalid replacement string'); 30 | 31 | if (!file) 32 | common.error('no file given'); 33 | 34 | if (!fs.existsSync(file)) 35 | common.error('no such file or directory: ' + file); 36 | 37 | var result = fs.readFileSync(file, 'utf8').replace(regex, replacement); 38 | if (options.inplace) 39 | fs.writeFileSync(file, result, 'utf8'); 40 | 41 | return common.ShellString(result); 42 | } 43 | module.exports = _sed; 44 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/tempdir.js: -------------------------------------------------------------------------------- 1 | var common = require('./common'); 2 | var os = require('os'); 3 | var fs = require('fs'); 4 | 5 | // Returns false if 'dir' is not a writeable directory, 'dir' otherwise 6 | function writeableDir(dir) { 7 | if (!dir || !fs.existsSync(dir)) 8 | return false; 9 | 10 | if (!fs.statSync(dir).isDirectory()) 11 | return false; 12 | 13 | var testFile = dir+'/'+common.randomFileName(); 14 | try { 15 | fs.writeFileSync(testFile, ' '); 16 | common.unlinkSync(testFile); 17 | return dir; 18 | } catch (e) { 19 | return false; 20 | } 21 | } 22 | 23 | 24 | //@ 25 | //@ ### tempdir() 26 | //@ 27 | //@ Examples: 28 | //@ 29 | //@ ```javascript 30 | //@ var tmp = tempdir(); // "/tmp" for most *nix platforms 31 | //@ ``` 32 | //@ 33 | //@ Searches and returns string containing a writeable, platform-dependent temporary directory. 34 | //@ Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir). 35 | function _tempDir() { 36 | var state = common.state; 37 | if (state.tempDir) 38 | return state.tempDir; // from cache 39 | 40 | state.tempDir = writeableDir(os.tempDir && os.tempDir()) || // node 0.8+ 41 | writeableDir(process.env['TMPDIR']) || 42 | writeableDir(process.env['TEMP']) || 43 | writeableDir(process.env['TMP']) || 44 | writeableDir(process.env['Wimp$ScrapDir']) || // RiscOS 45 | writeableDir('C:\\TEMP') || // Windows 46 | writeableDir('C:\\TMP') || // Windows 47 | writeableDir('\\TEMP') || // Windows 48 | writeableDir('\\TMP') || // Windows 49 | writeableDir('/tmp') || 50 | writeableDir('/var/tmp') || 51 | writeableDir('/usr/tmp') || 52 | writeableDir('.'); // last resort 53 | 54 | return state.tempDir; 55 | } 56 | module.exports = _tempDir; 57 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/test.js: -------------------------------------------------------------------------------- 1 | var common = require('./common'); 2 | var fs = require('fs'); 3 | 4 | //@ 5 | //@ ### test(expression) 6 | //@ Available expression primaries: 7 | //@ 8 | //@ + `'-b', 'path'`: true if path is a block device 9 | //@ + `'-c', 'path'`: true if path is a character device 10 | //@ + `'-d', 'path'`: true if path is a directory 11 | //@ + `'-e', 'path'`: true if path exists 12 | //@ + `'-f', 'path'`: true if path is a regular file 13 | //@ + `'-L', 'path'`: true if path is a symboilc link 14 | //@ + `'-p', 'path'`: true if path is a pipe (FIFO) 15 | //@ + `'-S', 'path'`: true if path is a socket 16 | //@ 17 | //@ Examples: 18 | //@ 19 | //@ ```javascript 20 | //@ if (test('-d', path)) { /* do something with dir */ }; 21 | //@ if (!test('-f', path)) continue; // skip if it's a regular file 22 | //@ ``` 23 | //@ 24 | //@ Evaluates expression using the available primaries and returns corresponding value. 25 | function _test(options, path) { 26 | if (!path) 27 | common.error('no path given'); 28 | 29 | // hack - only works with unary primaries 30 | options = common.parseOptions(options, { 31 | 'b': 'block', 32 | 'c': 'character', 33 | 'd': 'directory', 34 | 'e': 'exists', 35 | 'f': 'file', 36 | 'L': 'link', 37 | 'p': 'pipe', 38 | 'S': 'socket' 39 | }); 40 | 41 | var canInterpret = false; 42 | for (var key in options) 43 | if (options[key] === true) { 44 | canInterpret = true; 45 | break; 46 | } 47 | 48 | if (!canInterpret) 49 | common.error('could not interpret expression'); 50 | 51 | if (options.link) { 52 | try { 53 | return fs.lstatSync(path).isSymbolicLink(); 54 | } catch(e) { 55 | return false; 56 | } 57 | } 58 | 59 | if (!fs.existsSync(path)) 60 | return false; 61 | 62 | if (options.exists) 63 | return true; 64 | 65 | var stats = fs.statSync(path); 66 | 67 | if (options.block) 68 | return stats.isBlockDevice(); 69 | 70 | if (options.character) 71 | return stats.isCharacterDevice(); 72 | 73 | if (options.directory) 74 | return stats.isDirectory(); 75 | 76 | if (options.file) 77 | return stats.isFile(); 78 | 79 | if (options.pipe) 80 | return stats.isFIFO(); 81 | 82 | if (options.socket) 83 | return stats.isSocket(); 84 | } // test 85 | module.exports = _test; 86 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/to.js: -------------------------------------------------------------------------------- 1 | var common = require('./common'); 2 | var fs = require('fs'); 3 | var path = require('path'); 4 | 5 | //@ 6 | //@ ### 'string'.to(file) 7 | //@ 8 | //@ Examples: 9 | //@ 10 | //@ ```javascript 11 | //@ cat('input.txt').to('output.txt'); 12 | //@ ``` 13 | //@ 14 | //@ Analogous to the redirection operator `>` in Unix, but works with JavaScript strings (such as 15 | //@ those returned by `cat`, `grep`, etc). _Like Unix redirections, `to()` will overwrite any existing file!_ 16 | function _to(options, file) { 17 | if (!file) 18 | common.error('wrong arguments'); 19 | 20 | if (!fs.existsSync( path.dirname(file) )) 21 | common.error('no such file or directory: ' + path.dirname(file)); 22 | 23 | try { 24 | fs.writeFileSync(file, this.toString(), 'utf8'); 25 | } catch(e) { 26 | common.error('could not write to file (code '+e.code+'): '+file, true); 27 | } 28 | } 29 | module.exports = _to; 30 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/toEnd.js: -------------------------------------------------------------------------------- 1 | var common = require('./common'); 2 | var fs = require('fs'); 3 | var path = require('path'); 4 | 5 | //@ 6 | //@ ### 'string'.toEnd(file) 7 | //@ 8 | //@ Examples: 9 | //@ 10 | //@ ```javascript 11 | //@ cat('input.txt').toEnd('output.txt'); 12 | //@ ``` 13 | //@ 14 | //@ Analogous to the redirect-and-append operator `>>` in Unix, but works with JavaScript strings (such as 15 | //@ those returned by `cat`, `grep`, etc). 16 | function _toEnd(options, file) { 17 | if (!file) 18 | common.error('wrong arguments'); 19 | 20 | if (!fs.existsSync( path.dirname(file) )) 21 | common.error('no such file or directory: ' + path.dirname(file)); 22 | 23 | try { 24 | fs.appendFileSync(file, this.toString(), 'utf8'); 25 | } catch(e) { 26 | common.error('could not append to file (code '+e.code+'): '+file, true); 27 | } 28 | } 29 | module.exports = _toEnd; 30 | -------------------------------------------------------------------------------- /node_modules/shelljs/src/which.js: -------------------------------------------------------------------------------- 1 | var common = require('./common'); 2 | var fs = require('fs'); 3 | var path = require('path'); 4 | 5 | // Cross-platform method for splitting environment PATH variables 6 | function splitPath(p) { 7 | for (i=1;i<2;i++) {} 8 | 9 | if (!p) 10 | return []; 11 | 12 | if (common.platform === 'win') 13 | return p.split(';'); 14 | else 15 | return p.split(':'); 16 | } 17 | 18 | //@ 19 | //@ ### which(command) 20 | //@ 21 | //@ Examples: 22 | //@ 23 | //@ ```javascript 24 | //@ var nodeExec = which('node'); 25 | //@ ``` 26 | //@ 27 | //@ Searches for `command` in the system's PATH. On Windows looks for `.exe`, `.cmd`, and `.bat` extensions. 28 | //@ Returns string containing the absolute path to the command. 29 | function _which(options, cmd) { 30 | if (!cmd) 31 | common.error('must specify command'); 32 | 33 | var pathEnv = process.env.path || process.env.Path || process.env.PATH, 34 | pathArray = splitPath(pathEnv), 35 | where = null; 36 | 37 | // No relative/absolute paths provided? 38 | if (cmd.search(/\//) === -1) { 39 | // Search for command in PATH 40 | pathArray.forEach(function(dir) { 41 | if (where) 42 | return; // already found it 43 | 44 | var attempt = path.resolve(dir + '/' + cmd); 45 | if (fs.existsSync(attempt)) { 46 | where = attempt; 47 | return; 48 | } 49 | 50 | if (common.platform === 'win') { 51 | var baseAttempt = attempt; 52 | attempt = baseAttempt + '.exe'; 53 | if (fs.existsSync(attempt)) { 54 | where = attempt; 55 | return; 56 | } 57 | attempt = baseAttempt + '.cmd'; 58 | if (fs.existsSync(attempt)) { 59 | where = attempt; 60 | return; 61 | } 62 | attempt = baseAttempt + '.bat'; 63 | if (fs.existsSync(attempt)) { 64 | where = attempt; 65 | return; 66 | } 67 | } // if 'win' 68 | }); 69 | } 70 | 71 | // Command not found anywhere? 72 | if (!fs.existsSync(cmd) && !where) 73 | return null; 74 | 75 | where = where || path.resolve(cmd); 76 | 77 | return common.ShellString(where); 78 | } 79 | module.exports = _which; 80 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cordova-ubuntu", 3 | "version": "4.3.5", 4 | "description": "Cordova tooling for the Ubuntu platform.", 5 | "main": "bin/create", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/apache/cordova-ubuntu" 9 | }, 10 | "engineStrict": "true", 11 | "engines": { 12 | "node": ">=0.10.0" 13 | }, 14 | "dependencies": { 15 | "colors": "0.6.2", 16 | "optimist": "0.6.0", 17 | "q": "2.0.*", 18 | "shelljs": "0.2.6", 19 | "elementtree": "*" 20 | }, 21 | "bundledDependencies": [ 22 | "colors", 23 | "optimist", 24 | "q", 25 | "shelljs", 26 | "elementtree" 27 | ], 28 | "keywords": [ 29 | "ubuntu", 30 | "cordova", 31 | "apache" 32 | ], 33 | "author": "Apache Software Foundation", 34 | "contributors": [ 35 | { 36 | "name": "Maxim Ermilov", 37 | "email": "maxim.ermilov@canonical.com" 38 | }, 39 | { 40 | "name": "Jean-Francois Moy", 41 | "email": "jean-francois.moy@canonical.com" 42 | }, 43 | { 44 | "name": "David Barth", 45 | "email": "david.barth@canonical.com" 46 | } 47 | ], 48 | "license": "Apache Version 2.0" 49 | } 50 | -------------------------------------------------------------------------------- /qml/CordovaView.qml.in: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2013 Canonical Ltd. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | * 18 | */ 19 | import QtQuick 2.2 20 | import CordovaUbuntu @VERSION@ 21 | 22 | Item { 23 | id: root 24 | property string wwwDir 25 | 26 | property var mainWebview 27 | property var cordovaObject: cordova 28 | 29 | Cordova { 30 | id: cordova 31 | wwwDir: root.wwwDir 32 | } 33 | Image { 34 | id: splashscreen 35 | anchors.fill: parent 36 | } 37 | Loader { 38 | id: loader 39 | asynchronous: true 40 | visible: false 41 | anchors.fill: parent 42 | 43 | onLoaded: { 44 | root.mainWebview = loader.item.mainWebview 45 | cordova.parent = loader.item 46 | 47 | loader.item.completed.connect(function() { 48 | if (cordova.config().orientation() == 0) { 49 | loader.item.automaticOrientation = true 50 | } else { 51 | loader.item.automaticOrientation = true 52 | if (cordova.config().orientation() == 1) 53 | loader.item.orientationAngle = 90 54 | else 55 | loader.item.orientationAngle = 0 56 | } 57 | 58 | loader.item.visible = true 59 | loader.visible = true 60 | splashscreen.visible = false 61 | }); 62 | } 63 | } 64 | Component.onCompleted: { 65 | splashscreen.source = cordova.getSplashscreenPath() 66 | loader.source = "CordovaViewInternal.qml" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /qml/main.qml.in: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2013 Canonical Ltd. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | * 18 | */ 19 | import QtQuick 2.2 20 | import QtQuick.Window 2.1 21 | import CordovaUbuntu @VERSION@ 22 | import Ubuntu.Components 1.1 23 | 24 | Window { 25 | visibility: view.cordovaObject.config().fullscreen() ? Window.FullScreen : Window.AutomaticVisibility 26 | visible: true 27 | width: 560 28 | height: 896 29 | CordovaView { 30 | objectName: "cordovaView" 31 | width: parent.width 32 | height: parent.height 33 | wwwDir: www 34 | id: view 35 | Component.onCompleted: { 36 | UbuntuApplication.applicationName = view.cordovaObject.config().appId() 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/cordova.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Canonical Ltd. 3 | * Copyright 2011 Wolfgang Koller - http://www.gofg.at/ 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef CORDOVA_H_DJJKASDM44 19 | #define CORDOVA_H_DJJKASDM44 20 | 21 | #include 22 | #include 23 | 24 | #include "cplugin.h" 25 | #include "cordova_config.hpp" 26 | 27 | class QQuickView; 28 | class QQuickItem; 29 | 30 | class Cordova: public QObject { 31 | Q_OBJECT 32 | Q_PROPERTY(QString mainUrl READ mainUrl CONSTANT) 33 | 34 | public: 35 | explicit Cordova(const QDir &wwwDir, QQuickItem *item, QObject *parent = nullptr); 36 | 37 | QString mainUrl() const; 38 | QObject *topLevelEventsReceiver(); 39 | QQuickItem *rootObject(); 40 | QString get_app_dir(); 41 | 42 | void pushViewState(const QString &state); 43 | void popViewState(const QString &state); 44 | QString getSplashscreenPath(); 45 | 46 | const CordovaInternal::Config& config() const; 47 | 48 | template 49 | QSharedPointer getPlugin() { 50 | for (QSharedPointer &plugin: _plugins) { 51 | if (plugin->fullName() != A::fullID()) 52 | continue; 53 | return plugin; 54 | } 55 | 56 | return QSharedPointer(); 57 | } 58 | signals: 59 | void javaScriptExecNeeded(const QString &js); 60 | void qmlExecNeeded(const QString &src); 61 | void pluginWantsToBeAdded(const QString &pluginName, QObject *pluginObject, const QString &pluginShortName); 62 | 63 | public slots: 64 | void loadFinished(bool ok); 65 | void execJS(const QString &js); 66 | void setTitle(const QString &title); 67 | void execQML(const QString &src); 68 | void appLoaded(); 69 | 70 | private: 71 | void initPlugins(); 72 | 73 | QQuickItem *_item; 74 | QList> _plugins; 75 | 76 | QDir _www; 77 | QString _mainUrl; 78 | QList _states; 79 | CordovaInternal::Config _config; 80 | 81 | Q_DISABLE_COPY(Cordova) 82 | }; 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /src/cordova_config.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Canonical Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORDOVA_CONFIG_NMNMREQW525252 18 | #define CORDOVA_CONFIG_NMNMREQW525252 19 | 20 | #include 21 | #include "cordova_whitelist.hpp" 22 | 23 | namespace CordovaInternal { 24 | class Config: public QObject { 25 | Q_OBJECT 26 | public: 27 | enum Orientation { 28 | DEFAULT_ORIENTATION = 0, 29 | LANDSCAPE = 1, 30 | PORTRAIT = 2 31 | }; 32 | 33 | explicit Config(const QString &xmlConfig); 34 | 35 | const WhiteList& whitelist() const; 36 | const QString& content() const; 37 | 38 | Q_INVOKABLE QString appId() const; 39 | Q_INVOKABLE QString appVersion() const; 40 | 41 | bool disallowOverscroll() const; 42 | Q_INVOKABLE bool fullscreen() const; 43 | 44 | Q_INVOKABLE int orientation() const; 45 | private: 46 | WhiteList _whitelist; 47 | QString _content; 48 | QString _appId, _appVersion; 49 | bool _fullscreen, _disallowOverscroll; 50 | 51 | Orientation _orientation; 52 | 53 | Q_DISABLE_COPY(Config); 54 | }; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/cordova_whitelist.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Canonical Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORDOVA_WHITELIST_HKJBNNBNM53452 18 | #define CORDOVA_WHITELIST_HKJBNNBNM53452 19 | 20 | #include 21 | 22 | // ported from https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/Whitelist.java 23 | namespace CordovaInternal { 24 | class WhiteList { 25 | public: 26 | WhiteList(); 27 | 28 | bool isUrlWhiteListed(const QString &uri) const; 29 | void addWhiteListEntry(const QString &origin, bool subdomains); 30 | private: 31 | class URLPattern { 32 | public: 33 | URLPattern(const QString &scheme, const QString &host, 34 | const QString &port, const QString &path); 35 | bool matches(QUrl uri) const; 36 | 37 | private: 38 | QString regexFromPattern(const QString &pattern, bool allowWildcards) const; 39 | QRegExp _scheme, _host, _path; 40 | int _port; 41 | }; 42 | 43 | QList _whiteList; 44 | bool _unlimited, _empty; 45 | Q_DISABLE_COPY(WhiteList); 46 | }; 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/coreplugins.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2013 Canonical Ltd. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | * 18 | */ 19 | #include 20 | #include "cplugin.h" 21 | #include "coreplugins.h" 22 | INSERT_HEADER_HERE 23 | 24 | #define INIT_PLUGIN(class) \ 25 | res.prepend(QSharedPointer(new class(cordova))); \ 26 | 27 | extern "C" { 28 | 29 | Q_DECL_EXPORT QList> cordovaGetPluginInstances(Cordova *cordova) { 30 | Q_UNUSED(cordova); 31 | QList> res; 32 | 33 | INSERT_PLUGIN_HERE 34 | 35 | return res; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/coreplugins.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2013 Canonical Ltd. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | * 18 | */ 19 | #define INSERT_HEADER_HERE 20 | #define INSERT_PLUGIN_HERE 21 | -------------------------------------------------------------------------------- /src/plugins/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-ubuntu/1097b7fad0ae46d3d5fae1f9f3667784859ba4a2/src/plugins/empty -------------------------------------------------------------------------------- /src/qmlplugin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2013 Canonical Ltd. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | * KIND, either express or implied. See the License for the 15 | * specific language governing permissions and limitations 16 | * under the License. 17 | * 18 | */ 19 | #include "qmlplugin.h" 20 | 21 | void CordovaUbuntuPlugin::registerTypes(const char *) { 22 | qmlRegisterType("CordovaUbuntu", CORDOVA_UBUNTU_MAJOR_VERSION, CORDOVA_UBUNTU_MINOR_VERSION, "Cordova"); 23 | qmlRegisterUncreatableType("CordovaUbuntu", CORDOVA_UBUNTU_MAJOR_VERSION, CORDOVA_UBUNTU_MINOR_VERSION, "Config", "..."); 24 | } 25 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | 21 | cmake_minimum_required(VERSION 2.8.8) 22 | 23 | project(cordova-ubuntu-tests) 24 | 25 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 26 | set(CMAKE_AUTOMOC ON) 27 | 28 | SET(CMAKE_CXX_FLAGS "-std=c++11 -fno-omit-frame-pointer -Wall -Wextra") 29 | 30 | enable_testing() 31 | 32 | find_package(GTest REQUIRED) 33 | find_package(Qt5Widgets) 34 | find_package(Qt5Core) 35 | 36 | include_directories(${GTEST_INCLUDE_DIR}) 37 | 38 | add_subdirectory(../ cordova_ubuntu) 39 | 40 | add_executable(main 41 | main.cpp 42 | ) 43 | qt5_use_modules(main Quick Xml Widgets Core) 44 | target_link_libraries(main gtest pthread coreplugins cordovaubuntuplugin) 45 | 46 | add_test(Main main) 47 | -------------------------------------------------------------------------------- /tests/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 23 | Hello Cordova 24 | 25 | 26 | A sample Apache Cordova application that responds to the deviceready event. 27 | 28 | 29 | 30 | Apache Cordova Team 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 45 | 46 | -------------------------------------------------------------------------------- /tests/data/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 23 | Hello Cordova 24 | 25 | 26 | A sample Apache Cordova application that responds to the deviceready event. 27 | 28 | 29 | 30 | Apache Cordova Team 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 45 | 46 | -------------------------------------------------------------------------------- /tests/data/www/index.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/www/.touch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-ubuntu/1097b7fad0ae46d3d5fae1f9f3667784859ba4a2/tests/www/.touch -------------------------------------------------------------------------------- /xml/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 23 | Hello Cordova 24 | 25 | 26 | A sample Apache Cordova application that responds to the deviceready event. 27 | 28 | 29 | 30 | Apache Cordova Team 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 46 | 47 | --------------------------------------------------------------------------------