@walkeros/cli 0.4.1 → 0.5.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/CHANGELOG.md +26 -0
- package/README.md +247 -46
- package/dist/__tests__/bundle/bundler-helpers.test.js +0 -134
- package/dist/__tests__/bundle/bundler-helpers.test.js.map +1 -1
- package/dist/__tests__/bundle/bundler.test.js +253 -183
- package/dist/__tests__/bundle/bundler.test.js.map +1 -1
- package/dist/__tests__/bundle/programmatic.test.js +74 -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 +229 -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 +58 -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 +18 -0
- package/dist/commands/bundle/bundler.d.ts.map +1 -1
- package/dist/commands/bundle/bundler.js +286 -80
- 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/execution.d.ts.map +1 -1
- package/dist/commands/run/execution.js +6 -2
- package/dist/commands/run/execution.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 +70 -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 +9 -16
- package/dist/core/asset-resolver.d.ts.map +1 -1
- package/dist/core/asset-resolver.js +30 -41
- 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 +14 -27
- 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 +355 -0
- package/dist/examples/event.json +53 -0
- package/dist/examples/flow-order-complete.json +67 -0
- package/dist/examples/flow-simple.json +31 -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 +80 -310
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +924 -736
- 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/types/bundle.d.ts +64 -191
- 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 +55 -30
- package/examples/flow-order-complete.json +56 -57
- package/examples/flow-simple.json +24 -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 -4
- package/dist/__tests__/bundle/serializer.test.d.ts +0 -2
- package/dist/__tests__/bundle/serializer.test.d.ts.map +0 -1
- package/dist/__tests__/bundle/serializer.test.js +0 -173
- package/dist/__tests__/bundle/serializer.test.js.map +0 -1
- package/dist/__tests__/bundle/template-engine.test.d.ts +0 -2
- package/dist/__tests__/bundle/template-engine.test.d.ts.map +0 -1
- package/dist/__tests__/bundle/template-engine.test.js +0 -107
- package/dist/__tests__/bundle/template-engine.test.js.map +0 -1
- package/dist/commands/bundle/serializer.d.ts +0 -23
- package/dist/commands/bundle/serializer.d.ts.map +0 -1
- package/dist/commands/bundle/serializer.js +0 -127
- package/dist/commands/bundle/serializer.js.map +0 -1
- package/dist/commands/bundle/template-engine.d.ts +0 -20
- package/dist/commands/bundle/template-engine.d.ts.map +0 -1
- package/dist/commands/bundle/template-engine.js +0 -54
- package/dist/commands/bundle/template-engine.js.map +0 -1
- 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/dist/types/template.d.ts +0 -108
- package/dist/types/template.d.ts.map +0 -1
- package/dist/types/template.js +0 -10
- package/dist/types/template.js.map +0 -1
- package/templates/server.hbs +0 -29
- package/templates/web.hbs +0 -45
|
@@ -2,25 +2,51 @@
|
|
|
2
2
|
* Configuration Type Guards and Validators
|
|
3
3
|
*
|
|
4
4
|
* Type checking utilities for configuration validation.
|
|
5
|
+
* Uses Zod schemas from @walkeros/core for Flow.Setup validation.
|
|
5
6
|
*/
|
|
6
|
-
import type {
|
|
7
|
+
import type { Flow } from '@walkeros/core';
|
|
7
8
|
/**
|
|
8
9
|
* Type guard: Check if value is a plain object.
|
|
9
10
|
*/
|
|
10
11
|
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* Detect platform from flow config.
|
|
14
|
+
*
|
|
15
|
+
* Platform is determined by the presence of `web` or `server` key.
|
|
13
16
|
*/
|
|
14
|
-
export declare function
|
|
17
|
+
export declare function detectPlatform(flowConfig: Record<string, unknown>): 'web' | 'server' | undefined;
|
|
15
18
|
/**
|
|
16
|
-
* Type guard: Check if config is
|
|
19
|
+
* Type guard: Check if config is a valid Flow.Setup structure.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Uses Zod validation from @walkeros/core.
|
|
23
|
+
* Returns false instead of throwing on invalid input.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* if (isFlowSetup(config)) {
|
|
28
|
+
* const flowConfig = getFlowConfig(config, 'production');
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
17
31
|
*/
|
|
18
|
-
export declare function
|
|
32
|
+
export declare function isFlowSetup(data: unknown): data is Flow.Setup;
|
|
19
33
|
/**
|
|
20
|
-
*
|
|
34
|
+
* Validate Flow.Setup and throw descriptive error if invalid.
|
|
21
35
|
*
|
|
22
36
|
* @remarks
|
|
23
|
-
*
|
|
37
|
+
* Uses Zod validation from @walkeros/core.
|
|
38
|
+
* Provides detailed error messages from Zod.
|
|
39
|
+
*
|
|
40
|
+
* @param data - Raw configuration data
|
|
41
|
+
* @returns Validated Flow.Setup
|
|
42
|
+
* @throws Error with descriptive message if validation fails
|
|
43
|
+
*/
|
|
44
|
+
export declare function validateFlowSetup(data: unknown): Flow.Setup;
|
|
45
|
+
/**
|
|
46
|
+
* Get available flow names from a Flow.Setup.
|
|
47
|
+
*
|
|
48
|
+
* @param setup - Flow.Setup configuration
|
|
49
|
+
* @returns Array of flow names
|
|
24
50
|
*/
|
|
25
|
-
export declare function
|
|
51
|
+
export declare function getAvailableFlows(setup: Flow.Setup): string[];
|
|
26
52
|
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/config/validators.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/config/validators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAK3C;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOzE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,KAAK,GAAG,QAAQ,GAAG,SAAS,CAQ9B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,IAAI,CAAC,KAAK,CAG7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAkB3D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,MAAM,EAAE,CAE7D"}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* Configuration Type Guards and Validators
|
|
3
3
|
*
|
|
4
4
|
* Type checking utilities for configuration validation.
|
|
5
|
+
* Uses Zod schemas from @walkeros/core for Flow.Setup validation.
|
|
5
6
|
*/
|
|
7
|
+
import { schemas } from '@walkeros/core/dev';
|
|
8
|
+
const { safeParseSetup } = schemas;
|
|
6
9
|
/**
|
|
7
10
|
* Type guard: Check if value is a plain object.
|
|
8
11
|
*/
|
|
@@ -13,35 +16,70 @@ export function isObject(value) {
|
|
|
13
16
|
Object.prototype.toString.call(value) === '[object Object]');
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
|
-
*
|
|
19
|
+
* Detect platform from flow config.
|
|
20
|
+
*
|
|
21
|
+
* Platform is determined by the presence of `web` or `server` key.
|
|
17
22
|
*/
|
|
18
|
-
export function
|
|
19
|
-
|
|
23
|
+
export function detectPlatform(flowConfig) {
|
|
24
|
+
if ('web' in flowConfig && flowConfig.web !== undefined) {
|
|
25
|
+
return 'web';
|
|
26
|
+
}
|
|
27
|
+
if ('server' in flowConfig && flowConfig.server !== undefined) {
|
|
28
|
+
return 'server';
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
20
31
|
}
|
|
21
32
|
/**
|
|
22
|
-
* Type guard: Check if config is
|
|
33
|
+
* Type guard: Check if config is a valid Flow.Setup structure.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* Uses Zod validation from @walkeros/core.
|
|
37
|
+
* Returns false instead of throwing on invalid input.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* if (isFlowSetup(config)) {
|
|
42
|
+
* const flowConfig = getFlowConfig(config, 'production');
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
23
45
|
*/
|
|
24
|
-
export function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
data.version === 1 &&
|
|
28
|
-
'environments' in data &&
|
|
29
|
-
isObject(data.environments));
|
|
46
|
+
export function isFlowSetup(data) {
|
|
47
|
+
const result = safeParseSetup(data);
|
|
48
|
+
return result.success;
|
|
30
49
|
}
|
|
31
50
|
/**
|
|
32
|
-
*
|
|
51
|
+
* Validate Flow.Setup and throw descriptive error if invalid.
|
|
33
52
|
*
|
|
34
53
|
* @remarks
|
|
35
|
-
*
|
|
54
|
+
* Uses Zod validation from @walkeros/core.
|
|
55
|
+
* Provides detailed error messages from Zod.
|
|
56
|
+
*
|
|
57
|
+
* @param data - Raw configuration data
|
|
58
|
+
* @returns Validated Flow.Setup
|
|
59
|
+
* @throws Error with descriptive message if validation fails
|
|
60
|
+
*/
|
|
61
|
+
export function validateFlowSetup(data) {
|
|
62
|
+
const result = safeParseSetup(data);
|
|
63
|
+
if (!result.success) {
|
|
64
|
+
// Format Zod errors for CLI display
|
|
65
|
+
const errors = result.error.issues
|
|
66
|
+
.map((issue) => {
|
|
67
|
+
const path = issue.path.length > 0 ? issue.path.map(String).join('.') : 'root';
|
|
68
|
+
return ` - ${path}: ${issue.message}`;
|
|
69
|
+
})
|
|
70
|
+
.join('\n');
|
|
71
|
+
throw new Error(`Invalid configuration:\n${errors}`);
|
|
72
|
+
}
|
|
73
|
+
// Cast to Flow.Setup since Zod's inferred type is compatible but not identical
|
|
74
|
+
return result.data;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get available flow names from a Flow.Setup.
|
|
78
|
+
*
|
|
79
|
+
* @param setup - Flow.Setup configuration
|
|
80
|
+
* @returns Array of flow names
|
|
36
81
|
*/
|
|
37
|
-
export function
|
|
38
|
-
return (
|
|
39
|
-
'flow' in data &&
|
|
40
|
-
'build' in data &&
|
|
41
|
-
isObject(data.flow) &&
|
|
42
|
-
isObject(data.build) &&
|
|
43
|
-
'platform' in data.flow);
|
|
82
|
+
export function getAvailableFlows(setup) {
|
|
83
|
+
return Object.keys(setup.flows);
|
|
44
84
|
}
|
|
45
|
-
// Legacy format support removed in v0.3.0
|
|
46
|
-
// See docs/MIGRATION.md for migration guide
|
|
47
85
|
//# sourceMappingURL=validators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/config/validators.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/config/validators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;AAEnC;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,iBAAiB,CAC5D,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,UAAmC;IAEnC,IAAI,KAA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AAK,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Asset Resolver
|
|
3
3
|
*
|
|
4
|
-
* Unified path resolution for package assets (
|
|
5
|
-
*
|
|
4
|
+
* Unified path resolution for package assets (examples) and user assets.
|
|
5
|
+
* Assets are always siblings to the CLI entry point (in dist/ for production).
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
|
-
* Get the
|
|
8
|
+
* Get the directory containing CLI assets (examples).
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - Test (src): /path/to/packages/cli/src/core/asset-resolver.ts → /path/to/packages/cli
|
|
13
|
-
* - Docker: /cli
|
|
10
|
+
* In production: assets are in dist/ alongside the bundled CLI
|
|
11
|
+
* In development: assets are at package root
|
|
14
12
|
*
|
|
15
|
-
* @returns Absolute path to
|
|
13
|
+
* @returns Absolute path to assets directory
|
|
16
14
|
*/
|
|
17
|
-
export declare function
|
|
15
|
+
export declare function getAssetDir(): string;
|
|
18
16
|
/**
|
|
19
17
|
* Asset type for resolution strategy
|
|
20
18
|
*/
|
|
21
|
-
export type AssetType = '
|
|
19
|
+
export type AssetType = 'config' | 'bundle';
|
|
22
20
|
/**
|
|
23
21
|
* Resolve asset path using unified strategy
|
|
24
22
|
*
|
|
25
23
|
* Resolution rules:
|
|
26
|
-
* 1. Bare names (no / or \) → Package asset
|
|
27
|
-
* - "web.hbs" → ${packageRoot}/templates/web.hbs
|
|
28
|
-
* - "server-collect.json" → ${packageRoot}/examples/server-collect.json
|
|
29
|
-
*
|
|
24
|
+
* 1. Bare names (no / or \) → Package asset (examples)
|
|
30
25
|
* 2. Relative paths (./ or ../) → User asset relative to base directory
|
|
31
|
-
* - "./my-template.hbs" → ${baseDir}/my-template.hbs
|
|
32
|
-
*
|
|
33
26
|
* 3. Absolute paths → Use as-is
|
|
34
27
|
*
|
|
35
28
|
* @param assetPath - Path to resolve
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-resolver.d.ts","sourceRoot":"","sources":["../../src/core/asset-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"asset-resolver.d.ts","sourceRoot":"","sources":["../../src/core/asset-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH;;;;;;;GAOG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAkBpC;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAcR"}
|
|
@@ -1,53 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Asset Resolver
|
|
3
3
|
*
|
|
4
|
-
* Unified path resolution for package assets (
|
|
5
|
-
*
|
|
4
|
+
* Unified path resolution for package assets (examples) and user assets.
|
|
5
|
+
* Assets are always siblings to the CLI entry point (in dist/ for production).
|
|
6
6
|
*/
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
|
+
import { existsSync } from 'fs';
|
|
8
9
|
import path from 'path';
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Cached asset directory to avoid repeated filesystem checks
|
|
12
|
+
*/
|
|
13
|
+
let cachedAssetDir;
|
|
14
|
+
/**
|
|
15
|
+
* Get the directory containing CLI assets (examples).
|
|
11
16
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* - Test (src): /path/to/packages/cli/src/core/asset-resolver.ts → /path/to/packages/cli
|
|
15
|
-
* - Docker: /cli
|
|
17
|
+
* In production: assets are in dist/ alongside the bundled CLI
|
|
18
|
+
* In development: assets are at package root
|
|
16
19
|
*
|
|
17
|
-
* @returns Absolute path to
|
|
20
|
+
* @returns Absolute path to assets directory
|
|
18
21
|
*/
|
|
19
|
-
export function
|
|
22
|
+
export function getAssetDir() {
|
|
23
|
+
if (cachedAssetDir)
|
|
24
|
+
return cachedAssetDir;
|
|
20
25
|
const currentFile = fileURLToPath(import.meta.url);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// Files can be at any depth: dist/index.js or dist/core/asset-resolver.js
|
|
30
|
-
// Find the dist/ directory and go one level up
|
|
31
|
-
// e.g., /path/to/packages/cli/dist/core/asset-resolver.js -> /path/to/packages/cli
|
|
32
|
-
// e.g., /cli/dist/core/asset-resolver.js -> /cli (Docker)
|
|
33
|
-
if (currentFile.includes('/dist/')) {
|
|
34
|
-
const distIndex = currentFile.indexOf('/dist/');
|
|
35
|
-
return currentFile.substring(0, distIndex);
|
|
26
|
+
let dir = path.dirname(currentFile);
|
|
27
|
+
// Walk up until we find a directory with examples/ sibling
|
|
28
|
+
while (dir !== path.dirname(dir)) {
|
|
29
|
+
if (existsSync(path.join(dir, 'examples'))) {
|
|
30
|
+
cachedAssetDir = dir;
|
|
31
|
+
return dir;
|
|
32
|
+
}
|
|
33
|
+
dir = path.dirname(dir);
|
|
36
34
|
}
|
|
37
|
-
// Fallback
|
|
38
|
-
|
|
35
|
+
// Fallback to current file's directory (shouldn't happen if build is correct)
|
|
36
|
+
cachedAssetDir = path.dirname(currentFile);
|
|
37
|
+
return cachedAssetDir;
|
|
39
38
|
}
|
|
40
39
|
/**
|
|
41
40
|
* Resolve asset path using unified strategy
|
|
42
41
|
*
|
|
43
42
|
* Resolution rules:
|
|
44
|
-
* 1. Bare names (no / or \) → Package asset
|
|
45
|
-
* - "web.hbs" → ${packageRoot}/templates/web.hbs
|
|
46
|
-
* - "server-collect.json" → ${packageRoot}/examples/server-collect.json
|
|
47
|
-
*
|
|
43
|
+
* 1. Bare names (no / or \) → Package asset (examples)
|
|
48
44
|
* 2. Relative paths (./ or ../) → User asset relative to base directory
|
|
49
|
-
* - "./my-template.hbs" → ${baseDir}/my-template.hbs
|
|
50
|
-
*
|
|
51
45
|
* 3. Absolute paths → Use as-is
|
|
52
46
|
*
|
|
53
47
|
* @param assetPath - Path to resolve
|
|
@@ -56,21 +50,16 @@ export function getPackageRoot() {
|
|
|
56
50
|
* @returns Absolute path to asset
|
|
57
51
|
*/
|
|
58
52
|
export function resolveAsset(assetPath, assetType, baseDir) {
|
|
59
|
-
|
|
60
|
-
// Bare name → package asset
|
|
53
|
+
// Bare name → package asset (examples directory)
|
|
61
54
|
if (!assetPath.includes('/') && !assetPath.includes('\\')) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
// config or bundle → examples directory
|
|
66
|
-
return path.join(packageRoot, 'examples', assetPath);
|
|
55
|
+
const assetDir = getAssetDir();
|
|
56
|
+
return path.join(assetDir, 'examples', assetPath);
|
|
67
57
|
}
|
|
68
58
|
// Absolute path → use as-is
|
|
69
59
|
if (path.isAbsolute(assetPath)) {
|
|
70
60
|
return assetPath;
|
|
71
61
|
}
|
|
72
62
|
// Relative path → resolve from base directory
|
|
73
|
-
|
|
74
|
-
return path.resolve(resolveBase, assetPath);
|
|
63
|
+
return path.resolve(baseDir || process.cwd(), assetPath);
|
|
75
64
|
}
|
|
76
65
|
//# sourceMappingURL=asset-resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-resolver.js","sourceRoot":"","sources":["../../src/core/asset-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB
|
|
1
|
+
{"version":3,"file":"asset-resolver.js","sourceRoot":"","sources":["../../src/core/asset-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,I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9C,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build artifact cache for flow.json configurations
|
|
3
|
+
*
|
|
4
|
+
* Caches compiled bundles based on configuration content + date.
|
|
5
|
+
* Enables intelligent cache reuse with daily rebuild guarantee.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Get the cache file path for a flow.json configuration
|
|
9
|
+
*/
|
|
10
|
+
export declare function getBuildCachePath(configContent: string, cacheDir?: string): Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Check if a cached build exists for the given configuration
|
|
13
|
+
*/
|
|
14
|
+
export declare function isBuildCached(configContent: string, cacheDir?: string): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Store a build artifact in the cache
|
|
17
|
+
*/
|
|
18
|
+
export declare function cacheBuild(configContent: string, buildOutput: string, cacheDir?: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieve a cached build artifact
|
|
21
|
+
*/
|
|
22
|
+
export declare function getCachedBuild(configContent: string, cacheDir?: string): Promise<string | null>;
|
|
23
|
+
//# sourceMappingURL=build-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-cache.d.ts","sourceRoot":"","sources":["../../src/core/build-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,aAAa,EAAE,MAAM,EACrB,QAAQ,GAAE,MAAwB,GACjC,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,aAAa,EAAE,MAAM,EACrB,QAAQ,GAAE,MAAwB,GACjC,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,QAAQ,GAAE,MAAwB,GACjC,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,aAAa,EAAE,MAAM,EACrB,QAAQ,GAAE,MAAwB,GACjC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build artifact cache for flow.json configurations
|
|
3
|
+
*
|
|
4
|
+
* Caches compiled bundles based on configuration content + date.
|
|
5
|
+
* Enables intelligent cache reuse with daily rebuild guarantee.
|
|
6
|
+
*/
|
|
7
|
+
import fs from 'fs-extra';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { getFlowConfigCacheKey } from './cache-utils';
|
|
10
|
+
const BUILD_CACHE_DIR = path.join('.tmp', 'cache', 'builds');
|
|
11
|
+
/**
|
|
12
|
+
* Get the cache file path for a flow.json configuration
|
|
13
|
+
*/
|
|
14
|
+
export async function getBuildCachePath(configContent, cacheDir = BUILD_CACHE_DIR) {
|
|
15
|
+
const cacheKey = await getFlowConfigCacheKey(configContent);
|
|
16
|
+
return path.join(cacheDir, `${cacheKey}.js`);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Check if a cached build exists for the given configuration
|
|
20
|
+
*/
|
|
21
|
+
export async function isBuildCached(configContent, cacheDir = BUILD_CACHE_DIR) {
|
|
22
|
+
const cachePath = await getBuildCachePath(configContent, cacheDir);
|
|
23
|
+
return fs.pathExists(cachePath);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Store a build artifact in the cache
|
|
27
|
+
*/
|
|
28
|
+
export async function cacheBuild(configContent, buildOutput, cacheDir = BUILD_CACHE_DIR) {
|
|
29
|
+
const cachePath = await getBuildCachePath(configContent, cacheDir);
|
|
30
|
+
await fs.ensureDir(path.dirname(cachePath));
|
|
31
|
+
await fs.writeFile(cachePath, buildOutput, 'utf-8');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Retrieve a cached build artifact
|
|
35
|
+
*/
|
|
36
|
+
export async function getCachedBuild(configContent, cacheDir = BUILD_CACHE_DIR) {
|
|
37
|
+
const cachePath = await getBuildCachePath(configContent, cacheDir);
|
|
38
|
+
if (await fs.pathExists(cachePath)) {
|
|
39
|
+
return await fs.readFile(cachePath, 'utf-8');
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=build-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-cache.js","sourceRoot":"","sources":["../../src/core/build-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,aAAqB,EACrB,WAAmB,eAAe;IAElC,MAAM,QAAQ,GAAG,MAAM,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAC5D,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,QAAQ,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,aAAqB,EACrB,WAAmB,eAAe;IAElC,MAAM,SAAS,GAAG,MAAM,iBAAiB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IACnE,OAAO,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,aAAqB,EACrB,WAAmB,EACnB,WAAmB,eAAe;IAElC,MAAM,SAAS,GAAG,MAAM,iBAAiB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IACnE,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAC5C,MAAM,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,aAAqB,EACrB,WAAmB,eAAe;IAElC,MAAM,SAAS,GAAG,MAAM,iBAAiB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAEnE,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACnC,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache utility functions for hash-based cache keys
|
|
3
|
+
*
|
|
4
|
+
* Implements content-based and date-based cache invalidation for:
|
|
5
|
+
* - NPM package cache (mutable versions include daily date)
|
|
6
|
+
* - Build artifact cache (content + date hashing)
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Check if a version specifier is mutable (can change over time)
|
|
10
|
+
*/
|
|
11
|
+
export declare function isMutableVersion(version: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Get today's date in YYYY-MM-DD format
|
|
14
|
+
*/
|
|
15
|
+
export declare function getTodayDate(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Generate cache key for npm package.
|
|
18
|
+
* Mutable versions include date for daily invalidation.
|
|
19
|
+
* Exact versions are cached indefinitely.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getPackageCacheKey(packageName: string, version: string, date?: string): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Generate cache key for flow.json configuration.
|
|
24
|
+
* Includes date for daily rebuild guarantee.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getFlowConfigCacheKey(content: string, date?: string): Promise<string>;
|
|
27
|
+
//# sourceMappingURL=cache-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-utils.d.ts","sourceRoot":"","sources":["../../src/core/cache-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAQzD;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,CAYjB;AAWD;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,CAKjB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache utility functions for hash-based cache keys
|
|
3
|
+
*
|
|
4
|
+
* Implements content-based and date-based cache invalidation for:
|
|
5
|
+
* - NPM package cache (mutable versions include daily date)
|
|
6
|
+
* - Build artifact cache (content + date hashing)
|
|
7
|
+
*/
|
|
8
|
+
import { getHashServer } from '@walkeros/server-core';
|
|
9
|
+
const HASH_LENGTH = 12;
|
|
10
|
+
/**
|
|
11
|
+
* Check if a version specifier is mutable (can change over time)
|
|
12
|
+
*/
|
|
13
|
+
export function isMutableVersion(version) {
|
|
14
|
+
return (version === 'latest' ||
|
|
15
|
+
version.includes('^') ||
|
|
16
|
+
version.includes('~') ||
|
|
17
|
+
version.includes('*') ||
|
|
18
|
+
version.includes('x'));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get today's date in YYYY-MM-DD format
|
|
22
|
+
*/
|
|
23
|
+
export function getTodayDate() {
|
|
24
|
+
return new Date().toISOString().split('T')[0];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Generate cache key for npm package.
|
|
28
|
+
* Mutable versions include date for daily invalidation.
|
|
29
|
+
* Exact versions are cached indefinitely.
|
|
30
|
+
*/
|
|
31
|
+
export async function getPackageCacheKey(packageName, version, date) {
|
|
32
|
+
const safeName = packageName.replace(/\//g, '-').replace(/@/g, '');
|
|
33
|
+
if (isMutableVersion(version)) {
|
|
34
|
+
const dateStr = date ?? getTodayDate();
|
|
35
|
+
const input = `${safeName}@${version}:${dateStr}`;
|
|
36
|
+
return getHashServer(input, HASH_LENGTH);
|
|
37
|
+
}
|
|
38
|
+
// Exact version - no date component
|
|
39
|
+
const input = `${safeName}@${version}`;
|
|
40
|
+
return getHashServer(input, HASH_LENGTH);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Normalize JSON content for consistent hashing.
|
|
44
|
+
* Handles whitespace and property order variations.
|
|
45
|
+
*/
|
|
46
|
+
function normalizeJson(content) {
|
|
47
|
+
const parsed = JSON.parse(content);
|
|
48
|
+
return JSON.stringify(parsed);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Generate cache key for flow.json configuration.
|
|
52
|
+
* Includes date for daily rebuild guarantee.
|
|
53
|
+
*/
|
|
54
|
+
export async function getFlowConfigCacheKey(content, date) {
|
|
55
|
+
const dateStr = date ?? getTodayDate();
|
|
56
|
+
const normalized = normalizeJson(content);
|
|
57
|
+
const input = `${normalized}:${dateStr}`;
|
|
58
|
+
return getHashServer(input, HASH_LENGTH);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=cache-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-utils.js","sourceRoot":"","sources":["../../src/core/cache-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,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SAAS,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAe,EACf,IAAa;IAEb,MAAM,OAAO,GAAG,IAAI,IAAI,YAAY,EAAE,CAAC;IACvC,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,GAAG,UAAU,IAAI,OAAO,EAAE,CAAC;IACzC,OAAO,aAAa,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../../src/core/docker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../../src/core/docker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAC2C,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAEI,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,YAAY,QAAmB,CAAC;AAE7C;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GAAG,MAAM,EAAE,CASX;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,aAAkB,EAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,EAAE,CAiDV;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,aAAkB,EAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAiCf;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAS1D;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,KAAK,GAAE,MAAyB,GAC/B,OAAO,CAAC,OAAO,CAAC,CASlB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,SAAS,GAAG,OAAO,EACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,OAAO,GAAE;IACP,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,GACL,MAAM,EAAE,CA8DV;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,SAAS,GAAG,OAAO,EACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,OAAO,GAAE;IACP,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CACb,GACL,OAAO,CAAC,IAAI,CAAC,CAuBf"}
|
package/dist/core/docker.js
CHANGED
|
@@ -5,30 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { spawn } from 'child_process';
|
|
7
7
|
import path from 'path';
|
|
8
|
-
import { readFileSync } from 'fs';
|
|
9
|
-
import { fileURLToPath } from 'url';
|
|
10
8
|
import { VERSION as DOCKER_VERSION } from '@walkeros/docker';
|
|
11
9
|
import { isUrl } from '../config/utils.js';
|
|
12
|
-
|
|
13
|
-
// Handle both development (src/) and production (dist/) paths
|
|
14
|
-
function readPackageVersion() {
|
|
15
|
-
// Get the directory of this module (ESM-compatible)
|
|
16
|
-
const moduleFilename = fileURLToPath(import.meta.url);
|
|
17
|
-
const moduleDir = path.dirname(moduleFilename);
|
|
18
|
-
// Try production path first (dist/index.js -> ../package.json)
|
|
19
|
-
const prodPath = path.join(moduleDir, '../package.json');
|
|
20
|
-
try {
|
|
21
|
-
const pkg = JSON.parse(readFileSync(prodPath, 'utf-8'));
|
|
22
|
-
return pkg.version;
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
// Fall back to development path (src/core/docker.ts -> ../../package.json)
|
|
26
|
-
const devPath = path.join(moduleDir, '../../package.json');
|
|
27
|
-
const pkg = JSON.parse(readFileSync(devPath, 'utf-8'));
|
|
28
|
-
return pkg.version;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const CLI_VERSION = readPackageVersion();
|
|
10
|
+
const CLI_VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : '0.0.0';
|
|
32
11
|
/**
|
|
33
12
|
* Docker image for CLI/build tools (bundle, simulate)
|
|
34
13
|
* Uses explicit version by default, can be overridden with env var
|
|
@@ -143,7 +122,9 @@ export async function executeInDocker(command, args, options = {}, configFile) {
|
|
|
143
122
|
resolve();
|
|
144
123
|
}
|
|
145
124
|
else {
|
|
146
|
-
|
|
125
|
+
// Docker already logged the error via stdio inherit
|
|
126
|
+
// Just exit with same code - no duplicate message
|
|
127
|
+
process.exit(code || 1);
|
|
147
128
|
}
|
|
148
129
|
});
|
|
149
130
|
});
|
|
@@ -190,11 +171,15 @@ export function buildDockerRunCommand(mode, flowPath, options = {}) {
|
|
|
190
171
|
const cmd = ['docker', 'run', '--rm'];
|
|
191
172
|
// Set MODE environment variable
|
|
192
173
|
cmd.push('-e', `MODE=${mode}`);
|
|
193
|
-
// Mount
|
|
174
|
+
// Mount entire dist folder for collect mode (includes bundle + shared folders)
|
|
175
|
+
// Must mount to /app/dist (not /app) to preserve container's node_modules
|
|
176
|
+
// This allows relative paths like ./shared/credentials/sa.json to work
|
|
194
177
|
if (mode === 'collect' && flowPath) {
|
|
195
178
|
const absoluteFlowPath = path.resolve(cwd, flowPath);
|
|
196
|
-
|
|
197
|
-
|
|
179
|
+
const flowDir = path.dirname(absoluteFlowPath);
|
|
180
|
+
const flowFile = path.basename(absoluteFlowPath);
|
|
181
|
+
cmd.push('-v', `${flowDir}:/app/dist:ro`);
|
|
182
|
+
cmd.push('-e', `FLOW=/app/dist/${flowFile}`);
|
|
198
183
|
}
|
|
199
184
|
// Mount custom file for serve mode
|
|
200
185
|
if (mode === 'serve' && flowPath) {
|
|
@@ -258,7 +243,9 @@ export async function executeRunInDocker(mode, flowPath, options = {}) {
|
|
|
258
243
|
resolve();
|
|
259
244
|
}
|
|
260
245
|
else {
|
|
261
|
-
|
|
246
|
+
// Docker already logged the error via stdio inherit
|
|
247
|
+
// Just exit with same code - no duplicate message
|
|
248
|
+
process.exit(code || 1);
|
|
262
249
|
}
|
|
263
250
|
});
|
|
264
251
|
});
|