@itayzrihan/create-box-app 1.0.3 → 1.0.4
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/bin/create-box-app.js
CHANGED
|
@@ -8,87 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
const path = require('path');
|
|
11
|
-
const os = require('os');
|
|
12
11
|
|
|
13
12
|
const projectName = process.argv[2] || 'my-box-app';
|
|
14
13
|
const targetDir = path.join(process.cwd(), projectName);
|
|
15
14
|
const templateDir = path.join(__dirname, '..', 'template');
|
|
16
15
|
|
|
17
|
-
/**
|
|
18
|
-
* Get VS Code global settings path based on OS
|
|
19
|
-
*/
|
|
20
|
-
function getVSCodeSettingsPath() {
|
|
21
|
-
const platform = os.platform();
|
|
22
|
-
const home = os.homedir();
|
|
23
|
-
|
|
24
|
-
if (platform === 'win32') {
|
|
25
|
-
return path.join(process.env.APPDATA || path.join(home, 'AppData', 'Roaming'), 'Code', 'User', 'settings.json');
|
|
26
|
-
} else if (platform === 'darwin') {
|
|
27
|
-
return path.join(home, 'Library', 'Application Support', 'Code', 'User', 'settings.json');
|
|
28
|
-
} else {
|
|
29
|
-
return path.join(home, '.config', 'Code', 'User', 'settings.json');
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Configure VS Code to recognize .box files as HTML globally
|
|
35
|
-
*/
|
|
36
|
-
function configureVSCodeGlobally() {
|
|
37
|
-
const settingsPath = getVSCodeSettingsPath();
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
let settings = {};
|
|
41
|
-
|
|
42
|
-
// Read existing settings if file exists
|
|
43
|
-
if (fs.existsSync(settingsPath)) {
|
|
44
|
-
const content = fs.readFileSync(settingsPath, 'utf-8');
|
|
45
|
-
// Remove comments from JSONC (VS Code settings can have comments)
|
|
46
|
-
const cleanContent = content.replace(/\/\/.*$/gm, '').replace(/\/\*[\s\S]*?\*\//g, '');
|
|
47
|
-
try {
|
|
48
|
-
settings = JSON.parse(cleanContent);
|
|
49
|
-
} catch {
|
|
50
|
-
// If parsing fails, try to work with the raw content
|
|
51
|
-
// Check if .box association already exists
|
|
52
|
-
if (content.includes('"*.box"')) {
|
|
53
|
-
return { success: true, alreadyConfigured: true };
|
|
54
|
-
}
|
|
55
|
-
// Can't safely modify, skip
|
|
56
|
-
return { success: false, reason: 'Could not parse existing settings' };
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Check if already configured
|
|
61
|
-
if (settings['files.associations'] && settings['files.associations']['*.box'] === 'html') {
|
|
62
|
-
return { success: true, alreadyConfigured: true };
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Add file association
|
|
66
|
-
if (!settings['files.associations']) {
|
|
67
|
-
settings['files.associations'] = {};
|
|
68
|
-
}
|
|
69
|
-
settings['files.associations']['*.box'] = 'html';
|
|
70
|
-
|
|
71
|
-
// Add emmet support
|
|
72
|
-
if (!settings['emmet.includeLanguages']) {
|
|
73
|
-
settings['emmet.includeLanguages'] = {};
|
|
74
|
-
}
|
|
75
|
-
settings['emmet.includeLanguages']['box'] = 'html';
|
|
76
|
-
|
|
77
|
-
// Ensure directory exists
|
|
78
|
-
const settingsDir = path.dirname(settingsPath);
|
|
79
|
-
if (!fs.existsSync(settingsDir)) {
|
|
80
|
-
fs.mkdirSync(settingsDir, { recursive: true });
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Write updated settings
|
|
84
|
-
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
85
|
-
|
|
86
|
-
return { success: true, alreadyConfigured: false };
|
|
87
|
-
} catch (error) {
|
|
88
|
-
return { success: false, reason: error.message };
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
16
|
async function init() {
|
|
93
17
|
console.log(`\n╔══════════════════════════════════════════════════════════════╗
|
|
94
18
|
║ 📦 BOX Framework Setup ║
|
|
@@ -109,38 +33,35 @@ async function init() {
|
|
|
109
33
|
// Copy template directory recursively
|
|
110
34
|
copyDir(templateDir, targetDir);
|
|
111
35
|
|
|
36
|
+
// Rename workspace file to project name
|
|
37
|
+
const oldWorkspacePath = path.join(targetDir, 'project.code-workspace');
|
|
38
|
+
const newWorkspacePath = path.join(targetDir, `${projectName}.code-workspace`);
|
|
39
|
+
if (fs.existsSync(oldWorkspacePath)) {
|
|
40
|
+
fs.renameSync(oldWorkspacePath, newWorkspacePath);
|
|
41
|
+
}
|
|
42
|
+
|
|
112
43
|
// Customize package.json
|
|
113
44
|
const pkgPath = path.join(targetDir, 'package.json');
|
|
114
45
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
115
46
|
pkg.name = projectName;
|
|
116
47
|
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
|
|
117
48
|
|
|
118
|
-
// Configure VS Code globally
|
|
119
|
-
const vscodeResult = configureVSCodeGlobally();
|
|
120
|
-
|
|
121
49
|
console.log(`✅ Project created successfully!\n`);
|
|
122
50
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
console.log(`🎨 VS Code: .box files already configured as HTML\n`);
|
|
127
|
-
} else {
|
|
128
|
-
console.log(`🎨 VS Code: Configured .box files as HTML globally!\n`);
|
|
129
|
-
}
|
|
130
|
-
} else {
|
|
131
|
-
console.log(`💡 Tip: Add this to your VS Code settings for .box syntax highlighting:`);
|
|
132
|
-
console.log(` "files.associations": { "*.box": "html" }\n`);
|
|
133
|
-
}
|
|
51
|
+
console.log(`╔══════════════════════════════════════════════════════════════╗`);
|
|
52
|
+
console.log(`║ 🎨 IMPORTANT: Open the WORKSPACE file for syntax highlighting`);
|
|
53
|
+
console.log(`╚══════════════════════════════════════════════════════════════╝\n`);
|
|
134
54
|
|
|
135
55
|
console.log(`📋 Next steps:\n`);
|
|
136
|
-
console.log(` 1.
|
|
137
|
-
console.log(`
|
|
56
|
+
console.log(` 1. Open the workspace in VS Code (REQUIRED for .box highlighting):`);
|
|
57
|
+
console.log(` code ${projectName}/${projectName}.code-workspace\n`);
|
|
138
58
|
console.log(` 2. Install dependencies:`);
|
|
59
|
+
console.log(` cd ${projectName}`);
|
|
139
60
|
console.log(` npm install\n`);
|
|
140
61
|
console.log(` 3. Start the dev server:`);
|
|
141
62
|
console.log(` npm run dev\n`);
|
|
142
|
-
console.log(` 4. Open
|
|
143
|
-
console.log(
|
|
63
|
+
console.log(` 4. Open http://localhost:3000\n`);
|
|
64
|
+
console.log(`💡 TIP: Always open the .code-workspace file, not the folder!\n`);
|
|
144
65
|
console.log(`📚 Learn more: https://github.com/itayzrihan/box\n`);
|
|
145
66
|
console.log(`Happy BOXing! 🚀\n`);
|
|
146
67
|
} catch (error) {
|
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -7,6 +7,23 @@ Welcome to your BOX Framework application! This is a fully functional starter te
|
|
|
7
7
|
- Use **component composition** with `<include />`
|
|
8
8
|
- Develop with **instant hot-reload** (HMR)
|
|
9
9
|
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## ⚠️ IMPORTANT: Open the Workspace File!
|
|
13
|
+
|
|
14
|
+
**For proper syntax highlighting in .box files, always open the `.code-workspace` file:**
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
code my-box-app.code-workspace
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or in VS Code: **File → Open Workspace from File → select `my-box-app.code-workspace`**
|
|
21
|
+
|
|
22
|
+
> 💡 **AI Assistants:** This project uses `.box` files which are HTML-like components.
|
|
23
|
+
> The workspace file configures VS Code to treat them as HTML with full syntax highlighting and Emmet support.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
10
27
|
## Quick Start
|
|
11
28
|
|
|
12
29
|
```bash
|
|
@@ -20,10 +37,7 @@ Visit **http://localhost:3000** and start building!
|
|
|
20
37
|
|
|
21
38
|
```
|
|
22
39
|
my-box-app/
|
|
23
|
-
├── .
|
|
24
|
-
│ ├── settings.json # IDE settings (.box → HTML highlighting)
|
|
25
|
-
│ ├── extensions.json # Recommended VS Code extensions
|
|
26
|
-
│ └── launch.json # Debug configurations
|
|
40
|
+
├── my-box-app.code-workspace # ⬅️ OPEN THIS FILE in VS Code!
|
|
27
41
|
├── src/
|
|
28
42
|
│ ├── main.box # App entry point
|
|
29
43
|
│ ├── counter.box # State management example
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"folders": [
|
|
3
|
+
{
|
|
4
|
+
"path": "."
|
|
5
|
+
}
|
|
6
|
+
],
|
|
7
|
+
"settings": {
|
|
8
|
+
"files.associations": {
|
|
9
|
+
"*.box": "html"
|
|
10
|
+
},
|
|
11
|
+
"emmet.includeLanguages": {
|
|
12
|
+
"box": "html"
|
|
13
|
+
},
|
|
14
|
+
"editor.quickSuggestions": {
|
|
15
|
+
"strings": true
|
|
16
|
+
},
|
|
17
|
+
"editor.formatOnSave": true,
|
|
18
|
+
"editor.tabSize": 2,
|
|
19
|
+
"editor.wordWrap": "on",
|
|
20
|
+
"editor.bracketPairColorization.enabled": true,
|
|
21
|
+
"html.autoClosingTags": true,
|
|
22
|
+
"css.colorDecorators": true,
|
|
23
|
+
"files.exclude": {
|
|
24
|
+
"**/node_modules": true
|
|
25
|
+
},
|
|
26
|
+
"search.exclude": {
|
|
27
|
+
"**/node_modules": true,
|
|
28
|
+
"**/dist": true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"extensions": {
|
|
32
|
+
"recommendations": [
|
|
33
|
+
"formulahendry.auto-rename-tag",
|
|
34
|
+
"formulahendry.auto-close-tag",
|
|
35
|
+
"christian-kohler.path-intellisense"
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"recommendations": [
|
|
3
|
-
"bradlc.vscode-tailwindcss",
|
|
4
|
-
"formulahendry.auto-rename-tag",
|
|
5
|
-
"formulahendry.auto-close-tag",
|
|
6
|
-
"christian-kohler.path-intellisense",
|
|
7
|
-
"pranaygp.vscode-css-peek",
|
|
8
|
-
"zignd.html-css-class-completion",
|
|
9
|
-
"ecmel.vscode-html-css",
|
|
10
|
-
"ritwickdey.liveserver"
|
|
11
|
-
],
|
|
12
|
-
"unwantedRecommendations": []
|
|
13
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.2.0",
|
|
3
|
-
"configurations": [
|
|
4
|
-
{
|
|
5
|
-
"name": "BOX Dev Server",
|
|
6
|
-
"type": "node",
|
|
7
|
-
"request": "launch",
|
|
8
|
-
"runtimeExecutable": "npm",
|
|
9
|
-
"runtimeArgs": ["run", "dev"],
|
|
10
|
-
"cwd": "${workspaceFolder}",
|
|
11
|
-
"console": "integratedTerminal",
|
|
12
|
-
"skipFiles": ["<node_internals>/**"]
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"name": "BOX Production Server",
|
|
16
|
-
"type": "node",
|
|
17
|
-
"request": "launch",
|
|
18
|
-
"program": "${workspaceFolder}/dist/server.js",
|
|
19
|
-
"cwd": "${workspaceFolder}",
|
|
20
|
-
"preLaunchTask": "npm: build",
|
|
21
|
-
"console": "integratedTerminal",
|
|
22
|
-
"skipFiles": ["<node_internals>/**"]
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Associate .box files with HTML for syntax highlighting
|
|
3
|
-
"files.associations": {
|
|
4
|
-
"*.box": "html"
|
|
5
|
-
},
|
|
6
|
-
|
|
7
|
-
// Enable Emmet in .box files for fast HTML typing
|
|
8
|
-
"emmet.includeLanguages": {
|
|
9
|
-
"box": "html"
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
// Enable autocomplete in strings (useful for box-bind attributes)
|
|
13
|
-
"editor.quickSuggestions": {
|
|
14
|
-
"strings": true
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
// Format on save for consistent code style
|
|
18
|
-
"editor.formatOnSave": true,
|
|
19
|
-
|
|
20
|
-
// Use 2 spaces for indentation (HTML/CSS/JS standard)
|
|
21
|
-
"editor.tabSize": 2,
|
|
22
|
-
|
|
23
|
-
// Wrap long lines for readability
|
|
24
|
-
"editor.wordWrap": "on",
|
|
25
|
-
|
|
26
|
-
// Show matching brackets clearly
|
|
27
|
-
"editor.bracketPairColorization.enabled": true,
|
|
28
|
-
|
|
29
|
-
// Auto-close HTML tags
|
|
30
|
-
"html.autoClosingTags": true,
|
|
31
|
-
|
|
32
|
-
// Show color decorators in CSS
|
|
33
|
-
"css.colorDecorators": true,
|
|
34
|
-
|
|
35
|
-
// Exclude build artifacts from explorer and search
|
|
36
|
-
"files.exclude": {
|
|
37
|
-
"**/node_modules": true,
|
|
38
|
-
"**/dist": false
|
|
39
|
-
},
|
|
40
|
-
"search.exclude": {
|
|
41
|
-
"**/node_modules": true,
|
|
42
|
-
"**/dist": true
|
|
43
|
-
}
|
|
44
|
-
}
|