wexts 4.1.5 → 4.1.7
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 +49 -49
- package/bin/wexts.cjs +2 -2
- package/dist/chunk-27NEYQD2.mjs +222 -0
- package/dist/chunk-27NEYQD2.mjs.map +1 -0
- package/dist/chunk-2LJVUMXW.js +228 -0
- package/dist/chunk-2LJVUMXW.js.map +1 -0
- package/dist/chunk-5DBFN65W.mjs +183 -0
- package/dist/chunk-5DBFN65W.mjs.map +1 -0
- package/dist/chunk-75HBI2XG.js +504 -0
- package/dist/chunk-75HBI2XG.js.map +1 -0
- package/dist/chunk-AVMQJWYD.js +95 -0
- package/dist/chunk-AVMQJWYD.js.map +1 -0
- package/dist/chunk-C2AG7Q3C.mjs +65 -0
- package/dist/chunk-C2AG7Q3C.mjs.map +1 -0
- package/dist/chunk-DS5KVVWJ.mjs +95 -0
- package/dist/chunk-DS5KVVWJ.mjs.map +1 -0
- package/dist/chunk-FUPLZMSR.mjs +228 -0
- package/dist/chunk-FUPLZMSR.mjs.map +1 -0
- package/dist/chunk-HLT3IHJY.js +183 -0
- package/dist/chunk-HLT3IHJY.js.map +1 -0
- package/dist/chunk-IRRJJ7KL.js +273 -0
- package/dist/chunk-IRRJJ7KL.js.map +1 -0
- package/dist/chunk-L77ANWWT.mjs +22 -0
- package/dist/chunk-L77ANWWT.mjs.map +1 -0
- package/dist/chunk-P3Q4I5FD.js +222 -0
- package/dist/chunk-P3Q4I5FD.js.map +1 -0
- package/dist/chunk-VBIQGUDI.mjs +504 -0
- package/dist/chunk-VBIQGUDI.mjs.map +1 -0
- package/dist/chunk-VJY6PHYF.mjs +273 -0
- package/dist/chunk-VJY6PHYF.mjs.map +1 -0
- package/dist/chunk-WCKSKU3C.js +65 -0
- package/dist/chunk-WCKSKU3C.js.map +1 -0
- package/dist/chunk-XE4OXN2W.js +12 -0
- package/dist/chunk-XE4OXN2W.js.map +1 -0
- package/dist/cli/index.d.mts +23 -0
- package/dist/cli/index.d.ts +23 -0
- package/dist/cli/index.js +634 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/index.mjs +636 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/client/index.d.mts +43 -0
- package/dist/client/index.d.ts +43 -0
- package/dist/client/index.js +187 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +166 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/codegen/index.d.mts +2 -0
- package/dist/codegen/index.d.ts +2 -0
- package/dist/codegen/index.js +16 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/codegen/index.mjs +16 -0
- package/dist/codegen/index.mjs.map +1 -0
- package/dist/decorators-BiQtOHuF.d.ts +60 -0
- package/dist/decorators-vBopODtr.d.mts +60 -0
- package/dist/dev-server/index.d.mts +1 -0
- package/dist/dev-server/index.d.ts +1 -0
- package/dist/dev-server/index.js +13 -0
- package/dist/dev-server/index.js.map +1 -0
- package/dist/dev-server/index.mjs +13 -0
- package/dist/dev-server/index.mjs.map +1 -0
- package/dist/errors-D545UvXf.d.mts +37 -0
- package/dist/errors-D545UvXf.d.ts +37 -0
- package/dist/index-7RvU-jGE.d.mts +66 -0
- package/dist/index-7RvU-jGE.d.ts +66 -0
- package/dist/index-BsafLP-a.d.mts +70 -0
- package/dist/index-BsafLP-a.d.ts +70 -0
- package/dist/index-CJKs4wtN.d.ts +92 -0
- package/dist/index-CUR6CnLk.d.ts +27 -0
- package/dist/index-h66Vq9dK.d.mts +92 -0
- package/dist/index-tqmYsTUn.d.mts +27 -0
- package/dist/index.d.mts +289 -0
- package/dist/index.d.ts +289 -0
- package/dist/index.js +544 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +544 -0
- package/dist/index.mjs.map +1 -0
- package/dist/nest/index.d.mts +2 -0
- package/dist/nest/index.d.ts +2 -0
- package/dist/nest/index.js +36 -0
- package/dist/nest/index.js.map +1 -0
- package/dist/nest/index.mjs +36 -0
- package/dist/nest/index.mjs.map +1 -0
- package/dist/next/index.d.mts +66 -0
- package/dist/next/index.d.ts +66 -0
- package/dist/next/index.js +282 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/index.mjs +251 -0
- package/dist/next/index.mjs.map +1 -0
- package/dist/rpc/index.d.mts +32 -0
- package/dist/rpc/index.d.ts +32 -0
- package/dist/rpc/index.js +19 -0
- package/dist/rpc/index.js.map +1 -0
- package/dist/rpc/index.mjs +1 -0
- package/dist/rpc/index.mjs.map +1 -0
- package/dist/runtime/index.d.mts +55 -0
- package/dist/runtime/index.d.ts +55 -0
- package/dist/runtime/index.js +15 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/index.mjs +15 -0
- package/dist/runtime/index.mjs.map +1 -0
- package/dist/server/index.d.mts +7 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +58 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +58 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/types/index.d.mts +12 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types-CQ_aexOX.d.mts +32 -0
- package/dist/types-CQ_aexOX.d.ts +32 -0
- package/dist/vercel-builder/index.d.mts +58 -0
- package/dist/vercel-builder/index.d.ts +58 -0
- package/dist/vercel-builder/index.js +330 -0
- package/dist/vercel-builder/index.js.map +1 -0
- package/dist/vercel-builder/index.mjs +330 -0
- package/dist/vercel-builder/index.mjs.map +1 -0
- package/package.json +153 -153
- package/templates/.dockerignore +43 -43
- package/templates/.env.example +17 -17
- package/templates/Dockerfile +60 -60
- package/templates/Procfile +1 -1
- package/templates/README.md +67 -67
- package/templates/api-sdk.ts +115 -115
- package/templates/docker-compose.yml +34 -34
- package/templates/nestjs-api/.env.example +3 -3
- package/templates/nestjs-api/README.md +87 -87
- package/templates/nestjs-api/nest-cli.json +6 -6
- package/templates/nestjs-api/package.json +40 -40
- package/templates/nestjs-api/prisma/migrations/20251123205437_init/migration.sql +24 -24
- package/templates/nestjs-api/prisma/migrations/migration_lock.toml +3 -3
- package/templates/nestjs-api/prisma/schema.prisma +29 -29
- package/templates/nestjs-api/src/app.module.ts +19 -17
- package/templates/nestjs-api/src/auth/auth.controller.ts +27 -27
- package/templates/nestjs-api/src/auth/auth.module.ts +37 -37
- package/templates/nestjs-api/src/auth/auth.service.ts +86 -86
- package/templates/nestjs-api/src/auth/dto/auth.dto.ts +22 -22
- package/templates/nestjs-api/src/auth/guards/jwt-auth.guard.ts +5 -5
- package/templates/nestjs-api/src/auth/strategies/jwt.strategy.ts +27 -27
- package/templates/nestjs-api/src/hello.service.ts +11 -0
- package/templates/nestjs-api/src/main.ts +32 -32
- package/templates/nestjs-api/src/prisma/prisma.module.ts +9 -9
- package/templates/nestjs-api/src/prisma/prisma.service.ts +14 -14
- package/templates/nestjs-api/src/todos/dto/todo.dto.ts +24 -24
- package/templates/nestjs-api/src/todos/todos.controller.ts +39 -39
- package/templates/nestjs-api/src/todos/todos.module.ts +11 -11
- package/templates/nestjs-api/src/todos/todos.service.ts +53 -53
- package/templates/nestjs-api/src/users/users.controller.ts +14 -14
- package/templates/nestjs-api/src/users/users.module.ts +12 -12
- package/templates/nestjs-api/src/users/users.service.ts +19 -19
- package/templates/nestjs-api/tsconfig.json +39 -39
- package/templates/nextjs-web/README.md +76 -76
- package/templates/nextjs-web/app/actions/auth.ts +108 -108
- package/templates/nextjs-web/app/dashboard/error.tsx +39 -39
- package/templates/nextjs-web/app/dashboard/loading.tsx +14 -14
- package/templates/nextjs-web/app/dashboard/page.tsx +5 -5
- package/templates/nextjs-web/app/globals.css +93 -93
- package/templates/nextjs-web/app/layout.tsx +29 -29
- package/templates/nextjs-web/app/login/page.tsx +5 -5
- package/templates/nextjs-web/app/page.tsx +138 -28
- package/templates/nextjs-web/app/register/page.tsx +5 -5
- package/templates/nextjs-web/components/ui/button.tsx +56 -56
- package/templates/nextjs-web/components/ui/card.tsx +79 -79
- package/templates/nextjs-web/components/ui/input.tsx +25 -25
- package/templates/nextjs-web/components/ui/label.tsx +24 -24
- package/templates/nextjs-web/features/auth/LoginForm.tsx +140 -140
- package/templates/nextjs-web/features/auth/RegisterForm.tsx +159 -159
- package/templates/nextjs-web/features/auth/api.ts +35 -35
- package/templates/nextjs-web/features/auth/index.ts +3 -3
- package/templates/nextjs-web/features/dashboard/DashboardView.tsx +204 -204
- package/templates/nextjs-web/features/dashboard/api.ts +9 -9
- package/templates/nextjs-web/features/dashboard/components.tsx +74 -74
- package/templates/nextjs-web/features/dashboard/index.ts +3 -3
- package/templates/nextjs-web/hooks/index.ts +4 -4
- package/templates/nextjs-web/lib/api-client.ts +89 -89
- package/templates/nextjs-web/lib/api.ts +115 -115
- package/templates/nextjs-web/lib/axios-global-config.ts +17 -17
- package/templates/nextjs-web/lib/utils.ts +6 -6
- package/templates/nextjs-web/lib/wexts-client.ts +4 -4
- package/templates/nextjs-web/next-env.d.ts +6 -6
- package/templates/nextjs-web/next.config.ts +20 -20
- package/templates/nextjs-web/package.json +37 -37
- package/templates/nextjs-web/postcss.config.js +6 -6
- package/templates/nextjs-web/tailwind.config.ts +69 -69
- package/templates/nextjs-web/tsconfig.json +41 -41
- package/templates/nixpacks.toml +11 -11
- package/templates/root-package.json +31 -31
- package/templates/server.ts +66 -66
- package/templates/tsconfig.json +30 -30
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
WextsError,
|
|
4
|
+
formatWextsError
|
|
5
|
+
} from "../chunk-DS5KVVWJ.mjs";
|
|
6
|
+
import {
|
|
7
|
+
logger
|
|
8
|
+
} from "../chunk-C2AG7Q3C.mjs";
|
|
9
|
+
import {
|
|
10
|
+
__dirname,
|
|
11
|
+
__filename,
|
|
12
|
+
__name
|
|
13
|
+
} from "../chunk-L77ANWWT.mjs";
|
|
14
|
+
|
|
15
|
+
// src/cli/index.ts
|
|
16
|
+
import { Command } from "commander";
|
|
17
|
+
import * as fs from "fs";
|
|
18
|
+
import * as path from "path";
|
|
19
|
+
import { spawnSync } from "child_process";
|
|
20
|
+
import { createRequire } from "module";
|
|
21
|
+
function createCliProgram() {
|
|
22
|
+
const program = new Command();
|
|
23
|
+
program.name("wexts").description("Wexts - production-focused single-runtime Next.js + NestJS toolkit").version(readPackageVersion());
|
|
24
|
+
program.command("create <project-name>").description("Create a verified Wexts starter").option("-t, --template <template>", "Template to use (starter|legacy)", "starter").option("--skip-install", "Skip dependency installation", false).action(async (projectName, options) => {
|
|
25
|
+
await createProject(projectName, options.template, {
|
|
26
|
+
skipInstall: options.skipInstall
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
program.command("dev").description("Start local development processes").option("-a, --api <path>", "Path to API project", "./apps/api").option("-w, --web <path>", "Path to Web project", "./apps/web").option("-p, --port <port>", "Port for web server", "3000").option("--api-port <port>", "Port for API server", "5050").option("--proxy", "Enable development proxy on a separate proxy port", false).option("-c, --config <path>", "Runtime config module path", "./wexts.runtime.js").action(async (options) => {
|
|
30
|
+
const { FusionDevServer } = await import("../dev-server/index.mjs");
|
|
31
|
+
const server = new FusionDevServer();
|
|
32
|
+
await server.start({
|
|
33
|
+
apiPath: options.api,
|
|
34
|
+
webPath: options.web,
|
|
35
|
+
webPort: Number(options.port),
|
|
36
|
+
apiPort: Number(options.apiPort),
|
|
37
|
+
useProxy: options.proxy,
|
|
38
|
+
rootDir: process.cwd(),
|
|
39
|
+
runtimeConfigPath: options.config
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
program.command("generate [type] [name]").alias("g").description("Generate RPC manifest/client, or scaffold a minimal RPC service").option("-p, --project <path>", "Path to NestJS project", "./apps/api").option("-o, --output <path>", "Output directory for generated RPC client", "./apps/web/lib/wexts").option("--force", "Overwrite generated files if they already exist", false).action(async (type, name, options) => {
|
|
43
|
+
if (!type || type === "rpc" && !name) {
|
|
44
|
+
const { generateRpcClient } = await import("../codegen/index.mjs");
|
|
45
|
+
const manifest = await generateRpcClient({
|
|
46
|
+
projectPath: path.resolve(options.project),
|
|
47
|
+
outputPath: path.resolve(options.output)
|
|
48
|
+
});
|
|
49
|
+
logger.success(`Generated Wexts RPC client for ${manifest.services.length} service(s).`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (isScaffoldGenerator(type)) {
|
|
53
|
+
const targetRoot = type === "config" ? process.cwd() : path.resolve(options.project);
|
|
54
|
+
const changedFiles = await scaffoldGenerator({
|
|
55
|
+
type,
|
|
56
|
+
name,
|
|
57
|
+
targetRoot,
|
|
58
|
+
force: options.force
|
|
59
|
+
});
|
|
60
|
+
for (const file of changedFiles) logger.info(`created ${path.relative(process.cwd(), file)}`);
|
|
61
|
+
logger.success(`Generated ${type}${name ? ` ${name}` : ""}.`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
throw new Error(`Unknown generator "${type}". Supported generators: rpc, service, module, entity, guard, config.`);
|
|
65
|
+
});
|
|
66
|
+
program.command("codegen").description("Alias for wexts generate rpc").option("-p, --project <path>", "Path to NestJS project", "./apps/api").option("-o, --output <path>", "Output directory for generated RPC client", "./apps/web/lib/wexts").action(async (options) => {
|
|
67
|
+
const { generateRpcClient } = await import("../codegen/index.mjs");
|
|
68
|
+
const manifest = await generateRpcClient({
|
|
69
|
+
projectPath: path.resolve(options.project),
|
|
70
|
+
outputPath: path.resolve(options.output)
|
|
71
|
+
});
|
|
72
|
+
logger.success(`Generated Wexts RPC client for ${manifest.services.length} service(s).`);
|
|
73
|
+
});
|
|
74
|
+
program.command("build").description("Build a Wexts project for production").option("--skip-generate", "Skip RPC generation before build", false).option("-p, --project <path>", "Path to NestJS project", "./apps/api").option("-o, --output <path>", "Output directory for generated RPC client", "./apps/web/lib/wexts").action(async (options) => {
|
|
75
|
+
if (!options.skipGenerate && fs.existsSync(options.project)) {
|
|
76
|
+
const { generateRpcClient } = await import("../codegen/index.mjs");
|
|
77
|
+
await generateRpcClient({
|
|
78
|
+
projectPath: path.resolve(options.project),
|
|
79
|
+
outputPath: path.resolve(options.output)
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
runScript("build", {
|
|
83
|
+
cwd: process.cwd()
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
program.command("start").description("Start the Wexts runtime").option("-c, --config <path>", "Runtime config module path", "./wexts.runtime.js").option("-p, --port <port>", "Port to listen on", process.env.PORT ?? "3000").option("--dev", "Run the runtime in development mode", false).action(async (options) => {
|
|
87
|
+
const { startWextsRuntime } = await import("../runtime/index.mjs");
|
|
88
|
+
const configPath = path.resolve(options.config);
|
|
89
|
+
const runtimeConfig = fs.existsSync(configPath) ? await loadRuntimeConfig(configPath, options.dev) : {};
|
|
90
|
+
await startWextsRuntime({
|
|
91
|
+
...runtimeConfig,
|
|
92
|
+
port: Number(options.port),
|
|
93
|
+
dev: options.dev
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
program.command("vercel-build").description("Build for Vercel using Build Output API v3").option("-p, --project <path>", "Path to NestJS project", "./apps/api").option("-o, --output <path>", "Output dir for RPC client", "./apps/web/lib/wexts").option("-c, --config <path>", "Runtime config module path", "./wexts.runtime.js").option("--skip-codegen", "Skip RPC generation", false).option("--skip-build", "Skip project build step", false).option("--node-version <version>", "Node.js version for Vercel function", "20").option("--max-duration <seconds>", "Max duration for serverless function", "30").action(async (options) => {
|
|
97
|
+
const { buildVercelOutput } = await import("../vercel-builder/index.mjs");
|
|
98
|
+
const result = await buildVercelOutput({
|
|
99
|
+
rootDir: process.cwd(),
|
|
100
|
+
apiProjectPath: options.project,
|
|
101
|
+
rpcOutputPath: options.output,
|
|
102
|
+
runtimeConfigPath: options.config,
|
|
103
|
+
skipCodegen: options.skipCodegen,
|
|
104
|
+
skipBuild: options.skipBuild,
|
|
105
|
+
nodeVersion: options.nodeVersion,
|
|
106
|
+
maxDuration: Number(options.maxDuration)
|
|
107
|
+
});
|
|
108
|
+
if (result.warnings.length > 0) {
|
|
109
|
+
for (const warning of result.warnings) logger.warn(warning);
|
|
110
|
+
}
|
|
111
|
+
if (result.errors.length > 0) {
|
|
112
|
+
for (const error of result.errors) logger.error(error);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
logger.success("Vercel build output ready at .vercel/output");
|
|
116
|
+
});
|
|
117
|
+
program.command("doctor").description("Validate Wexts project configuration").option("--security", "Run security-specific checks", false).action(async (options) => {
|
|
118
|
+
const result = runDoctor(process.cwd(), options.security);
|
|
119
|
+
for (const warning of result.warnings) logger.warn(warning);
|
|
120
|
+
for (const error of result.errors) logger.error(error);
|
|
121
|
+
if (result.errors.length > 0) process.exit(1);
|
|
122
|
+
logger.success(options.security ? "Security doctor passed." : "Doctor passed.");
|
|
123
|
+
});
|
|
124
|
+
return program;
|
|
125
|
+
}
|
|
126
|
+
__name(createCliProgram, "createCliProgram");
|
|
127
|
+
function runDoctor(cwd, security = false) {
|
|
128
|
+
const result = {
|
|
129
|
+
errors: [],
|
|
130
|
+
warnings: []
|
|
131
|
+
};
|
|
132
|
+
const pkgPath = path.join(cwd, "package.json");
|
|
133
|
+
if (!fs.existsSync(pkgPath)) {
|
|
134
|
+
result.errors.push("package.json not found.");
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
138
|
+
if (!pkg.packageManager?.startsWith("pnpm@")) {
|
|
139
|
+
result.warnings.push("packageManager should pin pnpm.");
|
|
140
|
+
}
|
|
141
|
+
for (const dir of [
|
|
142
|
+
"apps/api",
|
|
143
|
+
"apps/web"
|
|
144
|
+
]) {
|
|
145
|
+
if (!fs.existsSync(path.join(cwd, dir))) {
|
|
146
|
+
result.warnings.push(`${dir} not found; some Wexts commands may need explicit paths.`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (fs.existsSync(path.join(cwd, "apps/api")) && fs.existsSync(path.join(cwd, "apps/web"))) {
|
|
150
|
+
result.warnings.push("Development mode starts an API compiler plus the Wexts runtime so `/rpc` and Next routes share the web port.");
|
|
151
|
+
}
|
|
152
|
+
if (security) {
|
|
153
|
+
const source = readAllText(cwd, [
|
|
154
|
+
"apps/api/src",
|
|
155
|
+
"packages/templates/nestjs-api/src"
|
|
156
|
+
]);
|
|
157
|
+
if (source.includes("default-secret")) {
|
|
158
|
+
result.errors.push('JWT fallback "default-secret" found. Production apps must fail without a strong JWT_SECRET.');
|
|
159
|
+
}
|
|
160
|
+
if (/origin:\s*['"]\*['"]/.test(source)) {
|
|
161
|
+
result.errors.push("Wildcard CORS origin found. Use an explicit origin allowlist.");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
__name(runDoctor, "runDoctor");
|
|
167
|
+
async function createProject(projectName, template, options) {
|
|
168
|
+
const projectPath = path.join(process.cwd(), projectName);
|
|
169
|
+
if (fs.existsSync(projectPath)) {
|
|
170
|
+
throw new Error(`Directory already exists: ${projectName}`);
|
|
171
|
+
}
|
|
172
|
+
fs.mkdirSync(projectPath, {
|
|
173
|
+
recursive: true
|
|
174
|
+
});
|
|
175
|
+
if (template === "starter") {
|
|
176
|
+
await createVerifiedStarter(projectPath, projectName, options.wextsDependency ?? resolveCreateWextsDependency(projectPath));
|
|
177
|
+
} else if (template === "legacy") {
|
|
178
|
+
createLegacyProject(projectPath, projectName);
|
|
179
|
+
} else {
|
|
180
|
+
throw new Error(`Unknown template "${template}". Supported templates: starter, legacy.`);
|
|
181
|
+
}
|
|
182
|
+
if (!options.skipInstall) {
|
|
183
|
+
runCommand(detectPackageManager(projectPath), [
|
|
184
|
+
"install"
|
|
185
|
+
], projectPath);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
__name(createProject, "createProject");
|
|
189
|
+
async function createVerifiedStarter(projectPath, projectName, wextsDependency) {
|
|
190
|
+
const files = {
|
|
191
|
+
"pnpm-workspace.yaml": "packages:\n - 'apps/*'\n",
|
|
192
|
+
"package.json": JSON.stringify({
|
|
193
|
+
name: projectName,
|
|
194
|
+
version: "0.1.0",
|
|
195
|
+
private: true,
|
|
196
|
+
packageManager: "pnpm@10.22.0",
|
|
197
|
+
scripts: {
|
|
198
|
+
dev: "wexts dev",
|
|
199
|
+
generate: "wexts generate -p apps/api -o apps/web/lib/wexts",
|
|
200
|
+
build: "pnpm run generate && tsc -p apps/api/tsconfig.json && next build apps/web",
|
|
201
|
+
start: "wexts start -c ./wexts.runtime.js",
|
|
202
|
+
"vercel-build": "wexts vercel-build -p apps/api -o apps/web/lib/wexts -c ./wexts.runtime.js",
|
|
203
|
+
doctor: "wexts doctor",
|
|
204
|
+
"doctor:security": "wexts doctor --security"
|
|
205
|
+
},
|
|
206
|
+
dependencies: {
|
|
207
|
+
wexts: wextsDependency
|
|
208
|
+
}
|
|
209
|
+
}, null, 2),
|
|
210
|
+
"wexts.runtime.js": `const { HelloService } = require('./apps/api/dist/hello.service.js');
|
|
211
|
+
|
|
212
|
+
module.exports = {
|
|
213
|
+
nextDir: './apps/web',
|
|
214
|
+
rpcManifestPath: './apps/web/lib/wexts/wexts.rpc.manifest.json',
|
|
215
|
+
rpcServices: {
|
|
216
|
+
hello: new HelloService(),
|
|
217
|
+
},
|
|
218
|
+
security: {
|
|
219
|
+
allowedOrigins: ['http://localhost:3000'],
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
`,
|
|
223
|
+
"README.md": `# ${projectName}
|
|
224
|
+
|
|
225
|
+
Verified Wexts starter with Next.js and NestJS.
|
|
226
|
+
|
|
227
|
+
\`\`\`bash
|
|
228
|
+
pnpm install
|
|
229
|
+
pnpm run generate
|
|
230
|
+
pnpm run build
|
|
231
|
+
pnpm run dev
|
|
232
|
+
\`\`\`
|
|
233
|
+
`,
|
|
234
|
+
".cursorrules": `# Wexts Project AI Rules
|
|
235
|
+
|
|
236
|
+
You are an expert full-stack developer working on a Wexts application.
|
|
237
|
+
Wexts is a unified single-runtime toolkit that combines Next.js (frontend) and NestJS (backend) using a highly typed RPC bridge.
|
|
238
|
+
|
|
239
|
+
## Project Structure
|
|
240
|
+
- \`apps/api/\`: The NestJS backend. Contains business logic, database models, and RPC services.
|
|
241
|
+
- \`apps/web/\`: The Next.js frontend. Contains UI components, pages, and consumes the RPC client.
|
|
242
|
+
- \`apps/web/lib/wexts\`: The auto-generated typed RPC client (DO NOT EDIT MANUALLY).
|
|
243
|
+
|
|
244
|
+
## Backend Guidelines (NestJS)
|
|
245
|
+
1. **RPC Services**: To create an API endpoint, create a NestJS provider decorated with \`@RpcService({ name: 'serviceName' })\` and methods decorated with \`@RpcMethod()\`.
|
|
246
|
+
2. **Imports**: Import \`@RpcService\` and \`@RpcMethod\` from \`wexts/nest\`.
|
|
247
|
+
3. Do NOT manually create REST controllers unless explicitly needed for webhooks. Use the RPC bridge for all internal frontend-backend communication.
|
|
248
|
+
4. **Auth**: If a service requires authentication, set \`@RpcService({ requireAuth: true })\`.
|
|
249
|
+
|
|
250
|
+
## Frontend Guidelines (Next.js)
|
|
251
|
+
1. **RPC Usage**: To call the backend, import the \`api\` client from \`@/lib/wexts\` or your designated Wexts client file (e.g., \`useWexts()\`).
|
|
252
|
+
2. **Syntax**: \`const data = await api.serviceName.methodName(args);\`
|
|
253
|
+
3. The \`api\` object is fully type-safe. Rely on TypeScript autocomplete rather than guessing endpoints.
|
|
254
|
+
`
|
|
255
|
+
};
|
|
256
|
+
for (const [relativePath, content] of Object.entries(files)) {
|
|
257
|
+
const absolutePath = path.join(projectPath, relativePath);
|
|
258
|
+
fs.mkdirSync(path.dirname(absolutePath), {
|
|
259
|
+
recursive: true
|
|
260
|
+
});
|
|
261
|
+
fs.writeFileSync(absolutePath, content);
|
|
262
|
+
}
|
|
263
|
+
const templatePath = findTemplatePath();
|
|
264
|
+
if (!templatePath) {
|
|
265
|
+
throw new Error("Template directory not found in package.");
|
|
266
|
+
}
|
|
267
|
+
const apiTemplatePath = path.join(templatePath, "nestjs-api");
|
|
268
|
+
const apiDestPath = path.join(projectPath, "apps/api");
|
|
269
|
+
if (fs.existsSync(apiTemplatePath)) {
|
|
270
|
+
fs.cpSync(apiTemplatePath, apiDestPath, {
|
|
271
|
+
recursive: true,
|
|
272
|
+
filter: /* @__PURE__ */ __name((src) => {
|
|
273
|
+
const basename2 = path.basename(src);
|
|
274
|
+
return basename2 !== "node_modules" && basename2 !== "dist" && basename2 !== "package-lock.json";
|
|
275
|
+
}, "filter")
|
|
276
|
+
});
|
|
277
|
+
const apiPkgPath = path.join(apiDestPath, "package.json");
|
|
278
|
+
if (fs.existsSync(apiPkgPath)) {
|
|
279
|
+
const apiPkg = JSON.parse(fs.readFileSync(apiPkgPath, "utf8"));
|
|
280
|
+
apiPkg.name = `${projectName}-api`;
|
|
281
|
+
if (apiPkg.dependencies?.wexts) apiPkg.dependencies.wexts = wextsDependency;
|
|
282
|
+
fs.writeFileSync(apiPkgPath, JSON.stringify(apiPkg, null, 2));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const webTemplatePath = path.join(templatePath, "nextjs-web");
|
|
286
|
+
const webDestPath = path.join(projectPath, "apps/web");
|
|
287
|
+
if (fs.existsSync(webTemplatePath)) {
|
|
288
|
+
fs.cpSync(webTemplatePath, webDestPath, {
|
|
289
|
+
recursive: true,
|
|
290
|
+
filter: /* @__PURE__ */ __name((src) => {
|
|
291
|
+
const basename2 = path.basename(src);
|
|
292
|
+
return basename2 !== "node_modules" && basename2 !== ".next" && basename2 !== "package-lock.json";
|
|
293
|
+
}, "filter")
|
|
294
|
+
});
|
|
295
|
+
const webPkgPath = path.join(webDestPath, "package.json");
|
|
296
|
+
if (fs.existsSync(webPkgPath)) {
|
|
297
|
+
const webPkg = JSON.parse(fs.readFileSync(webPkgPath, "utf8"));
|
|
298
|
+
webPkg.name = `${projectName}-web`;
|
|
299
|
+
if (webPkg.dependencies?.wexts) webPkg.dependencies.wexts = wextsDependency;
|
|
300
|
+
fs.writeFileSync(webPkgPath, JSON.stringify(webPkg, null, 2));
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (fs.existsSync(path.join(apiDestPath, "src"))) {
|
|
304
|
+
try {
|
|
305
|
+
const { generateRpcClient } = await import("../codegen/index.mjs");
|
|
306
|
+
await generateRpcClient({
|
|
307
|
+
projectPath: path.join(projectPath, "apps/api"),
|
|
308
|
+
outputPath: path.join(projectPath, "apps/web/lib/wexts")
|
|
309
|
+
});
|
|
310
|
+
} catch (e) {
|
|
311
|
+
logger.warn('Initial RPC generation failed; you may need to run "wexts generate" after setup.');
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
__name(createVerifiedStarter, "createVerifiedStarter");
|
|
316
|
+
function createLegacyProject(projectPath, projectName) {
|
|
317
|
+
const templatePath = findTemplatePath();
|
|
318
|
+
if (!templatePath) {
|
|
319
|
+
throw new Error("Template directory not found in package.");
|
|
320
|
+
}
|
|
321
|
+
fs.mkdirSync(path.join(projectPath, "apps"), {
|
|
322
|
+
recursive: true
|
|
323
|
+
});
|
|
324
|
+
fs.cpSync(path.join(templatePath, "nestjs-api"), path.join(projectPath, "apps/api"), {
|
|
325
|
+
recursive: true
|
|
326
|
+
});
|
|
327
|
+
fs.cpSync(path.join(templatePath, "nextjs-web"), path.join(projectPath, "apps/web"), {
|
|
328
|
+
recursive: true
|
|
329
|
+
});
|
|
330
|
+
fs.rmSync(path.join(projectPath, "apps/web/package-lock.json"), {
|
|
331
|
+
force: true
|
|
332
|
+
});
|
|
333
|
+
fs.rmSync(path.join(projectPath, "apps/api/package-lock.json"), {
|
|
334
|
+
force: true
|
|
335
|
+
});
|
|
336
|
+
fs.writeFileSync(path.join(projectPath, "pnpm-workspace.yaml"), "packages:\n - 'apps/*'\n");
|
|
337
|
+
fs.writeFileSync(path.join(projectPath, "package.json"), JSON.stringify({
|
|
338
|
+
name: projectName,
|
|
339
|
+
private: true,
|
|
340
|
+
packageManager: "pnpm@10.22.0",
|
|
341
|
+
scripts: {
|
|
342
|
+
dev: "wexts dev",
|
|
343
|
+
generate: "wexts generate",
|
|
344
|
+
build: "wexts build",
|
|
345
|
+
start: "wexts start",
|
|
346
|
+
doctor: "wexts doctor"
|
|
347
|
+
},
|
|
348
|
+
devDependencies: {
|
|
349
|
+
wexts: `^${readPackageVersion()}`
|
|
350
|
+
}
|
|
351
|
+
}, null, 2));
|
|
352
|
+
}
|
|
353
|
+
__name(createLegacyProject, "createLegacyProject");
|
|
354
|
+
function resolveCreateWextsDependency(projectPath) {
|
|
355
|
+
const packageRoot = path.resolve(__dirname, "../..");
|
|
356
|
+
const cwdLocalPackage = path.join(process.cwd(), "node_modules/wexts");
|
|
357
|
+
try {
|
|
358
|
+
if (fs.existsSync(cwdLocalPackage) && fs.realpathSync(cwdLocalPackage) === fs.realpathSync(packageRoot)) {
|
|
359
|
+
return `file:${path.relative(projectPath, cwdLocalPackage)}`;
|
|
360
|
+
}
|
|
361
|
+
} catch {
|
|
362
|
+
}
|
|
363
|
+
return `^${readPackageVersion()}`;
|
|
364
|
+
}
|
|
365
|
+
__name(resolveCreateWextsDependency, "resolveCreateWextsDependency");
|
|
366
|
+
async function scaffoldGenerator(options) {
|
|
367
|
+
if (options.type !== "config" && !options.name) {
|
|
368
|
+
throw new WextsError({
|
|
369
|
+
code: "WEXTS_CLI_GENERATOR_NAME_REQUIRED",
|
|
370
|
+
message: `Generator "${options.type}" requires a name.`,
|
|
371
|
+
suggestedFix: `Run \`wexts generate ${options.type} hello\` or use \`wexts generate config\`.`,
|
|
372
|
+
docsSlug: "cli"
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
if (options.type === "config") {
|
|
376
|
+
return writeGeneratedFiles(options.targetRoot, [
|
|
377
|
+
{
|
|
378
|
+
relativePath: "wexts.runtime.js",
|
|
379
|
+
content: `/** @type {import('wexts/runtime').WextsRuntimeConfig} */
|
|
380
|
+
module.exports = {
|
|
381
|
+
rootDir: __dirname,
|
|
382
|
+
port: Number(process.env.PORT || 3000),
|
|
383
|
+
rpcManifestPath: 'apps/web/lib/wexts/wexts.rpc.manifest.json',
|
|
384
|
+
security: {
|
|
385
|
+
enabled: true,
|
|
386
|
+
production: process.env.NODE_ENV === 'production',
|
|
387
|
+
allowedOrigins: process.env.WEXTS_ALLOWED_ORIGINS?.split(',').filter(Boolean) || [],
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
`
|
|
391
|
+
}
|
|
392
|
+
], Boolean(options.force));
|
|
393
|
+
}
|
|
394
|
+
const rawName = options.name;
|
|
395
|
+
const name = toKebabCase(rawName);
|
|
396
|
+
const classBase = toPascalCase(name);
|
|
397
|
+
const srcRoot = path.join(options.targetRoot, "src");
|
|
398
|
+
const filesByType = {
|
|
399
|
+
rpc: rpcServiceFiles(name, classBase),
|
|
400
|
+
service: [
|
|
401
|
+
{
|
|
402
|
+
relativePath: path.join("src", name, `${name}.service.ts`),
|
|
403
|
+
content: `import { Injectable } from '@nestjs/common';
|
|
404
|
+
|
|
405
|
+
@Injectable()
|
|
406
|
+
export class ${classBase}Service {
|
|
407
|
+
async execute(): Promise<string> {
|
|
408
|
+
return '${toCamelCase(name)}';
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
`
|
|
412
|
+
}
|
|
413
|
+
],
|
|
414
|
+
module: [
|
|
415
|
+
{
|
|
416
|
+
relativePath: path.join("src", name, `${name}.module.ts`),
|
|
417
|
+
content: `import { Module } from '@nestjs/common';
|
|
418
|
+
|
|
419
|
+
@Module({})
|
|
420
|
+
export class ${classBase}Module {}
|
|
421
|
+
`
|
|
422
|
+
}
|
|
423
|
+
],
|
|
424
|
+
entity: [
|
|
425
|
+
{
|
|
426
|
+
relativePath: path.join("src", name, `${name}.entity.ts`),
|
|
427
|
+
content: `export interface ${classBase}Entity {
|
|
428
|
+
id: string;
|
|
429
|
+
createdAt: Date;
|
|
430
|
+
updatedAt: Date;
|
|
431
|
+
}
|
|
432
|
+
`
|
|
433
|
+
}
|
|
434
|
+
],
|
|
435
|
+
guard: [
|
|
436
|
+
{
|
|
437
|
+
relativePath: path.join("src", name, `${name}.guard.ts`),
|
|
438
|
+
content: `import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
|
|
439
|
+
|
|
440
|
+
@Injectable()
|
|
441
|
+
export class ${classBase}Guard implements CanActivate {
|
|
442
|
+
canActivate(_context: ExecutionContext): boolean {
|
|
443
|
+
return true;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
`
|
|
447
|
+
}
|
|
448
|
+
]
|
|
449
|
+
};
|
|
450
|
+
fs.mkdirSync(srcRoot, {
|
|
451
|
+
recursive: true
|
|
452
|
+
});
|
|
453
|
+
return writeGeneratedFiles(options.targetRoot, filesByType[options.type], Boolean(options.force));
|
|
454
|
+
}
|
|
455
|
+
__name(scaffoldGenerator, "scaffoldGenerator");
|
|
456
|
+
function isScaffoldGenerator(type) {
|
|
457
|
+
return [
|
|
458
|
+
"rpc",
|
|
459
|
+
"service",
|
|
460
|
+
"module",
|
|
461
|
+
"entity",
|
|
462
|
+
"guard",
|
|
463
|
+
"config"
|
|
464
|
+
].includes(type);
|
|
465
|
+
}
|
|
466
|
+
__name(isScaffoldGenerator, "isScaffoldGenerator");
|
|
467
|
+
function rpcServiceFiles(serviceName, classBase) {
|
|
468
|
+
return [
|
|
469
|
+
{
|
|
470
|
+
relativePath: path.join("src", serviceName, `${serviceName}.service.ts`),
|
|
471
|
+
content: `import { Injectable } from '@nestjs/common';
|
|
472
|
+
import { RpcMethod, RpcService } from 'wexts/nest';
|
|
473
|
+
|
|
474
|
+
@Injectable()
|
|
475
|
+
@RpcService({ name: '${toCamelCase(serviceName)}', requireAuth: false })
|
|
476
|
+
export class ${classBase}Service {
|
|
477
|
+
@RpcMethod()
|
|
478
|
+
async sayHello(name: string): Promise<string> {
|
|
479
|
+
return \`Hello, \${name}!\`;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
`
|
|
483
|
+
}
|
|
484
|
+
];
|
|
485
|
+
}
|
|
486
|
+
__name(rpcServiceFiles, "rpcServiceFiles");
|
|
487
|
+
function writeGeneratedFiles(root, files, force) {
|
|
488
|
+
const changedFiles = [];
|
|
489
|
+
for (const file of files) {
|
|
490
|
+
const absolutePath = path.join(root, file.relativePath);
|
|
491
|
+
if (fs.existsSync(absolutePath) && !force) {
|
|
492
|
+
throw new WextsError({
|
|
493
|
+
code: "WEXTS_CLI_GENERATOR_FILE_EXISTS",
|
|
494
|
+
message: `Refusing to overwrite existing file: ${absolutePath}`,
|
|
495
|
+
suggestedFix: "Review the file, then rerun with --force if overwriting is intentional.",
|
|
496
|
+
docsSlug: "cli"
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
fs.mkdirSync(path.dirname(absolutePath), {
|
|
500
|
+
recursive: true
|
|
501
|
+
});
|
|
502
|
+
fs.writeFileSync(absolutePath, file.content);
|
|
503
|
+
changedFiles.push(absolutePath);
|
|
504
|
+
}
|
|
505
|
+
return changedFiles;
|
|
506
|
+
}
|
|
507
|
+
__name(writeGeneratedFiles, "writeGeneratedFiles");
|
|
508
|
+
function runScript(script, options) {
|
|
509
|
+
const cwd = options.cwd ?? process.cwd();
|
|
510
|
+
const packageManager = detectPackageManager(cwd);
|
|
511
|
+
const args = packageManager === "npm" ? [
|
|
512
|
+
"run",
|
|
513
|
+
script
|
|
514
|
+
] : [
|
|
515
|
+
"run",
|
|
516
|
+
script
|
|
517
|
+
];
|
|
518
|
+
runCommand(packageManager, args, cwd);
|
|
519
|
+
}
|
|
520
|
+
__name(runScript, "runScript");
|
|
521
|
+
function runCommand(command, args, cwd) {
|
|
522
|
+
const result = spawnSync(command, args, {
|
|
523
|
+
cwd,
|
|
524
|
+
stdio: "inherit",
|
|
525
|
+
shell: process.platform === "win32"
|
|
526
|
+
});
|
|
527
|
+
if (result.status !== 0) {
|
|
528
|
+
throw new Error(`${command} ${args.join(" ")} failed with exit code ${result.status}`);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
__name(runCommand, "runCommand");
|
|
532
|
+
function detectPackageManager(cwd) {
|
|
533
|
+
const packageJsonPath = path.join(cwd, "package.json");
|
|
534
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
535
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
536
|
+
if (pkg.packageManager?.startsWith("pnpm@")) return "pnpm";
|
|
537
|
+
}
|
|
538
|
+
if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
539
|
+
if (fs.existsSync(path.join(cwd, "pnpm-workspace.yaml"))) return "pnpm";
|
|
540
|
+
return "npm";
|
|
541
|
+
}
|
|
542
|
+
__name(detectPackageManager, "detectPackageManager");
|
|
543
|
+
function findTemplatePath() {
|
|
544
|
+
const candidates = [
|
|
545
|
+
path.resolve(__dirname, "../../templates"),
|
|
546
|
+
path.resolve(__dirname, "../templates"),
|
|
547
|
+
path.resolve(process.cwd(), "packages/templates")
|
|
548
|
+
];
|
|
549
|
+
return candidates.find((candidate) => fs.existsSync(candidate));
|
|
550
|
+
}
|
|
551
|
+
__name(findTemplatePath, "findTemplatePath");
|
|
552
|
+
function readPackageVersion() {
|
|
553
|
+
const packageJsonPath = path.resolve(__dirname, "../../package.json");
|
|
554
|
+
if (!fs.existsSync(packageJsonPath)) return "0.0.0";
|
|
555
|
+
return JSON.parse(fs.readFileSync(packageJsonPath, "utf8")).version;
|
|
556
|
+
}
|
|
557
|
+
__name(readPackageVersion, "readPackageVersion");
|
|
558
|
+
function readAllText(cwd, dirs) {
|
|
559
|
+
let text = "";
|
|
560
|
+
for (const dir of dirs) {
|
|
561
|
+
const absolute = path.join(cwd, dir);
|
|
562
|
+
if (!fs.existsSync(absolute)) continue;
|
|
563
|
+
for (const file of walk(absolute)) {
|
|
564
|
+
if (file.endsWith(".ts") || file.endsWith(".tsx") || file.endsWith(".js")) {
|
|
565
|
+
text += fs.readFileSync(file, "utf8");
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
return text;
|
|
570
|
+
}
|
|
571
|
+
__name(readAllText, "readAllText");
|
|
572
|
+
function walk(dir) {
|
|
573
|
+
return fs.readdirSync(dir, {
|
|
574
|
+
withFileTypes: true
|
|
575
|
+
}).flatMap((entry) => {
|
|
576
|
+
const absolute = path.join(dir, entry.name);
|
|
577
|
+
if (entry.isDirectory()) return walk(absolute);
|
|
578
|
+
return [
|
|
579
|
+
absolute
|
|
580
|
+
];
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
__name(walk, "walk");
|
|
584
|
+
function toKebabCase(value) {
|
|
585
|
+
return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[_\s]+/g, "-").toLowerCase();
|
|
586
|
+
}
|
|
587
|
+
__name(toKebabCase, "toKebabCase");
|
|
588
|
+
function toPascalCase(value) {
|
|
589
|
+
return toKebabCase(value).split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
590
|
+
}
|
|
591
|
+
__name(toPascalCase, "toPascalCase");
|
|
592
|
+
function toCamelCase(value) {
|
|
593
|
+
const pascal = toPascalCase(value);
|
|
594
|
+
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
595
|
+
}
|
|
596
|
+
__name(toCamelCase, "toCamelCase");
|
|
597
|
+
function pathToFileUrl(filePath) {
|
|
598
|
+
return `file://${filePath}`;
|
|
599
|
+
}
|
|
600
|
+
__name(pathToFileUrl, "pathToFileUrl");
|
|
601
|
+
async function loadRuntimeConfig(configPath, retry = false) {
|
|
602
|
+
const deadline = Date.now() + (retry ? 15e3 : 0);
|
|
603
|
+
let lastError;
|
|
604
|
+
do {
|
|
605
|
+
try {
|
|
606
|
+
if (configPath.endsWith(".mjs")) {
|
|
607
|
+
const mod2 = await import(pathToFileUrl(configPath));
|
|
608
|
+
return mod2.default ?? mod2;
|
|
609
|
+
}
|
|
610
|
+
const require2 = createRequire(__filename);
|
|
611
|
+
delete require2.cache[require2.resolve(configPath)];
|
|
612
|
+
const mod = require2(configPath);
|
|
613
|
+
return mod.default ?? mod;
|
|
614
|
+
} catch (error) {
|
|
615
|
+
lastError = error;
|
|
616
|
+
if (!retry || Date.now() >= deadline) break;
|
|
617
|
+
await new Promise((resolve2) => setTimeout(resolve2, 500));
|
|
618
|
+
}
|
|
619
|
+
} while (retry);
|
|
620
|
+
throw lastError;
|
|
621
|
+
}
|
|
622
|
+
__name(loadRuntimeConfig, "loadRuntimeConfig");
|
|
623
|
+
var invokedAsCli = process.argv[1] && (path.basename(process.argv[1]) === "wexts" || path.basename(process.argv[1]) === "wexts.cjs" || path.resolve(process.argv[1]).includes(`${path.sep}dist${path.sep}cli${path.sep}index`));
|
|
624
|
+
if (invokedAsCli && !process.env.VITEST) {
|
|
625
|
+
createCliProgram().parseAsync(process.argv).catch((error) => {
|
|
626
|
+
logger.error(formatWextsError(error));
|
|
627
|
+
process.exit(1);
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
export {
|
|
631
|
+
createCliProgram,
|
|
632
|
+
createProject,
|
|
633
|
+
runDoctor,
|
|
634
|
+
scaffoldGenerator
|
|
635
|
+
};
|
|
636
|
+
//# sourceMappingURL=index.mjs.map
|