Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Candy should have an easier way to install and use via package management #432

Open
who opened this issue Sep 22, 2015 · 8 comments
Open

Comments

@who
Copy link

who commented Sep 22, 2015

I have an existing web application which uses npm+bower+grunt, I and would like to add Candy to it. I found that this was not easy, and I believe this process could be greatly simplified.

If you want to include Candy in an existing node+grunt app, you have to something like the following:

1. Add Candy to your package.json
Add "candy": "candy-chat/candy#3bad2bc2ca" to your package.json. This will cause npm to download the github repo when npm install is performed. I used commit #3bad2bc2ca as a tag.

2. Install Candy's node modules and run Candy's grunt build
Because there are no dist assets in the github repo, you have to run npm install and grunt build on behalf of Candy inside ./node_modules/candy. For the npm install, you can use grunt-auto-install, and for the grunt build, you can use grunt-subgrunt.

After you add and configure grunt-auto-install, whenever you run npm install at your root application's scope, npm install will also be run inside the ./node_modules/candy folder for you. This will install the node modules required by Candy in preparation for the grunt build.

After you add and configure sub-grunt, you can configure a grunt task at your root application's scope to trigger grunt jobs in the ./node_modules/candy folder. This will build all of the JS bundles that Candy needs.

2.1 Install and configure grunt-auto-install

Install the package

npm install grunt-auto-install --save-dev

Configure your Gruntfile.js

grunt.initConfig({
  auto_install: {
    local:{},
    run: {
        options: {
            cwd: './node_modules/candy',
            stdout: true,
            stderr: true,
            failOnError: true,
            npm: true
        }
    }
  },
});

grunt.loadNpmTasks('grunt-auto-install');

Then, at your application root, you can test this by invoking the grunt command grunt auto_install:run. Candy's node modules should then be installed in ./node_modules/candy/node_modules

2.2 Install and configure grunt-auto-install

Install the package

npm install grunt-subgrunt --save-dev

Configure your Gruntfile.js

grunt.initConfig({
  subgrunt: {
    run: {
      projects: {
        'node_modules/candy': ['build']
      }
    }
  }
});

grunt.loadNpmTasks('grunt-subgrunt');

Then, at your application root, you can test this by invoking the grunt command grunt subgrunt:run. Candy's JS files will then be generated.

Conclusion & Recommendation
This is probably more complex than it should be. Step 2, 2.1, and 2.2 above could be completely removed if Candy would include pre-built or "dist" assets in it's repo. I recommend that Candy publish pre-built assets as a part of each build pushed to Github.

@benlangfeld
Copy link
Member

if Candy would include pre-built or "dist" assets in it's repo. I recommend that Candy publish pre-built assets as a part of each build pushed to Github.

We explicitly do not do this because it is not a sensible approach to distributing software. Something along the lines of "subgrunt" or preferably a standard approach for packaging Javascript modules, is consistent with the requirements of developing, building and distributing software. Unfortunately Javascript has a very immature ecosystem, so these things are still being (re-)invented.

For now, I would recommend contributing the above as documentation.

@zh99998
Copy link
Contributor

zh99998 commented Oct 14, 2015

have a look at other packages needs to build. such as bootstrap. just don't directly point at github repo. but a pre-compiled one.

and could you don't specific jquery version in dependence? many websites already using jquery 2.x, and will cause problem.

again, look at other packages, such as bootstrap, it says "jquery": ">= 1.9.1"

@benlangfeld
Copy link
Member

We do not bundle any jQuery, @zh99998, you can use whatever version you like.

@zh99998
Copy link
Contributor

zh99998 commented Nov 25, 2016

just release a compiled tar.gz format package here will help a lot.
npm support tarball url as dependency, but not support zip

@benlangfeld
Copy link
Member

Like the tarballs at https://github.com/candy-chat/candy/releases, @zh99998?

@zh99998
Copy link
Contributor

zh99998 commented Nov 25, 2016

@benlangfeld yes I'm talking about here
https://github.com/candy-chat/candy/releases

now only released COMPILED package in zip format, no tar.gz

@benlangfeld
Copy link
Member

benlangfeld commented Nov 25, 2016

The release config is at https://github.com/candy-chat/candy/blob/master/Gruntfile.js#L215-L259. Would you be able to prep a PR which releases compiled tarballs too, @zh99998?

@zh99998
Copy link
Contributor

zh99998 commented Dec 5, 2016

sorry I tried several times but can't build it.....
seems due to this dylang/grunt-notify#118

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants