npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vs-utils

v1.0.3

Published

Tools and utilities for working with Visual Studio projects

Downloads

74

Readme

vs-utils

Azure Pipelines Build Status

Node-based read-only object model for parsing and reading Visual Studio projects/solutions.

Parsing Functions

parseSolution

parseSolution(file, opts);

Arguments

  • file - Can be a path, file contents, or buffer
  • opts - An options object (optional). For details see Parsing Options

Return value

A Promise which resolves to a Solution object

parseSolutionSync

parseSolutionSync(file, opts);

Arguments

  • file - Can be a path, file contents, or buffer
  • opts - An options object (optional). For details see Parsing Options

Return value

A Solution object

parseProject

parseProject(file, opts);

Arguments

  • file - Can be a path, file contents, or buffer
  • opts - An options object (optional). For details see Parsing Options

Return value

A Promise which resolves to a Project object

parseProjectSync

parseProjectSync(file, opts);

Arguments

  • file - Can be a path, file contents, or buffer
  • opts - An options object (optional). For details see Parsing Options

Return value

A Project object

Parsing Options

An options object can be passed to a parsing function to customize its behaviour.

deepParse

deepParse - Specifying true will also read and parse all dependencies. Defaults to false.

Example: A solution is dependent on its projects, while a project is dependent on its packages.

dirRoot

dirRoot - The root directory under which the solution or project lives. Defaults to undefined.

Required when doing a deep parse of a solution or project from file contents or a buffer.

Examples

For a full list of samples and demos, see the samples folder. Alternately, clone the repository and run npm run demo.

Parse solution from path and enumerate projects

const vsUtils = require('vs-utils');

const solution = await vsUtils.parseSolution('HelloWorld.sln');

solution.projects.forEach(project => {
  const projectName = project.name;
  console.log(`Project: ${project.name}\r\n`);
});

Parse solution from file contents and find test projects

const vsUtils = require('vs-utils');
const fs = require('fs');

const contents = await fs.readFile('HelloWorld.sln', { encoding: 'utf-8' });
const solution = await vsUtils.parseSolution(contents);
const testProjects = solution.projects.filter(proj => proj.determinePackageVersion('NUnit'));

Parse solution from buffer and find packages with multiple versions

const vsUtils = require('vs-utils');
const fs = require('fs');

const buffer = await fs.readFile('HelloWorld.sln');
const solution = await vsUtils.parseSolution(buffer);

const packageMap = solution.getAllPackageVersions();
const filteredPackages = Array.from(packageMap.entries()).filter(value => value[1].length > 1);
const packages = new Map(filteredPackages);

console.log('Packages with multiple versions in solution');
console.log(packages);

Object Model

Solution

Properties

  • fileFormatVersion - string - The version of the Visual Studio file format
  • visualStudioVersion - string - The version of Visual Studio to use the solution
  • minimumVisualStudioVersion - string - The minimum version of Visual Studio to use the solution
  • projects - array - An array of Project instances

Functions

data()

Returns the underlying parsed project info

determinePackageVersions(packageName)

Returns an array of Version instances for the given package name

determineAssemblyVersions(assemblyName)

Returns an array of Version instances for the given assembly name

getProject(projectName)

Returns a Project instance by name (or undefined if not found)

getAllPackageVersions()

Returns a Map of package names mapped to an array of Version instances

getAllAssemblyVersions()

Returns a Map of assembly names mapped to an array of Version instances

Project

Properties

  • id - string - The ID of the project
  • name - string - The name of the project
  • relativePath - string - The path of the project, relative to the solution file
  • projectTypeId - string - The Type ID of the project
  • codeFiles - array - An array of strings of code files in the project
  • packages - array - An array of packages in the project
  • references - array - An array of references in the project

Functions

data()

Returns the underlying parsed project info

determinePackageVersion(packageName)

Returns the Version instance of the package in the project

determineAssemblyVersion(assemblyName)

Returns the Version instance of the assembly in the project

Version

Properties

  • major - string - The major version number
  • minor - string - The minor version number
  • patch - string - The patch version number
  • version - string - The full version string
  • originalString - string - The original version string