Component install and gitlab

187 views
Skip to first unread message

Sankar Gorthi

unread,
Sep 6, 2013, 5:47:29 PM9/6/13
to compo...@googlegroups.com
Gitlab always needs authentication for raw file reads to work. Which is fine, I used https://github.com/anthonyshort/gitorious-component-server to add the private_token param to the end of the URL (not to mention, following the gitlab pattern) and I can access the files using 


Now, I see the following error. Am I missing something here?

~/dev/feature
$ component install -v

     install : sgorthi/templates@master
       fetch : sgorthi/templates:scripts/main.js
       fetch : sgorthi/templates:scripts/template.js
       fetch : sgorthi/templates:index.js
       fetch : sgorthi/templates:styles/template.sass
       fetch : sgorthi/templates:tmpl/template.hbs
     warning : failed to fetch http://localhost:3000/components/sgorthi/templates/master/scripts/main.js, got 302 "Moved Temporarily"
    complete : sgorthi/templates
       error : failed to fetch https://raw.github.com/sgorthi/templates/master/component.json, got 404 "Not Found"

vision media [ Tj Holowaychuk ]

unread,
Sep 6, 2013, 6:09:32 PM9/6/13
to compo...@googlegroups.com
until we use superagent for installs again that redirect will break things, we have to fix superagent basically haha or re-implement all that stuff again


--
You received this message because you are subscribed to the Google Groups "component" group.
To unsubscribe from this group and stop receiving emails from it, send an email to componentjs...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sankar Gorthi

unread,
Sep 6, 2013, 6:48:31 PM9/6/13
to compo...@googlegroups.com, t...@vision-media.ca
So my options are use local repos or local repos. Got it.

:(

I couldn't figure out how to organize my component-server and not have to maintain the files in there if it's a shared set of components that will be updated quite regularly. Is it supposed to simply point to a git repo that contains all the projects? How do you not have to manually update content in the local folder to pull the latest components?

vision media [ Tj Holowaychuk ]

unread,
Sep 6, 2013, 8:20:32 PM9/6/13
to compo...@googlegroups.com
the server thing is just an example, if you're self-hosting git repos etc you could use it, but it's mostly an example. I don't love the "elegance" of baking in support for these other services, but if we make it modular I'm alright with supporting github/bitbucket/gitlab etc

Sankar Gorthi

unread,
Sep 9, 2013, 2:39:36 PM9/9/13
to compo...@googlegroups.com, t...@vision-media.ca
I'm going to try a simple express server that `git show`s the file given the url pattern and point it to the repo folder. That way I hope to go around gitlab's authentication.

If one already exists (I wasn't able to find one that supports tags), let me know.

Sankar Gorthi

unread,
Sep 9, 2013, 3:20:54 PM9/9/13
to compo...@googlegroups.com, t...@vision-media.ca
var express = require('express');
var app = express();
var sys = require('sys');
var exec = require('child_process').exec;

app.all('/components/:username/:component/:version/*', function(req, res, next) {
var params = req.params;

if (params.length > 0) {
var file = getRawFile(function(data) {
res.send(data);
}, params.username, params.component, params.version, params[0]);
}
});

app.get('/', function(req, res, next) {
res.send('Component server');
});

app.listen('3917');

/* Utils */
function getRawFile(callback, username, component, version, file) {
var path = ['/path/to/repositories/',
username,
component + '.git'
].join('/');
exec('git --git-dir ' + path + ' show ' + version + ':' + file, function(error, stdout) {
callback(stdout);
});
}

A very naive implementation. Works for now and I can extend it to store git repos at a folder locally and still get the components.

Suggestions welcome.

Sankar Gorthi

unread,
Sep 9, 2013, 5:05:20 PM9/9/13
to compo...@googlegroups.com, t...@vision-media.ca
PS: Completely unrelated, just noticed that Tj Holowaychuk wrote expressjs as well. Wow!

Sankar Gorthi

unread,
Sep 10, 2013, 7:59:44 PM9/10/13
to compo...@googlegroups.com, t...@vision-media.ca
Small improvement: Return a 404 if a path doesn't exist. This should allow component to fail-over to the next remote.

var express = require('express');
var app = express();
var sys = require('sys');
var exec = require('child_process').exec;

app.all('/components/:username/:component/:version/*', function(req, res, next) {
var params = req.params;

if (params.length > 0) {
var file = getRawFile(function(data) {
if (!data) {
res.send('File not found!', 404);

Sankar Gorthi

unread,
Sep 25, 2013, 8:45:26 PM9/25/13
to compo...@googlegroups.com
Ran into an issue with larger files. The async `exec` call was resulting in large files being cut off

var express = require('express');
var app = express();
var sys = require('sys');
var exec = require('execSync').exec;

app.get('/components/:username/:component/:version/*', function(req, res, next) {
var params = req.params;

if (params.length > 0) {
var file = getRawFile(function(data) {
if (!data) {
res.send('File not found', 404);
}
res.send(data);
}, params.username, params.component, params.version, params[0]);
}
});

app.get('/', function(req, res, next) {
res.send('Component server');
});

app.listen('3917');

/* Utils */
function getRawFile(callback, username, component, version, file) {
var path = ['/path/to/repositories/',
username,
component + '.git'
].join('/');
var result = exec('git --git-dir ' + path + ' show ' + version + ':' + file);
callback(result.stdout);
}

Milan Iliev

unread,
Nov 11, 2013, 11:53:52 AM11/11/13
to compo...@googlegroups.com
Sankar,

Are you interested on putting this on GitHub somewhere? I'd love to submit patches to it, like a config file and remove some dependencies (Also, it's better than TJ Holowaychuk's example server; maybe we can link it from the component.js wiki eventually).
Message has been deleted

Sankar Gorthi

unread,
Nov 11, 2013, 1:17:11 PM11/11/13
to compo...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages