UNPKG

12.4 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4 return new (P || (P = Promise))(function (resolve, reject) {
5 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8 step((generator = generator.apply(thisArg, _arguments || [])).next());
9 });
10};
11var __generator = (this && this.__generator) || function (thisArg, body) {
12 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14 function verb(n) { return function (v) { return step([n, v]); }; }
15 function step(op) {
16 if (f) throw new TypeError("Generator is already executing.");
17 while (_) try {
18 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;
19 if (y = 0, t) op = [op[0] & 2, t.value];
20 switch (op[0]) {
21 case 0: case 1: t = op; break;
22 case 4: _.label++; return { value: op[1], done: false };
23 case 5: _.label++; y = op[1]; op = [0]; continue;
24 case 7: op = _.ops.pop(); _.trys.pop(); continue;
25 default:
26 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30 if (t[2]) _.ops.pop();
31 _.trys.pop(); continue;
32 }
33 op = body.call(thisArg, _);
34 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36 }
37};
38var __spreadArrays = (this && this.__spreadArrays) || function () {
39 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
40 for (var r = Array(s), k = 0, i = 0; i < il; i++)
41 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
42 r[k] = a[j];
43 return r;
44};
45Object.defineProperty(exports, "__esModule", { value: true });
46exports.devDependencies = exports.dependencies = void 0;
47var utils_1 = require("@omni-door/utils");
48var dependencies_stable_map_1 = require("./dependencies_stable_map");
49function dependencies(strategy, config) {
50 return __awaiter(this, void 0, void 0, function () {
51 var dependency, deps;
52 return __generator(this, function (_a) {
53 switch (_a.label) {
54 case 0: return [4 /*yield*/, utils_1.getDependency(strategy, dependencies_stable_map_1.dependencies)];
55 case 1:
56 dependency = _a.sent();
57 deps = [
58 dependency('vue'),
59 dependency('vue-router'),
60 dependency('core-js'),
61 dependency('regenerator-runtime'),
62 config.layout === 'rem' ? dependency('amfe-flexible') : ''
63 ];
64 return [2 /*return*/, {
65 depArr: __spreadArrays(deps),
66 depStr: utils_1.arr2str(deps)
67 }];
68 }
69 });
70 });
71}
72exports.dependencies = dependencies;
73function devDependencies(strategy, config) {
74 return __awaiter(this, void 0, void 0, function () {
75 var dependency, ts, test, eslint, prettier, commitlint, style, stylelint, layout, tag, loaderDependencies, babelDependencies, pluginDependencies, buildDependencies, testDependencies, testTypesDependencies, tsDependencies, eslintDependencies, prettierDependencies, commitlintDependencies, stylelintDependencies, devServerDependencies, defaultDep;
76 return __generator(this, function (_a) {
77 switch (_a.label) {
78 case 0: return [4 /*yield*/, utils_1.getDependency(strategy, dependencies_stable_map_1.devDependencies)];
79 case 1:
80 dependency = _a.sent();
81 ts = config.ts, test = config.test, eslint = config.eslint, prettier = config.prettier, commitlint = config.commitlint, style = config.style, stylelint = config.stylelint, layout = config.layout, tag = config.tag;
82 loaderDependencies = [
83 dependency('vue-loader'),
84 dependency('@vue/compiler-sfc'),
85 dependency('babel-loader'),
86 style ? dependency('style-loader') : '',
87 style ? dependency('css-loader') : '',
88 style ? dependency('postcss') : '',
89 style ? dependency('postcss-loader') : '',
90 style ? dependency('autoprefixer') : '',
91 style && layout === 'rem' ? dependency('postcss-plugin-px2rem') : '',
92 style && layout === 'viewport' ? dependency('postcss-px-to-viewport') : '',
93 (style === 'all' || style === 'less') ? dependency('less') : '',
94 (style === 'all' || style === 'less') ? dependency('less-loader') : '',
95 (style === 'all' || style === 'scss') ? dependency('sass-loader') : '',
96 (style === 'all' || style === 'scss') ? dependency('node-sass') : '',
97 dependency('url-loader'),
98 dependency('file-loader')
99 ];
100 babelDependencies = [
101 dependency('@babel/core'),
102 dependency('@babel/preset-env'),
103 ts ? dependency('@babel/preset-typescript') : ''
104 ];
105 pluginDependencies = [
106 dependency('html-webpack-plugin'),
107 dependency('terser-webpack-plugin'),
108 style ? dependency('optimize-css-assets-webpack-plugin') : '',
109 style ? dependency('mini-css-extract-plugin') : '',
110 style ? dependency('cssnano') : '',
111 dependency('webpackbar'),
112 dependency('webpack-bundle-analyzer'),
113 style ? dependency('html-inline-css-webpack-plugin') : '',
114 dependency('html-webpack-externals-plugin'),
115 ts ? dependency('fork-ts-checker-webpack-plugin') : ''
116 ];
117 buildDependencies = __spreadArrays([
118 dependency('webpack'),
119 dependency('webpack-cli'),
120 dependency('webpack-merge')
121 ], pluginDependencies, loaderDependencies, babelDependencies);
122 testDependencies = test ? [
123 dependency('vue-jest'),
124 dependency('@vue/test-utils'),
125 dependency('jest'),
126 dependency('jest-transform-stub'),
127 ts ? dependency('ts-jest') : dependency('babel-jest')
128 ] : [];
129 testTypesDependencies = test ? [
130 dependency('@types/jest')
131 ] : [];
132 tsDependencies = ts ? __spreadArrays([
133 dependency('typescript'),
134 dependency('ts-node'),
135 dependency('@types/webpack-env')
136 ], testTypesDependencies) : [];
137 eslintDependencies = eslint ? [
138 dependency('eslint'),
139 dependency('eslint-plugin-vue'),
140 dependency('vue-eslint-parser'),
141 ts ? dependency('@vue/eslint-config-typescript') : '',
142 ts ? dependency('@typescript-eslint/eslint-plugin') : '',
143 ts ? dependency('@typescript-eslint/parser') : ''
144 ] : [];
145 prettierDependencies = prettier ? [
146 dependency('prettier'),
147 eslint ? dependency('eslint-config-prettier') : '',
148 eslint ? dependency('eslint-plugin-prettier') : '',
149 eslint ? dependency('@vue/eslint-config-prettier') : '',
150 stylelint ? dependency('stylelint-config-prettier') : ''
151 ] : [];
152 commitlintDependencies = commitlint ? [
153 dependency('@commitlint/cli'),
154 dependency('husky'),
155 dependency('lint-staged')
156 ] : [];
157 stylelintDependencies = stylelint ? [
158 dependency('stylelint'),
159 dependency('stylelint-config-standard'),
160 dependency('stylelint-config-css-modules'),
161 dependency('stylelint-config-rational-order'),
162 dependency('stylelint-order'),
163 dependency('stylelint-declaration-block-no-ignored-properties'),
164 ts ? dependency('@types/vfile-message') : '',
165 style === 'all' || style === 'scss' ? dependency('stylelint-scss') : ''
166 ] : [];
167 devServerDependencies = [
168 dependency('open'),
169 dependency('ip'),
170 dependency('detect-port'),
171 dependency('express'),
172 dependency('serve-favicon'),
173 dependency('webpack-dev-middleware'),
174 dependency('webpack-hot-middleware'),
175 dependency('http-proxy-middleware')
176 ];
177 defaultDep = [
178 !tag ? dependency('@omni-door/cli') : "@omni-door/cli@" + tag,
179 dependency('del')
180 ];
181 return [2 /*return*/, {
182 devDepArr: __spreadArrays(defaultDep, buildDependencies, tsDependencies, testDependencies, eslintDependencies, prettierDependencies, commitlintDependencies, stylelintDependencies, devServerDependencies),
183 defaultDepArr: defaultDep,
184 defaultDepStr: utils_1.arr2str(defaultDep),
185 buildDepArr: buildDependencies,
186 buildDepStr: utils_1.arr2str(buildDependencies),
187 tsDepArr: tsDependencies,
188 tsDepStr: utils_1.arr2str(tsDependencies),
189 testDepArr: testDependencies,
190 testDepStr: utils_1.arr2str(testDependencies),
191 eslintDepArr: eslintDependencies,
192 eslintDepStr: utils_1.arr2str(eslintDependencies),
193 prettierDepArr: prettierDependencies,
194 prettierDepStr: utils_1.arr2str(prettierDependencies),
195 commitlintDepArr: commitlintDependencies,
196 commitlintDepStr: utils_1.arr2str(commitlintDependencies),
197 stylelintDepArr: stylelintDependencies,
198 stylelintDepStr: utils_1.arr2str(stylelintDependencies),
199 devServerDepArr: devServerDependencies,
200 devServerDepStr: utils_1.arr2str(devServerDependencies)
201 }];
202 }
203 });
204 });
205}
206exports.devDependencies = devDependencies;