initial commit

This commit is contained in:
Zoe
2023-01-03 09:29:04 -06:00
commit 7851137d88
12889 changed files with 2557443 additions and 0 deletions

21
node_modules/@nuxt/telemetry/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Nuxt Project
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

101
node_modules/@nuxt/telemetry/README.md generated vendored Normal file
View File

@@ -0,0 +1,101 @@
# Nuxt Telemetry Module
Nuxt collects anonymous telemetry data about general usage. This helps us to accurately gauge Nuxt feature usage and customization across all our users.
This program is optional. You will be asked on first time to get permission and you can always [opt-out](#opting-out) if you'd not like to share any information.
## Why collecting Telemetry?
Nuxt has grown a lot from its [initial release](https://github.com/nuxt/nuxt.js/releases/tag/v0.2.0) (7 Nov 2016) and we are keep listening to [community feedback](https://github.com/nuxt/nuxt.js/issues) to improve it.
However, this manual process only collects feedback from a subset of users that takes the time to fill the issue template and it may have different needs or use-case than you.
Nuxt Telemetry 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 Nuxt is used globally, measuring improvements made (DX and performances) and their relevance.
## Events
We collect multiple events:
- Command invoked (`nuxt dev`, `nuxt build`, etc)
- Versions of Nuxt and Node.js
- General machine informations (MacOS/Linux/Windows and if command is run within CI, ci name)
- Duration of the Webpack build and average size of the application, as well as the generation stats (when using `nuxt generate` or `nuxt export`)
- What are the *public dependency* of your project (Nuxt modules)
You can see the list of events in [lib/events](./src/events).
Example of an event:
```json
{
"name": "NUXT_PROJECT",
"payload": {
"type": "GIT",
"isSSR": true,
"target": "server",
"isTypescriptBuild": false,
"isTypescriptRuntime": false,
"isProgrammatic": false,
"packageManager": "npm"
}
}
```
To display the exact data that will be sent, you can use `NUXT_TELEMETRY_DEBUG=1`.
## Sensitive data
We take your privacy and our security very seriously.
We do not collect any metrics which may contain sensitive data.
This includes, but is not limited to: environment variables, file paths, contents of files, logs, or serialized JavaScript errors.
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.
## Opting-out
You can disable Nuxt Telemetry for your project with several ways:
1. Setting `telemetry: false` in your `nuxt.config`:
```js
export default {
telemetry: false
}
```
2. Using an environment variable:
```bash
NUXT_TELEMETRY_DISABLED=1
```
3. Using `npx nuxt telemetry disable`
```bash
npx nuxt telemetry [status|enable|disable] [-g,--global] [dir]
```
## Skip Prompt
If you encounter problems with consent prompt, and want to participate without asking this question, you can set `telemetry: true` from `nuxt.config`:
```js
export default {
telemetry: true
}
```
## Thank you
We want to thank you for participating in this telemetry program to help us better understand how you use Nuxt to keep improving it 💚
## Development
- Run `yarn dev:prepare` to generate type stubs.
- Use `yarn dev` to start [playground](./playground) in development mode.
## License
[MIT License](./LICENSE)

3
node_modules/@nuxt/telemetry/bin/nuxt-telemetry.mjs generated vendored Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env node
process._startTime = Date.now()
import('../dist/cli.mjs').then(r => (r.default || r).main())

4
node_modules/@nuxt/telemetry/dist/cli.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
declare const usage = "npx nuxt-telemetry `status`|`enable`|`disable`|`consent` [`-g`,`--global`] [`dir`]";
declare function main(): void;
export { main, usage };

123
node_modules/@nuxt/telemetry/dist/cli.mjs generated vendored Normal file
View File

@@ -0,0 +1,123 @@
import { resolve } from 'path';
import { existsSync, readFileSync } from 'fs';
import { homedir } from 'os';
import destr from 'destr';
import mri from 'mri';
import * as rc from 'rc9';
import c from 'chalk';
import consola from 'consola';
import jiti from 'jiti';
import { isTest } from 'std-env';
import { parse } from 'dotenv';
import { e as ensureUserconsent, c as consentVersion } from './shared/telemetry.5a54e3dd.mjs';
import 'inquirer';
import 'is-docker';
const usage = "npx nuxt-telemetry `status`|`enable`|`disable`|`consent` [`-g`,`--global`] [`dir`]";
const RC_FILENAME = ".nuxtrc";
function _run() {
const _argv = process.argv.slice(2);
const args = mri(_argv, {
boolean: [
"--global"
],
alias: {
"-g": "--global"
}
});
const [command, _dir = "."] = args._;
const dir = resolve(process.cwd(), _dir);
const global = args["--global"];
if (!global && !existsSync(resolve(dir, "nuxt.config.js")) && !existsSync(resolve(dir, "nuxt.config.ts"))) {
consola.error("It seems you are not in a nuxt project!");
consola.info("You can try with providing dir or using `-g`");
showUsage();
}
switch (command) {
case "enable":
setRC("telemetry.enabled", true);
setRC("telemetry.consent", consentVersion);
showStatus();
consola.info("You can disable telemetry with `npx nuxt telemetry disable " + (global ? "-g" : _dir));
return;
case "disable":
setRC("telemetry.enabled", false);
setRC("telemetry.consent", 0);
showStatus();
consola.info("You can enable telemetry with `npx nuxt telemetry enable " + (global ? "-g" : _dir) + "`");
return;
case "status":
return showStatus();
case "consent":
return _prompt();
default:
showUsage();
}
async function _prompt() {
const accepted = await ensureUserconsent({});
if (accepted && !global) {
setRC("telemetry.enabled", true);
setRC("telemetry.consent", consentVersion);
}
showStatus();
}
function _checkDisabled() {
if (isTest) {
return "Because running in test environment";
}
if (destr(process.env.NUXT_TELEMETRY_DISABLED)) {
return "by `NUXT_TELEMETRY_DISABLED` environment variable";
}
const dotenvFile = resolve(dir, ".env");
if (existsSync(dotenvFile)) {
const _env = parse(readFileSync(dotenvFile));
if (destr(_env.NUXT_TELEMETRY_DISABLED)) {
return "by `NUXT_TELEMETRY_DISABLED` from " + dotenvFile;
}
}
const disabledByConf = (conf) => conf.telemetry === false || conf.telemetry && conf.telemetry.enabled === false;
try {
const _require = jiti(dir);
if (disabledByConf(_require("./nuxt.config"))) {
return "by " + _require.resolve("./nuxt.config");
}
} catch (_) {
}
if (disabledByConf(rc.read({ name: RC_FILENAME, dir }))) {
return "by " + resolve(dir, RC_FILENAME);
}
if (disabledByConf(rc.readUser({ name: RC_FILENAME }))) {
return "by " + resolve(homedir(), RC_FILENAME);
}
}
function showStatus() {
const disabled = _checkDisabled();
if (disabled) {
consola.info(`Nuxt telemetry is ${c.yellow("disabled")} ${disabled}`);
} else {
consola.info(`Nuxt telemetry is ${c.green("enabled")}`, global ? "on machine" : "on current project");
}
}
function showUsage() {
consola.info(`Usage: ${usage}`);
process.exit(0);
}
function setRC(key, val) {
const update = { [key]: val };
if (global) {
rc.updateUser(update, RC_FILENAME);
} else {
rc.update(update, { name: RC_FILENAME, dir });
}
}
}
function main() {
try {
_run();
} catch (err) {
consola.fatal(err);
process.exit(1);
}
}
export { main, usage };

5
node_modules/@nuxt/telemetry/dist/module.cjs generated vendored Normal file
View File

@@ -0,0 +1,5 @@
module.exports = function(...args) {
return import('./module.mjs').then(m => m.default.call(this, ...args))
}
const _meta = module.exports.meta = require('./module.json')
module.exports.getMeta = () => Promise.resolve(_meta)

14
node_modules/@nuxt/telemetry/dist/module.d.ts generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import * as _nuxt_schema from '@nuxt/schema';
interface TelemetryOptions {
debug: boolean
endpoint: string
seed: string
consent?: number
enabled: boolean
}
type ModuleOptions = boolean | TelemetryOptions;
declare const _default: _nuxt_schema.NuxtModule<TelemetryOptions>;
export { ModuleOptions, _default as default };

5
node_modules/@nuxt/telemetry/dist/module.json generated vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"name": "@nuxt/telemetry",
"configKey": "telemetry",
"version": "2.1.8"
}

407
node_modules/@nuxt/telemetry/dist/module.mjs generated vendored Normal file
View File

@@ -0,0 +1,407 @@
import destr from 'destr';
import { nanoid } from 'nanoid';
import { getNuxtVersion, isNuxt3, useLogger, defineNuxtModule } from '@nuxt/kit';
import { e as ensureUserconsent, u as updateUserNuxtRc } from './shared/telemetry.5a54e3dd.mjs';
import { fetch } from 'ohmyfetch';
import path, { join } from 'path';
import { existsSync } from 'fs';
import createRequire from 'create-require';
import os from 'os';
import gitUrlParse from 'git-url-parse';
import parseGitConfig from 'parse-git-config';
import isDocker from 'is-docker';
import { provider } from 'std-env';
import fs from 'fs-extra';
import { createHash } from 'crypto';
import 'chalk';
import 'inquirer';
import 'consola';
import 'rc9';
const version = "2.1.8";
async function postEvent(endpoint, body) {
const res = await fetch(endpoint, {
method: "POST",
body: JSON.stringify(body),
headers: {
"content-type": "application/json",
"user-agent": "Nuxt Telemetry " + version
}
});
if (!res.ok) {
throw new Error(res.statusText);
}
}
const build = function({ nuxt }, payload) {
const duration = { build: payload.duration.build };
let isSuccess = true;
for (const [name, stat] of Object.entries(payload.stats)) {
duration[name] = stat.duration;
if (!stat.success) {
isSuccess = false;
}
}
return {
name: "build",
isSuccess,
isDev: nuxt.options.dev || false,
duration
};
};
const command = function({ nuxt }) {
let command2 = process.argv[2] || "unknown";
const flagMap = {
dev: "dev",
_generate: "generate",
_export: "export",
_build: "build",
_serve: "serve",
_start: "start"
};
for (const flag in flagMap) {
if (nuxt.options[flag]) {
command2 = flagMap[flag];
break;
}
}
return {
name: "command",
command: command2
};
};
const generate = function generate2({ nuxt }, payload) {
return {
name: "generate",
isExport: !!nuxt.options._export,
routesCount: payload.routesCount,
duration: {
generate: payload.duration.generate
}
};
};
const dependency = function({ nuxt: { options } }) {
const events = [];
const projectDeps = getDependencies(options.rootDir);
const modules = normalizeModules(options.modules);
const buildModules = normalizeModules(options.buildModules);
const relatedDeps = [...modules, ...buildModules];
for (const dep of projectDeps) {
if (!relatedDeps.includes(dep.name)) {
continue;
}
events.push({
name: "dependency",
packageName: dep.name,
version: dep.version,
isDevDependency: dep.dev,
isModule: modules.includes(dep.name),
isBuildModule: buildModules.includes(dep.name)
});
}
return events;
};
function normalizeModules(modules) {
return modules.map((m) => {
if (typeof m === "string") {
return m;
}
if (Array.isArray(m) && typeof m[0] === "string") {
return m[0];
}
return null;
}).filter(Boolean);
}
function getDependencies(rootDir) {
const pkgPath = join(rootDir, "package.json");
if (!existsSync(pkgPath)) {
return [];
}
const _require = createRequire(rootDir);
const pkg = _require(pkgPath);
const mapDeps = (depsObj, dev = false) => {
const _deps = [];
for (const name in depsObj) {
try {
const pkg2 = _require(join(name, "package.json"));
_deps.push({ name, version: pkg2.version, dev });
} catch (_e) {
_deps.push({ name, version: depsObj[name], dev });
}
}
return _deps;
};
const deps = [];
if (pkg.dependencies) {
deps.push(...mapDeps(pkg.dependencies));
}
if (pkg.devDependencies) {
deps.push(...mapDeps(pkg.devDependencies, true));
}
return deps;
}
const project = function(context) {
const { options } = context.nuxt;
return {
name: "project",
type: context.git && context.git.url ? "git" : "local",
isSSR: options.mode === "universal" || options.ssr === true,
target: options._generate ? "static" : "server",
packageManager: context.packageManager
};
};
const session = function({ seed }) {
return {
name: "session",
id: seed
};
};
const events = {
__proto__: null,
build: build,
command: command,
generate: generate,
dependency: dependency,
getDependencies: getDependencies,
project: project,
session: session
};
const FILE2PM = {
"yarn.lock": "yarn",
"package-lock.json": "npm",
"shrinkwrap.json": "npm",
"pnpm-lock.yaml": "pnpm"
};
async function detectPackageManager(rootDir) {
for (const file in FILE2PM) {
if (await fs.pathExists(path.resolve(rootDir, file))) {
return FILE2PM[file];
}
}
return "unknown";
}
function hash(str) {
return createHash("sha256").update(str).digest("hex").substr(0, 16);
}
async function createContext(nuxt, options) {
const rootDir = nuxt.options.rootDir || process.cwd();
const git = await getGit(rootDir);
const packageManager = await detectPackageManager(rootDir);
const { seed } = options;
const projectHash = await getProjectHash(rootDir, git, seed);
const projectSession = getProjectSession(projectHash, seed);
const nuxtVersion = getNuxtVersion(nuxt);
const nuxtMajorVersion = isNuxt3(nuxt) ? 3 : 2;
const nodeVersion = process.version.replace("v", "");
const isEdge = nuxtVersion.includes("edge");
return {
nuxt,
seed,
git,
projectHash,
projectSession,
nuxtVersion,
nuxtMajorVersion,
isEdge,
cli: getCLI(),
nodeVersion,
os: os.type().toLocaleLowerCase(),
environment: getEnv(),
packageManager,
concent: options.consent
};
}
function getEnv() {
if (provider) {
return provider;
}
if (isDocker()) {
return "Docker";
}
return "unknown";
}
function getCLI() {
const entry = process.argv[1];
const knownCLIs = {
"nuxt-ts.js": "nuxt-ts",
"nuxt-start.js": "nuxt-start",
"nuxt.js": "nuxt",
nuxi: "nuxi"
};
for (const key in knownCLIs) {
if (entry.includes(key)) {
const edge = entry.includes("-edge") ? "-edge" : "";
return knownCLIs[key] + edge;
}
}
return "programmatic";
}
function getProjectSession(projectHash, sessionId) {
return hash(`${projectHash}#${sessionId}`);
}
function getProjectHash(rootDir, git, seed) {
let id;
if (git && git.url) {
id = `${git.source}#${git.owner}#${git.name}`;
} else {
id = `${rootDir}#${seed}`;
}
return hash(id);
}
async function getGitRemote(rootDir) {
try {
const parsed = await parseGitConfig({ cwd: rootDir });
if (parsed) {
const gitRemote = parsed['remote "origin"'].url;
return gitRemote;
}
return null;
} catch (err) {
return null;
}
}
async function getGit(rootDir) {
const gitRemote = await getGitRemote(rootDir);
if (!gitRemote) {
return;
}
const meta = gitUrlParse(gitRemote);
const url = meta.toString("https");
return {
url,
gitRemote,
source: meta.source,
owner: meta.owner,
name: meta.name
};
}
const log = useLogger("@nuxt/telemetry");
class Telemetry {
constructor(nuxt, options) {
this.events = [];
this.nuxt = nuxt;
this.options = options;
}
getContext() {
if (!this._contextPromise) {
this._contextPromise = createContext(this.nuxt, this.options);
}
return this._contextPromise;
}
createEvent(name, payload) {
const eventFactory = events[name];
if (typeof eventFactory !== "function") {
log.warn("Unknown event:", name);
return;
}
const eventPromise = this._invokeEvent(name, eventFactory, payload);
this.events.push(eventPromise);
}
async _invokeEvent(name, eventFactory, payload) {
try {
const context = await this.getContext();
const event = await eventFactory(context, payload);
event.name = name;
return event;
} catch (err) {
log.error("Error while running event:", err);
}
}
async getPublicContext() {
const context = await this.getContext();
const eventContext = {};
for (const key of [
"nuxtVersion",
"nuxtMajorVersion",
"isEdge",
"nodeVersion",
"cli",
"os",
"environment",
"projectHash",
"projectSession"
]) {
eventContext[key] = context[key];
}
return eventContext;
}
async sendEvents(debug) {
const events2 = [].concat(...(await Promise.all(this.events)).filter(Boolean));
this.events = [];
const context = await this.getPublicContext();
const body = {
timestamp: Date.now(),
context,
events: events2
};
if (this.options.endpoint) {
const start = Date.now();
try {
if (debug) {
log.info("Sending events:", JSON.stringify(body, null, 2));
}
await postEvent(this.options.endpoint, body);
if (debug) {
log.success(`Events sent to \`${this.options.endpoint}\` (${Date.now() - start} ms)`);
}
} catch (err) {
if (debug) {
log.error(`Error sending sent to \`${this.options.endpoint}\` (${Date.now() - start} ms)
`, err);
}
}
}
}
}
const module = defineNuxtModule({
meta: {
name: "@nuxt/telemetry",
configKey: "telemetry"
},
defaults: {
endpoint: process.env.NUXT_TELEMETRY_ENDPOINT || "https://telemetry.nuxtjs.com",
debug: destr(process.env.NUXT_TELEMETRY_DEBUG),
enabled: void 0,
seed: void 0
},
async setup(toptions, nuxt) {
if (!toptions.debug) {
log.level = 0;
}
const _topLevelTelemetry = nuxt.options.telemetry;
if (_topLevelTelemetry !== true) {
if (toptions.enabled === false || _topLevelTelemetry === false || !await ensureUserconsent(toptions)) {
log.info("Telemetry disabled");
return;
}
}
log.info("Telemetry enabled");
if (!toptions.seed) {
toptions.seed = hash(nanoid());
updateUserNuxtRc("telemetry.seed", toptions.seed);
log.info("Seed generated:", toptions.seed);
}
const t = new Telemetry(nuxt, toptions);
nuxt.hook("modules:done", () => {
t.createEvent("project");
t.createEvent("session");
t.createEvent("command");
t.sendEvents(toptions.debug);
});
}
});
export { module as default };

View File

@@ -0,0 +1,41 @@
import c from 'chalk';
import inquirer from 'inquirer';
import consola from 'consola';
import { isMinimal } from 'std-env';
import isDocker from 'is-docker';
import { updateUser } from 'rc9';
const consentVersion = 1;
function updateUserNuxtRc(key, val) {
updateUser({ [key]: val }, ".nuxtrc");
}
async function ensureUserconsent(options) {
if (options.consent >= consentVersion) {
return true;
}
if (isMinimal || process.env.CODESANDBOX_SSE || process.env.NEXT_TELEMETRY_DISABLED || isDocker()) {
return false;
}
process.stdout.write("\n");
consola.info(`${c.green("Nuxt")} collects completely anonymous data about usage.
This will help us improve Nuxt developer experience over time.
Read more on ${c.cyan.underline("https://github.com/nuxt/telemetry")}
`);
const { accept } = await inquirer.prompt({
type: "confirm",
name: "accept",
message: "Are you interested in participating?"
});
process.stdout.write("\n");
if (accept) {
updateUserNuxtRc("telemetry.consent", consentVersion);
updateUserNuxtRc("telemetry.enabled", true);
return true;
}
updateUserNuxtRc("telemetry.enabled", false);
return false;
}
export { consentVersion as c, ensureUserconsent as e, updateUserNuxtRc as u };

10
node_modules/@nuxt/telemetry/dist/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
import { ModuleOptions } from './module'
declare module '@nuxt/schema' {
interface NuxtConfig { ['telemetry']?: Partial<ModuleOptions> }
interface NuxtOptions { ['telemetry']?: ModuleOptions }
}
export { ModuleOptions, default } from './module'

63
node_modules/@nuxt/telemetry/package.json generated vendored Normal file
View File

@@ -0,0 +1,63 @@
{
"name": "@nuxt/telemetry",
"version": "2.1.8",
"repository": "nuxt/telemetry",
"license": "MIT",
"type": "module",
"exports": {
".": {
"import": "./dist/module.mjs",
"require": "./dist/module.cjs"
}
},
"main": "./dist/module.cjs",
"types": "./dist/types.d.ts",
"bin": {
"nuxt-telemetry": "./bin/nuxt-telemetry.mjs"
},
"files": [
"dist",
"bin"
],
"scripts": {
"build": "nuxt-module-build",
"dev": "NUXT_TELEMETRY_DEBUG=1 nuxi dev playground",
"dev:build": "NUXT_TELEMETRY_DEBUG=1 nuxi build playground",
"dev:generate": "NUXT_TELEMETRY_DEBUG=1 nuxi build playground",
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
"lint": "eslint --ext .ts,.js,.vue .",
"nuxt-telemetry": "jiti ./src/cli.ts",
"prepack": "nuxt-module-build",
"release": "yarn test && yarn build && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint"
},
"dependencies": {
"@nuxt/kit": "^3.0.0-rc.14",
"chalk": "^5.1.2",
"ci-info": "^3.6.1",
"consola": "^2.15.3",
"create-require": "^1.1.1",
"defu": "^6.1.1",
"destr": "^1.2.1",
"dotenv": "^16.0.3",
"fs-extra": "^10.1.0",
"git-url-parse": "^13.1.0",
"inquirer": "^9.1.4",
"is-docker": "^3.0.0",
"jiti": "^1.16.0",
"mri": "^1.2.0",
"nanoid": "^4.0.0",
"node-fetch": "^3.3.0",
"ohmyfetch": "^0.4.21",
"parse-git-config": "^3.0.0",
"rc9": "^2.0.0",
"std-env": "^3.3.1"
},
"devDependencies": {
"@nuxt/module-builder": "^0.2.1",
"@nuxtjs/eslint-config-typescript": "^11.0.0",
"eslint": "^8.27.0",
"nuxt": "^3.0.0-rc.14",
"standard-version": "^9.3.2"
}
}