@stacksjs/actions 0.59.11 → 0.61.0
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
package/src/domains/remove.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
+
import { parseOptions } from '@stacksjs/cli'
|
|
3
|
+
import { app } from '@stacksjs/config'
|
|
4
|
+
import { deleteHostedZoneRecords } from '@stacksjs/dns'
|
|
2
5
|
import { handleError } from '@stacksjs/error-handling'
|
|
3
6
|
import { logger } from '@stacksjs/logging'
|
|
4
|
-
import { deleteHostedZoneRecords } from '@stacksjs/dns'
|
|
5
|
-
import { app } from '@stacksjs/config'
|
|
6
|
-
import { parseOptions } from '@stacksjs/cli'
|
|
7
7
|
|
|
8
8
|
interface RemoveOptions {
|
|
9
9
|
domain?: string
|
|
@@ -19,15 +19,13 @@ const options: RemoveOptions = {
|
|
|
19
19
|
if (!options.domain) {
|
|
20
20
|
if (app.url) {
|
|
21
21
|
options.domain = app.url
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
22
|
+
} else {
|
|
24
23
|
handleError('there was no domain provided when')
|
|
25
24
|
process.exit(1)
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
if (options.verbose)
|
|
30
|
-
logger.log(`Removing domain: ${options.domain}`)
|
|
28
|
+
if (options.verbose) logger.log(`Removing domain: ${options.domain}`)
|
|
31
29
|
|
|
32
30
|
// const result = await deleteHostedZone(options.domain)
|
|
33
31
|
const result = await deleteHostedZoneRecords(options.domain)
|
package/src/examples.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
+
import { NpmScript } from '@stacksjs/enums'
|
|
2
3
|
import { log } from '@stacksjs/logging'
|
|
3
4
|
import { hasComponents } from '@stacksjs/storage'
|
|
4
|
-
import { runNpmScript } from '@stacksjs/utils'
|
|
5
5
|
import type { ExamplesOptions } from '@stacksjs/types'
|
|
6
6
|
import { ExitCode } from '@stacksjs/types'
|
|
7
|
-
import {
|
|
7
|
+
import { runNpmScript } from '@stacksjs/utils'
|
|
8
8
|
|
|
9
9
|
export async function invoke(options: ExamplesOptions) {
|
|
10
|
-
if (options.components || options.vue)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
else if (options.webComponents || options.elements)
|
|
14
|
-
await webComponentExample(options)
|
|
15
|
-
|
|
10
|
+
if (options.components || options.vue) await componentExample(options)
|
|
11
|
+
else if (options.webComponents || options.elements) await webComponentExample(options)
|
|
16
12
|
else
|
|
17
|
-
log.error(
|
|
13
|
+
log.error(
|
|
14
|
+
'An unsupported option was used. Please try again, check the documentation & report the issue, if needed.',
|
|
15
|
+
)
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
export async function examples(options: ExamplesOptions) {
|
|
@@ -25,8 +23,7 @@ export async function componentExample(options: ExamplesOptions) {
|
|
|
25
23
|
if (hasComponents()) {
|
|
26
24
|
await runNpmScript(NpmScript.ExampleVue, options)
|
|
27
25
|
log.success('Your component library was built successfully')
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
26
|
+
} else {
|
|
30
27
|
log.info('No components found.')
|
|
31
28
|
// todo: throw custom error here
|
|
32
29
|
}
|
|
@@ -37,8 +34,7 @@ export async function webComponentExample(options: ExamplesOptions) {
|
|
|
37
34
|
log.info('Building your Web Component library...')
|
|
38
35
|
await runNpmScript(NpmScript.BuildWebComponents, options)
|
|
39
36
|
log.success('Your Web Component library was built successfully')
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
37
|
+
} else {
|
|
42
38
|
log.info('No components found.')
|
|
43
39
|
// todo: throw custom error here
|
|
44
40
|
process.exit(ExitCode.FatalError)
|
package/src/find-projects.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import { findStacksProjects } from '@stacksjs/utils'
|
|
3
|
-
import { log } from '@stacksjs/logging'
|
|
4
2
|
import { parseOptions } from '@stacksjs/cli'
|
|
3
|
+
import { log } from '@stacksjs/logging'
|
|
4
|
+
import { findStacksProjects } from '@stacksjs/utils'
|
|
5
5
|
|
|
6
6
|
try {
|
|
7
7
|
const options = parseOptions()
|
|
@@ -9,13 +9,11 @@ try {
|
|
|
9
9
|
|
|
10
10
|
if (projects.length > 0) {
|
|
11
11
|
log.info('Found Projects:')
|
|
12
|
-
|
|
13
|
-
projects.forEach(project => console.log(` - ${project}`))
|
|
12
|
+
projects.forEach((project) => console.log(` - ${project}`))
|
|
14
13
|
process.exit()
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
log.info('No Stacks Projects found.')
|
|
18
|
-
}
|
|
19
|
-
catch (error: any) {
|
|
17
|
+
} catch (error: any) {
|
|
20
18
|
log.error('Error searching for Stacks projects:', error)
|
|
21
19
|
}
|
package/src/fresh.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import { ExitCode } from '@stacksjs/types'
|
|
3
2
|
import { runCommand } from '@stacksjs/cli'
|
|
3
|
+
import { handleError } from '@stacksjs/error-handling'
|
|
4
4
|
import { logger } from '@stacksjs/logging'
|
|
5
5
|
import { projectPath } from '@stacksjs/path'
|
|
6
|
+
import { ExitCode } from '@stacksjs/types'
|
|
6
7
|
import { cleanProject } from '@stacksjs/utils'
|
|
7
8
|
|
|
8
9
|
logger.log('Cleaning project...')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readdir } from 'node:fs/promises'
|
|
2
|
-
import { path as p } from '@stacksjs/path'
|
|
3
2
|
import { logger } from '@stacksjs/logging'
|
|
3
|
+
import { path as p } from '@stacksjs/path'
|
|
4
4
|
import { storage } from '@stacksjs/storage'
|
|
5
5
|
|
|
6
6
|
logger.log('Generating action types...')
|
|
@@ -14,12 +14,10 @@ const validActions = `// This file is auto-generated by Stacks. Do not edit this
|
|
|
14
14
|
//
|
|
15
15
|
// For more information, please visit: https://stacksjs.org/docs
|
|
16
16
|
|
|
17
|
-
export type ActionPath = ${
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
.join(' | ')
|
|
22
|
-
}
|
|
17
|
+
export type ActionPath = ${files
|
|
18
|
+
.filter((file) => file.endsWith('.ts'))
|
|
19
|
+
.map((value) => `'${domain}/${value.replace('.ts', '')}'`)
|
|
20
|
+
.join(' | ')}
|
|
23
21
|
`
|
|
24
22
|
|
|
25
23
|
await storage.writeFile(p.frameworkPath('types/actions.d.ts'), validActions)
|
|
@@ -10,10 +10,7 @@ import { generateComponentMeta } from '../helpers/component-meta'
|
|
|
10
10
|
|
|
11
11
|
log.info('Generating component meta...')
|
|
12
12
|
|
|
13
|
-
if (hasComponents())
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
else
|
|
17
|
-
log.info('No components found. Skipping component meta generation.')
|
|
13
|
+
if (hasComponents()) generateComponentMeta()
|
|
14
|
+
else log.info('No components found. Skipping component meta generation.')
|
|
18
15
|
|
|
19
16
|
log.success('Generated component meta.')
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import { ExitCode } from '@stacksjs/types'
|
|
3
|
-
import { writeTextFile } from '@stacksjs/storage'
|
|
4
|
-
import { projectPath } from '@stacksjs/path'
|
|
5
2
|
import { cli } from '@stacksjs/config'
|
|
3
|
+
import { log } from '@stacksjs/logging'
|
|
4
|
+
import { projectPath } from '@stacksjs/path'
|
|
5
|
+
import { writeTextFile } from '@stacksjs/storage'
|
|
6
|
+
import { ExitCode } from '@stacksjs/types'
|
|
6
7
|
|
|
7
8
|
log.info('Ensuring Component Library Entry Point...')
|
|
8
9
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { env as e, envEnum } from '@stacksjs/env'
|
|
2
|
+
import { logger } from '@stacksjs/logging'
|
|
1
3
|
import { path as p } from '@stacksjs/path'
|
|
2
4
|
import { storage } from '@stacksjs/storage'
|
|
3
|
-
import { env as e, enums } from '@stacksjs/env'
|
|
4
|
-
import { logger } from '@stacksjs/logging'
|
|
5
5
|
import { envKeys } from '../../../../env'
|
|
6
6
|
|
|
7
7
|
logger.log('Generating type env files...')
|
|
@@ -15,53 +15,48 @@ const envTypes = `
|
|
|
15
15
|
|
|
16
16
|
declare module 'bun' {
|
|
17
17
|
namespace env {
|
|
18
|
-
${envKeys
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
${envKeys
|
|
19
|
+
.map((key) => {
|
|
20
|
+
let type: string | undefined = typeof e[key]
|
|
21
|
+
let value: string | boolean | number | undefined = e[key]
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
if (!value) {
|
|
24
|
+
if (envEnum[key]) {
|
|
25
|
+
type = envEnum[key]?.map((item) => `'${item}'`).join(' | ')
|
|
26
|
+
value = envEnum[key]?.[0] // default to the first enum value
|
|
27
|
+
} else {
|
|
28
|
+
switch (type) {
|
|
29
|
+
case 'number':
|
|
30
|
+
value = '0'
|
|
31
|
+
break
|
|
32
|
+
case 'boolean':
|
|
33
|
+
value = false
|
|
34
|
+
break
|
|
35
|
+
default:
|
|
36
|
+
value = ''
|
|
37
|
+
}
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
type = 'string'
|
|
42
|
+
if (typeof value === 'string') {
|
|
43
|
+
if (value.toLowerCase() === 'true' || value.toLowerCase() === 'false') {
|
|
44
|
+
type = 'boolean'
|
|
45
|
+
} else if (!Number.isNaN(Number.parseFloat(value)) && Number.isFinite(Number(value))) {
|
|
46
|
+
type = 'number'
|
|
47
|
+
} else if (envEnum[key]) {
|
|
48
|
+
// @ts-expect-error envEnum[key] is defined
|
|
49
|
+
type = envEnum[key].map((item) => `'${item}'`).join(' | ')
|
|
50
|
+
}
|
|
51
|
+
} else if (typeof value === 'number') {
|
|
47
52
|
type = 'number'
|
|
53
|
+
} else if (typeof value === 'boolean') {
|
|
54
|
+
type = 'boolean'
|
|
48
55
|
}
|
|
49
|
-
else if (enums[key]) {
|
|
50
|
-
// @ts-expect-error enums[key] is defined
|
|
51
|
-
type = enums[key].map(item => `'${item}'`).join(' | ')
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
else if (typeof value === 'number') {
|
|
56
|
-
type = 'number'
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
else if (typeof value === 'boolean') {
|
|
60
|
-
type = 'boolean'
|
|
61
|
-
}
|
|
62
56
|
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
return `const ${key}: ${type}`
|
|
58
|
+
})
|
|
59
|
+
.join('\n ')}
|
|
65
60
|
}
|
|
66
61
|
}
|
|
67
62
|
`
|
|
@@ -78,7 +73,7 @@ const env = `
|
|
|
78
73
|
// For more information, please visit: https://stacksjs.org/docs
|
|
79
74
|
|
|
80
75
|
export const envKeys = [
|
|
81
|
-
${envKeys.map(key => `'${key}'`).join(',\n ')}
|
|
76
|
+
${envKeys.map((key) => `'${key}'`).join(',\n ')}
|
|
82
77
|
] as const
|
|
83
78
|
|
|
84
79
|
export type EnvKey = typeof envKeys[number]
|
|
@@ -12,7 +12,6 @@ import { generateVsCodeCustomData, generateWebTypes } from '../helpers/vscode-cu
|
|
|
12
12
|
if (hasComponents()) {
|
|
13
13
|
await generateWebTypes()
|
|
14
14
|
await generateVsCodeCustomData()
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
15
|
+
} else {
|
|
17
16
|
log.info('No components found. Skipping IDE helper generation.')
|
|
18
17
|
}
|
package/src/generate/index.ts
CHANGED
|
@@ -1,35 +1,23 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import {
|
|
2
|
+
import { runCommand } from '@stacksjs/cli'
|
|
3
3
|
import { Action, NpmScript } from '@stacksjs/enums'
|
|
4
|
+
import { log } from '@stacksjs/logging'
|
|
5
|
+
import { frameworkPath, projectPath } from '@stacksjs/path'
|
|
4
6
|
import type { GeneratorOptions } from '@stacksjs/types'
|
|
5
|
-
import { runCommand } from '@stacksjs/cli'
|
|
6
7
|
import { runNpmScript } from '@stacksjs/utils'
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
8
|
+
import { runAction } from '../helpers'
|
|
9
|
+
import { generateVsCodeCustomData as genVsCodeCustomData } from '../helpers/vscode-custom-data'
|
|
9
10
|
|
|
10
11
|
// import { files } from '@stacksjs/storage'
|
|
11
12
|
|
|
12
13
|
export async function invoke(options?: GeneratorOptions) {
|
|
13
|
-
if (options?.types)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
else if (options?.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
else if (options?.
|
|
20
|
-
await generateWebTypes(options)
|
|
21
|
-
|
|
22
|
-
else if (options?.customData)
|
|
23
|
-
await generateVsCodeCustomData(options)
|
|
24
|
-
|
|
25
|
-
else if (options?.ideHelpers)
|
|
26
|
-
await generateIdeHelpers(options)
|
|
27
|
-
|
|
28
|
-
else if (options?.componentMeta)
|
|
29
|
-
await generateComponentMeta(options)
|
|
30
|
-
|
|
31
|
-
else if (options?.coreSymlink)
|
|
32
|
-
await generateCoreSymlink()
|
|
14
|
+
if (options?.types) await generateTypes(options)
|
|
15
|
+
else if (options?.entries) await generateLibEntries(options)
|
|
16
|
+
else if (options?.webTypes) await generateWebTypes(options)
|
|
17
|
+
else if (options?.customData) await generateVsCodeCustomData(options)
|
|
18
|
+
else if (options?.ideHelpers) await generateIdeHelpers(options)
|
|
19
|
+
else if (options?.componentMeta) await generateComponentMeta(options)
|
|
20
|
+
else if (options?.coreSymlink) await generateCoreSymlink()
|
|
33
21
|
}
|
|
34
22
|
|
|
35
23
|
export function generate(options: GeneratorOptions) {
|
|
@@ -62,17 +50,15 @@ export async function generateWebTypes(options?: GeneratorOptions) {
|
|
|
62
50
|
}
|
|
63
51
|
|
|
64
52
|
export async function generateVsCodeCustomData(options?: GeneratorOptions) {
|
|
65
|
-
const result = await
|
|
66
|
-
cwd: frameworkPath(),
|
|
67
|
-
...options,
|
|
68
|
-
})
|
|
53
|
+
const result = await genVsCodeCustomData()
|
|
69
54
|
|
|
70
55
|
if (result.isErr()) {
|
|
71
56
|
log.error('There was an error generating the custom-elements.json file.', result.error)
|
|
72
57
|
process.exit()
|
|
73
58
|
}
|
|
74
59
|
|
|
75
|
-
await runAction(Action.LintFix, { verbose: true }) // the generated json file needs to be linted
|
|
60
|
+
await runAction(Action.LintFix, { verbose: true }) // because the generated json file needs to be linted
|
|
61
|
+
|
|
76
62
|
log.success('Successfully generated the custom-elements.json file')
|
|
77
63
|
}
|
|
78
64
|
|
|
@@ -89,7 +75,7 @@ export async function generateIdeHelpers(options?: GeneratorOptions) {
|
|
|
89
75
|
}
|
|
90
76
|
|
|
91
77
|
export async function generateComponentMeta(options?: GeneratorOptions) {
|
|
92
|
-
const result = await
|
|
78
|
+
const result = await genVsCodeCustomData()
|
|
93
79
|
|
|
94
80
|
if (result.isErr()) {
|
|
95
81
|
log.error('There was an error generating your component meta information.', result.error)
|
|
@@ -114,16 +100,6 @@ export async function generateTypes(options?: GeneratorOptions) {
|
|
|
114
100
|
log.success('Types were generated successfully')
|
|
115
101
|
}
|
|
116
102
|
|
|
117
|
-
export function generateMigrations() {
|
|
118
|
-
// const path = frameworkPath('database/schema.prisma')
|
|
119
|
-
|
|
120
|
-
// await migrate(path, { database: database.driver })
|
|
121
|
-
|
|
122
|
-
// await runCommand(`bunx prisma migrate dev --schema=${path}`)
|
|
123
|
-
|
|
124
|
-
log.success('Successfully updated migrations')
|
|
125
|
-
}
|
|
126
|
-
|
|
127
103
|
export function generatePkgxConfig() {
|
|
128
104
|
// write the yaml string to a file in your project root
|
|
129
105
|
// files.put(projectPath('./pkgx.yaml'), yamlStr)
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { log } from '@stacksjs/logging'
|
|
3
2
|
import { library } from '@stacksjs/config'
|
|
3
|
+
import { log } from '@stacksjs/logging'
|
|
4
4
|
import { hasComponents, hasFunctions } from '@stacksjs/storage'
|
|
5
5
|
import { generateLibEntry } from '../helpers/lib-entries'
|
|
6
6
|
|
|
7
7
|
if (library.releaseable && hasComponents()) {
|
|
8
8
|
await generateLibEntry('vue-components')
|
|
9
9
|
await generateLibEntry('web-components')
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
10
|
+
} else {
|
|
12
11
|
log.info('No components found. Skipping building component entry points.')
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
if (library.releaseable && hasFunctions())
|
|
16
|
-
|
|
17
|
-
else
|
|
18
|
-
log.info('No functions found. Skipping building function entry point.')
|
|
14
|
+
if (library.releaseable && hasFunctions()) await generateLibEntry('functions')
|
|
15
|
+
else log.info('No functions found. Skipping building function entry point.')
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { log, runCommand } from '@stacksjs/cli'
|
|
1
2
|
// generates the pkgx file based on the user configuration
|
|
2
3
|
import { config } from '@stacksjs/config'
|
|
3
|
-
import { runCommand } from '@stacksjs/cli'
|
|
4
4
|
|
|
5
5
|
// @ts-expect-error - no types
|
|
6
6
|
import data from '../../../../../pkgx.yaml'
|
|
7
7
|
|
|
8
|
-
if (!data)
|
|
9
|
-
throw new Error('pkgx.yaml file not found')
|
|
8
|
+
if (!data) throw new Error('pkgx.yaml file not found')
|
|
10
9
|
|
|
11
10
|
if (data.dependencies['aws.amazon.com/cdk'] === undefined) {
|
|
12
11
|
log.info('aws.amazon.com/cdk dependency not found in pkgx.yaml.')
|
|
@@ -27,16 +26,14 @@ if (data.dependencies['bun.sh'] === undefined) {
|
|
|
27
26
|
log.info('bun.sh dependency not found in pkgx.yaml.')
|
|
28
27
|
// throw an error unless its installed locally
|
|
29
28
|
const result = await runCommand('which aws')
|
|
30
|
-
if (result.isErr())
|
|
31
|
-
throw new Error('bun.sh dependency not found in pkgx.yaml. To confirm, run `which bun`')
|
|
29
|
+
if (result.isErr()) throw new Error('bun.sh dependency not found in pkgx.yaml. To confirm, run `which bun`')
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
if (data.dependencies['info-zip.org/zip'] === undefined) {
|
|
35
33
|
log.info('info-zip.org/zip dependency not found in pkgx.yaml.')
|
|
36
34
|
// throw an error unless its installed locally
|
|
37
35
|
const result = await runCommand('which zip')
|
|
38
|
-
if (result.isErr())
|
|
39
|
-
throw new Error('info-zip.org/zip dependency not found in pkgx.yaml. To confirm, run `which zip`')
|
|
36
|
+
if (result.isErr()) throw new Error('info-zip.org/zip dependency not found in pkgx.yaml. To confirm, run `which zip`')
|
|
40
37
|
}
|
|
41
38
|
|
|
42
39
|
if (data.dependencies['info-zip.org/unzip'] === undefined) {
|
|
@@ -59,14 +56,12 @@ if (data.dependencies['redis.io'] === undefined) {
|
|
|
59
56
|
log.info('redis.io dependency not found in pkgx.yaml.')
|
|
60
57
|
// throw an error unless its installed locally
|
|
61
58
|
const result = await runCommand('which redis')
|
|
62
|
-
if (result.isErr())
|
|
63
|
-
throw new Error('redis.io dependency not found in pkgx.yaml. To confirm, run `which redis`')
|
|
59
|
+
if (result.isErr()) throw new Error('redis.io dependency not found in pkgx.yaml. To confirm, run `which redis`')
|
|
64
60
|
}
|
|
65
61
|
|
|
66
62
|
if (config.database.default === 'sqlite' && data.dependencies['sqlite.org'] === undefined) {
|
|
67
63
|
log.info('sqlite.org dependency not found in pkgx.yaml.')
|
|
68
64
|
// throw an error unless its installed locally
|
|
69
65
|
const result = await runCommand('which sqlite')
|
|
70
|
-
if (result.isErr())
|
|
71
|
-
throw new Error('sqlite.org dependency not found in pkgx.yaml. To confirm, run `which sqlite`')
|
|
66
|
+
if (result.isErr()) throw new Error('sqlite.org dependency not found in pkgx.yaml. To confirm, run `which sqlite`')
|
|
72
67
|
}
|
|
@@ -11,9 +11,7 @@ import { generateVsCodeCustomData } from '../helpers/vscode-custom-data'
|
|
|
11
11
|
|
|
12
12
|
log.info('Generating VS Code custom data...')
|
|
13
13
|
|
|
14
|
-
if (hasComponents())
|
|
15
|
-
await generateVsCodeCustomData()
|
|
16
|
-
|
|
14
|
+
if (hasComponents()) await generateVsCodeCustomData()
|
|
17
15
|
else log.info('No components found. Skipping VS Code custom data generation.')
|
|
18
16
|
|
|
19
17
|
log.success('Generated VS Code custom data.')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { frameworkPath, join,
|
|
1
|
+
import { path, frameworkPath, join, projectPath } from '@stacksjs/path'
|
|
2
2
|
import { existsSync, glob, mkdirSync, writeFileSync } from '@stacksjs/storage'
|
|
3
3
|
import MarkdownIt from 'markdown-it'
|
|
4
4
|
import { type ComponentMeta, type MetaCheckerOptions, createComponentMetaChecker } from 'vue-component-meta'
|
|
@@ -21,10 +21,7 @@ export function generateComponentMeta() {
|
|
|
21
21
|
printer: { newLine: 1 },
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const tsconfigChecker = createComponentMetaChecker(
|
|
25
|
-
projectPath('tsconfig.json'),
|
|
26
|
-
checkerOptions,
|
|
27
|
-
)
|
|
24
|
+
const tsconfigChecker = createComponentMetaChecker(projectPath('tsconfig.json'), checkerOptions)
|
|
28
25
|
|
|
29
26
|
const filterMeta = (meta: ComponentMeta): ComponentApi => {
|
|
30
27
|
// const clonedMeta: ComponentMeta = JSON.parse(JSON.stringify(meta))
|
|
@@ -32,8 +29,7 @@ export function generateComponentMeta() {
|
|
|
32
29
|
// Exclude global props
|
|
33
30
|
const props: ComponentApiProps[] = []
|
|
34
31
|
meta.props.forEach((prop) => {
|
|
35
|
-
if (prop?.global)
|
|
36
|
-
return
|
|
32
|
+
if (prop?.global) return
|
|
37
33
|
|
|
38
34
|
const { name, description, required, type, default: defaultValue } = prop
|
|
39
35
|
|
|
@@ -55,22 +51,21 @@ export function generateComponentMeta() {
|
|
|
55
51
|
}
|
|
56
52
|
}
|
|
57
53
|
|
|
58
|
-
const components = glob.sync(['components/*.stx', 'components/**/*.stx'], {
|
|
54
|
+
const components = glob.sync(['components/*.stx', 'components/**/*.stx', 'components/*.vue', 'components/**/*.vue'], {
|
|
59
55
|
cwd: projectPath(),
|
|
60
56
|
absolute: true,
|
|
61
57
|
})
|
|
62
58
|
|
|
63
59
|
components.forEach((componentPath) => {
|
|
64
60
|
// Thanks: https://futurestud.io/tutorials/node-js-get-a-file-name-with-or-without-extension
|
|
65
|
-
const componentExportName = parse(componentPath).name
|
|
61
|
+
const componentExportName = path.parse(componentPath).name
|
|
66
62
|
const meta = filterMeta(tsconfigChecker.getComponentMeta(componentPath, componentExportName))
|
|
67
63
|
|
|
68
64
|
const metaDirPath = frameworkPath('component-meta')
|
|
69
65
|
|
|
70
66
|
// if meta dir doesn't exist create
|
|
71
67
|
|
|
72
|
-
if (!existsSync(metaDirPath))
|
|
73
|
-
mkdirSync(metaDirPath)
|
|
68
|
+
if (!existsSync(metaDirPath)) mkdirSync(metaDirPath)
|
|
74
69
|
|
|
75
70
|
const metaJsonFilePath = join(metaDirPath, `${componentExportName}.json`)
|
|
76
71
|
writeFileSync(metaJsonFilePath, JSON.stringify(meta, null, 4))
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
2
|
import { log } from '@stacksjs/logging'
|
|
3
|
-
import { kebabCase } from '@stacksjs/strings'
|
|
4
3
|
import type { LibraryType } from '@stacksjs/path'
|
|
5
4
|
import { componentsPath, functionsPath, libraryEntryPath } from '@stacksjs/path'
|
|
6
5
|
import { writeTextFile } from '@stacksjs/storage'
|
|
7
|
-
import {
|
|
6
|
+
import { kebabCase } from '@stacksjs/strings'
|
|
8
7
|
import { ExitCode } from '@stacksjs/types'
|
|
8
|
+
import { determineResetPreset } from '@stacksjs/utils'
|
|
9
9
|
import library from '~/config/library'
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -19,14 +19,11 @@ export async function generateLibEntry(type: LibraryType) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export async function createLibraryEntryPoint(type: LibraryType) {
|
|
22
|
-
if (type === 'vue-components')
|
|
23
|
-
await createVueLibraryEntryPoint()
|
|
22
|
+
if (type === 'vue-components') await createVueLibraryEntryPoint()
|
|
24
23
|
|
|
25
|
-
if (type === 'web-components')
|
|
26
|
-
await createWebComponentLibraryEntryPoint()
|
|
24
|
+
if (type === 'web-components') await createWebComponentLibraryEntryPoint()
|
|
27
25
|
|
|
28
|
-
if (type === 'functions')
|
|
29
|
-
await createFunctionLibraryEntryPoint()
|
|
26
|
+
if (type === 'functions') await createFunctionLibraryEntryPoint()
|
|
30
27
|
}
|
|
31
28
|
|
|
32
29
|
export async function createVueLibraryEntryPoint(type: LibraryType = 'vue-components') {
|
|
@@ -75,16 +72,18 @@ export function generateEntryPointData(type: LibraryType): string {
|
|
|
75
72
|
let arr = []
|
|
76
73
|
|
|
77
74
|
if (type === 'functions') {
|
|
78
|
-
if (!library.functions?.
|
|
79
|
-
log.error(
|
|
75
|
+
if (!library.functions?.files) {
|
|
76
|
+
log.error(
|
|
77
|
+
new Error(
|
|
78
|
+
'There are no functions defined to be built. Please check your config/library.ts file for potential adjustments',
|
|
79
|
+
),
|
|
80
|
+
)
|
|
80
81
|
process.exit()
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
for (const fx of library.functions
|
|
84
|
-
if (Array.isArray(fx))
|
|
85
|
-
|
|
86
|
-
else
|
|
87
|
-
arr.push(`export * from '${functionsPath(fx)}'`)
|
|
84
|
+
for (const fx of library.functions.files) {
|
|
85
|
+
if (Array.isArray(fx)) arr.push(`export * as ${fx[1]} from '${functionsPath(fx[0])}'`)
|
|
86
|
+
else arr.push(`export * from '${functionsPath(fx)}'`)
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
// join the array into a string with each element being on a new line
|
|
@@ -93,17 +92,20 @@ export function generateEntryPointData(type: LibraryType): string {
|
|
|
93
92
|
|
|
94
93
|
if (type === 'vue-components') {
|
|
95
94
|
if (!library.vueComponents?.tags) {
|
|
96
|
-
log.error(
|
|
95
|
+
log.error(
|
|
96
|
+
new Error(
|
|
97
|
+
'There are no components defined to be built. Please check your config/library.ts file for potential adjustments',
|
|
98
|
+
),
|
|
99
|
+
)
|
|
97
100
|
process.exit()
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
arr = determineResetPreset()
|
|
101
104
|
|
|
102
|
-
for (const component of library.vueComponents
|
|
105
|
+
for (const component of library.vueComponents.tags.map((tag) => tag.name)) {
|
|
103
106
|
if (Array.isArray(component))
|
|
104
107
|
arr.push(`export { default as ${component[1]} } from '${componentsPath(component[0])}.stx'`)
|
|
105
|
-
else
|
|
106
|
-
arr.push(`export { default as ${component} } from '${componentsPath(component)}.stx'`)
|
|
108
|
+
else arr.push(`export { default as ${component} } from '${componentsPath(component)}.stx'`)
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
// join the array into a string with each element being on a new line
|
|
@@ -112,22 +114,25 @@ export function generateEntryPointData(type: LibraryType): string {
|
|
|
112
114
|
|
|
113
115
|
// at this point, we know it is a Web Component we are building
|
|
114
116
|
arr = determineResetPreset()
|
|
115
|
-
const imports = [...arr,
|
|
117
|
+
const imports = [...arr, "import { defineCustomElement } from 'vue'"]
|
|
116
118
|
const declarations = []
|
|
117
119
|
const definitions = []
|
|
118
120
|
|
|
119
121
|
if (!library.webComponents?.tags) {
|
|
120
|
-
log.error(
|
|
122
|
+
log.error(
|
|
123
|
+
new Error(
|
|
124
|
+
'There are no components defined to be built. Please check your config/library.ts file for potential adjustments',
|
|
125
|
+
),
|
|
126
|
+
)
|
|
121
127
|
process.exit()
|
|
122
128
|
}
|
|
123
129
|
|
|
124
|
-
for (const component of library.webComponents
|
|
130
|
+
for (const component of library.webComponents.tags.map((tag) => tag.name)) {
|
|
125
131
|
if (Array.isArray(component)) {
|
|
126
132
|
imports.push(`import ${component[1]} from '${componentsPath(component[0])}.stx'`)
|
|
127
133
|
declarations.push(`const ${component[1]}CustomElement = defineCustomElement(${component[1]})`)
|
|
128
|
-
definitions.push(`customElements.define('${kebabCase(component[1])}', ${component[1]}CustomElement)`)
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
134
|
+
definitions.push(`customElements.define('${kebabCase(component[1] as string)}', ${component[1]}CustomElement)`)
|
|
135
|
+
} else {
|
|
131
136
|
imports.push(`import ${component} from '${componentsPath(component)}.stx'`)
|
|
132
137
|
declarations.push(`const ${component}CustomElement = defineCustomElement(${component})`)
|
|
133
138
|
definitions.push(`customElements.define('${kebabCase(component)}', ${component}CustomElement)`)
|