@elmoorx/cli 2.0.0-alpha.25 → 3.0.0-alpha.2
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 +3 -3
- package/package.json +5 -1
- package/src/build.ts +2 -2
- package/src/commands.ts +14 -14
- package/src/create.ts +4 -4
- package/src/dev.ts +4 -4
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @elmoorx/cli
|
|
2
2
|
|
|
3
3
|
> CLI tool: init, dev, build, deploy, generate, doctor
|
|
4
4
|
|
|
@@ -7,13 +7,13 @@ Part of the [Wafra Framework](https://github.com/wafra/framework) — Build fast
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install @
|
|
10
|
+
npm install @elmoorx/cli
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Quick Start
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
-
import { /* exports */ } from '@
|
|
16
|
+
import { /* exports */ } from '@elmoorx/cli';
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elmoorx/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.2",
|
|
4
4
|
"description": "CLI tool: init, dev, build, deploy, generate, doctor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -36,5 +36,9 @@
|
|
|
36
36
|
"types": "./src/index.ts",
|
|
37
37
|
"exports": {
|
|
38
38
|
".": "./src/index.ts"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public",
|
|
42
|
+
"registry": "https://registry.npmjs.org/"
|
|
39
43
|
}
|
|
40
44
|
}
|
package/src/build.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* wafra build
|
|
3
3
|
* Bundles the app for production:
|
|
4
|
-
* - Compile all routes via @
|
|
4
|
+
* - Compile all routes via @elmoorx/compiler
|
|
5
5
|
* - Pre-render static HTML for SSR routes
|
|
6
6
|
* - Tree-shake unused runtime APIs
|
|
7
7
|
* - Minify + gzip — output to dist/
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { readdir, readFile, writeFile, mkdir, stat } from "node:fs/promises";
|
|
11
11
|
import { existsSync } from "node:fs";
|
|
12
12
|
import { join, extname, relative } from "node:path";
|
|
13
|
-
import { compile } from "@
|
|
13
|
+
import { compile } from "@elmoorx/compiler";
|
|
14
14
|
|
|
15
15
|
export async function buildProject(rootDir: string): Promise<void> {
|
|
16
16
|
const srcDir = join(rootDir, "src");
|
package/src/commands.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @elmoorx/cli — Additional commands
|
|
3
3
|
* ============================================
|
|
4
4
|
* wafra doctor Diagnose project health
|
|
5
5
|
* wafra info Show project + environment info
|
|
@@ -38,18 +38,18 @@ export async function doctor(rootDir: string): Promise<DoctorCheck[]> {
|
|
|
38
38
|
|
|
39
39
|
// Check 2: Wafra dependencies
|
|
40
40
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
41
|
-
if (deps["@
|
|
41
|
+
if (deps["@elmoorx/runtime"]) {
|
|
42
42
|
checks.push({
|
|
43
|
-
name: "@
|
|
43
|
+
name: "@elmoorx/runtime",
|
|
44
44
|
status: "pass",
|
|
45
|
-
message: `Installed — ${deps["@
|
|
45
|
+
message: `Installed — ${deps["@elmoorx/runtime"]}`,
|
|
46
46
|
});
|
|
47
47
|
} else {
|
|
48
48
|
checks.push({
|
|
49
|
-
name: "@
|
|
49
|
+
name: "@elmoorx/runtime",
|
|
50
50
|
status: "fail",
|
|
51
51
|
message: "Not installed",
|
|
52
|
-
fix: "npm install @
|
|
52
|
+
fix: "npm install @elmoorx/runtime",
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -78,7 +78,7 @@ export async function doctor(rootDir: string): Promise<DoctorCheck[]> {
|
|
|
78
78
|
const jsxSetting = tsconfig.compilerOptions?.jsx;
|
|
79
79
|
if (jsxSetting === "react-jsx") {
|
|
80
80
|
const jsxImport = tsconfig.compilerOptions?.jsxImportSource;
|
|
81
|
-
if (jsxImport === "@
|
|
81
|
+
if (jsxImport === "@elmoorx/runtime") {
|
|
82
82
|
checks.push({
|
|
83
83
|
name: "TypeScript JSX",
|
|
84
84
|
status: "pass",
|
|
@@ -88,8 +88,8 @@ export async function doctor(rootDir: string): Promise<DoctorCheck[]> {
|
|
|
88
88
|
checks.push({
|
|
89
89
|
name: "TypeScript JSX",
|
|
90
90
|
status: "warn",
|
|
91
|
-
message: `jsxImportSource is "${jsxImport}" — should be "@
|
|
92
|
-
fix: 'Set "jsxImportSource": "@
|
|
91
|
+
message: `jsxImportSource is "${jsxImport}" — should be "@elmoorx/runtime"`,
|
|
92
|
+
fix: 'Set "jsxImportSource": "@elmoorx/runtime" in tsconfig.json',
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
} else {
|
|
@@ -160,7 +160,7 @@ export async function doctor(rootDir: string): Promise<DoctorCheck[]> {
|
|
|
160
160
|
checks.push({
|
|
161
161
|
name: "Security headers",
|
|
162
162
|
status: "pass",
|
|
163
|
-
message: "Auto-applied by @
|
|
163
|
+
message: "Auto-applied by @elmoorx/server",
|
|
164
164
|
});
|
|
165
165
|
|
|
166
166
|
// Check 8: ESLint config
|
|
@@ -177,7 +177,7 @@ export async function doctor(rootDir: string): Promise<DoctorCheck[]> {
|
|
|
177
177
|
name: "ESLint",
|
|
178
178
|
status: "warn",
|
|
179
179
|
message: "No ESLint config found",
|
|
180
|
-
fix: "Install @
|
|
180
|
+
fix: "Install @elmoorx/eslint-plugin for Wafra best practices",
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
183
|
} catch (err) {
|
|
@@ -226,7 +226,7 @@ export interface ProjectInfo {
|
|
|
226
226
|
export async function info(rootDir: string): Promise<ProjectInfo> {
|
|
227
227
|
const pkg = JSON.parse(await readFile(join(rootDir, "package.json"), "utf-8"));
|
|
228
228
|
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
229
|
-
const wafraPackages = Object.keys(allDeps).filter(d => d.startsWith("@
|
|
229
|
+
const wafraPackages = Object.keys(allDeps).filter(d => d.startsWith("@elmoorx/"));
|
|
230
230
|
|
|
231
231
|
// Count source files
|
|
232
232
|
const srcDir = join(rootDir, "src");
|
|
@@ -329,7 +329,7 @@ export async function analyze(rootDir: string): Promise<BundleAnalysis> {
|
|
|
329
329
|
recommendations.push("JavaScript is large — review imports and use tree-shaking");
|
|
330
330
|
}
|
|
331
331
|
if (byType[".css"]?.size > 30_000) {
|
|
332
|
-
recommendations.push("CSS is large — consider using @
|
|
332
|
+
recommendations.push("CSS is large — consider using @elmoorx/css for scoped styles");
|
|
333
333
|
}
|
|
334
334
|
if (!files.some(f => f.path.endsWith(".html"))) {
|
|
335
335
|
recommendations.push("No HTML files in dist/ — check SSR/SSG configuration");
|
|
@@ -381,7 +381,7 @@ export async function checkUpdates(rootDir: string): Promise<{
|
|
|
381
381
|
}> {
|
|
382
382
|
const pkg = JSON.parse(await readFile(join(rootDir, "package.json"), "utf-8"));
|
|
383
383
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
384
|
-
const wafraDeps = Object.keys(deps).filter(d => d.startsWith("@
|
|
384
|
+
const wafraDeps = Object.keys(deps).filter(d => d.startsWith("@elmoorx/"));
|
|
385
385
|
|
|
386
386
|
const result = [];
|
|
387
387
|
for (const dep of wafraDeps) {
|
package/src/create.ts
CHANGED
|
@@ -32,10 +32,10 @@ export async function createProject(name: string): Promise<void> {
|
|
|
32
32
|
deploy: "wafra deploy",
|
|
33
33
|
},
|
|
34
34
|
dependencies: {
|
|
35
|
-
"@
|
|
35
|
+
"@elmoorx/runtime": "^1.0.0",
|
|
36
36
|
},
|
|
37
37
|
devDependencies: {
|
|
38
|
-
"@
|
|
38
|
+
"@elmoorx/cli": "^1.0.0",
|
|
39
39
|
typescript: "^5.4.0",
|
|
40
40
|
},
|
|
41
41
|
},
|
|
@@ -55,7 +55,7 @@ export async function createProject(name: string): Promise<void> {
|
|
|
55
55
|
lib: ["ES2022", "DOM", "DOM.Iterable"],
|
|
56
56
|
strict: true,
|
|
57
57
|
jsx: "react-jsx",
|
|
58
|
-
jsxImportSource: "@
|
|
58
|
+
jsxImportSource: "@elmoorx/runtime",
|
|
59
59
|
outDir: "dist",
|
|
60
60
|
},
|
|
61
61
|
include: ["src/**/*"],
|
|
@@ -67,7 +67,7 @@ export async function createProject(name: string): Promise<void> {
|
|
|
67
67
|
|
|
68
68
|
await writeFile(
|
|
69
69
|
join(root, "src", "index.wafra.tsx"),
|
|
70
|
-
`import { $state, island, h } from "@
|
|
70
|
+
`import { $state, island, h } from "@elmoorx/runtime";
|
|
71
71
|
|
|
72
72
|
const Counter = island(() => {
|
|
73
73
|
const count = $state(0);
|
package/src/dev.ts
CHANGED
|
@@ -12,8 +12,8 @@ import { readFile, writeFile, mkdir, readdir } from "node:fs/promises";
|
|
|
12
12
|
import { existsSync, watch } from "node:fs";
|
|
13
13
|
import { join, extname, dirname } from "node:path";
|
|
14
14
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
15
|
-
import { SECURITY_HEADERS, generateCsrfToken } from "@
|
|
16
|
-
import { compile } from "@
|
|
15
|
+
import { SECURITY_HEADERS, generateCsrfToken } from "@elmoorx/runtime";
|
|
16
|
+
import { compile } from "@elmoorx/compiler";
|
|
17
17
|
|
|
18
18
|
export interface DevServerOptions {
|
|
19
19
|
rootDir: string;
|
|
@@ -166,7 +166,7 @@ async function ssrRoute(
|
|
|
166
166
|
format: "esm",
|
|
167
167
|
target: "es2022",
|
|
168
168
|
jsx: "automatic",
|
|
169
|
-
jsxImportSource: "@
|
|
169
|
+
jsxImportSource: "@elmoorx/runtime",
|
|
170
170
|
define: {
|
|
171
171
|
"import.meta.env.SSR": "true",
|
|
172
172
|
},
|
|
@@ -187,7 +187,7 @@ async function ssrRoute(
|
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
const { renderToString } = await import("@
|
|
190
|
+
const { renderToString } = await import("@elmoorx/runtime");
|
|
191
191
|
const node = Component({ url: url.pathname });
|
|
192
192
|
const html = renderToString(node);
|
|
193
193
|
|