@investorphem/string-tools 1.0.1 → 1.0.2
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.
- package/.github/workflows/publish.yml +25 -27
- package/README.md +129 -24
- package/package.json +1 -1
|
@@ -1,44 +1,42 @@
|
|
|
1
|
-
name:
|
|
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
|
-
|
|
15
|
-
|
|
15
|
+
- name: Checkout repository
|
|
16
|
+
uses: actions/checkout@v4
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
- name: Setup Node
|
|
19
|
+
uses: actions/setup-node@v4
|
|
19
20
|
with:
|
|
20
|
-
node-version:
|
|
21
|
+
node-version: 20
|
|
21
22
|
registry-url: 'https://registry.npmjs.org/'
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: npm install
|
|
25
26
|
|
|
26
|
-
|
|
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
|
+
[](https://www.npmjs.com/package/@investorphem/string-tools)
|
|
4
|
+
[](https://www.npmjs.com/package/@investorphem/string-tools)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://github.com/investorphem/string-tools/actions/workflows/publish.yml)
|
|
7
|
+
[](https://standardjs.com)
|
|
8
|
+
[](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
|
-
|
|
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
|
-
|
|
29
|
+
---
|
|
11
30
|
|
|
12
|
-
Installation
|
|
31
|
+
## 📦 Installation
|
|
13
32
|
|
|
33
|
+
```bash
|
|
14
34
|
npm install @investorphem/string-tools
|
|
35
|
+
```
|
|
15
36
|
|
|
16
|
-
|
|
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
|
-
|
|
55
|
+
Capitalizes the first character of a string.
|
|
25
56
|
|
|
26
|
-
|
|
57
|
+
**Parameters:**
|
|
27
58
|
|
|
28
|
-
|
|
59
|
+
* `str` *(string)* – The string to capitalize
|
|
29
60
|
|
|
30
|
-
|
|
61
|
+
**Returns:**
|
|
31
62
|
|
|
32
|
-
|
|
63
|
+
* *(string)* – Capitalized string
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
### `kebabCase(str)`
|
|
33
68
|
|
|
34
69
|
Converts a string to kebab-case.
|
|
35
70
|
|
|
36
|
-
|
|
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
|
-
|
|
89
|
+
**Returns:**
|
|
39
90
|
|
|
40
|
-
|
|
91
|
+
* *(string)* – Reversed string
|
|
41
92
|
|
|
42
|
-
|
|
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!
|
|
121
|
+
Contributions are welcome!
|
|
47
122
|
|
|
48
|
-
|
|
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
|
-
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 🏷️ Badges Explained
|
|
53
139
|
|
|
54
|
-
npm version
|
|
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
|
-
|
|
155
|
+
## 🔥 Pro Tip
|
|
57
156
|
|
|
58
|
-
|
|
157
|
+
Always ensure your version changes before publishing. GitHub Actions handles this automatically, but if you manually publish, run:
|
|
59
158
|
|
|
60
|
-
|
|
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
|
-
|
|
171
|
+
⭐ If you find this package useful, consider giving the repo a star!
|