#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var nodeVersions = process.version;
var versionArrStr = nodeVersions.split(".");
versionArrStr[0] = versionArrStr[0].replace("v", "");
var versionArray = versionArrStr.map(function (item) {
    return parseInt(item);
});
if (versionArray[0] < 8) {
    console.error('请您安装NodeJS v8.0 以上版本');
    process.exit(1);
}
const args = require("args");
const index_1 = require("../out/index");
args.command('create', 'create project', (name, sub, options) => {
    index_1.create.run(name, sub, options).catch(e => console.log(e));
});
args.command('install', 'install a library', (name, sub, options) => {
    index_1.install.run(name, sub, options).catch(e => console.log(e));
});
args.option('tag', 'which tag you want to publish')
    .command('publish', 'publish a library', (name, sub, option) => {
    index_1.publish.run(name, sub, option).catch(e => console.error(e));
});
args.command('upgrade', 'upgrade your project', (name, sub, option) => {
    index_1.upgrade.run(name, sub, option).catch(e => console.error(e));
});
args.command("check", "check & remove unused resource", (name, sub, option) => {
    index_1.check.run(name, sub, option).catch(e => console.error(e));
});
args.command("wechat", 'execute wechat ide method', (name, sub, option) => {
    index_1.wechat.run(name, sub, option);
});
args.command("build", "build your project", (name, sub, option) => {
    const projectRoot = sub[0] || ".";
    index_1.build.build({
        projectRoot,
        debug: true,
        target: "web"
    });
});
args.command("bake", "bake your project", (name, sub, option) => {
    const projectRoot = sub[0] || ".";
    index_1.build.bake({
        projectRoot,
        debug: true,
        target: "web"
    }).then((bakeResult) => {
        const list = bakeResult.warn.concat(bakeResult.error);
        list.forEach((item) => {
            console.log(item);
        });
    });
});
args.command("info", "paper-cli info", (name, sub, option) => {
    index_1.info.run(name, sub, option).catch(e => console.log(e));
});
args.parse(process.argv);
