From 6b73be65d9235386088fe8ffb7778d242d03c259 Mon Sep 17 00:00:00 2001 From: Hideyuki Kagami Date: Sun, 28 Jan 2024 17:09:04 +0900 Subject: [PATCH] adjust patch libs --- generators/react-native/generator.mjs | 39 +++++++++++++-------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/generators/react-native/generator.mjs b/generators/react-native/generator.mjs index 531f330e5..0e6b7c401 100644 --- a/generators/react-native/generator.mjs +++ b/generators/react-native/generator.mjs @@ -17,6 +17,8 @@ import { patchNavigationForEntity, patchEntityApi, patchInFile, + appendFiles, + patchBabel, } from '../../lib/index.js'; export default class extends BaseApplicationGenerator { @@ -144,25 +146,9 @@ export default class extends BaseApplicationGenerator { get [BaseApplicationGenerator.PREPARING]() { return this.asPreparingTaskGroup({ - // preparing({ application }) { - // application.myCustomConfigFoo = this.jhipsterConfig.myCustomConfig === 'foo'; - // application.myCustomConfigBar = this.jhipsterConfig.myCustomConfig === 'bar'; - // application.myCustomConfigNo = !this.jhipsterConfig.myCustomConfig || this.jhipsterConfig.myCustomConfig === 'no'; - // }, - // differentRelationshipsWorkaround(foo) { - // // todo: remove this - need to figure out why context.differentRelationships - // // todo: has a value here but is undefined in the templates. - // const alreadyIncludedEntities = []; - // const uniqueEntityRelationships = []; - // this.context.relationships.forEach(relation => { - // if (!alreadyIncludedEntities.includes(relation.otherEntityName)) { - // alreadyIncludedEntities.push(relation.otherEntityName); - // uniqueEntityRelationships.push(relation); - // } - // }); - // this.reactNativeContext.uniqueOwnerSideRelationships = uniqueEntityRelationships.filter(relation => relation.ownerSide); - // this.reactNativeContext.ownerSideRelationships = this.context.relationships.filter(relation => relation.ownerSide); - // }, + preparingPatchInFile() { + this.patchInFile = patchInFile.bind(this); + }, }); } @@ -188,6 +174,20 @@ export default class extends BaseApplicationGenerator { this.replacePackageJsonVersions('REPLACE_WITH_VERSION', join(srcDir, 'templates/package.json')); this.replacePackageJsonVersions('EXPO_REPLACE_WITH_VERSION', join(srcDir, 'resources/expo/package.json')); }, + async patchUriScheme({ application }) { + const appConfig = this.fs.readJSON('app.json'); + appConfig.expo.scheme = application.baseName.toLowerCase(); + appConfig.expo.extra = {}; + appConfig.expo.web = appConfig.expo.web || {}; + appConfig.expo.web.bundler = 'metro'; + this.fs.writeJSON('app.json', appConfig); + }, + async appendFiles() { + appendFiles.bind(this)(); + }, + async patchBabel() { + patchBabel.bind(this)(); + }, }); } @@ -242,7 +242,6 @@ export default class extends BaseApplicationGenerator { return this.asWritingEntitiesTaskGroup({ async writeEntities({ application, entities }) { const { enableTranslation } = application; - this.patchInFile = patchInFile.bind(this); await Promise.all( entities .filter(entity => !entity.builtIn)