english-lang 0.2.1 → 0.2.3

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 (2) hide show
  1. package/dist/cli/engc.js +61 -21
  2. package/package.json +1 -1
package/dist/cli/engc.js CHANGED
@@ -50,6 +50,32 @@ const fs = __importStar(require("fs"));
50
50
  const path = __importStar(require("path"));
51
51
  const childProcess = __importStar(require("child_process"));
52
52
  const index_1 = require("../index");
53
+ // ── Starter App.tsx ───────────────────────────────────────────
54
+ const STARTER_APP_TSX = `\
55
+ // App.tsx — wired up by engc init
56
+ // All screens are generated from .eng source files in screens/
57
+
58
+ import React from 'react';
59
+ import { NavigationContainer } from '@react-navigation/native';
60
+ import { createNativeStackNavigator } from '@react-navigation/native-stack';
61
+ import { SafeAreaProvider } from 'react-native-safe-area-context';
62
+
63
+ import { HomeScreen } from './src/HomeScreen';
64
+
65
+ const Stack = createNativeStackNavigator();
66
+
67
+ export default function App() {
68
+ return (
69
+ <SafeAreaProvider>
70
+ <NavigationContainer>
71
+ <Stack.Navigator initialRouteName="Home">
72
+ <Stack.Screen name="Home" component={HomeScreen} />
73
+ </Stack.Navigator>
74
+ </NavigationContainer>
75
+ </SafeAreaProvider>
76
+ );
77
+ }
78
+ `;
53
79
  // ── Starter .eng file ─────────────────────────────────────────
54
80
  const STARTER_ENG = `\
55
81
  screen HomeScreen:
@@ -78,7 +104,7 @@ screen HomeScreen:
78
104
  button "Reset"
79
105
  `;
80
106
  // ── Dev ───────────────────────────────────────────────────────
81
- function devProject(projectDir) {
107
+ function devProject(projectDir = process.cwd()) {
82
108
  const screensDir = path.join(projectDir, 'screens');
83
109
  const rnDir = path.join(projectDir, 'rn');
84
110
  const rnSrcDir = path.join(rnDir, 'src');
@@ -120,12 +146,11 @@ function initProject(name) {
120
146
  console.error(`[engc] Directory already exists: ${projectDir}`);
121
147
  process.exit(1);
122
148
  }
123
- console.log(`[engc] Creating project ${name} ...`);
124
- // Create folder structure
149
+ console.log(`[engc] Creating project ${name} ...\n`);
150
+ // Create screens folder
125
151
  const screensDir = path.join(projectDir, 'screens');
126
152
  const rnSrcDir = path.join(projectDir, 'rn', 'src');
127
153
  fs.mkdirSync(screensDir, { recursive: true });
128
- fs.mkdirSync(rnSrcDir, { recursive: true });
129
154
  // Write starter .eng file
130
155
  fs.writeFileSync(path.join(screensDir, 'HomeScreen.eng'), STARTER_ENG, 'utf8');
131
156
  console.log('[engc] Created screens/HomeScreen.eng');
@@ -144,29 +169,44 @@ function initProject(name) {
144
169
  },
145
170
  };
146
171
  fs.writeFileSync(path.join(projectDir, 'package.json'), JSON.stringify(pkg, null, 2) + '\n', 'utf8');
147
- console.log('[engc] Created package.json');
148
- // Scaffold React Native app inside rn/
149
- console.log('[engc] Scaffolding React Native app in rn/ (this takes a minute) ...');
172
+ console.log('[engc] Created package.json\n');
173
+ // Scaffold latest React Native app
174
+ console.log('[engc] Scaffolding latest React Native app in rn/ ...');
150
175
  try {
151
- childProcess.execSync('npx @react-native-community/cli init rn --skip-install', { cwd: projectDir, stdio: 'inherit' });
176
+ childProcess.execSync('npx @react-native-community/cli@latest init rn', { cwd: projectDir, stdio: 'inherit' });
152
177
  }
153
178
  catch {
154
- console.error('[engc] Failed to scaffold React Native app. Make sure Node and npx are available.');
179
+ console.error('[engc] Failed to scaffold React Native app.');
155
180
  process.exit(1);
156
181
  }
157
- // Install rn dependencies
158
- console.log('[engc] Installing React Native dependencies ...');
159
- childProcess.execSync('npm install', { cwd: path.join(projectDir, 'rn'), stdio: 'inherit' });
160
- // Compile the starter screen
161
- console.log('[engc] Compiling starter screens ...');
182
+ // Install React Navigation
183
+ const rnDir = path.join(projectDir, 'rn');
184
+ console.log('\n[engc] Installing React Navigation ...');
185
+ childProcess.execSync('npm install @react-navigation/native @react-navigation/native-stack react-native-screens react-native-safe-area-context', { cwd: rnDir, stdio: 'inherit' });
186
+ // Patch App.tsx to import the compiled HomeScreen
187
+ fs.writeFileSync(path.join(rnDir, 'App.tsx'), STARTER_APP_TSX, 'utf8');
188
+ console.log('[engc] Patched rn/App.tsx');
189
+ // Pod install for iOS
190
+ const iosDir = path.join(rnDir, 'ios');
191
+ if (fs.existsSync(iosDir)) {
192
+ console.log('\n[engc] Installing iOS CocoaPods ...');
193
+ try {
194
+ childProcess.execSync('bundle install && bundle exec pod install', {
195
+ cwd: iosDir,
196
+ stdio: 'inherit',
197
+ });
198
+ }
199
+ catch {
200
+ console.warn('[engc] Pod install failed — run it manually: cd rn/ios && pod install');
201
+ }
202
+ }
203
+ // Compile starter screens into rn/src/
204
+ fs.mkdirSync(rnSrcDir, { recursive: true });
205
+ console.log('\n[engc] Compiling starter screens ...');
162
206
  compileDir(screensDir, rnSrcDir);
163
- console.log(`
164
- [engc] Done! Your project is ready.
165
-
166
- cd ${name}
167
- npm run dev ← starts Metro + watches .eng files
168
- cd rn && npx react-native run-ios
169
- `);
207
+ console.log('\n[engc] All done! Starting Metro + eng watcher ...\n');
208
+ // Auto-start dev mode immediately
209
+ devProject(projectDir);
170
210
  }
171
211
  // ── Compile helpers ───────────────────────────────────────────
172
212
  function compileFile(inputPath, outDir) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "english-lang",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "The English (.eng) programming language compiler",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {