Skip to content

chore: add publish scripts #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"id": "org.nativescript.demo",
"tns-android": {
"version": "3.4.1"
},
"tns-ios": {
"version": "3.4.1"
}
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"scripts": {
"tsc": "cd src && npm i && npm run tsc",
"tsc": "cd src && npm i && tsc",
"start-server": "cd demo-server && npm i && node server.js 8080",
"start-demo": "npm run start-demo-android",
"start-demo-android": "npm run tsc && cd demo && npm i && tns run android",
"start-demo-ios": "npm run tsc && cd demo && npm i && tns run ios"
}
}
}
48 changes: 48 additions & 0 deletions publish/pack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
set -e
CURRENT_DIR=$(pwd)
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"

# build plugin
echo 'Building plugin...'
cd "$SOURCE_DIR"
npm run build
cd "$CURRENT_DIR"

# copy plugin
echo 'Copying plugin source...'
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

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
9 changes: 9 additions & 0 deletions publish/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "nativescript-publish",
"version": "1.0.0",
"description": "Publish helper",
"devDependencies": {
"ncp": "^2.0.0",
"rimraf": "^2.5.0"
}
}
11 changes: 11 additions & 0 deletions publish/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

PACK_DIR=package;

publish() {
cd $PACK_DIR
echo 'Publishing to npm...'
npm publish *.tgz
}

./pack.sh && publish
4 changes: 2 additions & 2 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"typescript": "~2.7.1"
},
"scripts": {
"tsc": "tsc",
"build": "npm i && tsc",
"prepack": "tsc"
}
}
}