gritty 9.0.4 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ 2026.02.12, v10.0.0
2
+
3
+ feature:
4
+ - 7c4b076 gritty: migrate to ESM
5
+ - 7cc62e0 gritty: get rid of mock-require
6
+
1
7
  2026.02.10, v9.0.4
2
8
 
3
9
  feature:
package/README.md CHANGED
@@ -107,15 +107,15 @@ And use it this way:
107
107
 
108
108
  ```js
109
109
  // server.js
110
- const http = require('node:http');
111
- const gritty = require('gritty');
110
+ import http from 'node:http';
111
+ import {gritty} from 'gritty';
112
112
 
113
- const express = require('express');
114
- const io = require('socket.io');
113
+ import express from 'express';
114
+ import {Server} from 'socket.io';
115
115
 
116
116
  const app = express();
117
117
  const server = http.createServer(app);
118
- const socket = io.listen(server);
118
+ const socket = new Server(server);
119
119
 
120
120
  const port = 1337;
121
121
  const ip = '0.0.0.0';
package/bin/gritty.js CHANGED
@@ -1,10 +1,25 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- 'use strict';
3
+ import process from 'node:process';
4
+ import http from 'node:http';
5
+ import {fileURLToPath} from 'node:url';
6
+ import {dirname} from 'node:path';
7
+ import yargsParser from 'yargs-parser';
8
+ import squad from 'squad';
9
+ import express from 'express';
10
+ import {Server} from 'socket.io';
11
+ import {gritty} from '#gritty/server';
12
+ import bin from '../help.json' with {
13
+ type: 'json',
14
+ };
15
+ import pack from '../package.json' with {
16
+ type: 'json',
17
+ };
4
18
 
5
- const {join} = require('node:path');
6
- const process = require('node:process');
7
- const args = require('yargs-parser')(process.argv.slice(2), {
19
+ const __filename = fileURLToPath(import.meta.url);
20
+ const __dirname = dirname(__filename);
21
+
22
+ const args = yargsParser(process.argv.slice(2), {
8
23
  boolean: [
9
24
  'version',
10
25
  'help',
@@ -45,12 +60,10 @@ function main(args) {
45
60
  }
46
61
 
47
62
  function path() {
48
- console.log(join(__dirname, '..'));
63
+ console.log(new URL('..', import.meta.url).pathname);
49
64
  }
50
65
 
51
66
  function start(options) {
52
- const squad = require('squad');
53
-
54
67
  const {
55
68
  port,
56
69
  command,
@@ -61,12 +74,6 @@ function start(options) {
61
74
 
62
75
  const DIR = `${__dirname}/../`;
63
76
 
64
- const gritty = require('../');
65
- const http = require('node:http');
66
-
67
- const express = require('express');
68
- const io = require('socket.io');
69
-
70
77
  const app = express();
71
78
  const server = http.createServer(app);
72
79
 
@@ -77,7 +84,7 @@ function start(options) {
77
84
  .use(gritty())
78
85
  .use(express.static(DIR));
79
86
 
80
- const socket = io(server);
87
+ const socket = new Server(server);
81
88
 
82
89
  gritty.listen(socket, {
83
90
  command,
@@ -92,7 +99,6 @@ function start(options) {
92
99
  }
93
100
 
94
101
  function help() {
95
- const bin = require('../help');
96
102
  const usage = 'Usage: gritty [options]';
97
103
 
98
104
  console.log(usage);
@@ -104,7 +110,6 @@ function help() {
104
110
  }
105
111
 
106
112
  function version() {
107
- const pack = require('../package');
108
113
  console.log('v' + pack.version);
109
114
  }
110
115