Upload packaging folder
[platform/upstream/iotjs.git] / docs / devs / IoT.js-Package-(outdated).md
1 **The content on this page does not work. Currently, there is no plan to run ipm server. This document will leave for discussion in the future.**
2
3 IoT.js follows the practice of node.js npm to provide module development community with separate IoT.js own registry.
4
5 * To see what it actually is, please visit [www.npmjs.com](https://www.npmjs.com/), and also [docs.npmjs.com](https://docs.npmjs.com/).
6 * To avoid confusion with the original server, we'll call it "ipm", for IoT.js Package Manager.
7 * Current status of "ipm" is started and it's for developers so has no separate web page. We need to develop them.
8 * "npm" program is used for publish and download modules. We may fork when customization is needed.
9
10 ### Installing "npm"
11 ```
12 sudo apt-get install npm
13 ```
14
15 ### Setting registry
16
17 As ipm uses different server, you need to change registry information
18 ```
19 npm config set registry="http://ipm.iotjs.net:5984/registry/_design/app/_rewrite"
20 ```
21
22 ### Adding your account
23
24 You may have to register your account if you plan to publish some packages, for example,
25 ```
26 npm set init.author.name "Your Name"
27 npm set init.author.email "you@example.com"
28 npm set init.author.url "http://yourblog.com"
29 npm adduser
30 ```
31 Please set to your real name and email address. url is optional.
32
33 ### Publish a package
34
35 cd to your package folder you wish to publish and init
36 ```
37 npm init
38 ```
39
40 It'll ask information for your package, for an example;
41 ```
42 Press ^C at any time to quit.
43 name: (t) echotest
44 version: (1.0.0) 0.0.1
45 description: simple echo server
46 entry point: (index.js)
47 test command:
48 git repository:
49 keywords:
50 license: (ISC)
51 About to write to /(your working folder)/package.json:
52 {
53   "name": "echotest",
54   "version": "0.0.1",
55   "description": "simple echo server",
56   "main": "index.js",
57   "scripts": {
58     "test": "echo \"Error: no test specified\" && exit 1"
59   },
60   "author": "(your name) <your email address> (your blog page)",
61   "license": "ISC"
62 }
63
64 Is this ok? (yes) yes
65 ```
66
67 and all things are good to go, publish.
68 ```
69 npm publish ./
70 ```
71
72 Please visit [npmjs.org](https://docs.npmjs.com/getting-started/publishing-npm-packages) for detailed explanations.
73
74
75 ### About the license of each packages
76
77 IoT.js is released under Apache 2.0 license, [this page](../License.md). We assume you also agree on this license when publishing to ipm registry.
78
79 ### Downloading packages
80
81 "npm" provides local and global packages and you may be working on some powerful machines. In IoT devices this may be somewhat different. It may not have enough memory, power, network or even no console to give commands. So it can have several scenarios depending on the device you may be working on. This may be some of them;
82
83 1) Download to your machine with Linux, Mac or Windows.
84   * Install packages to your powerful machine
85   * Send it to the IoT device through copy to memory card
86   * or send through serial line, BT, USB with old time kermit or z-modem
87
88 2) If it has a WiFi the download directly from the registry
89   * But to make this work, we need to develop a small shell program with iotjs.
90   * This can be done with built-in module downloader, we need to develop this.
91   * Issue [#75](https://github.com/Samsung/iotjs/issues/75) to track
92
93 3) If your IoT is very small and even has no writable file system
94   * Package modules should be built-in to IoT.js at compile time.
95   * We should also develop this.
96
97 4) any more ideas?
98
99
100 As for case 1),
101 ```
102 (cd to some working directory)
103 npm install <package name>
104 (copy node_modules folder to your device)
105 ```
106
107 As mentioned above, npm has local and global packages. But for IoT.js lets stick on the local only. For some cases running on ROTS there may not be any globals place.
108
109 ### Package license
110
111 You may use ipm packages freely under Apache 2.0 license, read [this page](../License.md)
112
113 ### Searching for packages
114
115 Searching is possible with search command. See [docs.npmjs.com/cli/search](https://docs.npmjs.com/cli/search).
116
117 ```
118 npm search <keyword>
119 ```
120
121 If you omit the keyword, it'll list all packages registered.