这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@Jpoliachik
Copy link
Contributor

@Jpoliachik Jpoliachik commented Feb 21, 2024

This PR adds support for removing MobX-State-Tree code from a non-demo project.
Retargeted to v10 branch.

Changes:

  • // @mst inline comments, similar to how demo code removal works
  • Refactored demo.ts removal logic into more generic markup.ts to be shared with @mst comment types too, and make it easy to add additional other types in the future too.
  • Added new replace-next-line markup command type, to help swap out lines of code easily without hot patching in scripts (keeps code replacements inline next to other code)

The option shows up --removeDemo=true is set
image

Copy link
Contributor

@frankcalise frankcalise left a comment

Choose a reason for hiding this comment

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

First pass, it's taking shape nice work!

// TODO: full dryRun support

p()
p(`Removing MobX-State-Tree code from '${TARGET_DIR}'${dryRun ? " (dry run)" : ""}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

What about a try/catch here and if running into any issues, let's warn the user the automated removal could not be completed and refer them to the recipe to do so manually?

Copy link
Contributor

Choose a reason for hiding this comment

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

A suggestion: if we want to refer people to document officially, I think that document should be docs in Ignite, and not a cookbook recipe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a link to the recipe in the existing try/catch as part of the new flow 👍
I think since it's a tutorial and intended as a backup if this fails, it makes sense to keep it in Cookbook, IMO.
image

Copy link
Contributor

@lindboe lindboe Aug 1, 2024

Choose a reason for hiding this comment

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

The main reason I say documentation and not a cookbook recipe was that the original intention of cookbook was it to have less obligation to keep it perfect and/or up-to-date (and therefore encourage contributions).

Linking to things officially from here makes it seem more like documentation, to me, which also implies it should continue to be tested with Ignite updates and stay accurate. Drawing a clear line on what we want to keep up-to-date and what's "this worked at one point" seems valuable to me.

Medium GAFO on this, definitely open to disagreement, but that's the thinking behind it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to leave as a Cookbook link for now for simplicity, but if we find that the cookbook recipe falls out of date or if we want to integrate the MobX Removal instructions into official Ignite docs in the future, we can make those changes separately

@frankcalise
Copy link
Contributor

@Jpoliachik can you target this against v10 as the base branch?

* feat(boilerplate): mmkv in over async storage

* fix(cli): remove async storage new arch specifics

* test(boilerplate): mmkv clean up

* fix(boilerplate): storage.load with just a string

* test(boilerplate): storage test types
@frankcalise frankcalise added this to the Ignite v10 milestone Apr 2, 2024
@Jpoliachik
Copy link
Contributor Author

@frankcalise sure thing, I'll work on this early next week 👍

@Jpoliachik Jpoliachik marked this pull request as ready for review May 9, 2024 15:30
@Jpoliachik Jpoliachik changed the title DRAFT: Remove MobX-State-Tree flag for non-demo projects Remove MobX-State-Tree flag for non-demo projects May 9, 2024
@Jpoliachik Jpoliachik changed the base branch from master to v10 May 9, 2024 15:35
// reactotron integration with the MST root store (DEV only)
if (__DEV__) {
// @ts-ignore
console.tron.trackMstNode(rootStore)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure why this wasn't needed before, but I was getting typescript errors without.

result = sanitize(result)
} else {
result = updateFile(result, markupPrefix)
result = sanitize(result)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if this extra sanitize() was happening before - what behavior do we want here, I assumed we'd always want to get rid of all the markup regardless

# Conflicts:
#	boilerplate/app/devtools/ReactotronConfig.ts
#	boilerplate/package.json
#	src/commands/new.ts
)
p()
command(
"remove-mst-markup (rmstm)",
Copy link
Contributor

Choose a reason for hiding this comment

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

From what I can tell, removal of MST, and removal of MST markup can only be done when generating a new project, since either way the markup won't exist after generation, right?

If that's the case, should we consider these commands "internal" and not document them here, since they can't be used by end users? Or at least add that information in to the docs for context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good point - I was copying the pattern for removeDemo, but I suppose both cases wouldn't ever be usable outside of the new flow.

I'll remove the mst & mst-markup help commands - can you think of any reason to keep remove-demo and remove-demo-markup still? (maybe out of scope)

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't think of any reason, no, @frankcalise ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the reasoning was if you had an existing project where the markup wasn't removed (for the demo markup that is). We didn't always remove the markup out of the box.

That was probably around v8 though and fixed in or around some patch of 9 - we could probably look to remove it as never leaving mark up is what's current.

If we want to address the demo one as a separate PR that's fine

// TODO: full dryRun support

p()
p(`Removing MobX-State-Tree code from '${TARGET_DIR}'${dryRun ? " (dry run)" : ""}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

A suggestion: if we want to refer people to document officially, I think that document should be docs in Ignite, and not a cookbook recipe.

@Jpoliachik
Copy link
Contributor Author

This is ready for additional review.

As far as CLI documentation, I added the --mst flag option to the list, and added a blurb under the MST page. I didn't think much else was necessary, since this flag should be straightforward for users, but i'm open to opinions if we think other docs are needed!

Copy link
Contributor

@lindboe lindboe left a comment

Choose a reason for hiding this comment

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

LGTM, just a small conflict now after the v10 branch has been updated

Thanks for this! 🌟 🥳

@Jpoliachik Jpoliachik merged commit a738243 into v10 Aug 5, 2024
@Jpoliachik Jpoliachik deleted the feat/mst-flag branch August 5, 2024 20:01
infinitered-circleci pushed a commit that referenced this pull request Oct 14, 2024
# [10.0.0](v9.10.1...v10.0.0) (2024-10-14)

### Bug Fixes

* **boilerplate:** expo-router initialize i18n ([#2791](#2791) by [@frankcalise](https://github.com/frankcalise)) ([a00113e](a00113e))
* **boilerplate:** Make icon default color explicit, and respond to dark mode ([#2795](#2795) by [@lindboe](https://github.com/lindboe)) ([b82398d](b82398d))
* **cli:** improper MST removal when using CLI prompt, new arch compat ([#2785](#2785) by [@frankcalise](https://github.com/frankcalise)) ([3956652](3956652))
* remove snackify command and references ([#2763](#2763) by [@frankcalise](https://github.com/frankcalise)) ([09671e8](09671e8))

### Features

* Ignite X with Expo 51 ([005ef05](005ef05))
* **boilerplate:** Toggle component refactored to Checkbox, Radio and Switch ([#2667](#2667) by [@frankcalise](https://github.com/frankcalise)) ([54f5208](54f5208))
* **cli:** expo-router option ([#2727](#2727) by [@frankcalise](https://github.com/frankcalise)) ([8bea1f9](8bea1f9)), closes [#2731](#2731)
* **cli:** generator options --dir and --case  ([#2726](#2726) by [@frankcalise](https://github.com/frankcalise)) ([dff3d24](dff3d24))
* **Theming:** Adds theming support with documentation. ([#2636](#2636)) ([a1ae047](a1ae047))
* **v10:** cng default ([#2641](#2641)) ([c7d998d](c7d998d))
* **v10:** Remove MobX-State-Tree flag for non-demo projects ([#2647](#2647) by @Jpoliachik) ([a738243](a738243))
* add MMKV for v10 ([#2660](#2660) by [@frankcalise](https://github.com/frankcalise)) ([9164e5e](9164e5e))

### BREAKING CHANGES

* Ignite X is out now! This update adds:

* Expo Prebuild as default
* Dark mode support
* Static routing with Expo Router
* Flexible generator directory support
* Option to remove mobx-state-tree
* AsyncStorage->MMKV
* New i18n configuration with react-i18next
* Lint configuration updates
* Toggle component → Checkbox, Radio, and Switch
* Improved keyboard avoidance
* Component test example configuration

Read all about it in our blog article!

https://shift.infinite.red/what-is-ignite-x-9ecde0b34d75
@infinitered-circleci
Copy link
Collaborator

🎉 This PR is included in version 10.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants