@kiwicom/orbit-tracking
Version:
Tracking for orbit design system
54 lines (51 loc) • 1.87 kB
JavaScript
import {
fetcher_default
} from "./chunk-RB4F4ZCW.js";
import {
errorMessage,
infoMessage
} from "./chunk-ZXUFWPBJ.js";
import {
__dirname
} from "./chunk-5T6242DN.js";
import {
SCOPE
} from "./chunk-NCG23OMG.js";
// src/cli.ts
import sade from "sade";
import { fs, path } from "zx";
import "dotenv/config";
var packageJson = fs.readJsonSync(path.resolve(__dirname, "../package.json"));
async function cli(args) {
sade("orbit-tracking", true).version(packageJson.version).describe(packageJson.description).option("-s, --scope", "Repositories to fetch from").example("-s frontend account smart-faq search").option("-o, --output", "Output path for parsed files").example("-o path/to/folder").option("-c --config", "Path to react-scanner config").example("-c path/to/scanner.config.js").action(({ output, config, scope }) => {
const idx = process.argv.indexOf("-o") || process.argv.indexOf("--output");
const passedScope = process.argv.slice(3, idx === 0 ? idx : process.argv.length);
if (!process.env.GITLAB_TOKEN) {
errorMessage("Gitlab api token is missing");
process.exit(1);
}
if (config && !fs.existsSync(config)) {
errorMessage("Could not find config file");
process.exit(1);
}
if (output && !fs.existsSync(output)) {
errorMessage("Path does not exists");
process.exit(1);
}
if (scope) {
if (SCOPE.some((v) => passedScope.includes(v))) {
fetcher_default({ scope: passedScope, outputPath: output, config });
infoMessage(`Start fetching: ${passedScope.join(" / ")}`);
} else {
errorMessage("ERR: This project is not in the scope");
process.exit(1);
}
} else {
fetcher_default({ scope: SCOPE, outputPath: output, config });
infoMessage("Start fetching from default scope");
}
}).parse(args);
}
export {
cli
};