Commit 0cd472b028e88ceb65e2dfedce1ff1afbe2ab7e9
Use ssb-npm-registry
cel authored on 9/20/2017, 10:10:48 PMHenry committed on 11/30/2017, 9:46:20 PM
Parent: 176fc9341ed03d9a3b53a036578e7f7e026619e8
Files changed
bin.js | changed |
package.json | changed |
plugins/plugins.js | changed |
bin.js | ||
---|---|---|
@@ -48,8 +48,9 @@ | ||
48 | 48 … | .use(require('./plugins/private')) |
49 | 49 … | .use(require('ssb-query')) |
50 | 50 … | .use(require('ssb-links')) |
51 | 51 … | .use(require('ssb-ws')) |
52 … | + .use(require('ssb-npm-registry')) | |
52 | 53 … | |
53 | 54 … | // add third-party plugins |
54 | 55 … | require('./plugins/plugins').loadUserPlugins(createSbot, config) |
55 | 56 … |
package.json | ||
---|---|---|
@@ -62,8 +62,9 @@ | ||
62 | 62 … | "ssb-friends": "^2.3.2", |
63 | 63 … | "ssb-keys": "^7.0.13", |
64 | 64 … | "ssb-links": "^3.0.0", |
65 | 65 … | "ssb-msgs": "~5.2.0", |
66 … | + "ssb-npm-registry": "^1.0.1", | |
66 | 67 … | "ssb-query": "^1.0.0", |
67 | 68 … | "ssb-ref": "^2.7.1", |
68 | 69 … | "ssb-ws": "^1.0.3", |
69 | 70 … | "statistics": "^3.0.0", |
plugins/plugins.js | ||
---|---|---|
@@ -99,17 +99,27 @@ | ||
99 | 99 … | // create a tmp directory to install into |
100 | 100 … | var tmpInstallPath = path.join(osenv.tmpdir(), pluginName) |
101 | 101 … | rimraf.sync(tmpInstallPath); mkdirp.sync(tmpInstallPath) |
102 | 102 … | |
103 … | + if (this['npm-registry']) this['npm-registry'].getAddress(next) | |
104 … | + else next() | |
105 … | + | |
103 | 106 … | // build args |
104 | 107 … | // --global-style: dont dedup at the top level, gives proper isolation between each plugin |
105 | 108 … | // --loglevel error: dont output warnings, because npm just whines about the lack of a package.json in ~/.ssb |
109 … | + | |
106 | 110 … | var args = ['install', from||pluginName, '--global-style', '--loglevel', 'error'] |
107 | 111 … | if (dryRun) |
108 | 112 … | args.push('--dry-run') |
109 | 113 … | |
110 | - // exec npm | |
111 | - var child = spawn('npm', args, { cwd: tmpInstallPath }) | |
114 … | + function next(err, registryUrl) { | |
115 … | + if (err) console.trace(err) | |
116 … | + | |
117 … | + if (registryUrl) | |
118 … | + args.push('--registry', registryUrl) | |
119 … | + | |
120 … | + // exec npm | |
121 … | + var child = spawn('npm', args, { cwd: tmpInstallPath }) | |
112 | 122 … | .on('close', function (code) { |
113 | 123 … | if (code == 0 && !dryRun) { |
114 | 124 … | var tmpInstallNMPath = path.join(tmpInstallPath, 'node_modules') |
115 | 125 … | var finalInstallNMPath = path.join(installPath, 'node_modules') |
@@ -144,8 +154,9 @@ | ||
144 | 154 … | pull.values([new Buffer('Installing "'+pluginName+'"...\n', 'utf-8')]), |
145 | 155 … | many([toPull(child.stdout), toPull(child.stderr)]), |
146 | 156 … | p |
147 | 157 … | ]) |
158 … | + } | |
148 | 159 … | }, 'string', 'object?'), |
149 | 160 … | uninstall: valid.source(function (pluginName, opts) { |
150 | 161 … | var p = pushable() |
151 | 162 … | if (!pluginName || typeof pluginName !== 'string') |
Built with git-ssb-web