@teardown/cli 1.2.38 → 2.0.41
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/bin/teardown.js +11 -1
- package/package.json +77 -57
- package/src/cli/commands/init.ts +254 -0
- package/src/cli/commands/plugins.ts +93 -0
- package/src/cli/commands/prebuild.ts +168 -0
- package/src/cli/commands/run.ts +727 -0
- package/src/cli/commands/start.ts +87 -0
- package/src/cli/commands/validate.ts +62 -0
- package/src/cli/index.ts +59 -0
- package/src/config/index.ts +45 -0
- package/src/config/loader.ts +366 -0
- package/src/config/schema.ts +235 -0
- package/src/config/types.ts +322 -0
- package/src/index.ts +177 -0
- package/src/pipeline/cache.ts +179 -0
- package/src/pipeline/index.ts +10 -0
- package/src/pipeline/stages.ts +692 -0
- package/src/plugins/base.ts +370 -0
- package/src/plugins/capabilities/biometrics.ts +64 -0
- package/src/plugins/capabilities/bluetooth.ts +86 -0
- package/src/plugins/capabilities/calendar.ts +57 -0
- package/src/plugins/capabilities/camera.ts +77 -0
- package/src/plugins/capabilities/contacts.ts +57 -0
- package/src/plugins/capabilities/deep-linking.ts +124 -0
- package/src/plugins/capabilities/firebase.ts +138 -0
- package/src/plugins/capabilities/index.ts +96 -0
- package/src/plugins/capabilities/location.ts +87 -0
- package/src/plugins/capabilities/photo-library.ts +80 -0
- package/src/plugins/capabilities/push-notifications.ts +98 -0
- package/src/plugins/capabilities/sign-in-with-apple.ts +53 -0
- package/src/plugins/context.ts +220 -0
- package/src/plugins/index.ts +26 -0
- package/src/plugins/resolver.ts +321 -0
- package/src/templates/generator.ts +507 -0
- package/src/templates/index.ts +9 -0
- package/src/templates/paths.ts +25 -0
- package/src/transformers/android/gradle.ts +400 -0
- package/src/transformers/android/index.ts +19 -0
- package/src/transformers/android/manifest.ts +506 -0
- package/src/transformers/index.ts +39 -0
- package/src/transformers/ios/entitlements.ts +283 -0
- package/src/transformers/ios/index.ts +10 -0
- package/src/transformers/ios/pbxproj.ts +267 -0
- package/src/transformers/ios/plist.ts +198 -0
- package/src/utils/fs.ts +429 -0
- package/src/utils/index.ts +21 -0
- package/src/utils/logger.ts +203 -0
- package/templates/.gitignore +63 -0
- package/templates/Gemfile +3 -0
- package/templates/android/app/build.gradle.kts +97 -0
- package/templates/android/app/proguard-rules.pro +10 -0
- package/templates/android/app/src/main/AndroidManifest.xml +26 -0
- package/templates/android/app/src/main/java/com/appname/MainActivity.kt +22 -0
- package/templates/android/app/src/main/java/com/appname/MainApplication.kt +44 -0
- package/templates/android/app/src/main/res/values/strings.xml +3 -0
- package/templates/android/app/src/main/res/values/styles.xml +7 -0
- package/templates/android/build.gradle.kts +44 -0
- package/templates/android/gradle.properties +39 -0
- package/templates/android/settings.gradle.kts +12 -0
- package/templates/babel.config.js +15 -0
- package/templates/index.js +7 -0
- package/templates/ios/.xcode.env +11 -0
- package/templates/ios/AppName/AppDelegate.swift +25 -0
- package/templates/ios/AppName/AppName-Bridging-Header.h +4 -0
- package/templates/ios/AppName/AppName.entitlements +6 -0
- package/templates/ios/AppName/Images.xcassets/AppIcon.appiconset/Contents.json +35 -0
- package/templates/ios/AppName/Images.xcassets/Contents.json +6 -0
- package/templates/ios/AppName/Info.plist +49 -0
- package/templates/ios/AppName/LaunchScreen.storyboard +38 -0
- package/templates/ios/AppName.xcodeproj/project.pbxproj +402 -0
- package/templates/ios/AppName.xcodeproj/xcshareddata/xcschemes/AppName.xcscheme +78 -0
- package/templates/ios/Podfile +35 -0
- package/templates/metro.config.js +41 -0
- package/templates/package.json +57 -0
- package/templates/react-native.config.js +8 -0
- package/templates/src/app/index.tsx +34 -0
- package/templates/src/assets/fonts/.gitkeep +1 -0
- package/templates/src/assets/images/.gitkeep +1 -0
- package/templates/src/components/ui/accordion.tsx +114 -0
- package/templates/src/components/ui/avatar.tsx +75 -0
- package/templates/src/components/ui/button.tsx +93 -0
- package/templates/src/components/ui/card.tsx +120 -0
- package/templates/src/components/ui/checkbox.tsx +133 -0
- package/templates/src/components/ui/chip.tsx +95 -0
- package/templates/src/components/ui/dialog.tsx +134 -0
- package/templates/src/components/ui/divider.tsx +67 -0
- package/templates/src/components/ui/error-view.tsx +82 -0
- package/templates/src/components/ui/form-field.tsx +101 -0
- package/templates/src/components/ui/index.ts +100 -0
- package/templates/src/components/ui/popover.tsx +92 -0
- package/templates/src/components/ui/pressable-feedback.tsx +88 -0
- package/templates/src/components/ui/radio-group.tsx +153 -0
- package/templates/src/components/ui/scroll-shadow.tsx +108 -0
- package/templates/src/components/ui/select.tsx +165 -0
- package/templates/src/components/ui/skeleton-group.tsx +97 -0
- package/templates/src/components/ui/skeleton.tsx +87 -0
- package/templates/src/components/ui/spinner.tsx +87 -0
- package/templates/src/components/ui/surface.tsx +95 -0
- package/templates/src/components/ui/switch.tsx +124 -0
- package/templates/src/components/ui/tabs.tsx +154 -0
- package/templates/src/components/ui/text-field.tsx +106 -0
- package/templates/src/components/ui/toast.tsx +129 -0
- package/templates/src/contexts/.gitkeep +2 -0
- package/templates/src/core/clients/api/api.client.ts +113 -0
- package/templates/src/core/clients/api/index.ts +1 -0
- package/templates/src/core/clients/storage/index.ts +1 -0
- package/templates/src/core/clients/storage/storage.client.ts +121 -0
- package/templates/src/core/constants/index.ts +19 -0
- package/templates/src/core/core.ts +40 -0
- package/templates/src/core/index.ts +10 -0
- package/templates/src/global.css +87 -0
- package/templates/src/hooks/index.ts +6 -0
- package/templates/src/hooks/use-debounce.ts +23 -0
- package/templates/src/hooks/use-mounted.ts +21 -0
- package/templates/src/index.ts +28 -0
- package/templates/src/lib/index.ts +5 -0
- package/templates/src/lib/utils.ts +115 -0
- package/templates/src/modules/.gitkeep +6 -0
- package/templates/src/navigation/index.ts +8 -0
- package/templates/src/navigation/navigation-provider.tsx +36 -0
- package/templates/src/navigation/router.tsx +137 -0
- package/templates/src/providers/app.provider.tsx +29 -0
- package/templates/src/providers/index.ts +5 -0
- package/templates/src/routes/(tabs)/_layout.tsx +42 -0
- package/templates/src/routes/(tabs)/explore.tsx +161 -0
- package/templates/src/routes/(tabs)/home.tsx +138 -0
- package/templates/src/routes/(tabs)/profile.tsx +151 -0
- package/templates/src/routes/_layout.tsx +18 -0
- package/templates/src/routes/settings.tsx +194 -0
- package/templates/src/screens/auth/index.ts +6 -0
- package/templates/src/screens/auth/login.tsx +165 -0
- package/templates/src/screens/auth/register.tsx +203 -0
- package/templates/src/screens/home.tsx +204 -0
- package/templates/src/screens/index.ts +17 -0
- package/templates/src/screens/profile.tsx +210 -0
- package/templates/src/screens/settings.tsx +216 -0
- package/templates/src/screens/welcome.tsx +101 -0
- package/templates/src/styles/index.ts +103 -0
- package/templates/src/types/common.ts +71 -0
- package/templates/src/types/index.ts +5 -0
- package/templates/tsconfig.json +14 -0
- package/README.md +0 -15
- package/assets/favicon.ico +0 -0
- package/dist/commands/dev/dev.js +0 -55
- package/dist/commands/init/init-teardown.js +0 -26
- package/dist/index.js +0 -20
- package/dist/modules/dev/dev-menu/keyboard-handler.js +0 -138
- package/dist/modules/dev/dev-menu/open-debugger-keyboard-handler.js +0 -105
- package/dist/modules/dev/dev-server/cdp/cdp.adapter.js +0 -12
- package/dist/modules/dev/dev-server/cdp/index.js +0 -18
- package/dist/modules/dev/dev-server/cdp/types.js +0 -2
- package/dist/modules/dev/dev-server/dev-server-checker.js +0 -72
- package/dist/modules/dev/dev-server/dev-server.js +0 -269
- package/dist/modules/dev/dev-server/inspector/device.event-reporter.js +0 -165
- package/dist/modules/dev/dev-server/inspector/device.js +0 -577
- package/dist/modules/dev/dev-server/inspector/inspector.js +0 -204
- package/dist/modules/dev/dev-server/inspector/types.js +0 -2
- package/dist/modules/dev/dev-server/inspector/wss/servers/debugger-connection.server.js +0 -61
- package/dist/modules/dev/dev-server/inspector/wss/servers/device-connection.server.js +0 -64
- package/dist/modules/dev/dev-server/plugins/devtools.plugin.js +0 -50
- package/dist/modules/dev/dev-server/plugins/favicon.plugin.js +0 -19
- package/dist/modules/dev/dev-server/plugins/multipart.plugin.js +0 -62
- package/dist/modules/dev/dev-server/plugins/systrace.plugin.js +0 -28
- package/dist/modules/dev/dev-server/plugins/types.js +0 -2
- package/dist/modules/dev/dev-server/plugins/wss/index.js +0 -19
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-api.server.js +0 -66
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-debugger.server.js +0 -128
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-dev-client.server.js +0 -75
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-events.server.js +0 -198
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-hmr.server.js +0 -120
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-message.server.js +0 -357
- package/dist/modules/dev/dev-server/plugins/wss/types.js +0 -2
- package/dist/modules/dev/dev-server/plugins/wss/web-socket-router.js +0 -57
- package/dist/modules/dev/dev-server/plugins/wss/web-socket-server-adapter.js +0 -26
- package/dist/modules/dev/dev-server/plugins/wss/web-socket-server.js +0 -46
- package/dist/modules/dev/dev-server/plugins/wss/wss.plugin.js +0 -55
- package/dist/modules/dev/dev-server/sybmolicate/sybmolicate.plugin.js +0 -36
- package/dist/modules/dev/dev-server/sybmolicate/types.js +0 -2
- package/dist/modules/dev/terminal/base.terminal.reporter.js +0 -78
- package/dist/modules/dev/terminal/terminal.reporter.js +0 -76
- package/dist/modules/dev/types.js +0 -2
- package/dist/modules/dev/utils/log.js +0 -73
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";
|