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

Added barrel file for models #341

Merged
merged 23 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8a1bb1f
Added block in readme regarding upgrading
nsoderstromgmp Aug 1, 2019
3e769a5
Moved block above typescript
nsoderstromgmp Aug 2, 2019
d206d69
Merge branch 'master' of https://github.com/infinitered/ignite-bowser
nsoderstromgmp Dec 27, 2019
0cb6cff
Added ability to generate a React.FunctionComponent aka "hooks enable…
nsoderstromgmp Dec 29, 2019
4cd1475
Fixed prettier commands so they work with zsh.
nsoderstromgmp Dec 29, 2019
3a23ccc
Added parameters for choosing component type.
nsoderstromgmp Jan 1, 2020
148d32d
Updated component tests.
nsoderstromgmp Jan 1, 2020
da9b106
Updated component tests.
nsoderstromgmp Jan 1, 2020
1acd22d
Added documentation for generators.
nsoderstromgmp Jan 7, 2020
5e5669a
Added documentation for the navigation generator.
nsoderstromgmp Jan 7, 2020
b1ff75f
Added spacing, small tweaks
jamonholmgren Jan 16, 2020
1a8097f
Merge branch 'master' of https://github.com/infinitered/ignite-bowser
nsoderstromgmp Jan 17, 2020
647f983
Updated React Native version to 0.61.5.
nsoderstromgmp Jan 17, 2020
7f22cca
Merge branch 'master' of https://github.com/nirre7/ignite-bowser
nsoderstromgmp Jan 17, 2020
80a626f
Merge branch 'master' of https://github.com/infinitered/ignite-bowser
nsoderstromgmp Mar 30, 2020
b4b5766
Merge branch 'master' of https://github.com/infinitered/ignite-bowser
nsoderstromgmp Apr 15, 2020
40fb5bb
Merge branch 'master' of https://github.com/infinitered/ignite-bowser
nsoderstromgmp May 18, 2020
7474763
Added barrel export to models.
nsoderstromgmp May 18, 2020
c177a68
Updated test
nsoderstromgmp May 19, 2020
ef40b2d
Added return type.
nsoderstromgmp May 19, 2020
4168130
Merge branch 'master' into generator-improvements
jamonholmgren May 21, 2020
3143afd
Fix conflict
jamonholmgren May 21, 2020
e244a7d
Fix path issues maybe
jamonholmgren May 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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