UNPKG

@kiwicom/orbit-tracking

Version:

Tracking for orbit design system

54 lines (41 loc) 2.44 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _chunkLYO3WS6Ncjs = require('./chunk-LYO3WS6N.cjs'); var _chunkEZDBWJICcjs = require('./chunk-EZDBWJIC.cjs'); var _chunkAYAW7EDScjs = require('./chunk-AYAW7EDS.cjs'); var _chunkORI44T3Ecjs = require('./chunk-ORI44T3E.cjs'); // src/cli.ts var _sade = require('sade'); var _sade2 = _interopRequireDefault(_sade); var _zx = require('zx'); require('dotenv/config'); var packageJson = _zx.fs.readJsonSync(_zx.path.resolve(_chunkAYAW7EDScjs.__dirname, "../package.json")); async function cli(args) { _sade2.default.call(void 0, "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) { _chunkEZDBWJICcjs.errorMessage.call(void 0, "Gitlab api token is missing"); process.exit(1); } if (config && !_zx.fs.existsSync(config)) { _chunkEZDBWJICcjs.errorMessage.call(void 0, "Could not find config file"); process.exit(1); } if (output && !_zx.fs.existsSync(output)) { _chunkEZDBWJICcjs.errorMessage.call(void 0, "Path does not exists"); process.exit(1); } if (scope) { if (_chunkORI44T3Ecjs.SCOPE.some((v) => passedScope.includes(v))) { _chunkLYO3WS6Ncjs.fetcher_default.call(void 0, { scope: passedScope, outputPath: output, config }); _chunkEZDBWJICcjs.infoMessage.call(void 0, `Start fetching: ${passedScope.join(" / ")}`); } else { _chunkEZDBWJICcjs.errorMessage.call(void 0, "ERR: This project is not in the scope"); process.exit(1); } } else { _chunkLYO3WS6Ncjs.fetcher_default.call(void 0, { scope: _chunkORI44T3Ecjs.SCOPE, outputPath: output, config }); _chunkEZDBWJICcjs.infoMessage.call(void 0, "Start fetching from default scope"); } }).parse(args); } exports.cli = cli;