Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
103
Frontend-Learner/node_modules/@nuxt/devtools-wizard/dist/chunks/builtin.mjs
generated
vendored
Normal file
103
Frontend-Learner/node_modules/@nuxt/devtools-wizard/dist/chunks/builtin.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
import { existsSync } from 'node:fs';
|
||||
import fsp from 'node:fs/promises';
|
||||
import { relative } from 'node:path';
|
||||
import { consola } from 'consola';
|
||||
import { colors } from 'consola/utils';
|
||||
import { diffLines } from 'diff';
|
||||
import { parseModule } from 'magicast';
|
||||
import { join } from 'pathe';
|
||||
import prompts from 'prompts';
|
||||
|
||||
function findNuxtConfig(cwd) {
|
||||
const names = [
|
||||
"nuxt.config.ts",
|
||||
"nuxt.config.js"
|
||||
];
|
||||
for (const name of names) {
|
||||
const path = join(cwd, name);
|
||||
if (existsSync(path))
|
||||
return path;
|
||||
}
|
||||
}
|
||||
function printOutManual(value) {
|
||||
consola.info(colors.yellow("To manually enable Nuxt DevTools, add the following to your Nuxt config:"));
|
||||
consola.info(colors.cyan(`
|
||||
devtools: { enabled: ${value} }
|
||||
`));
|
||||
}
|
||||
async function toggleConfig(cwd, value) {
|
||||
const nuxtConfig = findNuxtConfig(cwd);
|
||||
if (!nuxtConfig) {
|
||||
consola.error(colors.red("Unable to find Nuxt config file in current directory"));
|
||||
process.exitCode = 1;
|
||||
printOutManual(true);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const source = await fsp.readFile(nuxtConfig, "utf-8");
|
||||
const mod = await parseModule(source, { sourceFileName: nuxtConfig });
|
||||
const config = mod.exports.default.$type === "function-call" ? mod.exports.default.$args[0] : mod.exports.default;
|
||||
if (config.devtools || value) {
|
||||
config.devtools ||= {};
|
||||
if (typeof config.devtools === "object")
|
||||
config.devtools.enabled = value;
|
||||
}
|
||||
const generated = mod.generate().code;
|
||||
if (source.trim() === generated.trim()) {
|
||||
consola.info(colors.yellow(`Nuxt DevTools is already ${value ? "enabled" : "disabled"}`));
|
||||
} else {
|
||||
consola.log("");
|
||||
consola.log("We are going to update the Nuxt config with with the following changes:");
|
||||
consola.log(colors.bold(colors.green(`./${relative(cwd, nuxtConfig)}`)));
|
||||
consola.log("");
|
||||
printDiffToCLI(source, generated);
|
||||
consola.log("");
|
||||
const { confirm } = await prompts({
|
||||
type: "confirm",
|
||||
name: "confirm",
|
||||
message: "Continue?",
|
||||
initial: true
|
||||
});
|
||||
if (!confirm)
|
||||
return false;
|
||||
await fsp.writeFile(nuxtConfig, `${generated.trimEnd()}
|
||||
`, "utf-8");
|
||||
}
|
||||
} catch {
|
||||
consola.error(colors.red("Unable to update Nuxt config file automatically"));
|
||||
process.exitCode = 1;
|
||||
printOutManual(true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
async function enable(cwd) {
|
||||
await toggleConfig(cwd, true);
|
||||
}
|
||||
async function disable(cwd) {
|
||||
await toggleConfig(cwd, false);
|
||||
}
|
||||
function printDiffToCLI(from, to) {
|
||||
const diffs = diffLines(from.trim(), to.trim());
|
||||
let output = "";
|
||||
let no = 0;
|
||||
for (const diff of diffs) {
|
||||
const lines = diff.value.trimEnd().split("\n");
|
||||
for (const line of lines) {
|
||||
if (!diff.added)
|
||||
no += 1;
|
||||
if (diff.added)
|
||||
output += colors.green(`+ | ${line}
|
||||
`);
|
||||
else if (diff.removed)
|
||||
output += colors.red(`-${no.toString().padStart(3, " ")} | ${line}
|
||||
`);
|
||||
else
|
||||
output += colors.gray(`${colors.dim(`${no.toString().padStart(4, " ")} |`)} ${line}
|
||||
`);
|
||||
}
|
||||
}
|
||||
consola.log(output.trimEnd());
|
||||
}
|
||||
|
||||
export { disable, enable };
|
||||
51
Frontend-Learner/node_modules/@nuxt/devtools-wizard/dist/index.mjs
generated
vendored
Normal file
51
Frontend-Learner/node_modules/@nuxt/devtools-wizard/dist/index.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import { consola } from 'consola';
|
||||
import { colors } from 'consola/utils';
|
||||
import { readPackageJSON } from 'pkg-types';
|
||||
|
||||
const name = "@nuxt/devtools-wizard";
|
||||
const version = "3.1.1";
|
||||
|
||||
async function getNuxtVersion(path) {
|
||||
try {
|
||||
const pkg = await readPackageJSON("nuxt", { url: path });
|
||||
if (!pkg.version)
|
||||
consola.warn("Cannot find any installed nuxt versions in ", path);
|
||||
return pkg.version || null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
async function run() {
|
||||
const args = process.argv.slice(2);
|
||||
const command = args[0];
|
||||
const cwd = process.cwd();
|
||||
consola.log("");
|
||||
consola.log(colors.bold(colors.green(" Nuxt ")));
|
||||
consola.log(`${colors.inverse(colors.bold(colors.green(" DevTools ")))} ${colors.green(`v${version}`)}`);
|
||||
consola.log(`
|
||||
${colors.gray("Learn more at https://devtools.nuxt.com\n")}`);
|
||||
if (name.endsWith("-edge") || name.endsWith("-nightly"))
|
||||
throw new Error("[Nuxt DevTools] Nightly release of Nuxt DevTools requires to be installed locally. Learn more at https://github.com/nuxt/devtools/#nightly-release-channel");
|
||||
const nuxtVersion = await getNuxtVersion(cwd);
|
||||
if (!nuxtVersion) {
|
||||
consola.error("[Nuxt DevTools] Unable to find any installed nuxt version in the current directory");
|
||||
process.exit(1);
|
||||
}
|
||||
if (command === "enable") {
|
||||
consola.log(colors.green("Enabling Nuxt DevTools..."));
|
||||
await import('./chunks/builtin.mjs').then((r) => r.enable(cwd));
|
||||
} else if (command === "disable") {
|
||||
consola.log(colors.magenta("Disabling Nuxt DevTools..."));
|
||||
await import('./chunks/builtin.mjs').then((r) => r.disable(cwd));
|
||||
} else if (!command) {
|
||||
consola.log(`npx ${name} enable|disable`);
|
||||
process.exit(1);
|
||||
} else {
|
||||
consola.log(colors.red(`Unknown command "${command}"`));
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
run().catch((err) => {
|
||||
consola.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue