devkits-case-convert 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/README.md +131 -0
  2. package/index.js +168 -0
  3. package/package.json +48 -0
  4. package/test.js +81 -0
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # devkits-case-convert
2
+
3
+ > Convert text between camelCase, snake_case, kebab-case, and more
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g devkits-case-convert
9
+ ```
10
+
11
+ Or use without installation:
12
+
13
+ ```bash
14
+ npx devkits-case-convert [args]
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```bash
20
+ # Convert to camelCase
21
+ dk-case "hello world" -t camel # helloWorld
22
+
23
+ # Convert to PascalCase
24
+ dk-case "hello world" -t pascal # HelloWorld
25
+
26
+ # Convert to snake_case
27
+ dk-case "helloWorld" -t snake # hello_world
28
+
29
+ # Convert to kebab-case
30
+ dk-case "hello_world" -t kebab # hello-world
31
+
32
+ # Convert to CONSTANT_CASE
33
+ dk-case "helloWorld" -t constant # HELLO_WORLD
34
+
35
+ # Convert to Sentence case
36
+ dk-case "hello world" -t sentence # Hello world
37
+
38
+ # Convert to Title Case
39
+ dk-case "hello world" -t title # Hello World
40
+
41
+ # Convert to lowercase
42
+ dk-case "Hello World" -t lower # hello world
43
+
44
+ # Convert to UPPERCASE
45
+ dk-case "Hello World" -t upper # HELLO WORLD
46
+
47
+ # From stdin
48
+ echo "hello_world" | dk-case -t camel # helloWorld
49
+ ```
50
+
51
+ ## Why @devkits/case-convert?
52
+
53
+ - ✅ Fast - Instant conversion
54
+ - ✅ Zero dependencies - Pure Node.js
55
+ - ✅ Offline - Works without internet
56
+ - ✅ Free - Open source (MIT)
57
+ - ✅ CLI - Use in your terminal
58
+ - ✅ 9 case formats supported
59
+
60
+ ## Web Version
61
+
62
+ Prefer a GUI? Check out the web version: **https://devkits-tools.surge.sh/tools/text-case**
63
+
64
+ - 84 developer tools in one PWA
65
+ - Works offline
66
+ - No signup required
67
+
68
+ ## Pro Features
69
+
70
+ Upgrade to Pro for advanced features:
71
+
72
+ - 📦 Batch Processing
73
+ - 🔗 API Access (1000 req/day free)
74
+ - ☁️ Cloud Sync
75
+ - 🎨 Custom Themes
76
+ - 📊 Advanced Analytics
77
+ - 💬 Priority Support
78
+
79
+ **Price:** $9 one-time payment
80
+ **Upgrade:** https://devkits-tools.surge.sh/pro
81
+ **Discount:** Use code `EARLYBIRD-2026` for 20% off
82
+
83
+ ## See Also
84
+
85
+ Part of the **[DevKits Tools](https://devkits-tools.surge.sh)** collection — 80+ free developer tools:
86
+
87
+ ### Popular Tools
88
+
89
+ | Tool | npm Package | Description |
90
+ |------|-------------|-------------|
91
+ | **[Base64](https://devkits-tools.surge.sh/tools/base64)** | `@devkits/base64` | Encode/decode Base64 |
92
+ | **[JSON Formatter](https://devkits-tools.surge.sh/tools/json-formatter)** | `@devkits/json-formatter` | Format and validate JSON |
93
+ | **[Color Converter](https://devkits-tools.surge.sh/tools/color-converter)** | `@devkits/color-converter` | HEX/RGB/HSL conversion |
94
+ | **[UUID Generator](https://devkits-tools.surge.sh/tools/uuid-generator)** | `@devkits/uuid-generator` | Generate unique UUIDs |
95
+ | **[Hash Generator](https://devkits-tools.surge.sh/tools/hash-generator)** | `@devkits/hash-generator` | MD5, SHA1, SHA256, SHA512 |
96
+ | **[Regex Tester](https://devkits-tools.surge.sh/tools/regex-tester)** | `@devkits/regex-tester` | Test regex patterns |
97
+
98
+ ### Other DevKits Tools
99
+
100
+ - **[HTML Tools](https://devkits-tools.surge.sh/tools/html-entities)** — HTML entity encode/decode
101
+ - **[CSS Tools](https://devkits-tools.surge.sh/tools/css-minifier)** — CSS minify/format
102
+ - **[Cron Parser](https://devkits-tools.surge.sh/tools/cron-parser)** — Parse cron expressions
103
+ - **[Slugify](https://devkits-tools.surge.sh/tools/slug-generator)** — Create URL-friendly slugs
104
+ - **[Lorem Ipsum](https://devkits-tools.surge.sh/tools/lorem-ipsum)** — Generate placeholder text
105
+ - **[Password Generator](https://devkits-tools.surge.sh/tools/password-generator)** — Secure passwords
106
+ - **[Text Counter](https://devkits-tools.surge.sh/tools/text-counter)** — Word/char counter
107
+ - **[Timestamp](https://devkits-tools.surge.sh/tools/timestamp)** — Unix timestamp converter
108
+
109
+ ---
110
+
111
+ ### More from DevKits
112
+
113
+ - **[Invoicely](https://invoicely-app.surge.sh)** — Free invoice generator for freelancers
114
+ - **[SnapOG](https://snapog.surge.sh)** — Free OG image generator with 20+ templates
115
+ - **[API Monitor](https://api-monitor-saas.surge.sh)** — Real-time API monitoring
116
+
117
+ ---
118
+
119
+ 👉 **Explore all 80+ developer tools at [DevKits Tools](https://devkits-tools.surge.sh)**
120
+
121
+ ## License
122
+
123
+ MIT © [DevKits Team](https://devkits-tools.surge.sh)
124
+
125
+ ---
126
+
127
+ ## 🚀 API Monitoring for Developers
128
+
129
+ Build better APIs with **API Monitor SaaS** — real-time monitoring, alerting, and analytics.
130
+
131
+ 👉 **Early Access: $1 pre-order (50% off for life)** → https://api-monitor-saas.surge.sh?utm_source=npm&utm_medium=readme&utm_campaign=phase0
package/index.js ADDED
@@ -0,0 +1,168 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @devkits/case-convert - Convert text between different cases
5
+ *
6
+ * Usage:
7
+ * dk-case "hello world" -t camel # helloWorld
8
+ * dk-case "helloWorld" -t snake # hello_world
9
+ * dk-case "hello_world" -t kebab # hello-world
10
+ * echo "hello world" | dk-case -t pascal
11
+ *
12
+ * Web version: https://devkits-tools.surge.sh/tools/text-case
13
+ * Pro features: https://devkits-tools.surge.sh/pro
14
+ */
15
+
16
+ function splitWords(text) {
17
+ // Handle different input formats
18
+ return text
19
+ // Insert space before uppercase letters (camelCase/PascalCase)
20
+ .replace(/([a-z])([A-Z])/g, '$1 $2')
21
+ // Split on common separators
22
+ .split(/[\s_-]+/)
23
+ .filter(w => w.length > 0)
24
+ .map(w => w.toLowerCase());
25
+ }
26
+
27
+ function toCamelCase(words) {
28
+ if (words.length === 0) return '';
29
+ return words[0] + words.slice(1).map(w => w.charAt(0).toUpperCase() + w.slice(1)).join('');
30
+ }
31
+
32
+ function toPascalCase(words) {
33
+ return words.map(w => w.charAt(0).toUpperCase() + w.slice(1)).join('');
34
+ }
35
+
36
+ function toSnakeCase(words) {
37
+ return words.join('_');
38
+ }
39
+
40
+ function toKebabCase(words) {
41
+ return words.join('-');
42
+ }
43
+
44
+ function toConstantCase(words) {
45
+ return words.map(w => w.toUpperCase()).join('_');
46
+ }
47
+
48
+ function toSentenceCase(words) {
49
+ const sentence = words.join(' ');
50
+ return sentence.charAt(0).toUpperCase() + sentence.slice(1);
51
+ }
52
+
53
+ function toTitleCase(words) {
54
+ return words.map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ');
55
+ }
56
+
57
+ function convertCase(text, targetCase) {
58
+ const words = splitWords(text);
59
+
60
+ switch (targetCase) {
61
+ case 'camel':
62
+ return toCamelCase(words);
63
+ case 'pascal':
64
+ return toPascalCase(words);
65
+ case 'snake':
66
+ return toSnakeCase(words);
67
+ case 'kebab':
68
+ return toKebabCase(words);
69
+ case 'constant':
70
+ return toConstantCase(words);
71
+ case 'sentence':
72
+ return toSentenceCase(words);
73
+ case 'title':
74
+ return toTitleCase(words);
75
+ case 'lower':
76
+ return words.join(' ').toLowerCase();
77
+ case 'upper':
78
+ return words.join(' ').toUpperCase();
79
+ default:
80
+ return text;
81
+ }
82
+ }
83
+
84
+ function showHelp() {
85
+ console.log(`
86
+ @devkits/case-convert - Convert text between different cases
87
+
88
+ Usage:
89
+ dk-case "hello world" -t camel # helloWorld
90
+ dk-case "helloWorld" -t snake # hello_world
91
+ dk-case "hello_world" -t kebab # hello-world
92
+ echo "hello world" | dk-case -t pascal
93
+
94
+ Options:
95
+ -t, --to <case> Target case: camel, pascal, snake, kebab,
96
+ constant, sentence, title, lower, upper
97
+ -h, --help Show this help message
98
+
99
+ Cases:
100
+ camel - helloWorld (first word lowercase, rest capitalized)
101
+ pascal - HelloWorld (all words capitalized, no separator)
102
+ snake - hello_world (lowercase with underscores)
103
+ kebab - hello-world (lowercase with hyphens)
104
+ constant - HELLO_WORLD (uppercase with underscores)
105
+ sentence - Hello world (sentence case)
106
+ title - Hello World (title case)
107
+ lower - hello world (all lowercase)
108
+ upper - HELLO WORLD (all uppercase)
109
+
110
+ Examples:
111
+ dk-case "hello world" -t camel
112
+ dk-case "helloWorld" -t snake
113
+ dk-case "hello_world" -t kebab
114
+ dk-case "Hello-World" -t constant
115
+
116
+ Web version: https://devkits-tools.surge.sh/tools/text-case
117
+ Pro features: https://devkits-tools.surge.sh/pro
118
+ `);
119
+ }
120
+
121
+ // Main entry point
122
+ const args = process.argv.slice(2);
123
+
124
+ if (!args.length || args.includes('-h') || args.includes('--help')) {
125
+ showHelp();
126
+ process.exit(0);
127
+ }
128
+
129
+ // Parse options
130
+ let targetCase = 'camel';
131
+ let text = '';
132
+ const remainingArgs = [];
133
+
134
+ for (let i = 0; i < args.length; i++) {
135
+ if (args[i] === '-t' || args[i] === '--to') {
136
+ targetCase = args[++i] || 'camel';
137
+ } else {
138
+ remainingArgs.push(args[i]);
139
+ }
140
+ }
141
+
142
+ // Read from stdin if no text provided
143
+ if (remainingArgs.length === 0 && !process.stdin.isTTY) {
144
+ let stdin = '';
145
+ process.stdin.setEncoding('utf8');
146
+ process.stdin.on('readable', () => {
147
+ let chunk;
148
+ while ((chunk = process.stdin.read()) !== null) {
149
+ stdin += chunk;
150
+ }
151
+ });
152
+ process.stdin.on('end', () => {
153
+ text = stdin.trim();
154
+ if (text) {
155
+ console.log(convertCase(text, targetCase));
156
+ } else {
157
+ showHelp();
158
+ }
159
+ });
160
+ } else {
161
+ text = remainingArgs.join(' ');
162
+ if (!text) {
163
+ console.error('Error: No text provided');
164
+ showHelp();
165
+ process.exit(1);
166
+ }
167
+ console.log(convertCase(text, targetCase));
168
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "devkits-case-convert",
3
+ "version": "1.0.0",
4
+ "description": "Convert text between camelCase, snake_case, kebab-case, and more",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "dk-case": "./index.js",
8
+ "case-convert": "./index.js"
9
+ },
10
+ "scripts": {
11
+ "test": "node test.js"
12
+ },
13
+ "keywords": [
14
+ "case",
15
+ "convert",
16
+ "camelcase",
17
+ "snakecase",
18
+ "kebabcase",
19
+ "devkits",
20
+ "developer-tools",
21
+ "cli",
22
+ "command-line",
23
+ "nodejs",
24
+ "utility",
25
+ "productivity",
26
+ "dev-tools",
27
+ "free-tools"
28
+ ],
29
+ "author": "DevKits Team <devkits-auto@protonmail.com>",
30
+ "license": "MIT",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/devkits/tools"
34
+ },
35
+ "homepage": "https://devkits-tools.surge.sh/tools/text-case",
36
+ "bugs": {
37
+ "url": "https://github.com/devkits/tools/issues"
38
+ },
39
+ "engines": {
40
+ "node": ">=14.0.0"
41
+ },
42
+ "files": [
43
+ "index.js",
44
+ "README.md",
45
+ "test.js"
46
+ ],
47
+ "dependencies": {}
48
+ }
package/test.js ADDED
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Tests for @devkits/case-convert
5
+ */
6
+
7
+ const { execSync } = require('child_process');
8
+
9
+ const tests = [
10
+ {
11
+ name: 'To camelCase',
12
+ cmd: 'node index.js "hello world" -t camel',
13
+ expected: 'helloWorld'
14
+ },
15
+ {
16
+ name: 'To PascalCase',
17
+ cmd: 'node index.js "hello world" -t pascal',
18
+ expected: 'HelloWorld'
19
+ },
20
+ {
21
+ name: 'To snake_case',
22
+ cmd: 'node index.js "helloWorld" -t snake',
23
+ expected: 'hello_world'
24
+ },
25
+ {
26
+ name: 'To kebab-case',
27
+ cmd: 'node index.js "hello_world" -t kebab',
28
+ expected: 'hello-world'
29
+ },
30
+ {
31
+ name: 'To CONSTANT_CASE',
32
+ cmd: 'node index.js "helloWorld" -t constant',
33
+ expected: 'HELLO_WORLD'
34
+ },
35
+ {
36
+ name: 'To Sentence case',
37
+ cmd: 'node index.js "hello world" -t sentence',
38
+ expected: 'Hello world'
39
+ },
40
+ {
41
+ name: 'To Title Case',
42
+ cmd: 'node index.js "hello world" -t title',
43
+ expected: 'Hello World'
44
+ },
45
+ {
46
+ name: 'To lowercase',
47
+ cmd: 'node index.js "Hello World" -t lower',
48
+ expected: 'hello world'
49
+ },
50
+ {
51
+ name: 'To UPPERCASE',
52
+ cmd: 'node index.js "Hello World" -t upper',
53
+ expected: 'HELLO WORLD'
54
+ },
55
+ ];
56
+
57
+ let passed = 0;
58
+ let failed = 0;
59
+
60
+ console.log('Running @devkits/case-convert tests...\n');
61
+
62
+ for (const test of tests) {
63
+ try {
64
+ const result = execSync(test.cmd, { encoding: 'utf8' }).trim();
65
+ if (result === test.expected) {
66
+ console.log(`✅ ${test.name}`);
67
+ passed++;
68
+ } else {
69
+ console.log(`❌ ${test.name}`);
70
+ console.log(` Expected: ${test.expected}`);
71
+ console.log(` Got: ${result}`);
72
+ failed++;
73
+ }
74
+ } catch (err) {
75
+ console.log(`❌ ${test.name} - Error: ${err.message}`);
76
+ failed++;
77
+ }
78
+ }
79
+
80
+ console.log(`\n${passed}/${tests.length} tests passed`);
81
+ process.exit(failed > 0 ? 1 : 0);