From ba226ba5778192e11f55b867cbde353a1df98419 Mon Sep 17 00:00:00 2001 From: samridh-111 Date: Sat, 21 Jun 2025 12:45:57 +0530 Subject: [PATCH 1/9] commit message: added "add snippet" feature. Added its required fields in index.js. Does work in cli but does not take input yet --- .DS_Store | Bin 0 -> 6148 bytes index.js | 17 ++++++++++++++++- package.json | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a2aef4ee7df12669d83d0f91425047979441e751 GIT binary patch literal 6148 zcmeHKu};G<5IwgMRDe(yBnF0jK}G){l)w*kWS|N~EutZnN`=_+C42+?0UL}=O#B8j zytA)u+>nY10lKT~XZ!B#msiD(iO6)O{WejPh#Dx2!3L@?jQw0nR+AA9`cB1FC>3@EaAdFFv(sKo@lFzrU|YeSSC3LD4e4s8l5IgV|EkK$bvYw(5K W07injLyW-mL%_& literal 0 HcmV?d00001 diff --git a/index.js b/index.js index a27114d..8c653ef 100755 --- a/index.js +++ b/index.js @@ -18,4 +18,19 @@ program .option('-f') .action(() =>{ console.log('Hello User, Welcome to the CLI');}); -program.parse(); \ No newline at end of file +program +.name('add snippet ') +.description('Add your code snippet in the language of your choice') +.option('-l,--lang','specify the programming language') +.option('-d,--desc','describe the code snippet') +.option('-f,--file','Path to the file containting the snippet') +.option('--tags ', 'Comma-separated tags', val => val.split(',')) +.action((name,option) =>{ + console.log('Name: ',name); + console.log('Language: ', option.lang); + console.log('Description: ', option.desc); + console.log('File Path: ', option.file); + console.log('Tags: ', option.tags); +}); + +program.parse(process.argvs); \ No newline at end of file diff --git a/package.json b/package.json index e26a445..0f6ebc1 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,6 @@ "author": "", "license": "ISC", "dependencies": { - "commander": "^14.0.0" + "commander": "^14.0.0" } -} \ No newline at end of file +} From 817bce7d872efe5cd3d507b555c3eeeee83bd82e Mon Sep 17 00:00:00 2001 From: samridh-111 Date: Tue, 1 Jul 2025 00:56:11 +0530 Subject: [PATCH 2/9] Added 'delete snippet' and 'edit snippet' tested for bugs --- index.js | 118 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 101 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index 8c653ef..8dd660c 100755 --- a/index.js +++ b/index.js @@ -1,6 +1,9 @@ #!/usr/bin/env node import { Command } from 'commander'; +import readline from 'readline'; +import fs from 'fs'; +import path from 'path'; // const {PrismaClient}=require('@prisma/client'); const program = new Command(); @@ -8,29 +11,110 @@ const program = new Command(); program -.name(' Code Snippet CLI') +.name('snippet-cli') .description('My Code Snippet CLI program') .version('1.0.0'); + +//greeting snippet program .command('hi ') -.description('Says hi to the user') -.option('-f') -.action(() =>{ console.log('Hello User, Welcome to the CLI');}); +.description('Says hi to the user') +.action((name) => { + console.log(`Hello ${name}, Welcome to the CLI: what are we here for today:`); +}); + +//add snippet +program + .command('add-snippet ') + .description('Add your code snippet in the language of your choice') + .option('-l, --lang ', 'Specify the programming language') + .option('-d, --desc ', 'Describe the code snippet') + .option('-f, --file ', 'Path to the file containing the snippet') + .option('--tags ', 'Comma-separated tags', val => val.split(',')) + .action((name, options) => { + console.log('Name:', name); + console.log('Language:', options.lang); + console.log('Description:', options.desc); + console.log('File Path:', options.file); + console.log('Tags:', options.tags); + }); + +//delete snippet program -.name('add snippet ') -.description('Add your code snippet in the language of your choice') -.option('-l,--lang','specify the programming language') -.option('-d,--desc','describe the code snippet') -.option('-f,--file','Path to the file containting the snippet') -.option('--tags ', 'Comma-separated tags', val => val.split(',')) -.action((name,option) =>{ - console.log('Name: ',name); - console.log('Language: ', option.lang); - console.log('Description: ', option.desc); - console.log('File Path: ', option.file); - console.log('Tags: ', option.tags); + .command('delete-snippet ') + .description('Delete the snippet that you would like to discard') + .option('-f, --file ', 'Path to the file containing the snippet') + .action((name, options) => { + if (!options.file) { + console.error('❌ Please provide a file path using -f or --file'); + process.exit(1); + } + + const filePath = path.resolve(options.file); + + // Confirm with user before deleting + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + }); + + rl.question(`⚠️ Are you sure you want to delete "${name}" at ${filePath}? (y/n): `, (answer) => { + rl.close(); + + if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') { + fs.unlink(filePath, (err) => { + if (err) { + console.error(`❌ Failed to delete file: ${filePath}`); + console.error(err.message); + } else { + console.log(`✅ Snippet "${name}" deleted from ${filePath}`); + } + }); + } else { + console.log('❎ Deletion cancelled.'); + } + }); + }); + + +//edit-snippet +program +.command('edit-snippet ') +.description('Edit an existing snippet') +.option('-l, --lang ', 'New programming language') +.option('-d, --desc ', 'New description') +.option('-f, --file ', 'Path to the file to overwrite') // ✅ Fix is here +.option('--tags ', 'New comma-separated tags', val => val.split(',')) +.action((name, options) => { + if (!options.file) { + console.error('❌ Please provide the file path using -f or --file'); + process.exit(1); + } + + const filePath = path.resolve(options.file); + + if (!fs.existsSync(filePath)) { + console.error(`❌ File not found: ${filePath}`); + process.exit(1); + } + + console.log(`✏️ Editing snippet "${name}" at ${filePath}`); + + if (options.lang) { + console.log(`🧠 Language updated to: ${options.lang}`); + } + if (options.desc) { + console.log(`📝 Description updated to: ${options.desc}`); + } + if (options.tags) { + console.log(`🏷️ Tags updated to: ${options.tags.join(', ')}`); + } + + console.log('✅ Edit command completed (metadata displayed, file not changed)'); }); -program.parse(process.argvs); \ No newline at end of file +//list and view snippet pending + +program.parse(process.argv); \ No newline at end of file From 0f0bd98debebdc58b3cf6a74e6b08b40705ce405 Mon Sep 17 00:00:00 2001 From: samridh-111 Date: Thu, 3 Jul 2025 13:36:49 +0530 Subject: [PATCH 3/9] Added list snippet function. Added new file 'snippet.json' to store the Snippets --- index.js | 115 ++++++++++++++++++++++++++++++++++----------------- snippet.json | 1 + 2 files changed, 78 insertions(+), 38 deletions(-) create mode 100644 snippet.json diff --git a/index.js b/index.js index 8dd660c..892867a 100755 --- a/index.js +++ b/index.js @@ -3,13 +3,30 @@ import { Command } from 'commander'; import readline from 'readline'; import fs from 'fs'; -import path from 'path'; -// const {PrismaClient}=require('@prisma/client'); +import path, { resolve } from 'path'; +import { json } from 'stream/consumers'; +// const {PrismaClient}=require(`@prisma/client`); +const DATA_FILE=path.resolve('./snippet.json'); const program = new Command(); // const prisma = new PrismaClient(); +//for loading snippet from JSON file +function loadSnippets(){ + if(!fs.existsSync(DATA_FILE)){ + return[]; + } + const data =fs.readFileSync(DATA_FILE,'utf-8'); + return JSON.parse(data); +} +//save snippets to JSON file +function savedSnippets(snippets){ + fs.writeFileSync(DATA_FILE,JSON.stringify(snippets,null,2),'utf-8') +} + + +//cli code starts here program .name('snippet-cli') .description('My Code Snippet CLI program') @@ -18,37 +35,37 @@ program //greeting snippet program -.command('hi ') -.description('Says hi to the user') +.command(`hi `) +.description(`Says hi to the user`) .action((name) => { console.log(`Hello ${name}, Welcome to the CLI: what are we here for today:`); }); //add snippet program - .command('add-snippet ') - .description('Add your code snippet in the language of your choice') - .option('-l, --lang ', 'Specify the programming language') - .option('-d, --desc ', 'Describe the code snippet') - .option('-f, --file ', 'Path to the file containing the snippet') - .option('--tags ', 'Comma-separated tags', val => val.split(',')) + .command(`add-snippet `) + .description(`Add your code snippet in the language of your choice`) + .option(`-l, --lang `, `Specify the programming language`) + .option(`-d, --desc `, `Describe the code snippet`) + .option(`-f, --file `, `Path to the file containing the snippet`) + .option(`--tags `, `Comma-separated tags`, val => val.split(`,`)) .action((name, options) => { - console.log('Name:', name); - console.log('Language:', options.lang); - console.log('Description:', options.desc); - console.log('File Path:', options.file); - console.log('Tags:', options.tags); + console.log(`Name:`, name); + console.log(`Language:`, options.lang); + console.log(`Description:`, options.desc); + console.log(`File Path:`, options.file); + console.log(`Tags:`, options.tags); }); //delete snippet program - .command('delete-snippet ') - .description('Delete the snippet that you would like to discard') - .option('-f, --file ', 'Path to the file containing the snippet') + .command(`delete-snippet `) + .description(`Delete the snippet that you would like to discard`) + .option(`-f, --file `, `Path to the file containing the snippet`) .action((name, options) => { if (!options.file) { - console.error('❌ Please provide a file path using -f or --file'); + console.error(`Please provide a file path using -f or --file`); process.exit(1); } @@ -60,61 +77,83 @@ program output: process.stdout, }); - rl.question(`⚠️ Are you sure you want to delete "${name}" at ${filePath}? (y/n): `, (answer) => { + rl.question(`Are you sure you want to delete "${name}" at ${filePath}? (y/n): `, (answer) => { rl.close(); - if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') { + if (answer.toLowerCase() === `y` || answer.toLowerCase() === `yes`) { fs.unlink(filePath, (err) => { if (err) { - console.error(`❌ Failed to delete file: ${filePath}`); + console.error(`Failed to delete file: ${filePath}`); console.error(err.message); } else { - console.log(`✅ Snippet "${name}" deleted from ${filePath}`); + console.log(`Snippet "${name}" deleted from ${filePath}`); } }); } else { - console.log('❎ Deletion cancelled.'); + console.log(`Deletion cancelled.`); } }); }); + //edit-snippet program -.command('edit-snippet ') -.description('Edit an existing snippet') -.option('-l, --lang ', 'New programming language') -.option('-d, --desc ', 'New description') -.option('-f, --file ', 'Path to the file to overwrite') // ✅ Fix is here -.option('--tags ', 'New comma-separated tags', val => val.split(',')) +.command(`edit-snippet `) +.description(`Edit an existing snippet`) +.option(`-l, --lang `, `New programming language`) +.option(`-d, --desc `, `New description`) +.option(`-f, --file `, `Path to the file to overwrite`) // ✅ Fix is here +.option(`--tags `, `New comma-separated tags`, val => val.split(`,`)) .action((name, options) => { if (!options.file) { - console.error('❌ Please provide the file path using -f or --file'); + console.error(`Please provide the file path using -f or --file`); process.exit(1); } const filePath = path.resolve(options.file); if (!fs.existsSync(filePath)) { - console.error(`❌ File not found: ${filePath}`); + console.error(`File not found: ${filePath}`); process.exit(1); } - console.log(`✏️ Editing snippet "${name}" at ${filePath}`); + console.log(`Editing snippet "${name}" at ${filePath}`); if (options.lang) { - console.log(`🧠 Language updated to: ${options.lang}`); + console.log(`Language updated to: ${options.lang}`); } if (options.desc) { - console.log(`📝 Description updated to: ${options.desc}`); + console.log(`Description updated to: ${options.desc}`); } if (options.tags) { - console.log(`🏷️ Tags updated to: ${options.tags.join(', ')}`); + console.log(`Tags updated to: ${options.tags.join(`, `)}`); } - console.log('✅ Edit command completed (metadata displayed, file not changed)'); + console.log(` Edit command completed (metadata displayed, file not changed)`); +}); + +//list snippet +program +.command(`list-snippet`) +.description(`List all your snippets`) +.action(() => { + const snippets = loadSnippets(); + if (snippets.length===0){ + console.log(`No snippets saved yet`); + return; + } +console.log(`Saved snippets`); +snippets.forEach((snip,index) =>{ + console.log(`Snippet- ${index + 1}`); + console.log(` Name: ${snip.name}`); + console.log(`language: ${snip.lang}`); + console.log(`Description: ${snip.desc}`); + console.log(`File path: ${snip.filepath}`); + console.log(`Tags: ${snip.tags?.join(`, `)}`); +}); }); -//list and view snippet pending +//view snippet pending program.parse(process.argv); \ No newline at end of file diff --git a/snippet.json b/snippet.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/snippet.json @@ -0,0 +1 @@ +[] From c8aeb1700cddeb1df4e6ae2f2c278858567c5a31 Mon Sep 17 00:00:00 2001 From: samridh-111 Date: Wed, 9 Jul 2025 10:14:34 +0530 Subject: [PATCH 4/9] Added view and list snippet. currently working on search snippet (commented out). also storing snippets locally in snippet.json --- index.js | 96 +++++++++++-- package-lock.json | 337 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 + snippet.json | 10 +- 4 files changed, 435 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 892867a..c689c7f 100755 --- a/index.js +++ b/index.js @@ -2,8 +2,9 @@ import { Command } from 'commander'; import readline from 'readline'; -import fs from 'fs'; +import fs, { read } from 'fs'; import path, { resolve } from 'path'; +import clipboardy from 'clipboardy'; import { json } from 'stream/consumers'; // const {PrismaClient}=require(`@prisma/client`); const DATA_FILE=path.resolve('./snippet.json'); @@ -50,13 +51,21 @@ program .option(`-f, --file `, `Path to the file containing the snippet`) .option(`--tags `, `Comma-separated tags`, val => val.split(`,`)) .action((name, options) => { - console.log(`Name:`, name); - console.log(`Language:`, options.lang); - console.log(`Description:`, options.desc); - console.log(`File Path:`, options.file); - console.log(`Tags:`, options.tags); - }); + const snippets = loadSnippets(); + + const newSnippet = { + name, + lang: options.lang || '', + desc: options.desc || '', + file: options.file || '', + tags: options.tags || [], + }; + snippets.push(newSnippet); + savedSnippets(snippets); + + console.log(` Snippet "${name}" saved successfully.`); +}); //delete snippet program @@ -104,7 +113,7 @@ program .option(`-l, --lang `, `New programming language`) .option(`-d, --desc `, `New description`) .option(`-f, --file `, `Path to the file to overwrite`) // ✅ Fix is here -.option(`--tags `, `New comma-separated tags`, val => val.split(`,`)) + .option(`--tags `, `New comma-separated tags`, val => val.split(`,`)) .action((name, options) => { if (!options.file) { console.error(`Please provide the file path using -f or --file`); @@ -155,5 +164,74 @@ snippets.forEach((snip,index) =>{ }); -//view snippet pending +//view snippet +program +.command('view-snippet ') +.description('view specific snippets') +.action((name)=>{ + const snippets= loadSnippets(); + const snippet=snippets.find(s=>s.name===name); + + if(!snippet){ + console.log(`ERROR! snippets not found`); + process.exit(1); + } + + console.log(`\n Snippet details:`); + console.log(`Snippet Name: ${snippet.name}`); + console.log(`Snippet Language: ${snippet.lang}`); + console.log(`Snippet Description: ${snippet.desc}`); + console.log(`Snippet Path: ${snippet.file}`); + console.log(`Snippet Tags: ${snippet.tags?.join(',')||'None'}`); + console.log(`\n Code:`); + + //read and display code + const filePath=path.resolve(snippet.file); + if(!fs.existsSync(filePath)){ + console.log(`ERROR! File path ${filePath} not found`); + process.exit(1); + } + const code= fs.readFileSync(filePath,'utf-8'); + console.log(code); + + //reading the snippet and storing it + const rl =readline.createInterface({ + input:process.stdin, + output:process.stdout + }) + //ask cli user to copy code to clipbaord (y/n options) + rl.question(`do you want to copy the snippet to your cli? (y/n): `,answer =>{ + if(answer.toLowerCase==='y'){ + clipboardy.writeSync(code); + console.log(`The snippet ${name} has been copied to your clipboard`); + }else{ + console.log(`The snippet ${name} has not been copied to your clipboard. exiting view snippet mode.`); + } + rl.close(); + }) +}); + +//search snippet +// program +// .command('search-snippet') +// .description('search for the snippet you are looking for on the basis of language,keywords and tags') +// .option('-l,--lang','Filter on the basis of programming language') +// .option('-k,--key','Filter on the basis of keywords used') +// .option(`--tags `, `New comma-separated tags`, val => val.split(`,`)) + +// action((options)=>{ +// const snippets=loadSnippets; +// const matches=snippets.filter(snippet=>{ +// const matchlang =options.lang? options.lang===snippet.lang:true; +// const matchtag =options.tag?snippet.tag?.includes(options.tag):true; +// const matchkey=options.keywords?fs.readFileSync(path.resolve(filePath),'utf-8').includes(options.keywords):true; + +// return matchlang && matchtag && matchkey; +// }); +// if(!matches.length) return console.log("Snippet not found"); +// matches.forEach((s,i)=>{ +// console.log(`\n ${s+1}.${name}[${s.lang}]`); +// console.log(`Tags: `); +// }) +// }) program.parse(process.argv); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index bf1e9cb..4189f32 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,12 +9,42 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "clipboard": "^2.0.11", + "clipboardy": "^4.0.0", "commander": "^14.0.0" }, "bin": { "mycli": "index.js" } }, + "node_modules/clipboard": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.11.tgz", + "integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==", + "license": "MIT", + "dependencies": { + "good-listener": "^1.2.2", + "select": "^1.1.2", + "tiny-emitter": "^2.0.0" + } + }, + "node_modules/clipboardy": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/clipboardy/-/clipboardy-4.0.0.tgz", + "integrity": "sha512-5mOlNS0mhX0707P2I0aZ2V/cmHUEO/fL7VFLqszkhUsxt7RwnmrInf/eEQKlf5GzvYeHIjT+Ov1HRfNmymlG0w==", + "license": "MIT", + "dependencies": { + "execa": "^8.0.1", + "is-wsl": "^3.1.0", + "is64bit": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/commander": { "version": "14.0.0", "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.0.tgz", @@ -23,6 +53,313 @@ "engines": { "node": ">=20" } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/delegate": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz", + "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==", + "license": "MIT" + }, + "node_modules/execa": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", + "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^8.0.1", + "human-signals": "^5.0.0", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^4.1.0", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": ">=16.17" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/get-stream": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "license": "MIT", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/good-listener": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", + "integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==", + "license": "MIT", + "dependencies": { + "delegate": "^3.1.2" + } + }, + "node_modules/human-signals": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", + "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=16.17.0" + } + }, + "node_modules/is-docker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", + "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-inside-container": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "license": "MIT", + "dependencies": { + "is-docker": "^3.0.0" + }, + "bin": { + "is-inside-container": "cli.js" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-wsl": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz", + "integrity": "sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==", + "license": "MIT", + "dependencies": { + "is-inside-container": "^1.0.0" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is64bit": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is64bit/-/is64bit-2.0.0.tgz", + "integrity": "sha512-jv+8jaWCl0g2lSBkNSVXdzfBA0npK1HGC2KtWM9FumFRoGS94g3NbCCLVnCYHLjp4GrW2KZeeSTMo5ddtznmGw==", + "license": "MIT", + "dependencies": { + "system-architecture": "^0.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "license": "ISC" + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "license": "MIT" + }, + "node_modules/mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/npm-run-path": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", + "integrity": "sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==", + "license": "MIT", + "dependencies": { + "path-key": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/npm-run-path/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/onetime": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", + "license": "MIT", + "dependencies": { + "mimic-fn": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/select": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", + "integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA==", + "license": "MIT" + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/strip-final-newline": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/system-architecture": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/system-architecture/-/system-architecture-0.1.0.tgz", + "integrity": "sha512-ulAk51I9UVUyJgxlv9M6lFot2WP3e7t8Kz9+IS6D4rVba1tR9kON+Ey69f+1R4Q8cd45Lod6a4IcJIxnzGc/zA==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/tiny-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", + "license": "MIT" + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } } } } diff --git a/package.json b/package.json index 0f6ebc1..3a1b55d 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,8 @@ "author": "", "license": "ISC", "dependencies": { + "clipboard": "^2.0.11", + "clipboardy": "^4.0.0", "commander": "^14.0.0" } } diff --git a/snippet.json b/snippet.json index fe51488..4b96e14 100644 --- a/snippet.json +++ b/snippet.json @@ -1 +1,9 @@ -[] +[ + { + "name": "testing", + "lang": "python", + "desc": "testing", + "file": "./index.js", + "tags": [] + } +] \ No newline at end of file From cdfa9ada93a511abb7761d9237d894f73304d3bd Mon Sep 17 00:00:00 2001 From: samridh-111 Date: Sat, 12 Jul 2025 11:27:33 +0530 Subject: [PATCH 5/9] search snippet function added. can filter on the basis of language, tags and any specific keywords --- index.js | 64 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/index.js b/index.js index c689c7f..67ac8cd 100755 --- a/index.js +++ b/index.js @@ -18,7 +18,19 @@ function loadSnippets(){ return[]; } const data =fs.readFileSync(DATA_FILE,'utf-8'); - return JSON.parse(data); + + try{ + const parsed =JSON.parse(data); + if(Array.isArray(parsed)){ + return parsed; + }else{ + console.log(`Snippet DB is not an array`); + return[]; + } + }catch(err){ + console.error(`JSON not passed error`.err.message); + return[]; + } } //save snippets to JSON file @@ -201,7 +213,7 @@ program }) //ask cli user to copy code to clipbaord (y/n options) rl.question(`do you want to copy the snippet to your cli? (y/n): `,answer =>{ - if(answer.toLowerCase==='y'){ + if(answer.toLowerCase()==='y'){ clipboardy.writeSync(code); console.log(`The snippet ${name} has been copied to your clipboard`); }else{ @@ -211,27 +223,29 @@ program }) }); -//search snippet -// program -// .command('search-snippet') -// .description('search for the snippet you are looking for on the basis of language,keywords and tags') -// .option('-l,--lang','Filter on the basis of programming language') -// .option('-k,--key','Filter on the basis of keywords used') -// .option(`--tags `, `New comma-separated tags`, val => val.split(`,`)) - -// action((options)=>{ -// const snippets=loadSnippets; -// const matches=snippets.filter(snippet=>{ -// const matchlang =options.lang? options.lang===snippet.lang:true; -// const matchtag =options.tag?snippet.tag?.includes(options.tag):true; -// const matchkey=options.keywords?fs.readFileSync(path.resolve(filePath),'utf-8').includes(options.keywords):true; - -// return matchlang && matchtag && matchkey; -// }); -// if(!matches.length) return console.log("Snippet not found"); -// matches.forEach((s,i)=>{ -// console.log(`\n ${s+1}.${name}[${s.lang}]`); -// console.log(`Tags: `); -// }) -// }) +// search snippet +program +.command('search-snippet') +.description('search for the snippet you are looking for on the basis of language,keywords and tags') +.option('-l,--lang','Filter on the basis of programming language') +.option('-k,--key','Filter on the basis of keywords used') +.option(`--tags `, `New comma-separated tags`, val => val.split(`,`)) + +.action((options)=>{ + const snippets=loadSnippets(); + const matches=snippets.filter(snippet=>{ + const matchlang =options.lang? options.lang===snippet.lang:true; + const matchtag =options.tag?snippet.tag?.includes(options.tag):true; + const matchkey=options.keywords?fs.readFileSync(path.resolve(filePath),'utf-8').includes(options.keywords):true; + + return matchlang && matchtag && matchkey; + }); + if(!matches.length) return console.log("Snippet not found"); + matches.forEach((s,i)=>{ + console.log(`\n ${i+1}. ${s.name}[${s.lang}]`); + console.log(`Tags: ${snippets.tags?.join(', ')}`); + console.log(`File: ${s.file}`); + console.log('-----------------------------'); + }) +}) program.parse(process.argv); \ No newline at end of file From 9c85c4b8cdc4f2ae0b0a69e638f6fab8ab1e1470 Mon Sep 17 00:00:00 2001 From: samridh-111 Date: Mon, 21 Jul 2025 12:20:37 +0530 Subject: [PATCH 6/9] Updated Search function to support Fuzzy Search (commented out previous search function for now) --- index.js | 30 ++++++++++++++++++++++++++++-- package-lock.json | 12 +++++++++++- package.json | 3 ++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 67ac8cd..57af2d3 100755 --- a/index.js +++ b/index.js @@ -1,11 +1,11 @@ #!/usr/bin/env node - import { Command } from 'commander'; import readline from 'readline'; import fs, { read } from 'fs'; import path, { resolve } from 'path'; import clipboardy from 'clipboardy'; import { json } from 'stream/consumers'; +import Fuse from 'fuse.js'; // const {PrismaClient}=require(`@prisma/client`); const DATA_FILE=path.resolve('./snippet.json'); @@ -223,7 +223,33 @@ program }) }); -// search snippet +// search snippet (OLDER) +// program +// .command('search-snippet') +// .description('search for the snippet you are looking for on the basis of language,keywords and tags') +// .option('-l,--lang','Filter on the basis of programming language') +// .option('-k,--key','Filter on the basis of keywords used') +// .option(`--tags `, `New comma-separated tags`, val => val.split(`,`)) + +// .action((options)=>{ +// const snippets=loadSnippets(); +// const matches=snippets.filter(snippet=>{ +// const matchlang =options.lang? options.lang===snippet.lang:true; +// const matchtag =options.tag?snippet.tag?.includes(options.tag):true; +// const matchkey=options.keywords?fs.readFileSync(path.resolve(filePath),'utf-8').includes(options.keywords):true; + +// return matchlang && matchtag && matchkey; +// }); +// if(!matches.length) return console.log("Snippet not found"); +// matches.forEach((s,i)=>{ +// console.log(`\n ${i+1}. ${s.name}[${s.lang}]`); +// console.log(`Tags: ${snippets.tags?.join(', ')}`); +// console.log(`File: ${s.file}`); +// console.log('-----------------------------'); +// }) +// }) + +//Search snippet FUZZY program .command('search-snippet') .description('search for the snippet you are looking for on the basis of language,keywords and tags') diff --git a/package-lock.json b/package-lock.json index 4189f32..2ca6ed6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,8 @@ "dependencies": { "clipboard": "^2.0.11", "clipboardy": "^4.0.0", - "commander": "^14.0.0" + "commander": "^14.0.0", + "fuse.js": "^7.1.0" }, "bin": { "mycli": "index.js" @@ -97,6 +98,15 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, + "node_modules/fuse.js": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.1.0.tgz", + "integrity": "sha512-trLf4SzuuUxfusZADLINj+dE8clK1frKdmqiJNb1Es75fmI5oY6X2mxLVUciLLjxqw/xr72Dhy+lER6dGd02FQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=10" + } + }, "node_modules/get-stream": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", diff --git a/package.json b/package.json index 3a1b55d..3bc130b 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "dependencies": { "clipboard": "^2.0.11", "clipboardy": "^4.0.0", - "commander": "^14.0.0" + "commander": "^14.0.0", + "fuse.js": "^7.1.0" } } From fdb409a4c51632a13bc7ca388cd5f917b35c28a9 Mon Sep 17 00:00:00 2001 From: samridh-111 Date: Mon, 21 Jul 2025 22:17:12 +0530 Subject: [PATCH 7/9] prettier commit --- index.js | 326 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 169 insertions(+), 157 deletions(-) diff --git a/index.js b/index.js index 57af2d3..8b266db 100755 --- a/index.js +++ b/index.js @@ -1,58 +1,57 @@ #!/usr/bin/env node -import { Command } from 'commander'; -import readline from 'readline'; -import fs, { read } from 'fs'; -import path, { resolve } from 'path'; -import clipboardy from 'clipboardy'; -import { json } from 'stream/consumers'; -import Fuse from 'fuse.js'; +import { Command } from "commander"; +import readline from "readline"; +import fs, { read } from "fs"; +import path, { resolve } from "path"; +import clipboardy from "clipboardy"; +import { json } from "stream/consumers"; +import Fuse from "fuse.js"; // const {PrismaClient}=require(`@prisma/client`); -const DATA_FILE=path.resolve('./snippet.json'); +const DATA_FILE = path.resolve("./snippet.json"); const program = new Command(); -// const prisma = new PrismaClient(); //for loading snippet from JSON file -function loadSnippets(){ - if(!fs.existsSync(DATA_FILE)){ - return[]; +function loadSnippets() { + if (!fs.existsSync(DATA_FILE)) { + return []; } - const data =fs.readFileSync(DATA_FILE,'utf-8'); + const data = fs.readFileSync(DATA_FILE, "utf-8"); - try{ - const parsed =JSON.parse(data); - if(Array.isArray(parsed)){ + try { + const parsed = JSON.parse(data); + if (Array.isArray(parsed)) { return parsed; - }else{ + } else { console.log(`Snippet DB is not an array`); - return[]; + return []; } - }catch(err){ + } catch (err) { console.error(`JSON not passed error`.err.message); - return[]; + return []; } } //save snippets to JSON file -function savedSnippets(snippets){ - fs.writeFileSync(DATA_FILE,JSON.stringify(snippets,null,2),'utf-8') +function savedSnippets(snippets) { + fs.writeFileSync(DATA_FILE, JSON.stringify(snippets, null, 2), "utf-8"); } - //cli code starts here program -.name('snippet-cli') -.description('My Code Snippet CLI program') -.version('1.0.0'); - + .name("snippet-cli") + .description("My Code Snippet CLI program") + .version("1.0.0"); //greeting snippet program -.command(`hi `) -.description(`Says hi to the user`) -.action((name) => { - console.log(`Hello ${name}, Welcome to the CLI: what are we here for today:`); -}); + .command(`hi `) + .description(`Says hi to the user`) + .action((name) => { + console.log( + `Hello ${name}, Welcome to the CLI: what are we here for today:` + ); + }); //add snippet program @@ -61,23 +60,23 @@ program .option(`-l, --lang `, `Specify the programming language`) .option(`-d, --desc `, `Describe the code snippet`) .option(`-f, --file `, `Path to the file containing the snippet`) - .option(`--tags `, `Comma-separated tags`, val => val.split(`,`)) + .option(`--tags `, `Comma-separated tags`, (val) => val.split(`,`)) .action((name, options) => { - const snippets = loadSnippets(); + const snippets = loadSnippets(); - const newSnippet = { - name, - lang: options.lang || '', - desc: options.desc || '', - file: options.file || '', - tags: options.tags || [], - }; + const newSnippet = { + name, + lang: options.lang || "", + desc: options.desc || "", + file: options.file || "", + tags: options.tags || [], + }; - snippets.push(newSnippet); - savedSnippets(snippets); + snippets.push(newSnippet); + savedSnippets(snippets); - console.log(` Snippet "${name}" saved successfully.`); -}); + console.log(` Snippet "${name}" saved successfully.`); + }); //delete snippet program @@ -98,35 +97,36 @@ program output: process.stdout, }); - rl.question(`Are you sure you want to delete "${name}" at ${filePath}? (y/n): `, (answer) => { - rl.close(); - - if (answer.toLowerCase() === `y` || answer.toLowerCase() === `yes`) { - fs.unlink(filePath, (err) => { - if (err) { - console.error(`Failed to delete file: ${filePath}`); - console.error(err.message); - } else { - console.log(`Snippet "${name}" deleted from ${filePath}`); - } - }); - } else { - console.log(`Deletion cancelled.`); + rl.question( + `Are you sure you want to delete "${name}" at ${filePath}? (y/n): `, + (answer) => { + rl.close(); + + if (answer.toLowerCase() === `y` || answer.toLowerCase() === `yes`) { + fs.unlink(filePath, (err) => { + if (err) { + console.error(`Failed to delete file: ${filePath}`); + console.error(err.message); + } else { + console.log(`Snippet "${name}" deleted from ${filePath}`); + } + }); + } else { + console.log(`Deletion cancelled.`); + } } - }); + ); }); - - //edit-snippet program -.command(`edit-snippet `) -.description(`Edit an existing snippet`) -.option(`-l, --lang `, `New programming language`) -.option(`-d, --desc `, `New description`) -.option(`-f, --file `, `Path to the file to overwrite`) // ✅ Fix is here - .option(`--tags `, `New comma-separated tags`, val => val.split(`,`)) -.action((name, options) => { + .command(`edit-snippet `) + .description(`Edit an existing snippet`) + .option(`-l, --lang `, `New programming language`) + .option(`-d, --desc `, `New description`) + .option(`-f, --file `, `Path to the file to overwrite`) // ✅ Fix is here + .option(`--tags `, `New comma-separated tags`, (val) => val.split(`,`)) + .action((name, options) => { if (!options.file) { console.error(`Please provide the file path using -f or --file`); process.exit(1); @@ -140,7 +140,7 @@ program } console.log(`Editing snippet "${name}" at ${filePath}`); - + if (options.lang) { console.log(`Language updated to: ${options.lang}`); } @@ -151,77 +151,83 @@ program console.log(`Tags updated to: ${options.tags.join(`, `)}`); } - console.log(` Edit command completed (metadata displayed, file not changed)`); -}); + console.log( + ` Edit command completed (metadata displayed, file not changed)` + ); + }); //list snippet program -.command(`list-snippet`) -.description(`List all your snippets`) -.action(() => { - const snippets = loadSnippets(); - if (snippets.length===0){ - console.log(`No snippets saved yet`); - return; - } -console.log(`Saved snippets`); -snippets.forEach((snip,index) =>{ - console.log(`Snippet- ${index + 1}`); - console.log(` Name: ${snip.name}`); - console.log(`language: ${snip.lang}`); - console.log(`Description: ${snip.desc}`); - console.log(`File path: ${snip.filepath}`); - console.log(`Tags: ${snip.tags?.join(`, `)}`); -}); -}); - + .command(`list-snippet`) + .description(`List all your snippets`) + .action(() => { + const snippets = loadSnippets(); + if (snippets.length === 0) { + console.log(`No snippets saved yet`); + return; + } + console.log(`Saved snippets`); + snippets.forEach((snip, index) => { + console.log(`Snippet- ${index + 1}`); + console.log(` Name: ${snip.name}`); + console.log(`language: ${snip.lang}`); + console.log(`Description: ${snip.desc}`); + console.log(`File path: ${snip.filepath}`); + console.log(`Tags: ${snip.tags?.join(`, `)}`); + }); + }); //view snippet program -.command('view-snippet ') -.description('view specific snippets') -.action((name)=>{ - const snippets= loadSnippets(); - const snippet=snippets.find(s=>s.name===name); - - if(!snippet){ - console.log(`ERROR! snippets not found`); - process.exit(1); - } + .command("view-snippet ") + .description("view specific snippets") + .action((name) => { + const snippets = loadSnippets(); + const snippet = snippets.find((s) => s.name === name); + + if (!snippet) { + console.log(`ERROR! snippets not found`); + process.exit(1); + } - console.log(`\n Snippet details:`); - console.log(`Snippet Name: ${snippet.name}`); - console.log(`Snippet Language: ${snippet.lang}`); - console.log(`Snippet Description: ${snippet.desc}`); - console.log(`Snippet Path: ${snippet.file}`); - console.log(`Snippet Tags: ${snippet.tags?.join(',')||'None'}`); - console.log(`\n Code:`); - - //read and display code - const filePath=path.resolve(snippet.file); - if(!fs.existsSync(filePath)){ - console.log(`ERROR! File path ${filePath} not found`); - process.exit(1); - } - const code= fs.readFileSync(filePath,'utf-8'); - console.log(code); - - //reading the snippet and storing it - const rl =readline.createInterface({ - input:process.stdin, - output:process.stdout - }) - //ask cli user to copy code to clipbaord (y/n options) - rl.question(`do you want to copy the snippet to your cli? (y/n): `,answer =>{ - if(answer.toLowerCase()==='y'){ - clipboardy.writeSync(code); - console.log(`The snippet ${name} has been copied to your clipboard`); - }else{ - console.log(`The snippet ${name} has not been copied to your clipboard. exiting view snippet mode.`); + console.log(`\n Snippet details:`); + console.log(`Snippet Name: ${snippet.name}`); + console.log(`Snippet Language: ${snippet.lang}`); + console.log(`Snippet Description: ${snippet.desc}`); + console.log(`Snippet Path: ${snippet.file}`); + console.log(`Snippet Tags: ${snippet.tags?.join(",") || "None"}`); + console.log(`\n Code:`); + + //read and display code + const filePath = path.resolve(snippet.file); + if (!fs.existsSync(filePath)) { + console.log(`ERROR! File path ${filePath} not found`); + process.exit(1); } - rl.close(); - }) -}); + const code = fs.readFileSync(filePath, "utf-8"); + console.log(code); + + //reading the snippet and storing it + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + }); + //ask cli user to copy code to clipbaord (y/n options) + rl.question( + `do you want to copy the snippet to your cli? (y/n): `, + (answer) => { + if (answer.toLowerCase() === "y") { + clipboardy.writeSync(code); + console.log(`The snippet ${name} has been copied to your clipboard`); + } else { + console.log( + `The snippet ${name} has not been copied to your clipboard. exiting view snippet mode.` + ); + } + rl.close(); + } + ); + }); // search snippet (OLDER) // program @@ -249,29 +255,35 @@ program // }) // }) -//Search snippet FUZZY +//Search snippet FUZZY program -.command('search-snippet') -.description('search for the snippet you are looking for on the basis of language,keywords and tags') -.option('-l,--lang','Filter on the basis of programming language') -.option('-k,--key','Filter on the basis of keywords used') -.option(`--tags `, `New comma-separated tags`, val => val.split(`,`)) - -.action((options)=>{ - const snippets=loadSnippets(); - const matches=snippets.filter(snippet=>{ - const matchlang =options.lang? options.lang===snippet.lang:true; - const matchtag =options.tag?snippet.tag?.includes(options.tag):true; - const matchkey=options.keywords?fs.readFileSync(path.resolve(filePath),'utf-8').includes(options.keywords):true; - - return matchlang && matchtag && matchkey; + .command("search-snippet") + .description( + "search for the snippet you are looking for on the basis of language,keywords and tags" + ) + .option("-l,--lang", "Filter on the basis of programming language") + .option("-k,--key", "Filter on the basis of keywords used") + .option(`--tags `, `New comma-separated tags`, (val) => val.split(`,`)) + + .action((options) => { + const snippets = loadSnippets(); + const matches = snippets.filter((snippet) => { + const matchlang = options.lang ? options.lang === snippet.lang : true; + const matchtag = options.tag ? snippet.tag?.includes(options.tag) : true; + const matchkey = options.keywords + ? fs + .readFileSync(path.resolve(filePath), "utf-8") + .includes(options.keywords) + : true; + + return matchlang && matchtag && matchkey; + }); + if (!matches.length) return console.log("Snippet not found"); + matches.forEach((s, i) => { + console.log(`\n ${i + 1}. ${s.name}[${s.lang}]`); + console.log(`Tags: ${snippets.tags?.join(", ")}`); + console.log(`File: ${s.file}`); + console.log("-----------------------------"); + }); }); - if(!matches.length) return console.log("Snippet not found"); - matches.forEach((s,i)=>{ - console.log(`\n ${i+1}. ${s.name}[${s.lang}]`); - console.log(`Tags: ${snippets.tags?.join(', ')}`); - console.log(`File: ${s.file}`); - console.log('-----------------------------'); - }) -}) -program.parse(process.argv); \ No newline at end of file +program.parse(process.argv); From 5c76e91912dbe988cabd7a63334d0eea298491b6 Mon Sep 17 00:00:00 2001 From: samridh-111 Date: Thu, 31 Jul 2025 22:44:31 +0530 Subject: [PATCH 8/9] Schema creation --- .env | 11 ++ .gitignore | 3 +- package-lock.json | 261 ++++++++++++++++++++++++++++++++++++++++++- package.json | 5 +- prisma/schema.prisma | 15 +++ 5 files changed, 292 insertions(+), 3 deletions(-) create mode 100644 .env create mode 100644 prisma/schema.prisma diff --git a/.env b/.env new file mode 100644 index 0000000..0337c21 --- /dev/null +++ b/.env @@ -0,0 +1,11 @@ +# Environment variables declared in this file are automatically made available to Prisma. +# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema + +# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. +# See the documentation for all the connection string options: https://pris.ly/d/connection-strings + +# The following `prisma+postgres` URL is similar to the URL produced by running a local Prisma Postgres +# server with the `prisma dev` CLI command, when not choosing any non-default ports or settings. The API key, unlike the +# one found in a remote Prisma Postgres URL, does not contain any sensitive information. + +DATABASE_URL="prisma+postgres://localhost:51213/?api_key=eyJkYXRhYmFzZVVybCI6InBvc3RncmVzOi8vcG9zdGdyZXM6cG9zdGdyZXNAbG9jYWxob3N0OjUxMjE0L3RlbXBsYXRlMT9zc2xtb2RlPWRpc2FibGUmY29ubmVjdGlvbl9saW1pdD0xJmNvbm5lY3RfdGltZW91dD0wJm1heF9pZGxlX2Nvbm5lY3Rpb25fbGlmZXRpbWU9MCZwb29sX3RpbWVvdXQ9MCZzaW5nbGVfdXNlX2Nvbm5lY3Rpb25zPXRydWUmc29ja2V0X3RpbWVvdXQ9MCIsIm5hbWUiOiJkZWZhdWx0Iiwic2hhZG93RGF0YWJhc2VVcmwiOiJwb3N0Z3JlczovL3Bvc3RncmVzOnBvc3RncmVzQGxvY2FsaG9zdDo1MTIxNS90ZW1wbGF0ZTE_c3NsbW9kZT1kaXNhYmxlJmNvbm5lY3Rpb25fbGltaXQ9MSZjb25uZWN0X3RpbWVvdXQ9MCZtYXhfaWRsZV9jb25uZWN0aW9uX2xpZmV0aW1lPTAmcG9vbF90aW1lb3V0PTAmc2luZ2xlX3VzZV9jb25uZWN0aW9ucz10cnVlJnNvY2tldF90aW1lb3V0PTAifQ" \ No newline at end of file diff --git a/.gitignore b/.gitignore index b512c09..10b20fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +/generated/prisma diff --git a/package-lock.json b/package-lock.json index 2ca6ed6..6707e45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,15 +9,94 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "@prisma/client": "^6.12.0", "clipboard": "^2.0.11", "clipboardy": "^4.0.0", "commander": "^14.0.0", - "fuse.js": "^7.1.0" + "fuse.js": "^7.1.0", + "pg": "^8.16.3", + "prisma": "^6.12.0" }, "bin": { "mycli": "index.js" } }, + "node_modules/@prisma/client": { + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-6.12.0.tgz", + "integrity": "sha512-wn98bJ3Cj6edlF4jjpgXwbnQIo/fQLqqQHPk2POrZPxTlhY3+n90SSIF3LMRVa8VzRFC/Gec3YKJRxRu+AIGVA==", + "hasInstallScript": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "peerDependencies": { + "prisma": "*", + "typescript": ">=5.1.0" + }, + "peerDependenciesMeta": { + "prisma": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/@prisma/config": { + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/@prisma/config/-/config-6.12.0.tgz", + "integrity": "sha512-HovZWzhWEMedHxmjefQBRZa40P81N7/+74khKFz9e1AFjakcIQdXgMWKgt20HaACzY+d1LRBC+L4tiz71t9fkg==", + "license": "Apache-2.0", + "dependencies": { + "jiti": "2.4.2" + } + }, + "node_modules/@prisma/debug": { + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.12.0.tgz", + "integrity": "sha512-plbz6z72orcqr0eeio7zgUrZj5EudZUpAeWkFTA/DDdXEj28YHDXuiakvR6S7sD6tZi+jiwQEJAPeV6J6m/tEQ==", + "license": "Apache-2.0" + }, + "node_modules/@prisma/engines": { + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-6.12.0.tgz", + "integrity": "sha512-4BRZZUaAuB4p0XhTauxelvFs7IllhPmNLvmla0bO1nkECs8n/o1pUvAVbQ/VOrZR5DnF4HED0PrGai+rIOVePA==", + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@prisma/debug": "6.12.0", + "@prisma/engines-version": "6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc", + "@prisma/fetch-engine": "6.12.0", + "@prisma/get-platform": "6.12.0" + } + }, + "node_modules/@prisma/engines-version": { + "version": "6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc.tgz", + "integrity": "sha512-70vhecxBJlRr06VfahDzk9ow4k1HIaSfVUT3X0/kZoHCMl9zbabut4gEXAyzJZxaCGi5igAA7SyyfBI//mmkbQ==", + "license": "Apache-2.0" + }, + "node_modules/@prisma/fetch-engine": { + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.12.0.tgz", + "integrity": "sha512-EamoiwrK46rpWaEbLX9aqKDPOd8IyLnZAkiYXFNuq0YsU0Z8K09/rH8S7feOWAVJ3xzeSgcEJtBlVDrajM9Sag==", + "license": "Apache-2.0", + "dependencies": { + "@prisma/debug": "6.12.0", + "@prisma/engines-version": "6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc", + "@prisma/get-platform": "6.12.0" + } + }, + "node_modules/@prisma/get-platform": { + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.12.0.tgz", + "integrity": "sha512-nRerTGhTlgyvcBlyWgt8OLNIV7QgJS2XYXMJD1hysorMCuLAjuDDuoxmVt7C2nLxbuxbWPp7OuFRHC23HqD9dA==", + "license": "Apache-2.0", + "dependencies": { + "@prisma/debug": "6.12.0" + } + }, "node_modules/clipboard": { "version": "2.0.11", "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.11.tgz", @@ -218,6 +297,15 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "license": "ISC" }, + "node_modules/jiti": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.2.tgz", + "integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==", + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -287,6 +375,159 @@ "node": ">=8" } }, + "node_modules/pg": { + "version": "8.16.3", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.16.3.tgz", + "integrity": "sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw==", + "license": "MIT", + "dependencies": { + "pg-connection-string": "^2.9.1", + "pg-pool": "^3.10.1", + "pg-protocol": "^1.10.3", + "pg-types": "2.2.0", + "pgpass": "1.0.5" + }, + "engines": { + "node": ">= 16.0.0" + }, + "optionalDependencies": { + "pg-cloudflare": "^1.2.7" + }, + "peerDependencies": { + "pg-native": ">=3.0.1" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } + }, + "node_modules/pg-cloudflare": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.2.7.tgz", + "integrity": "sha512-YgCtzMH0ptvZJslLM1ffsY4EuGaU0cx4XSdXLRFae8bPP4dS5xL1tNB3k2o/N64cHJpwU7dxKli/nZ2lUa5fLg==", + "license": "MIT", + "optional": true + }, + "node_modules/pg-connection-string": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.9.1.tgz", + "integrity": "sha512-nkc6NpDcvPVpZXxrreI/FOtX3XemeLl8E0qFr6F2Lrm/I8WOnaWNhIPK2Z7OHpw7gh5XJThi6j6ppgNoaT1w4w==", + "license": "MIT" + }, + "node_modules/pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", + "license": "ISC", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/pg-pool": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.10.1.tgz", + "integrity": "sha512-Tu8jMlcX+9d8+QVzKIvM/uJtp07PKr82IUOYEphaWcoBhIYkoHpLXN3qO59nAI11ripznDsEzEv8nUxBVWajGg==", + "license": "MIT", + "peerDependencies": { + "pg": ">=8.0" + } + }, + "node_modules/pg-protocol": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.10.3.tgz", + "integrity": "sha512-6DIBgBQaTKDJyxnXaLiLR8wBpQQcGWuAESkRBX/t6OwA8YsqP+iVSiond2EDy6Y/dsGk8rh/jtax3js5NeV7JQ==", + "license": "MIT" + }, + "node_modules/pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "license": "MIT", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "license": "MIT", + "dependencies": { + "split2": "^4.1.0" + } + }, + "node_modules/postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/postgres-bytea": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", + "integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "license": "MIT", + "dependencies": { + "xtend": "^4.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/prisma": { + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-6.12.0.tgz", + "integrity": "sha512-pmV7NEqQej9WjizN6RSNIwf7Y+jeh9mY1JEX2WjGxJi4YZWexClhde1yz/FuvAM+cTwzchcMytu2m4I6wPkIzg==", + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@prisma/config": "6.12.0", + "@prisma/engines": "6.12.0" + }, + "bin": { + "prisma": "build/index.js" + }, + "engines": { + "node": ">=18.18" + }, + "peerDependencies": { + "typescript": ">=5.1.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/select": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", @@ -326,6 +567,15 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, "node_modules/strip-final-newline": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", @@ -370,6 +620,15 @@ "engines": { "node": ">= 8" } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "license": "MIT", + "engines": { + "node": ">=0.4" + } } } } diff --git a/package.json b/package.json index 3bc130b..be2b7a5 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,12 @@ "author": "", "license": "ISC", "dependencies": { + "@prisma/client": "^6.12.0", "clipboard": "^2.0.11", "clipboardy": "^4.0.0", "commander": "^14.0.0", - "fuse.js": "^7.1.0" + "fuse.js": "^7.1.0", + "pg": "^8.16.3", + "prisma": "^6.12.0" } } diff --git a/prisma/schema.prisma b/prisma/schema.prisma new file mode 100644 index 0000000..e8b9fe9 --- /dev/null +++ b/prisma/schema.prisma @@ -0,0 +1,15 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? +// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init + +generator client { + provider = "prisma-client-js" + output = "../generated/prisma" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} From 241af00b4d51f642228c136bd0526cab87c870f4 Mon Sep 17 00:00:00 2001 From: samridh-111 Date: Thu, 7 Aug 2025 19:39:33 +0530 Subject: [PATCH 9/9] Prisma set up and databse testing --- .env | 2 +- index.js | 364 ++++++++++----------------- lib/prisma.js | 5 + package-lock.json | 571 ++++++++++++++++++++++++++++++++++++++++--- package.json | 4 +- prisma/schema.prisma | 18 +- snippet.json | 9 - 7 files changed, 685 insertions(+), 288 deletions(-) create mode 100644 lib/prisma.js delete mode 100644 snippet.json diff --git a/.env b/.env index 0337c21..78297e6 100644 --- a/.env +++ b/.env @@ -8,4 +8,4 @@ # server with the `prisma dev` CLI command, when not choosing any non-default ports or settings. The API key, unlike the # one found in a remote Prisma Postgres URL, does not contain any sensitive information. -DATABASE_URL="prisma+postgres://localhost:51213/?api_key=eyJkYXRhYmFzZVVybCI6InBvc3RncmVzOi8vcG9zdGdyZXM6cG9zdGdyZXNAbG9jYWxob3N0OjUxMjE0L3RlbXBsYXRlMT9zc2xtb2RlPWRpc2FibGUmY29ubmVjdGlvbl9saW1pdD0xJmNvbm5lY3RfdGltZW91dD0wJm1heF9pZGxlX2Nvbm5lY3Rpb25fbGlmZXRpbWU9MCZwb29sX3RpbWVvdXQ9MCZzaW5nbGVfdXNlX2Nvbm5lY3Rpb25zPXRydWUmc29ja2V0X3RpbWVvdXQ9MCIsIm5hbWUiOiJkZWZhdWx0Iiwic2hhZG93RGF0YWJhc2VVcmwiOiJwb3N0Z3JlczovL3Bvc3RncmVzOnBvc3RncmVzQGxvY2FsaG9zdDo1MTIxNS90ZW1wbGF0ZTE_c3NsbW9kZT1kaXNhYmxlJmNvbm5lY3Rpb25fbGltaXQ9MSZjb25uZWN0X3RpbWVvdXQ9MCZtYXhfaWRsZV9jb25uZWN0aW9uX2xpZmV0aW1lPTAmcG9vbF90aW1lb3V0PTAmc2luZ2xlX3VzZV9jb25uZWN0aW9ucz10cnVlJnNvY2tldF90aW1lb3V0PTAifQ" \ No newline at end of file +DATABASE_URL="postgresql://postgres.wgxbziqzoxkhmhvrqaee:Samsamdatabase1212@aws-0-us-east-2.pooler.supabase.com:5432/postgres" \ No newline at end of file diff --git a/index.js b/index.js index 8b266db..4b461a5 100755 --- a/index.js +++ b/index.js @@ -1,289 +1,189 @@ #!/usr/bin/env node import { Command } from "commander"; +import fs from "fs"; +import path from "path"; import readline from "readline"; -import fs, { read } from "fs"; -import path, { resolve } from "path"; import clipboardy from "clipboardy"; -import { json } from "stream/consumers"; -import Fuse from "fuse.js"; -// const {PrismaClient}=require(`@prisma/client`); -const DATA_FILE = path.resolve("./snippet.json"); +import prisma from "./lib/prisma.js"; const program = new Command(); -//for loading snippet from JSON file -function loadSnippets() { - if (!fs.existsSync(DATA_FILE)) { - return []; - } - const data = fs.readFileSync(DATA_FILE, "utf-8"); - - try { - const parsed = JSON.parse(data); - if (Array.isArray(parsed)) { - return parsed; - } else { - console.log(`Snippet DB is not an array`); - return []; - } - } catch (err) { - console.error(`JSON not passed error`.err.message); - return []; - } -} - -//save snippets to JSON file -function savedSnippets(snippets) { - fs.writeFileSync(DATA_FILE, JSON.stringify(snippets, null, 2), "utf-8"); -} - -//cli code starts here program .name("snippet-cli") .description("My Code Snippet CLI program") .version("1.0.0"); -//greeting snippet -program - .command(`hi `) - .description(`Says hi to the user`) - .action((name) => { - console.log( - `Hello ${name}, Welcome to the CLI: what are we here for today:` - ); - }); - -//add snippet +// Add snippet program - .command(`add-snippet `) - .description(`Add your code snippet in the language of your choice`) - .option(`-l, --lang `, `Specify the programming language`) - .option(`-d, --desc `, `Describe the code snippet`) - .option(`-f, --file `, `Path to the file containing the snippet`) - .option(`--tags `, `Comma-separated tags`, (val) => val.split(`,`)) - .action((name, options) => { - const snippets = loadSnippets(); - - const newSnippet = { - name, - lang: options.lang || "", - desc: options.desc || "", - file: options.file || "", - tags: options.tags || [], - }; - - snippets.push(newSnippet); - savedSnippets(snippets); + .command("add-snippet ") + .description("Add a code snippet") + .option("-l, --lang ", "Programming language") + .option("-d, --desc ", "Snippet description") + .option("-f, --file ", "Path to the file containing the snippet") + .option("--tags ", "Comma-separated tags", (val) => val.split(",")) + .action(async (name, options) => { + try { + if (!options.file || !fs.existsSync(options.file)) { + console.error("❌ File path is required and must exist."); + process.exit(1); + } - console.log(` Snippet "${name}" saved successfully.`); + const code = fs.readFileSync(options.file, "utf-8"); + + await prisma.snippet.create({ + data: { + name, + lang: options.lang || "", + desc: options.desc || "", + file: options.file, + tags: options.tags || [], + code, + }, + }); + + console.log(`✅ Snippet "${name}" saved to DB.`); + } catch (err) { + console.error(`❌ Failed to save snippet: ${err.message}`); + } }); -//delete snippet +// Delete snippet program - .command(`delete-snippet `) - .description(`Delete the snippet that you would like to discard`) - .option(`-f, --file `, `Path to the file containing the snippet`) - .action((name, options) => { - if (!options.file) { - console.error(`Please provide a file path using -f or --file`); - process.exit(1); + .command("delete-snippet ") + .description("Delete a snippet from the database") + .action(async (name) => { + try { + await prisma.snippet.delete({ + where: { name }, + }); + console.log(`🗑️ Snippet "${name}" deleted.`); + } catch (err) { + console.error(`❌ Failed to delete: ${err.message}`); } - - const filePath = path.resolve(options.file); - - // Confirm with user before deleting - const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, - }); - - rl.question( - `Are you sure you want to delete "${name}" at ${filePath}? (y/n): `, - (answer) => { - rl.close(); - - if (answer.toLowerCase() === `y` || answer.toLowerCase() === `yes`) { - fs.unlink(filePath, (err) => { - if (err) { - console.error(`Failed to delete file: ${filePath}`); - console.error(err.message); - } else { - console.log(`Snippet "${name}" deleted from ${filePath}`); - } - }); - } else { - console.log(`Deletion cancelled.`); - } - } - ); }); -//edit-snippet +// Edit snippet program - .command(`edit-snippet `) - .description(`Edit an existing snippet`) - .option(`-l, --lang `, `New programming language`) - .option(`-d, --desc `, `New description`) - .option(`-f, --file `, `Path to the file to overwrite`) // ✅ Fix is here - .option(`--tags `, `New comma-separated tags`, (val) => val.split(`,`)) - .action((name, options) => { - if (!options.file) { - console.error(`Please provide the file path using -f or --file`); - process.exit(1); - } - - const filePath = path.resolve(options.file); - - if (!fs.existsSync(filePath)) { - console.error(`File not found: ${filePath}`); - process.exit(1); - } + .command("edit-snippet ") + .description("Edit an existing snippet") + .option("-l, --lang ", "New programming language") + .option("-d, --desc ", "New description") + .option("-f, --file ", "New file path") + .option("--tags ", "New comma-separated tags", (val) => val.split(",")) + .action(async (name, options) => { + try { + const updates = {}; + + if (options.lang) updates.lang = options.lang; + if (options.desc) updates.desc = options.desc; + if (options.tags) updates.tags = options.tags; + + if (options.file) { + if (!fs.existsSync(options.file)) { + console.error("❌ Provided file does not exist."); + process.exit(1); + } + updates.file = options.file; + updates.code = fs.readFileSync(options.file, "utf-8"); + } - console.log(`Editing snippet "${name}" at ${filePath}`); + await prisma.snippet.update({ + where: { name }, + data: updates, + }); - if (options.lang) { - console.log(`Language updated to: ${options.lang}`); + console.log(`✏️ Snippet "${name}" updated.`); + } catch (err) { + console.error(`❌ Failed to update: ${err.message}`); } - if (options.desc) { - console.log(`Description updated to: ${options.desc}`); - } - if (options.tags) { - console.log(`Tags updated to: ${options.tags.join(`, `)}`); - } - - console.log( - ` Edit command completed (metadata displayed, file not changed)` - ); }); -//list snippet +// List snippets program - .command(`list-snippet`) - .description(`List all your snippets`) - .action(() => { - const snippets = loadSnippets(); + .command("list-snippet") + .description("List all snippets") + .action(async () => { + const snippets = await prisma.snippet.findMany(); + if (snippets.length === 0) { - console.log(`No snippets saved yet`); + console.log("📭 No snippets found."); return; } - console.log(`Saved snippets`); - snippets.forEach((snip, index) => { - console.log(`Snippet- ${index + 1}`); - console.log(` Name: ${snip.name}`); - console.log(`language: ${snip.lang}`); - console.log(`Description: ${snip.desc}`); - console.log(`File path: ${snip.filepath}`); - console.log(`Tags: ${snip.tags?.join(`, `)}`); + + snippets.forEach((s, i) => { + console.log(`\n${i + 1}. ${s.name} [${s.lang}]`); + console.log(`📄 ${s.desc}`); + console.log(`📁 ${s.file}`); + console.log(`🏷️ ${s.tags?.join(", ")}`); }); }); -//view snippet +// View a snippet program .command("view-snippet ") - .description("view specific snippets") - .action((name) => { - const snippets = loadSnippets(); - const snippet = snippets.find((s) => s.name === name); + .description("View a specific snippet") + .action(async (name) => { + const snippet = await prisma.snippet.findUnique({ where: { name } }); if (!snippet) { - console.log(`ERROR! snippets not found`); - process.exit(1); + console.log("❌ Snippet not found."); + return; } - console.log(`\n Snippet details:`); - console.log(`Snippet Name: ${snippet.name}`); - console.log(`Snippet Language: ${snippet.lang}`); - console.log(`Snippet Description: ${snippet.desc}`); - console.log(`Snippet Path: ${snippet.file}`); - console.log(`Snippet Tags: ${snippet.tags?.join(",") || "None"}`); - console.log(`\n Code:`); + console.log(`\n📌 Name: ${snippet.name}`); + console.log(`🖋️ Language: ${snippet.lang}`); + console.log(`📝 Description: ${snippet.desc}`); + console.log(`📁 File: ${snippet.file}`); + console.log(`🏷️ Tags: ${snippet.tags?.join(", ")}`); + console.log(`\n📄 Code:\n${snippet.code}`); - //read and display code - const filePath = path.resolve(snippet.file); - if (!fs.existsSync(filePath)) { - console.log(`ERROR! File path ${filePath} not found`); - process.exit(1); - } - const code = fs.readFileSync(filePath, "utf-8"); - console.log(code); - - //reading the snippet and storing it const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); - //ask cli user to copy code to clipbaord (y/n options) - rl.question( - `do you want to copy the snippet to your cli? (y/n): `, - (answer) => { - if (answer.toLowerCase() === "y") { - clipboardy.writeSync(code); - console.log(`The snippet ${name} has been copied to your clipboard`); - } else { - console.log( - `The snippet ${name} has not been copied to your clipboard. exiting view snippet mode.` - ); - } - rl.close(); + + rl.question("📋 Copy to clipboard? (y/n): ", (answer) => { + if (answer.toLowerCase() === "y") { + clipboardy.writeSync(snippet.code); + console.log("✅ Copied to clipboard."); } - ); + rl.close(); + }); }); -// search snippet (OLDER) -// program -// .command('search-snippet') -// .description('search for the snippet you are looking for on the basis of language,keywords and tags') -// .option('-l,--lang','Filter on the basis of programming language') -// .option('-k,--key','Filter on the basis of keywords used') -// .option(`--tags `, `New comma-separated tags`, val => val.split(`,`)) - -// .action((options)=>{ -// const snippets=loadSnippets(); -// const matches=snippets.filter(snippet=>{ -// const matchlang =options.lang? options.lang===snippet.lang:true; -// const matchtag =options.tag?snippet.tag?.includes(options.tag):true; -// const matchkey=options.keywords?fs.readFileSync(path.resolve(filePath),'utf-8').includes(options.keywords):true; - -// return matchlang && matchtag && matchkey; -// }); -// if(!matches.length) return console.log("Snippet not found"); -// matches.forEach((s,i)=>{ -// console.log(`\n ${i+1}. ${s.name}[${s.lang}]`); -// console.log(`Tags: ${snippets.tags?.join(', ')}`); -// console.log(`File: ${s.file}`); -// console.log('-----------------------------'); -// }) -// }) - -//Search snippet FUZZY +// Search snippet (basic) program .command("search-snippet") - .description( - "search for the snippet you are looking for on the basis of language,keywords and tags" - ) - .option("-l,--lang", "Filter on the basis of programming language") - .option("-k,--key", "Filter on the basis of keywords used") - .option(`--tags `, `New comma-separated tags`, (val) => val.split(`,`)) + .description("Search snippets by keyword or tag") + .option("-k, --key ", "Search in name/desc/code") + .option("--tag ", "Search by tag") + .action(async (options) => { + const snippets = await prisma.snippet.findMany(); + + const results = snippets.filter((s) => { + const keywordMatch = options.key + ? [s.name, s.desc, s.code].some((field) => + field?.toLowerCase().includes(options.key.toLowerCase()) + ) + : true; - .action((options) => { - const snippets = loadSnippets(); - const matches = snippets.filter((snippet) => { - const matchlang = options.lang ? options.lang === snippet.lang : true; - const matchtag = options.tag ? snippet.tag?.includes(options.tag) : true; - const matchkey = options.keywords - ? fs - .readFileSync(path.resolve(filePath), "utf-8") - .includes(options.keywords) + const tagMatch = options.tag + ? s.tags?.includes(options.tag) : true; - return matchlang && matchtag && matchkey; + return keywordMatch && tagMatch; }); - if (!matches.length) return console.log("Snippet not found"); - matches.forEach((s, i) => { - console.log(`\n ${i + 1}. ${s.name}[${s.lang}]`); - console.log(`Tags: ${snippets.tags?.join(", ")}`); + + if (!results.length) { + console.log("🔍 No matching snippets."); + return; + } + + results.forEach((s, i) => { + console.log(`\n${i + 1}. ${s.name} [${s.lang}]`); + console.log(`Tags: ${s.tags?.join(", ")}`); console.log(`File: ${s.file}`); - console.log("-----------------------------"); }); }); + program.parse(process.argv); diff --git a/lib/prisma.js b/lib/prisma.js new file mode 100644 index 0000000..4e54f7a --- /dev/null +++ b/lib/prisma.js @@ -0,0 +1,5 @@ +import { PrismaClient } from '@prisma/client'; + +const prisma = new PrismaClient(); + +export default prisma; diff --git a/package-lock.json b/package-lock.json index 6707e45..7dbb362 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,22 +9,45 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@prisma/client": "^6.12.0", + "@prisma/client": "^6.13.0", "clipboard": "^2.0.11", "clipboardy": "^4.0.0", "commander": "^14.0.0", "fuse.js": "^7.1.0", "pg": "^8.16.3", - "prisma": "^6.12.0" + "prisma": "^6.13.0" }, "bin": { "mycli": "index.js" } }, + "node_modules/@babel/code-frame": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", + "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.27.1", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", + "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@prisma/client": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/client/-/client-6.12.0.tgz", - "integrity": "sha512-wn98bJ3Cj6edlF4jjpgXwbnQIo/fQLqqQHPk2POrZPxTlhY3+n90SSIF3LMRVa8VzRFC/Gec3YKJRxRu+AIGVA==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-6.13.0.tgz", + "integrity": "sha512-8m2+I3dQovkV8CkDMluiwEV1TxV9EXdT6xaCz39O6jYw7mkf5gwfmi+cL4LJsEPwz5tG7sreBwkRpEMJedGYUQ==", "hasInstallScript": true, "license": "Apache-2.0", "engines": { @@ -44,57 +67,124 @@ } }, "node_modules/@prisma/config": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/config/-/config-6.12.0.tgz", - "integrity": "sha512-HovZWzhWEMedHxmjefQBRZa40P81N7/+74khKFz9e1AFjakcIQdXgMWKgt20HaACzY+d1LRBC+L4tiz71t9fkg==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/@prisma/config/-/config-6.13.0.tgz", + "integrity": "sha512-OYMM+pcrvj/NqNWCGESSxVG3O7kX6oWuGyvufTUNnDw740KIQvNyA4v0eILgkpuwsKIDU36beZCkUtIt0naTog==", "license": "Apache-2.0", "dependencies": { - "jiti": "2.4.2" + "c12": "3.1.0", + "deepmerge-ts": "7.1.5", + "effect": "3.16.12", + "read-package-up": "11.0.0" } }, "node_modules/@prisma/debug": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.12.0.tgz", - "integrity": "sha512-plbz6z72orcqr0eeio7zgUrZj5EudZUpAeWkFTA/DDdXEj28YHDXuiakvR6S7sD6tZi+jiwQEJAPeV6J6m/tEQ==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.13.0.tgz", + "integrity": "sha512-um+9pfKJW0ihmM83id9FXGi5qEbVJ0Vxi1Gm0xpYsjwUBnw6s2LdPBbrsG9QXRX46K4CLWCTNvskXBup4i9hlw==", "license": "Apache-2.0" }, "node_modules/@prisma/engines": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-6.12.0.tgz", - "integrity": "sha512-4BRZZUaAuB4p0XhTauxelvFs7IllhPmNLvmla0bO1nkECs8n/o1pUvAVbQ/VOrZR5DnF4HED0PrGai+rIOVePA==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-6.13.0.tgz", + "integrity": "sha512-D+1B79LFvtWA0KTt8ALekQ6A/glB9w10ETknH5Y9g1k2NYYQOQy93ffiuqLn3Pl6IPJG3EsK/YMROKEaq8KBrA==", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@prisma/debug": "6.12.0", - "@prisma/engines-version": "6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc", - "@prisma/fetch-engine": "6.12.0", - "@prisma/get-platform": "6.12.0" + "@prisma/debug": "6.13.0", + "@prisma/engines-version": "6.13.0-35.361e86d0ea4987e9f53a565309b3eed797a6bcbd", + "@prisma/fetch-engine": "6.13.0", + "@prisma/get-platform": "6.13.0" } }, "node_modules/@prisma/engines-version": { - "version": "6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc", - "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc.tgz", - "integrity": "sha512-70vhecxBJlRr06VfahDzk9ow4k1HIaSfVUT3X0/kZoHCMl9zbabut4gEXAyzJZxaCGi5igAA7SyyfBI//mmkbQ==", + "version": "6.13.0-35.361e86d0ea4987e9f53a565309b3eed797a6bcbd", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-6.13.0-35.361e86d0ea4987e9f53a565309b3eed797a6bcbd.tgz", + "integrity": "sha512-MpPyKSzBX7P/ZY9odp9TSegnS/yH3CSbchQE9f0yBg3l2QyN59I6vGXcoYcqKC9VTniS1s18AMmhyr1OWavjHg==", "license": "Apache-2.0" }, "node_modules/@prisma/fetch-engine": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.12.0.tgz", - "integrity": "sha512-EamoiwrK46rpWaEbLX9aqKDPOd8IyLnZAkiYXFNuq0YsU0Z8K09/rH8S7feOWAVJ3xzeSgcEJtBlVDrajM9Sag==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.13.0.tgz", + "integrity": "sha512-grmmq+4FeFKmaaytA8Ozc2+Tf3BC8xn/DVJos6LL022mfRlMZYjT3hZM0/xG7+5fO95zFG9CkDUs0m1S2rXs5Q==", "license": "Apache-2.0", "dependencies": { - "@prisma/debug": "6.12.0", - "@prisma/engines-version": "6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc", - "@prisma/get-platform": "6.12.0" + "@prisma/debug": "6.13.0", + "@prisma/engines-version": "6.13.0-35.361e86d0ea4987e9f53a565309b3eed797a6bcbd", + "@prisma/get-platform": "6.13.0" } }, "node_modules/@prisma/get-platform": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.12.0.tgz", - "integrity": "sha512-nRerTGhTlgyvcBlyWgt8OLNIV7QgJS2XYXMJD1hysorMCuLAjuDDuoxmVt7C2nLxbuxbWPp7OuFRHC23HqD9dA==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.13.0.tgz", + "integrity": "sha512-Nii2pX50fY4QKKxQwm7/vvqT6Ku8yYJLZAFX4e2vzHwRdMqjugcOG5hOSLjxqoXb0cvOspV70TOhMzrw8kqAnw==", "license": "Apache-2.0", "dependencies": { - "@prisma/debug": "6.12.0" + "@prisma/debug": "6.13.0" + } + }, + "node_modules/@standard-schema/spec": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.0.0.tgz", + "integrity": "sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==", + "license": "MIT" + }, + "node_modules/@types/normalize-package-data": { + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz", + "integrity": "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==", + "license": "MIT" + }, + "node_modules/c12": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/c12/-/c12-3.1.0.tgz", + "integrity": "sha512-uWoS8OU1MEIsOv8p/5a82c3H31LsWVR5qiyXVfBNOzfffjUWtPnhAb4BYI2uG2HfGmZmFjCtui5XNWaps+iFuw==", + "license": "MIT", + "dependencies": { + "chokidar": "^4.0.3", + "confbox": "^0.2.2", + "defu": "^6.1.4", + "dotenv": "^16.6.1", + "exsolve": "^1.0.7", + "giget": "^2.0.0", + "jiti": "^2.4.2", + "ohash": "^2.0.11", + "pathe": "^2.0.3", + "perfect-debounce": "^1.0.0", + "pkg-types": "^2.2.0", + "rc9": "^2.1.2" + }, + "peerDependencies": { + "magicast": "^0.3.5" + }, + "peerDependenciesMeta": { + "magicast": { + "optional": true + } + } + }, + "node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "license": "MIT", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/citty": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/citty/-/citty-0.1.6.tgz", + "integrity": "sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==", + "license": "MIT", + "dependencies": { + "consola": "^3.2.3" } }, "node_modules/clipboard": { @@ -134,6 +224,21 @@ "node": ">=20" } }, + "node_modules/confbox": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.2.2.tgz", + "integrity": "sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ==", + "license": "MIT" + }, + "node_modules/consola": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/consola/-/consola-3.4.2.tgz", + "integrity": "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==", + "license": "MIT", + "engines": { + "node": "^14.18.0 || >=16.10.0" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -148,12 +253,55 @@ "node": ">= 8" } }, + "node_modules/deepmerge-ts": { + "version": "7.1.5", + "resolved": "https://registry.npmjs.org/deepmerge-ts/-/deepmerge-ts-7.1.5.tgz", + "integrity": "sha512-HOJkrhaYsweh+W+e74Yn7YStZOilkoPb6fycpwNLKzSPtruFs48nYis0zy5yJz1+ktUhHxoRDJ27RQAWLIJVJw==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/defu": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz", + "integrity": "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==", + "license": "MIT" + }, "node_modules/delegate": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz", "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==", "license": "MIT" }, + "node_modules/destr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/destr/-/destr-2.0.5.tgz", + "integrity": "sha512-ugFTXCtDZunbzasqBxrK93Ik/DRYsO6S/fedkWEMKqt04xZ4csmnmwGDBAb07QWNaGMAmnTIemsYZCksjATwsA==", + "license": "MIT" + }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/effect": { + "version": "3.16.12", + "resolved": "https://registry.npmjs.org/effect/-/effect-3.16.12.tgz", + "integrity": "sha512-N39iBk0K71F9nb442TLbTkjl24FLUzuvx2i1I2RsEAQsdAdUTuUoW0vlfUXgkMTUOnYqKnWcFfqw4hK4Pw27hg==", + "license": "MIT", + "dependencies": { + "@standard-schema/spec": "^1.0.0", + "fast-check": "^3.23.1" + } + }, "node_modules/execa": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", @@ -177,6 +325,46 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, + "node_modules/exsolve": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/exsolve/-/exsolve-1.0.7.tgz", + "integrity": "sha512-VO5fQUzZtI6C+vx4w/4BWJpg3s/5l+6pRQEHzFRM8WFi4XffSP1Z+4qi7GbjWbvRQEbdIco5mIMq+zX4rPuLrw==", + "license": "MIT" + }, + "node_modules/fast-check": { + "version": "3.23.2", + "resolved": "https://registry.npmjs.org/fast-check/-/fast-check-3.23.2.tgz", + "integrity": "sha512-h5+1OzzfCC3Ef7VbtKdcv7zsstUQwUDlYpUTvjeUsJAssPgLn7QzbboPtL5ro04Mq0rPOsMzl7q5hIbRs2wD1A==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ], + "license": "MIT", + "dependencies": { + "pure-rand": "^6.1.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/find-up-simple": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/find-up-simple/-/find-up-simple-1.0.1.tgz", + "integrity": "sha512-afd4O7zpqHeRyg4PfDQsXmlDe2PfdHtJt6Akt8jOWaApLOZk5JXs6VMR29lz03pRe9mpykrRCYIYxaJYcfpncQ==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/fuse.js": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.1.0.tgz", @@ -198,6 +386,23 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/giget": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/giget/-/giget-2.0.0.tgz", + "integrity": "sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA==", + "license": "MIT", + "dependencies": { + "citty": "^0.1.6", + "consola": "^3.4.0", + "defu": "^6.1.4", + "node-fetch-native": "^1.6.6", + "nypm": "^0.6.0", + "pathe": "^2.0.3" + }, + "bin": { + "giget": "dist/cli.mjs" + } + }, "node_modules/good-listener": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", @@ -207,6 +412,18 @@ "delegate": "^3.1.2" } }, + "node_modules/hosted-git-info": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-7.0.2.tgz", + "integrity": "sha512-puUZAUKT5m8Zzvs72XWy3HtvVbTWljRE66cP60bxJzAqf2DgICo7lYTY2IHUmLnNpjYvw5bvmoHvPc0QO2a62w==", + "license": "ISC", + "dependencies": { + "lru-cache": "^10.0.1" + }, + "engines": { + "node": "^16.14.0 || >=18.0.0" + } + }, "node_modules/human-signals": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", @@ -216,6 +433,18 @@ "node": ">=16.17.0" } }, + "node_modules/index-to-position": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/index-to-position/-/index-to-position-1.1.0.tgz", + "integrity": "sha512-XPdx9Dq4t9Qk1mTMbWONJqU7boCoumEH7fRET37HX5+khDUl3J2W6PdALxhILYlIYx2amlwYcRPp28p0tSiojg==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-docker": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", @@ -298,14 +527,26 @@ "license": "ISC" }, "node_modules/jiti": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.2.tgz", - "integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.5.1.tgz", + "integrity": "sha512-twQoecYPiVA5K/h6SxtORw/Bs3ar+mLUtoPSc7iMXzQzK8d7eJ/R09wmTwAjiamETn1cXYPGfNnu7DMoHgu12w==", "license": "MIT", "bin": { "jiti": "lib/jiti-cli.mjs" } }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "license": "ISC" + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -324,6 +565,26 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/node-fetch-native": { + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.7.tgz", + "integrity": "sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q==", + "license": "MIT" + }, + "node_modules/normalize-package-data": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-6.0.2.tgz", + "integrity": "sha512-V6gygoYb/5EmNI+MEGrWkC+e6+Rr7mTmfHrxDbLzxQogBkgzo76rkok0Am6thgSF7Mv2nLOajAJj5vDJZEFn7g==", + "license": "BSD-2-Clause", + "dependencies": { + "hosted-git-info": "^7.0.0", + "semver": "^7.3.5", + "validate-npm-package-license": "^3.0.4" + }, + "engines": { + "node": "^16.14.0 || >=18.0.0" + } + }, "node_modules/npm-run-path": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", @@ -351,6 +612,31 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/nypm": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/nypm/-/nypm-0.6.1.tgz", + "integrity": "sha512-hlacBiRiv1k9hZFiphPUkfSQ/ZfQzZDzC+8z0wL3lvDAOUu/2NnChkKuMoMjNur/9OpKuz2QsIeiPVN0xM5Q0w==", + "license": "MIT", + "dependencies": { + "citty": "^0.1.6", + "consola": "^3.4.2", + "pathe": "^2.0.3", + "pkg-types": "^2.2.0", + "tinyexec": "^1.0.1" + }, + "bin": { + "nypm": "dist/cli.mjs" + }, + "engines": { + "node": "^14.16.0 || >=16.10.0" + } + }, + "node_modules/ohash": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/ohash/-/ohash-2.0.11.tgz", + "integrity": "sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==", + "license": "MIT" + }, "node_modules/onetime": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", @@ -366,6 +652,23 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/parse-json": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-8.3.0.tgz", + "integrity": "sha512-ybiGyvspI+fAoRQbIPRddCcSTV9/LsJbf0e/S85VLowVGzRmokfneg2kwVW/KU5rOXrPSbF1qAKPMgNTqqROQQ==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.26.2", + "index-to-position": "^1.1.0", + "type-fest": "^4.39.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -375,6 +678,18 @@ "node": ">=8" } }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "license": "MIT" + }, + "node_modules/perfect-debounce": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-1.0.0.tgz", + "integrity": "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==", + "license": "MIT" + }, "node_modules/pg": { "version": "8.16.3", "resolved": "https://registry.npmjs.org/pg/-/pg-8.16.3.tgz", @@ -464,6 +779,23 @@ "split2": "^4.1.0" } }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/pkg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-2.2.0.tgz", + "integrity": "sha512-2SM/GZGAEkPp3KWORxQZns4M+WSeXbC2HEvmOIJe3Cmiv6ieAJvdVhDldtHqM5J1Y7MrR1XhkBT/rMlhh9FdqQ==", + "license": "MIT", + "dependencies": { + "confbox": "^0.2.2", + "exsolve": "^1.0.7", + "pathe": "^2.0.3" + } + }, "node_modules/postgres-array": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", @@ -504,14 +836,14 @@ } }, "node_modules/prisma": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/prisma/-/prisma-6.12.0.tgz", - "integrity": "sha512-pmV7NEqQej9WjizN6RSNIwf7Y+jeh9mY1JEX2WjGxJi4YZWexClhde1yz/FuvAM+cTwzchcMytu2m4I6wPkIzg==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-6.13.0.tgz", + "integrity": "sha512-dfzORf0AbcEyyzxuv2lEwG8g+WRGF/qDQTpHf/6JoHsyF5MyzCEZwClVaEmw3WXcobgadosOboKUgQU0kFs9kw==", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@prisma/config": "6.12.0", - "@prisma/engines": "6.12.0" + "@prisma/config": "6.13.0", + "@prisma/engines": "6.13.0" }, "bin": { "prisma": "build/index.js" @@ -528,12 +860,99 @@ } } }, + "node_modules/pure-rand": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.1.0.tgz", + "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ], + "license": "MIT" + }, + "node_modules/rc9": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/rc9/-/rc9-2.1.2.tgz", + "integrity": "sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg==", + "license": "MIT", + "dependencies": { + "defu": "^6.1.4", + "destr": "^2.0.3" + } + }, + "node_modules/read-package-up": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/read-package-up/-/read-package-up-11.0.0.tgz", + "integrity": "sha512-MbgfoNPANMdb4oRBNg5eqLbB2t2r+o5Ua1pNt8BqGp4I0FJZhuVSOj3PaBPni4azWuSzEdNn2evevzVmEk1ohQ==", + "license": "MIT", + "dependencies": { + "find-up-simple": "^1.0.0", + "read-pkg": "^9.0.0", + "type-fest": "^4.6.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/read-pkg": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-9.0.1.tgz", + "integrity": "sha512-9viLL4/n1BJUCT1NXVTdS1jtm80yDEgR5T4yCelII49Mbj0v1rZdKqj7zCiYdbB0CuCgdrvHcNogAKTFPBocFA==", + "license": "MIT", + "dependencies": { + "@types/normalize-package-data": "^2.4.3", + "normalize-package-data": "^6.0.0", + "parse-json": "^8.0.0", + "type-fest": "^4.6.0", + "unicorn-magic": "^0.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "license": "MIT", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/select": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", "integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA==", "license": "MIT" }, + "node_modules/semver": { + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -567,6 +986,38 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/spdx-correct": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz", + "integrity": "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==", + "license": "Apache-2.0", + "dependencies": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-exceptions": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz", + "integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==", + "license": "CC-BY-3.0" + }, + "node_modules/spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "license": "MIT", + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-license-ids": { + "version": "3.0.22", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.22.tgz", + "integrity": "sha512-4PRT4nh1EImPbt2jASOKHX7PB7I+e4IWNLvkKFDxNhJlfjbYlleYQh285Z/3mPTHSAK/AvdMmw5BNNuYH8ShgQ==", + "license": "CC0-1.0" + }, "node_modules/split2": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", @@ -606,6 +1057,46 @@ "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", "license": "MIT" }, + "node_modules/tinyexec": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.1.tgz", + "integrity": "sha512-5uC6DDlmeqiOwCPmK9jMSdOuZTh8bU39Ys6yidB+UTt5hfZUPGAypSgFRiEp+jbi9qH40BLDvy85jIU88wKSqw==", + "license": "MIT" + }, + "node_modules/type-fest": { + "version": "4.41.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz", + "integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==", + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/unicorn-magic": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz", + "integrity": "sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "license": "Apache-2.0", + "dependencies": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index be2b7a5..0ccfafd 100644 --- a/package.json +++ b/package.json @@ -14,12 +14,12 @@ "author": "", "license": "ISC", "dependencies": { - "@prisma/client": "^6.12.0", + "@prisma/client": "^6.13.0", "clipboard": "^2.0.11", "clipboardy": "^4.0.0", "commander": "^14.0.0", "fuse.js": "^7.1.0", "pg": "^8.16.3", - "prisma": "^6.12.0" + "prisma": "^6.13.0" } } diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e8b9fe9..4ca01ac 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -4,12 +4,22 @@ // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} generator client { provider = "prisma-client-js" - output = "../generated/prisma" } -datasource db { - provider = "postgresql" - url = env("DATABASE_URL") +model Snippet { + id String @id @default(uuid()) + name String + lang String + desc String + file String + tags String[] + code String + createdAt DateTime @default(now()) } + diff --git a/snippet.json b/snippet.json deleted file mode 100644 index 4b96e14..0000000 --- a/snippet.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - { - "name": "testing", - "lang": "python", - "desc": "testing", - "file": "./index.js", - "tags": [] - } -] \ No newline at end of file