Skip to content

Commit f10b6f0

Browse files
author
Abdallah Shaban
authored
Merge pull request aws-amplify#4563 from aws-amplify/react-native-picker
React native picker
2 parents 750db3a + 6910b70 commit f10b6f0

File tree

189 files changed

+3205
-2468
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+3205
-2468
lines changed

generatePathMap.cjs.js

Lines changed: 126 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,156 @@
11
// eslint-disable-next-line @typescript-eslint/no-var-requires
2-
const fs = require("fs");
2+
const fs = require('fs');
33

44
function generatePathMap(
55
obj,
66
pathMap = {
7-
"/": {
8-
page: "/",
7+
'/': {
8+
page: '/'
99
},
10-
"/404": {
11-
page: "/404",
10+
'/404': {
11+
page: '/404'
1212
},
13-
"/start": {
14-
page: "/start",
13+
'/start': {
14+
page: '/start'
1515
},
16-
"/start/q/integration/js": {
17-
page: "/start/q/integration/[integration]",
16+
'/start/q/integration/js': {
17+
page: '/start/q/integration/[integration]'
1818
},
19-
"/start/q/integration/react": {
20-
page: "/start/q/integration/[integration]",
19+
'/start/q/integration/react': {
20+
page: '/start/q/integration/[integration]'
2121
},
22-
"/start/q/integration/angular": {
23-
page: "/start/q/integration/[integration]",
22+
'/start/q/integration/angular': {
23+
page: '/start/q/integration/[integration]'
2424
},
25-
"/start/q/integration/vue": {
26-
page: "/start/q/integration/[integration]",
25+
'/start/q/integration/vue': {
26+
page: '/start/q/integration/[integration]'
2727
},
28-
"/start/q/integration/next": {
29-
page: "/start/q/integration/[integration]",
28+
'/start/q/integration/next': {
29+
page: '/start/q/integration/[integration]'
3030
},
31-
"/start/q/integration/android": {
32-
page: "/start/q/integration/[integration]",
31+
'/start/q/integration/android': {
32+
page: '/start/q/integration/[integration]'
3333
},
34-
"/start/q/integration/react-native": {
35-
page: "/start/q/integration/[integration]",
34+
'/start/q/integration/react-native': {
35+
page: '/start/q/integration/[integration]'
3636
},
37-
"/start/q/integration/ionic": {
38-
page: "/start/q/integration/[integration]",
37+
'/start/q/integration/ionic': {
38+
page: '/start/q/integration/[integration]'
3939
},
40-
"/start/q/integration/ios": {
41-
page: "/start/q/integration/[integration]",
40+
'/start/q/integration/ios': {
41+
page: '/start/q/integration/[integration]'
4242
},
43-
"/start/q/integration/flutter": {
44-
page: "/start/q/integration/[integration]",
43+
'/start/q/integration/flutter': {
44+
page: '/start/q/integration/[integration]'
4545
},
46-
"/lib/q/platform/flutter": {
47-
page: "/lib/q/platform/[platform]",
46+
'/lib/q/platform/flutter': {
47+
page: '/lib/q/platform/[platform]'
4848
},
49-
"/lib/q/platform/android": {
50-
page: "/lib/q/platform/[platform]",
49+
'/lib/q/platform/android': {
50+
page: '/lib/q/platform/[platform]'
5151
},
52-
"/lib/q/platform/ios": {
53-
page: "/lib/q/platform/[platform]",
52+
'/lib/q/platform/ios': {
53+
page: '/lib/q/platform/[platform]'
5454
},
55-
"/lib/q/platform/js": {
56-
page: "/lib/q/platform/[platform]",
55+
'/lib/q/platform/js': {
56+
page: '/lib/q/platform/[platform]'
5757
},
58-
"/ui/q/framework/react": {
59-
page: "/ui/q/framework/[framework]",
58+
'/lib/q/platform/react-native': {
59+
page: '/lib/q/platform/[platform]'
6060
},
61-
"/ui/q/framework/react-native": {
62-
page: "/ui/q/framework/[framework]",
61+
'/ui/q/framework/react': {
62+
page: '/ui/q/framework/[framework]'
6363
},
64-
"/ui/q/framework/angular": {
65-
page: "/ui/q/framework/[framework]",
64+
'/ui/q/framework/react-native': {
65+
page: '/ui/q/framework/[framework]'
6666
},
67-
"/ui/q/framework/vue": {
68-
page: "/ui/q/framework/[framework]",
67+
'/ui/q/framework/angular': {
68+
page: '/ui/q/framework/[framework]'
6969
},
70-
"/ui/q/framework/ionic": {
71-
page: "/ui/q/framework/[framework]",
70+
'/ui/q/framework/vue': {
71+
page: '/ui/q/framework/[framework]'
7272
},
73-
"/ui/q/framework/flutter": {
74-
page: "/ui/q/framework/[framework]",
73+
'/ui/q/framework/ionic': {
74+
page: '/ui/q/framework/[framework]'
7575
},
76-
"/ui/q/framework/next": {
77-
page: "/ui/q/framework/[framework]",
76+
'/ui/q/framework/flutter': {
77+
page: '/ui/q/framework/[framework]'
7878
},
79-
"/ui-legacy/q/framework/react": {
80-
page: "/ui-legacy/q/framework/[framework]",
79+
'/ui/q/framework/next': {
80+
page: '/ui/q/framework/[framework]'
8181
},
82-
"/ui-legacy/q/framework/react-native": {
83-
page: "/ui-legacy/q/framework/[framework]",
82+
'/ui-legacy/q/framework/react': {
83+
page: '/ui-legacy/q/framework/[framework]'
8484
},
85-
"/ui-legacy/q/framework/angular": {
86-
page: "/ui-legacy/q/framework/[framework]",
85+
'/ui-legacy/q/framework/react-native': {
86+
page: '/ui-legacy/q/framework/[framework]'
8787
},
88-
"/ui-legacy/q/framework/vue": {
89-
page: "/ui-legacy/q/framework/[framework]",
88+
'/ui-legacy/q/framework/angular': {
89+
page: '/ui-legacy/q/framework/[framework]'
9090
},
91-
"/ui-legacy/q/framework/ionic": {
92-
page: "/ui-legacy/q/framework/[framework]",
91+
'/ui-legacy/q/framework/vue': {
92+
page: '/ui-legacy/q/framework/[framework]'
9393
},
94-
"/ui-legacy/q/framework/next": {
95-
page: "/ui-legacy/q/framework/[framework]",
94+
'/ui-legacy/q/framework/ionic': {
95+
page: '/ui-legacy/q/framework/[framework]'
9696
},
97-
"/sdk/q/platform/js": {
98-
page: "/sdk/q/platform/[platform]",
97+
'/ui-legacy/q/framework/next': {
98+
page: '/ui-legacy/q/framework/[framework]'
9999
},
100-
"/sdk/q/platform/android": {
101-
page: "/sdk/q/platform/[platform]",
100+
'/sdk/q/platform/js': {
101+
page: '/sdk/q/platform/[platform]'
102102
},
103-
"/sdk/q/platform/ios": {
104-
page: "/sdk/q/platform/[platform]",
103+
'/sdk/q/platform/android': {
104+
page: '/sdk/q/platform/[platform]'
105105
},
106-
"/sdk/q/platform/flutter": {
107-
page: "/sdk/q/platform/[platform]",
106+
'/sdk/q/platform/ios': {
107+
page: '/sdk/q/platform/[platform]'
108108
},
109-
"/console": {
110-
page: "/console",
109+
'/sdk/q/platform/flutter': {
110+
page: '/sdk/q/platform/[platform]'
111111
},
112-
"/cli": {
113-
page: "/cli",
112+
'/console': {
113+
page: '/console'
114114
},
115-
"/cli/function": {
116-
page: "/cli/function",
115+
'/cli': {
116+
page: '/cli'
117117
},
118-
},
118+
'/cli/function': {
119+
page: '/cli/function'
120+
}
121+
}
119122
) {
120123
for (const [_, value] of Object.entries(obj)) {
121-
const {items, filters, route, productRoot} = value;
124+
const { items, filters, route, productRoot } = value;
122125

123126
if (productRoot) {
124-
const {route} = productRoot;
127+
const { route } = productRoot;
125128

126-
let filterKind = "";
127-
if (route.startsWith("/cli") || route.startsWith("/console")) {
128-
filterKind = "";
129-
} else if (route.startsWith("/lib")) {
130-
filterKind = "platform";
131-
} else if (route.startsWith("/sdk")) {
132-
filterKind = "platform";
133-
} else if (route.startsWith("/ui")) {
134-
filterKind = "framework";
135-
} else if (route.startsWith("/guides")) {
136-
filterKind = "platform";
137-
} else if (route.startsWith("/start")) {
138-
filterKind = "integration";
129+
let filterKind = '';
130+
if (route.startsWith('/cli') || route.startsWith('/console')) {
131+
filterKind = '';
132+
} else if (route.startsWith('/lib')) {
133+
filterKind = 'platform';
134+
} else if (route.startsWith('/sdk')) {
135+
filterKind = 'platform';
136+
} else if (route.startsWith('/ui')) {
137+
filterKind = 'framework';
138+
} else if (route.startsWith('/guides')) {
139+
filterKind = 'platform';
140+
} else if (route.startsWith('/start')) {
141+
filterKind = 'integration';
139142
}
140143

141-
if (filterKind !== "") {
142-
const aOrAn = "aeiou".includes(filterKind[0]) ? "an" : "a";
144+
if (filterKind !== '') {
145+
const aOrAn = 'aeiou'.includes(filterKind[0]) ? 'an' : 'a';
143146
pathMap[route] = {
144-
page: "/ChooseFilterPage",
147+
page: '/ChooseFilterPage',
145148
query: {
146149
address: route,
147-
directoryPath: "/ChooseFilterPage",
150+
directoryPath: '/ChooseFilterPage',
148151
filterKind: filterKind,
149-
message: `Choose ${aOrAn} ${filterKind}:`,
150-
},
152+
message: `Choose ${aOrAn} ${filterKind}:`
153+
}
151154
};
152155
}
153156
}
@@ -157,12 +160,12 @@ function generatePathMap(
157160
}
158161

159162
if (!filters || !filters.length) {
160-
let page = "";
163+
let page = '';
161164
const mdxSrc = `${route}.mdx`;
162165
const tsxSrc = `${route}.tsx`;
163166

164-
const maybeMDXFile = "./src/pages" + mdxSrc;
165-
const maybeTSXFile = "./src/pages" + tsxSrc;
167+
const maybeMDXFile = './src/pages' + mdxSrc;
168+
const maybeTSXFile = './src/pages' + tsxSrc;
166169

167170
if (fs.existsSync(maybeTSXFile)) {
168171
page = tsxSrc;
@@ -172,18 +175,18 @@ function generatePathMap(
172175

173176
if (page.length) {
174177
pathMap[route] = {
175-
page: route,
178+
page: route
176179
};
177180
}
178181

179182
continue;
180183
}
181184

182-
let page = "";
183-
let routeType = "";
184-
["platform", "framework", "integration"].forEach((type) => {
185+
let page = '';
186+
let routeType = '';
187+
['platform', 'framework', 'integration'].forEach((type) => {
185188
const src = `${route}/q/${type}/[${type}].mdx`;
186-
const maybeFile = "./src/pages" + src;
189+
const maybeFile = './src/pages' + src;
187190
if (fs.existsSync(maybeFile)) {
188191
page = src;
189192
routeType = type;
@@ -197,35 +200,35 @@ function generatePathMap(
197200
// generate for _all_ filters -- unsupported filters will just generate ChooseFilterPages, which is what we want
198201
// ideally misspellings would also map to a ChooseFilterPage, but this doesn't work with SSG
199202
let allFilters = filters;
200-
if (routeType !== "") {
203+
if (routeType !== '') {
201204
allFilters = [
202-
"js",
203-
"android",
204-
"ios",
205-
"flutter",
206-
"react",
207-
"react-native",
208-
"angular",
209-
"vue",
210-
"ionic",
211-
"next",
205+
'js',
206+
'android',
207+
'ios',
208+
'flutter',
209+
'react',
210+
'react-native',
211+
'angular',
212+
'vue',
213+
'ionic',
214+
'next'
212215
];
213216
}
214217
allFilters.forEach((filter) => {
215-
pathMap[route + "/q/" + routeType + "/" + filter] = {
216-
page: `${route}/q/${routeType}/[${routeType}]`,
218+
pathMap[route + '/q/' + routeType + '/' + filter] = {
219+
page: `${route}/q/${routeType}/[${routeType}]`
217220
};
218221
});
219-
const aOrAn = "aeiou".includes(routeType[0]) ? "an" : "a";
222+
const aOrAn = 'aeiou'.includes(routeType[0]) ? 'an' : 'a';
220223
pathMap[route] = {
221-
page: "/ChooseFilterPage",
224+
page: '/ChooseFilterPage',
222225
query: {
223226
address: route,
224-
directoryPath: "/ChooseFilterPage",
227+
directoryPath: '/ChooseFilterPage',
225228
filterKind: routeType,
226229
filters: filters,
227-
message: `Choose ${aOrAn} ${routeType}:`,
228-
},
230+
message: `Choose ${aOrAn} ${routeType}:`
231+
}
229232
};
230233
}
231234
return pathMap;

0 commit comments

Comments
 (0)