@tdk-landscape/tdk-cli-core 1.3.15 → 1.3.26
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/Tiltfile +144 -0
- package/discovery/AGENTS.md +362 -0
- package/discovery/TILT_DISCOVERY.star +424 -0
- package/discovery/Tiltfile +58 -0
- package/discovery/config.star +258 -0
- package/discovery/constants.star +127 -0
- package/discovery/deterministic.star +211 -0
- package/discovery/discovery_daemon.star +191 -0
- package/discovery/discovery_orchestrator.star +460 -0
- package/discovery/filtering.star +5 -0
- package/discovery/identity-management-backend/service.yaml +26 -0
- package/discovery/identity-management-frontend/service.yaml +29 -0
- package/discovery/identity-sdk/service.yaml +9 -0
- package/discovery/incremental_discovery.star +213 -0
- package/discovery/indexing.star +7 -0
- package/discovery/json_manifest_scanner.star +51 -0
- package/discovery/libraries.star +46 -0
- package/discovery/loading.star +23 -0
- package/discovery/manifest/constants.star +104 -0
- package/discovery/manifest/loading.star +386 -0
- package/discovery/manifest/normalize.star +281 -0
- package/discovery/manifest/validation.star +108 -0
- package/discovery/normalization.star +11 -0
- package/discovery/registry.star +544 -0
- package/discovery/resource_snapshot.py +382 -0
- package/discovery/resource_snapshot.star +143 -0
- package/discovery/schemas.star +1 -0
- package/discovery/services/platform/cdc/debezium/nats-connector/service.yaml +9 -0
- package/discovery/services/platform/cdc/nats-http-bridge/service.yaml +9 -0
- package/discovery/services/platform/orchestrator/orchestrator-glue-backend/service.yaml +26 -0
- package/discovery/services/platform/synthetic-monitor/service.yaml +9 -0
- package/discovery/test_resource_snapshot.py +251 -0
- package/discovery/validation.star +78 -0
- package/discovery/versioning.star +1 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +11 -0
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +1 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/project.d.ts.map +1 -1
- package/dist/commands/project.js +36 -41
- package/dist/commands/project.js.map +1 -1
- package/dist/commands/resource.d.ts.map +1 -1
- package/dist/commands/resource.js +51 -55
- package/dist/commands/resource.js.map +1 -1
- package/dist/commands/stack.d.ts.map +1 -1
- package/dist/commands/stack.js +22 -24
- package/dist/commands/stack.js.map +1 -1
- package/dist/commands/ui.d.ts.map +1 -1
- package/dist/commands/ui.js +1 -2
- package/dist/commands/ui.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +1 -2
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/upgrade.d.ts +8 -0
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +59 -18
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/generator/extension-fetch.d.ts +19 -0
- package/dist/generator/extension-fetch.d.ts.map +1 -1
- package/dist/generator/extension-fetch.js +71 -5
- package/dist/generator/extension-fetch.js.map +1 -1
- package/dist/generator/template-engine.d.ts +1 -0
- package/dist/generator/template-engine.d.ts.map +1 -1
- package/dist/generator/template-engine.js +50 -6
- package/dist/generator/template-engine.js.map +1 -1
- package/dist/utils/command-helpers.d.ts.map +1 -1
- package/dist/utils/command-helpers.js +7 -9
- package/dist/utils/command-helpers.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +1 -0
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/errors.d.ts +2 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +6 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/project-features.d.ts.map +1 -1
- package/dist/utils/project-features.js +1 -1
- package/dist/utils/project-features.js.map +1 -1
- package/dist/utils/resource-features.d.ts.map +1 -1
- package/dist/utils/resource-features.js +2 -2
- package/dist/utils/resource-features.js.map +1 -1
- package/dist/utils/tar.js +4 -4
- package/dist/utils/tar.js.map +1 -1
- package/dist/utils/validation.d.ts +7 -0
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +9 -0
- package/dist/utils/validation.js.map +1 -1
- package/engine/AGENTS.md +705 -0
- package/engine/README.md +29 -0
- package/engine/REFACTORING_MANIFEST_SYSTEM.md +974 -0
- package/engine/Tiltfile +80 -0
- package/engine/assets/docker/golden-layers.Dockerfile +221 -0
- package/engine/assets/scripts/cleanup-completed-migrator-images.sh +37 -0
- package/engine/assets/scripts/cleanup-tilt-images.sh +120 -0
- package/engine/assets/scripts/mac-m1-resource-monitor.sh +121 -0
- package/engine/config.star +3 -0
- package/engine/docs/AUTODISCOVERY_TEST.md +182 -0
- package/engine/docs/C4-ARCHITECTURE-operations.md +396 -0
- package/engine/docs/C4-ARCHITECTURE-overview.md +284 -0
- package/engine/docs/C4-ARCHITECTURE.md +17 -0
- package/engine/docs/GOLDEN_IMAGE_INTEGRATION.md +349 -0
- package/engine/docs/MANIFEST_DRIVEN_ARCHITECTURE.md +357 -0
- package/engine/docs/README.md +284 -0
- package/engine/entrypoint.star +97 -0
- package/engine/lifecycle/orchestrator.star +260 -0
- package/engine/paths.star +717 -0
- package/engine/schemas/manifest-schema.json +301 -0
- package/engine/schemas/service-schema.json +301 -0
- package/engine/scripts/README.md +89 -0
- package/engine/scripts/build-and-publish-lib.sh +205 -0
- package/engine/scripts/check-lib-publish.sh +85 -0
- package/engine/scripts/debug-container.sh +258 -0
- package/engine/scripts/generate-manifest.sh +197 -0
- package/engine/spec.master +702 -0
- package/engine/spec.master.example +341 -0
- package/engine/topologies/README.md +34 -0
- package/engine/topologies/platform/docker/AGENTS.md +59 -0
- package/engine/topologies/platform/docker/auth/auth.star +167 -0
- package/engine/topologies/platform/docker/build/golden_image.star +37 -0
- package/engine/topologies/platform/docker/build/golden_image_build.star +82 -0
- package/engine/topologies/platform/docker/build/golden_image_constants.star +93 -0
- package/engine/topologies/platform/docker/build/golden_image_dockerfile.star +291 -0
- package/engine/topologies/platform/docker/compose/compose.star +636 -0
- package/engine/topologies/platform/docker/compose/compose_helpers.star +52 -0
- package/engine/topologies/platform/docker/compose/traefik_standalone.star +53 -0
- package/engine/topologies/platform/docker/config/bunignore.star +142 -0
- package/engine/topologies/platform/docker/config/dockerignore.star +150 -0
- package/engine/topologies/platform/docker/constants.star +170 -0
- package/engine/topologies/platform/docker/dockerfile/dockerfile.star +54 -0
- package/engine/topologies/platform/docker/generators/golden_docker_generator_v2.star +73 -0
- package/engine/topologies/platform/docker/index.star +27 -0
- package/engine/topologies/platform/docker/layers/bun_helpers.star +23 -0
- package/engine/topologies/platform/docker/layers/infisical/index.star +40 -0
- package/engine/topologies/platform/docker/layers/infisical/infisical_docker.star +262 -0
- package/engine/topologies/platform/docker/layers/l1_base_layers.star +87 -0
- package/engine/topologies/platform/docker/layers/l2_dependency_layers.star +125 -0
- package/engine/topologies/platform/docker/layers/l3_builder_layers.star +209 -0
- package/engine/topologies/platform/docker/layers/l4_runtime_layers.star +214 -0
- package/engine/topologies/platform/docker/layers/prisma/constants.star +135 -0
- package/engine/topologies/platform/docker/layers/prisma/db_readiness.star +96 -0
- package/engine/topologies/platform/docker/layers/prisma/filesystem_setup.star +109 -0
- package/engine/topologies/platform/docker/layers/prisma/migrate_script.star +98 -0
- package/engine/topologies/platform/docker/layers/prisma/prisma_build.star +126 -0
- package/engine/topologies/platform/docker/layers/prisma/prisma_runtime.star +161 -0
- package/engine/topologies/platform/docker/layers/prisma/secret_resolution.star +119 -0
- package/engine/topologies/platform/docker/networking/api_path_constants.star +230 -0
- package/engine/topologies/platform/docker/networking/sablier_container_cycle.star +27 -0
- package/engine/topologies/platform/docker/networking/traefik.star +232 -0
- package/engine/topologies/platform/docker/networking/traefik_constants.star +146 -0
- package/engine/topologies/platform/docker/networking/traefik_helpers.star +160 -0
- package/engine/topologies/platform/docker/secrets/infisical.star +135 -0
- package/engine/topologies/platform/net/proxy.star +4 -0
- package/engine/topologies/platform/registries/local.star +4 -0
- package/engine/topologies/platform/security/secrets.star +239 -0
- package/engine/topologies/platform/state/relational.star +4 -0
- package/engine/topologies/tilt/common/AGENTS.md +59 -0
- package/engine/topologies/tilt/common/utils.star +364 -0
- package/engine/topologies/tilt/common/utils_debug.star +69 -0
- package/engine/topologies/tilt/common/utils_deterministic.star +168 -0
- package/engine/topologies/tilt/common/utils_docker_networks.star +46 -0
- package/engine/topologies/tilt/common/utils_env.star +43 -0
- package/engine/topologies/tilt/common/utils_output.star +97 -0
- package/engine/topologies/tilt/config/AGENTS.md +68 -0
- package/engine/topologies/tilt/config/defaults.star +3 -0
- package/engine/topologies/tilt/config/feature_flags.star +10 -0
- package/engine/topologies/tilt/config/global.star +55 -0
- package/engine/topologies/tilt/config/profiles.star +382 -0
- package/engine/topologies/tilt/generators/agents_md.star +62 -0
- package/engine/topologies/tilt/generators/api_gateway.star +145 -0
- package/engine/topologies/tilt/generators/index.star +124 -0
- package/engine/topologies/tilt/generators/infisical/README.md +424 -0
- package/engine/topologies/tilt/generators/infisical/examples.star +312 -0
- package/engine/topologies/tilt/generators/infisical/index.star +57 -0
- package/engine/topologies/tilt/generators/infisical/machine_identity.star +420 -0
- package/engine/topologies/tilt/generators/infisical/organization.star +534 -0
- package/engine/topologies/tilt/generators/infisical/path_manager.star +476 -0
- package/engine/topologies/tilt/generators/infisical/secrets_generator.star +420 -0
- package/engine/topologies/tilt/generators/nginx_conf.star +143 -0
- package/engine/topologies/tilt/generators/npmrc.star +111 -0
- package/engine/topologies/tilt/generators/tsconfig.star +23 -0
- package/engine/topologies/tilt/generators/typescript/backend_library_tsconfig.star +71 -0
- package/engine/topologies/tilt/generators/typescript/backend_tsconfig.star +124 -0
- package/engine/topologies/tilt/generators/typescript/common.star +7 -0
- package/engine/topologies/tilt/generators/typescript/frontend_library_tsconfig.star +76 -0
- package/engine/topologies/tilt/generators/typescript/frontend_tsconfig.star +110 -0
- package/engine/topologies/tilt/generators/typescript/include.star +23 -0
- package/engine/topologies/tilt/generators/typescript/playwright_config.star +40 -0
- package/engine/topologies/tilt/generators/typescript/prisma_config.star +49 -0
- package/engine/topologies/tilt/generators/validators.star +853 -0
- package/engine/topologies/tilt/generators/vite/backend.star +78 -0
- package/engine/topologies/tilt/generators/vite/frontend.star +98 -0
- package/engine/topologies/tilt/generators/vite/generators.star +43 -0
- package/engine/topologies/tilt/generators/vite/helpers.star +244 -0
- package/engine/topologies/tilt/generators/vite/library.star +65 -0
- package/engine/topologies/tilt/generators/vite/sdk.star +73 -0
- package/engine/topologies/tilt/generators/vite/templates.star +737 -0
- package/engine/topologies/tilt/generators/vite_config.star +22 -0
- package/engine/topologies/tilt/manifest/AGENTS.md +61 -0
- package/engine/topologies/tilt/manifest/README.md +693 -0
- package/engine/topologies/tilt/manifest/__init__.star +218 -0
- package/engine/topologies/tilt/manifest/constants.star +252 -0
- package/engine/topologies/tilt/manifest/errors.star +266 -0
- package/engine/topologies/tilt/manifest/integration.star +339 -0
- package/engine/topologies/tilt/manifest/json_to_yaml.py +54 -0
- package/engine/topologies/tilt/manifest/loader.star +214 -0
- package/engine/topologies/tilt/manifest/mapper.star +227 -0
- package/engine/topologies/tilt/manifest/parser.star +400 -0
- package/engine/topologies/tilt/manifest/schema.star +462 -0
- package/engine/topologies/tilt/manifest/tests/test_integration.star +276 -0
- package/engine/topologies/tilt/manifest/tests/test_loader_parser.star +397 -0
- package/engine/topologies/tilt/manifest/tests/test_manifest.star +316 -0
- package/engine/topologies/tilt/manifest/tests/test_validator.star +470 -0
- package/engine/topologies/tilt/manifest/validator.star +717 -0
- package/engine/topologies/tilt/manifest/yaml_to_json.py +18 -0
- package/engine/topologies/tilt/resources/AGENTS.md +71 -0
- package/engine/topologies/tilt/resources/conditions.star +3 -0
- package/engine/topologies/tilt/resources/databases.star +244 -0
- package/engine/topologies/tilt/resources/declaration.star +3 -0
- package/engine/topologies/tilt/resources/deps.star +3 -0
- package/engine/topologies/tilt/resources/infra-loader.star +437 -0
- package/engine/topologies/tilt/resources/libs.star +30 -0
- package/engine/topologies/tilt/resources/libs_discovery.star +102 -0
- package/engine/topologies/tilt/resources/libs_paths.star +79 -0
- package/engine/topologies/tilt/resources/libs_resource_definition.star +151 -0
- package/engine/topologies/tilt/resources/libs_setup.star +164 -0
- package/engine/topologies/tilt/resources/libs_tsconfig.star +37 -0
- package/engine/topologies/tilt/resources/orchestrator/apply.star +77 -0
- package/engine/topologies/tilt/resources/orchestrator/apply_compose_resource_registration.star +431 -0
- package/engine/topologies/tilt/resources/orchestrator/apply_manifest_orchestration.star +81 -0
- package/engine/topologies/tilt/resources/orchestrator/apply_migrator_orchestration.star +148 -0
- package/engine/topologies/tilt/resources/orchestrator/apply_resource_validation.star +36 -0
- package/engine/topologies/tilt/resources/orchestrator/apply_runtime_flags.star +44 -0
- package/engine/topologies/tilt/resources/orchestrator/builders/typescript.star +164 -0
- package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/AGENTS.md +75 -0
- package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/index.star +21 -0
- package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/resolver.star +134 -0
- package/engine/topologies/tilt/resources/orchestrator/generators/env.star +258 -0
- package/engine/topologies/tilt/resources/orchestrator/generators/frontend.star +169 -0
- package/engine/topologies/tilt/resources/orchestrator/generators/manifest_resource.star +524 -0
- package/engine/topologies/tilt/resources/orchestrator/helpers.star +33 -0
- package/engine/topologies/tilt/resources/orchestrator.star +54 -0
- package/engine/topologies/tilt/resources/ordering.star +3 -0
- package/engine/topologies/tilt/resources/triggers.star +3 -0
- package/engine/topologies/tilt/resources/watchers.star +299 -0
- package/engine/where-things-live.star +717 -0
- package/ext/Tiltfile +66 -0
- package/ext/ide-components/README.md +219 -0
- package/ext/ide-components/code_executor/server.py +268 -0
- package/ext/ide-components/code_viewer/server.py +206 -0
- package/ext/ide-components/config_inspector/server.py +1050 -0
- package/ext/ide-components/file_browser/server.py +285 -0
- package/ext/ide-components/shared/config_service.py +469 -0
- package/ext/ide-components/shared/file_utils.py +298 -0
- package/ext/ide-components/shared/http_utils.py +232 -0
- package/ext/ide-components/shared/static/styles.css +1334 -0
- package/ext/ide-components/shared/syntax_highlighter.py +140 -0
- package/ext/ide-components/shared/template_engine.py +123 -0
- package/ext/ide-components/shared/templates/base.html +121 -0
- package/ext/ide-components/shared/test_config_service.py +326 -0
- package/ext/ide-components/shared/tilt_integration.py +158 -0
- package/ext/ui-enhancements/cron-status-server.sh +49 -0
- package/ext/ui-enhancements/cron-status-tracker.sh +146 -0
- package/ext/ui-enhancements/extension.yaml +36 -0
- package/ext/ui-enhancements/tiltfile.py +99 -0
- package/ext/ui-enhancements/ui/cron-jobs-tab.css +396 -0
- package/ext/ui-enhancements/ui/help-panel.css +279 -0
- package/ext/ui-enhancements/ui/icons.css +125 -0
- package/ext/ui-enhancements/ui/tooltips.css +114 -0
- package/package.json +13 -9
- package/specs/specs/TILT_SERVICE_DEFAULTS.star +205 -0
- package/specs/specs/TILT_TECH_STACK.star +159 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# ⚡ TILT SDK - VITE BACKEND GENERATOR
|
|
3
|
+
|
|
4
|
+
# === INLINED CONSTANTS for pure extension loading ===
|
|
5
|
+
BASE_PORT_BACKEND = 4000
|
|
6
|
+
OUTPUT = struct(AUTOGENERATED_FOLDER = ".autogenerated")
|
|
7
|
+
# === END INLINED CONSTANTS ===
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
load('../../../../topologies/tilt/manifest/constants.star', 'GENERATED_CONFIG_FILENAMES')
|
|
11
|
+
# =============================================================================
|
|
12
|
+
# Path: .tilt/providers/vite/backend.star
|
|
13
|
+
# Purpose: Vite config generator for Backend services
|
|
14
|
+
# =============================================================================
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
load('./templates.star', 'TEMPLATE_VITE_BACKEND_WITH_NODE', 'TEMPLATE_VITE_BACKEND_VITEST_ONLY')
|
|
18
|
+
load('./helpers.star',
|
|
19
|
+
'build_header',
|
|
20
|
+
'generate_backend_path_aliases',
|
|
21
|
+
'generate_externals_config',
|
|
22
|
+
'generate_vitest_inline_deps'
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
# Constants for output paths
|
|
26
|
+
VITE_BACKEND_CONFIG_PATH = '/' + OUTPUT.AUTOGENERATED_FOLDER + '/' + GENERATED_CONFIG_FILENAMES['vite_backend']
|
|
27
|
+
|
|
28
|
+
def generate_backend(manifest, write_fn=None):
|
|
29
|
+
"""
|
|
30
|
+
Generate vite.config.ts for BACKEND services.
|
|
31
|
+
|
|
32
|
+
Why backends use Vite:
|
|
33
|
+
1. Vitest: Fastest test runner for TypeScript
|
|
34
|
+
2. vite-plugin-node: Instant HMR for Node.js (no restart) - OPTIONAL
|
|
35
|
+
3. Fast TypeScript transpilation via SWC/esbuild
|
|
36
|
+
4. Unified config with frontend teams
|
|
37
|
+
"""
|
|
38
|
+
app_type = manifest.get('appType', 'backend')
|
|
39
|
+
if app_type not in ['backend', 'migrator']:
|
|
40
|
+
fail("Vite.backend() requires a backend manifest, got: " + app_type)
|
|
41
|
+
|
|
42
|
+
resource_path = manifest.get('_resource_path', '')
|
|
43
|
+
app_name = manifest.get('appName', 'unknown')
|
|
44
|
+
port = manifest.get('port', BASE_PORT_BACKEND)
|
|
45
|
+
|
|
46
|
+
# 🔥 SMART DETECTION: Check if service uses vite-plugin-node for HMR
|
|
47
|
+
use_vite_node = manifest.get('useViteNode', False)
|
|
48
|
+
features = manifest.get('features', [])
|
|
49
|
+
if 'vite-node' in features or 'vite-plugin-node' in features or 'hmr' in features:
|
|
50
|
+
use_vite_node = True
|
|
51
|
+
|
|
52
|
+
entry_point = manifest.get('entryPoint', './src/index.ts')
|
|
53
|
+
path_aliases = generate_backend_path_aliases(resource_path, manifest)
|
|
54
|
+
vitest_inline_deps = generate_vitest_inline_deps(manifest)
|
|
55
|
+
|
|
56
|
+
if use_vite_node:
|
|
57
|
+
header = build_header('Vite.backend()', app_name, 'Backend (SSR + HMR + Vitest)')
|
|
58
|
+
externals_config = generate_externals_config(manifest)
|
|
59
|
+
config = TEMPLATE_VITE_BACKEND_WITH_NODE.format(
|
|
60
|
+
header=header,
|
|
61
|
+
entry_point=entry_point,
|
|
62
|
+
port=port,
|
|
63
|
+
path_aliases=path_aliases,
|
|
64
|
+
externals_config=externals_config,
|
|
65
|
+
vitest_inline_deps=vitest_inline_deps,
|
|
66
|
+
)
|
|
67
|
+
else:
|
|
68
|
+
header = build_header('Vite.backend()', app_name, 'Backend (Vitest)')
|
|
69
|
+
config = TEMPLATE_VITE_BACKEND_VITEST_ONLY.format(
|
|
70
|
+
header=header,
|
|
71
|
+
path_aliases=path_aliases,
|
|
72
|
+
vitest_inline_deps=vitest_inline_deps,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
if write_fn:
|
|
76
|
+
write_fn(resource_path + VITE_BACKEND_CONFIG_PATH, config)
|
|
77
|
+
|
|
78
|
+
return config
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# ⚡ TILT SDK - VITE FRONTEND GENERATOR
|
|
3
|
+
|
|
4
|
+
# === INLINED CONSTANTS for pure extension loading ===
|
|
5
|
+
BASE_PORT_FRONTEND = 3000
|
|
6
|
+
BASE_PORT_BACKEND = 4000
|
|
7
|
+
OUTPUT = struct(AUTOGENERATED_FOLDER = ".autogenerated")
|
|
8
|
+
# === END INLINED CONSTANTS ===
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
load('../../../../topologies/tilt/manifest/constants.star', 'GENERATED_CONFIG_FILENAMES')
|
|
12
|
+
# =============================================================================
|
|
13
|
+
# Path: .tilt/providers/vite/frontend.star
|
|
14
|
+
# Purpose: Vite config generator for Frontend services
|
|
15
|
+
# =============================================================================
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
load('./templates.star', 'TEMPLATE_VITE_FRONTEND', 'TEMPLATE_VITE_FRONTEND_BUILD')
|
|
19
|
+
load('./helpers.star',
|
|
20
|
+
'build_header',
|
|
21
|
+
'generate_frontend_internal_aliases',
|
|
22
|
+
'generate_frontend_optimize_deps',
|
|
23
|
+
'generate_proxy_block'
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
# Constants for output paths
|
|
27
|
+
VITE_FRONTEND_CONFIG_PATH = '/' + OUTPUT.AUTOGENERATED_FOLDER + '/' + GENERATED_CONFIG_FILENAMES['vite_frontend']
|
|
28
|
+
VITE_FRONTEND_BUILD_CONFIG_PATH = '/' + OUTPUT.AUTOGENERATED_FOLDER + '/' + GENERATED_CONFIG_FILENAMES['vite_build']
|
|
29
|
+
|
|
30
|
+
def _normalize_vite_base_path(base_path):
|
|
31
|
+
"""Vite subpath deploys are more reliable with a trailing slash."""
|
|
32
|
+
if not base_path:
|
|
33
|
+
return '/'
|
|
34
|
+
if not base_path.startswith('/'):
|
|
35
|
+
base_path = '/' + base_path
|
|
36
|
+
if base_path != '/' and not base_path.endswith('/'):
|
|
37
|
+
base_path = base_path + '/'
|
|
38
|
+
return base_path
|
|
39
|
+
|
|
40
|
+
def generate_frontend(manifest, backend_manifest=None, write_fn=None):
|
|
41
|
+
"""
|
|
42
|
+
Generate vite.config.ts for FRONTEND services.
|
|
43
|
+
|
|
44
|
+
Features:
|
|
45
|
+
- Auto-proxy to backend based on backend manifest port
|
|
46
|
+
- HMR configuration with correct ports
|
|
47
|
+
- Base path configuration
|
|
48
|
+
- TypeScript path aliases
|
|
49
|
+
- 🔥 Auto-generated internal dependency aliases from package.json
|
|
50
|
+
- 🔥 optimizeDeps.include for faster dev startup
|
|
51
|
+
"""
|
|
52
|
+
if manifest.get('appType') != 'frontend':
|
|
53
|
+
fail("Vite.frontend() requires a frontend manifest, got: " + manifest.get('appType', 'unknown'))
|
|
54
|
+
|
|
55
|
+
resource_path = manifest.get('_resource_path', '')
|
|
56
|
+
stack = manifest.get('stack', 'app')
|
|
57
|
+
port = manifest.get('port', BASE_PORT_FRONTEND)
|
|
58
|
+
hmr_port = port + 1000 # HMR port is always port + 1000
|
|
59
|
+
base_path = manifest.get('basePath', '/' + stack + 's')
|
|
60
|
+
vite_base_path = _normalize_vite_base_path(base_path)
|
|
61
|
+
app_name = manifest.get('appName', 'unknown')
|
|
62
|
+
|
|
63
|
+
backend_port = BASE_PORT_BACKEND
|
|
64
|
+
if backend_manifest:
|
|
65
|
+
backend_port = backend_manifest.get('port', BASE_PORT_BACKEND)
|
|
66
|
+
|
|
67
|
+
# Use traefik pathPrefix for API base path (modern pattern)
|
|
68
|
+
traefik_config = manifest.get('traefik', {})
|
|
69
|
+
api_base_path = traefik_config.get('pathPrefix', '/api')
|
|
70
|
+
|
|
71
|
+
proxy_config = generate_proxy_block(api_base_path, backend_port, [], stack)
|
|
72
|
+
header = build_header('Vite.frontend()', app_name)
|
|
73
|
+
# Config is written under .autogenerated/, so aliases need one extra ".." level.
|
|
74
|
+
internal_aliases = generate_frontend_internal_aliases(resource_path, manifest, 1)
|
|
75
|
+
optimize_deps_include = generate_frontend_optimize_deps(manifest)
|
|
76
|
+
|
|
77
|
+
config = TEMPLATE_VITE_FRONTEND.format(
|
|
78
|
+
header=header,
|
|
79
|
+
base_path=vite_base_path,
|
|
80
|
+
port=port,
|
|
81
|
+
hmr_port=hmr_port,
|
|
82
|
+
proxy_config=proxy_config,
|
|
83
|
+
internal_aliases=internal_aliases,
|
|
84
|
+
optimize_deps_include=optimize_deps_include,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
build_cfg_header = build_header('Vite.frontend()', app_name, 'Build-only Vite config')
|
|
88
|
+
build_config = TEMPLATE_VITE_FRONTEND_BUILD.format(
|
|
89
|
+
header=build_cfg_header,
|
|
90
|
+
base_path=vite_base_path,
|
|
91
|
+
optimize_deps_include=optimize_deps_include,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
if write_fn:
|
|
95
|
+
write_fn(resource_path + VITE_FRONTEND_CONFIG_PATH, config)
|
|
96
|
+
write_fn(resource_path + VITE_FRONTEND_BUILD_CONFIG_PATH, build_config)
|
|
97
|
+
|
|
98
|
+
return config
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# ⚡ TILT SDK - VITE PROVIDER GENERATORS
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Path: .tilt/providers/vite/generators.star
|
|
5
|
+
# Purpose: Vite config generators dispatcher
|
|
6
|
+
# =============================================================================
|
|
7
|
+
|
|
8
|
+
load('./frontend.star', _generate_frontend = 'generate_frontend')
|
|
9
|
+
load('./backend.star', _generate_backend = 'generate_backend')
|
|
10
|
+
load('./library.star', _generate_library = 'generate_library')
|
|
11
|
+
load('./sdk.star', _generate_sdk = 'generate_sdk')
|
|
12
|
+
|
|
13
|
+
generate_frontend = _generate_frontend
|
|
14
|
+
generate_backend = _generate_backend
|
|
15
|
+
generate_library = _generate_library
|
|
16
|
+
generate_sdk = _generate_sdk
|
|
17
|
+
|
|
18
|
+
def generate_for_manifest(manifest, backend_manifest=None, write_fn=None):
|
|
19
|
+
"""
|
|
20
|
+
Universal dispatcher that generates the appropriate vite.config.ts
|
|
21
|
+
based on manifest appType.
|
|
22
|
+
|
|
23
|
+
This is the main entry point that Tilt should call for ALL services.
|
|
24
|
+
"""
|
|
25
|
+
app_type = manifest.get('appType', 'backend')
|
|
26
|
+
needs_vite = manifest.get('needsVite', True)
|
|
27
|
+
|
|
28
|
+
if not needs_vite:
|
|
29
|
+
return None
|
|
30
|
+
|
|
31
|
+
if app_type == 'frontend':
|
|
32
|
+
return generate_frontend(manifest, backend_manifest, write_fn)
|
|
33
|
+
elif app_type == 'backend':
|
|
34
|
+
return generate_backend(manifest, write_fn)
|
|
35
|
+
elif app_type == 'library':
|
|
36
|
+
return generate_library(manifest, write_fn)
|
|
37
|
+
elif app_type == 'sdk':
|
|
38
|
+
return generate_sdk(manifest, write_fn)
|
|
39
|
+
elif app_type == 'migrator':
|
|
40
|
+
return generate_backend(manifest, write_fn)
|
|
41
|
+
else:
|
|
42
|
+
print(" ⚠️ Unknown appType '" + app_type + "' for Vite config generation")
|
|
43
|
+
return None
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# ⚡ TILT SDK - VITE PROVIDER HELPERS
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Path: .tilt/providers/vite/helpers.star
|
|
5
|
+
# Purpose: Shared helper functions for Vite generators
|
|
6
|
+
# =============================================================================
|
|
7
|
+
|
|
8
|
+
load('../../../../topologies/tilt/common/utils.star', 'Utils')
|
|
9
|
+
|
|
10
|
+
# Load npm scope from project.json (or use project name as default)
|
|
11
|
+
# Use TDK_PROJECT_ROOT env var set by Tilt, fallback to current directory
|
|
12
|
+
def _load_npm_scope():
|
|
13
|
+
project_root = os.environ.get('TDK_PROJECT_ROOT', '')
|
|
14
|
+
project_json_path = '.tdk/project.json'
|
|
15
|
+
if project_root:
|
|
16
|
+
project_json_path = project_root + '/' + project_json_path
|
|
17
|
+
|
|
18
|
+
if os.path.exists(project_json_path):
|
|
19
|
+
_project_json = read_json(project_json_path)
|
|
20
|
+
return _project_json.get('project', {}).get('name', 'tdk-project')
|
|
21
|
+
return 'tdk-project'
|
|
22
|
+
|
|
23
|
+
_NPM_SCOPE = _load_npm_scope()
|
|
24
|
+
# =============================================================================
|
|
25
|
+
# API PATH CONSTANTS - Import for full descriptive API naming
|
|
26
|
+
# =============================================================================
|
|
27
|
+
load('../../../../topologies/platform/docker/networking/api_path_constants.star',
|
|
28
|
+
'get_api_path_for_stack',
|
|
29
|
+
'build_traefik_url')
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def build_header(generator_fn, app_name, extra_header=''):
|
|
33
|
+
"""Build the standard file header using shared utility."""
|
|
34
|
+
return Utils.get_template_header(
|
|
35
|
+
'vite',
|
|
36
|
+
'Vite.' + generator_fn,
|
|
37
|
+
app_name,
|
|
38
|
+
extra_header
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def generate_frontend_internal_aliases(resource_path, manifest, config_depth_offset=0):
|
|
43
|
+
"""
|
|
44
|
+
Generate internal package aliases for frontend Vite config.
|
|
45
|
+
|
|
46
|
+
Convention over Configuration:
|
|
47
|
+
@{npm_scope}/platform-x → {rel_to_root}shared-platform-engineering/platform-x/src
|
|
48
|
+
@{npm_scope}/product-x → {rel_to_root}shared-product-engineering/product-x/src
|
|
49
|
+
"""
|
|
50
|
+
internal_deps = manifest.get('_internalDeps', [])
|
|
51
|
+
|
|
52
|
+
if not internal_deps:
|
|
53
|
+
return ' // No internal dependencies detected'
|
|
54
|
+
|
|
55
|
+
# Calculate depth for relative paths (Starlark-compatible)
|
|
56
|
+
resource_parts = []
|
|
57
|
+
for p in resource_path.split('/'):
|
|
58
|
+
if p:
|
|
59
|
+
resource_parts.append(p)
|
|
60
|
+
depth = len(resource_parts) + config_depth_offset
|
|
61
|
+
rel_to_root = '../' * depth
|
|
62
|
+
|
|
63
|
+
lines = [' // 🔥 Auto-generated internal package aliases (from package.json)']
|
|
64
|
+
|
|
65
|
+
for dep in sorted(internal_deps):
|
|
66
|
+
if dep.startswith('@' + _NPM_SCOPE + '/'):
|
|
67
|
+
lib_name = dep.replace('@' + _NPM_SCOPE + '/', '')
|
|
68
|
+
|
|
69
|
+
# Determine library root by naming convention
|
|
70
|
+
if lib_name.startswith('platform-'):
|
|
71
|
+
lib_path = rel_to_root + 'shared-platform-engineering/' + lib_name + '/dist'
|
|
72
|
+
elif lib_name.startswith('product-'):
|
|
73
|
+
lib_path = rel_to_root + 'shared-product-engineering/' + lib_name + '/dist'
|
|
74
|
+
elif lib_name in ['domain', 'application', 'infrastructure', 'presentation']:
|
|
75
|
+
lib_path = rel_to_root + 'shared-ddd-layers/' + lib_name + '/src'
|
|
76
|
+
else:
|
|
77
|
+
lib_path = rel_to_root + 'shared-platform-engineering/' + lib_name + '/src'
|
|
78
|
+
|
|
79
|
+
lines.append(" '" + dep + "': resolve(__dirname, '" + lib_path + "'),")
|
|
80
|
+
|
|
81
|
+
return '\n'.join(lines)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def generate_frontend_optimize_deps(manifest):
|
|
85
|
+
"""Generate optimizeDeps.include array for faster Vite dev startup."""
|
|
86
|
+
internal_deps = manifest.get('_internalDeps', [])
|
|
87
|
+
|
|
88
|
+
if not internal_deps:
|
|
89
|
+
return ''
|
|
90
|
+
|
|
91
|
+
# Filter optimize deps (Starlark-compatible)
|
|
92
|
+
optimize_deps = []
|
|
93
|
+
for dep in internal_deps:
|
|
94
|
+
if dep.startswith('@' + _NPM_SCOPE + '/'):
|
|
95
|
+
optimize_deps.append(dep)
|
|
96
|
+
|
|
97
|
+
if not optimize_deps:
|
|
98
|
+
return ''
|
|
99
|
+
|
|
100
|
+
# Build quoted deps list (Starlark-compatible)
|
|
101
|
+
quoted_deps = []
|
|
102
|
+
for dep in sorted(optimize_deps):
|
|
103
|
+
quoted_deps.append("'" + dep + "'")
|
|
104
|
+
|
|
105
|
+
return '\n ' + ',\n '.join(quoted_deps) + ',\n '
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def generate_proxy_block(api_base_path, backend_port, additional_routes, stack='app'):
|
|
109
|
+
"""Generate Vite proxy config using full descriptive API paths.
|
|
110
|
+
|
|
111
|
+
Uses API naming convention with full service names from manifest:
|
|
112
|
+
- Pattern: /api/v1/{app-name}
|
|
113
|
+
- Generated from manifest "stack" and "appName" fields
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
api_base_path: The base API path (from manifest)
|
|
117
|
+
backend_port: Backend resource port (kept for compatibility)
|
|
118
|
+
additional_routes: Additional proxy routes
|
|
119
|
+
stack: Resource stack name (from manifest.json)
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
Vite proxy configuration string
|
|
123
|
+
"""
|
|
124
|
+
# Get full descriptive API path for this stack using constants
|
|
125
|
+
# This replaces the old pattern: 'http://localhost:' + str(backend_port)
|
|
126
|
+
api_path = get_api_path_for_stack(stack)
|
|
127
|
+
|
|
128
|
+
# Build Traefik gateway URL using the full API path
|
|
129
|
+
# Format: http://{project}.localhost/api/v1/{full-service-name}
|
|
130
|
+
local_target = build_traefik_url(api_path)
|
|
131
|
+
|
|
132
|
+
routes = [
|
|
133
|
+
(api_base_path, local_target),
|
|
134
|
+
('/health', local_target),
|
|
135
|
+
('/trpc', local_target),
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
for route in additional_routes:
|
|
139
|
+
if type(route) == 'dict':
|
|
140
|
+
routes.append((route.get('path', '/'), route.get('target', local_target)))
|
|
141
|
+
else:
|
|
142
|
+
routes.append((route, local_target))
|
|
143
|
+
|
|
144
|
+
lines = [' proxy: {']
|
|
145
|
+
for path, target in routes:
|
|
146
|
+
lines.append(" '" + path + "': {")
|
|
147
|
+
lines.append(" target: '" + target + "',")
|
|
148
|
+
lines.append(" changeOrigin: true,")
|
|
149
|
+
lines.append(" secure: false,")
|
|
150
|
+
lines.append(" },")
|
|
151
|
+
lines.append(' },')
|
|
152
|
+
|
|
153
|
+
return '\n'.join(lines)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def generate_backend_path_aliases(resource_path, manifest):
|
|
157
|
+
"""Generate TypeScript path aliases for DDD architecture."""
|
|
158
|
+
lines = []
|
|
159
|
+
|
|
160
|
+
ddd_aliases = [
|
|
161
|
+
('@application', './src/application'),
|
|
162
|
+
('@domain', './src/domain'),
|
|
163
|
+
('@infrastructure', './src/infrastructure'),
|
|
164
|
+
('@presentation', './src/presentation'),
|
|
165
|
+
('@test', './src/tests'),
|
|
166
|
+
]
|
|
167
|
+
|
|
168
|
+
for alias, rel_path in ddd_aliases:
|
|
169
|
+
lines.append(" '" + alias + "': path.resolve(__dirname, '" + rel_path + "'),")
|
|
170
|
+
|
|
171
|
+
resource_parts = []
|
|
172
|
+
for p in resource_path.split('/'):
|
|
173
|
+
if p:
|
|
174
|
+
resource_parts.append(p)
|
|
175
|
+
depth = len(resource_parts)
|
|
176
|
+
rel_to_root = '../' * depth
|
|
177
|
+
|
|
178
|
+
internal_deps = manifest.get('_internalDeps', [])
|
|
179
|
+
for dep in sorted(internal_deps):
|
|
180
|
+
if dep.startswith('@' + _NPM_SCOPE + '/'):
|
|
181
|
+
lib_name = dep.replace('@' + _NPM_SCOPE + '/', '')
|
|
182
|
+
|
|
183
|
+
if lib_name.startswith('platform-'):
|
|
184
|
+
lib_path = rel_to_root + 'shared-platform-engineering/' + lib_name + '/dist'
|
|
185
|
+
elif lib_name.startswith('product-'):
|
|
186
|
+
lib_path = rel_to_root + 'shared-product-engineering/' + lib_name + '/dist'
|
|
187
|
+
elif lib_name in ['domain', 'application', 'infrastructure', 'presentation']:
|
|
188
|
+
lib_path = rel_to_root + 'shared-ddd-layers/' + lib_name + '/src'
|
|
189
|
+
else:
|
|
190
|
+
lib_path = rel_to_root + 'shared-platform-engineering/' + lib_name + '/src'
|
|
191
|
+
|
|
192
|
+
lines.append(" '" + dep + "': path.resolve(__dirname, '" + lib_path + "'),")
|
|
193
|
+
|
|
194
|
+
return '\n'.join(lines)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def generate_externals_config(manifest):
|
|
198
|
+
"""Generate Rollup externals for Node.js backend build."""
|
|
199
|
+
externals = [
|
|
200
|
+
'/^node:.*/',
|
|
201
|
+
'@prisma/client',
|
|
202
|
+
'prisma',
|
|
203
|
+
'hono',
|
|
204
|
+
'nats',
|
|
205
|
+
]
|
|
206
|
+
|
|
207
|
+
if manifest.get('usePrisma'):
|
|
208
|
+
externals.extend(['.prisma/client', '@prisma/adapter-pg'])
|
|
209
|
+
|
|
210
|
+
if manifest.get('useNats'):
|
|
211
|
+
externals.append('nats')
|
|
212
|
+
|
|
213
|
+
# Build externals config (Starlark-compatible)
|
|
214
|
+
externals_quoted = []
|
|
215
|
+
for e in externals:
|
|
216
|
+
if not e.startswith('/'):
|
|
217
|
+
externals_quoted.append("'" + e + "'")
|
|
218
|
+
else:
|
|
219
|
+
externals_quoted.append(e)
|
|
220
|
+
|
|
221
|
+
return '[' + ', '.join(externals_quoted) + ']'
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def generate_vitest_inline_deps(manifest):
|
|
225
|
+
"""Generate Vitest inline deps for internal packages."""
|
|
226
|
+
internal_deps = manifest.get('_internalDeps', [])
|
|
227
|
+
|
|
228
|
+
# Filter inline deps (Starlark-compatible)
|
|
229
|
+
inline_deps = []
|
|
230
|
+
for dep in internal_deps:
|
|
231
|
+
if dep.startswith('@' + _NPM_SCOPE + '/'):
|
|
232
|
+
inline_deps.append(dep)
|
|
233
|
+
|
|
234
|
+
if not inline_deps:
|
|
235
|
+
return ''
|
|
236
|
+
|
|
237
|
+
# Build quoted deps list (Starlark-compatible)
|
|
238
|
+
quoted_deps = []
|
|
239
|
+
for dep in inline_deps:
|
|
240
|
+
quoted_deps.append("'" + dep + "'")
|
|
241
|
+
|
|
242
|
+
return '\n ' + ',\n '.join(quoted_deps) + ',\n '
|
|
243
|
+
|
|
244
|
+
CONSTANTS = {}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# ⚡ TILT SDK - VITE LIBRARY GENERATOR
|
|
3
|
+
|
|
4
|
+
# === INLINED CONSTANTS for pure extension loading ===
|
|
5
|
+
OUTPUT = struct(AUTOGENERATED_FOLDER = ".autogenerated")
|
|
6
|
+
# === END INLINED CONSTANTS ===
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
load('../../../../topologies/tilt/manifest/constants.star', 'GENERATED_CONFIG_FILENAMES')
|
|
10
|
+
# =============================================================================
|
|
11
|
+
# Path: .tilt/providers/vite/library.star
|
|
12
|
+
# Purpose: Vite config generator for Library packages
|
|
13
|
+
# =============================================================================
|
|
14
|
+
|
|
15
|
+
load('./templates.star', 'TEMPLATE_VITE_LIBRARY')
|
|
16
|
+
load('./helpers.star', 'build_header')
|
|
17
|
+
|
|
18
|
+
# Constants for output paths
|
|
19
|
+
VITE_LIBRARY_CONFIG_PATH = '/' + OUTPUT.AUTOGENERATED_FOLDER + '/' + GENERATED_CONFIG_FILENAMES['vite_library']
|
|
20
|
+
|
|
21
|
+
def generate_library(manifest, write_fn=None):
|
|
22
|
+
"""
|
|
23
|
+
Generate vite.config.ts for LIBRARY packages.
|
|
24
|
+
|
|
25
|
+
Library-specific features:
|
|
26
|
+
1. vite-plugin-dts: Auto-generate .d.ts type definitions (only if in deps)
|
|
27
|
+
2. External all dependencies (peer deps pattern)
|
|
28
|
+
3. Both ESM and CJS output formats
|
|
29
|
+
4. Vitest for testing
|
|
30
|
+
"""
|
|
31
|
+
resource_path = manifest.get('_resource_path', '')
|
|
32
|
+
app_name = manifest.get('appName', 'unknown')
|
|
33
|
+
|
|
34
|
+
has_react = manifest.get('hasReact', False)
|
|
35
|
+
has_dts = manifest.get('hasDts', False)
|
|
36
|
+
|
|
37
|
+
plugin_imports = ''
|
|
38
|
+
plugins = []
|
|
39
|
+
|
|
40
|
+
if has_dts:
|
|
41
|
+
plugin_imports = "import dts from 'vite-plugin-dts';"
|
|
42
|
+
plugins.append('dts({ insertTypesEntry: true, tsconfigPath: resolve(__dirname, \'./tsconfig.autogenerated.json\') })')
|
|
43
|
+
|
|
44
|
+
if has_react:
|
|
45
|
+
if plugin_imports:
|
|
46
|
+
plugin_imports += "\nimport react from '@vitejs/plugin-react';"
|
|
47
|
+
else:
|
|
48
|
+
plugin_imports = "import react from '@vitejs/plugin-react';"
|
|
49
|
+
plugins.insert(0, 'react()')
|
|
50
|
+
|
|
51
|
+
plugins_str = ', '.join(plugins)
|
|
52
|
+
header = build_header('Vite.library()', app_name, 'Library (Build + DTS + Vitest)')
|
|
53
|
+
lib_name = app_name.replace('-', '_')
|
|
54
|
+
|
|
55
|
+
config = TEMPLATE_VITE_LIBRARY.format(
|
|
56
|
+
header=header,
|
|
57
|
+
plugin_imports=plugin_imports,
|
|
58
|
+
plugins_str=plugins_str,
|
|
59
|
+
lib_name=lib_name,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
if write_fn:
|
|
63
|
+
write_fn(resource_path + VITE_LIBRARY_CONFIG_PATH, config)
|
|
64
|
+
|
|
65
|
+
return config
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# ⚡ TILT SDK - VITE SDK GENERATOR
|
|
3
|
+
|
|
4
|
+
# === INLINED CONSTANTS for pure extension loading ===
|
|
5
|
+
OUTPUT = struct(AUTOGENERATED_FOLDER = ".autogenerated")
|
|
6
|
+
# === END INLINED CONSTANTS ===
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
load('../../../../topologies/tilt/manifest/constants.star', 'GENERATED_CONFIG_FILENAMES')
|
|
10
|
+
# =============================================================================
|
|
11
|
+
# Path: .tilt/providers/vite/sdk.star
|
|
12
|
+
# Purpose: Vite config generator for SDK packages (Module Federation)
|
|
13
|
+
# =============================================================================
|
|
14
|
+
|
|
15
|
+
load('./templates.star', 'TEMPLATE_VITE_SDK')
|
|
16
|
+
load('./helpers.star', 'build_header')
|
|
17
|
+
|
|
18
|
+
# Constants for output paths
|
|
19
|
+
VITE_SDK_CONFIG_PATH = '/' + OUTPUT.AUTOGENERATED_FOLDER + '/' + GENERATED_CONFIG_FILENAMES['vite_sdk']
|
|
20
|
+
|
|
21
|
+
def generate_sdk(manifest, write_fn=None):
|
|
22
|
+
"""
|
|
23
|
+
Generate vite.config.ts for SDK packages with Module Federation.
|
|
24
|
+
|
|
25
|
+
SDK features:
|
|
26
|
+
1. @module-federation/vite for runtime module sharing
|
|
27
|
+
2. Exposes configured modules
|
|
28
|
+
3. Shared React/React-DOM as singletons
|
|
29
|
+
4. Remote entry generation
|
|
30
|
+
"""
|
|
31
|
+
resource_path = manifest.get('_resource_path', '')
|
|
32
|
+
app_name = manifest.get('appName', 'unknown')
|
|
33
|
+
port = manifest.get('port', 3001)
|
|
34
|
+
|
|
35
|
+
federation_name = app_name.replace('-', '_')
|
|
36
|
+
|
|
37
|
+
exposes = manifest.get('federationExposes', {
|
|
38
|
+
'./App': './src/App.tsx',
|
|
39
|
+
'./client': './src/clients/main-client.ts',
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
exposes_lines = []
|
|
43
|
+
for key, value in exposes.items():
|
|
44
|
+
exposes_lines.append(" '" + key + "': '" + value + "',")
|
|
45
|
+
exposes_str = '\n'.join(exposes_lines)
|
|
46
|
+
|
|
47
|
+
shared_deps = manifest.get('federationShared', [
|
|
48
|
+
'react',
|
|
49
|
+
'react-dom',
|
|
50
|
+
'react-router-dom',
|
|
51
|
+
'@tanstack/react-query',
|
|
52
|
+
'zod',
|
|
53
|
+
])
|
|
54
|
+
|
|
55
|
+
shared_lines = []
|
|
56
|
+
for dep in shared_deps:
|
|
57
|
+
shared_lines.append(" '" + dep + "': { singleton: true },")
|
|
58
|
+
shared_str = '\n'.join(shared_lines)
|
|
59
|
+
|
|
60
|
+
header = build_header('Vite.sdk()', app_name, 'SDK (Module Federation)')
|
|
61
|
+
|
|
62
|
+
config = TEMPLATE_VITE_SDK.format(
|
|
63
|
+
header=header,
|
|
64
|
+
federation_name=federation_name,
|
|
65
|
+
port=port,
|
|
66
|
+
exposes_str=exposes_str,
|
|
67
|
+
shared_str=shared_str,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
if write_fn:
|
|
71
|
+
write_fn(resource_path + VITE_SDK_CONFIG_PATH, config)
|
|
72
|
+
|
|
73
|
+
return config
|