@highbeek/create-rnstarterkit 1.0.2-beta.0 → 1.0.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -39,14 +39,14 @@ async function main() {
|
|
|
39
39
|
type: "rawlist",
|
|
40
40
|
name: "state",
|
|
41
41
|
message: "State management?",
|
|
42
|
-
choices: ["None", "Redux Toolkit", "Zustand"],
|
|
43
|
-
default: "
|
|
42
|
+
choices: ["None", "Context API", "Redux Toolkit", "Zustand"],
|
|
43
|
+
default: "Context API",
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
type: "rawlist",
|
|
47
47
|
name: "dataFetching",
|
|
48
48
|
message: "Data fetching library?",
|
|
49
|
-
choices: ["None", "React Query", "SWR"
|
|
49
|
+
choices: ["None", "React Query", "SWR"],
|
|
50
50
|
default: "None",
|
|
51
51
|
},
|
|
52
52
|
{
|
|
@@ -75,6 +75,14 @@ async function main() {
|
|
|
75
75
|
message: "Include API client scaffold?",
|
|
76
76
|
default: true,
|
|
77
77
|
},
|
|
78
|
+
{
|
|
79
|
+
type: "rawlist",
|
|
80
|
+
name: "apiClientType",
|
|
81
|
+
message: "API client transport?",
|
|
82
|
+
choices: ["Fetch", "Axios"],
|
|
83
|
+
default: "Fetch",
|
|
84
|
+
when: (answers) => answers.apiClient,
|
|
85
|
+
},
|
|
78
86
|
{
|
|
79
87
|
type: "confirm",
|
|
80
88
|
name: "ci",
|
|
@@ -8,7 +8,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const execa_1 = require("execa");
|
|
10
10
|
async function generateApp(options) {
|
|
11
|
-
const { platform, projectName, auth, apiClient, absoluteImports, state, dataFetching, validation, storage, typescript, } = options;
|
|
11
|
+
const { platform, projectName, auth, apiClient, absoluteImports, state, dataFetching, validation, storage, typescript, apiClientType, } = options;
|
|
12
12
|
const templateRoot = await resolveTemplateRoot();
|
|
13
13
|
const templateFolder = platform === "Expo" ? "expo-base" : "cli-base";
|
|
14
14
|
const templatePath = path_1.default.join(templateRoot, templateFolder);
|
|
@@ -45,7 +45,8 @@ async function generateApp(options) {
|
|
|
45
45
|
if (storage === "MMKV")
|
|
46
46
|
await copyOptionalModule("mmkv", targetPath);
|
|
47
47
|
await configureAbsoluteImports(targetPath, platform, absoluteImports);
|
|
48
|
-
await configureDataFetching(targetPath, dataFetching
|
|
48
|
+
await configureDataFetching(targetPath, dataFetching);
|
|
49
|
+
await configureApiClientTransport(targetPath, apiClient, apiClientType);
|
|
49
50
|
await configureValidation(targetPath, validation);
|
|
50
51
|
if (typescript) {
|
|
51
52
|
const tsconfigTemplate = path_1.default.join(templateRoot, "optional/tsconfig.json");
|
|
@@ -175,7 +176,7 @@ async function configureAbsoluteImports(targetPath, platform, absoluteImports) {
|
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
|
-
async function configureDataFetching(targetPath, dataFetching
|
|
179
|
+
async function configureDataFetching(targetPath, dataFetching) {
|
|
179
180
|
if (dataFetching === "React Query") {
|
|
180
181
|
await ensureDependencies(targetPath, {
|
|
181
182
|
dependencies: {
|
|
@@ -194,7 +195,9 @@ export const queryClient = new QueryClient();
|
|
|
194
195
|
},
|
|
195
196
|
});
|
|
196
197
|
}
|
|
197
|
-
|
|
198
|
+
}
|
|
199
|
+
async function configureApiClientTransport(targetPath, apiClient, apiClientType) {
|
|
200
|
+
if (apiClient && apiClientType === "Axios") {
|
|
198
201
|
await ensureDependencies(targetPath, {
|
|
199
202
|
dependencies: {
|
|
200
203
|
axios: "^1.12.2",
|
|
@@ -208,8 +211,7 @@ export const axiosClient = axios.create({
|
|
|
208
211
|
timeout: 15000,
|
|
209
212
|
});
|
|
210
213
|
`);
|
|
211
|
-
|
|
212
|
-
await fs_extra_1.default.writeFile(path_1.default.join(targetPath, "api/client.ts"), `import axios from "axios";
|
|
214
|
+
await fs_extra_1.default.writeFile(path_1.default.join(targetPath, "api/client.ts"), `import axios from "axios";
|
|
213
215
|
import { API_BASE_URL } from "../config/env";
|
|
214
216
|
|
|
215
217
|
export class ApiError extends Error {
|
|
@@ -291,7 +293,6 @@ export const apiClient = {
|
|
|
291
293
|
request<T>("DELETE", path, undefined, options),
|
|
292
294
|
};
|
|
293
295
|
`, "utf8");
|
|
294
|
-
}
|
|
295
296
|
}
|
|
296
297
|
}
|
|
297
298
|
async function configureValidation(targetPath, validation) {
|
package/package.json
CHANGED