#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const index_1 = require("../lib/index");
/**
* Below are the APIs of CLI (Command Line Interface). Some inappropriate titles are used because they are generated by JsDoc.
*
* @namespace CLI
*/
// analytics
/**
* @function analytics
* @memberof CLI
* @example
Usage: insert-gtag analytics [options] <dirPath> <trackingId> [additionalId...]
Insert Google Analytics code (gtag.js) in html files
Options:
-V, --version output the version number
-M, --matched-reg-exp <exp> RegExp pattern of extensions of file to be inserted. Default.
"\.html?$"
-I, --ignored-reg-exp <exp> RegExp pattern of file to be exclude. Ex. "[_\-.]cache\d+"
-N, --indents <number> Number of indenting white spaces. Default: 4
-h, --help display help for command
// Ex1.
> insert-gtag analytics "D:\MyHtmlDir" "UA-XXXXXX-Y"
done
// Ex2.
> insert-gtag analytics "D:\HtmlDir2" --indents 2 "UA-XXXXXX-Y" "AW-XXXXXXXXXX"
done
*/
commander_1.program
.command('analytics <dirPath> <trackingId> [additionalId...]')
.version('1.0.0')
.description('Insert Google Analytics code (gtag.js) in html files')
.option('-M, --matched-reg-exp <exp>', 'RegExp pattern of extensions of file to be inserted. Default. "\\.html?$"')
.option('-I, --ignored-reg-exp <exp>', 'RegExp pattern of file to be exclude. Ex. "[_\\-.]cache\\d+"')
.option('-N, --indents <number>', 'Number of indenting white spaces. Default: 4')
.action(async (dirPath, trackingId, additionalId, options) => {
await (0, index_1.insertGtagCode)(dirPath, [trackingId, ...additionalId], options);
process.stdout.write('done');
});
// tag-manager
/**
* @function tag-manager
* @memberof CLI
* @example
Usage: insert-gtag tag-manager [options] <dirPath> <gtmId>
Insert Google Tag Manager code in html files
Options:
-V, --version output the version number
-M, --matched-reg-exp <exp> RegExp pattern of extensions of file to be inserted. Default.
"\.html?$"
-I, --ignored-reg-exp <exp> RegExp pattern of file to be exclude. Ex. "[_\-.]cache\d+"
-N, --indents <number> Number of indenting white spaces. Default: 4
-h, --help display help for command
// Ex.
> insert-gtag tag-manager "D:\MyHtmlDir" "YOUR_GTM_ID"
done
*/
commander_1.program
.command('tag-manager <dirPath> <gtmId>')
.version('1.0.0')
.description('Insert Google Tag Manager code in html files')
.option('-M, --matched-reg-exp <exp>', 'RegExp pattern of extensions of file to be inserted. Default. "\\.html?$"')
.option('-I, --ignored-reg-exp <exp>', 'RegExp pattern of file to be exclude. Ex. "[_\\-.]cache\\d+"')
.option('-N, --indents <number>', 'Number of indenting white spaces. Default: 4')
.action(async (dirPath, gtmId, options) => {
await (0, index_1.insertGTagManagerCode)(dirPath, gtmId, options);
process.stdout.write('done');
});
commander_1.program.parse(process.argv);
//# sourceMappingURL=index.js.map