@acoustic-content-sdk/cli
Version:
Command line utility for the Acoustic Content SDK.
622 lines (605 loc) • 25.9 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@acoustic-content-sdk/tooling'), require('@acoustic-content-sdk/utils'), require('path'), require('process'), require('rxjs/operators'), require('@acoustic-content-sdk/api'), require('commander'), require('@acoustic-content-sdk/tooling-feature-module'), require('@acoustic-content-sdk/tooling-messages'), require('@acoustic-content-sdk/tooling-types')) :
typeof define === 'function' && define.amd ? define('@acoustic-content-sdk/cli', ['exports', '@acoustic-content-sdk/tooling', '@acoustic-content-sdk/utils', 'path', 'process', 'rxjs/operators', '@acoustic-content-sdk/api', 'commander', '@acoustic-content-sdk/tooling-feature-module', '@acoustic-content-sdk/tooling-messages', '@acoustic-content-sdk/tooling-types'], factory) :
(global = global || self, factory((global['acoustic-content-sdk'] = global['acoustic-content-sdk'] || {}, global['acoustic-content-sdk'].cli = {}), global['acoustic-content-sdk'].tooling, global['acoustic-content-sdk'].utils, global.path, global.process, global.rxjs.operators, global['acoustic-content-sdk'].api, global.Commander, global['acoustic-content-sdk']['tooling-feature-module'], global['acoustic-content-sdk']['tooling-messages'], global['acoustic-content-sdk']['tooling-types']));
}(this, (function (exports, tooling, utils, path, process, operators, api, commander, toolingFeatureModule, toolingMessages, toolingTypes) { 'use strict';
/**
* @fileoverview added by tsickle
* Generated from: commands/utils.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} aValue
* @return {?}
*/
function splitParams(aValue) {
return utils.isString(aValue)
? aValue.split(',')
: utils.isStringArray(aValue)
? aValue
: undefined;
}
/**
* @param {?} aRoot
* @param {?} aDir
* @return {?}
*/
function getFullPath(aRoot, aDir) {
return path.normalize(path.isAbsolute(aDir) ? aDir : path.join(aRoot, aDir));
}
/**
* @fileoverview added by tsickle
* Generated from: commands/canonicalize.assets.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var CANONICALIZE_ASSETS = 'canonicalize-assets';
/**
* @param {?} program
* @return {?}
*/
function canonicalizeAssetsCommand(program) {
// register our commands
/** @type {?} */
var cmd = program
.command(CANONICALIZE_ASSETS)
.description('Rewrites the wchtools data folder in a canonical format.')
.option('--data <data>', 'Location of the data directory.')
.option('--dir <dir>', 'Location of the target directory. Defaults to the data directory.')
.option('--include <include>', 'Regular expression of the types to include.')
.option('--exclude <exclude>', 'Regular expression of the types to exclude.')
.action((/**
* @param {?} aLayoutName
* @return {?}
*/
function (aLayoutName) {
// service
/** @type {?} */
var logSvc = program.verbose
? tooling.createChalkLoggerService()
: utils.NOOP_LOGGER_SERVICE;
// logger
/** @type {?} */
var logger = logSvc.get(cmd.name());
// write callback
/** @type {?} */
var currentDir = process.cwd();
/** @type {?} */
var dataDir = path.normalize(cmd.data || path.join(currentDir, 'data'));
// target dire
/** @type {?} */
var dstDir = path.normalize(cmd.dir || dataDir);
// log this
logger.info('dataDir', dataDir, 'dstDir', dstDir);
// execute the command
/** @type {?} */
var command = tooling.canonicalizeAssets({
data: '/',
include: splitParams(cmd.include),
exclude: splitParams(cmd.exclude)
});
// execute the command
/** @type {?} */
var files$ = utils.rxPipe(command(tooling.createReadDirectory(dataDir), logSvc), tooling.writeFiles(dstDir), tooling.logFileDescriptor(), operators.ignoreElements());
// subscribe
return files$.toPromise();
}));
// ok
return cmd;
}
/**
* @fileoverview added by tsickle
* Generated from: commands/generate.data.overlay.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var GENERATE_DATA_OVERLAY_COMMAND = 'generate-data-overlay';
/**
* Generates a data overlay of the wchtools folders referenced by a node module and all
* of its dependencies. The resulting folder can then be used with {\@link https://www.npmjs.com/package/wchtools-cli|wchtools}.
*
* @param {?} program - the commander instance to attach the command to
* @return {?} the commander instance
*/
function generateDataOverlayCommand(program) {
// register our commands
/** @type {?} */
var cmd = program
.command("" + GENERATE_DATA_OVERLAY_COMMAND)
.description('Generates an overlay of wchtools data folders for referenced modules.')
.option('--dir <dir>', 'Location of the target directory. Defaults to "temp".')
.option('--src <dir>', 'Location of the directory that contains the package.json to analyze. Defaults to the current working directory.')
.action((/**
* @return {?}
*/
function () {
// service
/** @type {?} */
var logSvc = program.verbose
? tooling.createChalkLoggerService()
: utils.NOOP_LOGGER_SERVICE;
// logger
/** @type {?} */
var logger = logSvc.get(cmd.name());
// write callback
/** @type {?} */
var currentDir = process.cwd();
// target dir
/** @type {?} */
var fullDstDir = getFullPath(currentDir, cmd.dir || 'temp');
// source dir
/** @type {?} */
var fullSrcDir = getFullPath(currentDir, cmd.src || '');
// root
var srcRoot = path.parse(fullSrcDir).root;
var dstRoot = path.parse(fullDstDir).root;
// decode relative paths
/** @type {?} */
var dstDir = path.relative(dstRoot, fullDstDir);
/** @type {?} */
var srcDir = path.relative(srcRoot, fullSrcDir);
// log this
logger.info('srcDir', srcDir);
logger.info('dstDir', dstDir);
// execute the command
/** @type {?} */
var command = tooling.generateDataOverlay({
src: srcDir
});
// execute the command
/** @type {?} */
var files$ = utils.rxPipe(command(tooling.createReadTextFile(srcRoot), tooling.createReadDirectory(dstRoot), logSvc), tooling.writeFiles(fullDstDir), tooling.logFileDescriptor(), operators.ignoreElements());
// subscribe
return files$.toPromise();
}));
// ok
return cmd;
}
/**
* @fileoverview added by tsickle
* Generated from: commands/generate.keys.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} program
* @return {?}
*/
function generateKeysCommand(program) {
// register our commands
/** @type {?} */
var cmd = program
.command('generate-keys')
.description('Generates keys into the content.')
.option('--data <data>', 'Location of the data directory.')
.option('--dir <dir>', 'Location of the target directory. Defaults to the data directory.')
.option('--include <include>', 'Regular expression of the content items to include.')
.option('--exclude <exclude>', 'Regular expression of the content items to exclude.')
.action((/**
* @return {?}
*/
function () {
// service
/** @type {?} */
var logSvc = program.verbose
? tooling.createChalkLoggerService()
: utils.NOOP_LOGGER_SERVICE;
// logger
/** @type {?} */
var logger = logSvc.get(cmd.name());
// write callback
/** @type {?} */
var currentDir = process.cwd();
/** @type {?} */
var dataDir = path.normalize(cmd.data || path.join(currentDir, 'data'));
// target dire
/** @type {?} */
var dstDir = path.normalize(cmd.dir || dataDir);
// log this
logger.info('dataDir', dataDir, 'dstDir', dstDir);
// execute the command
/** @type {?} */
var command = tooling.generateKeys({
data: '/',
include: splitParams(cmd.include),
exclude: splitParams(cmd.exclude)
});
// execute the command
/** @type {?} */
var files$ = utils.rxPipe(command(tooling.createReadDirectory(dataDir), logSvc), tooling.writeFiles(dstDir), tooling.logFileDescriptor(), operators.ignoreElements());
// subscribe
return files$.toPromise();
}));
// ok
return cmd;
}
/**
* @fileoverview added by tsickle
* Generated from: commands/generate.layout.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var GENERATE_LAYOUT_COMMAND = 'generate-layout';
/**
* @param {?} program
* @return {?}
*/
function generateLayoutCommand(program) {
// register our commands
/** @type {?} */
var cmd = program
.command(GENERATE_LAYOUT_COMMAND + " [name]")
.description('Generates a layout for a particular content type.')
.option('--data <data>', 'Location of the data directory.')
.requiredOption('--type <type>', 'Name or ID of the type.')
.option('--dir <dir>', 'Location of the target directory. Defaults to the data directory.')
.option('--templateType <templateType>', 'Type of the rendering template to use, can be "angular" or "handlebars".')
.option('--tags <tags>', 'Tags to add to the new layouts.')
.action((/**
* @param {?} aLayoutName
* @return {?}
*/
function (aLayoutName) {
// service
/** @type {?} */
var logSvc = program.verbose
? tooling.createChalkLoggerService()
: utils.NOOP_LOGGER_SERVICE;
// logger
/** @type {?} */
var logger = logSvc.get(cmd.name());
// write callback
/** @type {?} */
var currentDir = process.cwd();
/** @type {?} */
var dataDir = path.normalize(cmd.data || path.join(currentDir, 'data'));
// target dire
/** @type {?} */
var dstDir = path.normalize(cmd.dir || dataDir);
// log this
logger.info('dataDir', dataDir, 'dstDir', dstDir);
// execute the command
/** @type {?} */
var command = tooling.generateLayout({
data: '/',
type: cmd.type,
name: aLayoutName,
tags: splitParams(cmd.tags),
templateType: cmd.templateType
});
// execute the command
/** @type {?} */
var files$ = utils.rxPipe(command(tooling.createReadDirectory(dataDir), logSvc), tooling.writeFiles(dstDir), tooling.logFileDescriptor(), operators.ignoreElements());
// subscribe
return files$.toPromise();
}));
// ok
return cmd;
}
/**
* @fileoverview added by tsickle
* Generated from: commands/generate.layouts.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} program
* @return {?}
*/
function generateLayoutsCommand(program) {
// register our commands
/** @type {?} */
var cmd = program
.command('generate-layouts')
.description('Generates layouts and layout mappings based on type information in a batch in the wchtools folder. The names of the artifacts are derived from the type names.')
.option('--data <data>', 'Location of the data directory.')
.option('--dir <dir>', 'Location of the target directory. Defaults to the data directory.')
.option('--include <include>', 'Regular expression of the types to include.')
.option('--exclude <exclude>', 'Regular expression of the types to exclude.')
.option('--templateType <templateType>', 'Type of the rendering template to use, can be "angular" or "handlebars".')
.option('--tags <tags>', 'Tags to add to the new layouts.')
.action((/**
* @return {?}
*/
function () {
// service
/** @type {?} */
var logSvc = program.verbose
? tooling.createChalkLoggerService()
: utils.NOOP_LOGGER_SERVICE;
// logger
/** @type {?} */
var logger = logSvc.get(cmd.name());
// write callback
/** @type {?} */
var currentDir = process.cwd();
/** @type {?} */
var dataDir = path.normalize(cmd.data || path.join(currentDir, 'data'));
// target dire
/** @type {?} */
var dstDir = path.normalize(cmd.dir || dataDir);
// log this
logger.info('dataDir', dataDir, 'dstDir', dstDir);
// execute the command
/** @type {?} */
var command = tooling.generateLayouts({
data: '/',
tags: splitParams(cmd.tags),
include: splitParams(cmd.include),
exclude: splitParams(cmd.exclude),
templateType: cmd.templateType
});
// execute the command
/** @type {?} */
var files$ = utils.rxPipe(command(tooling.createReadDirectory(dataDir), logSvc), tooling.writeFiles(dstDir), tooling.logFileDescriptor(), operators.ignoreElements());
// subscribe
return files$.toPromise();
}));
// ok
return cmd;
}
/**
* @fileoverview added by tsickle
* Generated from: version.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* Version and build number of the package
* @type {?}
*/
var VERSION = { version: { major: '9', minor: '0', patch: '10076', branch: 'master' }, build: new Date(1585229427693) };
/**
* Module name
* @type {?}
*/
var MODULE = '@acoustic-content-sdk/cli';
/**
* @fileoverview added by tsickle
* Generated from: commands/version.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} program
* @return {?}
*/
function versionCommand(program) {
// default
/** @type {?} */
var cmd = program
.command('version', { isDefault: true })
.description('Show version info.')
.action((/**
* @return {?}
*/
function () {
// logger
/** @type {?} */
var logSvc = tooling.createChalkLoggerService();
/** @type {?} */
var logger = logSvc.get(cmd.name());
// version
logger.info(MODULE, api.createVersionString(VERSION));
}));
// ok
return cmd;
}
/**
* @fileoverview added by tsickle
* Generated from: commands/index.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* Generated from: commands/generate.feature.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var GENERATE_FEATURE_MODULE_COMMAND = 'generate-feature-module';
/**
*
*
* @param {?} program - the commander instance to attach the command to
* @return {?} the commander instance
*/
function generateFeatureModuleCommand(program) {
// register our commands
/** @type {?} */
var cmd = program
.command("" + GENERATE_FEATURE_MODULE_COMMAND)
.description('Adds support for the ng-add schematic to feature modules.')
.option('--src <dir>', 'Location of the directory that contains the package.json to analyze. Defaults to the current working directory.')
.requiredOption('--module <modules>', 'NgModule to export from the feature module. May be a comma separated list.')
.action((/**
* @return {?}
*/
function () {
// service
/** @type {?} */
var logSvc = program.verbose
? tooling.createChalkLoggerService()
: utils.NOOP_LOGGER_SERVICE;
// logger
/** @type {?} */
var logger = logSvc.get(cmd.name());
// write callback
/** @type {?} */
var currentDir = process.cwd();
// module
/** @type {?} */
var module = cmd.module;
// source dir
/** @type {?} */
var srcDir = getFullPath(currentDir, cmd.src || '');
// log this
logger.info('module', module);
logger.info('srcDir', srcDir);
// execute the command
/** @type {?} */
var command = toolingFeatureModule.generateFeatureModule({
module: module
});
// execute the command
/** @type {?} */
var files$ = utils.rxPipe(command(tooling.createReadTextFile(srcDir), logSvc), tooling.writeFiles(srcDir), tooling.logFileDescriptor(), operators.ignoreElements());
// subscribe
return files$.toPromise();
}));
// ok
return cmd;
}
/**
* @fileoverview added by tsickle
* Generated from: commands/generate.messages.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var GENERATE_MESSAGES_COMMAND = 'generate-messages';
/**
* Returns a command that generates a typescript message file from NLS JSON input sources.
*
* @param {?} program - the driver
* @return {?} the command
*/
function generateMessagesCommand(program) {
// register our commands
/** @type {?} */
var messageCommand = program
.command(GENERATE_MESSAGES_COMMAND)
.description('Generate translated messages.')
.option('--src <directory>', 'Source directory')
.option('--dir <directory>', 'Target directory')
.option('--default <default>', 'Default locale')
.action((/**
* @return {?}
*/
function () {
// service
/** @type {?} */
var logSvc = program.verbose
? tooling.createChalkLoggerService()
: utils.NOOP_LOGGER_SERVICE;
// logger
/** @type {?} */
var logger = logSvc.get(messageCommand.name());
// write callback
/** @type {?} */
var srcDir = messageCommand.src || process.cwd();
/** @type {?} */
var dstDir = messageCommand.dir || process.cwd();
/** @type {?} */
var defaultLocale = messageCommand.default;
// log this
logger.info('srcDir', srcDir);
logger.info('dstDir', dstDir);
logger.info('defaultLocale', defaultLocale);
// read callback
/** @type {?} */
var command = toolingMessages.generateMessages({ dir: '/', default: defaultLocale });
// execute the command
/** @type {?} */
var cmp$ = utils.rxPipe(command(tooling.createReadDirectory(srcDir), logSvc), tooling.writeFiles(dstDir), tooling.logFileDescriptor(), operators.ignoreElements());
// subscribe
return cmp$.toPromise();
}));
return messageCommand;
}
/**
* @fileoverview added by tsickle
* Generated from: commands/generate.types.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var GENERATE_TYPES_COMMAND = 'generate-types';
/**
* Generates typings and helper methods based on a set of content type definitions.
*
* @param {?} program
* @return {?}
*/
function generateTypesCommand(program) {
// register our commands
/** @type {?} */
var cmd = program
.command(GENERATE_TYPES_COMMAND)
.description('Generates typings and helper methods based on a set of content type definitions.')
.option('--data <data>', 'Location of the data directory.')
.option('--dir <dir>', 'Location of the target directory. Defaults to the "src" directory.')
.option('--include <include>', 'Regular expression of the types to include.')
.option('--exclude <exclude>', 'Regular expression of the types to exclude.')
.action((/**
* @return {?}
*/
function () {
// service
/** @type {?} */
var logSvc = program.verbose
? tooling.createChalkLoggerService()
: utils.NOOP_LOGGER_SERVICE;
// logger
/** @type {?} */
var logger = logSvc.get(cmd.name());
// write callback
/** @type {?} */
var currentDir = process.cwd();
/** @type {?} */
var dataDir = path.normalize(cmd.data || path.join(currentDir, 'data'));
// target dire
/** @type {?} */
var dstDir = path.normalize(cmd.dir || currentDir);
// log this
logger.info('dataDir', dataDir);
logger.info('dstDir', dstDir);
// execute the command
/** @type {?} */
var command = toolingTypes.generateTypes({
data: '/',
include: splitParams(cmd.include),
exclude: splitParams(cmd.exclude)
});
// execute the command
/** @type {?} */
var files$ = utils.rxPipe(command(tooling.createReadDirectory(dataDir), tooling.createReadTextFile(dataDir), logSvc), tooling.writeFiles(dstDir), tooling.logFileDescriptor(), operators.ignoreElements());
// subscribe
return files$.toPromise();
}));
// ok
return cmd;
}
/**
* @fileoverview added by tsickle
* Generated from: driver/index.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var NAME = 'acoustic-content-sdk-cli';
/**
* @param {?=} aArgs
* @return {?}
*/
function runProgram(aArgs) {
if (aArgs === void 0) { aArgs = process.argv; }
// construct the wrapper
/** @type {?} */
var program = new commander.Command(NAME)
.version(api.createVersionString(VERSION))
.option('-v, --verbose', 'print additional logs');
versionCommand(program);
generateLayoutsCommand(program);
generateLayoutCommand(program);
generateKeysCommand(program);
generateDataOverlayCommand(program);
generateMessagesCommand(program);
generateTypesCommand(program);
generateFeatureModuleCommand(program);
canonicalizeAssetsCommand(program);
return program.parse(aArgs);
}
exports.VERSION = VERSION;
exports.canonicalizeAssetsCommand = canonicalizeAssetsCommand;
exports.generateDataOverlayCommand = generateDataOverlayCommand;
exports.generateKeysCommand = generateKeysCommand;
exports.generateLayoutCommand = generateLayoutCommand;
exports.generateLayoutsCommand = generateLayoutsCommand;
exports.runProgram = runProgram;
exports.versionCommand = versionCommand;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=acoustic-content-sdk-cli.umd.js.map