Coder Social home page Coder Social logo

flatten's People

Contributors

arifsetiawan avatar naderm avatar teltploek avatar vf1 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

Watchers

 avatar  avatar  avatar

flatten's Issues

flatten exclude some packages

It would be good to have a functionality to ignore flattening some packages. Like using a .flattenignore file or thorugh cli options.

This is a use case where we use the same module built both for nw-gyp and node-gyp (ie., two copies of same module exists).

Thanks

questions about flatten-packages.

I'm new to flatten-packages and have a few questions. Looking forward to your kind reply. Thanks.

  1. node v3 (search keyword flat) already flat the packages maximally. Do I still need to use flatten-packages?
  2. What's the difference between flatten-packages and npm dedupe?

npm dedup: The deduplication algorithm walks the tree, moving each dependency as far up in the tree as possible, even if duplicates are not found. This will result in both a flat and deduplicated tree.

I think npm dedupe is doing the same thing? How does flatten-packages handle conflict packages?

More files after flattening ?

I get more files in my node_modules folder after flattening than before.
Intuitively it should be the opposite as some dependencies are merged and node_modules directories are removed.
Is it a bug or am I missing something ?

Before:

2.599 Files
666 Folders
14.863.707 Bytes

After:

3.312 Files (27% more)
668 Folders
17.719.802 Bytes (19% more)

I tried with several dependencies setup, with common modules (connect, fs-extra, chokidar, ...) and starting with a clean env (empty node_modules dir). I get no error and sub node_modules directory are successfully removed by the command.

JS file encoding incorrect?

Trying to use this package on Linux, I have a weird error :
$ flatten-packages
: No such file or directory

Looks like the main script has DOS encoding.
Is it working anywhere other than Windows/Cygwin?

ability to run flatten function in a silent mode

I'm using flatten-packages inside of a gulp task:

gulp.task('flatten', function (next) {
  flatten(dist, {}, next)
})

and I would like to have an ability to disable all flatten-packages output, e.g.:

gulp.task('flatten', function (next) {
  flatten(dist, { silent: true }, next)
})

Right not it's not even possible to turn verbose mode of, because you're overwriting options.verbose with true.

For now I'm using a dirty hack with Object.defineProperty to turn verbose mode off, but I'm still getting a lot of annoying console output.

Thanx!

Automatic deployment

Just a info about Automatic deployment, you can edit readme if you want.

In package.json, you can define this package install in "preinstall" and package run in "postinstall":

 "scripts": {
    "preinstall": "npm i -g flatten-packages",
    "postinstall": "flatten-packages"
  },

Then, when you call npm install the npm itself will install flatten-packages and will run it after install process.

Prevent flattening devDependencies

flatten-packages should be able de process (through options?) dependencies alone (excluding devDependencies).
Also flatten-packages -p should print them into the correct key (dev/not-dev) especially when both are processed.

uglify not working after flattering

Hi,
after using flatten-packages, uglify (grunt-contrib-uglify) gives me the following message:
"Warning: An error occurred while processing a template (undefined is not a function). Use --force to continue."
but other tasks are working fine (like cssmin and compass).
I really appreciate your help.

Flatten fails on a test fixture that is supposed to be broken.

...
 duplicate: enhanced-resolve 0.4.12 existing version: 0.9.1
[SyntaxError: /Users/Donovan/code/lendinghome-monolith/ops/node_modules/enhanced-require/node_modules/enhanced-resolve/test/fixtures/node_modules/invalidPackageJson/package.json: Unexpected end of input]

Error: ENOENT, no such file or directory when moving directories

moving directory c:\Users\Administrator\projects\fireball-x\fireball\dist\resources\app\node_modules\chalk\node_modules\has-ansi\node_modules\get-stdin to c:\Users\Administrator\projects\fireball-x\fireball\dist\resources\app\node_modules\get-stdin
{ [Error: ENOENT, no such file or directory 'c:\Users\Administrator\projects\fireball-x\fireball\dist\resources\app\node_modules\chalk\node_modules\has-ansi\node_modules\get-stdin']
  errno: -4058,
  code: 'ENOENT',
  path: 'c:\\Users\\Administrator\\projects\\fireball-x\\fireball\\dist\\resources\\app\\node_modules\\chalk\\node_modules\\has-ansi\\node_modules\\get-stdin',
  syscall: 'stat' }

When this error occurs, I checked and the source folder c:\Users\Administrator\projects\fireball-x\fireball\dist\resources\app\node_modules\chalk\node_modules\has-ansi\node_modules\get-stdin does exists.

My project's node_modules iteration info:

node_modules iteration complete
there are 512 unique packages
          962 duplicate packages
there are 41 packages in node_modules level 1
          219 packages in node_modules level 2
          420 packages in node_modules level 3
          374 packages in node_modules level 4
          240 packages in node_modules level 5
          124 packages in node_modules level 6
          38 packages in node_modules level 7
          17 packages in node_modules level 8
          1 packages in node_modules level 9

Package w/o name or version

I encountered invalid package that crashed flatten-packages.
https://github.com/substack/node-browserify/blob/master/test/field/node_modules/z-miss/package.json

Here is a tiny fix:

          try {
            var packageJson = require(modules[i]);
            currentData.name = packageJson.name;
            currentData.version = packageJson.version;
            if(typeof(currentData.name) === 'undefined')
              continue;
              //throw 'Name is not specified in ' + modules[i];
            if(typeof(currentData.version) === 'undefined')
              continue;
              //throw 'Version is not specified in ' + modules[i];
          }
          catch(err) {
            return callback(err);
          }

I prefer to ignory error and moving forward.

BTW: Thanks for flatten-packages.

Wrench is deprecated

I know this project isn't maintained any more, but in case others are seeing messages like this:

npm WARN deprecated [email protected]: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.

It may be coming from this

Cannot Read property verbose of undefined

Hi arifsetiawan,
using your module, in the flatten.js file. The error is shown in the title. It's called when the code request:

options.verbose

Because there is no options defined. Where am I wrong?
I'm using the module because is require in the node-zendesk module.
Thanks!

Missing versioning in package throws error in already flattened directory

When I ran flatten-packages in an already flattened directory, I got the following error:

PS D:\Project> flatten-packages
processing directory D:\Project
there are 210 total packages

C:\Users\teltploek\AppData\Roaming\npm\node_modules\flatten-packages\lib\flatten.js:89
ole.log(' duplicate:'.magenta, currentData.name, currentData.version.cyan, 'ex
                                                                    ^
TypeError: Cannot read property 'cyan' of undefined
    at C:\Users\teltploek\AppData\Roaming\npm\node_modules\flatten-packages\lib\flatten.js:89:89
    at C:\Users\teltploek\AppData\Roaming\npm\node_modules\flatten-packages\lib\flatten.js:198:31
    at C:\Users\teltploek\AppData\Roaming\npm\node_modules\flatten-packages\lib\flatten.js:198:31
    at C:\Users\teltploek\AppData\Roaming\npm\node_modules\flatten-packages\lib\flatten.js:198:31
    at C:\Users\teltploek\AppData\Roaming\npm\node_modules\flatten-packages\lib\flatten.js:198:31
    at C:\Users\teltploek\AppData\Roaming\npm\node_modules\flatten-packages\lib\flatten.js:198:31
    at C:\Users\teltploek\AppData\Roaming\npm\node_modules\flatten-packages\lib\flatten.js:198:31
    at C:\Users\teltploek\AppData\Roaming\npm\node_modules\flatten-packages\lib\flatten.js:198:31
    at C:\Users\teltploek\AppData\Roaming\npm\node_modules\flatten-packages\lib\flatten.js:198:31
    at C:\Users\teltploek\AppData\Roaming\npm\node_modules\flatten-packages\lib\flatten.js:214:27

The reason for the error is, that a package has no version information in its package.json. The package garply has a package.json containing:

{
    "main" : "./lib"
}

I'll submit a pull request to correct this in a short while.

Honor package.json version ranges

Example: don't replace node_modules which has strict dependency version on package.json to avoid new module breaking changes

My proposal is to put such module in its original location (don't move to first level or delete it)

Broken modules

I just run flatten-packages in order to prevent too long path and my gulp script stop working. There are commands to reproduce this case:

yo gulp-angular   // keep default options
gulp build        // all works properly
flatten-packages
gulp build        // node print some error

While running gulp second time I receive the following error:

E:\projects\a2\node_modules\karma\lib\middleware\runner.js:11
var json = require('connect').json();
                              ^
TypeError: undefined is not a function
    at Object.<anonymous> (E:\projects\a2\node_modules\karma\lib\middleware\runner.js:11:31)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (E:\projects\a2\node_modules\karma\lib\web-server.js:7:24)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

Does not handle .bin files

Currently when flattened, all the .bin files (coffeescript for example) are not copied to the .bin directory of the parent.

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.