create-lunar-kit 0.1.2 → 0.1.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/index.js +65 -74
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,12 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // ../../node_modules/.pnpm/tsup@8.5.1_jiti@1.21.7_postcss@8.4.49_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/esm_shims.js
4
- import path from "path";
5
- import { fileURLToPath } from "url";
6
- var getFilename = () => fileURLToPath(import.meta.url);
7
- var getDirname = () => path.dirname(getFilename());
8
- var __dirname = /* @__PURE__ */ getDirname();
9
-
10
3
  // src/index.ts
11
4
  import { Command } from "commander";
12
5
  import prompts from "prompts";
@@ -14,8 +7,8 @@ import chalk3 from "chalk";
14
7
  import ora from "ora";
15
8
  import { execa } from "execa";
16
9
  import fs2 from "fs-extra";
17
- import path3 from "path";
18
- import { fileURLToPath as fileURLToPath2 } from "url";
10
+ import path2 from "path";
11
+ import { fileURLToPath } from "url";
19
12
 
20
13
  // src/assets/logo.ts
21
14
  import chalk from "chalk";
@@ -64,9 +57,8 @@ var renderLogo = () => {
64
57
 
65
58
  // src/commands/init.ts
66
59
  import fs from "fs-extra";
67
- import path2 from "path";
68
- var COMPONENTS_SOURCE = path2.join(__dirname, "../..", "src", "components");
69
- var SOURCE = path2.join(__dirname, "../..", "src");
60
+ import path from "path";
61
+ import { LOCAL_COMPONENTS_PATH, LOCAL_SOURCE_PATH } from "@lunar-kit/core";
70
62
  async function createSrcStructure(projectPath, navigation) {
71
63
  const dirs = [
72
64
  "src/modules",
@@ -78,42 +70,42 @@ async function createSrcStructure(projectPath, navigation) {
78
70
  "src/types"
79
71
  ];
80
72
  for (const dir of dirs) {
81
- await fs.ensureDir(path2.join(projectPath, dir));
73
+ await fs.ensureDir(path.join(projectPath, dir));
82
74
  }
83
- await createBarrelExport(path2.join(projectPath, "src/components"), "index.ts");
84
- await createBarrelExport(path2.join(projectPath, "src/hooks"), "index.ts");
85
- await createBarrelExport(path2.join(projectPath, "src/stores"), "index.ts");
75
+ await createBarrelExport(path.join(projectPath, "src/components"), "index.ts");
76
+ await createBarrelExport(path.join(projectPath, "src/hooks"), "index.ts");
77
+ await createBarrelExport(path.join(projectPath, "src/stores"), "index.ts");
86
78
  }
87
79
  async function createBarrelExport(dir, filename) {
88
80
  const content = `// Auto-generated barrel export
89
81
  // This file is managed by Lunar Kit CLI
90
82
  `;
91
- await fs.writeFile(path2.join(dir, filename), content);
83
+ await fs.writeFile(path.join(dir, filename), content);
92
84
  }
93
85
  async function setupAppEntry(projectPath, navigation) {
94
86
  if (navigation === "expo-router") {
95
- const appTsxPath = path2.join(projectPath, "App.tsx");
87
+ const appTsxPath = path.join(projectPath, "App.tsx");
96
88
  if (fs.existsSync(appTsxPath)) {
97
89
  await fs.remove(appTsxPath);
98
90
  }
99
- const indexPath = path2.join(projectPath, "index.ts");
91
+ const indexPath = path.join(projectPath, "index.ts");
100
92
  if (fs.existsSync(indexPath)) {
101
93
  await fs.remove(indexPath);
102
94
  }
103
- const indexJsPath = path2.join(projectPath, "index.js");
95
+ const indexJsPath = path.join(projectPath, "index.js");
104
96
  if (fs.existsSync(indexJsPath)) {
105
97
  await fs.remove(indexJsPath);
106
98
  }
107
- const pkgPath = path2.join(projectPath, "package.json");
99
+ const pkgPath = path.join(projectPath, "package.json");
108
100
  const pkg = await fs.readJson(pkgPath);
109
101
  pkg.main = "expo-router/entry";
110
102
  await fs.writeJson(pkgPath, pkg, { spaces: 2 });
111
103
  } else {
112
- const indexPath = path2.join(projectPath, "index.ts");
104
+ const indexPath = path.join(projectPath, "index.ts");
113
105
  if (fs.existsSync(indexPath)) {
114
106
  await fs.remove(indexPath);
115
107
  }
116
- const indexJsPath = path2.join(projectPath, "index.js");
108
+ const indexJsPath = path.join(projectPath, "index.js");
117
109
  if (fs.existsSync(indexJsPath)) {
118
110
  await fs.remove(indexJsPath);
119
111
  }
@@ -122,14 +114,14 @@ async function setupAppEntry(projectPath, navigation) {
122
114
  export default function App() {
123
115
  return <Main />;
124
116
  }`;
125
- await fs.writeFile(path2.join(projectPath, "App.tsx"), appContent);
126
- const pkgPath = path2.join(projectPath, "package.json");
117
+ await fs.writeFile(path.join(projectPath, "App.tsx"), appContent);
118
+ const pkgPath = path.join(projectPath, "package.json");
127
119
  const pkg = await fs.readJson(pkgPath);
128
120
  if (pkg.main) {
129
121
  delete pkg.main;
130
122
  }
131
123
  await fs.writeJson(pkgPath, pkg, { spaces: 2 });
132
- const appJsonPath = path2.join(projectPath, "app.json");
124
+ const appJsonPath = path.join(projectPath, "app.json");
133
125
  if (fs.existsSync(appJsonPath)) {
134
126
  const appJson = await fs.readJson(appJsonPath);
135
127
  if (!appJson.expo) {
@@ -159,11 +151,11 @@ export default function Main() {
159
151
  </View>
160
152
  );
161
153
  }`;
162
- await fs.writeFile(path2.join(projectPath, "src", "Main.tsx"), mainContent);
154
+ await fs.writeFile(path.join(projectPath, "src", "Main.tsx"), mainContent);
163
155
  }
164
156
  }
165
157
  async function setupExpoRouterSrc(projectPath) {
166
- const appDir = path2.join(projectPath, "app");
158
+ const appDir = path.join(projectPath, "app");
167
159
  await fs.ensureDir(appDir);
168
160
  const layoutContent = `import React from 'react';
169
161
  import '../src/global.css';
@@ -189,7 +181,7 @@ export default function RootLayout() {
189
181
  </GestureHandlerRootView>
190
182
  );
191
183
  }`;
192
- await fs.writeFile(path2.join(appDir, "_layout.tsx"), layoutContent);
184
+ await fs.writeFile(path.join(appDir, "_layout.tsx"), layoutContent);
193
185
  const indexContent = `import React from 'react';
194
186
  import { View, Text } from 'react-native';
195
187
  import { Button } from '@/components/ui/button';
@@ -209,7 +201,7 @@ export default function IndexScreen() {
209
201
  </View>
210
202
  );
211
203
  }`;
212
- await fs.writeFile(path2.join(appDir, "index.tsx"), indexContent);
204
+ await fs.writeFile(path.join(appDir, "index.tsx"), indexContent);
213
205
  }
214
206
  async function setupReactNavigationSrc(projectPath) {
215
207
  const navContent = `import { NavigationContainer } from '@react-navigation/native';
@@ -227,7 +219,7 @@ export default function Navigation() {
227
219
  </NavigationContainer>
228
220
  );
229
221
  }`;
230
- await fs.writeFile(path2.join(projectPath, "src", "Navigation.tsx"), navContent);
222
+ await fs.writeFile(path.join(projectPath, "src", "Navigation.tsx"), navContent);
231
223
  const homeContent = `import React from 'react';
232
224
  import { View, Text } from 'react-native';
233
225
  import { Button } from '../components/ui/button';
@@ -247,7 +239,7 @@ export default function HomeScreen() {
247
239
  </View>
248
240
  );
249
241
  }`;
250
- await fs.writeFile(path2.join(projectPath, "src", "screens", "HomeScreen.tsx"), homeContent);
242
+ await fs.writeFile(path.join(projectPath, "src", "screens", "HomeScreen.tsx"), homeContent);
251
243
  const mainContent = `import React from 'react';
252
244
  import './global.css';
253
245
  import { StatusBar } from 'expo-status-bar';
@@ -261,10 +253,10 @@ export default function Main() {
261
253
  </>
262
254
  );
263
255
  }`;
264
- await fs.writeFile(path2.join(projectPath, "src", "Main.tsx"), mainContent);
256
+ await fs.writeFile(path.join(projectPath, "src", "Main.tsx"), mainContent);
265
257
  }
266
258
  async function setupAuthSrc(projectPath, navigation) {
267
- const authDir = navigation === "expo-router" ? path2.join(projectPath, "app", "(auth)") : path2.join(projectPath, "src", "screens", "auth");
259
+ const authDir = navigation === "expo-router" ? path.join(projectPath, "app", "(auth)") : path.join(projectPath, "src", "screens", "auth");
268
260
  await fs.ensureDir(authDir);
269
261
  const loginScreen = `import { View, Text } from 'react-native';
270
262
  import { Button } from '@/src/components/ui/button';
@@ -277,16 +269,16 @@ export default function LoginScreen() {
277
269
  </View>
278
270
  );
279
271
  }`;
280
- await fs.writeFile(path2.join(authDir, "login.tsx"), loginScreen);
272
+ await fs.writeFile(path.join(authDir, "login.tsx"), loginScreen);
281
273
  }
282
274
  async function setupDarkModeSrc(projectPath, navigation) {
283
275
  const themeProvider = fs.readFileSync(
284
- path2.join(SOURCE, "providers", "theme-provider.tsx")
276
+ path.join(LOCAL_SOURCE_PATH, "providers", "theme-provider.tsx")
285
277
  );
286
278
  const themeStore = fs.readFileSync(
287
- path2.join(SOURCE, "stores", "theme.ts")
279
+ path.join(LOCAL_SOURCE_PATH, "stores", "theme.ts")
288
280
  );
289
- const storesIndexPath = path2.join(projectPath, "src", "stores", "index.ts");
281
+ const storesIndexPath = path.join(projectPath, "src", "stores", "index.ts");
290
282
  let storesIndexContent = `// Auto-generated barrel export
291
283
  // This file is managed by Lunar Kit CLI
292
284
  `;
@@ -296,32 +288,32 @@ async function setupDarkModeSrc(projectPath, navigation) {
296
288
  let toolbarContent;
297
289
  if (navigation === "expo-router") {
298
290
  toolbarContent = fs.readFileSync(
299
- path2.join(SOURCE, "hooks", "useToolbar.tsx")
291
+ path.join(LOCAL_SOURCE_PATH, "hooks", "useToolbar.tsx")
300
292
  );
301
293
  } else {
302
294
  toolbarContent = fs.readFileSync(
303
- path2.join(SOURCE, "hooks", "useToolbar.react-navigation.tsx")
295
+ path.join(LOCAL_SOURCE_PATH, "hooks", "useToolbar.react-navigation.tsx")
304
296
  );
305
297
  }
306
298
  const themeContent = fs.readFileSync(
307
- path2.join(SOURCE, "hooks", "useTheme.ts")
299
+ path.join(LOCAL_SOURCE_PATH, "hooks", "useTheme.ts")
308
300
  );
309
301
  const themeColor = fs.readFileSync(
310
- path2.join(SOURCE, "hooks", "useThemeColors.ts")
302
+ path.join(LOCAL_SOURCE_PATH, "hooks", "useThemeColors.ts")
311
303
  );
312
304
  const libTheme = fs.readFileSync(
313
- path2.join(SOURCE, "lib", "theme.ts")
305
+ path.join(LOCAL_SOURCE_PATH, "lib", "theme.ts")
314
306
  );
315
- await fs.ensureDir(path2.join(projectPath, "src", "providers"));
316
- await fs.writeFile(path2.join(projectPath, "src", "providers", "theme-provider.tsx"), themeProvider);
317
- await fs.ensureDir(path2.join(projectPath, "src", "stores"));
318
- await fs.writeFile(path2.join(projectPath, "src", "stores", "theme.ts"), themeStore);
319
- await fs.ensureDir(path2.join(projectPath, "src", "hooks"));
320
- await fs.writeFile(path2.join(projectPath, "src", "hooks", "useToolbar.tsx"), toolbarContent);
321
- await fs.writeFile(path2.join(projectPath, "src", "hooks", "useTheme.ts"), themeContent);
322
- await fs.writeFile(path2.join(projectPath, "src", "hooks", "useThemeColors.ts"), themeColor);
323
- await fs.ensureDir(path2.join(projectPath, "src", "lib"));
324
- await fs.writeFile(path2.join(projectPath, "src", "lib", "theme.ts"), libTheme);
307
+ await fs.ensureDir(path.join(projectPath, "src", "providers"));
308
+ await fs.writeFile(path.join(projectPath, "src", "providers", "theme-provider.tsx"), themeProvider);
309
+ await fs.ensureDir(path.join(projectPath, "src", "stores"));
310
+ await fs.writeFile(path.join(projectPath, "src", "stores", "theme.ts"), themeStore);
311
+ await fs.ensureDir(path.join(projectPath, "src", "hooks"));
312
+ await fs.writeFile(path.join(projectPath, "src", "hooks", "useToolbar.tsx"), toolbarContent);
313
+ await fs.writeFile(path.join(projectPath, "src", "hooks", "useTheme.ts"), themeContent);
314
+ await fs.writeFile(path.join(projectPath, "src", "hooks", "useThemeColors.ts"), themeColor);
315
+ await fs.ensureDir(path.join(projectPath, "src", "lib"));
316
+ await fs.writeFile(path.join(projectPath, "src", "lib", "theme.ts"), libTheme);
325
317
  }
326
318
  async function setupFormsSrc(projectPath) {
327
319
  const hookContent = `import { useState } from 'react';
@@ -350,17 +342,17 @@ export function useForm<T>(initialValues: T) {
350
342
 
351
343
  return { values, errors, handleChange, validate };
352
344
  }`;
353
- await fs.writeFile(path2.join(projectPath, "src", "hooks", "useForm.ts"), hookContent);
345
+ await fs.writeFile(path.join(projectPath, "src", "hooks", "useForm.ts"), hookContent);
354
346
  }
355
347
  async function setupNativeWind(projectPath) {
356
348
  const globalCss = `@tailwind base;
357
349
  @tailwind components;
358
350
  @tailwind utilities;`;
359
- await fs.writeFile(path2.join(projectPath, "src", "global.css"), globalCss);
351
+ await fs.writeFile(path.join(projectPath, "src", "global.css"), globalCss);
360
352
  const tailwindConfig = fs.readFileSync(
361
- path2.join(SOURCE, "tailwind.config.js")
353
+ path.join(LOCAL_SOURCE_PATH, "tailwind.config.js")
362
354
  );
363
- await fs.writeFile(path2.join(projectPath, "tailwind.config.js"), tailwindConfig);
355
+ await fs.writeFile(path.join(projectPath, "tailwind.config.js"), tailwindConfig);
364
356
  const metroConfig = `const { getDefaultConfig } = require('expo/metro-config');
365
357
  const { withNativeWind } = require('nativewind/metro');
366
358
 
@@ -369,7 +361,7 @@ const config = getDefaultConfig(__dirname);
369
361
  module.exports = withNativeWind(config, {
370
362
  input: './src/global.css',
371
363
  });`;
372
- await fs.writeFile(path2.join(projectPath, "metro.config.js"), metroConfig);
364
+ await fs.writeFile(path.join(projectPath, "metro.config.js"), metroConfig);
373
365
  const babelConfig = `module.exports = function (api) {
374
366
  api.cache(true);
375
367
  return {
@@ -379,25 +371,25 @@ module.exports = withNativeWind(config, {
379
371
  ],
380
372
  };
381
373
  };`;
382
- await fs.writeFile(path2.join(projectPath, "babel.config.js"), babelConfig);
374
+ await fs.writeFile(path.join(projectPath, "babel.config.js"), babelConfig);
383
375
  const nativewindEnv = `/// <reference types="nativewind/types" />`;
384
- await fs.writeFile(path2.join(projectPath, "nativewind-env.d.ts"), nativewindEnv);
376
+ await fs.writeFile(path.join(projectPath, "nativewind-env.d.ts"), nativewindEnv);
385
377
  const utilsContent = fs.readFileSync(
386
- path2.join(SOURCE, "lib", "utils.ts")
378
+ path.join(LOCAL_SOURCE_PATH, "lib", "utils.ts")
387
379
  );
388
380
  const colorsContent = fs.readFileSync(
389
- path2.join(SOURCE, "lib", "theme.ts")
381
+ path.join(LOCAL_SOURCE_PATH, "lib", "theme.ts")
390
382
  );
391
- await fs.writeFile(path2.join(projectPath, "src", "lib", "utils.ts"), utilsContent);
392
- await fs.writeFile(path2.join(projectPath, "src", "lib", "theme.ts"), colorsContent);
383
+ await fs.writeFile(path.join(projectPath, "src", "lib", "utils.ts"), utilsContent);
384
+ await fs.writeFile(path.join(projectPath, "src", "lib", "theme.ts"), colorsContent);
393
385
  const buttonContent = fs.readFileSync(
394
- path2.join(COMPONENTS_SOURCE, "ui", "button.tsx")
386
+ path.join(LOCAL_COMPONENTS_PATH, "ui", "button.tsx")
395
387
  );
396
388
  const textContent = fs.readFileSync(
397
- path2.join(COMPONENTS_SOURCE, "ui", "text.tsx")
389
+ path.join(LOCAL_COMPONENTS_PATH, "ui", "text.tsx")
398
390
  );
399
- await fs.writeFile(path2.join(projectPath, "src", "components", "ui", "button.tsx"), buttonContent);
400
- await fs.writeFile(path2.join(projectPath, "src", "components", "ui", "text.tsx"), textContent);
391
+ await fs.writeFile(path.join(projectPath, "src", "components", "ui", "button.tsx"), buttonContent);
392
+ await fs.writeFile(path.join(projectPath, "src", "components", "ui", "text.tsx"), textContent);
401
393
  const tsconfigContent = `{
402
394
  "extends": "expo/tsconfig.base",
403
395
  "compilerOptions": {
@@ -413,10 +405,10 @@ module.exports = withNativeWind(config, {
413
405
  }
414
406
  }
415
407
  }`;
416
- await fs.writeFile(path2.join(projectPath, "tsconfig.json"), tsconfigContent);
408
+ await fs.writeFile(path.join(projectPath, "tsconfig.json"), tsconfigContent);
417
409
  }
418
410
  async function updatePackageJson(projectPath, navigation, features) {
419
- const pkgPath = path2.join(projectPath, "package.json");
411
+ const pkgPath = path.join(projectPath, "package.json");
420
412
  const pkg = await fs.readJson(pkgPath);
421
413
  pkg.dependencies = {
422
414
  ...pkg.dependencies,
@@ -468,7 +460,6 @@ async function createConfig(projectPath, navigation, features, packageManager) {
468
460
  storesDir: "src/stores",
469
461
  uiComponentsDir: "src/components/ui",
470
462
  packageManager,
471
- // DONE: Add this
472
463
  namingConvention: {
473
464
  files: "snake_case",
474
465
  exports: "PascalCase",
@@ -478,7 +469,7 @@ async function createConfig(projectPath, navigation, features, packageManager) {
478
469
  autoImport: true,
479
470
  autoBarrelExport: true
480
471
  };
481
- await fs.writeJson(path2.join(projectPath, "kit.config.json"), config, { spaces: 2 });
472
+ await fs.writeJson(path.join(projectPath, "kit.config.json"), config, { spaces: 2 });
482
473
  }
483
474
 
484
475
  // src/res/close.ts
@@ -505,7 +496,7 @@ function closeInitProject(packageManager, name) {
505
496
  }
506
497
 
507
498
  // src/index.ts
508
- var __filename2 = fileURLToPath2(import.meta.url);
499
+ var __filename2 = fileURLToPath(import.meta.url);
509
500
  var program = new Command();
510
501
  program.name("create-lunar-kit").description("Create a new React Native app with Lunar Kit").argument("[project-name]", "Name of your project").action(async (projectName) => {
511
502
  renderLogo();
@@ -559,7 +550,7 @@ program.name("create-lunar-kit").description("Create a new React Native app with
559
550
  console.log(chalk3.red("Project name is required"));
560
551
  process.exit(1);
561
552
  }
562
- const projectPath = path3.join(process.cwd(), name);
553
+ const projectPath = path2.join(process.cwd(), name);
563
554
  if (fs2.existsSync(projectPath)) {
564
555
  console.log(chalk3.red(`Directory ${name} already exists`));
565
556
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-lunar-kit",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Create a new React Native app with Lunar Kit and NativeWind pre-configured",
5
5
  "author": "Your Name",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "starter"
25
25
  ],
26
26
  "dependencies": {
27
- "@lunar-kit/core": "0.1.0",
27
+ "@lunar-kit/core": "0.1.2",
28
28
  "chalk": "^5.4.1",
29
29
  "commander": "^12.1.0",
30
30
  "execa": "^9.6.1",