1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | var bl = require("./lib/package/bundleLinter.js");
|
20 | var program = require("commander");
|
21 | var pkj = require('./package.json');
|
22 | var bundleType = require('./lib/package/BundleTypes.js')
|
23 |
|
24 | program
|
25 | .version(pkj.version)
|
26 | .option("-s, --path <path>", "Path of the proxies")
|
27 | .option("-f, --formatter [value]", "Specify formatters (default json.js)")
|
28 | .option("-w, --write [value]", "file path to write results")
|
29 | .option(
|
30 | "-d, --destPath [value]",
|
31 | "Provide the host and path to upload linter results"
|
32 | )
|
33 | .option("-e, --excluded [value]", "The comma separated list of tests to be excluded")
|
34 | .option("--maxWarnings [value]", "Number of warnings to trigger nonzero exit code - default: -1")
|
35 | .option("-u, --user [value]", "Apigee user account")
|
36 | .option("-p, --password [value]", "Apigee password")
|
37 | .option("-o, --organization [value]", "Apigee organization")
|
38 | .option("-x, --externalPluginsDirectory [value]", "Relative or full path to an external plugins directory");
|
39 |
|
40 | program.on("--help", function() {
|
41 | console.log("\nExample: apigeelint -s sampleProxy/ -f table.js");
|
42 | console.log("");
|
43 | });
|
44 |
|
45 | program.parse(process.argv);
|
46 |
|
47 | var configuration = {
|
48 | debug: true,
|
49 | source: {
|
50 | type: "filesystem",
|
51 | path: program.path,
|
52 | bundleType: program.path.includes(bundleType.BundleType.SHAREDFLOW) ? bundleType.BundleType.SHAREDFLOW : bundleType.BundleType.APIPROXY
|
53 | },
|
54 | externalPluginsDirectory: program.externalPluginsDirectory,
|
55 | excluded: {},
|
56 | maxWarnings: -1
|
57 | };
|
58 |
|
59 | if(!isNaN(program.maxWarnings)){
|
60 | configuration.maxWarnings = Number.parseInt(program.maxWarnings);
|
61 | }
|
62 |
|
63 | if (program.formatter) {
|
64 | configuration.formatter = program.formatter || "json.js";
|
65 | }
|
66 |
|
67 | if (program.excluded && typeof(program.excluded) === "string") {
|
68 | var excluded = program.excluded.split(",");
|
69 | configuration.excluded = configuration.excluded || {};
|
70 | for (var i in excluded)
|
71 | {
|
72 | configuration.excluded[excluded[i]] = true;
|
73 | }
|
74 | }
|
75 |
|
76 | if (program.user) {
|
77 |
|
78 | configuration.apiUpload = {
|
79 | destPath:
|
80 | program.destPath || "https://csdata-test.apigee.net/v1/lintresults",
|
81 | user: program.user,
|
82 | password: program.password,
|
83 | organization: program.organization
|
84 | };
|
85 | }
|
86 |
|
87 | if (program.write) {
|
88 | configuration.writePath = program.write;
|
89 | }
|
90 |
|
91 | bl.lint(configuration);
|