@nuxt/devtools-wizard-nightly 2.0.0-beta.0-28940159.3b2c84c

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-PRESENT Nuxt Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,129 @@
1
+ <a href="https://devtools.nuxt.com"><img width="1200" alt="Nuxt DevTools" src="https://github-production-user-asset-6210df.s3.amazonaws.com/904724/261577617-a10567bd-ad33-48cc-9bda-9e37dbe1929f.png"></a>
2
+ <br>
3
+
4
+ <h1>
5
+ Nuxt DevTools
6
+ </h1>
7
+
8
+ [![npm version][npm-version-src]][npm-version-href]
9
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
10
+ [![License][license-src]][license-href]
11
+ [![Nuxt][nuxt-src]][nuxt-href]
12
+ [![Volta][volta-src]][volta-href]
13
+
14
+ <p>
15
+ Unleash Nuxt Developer Experience.
16
+ <br>Nuxt DevTools is a set of visual tools that help you to know your app better.
17
+ </p>
18
+
19
+ <p>
20
+ <a href="https://nuxt.com/blog/nuxt-devtools-v1-0">πŸ‘‹ Introduction</a> |
21
+ <a href="https://github.com/nuxt/devtools/discussions/29">πŸ’‘ Ideas & Suggestions</a> |
22
+ <a href="https://github.com/nuxt/devtools/discussions/31">πŸ—ΊοΈ Project Roadmap</a> |
23
+ <a href="https://devtools.nuxt.com/">πŸ“š Documentation</a>
24
+ </p>
25
+
26
+ <br>
27
+
28
+ > [!NOTE]
29
+ > You are viewing the v2.x branch which are in active development. For the latest stable version, please refer to the [v1.x branch](https://github.com/nuxt/devtools/tree/v1)
30
+
31
+ ## Installation
32
+
33
+ > Nuxt DevTools v2 requires **Nuxt v3.15.0 or higher**.
34
+
35
+ Nuxt DevTools is **enabled by default** in Nuxt v3.8.0. You can press <kbd>Shift</kbd> + <kbd>Alt</kbd> / <kbd>⇧ Shift</kbd> + <kbd>βŒ₯ Option</kbd> + <kbd>D</kbd> in your app to open it up.
36
+
37
+ If you want to explicitly enable or disable Nuxt DevTools, you can update your `nuxt.config` with:
38
+
39
+ ```js
40
+ export default defineNuxtConfig({
41
+ devtools: {
42
+ enabled: true // or false to disable
43
+ }
44
+ })
45
+ ```
46
+
47
+ ### Nightly Release Channel
48
+
49
+ Similar to [Nuxt's Nightly Channel](https://nuxt.com/docs/guide/going-further/nightly-release-channel), DevTools also offers a nightly release channel, that automatically releases for every commit to `main` branch.
50
+
51
+ You can opt-in to the nightly release channel by running:
52
+
53
+ ```diff
54
+ {
55
+ "devDependencies": {
56
+ -- "@nuxt/devtools": "^0.1.0"
57
+ ++ "@nuxt/devtools": "npm:@nuxt/devtools-nightly@latest"
58
+ }
59
+ }
60
+ ```
61
+
62
+ Remove lockfile (`package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml`) and reinstall dependencies.
63
+
64
+ ### Module Options
65
+
66
+ To configure Nuxt DevTools, you can pass the `devtools` options.
67
+
68
+ ```ts
69
+ // nuxt.config.ts
70
+ export default defineNuxtConfig({
71
+ devtools: {
72
+ // Enable devtools (default: true)
73
+ enabled: true,
74
+ // VS Code Server options
75
+ vscode: {},
76
+ // ...other options
77
+ }
78
+ })
79
+ ```
80
+
81
+ For all options available, please refer to TSDocs in your IDE, or the [type definition file](https://github.com/nuxt/devtools/blob/main/packages/devtools-kit/src/_types/options.ts).
82
+
83
+ ## Features
84
+
85
+ Read the [**Announcement Blog Post 🎊**](https://nuxt.com/blog/nuxt-devtools-v1-0) for why we built Nuxt DevTools and what it can do!
86
+
87
+ ## Module Authors
88
+
89
+ Please refer to the [Module Authors Guide](https://devtools.nuxt.com/module/guide).
90
+
91
+ ## Contribution Guide
92
+
93
+ Please refer to the [Contribution Guide](https://devtools.nuxt.com/development/contributing).
94
+
95
+ ## Anonymous Usage Analytics
96
+
97
+ Nuxt DevTools collects anonymous telemetry data about general usage. This helps us to accurately gauge feature usage and customization across all our users. This data will let us better understand how each features in Nuxt DevTools are used, measuring improvements made (DX and performances) and their relevance. It would also help us to prioritize our efforts and focus on the features that matter the most to our users.
98
+
99
+ Nuxt DevTools' telemetry data is piped through [Nuxt Telemetry](https://github.com/nuxt/telemetry), meaning that Nuxt DevTools will respect your local and global Nuxt Telemetry settings. You can also opt-out Nuxt DevTools' telemetry in the Nuxt DevTools settings.
100
+
101
+ The data we collect is completely anonymous, not traceable to the source (using hash+seed), and only meaningful in aggregate form. No data we collect is personally identifiable or trackable.
102
+
103
+ ### Events
104
+
105
+ On top of the [default Nuxt Telemetry events](https://github.com/nuxt/telemetry#events), Nuxt DevTools also collects the following events:
106
+
107
+ - Versions of Nuxt DevTools
108
+ - Navigations between tabs/feature
109
+ - This helps us to understand which features are used the most to prioritize our efforts.
110
+ - Browser and OS names and versions
111
+ - This helps us improve compatibility across different browsers and operating systems.
112
+ - Click event on some action buttons
113
+
114
+ ## License
115
+
116
+ [MIT](./LICENSE)
117
+
118
+ <!-- Badges -->
119
+
120
+ [npm-version-src]: https://img.shields.io/npm/v/@nuxt/devtools/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
121
+ [npm-version-href]: https://npmjs.com/package/@nuxt/devtools
122
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@nuxt/devtools.svg?style=flat&colorA=18181B&colorB=28CF8D
123
+ [npm-downloads-href]: https://npm.chart.dev/@nuxt/devtools
124
+ [license-src]: https://img.shields.io/npm/l/@nuxt/devtools.svg?style=flat&colorA=18181B&colorB=28CF8D
125
+ [license-href]: https://npmjs.com/package/@nuxt/devtools
126
+ [nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
127
+ [nuxt-href]: https://nuxt.com
128
+ [volta-src]: https://user-images.githubusercontent.com/904724/209143798-32345f6c-3cf8-4e06-9659-f4ace4a6acde.svg
129
+ [volta-href]: https://volta.net/nuxt/devtools?utm_source=nuxt_devtools_readme
package/cli.mjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import('./dist/index.mjs')
@@ -0,0 +1,109 @@
1
+ import { existsSync } from 'node:fs';
2
+ import fsp from 'node:fs/promises';
3
+ import { relative } from 'node:path';
4
+ import { consola } from 'consola';
5
+ import { colors } from 'consola/utils';
6
+ import { diffLines } from 'diff';
7
+ import { parseModule } from 'magicast';
8
+ import { join } from 'pathe';
9
+ import prompts from 'prompts';
10
+
11
+ function findNuxtConfig(cwd) {
12
+ const names = [
13
+ "nuxt.config.ts",
14
+ "nuxt.config.js"
15
+ ];
16
+ for (const name of names) {
17
+ const path = join(cwd, name);
18
+ if (existsSync(path))
19
+ return path;
20
+ }
21
+ }
22
+ function printOutManual(value) {
23
+ consola.info(colors.yellow("To manually enable Nuxt DevTools, add the following to your Nuxt config:"));
24
+ consola.info(colors.cyan(`
25
+ devtools: { enabled: ${value} }
26
+ `));
27
+ }
28
+ async function toggleConfig(cwd, value) {
29
+ const nuxtConfig = findNuxtConfig(cwd);
30
+ if (!nuxtConfig) {
31
+ consola.error(colors.red("Unable to find Nuxt config file in current directory"));
32
+ process.exitCode = 1;
33
+ printOutManual(true);
34
+ return false;
35
+ }
36
+ try {
37
+ const source = await fsp.readFile(nuxtConfig, "utf-8");
38
+ const mod = await parseModule(source, { sourceFileName: nuxtConfig });
39
+ const config = mod.exports.default.$type === "function-call" ? mod.exports.default.$args[0] : mod.exports.default;
40
+ if (config.devtools || value) {
41
+ config.devtools ||= {};
42
+ if (typeof config.devtools === "object")
43
+ config.devtools.enabled = value;
44
+ }
45
+ const generated = mod.generate().code;
46
+ if (source.trim() === generated.trim()) {
47
+ consola.info(colors.yellow(`Nuxt DevTools is already ${value ? "enabled" : "disabled"}`));
48
+ } else {
49
+ consola.log("");
50
+ consola.log("We are going to update the Nuxt config with with the following changes:");
51
+ consola.log(colors.bold(colors.green(`./${relative(cwd, nuxtConfig)}`)));
52
+ consola.log("");
53
+ printDiffToCLI(source, generated);
54
+ consola.log("");
55
+ const { confirm } = await prompts({
56
+ type: "confirm",
57
+ name: "confirm",
58
+ message: "Continue?",
59
+ initial: true
60
+ });
61
+ if (!confirm)
62
+ return false;
63
+ await fsp.writeFile(nuxtConfig, `${generated.trimEnd()}
64
+ `, "utf-8");
65
+ }
66
+ } catch {
67
+ consola.error(colors.red("Unable to update Nuxt config file automatically"));
68
+ process.exitCode = 1;
69
+ printOutManual(true);
70
+ return false;
71
+ }
72
+ return true;
73
+ }
74
+ async function enable(cwd) {
75
+ if (await toggleConfig(cwd, true)) {
76
+ await import('./global.mjs').then((r) => r.disableSilently(cwd));
77
+ consola.success(colors.green("Nuxt DevTools is enabled! Restart your Nuxt app to start using it."));
78
+ }
79
+ }
80
+ async function disable(cwd) {
81
+ if (await toggleConfig(cwd, false)) {
82
+ await import('./global.mjs').then((r) => r.disableSilently(cwd));
83
+ consola.success("Nuxt DevTools disabled for this project.");
84
+ }
85
+ }
86
+ function printDiffToCLI(from, to) {
87
+ const diffs = diffLines(from.trim(), to.trim());
88
+ let output = "";
89
+ let no = 0;
90
+ for (const diff of diffs) {
91
+ const lines = diff.value.trimEnd().split("\n");
92
+ for (const line of lines) {
93
+ if (!diff.added)
94
+ no += 1;
95
+ if (diff.added)
96
+ output += colors.green(`+ | ${line}
97
+ `);
98
+ else if (diff.removed)
99
+ output += colors.red(`-${no.toString().padStart(3, " ")} | ${line}
100
+ `);
101
+ else
102
+ output += colors.gray(`${colors.dim(`${no.toString().padStart(4, " ")} |`)} ${line}
103
+ `);
104
+ }
105
+ }
106
+ consola.log(output.trimEnd());
107
+ }
108
+
109
+ export { disable, enable };
@@ -0,0 +1,67 @@
1
+ import fs from 'node:fs';
2
+ import { consola } from 'consola';
3
+ import { execa } from 'execa';
4
+ import globalDirs from 'global-directory';
5
+ import { resolve } from 'pathe';
6
+ import { readUser, writeUser } from 'rc9';
7
+
8
+ const moduleName = "@nuxt/devtools";
9
+ const RC_PATH = ".nuxtrc";
10
+ const pathRegex = /[\\/]@nuxt[\\/]devtools[\\/]/;
11
+ async function enable(cwd) {
12
+ const rc = readUser(RC_PATH);
13
+ consola.info("Installed Nuxt DevTools...");
14
+ await execa("npm", ["install", "-g", `${moduleName}@latest`], { stdio: "inherit" });
15
+ markEnable(rc, cwd);
16
+ consola.info("Nuxt DevTools enabled! Restart your Nuxt app to start using it.");
17
+ }
18
+ function markEnable(rc, path) {
19
+ const modulePath = resolve(globalDirs.npm.packages, moduleName);
20
+ const targetPath = resolve(modulePath, "module.cjs").replace(/\\/g, "/");
21
+ if (!fs.existsSync(targetPath))
22
+ throw new Error("Failed to locate the global Nuxt DevTools module. You may try it again");
23
+ removeModule(rc);
24
+ if (!rc.modules?.includes(targetPath))
25
+ rc.modules = [...rc.modules || [], targetPath];
26
+ if (!rc.devtoolsGlobal)
27
+ rc.devtoolsGlobal = {};
28
+ if (!rc.devtoolsGlobal.projects)
29
+ rc.devtoolsGlobal.projects = [];
30
+ if (!rc.devtoolsGlobal.projects.includes(path))
31
+ rc.devtoolsGlobal.projects.push(path);
32
+ writeUser(rc, RC_PATH);
33
+ }
34
+ function disableSilently(cwd) {
35
+ const rc = readUser(RC_PATH);
36
+ if (markDisable(rc, cwd))
37
+ writeUser(rc, RC_PATH);
38
+ }
39
+ async function disable(cwd, args) {
40
+ const rc = readUser(RC_PATH);
41
+ const isRemove = args.includes("--remove");
42
+ if (markDisable(rc, cwd))
43
+ consola.success("Nuxt DevTools disabled for this project.");
44
+ else if (!isRemove)
45
+ consola.warn("Nuxt DevTools is not enabled for this project.");
46
+ if (isRemove) {
47
+ removeModule(rc);
48
+ consola.success("Nuxt DevTools is removed globally");
49
+ }
50
+ writeUser(rc, RC_PATH);
51
+ }
52
+ function markDisable(rc, path) {
53
+ if (rc?.devtoolsGlobal?.projects?.includes(path)) {
54
+ rc.devtoolsGlobal.projects = rc.devtoolsGlobal.projects.filter((p) => p !== path);
55
+ return true;
56
+ }
57
+ if (!rc?.devtoolsGlobal?.projects?.length)
58
+ removeModule(rc);
59
+ return false;
60
+ }
61
+ function removeModule(rc) {
62
+ if (Array.isArray(rc.modules))
63
+ rc.modules = rc.modules.filter((p) => !p.match(pathRegex));
64
+ return true;
65
+ }
66
+
67
+ export { RC_PATH, disable, disableSilently, enable, removeModule };
package/dist/index.mjs ADDED
@@ -0,0 +1,59 @@
1
+ import { consola } from 'consola';
2
+ import { colors } from 'consola/utils';
3
+ import { readPackageJSON } from 'pkg-types';
4
+ import semver from 'semver';
5
+
6
+ const name = "@nuxt/devtools-wizard-nightly";
7
+ const version = "2.0.0-beta.0-28940159.3b2c84c";
8
+
9
+ async function getNuxtVersion(path) {
10
+ try {
11
+ const pkg = await readPackageJSON("nuxt", { url: path });
12
+ if (!pkg.version)
13
+ consola.warn("Cannot find any installed nuxt versions in ", path);
14
+ return pkg.version || null;
15
+ } catch {
16
+ return null;
17
+ }
18
+ }
19
+ async function run() {
20
+ const args = process.argv.slice(2);
21
+ const command = args[0];
22
+ const cwd = process.cwd();
23
+ consola.log("");
24
+ consola.log(colors.bold(colors.green(" Nuxt ")));
25
+ consola.log(`${colors.inverse(colors.bold(colors.green(" DevTools ")))} ${colors.green(`v${version}`)}`);
26
+ consola.log(`
27
+ ${colors.gray("Learn more at https://devtools.nuxt.com\n")}`);
28
+ if (name.endsWith("-edge") || name.endsWith("-nightly"))
29
+ throw new Error("Nightly release of Nuxt DevTools requires to be installed locally. Learn more at https://github.com/nuxt/devtools/#nightly-release-channel");
30
+ const nuxtVersion = await getNuxtVersion(cwd);
31
+ if (!nuxtVersion) {
32
+ consola.error("Unable to find any installed nuxt version in the current directory");
33
+ process.exit(1);
34
+ }
35
+ const isDevToolsBuiltIn = semver.gte(nuxtVersion, "3.4.0");
36
+ if (command === "enable") {
37
+ consola.log(colors.green("Enabling Nuxt DevTools..."));
38
+ if (isDevToolsBuiltIn)
39
+ await import('./chunks/builtin.mjs').then((r) => r.enable(cwd));
40
+ else
41
+ await import('./chunks/global.mjs').then((r) => r.enable(cwd));
42
+ } else if (command === "disable") {
43
+ consola.log(colors.magenta("Disabling Nuxt DevTools..."));
44
+ if (isDevToolsBuiltIn)
45
+ await import('./chunks/builtin.mjs').then((r) => r.disable(cwd));
46
+ else
47
+ await import('./chunks/global.mjs').then((r) => r.disable(cwd, args));
48
+ } else if (!command) {
49
+ consola.log(`npx ${name} enable|disable`);
50
+ process.exit(1);
51
+ } else {
52
+ consola.log(colors.red(`Unknown command "${command}"`));
53
+ process.exit(1);
54
+ }
55
+ }
56
+ run().catch((err) => {
57
+ consola.error(err);
58
+ process.exit(1);
59
+ });
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@nuxt/devtools-wizard-nightly",
3
+ "type": "module",
4
+ "version": "2.0.0-beta.0-28940159.3b2c84c",
5
+ "description": "CLI Wizard to toggle Nuxt DevTools",
6
+ "license": "MIT",
7
+ "homepage": "https://devtools.nuxt.com",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/nuxt/devtools.git",
11
+ "directory": "packages/devtools-wizard"
12
+ },
13
+ "main": "./dist/index.mjs",
14
+ "bin": "./cli.mjs",
15
+ "files": [
16
+ "*.cjs",
17
+ "*.d.ts",
18
+ "*.mjs",
19
+ "dist"
20
+ ],
21
+ "dependencies": {
22
+ "consola": "^3.3.3",
23
+ "diff": "^7.0.0",
24
+ "execa": "^7.2.0",
25
+ "global-directory": "^4.0.1",
26
+ "magicast": "^0.3.5",
27
+ "pathe": "^2.0.0",
28
+ "pkg-types": "^1.3.0",
29
+ "prompts": "^2.4.2",
30
+ "rc9": "^2.1.2",
31
+ "semver": "^7.6.3"
32
+ },
33
+ "devDependencies": {
34
+ "@types/diff": "^7.0.0",
35
+ "@types/prompts": "^2.4.9",
36
+ "unbuild": "^3.2.0"
37
+ },
38
+ "scripts": {
39
+ "build": "unbuild",
40
+ "stub": "unbuild --stub",
41
+ "dev:prepare": "nr stub"
42
+ }
43
+ }