@tsed/cli 7.5.0-rc.1 → 7.5.0-rc.3
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/lib/esm/bin/boot.js +42 -0
- package/lib/esm/bin/tsed-build.js +23 -0
- package/lib/esm/bin/tsed-dev.js +131 -0
- package/lib/esm/bin/tsed.js +30 -42
- package/lib/esm/commands/index.js +1 -3
- package/lib/esm/runtimes/RuntimesModule.js +1 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/bin/boot.d.ts +1 -0
- package/lib/types/bin/tsed-build.d.ts +1 -0
- package/lib/types/bin/tsed-dev.d.ts +1 -0
- package/lib/types/bin/tsed.d.ts +1 -1
- package/lib/types/commands/index.d.ts +1 -3
- package/package.json +6 -6
- package/lib/esm/commands/build/BuildCmd.js +0 -21
- package/lib/esm/commands/dev/DevCmd.js +0 -118
- package/lib/types/commands/build/BuildCmd.d.ts +0 -9
- package/lib/types/commands/dev/DevCmd.d.ts +0 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function build(rawArgs?: string[]): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dev(rawArgs?: string[]): Promise<void>;
|
package/lib/types/bin/tsed.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
export {};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { AddCmd } from "./add/AddCmd.js";
|
|
2
|
-
import { BuildCmd } from "./build/BuildCmd.js";
|
|
3
|
-
import { DevCmd } from "./dev/DevCmd.js";
|
|
4
2
|
import { GenerateCmd } from "./generate/GenerateCmd.js";
|
|
5
3
|
import { InitCmd } from "./init/InitCmd.js";
|
|
6
4
|
import { RunCmd } from "./run/RunCmd.js";
|
|
7
5
|
import { CreateTemplateCommand } from "./template/CreateTemplateCommand.js";
|
|
8
6
|
import { UpdateCmd } from "./update/UpdateCmd.js";
|
|
9
|
-
declare const _default: (typeof CreateTemplateCommand | typeof AddCmd | typeof GenerateCmd | typeof
|
|
7
|
+
declare const _default: (typeof CreateTemplateCommand | typeof AddCmd | typeof GenerateCmd | typeof InitCmd | import("@tsed/di").FactoryTokenProvider<{
|
|
10
8
|
$prompt: any;
|
|
11
9
|
$exec: any;
|
|
12
10
|
token: import("@tsed/di").TokenProvider<import("@tsed/cli-core").CommandProvider>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/cli",
|
|
3
3
|
"description": "CLI to bootstrap your Ts.ED project",
|
|
4
|
-
"version": "7.5.0-rc.
|
|
4
|
+
"version": "7.5.0-rc.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/esm/index.js",
|
|
7
7
|
"source": "./src/index.ts",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"@swc-node/register": "^1.11.1",
|
|
51
51
|
"@swc/core": "^1.15.7",
|
|
52
52
|
"@swc/helpers": "^0.5.17",
|
|
53
|
-
"@tsed/cli-core": "7.5.0-rc.
|
|
54
|
-
"@tsed/cli-mcp": "7.5.0-rc.
|
|
55
|
-
"@tsed/cli-prompts": "7.5.0-rc.
|
|
56
|
-
"@tsed/cli-tasks": "7.5.0-rc.
|
|
53
|
+
"@tsed/cli-core": "7.5.0-rc.3",
|
|
54
|
+
"@tsed/cli-mcp": "7.5.0-rc.3",
|
|
55
|
+
"@tsed/cli-prompts": "7.5.0-rc.3",
|
|
56
|
+
"@tsed/cli-tasks": "7.5.0-rc.3",
|
|
57
57
|
"@tsed/core": ">=8.21.0",
|
|
58
58
|
"@tsed/di": ">=8.21.0",
|
|
59
59
|
"@tsed/hooks": ">=8.21.0",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"zod": "3.25.76"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@tsed/typescript": "7.5.0-rc.
|
|
80
|
+
"@tsed/typescript": "7.5.0-rc.3",
|
|
81
81
|
"@types/change-case": "^2.3.1",
|
|
82
82
|
"@types/consolidate": "0.14.4",
|
|
83
83
|
"cross-env": "7.0.3",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { command, inject } from "@tsed/cli-core";
|
|
2
|
-
import { taskLogger } from "@tsed/cli-tasks";
|
|
3
|
-
import { CliRunScript } from "../../services/CliRunScript.js";
|
|
4
|
-
export class BuildCmd {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.runScript = inject(CliRunScript);
|
|
7
|
-
}
|
|
8
|
-
async $exec(ctx) {
|
|
9
|
-
const command = "vite build";
|
|
10
|
-
taskLogger().info(`Run ${[command, ...ctx.rawArgs].join(" ")}`);
|
|
11
|
-
await this.runScript.run(command, ctx.rawArgs, {
|
|
12
|
-
env: process.env
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
command({
|
|
17
|
-
token: BuildCmd,
|
|
18
|
-
name: "build",
|
|
19
|
-
description: "Build the project",
|
|
20
|
-
allowUnknownOption: true
|
|
21
|
-
});
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import process from "node:process";
|
|
3
|
-
import { command, normalizePath } from "@tsed/cli-core";
|
|
4
|
-
import { taskLogger } from "@tsed/cli-tasks";
|
|
5
|
-
export class DevCmd {
|
|
6
|
-
async $exec(ctx) {
|
|
7
|
-
await this.runViteDev(ctx.rawArgs);
|
|
8
|
-
}
|
|
9
|
-
parseWatchValue(args) {
|
|
10
|
-
const watchArg = args.find((arg) => arg === "--watch" || arg.startsWith("--watch="));
|
|
11
|
-
if (!watchArg) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
if (watchArg === "--watch") {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
return watchArg !== "--watch=false";
|
|
18
|
-
}
|
|
19
|
-
async createViteDevServer() {
|
|
20
|
-
const { createServer } = await import("vite");
|
|
21
|
-
return createServer({
|
|
22
|
-
configFile: normalizePath("vite.config.ts"),
|
|
23
|
-
server: {
|
|
24
|
-
middlewareMode: true,
|
|
25
|
-
hmr: false,
|
|
26
|
-
ws: false
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
async runViteApp() {
|
|
31
|
-
const vite = await this.createViteDevServer();
|
|
32
|
-
const shutdown = async () => {
|
|
33
|
-
await vite.close();
|
|
34
|
-
process.exit(0);
|
|
35
|
-
};
|
|
36
|
-
process.on("SIGINT", shutdown);
|
|
37
|
-
process.on("SIGTERM", shutdown);
|
|
38
|
-
await vite.ssrLoadModule(`/src/index.ts?t=${Date.now()}`);
|
|
39
|
-
await new Promise(() => { });
|
|
40
|
-
}
|
|
41
|
-
async runViteController(rawArgs) {
|
|
42
|
-
const watch = this.parseWatchValue(rawArgs);
|
|
43
|
-
const vite = await this.createViteDevServer();
|
|
44
|
-
let childProcess;
|
|
45
|
-
let restarting = false;
|
|
46
|
-
let queued = false;
|
|
47
|
-
const startChild = () => {
|
|
48
|
-
const [, scriptPath] = process.argv;
|
|
49
|
-
const args = scriptPath ? [scriptPath, "dev", ...rawArgs] : ["dev", ...rawArgs];
|
|
50
|
-
childProcess = spawn(process.execPath, args, {
|
|
51
|
-
env: {
|
|
52
|
-
...process.env,
|
|
53
|
-
TSED_VITE_RUN_MODE: "app"
|
|
54
|
-
},
|
|
55
|
-
stdio: "inherit"
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
const stopChild = async () => {
|
|
59
|
-
if (!childProcess || childProcess.killed) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
await new Promise((resolve) => {
|
|
63
|
-
childProcess.once("exit", resolve);
|
|
64
|
-
childProcess.kill("SIGTERM");
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
const restartChild = async (reason, file = "") => {
|
|
68
|
-
if (restarting) {
|
|
69
|
-
queued = true;
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
restarting = true;
|
|
73
|
-
const suffix = file ? `: ${file}` : "";
|
|
74
|
-
taskLogger().info(`[tsed-dev] restart (${reason})${suffix}`);
|
|
75
|
-
await stopChild();
|
|
76
|
-
startChild();
|
|
77
|
-
restarting = false;
|
|
78
|
-
if (queued) {
|
|
79
|
-
queued = false;
|
|
80
|
-
await restartChild("queued");
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
if (watch) {
|
|
84
|
-
vite.watcher.on("all", async (event, file) => {
|
|
85
|
-
if (!file || file.includes("node_modules") || file.includes(".git") || file.includes("/dist/")) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (["add", "change", "unlink"].includes(event)) {
|
|
89
|
-
await restartChild(event, file);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
vite.watcher.once("ready", () => {
|
|
94
|
-
startChild();
|
|
95
|
-
});
|
|
96
|
-
const shutdown = async () => {
|
|
97
|
-
await stopChild();
|
|
98
|
-
await vite.close();
|
|
99
|
-
process.exit(0);
|
|
100
|
-
};
|
|
101
|
-
process.on("SIGINT", shutdown);
|
|
102
|
-
process.on("SIGTERM", shutdown);
|
|
103
|
-
await new Promise(() => { });
|
|
104
|
-
}
|
|
105
|
-
async runViteDev(rawArgs) {
|
|
106
|
-
if (process.env.TSED_VITE_RUN_MODE === "app") {
|
|
107
|
-
await this.runViteApp();
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
await this.runViteController(rawArgs);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
command({
|
|
114
|
-
token: DevCmd,
|
|
115
|
-
name: "dev",
|
|
116
|
-
description: "Run the project in development mode",
|
|
117
|
-
allowUnknownOption: true
|
|
118
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type CommandProvider } from "@tsed/cli-core";
|
|
2
|
-
import { CliRunScript } from "../../services/CliRunScript.js";
|
|
3
|
-
export interface BuildCmdContext {
|
|
4
|
-
rawArgs: string[];
|
|
5
|
-
}
|
|
6
|
-
export declare class BuildCmd implements CommandProvider {
|
|
7
|
-
protected runScript: CliRunScript;
|
|
8
|
-
$exec(ctx: BuildCmdContext): Promise<void>;
|
|
9
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type CommandProvider } from "@tsed/cli-core";
|
|
2
|
-
export interface DevCmdContext {
|
|
3
|
-
rawArgs: string[];
|
|
4
|
-
}
|
|
5
|
-
export declare class DevCmd implements CommandProvider {
|
|
6
|
-
$exec(ctx: DevCmdContext): Promise<void>;
|
|
7
|
-
protected parseWatchValue(args: string[]): boolean;
|
|
8
|
-
protected createViteDevServer(): Promise<import("vite").ViteDevServer>;
|
|
9
|
-
protected runViteApp(): Promise<void>;
|
|
10
|
-
protected runViteController(rawArgs: string[]): Promise<void>;
|
|
11
|
-
protected runViteDev(rawArgs: string[]): Promise<void>;
|
|
12
|
-
}
|