juxscript 1.1.72 → 1.1.74

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/cli.js CHANGED
@@ -42,7 +42,6 @@ async function createProject(projectName) {
42
42
  // Fallback: create minimal starter
43
43
  const juxDir = path.join(targetDir, 'jux');
44
44
  fs.mkdirSync(juxDir, { recursive: true });
45
- // Updated to use jux namespace and renderTo
46
45
  fs.writeFileSync(
47
46
  path.join(juxDir, 'index.jux'),
48
47
  `import { jux } from 'juxscript';\n\njux.element('h1', { id: 'welcome' })\n .text('Welcome to JUX!')\n .render('app');\n`
@@ -58,6 +57,15 @@ async function createProject(projectName) {
58
57
  console.log(' ✓ Created juxconfig.js');
59
58
  }
60
59
 
60
+ // ✅ 4. Read config to determine public folder location
61
+ let publicDirName = 'public'; // default
62
+ try {
63
+ const configModule = await import(`file://${configDest}`);
64
+ publicDirName = configModule.config?.directories?.public || 'public';
65
+ } catch (e) {
66
+ // Use default if config can't be read
67
+ }
68
+
61
69
  // 4. Create package.json
62
70
  const pkg = {
63
71
  name: projectName,
@@ -76,7 +84,7 @@ async function createProject(projectName) {
76
84
  console.log(' ✓ Created package.json');
77
85
 
78
86
  // 5. Create public folder with examples
79
- const publicDir = path.join(targetDir, 'public');
87
+ const publicDir = path.join(targetDir, publicDirName);
80
88
  fs.mkdirSync(publicDir, { recursive: true });
81
89
 
82
90
  // Create example favicon
@@ -91,9 +99,9 @@ async function createProject(projectName) {
91
99
  `/* Custom styles for your JUX app */\nbody {\n margin: 0;\n font-family: system-ui, -apple-system, sans-serif;\n}\n`
92
100
  );
93
101
 
94
- console.log(' ✓ Created public/ folder');
102
+ console.log(` ✓ Created ${publicDirName}/ folder`);
95
103
 
96
- // 6. Create .gitignore (renumbered)
104
+ // 6. Create .gitignore
97
105
  fs.writeFileSync(
98
106
  path.join(targetDir, '.gitignore'),
99
107
  `.jux-dist/\nnode_modules/\n.DS_Store\n.env\n*.log\n`
@@ -122,7 +130,7 @@ async function createProject(projectName) {
122
130
  // COMMAND: init
123
131
  // Initializes JUX in an existing project
124
132
  // ═══════════════════════════════════════════════════════════════
125
- function initProject() {
133
+ async function initProject() {
126
134
  const targetDir = process.cwd();
127
135
 
128
136
  console.log('\n📦 Initializing JUX in current directory\n');
@@ -139,7 +147,6 @@ function initProject() {
139
147
  copyDirRecursive(templateDir, juxDir);
140
148
  console.log(' ✓ Copied template files to ./jux');
141
149
  } else {
142
- // Updated to use jux namespace and renderTo
143
150
  fs.writeFileSync(
144
151
  path.join(juxDir, 'index.jux'),
145
152
  `import { jux } from 'juxscript';\n\njux.element('h1', { id: 'welcome' })\n .text('Welcome to JUX!')\n .render('app');\n`
@@ -178,8 +185,19 @@ function initProject() {
178
185
  }
179
186
  }
180
187
 
181
- // ✅ Create public folder
182
- const publicDir = path.join(targetDir, 'public');
188
+ // ✅ 4. Read config to determine public folder location
189
+ let publicDirName = 'public'; // default
190
+ if (fs.existsSync(configDest)) {
191
+ try {
192
+ const configModule = await import(`file://${configDest}`);
193
+ publicDirName = configModule.config?.directories?.public || 'public';
194
+ } catch (e) {
195
+ // Use default if config can't be read
196
+ }
197
+ }
198
+
199
+ // ✅ 5. Create configured public folder
200
+ const publicDir = path.join(targetDir, publicDirName);
183
201
  if (!fs.existsSync(publicDir)) {
184
202
  fs.mkdirSync(publicDir, { recursive: true });
185
203
 
@@ -188,7 +206,7 @@ function initProject() {
188
206
  `/* Custom styles */\nbody { margin: 0; font-family: system-ui; }\n`
189
207
  );
190
208
 
191
- console.log(' ✓ Created public/ folder');
209
+ console.log(` ✓ Created ${publicDirName}/ folder`);
192
210
  }
193
211
 
194
212
  console.log('\n✅ Initialized. Run: npm run dev\n');
@@ -280,12 +298,12 @@ Options:
280
298
  // ═══════════════════════════════════════════════════════════════
281
299
  switch (command) {
282
300
  case 'create':
283
- createProject(args[0]);
301
+ createProject(args[0]); // ✅ Already async, no await needed at top level
284
302
  break;
285
303
 
286
304
  case 'init':
287
305
  case 'install':
288
- initProject();
306
+ initProject(); // ✅ Already async, no await needed at top level
289
307
  break;
290
308
 
291
309
  case 'build':
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "totalComponents": 63,
3
- "generatedAt": "2026-02-11T21:53:07.299Z",
3
+ "generatedAt": "2026-02-11T22:12:04.679Z",
4
4
  "components": [
5
5
  {
6
6
  "file": "alert.js",
@@ -9,6 +9,7 @@ export const config = {
9
9
  directories: {
10
10
  source: './jux', // Where your .jux files live
11
11
  distribution: './.jux-dist', // Where build artifacts go
12
+ public: './public' // ✅ Static assets folder (CSS, images, fonts, etc.)
12
13
  },
13
14
 
14
15
  // Application Defaults
@@ -23,7 +23,8 @@ try {
23
23
  // ═══════════════════════════════════════════════════════════════
24
24
  const directories = {
25
25
  source: rawConfig.directories?.source || './jux',
26
- distribution: rawConfig.directories?.distribution || './.jux-dist'
26
+ distribution: rawConfig.directories?.distribution || './.jux-dist',
27
+ public: rawConfig.directories?.public || './public' // ✅ Configurable public folder
27
28
  };
28
29
 
29
30
  const defaults = {
@@ -36,7 +37,7 @@ const defaults = {
36
37
  const paths = {
37
38
  source: path.resolve(PROJECT_ROOT, directories.source),
38
39
  distribution: path.resolve(PROJECT_ROOT, directories.distribution),
39
- public: path.resolve(PROJECT_ROOT, 'public') // ✅ Add public path
40
+ public: path.resolve(PROJECT_ROOT, directories.public) // ✅ Use configured path
40
41
  };
41
42
 
42
43
  // ═══════════════════════════════════════════════════════════════
@@ -68,8 +69,9 @@ console.log(`\n`);
68
69
  const compiler = new JuxCompiler({
69
70
  srcDir: paths.source,
70
71
  distDir: paths.distribution,
72
+ publicDir: directories.public, // ✅ Pass configured public directory name
71
73
  defaults,
72
- paths
74
+ paths // ✅ Pass resolved paths object (includes paths.public)
73
75
  });
74
76
 
75
77
  compiler.build()
@@ -13,6 +13,7 @@ export class JuxCompiler {
13
13
  this.config = config;
14
14
  this.srcDir = config.srcDir || './jux';
15
15
  this.distDir = config.distDir || './.jux-dist';
16
+ this.publicDir = config.publicDir || './public'; // ✅ Configurable public path
16
17
  this.defaults = config.defaults || {};
17
18
  this.paths = config.paths || {};
18
19
  this._juxscriptExports = null;
@@ -505,8 +506,10 @@ navigate(location.pathname);
505
506
  * Copy public folder contents to dist
506
507
  */
507
508
  copyPublicFolder() {
508
- const projectRoot = process.cwd();
509
- const publicSrc = path.resolve(projectRoot, 'public');
509
+ // Use configured public path or resolve from paths object
510
+ const publicSrc = this.paths.public
511
+ ? this.paths.public
512
+ : path.resolve(process.cwd(), this.publicDir);
510
513
 
511
514
  if (!fs.existsSync(publicSrc)) {
512
515
  return; // No public folder, skip
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juxscript",
3
- "version": "1.1.72",
3
+ "version": "1.1.74",
4
4
  "type": "module",
5
5
  "description": "A JavaScript UX authorship platform",
6
6
  "main": "index.js",