@walkeros/cli 0.4.1 → 0.4.2
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/CHANGELOG.md +13 -0
- package/README.md +112 -42
- package/dist/__tests__/bundle/bundler.test.js +174 -164
- package/dist/__tests__/bundle/bundler.test.js.map +1 -1
- package/dist/__tests__/bundle/programmatic.test.js +76 -53
- package/dist/__tests__/bundle/programmatic.test.js.map +1 -1
- package/dist/__tests__/cli.test.js +58 -46
- package/dist/__tests__/cli.test.js.map +1 -1
- package/dist/__tests__/config-loader.test.d.ts +1 -1
- package/dist/__tests__/config-loader.test.js +231 -212
- package/dist/__tests__/config-loader.test.js.map +1 -1
- package/dist/__tests__/core/build-cache.test.d.ts +2 -0
- package/dist/__tests__/core/build-cache.test.d.ts.map +1 -0
- package/dist/__tests__/core/build-cache.test.js +55 -0
- package/dist/__tests__/core/build-cache.test.js.map +1 -0
- package/dist/__tests__/core/cache-utils.test.d.ts +2 -0
- package/dist/__tests__/core/cache-utils.test.d.ts.map +1 -0
- package/dist/__tests__/core/cache-utils.test.js +70 -0
- package/dist/__tests__/core/cache-utils.test.js.map +1 -0
- package/dist/__tests__/integration/bundle-run.integration.test.js +8 -4
- package/dist/__tests__/integration/bundle-run.integration.test.js.map +1 -1
- package/dist/__tests__/simulate/node-executor.test.d.ts +5 -0
- package/dist/__tests__/simulate/node-executor.test.d.ts.map +1 -0
- package/dist/__tests__/simulate/node-executor.test.js +25 -0
- package/dist/__tests__/simulate/node-executor.test.js.map +1 -0
- package/dist/__tests__/simulate/server-simulate.integration.test.d.ts +5 -0
- package/dist/__tests__/simulate/server-simulate.integration.test.d.ts.map +1 -0
- package/dist/__tests__/simulate/server-simulate.integration.test.js +59 -0
- package/dist/__tests__/simulate/server-simulate.integration.test.js.map +1 -0
- package/dist/__tests__/smoke/production.smoke.test.js +9 -2
- package/dist/__tests__/smoke/production.smoke.test.js.map +1 -1
- package/dist/commands/bundle/bundler.d.ts.map +1 -1
- package/dist/commands/bundle/bundler.js +93 -3
- package/dist/commands/bundle/bundler.js.map +1 -1
- package/dist/commands/bundle/index.d.ts +16 -10
- package/dist/commands/bundle/index.d.ts.map +1 -1
- package/dist/commands/bundle/index.js +44 -32
- package/dist/commands/bundle/index.js.map +1 -1
- package/dist/commands/bundle/package-manager.d.ts +2 -1
- package/dist/commands/bundle/package-manager.d.ts.map +1 -1
- package/dist/commands/bundle/package-manager.js +34 -7
- package/dist/commands/bundle/package-manager.js.map +1 -1
- package/dist/commands/cache.d.ts +3 -0
- package/dist/commands/cache.d.ts.map +1 -0
- package/dist/commands/cache.js +44 -0
- package/dist/commands/cache.js.map +1 -0
- package/dist/commands/push/index.d.ts.map +1 -1
- package/dist/commands/push/index.js +49 -44
- package/dist/commands/push/index.js.map +1 -1
- package/dist/commands/push/types.d.ts +1 -1
- package/dist/commands/push/types.d.ts.map +1 -1
- package/dist/commands/run/__tests__/run.integration.test.js +14 -15
- package/dist/commands/run/__tests__/run.integration.test.js.map +1 -1
- package/dist/commands/run/utils.d.ts +4 -1
- package/dist/commands/run/utils.d.ts.map +1 -1
- package/dist/commands/run/utils.js +18 -24
- package/dist/commands/run/utils.js.map +1 -1
- package/dist/commands/run/validators.d.ts +9 -5
- package/dist/commands/run/validators.d.ts.map +1 -1
- package/dist/commands/run/validators.js +14 -11
- package/dist/commands/run/validators.js.map +1 -1
- package/dist/commands/simulate/index.d.ts +1 -0
- package/dist/commands/simulate/index.d.ts.map +1 -1
- package/dist/commands/simulate/index.js +1 -0
- package/dist/commands/simulate/index.js.map +1 -1
- package/dist/commands/simulate/node-executor.d.ts +28 -0
- package/dist/commands/simulate/node-executor.d.ts.map +1 -0
- package/dist/commands/simulate/node-executor.js +94 -0
- package/dist/commands/simulate/node-executor.js.map +1 -0
- package/dist/commands/simulate/simulator.d.ts.map +1 -1
- package/dist/commands/simulate/simulator.js +36 -32
- package/dist/commands/simulate/simulator.js.map +1 -1
- package/dist/config/build-defaults.d.ts +49 -0
- package/dist/config/build-defaults.d.ts.map +1 -0
- package/dist/config/build-defaults.js +72 -0
- package/dist/config/build-defaults.js.map +1 -0
- package/dist/config/index.d.ts +6 -7
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +6 -7
- package/dist/config/index.js.map +1 -1
- package/dist/config/loader.d.ts +34 -27
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +107 -92
- package/dist/config/loader.js.map +1 -1
- package/dist/config/validators.d.ts +34 -8
- package/dist/config/validators.d.ts.map +1 -1
- package/dist/config/validators.js +59 -21
- package/dist/config/validators.js.map +1 -1
- package/dist/core/asset-resolver.d.ts +8 -15
- package/dist/core/asset-resolver.d.ts.map +1 -1
- package/dist/core/asset-resolver.js +30 -37
- package/dist/core/asset-resolver.js.map +1 -1
- package/dist/core/build-cache.d.ts +23 -0
- package/dist/core/build-cache.d.ts.map +1 -0
- package/dist/core/build-cache.js +43 -0
- package/dist/core/build-cache.js.map +1 -0
- package/dist/core/cache-utils.d.ts +27 -0
- package/dist/core/cache-utils.d.ts.map +1 -0
- package/dist/core/cache-utils.js +60 -0
- package/dist/core/cache-utils.js.map +1 -0
- package/dist/core/docker.d.ts.map +1 -1
- package/dist/core/docker.js +8 -25
- package/dist/core/docker.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/local-packages.d.ts +19 -0
- package/dist/core/local-packages.d.ts.map +1 -0
- package/dist/core/local-packages.js +60 -0
- package/dist/core/local-packages.js.map +1 -0
- package/dist/examples/.npm-cache/content-v2/sha512/0d/2d/7581c288670eaf8538ddd9df145b78756ce3be0791c6e0b9cd33429b3bae894525b9bda287a3cedffbcdd2c7b3107bafc03f2b0367eea489eee1cc042abb +1 -0
- package/dist/examples/.npm-cache/content-v2/sha512/12/20/bc4f5acca143809f7e07da1fdafb38137d93243de4d5b403e6e10b92d0d3a6e51eab24fe9dbc9d3ed1cd72e8f7a406085e99c422bb2c7d1166cf9f1f564e +0 -0
- package/dist/examples/.npm-cache/content-v2/sha512/22/ee/fb2695b01871c1d36946bdcfb49f1b520a57200d0a0b221b1e7d5f047ab38a8b2ab0e5f0e25a00acde1f3f2f9d24430a18f1092d438bc1a9e9891cc45f75 +0 -0
- package/dist/examples/.npm-cache/content-v2/sha512/24/89/da1ce6a61bca6de7e132f241a675c01c83738bf6b78af25b5cce01d3030361332b3fe938571e2b721f1555da9ddf930fdcf8c02f0471556071590e68cc09 +0 -0
- package/dist/examples/.npm-cache/content-v2/sha512/47/fd/c6be997da99228c3e279b95d4a46d6913947078a178f54ac71795a159f3513b1483232f4c2d0a1f403178bf9f96bb19615de32a9e2133e949880c6bc15e2 +0 -0
- package/dist/examples/.npm-cache/content-v2/sha512/4b/1c/c1cb7f8b32102071a89fef97158daa32080ebaedfbbd596880d2213d84e305abc76d2a95a412ded55c1c3d487adcb1ceff87fc2c85d7e2856ebd9d3f16f3 +0 -0
- package/dist/examples/.npm-cache/content-v2/sha512/6e/53/ff864769671f44f39d8a3bf904cd646535b745cc4824a8bb3189193b474678049f43b5178ba15cad7f0289046105e70f1565afc84e907120b35a466690fd +1 -0
- package/dist/examples/.npm-cache/content-v2/sha512/70/4c/4c8837d446965c5551b4ea527e95fa011744fb727581d82cf35bb5599ea0b57d18baa490f7af93ef9a16e8e45e5c0802737da20575f4056a4a5c9a3cd288 +0 -0
- package/dist/examples/.npm-cache/content-v2/sha512/96/ad/05de3bbb12d7de8ea353f962bdaea7d2eb44f707f2973462a6635daf537c67b46cca7764fed7d464fe62152c3f783a07aba1ceb35e09ad446bff05a4b466 +1 -0
- package/dist/examples/.npm-cache/content-v2/sha512/b5/20/52dde94e6cef7170f6089c64a4843e57be18be450d956f4e455905aed047ae6a368451c93035e6ac3ee59576b600f03f815afba0836b3a16e10a9aaca4ba +1 -0
- package/dist/examples/.npm-cache/content-v2/sha512/c7/a9/d166a1c39f97df312c59261319ba1cf9aac178bda0a0cb697d5ddd78bd8dd38ef1bf40017bcc8633c2049896c2d70696d9bff9280851f270792ff38bb3a0 +1 -0
- package/dist/examples/.npm-cache/content-v2/sha512/e0/d0/8c14083b633e6adbd3c6a93da5fc0f6bbd456c5512ef276920bedd8d85d551052adff992de977aff326616a211aaa2d6ddcc801149e9b7f914f566359b6a +1 -0
- package/dist/examples/.npm-cache/content-v2/sha512/e7/c5/06ad3fd79ac4f1031fe0b16ea5e54e232ca397bbcd7592c679021cbfb027276099f8c848f3f7a7691f0102ad53aa64f9141e61d729b037a678bd60440d17 +1 -0
- package/dist/examples/.npm-cache/content-v2/sha512/f3/28/d5d32329604ed7d471a4949105daa2cc98858cf24f45b0b97c41d0eb0d5a9fe7bf1f69c792161cc6693e4fc1b52e886ac41875ebfb8fe47fafe417ca3e6e +0 -0
- package/dist/examples/.npm-cache/index-v5/04/5a/2b5d7a7c407d85d746baa0f5c9388a333e35a717a8a0a81943daa6cb1364 +3 -0
- package/dist/examples/.npm-cache/index-v5/12/9a/eba560cbace295d8ee04cf283015377bd77b379e70968fb6bc407c7fc410 +15 -0
- package/dist/examples/.npm-cache/index-v5/2f/a2/7b047564b0ee21ac835ec609e89153dd6549be554d098584d5bfd19fe043 +15 -0
- package/dist/examples/.npm-cache/index-v5/32/8e/322d58dd8d1e000be248ada51385bf96288e56039de9feec1a4c6a467653 +3 -0
- package/dist/examples/.npm-cache/index-v5/57/93/d1d7cd1402e3e26468db03f2870822bb2c9018a506cdfb3b405f38cd3e1c +3 -0
- package/dist/examples/.npm-cache/index-v5/5d/f8/0a1f4fa7149e4ff33e09eb6aea41ac8d1730c868a5d3ace91f762698acff +3 -0
- package/dist/examples/.npm-cache/index-v5/69/a4/a92c72d838259b051cdf8e0acfb2bc680b6d4cfc642314a7836c3f7b2c50 +15 -0
- package/dist/examples/.npm-cache/index-v5/71/31/6da3423bb203f3de5eb16c942431073f89be2cfcb40058ec91dcb5ce0abc +15 -0
- package/dist/examples/.npm-cache/index-v5/7b/94/72b6bffa050d9ef52a558dd220663695bc606f756be0dfa196ef4f3913ba +3 -0
- package/dist/examples/.npm-cache/index-v5/85/9e/99e97fdd562517e56285337db91d1a8f2f416b8d631cf4d7d754fa671299 +15 -0
- package/dist/examples/.npm-cache/index-v5/92/4c/9416ada81a9b3c679539fd1ab53f8de3d41ff268f35eba7a194389a85b06 +3 -0
- package/dist/examples/.npm-cache/index-v5/c1/5a/13df76b218deed8a6ef12961116af5183db98c53fad1b922fd9edc075247 +3 -0
- package/dist/examples/.npm-cache/index-v5/cb/11/253c55410a8ab7c4a9ea9d6e1bf8ef1450a581da64c478074dfd82c8bff6 +3 -0
- package/dist/examples/.npm-cache/index-v5/d5/ae/b57fad3a62b5ba2dbdf24b042a9e7b70820f3db00e5a630f02e1fea020dc +3 -0
- package/dist/examples/.npm-cache/index-v5/d6/32/2f620f83c7d14451de98de8298c2408e05a16cc0829bd16c891ac19d7a67 +3 -0
- package/dist/examples/.npm-cache/index-v5/dd/b5/01dc7a3cd8b6a03a69aee9af500d51ae19cb0aa12631a4aafd152148b8e5 +15 -0
- package/dist/examples/.npm-cache/index-v5/e0/cf/6b862c15d74630d3871cd813d305210ab741311deb10baf8813014e0bc30 +3 -0
- package/dist/examples/.npm-cache/index-v5/e2/be/e880ccd35950a814d3c1dded34d3938ac61b15a195321dc51357f801aad4 +15 -0
- package/dist/examples/.npm-cache/index-v5/e5/1f/f4affe0b392cd03288f23cc03abcb274ff11a2c8f8965299de681914abb2 +3 -0
- package/dist/examples/.npm-cache/index-v5/f3/5b/9ebe450958ff0d7cc44ab0a00080cb8a3ff1389744b5eab5f97b68a6a6af +3 -0
- package/dist/examples/.npm-cache/index-v5/fb/c1/0de405e902866d53e7c30cf36a97dc2578838622b261816f44dc377c9a80 +3 -0
- package/dist/examples/README.md +343 -0
- package/dist/examples/event.json +53 -0
- package/dist/examples/flow-order-complete.json +68 -0
- package/dist/examples/flow-simple.json +32 -0
- package/dist/examples/flow.json +82 -0
- package/dist/examples/server-collect.json +60 -0
- package/dist/examples/server-collect.mjs +13540 -0
- package/dist/examples/test.html +43 -0
- package/dist/examples/web-serve.js +25503 -0
- package/dist/examples/web-serve.json +74 -0
- package/dist/index.d.ts +84 -201
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +675 -422
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.d.ts +9 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +9 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/primitives.d.ts +37 -0
- package/dist/schemas/primitives.d.ts.map +1 -0
- package/dist/schemas/primitives.js +43 -0
- package/dist/schemas/primitives.js.map +1 -0
- package/dist/schemas/run.d.ts +23 -0
- package/dist/schemas/run.d.ts.map +1 -0
- package/dist/schemas/run.js +20 -0
- package/dist/schemas/run.js.map +1 -0
- package/dist/templates/server.hbs +29 -0
- package/dist/templates/web.hbs +45 -0
- package/dist/types/bundle.d.ts +68 -190
- package/dist/types/bundle.d.ts.map +1 -1
- package/dist/types/bundle.js +2 -2
- package/dist/walker.js +1 -0
- package/examples/README.md +42 -29
- package/examples/flow-order-complete.json +57 -57
- package/examples/flow-simple.json +25 -25
- package/examples/flow.json +69 -69
- package/examples/server-collect.json +51 -44
- package/examples/server-collect.mjs +1 -1
- package/examples/web-serve.json +62 -63
- package/package.json +2 -2
- package/dist/config/defaults.d.ts +0 -33
- package/dist/config/defaults.d.ts.map +0 -1
- package/dist/config/defaults.js +0 -69
- package/dist/config/defaults.js.map +0 -1
- package/dist/config/parser.d.ts +0 -128
- package/dist/config/parser.d.ts.map +0 -1
- package/dist/config/parser.js +0 -256
- package/dist/config/parser.js.map +0 -1
package/examples/web-serve.json
CHANGED
|
@@ -1,75 +1,74 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
"version": 1,
|
|
3
|
+
"flows": {
|
|
4
|
+
"default": {
|
|
5
|
+
"web": {
|
|
6
|
+
"windowCollector": "collector",
|
|
7
|
+
"windowElb": "elb"
|
|
8
|
+
},
|
|
9
|
+
"packages": {
|
|
10
|
+
"@walkeros/collector": {
|
|
11
|
+
"imports": ["startFlow"]
|
|
12
|
+
},
|
|
13
|
+
"@walkeros/source-demo": {
|
|
14
|
+
"imports": ["sourceDemo"]
|
|
15
|
+
},
|
|
16
|
+
"@walkeros/destination-demo": {
|
|
17
|
+
"imports": ["destinationDemo"]
|
|
18
|
+
},
|
|
19
|
+
"@walkeros/web-destination-api": {
|
|
20
|
+
"imports": ["destinationAPI"]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"sources": {
|
|
24
|
+
"demo": {
|
|
25
|
+
"package": "@walkeros/source-demo",
|
|
26
|
+
"config": {
|
|
27
|
+
"settings": {
|
|
28
|
+
"events": [
|
|
29
|
+
{
|
|
30
|
+
"name": "page view",
|
|
31
|
+
"data": { "title": "Home", "path": "/" },
|
|
32
|
+
"delay": 0
|
|
21
33
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
{
|
|
35
|
+
"name": "product view",
|
|
36
|
+
"data": {
|
|
37
|
+
"id": "P123",
|
|
38
|
+
"name": "Test Product",
|
|
39
|
+
"price": 99.99
|
|
40
|
+
},
|
|
41
|
+
"delay": 100
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
25
45
|
}
|
|
26
46
|
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
},
|
|
48
|
+
"destinations": {
|
|
49
|
+
"demo": {
|
|
50
|
+
"package": "@walkeros/destination-demo",
|
|
51
|
+
"config": {
|
|
52
|
+
"settings": {
|
|
53
|
+
"name": "demo"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"api": {
|
|
58
|
+
"package": "@walkeros/web-destination-api",
|
|
59
|
+
"config": {
|
|
60
|
+
"settings": {
|
|
61
|
+
"url": "http://localhost:8080/collect"
|
|
62
|
+
}
|
|
36
63
|
}
|
|
37
64
|
}
|
|
38
65
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"url": "http://localhost:8080/collect"
|
|
44
|
-
}
|
|
66
|
+
"collector": {
|
|
67
|
+
"run": true,
|
|
68
|
+
"globals": {
|
|
69
|
+
"language": "en"
|
|
45
70
|
}
|
|
46
71
|
}
|
|
47
|
-
},
|
|
48
|
-
"collector": {
|
|
49
|
-
"run": true,
|
|
50
|
-
"globals": {
|
|
51
|
-
"language": "en"
|
|
52
|
-
}
|
|
53
72
|
}
|
|
54
|
-
},
|
|
55
|
-
"build": {
|
|
56
|
-
"packages": {
|
|
57
|
-
"@walkeros/collector": {
|
|
58
|
-
"imports": ["startFlow"]
|
|
59
|
-
},
|
|
60
|
-
"@walkeros/source-demo": {
|
|
61
|
-
"imports": ["sourceDemo"]
|
|
62
|
-
},
|
|
63
|
-
"@walkeros/destination-demo": {
|
|
64
|
-
"imports": ["destinationDemo"]
|
|
65
|
-
},
|
|
66
|
-
"@walkeros/web-destination-api": {
|
|
67
|
-
"imports": ["destinationAPI"]
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
"minify": true,
|
|
71
|
-
"output": "web-serve.js",
|
|
72
|
-
"windowCollector": "collector",
|
|
73
|
-
"windowElb": "elb"
|
|
74
73
|
}
|
|
75
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "walkerOS CLI - Bundle and deploy walkerOS components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"docker:publish": "bash scripts/publish-docker.sh"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@walkeros/core": "^0.4.
|
|
37
|
+
"@walkeros/core": "^0.4.2",
|
|
38
38
|
"@walkeros/docker": "*",
|
|
39
39
|
"@walkeros/server-core": "*",
|
|
40
40
|
"chalk": "^5.3.0",
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration Defaults
|
|
3
|
-
*
|
|
4
|
-
* Platform-specific default build options.
|
|
5
|
-
*/
|
|
6
|
-
import type { BuildOptions } from '../types/bundle.js';
|
|
7
|
-
/**
|
|
8
|
-
* Get default build configuration for platform.
|
|
9
|
-
*
|
|
10
|
-
* @param platform - Target platform ('web' or 'server')
|
|
11
|
-
* @param code - User code to include (required for BuildOptions)
|
|
12
|
-
* @param output - Output file path (optional, uses platform default)
|
|
13
|
-
* @returns Platform-specific default build options
|
|
14
|
-
*
|
|
15
|
-
* @remarks
|
|
16
|
-
* Provides sensible defaults for each platform:
|
|
17
|
-
* - web: IIFE format for browser, ES2020 target
|
|
18
|
-
* - server: ESM format for Node.js, Node18 target
|
|
19
|
-
*/
|
|
20
|
-
export declare function getDefaultBuildOptions(platform: 'web' | 'server', code: string, output?: string): Partial<BuildOptions>;
|
|
21
|
-
/**
|
|
22
|
-
* Ensure build options have all required fields.
|
|
23
|
-
*
|
|
24
|
-
* @param buildOptions - Build options (possibly incomplete)
|
|
25
|
-
* @param flowPlatform - Platform from Flow.Config
|
|
26
|
-
* @returns Complete build options with defaults filled in
|
|
27
|
-
*
|
|
28
|
-
* @remarks
|
|
29
|
-
* Validates and fills in missing required fields using platform-specific defaults.
|
|
30
|
-
* Throws error if critical fields (code, output) are missing.
|
|
31
|
-
*/
|
|
32
|
-
export declare function ensureBuildOptions(buildOptions: Partial<BuildOptions>, flowPlatform: 'web' | 'server'): BuildOptions;
|
|
33
|
-
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,KAAK,GAAG,QAAQ,EAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,YAAY,CAAC,CA0BvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,OAAO,CAAC,YAAY,CAAC,EACnC,YAAY,EAAE,KAAK,GAAG,QAAQ,GAC7B,YAAY,CAmBd"}
|
package/dist/config/defaults.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration Defaults
|
|
3
|
-
*
|
|
4
|
-
* Platform-specific default build options.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Get default build configuration for platform.
|
|
8
|
-
*
|
|
9
|
-
* @param platform - Target platform ('web' or 'server')
|
|
10
|
-
* @param code - User code to include (required for BuildOptions)
|
|
11
|
-
* @param output - Output file path (optional, uses platform default)
|
|
12
|
-
* @returns Platform-specific default build options
|
|
13
|
-
*
|
|
14
|
-
* @remarks
|
|
15
|
-
* Provides sensible defaults for each platform:
|
|
16
|
-
* - web: IIFE format for browser, ES2020 target
|
|
17
|
-
* - server: ESM format for Node.js, Node18 target
|
|
18
|
-
*/
|
|
19
|
-
export function getDefaultBuildOptions(platform, code, output) {
|
|
20
|
-
const common = {
|
|
21
|
-
code,
|
|
22
|
-
packages: {},
|
|
23
|
-
minify: false,
|
|
24
|
-
sourcemap: false,
|
|
25
|
-
cache: true,
|
|
26
|
-
};
|
|
27
|
-
if (platform === 'web') {
|
|
28
|
-
return {
|
|
29
|
-
...common,
|
|
30
|
-
platform: 'browser',
|
|
31
|
-
format: 'iife',
|
|
32
|
-
target: 'es2020',
|
|
33
|
-
output: output || './dist/walker.js',
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
...common,
|
|
38
|
-
platform: 'node',
|
|
39
|
-
format: 'esm',
|
|
40
|
-
target: 'node18',
|
|
41
|
-
output: output || './dist/bundle.js',
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Ensure build options have all required fields.
|
|
46
|
-
*
|
|
47
|
-
* @param buildOptions - Build options (possibly incomplete)
|
|
48
|
-
* @param flowPlatform - Platform from Flow.Config
|
|
49
|
-
* @returns Complete build options with defaults filled in
|
|
50
|
-
*
|
|
51
|
-
* @remarks
|
|
52
|
-
* Validates and fills in missing required fields using platform-specific defaults.
|
|
53
|
-
* Throws error if critical fields (code, output) are missing.
|
|
54
|
-
*/
|
|
55
|
-
export function ensureBuildOptions(buildOptions, flowPlatform) {
|
|
56
|
-
const defaults = getDefaultBuildOptions(flowPlatform, buildOptions.code || '', buildOptions.output);
|
|
57
|
-
// Validate required fields
|
|
58
|
-
if (!buildOptions.output && !defaults.output) {
|
|
59
|
-
throw new Error('BuildOptions.output is required');
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
...defaults,
|
|
63
|
-
...buildOptions,
|
|
64
|
-
code: buildOptions.code || defaults.code || '',
|
|
65
|
-
output: buildOptions.output || defaults.output,
|
|
66
|
-
packages: buildOptions.packages || defaults.packages,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=defaults.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names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CAAC;AACpB,CAAC"}
|
package/dist/config/parser.d.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration Parser
|
|
3
|
-
*
|
|
4
|
-
* Parsing and normalization logic for configurations.
|
|
5
|
-
*/
|
|
6
|
-
import type { Flow } from '@walkeros/core';
|
|
7
|
-
import type { BuildOptions, EnvironmentConfig } from '../types/bundle.js';
|
|
8
|
-
/**
|
|
9
|
-
* Result of parsing bundle configuration.
|
|
10
|
-
*/
|
|
11
|
-
export interface ParsedConfig {
|
|
12
|
-
flowConfig: Flow.Config;
|
|
13
|
-
buildOptions: BuildOptions;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Result of config structure parsing (before validation).
|
|
17
|
-
*/
|
|
18
|
-
export interface ParsedStructure {
|
|
19
|
-
/** Raw flow config (not yet validated) */
|
|
20
|
-
flowConfig: unknown;
|
|
21
|
-
/** Raw build options (not yet validated) */
|
|
22
|
-
buildOptions: unknown;
|
|
23
|
-
/** Metadata about the config */
|
|
24
|
-
metadata: {
|
|
25
|
-
/** Selected environment name */
|
|
26
|
-
environment: string;
|
|
27
|
-
/** Whether this is a multi-environment setup */
|
|
28
|
-
isMultiEnvironment: boolean;
|
|
29
|
-
/** All available environment names (for multi-env setups) */
|
|
30
|
-
availableEnvironments?: string[];
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Options for parsing config structure.
|
|
35
|
-
*/
|
|
36
|
-
export interface ParseStructureOptions {
|
|
37
|
-
/** Config file path (for error messages) */
|
|
38
|
-
configPath?: string;
|
|
39
|
-
/** Environment to select (for multi-env configs) */
|
|
40
|
-
environment?: string;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Parse config structure and extract environment-specific configuration.
|
|
44
|
-
*
|
|
45
|
-
* @param rawConfig - Raw configuration object
|
|
46
|
-
* @param options - Parsing options
|
|
47
|
-
* @returns Extracted flow config, build options, and metadata
|
|
48
|
-
* @throws Error if config format is invalid or environment is missing
|
|
49
|
-
*
|
|
50
|
-
* @remarks
|
|
51
|
-
* **Level 1 of 3-level config loading**:
|
|
52
|
-
* - Detects multi-env vs single-env format
|
|
53
|
-
* - Extracts the appropriate environment config
|
|
54
|
-
* - No validation performed (happens in normalizeAndValidate)
|
|
55
|
-
*/
|
|
56
|
-
export declare function parseConfigStructure(rawConfig: unknown, options?: ParseStructureOptions): ParsedStructure;
|
|
57
|
-
/**
|
|
58
|
-
* Normalize and validate flow and build configurations.
|
|
59
|
-
*
|
|
60
|
-
* @param flowConfig - Raw flow configuration
|
|
61
|
-
* @param buildOptions - Raw build options
|
|
62
|
-
* @param configPath - Path to config file (for relative template resolution)
|
|
63
|
-
* @returns Validated and normalized configuration
|
|
64
|
-
* @throws Error if validation fails
|
|
65
|
-
*
|
|
66
|
-
* @remarks
|
|
67
|
-
* **Level 2 of 3-level config loading**:
|
|
68
|
-
* - Validates platform (once!)
|
|
69
|
-
* - Applies platform-specific defaults (single pass)
|
|
70
|
-
* - Resolves relative template paths
|
|
71
|
-
* - Ensures all required fields are present
|
|
72
|
-
*/
|
|
73
|
-
export declare function normalizeAndValidate(flowConfig: unknown, buildOptions: unknown, configPath?: string): ParsedConfig;
|
|
74
|
-
/**
|
|
75
|
-
* Parse and normalize bundle configuration.
|
|
76
|
-
*
|
|
77
|
-
* @param data - Raw configuration data (EnvironmentConfig format: { flow, build })
|
|
78
|
-
* @returns Normalized flowConfig and buildOptions with platform-specific defaults
|
|
79
|
-
* @throws Error if validation fails
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```typescript
|
|
83
|
-
* const { flowConfig, buildOptions } = parseBundleConfig({
|
|
84
|
-
* flow: {
|
|
85
|
-
* platform: 'web',
|
|
86
|
-
* sources: { browser: {...} },
|
|
87
|
-
* destinations: { gtag: {...} }
|
|
88
|
-
* },
|
|
89
|
-
* build: {
|
|
90
|
-
* packages: { '@walkeros/core': {...} },
|
|
91
|
-
* code: '...',
|
|
92
|
-
* output: './dist/bundle.js'
|
|
93
|
-
* }
|
|
94
|
-
* });
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
export declare function parseBundleConfig(data: unknown): ParsedConfig;
|
|
98
|
-
/**
|
|
99
|
-
* Safely parse bundle configuration without throwing.
|
|
100
|
-
*
|
|
101
|
-
* @param data - Raw configuration data
|
|
102
|
-
* @returns Success result with normalized configs or error result
|
|
103
|
-
*/
|
|
104
|
-
export declare function safeParseBundleConfig(data: unknown): {
|
|
105
|
-
success: boolean;
|
|
106
|
-
data?: ParsedConfig;
|
|
107
|
-
error?: Error;
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Normalize flow and build configurations with platform-specific defaults.
|
|
111
|
-
*
|
|
112
|
-
* @param config - Environment configuration or flow+build object
|
|
113
|
-
* @param configPath - Path to config file (for relative template resolution)
|
|
114
|
-
* @returns Normalized flow and build configurations
|
|
115
|
-
*
|
|
116
|
-
* @deprecated Use normalizeAndValidate() instead (simpler, single-pass validation)
|
|
117
|
-
*
|
|
118
|
-
* @remarks
|
|
119
|
-
* Kept for backward compatibility. Internally delegates to normalizeAndValidate().
|
|
120
|
-
*/
|
|
121
|
-
export declare function normalizeConfigs(config: EnvironmentConfig | {
|
|
122
|
-
flow: Flow.Config;
|
|
123
|
-
build: Partial<BuildOptions>;
|
|
124
|
-
}, configPath?: string): {
|
|
125
|
-
flowConfig: Flow.Config;
|
|
126
|
-
buildOptions: BuildOptions;
|
|
127
|
-
};
|
|
128
|
-
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/config/parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAQ5B;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AAI,CAAC,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;CAAE,EACvD,UAAU,CAAC,EAAE,MAAM,GAClB;IAAE,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC;IAAC,YAAY,EAAE,YAAY,CAAA;CAAE,CAGzD"}
|
package/dist/config/parser.js
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration Parser
|
|
3
|
-
*
|
|
4
|
-
* Parsing and normalization logic for configurations.
|
|
5
|
-
*/
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { isObject, isSingleEnvConfig, isMultiEnvConfig, validatePlatform, } from './validators.js';
|
|
8
|
-
/**
|
|
9
|
-
* Parse config structure and extract environment-specific configuration.
|
|
10
|
-
*
|
|
11
|
-
* @param rawConfig - Raw configuration object
|
|
12
|
-
* @param options - Parsing options
|
|
13
|
-
* @returns Extracted flow config, build options, and metadata
|
|
14
|
-
* @throws Error if config format is invalid or environment is missing
|
|
15
|
-
*
|
|
16
|
-
* @remarks
|
|
17
|
-
* **Level 1 of 3-level config loading**:
|
|
18
|
-
* - Detects multi-env vs single-env format
|
|
19
|
-
* - Extracts the appropriate environment config
|
|
20
|
-
* - No validation performed (happens in normalizeAndValidate)
|
|
21
|
-
*/
|
|
22
|
-
export function parseConfigStructure(rawConfig, options = {}) {
|
|
23
|
-
// Multi-environment format
|
|
24
|
-
if (isMultiEnvConfig(rawConfig)) {
|
|
25
|
-
const setup = rawConfig;
|
|
26
|
-
const availableEnvironments = Object.keys(setup.environments);
|
|
27
|
-
// Validate environment selection
|
|
28
|
-
if (!options.environment) {
|
|
29
|
-
throw new Error(`Multi-environment configuration detected. Please specify an environment using --env flag.\n` +
|
|
30
|
-
`Available environments: ${availableEnvironments.join(', ')}`);
|
|
31
|
-
}
|
|
32
|
-
const selectedEnv = options.environment;
|
|
33
|
-
if (!setup.environments[selectedEnv]) {
|
|
34
|
-
throw new Error(`Environment "${selectedEnv}" not found in configuration.\n` +
|
|
35
|
-
`Available environments: ${availableEnvironments.join(', ')}`);
|
|
36
|
-
}
|
|
37
|
-
const envConfig = setup.environments[selectedEnv];
|
|
38
|
-
return {
|
|
39
|
-
flowConfig: envConfig.flow,
|
|
40
|
-
buildOptions: envConfig.build,
|
|
41
|
-
metadata: {
|
|
42
|
-
environment: selectedEnv,
|
|
43
|
-
isMultiEnvironment: true,
|
|
44
|
-
availableEnvironments,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
// Single-environment format
|
|
49
|
-
if (isSingleEnvConfig(rawConfig)) {
|
|
50
|
-
const config = rawConfig;
|
|
51
|
-
return {
|
|
52
|
-
flowConfig: config.flow,
|
|
53
|
-
buildOptions: config.build,
|
|
54
|
-
metadata: {
|
|
55
|
-
environment: 'default',
|
|
56
|
-
isMultiEnvironment: false,
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
// Invalid format - provide helpful error
|
|
61
|
-
const configPath = options.configPath || 'configuration';
|
|
62
|
-
const configType = isObject(rawConfig)
|
|
63
|
-
? 'platform' in rawConfig
|
|
64
|
-
? `invalid platform value: "${rawConfig.platform}"`
|
|
65
|
-
: 'missing "flow" and "build" fields'
|
|
66
|
-
: `not an object (got ${typeof rawConfig})`;
|
|
67
|
-
throw new Error(`Invalid configuration format at ${configPath}.\n` +
|
|
68
|
-
`Configuration ${configType}.\n\n` +
|
|
69
|
-
`Expected either:\n` +
|
|
70
|
-
` 1. Multi-environment: { version: 1, environments: { prod: { flow: {...}, build: {...} } } }\n` +
|
|
71
|
-
` 2. Single-environment: { flow: { platform: "web" | "server", ... }, build: { packages: {...}, ... } }`);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Normalize and validate flow and build configurations.
|
|
75
|
-
*
|
|
76
|
-
* @param flowConfig - Raw flow configuration
|
|
77
|
-
* @param buildOptions - Raw build options
|
|
78
|
-
* @param configPath - Path to config file (for relative template resolution)
|
|
79
|
-
* @returns Validated and normalized configuration
|
|
80
|
-
* @throws Error if validation fails
|
|
81
|
-
*
|
|
82
|
-
* @remarks
|
|
83
|
-
* **Level 2 of 3-level config loading**:
|
|
84
|
-
* - Validates platform (once!)
|
|
85
|
-
* - Applies platform-specific defaults (single pass)
|
|
86
|
-
* - Resolves relative template paths
|
|
87
|
-
* - Ensures all required fields are present
|
|
88
|
-
*/
|
|
89
|
-
export function normalizeAndValidate(flowConfig, buildOptions, configPath) {
|
|
90
|
-
// Extract and validate platform (ONCE - not in type guards)
|
|
91
|
-
if (!isObject(flowConfig) || !('platform' in flowConfig)) {
|
|
92
|
-
throw new Error(`Invalid flow config: missing "platform" field. Expected "web" or "server".`);
|
|
93
|
-
}
|
|
94
|
-
const platform = flowConfig.platform;
|
|
95
|
-
if (!validatePlatform(platform)) {
|
|
96
|
-
throw new Error(`Invalid platform "${platform}". Must be "web" or "server".`);
|
|
97
|
-
}
|
|
98
|
-
// Validate build options structure
|
|
99
|
-
if (!isObject(buildOptions)) {
|
|
100
|
-
throw new Error(`Invalid build options: expected object, got ${typeof buildOptions}`);
|
|
101
|
-
}
|
|
102
|
-
// Apply platform-specific defaults (single pass merge)
|
|
103
|
-
const platformDefaults = platform === 'web'
|
|
104
|
-
? {
|
|
105
|
-
platform: 'browser',
|
|
106
|
-
format: 'iife',
|
|
107
|
-
target: 'es2020',
|
|
108
|
-
minify: false,
|
|
109
|
-
sourcemap: false,
|
|
110
|
-
tempDir: '.tmp',
|
|
111
|
-
cache: true,
|
|
112
|
-
}
|
|
113
|
-
: {
|
|
114
|
-
platform: 'node',
|
|
115
|
-
format: 'esm',
|
|
116
|
-
target: 'node20',
|
|
117
|
-
minify: false,
|
|
118
|
-
sourcemap: false,
|
|
119
|
-
tempDir: '.tmp',
|
|
120
|
-
cache: true,
|
|
121
|
-
};
|
|
122
|
-
// Single merge: defaults + user config + conditional defaults
|
|
123
|
-
const merged = {
|
|
124
|
-
...platformDefaults,
|
|
125
|
-
...buildOptions,
|
|
126
|
-
};
|
|
127
|
-
// Auto-select default template based on platform if not specified
|
|
128
|
-
if (merged.template === undefined) {
|
|
129
|
-
merged.template = platform === 'server' ? 'server.hbs' : 'web.hbs';
|
|
130
|
-
}
|
|
131
|
-
// Apply window assignment defaults for browser IIFE
|
|
132
|
-
if (merged.format === 'iife' && merged.platform === 'browser') {
|
|
133
|
-
if (merged.windowCollector === undefined) {
|
|
134
|
-
merged.windowCollector = 'collector';
|
|
135
|
-
}
|
|
136
|
-
if (merged.windowElb === undefined) {
|
|
137
|
-
merged.windowElb = 'elb';
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
// Resolve template path relative to config file directory if it starts with ./ or ../
|
|
141
|
-
if (configPath &&
|
|
142
|
-
merged.template &&
|
|
143
|
-
!path.isAbsolute(merged.template) &&
|
|
144
|
-
(merged.template.startsWith('./') || merged.template.startsWith('../'))) {
|
|
145
|
-
const configDir = path.dirname(configPath);
|
|
146
|
-
merged.template = path.resolve(configDir, merged.template);
|
|
147
|
-
}
|
|
148
|
-
// Apply platform-specific defaults for required fields
|
|
149
|
-
if (!merged.output || merged.output === '') {
|
|
150
|
-
merged.output =
|
|
151
|
-
platform === 'web' ? './dist/walker.js' : './dist/bundle.js';
|
|
152
|
-
}
|
|
153
|
-
// Resolve output path relative to config file directory if it's relative
|
|
154
|
-
// Skip resolution for placeholder paths used in tests/programmatic API
|
|
155
|
-
if (configPath &&
|
|
156
|
-
configPath !== '/unknown/path' &&
|
|
157
|
-
merged.output &&
|
|
158
|
-
!path.isAbsolute(merged.output)) {
|
|
159
|
-
const configDir = path.dirname(configPath);
|
|
160
|
-
merged.output = path.resolve(configDir, merged.output);
|
|
161
|
-
}
|
|
162
|
-
if (!merged.packages) {
|
|
163
|
-
merged.packages = {};
|
|
164
|
-
}
|
|
165
|
-
if (merged.code === undefined || merged.code === '') {
|
|
166
|
-
merged.code = '';
|
|
167
|
-
}
|
|
168
|
-
// Return fully validated config
|
|
169
|
-
return {
|
|
170
|
-
flowConfig: flowConfig,
|
|
171
|
-
buildOptions: merged,
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Parse and normalize bundle configuration.
|
|
176
|
-
*
|
|
177
|
-
* @param data - Raw configuration data (EnvironmentConfig format: { flow, build })
|
|
178
|
-
* @returns Normalized flowConfig and buildOptions with platform-specific defaults
|
|
179
|
-
* @throws Error if validation fails
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```typescript
|
|
183
|
-
* const { flowConfig, buildOptions } = parseBundleConfig({
|
|
184
|
-
* flow: {
|
|
185
|
-
* platform: 'web',
|
|
186
|
-
* sources: { browser: {...} },
|
|
187
|
-
* destinations: { gtag: {...} }
|
|
188
|
-
* },
|
|
189
|
-
* build: {
|
|
190
|
-
* packages: { '@walkeros/core': {...} },
|
|
191
|
-
* code: '...',
|
|
192
|
-
* output: './dist/bundle.js'
|
|
193
|
-
* }
|
|
194
|
-
* });
|
|
195
|
-
* ```
|
|
196
|
-
*/
|
|
197
|
-
export function parseBundleConfig(data) {
|
|
198
|
-
// Basic type checking
|
|
199
|
-
if (!isObject(data)) {
|
|
200
|
-
throw new Error(`Invalid config: expected object, got ${typeof data}`);
|
|
201
|
-
}
|
|
202
|
-
// Check for new format { flow, build }
|
|
203
|
-
if (!('flow' in data) || !isObject(data.flow)) {
|
|
204
|
-
throw new Error(`Invalid config: missing "flow" field. ` +
|
|
205
|
-
`Expected format: { flow: { platform: "web" | "server", ... }, build: { ... } }`);
|
|
206
|
-
}
|
|
207
|
-
if (!('build' in data) || !isObject(data.build)) {
|
|
208
|
-
throw new Error(`Invalid config: missing "build" field. ` +
|
|
209
|
-
`Expected format: { flow: { platform: "web" | "server", ... }, build: { ... } }`);
|
|
210
|
-
}
|
|
211
|
-
// Validate build.packages field
|
|
212
|
-
const buildData = data.build;
|
|
213
|
-
if ('packages' in buildData && !isObject(buildData.packages)) {
|
|
214
|
-
throw new Error(`Invalid config: build.packages must be an object, got ${typeof buildData.packages}`);
|
|
215
|
-
}
|
|
216
|
-
// Use new simplified validation
|
|
217
|
-
return normalizeAndValidate(data.flow, data.build, '/unknown/path');
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Safely parse bundle configuration without throwing.
|
|
221
|
-
*
|
|
222
|
-
* @param data - Raw configuration data
|
|
223
|
-
* @returns Success result with normalized configs or error result
|
|
224
|
-
*/
|
|
225
|
-
export function safeParseBundleConfig(data) {
|
|
226
|
-
try {
|
|
227
|
-
const normalized = parseBundleConfig(data);
|
|
228
|
-
return {
|
|
229
|
-
success: true,
|
|
230
|
-
data: normalized,
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
catch (error) {
|
|
234
|
-
return {
|
|
235
|
-
success: false,
|
|
236
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Normalize flow and build configurations with platform-specific defaults.
|
|
242
|
-
*
|
|
243
|
-
* @param config - Environment configuration or flow+build object
|
|
244
|
-
* @param configPath - Path to config file (for relative template resolution)
|
|
245
|
-
* @returns Normalized flow and build configurations
|
|
246
|
-
*
|
|
247
|
-
* @deprecated Use normalizeAndValidate() instead (simpler, single-pass validation)
|
|
248
|
-
*
|
|
249
|
-
* @remarks
|
|
250
|
-
* Kept for backward compatibility. Internally delegates to normalizeAndValidate().
|
|
251
|
-
*/
|
|
252
|
-
export function normalizeConfigs(config, configPath) {
|
|
253
|
-
// Delegate to new simplified function
|
|
254
|
-
return normalizeAndValidate(config.flow, config.build, configPath);
|
|
255
|
-
}
|
|
256
|
-
//# sourceMappingURL=parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/config/parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAOxB,OAAO,EACL,QAAQ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