-
Notifications
You must be signed in to change notification settings - Fork 1
/
create-npm-pkg.sh
executable file
·125 lines (100 loc) · 2.26 KB
/
create-npm-pkg.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env bash
# Create npm package and git repo. + travis-ci
# dependencies: hub.github.com, ~/.gh-user with your gh login
name=$1
description=$2
homepage="https://npmjs.com/package/$name"
user=$(cat ~/.gh-user)
origin="[email protected]:$user/$name.git"
mkdir $name && cd $name
##
##
echo setup defaults...
cat << PKG > package.json
{
"name": "$name",
"description": "$description",
"version": "0.1.0",
"main": "src/index.js",
"scripts": {
"test": "ava"
},
"devDependencies": {
"ava": "^0.20.0"
},
"repository": {
"url": "$origin",
"type": "git"
},
"author": "$(git config user.name) <$(git config user.email)>"
}
PKG
echo '#macOS' >> .gitignore
http https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore >> .gitignore
echo '#node' >> .gitignore
http https://raw.githubusercontent.com/github/gitignore/master/Node.gitignore >> .gitignore
echo "# $name [![Build Status](https://travis-ci.org/$user/$name.svg?branch=master)](https://travis-ci.org/$user/$name)" >> README.md
echo >> README.md
echo $description >> README.md
echo >> README.md
echo '## usage' >> README.md
echo >> README.md
cat << EOF > .travis.yml
language: node_js
node_js:
- "node"
EOF
cat << EOF > test.js
import test from 'ava';
import lib from './src';
test('foo', t => {
t.pass();
});
test('bar', async t => {
const bar = Promise.resolve('bar');
t.is(await bar, 'bar');
});
EOF
##
##
echo yarn init...
yarn init
yarn add --dev ava
##
##
mkdir src test docs build
##
##
echo git init...
git init
echo $description > .git/description
##
##
echo create repo...
result="$(\
hub create -d "$description" -h "$homepage" "$name"\
)"
echo $result # todo parse repo
##
##
echo commit and push...
git add .
git commit -m init
#git remote add origin $origin # hub added already
git push -u origin master
##
##
echo npm publish...
npm publish
##
##
echo enable travis...
travis enable -r $user/$name || echo -e "do it manually:\ntravis enable -r $user/$name"
echo -e "\n🎉 done\n cd $name"
# echo '{ \
# "name": "'$name'",\
# "description": "'$description'",\
# "homepage": "https://npmjs.com/package/'$name'",\
# "has_wiki": false\
# }' | http post "https://api.github.com/repos/$(cat ~/.gh-user)" "Authorization: token $(cat ~/.gh-token)"
#