create-nextify 0.1.14 → 0.1.16

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/devServer.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import fs from 'node:fs';
3
3
  import { createServer as createHttpServer } from 'node:http';
4
+ import { pathToFileURL } from 'node:url';
4
5
  const PORT = Number(process.env.PORT ?? 3000);
5
6
  const PROJECT_ROOT = process.env.NEXTIFY_ROOT ?? process.cwd();
6
7
  const PAGES_DIR = path.join(PROJECT_ROOT, 'pages');
@@ -79,16 +80,17 @@ function buildHtmlShell(routePath) {
79
80
  export async function startDevServer(options = {}) {
80
81
  const root = options.root ?? PROJECT_ROOT;
81
82
  const port = options.port ?? PORT;
82
- // Resolve vite e plugin-react a partir do projeto do usuário (node_modules local)
83
- const vitePath = path.join(root, 'node_modules', 'vite', 'dist', 'node', 'index.js');
84
- const reactPluginPath = path.join(root, 'node_modules', '@vitejs', 'plugin-react', 'dist', 'index.mjs');
83
+ // pathToFileURL converte C:\... para file:///C:/... obrigatório no Windows
84
+ const vitePath = pathToFileURL(path.join(root, 'node_modules', 'vite', 'dist', 'node', 'index.js')).href;
85
+ const reactPluginPath = pathToFileURL(path.join(root, 'node_modules', '@vitejs', 'plugin-react', 'dist', 'index.mjs')).href;
85
86
  let createViteServer, react;
86
87
  try {
87
88
  ({ createServer: createViteServer } = await import(vitePath));
88
89
  ({ default: react } = await import(reactPluginPath));
89
90
  }
90
91
  catch (err) {
91
- console.error('[nextify] Vite não encontrado. Rode: npm install vite @vitejs/plugin-react');
92
+ console.error('\n[nextify] Vite não encontrado. Rode dentro do projeto:\n');
93
+ console.error(' npm install vite @vitejs/plugin-react\n');
92
94
  console.error(err.message);
93
95
  process.exit(1);
94
96
  }
@@ -107,7 +109,8 @@ export async function startDevServer(options = {}) {
107
109
  const server = createHttpServer(async (req, res) => {
108
110
  const host = req.headers.host ?? `localhost:${port}`;
109
111
  const pathname = new URL(`http://${host}${req.url}`).pathname;
110
- if (pathname.startsWith('/@') || pathname.startsWith('/node_modules') ||
112
+ if (pathname.startsWith('/@') ||
113
+ pathname.startsWith('/node_modules') ||
111
114
  /\.(js|ts|tsx|jsx|css|svg|png|ico|woff2?|map)$/.test(pathname)) {
112
115
  vite.middlewares(req, res, () => { res.statusCode = 404; res.end(); });
113
116
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nextify",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "CLI para criar aplicações Nextify.js",
5
5
  "type": "module",
6
6
  "bin": {