ts2famix 1.0.6 → 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/dist/ts2famix-cli.js +17 -5
- package/package.json +1 -1
- package/src/ts2famix-cli.ts +19 -6
package/dist/ts2famix-cli.js
CHANGED
|
@@ -30,17 +30,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
30
30
|
const fs = __importStar(require("fs"));
|
|
31
31
|
const yargs_1 = __importDefault(require("yargs"));
|
|
32
32
|
const analyze_1 = require("./analyze");
|
|
33
|
-
const
|
|
33
|
+
const ts_morph_1 = require("ts-morph");
|
|
34
34
|
const argv = yargs_1.default
|
|
35
|
-
.example(`
|
|
35
|
+
.example(`ts2famix -i "path/to/project/**/*.ts" -o JSONModels/projectName.json`, 'Creates a JSON-format Famix model of typescript files.')
|
|
36
|
+
.example(`ts2famix -i path/to/tsconfig.json -o JSONModels/projectName.json`, 'Creates a JSON-format model of a typescript project.')
|
|
36
37
|
.alias('i', 'input')
|
|
37
38
|
.nargs('i', 1)
|
|
38
39
|
.alias('o', 'output')
|
|
39
40
|
.nargs('o', 1)
|
|
40
41
|
.demandOption('input').demandOption('output').parseSync();
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const importer = new analyze_1.Importer();
|
|
43
|
+
let famixRep;
|
|
44
|
+
if (argv.input.endsWith('tsconfig.json')) {
|
|
45
|
+
const tsConfigFilePath = argv.input;
|
|
46
|
+
const project = new ts_morph_1.Project({
|
|
47
|
+
tsConfigFilePath
|
|
48
|
+
});
|
|
49
|
+
famixRep = importer.famixRepFromProject(project);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const paths = new Array();
|
|
53
|
+
paths.push(argv.input);
|
|
54
|
+
famixRep = importer.famixRepFromPaths(paths);
|
|
55
|
+
}
|
|
44
56
|
const jsonOutput = famixRep.getJSON();
|
|
45
57
|
const jsonFilePath = argv.output;
|
|
46
58
|
fs.writeFile(jsonFilePath, jsonOutput, (err) => {
|
package/package.json
CHANGED
package/src/ts2famix-cli.ts
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
import * as fs from "fs";
|
|
2
3
|
import yargs from "yargs";
|
|
3
4
|
import { Importer } from './analyze';
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
import { FamixRepository } from "./lib/famix/src/famix_repository";
|
|
6
|
+
import { Project } from "ts-morph";
|
|
6
7
|
|
|
7
8
|
const argv = yargs
|
|
8
|
-
.example(`
|
|
9
|
+
.example(`ts2famix -i "path/to/project/**/*.ts" -o JSONModels/projectName.json`, 'Creates a JSON-format Famix model of typescript files.')
|
|
10
|
+
.example(`ts2famix -i path/to/tsconfig.json -o JSONModels/projectName.json`, 'Creates a JSON-format model of a typescript project.')
|
|
9
11
|
.alias('i', 'input')
|
|
10
12
|
.nargs('i', 1)
|
|
11
13
|
.alias('o', 'output')
|
|
12
14
|
.nargs('o', 1)
|
|
13
15
|
.demandOption('input').demandOption('output').parseSync();
|
|
14
16
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
+
const importer = new Importer();
|
|
18
|
+
let famixRep: FamixRepository;
|
|
19
|
+
|
|
20
|
+
if ((argv.input as string).endsWith('tsconfig.json')) {
|
|
21
|
+
const tsConfigFilePath = argv.input as string;
|
|
22
|
+
const project = new Project({
|
|
23
|
+
tsConfigFilePath
|
|
24
|
+
});
|
|
25
|
+
famixRep = importer.famixRepFromProject(project);
|
|
26
|
+
} else {
|
|
27
|
+
const paths = new Array<string>();
|
|
28
|
+
paths.push(argv.input as string);
|
|
29
|
+
famixRep = importer.famixRepFromPaths(paths);
|
|
30
|
+
}
|
|
17
31
|
|
|
18
|
-
const famixRep = importer.famixRepFromPaths(paths);
|
|
19
32
|
const jsonOutput = famixRep.getJSON();
|
|
20
33
|
const jsonFilePath = argv.output as string;
|
|
21
34
|
|