codequiry-cli 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/src/const.js ADDED
@@ -0,0 +1,56 @@
1
+ export const API_KEY_FILE = './apikey.json';
2
+ export const validLanguageIds = {
3
+ "error": "Invalid programming language, must be a valid language ID",
4
+ "available_languages": [
5
+ { id: 13, language: 'Java (.java)' },
6
+ { id: 14, language: 'Python (.py)' },
7
+ { id: 16, language: 'C (.c/.h)' },
8
+ { id: 17, language: 'C/C++ (.cc/.c/.h/.cpp/.hpp)' },
9
+ { id: 18, language: 'C# (.cs)' },
10
+ { id: 20, language: 'Perl (.pl/.sh)' },
11
+ { id: 21, language: 'PHP (.php)' },
12
+ { id: 22, language: 'SQL (.sql)' },
13
+ { id: 23, language: 'VB (.vb/.bas)' },
14
+ { id: 24, language: 'XML (.xml)' },
15
+ { id: 28, language: 'Haskell (.hs/.lhs)' },
16
+ { id: 29, language: 'Pascal (.pas/.inc)' },
17
+ { id: 30, language: 'Go (.go)' },
18
+ { id: 31, language: 'Matlab (.m)' },
19
+ { id: 32, language: 'Lisp (.el)' },
20
+ { id: 33, language: 'Ruby (.rb)' },
21
+ { id: 34, language: 'Assembly (.asm/.s)' },
22
+ { id: 38, language: 'HTML Javascript (.html/.htm/.xhtml)' },
23
+ { id: 39, language: 'Javascript (.js/.ts)' },
24
+ { id: 40, language: 'HTML (.html/.htm/.xhtml)' },
25
+ { id: 41, language: 'Plain text (.txt)' },
26
+ { id: 42, language: 'Text file by char (.txt)' },
27
+ { id: 43, language: 'Swift (.swift)' },
28
+ { id: 44, language: 'Kotlin (.kt/.kts)' },
29
+ { id: 45, language: 'Yacc (.y,.yy,.ypp,.yxx)' },
30
+ { id: 46, language: 'Lex (.l,.ll)' },
31
+ { id: 47, language: 'Elixir (.ex, .exs)' },
32
+ { id: 48, language: 'Python Jupyter Notebook (.ipynb)' },
33
+ { id: 49, language: 'Dart (.dart)' },
34
+ { id: 50, language: 'Shell (.sh/.bash)' },
35
+ { id: 51, language: 'Rust (.rs)' },
36
+ { id: 52, language: 'Scala (.scala)' },
37
+ { id: 53, language: 'R (.r)' },
38
+ { id: 54, language: 'Objective-C (.m, .mm)' },
39
+ { id: 55, language: 'TypeScript (.ts, .tsx)' },
40
+ { id: 56, language: 'Markdown (.md)' },
41
+ { id: 57, language: 'Julia (.jl)' },
42
+ { id: 58, language: 'Groovy (.groovy)' },
43
+ { id: 59, language: 'Sass/SCSS (.scss, .sass)' },
44
+ { id: 60, language: 'CoffeeScript (.coffee)' },
45
+ { id: 61, language: 'Lua (.lua)' },
46
+ { id: 62, language: 'Erlang (.erl, .hrl)' },
47
+ { id: 63, language: 'F# (.fs, .fsi, .fsx)' },
48
+ { id: 64, language: 'Fortran (.f90, .f95)' },
49
+ { id: 65, language: 'Haxe (.hx)' },
50
+ { id: 66, language: 'Scheme (.scm, .ss)' },
51
+ { id: 67, language: 'Tcl (.tcl)' },
52
+ { id: 68, language: 'Ada (.adb, .ads)' },
53
+ { id: 69, language: 'COBOL (.cob, .cbl)' },
54
+ { id: 70, language: 'VHDL (.vhd, .vhdl)' }
55
+ ]
56
+ }
package/src/index.js ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { program } from 'commander';
4
+ import { authenticate } from './auth.js';
5
+ import { createCheck, uploadToCheck, startCheck, retriveCheck, checkStatus, resultOverview, detailedResult } from './check.js';
6
+
7
+ program
8
+ .version('1.0.0')
9
+ .description('CLI for Plagiarism Checker API');
10
+
11
+ program
12
+ .command('auth')
13
+ .description('Authenticate API key')
14
+ .action(authenticate);
15
+
16
+ program
17
+ .command('createCheck')
18
+ .description('Create check')
19
+ .action(createCheck);
20
+
21
+ program
22
+ .command('uploadToCheck')
23
+ .description('Upload file to check')
24
+ .action(uploadToCheck);
25
+
26
+ program
27
+ .command('startCheck')
28
+ .description('Start check')
29
+ .action(startCheck);
30
+
31
+ program
32
+ .command('retriveCheck')
33
+ .description('Retrive checks')
34
+ .action(retriveCheck);
35
+
36
+ program
37
+ .command('checkStatus')
38
+ .description('Check status')
39
+ .action(checkStatus);
40
+
41
+ program
42
+ .command('resultOverview')
43
+ .description('Result Overview')
44
+ .action(resultOverview);
45
+
46
+ program
47
+ .command('detailedResult')
48
+ .description('Detailed Result')
49
+ .action(detailedResult);
50
+
51
+ program.parse(process.argv);
package/src/util.js ADDED
@@ -0,0 +1,26 @@
1
+ import fs from 'fs';
2
+ import { API_KEY_FILE } from './const.js';
3
+ import path from 'path';
4
+
5
+ export function getApiKey() {
6
+ if (fs.existsSync(API_KEY_FILE)) {
7
+ return JSON.parse(fs.readFileSync(API_KEY_FILE, 'utf8')).apiKey;
8
+ } else {
9
+ return null;
10
+ }
11
+ }
12
+
13
+ export function isValidNumber(value) {
14
+ return !isNaN(value) && typeof Number(value) === 'number';
15
+ };
16
+
17
+ export function getZipFiles() {
18
+ try {
19
+ const files = fs.readdirSync('./uploads/');
20
+ const zipFiles = files.filter(file => path.extname(file).toLowerCase() === '.zip');
21
+ return zipFiles;
22
+ } catch (error) {
23
+ console.error('Error reading directory:', error);
24
+ return [];
25
+ }
26
+ };
File without changes