nuclie 1.0.0 → 1.0.2

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/cli.js CHANGED
File without changes
@@ -9,12 +9,19 @@ import { TEMPLATES } from './templates.js';
9
9
  import { red, green, blue, bold } from 'kleur/colors';
10
10
  async function main() {
11
11
  const args = process.argv.slice(2);
12
- // Usage: node cli.js <project-name> --template <template>
13
12
  let projectName = args[0];
13
+ // Ignore 'bootstrap' or 'init' keyword if it's the first arg
14
+ if (projectName === 'bootstrap' || projectName === 'init' || projectName === 'create') {
15
+ projectName = args[1];
16
+ }
17
+ // Check for --name flag
18
+ const nameIndexRange = args.indexOf('--name');
19
+ if (nameIndexRange > -1) {
20
+ projectName = args[nameIndexRange + 1];
21
+ }
14
22
  let templateName = args.indexOf('--template') > -1 ? args[args.indexOf('--template') + 1] : null;
15
- // Interactive Stub (For real usage, use prompts/inquirer)
16
- if (!projectName) {
17
- console.error(red('Please specify project name: create-nuclie <name>'));
23
+ if (!projectName || projectName.startsWith('--')) {
24
+ console.error(red('Please specify project name: create-nuclie <name> or --name <name>'));
18
25
  process.exit(1);
19
26
  }
20
27
  if (!templateName) {
@@ -45,6 +52,20 @@ async function main() {
45
52
  fs.writeFileSync(filePath, file.content);
46
53
  }
47
54
  // 3. Create package.json
55
+ let nuclieVersion = 'latest';
56
+ try {
57
+ const pkgjsonPath = path.resolve(process.cwd(), 'node_modules/nuclie/package.json');
58
+ if (fs.existsSync(pkgjsonPath)) {
59
+ nuclieVersion = '^' + JSON.parse(fs.readFileSync(pkgjsonPath, 'utf8')).version;
60
+ }
61
+ else {
62
+ const localPkgPath = new URL('../../package.json', import.meta.url);
63
+ if (fs.existsSync(localPkgPath)) {
64
+ nuclieVersion = '^' + JSON.parse(fs.readFileSync(localPkgPath, 'utf8')).version;
65
+ }
66
+ }
67
+ }
68
+ catch (e) { }
48
69
  const pkg = {
49
70
  name: projectName,
50
71
  version: '0.0.0',
@@ -57,7 +78,7 @@ async function main() {
57
78
  dependencies: template.dependencies,
58
79
  devDependencies: {
59
80
  ...template.devDependencies,
60
- "nuclie": "latest"
81
+ "nuclie": nuclieVersion
61
82
  }
62
83
  };
63
84
  fs.writeFileSync(path.join(targetDir, 'package.json'), JSON.stringify(pkg, null, 2));
@@ -27,15 +27,17 @@ const COMMON_FILES = [
27
27
  }
28
28
  ];
29
29
  export const TEMPLATES = {
30
- react: {
31
- id: 'react',
32
- name: 'React',
30
+ 'react-ts': {
31
+ id: 'react-ts',
32
+ name: 'React TypeScript',
33
33
  description: 'React Latest + TypeScript + Nuclie',
34
34
  files: [
35
35
  ...COMMON_FILES,
36
- { path: 'src/main.tsx', content: `import { createRoot } from 'react-dom/client'; import App from './App'; createRoot(document.getElementById('root')!).render(<App />);` },
37
- { path: 'src/App.tsx', content: `export default function App() { return <h1>Hello Nuclie React</h1>; }` },
38
- { path: 'index.html', content: `<!DOCTYPE html><body><div id="root"></div><script type="module" src="/src/main.tsx"></script></body>` }
36
+ { path: 'index.html', content: `<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="UTF-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <title>Nuclie + React + TS</title>\n </head>\n <body>\n <div id="root"></div>\n <script type="module" src="/src/main.tsx"></script>\n </body>\n</html>` },
37
+ { path: 'src/main.tsx', content: `import { StrictMode } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport './index.css';\nimport App from './App.tsx';\n\ncreateRoot(document.getElementById('root')!).render(\n <StrictMode>\n <App />\n </StrictMode>,\n);` },
38
+ { path: 'src/App.tsx', content: `import { useState } from 'react';\nimport './App.css';\n\nfunction App() {\n const [count, setCount] = useState(0);\n\n return (\n <>\n <h1>Nuclie + React</h1>\n <div className="card">\n <button onClick={() => setCount((count) => count + 1)}>\n count is {count}\n </button>\n <p>\n Edit <code>src/App.tsx</code> and save to test HMR\n </p>\n </div>\n <p className="read-the-docs">\n Click on the Nuclie and React logos to learn more\n </p>\n </>\n );\n}\n\nexport default App;\n` },
39
+ { path: 'src/index.css', content: `:root {\n font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;\n line-height: 1.5;\n font-weight: 400;\n color-scheme: light dark;\n color: rgba(255, 255, 255, 0.87);\n background-color: #242424;\n font-synthesis: none;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\nbody {\n margin: 0;\n display: flex;\n place-items: center;\n min-width: 320px;\n min-height: 100vh;\n}\n\nh1 {\n font-size: 3.2em;\n line-height: 1.1;\n}\n\n#root {\n max-width: 1280px;\n margin: 0 auto;\n padding: 2rem;\n text-align: center;\n}` },
40
+ { path: 'src/App.css', content: `.logo {\n height: 6em;\n padding: 1.5em;\n will-change: filter;\n transition: filter 300ms;\n}\n.logo:hover {\n filter: drop-shadow(0 0 2em #646cffaa);\n}\n.logo.react:hover {\n filter: drop-shadow(0 0 2em #61dafbaa);\n}\n\n@keyframes logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\n@media (prefers-reduced-motion: no-preference) {\n a:nth-of-type(2) .logo {\n animation: logo-spin infinite 20s linear;\n }\n}\n\n.card {\n padding: 2em;\n}\n\n.read-the-docs {\n color: #888;\n}` }
39
41
  ],
40
42
  dependencies: { "react": "latest", "react-dom": "latest" },
41
43
  devDependencies: { "@types/react": "latest", "@types/react-dom": "latest" }
File without changes
@@ -761,6 +761,7 @@ export async function startDevServer(cliCfg, existingServer) {
761
761
  path.join(cfg.root, 'node_modules/react-refresh/cjs/react-refresh-runtime.development.js'),
762
762
  path.join(cfg.root, '../node_modules/react-refresh/cjs/react-refresh-runtime.development.js'),
763
763
  path.join(process.cwd(), 'node_modules/react-refresh/cjs/react-refresh-runtime.development.js'),
764
+ path.join(__dirname, '../../node_modules/react-refresh/cjs/react-refresh-runtime.development.js')
764
765
  ];
765
766
  let runtime = null;
766
767
  for (const checkPath of searchPaths) {
@@ -7,6 +7,9 @@ import http from 'http';
7
7
  import path from 'path';
8
8
  import fs from 'fs';
9
9
  import os from 'os';
10
+ import { fileURLToPath } from 'url';
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
10
13
  let features = null;
11
14
  let isInitializing = false;
12
15
  export async function startDevServer(cfg) {
@@ -87,10 +90,21 @@ export async function startDevServer(cfg) {
87
90
  if (networkIP)
88
91
  break;
89
92
  }
90
- // Enhanced Startup Banner (Create React App style)
91
93
  console.log(`\n\x1b[32mStarting the development server...\x1b[0m\n`);
94
+ // Try to read version from package.json
95
+ let version = '1.0.0';
96
+ try {
97
+ // Since this file ends up in dist/dev, we need to go up to the project root
98
+ const pkgPath = path.resolve(__dirname, '../../package.json');
99
+ if (fs.existsSync(pkgPath)) {
100
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
101
+ if (pkg.version)
102
+ version = pkg.version;
103
+ }
104
+ }
105
+ catch (e) { }
92
106
  // Futuristic Nuclie Branding (Engineering First)
93
- console.log(`\x1b[36m ⚡ NUCLIE \x1b[90mv2.0.2\x1b[0m`);
107
+ console.log(`\x1b[36m ⚡ NUCLIE \x1b[90mv${version}\x1b[0m`);
94
108
  console.log(`\x1b[90m ─────────────────────────────────────\x1b[0m`);
95
109
  // Metrics Layout
96
110
  console.log(` \x1b[32m▶\x1b[0m \x1b[1mCore\x1b[0m \x1b[32mReady\x1b[0m in \x1b[33m${duration}ms\x1b[0m`);
@@ -7,6 +7,13 @@ export async function bootstrapProject(cwd, template = 'react') {
7
7
  await fs.mkdir(path.join(cwd, 'src'), { recursive: true });
8
8
  await fs.mkdir(path.join(cwd, 'public'), { recursive: true });
9
9
  // 2. Create package.json
10
+ let nuclieVersion = 'latest';
11
+ try {
12
+ const localPkgPath = new URL('../../package.json', import.meta.url);
13
+ const pkgJsonStr = await fs.readFile(localPkgPath, 'utf8');
14
+ nuclieVersion = '^' + JSON.parse(pkgJsonStr).version;
15
+ }
16
+ catch (e) { }
10
17
  const pkg = {
11
18
  name: path.basename(cwd),
12
19
  version: '0.1.0',
@@ -17,18 +24,20 @@ export async function bootstrapProject(cwd, template = 'react') {
17
24
  "build": "nuclie build",
18
25
  "preview": "nuclie dev --port 4173"
19
26
  },
20
- dependencies: template === 'react' ? {
21
- "react": "^18.2.0",
22
- "react-dom": "^18.2.0"
27
+ dependencies: (template === 'react' || template === 'react-ts') ? {
28
+ "react": "^19.2.3",
29
+ "react-dom": "^19.2.3"
23
30
  } : {},
24
31
  devDependencies: {
25
- "nuclie": "latest",
26
- "typescript": "^5.0.0"
32
+ "nuclie": nuclieVersion,
33
+ "typescript": "^5.0.0",
34
+ "@types/react": "^19.0.0",
35
+ "@types/react-dom": "^19.0.0"
27
36
  }
28
37
  };
29
38
  await fs.writeFile(path.join(cwd, 'package.json'), JSON.stringify(pkg, null, 2));
30
39
  // 3. Create initial source files
31
- if (template === 'react') {
40
+ if (template === 'react' || template === 'react-ts') {
32
41
  await fs.writeFile(path.join(cwd, 'src/main.tsx'), `
33
42
  import React from 'react';
34
43
  import ReactDOM from 'react-dom/client';
@@ -6,6 +6,7 @@ const _require = createRequire(import.meta.url);
6
6
  const __filename = fileURLToPath(import.meta.url);
7
7
  const __dirname = path.dirname(__filename);
8
8
  let native;
9
+ let nativeLoaded = false;
9
10
  try {
10
11
  const candidates = [
11
12
  path.resolve(__dirname, '../../nuclie_native.node'),
@@ -21,15 +22,17 @@ try {
21
22
  }
22
23
  }
23
24
  if (found) {
24
- native = _require(found);
25
- }
26
- else {
27
- // Use fallback instead of throwing
28
- native = null;
25
+ let loadedNative = _require(found);
26
+ if (loadedNative && loadedNative.GraphAnalyzer) {
27
+ native = loadedNative;
28
+ nativeLoaded = true;
29
+ }
29
30
  }
30
31
  }
31
32
  catch (e) {
32
- // Fallback Mock with proper hashing
33
+ // Ignore require errors
34
+ }
35
+ if (!nativeLoaded || !native) {
33
36
  const crypto = _require('crypto');
34
37
  native = {
35
38
  GraphAnalyzer: class {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuclie",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "⚡ Fast build tool with HMR, source maps, tree shaking, and module federation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
Binary file