@warlock.js/core 4.0.132 → 4.0.133

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.
@@ -0,0 +1,2 @@
1
+ export declare const createDatabaseCommand: import("../cli-command").CLICommand;
2
+ //# sourceMappingURL=create-database.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-database.command.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/create-database.command.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,qCAiBhC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import {createDatabaseAction}from'../../database/create-database-action.js';import {command}from'../cli-command.js';const createDatabaseCommand = command({
2
+ name: "create-database <name>",
3
+ alias: "cdb",
4
+ description: "Create a new database",
5
+ action: createDatabaseAction,
6
+ preload: {
7
+ config: ["database", "log"],
8
+ env: true,
9
+ connectors: ["database"],
10
+ },
11
+ options: [
12
+ {
13
+ text: "--connection, -c",
14
+ description: "Database connection name",
15
+ defaultValue: "default",
16
+ },
17
+ ],
18
+ });export{createDatabaseCommand};//# sourceMappingURL=create-database.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-database.command.js","sources":["../../../src/cli/commands/create-database.command.ts"],"sourcesContent":[null],"names":[],"mappings":"oHAGO,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAC3C,IAAA,IAAI,EAAE,wBAAwB;AAC9B,IAAA,KAAK,EAAE,KAAK;AACZ,IAAA,WAAW,EAAE,uBAAuB;AACpC,IAAA,MAAM,EAAE,oBAAoB;AAC5B,IAAA,OAAO,EAAE;AACP,QAAA,MAAM,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC;AAC3B,QAAA,GAAG,EAAE,IAAI;QACT,UAAU,EAAE,CAAC,UAAU,CAAC;AACzB,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA;AACE,YAAA,IAAI,EAAE,kBAAkB;AACxB,YAAA,WAAW,EAAE,0BAA0B;AACvC,YAAA,YAAY,EAAE,SAAS;AACxB,SAAA;AACF,KAAA;AACF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"framework-cli-commands.d.ts","sourceRoot":"","sources":["../../src/cli/framework-cli-commands.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,iBAAiB,sCAuB7B,CAAC"}
1
+ {"version":3,"file":"framework-cli-commands.d.ts","sourceRoot":"","sources":["../../src/cli/framework-cli-commands.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,iBAAiB,sCAwB7B,CAAC"}
@@ -1,4 +1,4 @@
1
- import {addCommand}from'./commands/add.command.js';import {buildCommand}from'./commands/build.command.js';import {devServerCommand}from'./commands/dev-server.command.js';import {generateCommand,generateModuleCommand,generateControllerCommand,generateServiceCommand,generateModelCommand,generateRepositoryCommand,generateResourceCommand,generateValidationCommand,generateMigrationCommand}from'./commands/generate/generate.command.js';import {migrateCommand}from'./commands/migrate.command.js';import {seedCommand}from'./commands/seed.command.js';import {startProductionCommand}from'./commands/start-production.command.js';import {typingsGeneratorCommand}from'./commands/typings-generator.command.js';const frameworkCommands = [
1
+ import {addCommand}from'./commands/add.command.js';import {buildCommand}from'./commands/build.command.js';import {devServerCommand}from'./commands/dev-server.command.js';import {generateCommand,generateModuleCommand,generateControllerCommand,generateServiceCommand,generateModelCommand,generateRepositoryCommand,generateResourceCommand,generateValidationCommand,generateMigrationCommand}from'./commands/generate/generate.command.js';import {migrateCommand}from'./commands/migrate.command.js';import {seedCommand}from'./commands/seed.command.js';import {createDatabaseCommand}from'./commands/create-database.command.js';import {startProductionCommand}from'./commands/start-production.command.js';import {typingsGeneratorCommand}from'./commands/typings-generator.command.js';const frameworkCommands = [
2
2
  devServerCommand,
3
3
  buildCommand,
4
4
  startProductionCommand,
@@ -6,6 +6,7 @@ import {addCommand}from'./commands/add.command.js';import {buildCommand}from'./c
6
6
  // database commands
7
7
  migrateCommand,
8
8
  seedCommand,
9
+ createDatabaseCommand,
9
10
  // generation/installation commands
10
11
  addCommand,
11
12
  // scaffolding commands
@@ -1 +1 @@
1
- {"version":3,"file":"framework-cli-commands.js","sources":["../../src/cli/framework-cli-commands.ts"],"sourcesContent":[null],"names":[],"mappings":"2rBAmBa,MAAA,iBAAiB,GAAG;IAC/B,gBAAgB;IAChB,YAAY;IACZ,sBAAsB;IACtB,uBAAuB;;IAGvB,cAAc;IACd,WAAW;;IAGX,UAAU;;IAGV,eAAe;IACf,qBAAqB;IACrB,yBAAyB;IACzB,sBAAsB;IACtB,oBAAoB;IACpB,yBAAyB;IACzB,uBAAuB;IACvB,yBAAyB;IACzB,wBAAwB;"}
1
+ {"version":3,"file":"framework-cli-commands.js","sources":["../../src/cli/framework-cli-commands.ts"],"sourcesContent":[null],"names":[],"mappings":"qwBAqBa,MAAA,iBAAiB,GAAG;IAC/B,gBAAgB;IAChB,YAAY;IACZ,sBAAsB;IACtB,uBAAuB;;IAGvB,cAAc;IACd,WAAW;IACX,qBAAqB;;IAGrB,UAAU;;IAGV,eAAe;IACf,qBAAqB;IACrB,yBAAyB;IACzB,sBAAsB;IACtB,oBAAoB;IACpB,yBAAyB;IACzB,uBAAuB;IACvB,yBAAyB;IACzB,wBAAwB;"}
@@ -0,0 +1,3 @@
1
+ import { CommandActionData } from "../cli/types";
2
+ export declare function createDatabaseAction(command: CommandActionData): Promise<void>;
3
+ //# sourceMappingURL=create-database-action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-database-action.d.ts","sourceRoot":"","sources":["../../src/database/create-database-action.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,iBA8CpE"}
@@ -0,0 +1,28 @@
1
+ import {colors}from'@mongez/copper';import {dataSourceRegistry}from'@warlock.js/cascade';import {log}from'@warlock.js/logger';import {config}from'../config/config-getter.js';import'../config/config-handlers.js';async function createDatabaseAction(command) {
2
+ const name = command.args[0];
3
+ const { connection = "default" } = command.options;
4
+ const dataSource = dataSourceRegistry.get(connection === "default" || connection === true ? undefined : String(connection));
5
+ let databaseName = name;
6
+ if (!databaseName) {
7
+ if (connection === "default") {
8
+ databaseName = config.get("database")?.database;
9
+ }
10
+ }
11
+ if (!databaseName) {
12
+ log.error("database", "create", "Database name is required. Please provide a name or configure it in the database config.");
13
+ return;
14
+ }
15
+ log.info("database", "create", `Creating database ${colors.cyan(databaseName)}...`);
16
+ try {
17
+ const created = await dataSource.driver.createDatabase(databaseName);
18
+ if (created) {
19
+ log.success("database", "create", `Database ${colors.green(databaseName)} created successfully.`);
20
+ }
21
+ else {
22
+ log.warn("database", "create", `Database ${colors.yellow(databaseName)} already exists.`);
23
+ }
24
+ }
25
+ catch (error) {
26
+ log.error("database", "create", `Failed to create database ${colors.red(databaseName)}: ${error.message}`);
27
+ }
28
+ }export{createDatabaseAction};//# sourceMappingURL=create-database-action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-database-action.js","sources":["../../src/database/create-database-action.ts"],"sourcesContent":[null],"names":[],"mappings":"mNAMO,eAAe,oBAAoB,CAAC,OAA0B,EAAA;IACnE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,EAAE,UAAU,GAAG,SAAS,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAEnD,MAAM,UAAU,GAAG,kBAAkB,CAAC,GAAG,CACvC,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,CACjF,CAAC;IAEF,IAAI,YAAY,GAAG,IAAI,CAAC;IAExB,IAAI,CAAC,YAAY,EAAE;QACjB,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC;AACjD,SAAA;AACF,KAAA;IAED,IAAI,CAAC,YAAY,EAAE;QACjB,GAAG,CAAC,KAAK,CACP,UAAU,EACV,QAAQ,EACR,0FAA0F,CAC3F,CAAC;QACF,OAAO;AACR,KAAA;AAED,IAAA,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAA,kBAAA,EAAqB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA,GAAA,CAAK,CAAC,CAAC;IAEpF,IAAI;QACF,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;AAErE,QAAA,IAAI,OAAO,EAAE;AACX,YAAA,GAAG,CAAC,OAAO,CACT,UAAU,EACV,QAAQ,EACR,CAAA,SAAA,EAAY,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA,sBAAA,CAAwB,CAC/D,CAAC;AACH,SAAA;AAAM,aAAA;AACL,YAAA,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAA,SAAA,EAAY,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA,gBAAA,CAAkB,CAAC,CAAC;AAC3F,SAAA;AACF,KAAA;AAAC,IAAA,OAAO,KAAU,EAAE;QACnB,GAAG,CAAC,KAAK,CACP,UAAU,EACV,QAAQ,EACR,6BAA6B,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAK,EAAA,EAAA,KAAK,CAAC,OAAO,CAAA,CAAE,CAC1E,CAAC;AACH,KAAA;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warlock.js/core",
3
- "version": "4.0.132",
3
+ "version": "4.0.133",
4
4
  "description": "A robust nodejs framework for building blazing fast applications",
5
5
  "main": "./esm/index.js",
6
6
  "bin": {
@@ -27,12 +27,12 @@
27
27
  "@mongez/slug": "^1.0.7",
28
28
  "@mongez/supportive-is": "^2.0.4",
29
29
  "@mongez/time-wizard": "^1.0.6",
30
- "@warlock.js/auth": "4.0.132",
31
- "@warlock.js/cache": "4.0.132",
32
- "@warlock.js/cascade": "4.0.132",
33
- "@warlock.js/context": "4.0.132",
34
- "@warlock.js/logger": "4.0.132",
35
- "@warlock.js/seal": "4.0.132",
30
+ "@warlock.js/auth": "4.0.133",
31
+ "@warlock.js/cache": "4.0.133",
32
+ "@warlock.js/cascade": "4.0.133",
33
+ "@warlock.js/context": "4.0.133",
34
+ "@warlock.js/logger": "4.0.133",
35
+ "@warlock.js/seal": "4.0.133",
36
36
  "axios": "^1.7.9",
37
37
  "chokidar": "^5.0.0",
38
38
  "dayjs": "^1.11.19",