MohGovIL / hamagen-react-native

Israel's Ministry of Health's COVID-19 Exposure Prevention App
https://health.gov.il/
MIT License
508 stars 153 forks source link

Build fail due to github repo usage instead of npm package for @tmcw/togeojson #251

Open emanuelb opened 4 years ago

emanuelb commented 4 years ago

Running ./gradlew assembleRelease (to build android app)

Result:

> Task :app:bundleReleaseJsAndAssets
warn The following packages use deprecated "rnpm" config that will stop working from next release:
  - react-native-extra-dimensions-android: https://github.com/Sunhat/react-native-extra-dimensions-android#readme
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
warning: the transform cache was reset.
Loading dependency graph, done.
error While trying to resolve module `@tmcw/togeojson` from file `/app/hamagen-react-native/src/services/LocationHistoryService.ts`, the package `/app/hamagen-react-native/node_modules/@tmcw/togeojson/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/app/hamagen-react-native/node_modules/@tmcw/togeojson/dist/togeojson.umd.js`. Indeed, none of these files exist:

  * /app/hamagen-react-native/node_modules/@tmcw/togeojson/dist/togeojson.umd.js(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  * /app/hamagen-react-native/node_modules/@tmcw/togeojson/dist/togeojson.umd.js/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx). Run CLI with --verbose flag for more details.
Error: While trying to resolve module `@tmcw/togeojson` from file `/app/hamagen-react-native/src/services/LocationHistoryService.ts`, the package `/app/hamagen-react-native/node_modules/@tmcw/togeojson/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/app/hamagen-react-native/node_modules/@tmcw/togeojson/dist/togeojson.umd.js`. Indeed, none of these files exist:

  * /app/hamagen-react-native/node_modules/@tmcw/togeojson/dist/togeojson.umd.js(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  * /app/hamagen-react-native/node_modules/@tmcw/togeojson/dist/togeojson.umd.js/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
    at ResolutionRequest.resolveDependency (/app/hamagen-react-native/node_modules/react-native/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:65:15)
    at DependencyGraph.resolveDependency (/app/hamagen-react-native/node_modules/react-native/node_modules/metro/src/node-haste/DependencyGraph.js:282:16)
    at Object.resolve (/app/hamagen-react-native/node_modules/react-native/node_modules/metro/src/lib/transformHelpers.js:267:42)
    at /app/hamagen-react-native/node_modules/react-native/node_modules/metro/src/DeltaBundler/traverseDependencies.js:426:31
    at Array.map (<anonymous>)
    at resolveDependencies (/app/hamagen-react-native/node_modules/react-native/node_modules/metro/src/DeltaBundler/traverseDependencies.js:423:18)
    at /app/hamagen-react-native/node_modules/react-native/node_modules/metro/src/DeltaBundler/traverseDependencies.js:275:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/app/hamagen-react-native/node_modules/react-native/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)
    at _next (/app/hamagen-react-native/node_modules/react-native/node_modules/metro/src/DeltaBundler/traverseDependencies.js:107:9)

> Task :app:bundleReleaseJsAndAssets FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'npx'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings

it's happening because: (There old open issue about the required fix in #199 which isn't fixed yet)

the usage of github url/repo at:

https://github.com/MohGovIL/hamagen-react-native/blob/7d517d5e115a993aa2146d8cbae148992478f181/package.json#L26

instead of yarn package version, currently latest is: 4.1.0 as can be seen at: https://yarnpkg.com/package/@tmcw/togeojson

fix:

Change above url to: "@tmcw/togeojson": "4.1.0" (after testing that everything working, no breaking changes,etc...) which will fix both this issue & #199.

There is also open issue about adding CI test to ensure all packages are installed from yarn repo #200 (which help for reproducible-builds, as version number is used) and to reduce number of allowed hosts for retriving packages to 1 (registry.yarnpkg.com) and help avoid issues as this (build failure, as installation via github-repo is broken) and against malicious PRs which will add another trusted host.