@stacksjs/actions 0.59.11 → 0.61.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/add.js +29 -0
- package/dist/build/component-libs.js +9 -0
- package/dist/build/core.js +21 -0
- package/dist/build/stacks.js +8 -0
- package/dist/build.js +317 -0
- package/dist/bump.js +16 -0
- package/dist/changelog.js +17 -0
- package/dist/clean.js +6 -0
- package/dist/commit.js +17 -0
- package/dist/copy-types.js +14 -0
- package/dist/database/seed.js +8 -0
- package/dist/deploy/index.js +31 -0
- package/dist/dev/components.js +11 -0
- package/dist/dev/docs.js +7 -0
- package/dist/dev/index.js +112 -0
- package/dist/examples.js +43 -0
- package/dist/fresh.js +19 -0
- package/dist/generate/component-meta.js +59 -0
- package/dist/generate/ide-helpers.js +96 -0
- package/dist/generate/index.js +251 -0
- package/dist/generate/lib-entries.js +175 -0
- package/dist/generate/vscode-custom-data.js +96 -0
- package/dist/helpers/component-meta.js +50 -0
- package/dist/helpers/lib-entries.js +166 -0
- package/dist/helpers/package-json.js +146 -0
- package/dist/helpers/utils.js +67 -0
- package/dist/helpers/vscode-custom-data.js +88 -0
- package/dist/index.js +676 -0
- package/dist/key-generate.js +10 -0
- package/dist/lint/fix.js +12 -0
- package/dist/lint/index.js +16 -0
- package/dist/make.js +319 -0
- package/dist/prepublish.js +17 -0
- package/dist/release.js +646 -0
- package/dist/test/coverage.js +9 -0
- package/dist/test/feature.js +9 -0
- package/dist/test/ui.js +6 -0
- package/dist/test/unit.js +6 -0
- package/dist/test.js +6 -0
- package/dist/typecheck.js +6 -0
- package/dist/types.js +21 -0
- package/dist/upgrade/dependencies.js +6 -0
- package/dist/upgrade/framework.js +1 -0
- package/dist/upgrade/index.js +78 -0
- package/dist/upgrade.js +46 -0
- package/package.json +5 -5
- package/src/action.ts +1 -0
- package/src/actions.ts +2 -2
- package/src/add.ts +3 -6
- package/src/ai/request-model-access.ts +10 -7
- package/src/build/component-libs.ts +5 -2
- package/src/build/core.ts +1 -2
- package/src/build/stacks.ts +8 -5
- package/src/build.ts +11 -25
- package/src/bump.ts +0 -2
- package/src/check/ports.ts +2 -3
- package/src/commit.ts +2 -2
- package/src/copy-types.ts +1 -1
- package/src/database/seed.ts +8 -4
- package/src/deploy/create-receipt-rule.ts +3 -7
- package/src/deploy/index.ts +2 -1
- package/src/dev/api.ts +4 -4
- package/src/dev/components.ts +3 -5
- package/src/dev/index.ts +2 -2
- package/src/domains/add.ts +8 -6
- package/src/domains/purchase.ts +26 -24
- package/src/domains/remove.ts +5 -7
- package/src/examples.ts +9 -13
- package/src/find-projects.ts +4 -6
- package/src/fresh.ts +2 -1
- package/src/generate/action-types.ts +5 -7
- package/src/generate/component-meta.ts +2 -5
- package/src/generate/custom-cli-file.ts +4 -3
- package/src/generate/env-files.ts +38 -43
- package/src/generate/ide-helpers.ts +1 -2
- package/src/generate/index.ts +16 -40
- package/src/generate/lib-entries.ts +4 -7
- package/src/generate/pkgx-file.ts +6 -11
- package/src/generate/vscode-custom-data.ts +1 -3
- package/src/helpers/component-meta.ts +6 -11
- package/src/helpers/index.ts +5 -0
- package/src/helpers/lib-entries.ts +30 -25
- package/src/helpers/package-json.ts +13 -16
- package/src/helpers/utils.ts +56 -13
- package/src/helpers/vscode-custom-data.ts +1 -2
- package/src/index.ts +2 -1
- package/src/key-generate.ts +3 -4
- package/src/lint/fix.ts +10 -2
- package/src/lint/index.ts +6 -8
- package/src/make.ts +79 -77
- package/src/migrate/database.ts +22 -1
- package/src/migrate/fresh.ts +20 -0
- package/src/orm/base.ts +0 -0
- package/src/orm/generate-model.ts +1177 -0
- package/src/{generate/model-classes.ts → orm/user.ts} +33 -48
- package/src/prepublish.ts +5 -2
- package/src/release.ts +15 -11
- package/src/test/coverage.ts +5 -2
- package/src/test/feature.ts +5 -2
- package/src/test/ui.ts +1 -1
- package/src/test/unit.ts +1 -1
- package/src/test.ts +1 -1
- package/src/typecheck.ts +1 -1
- package/src/types.ts +2 -2
- package/src/upgrade/binary.ts +3 -5
- package/src/upgrade/index.ts +4 -8
- package/src/upgrade/shell.ts +10 -10
- package/src/upgrade.ts +28 -25
- package/dist/action.d.ts +0 -36
- package/dist/add.d.ts +0 -6
- package/dist/build/component-libs.d.ts +0 -1
- package/dist/build/core.d.ts +0 -1
- package/dist/build/stacks.d.ts +0 -1
- package/dist/build.d.ts +0 -9
- package/dist/bump.d.ts +0 -1
- package/dist/changelog.d.ts +0 -1
- package/dist/clean.d.ts +0 -1
- package/dist/commit.d.ts +0 -3
- package/dist/copy-types.d.ts +0 -5
- package/dist/database/seed.d.ts +0 -1
- package/dist/deploy/index.d.ts +0 -1
- package/dist/dev/components.d.ts +0 -1
- package/dist/dev/docs.d.ts +0 -1
- package/dist/dev/index.d.ts +0 -10
- package/dist/examples.d.ts +0 -5
- package/dist/fresh.d.ts +0 -1
- package/dist/generate/component-meta.d.ts +0 -5
- package/dist/generate/ide-helpers.d.ts +0 -6
- package/dist/generate/index.d.ts +0 -13
- package/dist/generate/lib-entries.d.ts +0 -2
- package/dist/generate/vscode-custom-data.d.ts +0 -6
- package/dist/helpers/component-meta.d.ts +0 -22
- package/dist/helpers/lib-entries.d.ts +0 -13
- package/dist/helpers/package-json.d.ts +0 -3
- package/dist/helpers/utils.d.ts +0 -18
- package/dist/helpers/vscode-custom-data.d.ts +0 -2
- package/dist/index.d.ts +0 -7
- package/dist/key-generate.d.ts +0 -1
- package/dist/lint/fix.d.ts +0 -1
- package/dist/lint/index.d.ts +0 -1
- package/dist/make.d.ts +0 -20
- package/dist/prepublish.d.ts +0 -1
- package/dist/release.d.ts +0 -2
- package/dist/test/coverage.d.ts +0 -1
- package/dist/test/feature.d.ts +0 -1
- package/dist/test/ui.d.ts +0 -1
- package/dist/test/unit.d.ts +0 -1
- package/dist/test.d.ts +0 -1
- package/dist/tinker.d.ts +0 -1
- package/dist/typecheck.d.ts +0 -1
- package/dist/types.d.ts +0 -3
- package/dist/upgrade/dependencies.d.ts +0 -1
- package/dist/upgrade/framework.d.ts +0 -1
- package/dist/upgrade/index.d.ts +0 -1
- package/dist/upgrade.d.ts +0 -4
- package/src/database/fields.ts +0 -111
- package/src/database/migration-mysql.ts +0 -72
- package/src/database/migration-sqlite.ts +0 -67
- package/src/database/migration.ts +0 -10
- package/src/database/user-migration.ts +0 -20
- package/src/generate/model-generate.ts +0 -12
- package/src/migrate/dns.ts +0 -3
- package/src/tinker.ts +0 -10
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type ComponentMeta } from 'vue-component-meta';
|
|
2
|
-
/**
|
|
3
|
-
* ℹ️ Useful Links
|
|
4
|
-
*
|
|
5
|
-
* vue-component-meta tests: https://github.com/johnsoncodehk/volar/blob/master/vue-language-tools/vue-component-meta/tests/index.spec.ts
|
|
6
|
-
* Discord thread about improving vue-component-meta: https://discord.com/channels/793943652350427136/1027819645677350912
|
|
7
|
-
* GitHub issue for improving vue-component-meta based on runtime/dynamic props: https://github.com/johnsoncodehk/volar/issues/1854
|
|
8
|
-
* Discord chat: https://discord.com/channels/793943652350427136/1027819645677350912
|
|
9
|
-
* original script: https://raw.githubusercontent.com/jd-solanki/anu/main/scripts/gen-component-meta.ts
|
|
10
|
-
*/
|
|
11
|
-
export declare function generateComponentMeta(): void;
|
|
12
|
-
export interface ComponentApiProps {
|
|
13
|
-
name: ComponentMeta['props'][number]['name'];
|
|
14
|
-
description: ComponentMeta['props'][number]['description'];
|
|
15
|
-
type: ComponentMeta['props'][number]['type'];
|
|
16
|
-
default: ComponentMeta['props'][number]['default'];
|
|
17
|
-
}
|
|
18
|
-
export interface ComponentApi {
|
|
19
|
-
props: ComponentApiProps[];
|
|
20
|
-
events: ComponentMeta['events'];
|
|
21
|
-
slots: ComponentMeta['slots'];
|
|
22
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { LibraryType } from '@stacksjs/path';
|
|
2
|
-
/**
|
|
3
|
-
* Based on the config values, this method
|
|
4
|
-
* will generate the library entry points.
|
|
5
|
-
*
|
|
6
|
-
* @param type LibraryType
|
|
7
|
-
*/
|
|
8
|
-
export declare function generateLibEntry(type: LibraryType): Promise<void>;
|
|
9
|
-
export declare function createLibraryEntryPoint(type: LibraryType): Promise<void>;
|
|
10
|
-
export declare function createVueLibraryEntryPoint(type?: LibraryType): Promise<void>;
|
|
11
|
-
export declare function createWebComponentLibraryEntryPoint(type?: LibraryType): Promise<void>;
|
|
12
|
-
export declare function createFunctionLibraryEntryPoint(type?: LibraryType): Promise<void>;
|
|
13
|
-
export declare function generateEntryPointData(type: LibraryType): string;
|
package/dist/helpers/utils.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ActionOptions } from '@stacksjs/types';
|
|
2
|
-
/**
|
|
3
|
-
* Run an Action the Stacks way.
|
|
4
|
-
*
|
|
5
|
-
* @param action The action to invoke.
|
|
6
|
-
* @param options The options to pass to the command.
|
|
7
|
-
* @returns The result of the command.
|
|
8
|
-
*/
|
|
9
|
-
export declare function runAction(action: string, options?: ActionOptions): Promise<any>;
|
|
10
|
-
/**
|
|
11
|
-
* Run Actions the Stacks way.
|
|
12
|
-
*
|
|
13
|
-
* @param actions The actions to invoke.
|
|
14
|
-
* @param options The options to pass to the command.
|
|
15
|
-
* @returns The result of the command.
|
|
16
|
-
*/
|
|
17
|
-
export declare function runActions(actions: string[], options?: ActionOptions): Promise<any>;
|
|
18
|
-
export declare function hasAction(action: string): any;
|
package/dist/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from './action';
|
|
2
|
-
export * from './dev';
|
|
3
|
-
export * from './generate';
|
|
4
|
-
export * from './helpers/utils';
|
|
5
|
-
export { commit as runCommit } from './commit';
|
|
6
|
-
export { add as runAdd } from './add';
|
|
7
|
-
export { make as runMake, makeComponent, makeDatabase, makeFunction, makeLanguage, makeNotification, makePage, makeStack, createComponent, createDatabase, createFactory, createFunction, createLanguage, createMigration, createModel, createNotification, createPage, } from './make';
|
package/dist/key-generate.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/lint/fix.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/lint/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/make.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { MakeOptions } from '@stacksjs/types';
|
|
2
|
-
export declare function invoke(options: MakeOptions): Promise<void>;
|
|
3
|
-
export declare function make(options: MakeOptions): Promise<void>;
|
|
4
|
-
export declare function makeComponent(options: MakeOptions): Promise<void>;
|
|
5
|
-
export declare function createComponent(options: MakeOptions): Promise<void>;
|
|
6
|
-
export declare function makeDatabase(options: MakeOptions): void;
|
|
7
|
-
export declare function createDatabase(options: MakeOptions): void;
|
|
8
|
-
export declare function factory(options: MakeOptions): void;
|
|
9
|
-
export declare function createFactory(options: MakeOptions): void;
|
|
10
|
-
export declare function makeNotification(options: MakeOptions): Promise<void>;
|
|
11
|
-
export declare function makePage(options: MakeOptions): Promise<void>;
|
|
12
|
-
export declare function createPage(options: MakeOptions): Promise<void>;
|
|
13
|
-
export declare function makeFunction(options: MakeOptions): Promise<void>;
|
|
14
|
-
export declare function createFunction(options: MakeOptions): Promise<void>;
|
|
15
|
-
export declare function makeLanguage(options: MakeOptions): Promise<void>;
|
|
16
|
-
export declare function createLanguage(options: MakeOptions): Promise<void>;
|
|
17
|
-
export declare function makeStack(options: MakeOptions): void;
|
|
18
|
-
export declare function createNotification(options: MakeOptions): Promise<boolean>;
|
|
19
|
-
export declare function createMigration(options: MakeOptions): Promise<void>;
|
|
20
|
-
export declare function createModel(options: MakeOptions): Promise<void>;
|
package/dist/prepublish.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/release.d.ts
DELETED
package/dist/test/coverage.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/test/feature.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/test/ui.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/test/unit.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/tinker.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/typecheck.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/upgrade/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/upgrade.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { UpgradeOptions } from '@stacksjs/types';
|
|
2
|
-
export declare function checkForUncommittedChanges(options: UpgradeOptions): void;
|
|
3
|
-
export declare function downloadFrameworkUpdate(options: UpgradeOptions): Promise<void>;
|
|
4
|
-
export declare function updateDependencies(): Promise<void>;
|
package/src/database/fields.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import User from '../../../../../../app/Models/User'
|
|
2
|
-
|
|
3
|
-
const fields = User.fields // Assuming you have a specific type for fields
|
|
4
|
-
|
|
5
|
-
export interface ModelElement {
|
|
6
|
-
field: string
|
|
7
|
-
default: string | number | boolean | Date | undefined | null
|
|
8
|
-
unique: boolean
|
|
9
|
-
fieldArray: FieldArrayElement[]
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface FieldArrayElement {
|
|
13
|
-
entity: string
|
|
14
|
-
charValue?: string | null
|
|
15
|
-
// Add other properties as needed
|
|
16
|
-
}
|
|
17
|
-
const rules: string[] = []
|
|
18
|
-
|
|
19
|
-
async function extractModelRule() {
|
|
20
|
-
const modelFile = Bun.file('../../../../../app/Models/User.ts') // Assuming Bun is imported properly
|
|
21
|
-
|
|
22
|
-
const code = await modelFile.text()
|
|
23
|
-
|
|
24
|
-
const regex = /rule:.*$/gm
|
|
25
|
-
|
|
26
|
-
let match: RegExpExecArray | null
|
|
27
|
-
match = regex.exec(code)
|
|
28
|
-
while (match !== null) {
|
|
29
|
-
rules.push(match[0])
|
|
30
|
-
match = regex.exec(code)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
await extractModelRule()
|
|
35
|
-
|
|
36
|
-
const fieldKeys = Object.keys(fields)
|
|
37
|
-
|
|
38
|
-
const input: ModelElement[] = fieldKeys.map((field, index) => {
|
|
39
|
-
const fieldExist = fields[field]
|
|
40
|
-
let defaultValue = null
|
|
41
|
-
let uniqueValue = false
|
|
42
|
-
|
|
43
|
-
if (fieldExist) {
|
|
44
|
-
defaultValue = fieldExist?.default || null
|
|
45
|
-
uniqueValue = fieldExist?.unique || false
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
field,
|
|
50
|
-
default: defaultValue,
|
|
51
|
-
unique: uniqueValue,
|
|
52
|
-
fieldArray: parseRule(rules[index]),
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
function parseRule(rule: string): FieldArrayElement[] {
|
|
57
|
-
const parts = rule.split('rule: validator.')
|
|
58
|
-
|
|
59
|
-
if (parts.length !== 2)
|
|
60
|
-
return []
|
|
61
|
-
|
|
62
|
-
if (!parts[1])
|
|
63
|
-
parts[1] = ''
|
|
64
|
-
|
|
65
|
-
const extractedString = parts[1].replace(/,/g, '')
|
|
66
|
-
|
|
67
|
-
if (!extractedString)
|
|
68
|
-
return []
|
|
69
|
-
|
|
70
|
-
const extractedParts = extractedString.split('.')
|
|
71
|
-
const regex = /\(([^)]+)\)/
|
|
72
|
-
|
|
73
|
-
return extractedParts.map((input) => {
|
|
74
|
-
const match = regex.exec(input)
|
|
75
|
-
const value = match ? match[1] : null
|
|
76
|
-
const field = input.replace(regex, '').replace(/\(|\)/g, '')
|
|
77
|
-
return { entity: field, charValue: value }
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const modelEntity: ModelElement[] = input
|
|
82
|
-
|
|
83
|
-
// You can now use the modelEntity array with type safety.
|
|
84
|
-
|
|
85
|
-
const fieldAssociation: { [key: string]: { [key: string]: string } } = {
|
|
86
|
-
mysql: {
|
|
87
|
-
string: 'varchar',
|
|
88
|
-
enum: 'varchar',
|
|
89
|
-
number: 'integer',
|
|
90
|
-
boolean: 'boolean',
|
|
91
|
-
text: 'text',
|
|
92
|
-
},
|
|
93
|
-
sqlite: {
|
|
94
|
-
string: 'text',
|
|
95
|
-
enum: 'text',
|
|
96
|
-
number: 'integer',
|
|
97
|
-
boolean: 'boolean',
|
|
98
|
-
text: 'text',
|
|
99
|
-
},
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const fieldEntity = [
|
|
103
|
-
'maxLength',
|
|
104
|
-
]
|
|
105
|
-
|
|
106
|
-
const excludeFieldEntity = [
|
|
107
|
-
'minLength',
|
|
108
|
-
'enum',
|
|
109
|
-
]
|
|
110
|
-
|
|
111
|
-
export { fieldEntity, fieldAssociation, modelEntity, excludeFieldEntity }
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import User from '../../../../../../app/Models/User'
|
|
2
|
-
import { fieldAssociation, fieldEntity, modelEntity } from './fields'
|
|
3
|
-
|
|
4
|
-
const file = Bun.file('user-migration.ts')
|
|
5
|
-
|
|
6
|
-
const driver = 'mysql'
|
|
7
|
-
|
|
8
|
-
const writer = file.writer()
|
|
9
|
-
|
|
10
|
-
writer.write('import { Kysely, sql } from \'kysely\'\n')
|
|
11
|
-
writer.write('import { db } from \'@stacksjs/database\'\n')
|
|
12
|
-
writer.write('\n')
|
|
13
|
-
writer.write('export async function up(db: Kysely<any>): Promise<void> {\n')
|
|
14
|
-
|
|
15
|
-
writer.write(' await db.schema\n')
|
|
16
|
-
writer.write(` .createTable('${User.table}')\n`)
|
|
17
|
-
|
|
18
|
-
writer.write(' .addColumn(\'id\', \'integer\', (col) => col.primaryKey())\n')
|
|
19
|
-
|
|
20
|
-
for (let modelIndex = 0; modelIndex < modelEntity.length; modelIndex++) {
|
|
21
|
-
const modelElement = modelEntity[modelIndex]
|
|
22
|
-
|
|
23
|
-
if (!modelElement)
|
|
24
|
-
continue
|
|
25
|
-
|
|
26
|
-
let entity = ''
|
|
27
|
-
let characteristic = ''
|
|
28
|
-
|
|
29
|
-
const isNullablePresent = modelElement.fieldArray.some(item => item.entity === 'nullable')
|
|
30
|
-
|
|
31
|
-
if (modelElement.default)
|
|
32
|
-
characteristic += `.defaultTo('${modelElement.default.toString()}')`
|
|
33
|
-
|
|
34
|
-
if (modelElement.unique)
|
|
35
|
-
characteristic += '.unique()'
|
|
36
|
-
|
|
37
|
-
if (!isNullablePresent)
|
|
38
|
-
characteristic += '.notNull()'
|
|
39
|
-
|
|
40
|
-
for (let fieldIndex = 0; fieldIndex < modelElement.fieldArray.length; fieldIndex++) {
|
|
41
|
-
const fieldArrayElement = modelElement.fieldArray[fieldIndex]
|
|
42
|
-
|
|
43
|
-
if (!fieldArrayElement)
|
|
44
|
-
continue
|
|
45
|
-
|
|
46
|
-
if (!fieldAssociation[driver])
|
|
47
|
-
continue
|
|
48
|
-
|
|
49
|
-
if (fieldAssociation[driver][fieldArrayElement.entity])
|
|
50
|
-
entity += `${fieldAssociation[driver][fieldArrayElement.entity]}`
|
|
51
|
-
|
|
52
|
-
fieldEntity.forEach((entityField) => {
|
|
53
|
-
if (fieldArrayElement.entity === entityField)
|
|
54
|
-
entity += `(${fieldArrayElement.charValue})`
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
const isMaxLengthPresent = modelElement.fieldArray.some(item => item.entity === 'maxLength')
|
|
58
|
-
|
|
59
|
-
if (fieldAssociation[driver][fieldArrayElement.entity] === 'varchar' && !isMaxLengthPresent)
|
|
60
|
-
entity += '(255)'
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
writer.write(` .addColumn('${modelElement.field}', '${entity}', (col) => col${characteristic})\n`)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
writer.write(' .addColumn(\'created_at\', \'timestamp\', (col) => col.defaultTo(sql`now()`).notNull())\n')
|
|
67
|
-
writer.write(' .execute()\n')
|
|
68
|
-
writer.write('}\n\n')
|
|
69
|
-
|
|
70
|
-
writer.write('process.exit(0)\n')
|
|
71
|
-
|
|
72
|
-
await writer.end()
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// import { generateMigrationFile } from '@stacksjs/database'
|
|
2
|
-
import User from '../../../../../../app/Models/User'
|
|
3
|
-
import { fieldAssociation, modelEntity } from './fields'
|
|
4
|
-
|
|
5
|
-
const file = Bun.file('user-migration.ts')
|
|
6
|
-
const writer = file.writer()
|
|
7
|
-
|
|
8
|
-
const driver = 'sqlite'
|
|
9
|
-
|
|
10
|
-
writer.write('import { Kysely, sql } from \'kysely\'\n')
|
|
11
|
-
writer.write('import { db } from \'@stacksjs/database\'\n')
|
|
12
|
-
writer.write('\n')
|
|
13
|
-
writer.write('export async function up(db: Kysely<any>): Promise<void> {\n')
|
|
14
|
-
|
|
15
|
-
writer.write(' await db.schema\n')
|
|
16
|
-
writer.write(` .createTable('${User.table}')\n`)
|
|
17
|
-
|
|
18
|
-
writer.write(' .addColumn(\'id\', \'integer\', (col) => col.primaryKey())\n')
|
|
19
|
-
|
|
20
|
-
for (let modelIndex = 0; modelIndex < modelEntity.length; modelIndex++) {
|
|
21
|
-
const modelElement = modelEntity[modelIndex]
|
|
22
|
-
|
|
23
|
-
if (!modelElement)
|
|
24
|
-
continue
|
|
25
|
-
|
|
26
|
-
let entity = ''
|
|
27
|
-
let characteristic = ''
|
|
28
|
-
|
|
29
|
-
const isNullablePresent = modelElement.fieldArray.some(item => item.entity === 'nullable')
|
|
30
|
-
|
|
31
|
-
if (modelElement.default)
|
|
32
|
-
characteristic += `.defaultTo('${modelElement.default.toString()}')`
|
|
33
|
-
|
|
34
|
-
if (modelElement.unique)
|
|
35
|
-
characteristic += '.unique()'
|
|
36
|
-
|
|
37
|
-
if (!isNullablePresent)
|
|
38
|
-
characteristic += '.notNull()'
|
|
39
|
-
|
|
40
|
-
for (let fieldIndex = 0; fieldIndex < modelElement.fieldArray.length; fieldIndex++) {
|
|
41
|
-
const fieldArrayElement = modelElement.fieldArray[fieldIndex]
|
|
42
|
-
|
|
43
|
-
if (!fieldArrayElement)
|
|
44
|
-
continue
|
|
45
|
-
|
|
46
|
-
if (!fieldAssociation[driver])
|
|
47
|
-
continue
|
|
48
|
-
|
|
49
|
-
if (fieldAssociation[driver][fieldArrayElement.entity])
|
|
50
|
-
entity += `${fieldAssociation[driver][fieldArrayElement.entity]}`
|
|
51
|
-
|
|
52
|
-
// fieldEntity.forEach((entityField) => {
|
|
53
|
-
// if (fieldArrayElement.entity === entityField)
|
|
54
|
-
// entity += `(${fieldArrayElement.charValue})`
|
|
55
|
-
// })
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
writer.write(` .addColumn('${modelElement.field}', '${entity}', (col) => col${characteristic})\n`)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
writer.write(' .addColumn(\'created_at\', \'timestamp\', (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`).notNull())\n')
|
|
62
|
-
writer.write(' .execute()\n')
|
|
63
|
-
writer.write('}\n\n')
|
|
64
|
-
|
|
65
|
-
writer.write('process.exit(0)\n')
|
|
66
|
-
|
|
67
|
-
await writer.end()
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// import { generateMigrationFile } from '@stacksjs/database'
|
|
2
|
-
// import { config } from '@stacksjs/config'
|
|
3
|
-
|
|
4
|
-
// const driver = config.database.default
|
|
5
|
-
const driver = 'sqlite'
|
|
6
|
-
|
|
7
|
-
if (driver === 'sqlite')
|
|
8
|
-
await import('./migration-sqlite.js')
|
|
9
|
-
else
|
|
10
|
-
await import('./migration-mysql.js')
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import process from 'node:process'
|
|
2
|
-
import type { Kysely } from 'kysely'
|
|
3
|
-
import { sql } from 'kysely'
|
|
4
|
-
import { db } from '@stacksjs/database'
|
|
5
|
-
import { ExitCode } from '@stacksjs/types'
|
|
6
|
-
|
|
7
|
-
export async function up(db: Kysely<any>): Promise<void> {
|
|
8
|
-
await db.schema
|
|
9
|
-
.createTable('users')
|
|
10
|
-
.addColumn('id', 'integer', col => col.primaryKey())
|
|
11
|
-
.addColumn('name', 'text', col => col.defaultTo('test').notNull())
|
|
12
|
-
.addColumn('email', 'text', col => col.defaultTo('test email').unique().notNull())
|
|
13
|
-
.addColumn('password', 'text', col => col.notNull())
|
|
14
|
-
.addColumn('created_at', 'timestamp', col => col.defaultTo(sql`CURRENT_TIMESTAMP`).notNull())
|
|
15
|
-
.execute()
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
await up(db)
|
|
19
|
-
|
|
20
|
-
process.exit(ExitCode.Success)
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { path as p } from '@stacksjs/path'
|
|
2
|
-
|
|
3
|
-
const modelGenerate = Bun.file('model-classes.ts') // Assuming Bun is imported properly
|
|
4
|
-
const file = Bun.file(p.projectStoragePath('framework/orm/UserModel.ts'))
|
|
5
|
-
|
|
6
|
-
const code = await modelGenerate.text()
|
|
7
|
-
|
|
8
|
-
const writer = file.writer()
|
|
9
|
-
|
|
10
|
-
writer.write(code)
|
|
11
|
-
|
|
12
|
-
await writer.end()
|
package/src/migrate/dns.ts
DELETED