config2ts 2.5.2 → 2.5.4

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/README.md CHANGED
@@ -41,9 +41,9 @@ Scan assets directory and generate an `assets.ts` index file with nested resourc
41
41
 
42
42
  - `-a, --assets <path>` set assets resource directory. default: `public`
43
43
  - Output file: `assets.ts` (alongside the merged config file)
44
- - Directory/filenames are converted to camelCase keys
44
+ - File and directory names are used exactly as-is (e.g., `Direction.png` → `Direction`, `adjust-horizontal.png` → `'adjust-horizontal'`); keys with special characters are automatically quoted
45
45
  - `type` field uses file extension (lowercase), e.g. `'png'`, `'mp3'`, `'svg'`
46
- - Directories containing 2+ files of the same extension get a dedicated type (e.g. `PngAsset`, `Mp3Asset`) and `as Record<string, XxxAsset>` annotation
46
+ - Directories containing 2+ files of the same extension get a dedicated type (e.g. `PngAsset`, `Mp3Asset`) and `satisfies Record<string, XxxAsset>` annotation
47
47
  - Directories with ≤1 file or mixed extensions do not get a type annotation
48
48
  - Nested directories are supported (e.g. `public/sub/image/`)
49
49
 
@@ -59,14 +59,14 @@ export type SvgAsset = { path: string; type: 'svg' };
59
59
  export const ASSETS = {
60
60
  public: {
61
61
  image: {
62
- adjustHorizontal: {path:'public/image/adjust-horizontal.png',type:'png'},
63
- direction: {path:'public/image/direction.png',type:'png'}
62
+ 'adjust-horizontal': {path:'public/image/adjust-horizontal.png',type:'png'},
63
+ Direction: {path:'public/image/Direction.png',type:'png'}
64
64
  } satisfies Record<string, PngAsset>,
65
65
  music: {
66
66
  effect1: {path:'public/music/effect1.mp3',type:'mp3'},
67
67
  effect2: {path:'public/music/effect2.mp3',type:'mp3'}
68
68
  } satisfies Record<string, Mp3Asset>,
69
- singleFile: {
69
+ 'single-file': {
70
70
  effect1: {path:'public/single-file/effect1.mp3',type:'mp3'}
71
71
  }
72
72
  }
@@ -78,9 +78,12 @@ export const ASSETS = {
78
78
  ```typescript
79
79
  import { ASSETS } from "./assets";
80
80
 
81
- const meta = ASSETS.public.image.adjustHorizontal;
82
- // meta.path → 'public/image/adjust-horizontal.png'
81
+ const meta = ASSETS.public.image.Direction;
82
+ // meta.path → 'public/image/Direction.png'
83
83
  // meta.type → 'png'
84
+
85
+ const adjustMeta = ASSETS.public.image['adjust-horizontal'];
86
+ // adjustMeta.path → 'public/image/adjust-horizontal.png'
84
87
  ```
85
88
 
86
89
  ## Options
package/lib/config2ts.js CHANGED
@@ -342,7 +342,7 @@ function scanDir(dir, basePath) {
342
342
  for (const entry of entries) {
343
343
  const fullPath = path.join(dir, entry.name);
344
344
  if (entry.isDirectory()) {
345
- const key = changeCase.camelCase(entry.name);
345
+ const key = entry.name;
346
346
  const childNode = scanDir(fullPath, path.posix.join(basePath, entry.name));
347
347
  if (childNode !== null) {
348
348
  node[key] = childNode;
@@ -352,7 +352,7 @@ function scanDir(dir, basePath) {
352
352
  else if (entry.isFile()) {
353
353
  const parsed = path.parse(entry.name);
354
354
  const ext = parsed.ext.slice(1).toLowerCase();
355
- const key = changeCase.camelCase(parsed.name);
355
+ const key = parsed.name;
356
356
  const relPath = path.posix.join(basePath, entry.name);
357
357
  node[key] = { path: relPath, type: ext };
358
358
  hasContent = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "config2ts",
3
- "version": "2.5.2",
3
+ "version": "2.5.4",
4
4
  "description": "convert config to ts file.",
5
5
  "main": "lib/config2ts.js",
6
6
  "types": "lib/config2ts.d.ts",