Skip to content

Commit 46687b8

Browse files
authored
Merge pull request #116 from NativeScript/tbozhikov/add-publish-scripts
chore: add publish scripts
2 parents 2324ca1 + 3cd82f3 commit 46687b8

File tree

6 files changed

+75
-4
lines changed

6 files changed

+75
-4
lines changed

demo/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"id": "org.nativescript.demo",
88
"tns-android": {
99
"version": "3.4.1"
10+
},
11+
"tns-ios": {
12+
"version": "3.4.1"
1013
}
1114
},
1215
"dependencies": {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"scripts": {
3-
"tsc": "cd src && npm i && npm run tsc",
3+
"tsc": "cd src && npm i && tsc",
44
"start-server": "cd demo-server && npm i && node server.js 8080",
55
"start-demo": "npm run start-demo-android",
66
"start-demo-android": "npm run tsc && cd demo && npm i && tns run android",
77
"start-demo-ios": "npm run tsc && cd demo && npm i && tns run ios"
88
}
9-
}
9+
}

publish/pack.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
set -e
3+
CURRENT_DIR=$(pwd)
4+
SOURCE_DIR=../src;
5+
TO_SOURCE_DIR=src;
6+
PACK_DIR=package;
7+
ROOT_DIR=..;
8+
PUBLISH=--publish
9+
10+
install(){
11+
npm i
12+
}
13+
14+
pack() {
15+
16+
echo 'Clearing /src and /package...'
17+
node_modules/.bin/rimraf "$TO_SOURCE_DIR"
18+
node_modules/.bin/rimraf "$PACK_DIR"
19+
20+
# build plugin
21+
echo 'Building plugin...'
22+
cd "$SOURCE_DIR"
23+
npm run build
24+
cd "$CURRENT_DIR"
25+
26+
# copy plugin
27+
echo 'Copying plugin source...'
28+
node_modules/.bin/ncp "$SOURCE_DIR" "$TO_SOURCE_DIR"
29+
30+
# copy README & LICENSE to src
31+
echo 'Copying README and LICENSE to /src...'
32+
node_modules/.bin/ncp "$ROOT_DIR"/LICENSE "$TO_SOURCE_DIR"/LICENSE
33+
node_modules/.bin/ncp "$ROOT_DIR"/README.md "$TO_SOURCE_DIR"/README.md
34+
35+
echo 'Creating package...'
36+
# create package dir
37+
mkdir "$PACK_DIR"
38+
39+
# create the package
40+
cd "$PACK_DIR"
41+
npm pack ../"$TO_SOURCE_DIR"
42+
43+
# delete source directory used to create the package
44+
cd ..
45+
node_modules/.bin/rimraf "$TO_SOURCE_DIR"
46+
}
47+
48+
install && pack

publish/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "nativescript-publish",
3+
"version": "1.0.0",
4+
"description": "Publish helper",
5+
"devDependencies": {
6+
"ncp": "^2.0.0",
7+
"rimraf": "^2.5.0"
8+
}
9+
}

publish/publish.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
PACK_DIR=package;
4+
5+
publish() {
6+
cd $PACK_DIR
7+
echo 'Publishing to npm...'
8+
npm publish *.tgz
9+
}
10+
11+
./pack.sh && publish

src/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"typescript": "~2.7.1"
3636
},
3737
"scripts": {
38-
"tsc": "tsc",
38+
"build": "npm i && tsc",
3939
"prepack": "tsc"
4040
}
41-
}
41+
}

0 commit comments

Comments
 (0)