stonyx 0.2.3-alpha.17 → 0.2.3-alpha.19

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.
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>;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Validates and initializes stonyx modules
3
+ * TODO: Refactor into a ModuleLoader class (good coding exercise)
4
+ */
5
+ import { readFile } from '@stonyx/utils/file';
6
+ import { kebabCaseToCamelCase } from '@stonyx/utils/string';
7
+ import { mergeObject } from '@stonyx/utils/object';
8
+ const modulePromises = {};
9
+ // Configure module-specific logging
10
+ function configureLog(chronicle, module, config) {
11
+ const { logColor, logMethod, logTimestamp } = config;
12
+ if (!logColor)
13
+ return;
14
+ chronicle.defineType(logMethod || module, logColor, { logTimestamp: !!logTimestamp });
15
+ }
16
+ function initializeModule(moduleName, moduleClass, modules, initPromises) {
17
+ const moduleInstance = new moduleClass();
18
+ modules.push(moduleInstance);
19
+ if (!moduleInstance.init)
20
+ return;
21
+ initPromises.push((async () => {
22
+ await moduleInstance.init();
23
+ modulePromises[moduleName]?.resolve();
24
+ })());
25
+ }
26
+ export default async function loadModules(config, rootPath, chronicle) {
27
+ const modules = [];
28
+ const initPromises = [];
29
+ const rootPackage = await readFile(`${rootPath}/package.json`, { json: true });
30
+ const dependencies = rootPackage.devDependencies;
31
+ const projectName = rootPackage.name;
32
+ // Expose rootPath to public configuration
33
+ config.rootPath = rootPath;
34
+ const moduleDependencies = Object.keys(dependencies).filter((moduleName) => moduleName.startsWith('@stonyx/'));
35
+ // Setup module promises prior to initialization
36
+ for (const moduleName of moduleDependencies) {
37
+ const promise = {};
38
+ modulePromises[moduleName] = promise;
39
+ promise.ready = new Promise(resolve => promise.resolve = resolve);
40
+ }
41
+ // Standalone module configuration
42
+ if (rootPackage.keywords?.includes('stonyx-module')) {
43
+ configureLog(chronicle, projectName, config);
44
+ const entryPoint = rootPackage.main;
45
+ const { default: moduleClass } = await import(`${rootPath}/${entryPoint}`);
46
+ initializeModule(rootPackage.name, moduleClass, modules, initPromises);
47
+ }
48
+ for (const moduleName of moduleDependencies) {
49
+ const modulePackage = await readFile(`${rootPath}/node_modules/${moduleName}/package.json`, { json: true, missingFileCallback: (_filePath) => {
50
+ console.warn(`Warning: Could not locate stonyx module: "${moduleName}". Module was not loaded`);
51
+ return '';
52
+ } });
53
+ if (!modulePackage)
54
+ continue;
55
+ const keywords = modulePackage.keywords;
56
+ if (!keywords.includes('stonyx-module')) {
57
+ console.warn(`Warning: Stonyx modules must contain the "stonyx-module" keyword. Module was not loaded`);
58
+ continue;
59
+ }
60
+ if (!keywords.includes('stonyx-async')) {
61
+ modulePromises[moduleName].resolve();
62
+ continue;
63
+ }
64
+ try {
65
+ // Load & Configure Async Modules
66
+ const { default: moduleConfig } = await import(`${rootPath}/node_modules/${moduleName}/config/environment.js`);
67
+ const module = kebabCaseToCamelCase(moduleName.split('/').pop());
68
+ const userConfig = config[module] || {};
69
+ const finalConfig = mergeObject(moduleConfig, userConfig);
70
+ config[module] = finalConfig;
71
+ // Configure module-specific logging
72
+ configureLog(chronicle, module, finalConfig);
73
+ const entryPoint = modulePackage.main;
74
+ const { default: moduleClass } = await import(`${rootPath}/node_modules/${moduleName}/${entryPoint}`);
75
+ initializeModule(moduleName, moduleClass, modules, initPromises);
76
+ }
77
+ catch (error) {
78
+ console.error(error);
79
+ throw new Error(`Stonyx modules with async loading must have a config/environment.js file with default configurations. Module "${moduleName}" failed to load.`);
80
+ }
81
+ }
82
+ // Wait until all modules are initialized
83
+ await Promise.all(initPromises);
84
+ return modules;
85
+ }
86
+ export async function waitForModule(moduleName) {
87
+ const fullName = `@stonyx/${moduleName}`;
88
+ const modulePromise = modulePromises[fullName];
89
+ if (!modulePromise)
90
+ throw new Error(`Could wait for module: ${fullName}. Module was not registered in project dependencies`);
91
+ await modulePromises[fullName].ready;
92
+ }
package/package.json CHANGED
@@ -1,25 +1,41 @@
1
1
  {
2
2
  "name": "stonyx",
3
- "version": "0.2.3-alpha.17",
3
+ "version": "0.2.3-alpha.19",
4
4
  "description": "Base stonyx framework module",
5
- "main": "main.js",
5
+ "main": "dist/main.js",
6
+ "types": "dist/main.d.ts",
6
7
  "type": "module",
7
8
  "bin": {
8
- "stonyx": "./src/cli.js"
9
+ "stonyx": "./dist/cli.js"
9
10
  },
10
11
  "exports": {
11
- ".": "./src/main.js",
12
- "./config": "./src/exports/config.js",
13
- "./log": "./src/exports/log.js",
14
- "./test-helpers": "./src/exports/test-helpers.js",
15
- "./lifecycle": "./src/lifecycle.js"
12
+ ".": {
13
+ "types": "./dist/main.d.ts",
14
+ "default": "./dist/main.js"
15
+ },
16
+ "./config": {
17
+ "types": "./dist/exports/config.d.ts",
18
+ "default": "./dist/exports/config.js"
19
+ },
20
+ "./log": {
21
+ "types": "./dist/exports/log.d.ts",
22
+ "default": "./dist/exports/log.js"
23
+ },
24
+ "./test-helpers": {
25
+ "types": "./dist/exports/test-helpers.d.ts",
26
+ "default": "./dist/exports/test-helpers.js"
27
+ },
28
+ "./lifecycle": {
29
+ "types": "./dist/lifecycle.d.ts",
30
+ "default": "./dist/lifecycle.js"
31
+ }
16
32
  },
17
33
  "repository": {
18
34
  "type": "git",
19
35
  "url": "git+https://github.com/abofs/stonyx.git"
20
36
  },
21
37
  "files": [
22
- "src",
38
+ "dist",
23
39
  "config",
24
40
  "README.md"
25
41
  ],
@@ -35,16 +51,22 @@
35
51
  "url": "https://github.com/abofs/stonyx/issues"
36
52
  },
37
53
  "dependencies": {
38
- "@stonyx/utils": "0.2.3-beta.11",
39
- "@stonyx/logs": "1.0.1-beta.6"
54
+ "@stonyx/utils": "0.2.3-beta.18",
55
+ "@stonyx/logs": "1.0.1-beta.11"
40
56
  },
41
57
  "devDependencies": {
58
+ "@types/node": "^25.5.2",
59
+ "@types/qunit": "^2.19.13",
60
+ "@types/sinon": "^21.0.1",
42
61
  "qunit": "^2.24.1",
43
- "sinon": "^21.0.0"
62
+ "sinon": "^21.0.0",
63
+ "typescript": "^5.8.3"
44
64
  },
45
65
  "scripts": {
66
+ "build": "tsc",
67
+ "build:test": "tsc -p tsconfig.test.json",
46
68
  "start": "node .",
47
- "test": "qunit",
69
+ "test": "pnpm build && pnpm build:test && qunit 'dist-test/test/**/*-test.js'",
48
70
  "error": "echo \"Error: no error handling\" && exit 1",
49
71
  "postinstall": "node scripts/postinstall.js"
50
72
  }
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
- }
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
- }