@mokup/cli 1.0.4 → 1.0.5
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/index.cjs +16 -13
- package/dist/index.mjs +13 -10
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -9,7 +9,6 @@ const node_url = require('node:url');
|
|
|
9
9
|
const esbuild = require('@mokup/shared/esbuild');
|
|
10
10
|
const runtime = require('@mokup/runtime');
|
|
11
11
|
const jsoncParser = require('@mokup/shared/jsonc-parser');
|
|
12
|
-
const server = require('@mokup/server');
|
|
13
12
|
const node = require('@mokup/server/node');
|
|
14
13
|
const commander = require('commander');
|
|
15
14
|
|
|
@@ -829,10 +828,10 @@ function toServeOptions(options) {
|
|
|
829
828
|
}
|
|
830
829
|
serveOptions.port = parsed;
|
|
831
830
|
}
|
|
832
|
-
|
|
833
|
-
serveOptions
|
|
834
|
-
|
|
835
|
-
|
|
831
|
+
return {
|
|
832
|
+
entry: serveOptions,
|
|
833
|
+
playground: options.playground
|
|
834
|
+
};
|
|
836
835
|
}
|
|
837
836
|
function createCli() {
|
|
838
837
|
const program = new commander.Command();
|
|
@@ -843,14 +842,18 @@ function createCli() {
|
|
|
843
842
|
});
|
|
844
843
|
program.command("serve").description("Start a Node.js mock server").option("-d, --dir <dir>", "Mock directory (repeatable)", collectValues).option("--prefix <prefix>", "URL prefix").option("--include <pattern>", "Include regex (repeatable)", collectRegex).option("--exclude <pattern>", "Exclude regex (repeatable)", collectRegex).option("--ignore-prefix <prefix>", "Ignore path segment prefix (repeatable)", collectValues).option("--host <host>", "Hostname (default: localhost)").option("--port <port>", "Port (default: 8080)").option("--no-watch", "Disable file watching").option("--no-playground", "Disable Playground").option("--no-log", "Disable logging").action(async (options) => {
|
|
845
844
|
const serveOptions = toServeOptions(options);
|
|
846
|
-
const
|
|
847
|
-
const
|
|
848
|
-
const
|
|
845
|
+
const { entry, playground } = serveOptions;
|
|
846
|
+
const host = entry.host ?? "localhost";
|
|
847
|
+
const port = entry.port ?? 8080;
|
|
848
|
+
const playgroundEnabled = playground !== false;
|
|
849
849
|
const playgroundPath = "/_mokup";
|
|
850
|
-
const server
|
|
850
|
+
const server = await node.createFetchServer({
|
|
851
|
+
entries: entry,
|
|
852
|
+
playground
|
|
853
|
+
});
|
|
851
854
|
const nodeServer = node.serve(
|
|
852
855
|
{
|
|
853
|
-
fetch: server
|
|
856
|
+
fetch: server.fetch,
|
|
854
857
|
hostname: host,
|
|
855
858
|
port
|
|
856
859
|
},
|
|
@@ -863,11 +866,11 @@ function createCli() {
|
|
|
863
866
|
}
|
|
864
867
|
}
|
|
865
868
|
);
|
|
866
|
-
server
|
|
869
|
+
server.injectWebSocket?.(nodeServer);
|
|
867
870
|
const shutdown = async () => {
|
|
868
871
|
try {
|
|
869
|
-
if (server
|
|
870
|
-
await server
|
|
872
|
+
if (server.close) {
|
|
873
|
+
await server.close();
|
|
871
874
|
}
|
|
872
875
|
await new Promise((resolve, reject) => {
|
|
873
876
|
nodeServer.close((error) => {
|
package/dist/index.mjs
CHANGED
|
@@ -7,8 +7,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
7
7
|
import { build } from '@mokup/shared/esbuild';
|
|
8
8
|
import { parseRouteTemplate, compareRouteScore } from '@mokup/runtime';
|
|
9
9
|
import { parse } from '@mokup/shared/jsonc-parser';
|
|
10
|
-
import { createFetchServer } from '@mokup/server';
|
|
11
|
-
import { serve } from '@mokup/server/node';
|
|
10
|
+
import { createFetchServer, serve } from '@mokup/server/node';
|
|
12
11
|
import { Command } from 'commander';
|
|
13
12
|
|
|
14
13
|
async function writeBundle(outDir, hasHandlers) {
|
|
@@ -822,10 +821,10 @@ function toServeOptions(options) {
|
|
|
822
821
|
}
|
|
823
822
|
serveOptions.port = parsed;
|
|
824
823
|
}
|
|
825
|
-
|
|
826
|
-
serveOptions
|
|
827
|
-
|
|
828
|
-
|
|
824
|
+
return {
|
|
825
|
+
entry: serveOptions,
|
|
826
|
+
playground: options.playground
|
|
827
|
+
};
|
|
829
828
|
}
|
|
830
829
|
function createCli() {
|
|
831
830
|
const program = new Command();
|
|
@@ -836,11 +835,15 @@ function createCli() {
|
|
|
836
835
|
});
|
|
837
836
|
program.command("serve").description("Start a Node.js mock server").option("-d, --dir <dir>", "Mock directory (repeatable)", collectValues).option("--prefix <prefix>", "URL prefix").option("--include <pattern>", "Include regex (repeatable)", collectRegex).option("--exclude <pattern>", "Exclude regex (repeatable)", collectRegex).option("--ignore-prefix <prefix>", "Ignore path segment prefix (repeatable)", collectValues).option("--host <host>", "Hostname (default: localhost)").option("--port <port>", "Port (default: 8080)").option("--no-watch", "Disable file watching").option("--no-playground", "Disable Playground").option("--no-log", "Disable logging").action(async (options) => {
|
|
838
837
|
const serveOptions = toServeOptions(options);
|
|
839
|
-
const
|
|
840
|
-
const
|
|
841
|
-
const
|
|
838
|
+
const { entry, playground } = serveOptions;
|
|
839
|
+
const host = entry.host ?? "localhost";
|
|
840
|
+
const port = entry.port ?? 8080;
|
|
841
|
+
const playgroundEnabled = playground !== false;
|
|
842
842
|
const playgroundPath = "/_mokup";
|
|
843
|
-
const server = await createFetchServer(
|
|
843
|
+
const server = await createFetchServer({
|
|
844
|
+
entries: entry,
|
|
845
|
+
playground
|
|
846
|
+
});
|
|
844
847
|
const nodeServer = serve(
|
|
845
848
|
{
|
|
846
849
|
fetch: server.fetch,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mokup/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"description": "CLI for building mokup manifests and handlers.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://mokup.icebreaker.top",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"commander": "^14.0.0",
|
|
31
|
-
"@mokup/runtime": "1.0.
|
|
32
|
-
"@mokup/
|
|
33
|
-
"@mokup/
|
|
31
|
+
"@mokup/runtime": "1.0.2",
|
|
32
|
+
"@mokup/shared": "1.0.1",
|
|
33
|
+
"@mokup/server": "1.1.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^25.0.10",
|