-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve create-react-component script
- support onlyNamedExport option - bumpup assert package - remove mock files and it was replaced by snapshotTest - split files
- Loading branch information
Showing
47 changed files
with
501 additions
and
303 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import * as path from "https://deno.land/std@0.126.0/path/mod.ts"; | ||
import * as fs from "https://deno.land/std@0.126.0/fs/mod.ts"; | ||
import * as path from "https://deno.land/std@0.138.0/path/mod.ts"; | ||
import * as fs from "https://deno.land/std@0.138.0/fs/mod.ts"; | ||
|
||
export async function copyFixtures(outPath: string): Promise<void> { | ||
const __dirname = path.dirname(path.fromFileUrl(import.meta.url)); | ||
const src = path.join(__dirname, "fixture2"); | ||
await fs.copy(src, outPath, {overwrite: true}); | ||
await fs.copy(src, outPath, { overwrite: true }); | ||
} |
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ import genUrichk from "./urichk.ts"; | |
import genFixture2 from "./fixture2.ts"; | ||
import genPbkit from "./pbkit.ts"; | ||
|
||
import { emptyDir } from "https://deno.land/std@0.126.0/fs/mod.ts"; | ||
import { emptyDir } from "https://deno.land/std@0.138.0/fs/mod.ts"; | ||
import { Command, EnumType } from "https://deno.land/x/[email protected]/mod.ts"; | ||
|
||
const defaultPollapoDir = ".pollapo"; | ||
|
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
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,6 +1,6 @@ | ||
import { GenOptions } from "./index.ts"; | ||
import { ensureDir } from "https://deno.land/std@0.126.0/fs/mod.ts"; | ||
import * as path from "https://deno.land/std@0.126.0/path/mod.ts"; | ||
import { ensureDir } from "https://deno.land/std@0.138.0/fs/mod.ts"; | ||
import * as path from "https://deno.land/std@0.138.0/path/mod.ts"; | ||
import { compile as compileNextjsNavigationHook } from "https://deno.land/x/[email protected]/compile/nextjs-navigation-hook.ts"; | ||
import { compile as compileNextjsSearchParamsHook } from "https://deno.land/x/[email protected]/compile/nextjs-search-params-hook.ts"; | ||
import { kebabToPascal } from "../misc/case.ts"; | ||
|
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,4 +1,4 @@ | ||
import * as path from "https://deno.land/std@0.126.0/path/mod.ts"; | ||
import * as path from "https://deno.land/std@0.138.0/path/mod.ts"; | ||
import { Schema } from "https://deno.land/x/[email protected]/schema.ts"; | ||
import { schema2ts } from "https://deno.land/x/[email protected]/codegen/ts.ts"; | ||
import { getReadFunction } from "https://deno.land/x/[email protected]/io/read-schema.ts"; | ||
|
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,5 +1,5 @@ | ||
import { walk } from "https://deno.land/std@0.126.0/fs/walk.ts"; | ||
import * as path from "https://deno.land/std@0.126.0/path/mod.ts"; | ||
import { walk } from "https://deno.land/std@0.138.0/fs/walk.ts"; | ||
import * as path from "https://deno.land/std@0.138.0/path/mod.ts"; | ||
import { parse } from "https://deno.land/x/[email protected]/index.ts"; | ||
import type { Urichk } from "https://deno.land/x/[email protected]/ast.ts"; | ||
|
||
|
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,5 +1,5 @@ | ||
import { stringify } from "https://deno.land/std@0.126.0/encoding/yaml.ts"; | ||
import { walk } from "https://deno.land/std@0.126.0/fs/walk.ts"; | ||
import { stringify } from "https://deno.land/std@0.138.0/encoding/yaml.ts"; | ||
import { walk } from "https://deno.land/std@0.138.0/fs/walk.ts"; | ||
import { Command } from "https://deno.land/x/[email protected]/command/mod.ts"; | ||
import * as ast from "https://deno.land/x/[email protected]/core/ast/index.ts"; | ||
import { parse } from "https://deno.land/x/[email protected]/core/parser/proto.ts"; | ||
|
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,4 +1,4 @@ | ||
import { serve } from "https://deno.land/std@0.126.0/http/server.ts"; | ||
import { serve } from "https://deno.land/std@0.138.0/http/server.ts"; | ||
import { Command } from "https://deno.land/x/[email protected]/command/mod.ts"; | ||
import openBrowser from "../misc/open-browser.ts"; | ||
|
||
|
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
4 changes: 4 additions & 0 deletions
4
www-snippet/create-react-component/CreateReactComponentOption.ts
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,4 @@ | ||
export interface CreateReactComponentOption { | ||
forwardRef?: boolean; | ||
onlyNamedExport?: boolean; | ||
} |
14 changes: 0 additions & 14 deletions
14
www-snippet/create-react-component/__mocks__/react-component/LoremIpsumWithRef_tsx
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
www-snippet/create-react-component/__mocks__/react-component/LoremIpsum_spec_tsx
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
www-snippet/create-react-component/__mocks__/react-component/LoremIpsum_stories_tsx
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
www-snippet/create-react-component/__mocks__/react-component/LoremIpsum_tsx
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
www-snippet/create-react-component/__mocks__/react-component/index_ts
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
www-snippet/create-react-component/__mocks__/readMockFile.test.ts
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
www-snippet/create-react-component/__mocks__/readMockFile.ts
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
www-snippet/create-react-component/__snapshots__/createReactComponentContent.test.ts.snap
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,61 @@ | ||
export const snapshot = {}; | ||
|
||
snapshot[`should return correct react component. 1`] = ` | ||
'import React, { memo, PropsWithChildren } from "react"; | ||
export interface LoremIpsumProps {} | ||
const LoremIpsum = (({}: PropsWithChildren<LoremIpsumProps>) => { | ||
return <>LoremIpsum</>; | ||
}); | ||
export default memo(LoremIpsum); | ||
' | ||
`; | ||
snapshot[`should return correct react component. 2`] = ` | ||
'import React, { forwardRef, memo } from "react"; | ||
type RefElement = HTMLDivElement; | ||
type RefElementProps = React.HTMLAttributes<HTMLDivElement>; | ||
export interface LoremIpsumProps extends RefElementProps {} | ||
const LoremIpsum = forwardRef<RefElement, LoremIpsumProps>((props, ref) => { | ||
return <div ref={ref} {...props}>Lorem Ipsum</div>; | ||
}); | ||
export default memo(LoremIpsum) | ||
LoremIpsum.displayName = "LoremIpsum"; | ||
' | ||
`; | ||
snapshot[`should return correct react component. 3`] = ` | ||
'import React, { memo, PropsWithChildren } from "react"; | ||
export interface LoremIpsumProps {} | ||
const LoremIpsum = (({}: PropsWithChildren<LoremIpsumProps>) => { | ||
return <>LoremIpsum</>; | ||
}); | ||
export { LoremIpsum: memo(LoremIpsum) }; | ||
' | ||
`; | ||
snapshot[`should return correct react component. 4`] = ` | ||
'import React, { forwardRef, memo } from "react"; | ||
type RefElement = HTMLDivElement; | ||
type RefElementProps = React.HTMLAttributes<HTMLDivElement>; | ||
export interface LoremIpsumProps extends RefElementProps {} | ||
const LoremIpsum = forwardRef<RefElement, LoremIpsumProps>((props, ref) => { | ||
return <div ref={ref} {...props}>Lorem Ipsum</div>; | ||
}); | ||
export { LoremIpsum: memo(LoremIpsum) } | ||
LoremIpsum.displayName = "LoremIpsum"; | ||
' | ||
`; |
12 changes: 12 additions & 0 deletions
12
...pet/create-react-component/__snapshots__/createReactComponentReExportContent.test.ts.snap
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,12 @@ | ||
export const snapshot = {}; | ||
|
||
snapshot[`should return correct react component re-export. 1`] = ` | ||
'export { default } from "./LoremIpsum"; | ||
export * from "./LoremIpsum"; | ||
' | ||
`; | ||
|
||
snapshot[`should return correct react component re-export. 2`] = ` | ||
'export * from "./LoremIpsum"; | ||
' | ||
`; |
Oops, something went wrong.