Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

duo

duojs403MIT0.15.7

A next-generation package manager for the front-end

readme

duo

npm version build status Join the chat at https://gitter.im/duojs/duo

Duo is a next-generation package manager that blends the best ideas from Component, Browserify and Go to make organizing and writing front-end code quick and painless.

Features

  1. has first-class support for Javascript, HTML and CSS
  2. exposes a unix-y command line interface
  3. pulls source directly from GitHub with semantic versioning
  4. supports source transforms, like Coffeescript or Sass
  5. does not require a manifest

Installation

Install Duo straight from npm with:

$ npm install -g duo

Getting Started

To get started just write normal Javascript, requiring dependencies straight from the file system or from GitHub as you need them:

var uid = require('matthewmueller/uid');
var fmt = require('yields/fmt');

var msg = fmt('Your unique ID is %s!', uid());
window.alert(msg);

Then use duo to install your dependencies and build your file:

$ duo index.js

Finally, drop a single <script> onto your page and you're done!

<script src="build/index.js"></script>

Same goes for CSS! You can require dependencies and assets from the file system or straight from GitHub:

@import 'necolas/normalize.css';

body {
  color: teal;
  background: url('./background-image.jpg');
}

Then bundle up your CSS with duo:

$ duo index.css

And add your bundled-up stylesheet to your page!

<link rel="stylesheet" href="build/index.css">

Authenticate with Github

We recommend that you authenticate with Github so you can increase your rate limit and allow you to pull from private repositories. To do that, add the following entry to your ~/.netrc file:

machine api.github.com
  login <username>
  password <token>

You can create a new token here: https://github.com/settings/tokens/new

Debugging

If you run into an issue with Duo, often times you can resolve it by prepending DEBUG=duo* to your $COMMAND:

$ DEBUG=duo* $COMMAND

Example:

$ DEBUG=duo* duo index.js

If you can't figure it out, you should open an issue: https://github.com/duojs/duo/issues

Test

Download this repository and run:

make test

Authors

License

The MIT License

Copyright © 2014

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.

changelog

0.15.7 / 2016-07-21

  • bump duo-main (and css-compat)
  • update node versions

0.15.6 / 2016-04-20

  • fixing bug in local path resolve

0.15.5 / 2016-02-01

  • package: update duo-package to 0.10.3

0.15.4 / 2016-02-01

  • package: update duo-package to 0.10.2

0.15.3 / 2015-08-05

  • sharing cached packages between parallel cli builds

0.15.2 / 2015-07-28

  • fix: need to store a package ref for this cache to work

0.15.1 / 2015-07-28

  • fix: handling parallel package resolution better

0.15.0 / 2015-07-27

  • add: duo-authenticate
  • add: duo/duo-install --update
  • bugfix: check GH_TOKEN env var for token

0.14.1 / 2015-07-22

  • bug: allowing files with dots in the name to be required
  • bug: fixing an error caused by an empty string as the entry source code

0.14.0 / 2015-07-13

  • updating internals (eg: duo-package, duo-css-compat)

0.13.2 / 2015-07-04

  • adding unyield to cache-related methods

0.13.1 / 2015-07-03

  • include duo as an option to altPlugins

0.13.0 / 2015-07-03

  • adding a hash function that can be used by plugins
  • overhauling cache with new duo-cache module

0.12.3 / 2015-06-24

  • upgrading css-compat to fix token bug

0.12.2 / 2015-06-23

  • meta: adding eslint
  • meta: upgrading deps and updating tests
  • build: removing sync file io

0.12.1 / 2015-06-17

  • No longer forcefully closing process on errors (waiting until call stack clears)

0.12.0 / 2015-06-01

  • Added: duo-install(1)

0.11.4 / 2015-05-01

  • Upgrading stream-log

0.11.3 / 2015-04-29

  • Adding 'wrote' log event (uses green for success!)

0.11.2 / 2015-04-09

  • Merge pull request #457 from duojs/clean-cache-quiet
  • moving gitter badge alongside other badges
  • fixing arrays for alt plugins
  • removing only in test
  • adding a quiet mode for clean-cache

0.11.1 / 2015-03-29

  • Bugfix: removing gnode from JS API
  • Adds entry to alternate plugins API

0.11.0 / 2015-03-29

  • BREAKING removing gnode and native node 0.10 support (see docs)
  • Adding travis tests for node 0.12 and iojs
  • Updating duo-package and duo-pack
  • Adding support for "alternate plugins" (see docs)

0.10.0 / 2015-03-19

  • BREAKING now returning a { code, map } object from Duo#run()
  • Added Duo#sourceMap() to JS API
  • Added external source-maps support with the --external-source-maps CLI flag
  • Added duo clean-cache to CLI
  • Updated duo-css-compat to have cleaner name displayed in CLI

0.9.6 / 2015-2-28

  • Fixing non-js/css assets being processed as entry files.

0.9.5 / 2015-2-28

  • Updating duo-package (handling gh token in duo directly)

0.9.4 / 2015-2-13

  • Cleaning up "quiet" and "verbose" mode behavior

0.9.3 / 2015-2-12

  • Fixing directory processing for entries

0.9.2 / 2015-1-19

  • Bumps duo-pack version to fix off-by-one sourcemap bug (#125)

0.9.1 / 2015-1-5

  • Fixing bug that caused a single folder argument to be treated as a missing subcommand
  • Handling syntax errors in manifest files more gracefully

0.9.0 / 2014-12-12

  • BREAKING removing some magic from the cli, making all arguments treated the same
  • allow modules to export an array of pre-configured plugins
  • adding ability to --use multiple times, while retaining backwards compatibility
  • adding a test for a non-default install location
  • using installTo instead of hard-coding 'components', improving test reliability too
  • adding File#local() and File#remote() + tests (fixes #402)

0.8.10 / 2014-11-10

  • adding test for include deps parsing
  • allowing includes to require other named includes
  • adding way to check if something has already been included

0.8.9 / 2014-11-03

  • An imperfect fix for multiple symlink creation.
  • Add "cache" flag to API documentation

0.8.8 / 2014-10-27

  • speed up CLI with caching and lazy-loading big modules
  • fix: require conflicts
  • deps: remove redundant deps
  • bump file-deps
  • update timeout for travis

0.8.7 / 2014-10-24

  • fix: symlink => copy should not empty target file
  • authentication no longer required :-)

0.8.6 / 2014-10-24

  • bump duo-pack
  • add umd (--standalone)

0.8.5 / 2014-10-20

  • Bump: Update debug
  • Fixed: --use should look for plugin in working directory
  • Fixed: getting cli --output to be understood
  • Added: support for working with arbitrary assets to duo
  • Removed: incorrect test
  • Added: Clarify all the internal methods and provide examples in the source

0.8.4 / 2014-09-14

  • Added: capability to bypass cache
  • Bumped: gnode to 0.1.0
  • Bumped: duo-pack to fix duplicate CSS
  • Refactored: extract out conditionals
  • Added: tests for new accessors
  • Refactored: change accessors to make them all consistent
  • Refactored: clean up style to make the repository consistent

0.8.3 / 2014-09-04

  • Bump: duo-parse to fix * issue (component/emitter@*)
  • Added: CSS Compatibility for CSS-based Components

0.8.2 / 2014-08-31

  • Fixed: CSS assets should be relative to entryfile, not root
  • Windows: do not parse dep as an url
  • Windows: replace cross-spawn with win-fork
  • Tests: test examples
  • Refactored: duo#dependency to have the signature dependency(dep, file, entry)
  • Refactored: duo#resolve to have signature resolve(dep, file, entry)
  • Refactored: move duo#parse into separate repo
  • Fixed: for remote packages with absolute paths
  • Fixed: --quiet flag when --use'ing plugins
  • Windows: fixed path root checking in findroot()
  • CLI: Use safer way to check if a path is a file in duo
  • Added: support require('..'). closes: #231

0.8.1 / 2014-08-21

  • do not remove duplicate asset references

0.8.0 / 2014-08-20

  • update css example
  • use relative CSS urls instead of absolute
  • assets should be written/symlinked to duo.assets() even if the assets were cached
  • add tests for $ duo in.js out
  • $ duo in.js out should write to out/ and not print to stdout
  • _duo: Fix logging from streaming from stdin

0.7.7 / 2014-08-20

  • fix silly typo

0.7.6 / 2014-08-20

  • added duo.copy() to copy assets instead of symlink. closes: #208
  • bump duo-watch
  • update logo :-D
  • cleaning up breaking ls/duplicates tests
  • adding tests for CLI --use
  • Improving --use in CLI
  • fix cli root resolving, closes #202

0.7.5 / 2014-08-18

  • fix duo#write() when entry file's type changes
  • add cli documentation and remove dead links

0.7.4 / 2014-08-17

  • fix watch to repeat the original command
  • edited readme, pulled docs into /docs folder

0.7.3 / 2014-08-16

  • fix string-to-js

0.7.2 / 2014-08-16

  • bump string-to-js to support arbitrary files
  • bump duo-pack to not duplicate CSS imports

0.7.1 / 2014-08-16

  • .use(fn|gen) idempotent across duo instances
  • added -w, --watch to CLI
  • fix module/ example
  • support running tests with $ mocha on node 0.10.x
  • add node_modules to default makefile task so it installs node_modules if not installed

0.7.0 / 2014-08-15

  • duo(1): update CLI to support multiple entries
  • refactor entrypoint so duo.entry() is idempotent
  • test: added tests for cli
  • duo(1): fix printing
  • pass entry key to mapping
  • duo.js: Fix jsdoc
  • Added coverage
  • duo.js: Remove #readjson()
  • test: Verify #install() works
  • duo.js: Fix #install(path)

0.6.2 / 2014-08-11

  • duo(1): fix undefined "path"
  • tests: add cli tests
  • test: duo -> duo-api
  • fix duo#write([fn])
  • remove commented code

0.6.1 / 2014-08-09

  • add .npmignore

0.6.0 / 2014-08-09

  • bin/_duo: added support for stdin
  • lib/duo: added duo#src(src, [type])
  • lib/duo: update concurrency to 50
  • bin/_duo: Add --quiet flag
  • bin/_duo: adding basic plugin support

0.5.5 / 2014-08-08

  • downgraded debug so it prints out using stderr
  • fixing Duo#assets() to correctly reference project root
  • adding output dir option to CLI
  • parse.js: Add support for 'provider/user/repo'
  • set the default concurrency to 10
  • add npm install to make
  • bin/_duo: Spawn subcommands through gnode
  • bin/_duo: Fix trailing whitespace
  • remove duplicate installs in duo(1). closes: #126
  • test to make sure we're ignore http deps in css
  • fix cache without deps. closes #120

0.5.4 / 2014-08-03

  • bump string-to-js to fix json loading. closes: #121
  • fix empty css @import issue. closes: #119.
  • support concurrent writes to mapping.

0.5.3 / 2014-08-02

  • bump duo-package.
  • Duo#auth(user, token) => Duo#token(token)
  • using gnode to support node v0.10 w/o extra effort needed internally (@dominicbarnes)

0.5.2 / 2014-08-01

0.5.1 / 2014-08-01

  • Bumped because of NPM publish fail ("shasum check failed") (@eudinaesis)

0.5.0 / 2014-07-30

  • Breaking: The entry is no longer optional, and you can no longer use a component.json as an entry
  • Added a File abstraction to contain the file state.
  • Added a transform singleton that uses https://github.com/matthewmueller/step.js
  • Broke duo#dependencies() out. Now we do a lot of heavy lifting in duo#dependency() now.
  • Added yieldable() helper to support yield duo.run() and duo.run(fn) without the extra duo#_run() fn.
  • fix duo(1) for components with js and css main object
  • duo-duplicates(1): remove / - replacement
  • remove quiet option until we have a need for it
  • add support for 'main' objects. fix logging
  • added multiple builds with a main array and lots of usability improvements
  • clean up auth

0.4.1 / 2014-07-02

  • fix: make sure / works only in css mode
  • fix parsing ambiguity: require(user/repo@ref/path) => require(user/repo@ref:/path)
  • clean up example
  • add css support

0.3.4 / 2014-06-30

  • rootext => type

0.3.3 / 2014-06-30

  • fix duo#use

0.3.2 / 2014-06-27

  • fix: edge-case extensions org/pkg.js was eql to org/pkg.js-whatever.

0.3.1 / 2014-06-25

  • npm is being wierd

0.3.0 / 2014-06-21

  • duo#run([fn]) now supports an optional callback function

0.2.9 / 2014-06-21

  • expose entry key in duo.json
  • duo(1): add --root option

0.2.8 / 2014-06-20

  • bundles: support multiple bundles within duo.json (for caching)
  • update jade example

0.2.7 / 2014-06-19

  • fix: ambiguous repo name see #71
  • add more tests

0.2.6 / 2014-06-19

0.2.5 / 2014-06-19

  • component compatibility: support deps with repos that have an extension (ex. guille/ms.js => require('ms'))
  • duo.entry(file) should also work with full file paths

0.2.1 / 2014-06-18

  • duo(1): fix, cast --development

0.2.0 / 2014-06-18

  • fix: sourcemaps
  • fix: new Error typo
  • remove better-error dep
  • make: allow custom mocha reporter
  • duo-duplicates: show total size
  • duo-duplicates: fix to show real size
  • added tests for duo#include(name, src)
  • added duo.include(name, src) + jade example
  • Merge pull request #53 from component/fix/duo-ls
  • Merge pull request #56 from component/fix/no-deps
  • added regenerator plugin example
  • fix: build with no deps
  • duo-ls(1): use stream-log
  • pack: sort names before packing, fixes #49
  • thunkify => thunk
  • build: allow entries to be .coffee, .styl, etc. fix generator plugins
  • deps: pin duo-pack, duo-package
  • tests: add rebuild .mtime tests and fix
  • tests: add idempotent test and fix

0.1.0 / 2014-06-10

  • pin duo-pack, duo-package
  • perf: dont visit files more than once
  • duo(1): add --concurrency option back
  • logs: show less logs and add --verbose, closes #43
  • resolve(): fix ../file.ext resolution
  • tests: add resolve-file test
  • add global option, closes #21
  • add initial tests
  • duo(1): support out.js, closes #24
  • duo(1): add --development, closes #22
  • duo(1): log to stderr in order to keep the build.js working
  • refactor parse
  • update file-deps and remove file-pipe
  • cleanup package.json and resolve to master for duo-* packages
  • cleanup. more logging. better errors.
  • duo-duplicates(1): exit with 1 when duplicates are found
  • duo-duplicates(1): clean a bit and add sizes, closes #12
  • require-syntax: move from user:project to user/project
  • fix: set entry() as entry in build.js
  • update duo(1)
  • update duo-ls(1) and duo-duplicates(1).
  • add plugin support
  • depend on duo-package master
  • build: add initial css support
  • fix: dont ignroe all deps when a single dep is not resolved
  • examples: update entry example
  • resolve: when ./path, try ./path/index.ext and ./path.ext
  • Pack() and return a string