From 35ce289bb219f9c68a61629bd419d9a55dfedbc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 13 Jul 2016 12:01:43 +0200 Subject: [PATCH 1/3] Ignore most files when publishing to npm References #1167 --- .npmignore | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 000000000..a6dffab7b --- /dev/null +++ b/.npmignore @@ -0,0 +1,7 @@ +* +!README.md +!MIT-LICENSE +!dist/zepto.js +!dist/zepto.min.js +!src/*.js +src/amd_layout.js From 120f12fdcccceabd778139e016efd9fe9d7be24a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 13 Jul 2016 12:07:21 +0200 Subject: [PATCH 2/3] Add `main` field to package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 2419f3f16..4bfcd62c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "zepto" , "version": "1.1.6" + , "main": "dist/zepto.js" , "homepage": "http://zeptojs.com" , "scripts": { "test": "coffee make test" From c151149fe3a8fd97d775e9d75c952862b7ea2b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 13 Jul 2016 12:29:18 +0200 Subject: [PATCH 3/3] Add `make publish` target for npm --- make | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/make b/make index 12217bf88..beb26b942 100755 --- a/make +++ b/make @@ -2,7 +2,6 @@ require 'shelljs/make' fs = require 'fs' -version = '1.1.6' zepto_js = 'dist/zepto.js' zepto_min = 'dist/zepto.min.js' zepto_gz = 'dist/zepto.min.gz' @@ -63,6 +62,18 @@ target.compress = -> factor = fsize(zepto_js) / fsize(zepto_gz) echo "compression factor: #{format_number(factor)}" +target.publish = -> + tag = 'v' + package_version() + if git_version() == tag + rm '-r', zepto_js + env['MODULES'] = env['NOAMD'] = '' + target.dist() + res = exec 'npm publish' + exit res.code + else + console.error 'error: latest commit should be tagged with ' + tag + exit 1 + ## HELPERS ## stale = (file, source) -> @@ -83,9 +94,15 @@ format_number = (size, precision = 1) -> report_size = (file) -> echo "#{file}: #{format_number(fsize(file) / 1024)} KiB" -describe_version = -> +package_version = -> + JSON.parse(cat('package.json')).version + +git_version = -> desc = exec "git --git-dir='#{root + '.git'}' describe --tags HEAD", silent: true - if desc.code is 0 then desc.output.replace(/\s+$/, '') else version + desc.output.replace(/\s+$/, '') if desc.code is 0 + +describe_version = -> + git_version() || package_version() minify = (source_code) -> uglify = require('uglify-js')