1- // standalone JS - needs Node.js installed; run with node <thisfile>
1+ // standalone JS - needs Node.js installed; run with
2+ // node <thisfile>
23//
34// Idea here is to have a program that helps with creation of a new AIA
45// algorithm module. Reads in the algorithm name and an ID used internally
56// in code, filenames, etc. Output unix commands to create all the extra files
67// (currently copy the heapsort files; they will need to be edited for the
78// new algorithm), plus some snippets of code and indications of where to
8- // put them so we can just edit a bunch of files and mostly copy+paste.
9- // XXX It would be nice to be able to say what files to copy (not Heapsort)
10- // but filenames are not really consistent enough currently.
9+ // put them so we can mostly copy+paste.
10+ // XXX It would be nice to be able to say what algorithm to copy (not Heapsort)
11+ // and input algCat but filenames are not really consistent enough currently.
1112
1213const readline = require ( 'readline' ) ;
1314
@@ -22,7 +23,7 @@ const rl = readline.createInterface({
2223
2324let algName ;
2425let algID ;
25- let algCat = 'Sort' ; // XXX Best input this also?
26+ let algCat = 'Sort' ;
2627console . log ( "What's the name of your new algorithm used in menus etc, eg 2-3-4 Tree? " ) ;
2728
2829rl . on ( 'line' , ( line ) => {
@@ -43,17 +44,21 @@ rl.on('close', () => {
4344} ) ;
4445
4546// let devBranch = "<development branch>"
46- let devBranch = "2025_sem2"
47+ let devBranch = "2025_sem2" // XXX
4748
4849let doIt = ( algName , algID ) => {
4950 console . log ( "" ) ;
5051 console . log ( "Guide to adding algorithm named " + algName + " with ID " + algID ) ;
5152 console . log ( "(best save this in a file and keep track of your progress)" ) ;
53+ console . log ( "If you follow these steps exactly (recommended) your new algorithm" ) ;
54+ console . log ( "will initially be a copy of Heapsort (you can then edit it as desired)." ) ;
55+ console . log ( "It will not appear in algorithm menus but can be accessed via the URL." ) ;
56+ console . log ( "<base URL>/alg=" + algID + "&mode=sort" ) ;
5257 console . log ( "" ) ;
5358 console . log ( "Execute the following commands from the AIA repository directory:" ) ;
5459 console . log ( "" ) ;
5560 console . log ( "git switch " + devBranch + "; git pull" ) ;
56- console . log ( "git switch + c add_" + algID ) ;
61+ console . log ( "git switch - c add_" + algID ) ;
5762 console . log ( "" ) ;
5863 console . log ( "cp src/algorithms/controllers/heapSort.js src/algorithms/controllers/" + algID + ".js" ) ;
5964 console . log ( "git add src/algorithms/controllers/" + algID + ".js" ) ;
@@ -70,13 +75,13 @@ let doIt = (algName, algID) => {
7075 console . log ( "but best defer that until after you have added the new algorithm" ) ;
7176 console . log ( "" ) ;
7277 console . log ( "echo \"export { default as " + algID + "} from './" + algID + "'\" >> src/algorithms/controllers/index.js" ) ;
73- console . log ( "echo \"export { default as " + algID + "} from './" + algID + "'\" >> src/algorithms/explanations/index.js" ) ;
74- console . log ( "echo \"export { default as " + algID + "} from './" + algID + "'\" >> src/algorithms/extra-info/index.js" ) ;
78+ console . log ( "echo \"export { default as " + algID + "} from './" + algID + ".md '\" >> src/algorithms/explanations/index.js" ) ;
79+ console . log ( "echo \"export { default as " + algID + "} from './" + algID + ".md '\" >> src/algorithms/extra-info/index.js" ) ;
7580 console . log ( "echo \"export { default as " + algID + "} from './" + algID + "'\" >> src/algorithms/parameters/index.js" ) ;
7681 console . log ( "echo \"export { default as " + algID + "} from './" + algID
7782+ "'\" >> src/algorithms/pseudocode/index.js" ) ;
7883 console . log ( "" ) ;
79- console . log ( "Edit src/algorithms/index.js to add to the allalgs definition; something like :" ) ;
84+ console . log ( "Edit src/algorithms/index.js to add the following to the allalgs definition:" ) ;
8085 console . log ( " '" + algID + "': {" ) ;
8186 console . log ( " name: '" + algName + "'," ) ;
8287 console . log ( " noDeploy: false," ) ;
@@ -91,8 +96,9 @@ let doIt = (algName, algID) => {
9196 console . log ( " controller: {" ) ;
9297 console . log ( " sort: Controller." + algID + "," ) ;
9398 console . log ( " }," ) ;
99+ console . log ( " }," ) ;
94100 // XXX ...
95- console . log ( "XXX Above may change with changes to index generation code " ) ;
101+ console . log ( "Note: above may change when code for algorithm index generation is modified " ) ;
96102 console . log ( "" ) ;
97103 console . log ( "Make sure the system compiles and existing algorithms run OK." ) ;
98104 console . log ( "This may require checking and re-working some of the steps above." ) ;
0 commit comments