UNPKG

tsm-cli

Version:

Simple way to manage typescipt and angular2 submodules from one repository

52 lines (51 loc) 1.94 kB
"use strict"; // todo: add load from config file, TBD Object.defineProperty(exports, "__esModule", { value: true }); const path = require("path"); const Listr = require('listr'); const cpy = require('cpy'); const del = require('del'); const npm_submodules_1 = require("npm-submodules"); const tasks_1 = require("../tasks"); function buildCommand({ project, verbose, clean, local }) { // 1. clean dist folders // 2.1 merge pkg json // todo: 2.2 validate pkg (main, module, types fields) // 2.3 write pkg // 3. compile ts return npm_submodules_1.findSubmodules(project, { local }) .then(opts => new Listr([ { title: 'Clean dist folders', task: () => new Listr(opts.map(opt => ({ title: `Cleaning ${opt.dist}`, task: () => del([opt.dist + '/**', '!' + opt.dist]) }))), skip: () => !clean }, { title: 'Copy md files and license', task: () => Promise.all(opts.map(opt => cpy(['*.md', 'LICENSE'], opt.dist) .then(() => cpy([path.join(opt.src, '*.md'), path.join(opt.src, 'LICENSE')], opt.dist)))) }, { title: "Build package.json files", task: () => npm_submodules_1.buildPkgs(opts, { local }) }, { title: 'Build projects', task: () => new Listr(opts.map(opt => ({ title: `Building ${opt.pkg.name} (${opt.src})`, task: () => tasks_1.build(opt.project) }))) } ], { renderer: verbose ? 'verbose' : 'default' })); } exports.buildCommand = buildCommand; function buildTsRun(cli) { const { project, watch, verbose, clean, local } = cli.flags; return buildCommand({ project, verbose, clean, local }) .then(tasks => npm_submodules_1.tasksWatch({ project, tasks, watch })); } exports.buildTsRun = buildTsRun;