Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
feat(boilerplate): Upgrades to React Native 0.61.5, adds barrel file …
Browse files Browse the repository at this point in the history
…for models (#341 by @nirre7)
  • Loading branch information
nirre7 authored May 22, 2020
1 parent d3f9cc4 commit 0c79752
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion boilerplate/app/app.tsx.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
setRootNavigation,
useNavigationPersistence,
} from "./navigation"
import { RootStore, RootStoreProvider, setupRootStore } from "./models/root-store"
import { RootStore, RootStoreProvider, setupRootStore } from "./models"

// This puts screens in a native ViewController or Activity. If you want fully native
// stack navigation, use `createNativeStackNavigator` in place of `createStackNavigator`:
Expand Down
3 changes: 0 additions & 3 deletions boilerplate/app/models/extensions/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion boilerplate/app/models/extensions/with-root-store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getRoot, IStateTreeNode } from "mobx-state-tree"
import { RootStoreModel } from "../root-store"
import { RootStoreModel } from "../root-store/root-store"

/**
* Adds a rootStore property to the node for a convenient
Expand Down
6 changes: 6 additions & 0 deletions boilerplate/app/models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from "./extensions/with-environment"
export * from "./extensions/with-root-store"
export * from "./extensions/with-status"
export * from "./root-store/root-store"
export * from "./root-store/root-store-context"
export * from "./root-store/setup-root-store"
3 changes: 0 additions & 3 deletions boilerplate/app/models/root-store/index.ts

This file was deleted.

18 changes: 11 additions & 7 deletions src/commands/generate/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ export const run = async function(toolbox: GluegunToolbox) {
},
]

const rollupPath = `app/models/${name}/index.ts`
const rollupExists = filesystem.exists(rollupPath)

if (rollupExists) {
await patching.prepend(rollupPath, `export * from "./${name}"`)
} else {
jobs.push({ template: "rollup-index.ts.ejs", target: rollupPath })
// patch the barrel export file
const barrelExportPath = `${process.cwd()}/app/models/index.ts`
const exportToAdd = `export * from "./${name}/${name}"\n`

if (!filesystem.exists(barrelExportPath)) {
const msg =
`No '${barrelExportPath}' file found. Can't export model.` +
`Export your new model manually.`
print.warning(msg)
process.exit(1)
}
await patching.append(barrelExportPath, exportToAdd)

await ignite.copyBatch(toolbox, jobs, props)

Expand Down
2 changes: 1 addition & 1 deletion templates/function-component.tsx.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { FunctionComponent as Component } from "react"
import { View } from "react-native"
import { Text } from "../"
// import { observer } from "mobx-react-lite"
// import { useStores } from "../../models/root-store"
// import { useStores } from "../../models"
import { <%= props.camelCaseName %>Styles as styles } from "./<%= props.name %>.styles"

export interface <%= props.pascalName %>Props {}
Expand Down
2 changes: 1 addition & 1 deletion templates/screen.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { observer } from "mobx-react-lite"
import { ViewStyle } from "react-native"
import { Screen, Text } from "../components"
// import { useNavigation } from "@react-navigation/native"
// import { useStores } from "../models/root-store"
// import { useStores } from "../models"
import { color } from "../theme"

const ROOT: ViewStyle = {
Expand Down
2 changes: 1 addition & 1 deletion test/generators-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe("a generated app", () => {
await execaShell(`${IGNITE_COMMAND} g model ${simpleModel}`, { preferLocal: false })
expect(jetpack.exists(`app/models/${simpleModel}/${simpleModel}.ts`)).toBe("file")
expect(jetpack.exists(`app/models/${simpleModel}/${simpleModel}.test.ts`)).toBe("file")
expect(jetpack.exists(`app/models/${simpleModel}/index.ts`)).toBe("file")
expect(jetpack.exists(`app/models/index.ts`)).toBe("file")
const lint = await execa("npm", ["-s", "run", "lint"])
expect(lint.stderr).toBe("")
})
Expand Down

2 comments on commit 0c79752

@viralS-tuanlv
Copy link

Choose a reason for hiding this comment

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

what is Upgrades to React Native 0.61.5? wrong name of commit?

@nirre7
Copy link
Contributor Author

@nirre7 nirre7 commented on 0c79752 May 24, 2020

Choose a reason for hiding this comment

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

Weird. Muat have been my ide and me not paying attention. Ignite bowser is already on that version.

Please sign in to comment.