Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

print-project

Package Overview
Dependencies
Maintainers
0
Versions
33
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.15 to 1.0.16

39

dist/index.js

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

const program = new commander_1.Command();
program.argument("<startPath>", "Starting directory path").option("--ignore <patterns>", "Comma-separated list of patterns to ignore").option("--include <patterns>", "Comma-separated list of patterns to include").option("--ignore-default", "Disable default ignore patterns").parse(process.argv);
program
.argument("<startPath>", "Starting directory path")
.option("--ignore <patterns>", "Comma-separated list of patterns to ignore")
.option("--include <patterns>", "Comma-separated list of patterns to include")
.option("--ignore-default", "Disable default ignore patterns")
.parse(process.argv);
const startPath = program.args[0] && path.resolve(program.args[0]);

@@ -41,9 +46,29 @@ const options = program.opts();

const includePatterns = options.include ? options.include.split(",").filter(Boolean).map((pattern) => pattern.trim()) : [];
const useDefaultIgnore = !options.ignoreDefault;
let ignorePatterns = useDefaultIgnore ? [...constants_1.defaultIgnorePatterns, ...userIgnorePatterns] : userIgnorePatterns;
ignorePatterns.push("project-print.txt");
// Build the final ignore patterns list
let ignorePatterns = [];
// Always include project-print.txt in ignore patterns
const alwaysIgnore = ["project-print.txt"];
// If user specified --ignore-default, don't use default patterns
if (!options.ignoreDefault) {
ignorePatterns = [...constants_1.defaultIgnorePatterns];
}
// Add user's ignore patterns
ignorePatterns = [...ignorePatterns, ...userIgnorePatterns, ...alwaysIgnore];
// Remove any patterns that match the include patterns
if (includePatterns.length > 0) {
ignorePatterns = ignorePatterns.filter(ignorePattern => {
return !includePatterns.some(includePattern => {
// If the ignore pattern matches any include pattern, remove it from ignores
const ignoreRegex = new RegExp(ignorePattern.replace(/\*/g, '.*'), 'i');
return ignoreRegex.test(includePattern);
});
});
}
function matchesPattern(filePath, patterns) {
return patterns.some(pattern => {
const regexPattern = pattern.split("*").map(s => s.replace(/[|\\{}()[\]^$+?.]/g, "\\$&")).join(".*");
const regex = new RegExp(regexPattern, "i");
const regexPattern = pattern
.split('*')
.map(s => s.replace(/[|\\{}()[\]^$+?.]/g, '\\$&'))
.join('.*');
const regex = new RegExp(regexPattern, 'i');
console.log(`Checking ${filePath} against pattern: ${pattern} (regex: ${regex})`);

@@ -67,3 +92,2 @@ const matches = regex.test(filePath);

console.log(`Include pattern match: ${isIncluded}`);
// Include this file if it matches include patterns
return isIncluded;

@@ -125,3 +149,2 @@ }

console.log(`Including: ${includePatterns.length > 0 ? includePatterns.join(", ") : "All files (except ignored)"}`);
console.log(`Using default ignore: ${useDefaultIgnore}`);
readDirectory(startPath, ignorePatterns, includePatterns, treeStructure);

@@ -128,0 +151,0 @@ console.log("\nProcessed file structure:\n");

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

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

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

const program = new Command();
program.argument("<startPath>", "Starting directory path").option("--ignore <patterns>", "Comma-separated list of patterns to ignore").option("--include <patterns>", "Comma-separated list of patterns to include").option("--ignore-default", "Disable default ignore patterns").parse(process.argv);
program
.argument("<startPath>", "Starting directory path")
.option("--ignore <patterns>", "Comma-separated list of patterns to ignore")
.option("--include <patterns>", "Comma-separated list of patterns to include")
.option("--ignore-default", "Disable default ignore patterns")
.parse(process.argv);

@@ -19,12 +24,36 @@ const startPath: string | undefined = program.args[0] && path.resolve(program.args[0]);

const includePatterns: string[] = options.include ? options.include.split(",").filter(Boolean).map((pattern: string) => pattern.trim()) : [];
const useDefaultIgnore: boolean = !options.ignoreDefault;
let ignorePatterns: string[] = useDefaultIgnore ? [...defaultIgnorePatterns, ...userIgnorePatterns] : userIgnorePatterns;
ignorePatterns.push("project-print.txt");
// Build the final ignore patterns list
let ignorePatterns: string[] = [];
// Always include project-print.txt in ignore patterns
const alwaysIgnore = ["project-print.txt"];
// If user specified --ignore-default, don't use default patterns
if (!options.ignoreDefault) {
ignorePatterns = [...defaultIgnorePatterns];
}
// Add user's ignore patterns
ignorePatterns = [...ignorePatterns, ...userIgnorePatterns, ...alwaysIgnore];
// Remove any patterns that match the include patterns
if (includePatterns.length > 0) {
ignorePatterns = ignorePatterns.filter(ignorePattern => {
return !includePatterns.some(includePattern => {
// If the ignore pattern matches any include pattern, remove it from ignores
const ignoreRegex = new RegExp(ignorePattern.replace(/\*/g, '.*'), 'i');
return ignoreRegex.test(includePattern);
});
});
}
function matchesPattern(filePath: string, patterns: string[]): boolean {
return patterns.some(pattern => {
const regexPattern = pattern.split("*").map(s => s.replace(/[|\\{}()[\]^$+?.]/g, "\\$&")).join(".*");
const regexPattern = pattern
.split('*')
.map(s => s.replace(/[|\\{}()[\]^$+?.]/g, '\\$&'))
.join('.*');
const regex = new RegExp(regexPattern, "i");
const regex = new RegExp(regexPattern, 'i');
console.log(`Checking ${filePath} against pattern: ${pattern} (regex: ${regex})`);

@@ -51,3 +80,2 @@ const matches = regex.test(filePath);

console.log(`Include pattern match: ${isIncluded}`);
// Include this file if it matches include patterns
return isIncluded;

@@ -119,3 +147,2 @@ }

console.log(`Including: ${includePatterns.length > 0 ? includePatterns.join(", ") : "All files (except ignored)"}`);
console.log(`Using default ignore: ${useDefaultIgnore}`);

@@ -122,0 +149,0 @@ readDirectory(startPath, ignorePatterns, includePatterns, treeStructure);

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