stonyx 0.2.3-alpha.8 → 0.2.3-alpha.80

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 (71) hide show
  1. package/README.md +32 -7
  2. package/config/{environment.js → environment copy.ts } +16 -12
  3. package/dist/cli/help.d.ts +8 -0
  4. package/dist/cli/help.js +43 -0
  5. package/dist/cli/load-commands.d.ts +10 -0
  6. package/dist/cli/load-commands.js +49 -0
  7. package/dist/cli/new.d.ts +72 -0
  8. package/dist/cli/new.js +422 -0
  9. package/dist/cli/serve.d.ts +6 -0
  10. package/dist/cli/serve.js +49 -0
  11. package/dist/cli/test-setup.d.ts +1 -0
  12. package/dist/cli/test-setup.js +30 -0
  13. package/dist/cli/test.d.ts +4 -0
  14. package/dist/cli/test.js +23 -0
  15. package/dist/cli.d.ts +2 -0
  16. package/dist/cli.js +53 -0
  17. package/dist/exports/config.d.ts +2 -0
  18. package/dist/exports/config.js +2 -0
  19. package/dist/exports/log.d.ts +2 -0
  20. package/{src → dist}/exports/log.js +1 -2
  21. package/dist/exports/test-helpers.d.ts +5 -0
  22. package/dist/exports/test-helpers.js +7 -0
  23. package/dist/lifecycle.d.ts +7 -0
  24. package/dist/lifecycle.js +18 -0
  25. package/dist/main.d.ts +22 -0
  26. package/dist/main.js +102 -0
  27. package/dist/modules.d.ts +5 -0
  28. package/dist/modules.js +186 -0
  29. package/dist/util/duplicate-core.d.ts +186 -0
  30. package/dist/util/duplicate-core.js +377 -0
  31. package/dist/util/import-config.d.ts +52 -0
  32. package/dist/util/import-config.js +256 -0
  33. package/dist/util/resolve-entry-point.d.ts +1 -0
  34. package/dist/util/resolve-entry-point.js +14 -0
  35. package/dist/util/resolve-module-name.d.ts +14 -0
  36. package/dist/util/resolve-module-name.js +33 -0
  37. package/package.json +41 -12
  38. package/scripts/postinstall-manifest.js +16 -0
  39. package/scripts/postinstall.js +17 -2
  40. package/.claude/index.md +0 -96
  41. package/.github/workflows/ci.yml +0 -16
  42. package/.github/workflows/publish.yml +0 -51
  43. package/docs/api.md +0 -89
  44. package/docs/cli.md +0 -78
  45. package/docs/configuration.md +0 -72
  46. package/docs/conventions/cron-conventions.md +0 -195
  47. package/docs/conventions/discord-conventions.md +0 -62
  48. package/docs/conventions/framework-modules.md +0 -140
  49. package/docs/conventions/index.md +0 -25
  50. package/docs/conventions/orm-conventions.md +0 -190
  51. package/docs/conventions/project-structure.md +0 -105
  52. package/docs/conventions/rest-conventions.md +0 -96
  53. package/docs/conventions/testing-conventions.md +0 -56
  54. package/docs/developing-modules.md +0 -108
  55. package/docs/index.md +0 -15
  56. package/docs/lifecycle.md +0 -47
  57. package/docs/logging.md +0 -52
  58. package/docs/modules.md +0 -78
  59. package/docs/testing.md +0 -64
  60. package/src/cli/help.js +0 -48
  61. package/src/cli/load-commands.js +0 -56
  62. package/src/cli/new.js +0 -237
  63. package/src/cli/serve.js +0 -38
  64. package/src/cli/test-setup.js +0 -8
  65. package/src/cli/test.js +0 -27
  66. package/src/cli.js +0 -63
  67. package/src/exports/config.js +0 -3
  68. package/src/exports/test-helpers.js +0 -8
  69. package/src/lifecycle.js +0 -17
  70. package/src/main.js +0 -101
  71. package/src/modules.js +0 -112
package/docs/modules.md DELETED
@@ -1,78 +0,0 @@
1
- # Module System
2
-
3
- Stonyx uses a plug-and-play module architecture. Modules are automatically detected, loaded, and initialized at startup.
4
-
5
- ## How Modules Are Discovered
6
-
7
- Stonyx scans your project's `devDependencies` for packages prefixed with `@stonyx/`. Each matching package must include the `stonyx-module` keyword in its `package.json` to be loaded.
8
-
9
- ```json
10
- {
11
- "name": "@stonyx/my-module",
12
- "keywords": ["stonyx-module"],
13
- "main": "src/index.js"
14
- }
15
- ```
16
-
17
- ## Sync vs Async Modules
18
-
19
- ### Sync Modules
20
-
21
- Modules with only the `stonyx-module` keyword are treated as synchronous. They are instantiated but their promise resolves immediately — no init phase is awaited.
22
-
23
- ### Async Modules
24
-
25
- Modules that also include the `stonyx-async` keyword require initialization before they're ready:
26
-
27
- ```json
28
- {
29
- "keywords": ["stonyx-module", "stonyx-async"]
30
- }
31
- ```
32
-
33
- Async modules **must** include a `config/environment.js` with default configuration. This is merged with the user's project config before initialization.
34
-
35
- Async modules can define an `init()` method that Stonyx awaits:
36
-
37
- ```js
38
- export default class MyModule {
39
- async init() {
40
- // Connect to database, start server, etc.
41
- }
42
- }
43
- ```
44
-
45
- All module `init()` calls run concurrently via `Promise.all`.
46
-
47
- ## Module Lifecycle
48
-
49
- 1. **Discovery** — scan `devDependencies` for `@stonyx/*` packages
50
- 2. **Validation** — verify `stonyx-module` keyword exists
51
- 3. **Config merge** — async module defaults merged with user config
52
- 4. **Log setup** — module-specific Chronicle log created if `logColor` is set
53
- 5. **Instantiation** — module class is `new`'d
54
- 6. **Initialization** — `init()` called (async modules only)
55
- 7. **Startup hooks** — `startup()` called after all modules init (see [Lifecycle](lifecycle.md))
56
- 8. **Shutdown hooks** — `shutdown()` called on process exit (see [Lifecycle](lifecycle.md))
57
-
58
- ## waitForModule
59
-
60
- For submodule developers who need to ensure another async module is ready:
61
-
62
- ```js
63
- import { waitForModule } from 'stonyx';
64
-
65
- await waitForModule('rest-server'); // Waits for @stonyx/rest-server
66
- ```
67
-
68
- > **Note:** `waitForModule` is only needed during submodule development or testing. End-user applications don't need it — the CLI ensures all modules are initialized before running your app.
69
-
70
- ## Official Modules
71
-
72
- | Module | Description |
73
- |--------|-------------|
74
- | [@stonyx/cron](https://github.com/abofs/stonyx-cron) | Lightweight async job scheduling with min-heap |
75
- | [@stonyx/rest-server](https://github.com/abofs/stonyx-rest-server) | Dynamic REST server with auto-route registration |
76
- | [@stonyx/orm](https://github.com/abofs/stonyx-orm) | ORM with models, relationships, serializers, and optional REST integration |
77
-
78
- See each module's repository for its specific documentation.
package/docs/testing.md DELETED
@@ -1,64 +0,0 @@
1
- # Testing
2
-
3
- Stonyx includes built-in test infrastructure using [QUnit](https://qunitjs.com/).
4
-
5
- ## Running Tests
6
-
7
- ```bash
8
- stonyx test # Runs test/**/*-test.js by default
9
- stonyx test "test/unit/**/*.js" # Custom glob pattern
10
- ```
11
-
12
- The test command:
13
- 1. Sets `NODE_ENV=test`
14
- 2. Bootstraps Stonyx via a `--require` setup file
15
- 3. Applies [test config overrides](configuration.md#test-environment-overrides)
16
- 4. Runs QUnit with the specified glob
17
-
18
- ## Test Config Overrides
19
-
20
- Create `test/config/environment.js` to override configuration during tests:
21
-
22
- ```js
23
- export default {
24
- debug: false,
25
- restServer: { port: 0 },
26
- };
27
- ```
28
-
29
- These are deep-merged into the main config. See [Configuration](configuration.md#test-environment-overrides).
30
-
31
- ## Integration Test Helper
32
-
33
- For tests that need Stonyx fully initialized (e.g., testing modules with database connections):
34
-
35
- ```js
36
- import { setupIntegrationTests } from 'stonyx/test-helpers';
37
-
38
- const { module, test } = QUnit;
39
-
40
- module('My Integration Test', function(hooks) {
41
- setupIntegrationTests(hooks);
42
-
43
- test('can access modules', function(assert) {
44
- // Stonyx is fully initialized here
45
- assert.ok(true);
46
- });
47
- });
48
- ```
49
-
50
- `setupIntegrationTests` adds a `before` hook that waits for `Stonyx.ready` to resolve.
51
-
52
- ## Test File Convention
53
-
54
- Place tests under `test/` with the `-test.js` suffix:
55
-
56
- ```
57
- test/
58
- unit/
59
- my-feature-test.js
60
- cli/
61
- serve-test.js
62
- integration/
63
- api-test.js
64
- ```
package/src/cli/help.js DELETED
@@ -1,48 +0,0 @@
1
- export default async function help({ args, builtInCommands, loadModuleCommands } = {}) {
2
- console.log('\nUsage: stonyx <command> [...args]\n');
3
- console.log('Commands:\n');
4
-
5
- if (builtInCommands) {
6
- for (const [name, { description }] of Object.entries(builtInCommands)) {
7
- console.log(` ${name.padEnd(20)} ${description}`);
8
- }
9
- }
10
-
11
- if (loadModuleCommands) {
12
- try {
13
- const moduleCommands = await loadModuleCommands();
14
- const entries = Object.entries(moduleCommands);
15
-
16
- if (entries.length) {
17
- console.log('\nModule commands:\n');
18
-
19
- for (const [name, { description }] of entries) {
20
- console.log(` ${name.padEnd(20)} ${description}`);
21
- }
22
- }
23
- } catch {
24
- // Module commands not available (e.g., no project context)
25
- }
26
- }
27
-
28
- console.log('\nAliases: s=serve, t=test, n=new, h=help\n');
29
-
30
- console.log('Project conventions:\n');
31
- console.log(' Entry point: app.js');
32
- console.log(' Config: config/environment.js');
33
- console.log(' DB schema: config/db-schema.js');
34
- console.log(' Models: models/');
35
- console.log(' Serializers: serializers/');
36
- console.log(' Access control: access/');
37
- console.log(' Transforms: transforms/');
38
- console.log(' Hooks: hooks/');
39
- console.log(' REST requests: requests/');
40
- console.log(' Cron jobs: crons/');
41
- console.log(' Tests: test/{unit,integration,acceptance}/');
42
- console.log('');
43
- console.log(' Logging: import log from \'stonyx/log\' (never console.log)');
44
- console.log(' Utilities: import from \'@stonyx/utils/*\' (never raw fs)');
45
- console.log(' Lint config: import from \'@abofs/code-conventions\'');
46
- console.log(' Package manager: pnpm');
47
- console.log('');
48
- }
@@ -1,56 +0,0 @@
1
- import { readFile } from 'fs/promises';
2
- import path from 'path';
3
-
4
- export default async function loadModuleCommands() {
5
- const cwd = process.cwd();
6
- const commands = {};
7
-
8
- let projectPackage;
9
-
10
- try {
11
- const raw = await readFile(path.join(cwd, 'package.json'), 'utf8');
12
- projectPackage = JSON.parse(raw);
13
- } catch {
14
- return commands;
15
- }
16
-
17
- const allDeps = {
18
- ...projectPackage.dependencies,
19
- ...projectPackage.devDependencies
20
- };
21
-
22
- const stonyxModules = Object.keys(allDeps).filter(name => name.startsWith('@stonyx/'));
23
-
24
- for (const moduleName of stonyxModules) {
25
- let modulePackage;
26
-
27
- try {
28
- const raw = await readFile(path.join(cwd, 'node_modules', moduleName, 'package.json'), 'utf8');
29
- modulePackage = JSON.parse(raw);
30
- } catch {
31
- continue;
32
- }
33
-
34
- const { exports: moduleExports } = modulePackage;
35
-
36
- if (!moduleExports || !moduleExports['./commands']) continue;
37
-
38
- try {
39
- const commandsModule = await import(path.join(cwd, 'node_modules', moduleName, moduleExports['./commands']));
40
- const moduleCommands = commandsModule.default;
41
-
42
- for (const [name, command] of Object.entries(moduleCommands)) {
43
- if (commands[name]) {
44
- console.warn(`Warning: Command "${name}" from ${moduleName} conflicts with existing command. Skipping.`);
45
- continue;
46
- }
47
-
48
- commands[name] = { ...command, module: moduleName };
49
- }
50
- } catch {
51
- continue;
52
- }
53
- }
54
-
55
- return commands;
56
- }
package/src/cli/new.js DELETED
@@ -1,237 +0,0 @@
1
- import { confirm, prompt } from '@stonyx/utils/prompt';
2
- import { createFile, createDirectory, copyFile, fileExists } from '@stonyx/utils/file';
3
- import { spawn } from 'child_process';
4
- import path from 'path';
5
- import { fileURLToPath } from 'url';
6
-
7
- const MODULE_OPTIONS = [
8
- {
9
- question: 'Will this project need a REST server?',
10
- package: '@stonyx/rest-server',
11
- dirs: ['requests']
12
- },
13
- {
14
- question: 'Will this project need WebSockets?',
15
- package: '@stonyx/sockets',
16
- dirs: ['socket-handlers']
17
- },
18
- {
19
- question: 'Will this project need data management?',
20
- package: '@stonyx/orm',
21
- dirs: ['models', 'serializers', 'access', 'transforms', 'hooks'],
22
- files: { 'config/db-schema.js': generateDbSchema }
23
- },
24
- {
25
- question: 'Will this project need scheduled tasks (cron)?',
26
- package: '@stonyx/cron',
27
- dirs: ['crons']
28
- },
29
- {
30
- question: 'Will this project need OAuth?',
31
- package: '@stonyx/oauth'
32
- },
33
- {
34
- question: 'Will this project need pub/sub events?',
35
- package: '@stonyx/events'
36
- },
37
- {
38
- question: 'Will this project need a Discord bot?',
39
- package: '@stonyx/discord',
40
- dirs: ['discord-commands', 'discord-events']
41
- }
42
- ];
43
-
44
- function generateDbSchema() {
45
- return `import { Model, hasMany } from '@stonyx/orm';
46
-
47
- export default class DBModel extends Model {
48
- // Define your collections here
49
- // examples = hasMany('example');
50
- }
51
- `;
52
- }
53
-
54
- function generatePackageJson(name, selectedModules) {
55
- const devDependencies = { stonyx: 'latest' };
56
-
57
- for (const mod of selectedModules) {
58
- devDependencies[mod.package] = 'latest';
59
- }
60
-
61
- // Sort dependencies alphabetically
62
- const sorted = Object.fromEntries(
63
- Object.entries(devDependencies).sort(([a], [b]) => a.localeCompare(b))
64
- );
65
-
66
- return JSON.stringify({
67
- name,
68
- version: '0.1.0',
69
- type: 'module',
70
- private: true,
71
- scripts: {
72
- start: 'stonyx serve',
73
- test: 'stonyx test'
74
- },
75
- devDependencies: sorted
76
- }, null, 2) + '\n';
77
- }
78
-
79
- function generateAppJs() {
80
- return `import log from 'stonyx/log';
81
-
82
- export default class App {
83
- constructor() {
84
- if (App.instance) return App.instance;
85
- App.instance = this;
86
-
87
- this.ready = this.init();
88
- }
89
-
90
- async init() {
91
- log.info('Initializing Application');
92
-
93
- // Application setup here
94
-
95
- log.info('Application has been initialized');
96
- }
97
- }
98
- `;
99
- }
100
-
101
- function generateEnvironmentJs() {
102
- return `export default {
103
- }
104
- `;
105
- }
106
-
107
- function generateEnvironmentExampleJs() {
108
- return `// Copy this file to environment.js and fill in your values
109
- // All values should use environment variables with ?? fallback defaults
110
-
111
- const {
112
- NODE_ENV,
113
- } = process.env;
114
-
115
- const environment = NODE_ENV ?? 'development';
116
-
117
- export default {
118
- }
119
- `;
120
- }
121
-
122
- function generateGitignore() {
123
- return `node_modules/
124
- .env
125
- db.json
126
- *.log
127
- `;
128
- }
129
-
130
- function runPnpmInstall(projectDir) {
131
- return new Promise((resolve, reject) => {
132
- const child = spawn('pnpm', ['install'], {
133
- cwd: projectDir,
134
- stdio: 'inherit'
135
- });
136
-
137
- child.on('close', code => {
138
- if (code === 0) resolve();
139
- else reject(new Error(`pnpm install exited with code ${code}`));
140
- });
141
-
142
- child.on('error', reject);
143
- });
144
- }
145
-
146
- export default async function newCommand({ args }) {
147
- let appName = args[0];
148
-
149
- if (!appName) {
150
- appName = await prompt('Project name:');
151
- }
152
-
153
- if (!appName) {
154
- console.error('Project name is required.');
155
- process.exit(1);
156
- }
157
-
158
- const projectDir = path.resolve(process.cwd(), appName);
159
-
160
- if (await fileExists(projectDir)) {
161
- console.error(`Directory "${appName}" already exists.`);
162
- process.exit(1);
163
- }
164
-
165
- console.log(`\nScaffolding new Stonyx project: ${appName}\n`);
166
-
167
- // Prompt for module selection
168
- const selectedModules = [];
169
-
170
- for (const mod of MODULE_OPTIONS) {
171
- if (await confirm(mod.question)) {
172
- selectedModules.push(mod);
173
- }
174
- }
175
-
176
- console.log('\nCreating project structure...\n');
177
-
178
- // Create project directory
179
- await createDirectory(projectDir);
180
-
181
- // Copy .nvmrc from monorepo root
182
- const monorepoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
183
- const nvmrcSource = path.join(monorepoRoot, '.nvmrc');
184
-
185
- if (await fileExists(nvmrcSource)) {
186
- await copyFile(nvmrcSource, path.join(projectDir, '.nvmrc'));
187
- }
188
-
189
- // Generate core files
190
- await createFile(path.join(projectDir, 'package.json'), generatePackageJson(appName, selectedModules));
191
- await createFile(path.join(projectDir, 'app.js'), generateAppJs());
192
- await createFile(path.join(projectDir, '.gitignore'), generateGitignore());
193
-
194
- // Create config directory and files
195
- await createFile(path.join(projectDir, 'config', 'environment.js'), generateEnvironmentJs());
196
- await createFile(path.join(projectDir, 'config', 'environment.example.js'), generateEnvironmentExampleJs());
197
-
198
- // Create module-specific directories and files
199
- for (const mod of selectedModules) {
200
- if (mod.dirs) {
201
- for (const dir of mod.dirs) {
202
- await createDirectory(path.join(projectDir, dir));
203
- // Create .gitkeep so empty dirs are tracked
204
- await createFile(path.join(projectDir, dir, '.gitkeep'), '');
205
- }
206
- }
207
-
208
- if (mod.files) {
209
- for (const [filePath, generator] of Object.entries(mod.files)) {
210
- await createFile(path.join(projectDir, filePath), generator());
211
- }
212
- }
213
- }
214
-
215
- // Create test structure
216
- await createDirectory(path.join(projectDir, 'test', 'unit'));
217
- await createFile(path.join(projectDir, 'test', 'unit', '.gitkeep'), '');
218
- await createDirectory(path.join(projectDir, 'test', 'integration'));
219
- await createFile(path.join(projectDir, 'test', 'integration', '.gitkeep'), '');
220
- await createDirectory(path.join(projectDir, 'test', 'acceptance'));
221
- await createFile(path.join(projectDir, 'test', 'acceptance', '.gitkeep'), '');
222
-
223
- // Create test config
224
- await createFile(path.join(projectDir, 'test', 'config', 'environment.js'), `export default {\n // Test-specific config overrides\n}\n`);
225
-
226
- console.log('Installing dependencies...\n');
227
-
228
- try {
229
- await runPnpmInstall(projectDir);
230
- } catch (error) {
231
- console.error('Failed to install dependencies. Run `pnpm install` manually in the project directory.');
232
- }
233
-
234
- console.log(`\n✓ Project "${appName}" created successfully!`);
235
- console.log(`\n cd ${appName}`);
236
- console.log(` stonyx serve\n`);
237
- }
package/src/cli/serve.js DELETED
@@ -1,38 +0,0 @@
1
- import { runStartupHooks, runShutdownHooks } from '../lifecycle.js';
2
-
3
- export function createShutdownHandler(modules) {
4
- let shuttingDown = false;
5
- return async () => {
6
- if (shuttingDown) return;
7
- shuttingDown = true;
8
-
9
- await runShutdownHooks(modules);
10
- process.exit(0);
11
- };
12
- }
13
-
14
- export default async function serve({ args }) {
15
- const cwd = process.cwd();
16
- const entryFlag = args.indexOf('--entry');
17
- const entryPoint = entryFlag !== -1 ? args[entryFlag + 1] : 'app.js';
18
-
19
- const { default: config } = await import(`${cwd}/config/environment.js`);
20
- const { default: Stonyx } = await import('../main.js');
21
-
22
- new Stonyx(config, cwd);
23
- await Stonyx.ready;
24
-
25
- const { modules } = Stonyx.instance;
26
- await runStartupHooks(modules);
27
-
28
- const shutdown = createShutdownHandler(modules);
29
-
30
- process.on('SIGTERM', shutdown);
31
- process.on('SIGINT', shutdown);
32
-
33
- const entryModule = await import(`${cwd}/${entryPoint}`);
34
-
35
- if (entryModule.default) {
36
- new entryModule.default();
37
- }
38
- }
@@ -1,8 +0,0 @@
1
- import { pathToFileURL } from 'url';
2
-
3
- const cwd = process.cwd();
4
-
5
- const { default: Stonyx } = await import('stonyx');
6
- const { default: config } = await import(pathToFileURL(`${cwd}/config/environment.js`));
7
-
8
- new Stonyx(config, cwd);
package/src/cli/test.js DELETED
@@ -1,27 +0,0 @@
1
- import { spawn } from 'child_process';
2
- import { fileURLToPath, pathToFileURL } from 'url';
3
- import path from 'path';
4
-
5
- export default async function test({ args }) {
6
- const cwd = process.cwd();
7
- const setupFile = path.resolve(path.dirname(fileURLToPath(import.meta.url)), 'test-setup.js');
8
- const setupFileUrl = pathToFileURL(setupFile).href;
9
- const qunitBin = path.resolve(cwd, 'node_modules/qunit/bin/qunit.js');
10
-
11
- // Default to conventional test glob if no args provided
12
- const testArgs = args.length > 0 ? args : ['test/**/*-test.js'];
13
-
14
- const child = spawn(process.execPath, [
15
- '--import', setupFileUrl,
16
- qunitBin,
17
- ...testArgs
18
- ], {
19
- cwd,
20
- stdio: 'inherit',
21
- env: { ...process.env, NODE_ENV: 'test' }
22
- });
23
-
24
- child.on('close', (code) => {
25
- process.exit(code);
26
- });
27
- }
package/src/cli.js DELETED
@@ -1,63 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import serve from './cli/serve.js';
4
- import test from './cli/test.js';
5
- import help from './cli/help.js';
6
- import newCommand from './cli/new.js';
7
- import loadModuleCommands from './cli/load-commands.js';
8
-
9
- try { process.loadEnvFile(); } catch { /* no .env file */ }
10
-
11
- const aliases = { s: 'serve', t: 'test', h: 'help', n: 'new' };
12
-
13
- const builtInCommands = {
14
- serve: { description: 'Bootstrap Stonyx and run the app', run: serve },
15
- test: { description: 'Bootstrap Stonyx in test mode and run tests', run: test },
16
- new: { description: 'Scaffold a new Stonyx project', run: newCommand },
17
- help: { description: 'Show available commands', run: help }
18
- };
19
-
20
- const args = process.argv.slice(2);
21
- const commandName = aliases[args[0]] || args[0];
22
- const commandArgs = args.slice(1);
23
-
24
- async function main() {
25
- if (!commandName || commandName === 'help') {
26
- await help({ args: commandArgs, builtInCommands, loadModuleCommands });
27
- return;
28
- }
29
-
30
- const builtIn = builtInCommands[commandName];
31
-
32
- if (builtIn) {
33
- await builtIn.run({ args: commandArgs });
34
- return;
35
- }
36
-
37
- // Search module commands
38
- const moduleCommands = await loadModuleCommands();
39
- const moduleCommand = moduleCommands[commandName];
40
-
41
- if (moduleCommand) {
42
- const cwd = process.cwd();
43
-
44
- if (moduleCommand.bootstrap) {
45
- const { default: config } = await import(`${cwd}/config/environment.js`);
46
- const { default: Stonyx } = await import('./main.js');
47
- new Stonyx(config, cwd);
48
- await Stonyx.ready;
49
- }
50
-
51
- await moduleCommand.run({ args: commandArgs, cwd });
52
- return;
53
- }
54
-
55
- console.error(`Unknown command: ${args[0]}\n`);
56
- await help({ args: [], builtInCommands, loadModuleCommands });
57
- process.exit(1);
58
- }
59
-
60
- main().catch(error => {
61
- console.error(error);
62
- process.exit(1);
63
- });
@@ -1,3 +0,0 @@
1
- import Stonyx from 'stonyx';
2
-
3
- export default Stonyx.config;
@@ -1,8 +0,0 @@
1
- import Stonyx from 'stonyx';
2
-
3
- export function setupIntegrationTests(hooks) {
4
- hooks.before(async function() {
5
- await Stonyx.ready;
6
- console.log('Stonyx ready');
7
- });
8
- }
package/src/lifecycle.js DELETED
@@ -1,17 +0,0 @@
1
- export async function runStartupHooks(modules) {
2
- for (const module of modules) {
3
- if (typeof module.startup === 'function') await module.startup();
4
- }
5
- }
6
-
7
- export async function runShutdownHooks(modules) {
8
- for (const module of [...modules].reverse()) {
9
- if (typeof module.shutdown === 'function') {
10
- try {
11
- await module.shutdown();
12
- } catch (error) {
13
- console.error('Error during module shutdown:', error);
14
- }
15
- }
16
- }
17
- }