@appweaver/cli 1.0.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 (76) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +7 -0
  3. package/build/build-command.d.ts +2 -0
  4. package/build/build-command.js +15 -0
  5. package/build/build-project.d.ts +8 -0
  6. package/build/build-project.js +19 -0
  7. package/build/index.d.ts +2 -0
  8. package/build/index.js +18 -0
  9. package/generate/generate-command.d.ts +2 -0
  10. package/generate/generate-command.js +38 -0
  11. package/generate/generate-schema.d.ts +12 -0
  12. package/generate/generate-schema.js +475 -0
  13. package/generate/generate-types.d.ts +10 -0
  14. package/generate/generate-types.js +86 -0
  15. package/generate/index.d.ts +3 -0
  16. package/generate/index.js +19 -0
  17. package/migrate/index.d.ts +1 -0
  18. package/migrate/index.js +17 -0
  19. package/migrate/migrate-command.d.ts +2 -0
  20. package/migrate/migrate-command.js +13 -0
  21. package/migration/index.d.ts +1 -0
  22. package/migration/index.js +17 -0
  23. package/migration/migration-command.d.ts +2 -0
  24. package/migration/migration-command.js +34 -0
  25. package/openapi/index.d.ts +1 -0
  26. package/openapi/index.js +17 -0
  27. package/openapi/openapi-command.d.ts +2 -0
  28. package/openapi/openapi-command.js +46 -0
  29. package/package.json +56 -0
  30. package/seed/index.d.ts +1 -0
  31. package/seed/index.js +17 -0
  32. package/seed/seed-command.d.ts +2 -0
  33. package/seed/seed-command.js +33 -0
  34. package/skill/GUIDELINES.md +298 -0
  35. package/skill/SKILL.md +593 -0
  36. package/skill/references/cache.md +207 -0
  37. package/skill/references/cli.md +213 -0
  38. package/skill/references/client.md +507 -0
  39. package/skill/references/configuration.md +402 -0
  40. package/skill/references/database.md +134 -0
  41. package/skill/references/dependency-injection.md +214 -0
  42. package/skill/references/events.md +152 -0
  43. package/skill/references/mailer.md +235 -0
  44. package/skill/references/queue.md +196 -0
  45. package/skill/references/resources.md +961 -0
  46. package/skill/references/scheduler.md +184 -0
  47. package/skill/references/security.md +694 -0
  48. package/skill/references/storage.md +251 -0
  49. package/start/index.d.ts +2 -0
  50. package/start/index.js +18 -0
  51. package/start/start-command.d.ts +2 -0
  52. package/start/start-command.js +17 -0
  53. package/start/start-project.d.ts +8 -0
  54. package/start/start-project.js +147 -0
  55. package/testing/index.d.ts +1 -0
  56. package/testing/index.js +17 -0
  57. package/testing/testing-command.d.ts +2 -0
  58. package/testing/testing-command.js +96 -0
  59. package/update/index.d.ts +2 -0
  60. package/update/index.js +18 -0
  61. package/update/update-command.d.ts +2 -0
  62. package/update/update-command.js +84 -0
  63. package/update/update-packages.d.ts +10 -0
  64. package/update/update-packages.js +45 -0
  65. package/update/update-skill.d.ts +8 -0
  66. package/update/update-skill.js +93 -0
  67. package/utils/index.d.ts +3 -0
  68. package/utils/index.js +19 -0
  69. package/utils/loader-util.d.ts +29 -0
  70. package/utils/loader-util.js +132 -0
  71. package/utils/path-util.d.ts +41 -0
  72. package/utils/path-util.js +98 -0
  73. package/utils/process-util.d.ts +39 -0
  74. package/utils/process-util.js +92 -0
  75. package/weaver.d.ts +2 -0
  76. package/weaver.js +53 -0
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runProcess = runProcess;
7
+ exports.assertEnv = assertEnv;
8
+ exports.assertEnvs = assertEnvs;
9
+ exports.isBunProcess = isBunProcess;
10
+ const node_child_process_1 = require("node:child_process");
11
+ const tree_kill_1 = __importDefault(require("tree-kill"));
12
+ const common_1 = require("@appweaver/common");
13
+ /**
14
+ * Executes a shell command with optional arguments and configuration parameters.
15
+ *
16
+ * @param {string} cmd - The command to execute.
17
+ * @param {string[]} [args=[]] - An array of arguments to pass to the command.
18
+ * @param {Object} [params={ quiet: false }] - Configurations for how the process should run.
19
+ * @param {boolean} [params.quiet=false] - If true, suppresses the process output.
20
+ * @param {AbortSignal} [params.signal] - Optional AbortSignal to terminate the running process.
21
+ * @return {Promise<number>} A promise that resolves with the exit code of the process or 1 on error.
22
+ */
23
+ function runProcess(cmd, args = [], params = {}) {
24
+ const { quiet = false, signal } = params;
25
+ return new Promise((resolve, reject) => {
26
+ if (signal?.aborted) {
27
+ return resolve(0);
28
+ }
29
+ const command = args.length > 0 ? `${cmd} ${args.join(' ')}` : cmd;
30
+ const child = (0, node_child_process_1.spawn)(command, {
31
+ stdio: quiet ? 'ignore' : 'inherit',
32
+ shell: true,
33
+ env: { ...process.env, WEAVER_CLI: undefined }
34
+ });
35
+ if (signal) {
36
+ const abortHandler = () => {
37
+ if (child.pid) {
38
+ (0, tree_kill_1.default)(child.pid, (err) => {
39
+ if (err) {
40
+ reject(err);
41
+ }
42
+ else {
43
+ resolve(0);
44
+ }
45
+ });
46
+ }
47
+ };
48
+ signal.addEventListener('abort', abortHandler, { once: true });
49
+ }
50
+ child.on('error', reject);
51
+ child.on('close', (code) => {
52
+ resolve(code ?? 99);
53
+ });
54
+ });
55
+ }
56
+ /**
57
+ * Verifies that the application's runtime environment matches the specified environment.
58
+ * Terminates the process with an error message if the environments do not match.
59
+ *
60
+ * @param {string} env - The expected environment (e.g., 'production', 'development').
61
+ * @param {string} message - The error message to display if the environment does not match.
62
+ */
63
+ function assertEnv(env, message) {
64
+ if (common_1.config.APP_ENV !== env) {
65
+ console.error(message);
66
+ process.exit(1);
67
+ }
68
+ }
69
+ /**
70
+ * Verifies that the application's runtime environment matches one of the specified environments.
71
+ * Terminates the process with an error message if the environment does not match any of the provided options.
72
+ *
73
+ * @param {string[]} envs - An array of expected environments (e.g., ['prod', 'dev', 'test']).
74
+ * @param {string} message - The error message to display if the environment does not match any of the provided options.
75
+ */
76
+ function assertEnvs(envs, message) {
77
+ if (!envs.includes(common_1.config.APP_ENV)) {
78
+ console.error(message);
79
+ process.exit(1);
80
+ }
81
+ }
82
+ /**
83
+ * Checks if the current environment is a Bun.js process.
84
+ *
85
+ * This method determines whether the global `Bun` object is defined,
86
+ * which indicates the code is running in a Bun.js runtime environment.
87
+ *
88
+ * @return {boolean} Returns `true` if the `Bun` object is defined, otherwise `false`.
89
+ */
90
+ function isBunProcess() {
91
+ return typeof Bun !== 'undefined';
92
+ }
package/weaver.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/weaver.js ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ process.env.WEAVER_CLI = 'true';
5
+ const node_child_process_1 = require("node:child_process");
6
+ const common_1 = require("@appweaver/common");
7
+ const utils_1 = require("./utils");
8
+ // Restart the same process if the Bun runtime is configured and Bun is
9
+ // available on the host machine
10
+ if (!(0, utils_1.isBunProcess)() && common_1.config.APP_RUNTIME === common_1.Runtime.Bun) {
11
+ const check = (0, node_child_process_1.spawnSync)('bun --version', {
12
+ stdio: 'ignore',
13
+ shell: true
14
+ });
15
+ if (check.status === 0) {
16
+ const result = (0, node_child_process_1.spawnSync)(`bun ${process.argv.slice(1).join(' ')}`, {
17
+ stdio: 'inherit',
18
+ shell: true
19
+ });
20
+ process.exit(result.status ?? 1);
21
+ }
22
+ // Bun isn't found — fall through to Node execution
23
+ }
24
+ // These imports should be added after resolving current runtime to avoid
25
+ // unnecessary loading of all dependencies
26
+ const commander_1 = require("commander");
27
+ const build_1 = require("./build");
28
+ const generate_1 = require("./generate");
29
+ const migrate_1 = require("./migrate");
30
+ const migration_1 = require("./migration");
31
+ const openapi_1 = require("./openapi");
32
+ const seed_1 = require("./seed");
33
+ const start_1 = require("./start");
34
+ const testing_1 = require("./testing");
35
+ const update_1 = require("./update");
36
+ const pkg = (0, utils_1.loadCliPackageJson)();
37
+ const program = new commander_1.Command();
38
+ program
39
+ .name('weaver')
40
+ .description('Appweaver CLI - Build and manage your application')
41
+ .version(pkg.version, '-v, --version', 'Output the current version.')
42
+ .helpOption('-h, --help', 'Output usage information.')
43
+ .usage('<command> [options]');
44
+ (0, build_1.buildCommand)(program);
45
+ (0, generate_1.generateCommand)(program);
46
+ (0, migrate_1.migrateCommand)(program);
47
+ (0, migration_1.migrationCommand)(program);
48
+ (0, openapi_1.openapiCommand)(program);
49
+ (0, seed_1.seedCommand)(program);
50
+ (0, start_1.startCommand)(program);
51
+ (0, testing_1.testingCommand)(program);
52
+ (0, update_1.updateCommand)(program);
53
+ program.parse();