generate-ui-cli 2.2.0 → 2.3.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.
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.findProjectConfig = findProjectConfig;
7
+ exports.pickConfiguredPath = pickConfiguredPath;
8
+ exports.resolveOptionalPath = resolveOptionalPath;
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const path_1 = __importDefault(require("path"));
11
+ function findProjectConfig(startDir) {
12
+ let dir = path_1.default.resolve(startDir);
13
+ const root = path_1.default.parse(dir).root;
14
+ while (true) {
15
+ const candidate = path_1.default.join(dir, 'generateui-config.json');
16
+ if (fs_1.default.existsSync(candidate)) {
17
+ const parsed = tryReadConfig(candidate);
18
+ if (parsed) {
19
+ return {
20
+ configPath: candidate,
21
+ config: parsed
22
+ };
23
+ }
24
+ }
25
+ if (dir === root) {
26
+ return {
27
+ configPath: null,
28
+ config: null
29
+ };
30
+ }
31
+ dir = path_1.default.dirname(dir);
32
+ }
33
+ }
34
+ function pickConfiguredPath(config, key) {
35
+ const scoped = config?.paths?.[key];
36
+ if (typeof scoped === 'string' && scoped.trim().length > 0) {
37
+ return scoped.trim();
38
+ }
39
+ const topLevel = config?.[key];
40
+ if (typeof topLevel === 'string' && topLevel.trim().length > 0) {
41
+ return topLevel.trim();
42
+ }
43
+ return null;
44
+ }
45
+ function resolveOptionalPath(cliValue, configuredValue, configPath) {
46
+ if (cliValue && cliValue.trim().length > 0) {
47
+ return path_1.default.resolve(process.cwd(), cliValue);
48
+ }
49
+ if (configuredValue &&
50
+ configuredValue.trim().length > 0 &&
51
+ configPath) {
52
+ return path_1.default.resolve(path_1.default.dirname(configPath), configuredValue);
53
+ }
54
+ return null;
55
+ }
56
+ function tryReadConfig(configPath) {
57
+ try {
58
+ const raw = fs_1.default.readFileSync(configPath, 'utf-8');
59
+ return JSON.parse(raw);
60
+ }
61
+ catch {
62
+ return null;
63
+ }
64
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generate-ui-cli",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Generate UI from OpenAPI",
5
5
  "license": "MIT",
6
6
  "repository": {