stonyx 0.2.3-alpha.2 → 0.2.3-alpha.21

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 (58) hide show
  1. package/README.md +16 -4
  2. package/dist/cli/help.d.ts +8 -0
  3. package/dist/cli/help.js +43 -0
  4. package/dist/cli/load-commands.d.ts +10 -0
  5. package/dist/cli/load-commands.js +49 -0
  6. package/dist/cli/new.d.ts +17 -0
  7. package/dist/cli/new.js +236 -0
  8. package/dist/cli/serve.d.ts +5 -0
  9. package/dist/cli/serve.js +29 -0
  10. package/dist/cli/test-setup.d.ts +1 -0
  11. package/{src → dist}/cli/test-setup.js +5 -8
  12. package/dist/cli/test.d.ts +3 -0
  13. package/dist/cli/test.js +23 -0
  14. package/dist/cli.d.ts +2 -0
  15. package/dist/cli.js +52 -0
  16. package/dist/exports/config.d.ts +2 -0
  17. package/dist/exports/config.js +2 -0
  18. package/dist/exports/log.d.ts +2 -0
  19. package/{src → dist}/exports/log.js +1 -2
  20. package/dist/exports/test-helpers.d.ts +5 -0
  21. package/dist/exports/test-helpers.js +7 -0
  22. package/dist/lifecycle.d.ts +7 -0
  23. package/dist/lifecycle.js +18 -0
  24. package/dist/main.d.ts +21 -0
  25. package/dist/main.js +89 -0
  26. package/dist/modules.d.ts +5 -0
  27. package/dist/modules.js +92 -0
  28. package/package.json +39 -12
  29. package/.claude/index.md +0 -94
  30. package/.github/workflows/ci.yml +0 -16
  31. package/.github/workflows/publish.yml +0 -51
  32. package/docs/api.md +0 -89
  33. package/docs/cli.md +0 -78
  34. package/docs/configuration.md +0 -72
  35. package/docs/conventions/framework-modules.md +0 -121
  36. package/docs/conventions/index.md +0 -23
  37. package/docs/conventions/orm-conventions.md +0 -158
  38. package/docs/conventions/project-structure.md +0 -106
  39. package/docs/conventions/rest-conventions.md +0 -96
  40. package/docs/conventions/testing-conventions.md +0 -56
  41. package/docs/developing-modules.md +0 -108
  42. package/docs/index.md +0 -15
  43. package/docs/lifecycle.md +0 -47
  44. package/docs/logging.md +0 -52
  45. package/docs/modules.md +0 -78
  46. package/docs/testing.md +0 -64
  47. package/scripts/postinstall.js +0 -11
  48. package/src/cli/help.js +0 -48
  49. package/src/cli/load-commands.js +0 -56
  50. package/src/cli/new.js +0 -232
  51. package/src/cli/serve.js +0 -38
  52. package/src/cli/test.js +0 -27
  53. package/src/cli.js +0 -63
  54. package/src/exports/config.js +0 -3
  55. package/src/exports/test-helpers.js +0 -8
  56. package/src/lifecycle.js +0 -17
  57. package/src/main.js +0 -101
  58. package/src/modules.js +0 -112
package/docs/lifecycle.md DELETED
@@ -1,47 +0,0 @@
1
- # Lifecycle Hooks
2
-
3
- Stonyx modules can define `startup()` and `shutdown()` methods that run at specific points in the application lifecycle.
4
-
5
- ## Startup Hooks
6
-
7
- Called sequentially (in module load order) after all modules have been initialized, right before your application entry point runs.
8
-
9
- ```js
10
- export default class MyModule {
11
- async startup() {
12
- // Called after all modules are init'd, before app.js runs
13
- }
14
- }
15
- ```
16
-
17
- ## Shutdown Hooks
18
-
19
- Called sequentially in **reverse** module load order when the process receives `SIGTERM` or `SIGINT`. Errors in one hook do not prevent other hooks from running.
20
-
21
- ```js
22
- export default class MyModule {
23
- async shutdown() {
24
- // Clean up connections, flush buffers, etc.
25
- }
26
- }
27
- ```
28
-
29
- ## Signal Handling
30
-
31
- The `stonyx serve` command registers signal handlers automatically:
32
-
33
- - **SIGTERM** — triggers shutdown hooks, then `process.exit(0)`
34
- - **SIGINT** — triggers shutdown hooks, then `process.exit(0)`
35
-
36
- Shutdown is idempotent — calling the handler multiple times only runs hooks once.
37
-
38
- ## Using Lifecycle Hooks Directly
39
-
40
- For advanced use cases, the lifecycle functions are available as a public export:
41
-
42
- ```js
43
- import { runStartupHooks, runShutdownHooks } from 'stonyx/lifecycle';
44
-
45
- await runStartupHooks(modules); // Calls startup() on each module in order
46
- await runShutdownHooks(modules); // Calls shutdown() on each module in reverse order
47
- ```
package/docs/logging.md DELETED
@@ -1,52 +0,0 @@
1
- # Logging
2
-
3
- Stonyx provides centralized, color-coded logging via [Chronicle](https://github.com/abofs/chronicle).
4
-
5
- ## Overview
6
-
7
- Every Stonyx instance creates a Chronicle logger with a default `title` log type (green). Modules and user services can register additional log types with custom colors.
8
-
9
- ## Module Logs
10
-
11
- Modules that specify `logColor` in their configuration automatically get a Chronicle log type:
12
-
13
- ```js
14
- // config/environment.js
15
- export default {
16
- restServer: {
17
- logColor: 'yellow',
18
- logMethod: 'api', // Optional — defaults to the config key name
19
- logTimestamp: true, // Optional — adds timestamps to log output
20
- },
21
- };
22
- ```
23
-
24
- This creates a `chronicle.api()` method that outputs in yellow with timestamps.
25
-
26
- ## Custom Logs
27
-
28
- You can define logs for any class or service in your project — not just Stonyx modules:
29
-
30
- ```js
31
- export default {
32
- myWorker: {
33
- logColor: 'cyan',
34
- logMethod: 'worker',
35
- logTimestamp: true,
36
- },
37
- };
38
- ```
39
-
40
- Any top-level config key with a `logColor` property will have a log type created automatically.
41
-
42
- ## Accessing the Logger
43
-
44
- ```js
45
- import log from 'stonyx/log';
46
-
47
- log.title('Application started');
48
- log.api('Request received'); // If restServer config defines logMethod: 'api'
49
- log.worker('Processing job'); // If myWorker config defines logMethod: 'worker'
50
- ```
51
-
52
- The `stonyx/log` export is a live reference to the Chronicle instance. It will throw if accessed before Stonyx is initialized.
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
- ```
@@ -1,11 +0,0 @@
1
- import { copyFile, createDirectory } from '@stonyx/utils/file';
2
-
3
- const projectDir = process.env.INIT_CWD;
4
- const configDir = `${projectDir}/config`;
5
- const envFile = 'environment.js';
6
-
7
- createDirectory(configDir);
8
-
9
- copyFile(`./config/environment copy.js`, `${configDir}/${envFile}`).then(result => {
10
- if (result) console.log(`Stonyx: ${envFile} has been successfully created. Please see README.md for more information.`);
11
- });
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,232 +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
-
39
- function generateDbSchema() {
40
- return `import { Model, hasMany } from '@stonyx/orm';
41
-
42
- export default class DBModel extends Model {
43
- // Define your collections here
44
- // examples = hasMany('example');
45
- }
46
- `;
47
- }
48
-
49
- function generatePackageJson(name, selectedModules) {
50
- const devDependencies = { stonyx: 'latest' };
51
-
52
- for (const mod of selectedModules) {
53
- devDependencies[mod.package] = 'latest';
54
- }
55
-
56
- // Sort dependencies alphabetically
57
- const sorted = Object.fromEntries(
58
- Object.entries(devDependencies).sort(([a], [b]) => a.localeCompare(b))
59
- );
60
-
61
- return JSON.stringify({
62
- name,
63
- version: '0.1.0',
64
- type: 'module',
65
- private: true,
66
- scripts: {
67
- start: 'stonyx serve',
68
- test: 'stonyx test'
69
- },
70
- devDependencies: sorted
71
- }, null, 2) + '\n';
72
- }
73
-
74
- function generateAppJs() {
75
- return `import log from 'stonyx/log';
76
-
77
- export default class App {
78
- constructor() {
79
- if (App.instance) return App.instance;
80
- App.instance = this;
81
-
82
- this.ready = this.init();
83
- }
84
-
85
- async init() {
86
- log.info('Initializing Application');
87
-
88
- // Application setup here
89
-
90
- log.info('Application has been initialized');
91
- }
92
- }
93
- `;
94
- }
95
-
96
- function generateEnvironmentJs() {
97
- return `export default {
98
- }
99
- `;
100
- }
101
-
102
- function generateEnvironmentExampleJs() {
103
- return `// Copy this file to environment.js and fill in your values
104
- // All values should use environment variables with ?? fallback defaults
105
-
106
- const {
107
- NODE_ENV,
108
- } = process.env;
109
-
110
- const environment = NODE_ENV ?? 'development';
111
-
112
- export default {
113
- }
114
- `;
115
- }
116
-
117
- function generateGitignore() {
118
- return `node_modules/
119
- .env
120
- db.json
121
- *.log
122
- `;
123
- }
124
-
125
- function runPnpmInstall(projectDir) {
126
- return new Promise((resolve, reject) => {
127
- const child = spawn('pnpm', ['install'], {
128
- cwd: projectDir,
129
- stdio: 'inherit'
130
- });
131
-
132
- child.on('close', code => {
133
- if (code === 0) resolve();
134
- else reject(new Error(`pnpm install exited with code ${code}`));
135
- });
136
-
137
- child.on('error', reject);
138
- });
139
- }
140
-
141
- export default async function newCommand({ args }) {
142
- let appName = args[0];
143
-
144
- if (!appName) {
145
- appName = await prompt('Project name:');
146
- }
147
-
148
- if (!appName) {
149
- console.error('Project name is required.');
150
- process.exit(1);
151
- }
152
-
153
- const projectDir = path.resolve(process.cwd(), appName);
154
-
155
- if (await fileExists(projectDir)) {
156
- console.error(`Directory "${appName}" already exists.`);
157
- process.exit(1);
158
- }
159
-
160
- console.log(`\nScaffolding new Stonyx project: ${appName}\n`);
161
-
162
- // Prompt for module selection
163
- const selectedModules = [];
164
-
165
- for (const mod of MODULE_OPTIONS) {
166
- if (await confirm(mod.question)) {
167
- selectedModules.push(mod);
168
- }
169
- }
170
-
171
- console.log('\nCreating project structure...\n');
172
-
173
- // Create project directory
174
- await createDirectory(projectDir);
175
-
176
- // Copy .nvmrc from monorepo root
177
- const monorepoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
178
- const nvmrcSource = path.join(monorepoRoot, '.nvmrc');
179
-
180
- if (await fileExists(nvmrcSource)) {
181
- await copyFile(nvmrcSource, path.join(projectDir, '.nvmrc'));
182
- }
183
-
184
- // Generate core files
185
- await createFile(path.join(projectDir, 'package.json'), generatePackageJson(appName, selectedModules));
186
- await createFile(path.join(projectDir, 'app.js'), generateAppJs());
187
- await createFile(path.join(projectDir, '.gitignore'), generateGitignore());
188
-
189
- // Create config directory and files
190
- await createFile(path.join(projectDir, 'config', 'environment.js'), generateEnvironmentJs());
191
- await createFile(path.join(projectDir, 'config', 'environment.example.js'), generateEnvironmentExampleJs());
192
-
193
- // Create module-specific directories and files
194
- for (const mod of selectedModules) {
195
- if (mod.dirs) {
196
- for (const dir of mod.dirs) {
197
- await createDirectory(path.join(projectDir, dir));
198
- // Create .gitkeep so empty dirs are tracked
199
- await createFile(path.join(projectDir, dir, '.gitkeep'), '');
200
- }
201
- }
202
-
203
- if (mod.files) {
204
- for (const [filePath, generator] of Object.entries(mod.files)) {
205
- await createFile(path.join(projectDir, filePath), generator());
206
- }
207
- }
208
- }
209
-
210
- // Create test structure
211
- await createDirectory(path.join(projectDir, 'test', 'unit'));
212
- await createFile(path.join(projectDir, 'test', 'unit', '.gitkeep'), '');
213
- await createDirectory(path.join(projectDir, 'test', 'integration'));
214
- await createFile(path.join(projectDir, 'test', 'integration', '.gitkeep'), '');
215
- await createDirectory(path.join(projectDir, 'test', 'acceptance'));
216
- await createFile(path.join(projectDir, 'test', 'acceptance', '.gitkeep'), '');
217
-
218
- // Create test config
219
- await createFile(path.join(projectDir, 'test', 'config', 'environment.js'), `export default {\n // Test-specific config overrides\n}\n`);
220
-
221
- console.log('Installing dependencies...\n');
222
-
223
- try {
224
- await runPnpmInstall(projectDir);
225
- } catch (error) {
226
- console.error('Failed to install dependencies. Run `pnpm install` manually in the project directory.');
227
- }
228
-
229
- console.log(`\n✓ Project "${appName}" created successfully!`);
230
- console.log(`\n cd ${appName}`);
231
- console.log(` stonyx serve\n`);
232
- }
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
- }
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
- }