analyze-codebase 1.2.0 → 1.2.2

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/dist/index.js CHANGED
@@ -16,7 +16,7 @@ commander_1.program
16
16
  .option("-exc, --exclude <exclude...>", "Specify the exclude", (value, previous) => previous.concat(value), [])
17
17
  .option("--checkFileNames [checkFileNames]", "Check file names", parseBoolean)
18
18
  .option("--checkFileContent [checkFileContent]", "Check directories", parseBoolean)
19
- .option("-w --writeJsonOutput [writeJsonOutput]", "Write json output", parseBoolean)
19
+ .option("-w, --writeJsonOutput [writeJsonOutput]", "Write json output", parseBoolean)
20
20
  .action((directory, options) => {
21
21
  var _a, _b, _c;
22
22
  if (options.checkFileNames === false &&
@@ -94,23 +94,34 @@ const makeMigrationFromLastFileSystem = async (directory) => {
94
94
  const data = await (0, exports.readAnalyzeResult)(directory);
95
95
  if (data)
96
96
  return;
97
+ // Check if the directory exists before trying to traverse it
98
+ const directoryExists = await (0, exports.checkFileExist)(directory);
99
+ if (!directoryExists) {
100
+ return;
101
+ }
97
102
  console.log(chalk_1.default.yellow("Migrating data from the last file system to the new file system...\n"));
98
103
  let newAnalyzeOutput;
99
104
  const oldAnalyzes = [];
100
- await (0, exports.traverseDirectory)({
101
- directory,
102
- checkFileNames: true,
103
- extensions: [".json"],
104
- onFile: async (filePath) => {
105
- try {
106
- const fileContent = JSON.parse(await fs.readFile(filePath, "utf-8"));
107
- oldAnalyzes.push(fileContent);
108
- }
109
- catch (error) {
110
- console.error(chalk_1.default.red(`Error reading the file: ${filePath}.`));
111
- }
112
- },
113
- });
105
+ try {
106
+ await (0, exports.traverseDirectory)({
107
+ directory,
108
+ checkFileNames: true,
109
+ extensions: [".json"],
110
+ onFile: async (filePath) => {
111
+ try {
112
+ const fileContent = JSON.parse(await fs.readFile(filePath, "utf-8"));
113
+ oldAnalyzes.push(fileContent);
114
+ }
115
+ catch (error) {
116
+ console.error(chalk_1.default.red(`Error reading the file: ${filePath}.`));
117
+ }
118
+ },
119
+ });
120
+ }
121
+ catch (error) {
122
+ // Directory doesn't exist or can't be read, skip migration
123
+ return;
124
+ }
114
125
  if (oldAnalyzes.length) {
115
126
  newAnalyzeOutput = {
116
127
  totalAnalyzeCount: oldAnalyzes.length,
package/package.json CHANGED
@@ -5,14 +5,34 @@
5
5
  "type": "git",
6
6
  "url": "https://github.com/mtahagocer/analyze-codebase"
7
7
  },
8
- "version": "1.2.0",
8
+ "version": "1.2.2",
9
9
  "main": "dist/index.js",
10
10
  "license": "MIT",
11
11
  "bin": {
12
12
  "analyze-codebase": "./dist/index.js"
13
13
  },
14
+ "keywords": [
15
+ "codebase",
16
+ "analyzer",
17
+ "code-analysis",
18
+ "static-analysis",
19
+ "file-analysis",
20
+ "directory-analysis",
21
+ "naming-conventions",
22
+ "code-structure",
23
+ "file-extensions",
24
+ "exclude-directories",
25
+ "js",
26
+ "ts",
27
+ "json-output",
28
+ "recursive",
29
+ "source-code",
30
+ "developer-tools",
31
+ "code-quality"
32
+ ],
14
33
  "scripts": {
15
34
  "cli": "ts-node ./src/index.ts",
35
+ "dev": "ts-node-dev --respawn --transpile-only ./src/index.ts",
16
36
  "start": "node ./dist/index.js",
17
37
  "compile": "npx rimraf dist && npx tsc",
18
38
  "publish": "npm run compile && npm publish"
@@ -20,6 +40,7 @@
20
40
  "devDependencies": {
21
41
  "@types/node": "^20.1.5",
22
42
  "ts-node": "^10.9.1",
43
+ "ts-node-dev": "^2.0.0",
23
44
  "typescript": "^5.0.4"
24
45
  },
25
46
  "dependencies": {