"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PROJECT_NAME_INPUT = exports.APPLICATION_TEMPLATE = exports.ALL_TEMPLATE = void 0;
var utils_1 = require("../utils");
var lodash_1 = require("lodash");
var first_level_template = [
    {
        name: 'Alibaba Cloud Serverless',
        value: 'Alibaba_Cloud_Serverless',
    },
    {
        name: 'AWS Cloud Serverless',
        value: 'devscomp/start-lambda',
    },
    {
        name: 'Tencent Cloud Serverless',
        value: 'devscomp/start-scf',
    },
    {
        name: 'Huawei Cloud Serverless',
        value: 'xinwuyun/start-fg',
    },
    {
        name: 'Baidu Cloud Serverless',
        value: 'xinwuyun/start-cfc',
    },
    {
        name: 'Dev Template for Serverless Devs',
        value: 'Dev_Template_for_Serverless_Devs',
    },
];
var devs_template = [
    {
        name: 'Application Scaffolding',
        value: 'devsapp/start-application',
    },
    {
        name: 'Component Scaffolding',
        value: 'devsapp/start-component',
    },
];
var ali_template = [
    {
        name: 'Quick start [Deploy a Hello World function to FaaS]',
        value: 'quick_start',
    },
    {
        name: 'Container example [Deploy function to FaaS with custom-container]',
        value: 'container_example',
    },
    {
        name: 'Web Framework [Deploy a web framework to FaaS]',
        value: 'web_framework',
    },
    {
        name: 'Static website [Deploy a static website]',
        value: 'static_website',
    },
    {
        name: 'Best practice [Experience serverless project]',
        value: 'best_practice',
    },
];
var quick_start_template = [
    {
        name: '[HTTP] Node.js 14',
        value: 'devsapp/start-fc-http-nodejs14',
        isDeploy: true,
    },
    {
        name: '[HTTP] Python3',
        value: 'devsapp/start-fc-http-python3',
        isDeploy: true,
    },
    {
        name: '[HTTP] Java8',
        value: 'devsapp/start-fc-http-java8',
    },
    {
        name: '[HTTP] PHP7',
        value: 'devsapp/start-fc-http-php7',
        isDeploy: true,
    },
    {
        name: '[HTTP] C++ (custom)',
        value: 'devsapp/fc-custom-cpp-http',
        isDeploy: true,
    },
    {
        name: '[Event] Node.js 14',
        value: 'devsapp/start-fc-event-nodejs14',
        isDeploy: true,
    },
    {
        name: '[Event] Python3',
        value: 'devsapp/start-fc-event-python3',
        isDeploy: true,
    },
    {
        name: '[Event] Java8',
        value: 'devsapp/start-fc-event-java8',
    },
    {
        name: '[Event] PHP7',
        value: 'devsapp/start-fc-event-php7',
        isDeploy: true,
    },
    {
        name: '[Event] Go (custom)',
        value: 'devsapp/fc-custom-golang-event',
    },
    {
        name: '[Event] Powershell (custom)',
        value: 'devsapp/fc-custom-powershell-event',
    },
    {
        name: '[Event] Typescript (custom)',
        value: 'devsapp/fc-custom-typescript-event',
    },
    {
        name: '[Event] Lua (custom)',
        value: 'devsapp/fc-custom-lua-event',
    },
    {
        name: '[Event] Ruby (custom)',
        value: 'devsapp/fc-custom-ruby-event',
    },
    {
        name: '[Event] Rust (custom)',
        value: 'devsapp/fc-custom-rust-event',
    },
    {
        name: '[Event] Dart (custom)',
        value: 'devsapp/fc-custom-dart-event',
    },
];
var container_example_template = [
    {
        name: '[HTTP] C++',
        value: 'devsapp/start-fc-custom-container-http-cpp',
    },
    {
        name: '[HTTP] Java (Springboot)',
        value: 'devsapp/start-fc-custom-container-http-springboot',
    },
    {
        name: '[HTTP] ASP.NET Core',
        value: 'devsapp/start-fc-custom-container-http-aspdotnetcore',
    },
    {
        name: '[Event] Node.js 14',
        value: 'devsapp/start-fc-custom-container-event-nodejs14',
        isDeploy: true,
    },
    {
        name: '[Event] Python3.9',
        value: 'devsapp/start-fc-custom-container-event-python3.9',
    },
    {
        name: '[Event] C++',
        value: 'devsapp/start-fc-custom-container-event-cpp',
    },
];
var web_framework_template = [
    {
        name: 'Express.js',
        value: 'devsapp/start-express',
        isDeploy: true,
    },
    {
        name: 'Egg.js',
        value: 'devsapp/start-egg',
        isDeploy: true,
    },
    {
        name: 'Koa.js',
        value: 'devsapp/start-koa',
    },
    {
        name: 'Nuxt.js (SSR)',
        value: 'devsapp/start-nuxt-ssr',
        isDeploy: true,
    },
    {
        name: 'Next.js (SSR)',
        value: 'devsapp/start-next-ssr',
        isDeploy: true,
    },
    {
        name: 'Django',
        value: 'devsapp/start-django',
        isDeploy: true,
    },
    {
        name: 'Flask',
        value: 'devsapp/start-flask',
        isDeploy: true,
    },
    {
        name: 'Tornado',
        value: 'devsapp/start-tornado',
        isDeploy: true,
    },
    {
        name: 'Springboot',
        value: 'devsapp/start-springboot',
    },
    {
        name: 'ThinkPHP',
        value: 'devsapp/start-thinkphp',
    },
    {
        name: 'Laravel',
        value: 'devsapp/start-laravel',
    },
];
var static_website_template = [
    {
        name: 'Vue.js',
        value: 'devsapp/website-vue',
        isDeploy: true,
    },
    {
        name: 'React.js',
        value: 'devsapp/website-react',
        isDeploy: true,
    },
    {
        name: 'Docusaurus',
        value: 'devsapp/website-docusaurus',
        isDeploy: true,
    },
    {
        name: 'Hexo',
        value: 'devsapp/website-hexo',
        isDeploy: true,
    },
    {
        name: 'Vuepress',
        value: 'devsapp/website-vuepress',
        isDeploy: true,
    },
];
var best_practice_template = [
    {
        name: '[AI] PyTorch',
        value: 'devsapp/start-pytorch',
        isDeploy: true,
    },
    {
        name: '[AI] Tensorflow',
        value: 'devsapp/start-tensorflow',
        isDeploy: true,
    },
    {
        name: '[AI] Image Prediction',
        value: 'devsapp/image-prediction-app',
        isDeploy: true,
    },
    {
        name: '[DB] MySQL Example',
        value: 'devsapp/start-fc-mysql-python',
    },
    {
        name: '[DB] MongoDB Example',
        value: 'devsapp/start-fc-mongodb-python',
    },
    {
        name: '[DB] Redis Example',
        value: 'devsapp start-fc-redis-python',
    },
    {
        name: 'Puppeteer Example',
        value: 'devsapp/puppeteer-nodejs',
    },
    {
        name: 'FFmpeg Example',
        value: 'devsapp/ffmpeg-app',
    },
    {
        name: 'Mall admin Example',
        value: 'devsapp/start-fc-mall-admin',
    },
];
var all_ali_template = (0, lodash_1.concat)(ali_template, quick_start_template, container_example_template, web_framework_template, static_website_template, best_practice_template);
exports.ALL_TEMPLATE = (0, lodash_1.concat)(first_level_template, all_ali_template, devs_template);
exports.APPLICATION_TEMPLATE = [
    {
        type: 'autocomplete',
        name: 'firstLevel',
        loop: true,
        message: 'Hello Serverless for Cloud Vendors',
        default: (0, lodash_1.first)(first_level_template).value,
        source: function (answersSoFar, input) {
            return __awaiter(this, void 0, void 0, function () {
                return __generator(this, function (_a) {
                    return [2 /*return*/, input
                            ? exports.ALL_TEMPLATE.filter(function (item) { return (0, lodash_1.lowerCase)(item.name).indexOf((0, lodash_1.lowerCase)(input)) !== -1; })
                            : first_level_template];
                });
            });
        },
    },
    {
        type: 'autocomplete',
        name: 'template',
        message: (0, utils_1.i18n)('template-tip'),
        default: (0, lodash_1.first)(devs_template).value,
        loop: true,
        when: function (answers) {
            return answers.firstLevel === 'Dev_Template_for_Serverless_Devs';
        },
        source: function (answersSoFar, input) {
            return __awaiter(this, void 0, void 0, function () {
                return __generator(this, function (_a) {
                    return [2 /*return*/, input
                            ? devs_template.filter(function (item) { return (0, lodash_1.lowerCase)(item.name).indexOf((0, lodash_1.lowerCase)(input)) !== -1; })
                            : devs_template];
                });
            });
        },
    },
    {
        type: 'autocomplete',
        name: 'ali_template',
        when: function (answers) {
            return answers.firstLevel === 'Alibaba_Cloud_Serverless';
        },
        default: (0, lodash_1.first)(ali_template).value,
        message: (0, utils_1.i18n)('app-tip'),
        source: function (answersSoFar, input) {
            return __awaiter(this, void 0, void 0, function () {
                return __generator(this, function (_a) {
                    return [2 /*return*/, input
                            ? all_ali_template.filter(function (item) { return (0, lodash_1.lowerCase)(item.name).indexOf((0, lodash_1.lowerCase)(input)) !== -1; })
                            : ali_template];
                });
            });
        },
    },
    {
        type: 'autocomplete',
        name: 'template',
        loop: true,
        when: function (answers) {
            return answers.ali_template === 'quick_start';
        },
        message: (0, utils_1.i18n)('template-tip'),
        default: (0, lodash_1.first)(quick_start_template).value,
        source: function (answersSoFar, input) {
            return __awaiter(this, void 0, void 0, function () {
                return __generator(this, function (_a) {
                    return [2 /*return*/, input
                            ? quick_start_template.filter(function (item) { return (0, lodash_1.lowerCase)(item.name).indexOf((0, lodash_1.lowerCase)(input)) !== -1; })
                            : quick_start_template];
                });
            });
        },
    },
    {
        type: 'autocomplete',
        name: 'template',
        loop: true,
        when: function (answers) {
            return answers.ali_template === 'container_example';
        },
        message: (0, utils_1.i18n)('template-tip'),
        default: (0, lodash_1.first)(container_example_template).value,
        source: function (answersSoFar, input) {
            return __awaiter(this, void 0, void 0, function () {
                return __generator(this, function (_a) {
                    return [2 /*return*/, input
                            ? container_example_template.filter(function (item) { return (0, lodash_1.lowerCase)(item.name).indexOf((0, lodash_1.lowerCase)(input)) !== -1; })
                            : container_example_template];
                });
            });
        },
    },
    {
        type: 'autocomplete',
        name: 'template',
        loop: true,
        when: function (answers) {
            return answers.ali_template === 'web_framework';
        },
        message: (0, utils_1.i18n)('template-tip'),
        default: (0, lodash_1.first)(web_framework_template).value,
        source: function (answersSoFar, input) {
            return __awaiter(this, void 0, void 0, function () {
                return __generator(this, function (_a) {
                    return [2 /*return*/, input
                            ? web_framework_template.filter(function (item) { return (0, lodash_1.lowerCase)(item.name).indexOf((0, lodash_1.lowerCase)(input)) !== -1; })
                            : web_framework_template];
                });
            });
        },
    },
    {
        type: 'autocomplete',
        name: 'template',
        loop: true,
        when: function (answers) {
            return answers.ali_template === 'static_website';
        },
        message: (0, utils_1.i18n)('template-tip'),
        default: (0, lodash_1.first)(static_website_template).value,
        source: function (answersSoFar, input) {
            return __awaiter(this, void 0, void 0, function () {
                return __generator(this, function (_a) {
                    return [2 /*return*/, input
                            ? static_website_template.filter(function (item) { return (0, lodash_1.lowerCase)(item.name).indexOf((0, lodash_1.lowerCase)(input)) !== -1; })
                            : static_website_template];
                });
            });
        },
    },
    {
        type: 'autocomplete',
        name: 'template',
        loop: true,
        when: function (answers) {
            return answers.ali_template === 'best_practice';
        },
        message: (0, utils_1.i18n)('template-tip'),
        default: (0, lodash_1.first)(best_practice_template).value,
        source: function (answersSoFar, input) {
            return __awaiter(this, void 0, void 0, function () {
                return __generator(this, function (_a) {
                    return [2 /*return*/, input
                            ? best_practice_template.filter(function (item) { return (0, lodash_1.lowerCase)(item.name).indexOf((0, lodash_1.lowerCase)(input)) !== -1; })
                            : best_practice_template];
                });
            });
        },
    },
];
exports.PROJECT_NAME_INPUT = {
    type: 'input',
    name: 'projectName',
    message: 'Please input your project name (init dir)',
    validate: function (input) {
        return input.length > 0 ? true : 'You must provide a project name';
    },
};
//# sourceMappingURL=data:application/json;base64, 