Skip to content

Commit

Permalink
feat(cli): add gen command
Browse files Browse the repository at this point in the history
affects: @varlet/cli, @varlet/ui
  • Loading branch information
haoziqaq committed Sep 9, 2021
1 parent 1a650a5 commit abdec46
Show file tree
Hide file tree
Showing 31 changed files with 1,120 additions and 49 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"bootstrap": "yarn && node scripts/bootstrap.mjs",
"commit": "git-cz",
"prepare": "husky install",
"publish": "node scripts/publish.mjs && lerna publish"
"publish": "node scripts/publish.mjs && lerna publish",
"gen": "varlet-cli gen"
},
"config": {
"commitizen": {
Expand Down
2 changes: 1 addition & 1 deletion packages/varlet-cli/generators/sfc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"vue": "^3.0.0"
},
"devDependencies": {
"@varlet/cli": "^1.16.3@alpha.14",
"@varlet/cli": "^1.16.3",
"vue": "3.1.4"
},
"lint-staged": {
Expand Down
13 changes: 13 additions & 0 deletions packages/varlet-cli/generators/sfc/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"strict": true,
"downlevelIteration": true,
"declaration": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowJs": true,
"lib": ["esnext", "dom"],
"allowSyntheticDefaultImports": true,
"jsx": "preserve"
}
}
39 changes: 20 additions & 19 deletions packages/varlet-cli/generators/sfc/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1599,20 +1599,20 @@
dependencies:
"@types/yargs-parser" "*"

"@varlet/cli@^1.16.3@alpha.14":
version "1.16.3-alpha.14"
resolved "https://registry.npmjs.org/@varlet/cli/-/cli-1.16.3-alpha.14.tgz#ebd053cc179abf90baba33b5b6480f414b2fcde0"
integrity sha512-bltwggLWWdWEDotA2n1AUGQTl8QM8x9FWsnkVrEDZ36WT+4JPK8cIYcdfvfzjfhWc/Ls6By36bmZ+YZ8Pnfcsw==
"@varlet/cli@^1.16.3":
version "1.16.3"
resolved "https://registry.npmjs.org/@varlet/cli/-/cli-1.16.3.tgz#ccc3391a0db6e4f23fa3673fea1073c285117ab1"
integrity sha512-cA0BldCj2uxCMA2tNvvuosjGbca61qXoKflHZCrWEokTDfX+4DJFkSORTqRzwrmBA9l2QPD0o/4HpKOx6o07Ag==
dependencies:
"@babel/core" "^7.14.8"
"@babel/preset-env" "^7.14.8"
"@babel/preset-typescript" "^7.14.5"
"@commitlint/cli" "^11.0.0"
"@commitlint/config-conventional" "^11.0.0"
"@varlet/icons" "^1.0.0"
"@varlet/markdown-loader" "^1.16.1"
"@varlet/markdown-loader" "^1.16.3"
"@varlet/touch-emulator" "^1.0.1"
"@varlet/ui" "^1.16.3-alpha.14+f804915"
"@varlet/ui" "^1.16.3"
"@vue/babel-plugin-jsx" "^1.0.6"
"@vue/compiler-sfc" "3.1.4"
"@vue/test-utils" "^2.0.0-rc.6"
Expand Down Expand Up @@ -1668,23 +1668,24 @@
fs-extra "^9.0.1"
webfont "^9.0.0"

"@varlet/markdown-loader@^1.16.1":
version "1.16.1"
resolved "https://registry.npmjs.org/@varlet/markdown-loader/-/markdown-loader-1.16.1.tgz#28fdb872e3ed782c4c4fd3b04f8e4c91c2d4b30f"
integrity sha512-myvHQfDluJHNa0TEFGHDcLpk0mzoh+vUr+L4WKyukv0REufmwAMu4xO2HIfOLdt4UsOPTc7g0SfXTJR7WI3PuQ==
"@varlet/markdown-loader@^1.16.3":
version "1.16.3"
resolved "https://registry.npmjs.org/@varlet/markdown-loader/-/markdown-loader-1.16.3.tgz#6560022bf009fef15dddcaab86aac47d3042831e"
integrity sha512-mtq1/69qPG1AvXHjUxzR934uM/sXAi2L08WLYdwvVA1jC8s2pVHJG9+IKpw36zeA1zyBFIYRhQBh61ZyzQXXDA==
dependencies:
highlight.js "^10.3.2"
highlight.js "10.3.2"
loader-utils "^2.0.0"
markdown-it "^12.0.2"

"@varlet/touch-emulator@^1.0.1":
version "1.0.1"
resolved "https://registry.nlark.com/@varlet/touch-emulator/download/@varlet/touch-emulator-1.0.1.tgz#3c2fb609561ecc089be6bf748ae42610cfca8a18"
integrity sha1-PC+2CVYezAib5r90iuQmEM/Kihg=

"@varlet/ui@^1.16.3-alpha.14+f804915":
version "1.16.3-alpha.14"
resolved "https://registry.npmjs.org/@varlet/ui/-/ui-1.16.3-alpha.14.tgz#e13254310f8f257635c0dbddfc9d829e54fc3ea7"
integrity sha512-MH54R3c2tCEoyWBMQhHCJ88O0UT9Oef2Uv9eRQLUd0G5ID51mScflyQMKWST6iGPEqcGza+xJzjpYEK5I5odxQ==
"@varlet/ui@^1.16.3":
version "1.16.3"
resolved "https://registry.npmjs.org/@varlet/ui/-/ui-1.16.3.tgz#774fb8e0e97aabea94248f8490b2dd9039aa15ff"
integrity sha512-pumru5LRJhBr1mqD7nOy7RupPPOTF9SGs6h7izlgbFYzD0wHttl/wkGY1fqxe4ZH7/C7acZWdB8/d3ggKVfPPg==
dependencies:
dayjs "^1.10.4"
decimal.js "^10.2.1"
Expand Down Expand Up @@ -4757,10 +4758,10 @@ he@^1.2.0:
resolved "https://registry.npm.taobao.org/he/download/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
integrity sha1-hK5l+n6vsWX922FWauFLrwVmTw8=

highlight.js@^10.3.2:
version "10.7.3"
resolved "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz#697272e3991356e40c3cac566a74eef681756531"
integrity sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==
[email protected]:
version "10.3.2"
resolved "https://registry.npmjs.org/highlight.js/-/highlight.js-10.3.2.tgz#135fd3619a00c3cbb8b4cd6dbc78d56bfcbc46f1"
integrity sha512-3jRT7OUYsVsKvukNKZCtnvRcFyCJqSEIuIMsEybAXRiFSwpt65qjPd/Pr+UOdYt7WJlt+lj3+ypUsHiySBp/Jw==

homedir-polyfill@^1.0.1:
version "1.0.3"
Expand Down
19 changes: 19 additions & 0 deletions packages/varlet-cli/generators/tsx/coverage/clover.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1631202978296" clover="3.2.0">
<project timestamp="1631202978296" name="All files">
<metrics statements="7" coveredstatements="4" conditionals="0" coveredconditionals="0" methods="4" coveredmethods="2" elements="11" coveredelements="6" complexity="0" loc="7" ncloc="7" packages="1" files="2" classes="2"/>
<file name="Button.tsx" path="/Users/qihao/varlet/packages/varlet-cli/generators/tsx/src/button/Button.tsx">
<metrics statements="4" coveredstatements="4" conditionals="0" coveredconditionals="0" methods="3" coveredmethods="2"/>
<line num="15" count="2" type="stmt"/>
<line num="17" count="2" type="stmt"/>
<line num="18" count="2" type="stmt"/>
<line num="20" count="2" type="stmt"/>
</file>
<file name="index.ts" path="/Users/qihao/varlet/packages/varlet-cli/generators/tsx/src/button/index.ts">
<metrics statements="3" coveredstatements="0" conditionals="0" coveredconditionals="0" methods="1" coveredmethods="0"/>
<line num="4" count="0" type="stmt"/>
<line num="5" count="0" type="stmt"/>
<line num="8" count="0" type="stmt"/>
</file>
</project>
</coverage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"/Users/qihao/varlet/packages/varlet-cli/generators/tsx/src/button/Button.tsx": {"path":"/Users/qihao/varlet/packages/varlet-cli/generators/tsx/src/button/Button.tsx","statementMap":{"0":{"start":{"line":15,"column":24},"end":{"line":15,"column":56}},"1":{"start":{"line":15,"column":38},"end":{"line":15,"column":56}},"2":{"start":{"line":17,"column":4},"end":{"line":29,"column":5}},"3":{"start":{"line":18,"column":24},"end":{"line":18,"column":29}},"4":{"start":{"line":20,"column":6},"end":{"line":28,"column":9}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":14,"column":2},"end":{"line":14,"column":3}},"loc":{"start":{"line":14,"column":26},"end":{"line":30,"column":3}},"line":14},"1":{"name":"(anonymous_1)","decl":{"start":{"line":15,"column":24},"end":{"line":15,"column":25}},"loc":{"start":{"line":15,"column":38},"end":{"line":15,"column":56}},"line":15},"2":{"name":"(anonymous_2)","decl":{"start":{"line":17,"column":11},"end":{"line":17,"column":12}},"loc":{"start":{"line":17,"column":17},"end":{"line":29,"column":5}},"line":17}},"branchMap":{},"s":{"0":2,"1":0,"2":2,"3":2,"4":2},"f":{"0":2,"1":0,"2":2},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"4fea11d37ecc423a0eae7a720274106a70376698"}
,"/Users/qihao/varlet/packages/varlet-cli/generators/tsx/src/button/index.ts": {"path":"/Users/qihao/varlet/packages/varlet-cli/generators/tsx/src/button/index.ts","statementMap":{"0":{"start":{"line":4,"column":0},"end":{"line":6,"column":1}},"1":{"start":{"line":5,"column":2},"end":{"line":5,"column":36}},"2":{"start":{"line":8,"column":32},"end":{"line":8,"column":38}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":4,"column":17},"end":{"line":4,"column":18}},"loc":{"start":{"line":4,"column":37},"end":{"line":6,"column":1}},"line":4}},"branchMap":{},"s":{"0":0,"1":0,"2":0},"f":{"0":0},"b":{}}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@

<!doctype html>
<html lang="en">

<head>
<title>Code coverage report for Button.tsx</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="prettify.css" />
<link rel="stylesheet" href="base.css" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(sort-arrow-sprite.png);
}
</style>
</head>

<body>
<div class='wrapper'>
<div class='pad1'>
<h1><a href="index.html">All files</a> Button.tsx</h1>
<div class='clearfix'>

<div class='fl pad1y space-right2'>
<span class="strong">80% </span>
<span class="quiet">Statements</span>
<span class='fraction'>4/5</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>0/0</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">66.67% </span>
<span class="quiet">Functions</span>
<span class='fraction'>2/3</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>4/4</span>
</div>


</div>
<p class="quiet">
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
</p>
</div>
<div class='status-line high'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
<a name='L2'></a><a href='#L2'>2</a>
<a name='L3'></a><a href='#L3'>3</a>
<a name='L4'></a><a href='#L4'>4</a>
<a name='L5'></a><a href='#L5'>5</a>
<a name='L6'></a><a href='#L6'>6</a>
<a name='L7'></a><a href='#L7'>7</a>
<a name='L8'></a><a href='#L8'>8</a>
<a name='L9'></a><a href='#L9'>9</a>
<a name='L10'></a><a href='#L10'>10</a>
<a name='L11'></a><a href='#L11'>11</a>
<a name='L12'></a><a href='#L12'>12</a>
<a name='L13'></a><a href='#L13'>13</a>
<a name='L14'></a><a href='#L14'>14</a>
<a name='L15'></a><a href='#L15'>15</a>
<a name='L16'></a><a href='#L16'>16</a>
<a name='L17'></a><a href='#L17'>17</a>
<a name='L18'></a><a href='#L18'>18</a>
<a name='L19'></a><a href='#L19'>19</a>
<a name='L20'></a><a href='#L20'>20</a>
<a name='L21'></a><a href='#L21'>21</a>
<a name='L22'></a><a href='#L22'>22</a>
<a name='L23'></a><a href='#L23'>23</a>
<a name='L24'></a><a href='#L24'>24</a>
<a name='L25'></a><a href='#L25'>25</a>
<a name='L26'></a><a href='#L26'>26</a>
<a name='L27'></a><a href='#L27'>27</a>
<a name='L28'></a><a href='#L28'>28</a>
<a name='L29'></a><a href='#L29'>29</a>
<a name='L30'></a><a href='#L30'>30</a>
<a name='L31'></a><a href='#L31'>31</a>
<a name='L32'></a><a href='#L32'>32</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">2x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import { defineComponent, PropType } from 'vue'
import './button.less'
&nbsp;
export default defineComponent({
name: 'BButton',
props: {
color: {
type: String
},
onClick: {
type: Function as PropType&lt;(e: Event) =&gt; void&gt;
}
},
setup(props, { slots }) {
const handleClick = <span class="fstat-no" title="function not covered" >(e</span>: Event) =&gt; <span class="cstat-no" title="statement not covered" >props.onClick?.(e)</span>
&nbsp;
return () =&gt; {
const { color } = props
&nbsp;
return &lt;&gt;
&lt;button
class="basic-button"
style={{ background: color }}
onClick={ handleClick }
&gt;
{ slots.default?.() }
&lt;/button&gt;
&lt;/&gt;
}
}
})
&nbsp;</pre></td></tr></table></pre>

<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
at Thu Sep 09 2021 23:56:18 GMT+0800 (China Standard Time)
</div>
</div>
<script src="prettify.js"></script>
<script>
window.onload = function () {
prettyPrint();
};
</script>
<script src="sorter.js"></script>
<script src="block-navigation.js"></script>
</body>
</html>

Loading

0 comments on commit abdec46

Please sign in to comment.