Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • SDN best practices


    likeablePanda
     Share

    Recommended Posts

    So, my partner in crime @Hosfad  and myself have been giving poor @Hashtag way too much work by basically cutting and pasting from our current giant private github, to the github repo on the SDN. Not ideal as then it can be hard to review, as again, poor @Hashtag let us know.

     

    Here's how our project is set up on a private github project/account (dummy project as an example):
    projectSetup.png.98f4c7f5f093a8c4037a77b5c609c230.png

     

    If we push this as-is to the SDN, my understanding is that all scripts would have to be updated at the same time, even if we only want to update one. Do we have to separate out into a bunch of different modules? Would that not make it so that we have to have a copy of UTILS_FOR_ALL_SCRIPTS in each module? And when we make a change to the utils, we'd have to update each and every single module with the new util folder? If we can avoid that it'd be great, there's a lot of room for human error there!

    In addition, if possible, we really like the interface github provides, so it'd be nice to connect the github repo to the sdn repo in some meaninful way.

    We'd love advice on how to refactor this , or just configure our repo with the SDN properly so we don't have to refactor.

     

     

    Edited by likeablePanda
    extra file
    Link to comment
    Share on other sites

    1 minute ago, Pandemic said:

    Hey there, I think the easiest way would be to use multiple git remotes, here's a little guide I found:

    https://jigarius.com/blog/multiple-git-remote-repositories

    But basically you'd have both our git repo and Github's as remotes, and when you commit and push your changes, it would go to both places :) 

    Thank you! that's excellent for having both sdn and our own repo. You went the extra mile and gave us a link :)

     

    The other thing i'm confused about is how to handle those individual scripts, each Main (as in FishingMain,FletchingMain,HerbloreMain) has their own @ScriptManifest.

    Suppose the Fishing, Herblore, and Fletching scripts are each their own unique scripts, some paid some not. If I commit and push to the SDN, these scripts aren't in different modules. So how do we update only one script at a time, even if we push code that changes multiple scripts?

    Link to comment
    Share on other sites

    28 minutes ago, likeablePanda said:

    Thank you! that's excellent for having both sdn and our own repo. You went the extra mile and gave us a link :)

     

    The other thing i'm confused about is how to handle those individual scripts, each Main (as in FishingMain,FletchingMain,HerbloreMain) has their own @ScriptManifest.

    Suppose the Fishing, Herblore, and Fletching scripts are each their own unique scripts, some paid some not. If I commit and push to the SDN, these scripts aren't in different modules. So how do we update only one script at a time, even if we push code that changes multiple scripts?

    You can have any number of scripts in the same repo, and when you go to upload them you set the repo (the actual .git part), and the module is the root folder name of the script you want to upload. When we compile it, we only compile that script, not the full repo.

    Example:

    • mygitrepo.git
      • Fighter/
        • src/
          • Fighter.java
      • Herblore/
        • src/
          • Herblore.java

    Then when you'd go to add it to our SDN, you'd put in your repo's name (mygitrepo in this case), and the module name would be the top level folder inside of that repo (either Fighter or Herblore here).

    Hope that helps!

    Link to comment
    Share on other sites

    3 minutes ago, Pandemic said:

    You can have any number of scripts in the same repo, and when you go to upload them you set the repo (the actual .git part), and the module is the root folder name of the script you want to upload. When we compile it, we only compile that script, not the full repo.

    Example:

    • mygitrepo.git
      • Fighter/
        • src/
          • Fighter.java
      • Herblore/
        • src/
          • Herblore.java

    Then when you'd go to add it to our SDN, you'd put in your repo's name (mygitrepo in this case), and the module name would be the top level folder inside of that repo (either Fighter or Herblore here).

    Hope that helps!

    Thank you so much for the help <3

    Link to comment
    Share on other sites

    1 hour ago, Pandemic said:

    When we compile it, we only compile that script, not the full repo.

    Example:

    • mygitrepo.git
      • Fighter/
        • src/
          • Fighter.java
      • Herblore/
        • src/
          • Herblore.java

    So we effectively have a "module", let's call it Utils, that all other modules depend on.

     

    • mygitrepo.git
      • Fighter/
        • src/
          • Fighter.java
      • Herblore/
        • src/
          • Herblore.java
      • Utils
        • src/
          • fancyAntiBan.java
          • whatever.java

     

    If we push something like this and set Utils as a dependency of Herblore and a dependency of Fighter (in intellij), will the SDN understand that? is there any way to communicate that dependency otherwise? 

    I'd like to avoid the following:
     

    • mygitrepo.git
      • Fighter/
        • src/
          • Fighter.java
          • Utils/
            • fancyAntiBan.java
            • whatever.java
               
      • Herblore/
        • src/
          • Herblore.java
          • Utils/
            • fancyAntiBan.java
            • whatever.java

    Because if we change utils for one script, we want it to change for *all* scripts

     

    Thanks again!

    Edited by likeablePanda
    Link to comment
    Share on other sites

    12 minutes ago, likeablePanda said:

    So we effectively have a "module", let's call it Utils, that all other modules depend on.

     

    • mygitrepo.git
      • Fighter/
        • src/
          • Fighter.java
      • Herblore/
        • src/
          • Herblore.java
      • Utils
        • src/
          • fancyAntiBan.java
          • whatever.java

     

    If we push something like this and set Utils as a dependency of Herblore and a dependency of Fighter (in intellij), will the SDN understand that? is there any way to communicate that dependency otherwise? 

    I'd like to avoid the following:
     

    • mygitrepo.git
      • Fighter/
        • src/
          • Fighter.java
          • Utils/
            • fancyAntiBan.java
            • whatever.java
               
      • Herblore/
        • src/
          • Herblore.java
          • Utils/
            • fancyAntiBan.java
            • whatever.java

    Because if we change utils for one script, we want it to change for *all* scripts

     

    Thanks again!

    Right now we don't have a very good way of handling that, and we require that you do it the way you say you'd like to avoid :(

    We might have better support for shared libraries like that since it's so often used, but as of now you'll have to do it the hard way.

    Thanks!

    Link to comment
    Share on other sites

    20 hours ago, Pandemic said:

    but as of now you'll have to do it the hard way.

     

    OVER. MY. DEAD. BODY!!!! I found a solution for my needs. I'll share it here.  I refuse to manually manage 10+ util folders!

    Here's how my folders are now setup

    • ZodiacFighter/
      • src/
        • Fighter.java
        • Utils/
          • fancyAntiBan.java
          • whatever.java
             
    • ZodiacHerblore/
      • src/
        • Herblore.java
        • Utils/
          • fancyAntiBan.java
          • whatever.java
    • ZodiacUtils
      • src/
        • Utils/
          • fancyAntiBan.java
          • whatever.java

    Notice I have BOTH a utils module AND Util package in each other module.

     

    In intellij, tell intellij to "Mark directory as excluded" every Utils folder in every module that isn't the Utils module.

    Then, I add a hook to the git pre-commit

     

    so in ProjectFolder/.git/hook/pre-commit I have the code:

    #!/usr/bin/env python
    
    import argparse
    import os
    import shutil
    
    def parse_args():
        pass
    
    def main(args=None):
        files = os.listdir(os.getcwd())
        for file in files:
            if(os.path.isdir(file)):
                print("directory " + file);
                if( not "ZodiacUtils" in file and "Zodiac" in file):
                
                    print("ZodiacUtils/src/Utils",file+"/src/Utils")
                    shutil.rmtree(file+"/src/Utils");
    
                    shutil.copytree("ZodiacUtils/src/Utils",file+"/src/Utils")
                    os.system("git add " + file+"/src/Utils");
        pass
    
    if __name__ == "__main__":
        args = parse_args()
        main(args)
    

    This replaces every src/Utils folder that contains the word "Zodiac" with the Utils folder in ZodiacUtils/src/Utils

    So now whenever you commit, it'll automatically copy those folders and add them to the repo. Note this is NOT a copy paste solution! it'd have to be personalized

     

    @Neffarion I wrote this before you posted this proposed solution. If I understand (which I may not), wouldn't this only work locally? Once you push it to the SDN the SDN has no knowledge of the module dependency as @Pandemic said in his previous post in this forum topic. Or am I missing something that'd be simpler than my silly yet effective solution

    Edited by likeablePanda
    code a *little* neater
    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.