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

[fingerprint] support skip app versions from app config #28712

Merged
merged 6 commits into from
May 17, 2024

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented May 9, 2024

Why

i've heard different feedback that they would like to ignore fingerprinting version from app.json. in their workflow they would bump version in app.json for simply for updates.
references:

How

  • introducing the sourceSkips bitwise flags that would potentially support more aggresive fingerprint for app repacking.
  • currently by default the sourceSkips is const DEFAULT_SOURCE_SKIPS = SourceSkips.AppConfigVersion | SourceSkips.AppConfigRuntimeVersion; Updates: change to SourceSkips.None
  • refactor config test to use true config content for testing

Test Plan

add some unit tests

Checklist

@expo-bot expo-bot added bot: suggestions ExpoBot has some suggestions bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels May 9, 2024
@Kudo Kudo marked this pull request as ready for review May 9, 2024 11:31
@Kudo Kudo requested review from wschurman and brentvatne May 9, 2024 11:32
Copy link
Member

@wschurman wschurman left a comment

Choose a reason for hiding this comment

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

Notes:

  • Need to think through how people will configure this who don't have access to the JS API (a file similar to .fingerprintignore maybe? how will the two interact?)
  • If we do go with the skips pattern, I think some of the items should probably be separated into their own skip enum option.

packages/@expo/fingerprint/src/Fingerprint.types.ts Outdated Show resolved Hide resolved
packages/@expo/fingerprint/src/Fingerprint.types.ts Outdated Show resolved Hide resolved
@@ -74,6 +74,8 @@ export const DEFAULT_IGNORE_PATHS = [
].join(',')}}/**/*`,
];

const DEFAULT_SOURCE_SKIPS = SourceSkips.AppConfigVersion | SourceSkips.AppConfigRuntimeVersion;
Copy link
Member

@wschurman wschurman May 10, 2024

Choose a reason for hiding this comment

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

I think it might be best to have None be the default? I realize runtime version is the logical default currently. I'm just more thinking about the different uses for this library and how to reduce breaking changes going forward (where a breaking change is a change that produces a fingerprint difference without changing the user-specified config):

  • As a standalone library, just running fingerprint from npx @expo/fingerprint. In this case it maybe makes sense to have some defaults, though I'm not sure. I think that configuration should probably mostly done through .fingerprintignore and another analogous concept for source skips.
  • As a part of the fingerprint runtimeVersion policy. In this case, all configuration needs to be done via .fingerprintignore and another analogous concept for source skips. We were okay with runtime version skip being default for it since it uses the policy and happened to not overlap with the skip. But going forward, I think None should be the default for this policy. We should strive to not introduce breaking changes here, though it's not the end of the world since the version of @expo/fingerprint used is tied to the expo-updates version which upgrading would trigger a new fingerprint anyways.
  • Through the JS API. In this case, I think having None be default makes the most sense since it's so easy for people to specify.

So overall, I think what we need is a way for people to define this in their project similar to .fingerprintignore. And maybe come up with a story of how the two interact.

Copy link
Member

Choose a reason for hiding this comment

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

i generally agree with @wschurman that we probably want to keep this list pretty small - although, i think we could get away with using the app version by default here, and i wouldn't be opposed to shipping that as-is. i'll leave that up to you guys to decide.

for anything beyond that, an approach for controlling ignores via something like .fingerprintignore (such as fingerprint.config.js) would be great - @Kudo brought this up on our sync today and i think we're on the same page. we could express our defaults in a version of that file that we create for people when they init fingerprint in their project.

packages/@expo/fingerprint/src/Fingerprint.types.ts Outdated Show resolved Hide resolved
AppConfigRuntimeVersion = 1 << 2,

// Skip app name in app.json
AppConfigName = 1 << 3,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
AppConfigName = 1 << 3,
AppConfigNameDescriptionShortName = 1 << 3,

(thinking more, maybe these should be separate skips?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this would be basically used for app repacking and i don't want to introduce too many options. let's use ExpoConfigNames for that.

packages/@expo/fingerprint/src/Fingerprint.types.ts Outdated Show resolved Hide resolved

if (sourceSkips & SourceSkips.AppConfigSchemes) {
delete normalizedConfig.scheme;
normalizedConfig.slug = '';
Copy link
Member

Choose a reason for hiding this comment

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

why is slug part of schemes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

during prebuild we will actually generate an implicit scheme based on slug.

packages/@expo/fingerprint/src/Fingerprint.types.ts Outdated Show resolved Hide resolved
Kudo added a commit that referenced this pull request May 15, 2024
# Why

follow up feedback from #28712 that we should add fingerprint config
support.

# How

introduce `fingerprint.config.js` support to override Options. not all
options are supported, because `ignorePaths` we would like to use
`.fingerprintignore` and `platform` is not supported for sure.
the priority is explicit Options > fingerprint.config.js > default
Options.
@Kudo Kudo force-pushed the @kudo/fingerprint-ignore-version branch from 67e0a99 to 253de74 Compare May 15, 2024 18:37
@Kudo Kudo changed the title [fingerprint] skip version from app config [fingerprint] support skip app versions from app config May 15, 2024
Copy link

socket-security bot commented May 15, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@react-navigation/[email protected] None +3 353 kB satya164
npm/@react-navigation/[email protected] environment 0 416 kB satya164
npm/[email protected] None 0 4.85 kB dmnd
npm/[email protected] None 0 2.34 MB tsapeta
npm/[email protected] None 0 108 kB brentvatne
npm/[email protected] None +4 546 kB wschurman
npm/[email protected] None 0 12.1 kB brentvatne
npm/[email protected] network 0 394 kB brentvatne
npm/[email protected] None 0 889 kB brentvatne
npm/[email protected] None 0 52 kB brentvatne
npm/[email protected] None +1 159 kB brentvatne
npm/[email protected] None 0 84.1 kB brentvatne
npm/[email protected] None 0 57.7 kB brentvatne
npm/[email protected] None 0 61.3 kB brentvatne
npm/[email protected] None 0 291 kB brentvatne
npm/[email protected] None 0 804 kB brentvatne
npm/[email protected] None 0 81.1 kB brentvatne
npm/[email protected] None 0 48 kB brentvatne
npm/[email protected] None 0 182 kB brentvatne
npm/[email protected] Transitive: environment, filesystem, unsafe +14 2.66 MB wschurman
npm/[email protected] None 0 269 kB brentvatne
npm/[email protected] None 0 71.2 kB brentvatne
npm/[email protected] Transitive: eval, filesystem, unsafe +9 14.3 MB brentvatne
npm/[email protected] None 0 115 kB brentvatne
npm/[email protected] None 0 62.1 kB brentvatne
npm/[email protected] None 0 100 kB brentvatne
npm/[email protected] None 0 303 kB brentvatne
npm/[email protected] None 0 610 kB brentvatne
npm/[email protected] None 0 36.1 kB brentvatne
npm/[email protected] None 0 127 kB brentvatne
npm/[email protected] None 0 268 kB brentvatne
npm/[email protected] None +1 621 kB brentvatne
npm/[email protected] None +1 23.9 kB brentvatne
npm/[email protected] None 0 55.1 kB brentvatne
npm/[email protected] None 0 71.7 kB brentvatne
npm/[email protected] None 0 110 kB brentvatne
npm/[email protected] None 0 78.3 kB brentvatne
npm/[email protected] None 0 133 kB brentvatne
npm/[email protected] None 0 353 kB brentvatne
npm/[email protected] None 0 40.5 kB brentvatne
npm/[email protected] None 0 479 kB wschurman
npm/[email protected] None 0 277 kB brentvatne
npm/[email protected] Transitive: environment, filesystem, shell, unsafe +27 16.5 MB brentvatne
npm/[email protected] Transitive: environment, filesystem +8 5.22 MB brentvatne
npm/[email protected] None 0 89.8 kB brentvatne
npm/[email protected] None 0 11.3 kB brentvatne
npm/[email protected] None 0 41.9 kB brentvatne
npm/[email protected] network Transitive: filesystem +10 1.58 MB brentvatne
npm/[email protected] None 0 80.6 kB brentvatne
npm/[email protected] None 0 5.37 kB brentvatne
npm/[email protected] None 0 30.2 kB brentvatne
npm/[email protected] environment, network Transitive: eval +4 2.84 MB brentvatne
npm/[email protected] None 0 50.7 kB brentvatne
npm/[email protected] None 0 146 kB brentvatne
npm/[email protected] None 0 102 kB brentvatne
npm/[email protected] None 0 224 kB brentvatne
npm/[email protected] None 0 29.7 kB brentvatne
npm/[email protected] None 0 40.2 kB brentvatne
npm/[email protected] None 0 70.2 kB brentvatne
npm/[email protected] None 0 120 kB brentvatne
npm/[email protected] None 0 9.18 MB brentvatne
npm/[email protected] None 0 15.3 kB brentvatne
npm/[email protected] None 0 43.7 kB brentvatne
npm/[email protected] None 0 29.9 kB brentvatne
npm/[email protected] None 0 39 kB brentvatne
npm/[email protected] None 0 44.7 kB brentvatne
npm/[email protected] None +1 164 kB brentvatne
npm/[email protected] None 0 45.2 kB brentvatne
npm/[email protected] Transitive: environment, filesystem, unsafe +15 5.37 MB brentvatne
npm/[email protected] None 0 28.3 kB brentvatne
npm/[email protected] None 0 237 kB brentvatne
npm/[email protected] None 0 186 kB brentvatne
npm/[email protected] environment 0 2.12 MB i1g
npm/[email protected] None 0 682 kB leebyron
npm/[email protected] None +1 34.5 kB blakeembrey
npm/[email protected] environment +1 4.6 MB gnoff
npm/[email protected] None +3 3.59 MB lukewalczak
npm/[email protected] environment, eval 0 3.83 MB piaskowyk
npm/[email protected] environment, network Transitive: eval, filesystem, shell, unsafe +103 101 MB react-native-bot
npm/[email protected] environment 0 316 kB gnoff
npm/[email protected] None 0 744 B afaq
npm/[email protected] None 0 32.8 MB mrdoob

🚮 Removed packages: npm/@apidevtools/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@babel/[email protected], npm/@emotion/[email protected], npm/@emotion/[email protected], npm/@emotion/[email protected], npm/@eslint-community/[email protected], npm/@eslint-community/[email protected], npm/@expo/[email protected], npm/@expo/[email protected], npm/@expo/[email protected], npm/@expo/[email protected], npm/@firebase/[email protected], npm/@floating-ui/[email protected], npm/@mdx-js/[email protected], npm/@mdx-js/[email protected], npm/@mdx-js/[email protected], npm/@nodelib/[email protected], npm/@nodelib/[email protected], npm/@octokit/[email protected], npm/@octokit/[email protected], npm/@octokit/[email protected], npm/@octokit/[email protected], npm/@ocular-d/[email protected], npm/@protobufjs/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@radix-ui/[email protected], npm/@reach/[email protected], npm/@sentry/[email protected], npm/@tailwindcss/[email protected], npm/@testing-library/[email protected], npm/@testing-library/[email protected], npm/@testing-library/[email protected], npm/@testing-library/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@types/[email protected], npm/@typescript-eslint/[email protected], npm/@typescript-eslint/[email protected], npm/@ungap/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

@Kudo
Copy link
Contributor Author

Kudo commented May 15, 2024

update the pr based on the feedback

  • default to SourceSkips.None and people could configure through fingerprint.config.js
  • refactor the config tests a little bit to use true config contents for testing. there's now a test to indicate the config test
      it('should support sourceSkips from config', async () => {
        await jest.isolateModulesAsync(async () => {
          vol.fromJSON(require('./fixtures/ExpoManaged47Project.json'));
          vol.writeFileSync(
            '/app/app.config.js',
            `\
    export default ({ config }) => {
      config.android = { versionCode: 1, package: 'com.example.app' };
      config.ios = { buildNumber: '1', bundleIdentifier: 'com.example.app' };
      return config;
    };`
          );
    
          const configContents = `\
    const { SourceSkips } = require('@expo/fingerprint');
    /** @type {import('@expo/fingerprint').Config} */
    const config = {
      sourceSkips: SourceSkips.ExpoConfigAndroidPackage | SourceSkips.ExpoConfigIosBundleIdentifier | SourceSkips.ExpoConfigVersions,
    };
    module.exports = config;
    `;
          vol.writeFileSync('/app/fingerprint.config.js', configContents);
          jest.doMock('/app/fingerprint.config.js', () => requireString(configContents), {
            virtual: true,
          });
    
          const sources = await getExpoConfigSourcesAsync('/app', await normalizeOptionsAsync('/app'));
          const expoConfigSource = sources.find<HashSourceContents>(
            (source): source is HashSourceContents =>
              source.type === 'contents' && source.id === 'expoConfig'
          );
          const expoConfig = JSON.parse(expoConfigSource?.contents?.toString() ?? 'null');
          expect(expoConfig).not.toBeNull();
          expect(expoConfig.version).toBeUndefined();
          expect(expoConfig.android.versionCode).toBeUndefined();
          expect(expoConfig.android.package).toBeUndefined();
          expect(expoConfig.ios.buildNumber).toBeUndefined();
          expect(expoConfig.ios.bundleIdentifier).toBeUndefined();
        });
      });

@Kudo Kudo requested a review from wschurman May 15, 2024 18:54
@Kudo Kudo merged commit 5b47f52 into main May 17, 2024
11 checks passed
@Kudo Kudo deleted the @kudo/fingerprint-ignore-version branch May 17, 2024 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: fingerprint compatible bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants