@stacksjs/actions 0.50.0 → 0.52.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 (88) hide show
  1. package/README.md +1 -1
  2. package/dist/{build-component-libs.mjs → build/component-libs.mjs} +1 -1
  3. package/dist/build/core.mjs +6 -0
  4. package/dist/{build-stacks.mjs → build/stacks.mjs} +1 -1
  5. package/dist/build.mjs +1 -1
  6. package/dist/bump.mjs +1 -1
  7. package/dist/changelog.mjs +1 -1
  8. package/dist/clean.d.ts +1 -8
  9. package/dist/clean.mjs +8 -12
  10. package/dist/deploy/domains.mjs +3 -0
  11. package/dist/deploy.mjs +6 -0
  12. package/dist/{dev-components.mjs → dev/components.mjs} +1 -1
  13. package/dist/{test-ui.mjs → dev/docs.mjs} +2 -2
  14. package/dist/{dev.d.ts → dev/index.d.ts} +1 -3
  15. package/dist/{dev.mjs → dev/index.mjs} +0 -17
  16. package/dist/fresh.mjs +2 -2
  17. package/dist/{generate-component-meta.mjs → generate/component-meta.mjs} +1 -1
  18. package/dist/{generate-ide-helpers.mjs → generate/ide-helpers.mjs} +1 -1
  19. package/dist/{generate.d.ts → generate/index.d.ts} +2 -0
  20. package/dist/{generate.mjs → generate/index.mjs} +15 -6
  21. package/dist/{generate-lib-entries.mjs → generate/lib-entries.mjs} +1 -1
  22. package/dist/{generate-package-jsons.mjs → generate/package-jsons.mjs} +1 -1
  23. package/dist/generate/settings.d.ts +2 -0
  24. package/dist/generate/settings.mjs +3 -0
  25. package/dist/{generate-vscode-custom-data.mjs → generate/vscode-custom-data.mjs} +1 -1
  26. package/dist/generate/vue-compat.mjs +3 -0
  27. package/dist/helpers/lib-entries.mjs +6 -6
  28. package/dist/helpers/package-json.mjs +9 -9
  29. package/dist/helpers/utils.d.ts +4 -5
  30. package/dist/helpers/utils.mjs +13 -10
  31. package/dist/helpers/vscode-custom-data.mjs +1 -1
  32. package/dist/key-generate.mjs +2 -2
  33. package/dist/{lint.mjs → lint/index.mjs} +1 -1
  34. package/dist/make.d.ts +2 -2
  35. package/dist/make.mjs +56 -15
  36. package/dist/migrate.mjs +2 -0
  37. package/dist/preinstall.mjs +2 -2
  38. package/dist/prepublish.mjs +1 -1
  39. package/dist/release.mjs +3 -5
  40. package/dist/seed.mjs +2 -0
  41. package/dist/test/coverage.d.ts +1 -0
  42. package/dist/{test-coverage.mjs → test/coverage.mjs} +1 -1
  43. package/dist/test/feature.d.ts +1 -0
  44. package/dist/test/feature.mjs +4 -0
  45. package/dist/test/ui.d.ts +1 -0
  46. package/dist/{test-unit.mjs → test/ui.mjs} +1 -1
  47. package/dist/test/unit.d.ts +1 -0
  48. package/dist/{test-feature.mjs → test/unit.mjs} +1 -1
  49. package/dist/test.mjs +1 -1
  50. package/dist/tinker.d.ts +1 -0
  51. package/dist/tinker.mjs +3 -0
  52. package/dist/typecheck.mjs +1 -1
  53. package/dist/upgrade/dependencies.d.ts +0 -0
  54. package/dist/upgrade/dependencies.mjs +0 -0
  55. package/dist/upgrade/framework.d.ts +1 -0
  56. package/dist/upgrade/framework.mjs +18 -0
  57. package/dist/upgrade/index.d.ts +1 -0
  58. package/dist/upgrade/index.mjs +11 -0
  59. package/dist/upgrade/node.d.ts +1 -0
  60. package/dist/upgrade/node.mjs +3 -0
  61. package/dist/upgrade/package-manager.d.ts +1 -0
  62. package/dist/upgrade/package-manager.mjs +3 -0
  63. package/dist/upgrade.d.ts +5 -0
  64. package/dist/upgrade.mjs +55 -0
  65. package/package.json +224 -22
  66. package/dist/build-core.mjs +0 -8
  67. package/dist/fix-lint-issues.mjs +0 -3
  68. package/dist/generate-vue-compat.mjs +0 -3
  69. package/dist/update.d.ts +0 -14
  70. package/dist/update.mjs +0 -100
  71. /package/dist/{build-component-libs.d.ts → build/component-libs.d.ts} +0 -0
  72. /package/dist/{build-core.d.ts → build/core.d.ts} +0 -0
  73. /package/dist/{build-stacks.d.ts → build/stacks.d.ts} +0 -0
  74. /package/dist/{fix-lint-issues.d.ts → deploy/domains.d.ts} +0 -0
  75. /package/dist/{dev-components.d.ts → deploy.d.ts} +0 -0
  76. /package/dist/{lint-fix.d.ts → dev/components.d.ts} +0 -0
  77. /package/dist/{lint.d.ts → dev/docs.d.ts} +0 -0
  78. /package/dist/{generate-component-meta.d.ts → generate/component-meta.d.ts} +0 -0
  79. /package/dist/{generate-ide-helpers.d.ts → generate/ide-helpers.d.ts} +0 -0
  80. /package/dist/{generate-lib-entries.d.ts → generate/lib-entries.d.ts} +0 -0
  81. /package/dist/{generate-package-jsons.d.ts → generate/package-jsons.d.ts} +0 -0
  82. /package/dist/{generate-vscode-custom-data.d.ts → generate/vscode-custom-data.d.ts} +0 -0
  83. /package/dist/{generate-vue-compat.d.ts → generate/vue-compat.d.ts} +0 -0
  84. /package/dist/{test-coverage.d.ts → lint/fix.d.ts} +0 -0
  85. /package/dist/{lint-fix.mjs → lint/fix.mjs} +0 -0
  86. /package/dist/{test-feature.d.ts → lint/index.d.ts} +0 -0
  87. /package/dist/{test-ui.d.ts → migrate.d.ts} +0 -0
  88. /package/dist/{test-unit.d.ts → seed.d.ts} +0 -0
package/README.md CHANGED
@@ -37,7 +37,7 @@ pnpm test
37
37
 
38
38
  Please see our [releases](https://github.com/stacksjs/stacks/releases) page for more information on what has changed recently.
39
39
 
40
- ## 💪🏼 Contributing
40
+ ## 🚜 Contributing
41
41
 
42
42
  Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.
43
43
 
@@ -2,7 +2,7 @@ import { log } from "@stacksjs/logging";
2
2
  import { frameworkPath } from "@stacksjs/path";
3
3
  import { runCommand } from "@stacksjs/cli";
4
4
  log.info("Building Component Libraries...");
5
- const result = await runCommand("npx mkdist -d", { debug: true, cwd: frameworkPath() });
5
+ const result = await runCommand("npx mkdist -d", { verbose: true, cwd: frameworkPath() });
6
6
  if (result.isErr()) {
7
7
  log.error("There was an error running `npx mkdist -d`.", result.error);
8
8
  process.exit();
@@ -0,0 +1,6 @@
1
+ import { frameworkPath } from "@stacksjs/path";
2
+ import { runCommands } from "@stacksjs/cli";
3
+ await runCommands([
4
+ 'pnpm -r --filter "./core/*" --filter "!./core/x-ray" build'
5
+ // build all packages except x-ray (which is a dev tool/app)
6
+ ], { verbose: true, cwd: frameworkPath(), shell: true });
@@ -9,4 +9,4 @@ await runCommands([
9
9
  // command to build the Stacks Core
10
10
  "cp -a ./core/. ./"
11
11
  // copy the core stacks to the famework's root
12
- ], { debug: true, cwd: frameworkPath() });
12
+ ], { verbose: true, cwd: frameworkPath() });
package/dist/build.mjs CHANGED
@@ -2,7 +2,7 @@ import { log } from "@stacksjs/logging";
2
2
  import { hasComponents, hasFunctions } from "@stacksjs/storage";
3
3
  import { runNpmScript } from "@stacksjs/utils";
4
4
  import { NpmScript } from "@stacksjs/types";
5
- import { types as generateTypes } from "./generate.mjs";
5
+ import { types as generateTypes } from "./generate/index.mjs";
6
6
  export async function invoke(options) {
7
7
  if (options.components)
8
8
  await componentLibraries(options);
package/dist/bump.mjs CHANGED
@@ -2,5 +2,5 @@ import { runCommand } from "@stacksjs/cli";
2
2
  import { frameworkPath } from "@stacksjs/path";
3
3
  await runCommand(
4
4
  'npx bumpp ./package.json ./buddy/package.json ./core/**/package.json ./vscode/package.json --execute "pnpm buddy changelog" --all',
5
- { debug: true, cwd: frameworkPath(), shell: true }
5
+ { verbose: true, cwd: frameworkPath(), shell: true }
6
6
  );
@@ -2,5 +2,5 @@ import { runCommand } from "@stacksjs/cli";
2
2
  import { projectPath } from "@stacksjs/path";
3
3
  await runCommand(
4
4
  "changelogen --output CHANGELOG.md --from $(git describe --abbrev=0 --tags HEAD^) --to $(git describe)",
5
- { debug: true, cwd: projectPath(), shell: true }
5
+ { verbose: true, cwd: projectPath(), shell: true }
6
6
  );
package/dist/clean.d.ts CHANGED
@@ -1,8 +1 @@
1
- import { type CleanOptions } from '@stacksjs/types';
2
- export declare function invoke(options?: CleanOptions): Promise<void>;
3
- /**
4
- * An alias of the invoke method.
5
- * @param options
6
- * @returns
7
- */
8
- export declare function clean(options: CleanOptions): Promise<void>;
1
+ export {};
package/dist/clean.mjs CHANGED
@@ -1,15 +1,11 @@
1
1
  import { log, runCommand } from "@stacksjs/cli";
2
+ import { projectPath } from "@stacksjs/path";
2
3
  import { ExitCode, NpmScript } from "@stacksjs/types";
3
- export async function invoke(options) {
4
- log.info("Running clean command...");
5
- const result = await runCommand(NpmScript.Clean, options);
6
- if (result.isOk()) {
7
- log.success("Cleaned up");
8
- process.exit(ExitCode.Success);
9
- }
10
- log.error(result.error);
11
- process.exit(ExitCode.FatalError);
12
- }
13
- export async function clean(options) {
14
- return invoke(options);
4
+ log.info("Running clean command...");
5
+ const result = await runCommand(NpmScript.Clean, { cwd: projectPath() });
6
+ if (result.isOk()) {
7
+ log.success("Cleaned up");
8
+ process.exit(ExitCode.Success);
15
9
  }
10
+ log.error(result.error);
11
+ process.exit(ExitCode.FatalError);
@@ -0,0 +1,3 @@
1
+ import { parseOptions } from "@stacksjs/cli";
2
+ const options = parseOptions();
3
+ console.log("options", options);
@@ -0,0 +1,6 @@
1
+ import { runCommands } from "@stacksjs/cli";
2
+ import { frameworkPath } from "@stacksjs/path";
3
+ await runCommands([
4
+ "pnpm buddy clean",
5
+ "pnpm install"
6
+ ], { cwd: frameworkPath(), verbose: true });
@@ -1,4 +1,4 @@
1
1
  import { runCommand } from "@stacksjs/cli";
2
2
  import { frameworkPath } from "@stacksjs/path";
3
3
  import { NpmScript } from "@stacksjs/types";
4
- await runCommand(NpmScript.DevComponents, { cwd: frameworkPath(), debug: true });
4
+ await runCommand(NpmScript.DevComponents, { cwd: frameworkPath(), verbose: true });
@@ -1,4 +1,4 @@
1
- import { NpmScript } from "@stacksjs/types";
2
1
  import { runCommand } from "@stacksjs/cli";
3
2
  import { frameworkPath } from "@stacksjs/path";
4
- await runCommand(NpmScript.TestUi, { debug: true, cwd: frameworkPath() });
3
+ import { NpmScript } from "@stacksjs/types";
4
+ await runCommand(NpmScript.DevDocs, { cwd: frameworkPath(), verbose: true });
@@ -1,13 +1,11 @@
1
1
  import type { DevOptions } from '@stacksjs/types';
2
- export declare function invoke(options: DevOptions): Promise<void>;
3
2
  /**
4
3
  * An alias of the invoke method.
5
4
  * @param options
6
5
  * @returns
7
6
  */
8
- export declare function dev(options: DevOptions): Promise<void>;
7
+ export declare function dev(options: DevOptions): Promise<any>;
9
8
  export declare function components(options: DevOptions): Promise<void>;
10
- export declare function docs(options: DevOptions): Promise<void>;
11
9
  export declare function desktop(options: DevOptions): Promise<void>;
12
10
  export declare function pages(options: DevOptions): Promise<void>;
13
11
  export declare function functions(options: DevOptions): Promise<void>;
@@ -1,19 +1,6 @@
1
1
  import { log } from "@stacksjs/logging";
2
2
  import { runNpmScript } from "@stacksjs/utils";
3
3
  import { NpmScript } from "@stacksjs/types";
4
- export async function invoke(options) {
5
- console.log("options are: ", options);
6
- if (options.components || options.all)
7
- await components(options);
8
- else if (options.docs || options.all)
9
- await docs(options);
10
- else if (options.pages || options.all)
11
- await pages(options);
12
- else if (options.functions || options.all)
13
- await functions(options);
14
- else if (options.desktop || options.all)
15
- await desktop(options);
16
- }
17
4
  export async function dev(options) {
18
5
  return invoke(options);
19
6
  }
@@ -21,10 +8,6 @@ export async function components(options) {
21
8
  log.info("Starting your components dev server...");
22
9
  await runNpmScript(NpmScript.DevComponents, options);
23
10
  }
24
- export async function docs(options) {
25
- log.info("Starting your docs dev server...");
26
- await runNpmScript(NpmScript.DevDocs, options);
27
- }
28
11
  export async function desktop(options) {
29
12
  log.info("Starting your Desktop engine...");
30
13
  await runNpmScript(NpmScript.DevDesktop, options);
package/dist/fresh.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { runCommands } from "@stacksjs/cli";
2
2
  import { frameworkPath } from "@stacksjs/path";
3
3
  await runCommands([
4
- "pnpm run clean",
4
+ "buddy clean",
5
5
  "pnpm install"
6
- ], { cwd: frameworkPath(), debug: true });
6
+ ], { cwd: frameworkPath(), verbose: true });
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { log } from "@stacksjs/logging";
3
3
  import { hasComponents } from "@stacksjs/storage";
4
- import { generateComponentMeta } from "./helpers/component-meta.mjs";
4
+ import { generateComponentMeta } from "../helpers/component-meta.mjs";
5
5
  if (hasComponents())
6
6
  await generateComponentMeta();
7
7
  else
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { log } from "@stacksjs/logging";
3
3
  import { hasComponents } from "@stacksjs/storage";
4
- import { generateVsCodeCustomData } from "./helpers/vscode-custom-data.mjs";
4
+ import { generateVsCodeCustomData } from "../helpers/vscode-custom-data.mjs";
5
5
  if (hasComponents()) {
6
6
  await generateVsCodeCustomData();
7
7
  } else {
@@ -13,3 +13,5 @@ export declare function vsCodeCustomData(options?: GeneratorOptions): Promise<vo
13
13
  export declare function ideHelpers(options?: GeneratorOptions): Promise<void>;
14
14
  export declare function componentMeta(options?: GeneratorOptions): Promise<void>;
15
15
  export declare function types(options?: GeneratorOptions): Promise<void>;
16
+ export declare function migrations(): Promise<void>;
17
+ export declare function seeder(): Promise<void>;
@@ -1,9 +1,10 @@
1
1
  import { log } from "@stacksjs/logging";
2
+ import { seed } from "@stacksjs/database";
2
3
  import { Action, NpmScript } from "@stacksjs/types";
3
4
  import { runNpmScript } from "@stacksjs/utils";
4
- import { projectPath } from "@stacksjs/path";
5
5
  import { runCommand } from "@stacksjs/cli";
6
- import { runAction } from "./helpers/index.mjs";
6
+ import { frameworkPath } from "@stacksjs/path";
7
+ import { runAction } from "../helpers/index.mjs";
7
8
  export async function invoke(options) {
8
9
  if (options?.types)
9
10
  await types(options);
@@ -24,7 +25,7 @@ export async function generate(options) {
24
25
  return invoke(options);
25
26
  }
26
27
  export async function libEntries(options) {
27
- const result = await runCommand("esno .stacks/core/actions/src/generate-package-json.ts", { ...options, debug: true, cwd: projectPath() });
28
+ const result = await runCommand("tsx .stacks/core/actions/src/generate-package-json.ts", { ...options, verbose: true, cwd: projectPath() });
28
29
  if (result.isErr()) {
29
30
  log.error("There was an error generating your library entry points.", result.error);
30
31
  process.exit();
@@ -53,7 +54,7 @@ export async function vsCodeCustomData(options) {
53
54
  log.error("There was an error generating the custom-elements.json file.", result.error);
54
55
  process.exit();
55
56
  }
56
- await runAction(Action.LintFix, { debug: true });
57
+ await runAction(Action.LintFix, { verbose: true });
57
58
  log.success("Successfully generated the custom-elements.json file");
58
59
  }
59
60
  export async function ideHelpers(options) {
@@ -62,7 +63,7 @@ export async function ideHelpers(options) {
62
63
  log.error("There was an error generating IDE helpers.", result.error);
63
64
  process.exit();
64
65
  }
65
- await runAction(Action.LintFix, { debug: true });
66
+ await runAction(Action.LintFix, { verbose: true });
66
67
  log.success("Successfully generated IDE helpers");
67
68
  }
68
69
  export async function componentMeta(options) {
@@ -71,7 +72,7 @@ export async function componentMeta(options) {
71
72
  log.error("There was an error generating your component meta information.", result.error);
72
73
  process.exit();
73
74
  }
74
- await runAction(Action.LintFix, { debug: true });
75
+ await runAction(Action.LintFix, { verbose: true });
75
76
  log.success("Successfully generated component meta information");
76
77
  }
77
78
  export async function types(options) {
@@ -82,3 +83,11 @@ export async function types(options) {
82
83
  }
83
84
  log.success("Types were generated successfully");
84
85
  }
86
+ export async function migrations() {
87
+ const path = frameworkPath("database/schema.prisma");
88
+ await runCommand(`npx prisma migrate dev --schema=${path}`);
89
+ log.success("Successfully updated migrations");
90
+ }
91
+ export async function seeder() {
92
+ await seed();
93
+ }
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { log } from "@stacksjs/logging";
3
3
  import { hasComponents, hasFunctions } from "@stacksjs/storage";
4
- import { generateLibEntry } from "./helpers/lib-entries.mjs";
4
+ import { generateLibEntry } from "../helpers/lib-entries.mjs";
5
5
  if (hasComponents()) {
6
6
  await generateLibEntry("vue-components");
7
7
  await generateLibEntry("web-components");
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { hasComponents, hasFunctions } from "@stacksjs/storage";
3
- import { generatePackageJson } from "./helpers/package-json.mjs";
3
+ import { generatePackageJson } from "../helpers/package-json.mjs";
4
4
  if (hasComponents()) {
5
5
  await generatePackageJson("vue-components");
6
6
  await generatePackageJson("web-components");
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { generateSettings } from "@stacksjs/pages";
3
+ await generateSettings();
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { log } from "@stacksjs/logging";
3
3
  import { hasComponents } from "@stacksjs/storage";
4
- import { generateVsCodeCustomData } from "./helpers/vscode-custom-data.mjs";
4
+ import { generateVsCodeCustomData } from "../helpers/vscode-custom-data.mjs";
5
5
  if (hasComponents())
6
6
  await generateVsCodeCustomData();
7
7
  else
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { generateVueCompat } from "../helpers/vue-compat.mjs";
3
+ await generateVueCompat(["wip"]);
@@ -43,11 +43,11 @@ export async function createFunctionLibraryEntryPoint() {
43
43
  export function generateEntryPointData(type) {
44
44
  let arr = [];
45
45
  if (type === "functions") {
46
- if (!library.functions.functions) {
46
+ if (!library.functions?.functions) {
47
47
  log.error("There are no functions defined to be built. Please check your config/library.ts file for potential adjustments.");
48
48
  process.exit();
49
49
  }
50
- for (const fx of library.functions.functions) {
50
+ for (const fx of library.functions?.functions) {
51
51
  if (Array.isArray(fx))
52
52
  arr.push(`export * as ${fx[1]} from '../../../functions/${fx[0]}'`);
53
53
  else
@@ -56,12 +56,12 @@ export function generateEntryPointData(type) {
56
56
  return arr.join("\r\n");
57
57
  }
58
58
  if (type === "vue-components") {
59
- if (!library.vueComponents.tags) {
59
+ if (!library.vueComponents?.tags) {
60
60
  log.error("There are no components defined to be built. Please check your config/library.ts file for potential adjustments.");
61
61
  process.exit();
62
62
  }
63
63
  arr = determineResetPreset();
64
- for (const component of library.vueComponents.tags.map((tag) => tag.name)) {
64
+ for (const component of library.vueComponents?.tags.map((tag) => tag.name)) {
65
65
  if (Array.isArray(component))
66
66
  arr.push(`export { default as ${component[1]} } from '../../../components/${component[0]}.vue'`);
67
67
  else
@@ -73,11 +73,11 @@ export function generateEntryPointData(type) {
73
73
  const imports = [...arr, "import { defineCustomElement } from 'vue'"];
74
74
  const declarations = [];
75
75
  const definitions = [];
76
- if (!library.webComponents.tags) {
76
+ if (!library.webComponents?.tags) {
77
77
  log.error("There are no components defined to be built. Please check your config/library.ts file for potential adjustments.");
78
78
  process.exit();
79
79
  }
80
- for (const component of library.webComponents.tags.map((tag) => tag.name)) {
80
+ for (const component of library.webComponents?.tags.map((tag) => tag.name)) {
81
81
  if (Array.isArray(component)) {
82
82
  imports.push(`import ${component[1]} from '../../../components/${component[0]}.vue'`);
83
83
  declarations.push(`const ${component[1]}CustomElement = defineCustomElement(${component[1]})`);
@@ -6,22 +6,22 @@ import { packageManager } from "../../package.json" assert { type: "json" };
6
6
  export async function generatePackageJson(type) {
7
7
  let name, description, directory, keywords, config, prettyName;
8
8
  if (type === "vue-components") {
9
- name = library.vueComponents.name;
10
- description = library.vueComponents.description;
9
+ name = library.vueComponents?.name;
10
+ description = library.vueComponents?.description;
11
11
  directory = "components";
12
- keywords = library.vueComponents.keywords;
12
+ keywords = library.vueComponents?.keywords;
13
13
  config = "vue-components";
14
14
  } else if (type === "web-components") {
15
- name = library.webComponents.name;
16
- description = library.webComponents.description;
15
+ name = library.webComponents?.name;
16
+ description = library.webComponents?.description;
17
17
  directory = "components";
18
- keywords = library.webComponents.keywords;
18
+ keywords = library.webComponents?.keywords;
19
19
  config = "web-components";
20
20
  } else if (type === "functions") {
21
- name = library.functions.name;
22
- description = library.functions.description;
21
+ name = library.functions?.name;
22
+ description = library.functions?.description;
23
23
  directory = "functions";
24
- keywords = library.functions.keywords;
24
+ keywords = library.functions?.keywords;
25
25
  config = "functions";
26
26
  }
27
27
  try {
@@ -1,6 +1,5 @@
1
- import type { CliOptions, CommandResult } from '@stacksjs/types';
2
- import type { Err, Result } from '@stacksjs/error-handling';
3
- export type ActionResult = Promise<Result<CommandResult<string>, Error> | Result<CommandResult<string>, Error>[] | Err<CommandResult<string>, string>>;
1
+ import type { ActionOptions, CommandResult } from '@stacksjs/types';
2
+ export type ActionResult = CommandResult;
4
3
  /**
5
4
  * Run an Action the Stacks way.
6
5
  *
@@ -8,7 +7,7 @@ export type ActionResult = Promise<Result<CommandResult<string>, Error> | Result
8
7
  * @param options The options to pass to the command.
9
8
  * @returns The result of the command.
10
9
  */
11
- export declare function runAction(action: string, options?: CliOptions): Promise<Result<CommandResult<string>, Error> | Result<CommandResult<string>, Error>[] | Err<CommandResult<string>, string>>;
10
+ export declare function runAction(action: string, options?: ActionOptions): Promise<CommandResult>;
12
11
  /**
13
12
  * Run Actions the Stacks way.
14
13
  *
@@ -16,5 +15,5 @@ export declare function runAction(action: string, options?: CliOptions): Promise
16
15
  * @param options The options to pass to the command.
17
16
  * @returns The result of the command.
18
17
  */
19
- export declare function runActions(actions: string[], options?: CliOptions): Promise<Result<CommandResult<string>, Error>[] | Result<CommandResult<string>, Error> | Err<CommandResult<string>, string>>;
18
+ export declare function runActions(actions: string[], options?: ActionOptions): Promise<CommandResult | CommandResult[]>;
20
19
  export declare function hasAction(action: string): boolean;
@@ -1,25 +1,28 @@
1
1
  import storage from "@stacksjs/storage";
2
- import { log, runCommand, runCommands } from "@stacksjs/cli";
2
+ import { italic, log, runCommand, runCommands } from "@stacksjs/cli";
3
3
  import { actionsPath, functionsPath } from "@stacksjs/path";
4
4
  import { err } from "@stacksjs/error-handling";
5
- const parseOptions = (options) => {
5
+ function parseOptions(options) {
6
6
  if (!options)
7
7
  return "";
8
8
  const parsedOptions = Object.entries(options).map(([key, value]) => {
9
- if (typeof value === "boolean")
9
+ if (key.length === 1)
10
+ return;
11
+ if (typeof value === "boolean" && value)
10
12
  return `--${key}`;
11
13
  else
12
14
  return `--${key}=${value}`;
13
15
  });
14
- return parsedOptions.join(" ").replace("----=", "");
15
- };
16
+ return parsedOptions.filter(Boolean).join(" ").replace("----=", "");
17
+ }
16
18
  export async function runAction(action, options) {
17
19
  if (!hasAction(action))
18
- return err(`The specified action "${action}" does not exist.`);
20
+ return err(`The specified action "${action}" does not exist`);
19
21
  const opts = parseOptions(options);
20
- const cmd = `npx esno ${actionsPath(`${action}.ts ${opts}`)}`;
21
- if (options?.debug)
22
- log.info("Running command:", cmd, options);
22
+ const cmd = `npx tsx ${actionsPath(`${action}.ts ${opts}`)}`;
23
+ console.log("cmd", cmd);
24
+ if (options?.verbose)
25
+ log.debug("running command:", italic(cmd));
23
26
  return options?.showSpinner ? await runCommands([cmd], options) : await runCommand(cmd, options);
24
27
  }
25
28
  export async function runActions(actions, options) {
@@ -29,7 +32,7 @@ export async function runActions(actions, options) {
29
32
  if (!hasAction(action))
30
33
  return err(`The specified action "${action}" does not exist`);
31
34
  }
32
- const commands = actions.map((action) => `npx esno ${actionsPath(`${action}.ts`)}`);
35
+ const commands = actions.map((action) => `npx tsx ${actionsPath(`${action}.ts`)}`);
33
36
  return await runCommands(commands, options);
34
37
  }
35
38
  export function hasAction(action) {
@@ -13,7 +13,7 @@ export async function generateVsCodeCustomData() {
13
13
  }
14
14
  }
15
15
  function generateComponentInfoData() {
16
- const componentsData = JSON.stringify(library.vueComponents.tags);
16
+ const componentsData = JSON.stringify(library.vueComponents?.tags);
17
17
  return `{
18
18
  "version": 1.1,
19
19
  "tags": ${componentsData}
@@ -1,8 +1,8 @@
1
1
  import { runCommand } from "@stacksjs/cli";
2
2
  import { isFile } from "@stacksjs/storage";
3
3
  import { setEnvValue } from "@stacksjs/utils";
4
- import { options } from "kolorist";
4
+ import { projectPath } from "@stacksjs/path";
5
5
  import { generateAppKey } from "@stacksjs/security";
6
6
  if (!isFile(".env"))
7
- await runCommand("cp .env.example .env", { ...options, cwd: projectPath() });
7
+ await runCommand("cp .env.example .env", { cwd: projectPath() });
8
8
  await setEnvValue("APP_KEY", await generateAppKey());
@@ -1,4 +1,4 @@
1
1
  import { runCommand } from "@stacksjs/cli";
2
2
  import { projectPath } from "@stacksjs/path";
3
3
  import { NpmScript } from "@stacksjs/types";
4
- await runCommand(NpmScript.Lint, { cwd: projectPath(), debug: true });
4
+ await runCommand(NpmScript.Lint, { cwd: projectPath(), verbose: true });
package/dist/make.d.ts CHANGED
@@ -12,8 +12,6 @@ export declare function database(options: MakeOptions): Promise<void>;
12
12
  export declare function createDatabase(options: MakeOptions): Promise<void>;
13
13
  export declare function factory(options: MakeOptions): Promise<void>;
14
14
  export declare function createFactory(options: MakeOptions): Promise<void>;
15
- export declare function migration(options: MakeOptions): Promise<void>;
16
- export declare function createMigration(options: MakeOptions): Promise<void>;
17
15
  export declare function notification(options: MakeOptions): Promise<void>;
18
16
  export declare function page(options: MakeOptions): Promise<void>;
19
17
  export declare function createPage(options: MakeOptions): Promise<void>;
@@ -23,3 +21,5 @@ export declare function language(options: MakeOptions): Promise<void>;
23
21
  export declare function createLanguage(options: MakeOptions): Promise<void>;
24
22
  export declare function stack(options: MakeOptions): Promise<void>;
25
23
  export declare function createNotification(options: MakeOptions): Promise<boolean>;
24
+ export declare function createMigration(options: MakeOptions): Promise<void>;
25
+ export declare function createModel(options: MakeOptions): Promise<void>;
package/dist/make.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { italic, log, spawn } from "@stacksjs/cli";
2
2
  import { createFolder, doesFolderExist, writeTextFile } from "@stacksjs/storage";
3
- import { resolve } from "@stacksjs/path";
3
+ import { frameworkPath, projectPath, resolve } from "@stacksjs/path";
4
4
  export async function invoke(options) {
5
5
  if (options.component)
6
6
  await component(options);
@@ -80,20 +80,6 @@ export async function factory(options) {
80
80
  export async function createFactory(options) {
81
81
  console.log("options", options);
82
82
  }
83
- export async function migration(options) {
84
- try {
85
- const name = options.name;
86
- log.info(`Creating your ${italic(name)} migration...`);
87
- await createMigration(options);
88
- log.success(`Created the ${italic(name)} migration.`);
89
- } catch (error) {
90
- log.error("There was an error creating your migration.", error);
91
- process.exit();
92
- }
93
- }
94
- export async function createMigration(options) {
95
- console.log("options", options);
96
- }
97
83
  export async function notification(options) {
98
84
  try {
99
85
  const name = options.name;
@@ -225,3 +211,58 @@ function send(): ${importOption} {
225
211
  return false;
226
212
  }
227
213
  }
214
+ export async function createMigration(options) {
215
+ const optionName = options.name;
216
+ const table = options.tableName;
217
+ const name = optionName[0].toUpperCase() + optionName.slice(1);
218
+ const path = frameworkPath(`database/migrations/${name}.ts`);
219
+ try {
220
+ await writeTextFile({
221
+ path: `${path}`,
222
+ data: `import { Kysely } from 'kysely'
223
+
224
+ export async function up(db: Kysely<any>): Promise<void> {
225
+ await db.schema
226
+ .createTable('${table}')
227
+ .addColumn('id', 'integer', (col) => col.autoIncrement().primaryKey())
228
+ .execute()
229
+ }`
230
+ });
231
+ log.success(`Successfully created your migration file at .stacks/database/migrations/${name}.ts`);
232
+ } catch (error) {
233
+ log.error(error);
234
+ }
235
+ }
236
+ export async function createModel(options) {
237
+ const optionName = options.name;
238
+ const name = optionName[0].toUpperCase() + optionName.slice(1);
239
+ const path = projectPath(`app/models/${name}.ts`);
240
+ try {
241
+ await writeTextFile({
242
+ path: `${path}`,
243
+ data: `import { faker } from '../../.stacks/core/faker/src' // stacks/faker or @stacksjs/faker
244
+ import { validate } from '../../.stacks/core/validation/src' // stacks/validate or @stacksjs/validate
245
+ import type { Model } from '../../.stacks/core/types/src' // stacks/types or @stacksjs/types
246
+
247
+ export default <Model> {
248
+ name: '${name}',
249
+ searchable: true, // boolean | IndexSettings,
250
+ authenticatable: true, // boolean | AuthSettings,
251
+ seeder: {
252
+ count: 10,
253
+ },
254
+ fields: {
255
+ name: {
256
+ type: 'String',
257
+ validation: validate.string().min(3).max(255),
258
+ factory: () => faker.name,
259
+ },
260
+ // more fields here
261
+ },
262
+ }`
263
+ });
264
+ log.success(`Successfully created your model at app/models/${name}.ts`);
265
+ } catch (error) {
266
+ log.error(error);
267
+ }
268
+ }
@@ -0,0 +1,2 @@
1
+ import { migrations } from "@stacksjs/actions/generate";
2
+ await migrations();
@@ -1,9 +1,9 @@
1
1
  import { log, spawn } from "@stacksjs/cli";
2
2
  import { projectPath } from "@stacksjs/path";
3
- import { determineDebugMode } from "@stacksjs/config";
3
+ import { determineDebugLevel } from "@stacksjs/utils";
4
4
  export async function invoke(options) {
5
5
  try {
6
- const stdio = determineDebugMode(options) ? "inherit" : "ignore";
6
+ const stdio = determineDebugLevel(options) ? "inherit" : "ignore";
7
7
  log.info("Preinstall check...");
8
8
  await spawn("npx only-allow pnpm", { stdio, cwd: projectPath() });
9
9
  log.success("Environment ready");
@@ -3,7 +3,7 @@ import { runtimePath } from "@stacksjs/path";
3
3
  import { runNpmScript } from "@stacksjs/utils";
4
4
  import { NpmScript } from "@stacksjs/types";
5
5
  log.info("Running prepublish command...");
6
- const result = await runNpmScript(NpmScript.BuildStacks, { debug: true, cwd: runtimePath() });
6
+ const result = await runNpmScript(NpmScript.BuildStacks, { verbose: true, cwd: runtimePath() });
7
7
  if (result.isErr()) {
8
8
  log.error("There was an error while prepublishing your stack, during the process of building Stacks.", result.error);
9
9
  process.exit();