setup-nativewind 1.0.0 → 1.1.0
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 +10 -35
- package/package.json +7 -7
- package/src/detector.js +22 -8
- package/src/index.js +12 -6
- package/src/installer.js +6 -3
- package/src/templates/expo-bare-ts/babel.config.js +9 -0
- package/src/templates/expo-bare-ts/global.css +3 -0
- package/src/templates/expo-bare-ts/metro.config.js +6 -0
- package/src/templates/expo-bare-ts/nativewind-env.d.ts +1 -0
- package/src/templates/expo-bare-ts/tailwind.config.js +11 -0
- package/src/templates/expo-managed-ts/babel.config.js +9 -0
- package/src/templates/expo-managed-ts/global.css +3 -0
- package/src/templates/expo-managed-ts/nativewind-env.d.ts +1 -0
- package/src/templates/expo-managed-ts/tailwind.config.js +7 -0
- package/src/templates/rn-cli-ts/babel.config.js +4 -0
- package/src/templates/rn-cli-ts/global.css +3 -0
- package/src/templates/rn-cli-ts/metro.config.js +8 -0
- package/src/templates/rn-cli-ts/nativewind-env.d.ts +1 -0
- package/src/templates/rn-cli-ts/tailwind.config.js +12 -0
package/README.md
CHANGED
|
@@ -9,17 +9,19 @@ npx setup-nativewind
|
|
|
9
9
|
|
|
10
10
|
## What it does
|
|
11
11
|
|
|
12
|
-
- ✅
|
|
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
|
|
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 |
|
|
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.
|
|
3
|
+
"version": "1.1.0",
|
|
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": "
|
|
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": "
|
|
22
|
+
"author": "Farhan <farhan104757@gmail.com>",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
|
26
|
-
"url": "https://github.com/
|
|
26
|
+
"url": "git+https://github.com/FarhanCodeSpace/setup-nativewind.git"
|
|
27
27
|
},
|
|
28
|
-
"homepage": "https://github.com/
|
|
28
|
+
"homepage": "https://github.com/FarhanCodeSpace/setup-nativewind#readme",
|
|
29
29
|
"bugs": {
|
|
30
|
-
"url": "https://github.com/
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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/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
|
-
|
|
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
|
-
|
|
19
|
+
console.error(chalk.red('✖ ' + err.message));
|
|
18
20
|
process.exit(1);
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -42,7 +44,11 @@ async function run() {
|
|
|
42
44
|
console.log(chalk.bold.green('\n✅ NativeWind setup complete!\n'));
|
|
43
45
|
console.log(chalk.yellow('Next steps:'));
|
|
44
46
|
console.log(' 1. Import global.css in your root layout');
|
|
45
|
-
console.log(' 2. Start using Tailwind classes in your components
|
|
47
|
+
console.log(' 2. Start using Tailwind classes in your components');
|
|
48
|
+
if (projectType.includes('ts')) {
|
|
49
|
+
console.log(' 3. nativewind-env.d.ts has been created for TypeScript support ✅');
|
|
50
|
+
}
|
|
51
|
+
console.log('');
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
run();
|
|
54
|
+
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':
|
|
5
|
-
'expo-
|
|
6
|
-
'
|
|
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 @@
|
|
|
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 @@
|
|
|
1
|
+
/// <reference types="nativewind/types" />
|
|
@@ -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
|
+
};
|