@stacksjs/actions 0.59.10 → 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.
Files changed (163) hide show
  1. package/dist/add.js +29 -0
  2. package/dist/build/component-libs.js +9 -0
  3. package/dist/build/core.js +21 -0
  4. package/dist/build/stacks.js +8 -0
  5. package/dist/build.js +317 -0
  6. package/dist/bump.js +16 -0
  7. package/dist/changelog.js +17 -0
  8. package/dist/clean.js +6 -0
  9. package/dist/commit.js +17 -0
  10. package/dist/copy-types.js +14 -0
  11. package/dist/database/seed.js +8 -0
  12. package/dist/deploy/index.js +31 -0
  13. package/dist/dev/components.js +11 -0
  14. package/dist/dev/docs.js +7 -0
  15. package/dist/dev/index.js +112 -0
  16. package/dist/examples.js +43 -0
  17. package/dist/fresh.js +19 -0
  18. package/dist/generate/component-meta.js +59 -0
  19. package/dist/generate/ide-helpers.js +96 -0
  20. package/dist/generate/index.js +251 -0
  21. package/dist/generate/lib-entries.js +175 -0
  22. package/dist/generate/vscode-custom-data.js +96 -0
  23. package/dist/helpers/component-meta.js +50 -0
  24. package/dist/helpers/lib-entries.js +166 -0
  25. package/dist/helpers/package-json.js +146 -0
  26. package/dist/helpers/utils.js +67 -0
  27. package/dist/helpers/vscode-custom-data.js +88 -0
  28. package/dist/index.js +676 -0
  29. package/dist/key-generate.js +10 -0
  30. package/dist/lint/fix.js +12 -0
  31. package/dist/lint/index.js +16 -0
  32. package/dist/make.js +319 -0
  33. package/dist/prepublish.js +17 -0
  34. package/dist/release.js +646 -0
  35. package/dist/test/coverage.js +9 -0
  36. package/dist/test/feature.js +9 -0
  37. package/dist/test/ui.js +6 -0
  38. package/dist/test/unit.js +6 -0
  39. package/dist/test.js +6 -0
  40. package/dist/typecheck.js +6 -0
  41. package/dist/types.js +21 -0
  42. package/dist/upgrade/dependencies.js +6 -0
  43. package/dist/upgrade/framework.js +1 -0
  44. package/dist/upgrade/index.js +78 -0
  45. package/dist/upgrade.js +46 -0
  46. package/package.json +5 -5
  47. package/src/action.ts +1 -0
  48. package/src/actions.ts +2 -2
  49. package/src/add.ts +3 -6
  50. package/src/ai/request-model-access.ts +10 -7
  51. package/src/build/component-libs.ts +5 -2
  52. package/src/build/core.ts +1 -2
  53. package/src/build/stacks.ts +8 -5
  54. package/src/build.ts +11 -25
  55. package/src/bump.ts +0 -2
  56. package/src/check/ports.ts +2 -3
  57. package/src/commit.ts +2 -2
  58. package/src/copy-types.ts +1 -1
  59. package/src/database/seed.ts +8 -4
  60. package/src/deploy/create-receipt-rule.ts +3 -7
  61. package/src/deploy/index.ts +2 -1
  62. package/src/dev/api.ts +4 -4
  63. package/src/dev/components.ts +3 -5
  64. package/src/dev/index.ts +2 -2
  65. package/src/domains/add.ts +8 -6
  66. package/src/domains/purchase.ts +26 -24
  67. package/src/domains/remove.ts +5 -7
  68. package/src/examples.ts +9 -13
  69. package/src/find-projects.ts +4 -6
  70. package/src/fresh.ts +2 -1
  71. package/src/generate/action-types.ts +5 -7
  72. package/src/generate/component-meta.ts +2 -5
  73. package/src/generate/custom-cli-file.ts +4 -3
  74. package/src/generate/env-files.ts +38 -43
  75. package/src/generate/ide-helpers.ts +1 -2
  76. package/src/generate/index.ts +16 -40
  77. package/src/generate/lib-entries.ts +4 -7
  78. package/src/generate/pkgx-file.ts +6 -11
  79. package/src/generate/vscode-custom-data.ts +1 -3
  80. package/src/helpers/component-meta.ts +6 -11
  81. package/src/helpers/index.ts +5 -0
  82. package/src/helpers/lib-entries.ts +30 -25
  83. package/src/helpers/package-json.ts +13 -16
  84. package/src/helpers/utils.ts +56 -13
  85. package/src/helpers/vscode-custom-data.ts +1 -2
  86. package/src/index.ts +2 -1
  87. package/src/key-generate.ts +3 -4
  88. package/src/lint/fix.ts +10 -2
  89. package/src/lint/index.ts +6 -10
  90. package/src/make.ts +79 -77
  91. package/src/migrate/database.ts +22 -1
  92. package/src/migrate/fresh.ts +20 -0
  93. package/src/orm/base.ts +0 -0
  94. package/src/orm/generate-model.ts +1177 -0
  95. package/src/{generate/model-classes.ts → orm/user.ts} +33 -48
  96. package/src/prepublish.ts +5 -2
  97. package/src/release.ts +15 -11
  98. package/src/test/coverage.ts +5 -2
  99. package/src/test/feature.ts +5 -2
  100. package/src/test/ui.ts +1 -1
  101. package/src/test/unit.ts +1 -1
  102. package/src/test.ts +1 -1
  103. package/src/typecheck.ts +1 -1
  104. package/src/types.ts +2 -2
  105. package/src/upgrade/binary.ts +3 -5
  106. package/src/upgrade/index.ts +4 -8
  107. package/src/upgrade/shell.ts +10 -10
  108. package/src/upgrade.ts +28 -25
  109. package/dist/action.d.ts +0 -36
  110. package/dist/add.d.ts +0 -6
  111. package/dist/build/component-libs.d.ts +0 -1
  112. package/dist/build/core.d.ts +0 -1
  113. package/dist/build/stacks.d.ts +0 -1
  114. package/dist/build.d.ts +0 -9
  115. package/dist/bump.d.ts +0 -1
  116. package/dist/changelog.d.ts +0 -1
  117. package/dist/clean.d.ts +0 -1
  118. package/dist/commit.d.ts +0 -3
  119. package/dist/copy-types.d.ts +0 -5
  120. package/dist/database/seed.d.ts +0 -1
  121. package/dist/deploy/index.d.ts +0 -1
  122. package/dist/dev/components.d.ts +0 -1
  123. package/dist/dev/docs.d.ts +0 -1
  124. package/dist/dev/index.d.ts +0 -10
  125. package/dist/examples.d.ts +0 -5
  126. package/dist/fresh.d.ts +0 -1
  127. package/dist/generate/component-meta.d.ts +0 -5
  128. package/dist/generate/ide-helpers.d.ts +0 -6
  129. package/dist/generate/index.d.ts +0 -13
  130. package/dist/generate/lib-entries.d.ts +0 -2
  131. package/dist/generate/vscode-custom-data.d.ts +0 -6
  132. package/dist/helpers/component-meta.d.ts +0 -22
  133. package/dist/helpers/lib-entries.d.ts +0 -13
  134. package/dist/helpers/package-json.d.ts +0 -3
  135. package/dist/helpers/utils.d.ts +0 -18
  136. package/dist/helpers/vscode-custom-data.d.ts +0 -2
  137. package/dist/index.d.ts +0 -7
  138. package/dist/key-generate.d.ts +0 -1
  139. package/dist/lint/fix.d.ts +0 -1
  140. package/dist/lint/index.d.ts +0 -1
  141. package/dist/make.d.ts +0 -20
  142. package/dist/prepublish.d.ts +0 -1
  143. package/dist/release.d.ts +0 -2
  144. package/dist/test/coverage.d.ts +0 -1
  145. package/dist/test/feature.d.ts +0 -1
  146. package/dist/test/ui.d.ts +0 -1
  147. package/dist/test/unit.d.ts +0 -1
  148. package/dist/test.d.ts +0 -1
  149. package/dist/tinker.d.ts +0 -1
  150. package/dist/typecheck.d.ts +0 -1
  151. package/dist/types.d.ts +0 -3
  152. package/dist/upgrade/dependencies.d.ts +0 -1
  153. package/dist/upgrade/framework.d.ts +0 -1
  154. package/dist/upgrade/index.d.ts +0 -1
  155. package/dist/upgrade.d.ts +0 -4
  156. package/src/database/fields.ts +0 -111
  157. package/src/database/migration-mysql.ts +0 -72
  158. package/src/database/migration-sqlite.ts +0 -67
  159. package/src/database/migration.ts +0 -10
  160. package/src/database/user-migration.ts +0 -20
  161. package/src/generate/model-generate.ts +0 -12
  162. package/src/migrate/dns.ts +0 -3
  163. package/src/tinker.ts +0 -10
package/dist/fresh.js ADDED
@@ -0,0 +1,19 @@
1
+ // @bun
2
+ // src/fresh.ts
3
+ import process from "process";
4
+ import {runCommand} from "@stacksjs/cli";
5
+ import {handleError} from "@stacksjs/error-handling";
6
+ import {logger} from "@stacksjs/logging";
7
+ import {projectPath} from "@stacksjs/path";
8
+ import {ExitCode} from "@stacksjs/types";
9
+ import {cleanProject} from "@stacksjs/utils";
10
+ logger.log("Cleaning project...");
11
+ await cleanProject();
12
+ logger.log("Installing dependencies...");
13
+ var result = await runCommand("bun install", {
14
+ cwd: projectPath()
15
+ });
16
+ if (result.isErr()) {
17
+ handleError(result.error);
18
+ process.exit(ExitCode.FatalError);
19
+ }
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+
4
+ // src/helpers/component-meta.ts
5
+ import {path as path2, frameworkPath, join, projectPath} from "@stacksjs/path";
6
+ import {existsSync, glob, mkdirSync, writeFileSync} from "@stacksjs/storage";
7
+ import MarkdownIt from "markdown-it";
8
+ import {createComponentMetaChecker} from "vue-component-meta";
9
+ function generateComponentMeta() {
10
+ const md = new MarkdownIt;
11
+ const checkerOptions = {
12
+ forceUseTs: true,
13
+ schema: { ignore: ["MyIgnoredNestedProps"] },
14
+ printer: { newLine: 1 }
15
+ };
16
+ const tsconfigChecker = createComponentMetaChecker(projectPath("tsconfig.json"), checkerOptions);
17
+ const filterMeta = (meta) => {
18
+ const props = [];
19
+ meta.props.forEach((prop) => {
20
+ if (prop?.global)
21
+ return;
22
+ const { name, description, required, type, default: defaultValue } = prop;
23
+ props.push({
24
+ name: `${name}${required ? "" : "?"}`,
25
+ description: md.render(description),
26
+ type,
27
+ default: defaultValue || "unknown"
28
+ });
29
+ });
30
+ return {
31
+ props,
32
+ events: meta.events,
33
+ slots: meta.slots
34
+ };
35
+ };
36
+ const components = glob.sync(["components/*.stx", "components/**/*.stx", "components/*.vue", "components/**/*.vue"], {
37
+ cwd: projectPath(),
38
+ absolute: true
39
+ });
40
+ components.forEach((componentPath) => {
41
+ const componentExportName = path2.parse(componentPath).name;
42
+ const meta = filterMeta(tsconfigChecker.getComponentMeta(componentPath, componentExportName));
43
+ const metaDirPath = frameworkPath("component-meta");
44
+ if (!existsSync(metaDirPath))
45
+ mkdirSync(metaDirPath);
46
+ const metaJsonFilePath = join(metaDirPath, `${componentExportName}.json`);
47
+ writeFileSync(metaJsonFilePath, JSON.stringify(meta, null, 4));
48
+ });
49
+ }
50
+
51
+ // src/generate/component-meta.ts
52
+ import {log} from "@stacksjs/logging";
53
+ import {hasComponents} from "@stacksjs/storage";
54
+ log.info("Generating component meta...");
55
+ if (hasComponents())
56
+ generateComponentMeta();
57
+ else
58
+ log.info("No components found. Skipping component meta generation.");
59
+ log.success("Generated component meta.");
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+
4
+ // src/helpers/vscode-custom-data.ts
5
+ import {log} from "@stacksjs/logging";
6
+ import {customElementsDataPath} from "@stacksjs/path";
7
+ import {writeTextFile} from "@stacksjs/storage";
8
+
9
+ // ../../../../config/library.ts
10
+ var library_default = {
11
+ name: "hello-world",
12
+ owner: "@stacksjs",
13
+ repository: "stacksjs/stacks",
14
+ license: "MIT",
15
+ author: "Chris Breuer",
16
+ contributors: ["Chris Breuer <chris@stacksjs.org>"],
17
+ defaultLanguage: "en",
18
+ releaseable: true,
19
+ vueComponents: {
20
+ name: "hello-world-vue",
21
+ description: "Your Vue component library description",
22
+ keywords: ["component", "library", "vue", "vite", "typescript", "javascript"],
23
+ tags: [
24
+ {
25
+ name: ["HelloWorld", "AppHelloWorld"],
26
+ description: "The Hello World custom element, built via this framework.",
27
+ attributes: [
28
+ {
29
+ name: "greeting",
30
+ description: "The greeting."
31
+ }
32
+ ]
33
+ }
34
+ ]
35
+ },
36
+ webComponents: {
37
+ name: "hello-world-elements",
38
+ description: "Your framework agnostic web component library description.",
39
+ keywords: ["custom-elements", "web-components", "library", "framework-agnostic", "typescript", "javascript"],
40
+ tags: [
41
+ {
42
+ name: ["HelloWorld", "AppHelloWorld"],
43
+ description: "The Hello World custom element, built via this framework.",
44
+ attributes: [
45
+ {
46
+ name: "greeting",
47
+ description: "The greeting."
48
+ }
49
+ ]
50
+ }
51
+ ]
52
+ },
53
+ functions: {
54
+ name: "hello-world-fx",
55
+ description: "Your function library description.",
56
+ keywords: ["functions", "composables", "library", "typescript", "javascript"],
57
+ shouldGenerateSourcemap: false,
58
+ files: ["counter", "dark"]
59
+ }
60
+ };
61
+
62
+ // src/helpers/vscode-custom-data.ts
63
+ async function generateVsCodeCustomData() {
64
+ try {
65
+ log.info("Generating custom-elements.json...");
66
+ await writeTextFile({
67
+ path: customElementsDataPath(),
68
+ data: generateComponentInfoData()
69
+ });
70
+ log.success("Generated custom-elements.json for IDEs.");
71
+ } catch (err) {
72
+ log.error("There was an error generating the custom-elements.json file.", err);
73
+ }
74
+ }
75
+ async function generateWebTypes() {
76
+ log.info("Generating web-types.json...");
77
+ log.info("This feature is not yet implemented.");
78
+ }
79
+ var generateComponentInfoData = function() {
80
+ const componentsData = JSON.stringify(library_default.vueComponents?.tags);
81
+ return `{
82
+ "version": 1.1,
83
+ "tags": ${componentsData}
84
+ }
85
+ `;
86
+ };
87
+
88
+ // src/generate/ide-helpers.ts
89
+ import {log as log2} from "@stacksjs/logging";
90
+ import {hasComponents} from "@stacksjs/storage";
91
+ if (hasComponents()) {
92
+ await generateWebTypes();
93
+ await generateVsCodeCustomData();
94
+ } else {
95
+ log2.info("No components found. Skipping IDE helper generation.");
96
+ }
@@ -0,0 +1,251 @@
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
+
64
+ // src/helpers/vscode-custom-data.ts
65
+ import {log as log2} from "@stacksjs/logging";
66
+ import {customElementsDataPath} from "@stacksjs/path";
67
+ import {writeTextFile} from "@stacksjs/storage";
68
+
69
+ // ../../../../config/library.ts
70
+ var library_default = {
71
+ name: "hello-world",
72
+ owner: "@stacksjs",
73
+ repository: "stacksjs/stacks",
74
+ license: "MIT",
75
+ author: "Chris Breuer",
76
+ contributors: ["Chris Breuer <chris@stacksjs.org>"],
77
+ defaultLanguage: "en",
78
+ releaseable: true,
79
+ vueComponents: {
80
+ name: "hello-world-vue",
81
+ description: "Your Vue component library description",
82
+ keywords: ["component", "library", "vue", "vite", "typescript", "javascript"],
83
+ tags: [
84
+ {
85
+ name: ["HelloWorld", "AppHelloWorld"],
86
+ description: "The Hello World custom element, built via this framework.",
87
+ attributes: [
88
+ {
89
+ name: "greeting",
90
+ description: "The greeting."
91
+ }
92
+ ]
93
+ }
94
+ ]
95
+ },
96
+ webComponents: {
97
+ name: "hello-world-elements",
98
+ description: "Your framework agnostic web component library description.",
99
+ keywords: ["custom-elements", "web-components", "library", "framework-agnostic", "typescript", "javascript"],
100
+ tags: [
101
+ {
102
+ name: ["HelloWorld", "AppHelloWorld"],
103
+ description: "The Hello World custom element, built via this framework.",
104
+ attributes: [
105
+ {
106
+ name: "greeting",
107
+ description: "The greeting."
108
+ }
109
+ ]
110
+ }
111
+ ]
112
+ },
113
+ functions: {
114
+ name: "hello-world-fx",
115
+ description: "Your function library description.",
116
+ keywords: ["functions", "composables", "library", "typescript", "javascript"],
117
+ shouldGenerateSourcemap: false,
118
+ files: ["counter", "dark"]
119
+ }
120
+ };
121
+
122
+ // src/helpers/vscode-custom-data.ts
123
+ async function generateVsCodeCustomData() {
124
+ try {
125
+ log2.info("Generating custom-elements.json...");
126
+ await writeTextFile({
127
+ path: customElementsDataPath(),
128
+ data: generateComponentInfoData()
129
+ });
130
+ log2.success("Generated custom-elements.json for IDEs.");
131
+ } catch (err2) {
132
+ log2.error("There was an error generating the custom-elements.json file.", err2);
133
+ }
134
+ }
135
+ async function generateWebTypes() {
136
+ log2.info("Generating web-types.json...");
137
+ log2.info("This feature is not yet implemented.");
138
+ }
139
+ var generateComponentInfoData = function() {
140
+ const componentsData = JSON.stringify(library_default.vueComponents?.tags);
141
+ return `{
142
+ "version": 1.1,
143
+ "tags": ${componentsData}
144
+ }
145
+ `;
146
+ };
147
+
148
+ // src/generate/index.ts
149
+ import process from "process";
150
+ import {runCommand as runCommand2} from "@stacksjs/cli";
151
+ import {Action, NpmScript} from "@stacksjs/enums";
152
+ import {log as log3} from "@stacksjs/logging";
153
+ import {frameworkPath, projectPath as projectPath2} from "@stacksjs/path";
154
+ import {runNpmScript} from "@stacksjs/utils";
155
+ async function invoke(options) {
156
+ if (options?.types)
157
+ await generateTypes(options);
158
+ else if (options?.entries)
159
+ await generateLibEntries(options);
160
+ else if (options?.webTypes)
161
+ await generateWebTypes2(options);
162
+ else if (options?.customData)
163
+ await generateVsCodeCustomData2(options);
164
+ else if (options?.ideHelpers)
165
+ await generateIdeHelpers(options);
166
+ else if (options?.componentMeta)
167
+ await generateComponentMeta(options);
168
+ else if (options?.coreSymlink)
169
+ await generateCoreSymlink();
170
+ }
171
+ function generate(options) {
172
+ return invoke(options);
173
+ }
174
+ async function generateLibEntries(options) {
175
+ const result = await runAction(Action.GenerateLibraryEntries, {
176
+ ...options,
177
+ cwd: projectPath2()
178
+ });
179
+ if (result.isErr()) {
180
+ log3.error("There was an error generating your library entry points", result.error);
181
+ process.exit();
182
+ }
183
+ log3.success("Library entry points generated successfully");
184
+ }
185
+ async function generateWebTypes2(options) {
186
+ const result = await runNpmScript(NpmScript.GenerateWebTypes, options);
187
+ if (result.isErr()) {
188
+ log3.error("There was an error generating the web-types.json file.", result.error);
189
+ process.exit();
190
+ }
191
+ log3.success("Successfully generated the web-types.json file");
192
+ }
193
+ async function generateVsCodeCustomData2(options) {
194
+ const result = await generateVsCodeCustomData();
195
+ if (result.isErr()) {
196
+ log3.error("There was an error generating the custom-elements.json file.", result.error);
197
+ process.exit();
198
+ }
199
+ await runAction(Action.LintFix, { verbose: true });
200
+ log3.success("Successfully generated the custom-elements.json file");
201
+ }
202
+ async function generateIdeHelpers(options) {
203
+ const result = await runNpmScript(NpmScript.GenerateIdeHelpers, options);
204
+ if (result.isErr()) {
205
+ log3.error("There was an error generating IDE helpers.", result.error);
206
+ process.exit();
207
+ }
208
+ await runAction(Action.LintFix, { verbose: true });
209
+ log3.success("Successfully generated IDE helpers");
210
+ }
211
+ async function generateComponentMeta(options) {
212
+ const result = await generateVsCodeCustomData();
213
+ if (result.isErr()) {
214
+ log3.error("There was an error generating your component meta information.", result.error);
215
+ process.exit();
216
+ }
217
+ await runAction(Action.LintFix, { verbose: true });
218
+ log3.success("Successfully generated component meta information");
219
+ }
220
+ async function generateTypes(options) {
221
+ const result = await runNpmScript(NpmScript.GenerateTypes, {
222
+ cwd: frameworkPath(),
223
+ ...options
224
+ });
225
+ if (result.isErr()) {
226
+ log3.error("There was an error generating your types.", result.error);
227
+ process.exit();
228
+ }
229
+ log3.success("Types were generated successfully");
230
+ }
231
+ function generatePkgxConfig() {
232
+ log3.success("Successfully generated `./pkgx.yaml` based on your config");
233
+ }
234
+ async function generateSeeder() {
235
+ }
236
+ async function generateCoreSymlink() {
237
+ await runCommand2(`ln -s ${frameworkPath()} ${projectPath2(".stacks")}`);
238
+ }
239
+ export {
240
+ invoke,
241
+ generateWebTypes2 as generateWebTypes,
242
+ generateVsCodeCustomData2 as generateVsCodeCustomData,
243
+ generateTypes,
244
+ generateSeeder,
245
+ generatePkgxConfig,
246
+ generateLibEntries,
247
+ generateIdeHelpers,
248
+ generateCoreSymlink,
249
+ generateComponentMeta,
250
+ generate
251
+ };
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+
4
+ // src/helpers/lib-entries.ts
5
+ import process from "process";
6
+ import {log} from "@stacksjs/logging";
7
+ import {componentsPath, functionsPath, libraryEntryPath} from "@stacksjs/path";
8
+ import {writeTextFile} from "@stacksjs/storage";
9
+ import {kebabCase} from "@stacksjs/strings";
10
+ import {ExitCode} from "@stacksjs/types";
11
+ import {determineResetPreset} from "@stacksjs/utils";
12
+
13
+ // ../../../../config/library.ts
14
+ var library_default = {
15
+ name: "hello-world",
16
+ owner: "@stacksjs",
17
+ repository: "stacksjs/stacks",
18
+ license: "MIT",
19
+ author: "Chris Breuer",
20
+ contributors: ["Chris Breuer <chris@stacksjs.org>"],
21
+ defaultLanguage: "en",
22
+ releaseable: true,
23
+ vueComponents: {
24
+ name: "hello-world-vue",
25
+ description: "Your Vue component library description",
26
+ keywords: ["component", "library", "vue", "vite", "typescript", "javascript"],
27
+ tags: [
28
+ {
29
+ name: ["HelloWorld", "AppHelloWorld"],
30
+ description: "The Hello World custom element, built via this framework.",
31
+ attributes: [
32
+ {
33
+ name: "greeting",
34
+ description: "The greeting."
35
+ }
36
+ ]
37
+ }
38
+ ]
39
+ },
40
+ webComponents: {
41
+ name: "hello-world-elements",
42
+ description: "Your framework agnostic web component library description.",
43
+ keywords: ["custom-elements", "web-components", "library", "framework-agnostic", "typescript", "javascript"],
44
+ tags: [
45
+ {
46
+ name: ["HelloWorld", "AppHelloWorld"],
47
+ description: "The Hello World custom element, built via this framework.",
48
+ attributes: [
49
+ {
50
+ name: "greeting",
51
+ description: "The greeting."
52
+ }
53
+ ]
54
+ }
55
+ ]
56
+ },
57
+ functions: {
58
+ name: "hello-world-fx",
59
+ description: "Your function library description.",
60
+ keywords: ["functions", "composables", "library", "typescript", "javascript"],
61
+ shouldGenerateSourcemap: false,
62
+ files: ["counter", "dark"]
63
+ }
64
+ };
65
+
66
+ // src/helpers/lib-entries.ts
67
+ async function generateLibEntry(type) {
68
+ await createLibraryEntryPoint(type);
69
+ }
70
+ async function createLibraryEntryPoint(type) {
71
+ if (type === "vue-components")
72
+ await createVueLibraryEntryPoint();
73
+ if (type === "web-components")
74
+ await createWebComponentLibraryEntryPoint();
75
+ if (type === "functions")
76
+ await createFunctionLibraryEntryPoint();
77
+ }
78
+ async function createVueLibraryEntryPoint(type = "vue-components") {
79
+ log.info("Ensuring Component Library Entry Point...");
80
+ await writeTextFile({
81
+ path: libraryEntryPath(type),
82
+ data: generateEntryPointData(type)
83
+ }).catch((err) => {
84
+ log.error("There was an error generating the Vue Component Library Entry Point.", err);
85
+ process.exit(ExitCode.FatalError);
86
+ });
87
+ log.success("Created Vue Component Library Entry Point");
88
+ }
89
+ async function createWebComponentLibraryEntryPoint(type = "web-components") {
90
+ log.info("Ensuring Web Component Library Entry Point...");
91
+ await writeTextFile({
92
+ path: libraryEntryPath(type),
93
+ data: generateEntryPointData(type)
94
+ }).catch((err) => {
95
+ log.error("There was an error generating the Web Component library entry point", err);
96
+ process.exit(ExitCode.FatalError);
97
+ });
98
+ log.success("Created Web Component Library Entry Point");
99
+ }
100
+ async function createFunctionLibraryEntryPoint(type = "functions") {
101
+ log.info("Ensuring Function Library Entry Point...");
102
+ await writeTextFile({
103
+ path: libraryEntryPath(type),
104
+ data: generateEntryPointData(type)
105
+ }).catch((err) => {
106
+ log.error("There was an error generating Function Library Entry Point", err);
107
+ process.exit(ExitCode.FatalError);
108
+ });
109
+ log.success("Created Functions Library Entry Point");
110
+ }
111
+ function generateEntryPointData(type) {
112
+ let arr = [];
113
+ if (type === "functions") {
114
+ if (!library_default.functions?.files) {
115
+ log.error(new Error("There are no functions defined to be built. Please check your config/library.ts file for potential adjustments"));
116
+ process.exit();
117
+ }
118
+ for (const fx of library_default.functions.files) {
119
+ if (Array.isArray(fx))
120
+ arr.push(`export * as ${fx[1]} from '${functionsPath(fx[0])}'`);
121
+ else
122
+ arr.push(`export * from '${functionsPath(fx)}'`);
123
+ }
124
+ return arr.join("\r\n");
125
+ }
126
+ if (type === "vue-components") {
127
+ if (!library_default.vueComponents?.tags) {
128
+ log.error(new Error("There are no components defined to be built. Please check your config/library.ts file for potential adjustments"));
129
+ process.exit();
130
+ }
131
+ arr = determineResetPreset();
132
+ for (const component of library_default.vueComponents.tags.map((tag) => tag.name)) {
133
+ if (Array.isArray(component))
134
+ arr.push(`export { default as ${component[1]} } from '${componentsPath(component[0])}.stx'`);
135
+ else
136
+ arr.push(`export { default as ${component} } from '${componentsPath(component)}.stx'`);
137
+ }
138
+ return arr.join("\r\n");
139
+ }
140
+ arr = determineResetPreset();
141
+ const imports = [...arr, "import { defineCustomElement } from 'vue'"];
142
+ const declarations = [];
143
+ const definitions = [];
144
+ if (!library_default.webComponents?.tags) {
145
+ log.error(new Error("There are no components defined to be built. Please check your config/library.ts file for potential adjustments"));
146
+ process.exit();
147
+ }
148
+ for (const component of library_default.webComponents.tags.map((tag) => tag.name)) {
149
+ if (Array.isArray(component)) {
150
+ imports.push(`import ${component[1]} from '${componentsPath(component[0])}.stx'`);
151
+ declarations.push(`const ${component[1]}CustomElement = defineCustomElement(${component[1]})`);
152
+ definitions.push(`customElements.define('${kebabCase(component[1])}', ${component[1]}CustomElement)`);
153
+ } else {
154
+ imports.push(`import ${component} from '${componentsPath(component)}.stx'`);
155
+ declarations.push(`const ${component}CustomElement = defineCustomElement(${component})`);
156
+ definitions.push(`customElements.define('${kebabCase(component)}', ${component}CustomElement)`);
157
+ }
158
+ }
159
+ return [...imports, ...declarations, ...definitions].join("\r\n");
160
+ }
161
+
162
+ // src/generate/lib-entries.ts
163
+ import {library as library2} from "@stacksjs/config";
164
+ import {log as log2} from "@stacksjs/logging";
165
+ import {hasComponents, hasFunctions} from "@stacksjs/storage";
166
+ if (library2.releaseable && hasComponents()) {
167
+ await generateLibEntry("vue-components");
168
+ await generateLibEntry("web-components");
169
+ } else {
170
+ log2.info("No components found. Skipping building component entry points.");
171
+ }
172
+ if (library2.releaseable && hasFunctions())
173
+ await generateLibEntry("functions");
174
+ else
175
+ log2.info("No functions found. Skipping building function entry point.");
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+
4
+ // src/helpers/vscode-custom-data.ts
5
+ import {log} from "@stacksjs/logging";
6
+ import {customElementsDataPath} from "@stacksjs/path";
7
+ import {writeTextFile} from "@stacksjs/storage";
8
+
9
+ // ../../../../config/library.ts
10
+ var library_default = {
11
+ name: "hello-world",
12
+ owner: "@stacksjs",
13
+ repository: "stacksjs/stacks",
14
+ license: "MIT",
15
+ author: "Chris Breuer",
16
+ contributors: ["Chris Breuer <chris@stacksjs.org>"],
17
+ defaultLanguage: "en",
18
+ releaseable: true,
19
+ vueComponents: {
20
+ name: "hello-world-vue",
21
+ description: "Your Vue component library description",
22
+ keywords: ["component", "library", "vue", "vite", "typescript", "javascript"],
23
+ tags: [
24
+ {
25
+ name: ["HelloWorld", "AppHelloWorld"],
26
+ description: "The Hello World custom element, built via this framework.",
27
+ attributes: [
28
+ {
29
+ name: "greeting",
30
+ description: "The greeting."
31
+ }
32
+ ]
33
+ }
34
+ ]
35
+ },
36
+ webComponents: {
37
+ name: "hello-world-elements",
38
+ description: "Your framework agnostic web component library description.",
39
+ keywords: ["custom-elements", "web-components", "library", "framework-agnostic", "typescript", "javascript"],
40
+ tags: [
41
+ {
42
+ name: ["HelloWorld", "AppHelloWorld"],
43
+ description: "The Hello World custom element, built via this framework.",
44
+ attributes: [
45
+ {
46
+ name: "greeting",
47
+ description: "The greeting."
48
+ }
49
+ ]
50
+ }
51
+ ]
52
+ },
53
+ functions: {
54
+ name: "hello-world-fx",
55
+ description: "Your function library description.",
56
+ keywords: ["functions", "composables", "library", "typescript", "javascript"],
57
+ shouldGenerateSourcemap: false,
58
+ files: ["counter", "dark"]
59
+ }
60
+ };
61
+
62
+ // src/helpers/vscode-custom-data.ts
63
+ async function generateVsCodeCustomData() {
64
+ try {
65
+ log.info("Generating custom-elements.json...");
66
+ await writeTextFile({
67
+ path: customElementsDataPath(),
68
+ data: generateComponentInfoData()
69
+ });
70
+ log.success("Generated custom-elements.json for IDEs.");
71
+ } catch (err) {
72
+ log.error("There was an error generating the custom-elements.json file.", err);
73
+ }
74
+ }
75
+ async function generateWebTypes() {
76
+ log.info("Generating web-types.json...");
77
+ log.info("This feature is not yet implemented.");
78
+ }
79
+ var generateComponentInfoData = function() {
80
+ const componentsData = JSON.stringify(library_default.vueComponents?.tags);
81
+ return `{
82
+ "version": 1.1,
83
+ "tags": ${componentsData}
84
+ }
85
+ `;
86
+ };
87
+
88
+ // src/generate/vscode-custom-data.ts
89
+ import {log as log2} from "@stacksjs/logging";
90
+ import {hasComponents} from "@stacksjs/storage";
91
+ log2.info("Generating VS Code custom data...");
92
+ if (hasComponents())
93
+ await generateVsCodeCustomData();
94
+ else
95
+ log2.info("No components found. Skipping VS Code custom data generation.");
96
+ log2.success("Generated VS Code custom data.");