1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.unsupportedTemplate = exports.supportedTemplates = exports.installableProjectTypes = exports.SupportedLanguage = exports.SUPPORTED_FRAMEWORKS = exports.ProjectType = exports.CoreBuilder = void 0;
|
7 |
|
8 | var _semver = require("@storybook/semver");
|
9 |
|
10 | function ltMajor(versionRange, major) {
|
11 |
|
12 | return (0, _semver.validRange)(versionRange) && (0, _semver.minVersion)(versionRange).major < major;
|
13 | }
|
14 |
|
15 | function eqMajor(versionRange, major) {
|
16 |
|
17 | return (0, _semver.validRange)(versionRange) && (0, _semver.minVersion)(versionRange).major === major;
|
18 | }
|
19 |
|
20 |
|
21 | let ProjectType;
|
22 | exports.ProjectType = ProjectType;
|
23 |
|
24 | (function (ProjectType) {
|
25 | ProjectType["UNDETECTED"] = "UNDETECTED";
|
26 | ProjectType["UNSUPPORTED"] = "UNSUPPORTED";
|
27 | ProjectType["REACT_SCRIPTS"] = "REACT_SCRIPTS";
|
28 | ProjectType["METEOR"] = "METEOR";
|
29 | ProjectType["REACT"] = "REACT";
|
30 | ProjectType["REACT_NATIVE"] = "REACT_NATIVE";
|
31 | ProjectType["REACT_PROJECT"] = "REACT_PROJECT";
|
32 | ProjectType["WEBPACK_REACT"] = "WEBPACK_REACT";
|
33 | ProjectType["VUE"] = "VUE";
|
34 | ProjectType["VUE3"] = "VUE3";
|
35 | ProjectType["SFC_VUE"] = "SFC_VUE";
|
36 | ProjectType["ANGULAR"] = "ANGULAR";
|
37 | ProjectType["EMBER"] = "EMBER";
|
38 | ProjectType["ALREADY_HAS_STORYBOOK"] = "ALREADY_HAS_STORYBOOK";
|
39 | ProjectType["UPDATE_PACKAGE_ORGANIZATIONS"] = "UPDATE_PACKAGE_ORGANIZATIONS";
|
40 | ProjectType["WEB_COMPONENTS"] = "WEB_COMPONENTS";
|
41 | ProjectType["MITHRIL"] = "MITHRIL";
|
42 | ProjectType["MARIONETTE"] = "MARIONETTE";
|
43 | ProjectType["MARKO"] = "MARKO";
|
44 | ProjectType["HTML"] = "HTML";
|
45 | ProjectType["RIOT"] = "RIOT";
|
46 | ProjectType["PREACT"] = "PREACT";
|
47 | ProjectType["SVELTE"] = "SVELTE";
|
48 | ProjectType["RAX"] = "RAX";
|
49 | ProjectType["AURELIA"] = "AURELIA";
|
50 | ProjectType["SERVER"] = "SERVER";
|
51 | })(ProjectType || (exports.ProjectType = ProjectType = {}));
|
52 |
|
53 | const SUPPORTED_FRAMEWORKS = ['react', 'react-native', 'vue', 'vue3', 'angular', 'mithril', 'riot', 'ember', 'marionette', 'marko', 'meteor', 'preact', 'svelte', 'rax', 'aurelia'];
|
54 | exports.SUPPORTED_FRAMEWORKS = SUPPORTED_FRAMEWORKS;
|
55 | let CoreBuilder;
|
56 |
|
57 | exports.CoreBuilder = CoreBuilder;
|
58 |
|
59 | (function (CoreBuilder) {
|
60 | CoreBuilder["Webpack4"] = "webpack4";
|
61 | CoreBuilder["Webpack5"] = "webpack5";
|
62 | CoreBuilder["Vite"] = "vite";
|
63 | })(CoreBuilder || (exports.CoreBuilder = CoreBuilder = {}));
|
64 |
|
65 | let SupportedLanguage;
|
66 | exports.SupportedLanguage = SupportedLanguage;
|
67 |
|
68 | (function (SupportedLanguage) {
|
69 | SupportedLanguage["JAVASCRIPT"] = "javascript";
|
70 | SupportedLanguage["TYPESCRIPT"] = "typescript";
|
71 | })(SupportedLanguage || (exports.SupportedLanguage = SupportedLanguage = {}));
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | const supportedTemplates = [{
|
81 | preset: ProjectType.METEOR,
|
82 | files: ['.meteor'],
|
83 | matcherFunction: ({
|
84 | files
|
85 | }) => {
|
86 | return files.every(Boolean);
|
87 | }
|
88 | }, {
|
89 | preset: ProjectType.SFC_VUE,
|
90 | dependencies: {
|
91 | 'vue-loader': versionRange => ltMajor(versionRange, 16),
|
92 | vuetify: versionRange => ltMajor(versionRange, 3)
|
93 | },
|
94 | matcherFunction: ({
|
95 | dependencies
|
96 | }) => {
|
97 | return dependencies.some(Boolean);
|
98 | }
|
99 | }, {
|
100 | preset: ProjectType.VUE,
|
101 |
|
102 | dependencies: {
|
103 | vue: versionRange => ltMajor(versionRange, 3),
|
104 | nuxt: versionRange => ltMajor(versionRange, 3)
|
105 | },
|
106 | matcherFunction: ({
|
107 | dependencies
|
108 | }) => {
|
109 | return dependencies.some(Boolean);
|
110 | }
|
111 | }, {
|
112 | preset: ProjectType.VUE3,
|
113 | dependencies: {
|
114 |
|
115 | vue: versionRange => versionRange === 'next' || eqMajor(versionRange, 3)
|
116 | },
|
117 | matcherFunction: ({
|
118 | dependencies
|
119 | }) => {
|
120 | return dependencies.some(Boolean);
|
121 | }
|
122 | }, {
|
123 | preset: ProjectType.EMBER,
|
124 | dependencies: ['ember-cli'],
|
125 | matcherFunction: ({
|
126 | dependencies
|
127 | }) => {
|
128 | return dependencies.every(Boolean);
|
129 | }
|
130 | }, {
|
131 | preset: ProjectType.REACT_PROJECT,
|
132 | peerDependencies: ['react'],
|
133 | matcherFunction: ({
|
134 | peerDependencies
|
135 | }) => {
|
136 | return peerDependencies.every(Boolean);
|
137 | }
|
138 | }, {
|
139 | preset: ProjectType.REACT_NATIVE,
|
140 | dependencies: ['react-native', 'react-native-scripts'],
|
141 | matcherFunction: ({
|
142 | dependencies
|
143 | }) => {
|
144 | return dependencies.some(Boolean);
|
145 | }
|
146 | }, {
|
147 | preset: ProjectType.REACT_SCRIPTS,
|
148 |
|
149 | files: ['/node_modules/.bin/react-scripts'],
|
150 |
|
151 | dependencies: ['react-scripts'],
|
152 | matcherFunction: ({
|
153 | dependencies,
|
154 | files
|
155 | }) => {
|
156 | return dependencies.every(Boolean) || files.every(Boolean);
|
157 | }
|
158 | }, {
|
159 | preset: ProjectType.WEBPACK_REACT,
|
160 | dependencies: ['react', 'webpack'],
|
161 | matcherFunction: ({
|
162 | dependencies
|
163 | }) => {
|
164 | return dependencies.every(Boolean);
|
165 | }
|
166 | }, {
|
167 | preset: ProjectType.REACT,
|
168 | dependencies: ['react'],
|
169 | matcherFunction: ({
|
170 | dependencies
|
171 | }) => {
|
172 | return dependencies.every(Boolean);
|
173 | }
|
174 | }, {
|
175 | preset: ProjectType.ANGULAR,
|
176 | dependencies: ['@angular/core'],
|
177 | matcherFunction: ({
|
178 | dependencies
|
179 | }) => {
|
180 | return dependencies.every(Boolean);
|
181 | }
|
182 | }, {
|
183 | preset: ProjectType.WEB_COMPONENTS,
|
184 | dependencies: ['lit-element', 'lit-html', 'lit'],
|
185 | matcherFunction: ({
|
186 | dependencies
|
187 | }) => {
|
188 | return dependencies.some(Boolean);
|
189 | }
|
190 | }, {
|
191 | preset: ProjectType.MITHRIL,
|
192 | dependencies: ['mithril'],
|
193 | matcherFunction: ({
|
194 | dependencies
|
195 | }) => {
|
196 | return dependencies.every(Boolean);
|
197 | }
|
198 | }, {
|
199 | preset: ProjectType.MARIONETTE,
|
200 | dependencies: ['backbone.marionette'],
|
201 | matcherFunction: ({
|
202 | dependencies
|
203 | }) => {
|
204 | return dependencies.every(Boolean);
|
205 | }
|
206 | }, {
|
207 | preset: ProjectType.MARKO,
|
208 | dependencies: ['marko'],
|
209 | matcherFunction: ({
|
210 | dependencies
|
211 | }) => {
|
212 | return dependencies.every(Boolean);
|
213 | }
|
214 | }, {
|
215 | preset: ProjectType.RIOT,
|
216 | dependencies: ['riot'],
|
217 | matcherFunction: ({
|
218 | dependencies
|
219 | }) => {
|
220 | return dependencies.every(Boolean);
|
221 | }
|
222 | }, {
|
223 | preset: ProjectType.PREACT,
|
224 | dependencies: ['preact'],
|
225 | matcherFunction: ({
|
226 | dependencies
|
227 | }) => {
|
228 | return dependencies.every(Boolean);
|
229 | }
|
230 | }, {
|
231 | preset: ProjectType.SVELTE,
|
232 | dependencies: ['svelte'],
|
233 | matcherFunction: ({
|
234 | dependencies
|
235 | }) => {
|
236 | return dependencies.every(Boolean);
|
237 | }
|
238 | }, {
|
239 | preset: ProjectType.RAX,
|
240 | dependencies: ['rax'],
|
241 | matcherFunction: ({
|
242 | dependencies
|
243 | }) => {
|
244 | return dependencies.every(Boolean);
|
245 | }
|
246 | }, {
|
247 | preset: ProjectType.AURELIA,
|
248 | dependencies: ['aurelia-bootstrapper'],
|
249 | matcherFunction: ({
|
250 | dependencies
|
251 | }) => {
|
252 | return dependencies.every(Boolean);
|
253 | }
|
254 | }];
|
255 |
|
256 |
|
257 |
|
258 | exports.supportedTemplates = supportedTemplates;
|
259 | const unsupportedTemplate = {
|
260 | preset: ProjectType.UNSUPPORTED,
|
261 | dependencies: {
|
262 |
|
263 | nuxt: versionRange => eqMajor(versionRange, 3)
|
264 | },
|
265 | matcherFunction: ({
|
266 | dependencies
|
267 | }) => {
|
268 | return dependencies.some(Boolean);
|
269 | }
|
270 | };
|
271 | exports.unsupportedTemplate = unsupportedTemplate;
|
272 | const notInstallableProjectTypes = [ProjectType.UNDETECTED, ProjectType.UNSUPPORTED, ProjectType.ALREADY_HAS_STORYBOOK, ProjectType.UPDATE_PACKAGE_ORGANIZATIONS];
|
273 | const installableProjectTypes = Object.values(ProjectType).filter(type => !notInstallableProjectTypes.includes(type)).map(type => type.toLowerCase());
|
274 | exports.installableProjectTypes = installableProjectTypes; |
\ | No newline at end of file |