@h3ravel/arquebus 3.0.0 → 3.0.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/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  Arquebus ORM is a Beautiful, expressive framework-agnostic Object-Relational Mapper (ORM) inspired by Laravel's Eloquent, designed for TypeScript applications and for the H3ravel Framework that makes it enjoyable to interact with your database. When using Arquebus, each database table has a corresponding "Model" that is used to interact with that table. In addition to retrieving records from the database table, Arquebus models allow you to insert, update, and delete records from the database as well.
16
16
 
17
- > Arquebus is a Typescript and Modern JS rewrite of [Sutando](https://sutando.org/) and is heavily inspired by Laravel's ORM [Eloquent](https://laravel.com/docs/12.x/eloquent).
17
+ > Arquebus is heavily inspired by Laravel's [Eloquent ORM](https://laravel.com/docs/12.x/eloquent).
18
18
 
19
19
  ## ✨ Features
20
20
 
package/bin/index.cjs CHANGED
@@ -30,17 +30,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  enumerable: true
31
31
  }) : target, mod));
32
32
  //#endregion
33
- let _h3ravel_shared = require("@h3ravel/shared");
34
33
  let _h3ravel_musket = require("@h3ravel/musket");
35
- let _h3ravel_support = require("@h3ravel/support");
36
- let node_fs_promises = require("node:fs/promises");
37
- node_fs_promises = __toESM(node_fs_promises, 1);
34
+ let _h3ravel_shared = require("@h3ravel/shared");
38
35
  let path = require("path");
39
36
  path = __toESM(path, 1);
37
+ let resolve_from = require("resolve-from");
38
+ resolve_from = __toESM(resolve_from, 1);
39
+ let node_fs_promises = require("node:fs/promises");
40
+ node_fs_promises = __toESM(node_fs_promises, 1);
40
41
  let node_path = require("node:path");
41
42
  node_path = __toESM(node_path, 1);
42
43
  let node_fs = require("node:fs");
43
44
  let node_url = require("node:url");
45
+ let _h3ravel_support = require("@h3ravel/support");
44
46
  let dayjs = require("dayjs");
45
47
  dayjs = __toESM(dayjs, 1);
46
48
  let dayjs_plugin_advancedFormat_js = require("dayjs/plugin/advancedFormat.js");
@@ -51,9 +53,41 @@ knex = __toESM(knex, 1);
51
53
  let fs = require("fs");
52
54
  let pluralize = require("pluralize");
53
55
  pluralize = __toESM(pluralize, 1);
54
- let resolve_from = require("resolve-from");
55
- resolve_from = __toESM(resolve_from, 1);
56
56
  let dotenv = require("dotenv");
57
+ //#region src/cli/utils.ts
58
+ const join = path.default.join;
59
+ var Utils = class {
60
+ static findModulePkg(moduleId, cwd) {
61
+ const parts = moduleId.replace(/\\/g, "/").split("/");
62
+ let packageName = "";
63
+ if (parts.length > 0 && parts[0][0] === "@") packageName += parts.shift() + "/";
64
+ packageName += parts.shift();
65
+ const packageJson = path.default.join(packageName, "package.json");
66
+ const resolved = resolve_from.default.silent(cwd ?? process.cwd(), packageJson);
67
+ if (!resolved) return;
68
+ return path.default.join(path.default.dirname(resolved), parts.join("/"));
69
+ }
70
+ static async getMigrationPaths(cwd, migrator, defaultPath, path$7) {
71
+ if (path$7) return [join(cwd, path$7)];
72
+ return [...migrator.getPaths(), join(cwd, defaultPath)];
73
+ }
74
+ };
75
+ var TableGuesser = class TableGuesser {
76
+ static CREATE_PATTERNS = [/^create_(\w+)_table$/, /^create_(\w+)$/];
77
+ static CHANGE_PATTERNS = [/.+_(to|from|in)_(\w+)_table$/, /.+_(to|from|in)_(\w+)$/];
78
+ static guess(migration) {
79
+ for (const pattern of TableGuesser.CREATE_PATTERNS) {
80
+ const matches = migration.match(pattern);
81
+ if (matches) return [matches[1], true];
82
+ }
83
+ for (const pattern of TableGuesser.CHANGE_PATTERNS) {
84
+ const matches = migration.match(pattern);
85
+ if (matches) return [matches[2], false];
86
+ }
87
+ return [];
88
+ }
89
+ };
90
+ //#endregion
57
91
  //#region src/cli/commands.ts
58
92
  var ArquebusCommand = class extends _h3ravel_musket.Command {
59
93
  pathOption(signature) {
@@ -5315,40 +5349,6 @@ var Migrator = class {
5315
5349
  }
5316
5350
  };
5317
5351
  //#endregion
5318
- //#region src/cli/utils.ts
5319
- const join = path.default.join;
5320
- var Utils = class {
5321
- static findModulePkg(moduleId, cwd) {
5322
- const parts = moduleId.replace(/\\/g, "/").split("/");
5323
- let packageName = "";
5324
- if (parts.length > 0 && parts[0][0] === "@") packageName += parts.shift() + "/";
5325
- packageName += parts.shift();
5326
- const packageJson = path.default.join(packageName, "package.json");
5327
- const resolved = resolve_from.default.silent(cwd ?? process.cwd(), packageJson);
5328
- if (!resolved) return;
5329
- return path.default.join(path.default.dirname(resolved), parts.join("/"));
5330
- }
5331
- static async getMigrationPaths(cwd, migrator, defaultPath, path$7) {
5332
- if (path$7) return [join(cwd, path$7)];
5333
- return [...migrator.getPaths(), join(cwd, defaultPath)];
5334
- }
5335
- };
5336
- var TableGuesser = class TableGuesser {
5337
- static CREATE_PATTERNS = [/^create_(\w+)_table$/, /^create_(\w+)$/];
5338
- static CHANGE_PATTERNS = [/.+_(to|from|in)_(\w+)_table$/, /.+_(to|from|in)_(\w+)$/];
5339
- static guess(migration) {
5340
- for (const pattern of TableGuesser.CREATE_PATTERNS) {
5341
- const matches = migration.match(pattern);
5342
- if (matches) return [matches[1], true];
5343
- }
5344
- for (const pattern of TableGuesser.CHANGE_PATTERNS) {
5345
- const matches = migration.match(pattern);
5346
- if (matches) return [matches[2], false];
5347
- }
5348
- return [];
5349
- }
5350
- };
5351
- //#endregion
5352
5352
  //#region src/migrate.ts
5353
5353
  var Migrate = class {
5354
5354
  basePath;
@@ -5589,10 +5589,10 @@ var MigrationCreator = class {
5589
5589
  };
5590
5590
  //#endregion
5591
5591
  //#region package.json
5592
- var version = "3.0.0";
5592
+ var version = "3.0.1";
5593
5593
  //#endregion
5594
5594
  //#region src/cli/index.ts
5595
- (class Cli {
5595
+ (class Cli extends _h3ravel_musket.Application {
5596
5596
  cwd;
5597
5597
  output = _h3ravel_shared.Logger;
5598
5598
  config = {};
@@ -5601,6 +5601,7 @@ var version = "3.0.0";
5601
5601
  configPath;
5602
5602
  modulePackage = { version: "N/A" };
5603
5603
  constructor(basePath) {
5604
+ super();
5604
5605
  this.basePath = basePath ?? (process.env.TEST === "true" ? "test/cli" : "");
5605
5606
  }
5606
5607
  static async init() {
@@ -5610,6 +5611,11 @@ var version = "3.0.0";
5610
5611
  await instance.loadConfig();
5611
5612
  await instance.run();
5612
5613
  }
5614
+ registerMusketListeners(musket) {
5615
+ musket.afterHandle.once(async () => {
5616
+ process.exit(0);
5617
+ });
5618
+ }
5613
5619
  terminateNotFound() {
5614
5620
  const cmd = _h3ravel_shared.Logger.log([["arquebus init", [
5615
5621
  "italic",
@@ -5659,22 +5665,21 @@ var version = "3.0.0";
5659
5665
  return this;
5660
5666
  }
5661
5667
  async run() {
5662
- const kernel = new _h3ravel_musket.Kernel(this).setCwd(this.cwd).setConfig({
5668
+ return await new _h3ravel_musket.Kernel(this).setCwd(this.cwd).setConfig({
5663
5669
  baseCommands: ArquebusCommands,
5664
5670
  name: "arquebus",
5665
5671
  hideMusketInfo: true,
5666
5672
  versionSeparator: "\n"
5667
- }).bootstrap();
5668
- kernel.modules = [{
5673
+ }).setPackages([{
5669
5674
  name: "@h3ravel/arquebus",
5670
- label: "Arquebus CLI version",
5671
- version
5675
+ label: "Arquebus CLI",
5676
+ version,
5677
+ base: true
5672
5678
  }, {
5673
5679
  name: "@h3ravel/arquebus",
5674
- label: "Arquebus Local version",
5680
+ label: "Arquebus ORM",
5675
5681
  version: this.modulePackage.version || "N/A"
5676
- }];
5677
- return await kernel.run();
5682
+ }]).bootstrap().run();
5678
5683
  }
5679
5684
  async initialize(type = "js") {
5680
5685
  if (!this.modulePath) this.output.error(["ERROR: No local arquebus install found", " Try running: pnpm add @h3ravel/arquebus"]);
package/bin/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
+ import { Application, Command, Kernel } from "@h3ravel/musket";
2
3
  import { FileSystem, Logger, TaskManager, importFile } from "@h3ravel/shared";
3
- import { Command, Kernel } from "@h3ravel/musket";
4
- import { Arr, Obj, Str, data_get, data_set } from "@h3ravel/support";
5
- import fs, { access, copyFile, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
6
4
  import path from "path";
5
+ import resolveFrom from "resolve-from";
6
+ import fs, { access, copyFile, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
7
7
  import path$1, { dirname } from "node:path";
8
8
  import { existsSync } from "node:fs";
9
9
  import { fileURLToPath } from "node:url";
10
+ import { Arr, Obj, Str, data_get, data_set } from "@h3ravel/support";
10
11
  import * as dayjsModule from "dayjs";
11
12
  import * as advancedFormatModule from "dayjs/plugin/advancedFormat.js";
12
13
  import { Collection, collect } from "@h3ravel/collect.js";
13
14
  import Knex from "knex";
14
15
  import { existsSync as existsSync$1 } from "fs";
15
16
  import pluralize from "pluralize";
16
- import resolveFrom from "resolve-from";
17
17
  import { config } from "dotenv";
18
18
  //#region \0rolldown/runtime.js
19
19
  var __defProp = Object.defineProperty;
@@ -27,6 +27,40 @@ var __exportAll = (all, no_symbols) => {
27
27
  return target;
28
28
  };
29
29
  //#endregion
30
+ //#region src/cli/utils.ts
31
+ const join = path.join;
32
+ var Utils = class {
33
+ static findModulePkg(moduleId, cwd) {
34
+ const parts = moduleId.replace(/\\/g, "/").split("/");
35
+ let packageName = "";
36
+ if (parts.length > 0 && parts[0][0] === "@") packageName += parts.shift() + "/";
37
+ packageName += parts.shift();
38
+ const packageJson = path.join(packageName, "package.json");
39
+ const resolved = resolveFrom.silent(cwd ?? process.cwd(), packageJson);
40
+ if (!resolved) return;
41
+ return path.join(path.dirname(resolved), parts.join("/"));
42
+ }
43
+ static async getMigrationPaths(cwd, migrator, defaultPath, path) {
44
+ if (path) return [join(cwd, path)];
45
+ return [...migrator.getPaths(), join(cwd, defaultPath)];
46
+ }
47
+ };
48
+ var TableGuesser = class TableGuesser {
49
+ static CREATE_PATTERNS = [/^create_(\w+)_table$/, /^create_(\w+)$/];
50
+ static CHANGE_PATTERNS = [/.+_(to|from|in)_(\w+)_table$/, /.+_(to|from|in)_(\w+)$/];
51
+ static guess(migration) {
52
+ for (const pattern of TableGuesser.CREATE_PATTERNS) {
53
+ const matches = migration.match(pattern);
54
+ if (matches) return [matches[1], true];
55
+ }
56
+ for (const pattern of TableGuesser.CHANGE_PATTERNS) {
57
+ const matches = migration.match(pattern);
58
+ if (matches) return [matches[2], false];
59
+ }
60
+ return [];
61
+ }
62
+ };
63
+ //#endregion
30
64
  //#region src/cli/commands.ts
31
65
  var ArquebusCommand = class extends Command {
32
66
  pathOption(signature) {
@@ -5288,40 +5322,6 @@ var Migrator = class {
5288
5322
  }
5289
5323
  };
5290
5324
  //#endregion
5291
- //#region src/cli/utils.ts
5292
- const join = path.join;
5293
- var Utils = class {
5294
- static findModulePkg(moduleId, cwd) {
5295
- const parts = moduleId.replace(/\\/g, "/").split("/");
5296
- let packageName = "";
5297
- if (parts.length > 0 && parts[0][0] === "@") packageName += parts.shift() + "/";
5298
- packageName += parts.shift();
5299
- const packageJson = path.join(packageName, "package.json");
5300
- const resolved = resolveFrom.silent(cwd ?? process.cwd(), packageJson);
5301
- if (!resolved) return;
5302
- return path.join(path.dirname(resolved), parts.join("/"));
5303
- }
5304
- static async getMigrationPaths(cwd, migrator, defaultPath, path) {
5305
- if (path) return [join(cwd, path)];
5306
- return [...migrator.getPaths(), join(cwd, defaultPath)];
5307
- }
5308
- };
5309
- var TableGuesser = class TableGuesser {
5310
- static CREATE_PATTERNS = [/^create_(\w+)_table$/, /^create_(\w+)$/];
5311
- static CHANGE_PATTERNS = [/.+_(to|from|in)_(\w+)_table$/, /.+_(to|from|in)_(\w+)$/];
5312
- static guess(migration) {
5313
- for (const pattern of TableGuesser.CREATE_PATTERNS) {
5314
- const matches = migration.match(pattern);
5315
- if (matches) return [matches[1], true];
5316
- }
5317
- for (const pattern of TableGuesser.CHANGE_PATTERNS) {
5318
- const matches = migration.match(pattern);
5319
- if (matches) return [matches[2], false];
5320
- }
5321
- return [];
5322
- }
5323
- };
5324
- //#endregion
5325
5325
  //#region src/migrate.ts
5326
5326
  var Migrate = class {
5327
5327
  basePath;
@@ -5562,10 +5562,10 @@ var MigrationCreator = class {
5562
5562
  };
5563
5563
  //#endregion
5564
5564
  //#region package.json
5565
- var version = "3.0.0";
5565
+ var version = "3.0.1";
5566
5566
  //#endregion
5567
5567
  //#region src/cli/index.ts
5568
- (class Cli {
5568
+ (class Cli extends Application {
5569
5569
  cwd;
5570
5570
  output = Logger;
5571
5571
  config = {};
@@ -5574,6 +5574,7 @@ var version = "3.0.0";
5574
5574
  configPath;
5575
5575
  modulePackage = { version: "N/A" };
5576
5576
  constructor(basePath) {
5577
+ super();
5577
5578
  this.basePath = basePath ?? (process.env.TEST === "true" ? "test/cli" : "");
5578
5579
  }
5579
5580
  static async init() {
@@ -5583,6 +5584,11 @@ var version = "3.0.0";
5583
5584
  await instance.loadConfig();
5584
5585
  await instance.run();
5585
5586
  }
5587
+ registerMusketListeners(musket) {
5588
+ musket.afterHandle.once(async () => {
5589
+ process.exit(0);
5590
+ });
5591
+ }
5586
5592
  terminateNotFound() {
5587
5593
  const cmd = Logger.log([["arquebus init", [
5588
5594
  "italic",
@@ -5632,22 +5638,21 @@ var version = "3.0.0";
5632
5638
  return this;
5633
5639
  }
5634
5640
  async run() {
5635
- const kernel = new Kernel(this).setCwd(this.cwd).setConfig({
5641
+ return await new Kernel(this).setCwd(this.cwd).setConfig({
5636
5642
  baseCommands: ArquebusCommands,
5637
5643
  name: "arquebus",
5638
5644
  hideMusketInfo: true,
5639
5645
  versionSeparator: "\n"
5640
- }).bootstrap();
5641
- kernel.modules = [{
5646
+ }).setPackages([{
5642
5647
  name: "@h3ravel/arquebus",
5643
- label: "Arquebus CLI version",
5644
- version
5648
+ label: "Arquebus CLI",
5649
+ version,
5650
+ base: true
5645
5651
  }, {
5646
5652
  name: "@h3ravel/arquebus",
5647
- label: "Arquebus Local version",
5653
+ label: "Arquebus ORM",
5648
5654
  version: this.modulePackage.version || "N/A"
5649
- }];
5650
- return await kernel.run();
5655
+ }]).bootstrap().run();
5651
5656
  }
5652
5657
  async initialize(type = "js") {
5653
5658
  if (!this.modulePath) this.output.error(["ERROR: No local arquebus install found", " Try running: pnpm add @h3ravel/arquebus"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h3ravel/arquebus",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Arquebus ORM is a Beautiful, expressive ORM inspired by Laravel's Eloquent, designed for TypeScript applications and for the H3ravel Framework.",
5
5
  "homepage": "https://h3ravel.toneflix.net/arquebus",
6
6
  "bin": {
@@ -155,9 +155,9 @@
155
155
  },
156
156
  "dependencies": {
157
157
  "@h3ravel/collect.js": "^5.4.0",
158
- "@h3ravel/musket": "^2.2.7",
159
- "@h3ravel/shared": "^2.2.5",
160
- "@h3ravel/support": "^2.2.5",
158
+ "@h3ravel/musket": "^2.2.12",
159
+ "@h3ravel/shared": "^2.2.6",
160
+ "@h3ravel/support": "^2.2.6",
161
161
  "barrelize": "^1.8.2",
162
162
  "chalk": "^5.6.2",
163
163
  "chokidar": "^5.0.0",
package/types/cli.ts ADDED
@@ -0,0 +1,20 @@
1
+ export type FileType = 'js' | 'ts'
2
+
3
+ export interface PathOptions {
4
+ path?: string
5
+ }
6
+
7
+ export interface MigrationOptions extends PathOptions {
8
+ step?: number | string
9
+ }
10
+
11
+ export interface MakeMigrationOptions extends PathOptions {
12
+ type?: FileType
13
+ table?: string
14
+ create?: string | boolean
15
+ }
16
+
17
+ export interface MakeFileOptions extends PathOptions {
18
+ type?: FileType
19
+ force?: boolean
20
+ }
package/types/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './builder'
2
+ export * from './cli'
2
3
  export * from './container'
3
4
  export * from './database'
4
5
  export * from './generics'