Skip to content

Commit 30bb384

Browse files
author
Test User
committed
Release version 0.2.0
### Added - Changes in bin/reactstream.js - Changes in changelog.py - Changes in git.sh - Changes in init.sh - Changes in package.json - Changes in publish.sh - Changes in reactstream.sh - Changes in run.sh - Changes in src/analyze.js - Changes in src/index.js - Changes in start.sh
1 parent 6dc5c54 commit 30bb384

15 files changed

Lines changed: 2064 additions & 127 deletions

.gitignore

Lines changed: 25 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,30 @@
1-
# Logs
2-
logs
1+
.idea
2+
.gradle
3+
build
4+
.reactstream
5+
package-lock.json
6+
node_modules
7+
# Compiled class file
8+
*.class
9+
10+
# Log file
311
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
lerna-debug.log*
8-
.pnpm-debug.log*
912

10-
# Diagnostic reports (https://nodejs.org/api/report.html)
11-
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
13+
# BlueJ files
14+
*.ctxt
1215

13-
# Runtime data
14-
pids
15-
*.pid
16-
*.seed
17-
*.pid.lock
16+
# Mobile Tools for Java (J2ME)
17+
.mtj.tmp/
1818

19-
# Directory for instrumented libs generated by jscoverage/JSCover
20-
lib-cov
19+
# Package Files #
20+
*.jar
21+
*.war
22+
*.nar
23+
*.ear
24+
*.zip
25+
*.tar.gz
26+
*.rar
2127

22-
# Coverage directory used by tools like istanbul
23-
coverage
24-
*.lcov
25-
26-
# nyc test coverage
27-
.nyc_output
28-
29-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30-
.grunt
31-
32-
# Bower dependency directory (https://bower.io/)
33-
bower_components
34-
35-
# node-waf configuration
36-
.lock-wscript
37-
38-
# Compiled binary addons (https://nodejs.org/api/addons.html)
39-
build/Release
40-
41-
# Dependency directories
42-
node_modules/
43-
jspm_packages/
44-
45-
# Snowpack dependency directory (https://snowpack.dev/)
46-
web_modules/
47-
48-
# TypeScript cache
49-
*.tsbuildinfo
50-
51-
# Optional npm cache directory
52-
.npm
53-
54-
# Optional eslint cache
55-
.eslintcache
56-
57-
# Optional stylelint cache
58-
.stylelintcache
59-
60-
# Microbundle cache
61-
.rpt2_cache/
62-
.rts2_cache_cjs/
63-
.rts2_cache_es/
64-
.rts2_cache_umd/
65-
66-
# Optional REPL history
67-
.node_repl_history
68-
69-
# Output of 'npm pack'
70-
*.tgz
71-
72-
# Yarn Integrity file
73-
.yarn-integrity
74-
75-
# dotenv environment variable files
76-
.env
77-
.env.development.local
78-
.env.test.local
79-
.env.production.local
80-
.env.local
81-
82-
# parcel-bundler cache (https://parceljs.org/)
83-
.cache
84-
.parcel-cache
85-
86-
# Next.js build output
87-
.next
88-
out
89-
90-
# Nuxt.js build / generate output
91-
.nuxt
92-
dist
93-
94-
# Gatsby files
95-
.cache/
96-
# Comment in the public line in if your project uses Gatsby and not Next.js
97-
# https://nextjs.org/blog/next-9-1#public-directory-support
98-
# public
99-
100-
# vuepress build output
101-
.vuepress/dist
102-
103-
# vuepress v2.x temp and cache directory
104-
.temp
105-
.cache
106-
107-
# Docusaurus cache and generated files
108-
.docusaurus
109-
110-
# Serverless directories
111-
.serverless/
112-
113-
# FuseBox cache
114-
.fusebox/
115-
116-
# DynamoDB Local files
117-
.dynamodb/
118-
119-
# TernJS port file
120-
.tern-port
121-
122-
# Stores VSCode versions used for testing VSCode extensions
123-
.vscode-test
124-
125-
# yarn v2
126-
.yarn/cache
127-
.yarn/unplugged
128-
.yarn/build-state.yml
129-
.yarn/install-state.gz
130-
.pnp.*
28+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
29+
hs_err_pid*
30+
replay_pid*

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [0.2.0] - 2024-11-26
6+
7+
### Added
8+
- Changes in bin/reactstream.js
9+
- Changes in changelog.py
10+
- Changes in git.sh
11+
- Changes in init.sh
12+
- Changes in package.json
13+
- Changes in publish.sh
14+
- Changes in reactstream.sh
15+
- Changes in run.sh
16+
- Changes in src/analyze.js
17+
- Changes in src/index.js
18+
- Changes in start.sh
19+

LICENSE

100644100755
File mode changed.

README.md

100644100755
Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,63 @@
1-
# nodejs
2-
reactstream command line tool to one line reactjs deployment
1+
2+
Przykład użycia:
3+
4+
```bash
5+
# Analiza pojedynczego komponentu
6+
./reactstream-analyze MyComponent.js --debug
7+
8+
# Analiza z automatyczną naprawą problemów
9+
./reactstream-analyze MyComponent.js --fix
10+
11+
# Porównanie dwóch komponentów
12+
./reactstream-analyze MyComponent1.js MyComponent2.js --compare
13+
14+
# Pełna analiza z debugowaniem i sugestiami optymalizacji
15+
./reactstream-analyze MyComponent.js --debug --verbose
16+
```
17+
18+
19+
Główne funkcje narzędzia:
20+
21+
1. Analiza składni i struktury:
22+
- Sprawdzanie poprawności składni JSX
23+
- Analiza importów i eksportów
24+
- Wykrywanie nieużywanych importów
25+
26+
2. Analiza hooków:
27+
- Sprawdzanie zasad hooków
28+
- Wykrywanie potencjalnych problemów z zależnościami
29+
- Sugestie optymalizacji
30+
31+
3. Analiza wydajności:
32+
- Wykrywanie niepotrzebnych rerenderów
33+
- Sprawdzanie optymalizacji memoizacji
34+
- Analiza użycia useCallback i useMemo
35+
36+
4. Debugowanie:
37+
- Automatyczne dodawanie punktów debugowania
38+
- Śledzenie aktualizacji stanu
39+
- Monitorowanie efektów ubocznych
40+
41+
5. Dostępność:
42+
- Sprawdzanie atrybutów ARIA
43+
- Weryfikacja alt dla obrazów
44+
- Kontrola kontrastów i semantyki
45+
46+
6. Optymalizacje:
47+
- Sugestie użycia React.memo
48+
- Optymalizacja hooków
49+
- Refaktoryzacja stanu
50+
51+
7. Porównywanie komponentów:
52+
- Analiza podobieństw
53+
- Wykrywanie duplikacji
54+
- Sugestie współdzielenia kodu
55+
56+
Aby połączyć oba narzędzia, możesz użyć:
57+
```bash
58+
# Najpierw analiza
59+
./reactstream-analyze MyComponent.js --debug
60+
61+
# Następnie uruchomienie z debuggerem
62+
./reactstream MyComponent.js --port=3000 --debug
63+
```

bin/reactstream.js

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
const fs = require('fs');
5+
const path = require('path');
6+
const { execSync } = require('child_process');
7+
const chalk = require('chalk');
8+
const minimist = require('minimist');
9+
const express = require('express');
10+
const webpack = require('webpack');
11+
const WebpackDevServer = require('webpack-dev-server');
12+
13+
// Parse command line arguments
14+
const argv = minimist(process.argv.slice(2));
15+
const components = argv._;
16+
const port = argv.port || 3000;
17+
18+
if (components.length === 0) {
19+
console.error(chalk.red('Error: Please specify at least one component to debug'));
20+
console.log(chalk.yellow('Usage: reactstream ComponentName [AnotherComponent...] [--port=3000]'));
21+
process.exit(1);
22+
}
23+
24+
// Create temporary directory for development
25+
const tempDir = path.join(process.cwd(), '.reactstream');
26+
if (!fs.existsSync(tempDir)) {
27+
fs.mkdirSync(tempDir);
28+
}
29+
30+
// Generate development environment
31+
const generateDevEnv = () => {
32+
// Create index.html
33+
const htmlContent = `
34+
<!DOCTYPE html>
35+
<html>
36+
<head>
37+
<title>ReactStream Debug Environment</title>
38+
<meta charset="UTF-8">
39+
</head>
40+
<body>
41+
<div id="root"></div>
42+
</body>
43+
</html>
44+
`;
45+
fs.writeFileSync(path.join(tempDir, 'index.html'), htmlContent);
46+
47+
// Generate entry point
48+
const entryContent = `
49+
import React from 'react';
50+
import { createRoot } from 'react-dom/client';
51+
${components.map(comp => `import ${comp} from '${path.resolve(process.cwd(), comp)}';`).join('\n')}
52+
53+
const App = () => (
54+
<div style={{ padding: '20px' }}>
55+
<h1>ReactStream Debug Environment</h1>
56+
${components.map(comp => `
57+
<div style={{ margin: '20px 0', padding: '20px', border: '1px solid #ccc' }}>
58+
<h2>${comp}</h2>
59+
<${comp} />
60+
</div>
61+
`).join('')}
62+
</div>
63+
);
64+
65+
const root = createRoot(document.getElementById('root'));
66+
root.render(<App />);
67+
`;
68+
fs.writeFileSync(path.join(tempDir, 'index.js'), entryContent);
69+
}
70+
71+
// Webpack configuration
72+
const webpackConfig = {
73+
mode: 'development',
74+
entry: path.join(tempDir, 'index.js'),
75+
output: {
76+
path: tempDir,
77+
filename: 'bundle.js',
78+
},
79+
module: {
80+
rules: [
81+
{
82+
test: /\.(js|jsx)$/,
83+
exclude: /node_modules/,
84+
use: {
85+
loader: 'babel-loader',
86+
options: {
87+
presets: ['@babel/preset-react', '@babel/preset-env'],
88+
},
89+
},
90+
},
91+
{
92+
test: /\.css$/,
93+
use: ['style-loader', 'css-loader'],
94+
},
95+
],
96+
},
97+
resolve: {
98+
extensions: ['.js', '.jsx'],
99+
},
100+
devtool: 'source-map',
101+
};
102+
103+
// Start development server
104+
const startDevServer = () => {
105+
const compiler = webpack(webpackConfig);
106+
const devServer = new WebpackDevServer({
107+
static: {
108+
directory: tempDir,
109+
},
110+
port,
111+
hot: true,
112+
open: true,
113+
client: {
114+
overlay: true,
115+
},
116+
}, compiler);
117+
118+
devServer.start()
119+
.then(() => {
120+
console.log(chalk.green(`\n🚀 ReactStream is running at http://localhost:${port}`));
121+
console.log(chalk.blue('\nDebugging components:'));
122+
components.forEach(comp => console.log(chalk.yellow(`- ${comp}`)));
123+
})
124+
.catch((err) => {
125+
console.error(chalk.red('Failed to start development server:'), err);
126+
process.exit(1);
127+
});
128+
};
129+
130+
// Main execution
131+
console.log(chalk.blue('🔧 Setting up ReactStream development environment...'));
132+
generateDevEnv();
133+
startDevServer();
134+
135+
// Cleanup on exit
136+
process.on('SIGINT', () => {
137+
console.log(chalk.blue('\nCleaning up...'));
138+
fs.rmSync(tempDir, { recursive: true, force: true });
139+
process.exit();
140+
});

0 commit comments

Comments
 (0)