stonyx 0.2.3-beta.37 → 0.2.3-beta.38

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.
@@ -0,0 +1,8 @@
1
+ import type { CommandDefinition } from './load-commands.js';
2
+ interface HelpOptions {
3
+ args?: string[];
4
+ builtInCommands?: Record<string, CommandDefinition>;
5
+ loadModuleCommands?: () => Promise<Record<string, CommandDefinition>>;
6
+ }
7
+ export default function help({ args, builtInCommands, loadModuleCommands }?: HelpOptions): Promise<void>;
8
+ export {};
@@ -0,0 +1,43 @@
1
+ export default async function help({ args, builtInCommands, loadModuleCommands } = {}) {
2
+ console.log('\nUsage: stonyx <command> [...args]\n');
3
+ console.log('Commands:\n');
4
+ if (builtInCommands) {
5
+ for (const [name, { description }] of Object.entries(builtInCommands)) {
6
+ console.log(` ${name.padEnd(20)} ${description}`);
7
+ }
8
+ }
9
+ if (loadModuleCommands) {
10
+ try {
11
+ const moduleCommands = await loadModuleCommands();
12
+ const entries = Object.entries(moduleCommands);
13
+ if (entries.length) {
14
+ console.log('\nModule commands:\n');
15
+ for (const [name, { description }] of entries) {
16
+ console.log(` ${name.padEnd(20)} ${description}`);
17
+ }
18
+ }
19
+ }
20
+ catch {
21
+ // Module commands not available (e.g., no project context)
22
+ }
23
+ }
24
+ console.log('\nAliases: s=serve, t=test, n=new, h=help\n');
25
+ console.log('Project conventions:\n');
26
+ console.log(' Entry point: app.js');
27
+ console.log(' Config: config/environment.js');
28
+ console.log(' DB schema: config/db-schema.js');
29
+ console.log(' Models: models/');
30
+ console.log(' Serializers: serializers/');
31
+ console.log(' Access control: access/');
32
+ console.log(' Transforms: transforms/');
33
+ console.log(' Hooks: hooks/');
34
+ console.log(' REST requests: requests/');
35
+ console.log(' Cron jobs: crons/');
36
+ console.log(' Tests: test/{unit,integration,acceptance}/');
37
+ console.log('');
38
+ console.log(' Logging: import log from \'stonyx/log\' (never console.log)');
39
+ console.log(' Utilities: import from \'@stonyx/utils/*\' (never raw fs)');
40
+ console.log(' Lint config: import from \'@abofs/code-conventions\'');
41
+ console.log(' Package manager: pnpm');
42
+ console.log('');
43
+ }
@@ -0,0 +1,10 @@
1
+ export interface CommandDefinition {
2
+ description: string;
3
+ run: (ctx: {
4
+ args: string[];
5
+ cwd?: string;
6
+ }) => Promise<void>;
7
+ bootstrap?: boolean;
8
+ module?: string;
9
+ }
10
+ export default function loadModuleCommands(): Promise<Record<string, CommandDefinition>>;
@@ -0,0 +1,47 @@
1
+ import { readFile } from 'fs/promises';
2
+ import path from 'path';
3
+ export default async function loadModuleCommands() {
4
+ const cwd = process.cwd();
5
+ const commands = {};
6
+ let projectPackage;
7
+ try {
8
+ const raw = await readFile(path.join(cwd, 'package.json'), 'utf8');
9
+ projectPackage = JSON.parse(raw);
10
+ }
11
+ catch {
12
+ return commands;
13
+ }
14
+ const allDeps = {
15
+ ...projectPackage.dependencies,
16
+ ...projectPackage.devDependencies
17
+ };
18
+ const stonyxModules = Object.keys(allDeps).filter(name => name.startsWith('@stonyx/'));
19
+ for (const moduleName of stonyxModules) {
20
+ let modulePackage;
21
+ try {
22
+ const raw = await readFile(path.join(cwd, 'node_modules', moduleName, 'package.json'), 'utf8');
23
+ modulePackage = JSON.parse(raw);
24
+ }
25
+ catch {
26
+ continue;
27
+ }
28
+ const moduleExports = modulePackage.exports;
29
+ if (!moduleExports || !moduleExports['./commands'])
30
+ continue;
31
+ try {
32
+ const commandsModule = await import(path.join(cwd, 'node_modules', moduleName, moduleExports['./commands']));
33
+ const moduleCommands = commandsModule.default;
34
+ for (const [name, command] of Object.entries(moduleCommands)) {
35
+ if (commands[name]) {
36
+ console.warn(`Warning: Command "${name}" from ${moduleName} conflicts with existing command. Skipping.`);
37
+ continue;
38
+ }
39
+ commands[name] = { ...command, module: moduleName };
40
+ }
41
+ }
42
+ catch {
43
+ continue;
44
+ }
45
+ }
46
+ return commands;
47
+ }
@@ -0,0 +1,3 @@
1
+ export default function newCommand({ args }: {
2
+ args: string[];
3
+ }): Promise<void>;
@@ -0,0 +1,204 @@
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
+ const MODULE_OPTIONS = [
7
+ {
8
+ question: 'Will this project need a REST server?',
9
+ package: '@stonyx/rest-server',
10
+ dirs: ['requests']
11
+ },
12
+ {
13
+ question: 'Will this project need WebSockets?',
14
+ package: '@stonyx/sockets',
15
+ dirs: ['socket-handlers']
16
+ },
17
+ {
18
+ question: 'Will this project need data management?',
19
+ package: '@stonyx/orm',
20
+ dirs: ['models', 'serializers', 'access', 'transforms', 'hooks'],
21
+ files: { 'config/db-schema.js': generateDbSchema }
22
+ },
23
+ {
24
+ question: 'Will this project need scheduled tasks (cron)?',
25
+ package: '@stonyx/cron',
26
+ dirs: ['crons']
27
+ },
28
+ {
29
+ question: 'Will this project need OAuth?',
30
+ package: '@stonyx/oauth'
31
+ },
32
+ {
33
+ question: 'Will this project need pub/sub events?',
34
+ package: '@stonyx/events'
35
+ },
36
+ {
37
+ question: 'Will this project need a Discord bot?',
38
+ package: '@stonyx/discord',
39
+ dirs: ['discord-commands', 'discord-events']
40
+ }
41
+ ];
42
+ function generateDbSchema() {
43
+ return `import { Model, hasMany } from '@stonyx/orm';
44
+
45
+ export default class DBModel extends Model {
46
+ // Define your collections here
47
+ // examples = hasMany('example');
48
+ }
49
+ `;
50
+ }
51
+ function generatePackageJson(name, selectedModules) {
52
+ const devDependencies = { stonyx: 'latest' };
53
+ for (const mod of selectedModules) {
54
+ devDependencies[mod.package] = 'latest';
55
+ }
56
+ // Sort dependencies alphabetically
57
+ const sorted = Object.fromEntries(Object.entries(devDependencies).sort(([a], [b]) => a.localeCompare(b)));
58
+ return JSON.stringify({
59
+ name,
60
+ version: '0.1.0',
61
+ type: 'module',
62
+ private: true,
63
+ scripts: {
64
+ start: 'stonyx serve',
65
+ test: 'stonyx test'
66
+ },
67
+ devDependencies: sorted
68
+ }, null, 2) + '\n';
69
+ }
70
+ function generateAppJs() {
71
+ return `import log from 'stonyx/log';
72
+
73
+ export default class App {
74
+ constructor() {
75
+ if (App.instance) return App.instance;
76
+ App.instance = this;
77
+
78
+ this.ready = this.init();
79
+ }
80
+
81
+ async init() {
82
+ log.info('Initializing Application');
83
+
84
+ // Application setup here
85
+
86
+ log.info('Application has been initialized');
87
+ }
88
+ }
89
+ `;
90
+ }
91
+ function generateEnvironmentJs() {
92
+ return `export default {
93
+ }
94
+ `;
95
+ }
96
+ function generateEnvironmentExampleJs() {
97
+ return `// Copy this file to environment.js and fill in your values
98
+ // All values should use environment variables with ?? fallback defaults
99
+
100
+ const {
101
+ NODE_ENV,
102
+ } = process.env;
103
+
104
+ const environment = NODE_ENV ?? 'development';
105
+
106
+ export default {
107
+ }
108
+ `;
109
+ }
110
+ function generateGitignore() {
111
+ return `node_modules/
112
+ .env
113
+ db.json
114
+ *.log
115
+ `;
116
+ }
117
+ function runPnpmInstall(projectDir) {
118
+ return new Promise((resolve, reject) => {
119
+ const child = spawn('pnpm', ['install'], {
120
+ cwd: projectDir,
121
+ stdio: 'inherit'
122
+ });
123
+ child.on('close', code => {
124
+ if (code === 0)
125
+ resolve();
126
+ else
127
+ reject(new Error(`pnpm install exited with code ${code}`));
128
+ });
129
+ child.on('error', reject);
130
+ });
131
+ }
132
+ export default async function newCommand({ args }) {
133
+ let appName = args[0];
134
+ if (!appName) {
135
+ appName = await prompt('Project name:');
136
+ }
137
+ if (!appName) {
138
+ console.error('Project name is required.');
139
+ process.exit(1);
140
+ }
141
+ const projectDir = path.resolve(process.cwd(), appName);
142
+ if (await fileExists(projectDir)) {
143
+ console.error(`Directory "${appName}" already exists.`);
144
+ process.exit(1);
145
+ }
146
+ console.log(`\nScaffolding new Stonyx project: ${appName}\n`);
147
+ // Prompt for module selection
148
+ const selectedModules = [];
149
+ for (const mod of MODULE_OPTIONS) {
150
+ if (await confirm(mod.question)) {
151
+ selectedModules.push(mod);
152
+ }
153
+ }
154
+ console.log('\nCreating project structure...\n');
155
+ // Create project directory
156
+ await createDirectory(projectDir);
157
+ // Copy .nvmrc from monorepo root
158
+ const monorepoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
159
+ const nvmrcSource = path.join(monorepoRoot, '.nvmrc');
160
+ if (await fileExists(nvmrcSource)) {
161
+ await copyFile(nvmrcSource, path.join(projectDir, '.nvmrc'));
162
+ }
163
+ // Generate core files
164
+ await createFile(path.join(projectDir, 'package.json'), generatePackageJson(appName, selectedModules));
165
+ await createFile(path.join(projectDir, 'app.js'), generateAppJs());
166
+ await createFile(path.join(projectDir, '.gitignore'), generateGitignore());
167
+ // Create config directory and files
168
+ await createFile(path.join(projectDir, 'config', 'environment.js'), generateEnvironmentJs());
169
+ await createFile(path.join(projectDir, 'config', 'environment.example.js'), generateEnvironmentExampleJs());
170
+ // Create module-specific directories and files
171
+ for (const mod of selectedModules) {
172
+ if (mod.dirs) {
173
+ for (const dir of mod.dirs) {
174
+ await createDirectory(path.join(projectDir, dir));
175
+ // Create .gitkeep so empty dirs are tracked
176
+ await createFile(path.join(projectDir, dir, '.gitkeep'), '');
177
+ }
178
+ }
179
+ if (mod.files) {
180
+ for (const [filePath, generator] of Object.entries(mod.files)) {
181
+ await createFile(path.join(projectDir, filePath), generator());
182
+ }
183
+ }
184
+ }
185
+ // Create test structure
186
+ await createDirectory(path.join(projectDir, 'test', 'unit'));
187
+ await createFile(path.join(projectDir, 'test', 'unit', '.gitkeep'), '');
188
+ await createDirectory(path.join(projectDir, 'test', 'integration'));
189
+ await createFile(path.join(projectDir, 'test', 'integration', '.gitkeep'), '');
190
+ await createDirectory(path.join(projectDir, 'test', 'acceptance'));
191
+ await createFile(path.join(projectDir, 'test', 'acceptance', '.gitkeep'), '');
192
+ // Create test config
193
+ await createFile(path.join(projectDir, 'test', 'config', 'environment.js'), `export default {\n // Test-specific config overrides\n}\n`);
194
+ console.log('Installing dependencies...\n');
195
+ try {
196
+ await runPnpmInstall(projectDir);
197
+ }
198
+ catch (error) {
199
+ console.error('Failed to install dependencies. Run `pnpm install` manually in the project directory.');
200
+ }
201
+ console.log(`\n✓ Project "${appName}" created successfully!`);
202
+ console.log(`\n cd ${appName}`);
203
+ console.log(` stonyx serve\n`);
204
+ }
@@ -0,0 +1,5 @@
1
+ import { type StoynxModule } from '../lifecycle.js';
2
+ export declare function createShutdownHandler(modules: StoynxModule[]): () => Promise<void>;
3
+ export default function serve({ args }: {
4
+ args: string[];
5
+ }): Promise<void>;
@@ -0,0 +1,29 @@
1
+ import { runStartupHooks, runShutdownHooks } from '../lifecycle.js';
2
+ export function createShutdownHandler(modules) {
3
+ let shuttingDown = false;
4
+ return async () => {
5
+ if (shuttingDown)
6
+ return;
7
+ shuttingDown = true;
8
+ await runShutdownHooks(modules);
9
+ process.exit(0);
10
+ };
11
+ }
12
+ export default async function serve({ args }) {
13
+ const cwd = process.cwd();
14
+ const entryFlag = args.indexOf('--entry');
15
+ const entryPoint = entryFlag !== -1 ? args[entryFlag + 1] : 'app.js';
16
+ const { default: config } = await import(`${cwd}/config/environment.js`);
17
+ const { default: Stonyx } = await import('../main.js');
18
+ new Stonyx(config, cwd);
19
+ await Stonyx.ready;
20
+ const { modules } = Stonyx.instance;
21
+ await runStartupHooks(modules);
22
+ const shutdown = createShutdownHandler(modules);
23
+ process.on('SIGTERM', shutdown);
24
+ process.on('SIGINT', shutdown);
25
+ const entryModule = await import(`${cwd}/${entryPoint}`);
26
+ if (entryModule.default) {
27
+ new entryModule.default();
28
+ }
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,5 @@
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);
1
+ import { pathToFileURL } from 'url';
2
+ const cwd = process.cwd();
3
+ const { default: Stonyx } = await import('stonyx');
4
+ const { default: config } = await import(pathToFileURL(`${cwd}/config/environment.js`).href);
5
+ new Stonyx(config, cwd);
@@ -0,0 +1,3 @@
1
+ export default function test({ args }: {
2
+ args: string[];
3
+ }): Promise<void>;
@@ -0,0 +1,23 @@
1
+ import { spawn } from 'child_process';
2
+ import { fileURLToPath, pathToFileURL } from 'url';
3
+ import path from 'path';
4
+ export default async function test({ args }) {
5
+ const cwd = process.cwd();
6
+ const setupFile = path.resolve(path.dirname(fileURLToPath(import.meta.url)), 'test-setup.js');
7
+ const setupFileUrl = pathToFileURL(setupFile).href;
8
+ const qunitBin = path.resolve(cwd, 'node_modules/qunit/bin/qunit.js');
9
+ // Default to conventional test glob if no args provided
10
+ const testArgs = args.length > 0 ? args : ['test/**/*-test.js'];
11
+ const child = spawn(process.execPath, [
12
+ '--import', setupFileUrl,
13
+ qunitBin,
14
+ ...testArgs
15
+ ], {
16
+ cwd,
17
+ stdio: 'inherit',
18
+ env: { ...process.env, NODE_ENV: 'test' }
19
+ });
20
+ child.on('close', (code) => {
21
+ process.exit(code ?? 1);
22
+ });
23
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ import serve from './cli/serve.js';
3
+ import test from './cli/test.js';
4
+ import help from './cli/help.js';
5
+ import newCommand from './cli/new.js';
6
+ import loadModuleCommands from './cli/load-commands.js';
7
+ try {
8
+ process.loadEnvFile();
9
+ }
10
+ catch { /* no .env file */ }
11
+ const aliases = { s: 'serve', t: 'test', h: 'help', n: 'new' };
12
+ const builtInCommands = {
13
+ serve: { description: 'Bootstrap Stonyx and run the app', run: serve },
14
+ test: { description: 'Bootstrap Stonyx in test mode and run tests', run: test },
15
+ new: { description: 'Scaffold a new Stonyx project', run: newCommand },
16
+ help: { description: 'Show available commands', run: help }
17
+ };
18
+ const args = process.argv.slice(2);
19
+ const commandName = aliases[args[0]] || args[0];
20
+ const commandArgs = args.slice(1);
21
+ async function main() {
22
+ if (!commandName || commandName === 'help') {
23
+ await help({ args: commandArgs, builtInCommands, loadModuleCommands });
24
+ return;
25
+ }
26
+ const builtIn = builtInCommands[commandName];
27
+ if (builtIn) {
28
+ await builtIn.run({ args: commandArgs });
29
+ return;
30
+ }
31
+ // Search module commands
32
+ const moduleCommands = await loadModuleCommands();
33
+ const moduleCommand = moduleCommands[commandName];
34
+ if (moduleCommand) {
35
+ const cwd = process.cwd();
36
+ if (moduleCommand.bootstrap) {
37
+ const { default: config } = await import(`${cwd}/config/environment.js`);
38
+ const { default: Stonyx } = await import('./main.js');
39
+ new Stonyx(config, cwd);
40
+ await Stonyx.ready;
41
+ }
42
+ await moduleCommand.run({ args: commandArgs, cwd });
43
+ return;
44
+ }
45
+ console.error(`Unknown command: ${args[0]}\n`);
46
+ await help({ args: [], builtInCommands, loadModuleCommands });
47
+ process.exit(1);
48
+ }
49
+ main().catch(error => {
50
+ console.error(error);
51
+ process.exit(1);
52
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../modules.js").StoynxConfig;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import Stonyx from 'stonyx';
2
+ export default Stonyx.config;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@stonyx/logs").default;
2
+ export default _default;
@@ -1,3 +1,2 @@
1
1
  import Stonyx from 'stonyx';
2
-
3
- export default Stonyx.log;
2
+ export default Stonyx.log;
@@ -0,0 +1,5 @@
1
+ interface TestHooks {
2
+ before(fn: () => Promise<void>): void;
3
+ }
4
+ export declare function setupIntegrationTests(hooks: TestHooks): void;
5
+ export {};
@@ -0,0 +1,7 @@
1
+ import Stonyx from 'stonyx';
2
+ export function setupIntegrationTests(hooks) {
3
+ hooks.before(async function () {
4
+ await Stonyx.ready;
5
+ console.log('Stonyx ready');
6
+ });
7
+ }
@@ -0,0 +1,7 @@
1
+ export interface StoynxModule {
2
+ init?(): Promise<void>;
3
+ startup?(): Promise<void>;
4
+ shutdown?(): Promise<void>;
5
+ }
6
+ export declare function runStartupHooks(modules: StoynxModule[]): Promise<void>;
7
+ export declare function runShutdownHooks(modules: StoynxModule[]): Promise<void>;
@@ -0,0 +1,18 @@
1
+ export async function runStartupHooks(modules) {
2
+ for (const module of modules) {
3
+ if (typeof module.startup === 'function')
4
+ await module.startup();
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
+ }
13
+ catch (error) {
14
+ console.error('Error during module shutdown:', error);
15
+ }
16
+ }
17
+ }
18
+ }
package/dist/main.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import Chronicle from '@stonyx/logs';
2
+ import type { StoynxModule } from './lifecycle.js';
3
+ import type { StoynxConfig } from './modules.js';
4
+ export default class Stonyx {
5
+ static initialized: boolean;
6
+ static modulePromises: Record<string, unknown>;
7
+ static instance: Stonyx;
8
+ static ready: Promise<void>;
9
+ config: StoynxConfig;
10
+ chronicle: Chronicle;
11
+ modules: StoynxModule[];
12
+ constructor(config: StoynxConfig, rootPath: string);
13
+ start(config: StoynxConfig, rootPath: string): Promise<void>;
14
+ /**
15
+ * Allows users to define their own log for any extra class via environment config
16
+ */
17
+ configureUserLogs(): void;
18
+ static get log(): Chronicle;
19
+ static get config(): StoynxConfig;
20
+ }
21
+ export { waitForModule } from './modules.js';
package/dist/main.js ADDED
@@ -0,0 +1,88 @@
1
+ /*
2
+ * Copyright 2025 Stone Costa
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import Chronicle from '@stonyx/logs';
17
+ import loadModules from './modules.js';
18
+ import { kebabCaseToCamelCase } from '@stonyx/utils/string';
19
+ import { mergeObject } from '@stonyx/utils/object';
20
+ export default class Stonyx {
21
+ static initialized = false;
22
+ static modulePromises = {};
23
+ static instance;
24
+ static ready;
25
+ config;
26
+ chronicle;
27
+ modules;
28
+ constructor(config, rootPath) {
29
+ if (Stonyx.instance)
30
+ return Stonyx.instance;
31
+ Stonyx.instance = this;
32
+ Stonyx.ready = this.start(config, rootPath);
33
+ }
34
+ async start(config, rootPath) {
35
+ if (!config)
36
+ throw new Error('Stonyx requires full environment configuration on startup');
37
+ if (!rootPath)
38
+ throw new Error('Stonyx requires root project\'s path on startup');
39
+ // Transform config from stonyx-modules running as a standalone
40
+ if (rootPath.includes('stonyx-')) {
41
+ const moduleName = kebabCaseToCamelCase(rootPath.split('/').pop().replace('stonyx-', ''));
42
+ config = { [moduleName]: config, ...(config.modules || {}) };
43
+ delete config.modules;
44
+ }
45
+ this.config = config;
46
+ this.chronicle = new Chronicle({ additionalLogs: { title: 'green' } });
47
+ Stonyx.initialized = true;
48
+ // Auto-merge test environment overrides (after initialized flag, before modules load)
49
+ // Uses in-place mutation to preserve existing references (e.g. stonyx/config export cache)
50
+ if (process.env.NODE_ENV === 'test') {
51
+ try {
52
+ const { default: testOverrides } = await import(`${rootPath}/test/config/environment.js`);
53
+ const merged = mergeObject(config, testOverrides);
54
+ Object.assign(config, merged);
55
+ }
56
+ catch { /* no test overrides found */ }
57
+ }
58
+ this.modules = await loadModules(config, rootPath, this.chronicle);
59
+ this.configureUserLogs();
60
+ }
61
+ /**
62
+ * Allows users to define their own log for any extra class via environment config
63
+ */
64
+ configureUserLogs() {
65
+ const { chronicle } = this;
66
+ for (const [className, config] of Object.entries(this.config)) {
67
+ if (!config || typeof config !== 'object')
68
+ continue;
69
+ if (chronicle[className])
70
+ continue;
71
+ const { logColor, logMethod, logTimestamp } = config;
72
+ if (!logColor)
73
+ continue;
74
+ chronicle.defineType(logMethod || className, logColor, { logTimestamp: !!logTimestamp });
75
+ }
76
+ }
77
+ static get log() {
78
+ if (!Stonyx.initialized)
79
+ throw new Error('Stonyx has not been initialized yet');
80
+ return Stonyx.instance.chronicle;
81
+ }
82
+ static get config() {
83
+ if (!Stonyx.initialized)
84
+ throw new Error('Stonyx has not been initialized yet');
85
+ return Stonyx.instance.config;
86
+ }
87
+ }
88
+ export { waitForModule } from './modules.js';
@@ -0,0 +1,5 @@
1
+ import type { StoynxModule } from './lifecycle.js';
2
+ import type Chronicle from '@stonyx/logs';
3
+ export type StoynxConfig = Record<string, Record<string, unknown> | unknown>;
4
+ export default function loadModules(config: StoynxConfig, rootPath: string, chronicle: Chronicle): Promise<StoynxModule[]>;
5
+ export declare function waitForModule(moduleName: string): Promise<void>;