From 87fa2a83c224962c845fd2d3ae83a390c94cd4b7 Mon Sep 17 00:00:00 2001 From: Tyler Williams Date: Thu, 17 Oct 2024 14:40:56 -0600 Subject: [PATCH 1/5] fix: add ending newline to model generator --- boilerplate/ignite/templates/model/NAME.ts.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boilerplate/ignite/templates/model/NAME.ts.ejs b/boilerplate/ignite/templates/model/NAME.ts.ejs index 84a7bbcd2..02a10fb67 100644 --- a/boilerplate/ignite/templates/model/NAME.ts.ejs +++ b/boilerplate/ignite/templates/model/NAME.ts.ejs @@ -31,4 +31,4 @@ export interface <%= props.pascalCaseName %>SnapshotOut extends SnapshotOutSnapshotIn extends SnapshotInModel> {} export const create<%= props.pascalCaseName %>DefaultModel = () => types.optional(<%= props.pascalCaseName %>Model, {}) -// @mst remove-file \ No newline at end of file +// @mst remove-file From 148e526f4eaf07d7b894949a9d96152185afa9af Mon Sep 17 00:00:00 2001 From: Tyler Williams Date: Thu, 17 Oct 2024 14:58:41 -0600 Subject: [PATCH 2/5] fix: add ending newline to model test generator --- boilerplate/ignite/templates/model/NAME.test.ts.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boilerplate/ignite/templates/model/NAME.test.ts.ejs b/boilerplate/ignite/templates/model/NAME.test.ts.ejs index 6cca55ec6..5504b5146 100644 --- a/boilerplate/ignite/templates/model/NAME.test.ts.ejs +++ b/boilerplate/ignite/templates/model/NAME.test.ts.ejs @@ -9,4 +9,4 @@ test("can be created", () => { expect(instance).toBeTruthy() }) -// @mst remove-file \ No newline at end of file +// @mst remove-file From cb78066ea24539569e21dcc20fbf9d5b9fe0c09c Mon Sep 17 00:00:00 2001 From: Tyler Williams Date: Thu, 17 Oct 2024 15:08:18 -0600 Subject: [PATCH 3/5] chore: disable prettier in Jest --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c1d974323..39d0ce0d0 100644 --- a/package.json +++ b/package.json @@ -159,6 +159,7 @@ "tsx", "js", "jsx" - ] + ], + "prettierPath": null } } From 89841942359faa1c434c000a018d04e27d834777 Mon Sep 17 00:00:00 2001 From: Tyler Williams Date: Thu, 17 Oct 2024 15:08:29 -0600 Subject: [PATCH 4/5] test: update generator snapshots --- test/vanilla/ignite-generate.test.ts | 108 ++++++++++++++------------- 1 file changed, 56 insertions(+), 52 deletions(-) diff --git a/test/vanilla/ignite-generate.test.ts b/test/vanilla/ignite-generate.test.ts index 82b54564f..3dad0df51 100644 --- a/test/vanilla/ignite-generate.test.ts +++ b/test/vanilla/ignite-generate.test.ts @@ -57,37 +57,39 @@ describe("ignite-cli generate", () => { " `) expect(read(`${TEMP_DIR}/app/models/Pizza.ts`)).toMatchInlineSnapshot(` - "import { Instance, SnapshotIn, SnapshotOut, types } from \\"mobx-state-tree\\" - import { withSetPropAction } from \\"./helpers/withSetPropAction\\" +"import { Instance, SnapshotIn, SnapshotOut, types } from \\"mobx-state-tree\\" +import { withSetPropAction } from \\"./helpers/withSetPropAction\\" - /** - * Model description here for TypeScript hints. - */ - export const PizzaModel = types - .model(\\"Pizza\\") - .props({}) - .actions(withSetPropAction) - .views((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars - .actions((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars - - export interface Pizza extends Instance {} - export interface PizzaSnapshotOut extends SnapshotOut {} - export interface PizzaSnapshotIn extends SnapshotIn {} - export const createPizzaDefaultModel = () => types.optional(PizzaModel, {}) - - // @mst remove-file" - `) +/** + * Model description here for TypeScript hints. + */ +export const PizzaModel = types + .model(\\"Pizza\\") + .props({}) + .actions(withSetPropAction) + .views((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars + .actions((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars + +export interface Pizza extends Instance {} +export interface PizzaSnapshotOut extends SnapshotOut {} +export interface PizzaSnapshotIn extends SnapshotIn {} +export const createPizzaDefaultModel = () => types.optional(PizzaModel, {}) + +// @mst remove-file +" +`) expect(read(`${TEMP_DIR}/app/models/Pizza.test.ts`)).toMatchInlineSnapshot(` - "import { PizzaModel } from \\"./Pizza\\" +"import { PizzaModel } from \\"./Pizza\\" - test(\\"can be created\\", () => { - const instance = PizzaModel.create({}) +test(\\"can be created\\", () => { + const instance = PizzaModel.create({}) - expect(instance).toBeTruthy() - }) + expect(instance).toBeTruthy() +}) - // @mst remove-file" - `) +// @mst remove-file +" +`) expect(read(`${TEMP_DIR}/app/models/index.ts`)).toMatchInlineSnapshot(` "export * from \\"./RootStore\\" export * from \\"./helpers/getRootStore\\" @@ -138,37 +140,39 @@ describe("ignite-cli generate", () => { " `) expect(read(`${TEMP_DIR}/app/models/PizzaStore.ts`)).toMatchInlineSnapshot(` - "import { Instance, SnapshotIn, SnapshotOut, types } from \\"mobx-state-tree\\" - import { withSetPropAction } from \\"./helpers/withSetPropAction\\" +"import { Instance, SnapshotIn, SnapshotOut, types } from \\"mobx-state-tree\\" +import { withSetPropAction } from \\"./helpers/withSetPropAction\\" - /** - * Model description here for TypeScript hints. - */ - export const PizzaStoreModel = types - .model(\\"PizzaStore\\") - .props({}) - .actions(withSetPropAction) - .views((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars - .actions((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars - - export interface PizzaStore extends Instance {} - export interface PizzaStoreSnapshotOut extends SnapshotOut {} - export interface PizzaStoreSnapshotIn extends SnapshotIn {} - export const createPizzaStoreDefaultModel = () => types.optional(PizzaStoreModel, {}) - - // @mst remove-file" - `) +/** + * Model description here for TypeScript hints. + */ +export const PizzaStoreModel = types + .model(\\"PizzaStore\\") + .props({}) + .actions(withSetPropAction) + .views((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars + .actions((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars + +export interface PizzaStore extends Instance {} +export interface PizzaStoreSnapshotOut extends SnapshotOut {} +export interface PizzaStoreSnapshotIn extends SnapshotIn {} +export const createPizzaStoreDefaultModel = () => types.optional(PizzaStoreModel, {}) + +// @mst remove-file +" +`) expect(read(`${TEMP_DIR}/app/models/PizzaStore.test.ts`)).toMatchInlineSnapshot(` - "import { PizzaStoreModel } from \\"./PizzaStore\\" +"import { PizzaStoreModel } from \\"./PizzaStore\\" - test(\\"can be created\\", () => { - const instance = PizzaStoreModel.create({}) +test(\\"can be created\\", () => { + const instance = PizzaStoreModel.create({}) - expect(instance).toBeTruthy() - }) + expect(instance).toBeTruthy() +}) - // @mst remove-file" - `) +// @mst remove-file +" +`) expect(read(`${TEMP_DIR}/app/models/index.ts`)).toMatchInlineSnapshot(` "export * from \\"./RootStore\\" export * from \\"./helpers/getRootStore\\" From ec682f836daea6f9db7009d0205ecfe6cd3f8e48 Mon Sep 17 00:00:00 2001 From: Tyler Williams Date: Fri, 18 Oct 2024 12:05:07 -0600 Subject: [PATCH 5/5] fix: optionally use 2 versions of prettier for Jest --- package.json | 3 ++- yarn.lock | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 39d0ce0d0..ed0fee478 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "husky": "^7.0.1", "jest": "^27.0.6", "prettier": "^3.3.3", + "prettier-2": "npm:prettier@2.8.8", "semantic-release": "^17.4.2", "ts-jest": "^27.0.4", "ts-node": "^10.2.0", @@ -160,6 +161,6 @@ "js", "jsx" ], - "prettierPath": null + "prettierPath": "/node_modules/prettier-2/index.js" } } diff --git a/yarn.lock b/yarn.lock index 29fe7f900..cb232c494 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5718,6 +5718,11 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== +"prettier-2@npm:prettier@2.8.8": + version "2.8.8" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" + integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== + prettier@^3.3.3: version "3.3.3" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105"