canxjs 1.0.0 → 1.0.1
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/cli/bin.ts +30 -0
- package/cli/create.ts +14 -10
- package/package.json +4 -4
package/cli/bin.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { existsSync, mkdirSync, writeFileSync, readdirSync } from 'fs';
|
|
8
8
|
import { join, resolve, basename } from 'path';
|
|
9
9
|
import { spawnSync } from 'child_process';
|
|
10
|
+
import { createProject } from './create';
|
|
10
11
|
|
|
11
12
|
const VERSION = '1.0.0';
|
|
12
13
|
|
|
@@ -331,6 +332,34 @@ function generateFile(type: string, name: string, options: string[] = []) {
|
|
|
331
332
|
// ============================================
|
|
332
333
|
|
|
333
334
|
const commands: Record<string, { description: string; handler: (args: string[]) => void | Promise<void> }> = {
|
|
335
|
+
new: {
|
|
336
|
+
description: 'Create a new CanxJS project',
|
|
337
|
+
handler: (args) => {
|
|
338
|
+
const name = args[0];
|
|
339
|
+
const template = args.includes('--api') ? 'api' : args.includes('--micro') ? 'microservice' : 'mvc';
|
|
340
|
+
|
|
341
|
+
if (!name) {
|
|
342
|
+
console.error('Usage: canx new <project-name> [options]');
|
|
343
|
+
process.exit(1);
|
|
344
|
+
}
|
|
345
|
+
createProject(name, template);
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
create: {
|
|
350
|
+
description: 'Alias for "new"',
|
|
351
|
+
handler: (args) => {
|
|
352
|
+
const name = args[0];
|
|
353
|
+
const template = args.includes('--api') ? 'api' : args.includes('--micro') ? 'microservice' : 'mvc';
|
|
354
|
+
|
|
355
|
+
if (!name) {
|
|
356
|
+
console.error('Usage: canx create <project-name> [options]');
|
|
357
|
+
process.exit(1);
|
|
358
|
+
}
|
|
359
|
+
createProject(name, template);
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
|
|
334
363
|
serve: {
|
|
335
364
|
description: 'Start development server with hot reload',
|
|
336
365
|
handler: () => {
|
|
@@ -560,6 +589,7 @@ Commands:`);
|
|
|
560
589
|
|
|
561
590
|
// Group commands
|
|
562
591
|
const groups: Record<string, string[]> = {
|
|
592
|
+
'Project': ['new', 'create'],
|
|
563
593
|
'Development': ['serve', 'build', 'routes'],
|
|
564
594
|
'Generators': ['make:controller', 'make:model', 'make:middleware', 'make:migration', 'make:seeder', 'make:service', 'make:notification'],
|
|
565
595
|
'Database': ['db:migrate', 'db:rollback', 'db:seed', 'db:fresh'],
|
package/cli/create.ts
CHANGED
|
@@ -402,12 +402,13 @@ Next steps:
|
|
|
402
402
|
}
|
|
403
403
|
|
|
404
404
|
// CLI entry
|
|
405
|
-
|
|
406
|
-
const
|
|
407
|
-
const
|
|
405
|
+
if (import.meta.main) {
|
|
406
|
+
const args = process.argv.slice(2);
|
|
407
|
+
const projectName = args.find(arg => !arg.startsWith('-'));
|
|
408
|
+
const template = args.includes('--api') ? 'api' : args.includes('--micro') ? 'microservice' : 'mvc';
|
|
408
409
|
|
|
409
|
-
function showHelp() {
|
|
410
|
-
|
|
410
|
+
function showHelp() {
|
|
411
|
+
console.log(`
|
|
411
412
|
CanxJS CLI - Project Scaffolding
|
|
412
413
|
|
|
413
414
|
Usage:
|
|
@@ -423,11 +424,14 @@ Examples:
|
|
|
423
424
|
bunx create-canx my-api --api
|
|
424
425
|
bunx create-canx my-service --micro
|
|
425
426
|
`);
|
|
426
|
-
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (args.includes('--help') || args.includes('-h') || !projectName) {
|
|
430
|
+
showHelp();
|
|
431
|
+
process.exit(0);
|
|
432
|
+
}
|
|
427
433
|
|
|
428
|
-
|
|
429
|
-
showHelp();
|
|
430
|
-
process.exit(0);
|
|
434
|
+
createProject(projectName, template);
|
|
431
435
|
}
|
|
432
436
|
|
|
433
|
-
createProject
|
|
437
|
+
export { createProject };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "canxjs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Ultra-fast async-first MVC backend framework for Bun runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -88,10 +88,10 @@
|
|
|
88
88
|
},
|
|
89
89
|
"repository": {
|
|
90
90
|
"type": "git",
|
|
91
|
-
"url": "git+https://github.com/
|
|
91
|
+
"url": "git+https://github.com/chandafa/canx.JS.git"
|
|
92
92
|
},
|
|
93
93
|
"bugs": {
|
|
94
|
-
"url": "https://github.com/
|
|
94
|
+
"url": "https://github.com/chandafa/canx.JS/issues"
|
|
95
95
|
},
|
|
96
|
-
"homepage": "https://
|
|
96
|
+
"homepage": "https://github.com/chandafa/canx.JS#readme"
|
|
97
97
|
}
|