New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

print-project

Package Overview
Dependencies
Maintainers
0
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

print-project - npm Package Compare versions

Comparing version 1.0.13 to 1.0.14

48

dist/index.js

@@ -39,3 +39,3 @@ #!/usr/bin/env node

.option("--include <patterns>", "Comma-separated list of patterns to include")
.option("--ignore-default", "Disable default ignore patterns") // Changed description to be clearer
.option("--ignore-default", "Disable default ignore patterns")
.parse(process.argv);

@@ -46,3 +46,3 @@ const startPath = program.args[0] && path.resolve(program.args[0]);

const includePatterns = options.include ? options.include.split(",").filter(Boolean).map((pattern) => pattern.trim()) : [];
const useDefaultIgnore = !options.ignoreDefault; // FIXED: Inverted the logic here
const useDefaultIgnore = !options.ignoreDefault;
let ignorePatterns = useDefaultIgnore ? [...constants_1.defaultIgnorePatterns, ...userIgnorePatterns] : userIgnorePatterns;

@@ -52,3 +52,2 @@ ignorePatterns.push("project-print.txt");

return patterns.some(pattern => {
// Convert glob pattern to regex
const regexPattern = pattern

@@ -67,3 +66,9 @@ .split('*')

console.log(`\nChecking file: ${filePath}`);
// If we have include patterns, only include files that match them
// First check if file matches ignore patterns
const isIgnored = matchesPattern(filePath, ignorePatterns);
if (isIgnored) {
console.log(`File is ignored: ${filePath}`);
return false;
}
// If we have include patterns, check if file matches them
if (includePatterns.length > 0) {

@@ -74,6 +79,4 @@ const isIncluded = matchesPattern(filePath, includePatterns);

}
// Otherwise, include files that don't match ignore patterns
const isIgnored = matchesPattern(filePath, ignorePatterns);
console.log(`Ignore pattern match: ${isIgnored}`);
return !isIgnored;
// If no include patterns, include all non-ignored files
return true;
}

@@ -87,21 +90,22 @@ function readDirectory(dirPath, ignorePatterns, includePatterns, treeStructure = {}, currentPath = "") {

console.log(`\nProcessing: ${fullPath}`);
const include = shouldIncludeFile(fullPath, ignorePatterns, includePatterns);
console.log(`Should include ${fullPath}: ${include}`);
if (!include) {
console.log(`Skipping ${fullPath}`);
return;
}
const relativePath = path.join(currentPath, dirent.name).replace(/\\/g, "/");
// For directories, we always recurse unless they're explicitly ignored
if (dirent.isDirectory()) {
console.log(`${fullPath} is a directory`);
treeStructure[relativePath] = {};
readDirectory(path.join(dirPath, dirent.name), ignorePatterns, includePatterns, treeStructure[relativePath], relativePath);
if (!matchesPattern(fullPath, ignorePatterns)) {
treeStructure[fullPath] = {};
readDirectory(path.join(dirPath, dirent.name), ignorePatterns, includePatterns, treeStructure[fullPath], fullPath);
}
else {
console.log(`Skipping ignored directory: ${fullPath}`);
}
}
else if (dirent.isFile()) {
console.log(`${fullPath} is a file`);
treeStructure[relativePath] = {};
const content = fs.readFileSync(path.join(dirPath, dirent.name), "utf8");
if (content.length > 0) {
projectPrint += `${fullPath}:\n${content}\n\n`;
console.log(`Added ${fullPath} to project print`);
if (shouldIncludeFile(fullPath, ignorePatterns, includePatterns)) {
treeStructure[fullPath] = {};
const content = fs.readFileSync(path.join(dirPath, dirent.name), "utf8");
if (content.length > 0) {
projectPrint += `${fullPath}:\n${content}\n\n`;
console.log(`Added ${fullPath} to project print`);
}
}

@@ -108,0 +112,0 @@ }

{
"name": "print-project",
"version": "1.0.13",
"version": "1.0.14",
"description": "A simple CLI tool to print the project tree structure and file contents",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -16,3 +16,3 @@ #!/usr/bin/env node

.option("--include <patterns>", "Comma-separated list of patterns to include")
.option("--ignore-default", "Disable default ignore patterns") // Changed description to be clearer
.option("--ignore-default", "Disable default ignore patterns")
.parse(process.argv);

@@ -24,3 +24,3 @@

const includePatterns: string[] = options.include ? options.include.split(",").filter(Boolean).map((pattern: string) => pattern.trim()) : [];
const useDefaultIgnore: boolean = !options.ignoreDefault; // FIXED: Inverted the logic here
const useDefaultIgnore: boolean = !options.ignoreDefault;

@@ -32,3 +32,2 @@ let ignorePatterns: string[] = useDefaultIgnore ? [...defaultIgnorePatterns, ...userIgnorePatterns] : userIgnorePatterns;

return patterns.some(pattern => {
// Convert glob pattern to regex
const regexPattern = pattern

@@ -50,3 +49,10 @@ .split('*')

// If we have include patterns, only include files that match them
// First check if file matches ignore patterns
const isIgnored = matchesPattern(filePath, ignorePatterns);
if (isIgnored) {
console.log(`File is ignored: ${filePath}`);
return false;
}
// If we have include patterns, check if file matches them
if (includePatterns.length > 0) {

@@ -58,6 +64,4 @@ const isIncluded = matchesPattern(filePath, includePatterns);

// Otherwise, include files that don't match ignore patterns
const isIgnored = matchesPattern(filePath, ignorePatterns);
console.log(`Ignore pattern match: ${isIgnored}`);
return !isIgnored;
// If no include patterns, include all non-ignored files
return true;
}

@@ -74,22 +78,26 @@

const include = shouldIncludeFile(fullPath, ignorePatterns, includePatterns);
console.log(`Should include ${fullPath}: ${include}`);
if (!include) {
console.log(`Skipping ${fullPath}`);
return;
}
const relativePath = path.join(currentPath, dirent.name).replace(/\\/g, "/");
// For directories, we always recurse unless they're explicitly ignored
if (dirent.isDirectory()) {
console.log(`${fullPath} is a directory`);
treeStructure[relativePath] = {};
readDirectory(path.join(dirPath, dirent.name), ignorePatterns, includePatterns, treeStructure[relativePath], relativePath);
if (!matchesPattern(fullPath, ignorePatterns)) {
treeStructure[fullPath] = {};
readDirectory(
path.join(dirPath, dirent.name),
ignorePatterns,
includePatterns,
treeStructure[fullPath],
fullPath
);
} else {
console.log(`Skipping ignored directory: ${fullPath}`);
}
} else if (dirent.isFile()) {
console.log(`${fullPath} is a file`);
treeStructure[relativePath] = {};
const content = fs.readFileSync(path.join(dirPath, dirent.name), "utf8");
if (content.length > 0) {
projectPrint += `${fullPath}:\n${content}\n\n`;
console.log(`Added ${fullPath} to project print`);
if (shouldIncludeFile(fullPath, ignorePatterns, includePatterns)) {
treeStructure[fullPath] = {};
const content = fs.readFileSync(path.join(dirPath, dirent.name), "utf8");
if (content.length > 0) {
projectPrint += `${fullPath}:\n${content}\n\n`;
console.log(`Added ${fullPath} to project print`);
}
}

@@ -96,0 +104,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc