create-nix-app 1.0.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/index.js ADDED
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ import prompts from 'prompts';
6
+ import { blue, green, yellow, reset } from 'kolorist';
7
+
8
+ const cwd = process.cwd();
9
+
10
+ async function init() {
11
+ console.log(blue('\n❄️ ¡Bienvenido a Nix.js!\n'));
12
+
13
+ const response = await prompts([
14
+ {
15
+ type: 'text',
16
+ name: 'projectName',
17
+ message: 'Nombre de tu proyecto:',
18
+ initial: 'nix-app'
19
+ },
20
+ {
21
+ type: 'select',
22
+ name: 'variant',
23
+ message: '¿Qué variante quieres usar?',
24
+ choices: [
25
+ { title: yellow('Vite + TypeScript'), value: 'vite-ts', description: 'Recomendado para DX rápida y tipado estricto' },
26
+ { title: yellow('Vite + JavaScript'), value: 'vite-js', description: 'Vite sin compilación de TS' },
27
+ { title: blue('Vanilla TypeScript'), value: 'vanilla-ts', description: 'Sin bundler, puro TSC' },
28
+ { title: blue('Vanilla JavaScript'), value: 'vanilla-js', description: 'Cero build, import maps directo en navegador' }
29
+ ]
30
+ }
31
+ ]);
32
+
33
+ if (!response.projectName || !response.variant) {
34
+ console.log('\nOperación cancelada. ¡Hasta pronto!');
35
+ return;
36
+ }
37
+
38
+ const targetDir = response.projectName;
39
+ const templateName = `template-${response.variant}`;
40
+ const root = path.join(cwd, targetDir);
41
+
42
+ if (!fs.existsSync(root)) {
43
+ fs.mkdirSync(root, { recursive: true });
44
+ }
45
+
46
+ const templateDir = path.resolve(
47
+ fileURLToPath(import.meta.url),
48
+ `../${templateName}`
49
+ );
50
+
51
+ const copy = (src, dest) => {
52
+ const stat = fs.statSync(src);
53
+ if (stat.isDirectory()) {
54
+ if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
55
+ for (const file of fs.readdirSync(src)) {
56
+ if (file === 'node_modules') continue;
57
+ copy(path.resolve(src, file), path.resolve(dest, file));
58
+ }
59
+ } else {
60
+ const targetFile = path.basename(dest) === '_gitignore'
61
+ ? dest.replace('_gitignore', '.gitignore')
62
+ : dest;
63
+ fs.copyFileSync(src, targetFile);
64
+ }
65
+ };
66
+
67
+ copy(templateDir, root);
68
+
69
+ const pkgPath = path.join(root, 'package.json');
70
+ if (fs.existsSync(pkgPath)) {
71
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
72
+ pkg.name = targetDir;
73
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
74
+ }
75
+
76
+ // 6. Mensajes de éxito
77
+ console.log(green(`\n¡Proyecto creado con éxito en ./${targetDir}!`));
78
+ console.log(`Variante seleccionada: ${reset(response.variant)}`);
79
+ console.log(`\nSiguientes pasos:`);
80
+ console.log(` cd ${targetDir}`);
81
+ console.log(` npm install`);
82
+ console.log(` npm run dev\n`);
83
+ }
84
+
85
+ init().catch((e) => {
86
+ console.error(e);
87
+ });
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "create-nix-app",
3
+ "version": "1.0.0",
4
+ "description": "Scaffolding tool for Nix.js reactive micro-framework",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-nix-app": "index.js"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "keywords": [
13
+ "nix",
14
+ "nix.js",
15
+ "framework",
16
+ "reactive",
17
+ "cli",
18
+ "create-app",
19
+ "scaffolding"
20
+ ],
21
+ "author": "Tu Nombre o el de tu Empresa",
22
+ "license": "MIT",
23
+ "dependencies": {
24
+ "kolorist": "^1.8.0",
25
+ "prompts": "^2.4.2"
26
+ }
27
+ }
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ dist
3
+ .env
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>❄️ ¡Bienvenido a Nix.js!</title>
7
+ <script type="importmap">
8
+ {
9
+ "imports": {
10
+ "@deijose/nix-js": "https://esm.sh/@deijose/nix-js@1.1.3"
11
+ }
12
+ }
13
+ </script>
14
+ </head>
15
+
16
+ <body>
17
+ <div id="app"></div>
18
+ <script type="module" src="./main.js"></script>
19
+ </body>
20
+ </html>
@@ -0,0 +1,17 @@
1
+ import { signal, html, mount } from "@deijose/nix-js";
2
+
3
+ function App() {
4
+ const count = signal(0);
5
+
6
+ return html`
7
+ <main style="font-family: sans-serif; padding: 2rem;">
8
+ <h1>❄️ Nix.js en estado puro</h1>
9
+ <p>Sin compilador. Sin bundler. Solo la web nativa.</p>
10
+ <button @click=${() => count.update((c) => c + 1)}>
11
+ Clicks: ${() => count.value}
12
+ </button>
13
+ </main>
14
+ `;
15
+ }
16
+
17
+ mount(App(), "#app");
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "nix-vanilla-js",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "npx serve ."
7
+ }
8
+ }
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ dist
3
+ .env
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>❄️ Nix.js Vanilla TS</title>
8
+ <script type="importmap">
9
+ {
10
+ "imports": {
11
+ "@deijose/nix-js": "https://esm.sh/@deijose/nix-js@1.1.3"
12
+ }
13
+ }
14
+ </script>
15
+ </head>
16
+
17
+ <body>
18
+ <div id="app"></div>
19
+ <script type="module" src="./dist/main.js"></script>
20
+ </body>
21
+
22
+ </html>
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "nix-vanilla-ts",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "tsc --watch & npx serve .",
7
+ "build": "tsc"
8
+ },
9
+ "dependencies": {
10
+ "@deijose/nix-js": "^1.1.3"
11
+ },
12
+ "devDependencies": {
13
+ "typescript": "~5.9.3"
14
+ }
15
+ }
@@ -0,0 +1,17 @@
1
+ import { signal, html, mount } from "@deijose/nix-js";
2
+ import type { NixTemplate } from "@deijose/nix-js";
3
+
4
+ function App(): NixTemplate {
5
+ const count = signal<number>(0);
6
+
7
+ return html`
8
+ <main style="font-family: sans-serif; padding: 2rem;">
9
+ <h1>❄️ Nix.js + TypeScript Vanilla</h1>
10
+ <button @click=${() => count.update((c) => c + 1)}>
11
+ Clicks: ${() => count.value}
12
+ </button>
13
+ </main>
14
+ `;
15
+ }
16
+
17
+ mount(App(), "#app");
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "node",
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "skipLibCheck": true
10
+ },
11
+ "include": [
12
+ "src/**/*"
13
+ ]
14
+ }
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ dist
3
+ .env
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>❄️ Nix.js + Vite JS</title>
7
+ <script type="importmap">
8
+ {
9
+ "imports": {
10
+ "@deijose/nix-js": "https://esm.sh/@deijose/nix-js@1.1.3"
11
+ }
12
+ }
13
+ </script>
14
+ </head>
15
+
16
+ <body>
17
+ <div id="app"></div>
18
+ <script type="module" src="./main.js"></script>
19
+ </body>
20
+ </html>
@@ -0,0 +1,17 @@
1
+ import { signal, html, mount } from "@deijose/nix-js";
2
+
3
+ function App() {
4
+ const count = signal(0);
5
+
6
+ return html`
7
+ <main style="font-family: sans-serif; padding: 2rem;">
8
+ <h1>❄️ Nix.js + Vite</h1>
9
+ <p>Sin compilador. Sin bundler. Solo la web nativa.</p>
10
+ <button @click=${() => count.update((c) => c + 1)}>
11
+ Clicks: ${() => count.value}
12
+ </button>
13
+ </main>
14
+ `;
15
+ }
16
+
17
+ mount(App(), "#app");
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "nix-vite-js",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "vite",
7
+ "build": "vite build",
8
+ "preview": "vite preview"
9
+ },
10
+ "dependencies": {
11
+ "@deijose/nix-js": "^1.1.3"
12
+ },
13
+ "devDependencies": {
14
+ "vite": "^8.0.0-beta.13"
15
+ }
16
+ }
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from "vite";
2
+
3
+ export default defineConfig({
4
+ plugins: [],
5
+ });
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ dist
3
+ .env
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>❄️ Nix.js + Vite TS</title>
8
+ <script type="importmap">
9
+ {
10
+ "imports": {
11
+ "@deijose/nix-js": "https://esm.sh/@deijose/nix-js@1.1.3"
12
+ }
13
+ }
14
+ </script>
15
+ </head>
16
+
17
+ <body>
18
+ <div id="app"></div>
19
+ <script type="module" src="/src/main.ts"></script>
20
+ </body>
21
+
22
+ </html>
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "nix-vite-ts",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "vite",
7
+ "build": "tsc --noEmit && vite build",
8
+ "preview": "vite preview"
9
+ },
10
+ "dependencies": {
11
+ "@deijose/nix-js": "^1.1.3"
12
+ },
13
+ "devDependencies": {
14
+ "typescript": "~5.9.3",
15
+ "vite": "^8.0.0-beta.13"
16
+ }
17
+ }
@@ -0,0 +1,17 @@
1
+ import { signal, html, mount } from "@deijose/nix-js";
2
+ import type { NixTemplate } from "@deijose/nix-js";
3
+
4
+ function App(): NixTemplate {
5
+ const count = signal<number>(0);
6
+
7
+ return html`
8
+ <main style="font-family: sans-serif; padding: 2rem;">
9
+ <h1>❄️ Nix.js + Vite + TypeScript Vanilla</h1>
10
+ <button @click=${() => count.update((c) => c + 1)}>
11
+ Clicks: ${() => count.value}
12
+ </button>
13
+ </main>
14
+ `;
15
+ }
16
+
17
+ mount(App(), "#app");
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "lib": [
7
+ "ES2022",
8
+ "DOM",
9
+ "DOM.Iterable"
10
+ ],
11
+ "skipLibCheck": true,
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "resolveJsonModule": true,
15
+ "isolatedModules": true,
16
+ "noEmit": true,
17
+ "strict": true,
18
+ "noUnusedLocals": true,
19
+ "noUnusedParameters": true,
20
+ "noFallthroughCasesInSwitch": true
21
+ },
22
+ "include": [
23
+ "src"
24
+ ]
25
+ }
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from "vite";
2
+
3
+ export default defineConfig({
4
+ plugins: [],
5
+ });