Skip to content

Commit

Permalink
presenter 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
woohm402 committed Jun 24, 2024
1 parent f5ef463 commit 6488025
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export default [
{
ignores: ['esbuild.js', 'out', 'dist', 'node_modules', '.vscode-test'],
},
...config,
...config(),
];
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@vscode/test-cli": "0.0.9",
"@vscode/test-electron": "2.4.0",
"@vscode/vsce": "2.27.0",
"@woohm402/eslint-config-base": "0.1.0",
"@woohm402/eslint-config-base": "0.2.5",
"esbuild": "0.21.4",
"eslint": "9.4.0",
"npm-run-all": "4.1.5",
Expand Down
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from 'fs';
import * as path from 'path';
import * as vscode from 'vscode';

import { componentTemplate, cssTemplate } from './templates';
import { componentTemplate, cssTemplate, presenterTemplate } from './templates';

export function activate(context: vscode.ExtensionContext) {
const disposable = vscode.commands.registerCommand('createComponent', async (uri) => {
Expand All @@ -25,11 +25,13 @@ export function activate(context: vscode.ExtensionContext) {

fs.writeFileSync(path.join(componentPath, 'index.tsx'), componentTemplate(componentName));
fs.writeFileSync(path.join(componentPath, 'index.module.css'), cssTemplate());
fs.writeFileSync(path.join(componentPath, 'index.presenter.ts'), presenterTemplate(componentName));

vscode.window.showInformationMessage(`Component Created!`);
} else {
vscode.window.showInformationMessage(`Component already Exist`);
}
return undefined;
}
});

Expand Down
30 changes: 27 additions & 3 deletions src/templates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,41 @@ export const cssTemplate = () => `.wrapper {
}
`;

export const componentTemplate = (componentName: string) => `import styles from './index.module.css';
export const componentTemplate = (
componentName: string,
) => `import { ${getPresenterName(componentName)} } from './index.presenter.ts';
export const ${componentName} = ({
import styles from './index.module.css';
export const ${componentName} = ({
props,
}: {
props: Parameters<typeof ${getPresenterName(componentName)}.useViewModel>[0];
}) => {
const viewModel = ${getPresenterName(componentName)}.useViewModel({});
return (
<div className={styles.wrapper}>
</div>
);
};
`;

export const presenterTemplate = (componentName: string) => `type Props = {
};
type ViewModel = {
};
export const ${getPresenterName(componentName)} = {
useViewModel: (props: Props): ViewModel => {
},
}
`;

const getPresenterName = (componentName: string) =>
componentName.slice(0, 1).toLowerCase() + componentName.slice(1) + 'Presenter';
39 changes: 7 additions & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,10 @@
optionalDependencies:
keytar "^7.7.0"

"@woohm402/eslint-config-base@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@woohm402/eslint-config-base/-/eslint-config-base-0.1.0.tgz#c7733a46b5021e35f684f663c8759b83fa038b08"
integrity sha512-U48REf7SPQdK8I/ofZaTyG2jjwR+wEnb9wLvUamDKIlHvTmHS1zD/8GdbifFiBBcRDiOpJlSx4BiAm2+Dem/7g==
"@woohm402/eslint-config-base@0.2.5":
version "0.2.5"
resolved "https://registry.yarnpkg.com/@woohm402/eslint-config-base/-/eslint-config-base-0.2.5.tgz#b82fbd29f28eeeaf2576c6eec248d63cba9d9729"
integrity sha512-U9AMSsAMVi9sbLNaDFo/zY1p8GOjwbh0bSpVysW32RZ5mygXT0spq2wJqMyIMIMOVukeWkEy9axLEm0avsBFNQ==
dependencies:
"@eslint-community/eslint-plugin-eslint-comments" "4.3.0"
eslint-config-prettier "9.1.0"
Expand Down Expand Up @@ -3125,16 +3125,7 @@ stoppable@^1.1.0:
resolved "https://registry.yarnpkg.com/stoppable/-/stoppable-1.1.0.tgz#32da568e83ea488b08e4d7ea2c3bcc9d75015d5b"
integrity sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -3213,14 +3204,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -3546,16 +3530,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343"
integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down

0 comments on commit 6488025

Please sign in to comment.