@jsonpages/cli 3.0.14 → 3.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsonpages/cli",
3
- "version": "3.0.14",
3
+ "version": "3.0.15",
4
4
  "description": "JsonPages CLI - Sovereign Projection Engine",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -16,10 +16,12 @@ const program = new Command();
16
16
  program
17
17
  .name('jsonpages')
18
18
  .description('JsonPages CLI - Sovereign Projection Engine')
19
- .version('2.0.6'); // Bump version
19
+ .version('2.0.2'); // Bump version
20
20
 
21
21
  /**
22
22
  * 🧠 THE UNIVERSAL INTERPRETER
23
+ * Legge lo script bash "DNA" e lo esegue usando le API di Node.js.
24
+ * Rende la CLI compatibile con Windows (PowerShell/CMD) senza bisogno di Bash.
23
25
  */
24
26
  async function processScriptInNode(scriptPath, targetDir) {
25
27
  const content = await fs.readFile(scriptPath, 'utf-8');
@@ -33,26 +35,35 @@ async function processScriptInNode(scriptPath, targetDir) {
33
35
  for (const line of lines) {
34
36
  const trimmed = line.trim();
35
37
 
38
+ // 1. Modalità Cattura (Siamo dentro un cat << 'DELIMITER')
36
39
  if (captureMode) {
37
40
  if (trimmed === delimiter) {
41
+ // Fine del blocco: Scriviamo su disco
38
42
  const filePath = path.join(targetDir, currentFile);
39
43
  await fs.outputFile(filePath, fileBuffer.join('\n'));
40
44
  captureMode = false;
41
45
  fileBuffer = [];
42
46
  } else {
43
- fileBuffer.push(line);
47
+ fileBuffer.push(line); // Preserva l'indentazione originale
44
48
  }
45
49
  continue;
46
50
  }
47
51
 
52
+ // 2. Parsing Comandi Bash -> Node Operations
53
+
54
+ // Rileva: mkdir -p "path"
48
55
  if (trimmed.startsWith('mkdir -p')) {
49
56
  const match = trimmed.match(/"([^"]+)"/) || trimmed.match(/\s+([^\s]+)/);
57
+ // Supporta sia mkdir -p "foo/bar" che mkdir -p foo/bar
50
58
  const dirPath = match ? match[1].replace(/"/g, '') : null;
51
59
  if (dirPath) {
52
60
  await fs.ensureDir(path.join(targetDir, dirPath));
53
61
  }
54
62
  }
63
+
64
+ // Rileva: cat << 'DELIMITER' > "path"
55
65
  else if (trimmed.startsWith('cat <<')) {
66
+ // Regex robusta per catturare il delimitatore e il path del file
56
67
  const match = trimmed.match(/<<\s*'([^']+)'\s*>\s*"([^"]+)"/);
57
68
  if (match) {
58
69
  delimiter = match[1];
@@ -60,6 +71,7 @@ async function processScriptInNode(scriptPath, targetDir) {
60
71
  captureMode = true;
61
72
  }
62
73
  }
74
+ // Ignora echo, set -e, commenti #, ecc.
63
75
  }
64
76
  }
65
77
 
@@ -75,11 +87,15 @@ program
75
87
  }
76
88
 
77
89
  const targetDir = path.join(process.cwd(), name);
90
+
91
+ // 🔍 Asset Resolution
92
+ // Cerca lo script nella cartella assets installata col pacchetto
78
93
  const defaultScriptPath = path.resolve(__dirname, '../assets/src_tenant_alpha.sh');
79
94
  const scriptPath = options.script ? path.resolve(process.cwd(), options.script) : defaultScriptPath;
80
95
 
81
96
  if (!fs.existsSync(scriptPath)) {
82
97
  console.log(chalk.red(`❌ Error: DNA script not found at ${scriptPath}`));
98
+ console.log(chalk.yellow(`Debug info: __dirname is ${__dirname}`));
83
99
  return;
84
100
  }
85
101
 
@@ -87,9 +103,11 @@ program
87
103
  const spinner = ora();
88
104
 
89
105
  try {
90
- // 1. SCAFFOLDING
106
+ // 1. SCAFFOLDING INFRA
91
107
  spinner.start('Setting up environment (Vite + TS)...');
92
108
  await fs.ensureDir(targetDir);
109
+
110
+ // Windows fix: npm.cmd invece di npm
93
111
  const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
94
112
 
95
113
  await execa(npmCmd, ['create', 'vite@latest', '.', '--', '--template', 'react-ts'], { cwd: targetDir });
@@ -98,7 +116,7 @@ program
98
116
  // 2. CLEANUP
99
117
  spinner.start('Wiping default boilerplate...');
100
118
  await fs.emptyDir(path.join(targetDir, 'src'));
101
- const junk = ['App.css', 'App.tsx', 'main.tsx', 'vite-env.d.ts', 'favicon.ico', 'index.html', 'package.json', 'package-lock.json'];
119
+ const junk = ['App.css', 'App.tsx', 'main.tsx', 'vite-env.d.ts', 'favicon.ico', 'index.html'];
102
120
  for (const file of junk) {
103
121
  await fs.remove(path.join(targetDir, file)).catch(() => {});
104
122
  await fs.remove(path.join(targetDir, 'src', file)).catch(() => {});
@@ -110,14 +128,31 @@ program
110
128
  await injectInfraFiles(targetDir, name);
111
129
  spinner.succeed('Infrastructure configured.');
112
130
 
113
- // 4. DETERMINISTIC PROJECTION
131
+ // 4. DETERMINISTIC PROJECTION (Node-based Interpreter)
114
132
  spinner.start('Executing deterministic src projection...');
133
+ // Invece di execa('./script.sh'), usiamo il nostro interprete
115
134
  await processScriptInNode(scriptPath, targetDir);
116
135
  spinner.succeed('Source code and assets projected successfully.');
117
136
 
118
- // 5. INSTALLATION
137
+ // 5. DEPENDENCY RESOLUTION
119
138
  spinner.start('Installing dependencies (this may take a minute)...');
120
- await execa(npmCmd, ['install'], { cwd: targetDir });
139
+
140
+ const deps = [
141
+ 'react', 'react-dom', 'zod', 'react-router-dom',
142
+ 'lucide-react', 'radix-ui',
143
+ 'tailwind-merge', 'clsx',
144
+ 'file-saver', 'jszip',
145
+ '@jsonpages/core' // Scarica dal registry pubblico
146
+ ];
147
+
148
+ const devDeps = [
149
+ 'vite', '@vitejs/plugin-react', 'typescript',
150
+ '@tailwindcss/vite', 'tailwindcss',
151
+ '@types/node', '@types/react', '@types/react-dom', '@types/file-saver'
152
+ ];
153
+
154
+ await execa(npmCmd, ['install', ...deps], { cwd: targetDir });
155
+ await execa(npmCmd, ['install', '-D', ...devDeps], { cwd: targetDir });
121
156
 
122
157
  spinner.succeed(chalk.green.bold('✨ Tenant Ready!'));
123
158
 
@@ -143,33 +178,6 @@ async function injectInfraFiles(targetDir, name) {
143
178
  "dev": "vite",
144
179
  "build": "tsc && vite build",
145
180
  "preview": "vite preview"
146
- },
147
- dependencies: {
148
- "react": "^19.0.0",
149
- "react-dom": "^19.0.0",
150
- "react-router-dom": "^6.30.0",
151
- "zod": "^3.24.1",
152
- "lucide-react": "^0.474.0",
153
- "radix-ui": "^1.0.1",
154
- "@base-ui/react": "^1.0.0-alpha.1",
155
- "class-variance-authority": "^0.7.0",
156
- "tailwind-merge": "^2.2.0",
157
- "clsx": "^2.1.0",
158
- "tailwindcss-animate": "^1.0.7", // 👈 FIX: Pacchetto corretto
159
- "file-saver": "^2.0.5",
160
- "jszip": "^3.10.1",
161
- "@jsonpages/core": "latest"
162
- },
163
- devDependencies: {
164
- "vite": "^6.0.0",
165
- "@vitejs/plugin-react": "^4.2.1",
166
- "typescript": "^5.7.3",
167
- "@tailwindcss/vite": "^4.0.0",
168
- "tailwindcss": "^4.0.0",
169
- "@types/node": "^20.0.0",
170
- "@types/react": "^19.0.0",
171
- "@types/react-dom": "^19.0.0",
172
- "@types/file-saver": "^2.0.7"
173
181
  }
174
182
  };
175
183
  await fs.writeJson(path.join(targetDir, 'package.json'), pkg, { spaces: 2 });