npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

deuce

v0.0.1

Published

Deuce is a developer tool for building serverless web applications with YUI.

Downloads

3

Readme

Deuce

Deuce is a developer tool for building serverless web applications with YUI. It allows you to easily create YUI based applications that run locally from the file system. These applications can then be deployed into containers like Cordova (Phonegap) or severed with caching instructions using a cache manifest file.

Installation

> npm install deuce -g
> deuce -h

Usage

With no options provided Deuce will start a connect server on localhost port 3000.

> deuce
> Running at http://localhost:3000/index.html

Once running Deuce will serve a single http://localhost:3000/index.html page. This page defines a YUI global configuration object which includes all ".js" files that are YUI Modules and were found in or below the application directory. Any ".js" files found which were not YUI Modules will still be available but called out on server start. For example, the directory structure below;

./app
	init.js
	/lib
		/my-yui-module.js
		/not-yui.js

When used with Deuce;

> cd ./app
> deuce

Serves the following URI's;

http://localhost:3000/index.html
http://localhost:3000/init.js
http://localhost:3000/lib/my-yui-module.js
http://localhost:3000/lib/not-yui.js

In addition to the above, all YUI Modules are a available on the the URI http://localhost:3000/yui. The version of YUI used is the same as the one installed with Deuce. You can check this by running the following command.

> npm ls yui

Once you have your serverless web application ready to go you can build it with the following command;

> deuce --build ../output/dir

If you want your final application to be minified you can add the "--uglify" option;

> deuce --uglify --build ../output/dir

Helpers

Deuce comes with some helpers to ease your application creation process.

YUI.add("init");

When using the generated "index.html", Deuce will try and .use() a module named "init". In your application directory you can create a ".js" file with any name and insert following.

YUI.add("init", function (Y) {
	Y.log("Hello world!");
});

When you start Deuce if will load the "init" module automatically.

./confs

Any directory that has the name "confs" will be treated as a bucket of configuration files. You can add any number of ".yaml" and ".json" files into this directory. Deuce will map this directory into a YUI Module where each file found will be represented as an attribute of the module. For example;

./app
	/group
		/confs
			home.json
			away.yaml

With this directory structure Deuce will map the URI http://localhost:3000/group/confs.js to a YUI Module like the one below. The name of the YUI Module is the parent directory appended with the string "-confs".

YUI.add("group-confs", function (Y) {
	Y.namespace("confs")["group-confs"] = {
    	"away": {
        	"key": "val"
    	},
    	"home": {
        	"key": "val"
    	}
	};
});

./tmpls

Any directory that has the name "tmpls" will be treated as a bucket of template files. You can add any number of none ".js" files into this directory. Deuce will map this directory into a YUI Module where each file found will be represented as an attribute of the module. For example;

./app
	/group
		/tmpls
			home.html
			away.html

With this directory structure Deuce will map the URI http://localhost:3000/group/tmpls.js to a YUI Module like the one below. The name of the YUI Module is the parent directory appended with the string "-tmpls".

YUI.add("group-tmpls", function (Y) {
	Y.namespace("tmpls")["group-tmpls"] = {
    	"away": "<div>{{key}}</div>",
    	"home": "<span>{{key}}</span>"
	};
});

./langs

Any directory that has the name "langs" will be treated as a directory of YUI Language Modules. You can add any number of ".yaml" and ".json" files into this directory. Deuce will map each file into a YUI Language Module where each file found will become a different language. For example;

./app
	/group
		/langs
			module_en.yaml
			module_en-US.json
			module_en-GB.yaml

With this directory structure Deuce will generate the following URI's where each URI is a YUI Language Module.

http://localhost:3000/group/langs/module_en.js
http://localhost:3000/group/langs/module_en-US.js
http://localhost:3000/group/langs/module_en-GB.js

Customize

Deuce attempts to provide sensible defaults. However, if these do not meet your requirements here are some options that may help you.

init.yml & init.json

You can provide either an "init.yaml" or an "init.json" in your application directory root.

./app
	init.yaml
	init.js

If Deuce encounters one of these at server start it will use the values defined there in place of its defaults. Below are the currently supported keys;

# The URL to use for loading YUI
url: "./yui/yui/yui.js"

# The "YUI.GlobalConfig" that will be used
yui:
    debug: true
    combine: false
    base: "./yui/"

# Arrays to hold strings that you want in either
# the <head> or <body> tags of the html page
html:
    head: 
        - "<title>Deuce</title>"
    body:
        - "<!-- Deuce -->"

index.html

Unless an "index.html" file is found in the application directory root, Deuce will generate one for you. It uses default settings that can be overridden via the configuration files "init.yaml" or "init.json".

<html>
    <head>
        <title>Deuce</title>
        <script src="./yui/yui/yui.js"></script>
        <script type="text/javascript">
        	YUI.GlobalConfig = {
				"debug":true,
				"combine":false,
				"base":"./yui/",
				"modules":{
					"init":{
						"fullpath":"./init.js"
					}
				}
			};
			YUI().use("init");
        </script>
    </head>
    <body>
		<!-- Deuce -->
    </body>
</html>

License

Deuce is released under the MIT license.

(The MIT License)

Copyright (c) 2012 Richard S Allinson [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.