@stacksjs/actions 0.57.3 → 0.58.19

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 (164) hide show
  1. package/README.md +4 -4
  2. package/dist/src/add.js +29 -0
  3. package/dist/src/build/component-libs.js +6 -0
  4. package/dist/src/build/core.js +25 -0
  5. package/dist/src/build/stacks.js +8 -0
  6. package/dist/src/build.js +226 -0
  7. package/dist/src/bump.js +8 -0
  8. package/dist/src/changelog.js +9 -0
  9. package/dist/src/clean.js +6 -0
  10. package/dist/src/commit.js +17 -0
  11. package/dist/{copy-types.mjs → src/copy-types.js} +7 -4
  12. package/dist/src/database/seed.js +4 -0
  13. package/dist/src/deploy/index.js +31 -0
  14. package/dist/src/dev/components.js +11 -0
  15. package/dist/src/dev/docs.js +7 -0
  16. package/dist/src/dev/index.js +90 -0
  17. package/dist/{examples.mjs → src/examples.js} +18 -8
  18. package/dist/src/fresh.js +18 -0
  19. package/dist/src/generate/component-meta.js +57 -0
  20. package/dist/src/generate/ide-helpers.js +83 -0
  21. package/dist/src/generate/index.js +161 -0
  22. package/dist/src/generate/lib-entries.js +168 -0
  23. package/dist/src/generate/vscode-custom-data.js +82 -0
  24. package/dist/src/generate/vue-compat.js +18 -0
  25. package/dist/{helpers/component-meta.mjs → src/helpers/component-meta.js} +13 -13
  26. package/dist/src/helpers/index.js +56 -0
  27. package/dist/src/helpers/lib-entries.js +160 -0
  28. package/dist/src/helpers/package-json.js +135 -0
  29. package/dist/src/helpers/utils.js +56 -0
  30. package/dist/src/helpers/vscode-custom-data.js +75 -0
  31. package/dist/src/helpers/vue-compat.js +16 -0
  32. package/dist/src/index.js +577 -0
  33. package/dist/src/key-generate.js +10 -0
  34. package/dist/src/lint/fix.js +8 -0
  35. package/dist/src/lint/index.js +21 -0
  36. package/dist/{make.mjs → src/make.js} +71 -49
  37. package/dist/src/prepublish.js +14 -0
  38. package/dist/src/release.js +545 -0
  39. package/dist/src/test/coverage.js +6 -0
  40. package/dist/src/test/feature.js +6 -0
  41. package/dist/src/test/ui.js +6 -0
  42. package/dist/src/test/unit.js +6 -0
  43. package/dist/src/test.js +6 -0
  44. package/dist/src/tinker.js +5 -0
  45. package/dist/src/typecheck.js +6 -0
  46. package/dist/src/types.js +21 -0
  47. package/dist/src/upgrade/dependencies.js +6 -0
  48. package/dist/src/upgrade/framework.js +1 -0
  49. package/dist/src/upgrade/index.js +1 -0
  50. package/dist/src/upgrade.js +39 -0
  51. package/package.json +53 -239
  52. package/LICENSE.md +0 -21
  53. package/dist/add.d.ts +0 -11
  54. package/dist/add.mjs +0 -20
  55. package/dist/build/component-libs.d.ts +0 -1
  56. package/dist/build/component-libs.mjs +0 -4
  57. package/dist/build/core.d.ts +0 -1
  58. package/dist/build/core.mjs +0 -6
  59. package/dist/build/stacks.d.ts +0 -1
  60. package/dist/build/stacks.mjs +0 -12
  61. package/dist/build.d.ts +0 -14
  62. package/dist/build.mjs +0 -68
  63. package/dist/build.ts.d.ts +0 -1
  64. package/dist/build.ts.mjs +0 -13
  65. package/dist/bump.d.ts +0 -1
  66. package/dist/bump.mjs +0 -6
  67. package/dist/changelog.d.ts +0 -1
  68. package/dist/changelog.mjs +0 -6
  69. package/dist/clean.d.ts +0 -1
  70. package/dist/clean.mjs +0 -10
  71. package/dist/commit.d.ts +0 -8
  72. package/dist/commit.mjs +0 -11
  73. package/dist/copy-types.d.ts +0 -5
  74. package/dist/deploy/domains.d.ts +0 -1
  75. package/dist/deploy/domains.mjs +0 -3
  76. package/dist/deploy/index.d.ts +0 -1
  77. package/dist/deploy/index.mjs +0 -3
  78. package/dist/dev/components.d.ts +0 -1
  79. package/dist/dev/components.mjs +0 -4
  80. package/dist/dev/docs.d.ts +0 -1
  81. package/dist/dev/docs.mjs +0 -4
  82. package/dist/dev/index.d.ts +0 -5
  83. package/dist/dev/index.mjs +0 -20
  84. package/dist/examples.d.ts +0 -10
  85. package/dist/fresh.d.ts +0 -1
  86. package/dist/fresh.mjs +0 -6
  87. package/dist/generate/component-meta.d.ts +0 -5
  88. package/dist/generate/component-meta.mjs +0 -8
  89. package/dist/generate/ide-helpers.d.ts +0 -6
  90. package/dist/generate/ide-helpers.mjs +0 -9
  91. package/dist/generate/index.d.ts +0 -17
  92. package/dist/generate/index.mjs +0 -93
  93. package/dist/generate/lib-entries.d.ts +0 -2
  94. package/dist/generate/lib-entries.mjs +0 -14
  95. package/dist/generate/settings.d.ts +0 -1
  96. package/dist/generate/settings.mjs +0 -1
  97. package/dist/generate/vscode-custom-data.d.ts +0 -6
  98. package/dist/generate/vscode-custom-data.mjs +0 -8
  99. package/dist/generate/vue-compat.d.ts +0 -6
  100. package/dist/generate/vue-compat.mjs +0 -3
  101. package/dist/helpers/component-meta.d.ts +0 -22
  102. package/dist/helpers/index.d.ts +0 -6
  103. package/dist/helpers/index.mjs +0 -6
  104. package/dist/helpers/lib-entries.d.ts +0 -13
  105. package/dist/helpers/lib-entries.mjs +0 -101
  106. package/dist/helpers/package-json.d.ts +0 -3
  107. package/dist/helpers/package-json.mjs +0 -82
  108. package/dist/helpers/utils.d.ts +0 -19
  109. package/dist/helpers/utils.mjs +0 -40
  110. package/dist/helpers/vscode-custom-data.d.ts +0 -1
  111. package/dist/helpers/vscode-custom-data.mjs +0 -22
  112. package/dist/helpers/vue-compat.d.ts +0 -1
  113. package/dist/helpers/vue-compat.mjs +0 -12
  114. package/dist/index.d.ts +0 -1
  115. package/dist/index.mjs +0 -1
  116. package/dist/key-generate.d.ts +0 -1
  117. package/dist/key-generate.mjs +0 -8
  118. package/dist/lint/fix.d.ts +0 -1
  119. package/dist/lint/fix.mjs +0 -4
  120. package/dist/lint/index.d.ts +0 -1
  121. package/dist/lint/index.mjs +0 -14
  122. package/dist/make.d.ts +0 -25
  123. package/dist/migrate.d.ts +0 -1
  124. package/dist/migrate.mjs +0 -2
  125. package/dist/preinstall.d.ts +0 -8
  126. package/dist/preinstall.mjs +0 -17
  127. package/dist/prepublish.d.ts +0 -1
  128. package/dist/prepublish.mjs +0 -11
  129. package/dist/release.d.ts +0 -2
  130. package/dist/release.mjs +0 -16
  131. package/dist/seed.d.ts +0 -1
  132. package/dist/seed.mjs +0 -2
  133. package/dist/test/coverage.d.ts +0 -1
  134. package/dist/test/coverage.mjs +0 -4
  135. package/dist/test/feature.d.ts +0 -1
  136. package/dist/test/feature.mjs +0 -4
  137. package/dist/test/ui.d.ts +0 -1
  138. package/dist/test/ui.mjs +0 -4
  139. package/dist/test/unit.d.ts +0 -1
  140. package/dist/test/unit.mjs +0 -4
  141. package/dist/test.d.ts +0 -1
  142. package/dist/test.mjs +0 -4
  143. package/dist/test.ts.d.ts +0 -2
  144. package/dist/test.ts.mjs +0 -6
  145. package/dist/tinker.d.ts +0 -1
  146. package/dist/tinker.mjs +0 -3
  147. package/dist/typecheck.d.ts +0 -1
  148. package/dist/typecheck.mjs +0 -4
  149. package/dist/types.d.ts +0 -8
  150. package/dist/types.mjs +0 -14
  151. package/dist/upgrade/dependencies.d.ts +0 -0
  152. package/dist/upgrade/dependencies.mjs +0 -0
  153. package/dist/upgrade/framework.d.ts +0 -0
  154. package/dist/upgrade/framework.mjs +0 -0
  155. package/dist/upgrade/index.d.ts +0 -0
  156. package/dist/upgrade/index.mjs +0 -0
  157. package/dist/upgrade/node.d.ts +0 -0
  158. package/dist/upgrade/node.mjs +0 -0
  159. package/dist/upgrade/package-manager.d.ts +0 -0
  160. package/dist/upgrade/package-manager.mjs +0 -0
  161. package/dist/upgrade.d.ts +0 -5
  162. package/dist/upgrade.mjs +0 -55
  163. package/dist/upgrade.ts.d.ts +0 -1
  164. package/dist/upgrade.ts.mjs +0 -9
@@ -0,0 +1,83 @@
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
+ // /Users/chrisbreuer/Code/stacks/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
+ vueComponents: {
19
+ name: "hello-world-vue",
20
+ description: "Your Vue component library description",
21
+ keywords: ["component", "library", "vue", "vite", "typescript", "javascript"],
22
+ tags: [{
23
+ name: ["HelloWorld", "AppHelloWorld"],
24
+ description: "The Hello World custom element, built via this framework.",
25
+ attributes: [{
26
+ name: "greeting",
27
+ description: "The greeting."
28
+ }]
29
+ }]
30
+ },
31
+ webComponents: {
32
+ name: "hello-world-elements",
33
+ description: "Your framework agnostic web component library description.",
34
+ keywords: ["custom-elements", "web-components", "library", "framework-agnostic", "typescript", "javascript"],
35
+ tags: [{
36
+ name: ["HelloWorld", "AppHelloWorld"],
37
+ description: "The Hello World custom element, built via this framework.",
38
+ attributes: [{
39
+ name: "greeting",
40
+ description: "The greeting."
41
+ }]
42
+ }]
43
+ },
44
+ functions: {
45
+ name: "hello-world-fx",
46
+ description: "Your function library description.",
47
+ keywords: ["functions", "composables", "library", "typescript", "javascript"],
48
+ shouldGenerateSourcemap: false,
49
+ functions: [
50
+ "counter",
51
+ "dark"
52
+ ]
53
+ }
54
+ };
55
+
56
+ // src/helpers/vscode-custom-data.ts
57
+ async function generateVsCodeCustomData() {
58
+ try {
59
+ await writeTextFile({
60
+ path: customElementsDataPath(),
61
+ data: generateComponentInfoData()
62
+ });
63
+ } catch (err) {
64
+ log.error("There was an error generating the VS Code custom data file.", err);
65
+ }
66
+ }
67
+ var generateComponentInfoData = function() {
68
+ const componentsData = JSON.stringify(library_default.vueComponents?.tags);
69
+ return `{
70
+ "version": 1.1,
71
+ "tags": ${componentsData}
72
+ }
73
+ `;
74
+ };
75
+
76
+ // src/generate/ide-helpers.ts
77
+ import {log as log2} from "@stacksjs/logging";
78
+ import {hasComponents} from "@stacksjs/storage";
79
+ if (hasComponents()) {
80
+ await generateVsCodeCustomData();
81
+ } else {
82
+ log2.info("No components found. Skipping IDE helper generation.");
83
+ }
@@ -0,0 +1,161 @@
1
+ // @bun
2
+ // src/helpers/utils.ts
3
+ import * as storage from "@stacksjs/storage";
4
+ import {italic, runCommand, runCommands, underline} from "@stacksjs/cli";
5
+ import {log} from "@stacksjs/logging";
6
+ import * as p from "@stacksjs/path";
7
+ import {err, handleError} from "@stacksjs/error-handling";
8
+ var parseOptions = function(options) {
9
+ if (!options)
10
+ return "";
11
+ const parsedOptions = Object.entries(options).map(([key, value]) => {
12
+ if (key.length === 1)
13
+ return `-${key}=${value}`;
14
+ if (typeof value === "boolean" && value)
15
+ return `--${key}`;
16
+ return `--${key}=${typeof value === "string" && value.includes(" ") ? `"${value}"` : value}`;
17
+ });
18
+ return parsedOptions.filter(Boolean).join(" ").replace("----=", "");
19
+ };
20
+ async function runAction(action, options) {
21
+ if (!hasAction(action))
22
+ return err(handleError(`The specified action "${action}" does not exist`));
23
+ const opts = parseOptions(options);
24
+ const path = p.relativeActionsPath(`${action}.ts`);
25
+ const cmd = `bun --bun ${`${path} ${opts}`}`;
26
+ const o = {
27
+ cwd: options?.cwd || p.projectPath(),
28
+ ...options
29
+ };
30
+ if (options?.verbose) {
31
+ log.debug("Running cmd:", underline(italic(cmd)));
32
+ log.debug("Running action:", underline(italic(`./actions/${action}.ts`)));
33
+ log.debug("with action options of:", o);
34
+ }
35
+ return await runCommand(cmd, o);
36
+ }
37
+ async function runActions(actions, options) {
38
+ if (!actions.length)
39
+ return err("No actions were specified");
40
+ for (const action of actions) {
41
+ if (!hasAction(action))
42
+ return err(`The specified action "${action}" does not exist`);
43
+ }
44
+ const commands = actions.map((action) => `bun --bun ${p.relativeActionsPath(`${action}.ts`)}`);
45
+ return await runCommands(commands, options);
46
+ }
47
+ function hasAction(action) {
48
+ if (storage.isFile(p.functionsPath(`actions/${action}.ts`)))
49
+ return true;
50
+ return storage.isFile(p.actionsPath(`${action}.ts`));
51
+ }
52
+ // src/generate/index.ts
53
+ import process from "process";
54
+ import {log as log2} from "@stacksjs/logging";
55
+ import {Action, NpmScript} from "@stacksjs/enums";
56
+ import {runNpmScript} from "@stacksjs/utils";
57
+ import {projectPath as projectPath2} from "@stacksjs/path";
58
+ async function invoke(options) {
59
+ if (options?.types)
60
+ await generateTypes(options);
61
+ else if (options?.entries)
62
+ await generateLibEntries(options);
63
+ else if (options?.webTypes)
64
+ await generateWebTypes(options);
65
+ else if (options?.customData)
66
+ await generateVsCodeCustomData(options);
67
+ else if (options?.ideHelpers)
68
+ await generateIdeHelpers(options);
69
+ else if (options?.vueCompatibility)
70
+ await generateVueCompat(options);
71
+ else if (options?.componentMeta)
72
+ await generateComponentMeta(options);
73
+ }
74
+ function generate(options) {
75
+ return invoke(options);
76
+ }
77
+ async function generateLibEntries(options) {
78
+ const result = await runAction(Action.GenerateLibraryEntries, {
79
+ ...options,
80
+ verbose: true,
81
+ cwd: projectPath2()
82
+ });
83
+ if (result.isErr()) {
84
+ log2.error("There was an error generating your library entry points", result.error);
85
+ process.exit();
86
+ }
87
+ log2.success("Library entry points generated successfully");
88
+ }
89
+ async function generateVueCompat(options) {
90
+ const result = await runNpmScript(NpmScript.GenerateVueCompat, options);
91
+ if (result.isErr()) {
92
+ log2.error("There was an error generating Vue 2 compatibility.", result.error);
93
+ process.exit();
94
+ }
95
+ log2.success("Libraries are now Vue 2 & 3 compatible");
96
+ }
97
+ async function generateWebTypes(options) {
98
+ const result = await runNpmScript(NpmScript.GenerateWebTypes, options);
99
+ if (result.isErr()) {
100
+ log2.error("There was an error generating the web-types.json file.", result.error);
101
+ process.exit();
102
+ }
103
+ log2.success("Successfully generated the web-types.json file");
104
+ }
105
+ async function generateVsCodeCustomData(options) {
106
+ const result = await runNpmScript(NpmScript.GenerateVsCodeCustomData, options);
107
+ if (result.isErr()) {
108
+ log2.error("There was an error generating the custom-elements.json file.", result.error);
109
+ process.exit();
110
+ }
111
+ await runAction(Action.LintFix, { verbose: true });
112
+ log2.success("Successfully generated the custom-elements.json file");
113
+ }
114
+ async function generateIdeHelpers(options) {
115
+ const result = await runNpmScript(NpmScript.GenerateIdeHelpers, options);
116
+ if (result.isErr()) {
117
+ log2.error("There was an error generating IDE helpers.", result.error);
118
+ process.exit();
119
+ }
120
+ await runAction(Action.LintFix, { verbose: true });
121
+ log2.success("Successfully generated IDE helpers");
122
+ }
123
+ async function generateComponentMeta(options) {
124
+ const result = await runNpmScript(NpmScript.GenerateComponentMeta, options);
125
+ if (result.isErr()) {
126
+ log2.error("There was an error generating your component meta information.", result.error);
127
+ process.exit();
128
+ }
129
+ await runAction(Action.LintFix, { verbose: true });
130
+ log2.success("Successfully generated component meta information");
131
+ }
132
+ async function generateTypes(options) {
133
+ const result = await runNpmScript(NpmScript.GenerateTypes, options);
134
+ if (result.isErr()) {
135
+ log2.error("There was an error generating your types.", result.error);
136
+ process.exit();
137
+ }
138
+ log2.success("Types were generated successfully");
139
+ }
140
+ function generateMigrations() {
141
+ log2.success("Successfully updated migrations");
142
+ }
143
+ function generatePkgxConfig() {
144
+ log2.success("Successfully generated `./pkgx.yaml` based on your configs");
145
+ }
146
+ async function generateSeeder() {
147
+ }
148
+ export {
149
+ invoke,
150
+ generateWebTypes,
151
+ generateVueCompat,
152
+ generateVsCodeCustomData,
153
+ generateTypes,
154
+ generateSeeder,
155
+ generatePkgxConfig,
156
+ generateMigrations,
157
+ generateLibEntries,
158
+ generateIdeHelpers,
159
+ generateComponentMeta,
160
+ generate
161
+ };
@@ -0,0 +1,168 @@
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 {kebabCase} from "@stacksjs/strings";
8
+ import {componentsPath, functionsPath, libraryEntryPath} from "@stacksjs/path";
9
+ import {writeTextFile} from "@stacksjs/storage";
10
+ import {determineResetPreset} from "@stacksjs/utils";
11
+ import {ExitCode} from "@stacksjs/types";
12
+
13
+ // /Users/chrisbreuer/Code/stacks/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
+ vueComponents: {
23
+ name: "hello-world-vue",
24
+ description: "Your Vue component library description",
25
+ keywords: ["component", "library", "vue", "vite", "typescript", "javascript"],
26
+ tags: [{
27
+ name: ["HelloWorld", "AppHelloWorld"],
28
+ description: "The Hello World custom element, built via this framework.",
29
+ attributes: [{
30
+ name: "greeting",
31
+ description: "The greeting."
32
+ }]
33
+ }]
34
+ },
35
+ webComponents: {
36
+ name: "hello-world-elements",
37
+ description: "Your framework agnostic web component library description.",
38
+ keywords: ["custom-elements", "web-components", "library", "framework-agnostic", "typescript", "javascript"],
39
+ tags: [{
40
+ name: ["HelloWorld", "AppHelloWorld"],
41
+ description: "The Hello World custom element, built via this framework.",
42
+ attributes: [{
43
+ name: "greeting",
44
+ description: "The greeting."
45
+ }]
46
+ }]
47
+ },
48
+ functions: {
49
+ name: "hello-world-fx",
50
+ description: "Your function library description.",
51
+ keywords: ["functions", "composables", "library", "typescript", "javascript"],
52
+ shouldGenerateSourcemap: false,
53
+ functions: [
54
+ "counter",
55
+ "dark"
56
+ ]
57
+ }
58
+ };
59
+
60
+ // src/helpers/lib-entries.ts
61
+ async function generateLibEntry(type) {
62
+ await createLibraryEntryPoint(type);
63
+ }
64
+ async function createLibraryEntryPoint(type) {
65
+ if (type === "vue-components")
66
+ await createVueLibraryEntryPoint();
67
+ if (type === "web-components")
68
+ await createWebComponentLibraryEntryPoint();
69
+ if (type === "functions")
70
+ await createFunctionLibraryEntryPoint();
71
+ }
72
+ async function createVueLibraryEntryPoint(type = "vue-components") {
73
+ log.info("Creating the Vue component library entry point...");
74
+ await writeTextFile({
75
+ path: libraryEntryPath(type),
76
+ data: generateEntryPointData(type)
77
+ }).catch((err) => {
78
+ log.error("There was an error generating the Vue component library entry point.", err);
79
+ process.exit(ExitCode.FatalError);
80
+ });
81
+ log.success("Created the Vue component library entry point");
82
+ }
83
+ async function createWebComponentLibraryEntryPoint(type = "web-components") {
84
+ log.info("Creating the Web Component library entry point...");
85
+ await writeTextFile({
86
+ path: libraryEntryPath(type),
87
+ data: generateEntryPointData(type)
88
+ }).catch((err) => {
89
+ log.error("There was an error generating the Web Component library entry point", err);
90
+ process.exit(ExitCode.FatalError);
91
+ });
92
+ log.success("Created Web Component library entry point");
93
+ }
94
+ async function createFunctionLibraryEntryPoint(type = "functions") {
95
+ log.info("Creating the Function library entry point...");
96
+ await writeTextFile({
97
+ path: libraryEntryPath(type),
98
+ data: generateEntryPointData(type)
99
+ }).catch((err) => {
100
+ log.error("There was an error generating Function library entry point", err);
101
+ process.exit(ExitCode.FatalError);
102
+ });
103
+ log.success("Created Functions library entry point");
104
+ }
105
+ function generateEntryPointData(type) {
106
+ let arr = [];
107
+ if (type === "functions") {
108
+ if (!library_default.functions?.functions) {
109
+ log.error(new Error("There are no functions defined to be built. Please check your config/library.ts file for potential adjustments"));
110
+ process.exit();
111
+ }
112
+ for (const fx of library_default.functions?.functions) {
113
+ if (Array.isArray(fx))
114
+ arr.push(`export * as ${fx[1]} from '${functionsPath(fx[0])}'`);
115
+ else
116
+ arr.push(`export * from '${functionsPath(fx)}'`);
117
+ }
118
+ return arr.join("\r\n");
119
+ }
120
+ if (type === "vue-components") {
121
+ if (!library_default.vueComponents?.tags) {
122
+ log.error(new Error("There are no components defined to be built. Please check your config/library.ts file for potential adjustments"));
123
+ process.exit();
124
+ }
125
+ arr = determineResetPreset();
126
+ for (const component of library_default.vueComponents?.tags.map((tag) => tag.name)) {
127
+ if (Array.isArray(component))
128
+ arr.push(`export { default as ${component[1]} } from '${componentsPath(component[0])}.stx'`);
129
+ else
130
+ arr.push(`export { default as ${component} } from '${componentsPath(component)}.stx'`);
131
+ }
132
+ return arr.join("\r\n");
133
+ }
134
+ arr = determineResetPreset();
135
+ const imports = [...arr, "import { defineCustomElement } from \'vue\'"];
136
+ const declarations = [];
137
+ const definitions = [];
138
+ if (!library_default.webComponents?.tags) {
139
+ log.error(new Error("There are no components defined to be built. Please check your config/library.ts file for potential adjustments"));
140
+ process.exit();
141
+ }
142
+ for (const component of library_default.webComponents?.tags.map((tag) => tag.name)) {
143
+ if (Array.isArray(component)) {
144
+ imports.push(`import ${component[1]} from '${componentsPath(component[0])}.stx'`);
145
+ declarations.push(`const ${component[1]}CustomElement = defineCustomElement(${component[1]})`);
146
+ definitions.push(`customElements.define('${kebabCase(component[1])}', ${component[1]}CustomElement)`);
147
+ } else {
148
+ imports.push(`import ${component} from '${componentsPath(component)}.stx'`);
149
+ declarations.push(`const ${component}CustomElement = defineCustomElement(${component})`);
150
+ definitions.push(`customElements.define('${kebabCase(component)}', ${component}CustomElement)`);
151
+ }
152
+ }
153
+ return [...imports, ...declarations, ...definitions].join("\r\n");
154
+ }
155
+
156
+ // src/generate/lib-entries.ts
157
+ import {log as log2} from "@stacksjs/logging";
158
+ import {hasComponents, hasFunctions} from "@stacksjs/storage";
159
+ if (hasComponents()) {
160
+ await generateLibEntry("vue-components");
161
+ await generateLibEntry("web-components");
162
+ } else {
163
+ log2.info("No components found. Skipping building component entry points.");
164
+ }
165
+ if (hasFunctions())
166
+ await generateLibEntry("functions");
167
+ else
168
+ log2.info("No functions found. Skipping building function entry point.");
@@ -0,0 +1,82 @@
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
+ // /Users/chrisbreuer/Code/stacks/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
+ vueComponents: {
19
+ name: "hello-world-vue",
20
+ description: "Your Vue component library description",
21
+ keywords: ["component", "library", "vue", "vite", "typescript", "javascript"],
22
+ tags: [{
23
+ name: ["HelloWorld", "AppHelloWorld"],
24
+ description: "The Hello World custom element, built via this framework.",
25
+ attributes: [{
26
+ name: "greeting",
27
+ description: "The greeting."
28
+ }]
29
+ }]
30
+ },
31
+ webComponents: {
32
+ name: "hello-world-elements",
33
+ description: "Your framework agnostic web component library description.",
34
+ keywords: ["custom-elements", "web-components", "library", "framework-agnostic", "typescript", "javascript"],
35
+ tags: [{
36
+ name: ["HelloWorld", "AppHelloWorld"],
37
+ description: "The Hello World custom element, built via this framework.",
38
+ attributes: [{
39
+ name: "greeting",
40
+ description: "The greeting."
41
+ }]
42
+ }]
43
+ },
44
+ functions: {
45
+ name: "hello-world-fx",
46
+ description: "Your function library description.",
47
+ keywords: ["functions", "composables", "library", "typescript", "javascript"],
48
+ shouldGenerateSourcemap: false,
49
+ functions: [
50
+ "counter",
51
+ "dark"
52
+ ]
53
+ }
54
+ };
55
+
56
+ // src/helpers/vscode-custom-data.ts
57
+ async function generateVsCodeCustomData() {
58
+ try {
59
+ await writeTextFile({
60
+ path: customElementsDataPath(),
61
+ data: generateComponentInfoData()
62
+ });
63
+ } catch (err) {
64
+ log.error("There was an error generating the VS Code custom data file.", err);
65
+ }
66
+ }
67
+ var generateComponentInfoData = function() {
68
+ const componentsData = JSON.stringify(library_default.vueComponents?.tags);
69
+ return `{
70
+ "version": 1.1,
71
+ "tags": ${componentsData}
72
+ }
73
+ `;
74
+ };
75
+
76
+ // src/generate/vscode-custom-data.ts
77
+ import {log as log2} from "@stacksjs/logging";
78
+ import {hasComponents} from "@stacksjs/storage";
79
+ if (hasComponents())
80
+ await generateVsCodeCustomData();
81
+ else
82
+ log2.info("No components found. Skipping VS Code custom data generation.");
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+
4
+ // src/helpers/vue-compat.ts
5
+ import {fs, glob} from "@stacksjs/storage";
6
+ async function generateVueCompat(paths) {
7
+ const files = await glob(paths, {
8
+ onlyFiles: true
9
+ });
10
+ for (const f of files) {
11
+ const raw = await fs.readFile(f, "utf-8");
12
+ const changed = raw.replace(/"@vue\/composition-api"/g, "\'vue-demi\'").replace(/"vue"/g, "\'vue-demi\'").replace(/'vue'/g, "\'vue-demi\'");
13
+ await fs.writeFile(f, changed, "utf-8");
14
+ }
15
+ }
16
+
17
+ // src/generate/vue-compat.ts
18
+ await generateVueCompat(["wip"]);
@@ -1,29 +1,26 @@
1
- import { existsSync, mkdirSync, writeFileSync } from "node:fs";
2
- import fg from "fast-glob";
1
+ // @bun
2
+ // src/helpers/component-meta.ts
3
+ import {frameworkPath, join, parse, projectPath} from "@stacksjs/path";
4
+ import {existsSync, glob, mkdirSync, writeFileSync} from "@stacksjs/storage";
3
5
  import MarkdownIt from "markdown-it";
4
- import { createComponentMetaChecker } from "vue-component-meta";
5
- import { frameworkPath, join, parse, projectPath } from "@stacksjs/path";
6
- export async function generateComponentMeta() {
7
- const md = new MarkdownIt();
6
+ import {createComponentMetaChecker} from "vue-component-meta";
7
+ function generateComponentMeta() {
8
+ const md = new MarkdownIt;
8
9
  const checkerOptions = {
9
10
  forceUseTs: true,
10
11
  schema: { ignore: ["MyIgnoredNestedProps"] },
11
12
  printer: { newLine: 1 }
12
13
  };
13
- const tsconfigChecker = createComponentMetaChecker(
14
- projectPath("tsconfig.json"),
15
- checkerOptions
16
- );
14
+ const tsconfigChecker = createComponentMetaChecker(projectPath("tsconfig.json"), checkerOptions);
17
15
  const filterMeta = (meta) => {
18
16
  const props = [];
19
17
  meta.props.forEach((prop) => {
20
- if (prop.global)
18
+ if (prop?.global)
21
19
  return;
22
20
  const { name, description, required, type, default: defaultValue } = prop;
23
21
  props.push({
24
22
  name: `${name}${required ? "" : "?"}`,
25
23
  description: md.render(description),
26
- // required,
27
24
  type,
28
25
  default: defaultValue || "unknown"
29
26
  });
@@ -34,7 +31,7 @@ export async function generateComponentMeta() {
34
31
  slots: meta.slots
35
32
  };
36
33
  };
37
- const components = fg.sync(["components/*.vue", "components/**/*.vue"], {
34
+ const components = glob.sync(["components/*.stx", "components/**/*.stx"], {
38
35
  cwd: projectPath(),
39
36
  absolute: true
40
37
  });
@@ -48,3 +45,6 @@ export async function generateComponentMeta() {
48
45
  writeFileSync(metaJsonFilePath, JSON.stringify(meta, null, 4));
49
46
  });
50
47
  }
48
+ export {
49
+ generateComponentMeta
50
+ };
@@ -0,0 +1,56 @@
1
+ // @bun
2
+ // src/helpers/utils.ts
3
+ import * as storage from "@stacksjs/storage";
4
+ import {italic, runCommand, runCommands, underline} from "@stacksjs/cli";
5
+ import {log} from "@stacksjs/logging";
6
+ import * as p from "@stacksjs/path";
7
+ import {err, handleError} from "@stacksjs/error-handling";
8
+ var parseOptions = function(options) {
9
+ if (!options)
10
+ return "";
11
+ const parsedOptions = Object.entries(options).map(([key, value]) => {
12
+ if (key.length === 1)
13
+ return `-${key}=${value}`;
14
+ if (typeof value === "boolean" && value)
15
+ return `--${key}`;
16
+ return `--${key}=${typeof value === "string" && value.includes(" ") ? `"${value}"` : value}`;
17
+ });
18
+ return parsedOptions.filter(Boolean).join(" ").replace("----=", "");
19
+ };
20
+ async function runAction(action, options) {
21
+ if (!hasAction(action))
22
+ return err(handleError(`The specified action "${action}" does not exist`));
23
+ const opts = parseOptions(options);
24
+ const path = p.relativeActionsPath(`${action}.ts`);
25
+ const cmd = `bun --bun ${`${path} ${opts}`}`;
26
+ const o = {
27
+ cwd: options?.cwd || p.projectPath(),
28
+ ...options
29
+ };
30
+ if (options?.verbose) {
31
+ log.debug("Running cmd:", underline(italic(cmd)));
32
+ log.debug("Running action:", underline(italic(`./actions/${action}.ts`)));
33
+ log.debug("with action options of:", o);
34
+ }
35
+ return await runCommand(cmd, o);
36
+ }
37
+ async function runActions(actions, options) {
38
+ if (!actions.length)
39
+ return err("No actions were specified");
40
+ for (const action of actions) {
41
+ if (!hasAction(action))
42
+ return err(`The specified action "${action}" does not exist`);
43
+ }
44
+ const commands = actions.map((action) => `bun --bun ${p.relativeActionsPath(`${action}.ts`)}`);
45
+ return await runCommands(commands, options);
46
+ }
47
+ function hasAction(action) {
48
+ if (storage.isFile(p.functionsPath(`actions/${action}.ts`)))
49
+ return true;
50
+ return storage.isFile(p.actionsPath(`${action}.ts`));
51
+ }
52
+ export {
53
+ runActions,
54
+ runAction,
55
+ hasAction
56
+ };