create-nextify 0.1.8 → 0.1.10
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 +108 -0
- package/package.json +8 -5
package/dist/index.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import http from 'node:http';
|
|
3
|
+
import { mkdirSync, writeFileSync, existsSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
function createProject(target = 'nextify-app') {
|
|
6
|
+
const root = join(process.cwd(), target);
|
|
7
|
+
if (existsSync(root)) {
|
|
8
|
+
console.error(`Erro: a pasta "${target}" já existe.`);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
mkdirSync(join(root, 'pages', 'api'), { recursive: true });
|
|
12
|
+
writeFileSync(join(root, 'package.json'), JSON.stringify({
|
|
13
|
+
name: target,
|
|
14
|
+
private: true,
|
|
15
|
+
scripts: {
|
|
16
|
+
dev: 'nextify dev',
|
|
17
|
+
build: 'nextify build',
|
|
18
|
+
start: 'nextify start'
|
|
19
|
+
},
|
|
20
|
+
devDependencies: {
|
|
21
|
+
"create-nextify": "^0.1.0"
|
|
22
|
+
}
|
|
23
|
+
}, null, 2));
|
|
24
|
+
writeFileSync(join(root, 'pages', 'index.tsx'), `export default function Home() {
|
|
25
|
+
return (
|
|
26
|
+
<main>
|
|
27
|
+
<h1>Bem-vindo ao Nextify.js 🚀</h1>
|
|
28
|
+
</main>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
`);
|
|
32
|
+
writeFileSync(join(root, 'pages', 'api', 'health.ts'), `export default async function handler() {
|
|
33
|
+
return new Response(JSON.stringify({ ok: true }), {
|
|
34
|
+
headers: { 'content-type': 'application/json' }
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
`);
|
|
38
|
+
console.log(`\n✔ Projeto criado em: ${root}`);
|
|
39
|
+
console.log('\nPróximos passos:\n');
|
|
40
|
+
console.log(` cd ${target}`);
|
|
41
|
+
console.log(' npm install');
|
|
42
|
+
console.log(' npm run dev\n');
|
|
43
|
+
}
|
|
44
|
+
function runDevServer(port) {
|
|
45
|
+
const server = http.createServer((_req, res) => {
|
|
46
|
+
res.setHeader('content-type', 'text/plain; charset=utf-8');
|
|
47
|
+
res.end('Nextify dev server ativo 🚀');
|
|
48
|
+
});
|
|
49
|
+
server.listen(port, () => {
|
|
50
|
+
console.log(`Nextify dev server em http://localhost:${port}`);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function runProdServer(port) {
|
|
54
|
+
const server = http.createServer((_req, res) => {
|
|
55
|
+
res.setHeader('content-type', 'text/plain; charset=utf-8');
|
|
56
|
+
res.end('Nextify production server ativo 🚀');
|
|
57
|
+
});
|
|
58
|
+
server.listen(port, () => {
|
|
59
|
+
console.log(`Nextify start server em http://localhost:${port}`);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function runBuild() {
|
|
63
|
+
mkdirSync(join(process.cwd(), 'dist'), { recursive: true });
|
|
64
|
+
writeFileSync(join(process.cwd(), 'dist', 'route-manifest.json'), JSON.stringify({
|
|
65
|
+
generatedAt: new Date().toISOString(),
|
|
66
|
+
note: 'Manifesto de rotas gerado pelo CLI do Nextify.'
|
|
67
|
+
}, null, 2));
|
|
68
|
+
console.log('✔ Build do Nextify concluído. Artefatos em dist/');
|
|
69
|
+
}
|
|
70
|
+
function showHelp() {
|
|
71
|
+
console.log(`
|
|
72
|
+
Uso:
|
|
73
|
+
|
|
74
|
+
create-nextify [nome-do-projeto]
|
|
75
|
+
|
|
76
|
+
ou
|
|
77
|
+
|
|
78
|
+
nextify create [nome-do-projeto]
|
|
79
|
+
nextify dev [porta]
|
|
80
|
+
nextify build
|
|
81
|
+
nextify start [porta]
|
|
82
|
+
`);
|
|
83
|
+
}
|
|
84
|
+
const args = process.argv.slice(2);
|
|
85
|
+
if (args.length === 0) {
|
|
86
|
+
showHelp();
|
|
87
|
+
process.exit(0);
|
|
88
|
+
}
|
|
89
|
+
const command = args[0];
|
|
90
|
+
const portArg = Number(process.env.PORT ?? args[1] ?? 3000);
|
|
91
|
+
const port = Number.isFinite(portArg) ? portArg : 3000;
|
|
92
|
+
switch (command) {
|
|
93
|
+
case "create":
|
|
94
|
+
createProject(args[1]);
|
|
95
|
+
break;
|
|
96
|
+
case "dev":
|
|
97
|
+
runDevServer(port);
|
|
98
|
+
break;
|
|
99
|
+
case "build":
|
|
100
|
+
runBuild();
|
|
101
|
+
break;
|
|
102
|
+
case "start":
|
|
103
|
+
runProdServer(port);
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
// suporta: npx create-nextify minha-app
|
|
107
|
+
createProject(command);
|
|
108
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-nextify",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "CLI para criar aplicações Nextify.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"nextify": "./
|
|
8
|
-
"create-nextify": "./
|
|
7
|
+
"nextify": "./dist/index.js",
|
|
8
|
+
"create-nextify": "./dist/index.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
|
-
"
|
|
11
|
+
"dist"
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "node -e \"console.log('build de demonstração concluído')\"",
|
|
@@ -22,5 +22,8 @@
|
|
|
22
22
|
"cli"
|
|
23
23
|
],
|
|
24
24
|
"author": "Ricardo Oliveira",
|
|
25
|
-
"license": "MIT"
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "^5.9.3"
|
|
28
|
+
}
|
|
26
29
|
}
|