@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
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/helpers/component-meta.ts
|
|
3
|
+
import {path as path2, frameworkPath, join, projectPath} from "@stacksjs/path";
|
|
4
|
+
import {existsSync, glob, mkdirSync, writeFileSync} from "@stacksjs/storage";
|
|
5
|
+
import MarkdownIt from "markdown-it";
|
|
6
|
+
import {createComponentMetaChecker} from "vue-component-meta";
|
|
7
|
+
function generateComponentMeta() {
|
|
8
|
+
const md = new MarkdownIt;
|
|
9
|
+
const checkerOptions = {
|
|
10
|
+
forceUseTs: true,
|
|
11
|
+
schema: { ignore: ["MyIgnoredNestedProps"] },
|
|
12
|
+
printer: { newLine: 1 }
|
|
13
|
+
};
|
|
14
|
+
const tsconfigChecker = createComponentMetaChecker(projectPath("tsconfig.json"), checkerOptions);
|
|
15
|
+
const filterMeta = (meta) => {
|
|
16
|
+
const props = [];
|
|
17
|
+
meta.props.forEach((prop) => {
|
|
18
|
+
if (prop?.global)
|
|
19
|
+
return;
|
|
20
|
+
const { name, description, required, type, default: defaultValue } = prop;
|
|
21
|
+
props.push({
|
|
22
|
+
name: `${name}${required ? "" : "?"}`,
|
|
23
|
+
description: md.render(description),
|
|
24
|
+
type,
|
|
25
|
+
default: defaultValue || "unknown"
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
props,
|
|
30
|
+
events: meta.events,
|
|
31
|
+
slots: meta.slots
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const components = glob.sync(["components/*.stx", "components/**/*.stx", "components/*.vue", "components/**/*.vue"], {
|
|
35
|
+
cwd: projectPath(),
|
|
36
|
+
absolute: true
|
|
37
|
+
});
|
|
38
|
+
components.forEach((componentPath) => {
|
|
39
|
+
const componentExportName = path2.parse(componentPath).name;
|
|
40
|
+
const meta = filterMeta(tsconfigChecker.getComponentMeta(componentPath, componentExportName));
|
|
41
|
+
const metaDirPath = frameworkPath("component-meta");
|
|
42
|
+
if (!existsSync(metaDirPath))
|
|
43
|
+
mkdirSync(metaDirPath);
|
|
44
|
+
const metaJsonFilePath = join(metaDirPath, `${componentExportName}.json`);
|
|
45
|
+
writeFileSync(metaJsonFilePath, JSON.stringify(meta, null, 4));
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
generateComponentMeta
|
|
50
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/helpers/lib-entries.ts
|
|
3
|
+
import process from "process";
|
|
4
|
+
import {log} from "@stacksjs/logging";
|
|
5
|
+
import {componentsPath, functionsPath, libraryEntryPath} from "@stacksjs/path";
|
|
6
|
+
import {writeTextFile} from "@stacksjs/storage";
|
|
7
|
+
import {kebabCase} from "@stacksjs/strings";
|
|
8
|
+
import {ExitCode} from "@stacksjs/types";
|
|
9
|
+
import {determineResetPreset} from "@stacksjs/utils";
|
|
10
|
+
|
|
11
|
+
// ../../../../config/library.ts
|
|
12
|
+
var library_default = {
|
|
13
|
+
name: "hello-world",
|
|
14
|
+
owner: "@stacksjs",
|
|
15
|
+
repository: "stacksjs/stacks",
|
|
16
|
+
license: "MIT",
|
|
17
|
+
author: "Chris Breuer",
|
|
18
|
+
contributors: ["Chris Breuer <chris@stacksjs.org>"],
|
|
19
|
+
defaultLanguage: "en",
|
|
20
|
+
releaseable: true,
|
|
21
|
+
vueComponents: {
|
|
22
|
+
name: "hello-world-vue",
|
|
23
|
+
description: "Your Vue component library description",
|
|
24
|
+
keywords: ["component", "library", "vue", "vite", "typescript", "javascript"],
|
|
25
|
+
tags: [
|
|
26
|
+
{
|
|
27
|
+
name: ["HelloWorld", "AppHelloWorld"],
|
|
28
|
+
description: "The Hello World custom element, built via this framework.",
|
|
29
|
+
attributes: [
|
|
30
|
+
{
|
|
31
|
+
name: "greeting",
|
|
32
|
+
description: "The greeting."
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
webComponents: {
|
|
39
|
+
name: "hello-world-elements",
|
|
40
|
+
description: "Your framework agnostic web component library description.",
|
|
41
|
+
keywords: ["custom-elements", "web-components", "library", "framework-agnostic", "typescript", "javascript"],
|
|
42
|
+
tags: [
|
|
43
|
+
{
|
|
44
|
+
name: ["HelloWorld", "AppHelloWorld"],
|
|
45
|
+
description: "The Hello World custom element, built via this framework.",
|
|
46
|
+
attributes: [
|
|
47
|
+
{
|
|
48
|
+
name: "greeting",
|
|
49
|
+
description: "The greeting."
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
functions: {
|
|
56
|
+
name: "hello-world-fx",
|
|
57
|
+
description: "Your function library description.",
|
|
58
|
+
keywords: ["functions", "composables", "library", "typescript", "javascript"],
|
|
59
|
+
shouldGenerateSourcemap: false,
|
|
60
|
+
files: ["counter", "dark"]
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/helpers/lib-entries.ts
|
|
65
|
+
async function generateLibEntry(type) {
|
|
66
|
+
await createLibraryEntryPoint(type);
|
|
67
|
+
}
|
|
68
|
+
async function createLibraryEntryPoint(type) {
|
|
69
|
+
if (type === "vue-components")
|
|
70
|
+
await createVueLibraryEntryPoint();
|
|
71
|
+
if (type === "web-components")
|
|
72
|
+
await createWebComponentLibraryEntryPoint();
|
|
73
|
+
if (type === "functions")
|
|
74
|
+
await createFunctionLibraryEntryPoint();
|
|
75
|
+
}
|
|
76
|
+
async function createVueLibraryEntryPoint(type = "vue-components") {
|
|
77
|
+
log.info("Ensuring Component Library Entry Point...");
|
|
78
|
+
await writeTextFile({
|
|
79
|
+
path: libraryEntryPath(type),
|
|
80
|
+
data: generateEntryPointData(type)
|
|
81
|
+
}).catch((err) => {
|
|
82
|
+
log.error("There was an error generating the Vue Component Library Entry Point.", err);
|
|
83
|
+
process.exit(ExitCode.FatalError);
|
|
84
|
+
});
|
|
85
|
+
log.success("Created Vue Component Library Entry Point");
|
|
86
|
+
}
|
|
87
|
+
async function createWebComponentLibraryEntryPoint(type = "web-components") {
|
|
88
|
+
log.info("Ensuring Web Component Library Entry Point...");
|
|
89
|
+
await writeTextFile({
|
|
90
|
+
path: libraryEntryPath(type),
|
|
91
|
+
data: generateEntryPointData(type)
|
|
92
|
+
}).catch((err) => {
|
|
93
|
+
log.error("There was an error generating the Web Component library entry point", err);
|
|
94
|
+
process.exit(ExitCode.FatalError);
|
|
95
|
+
});
|
|
96
|
+
log.success("Created Web Component Library Entry Point");
|
|
97
|
+
}
|
|
98
|
+
async function createFunctionLibraryEntryPoint(type = "functions") {
|
|
99
|
+
log.info("Ensuring Function Library Entry Point...");
|
|
100
|
+
await writeTextFile({
|
|
101
|
+
path: libraryEntryPath(type),
|
|
102
|
+
data: generateEntryPointData(type)
|
|
103
|
+
}).catch((err) => {
|
|
104
|
+
log.error("There was an error generating Function Library Entry Point", err);
|
|
105
|
+
process.exit(ExitCode.FatalError);
|
|
106
|
+
});
|
|
107
|
+
log.success("Created Functions Library Entry Point");
|
|
108
|
+
}
|
|
109
|
+
function generateEntryPointData(type) {
|
|
110
|
+
let arr = [];
|
|
111
|
+
if (type === "functions") {
|
|
112
|
+
if (!library_default.functions?.files) {
|
|
113
|
+
log.error(new Error("There are no functions defined to be built. Please check your config/library.ts file for potential adjustments"));
|
|
114
|
+
process.exit();
|
|
115
|
+
}
|
|
116
|
+
for (const fx of library_default.functions.files) {
|
|
117
|
+
if (Array.isArray(fx))
|
|
118
|
+
arr.push(`export * as ${fx[1]} from '${functionsPath(fx[0])}'`);
|
|
119
|
+
else
|
|
120
|
+
arr.push(`export * from '${functionsPath(fx)}'`);
|
|
121
|
+
}
|
|
122
|
+
return arr.join("\r\n");
|
|
123
|
+
}
|
|
124
|
+
if (type === "vue-components") {
|
|
125
|
+
if (!library_default.vueComponents?.tags) {
|
|
126
|
+
log.error(new Error("There are no components defined to be built. Please check your config/library.ts file for potential adjustments"));
|
|
127
|
+
process.exit();
|
|
128
|
+
}
|
|
129
|
+
arr = determineResetPreset();
|
|
130
|
+
for (const component of library_default.vueComponents.tags.map((tag) => tag.name)) {
|
|
131
|
+
if (Array.isArray(component))
|
|
132
|
+
arr.push(`export { default as ${component[1]} } from '${componentsPath(component[0])}.stx'`);
|
|
133
|
+
else
|
|
134
|
+
arr.push(`export { default as ${component} } from '${componentsPath(component)}.stx'`);
|
|
135
|
+
}
|
|
136
|
+
return arr.join("\r\n");
|
|
137
|
+
}
|
|
138
|
+
arr = determineResetPreset();
|
|
139
|
+
const imports = [...arr, "import { defineCustomElement } from 'vue'"];
|
|
140
|
+
const declarations = [];
|
|
141
|
+
const definitions = [];
|
|
142
|
+
if (!library_default.webComponents?.tags) {
|
|
143
|
+
log.error(new Error("There are no components defined to be built. Please check your config/library.ts file for potential adjustments"));
|
|
144
|
+
process.exit();
|
|
145
|
+
}
|
|
146
|
+
for (const component of library_default.webComponents.tags.map((tag) => tag.name)) {
|
|
147
|
+
if (Array.isArray(component)) {
|
|
148
|
+
imports.push(`import ${component[1]} from '${componentsPath(component[0])}.stx'`);
|
|
149
|
+
declarations.push(`const ${component[1]}CustomElement = defineCustomElement(${component[1]})`);
|
|
150
|
+
definitions.push(`customElements.define('${kebabCase(component[1])}', ${component[1]}CustomElement)`);
|
|
151
|
+
} else {
|
|
152
|
+
imports.push(`import ${component} from '${componentsPath(component)}.stx'`);
|
|
153
|
+
declarations.push(`const ${component}CustomElement = defineCustomElement(${component})`);
|
|
154
|
+
definitions.push(`customElements.define('${kebabCase(component)}', ${component}CustomElement)`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return [...imports, ...declarations, ...definitions].join("\r\n");
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
generateLibEntry,
|
|
161
|
+
generateEntryPointData,
|
|
162
|
+
createWebComponentLibraryEntryPoint,
|
|
163
|
+
createVueLibraryEntryPoint,
|
|
164
|
+
createLibraryEntryPoint,
|
|
165
|
+
createFunctionLibraryEntryPoint
|
|
166
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/helpers/package-json.ts
|
|
3
|
+
import {log} from "@stacksjs/logging";
|
|
4
|
+
import {packageJsonPath} from "@stacksjs/path";
|
|
5
|
+
import {writeTextFile} from "@stacksjs/storage";
|
|
6
|
+
|
|
7
|
+
// ../../../../config/library.ts
|
|
8
|
+
var library_default = {
|
|
9
|
+
name: "hello-world",
|
|
10
|
+
owner: "@stacksjs",
|
|
11
|
+
repository: "stacksjs/stacks",
|
|
12
|
+
license: "MIT",
|
|
13
|
+
author: "Chris Breuer",
|
|
14
|
+
contributors: ["Chris Breuer <chris@stacksjs.org>"],
|
|
15
|
+
defaultLanguage: "en",
|
|
16
|
+
releaseable: true,
|
|
17
|
+
vueComponents: {
|
|
18
|
+
name: "hello-world-vue",
|
|
19
|
+
description: "Your Vue component library description",
|
|
20
|
+
keywords: ["component", "library", "vue", "vite", "typescript", "javascript"],
|
|
21
|
+
tags: [
|
|
22
|
+
{
|
|
23
|
+
name: ["HelloWorld", "AppHelloWorld"],
|
|
24
|
+
description: "The Hello World custom element, built via this framework.",
|
|
25
|
+
attributes: [
|
|
26
|
+
{
|
|
27
|
+
name: "greeting",
|
|
28
|
+
description: "The greeting."
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
webComponents: {
|
|
35
|
+
name: "hello-world-elements",
|
|
36
|
+
description: "Your framework agnostic web component library description.",
|
|
37
|
+
keywords: ["custom-elements", "web-components", "library", "framework-agnostic", "typescript", "javascript"],
|
|
38
|
+
tags: [
|
|
39
|
+
{
|
|
40
|
+
name: ["HelloWorld", "AppHelloWorld"],
|
|
41
|
+
description: "The Hello World custom element, built via this framework.",
|
|
42
|
+
attributes: [
|
|
43
|
+
{
|
|
44
|
+
name: "greeting",
|
|
45
|
+
description: "The greeting."
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
functions: {
|
|
52
|
+
name: "hello-world-fx",
|
|
53
|
+
description: "Your function library description.",
|
|
54
|
+
keywords: ["functions", "composables", "library", "typescript", "javascript"],
|
|
55
|
+
shouldGenerateSourcemap: false,
|
|
56
|
+
files: ["counter", "dark"]
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// src/helpers/package-json.ts
|
|
61
|
+
async function generatePackageJson(type) {
|
|
62
|
+
let name;
|
|
63
|
+
let description;
|
|
64
|
+
let directory;
|
|
65
|
+
let keywords;
|
|
66
|
+
let config;
|
|
67
|
+
let prettyName;
|
|
68
|
+
if (type === "vue-components") {
|
|
69
|
+
name = library_default.vueComponents?.name;
|
|
70
|
+
description = library_default.vueComponents?.description;
|
|
71
|
+
directory = "components";
|
|
72
|
+
keywords = library_default.vueComponents?.keywords;
|
|
73
|
+
config = "vue-components";
|
|
74
|
+
} else if (type === "web-components") {
|
|
75
|
+
name = library_default.webComponents?.name;
|
|
76
|
+
description = library_default.webComponents?.description;
|
|
77
|
+
directory = "components";
|
|
78
|
+
keywords = library_default.webComponents?.keywords;
|
|
79
|
+
config = "web-components";
|
|
80
|
+
} else if (type === "functions") {
|
|
81
|
+
name = library_default.functions?.name;
|
|
82
|
+
description = library_default.functions?.description;
|
|
83
|
+
directory = "functions";
|
|
84
|
+
keywords = library_default.functions?.keywords;
|
|
85
|
+
config = "functions";
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
await writeTextFile({
|
|
89
|
+
path: packageJsonPath(type),
|
|
90
|
+
data: `{
|
|
91
|
+
"name": "${name}",
|
|
92
|
+
"type": "module",
|
|
93
|
+
"version": "",
|
|
94
|
+
"packageManager": "bun",
|
|
95
|
+
"description": "${description}",
|
|
96
|
+
"author": "${library_default.author}",
|
|
97
|
+
"license": "MIT",
|
|
98
|
+
"homepage": "https://github.com/${library_default.repository}/tree/main/${directory}#readme",
|
|
99
|
+
"repository": {
|
|
100
|
+
"type": "git",
|
|
101
|
+
"url": "git+https://github.com/${library_default.repository}.git",
|
|
102
|
+
"directory": "${directory}"
|
|
103
|
+
},
|
|
104
|
+
"bugs": {
|
|
105
|
+
"url": "https://github.com/${library_default.repository}/issues"
|
|
106
|
+
},
|
|
107
|
+
"keywords": ${JSON.stringify(keywords)},
|
|
108
|
+
"contributors": ${JSON.stringify(library_default.contributors)},
|
|
109
|
+
"exports": {
|
|
110
|
+
".": {
|
|
111
|
+
"types": "./dist/index.d.ts",
|
|
112
|
+
"require": "./dist/index.cjs",
|
|
113
|
+
"import": "./dist/index.js"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"main": "dist/index.cjs",
|
|
117
|
+
"module": "dist/index.js",
|
|
118
|
+
"types": "dist/index.d.ts",
|
|
119
|
+
"files": [
|
|
120
|
+
"dist",
|
|
121
|
+
"README.md"
|
|
122
|
+
],
|
|
123
|
+
"scripts": {
|
|
124
|
+
"build": "vite build -c ../build/${config}.ts",
|
|
125
|
+
"prepublishOnly": "bun run build"
|
|
126
|
+
},
|
|
127
|
+
"devDependencies": {
|
|
128
|
+
"stacks": "workspace:*"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
`
|
|
132
|
+
});
|
|
133
|
+
if (type === "vue-components")
|
|
134
|
+
prettyName = "Vue Component library";
|
|
135
|
+
else if (type === "web-components")
|
|
136
|
+
prettyName = "Web Component library";
|
|
137
|
+
else if (type === "functions")
|
|
138
|
+
prettyName = "Function Library";
|
|
139
|
+
log.success(`Created ${prettyName} package.json file`);
|
|
140
|
+
} catch (err) {
|
|
141
|
+
log.error(`There was an error creating the ${prettyName} package.json`, err);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export {
|
|
145
|
+
generatePackageJson
|
|
146
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/helpers/utils.ts
|
|
3
|
+
import {buddyOptions, runCommand, runCommands} from "@stacksjs/cli";
|
|
4
|
+
import {err} from "@stacksjs/error-handling";
|
|
5
|
+
import {log} from "@stacksjs/logging";
|
|
6
|
+
import * as p from "@stacksjs/path";
|
|
7
|
+
import {glob} from "@stacksjs/storage";
|
|
8
|
+
var {Glob } = globalThis.Bun;
|
|
9
|
+
async function runAction(action, options) {
|
|
10
|
+
const glob2 = new Glob("**/*.ts");
|
|
11
|
+
const scanOptions = { cwd: p.userActionsPath(), onlyFiles: true };
|
|
12
|
+
for await (const file of glob2.scan(scanOptions)) {
|
|
13
|
+
log.debug("file", file);
|
|
14
|
+
if (file === `${action}.ts` || file.endsWith(`${action}.ts`))
|
|
15
|
+
return (await import(p.userActionsPath(file))).default.handle();
|
|
16
|
+
const a = await import(p.userActionsPath(file));
|
|
17
|
+
if (a.name === action)
|
|
18
|
+
return await a.handle();
|
|
19
|
+
}
|
|
20
|
+
const opts = buddyOptions();
|
|
21
|
+
const path = p.relativeActionsPath(`src/${action}.ts`);
|
|
22
|
+
const cmd = `bun --bun ${path} ${opts}`.trimEnd();
|
|
23
|
+
const optionsWithCwd = {
|
|
24
|
+
cwd: options?.cwd || p.projectPath(),
|
|
25
|
+
...options
|
|
26
|
+
};
|
|
27
|
+
log.debug("runAction:", cmd);
|
|
28
|
+
log.debug("action options:", optionsWithCwd);
|
|
29
|
+
return await runCommand(cmd, optionsWithCwd);
|
|
30
|
+
}
|
|
31
|
+
async function runActions(actions, options) {
|
|
32
|
+
log.debug("runActions:", actions, options);
|
|
33
|
+
if (!actions.length)
|
|
34
|
+
return err("No actions were specified");
|
|
35
|
+
for (const action of actions) {
|
|
36
|
+
log.debug(`running action "${action}"`);
|
|
37
|
+
if (!hasAction(action))
|
|
38
|
+
return err(`The specified action "${action}" does not exist`);
|
|
39
|
+
}
|
|
40
|
+
const opts = buddyOptions();
|
|
41
|
+
const o = {
|
|
42
|
+
cwd: options?.cwd || p.projectPath(),
|
|
43
|
+
...options
|
|
44
|
+
};
|
|
45
|
+
const commands = actions.map((action) => `bun --bun ${p.relativeActionsPath(`src/${action}.ts`)} ${opts}`);
|
|
46
|
+
log.debug("commands:", commands);
|
|
47
|
+
return await runCommands(commands, o);
|
|
48
|
+
}
|
|
49
|
+
function hasAction(action) {
|
|
50
|
+
const userActionPatterns = [
|
|
51
|
+
`${action}.ts`,
|
|
52
|
+
`${action}`,
|
|
53
|
+
`Dashboard/${action}.ts`,
|
|
54
|
+
`Dashboard/${action}`,
|
|
55
|
+
`Buddy/${action}.ts`,
|
|
56
|
+
`Buddy/${action}`
|
|
57
|
+
];
|
|
58
|
+
const actionPatterns = [`src/${action}.ts`, `src/${action}`, `${action}.ts`, `${action}`];
|
|
59
|
+
const userActionFiles = glob.sync(userActionPatterns.map((pattern) => p.userActionsPath(pattern)));
|
|
60
|
+
const actionFiles = glob.sync(actionPatterns.map((pattern) => p.actionsPath(pattern)));
|
|
61
|
+
return userActionFiles.length > 0 || actionFiles.length > 0;
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
runActions,
|
|
65
|
+
runAction,
|
|
66
|
+
hasAction
|
|
67
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/helpers/vscode-custom-data.ts
|
|
3
|
+
import {log} from "@stacksjs/logging";
|
|
4
|
+
import {customElementsDataPath} from "@stacksjs/path";
|
|
5
|
+
import {writeTextFile} from "@stacksjs/storage";
|
|
6
|
+
|
|
7
|
+
// ../../../../config/library.ts
|
|
8
|
+
var library_default = {
|
|
9
|
+
name: "hello-world",
|
|
10
|
+
owner: "@stacksjs",
|
|
11
|
+
repository: "stacksjs/stacks",
|
|
12
|
+
license: "MIT",
|
|
13
|
+
author: "Chris Breuer",
|
|
14
|
+
contributors: ["Chris Breuer <chris@stacksjs.org>"],
|
|
15
|
+
defaultLanguage: "en",
|
|
16
|
+
releaseable: true,
|
|
17
|
+
vueComponents: {
|
|
18
|
+
name: "hello-world-vue",
|
|
19
|
+
description: "Your Vue component library description",
|
|
20
|
+
keywords: ["component", "library", "vue", "vite", "typescript", "javascript"],
|
|
21
|
+
tags: [
|
|
22
|
+
{
|
|
23
|
+
name: ["HelloWorld", "AppHelloWorld"],
|
|
24
|
+
description: "The Hello World custom element, built via this framework.",
|
|
25
|
+
attributes: [
|
|
26
|
+
{
|
|
27
|
+
name: "greeting",
|
|
28
|
+
description: "The greeting."
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
webComponents: {
|
|
35
|
+
name: "hello-world-elements",
|
|
36
|
+
description: "Your framework agnostic web component library description.",
|
|
37
|
+
keywords: ["custom-elements", "web-components", "library", "framework-agnostic", "typescript", "javascript"],
|
|
38
|
+
tags: [
|
|
39
|
+
{
|
|
40
|
+
name: ["HelloWorld", "AppHelloWorld"],
|
|
41
|
+
description: "The Hello World custom element, built via this framework.",
|
|
42
|
+
attributes: [
|
|
43
|
+
{
|
|
44
|
+
name: "greeting",
|
|
45
|
+
description: "The greeting."
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
functions: {
|
|
52
|
+
name: "hello-world-fx",
|
|
53
|
+
description: "Your function library description.",
|
|
54
|
+
keywords: ["functions", "composables", "library", "typescript", "javascript"],
|
|
55
|
+
shouldGenerateSourcemap: false,
|
|
56
|
+
files: ["counter", "dark"]
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// src/helpers/vscode-custom-data.ts
|
|
61
|
+
async function generateVsCodeCustomData() {
|
|
62
|
+
try {
|
|
63
|
+
log.info("Generating custom-elements.json...");
|
|
64
|
+
await writeTextFile({
|
|
65
|
+
path: customElementsDataPath(),
|
|
66
|
+
data: generateComponentInfoData()
|
|
67
|
+
});
|
|
68
|
+
log.success("Generated custom-elements.json for IDEs.");
|
|
69
|
+
} catch (err) {
|
|
70
|
+
log.error("There was an error generating the custom-elements.json file.", err);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function generateWebTypes() {
|
|
74
|
+
log.info("Generating web-types.json...");
|
|
75
|
+
log.info("This feature is not yet implemented.");
|
|
76
|
+
}
|
|
77
|
+
var generateComponentInfoData = function() {
|
|
78
|
+
const componentsData = JSON.stringify(library_default.vueComponents?.tags);
|
|
79
|
+
return `{
|
|
80
|
+
"version": 1.1,
|
|
81
|
+
"tags": ${componentsData}
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
};
|
|
85
|
+
export {
|
|
86
|
+
generateWebTypes,
|
|
87
|
+
generateVsCodeCustomData
|
|
88
|
+
};
|