march-hare 0.13.0 → 0.13.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 (129) hide show
  1. package/README.md +25 -1
  2. package/dist/action/index.d.ts +2 -2
  3. package/dist/action/utils.d.ts +2 -2
  4. package/dist/actions/index.d.ts +2 -2
  5. package/dist/actions/types.d.ts +3 -3
  6. package/dist/actions/utils.d.ts +3 -3
  7. package/dist/app/index.d.ts +7 -7
  8. package/dist/app/types.d.ts +5 -5
  9. package/dist/boundary/components/broadcast/index.d.ts +2 -2
  10. package/dist/boundary/components/broadcast/types.d.ts +1 -1
  11. package/dist/boundary/components/consumer/components/partition/index.d.ts +1 -1
  12. package/dist/boundary/components/consumer/components/partition/types.d.ts +1 -1
  13. package/dist/boundary/components/consumer/index.d.ts +5 -5
  14. package/dist/boundary/components/consumer/types.d.ts +1 -1
  15. package/dist/boundary/components/consumer/utils.d.ts +1 -1
  16. package/dist/boundary/components/env/index.d.ts +3 -27
  17. package/dist/boundary/components/env/types.d.ts +24 -2
  18. package/dist/boundary/components/env/utils.d.ts +1 -1
  19. package/dist/boundary/components/scope/index.d.ts +2 -2
  20. package/dist/boundary/components/scope/types.d.ts +1 -1
  21. package/dist/boundary/components/scope/utils.d.ts +1 -1
  22. package/dist/boundary/components/sharing/index.d.ts +1 -1
  23. package/dist/boundary/components/tap/index.d.ts +3 -3
  24. package/dist/boundary/components/tap/types.d.ts +2 -2
  25. package/dist/boundary/components/tap/utils.d.ts +1 -1
  26. package/dist/boundary/components/tasks/index.d.ts +2 -2
  27. package/dist/boundary/components/tasks/utils.d.ts +1 -1
  28. package/dist/boundary/index.d.ts +1 -1
  29. package/dist/boundary/types.d.ts +2 -2
  30. package/dist/cache/index.d.ts +2 -2
  31. package/dist/cache/types.d.ts +1 -1
  32. package/dist/cli/bin/mh.js +10 -0
  33. package/dist/cli/lib/banner/index.js +14 -0
  34. package/dist/cli/lib/commands/app/index.js +37 -0
  35. package/dist/cli/lib/commands/feature/index.js +55 -0
  36. package/dist/cli/lib/commands/index.js +89 -0
  37. package/dist/cli/lib/commands/init/index.js +29 -0
  38. package/dist/cli/lib/commands/shared/index.js +56 -0
  39. package/dist/cli/lib/index.js +56 -0
  40. package/dist/cli/lib/parser/index.js +24 -0
  41. package/dist/cli/lib/prompt/index.js +61 -0
  42. package/dist/cli/lib/runner/index.js +46 -0
  43. package/dist/cli/lib/runner/types.js +1 -0
  44. package/dist/cli/lib/runner/utils.js +60 -0
  45. package/dist/cli/lib/types.js +1 -0
  46. package/dist/cli/lib/utils.js +20 -0
  47. package/dist/cli/templates/app/action/actions.ts.ejs.t +10 -0
  48. package/dist/cli/templates/app/action/types.ts.ejs.t +7 -0
  49. package/dist/cli/templates/app/integration/index.integration.tsx.ejs.t +13 -0
  50. package/dist/cli/templates/app/page/actions.ts.ejs.t +14 -0
  51. package/dist/cli/templates/app/page/index.tsx.ejs.t +20 -0
  52. package/dist/cli/templates/app/page/styles.ts.ejs.t +35 -0
  53. package/dist/cli/templates/app/page/types.ts.ejs.t +12 -0
  54. package/dist/cli/templates/feature/action/actions.ts.ejs.t +10 -0
  55. package/dist/cli/templates/feature/action/types.ts.ejs.t +7 -0
  56. package/dist/cli/templates/feature/multicast/types.ts.ejs.t +7 -0
  57. package/dist/cli/templates/feature/presentational/index.tsx.ejs.t +14 -0
  58. package/dist/cli/templates/feature/presentational/types.ts.ejs.t +12 -0
  59. package/dist/cli/templates/feature/presentational/utils.ts.ejs.t +8 -0
  60. package/dist/cli/templates/feature/stateful/actions.ts.ejs.t +16 -0
  61. package/dist/cli/templates/feature/stateful/index.tsx.ejs.t +19 -0
  62. package/dist/cli/templates/feature/stateful/types.ts.ejs.t +16 -0
  63. package/dist/cli/templates/feature/stateful/utils.ts.ejs.t +8 -0
  64. package/dist/cli/templates/feature/unit/index.test.tsx.ejs.t +21 -0
  65. package/dist/cli/templates/init/new/README.md.ejs.t +48 -0
  66. package/dist/cli/templates/init/new/eslint.config.js.ejs.t +88 -0
  67. package/dist/cli/templates/init/new/gitignore.ejs.t +9 -0
  68. package/dist/cli/templates/init/new/index.html.ejs.t +18 -0
  69. package/dist/cli/templates/init/new/package.json.ejs.t +54 -0
  70. package/dist/cli/templates/init/new/playwright.config.ts.ejs.t +17 -0
  71. package/dist/cli/templates/init/new/prettierrc.ejs.t +8 -0
  72. package/dist/cli/templates/init/new/src.app.index.tsx.ejs.t +14 -0
  73. package/dist/cli/templates/init/new/src.app.pages.home.actions.ts.ejs.t +16 -0
  74. package/dist/cli/templates/init/new/src.app.pages.home.index.tsx.ejs.t +30 -0
  75. package/dist/cli/templates/init/new/src.app.pages.home.integration.tsx.ejs.t +28 -0
  76. package/dist/cli/templates/init/new/src.app.pages.home.styles.ts.ejs.t +45 -0
  77. package/dist/cli/templates/init/new/src.app.pages.home.types.ts.ejs.t +12 -0
  78. package/dist/cli/templates/init/new/src.app.utils.ts.ejs.t +9 -0
  79. package/dist/cli/templates/init/new/src.features.greet.actions.ts.ejs.t +20 -0
  80. package/dist/cli/templates/init/new/src.features.greet.index.test.tsx.ejs.t +21 -0
  81. package/dist/cli/templates/init/new/src.features.greet.index.tsx.ejs.t +24 -0
  82. package/dist/cli/templates/init/new/src.features.greet.types.ts.ejs.t +18 -0
  83. package/dist/cli/templates/init/new/src.features.greet.utils.ts.ejs.t +8 -0
  84. package/dist/cli/templates/init/new/src.index.tsx.ejs.t +8 -0
  85. package/dist/cli/templates/init/new/src.shared.components.button.index.test.tsx.ejs.t +13 -0
  86. package/dist/cli/templates/init/new/src.shared.components.button.index.tsx.ejs.t +10 -0
  87. package/dist/cli/templates/init/new/src.shared.components.button.types.ts.ejs.t +6 -0
  88. package/dist/cli/templates/init/new/src.shared.resources.index.ts.ejs.t +4 -0
  89. package/dist/cli/templates/init/new/src.shared.theme.index.ts.ejs.t +51 -0
  90. package/dist/cli/templates/init/new/src.shared.types.index.ts.ejs.t +23 -0
  91. package/dist/cli/templates/init/new/src.test-setup.ts.ejs.t +10 -0
  92. package/dist/cli/templates/init/new/src.vite-env.d.ts.ejs.t +4 -0
  93. package/dist/cli/templates/init/new/tests.home.e2e.ts.ejs.t +14 -0
  94. package/dist/cli/templates/init/new/tsconfig.json.ejs.t +29 -0
  95. package/dist/cli/templates/init/new/vite.config.ts.ejs.t +17 -0
  96. package/dist/cli/templates/init/new/vitest.config.ts.ejs.t +24 -0
  97. package/dist/cli/templates/shared/component/index.tsx.ejs.t +9 -0
  98. package/dist/cli/templates/shared/component/types.ts.ejs.t +8 -0
  99. package/dist/cli/templates/shared/resource/index.ts.ejs.t +15 -0
  100. package/dist/cli/templates/shared/resource/types.ts.ejs.t +10 -0
  101. package/dist/cli/templates/shared/type-broadcast/types.ts.ejs.t +7 -0
  102. package/dist/cli/templates/shared/type-payload/types.ts.ejs.t +9 -0
  103. package/dist/cli/templates/shared/unit-component/index.test.tsx.ejs.t +13 -0
  104. package/dist/cli/templates/shared/unit-resource/index.test.ts.ejs.t +15 -0
  105. package/dist/cli/templates/shared/unit-util/index.test.ts.ejs.t +11 -0
  106. package/dist/cli/templates/shared/util/index.ts.ejs.t +6 -0
  107. package/dist/coalesce/index.d.ts +1 -1
  108. package/dist/context/index.d.ts +1 -1
  109. package/dist/error/types.d.ts +1 -1
  110. package/dist/error/utils.d.ts +1 -1
  111. package/dist/index.d.ts +16 -16
  112. package/dist/march-hare.js.map +1 -1
  113. package/dist/march-hare.umd.cjs.map +1 -1
  114. package/dist/resource/index.d.ts +4 -4
  115. package/dist/resource/types.d.ts +3 -3
  116. package/dist/resource/utils.d.ts +4 -4
  117. package/dist/scope/index.d.ts +3 -3
  118. package/dist/scope/types.d.ts +2 -2
  119. package/dist/scope/utils.d.ts +2 -2
  120. package/dist/shared/index.d.ts +4 -4
  121. package/dist/types/index.d.ts +5 -5
  122. package/dist/utils/index.d.ts +3 -3
  123. package/dist/utils/types.d.ts +1 -1
  124. package/dist/utils/utils.d.ts +1 -1
  125. package/dist/with/index.d.ts +3 -3
  126. package/dist/with/types.d.ts +2 -2
  127. package/dist/with/utils.d.ts +3 -3
  128. package/package.json +18 -4
  129. package/src/cli/README.md +314 -0
@@ -0,0 +1,24 @@
1
+ ---
2
+ to: vitest.config.ts
3
+ ---
4
+ import { resolve } from "node:path";
5
+ import { defineConfig } from "vitest/config";
6
+ import react from "@vitejs/plugin-react";
7
+
8
+ export default defineConfig({
9
+ plugins: [react()],
10
+ resolve: {
11
+ alias: {
12
+ "@app": resolve(__dirname, "src/app"),
13
+ "@features": resolve(__dirname, "src/features"),
14
+ "@shared": resolve(__dirname, "src/shared"),
15
+ },
16
+ },
17
+ test: {
18
+ environment: "happy-dom",
19
+ include: ["src/**/*.test.{ts,tsx}", "src/**/*.integration.{ts,tsx}"],
20
+ setupFiles: ["./src/test-setup.ts"],
21
+ clearMocks: true,
22
+ restoreMocks: true,
23
+ },
24
+ });
@@ -0,0 +1,9 @@
1
+ ---
2
+ to: src/shared/components/<%= name %>/index.tsx
3
+ ---
4
+ import * as React from "react";
5
+ import type { Props } from "./types.ts";
6
+
7
+ export function <%= pascalName %>({ children, ...rest }: Props): React.ReactElement {
8
+ return <div {...rest}>{children}</div>;
9
+ }
@@ -0,0 +1,8 @@
1
+ ---
2
+ to: src/shared/components/<%= name %>/types.ts
3
+ ---
4
+ import type { HTMLAttributes, ReactNode } from "react";
5
+
6
+ export type Props = HTMLAttributes<HTMLDivElement> & {
7
+ children?: ReactNode;
8
+ };
@@ -0,0 +1,15 @@
1
+ ---
2
+ to: src/shared/resources/<%= name %>/index.ts
3
+ ---
4
+ import { shared } from "march-hare";
5
+ import ky from "ky";
6
+ import { type Envs } from "@shared/types/index.ts";
7
+ import { <%= pascalName %> } from "./types.ts";
8
+
9
+ export const fetch = shared.Resource<Envs, <%= pascalName %>.Response>((context) =>
10
+ ky
11
+ .get(`${context.env.apiBase}/<%= name %>`, {
12
+ signal: context.controller.signal,
13
+ })
14
+ .json<<%= pascalName %>.Response>(),
15
+ );
@@ -0,0 +1,10 @@
1
+ ---
2
+ to: src/shared/resources/<%= name %>/types.ts
3
+ ---
4
+ export namespace <%= pascalName %> {
5
+ export type Item = {
6
+ id: string;
7
+ };
8
+
9
+ export type Response = Item[];
10
+ }
@@ -0,0 +1,7 @@
1
+ ---
2
+ to: src/shared/types/index.ts
3
+ inject: true
4
+ after: ^export namespace Broadcast \{$
5
+ skip_if: <%= pascalName %>
6
+ ---
7
+ export const <%= pascalName %> = Action<unknown>("<%= pascalName %>", Distribution.Broadcast);
@@ -0,0 +1,9 @@
1
+ ---
2
+ to: src/shared/types/index.ts
3
+ inject: true
4
+ after: ^export namespace Payload \{$
5
+ skip_if: <%= pascalName %>
6
+ ---
7
+ export type <%= pascalName %> = {
8
+ id: string;
9
+ };
@@ -0,0 +1,13 @@
1
+ ---
2
+ to: src/shared/components/<%= name %>/index.test.tsx
3
+ ---
4
+ import { describe, expect, it } from "vitest";
5
+ import { render } from "@testing-library/react";
6
+ import { <%= pascalName %> } from "./index.tsx";
7
+
8
+ describe("<%= pascalName %>", () => {
9
+ it("renders without crashing", () => {
10
+ render(<<%= pascalName %> />);
11
+ expect(document.body).toBeInTheDocument();
12
+ });
13
+ });
@@ -0,0 +1,15 @@
1
+ ---
2
+ to: src/shared/resources/<%= name %>/index.test.ts
3
+ ---
4
+ import { describe, expect, it } from "vitest";
5
+ import { fetch } from "./index.ts";
6
+
7
+ describe("resource.<%= name %>", () => {
8
+ it("exposes a fetcher handle", () => {
9
+ expect(typeof fetch).toBe("function");
10
+ });
11
+
12
+ it("returns null on the first sync call (cache miss)", () => {
13
+ expect(fetch.get()).toBeNull();
14
+ });
15
+ });
@@ -0,0 +1,11 @@
1
+ ---
2
+ to: src/shared/utils/<%= name %>/index.test.ts
3
+ ---
4
+ import { describe, expect, it } from "vitest";
5
+ import { <%= camel(name) %> } from "./index.ts";
6
+
7
+ describe("<%= camel(name) %>", () => {
8
+ it("returns a string", () => {
9
+ expect(typeof <%= camel(name) %>("hello")).toBe("string");
10
+ });
11
+ });
@@ -0,0 +1,6 @@
1
+ ---
2
+ to: src/shared/utils/<%= name %>/index.ts
3
+ ---
4
+ export function <%= camel(name) %>(input: string): string {
5
+ return input.trim();
6
+ }
@@ -1,4 +1,4 @@
1
- import { Coalesce } from '../resource/types';
1
+ import { Coalesce } from '../resource/types.js';
2
2
  /**
3
3
  * Sentinel token used when `.coalesce()` is called with no explicit
4
4
  * argument. Every untokened caller for the same `(Resource, params)`
@@ -1,4 +1,4 @@
1
- import { Actions, Context as ContextHandle, Model, Props } from '../types/index';
1
+ import { Actions, Context as ContextHandle, Model, Props } from '../types/index.js';
2
2
  /**
3
3
  * Returns a stable, typed controller handle up-front &mdash; before a
4
4
  * model is declared via `context.useActions(...)`. Use this when an
@@ -1,4 +1,4 @@
1
- import { Task } from '../boundary/components/tasks/types';
1
+ import { Task } from '../boundary/components/tasks/types.js';
2
2
  /**
3
3
  * Reasons why an action error occurred.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { Reason } from './types';
1
+ import { Reason } from './types.js';
2
2
  /**
3
3
  * Determines the error reason based on what was thrown.
4
4
  *
package/dist/index.d.ts CHANGED
@@ -1,18 +1,18 @@
1
- export { App } from './app/index';
2
- export type { AppHandle } from './app/index';
3
- export { Action } from './action/index';
4
- export { Distribution, Lifecycle } from './types/index';
5
- export { With } from './with/index';
6
- export { Boundary } from './boundary/index';
7
- export { Cache } from './cache/index';
8
- export { Reason, Aborted } from './error/index';
9
- export { annotate } from './annotate/index';
1
+ export { App } from './app/index.js';
2
+ export type { AppHandle } from './app/index.js';
3
+ export { Action } from './action/index.js';
4
+ export { Distribution, Lifecycle } from './types/index.js';
5
+ export { With } from './with/index.js';
6
+ export { Boundary } from './boundary/index.js';
7
+ export { Cache } from './cache/index.js';
8
+ export { Reason, Aborted } from './error/index.js';
9
+ export { annotate } from './annotate/index.js';
10
10
  export { Operation, Op, State } from 'immertation';
11
- export * as utils from './utils/index';
12
- export * as shared from './shared/index';
13
- export type { Fault } from './error/index';
14
- export type { Adapter } from './cache/index';
11
+ export * as utils from './utils/index.js';
12
+ export * as shared from './shared/index.js';
13
+ export type { Fault } from './error/index.js';
14
+ export type { Adapter } from './cache/index.js';
15
15
  export type { Box } from 'immertation';
16
- export type { Pk, Maybe, Handler, Handlers } from './types/index';
17
- export type { Envless } from './boundary/components/env/index';
18
- export type { Tap, Taps } from './boundary/components/tap/types';
16
+ export type { Pk, Maybe, Handler, Handlers } from './types/index.js';
17
+ export type { Envless } from './boundary/components/env/types.js';
18
+ export type { Tap, Taps } from './boundary/components/tap/types.js';