Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.
This commit is contained in:
55
node_modules/@astrojs/telemetry/dist/project-info.js
generated
vendored
Normal file
55
node_modules/@astrojs/telemetry/dist/project-info.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
import { execSync } from "node:child_process";
|
||||
import { createHash } from "node:crypto";
|
||||
import detectPackageManager from "which-pm-runs";
|
||||
function createAnonymousValue(payload) {
|
||||
if (payload === "") {
|
||||
return payload;
|
||||
}
|
||||
const hash = createHash("sha256");
|
||||
hash.update(payload);
|
||||
return hash.digest("hex");
|
||||
}
|
||||
function getProjectIdFromGit() {
|
||||
try {
|
||||
const originBuffer = execSync(`git rev-list --max-parents=0 HEAD`, {
|
||||
timeout: 500,
|
||||
stdio: ["ignore", "pipe", "ignore"]
|
||||
});
|
||||
return String(originBuffer).trim();
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function getProjectId(isCI) {
|
||||
const projectIdFromGit = getProjectIdFromGit();
|
||||
if (projectIdFromGit) {
|
||||
return {
|
||||
isGit: true,
|
||||
anonymousProjectId: createAnonymousValue(projectIdFromGit)
|
||||
};
|
||||
}
|
||||
const cwd = process.cwd();
|
||||
const isCwdGeneric = (cwd.match(/[/|\\]/g) || []).length === 1;
|
||||
if (isCI || isCwdGeneric) {
|
||||
return {
|
||||
isGit: false,
|
||||
anonymousProjectId: void 0
|
||||
};
|
||||
}
|
||||
return {
|
||||
isGit: false,
|
||||
anonymousProjectId: createAnonymousValue(cwd)
|
||||
};
|
||||
}
|
||||
function getProjectInfo(isCI) {
|
||||
const projectId = getProjectId(isCI);
|
||||
const packageManager = detectPackageManager();
|
||||
return {
|
||||
...projectId,
|
||||
packageManager: packageManager?.name,
|
||||
packageManagerVersion: packageManager?.version
|
||||
};
|
||||
}
|
||||
export {
|
||||
getProjectInfo
|
||||
};
|
Reference in New Issue
Block a user