penambahan web socket
This commit is contained in:
51
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/build.mjs
generated
vendored
Normal file
51
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/build.mjs
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
import nodeCrypto from 'node:crypto';
|
||||
import { defineCommand } from 'citty';
|
||||
import { createNitro, prepare, copyPublicAssets, prerender, build as build$1 } from 'nitropack/core';
|
||||
import { resolve } from 'pathe';
|
||||
import { c as commonArgs } from './common.mjs';
|
||||
|
||||
if (!globalThis.crypto) {
|
||||
globalThis.crypto = nodeCrypto;
|
||||
}
|
||||
const build = defineCommand({
|
||||
meta: {
|
||||
name: "build",
|
||||
description: "Build nitro project for production"
|
||||
},
|
||||
args: {
|
||||
...commonArgs,
|
||||
minify: {
|
||||
type: "boolean",
|
||||
description: "Minify the output (overrides preset defaults you can also use `--no-minify` to disable)."
|
||||
},
|
||||
preset: {
|
||||
type: "string",
|
||||
description: "The build preset to use (you can also use `NITRO_PRESET` environment variable)."
|
||||
},
|
||||
compatibilityDate: {
|
||||
type: "string",
|
||||
description: "The date to use for preset compatibility (you can also use `NITRO_COMPATIBILITY_DATE` environment variable)."
|
||||
}
|
||||
},
|
||||
async run({ args }) {
|
||||
const rootDir = resolve(args.dir || args._dir || ".");
|
||||
const nitro = await createNitro(
|
||||
{
|
||||
rootDir,
|
||||
dev: false,
|
||||
minify: args.minify,
|
||||
preset: args.preset
|
||||
},
|
||||
{
|
||||
compatibilityDate: args.compatibilityDate
|
||||
}
|
||||
);
|
||||
await prepare(nitro);
|
||||
await copyPublicAssets(nitro);
|
||||
await prerender(nitro);
|
||||
await build$1(nitro);
|
||||
await nitro.close();
|
||||
}
|
||||
});
|
||||
|
||||
export { build as default };
|
||||
13
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/common.mjs
generated
vendored
Normal file
13
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/common.mjs
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
const commonArgs = {
|
||||
dir: {
|
||||
type: "string",
|
||||
description: "project root directory"
|
||||
},
|
||||
_dir: {
|
||||
type: "positional",
|
||||
default: ".",
|
||||
description: "project root directory (prefer using `--dir`)"
|
||||
}
|
||||
};
|
||||
|
||||
export { commonArgs as c };
|
||||
66
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/dev.mjs
generated
vendored
Normal file
66
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/dev.mjs
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
import nodeCrypto from 'node:crypto';
|
||||
import { defineCommand } from 'citty';
|
||||
import { consola } from 'consola';
|
||||
import { getArgs, parseArgs } from 'listhen/cli';
|
||||
import { createNitro, createDevServer, prepare, build } from 'nitropack/core';
|
||||
import { resolve } from 'pathe';
|
||||
import { c as commonArgs } from './common.mjs';
|
||||
|
||||
const hmrKeyRe = /^runtimeConfig\.|routeRules\./;
|
||||
if (!globalThis.crypto) {
|
||||
globalThis.crypto = nodeCrypto;
|
||||
}
|
||||
const dev = defineCommand({
|
||||
meta: {
|
||||
name: "dev",
|
||||
description: "Start the development server"
|
||||
},
|
||||
args: {
|
||||
...commonArgs,
|
||||
...getArgs()
|
||||
},
|
||||
async run({ args }) {
|
||||
const rootDir = resolve(args.dir || args._dir || ".");
|
||||
let nitro;
|
||||
const reload = async () => {
|
||||
if (nitro) {
|
||||
consola.info("Restarting dev server...");
|
||||
if ("unwatch" in nitro.options._c12) {
|
||||
await nitro.options._c12.unwatch();
|
||||
}
|
||||
await nitro.close();
|
||||
}
|
||||
nitro = await createNitro(
|
||||
{
|
||||
rootDir,
|
||||
dev: true,
|
||||
_cli: { command: "dev" }
|
||||
},
|
||||
{
|
||||
watch: true,
|
||||
c12: {
|
||||
async onUpdate({ getDiff, newConfig }) {
|
||||
const diff = getDiff();
|
||||
if (diff.length === 0) {
|
||||
return;
|
||||
}
|
||||
consola.info(
|
||||
"Nitro config updated:\n" + diff.map((entry) => ` ${entry.toString()}`).join("\n")
|
||||
);
|
||||
await (diff.every((e) => hmrKeyRe.test(e.key)) ? nitro.updateConfig(newConfig.config || {}) : reload());
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
nitro.hooks.hookOnce("restart", reload);
|
||||
const server = createDevServer(nitro);
|
||||
const listhenOptions = parseArgs(args);
|
||||
await server.listen(listhenOptions.port || 3e3, listhenOptions);
|
||||
await prepare(nitro);
|
||||
await build(nitro);
|
||||
};
|
||||
await reload();
|
||||
}
|
||||
});
|
||||
|
||||
export { dev as default };
|
||||
1
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/index.d.mts
generated
vendored
Normal file
1
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/index.d.ts
generated
vendored
Normal file
1
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
18
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/index.mjs
generated
vendored
Normal file
18
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
import { defineCommand, runMain } from 'citty';
|
||||
import { version } from 'nitropack/meta';
|
||||
|
||||
const main = defineCommand({
|
||||
meta: {
|
||||
name: "nitro",
|
||||
description: "Nitro CLI",
|
||||
version: version
|
||||
},
|
||||
subCommands: {
|
||||
dev: () => import('./dev.mjs').then((r) => r.default),
|
||||
build: () => import('./build.mjs').then((r) => r.default),
|
||||
prepare: () => import('./prepare.mjs').then((r) => r.default),
|
||||
task: () => import('./index2.mjs').then((r) => r.default)
|
||||
}
|
||||
});
|
||||
runMain(main);
|
||||
14
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/index2.mjs
generated
vendored
Normal file
14
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/index2.mjs
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { defineCommand } from 'citty';
|
||||
|
||||
const index = defineCommand({
|
||||
meta: {
|
||||
name: "task",
|
||||
description: "Operate in nitro tasks (experimental)"
|
||||
},
|
||||
subCommands: {
|
||||
list: () => import('./list.mjs').then((r) => r.default),
|
||||
run: () => import('./run.mjs').then((r) => r.default)
|
||||
}
|
||||
});
|
||||
|
||||
export { index as default };
|
||||
32
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/list.mjs
generated
vendored
Normal file
32
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/list.mjs
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { defineCommand } from 'citty';
|
||||
import { consola } from 'consola';
|
||||
import { loadOptions, listTasks } from 'nitropack/core';
|
||||
import { resolve } from 'pathe';
|
||||
|
||||
const list = defineCommand({
|
||||
meta: {
|
||||
name: "run",
|
||||
description: "List available tasks (experimental)"
|
||||
},
|
||||
args: {
|
||||
dir: {
|
||||
type: "string",
|
||||
description: "project root directory"
|
||||
}
|
||||
},
|
||||
async run({ args }) {
|
||||
const cwd = resolve(args.dir || args.cwd || ".");
|
||||
const options = await loadOptions({ rootDir: cwd }).catch(() => void 0);
|
||||
const tasks = await listTasks({
|
||||
cwd,
|
||||
buildDir: options?.buildDir || ".nitro"
|
||||
});
|
||||
for (const [name, task] of Object.entries(tasks)) {
|
||||
consola.log(
|
||||
` - \`${name}\`${task.meta?.description ? ` - ${task.meta.description}` : ""}`
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export { list as default };
|
||||
21
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/prepare.mjs
generated
vendored
Normal file
21
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/prepare.mjs
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { defineCommand } from 'citty';
|
||||
import { createNitro, writeTypes } from 'nitropack/core';
|
||||
import { resolve } from 'pathe';
|
||||
import { c as commonArgs } from './common.mjs';
|
||||
|
||||
const prepare = defineCommand({
|
||||
meta: {
|
||||
name: "prepare",
|
||||
description: "Generate types for the project"
|
||||
},
|
||||
args: {
|
||||
...commonArgs
|
||||
},
|
||||
async run({ args }) {
|
||||
const rootDir = resolve(args.dir || args._dir || ".");
|
||||
const nitro = await createNitro({ rootDir });
|
||||
await writeTypes(nitro);
|
||||
}
|
||||
});
|
||||
|
||||
export { prepare as default };
|
||||
58
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/run.mjs
generated
vendored
Normal file
58
examples/nuxt3-websocket-client/node_modules/nitropack/dist/cli/run.mjs
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
import { defineCommand } from 'citty';
|
||||
import { consola } from 'consola';
|
||||
import destr from 'destr';
|
||||
import { loadOptions, runTask } from 'nitropack/core';
|
||||
import { resolve } from 'pathe';
|
||||
|
||||
const run = defineCommand({
|
||||
meta: {
|
||||
name: "run",
|
||||
description: "Run a runtime task in the currently running dev server (experimental)"
|
||||
},
|
||||
args: {
|
||||
name: {
|
||||
type: "positional",
|
||||
description: "task name",
|
||||
required: true
|
||||
},
|
||||
dir: {
|
||||
type: "string",
|
||||
description: "project root directory"
|
||||
},
|
||||
payload: {
|
||||
type: "string",
|
||||
description: "payload json to pass to the task"
|
||||
}
|
||||
},
|
||||
async run({ args }) {
|
||||
const cwd = resolve(args.dir || args.cwd || ".");
|
||||
const options = await loadOptions({ rootDir: cwd }).catch(() => void 0);
|
||||
consola.info(`Running task \`${args.name}\`...`);
|
||||
let payload = destr(args.payload || "{}");
|
||||
if (typeof payload !== "object") {
|
||||
consola.error(
|
||||
`Invalid payload: \`${args.payload}\` (it should be a valid JSON object)`
|
||||
);
|
||||
payload = void 0;
|
||||
}
|
||||
try {
|
||||
const { result } = await runTask(
|
||||
{
|
||||
name: args.name,
|
||||
context: {},
|
||||
payload
|
||||
},
|
||||
{
|
||||
cwd,
|
||||
buildDir: options?.buildDir || ".nitro"
|
||||
}
|
||||
);
|
||||
consola.success("Result:", result);
|
||||
} catch (error) {
|
||||
consola.error(`Failed to run task \`${args.name}\`: ${error}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export { run as default };
|
||||
Reference in New Issue
Block a user