lavina 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 (2) hide show
  1. package/cli.js +39 -8
  2. package/package.json +6 -3
package/cli.js CHANGED
@@ -8,13 +8,24 @@ import saveDependencies from './src/cli/helpers/saveDependencies.js';
8
8
  import { spawn } from 'child_process';
9
9
  import { getLibDirName } from './src/cli/helpers/getLibDirName.js';
10
10
  import open from 'open';
11
+ import path from 'path';
12
+ import { existsSync, readFileSync } from 'fs';
13
+
14
+ const packageJson = JSON.parse(
15
+ readFileSync(new URL('./package.json', import.meta.url), 'utf8'),
16
+ );
11
17
 
12
18
  const program = new Command();
13
19
 
20
+ const commonEnv = {
21
+ ...process.env,
22
+ PROJECT_PATH: process.cwd(),
23
+ };
24
+
14
25
  program
15
26
  .name('lavina')
16
27
  .description('lavina - automated dependency propagation tool')
17
- .version('0.1.0');
28
+ .version(packageJson.version);
18
29
 
19
30
  program
20
31
  .command('scan')
@@ -29,7 +40,7 @@ program
29
40
 
30
41
  const outputPath = saveDependencies(mappedProjects);
31
42
 
32
- mappedProjects.map((project) => {
43
+ mappedProjects.forEach((project) => {
33
44
  Logger.color(COLORS.YELLOW).log(
34
45
  `\n- ${project.displayName}: ${project.version}`,
35
46
  true,
@@ -48,6 +59,11 @@ program
48
59
  `\nDependency map saved to: ${outputPath}\n`,
49
60
  true,
50
61
  );
62
+
63
+ Logger.color(COLORS.GREEN).log(
64
+ `\nRun lavina ui to explore the dependency graph in browser!`,
65
+ true,
66
+ );
51
67
  });
52
68
 
53
69
  program
@@ -55,7 +71,7 @@ program
55
71
  .description('Show dependency graph in a web UI')
56
72
  .action(async () => {
57
73
  const { __dirname } = getLibDirName(import.meta.url);
58
- const uiPath = `${__dirname}/lavina-ui`;
74
+ const uiPath = path.join(__dirname, 'lavina-ui');
59
75
  Logger.color(COLORS.GREEN).log(
60
76
  `Launching Lavina UI from ${uiPath}...`,
61
77
  true,
@@ -68,18 +84,27 @@ program
68
84
  'server.js',
69
85
  );
70
86
 
71
- const isBuilt = fs.existsSync(standaloneServer);
87
+ const isBuilt = existsSync(standaloneServer);
88
+
89
+ let nextProcess;
90
+
91
+ if (!existsSync(uiPath)) {
92
+ Logger.color(COLORS.RED).log(`Lavina UI not found at ${uiPath}`, true);
93
+ return;
94
+ }
72
95
 
73
96
  if (isBuilt) {
74
97
  // published package
75
- spawn('node', ['server.js'], {
98
+ nextProcess = spawn('node', ['server.js'], {
76
99
  cwd: path.dirname(standaloneServer),
100
+ stdio: ['inherit', 'pipe', 'pipe'],
77
101
  env: commonEnv,
78
102
  });
79
103
  } else {
80
104
  // local development
81
- spawn('npm', ['run', 'dev'], {
105
+ nextProcess = spawn('npm', ['run', 'dev'], {
82
106
  cwd: uiPath,
107
+ stdio: ['inherit', 'pipe', 'pipe'],
83
108
  shell: true,
84
109
  env: commonEnv,
85
110
  });
@@ -87,10 +112,16 @@ program
87
112
 
88
113
  let isOpened = false;
89
114
  nextProcess.stdout?.on('data', (data) => {
90
- process.stderr.write(data);
115
+ process.stdout.write(data);
91
116
 
92
117
  if (isOpened) return;
93
- if (data.toString().indexOf('Ready') > -1) {
118
+ const text = data.toString();
119
+
120
+ if (
121
+ text.includes('Ready') ||
122
+ text.includes('ready') ||
123
+ text.includes('Local:')
124
+ ) {
94
125
  open('http://localhost:3000');
95
126
  isOpened = true;
96
127
  }
package/package.json CHANGED
@@ -1,15 +1,18 @@
1
1
  {
2
2
  "name": "lavina",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Lavina is an automated dependency propagation tool designed to scan microservice architectures and build dependency graphs between internal projects.",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",
8
- "dev": "npm unlink -g lavina && npm link"
8
+ "dev": "npm unlink -g lavina && npm link",
9
+ "release": "npm run build-ui && npm publish"
9
10
  },
10
11
  "files": [
11
12
  "cli.js",
12
- "src"
13
+ "src",
14
+ "lavina-ui/.next/standalone",
15
+ "lavina-ui/.next/static"
13
16
  ],
14
17
  "author": "Elena Kikiova",
15
18
  "license": "ISC",