Skip to content

Refactor resolveFramework to use declarative .some() and .every() - #8262

Draft
gonzaloriestra wants to merge 1 commit into
mainfrom
refactor-framework-detection-23259390411241093
Draft

Refactor resolveFramework to use declarative .some() and .every()#8262
gonzaloriestra wants to merge 1 commit into
mainfrom
refactor-framework-detection-23259390411241093

Conversation

@gonzaloriestra

Copy link
Copy Markdown
Contributor

Refactored resolveFramework in packages/cli-kit/src/public/node/framework.ts to use standard .some() and .every() array helper methods instead of .reduce(). This fixes a bug in the old reduce implementation where the accumulator was not correctly passed on the some detectors and enables early exit short-circuiting. Added unit tests for these behaviors in framework.test.ts.


PR created automatically by Jules for task 23259390411241093 started by @gonzaloriestra

Replace complex and buggy `.reduce()` operations with standard `.some()` and `.every()` array helper methods in `packages/cli-kit/src/public/node/framework.ts`. This simplifies the control flow, improves readability, resolves a non-accumulating reduce bug on `.some` detectors, and enables early exit short-circuiting. Also added tests to cover `some` framework detectors in `framework.test.ts`.
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/node/framework.d.ts
@@ -1,3 +1,41 @@
+interface FrameworkDetectionPattern {
+    /**
+     * @example A file path
+     * ```
+     * "package.json"
+     * ```
+     */
+    path: string;
+    /**
+     * @example A matcher
+     * ```
+     * "\"(dev)?(d|D)ependencies\":\\s*{[^}]*\"next\":\\s*\".+?\"[^}]*}"
+     * ```
+     */
+    matchContent?: string;
+}
+interface Framework {
+    /**
+     * Name of the framework
+     * @example "nextjs"
+     */
+    name: string;
+    /**
+     * Detectors used to find out the framework
+     */
+    detectors: {
+        /**
+         * Collection of detectors that must be matched for the framework
+         * to be detected.
+         */
+        every?: FrameworkDetectionPattern[];
+        /**
+         * Collection of detectors where one match triggers the framework
+         * to be detected.
+         */
+        some?: FrameworkDetectionPattern[];
+    };
+}
 /**
  * Tries to identify the using of a framework analyzing the existence and/or content of different files inside a
  * specific directory.
@@ -5,4 +43,6 @@
  * @param rootDirectory - Directory from which the files required for each framework are searched
  * @returns The name of the framework used or 'unknown' otherwise
  */
-export declare function resolveFramework(rootDirectory: string): Promise<string>;
\ No newline at end of file
+export declare function resolveFramework(rootDirectory: string): Promise<string>;
+export declare const _frameworks: Framework[];
+export {};
\ No newline at end of file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant