juxscript 1.0.50 → 1.0.51
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 +25 -21
- package/machinery/config.js +47 -0
- package/machinery/server.js +3 -3
- package/package.json +1 -1
- package/presets/{jux.jux → default/index.jux} +1 -1
- package/presets/default/layout.jux +1 -1
package/bin/cli.js
CHANGED
|
@@ -147,6 +147,10 @@ import {
|
|
|
147
147
|
} from '../machinery/compiler.js';
|
|
148
148
|
import { generateDocs } from '../machinery/doc-generator.js';
|
|
149
149
|
import { start } from '../machinery/server.js';
|
|
150
|
+
import { loadConfig, runBootstrap } from '../machinery/config.js';
|
|
151
|
+
|
|
152
|
+
// ✅ Load config BEFORE setting up PATHS
|
|
153
|
+
const config = await loadConfig(process.cwd());
|
|
150
154
|
|
|
151
155
|
// CLEAR PATH CONTRACT - CONVENTIONS
|
|
152
156
|
const PATHS = {
|
|
@@ -158,25 +162,25 @@ const PATHS = {
|
|
|
158
162
|
|
|
159
163
|
// Where user's .jux source files live (CONVENTION: ./jux/)
|
|
160
164
|
get juxSource() {
|
|
161
|
-
return path.join(this.projectRoot,
|
|
165
|
+
return path.join(this.projectRoot, config.sourceDir);
|
|
162
166
|
},
|
|
163
167
|
|
|
164
168
|
// Where jux lib files are (components, layouts, etc.)
|
|
165
169
|
get juxLib() {
|
|
166
|
-
return path.
|
|
170
|
+
return path.resolve(__dirname, '..', 'lib');
|
|
167
171
|
},
|
|
168
172
|
|
|
169
173
|
// Where frontend build output goes (CONVENTION: ./jux-dist/)
|
|
170
174
|
get frontendDist() {
|
|
171
|
-
return path.join(this.projectRoot,
|
|
175
|
+
return path.join(this.projectRoot, config.distDir);
|
|
172
176
|
}
|
|
173
177
|
};
|
|
174
178
|
|
|
175
179
|
console.log('📍 JUX Paths:');
|
|
176
180
|
console.log(` Package: ${PATHS.packageRoot}`);
|
|
177
181
|
console.log(` Project: ${PATHS.projectRoot}`);
|
|
178
|
-
console.log(` Source: ${PATHS.juxSource}`);
|
|
179
|
-
console.log(` Output: ${PATHS.frontendDist}`);
|
|
182
|
+
console.log(` Source: ${PATHS.juxSource} (from config: ${config.sourceDir})`);
|
|
183
|
+
console.log(` Output: ${PATHS.frontendDist} (from config: ${config.distDir})`);
|
|
180
184
|
console.log(` Lib: ${PATHS.juxLib}\n`);
|
|
181
185
|
|
|
182
186
|
/**
|
|
@@ -208,7 +212,7 @@ function findJuxFiles(dir, fileList = []) {
|
|
|
208
212
|
*
|
|
209
213
|
* @param {boolean} isServe - Whether building for dev server
|
|
210
214
|
*/
|
|
211
|
-
async function buildProject(isServe = false) {
|
|
215
|
+
async function buildProject(isServe = false, wsPort = 3001) {
|
|
212
216
|
const buildStartTime = performance.now();
|
|
213
217
|
console.log('🔨 Building JUX frontend...\n');
|
|
214
218
|
|
|
@@ -430,9 +434,9 @@ jux.paragraph('counter')
|
|
|
430
434
|
console.log('+ Created package.json');
|
|
431
435
|
}
|
|
432
436
|
|
|
433
|
-
// Create .gitignore
|
|
437
|
+
// Create .gitignore with config.distDir
|
|
434
438
|
const gitignorePath = path.join(PATHS.projectRoot, '.gitignore');
|
|
435
|
-
const gitignoreContent =
|
|
439
|
+
const gitignoreContent = `${config.distDir}/\nnode_modules/\n.DS_Store\n`;
|
|
436
440
|
|
|
437
441
|
if (!fs.existsSync(gitignorePath)) {
|
|
438
442
|
fs.writeFileSync(gitignorePath, gitignoreContent);
|
|
@@ -458,8 +462,8 @@ jux.paragraph('counter')
|
|
|
458
462
|
|
|
459
463
|
console.log('\n✅ JUX project initialized!\n');
|
|
460
464
|
console.log('Project structure:');
|
|
461
|
-
console.log(
|
|
462
|
-
console.log(
|
|
465
|
+
console.log(` ${config.sourceDir}/ # Your source files`);
|
|
466
|
+
console.log(` ${config.distDir}/ # Build output (git-ignored)`);
|
|
463
467
|
console.log(' juxconfig.js # Configuration');
|
|
464
468
|
console.log(' package.json # Dependencies\n');
|
|
465
469
|
console.log('Next steps:');
|
|
@@ -467,19 +471,19 @@ jux.paragraph('counter')
|
|
|
467
471
|
console.log(' npm run dev # Start dev server\n');
|
|
468
472
|
|
|
469
473
|
} else if (command === 'build') {
|
|
470
|
-
// ✅
|
|
474
|
+
// ✅ Run bootstrap before build
|
|
475
|
+
await runBootstrap(config.bootstrap);
|
|
471
476
|
await buildProject(false);
|
|
472
477
|
console.log(`✅ Build complete: ${PATHS.frontendDist}`);
|
|
473
478
|
|
|
474
479
|
} else if (command === 'serve') {
|
|
475
|
-
// ✅
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
// Parse port arguments: npx jux serve [httpPort] [wsPort]
|
|
479
|
-
const httpPort = parseInt(process.argv[3]) || 3000;
|
|
480
|
-
const wsPort = parseInt(process.argv[4]) || 3001;
|
|
480
|
+
// ✅ Use ports from config
|
|
481
|
+
const httpPort = parseInt(process.argv[3]) || config.ports.http;
|
|
482
|
+
const wsPort = parseInt(process.argv[4]) || config.ports.ws;
|
|
481
483
|
|
|
482
|
-
await
|
|
484
|
+
await runBootstrap(config.bootstrap);
|
|
485
|
+
await buildProject(true, wsPort);
|
|
486
|
+
await start(httpPort, wsPort, PATHS.frontendDist);
|
|
483
487
|
|
|
484
488
|
} else {
|
|
485
489
|
console.log(`
|
|
@@ -488,16 +492,16 @@ JUX CLI - A JavaScript UX authorship platform
|
|
|
488
492
|
Usage:
|
|
489
493
|
npx jux create [name] Create a new JUX project
|
|
490
494
|
npx jux init Initialize JUX in current directory
|
|
491
|
-
npx jux build Build router bundle to
|
|
495
|
+
npx jux build Build router bundle to ${config.distDir}/
|
|
492
496
|
npx jux serve [http] [ws] Start dev server with hot reload
|
|
493
497
|
|
|
494
498
|
Project Structure:
|
|
495
499
|
my-project/
|
|
496
|
-
├── .
|
|
500
|
+
├── ${config.distDir}/ # Build output (git-ignored, like .git)
|
|
497
501
|
│ ├── lib/
|
|
498
502
|
│ ├── main.js
|
|
499
503
|
│ └── index.html
|
|
500
|
-
├──
|
|
504
|
+
├── ${config.sourceDir}/ # Your .jux source files
|
|
501
505
|
│ ├── index.jux
|
|
502
506
|
│ ├── layout.css
|
|
503
507
|
│ └── layout.jux
|
package/machinery/config.js
CHANGED
|
@@ -706,4 +706,51 @@ export function generateIndexHtml(distDir, routes, mainJsFilename = 'main.js') {
|
|
|
706
706
|
|
|
707
707
|
console.log(` ✓ Generated: index.html (references ${mainJsFilename})`);
|
|
708
708
|
console.log('✅ Index HTML complete\n');
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
export const defaultConfig = {
|
|
712
|
+
// Source directory for .jux files
|
|
713
|
+
sourceDir: 'jux',
|
|
714
|
+
|
|
715
|
+
// Output directory for built files (hidden like .git)
|
|
716
|
+
distDir: '.jux', // ✅ Matches your example
|
|
717
|
+
|
|
718
|
+
// Dev server ports
|
|
719
|
+
ports: {
|
|
720
|
+
http: 3000,
|
|
721
|
+
ws: 3001
|
|
722
|
+
},
|
|
723
|
+
|
|
724
|
+
// Build options
|
|
725
|
+
build: {
|
|
726
|
+
minify: false,
|
|
727
|
+
sourcemap: true
|
|
728
|
+
},
|
|
729
|
+
|
|
730
|
+
// Bootstrap functions (run before app starts)
|
|
731
|
+
bootstrap: []
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Load configuration and run bootstrap functions
|
|
736
|
+
*/
|
|
737
|
+
function loadConfig() {
|
|
738
|
+
// Load config from file
|
|
739
|
+
const configPath = path.join(__dirname, '../config.json');
|
|
740
|
+
if (fs.existsSync(configPath)) {
|
|
741
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
742
|
+
Object.assign(defaultConfig, config);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// Run bootstrap functions
|
|
746
|
+
runBootstrap();
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Run bootstrap functions
|
|
751
|
+
*/
|
|
752
|
+
function runBootstrap() {
|
|
753
|
+
console.log('🚀 Running bootstrap functions...');
|
|
754
|
+
defaultConfig.bootstrap.forEach(fn => fn());
|
|
755
|
+
console.log('✅ Bootstrap complete');
|
|
709
756
|
}
|
package/machinery/server.js
CHANGED
|
@@ -47,7 +47,7 @@ async function tryPort(startPort, maxAttempts = 5, reservedPorts = []) {
|
|
|
47
47
|
throw new Error(`Could not find available port after ${maxAttempts} attempts starting from ${startPort}`);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
async function serve(httpPort = 3000, wsPort = 3001, distDir = '
|
|
50
|
+
async function serve(httpPort = 3000, wsPort = 3001, distDir = './.jux') {
|
|
51
51
|
const app = express();
|
|
52
52
|
const absoluteDistDir = path.resolve(distDir);
|
|
53
53
|
const projectRoot = path.resolve('.');
|
|
@@ -147,6 +147,6 @@ async function serve(httpPort = 3000, wsPort = 3001, distDir = './jux-dist') {
|
|
|
147
147
|
return { server, httpPort: availableHttpPort, wsPort: availableWsPort };
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
export async function start(httpPort = 3000, wsPort = 3001) {
|
|
151
|
-
return serve(httpPort, wsPort,
|
|
150
|
+
export async function start(httpPort = 3000, wsPort = 3001, distDir = './.jux') {
|
|
151
|
+
return serve(httpPort, wsPort, distDir);
|
|
152
152
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jux } from 'juxscript';
|
|
2
2
|
|
|
3
3
|
// Import the layout styles - testing link.
|
|
4
|
-
jux.include('
|
|
4
|
+
jux.include('layout.css');
|
|
5
5
|
|
|
6
6
|
// ═══════════════════════════════════════════════════════════════════
|
|
7
7
|
// GRID LAYOUT - INITIALIZATION FUNCTION
|