-
Notifications
You must be signed in to change notification settings - Fork 156
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
Use .shopify/.gitignore
instead of appending to .gitignore
#5475
base: main
Are you sure you want to change the base?
Conversation
Instead of writing to the host application's `.gitignore` to hide the `.shopify` directory, we can write a `.gitignore` in the directory itself, which makes the directory self-ignoring.
Differences in type declarationsWe 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:
New type declarationspackages/cli-kit/dist/public/node/hiddenFolder.d.ts/**
* Creates a git ignored hidden .shopify folder in the given app directory, and pass its path to the given callback.
*
* @param appDirectory - The directory of the app.
* @param callback - A callback that receives the path to the hidden folder.
* @returns The value returned by the callback function.
*/
export declare function withHiddenShopifyFolderIn<T>(appDirectory: string, callback: (hiddenFolder: string) => T): T;
/**
* Calls the given callback with the path to the config file in the hidden .shopify folder,
* ensuring the hidden folder is set up first.
*
* @param appDirectory - The directory of the app.
* @param callback - A callback that receives the path to the hidden config file.
* @returns The value returned by the callback function.
*/
export declare function withHiddenConfigPathIn<T>(appDirectory: string, callback: (hiddenConfigPath: string) => T): T;
Existing type declarationspackages/cli-kit/dist/public/node/git.d.ts@@ -35,6 +35,8 @@ export declare function createGitIgnore(directory: string, template: GitIgnoreTe
*
* @param root - The directory containing the .gitignore file.
* @param entry - The entry to add to the .gitignore file.
+ *
+ * @deprecated We should not edit the user's existing gitignore.
*/
export declare function addToGitIgnore(root: string, entry: string): void;
/**
|
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success2086 tests passing in 927 suites. Report generated by 🧪jest coverage report action from b63fb66 |
mkdirSync(hiddenFolder, {recursive: true}) | ||
writeFileSync(joinPath(hiddenFolder, '.gitignore'), `# Ignore the entire ${HIDDEN_FOLDER_NAME} directory\n*`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We call mkdir
and writeFile
everytime? is that cheaper than checking for existance of the file?
WHY are these changes introduced?
We should avoid "dirtying" the host application's
.gitignore
.WHAT is this pull request doing?
Instead of writing to the host application's
.gitignore
to hide the.shopify
directory, we can write a.gitignore
in the directory itself, which makes the directory self-ignoring.How to test your changes?
Test coverage should be good enough, but you could use the previous version of the CLI to perform a task which writes to
.gitignore
, and inspect that it wrote to it, then repeat that task using this branch and ensure the.shopify
directory and its contents remain ignored even if.gitignore
doesn't contain.shopify
.Post-release steps
Measuring impact
How do we know this change was effective? Please choose one:
Checklist