project-to-text 1.0.0
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/LICENSE +21 -0
- package/README.md +115 -0
- package/bin/exporter.js +54 -0
- package/package.json +40 -0
- package/src/reader.js +17 -0
- package/src/scanner.js +24 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 IrbadAbdeldjelil
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# project-to-text
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/project-to-text)
|
|
4
|
+
[](https://github.com/your-username/project-to-text/blob/main/LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/project-to-text)
|
|
6
|
+
|
|
7
|
+
A powerful tool that converts your entire project into a single text file, making it easy to share with AI assistants for code review, analysis, and feedback.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g project-to-text
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
cd your-project
|
|
20
|
+
project-to-text
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Creates `thisProject.txt` with your project content.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Command Line
|
|
28
|
+
```bash
|
|
29
|
+
# Basic usage
|
|
30
|
+
project-to-text
|
|
31
|
+
|
|
32
|
+
# Ignore specific files
|
|
33
|
+
project-to-text --ignore "dist/**,*.log"
|
|
34
|
+
|
|
35
|
+
# Using npx
|
|
36
|
+
npx project-to-text
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Programmatic Usage
|
|
40
|
+
```javascript
|
|
41
|
+
const exporter = require('project-to-text');
|
|
42
|
+
|
|
43
|
+
// Basic usage
|
|
44
|
+
await exporter();
|
|
45
|
+
|
|
46
|
+
// With custom ignore patterns
|
|
47
|
+
await exporter('current-file.js', ['dist/**', '*.log']);
|
|
48
|
+
```
|
|
49
|
+
## API
|
|
50
|
+
|
|
51
|
+
### `exporter(thisFile?, customIgnore?)`
|
|
52
|
+
|
|
53
|
+
- `thisFile` - Current file name to exclude (optional)
|
|
54
|
+
- `customIgnore` - Array of ignore patterns (optional)
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
- Scans entire project structure
|
|
59
|
+
- Smart ignoring of node_modules, build files, etc.
|
|
60
|
+
- Custom ignore patterns
|
|
61
|
+
- Clean formatted output
|
|
62
|
+
- Fast and lightweight
|
|
63
|
+
|
|
64
|
+
## Default Ignored Files
|
|
65
|
+
|
|
66
|
+
- `node_modules/**`
|
|
67
|
+
- `.git/**`
|
|
68
|
+
- `dist/`, `build/`, `coverage/`
|
|
69
|
+
- `*.log`
|
|
70
|
+
- `package-lock.json`
|
|
71
|
+
|
|
72
|
+
## Output Format
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
FILE : src/index.js
|
|
76
|
+
CONTENT : // Your code here...
|
|
77
|
+
|
|
78
|
+
FILE : package.json
|
|
79
|
+
CONTENT : {
|
|
80
|
+
"name": "my-project"
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Use Cases
|
|
85
|
+
|
|
86
|
+
- Share code with AI assistants (ChatGPT, Claude, etc.)
|
|
87
|
+
- Code reviews and analysis
|
|
88
|
+
- Project documentation
|
|
89
|
+
- Backup and sharing
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## 📜 License
|
|
94
|
+
|
|
95
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
96
|
+
|
|
97
|
+
## 👨💻 Author
|
|
98
|
+
|
|
99
|
+
**Irbad Abdeldjelil**
|
|
100
|
+
- Email: irbadabdeldjelil@gmail.com
|
|
101
|
+
- GitHub: [@your-username](https://github.com/IrbadAbdeldjelil)
|
|
102
|
+
|
|
103
|
+
## 🙏 Acknowledgments
|
|
104
|
+
|
|
105
|
+
- Built with [fast-glob](https://github.com/mrmlnc/fast-glob) for fast file scanning
|
|
106
|
+
- Inspired by the need for better AI code analysis workflows
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
<div align="center">
|
|
111
|
+
|
|
112
|
+
**If you find this tool helpful, please consider giving it a ⭐ on GitHub!**
|
|
113
|
+
|
|
114
|
+
</div>
|
|
115
|
+
```
|
package/bin/exporter.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const scanner = require('../src/scanner.js');
|
|
3
|
+
const reader = require('../src/reader');
|
|
4
|
+
const fs = require('fs/promises');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
// الدالة الرئيسية للتصدير
|
|
8
|
+
async function exporter(thisFile = path.basename(__filename), customIgnore = []) {
|
|
9
|
+
try {
|
|
10
|
+
console.log('🔧 Running with ignore patterns:', customIgnore);
|
|
11
|
+
|
|
12
|
+
const projectStruc = await scanner(customIgnore);
|
|
13
|
+
|
|
14
|
+
if(projectStruc.includes('thisProject.txt')) {
|
|
15
|
+
await fs.rm('thisProject.txt');
|
|
16
|
+
console.log('🗑️ Deleted old file');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const results = await reader(thisFile, customIgnore);
|
|
20
|
+
await fs.writeFile('thisProject.txt', results, 'utf8');
|
|
21
|
+
console.log('✅ Project exported successfully to thisProject.txt');
|
|
22
|
+
console.log('📊 Total files processed:', projectStruc.length);
|
|
23
|
+
} catch(error) {
|
|
24
|
+
console.log('❌ Failed to export:', error.message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// معالجة وسيطات CLI بشكل صحيح
|
|
29
|
+
function parseArgs() {
|
|
30
|
+
const args = process.argv.slice(2);
|
|
31
|
+
let customIgnore = [];
|
|
32
|
+
|
|
33
|
+
console.log('📨 Raw arguments:', args);
|
|
34
|
+
|
|
35
|
+
for (let i = 0; i < args.length; i++) {
|
|
36
|
+
if (args[i] === '--ignore' && args[i + 1]) {
|
|
37
|
+
customIgnore = args[i + 1].split(',');
|
|
38
|
+
console.log('🎯 Parsed ignore patterns:', customIgnore);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return customIgnore;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// تصدير الدالة للاستخدام كـ module
|
|
47
|
+
module.exports = exporter;
|
|
48
|
+
|
|
49
|
+
// إذا تم تشغيل الملف مباشرة كـ CLI
|
|
50
|
+
if (require.main === module) {
|
|
51
|
+
const customIgnore = parseArgs();
|
|
52
|
+
const thisFile = path.basename(__filename);
|
|
53
|
+
exporter(thisFile, customIgnore).catch(console.error);
|
|
54
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "project-to-text",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Convert your project to a single text file for AI analysis and code sharing",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"project",
|
|
7
|
+
"text",
|
|
8
|
+
"export",
|
|
9
|
+
"ai",
|
|
10
|
+
"analysis",
|
|
11
|
+
"documentation",
|
|
12
|
+
"code-sharing"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Irbad Abdeldjelil <irbadabdeldjelil@gmail.com>",
|
|
16
|
+
"type": "commonjs",
|
|
17
|
+
"main": "bin/exporter.js",
|
|
18
|
+
"bin": {
|
|
19
|
+
"project-to-text": "bin/exporter.js"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"start": "node bin/exporter.js",
|
|
23
|
+
"export": "node bin/exporter.js",
|
|
24
|
+
"test": "echo \"No tests specified\" && exit 0"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"fast-glob": "^3.3.3"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=14.0.0"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/irbad/project-to-text"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/irbad/project-to-text#readme",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/irbad/project-to-text/issues"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/reader.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const scanner = require('./scanner');
|
|
2
|
+
const fs = require('fs/promises');
|
|
3
|
+
|
|
4
|
+
module.exports = async function (thisFile, customIgnore = []) {
|
|
5
|
+
const files = await scanner(customIgnore);
|
|
6
|
+
let results = '';
|
|
7
|
+
for (const file of files) {
|
|
8
|
+
if (file.includes(thisFile)) continue;
|
|
9
|
+
// get file content
|
|
10
|
+
let content = await fs.readFile(file, 'utf8');
|
|
11
|
+
// if not empty
|
|
12
|
+
if (content) {
|
|
13
|
+
results += `FILE : ${file} \nCONTENT : ${content.trim()}\n`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return results;
|
|
17
|
+
}
|
package/src/scanner.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const fg = require('fast-glob');
|
|
2
|
+
|
|
3
|
+
module.exports = async (customIgnore = []) => {
|
|
4
|
+
const defaultIgnore = [
|
|
5
|
+
'node_modules/**',
|
|
6
|
+
'README.md',
|
|
7
|
+
'package-lock.json',
|
|
8
|
+
'package.json',
|
|
9
|
+
'.git/**',
|
|
10
|
+
'.DS_Store',
|
|
11
|
+
'*.log',
|
|
12
|
+
'coverage/**',
|
|
13
|
+
'dist/**',
|
|
14
|
+
'build/**'
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const ignoreList = [...defaultIgnore, ...customIgnore];
|
|
18
|
+
|
|
19
|
+
const results = await fg('**/**', {
|
|
20
|
+
ignore: ignoreList,
|
|
21
|
+
dot: true
|
|
22
|
+
});
|
|
23
|
+
return results;
|
|
24
|
+
}
|