create-nextify 0.1.10 → 0.1.11
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/dist/index.js +49 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12,43 +12,74 @@ function createProject(target = 'nextify-app') {
|
|
|
12
12
|
writeFileSync(join(root, 'package.json'), JSON.stringify({
|
|
13
13
|
name: target,
|
|
14
14
|
private: true,
|
|
15
|
+
type: 'module',
|
|
15
16
|
scripts: {
|
|
16
17
|
dev: 'nextify dev',
|
|
17
18
|
build: 'nextify build',
|
|
18
|
-
start: 'nextify start'
|
|
19
|
+
start: 'nextify start',
|
|
20
|
+
},
|
|
21
|
+
dependencies: {
|
|
22
|
+
react: '^18.3.1',
|
|
23
|
+
'react-dom': '^18.3.1',
|
|
19
24
|
},
|
|
20
25
|
devDependencies: {
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
'create-nextify': 'latest',
|
|
27
|
+
'@types/react': '^18.3.1',
|
|
28
|
+
'@types/react-dom': '^18.3.1',
|
|
29
|
+
typescript: '^5.0.0',
|
|
30
|
+
},
|
|
23
31
|
}, null, 2));
|
|
24
32
|
writeFileSync(join(root, 'pages', 'index.tsx'), `export default function Home() {
|
|
25
33
|
return (
|
|
26
|
-
<main>
|
|
34
|
+
<main style={{ fontFamily: 'sans-serif', padding: '2rem' }}>
|
|
27
35
|
<h1>Bem-vindo ao Nextify.js 🚀</h1>
|
|
36
|
+
<p>Edite <code>pages/index.tsx</code> para começar.</p>
|
|
28
37
|
</main>
|
|
29
38
|
);
|
|
30
39
|
}
|
|
31
40
|
`);
|
|
32
41
|
writeFileSync(join(root, 'pages', 'api', 'health.ts'), `export default async function handler() {
|
|
33
42
|
return new Response(JSON.stringify({ ok: true }), {
|
|
34
|
-
headers: { 'content-type': 'application/json' }
|
|
43
|
+
headers: { 'content-type': 'application/json' },
|
|
35
44
|
});
|
|
36
45
|
}
|
|
37
46
|
`);
|
|
47
|
+
writeFileSync(join(root, 'tsconfig.json'), JSON.stringify({
|
|
48
|
+
compilerOptions: {
|
|
49
|
+
target: 'ES2022',
|
|
50
|
+
module: 'ESNext',
|
|
51
|
+
moduleResolution: 'bundler',
|
|
52
|
+
jsx: 'react-jsx',
|
|
53
|
+
strict: true,
|
|
54
|
+
esModuleInterop: true,
|
|
55
|
+
skipLibCheck: true,
|
|
56
|
+
},
|
|
57
|
+
include: ['pages', 'src'],
|
|
58
|
+
}, null, 2));
|
|
38
59
|
console.log(`\n✔ Projeto criado em: ${root}`);
|
|
39
60
|
console.log('\nPróximos passos:\n');
|
|
40
61
|
console.log(` cd ${target}`);
|
|
41
62
|
console.log(' npm install');
|
|
42
63
|
console.log(' npm run dev\n');
|
|
43
64
|
}
|
|
44
|
-
function runDevServer(port) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
65
|
+
async function runDevServer(port) {
|
|
66
|
+
// Tenta usar o @nextify/dev-server real (com Vite)
|
|
67
|
+
try {
|
|
68
|
+
const { startDevServer } = await import('@nextify/dev-server');
|
|
69
|
+
await startDevServer({ root: process.cwd(), port });
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// Fallback: servidor simples se o dev-server não estiver instalado
|
|
73
|
+
console.warn('[nextify] @nextify/dev-server não encontrado — usando servidor básico.\n' +
|
|
74
|
+
' Instale as dependências do projeto com: npm install\n');
|
|
75
|
+
const server = http.createServer((_req, res) => {
|
|
76
|
+
res.setHeader('content-type', 'text/plain; charset=utf-8');
|
|
77
|
+
res.end('Nextify dev server ativo (modo básico)');
|
|
78
|
+
});
|
|
79
|
+
server.listen(port, () => {
|
|
80
|
+
console.log(` ➜ Local: http://localhost:${port}`);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
52
83
|
}
|
|
53
84
|
function runProdServer(port) {
|
|
54
85
|
const server = http.createServer((_req, res) => {
|
|
@@ -63,7 +94,7 @@ function runBuild() {
|
|
|
63
94
|
mkdirSync(join(process.cwd(), 'dist'), { recursive: true });
|
|
64
95
|
writeFileSync(join(process.cwd(), 'dist', 'route-manifest.json'), JSON.stringify({
|
|
65
96
|
generatedAt: new Date().toISOString(),
|
|
66
|
-
note: 'Manifesto de rotas gerado pelo CLI do Nextify.'
|
|
97
|
+
note: 'Manifesto de rotas gerado pelo CLI do Nextify.',
|
|
67
98
|
}, null, 2));
|
|
68
99
|
console.log('✔ Build do Nextify concluído. Artefatos em dist/');
|
|
69
100
|
}
|
|
@@ -90,16 +121,16 @@ const command = args[0];
|
|
|
90
121
|
const portArg = Number(process.env.PORT ?? args[1] ?? 3000);
|
|
91
122
|
const port = Number.isFinite(portArg) ? portArg : 3000;
|
|
92
123
|
switch (command) {
|
|
93
|
-
case
|
|
124
|
+
case 'create':
|
|
94
125
|
createProject(args[1]);
|
|
95
126
|
break;
|
|
96
|
-
case
|
|
127
|
+
case 'dev':
|
|
97
128
|
runDevServer(port);
|
|
98
129
|
break;
|
|
99
|
-
case
|
|
130
|
+
case 'build':
|
|
100
131
|
runBuild();
|
|
101
132
|
break;
|
|
102
|
-
case
|
|
133
|
+
case 'start':
|
|
103
134
|
runProdServer(port);
|
|
104
135
|
break;
|
|
105
136
|
default:
|