@jsrepo/transform-filecasing 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.
- package/LICENSE +21 -0
- package/README.md +72 -0
- package/dist/index.d.mts +32 -0
- package/dist/index.mjs +2 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 jsrepo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @jsrepo/transform-filecasing
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/@jsrepo/transform-filecasing)
|
|
4
|
+
[](https://npmjs.com/package/@jsrepo/transform-filecasing)
|
|
5
|
+
|
|
6
|
+
A transform plugin for transforming file and folder names to different case formats before they are added to your project.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
Run the following command to install and add the transform to your config:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
jsrepo config transform filecasing
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Manual Configuration
|
|
17
|
+
|
|
18
|
+
Install the transform plugin:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
pnpm install @jsrepo/transform-filecasing -D
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Add the transform to your config:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { defineConfig } from "jsrepo";
|
|
28
|
+
import fileCasing from "@jsrepo/transform-filecasing";
|
|
29
|
+
|
|
30
|
+
export default defineConfig({
|
|
31
|
+
transforms: [fileCasing({ to: "camel" })],
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Options
|
|
36
|
+
|
|
37
|
+
| Option | Type | Description |
|
|
38
|
+
|--------|------|-------------|
|
|
39
|
+
| `to` | `"kebab" \| "camel" \| "snake" \| "pascal"` | The target case format for file and folder names |
|
|
40
|
+
| `transformDirectories` | `boolean` | Whether to transform directory segments in the path. When `false`, only the filename baseName is transformed. Defaults to `true` |
|
|
41
|
+
|
|
42
|
+
### Examples
|
|
43
|
+
|
|
44
|
+
Transform both directories and filenames (default behavior):
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { defineConfig } from "jsrepo";
|
|
48
|
+
import fileCasing from "@jsrepo/transform-filecasing";
|
|
49
|
+
|
|
50
|
+
export default defineConfig({
|
|
51
|
+
// Config path: 'src/lib/components/ui'
|
|
52
|
+
// Item path: 'button/index.ts'
|
|
53
|
+
transforms: [fileCasing({ to: "pascal" })],
|
|
54
|
+
});
|
|
55
|
+
// Result: 'src/lib/components/ui/Button/Index.ts'
|
|
56
|
+
// Only the item's relative path is transformed, not the config path
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Transform only filenames, preserve directory names:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { defineConfig } from "jsrepo";
|
|
63
|
+
import fileCasing from "@jsrepo/transform-filecasing";
|
|
64
|
+
|
|
65
|
+
export default defineConfig({
|
|
66
|
+
// Config path: 'src/lib/components/ui'
|
|
67
|
+
// Item path: 'my-components/use-hook.ts'
|
|
68
|
+
transforms: [fileCasing({ to: "camel", transformDirectories: false })],
|
|
69
|
+
});
|
|
70
|
+
// Result: 'src/lib/components/ui/my-components/useHook.ts'
|
|
71
|
+
// Only the filename is transformed, directories in the item path are preserved
|
|
72
|
+
```
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Transform } from "jsrepo";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
type CaseType = 'kebab' | 'camel' | 'snake' | 'pascal';
|
|
5
|
+
type Options = {
|
|
6
|
+
/** The target case format to transform file and folder names to. */
|
|
7
|
+
to: CaseType;
|
|
8
|
+
/** Whether to transform directory segments in the path. When `false`, only the filename baseName is transformed. @default true */
|
|
9
|
+
transformDirectories?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A transform plugin for jsrepo to transform file and folder name cases.
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { defineConfig } from "jsrepo";
|
|
16
|
+
* import fileCasing from "@jsrepo/transform-filecasing";
|
|
17
|
+
*
|
|
18
|
+
* export default defineConfig({
|
|
19
|
+
* // ...
|
|
20
|
+
* transforms: [fileCasing({ to: "camel" })],
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param options - The options for the transform plugin.
|
|
25
|
+
*/
|
|
26
|
+
declare function export_default({
|
|
27
|
+
to,
|
|
28
|
+
transformDirectories
|
|
29
|
+
}?: Partial<Options>): Transform;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { CaseType, Options, export_default as default };
|
|
32
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{camelCase as e,kebabCase as t,pascalCase as n,snakeCase as r}from"change-case";const i={kebab:t,camel:e,snake:r,pascal:n};function a({to:e=`kebab`,transformDirectories:t=!0}={}){let n=i[e];if(!n)throw Error(`Invalid case type: "${e}". Expected one of: kebab, camel, snake, pascal`);return{transform:async({fileName:e})=>{let r=e.split(`/`),i=r.map((e,i)=>{if(i===r.length-1){let t=e.indexOf(`.`),r=t>=0?e.slice(0,t):e,i=t>=0?e.slice(t):``;return`${n(r)}${i}`}return t?n(e):e}).join(`/`);return i===e?{}:{fileName:i}}}}export{a as default};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jsrepo/transform-filecasing",
|
|
3
|
+
"description": "A transform plugin for jsrepo to transform file and folder name cases.",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://jsrepo.dev",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Aleksei Gurianov",
|
|
9
|
+
"url": "https://github.com/guria"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/jsrepojs/jsrepo"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/jsrepojs/jsrepo/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"jsrepo",
|
|
20
|
+
"transform",
|
|
21
|
+
"change-case",
|
|
22
|
+
"filecasing",
|
|
23
|
+
"filename",
|
|
24
|
+
"plugin"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.mts",
|
|
30
|
+
"default": "./dist/index.mjs"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"main": "./dist/index.mjs",
|
|
34
|
+
"files": [
|
|
35
|
+
"dist/**/*",
|
|
36
|
+
"!dist/**/*.map"
|
|
37
|
+
],
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"jsrepo": "3.2.1"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"change-case": "^5.4.4"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^25.2.0",
|
|
46
|
+
"tsdown": "0.19.0-beta.3",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
48
|
+
"vitest": "^4.0.18"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsdown",
|
|
52
|
+
"dev": "tsdown --watch",
|
|
53
|
+
"check": "tsc --noEmit",
|
|
54
|
+
"test": "vitest",
|
|
55
|
+
"bundle-analyze": "FORCE_COLOR=1 pnpx bundle-analyze . --fail-if-exceeds-bytes 500000"
|
|
56
|
+
}
|
|
57
|
+
}
|