create-modularityjs 0.0.0-stage → 1.1.0-beta.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/dist/main.js +131 -0
- package/package.json +22 -6
- package/README.md +0 -3
package/dist/main.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/main.ts
|
|
4
|
+
import { createRequire } from "module";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { spawnSync } from "child_process";
|
|
7
|
+
|
|
8
|
+
// ../internal/src/Logger.ts
|
|
9
|
+
var Logger = class _Logger {
|
|
10
|
+
static groupDepth = 0;
|
|
11
|
+
frameworkName;
|
|
12
|
+
badgeSymbol;
|
|
13
|
+
isVerbose;
|
|
14
|
+
// Simple, internal ANSI escape sequences
|
|
15
|
+
static colors = {
|
|
16
|
+
reset: "\x1B[0m",
|
|
17
|
+
bold: "\x1B[1m",
|
|
18
|
+
dim: "\x1B[2m",
|
|
19
|
+
cyan: "\x1B[36m",
|
|
20
|
+
green: "\x1B[32m",
|
|
21
|
+
yellow: "\x1B[33m",
|
|
22
|
+
red: "\x1B[31m"
|
|
23
|
+
};
|
|
24
|
+
constructor(options = {}) {
|
|
25
|
+
this.frameworkName = options.frameworkName || "my-ssr";
|
|
26
|
+
this.badgeSymbol = options.badgeSymbol || "\u2B22";
|
|
27
|
+
this.isVerbose = options.verbose ?? process.argv.includes("--verbose");
|
|
28
|
+
}
|
|
29
|
+
// Generates the immutable framework branding string
|
|
30
|
+
get badge() {
|
|
31
|
+
const { bold, cyan, reset } = _Logger.colors;
|
|
32
|
+
return `${bold}${cyan}${this.badgeSymbol} ${this.frameworkName}${reset}`;
|
|
33
|
+
}
|
|
34
|
+
get indentation() {
|
|
35
|
+
return " ".repeat(_Logger.groupDepth);
|
|
36
|
+
}
|
|
37
|
+
get groupedBadge() {
|
|
38
|
+
if (_Logger.groupDepth === 0) return this.badge;
|
|
39
|
+
const { dim, reset } = _Logger.colors;
|
|
40
|
+
return `${dim}${this.frameworkName}${reset}`;
|
|
41
|
+
}
|
|
42
|
+
styleGroupedMessage(message) {
|
|
43
|
+
if (_Logger.groupDepth === 0) return message;
|
|
44
|
+
const { dim, reset } = _Logger.colors;
|
|
45
|
+
return `${dim}${message}${reset}`;
|
|
46
|
+
}
|
|
47
|
+
group(title) {
|
|
48
|
+
const { dim, reset } = _Logger.colors;
|
|
49
|
+
console.log(`${this.badge} ${dim}info${reset} ${title}`);
|
|
50
|
+
_Logger.groupDepth += 1;
|
|
51
|
+
}
|
|
52
|
+
groupEnd() {
|
|
53
|
+
_Logger.groupDepth = Math.max(0, _Logger.groupDepth - 1);
|
|
54
|
+
}
|
|
55
|
+
log(message, ...details) {
|
|
56
|
+
const { dim, reset } = _Logger.colors;
|
|
57
|
+
console.log(
|
|
58
|
+
`${this.indentation}${this.groupedBadge} ${dim}info${reset} ${this.styleGroupedMessage(message)}`,
|
|
59
|
+
...details
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
warn(message, ...details) {
|
|
63
|
+
const { yellow, reset } = _Logger.colors;
|
|
64
|
+
console.warn(
|
|
65
|
+
`${this.indentation}${this.groupedBadge} ${yellow}warn${reset} ${this.styleGroupedMessage(message)}`,
|
|
66
|
+
...details
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
// 1. Initial framework boot announcement
|
|
70
|
+
ready(port) {
|
|
71
|
+
const { green, dim, cyan, bold, reset } = _Logger.colors;
|
|
72
|
+
console.log(`
|
|
73
|
+
${this.indentation}${this.groupedBadge} ${green}ready${reset} in ${dim}dev mode${reset}`);
|
|
74
|
+
console.log(`${this.indentation} ${dim}\u2794${reset} Local: ${bold}${cyan}http://localhost:${port}${reset}
|
|
75
|
+
`);
|
|
76
|
+
}
|
|
77
|
+
// 2. High-frequency compiler or builder lifecycles (Muted unless verbose)
|
|
78
|
+
step(action, detail) {
|
|
79
|
+
if (!this.isVerbose) return;
|
|
80
|
+
const { dim, reset } = _Logger.colors;
|
|
81
|
+
const time = (/* @__PURE__ */ new Date()).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" });
|
|
82
|
+
const groupedDetail = this.styleGroupedMessage(`${action}: ${detail}`);
|
|
83
|
+
console.log(`${this.indentation}${dim}[${time}]${reset} ${this.groupedBadge} ${groupedDetail}`);
|
|
84
|
+
}
|
|
85
|
+
// 3. SSR Request completion markers
|
|
86
|
+
rendered(path2, durationMs) {
|
|
87
|
+
const { dim, bold, reset } = _Logger.colors;
|
|
88
|
+
const renderedMessage = this.styleGroupedMessage(`${path2} (${durationMs}ms)`);
|
|
89
|
+
console.log(`${this.indentation}${this.groupedBadge} ${dim}rendered${reset} ${bold}${renderedMessage}${reset}`);
|
|
90
|
+
}
|
|
91
|
+
// 4. Clean user error isolation (Removes framework noise from stack traces)
|
|
92
|
+
error(title, errorObj, context) {
|
|
93
|
+
const { bold, red, dim, reset } = _Logger.colors;
|
|
94
|
+
const error = errorObj instanceof Error ? errorObj : new Error(String(errorObj));
|
|
95
|
+
console.error(`
|
|
96
|
+
${this.indentation}${bold}${red}[${this.frameworkName}] ${title}${reset}`);
|
|
97
|
+
if (context) {
|
|
98
|
+
console.error(`${this.indentation}${dim}Context:${reset} ${bold}${context}${reset}`);
|
|
99
|
+
}
|
|
100
|
+
console.error(`${this.indentation}${red}${error.message}${reset}`);
|
|
101
|
+
if (error.stack) {
|
|
102
|
+
const cleanStack = error.stack.split("\n").slice(1).filter((line) => !line.includes("node_modules") && !line.includes("node:internal")).join("\n");
|
|
103
|
+
if (cleanStack) {
|
|
104
|
+
console.error(`${this.indentation}${dim}Stack Trace:
|
|
105
|
+
${cleanStack}${reset}
|
|
106
|
+
`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// 5. Utility window clear for Hot Module Replacement (HMR) ticks
|
|
111
|
+
clear() {
|
|
112
|
+
process.stdout.write(process.platform === "win32" ? "\x1Bc" : "\x1B[2J\x1B[3J\x1B[H");
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// src/main.ts
|
|
117
|
+
var logger = new Logger({ frameworkName: "create-modularityjs" });
|
|
118
|
+
var require2 = createRequire(import.meta.url);
|
|
119
|
+
var cliPackageJson = require2.resolve("@tmraaex/modularity/package.json");
|
|
120
|
+
var cliEntry = path.join(path.dirname(cliPackageJson), "dist", "main.js");
|
|
121
|
+
var result = spawnSync(
|
|
122
|
+
process.execPath,
|
|
123
|
+
[cliEntry, "create", ...process.argv.slice(2)],
|
|
124
|
+
{ stdio: "inherit" }
|
|
125
|
+
);
|
|
126
|
+
if (result.error) {
|
|
127
|
+
logger.error("Failed to launch the ModularityJS CLI", result.error, cliEntry);
|
|
128
|
+
process.exitCode = 1;
|
|
129
|
+
} else {
|
|
130
|
+
process.exitCode = result.status ?? 1;
|
|
131
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "create-modularityjs",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "create-modularityjs",
|
|
3
|
+
"version": "1.1.0-beta.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"create-modularityjs": "dist/main.js"
|
|
7
|
+
},
|
|
8
|
+
"files": ["dist"],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsup",
|
|
11
|
+
"prepack": "bun run build"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@tmraaex/modularity": "^1.1.0-beta.2"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@tmraaex/internal": "workspace:*",
|
|
18
|
+
"@types/node": "^26.6.5",
|
|
19
|
+
"tsup": "^8.0.0",
|
|
20
|
+
"typescript": "^5.0.0"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/README.md
DELETED