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

Enforce that all commands load an app #4509

Open
wants to merge 6 commits into
base: login-on-init
Choose a base branch
from

Conversation

isaacroldan
Copy link
Contributor

WHY are these changes introduced?

All commands should track all app-related details.
To enforce that, we make every app command return an AppInterface, which means that an app was loaded at some point.

WHAT is this pull request doing?

  • Add a new ESLint rule to make all commands in app/commands extend AppCommand
  • In AppCommand define the run function to return an object with an AppInterface, TS will force all child classes to use the same return type.
  • Solve all the issues created by the two rules above: all commands extend AppCommand, all return an AppInterface now.

IN A FUTURE PR:

  • All app commands should return a Session, to force authentication in all of them.
  • Since all commands have auth + app loading -> extract that logic to a single place: loadAppContext

How to test your changes?

Nothing to test in the CLI itself, you can try to modify the code of a command and see that the rules are being applied.

Post-release steps

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor

We detected some changes at either packages/*/src or packages/cli-kit/assets/cli-ruby/** and there are no updates in the .changeset.
If the changes are user-facing, run "pnpm changeset add" to track your changes and include them in the next release CHANGELOG.

Copy link
Contributor

github-actions bot commented Sep 23, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
72.51% (-0.21% 🔻)
8490/11708
🟡 Branches 69.41% 4153/5983
🟡 Functions
71.54% (-0.02% 🔻)
2202/3078
🟡 Lines
72.83% (-0.23% 🔻)
8034/11031
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🔴
... / dev.ts
9.65% (-0.09% 🔻)
1.56% 15.79%
9.52% (-0.09% 🔻)

Test suite run success

1927 tests passing in 872 suites.

Report generated by 🧪jest coverage report action from 02e6acb

Copy link
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/common/url.d.ts
@@ -5,4 +5,11 @@
  * @returns True if the URL is valid, false otherwise.
  * @throws An error if URL's constructor throws an error other than .
  */
-export declare function isValidURL(url: string): boolean;
\ No newline at end of file
+export declare function isValidURL(url: string): boolean;
+/**
+ * Safely parse a string into a URL.
+ *
+ * @param url - The string to parse into a URL.
+ * @returns A URL object if the parsing is successful, undefined otherwise.
+ */
+export declare function safeParseURL(url: string): URL | undefined;
\ No newline at end of file
packages/cli-kit/dist/public/node/node-package-manager.d.ts
@@ -293,4 +293,17 @@ export declare function addResolutionOrOverride(directory: string, dependencies:
  * @param packageJSON - Package.json file to write.
  */
 export declare function writePackageJSON(directory: string, packageJSON: PackageJson): Promise<void>;
+/**
+ * Infers the package manager to be used based on the provided options and environment.
+ *
+ * This function determines the package manager in the following order of precedence:
+ * 1. Uses the package manager specified in the options, if valid.
+ * 2. Infers the package manager from the user agent string.
+ * 3. Infers the package manager used for the global CLI installation.
+ * 4. Defaults to 'npm' if no other method succeeds.
+ *
+ * @param optionsPackageManager - The package manager specified in the options (if any).
+ * @returns The inferred package manager as a PackageManager type.
+ */
+export declare function inferPackageManager(optionsPackageManager: string | undefined, env?: NodeJS.ProcessEnv): PackageManager;
 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant