setup-nativewind 1.0.0 → 1.1.1

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/README.md CHANGED
@@ -9,17 +9,19 @@ npx setup-nativewind
9
9
 
10
10
  ## What it does
11
11
 
12
- - ✅ Detects your project type (Expo managed, Expo bare, React Native CLI)
12
+ - ✅ Auto detects your project type (Expo managed, Expo bare, React Native CLI)
13
+ - ✅ Auto detects JavaScript or TypeScript
13
14
  - ✅ Installs `nativewind` and `tailwindcss` automatically
14
- - ✅ Creates `tailwind.config.js`, `babel.config.js`, `global.css` and other required files
15
+ - ✅ Creates all required config files
16
+ - ✅ Creates `nativewind-env.d.ts` for TypeScript projects
15
17
 
16
18
  ## Supported Project Types
17
19
 
18
- | Project Type | Supported |
19
- |---|---|
20
- | Expo Managed | ✅ |
21
- | Expo Bare | ✅ |
22
- | React Native CLI | ✅ |
20
+ | Project Type | JavaScript | TypeScript |
21
+ |---|---|---|
22
+ | Expo Managed | ✅ | ✅ |
23
+ | Expo Bare | ✅ | ✅ |
24
+ | React Native CLI | ✅ | ✅ |
23
25
 
24
26
  ## Requirements
25
27
 
@@ -28,31 +30,4 @@ npx setup-nativewind
28
30
 
29
31
  ## License
30
32
 
31
- MIT
32
- ```
33
-
34
- ---
35
-
36
- ## LICENSE
37
- ```
38
- MIT License
39
-
40
- Copyright (c) 2025 Farhan
41
-
42
- Permission is hereby granted, free of charge, to any person obtaining a copy
43
- of this software and associated documentation files (the "Software"), to deal
44
- in the Software without restriction, including without limitation the rights
45
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
46
- copies of the Software, and to permit persons to whom the Software is
47
- furnished to do so, subject to the following conditions:
48
-
49
- The above copyright notice and this permission notice shall be included in all
50
- copies or substantial portions of the Software.
51
-
52
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
55
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
58
- SOFTWARE.
33
+ MIT
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "setup-nativewind",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "One command NativeWind setup for Expo and React Native",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
7
7
  "bin": {
8
- "setup-nativewind": "./bin/index.js"
8
+ "setup-nativewind": "bin/index.js"
9
9
  },
10
10
  "files": [
11
11
  "bin",
@@ -19,15 +19,15 @@
19
19
  "cli",
20
20
  "setup"
21
21
  ],
22
- "author": "Your Name <you@email.com>",
22
+ "author": "Farhan <farhan104757@gmail.com>",
23
23
  "license": "MIT",
24
24
  "repository": {
25
25
  "type": "git",
26
- "url": "https://github.com/YOUR_USERNAME/setup-nativewind.git"
26
+ "url": "git+https://github.com/FarhanCodeSpace/setup-nativewind.git"
27
27
  },
28
- "homepage": "https://github.com/YOUR_USERNAME/setup-nativewind#readme",
28
+ "homepage": "https://github.com/FarhanCodeSpace/setup-nativewind#readme",
29
29
  "bugs": {
30
- "url": "https://github.com/YOUR_USERNAME/setup-nativewind/issues"
30
+ "url": "https://github.com/FarhanCodeSpace/setup-nativewind/issues"
31
31
  },
32
32
  "dependencies": {
33
33
  "chalk": "^5.3.0",
@@ -36,4 +36,4 @@
36
36
  "ora": "^7.0.1",
37
37
  "prompts": "^2.4.2"
38
38
  }
39
- }
39
+ }
package/src/detector.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import fs from 'fs-extra';
2
2
  import path from 'path';
3
+ import prompts from 'prompts';
3
4
 
4
- export function detectProjectType() {
5
+ export async function detectProjectType() {
5
6
  const pkgPath = path.join(process.cwd(), 'package.json');
6
7
 
7
8
  if (!fs.existsSync(pkgPath)) {
@@ -14,17 +15,30 @@ export function detectProjectType() {
14
15
  ...pkg.devDependencies,
15
16
  };
16
17
 
18
+ // Ask user for language
19
+ const { language } = await prompts({
20
+ type: 'select',
21
+ name: 'language',
22
+ message: 'Is your project JavaScript or TypeScript?',
23
+ choices: [
24
+ { title: 'JavaScript', value: 'js' },
25
+ { title: 'TypeScript', value: 'ts' },
26
+ ],
27
+ });
28
+
29
+ const isTypeScript = language === 'ts';
30
+
17
31
  if (deps['expo']) {
18
- // Check if it's bare or managed
19
- if (fs.existsSync(path.join(process.cwd(), 'android')) ||
20
- fs.existsSync(path.join(process.cwd(), 'ios'))) {
21
- return 'expo-bare';
22
- }
23
- return 'expo-managed';
32
+ const isBare =
33
+ fs.existsSync(path.join(process.cwd(), 'android')) ||
34
+ fs.existsSync(path.join(process.cwd(), 'ios'));
35
+
36
+ if (isBare) return isTypeScript ? 'expo-bare-ts' : 'expo-bare';
37
+ return isTypeScript ? 'expo-managed-ts' : 'expo-managed';
24
38
  }
25
39
 
26
40
  if (deps['react-native']) {
27
- return 'rn-cli';
41
+ return isTypeScript ? 'rn-cli-ts' : 'rn-cli';
28
42
  }
29
43
 
30
44
  throw new Error('Could not detect project type. Make sure you are in a React Native or Expo project.');
package/src/fileWriter.js CHANGED
@@ -7,7 +7,6 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
7
  export async function writeConfigFiles(projectType) {
8
8
  const templateDir = path.join(__dirname, 'templates', projectType);
9
9
  const targetDir = process.cwd();
10
-
11
10
  const files = fs.readdirSync(templateDir);
12
11
 
13
12
  for (const file of files) {
@@ -15,7 +14,7 @@ export async function writeConfigFiles(projectType) {
15
14
  const dest = path.join(targetDir, file);
16
15
 
17
16
  if (fs.existsSync(dest)) {
18
- console.warn(`⚠️ Skipping ${file} — already exists`);
17
+ console.log(`⚠️ Skipping ${file} — already exists`);
19
18
  continue;
20
19
  }
21
20
 
package/src/index.js CHANGED
@@ -9,12 +9,14 @@ async function run() {
9
9
 
10
10
  // Step 1: Detect project
11
11
  let projectType;
12
- const detectSpinner = ora('Detecting project type...').start();
13
12
  try {
14
- projectType = detectProjectType();
15
- detectSpinner.succeed(`Detected: ${chalk.green(projectType)}`);
13
+ projectType = await detectProjectType();
14
+ const isTS = projectType.includes('ts');
15
+ console.log(
16
+ `✔ Detected: ${chalk.green(projectType)} ${isTS ? chalk.blue('(TypeScript)') : chalk.yellow('(JavaScript)')}`
17
+ );
16
18
  } catch (err) {
17
- detectSpinner.fail(err.message);
19
+ console.error(chalk.red('✖ ' + err.message));
18
20
  process.exit(1);
19
21
  }
20
22
 
@@ -31,10 +33,11 @@ async function run() {
31
33
  // Step 3: Write config files
32
34
  const fileSpinner = ora('Creating config files...').start();
33
35
  try {
36
+ fileSpinner.stop(); // stop before logging individual files
34
37
  await writeConfigFiles(projectType);
35
- fileSpinner.succeed('Config files created');
38
+ console.log(chalk.green('Config files created'));
36
39
  } catch (err) {
37
- fileSpinner.fail('File creation failed: ' + err.message);
40
+ console.error(chalk.red('File creation failed: ' + err.message));
38
41
  process.exit(1);
39
42
  }
40
43
 
@@ -42,7 +45,11 @@ async function run() {
42
45
  console.log(chalk.bold.green('\n✅ NativeWind setup complete!\n'));
43
46
  console.log(chalk.yellow('Next steps:'));
44
47
  console.log(' 1. Import global.css in your root layout');
45
- console.log(' 2. Start using Tailwind classes in your components\n');
48
+ console.log(' 2. Start using Tailwind classes in your components');
49
+ if (projectType.includes('ts')) {
50
+ console.log(' 3. nativewind-env.d.ts has been created for TypeScript support ✅');
51
+ }
52
+ console.log('');
46
53
  }
47
54
 
48
- run();
55
+ run();
package/src/installer.js CHANGED
@@ -1,9 +1,12 @@
1
1
  import { execSync } from 'child_process';
2
2
 
3
3
  const packages = {
4
- 'expo-managed': 'nativewind tailwindcss',
5
- 'expo-bare': 'nativewind tailwindcss',
6
- 'rn-cli': 'nativewind tailwindcss react-native-reanimated react-native-safe-area-context',
4
+ 'expo-managed': 'nativewind tailwindcss',
5
+ 'expo-managed-ts': 'nativewind tailwindcss',
6
+ 'expo-bare': 'nativewind tailwindcss',
7
+ 'expo-bare-ts': 'nativewind tailwindcss',
8
+ 'rn-cli': 'nativewind tailwindcss react-native-reanimated react-native-safe-area-context',
9
+ 'rn-cli-ts': 'nativewind tailwindcss react-native-reanimated react-native-safe-area-context',
7
10
  };
8
11
 
9
12
  export function installDependencies(projectType) {
@@ -0,0 +1,9 @@
1
+ module.exports = function (api) {
2
+ api.cache(true);
3
+ return {
4
+ presets: [
5
+ ["babel-preset-expo", { jsxImportSource: "nativewind" }],
6
+ "nativewind/babel",
7
+ ],
8
+ };
9
+ };
@@ -0,0 +1,3 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
@@ -0,0 +1,6 @@
1
+ const { getDefaultConfig } = require("expo/metro-config");
2
+ const { withNativeWind } = require("nativewind/metro");
3
+
4
+ const config = getDefaultConfig(__dirname);
5
+
6
+ module.exports = withNativeWind(config, { input: "./global.css" });
@@ -0,0 +1 @@
1
+ /// <reference types="nativewind/types" />
@@ -0,0 +1,11 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: [
4
+ "./app/**/*.{js,jsx,ts,tsx}",
5
+ "./components/**/*.{js,jsx,ts,tsx}",
6
+ "./src/**/*.{js,jsx,ts,tsx}"
7
+ ],
8
+ presets: [require("nativewind/preset")],
9
+ theme: { extend: {} },
10
+ plugins: [],
11
+ };
@@ -0,0 +1,9 @@
1
+ module.exports = function (api) {
2
+ api.cache(true);
3
+ return {
4
+ presets: [
5
+ ["babel-preset-expo", { jsxImportSource: "nativewind" }],
6
+ "nativewind/babel",
7
+ ],
8
+ };
9
+ };
@@ -0,0 +1,3 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
@@ -0,0 +1 @@
1
+ /// <reference types="nativewind/types" />
@@ -0,0 +1,7 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: ["./app/**/*.{js,jsx,ts,tsx}", "./components/**/*.{js,jsx,ts,tsx}"],
4
+ presets: [require("nativewind/preset")],
5
+ theme: { extend: {} },
6
+ plugins: [],
7
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ presets: ['module:@react-native/babel-preset'],
3
+ plugins: ["nativewind/babel"],
4
+ };
@@ -0,0 +1,3 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
@@ -0,0 +1,8 @@
1
+ const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");
2
+ const { withNativeWind } = require("nativewind/metro");
3
+
4
+ const config = mergeConfig(getDefaultConfig(__dirname), {
5
+ /* your custom config */
6
+ });
7
+
8
+ module.exports = withNativeWind(config, { input: "./global.css" });
@@ -0,0 +1 @@
1
+ /// <reference types="nativewind/types" />
@@ -0,0 +1,12 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: [
4
+ "./App.{js,jsx,ts,tsx}",
5
+ "./src/**/*.{js,jsx,ts,tsx}",
6
+ "./screens/**/*.{js,jsx,ts,tsx}",
7
+ "./components/**/*.{js,jsx,ts,tsx}"
8
+ ],
9
+ presets: [require("nativewind/preset")],
10
+ theme: { extend: {} },
11
+ plugins: [],
12
+ };