cli icon indicating copy to clipboard operation
cli copied to clipboard

Patch app toml files

Open isaacroldan opened this issue 1 year ago β€’ 4 comments

WHY are these changes introduced?

Be more specific about what we write to the toml file. Instead of taking the whole app config and overwriting the toml, the idea is to load the current toml and patch with just the new values.

WHAT is this pull request doing?

  • Add a new function: patchAppConfigurationFile
  • This new function, given a config path and a patch object will load the toml, parse it, apply the patch and save it back to the filesystem again.
  • Updated usages of writeAppConfigurationFile to use patchAppConfigurationFile with more specific patches.
  • writeAppConfigurationFile is now used only during link.

How to test your changes?

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

isaacroldan avatar Oct 01 '24 11:10 isaacroldan

Thanks for your contribution!

Depending on what you are working on, you may want to request a review from a Shopify team:

  • Themes: @shopify/advanced-edits
  • UI extensions: @shopify/ui-extensions-cli
    • Checkout UI extensions: @shopify/checkout-ui-extensions-api-stewardship
  • Hydrogen: @shopify/hydrogen
  • Other: @shopify/app-inner-loop

github-actions[bot] avatar Oct 01 '24 11:10 github-actions[bot]

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/private/node/analytics.d.ts
@@ -20,7 +20,6 @@ interface EnvironmentData {
     env_cloud: string;
     env_package_manager: string;
     env_is_global: boolean;
-    env_auth_method: string;
 }
 export declare function getEnvironmentData(config: Interfaces.Config): Promise<EnvironmentData>;
 export declare function getSensitiveEnvironmentData(config: Interfaces.Config): Promise<{

packages/cli-kit/dist/private/node/session.d.ts
@@ -62,35 +62,16 @@ export interface OAuthSession {
     appManagement?: string;
     userId: string;
 }
-type AuthMethod = 'partners_token' | 'device_auth' | 'theme_access_token' | 'custom_app_token' | 'none';
 /**
  * Retrieves the user ID from the current session or returns 'unknown' if not found.
- *
- * This function performs the following steps:
- * 1. Checks for a cached user ID in memory (obtained in the current run).
- * 2. Attempts to fetch it from the secure store (from a previous auth session).
- * 3. Checks if a custom token was used (either as a theme password or partners token).
- * 4. If a custom token is present in the environment, generates a UUID and uses it as userId.
- * 5. If after all this we don't have a userId, then reports as 'unknown'.
+ * This function first checks for a cached user ID in memory (obtained in the current run)
+ * Then attempts to fetch it from the secure store. (from a previous auth session)
+ * If no user ID is found, it returns 'unknown'.
  *
  * @returns A Promise that resolves to the user ID as a string.
  */
 export declare function getLastSeenUserIdAfterAuth(): Promise<string>;
 export declare function setLastSeenUserIdAfterAuth(id: string): void;
-/**
- * Retrieves the last seen authentication method used in the current session.
- *
- * This function checks for the authentication method in the following order:
- * 1. Returns the cached auth method if it's not 'none'.
- * 2. Checks for a cached session, which implies 'device_auth' was used.
- * 3. Checks for a partners token in the environment.
- * 4. Checks for a theme password in the environment.
- * 5. If none of the above are true, returns 'none'.
- *
- * @returns A Promise that resolves to the last seen authentication method as an AuthMethod type.
- */
-export declare function getLastSeenAuthMethod(): Promise<AuthMethod>;
-export declare function setLastSeenAuthMethod(method: AuthMethod): void;
 /**
  * This method ensures that we have a valid session to authenticate against the given applications using the provided scopes.
  *

packages/cli-kit/dist/public/node/monorail.d.ts
@@ -2,7 +2,7 @@ import { JsonMap } from '../../private/common/json.js';
 import { DeepRequired } from '../common/ts/deep-required.js';
 export { DeepRequired };
 type Optional<T> = T | null;
-export declare const MONORAIL_COMMAND_TOPIC = "app_cli3_command/1.14";
+export declare const MONORAIL_COMMAND_TOPIC = "app_cli3_command/1.13";
 export interface Schemas {
     [MONORAIL_COMMAND_TOPIC]: {
         sensitive: {
@@ -121,7 +121,6 @@ export interface Schemas {
             env_web_ide?: Optional<string>;
             env_cloud?: Optional<string>;
             env_is_global?: Optional<boolean>;
-            env_auth_method?: Optional<string>;
         };
     };
     [schemaId: string]: {

packages/cli-kit/dist/private/node/api/rest.d.ts
@@ -6,5 +6,4 @@ export declare function restRequestUrl(session: AdminSession, apiVersion: string
 }, env?: NodeJS.ProcessEnv): string;
 export declare function restRequestHeaders(session: AdminSession): {
     [key: string]: string;
-};
-export declare function isThemeAccessSession(session: AdminSession): boolean;
\ No newline at end of file
+};
\ No newline at end of file

packages/cli-kit/dist/public/node/context/local.d.ts
@@ -125,13 +125,6 @@ export declare function codespacePortForwardingDomain(env?: NodeJS.ProcessEnv):
  * @returns True in case the CLI is run from a cloud environment.
  */
 export declare function isCloudEnvironment(env?: NodeJS.ProcessEnv): boolean;
-/**
- * The token used to run a theme command with a custom password.
- *
- * @param env - Environment variables used when the cli is launched.
- * @returns A string with the token.
- */
-export declare function themeToken(env?: NodeJS.ProcessEnv): string | undefined;
 /**
  * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of
  * them. Platform name 'localhost' is returned otherwise.

github-actions[bot] avatar Oct 01 '24 15:10 github-actions[bot]

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.

github-actions[bot] avatar Oct 07 '24 10:10 github-actions[bot]

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟑 Statements
72.54% (+0.04% πŸ”Ό)
8391/11567
🟑 Branches
69.06% (+0.02% πŸ”Ό)
4121/5967
🟑 Functions
71.95% (+0.02% πŸ”Ό)
2193/3048
🟑 Lines
72.85% (+0.04% πŸ”Ό)
7933/10890
Show new covered files 🐣
St.:grey_question:
File Statements Branches Functions Lines
🟒
... / patch-app-configuration-file.ts
100% 100% 100% 100%
Show files with reduced coverage πŸ”»
St.:grey_question:
File Statements Branches Functions Lines
🟒
... / urls.ts
82.57%
78.31% (-0.51% πŸ”»)
75% 84.47%

Test suite run success

1916 tests passing in 870 suites.

Report generated by πŸ§ͺjest coverage report action from 710cc73d64dd652987e7b9f00e3e0a21edc05f72

github-actions[bot] avatar Oct 07 '24 11:10 github-actions[bot]