Socket
Socket
Sign inDemoInstall

dpdm

Package Overview
Dependencies
63
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.11.0 to 3.12.0

23

lib/bin/dpdm.js

@@ -94,2 +94,6 @@ #!/usr/bin/env node

})
.option('detect-unused-files-from', {
type: 'string',
desc: 'this file is a glob, used for finding unused files',
})
.alias('h', 'help')

@@ -178,2 +182,21 @@ .wrap(Math.min(yargs_1.default.terminalWidth(), 100)).argv;

}
if (argv.detectUnusedFilesFrom) {
const allFiles = yield (0, utils_1.glob)(argv.detectUnusedFilesFrom);
const shortAllFiles = allFiles.map((v) => path_1.default.relative(context, v));
const unusedFiles = shortAllFiles.filter((v) => !(v in tree)).sort();
console.log(chalk_1.default.bold.cyan('• Unused files'));
if (unusedFiles.length === 0) {
console.log(chalk_1.default.bold.green(' ✅ Congratulations, no unused file was found in your project. (total: ' +
allFiles.length +
', used: ' +
Object.keys(tree).length +
')'));
}
else {
const len = unusedFiles.length.toString().length;
unusedFiles.forEach((f, i) => {
console.log('%s) %s', i.toString().padStart(len, '0'), f);
});
}
}
for (const [label, code] of exitCodes) {

@@ -180,0 +203,0 @@ switch (label) {

2

package.json
{
"name": "dpdm",
"version": "3.11.0",
"version": "3.12.0",
"description": "Analyze circular dependencies in your JavaScript/TypeScript projects.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -79,2 +79,8 @@ <h1 align="center">

5. Find unused files by `index.js` in `src` directory:
```bash
dpdm --no-tree --no-warning --no-circular --detect-unused-files-from 'src/**/*.*' 'index.js'
```
### Options

@@ -84,3 +90,3 @@

$ dpdm --help
dpdm [options] <files...>
dpdm.ts [options] <files...>

@@ -90,33 +96,33 @@ Analyze the files' dependencies.

Positionals:
files The file paths or globs [string]
files The file paths or globs [string]
Options:
--version Show version number [boolean]
--context the context directory to shorten path, default is current
directory [string]
--extensions, --ext comma separated extensions to resolve
[string] [default: ".ts,.tsx,.mjs,.js,.jsx,.json"]
--js comma separated extensions indicate the file is js like
[string] [default: ".ts,.tsx,.mjs,.js,.jsx"]
--include included filenames regexp in string, default includes all files
[string] [default: ".*"]
--exclude excluded filenames regexp in string, set as empty string to
include all files [string] [default: "node_modules"]
-o, --output output json to file [string]
--tree print tree to stdout [boolean] [default: true]
--circular print circular to stdout [boolean] [default: true]
--warning print warning to stdout [boolean] [default: true]
--tsconfig the tsconfig path, which is used for resolve path alias,
default is tsconfig.json if it exists in context directory
[string]
-T, --transform transform typescript modules to javascript before analyze, it
allows you to omit types dependency in typescript
[boolean] [default: false]
--exit-code exit with specified code, the value format is CASE:CODE,
`circular` is the only supported CASE, CODE should be a integer
between 0 and 128. For example: `dpdm --exit-code circular:1`
the program will exit with code 1 if circular dependency found.
[string]
--progress show progress bar [boolean] [default: true]
-h, --help Show help [boolean]
--version Show version number [boolean]
--context the context directory to shorten path, default is current
directory [string]
--extensions, --ext comma separated extensions to resolve
[string] [default: ".ts,.tsx,.mjs,.js,.jsx,.json"]
--js comma separated extensions indicate the file is js like
[string] [default: ".ts,.tsx,.mjs,.js,.jsx"]
--include included filenames regexp in string, default includes all files
[string] [default: ".*"]
--exclude excluded filenames regexp in string, set as empty string to
include all files [string] [default: "node_modules"]
-o, --output output json to file [string]
--tree print tree to stdout [boolean] [default: true]
--circular print circular to stdout [boolean] [default: true]
--warning print warning to stdout [boolean] [default: true]
--tsconfig the tsconfig path, which is used for resolve path alias, default
is tsconfig.json if it exists in context directory [string]
-T, --transform transform typescript modules to javascript before analyze, it
allows you to omit types dependency in typescript
[boolean] [default: false]
--exit-code exit with specified code, the value format is CASE:CODE,
`circular` is the only supported CASE, CODE should be a integer
between 0 and 128. For example: `dpdm --exit-code circular:1` the
program will exit with code 1 if circular dependency found.
[string]
--progress show progress bar [boolean] [default: true]
--detect-unused-files-from this file is a glob, used for finding unused files [string]
-h, --help Show help [boolean]
```

@@ -123,0 +129,0 @@

@@ -107,2 +107,6 @@ #!/usr/bin/env node

})
.option('detect-unused-files-from', {
type: 'string',
desc: 'this file is a glob, used for finding unused files',
})
.alias('h', 'help')

@@ -215,2 +219,24 @@ .wrap(Math.min(yargs.terminalWidth(), 100)).argv;

}
if (argv.detectUnusedFilesFrom) {
const allFiles = await glob(argv.detectUnusedFilesFrom);
const shortAllFiles = allFiles.map((v) => path.relative(context, v));
const unusedFiles = shortAllFiles.filter((v) => !(v in tree)).sort();
console.log(chalk.bold.cyan('• Unused files'));
if (unusedFiles.length === 0) {
console.log(
chalk.bold.green(
' ✅ Congratulations, no unused file was found in your project. (total: ' +
allFiles.length +
', used: ' +
Object.keys(tree).length +
')',
),
);
} else {
const len = unusedFiles.length.toString().length;
unusedFiles.forEach((f, i) => {
console.log('%s) %s', i.toString().padStart(len, '0'), f);
});
}
}
for (const [label, code] of exitCodes) {

@@ -217,0 +243,0 @@ switch (label) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc