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 = [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 getAppflowAdvertisement() {
|
82 | return `
|
83 | ──────────────────────────────────────────────────────────────
|
84 |
|
85 | ${color_1.title('Ionic Appflow')}, the mobile DevOps solution by Ionic
|
86 |
|
87 | Continuously build, deploy, and ship apps ${emoji_1.emoji('🚀', '')}
|
88 | Focus on building apps while we automate the rest ${emoji_1.emoji('🎁', '')}
|
89 |
|
90 | ${emoji_1.emoji(' 👉 ', 'Learn more:')} ${color_1.strong('https://ion.link/appflow')} ${emoji_1.emoji(' 👈', '')}
|
91 |
|
92 | ──────────────────────────────────────────────────────────────
|
93 | `;
|
94 | }
|
95 | function getAdvisoryAdvertisement() {
|
96 | return `
|
97 | ──────────────────────────────────────────────────────────────────────────────
|
98 |
|
99 | ${color_1.title('Ionic Advisory')}, tailored solutions and expert services by Ionic
|
100 |
|
101 | Go to market faster ${emoji_1.emoji('🏆', '')}
|
102 | Real-time troubleshooting and guidance ${emoji_1.emoji('💁', '')}
|
103 | Custom training, best practices, code and architecture reviews ${emoji_1.emoji('🔎', '')}
|
104 | Customized strategies for every phase of the development lifecycle ${emoji_1.emoji('🔮', '')}
|
105 |
|
106 | ${emoji_1.emoji(' 👉 ', 'Learn more:')} ${color_1.strong('https://ion.link/advisory')} ${emoji_1.emoji(' 👈', '')}
|
107 |
|
108 | ──────────────────────────────────────────────────────────────────────────────
|
109 | `;
|
110 | }
|
111 | function getEnterpriseAdvertisement() {
|
112 | return `
|
113 | ──────────────────────────────────────────────────────────────────────
|
114 |
|
115 | ${color_1.title('Ionic Enterprise')}, platform and solutions for teams by Ionic
|
116 |
|
117 | Powerful library of native APIs ${emoji_1.emoji('⚡️', '')}
|
118 | A supercharged platform for teams ${emoji_1.emoji('💪', '')}
|
119 |
|
120 | ${emoji_1.emoji(' 👉 ', 'Learn more:')} ${color_1.strong('https://ion.link/enterprise')} ${emoji_1.emoji(' 👈', '')}
|
121 |
|
122 | ──────────────────────────────────────────────────────────────────────
|
123 | `;
|
124 | }
|
125 | async function getStarterList(config, tag = 'latest') {
|
126 | const { req } = await http_1.createRequest('GET', `${exports.STARTER_BASE_URL}/${tag === 'latest' ? '' : `${tag}/`}starters.json`, config.getHTTPConfig());
|
127 | const res = await req;
|
128 |
|
129 | return res.body;
|
130 | }
|
131 | exports.getStarterList = getStarterList;
|
132 | function getStarterProjectTypes() {
|
133 | return lodash.uniq(exports.STARTER_TEMPLATES.map(t => t.projectType));
|
134 | }
|
135 | exports.getStarterProjectTypes = getStarterProjectTypes;
|
136 | exports.SUPPORTED_FRAMEWORKS = [
|
137 | {
|
138 | name: 'Angular',
|
139 | type: 'angular',
|
140 | description: 'https://angular.io',
|
141 | },
|
142 | {
|
143 | name: 'React',
|
144 | type: 'react',
|
145 | description: 'https://reactjs.org',
|
146 | },
|
147 | ];
|
148 | exports.STARTER_TEMPLATES = [
|
149 | {
|
150 | name: 'tabs',
|
151 | projectType: 'angular',
|
152 | type: 'managed',
|
153 | description: 'A starting project with a simple tabbed interface',
|
154 | id: 'angular-official-tabs',
|
155 | },
|
156 | {
|
157 | name: 'sidemenu',
|
158 | projectType: 'angular',
|
159 | type: 'managed',
|
160 | description: 'A starting project with a side menu with navigation in the content area',
|
161 | id: 'angular-official-sidemenu',
|
162 | },
|
163 | {
|
164 | name: 'blank',
|
165 | projectType: 'angular',
|
166 | type: 'managed',
|
167 | description: 'A blank starter project',
|
168 | id: 'angular-official-blank',
|
169 | },
|
170 | {
|
171 | name: 'list',
|
172 | projectType: 'angular',
|
173 | type: 'managed',
|
174 | description: 'A starting project with a list',
|
175 | id: 'angular-official-list',
|
176 | },
|
177 | {
|
178 | name: 'my-first-app',
|
179 | projectType: 'angular',
|
180 | type: 'repo',
|
181 | description: 'An example application that builds a camera with gallery',
|
182 | repo: 'https://github.com/ionic-team/photo-gallery-capacitor-ng',
|
183 | },
|
184 | {
|
185 | name: 'conference',
|
186 | projectType: 'angular',
|
187 | type: 'repo',
|
188 | description: 'A kitchen-sink application that shows off all Ionic has to offer',
|
189 | repo: 'https://github.com/ionic-team/ionic-conference-app',
|
190 | },
|
191 | {
|
192 | name: 'blank',
|
193 | projectType: 'react',
|
194 | type: 'managed',
|
195 | description: 'A blank starter project',
|
196 | id: 'react-official-blank',
|
197 | },
|
198 | {
|
199 | name: 'list',
|
200 | projectType: 'react',
|
201 | type: 'managed',
|
202 | description: 'A starting project with a list',
|
203 | id: 'react-official-list',
|
204 | },
|
205 | {
|
206 | name: 'my-first-app',
|
207 | projectType: 'react',
|
208 | type: 'repo',
|
209 | description: 'An example application that builds a camera with gallery',
|
210 | repo: 'https://github.com/ionic-team/photo-gallery-capacitor-react',
|
211 | },
|
212 | {
|
213 | name: 'sidemenu',
|
214 | projectType: 'react',
|
215 | type: 'managed',
|
216 | description: 'A starting project with a side menu with navigation in the content area',
|
217 | id: 'react-official-sidemenu',
|
218 | },
|
219 | {
|
220 | name: 'tabs',
|
221 | projectType: 'react',
|
222 | type: 'managed',
|
223 | description: 'A starting project with a simple tabbed interface',
|
224 | id: 'react-official-tabs',
|
225 | },
|
226 | {
|
227 | name: 'conference',
|
228 | projectType: 'react',
|
229 | type: 'repo',
|
230 | description: 'A kitchen-sink application that shows off all Ionic has to offer',
|
231 | repo: 'https://github.com/ionic-team/ionic-react-conference-app',
|
232 | },
|
233 | {
|
234 | name: 'tabs',
|
235 | projectType: 'ionic-angular',
|
236 | type: 'managed',
|
237 | description: 'A starting project with a simple tabbed interface',
|
238 | id: 'ionic-angular-official-tabs',
|
239 | },
|
240 | {
|
241 | name: 'sidemenu',
|
242 | projectType: 'ionic-angular',
|
243 | type: 'managed',
|
244 | description: 'A starting project with a side menu with navigation in the content area',
|
245 | id: 'ionic-angular-official-sidemenu',
|
246 | },
|
247 | {
|
248 | name: 'blank',
|
249 | projectType: 'ionic-angular',
|
250 | type: 'managed',
|
251 | description: 'A blank starter project',
|
252 | id: 'ionic-angular-official-blank',
|
253 | },
|
254 | {
|
255 | name: 'super',
|
256 | projectType: 'ionic-angular',
|
257 | type: 'managed',
|
258 | description: 'A starting project complete with pre-built pages, providers and best practices for Ionic development.',
|
259 | id: 'ionic-angular-official-super',
|
260 | },
|
261 | {
|
262 | name: 'tutorial',
|
263 | projectType: 'ionic-angular',
|
264 | type: 'managed',
|
265 | description: 'A tutorial based project that goes along with the Ionic documentation',
|
266 | id: 'ionic-angular-official-tutorial',
|
267 | },
|
268 | {
|
269 | name: 'aws',
|
270 | projectType: 'ionic-angular',
|
271 | type: 'managed',
|
272 | description: 'AWS Mobile Hub Starter',
|
273 | id: 'ionic-angular-official-aws',
|
274 | },
|
275 | {
|
276 | name: 'tabs',
|
277 | projectType: 'ionic1',
|
278 | type: 'managed',
|
279 | description: 'A starting project for Ionic using a simple tabbed interface',
|
280 | id: 'ionic1-official-tabs',
|
281 | },
|
282 | {
|
283 | name: 'sidemenu',
|
284 | projectType: 'ionic1',
|
285 | type: 'managed',
|
286 | description: 'A starting project for Ionic using a side menu with navigation in the content area',
|
287 | id: 'ionic1-official-sidemenu',
|
288 | },
|
289 | {
|
290 | name: 'blank',
|
291 | projectType: 'ionic1',
|
292 | type: 'managed',
|
293 | description: 'A blank starter project for Ionic',
|
294 | id: 'ionic1-official-blank',
|
295 | },
|
296 | {
|
297 | name: 'maps',
|
298 | projectType: 'ionic1',
|
299 | type: 'managed',
|
300 | description: 'An Ionic starter project using Google Maps and a side menu',
|
301 | id: 'ionic1-official-maps',
|
302 | },
|
303 | ];
|