@teardown/cli 1.2.39 → 2.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/bin/teardown.js +11 -1
  2. package/package.json +77 -57
  3. package/src/cli/commands/init.ts +254 -0
  4. package/src/cli/commands/plugins.ts +93 -0
  5. package/src/cli/commands/prebuild.ts +168 -0
  6. package/src/cli/commands/run.ts +727 -0
  7. package/src/cli/commands/start.ts +87 -0
  8. package/src/cli/commands/validate.ts +62 -0
  9. package/src/cli/index.ts +59 -0
  10. package/src/config/index.ts +45 -0
  11. package/src/config/loader.ts +366 -0
  12. package/src/config/schema.ts +235 -0
  13. package/src/config/types.ts +322 -0
  14. package/src/index.ts +177 -0
  15. package/src/pipeline/cache.ts +179 -0
  16. package/src/pipeline/index.ts +10 -0
  17. package/src/pipeline/stages.ts +692 -0
  18. package/src/plugins/base.ts +370 -0
  19. package/src/plugins/capabilities/biometrics.ts +64 -0
  20. package/src/plugins/capabilities/bluetooth.ts +86 -0
  21. package/src/plugins/capabilities/calendar.ts +57 -0
  22. package/src/plugins/capabilities/camera.ts +77 -0
  23. package/src/plugins/capabilities/contacts.ts +57 -0
  24. package/src/plugins/capabilities/deep-linking.ts +124 -0
  25. package/src/plugins/capabilities/firebase.ts +138 -0
  26. package/src/plugins/capabilities/index.ts +96 -0
  27. package/src/plugins/capabilities/location.ts +87 -0
  28. package/src/plugins/capabilities/photo-library.ts +80 -0
  29. package/src/plugins/capabilities/push-notifications.ts +98 -0
  30. package/src/plugins/capabilities/sign-in-with-apple.ts +53 -0
  31. package/src/plugins/context.ts +220 -0
  32. package/src/plugins/index.ts +26 -0
  33. package/src/plugins/resolver.ts +321 -0
  34. package/src/templates/generator.ts +507 -0
  35. package/src/templates/index.ts +9 -0
  36. package/src/templates/paths.ts +25 -0
  37. package/src/transformers/android/gradle.ts +400 -0
  38. package/src/transformers/android/index.ts +19 -0
  39. package/src/transformers/android/manifest.ts +506 -0
  40. package/src/transformers/index.ts +39 -0
  41. package/src/transformers/ios/entitlements.ts +283 -0
  42. package/src/transformers/ios/index.ts +10 -0
  43. package/src/transformers/ios/pbxproj.ts +267 -0
  44. package/src/transformers/ios/plist.ts +198 -0
  45. package/src/utils/fs.ts +429 -0
  46. package/src/utils/index.ts +21 -0
  47. package/src/utils/logger.ts +203 -0
  48. package/templates/.gitignore +63 -0
  49. package/templates/Gemfile +3 -0
  50. package/templates/android/app/build.gradle.kts +97 -0
  51. package/templates/android/app/proguard-rules.pro +10 -0
  52. package/templates/android/app/src/main/AndroidManifest.xml +26 -0
  53. package/templates/android/app/src/main/java/com/appname/MainActivity.kt +22 -0
  54. package/templates/android/app/src/main/java/com/appname/MainApplication.kt +44 -0
  55. package/templates/android/app/src/main/res/values/strings.xml +3 -0
  56. package/templates/android/app/src/main/res/values/styles.xml +7 -0
  57. package/templates/android/build.gradle.kts +44 -0
  58. package/templates/android/gradle.properties +39 -0
  59. package/templates/android/settings.gradle.kts +12 -0
  60. package/templates/babel.config.js +15 -0
  61. package/templates/index.js +7 -0
  62. package/templates/ios/.xcode.env +11 -0
  63. package/templates/ios/AppName/AppDelegate.swift +25 -0
  64. package/templates/ios/AppName/AppName-Bridging-Header.h +4 -0
  65. package/templates/ios/AppName/AppName.entitlements +6 -0
  66. package/templates/ios/AppName/Images.xcassets/AppIcon.appiconset/Contents.json +35 -0
  67. package/templates/ios/AppName/Images.xcassets/Contents.json +6 -0
  68. package/templates/ios/AppName/Info.plist +49 -0
  69. package/templates/ios/AppName/LaunchScreen.storyboard +38 -0
  70. package/templates/ios/AppName.xcodeproj/project.pbxproj +402 -0
  71. package/templates/ios/AppName.xcodeproj/xcshareddata/xcschemes/AppName.xcscheme +78 -0
  72. package/templates/ios/Podfile +35 -0
  73. package/templates/metro.config.js +41 -0
  74. package/templates/package.json +57 -0
  75. package/templates/react-native.config.js +8 -0
  76. package/templates/src/app/index.tsx +34 -0
  77. package/templates/src/assets/fonts/.gitkeep +1 -0
  78. package/templates/src/assets/images/.gitkeep +1 -0
  79. package/templates/src/components/ui/accordion.tsx +114 -0
  80. package/templates/src/components/ui/avatar.tsx +75 -0
  81. package/templates/src/components/ui/button.tsx +93 -0
  82. package/templates/src/components/ui/card.tsx +120 -0
  83. package/templates/src/components/ui/checkbox.tsx +133 -0
  84. package/templates/src/components/ui/chip.tsx +95 -0
  85. package/templates/src/components/ui/dialog.tsx +134 -0
  86. package/templates/src/components/ui/divider.tsx +67 -0
  87. package/templates/src/components/ui/error-view.tsx +82 -0
  88. package/templates/src/components/ui/form-field.tsx +101 -0
  89. package/templates/src/components/ui/index.ts +100 -0
  90. package/templates/src/components/ui/popover.tsx +92 -0
  91. package/templates/src/components/ui/pressable-feedback.tsx +88 -0
  92. package/templates/src/components/ui/radio-group.tsx +153 -0
  93. package/templates/src/components/ui/scroll-shadow.tsx +108 -0
  94. package/templates/src/components/ui/select.tsx +165 -0
  95. package/templates/src/components/ui/skeleton-group.tsx +97 -0
  96. package/templates/src/components/ui/skeleton.tsx +87 -0
  97. package/templates/src/components/ui/spinner.tsx +87 -0
  98. package/templates/src/components/ui/surface.tsx +95 -0
  99. package/templates/src/components/ui/switch.tsx +124 -0
  100. package/templates/src/components/ui/tabs.tsx +154 -0
  101. package/templates/src/components/ui/text-field.tsx +106 -0
  102. package/templates/src/components/ui/toast.tsx +129 -0
  103. package/templates/src/contexts/.gitkeep +2 -0
  104. package/templates/src/core/clients/api/api.client.ts +113 -0
  105. package/templates/src/core/clients/api/index.ts +1 -0
  106. package/templates/src/core/clients/storage/index.ts +1 -0
  107. package/templates/src/core/clients/storage/storage.client.ts +121 -0
  108. package/templates/src/core/constants/index.ts +19 -0
  109. package/templates/src/core/core.ts +40 -0
  110. package/templates/src/core/index.ts +10 -0
  111. package/templates/src/global.css +87 -0
  112. package/templates/src/hooks/index.ts +6 -0
  113. package/templates/src/hooks/use-debounce.ts +23 -0
  114. package/templates/src/hooks/use-mounted.ts +21 -0
  115. package/templates/src/index.ts +28 -0
  116. package/templates/src/lib/index.ts +5 -0
  117. package/templates/src/lib/utils.ts +115 -0
  118. package/templates/src/modules/.gitkeep +6 -0
  119. package/templates/src/navigation/index.ts +8 -0
  120. package/templates/src/navigation/navigation-provider.tsx +36 -0
  121. package/templates/src/navigation/router.tsx +137 -0
  122. package/templates/src/providers/app.provider.tsx +29 -0
  123. package/templates/src/providers/index.ts +5 -0
  124. package/templates/src/routes/(tabs)/_layout.tsx +42 -0
  125. package/templates/src/routes/(tabs)/explore.tsx +161 -0
  126. package/templates/src/routes/(tabs)/home.tsx +138 -0
  127. package/templates/src/routes/(tabs)/profile.tsx +151 -0
  128. package/templates/src/routes/_layout.tsx +18 -0
  129. package/templates/src/routes/settings.tsx +194 -0
  130. package/templates/src/screens/auth/index.ts +6 -0
  131. package/templates/src/screens/auth/login.tsx +165 -0
  132. package/templates/src/screens/auth/register.tsx +203 -0
  133. package/templates/src/screens/home.tsx +204 -0
  134. package/templates/src/screens/index.ts +17 -0
  135. package/templates/src/screens/profile.tsx +210 -0
  136. package/templates/src/screens/settings.tsx +216 -0
  137. package/templates/src/screens/welcome.tsx +101 -0
  138. package/templates/src/styles/index.ts +103 -0
  139. package/templates/src/types/common.ts +71 -0
  140. package/templates/src/types/index.ts +5 -0
  141. package/templates/tsconfig.json +14 -0
  142. package/README.md +0 -15
  143. package/assets/favicon.ico +0 -0
  144. package/dist/commands/dev/dev.d.ts +0 -22
  145. package/dist/commands/dev/dev.js +0 -56
  146. package/dist/commands/dev/dev.js.map +0 -1
  147. package/dist/commands/init/init-teardown.d.ts +0 -9
  148. package/dist/commands/init/init-teardown.js +0 -27
  149. package/dist/commands/init/init-teardown.js.map +0 -1
  150. package/dist/index.d.ts +0 -1
  151. package/dist/index.js +0 -21
  152. package/dist/index.js.map +0 -1
  153. package/dist/modules/dev/dev-menu/keyboard-handler.d.ts +0 -21
  154. package/dist/modules/dev/dev-menu/keyboard-handler.js +0 -139
  155. package/dist/modules/dev/dev-menu/keyboard-handler.js.map +0 -1
  156. package/dist/modules/dev/dev-menu/open-debugger-keyboard-handler.d.ts +0 -18
  157. package/dist/modules/dev/dev-menu/open-debugger-keyboard-handler.js +0 -106
  158. package/dist/modules/dev/dev-menu/open-debugger-keyboard-handler.js.map +0 -1
  159. package/dist/modules/dev/dev-server/cdp/cdp.adapter.d.ts +0 -6
  160. package/dist/modules/dev/dev-server/cdp/cdp.adapter.js +0 -13
  161. package/dist/modules/dev/dev-server/cdp/cdp.adapter.js.map +0 -1
  162. package/dist/modules/dev/dev-server/cdp/index.d.ts +0 -2
  163. package/dist/modules/dev/dev-server/cdp/index.js +0 -19
  164. package/dist/modules/dev/dev-server/cdp/index.js.map +0 -1
  165. package/dist/modules/dev/dev-server/cdp/types.d.ts +0 -107
  166. package/dist/modules/dev/dev-server/cdp/types.js +0 -3
  167. package/dist/modules/dev/dev-server/cdp/types.js.map +0 -1
  168. package/dist/modules/dev/dev-server/dev-server-checker.d.ts +0 -22
  169. package/dist/modules/dev/dev-server/dev-server-checker.js +0 -73
  170. package/dist/modules/dev/dev-server/dev-server-checker.js.map +0 -1
  171. package/dist/modules/dev/dev-server/dev-server.d.ts +0 -74
  172. package/dist/modules/dev/dev-server/dev-server.js +0 -272
  173. package/dist/modules/dev/dev-server/dev-server.js.map +0 -1
  174. package/dist/modules/dev/dev-server/inspector/device.d.ts +0 -46
  175. package/dist/modules/dev/dev-server/inspector/device.event-reporter.d.ts +0 -37
  176. package/dist/modules/dev/dev-server/inspector/device.event-reporter.js +0 -166
  177. package/dist/modules/dev/dev-server/inspector/device.event-reporter.js.map +0 -1
  178. package/dist/modules/dev/dev-server/inspector/device.js +0 -578
  179. package/dist/modules/dev/dev-server/inspector/device.js.map +0 -1
  180. package/dist/modules/dev/dev-server/inspector/inspector.d.ts +0 -27
  181. package/dist/modules/dev/dev-server/inspector/inspector.js +0 -225
  182. package/dist/modules/dev/dev-server/inspector/inspector.js.map +0 -1
  183. package/dist/modules/dev/dev-server/inspector/types.d.ts +0 -156
  184. package/dist/modules/dev/dev-server/inspector/types.js +0 -3
  185. package/dist/modules/dev/dev-server/inspector/types.js.map +0 -1
  186. package/dist/modules/dev/dev-server/inspector/wss/servers/debugger-connection.server.d.ts +0 -14
  187. package/dist/modules/dev/dev-server/inspector/wss/servers/debugger-connection.server.js +0 -63
  188. package/dist/modules/dev/dev-server/inspector/wss/servers/debugger-connection.server.js.map +0 -1
  189. package/dist/modules/dev/dev-server/inspector/wss/servers/device-connection.server.d.ts +0 -19
  190. package/dist/modules/dev/dev-server/inspector/wss/servers/device-connection.server.js +0 -66
  191. package/dist/modules/dev/dev-server/inspector/wss/servers/device-connection.server.js.map +0 -1
  192. package/dist/modules/dev/dev-server/plugins/devtools.plugin.d.ts +0 -1
  193. package/dist/modules/dev/dev-server/plugins/devtools.plugin.js +0 -51
  194. package/dist/modules/dev/dev-server/plugins/devtools.plugin.js.map +0 -1
  195. package/dist/modules/dev/dev-server/plugins/favicon.plugin.d.ts +0 -1
  196. package/dist/modules/dev/dev-server/plugins/favicon.plugin.js +0 -19
  197. package/dist/modules/dev/dev-server/plugins/favicon.plugin.js.map +0 -1
  198. package/dist/modules/dev/dev-server/plugins/multipart.plugin.d.ts +0 -1
  199. package/dist/modules/dev/dev-server/plugins/multipart.plugin.js +0 -63
  200. package/dist/modules/dev/dev-server/plugins/multipart.plugin.js.map +0 -1
  201. package/dist/modules/dev/dev-server/plugins/systrace.plugin.d.ts +0 -1
  202. package/dist/modules/dev/dev-server/plugins/systrace.plugin.js +0 -29
  203. package/dist/modules/dev/dev-server/plugins/systrace.plugin.js.map +0 -1
  204. package/dist/modules/dev/dev-server/plugins/types.d.ts +0 -11
  205. package/dist/modules/dev/dev-server/plugins/types.js +0 -3
  206. package/dist/modules/dev/dev-server/plugins/types.js.map +0 -1
  207. package/dist/modules/dev/dev-server/plugins/wss/index.d.ts +0 -3
  208. package/dist/modules/dev/dev-server/plugins/wss/index.js +0 -20
  209. package/dist/modules/dev/dev-server/plugins/wss/index.js.map +0 -1
  210. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-api.server.d.ts +0 -37
  211. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-api.server.js +0 -67
  212. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-api.server.js.map +0 -1
  213. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-debugger.server.d.ts +0 -63
  214. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-debugger.server.js +0 -129
  215. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-debugger.server.js.map +0 -1
  216. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-dev-client.server.d.ts +0 -32
  217. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-dev-client.server.js +0 -76
  218. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-dev-client.server.js.map +0 -1
  219. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-events.server.d.ts +0 -75
  220. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-events.server.js +0 -199
  221. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-events.server.js.map +0 -1
  222. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-hmr.server.d.ts +0 -44
  223. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-hmr.server.js +0 -121
  224. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-hmr.server.js.map +0 -1
  225. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-message.server.d.ts +0 -135
  226. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-message.server.js +0 -364
  227. package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-message.server.js.map +0 -1
  228. package/dist/modules/dev/dev-server/plugins/wss/types.d.ts +0 -6
  229. package/dist/modules/dev/dev-server/plugins/wss/types.js +0 -3
  230. package/dist/modules/dev/dev-server/plugins/wss/types.js.map +0 -1
  231. package/dist/modules/dev/dev-server/plugins/wss/web-socket-router.d.ts +0 -32
  232. package/dist/modules/dev/dev-server/plugins/wss/web-socket-router.js +0 -58
  233. package/dist/modules/dev/dev-server/plugins/wss/web-socket-router.js.map +0 -1
  234. package/dist/modules/dev/dev-server/plugins/wss/web-socket-server-adapter.d.ts +0 -13
  235. package/dist/modules/dev/dev-server/plugins/wss/web-socket-server-adapter.js +0 -27
  236. package/dist/modules/dev/dev-server/plugins/wss/web-socket-server-adapter.js.map +0 -1
  237. package/dist/modules/dev/dev-server/plugins/wss/web-socket-server.d.ts +0 -39
  238. package/dist/modules/dev/dev-server/plugins/wss/web-socket-server.js +0 -47
  239. package/dist/modules/dev/dev-server/plugins/wss/web-socket-server.js.map +0 -1
  240. package/dist/modules/dev/dev-server/plugins/wss/wss.plugin.d.ts +0 -24
  241. package/dist/modules/dev/dev-server/plugins/wss/wss.plugin.js +0 -56
  242. package/dist/modules/dev/dev-server/plugins/wss/wss.plugin.js.map +0 -1
  243. package/dist/modules/dev/dev-server/sybmolicate/sybmolicate.plugin.d.ts +0 -7
  244. package/dist/modules/dev/dev-server/sybmolicate/sybmolicate.plugin.js +0 -41
  245. package/dist/modules/dev/dev-server/sybmolicate/sybmolicate.plugin.js.map +0 -1
  246. package/dist/modules/dev/dev-server/sybmolicate/types.d.ts +0 -64
  247. package/dist/modules/dev/dev-server/sybmolicate/types.js +0 -3
  248. package/dist/modules/dev/dev-server/sybmolicate/types.js.map +0 -1
  249. package/dist/modules/dev/terminal/base.terminal.reporter.d.ts +0 -25
  250. package/dist/modules/dev/terminal/base.terminal.reporter.js +0 -79
  251. package/dist/modules/dev/terminal/base.terminal.reporter.js.map +0 -1
  252. package/dist/modules/dev/terminal/terminal.reporter.d.ts +0 -13
  253. package/dist/modules/dev/terminal/terminal.reporter.js +0 -83
  254. package/dist/modules/dev/terminal/terminal.reporter.js.map +0 -1
  255. package/dist/modules/dev/types.d.ts +0 -20
  256. package/dist/modules/dev/types.js +0 -3
  257. package/dist/modules/dev/types.js.map +0 -1
  258. package/dist/modules/dev/utils/log.d.ts +0 -23
  259. package/dist/modules/dev/utils/log.js +0 -74
  260. package/dist/modules/dev/utils/log.js.map +0 -1
package/src/index.ts ADDED
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Teardown Launchpad
3
+ *
4
+ * A React Native Prebuild System Independent of Expo
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+
9
+ // CLI
10
+ export { createProgram, run } from "./cli";
11
+ export type {
12
+ AndroidConfig,
13
+ BuildConfig,
14
+ ConfigLoadResult,
15
+ DryRunResult,
16
+ FileChange,
17
+ iOSConfig,
18
+ PermissionConfig,
19
+ PermissionMapping,
20
+ PermissionStatus,
21
+ PluginEntry,
22
+ PrebuildError,
23
+ PrebuildOptions,
24
+ PrebuildWarning,
25
+ ProcessedAppConfig,
26
+ SplashConfig,
27
+ TeardownConfig,
28
+ TemplateContext,
29
+ } from "./config";
30
+ // Configuration
31
+ export {
32
+ AndroidConfigSchema,
33
+ defineConfig,
34
+ findConfigFile,
35
+ generateDefaultConfig,
36
+ iOSConfigSchema,
37
+ loadConfig,
38
+ TeardownConfigSchema,
39
+ validateConfig,
40
+ watchConfig,
41
+ } from "./config";
42
+ export type { CacheEntry, PipelineResult, PipelineStage } from "./pipeline";
43
+ // Pipeline
44
+ export { createPipeline, IncrementalBuildCache, Pipeline } from "./pipeline";
45
+ export type {
46
+ AndroidManifest,
47
+ CycleInfo,
48
+ Entitlements,
49
+ InfoPlist,
50
+ PluginConstructor,
51
+ PluginContext,
52
+ } from "./plugins";
53
+ // Plugins
54
+ export {
55
+ BasePlugin,
56
+ createPluginContext,
57
+ DependencyResolver,
58
+ PluginResolutionError,
59
+ } from "./plugins";
60
+ export type {
61
+ BiometricsPluginConfig,
62
+ BluetoothPluginConfig,
63
+ CalendarPluginConfig,
64
+ CameraPluginConfig,
65
+ ContactsPluginConfig,
66
+ DeepLinkingPluginConfig,
67
+ FirebasePluginConfig,
68
+ LocationPluginConfig,
69
+ PhotoLibraryPluginConfig,
70
+ PushNotificationsPluginConfig,
71
+ SignInWithApplePluginConfig,
72
+ } from "./plugins/capabilities";
73
+ // Capability Plugins
74
+ export {
75
+ BiometricsPlugin,
76
+ BluetoothPlugin,
77
+ CalendarPlugin,
78
+ CameraPlugin,
79
+ CapabilityPlugins,
80
+ ContactsPlugin,
81
+ DeepLinkingPlugin,
82
+ FirebasePlugin,
83
+ getPluginByName,
84
+ LocationPlugin,
85
+ PhotoLibraryPlugin,
86
+ PushNotificationsPlugin,
87
+ SignInWithApplePlugin,
88
+ } from "./plugins/capabilities";
89
+ export type {
90
+ AndroidManifestXml,
91
+ BuildSettings,
92
+ EntitlementsContent,
93
+ InfoPlistContent,
94
+ } from "./transformers";
95
+ // Transformers
96
+ export {
97
+ AndroidManifestTransformer,
98
+ EntitlementsTransformer,
99
+ GradleTransformer,
100
+ PbxprojTransformer,
101
+ PlistTransformer,
102
+ StringsTransformer,
103
+ } from "./transformers";
104
+ export type { Logger, LogLevel, VirtualFileSystem } from "./utils";
105
+ // Utilities
106
+ export {
107
+ createLogger,
108
+ createVirtualFileSystem,
109
+ defaultLogger,
110
+ formatBytes,
111
+ formatDuration,
112
+ formatKeyValue,
113
+ formatList,
114
+ } from "./utils";
115
+
116
+ // Import types needed for prebuild function
117
+ import type { PrebuildOptions } from "./config/types";
118
+ import type { PipelineResult } from "./pipeline";
119
+ import type { BasePlugin } from "./plugins/base";
120
+
121
+ /**
122
+ * Prebuild the native projects
123
+ *
124
+ * This is the main entry point for programmatic usage.
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * import { prebuild } from '@teardown/cli';
129
+ *
130
+ * await prebuild({
131
+ * platform: 'all',
132
+ * projectRoot: process.cwd(),
133
+ * });
134
+ * ```
135
+ */
136
+ export async function prebuild(options: PrebuildOptions): Promise<PipelineResult> {
137
+ const { createPipeline } = await import("./pipeline");
138
+ const { loadConfig } = await import("./config");
139
+ const { getPluginByName } = await import("./plugins/capabilities");
140
+
141
+ const projectRoot = options.projectRoot ?? process.cwd();
142
+ const configResult = await loadConfig(projectRoot);
143
+
144
+ if (!configResult.success || !configResult.config) {
145
+ return {
146
+ success: false,
147
+ warnings: [],
148
+ errors: configResult.errors?.map((e) => ({
149
+ code: "CONFIG_ERROR",
150
+ message: e.message,
151
+ })) ?? [{ code: "CONFIG_ERROR", message: "Failed to load configuration" }],
152
+ duration: 0,
153
+ };
154
+ }
155
+
156
+ const pipeline = createPipeline();
157
+
158
+ // Register plugins from configuration
159
+ const plugins = configResult.config.plugins ?? [];
160
+ for (const pluginEntry of plugins) {
161
+ if (typeof pluginEntry === "string") {
162
+ const PluginClass = getPluginByName(pluginEntry);
163
+ if (PluginClass) {
164
+ const plugin = new (PluginClass as new () => BasePlugin)();
165
+ pipeline.registerPlugin(plugin);
166
+ }
167
+ } else if (Array.isArray(pluginEntry)) {
168
+ const [PluginClass, pluginConfig] = pluginEntry;
169
+ if (typeof PluginClass === "function") {
170
+ const plugin = new PluginClass();
171
+ pipeline.registerPlugin(plugin, pluginConfig);
172
+ }
173
+ }
174
+ }
175
+
176
+ return pipeline.execute(options);
177
+ }
@@ -0,0 +1,179 @@
1
+ import * as crypto from "node:crypto";
2
+ import * as fs from "node:fs";
3
+ import * as path from "node:path";
4
+ import type { TeardownConfig } from "../config/types";
5
+ import type { Logger } from "../utils/logger";
6
+
7
+ /**
8
+ * Cache entry stored on disk
9
+ */
10
+ export interface CacheEntry {
11
+ /** Hash of the configuration */
12
+ configHash: string;
13
+
14
+ /** Timestamp of the last build */
15
+ timestamp: number;
16
+
17
+ /** List of generated file paths */
18
+ outputs: string[];
19
+
20
+ /** Hash of plugin configurations */
21
+ pluginsHash: string;
22
+ }
23
+
24
+ /**
25
+ * Cache directory name
26
+ */
27
+ const CACHE_DIR = ".teardown";
28
+ const CACHE_FILE = "prebuild-cache.json";
29
+
30
+ /**
31
+ * Incremental build cache manager
32
+ *
33
+ * Tracks configuration changes to avoid unnecessary rebuilds
34
+ */
35
+ export class IncrementalBuildCache {
36
+ private logger: Logger;
37
+
38
+ constructor(logger: Logger) {
39
+ this.logger = logger;
40
+ }
41
+
42
+ /**
43
+ * Get the cache directory path
44
+ */
45
+ private getCacheDir(projectRoot: string): string {
46
+ return path.join(projectRoot, CACHE_DIR);
47
+ }
48
+
49
+ /**
50
+ * Get the cache file path
51
+ */
52
+ private getCachePath(projectRoot: string): string {
53
+ return path.join(this.getCacheDir(projectRoot), CACHE_FILE);
54
+ }
55
+
56
+ /**
57
+ * Load the cache entry from disk
58
+ */
59
+ private async loadCache(projectRoot: string): Promise<CacheEntry | null> {
60
+ const cachePath = this.getCachePath(projectRoot);
61
+
62
+ try {
63
+ const content = await fs.promises.readFile(cachePath, "utf-8");
64
+ return JSON.parse(content) as CacheEntry;
65
+ } catch {
66
+ return null;
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Save the cache entry to disk
72
+ */
73
+ private async saveCache(projectRoot: string, entry: CacheEntry): Promise<void> {
74
+ const cacheDir = this.getCacheDir(projectRoot);
75
+ const cachePath = this.getCachePath(projectRoot);
76
+
77
+ await fs.promises.mkdir(cacheDir, { recursive: true });
78
+ await fs.promises.writeFile(cachePath, JSON.stringify(entry, null, 2), "utf-8");
79
+ }
80
+
81
+ /**
82
+ * Compute a hash of the configuration
83
+ */
84
+ private computeConfigHash(config: TeardownConfig): string {
85
+ const content = JSON.stringify(config, null, 0);
86
+ return crypto.createHash("sha256").update(content).digest("hex").substring(0, 16);
87
+ }
88
+
89
+ /**
90
+ * Check if the prebuild can be skipped (no changes detected)
91
+ */
92
+ async shouldSkip(config: TeardownConfig, projectRoot: string): Promise<boolean> {
93
+ const cached = await this.loadCache(projectRoot);
94
+
95
+ if (!cached) {
96
+ this.logger.debug("No cache found, full rebuild required");
97
+ return false;
98
+ }
99
+
100
+ const currentHash = this.computeConfigHash(config);
101
+
102
+ if (cached.configHash !== currentHash) {
103
+ this.logger.debug("Configuration changed, rebuild required");
104
+ return false;
105
+ }
106
+
107
+ // Verify all cached outputs still exist
108
+ for (const output of cached.outputs) {
109
+ try {
110
+ await fs.promises.access(output);
111
+ } catch {
112
+ this.logger.debug(`Output file missing: ${output}, rebuild required`);
113
+ return false;
114
+ }
115
+ }
116
+
117
+ this.logger.debug("Cache valid, prebuild can be skipped");
118
+ return true;
119
+ }
120
+
121
+ /**
122
+ * Update the cache after a successful build
123
+ */
124
+ async update(config: TeardownConfig, projectRoot: string, outputs: string[]): Promise<void> {
125
+ const entry: CacheEntry = {
126
+ configHash: this.computeConfigHash(config),
127
+ timestamp: Date.now(),
128
+ outputs,
129
+ pluginsHash: this.computePluginsHash(config),
130
+ };
131
+
132
+ await this.saveCache(projectRoot, entry);
133
+ this.logger.debug("Build cache updated");
134
+ }
135
+
136
+ /**
137
+ * Compute hash of plugin configurations
138
+ */
139
+ private computePluginsHash(config: TeardownConfig): string {
140
+ const plugins = config.plugins || [];
141
+ const content = JSON.stringify(plugins, null, 0);
142
+ return crypto.createHash("sha256").update(content).digest("hex").substring(0, 16);
143
+ }
144
+
145
+ /**
146
+ * Clear the cache
147
+ */
148
+ async clear(projectRoot: string): Promise<void> {
149
+ const cacheDir = this.getCacheDir(projectRoot);
150
+
151
+ try {
152
+ await fs.promises.rm(cacheDir, { recursive: true, force: true });
153
+ this.logger.debug("Build cache cleared");
154
+ } catch {
155
+ // Cache dir might not exist
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Get cache statistics
161
+ */
162
+ async getStats(projectRoot: string): Promise<{
163
+ exists: boolean;
164
+ lastBuild?: Date;
165
+ outputCount?: number;
166
+ }> {
167
+ const cached = await this.loadCache(projectRoot);
168
+
169
+ if (!cached) {
170
+ return { exists: false };
171
+ }
172
+
173
+ return {
174
+ exists: true,
175
+ lastBuild: new Date(cached.timestamp),
176
+ outputCount: cached.outputs.length,
177
+ };
178
+ }
179
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Build pipeline for Teardown Launchpad
3
+ *
4
+ * Orchestrates the transformation of configuration into native projects
5
+ */
6
+
7
+ export type { CacheEntry } from "./cache";
8
+ export { IncrementalBuildCache } from "./cache";
9
+ export type { PipelineResult, PipelineStage } from "./stages";
10
+ export { createPipeline, Pipeline } from "./stages";