rnassist 1.0.0 → 1.0.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.
Files changed (3) hide show
  1. package/index.js +17 -2
  2. package/metro.js +9 -5
  3. package/package.json +2 -1
package/index.js CHANGED
@@ -10,8 +10,22 @@ const { llmService } = require("./llm");
10
10
  const { default: ora } = require("ora");
11
11
  const { scrapping } = require("./scrapper");
12
12
  const bugsJson = require("./bugs.json")
13
+ const { execSync } = require('child_process')
13
14
  require("dotenv").config({ quiet: true });
14
-
15
+ function checkForUpdates() {
16
+ try {
17
+ const latest = execSync('npm show rnassist version').toString().trim()
18
+ const current = require('./package.json').version
19
+ if (latest !== current) {
20
+ console.log(chalk.yellow(`New version available: ${latest}. Updating...`))
21
+ execSync('npm install -g rnassist', { stdio: 'inherit' })
22
+ console.log(chalk.green('Updated! Please re-run your command.'))
23
+ process.exit(0)
24
+ }
25
+ } catch(e) {
26
+ // silently fail if no internet
27
+ }
28
+ }
15
29
  async function isReactNativeApp(folder) {
16
30
  try {
17
31
  const hasPackage = await fs.readFile(
@@ -28,12 +42,13 @@ async function isReactNativeApp(folder) {
28
42
  }
29
43
 
30
44
  async function main() {
45
+ checkForUpdates();
31
46
  const isRN = await isReactNativeApp(process.cwd());
32
47
  if (!isRN) {
33
48
  console.log("This is not a React Native project.");
34
49
  process.exit();
35
50
  }
36
- connectMetro();
51
+ await connectMetro();
37
52
  const scannerData = await getData();
38
53
  const program = new Command();
39
54
  program.command("update-bugs").description("updating bugs from react native").action(()=> scrapping())
package/metro.js CHANGED
@@ -11,7 +11,12 @@ function getDebuggerUrl() {
11
11
  if (list.length > 0) {
12
12
  resolve(list[0].webSocketDebuggerUrl);
13
13
  } else {
14
- reject(new Error("No devices found"));
14
+ console.log(
15
+ chalk.red(
16
+ "Metro is not running. Start your app first with 'npx expo start' or 'npx react-native start'",
17
+ ),
18
+ );
19
+ process.exit(1);
15
20
  }
16
21
  });
17
22
  });
@@ -29,7 +34,6 @@ async function connectMetro() {
29
34
  const ws = new WebSocket(url);
30
35
 
31
36
  ws.on("open", () => {
32
-
33
37
  ws.send(
34
38
  JSON.stringify({
35
39
  id: 1,
@@ -109,8 +113,8 @@ async function connectMetro() {
109
113
 
110
114
  process.stdin.resume();
111
115
  }
112
- function getMetrics(){
113
- return {logs, error, network}
116
+ function getMetrics() {
117
+ return { logs, error, network };
114
118
  }
115
119
 
116
- module.exports = {getMetrics, connectMetro};
120
+ module.exports = { getMetrics, connectMetro };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rnassist",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "AI-powered debugger and performance analyzer for React Native projects",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,6 +18,7 @@
18
18
  "@google/generative-ai": "^0.24.1",
19
19
  "axios": "^1.13.6",
20
20
  "chalk": "^5.6.2",
21
+ "child_process": "^1.0.2",
21
22
  "commander": "^14.0.3",
22
23
  "dotenv": "^17.3.1",
23
24
  "express": "^5.2.1",