fsdcats 0.0.0-stage ā 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -2
- package/all-practicals.txt +905 -0
- package/bin/cli.js +81 -0
- package/index.js +10 -0
- package/lib/generator.js +97 -0
- package/lib/practicalsData.js +762 -0
- package/package.json +23 -4
- package/practical-1.txt +110 -0
- package/practical-2.txt +118 -0
- package/practical-3.txt +174 -0
- package/practical-4.txt +180 -0
- package/practical-5.txt +203 -0
- package/practical-crud.txt +84 -0
- package/practicals/crud-operations/server.js +55 -0
- package/practicals/p1-vue-directives/App.vue +59 -0
- package/practicals/p1-vue-directives/users.json +5 -0
- package/practicals/p2-props-emits/App.vue +53 -0
- package/practicals/p2-props-emits/DriverCard.vue +20 -0
- package/practicals/p3-file-upload/App.vue +67 -0
- package/practicals/p3-file-upload/server.js +61 -0
- package/practicals/p4-pinia-form/App.vue +54 -0
- package/practicals/p4-pinia-form/server.js +35 -0
- package/practicals/p4-pinia-form/store.js +39 -0
- package/practicals/p5-nuxt-routing/app.vue +6 -0
- package/practicals/p5-nuxt-routing/layouts/default.vue +21 -0
- package/practicals/p5-nuxt-routing/layouts/minimal.vue +9 -0
- package/practicals/p5-nuxt-routing/pages/about.vue +14 -0
- package/practicals/p5-nuxt-routing/pages/index.vue +8 -0
- package/practicals/p5-nuxt-routing/pages/items/[id].vue +32 -0
- package/practicals/p5-nuxt-routing/pages/items/index.vue +22 -0
package/bin/cli.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const readline = require('readline');
|
|
5
|
+
const { practicalsData, generatePracticalFile, generateAllFiles } = require('../lib/generator');
|
|
6
|
+
|
|
7
|
+
function printBanner() {
|
|
8
|
+
console.log('\n============================================================');
|
|
9
|
+
console.log(' FULLSTACK PRACTICAL EXAM CHEATSHEET GENERATOR (fsdcats) ');
|
|
10
|
+
console.log('============================================================\n');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const arg = process.argv[2];
|
|
14
|
+
|
|
15
|
+
if (arg) {
|
|
16
|
+
const cleanArg = arg.toLowerCase().replace(/^p/, '');
|
|
17
|
+
|
|
18
|
+
if (cleanArg === 'all') {
|
|
19
|
+
printBanner();
|
|
20
|
+
console.log('ā³ Generating text files for ALL practicals...');
|
|
21
|
+
const results = generateAllFiles(process.cwd());
|
|
22
|
+
console.log(`\nš Successfully generated ${results.length} files in current directory:\n`);
|
|
23
|
+
results.forEach(r => console.log(` š ${r.fileName} -> ${r.outPath}`));
|
|
24
|
+
console.log('\nText files are ready and opened for viewing!\n');
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const result = generatePracticalFile(cleanArg, process.cwd());
|
|
29
|
+
if (result) {
|
|
30
|
+
printBanner();
|
|
31
|
+
console.log(`ā
Generated: ${result.fileName}`);
|
|
32
|
+
console.log(`š Path: ${result.outPath}`);
|
|
33
|
+
console.log(`\nText file has been created and opened! You can copy-paste the steps and components.`);
|
|
34
|
+
process.exit(0);
|
|
35
|
+
} else {
|
|
36
|
+
console.log(`\nUnknown practical: "${arg}". Use 1, 2, 3, 4, 5, crud, or all.\n`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Interactive menu if no argument given
|
|
41
|
+
printBanner();
|
|
42
|
+
console.log('Select a practical to generate its text file (Setup Steps + Component Code):\n');
|
|
43
|
+
|
|
44
|
+
const keys = ['1', '2', '3', '4', '5', 'crud'];
|
|
45
|
+
keys.forEach(k => {
|
|
46
|
+
console.log(` [${k}] ${practicalsData[k].title} -> (${practicalsData[k].fileName})`);
|
|
47
|
+
});
|
|
48
|
+
console.log(' [all] Generate text files for ALL practicals');
|
|
49
|
+
console.log(' [q] Quit\n');
|
|
50
|
+
|
|
51
|
+
const rl = readline.createInterface({
|
|
52
|
+
input: process.stdin,
|
|
53
|
+
output: process.stdout
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
rl.question('Enter your choice (1-5, crud, all): ', (answer) => {
|
|
57
|
+
rl.close();
|
|
58
|
+
const choice = answer.trim().toLowerCase().replace(/^p/, '');
|
|
59
|
+
|
|
60
|
+
if (choice === 'q') {
|
|
61
|
+
console.log('Goodbye!');
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (choice === 'all') {
|
|
66
|
+
const results = generateAllFiles(process.cwd());
|
|
67
|
+
console.log(`\nš Successfully generated ${results.length} files:\n`);
|
|
68
|
+
results.forEach(r => console.log(` š ${r.fileName}`));
|
|
69
|
+
console.log('\nText files created and opened!\n');
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const res = generatePracticalFile(choice, process.cwd());
|
|
74
|
+
if (res) {
|
|
75
|
+
console.log(`\nā
Generated: ${res.fileName}`);
|
|
76
|
+
console.log(`š Location: ${res.outPath}`);
|
|
77
|
+
console.log('\nText file created and opened!\n');
|
|
78
|
+
} else {
|
|
79
|
+
console.log('\nInvalid selection. Run command again.\n');
|
|
80
|
+
}
|
|
81
|
+
});
|
package/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const practicalsData = require('./lib/practicalsData');
|
|
2
|
+
const generator = require('./lib/generator');
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
practicalsData,
|
|
6
|
+
...generator,
|
|
7
|
+
getPracticalText: (id) => generator.formatPracticalText(practicalsData[id]),
|
|
8
|
+
generatePracticalFile: generator.generatePracticalFile,
|
|
9
|
+
generateAllFiles: generator.generateAllFiles
|
|
10
|
+
};
|
package/lib/generator.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { exec } = require('child_process');
|
|
4
|
+
const practicalsData = require('./practicalsData');
|
|
5
|
+
|
|
6
|
+
function formatPracticalText(practical) {
|
|
7
|
+
let output = '';
|
|
8
|
+
|
|
9
|
+
// Title
|
|
10
|
+
output += `${practical.title.toUpperCase()}\n`;
|
|
11
|
+
output += `\n\n\n\n`;
|
|
12
|
+
|
|
13
|
+
// Setup Section
|
|
14
|
+
output += `SETUP:\n\n`;
|
|
15
|
+
output += `${practical.setupSteps.trim()}\n`;
|
|
16
|
+
output += `\n\n\n\n\n`;
|
|
17
|
+
|
|
18
|
+
// Components Section
|
|
19
|
+
output += `COMPONENTS:\n\n\n`;
|
|
20
|
+
|
|
21
|
+
practical.components.forEach((comp) => {
|
|
22
|
+
output += `COMPONENT: ${comp.name}\n`;
|
|
23
|
+
output += `PATH: ${comp.path}\n\n`;
|
|
24
|
+
output += `${comp.code.trim()}\n`;
|
|
25
|
+
output += `\n\n\n\n\n`;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return output;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function openFile(filePath) {
|
|
32
|
+
const platform = process.platform;
|
|
33
|
+
let cmd = '';
|
|
34
|
+
if (platform === 'darwin') {
|
|
35
|
+
cmd = `open "${filePath}"`;
|
|
36
|
+
} else if (platform === 'win32') {
|
|
37
|
+
cmd = `start "" "${filePath}"`;
|
|
38
|
+
} else {
|
|
39
|
+
cmd = `xdg-open "${filePath}"`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exec(cmd, () => {});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function generatePracticalFile(idOrKey, targetDir = process.cwd()) {
|
|
46
|
+
const key = String(idOrKey).toLowerCase().replace(/^p/, '');
|
|
47
|
+
const practical = practicalsData[key];
|
|
48
|
+
|
|
49
|
+
if (!practical) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const content = formatPracticalText(practical);
|
|
54
|
+
const outPath = path.join(targetDir, practical.fileName);
|
|
55
|
+
fs.writeFileSync(outPath, content, 'utf8');
|
|
56
|
+
openFile(outPath);
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
fileName: practical.fileName,
|
|
60
|
+
outPath,
|
|
61
|
+
content,
|
|
62
|
+
title: practical.title
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function generateAllFiles(targetDir = process.cwd()) {
|
|
67
|
+
const generated = [];
|
|
68
|
+
let combinedText = '';
|
|
69
|
+
|
|
70
|
+
for (const key of Object.keys(practicalsData)) {
|
|
71
|
+
const res = generatePracticalFile(key, targetDir);
|
|
72
|
+
if (res) {
|
|
73
|
+
generated.push(res);
|
|
74
|
+
combinedText += res.content + `\n\n\n\n\n\n`;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const combinedPath = path.join(targetDir, 'all-practicals.txt');
|
|
79
|
+
fs.writeFileSync(combinedPath, combinedText, 'utf8');
|
|
80
|
+
openFile(combinedPath);
|
|
81
|
+
|
|
82
|
+
generated.push({
|
|
83
|
+
fileName: 'all-practicals.txt',
|
|
84
|
+
outPath: combinedPath,
|
|
85
|
+
title: 'All Practicals'
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return generated;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
module.exports = {
|
|
92
|
+
practicalsData,
|
|
93
|
+
formatPracticalText,
|
|
94
|
+
generatePracticalFile,
|
|
95
|
+
generateAllFiles,
|
|
96
|
+
openFile
|
|
97
|
+
};
|