@itayzrihan/create-box-app 1.0.2 → 1.0.3

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.
@@ -8,11 +8,87 @@
8
8
 
9
9
  const fs = require('fs');
10
10
  const path = require('path');
11
+ const os = require('os');
11
12
 
12
13
  const projectName = process.argv[2] || 'my-box-app';
13
14
  const targetDir = path.join(process.cwd(), projectName);
14
15
  const templateDir = path.join(__dirname, '..', 'template');
15
16
 
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
+
16
92
  async function init() {
17
93
  console.log(`\n╔══════════════════════════════════════════════════════════════╗
18
94
  ║ 📦 BOX Framework Setup ║
@@ -39,7 +115,23 @@ async function init() {
39
115
  pkg.name = projectName;
40
116
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
41
117
 
118
+ // Configure VS Code globally
119
+ const vscodeResult = configureVSCodeGlobally();
120
+
42
121
  console.log(`✅ Project created successfully!\n`);
122
+
123
+ // Show VS Code configuration status
124
+ if (vscodeResult.success) {
125
+ if (vscodeResult.alreadyConfigured) {
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
+ }
134
+
43
135
  console.log(`📋 Next steps:\n`);
44
136
  console.log(` 1. Navigate to your project:`);
45
137
  console.log(` cd ${projectName}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itayzrihan/create-box-app",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Create a new BOX Framework application with one command",
5
5
  "main": "bin/create-box-app.js",
6
6
  "bin": {