Skip to content

Commit 0d5c9fc

Browse files
committed
chore: wip
1 parent a1dea74 commit 0d5c9fc

File tree

45 files changed

+241
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+241
-243
lines changed

.stacks/core/actions/src/database/fields.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,60 @@ const fieldkeys = Object.keys(fields)
77
const input = [
88
{
99
field: 'name',
10-
rule: 'validate.string().maxLength(50).nullable()'
10+
rule: 'validate.string().maxLength(50).nullable()',
1111
},
1212
{
1313
field: 'status',
14-
rule: 'validate.string().maxLength(50).nullable()'
14+
rule: 'validate.string().maxLength(50).nullable()',
1515
},
1616
{
1717
field: 'email',
18-
rule: 'validate.string().maxLength(50).nullable()'
18+
rule: 'validate.string().maxLength(50).nullable()',
1919
},
2020
{
2121
field: 'password',
22-
rule: 'validate.string().maxLength(50).nullable()'
23-
}
22+
rule: 'validate.string().maxLength(50).nullable()',
23+
},
2424
]
2525

26-
2726
const modelEntity = input.map((item) => {
2827
// Split the input string by "validate."
29-
const parts = item.rule.split('validate.');
28+
const parts = item.rule.split('validate.')
3029

3130
// Extract the string after "validate."
32-
const extractedString = parts[1];
31+
const extractedString = parts[1]
3332

3433
if (extractedString) {
3534
// Split the input string by periods (.)
36-
const extractedParts = extractedString.split('.');
35+
const extractedParts = extractedString.split('.')
3736

38-
const regex = /\(([^)]+)\)/;
37+
const regex = /\(([^)]+)\)/
3938

40-
const fieldArray = extractedParts.map(input => {
39+
const fieldArray = extractedParts.map((input) => {
4140
// Use the regular expression to extract values inside parentheses
42-
const match = regex.exec(input);
43-
const value = match ? match[1] : null;
44-
41+
const match = regex.exec(input)
42+
const value = match ? match[1] : null
43+
4544
// Remove the parentheses from the string
46-
const field = input.replace(regex, '').replace(/\(|\)/g, '');;
45+
const field = input.replace(regex, '').replace(/\(|\)/g, '')
4746

48-
return { entity: field, charValue: value };
49-
});
47+
return { entity: field, charValue: value }
48+
})
5049

5150
return { field: item.field, fieldArray }
5251
}
5352
})
5453

55-
5654
const fieldAssociation: { [key: string]: string } = {
5755
string: 'varchar',
5856
number: 'integer',
5957
boolean: 'boolean',
60-
text: 'text'
61-
};
58+
text: 'text',
59+
}
6260

6361
const fieldEntity = [
6462
'maxLength',
6563
'minLength',
6664
]
6765

68-
69-
export { fieldEntity, fieldAssociation, modelEntity }
66+
export { fieldEntity, fieldAssociation, modelEntity }

.stacks/core/actions/src/database/migration.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// import { generateMigrationFile } from '@stacksjs/database'
22
import User from '../../../../../app/models/User'
3-
import { modelEntity, fieldAssociation, fieldEntity } from './fields'
3+
import { fieldAssociation, fieldEntity, modelEntity } from './fields'
44

55
const file = Bun.file('user-migration.ts')
66
const writer = file.writer()
@@ -14,31 +14,30 @@ writer.write(' await db.schema \n')
1414
writer.write(` .createTable('${User.table}') \n`)
1515

1616
for (let modelIndex = 0; modelIndex < modelEntity.length; modelIndex++) {
17-
const modelElement: any = modelEntity[modelIndex];
17+
const modelElement: any = modelEntity[modelIndex]
1818

19-
let entity = '';
19+
let entity = ''
2020

2121
for (let fieldIndex = 0; fieldIndex < modelElement.fieldArray.length; fieldIndex++) {
22-
const fieldArrayElement = modelElement.fieldArray[fieldIndex];
22+
const fieldArrayElement = modelElement.fieldArray[fieldIndex]
2323

2424
console.log(fieldArrayElement)
2525

26-
if (fieldAssociation[fieldArrayElement.entity]) {
27-
entity += `${fieldAssociation[fieldArrayElement.entity]}`;
28-
}
26+
if (fieldAssociation[fieldArrayElement.entity])
27+
entity += `${fieldAssociation[fieldArrayElement.entity]}`
2928

30-
if (fieldArrayElement.charValue)
31-
entity += `(${fieldArrayElement.charValue})`;
29+
if (fieldArrayElement.charValue)
30+
entity += `(${fieldArrayElement.charValue})`
3231

3332
fieldEntity.forEach((entity) => {
3433
if (fieldArrayElement.entity === entity) {
3534
console.log(fieldArrayElement.charValue)
36-
entity += `(${fieldArrayElement.charValue})`;
35+
entity += `(${fieldArrayElement.charValue})`
3736
}
3837
})
3938
}
4039

41-
writer.write(` .addColumn('${modelElement.field}', '${entity}', (col) => col.notNull()) \n`);
40+
writer.write(` .addColumn('${modelElement.field}', '${entity}', (col) => col.notNull()) \n`)
4241
}
4342

4443
writer.write(' .addColumn(\'created_at\', \'timestamp\', (col) => col.defaultTo(sql`now()`).notNull()) \n')
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { Kysely, sql } from 'kysely'
2-
import { db } from '@stacksjs/database'
3-
4-
export async function up(db: Kysely<any>): Promise<void> {
5-
await db.schema
6-
.createTable('users')
7-
.addColumn('name', 'varchar(50)', (col) => col.notNull())
8-
.addColumn('status', 'varchar(50)', (col) => col.notNull())
9-
.addColumn('email', 'varchar(50)', (col) => col.notNull())
10-
.addColumn('password', 'varchar(50)', (col) => col.notNull())
11-
.addColumn('created_at', 'timestamp', (col) => col.defaultTo(sql`now()`).notNull())
12-
.execute()
13-
}
1+
import type { Kysely } from 'kysely'
2+
import { sql } from 'kysely'
143

15-
process.exit(0)
4+
export async function up(db: Kysely<any>): Promise<void> {
5+
await db.schema
6+
.createTable('users')
7+
.addColumn('name', 'varchar(50)', col => col.notNull())
8+
.addColumn('status', 'varchar(50)', col => col.notNull())
9+
.addColumn('email', 'varchar(50)', col => col.notNull())
10+
.addColumn('password', 'varchar(50)', col => col.notNull())
11+
.addColumn('created_at', 'timestamp', col => col.defaultTo(sql`now()`).notNull())
12+
.execute()
13+
}
14+
15+
process.exit(0)

.stacks/core/actions/src/domains/add.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const nameservers = result.value
2121

2222
console.log('')
2323
console.log('✅ Added your domain')
24-
console.log(' Nameservers: ' + nameservers.join(', '))
25-
console.log(' Cached in: ' + projectStoragePath('framework/cache/nameservers.txt'))
24+
console.log(` Nameservers: ${nameservers.join(', ')}`)
25+
console.log(` Cached in: ${projectStoragePath('framework/cache/nameservers.txt')}`)
2626
console.log('')
2727
console.log(italic('Please update your domain nameservers to the above values.'))

.stacks/core/actions/src/generate/env-files.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { path as p } from '@stacksjs/path'
22
import { storage } from '@stacksjs/storage'
3-
import { enums, env as e } from '@stacksjs/env'
3+
import { env as e, enums } from '@stacksjs/env'
44
import { envKeys } from '~/storage/framework/stacks/env'
55

66
console.log('Generating type env files...')
@@ -22,7 +22,8 @@ declare module 'bun' {
2222
if (enums[key]) {
2323
type = enums[key]?.map(item => `'${item}'`).join(' | ')
2424
value = enums[key]?.[0] // default to the first enum value
25-
} else {
25+
}
26+
else {
2627
switch (type) {
2728
case 'number':
2829
value = '0'
@@ -40,19 +41,19 @@ declare module 'bun' {
4041
if (typeof value === 'string') {
4142
if (value.toLowerCase() === 'true' || value.toLowerCase() === 'false') {
4243
type = 'boolean'
43-
} else if (!isNaN(parseFloat(value)) && isFinite(Number(value))) {
44+
}
45+
else if (!isNaN(Number.parseFloat(value)) && isFinite(Number(value))) {
4446
type = 'number'
45-
} else if (enums[key]) {
46-
// @ts-ignore
47+
}
48+
else if (enums[key]) {
49+
// @ts-expect-error
4750
type = enums[key].map(item => `'${item}'`).join(' | ')
4851
}
4952
}
5053
51-
else if (typeof value === 'number')
52-
type = 'number'
54+
else if (typeof value === 'number') { type = 'number' }
5355
54-
else if (typeof value === 'boolean')
55-
type = 'boolean'
56+
else if (typeof value === 'boolean') { type = 'boolean' }
5657
5758
return `const ${key}: ${type}`
5859
}).join('\n ')}

.stacks/core/arrays/src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T> {
2525
}
2626

2727
/**
28-
* Flatten `Arrayable<T>` to `Array<T>`
28+
* Flatten `Arrayable<T>` to `Array<T>`
2929
*
3030
* @category Array
3131
* @example

.stacks/core/buddy/src/commands/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export function build(buddy: CLI) {
136136
const result = await runAction(Action.BuildStacks, options)
137137

138138
if (result.isErr()) {
139-
log.error('Failed to build Stacks.', result.error as Error)
139+
log.error('Failed to build Stacks.', result.error)
140140
process.exit()
141141
}
142142

.stacks/core/buddy/src/commands/changelog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function changelog(buddy: CLI) {
2020
const result = await runAction(Action.Changelog, options)
2121

2222
if (result.isErr()) {
23-
await outro('While running the changelog command, there was an issue', { ...options, startTime: perf, useSeconds: true, isError: true }, result.error as Error)
23+
await outro('While running the changelog command, there was an issue', { ...options, startTime: perf, useSeconds: true, isError: true }, result.error)
2424
process.exit()
2525
}
2626

.stacks/core/buddy/src/commands/inspire.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function inspire(buddy: CLI) {
1313
const result = await runAction(Action.Inspire)
1414

1515
if (result.isErr()) {
16-
await outro('While running the inspire command, there was an issue', { startTime: perf, useSeconds: true, isError: true }, result.error as Error)
16+
await outro('While running the inspire command, there was an issue', { startTime: perf, useSeconds: true, isError: true }, result.error)
1717
process.exit()
1818
}
1919

.stacks/core/buddy/src/commands/key.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function key(buddy: CLI) {
1818
const result = await runAction(Action.KeyGenerate, options)
1919

2020
if (result.isErr()) {
21-
log.error('Failed to set random application key.', result.error as Error)
21+
log.error('Failed to set random application key.', result.error)
2222
process.exit()
2323
}
2424

0 commit comments

Comments
 (0)