alepha 0.13.0 → 0.13.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/api-jobs/index.d.ts +26 -26
- package/dist/api-users/index.d.ts +1 -1
- package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
- package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
- package/dist/cli/index.d.ts +3 -11
- package/dist/cli/index.js +106 -74
- package/dist/cli/index.js.map +1 -1
- package/dist/email/index.js +71 -73
- package/dist/email/index.js.map +1 -1
- package/dist/orm/index.d.ts +1 -1
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/index.d.ts +4 -4
- package/dist/retry/index.d.ts +1 -1
- package/dist/retry/index.js +2 -2
- package/dist/retry/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +6 -6
- package/dist/security/index.d.ts +28 -28
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server-health/index.d.ts +17 -17
- package/dist/server-metrics/index.js +170 -174
- package/dist/server-metrics/index.js.map +1 -1
- package/dist/server-security/index.d.ts +9 -9
- package/dist/vite/index.js +4 -5
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.d.ts +7 -7
- package/package.json +52 -103
- package/src/cli/apps/AlephaPackageBuilderCli.ts +7 -2
- package/src/cli/assets/appRouterTs.ts +9 -0
- package/src/cli/assets/indexHtml.ts +2 -1
- package/src/cli/assets/mainBrowserTs.ts +10 -0
- package/src/cli/commands/CoreCommands.ts +6 -5
- package/src/cli/commands/DrizzleCommands.ts +65 -57
- package/src/cli/commands/VerifyCommands.ts +1 -1
- package/src/cli/services/ProjectUtils.ts +44 -38
- package/src/orm/providers/DrizzleKitProvider.ts +1 -1
- package/src/retry/descriptors/$retry.ts +5 -3
- package/src/server/providers/NodeHttpServerProvider.ts +1 -1
- package/src/vite/helpers/boot.ts +3 -3
- package/dist/api-files/index.cjs +0 -1293
- package/dist/api-files/index.cjs.map +0 -1
- package/dist/api-files/index.d.cts +0 -829
- package/dist/api-jobs/index.cjs +0 -274
- package/dist/api-jobs/index.cjs.map +0 -1
- package/dist/api-jobs/index.d.cts +0 -654
- package/dist/api-notifications/index.cjs +0 -380
- package/dist/api-notifications/index.cjs.map +0 -1
- package/dist/api-notifications/index.d.cts +0 -289
- package/dist/api-parameters/index.cjs +0 -66
- package/dist/api-parameters/index.cjs.map +0 -1
- package/dist/api-parameters/index.d.cts +0 -84
- package/dist/api-users/index.cjs +0 -6009
- package/dist/api-users/index.cjs.map +0 -1
- package/dist/api-users/index.d.cts +0 -4740
- package/dist/api-verifications/index.cjs +0 -407
- package/dist/api-verifications/index.cjs.map +0 -1
- package/dist/api-verifications/index.d.cts +0 -207
- package/dist/batch/index.cjs +0 -408
- package/dist/batch/index.cjs.map +0 -1
- package/dist/batch/index.d.cts +0 -330
- package/dist/bin/index.cjs +0 -17
- package/dist/bin/index.cjs.map +0 -1
- package/dist/bin/index.d.cts +0 -1
- package/dist/bucket/index.cjs +0 -303
- package/dist/bucket/index.cjs.map +0 -1
- package/dist/bucket/index.d.cts +0 -355
- package/dist/cache/index.cjs +0 -241
- package/dist/cache/index.cjs.map +0 -1
- package/dist/cache/index.d.cts +0 -202
- package/dist/cache-redis/index.cjs +0 -84
- package/dist/cache-redis/index.cjs.map +0 -1
- package/dist/cache-redis/index.d.cts +0 -40
- package/dist/cli/chunk-DSlc6foC.cjs +0 -43
- package/dist/cli/dist-BBPjuQ56.js +0 -2778
- package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
- package/dist/cli/index.cjs +0 -1241
- package/dist/cli/index.cjs.map +0 -1
- package/dist/cli/index.d.cts +0 -422
- package/dist/command/index.cjs +0 -693
- package/dist/command/index.cjs.map +0 -1
- package/dist/command/index.d.cts +0 -340
- package/dist/core/index.cjs +0 -2264
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -1927
- package/dist/datetime/index.cjs +0 -318
- package/dist/datetime/index.cjs.map +0 -1
- package/dist/datetime/index.d.cts +0 -145
- package/dist/email/index.cjs +0 -10874
- package/dist/email/index.cjs.map +0 -1
- package/dist/email/index.d.cts +0 -186
- package/dist/fake/index.cjs +0 -34641
- package/dist/fake/index.cjs.map +0 -1
- package/dist/fake/index.d.cts +0 -74
- package/dist/file/index.cjs +0 -1212
- package/dist/file/index.cjs.map +0 -1
- package/dist/file/index.d.cts +0 -698
- package/dist/lock/index.cjs +0 -226
- package/dist/lock/index.cjs.map +0 -1
- package/dist/lock/index.d.cts +0 -361
- package/dist/lock-redis/index.cjs +0 -113
- package/dist/lock-redis/index.cjs.map +0 -1
- package/dist/lock-redis/index.d.cts +0 -24
- package/dist/logger/index.cjs +0 -521
- package/dist/logger/index.cjs.map +0 -1
- package/dist/logger/index.d.cts +0 -281
- package/dist/orm/index.cjs +0 -2986
- package/dist/orm/index.cjs.map +0 -1
- package/dist/orm/index.d.cts +0 -2213
- package/dist/queue/index.cjs +0 -1044
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts +0 -1265
- package/dist/queue-redis/index.cjs +0 -873
- package/dist/queue-redis/index.cjs.map +0 -1
- package/dist/queue-redis/index.d.cts +0 -82
- package/dist/redis/index.cjs +0 -153
- package/dist/redis/index.cjs.map +0 -1
- package/dist/redis/index.d.cts +0 -82
- package/dist/retry/index.cjs +0 -146
- package/dist/retry/index.cjs.map +0 -1
- package/dist/retry/index.d.cts +0 -172
- package/dist/router/index.cjs +0 -111
- package/dist/router/index.cjs.map +0 -1
- package/dist/router/index.d.cts +0 -46
- package/dist/scheduler/index.cjs +0 -576
- package/dist/scheduler/index.cjs.map +0 -1
- package/dist/scheduler/index.d.cts +0 -145
- package/dist/security/index.cjs +0 -2402
- package/dist/security/index.cjs.map +0 -1
- package/dist/security/index.d.cts +0 -598
- package/dist/server/index.cjs +0 -1680
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.d.cts +0 -810
- package/dist/server-auth/index.cjs +0 -3146
- package/dist/server-auth/index.cjs.map +0 -1
- package/dist/server-auth/index.d.cts +0 -1164
- package/dist/server-cache/index.cjs +0 -252
- package/dist/server-cache/index.cjs.map +0 -1
- package/dist/server-cache/index.d.cts +0 -164
- package/dist/server-compress/index.cjs +0 -141
- package/dist/server-compress/index.cjs.map +0 -1
- package/dist/server-compress/index.d.cts +0 -38
- package/dist/server-cookies/index.cjs +0 -234
- package/dist/server-cookies/index.cjs.map +0 -1
- package/dist/server-cookies/index.d.cts +0 -144
- package/dist/server-cors/index.cjs +0 -201
- package/dist/server-cors/index.cjs.map +0 -1
- package/dist/server-cors/index.d.cts +0 -140
- package/dist/server-health/index.cjs +0 -62
- package/dist/server-health/index.cjs.map +0 -1
- package/dist/server-health/index.d.cts +0 -58
- package/dist/server-helmet/index.cjs +0 -131
- package/dist/server-helmet/index.cjs.map +0 -1
- package/dist/server-helmet/index.d.cts +0 -97
- package/dist/server-links/index.cjs +0 -992
- package/dist/server-links/index.cjs.map +0 -1
- package/dist/server-links/index.d.cts +0 -513
- package/dist/server-metrics/index.cjs +0 -4535
- package/dist/server-metrics/index.cjs.map +0 -1
- package/dist/server-metrics/index.d.cts +0 -35
- package/dist/server-multipart/index.cjs +0 -237
- package/dist/server-multipart/index.cjs.map +0 -1
- package/dist/server-multipart/index.d.cts +0 -50
- package/dist/server-proxy/index.cjs +0 -186
- package/dist/server-proxy/index.cjs.map +0 -1
- package/dist/server-proxy/index.d.cts +0 -234
- package/dist/server-rate-limit/index.cjs +0 -241
- package/dist/server-rate-limit/index.cjs.map +0 -1
- package/dist/server-rate-limit/index.d.cts +0 -183
- package/dist/server-security/index.cjs +0 -316
- package/dist/server-security/index.cjs.map +0 -1
- package/dist/server-security/index.d.cts +0 -173
- package/dist/server-static/index.cjs +0 -170
- package/dist/server-static/index.cjs.map +0 -1
- package/dist/server-static/index.d.cts +0 -121
- package/dist/server-swagger/index.cjs +0 -1021
- package/dist/server-swagger/index.cjs.map +0 -1
- package/dist/server-swagger/index.d.cts +0 -382
- package/dist/sms/index.cjs +0 -221
- package/dist/sms/index.cjs.map +0 -1
- package/dist/sms/index.d.cts +0 -130
- package/dist/thread/index.cjs +0 -350
- package/dist/thread/index.cjs.map +0 -1
- package/dist/thread/index.d.cts +0 -260
- package/dist/topic/index.cjs +0 -282
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.d.cts +0 -523
- package/dist/topic-redis/index.cjs +0 -71
- package/dist/topic-redis/index.cjs.map +0 -1
- package/dist/topic-redis/index.d.cts +0 -42
- package/dist/vite/index.cjs +0 -1077
- package/dist/vite/index.cjs.map +0 -1
- package/dist/vite/index.d.cts +0 -542
- package/dist/websocket/index.cjs +0 -1117
- package/dist/websocket/index.cjs.map +0 -1
- package/dist/websocket/index.d.cts +0 -861
package/dist/cli/index.d.ts
CHANGED
|
@@ -179,15 +179,6 @@ declare class ProjectUtils {
|
|
|
179
179
|
alepha: Alepha;
|
|
180
180
|
entry: string;
|
|
181
181
|
}>;
|
|
182
|
-
/**
|
|
183
|
-
* Get DrizzleKitProvider from an Alepha instance.
|
|
184
|
-
*
|
|
185
|
-
* Searches the Alepha registry for the DrizzleKitProvider instance.
|
|
186
|
-
*
|
|
187
|
-
* @param alepha - The Alepha instance to search
|
|
188
|
-
* @returns The DrizzleKitProvider instance
|
|
189
|
-
*/
|
|
190
|
-
getKitFromAlepha(alepha: Alepha): any;
|
|
191
182
|
/**
|
|
192
183
|
* Generate JavaScript code for Drizzle entities export.
|
|
193
184
|
*
|
|
@@ -241,6 +232,7 @@ declare class ProjectUtils {
|
|
|
241
232
|
}
|
|
242
233
|
interface DependencyModes {
|
|
243
234
|
react?: boolean;
|
|
235
|
+
admin?: boolean;
|
|
244
236
|
}
|
|
245
237
|
//#endregion
|
|
246
238
|
//#region src/cli/commands/BiomeCommands.d.ts
|
|
@@ -273,9 +265,9 @@ declare class CoreCommands {
|
|
|
273
265
|
*/
|
|
274
266
|
readonly init: alepha_command0.CommandDescriptor<alepha0.TObject<{
|
|
275
267
|
yarn: alepha0.TOptional<alepha0.TBoolean>;
|
|
276
|
-
|
|
268
|
+
pnpm: alepha0.TOptional<alepha0.TBoolean>;
|
|
277
269
|
react: alepha0.TOptional<alepha0.TBoolean>;
|
|
278
|
-
|
|
270
|
+
admin: alepha0.TOptional<alepha0.TBoolean>;
|
|
279
271
|
}>, alepha0.TSchema>;
|
|
280
272
|
}
|
|
281
273
|
//#endregion
|
package/dist/cli/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
1
|
import { $env, $inject, $module, Alepha, AlephaError, OPTIONS, t } from "alepha";
|
|
3
2
|
import { $command, CliProvider } from "alepha/command";
|
|
4
3
|
import { $logger } from "alepha/logger";
|
|
@@ -78,6 +77,18 @@ var ProcessRunner = class {
|
|
|
78
77
|
}
|
|
79
78
|
};
|
|
80
79
|
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/cli/assets/appRouterTs.ts
|
|
82
|
+
const appRouterTs = () => `
|
|
83
|
+
import { $page } from "@alepha/react";
|
|
84
|
+
|
|
85
|
+
export class AppRouter {
|
|
86
|
+
home = $page({
|
|
87
|
+
component: () => "Hello World",
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
`.trim();
|
|
91
|
+
|
|
81
92
|
//#endregion
|
|
82
93
|
//#region src/cli/assets/biomeJson.ts
|
|
83
94
|
const biomeJson = `
|
|
@@ -116,7 +127,7 @@ const biomeJson = `
|
|
|
116
127
|
|
|
117
128
|
//#endregion
|
|
118
129
|
//#region src/cli/assets/indexHtml.ts
|
|
119
|
-
const indexHtml = (browserEntry
|
|
130
|
+
const indexHtml = (browserEntry) => `
|
|
120
131
|
<!DOCTYPE html>
|
|
121
132
|
<html lang="en">
|
|
122
133
|
<head>
|
|
@@ -124,11 +135,25 @@ const indexHtml = (browserEntry = "/src/main.tsx") => `
|
|
|
124
135
|
<title>App</title>
|
|
125
136
|
</head>
|
|
126
137
|
<body>
|
|
138
|
+
<div id="root"></div>
|
|
127
139
|
<script type="module" src="${browserEntry}"><\/script>
|
|
128
140
|
</body>
|
|
129
141
|
</html>
|
|
130
142
|
`.trim();
|
|
131
143
|
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/cli/assets/mainBrowserTs.ts
|
|
146
|
+
const mainBrowserTs = () => `
|
|
147
|
+
import { Alepha, run } from "alepha";
|
|
148
|
+
import { AppRouter } from "./AppRouter.ts";
|
|
149
|
+
|
|
150
|
+
const alepha = Alepha.create();
|
|
151
|
+
|
|
152
|
+
alepha.with(AppRouter);
|
|
153
|
+
|
|
154
|
+
run(alepha);
|
|
155
|
+
`.trim();
|
|
156
|
+
|
|
132
157
|
//#endregion
|
|
133
158
|
//#region src/cli/assets/tsconfigJson.ts
|
|
134
159
|
const tsconfigJson = `
|
|
@@ -181,16 +206,9 @@ var ProjectUtils = class {
|
|
|
181
206
|
* @param root - The root directory of the project
|
|
182
207
|
*/
|
|
183
208
|
async ensureYarn(root) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
} catch {
|
|
188
|
-
await writeFile(yarnrcPath, "nodeLinker: node-modules");
|
|
189
|
-
}
|
|
190
|
-
const npmLockPath = join(root, "package-lock.json");
|
|
191
|
-
const pnpmLockPath = join(root, "pnpm-lock.yaml");
|
|
192
|
-
await this.fs.rm(npmLockPath, { force: true });
|
|
193
|
-
await this.fs.rm(pnpmLockPath, { force: true });
|
|
209
|
+
await this.ensureFileExists(root, ".yarnrc.yml", "nodeLinker: node-modules", false);
|
|
210
|
+
await this.fs.rm(join(root, "package-lock.json"), { force: true });
|
|
211
|
+
await this.fs.rm(join(root, "pnpm-lock.yaml"), { force: true });
|
|
194
212
|
}
|
|
195
213
|
/**
|
|
196
214
|
* Generate package.json content with Alepha dependencies.
|
|
@@ -203,16 +221,19 @@ var ProjectUtils = class {
|
|
|
203
221
|
const devDependencies = {};
|
|
204
222
|
if (modes.react) {
|
|
205
223
|
dependencies["@alepha/react"] = `^${version}`;
|
|
206
|
-
dependencies.react = "19.
|
|
207
|
-
|
|
224
|
+
dependencies.react = "^19.2.0";
|
|
225
|
+
dependencies["react-dom"] = "^19.2.0";
|
|
226
|
+
devDependencies["@types/react"] = "^19.2.0";
|
|
208
227
|
}
|
|
228
|
+
if (modes.admin) dependencies["@alepha/ui"] = `^${version}`;
|
|
209
229
|
return {
|
|
210
230
|
type: "module",
|
|
211
231
|
dependencies,
|
|
212
232
|
devDependencies,
|
|
213
233
|
scripts: {
|
|
214
234
|
dev: "alepha dev",
|
|
215
|
-
build: "alepha build"
|
|
235
|
+
build: "alepha build",
|
|
236
|
+
verify: "alepha verify"
|
|
216
237
|
}
|
|
217
238
|
};
|
|
218
239
|
}
|
|
@@ -378,17 +399,6 @@ var ProjectUtils = class {
|
|
|
378
399
|
throw new AlephaError(`Could not find Alepha instance in entry file: ${entry}`);
|
|
379
400
|
}
|
|
380
401
|
/**
|
|
381
|
-
* Get DrizzleKitProvider from an Alepha instance.
|
|
382
|
-
*
|
|
383
|
-
* Searches the Alepha registry for the DrizzleKitProvider instance.
|
|
384
|
-
*
|
|
385
|
-
* @param alepha - The Alepha instance to search
|
|
386
|
-
* @returns The DrizzleKitProvider instance
|
|
387
|
-
*/
|
|
388
|
-
getKitFromAlepha(alepha) {
|
|
389
|
-
return alepha["registry"].values().find((it) => it.instance.constructor.name === "DrizzleKitProvider")?.instance;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
402
|
* Generate JavaScript code for Drizzle entities export.
|
|
393
403
|
*
|
|
394
404
|
* Creates a temporary entities.js file that imports from the entry file
|
|
@@ -447,7 +457,7 @@ ${models.map((it) => `export const ${it} = models["${it}"];`).join("\n")}
|
|
|
447
457
|
const rootDir = options.root;
|
|
448
458
|
this.log.debug(`Using project root: ${rootDir}`);
|
|
449
459
|
const { alepha, entry } = await this.loadAlephaFromServerEntryFile(rootDir, options.args);
|
|
450
|
-
const
|
|
460
|
+
const drizzleKitProvider = alepha.inject("DrizzleKitProvider");
|
|
451
461
|
const repositoryProvider = alepha.inject("RepositoryProvider");
|
|
452
462
|
const accepted = /* @__PURE__ */ new Set([]);
|
|
453
463
|
for (const descriptor of repositoryProvider.getRepositories()) {
|
|
@@ -463,7 +473,7 @@ ${models.map((it) => `export const ${it} = models["${it}"];`).join("\n")}
|
|
|
463
473
|
this.log.info("");
|
|
464
474
|
this.log.info(options.logMessage(providerName, dialect));
|
|
465
475
|
const drizzleConfigJsPath = await this.prepareDrizzleConfig({
|
|
466
|
-
kit,
|
|
476
|
+
kit: drizzleKitProvider,
|
|
467
477
|
provider,
|
|
468
478
|
providerName,
|
|
469
479
|
providerUrl: provider.url,
|
|
@@ -482,8 +492,16 @@ ${models.map((it) => `export const ${it} = models["${it}"];`).join("\n")}
|
|
|
482
492
|
}
|
|
483
493
|
async ensureIndexHtml(root) {
|
|
484
494
|
if (await this.fs.exists(join(root, "index.html"))) return;
|
|
485
|
-
const
|
|
486
|
-
|
|
495
|
+
const serverEntry = "src/main.server.ts";
|
|
496
|
+
const browserEntry = "src/main.browser.ts";
|
|
497
|
+
const appRouter = "src/AppRouter.ts";
|
|
498
|
+
await this.fs.writeFile(join(root, "index.html"), indexHtml(browserEntry));
|
|
499
|
+
try {
|
|
500
|
+
await this.fs.mkdir(join(root, "src"), { recursive: true });
|
|
501
|
+
} catch {}
|
|
502
|
+
if (!await this.fs.exists(join(root, browserEntry))) await this.fs.writeFile(join(root, browserEntry), mainBrowserTs());
|
|
503
|
+
if (!await this.fs.exists(join(root, serverEntry))) await this.fs.writeFile(join(root, serverEntry), mainBrowserTs());
|
|
504
|
+
if (!await this.fs.exists(join(root, appRouter))) await this.fs.writeFile(join(root, appRouter), appRouterTs());
|
|
487
505
|
}
|
|
488
506
|
async hasDir(root, dirName) {
|
|
489
507
|
return this.fs.exists(join(root, dirName));
|
|
@@ -560,9 +578,9 @@ var CoreCommands = class {
|
|
|
560
578
|
description: "Add missing Alepha configuration files to the project",
|
|
561
579
|
flags: t.object({
|
|
562
580
|
yarn: t.optional(t.boolean({ description: "Use Yarn package manager" })),
|
|
563
|
-
|
|
581
|
+
pnpm: t.optional(t.boolean({ description: "Use pnpm package manager" })),
|
|
564
582
|
react: t.optional(t.boolean({ description: "Include Alepha React dependencies" })),
|
|
565
|
-
|
|
583
|
+
admin: t.optional(t.boolean({ description: "Include Alepha admin panel dependencies" }))
|
|
566
584
|
}),
|
|
567
585
|
handler: async ({ run, flags, root }) => {
|
|
568
586
|
await run({
|
|
@@ -571,6 +589,8 @@ var CoreCommands = class {
|
|
|
571
589
|
await this.utils.ensureConfig(root, {
|
|
572
590
|
tsconfigJson: true,
|
|
573
591
|
packageJson: flags,
|
|
592
|
+
biomeJson: true,
|
|
593
|
+
viteConfigTs: true,
|
|
574
594
|
indexHtml: !!flags.react
|
|
575
595
|
});
|
|
576
596
|
}
|
|
@@ -578,6 +598,7 @@ var CoreCommands = class {
|
|
|
578
598
|
const guessedPm = await this.utils.getPackageManager(root);
|
|
579
599
|
if (flags.yarn || guessedPm === "yarn") {
|
|
580
600
|
await this.utils.ensureYarn(root);
|
|
601
|
+
await run("yarn set version stable");
|
|
581
602
|
await run("yarn install", { alias: "Installing dependencies with Yarn" });
|
|
582
603
|
} else await run("npm install", { alias: "Installing dependencies with npm" });
|
|
583
604
|
}
|
|
@@ -595,54 +616,61 @@ var DrizzleCommands = class {
|
|
|
595
616
|
* Check if database migrations are up to date.
|
|
596
617
|
*/
|
|
597
618
|
check = $command({
|
|
598
|
-
name: "db:
|
|
619
|
+
name: "db:check-migrations",
|
|
599
620
|
description: "Check if database migration files are up to date",
|
|
600
621
|
args: t.optional(t.text({
|
|
601
622
|
title: "path",
|
|
602
623
|
description: "Path to the Alepha server entry file"
|
|
603
624
|
})),
|
|
604
625
|
flags: drizzleCommandFlags,
|
|
605
|
-
handler: async ({ args,
|
|
626
|
+
handler: async ({ args, root }) => {
|
|
606
627
|
const rootDir = root;
|
|
607
628
|
this.log.debug(`Using project root: ${rootDir}`);
|
|
608
629
|
const { alepha } = await this.utils.loadAlephaFromServerEntryFile(rootDir, args);
|
|
609
|
-
const
|
|
610
|
-
const
|
|
611
|
-
const
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
630
|
+
const repositoryProvider = alepha.inject("RepositoryProvider");
|
|
631
|
+
const drizzleKitProvider = alepha.inject("DrizzleKitProvider");
|
|
632
|
+
const accepted = /* @__PURE__ */ new Set([]);
|
|
633
|
+
for (const descriptor of repositoryProvider.getRepositories()) {
|
|
634
|
+
const provider = descriptor.provider;
|
|
635
|
+
const providerName = provider.name;
|
|
636
|
+
if (accepted.has(providerName)) continue;
|
|
637
|
+
accepted.add(providerName);
|
|
638
|
+
const migrationDir = join(rootDir, "migrations", providerName);
|
|
639
|
+
const journalFile = await readFile(`${migrationDir}/meta/_journal.json`, "utf-8").catch(() => null);
|
|
640
|
+
if (!journalFile) {
|
|
641
|
+
this.log.info(`No migration journal found.`);
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
const journal = JSON.parse(journalFile);
|
|
645
|
+
const lastMigration = journal.entries[journal.entries.length - 1];
|
|
646
|
+
const lastSnapshot = JSON.parse(await readFile(`${migrationDir}/meta/${String(lastMigration.idx).padStart(4, "0")}_snapshot.json`, "utf-8"));
|
|
647
|
+
const models = drizzleKitProvider.getModels(provider);
|
|
648
|
+
const kit = drizzleKitProvider.importDrizzleKit();
|
|
649
|
+
const now = kit.generateDrizzleJson(models, lastSnapshot.id);
|
|
650
|
+
const migrationStatements = await new Promise((resolve) => {
|
|
651
|
+
(async () => {
|
|
652
|
+
const timer = setTimeout(() => {
|
|
653
|
+
resolve([{ message: "Migration generation timed out." }]);
|
|
654
|
+
}, 5e3);
|
|
655
|
+
const statements = await kit.generateMigration(lastSnapshot, now);
|
|
656
|
+
clearTimeout(timer);
|
|
657
|
+
resolve(statements);
|
|
658
|
+
})();
|
|
659
|
+
});
|
|
660
|
+
if (migrationStatements.length === 0) {
|
|
661
|
+
this.log.info("No changes detected.");
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
this.log.info("");
|
|
665
|
+
this.log.info("Detected migration statements:");
|
|
666
|
+
this.log.info("");
|
|
667
|
+
for (const stmt of migrationStatements) this.log.info(stmt);
|
|
668
|
+
this.log.info("");
|
|
669
|
+
this.log.info(`At least ${migrationStatements.length} change(s) detected.`);
|
|
670
|
+
this.log.info("Please, run 'alepha db:generate' to update the migration files.");
|
|
671
|
+
this.log.info("");
|
|
672
|
+
throw new AlephaError("Database migrations are not up to date.");
|
|
636
673
|
}
|
|
637
|
-
this.log.info("");
|
|
638
|
-
this.log.info("Detected migration statements:");
|
|
639
|
-
this.log.info("");
|
|
640
|
-
for (const stmt of migrationStatements) this.log.info(stmt);
|
|
641
|
-
this.log.info("");
|
|
642
|
-
this.log.info(`At least ${migrationStatements.length} change(s) detected.`);
|
|
643
|
-
this.log.info("Please, run 'alepha db:generate' to update the migration files.");
|
|
644
|
-
this.log.info("");
|
|
645
|
-
throw new AlephaError("Database migrations are not up to date.");
|
|
646
674
|
}
|
|
647
675
|
});
|
|
648
676
|
/**
|
|
@@ -842,7 +870,7 @@ var VerifyCommands = class {
|
|
|
842
870
|
await run("alepha lint");
|
|
843
871
|
await run("alepha typecheck");
|
|
844
872
|
if ((await this.utils.readPackageJson(root)).devDependencies?.vitest) await run("alepha test");
|
|
845
|
-
if (await this.utils.hasDir(root, "migrations")) await run("alepha db:
|
|
873
|
+
if (await this.utils.hasDir(root, "migrations")) await run("alepha db:check-migrations");
|
|
846
874
|
await run("alepha build");
|
|
847
875
|
await run("alepha clean");
|
|
848
876
|
}
|
|
@@ -1036,7 +1064,7 @@ var ViteCommands = class {
|
|
|
1036
1064
|
viteConfigTs: true
|
|
1037
1065
|
});
|
|
1038
1066
|
try {
|
|
1039
|
-
await import("./dist-
|
|
1067
|
+
await import("./dist-Dl9Vl7Ur.js");
|
|
1040
1068
|
} catch {
|
|
1041
1069
|
this.log.error("Vitest is not installed. Please install it with `npm install -D vitest` or `yarn add -D vitest`.");
|
|
1042
1070
|
process.exit(1);
|
|
@@ -1094,7 +1122,11 @@ var AlephaPackageBuilderCli = class {
|
|
|
1094
1122
|
const tmpDir = join(root, "node_modules/.alepha");
|
|
1095
1123
|
await this.fs.mkdir(tmpDir, { recursive: true }).catch(() => {});
|
|
1096
1124
|
await this.fs.writeFile(join(tmpDir, "module-dependencies.json"), JSON.stringify(modules, null, 2));
|
|
1097
|
-
const external = [
|
|
1125
|
+
const external = [
|
|
1126
|
+
"alepha",
|
|
1127
|
+
packageName,
|
|
1128
|
+
...modules.map((item) => `${packageName}/${item.name}`)
|
|
1129
|
+
];
|
|
1098
1130
|
await run.rm(this.dist);
|
|
1099
1131
|
const build = async (item) => {
|
|
1100
1132
|
const entries = [];
|
|
@@ -1103,7 +1135,7 @@ var AlephaPackageBuilderCli = class {
|
|
|
1103
1135
|
entries.push({
|
|
1104
1136
|
entry: join(src, "index.ts"),
|
|
1105
1137
|
outDir: dest,
|
|
1106
|
-
format: ["esm"
|
|
1138
|
+
format: ["esm"],
|
|
1107
1139
|
sourcemap: true,
|
|
1108
1140
|
fixedExtension: false,
|
|
1109
1141
|
platform: "node",
|