@matizze/prumo-cli 0.0.0-stage → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/README.md +121 -2
  2. package/dist/api.d.ts +10 -0
  3. package/dist/api.js +9 -0
  4. package/dist/args.d.ts +11 -0
  5. package/dist/args.js +61 -0
  6. package/dist/bin.d.ts +2 -0
  7. package/dist/bin.js +11 -0
  8. package/dist/codemod/add-route.d.ts +66 -0
  9. package/dist/codemod/add-route.js +435 -0
  10. package/dist/codemod/edit.d.ts +35 -0
  11. package/dist/codemod/edit.js +51 -0
  12. package/dist/codemod/index.d.ts +8 -0
  13. package/dist/codemod/index.js +8 -0
  14. package/dist/codemod/merge-barrel.d.ts +9 -0
  15. package/dist/codemod/merge-barrel.js +49 -0
  16. package/dist/codemod/messages.d.ts +11 -0
  17. package/dist/codemod/messages.js +46 -0
  18. package/dist/codemod/names.d.ts +62 -0
  19. package/dist/codemod/names.js +204 -0
  20. package/dist/codemod/plan.d.ts +45 -0
  21. package/dist/codemod/plan.js +147 -0
  22. package/dist/codemod/register-domain.d.ts +51 -0
  23. package/dist/codemod/register-domain.js +237 -0
  24. package/dist/codemod/register-messages.d.ts +11 -0
  25. package/dist/codemod/register-messages.js +112 -0
  26. package/dist/codemod/route-elements.d.ts +25 -0
  27. package/dist/codemod/route-elements.js +72 -0
  28. package/dist/commands/check.d.ts +16 -0
  29. package/dist/commands/check.js +47 -0
  30. package/dist/commands/doctor.d.ts +20 -0
  31. package/dist/commands/doctor.js +87 -0
  32. package/dist/commands/make-component.d.ts +33 -0
  33. package/dist/commands/make-component.js +85 -0
  34. package/dist/commands/make-domain.d.ts +30 -0
  35. package/dist/commands/make-domain.js +83 -0
  36. package/dist/commands/make-page.d.ts +30 -0
  37. package/dist/commands/make-page.js +73 -0
  38. package/dist/commands/new.d.ts +33 -0
  39. package/dist/commands/new.js +184 -0
  40. package/dist/commands/shared.d.ts +43 -0
  41. package/dist/commands/shared.js +83 -0
  42. package/dist/describe.d.ts +63 -0
  43. package/dist/describe.js +134 -0
  44. package/dist/doctor/checks.d.ts +35 -0
  45. package/dist/doctor/checks.js +283 -0
  46. package/dist/doctor/ranges.d.ts +16 -0
  47. package/dist/doctor/ranges.js +27 -0
  48. package/dist/doctor/versions.d.ts +33 -0
  49. package/dist/doctor/versions.js +44 -0
  50. package/dist/errors.d.ts +12 -0
  51. package/dist/errors.js +19 -0
  52. package/dist/generate/app.d.ts +29 -0
  53. package/dist/generate/app.js +137 -0
  54. package/dist/generate/component.d.ts +36 -0
  55. package/dist/generate/component.js +48 -0
  56. package/dist/generate/domain.d.ts +31 -0
  57. package/dist/generate/domain.js +63 -0
  58. package/dist/generate/page.d.ts +45 -0
  59. package/dist/generate/page.js +100 -0
  60. package/dist/help.d.ts +19 -0
  61. package/dist/help.js +97 -0
  62. package/dist/in-process.d.ts +26 -0
  63. package/dist/in-process.js +23 -0
  64. package/dist/index.d.ts +9 -0
  65. package/dist/index.js +9 -0
  66. package/dist/new/name.d.ts +7 -0
  67. package/dist/new/name.js +24 -0
  68. package/dist/new/packages.d.ts +6 -0
  69. package/dist/new/packages.js +40 -0
  70. package/dist/new/versions.d.ts +7 -0
  71. package/dist/new/versions.js +13 -0
  72. package/dist/pnpm.d.ts +14 -0
  73. package/dist/pnpm.js +37 -0
  74. package/dist/process.d.ts +22 -0
  75. package/dist/process.js +45 -0
  76. package/dist/project.d.ts +22 -0
  77. package/dist/project.js +42 -0
  78. package/dist/root.d.ts +3 -0
  79. package/dist/root.js +24 -0
  80. package/dist/run.d.ts +13 -0
  81. package/dist/run.js +72 -0
  82. package/dist/runtime.d.ts +19 -0
  83. package/dist/runtime.js +1 -0
  84. package/dist/templates.d.ts +26 -0
  85. package/dist/templates.js +46 -0
  86. package/package.json +45 -3
  87. package/templates/app/AGENTS.md.tpl +50 -0
  88. package/templates/app/README.md.tpl +15 -0
  89. package/templates/app/eslint.config.js.tpl +19 -0
  90. package/templates/app/gitignore.tpl +22 -0
  91. package/templates/app/index.html.tpl +12 -0
  92. package/templates/app/mcp.json.tpl +8 -0
  93. package/templates/app/src/App.tsx.tpl +8 -0
  94. package/templates/app/src/i18n.ts.tpl +12 -0
  95. package/templates/app/src/main.tsx.tpl +12 -0
  96. package/templates/app/src/messages/index.ts.tpl +1 -0
  97. package/templates/app/src/providers/app.tsx.tpl +23 -0
  98. package/templates/app/src/providers/repository/index.ts.tpl +5 -0
  99. package/templates/app/src/queries-index.ts.tpl +1 -0
  100. package/templates/app/src/repositories/index.ts.tpl +18 -0
  101. package/templates/app/src/repositories/options.ts.tpl +8 -0
  102. package/templates/app/src/schemas-index.ts.tpl +1 -0
  103. package/templates/app/src/test/render.tsx.tpl +31 -0
  104. package/templates/app/src/test/setup.ts.tpl +4 -0
  105. package/templates/app/typescript.json.tpl +24 -0
  106. package/templates/app/vite.config.ts.tpl +16 -0
  107. package/templates/component/component-test.tsx.tpl +9 -0
  108. package/templates/component/component.tsx.tpl +11 -0
  109. package/templates/domain/queries.ts.tpl +62 -0
  110. package/templates/domain/repository-contract-test.ts.tpl +75 -0
  111. package/templates/domain/repository-contract.ts.tpl +13 -0
  112. package/templates/domain/repository-fixtures.ts.tpl +8 -0
  113. package/templates/domain/repository-index.ts.tpl +12 -0
  114. package/templates/domain/repository-mock.ts.tpl +69 -0
  115. package/templates/domain/schema.ts.tpl +23 -0
  116. package/templates/page/index-domain-test.tsx.tpl +11 -0
  117. package/templates/page/index-test.tsx.tpl +10 -0
  118. package/templates/page/index.tsx.tpl +7 -0
  119. package/templates/page/messages-domain.en.json.tpl +5 -0
  120. package/templates/page/messages-domain.pt-BR.json.tpl +5 -0
  121. package/templates/page/messages.en.json.tpl +3 -0
  122. package/templates/page/messages.pt-BR.json.tpl +3 -0
  123. package/templates/page/model-domain.ts.tpl +17 -0
  124. package/templates/page/model.ts.tpl +8 -0
  125. package/templates/page/view-domain.tsx.tpl +20 -0
  126. package/templates/page/view.tsx.tpl +9 -0
@@ -0,0 +1,69 @@
1
+ import type { Page } from '@matizze/prumo-core/data'
2
+ import { UIError } from '@matizze/prumo-core/errors'
3
+ import { matchesSearch, paginate, sortBy, wait } from '@matizze/prumo-core/mock'
4
+ import type { {{singular.pascal}}Input, {{singular.pascal}}ListQuery, {{singular.pascal}}Schema } from '@/schemas'
5
+ import { MOCK_{{plural.constant}} } from './fixtures'
6
+ import type { I{{plural.pascal}}Repository } from './repository.contract'
7
+
8
+ export interface Mock{{plural.pascal}}RepositoryOptions {
9
+ /** Latência simulada por operação, em ms (padrão 300). Use 0 em testes. */
10
+ latencyMs?: number
11
+ }
12
+
13
+ export class Mock{{plural.pascal}}Repository implements I{{plural.pascal}}Repository {
14
+ private readonly items: {{singular.pascal}}Schema[] = [...MOCK_{{plural.constant}}]
15
+ private readonly latencyMs: number
16
+ private sequence = MOCK_{{plural.constant}}.length
17
+
18
+ constructor({ latencyMs = 300 }: Mock{{plural.pascal}}RepositoryOptions = {}) {
19
+ this.latencyMs = latencyMs
20
+ }
21
+
22
+ async list(query: {{singular.pascal}}ListQuery = {}): Promise<Page<{{singular.pascal}}Schema>> {
23
+ await wait(this.latencyMs)
24
+ const filtered = this.items.filter((item) => matchesSearch([item.name], query.search))
25
+ const sorted = sortBy(filtered, query.sort, {
26
+ name: (item) => item.name,
27
+ createdAt: (item) => item.createdAt,
28
+ })
29
+ return paginate(sorted, query.page, query.page_size)
30
+ }
31
+
32
+ async get(id: string): Promise<{{singular.pascal}}Schema> {
33
+ await wait(this.latencyMs)
34
+ return this.find(id).item
35
+ }
36
+
37
+ async create(input: {{singular.pascal}}Input): Promise<{{singular.pascal}}Schema> {
38
+ await wait(this.latencyMs)
39
+ this.sequence += 1
40
+ const item: {{singular.pascal}}Schema = {
41
+ id: `{{singular.kebab}}-${this.sequence}`,
42
+ name: input.name,
43
+ createdAt: new Date().toISOString(),
44
+ }
45
+ this.items.push(item)
46
+ return item
47
+ }
48
+
49
+ async update(id: string, input: {{singular.pascal}}Input): Promise<{{singular.pascal}}Schema> {
50
+ await wait(this.latencyMs)
51
+ const { at, item } = this.find(id)
52
+ // Troca o objeto em vez de mexer nele: as fixtures e o que já foi devolvido não mudam
53
+ const updated = { ...item, name: input.name }
54
+ this.items[at] = updated
55
+ return updated
56
+ }
57
+
58
+ async remove(id: string): Promise<void> {
59
+ await wait(this.latencyMs)
60
+ this.items.splice(this.find(id).at, 1)
61
+ }
62
+
63
+ private find(id: string): { at: number; item: {{singular.pascal}}Schema } {
64
+ const at = this.items.findIndex((candidate) => candidate.id === id)
65
+ const item = this.items[at]
66
+ if (!item) throw new UIError('{{singular.constant}}_NOT_FOUND', 'Registro não encontrado.')
67
+ return { at, item }
68
+ }
69
+ }
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod'
2
+ import type { PageQuery, Sort } from '@matizze/prumo-core/data'
3
+
4
+ export const {{singular.camel}}Schema = z.object({
5
+ id: z.string(),
6
+ name: z.string(),
7
+ createdAt: z.string(),
8
+ })
9
+
10
+ export type {{singular.pascal}}Schema = z.infer<typeof {{singular.camel}}Schema>
11
+
12
+ /** O que se envia para criar ou editar: o `id` e a data são do repositório. */
13
+ export const {{singular.camel}}InputSchema = {{singular.camel}}Schema.pick({ name: true })
14
+
15
+ export type {{singular.pascal}}Input = z.infer<typeof {{singular.camel}}InputSchema>
16
+
17
+ export type {{singular.pascal}}SortKey = 'name' | 'createdAt'
18
+
19
+ export interface {{singular.pascal}}ListQuery extends PageQuery {
20
+ /** Busca pelo nome, sem diferenciar maiúsculas e acentos. */
21
+ search?: string
22
+ sort?: Sort<{{singular.pascal}}SortKey>
23
+ }
@@ -0,0 +1,11 @@
1
+ import { screen } from '@testing-library/react'
2
+ import { expect, it } from 'vitest'
3
+ import { renderWithProviders } from '@/test/render'
4
+ import {{page.pascal}}Page from '.'
5
+
6
+ it('mostra o título e, depois de carregar, a lista do domínio', async () => {
7
+ renderWithProviders(<{{page.pascal}}Page />, { path: '/{{page.kebab}}' })
8
+
9
+ expect(screen.getByRole('heading', { name: '{{page.title}}' })).toBeDefined()
10
+ expect(await screen.findByRole('list')).toBeDefined()
11
+ })
@@ -0,0 +1,10 @@
1
+ import { screen } from '@testing-library/react'
2
+ import { expect, it } from 'vitest'
3
+ import { renderWithProviders } from '@/test/render'
4
+ import {{page.pascal}}Page from '.'
5
+
6
+ it('mostra o título da tela', () => {
7
+ renderWithProviders(<{{page.pascal}}Page />, { path: '/{{page.kebab}}' })
8
+
9
+ expect(screen.getByRole('heading', { name: '{{page.title}}' })).toBeDefined()
10
+ })
@@ -0,0 +1,7 @@
1
+ import { use{{page.pascal}}Model } from './model'
2
+ import { {{page.pascal}}View } from './view'
3
+
4
+ export default function {{page.pascal}}Page() {
5
+ const model = use{{page.pascal}}Model()
6
+ return <{{page.pascal}}View {...model} />
7
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "title": "{{page.title}}",
3
+ "loading": "Loading…",
4
+ "failed": "Could not load the list."
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "title": "{{page.title}}",
3
+ "loading": "Carregando…",
4
+ "failed": "Não foi possível carregar a lista."
5
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "title": "{{page.title}}"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "title": "{{page.title}}"
3
+ }
@@ -0,0 +1,17 @@
1
+ import { useTranslations } from '@/i18n'
2
+ import { use{{domain.pascal}}List } from '@/queries/{{domain.kebab}}'
3
+
4
+ export function use{{page.pascal}}Model() {
5
+ const t = useTranslations('{{page.camel}}')
6
+ const list = use{{domain.pascal}}List()
7
+ return {
8
+ title: t('title'),
9
+ loadingText: t('loading'),
10
+ failedText: t('failed'),
11
+ items: list.data?.items ?? [],
12
+ loading: list.isPending,
13
+ failed: list.isError,
14
+ }
15
+ }
16
+
17
+ export type {{page.pascal}}Model = ReturnType<typeof use{{page.pascal}}Model>
@@ -0,0 +1,8 @@
1
+ import { useTranslations } from '@/i18n'
2
+
3
+ export function use{{page.pascal}}Model() {
4
+ const t = useTranslations('{{page.camel}}')
5
+ return { title: t('title') }
6
+ }
7
+
8
+ export type {{page.pascal}}Model = ReturnType<typeof use{{page.pascal}}Model>
@@ -0,0 +1,20 @@
1
+ import type { {{page.pascal}}Model } from './model'
2
+
3
+ export function {{page.pascal}}View(m: {{page.pascal}}Model) {
4
+ return (
5
+ <main>
6
+ <h1>{m.title}</h1>
7
+ {m.loading ? (
8
+ <p>{m.loadingText}</p>
9
+ ) : m.failed ? (
10
+ <p role="alert">{m.failedText}</p>
11
+ ) : (
12
+ <ul>
13
+ {m.items.map((i) => (
14
+ <li key={i.id}>{i.name}</li>
15
+ ))}
16
+ </ul>
17
+ )}
18
+ </main>
19
+ )
20
+ }
@@ -0,0 +1,9 @@
1
+ import type { {{page.pascal}}Model } from './model'
2
+
3
+ export function {{page.pascal}}View(m: {{page.pascal}}Model) {
4
+ return (
5
+ <main>
6
+ <h1>{m.title}</h1>
7
+ </main>
8
+ )
9
+ }