qleaner 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js CHANGED
@@ -15,7 +15,8 @@ program
15
15
  .argument("<path>", "The path to the directory to scan for imports")
16
16
  .option("-l, --list-files", "List all the files in the project")
17
17
  .option("-i, --list-imports", "List all the imports in the project")
18
- .option("-e, --exclude-dir <dir>", "Exclude directories from the scan")
18
+ .option("-e, --exclude-dir <dir...>", "Exclude directories from the scan")
19
+ .option("-f, --exclude-file <file...>", "Exclude files from the scan")
19
20
  .action(async (path, options) => {
20
21
  const imports = await getFiles(path, options);
21
22
  });
@@ -23,10 +24,11 @@ program
23
24
  program.command("qlean-scan")
24
25
  .description("Scan the project for unused files")
25
26
  .argument("<path>", "The path to the directory to scan for unused files")
26
- .option("-e, --exclude-dir <dir>", "Exclude directories from the scan")
27
+ .option("-e, --exclude-dir <dir...>", "Exclude directories from the scan")
28
+ .option("-f, --exclude-file <file...>", "Exclude files from the scan")
27
29
  .action(async (path, options) => {
28
30
  const unusedFiles = await unUsedFiles(path, options);
29
- console.clear()
31
+ // console.clear()
30
32
  unusedFiles.forEach((file) => {
31
33
  console.log(file);
32
34
  });
package/command.js CHANGED
@@ -7,8 +7,15 @@ const traverse = require("@babel/traverse").default;
7
7
 
8
8
  async function getFiles(directory = "src", options) {
9
9
  const contentPaths = [`${directory}/**/*.{tsx,ts,js,jsx}`];
10
- if (options.excludeDir) {
11
- contentPaths.push(`!${options.excludeDir}/**`);
10
+ if (options.excludeDir && options.excludeDir.length > 0) {
11
+ options.excludeDir.forEach(dir => {
12
+ contentPaths.push(`!${dir}/**`);
13
+ });
14
+ }
15
+ if (options.excludeFile && options.excludeFile.length > 0) {
16
+ options.excludeFile.forEach(file => {
17
+ contentPaths.push(`!${directory}/**/${file}`);
18
+ });
12
19
  }
13
20
  const files = await fg(contentPaths);
14
21
  const imports = [];
@@ -59,8 +66,15 @@ async function getFiles(directory = "src", options) {
59
66
 
60
67
  async function unUsedFiles(directory = "src", options) {
61
68
  const contentPaths = [`${directory}/**/*.{tsx,ts,js,jsx}`];
62
- if (options.excludeDir) {
63
- contentPaths.push(`!${options.excludeDir}/**`);
69
+ if (options.excludeDir && options.excludeDir.length > 0) {
70
+ options.excludeDir.forEach(dir => {
71
+ contentPaths.push(`!${dir}/**`);
72
+ });
73
+ }
74
+ if (options.excludeFile && options.excludeFile.length > 0) {
75
+ options.excludeFile.forEach(file => {
76
+ contentPaths.push(`!${directory}/**/${file}`);
77
+ });
64
78
  }
65
79
  const files = await fg(contentPaths);
66
80
  const imports = [];
@@ -96,11 +110,9 @@ async function unUsedFiles(directory = "src", options) {
96
110
  while (!isFound && i < imports.length) {
97
111
 
98
112
  if (compareFiles(file, imports[i].from)) {
99
- console.log('Found', file, imports[i].from);
100
113
  isFound = true;
101
114
  break;
102
115
  }else if(i === imports.length - 1) {
103
- console.log('Not Found', file, imports[i].from);
104
116
  unusedFiles.push(file);
105
117
  break;
106
118
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qleaner",
3
3
  "packageManager": "yarn@4.6.0",
4
- "version": "1.0.7",
4
+ "version": "1.0.8",
5
5
  "main": "command.js",
6
6
  "bin": "./bin/cli.js",
7
7
  "scripts": {
File without changes
File without changes