pex-gl/pex

Set current pex-* package version is generated package.json

vorg opened this issue · 2 comments

vorg commented

Currenly we set * for each pex package. This is wrong as in the future as packages evolve we don't have track of which package we have used in that project. Solutions:

a) Synchronous npm show package version

var execSync = require('exec-sync');

function getPackageVersion(pkg) {
    var version = execSync('npm show ' + pkg + ' version');
    version = version.trim();
    return version;
}

'pex-color':            getPackageVersion('pex-color'),

Pros: easy
Cons: synchronous = slow, can't create projects when offline

b) Manually call npm install pex-color --save for each pex package

Additionally we need to call cd project name and npm install for all remaining packages

//'pex-color':           "*", //don't include pex-packages in generated package.json

Pros: faster
Cons: still can fail when offline, breaks 'generate project and forget' philosophy of a project generator

c) Hardcoded package versions in pex distro and update from time to time

'pex-color':           "0.1.0",

Pros: fast
Cons: easy to get out of sync with state of the packages

d) Run npm install 'ls node_modules' --save inside folder manually

Re-saves all package versions

Pros: optional
Cons: optional, requires effort

I think option a) is best for generator that gets out of your way, I think we could try some mixture of async.each and child_process.spawn to make it work asynchronously :)

There's still problem of creating offline projects, but if you do this offline you can't npm install inside the repo either...? Maybe we could show some warning/error message when ping 8.8.8.8 fails?

vorg commented

@szymonkaliski And that's what I did.

Fixed in a8e7c7a