create-warlock 4.1.7 → 4.1.9

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.
@@ -2,7 +2,7 @@ import { colors } from "@mongez/copper";
2
2
  import { directoryExists } from "@warlock.js/fs";
3
3
  import * as path$1 from "path";
4
4
 
5
- //#region ../../@warlock.js/create-warlock/src/commands/create-new-app/get-app-path.ts
5
+ //#region ../@warlock.js/create-warlock/src/commands/create-new-app/get-app-path.ts
6
6
  function getAppPath(appName) {
7
7
  const appPath = path$1.resolve(process.cwd(), appName);
8
8
  if (directoryExists(appPath)) {
@@ -10,7 +10,7 @@ import { cancel, confirm, isCancel, multiselect, select, text } from "@clack/pro
10
10
  import { colors } from "@mongez/copper";
11
11
  import { getJsonFile } from "@warlock.js/fs";
12
12
 
13
- //#region ../../@warlock.js/create-warlock/src/commands/create-new-app/index.ts
13
+ //#region ../@warlock.js/create-warlock/src/commands/create-new-app/index.ts
14
14
  async function createNewApp(cli = {}) {
15
15
  const pmDetectionPromise = detectPackageManagers();
16
16
  const createWarlockVersion = getJsonFile(packageRoot("package.json")).version;
@@ -1,4 +1,4 @@
1
- //#region ../../@warlock.js/create-warlock/src/commands/create-new-app/types.d.ts
1
+ //#region ../@warlock.js/create-warlock/src/commands/create-new-app/types.d.ts
2
2
  /**
3
3
  * Flags parsed from the command line for non-interactive scaffolding
4
4
  * (`create-warlock my-app --db=postgres --features=test,herald --ai=openai --yes`).
@@ -3,7 +3,7 @@ import { showSuccessScreen } from "../../ui/banner.mjs";
3
3
  import { spinnerMessages } from "../../ui/spinners.mjs";
4
4
  import { spinner } from "@clack/prompts";
5
5
 
6
- //#region ../../@warlock.js/create-warlock/src/commands/create-warlock-app/index.ts
6
+ //#region ../@warlock.js/create-warlock/src/commands/create-warlock-app/index.ts
7
7
  async function createWarlockApp(application) {
8
8
  const { useGit, useJWT, features, aiProviders, databaseDriver } = application.options;
9
9
  const templateSpinner = spinner();
@@ -1,4 +1,4 @@
1
- //#region ../../@warlock.js/create-warlock/src/features/database-drivers.ts
1
+ //#region ../@warlock.js/create-warlock/src/features/database-drivers.ts
2
2
  const databaseDrivers = [
3
3
  {
4
4
  value: "mongodb",
@@ -1,4 +1,4 @@
1
- //#region ../../@warlock.js/create-warlock/src/features/features-map.ts
1
+ //#region ../@warlock.js/create-warlock/src/features/features-map.ts
2
2
  /**
3
3
  * Optional features offered in the general multiselect step. The database
4
4
  * driver (its own select) and AI providers (their own step) are intentionally
@@ -5,7 +5,7 @@ import { packageRoot, template } from "./paths.mjs";
5
5
  import { copyDirectory, copyFile, fileExists, getFile, getJsonFile, putFile, putJsonFile, renameFile } from "@warlock.js/fs";
6
6
  import path from "path";
7
7
 
8
- //#region ../../@warlock.js/create-warlock/src/helpers/app.ts
8
+ //#region ../@warlock.js/create-warlock/src/helpers/app.ts
9
9
  var App = class {
10
10
  constructor(app) {
11
11
  this.app = app;
@@ -2,7 +2,7 @@ import { log } from "@clack/prompts";
2
2
  import { colors } from "@mongez/copper";
3
3
  import childProcess from "cross-spawn";
4
4
 
5
- //#region ../../@warlock.js/create-warlock/src/helpers/exec.ts
5
+ //#region ../@warlock.js/create-warlock/src/helpers/exec.ts
6
6
  /**
7
7
  * This function directly executes a command
8
8
  */
@@ -2,7 +2,7 @@ import { exec, execSync } from "child_process";
2
2
  import { promisify } from "util";
3
3
  import detectPackageManager from "which-pm-runs";
4
4
 
5
- //#region ../../@warlock.js/create-warlock/src/helpers/package-manager.ts
5
+ //#region ../@warlock.js/create-warlock/src/helpers/package-manager.ts
6
6
  const execAsync = promisify(exec);
7
7
  let detectedPackageManager;
8
8
  let cachedSystemManagers;
@@ -1,7 +1,7 @@
1
1
  import path from "path";
2
2
  import { fileURLToPath } from "url";
3
3
 
4
- //#region ../../@warlock.js/create-warlock/src/helpers/paths.ts
4
+ //#region ../@warlock.js/create-warlock/src/helpers/paths.ts
5
5
  const __filename = fileURLToPath(import.meta.url);
6
6
  const __dirname = path.dirname(__filename);
7
7
  function template(templateName) {
@@ -6,7 +6,7 @@ import { colors } from "@mongez/copper";
6
6
  import { copyDirectory, getFile, getJsonFile, putFile, putJsonFile, renameFile } from "@warlock.js/fs";
7
7
  import path from "path";
8
8
 
9
- //#region ../../@warlock.js/create-warlock/src/helpers/project-builder-helpers.ts
9
+ //#region ../@warlock.js/create-warlock/src/helpers/project-builder-helpers.ts
10
10
  async function initializeGitRepository(appPath) {
11
11
  await executeCommand(`git`, ["init"], appPath);
12
12
  await executeCommand(`git`, [
package/esm/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CliFlags } from "./commands/create-new-app/types.mjs";
2
2
 
3
- //#region ../../@warlock.js/create-warlock/src/index.d.ts
3
+ //#region ../@warlock.js/create-warlock/src/index.d.ts
4
4
  /**
5
5
  * Parse the scaffolder's own CLI flags for non-interactive mode.
6
6
  *
package/esm/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import createNewApp from "./commands/create-new-app/index.mjs";
2
2
 
3
- //#region ../../@warlock.js/create-warlock/src/index.ts
3
+ //#region ../@warlock.js/create-warlock/src/index.ts
4
4
  const valueFlags = [
5
5
  "name",
6
6
  "db",
package/esm/ui/banner.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { colors } from "@mongez/copper";
2
2
 
3
- //#region ../../@warlock.js/create-warlock/src/ui/banner.ts
3
+ //#region ../@warlock.js/create-warlock/src/ui/banner.ts
4
4
  const warlockTextAnsi = `
5
5
  \x1b[49m
6
6
  \x1b[49m \x1b[38;2;252;238;36m██╗ ██╗ █████╗ ██████╗ ██╗ ██████╗ ██████╗██╗ ██╗ \x1b[38;2;252;238;36m ██╗ ███████╗\x1b[m
@@ -1,4 +1,4 @@
1
- //#region ../../@warlock.js/create-warlock/src/ui/spinners.ts
1
+ //#region ../@warlock.js/create-warlock/src/ui/spinners.ts
2
2
  /**
3
3
  * Themed spinner messages for the wizard
4
4
  */
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "dependencies": {
10
10
  "@clack/prompts": "^0.7.0",
11
11
  "@mongez/copper": "^2.1.2",
12
- "@warlock.js/fs": "4.1.7",
12
+ "@warlock.js/fs": "*",
13
13
  "@mongez/reinforcements": "^3.2.0",
14
14
  "cross-spawn": "^7.0.3",
15
15
  "rimraf": "^6.0.1",
@@ -18,7 +18,7 @@
18
18
  "bin": {
19
19
  "create-warlock": "bin/create-app.js"
20
20
  },
21
- "version": "4.1.7",
21
+ "version": "4.1.9",
22
22
  "type": "module",
23
23
  "main": "./esm/index.mjs",
24
24
  "module": "./esm/index.mjs",
@@ -59,7 +59,8 @@
59
59
  "prettier": "^3.7.4",
60
60
  "prettier-plugin-organize-imports": "^4.3.0",
61
61
  "typescript": "^5.9.3",
62
- "husky": "^8.0.0"
62
+ "husky": "^8.0.0",
63
+ "vitest": "^4.0.6"
63
64
  },
64
65
  "huskier": {
65
66
  "hooks": {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  t,
3
- v,
4
3
  type Request,
5
4
  type RequestHandler,
6
5
  type Response,
7
6
  } from "@warlock.js/core";
7
+ import { v } from "@warlock.js/seal";
8
8
  import { forgotPasswordService } from "../services/forgot-password.service";
9
9
 
10
10
  /**
@@ -1,9 +1,9 @@
1
1
  import {
2
- v,
3
2
  type Request,
4
3
  type RequestHandler,
5
4
  type Response,
6
5
  } from "@warlock.js/core";
6
+ import { v } from "@warlock.js/seal";
7
7
  import { refreshTokensService } from "../services/auth.service";
8
8
 
9
9
  /**
@@ -34,7 +34,7 @@ export class OTP extends Model<OTPSchema> {
34
34
  */
35
35
  public get isValid(): boolean {
36
36
  if (this.get("usedAt")) return false;
37
- if (this.get("attempts") >= this.get("maxAttempts")) return false;
37
+ if ((this.get("attempts") ?? 0) >= (this.get("maxAttempts") ?? 0)) return false;
38
38
  if (new Date() > new Date(this.get("expiresAt"))) return false;
39
39
  return true;
40
40
  }
@@ -50,7 +50,7 @@ export class OTP extends Model<OTPSchema> {
50
50
  * Check if max attempts exceeded
51
51
  */
52
52
  public get isMaxAttemptsExceeded(): boolean {
53
- return this.get("attempts") >= this.get("maxAttempts");
53
+ return (this.get("attempts") ?? 0) >= (this.get("maxAttempts") ?? 0);
54
54
  }
55
55
 
56
56
  /**
@@ -64,6 +64,6 @@ export class OTP extends Model<OTPSchema> {
64
64
  * Increment failed attempt
65
65
  */
66
66
  public async incrementAttempt(): Promise<this> {
67
- return this.set("attempts", this.get("attempts") + 1).save();
67
+ return this.set("attempts", (this.get("attempts") ?? 0) + 1).save();
68
68
  }
69
69
  }
@@ -1,4 +1,4 @@
1
- import { v, type Infer } from "@warlock.js/core";
1
+ import { v, type Infer } from "@warlock.js/seal";
2
2
 
3
3
  export const loginSchema = v.object({
4
4
  email: v.email().required(),
@@ -1,4 +1,4 @@
1
- import { v, type Infer } from "@warlock.js/core";
1
+ import { v, type Infer } from "@warlock.js/seal";
2
2
 
3
3
  export const resetPasswordSchema = v.object({
4
4
  email: v.string().email().required(),
@@ -1,9 +1,18 @@
1
- import type { Duration } from "@warlock.js/auth";
2
1
  import { ForbiddenError, t } from "@warlock.js/core";
3
2
  import { OTP } from "../models/otp";
4
3
  import { AuthErrorCode } from "../utils/auth-error-code";
5
4
  import type { OTPChannel, OTPType } from "../utils/types";
6
5
 
6
+ /** Human-friendly duration parts, summed to milliseconds by `parseDurationToMs`. */
7
+ type Duration = {
8
+ milliseconds?: number;
9
+ seconds?: number;
10
+ minutes?: number;
11
+ hours?: number;
12
+ days?: number;
13
+ weeks?: number;
14
+ };
15
+
7
16
  // Default OTP expiration
8
17
  const DEFAULT_OTP_EXPIRATION: Duration = { minutes: 15 };
9
18
 
@@ -6,7 +6,13 @@ export const updatePostController: GuardedRequestHandler<UpdatePostSchema> = asy
6
6
  request,
7
7
  response,
8
8
  ) => {
9
- const post = await Post.find(request.int("id"));
9
+ const id = request.int("id");
10
+
11
+ if (!id) {
12
+ return response.notFound();
13
+ }
14
+
15
+ const post = await Post.find(id);
10
16
 
11
17
  if (!post) {
12
18
  return response.notFound();
@@ -1,6 +1,7 @@
1
1
  import { fileExistsAsync } from "@warlock.js/fs";
2
2
  import { CACHE_FOR } from "@warlock.js/cache";
3
- import { Image, type RequestHandler, storage, v } from "@warlock.js/core";
3
+ import { Image, type RequestHandler, storage } from "@warlock.js/core";
4
+ import { v } from "@warlock.js/seal";
4
5
 
5
6
  export const fetchUploadedFileController: RequestHandler = async (
6
7
  request,
@@ -4,7 +4,7 @@
4
4
  "lib": ["esnext", "dom"],
5
5
  "allowJs": false,
6
6
  "skipLibCheck": true,
7
- "experimentalDecorators": true,
7
+ "experimentalDecorators": false,
8
8
  "esModuleInterop": true,
9
9
  "allowSyntheticDefaultImports": true,
10
10
  "downlevelIteration": true,