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

find-duplicate-strings

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-duplicate-strings - npm Package Compare versions

Comparing version 1.0.3 to 2.0.0

lib/cli/questions/confirm-directory.d.ts

7

lib/cli/cli.d.ts

@@ -1,6 +0,1 @@

import { Answers } from 'inquirer';
import { Findings } from '../scan';
export declare const outputFindings: (findings: Findings) => void;
export declare const filterFileFormats: ({ scanPath }: Answers) => Promise<Answers>;
export declare const scanDirAndLogFindings: ({ extensions, scanPath }: Answers) => Findings;
export declare function run(): void;
export {};
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = exports.scanDirAndLogFindings = exports.filterFileFormats = exports.outputFindings = void 0;
const commander_1 = require("commander");
const inquirer_1 = require("inquirer");
const scan_1 = require("../scan");
const path_1 = require("path");
const fs_1 = require("fs");
const questions_json_1 = __importDefault(require("./questions.json"));
const scanner = new scan_1.Scanner();
const scanner_1 = require("../scanner");
const program = new commander_1.Command();
const prompt = inquirer_1.createPromptModule();
exports.outputFindings = (findings) => {
if (!Object.keys(findings).length) {
console.log('No duplicates where found.');
return;
}
prompt([questions_json_1.default.write]).then(({ writePath }) => {
const filePath = path_1.resolve(process.cwd(), writePath);
const data = JSON.stringify(findings, null, 2);
fs_1.writeFileSync(`${filePath}.json`, data, { encoding: 'utf8' });
});
};
exports.filterFileFormats = ({ scanPath }) => {
return prompt([questions_json_1.default.extensions]).then(({ extensions }) => ({ extensions, scanPath }));
};
exports.scanDirAndLogFindings = ({ extensions, scanPath }) => {
const resolvedPath = path_1.resolve(process.cwd(), scanPath);
if (!fs_1.existsSync(resolvedPath)) {
throw new Error('Directory does not exist, please pass a valid path.');
}
const findings = scanner.scanDir(resolvedPath, extensions);
if (Object.keys(findings).length) {
console.table(findings, ['count']);
}
return findings;
};
function run() {
prompt([questions_json_1.default.scan])
.then(exports.filterFileFormats)
.then(exports.scanDirAndLogFindings)
.then(exports.outputFindings)
.catch((e) => {
console.error(e);
});
}
exports.run = run;
program.action(run);
program.parse(process.argv);
program
.option('-s, --silent', 'Prevent the CLI from printing messages through the console.')
.action(({ silent }) => __awaiter(void 0, void 0, void 0, function* () { return (yield new scanner_1.Scanner(silent).init()).scan().catch((err) => console.error(`Error: ${err.message}`)); }))
.parse(process.argv);
#!/usr/bin/env node
export {};
#!/usr/bin/env node
"use strict";
require('./cli');
{
"name": "find-duplicate-strings",
"version": "1.0.3",
"version": "2.0.0",
"description": "Easy to use CLI that finds duplicate strings in a directory and stores them in a external file for easy reference",

@@ -37,20 +37,20 @@ "author": "Erwin Heitzman",

"dependencies": {
"commander": "^5.1.0",
"inquirer": "^7.1.0"
"commander": "^6.0.0",
"inquirer": "^7.3.3"
},
"devDependencies": {
"@types/inquirer": "^6.5.0",
"@types/jest": "^25.2.3",
"@types/node": "^14.0.5",
"@typescript-eslint/eslint-plugin": "^3.0.0",
"@typescript-eslint/parser": "^3.0.0",
"eslint": "^7.1.0",
"@types/inquirer": "^7.3.0",
"@types/jest": "^26.0.7",
"@types/node": "^14.0.25",
"@typescript-eslint/eslint-plugin": "^3.7.0",
"@typescript-eslint/parser": "^3.7.0",
"eslint": "^7.5.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.5",
"jest": "^25.5.4",
"lint-staged": "^10.2.6",
"jest": "^26.1.0",
"lint-staged": "^10.2.11",
"prettier": "^2.0.5",
"ts-jest": "^25.5.1",
"typescript": "^3.9.3"
"ts-jest": "^26.1.3",
"typescript": "^3.9.7"
},

@@ -57,0 +57,0 @@ "husky": {

[![Build Status](https://travis-ci.org/erwinheitzman/find-duplicate-strings.svg?branch=master)](https://travis-ci.org/erwinheitzman/find-duplicate-strings)
[![codecov](https://codecov.io/gh/erwinheitzman/find-duplicate-strings/branch/master/graph/badge.svg)](https://codecov.io/gh/erwinheitzman/find-duplicate-strings)
find-duplicate-strings
===========
# find-duplicate-strings

@@ -11,9 +10,11 @@ **Easy to use CLI that finds duplicate strings in a directory and stores them in a external file for easy reference**

First clone the repository:
```shell
Install:
```bash
npm i -g find-duplicate-strings
```
Then run the cli:
```shell
Run:
```bash
find-duplicate-strings

@@ -23,3 +24,4 @@ ```

You will be asked to enter a path to a existing directory to be scanned for duplicate string values:
```shell
```bash
? Please provide a directory to scan for duplicate values.

@@ -29,29 +31,57 @@ ./data

It will output a table containing it's findings:
```shell
┌─────────┬────────┐
│ (index) │ counts │
├─────────┼────────┤
│ foo │ 6 │
│ bar │ 6 │
│ unique │ 2 │
└─────────┴────────┘
You can provide any directories that you would like to exclude:
```bash
? Please provide any directories that you want to skip (separated list by ;) (node_modules)
```
You will be asked to enter the file extensions that you want to scan:
```shell
? Please provide the file extensions you want to scan or leave empty to scan all files
)O js
)O ts
)O json
Then you will be asked to enter the file extensions that you want to scan:
```bash
? Please provide the file extensions you want to scan or leave empty to scan all files (separated list by ;)
```
You will be asked to enter a path to a file that the results can be written to (json):
```shell
? Please provide a filepath to store the values.
It will then ask you if you would like to scan any other directories (the results will be stored in a single file):
```bash
? Would you like to scan another directory? (Y/n)
```
When done, if you aren't running in silent mode it will output a table containing it's first 10 findings:
```bash
┌─────────┬──────────────┬───────────────────────────────┐
│ (index) │ 0 │ 1 │
├─────────┼──────────────┼───────────────────────────────┤
│ 0 │ 'one' │ { count: 2, files: [Array] } │
│ 1 │ 'bar' │ { count: 15, files: [Array] } │
│ 2 │ 'two' │ { count: 2, files: [Array] } │
│ 3 │ 'foo' │ { count: 14, files: [Array] } │
│ 4 │ 'three' │ { count: 2, files: [Array] } │
│ 5 │ 'four' │ { count: 2, files: [Array] } │
│ 6 │ 'baz' │ { count: 2, files: [Array] } │
│ 7 │ 'five' │ { count: 2, files: [Array] } │
│ 8 │ 'foobar' │ { count: 6, files: [Array] } │
│ 9 │ 'not-unique' │ { count: 2, files: [Array] } │
│ 10 │ '...' │ '...' │
└─────────┴──────────────┴───────────────────────────────┘
```
Lastly you will be asked to enter a path to a file that the results can be written to (json):
```bash
? Please provide a filepath to store the output.
./output
```
## Help
Use the help flag to get more information about how to use the CLI.
```bash
find-duplicate-strings --help
```
### License
MIT
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