Skip to content
Snippets Groups Projects
Unverified Commit 7eb9595d authored by jeromecambon's avatar jeromecambon Committed by GitHub
Browse files

Replaced copy-wc command by duplicate-widget (#10)

parent fac5de0a
No related branches found
No related tags found
No related merge requests found
......@@ -42,11 +42,11 @@ Then, follow the following steps.
$ npm run init
```
- Duplicate the web component you want to extend, using the cwb CLI.
- Duplicate the standard widget you want to extend, using the cwb CLI.
For instance if you want to extend the `pb-input` web component and create `my-input`:
```bash
$ cd packages/widgets
$ cwb copy-wc --srcDir pb-input --destDir my-input
$ cwb duplicate-widget --srcDir pb-input --destDir my-input
````
- Install its dependencies:
......@@ -328,7 +328,7 @@ Commands:
cwb gen-properties Generate json properties from web component source file [aliases: genp]
cwb gen-properties-template Generate json properties template from web component name [aliases: genpt]
cwb gen-widget Generate a widget [aliases: genw]
cwb copy-wc Duplicate a web component [aliases: cp]
cwb duplicate-widget Duplicate an UI Designer standard widget [aliases: dupw]
Options:
-h, --help Show help [boolean]
......@@ -379,12 +379,12 @@ Options:
-v, --version Show version number [boolean]
```
### Copy a web component to a new one
### Duplicate an UI Designer standard widget
```shell
$ cwb copy-wc --help
cwb copy-wc
$ cwb dupw --help
cwb duplicate-widget
Duplicate a web component
Duplicate an UI Designer standard widget
Options:
--srcDir, -s source directory [required]
......
......@@ -11,7 +11,6 @@
"dependencies": {
"@types/node": "^14.14.35",
"archiver": "^5.3.0",
"extract-zip": "^2.0.1",
"jdenticon": "^3.1.0",
"typescript": "^4.1.3",
"web-component-analyzer": "^1.1.6",
......@@ -25,6 +24,7 @@
"@types/archiver": "^5.1.0",
"@types/jest": "^26.0.22",
"@types/yargs": "^15.0.13",
"extract-zip": "^2.0.1",
"jest": "^26.6.3",
"ts-jest": "^26.5.4"
}
......@@ -948,6 +948,7 @@
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.1.tgz",
"integrity": "sha512-A1b8SU4D10uoPjwb0lnHmmu8wZhR9d+9o2PKBQT2jU5YPTKsxac6M2qGAdY7VcL+dHHhARVUDmeg0rOrcd9EjA==",
"dev": true,
"optional": true,
"dependencies": {
"@types/node": "*"
......@@ -1903,6 +1904,7 @@
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"dev": true,
"dependencies": {
"ms": "2.1.2"
},
......@@ -2397,6 +2399,7 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz",
"integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==",
"dev": true,
"dependencies": {
"debug": "^4.1.1",
"get-stream": "^5.1.0",
......@@ -2476,6 +2479,7 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz",
"integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=",
"dev": true,
"dependencies": {
"pend": "~1.2.0"
}
......@@ -2606,6 +2610,7 @@
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
"integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
"dev": true,
"dependencies": {
"pump": "^3.0.0"
},
......@@ -4157,7 +4162,8 @@
"node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"node_modules/nanomatch": {
"version": "1.2.13",
......@@ -4559,7 +4565,8 @@
"node_modules/pend": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
"integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA="
"integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=",
"dev": true
},
"node_modules/performance-now": {
"version": "2.1.0",
......@@ -4671,6 +4678,7 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
"integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
"dev": true,
"dependencies": {
"end-of-stream": "^1.1.0",
"once": "^1.3.1"
......@@ -6623,6 +6631,7 @@
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
"integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=",
"dev": true,
"dependencies": {
"buffer-crc32": "~0.2.3",
"fd-slicer": "~1.1.0"
......@@ -7482,6 +7491,7 @@
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.1.tgz",
"integrity": "sha512-A1b8SU4D10uoPjwb0lnHmmu8wZhR9d+9o2PKBQT2jU5YPTKsxac6M2qGAdY7VcL+dHHhARVUDmeg0rOrcd9EjA==",
"dev": true,
"optional": true,
"requires": {
"@types/node": "*"
......@@ -8248,6 +8258,7 @@
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"dev": true,
"requires": {
"ms": "2.1.2"
}
......@@ -8636,6 +8647,7 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz",
"integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==",
"dev": true,
"requires": {
"@types/yauzl": "^2.9.1",
"debug": "^4.1.1",
......@@ -8701,6 +8713,7 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz",
"integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=",
"dev": true,
"requires": {
"pend": "~1.2.0"
}
......@@ -8798,6 +8811,7 @@
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
"integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
"dev": true,
"requires": {
"pump": "^3.0.0"
}
......@@ -10027,7 +10041,8 @@
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"nanomatch": {
"version": "1.2.13",
......@@ -10350,7 +10365,8 @@
"pend": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
"integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA="
"integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=",
"dev": true
},
"performance-now": {
"version": "2.1.0",
......@@ -10435,6 +10451,7 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
"integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
"dev": true,
"requires": {
"end-of-stream": "^1.1.0",
"once": "^1.3.1"
......@@ -12009,6 +12026,7 @@
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
"integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=",
"dev": true,
"requires": {
"buffer-crc32": "~0.2.3",
"fd-slicer": "~1.1.0"
......
......@@ -26,8 +26,8 @@ export class CliDefinition {
public static genPropertiesTemplateCommandAlias = "genpt";
public static genWidgetCommand = "gen-widget";
public static genWidgetCommandAlias = "genw";
public static copyWcCommand = "copy-wc";
public static copyWcCommandAlias = "cp";
public static duplicateWidgetCommand = "duplicate-widget";
public static duplicateWidgetCommandAlias = "dupw";
public static webComponentSourceParam = "webComponentSource";
public static webComponentNameParam = "webComponentName";
......@@ -85,8 +85,8 @@ export class CliDefinition {
.option(
CliDefinition.outputDirParam, CliDefinition.getOutputDirDef())
})
.command([CliDefinition.copyWcCommand, CliDefinition.copyWcCommandAlias],
'Duplicate a web component', () => {
.command([CliDefinition.duplicateWidgetCommand, CliDefinition.duplicateWidgetCommandAlias],
'Duplicate an UI Designer standard widget', () => {
return yargs
.option(
CliDefinition.sourceDirParam, {
......
......@@ -45,8 +45,8 @@ try {
case CliDefinition.genWidgetCommandAlias:
new CustomWidgetBuilder().generateCustomWidget(<string>params.propertiesFile, <string>params.webComponentBundle, <string>params.outputDir);
break;
case CliDefinition.copyWcCommand:
case CliDefinition.copyWcCommandAlias:
case CliDefinition.duplicateWidgetCommand:
case CliDefinition.duplicateWidgetCommandAlias:
new WebComponentCopier().copyWebComponent(<string>params.srcDir, <string>params.destDir);
break;
default:
......
......@@ -78,9 +78,9 @@ describe('CLI test', () => {
execCommand(command, `Widget has been generated in ${tempDir}/widget/widget-Input.zip`, done);
});
test('should handle correct parameters when copying a widget', async (done) => {
test('should handle correct parameters when duplicating a widget', async (done) => {
let command =
`node build/src/starter.js copy-wc --srcDir test/resources/pb-input --destDir ${tempDir}/my-input`;
`node build/src/starter.js duplicate-widget --srcDir test/resources/pb-input --destDir ${tempDir}/my-input`;
execCommand(command, `${tempDir}/my-input has been created!`, done);
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment