@stacksjs/actions 0.58.72 → 0.59.1

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 (115) hide show
  1. package/dist/action.d.ts +36 -0
  2. package/dist/add.d.ts +6 -0
  3. package/dist/build/component-libs.d.ts +1 -0
  4. package/dist/build/core.d.ts +1 -0
  5. package/dist/build/stacks.d.ts +1 -0
  6. package/dist/build.d.ts +9 -0
  7. package/dist/bump.d.ts +1 -0
  8. package/dist/changelog.d.ts +1 -0
  9. package/dist/clean.d.ts +1 -0
  10. package/dist/commit.d.ts +3 -0
  11. package/dist/copy-types.d.ts +5 -0
  12. package/dist/database/seed.d.ts +1 -0
  13. package/dist/deploy/index.d.ts +1 -0
  14. package/dist/dev/components.d.ts +1 -0
  15. package/dist/dev/docs.d.ts +1 -0
  16. package/dist/dev/index.d.ts +10 -0
  17. package/dist/examples.d.ts +5 -0
  18. package/dist/fresh.d.ts +1 -0
  19. package/dist/generate/component-meta.d.ts +5 -0
  20. package/dist/generate/ide-helpers.d.ts +6 -0
  21. package/dist/generate/index.d.ts +13 -0
  22. package/dist/generate/lib-entries.d.ts +2 -0
  23. package/dist/generate/vscode-custom-data.d.ts +6 -0
  24. package/dist/helpers/component-meta.d.ts +22 -0
  25. package/dist/helpers/lib-entries.d.ts +13 -0
  26. package/dist/helpers/package-json.d.ts +3 -0
  27. package/dist/helpers/utils.d.ts +18 -0
  28. package/dist/helpers/vscode-custom-data.d.ts +2 -0
  29. package/dist/index.d.ts +7 -0
  30. package/dist/key-generate.d.ts +1 -0
  31. package/dist/lint/fix.d.ts +1 -0
  32. package/dist/lint/index.d.ts +1 -0
  33. package/dist/make.d.ts +20 -0
  34. package/dist/prepublish.d.ts +1 -0
  35. package/dist/release.d.ts +2 -0
  36. package/dist/test/coverage.d.ts +1 -0
  37. package/dist/test/feature.d.ts +1 -0
  38. package/dist/test/ui.d.ts +1 -0
  39. package/dist/test/unit.d.ts +1 -0
  40. package/dist/test.d.ts +1 -0
  41. package/dist/tinker.d.ts +1 -0
  42. package/dist/typecheck.d.ts +1 -0
  43. package/dist/types.d.ts +3 -0
  44. package/dist/upgrade/dependencies.d.ts +1 -0
  45. package/dist/upgrade/framework.d.ts +1 -0
  46. package/dist/upgrade/index.d.ts +1 -0
  47. package/dist/upgrade.d.ts +4 -0
  48. package/package.json +5 -3
  49. package/src/bump.ts +8 -3
  50. package/src/check/ports.ts +27 -0
  51. package/src/deploy/index.ts +2 -6
  52. package/src/dev/api.ts +1 -1
  53. package/src/dev/index.ts +1 -1
  54. package/src/find-projects.ts +21 -0
  55. package/src/generate/action-types.ts +14 -78
  56. package/src/generate/custom-cli-file.ts +1 -1
  57. package/src/generate/index.ts +10 -2
  58. package/src/generate/symlink-core.ts +3 -0
  59. package/src/helpers/lib-entries.ts +3 -3
  60. package/src/helpers/utils.ts +10 -14
  61. package/src/index.ts +1 -2
  62. package/src/lint/fix.ts +1 -0
  63. package/src/upgrade/binary.ts +43 -0
  64. package/src/upgrade/index.ts +6 -0
  65. package/src/upgrade/shell.ts +64 -0
  66. package/dist/src/add.js +0 -29
  67. package/dist/src/build/component-libs.js +0 -6
  68. package/dist/src/build/core.js +0 -21
  69. package/dist/src/build/stacks.js +0 -8
  70. package/dist/src/build.js +0 -213
  71. package/dist/src/bump.js +0 -14
  72. package/dist/src/changelog.js +0 -17
  73. package/dist/src/clean.js +0 -6
  74. package/dist/src/commit.js +0 -17
  75. package/dist/src/copy-types.js +0 -14
  76. package/dist/src/database/seed.js +0 -1
  77. package/dist/src/deploy/index.js +0 -31
  78. package/dist/src/dev/components.js +0 -11
  79. package/dist/src/dev/docs.js +0 -7
  80. package/dist/src/dev/index.js +0 -92
  81. package/dist/src/examples.js +0 -43
  82. package/dist/src/fresh.js +0 -18
  83. package/dist/src/generate/component-meta.js +0 -59
  84. package/dist/src/generate/ide-helpers.js +0 -91
  85. package/dist/src/generate/index.js +0 -147
  86. package/dist/src/generate/lib-entries.js +0 -170
  87. package/dist/src/generate/vscode-custom-data.js +0 -91
  88. package/dist/src/helpers/component-meta.js +0 -50
  89. package/dist/src/helpers/index.js +0 -48
  90. package/dist/src/helpers/lib-entries.js +0 -161
  91. package/dist/src/helpers/package-json.js +0 -136
  92. package/dist/src/helpers/utils.js +0 -48
  93. package/dist/src/helpers/vscode-custom-data.js +0 -83
  94. package/dist/src/index.js +0 -583
  95. package/dist/src/key-generate.js +0 -10
  96. package/dist/src/lint/fix.js +0 -12
  97. package/dist/src/lint/index.js +0 -17
  98. package/dist/src/make.js +0 -291
  99. package/dist/src/prepublish.js +0 -14
  100. package/dist/src/release.js +0 -553
  101. package/dist/src/test/coverage.js +0 -6
  102. package/dist/src/test/feature.js +0 -6
  103. package/dist/src/test/ui.js +0 -6
  104. package/dist/src/test/unit.js +0 -6
  105. package/dist/src/test.js +0 -6
  106. package/dist/src/tinker.js +0 -5
  107. package/dist/src/typecheck.js +0 -6
  108. package/dist/src/types.js +0 -21
  109. package/dist/src/upgrade/dependencies.js +0 -6
  110. package/dist/src/upgrade/framework.js +0 -1
  111. package/dist/src/upgrade/index.js +0 -54
  112. package/dist/src/upgrade.js +0 -47
  113. package/src/generate/caddyfile.ts +0 -1
  114. package/src/helpers/index.ts +0 -1
  115. package/src/start-caddy.ts +0 -13
@@ -1,92 +0,0 @@
1
- // @bun
2
- // src/helpers/utils.ts
3
- import * as storage from "@stacksjs/storage";
4
- import {buddyOptions, runCommand, runCommands} 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
- async function runAction(action, options) {
9
- const opts = buddyOptions();
10
- const path = p.relativeActionsPath(`${action}.ts`);
11
- const cmd = `bun --bun ${path} ${opts}`.trimEnd();
12
- const optionsWithCwd = {
13
- cwd: options?.cwd || p.projectPath(),
14
- ...options
15
- };
16
- log.debug("runAction:", cmd);
17
- log.debug("action options:", optionsWithCwd);
18
- if (!hasAction(action))
19
- return err(handleError(`The specified action "${action}" does not exist`));
20
- return await runCommand(cmd, optionsWithCwd);
21
- }
22
- async function runActions(actions, options) {
23
- log.debug("runActions:", actions);
24
- log.debug("actions options:", options);
25
- if (!actions.length)
26
- return err("No actions were specified");
27
- for (const action of actions) {
28
- if (!hasAction(action))
29
- return err(`The specified action "${action}" does not exist`);
30
- }
31
- const opts = buddyOptions();
32
- const o = {
33
- cwd: options?.cwd || p.projectPath(),
34
- ...options
35
- };
36
- const commands = actions.map((action) => `bun --bun ${p.relativeActionsPath(`${action}.ts`)} ${opts}`);
37
- return await runCommands(commands, o);
38
- }
39
- function hasAction(action) {
40
- if (storage.isFile(p.functionsPath(`actions/${action}.ts`)))
41
- return true;
42
- return storage.isFile(p.actionsPath(`${action}.ts`));
43
- }
44
- // src/dev/index.ts
45
- import {log as log2} from "@stacksjs/logging";
46
- import {Action} from "@stacksjs/enums";
47
- async function runDevServer(options) {
48
- log2.info("Starting your Frontend Engine...");
49
- await runAction(Action.Dev, options);
50
- }
51
- async function runFrontendDevServer(options) {
52
- log2.info("Starting your UI Engine...");
53
- await runAction(Action.Dev, options);
54
- }
55
- async function runBackendDevServer(options) {
56
- runApiDevServer(options);
57
- }
58
- async function runApiDevServer(options) {
59
- log2.info("Starting your API...");
60
- await runAction(Action.DevApi, options);
61
- }
62
- async function runComponentsDevServer(options) {
63
- log2.info("Starting your Library Engine...");
64
- await runAction(Action.DevComponents, options);
65
- }
66
- async function runDashboardDevServer(options) {
67
- log2.info("Starting your Dashboard...");
68
- await runAction(Action.DevDashboard, options);
69
- }
70
- async function runSystemTrayDevServer(options) {
71
- log2.info("Starting your System Tray...");
72
- await runAction(Action.DevSystemTray, options);
73
- }
74
- async function runDesktopDevServer(options) {
75
- log2.info("Starting your Desktop Engine...");
76
- await runAction(Action.DevDesktop, options);
77
- }
78
- async function runDocsDevServer(options) {
79
- log2.info("Starting your Docs Engine...");
80
- await runAction(Action.DevDocs, options);
81
- }
82
- export {
83
- runSystemTrayDevServer,
84
- runFrontendDevServer,
85
- runDocsDevServer,
86
- runDevServer,
87
- runDesktopDevServer,
88
- runDashboardDevServer,
89
- runComponentsDevServer,
90
- runBackendDevServer,
91
- runApiDevServer
92
- };
@@ -1,43 +0,0 @@
1
- // @bun
2
- // src/examples.ts
3
- import process from "process";
4
- import {log} from "@stacksjs/logging";
5
- import {hasComponents} from "@stacksjs/storage";
6
- import {runNpmScript} from "@stacksjs/utils";
7
- import {ExitCode} from "@stacksjs/types";
8
- import {NpmScript} from "@stacksjs/enums";
9
- async function invoke(options) {
10
- if (options.components || options.vue)
11
- await componentExample(options);
12
- else if (options.webComponents || options.elements)
13
- await webComponentExample(options);
14
- else
15
- log.error("An unsupported option was used. Please try again, check the documentation & report the issue, if needed.");
16
- }
17
- async function examples(options) {
18
- return invoke(options);
19
- }
20
- async function componentExample(options) {
21
- if (hasComponents()) {
22
- await runNpmScript(NpmScript.ExampleVue, options);
23
- log.success("Your component library was built successfully");
24
- } else {
25
- log.info("No components found.");
26
- }
27
- }
28
- async function webComponentExample(options) {
29
- if (hasComponents()) {
30
- log.info("Building your Web Component library...");
31
- await runNpmScript(NpmScript.BuildWebComponents, options);
32
- log.success("Your Web Component library was built successfully");
33
- } else {
34
- log.info("No components found.");
35
- process.exit(ExitCode.FatalError);
36
- }
37
- }
38
- export {
39
- webComponentExample,
40
- invoke,
41
- examples,
42
- componentExample
43
- };
package/dist/src/fresh.js DELETED
@@ -1,18 +0,0 @@
1
- // @bun
2
- // src/fresh.ts
3
- import process from "process";
4
- import {ExitCode} from "@stacksjs/types";
5
- import {runCommand} from "@stacksjs/cli";
6
- import {logger} from "@stacksjs/logging";
7
- import {projectPath} from "@stacksjs/path";
8
- import {cleanProject} from "@stacksjs/utils";
9
- logger.log("Cleaning project...");
10
- await cleanProject();
11
- logger.log("Installing dependencies...");
12
- var result = await runCommand("bun install", {
13
- cwd: projectPath()
14
- });
15
- if (result.isErr()) {
16
- handleError(result.error);
17
- process.exit(ExitCode.FatalError);
18
- }
@@ -1,59 +0,0 @@
1
- #!/usr/bin/env bun
2
- // @bun
3
-
4
- // src/helpers/component-meta.ts
5
- import {frameworkPath, join, parse, 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"], {
37
- cwd: projectPath(),
38
- absolute: true
39
- });
40
- components.forEach((componentPath) => {
41
- const componentExportName = 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.");
@@ -1,91 +0,0 @@
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
- // /home/runner/work/stacks/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
- 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
- name: ["HelloWorld", "AppHelloWorld"],
25
- description: "The Hello World custom element, built via this framework.",
26
- attributes: [{
27
- name: "greeting",
28
- description: "The greeting."
29
- }]
30
- }]
31
- },
32
- webComponents: {
33
- name: "hello-world-elements",
34
- description: "Your framework agnostic web component library description.",
35
- keywords: ["custom-elements", "web-components", "library", "framework-agnostic", "typescript", "javascript"],
36
- tags: [{
37
- name: ["HelloWorld", "AppHelloWorld"],
38
- description: "The Hello World custom element, built via this framework.",
39
- attributes: [{
40
- name: "greeting",
41
- description: "The greeting."
42
- }]
43
- }]
44
- },
45
- functions: {
46
- name: "hello-world-fx",
47
- description: "Your function library description.",
48
- keywords: ["functions", "composables", "library", "typescript", "javascript"],
49
- shouldGenerateSourcemap: false,
50
- functions: [
51
- "counter",
52
- "dark"
53
- ]
54
- }
55
- };
56
-
57
- // src/helpers/vscode-custom-data.ts
58
- async function generateVsCodeCustomData() {
59
- try {
60
- log.info("Generating custom-elements.json...");
61
- await writeTextFile({
62
- path: customElementsDataPath(),
63
- data: generateComponentInfoData()
64
- });
65
- log.success("Generated custom-elements.json for IDEs.");
66
- } catch (err) {
67
- log.error("There was an error generating the custom-elements.json file.", err);
68
- }
69
- }
70
- async function generateWebTypes() {
71
- log.info("Generating web-types.json...");
72
- log.info("This feature is not yet implemented.");
73
- }
74
- var generateComponentInfoData = function() {
75
- const componentsData = JSON.stringify(library_default.vueComponents?.tags);
76
- return `{
77
- "version": 1.1,
78
- "tags": ${componentsData}
79
- }
80
- `;
81
- };
82
-
83
- // src/generate/ide-helpers.ts
84
- import {log as log2} from "@stacksjs/logging";
85
- import {hasComponents} from "@stacksjs/storage";
86
- if (hasComponents()) {
87
- await generateWebTypes();
88
- await generateVsCodeCustomData();
89
- } else {
90
- log2.info("No components found. Skipping IDE helper generation.");
91
- }
@@ -1,147 +0,0 @@
1
- // @bun
2
- // src/helpers/utils.ts
3
- import * as storage from "@stacksjs/storage";
4
- import {buddyOptions, runCommand, runCommands} 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
- async function runAction(action, options) {
9
- const opts = buddyOptions();
10
- const path = p.relativeActionsPath(`${action}.ts`);
11
- const cmd = `bun --bun ${path} ${opts}`.trimEnd();
12
- const optionsWithCwd = {
13
- cwd: options?.cwd || p.projectPath(),
14
- ...options
15
- };
16
- log.debug("runAction:", cmd);
17
- log.debug("action options:", optionsWithCwd);
18
- if (!hasAction(action))
19
- return err(handleError(`The specified action "${action}" does not exist`));
20
- return await runCommand(cmd, optionsWithCwd);
21
- }
22
- async function runActions(actions, options) {
23
- log.debug("runActions:", actions);
24
- log.debug("actions options:", options);
25
- if (!actions.length)
26
- return err("No actions were specified");
27
- for (const action of actions) {
28
- if (!hasAction(action))
29
- return err(`The specified action "${action}" does not exist`);
30
- }
31
- const opts = buddyOptions();
32
- const o = {
33
- cwd: options?.cwd || p.projectPath(),
34
- ...options
35
- };
36
- const commands = actions.map((action) => `bun --bun ${p.relativeActionsPath(`${action}.ts`)} ${opts}`);
37
- return await runCommands(commands, o);
38
- }
39
- function hasAction(action) {
40
- if (storage.isFile(p.functionsPath(`actions/${action}.ts`)))
41
- return true;
42
- return storage.isFile(p.actionsPath(`${action}.ts`));
43
- }
44
- // src/generate/index.ts
45
- import process from "process";
46
- import {log as log2} from "@stacksjs/logging";
47
- import {Action, NpmScript} from "@stacksjs/enums";
48
- import {runNpmScript} from "@stacksjs/utils";
49
- import {frameworkPath, projectPath as projectPath2} from "@stacksjs/path";
50
- async function invoke(options) {
51
- if (options?.types)
52
- await generateTypes(options);
53
- else if (options?.entries)
54
- await generateLibEntries(options);
55
- else if (options?.webTypes)
56
- await generateWebTypes(options);
57
- else if (options?.customData)
58
- await generateVsCodeCustomData(options);
59
- else if (options?.ideHelpers)
60
- await generateIdeHelpers(options);
61
- else if (options?.componentMeta)
62
- await generateComponentMeta(options);
63
- }
64
- function generate(options) {
65
- return invoke(options);
66
- }
67
- async function generateLibEntries(options) {
68
- const result = await runAction(Action.GenerateLibraryEntries, {
69
- ...options,
70
- cwd: projectPath2()
71
- });
72
- if (result.isErr()) {
73
- log2.error("There was an error generating your library entry points", result.error);
74
- process.exit();
75
- }
76
- log2.success("Library entry points generated successfully");
77
- }
78
- async function generateWebTypes(options) {
79
- const result = await runNpmScript(NpmScript.GenerateWebTypes, options);
80
- if (result.isErr()) {
81
- log2.error("There was an error generating the web-types.json file.", result.error);
82
- process.exit();
83
- }
84
- log2.success("Successfully generated the web-types.json file");
85
- }
86
- async function generateVsCodeCustomData(options) {
87
- const result = await runNpmScript(NpmScript.GenerateVsCodeCustomData, {
88
- cwd: frameworkPath(),
89
- ...options
90
- });
91
- if (result.isErr()) {
92
- log2.error("There was an error generating the custom-elements.json file.", result.error);
93
- process.exit();
94
- }
95
- await runAction(Action.LintFix, { verbose: true });
96
- log2.success("Successfully generated the custom-elements.json file");
97
- }
98
- async function generateIdeHelpers(options) {
99
- const result = await runNpmScript(NpmScript.GenerateIdeHelpers, options);
100
- if (result.isErr()) {
101
- log2.error("There was an error generating IDE helpers.", result.error);
102
- process.exit();
103
- }
104
- await runAction(Action.LintFix, { verbose: true });
105
- log2.success("Successfully generated IDE helpers");
106
- }
107
- async function generateComponentMeta(options) {
108
- const result = await runNpmScript(NpmScript.GenerateComponentMeta, options);
109
- if (result.isErr()) {
110
- log2.error("There was an error generating your component meta information.", result.error);
111
- process.exit();
112
- }
113
- await runAction(Action.LintFix, { verbose: true });
114
- log2.success("Successfully generated component meta information");
115
- }
116
- async function generateTypes(options) {
117
- const result = await runNpmScript(NpmScript.GenerateTypes, {
118
- cwd: frameworkPath(),
119
- ...options
120
- });
121
- if (result.isErr()) {
122
- log2.error("There was an error generating your types.", result.error);
123
- process.exit();
124
- }
125
- log2.success("Types were generated successfully");
126
- }
127
- function generateMigrations() {
128
- log2.success("Successfully updated migrations");
129
- }
130
- function generatePkgxConfig() {
131
- log2.success("Successfully generated `./pkgx.yaml` based on your configs");
132
- }
133
- async function generateSeeder() {
134
- }
135
- export {
136
- invoke,
137
- generateWebTypes,
138
- generateVsCodeCustomData,
139
- generateTypes,
140
- generateSeeder,
141
- generatePkgxConfig,
142
- generateMigrations,
143
- generateLibEntries,
144
- generateIdeHelpers,
145
- generateComponentMeta,
146
- generate
147
- };
@@ -1,170 +0,0 @@
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
- // /home/runner/work/stacks/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
- 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
- name: ["HelloWorld", "AppHelloWorld"],
29
- description: "The Hello World custom element, built via this framework.",
30
- attributes: [{
31
- name: "greeting",
32
- description: "The greeting."
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
- name: ["HelloWorld", "AppHelloWorld"],
42
- description: "The Hello World custom element, built via this framework.",
43
- attributes: [{
44
- name: "greeting",
45
- description: "The greeting."
46
- }]
47
- }]
48
- },
49
- functions: {
50
- name: "hello-world-fx",
51
- description: "Your function library description.",
52
- keywords: ["functions", "composables", "library", "typescript", "javascript"],
53
- shouldGenerateSourcemap: false,
54
- functions: [
55
- "counter",
56
- "dark"
57
- ]
58
- }
59
- };
60
-
61
- // src/helpers/lib-entries.ts
62
- async function generateLibEntry(type) {
63
- await createLibraryEntryPoint(type);
64
- }
65
- async function createLibraryEntryPoint(type) {
66
- if (type === "vue-components")
67
- await createVueLibraryEntryPoint();
68
- if (type === "web-components")
69
- await createWebComponentLibraryEntryPoint();
70
- if (type === "functions")
71
- await createFunctionLibraryEntryPoint();
72
- }
73
- async function createVueLibraryEntryPoint(type = "vue-components") {
74
- log.info("Creating Vue Component Library Entry Point...");
75
- await writeTextFile({
76
- path: libraryEntryPath(type),
77
- data: generateEntryPointData(type)
78
- }).catch((err) => {
79
- log.error("There was an error generating the Vue Component Library Entry Point.", err);
80
- process.exit(ExitCode.FatalError);
81
- });
82
- log.success("Created Vue Component Library Entry Point");
83
- }
84
- async function createWebComponentLibraryEntryPoint(type = "web-components") {
85
- log.info("Creating Web Component Library Entry Point...");
86
- await writeTextFile({
87
- path: libraryEntryPath(type),
88
- data: generateEntryPointData(type)
89
- }).catch((err) => {
90
- log.error("There was an error generating the Web Component library entry point", err);
91
- process.exit(ExitCode.FatalError);
92
- });
93
- log.success("Created Web Component Library Entry Point");
94
- }
95
- async function createFunctionLibraryEntryPoint(type = "functions") {
96
- log.info("Creating Function Library Entry Point...");
97
- await writeTextFile({
98
- path: libraryEntryPath(type),
99
- data: generateEntryPointData(type)
100
- }).catch((err) => {
101
- log.error("There was an error generating Function Library Entry Point", err);
102
- process.exit(ExitCode.FatalError);
103
- });
104
- log.success("Created Functions Library Entry Point");
105
- }
106
- function generateEntryPointData(type) {
107
- let arr = [];
108
- if (type === "functions") {
109
- if (!library_default.functions?.functions) {
110
- log.error(new Error("There are no functions defined to be built. Please check your config/library.ts file for potential adjustments"));
111
- process.exit();
112
- }
113
- for (const fx of library_default.functions?.functions) {
114
- if (Array.isArray(fx))
115
- arr.push(`export * as ${fx[1]} from '${functionsPath(fx[0])}'`);
116
- else
117
- arr.push(`export * from '${functionsPath(fx)}'`);
118
- }
119
- return arr.join("\r\n");
120
- }
121
- if (type === "vue-components") {
122
- if (!library_default.vueComponents?.tags) {
123
- log.error(new Error("There are no components defined to be built. Please check your config/library.ts file for potential adjustments"));
124
- process.exit();
125
- }
126
- arr = determineResetPreset();
127
- for (const component of library_default.vueComponents?.tags.map((tag) => tag.name)) {
128
- if (Array.isArray(component))
129
- arr.push(`export { default as ${component[1]} } from '${componentsPath(component[0])}.stx'`);
130
- else
131
- arr.push(`export { default as ${component} } from '${componentsPath(component)}.stx'`);
132
- }
133
- return arr.join("\r\n");
134
- }
135
- arr = determineResetPreset();
136
- const imports = [...arr, "import { defineCustomElement } from \'vue\'"];
137
- const declarations = [];
138
- const definitions = [];
139
- if (!library_default.webComponents?.tags) {
140
- log.error(new Error("There are no components defined to be built. Please check your config/library.ts file for potential adjustments"));
141
- process.exit();
142
- }
143
- for (const component of library_default.webComponents?.tags.map((tag) => tag.name)) {
144
- if (Array.isArray(component)) {
145
- imports.push(`import ${component[1]} from '${componentsPath(component[0])}.stx'`);
146
- declarations.push(`const ${component[1]}CustomElement = defineCustomElement(${component[1]})`);
147
- definitions.push(`customElements.define('${kebabCase(component[1])}', ${component[1]}CustomElement)`);
148
- } else {
149
- imports.push(`import ${component} from '${componentsPath(component)}.stx'`);
150
- declarations.push(`const ${component}CustomElement = defineCustomElement(${component})`);
151
- definitions.push(`customElements.define('${kebabCase(component)}', ${component}CustomElement)`);
152
- }
153
- }
154
- return [...imports, ...declarations, ...definitions].join("\r\n");
155
- }
156
-
157
- // src/generate/lib-entries.ts
158
- import {log as log2} from "@stacksjs/logging";
159
- import {library as library2} from "@stacksjs/config";
160
- import {hasComponents, hasFunctions} from "@stacksjs/storage";
161
- if (library2.releaseable && hasComponents()) {
162
- await generateLibEntry("vue-components");
163
- await generateLibEntry("web-components");
164
- } else {
165
- log2.info("No components found. Skipping building component entry points.");
166
- }
167
- if (library2.releaseable && hasFunctions())
168
- await generateLibEntry("functions");
169
- else
170
- log2.info("No functions found. Skipping building function entry point.");