1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const format_1 = require("@ionic/cli-framework/utils/format");
|
4 | const utils_fs_1 = require("@ionic/utils-fs");
|
5 | const lodash = require("lodash");
|
6 | const constants_1 = require("../constants");
|
7 | const guards_1 = require("../guards");
|
8 | const color_1 = require("./color");
|
9 | const errors_1 = require("./errors");
|
10 | const project_1 = require("./project");
|
11 | const emoji_1 = require("./utils/emoji");
|
12 | const http_1 = require("./utils/http");
|
13 | exports.STARTER_BASE_URL = 'https://d2ql0qc7j8u4b2.cloudfront.net';
|
14 | function verifyOptions(options, { log }) {
|
15 |
|
16 | if (options['list']) {
|
17 | const headers = ['name', 'description'];
|
18 | const typeOption = options['type'] ? String(options['type']) : undefined;
|
19 | if (typeOption && !constants_1.PROJECT_TYPES.includes(typeOption)) {
|
20 | throw new errors_1.FatalException(`${color_1.input(typeOption)} is not a valid project type.\n` +
|
21 | `Valid project types are: ${getStarterProjectTypes().map(type => color_1.input(type)).join(', ')}`);
|
22 | }
|
23 | const starterTypes = typeOption ? [typeOption] : getStarterProjectTypes();
|
24 | for (const starterType of starterTypes) {
|
25 | const starters = exports.STARTER_TEMPLATES.filter(template => template.projectType === starterType);
|
26 | log.rawmsg(`\n${color_1.strong(`Starters for ${project_1.prettyProjectName(starterType)}`)} (${color_1.input(`--type=${starterType}`)})\n\n`);
|
27 | log.rawmsg(format_1.columnar(starters.map(({ name, description }) => [color_1.input(name), description || '']), { headers }));
|
28 | log.rawmsg('\n');
|
29 | }
|
30 | throw new errors_1.FatalException('', 0);
|
31 | }
|
32 | if (options['skip-deps']) {
|
33 | log.warn(`The ${color_1.input('--skip-deps')} option has been deprecated. Please use ${color_1.input('--no-deps')}.`);
|
34 | options['deps'] = false;
|
35 | }
|
36 | if (options['skip-link']) {
|
37 | log.warn(`The ${color_1.input('--skip-link')} option has been deprecated. Please use ${color_1.input('--no-link')}.`);
|
38 | options['link'] = false;
|
39 | }
|
40 | if (options['pro-id']) {
|
41 | log.warn(`The ${color_1.input('--pro-id')} option has been deprecated. Please use ${color_1.input('--id')}.`);
|
42 | options['id'] = options['pro-id'];
|
43 | }
|
44 | if (options['id']) {
|
45 | if (options['link'] === false) {
|
46 | log.warn(`The ${color_1.input('--no-link')} option has no effect with ${color_1.input('--id')}. App must be linked.`);
|
47 | }
|
48 | options['link'] = true;
|
49 | if (!options['git']) {
|
50 | log.warn(`The ${color_1.input('--no-git')} option has no effect with ${color_1.input('--id')}. Git must be used.`);
|
51 | }
|
52 | options['git'] = true;
|
53 | }
|
54 | }
|
55 | exports.verifyOptions = verifyOptions;
|
56 | async function readStarterManifest(p) {
|
57 | try {
|
58 | const manifest = await utils_fs_1.readJson(p);
|
59 | if (!guards_1.isStarterManifest(manifest)) {
|
60 | throw new Error(`${p} is not a valid starter manifest.`);
|
61 | }
|
62 | return manifest;
|
63 | }
|
64 | catch (e) {
|
65 | if (e.code === 'ENOENT') {
|
66 | throw new Error(`${p} not found`);
|
67 | }
|
68 | else if (e instanceof SyntaxError) {
|
69 | throw new Error(`${p} is not valid JSON.`);
|
70 | }
|
71 | throw e;
|
72 | }
|
73 | }
|
74 | exports.readStarterManifest = readStarterManifest;
|
75 | function getAdvertisement() {
|
76 | const choices = [getStudioAdvertisement, getAppflowAdvertisement, getAdvisoryAdvertisement, getEnterpriseAdvertisement];
|
77 | const idx = Math.floor(Math.random() * choices.length);
|
78 | return `${choices[idx]()}\n\n`;
|
79 | }
|
80 | exports.getAdvertisement = getAdvertisement;
|
81 | function getStudioAdvertisement() {
|
82 | return `
|
83 | ──────────────────────────────────────────────────────────────────
|
84 |
|
85 | ${color_1.title('Ionic Studio')}, a powerful, local editor made with ${emoji_1.emoji('💖', 'love')} by Ionic
|
86 |
|
87 | Lightning fast app creation ${emoji_1.emoji('⚡️', '')}
|
88 | Quickest & easiest way to get started with Ionic ${emoji_1.emoji('🚀', '')}
|
89 |
|
90 | ${emoji_1.emoji(' 👉 ', 'Learn more:')} ${color_1.strong('https://ion.link/studio')} ${emoji_1.emoji(' 👈', '')}
|
91 |
|
92 | ──────────────────────────────────────────────────────────────────
|
93 | `;
|
94 | }
|
95 | function getAppflowAdvertisement() {
|
96 | return `
|
97 | ──────────────────────────────────────────────────────────────
|
98 |
|
99 | ${color_1.title('Ionic Appflow')}, the mobile DevOps solution by Ionic
|
100 |
|
101 | Continuously build, deploy, and ship apps ${emoji_1.emoji('🚀', '')}
|
102 | Focus on building apps while we automate the rest ${emoji_1.emoji('🎁', '')}
|
103 |
|
104 | ${emoji_1.emoji(' 👉 ', 'Learn more:')} ${color_1.strong('https://ion.link/appflow')} ${emoji_1.emoji(' 👈', '')}
|
105 |
|
106 | ──────────────────────────────────────────────────────────────
|
107 | `;
|
108 | }
|
109 | function getAdvisoryAdvertisement() {
|
110 | return `
|
111 | ──────────────────────────────────────────────────────────────────────────────
|
112 |
|
113 | ${color_1.title('Ionic Advisory')}, tailored solutions and expert services by Ionic
|
114 |
|
115 | Go to market faster ${emoji_1.emoji('🏆', '')}
|
116 | Real-time troubleshooting and guidance ${emoji_1.emoji('💁', '')}
|
117 | Custom training, best practices, code and architecture reviews ${emoji_1.emoji('🔎', '')}
|
118 | Customized strategies for every phase of the development lifecycle ${emoji_1.emoji('🔮', '')}
|
119 |
|
120 | ${emoji_1.emoji(' 👉 ', 'Learn more:')} ${color_1.strong('https://ion.link/advisory')} ${emoji_1.emoji(' 👈', '')}
|
121 |
|
122 | ──────────────────────────────────────────────────────────────────────────────
|
123 | `;
|
124 | }
|
125 | function getEnterpriseAdvertisement() {
|
126 | return `
|
127 | ──────────────────────────────────────────────────────────────────────
|
128 |
|
129 | ${color_1.title('Ionic Enterprise')}, platform and solutions for teams by Ionic
|
130 |
|
131 | Powerful library of native APIs ${emoji_1.emoji('⚡️', '')}
|
132 | A supercharged platform for teams ${emoji_1.emoji('💪', '')}
|
133 | Bring your company's designs to life with Design Systems ${emoji_1.emoji('🎨', '')}
|
134 |
|
135 | ${emoji_1.emoji(' 👉 ', 'Learn more:')} ${color_1.strong('https://ion.link/enterprise')} ${emoji_1.emoji(' 👈', '')}
|
136 |
|
137 | ──────────────────────────────────────────────────────────────────────
|
138 | `;
|
139 | }
|
140 | async function getStarterList(config, tag = 'latest') {
|
141 | const { req } = await http_1.createRequest('GET', `${exports.STARTER_BASE_URL}/${tag === 'latest' ? '' : `${tag}/`}starters.json`, config.getHTTPConfig());
|
142 | const res = await req;
|
143 |
|
144 | return res.body;
|
145 | }
|
146 | exports.getStarterList = getStarterList;
|
147 | function getStarterProjectTypes() {
|
148 | return lodash.uniq(exports.STARTER_TEMPLATES.map(t => t.projectType));
|
149 | }
|
150 | exports.getStarterProjectTypes = getStarterProjectTypes;
|
151 | exports.SUPPORTED_FRAMEWORKS = [
|
152 | {
|
153 | name: 'Angular',
|
154 | type: 'angular',
|
155 | description: 'https://angular.io',
|
156 | },
|
157 | {
|
158 | name: 'React',
|
159 | type: 'react',
|
160 | description: 'https://reactjs.org',
|
161 | },
|
162 | ];
|
163 | exports.STARTER_TEMPLATES = [
|
164 | {
|
165 | name: 'tabs',
|
166 | projectType: 'angular',
|
167 | type: 'managed',
|
168 | description: 'A starting project with a simple tabbed interface',
|
169 | id: 'angular-official-tabs',
|
170 | },
|
171 | {
|
172 | name: 'sidemenu',
|
173 | projectType: 'angular',
|
174 | type: 'managed',
|
175 | description: 'A starting project with a side menu with navigation in the content area',
|
176 | id: 'angular-official-sidemenu',
|
177 | },
|
178 | {
|
179 | name: 'blank',
|
180 | projectType: 'angular',
|
181 | type: 'managed',
|
182 | description: 'A blank starter project',
|
183 | id: 'angular-official-blank',
|
184 | },
|
185 | {
|
186 | name: 'my-first-app',
|
187 | projectType: 'angular',
|
188 | type: 'repo',
|
189 | description: 'An example application that builds a camera with gallery',
|
190 | repo: 'https://github.com/ionic-team/photo-gallery-tutorial-ionic4',
|
191 | },
|
192 | {
|
193 | name: 'conference',
|
194 | projectType: 'angular',
|
195 | type: 'repo',
|
196 | description: 'A kitchen-sink application that shows off all Ionic has to offer',
|
197 | repo: 'https://github.com/ionic-team/ionic-conference-app',
|
198 | },
|
199 | {
|
200 | name: 'blank',
|
201 | projectType: 'react',
|
202 | type: 'managed',
|
203 | description: 'A blank starter project',
|
204 | id: 'react-official-blank',
|
205 | },
|
206 | {
|
207 | name: 'sidemenu',
|
208 | projectType: 'react',
|
209 | type: 'managed',
|
210 | description: 'A starting project with a side menu with navigation in the content area',
|
211 | id: 'react-official-sidemenu',
|
212 | },
|
213 | {
|
214 | name: 'tabs',
|
215 | projectType: 'react',
|
216 | type: 'managed',
|
217 | description: 'A starting project with a simple tabbed interface',
|
218 | id: 'react-official-tabs',
|
219 | },
|
220 | {
|
221 | name: 'conference',
|
222 | projectType: 'react',
|
223 | type: 'repo',
|
224 | description: 'A kitchen-sink application that shows off all Ionic has to offer',
|
225 | repo: 'https://github.com/ionic-team/ionic-react-conference-app',
|
226 | },
|
227 | {
|
228 | name: 'tabs',
|
229 | projectType: 'ionic-angular',
|
230 | type: 'managed',
|
231 | description: 'A starting project with a simple tabbed interface',
|
232 | id: 'ionic-angular-official-tabs',
|
233 | },
|
234 | {
|
235 | name: 'sidemenu',
|
236 | projectType: 'ionic-angular',
|
237 | type: 'managed',
|
238 | description: 'A starting project with a side menu with navigation in the content area',
|
239 | id: 'ionic-angular-official-sidemenu',
|
240 | },
|
241 | {
|
242 | name: 'blank',
|
243 | projectType: 'ionic-angular',
|
244 | type: 'managed',
|
245 | description: 'A blank starter project',
|
246 | id: 'ionic-angular-official-blank',
|
247 | },
|
248 | {
|
249 | name: 'super',
|
250 | projectType: 'ionic-angular',
|
251 | type: 'managed',
|
252 | description: 'A starting project complete with pre-built pages, providers and best practices for Ionic development.',
|
253 | id: 'ionic-angular-official-super',
|
254 | },
|
255 | {
|
256 | name: 'tutorial',
|
257 | projectType: 'ionic-angular',
|
258 | type: 'managed',
|
259 | description: 'A tutorial based project that goes along with the Ionic documentation',
|
260 | id: 'ionic-angular-official-tutorial',
|
261 | },
|
262 | {
|
263 | name: 'aws',
|
264 | projectType: 'ionic-angular',
|
265 | type: 'managed',
|
266 | description: 'AWS Mobile Hub Starter',
|
267 | id: 'ionic-angular-official-aws',
|
268 | },
|
269 | {
|
270 | name: 'tabs',
|
271 | projectType: 'ionic1',
|
272 | type: 'managed',
|
273 | description: 'A starting project for Ionic using a simple tabbed interface',
|
274 | id: 'ionic1-official-tabs',
|
275 | },
|
276 | {
|
277 | name: 'sidemenu',
|
278 | projectType: 'ionic1',
|
279 | type: 'managed',
|
280 | description: 'A starting project for Ionic using a side menu with navigation in the content area',
|
281 | id: 'ionic1-official-sidemenu',
|
282 | },
|
283 | {
|
284 | name: 'blank',
|
285 | projectType: 'ionic1',
|
286 | type: 'managed',
|
287 | description: 'A blank starter project for Ionic',
|
288 | id: 'ionic1-official-blank',
|
289 | },
|
290 | {
|
291 | name: 'maps',
|
292 | projectType: 'ionic1',
|
293 | type: 'managed',
|
294 | description: 'An Ionic starter project using Google Maps and a side menu',
|
295 | id: 'ionic1-official-maps',
|
296 | },
|
297 | ];
|