@jnanda/a_library 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/captain.js +21 -0
  3. package/package.json +12 -0
  4. package/readme.md +347 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jagannat Nanda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/captain.js ADDED
@@ -0,0 +1,21 @@
1
+ (function (global) {
2
+
3
+ const Captain = {
4
+
5
+ sum: function(a, b) {
6
+ return a + b;
7
+ },
8
+
9
+ multiply: function(a, b) {
10
+ return a * b;
11
+ },
12
+
13
+ capitalize: function(str) {
14
+ return str.charAt(0).toUpperCase() + str.slice(1);
15
+ }
16
+
17
+ };
18
+
19
+ global.Captain = Captain;
20
+
21
+ })(typeof window !== "undefined" ? window : global);
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@jnanda/a_library",
3
+ "version": "1.0.0",
4
+ "description": "my sample library",
5
+ "main": "captain.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": ["captain", "js", "library","sample"],
10
+ "author": "jnanda",
11
+ "license": "MIT"
12
+ }
package/readme.md ADDED
@@ -0,0 +1,347 @@
1
+ # 🚀 Captain.js — Complete npm Publishing Guide
2
+
3
+ This document contains everything needed to build, structure, and publish `captain.js` to npm professionally.
4
+
5
+ ---
6
+
7
+ # 1️⃣ Prerequisites
8
+
9
+ Make sure you have:
10
+
11
+ - Node.js installed
12
+ - npm installed
13
+ - Git installed
14
+ - GitHub account
15
+ - npm account
16
+
17
+ Check versions:
18
+
19
+ ```bash
20
+ node -v
21
+ npm -v
22
+ git --version
23
+ ```
24
+
25
+ ---
26
+
27
+ # 2️⃣ Create Project Folder
28
+
29
+ ```bash
30
+ mkdir captain-js
31
+ cd captain-js
32
+ ```
33
+
34
+ ---
35
+
36
+ # 3️⃣ Create Library File
37
+
38
+ Create:
39
+
40
+ ```
41
+ captain.js
42
+ ```
43
+
44
+ Add:
45
+
46
+ ```javascript
47
+ (function (global) {
48
+
49
+ const Captain = {
50
+
51
+ sum: function(a, b) {
52
+ return a + b;
53
+ },
54
+
55
+ multiply: function(a, b) {
56
+ return a * b;
57
+ },
58
+
59
+ capitalize: function(str) {
60
+ return str.charAt(0).toUpperCase() + str.slice(1);
61
+ }
62
+
63
+ };
64
+
65
+ global.Captain = Captain;
66
+
67
+ })(typeof window !== "undefined" ? window : global);
68
+ ```
69
+
70
+ ---
71
+
72
+ # 4️⃣ Initialize npm
73
+
74
+ ```bash
75
+ npm init -y
76
+ ```
77
+
78
+ Edit `package.json`:
79
+
80
+ ```json
81
+ {
82
+ "name": "captain-js",
83
+ "version": "1.0.0",
84
+ "description": "A tiny OG JavaScript utility library",
85
+ "main": "captain.js",
86
+ "keywords": ["javascript", "utility", "library"],
87
+ "author": "Your Name",
88
+ "license": "MIT"
89
+ }
90
+ ```
91
+
92
+ ⚠️ Note: Package name must be unique on npm.
93
+
94
+ ---
95
+
96
+ # 5️⃣ Create README.md
97
+
98
+ Create:
99
+
100
+ ```
101
+ README.md
102
+ ```
103
+
104
+ Example content:
105
+
106
+ ```markdown
107
+ # Captain.js
108
+
109
+ A tiny OG JavaScript utility library.
110
+
111
+ ## Installation
112
+
113
+ ```bash
114
+ npm install captain-js
115
+ ```
116
+
117
+ ## CDN Usage
118
+
119
+ ```html
120
+ <script src="https://cdn.jsdelivr.net/npm/captain-js@1.0.0/captain.js"></script>
121
+ ```
122
+
123
+ ## Example
124
+
125
+ ```javascript
126
+ Captain.sum(2, 3); // 5
127
+ ```
128
+ ```
129
+
130
+ ---
131
+
132
+ # 6️⃣ Create .gitignore
133
+
134
+ Create:
135
+
136
+ ```
137
+ .gitignore
138
+ ```
139
+
140
+ Add:
141
+
142
+ ```
143
+ # Dependencies
144
+ node_modules/
145
+
146
+ # Logs
147
+ npm-debug.log*
148
+ yarn-debug.log*
149
+ yarn-error.log*
150
+
151
+ # Environment files
152
+ .env
153
+ .env.local
154
+
155
+ # OS files
156
+ .DS_Store
157
+ Thumbs.db
158
+
159
+ # Optional future build folders
160
+ dist/
161
+ build/
162
+ coverage/
163
+ ```
164
+
165
+ ### Why `.gitignore`?
166
+
167
+ It prevents unnecessary files (like `node_modules`) from being committed to GitHub.
168
+
169
+ ---
170
+
171
+ # 7️⃣ Create LICENSE (MIT)
172
+
173
+ Create:
174
+
175
+ ```
176
+ LICENSE
177
+ ```
178
+
179
+ Add:
180
+
181
+ ```
182
+ MIT License
183
+
184
+ Copyright (c) 2026 Your Name
185
+
186
+ Permission is hereby granted, free of charge, to any person obtaining a copy
187
+ of this software and associated documentation files (the "Software"), to deal
188
+ in the Software without restriction, including without limitation the rights
189
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
190
+ copies of the Software...
191
+ ```
192
+
193
+ (Use full MIT template from https://opensource.org/licenses/MIT)
194
+
195
+ ### Why License?
196
+
197
+ Without a license, legally no one can use your code.
198
+
199
+ MIT allows:
200
+ - Commercial use
201
+ - Modification
202
+ - Distribution
203
+ - Private use
204
+
205
+ Requires:
206
+ - Keeping copyright notice
207
+
208
+ ---
209
+
210
+ # 8️⃣ Initialize Git
211
+
212
+ ```bash
213
+ git init
214
+ git add .
215
+ git commit -m "Initial commit"
216
+ ```
217
+
218
+ ---
219
+
220
+ # 9️⃣ Push to GitHub
221
+
222
+ Create a repository on GitHub named `captain-js`.
223
+
224
+ Then:
225
+
226
+ ```bash
227
+ git remote add origin https://github.com/yourusername/captain-js.git
228
+ git branch -M main
229
+ git push -u origin main
230
+ ```
231
+
232
+ ---
233
+
234
+ # 🔟 Login to npm
235
+
236
+ ```bash
237
+ npm login
238
+ ```
239
+
240
+ Enter username, password, email, and OTP if required.
241
+
242
+ Check login:
243
+
244
+ ```bash
245
+ npm whoami
246
+ ```
247
+
248
+ ---
249
+
250
+ # 1️⃣1️⃣ Publish to npm
251
+
252
+ ```bash
253
+ npm publish
254
+ ```
255
+
256
+ If successful:
257
+
258
+ ```
259
+ + captain-js@1.0.0
260
+ ```
261
+
262
+ ---
263
+
264
+ # 1️⃣2️⃣ CDN Usage (Automatic)
265
+
266
+ After publishing, your package is automatically available on CDN:
267
+
268
+ ```
269
+ https://cdn.jsdelivr.net/npm/captain-js@1.0.0/captain.js
270
+ ```
271
+
272
+ Use in HTML:
273
+
274
+ ```html
275
+ <script src="https://cdn.jsdelivr.net/npm/captain-js@1.0.0/captain.js"></script>
276
+ ```
277
+
278
+ ---
279
+
280
+ # 1️⃣3️⃣ Updating Version
281
+
282
+ You cannot overwrite a published version.
283
+
284
+ Update version in `package.json`:
285
+
286
+ ```json
287
+ "version": "1.0.1"
288
+ ```
289
+
290
+ Then:
291
+
292
+ ```bash
293
+ npm publish
294
+ ```
295
+
296
+ ---
297
+
298
+ # 1️⃣4️⃣ Semantic Versioning
299
+
300
+ Format:
301
+
302
+ ```
303
+ MAJOR.MINOR.PATCH
304
+ ```
305
+
306
+ Examples:
307
+
308
+ - 1.0.1 → Bug fix
309
+ - 1.1.0 → New feature
310
+ - 2.0.0 → Breaking change
311
+
312
+ ---
313
+
314
+ # 📁 Final Folder Structure
315
+
316
+ ```
317
+ captain-js/
318
+
319
+ ├── captain.js
320
+ ├── package.json
321
+ ├── README.md
322
+ ├── LICENSE
323
+ └── .gitignore
324
+ ```
325
+
326
+ ---
327
+
328
+ # 🏁 You Are Now
329
+
330
+ ✔ A published npm package author
331
+ ✔ CDN-distributed globally
332
+ ✔ Properly licensed
333
+ ✔ Professionally structured
334
+
335
+ ---
336
+
337
+ # 🚀 Optional Next Steps
338
+
339
+ - Add minified build
340
+ - Add TypeScript definitions
341
+ - Add CI/CD auto publish
342
+ - Add automated version bumping
343
+ - Convert to ES Module + UMD
344
+
345
+ ---
346
+
347
+ Captain.js is now officially live-ready.