mono/packages/search/commands/test.js
2025-03-11 11:28:14 +01:00

59 lines
2.4 KiB
JavaScript

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const path = require("path");
const core_1 = require("@plastichub/core");
const osr_commons_1 = require("@plastichub/osr-commons");
const __1 = require("../");
const _cli_1 = require("../_cli");
const defaultOptions = (yargs) => {
return yargs.option('debug', {
default: 'false',
describe: 'debug messages'
}).option('verb', {
description: 'test verb : file|folder'
}).option('src', {
description: 'raw source file',
default: './tests/src.json'
}).option('dst', {
description: 'dst output path, supports XLS|CSV|HTML',
default: './tests/dst.json'
}).option('env_key', {
default: 'OSR-CONFIG',
describe: 'Environment key to the config path'
});
};
let options = (yargs) => defaultOptions(yargs);
const register = (cli) => {
return cli.command('test <verb>', 'Test commands', options, (argv) => __awaiter(void 0, void 0, void 0, function* () {
(0, _cli_1.defaults)();
if (argv.help) {
return;
}
const args = argv;
const config = (0, osr_commons_1.CONFIG_DEFAULT)(args.env_key);
const opts = {
verb: argv.verb,
src: path.resolve((0, core_1.substitute)(args.src, osr_commons_1.DEFAULT_ROOTS)),
dst: path.resolve((0, core_1.substitute)(args.dst, osr_commons_1.DEFAULT_ROOTS))
};
if (!opts.verb) {
__1.logger.error('No verb specified');
return;
}
if (opts.verb === 'file') {
}
__1.logger.debug(`Reading OSR Config with key "${argv.env_key}"`, opts);
}));
};
exports.register = register;
//# sourceMappingURL=test.js.map