@warlock.js/core 4.2.1 → 4.2.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/esm/_virtual/_rolldown/runtime.mjs +7 -0
- package/esm/cli/cli-commands.manager.mjs +290 -0
- package/esm/cli/cli-commands.manager.mjs.map +1 -0
- package/esm/cli/cli-commands.utils.mjs +217 -0
- package/esm/cli/cli-commands.utils.mjs.map +1 -0
- package/esm/cli/commands/add.command.mjs +27 -0
- package/esm/cli/commands/add.command.mjs.map +1 -0
- package/esm/cli/commands/build.command.mjs +14 -0
- package/esm/cli/commands/build.command.mjs.map +1 -0
- package/esm/cli/commands/create-database.command.mjs +24 -0
- package/esm/cli/commands/create-database.command.mjs.map +1 -0
- package/esm/cli/commands/dev-server.command.mjs +48 -0
- package/esm/cli/commands/dev-server.command.mjs.map +1 -0
- package/esm/cli/commands/drop-tables.command.mjs +23 -0
- package/esm/cli/commands/drop-tables.command.mjs.map +1 -0
- package/esm/cli/commands/generate/generate.command.mjs +201 -0
- package/esm/cli/commands/generate/generate.command.mjs.map +1 -0
- package/esm/cli/commands/generate/generators/column-dsl-parser.mjs +49 -0
- package/esm/cli/commands/generate/generators/column-dsl-parser.mjs.map +1 -0
- package/esm/cli/commands/generate/generators/controller.generator.mjs +48 -0
- package/esm/cli/commands/generate/generators/controller.generator.mjs.map +1 -0
- package/esm/cli/commands/generate/generators/migration.generator.mjs +81 -0
- package/esm/cli/commands/generate/generators/migration.generator.mjs.map +1 -0
- package/esm/cli/commands/generate/generators/model.generator.mjs +60 -0
- package/esm/cli/commands/generate/generators/model.generator.mjs.map +1 -0
- package/esm/cli/commands/generate/generators/module.generator.mjs +113 -0
- package/esm/cli/commands/generate/generators/module.generator.mjs.map +1 -0
- package/esm/cli/commands/generate/generators/repository.generator.mjs +42 -0
- package/esm/cli/commands/generate/generators/repository.generator.mjs.map +1 -0
- package/esm/cli/commands/generate/generators/resource.generator.mjs +42 -0
- package/esm/cli/commands/generate/generators/resource.generator.mjs.map +1 -0
- package/esm/cli/commands/generate/generators/service.generator.mjs +42 -0
- package/esm/cli/commands/generate/generators/service.generator.mjs.map +1 -0
- package/esm/cli/commands/generate/templates/stubs.mjs +514 -0
- package/esm/cli/commands/generate/templates/stubs.mjs.map +1 -0
- package/esm/cli/commands/generate/utils/name-parser.mjs +69 -0
- package/esm/cli/commands/generate/utils/name-parser.mjs.map +1 -0
- package/esm/cli/commands/generate/utils/path-resolver.mjs +56 -0
- package/esm/cli/commands/generate/utils/path-resolver.mjs.map +1 -0
- package/esm/cli/commands/generate/utils/prompt.mjs +28 -0
- package/esm/cli/commands/generate/utils/prompt.mjs.map +1 -0
- package/esm/cli/commands/generate/utils/writer.mjs +60 -0
- package/esm/cli/commands/generate/utils/writer.mjs.map +1 -0
- package/esm/cli/commands/migrate.command.mjs +60 -0
- package/esm/cli/commands/migrate.command.mjs.map +1 -0
- package/esm/cli/commands/seed.command.mjs +41 -0
- package/esm/cli/commands/seed.command.mjs.map +1 -0
- package/esm/cli/commands/start-production.command.mjs +50 -0
- package/esm/cli/commands/start-production.command.mjs.map +1 -0
- package/esm/cli/commands/storage-put.action.mjs +75 -0
- package/esm/cli/commands/storage-put.action.mjs.map +1 -0
- package/esm/cli/commands/storage-put.command.mjs +46 -0
- package/esm/cli/commands/storage-put.command.mjs.map +1 -0
- package/esm/cli/commands/typings-generator.command.mjs +38 -0
- package/esm/cli/commands/typings-generator.command.mjs.map +1 -0
- package/esm/cli/commands-loader.mjs +50 -0
- package/esm/cli/commands-loader.mjs.map +1 -0
- package/esm/cli/framework-cli-commands.mjs +37 -0
- package/esm/cli/framework-cli-commands.mjs.map +1 -0
- package/esm/cli/parse-cli-args.mjs +62 -0
- package/esm/cli/parse-cli-args.mjs.map +1 -0
- package/esm/cli/start.d.mts +1 -0
- package/esm/cli/start.mjs +8 -0
- package/esm/cli/start.mjs.map +1 -0
- package/esm/cli/string-similarity.mjs +56 -0
- package/esm/cli/string-similarity.mjs.map +1 -0
- package/esm/database/create-database-action.mjs +32 -0
- package/esm/database/create-database-action.mjs.map +1 -0
- package/esm/database/drop-tables-action.mjs +35 -0
- package/esm/database/drop-tables-action.mjs.map +1 -0
- package/esm/database/migrate-action.mjs +99 -0
- package/esm/database/migrate-action.mjs.map +1 -0
- package/esm/database/seed-command-action.mjs +74 -0
- package/esm/database/seed-command-action.mjs.map +1 -0
- package/esm/database/seeds/seeders.manager.mjs +129 -0
- package/esm/database/seeds/seeders.manager.mjs.map +1 -0
- package/esm/database/seeds/seeds-table-migration.mjs +31 -0
- package/esm/database/seeds/seeds-table-migration.mjs.map +1 -0
- package/esm/database/seeds/utils.mjs +6 -0
- package/esm/database/seeds/utils.mjs.map +1 -0
- package/esm/dev-server/dev-logger.mjs +12 -1
- package/esm/dev-server/dev-logger.mjs.map +1 -1
- package/esm/dev-server/development-server.mjs +115 -0
- package/esm/dev-server/development-server.mjs.map +1 -0
- package/esm/dev-server/layer-executor.mjs +114 -0
- package/esm/dev-server/layer-executor.mjs.map +1 -0
- package/esm/dev-server/start-development-server.mjs +63 -0
- package/esm/dev-server/start-development-server.mjs.map +1 -0
- package/esm/dev-server/type-generator.mjs +453 -0
- package/esm/dev-server/type-generator.mjs.map +1 -0
- package/esm/generations/add-command.action.mjs +480 -0
- package/esm/generations/add-command.action.mjs.map +1 -0
- package/esm/generations/stubs.mjs +436 -0
- package/esm/generations/stubs.mjs.map +1 -0
- package/esm/manifest/manifest-manager.mjs +79 -0
- package/esm/manifest/manifest-manager.mjs.map +1 -0
- package/esm/production/build-app-production.mjs +14 -0
- package/esm/production/build-app-production.mjs.map +1 -0
- package/esm/production/esbuild-plugins.mjs +37 -0
- package/esm/production/esbuild-plugins.mjs.map +1 -0
- package/esm/production/production-builder.mjs +264 -0
- package/esm/production/production-builder.mjs.map +1 -0
- package/esm/production/resolve-build-config.mjs +28 -0
- package/esm/production/resolve-build-config.mjs.map +1 -0
- package/esm/utils/framework-vesion.mjs +10 -1
- package/esm/utils/framework-vesion.mjs.map +1 -1
- package/package.json +15 -9
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { appPath, warlockPath } from "../utils/paths.mjs";
|
|
2
|
+
import "../utils/index.mjs";
|
|
3
|
+
import { tsconfigManager } from "../dev-server/tsconfig-manager.mjs";
|
|
4
|
+
import { nativeNodeModulesPlugin } from "./esbuild-plugins.mjs";
|
|
5
|
+
import { resolveBuildConfig } from "./resolve-build-config.mjs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { toCamelCase } from "@mongez/reinforcements";
|
|
8
|
+
import { colors } from "@mongez/copper";
|
|
9
|
+
import { ensureDirectoryAsync, fileExistsAsync, putFileAsync, removeDirectoryAsync } from "@warlock.js/fs";
|
|
10
|
+
import glob from "fast-glob";
|
|
11
|
+
import esbuild from "esbuild";
|
|
12
|
+
|
|
13
|
+
//#region ../@warlock.js/core/src/production/production-builder.ts
|
|
14
|
+
/**
|
|
15
|
+
* Production Builder
|
|
16
|
+
* Generates production-ready files and bundles them for deployment
|
|
17
|
+
* Build options are loaded from warlock.config.ts
|
|
18
|
+
*/
|
|
19
|
+
var ProductionBuilder = class {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.productionDir = warlockPath("production");
|
|
22
|
+
this.generatedFiles = {
|
|
23
|
+
locales: false,
|
|
24
|
+
events: false,
|
|
25
|
+
main: false,
|
|
26
|
+
routes: false
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Main build entry point
|
|
31
|
+
*/
|
|
32
|
+
async build() {
|
|
33
|
+
console.log(colors.cyan("Building for production...\n"));
|
|
34
|
+
await this.initializeOptions();
|
|
35
|
+
await this.generateCombinedFiles();
|
|
36
|
+
await this.generateEntryPoint();
|
|
37
|
+
await this.bundle();
|
|
38
|
+
await removeDirectoryAsync(this.productionDir);
|
|
39
|
+
console.log(colors.green("Build complete!"));
|
|
40
|
+
console.log(`Start production server by running ${colors.cyan("warlock start")}`);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Initialize options from warlock.config.ts
|
|
44
|
+
*/
|
|
45
|
+
async initializeOptions() {
|
|
46
|
+
this.options = resolveBuildConfig();
|
|
47
|
+
await ensureDirectoryAsync(this.productionDir);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Generate all combined files
|
|
51
|
+
*/
|
|
52
|
+
async generateCombinedFiles() {
|
|
53
|
+
console.log(colors.yellow(" Generating production files..."));
|
|
54
|
+
await this.generateBootstrap();
|
|
55
|
+
await this.generateConfigLoader();
|
|
56
|
+
const [locales, events, main, routes] = await Promise.all([
|
|
57
|
+
this.generateLocales(),
|
|
58
|
+
this.generateEvents(),
|
|
59
|
+
this.generateMain(),
|
|
60
|
+
this.generateRoutes()
|
|
61
|
+
]);
|
|
62
|
+
this.generatedFiles = {
|
|
63
|
+
locales,
|
|
64
|
+
events,
|
|
65
|
+
main,
|
|
66
|
+
routes
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Generate bootstrap.ts - ensures bootstrap() runs first and sets production environment
|
|
71
|
+
*/
|
|
72
|
+
async generateBootstrap() {
|
|
73
|
+
let content = `import { bootstrap, Application } from "@warlock.js/core";
|
|
74
|
+
|
|
75
|
+
// Set production environment
|
|
76
|
+
Application.setRuntimeStrategy("production");
|
|
77
|
+
Application.setEnvironment("production");
|
|
78
|
+
|
|
79
|
+
// Bootstrap the application
|
|
80
|
+
bootstrap();
|
|
81
|
+
`;
|
|
82
|
+
if (await fileExistsAsync(appPath("bootstrap.ts"))) content += "import './../../src/app/bootstrap';\n";
|
|
83
|
+
await putFileAsync(path.join(this.productionDir, "bootstrap.ts"), content);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Glob for module files matching a pattern
|
|
87
|
+
* Returns relative paths from .warlock/production/ to src/app/
|
|
88
|
+
*/
|
|
89
|
+
async globModule(fileName) {
|
|
90
|
+
return (await glob(`**/${fileName}.{ts,tsx}`, {
|
|
91
|
+
cwd: appPath(),
|
|
92
|
+
absolute: false
|
|
93
|
+
})).map((file) => "../../src/app/" + file.replace(/\.(ts|tsx)$/, ""));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Glob for files in a specific directory pattern
|
|
97
|
+
* Returns relative paths from .warlock/production/ to src/app/
|
|
98
|
+
*/
|
|
99
|
+
async globModuleDirectory(directory) {
|
|
100
|
+
return (await glob(`**/${directory}/*.{ts,tsx}`, {
|
|
101
|
+
cwd: appPath(),
|
|
102
|
+
absolute: false
|
|
103
|
+
})).map((file) => "../../src/app/" + file.replace(/\.(ts|tsx)$/, ""));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Generate config-loader.ts
|
|
107
|
+
*/
|
|
108
|
+
async generateConfigLoader() {
|
|
109
|
+
const configNames = (await glob("*.{ts,tsx}", {
|
|
110
|
+
cwd: path.join(process.cwd(), "src/config"),
|
|
111
|
+
absolute: false
|
|
112
|
+
})).map((f) => f.replace(/\.(ts|tsx)$/, ""));
|
|
113
|
+
const imports = ["import config from \"@mongez/config\";", "import { configSpecialHandlers } from \"@warlock.js/core\";"];
|
|
114
|
+
const configImports = [];
|
|
115
|
+
const configSetCalls = [];
|
|
116
|
+
const executors = [];
|
|
117
|
+
for (const configName of configNames) {
|
|
118
|
+
const properConfigName = toCamelCase(configName);
|
|
119
|
+
const varName = `${properConfigName}Config`;
|
|
120
|
+
configImports.push(`import ${varName} from "../../src/config/${configName}";`);
|
|
121
|
+
configSetCalls.push(`config.set("${properConfigName}", ${varName});`);
|
|
122
|
+
executors.push(`await configSpecialHandlers.execute("${properConfigName}", ${varName});`);
|
|
123
|
+
}
|
|
124
|
+
let content = [
|
|
125
|
+
...imports,
|
|
126
|
+
"",
|
|
127
|
+
"// Config imports",
|
|
128
|
+
...configImports,
|
|
129
|
+
"",
|
|
130
|
+
"// Register configs",
|
|
131
|
+
...configSetCalls,
|
|
132
|
+
"",
|
|
133
|
+
"// Special handlers",
|
|
134
|
+
...executors,
|
|
135
|
+
""
|
|
136
|
+
].join("\n");
|
|
137
|
+
if (await fileExistsAsync(appPath("prestart.ts"))) content += "import './../../src/app/prestart';\n";
|
|
138
|
+
await putFileAsync(path.join(this.productionDir, "config-loader.ts"), content);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Generate locales.ts (only if there are locale files)
|
|
142
|
+
* @returns true if file was generated with content
|
|
143
|
+
*/
|
|
144
|
+
async generateLocales() {
|
|
145
|
+
const files = await this.globModule("utils/locales");
|
|
146
|
+
if (files.length === 0) return false;
|
|
147
|
+
await this.generateImportsFile(files, "locales.ts");
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Generate events.ts (only if there are event files)
|
|
152
|
+
* @returns true if file was generated with content
|
|
153
|
+
*/
|
|
154
|
+
async generateEvents() {
|
|
155
|
+
const files = await this.globModuleDirectory("events");
|
|
156
|
+
if (files.length === 0) return false;
|
|
157
|
+
await this.generateImportsFile(files, "events.ts");
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Generate main.ts (only if there are main files)
|
|
162
|
+
* @returns true if file was generated with content
|
|
163
|
+
*/
|
|
164
|
+
async generateMain() {
|
|
165
|
+
const files = await this.globModule("main");
|
|
166
|
+
if (files.length === 0) return false;
|
|
167
|
+
await this.generateImportsFile(files, "main.ts");
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Generate routes.ts (only if there are route files)
|
|
172
|
+
* @returns true if file was generated with content
|
|
173
|
+
*/
|
|
174
|
+
async generateRoutes() {
|
|
175
|
+
const files = await this.globModule("routes");
|
|
176
|
+
if (files.length === 0) return false;
|
|
177
|
+
await this.generateImportsFile(files, "routes.ts");
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Generate a file with imports from all given files
|
|
182
|
+
*/
|
|
183
|
+
async generateImportsFile(importPaths, outputFile) {
|
|
184
|
+
const content = importPaths.map((importPath) => `import "${importPath}";`).join("\n") + "\n";
|
|
185
|
+
await putFileAsync(path.join(this.productionDir, outputFile), content);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Generate the main entry point (app.ts)
|
|
189
|
+
*/
|
|
190
|
+
async generateEntryPoint() {
|
|
191
|
+
console.log(colors.yellow(" Generating entry point..."));
|
|
192
|
+
const imports = [
|
|
193
|
+
"// 1. Bootstrap (loads .env, initializes framework)",
|
|
194
|
+
"import \"./bootstrap\";",
|
|
195
|
+
"",
|
|
196
|
+
"// 2. Load configs",
|
|
197
|
+
"import \"./config-loader\";",
|
|
198
|
+
"",
|
|
199
|
+
"// 3. Start early-phase connectors (database, cache, logger, ...)",
|
|
200
|
+
"// so data sources, cache, etc. are ready before app code runs",
|
|
201
|
+
"import { connectorsManager, ConnectorLifecyclePhase } from \"@warlock.js/core\";",
|
|
202
|
+
"await connectorsManager.startPhase(ConnectorLifecyclePhase.Early);"
|
|
203
|
+
];
|
|
204
|
+
imports.push("", "// 4. Load app code (events, locales, main, routes)");
|
|
205
|
+
if (this.generatedFiles.events) imports.push("await import(\"./events\");");
|
|
206
|
+
if (this.generatedFiles.locales) imports.push("await import(\"./locales\");");
|
|
207
|
+
if (this.generatedFiles.main) imports.push("await import(\"./main\");");
|
|
208
|
+
if (this.generatedFiles.routes) imports.push("await import(\"./routes\");");
|
|
209
|
+
imports.push("", "// 5. Start late-phase connectors (http, socket) — routes and", "// listeners registered by app code are now ready to bind", "await connectorsManager.startPhase(ConnectorLifecyclePhase.Late);", "connectorsManager.shutdownOnProcessKill();");
|
|
210
|
+
const content = imports.join("\n") + "\n";
|
|
211
|
+
await putFileAsync(path.join(this.productionDir, "app.ts"), content);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Bundle with esbuild
|
|
215
|
+
*/
|
|
216
|
+
async bundle() {
|
|
217
|
+
console.log(colors.magenta(" Bundling with esbuild..."));
|
|
218
|
+
const entryPoint = path.join(this.productionDir, "app.ts");
|
|
219
|
+
const outDir = this.options.outDirectory;
|
|
220
|
+
const outFileName = this.options.outFile;
|
|
221
|
+
const entryName = path.basename(outFileName, path.extname(outFileName));
|
|
222
|
+
await ensureDirectoryAsync(outDir);
|
|
223
|
+
const alias = this.buildAliasMapFromTsconfig();
|
|
224
|
+
await esbuild.build({
|
|
225
|
+
platform: "node",
|
|
226
|
+
entryPoints: [entryPoint],
|
|
227
|
+
bundle: true,
|
|
228
|
+
splitting: true,
|
|
229
|
+
packages: "external",
|
|
230
|
+
minify: this.options.minify,
|
|
231
|
+
sourcemap: this.options.sourcemap === true ? "linked" : this.options.sourcemap,
|
|
232
|
+
format: "esm",
|
|
233
|
+
target: ["node22"],
|
|
234
|
+
outdir: outDir,
|
|
235
|
+
entryNames: entryName,
|
|
236
|
+
alias,
|
|
237
|
+
plugins: [nativeNodeModulesPlugin]
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Build an alias map from tsconfig `paths` so esbuild resolves local
|
|
242
|
+
* source aliases (e.g. `@warlock.js/cascade`) to their on-disk source
|
|
243
|
+
* folders during bundling. Without this, `packages: "external"` would
|
|
244
|
+
* leave those bare specifiers as raw imports and Node would fail to
|
|
245
|
+
* resolve them at runtime (they aren't installed in node_modules).
|
|
246
|
+
*
|
|
247
|
+
* Only exact (non-wildcard) aliases are included — esbuild's `alias`
|
|
248
|
+
* option doesn't support glob-style mappings.
|
|
249
|
+
*/
|
|
250
|
+
buildAliasMapFromTsconfig() {
|
|
251
|
+
tsconfigManager.init();
|
|
252
|
+
const alias = {};
|
|
253
|
+
const baseUrl = path.resolve(process.cwd(), tsconfigManager.baseUrl);
|
|
254
|
+
for (const [from, to] of Object.entries(tsconfigManager.aliases)) {
|
|
255
|
+
if (from.endsWith("/*") || !Array.isArray(to) || to.length === 0) continue;
|
|
256
|
+
alias[from] = path.resolve(baseUrl, to[0]);
|
|
257
|
+
}
|
|
258
|
+
return alias;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
//#endregion
|
|
263
|
+
export { ProductionBuilder };
|
|
264
|
+
//# sourceMappingURL=production-builder.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"production-builder.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/production/production-builder.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport {\r\n ensureDirectoryAsync,\r\n fileExistsAsync,\r\n putFileAsync,\r\n removeDirectoryAsync,\r\n} from \"@warlock.js/fs\";\r\nimport esbuild from \"esbuild\";\r\nimport glob from \"fast-glob\";\r\nimport path from \"path\";\r\nimport { tsconfigManager } from \"../dev-server/tsconfig-manager\";\r\nimport { appPath, warlockPath } from \"../utils\";\r\nimport { nativeNodeModulesPlugin } from \"./esbuild-plugins\";\r\nimport { resolveBuildConfig, type ResolvedBuildConfig } from \"./resolve-build-config\";\r\nimport { toCamelCase, toKebabCase } from \"@mongez/reinforcements\";\r\n\r\n/**\r\n * Production Builder\r\n * Generates production-ready files and bundles them for deployment\r\n * Build options are loaded from warlock.config.ts\r\n */\r\nexport class ProductionBuilder {\r\n private options!: ResolvedBuildConfig;\r\n private readonly productionDir = warlockPath(\"production\");\r\n\r\n /**\r\n * Main build entry point\r\n */\r\n public async build(): Promise<void> {\r\n console.log(colors.cyan(\"Building for production...\\n\"));\r\n\r\n // Step 1: Initialize options from config\r\n await this.initializeOptions();\r\n\r\n // Step 2: Generate combined files\r\n await this.generateCombinedFiles();\r\n\r\n // Step 3: Generate entry point\r\n await this.generateEntryPoint();\r\n\r\n // Step 4: Bundle with esbuild\r\n await this.bundle();\r\n\r\n // // Step 5: Remove production folder\r\n await removeDirectoryAsync(this.productionDir);\r\n\r\n console.log(colors.green(\"Build complete!\"));\r\n console.log(`Start production server by running ${colors.cyan(\"warlock start\")}`);\r\n }\r\n\r\n /**\r\n * Initialize options from warlock.config.ts\r\n */\r\n private async initializeOptions(): Promise<void> {\r\n this.options = resolveBuildConfig();\r\n\r\n // Ensure production directory exists\r\n await ensureDirectoryAsync(this.productionDir);\r\n }\r\n\r\n /**\r\n * Track which special files were generated\r\n */\r\n private generatedFiles = {\r\n locales: false,\r\n events: false,\r\n main: false,\r\n routes: false,\r\n };\r\n\r\n /**\r\n * Generate all combined files\r\n */\r\n private async generateCombinedFiles(): Promise<void> {\r\n console.log(colors.yellow(\" Generating production files...\"));\r\n\r\n // Generate bootstrap.ts file\r\n await this.generateBootstrap();\r\n\r\n // Generate config loader\r\n await this.generateConfigLoader();\r\n\r\n // Generate special files and track which ones have content\r\n const [locales, events, main, routes] = await Promise.all([\r\n this.generateLocales(),\r\n this.generateEvents(),\r\n this.generateMain(),\r\n this.generateRoutes(),\r\n ]);\r\n\r\n this.generatedFiles = { locales, events, main, routes };\r\n }\r\n\r\n /**\r\n * Generate bootstrap.ts - ensures bootstrap() runs first and sets production environment\r\n */\r\n private async generateBootstrap(): Promise<void> {\r\n let content = `import { bootstrap, Application } from \"@warlock.js/core\";\r\n\r\n// Set production environment\r\nApplication.setRuntimeStrategy(\"production\");\r\nApplication.setEnvironment(\"production\");\r\n\r\n// Bootstrap the application\r\nbootstrap();\r\n`;\r\n if (await fileExistsAsync(appPath(\"bootstrap.ts\"))) {\r\n content += \"import './../../src/app/bootstrap';\\n\";\r\n }\r\n\r\n await putFileAsync(path.join(this.productionDir, \"bootstrap.ts\"), content);\r\n }\r\n\r\n /**\r\n * Glob for module files matching a pattern\r\n * Returns relative paths from .warlock/production/ to src/app/\r\n */\r\n private async globModule(fileName: string): Promise<string[]> {\r\n const pattern = `**/${fileName}.{ts,tsx}`;\r\n const appDirectory = appPath();\r\n\r\n const files = await glob(pattern, {\r\n cwd: appDirectory,\r\n absolute: false,\r\n });\r\n\r\n // Convert to relative paths from .warlock/production/ to src/app/\r\n // e.g., \"users/main\" -> \"../../src/app/users/main\"\r\n return files.map((file) => \"../../src/app/\" + file.replace(/\\.(ts|tsx)$/, \"\"));\r\n }\r\n\r\n /**\r\n * Glob for files in a specific directory pattern\r\n * Returns relative paths from .warlock/production/ to src/app/\r\n */\r\n private async globModuleDirectory(directory: string): Promise<string[]> {\r\n const pattern = `**/${directory}/*.{ts,tsx}`;\r\n const appDirectory = appPath();\r\n\r\n const files = await glob(pattern, {\r\n cwd: appDirectory,\r\n absolute: false,\r\n });\r\n\r\n return files.map((file) => \"../../src/app/\" + file.replace(/\\.(ts|tsx)$/, \"\"));\r\n }\r\n\r\n /**\r\n * Generate config-loader.ts\r\n */\r\n private async generateConfigLoader(): Promise<void> {\r\n const configDirectory = path.join(process.cwd(), \"src/config\");\r\n\r\n const files = await glob(\"*.{ts,tsx}\", {\r\n cwd: configDirectory,\r\n absolute: false,\r\n });\r\n\r\n const configNames = files.map((f) => f.replace(/\\.(ts|tsx)$/, \"\"));\r\n\r\n const imports: string[] = [\r\n 'import config from \"@mongez/config\";',\r\n 'import { configSpecialHandlers } from \"@warlock.js/core\";',\r\n ];\r\n const configImports: string[] = [];\r\n const configSetCalls: string[] = [];\r\n const executors: string[] = [];\r\n\r\n for (const configName of configNames) {\r\n const properConfigName = toCamelCase(configName);\r\n const varName = `${properConfigName}Config`;\r\n configImports.push(`import ${varName} from \"../../src/config/${configName}\";`);\r\n configSetCalls.push(`config.set(\"${properConfigName}\", ${varName});`);\r\n executors.push(`await configSpecialHandlers.execute(\"${properConfigName}\", ${varName});`);\r\n }\r\n\r\n let content = [\r\n ...imports,\r\n \"\",\r\n \"// Config imports\",\r\n ...configImports,\r\n \"\",\r\n \"// Register configs\",\r\n ...configSetCalls,\r\n \"\",\r\n \"// Special handlers\",\r\n ...executors,\r\n \"\",\r\n ].join(\"\\n\");\r\n\r\n if (await fileExistsAsync(appPath(\"prestart.ts\"))) {\r\n content += \"import './../../src/app/prestart';\\n\";\r\n }\r\n\r\n await putFileAsync(path.join(this.productionDir, \"config-loader.ts\"), content);\r\n }\r\n\r\n /**\r\n * Generate locales.ts (only if there are locale files)\r\n * @returns true if file was generated with content\r\n */\r\n private async generateLocales(): Promise<boolean> {\r\n const files = await this.globModule(\"utils/locales\");\r\n if (files.length === 0) return false;\r\n await this.generateImportsFile(files, \"locales.ts\");\r\n return true;\r\n }\r\n\r\n /**\r\n * Generate events.ts (only if there are event files)\r\n * @returns true if file was generated with content\r\n */\r\n private async generateEvents(): Promise<boolean> {\r\n const files = await this.globModuleDirectory(\"events\");\r\n if (files.length === 0) return false;\r\n await this.generateImportsFile(files, \"events.ts\");\r\n return true;\r\n }\r\n\r\n /**\r\n * Generate main.ts (only if there are main files)\r\n * @returns true if file was generated with content\r\n */\r\n private async generateMain(): Promise<boolean> {\r\n const files = await this.globModule(\"main\");\r\n if (files.length === 0) return false;\r\n await this.generateImportsFile(files, \"main.ts\");\r\n return true;\r\n }\r\n\r\n /**\r\n * Generate routes.ts (only if there are route files)\r\n * @returns true if file was generated with content\r\n */\r\n private async generateRoutes(): Promise<boolean> {\r\n const files = await this.globModule(\"routes\");\r\n if (files.length === 0) return false;\r\n await this.generateImportsFile(files, \"routes.ts\");\r\n return true;\r\n }\r\n\r\n /**\r\n * Generate a file with imports from all given files\r\n */\r\n private async generateImportsFile(importPaths: string[], outputFile: string): Promise<void> {\r\n const imports = importPaths.map((importPath) => `import \"${importPath}\";`);\r\n const content = imports.join(\"\\n\") + \"\\n\";\r\n await putFileAsync(path.join(this.productionDir, outputFile), content);\r\n }\r\n\r\n /**\r\n * Generate the main entry point (app.ts)\r\n */\r\n private async generateEntryPoint(): Promise<void> {\r\n console.log(colors.yellow(\" Generating entry point...\"));\r\n\r\n // Build imports based on which files were generated\r\n const imports: string[] = [\r\n \"// 1. Bootstrap (loads .env, initializes framework)\",\r\n 'import \"./bootstrap\";',\r\n \"\",\r\n \"// 2. Load configs\",\r\n 'import \"./config-loader\";',\r\n \"\",\r\n \"// 3. Start early-phase connectors (database, cache, logger, ...)\",\r\n \"// so data sources, cache, etc. are ready before app code runs\",\r\n 'import { connectorsManager, ConnectorLifecyclePhase } from \"@warlock.js/core\";',\r\n \"await connectorsManager.startPhase(ConnectorLifecyclePhase.Early);\",\r\n ];\r\n\r\n // App code uses dynamic `await import(...)` so each module's side\r\n // effects fire at THIS point in execution. Static imports would be\r\n // hoisted to module-instantiation time (before the early-phase await\r\n // resolves), which is exactly the bug this split is meant to fix.\r\n // Requires `splitting: true` in esbuild (set below in bundle()).\r\n imports.push(\"\", \"// 4. Load app code (events, locales, main, routes)\");\r\n\r\n if (this.generatedFiles.events) {\r\n imports.push('await import(\"./events\");');\r\n }\r\n if (this.generatedFiles.locales) {\r\n imports.push('await import(\"./locales\");');\r\n }\r\n if (this.generatedFiles.main) {\r\n imports.push('await import(\"./main\");');\r\n }\r\n if (this.generatedFiles.routes) {\r\n imports.push('await import(\"./routes\");');\r\n }\r\n\r\n // Start late-phase connectors after app code registers routes/listeners\r\n imports.push(\r\n \"\",\r\n \"// 5. Start late-phase connectors (http, socket) — routes and\",\r\n \"// listeners registered by app code are now ready to bind\",\r\n \"await connectorsManager.startPhase(ConnectorLifecyclePhase.Late);\",\r\n \"connectorsManager.shutdownOnProcessKill();\",\r\n );\r\n\r\n const content = imports.join(\"\\n\") + \"\\n\";\r\n await putFileAsync(path.join(this.productionDir, \"app.ts\"), content);\r\n }\r\n\r\n /**\r\n * Bundle with esbuild\r\n */\r\n private async bundle(): Promise<void> {\r\n console.log(colors.magenta(\" Bundling with esbuild...\"));\r\n\r\n const entryPoint = path.join(this.productionDir, \"app.ts\");\r\n const outDir = this.options!.outDirectory!;\r\n const outFileName = this.options!.outFile!;\r\n // Strip extension so entryNames produces \"<base>.js\" via esbuild\r\n const entryName = path.basename(outFileName, path.extname(outFileName));\r\n\r\n await ensureDirectoryAsync(outDir);\r\n\r\n const alias = this.buildAliasMapFromTsconfig();\r\n\r\n await esbuild.build({\r\n platform: \"node\",\r\n entryPoints: [entryPoint],\r\n bundle: true,\r\n // Required so dynamic `await import(\"./main\")` in the generated\r\n // app.ts produces separate chunks loaded at the runtime call site,\r\n // instead of inlining the modules at instantiation time (which\r\n // would defeat the early/late phase split).\r\n splitting: true,\r\n packages: \"external\",\r\n minify: this.options!.minify,\r\n sourcemap: this.options!.sourcemap === true ? \"linked\" : this.options!.sourcemap,\r\n format: \"esm\",\r\n // Targeting a concrete Node version (not \"esnext\") so esbuild\r\n // transpiles TC39 stage 3 decorators into helpers — Node does not\r\n // implement them natively yet.\r\n target: [\"node22\"],\r\n outdir: outDir,\r\n entryNames: entryName,\r\n alias,\r\n plugins: [nativeNodeModulesPlugin],\r\n });\r\n }\r\n\r\n /**\r\n * Build an alias map from tsconfig `paths` so esbuild resolves local\r\n * source aliases (e.g. `@warlock.js/cascade`) to their on-disk source\r\n * folders during bundling. Without this, `packages: \"external\"` would\r\n * leave those bare specifiers as raw imports and Node would fail to\r\n * resolve them at runtime (they aren't installed in node_modules).\r\n *\r\n * Only exact (non-wildcard) aliases are included — esbuild's `alias`\r\n * option doesn't support glob-style mappings.\r\n */\r\n private buildAliasMapFromTsconfig(): Record<string, string> {\r\n tsconfigManager.init();\r\n\r\n const alias: Record<string, string> = {};\r\n const baseUrl = path.resolve(process.cwd(), tsconfigManager.baseUrl);\r\n\r\n for (const [from, to] of Object.entries(tsconfigManager.aliases)) {\r\n if (from.endsWith(\"/*\") || !Array.isArray(to) || to.length === 0) {\r\n continue;\r\n }\r\n\r\n alias[from] = path.resolve(baseUrl, to[0]);\r\n }\r\n\r\n return alias;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,IAAa,oBAAb,MAA+B;;uBAEI,YAAY,YAAY;wBAwChC;GACvB,SAAS;GACT,QAAQ;GACR,MAAM;GACN,QAAQ;EACV;;;;;CAxCA,MAAa,QAAuB;EAClC,QAAQ,IAAI,OAAO,KAAK,8BAA8B,CAAC;EAGvD,MAAM,KAAK,kBAAkB;EAG7B,MAAM,KAAK,sBAAsB;EAGjC,MAAM,KAAK,mBAAmB;EAG9B,MAAM,KAAK,OAAO;EAGlB,MAAM,qBAAqB,KAAK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AAW;GACX,UAAU;GACV,QAAQ,KAAK,QAAS;GACtB,WAAW,KAAK,QAAS,cAAc,OAAO,WAAW,KAAK,QAAS;GACvE,QAAQ;GAIR,QAAQ,CAAC,QAAQ;GACjB,QAAQ;GACR,YAAY;GACZ;GACA,SAAS,CAAC,uBAAuB;EACnC,CAAC;CACH;;;;;;;;;;;CAYA,AAAQ,4BAAoD;EAC1D,gBAAgB,KAAK;EAErB,MAAM,QAAgC,CAAC;EACvC,MAAM,UAAU,KAAK,QAAQ,QAAQ,IAAI,GAAG,gBAAgB,OAAO;EAEnE,KAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,gBAAgB,OAAO,GAAG;GAChE,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,QAAQ,EAAE,KAAK,GAAG,WAAW,GAC7D;GAGF,MAAM,QAAQ,KAAK,QAAQ,SAAS,GAAG,EAAE;EAC3C;EAEA,OAAO;CACT;AACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { warlockConfigManager } from "../warlock-config/warlock-config.manager.mjs";
|
|
2
|
+
import { defaultWarlockConfigurations } from "../warlock-config/default-configurations.mjs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
//#region ../@warlock.js/core/src/production/resolve-build-config.ts
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the build config with framework defaults applied.
|
|
8
|
+
*
|
|
9
|
+
* Both the production builder and `warlock start` call this so they
|
|
10
|
+
* agree on where the bundle lives — previously each had its own local
|
|
11
|
+
* fallbacks and they drifted (`.warlock/production` vs `dist`),
|
|
12
|
+
* letting `build` and `start` look at different paths.
|
|
13
|
+
*/
|
|
14
|
+
function resolveBuildConfig() {
|
|
15
|
+
const userBuild = warlockConfigManager.get("build") ?? {};
|
|
16
|
+
const merged = {
|
|
17
|
+
...defaultWarlockConfigurations.build,
|
|
18
|
+
...userBuild
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
...merged,
|
|
22
|
+
entryPath: path.resolve(merged.outDirectory, merged.outFile)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { resolveBuildConfig };
|
|
28
|
+
//# sourceMappingURL=resolve-build-config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-build-config.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/production/resolve-build-config.ts"],"sourcesContent":["import path from \"path\";\nimport { defaultWarlockConfigurations } from \"../warlock-config/default-configurations\";\nimport type { WarlockConfig } from \"../warlock-config/types\";\nimport { warlockConfigManager } from \"../warlock-config/warlock-config.manager\";\n\nexport type ResolvedBuildConfig = Required<NonNullable<WarlockConfig[\"build\"]>> & {\n /** Absolute path to the bundled entry file (`{outDirectory}/{outFile}`) */\n entryPath: string;\n};\n\n/**\n * Resolve the build config with framework defaults applied.\n *\n * Both the production builder and `warlock start` call this so they\n * agree on where the bundle lives — previously each had its own local\n * fallbacks and they drifted (`.warlock/production` vs `dist`),\n * letting `build` and `start` look at different paths.\n */\nexport function resolveBuildConfig(): ResolvedBuildConfig {\n const userBuild = warlockConfigManager.get(\"build\") ?? {};\n const defaults = defaultWarlockConfigurations.build!;\n const merged = { ...defaults, ...userBuild } as Required<NonNullable<WarlockConfig[\"build\"]>>;\n\n return {\n ...merged,\n entryPath: path.resolve(merged.outDirectory, merged.outFile),\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAgB,qBAA0C;CACxD,MAAM,YAAY,qBAAqB,IAAI,OAAO,KAAK,CAAC;CAExD,MAAM,SAAS;EAAE,GADA,6BAA6B;EAChB,GAAG;CAAU;CAE3C,OAAO;EACL,GAAG;EACH,WAAW,KAAK,QAAQ,OAAO,cAAc,OAAO,OAAO;CAC7D;AACF"}
|
|
@@ -6,10 +6,19 @@ import path from "node:path";
|
|
|
6
6
|
* Cached version string
|
|
7
7
|
*/
|
|
8
8
|
let cachedVersion = null;
|
|
9
|
+
/**
|
|
10
|
+
* Get the framework version from package.json (cached)
|
|
11
|
+
*/
|
|
12
|
+
async function getWarlockVersion() {
|
|
13
|
+
if (cachedVersion) return cachedVersion;
|
|
14
|
+
const version = (await getJsonFileAsync(path.join(import.meta.dirname, "./../../package.json"))).version.replace(/\^|\~/g, "");
|
|
15
|
+
cachedVersion = version;
|
|
16
|
+
return version;
|
|
17
|
+
}
|
|
9
18
|
function getFrameworkVersion() {
|
|
10
19
|
return cachedVersion;
|
|
11
20
|
}
|
|
12
21
|
|
|
13
22
|
//#endregion
|
|
14
|
-
export { getFrameworkVersion };
|
|
23
|
+
export { getFrameworkVersion, getWarlockVersion };
|
|
15
24
|
//# sourceMappingURL=framework-vesion.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-vesion.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/utils/framework-vesion.ts"],"sourcesContent":["import { getJsonFileAsync } from \"@warlock.js/fs\";\r\nimport path from \"node:path\";\r\n\r\n/**\r\n * Cached version string\r\n */\r\nlet cachedVersion: string | null = null;\r\n\r\n/**\r\n * Get the framework version from package.json (cached)\r\n */\r\nexport async function getWarlockVersion(): Promise<string> {\r\n if (cachedVersion) return cachedVersion;\r\n\r\n const frameworkPackageJson = (await getJsonFileAsync(\r\n path.join(import.meta.dirname, \"./../../package.json\"),\r\n )) as { version: string };\r\n\r\n const version = frameworkPackageJson.version.replace(/\\^|\\~/g, \"\");\r\n cachedVersion = version;\r\n return version;\r\n}\r\n\r\nexport function getFrameworkVersion(): string | null {\r\n return cachedVersion;\r\n}\r\n"],"mappings":";;;;;;;AAMA,IAAI,gBAA+B;
|
|
1
|
+
{"version":3,"file":"framework-vesion.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/utils/framework-vesion.ts"],"sourcesContent":["import { getJsonFileAsync } from \"@warlock.js/fs\";\r\nimport path from \"node:path\";\r\n\r\n/**\r\n * Cached version string\r\n */\r\nlet cachedVersion: string | null = null;\r\n\r\n/**\r\n * Get the framework version from package.json (cached)\r\n */\r\nexport async function getWarlockVersion(): Promise<string> {\r\n if (cachedVersion) return cachedVersion;\r\n\r\n const frameworkPackageJson = (await getJsonFileAsync(\r\n path.join(import.meta.dirname, \"./../../package.json\"),\r\n )) as { version: string };\r\n\r\n const version = frameworkPackageJson.version.replace(/\\^|\\~/g, \"\");\r\n cachedVersion = version;\r\n return version;\r\n}\r\n\r\nexport function getFrameworkVersion(): string | null {\r\n return cachedVersion;\r\n}\r\n"],"mappings":";;;;;;;AAMA,IAAI,gBAA+B;;;;AAKnC,eAAsB,oBAAqC;CACzD,IAAI,eAAe,OAAO;CAM1B,MAAM,WAAU,MAJoB,iBAClC,KAAK,KAAK,OAAO,KAAK,SAAS,sBAAsB,CACvD,EAEoC,CAAC,QAAQ,QAAQ,UAAU,EAAE;CACjE,gBAAgB;CAChB,OAAO;AACT;AAEA,SAAgB,sBAAqC;CACnD,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"@mongez/slug": "^1.0.7",
|
|
37
37
|
"@mongez/supportive-is": "^2.1.3",
|
|
38
38
|
"@mongez/time-wizard": "^1.0.6",
|
|
39
|
-
"@warlock.js/auth": "4.2.
|
|
40
|
-
"@warlock.js/cache": "4.2.
|
|
41
|
-
"@warlock.js/cascade": "4.2.
|
|
42
|
-
"@warlock.js/context": "4.2.
|
|
43
|
-
"@warlock.js/logger": "4.2.
|
|
44
|
-
"@warlock.js/seal": "4.2.
|
|
45
|
-
"@warlock.js/fs": "4.2.
|
|
39
|
+
"@warlock.js/auth": "4.2.2",
|
|
40
|
+
"@warlock.js/cache": "4.2.2",
|
|
41
|
+
"@warlock.js/cascade": "4.2.2",
|
|
42
|
+
"@warlock.js/context": "4.2.2",
|
|
43
|
+
"@warlock.js/logger": "4.2.2",
|
|
44
|
+
"@warlock.js/seal": "4.2.2",
|
|
45
|
+
"@warlock.js/fs": "4.2.2",
|
|
46
46
|
"chokidar": "^5.0.0",
|
|
47
47
|
"dayjs": "^1.11.19",
|
|
48
48
|
"es-module-lexer": "^2.0.0",
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
"react": "^19.2.3",
|
|
69
69
|
"react-dom": "^19.2.3",
|
|
70
70
|
"@react-email/render": "^2.0.5",
|
|
71
|
-
"@warlock.js/herald": "4.2.
|
|
71
|
+
"@warlock.js/herald": "4.2.2"
|
|
72
72
|
},
|
|
73
73
|
"bin": {
|
|
74
74
|
"warlock": "bin/warlock.js"
|
|
75
75
|
},
|
|
76
|
-
"version": "4.2.
|
|
76
|
+
"version": "4.2.2",
|
|
77
77
|
"type": "module",
|
|
78
78
|
"main": "./esm/index.mjs",
|
|
79
79
|
"module": "./esm/index.mjs",
|
|
@@ -84,6 +84,12 @@
|
|
|
84
84
|
"types": "./esm/index.d.mts",
|
|
85
85
|
"default": "./esm/index.mjs"
|
|
86
86
|
}
|
|
87
|
+
},
|
|
88
|
+
"./cli/start": {
|
|
89
|
+
"import": {
|
|
90
|
+
"types": "./esm/cli/start.d.mts",
|
|
91
|
+
"default": "./esm/cli/start.mjs"
|
|
92
|
+
}
|
|
87
93
|
}
|
|
88
94
|
}
|
|
89
95
|
}
|