bgrins / TinyColor

Fast, small color manipulation and conversion for JavaScript
https://bgrins.github.io/TinyColor/
MIT License
5.08k stars 438 forks source link

cdnjs integration #49

Open HoffmannP opened 10 years ago

HoffmannP commented 10 years ago

Hy, I opened a pull-request to distribute your lovely library in cdnjs.com. Just wanted to let you know, so you could add personal information (e.g. your email), contributors, new updates.

Thanks again for sharing

bgrins commented 10 years ago

Alright, thanks for the heads up. What is the process for sending updated versions?

HoffmannP commented 10 years ago

You fork the cdnjs-repo, insert the files (minimized and possibly with map-file, you can just take the command I used, shown in the pull request) and update the package.json (trivial, just update the version number). Then you open a pull request. (or you message me and I can do that if you mind the hassle.)

yairEO commented 10 years ago

The code in cdnjs isn't updated btw

HoffmannP commented 10 years ago

@yairEO Thanks, I just opend a pull request

bgrins commented 10 years ago

@HoffmannP from that issue (https://github.com/cdnjs/cdnjs/pull/3416) it looks like you are using

uglifyjs tinycolor.js --source-map tinycolor.min.map --mangle -o tinycolor.min.js and tinycolor.js was downloaded from the github repository

Not that it is so hard to run that, but I do have uglify set up with grunt (https://github.com/bgrins/TinyColor/blob/master/Gruntfile.js#L12). The options aren't quite the same, but we should definitely update them so that generating files for a cdnjs compatible PR is as easy as running a git checkout TAG grunt build (or maybe we could add a grunt uglify that doesn't affect the doc files).

HoffmannP commented 10 years ago

for me it is always

git fetch upstream
git rebase mater/upstream
cd ajax/lib/tinycolor
mkdir $newVersion
cd $newVersion
wget https://raw.githubusercontent.com/bgrins/TinyColor/master/tinycolor.js
uglifyjs tinycolor.js --source-map tinycolor.min.map --mangle -o tinycolor.min.js
rm tinycolor.js
cd ..
# manually update version number in package.json to $newVersion
# could probably be automated using i.e. sed
git add $newVersion
git add package.json
git -m "Update tinycolor $newVersion"
git push
# manually open PR

There are a few steps that should/could be automated, the uglify process is not the problem, especially as I usually don't fetch the hole tinycolor-rep

bgrins commented 10 years ago

The problem is that if you wget https://raw.githubusercontent.com/bgrins/TinyColor/master/tinycolor.js, this may be different from the tagged version of that lib (which could lead to all kinds of inconsistencies). What I would suggest is something like this (this may not be verbatim commands, but pretty close to the idea):

For TinyColor

git fetch upstream
git rebase mater/upstream
git checkout 0.11.2
uglifyjs tinycolor.js --source-map tinycolor.min.map --mangle -o tinycolor.min.js
git checkout master

For cdn

git fetch upstream
git rebase mater/upstream
cd ajax/lib/tinycolor
mkdir 0.11.2
cd 0.11.2
cp /path/to/tinycolor/dist/tinycolor.min.js . # Copies in based on actual tagged release this way
cp /path/to/tinycolor/dist/tinycolor.min.map .
cd ..
git add 0.11.2
cp /path/to/tinycolor/package.json .
git -m "Update tinycolor $newVersion"
git push
# manually open PR

There are a few steps that should/could be automated, the uglify process is not the problem, especially as I usually don't fetch the hole tinycolor-rep

Still, if we had a grunt package command that made a folder called dist/0.11.2 and copied in the min.js and min.map files, then all you would have to do is copy that folder + the current package.json file into the cdnjs repo (which would get this down to many fewer steps)