├── .biddlerc ├── .gitignore ├── .gitmodules ├── LICENSE ├── applications └── readme.md ├── appveyor.yml ├── biddle.js ├── bin └── biddle ├── cmd └── biddle.cmd ├── documentation ├── documentation.md ├── gettingstarted.md └── package.md ├── downloads └── readme.md ├── installed.json ├── package.json ├── publications └── readme.md ├── published.json ├── readme.md ├── test ├── biddletesta │ ├── READMEa.md │ ├── biddletesta.js │ ├── liba │ │ ├── libaa.txt │ │ ├── libab.txt │ │ └── libac.txt │ ├── package.json │ └── testa │ │ ├── testaa.txt │ │ ├── testab.txt │ │ └── testac.txt └── biddletestb │ ├── .biddlerc │ ├── READMEb.md │ ├── biddletestb.js │ ├── libb │ ├── libba.txt │ ├── libbb.txt │ └── libbc.txt │ ├── package.json │ └── testb │ ├── testba.txt │ ├── testbb.txt │ └── testbc.txt └── today.js /.biddlerc: -------------------------------------------------------------------------------- 1 | { 2 | "directories": { 3 | "applications": "applications", 4 | "downloads" : "downloads", 5 | "publications": "publications" 6 | }, 7 | "exclusions" : [ 8 | ".DC_Store", 9 | "._DC_Store", 10 | ".git", 11 | ".gitmodules", 12 | "internal", 13 | "node_modules" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | today.js 2 | internal -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "applications/prettydiff/JSLint"] 2 | path = applications/prettydiff/JSLint 3 | url = https://github.com/douglascrockford/JSLint.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Austin Cheney 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /applications/readme.md: -------------------------------------------------------------------------------- 1 | # biddle - applications 2 | 3 | This directory is the default location packages fetched and installed by biddle. 4 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | 2 | # Install scripts. (runs after repo cloning) 3 | install: 4 | # Get the latest stable version of Node.js or io.js 5 | - ps: Install-Product node 6 | 7 | # Post-install test scripts. 8 | test_script: 9 | # Output useful info for debugging. 10 | - node --version 11 | - node biddle test 12 | 13 | # Don't actually build. 14 | build: off 15 | -------------------------------------------------------------------------------- /bin/biddle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require("../biddle.js"); 3 | -------------------------------------------------------------------------------- /cmd/biddle.cmd: -------------------------------------------------------------------------------- 1 | @IF EXIST "%~dp0\node.exe" ( 2 | "%~dp0\node.exe" "%~dp0\..\bin\biddle" %* 3 | ) ELSE ( 4 | node "%~dp0\..\bin\biddle" %* 5 | ) 6 | -------------------------------------------------------------------------------- /documentation/documentation.md: -------------------------------------------------------------------------------- 1 | # biddle, Documentation 2 | 3 | ## Commands 4 | 5 | ### Command Definitions and Examples 6 | For definitions and usage examples please see the [readme.md](../readme.md) file. 7 | 8 | ### Command Overview 9 | biddle operates with the convention: `biddle command argument1 argument2` 10 | 11 | The following table describes which commands require arguments and which commands run locally without a network connection. Commands with a "?" in the *Local* column are commands that will access the internet if provided a web address as an argument while commands with a "✓" will not access the internet. A second argument is required for the **copy** command and either optional or unused for all other commands. 12 | 13 | Command|Local|Argument Type|Second Argument 14 | ---|---|---|--- 15 | commands|✓|none|none 16 | copy|✓|local file system address|directory path 17 | get|?|local or web address|directory path 18 | global|✓|application name|none or "*remove*" 19 | hash|✓|file path or "*string*"|string value 20 | help|✓|number|none 21 | install|?|zip file address (local or web)|directory path 22 | list|✓|"*installed*" or "*published*"|none 23 | markdown|✓|path to markdown file|number 24 | publish|✓|directory path|directory path 25 | remove|✓|local file system address|none 26 | status|?|none or application name|none 27 | test|?|application name|none 28 | uninstall|✓|application name|none 29 | unpublish|✓|application name|"*all*" or "*latest*" or version 30 | unzip|✓|path to zip file|directory path 31 | update|✓|application name|none 32 | version|✓|none or installed app name|none 33 | zip|✓|local file system address|directory path 34 | 35 | ### cmds Object 36 | Some biddle commands require OS specific actions. For instance the commands to recursively delete a directory tree or zip a file differ by operating system. Many of these simple operations are required for the primary publication and installation tasks and are provided directly as a convenience. 37 | 38 | These commands are found in the **cmds** object in biddle.js near the top of the file. 39 | 40 | ## .biddlerc File 41 | An application may contain a file named *.biddlerc* to serve as a preset. This file will contain JSON in this format: 42 | ``` 43 | { 44 | "directories": { 45 | "applications": "applications", 46 | "downloads" : "downloads", 47 | "publications": "publications" 48 | }, 49 | "exclusions" : [ 50 | "file", "file", "directory" 51 | ] 52 | } 53 | ``` 54 | There are two key properties supported in the *.biddlerc* file: *directories* and *exclusions*. The *directories* object allows application specific defaults to be defined for the three directories that biddle will write to. The addresses are relative to the application directory and absolute addresses are also supported. The *exclusions* object allows an application specific list of files or directories to exclude when running the **publish** command. 55 | 56 | ## Publication and the published.json File 57 | The published.json file stores data on applications published by biddle with the following schema: 58 | 59 | { 60 | "applicationName": { 61 | "directory": "path/to/application", 62 | "latest" : "latestVersion", 63 | "versions" : [ 64 | "oldest version", "older version", "version string", "latest version" 65 | ] 66 | } 67 | } 68 | 69 | ### Naming Conflicts 70 | If an application is published with the same name an version as a previously published application biddle with throw an error. If an application is published with the same name as an existing application it will be installed to the same location as the existing application. If a new location is desired first unpublish the application and then publish it to the desired location. 71 | 72 | Since applications are stored by name an application of a given name may only exist once in biddle. Should a name conflict arise a possible solution is to run multiple instances of biddle for different types of applications. With biddle there isn't any central repository so another solution is to simply rename an application to something unique prior to publication. 73 | 74 | ### Directory 75 | The default publication point is the *publications* directory in biddle. An application may be published to any location permitted by the operating system. The published location is stored as the *directory* property in the published.json file. 76 | 77 | ### Versions 78 | Versions in biddle are completely free form. [SemVer](http://semver.org/) is strongly encouraged, but any string is accepted. 79 | 80 | ### Latest Version 81 | In addition to publishing a specified version of an application biddle will also create a *latest* version in the following criteria is met: 82 | 83 | * The current version is the first publication 84 | * larger than the immediately preceding version where larger means sorts lower after a JavaScript string sort. 85 | 86 | ## Installation and the installed.json File 87 | The published.json file stores data on applications published by biddle with the following schema: 88 | 89 | { 90 | "applicationName": { 91 | "location" : "path/to/application", 92 | "published": "address/of/publication", 93 | "variant" : "", 94 | "version" : "currentVersion" 95 | } 96 | } 97 | 98 | The data is similar to the data stored in published.json, but more simple. This data only associates a single version to an application and provides an address to retrieved zip file's directory in the *published* property. The published property is always an absolute path whether a web address or path on the local file system. The variant property determines the name of the installed application's variant so that the application can be updated according to this variant instead of the default flavor. The variant property is empty if the application's main version is installed. 99 | 100 | ### Naming Conflicts 101 | Naming conflicts may occur in exactly the same way as described for publications for the same reasons. 102 | 103 | ## Managing Applications 104 | biddle provides two commands to help manage applications: **list** and **status**. 105 | 106 | ### list Command 107 | The **list** command will indicate locally available applications by either publication, installation, or both. These lists include the application name, its latest published version or currently installed version, and the directory where the application is installed or published to. Although biddle can unpublish or uninstall applications from any location on the local file system printing the applications address is informative from a system management perspective. 108 | 109 | ### status Command 110 | The **status** command determines if installed applications are outdated compared to the published version. This command reaches out to the publication point indicated by the *published* property in the installed.json file, which could result in a network call if the publication point is a point on the web. 111 | 112 | ### test Command 113 | The **test** command spawns a child process to run an application's user acceptance tests from the command line. Although the command is run in a child process the output is returned to the current terminal as its generated. This is handy to verify the health and acceptance of an application before installing it or executing it. 114 | 115 | ## File Conventions 116 | The **publish** command writes files in addition to the necessary zip archive files. For every zip file written by the publish command a hash file of the same file name is also written. These file names, excluding the zip and hash file extensions, must remain the same or the **install** command will not unzip the zip file. 117 | 118 | If the *publication_variants* property is properly populated in an application's package.json file additional zip and hash files will also be written. Please see the [package.md](package.md) file for comprehensive information of *publication_variants*. 119 | 120 | If a the application qualifies as a latest publication copies of the zip and hash files from this published version will be written, or overwritten if already present, containing the word *latest* in the filename in place of the version. A text file will also be written, or overwritten if already present, named *latest.txt* containing only the version string. The latest.txt file is required for successful operation of the **status** command. For examples and more details please see [gettingstarted.md](gettingstarted.md). 121 | 122 | An application qualifies for latest status under the following conditions: 123 | 124 | * The application is published for the first time. 125 | * The version string is greater than the prior version string, based upon JavaScript string comparison logic, and does not contain the words *alpha* or *beta*. 126 | 127 | ## Global Installation Requirements 128 | 129 | ### bin File 130 | An application must have a bin file named `bin\myApplicationName`. The *myApplicationName* file has no file extension and should be named exactly like the application's parent directory, for example: *prettydiff/bin/prettydiff*. This file contains two things: 131 | 132 | 1. A shebang statement 133 | 2. A single execution instruction 134 | 135 | An example of the file used by biddle: 136 | 137 | #!/usr/bin/env node 138 | require("../biddle.js"); 139 | 140 | The shebang statement is only used by POSIX systems. This statement defines the environment to execute the application. biddle is not capable of writing the bin file automatically as it cannot guess at an applications execution environment. In the example shebang statement the executing environment is Node.js. 141 | 142 | The second line of code refers to the execution instruction, which in the biddle example tells Node.js to execute a file in the parent directory named biddle.js. 143 | 144 | ### Windows Execution 145 | Windows requires a file named `cmd\index.cmd`. This file allows command line execution of an application file that isn't a ".exe" file. The cmd file will point to the application's bin file and define the executing environment for the given application. Here is an example used by biddle where the environment is Node.js. 146 | 147 | @IF EXIST "%~dp0\node.exe" ( 148 | "%~dp0\node.exe" "..\bin\index" %* 149 | ) ELSE ( 150 | node "..\bin\index" %* 151 | ) 152 | 153 | Windows requires execution of the global command from an administrative terminal. biddle cannot tell if it is executing in an administrative terminal and so it is not removed from the Windows path during the **uninstall** command. In Windows applications must be removed from the path with the global command before the application is uninstalled. 154 | 155 | biddle global myApplicationName remove 156 | 157 | ### POSIX Execution 158 | If an application is uninstalled by biddle it will be removed from the PATH environmental variable automatically. Otherwise it will require a separate prior step to remove the application from the PATH. 159 | 160 | Examples: 161 | 162 | biddle uninstall myApplication 163 | 164 | or 165 | 166 | biddle global myApplication remove 167 | 168 | ### Restarting the Terminal 169 | Once the **global** command is executed the result is not available until the terminal is restarted. In POSIX systems biddle will output a command that, if executed, will allow immediate global availability of the application. 170 | -------------------------------------------------------------------------------- /documentation/gettingstarted.md: -------------------------------------------------------------------------------- 1 | # biddle, Getting Started 2 | 3 | ## Getting set up 4 | First thing is to get a copy of biddle, so let's download from Github 5 | 6 | git clone git@github.com:prettydiff/biddle.git 7 | cd biddle 8 | 9 | Let's add biddle to the system path so that we can run it from any directory on the file system. 10 | 11 | node biddle global 12 | 13 | ## Publish an application 14 | We need to publish an application to have something to play with. Biddle comes with two mock applications for running tests, so will use one of those. 15 | 16 | biddle publish test/biddletesta 17 | 18 | When we publish a new application a directory reflective of the application's name is written to the default location, which is the provided *publications* directory. Let's move into this published application directory to see what we have. 19 | 20 | cd publications/biddletesta 21 | 22 | You should see the following list of files: 23 | 24 | * biddletesta_99.99.1234.hash 25 | * biddletesta_99.99.1234.zip 26 | * biddletesta_latest.hash 27 | * biddletesta_latest.zip 28 | * biddletesta_min_99.99.1234.hash 29 | * biddletesta_min_99.99.1234.zip 30 | * biddletesta_min_latest.hash 31 | * biddletesta_min_latest.zip 32 | * biddletesta_prod_99.99.1234.hash 33 | * biddletesta_prod_99.99.1234.zip 34 | * biddletesta_prod_latest.hash 35 | * biddletesta_prod_latest.zip 36 | * latest.txt 37 | 38 | ## A brief explanation of publish 39 | By default the **publish** command will generate five files with the convention myAppName_version.zip, myAppName_version.hash, myAppName_latest.zip, myAppName_latest.hash, and latest.txt. For every zip file created a hash file is created with the same file name. If the version is the first publication or later than prior publications the files with *latest* (intead of *version*) are written. The latest named files are created as a convenience for users who want access to the newest updates without having to keep track of version details. Finally, the file *latest.txt* is written if the version is the latest version, which contains the version string. The *latest.txt* file is necessary for the **status** command. 40 | 41 | If by default the **publish** command writes 5 files then what are all those other files in the biddletesta directory? biddle supports a convention called *variants* where different forms of an application can be generated. These instructions are provided in the application's package.json file. See [package.json](package.md) for more information. 42 | 43 | ## Install an application 44 | Now that an application is published let's install from it. 45 | 46 | biddle install publications/biddletesta/biddletesta_latest.zip 47 | 48 | Install will to see if the provided path starts with *http* or *https* and if so will download the zip (and its hash file) from the internet. If not the **install** command will assume the path is to a file stored on the local file system and attempt to resolve the local path. 49 | 50 | Between getting the zip file and unzipping its contents biddle will run a hash of the file and compare it to the hash sequence provided in the requested hash file. If the hashes are a match the application is unzipped and installed. If the hashes don't match the zip file is stored in biddle's *downloads* directory so that the user can decide the next course of action. 51 | 52 | By default applications will be installed to biddle's *applications* directory. The installation location can be customized by specifying a parent directory location as the next argument. 53 | 54 | biddle install publications/biddletesta/biddletesta_latest.zip /myApps 55 | 56 | ## Test an application 57 | Before we run the application let's execute its acceptance tests to determine if the application works as expected. 58 | 59 | biddle test biddletesta 60 | 61 | ## Read the markdown 62 | It would be handy if we could read about the application without leaving the terminal. Fortunately, biddle includes a markdown parser and formatter for the command line interface. 63 | 64 | biddle markdown applications/biddletesta/READMEa.md 65 | 66 | ## List applications 67 | It is handy to know what applications are present, so let's generate a list of installed applications. 68 | 69 | biddle list installed 70 | 71 | We can also list the published applications. 72 | 73 | biddle list published 74 | 75 | Sometimes it is just more convenient to get a list of both the installed and published applications. 76 | 77 | biddle list 78 | 79 | ## Check application status 80 | We know the application is the latest version because its a dummy application it hasn't been modified, but bear with me. Let's check the status anyways. 81 | 82 | biddle status biddletesta 83 | 84 | If there were multiple applications installed we could get a complete status list by excluding the application name. 85 | 86 | biddle status 87 | 88 | ## Uninstall an application 89 | Our quick tour is coming to an end, so let's clean up our installed application. 90 | 91 | biddle uninstall biddletesta 92 | 93 | To uninstall an application only the application name is necessary. biddle knows where the application was installed, even if a custom installation location was specified. 94 | 95 | The application directory is deleted and the application is deleted from the *installed.json* file, which is the source of truth for all installed applications. 96 | 97 | ## Unpublish an application 98 | These steps will read like deja vu following the uninstall process. 99 | 100 | biddle unpublish biddletesta 101 | 102 | The unpublish command will delete the published application directory and delete the concerned data from the *published.json* file. 103 | -------------------------------------------------------------------------------- /documentation/package.md: -------------------------------------------------------------------------------- 1 | # biddle, package.json 2 | 3 | ## Required 4 | A package.json file is required for publication and installation support by biddle. This file must be saved in the root directory of the application with the filename *package.json*. 5 | 6 | ## Mandatory Fields 7 | 8 | * *name* - The name field must be a string of greater than 0 length. This is the name of the application. This value should be file system safe for all common file systems. If this value is not file system safe biddle will transform this value into something that is safer, which could result in a conflict if an application exists locally or is requested via the *install* command with this safer name. 9 | * *version* - The version field must be a string of greater than 0 length. 10 | - The *publish* command will throw an error if the application already exists with this name and version. 11 | - The *install* command will throw an error if the currently installed application is of this same version. 12 | - The *publish* command will not produce a **latest** named archive if the current version contains *alpha* or *beta*. 13 | - There are no other rules. Style your versions as random gibberish if you wish. 14 | 15 | ## Optionally Supported Fields 16 | * *test* - A string value representing a command line instruction for running an application's user acceptance tests via the **test** command. 17 | * *publication_variants* - The variants field must be an object. The variants allow custom alternate publications of an application. 18 | - Each property name in this object becomes part of a variant file name. For example an application named *myApp* at version *1.2.3* with a variant named *production* would produce files named: 19 | * myApp_1.2.3.hash 20 | * myApp_1.2.3.zip 21 | * myApp_production_1.2.3.hash 22 | * myApp_production_1.2.3.zip 23 | - Each property in the publication_variants object must be assigned to a child object containing one or both properties: 24 | * *exclusions* - An array of files or directories to delete from the application variant 25 | * *tasks* - An array of command line tasks to execute in synchronous order 26 | - Example: 27 | 28 | ``` 29 | "publication_variants": { 30 | "min" : { 31 | "exclusions": [ 32 | "libb", "testb" 33 | ], 34 | "tasks" : ["prettydiff minify myApp/lib"] 35 | }, 36 | "production": { 37 | "exclusions": ["testb"] 38 | } 39 | } 40 | ``` 41 | 42 | ## Recommended Fields 43 | Although additional data fields are not currently consumed by biddle some additional data is recommended. Support for this data may be added to biddle at a later time. 44 | 45 | * *date* - A date field indicating the date of latest publication is recommended. I prefer the format yyyymmdd as it increments from the largest and least precise unit to the most precise unit to form a single number unique to a given day. Version data is often hard for users to keep track of, but dates tend to be much easier. More so if the dates the follow a single format. 46 | * *description* - A verbose and descriptive explanation is helpful once many applications are installed. Forgetting the purpose of a given application is easy when there are many application's installed. 47 | * *repository* - When applications are working to encourage open source participation announcing the application's code repository is helpful. 48 | * *contact* - A contact point allows users to engage with application maintainers. This could be anything from an email address to the address of a bug tracking system. 49 | -------------------------------------------------------------------------------- /downloads/readme.md: -------------------------------------------------------------------------------- 1 | # biddle - downloads 2 | 3 | This directory is the default location for files fetched by the biddle `get` command. 4 | -------------------------------------------------------------------------------- /installed.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": { 3 | "email": "info@prettydiff.com", 4 | "name": "Austin Cheney", 5 | "url": "http://prettydiff.com/" 6 | }, 7 | "bin": "./bin/biddle", 8 | "bugs": { 9 | "email": "info@prettydiff.com", 10 | "url": "https://github.com/prettydiff/biddle/issues" 11 | }, 12 | "description": "Self-hosted application management and distribution. Package management owned by the developer.", 13 | "homepage": "http://prettydiff.com/", 14 | "keywords": [ 15 | "biddle", 16 | "test" 17 | ], 18 | "license": "MIT", 19 | "main": "biddle.js", 20 | "maintainers": [{ 21 | "email": "info@prettydiff.com", 22 | "name": "austincheney" 23 | }], 24 | "name": "biddle", 25 | "repository": { 26 | "type": "git", 27 | "url": "https://github.com/prettydiff/biddle" 28 | }, 29 | "version": "1.1.7" 30 | } 31 | -------------------------------------------------------------------------------- /publications/readme.md: -------------------------------------------------------------------------------- 1 | # biddle - publications 2 | 3 | This directory is the default location for files fetched by the biddle `publish` command. 4 | -------------------------------------------------------------------------------- /published.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # biddle 2 | *A package management application without a package management service.* 3 | 4 | ## License 5 | [MIT](https://opensource.org/licenses/MIT) 6 | 7 | ## Version 8 | 1.1.7 [![Build Status Image](https://semaphoreci.com/api/v1/prettydiff/biddle/branches/master/badge.svg)](https://semaphoreci.com/prettydiff/biddle) [![AppVeyor Build](https://ci.appveyor.com/api/projects/status/github/prettydiff/biddle?branch=master&svg=true)](https://ci.appveyor.com/project/prettydiff/biddle) 9 | [![NSP Status](https://nodesecurity.io/orgs/prettydiff/projects/dd20fc59-e9b4-4ff0-818e-e322a68811bf/badge)](https://nodesecurity.io/orgs/prettydiff/projects/dd20fc59-e9b4-4ff0-818e-e322a68811bf) 10 | 11 | ## About 12 | This application is a cross-OS solution to creating zip files for distribution and fetching files via HTTP(S). The project's goal is to provide a universal application distribution utility that is language agnostic, operating system independent, and platform independent. The only additional requirement for distributing application packages is online storage on a web server. This application provides all the utilities to retrieve, bundle, and unpackage applications. 13 | 14 | Watch the [video demo](https://asciinema.org/a/118428). 15 | 16 | biddle is inspired by the incredible awesomeness of [NPM](http://npmjs.com), but seeks to accomplish a few additional goals: 17 | 18 | * *integrity* - Downloaded packages will perform a hash comparison before they are unpackaged. If the hashes don't match the zip file will be saved in the downloads directory awaiting a human touch. 19 | * *autonomy* - Be freed from censorship. There is no central authority here. Host your own publications and manage them as you please from any location and with any name or content you choose. 20 | * *privacy* - Put biddle behind your firewall or an isolated environment to prevent public access to your applications and data. 21 | * *management* - There is no dependency hell here. Dependency management will not be automated, but a means to manage and review the status of all installed/published packages is provided. 22 | * *freedom* - biddle will work everywhere Node.js runs. It can be used with any application written in any language whether binary or text. 23 | 24 | ## Documentation 25 | * [Getting Started](documentation/gettingstarted.md) 26 | * [package.json](documentation/package.md) 27 | * [Documentation](documentation/documentation.md) 28 | 29 | ## Supported commands 30 | Commands are the third command line argument, or second if the *node* argument is absent. Commands are case insensitive, but values and local paths are case sensitive. All local address are either absolute from the root or relative from the current working directory. 31 | 32 | ### commands 33 | Conveniently lists the supported commands with a brief description. 34 | 35 | node biddle commands 36 | 37 | ### copy 38 | Copy files or directories to a different directory. 39 | 40 | node biddle copy myFile myOtherDirectory 41 | node biddle copy myDirectory myOtherDirectory 42 | 43 | ### get 44 | Merely downloads the requested resource and saves it as a file with the same filename. If the filename is not provided in the URI the final directory up to the domain name will become the filename, and if for some reason that doesn't work the default filename is *download.xxx*. 45 | 46 | Download a file to the default location, which is the provided *downloads* directory. 47 | 48 | node biddle get http://google.com 49 | 50 | Download a file to an alternate location. 51 | 52 | node biddle get http://google.com ../mydirectory 53 | 54 | ### global 55 | The global command adds an applications's path to the OS path variable so that the application can be run from any location as a command, for example: `biddle help` from root instead of `node biddle help` from the local biddle directory. Use the `remove` option to remove biddle from the path. This command requires use of an administrative console in Windows. For additional requirements see section **Global Application Requirements** in the [documentation](documentation/documentation.md). 56 | 57 | Allowing global availability to biddle. 58 | 59 | node biddle global 60 | 61 | Allowing global availability to any other application installed by biddle. 62 | 63 | biddle global myApplication 64 | 65 | Removing global availability to biddle. 66 | 67 | biddle global remove 68 | 69 | Removing global availability to any other application installed by biddle. 70 | 71 | biddle global myApplication remove 72 | 73 | ### hash 74 | Prints to console a SHA512 hash against a local file. 75 | 76 | node biddle hash downloads/myfile.zip 77 | 78 | Hash a string by indicating *string* and a value instead of a file path. 79 | 80 | node biddle hash string "my string value" 81 | 82 | ### help 83 | Prints the readme.md file contents to console in a human friendly way. 84 | 85 | No command will still generate the readme data. 86 | 87 | node biddle 88 | 89 | The default word wrapping is set to 100 characters. 90 | 91 | node biddle help 92 | 93 | Set a custom word wrap limit. 94 | 95 | node biddle help 80 96 | 97 | ### install 98 | Downloads the requested zip file, but performs a hash comparison before unzipping the file. 99 | 100 | node biddle install http://example.com/downloads/application_latest.zip 101 | 102 | ### list 103 | Will list all installed and/or published applications with their locations and latest versions. It can take the optional argument *installed* or *published* to output a specific list or both lists are produced. 104 | 105 | Only output the installed list. 106 | 107 | node biddle list installed 108 | 109 | Only output the published list. 110 | 111 | node biddle list published 112 | 113 | Output both lists 114 | 115 | node biddle list 116 | 117 | ### markdown 118 | Allows the internal markdown parser used by the **help** command to be supplied to a directed file to ease reading of documentation directly from the command line. 119 | 120 | The first argument after the command is the address of the file to read. 121 | 122 | node biddle markdown applications/example/readme.md 123 | 124 | You can also specify a custom word wrap limit. The default is 100. 125 | 126 | node biddle markdown applications/example/readme.md 80 127 | 128 | ### publish 129 | Writes a hash file and a zip file with a version number to the publications directory or some other specified location. Applications are required to have a file in their root directory named *package.json* with properties: *name* and *version*. 130 | 131 | Create a zip in the default location: ./publications/myApplicationDirectory 132 | 133 | node biddle publish ../myApplicationDirectory 134 | 135 | Publish to a custom location: ./myAlternateDirectory/myApplicationDirectory 136 | 137 | node biddle publish ../myApplicationDirectory myAlternateDirectory 138 | 139 | Use quotes if any argument contains spaces: 140 | 141 | node biddle publish "c:\program files\myApplicationDirectory" 142 | 143 | ### remove 144 | Removes a file or a directory tree 145 | 146 | node biddle remove myDirectory 147 | node biddle remove myFile 148 | 149 | ### status 150 | Will check whether an installed application is behind the latest published version. 151 | 152 | Check the status of all installed applications 153 | 154 | node biddle status 155 | 156 | Check the status of an application by name 157 | 158 | noe biddle status myApplicationName 159 | 160 | ### test 161 | Run the user acceptance tests for a given application. This command requires a *test* property in a package.json file. 162 | 163 | Run the tests against biddle 164 | 165 | node biddle test 166 | 167 | Run the tests against an installed application 168 | 169 | node biddle test applicationName 170 | 171 | Run the tests against a directory in the current location 172 | 173 | node biddle test ./directory 174 | 175 | Run the tests against a directory in a different location 176 | 177 | node biddle test ../../directory 178 | 179 | ### uninstall 180 | Will delete an installed application by name and remove the application from the installed list. 181 | 182 | node biddle uninstall myApplicationName 183 | 184 | ### unpublish 185 | Will delete a published application by name and version then remove the respective files. 186 | 187 | Unpublish an application by version. 188 | 189 | node biddle unpublish myApplicationName 1.0.0 190 | 191 | Unpublish an application's latest version 192 | 193 | node biddle unpublish myApplicationName latest 194 | 195 | Remove the published application entirely. 196 | 197 | node biddle unpublish myApplicationName all 198 | 199 | ### unzip 200 | Unzips a local zipped file. 201 | 202 | Unzip to the default location, the supplied *downloads* directory. 203 | 204 | node biddle unzip myZipFile.zip 205 | 206 | Unzip to a specified location. 207 | 208 | node biddle unzip myZipFile.zip myDirectory 209 | 210 | ### version 211 | Prints the version number/name of biddle or a named installed application. 212 | 213 | If no application is specified the current version of biddle is output. 214 | 215 | node biddle version 216 | 217 | Output the current version of "myApplication". 218 | 219 | node biddle version myApplication 220 | 221 | ### zip 222 | Zips local files or local directories into a zip file. 223 | 224 | Zip to the default location, the supplied *downloads* directory. 225 | 226 | node biddle zip ../myApplication 227 | 228 | Zip to a specified location. 229 | 230 | node biddle zip ../myApplication myCustom/Location/Directory 231 | 232 | ## Dependencies 233 | 234 | * This application is written in JavaScript and requires [Node.js](https://nodejs.org/en/) to run. 235 | * This application makes use of zip utilities provided by operating systems. 236 | * This application requires use of Windows's PowerShell to execute the *global* coammand in Windows. 237 | * The *test* command requires [Pretty Diff](https://github.com/prettydiff/prettydiff.git) and [JSLint](https://github.com/douglascrockford/JSLint.git) as git submodules from Github. 238 | -------------------------------------------------------------------------------- /test/biddletesta/READMEa.md: -------------------------------------------------------------------------------- 1 | # test README 2 | some dummy subtext 3 | 4 | heading by underline equals 5 | = 6 | 7 | heading by underline dashes 8 | - 9 | 10 | === 11 | 12 | ## First Secondary Heading 13 | >a big block quote lives here. This is where I am going to experience with wrapping a block quote a bit differently from other content. I need enough text in this quote to wrap a couple of times, so I will continue adding some nonsense and as long as it takes to ensure I have a fully qualified test. 14 | New line in a block quote 15 | More block 16 | 17 | This is a regular paragraph that needs to be long enough to wrap a couple times. This text will be unique from the text in the block quote because uniqueness saves time when debugging test failures. I am now writing a bunch of wrapping paragraph gibberish, such as f324fasdaowkefsdva. That one isn't even a word. It isn't cool if it doesn't contain a [hyperlink](http://tonowhwere.nothing) in some text. 18 | 19 | * list item 1 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 20 | * list item 2 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 21 | - sublist item 1 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 22 | - sublist item 2 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 23 | * subsublist item 1 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 24 | * subsublist item 2 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 25 | * list item 3 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 26 | - boo these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 27 | 28 | ### First Tertiary Heading \##### 29 | This text should be extra indented. 30 | 31 | * list item 1 32 | * list item 2 33 | - sublist item 1 34 | - sublist item 2 35 | * subsublist item 1 36 | * subsublist item 2 37 | * list item 3 38 | - boo 39 | 40 | #### Gettin Deep with the Headings 41 | 42 | >a big block quote lives here. This is where I am going to experience with wrapping a block quote a bit differently from other content. I need enough text in this quote to wrap a couple of times, so I will continue adding some nonsense and a long a t takes to ensure I have a fully qualified test. 43 | New line in a block quote 44 | More block and not a heading 45 | --- 46 | 47 | > a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a 48 | 49 | > aa a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a 50 | 51 | Horizontal Rule with * 52 | * * * 53 | 54 | Horizontal Rule with - (requires an empty line between it and text) 55 | 56 | - - - 57 | 58 | Horizontal Rule with _ 59 | _ _ _ 60 | 61 | Images get converted to their [![alt text description](https://hyperlink). 62 | 63 | This is a regular paragraph that needs to be long enough to wrap a couple times. This text will be unique from the text in the block quote because uniqueness saves time when debugging test failures. I am now writing a bunch of wrapping paragraph gibberish, such as f324fasdaowkefsdva. That one isn't even a word. 64 | 65 | * list item 1 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 66 | * list item 2 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 67 | - sublist item 1 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 68 | - sublist item 2 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 69 | * subsublist item 1 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 70 | * subsublist item 2 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 71 | * list item 3 these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 72 | - boo these also need to wrap like a paragraph. So blah blah wrapping some madness into a list item right gosh darn here and let's see what shakes out of the coolness. 73 | 74 | Command|Local|Argument Type|Second Argument 75 | ---|---|---|--- 76 | copy|✓|file path or directory path|directory path 77 | get|?|file path|none 78 | global|✓|none|none 79 | hash|✓|file path|none 80 | help|✓|number|none 81 | install|?|zip file|directory path 82 | list|✓|"*installed*" or "*published*"|none 83 | markdown|✓|path to markdown file|number 84 | publish|✓|directory path|directory path 85 | remove|✓|file path or directory path|none 86 | status|?|none or application name|none 87 | test|X|none|none 88 | uninstall|✓|application name|none 89 | unpublish|✓|application name|none 90 | unzip|✓|path to zip file|directory path 91 | zip|✓|file path or directory path|directory path 92 | 93 | ## New big Heading 94 | paragraph here to see if indentation is largely reset appropriate to the current heading 95 | that is bigger than the previous headings 96 | 97 | ```` 98 | code block 1 99 | ``` 100 | ```` 101 | ```` 102 | code block 2 103 | ~~~ 104 | ```` 105 | ~~~~ 106 | code block 3 107 | ~~~ 108 | ~~~~ 109 | ~~~~ 110 | code block 4 111 | ``` 112 | ~~~~ -------------------------------------------------------------------------------- /test/biddletesta/biddletesta.js: -------------------------------------------------------------------------------- 1 | /*prettydiff.com topcoms: true, insize: 4, inchar: " ", vertical: true */ 2 | /*jshint laxbreak: true*/ 3 | /*global __dirname, ace, console, define, global, module, options, process, require */ 4 | /* 5 | 6 | Execute in a NodeJS app: 7 | 8 | var prettydiff = require("prettydiff"), 9 | args = { 10 | source: "asdf", 11 | diff : "asdd", 12 | lang : "text" 13 | }, 14 | output = prettydiff(args); 15 | 16 | Execute on command line with NodeJS: 17 | 18 | prettydiff source:"c:\mydirectory\myfile.js" readmethod:"file" diff:"c:\myotherfile.js" 19 | 20 | Execute with WSH: 21 | cscript prettydiff.wsf /source:"myFile.xml" /mode:"beautify" 22 | 23 | Execute from JavaScript: 24 | var global = {}, 25 | args = { 26 | source: "asdf", 27 | diff : "asdd", 28 | lang : "text" 29 | }, 30 | output = prettydiff(args); 31 | 32 | 33 | ******* license start ******* 34 | @source: http://prettydiff.com/prettydiff.js 35 | @documentation - English: http://prettydiff.com/documentation.xhtml 36 | 37 | @licstart The following is the entire license notice for Pretty Diff. 38 | 39 | This code may not be used or redistributed unless the following 40 | conditions are met: 41 | 42 | * Prettydiff created by Austin Cheney originally on 3 Mar 2009. 43 | http://prettydiff.com/ 44 | 45 | * The use of diffview.js and prettydiff.js must contain the following 46 | copyright: 47 | Copyright (c) 2007, Snowtide Informatics Systems, Inc. 48 | All rights reserved. 49 | - Redistributions of source code must retain the above copyright 50 | notice, this list of conditions and the following disclaimer. 51 | - Redistributions in binary form must reproduce the above copyright 52 | notice, this list of conditions and the following disclaimer in the 53 | documentation and/or other materials provided with the 54 | distribution. 55 | - Neither the name of the Snowtide Informatics Systems nor the 56 | names of its contributors may be used to endorse or promote products 57 | derived from this software without specific prior written 58 | permission. 59 | - used as diffview function 60 | http://prettydiff.com/lib/diffview.js 61 | 62 | * The code mentioned above has significantly expanded documentation in 63 | each of the respective function's external JS file as linked from the 64 | documentation page: 65 | http://prettydiff.com/documentation.php 66 | 67 | * In addition to the previously stated requirements any use of any 68 | component, aside from directly using the full files in their entirety, 69 | must restate the license mentioned at the top of each concerned file. 70 | 71 | If each and all these conditions are met use, extension, alteration, 72 | and redistribution of Pretty Diff and its required assets is unlimited 73 | and free without author permission. 74 | 75 | @licend The above is the entire license notice for Pretty Diff. 76 | ******* license end ******* 77 | 78 | 79 | Special thanks to: 80 | 81 | * Harry Whitfield for the numerous test cases provided against 82 | JSPretty. http://g6auc.me.uk/ 83 | 84 | * Andreas Greuel for contributing samples to test diffview.js 85 | https://plus.google.com/105958105635636993368/posts 86 | 87 | */ 88 | (function prettydiff_init() { 89 | "use strict"; 90 | if (typeof global.prettydiff !== "object") { 91 | global.prettydiff = {}; 92 | } 93 | if (typeof global.prettydiff.meta !== "object") { 94 | // schema for global.prettydiff.meta lang - array, language detection time - string, 95 | // proctime (total execution time minus visual rendering) insize - number, input 96 | // size outsize - number, output size difftotal - number, difference count 97 | // difflines - number, difference lines 98 | global.prettydiff.meta = { 99 | difflines: 0, 100 | difftotal: 0, 101 | error : "", 102 | insize : 0, 103 | lang : [ 104 | "", "", "" 105 | ], 106 | outsize : 0, 107 | time : "" 108 | }; 109 | } 110 | if (typeof require === "function" && (typeof ace !== "object" || ace.prettydiffid === undefined)) { 111 | (function glib_prettydiff() { 112 | var localPath = (typeof process === "object" && typeof process.cwd === "function" && (process.cwd() === "/" || (/^([a-z]:\\)$/).test(process.cwd()) === true) && typeof __dirname === "string") 113 | ? __dirname 114 | : "."; 115 | if (global.prettydiff.language === undefined) { 116 | global.prettydiff.language = require(localPath + "/lib/language.js"); 117 | } 118 | if (global.prettydiff.finalFile === undefined) { 119 | global.prettydiff.finalFile = require(localPath + "/lib/finalFile.js"); 120 | } 121 | if (global.prettydiff.csspretty === undefined) { 122 | global.prettydiff.csspretty = require(localPath + "/lib/csspretty.js"); 123 | } 124 | if (global.prettydiff.csvpretty === undefined) { 125 | global.prettydiff.csvpretty = require(localPath + "/lib/csvpretty.js"); 126 | } 127 | if (global.prettydiff.diffview === undefined) { 128 | global.prettydiff.diffview = require(localPath + "/lib/diffview.js"); 129 | } 130 | if (global.prettydiff.jspretty === undefined) { 131 | global.prettydiff.jspretty = require(localPath + "/lib/jspretty.js"); 132 | } 133 | if (global.prettydiff.options === undefined) { 134 | global.prettydiff.options = require(localPath + "/lib/options.js"); 135 | } 136 | if (global.prettydiff.safeSort === undefined) { 137 | global.prettydiff.safeSort = require(localPath + "/lib/safeSort.js"); 138 | } 139 | if (global.prettydiff.markuppretty === undefined) { 140 | global.prettydiff.markuppretty = require(localPath + "/lib/markuppretty.js"); 141 | } 142 | }()); 143 | } 144 | var prettydiff = function prettydiff_(api) { 145 | var startTime = (typeof Date.now === "function") 146 | ? Date.now() 147 | : (function prettydiff__dateShim() { 148 | var dateItem = new Date(); 149 | return Date.parse(dateItem); 150 | }()), 151 | core = function core_(api) { 152 | var spacetest = (/^\s+$/g), 153 | apioutput = "", 154 | apidiffout = "", 155 | metaerror = "", 156 | finalFile = global.prettydiff.finalFile, 157 | options = global.prettydiff.options.functions.validate(api), 158 | jspretty = function core__jspretty() { 159 | var jsout = global.prettydiff.jspretty(options); 160 | if (options.nodeasync === true) { 161 | metaerror = jsout[1]; 162 | return jsout[0]; 163 | } 164 | metaerror = global.prettydiff.meta.error; 165 | return jsout; 166 | }, 167 | markuppretty = function core__markuppretty() { 168 | var markout = global.prettydiff.markuppretty(options); 169 | if (options.nodeasync === true) { 170 | metaerror = markout[1]; 171 | if (options.mode === "beautify" && options.inchar !== "\t") { 172 | markout[0] = markout[0].replace(/\r?\n[\t]*\u0020\/>/g, ""); 173 | } else if (options.mode === "diff") { 174 | markout[0] = markout[0].replace(/\r?\n[\t]*\u0020\/>/g, ""); 175 | } 176 | return markout[0]; 177 | } 178 | metaerror = global.prettydiff.meta.error; 179 | if (options.mode === "beautify" && options.inchar !== "\t") { 180 | markout = markout.replace(/\r?\n[\t]*\u0020\/>/g, ""); 181 | } else if (options.mode === "diff") { 182 | markout = markout.replace(/\r?\n[\t]*\u0020\/>/g, ""); 183 | } 184 | return markout; 185 | }, 186 | csspretty = function core__markupcss() { 187 | var cssout = global.prettydiff.csspretty(options); 188 | if (options.nodeasync === true) { 189 | metaerror = cssout[1]; 190 | return cssout[0]; 191 | } 192 | metaerror = global.prettydiff.meta.error; 193 | return cssout; 194 | }, 195 | proctime = function core__proctime() { 196 | var minuteString = "", 197 | hourString = "", 198 | minutes = 0, 199 | hours = 0, 200 | elapsed = (typeof Date.now === "function") 201 | ? ((Date.now() - startTime) / 1000) 202 | : (function core__proctime_dateShim() { 203 | var dateitem = new Date(); 204 | return Date.parse(dateitem); 205 | }()), 206 | secondString = elapsed.toFixed(3), 207 | plural = function core__proctime_plural(x, y) { 208 | var a = x + y; 209 | if (x !== 1) { 210 | a = a + "s"; 211 | } 212 | if (y !== " second") { 213 | a = a + " "; 214 | } 215 | return a; 216 | }, 217 | minute = function core__proctime_minute() { 218 | minutes = parseInt((elapsed / 60), 10); 219 | minuteString = plural(minutes, " minute"); 220 | minutes = elapsed - (minutes * 60); 221 | secondString = (minutes === 1) 222 | ? "1 second" 223 | : minutes.toFixed(3) + " seconds"; 224 | }; 225 | if (elapsed >= 60 && elapsed < 3600) { 226 | minute(); 227 | } else if (elapsed >= 3600) { 228 | hours = parseInt((elapsed / 3600), 10); 229 | hourString = hours.toString(); 230 | elapsed = elapsed - (hours * 3600); 231 | hourString = plural(hours, " hour"); 232 | minute(); 233 | } else { 234 | secondString = plural(secondString, " second"); 235 | } 236 | return hourString + minuteString + secondString; 237 | }, 238 | output = function core__output(finalProduct, difftotal, difflines) { 239 | var meta = { 240 | difflines: 0, 241 | difftotal: 0, 242 | error : "", 243 | insize : 0, 244 | lang : [ 245 | "", "", "" 246 | ], 247 | outsize : 0, 248 | time : "" 249 | }; 250 | meta.lang = options.autoval; 251 | meta.time = proctime(); 252 | meta.insize = (options.mode === "diff") 253 | ? options.source.length + options.diff.length 254 | : options.source.length; 255 | if (options.mode === "parse" && options.lang !== "text" && typeof finalProduct === "object" && (options.autoval[0] !== "" || options.lang !== "auto")) { 256 | if (options.parseFormat === "sequential" || options.parseFormat === "htmltable") { 257 | meta.outsize = finalProduct.data.length; 258 | } else { 259 | meta.outsize = finalProduct.data.token.length; 260 | } 261 | } else { 262 | meta.outsize = finalProduct.length; 263 | } 264 | if (options.autoval[0] === "text" && options.mode !== "diff") { 265 | if (options.autoval[2] === "unknown") { 266 | meta.error = "Language is set to auto, but could not be detected. File not parsed."; 267 | } else { 268 | meta.error = "Language is set to text, but plain text is only supported in diff mode. File not" + 269 | " parsed."; 270 | } 271 | } 272 | if (difftotal !== undefined) { 273 | meta.difftotal = difftotal; 274 | } 275 | if (difflines !== undefined) { 276 | meta.difflines = difflines; 277 | } 278 | meta.error = metaerror; 279 | if (options.nodeasync === true) { 280 | return [finalProduct, meta]; 281 | } 282 | global.prettydiff.meta = meta; 283 | return finalProduct; 284 | }; 285 | if (options.source === "" && (options.mode === "beautify" || options.mode === "minify" || options.mode === "analysis" || (options.mode === "diff" && options.diffcli === false) || (options.mode === "parse" && options.parseFormat === "htmltable"))) { 286 | metaerror = "options.source is empty!"; 287 | return output(""); 288 | } 289 | if (options.mode === "diff" && options.diffcli === false) { 290 | if (options.diff === "") { 291 | metaerror = "options.mode is 'diff' and options.diff is empty!"; 292 | return output(""); 293 | } 294 | if (options.lang === "csv") { 295 | options.lang = "text"; 296 | } 297 | } 298 | if (options.autoval[0] === "text" && options.mode !== "diff") { 299 | metaerror = "Language is either text or undetermined, but text is only allowed for the 'diff'" + 300 | " mode!"; 301 | return output(options.source); 302 | } 303 | finalFile.order[7] = options.color; 304 | if (options.mode === "diff") { 305 | options.vertical = false; 306 | options.jsscope = false; 307 | options.preserve = 0; 308 | if (options.diffcomments === false) { 309 | options.comments = "nocomment"; 310 | } 311 | if (options.lang === "css") { 312 | apioutput = csspretty(); 313 | options.source = options.diff; 314 | apidiffout = csspretty(); 315 | } else if (options.lang === "csv") { 316 | apioutput = global.prettydiff.csvpretty(options); 317 | apidiffout = global.prettydiff.csvpretty(options); 318 | } else if (options.lang === "markup") { 319 | apioutput = markuppretty(); 320 | options.source = options.diff; 321 | apidiffout = markuppretty(); 322 | } else if (options.lang === "text") { 323 | apioutput = options.source; 324 | apidiffout = options.diff; 325 | } else { 326 | apioutput = jspretty(); 327 | options.source = options.diff; 328 | apidiffout = jspretty(); 329 | } 330 | if (options.quote === true) { 331 | apioutput = apioutput.replace(/'/g, "\""); 332 | apidiffout = apidiffout.replace(/'/g, "\""); 333 | } 334 | if (options.semicolon === true) { 335 | apioutput = apioutput 336 | .replace(/;\r\n/g, "\r\n") 337 | .replace(/;\n/g, "\n"); 338 | apidiffout = apidiffout 339 | .replace(/;\r\n/g, "\r\n") 340 | .replace(/;\n/g, "\n"); 341 | } 342 | if (options.sourcelabel === "" || spacetest.test(options.sourcelabel)) { 343 | options.sourcelabel = "Base Text"; 344 | } 345 | if (options.difflabel === "" || spacetest.test(options.difflabel)) { 346 | options.difflabel = "New Text"; 347 | } 348 | if (options.jsx === true) { 349 | options.autoval = ["jsx", "javascript", "React JSX"]; 350 | } 351 | return (function core__diff() { 352 | var a = ""; 353 | options.diff = apidiffout; 354 | options.source = apioutput; 355 | if (options.diffcli === true) { 356 | return output(global.prettydiff.diffview(options)); 357 | } 358 | if (apioutput === "Error: This does not appear to be JavaScript." || apidiffout === "Error: This does not appear to be JavaScript.") { 359 | return output("

Error: Please try using the option labeled Plain Text (d" + 360 | "iff only). The input does not appear to be mark" + 361 | "up, CSS, or JavaScript.

"); 362 | } 363 | if (options.lang === "text") { 364 | options.inchar = ""; 365 | } 366 | a = global.prettydiff.diffview(options); 367 | if (options.jsx === true) { 368 | options.autoval = ["jsx", "javascript", "React JSX"]; 369 | } 370 | if (options.api === "") { 371 | finalFile.order[10] = a[0]; 372 | finalFile.order[12] = finalFile.script.diff; 373 | return output(finalFile.order.join(""), a[1], a[2]); 374 | } 375 | return output(a[0], a[1], a[2]); 376 | }()); 377 | } else { 378 | if (options.mode === "analysis") { 379 | options.accessibility = true; 380 | } 381 | if (options.lang === "css") { 382 | apioutput = csspretty(); 383 | } else if (options.lang === "csv") { 384 | apioutput = global.prettydiff.csvpretty(options); 385 | } else if (options.lang === "markup") { 386 | apioutput = markuppretty(); 387 | } else if (options.lang === "text") { 388 | apioutput = options.source; 389 | apidiffout = ""; 390 | } else { 391 | apioutput = jspretty(); 392 | } 393 | if (options.api === "") { 394 | if (options.mode === "analysis" || (options.mode === "parse" && options.parseFormat === "htmltable")) { 395 | finalFile.order[10] = apidiffout; 396 | apioutput = finalFile.order.join(""); 397 | } else if (options.mode === "beautify" && options.jsscope !== "none" && options.lang === "javascript") { 398 | finalFile.order[10] = apidiffout; 399 | finalFile.order[12] = finalFile.script.beautify; 400 | apioutput = finalFile.order.join(""); 401 | } 402 | } 403 | if (options.jsx === true) { 404 | options.autoval = ["jsx", "javascript", "React JSX"]; 405 | } 406 | return output(apioutput); 407 | } 408 | }; 409 | return core(api); 410 | }; 411 | global.prettydiff.edition = { 412 | addon : { 413 | ace: 160307 414 | }, 415 | api : { 416 | dom : 160921, //dom.js 417 | nodeLocal: 160816 //node-local.js 418 | }, 419 | css : 160814, //css files 420 | csspretty : 160902, //csspretty lib 421 | csvpretty : 160816, //csvpretty lib 422 | diffview : 160902, //diffview lib 423 | documentation: 160828, //documentation.xhtml and various guide pages 424 | finalFile : 160816, //HTML report generator 425 | jspretty : 160921, //jspretty lib 426 | language : 160921, //language lib 427 | latest : 0, 428 | lint : 160914, //unit test and lint automation as test/lint.js 429 | markuppretty : 160921, //markuppretty lib 430 | options : 160921, //options management 431 | prettydiff : 160902, //this file 432 | safeSort : 160816, //safeSort lib 433 | version : "2.1.11", //version number 434 | webtool : 160827 435 | }; 436 | global.prettydiff.edition.latest = (function edition_latest() { 437 | return Math.max(global.prettydiff.edition.css, global.prettydiff.edition.csspretty, global.prettydiff.edition.csvpretty, global.prettydiff.edition.diffview, global.prettydiff.edition.documentation, global.prettydiff.edition.finalFile, global.prettydiff.edition.jspretty, global.prettydiff.edition.language, global.prettydiff.edition.markuppretty, global.prettydiff.edition.options, global.prettydiff.edition.prettydiff, global.prettydiff.edition.webtool, global.prettydiff.edition.api.dom, global.prettydiff.edition.api.nodeLocal); 438 | }()); 439 | if (typeof module === "object" && typeof module.parent === "object") { 440 | //commonjs and nodejs support 441 | module.exports.edition = global.prettydiff.edition; 442 | module.exports.meta = global.prettydiff.meta; 443 | module.exports = function commonjs_prettydiff(x) { 444 | return prettydiff(x); 445 | }; 446 | if (process.argv.length === 2 && process.argv[1].indexOf("prettydiff.js") > -1) { 447 | console.log("Please try: node api/node-local.js"); 448 | } 449 | } else if ((typeof define === "object" || typeof define === "function") && (typeof ace !== "object" || ace.prettydiffid === undefined)) { 450 | //requirejs support 451 | define(function requirejs(require, module) { 452 | module.exports.edition = global.prettydiff.edition; 453 | module.exports.meta = global.prettydiff.meta; 454 | module.exports = function requirejs_prettydiff_export(x) { 455 | return prettydiff(x); 456 | }; 457 | //worthless if block to appease RequireJS and JSLint 458 | if (typeof require === "number") { 459 | return require; 460 | } 461 | return function requirejs_prettydiff_module(x) { 462 | prettydiff(x); 463 | }; 464 | }); 465 | } else { 466 | global.prettydiff.prettydiff = prettydiff; 467 | } 468 | }()); 469 | -------------------------------------------------------------------------------- /test/biddletesta/liba/libaa.txt: -------------------------------------------------------------------------------- 1 | libaa 2 | -------------------------------------------------------------------------------- /test/biddletesta/liba/libab.txt: -------------------------------------------------------------------------------- 1 | libab 2 | -------------------------------------------------------------------------------- /test/biddletesta/liba/libac.txt: -------------------------------------------------------------------------------- 1 | libac 2 | -------------------------------------------------------------------------------- /test/biddletesta/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author" : { 3 | "email": "info@prettydiff.com", 4 | "name" : "Austin Cheney", 5 | "url" : "http://prettydiff.com/" 6 | }, 7 | "bin" : "./bin/biddle", 8 | "bugs" : { 9 | "email": "info@prettydiff.com", 10 | "url" : "https://github.com/prettydiff/biddle/issues" 11 | }, 12 | "description" : "Biddle test app.", 13 | "homepage" : "http://prettydiff.com/", 14 | "keywords" : [ 15 | "biddle", "test" 16 | ], 17 | "license" : "MIT", 18 | "main" : "biddletesta.js", 19 | "maintainers" : [ 20 | { 21 | "email": "info@prettydiff.com", 22 | "name" : "austincheney" 23 | } 24 | ], 25 | "name" : "biddletesta", 26 | "publication_variants": { 27 | "min" : { 28 | "exclusions": [ 29 | "liba", "testa" 30 | ], 31 | "tasks" : [] 32 | }, 33 | "prod": { 34 | "exclusions": ["testa"], 35 | "tasks" : [] 36 | } 37 | }, 38 | "repository" : { 39 | "type": "git", 40 | "url" : "https://github.com/prettydiff/biddle" 41 | }, 42 | "version" : "99.99.1234" 43 | } 44 | -------------------------------------------------------------------------------- /test/biddletesta/testa/testaa.txt: -------------------------------------------------------------------------------- 1 | testaa 2 | -------------------------------------------------------------------------------- /test/biddletesta/testa/testab.txt: -------------------------------------------------------------------------------- 1 | testab 2 | -------------------------------------------------------------------------------- /test/biddletesta/testa/testac.txt: -------------------------------------------------------------------------------- 1 | testac 2 | -------------------------------------------------------------------------------- /test/biddletestb/.biddlerc: -------------------------------------------------------------------------------- 1 | { 2 | "directories": { 3 | "applications": "applications", 4 | "downloads" : "downloads", 5 | "publications": "../../unittest/publications" 6 | }, 7 | "exclusions" : [ 8 | ".DC_Store", 9 | "._DC_Store", 10 | ".git", 11 | ".gitmodules", 12 | "node_modules" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /test/biddletestb/READMEb.md: -------------------------------------------------------------------------------- 1 | Try it online at [http://prettydiff.com/](http://prettydiff.com/). 2 | 3 | # ![Pretty Diff logo](http://prettydiff.com/images/pdlogoxs.svg) Pretty Diff 4 | 5 | [![Travis CI Build](https://travis-ci.org/prettydiff/prettydiff.svg)](https://travis-ci.org/prettydiff/prettydiff) 6 | [![AppVeyor Build](https://ci.appveyor.com/api/projects/status/github/prettydiff/prettydiff?branch=master&svg=true)](https://ci.appveyor.com/project/prettydiff/prettydiff) 7 | [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/prettydiff/prettydiff?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 8 | [![Twitter Tweets](https://img.shields.io/twitter/url/http/prettydiff.com.svg?style=social)](https://twitter.com/intent/tweet?text=Handy%20web%20development%20tool:%20%20url=http%3A%2F%2Fprettydiff.com) 9 | 10 | ## Summary 11 | 12 | Language aware code comparison tool for several web based languages. It also beautifies, minifies, and a few other things. 13 | 14 | ## Benefits - see [overview page](http://prettydiff.com/overview.xhtml) for more details 15 | 16 | * ES6 / JS2015 ready 17 | * [React JSX format support](http://prettydiff.com/guide/react_jsx.xhtml) 18 | * LESS, SCSS (Sass), and CSS support 19 | * Separate support for XML and HTML 20 | * [Recursive command line directory diff](http://prettydiff.com/guide/diffcli.xhtml) 21 | * [JavaScript scope in colors](http://prettydiff.com/guide/jshtml.xhtml) 22 | * [Supports presets for popular styleguides](http://prettydiff.com/guide/styleguide.xhtml) 23 | * [Markup beautification with optional opt out](http://prettydiff.com/guide/tag_ignore.xhtml) 24 | * [JavaScript auto correction](http://prettydiff.com/guide/jscorrect.xhtml) 25 | * [Supports a ton of options](http://prettydiff.com/documentation.php#function_properties) 26 | * [Default beautifier](https://atom.io/packages/atom-beautify/) for several languages in [Atom.io](https://atom.io/) 27 | 28 | ## Executing Pretty Diff 29 | 30 | ### Run with Node.js / CommonJS / RequireJS 31 | 32 | A Node.js command line utility is provided by api/node-local.js. This file can execute in the following modes: 33 | 34 | * auto - Determine if the resource is text, a file, or a directory and process as such (except that directories are processed with the subdirectory option) 35 | * screen - code input is on the command line and output is to the command line 36 | * filescreen - code input is in a file and the output is to the command line 37 | * file - the input and the output reside in files 38 | * directory - everything in a directory is processed into a specified output directory except ".", "..", and subdirectories 39 | * subdirectory - process the entire directory tree 40 | 41 | #### Execute in the context of a NodeJS application 42 | 43 | Add this code to your application 44 | 45 | var prettydiff = require("prettydiff"), 46 | args = { 47 | source: "asdf", 48 | diff : "asdd", 49 | lang : "text" 50 | }, 51 | output = prettydiff(args); 52 | 53 | #### Execute from the command line 54 | 55 | Run in windows 56 | 57 | node api/node-local.js source:"c:\myDirectory" readmethod:"subdirectory" diff:"c:\myOtherDirectory" 58 | 59 | Run in Linux and OSX 60 | 61 | node api/node-local.js source:"myDirectory" mode:"beautify" readmethod:"subdirectory" output:"path/to/outputDirectory" 62 | 63 | To see a *man* page provide no arguments or these: help, man, manual 64 | 65 | node api/node-local.js h 66 | node api/node-local.js help 67 | node api/node-local.js man 68 | node api/node-local.js manual 69 | 70 | To see only the version number supply only *v* or *version* as an argument: 71 | 72 | node api/node-local.js v 73 | node api/node-local.js version 74 | 75 | To see a list of current settings on the console supply *list* as an argument: 76 | 77 | node api/node-local.js l 78 | node api/node-local.js list 79 | 80 | #### Set configurations with a **.prettydiffrc** file. 81 | 82 | Pretty Diff will first look for a .prettydiffrc file from the current directory in the command prompt. If the .prettydiffrc is not present in the current directory it will then look for it in the application's directory. 83 | 84 | The .prettydiffrc first checks for JSON format. This allows a simple means of defining options in a file. It also allows a [JavaScript application format](http://prettydiff.com/.prettydiffrc) so that options can be set conditionally. 85 | 86 | ### Run in a web browser with api/dom.js 87 | 88 | Please feel free to use index.xhtml file to supplement dom.js. Otherwise, dom.js requires supplemental assistance to map DOM nodes from an HTML source. dom.js is fault tolerant so nodes mapped to the supplied index.xhtml don't need to be supported from custom HTML. 89 | 90 | To run Pretty Diff using dom.js include the following two script tags and bind the global.prettydiff.pd.recycle() function to the executing event. Please refer to index.xhtml for an HTML example and documentation.xhtml for option and execution information. 91 | 92 | 93 | 94 | 95 | 96 | 97 | **(optional)** 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | ### Execute with vanilla JS 107 | 108 | var global = {}, 109 | args = { 110 | source: "asdf", 111 | diff : "asdd", 112 | lang : "text" 113 | }, 114 | output = prettydiff(args); 115 | 116 | ### Run Pretty Diff in [Atom](https://atom.io/) code editor with the [atom-beautify](https://atom.io/packages/atom-beautify) package. 117 | 118 | ### Run the unit tests 119 | 120 | cd prettydiff 121 | node test/lint.js 122 | 123 | ## License: 124 | 125 | **@source** http://prettydiff.com/prettydiff.js 126 | 127 | **@documentation** English: http://prettydiff.com/documentation.xhtml 128 | 129 | **@licstart** The following is the entire license notice for Pretty Diff. 130 | 131 | This code may not be used or redistributed unless the following 132 | conditions are met: 133 | 134 | * Prettydiff created by Austin Cheney originally on 3 Mar 2009. http://prettydiff.com/ 135 | * The use of diffview.js and prettydiff.js must contain the following copyright: 136 | * Copyright (c) 2007, Snowtide Informatics Systems, Inc. All rights reserved. 137 | - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 138 | - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 139 | - Neither the name of the Snowtide Informatics Systems nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 140 | - used as diffview function http://prettydiff.com/lib/diffview.js 141 | * The code mentioned above has significantly expanded documentation in each of the respective function's external JS file as linked from the documentation page: http://prettydiff.com/documentation.xhtml 142 | * In addition to the previously stated requirements any use of any component, aside from directly using the full files in their entirety, must restate the license mentioned at the top of each concerned file. 143 | 144 | If each and all these conditions are met use, extension, alteration, 145 | and redistribution of Pretty Diff and its required assets is unlimited 146 | and free without author permission. 147 | 148 | **@licend** The above is the entire license notice for Pretty Diff. 149 | 150 | ## Acknowledgements 151 | 152 | * Harry Whitfield - http://g6auc.me.uk/ 153 | - JS Pretty QA 154 | - JS Pretty widget 155 | * Andreas Greuel - https://plus.google.com/105958105635636993368/posts 156 | - diffview.js QA 157 | -------------------------------------------------------------------------------- /test/biddletestb/biddletestb.js: -------------------------------------------------------------------------------- 1 | /*prettydiff.com topcoms: true, insize: 4, inchar: " ", vertical: true */ 2 | /*jshint laxbreak: true*/ 3 | /*global __dirname, ace, console, define, global, module, options, process, require */ 4 | /* 5 | 6 | Execute in a NodeJS app: 7 | 8 | var prettydiff = require("prettydiff"), 9 | args = { 10 | source: "asdf", 11 | diff : "asdd", 12 | lang : "text" 13 | }, 14 | output = prettydiff(args); 15 | 16 | Execute on command line with NodeJS: 17 | 18 | prettydiff source:"c:\mydirectory\myfile.js" readmethod:"file" diff:"c:\myotherfile.js" 19 | 20 | Execute with WSH: 21 | cscript prettydiff.wsf /source:"myFile.xml" /mode:"beautify" 22 | 23 | Execute from JavaScript: 24 | var global = {}, 25 | args = { 26 | source: "asdf", 27 | diff : "asdd", 28 | lang : "text" 29 | }, 30 | output = prettydiff(args); 31 | 32 | 33 | ******* license start ******* 34 | @source: http://prettydiff.com/prettydiff.js 35 | @documentation - English: http://prettydiff.com/documentation.xhtml 36 | 37 | @licstart The following is the entire license notice for Pretty Diff. 38 | 39 | This code may not be used or redistributed unless the following 40 | conditions are met: 41 | 42 | * Prettydiff created by Austin Cheney originally on 3 Mar 2009. 43 | http://prettydiff.com/ 44 | 45 | * The use of diffview.js and prettydiff.js must contain the following 46 | copyright: 47 | Copyright (c) 2007, Snowtide Informatics Systems, Inc. 48 | All rights reserved. 49 | - Redistributions of source code must retain the above copyright 50 | notice, this list of conditions and the following disclaimer. 51 | - Redistributions in binary form must reproduce the above copyright 52 | notice, this list of conditions and the following disclaimer in the 53 | documentation and/or other materials provided with the 54 | distribution. 55 | - Neither the name of the Snowtide Informatics Systems nor the 56 | names of its contributors may be used to endorse or promote products 57 | derived from this software without specific prior written 58 | permission. 59 | - used as diffview function 60 | http://prettydiff.com/lib/diffview.js 61 | 62 | * The code mentioned above has significantly expanded documentation in 63 | each of the respective function's external JS file as linked from the 64 | documentation page: 65 | http://prettydiff.com/documentation.php 66 | 67 | * In addition to the previously stated requirements any use of any 68 | component, aside from directly using the full files in their entirety, 69 | must restate the license mentioned at the top of each concerned file. 70 | 71 | If each and all these conditions are met use, extension, alteration, 72 | and redistribution of Pretty Diff and its required assets is unlimited 73 | and free without author permission. 74 | 75 | @licend The above is the entire license notice for Pretty Diff. 76 | ******* license end ******* 77 | 78 | 79 | Special thanks to: 80 | 81 | * Harry Whitfield for the numerous test cases provided against 82 | JSPretty. http://g6auc.me.uk/ 83 | 84 | * Andreas Greuel for contributing samples to test diffview.js 85 | https://plus.google.com/105958105635636993368/posts 86 | 87 | */ 88 | (function prettydiff_init() { 89 | "use strict"; 90 | if (typeof global.prettydiff !== "object") { 91 | global.prettydiff = {}; 92 | } 93 | if (typeof global.prettydiff.meta !== "object") { 94 | // schema for global.prettydiff.meta lang - array, language detection time - string, 95 | // proctime (total execution time minus visual rendering) insize - number, input 96 | // size outsize - number, output size difftotal - number, difference count 97 | // difflines - number, difference lines 98 | global.prettydiff.meta = { 99 | difflines: 0, 100 | difftotal: 0, 101 | error : "", 102 | insize : 0, 103 | lang : [ 104 | "", "", "" 105 | ], 106 | outsize : 0, 107 | time : "" 108 | }; 109 | } 110 | if (typeof require === "function" && (typeof ace !== "object" || ace.prettydiffid === undefined)) { 111 | (function glib_prettydiff() { 112 | var localPath = (typeof process === "object" && typeof process.cwd === "function" && (process.cwd() === "/" || (/^([a-z]:\\)$/).test(process.cwd()) === true) && typeof __dirname === "string") 113 | ? __dirname 114 | : "."; 115 | if (global.prettydiff.language === undefined) { 116 | global.prettydiff.language = require(localPath + "/lib/language.js"); 117 | } 118 | if (global.prettydiff.finalFile === undefined) { 119 | global.prettydiff.finalFile = require(localPath + "/lib/finalFile.js"); 120 | } 121 | if (global.prettydiff.csspretty === undefined) { 122 | global.prettydiff.csspretty = require(localPath + "/lib/csspretty.js"); 123 | } 124 | if (global.prettydiff.csvpretty === undefined) { 125 | global.prettydiff.csvpretty = require(localPath + "/lib/csvpretty.js"); 126 | } 127 | if (global.prettydiff.diffview === undefined) { 128 | global.prettydiff.diffview = require(localPath + "/lib/diffview.js"); 129 | } 130 | if (global.prettydiff.jspretty === undefined) { 131 | global.prettydiff.jspretty = require(localPath + "/lib/jspretty.js"); 132 | } 133 | if (global.prettydiff.options === undefined) { 134 | global.prettydiff.options = require(localPath + "/lib/options.js"); 135 | } 136 | if (global.prettydiff.safeSort === undefined) { 137 | global.prettydiff.safeSort = require(localPath + "/lib/safeSort.js"); 138 | } 139 | if (global.prettydiff.markuppretty === undefined) { 140 | global.prettydiff.markuppretty = require(localPath + "/lib/markuppretty.js"); 141 | } 142 | }()); 143 | } 144 | var prettydiff = function prettydiff_(api) { 145 | var startTime = (typeof Date.now === "function") 146 | ? Date.now() 147 | : (function prettydiff__dateShim() { 148 | var dateItem = new Date(); 149 | return Date.parse(dateItem); 150 | }()), 151 | core = function core_(api) { 152 | var spacetest = (/^\s+$/g), 153 | apioutput = "", 154 | apidiffout = "", 155 | metaerror = "", 156 | finalFile = global.prettydiff.finalFile, 157 | options = global.prettydiff.options.functions.validate(api), 158 | jspretty = function core__jspretty() { 159 | var jsout = global.prettydiff.jspretty(options); 160 | if (options.nodeasync === true) { 161 | metaerror = jsout[1]; 162 | return jsout[0]; 163 | } 164 | metaerror = global.prettydiff.meta.error; 165 | return jsout; 166 | }, 167 | markuppretty = function core__markuppretty() { 168 | var markout = global.prettydiff.markuppretty(options); 169 | if (options.nodeasync === true) { 170 | metaerror = markout[1]; 171 | if (options.mode === "beautify" && options.inchar !== "\t") { 172 | markout[0] = markout[0].replace(/\r?\n[\t]*\u0020\/>/g, ""); 173 | } else if (options.mode === "diff") { 174 | markout[0] = markout[0].replace(/\r?\n[\t]*\u0020\/>/g, ""); 175 | } 176 | return markout[0]; 177 | } 178 | metaerror = global.prettydiff.meta.error; 179 | if (options.mode === "beautify" && options.inchar !== "\t") { 180 | markout = markout.replace(/\r?\n[\t]*\u0020\/>/g, ""); 181 | } else if (options.mode === "diff") { 182 | markout = markout.replace(/\r?\n[\t]*\u0020\/>/g, ""); 183 | } 184 | return markout; 185 | }, 186 | csspretty = function core__markupcss() { 187 | var cssout = global.prettydiff.csspretty(options); 188 | if (options.nodeasync === true) { 189 | metaerror = cssout[1]; 190 | return cssout[0]; 191 | } 192 | metaerror = global.prettydiff.meta.error; 193 | return cssout; 194 | }, 195 | proctime = function core__proctime() { 196 | var minuteString = "", 197 | hourString = "", 198 | minutes = 0, 199 | hours = 0, 200 | elapsed = (typeof Date.now === "function") 201 | ? ((Date.now() - startTime) / 1000) 202 | : (function core__proctime_dateShim() { 203 | var dateitem = new Date(); 204 | return Date.parse(dateitem); 205 | }()), 206 | secondString = elapsed.toFixed(3), 207 | plural = function core__proctime_plural(x, y) { 208 | var a = x + y; 209 | if (x !== 1) { 210 | a = a + "s"; 211 | } 212 | if (y !== " second") { 213 | a = a + " "; 214 | } 215 | return a; 216 | }, 217 | minute = function core__proctime_minute() { 218 | minutes = parseInt((elapsed / 60), 10); 219 | minuteString = plural(minutes, " minute"); 220 | minutes = elapsed - (minutes * 60); 221 | secondString = (minutes === 1) 222 | ? "1 second" 223 | : minutes.toFixed(3) + " seconds"; 224 | }; 225 | if (elapsed >= 60 && elapsed < 3600) { 226 | minute(); 227 | } else if (elapsed >= 3600) { 228 | hours = parseInt((elapsed / 3600), 10); 229 | hourString = hours.toString(); 230 | elapsed = elapsed - (hours * 3600); 231 | hourString = plural(hours, " hour"); 232 | minute(); 233 | } else { 234 | secondString = plural(secondString, " second"); 235 | } 236 | return hourString + minuteString + secondString; 237 | }, 238 | output = function core__output(finalProduct, difftotal, difflines) { 239 | var meta = { 240 | difflines: 0, 241 | difftotal: 0, 242 | error : "", 243 | insize : 0, 244 | lang : [ 245 | "", "", "" 246 | ], 247 | outsize : 0, 248 | time : "" 249 | }; 250 | meta.lang = options.autoval; 251 | meta.time = proctime(); 252 | meta.insize = (options.mode === "diff") 253 | ? options.source.length + options.diff.length 254 | : options.source.length; 255 | if (options.mode === "parse" && options.lang !== "text" && typeof finalProduct === "object" && (options.autoval[0] !== "" || options.lang !== "auto")) { 256 | if (options.parseFormat === "sequential" || options.parseFormat === "htmltable") { 257 | meta.outsize = finalProduct.data.length; 258 | } else { 259 | meta.outsize = finalProduct.data.token.length; 260 | } 261 | } else { 262 | meta.outsize = finalProduct.length; 263 | } 264 | if (options.autoval[0] === "text" && options.mode !== "diff") { 265 | if (options.autoval[2] === "unknown") { 266 | meta.error = "Language is set to auto, but could not be detected. File not parsed."; 267 | } else { 268 | meta.error = "Language is set to text, but plain text is only supported in diff mode. File not" + 269 | " parsed."; 270 | } 271 | } 272 | if (difftotal !== undefined) { 273 | meta.difftotal = difftotal; 274 | } 275 | if (difflines !== undefined) { 276 | meta.difflines = difflines; 277 | } 278 | meta.error = metaerror; 279 | if (options.nodeasync === true) { 280 | return [finalProduct, meta]; 281 | } 282 | global.prettydiff.meta = meta; 283 | return finalProduct; 284 | }; 285 | if (options.source === "" && (options.mode === "beautify" || options.mode === "minify" || options.mode === "analysis" || (options.mode === "diff" && options.diffcli === false) || (options.mode === "parse" && options.parseFormat === "htmltable"))) { 286 | metaerror = "options.source is empty!"; 287 | return output(""); 288 | } 289 | if (options.mode === "diff" && options.diffcli === false) { 290 | if (options.diff === "") { 291 | metaerror = "options.mode is 'diff' and options.diff is empty!"; 292 | return output(""); 293 | } 294 | if (options.lang === "csv") { 295 | options.lang = "text"; 296 | } 297 | } 298 | if (options.autoval[0] === "text" && options.mode !== "diff") { 299 | metaerror = "Language is either text or undetermined, but text is only allowed for the 'diff'" + 300 | " mode!"; 301 | return output(options.source); 302 | } 303 | finalFile.order[7] = options.color; 304 | if (options.mode === "diff") { 305 | options.vertical = false; 306 | options.jsscope = false; 307 | options.preserve = 0; 308 | if (options.diffcomments === false) { 309 | options.comments = "nocomment"; 310 | } 311 | if (options.lang === "css") { 312 | apioutput = csspretty(); 313 | options.source = options.diff; 314 | apidiffout = csspretty(); 315 | } else if (options.lang === "csv") { 316 | apioutput = global.prettydiff.csvpretty(options); 317 | apidiffout = global.prettydiff.csvpretty(options); 318 | } else if (options.lang === "markup") { 319 | apioutput = markuppretty(); 320 | options.source = options.diff; 321 | apidiffout = markuppretty(); 322 | } else if (options.lang === "text") { 323 | apioutput = options.source; 324 | apidiffout = options.diff; 325 | } else { 326 | apioutput = jspretty(); 327 | options.source = options.diff; 328 | apidiffout = jspretty(); 329 | } 330 | if (options.quote === true) { 331 | apioutput = apioutput.replace(/'/g, "\""); 332 | apidiffout = apidiffout.replace(/'/g, "\""); 333 | } 334 | if (options.semicolon === true) { 335 | apioutput = apioutput 336 | .replace(/;\r\n/g, "\r\n") 337 | .replace(/;\n/g, "\n"); 338 | apidiffout = apidiffout 339 | .replace(/;\r\n/g, "\r\n") 340 | .replace(/;\n/g, "\n"); 341 | } 342 | if (options.sourcelabel === "" || spacetest.test(options.sourcelabel)) { 343 | options.sourcelabel = "Base Text"; 344 | } 345 | if (options.difflabel === "" || spacetest.test(options.difflabel)) { 346 | options.difflabel = "New Text"; 347 | } 348 | if (options.jsx === true) { 349 | options.autoval = ["jsx", "javascript", "React JSX"]; 350 | } 351 | return (function core__diff() { 352 | var a = ""; 353 | options.diff = apidiffout; 354 | options.source = apioutput; 355 | if (options.diffcli === true) { 356 | return output(global.prettydiff.diffview(options)); 357 | } 358 | if (apioutput === "Error: This does not appear to be JavaScript." || apidiffout === "Error: This does not appear to be JavaScript.") { 359 | return output("

Error: Please try using the option labeled Plain Text (d" + 360 | "iff only). The input does not appear to be mark" + 361 | "up, CSS, or JavaScript.

"); 362 | } 363 | if (options.lang === "text") { 364 | options.inchar = ""; 365 | } 366 | a = global.prettydiff.diffview(options); 367 | if (options.jsx === true) { 368 | options.autoval = ["jsx", "javascript", "React JSX"]; 369 | } 370 | if (options.api === "") { 371 | finalFile.order[10] = a[0]; 372 | finalFile.order[12] = finalFile.script.diff; 373 | return output(finalFile.order.join(""), a[1], a[2]); 374 | } 375 | return output(a[0], a[1], a[2]); 376 | }()); 377 | } else { 378 | if (options.mode === "analysis") { 379 | options.accessibility = true; 380 | } 381 | if (options.lang === "css") { 382 | apioutput = csspretty(); 383 | } else if (options.lang === "csv") { 384 | apioutput = global.prettydiff.csvpretty(options); 385 | } else if (options.lang === "markup") { 386 | apioutput = markuppretty(); 387 | } else if (options.lang === "text") { 388 | apioutput = options.source; 389 | apidiffout = ""; 390 | } else { 391 | apioutput = jspretty(); 392 | } 393 | if (options.api === "") { 394 | if (options.mode === "analysis" || (options.mode === "parse" && options.parseFormat === "htmltable")) { 395 | finalFile.order[10] = apidiffout; 396 | apioutput = finalFile.order.join(""); 397 | } else if (options.mode === "beautify" && options.jsscope !== "none" && options.lang === "javascript") { 398 | finalFile.order[10] = apidiffout; 399 | finalFile.order[12] = finalFile.script.beautify; 400 | apioutput = finalFile.order.join(""); 401 | } 402 | } 403 | if (options.jsx === true) { 404 | options.autoval = ["jsx", "javascript", "React JSX"]; 405 | } 406 | return output(apioutput); 407 | } 408 | }; 409 | return core(api); 410 | }; 411 | global.prettydiff.edition = { 412 | addon : { 413 | ace: 160307 414 | }, 415 | api : { 416 | dom : 160921, //dom.js 417 | nodeLocal: 160816 //node-local.js 418 | }, 419 | css : 160814, //css files 420 | csspretty : 160902, //csspretty lib 421 | csvpretty : 160816, //csvpretty lib 422 | diffview : 160902, //diffview lib 423 | documentation: 160828, //documentation.xhtml and various guide pages 424 | finalFile : 160816, //HTML report generator 425 | jspretty : 160921, //jspretty lib 426 | language : 160921, //language lib 427 | latest : 0, 428 | lint : 160914, //unit test and lint automation as test/lint.js 429 | markuppretty : 160921, //markuppretty lib 430 | options : 160921, //options management 431 | prettydiff : 160902, //this file 432 | safeSort : 160816, //safeSort lib 433 | version : "2.1.11", //version number 434 | webtool : 160827 435 | }; 436 | global.prettydiff.edition.latest = (function edition_latest() { 437 | return Math.max(global.prettydiff.edition.css, global.prettydiff.edition.csspretty, global.prettydiff.edition.csvpretty, global.prettydiff.edition.diffview, global.prettydiff.edition.documentation, global.prettydiff.edition.finalFile, global.prettydiff.edition.jspretty, global.prettydiff.edition.language, global.prettydiff.edition.markuppretty, global.prettydiff.edition.options, global.prettydiff.edition.prettydiff, global.prettydiff.edition.webtool, global.prettydiff.edition.api.dom, global.prettydiff.edition.api.nodeLocal); 438 | }()); 439 | if (typeof module === "object" && typeof module.parent === "object") { 440 | //commonjs and nodejs support 441 | module.exports.edition = global.prettydiff.edition; 442 | module.exports.meta = global.prettydiff.meta; 443 | module.exports = function commonjs_prettydiff(x) { 444 | return prettydiff(x); 445 | }; 446 | if (process.argv.length === 2 && process.argv[1].indexOf("prettydiff.js") > -1) { 447 | console.log("Please try: node api/node-local.js"); 448 | } 449 | } else if ((typeof define === "object" || typeof define === "function") && (typeof ace !== "object" || ace.prettydiffid === undefined)) { 450 | //requirejs support 451 | define(function requirejs(require, module) { 452 | module.exports.edition = global.prettydiff.edition; 453 | module.exports.meta = global.prettydiff.meta; 454 | module.exports = function requirejs_prettydiff_export(x) { 455 | return prettydiff(x); 456 | }; 457 | //worthless if block to appease RequireJS and JSLint 458 | if (typeof require === "number") { 459 | return require; 460 | } 461 | return function requirejs_prettydiff_module(x) { 462 | prettydiff(x); 463 | }; 464 | }); 465 | } else { 466 | global.prettydiff.prettydiff = prettydiff; 467 | } 468 | }()); 469 | -------------------------------------------------------------------------------- /test/biddletestb/libb/libba.txt: -------------------------------------------------------------------------------- 1 | libba 2 | -------------------------------------------------------------------------------- /test/biddletestb/libb/libbb.txt: -------------------------------------------------------------------------------- 1 | libbb 2 | -------------------------------------------------------------------------------- /test/biddletestb/libb/libbc.txt: -------------------------------------------------------------------------------- 1 | libbc 2 | -------------------------------------------------------------------------------- /test/biddletestb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author" : { 3 | "email": "info@prettydiff.com", 4 | "name" : "Austin Cheney", 5 | "url" : "http://prettydiff.com/" 6 | }, 7 | "bin" : "./bin/biddle", 8 | "bugs" : { 9 | "email": "info@prettydiff.com", 10 | "url" : "https://github.com/prettydiff/biddle/issues" 11 | }, 12 | "description" : "Biddle test app b.", 13 | "homepage" : "http://prettydiff.com/", 14 | "keywords" : [ 15 | "biddle", "test" 16 | ], 17 | "license" : "MIT", 18 | "main" : "biddletestb.js", 19 | "maintainers" : [ 20 | { 21 | "email": "info@prettydiff.com", 22 | "name" : "austincheney" 23 | } 24 | ], 25 | "name" : "biddletestb", 26 | "publication_variants": { 27 | "min" : { 28 | "exclusions": [ 29 | "libb", "testb" 30 | ], 31 | "tasks" : [] 32 | }, 33 | "prod": { 34 | "exclusions": ["testb"], 35 | "tasks" : [] 36 | } 37 | }, 38 | "repository" : { 39 | "type": "git", 40 | "url" : "https://github.com/prettydiff/biddle" 41 | }, 42 | "version" : "98.98.1234" 43 | } 44 | -------------------------------------------------------------------------------- /test/biddletestb/testb/testba.txt: -------------------------------------------------------------------------------- 1 | testba 2 | -------------------------------------------------------------------------------- /test/biddletestb/testb/testbb.txt: -------------------------------------------------------------------------------- 1 | testbb 2 | -------------------------------------------------------------------------------- /test/biddletestb/testb/testbc.txt: -------------------------------------------------------------------------------- 1 | testbc 2 | -------------------------------------------------------------------------------- /today.js: -------------------------------------------------------------------------------- 1 | /*global module*/(function () {"use strict";var today=0;module.exports=today;}()); 2 | --------------------------------------------------------------------------------