@stacksjs/actions 0.58.47 → 0.58.49
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/src/generate/ide-helpers.js +1 -0
- package/dist/src/generate/lib-entries.js +4 -2
- package/dist/src/generate/vscode-custom-data.js +1 -0
- package/dist/src/helpers/lib-entries.js +1 -0
- package/dist/src/helpers/package-json.js +1 -0
- package/dist/src/helpers/vscode-custom-data.js +1 -0
- package/dist/src/upgrade.js +1 -1
- package/package.json +18 -17
- package/src/action.ts +11 -0
- package/src/actions.ts +2 -0
- package/src/add.ts +27 -0
- package/src/ai/request-model-access.ts +74 -0
- package/src/build/cli.ts +7 -0
- package/src/build/component-libs.ts +5 -0
- package/src/build/core.ts +34 -0
- package/src/build/desktop.ts +7 -0
- package/src/build/docs.ts +7 -0
- package/src/build/stacks.ts +7 -0
- package/src/build.ts +89 -0
- package/src/bump.ts +11 -0
- package/src/cdn/invalidate-cache.ts +27 -0
- package/src/changelog.ts +11 -0
- package/src/clean.ts +6 -0
- package/src/commit.ts +14 -0
- package/src/copy-types.ts +22 -0
- package/src/database/fields.ts +111 -0
- package/src/database/migration-mysql.ts +72 -0
- package/src/database/migration-sqlite.ts +67 -0
- package/src/database/migration.ts +10 -0
- package/src/database/mydb.sqlite +0 -0
- package/src/database/seed.ts +4 -0
- package/src/database/stacks.sqlite +0 -0
- package/src/database/user-migration.ts +20 -0
- package/src/deploy/create-receipt-rule.ts +55 -0
- package/src/deploy/index.ts +46 -0
- package/src/dev/api.ts +19 -0
- package/src/dev/components.ts +14 -0
- package/src/dev/dashboard.ts +7 -0
- package/src/dev/desktop.ts +7 -0
- package/src/dev/docs.ts +7 -0
- package/src/dev/index.ts +48 -0
- package/src/dev/system-tray.ts +6 -0
- package/src/dev/views.ts +7 -0
- package/src/domains/add.ts +82 -0
- package/src/domains/purchase.ts +76 -0
- package/src/domains/remove.ts +38 -0
- package/src/examples.ts +46 -0
- package/src/fresh.ts +20 -0
- package/src/generate/caddyfile.ts +1 -0
- package/src/generate/component-meta.ts +19 -0
- package/src/generate/env-files.ts +89 -0
- package/src/generate/ide-helpers.ts +18 -0
- package/src/generate/index.ts +132 -0
- package/src/generate/lib-entries.ts +18 -0
- package/src/generate/model-classes.ts +299 -0
- package/src/generate/model-generate.ts +12 -0
- package/src/generate/pkgx-file.ts +72 -0
- package/src/generate/types.ts +6 -0
- package/src/generate/vscode-custom-data.ts +19 -0
- package/src/generate/web-types.ts +2 -0
- package/src/helpers/component-meta.ts +93 -0
- package/src/helpers/index.ts +1 -0
- package/src/helpers/lib-entries.ts +139 -0
- package/src/helpers/package-json.ts +96 -0
- package/src/helpers/utils.ts +82 -0
- package/src/helpers/vscode-custom-data.ts +35 -0
- package/src/index.ts +29 -0
- package/src/key-generate.ts +10 -0
- package/src/lint/fix.ts +7 -0
- package/src/lint/index.ts +27 -0
- package/src/make.ts +322 -0
- package/src/migrate/database.ts +1 -0
- package/src/migrate/dns.ts +3 -0
- package/src/prepublish.ts +17 -0
- package/src/release.ts +15 -0
- package/src/start-caddy.ts +13 -0
- package/src/test/coverage.ts +5 -0
- package/src/test/feature.ts +5 -0
- package/src/test/ui.ts +5 -0
- package/src/test/unit.ts +5 -0
- package/src/test.ts +5 -0
- package/src/tinker.ts +10 -0
- package/src/typecheck.ts +5 -0
- package/src/types.ts +20 -0
- package/src/upgrade/bun.ts +4 -0
- package/src/upgrade/dependencies.ts +0 -0
- package/src/upgrade/framework.ts +30 -0
- package/src/upgrade/index.ts +21 -0
- package/src/upgrade.ts +65 -0
- package/src/zip/api.ts +22 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { frameworkPath, join, parse, projectPath } from '@stacksjs/path'
|
|
2
|
+
import { existsSync, glob, mkdirSync, writeFileSync } from '@stacksjs/storage'
|
|
3
|
+
import MarkdownIt from 'markdown-it'
|
|
4
|
+
import { type ComponentMeta, type MetaCheckerOptions, createComponentMetaChecker } from 'vue-component-meta'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ℹ️ Useful Links
|
|
8
|
+
*
|
|
9
|
+
* vue-component-meta tests: https://github.com/johnsoncodehk/volar/blob/master/vue-language-tools/vue-component-meta/tests/index.spec.ts
|
|
10
|
+
* Discord thread about improving vue-component-meta: https://discord.com/channels/793943652350427136/1027819645677350912
|
|
11
|
+
* GitHub issue for improving vue-component-meta based on runtime/dynamic props: https://github.com/johnsoncodehk/volar/issues/1854
|
|
12
|
+
* Discord chat: https://discord.com/channels/793943652350427136/1027819645677350912
|
|
13
|
+
* original script: https://raw.githubusercontent.com/jd-solanki/anu/main/scripts/gen-component-meta.ts
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export function generateComponentMeta() {
|
|
17
|
+
const md = new MarkdownIt()
|
|
18
|
+
const checkerOptions: MetaCheckerOptions = {
|
|
19
|
+
forceUseTs: true,
|
|
20
|
+
schema: { ignore: ['MyIgnoredNestedProps'] },
|
|
21
|
+
printer: { newLine: 1 },
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const tsconfigChecker = createComponentMetaChecker(
|
|
25
|
+
projectPath('tsconfig.json'),
|
|
26
|
+
checkerOptions,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const filterMeta = (meta: ComponentMeta): ComponentApi => {
|
|
30
|
+
// const clonedMeta: ComponentMeta = JSON.parse(JSON.stringify(meta))
|
|
31
|
+
|
|
32
|
+
// Exclude global props
|
|
33
|
+
const props: ComponentApiProps[] = []
|
|
34
|
+
meta.props.forEach((prop) => {
|
|
35
|
+
if (prop?.global)
|
|
36
|
+
return
|
|
37
|
+
|
|
38
|
+
const { name, description, required, type, default: defaultValue } = prop
|
|
39
|
+
|
|
40
|
+
props.push({
|
|
41
|
+
name: `${name}${required ? '' : '?'}`,
|
|
42
|
+
description: md.render(description),
|
|
43
|
+
|
|
44
|
+
// required,
|
|
45
|
+
|
|
46
|
+
type,
|
|
47
|
+
default: defaultValue || 'unknown',
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
props,
|
|
53
|
+
events: meta.events,
|
|
54
|
+
slots: meta.slots,
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const components = glob.sync(['components/*.stx', 'components/**/*.stx'], {
|
|
59
|
+
cwd: projectPath(),
|
|
60
|
+
absolute: true,
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
components.forEach((componentPath) => {
|
|
64
|
+
// Thanks: https://futurestud.io/tutorials/node-js-get-a-file-name-with-or-without-extension
|
|
65
|
+
const componentExportName = parse(componentPath).name
|
|
66
|
+
const meta = filterMeta(tsconfigChecker.getComponentMeta(componentPath, componentExportName))
|
|
67
|
+
|
|
68
|
+
const metaDirPath = frameworkPath('component-meta')
|
|
69
|
+
|
|
70
|
+
// if meta dir doesn't exist create
|
|
71
|
+
|
|
72
|
+
if (!existsSync(metaDirPath))
|
|
73
|
+
mkdirSync(metaDirPath)
|
|
74
|
+
|
|
75
|
+
const metaJsonFilePath = join(metaDirPath, `${componentExportName}.json`)
|
|
76
|
+
writeFileSync(metaJsonFilePath, JSON.stringify(meta, null, 4))
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface ComponentApiProps {
|
|
81
|
+
name: ComponentMeta['props'][number]['name']
|
|
82
|
+
description: ComponentMeta['props'][number]['description']
|
|
83
|
+
|
|
84
|
+
// required: ComponentMeta['props'][number]['required']
|
|
85
|
+
type: ComponentMeta['props'][number]['type']
|
|
86
|
+
default: ComponentMeta['props'][number]['default']
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ComponentApi {
|
|
90
|
+
props: ComponentApiProps[]
|
|
91
|
+
events: ComponentMeta['events']
|
|
92
|
+
slots: ComponentMeta['slots']
|
|
93
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './utils'
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { log } from '@stacksjs/logging'
|
|
3
|
+
import { kebabCase } from '@stacksjs/strings'
|
|
4
|
+
import type { LibraryType } from '@stacksjs/path'
|
|
5
|
+
import { componentsPath, functionsPath, libraryEntryPath } from '@stacksjs/path'
|
|
6
|
+
import { writeTextFile } from '@stacksjs/storage'
|
|
7
|
+
import { determineResetPreset } from '@stacksjs/utils'
|
|
8
|
+
import { ExitCode } from '@stacksjs/types'
|
|
9
|
+
import library from '~/config/library'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Based on the config values, this method
|
|
13
|
+
* will generate the library entry points.
|
|
14
|
+
*
|
|
15
|
+
* @param type LibraryType
|
|
16
|
+
*/
|
|
17
|
+
export async function generateLibEntry(type: LibraryType) {
|
|
18
|
+
await createLibraryEntryPoint(type)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function createLibraryEntryPoint(type: LibraryType) {
|
|
22
|
+
if (type === 'vue-components')
|
|
23
|
+
await createVueLibraryEntryPoint()
|
|
24
|
+
|
|
25
|
+
if (type === 'web-components')
|
|
26
|
+
await createWebComponentLibraryEntryPoint()
|
|
27
|
+
|
|
28
|
+
if (type === 'functions')
|
|
29
|
+
await createFunctionLibraryEntryPoint()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function createVueLibraryEntryPoint(type: LibraryType = 'vue-components') {
|
|
33
|
+
log.info('Creating Vue Component Library Entry Point...')
|
|
34
|
+
|
|
35
|
+
await writeTextFile({
|
|
36
|
+
path: libraryEntryPath(type),
|
|
37
|
+
data: generateEntryPointData(type),
|
|
38
|
+
}).catch((err) => {
|
|
39
|
+
log.error('There was an error generating the Vue Component Library Entry Point.', err)
|
|
40
|
+
process.exit(ExitCode.FatalError)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
log.success('Created Vue Component Library Entry Point')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function createWebComponentLibraryEntryPoint(type: LibraryType = 'web-components') {
|
|
47
|
+
log.info('Creating Web Component Library Entry Point...')
|
|
48
|
+
|
|
49
|
+
await writeTextFile({
|
|
50
|
+
path: libraryEntryPath(type),
|
|
51
|
+
data: generateEntryPointData(type),
|
|
52
|
+
}).catch((err) => {
|
|
53
|
+
log.error('There was an error generating the Web Component library entry point', err)
|
|
54
|
+
process.exit(ExitCode.FatalError)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
log.success('Created Web Component Library Entry Point')
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function createFunctionLibraryEntryPoint(type: LibraryType = 'functions') {
|
|
61
|
+
log.info('Creating Function Library Entry Point...')
|
|
62
|
+
|
|
63
|
+
await writeTextFile({
|
|
64
|
+
path: libraryEntryPath(type),
|
|
65
|
+
data: generateEntryPointData(type),
|
|
66
|
+
}).catch((err) => {
|
|
67
|
+
log.error('There was an error generating Function Library Entry Point', err)
|
|
68
|
+
process.exit(ExitCode.FatalError)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
log.success('Created Functions Library Entry Point')
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function generateEntryPointData(type: LibraryType): string {
|
|
75
|
+
let arr = []
|
|
76
|
+
|
|
77
|
+
if (type === 'functions') {
|
|
78
|
+
if (!library.functions?.functions) {
|
|
79
|
+
log.error(new Error('There are no functions defined to be built. Please check your config/library.ts file for potential adjustments'))
|
|
80
|
+
process.exit()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
for (const fx of library.functions?.functions) {
|
|
84
|
+
if (Array.isArray(fx))
|
|
85
|
+
arr.push(`export * as ${fx[1]} from '${functionsPath(fx[0])}'`)
|
|
86
|
+
else
|
|
87
|
+
arr.push(`export * from '${functionsPath(fx)}'`)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// join the array into a string with each element being on a new line
|
|
91
|
+
return arr.join('\r\n')
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (type === 'vue-components') {
|
|
95
|
+
if (!library.vueComponents?.tags) {
|
|
96
|
+
log.error(new Error('There are no components defined to be built. Please check your config/library.ts file for potential adjustments'))
|
|
97
|
+
process.exit()
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
arr = determineResetPreset()
|
|
101
|
+
|
|
102
|
+
for (const component of library.vueComponents?.tags.map(tag => tag.name)) {
|
|
103
|
+
if (Array.isArray(component))
|
|
104
|
+
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'`)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// join the array into a string with each element being on a new line
|
|
110
|
+
return arr.join('\r\n')
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// at this point, we know it is a Web Component we are building
|
|
114
|
+
arr = determineResetPreset()
|
|
115
|
+
const imports = [...arr, 'import { defineCustomElement } from \'vue\'']
|
|
116
|
+
const declarations = []
|
|
117
|
+
const definitions = []
|
|
118
|
+
|
|
119
|
+
if (!library.webComponents?.tags) {
|
|
120
|
+
log.error(new Error('There are no components defined to be built. Please check your config/library.ts file for potential adjustments'))
|
|
121
|
+
process.exit()
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
for (const component of library.webComponents?.tags.map(tag => tag.name)) {
|
|
125
|
+
if (Array.isArray(component)) {
|
|
126
|
+
imports.push(`import ${component[1]} from '${componentsPath(component[0])}.stx'`)
|
|
127
|
+
declarations.push(`const ${component[1]}CustomElement = defineCustomElement(${component[1]})`)
|
|
128
|
+
definitions.push(`customElements.define('${kebabCase(component[1])}', ${component[1]}CustomElement)`)
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
imports.push(`import ${component} from '${componentsPath(component)}.stx'`)
|
|
132
|
+
declarations.push(`const ${component}CustomElement = defineCustomElement(${component})`)
|
|
133
|
+
definitions.push(`customElements.define('${kebabCase(component)}', ${component}CustomElement)`)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// join the array into a string with each element being on a new line
|
|
138
|
+
return [...imports, ...declarations, ...definitions].join('\r\n')
|
|
139
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { log } from '@stacksjs/logging'
|
|
2
|
+
import { writeTextFile } from '@stacksjs/storage'
|
|
3
|
+
import { packageJsonPath } from '@stacksjs/path'
|
|
4
|
+
import library from '~/config/library'
|
|
5
|
+
|
|
6
|
+
type PackageJsonType = 'vue-components' | 'web-components' | 'functions'
|
|
7
|
+
|
|
8
|
+
export async function generatePackageJson(type: PackageJsonType) {
|
|
9
|
+
let name, description, directory, keywords, config, prettyName
|
|
10
|
+
|
|
11
|
+
if (type === 'vue-components') {
|
|
12
|
+
name = library.vueComponents?.name
|
|
13
|
+
description = library.vueComponents?.description
|
|
14
|
+
directory = 'components'
|
|
15
|
+
keywords = library.vueComponents?.keywords
|
|
16
|
+
config = 'vue-components'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
else if (type === 'web-components') {
|
|
20
|
+
name = library.webComponents?.name
|
|
21
|
+
description = library.webComponents?.description
|
|
22
|
+
directory = 'components'
|
|
23
|
+
keywords = library.webComponents?.keywords
|
|
24
|
+
config = 'web-components'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
else if (type === 'functions') {
|
|
28
|
+
name = library.functions?.name
|
|
29
|
+
description = library.functions?.description
|
|
30
|
+
directory = 'functions'
|
|
31
|
+
keywords = library.functions?.keywords
|
|
32
|
+
config = 'functions'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
// the version does not have to be set here,
|
|
37
|
+
// it will be set automatically by the release script
|
|
38
|
+
await writeTextFile({
|
|
39
|
+
path: packageJsonPath(type),
|
|
40
|
+
data: `{
|
|
41
|
+
"name": "${name}",
|
|
42
|
+
"type": "module",
|
|
43
|
+
"version": "",
|
|
44
|
+
"packageManager": "bun",
|
|
45
|
+
"description": "${description}",
|
|
46
|
+
"author": "${library.author}",
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"homepage": "https://github.com/${library.repository}/tree/main/${directory}#readme",
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/${library.repository}.git",
|
|
52
|
+
"directory": "${directory}"
|
|
53
|
+
},
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/${library.repository}/issues"
|
|
56
|
+
},
|
|
57
|
+
"keywords": ${JSON.stringify(keywords)},
|
|
58
|
+
"contributors": ${JSON.stringify(library.contributors)},
|
|
59
|
+
"exports": {
|
|
60
|
+
".": {
|
|
61
|
+
"types": "./dist/index.d.ts",
|
|
62
|
+
"require": "./dist/index.cjs",
|
|
63
|
+
"import": "./dist/index.js"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"main": "dist/index.cjs",
|
|
67
|
+
"module": "dist/index.js",
|
|
68
|
+
"types": "dist/index.d.ts",
|
|
69
|
+
"files": [
|
|
70
|
+
"dist",
|
|
71
|
+
"README.md"
|
|
72
|
+
],
|
|
73
|
+
"scripts": {
|
|
74
|
+
"build": "vite build -c ../build/${config}.ts",
|
|
75
|
+
"prepublishOnly": "bun --bun run build"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"stacks": "workspace:*"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`,
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
if (type === 'vue-components')
|
|
85
|
+
prettyName = 'Vue Component library'
|
|
86
|
+
else if (type === 'web-components')
|
|
87
|
+
prettyName = 'Web Component library'
|
|
88
|
+
else if (type === 'functions')
|
|
89
|
+
prettyName = 'Function Library'
|
|
90
|
+
|
|
91
|
+
log.success(`Created ${prettyName} package.json file`)
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
log.error(`There was an error creating the ${prettyName} package.json`, err)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as storage from '@stacksjs/storage'
|
|
2
|
+
import { italic, runCommand, runCommands, underline } from '@stacksjs/cli'
|
|
3
|
+
import { log } from '@stacksjs/logging'
|
|
4
|
+
import * as p from '@stacksjs/path'
|
|
5
|
+
import type { ActionOptions, StacksError, Subprocess } from '@stacksjs/types'
|
|
6
|
+
import { type Result, err, handleError } from '@stacksjs/error-handling'
|
|
7
|
+
|
|
8
|
+
function parseOptions(options?: ActionOptions) {
|
|
9
|
+
if (!options)
|
|
10
|
+
return ''
|
|
11
|
+
|
|
12
|
+
const parsedOptions = Object.entries(options).map(([key, value]) => {
|
|
13
|
+
if (key.length === 1)
|
|
14
|
+
return `-${key}=${value}`
|
|
15
|
+
|
|
16
|
+
if (typeof value === 'boolean' && value) // if the value is `true`, just return the key
|
|
17
|
+
return `--${key}`
|
|
18
|
+
|
|
19
|
+
return `--${key}=${typeof value === 'string' && value.includes(' ') ? `"${value}"` : value}`
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
// filter out undefined values and join the array
|
|
23
|
+
return parsedOptions.filter(Boolean).join(' ').replace('----=', '')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// export type ActionResult = CommandResult
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Run an Action the Stacks way.
|
|
30
|
+
*
|
|
31
|
+
* @param action The action to invoke.
|
|
32
|
+
* @param options The options to pass to the command.
|
|
33
|
+
* @returns The result of the command.
|
|
34
|
+
*/
|
|
35
|
+
export async function runAction(action: string, options?: ActionOptions): Promise<Result<Subprocess, StacksError>> {
|
|
36
|
+
if (!hasAction(action))
|
|
37
|
+
return err(handleError(`The specified action "${action}" does not exist`))
|
|
38
|
+
|
|
39
|
+
const opts = parseOptions(options)
|
|
40
|
+
const path = p.relativeActionsPath(`${action}.ts`)
|
|
41
|
+
const cmd = `bun --bun ${`${path} ${opts}`}`
|
|
42
|
+
const o = {
|
|
43
|
+
cwd: options?.cwd || p.projectPath(),
|
|
44
|
+
...options,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (options?.verbose) {
|
|
48
|
+
log.debug('Running cmd:', underline(italic(cmd)))
|
|
49
|
+
log.debug('Running action:', underline(italic(`./actions/${action}.ts`)))
|
|
50
|
+
log.debug('with action options of:', o)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return await runCommand(cmd, o)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Run Actions the Stacks way.
|
|
58
|
+
*
|
|
59
|
+
* @param actions The actions to invoke.
|
|
60
|
+
* @param options The options to pass to the command.
|
|
61
|
+
* @returns The result of the command.
|
|
62
|
+
*/
|
|
63
|
+
export async function runActions(actions: string[], options?: ActionOptions) {
|
|
64
|
+
if (!actions.length)
|
|
65
|
+
return err('No actions were specified')
|
|
66
|
+
|
|
67
|
+
for (const action of actions) {
|
|
68
|
+
if (!hasAction(action))
|
|
69
|
+
return err(`The specified action "${action}" does not exist`)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const commands = actions.map(action => `bun --bun ${p.relativeActionsPath(`${action}.ts`)}`)
|
|
73
|
+
|
|
74
|
+
return await runCommands(commands, options)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function hasAction(action: string) {
|
|
78
|
+
if (storage.isFile(p.functionsPath(`actions/${action}.ts`)))
|
|
79
|
+
return true
|
|
80
|
+
|
|
81
|
+
return storage.isFile(p.actionsPath(`${action}.ts`))
|
|
82
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { log } from '@stacksjs/logging'
|
|
2
|
+
import { customElementsDataPath } from '@stacksjs/path'
|
|
3
|
+
import { writeTextFile } from '@stacksjs/storage'
|
|
4
|
+
import library from '~/config/library'
|
|
5
|
+
|
|
6
|
+
export async function generateVsCodeCustomData() {
|
|
7
|
+
try {
|
|
8
|
+
log.info('Generating custom-elements.json...')
|
|
9
|
+
// the version does not have to be set here,
|
|
10
|
+
// it will be set automatically by the release script
|
|
11
|
+
await writeTextFile({
|
|
12
|
+
path: customElementsDataPath(),
|
|
13
|
+
data: generateComponentInfoData(),
|
|
14
|
+
})
|
|
15
|
+
log.success('Generated custom-elements.json for IDEs.')
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
log.error('There was an error generating the custom-elements.json file.', err)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function generateWebTypes() {
|
|
23
|
+
log.info('Generating web-types.json...')
|
|
24
|
+
log.info('This feature is not yet implemented.')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function generateComponentInfoData() {
|
|
28
|
+
const componentsData = JSON.stringify(library.vueComponents?.tags)
|
|
29
|
+
|
|
30
|
+
return `{
|
|
31
|
+
"version": 1.1,
|
|
32
|
+
"tags": ${componentsData}
|
|
33
|
+
}
|
|
34
|
+
`
|
|
35
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export * from './action'
|
|
2
|
+
export * from './dev'
|
|
3
|
+
export * from './generate'
|
|
4
|
+
export * from './helpers'
|
|
5
|
+
|
|
6
|
+
export { examples as runExample } from './examples'
|
|
7
|
+
export { commit as runCommit } from './commit'
|
|
8
|
+
export { add as runAdd } from './add'
|
|
9
|
+
|
|
10
|
+
// makeFactory,
|
|
11
|
+
export {
|
|
12
|
+
make as runMake,
|
|
13
|
+
makeComponent,
|
|
14
|
+
makeDatabase,
|
|
15
|
+
makeFunction,
|
|
16
|
+
makeLanguage,
|
|
17
|
+
makeNotification,
|
|
18
|
+
makePage,
|
|
19
|
+
makeStack,
|
|
20
|
+
createComponent,
|
|
21
|
+
createDatabase,
|
|
22
|
+
createFactory,
|
|
23
|
+
createFunction,
|
|
24
|
+
createLanguage,
|
|
25
|
+
createMigration,
|
|
26
|
+
createModel,
|
|
27
|
+
createNotification,
|
|
28
|
+
createPage,
|
|
29
|
+
} from './make'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { runCommand } from '@stacksjs/cli'
|
|
2
|
+
import { isFile } from '@stacksjs/storage'
|
|
3
|
+
import { setEnvValue } from '@stacksjs/utils'
|
|
4
|
+
import { projectPath } from '@stacksjs/path'
|
|
5
|
+
import { generateAppKey } from '@stacksjs/security'
|
|
6
|
+
|
|
7
|
+
if (!isFile('.env'))
|
|
8
|
+
await runCommand('cp .env.example .env', { cwd: projectPath() })
|
|
9
|
+
|
|
10
|
+
await setEnvValue('APP_KEY', generateAppKey())
|
package/src/lint/fix.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { log, runCommands } from '@stacksjs/cli'
|
|
2
|
+
import { projectPath } from '@stacksjs/path'
|
|
3
|
+
import { NpmScript } from '@stacksjs/enums'
|
|
4
|
+
|
|
5
|
+
log.info('Ensuring Code Style...')
|
|
6
|
+
await runCommands([NpmScript.LintFix], { cwd: projectPath() })
|
|
7
|
+
log.success('Linted')
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { ExitCode } from '@stacksjs/types'
|
|
3
|
+
import { NpmScript } from '@stacksjs/enums'
|
|
4
|
+
import { log, runCommands } from '@stacksjs/cli'
|
|
5
|
+
import { projectPath } from '@stacksjs/path'
|
|
6
|
+
|
|
7
|
+
// import { $ } from 'bun'
|
|
8
|
+
|
|
9
|
+
log.info('Ensuring Code Style...')
|
|
10
|
+
|
|
11
|
+
// TODO: somehow, we currently cannot trigger bunx using $`` syntax
|
|
12
|
+
// $.cwd(projectPath())
|
|
13
|
+
|
|
14
|
+
// await $`${NpmScript.Lint}`
|
|
15
|
+
// await $`${NpmScript.LintPackageJson}`
|
|
16
|
+
|
|
17
|
+
const result = await runCommands([
|
|
18
|
+
NpmScript.Lint,
|
|
19
|
+
NpmScript.LintPackageJson,
|
|
20
|
+
], { cwd: projectPath() })
|
|
21
|
+
|
|
22
|
+
if (Array.isArray(result)) {
|
|
23
|
+
if (result.map(r => r.isErr()).includes(true))
|
|
24
|
+
process.exit(ExitCode.FatalError)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
log.success('Linted')
|