caselyjs 0.1.0 → 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 (59) hide show
  1. package/README.md +91 -35
  2. package/dist/bin.d.ts +2 -0
  3. package/dist/bin.js +33 -0
  4. package/dist/bin.js.map +1 -0
  5. package/dist/casely.d.ts +7 -0
  6. package/dist/casely.js +75 -0
  7. package/dist/casely.js.map +1 -0
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.js +18 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/tools/case-identifier.d.ts +1 -0
  12. package/dist/tools/case-identifier.js +16 -0
  13. package/dist/tools/case-identifier.js.map +1 -0
  14. package/dist/tools/mutate-case.d.ts +2 -0
  15. package/dist/tools/mutate-case.js +18 -0
  16. package/dist/tools/mutate-case.js.map +1 -0
  17. package/dist/tools/resolver.d.ts +9 -0
  18. package/dist/tools/resolver.js +34 -0
  19. package/dist/tools/resolver.js.map +1 -0
  20. package/dist/transforms/to-camel.d.ts +2 -0
  21. package/dist/transforms/to-camel.js +61 -0
  22. package/dist/transforms/to-camel.js.map +1 -0
  23. package/dist/transforms/to-kebab.d.ts +2 -0
  24. package/dist/transforms/to-kebab.js +62 -0
  25. package/dist/transforms/to-kebab.js.map +1 -0
  26. package/dist/transforms/to-pascal.d.ts +2 -0
  27. package/dist/transforms/to-pascal.js +61 -0
  28. package/dist/transforms/to-pascal.js.map +1 -0
  29. package/dist/types.d.ts +9 -0
  30. package/dist/types.js +3 -0
  31. package/dist/types.js.map +1 -0
  32. package/package.json +23 -8
  33. package/src/bin.ts +36 -0
  34. package/src/casely.ts +87 -0
  35. package/src/index.ts +1 -0
  36. package/src/tools/case-identifier.ts +12 -0
  37. package/src/tools/mutate-case.ts +24 -0
  38. package/src/tools/resolver.ts +55 -0
  39. package/src/transforms/to-camel.ts +70 -0
  40. package/src/transforms/to-kebab.ts +71 -0
  41. package/src/transforms/to-pascal.ts +68 -0
  42. package/src/types.ts +10 -0
  43. package/test/hello-world/new-world.js +0 -0
  44. package/test/hello.json +0 -0
  45. package/test/hello.py +0 -0
  46. package/test/index.md +0 -0
  47. package/test/pascal.js +0 -0
  48. package/test/why-not/why-no/why-no.ts +0 -0
  49. package/test/why-not/why-not/pascal.js +0 -0
  50. package/test/world-book.go +0 -0
  51. package/tsconfig.json +33 -0
  52. package/casely.js +0 -56
  53. package/index.js +0 -1
  54. package/tools/case-identifier.js +0 -10
  55. package/tools/mutate-case.js +0 -21
  56. package/tools/resolver.js +0 -36
  57. package/tools/transforms/to-camel.js +0 -58
  58. package/tools/transforms/to-kebab.js +0 -59
  59. package/tools/transforms/to-pascal.js +0 -58
@@ -1,58 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
- function toCamelCase(str) {
5
- return str
6
- .replace(/[-_](.)/g, (_, group1) => group1.toUpperCase())
7
- .replace(/^(.)/, (_, group1) => group1.toLowerCase());
8
- }
9
-
10
- function kebabToCamel(targetPath) {
11
- const parent = path.dirname(targetPath);
12
- const currentName = path.basename(targetPath);
13
- const newName = toCamelCase(currentName);
14
- const newPath = path.join(parent, newName);
15
-
16
- if (currentName === newName) {
17
- console.log(`✅ Already in camelCase: ${currentName}`);
18
- return;
19
- }
20
-
21
- try {
22
- fs.renameSync(targetPath, newPath);
23
- console.log(`✨ Renamed Kebab → Camel: ${currentName} ➝ ${newName}`);
24
- } catch (err) {
25
- console.error(`❌ Rename failed: ${err.message}`);
26
- }
27
- }
28
-
29
- function pascalToCamel(targetPath) {
30
- const parent = path.dirname(targetPath);
31
- const currentName = path.basename(targetPath);
32
- const newName = currentName.charAt(0).toLowerCase() + currentName.slice(1);
33
- const newPath = path.join(parent, newName);
34
-
35
- if (currentName === newName) {
36
- console.log(`✅ Already in camelCase: ${currentName}`);
37
- return;
38
- }
39
-
40
- try {
41
- fs.renameSync(targetPath, newPath);
42
- console.log(`✨ Renamed Pascal → Camel: ${currentName} ➝ ${newName}`);
43
- } catch (err) {
44
- console.error(`❌ Rename failed: ${err.message}`);
45
- }
46
- }
47
-
48
- // ----------------------------------------------------
49
-
50
- export function toCamel(targetPath, currentType) {
51
- if (currentType === 'kebab') {
52
- kebabToCamel(targetPath);
53
- } else if (currentType === 'pascal') {
54
- pascalToCamel(targetPath);
55
- } else {
56
- console.log('⚠️ Unsupported case type passed.');
57
- }
58
- }
@@ -1,59 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
- function toKebabCase(str) {
5
- return str
6
- .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
7
- .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')
8
- .toLowerCase();
9
- }
10
-
11
- function pascalToKebab(targetPath) {
12
- const parent = path.dirname(targetPath);
13
- const currentName = path.basename(targetPath);
14
- const newName = toKebabCase(currentName);
15
- const newPath = path.join(parent, newName);
16
-
17
- if (currentName === newName) {
18
- console.log(`✅ Already in kebab-case: ${currentName}`);
19
- return;
20
- }
21
-
22
- try {
23
- fs.renameSync(targetPath, newPath);
24
- console.log(`✨ Renamed Pascal → Kebab: ${currentName} ➝ ${newName}`);
25
- } catch (err) {
26
- console.error(`❌ Rename failed: ${err.message}`);
27
- }
28
- }
29
-
30
- function camelToKebab(targetPath) {
31
- const parent = path.dirname(targetPath);
32
- const currentName = path.basename(targetPath);
33
- const newName = toKebabCase(currentName);
34
- const newPath = path.join(parent, newName);
35
-
36
- if (currentName === newName) {
37
- console.log(`✅ Already in kebab-case: ${currentName}`);
38
- return;
39
- }
40
-
41
- try {
42
- fs.renameSync(targetPath, newPath);
43
- console.log(`✨ Renamed Camel → Kebab: ${currentName} ➝ ${newName}`);
44
- } catch (err) {
45
- console.error(`❌ Rename failed: ${err.message}`);
46
- }
47
- }
48
-
49
- // ----------------------------------------------------
50
-
51
- export function toKebab(targetPath, currentType) {
52
- if (currentType === 'pascal') {
53
- pascalToKebab(targetPath);
54
- } else if (currentType === 'camel') {
55
- camelToKebab(targetPath);
56
- } else {
57
- console.log('⚠️ Unsupported case type passed.');
58
- }
59
- }
@@ -1,58 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
- function toPascalCase(str) {
5
- return str
6
- .replace(/[-_](.)/g, (_, group1) => group1.toUpperCase())
7
- .replace(/^(.)/, (_, group1) => group1.toUpperCase());
8
- }
9
-
10
- function kebabToPascal(targetPath) {
11
- const parent = path.dirname(targetPath);
12
- const currentName = path.basename(targetPath);
13
- const newName = toPascalCase(currentName);
14
- const newPath = path.join(parent, newName);
15
-
16
- if (currentName === newName) {
17
- console.log(`✅ Already in PascalCase: ${currentName}`);
18
- return;
19
- }
20
-
21
- try {
22
- fs.renameSync(targetPath, newPath);
23
- console.log(`✨ Renamed Kebab → Pascal: ${currentName} ➝ ${newName}`);
24
- } catch (err) {
25
- console.error(`❌ Rename failed: ${err.message}`);
26
- }
27
- }
28
-
29
- function camelToPascal(targetPath) {
30
- const parent = path.dirname(targetPath);
31
- const currentName = path.basename(targetPath);
32
- const newName = currentName.charAt(0).toUpperCase() + currentName.slice(1);
33
- const newPath = path.join(parent, newName);
34
-
35
- if (currentName === newName) {
36
- console.log(`✅ Already in PascalCase: ${currentName}`);
37
- return;
38
- }
39
-
40
- try {
41
- fs.renameSync(targetPath, newPath);
42
- console.log(`✨ Renamed Camel → Pascal: ${currentName} ➝ ${newName}`);
43
- } catch (err) {
44
- console.error(`❌ Rename failed: ${err.message}`);
45
- }
46
- }
47
-
48
- // ----------------------------------------------------
49
-
50
- export function toPascal(targetPath, currentType) {
51
- if (currentType === 'kebab') {
52
- kebabToPascal(targetPath);
53
- } else if (currentType === 'camel') {
54
- camelToPascal(targetPath);
55
- } else {
56
- console.log('⚠️ Unsupported case type passed.');
57
- }
58
- }