generator-reshow 0.0.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/generators/app/README.md +4 -0
- package/generators/app/__tests__/TestApp.js +15 -4
- package/generators/app/index.js +32 -45
- package/generators/app/templates/README.md +9 -0
- package/generators/app/templates/data/env +1 -0
- package/generators/app/templates/package.json +7 -9
- package/generators/app/templates/screen.sh +34 -0
- package/generators/app/templates/ui/pages/Page1.jsx +8 -0
- package/generators/app/templates/ui/pages/Page2.jsx +8 -0
- package/generators/app/templates/ui/pages/index.jsx +5 -3
- package/generators/app/templates/ui/templates/Doc.jsx +1 -1
- package/generators/compile-sh/README.md +8 -0
- package/generators/compile-sh/__tests__/Test.js +45 -0
- package/generators/compile-sh/index.js +12 -0
- package/generators/{app → compile-sh}/templates/compile.sh +47 -10
- package/generators/generator/README.md +9 -0
- package/generators/generator/__tests__/TestGenerator.js +44 -0
- package/generators/generator/index.js +31 -51
- package/generators/generator/templates/README.md +9 -0
- package/generators/generator/templates/Test.js +45 -0
- package/generators/generator/templates/index.js +65 -0
- package/generators/generator/templates/templates/README.md +9 -0
- package/generators/library/README.md +9 -0
- package/generators/library/__tests__/Test.js +45 -0
- package/generators/library/index.js +84 -0
- package/generators/library/templates/README.md +15 -0
- package/generators/library/templates/Test.js +10 -0
- package/generators/library/templates/compile.sh +3 -0
- package/generators/library/templates/package.json +34 -0
- package/generators/library/templates/src/index.js +3 -0
- package/generators/library/templates/yarn.lock +4075 -0
- package/generators/npm/README.md +9 -0
- package/generators/npm/__tests__/Test.js +46 -0
- package/generators/npm/index.js +92 -0
- package/generators/npm/templates/README.md +15 -0
- package/generators/npm/templates/Test.js +10 -0
- package/generators/npm/templates/package.json +34 -0
- package/generators/npm/templates/src/index.js +5 -0
- package/generators/npm/templates/src/init.js +8 -0
- package/generators/npm/templates/yarn.lock +4026 -0
- package/package.json +7 -3
- package/generators/app/templates/.gitignore +0 -8
- package/generators/app/templates/ui/pages/Atoms.jsx +0 -8
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# `generator-reshow`
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Lets you focus on code, not build tools like `create-react-app`
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
npx yonpx reshow my-app
|
|
9
|
+
cd my-app
|
|
10
|
+
npm start
|
|
11
11
|
```
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* https://yeoman.io/authoring/testing.html
|
|
3
3
|
* https://gilsondev.gitbooks.io/yeoman-authoring/content/authoring/unit_testing.html
|
|
4
|
+
*
|
|
5
|
+
* https://github.com/yeoman/yeoman-assert/blob/main/index.js
|
|
6
|
+
* https://github.com/yeoman/yeoman-test/blob/main/lib/run-context.js
|
|
4
7
|
*/
|
|
5
8
|
|
|
6
|
-
const
|
|
7
|
-
const { YoTest, assert } =
|
|
9
|
+
const getYoUnit = require("yo-unit");
|
|
10
|
+
const { YoTest, assert } = getYoUnit();
|
|
11
|
+
|
|
12
|
+
describe("generator-reshow:app", () => {
|
|
13
|
+
let runResult;
|
|
8
14
|
|
|
9
|
-
describe("generator-reshow-app:app", () => {
|
|
10
15
|
before(async () => {
|
|
11
|
-
await YoTest({
|
|
16
|
+
runResult = await YoTest({
|
|
12
17
|
source: __dirname + "/../.",
|
|
13
18
|
params: {
|
|
14
19
|
isReady: true,
|
|
@@ -19,6 +24,12 @@ describe("generator-reshow-app:app", () => {
|
|
|
19
24
|
});
|
|
20
25
|
});
|
|
21
26
|
|
|
27
|
+
after(()=>{
|
|
28
|
+
if (runResult) {
|
|
29
|
+
runResult.restore();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
22
33
|
it("should have folder", () => {
|
|
23
34
|
assert.file(["src", "ui"]);
|
|
24
35
|
});
|
package/generators/app/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
const getYo = require("yo-reshow");
|
|
2
|
-
const { YoGenerator, YoHelper } = getYo();
|
|
2
|
+
const { YoGenerator, YoHelper, commonPrompt } = getYo();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* App Generator
|
|
6
|
+
*/
|
|
3
7
|
|
|
4
8
|
module.exports = class extends YoGenerator {
|
|
5
9
|
/**
|
|
@@ -17,66 +21,49 @@ module.exports = class extends YoGenerator {
|
|
|
17
21
|
*/
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
|
-
*
|
|
24
|
+
* Questions.
|
|
21
25
|
*
|
|
22
26
|
* https://www.alwaystwisted.com/post.php?s=using-lists-in-a-yeoman-generator
|
|
23
27
|
* https://github.com/SBoudrias/Inquirer.js
|
|
24
28
|
*/
|
|
25
29
|
async prompting() {
|
|
26
|
-
const {
|
|
27
|
-
// https://github.com/yeoman/environment/blob/main/lib/util/log.js
|
|
28
|
-
say(
|
|
29
|
-
'Before "Start!"\n\n!! Need Create Folder First !!\n\nYou need create folder by yourself.'
|
|
30
|
-
);
|
|
31
|
-
|
|
30
|
+
const { handleAnswers } = YoHelper(this);
|
|
32
31
|
const prompts = [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
name: "isReady",
|
|
36
|
-
message: `We will put files at [${destFolderName}], do you already create app folder?`,
|
|
37
|
-
default: false,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
when: (response) => {
|
|
41
|
-
if (!response.isReady) {
|
|
42
|
-
process.exit(0);
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
type: "input",
|
|
48
|
-
name: "mainName",
|
|
49
|
-
message: "Please input your app name?",
|
|
50
|
-
default: destFolderName,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
type: "input",
|
|
54
|
-
name: "description",
|
|
55
|
-
message:
|
|
56
|
-
"Please input description for plug-in? (will use in package.json)",
|
|
57
|
-
default: "About ...",
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
type: "input",
|
|
61
|
-
name: "keyword",
|
|
62
|
-
message: "Please input keyword for plug-in? (will use in package.json)",
|
|
63
|
-
default: "",
|
|
64
|
-
},
|
|
32
|
+
...commonPrompt.mainName(this),
|
|
33
|
+
...commonPrompt.desc(this),
|
|
65
34
|
];
|
|
66
35
|
const answers = await this.prompt(prompts);
|
|
67
|
-
|
|
68
|
-
this.
|
|
69
|
-
|
|
36
|
+
handleAnswers(answers);
|
|
37
|
+
this.composeWith(require.resolve("../compile-sh"), {
|
|
38
|
+
webpackEnabled: true,
|
|
39
|
+
});
|
|
70
40
|
}
|
|
71
41
|
|
|
72
42
|
writing() {
|
|
73
|
-
|
|
43
|
+
this.env.options.nodePackageManager = "yarn";
|
|
44
|
+
const { cp, chMainName, mkdir } = YoHelper(this);
|
|
45
|
+
|
|
46
|
+
// handle change to new folder
|
|
47
|
+
chMainName(this.mainName);
|
|
48
|
+
|
|
49
|
+
// handle copy file
|
|
50
|
+
mkdir("ui/organisms");
|
|
74
51
|
cp("ui");
|
|
75
52
|
cp("src");
|
|
53
|
+
cp("data");
|
|
76
54
|
cp(".gitignore");
|
|
77
|
-
cp("
|
|
55
|
+
cp("screen.sh");
|
|
78
56
|
cp("index.html");
|
|
79
57
|
cp("package.json");
|
|
58
|
+
cp("README.md");
|
|
80
59
|
cp("webpack.config.js");
|
|
81
60
|
}
|
|
61
|
+
|
|
62
|
+
async end() {
|
|
63
|
+
if (!this.options?.skipInstall) {
|
|
64
|
+
const { say } = YoHelper(this);
|
|
65
|
+
await this.spawnCommand("./compile.sh", ["s", "open"]);
|
|
66
|
+
say("Check the web browser, it should autoload now.");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
82
69
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
htmlTitle="DEMO"
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"private": true,
|
|
3
3
|
"repository": {
|
|
4
4
|
"type": "git",
|
|
5
|
-
"url": "https://github.com/react-atomic/
|
|
5
|
+
"url": "https://github.com/react-atomic/"
|
|
6
6
|
},
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
],
|
|
7
|
+
"description": "Reshow App",
|
|
8
|
+
"version": "0.0.0",
|
|
9
|
+
"keywords": ["app", "reshow-app"],
|
|
11
10
|
"author": "",
|
|
12
11
|
"license": "ISC",
|
|
13
|
-
"dependencies": {
|
|
12
|
+
"dependencies": {},
|
|
13
|
+
"devDependencies": {
|
|
14
14
|
"get-object-value": "*",
|
|
15
|
-
"get-scroll-info": "*",
|
|
16
15
|
"organism-react-ajax": "*",
|
|
17
16
|
"organism-react-navigation": "*",
|
|
18
17
|
"organism-react-popup": "*",
|
|
19
18
|
"organism-react-progress": "*",
|
|
20
19
|
"pmvc_react_admin": "*",
|
|
21
|
-
"pmvc_react_list": "*",
|
|
22
20
|
"react": "^16.x",
|
|
23
21
|
"react-dom": "^16.x",
|
|
24
22
|
"reshow": "*",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
SCREEN_NAME=`basename "$PWD"`
|
|
4
|
+
|
|
5
|
+
exec() {
|
|
6
|
+
tabName=$1
|
|
7
|
+
cmd=$2
|
|
8
|
+
echo $tabName
|
|
9
|
+
if ! screen -list | grep -q "${SCREEN_NAME}"; then
|
|
10
|
+
screen -dmS ${SCREEN_NAME};
|
|
11
|
+
sleep 1;
|
|
12
|
+
fi
|
|
13
|
+
screen -S ${SCREEN_NAME} -X screen -t ${tabName}
|
|
14
|
+
screen -S ${SCREEN_NAME} -p ${tabName} -X stuff "$cmd^M";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
case "$1" in
|
|
18
|
+
enter)
|
|
19
|
+
screen -r $SCREEN_NAME
|
|
20
|
+
;;
|
|
21
|
+
stopall)
|
|
22
|
+
screen -X -S ${SCREEN_NAME} quit
|
|
23
|
+
;;
|
|
24
|
+
startall)
|
|
25
|
+
exec "server" "./compile.sh s"
|
|
26
|
+
exec "hot" "./compile.sh hot"
|
|
27
|
+
echo "run 'screen -r $SCREEN_NAME' or './screen.sh enter' to enter screen"
|
|
28
|
+
;;
|
|
29
|
+
*)
|
|
30
|
+
echo $"Usage: $0 {startall|stopall|enter}"
|
|
31
|
+
exit 1
|
|
32
|
+
esac
|
|
33
|
+
|
|
34
|
+
exit $?
|
|
@@ -4,10 +4,12 @@ import { PopupPool } from "organism-react-popup";
|
|
|
4
4
|
import { PageLoadProgressHandler } from "organism-react-progress";
|
|
5
5
|
|
|
6
6
|
import Doc from "../templates/Doc";
|
|
7
|
-
import
|
|
7
|
+
import Page1 from "../pages/Page1";
|
|
8
|
+
import Page2 from "../pages/Page2";
|
|
8
9
|
|
|
9
10
|
const themes = {
|
|
10
|
-
|
|
11
|
+
Page1,
|
|
12
|
+
Page2,
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
const Index = (props) => (
|
|
@@ -15,7 +17,7 @@ const Index = (props) => (
|
|
|
15
17
|
{({ tplProps }) => {
|
|
16
18
|
return (
|
|
17
19
|
<Doc {...tplProps}>
|
|
18
|
-
<ClientRoute {...props} themes={themes} defaultThemePath="
|
|
20
|
+
<ClientRoute {...props} themes={themes} defaultThemePath="Page1" />
|
|
19
21
|
<PageLoadProgressHandler ajax={true} />
|
|
20
22
|
<ReshowMessage />
|
|
21
23
|
<PopupPool />
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://yeoman.io/authoring/testing.html
|
|
3
|
+
* https://gilsondev.gitbooks.io/yeoman-authoring/content/authoring/unit_testing.html
|
|
4
|
+
*
|
|
5
|
+
* https://github.com/yeoman/yeoman-assert/blob/main/index.js
|
|
6
|
+
* https://github.com/yeoman/yeoman-test/blob/main/lib/run-context.js
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const getYoUnit = require("yo-unit");
|
|
10
|
+
const { YoTest, assert } = getYoUnit();
|
|
11
|
+
|
|
12
|
+
describe("!! compile-sh !!", () => {
|
|
13
|
+
let runResult;
|
|
14
|
+
|
|
15
|
+
before(async () => {
|
|
16
|
+
runResult = await YoTest({
|
|
17
|
+
source: __dirname + "/../.",
|
|
18
|
+
params: {
|
|
19
|
+
isReady: true,
|
|
20
|
+
appNamee: "foo",
|
|
21
|
+
description: "foo-desc",
|
|
22
|
+
keyword: "foo-keyword",
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
after(() => {
|
|
28
|
+
if (runResult) {
|
|
29
|
+
runResult.restore();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should have folder", () => {
|
|
34
|
+
// assert.file(["src", "ui"]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should have file", () => {
|
|
38
|
+
// assert.file(["compile.sh", "index.html"]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should have content", () => {
|
|
42
|
+
// assert.fileContent('composer.json', 'foo-desc');
|
|
43
|
+
// assert.fileContent('.circleci/config.yml', 'foo');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const getYo = require("yo-reshow");
|
|
2
|
+
const { YoGenerator, YoHelper, commonPrompt } = getYo();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* compile-sh Generator
|
|
6
|
+
*/
|
|
7
|
+
module.exports = class extends YoGenerator {
|
|
8
|
+
writing() {
|
|
9
|
+
const { cp } = YoHelper(this);
|
|
10
|
+
cp("compile.sh", null, { webpackEnabled: this.options.webpackEnabled });
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -3,21 +3,38 @@
|
|
|
3
3
|
conf='{'
|
|
4
4
|
conf+='"assetsRoot":"./assets/",'
|
|
5
5
|
conf+='"externals":{"d3": "d3"},'
|
|
6
|
-
conf+='"
|
|
6
|
+
conf+='"hotPort": "'${hotPort:-3088}'"'
|
|
7
7
|
conf+='}'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
cd $
|
|
11
|
-
|
|
9
|
+
DIR=$( cd "$(dirname "$0")" ; pwd -P )
|
|
10
|
+
cd $DIR
|
|
11
|
+
OPEN=$(which xdg-open 2>/dev/null)
|
|
12
|
+
if [ -z "$OPEN" ]; then
|
|
13
|
+
OPEN="open"
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
if [ "x<%= webpackEnabled %>" == "xon" ]; then
|
|
17
|
+
webpack='npm run webpack --'
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
checkBabel(){
|
|
21
|
+
if [ ! -e ".babelrc" ] && [ ! -e "../../packages" ]; then
|
|
22
|
+
if [ -e ${DIR}/node_modules/reshow-app/.babelrc ]; then
|
|
23
|
+
cp ${DIR}/node_modules/reshow-app/.babelrc ${DIR}/.babelrc
|
|
24
|
+
fi
|
|
25
|
+
fi
|
|
26
|
+
}
|
|
12
27
|
|
|
13
28
|
production(){
|
|
14
29
|
echo "Production Mode";
|
|
30
|
+
checkBabel
|
|
15
31
|
npm run build
|
|
16
|
-
CONFIG=$conf NODE_ENV=production $webpack
|
|
32
|
+
CONFIG=$conf NODE_ENV=production $webpack
|
|
17
33
|
}
|
|
18
34
|
|
|
19
35
|
analyzer(){
|
|
20
36
|
echo "Analyzer Mode";
|
|
37
|
+
checkBabel
|
|
21
38
|
npm run build
|
|
22
39
|
CONFIG=$conf BUNDLE='{}' $webpack
|
|
23
40
|
}
|
|
@@ -25,17 +42,31 @@ analyzer(){
|
|
|
25
42
|
develop(){
|
|
26
43
|
stop
|
|
27
44
|
echo "Develop Mode";
|
|
45
|
+
checkBabel
|
|
28
46
|
npm run build
|
|
29
47
|
CONFIG=$conf $webpack
|
|
30
48
|
}
|
|
31
49
|
|
|
50
|
+
stopServer(){
|
|
51
|
+
killBy ${DIR}/node_modules/.bin/ws
|
|
52
|
+
echo "stop server done";
|
|
53
|
+
}
|
|
54
|
+
|
|
32
55
|
startServer(){
|
|
33
|
-
|
|
34
|
-
killBy ${DIR}/node_modules/.bin/ws
|
|
56
|
+
stopServer
|
|
35
57
|
yarn
|
|
58
|
+
if [ ! -e "build" ]; then
|
|
59
|
+
develop
|
|
60
|
+
fi
|
|
36
61
|
port=${port-3000}
|
|
37
62
|
echo "Start server";
|
|
38
|
-
|
|
63
|
+
if [ "$1" == "open" ]; then
|
|
64
|
+
npm run start -- -p $port &
|
|
65
|
+
sleep 3
|
|
66
|
+
$OPEN http://localhost:$port
|
|
67
|
+
else
|
|
68
|
+
npm run start -- -p $port -v
|
|
69
|
+
fi
|
|
39
70
|
}
|
|
40
71
|
|
|
41
72
|
killBy(){
|
|
@@ -43,7 +74,6 @@ killBy(){
|
|
|
43
74
|
}
|
|
44
75
|
|
|
45
76
|
stop(){
|
|
46
|
-
DIR="$( cd "$(dirname "$0")" ; pwd -P )"
|
|
47
77
|
killBy ${DIR}/node_modules/.bin/babel
|
|
48
78
|
cat webpack.pid | xargs -I{} kill -9 {}
|
|
49
79
|
npm run clean
|
|
@@ -53,6 +83,7 @@ stop(){
|
|
|
53
83
|
watch(){
|
|
54
84
|
stop
|
|
55
85
|
echo "Watch Mode";
|
|
86
|
+
checkBabel
|
|
56
87
|
npm run build:ui -- --watch &
|
|
57
88
|
npm run build:src -- --watch &
|
|
58
89
|
sleep 10
|
|
@@ -62,6 +93,7 @@ watch(){
|
|
|
62
93
|
watchTest(){
|
|
63
94
|
stop
|
|
64
95
|
echo "Watch Test";
|
|
96
|
+
checkBabel
|
|
65
97
|
npm run build:test:ui -- --watch &
|
|
66
98
|
npm run build:test:src -- --watch &
|
|
67
99
|
}
|
|
@@ -69,8 +101,10 @@ watchTest(){
|
|
|
69
101
|
hot(){
|
|
70
102
|
stop
|
|
71
103
|
echo "Hot Mode";
|
|
104
|
+
checkBabel
|
|
72
105
|
npm run build:ui -- --watch &
|
|
73
106
|
npm run build:src -- --watch &
|
|
107
|
+
sleep 5
|
|
74
108
|
HOT_UPDATE=1 CONFIG=$conf $webpack serve &
|
|
75
109
|
}
|
|
76
110
|
|
|
@@ -82,7 +116,10 @@ case "$1" in
|
|
|
82
116
|
analyzer
|
|
83
117
|
;;
|
|
84
118
|
s)
|
|
85
|
-
startServer
|
|
119
|
+
startServer $2
|
|
120
|
+
;;
|
|
121
|
+
ss)
|
|
122
|
+
stopServer
|
|
86
123
|
;;
|
|
87
124
|
hot)
|
|
88
125
|
hot
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://yeoman.io/authoring/testing.html
|
|
3
|
+
* https://gilsondev.gitbooks.io/yeoman-authoring/content/authoring/unit_testing.html
|
|
4
|
+
*
|
|
5
|
+
* https://github.com/yeoman/yeoman-assert/blob/main/index.js
|
|
6
|
+
* https://github.com/yeoman/yeoman-test/blob/main/lib/run-context.js
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const getYoUnit = require("yo-unit");
|
|
10
|
+
const { YoTest, assert } = getYoUnit();
|
|
11
|
+
|
|
12
|
+
describe("!! generator !!", () => {
|
|
13
|
+
let runResult;
|
|
14
|
+
|
|
15
|
+
before(async () => {
|
|
16
|
+
runResult = await YoTest({
|
|
17
|
+
source: __dirname + "/../.",
|
|
18
|
+
params: {
|
|
19
|
+
isReady: true,
|
|
20
|
+
mainNamee: "foo",
|
|
21
|
+
description: "foo-desc",
|
|
22
|
+
keyword: "foo-keyword",
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
after(() => {
|
|
28
|
+
if (runResult) {
|
|
29
|
+
runResult.restore();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should have folder", () => {
|
|
34
|
+
assert.file(["__tests__"]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should have file", () => {
|
|
38
|
+
assert.file(["README.md", "index.js"]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should have content", () => {
|
|
42
|
+
assert.fileContent("README.md", "foo");
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
const getYo = require("yo-reshow");
|
|
2
|
-
const { YoGenerator, YoHelper } = getYo();
|
|
2
|
+
const { YoGenerator, YoHelper, commonPrompt } = getYo();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The Generator
|
|
6
|
+
*/
|
|
3
7
|
|
|
4
8
|
module.exports = class extends YoGenerator {
|
|
5
9
|
/**
|
|
@@ -17,66 +21,42 @@ module.exports = class extends YoGenerator {
|
|
|
17
21
|
*/
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
|
-
*
|
|
24
|
+
* Questions.
|
|
21
25
|
*
|
|
22
26
|
* https://www.alwaystwisted.com/post.php?s=using-lists-in-a-yeoman-generator
|
|
23
27
|
* https://github.com/SBoudrias/Inquirer.js
|
|
24
28
|
*/
|
|
25
29
|
async prompting() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
this.env.options.nodePackageManager = "yarn";
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
handleAnswers,
|
|
34
|
+
mergePromptOrOption,
|
|
35
|
+
promptChainLocator,
|
|
36
|
+
promptChain,
|
|
37
|
+
} = YoHelper(this);
|
|
31
38
|
|
|
32
39
|
const prompts = [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
name: "isReady",
|
|
36
|
-
message: `We will put files at [${destFolderName}], do you already create generator folder?`,
|
|
37
|
-
default: false,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
when: (response) => {
|
|
41
|
-
if (!response.isReady) {
|
|
42
|
-
process.exit(0);
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
type: "input",
|
|
48
|
-
name: "mainName",
|
|
49
|
-
message: "Please input your generator name?",
|
|
50
|
-
default: destFolderName,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
type: "input",
|
|
54
|
-
name: "description",
|
|
55
|
-
message:
|
|
56
|
-
"Please input description for plug-in? (will use in package.json)",
|
|
57
|
-
default: "About ...",
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
type: "input",
|
|
61
|
-
name: "keyword",
|
|
62
|
-
message: "Please input keyword for plug-in? (will use in package.json)",
|
|
63
|
-
default: "",
|
|
64
|
-
},
|
|
40
|
+
...commonPrompt.mainName(this),
|
|
41
|
+
...commonPrompt.desc(this),
|
|
65
42
|
];
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
43
|
+
|
|
44
|
+
const answers = await promptChain(promptChainLocator(prompts));
|
|
45
|
+
handleAnswers(answers, (payload)=>{
|
|
46
|
+
payload.generatorName = payload.mainName;
|
|
47
|
+
});
|
|
70
48
|
}
|
|
71
49
|
|
|
72
50
|
writing() {
|
|
73
|
-
const { cp } = YoHelper(this);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
cp(
|
|
80
|
-
cp(
|
|
51
|
+
const { cp, chMainName } = YoHelper(this);
|
|
52
|
+
|
|
53
|
+
// handle change to new folder
|
|
54
|
+
chMainName(this.mainName);
|
|
55
|
+
|
|
56
|
+
// handle copy file
|
|
57
|
+
cp('Test.js', '__tests__/Test.js', this.payload);
|
|
58
|
+
cp('README.md', null, this.payload);
|
|
59
|
+
cp('index.js', null, this.payload);
|
|
60
|
+
cp('templates');
|
|
81
61
|
}
|
|
82
62
|
};
|