@vitus-labs/tools-core 1.9.1-alpha.1 → 1.9.1-alpha.10

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 (2) hide show
  1. package/README.md +74 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # @vitus-labs/tools-core
2
+
3
+ Shared utilities for config loading, package metadata, and file discovery.
4
+
5
+ This is the foundation package used by all other `@vitus-labs/tools-*` packages.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ bun add @vitus-labs/tools-core
11
+ ```
12
+
13
+ ## API
14
+
15
+ ### `defineConfig(config)`
16
+
17
+ Identity helper for typed config files:
18
+
19
+ ```js
20
+ // vl-tools.config.mjs
21
+ import { defineConfig } from '@vitus-labs/tools-core'
22
+
23
+ export default defineConfig({
24
+ build: { sourceDir: 'src', outputDir: 'lib' },
25
+ stories: { framework: 'next' },
26
+ })
27
+ ```
28
+
29
+ ### `PKG`
30
+
31
+ Parsed `package.json` of the consuming project, augmented with:
32
+
33
+ - `bundleName` — camelCase package name (e.g. `@my-org/my-lib` → `myOrgMyLib`)
34
+ - `externalDependencies` — merged `dependencies` + `peerDependencies` keys
35
+
36
+ ### `VL_CONFIG`
37
+
38
+ Loaded config from `vl-tools.config.mjs`. Returns a function to access config sections:
39
+
40
+ ```ts
41
+ const buildConfig = VL_CONFIG('build')
42
+ buildConfig.get('sourceDir', 'src') // read with default
43
+ buildConfig.merge({ outputDir: 'dist' }) // deep-merge
44
+ ```
45
+
46
+ Config files cascade: root configs load first, closest package config overrides.
47
+
48
+ ### `TS_CONFIG`
49
+
50
+ Parsed `tsconfig.json` of the consuming project.
51
+
52
+ ### `findFile(filename)`
53
+
54
+ Walks up the directory tree from `cwd` to find a file by name.
55
+
56
+ ### `loadFileToJSON(filename)`
57
+
58
+ Finds and parses a JSON file from the directory tree.
59
+
60
+ ### `loadConfigParam(filename)`
61
+
62
+ Returns a function `(key, defaultValue)` to read dot-path keys from a JSON config file.
63
+
64
+ ### `swapGlobals(globals)`
65
+
66
+ Inverts key/value pairs — used to convert rollup `globals` format.
67
+
68
+ ## Note
69
+
70
+ `PKG`, `VL_CONFIG`, and `TS_CONFIG` are computed at module load time using top-level `await`. Importing this package has side effects (reads `package.json`, `tsconfig.json`, and `vl-tools.config.mjs` from `cwd`).
71
+
72
+ ## License
73
+
74
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitus-labs/tools-core",
3
- "version": "1.9.1-alpha.1+36e6e6c",
3
+ "version": "1.9.1-alpha.10+31b102c",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,8 +30,8 @@
30
30
  "typecheck": "tsc --noEmit"
31
31
  },
32
32
  "devDependencies": {
33
- "@vitus-labs/tools-typescript": "1.9.1-alpha.1+36e6e6c",
33
+ "@vitus-labs/tools-typescript": "1.9.1-alpha.10+31b102c",
34
34
  "typescript": "^5.9.3"
35
35
  },
36
- "gitHead": "36e6e6c15e179f41726ee969abdd665aff0c17a3"
36
+ "gitHead": "31b102cb703efe724ea51f66033c642adc691c9e"
37
37
  }