Skip to content

Commit c6bb0b5

Browse files
authored
Merge pull request #116 from gluestack/fix/next15-support
Fix/next15 support
2 parents fcd2e1c + 65cd7d1 commit c6bb0b5

File tree

4 files changed

+68
-2
lines changed

4 files changed

+68
-2
lines changed

packages/gluestack-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"cli"
1111
],
1212
"description": "A CLI tool for easily adding components from gluestack to your projects.",
13-
"version": "0.7.20",
13+
"version": "0.7.22",
1414
"license": "MIT",
1515
"main": "dist/index.js",
1616
"files": [

packages/gluestack-cli/src/commands/init.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from '../util';
1313
import path, { resolve } from 'path';
1414
import fs from 'fs';
15+
import { checkNextVersion } from '../util/check-next-version';
1516

1617
const initOptionsSchema = z.object({
1718
useNpm: z.boolean(),
@@ -59,6 +60,16 @@ export const init = new Command()
5960
);
6061
process.exit(1);
6162
}
63+
64+
//TODO : remove this check once nextjs 15 is supported properly
65+
const isNextjs15 = await checkNextVersion();
66+
if (isNextjs15) {
67+
log.info(
68+
`Next.js 15 is not supported by the init command.\n Please use 'npm create gluestack-ui@latest' to clone a new next 15 project.\n`
69+
);
70+
process.exit(1);
71+
}
72+
6273
//if multiple package managers are used
6374
if (
6475
(options.useNpm && options.useYarn) ||
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { Transform } from 'jscodeshift';
2+
3+
const transform: Transform = (file, api) => {
4+
const j = api.jscodeshift;
5+
const root = j(file.source);
6+
7+
// Look for eslintConfig array definition
8+
root
9+
.find(j.VariableDeclarator, { id: { name: 'eslintConfig' } })
10+
.forEach((path) => {
11+
const arrayExpression = path.node.init;
12+
13+
if (arrayExpression && arrayExpression.type === 'ArrayExpression') {
14+
const newRuleObject = j.objectExpression([
15+
j.property(
16+
'init',
17+
j.identifier('rules'),
18+
j.objectExpression([
19+
j.property(
20+
'init',
21+
j.stringLiteral('@typescript-eslint/no-explicit-any'),
22+
j.stringLiteral('off')
23+
),
24+
])
25+
),
26+
]);
27+
28+
// Ensure new rule object isn't already present
29+
const hasRuleAlready = arrayExpression.elements.some(
30+
(el) =>
31+
el &&
32+
el.type === 'ObjectExpression' &&
33+
el.properties.some(
34+
(prop) =>
35+
prop.key.type === 'Identifier' &&
36+
prop.key.name === 'rules' &&
37+
prop.value.type === 'ObjectExpression' &&
38+
prop.value.properties.some(
39+
(rule) =>
40+
rule.key.type === 'StringLiteral' &&
41+
rule.key.value === '@typescript-eslint/no-explicit-any'
42+
)
43+
)
44+
);
45+
46+
if (!hasRuleAlready) {
47+
arrayExpression.elements.push(newRuleObject);
48+
}
49+
}
50+
});
51+
52+
return root.toSource();
53+
};
54+
55+
export default transform;

packages/gluestack-cli/template/nextjs/next15/registry.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React, { useRef, useState } from 'react';
33
import { useServerInsertedHTML } from 'next/navigation';
44
import { StyleRegistry, createStyleRegistry } from 'styled-jsx';
5-
// @ts-ignore
5+
// @ts-expect-error : AppRegistry is defined in react-native-web but its type is not defined
66
import { AppRegistry } from 'react-native-web';
77
import { flush } from '@gluestack-ui/nativewind-utils/flush';
88

0 commit comments

Comments
 (0)