marklogic-community / roxy

Deployment tool for MarkLogic applications. Also provides optional unit test and XQuery MVC structure
Other
87 stars 66 forks source link

Add support for npm install #454

Closed rlouapre closed 7 years ago

rlouapre commented 9 years ago

Would it be possible to add package.json in the root project so Roxy could be installed from npm?

MarkLogic Slush generator could then use it with gulp-install task and this code [2] would not be necessary.

[1] - https://docs.npmjs.com/cli/install [2] - https://github.com/marklogic/slush-marklogic-node/blob/master/slushfile.js#L32-L66

grtjn commented 9 years ago

I like the idea of making Roxy into an npm package, but the section of slushfile you are referring to only downloads the ml script. The ml new command in the runRoxy part after that will do a git clone to fetch full Roxy, and run the init command on it.

Might be interesting though to consider reengineering ml new and ml upgrade to not use git, or allow npm as a fallback?

rlouapre commented 9 years ago

I never noticed and used ml new

npm would provide a easier way to install and update Roxy. It will also help to integrate Roxy in Gulp scripts.

joemfb commented 9 years ago

I like npm quite a bit, but Roxy is almost entirely Ruby. I think it should be published as a gem on rubygems.org

grtjn commented 9 years ago

Would make a lot of sense for RoxyJS if that ever sees life.. ;-)

dmcassel commented 9 years ago

My group will have some interns this summer. I'm thinking about putting them to work on a Node-based RoxyJS using the Management API.

joemfb commented 9 years ago

Do you know if there are the plans to include management API methods / bindings with the official node client?

dmcassel commented 9 years ago

From my sources, no concrete plans, but we're open to the official client expanding in that direction. Tickets for discussion would be good before PRs.

rlouapre commented 9 years ago

My initial question was just about to ease Roxy install from gulp / javascript. I end up using download package and the following code:

    var installRoxy = function(answers, cb) {
        var Download = require('download');
        new Download({mode: '755', extract: true, strip: 1})
            .get('https://github.com/marklogic/roxy/releases/download/v' + answers.roxyVersion + '/roxy-' + answers.roxyVersion + '.zip')
            .dest('./roxy')
            .run(
                function() {
                    if (cb) cb();
                }
            );
    };
grtjn commented 9 years ago

Thnx for sharing!

grtjn commented 9 years ago

Elegant way to download Roxy by the way, using the release zip, instead of using git clone. It does mean you cannot make use of the dev branch, which often has some nice new extras, but alas.

I agree with Joe though, that it doesn't make too much sense to make an npm package of Roxy. But a Gem doesn't really make much sense either. Roxy is mostly a standalone app.

I would see something in making an mlpm package out of it. @joemfb WDYT? And if you agree, what would we need to do to get this as a package into mlpm registry?

joemfb commented 9 years ago

I disagree; I think Roxy is or should be a command-line tool for managing apps. And since it's written in Ruby, I think it should be distributed as a gem. (Homebrew could also work, but then what about Windows: nuget?)

That would mean that app_specific.rb, build.properties, and any environment-specific config would live within a Roxy project, but all the Ruby and XQuery libraries would be bundled within the gem. One nice consequence of this would be cleaner, smaller projects.

My view for mlpm is that it should manage packages that are to be evaluated within Marklogic. I think Marklogic-related tools should use language/environment specific distribution mechanisms (npm for js, Rubygems for ruby, pip for python, etc.).

grtjn commented 9 years ago

Makes sense. So not npm package, nor mlpm package. Still not sure about gem either though. A gem would make perfect sense if Roxy would be a library that you could 'require' from within a different Ruby project. But Roxy is a large mix of things. There is all kinds of stuff in there.

And apart from all that, I see not a lot of gain in packaging Roxy to be honest. Just downloading the zip, or the ml script seems pretty straight-forward already to me..

Anyone else thoughts on this?

joemfb commented 9 years ago

Like npm packages, ruby gems aren't just for managing dependencies, but also distributing executables:

grtjn commented 9 years ago

I know, but still..

rlouapre commented 9 years ago

I did not say that Roxy should be published a npm package. I just suggested to add a package.json

grtjn commented 9 years ago

Ah, and then just install directly from github! I like your approach of downloading the zip better I think. But if it really helps you...

rlouapre commented 9 years ago

If package.json was available roxy could be installed like this: for master branch - npm install marklogic/roxy for dev branch - npm install marklogic/roxy#dev any specific version - npm install marklogic/roxy#{tag-name}

grtjn commented 9 years ago

I'm only thinking, doing npm install would put all roxy files inside node_modules/roxy/, not directly helpful. On the other hand, we could perhaps add an ml.js, that should get linked as ml, and wraps ml.rb like ml.bat and ml sh script does. It would rely on sys-call to Ruby, but would at least make the npm install actually give you something useful.

I also like to take a closer look at the gem stuff..

rlouapre commented 9 years ago

I came around this issue using cwd parameter [1](with ml) and [2](with ml.rb) here roxy project is in /roxy directory.

Again my idea was to provide better integration with gulp and slush (I am not sure how gem will help in this use case).

[1] - https://github.com/nativelogix/xquerrail2.framework/blob/master/gulpfile.js#L118 [2] - https://github.com/nativelogix/slush-xquerrail/blob/master/templates/app/gulpFile.js#L31

rlouapre commented 9 years ago

Would it make sense to create a different issue for gem?

grtjn commented 9 years ago

Yes, with low prio as nobody asked for it yet. :)

grtjn commented 7 years ago

Seems to work: npm install grtjn/roxy#454-package-json, but still wondering what the real benefit is. I agree with Joe that a gem distribution makes most sense, and for other uses there is either the option to git clone (like the built-in upgrader and ml new are doing), or you can grab zip or jar from the releases page.

Slush-marklogic-node downloads the ml-script, and lets ml new figure out itself how to get Roxy (e.g. by using git clone currently). Using ml new has the benefit it automatically cleans up and initializes the project along the way, so you get a much better starting point than by just cloning/copying Roxy..

grtjn commented 7 years ago

I thinking about closing this ticket. Thoughts?