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eAAe,CAAC;IAarE,IAAI,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC;IAiB9D,kBAAkB,CACxB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACd,MAAM,CAAC,eAAe;CASzB","file":"steps.d.ts","sourcesContent":["/**\n *\tMIT License\n *\n *\tCopyright (c) 2019 - 2022 Toreda, Inc.\n *\n *\tPermission is hereby granted, free of charge, to any person obtaining a copy\n *\tof this software and associated documentation files (the \"Software\"), to deal\n *\tin the Software without restriction, including without limitation the rights\n *\tto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n *\tcopies of the Software, and to permit persons to whom the Software is\n *\tfurnished to do so, subject to the following conditions:\n\n * \tThe above copyright notice and this permission notice shall be included in all\n * \tcopies or substantial portions of the Software.\n *\n * \tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n *\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n *\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * \tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n *\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n *\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * \tSOFTWARE.\n *\n */\n\nimport {dest, src} from 'gulp';\n\nimport {Clean} from '../clean';\nimport {Create} from '../create';\nimport {Linter} from '../linter';\nimport {LinterTarget} from '../linter/target';\nimport {Log} from '@toreda/log';\nimport {Run} from '../run';\nimport type {TranspileOptions} from '../transpile/options';\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst nunjucksRender = require('gulp-nunjucks-render');\n\n/**\n * Build steps that can be used directly in gulp.\n *\n * @category Gulp\n */\nexport class GulpSteps {\n\tprivate readonly run: Run;\n\t/** Create files and directories. */\n\tprivate readonly create: Create;\n\t/** Clean files & folders in preparation for build. */\n\tprivate readonly clean: Clean;\n\tprivate readonly linter: Linter;\n\tprivate readonly log: Log;\n\t/**\n\t * Constructor\n\t * @param build\n\t * @param run\n\t * @param create\n\t * @param clean\n\t */\n\tconstructor(run: Run, create: Create, linter: Linter, clean: Clean, log: Log) {\n\t\tthis.run = run;\n\t\tthis.create = create;\n\t\tthis.clean = clean;\n\t\tthis.linter = linter;\n\t\tthis.log = log.makeLog('GulpSteps');\n\t}\n\n\t/**\n\t * Run preconfigured webpack build step.\n\t * @returns\n\t */\n\tpublic async webpack(): Promise<NodeJS.ReadWriteStream> {\n\t\tawait this.run.webpack();\n\n\t\treturn src('.', {allowEmpty: true});\n\t}\n\n\t/**\n\t * Recursively copy src dir contents matching regex pattern to target dest dir.\n\t * @param srcPattern\t\tRegex pattern matching designed src files.\n\t * @param destPath\t\t\tTarget dir where contents are copied to.\n\t * @returns\n\t */\n\tpublic copyContents(srcPattern: string, destPath: string): NodeJS.ReadWriteStream {\n\t\treturn src(srcPattern).pipe(dest(destPath));\n\t}\n\n\tpublic async createDir(\n\t\ttargetPath: string | string[],\n\t\toverwrite?: boolean\n\t): Promise<NodeJS.ReadWriteStream> {\n\t\tconst targetPaths: string[] = Array.isArray(targetPath) ? targetPath : [];\n\n\t\tif (typeof targetPath === 'string') {\n\t\t\ttargetPaths.push(targetPath);\n\t\t}\n\n\t\tfor (const target of targetPaths) {\n\t\t\tawait this.create.dir(target, overwrite);\n\t\t}\n\n\t\treturn src('.', {allowEmpty: true});\n\t}\n\n\t/**\n\t * Recursively remove all files and folders from targetPath, and\n\t * then removes the target folder.\n\t * @param targetPath\n\t * @returns\n\t */\n\tpublic async cleanDir(targetPath: string | string[], force?: boolean): Promise<NodeJS.ReadWriteStream> {\n\t\tconst targetPaths: string[] = Array.isArray(targetPath) ? targetPath : [];\n\n\t\tif (typeof targetPath === 'string') {\n\t\t\ttargetPaths.push(targetPath);\n\t\t}\n\n\t\tfor (const target of targetPaths) {\n\t\t\tawait this.clean.dir(target, force);\n\t\t}\n\n\t\treturn src('.', {allowEmpty: true});\n\t}\n\n\tpublic async transpile(options: TranspileOptions): Promise<NodeJS.ReadWriteStream> {\n\t\tconst tsConfigDir = typeof options.tsConfigDirPath === 'string' ? options.tsConfigDirPath : './dist';\n\t\tconst tsConfigFilname =\n\t\t\ttypeof options.tsConfigFilePath === 'string' ? options.tsConfigDirPath : 'tsconfig.json';\n\n\t\treturn await this.run.typescript(tsConfigDir, tsConfigFilname);\n\t}\n\n\t/**\n\t * Lint all source files identified by target srcPattern globs.\n\t * @param tgt\n\t * @returns\n\t */\n\tpublic async lint(tgt: LinterTarget): Promise<NodeJS.ReadWriteStream> {\n\t\tconst fnLog = this.log.makeLog('lint');\n\t\tconst summary = await this.linter.execute(tgt);\n\n\t\tif (!summary.status.success) {\n\t\t\tconst msg = `Linter did not complete successfully due to error code '${summary.status.code}'. ${summary.status.description}.`;\n\n\t\t\tif (tgt.abortOnLimitBreak === true) {\n\t\t\t\tthrow new Error(msg);\n\t\t\t} else {\n\t\t\t\tfnLog.error(msg);\n\t\t\t}\n\t\t}\n\n\t\treturn src('.', {allowEmpty: true});\n\t}\n\n\tpublic renderNunjucksHtml(\n\t\ttemplatePath: string,\n\t\tsrcPattern: string,\n\t\tdestPath: string\n\t): NodeJS.ReadWriteStream {\n\t\treturn src(srcPattern)\n\t\t\t.pipe(\n\t\t\t\tnunjucksRender({\n\t\t\t\t\tpath: templatePath\n\t\t\t\t})\n\t\t\t)\n\t\t\t.pipe(dest(destPath));\n\t}\n}\n"]}