@investorphem/string-tools 1.0.1 → 1.0.3

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.
@@ -1,44 +1,42 @@
1
- name: Auto Publish to npm
1
+ name: Publish SDK
2
2
 
3
3
  on:
4
4
  push:
5
5
  branches:
6
6
  - main
7
- workflow_dispatch:
8
7
 
9
8
  jobs:
10
9
  publish:
11
10
  runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
12
13
 
13
14
  steps:
14
- # 1️⃣ Checkout the repository
15
- - uses: actions/checkout@v3
15
+ - name: Checkout repository
16
+ uses: actions/checkout@v4
16
17
 
17
- # 2️⃣ Setup Node.js and npm
18
- - uses: actions/setup-node@v3
18
+ - name: Setup Node
19
+ uses: actions/setup-node@v4
19
20
  with:
20
- node-version: '20'
21
+ node-version: 20
21
22
  registry-url: 'https://registry.npmjs.org/'
22
23
 
23
- # 3️⃣ Install dependencies
24
- - run: npm install
24
+ - name: Install dependencies
25
+ run: npm install
25
26
 
26
- # 4️⃣ Optional: Run tests
27
- - run: npm test || echo "No tests found, continuing..."
28
-
29
- # 5️⃣ Configure Git for npm version commit
30
- - name: Configure Git
31
- run: |
32
- git config user.name "GitHub Actions"
33
- git config user.email "actions@github.com"
34
-
35
- # 6️⃣ Auto-increment patch version
36
- - name: Bump version
37
- run: |
38
- npm version patch -m "ci: bump version to %s"
39
-
40
- # 7️⃣ Publish to npm
41
- - name: Publish package
42
- run: npm publish --access public
27
+ - name: Publish to npm
43
28
  env:
44
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
30
+ run: |
31
+ # Get the current version from package.json
32
+ PACKAGE_NAME=$(node -p "require('./package.json').name")
33
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
34
+
35
+ # Check if this specific version is already on npm
36
+ if npm view "$PACKAGE_NAME@$CURRENT_VERSION" version > /dev/null 2>&1; then
37
+ echo "⚠️ Version $CURRENT_VERSION already exists on npm. Skipping publish."
38
+ exit 0
39
+ else
40
+ echo "🚀 Publishing version $CURRENT_VERSION..."
41
+ npm publish --access public
42
+ fi
package/README.md CHANGED
@@ -1,66 +1,171 @@
1
- @investorphem/string-tools
1
+ # @investorphem/string-tools
2
2
 
3
-
3
+ [![npm version](https://img.shields.io/npm/v/@investorphem/string-tools.svg?style=flat-square)](https://www.npmjs.com/package/@investorphem/string-tools)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@investorphem/string-tools.svg?style=flat-square)](https://www.npmjs.com/package/@investorphem/string-tools)
5
+ [![License](https://img.shields.io/npm/l/@investorphem/string-tools.svg?style=flat-square)](LICENSE)
6
+ [![Build Status](https://github.com/investorphem/string-tools/actions/workflows/publish.yml/badge.svg)](https://github.com/investorphem/string-tools/actions/workflows/publish.yml)
7
+ [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
8
+ [![Contributors](https://img.shields.io/github/contributors/investorphem/string-tools.svg)](https://github.com/investorphem/string-tools/graphs/contributors)
4
9
 
10
+ ---
11
+
12
+ ## 🚀 Description
13
+
14
+ `@investorphem/string-tools` is a robust, lightweight, and production-ready JavaScript utility library for handling common string operations.
15
+
16
+ It is designed for developers who want **simple, fast, and dependency-free utilities** with **automated CI/CD publishing via GitHub Actions**.
5
17
 
6
18
  ---
7
19
 
8
- Description
20
+ ## ✨ Features
21
+
22
+ * 🔠 Capitalize the first letter of any string
23
+ * 🔗 Convert strings to kebab-case
24
+ * 🔄 Reverse strings efficiently
25
+ * ⚡ Zero dependencies (lightweight)
26
+ * 🤖 Fully automated npm publishing with GitHub Actions
27
+ * 📦 Scoped package for better organization (`@investorphem/*`)
9
28
 
10
- @investorphem/string-tools is a lightweight and robust collection of string utility functions for JavaScript developers. It includes commonly needed functions like capitalizing strings, converting to kebab-case, and reversing strings.
29
+ ---
11
30
 
12
- Installation
31
+ ## 📦 Installation
13
32
 
33
+ ```bash
14
34
  npm install @investorphem/string-tools
35
+ ```
15
36
 
16
- Usage
37
+ ---
38
+
39
+ ## 🧠 Usage
17
40
 
41
+ ```js
18
42
  const { capitalize, kebabCase, reverse } = require('@investorphem/string-tools');
19
43
 
20
44
  console.log(capitalize('hello')); // Hello
21
45
  console.log(kebabCase('Hello World')); // hello-world
22
46
  console.log(reverse('abc')); // cba
47
+ ```
48
+
49
+ ---
50
+
51
+ ## 📚 API Reference
52
+
53
+ ### `capitalize(str)`
23
54
 
24
- Functions
55
+ Capitalizes the first character of a string.
25
56
 
26
- capitalize(str)
57
+ **Parameters:**
27
58
 
28
- Capitalizes the first letter of the given string.
59
+ * `str` *(string)* The string to capitalize
29
60
 
30
- capitalize('hello'); // Hello
61
+ **Returns:**
31
62
 
32
- kebabCase(str)
63
+ * *(string)* – Capitalized string
64
+
65
+ ---
66
+
67
+ ### `kebabCase(str)`
33
68
 
34
69
  Converts a string to kebab-case.
35
70
 
36
- kebabCase('Hello World'); // hello-world
71
+ **Parameters:**
72
+
73
+ * `str` *(string)* – The string to convert
74
+
75
+ **Returns:**
76
+
77
+ * *(string)* – Kebab-case string
78
+
79
+ ---
80
+
81
+ ### `reverse(str)`
82
+
83
+ Reverses the input string.
84
+
85
+ **Parameters:**
86
+
87
+ * `str` *(string)* – The string to reverse
37
88
 
38
- reverse(str)
89
+ **Returns:**
39
90
 
40
- Reverses the string.
91
+ * *(string)* – Reversed string
41
92
 
42
- reverse('abc'); // cba
93
+ ---
94
+
95
+ ## ⚙️ CI/CD (GitHub Actions)
96
+
97
+ This project is fully automated using GitHub Actions:
98
+
99
+ * On every push to `main`:
100
+
101
+ * Version is automatically bumped (patch)
102
+ * Package is published to npm
103
+
104
+ ### ⚠️ Important Note
105
+
106
+ If publishing fails with:
107
+
108
+ ```
109
+ 403 Forbidden - You cannot publish over the previously published versions
110
+ ```
111
+
112
+ It means:
113
+
114
+ * npm does **NOT allow publishing the same version twice**
115
+ * Ensure version is properly incremented before publishing
116
+
117
+ ---
43
118
 
44
- Contributing
119
+ ## 🛠️ Contributing
45
120
 
46
- Contributions are welcome! Please fork the repository and submit pull requests. Ensure all tests pass before submitting.
121
+ Contributions are welcome!
47
122
 
48
- License
123
+ 1. Fork the repository
124
+ 2. Create a new branch
125
+ 3. Make your changes
126
+ 4. Submit a pull request
127
+
128
+ Make sure your code follows the [StandardJS style guide](https://standardjs.com).
129
+
130
+ ---
131
+
132
+ ## 📄 License
49
133
 
50
134
  This project is licensed under the MIT License.
51
135
 
52
- Badges Explained
136
+ ---
137
+
138
+ ## 🏷️ Badges Explained
53
139
 
54
- npm version: Shows the latest version on npm.
140
+ * **npm version** Latest published version
141
+ * **npm downloads** → Monthly downloads count
142
+ * **License** → Project license
143
+ * **Build Status** → GitHub Actions workflow status
144
+ * **Code Style** → StandardJS compliance
145
+ * **Contributors** → Number of contributors
146
+
147
+ ---
148
+
149
+ ## 👨‍💻 Author
150
+
151
+ **Oluwafemi Olagoke**
152
+
153
+ ---
55
154
 
56
- npm downloads: Shows total downloads from npm.
155
+ ## 🔥 Pro Tip
57
156
 
58
- License: Shows the license type.
157
+ Always ensure your version changes before publishing. GitHub Actions handles this automatically, but if you manually publish, run:
59
158
 
60
- Build Status: Shows GitHub Action status for auto-publishing.
159
+ ```bash
160
+ npm version patch
161
+ ```
61
162
 
163
+ before:
62
164
 
165
+ ```bash
166
+ npm publish
167
+ ```
63
168
 
64
169
  ---
65
170
 
66
- Maintained by Oluwafemi Olagoke
171
+ If you find this package useful, consider giving the repo a star!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@investorphem/string-tools",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "main": "index.js",
5
5
  "description": "Handy string utility functions for developers",
6
6
  "scripts": {
@@ -13,4 +13,4 @@
13
13
  ],
14
14
  "author": "Oluwafemi Olagoke",
15
15
  "license": "MIT"
16
- }
16
+ }