diff --git a/publish/pack.sh b/publish/pack.sh new file mode 100644 index 0000000..f714710 --- /dev/null +++ b/publish/pack.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +SOURCE_DIR=../src +TO_SOURCE_DIR=src +PACK_DIR=package +ROOT_DIR=.. +PUBLISH=--publish + +install() { + npm i +} + +pack() { + + echo 'Clearing /src and /package...' + node_modules/.bin/rimraf "$TO_SOURCE_DIR" + node_modules/.bin/rimraf "$PACK_DIR" + + # copy src + echo 'Copying src...' + node_modules/.bin/ncp "$SOURCE_DIR" "$TO_SOURCE_DIR" + + # copy README & LICENSE to src + echo 'Copying README and LICENSE to /src...' + node_modules/.bin/ncp "$ROOT_DIR"/LICENSE "$TO_SOURCE_DIR"/LICENSE + node_modules/.bin/ncp "$ROOT_DIR"/README.md "$TO_SOURCE_DIR"/README.md + + # compile package and copy files required by npm + echo 'Building /src...' + cd "$TO_SOURCE_DIR" + node_modules/.bin/tsc + cd .. + + echo 'Creating package...' + # create package dir + mkdir "$PACK_DIR" + + # create the package + cd "$PACK_DIR" + npm pack ../"$TO_SOURCE_DIR" + + # delete source directory used to create the package + cd .. + node_modules/.bin/rimraf "$TO_SOURCE_DIR" +} + +install && pack diff --git a/publish/package.json b/publish/package.json new file mode 100644 index 0000000..b84f136 --- /dev/null +++ b/publish/package.json @@ -0,0 +1,9 @@ +{ + "name": "nativescript-publish", + "version": "1.0.0", + "description": "Publish helper", + "devDependencies": { + "ncp": "^2.0.0", + "rimraf": "^2.5.0" + } + } \ No newline at end of file diff --git a/publish/publish.sh b/publish/publish.sh new file mode 100644 index 0000000..224a771 --- /dev/null +++ b/publish/publish.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +PACK_DIR=package + +publish() { + cd $PACK_DIR + echo 'Publishing to npm...' + npm publish *.tgz +} + +./pack.sh && publish