@teardown/cli 2.0.65 → 2.0.66

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teardown/cli",
3
- "version": "2.0.65",
3
+ "version": "2.0.66",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -71,7 +71,7 @@
71
71
  },
72
72
  "devDependencies": {
73
73
  "@biomejs/biome": "2.3.11",
74
- "@teardown/tsconfig": "2.0.65",
74
+ "@teardown/tsconfig": "2.0.66",
75
75
  "@types/bun": "1.3.5",
76
76
  "@types/ejs": "^3.1.5",
77
77
  "typescript": "5.9.3"
@@ -144,7 +144,7 @@ export class TemplateGenerator {
144
144
  * Check if src folder exists
145
145
  */
146
146
  async srcFolderExists(): Promise<boolean> {
147
- const srcPath = join(this.options.projectRoot, "src", "index.ts");
147
+ const srcPath = join(this.options.projectRoot, "src");
148
148
  try {
149
149
  await stat(srcPath);
150
150
  return true;
@@ -180,63 +180,87 @@ export class TemplateGenerator {
180
180
  "tsconfig.json",
181
181
  "babel.config.js",
182
182
  "metro.config.js",
183
- "index.js",
184
- "index.ts",
183
+ "index.tsx",
185
184
  "react-native.config.js",
186
185
  "Gemfile",
187
186
  ];
188
187
 
189
188
  for (const file of configFiles) {
190
- const templatePath = join(getTemplatesPath(), file);
191
- const outputPath = join(this.options.projectRoot, file);
189
+ const fileResult = await this.processConfigFile(file);
190
+ if (fileResult.created) {
191
+ result.filesCreated.push(fileResult.path);
192
+ } else if (fileResult.skipped) {
193
+ result.filesSkipped.push(fileResult.path);
194
+ } else if (fileResult.error) {
195
+ result.errors.push(fileResult.error);
196
+ }
197
+ }
192
198
 
193
- try {
194
- // Check if template file exists
195
- try {
196
- await stat(templatePath);
197
- } catch {
198
- // Template doesn't exist, skip
199
- continue;
200
- }
199
+ if (result.errors.length > 0) {
200
+ result.success = false;
201
+ }
201
202
 
202
- // Check if output file already exists
203
- if (!this.options.force) {
204
- try {
205
- await stat(outputPath);
206
- result.filesSkipped.push(outputPath);
207
- this.logger?.debug(`${file} already exists, skipping`);
208
- continue;
209
- } catch {
210
- // File doesn't exist, continue
211
- }
212
- }
203
+ return result;
204
+ }
213
205
 
214
- const content = await readFile(templatePath, "utf-8");
215
- let processedContent = content;
206
+ /**
207
+ * Process a single config file from template
208
+ */
209
+ private async processConfigFile(
210
+ file: string
211
+ ): Promise<{ path: string; created?: boolean; skipped?: boolean; error?: string }> {
212
+ const templatePath = join(getTemplatesPath(), file);
213
+ const outputPath = join(this.options.projectRoot, file);
214
+
215
+ // Check if template file exists
216
+ if (!(await this.fileExists(templatePath))) {
217
+ return { path: outputPath };
218
+ }
216
219
 
217
- // Process EJS if the file contains EJS tags
218
- if (content.includes("<%=") || content.includes("<%")) {
219
- processedContent = ejs.render(content, this.options.variables, {
220
- filename: templatePath,
221
- });
222
- }
220
+ // Check if output file already exists
221
+ if (!this.options.force && (await this.fileExists(outputPath))) {
222
+ this.logger?.debug(`${file} already exists, skipping`);
223
+ return { path: outputPath, skipped: true };
224
+ }
223
225
 
224
- if (!this.options.dryRun) {
225
- await writeFile(outputPath, processedContent, "utf-8");
226
- }
226
+ try {
227
+ const content = await readFile(templatePath, "utf-8");
228
+ const processedContent = this.processEjsContent(content, templatePath);
227
229
 
228
- result.filesCreated.push(outputPath);
229
- this.logger?.debug(`Created: ${outputPath}`);
230
- } catch (error) {
231
- result.errors.push(`Failed to generate ${file}: ${error instanceof Error ? error.message : String(error)}`);
230
+ if (!this.options.dryRun) {
231
+ await writeFile(outputPath, processedContent, "utf-8");
232
232
  }
233
+
234
+ this.logger?.debug(`Created: ${outputPath}`);
235
+ return { path: outputPath, created: true };
236
+ } catch (error) {
237
+ return {
238
+ path: outputPath,
239
+ error: `Failed to generate ${file}: ${error instanceof Error ? error.message : String(error)}`,
240
+ };
233
241
  }
242
+ }
234
243
 
235
- if (result.errors.length > 0) {
236
- result.success = false;
244
+ /**
245
+ * Check if a file exists
246
+ */
247
+ private async fileExists(filePath: string): Promise<boolean> {
248
+ try {
249
+ await stat(filePath);
250
+ return true;
251
+ } catch {
252
+ return false;
237
253
  }
254
+ }
238
255
 
239
- return result;
256
+ /**
257
+ * Process EJS content if it contains EJS tags
258
+ */
259
+ private processEjsContent(content: string, templatePath: string): string {
260
+ if (content.includes("<%=") || content.includes("<%")) {
261
+ return ejs.render(content, this.options.variables, { filename: templatePath });
262
+ }
263
+ return content;
240
264
  }
241
265
 
242
266
  /**
@@ -6,8 +6,9 @@
6
6
  */
7
7
 
8
8
  import { DevClientProvider } from "@teardown/dev-client";
9
- import { devClientConfig } from "../dev-client.config";
10
- import { App } from "./app";
9
+ import { AppRegistry } from "react-native";
10
+ import { devClientConfig } from "./dev-client.config";
11
+ import { App } from "./src/app";
11
12
 
12
13
  /**
13
14
  * Root component with development client wrapper
@@ -19,3 +20,5 @@ export function Root() {
19
20
  </DevClientProvider>
20
21
  );
21
22
  }
23
+
24
+ AppRegistry.registerComponent("<%= appName %>", () => Root);
@@ -1,11 +0,0 @@
1
- /**
2
- * App Entry Point
3
- *
4
- * This file registers the root component with React Native's AppRegistry.
5
- * The app is wrapped with DevClientProvider for development tools.
6
- */
7
-
8
- import { AppRegistry } from "react-native";
9
- import { Root } from "./src";
10
-
11
- AppRegistry.registerComponent("<%= appName %>", () => Root);