• Stars
    star
    349
  • Rank 117,575 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Install local dependencies as symlinks.

linklocal

Create symlinks to local dependencies in your package.json.

linklocal is a development tool that reduces overheads of breaking your application into small packages. It gives you more expressive power than simple files and folders, yet requires far less overhead than versioning and publishing packages to a local private registry.

Requires npm 2.0.0 and above in order for npm to recognise local paths as dependencies.

Build Status

NPM NPM

Installation

npm install -g linklocal

Usage

linklocal --help

  Usage: linklocal [options] <dir>

  Options:

    -h, --help             output usage information
    -f, --format [format]  output format
    -l, --link             Link local dependencies [default]
    -r, --recursive        Link recursively
    -q, --unique           Only unique lines of output
    -u, --unlink           Unlink local dependencies
    -n, --named            Link only named packages, last argument is cwd
    --absolute             Format output paths as absolute paths
    --files                Output only symlink targets (--format="%h") [default]
    --links                Output only symlinks (--format="%s")
    --list                 Only list local dependencies. Does not link.
    --long                 Output the symlink to hardlink mapping (--format="%s -> %h")
    --no-summary           Exclude summary i.e. "Listed 22 dependencies"
    -V, --version          output the version number

  Examples:

    linklocal                                                 # link local deps in current dir
    linklocal link                                            # link local deps in current dir
    linklocal -r                                              # link local deps recursively
    linklocal unlink                                          # unlink only in current dir
    linklocal unlink -r                                       # unlink recursively

    linklocal list                                            # list all local deps, ignores link status
    linklocal list -r                                         # list all local deps recursively, ignoring link status

    linklocal -- mydir                                        # link local deps in mydir
    linklocal unlink -- mydir                                 # unlink local deps in mydir
    linklocal --named pkgname ../to/pkg                       # link local dep by name/path
    linklocal --named pkgname1 pkgname2 ../to/pkg             # link local deps by name/path
    linklocal unlink --named pkgname ../to/pkg                # unlink local dep by name/
    linklocal --named -r pkgname ../to/pkg                    # link local deps recursively by name/
    linklocal --named -r @scope/pkgname pkgname ../to/pkg     # link local deps recursively by name/ with npm @scope

  Formats:

    %s: relative path to symlink
    %S: absolute path to symlink
    %h: relative real path to symlink target
    %H: absolute real path to symlink target

    relative paths are relative to cwd

About

npm 2.0.0 supports specifying local dependencies in your package.json:

> npm install --save ../apple
> cat package.json
{
  "name": "bowl",
  "version": "1.0.0",
  "dependencies": {
    "apple": "file:../apple"
  }
}

npm install will copy (and npm install) the package into the target's node_module's hierarchy.

This is not an ideal workflow during development: any time you modify your local dependency, you must reinstall it in every location that depends on it. If you do not update all copies, you will have different versions of the same code, probably under the same version number.

Global npm link dependencies are also not ideal as packages clobber each other across projects.

By symlinking local dependencies while in development, changes can be instantly consumed by dependees, effects are limited to the current package and you can be more certain local dependees are using the latest changes.

linklocal symlinks both development and production dependencies, and ignores modules packed by NPM (.tgz).

Examples

Linking

linklocal creates symlinks to any local dependencies it finds in your package.json.

e.g. test/banana/package.json.

{
  "name": "banana",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "apple": "file:../apple"
  }
}

Note file: dependencies are standard syntax in npm 2.x, just so that npm will copy the dependency into place, rather than symlink it. That's what linklocal is for:

# from test/banana
# find local dependencies and symlink them
> linklocal
node_modules/apple -> ../apple

Linked 1 dependency
> # proof:
> ls -l node_modules
total 8
lrwxr-xr-x  1 timoxley  staff  11 20 Sep 01:39 apple -> ../../apple

Unlinking

You can unlink all local links using linklocal --unlink.

# from test/banana
> linklocal --unlink
node_modules/apple -> ../apple

Unlinked 1 dependency

> ls -l node_modules

>

Recursively Linking local dependencies in local dependencies

If your local dependencies have local dependencies, you can use linklocal -r to recursively link all local dependencies:

bowl depends on banana banana depends on apple

With Recursion

apple gets linked into banana

node_modules/apple -> ../apple
node_modules/banana -> ../banana
../banana/node_modules/apple -> ../apple
node_modules/@nuts/almond -> ../almond

Linked 4 dependencies

Without Recursion

apple does not get linked into banana

# from test/bowl
> linklocal
node_modules/apple -> ../apple
node_modules/banana -> ../banana
node_modules/@nuts/almond -> ../almond

Linked 3 dependencies

Linking and Unlinking Packages by Name

# from test/named
> linklocal --named mypackagename ../
node_modules/mypackagename -> ../mypackagename

Linked 1 dependency

When linking local named packages, you may do so regularly or with recursion. The package names should be entered as an unordered list of strings, where the final argument is the relative path to where the source files for these packages are located.

Recommendations

linklocal does not install dependencies of linked dependencies. To have dependencies installed, use timoxley/bulk or xargs in a script like:

{
  "name": "my-app",
  "scripts": {
    "dev": "linklocal link -r && linklocal list -r | bulk -c 'npm install --production'",
    "prepublish": "if [ \"$NODE_ENV\" != \"production\" ]; then npm run dev; fi"
  }
}

Caveats

  • linklocal does not install dependencies of linked dependencies, as such you typically end up installing dependencies of linked dependencies twice: once during npm install, then again after linklocal

See Also

Contributors

Big thanks to:

  • Yoshua Wuyts
  • ben_cripps
  • Vincent Weevers
  • Craig Jefferds
  • amalygin
  • Mikael Brevik

License

MIT

More Repositories

1

functional-javascript-workshop

A functional javascript workshop. No libraries required (i.e. no underscore), just ES5.
JavaScript
2,049
star
2

best-practices

Tidbits of developer best practices from around the web
1,275
star
3

keycode

Convert between keyboard keycodes and keynames and vice versa.
JavaScript
452
star
4

columnify

Create text-based columns suitable for console output. Supports cell wrapping.
JavaScript
425
star
5

npm-run

Run locally-installed node module executables.
JavaScript
183
star
6

polyfill-webcomponents

(deprecated) Browserify-compatible web-component polyfills, courtesy of Polymer
JavaScript
119
star
7

pkgfiles

Sanity check which files you are and aren't about to publish to npm
JavaScript
82
star
8

npm-which

Locate a program or locally installed node module's executable
JavaScript
78
star
9

offset

Get offset of an element within the document
JavaScript
59
star
10

wcwidth

Port of C's wcwidth() and wcswidth()
JavaScript
53
star
11

npm-path

Get a PATH containing locally installed module executables.
JavaScript
49
star
12

colornames

Map color names to HEX color values
JavaScript
45
star
13

react

Emit change events whenever object changes. Compatible with component/reactive.
JavaScript
41
star
14

sift

Fast String Distance (SIFT) Algorithm
JavaScript
40
star
15

npm3

Use npm v3 alongside your currently installed npm.
JavaScript
34
star
16

pkgcount

Produce a report on number of duplicate packages in node_modules.
JavaScript
29
star
17

scroll-position

Fire events when scrolling over dom elements
JavaScript
28
star
18

next-tick

process.nextTick for browser
JavaScript
25
star
19

robotlegs-utilities-UndoableCommand

Undoable Command Classes for Robotlegs Framework
JavaScript
24
star
20

npm-tutor

npm tutor for nodeconf 2014
JavaScript
23
star
21

saltmine

Arbitrary computation on the GPU using WebGL.
JavaScript
22
star
22

mdm-tunnel

A tunnel for getting behind NATs
JavaScript
20
star
23

cruft

Delete cruft from npm packages
JavaScript
19
star
24

nim

Command-line tool for inspecting node library objects, function implementations and listing properties – with syntax highlighting.
JavaScript
19
star
25

adventure-map

Simple exercise loader & generators for substack/adventure.
JavaScript
19
star
26

tojson-loader

WebPack Loader. Generate JSON assets at build-time.
JavaScript
18
star
27

css-path

Get CSS path to an element.
JavaScript
18
star
28

chimes

`Array.prototype` iteration methods for any iterator.
JavaScript
18
star
29

to-factory

Convert ES6 classes into factory functions so they can be called with or without new.
JavaScript
18
star
30

graphs

An intuitive data structure for graphs, implemented using ES6 data structures.
JavaScript
17
star
31

canvas-noise

Generate noise on a canvas.
JavaScript
16
star
32

serializerr

Convert Errors & Objects into an easily-serialized vanilla Object.
JavaScript
15
star
33

osi-licenses-full

All OSI-approved licenses as markdown
JavaScript
15
star
34

split-object

Work with Objects using built-in functional Array methods.
JavaScript
14
star
35

assertf

assert with printf message formatting
JavaScript
14
star
36

pkgrep

Powerful CLI tool to find, filter & format package data in node_modules.
JavaScript
13
star
37

npm-next

Wraps the latest unstable version of npm with different name so you can test alongside stable npm.
JavaScript
12
star
38

pkill

Convenience wrapper around `pkill(1)`
JavaScript
12
star
39

async-compose

Compose multiple async functions together to operate on a result.
JavaScript
11
star
40

voxel-real-physics

"Real" physics for VoxelJS with CANNON.JS
JavaScript
11
star
41

node-webhooks

easily create webhooks
JavaScript
10
star
42

scriptloader

Absurdly simple on-demand script loader.
JavaScript
10
star
43

protochain

Get the prototype chain of an object or primitive as an Array.
JavaScript
9
star
44

get

Create functions for use with map, reduce, filter, etc. that get object properties without need for anonymous wrappers.
JavaScript
9
star
45

color-convert

Convert colors between RGB, HSL & HSV.
JavaScript
9
star
46

express-koans

WIP Express 3 Koans
JavaScript
9
star
47

til

Today I learned
8
star
48

file-uploader

Programmatic multipart file uploads
JavaScript
8
star
49

enode

Easily harness the power of DNode/Upnode
JavaScript
8
star
50

beforefn

Execute a function before a function.
JavaScript
8
star
51

afterfn

Invoke a function after a function.
JavaScript
7
star
52

neuquant

NeuQuant Neural-Net Quantization Algorithm
JavaScript
7
star
53

guardfn

Conditionally execute a function
JavaScript
7
star
54

voxel-merge

Merge voxel chunks into convex volumes.
JavaScript
7
star
55

to-array

Convert an array-like object into an Array.
JavaScript
7
star
56

installed

Read all the installed packages in a folder, and produce an Array of all the data.
JavaScript
7
star
57

pkgresolve

Resolve a dependency from within the context of another package.
JavaScript
6
star
58

stitchup

Command-line stitchjs. Easily package and minify Javascript & Coffeescript CommonJS modules. Individual modules can be imported in the browser via require()
CoffeeScript
6
star
59

midi-experiment

JavaScript
6
star
60

assert

assert module ported from Node.JS for use as a component in the browser.
JavaScript
6
star
61

xpath

XPath utilities extracted from Firebug.
JavaScript
6
star
62

grunt-ember

Collate Ember templates into a single file
JavaScript
6
star
63

candlelightproject

Android IPv6 Geo-Location Based Wireless Mesh Network
Java
6
star
64

opengl-es2-docset

Dash docset for OpenGL ES 2.0 (i.e. webgl)
HTML
5
star
65

element-collection

Provide enumerable methods (find/select/filter) to collections of DOM Elements
JavaScript
5
star
66

ordered-set

A performant ES6 Set subclass that defines custom iteration order.
JavaScript
5
star
67

fnfn

Add before/after/around/guard functions to an API.
JavaScript
5
star
68

statement

A State Machine. Under Construction.
JavaScript
5
star
69

element-selector

Use mouse to select elements on the screen
JavaScript
4
star
70

npm-fresh

Keep your npm cache fresh.
JavaScript
4
star
71

cellutron

My first attempt at a game. Top down 'shooter' style. Pure AS3. Uses box2d physics, TweenMax for tweening & Flint for some particles.
ActionScript
4
star
72

npm-prev

Wraps previous stable version of npm so you can run it alongside other npm versions
JavaScript
4
star
73

candlelight

Android Mesh Network
3
star
74

silk-app-examples

Gregfroese's Silk Example Components
PHP
3
star
75

pipe-graph

Generate graphs of your streams.
JavaScript
3
star
76

overshadow-listeners

Add an event listener before existing listeners.
JavaScript
3
star
77

signalfn

Simple signalling
JavaScript
3
star
78

es5-workshop

Introduction to ES5 methods.
JavaScript
3
star
79

slow-install

An npm package that's slow to install. Slowness is configurable.
JavaScript
2
star
80

get-descriptor

Prototype-aware Object.getOwnPropertyDescriptor
JavaScript
2
star
81

eventsource-stream

Stream events to the browser as server-sent events.
JavaScript
2
star
82

bin-path

Get paths to module executables
JavaScript
2
star
83

node-xmlrpc-multicall

system.multicall for node-xmlrpc
JavaScript
2
star
84

attribute-binding

Bind to incoming data via attributes on your custom elements.
JavaScript
2
star
85

component-server

Easily serve local components as dependencies.
JavaScript
2
star
86

statemachine

A State Machine. Under Construction.
JavaScript
2
star
87

xpath2css

Convert simple xpaths to CSS selectors.
JavaScript
2
star
88

namefn

Rename a function.
JavaScript
2
star
89

lzw

LZW Encoder
JavaScript
2
star
90

component-badge

Generate component badges. WIP
JavaScript
2
star
91

backbone-events

Backbone.Events API as a component
JavaScript
2
star
92

browserify-slides

SingaporeJS 17 Feb 2014
JavaScript
2
star
93

component-dashdoc

Generate a Dash docset for published components.
JavaScript
2
star
94

tapef

Tape API with Mocha's error output. A hack.
JavaScript
2
star
95

switchstream

switch between output streams. e.g. a filter that pipes valid & invalid data to different streams
JavaScript
2
star
96

dom-support

Component to test browser feature support.
JavaScript
2
star
97

pincushion

JavaScript
2
star
98

expressions

Grab bag of template binding expressions.
JavaScript
2
star
99

overlay

Generate overlays over DOM elements.
JavaScript
2
star
100

npm-home

Chrome Extension. Redirects to a package's github page from npm.org. Simulates original behaviour of `npm home`.
JavaScript
2
star