Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor classes into files #1522

Merged
merged 6 commits into from
May 25, 2021

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented May 18, 2021

Pull Request

Problem

The single-file index.js is a bit intimidating to work in, specially for new contributors. We now have some classes which can stand alone.

Issue: #1496

Solution

Short version: factor out the classes into separate files!

Implementation detail: the Help class takes parameter types of multiple classes, but this is a type dependency and not a code dependency. Using a TypeScript style JSDoc import allows the strong typing checks without introducing a circular require dependency between help.js and command.js. I am using Visual Studio Code which understands this for IntelliSense, and TypeScript uses this for npm run typescript-checkJS. If we have other editors people want to use that have their own imports, we can add them as required.

I like that the exports are now simple and obvious in index.tab .

ChangeLog

  • refactor index.tab into a file per class

@shadowspawn shadowspawn added this to the v8.0.0 milestone May 18, 2021
@shadowspawn
Copy link
Collaborator Author

Future reference: if we do need to do "real" imports then @cravler demonstrated how to simply break the cycle by having Command implement createHelp in a superclass in index.tab. Skeleton:

class Command extends BaseCommand {
  createCommand(name) {
    return new Command(name);
  };

  createHelp() {
    return Object.assign(new Help(), this.configureHelp());
  };
}

@shadowspawn shadowspawn marked this pull request as ready for review May 19, 2021 08:06
@shadowspawn shadowspawn marked this pull request as draft May 19, 2021 21:42
@shadowspawn
Copy link
Collaborator Author

shadowspawn commented May 19, 2021

I moved back to draft, I just want to check can install from a pack and it works before I call it ready. [Done.]

@shadowspawn shadowspawn marked this pull request as ready for review May 20, 2021 01:53
@shadowspawn shadowspawn changed the title Refactor out classes into files Refactor classes into files May 20, 2021
Copy link
Collaborator

@abetomo abetomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@shadowspawn shadowspawn merged commit 08245cc into tj:release/8.x May 25, 2021
@shadowspawn shadowspawn deleted the feature/refactor-destructure branch May 25, 2021 06:01
@shadowspawn shadowspawn added the pending release Merged into a branch for a future release, but not released yet label May 25, 2021
@shadowspawn shadowspawn removed the pending release Merged into a branch for a future release, but not released yet label Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants