Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[module-scripts] vendoring source-login-scripts.sh #15336

Merged
merged 8 commits into from
Dec 1, 2021

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented Nov 29, 2021

Why

follow up with #14895 (comment)
close ENG-2493

How

add templates/scripts/source-login-scripts.sh to expo-module-scripts and it will sync to expo module package when yarn prepare if there's also scripts/source-login-scripts.sh and having @generated comment mark.

change the file iterator in expo-module-configure from shell glob expansion with find which enabled the recursive iteration, e.g. scripts/source-login-scripts.sh

Test Plan

  • modify some template files in expo-module-scripts and yarn prepare for expo-constants, make sure the files are synced.
  • yare prepack in expo-updates and from a sdk43 project to run yarn add file:/path/to/expo/packages/expo-updates, test the build successful.

Checklist

  • Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md).
  • This diff will work correctly for expo build (eg: updated @expo/xdl).
  • This diff will work correctly for expo prebuild & EAS Build (eg: updated a module plugin).

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Nov 29, 2021
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Nov 29, 2021
@Kudo Kudo requested review from brentvatne and ide November 29, 2021 15:19
@Kudo Kudo marked this pull request as ready for review November 29, 2021 15:19
@@ -12,6 +12,8 @@
"test": "expo-module test",
"prepare": "expo-module prepare",
"prepublishOnly": "expo-module prepublishOnly",
"prepack": "expo-module vendorScripts",
Copy link
Member

Choose a reason for hiding this comment

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

The expo-module-scripts binaries are named after npm lifecycle scripts: expo-module prepack. The idea is that each package's package.json file shouldn't make many decisions -- they should just map each npm lifecycle script to expo-module <X>.

Comment on lines 19 to 21
# Keeps the following `$$EXPO_MODULE_VENDOR_SCRIPTS$$`` comment and
# `expo-module-scripts' will replace the comment line with the content of `source-login-scripts.sh` during npm prepack
source "$EXPO_UPDATES_PACKAGE_DIR/../../tools/source-login-scripts.sh" # $$EXPO_MODULE_VENDOR_SCRIPTS$$ '../../../tools/source-login-scripts.sh'
Copy link
Member

Choose a reason for hiding this comment

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

Dynamically vendoring the script seems fragile. I think it would be better just to copy/paste it and commit the vendored scripts to the repo (Git will deduplicate the files in its index).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i agree that and what's the "vendoring" in your thought? the current work is exactly copy/paste the source-login-scripts.sh into expo-constants package:

source "$EXPO_CONSTANTS_PACKAGE_DIR/scripts/source-login-scripts.sh"

Copy link
Member

Choose a reason for hiding this comment

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

I have two ideas:

  • Vendoring + committing the script to Git: Copy and paste source-login-scripts.sh into the packages that need it. If we need to, we could make expo-module prepare check if scripts/source-login-scripts.sh is defined and contains the string # @autogenerated. If so, it would copy the latest version of source-login-scripts.sh into the package, similar to how tsconfig.json, babel.config.js, etc. are copied.
  • Depending on the the script as an npm dependency: add source-login-scripts@^1.0.0 to package.json and source $script_dir/../../node_modules/source-login-scripts/source-login-scripts.sh. However, this technique breaks with Yarn workspaces since the source-login-scripts package might be hoisted into the root directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i like the option 1 because it won't break workspace support and easier to maintain. i'll update the pr accordingly. thanks for your advice 😁

@expo-bot expo-bot added bot: suggestions ExpoBot has some suggestions and removed bot: passed checks ExpoBot has nothing to complain about labels Nov 30, 2021
@Kudo Kudo requested a review from ide November 30, 2021 17:07
Copy link
Member

@ide ide left a comment

Choose a reason for hiding this comment

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

The last thing we may want to do is to create a symlink from tools/source-login-scripts.sh to packages/expo-module-scripts/templates/scripts/source-login-scripts.sh so there is just one main copy in this repo.

@Kudo Kudo force-pushed the @kudo/vendoring-source-login-script branch from d736bae to a496c5c Compare December 1, 2021 01:42
@Kudo Kudo requested a review from tsapeta as a code owner December 1, 2021 01:42
@expo-bot
Copy link
Collaborator

expo-bot commented Dec 1, 2021

Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines.

I've found some issues in your pull request that should be addressed (click on them for more details) 👇

⚠️ Suggestion: Missing changelog entries


Your changes should be noted in the changelog. Read Updating Changelogs guide and consider (it's optional) adding an appropriate entry to the following changelogs:


Generated by ExpoBot 🤖 against a496c5c

@Kudo
Copy link
Contributor Author

Kudo commented Dec 1, 2021

The last thing we may want to do is to create a symlink from tools/source-login-scripts.sh to packages/expo-module-scripts/templates/scripts/source-login-scripts.sh so there is just one main copy in this repo.

good idea 👏
i was hesitant of updating the code for accessing from tools/source-login-scripts.sh to packages/expo-module-scripts/templates/scripts/source-login-scripts.sh. the symlink solution works for good semantic and maintenance cost.

i've updated the pr for the symlink change.

@Kudo Kudo merged commit 8db2fac into master Dec 1, 2021
@Kudo Kudo deleted the @kudo/vendoring-source-login-script branch December 1, 2021 10:46
Kudo added a commit that referenced this pull request Dec 2, 2021
…po modules (#15376)

# Why

regression of #15336, where we should not sync `source-login-scripts.sh` to other expo modules.
i just misread the `if [ ! -f "$output_file" ] || grep --quiet "@generated" "$output_file"; then` line.

# How

- introduce `source-login-scripts.sh` as an optional template file which only to sync if it's present and contains `@generated` as described in #15336 (comment)

# Test Plan

- `yarn prepare` in expo-device and make sure `source-login-scripts.sh` not be generated.
- change `source-login-scripts.sh` and `yarn prepare` in expo-constants. check it's updated.


Co-authored-by: James Ide <ide@users.noreply.github.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bot: suggestions ExpoBot has some suggestions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants