Coder Social home page Coder Social logo

alexandergugel / ied Goto Github PK

View Code? Open in Web Editor NEW
2.0K 38.0 53.0 4.15 MB

:package: Like npm, but faster - an alternative package manager for Node

Home Page: http://alexandergugel.github.io/ied

License: MIT License

JavaScript 98.47% Makefile 1.53%
package-manager node

ied's Introduction

ied

Travis npm Inline docs

__/\\\\\\\\\\\__/\\\\\\\\\\\\\\\__/\\\\\\\\\\\\____
 _\/////\\\///__\/\\\///////////__\/\\\////////\\\__
  _____\/\\\_____\/\\\_____________\/\\\______\//\\\_
   _____\/\\\_____\/\\\\\\\\\\\_____\/\\\_______\/\\\_
    _____\/\\\_____\/\\\///////______\/\\\_______\/\\\_
     _____\/\\\_____\/\\\_____________\/\\\_______\/\\\_
      _____\/\\\_____\/\\\_____________\/\\\_______/\\\__
       __/\\\\\\\\\\\_\/\\\\\\\\\\\\\\\_\/\\\\\\\\\\\\/___
        _\///////////__\///////////////__\////////////_____

An alternative package manager for Node.

  • Concurrent Installations - ied installs sub-dependencies in parallel. This means that the download of a dependency might have been completed before that of its parent or any of its siblings even started.

  • Correct Caching - Downloaded packages are being cached locally. Similarly to the entry dependencies stored in node_modules, they are being identified by their checksums. Therefore we can guarantee the consistency of the cache itself without (manually) invalidating dependencies (e.g. due to overridden version numbers).

  • node_modules as CAS - Packages are always being referenced by their SHA-1 checksums. Therefore a node_modules directory can be considered to be a Content Addressable Storage, meaning that packages are being identified by their contents, not by arbitrary identifiers, such as package names that are not guaranteed to be unique across different registries.

  • Flat node_modules - Due to the CAS-based design, conflicts due to naming collisions are more or less impossible. Therefore all dependencies can be stored in a flat directory structure. Circular dependencies and dependencies on different versions of the same packages are still being handled correctly.

  • Guaranteed uniqueness - Since the directory in which a specific package is being stored is determined by its shasum, identical packages can't conflict due to their location in the file system itself. This also means that the same dependency won't be installed more than once. Dependencies don't need to be explicitly declared as peerDependencies, since shared sub-dependencies are the default, not an option.

  • Atomic installs - The atomicity of installs can be ensured on a package-level. "In progress" downloads are being stored in node_modules/.tmp and moved into node_modules once their download has been completed. In order to prevent deadlocks, packages that have circular dependencies are exempt from this limitation. In most cases however, the node_modules directory is consistent at any given point in time during the main installation procedure.

  • Package names as links - While packages are being referenced by their shasum internally, they can still be required via their human-readable equivalent name. Package names themselves are simply symbolic links to the actual content-addressed package itself. A nice side-effect of this design is that in contrast to other package managers, you can not accidentally require a sub-dependency that hasn't been installed as such.

  • Semantic Versioning - Semantic version numbers are being resolved correctly.

  • Arbitrary package groups - Packages can be grouped into "package groups", such as dependencies and devDependencies. Dependencies can be installed exclusively based on the group they are in.

Internals

Under the hood, ied maintains an "object database", similar to git. Instead of storing packages by some arbitrary name, a SHA1-checksum is being generated to approximate their contents. The checksums can not only be used for guaranteeing a certain level of trust and consistency, but they also simplify the algorithm through which dependencies are being managed.

The algorithm through which packages are being installed guarantees consistency through atomic installs. The installation of a package either fails or succeeds, but at no point in time can a dependency itself be required without having its own sub-dependencies installed (with the exception of shared circular dependencies).

The checksum of a package is based on the contents of the package itself, not of its sub-dependencies. Therefore the validity of a package can be verified by hashing the package itself. Subsequent dependency updates have no effect of the generated checksum.

Since node_modules is essentially a file-system based content addressable storage, multiple versions of the same package can co-exist in the same project. In order to expose dependencies via CommonJS, symbolic links are being created that reference a specific version of the package. This has multiple advantages:

  1. Undeclared dependencies that have been installed as sub-dependencies of "direct" dependencies are unlikely to be required "accidentally".

  2. There is no need to "manually" (as in additionally to the installation procedure itself) de-duplicate the dependency graph. As long as the uniqueness of filenames itself can be guaranteed on an OS-level, it is impossible to install the same package twice. This does not prevent users from installing different versions of the same dependency as long as the content is different (whereas a different version declared in the package.json counts as different contents).

  3. Shorter pathnames and less problems due to OS-level limitations (as in Windows where the maximum path length is limited).

  4. Additional application-level startup performance improvements. require needs to traverse less directories. A limited number of symbolic links need to be followed. This performance improvement is primarily useful for continuously running tests, where startup time is actually noticeable for larger test suits.

Directory Structure

The used directory structure is primarily optimized for reducing the amount of IO interaction with the file system during subsequent installations and guaranteeing the consistency of installed packages.

A consequence of the require.resolve algorithm used by Node, all packages need to be stored in a project-level node_modules directory. This directory is completely flat on a package-level, meaning that there are no nested packages inside it.

Instead each package is being stored in its content-addressed directory. Such a directory has two sub-directories:

  • package - This is where the unpacked package contents is being stored. At no point in time will this directory be modified. This enables us to verify the integrity of the package at a later point in time by comparing the actual checksum to the one defined by other dependents or registries.

  • node_modules - Sub-dependencies of the dependency installed in package are being referenced by symbolic links in node_modules of the package itself. require.resolve will fall-back to this level after failing to locate a dependency in package. This means checked in dependencies are still supported, provided that their sub-dependencies are also available (anywhere in the dependency graph).

On a project level, the node_modules directory contains the fetched packages, installed dependencies and links that expose the packages to user-land via require.

A comparison of sample directory structures produced by ied, npm 2 and npm 3 is available as a GitHub Gist.

Why?

The original idea was to implement npm's pre-v3 install algorithm in as few lines as possible. This goal was achieved in c4ba56f.

Currently the main goal of this project is to provide a more performant alternative to npm.

Installation

The easiest way to install ied is using npm:

npm i -g ied

Alternatively you can also "bootstrap" ied. After an initial installation via npm, ied will install its own dependencies:

git clone https://github.com/alexanderGugel/ied ied && cd $_ && make install

Usage

The goal of ied is to support ~ 80 per cent of the npm commands that one uses on a daily basis. Feature parity with npm other than with its installation process itself is not an immediate goal. Raw performance is the primary concern during the development process.

A global configuration can be supplied via environment variables. NODE_DEBUG can be used in order to debug specific sub-systems. The progress bar will be disabled in that case.

Although run-script is supported, lifecycle scripts are not.

At this point in time, the majority of the command API is self-documenting. More extensive documentation will be available once the API is stabilized.

A high-level USAGE help is also supplied. The main goal is to keep the API predictable for regular npm-users. This means certain flags, such as for example --save, --save-dev, --save-optional, are supported.

  ied is a package manager for Node.

  Usage:

    ied [command] [arguments]

  The commands are:

    install     fetch packages and dependencies
    run         run a package.json script
    shell       enter a sub-shell with augmented PATH
    ping        check if the registry is up
    config      print the used config
    init        initialize a new package
    link        link the current package or into it
    unlink      unlink the current package or from it
    start       runs `ied run start`
    stop        runs `ied run stop`
    build       runs `ied run build`
    test        runs `ied run test`

  Flags:
    -h, --help          show usage information
    -v, --version       print the current version
    -S, --save          update package.json dependencies
    -D, --save-dev      update package.json devDependencies
    -O, --save-optional update package.json optionalDependencies
    -r, --registry      use a custom registry
                        (default: http://registry.npmjs.org/)
    -b, --build         execute lifecycle scripts upon completion
                        (e.g. postinstall)

  Example:
    ied install
    ied install <pkg>
    ied install <pkg>@<version>
    ied install <pkg>@<version range>

    Can specify one or more: ied install semver@^5.0.1 tape
    If no argument is supplied, installs dependencies from package.json.
    Sub-commands can also be called via their shorthand aliases.

  README:  https://github.com/alexanderGugel/ied
  ISSUES:  https://github.com/alexanderGugel/ied/issues

Development notes

To run the test suite, run npm test. The test suite mocks all HTTP requests, with fixtures cached inside fixtures/generated/. If you make new tests that perform HTTP requests, it'll be saved there.

npm test

Credits

Some ideas and (upcoming) features of ied are heavily inspired by Nix, a purely functional package manager.

License

Licensed under the MIT license. See LICENSE.

ied's People

Contributors

alexandergugel avatar alindeman avatar arjanschouten avatar chaconnewu avatar joshschreuder avatar just-boris avatar mgcrea avatar mrmlnc avatar nisaacson avatar rstacruz avatar siegfriedehret avatar stephanebachelier avatar twhid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ied's Issues

Shared CAS

This seems like it will eventually be possible: instead of symlinking node_modules/03abd30a... into node_modules/lodash, you can symlink it from ~/.ied/modules/. If you include the node version in the hash computation for compiled modules (those that have node.gyp), it'd even be cross-compatible even with multiple node versions installed in your system.

Known issue with eslint

Currently standard is not supported.

This is due to a reported bug in eslint: eslint/eslint#4263

The error will be along the lines of:

 % ./node_modules/.bin/standard                                                                                                          ied/example (master) Alexanders-MacBook-Pro
/Users/alex/repos/ied/example/node_modules/2f013912b2794ddb30bbaa89dc13fb3a990cc72b/package/rc/.eslintrc
standard-react
standard: Unexpected linter output:

Error: Cannot find module 'eslint-config-standard-react'
Referenced from: /Users/alex/repos/ied/example/node_modules/2f013912b2794ddb30bbaa89dc13fb3a990cc72b/package/rc/.eslintrc
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at readConfigFromFile (/Users/alex/repos/ied/example/node_modules/a75aaf07e28650772ed0e70daa2ce083079b6514/package/lib/config.js:158:44)
    at loadConfig (/Users/alex/repos/ied/example/node_modules/a75aaf07e28650772ed0e70daa2ce083079b6514/package/lib/config.js:179:22)
    at /Users/alex/repos/ied/example/node_modules/a75aaf07e28650772ed0e70daa2ce083079b6514/package/lib/config.js:210:46
    at Array.reduceRight (native)
    at loadConfig (/Users/alex/repos/ied/example/node_modules/a75aaf07e28650772ed0e70daa2ce083079b6514/package/lib/config.js:194:36)
    at new Config (/Users/alex/repos/ied/example/node_modules/a75aaf07e28650772ed0e70daa2ce083079b6514/package/lib/config.js:388:38)

If you think this is a bug in `standard`, open an issue: https://github.com/feross/standard/issues

Would not work on OSX with multiple drive ( at least by default )

Here's the error :

[====                          ] 11.51%/usr/local/lib/node_modules/ied/lib/install_cmd.js:63
        if (err) throw err
                 ^

Error: EXDEV: cross-device link not permitted, rename '/var/folders/yn/rs_xqqsn3vv8ftktwl_1l0_w0000gn/T/7ec9f2a7-4722-4ddf-9717-28bb2e7c8196' -> '/Volumes/Macintosh HD 2/dev/prs/emoji/node_modules/7d3b63a17887e9e2c2bf55dbd3318fe34a39d1e7'
    at Error (native)

Reproduce :

  1. install using nvm, node 0.12, and fish on macosx using npm i -g ied
  2. go to any complex node project directory ( not tried on a trivial one, but tried on 3 complex node projects )
  3. do rm -rf node_modules
  4. do ied i
  5. get this kind of error every time

BTW, it was really fast to get to this error, ied seems a great idea besides this bug

Missing dependency

First of all: wow, ied is remarkably fast. I love the nix-like architecture, and the small size of the codebase.

I was trying it out with socket.io and ran into an issue with a missing engine.io dependency. It also seems to not be building binary deps? (I actually think opting into these, and leaving them out by default would be swell!)

Here's a gifcast showing my problem
ied

Roadmap

I'd like to contribute more feature work, but it'd be nice if there was a roadmap to see what we can do. TODO.md looks like it hasn't been updated in a while, and doesn't expound on things (like "allow running npm and ied in the same project" — what's to do there?)

Name in poor taste?

Just throwing it out there. I'm sure it's not intentional, but — especially given current state of affairs in the world — another name might not be a bad idea.

Error: EXDEV, rename

Just tried ied install restify in an empty directory. It failed almost immediately with:

$ ied install restify
[==============================] 100.00%/Users/jclulow/.node/node_modules/ied/lib/install_cmd.js:63
        if (err) throw err
                       ^
Error: EXDEV, rename '/var/folders/p3/dwph0qjj02g5fmxwmczcbpgc0000gn/T/11fc00f7-f718-4fc9-92a5-f0b451bff06d'
    at Error (native)

I haven't really dug into the code, but if we assume this is actually a rename(2) call, it is likely failing because you're trying to rename something from somewhere in TMPDIR to my working directory -- which happens to be on a different filesystem:

       EXDEV
                       The links named by old and new are on different file
                       systems.

(Node version v0.12.7, operating system is Mac OS X 10.11)

Suggestion: Make ied interactive

Looks great, btw! Gave it a 👍

Just a suggestion, you can shoot this down if you want:

Vorpal is a recent CLI framework which would make ied into an interactive app. With this, you can run it straight from the terminal and have it execute a single command and then exit as it does now; or you can have the app remain alive in an interactive prompt, sort of giving it its own namespace. In this, you could do some awesome things such as providing tabbed auto-completion of available packages. Here's some examples of what you can do with Vorpal. If you have any questions, just let me know!

No support for --global option?

I encountered the following error.

$ ied i -g jshint
module.js:339
    throw err;
    ^

Error: Cannot find module '/Users/skatsuta/package.json'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at installCmd (/usr/local/lib/node_modules/ied/lib/install_cmd.js:18:15)
    at /usr/local/lib/node_modules/ied/bin/cmd.js:56:7
    at Object.<anonymous> (/usr/local/lib/node_modules/ied/bin/cmd.js:100:2)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)

Doesn't ied support --global option? I'd be glad if it does.

Support transactions as a way to resolve dead-locks during installation process

Locked packages are currently treated like installed ones. This is currently the easiest (and only) way to resolve circular dependencies during the installation of a package itself.

Instead we should dynamically create and update a graph of dependencies and their respective sub-dependencies. Once a cycle has been detected, a new transaction needs to be created and applied in an atomic way.

Reference: https://github.com/alexanderGugel/ied/blob/master/lib/install.js#L46

ied i -g flint

We have a pretty massive CLI that installs tons of stuff. It takes a ton of time with npm, but installing it into a local directory with ied is super fast.

When I try ied i -g flint it gives me this:

zsh: correct ied to id [nyae]? n
/Users/nw/.nvm/versions/node/v5.2.0/lib/node_modules/ied/lib/install_cmd.js:65
        if (err) throw err
                 ^

Error: EINVAL: invalid argument, readlink '/Users/nw/flint/node_modules/lodash'
    at Error (native)

Perhaps a good test case for ied, would love to use it in general.

Node: 5.2.0

No satisfying target found for jsbn

I try to install laravel-elixir and get:

$ ied install laravel-elixir
[======                        ] 19.26%/usr/local/lib/node_modules/ied/lib/install_cmd.js:65
        if (err) throw err
                 ^

Error: No satisfying target found for jsbn@git+https://github.com/rynomad/jsbn.git
    at /usr/local/lib/node_modules/ied/lib/resolve.js:88:17
    at fetch (/usr/local/lib/node_modules/ied/lib/resolve.js:21:5)
    at resolve (/usr/local/lib/node_modules/ied/lib/resolve.js:80:3)
    at fn (/usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:741:34)
    at /usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:1208:16
    at /usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:166:37
    at /usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:701:43
    at /usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:167:37
    at Object.async.waterfall (/usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:705:44)
    at install (/usr/local/lib/node_modules/ied/lib/install.js:114:9)
    at /usr/local/lib/node_modules/ied/lib/install.js:38:5

Support offline / no-index installs

We occasionally see build failures due to problems accessing the npm server. While we could run a local npm server instance ourselves, doing so adds unwanted complexity.

The Python world has a simple solution: save a copy of the used packages to a local directory or web accessible directory listing, then install using:

$ pip --no-index --find-links=/path/or/url ...

The package manager will then simply fetch the desired packages from the local directory or from the links extracted from the returned html directory listing. See: https://pip.pypa.io/en/stable/reference/pip_wheel/?highlight=find-links#cmdoption-f

This also provides a simple way to publish private packages within your organisation.

Why not working on npm ?

Hi !
This looks like a great idea to want npm to be faster and easier to use.
I was wondering why as you look like you have great skills, you did not offer your time and devote your idea to the npm project ?

What are the technical challenge that forced you to start from scratch ?
Any ideologies pushed you to do so ?

Thanks,

G

Global install fail

Hi,

I tried to install ied with npm

npm i -g ied

but it failed

npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "-g" "ied"
npm ERR! node v4.2.1
npm ERR! npm v2.14.7
npm ERR! path /usr/local/lib/node_modules/ied/bin/cmd.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod

npm ERR! enoent ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/ied/bin/cmd.js'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

Downloading the tarball (http://registry.npmjs.org/ied/-/ied-0.2.0.tgz) pointed by

npm info ied

and uncompressing it result in a single folder named package with a single file package.json

tree package

package
└── package.json

0 directories, 1 file

It looks like there are missing files...

[feature request] Support local paths in package.json.

Like this.

I've got a project with an auto-generated package.json that looks like this:

{
    "name": "rocket_module__root",
    "description": "root package",
    "version": "0.0.0",
    "license": "WTFPL",
    "repository": {
        "type": "git",
        "url": "git://github.com/meteor-rocket/module.git"
    },
    "dependencies": {
        "webpack": "^1.10.5",
        "rocket_module__rocket_module": "file:./packages/rocket_module__rocket_module",
        "rocket_module___app": "file:./packages/rocket_module___app"
    }
}

nom currently throws a 404 error about "rocket_module__rocket_module" not being in npmjs.com.

By the way, nom's speed is awesome.

TypeError: Cannot read property 'dist' of null

I got this when running ied install inside of bootstrap@181f76f.

> ied install
/usr/lib/node_modules/ied/lib/expose.js:47
  debug('expose %s in %s', pkg.dist.shasum, dir)
                              ^

TypeError: Cannot read property 'dist' of null
    at expose (/usr/lib/node_modules/ied/lib/expose.js:47:31)
    at /usr/lib/node_modules/ied/node_modules/async/lib/async.js:356:13
    at async.forEachOf.async.eachOf (/usr/lib/node_modules/ied/node_modules/async/lib/ac.js:233:13)
    at _asyncMap (/usr/lib/node_modules/ied/node_modules/async/lib/async.js:355:9)
    at Object.map (/usr/lib/node_modules/ied/node_modules/async/lib/async.js:337:20)
    at expose (/usr/lib/node_modules/ied/lib/expose.js:42:11)
    at fn (/usr/lib/node_modules/ied/node_modules/async/lib/async.js:741:34)
    at /usr/lib/node_modules/ied/node_modules/async/lib/async.js:1208:16
    at /usr/lib/node_modules/ied/node_modules/async/lib/async.js:166:37
    at /usr/lib/node_modules/ied/node_modules/async/lib/async.js:701:43

Support for `npm link` functionality

For people that work with private modules, ssh/https (covered in #7 ) and npm link are critical to the work flow. Please consider adding sym-linking functionality to avoid having to commit/push/install for every change when co-developing modules. Thanks!

Always use `bash` in npm commands

I'm using fish-shell, and npm commands with && and || don't work. This is because fish-shell doesn't support them.

 →  ied test
Unsupported use of '&&'. In fish, please use 'COMMAND; and COMMAND'.
fish: echo "Error: no test specified" && exit 1
                                       ^
test exited with status 127

ied error during runtime, executed without params, environment is windows 7 pro.

var debug = util.debuglog('expose')
^
TypeError: Object # has no method 'debuglog'
at Object. (C:\Users\user\AppData\Roaming\npm\node_modules\ied\lib\expose.
js:7:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (C:\Users\user\AppData\Roaming\npm\node_modules\ied\lib\install
_cmd.js:7:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)

ied run PATH problem

for the ied itself:

~> ied run test
/usr/local/lib/node_modules/ied/lib/run_cmd.js:32
    if (err) throw err
             ^

Error: spawn mocha && standard ENOENT
    at exports._errnoException (util.js:860:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at doNTCallback2 (node.js:450:9)
    at process._tickCallback (node.js:364:17)
    at Function.Module.runMain (module.js:459:11)
    at startup (node.js:136:18)
    at node.js:972:3

if i switch to npm everything is ok:

~> npm test

> [email protected] test /Users/nos/Documents/Projects/ied
> mocha && standard
...
...

it seems that something around here meet some problem.. i think i can have a look at it

--save-dev also copy "dependencies" into "devDependencies"

for ied repo it self:

16:57:34 nos:~/Documents/Projects/ied 9 (master u=)
~> ied install --save-dev debug
16:57:51 nos:~/Documents/Projects/ied 9 (master * u=)
~> gd
diff --git a/package.json b/package.json
index fa0aa17..507a5b7 100644
--- a/package.json
+++ b/package.json
@@ -19,11 +19,22 @@
     "tar-fs": "^1.8.1"
   },
   "devDependencies": {
-    "mocha": "^2.3.3",
+    "mocha": "^2.3.4",
     "mock-fs": "^3.4.0",
-    "mockmock": "0.0.5",
+    "mockmock": "^0.0.5",
     "proxyquire": "^1.7.3",
-    "standard": "^5.3.1"
+    "standard": "^5.3.1",
+    "archy": "^1.0.0",
+    "async": "^1.5.0",
+    "easy-table": "^1.0.0",
+    "gunzip-maybe": "^1.2.1",
+    "init-package-json": "^1.9.1",
+    "minimist": "^1.2.0",
+    "mkdirp": "^0.5.1",
+    "node-uuid": "^1.4.7",
+    "object-assign": "^3.0.0",
+    "semver": "^5.0.3",
+    "tar-fs": "^1.8.1"
   },
   "scripts": {
     "test": "mocha && standard",
@@ -44,4 +55,4 @@
     "example": "example",
     "test": "test"
   }
-}
+}
\ No newline at end of file

Why ied?

Would not be more useful to contribute back to npm instead of creating another divergence?

Initialize a new package does not work on Windows

Description

As i understand from the documentation, command ied init is an alternative to npm init. I write in the console ied init and get error.

Versions:

OS: Windows 10 x64 (10.0.10586)
nvm: v1.1.0 (nvm-windows)
Node.js: v4.2.4 (x64)
npm: v2.14.12
ied: v0.3.6

Console input

$ ied init

Console output

path.js:8
    throw new TypeError('Path must be a string. Received ' +
    ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:8:11)
    at Object.win32.resolve (path.js:130:5)
    at initCmd (C:\Users\jacke\AppData\Roaming\nvm\v4.2.4\node_modules\ied\lib\init_cmd.js:7:23)
    at C:\Users\jacke\AppData\Roaming\nvm\v4.2.4\node_modules\ied\bin\cmd.js:89:7
    at Object.<anonymous> (C:\Users\jacke\AppData\Roaming\nvm\v4.2.4\node_modules\ied\bin\cmd.js:100:2)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Function.Module.runMain (module.js:467:10)

Missing support for private / non-npm dependencies

ied fails when I try to install private dependencies

$ ied install
/usr/local/lib/node_modules/ied/lib/install_cmd.js:63
        if (err) throw err
                       ^ 
Error: Unexpected status code 404 for http://registry.npmjs.org/my-private-repo
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/ied/lib/resolve.js:37:17)
    at ClientRequest.g (events.js:199:16)
    at ClientRequest.emit (events.js:107:17)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:426:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:111:23)
    at Socket.socketOnData (_http_client.js:317:20)
    at Socket.emit (events.js:107:17)
    at readableAddChunk (_stream_readable.js:163:16)
    at Socket.Readable.push (_stream_readable.js:126:10)
    at TCP.onread (net.js:538:20)

If I run npm install everything works fine. The expected behavior is that ied uses my ssh keys to load the private repos from github. see using git urls as dependencies

reinstall error

ied install
rm -rf node_modules
ied install

Error: Cannot find module '/Users/me/workspace/lib/node_modules/.tmp/beb952e7-ad2e-4da1-9378-61b6547389ed/package.json'

TypeError: Object #<Object> has no method 'debuglog'

The module maybe should check the node version and inform the user the current version is not supported?

node --version // v0.10.26
ied install commander
/usr/local/lib/node_modules/ied/lib/expose.js:8
var debug = util.debuglog('expose')
                 ^
TypeError: Object #<Object> has no method 'debuglog'
    at Object.<anonymous> (/usr/local/lib/node_modules/ied/lib/expose.js:8:18)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/ied/lib/install_cmd.js:7:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

mac os x 10.10.5

Suggestion: temporarily defer to npm executable to cover gaps in functionality

For instance, at the moment ied doesn't support installs from gtihub.
Granted listing deps from gh isn't an ideal approach, but people do it, lots (particularly if you've got a PR waiting for merge, but you need your fix now)

So we stub some code for recognizing a GH dep and then pass it to npm if/until ied supports it, e.g.

pseudo-ish code:

var spawn = require('child_process').spawn
if (gh(dep)) {
  spawn('npm', ['install', dep])
   .on('end', next)
   .on('error', fail)
   .pipe(process.stdout)
}

Maybe create small module for handling "npm fallthrough"

Cannot find package.json error

I'm getting this error on [email protected]. Wish I can help debug, but I don't know where to start looking.

→ rm -rf node_modules
→  ied i
[=========================     ] 80.98%/Users/rsc/.nvm/versions/node/v4.1.0/lib/node_modules/ied/lib/install_cmd.js:65
        if (err) throw err
                 ^

Error: Cannot find module '/Users/rsc/Projects/.../node_modules/.tmp/5bba49cf-1574-48bc-96f8-40c2e8d0782e/package.json'
   at readPackage (/Users/rsc/.nvm/versions/node/v4.1.0/lib/node_modules/ied/lib/install.js:38:11)
    at fn (/Users/rsc/.nvm/versions/node/v4.1.0/lib/node_modules/ied/node_modules/async/lib/async.js:746:34)
    at /Users/rsc/.nvm/versions/node/v4.1.0/lib/node_modules/ied/node_modules/async/lib/async.js:1213:16
    at /Users/rsc/.nvm/versions/node/v4.1.0/lib/node_modules/ied/node_modules/async/lib/async.js:166:37

That folder has these:

→ cd node_modules/.tmp/5bba49cf-1574-48bc-96f8-40c2e8d0782e

→  grep -E 'name|version' package/package.json
  "name": "babel-register",
  "version": "6.4.3",

→  find .
./node_modules
./node_modules/babel-register
./package
./package/lib
./package/lib/browser.js
./package/lib/cache.js
./package/lib/node.js
./package/package.json
./package/README.md
./package/src
./package/src/browser.js
./package/src/cache.js
./package/src/node.js

Support --no-optional flag

Useful for when npm modules have optional dependencies you don't want or don't work on your platform. For example, ldapjs had optional dependencies on some dtrace libraries that don't work on OSX and slow down installs. Being able to skip them like I can with npm would be badass.

TypeError: Cannot read property 'dist' of null (pkg.dist.shasum)

Hello! I tried installing a package's dependencies with ied and hit the following error:

$ ied install
  debug('expose %s in %s', pkg.dist.shasum, dir)
                              ^

TypeError: Cannot read property 'dist' of null
    at expose (/usr/local/lib/node_modules/ied/lib/expose.js:42:31)
    at /usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:356:13
    at async.forEachOf.async.eachOf (/usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:233:13)
    at _asyncMap (/usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:355:9)
    at Object.map (/usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:337:20)
    at expose (/usr/local/lib/node_modules/ied/lib/expose.js:37:11)
    at fn (/usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:741:34)
    at /usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:1208:16
    at /usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:166:37
    at /usr/local/lib/node_modules/ied/node_modules/async/lib/async.js:701:43

I can post the package.json if necessary.

Module cannot find dependencies

XO cannot find dependencies. Directories of all dependencies exist in the directory node_modules. If you install all the dependencies manually, then everything works fine. As I understand it, the problem is in the links between directories.

Versions:

OS: Windows 10 x64 (10.0.10586)
nvm: v1.1.0 (nvm-windows)
Node.js: v4.2.4 (x64)
npm: v2.14.12
ied: v0.3.6

Gulpfile.js

const gulp = require('gulp');
const xo = require('gulp-xo');

gulp.task('default', () =>
  gulp.src('test.js')
    .pipe(xo())
);

test.js

error string

Console input

$ gulp

Console output

[20:02:18] Using gulpfile C:\projects\test\gulpfile.js
[20:02:18] Starting 'default'...
[20:02:18] 'default' errored after 56 ms
[20:02:18] Error in plugin 'gulp-xo'
Message:
    Cannot read config package: eslint-config-xo
Error: Cannot find module 'eslint-config-xo'
Referenced from:
Details:
    code: MODULE_NOT_FOUND
    fileName: C:\projects\test\test.js
C:\projects\test\node_modules\00b5ac306c9dc714e30f9feee78353f78bf6013b\package\index.js:31
                var results = report.results;
                                    ^

TypeError: Cannot read property 'results' of undefined
    at DestroyableTransform._transform (C:\projects\test\node_modules\00b5ac306c9dc714e30f9feee78353f78bf6013b\package\index.js:31:23)
    at DestroyableTransform.Transform._read (C:\projects\test\node_modules\a2426f8dcd4551c77a33f96edf2886a23c829669\package\lib\_stream_transform.js:172:10)
    at DestroyableTransform.Transform._write (C:\projects\test\node_modules\a2426f8dcd4551c77a33f96edf2886a23c829669\package\lib\_stream_transform.js:160:12)
    at doWrite (C:\projects\test\node_modules\a2426f8dcd4551c77a33f96edf2886a23c829669\package\lib\_stream_writable.js:335:12)
    at writeOrBuffer (C:\projects\test\node_modules\a2426f8dcd4551c77a33f96edf2886a23c829669\package\lib\_stream_writable.js:321:5)
    at DestroyableTransform.Writable.write (C:\projects\test\node_modules\a2426f8dcd4551c77a33f96edf2886a23c829669\package\lib\_stream_writable.js:248:11)
    at write (C:\projects\test\node_modules\3a360dd66c1b1d7fd4705389860eda1d0f61126c\package\lib\_stream_readable.js:623:24)
    at flow (C:\projects\test\node_modules\3a360dd66c1b1d7fd4705389860eda1d0f61126c\package\lib\_stream_readable.js:632:7)
    at DestroyableTransform.pipeOnReadable (C:\projects\test\node_modules\3a360dd66c1b1d7fd4705389860eda1d0f61126c\package\lib\_stream_readable.js:664:5)
    at emitNone (events.js:67:13)

Tests

We need more (as in "any").

Having tests makes you look like an adult.

getaddrinfo ENOTFOUND vs https registry

When trying to install this particular package ied does a bit of work, then fails with a weird getaddrinfo ENOTFOUND error:

> ied install css-loader
[==============================] 100.00%/usr/local/lib/node_modules/ied/lib/install_cmd.js:65
        if (err) throw err
                 ^

Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:80
    at errnoException (dns.js:26:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:77:26)
>

Switching to the https registry does work though:

> ied install --registry=https://registry.npmjs.org/ css-loader
> 

edit: not sure switching the --registry actually fixed anything, seems intermittent.

Regardless of this bug, perhaps should default to the https endpoint.

> ied --version
ied version 0.3.4
> node --version
v4.2.2

[CAS] Prefix folder names with package name

The downside with checksum folder names is that it can make stacktrace debugging very difficult. It's impossible to tell what module is what without manually opening up each folder.

current: 2796642723573859565633fc6274444bee2f8ce3
suggested (a): async_2796642723573859565633fc6274444bee2f8ce3
suggested (b): async_1.5.0_2796642723573859565633fc6274444bee2f8ce3

@alexanderGugel Is this something you'd be open to?

Unexpected Status Code 404 when trying to run npm install

After running ied install I get the following error message on OSX:

[==============================] 100.00%/Users/ed/.nvm/versions/node/v4.2.1/lib/node_modules/ied/lib/install_cmd.js:63
        if (err) throw err
                 ^

Error: Unexpected status code: 404
    at ClientRequest.<anonymous> (/Users/ed/.nvm/versions/node/v4.2.1/lib/node_modules/ied/lib/resolve.js:37:17)
    at ClientRequest.g (events.js:260:16)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:415:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:88:23)
    at Socket.socketOnData (_http_client.js:305:20)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:146:16)

IED behind a proxy

How can I use IED behind a corporate proxy?

I've tried:

ied config set http-proxy <my proxy>

Why ied?

I keep thinking about improvised explosive devices...

Support npm-shrinkwrap?

Really liking the project but I was wondering if you planned on supporting npm-shrinkwrap or making an equivalent? I find that locking down dependencies is really important for ensuring consistency and I've been stung far too many times by libraries not following semver.

The "type" argument in fs.symlink

This argument seems to be only respected on Windows, but it is currently not set correctly - it should be 'dir'. So is there any reason for the current behavior?

I suggest the type argument is removed from forceSymlink altogether and replaced with 'dir' where it is used.

npm installed dependencies crash ied `Error: EINVAL: invalid argument, readlink`

If you have dependencies installed with npm i.e. as a non-symlink dir node_modules/dependency_name, ied will crash when it tries to readlink the dir.

> mkdir ied-npm-crash
> cd ied-npm-crash
> npm init -f
npm WARN using --force I sure hope you know what you are doing.
Wrote to /Users/timoxley/Projects/tests/ied-npm-crash/package.json:

{
  "name": "ied-npm-crash",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "Tim Oxley <[email protected]>",
  "license": "ISC"
}
> npm install --save mkdirp
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm http request GET https://registry.npmjs.org/mkdirp
npm http 304 https://registry.npmjs.org/mkdirp
npm http request GET https://registry.npmjs.org/minimist
npm http 304 https://registry.npmjs.org/minimist
[email protected] node_modules/mkdirp
└── [email protected]

 > ied install
/usr/local/lib/node_modules/ied/lib/install_cmd.js:65
        if (err) throw err
                 ^

Error: EINVAL: invalid argument, readlink '/Users/timoxley/Projects/tests/ied-npm-crash/node_modules/mkdirp'
    at Error (native)

IED behind proxy part 2

A few issues that I found testing ied behind proxy:

  1. It expects HTTP_PROXY environment variable in all caps; most unix/linux/mac command line tools work with lower case http_proxy, these includes npm and git.
  2. Initial run of ied install against a react-webpack tutorial project produced this error messages:
/xxx/v5.1.0/lib/node_modules/ied/lib/expose.js:47
    debug('expose %s in %s', pkg.dist.shasum, dir)

TypeError: Cannot read property 'dist' of undefined
    at expose (/xxx/node/v5.1.0/lib/node_modules/ied/lib/expose.js:47:31)
    at /xxx/node/v5.1.0/lib/node_modules/ied/node_modules/async/lib/async.js:356:13)
    at async.forEachOf.async.eachOf (/xxx/v5.1.0/lib/node_modules/ied/node_modules/async/lib/async.js:233:31)
    at _asyncMap (/xxx/v5.1.0/lib/node_modules/ied/node_modules/async/lib/async.js:359:9)
    at Object.map (/xxx/v5.1.0/lib/node_modules/ied/node_modules/async/lib/async.js:359:9)
    at expose (/xxx/node/v5.1.0/lib/node_modules/ied/lib/expose.js:42:11)
    at fn (/xxx/v5.1.0/lib/node_modules/ied/node_modules/async/lib/async.js:741:34)
    at /xxx/v5.1.0/lib/node_modules/ied/node_modules/async/lib/async.js:1208:16
    at /xxx/v5.1.0/lib/node_modules/ied/node_modules/async/lib/async.js:166:37
    at /xxx/v5.1.0/lib/node_modules/ied/node_modules/async/lib/async.js:701:43
  1. I thought I gave it another run, so I re-run ied install and got the following message:
/xxx/v5.1.0/lib/node_modules/ied/lib/install_cmd.js:65
        if (err) throw err
                 ^

Error: No satisfying target found for jsbn@git+https://github.com/rynomad/jsbn.git
    at /xxx/v5.1.0/lib/node_modules/ied/lib/resolve.js:83:17
    at resolvePending (/xxx/v5.1.0/lib/node_modules/ied/lib/resolve.js:15:25)
    at IncomingMessage.<anonymous> (/xxx/v5.1.0/lib/node_modules/ied/lib/resolve.js:57:9)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:905:12)
    at doNTCallback2 (node.js:452:9)
    at process._tickCallback (node.js:366:17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.