Skip to content

Commit 9e4e145

Browse files
committed
🐼 fix bugs
1 parent d1dc52e commit 9e4e145

17 files changed

Lines changed: 89 additions & 36 deletions

bin/combine/components/combine-components.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { fs } = require("file-system");
1+
const fs = require("file-system");
22

33
/**
44
* @function combineComponents

bin/combine/pages/combine-pages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { fs } = require("file-system");
1+
const fs = require("file-system");
22

33
/**
44
* @function combinePages

bin/create/component/functions/create-component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { fs } = require("file-system");
1+
const fs = require("file-system");
22
const { componentTemplateJs, componentTemplateTs } = require("../templates");
33

44
/**
@@ -22,6 +22,7 @@ exports.createComponent = (componentName, js, ts, folder) => {
2222
} else {
2323
fs.writeFile(path, componentTemplateTs(componentName), (err) => {
2424
if (err) {
25+
console.log(err);
2526
console.log(`Unable to create ${componentName} component`);
2627
} else {
2728
console.log(`${path} created`);

bin/create/component/templates/component-template-js.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* @author [Omar Belghaouti](https://github.com/Omar-Belghaouti)
88
*/
99
exports.componentTemplateJs = (componentName) => {
10-
let component = componentName;
11-
component[0] = component[0].toUpperCase();
10+
let component =
11+
componentName.charAt(0).toUpperCase() + componentName.slice(1);
1212
return `// export ${component} component
1313
const ${component} = () => {
1414
return <div>${component} component created!</div>;

bin/create/component/templates/component-template-ts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* @author [Omar Belghaouti](https://github.com/Omar-Belghaouti)
88
*/
99
exports.componentTemplateTs = (componentName) => {
10-
let component = componentName;
11-
component[0] = component[0].toUpperCase();
10+
let component =
11+
componentName.charAt(0).toUpperCase() + componentName.slice(1);
1212
return `import { FC } from "react";
1313
1414
// define ${component} props interface

bin/create/page/functions/create-page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { fs } = require("file-system");
1+
const fs = require("file-system");
22
const {
33
pageTemplateJs,
44
pageTemplateTs,

bin/create/page/templates/page-function-template-js.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* @author [Omar Belghaouti](https://github.com/Omar-Belghaouti)
88
*/
99
exports.pageFunctionTemplateJs = (pageName) => {
10-
let page = pageName;
11-
page[0] = page[0].toUpperCase();
12-
return `// write your ${page} functions here
13-
export {};
14-
`;
10+
let page = pageName.charAt(0).toUpperCase() + pageName.slice(1);
11+
return `// write your ${page} functions here`;
1512
};

bin/create/page/templates/page-function-template-ts.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @author [Omar Belghaouti](https://github.com/Omar-Belghaouti)
88
*/
99
exports.pageFunctionTemplateTs = (pageName) => {
10-
let page = pageName;
11-
page[0] = page[0].toUpperCase();
12-
return `// write your ${page} functions here`;
10+
let page = pageName.charAt(0).toUpperCase() + pageName.slice(1);
11+
return `// write your ${page} functions here
12+
export {};`;
1313
};

bin/create/page/templates/page-template-js.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
* @returns {string} the page template in javascript.
66
* @author [Omar Belghaouti](https://github.com/Omar-Belghaouti)
77
*/
8-
exports.pageTemplateJs = (pageName) => `
9-
${pageName}
8+
exports.pageTemplateJs = (pageName) => {
9+
let page = pageName.charAt(0).toUpperCase() + pageName.slice(1);
10+
return `// export ${page} page
11+
const ${page} = () => {
12+
return <div>${page} page created!</div>;
13+
}
14+
export default ${page};
1015
`;
16+
};

bin/create/page/templates/page-template-ts.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
* @returns {string} the page template in typescript.
66
* @author [Omar Belghaouti](https://github.com/Omar-Belghaouti)
77
*/
8-
exports.pageTemplateTs = (pageName) => `
9-
${pageName}
8+
exports.pageTemplateTs = (pageName) => {
9+
let page = pageName.charAt(0).toUpperCase() + pageName.slice(1);
10+
return `import { FC } from "react";
11+
12+
// define ${page} props interface
13+
interface ${page}Props {}
14+
15+
// export ${page} page
16+
const ${page}: FC<${page}Props> = ({}: ${page}Props): JSX.Element => {
17+
return <div>${page} page created!</div>;
18+
}
19+
export default ${page};
1020
`;
21+
};

0 commit comments

Comments
 (0)