@axiomify/cli 2.0.0
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/dist/commands/build.d.ts +1 -0
- package/dist/commands/build.js +69 -0
- package/dist/commands/dev.d.ts +1 -0
- package/dist/commands/dev.js +82 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +69 -0
- package/dist/commands/routes.d.ts +1 -0
- package/dist/commands/routes.js +93 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +34 -0
- package/package.json +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildProject(entry: string): Promise<void>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.buildProject = buildProject;
|
|
40
|
+
const esbuild = __importStar(require("esbuild"));
|
|
41
|
+
const path_1 = __importDefault(require("path"));
|
|
42
|
+
async function buildProject(entry) {
|
|
43
|
+
const entryPath = path_1.default.resolve(process.cwd(), entry);
|
|
44
|
+
const outPath = path_1.default.resolve(process.cwd(), 'dist/index.js');
|
|
45
|
+
console.log(`šØ Building production bundle from ${entry}...`);
|
|
46
|
+
try {
|
|
47
|
+
await esbuild.build({
|
|
48
|
+
entryPoints: [entryPath],
|
|
49
|
+
bundle: true,
|
|
50
|
+
platform: 'node',
|
|
51
|
+
target: 'node18',
|
|
52
|
+
outfile: outPath,
|
|
53
|
+
minify: true,
|
|
54
|
+
keepNames: true, // Important for preserving class names in logs
|
|
55
|
+
external: [
|
|
56
|
+
'express',
|
|
57
|
+
'@axiomify/core',
|
|
58
|
+
'@axiomify/express',
|
|
59
|
+
// In a real monorepo, these might be bundled or kept external based on preference.
|
|
60
|
+
// For Node.js backends, keeping node_modules external is standard practice.
|
|
61
|
+
],
|
|
62
|
+
});
|
|
63
|
+
console.log(`ā
Build successful: ${outPath}`);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.error('ā Build failed:', error);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function devServer(entry: string): Promise<void>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.devServer = devServer;
|
|
40
|
+
const child_process_1 = require("child_process");
|
|
41
|
+
const esbuild = __importStar(require("esbuild"));
|
|
42
|
+
const path_1 = __importDefault(require("path"));
|
|
43
|
+
async function devServer(entry) {
|
|
44
|
+
const entryPath = path_1.default.resolve(process.cwd(), entry);
|
|
45
|
+
const outPath = path_1.default.resolve(process.cwd(), '.axiomify/dev.js');
|
|
46
|
+
let nodeProcess = null;
|
|
47
|
+
const restartServer = () => {
|
|
48
|
+
if (nodeProcess)
|
|
49
|
+
nodeProcess.kill();
|
|
50
|
+
console.log(`\nš Restarting server...`);
|
|
51
|
+
nodeProcess = (0, child_process_1.spawn)('node', [outPath], { stdio: 'inherit' });
|
|
52
|
+
};
|
|
53
|
+
const watchPlugin = {
|
|
54
|
+
name: 'watch-plugin',
|
|
55
|
+
setup(build) {
|
|
56
|
+
build.onEnd((result) => {
|
|
57
|
+
if (result.errors.length > 0) {
|
|
58
|
+
console.error('ā Build failed. Waiting for changes...');
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
restartServer();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
const ctx = await esbuild.context({
|
|
67
|
+
entryPoints: [entryPath],
|
|
68
|
+
bundle: true,
|
|
69
|
+
platform: 'node',
|
|
70
|
+
outfile: outPath,
|
|
71
|
+
external: [
|
|
72
|
+
'express',
|
|
73
|
+
'@axiomify/core',
|
|
74
|
+
'@axiomify/express',
|
|
75
|
+
'@axiomify/logger',
|
|
76
|
+
'maskify-ts',
|
|
77
|
+
],
|
|
78
|
+
plugins: [watchPlugin],
|
|
79
|
+
});
|
|
80
|
+
console.log(`š Axiomify Dev Engine watching for changes...`);
|
|
81
|
+
await ctx.watch();
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initProject(targetDir: string): Promise<void>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.initProject = initProject;
|
|
7
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
async function initProject(targetDir) {
|
|
10
|
+
const dir = path_1.default.resolve(process.cwd(), targetDir);
|
|
11
|
+
await promises_1.default.mkdir(path_1.default.join(dir, 'src'), { recursive: true });
|
|
12
|
+
const pkgJson = {
|
|
13
|
+
name: 'axiomify-app',
|
|
14
|
+
version: '1.0.0',
|
|
15
|
+
private: true,
|
|
16
|
+
scripts: {
|
|
17
|
+
dev: 'axiomify dev src/index.ts',
|
|
18
|
+
build: 'axiomify build src/index.ts',
|
|
19
|
+
start: 'node dist/index.js',
|
|
20
|
+
routes: 'axiomify routes src/index.ts',
|
|
21
|
+
},
|
|
22
|
+
dependencies: {
|
|
23
|
+
'@axiomify/core': 'latest',
|
|
24
|
+
'@axiomify/express': 'latest',
|
|
25
|
+
},
|
|
26
|
+
devDependencies: {
|
|
27
|
+
typescript: '^5.0.0',
|
|
28
|
+
'@types/node': '^20.0.0',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
const tsConfig = {
|
|
32
|
+
compilerOptions: {
|
|
33
|
+
target: 'ES2022',
|
|
34
|
+
module: 'CommonJS',
|
|
35
|
+
moduleResolution: 'node',
|
|
36
|
+
strict: true,
|
|
37
|
+
esModuleInterop: true,
|
|
38
|
+
skipLibCheck: true,
|
|
39
|
+
forceConsistentCasingInFileNames: true,
|
|
40
|
+
outDir: './dist',
|
|
41
|
+
},
|
|
42
|
+
include: ['src/**/*'],
|
|
43
|
+
};
|
|
44
|
+
const indexTs = `import { Axiomify, z } from '@axiomify/core';
|
|
45
|
+
import { ExpressAdapter } from '@axiomify/express';
|
|
46
|
+
|
|
47
|
+
// Exporting the app instance is required for the 'axiomify routes' CLI command
|
|
48
|
+
export const app = new Axiomify();
|
|
49
|
+
|
|
50
|
+
app.route({
|
|
51
|
+
method: 'GET',
|
|
52
|
+
path: '/health',
|
|
53
|
+
handler: async (req, res) => {
|
|
54
|
+
res.status(200).send({ status: 'healthy', timestamp: Date.now() }, 'System Operational');
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Prevent listening during CLI inspection
|
|
59
|
+
if (require.main === module) {
|
|
60
|
+
const adapter = new ExpressAdapter(app);
|
|
61
|
+
adapter.listen(3000, () => console.log('š Axiomify engine online on port 3000'));
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
await promises_1.default.writeFile(path_1.default.join(dir, 'package.json'), JSON.stringify(pkgJson, null, 2));
|
|
65
|
+
await promises_1.default.writeFile(path_1.default.join(dir, 'tsconfig.json'), JSON.stringify(tsConfig, null, 2));
|
|
66
|
+
await promises_1.default.writeFile(path_1.default.join(dir, 'src', 'index.ts'), indexTs);
|
|
67
|
+
console.log(`ā
Axiomify project initialized in ${dir}`);
|
|
68
|
+
console.log(`š¦ Run 'npm install' to install dependencies.`);
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function inspectRoutes(entry: string): Promise<void>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.inspectRoutes = inspectRoutes;
|
|
40
|
+
const esbuild = __importStar(require("esbuild"));
|
|
41
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
42
|
+
const path_1 = __importDefault(require("path"));
|
|
43
|
+
async function inspectRoutes(entry) {
|
|
44
|
+
const entryPath = path_1.default.resolve(process.cwd(), entry);
|
|
45
|
+
const tempPath = path_1.default.resolve(process.cwd(), '.axiomify/inspect.cjs');
|
|
46
|
+
try {
|
|
47
|
+
// 1. Compile the app to a temporary CommonJS file
|
|
48
|
+
await esbuild.build({
|
|
49
|
+
entryPoints: [entryPath],
|
|
50
|
+
bundle: true,
|
|
51
|
+
platform: 'node',
|
|
52
|
+
format: 'cjs',
|
|
53
|
+
outfile: tempPath,
|
|
54
|
+
external: ['express', '@axiomify/core', '@axiomify/express'],
|
|
55
|
+
});
|
|
56
|
+
// 2. Clear require cache to ensure fresh load
|
|
57
|
+
delete require.cache[require.resolve(tempPath)];
|
|
58
|
+
// 3. Import the compiled app
|
|
59
|
+
const mod = require(tempPath);
|
|
60
|
+
const app = mod.app || mod.default;
|
|
61
|
+
if (!app || typeof app.registeredRoutes === 'undefined') {
|
|
62
|
+
console.error('ā Error: Could not find an exported Axiomify instance.');
|
|
63
|
+
console.error('Ensure your entry file exports the app: `export const app = new Axiomify();`');
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
// 4. Format and print the routes
|
|
67
|
+
console.log('\nš§ Registered Axiomify Routes:');
|
|
68
|
+
console.log('----------------------------------------------------');
|
|
69
|
+
console.log(`${'METHOD'.padEnd(10)} | ${'PATH'.padEnd(30)} | VALIDATION`);
|
|
70
|
+
console.log('----------------------------------------------------');
|
|
71
|
+
app.registeredRoutes.forEach((route) => {
|
|
72
|
+
const schemas = [];
|
|
73
|
+
if (route.schema?.body)
|
|
74
|
+
schemas.push('Body');
|
|
75
|
+
if (route.schema?.query)
|
|
76
|
+
schemas.push('Query');
|
|
77
|
+
if (route.schema?.params)
|
|
78
|
+
schemas.push('Params');
|
|
79
|
+
const validationStr = schemas.length > 0 ? schemas.join(', ') : 'None';
|
|
80
|
+
console.log(`${route.method.padEnd(10)} | ${route.path.padEnd(30)} | ${validationStr}`);
|
|
81
|
+
});
|
|
82
|
+
console.log('----------------------------------------------------\n');
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.error('ā Failed to inspect routes:', error);
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
// 5. Cleanup temp file
|
|
89
|
+
await promises_1.default
|
|
90
|
+
.rm(path_1.default.dirname(tempPath), { recursive: true, force: true })
|
|
91
|
+
.catch(() => { });
|
|
92
|
+
}
|
|
93
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const build_1 = require("./commands/build");
|
|
6
|
+
const dev_1 = require("./commands/dev");
|
|
7
|
+
const init_1 = require("./commands/init");
|
|
8
|
+
const routes_1 = require("./commands/routes");
|
|
9
|
+
const program = new commander_1.Command();
|
|
10
|
+
program
|
|
11
|
+
.name('axiomify')
|
|
12
|
+
.description('The official CLI for the Axiomify framework')
|
|
13
|
+
.version('1.0.0');
|
|
14
|
+
program
|
|
15
|
+
.command('init')
|
|
16
|
+
.description('Bootstrap a new Axiomify project')
|
|
17
|
+
.argument('[directory]', 'Target directory', '.')
|
|
18
|
+
.action(init_1.initProject);
|
|
19
|
+
program
|
|
20
|
+
.command('dev')
|
|
21
|
+
.description('Start the development server with hot-reload')
|
|
22
|
+
.argument('[entry]', 'Entry file', 'src/index.ts')
|
|
23
|
+
.action(dev_1.devServer);
|
|
24
|
+
program
|
|
25
|
+
.command('build')
|
|
26
|
+
.description('Compile the application for production')
|
|
27
|
+
.argument('[entry]', 'Entry file', 'src/index.ts')
|
|
28
|
+
.action(build_1.buildProject);
|
|
29
|
+
program
|
|
30
|
+
.command('routes')
|
|
31
|
+
.description('Inspect and list all registered routes in the application')
|
|
32
|
+
.argument('[entry]', 'Entry file', 'src/index.ts')
|
|
33
|
+
.action(routes_1.inspectRoutes);
|
|
34
|
+
program.parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@axiomify/cli",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"bin": {
|
|
5
|
+
"axiomify": "./dist/index.js"
|
|
6
|
+
},
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@axiomify/core": "*",
|
|
18
|
+
"commander": "^12.0.0",
|
|
19
|
+
"esbuild": "^0.20.1"
|
|
20
|
+
}
|
|
21
|
+
}
|