app-expo-cli 1.0.7 → 1.0.9

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.
package/bun.lock CHANGED
@@ -9,6 +9,7 @@
9
9
  "degit": "^2.8.4",
10
10
  "execa": "^9.6.1",
11
11
  "fs-extra": "^11.3.3",
12
+ "simple-update-notifier": "^2.0.0",
12
13
  },
13
14
  },
14
15
  },
@@ -59,12 +60,16 @@
59
60
 
60
61
  "pretty-ms": ["pretty-ms@9.3.0", "", { "dependencies": { "parse-ms": "^4.0.0" } }, "sha512-gjVS5hOP+M3wMm5nmNOucbIrqudzs9v/57bWRHQWLYklXqoXKrVfYW2W9+glfGsqtPgpiz5WwyEEB+ksXIx3gQ=="],
61
62
 
63
+ "semver": ["semver@7.7.4", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA=="],
64
+
62
65
  "shebang-command": ["shebang-command@2.0.0", "", { "dependencies": { "shebang-regex": "^3.0.0" } }, "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA=="],
63
66
 
64
67
  "shebang-regex": ["shebang-regex@3.0.0", "", {}, "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="],
65
68
 
66
69
  "signal-exit": ["signal-exit@4.1.0", "", {}, "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw=="],
67
70
 
71
+ "simple-update-notifier": ["simple-update-notifier@2.0.0", "", { "dependencies": { "semver": "^7.5.3" } }, "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w=="],
72
+
68
73
  "sisteransi": ["sisteransi@1.0.5", "", {}, "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg=="],
69
74
 
70
75
  "strip-final-newline": ["strip-final-newline@4.0.0", "", {}, "sha512-aulFJcD6YK8V1G7iRB5tigAP4TsHBZZrOV8pjV++zdUwmeV8uzbY7yn6h9MswN62adStNZFuCIx4haBnRuMDaw=="],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "app-expo-cli",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "A powerful CLI to bootstrap Expo projects with professional architecture",
5
5
  "keywords": [
6
6
  "expo",
@@ -40,6 +40,7 @@
40
40
  "chalk": "^5.6.2",
41
41
  "degit": "^2.8.4",
42
42
  "execa": "^9.6.1",
43
- "fs-extra": "^11.3.3"
43
+ "fs-extra": "^11.3.3",
44
+ "simple-update-notifier": "^2.0.0"
44
45
  }
45
46
  }
package/src/index.js CHANGED
@@ -1,38 +1,130 @@
1
+ import chalk from "chalk";
1
2
  import fs from "fs-extra";
2
3
  import path from "path";
4
+ import updateNotifier from "simple-update-notifier";
3
5
  import { fileURLToPath } from "url";
4
6
  import { copyDefaultFiles } from "./copy-template.js";
5
7
  import { createExpoApp } from "./create-expo.js";
6
8
  import { installDependencies } from "./install-deps.js";
7
9
  import { logError } from "./utils/logger.js";
8
- const projectName = process.argv[2];
9
-
10
- if (!projectName) {
11
- logError("Please provide project name");
12
- process.exit(1);
13
- }
14
10
 
15
11
  // __dirname replacement for ESM
16
12
  const __filename = fileURLToPath(import.meta.url);
17
13
  const __dirname = path.dirname(__filename);
18
14
 
15
+ // Correct path to package.json
16
+ const pkgPath = path.join(__dirname, "..", "package.json");
17
+
19
18
  async function init() {
19
+ // Read package.json
20
+ let pkg;
21
+ try {
22
+ pkg = await fs.readJson(pkgPath);
23
+ } catch (error) {
24
+ logError("Could not find package.json.");
25
+ process.exit(1);
26
+ }
27
+
28
+ const args = process.argv.slice(2);
29
+
30
+ // 1. Handle Version Flags
31
+ if (
32
+ args.includes("--version") ||
33
+ args.includes("-v") ||
34
+ args.includes("--v")
35
+ ) {
36
+ console.log(`${chalk.cyan(pkg.name)} version: ${chalk.green(pkg.version)}`);
37
+ process.exit(0);
38
+ }
39
+
40
+ // 2. Handle Update Flags (-u or --update)
41
+ if (args.includes("--update") || args.includes("-u")) {
42
+ const notifier = updateNotifier({ pkg });
43
+
44
+ // Check if update exists (notifier returns info if update is available)
45
+ if (notifier && notifier.update) {
46
+ console.log(
47
+ chalk.yellow(
48
+ `Update available: ${chalk.bold(notifier.update.latest)}. You have ${chalk.bold(pkg.version)}.`,
49
+ ),
50
+ );
51
+ console.log(
52
+ chalk.gray(
53
+ `Run ${chalk.cyan(`npm install -g ${pkg.name}`)} to update.`,
54
+ ),
55
+ );
56
+ } else {
57
+ console.log(chalk.green("You are using the latest version. ✅"));
58
+ }
59
+ process.exit(0);
60
+ }
61
+
62
+ // 3. Handle Help Flags (--help or -h)
63
+ if (args.includes("--help") || args.includes("-h")) {
64
+ console.log(`\n${chalk.bold.cyan(pkg.name.toUpperCase())} - CLI Tool\n`);
65
+ console.log(chalk.bold("Usage:"));
66
+ console.log(chalk.gray(` npx ${pkg.name} <project-name>\n`));
67
+ console.log(chalk.bold("Options:"));
68
+ console.log(` -v, --version ${chalk.gray("Show version number")}`);
69
+ console.log(` -u, --update ${chalk.gray("Check for updates")}`);
70
+ console.log(` -h, --help ${chalk.gray("Show help guide")}`);
71
+ process.exit(0);
72
+ }
73
+
74
+ // 4. Get Project Name (Argument check)
75
+ const projectName = args[0];
76
+
77
+ if (!projectName) {
78
+ logError(
79
+ `Please provide project name. Usage: npx ${pkg.name} <project-name>`,
80
+ );
81
+ process.exit(1);
82
+ }
83
+
84
+ if (projectName.startsWith("-")) {
85
+ logError("Project name cannot start with a hyphen (-)");
86
+ process.exit(1);
87
+ }
88
+
89
+ const namePattern = /^[a-z0-9-_]+$/;
90
+ if (!namePattern.test(projectName)) {
91
+ logError(
92
+ "Invalid project name! Use only lowercase letters, numbers, hyphens, and underscores.",
93
+ );
94
+ console.log(chalk.yellow("Example: my-new-app or expo_project_1"));
95
+ process.exit(1);
96
+ }
97
+
20
98
  try {
21
99
  const projectPath = path.join(process.cwd(), projectName);
22
100
 
23
101
  if (await fs.pathExists(projectPath)) {
24
- logError("Project already exists");
102
+ logError(`Directory "${projectName}" already exists.`);
25
103
  process.exit(1);
26
104
  }
27
105
 
106
+ console.log(
107
+ chalk.blue(
108
+ `\nCreating a new Expo project in ${chalk.bold(projectPath)}...`,
109
+ ),
110
+ );
111
+
112
+ // Step 1: Create Expo App
28
113
  await createExpoApp(projectName);
29
114
 
115
+ // Step 2: Copy Template Files
30
116
  await copyDefaultFiles(projectPath, __dirname);
117
+
118
+ // Step 3: Install Dependencies
31
119
  await installDependencies(projectPath);
32
120
 
33
- console.log("\n✅ Project ready 🚀");
121
+ console.log("\n" + chalk.green.bold("✅ Project ready 🚀"));
122
+ console.log(chalk.gray(`\nNext steps:`));
123
+ console.log(chalk.cyan(` cd ${projectName}`));
124
+ console.log(chalk.cyan(` bun start`));
34
125
  } catch (err) {
35
126
  logError(err.message);
127
+ process.exit(1);
36
128
  }
37
129
  }
38
130
 
@@ -1,25 +1,20 @@
1
1
  import { api } from "../api-config/baseApi";
2
- import { IUserFetch } from "../interface/interface";
3
2
  import { tagTypes } from "../interface/tag-types";
4
3
 
4
+ const base = "auth";
5
+
5
6
  const authSlice = api.injectEndpoints({
6
7
  endpoints: (builder) => ({
7
- getProfile: builder.query<IUserFetch, unknown>({
8
+ getProfile: builder.query({
8
9
  query: () => ({
9
- url: `/auth/get-profile`,
10
- }),
11
- providesTags: [tagTypes.users],
12
- }),
13
- getOthersProfile: builder.query<IUserFetch, any>({
14
- query: (id) => ({
15
- url: `/auth/get-other-profile?id=${id}`,
10
+ url: `/${base}/get-profile`,
16
11
  }),
17
12
  providesTags: [tagTypes.users],
18
13
  }),
19
14
 
20
- updateUser: builder.mutation<any, any>({
15
+ updateUser: builder.mutation({
21
16
  query: (data) => ({
22
- url: `/auth`,
17
+ url: `/${base}`,
23
18
  headers: {
24
19
  "Content-Type": "multipart/form-data",
25
20
  },
@@ -29,40 +24,32 @@ const authSlice = api.injectEndpoints({
29
24
  invalidatesTags: [tagTypes.users],
30
25
  }),
31
26
 
32
- updateLocation: builder.mutation<any, any>({
33
- query: (data) => ({
34
- url: `/auth/location`,
35
- method: "PATCH",
36
- body: data,
37
- }),
38
- invalidatesTags: [tagTypes.users, tagTypes.post, tagTypes.activities],
39
- }),
40
- tokenCheck: builder.mutation<any, any>({
27
+ tokenCheck: builder.mutation({
41
28
  query: () => ({
42
- url: `/auth/check-token`,
29
+ url: `/${base}/check-token`,
43
30
  method: "POST",
44
31
  }),
45
32
  invalidatesTags: [tagTypes.users],
46
33
  }),
47
- login: builder.mutation<any, any>({
34
+ login: builder.mutation({
48
35
  query: (data) => ({
49
- url: `/auth/login`,
36
+ url: `/${base}/login`,
50
37
  method: "POST",
51
38
  body: data,
52
39
  }),
53
40
  invalidatesTags: [tagTypes.users],
54
41
  }),
55
- signUp: builder.mutation<any, any>({
42
+ signUp: builder.mutation({
56
43
  query: (data) => ({
57
- url: `/auth/signup`,
44
+ url: `/${base}/signup`,
58
45
  method: "POST",
59
46
  body: data,
60
47
  }),
61
48
  invalidatesTags: [tagTypes.users],
62
49
  }),
63
- emailVerify: builder.mutation<any, any>({
50
+ emailVerify: builder.mutation({
64
51
  query: (data) => ({
65
- url: `/auth/verify-email`,
52
+ url: `/${base}/verify-email`,
66
53
  method: "POST",
67
54
  body: data,
68
55
  }),
@@ -70,94 +57,42 @@ const authSlice = api.injectEndpoints({
70
57
  }),
71
58
  deleteUser: builder.mutation({
72
59
  query: (id) => ({
73
- url: `/auth/delete`,
60
+ url: `/${base}/delete`,
74
61
  method: "DELETE",
75
62
  }),
76
63
  invalidatesTags: [tagTypes.users],
77
64
  }),
78
65
 
79
- forgot: builder.mutation<any, any>({
66
+ forgot: builder.mutation({
80
67
  query: (data) => ({
81
- url: `/auth/forgot`,
68
+ url: `/${base}/forgot`,
82
69
  method: "POST",
83
70
  body: data,
84
71
  }),
85
72
  invalidatesTags: [tagTypes.users],
86
73
  }),
87
- resetPassword: builder.mutation<any, any>({
74
+ resetPassword: builder.mutation({
88
75
  query: (data) => ({
89
- url: `/auth/reset-password`,
76
+ url: `/${base}/reset-password`,
90
77
  method: "POST",
91
78
  body: data,
92
79
  }),
93
80
  invalidatesTags: [tagTypes.users],
94
81
  }),
95
- changePassword: builder.mutation<any, any>({
82
+ changePassword: builder.mutation({
96
83
  query: (data) => ({
97
- url: `/auth/change-password`,
84
+ url: `/${base}/change-password`,
98
85
  method: "POST",
99
86
  body: data,
100
87
  }),
101
88
  invalidatesTags: [tagTypes.users],
102
89
  }),
103
- // changeProfileImage: builder.mutation<any, any>({
104
- // query: (photo) => ({
105
- // url: `/auth/change-profile-photo`,
106
- // method: "POST",
107
- // body: photo,
108
- // headers: {
109
- // "Content-Type": "multipart/form-data",
110
- // },
111
- // }),
112
- // invalidatesTags: [tagTypes.users],
113
- // }),
114
-
115
- switchGhost: builder.mutation<any, any>({
116
- query: () => ({
117
- url: `/auth/switch-ghost`,
118
- method: "POST",
119
- }),
120
- invalidatesTags: [tagTypes.users],
121
- }),
122
- googleLogin: builder.mutation<any, any>({
123
- query: (data) => ({
124
- url: `/auth/login/google`,
125
- method: "POST",
126
- params: data,
127
- }),
128
- invalidatesTags: [tagTypes.users],
129
- }),
130
- googleLoginCode: builder.mutation<any, any>({
131
- query: (data) => ({
132
- url: `/auth/login/google/code?code=${data}`,
133
- method: "POST",
134
- }),
135
- invalidatesTags: [tagTypes.users],
136
- }),
137
- appleLogin: builder.mutation<any, any>({
138
- query: (data) => ({
139
- url: `/auth/login/apple`,
140
- method: "POST",
141
- params: data,
142
- }),
143
- invalidatesTags: [tagTypes.users],
144
- }),
145
-
146
- deleteUserAccount: builder.mutation<any, any>({
147
- query: (password) => ({
148
- url: `/auth/profile-delete`,
149
- method: "POST",
150
- body: password,
151
- }),
152
- invalidatesTags: [tagTypes.users],
153
- }),
154
90
  }),
155
91
  });
156
92
 
157
93
  export const {
158
94
  useGetProfileQuery,
159
95
  useDeleteUserMutation,
160
- useAppleLoginMutation,
161
96
  useEmailVerifyMutation,
162
97
  useForgotMutation,
163
98
  useSignUpMutation,
@@ -165,11 +100,5 @@ export const {
165
100
  useUpdateUserMutation,
166
101
  useTokenCheckMutation,
167
102
  useResetPasswordMutation,
168
- useGoogleLoginMutation,
169
- useDeleteUserAccountMutation,
170
- useGoogleLoginCodeMutation,
171
- useSwitchGhostMutation,
172
103
  useChangePasswordMutation,
173
- useGetOthersProfileQuery,
174
- useUpdateLocationMutation,
175
104
  } = authSlice;