ihub-cli 1.0.0 → 1.0.1
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/dbconnection.js +0 -12
- package/index.js +9 -4
- package/package.json +1 -1
- package/recursive_file_extractor.js +23 -20
package/dbconnection.js
CHANGED
|
@@ -10,18 +10,6 @@ const client = new MongoClient(uri, {
|
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
async function runConnectionTest() {
|
|
14
|
-
try {
|
|
15
|
-
|
|
16
|
-
await client.connect();
|
|
17
|
-
await client.db("admin").command({ ping: 1 });
|
|
18
|
-
console.log("Pinged your deployment. You successfully connected to MongoDB!");
|
|
19
|
-
} catch (error) {
|
|
20
|
-
console.error("Connection error:", error);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
runConnectionTest();
|
|
25
13
|
|
|
26
14
|
|
|
27
15
|
function provideClient() {
|
package/index.js
CHANGED
|
@@ -11,8 +11,6 @@ import { PinataSDK } from "pinata";
|
|
|
11
11
|
import { provideClient } from "./dbconnection.js"
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
14
|
const IHUB_DIR = path.join(os.homedir(), ".ihub");
|
|
17
15
|
const FILE_TO_STORE_LOGIN = path.join(IHUB_DIR, "login.txt");
|
|
18
16
|
|
|
@@ -321,7 +319,8 @@ async function Push(FOLDER_TO_UPLOAD,pinata,client) {
|
|
|
321
319
|
const coll = db.collection("ihub_col");
|
|
322
320
|
|
|
323
321
|
let uploads=[]
|
|
324
|
-
|
|
322
|
+
const absolutePath = path.resolve(FOLDER_TO_UPLOAD);
|
|
323
|
+
let files=dirtoFileArray(absolutePath)
|
|
325
324
|
|
|
326
325
|
for (let file of files) {
|
|
327
326
|
|
|
@@ -332,7 +331,7 @@ async function Push(FOLDER_TO_UPLOAD,pinata,client) {
|
|
|
332
331
|
|
|
333
332
|
console.log(uploads)
|
|
334
333
|
const data = fs.readFileSync(FILE_TO_STORE_LOGIN, 'utf8');
|
|
335
|
-
const lastpath = path.basename(
|
|
334
|
+
const lastpath = path.basename(absolutePath);
|
|
336
335
|
|
|
337
336
|
let meta={"id":data,"folder":lastpath,"uploads":uploads,"is_latest":true}
|
|
338
337
|
|
|
@@ -453,6 +452,12 @@ yargs(hideBin(process.argv))
|
|
|
453
452
|
}
|
|
454
453
|
)
|
|
455
454
|
.demandCommand(1, 'You must provide a top-level command like "ihub".')
|
|
455
|
+
.usage('ihub <command> [options]')
|
|
456
|
+
.example('ihub op login 0xABC...', 'Login using wallet address')
|
|
457
|
+
.example('ihub op push ./repo', 'Push a local repository')
|
|
458
|
+
.example('ihub op clone <reponame> --new true', 'Clone a new repository | name will be the reponame in UI')
|
|
459
|
+
.example('ihub op clone <reponame>', 'Clone an existing repository | name will be the reponame in UI')
|
|
460
|
+
.epilog('ImmutableHub CLI • Built with ❤️')
|
|
456
461
|
.help()
|
|
457
462
|
.argv;
|
|
458
463
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import fs from "fs"
|
|
2
2
|
import path from "path";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* @param {string} dir - Directory path
|
|
6
|
-
* @param {string[]} fileList - Accumulator for file paths
|
|
7
|
-
* @returns {string[]} Array of file paths
|
|
8
|
-
*/
|
|
3
|
+
|
|
4
|
+
|
|
9
5
|
function getAllFiles(dir, fileList = []) {
|
|
10
6
|
|
|
11
7
|
|
|
12
|
-
const skipDirs = [
|
|
8
|
+
const skipDirs = [
|
|
9
|
+
'node_modules',
|
|
10
|
+
'.git',
|
|
11
|
+
'dist',
|
|
12
|
+
'build',
|
|
13
|
+
'.next',
|
|
14
|
+
'coverage',
|
|
15
|
+
'__pycache__',
|
|
16
|
+
'.venv',
|
|
17
|
+
'venv',
|
|
18
|
+
'env',
|
|
19
|
+
'.env',
|
|
20
|
+
'.tox',
|
|
21
|
+
'.pytest_cache',
|
|
22
|
+
'.mypy_cache',
|
|
23
|
+
'.ruff_cache',
|
|
24
|
+
'.eggs',
|
|
25
|
+
'pip-wheel-metadata'];
|
|
13
26
|
const files = fs.readdirSync(dir);
|
|
14
27
|
|
|
15
28
|
files.forEach(file => {
|
|
@@ -27,11 +40,7 @@ function getAllFiles(dir, fileList = []) {
|
|
|
27
40
|
}
|
|
28
41
|
|
|
29
42
|
|
|
30
|
-
|
|
31
|
-
* Get MIME type from file extension
|
|
32
|
-
* @param {string} fileName - File name
|
|
33
|
-
* @returns {string} MIME type
|
|
34
|
-
*/
|
|
43
|
+
|
|
35
44
|
function getMimeType(fileName) {
|
|
36
45
|
const ext = path.extname(fileName).toLowerCase();
|
|
37
46
|
const types = {
|
|
@@ -54,17 +63,14 @@ function getMimeType(fileName) {
|
|
|
54
63
|
'.xml': 'application/xml',
|
|
55
64
|
'.csv': 'text/csv',
|
|
56
65
|
'.md': 'text/markdown',
|
|
66
|
+
'.py': 'text/x-python',
|
|
57
67
|
};
|
|
58
68
|
return types[ext] || 'application/octet-stream';
|
|
59
69
|
}
|
|
60
70
|
|
|
61
71
|
|
|
62
72
|
|
|
63
|
-
|
|
64
|
-
* Convert file paths to File objects for Pinata
|
|
65
|
-
* @param {string} dirPath - Directory path
|
|
66
|
-
* @returns {File[]} Array of File objects
|
|
67
|
-
*/
|
|
73
|
+
|
|
68
74
|
export default function dirToFileArray(dirPath) {
|
|
69
75
|
const filePaths = getAllFiles(dirPath);
|
|
70
76
|
|
|
@@ -75,6 +81,3 @@ export default function dirToFileArray(dirPath) {
|
|
|
75
81
|
return new File([buffer], fileName,{type:mimeType});
|
|
76
82
|
});
|
|
77
83
|
}
|
|
78
|
-
//const FOLDER_TO_UPLOAD = path.resolve('./demofolder');
|
|
79
|
-
//let f=dirToFileArray(FOLDER_TO_UPLOAD)
|
|
80
|
-
//console.log(f)
|