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
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,12 +1,7 @@
1
1
  {
2
2
  "name": "caselyjs",
3
- "version": "0.1.0",
4
- "description": "A minimal renaming tool for setting an uniform naming convetion accross all files, capable of renaming 100+ files in one go.",
5
- "main": "index.js",
6
- "type": "module",
7
- "scripts": {
8
- "rename": "node index.js"
9
- },
3
+ "version": "1.0.0",
4
+ "description": "Rename codebase files and directories with ease",
10
5
  "repository": {
11
6
  "type": "git",
12
7
  "url": "git+https://github.com/codezaura/caselyjs.git"
@@ -24,5 +19,25 @@
24
19
  "bugs": {
25
20
  "url": "https://github.com/codezaura/caselyjs/issues"
26
21
  },
27
- "homepage": "https://github.com/codezaura/caselyjs#readme"
22
+ "homepage": "https://github.com/codezaura/caselyjs#readme",
23
+ "main": "dist/index.js",
24
+ "types": "dist/index.d.ts",
25
+ "bin": {
26
+ "casely": "dist/bin.js"
27
+ },
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "start": "node dist/bin.js",
31
+ "dev": "ts-node src/bin.ts",
32
+ "prepublishOnly": "npm run build"
33
+ },
34
+ "dependencies": {
35
+ "chalk": "^5.3.0",
36
+ "commander": "^11.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^20.19.39",
40
+ "ts-node": "^10.9.1",
41
+ "typescript": "^5.0.0"
42
+ }
28
43
  }
package/src/bin.ts ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { casely } from "./index";
4
+ import chalk from "chalk";
5
+
6
+ const program = new Command();
7
+
8
+ program
9
+ .name("caselyjs")
10
+ .description("Transform codebase file and directory casing")
11
+ .version("2.0.0")
12
+ .argument("[path]", "Path to process", ".")
13
+ .option("-c, --case <type>", "Target case: camel, kebab, pascal", "kebab")
14
+ .option(
15
+ "-e, --ext <extensions>",
16
+ "Comma separated extensions",
17
+ "js,jsx,ts,tsx",
18
+ )
19
+ .option("-f, --full", "Rename directories as well", false)
20
+ .option("--dry", "Dry run (show changes without applying)", false)
21
+ .action(async (path, options) => {
22
+ console.log(chalk.blue.bold(`\n🚀 CaselyJS starting in ${path}...`));
23
+
24
+ casely.config({
25
+ path: path,
26
+ case: options.case,
27
+ file: options.ext.split(","),
28
+ operate: options.full ? "full" : "partial",
29
+ dryRun: options.dry,
30
+ });
31
+
32
+ await casely.execute();
33
+ console.log(chalk.green.bold("\n✨ Casing transformation complete!"));
34
+ });
35
+
36
+ program.parse();
package/src/casely.ts ADDED
@@ -0,0 +1,87 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+ import { pathResolver } from "./tools/resolver";
4
+ import { caseIdentifier } from "./tools/case-identifier";
5
+ import { CaselyConfig, CaseType } from "./types";
6
+ import chalk from "chalk";
7
+
8
+ // -------------------------------------------------------------
9
+
10
+ let defaultConfig: CaselyConfig = {
11
+ path: process.cwd(),
12
+ file: ["js", "jsx", "ts", "tsx"],
13
+ case: "kebab",
14
+ operate: "partial",
15
+ dryRun: false,
16
+ };
17
+
18
+ // -------------------------------------------------------------
19
+
20
+ export const casely = {
21
+ config(options: Partial<CaselyConfig>) {
22
+ defaultConfig = { ...defaultConfig, ...options };
23
+ },
24
+
25
+ async execute() {
26
+ const { files, folders } = pathResolver(defaultConfig.path, {
27
+ recursive: true,
28
+ });
29
+
30
+ // 1. Handle Files
31
+ for (const filePath of files) {
32
+ const ext = path.extname(filePath).slice(1);
33
+ if (!defaultConfig.file.includes(ext)) continue;
34
+
35
+ const dirname = path.dirname(filePath);
36
+ const basename = path.basename(filePath, `.${ext}`);
37
+ const currentCase = caseIdentifier(basename);
38
+
39
+ if (currentCase !== defaultConfig.case) {
40
+ this.rename(filePath, basename, ext, currentCase);
41
+ }
42
+ }
43
+
44
+ // 2. Handle Folders (Bottom-Up)
45
+ if (defaultConfig.operate === "full") {
46
+ const sortedFolders = folders.sort((a, b) => b.length - a.length);
47
+ for (const folderPath of sortedFolders) {
48
+ const basename = path.basename(folderPath);
49
+ const currentCase = caseIdentifier(basename);
50
+
51
+ if (currentCase !== defaultConfig.case) {
52
+ this.rename(folderPath, basename, "", currentCase);
53
+ }
54
+ }
55
+ }
56
+ },
57
+
58
+ rename(fullPath: string, name: string, ext: string, currentCase: CaseType) {
59
+ const newName = this.transform(name, defaultConfig.case);
60
+ const finalName = ext ? `${newName}.${ext}` : newName;
61
+ const newPath = path.join(path.dirname(fullPath), finalName);
62
+
63
+ if (defaultConfig.dryRun) {
64
+ console.log(
65
+ chalk.yellow(`[DRY RUN] ${path.basename(fullPath)} ➝ ${finalName}`),
66
+ );
67
+ } else {
68
+ fs.renameSync(fullPath, newPath);
69
+ console.log(chalk.cyan(`✔ Renamed: ${finalName}`));
70
+ }
71
+ },
72
+
73
+ transform(str: string, target: CaseType): string {
74
+ // Your transformation logic (toCamel, toKebab, etc)
75
+ if (target === "kebab")
76
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
77
+ if (target === "camel")
78
+ return str
79
+ .replace(/[-_](.)/g, (_, g) => g.toUpperCase())
80
+ .replace(/^(.)/, (g) => g.toLowerCase());
81
+ if (target === "pascal")
82
+ return str
83
+ .replace(/[-_](.)/g, (_, g) => g.toUpperCase())
84
+ .replace(/^(.)/, (g) => g.toUpperCase());
85
+ return str;
86
+ },
87
+ };
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./casely";
@@ -0,0 +1,12 @@
1
+ // -------------------------------------------------------------
2
+
3
+ export function caseIdentifier(val: string) {
4
+ const str = val.split(".")[0];
5
+
6
+ if (/^[a-z]+$/.test(str)) return "kebab";
7
+ if (/^[a-z]+(-[a-z]+)+$/.test(str)) return "kebab";
8
+ if (/^[a-z]+(?:[A-Z][a-z]*)*$/.test(str)) return "camel";
9
+ if (/^[A-Z][a-z]+(?:[A-Z][a-z]*)*$/.test(str)) return "pascal";
10
+
11
+ return "unknown";
12
+ }
@@ -0,0 +1,24 @@
1
+ import { toCamel } from "../transforms/to-camel.js";
2
+ import { toKebab } from "../transforms/to-kebab.js";
3
+ import { toPascal } from "../transforms/to-pascal.js";
4
+ import { CaseType } from "../types.js";
5
+
6
+ // -------------------------------------------------------------
7
+
8
+ export async function mutateCase(
9
+ path: string,
10
+ currentType: Exclude<CaseType, "unknown">,
11
+ expectedType: Exclude<CaseType, "unknown">,
12
+ ): Promise<void> {
13
+ if (expectedType === "camel") {
14
+ toCamel(path, currentType);
15
+ }
16
+
17
+ if (expectedType === "kebab") {
18
+ toKebab(path, currentType);
19
+ }
20
+
21
+ if (expectedType === "pascal") {
22
+ toPascal(path, currentType);
23
+ }
24
+ }
@@ -0,0 +1,55 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ // -------------------------------------------------------------
5
+
6
+ interface PathResolverOptions {
7
+ recursive?: boolean;
8
+ }
9
+
10
+ interface PathResolverResult {
11
+ files: string[];
12
+ folders: string[];
13
+ }
14
+
15
+ // -------------------------------------------------------------
16
+
17
+ /**
18
+ * List all files and folders in a given path
19
+ * @param targetPath - The directory to scan
20
+ * @param options - Configuration options
21
+ * @param options.recursive - If true, lists recursively (default: false)
22
+ * @returns An object containing arrays of file and folder paths
23
+ */
24
+ export function pathResolver(
25
+ targetPath: string,
26
+ options: PathResolverOptions = {},
27
+ ): PathResolverResult {
28
+ const { recursive = false } = options;
29
+
30
+ const result: PathResolverResult = {
31
+ files: [],
32
+ folders: [],
33
+ };
34
+
35
+ function scan(dir: string): void {
36
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
37
+
38
+ for (const entry of entries) {
39
+ const fullPath = path.join(dir, entry.name);
40
+ const normalizedPath = fullPath.replace(/\\/g, "/");
41
+
42
+ if (entry.isDirectory()) {
43
+ result.folders.push(normalizedPath);
44
+ if (recursive) {
45
+ scan(fullPath);
46
+ }
47
+ } else if (entry.isFile()) {
48
+ result.files.push(normalizedPath);
49
+ }
50
+ }
51
+ }
52
+
53
+ scan(targetPath);
54
+ return result;
55
+ }
@@ -0,0 +1,70 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { type CaseType } from "../types";
4
+
5
+ // -------------------------------------------------------------
6
+
7
+ function toCamelCase(str: string): string {
8
+ return str
9
+ .replace(/[-_](.)/g, (_, group1: string) => group1.toUpperCase())
10
+ .replace(/^(.)/, (_, group1: string) => group1.toLowerCase());
11
+ }
12
+
13
+ // -------------------------------------------------------------
14
+
15
+ function kebabToCamel(targetPath: string): void {
16
+ const parent = path.dirname(targetPath);
17
+ const currentName = path.basename(targetPath);
18
+ const newName = toCamelCase(currentName);
19
+ const newPath = path.join(parent, newName);
20
+
21
+ if (currentName === newName) {
22
+ console.log(`✅ Already in camelCase: ${currentName}`);
23
+ return;
24
+ }
25
+
26
+ try {
27
+ fs.renameSync(targetPath, newPath);
28
+ console.log(`✨ Renamed Kebab → Camel: ${currentName} ➝ ${newName}`);
29
+ } catch (err) {
30
+ const message = err instanceof Error ? err.message : String(err);
31
+ console.error(`❌ Rename failed: ${message}`);
32
+ }
33
+ }
34
+
35
+ // -------------------------------------------------------------
36
+
37
+ function pascalToCamel(targetPath: string): void {
38
+ const parent = path.dirname(targetPath);
39
+ const currentName = path.basename(targetPath);
40
+ const newName = currentName.charAt(0).toLowerCase() + currentName.slice(1);
41
+ const newPath = path.join(parent, newName);
42
+
43
+ if (currentName === newName) {
44
+ console.log(`✅ Already in camelCase: ${currentName}`);
45
+ return;
46
+ }
47
+
48
+ try {
49
+ fs.renameSync(targetPath, newPath);
50
+ console.log(`✨ Renamed Pascal → Camel: ${currentName} ➝ ${newName}`);
51
+ } catch (err) {
52
+ const message = err instanceof Error ? err.message : String(err);
53
+ console.error(`❌ Rename failed: ${message}`);
54
+ }
55
+ }
56
+
57
+ // -------------------------------------------------------------
58
+
59
+ export function toCamel(
60
+ targetPath: string,
61
+ currentType: Partial<CaseType>,
62
+ ): void {
63
+ if (currentType === "kebab") {
64
+ kebabToCamel(targetPath);
65
+ } else if (currentType === "pascal") {
66
+ pascalToCamel(targetPath);
67
+ } else {
68
+ console.log("⚠️ Unsupported case type passed.");
69
+ }
70
+ }
@@ -0,0 +1,71 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { type CaseType } from "../types";
4
+
5
+ // -------------------------------------------------------------
6
+
7
+ function toKebabCase(str: string): string {
8
+ return str
9
+ .replace(/([a-z0-9])([A-Z])/g, "$1-$2")
10
+ .replace(/([A-Z])([A-Z][a-z])/g, "$1-$2")
11
+ .toLowerCase();
12
+ }
13
+
14
+ // -------------------------------------------------------------
15
+
16
+ function pascalToKebab(targetPath: string): void {
17
+ const parent = path.dirname(targetPath);
18
+ const currentName = path.basename(targetPath);
19
+ const newName = toKebabCase(currentName);
20
+ const newPath = path.join(parent, newName);
21
+
22
+ if (currentName === newName) {
23
+ console.log(`✅ Already in kebab-case: ${currentName}`);
24
+ return;
25
+ }
26
+
27
+ try {
28
+ fs.renameSync(targetPath, newPath);
29
+ console.log(`✨ Renamed Pascal → Kebab: ${currentName} ➝ ${newName}`);
30
+ } catch (err) {
31
+ const message = err instanceof Error ? err.message : String(err);
32
+ console.error(`❌ Rename failed: ${message}`);
33
+ }
34
+ }
35
+
36
+ // -------------------------------------------------------------
37
+
38
+ function camelToKebab(targetPath: string): void {
39
+ const parent = path.dirname(targetPath);
40
+ const currentName = path.basename(targetPath);
41
+ const newName = toKebabCase(currentName);
42
+ const newPath = path.join(parent, newName);
43
+
44
+ if (currentName === newName) {
45
+ console.log(`✅ Already in kebab-case: ${currentName}`);
46
+ return;
47
+ }
48
+
49
+ try {
50
+ fs.renameSync(targetPath, newPath);
51
+ console.log(`✨ Renamed Camel → Kebab: ${currentName} ➝ ${newName}`);
52
+ } catch (err) {
53
+ const message = err instanceof Error ? err.message : String(err);
54
+ console.error(`❌ Rename failed: ${message}`);
55
+ }
56
+ }
57
+
58
+ // -------------------------------------------------------------
59
+
60
+ export function toKebab(
61
+ targetPath: string,
62
+ currentType: Partial<CaseType>,
63
+ ): void {
64
+ if (currentType === "pascal") {
65
+ pascalToKebab(targetPath);
66
+ } else if (currentType === "camel") {
67
+ camelToKebab(targetPath);
68
+ } else {
69
+ console.log("⚠️ Unsupported case type passed.");
70
+ }
71
+ }
@@ -0,0 +1,68 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { type CaseType } from "../types";
4
+
5
+ // -------------------------------------------------------------
6
+
7
+ function toPascalCase(str: string): string {
8
+ return str
9
+ .replace(/[-_](.)/g, (_, group1: string) => group1.toUpperCase())
10
+ .replace(/^(.)/, (_, group1: string) => group1.toUpperCase());
11
+ }
12
+
13
+ function kebabToPascal(targetPath: string): void {
14
+ const parent = path.dirname(targetPath);
15
+ const currentName = path.basename(targetPath);
16
+ const newName = toPascalCase(currentName);
17
+ const newPath = path.join(parent, newName);
18
+
19
+ if (currentName === newName) {
20
+ console.log(`✅ Already in PascalCase: ${currentName}`);
21
+ return;
22
+ }
23
+
24
+ try {
25
+ fs.renameSync(targetPath, newPath);
26
+ console.log(`✨ Renamed Kebab → Pascal: ${currentName} ➝ ${newName}`);
27
+ } catch (err) {
28
+ const message = err instanceof Error ? err.message : String(err);
29
+ console.error(`❌ Rename failed: ${message}`);
30
+ }
31
+ }
32
+
33
+ // -------------------------------------------------------------
34
+
35
+ function camelToPascal(targetPath: string): void {
36
+ const parent = path.dirname(targetPath);
37
+ const currentName = path.basename(targetPath);
38
+ const newName = currentName.charAt(0).toUpperCase() + currentName.slice(1);
39
+ const newPath = path.join(parent, newName);
40
+
41
+ if (currentName === newName) {
42
+ console.log(`✅ Already in PascalCase: ${currentName}`);
43
+ return;
44
+ }
45
+
46
+ try {
47
+ fs.renameSync(targetPath, newPath);
48
+ console.log(`✨ Renamed Camel → Pascal: ${currentName} ➝ ${newName}`);
49
+ } catch (err) {
50
+ const message = err instanceof Error ? err.message : String(err);
51
+ console.error(`❌ Rename failed: ${message}`);
52
+ }
53
+ }
54
+
55
+ // -------------------------------------------------------------
56
+
57
+ export function toPascal(
58
+ targetPath: string,
59
+ currentType: Partial<CaseType>,
60
+ ): void {
61
+ if (currentType === "kebab") {
62
+ kebabToPascal(targetPath);
63
+ } else if (currentType === "camel") {
64
+ camelToPascal(targetPath);
65
+ } else {
66
+ console.log("⚠️ Unsupported case type passed.");
67
+ }
68
+ }
package/src/types.ts ADDED
@@ -0,0 +1,10 @@
1
+ export type CaseType = "camel" | "kebab" | "pascal" | "unknown";
2
+ export type OperationMode = "partial" | "full";
3
+
4
+ export interface CaselyConfig {
5
+ path: string;
6
+ file: string[]; // e.g. ["js", "ts"]
7
+ case: CaseType;
8
+ operate: OperationMode;
9
+ dryRun?: boolean;
10
+ }
File without changes
File without changes
package/test/hello.py ADDED
File without changes
package/test/index.md ADDED
File without changes
package/test/pascal.js ADDED
File without changes
File without changes
File without changes
File without changes
package/tsconfig.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Base Options */
4
+ "target": "ES2022",
5
+ "module": "nodenext",
6
+ "allowSyntheticDefaultImports": true,
7
+
8
+ "moduleResolution": "nodenext",
9
+ "lib": ["ES2022"],
10
+ "declaration": true /* Generates .d.ts files for your library users */,
11
+ "sourceMap": true /* Helps with debugging */,
12
+
13
+ /* Output Settings */
14
+ "outDir": "./dist" /* Where the compiled JS goes */,
15
+ "rootDir": "./src" /* Where your TS source lives */,
16
+ "removeComments": true,
17
+
18
+ /* Strictness & Safety */
19
+ "strict": true /* Ensures high-quality, type-safe code */,
20
+ "noImplicitAny": true,
21
+ "esModuleInterop": true /* Fixes compatibility with some older JS packages */,
22
+ "skipLibCheck": true,
23
+ "forceConsistentCasingInFileNames": true,
24
+
25
+ /* Path Mapping (Optional) */
26
+ "baseUrl": ".",
27
+ "paths": {
28
+ "*": ["node_modules/*"]
29
+ }
30
+ },
31
+ "include": ["src/**/*"] /* Only compile files in the src folder */,
32
+ "exclude": ["node_modules", "dist"]
33
+ }
package/casely.js DELETED
@@ -1,56 +0,0 @@
1
- import path from "path";
2
-
3
- import { pathResolver } from "./tools/resolver.js";
4
- import { caseIdentifier } from "./tools/case-identifier.js";
5
- import { mutateCase } from "./tools/mutate-case.js";
6
-
7
- // ------------------------------------------------
8
-
9
- let defaultConfig = {
10
- path: "",
11
- file: ["js", "jsx"],
12
- case: "kebab",
13
- operate: "partial",
14
- };
15
-
16
- // -------------------------------------------------
17
-
18
- export const casely = {
19
- config(options = {}) {
20
- defaultConfig = {
21
- ...defaultConfig,
22
- ...options,
23
- };
24
- },
25
-
26
- async execute() {
27
- const { files, folders } = pathResolver(defaultConfig.path, {
28
- recursive: true,
29
- });
30
-
31
- for (const file of files) {
32
- const value = file.split("/").pop();
33
- const fullPath = path.resolve(file);
34
- const [fileName, fileExt] = value.split(".");
35
- const currentCase = caseIdentifier(fileName);
36
-
37
- if (defaultConfig.file.includes(fileExt)) {
38
- if (currentCase !== defaultConfig.case) {
39
- await mutateCase(fullPath, currentCase, defaultConfig.case);
40
- }
41
- }
42
- }
43
-
44
- if (defaultConfig.operate === "full") {
45
- for (const folder of folders) {
46
- const value = folder.split("/").pop();
47
- const fullPath = path.resolve(folder);
48
- const currentCase = caseIdentifier(value);
49
-
50
- if (currentCase !== defaultConfig.case) {
51
- await mutateCase(fullPath, currentCase, defaultConfig.case);
52
- }
53
- }
54
- }
55
- },
56
- };
package/index.js DELETED
@@ -1 +0,0 @@
1
- export * from "./casely.js"
@@ -1,10 +0,0 @@
1
- export function caseIdentifier(val) {
2
- const str = val.split(".")[0]
3
-
4
- if (/^[a-z]+$/.test(str)) return 'kebab';
5
- if (/^[a-z]+(-[a-z]+)+$/.test(str)) return 'kebab';
6
- if (/^[a-z]+(?:[A-Z][a-z]*)*$/.test(str)) return 'camel';
7
- if (/^[A-Z][a-z]+(?:[A-Z][a-z]*)*$/.test(str)) return 'pascal';
8
-
9
- return 'unknown';
10
- }
@@ -1,21 +0,0 @@
1
- import { toCamel } from "./transforms/to-camel.js";
2
- import { toKebab } from "./transforms/to-kebab.js";
3
- import { toPascal } from "./transforms/to-pascal.js";
4
-
5
- // --------------------------------------------------------
6
-
7
- export async function mutateCase(path, currentType, expectedType) {
8
-
9
- if (expectedType === "camel") {
10
- toCamel(path, currentType);
11
- }
12
-
13
- if (expectedType === "kebab") {
14
- toKebab(path, currentType);
15
- }
16
-
17
- if (expectedType === "pascal") {
18
- toPascal(path, currentType);
19
- }
20
-
21
- }
package/tools/resolver.js DELETED
@@ -1,36 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
- /**
5
- * List all files and folders in a given path
6
- * @param {string} targetPath - The directory to scan
7
- * @param {Object} options
8
- * @param {boolean} [options.recursive=false] - If true, lists recursively
9
- * @returns {{ files: string[], folders: string[] }}
10
- */
11
- export function pathResolver(targetPath, options = { recursive: false }) {
12
- const result = {
13
- files: [],
14
- folders: [],
15
- };
16
-
17
- function scan(dir) {
18
- const entries = fs.readdirSync(dir, { withFileTypes: true });
19
-
20
- for (const entry of entries) {
21
- const fullPath = path.join(dir, entry.name);
22
-
23
- if (entry.isDirectory()) {
24
- result.folders.push(fullPath.replace(/\\/g, '/'));
25
- if (options.recursive) {
26
- scan(fullPath);
27
- }
28
- } else if (entry.isFile()) {
29
- result.files.push(fullPath.replace(/\\/g, '/'));
30
- }
31
- }
32
- }
33
-
34
- scan(targetPath);
35
- return result;
36
- }