Skip to content

feat: add analyze command #402

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

Merged
merged 16 commits into from
Mar 26, 2025
Merged

feat: add analyze command #402

merged 16 commits into from
Mar 26, 2025

Conversation

rmarescu
Copy link
Member

@rmarescu rmarescu commented Mar 22, 2025

Note

Experimental feature

Follow-up on #401

New command npx shortest analyze

Generates 3 files in .shortest/{framework} folder:

  • paths.json: list of all app files
  • tree.json: detailed app file structure hierarchy
  • analysis.json: app analysis

Sample files for https://github.com/antiwork/iffy:

or accessible at https://gist.github.com/rmarescu/d1b452812e7078afd19b301abf916853

Copy link

vercel bot commented Mar 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
shortest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 26, 2025 4:41am

@rmarescu rmarescu marked this pull request as ready for review March 26, 2025 04:44
Comment on lines +39 to +47
if (supportedFrameworks.length === 0) {
throw new ShortestError(`No supported framework found`);
}

if (supportedFrameworks.length > 1) {
throw new ShortestError(
`Multiple supported frameworks found: ${supportedFrameworks.map((f) => f.name).join(", ")}`,
);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Basic checks to limit usage to one app per repo, Next.js.

);

this.log.trace("Paths saved", {
path: path.join(this.frameworkDir, "paths.json"),
Copy link
Member Author

Choose a reason for hiding this comment

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

Not currently used in future steps, saved for debugging/reference.

};

await fs.writeFile(treeJsonPath, JSON.stringify(treeOutput, null, 2));
this.log.trace("Tree structure saved", { path: treeJsonPath });
Copy link
Member Author

Choose a reason for hiding this comment

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

Not currently used in future steps, saved for debugging/reference.

ast: null | parser.ParseResult<t.File>;
}

export class NextJsAnalyzer implements BaseAnalyzer {
Copy link
Member Author

Choose a reason for hiding this comment

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

Most of the core logic (AST parsing, components detection, etc) was AI-generated, with some considerable refactoring to reduce its complexity. It appears to be good enough for an MVP.

Comment on lines +28 to +39
ignore: [
"**/*.test.ts",
"**/*.test.tsx",
"**/*.test.js",
"**/*.test.jsx",
"**/*.spec.ts",
"**/*.spec.tsx",
"**/*.spec.js",
"**/*.spec.jsx",
"packages/**",
"test/**",
"tests/**",
Copy link
Member Author

Choose a reason for hiding this comment

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

Other files to be ignored besides what matches .gitignore.

@rmarescu rmarescu merged commit c67cf6e into main Mar 26, 2025
6 checks passed
@rmarescu rmarescu deleted the rmarescu/analyze branch March 26, 2025 04:45
@github-project-automation github-project-automation bot moved this to Done in Shortest Mar 26, 2025
@rmarescu rmarescu mentioned this pull request Mar 26, 2025
rmarescu added a commit that referenced this pull request Mar 27, 2025
> [!NOTE]
> Experimental feature

Follow-up on #402

New command `npx shortest plan`

Generates `.shortest/{framework}/test-plan.json`. Uses AI to generate up
to 10 test plans based on the `analysis.json` file

Sample
[test-plan.json](https://gist.github.com/rmarescu/3457f144757875456d34af417a66468a)
@rmarescu rmarescu added this to the v0.4.9 milestone Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant