{
    "componentChunkName": "component---src-pages-blog-index-tsx",
    "path": "/blog/",
    "result": {"data":{"posts":{"nodes":[{"tags":{"nodes":[{"name":"checkout"},{"name":"clone"},{"name":"commit"},{"name":"flow"},{"name":"fork"},{"name":"git"},{"name":"git flow"},{"name":"merge"},{"name":"pull"},{"name":"push"},{"name":"rebase"}]},"slug":"git-flow","content":"\n<p>Having a git flow is a great idea for each developer who does not want to face with too much of conflicts. So read this post if you need a practical and useful git flow.</p>\n\n\n\n<h2 class=\"wp-block-heading\">Forking</h2>\n\n\n\n<p>If you&#8217;ve been forked a repository from another repository, it&#8217;s recommended to run the following commands after cloning your forked repository:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-git\" data-lang=\"Git\"><code>git remote add upstream [base repository address]\n\ngit fetch upstream</code></pre></div>\n\n\n\n<h2 class=\"wp-block-heading\">Common Git Flow</h2>\n\n\n\n<p>This section is a common git flow for those repositories which is forked from another repository, and those which is not. So it doesn&#8217;t matter which one do you use. It&#8217;s recommended to follow the following git flow to decrease the potential risks.</p>\n\n\n\n<h3 class=\"wp-block-heading\">Create new local branch</h3>\n\n\n\n<p>I recommend you to create a local branch for yourself and always coding in that branch:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-git\" data-lang=\"Git\"><code># create a new local branch with your custom name, for example &quot;working&quot;&#39;\ngit checkout -b working</code></pre></div>\n\n\n\n<h3 class=\"wp-block-heading\">Committing</h3>\n\n\n\n<p>When you need to commit your changes, you need to do the following commands in your local branch:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-git\" data-lang=\"Git\"><code># if you have new files or folders\ngit add .\n\n# if you are working on specific issue, it&#39;s better to mention your issue number in your comment with a hashtag before --&gt; for example [#1]\ngit commit -am &#39;your-comment&#39;</code></pre></div>\n\n\n\n<h3 class=\"wp-block-heading\">Merge &amp; Rebase</h3>\n\n\n\n<p>If you reach a stable version and you need to merge your changes with the parent branch, follow the following flow:</p>\n\n\n\n<ol><li>Checkout to your parent branch:</li></ol>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-git\" data-lang=\"Git\"><code># if your parent branch is master\ngit checkout master</code></pre></div>\n\n\n\n<ol start=\"2\"><li>Pull the latest changes:</li></ol>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-git\" data-lang=\"Git\"><code># if you are working on a forked repository. Get the latest changes from parent repository\n# if your main branch of your parent repository is master\ngit pull upstream master\n\n# then\ngit pull</code></pre></div>\n\n\n\n<ol start=\"3\"><li>Rebase your local branch:</li></ol>\n\n\n\n<p>a. After finishing the <strong>second step</strong>, if there was updates caused by your pulling, you should get back to your local branch and rebase it from its parent, if not, you can skip the third step:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-git\" data-lang=\"Git\"><code>git checkout working\n\ngit rebase master</code></pre></div>\n\n\n\n<p>b. After using rebase command, <strong>if</strong> you face with conflict(s), first of all you should resolve the conflicts and then do the following commands and repeat it again until you not facing with conflict(s) anymore:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-git\" data-lang=\"Git\"><code>git add .\n\ngit rebase --continue</code></pre></div>\n\n\n\n<p>c. Getting back to your parent branch:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-git\" data-lang=\"Git\"><code>git checkout master</code></pre></div>\n\n\n\n<ol start=\"4\"><li>Merge &amp; Push: Now you can merge your parent ( master ) branch with your local one and then push it to your <a href=\"/blog/category/git\">git</a> repository with following commands:</li></ol>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-git\" data-lang=\"Git\"><code>git merge working\n\ngit push</code></pre></div>\n\n\n\n<h2 class=\"wp-block-heading\">Create a merge request</h2>\n\n\n\n<p>If you use forking, after following the above flow in your forked repository, you should create a merge request in your repository panel, from your forked repository to the main one and wait for reviewer to review it and merge it if it was OK.</p>\n\n\n\n<h2 class=\"wp-block-heading\">Git Flow Recommendation</h2>\n\n\n\n<p>Totally, it&#8217;s good to have a specific git flow for your development team and ask them to follow it. It will help your team to avoid facing with risky situations in pulling and pushing the codes.<br>Hope it being useful.<br>Don&#8217;t forget to share your comments with me.<br>Thanks.</p>\n","title":"Git flow for a forked repository, a practical solution","featuredImage":{"node":{"srcSet":"https://hramini-back.ir/wp-content/uploads/2021/05/Feature-image-300x158.jpg 300w, https://hramini-back.ir/wp-content/uploads/2021/05/Feature-image-1024x538.jpg 1024w, https://hramini-back.ir/wp-content/uploads/2021/05/Feature-image-768x403.jpg 768w, https://hramini-back.ir/wp-content/uploads/2021/05/Feature-image.jpg 1440w"}},"date":"2021-05-04","excerpt":"<p>If you&#8217;ve been forked a project from another repository, you can follow this flow for handling your git commands. &hellip; <a href=\"/git-flow/\" class=\"more-link\"><span class=\"readmore\">Continue reading&#8230;<span class=\"screen-reader-text\">Git flow for a forked repository, a practical solution</span></span></a></p>\n","categories":{"nodes":[{"name":"Git"}]}},{"tags":{"nodes":[{"name":"babel"},{"name":"jsx"},{"name":"npm"},{"name":"plugin"},{"name":"react"},{"name":"typescript"},{"name":"vue"},{"name":"vue-class-component"},{"name":"vuejs"},{"name":"webpack"}]},"slug":"using-vue-with-typescript-and-jsx","content":"\n<h2 class=\"wp-block-heading\">Why Typescript and JSX?</h2>\n\n\n\n<p>Hi everyone,<br>I like using <strong><a href=\"/blog/category/typescript/\" target=\"_blank\" rel=\"noreferrer noopener\">typescript</a></strong> and <strong><a href=\"/blog/category/front-end/jsx/\" target=\"_blank\" rel=\"noreferrer noopener\">JSX</a></strong> in front-end development, that&#8217;s why I was attracted to <strong>React</strong>. But you can use class component, with typescript and JSX in developing your front-end with <strong><a href=\"/blog/category/front-end/vue/\" target=\"_blank\" rel=\"noreferrer noopener\">Vue</a></strong>. In this post I want to show you how to do it.</p>\n\n\n\n<p>Vue is introduced a preset and a plugin for babel in its third version which is letting you to create your vue components easier with typescript and render your view with JSX.</p>\n\n\n\n<h2 class=\"wp-block-heading\">Getting Start</h2>\n\n\n\n<h3 class=\"wp-block-heading\">Installing the requirements for Vue, JSX and Typescript</h3>\n\n\n\n<p>First of all, you need to install the vue 3+, vue-class-component 8+, babel 7+, vue cli and typescript:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>npm i vue@^3.0.0\n##\nnpm i vue-class-component@^8.0.0-rc\n##\nnpm i @babel/core\n##\nnpm i @vue/cli\n##\nnpm i typescript</code></pre></div>\n\n\n\n<p>After that you should install <strong>webpack</strong>, <strong>webpack-cli</strong>, <strong>webpack-dev-server</strong> ( if you don&#8217;t have any specific server ), <strong>babel-loader</strong> and <strong>ts-loader</strong>:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>npm i webpack\n##\nnpm i webpack-cli@3.3.11\n##\nnpm i webpack-dev-server\n##\nnpm i babel-loader\n##\nnpm i ts-loader</code></pre></div>\n\n\n\n<p>For using <strong>JSX</strong> in your components, you need to install the following packages:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>npm i @vue/babel-preset-app\n##\nnpm i @vue/babel-plugin-jsx</code></pre></div>\n\n\n\n<h3 class=\"wp-block-heading\">Configurations</h3>\n\n\n\n<p>And then configure your <strong>.babelrc</strong> file like this:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-file=\".babelrc\" data-lang=\"JSON\"><code>{\n  &quot;presets&quot;: [&quot;@vue/babel-preset-app&quot;],\n  &quot;plugins&quot;: [&quot;@vue/babel-plugin-jsx&quot;]\n}</code></pre></div>\n\n\n\n<p>Then, create the <strong>webpack.config.js</strong> file in your root and use the following config:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-file=\"webpack.config.js\" data-lang=\"JavaScript\"><code>const { join } = require(&#39;path&#39;);\n\nmodule.exports = {\n  mode: &#39;development&#39;,\n  target: &#39;web&#39;,\n  entry: join(__dirname, &#39;./app/index.tsx&#39;),\n  output: {\n    filename: &#39;bundle.js&#39;,\n    path: join(__dirname, &#39;dist&#39;)\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.(ts|tsx)/,\n        exclude: /node_modules/,\n        use: [{ loader: &#39;babel-loader&#39; }, { loader: &#39;ts-loader&#39; }]\n      }\n    ]\n  },\n  watch: true,\n  resolve: {\n    extensions: [&#39;.ts&#39;, &#39;.tsx&#39;, &#39;.js&#39;, &#39;.jsx&#39;, &#39;.styl&#39;]\n  },\n  devServer: {\n    contentBase: join(__dirname, &#39;./app&#39;),\n    compress: true,\n    port: 9000,\n    publicPath: &#39;/dist/&#39;\n  }\n};</code></pre></div>\n\n\n\n<p>Also you should configure your tsconfig.json file as below:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-file=\"tsconfig.json\" data-lang=\"JSON\"><code>{\n  &quot;compileOnSave&quot;: true,\n  &quot;compilerOptions&quot;: {\n    &quot;experimentalDecorators&quot;: true,\n    &quot;target&quot;: &quot;esnext&quot;,\n    &quot;strict&quot;: true,\n    &quot;module&quot;: &quot;ESNext&quot;,\n    &quot;moduleResolution&quot;: &quot;node&quot;,\n    &quot;jsx&quot;: &quot;preserve&quot;,\n    &quot;strictPropertyInitialization&quot;: false\n  },\n  &quot;exclude&quot;: [&quot;node_modules&quot;]\n}</code></pre></div>\n\n\n\n<h3 class=\"wp-block-heading\">Start creating vue components with JSX and typescript</h3>\n\n\n\n<p>Then create a folder called <strong>app</strong> ( or any other name that you like, but you should remember to use the correct direction for your <strong>entry</strong> in <strong>webpack.config.js</strong> file) and create your first component in this folder like this:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-ts\" data-file=\"/app/home-component.tsx\" data-lang=\"TypeScript\"><code>import { Vue } from &quot;vue-class-component&quot;;\n\nexport class Home extends Vue {\n  public render(): any {\n    return &lt;p&gt;Hello world!!, this is our first vue component with JSX&lt;/p&gt;;\n  }\n}</code></pre></div>\n\n\n\n<p>Now we need an HTML file that I called it index.html and put it in <strong>app</strong> folder: ( you can use a different name or put it in a different folder, but remember to change the <strong>devSever</strong> configuration of your <strong>webpack.config.js</strong> file)</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-html\" data-file=\"/app/index.html\" data-lang=\"HTML\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot;&gt;\n  &lt;head&gt;\n    &lt;meta charset=&quot;UTF-8&quot; /&gt;\n    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;\n    &lt;title&gt;Document&lt;/title&gt;\n  &lt;/head&gt;\n  &lt;body&gt;\n    &lt;div id=&quot;root&quot;&gt;&lt;/div&gt;\n    &lt;script src=&quot;/dist/bundle.js&quot;&gt;&lt;/script&gt;\n  &lt;/body&gt;\n&lt;/html&gt;</code></pre></div>\n\n\n\n<p>Now you just need an entry point which is a file in <strong>app</strong> folder, called index.tsx. You should pass your main component to <strong>createApp</strong> function and then mount it to any specific element of your DOM. Here we are mounting it to an element that its ID is <strong>&#8220;root&#8221;</strong>:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-ts\" data-file=\"/app/index.tsx\" data-lang=\"TypeScript\"><code>import { createApp } from &quot;vue&quot;;\nimport { Home } from &quot;./home-component&quot;;\n\ncreateApp(&lt;Home /&gt;).mount(&quot;#root&quot;);</code></pre></div>\n\n\n\n<p>Then you can add the start script to your package.json as the following:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-file=\"package.json\" data-lang=\"JSON\"><code>{\n  ...\n  &quot;scripts&quot;: {\n    &quot;start&quot;: &quot;webpack-dev-server&quot;\n  },\n  ...\n}\n</code></pre></div>\n\n\n\n<p>After that use the following command:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>npm start</code></pre></div>\n\n\n\n<p>For using properties in your component, you need to create a class and use it in your component like this:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-ts\" data-file=\"/app/user-info-properties.tsx\" data-lang=\"TypeScript\"><code>import { prop } from &quot;vue-class-component&quot;;\n\nexport class UserInfoProperties {\n  public name: string | undefined = prop({ type: String });\n  public surname: string | undefined = prop({ type: String });\n  public role?: string | undefined = prop({ type: String });\n}</code></pre></div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-ts\" data-file=\"/app/user-info-component.tsx\" data-lang=\"TypeScript\"><code>import { Vue } from &quot;vue-class-component&quot;;\nimport { UserInfoProperties } from &quot;./user-info-properties&quot;;\n\nexport class UserInfo extends Vue.with(UserInfoProperties) {\n  public render(): any {\n    return (\n      &lt;div&gt;\n        &lt;p&gt;\n          &lt;b&gt;User info:&lt;/b&gt;\n        &lt;/p&gt;\n        &lt;p&gt;Name: {this.$props.name}&lt;/p&gt;\n        &lt;p&gt;Surname: {this.$props.surname}&lt;/p&gt;\n        &lt;p v-show={this.$props.role}&gt;Role: {this.$props.role}&lt;/p&gt;\n      &lt;/div&gt;\n    );\n  }\n}</code></pre></div>\n\n\n\n<p>Now if you change your <strong>Home</strong> component class and add the <strong>UserInfo</strong> component to it, you can see that it is forcing you to pass all required properties to your component. So you can use <strong>UserInfo</strong> component with <strong>role</strong> property:</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-ts\" data-file=\"/app/home-component.tsx\" data-lang=\"TypeScript\"><code>import { Vue } from &quot;vue-class-component&quot;;\nimport { UserInfo } from &quot;./user-info-component&quot;;\n\nexport class Home extends Vue {\n  public render(): any {\n    return (\n      &lt;div&gt;\n        &lt;p&gt;Hello world!!, this is our first vue component with JSX&lt;/p&gt;\n        &lt;UserInfo name=&quot;Hamidreza&quot; surname=&quot;Amini&quot; role=&quot;developer&quot; /&gt;\n      &lt;/div&gt;\n    );\n  }\n}</code></pre></div>\n\n\n\n<p>Or without <strong>role</strong> property ( because <strong>role</strong> is <strong>optional</strong> in <strong>UserInfoProperties</strong> class ):</p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-ts\" data-file=\"/app/home-component.tsx\" data-lang=\"TypeScript\"><code>import { Vue } from &quot;vue-class-component&quot;;\nimport { UserInfo } from &quot;./user-info-component&quot;;\n\nexport class Home extends Vue {\n  public render(): any {\n    return (\n      &lt;div&gt;\n        &lt;p&gt;Hello world!!, this is our first vue component with JSX&lt;/p&gt;\n        &lt;UserInfo name=&quot;Hamidreza&quot; surname=&quot;Amini&quot; /&gt;\n      &lt;/div&gt;\n    );\n  }\n}</code></pre></div>\n\n\n\n<p>That&#8217;s it. Now you can enjoy using <strong>vue</strong> with <strong>typescript</strong> and <strong>JSX</strong>. Please share your <strong>comments</strong> with me, thanks.</p>\n","title":"Using Vue with Typescript and JSX","featuredImage":{"node":{"srcSet":"https://hramini-back.ir/wp-content/uploads/2020/12/vuejs-jsx-typescript-300x158.png 300w, https://hramini-back.ir/wp-content/uploads/2020/12/vuejs-jsx-typescript-1024x538.png 1024w, https://hramini-back.ir/wp-content/uploads/2020/12/vuejs-jsx-typescript-768x403.png 768w, https://hramini-back.ir/wp-content/uploads/2020/12/vuejs-jsx-typescript.png 1440w"}},"date":"2020-12-31","excerpt":"<p>Vue is introduced a preset and a plugin for babel in its third version which is letting you to create your vue components easier with typescript and render your view with JSX. &hellip; <a href=\"/using-vue-with-typescript-and-jsx/\" class=\"more-link\"><span class=\"readmore\">Continue reading&#8230;<span class=\"screen-reader-text\">Using Vue with Typescript and JSX</span></span></a></p>\n","categories":{"nodes":[{"name":"JSX"},{"name":"Typescript"},{"name":"Vue"}]}}]},"categories":{"nodes":[{"name":"Back-End","id":"dGVybTo1","parentId":null},{"name":"Coffee","id":"dGVybToyMg==","parentId":null},{"name":"French","id":"dGVybToyMw==","parentId":"dGVybToyMg=="},{"name":"Front-End","id":"dGVybTo0","parentId":null},{"name":"Git","id":"dGVybToyNA==","parentId":null},{"name":"Javascript","id":"dGVybTo5","parentId":null},{"name":"JSX","id":"dGVybToxMQ==","parentId":"dGVybTo0"},{"name":"NodeJs","id":"dGVybToxMA==","parentId":"dGVybTo1"},{"name":"React","id":"dGVybTo3","parentId":"dGVybTo0"},{"name":"Typescript","id":"dGVybTo4","parentId":null},{"name":"Uncategorized","id":"dGVybTox","parentId":null},{"name":"Vue","id":"dGVybTo2","parentId":"dGVybTo0"}]}},"pageContext":{}},
    "staticQueryHashes": []}