@axiomify/cli 2.0.0 → 3.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/README.md +85 -0
- package/dist/commands/dev.js +17 -7
- package/dist/commands/routes.js +2 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @axiomify/cli
|
|
2
|
+
|
|
3
|
+
The official Command Line Interface for the Axiomify framework.
|
|
4
|
+
|
|
5
|
+
`@axiomify/cli` provides a lightning-fast development experience, production-ready build steps, and powerful inspection tools for your Axiomify applications.
|
|
6
|
+
|
|
7
|
+
## 📦 Installation
|
|
8
|
+
|
|
9
|
+
We recommend installing the CLI locally as a development dependency in your project so your CI/CD pipelines can utilize it:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @axiomify/cli -D
|
|
13
|
+
````
|
|
14
|
+
|
|
15
|
+
You can also install it globally if you want to use the `init` command anywhere on your machine:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g @axiomify/cli
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 🛠️ Commands
|
|
22
|
+
|
|
23
|
+
| Command | Description |
|
|
24
|
+
| :--- | :--- |
|
|
25
|
+
| `axiomify init` | Scaffolds a new, production-ready Axiomify project. |
|
|
26
|
+
| `axiomify dev <entry>` | Starts the development server with hot-module reloading (HMR). |
|
|
27
|
+
| `axiomify build <entry>` | Compiles your TypeScript application for production. |
|
|
28
|
+
| `axiomify routes <entry>`| Inspects your app and prints a visual table of all registered routes. |
|
|
29
|
+
|
|
30
|
+
## 🚀 Usage Guide
|
|
31
|
+
|
|
32
|
+
### 1\. Project Scaffolding
|
|
33
|
+
|
|
34
|
+
Quickly generate a new project with all the necessary TypeScript configurations and adapter boilerplates:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx @axiomify/cli init my-new-app
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 2\. Development Mode
|
|
41
|
+
|
|
42
|
+
Run your application locally. The CLI automatically watches your file system and restarts the server when it detects changes.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx axiomify dev src/index.ts
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 3\. Route Inspector
|
|
49
|
+
|
|
50
|
+
Having trouble debugging an endpoint? The route inspector parses your Radix tree and prints a clean, color-coded table of every available method, path, and attached schema directly to your terminal.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx axiomify routes src/index.ts
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 4\. Production Build
|
|
57
|
+
|
|
58
|
+
Compiles your application into highly optimized JavaScript ready for edge or serverless deployment.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npx axiomify build src/index.ts
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 📖 Standard `package.json` Setup
|
|
65
|
+
|
|
66
|
+
For the best developer experience, map the CLI commands to your project's npm scripts:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"scripts": {
|
|
71
|
+
"dev": "axiomify dev src/index.ts",
|
|
72
|
+
"build": "axiomify build src/index.ts",
|
|
73
|
+
"start": "node dist/index.js",
|
|
74
|
+
"routes": "axiomify routes src/index.ts"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 📚 Documentation
|
|
80
|
+
|
|
81
|
+
For complete documentation, guides, and ecosystem packages, please visit the [Axiomify Master Repository](https://github.com/OTopman/axiomify).
|
|
82
|
+
|
|
83
|
+
## 📄 License
|
|
84
|
+
|
|
85
|
+
MIT
|
package/dist/commands/dev.js
CHANGED
|
@@ -39,7 +39,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.devServer = devServer;
|
|
40
40
|
const child_process_1 = require("child_process");
|
|
41
41
|
const esbuild = __importStar(require("esbuild"));
|
|
42
|
+
const fs_1 = __importDefault(require("fs"));
|
|
42
43
|
const path_1 = __importDefault(require("path"));
|
|
44
|
+
// 🚀 THE FIX: Dynamically detect what the user has installed
|
|
45
|
+
async function getUserExternals(cwd) {
|
|
46
|
+
try {
|
|
47
|
+
const pkg = JSON.parse(fs_1.default.readFileSync(path_1.default.join(cwd, 'package.json'), 'utf8'));
|
|
48
|
+
return [
|
|
49
|
+
...Object.keys(pkg.dependencies || {}),
|
|
50
|
+
...Object.keys(pkg.devDependencies || {}),
|
|
51
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
43
58
|
async function devServer(entry) {
|
|
44
59
|
const entryPath = path_1.default.resolve(process.cwd(), entry);
|
|
45
60
|
const outPath = path_1.default.resolve(process.cwd(), '.axiomify/dev.js');
|
|
@@ -63,18 +78,13 @@ async function devServer(entry) {
|
|
|
63
78
|
});
|
|
64
79
|
},
|
|
65
80
|
};
|
|
81
|
+
const userExternals = await getUserExternals(process.cwd());
|
|
66
82
|
const ctx = await esbuild.context({
|
|
67
83
|
entryPoints: [entryPath],
|
|
68
84
|
bundle: true,
|
|
69
85
|
platform: 'node',
|
|
70
86
|
outfile: outPath,
|
|
71
|
-
external: [
|
|
72
|
-
'express',
|
|
73
|
-
'@axiomify/core',
|
|
74
|
-
'@axiomify/express',
|
|
75
|
-
'@axiomify/logger',
|
|
76
|
-
'maskify-ts',
|
|
77
|
-
],
|
|
87
|
+
external: [...new Set([...userExternals, 'node:*'])],
|
|
78
88
|
plugins: [watchPlugin],
|
|
79
89
|
});
|
|
80
90
|
console.log(`👀 Axiomify Dev Engine watching for changes...`);
|
package/dist/commands/routes.js
CHANGED
|
@@ -56,7 +56,8 @@ async function inspectRoutes(entry) {
|
|
|
56
56
|
// 2. Clear require cache to ensure fresh load
|
|
57
57
|
delete require.cache[require.resolve(tempPath)];
|
|
58
58
|
// 3. Import the compiled app
|
|
59
|
-
const
|
|
59
|
+
const fileUrl = `file://${tempPath}?t=${Date.now()}`;
|
|
60
|
+
const mod = await Promise.resolve(`${fileUrl}`).then(s => __importStar(require(s)));
|
|
60
61
|
const app = mod.app || mod.default;
|
|
61
62
|
if (!app || typeof app.registeredRoutes === 'undefined') {
|
|
62
63
|
console.error('❌ Error: Could not find an exported Axiomify instance.');
|