-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from magicspon/dev
Dev
- Loading branch information
Showing
57 changed files
with
4,789 additions
and
3,333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
--- | ||
to: "<%= storybook ? `${path}/${h.changeCase.pascalCase(name)}/${h.changeCase.pascalCase(name)}.stories.tsx` : null %>" | ||
--- | ||
import * as React from 'react' | ||
import { Meta } from '@storybook/react' | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { <%= h.changeCase.pascalCase(name) %> } from '.' | ||
|
||
export default { | ||
const meta = { | ||
title: 'Example/<%= h.changeCase.pascalCase(name) %>', | ||
component: <%= h.changeCase.pascalCase(name) %>, | ||
title: 'core/<%= h.changeCase.pascalCase(name) %>', | ||
} as Meta<typeof <%= h.changeCase.pascalCase(name) %>> | ||
parameters: { | ||
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout | ||
layout: 'centered', | ||
}, | ||
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs | ||
tags: ['autodocs'], | ||
// More on argTypes: https://storybook.js.org/docs/api/argtypes | ||
argTypes: {}, | ||
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args | ||
args: {}, | ||
} satisfies Meta<typeof <%= h.changeCase.pascalCase(name) %>> | ||
|
||
type Args = React.ComponentProps<typeof <%= h.changeCase.pascalCase(name) %>> | ||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Baic = { | ||
render: (args: Args) => { | ||
return <<%= h.changeCase.pascalCase(name) %> {...args} /> | ||
}, | ||
|
||
args: {} satisfies Args, | ||
} | ||
export const Primary: Story = { | ||
args: { | ||
<% if(variants){ -%> | ||
variant: "default" | ||
<% } -%> | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
to: <%= path %>/<%= name %>.ts | ||
--- | ||
|
||
type T<%= name %>Args = { | ||
// | ||
} | ||
|
||
export function <%= name %>(args: T<%= name %>Args) { | ||
|
||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const { getDirectories } = require('../../utils') | ||
|
||
module.exports = { | ||
prompt: async ({ prompter }) => { | ||
const { name } = await prompter.prompt({ | ||
type: 'input', | ||
name: 'name', | ||
message: 'Enter the function name:', | ||
}) | ||
|
||
const { directory } = await prompter.prompt({ | ||
type: 'select', | ||
name: 'directory', | ||
message: 'Directory:', | ||
choices: ['apps', 'packages'], | ||
}) | ||
|
||
const { package } = await prompter.prompt({ | ||
type: 'select', | ||
name: 'package', | ||
message: 'Package', | ||
choices: getDirectories(directory), | ||
}) | ||
|
||
const { tests } = await prompter.prompt({ | ||
type: 'confirm', | ||
name: 'tests', | ||
message: 'Do you want to include tests:', | ||
}) | ||
|
||
const basePath = `${directory}/${package}` | ||
console.log({ directory, basePath }) | ||
const path = | ||
directory === 'apps' ? `${basePath}/app/utils` : `${basePath}/src/utils` | ||
|
||
return { | ||
path, | ||
tests, | ||
name, | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
to: "<%= tests ? `${path}/${name}.spec.tsx` : null %>" | ||
--- | ||
import { expect, it, describe, vi } from 'vitest' | ||
import * as Fn from './<%= name %>' | ||
|
||
describe('<%= name %>', async () => { | ||
it('should be invoked', async () => { | ||
const getLegsSpy = vi.spyOn(Fn, '<%= name %>') | ||
Fn.<%= name %>({}) | ||
expect(getLegsSpy).toHaveBeenCalled() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
--- | ||
to: "<%= tests ? `${path}/hooks/use${h.changeCase.pascalCase(name)}/use${h.changeCase.pascalCase(name)}.spec.tsx` : null %>" | ||
--- | ||
import { renderHook, act } from '@testing-library/react-hooks' | ||
import { use<%= h.changeCase.pascalCase(name) %>, T<%= h.changeCase.pascalCase(name) %>Props } from '..'; | ||
import { expect, it, describe } from 'vitest' | ||
import { renderHook } from '@testing-library/react-hooks' | ||
import { use<%= h.changeCase.pascalCase(name) %> } from '.'; | ||
|
||
const defaultProps: T<%= h.changeCase.pascalCase(name) %>Props = { | ||
initialIndex: 0 | ||
}; | ||
|
||
describe('<%= h.changeCase.pascalCase(name) %>', () => { | ||
describe('use<%= h.changeCase.pascalCase(name) %>', () => { | ||
it('renders', () => { | ||
const { result } = renderHook(() => use<%= h.changeCase.pascalCase(name) %>(defaultProps)) | ||
|
||
act(() => { | ||
result.current.increment() | ||
}) | ||
const { result } = renderHook(() => use<%= h.changeCase.pascalCase(name) %>({})) | ||
|
||
expect(result.current.count).toBe(1) | ||
expect(result).toBeDefined() | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.