@h3ravel/arquebus 0.6.6 → 0.6.7

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.
Files changed (47) hide show
  1. package/README.md +5 -4
  2. package/package.json +4 -3
  3. package/bin/index.cjs +0 -5927
  4. package/bin/index.d.cts +0 -1
  5. package/bin/index.d.ts +0 -1
  6. package/bin/index.js +0 -5925
  7. package/bin/seeders-8GJzfIIN.js +0 -3
  8. package/bin/seeders-ByeSoCAQ.cjs +0 -131
  9. package/bin/seeders-CltigymO.js +0 -79
  10. package/bin/seeders-_xJ6VGVS.cjs +0 -3
  11. package/dist/browser/index.cjs +0 -1271
  12. package/dist/browser/index.d.cts +0 -4932
  13. package/dist/browser/index.d.ts +0 -4932
  14. package/dist/browser/index.js +0 -1218
  15. package/dist/index.cjs +0 -5713
  16. package/dist/index.d.cts +0 -5129
  17. package/dist/index.d.ts +0 -5129
  18. package/dist/index.js +0 -5644
  19. package/dist/inspector/index.cjs +0 -4908
  20. package/dist/inspector/index.d.cts +0 -83
  21. package/dist/inspector/index.d.ts +0 -83
  22. package/dist/inspector/index.js +0 -4881
  23. package/dist/migrations/chunk-PECeCxCb.js +0 -15
  24. package/dist/migrations/index.cjs +0 -5470
  25. package/dist/migrations/index.d.cts +0 -4965
  26. package/dist/migrations/index.d.ts +0 -4962
  27. package/dist/migrations/index.js +0 -5419
  28. package/dist/migrations/stubs/migration-js.stub +0 -21
  29. package/dist/migrations/stubs/migration-ts.stub +0 -18
  30. package/dist/migrations/stubs/migration.create-js.stub +0 -24
  31. package/dist/migrations/stubs/migration.create-ts.stub +0 -21
  32. package/dist/migrations/stubs/migration.update-js.stub +0 -25
  33. package/dist/migrations/stubs/migration.update-ts.stub +0 -22
  34. package/dist/seeders/index.cjs +0 -141
  35. package/dist/seeders/index.d.cts +0 -4766
  36. package/dist/seeders/index.d.ts +0 -4766
  37. package/dist/seeders/index.js +0 -118
  38. package/dist/seeders/index.ts +0 -3
  39. package/dist/seeders/runner.ts +0 -101
  40. package/dist/seeders/seeder-creator.ts +0 -42
  41. package/dist/seeders/seeder.ts +0 -10
  42. package/dist/stubs/arquebus.config-js.stub +0 -25
  43. package/dist/stubs/arquebus.config-ts.stub +0 -24
  44. package/dist/stubs/model-js.stub +0 -5
  45. package/dist/stubs/model-ts.stub +0 -5
  46. package/dist/stubs/seeder-js.stub +0 -13
  47. package/dist/stubs/seeder-ts.stub +0 -9
@@ -1,118 +0,0 @@
1
- import { access, mkdir, readFile, writeFile } from "node:fs/promises";
2
- import path from "path";
3
- import path$1, { dirname } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
-
6
- //#region src/seeders/seeder.ts
7
- var Seeder = class {};
8
- var seeder_default = Seeder;
9
-
10
- //#endregion
11
- //#region src/seeders/runner.ts
12
- async function glob(folderPath) {
13
- const { default: escalade } = await import("escalade");
14
- const entries = [];
15
- await escalade(folderPath, async (dir, names) => {
16
- await Promise.all(names.map(async (name) => {
17
- const p = path.join(dir, name);
18
- try {
19
- await access(p);
20
- if (p.endsWith(".js") || p.endsWith(".ts")) entries.push(p);
21
- } catch {}
22
- }));
23
- return "";
24
- });
25
- return entries;
26
- }
27
- var SeederRunner = class {
28
- resolver;
29
- connection;
30
- paths = [];
31
- constructor(resolver) {
32
- this.resolver = resolver;
33
- }
34
- path(p) {
35
- this.paths = Array.from(new Set([...this.paths, p]));
36
- }
37
- getPaths() {
38
- return this.paths;
39
- }
40
- resolveConnection(connection) {
41
- var _getInstance, _ref, _instance$connections;
42
- const name = connection || this.connection || "default";
43
- const instance = ((_getInstance = (_ref = this.resolver).getInstance) === null || _getInstance === void 0 ? void 0 : _getInstance.call(_ref)) ?? null;
44
- if (!!!(instance === null || instance === void 0 || (_instance$connections = instance.connections) === null || _instance$connections === void 0 ? void 0 : _instance$connections[name])) this.resolver.autoLoad().catch(() => {
45
- /** noop */
46
- });
47
- return this.resolver.fire(name);
48
- }
49
- setConnection(connection) {
50
- this.connection = connection;
51
- return this;
52
- }
53
- async getSeederFiles(paths) {
54
- const files = [];
55
- for (const p of paths) {
56
- if (p.endsWith(".js") || p.endsWith(".ts")) {
57
- files.push(p);
58
- continue;
59
- }
60
- files.push(...await glob(p));
61
- }
62
- return files;
63
- }
64
- async resolvePath(filePath) {
65
- try {
66
- const mod = await import(filePath);
67
- return new (mod.default ?? mod.Seeder)();
68
- } catch {
69
- return null;
70
- }
71
- }
72
- async run(paths, connection) {
73
- const files = await this.getSeederFiles(paths);
74
- const conn = this.resolveConnection(connection);
75
- for (const file of files) {
76
- const seeder = await this.resolvePath(file);
77
- if (seeder && typeof seeder.run === "function") await seeder.run(conn);
78
- }
79
- }
80
- };
81
- var runner_default = SeederRunner;
82
-
83
- //#endregion
84
- //#region node_modules/.pnpm/tsdown@0.15.6_typescript@5.9.3/node_modules/tsdown/esm-shims.js
85
- const getFilename = () => fileURLToPath(import.meta.url);
86
- const getDirname = () => path$1.dirname(getFilename());
87
- const __dirname = /* @__PURE__ */ getDirname();
88
-
89
- //#endregion
90
- //#region src/seeders/seeder-creator.ts
91
- var SeederCreator = class {
92
- constructor(customStubPath) {
93
- this.customStubPath = customStubPath;
94
- }
95
- async create(dir, name, type = "js") {
96
- await mkdir(dir, { recursive: true });
97
- const stubPath = this.getStubPath(type);
98
- let stub = await readFile(stubPath, "utf-8");
99
- stub = stub.replace(/{{ name }}/g, name);
100
- const filePath = path.join(dir, `${name}.${type}`);
101
- await writeFile(filePath, stub);
102
- return filePath;
103
- }
104
- getStubPath(type) {
105
- if (this.customStubPath) return path.join(this.customStubPath, `seeder-${type}.stub`);
106
- const __dirname$1 = this.getDirname(import.meta);
107
- return path.join(__dirname$1, "stubs", `seeder-${type}.stub`);
108
- }
109
- getDirname(meta) {
110
- if (typeof __dirname !== "undefined") return __dirname;
111
- if (meta && meta.url) return dirname(fileURLToPath(meta.url));
112
- throw new Error("Unable to determine dirname");
113
- }
114
- };
115
- var seeder_creator_default = SeederCreator;
116
-
117
- //#endregion
118
- export { seeder_default as Seeder, seeder_creator_default as SeederCreator, runner_default as SeederRunner };
@@ -1,3 +0,0 @@
1
- export { default as Seeder } from './seeder'
2
- export { default as SeederRunner } from './runner'
3
- export { default as SeederCreator } from './seeder-creator'
@@ -1,101 +0,0 @@
1
- import type QueryBuilder from 'src/query-builder'
2
- import type Seeder from './seeder'
3
- import type { TBaseConfig } from 'types/container'
4
- import { access } from 'node:fs/promises'
5
- import type { arquebus } from 'src'
6
- import path from 'path'
7
-
8
- async function glob (folderPath: string): Promise<string[]> {
9
- const { default: escalade } = await import('escalade')
10
- const entries: string[] = []
11
- const root = folderPath
12
- await escalade(root, async (dir, names) => {
13
- await Promise.all(
14
- names.map(async (name) => {
15
- const p = path.join(dir, name)
16
- try {
17
- await access(p)
18
- if (p.endsWith('.js') || p.endsWith('.ts')) entries.push(p)
19
- } catch {
20
- /** */
21
- }
22
- }),
23
- )
24
- return ''
25
- })
26
- return entries
27
- }
28
-
29
- export class SeederRunner {
30
- resolver: typeof arquebus
31
- connection!: TBaseConfig['client']
32
- paths: string[] = []
33
-
34
- constructor(resolver: typeof arquebus) {
35
- this.resolver = resolver
36
- }
37
-
38
- path (p: string): void {
39
- this.paths = Array.from(new Set([...this.paths, p]))
40
- }
41
-
42
- getPaths (): string[] {
43
- return this.paths
44
- }
45
-
46
- resolveConnection (connection?: TBaseConfig['client']): QueryBuilder {
47
- const name = connection || this.connection || 'default'
48
- // If the resolver has no connection manager entry, attempt to autoload config
49
- const instance: any = (this.resolver as any).getInstance?.() ?? null
50
- const hasConn = !!instance?.connections?.[name]
51
- if (!hasConn) {
52
- // Attempt autoload; do not throw if empty
53
- this.resolver
54
- .autoLoad()
55
- .catch(() => {
56
- /** noop */
57
- })
58
- }
59
- return this.resolver.fire(name)
60
- }
61
-
62
- setConnection (connection: TBaseConfig['client']): this {
63
- this.connection = connection
64
- return this
65
- }
66
-
67
- async getSeederFiles (paths: string[]): Promise<string[]> {
68
- const files: string[] = []
69
- for (const p of paths) {
70
- if (p.endsWith('.js') || p.endsWith('.ts')) {
71
- files.push(p)
72
- continue
73
- }
74
- files.push(...(await glob(p)))
75
- }
76
- return files
77
- }
78
-
79
- async resolvePath (filePath: string): Promise<Seeder | null> {
80
- try {
81
- const mod = await import(filePath)
82
- const instance = new (mod.default ?? mod.Seeder)()
83
- return instance as Seeder
84
- } catch {
85
- return null
86
- }
87
- }
88
-
89
- async run (paths: string[], connection?: TBaseConfig['client']): Promise<void> {
90
- const files = await this.getSeederFiles(paths)
91
- const conn = this.resolveConnection(connection)
92
- for (const file of files) {
93
- const seeder = await this.resolvePath(file)
94
- if (seeder && typeof seeder.run === 'function') {
95
- await seeder.run(conn)
96
- }
97
- }
98
- }
99
- }
100
-
101
- export default SeederRunner
@@ -1,42 +0,0 @@
1
- import { mkdir, readFile, writeFile } from 'node:fs/promises'
2
-
3
- import { dirname } from 'node:path'
4
- import { fileURLToPath } from 'node:url'
5
- import path from 'path'
6
-
7
- export class SeederCreator {
8
- constructor(private customStubPath?: string) { }
9
-
10
- async create (dir: string, name: string, type: 'js' | 'ts' = 'js') {
11
- await mkdir(dir, { recursive: true })
12
-
13
- const stubPath = this.getStubPath(type)
14
- let stub = await readFile(stubPath, 'utf-8')
15
- stub = stub.replace(/{{ name }}/g, name)
16
-
17
- const filePath = path.join(dir, `${name}.${type}`)
18
- await writeFile(filePath, stub)
19
-
20
- return filePath
21
- }
22
-
23
- getStubPath (type: 'js' | 'ts') {
24
- if (this.customStubPath) return path.join(this.customStubPath, `seeder-${type}.stub`)
25
- const __dirname = this.getDirname(import.meta as any)
26
- return path.join(__dirname, 'stubs', `seeder-${type}.stub`)
27
- }
28
-
29
- getDirname (meta: ImportMeta | null) {
30
- if (typeof __dirname !== 'undefined') {
31
- // CJS build
32
- return __dirname
33
- }
34
- if (meta && meta.url) {
35
- // ESM build
36
- return dirname(fileURLToPath(meta.url))
37
- }
38
- throw new Error('Unable to determine dirname')
39
- }
40
- }
41
-
42
- export default SeederCreator
@@ -1,10 +0,0 @@
1
- import type QueryBuilder from 'src/query-builder'
2
-
3
- export abstract class Seeder {
4
- /**
5
- * Run the database seeds
6
- */
7
- abstract run(connection: QueryBuilder): Promise<void>
8
- }
9
-
10
- export default Seeder
@@ -1,25 +0,0 @@
1
- import { defineConfig } from '@h3ravel/arquebus'
2
-
3
- export default defineConfig({
4
- client: 'mysql2',
5
- connection: {
6
- host: 'localhost',
7
- database: 'database',
8
- user: 'user',
9
- password: 'password'
10
- },
11
- migrations: {
12
- table: 'migrations',
13
- path: './migrations',
14
- },
15
- factories: {
16
- path: './factories',
17
- },
18
- seeders: {
19
- path: './seeders',
20
- },
21
- models: {
22
- path: './models'
23
- }
24
- })
25
-
@@ -1,24 +0,0 @@
1
- import { defineConfig } from '@h3ravel/arquebus'
2
-
3
- export default defineConfig({
4
- client: 'mysql2',
5
- connection: {
6
- host: 'localhost',
7
- database: 'database',
8
- user: 'user',
9
- password: 'password'
10
- },
11
- migrations: {
12
- table: 'migrations',
13
- path: './migrations',
14
- },
15
- factories: {
16
- path: './factories',
17
- },
18
- seeders: {
19
- path: './seeders',
20
- },
21
- models: {
22
- path: './models'
23
- }
24
- })
@@ -1,5 +0,0 @@
1
- import { Model } from '@h3ravel/arquebus'
2
-
3
- export default class {{ name }} extends Model {
4
- //
5
- }
@@ -1,5 +0,0 @@
1
- import { Model } from '@h3ravel/arquebus'
2
-
3
- export default class {{ name }} extends Model {
4
- //
5
- }
@@ -1,13 +0,0 @@
1
- import { Seeder } from '@h3ravel/arquebus'
2
-
3
- export default class {{ name }} extends Seeder {
4
- /**
5
- * Run the seeder.
6
- *
7
- * @param {(import('@h3ravel/arquebus').QueryBuilder)} connection
8
- */
9
- async run(connection) {
10
- // Example: insert sample data
11
- await connection.table('users').insert({ name: 'John Doe' })
12
- }
13
- }
@@ -1,9 +0,0 @@
1
- import type { QueryBuilder } from '@h3ravel/arquebus'
2
- import { Seeder } from '@h3ravel/arquebus'
3
-
4
- export default class {{ name }} extends Seeder {
5
- async run(connection: QueryBuilder) {
6
- // Example: insert sample data
7
- await connection.table('users').insert({ name: 'John Doe' })
8
- }
9
- }