generator-reshow 0.0.0 → 0.0.1

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.
Files changed (34) hide show
  1. package/README.md +4 -4
  2. package/generators/app/README.md +4 -0
  3. package/generators/app/__tests__/TestApp.js +15 -4
  4. package/generators/app/index.js +32 -45
  5. package/generators/app/templates/README.md +9 -0
  6. package/generators/app/templates/data/env +1 -0
  7. package/generators/app/templates/package.json +7 -9
  8. package/generators/app/templates/screen.sh +34 -0
  9. package/generators/app/templates/ui/pages/Page1.jsx +8 -0
  10. package/generators/app/templates/ui/pages/Page2.jsx +8 -0
  11. package/generators/app/templates/ui/pages/index.jsx +5 -3
  12. package/generators/compile-sh/README.md +8 -0
  13. package/generators/compile-sh/__tests__/Test.js +45 -0
  14. package/generators/compile-sh/index.js +12 -0
  15. package/generators/{app → compile-sh}/templates/compile.sh +47 -10
  16. package/generators/generator/README.md +9 -0
  17. package/generators/generator/__tests__/TestGenerator.js +44 -0
  18. package/generators/generator/index.js +31 -51
  19. package/generators/generator/templates/README.md +9 -0
  20. package/generators/generator/templates/Test.js +45 -0
  21. package/generators/generator/templates/index.js +65 -0
  22. package/generators/generator/templates/templates/README.md +9 -0
  23. package/generators/library/README.md +9 -0
  24. package/generators/library/__tests__/Test.js +45 -0
  25. package/generators/library/index.js +83 -0
  26. package/generators/library/templates/README.md +15 -0
  27. package/generators/library/templates/package.json +34 -0
  28. package/generators/npm/README.md +9 -0
  29. package/generators/npm/__tests__/Test.js +46 -0
  30. package/generators/npm/index.js +89 -0
  31. package/generators/npm/templates/README.md +15 -0
  32. package/generators/npm/templates/package.json +34 -0
  33. package/package.json +4 -1
  34. 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
- > TODO: description
3
+ > Lets you focus on code, not build tools like `create-react-app`
4
4
 
5
5
  ## Usage
6
6
 
7
7
  ```
8
- const generatorReshow = require('generator-reshow');
9
-
10
- // TODO: DEMONSTRATE API
8
+ npx yonpx reshow my-app
9
+ cd my-app
10
+ npm start
11
11
  ```
@@ -0,0 +1,4 @@
1
+ # `reshow:app`
2
+
3
+ > check https://github.com/react-atomic/reshow/tree/main/packages/generator-reshow
4
+
@@ -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 getYo = require("yo-reshow");
7
- const { YoTest, assert } = getYo();
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
  });
@@ -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
- * Using lists in a yeoman prompt
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 { say, destFolderName } = YoHelper(this);
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
- type: "confirm",
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
- this.mainName = answers.mainName;
68
- this.description = answers.description;
69
- this.keyword = answers.keyword || answers.mainName;
36
+ handleAnswers(answers);
37
+ this.composeWith(require.resolve("../compile-sh"), {
38
+ webpackEnabled: true,
39
+ });
70
40
  }
71
41
 
72
42
  writing() {
73
- const { cp } = YoHelper(this);
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("compile.sh");
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,9 @@
1
+ # `APP`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+
9
+ ```
@@ -0,0 +1 @@
1
+ htmlTitle="DEMO"
@@ -1,24 +1,22 @@
1
1
  {
2
- "description": "Reshow App",
2
+ "private": true,
3
3
  "repository": {
4
4
  "type": "git",
5
- "url": "https://github.com/react-atomic/react-atomic-ui"
5
+ "url": "https://github.com/react-atomic/"
6
6
  },
7
- "keywords": [
8
- "app",
9
- "reshow-app"
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 $?
@@ -0,0 +1,8 @@
1
+ import usePage from "../../src/usePage";
2
+
3
+ const Page1 = (props) => {
4
+ usePage({ ...props, pageName: "Page1" });
5
+ return <>This is page1</>;
6
+ };
7
+
8
+ export default Page1;
@@ -0,0 +1,8 @@
1
+ import usePage from "../../src/usePage";
2
+
3
+ const Page2 = (props) => {
4
+ usePage({ ...props, pageName: "Page2" });
5
+ return <>This is page2</>;
6
+ };
7
+
8
+ export default Page2;
@@ -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 Atoms from "../pages/Atoms";
7
+ import Page1 from "../pages/Page1";
8
+ import Page2 from "../pages/Page2";
8
9
 
9
10
  const themes = {
10
- Atoms,
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="Atoms" />
20
+ <ClientRoute {...props} themes={themes} defaultThemePath="Page1" />
19
21
  <PageLoadProgressHandler ajax={true} />
20
22
  <ReshowMessage />
21
23
  <PopupPool />
@@ -0,0 +1,8 @@
1
+ # `compile-sh`
2
+
3
+ > build compile.sh
4
+
5
+ ## Usage
6
+
7
+ > You should call it with this.composeWith()
8
+
@@ -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+='"devPort": "'${hotPort:-8080}'"'
6
+ conf+='"hotPort": "'${hotPort:-3088}'"'
7
7
  conf+='}'
8
8
 
9
- PWD=`dirname $0`
10
- cd $PWD
11
- webpack='npm run webpack --'
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 --mode=production
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
- DIR="$( cd "$(dirname "$0")" ; pwd -P )"
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
- npm run start -- -p $port -v
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,9 @@
1
+ # `generator`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ npx yonpx reshow:generator
9
+ ```
@@ -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
- * Using lists in a yeoman prompt
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 { say, destFolderName } = YoHelper(this);
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
- );
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
- type: "confirm",
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
- const answers = await this.prompt(prompts);
67
- this.mainName = answers.mainName;
68
- this.description = answers.description;
69
- this.keyword = answers.keyword || answers.mainName;
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
- cp("ui");
75
- cp("src");
76
- cp(".gitignore");
77
- cp("compile.sh");
78
- cp("index.html");
79
- cp("package.json");
80
- cp("webpack.config.js");
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
  };
@@ -0,0 +1,9 @@
1
+ # `<%= mainName %>`
2
+
3
+ > <%= description %>
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ npx yonpx <%= generatorName %>
9
+ ```
@@ -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("!! <%= mainName %> !!", () => {
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,65 @@
1
+ const getYo = require("yo-reshow");
2
+ const { YoGenerator, YoHelper, commonPrompt } = getYo();
3
+
4
+ /**
5
+ * <%= mainName %> Generator
6
+ */
7
+ module.exports = class extends YoGenerator {
8
+ /**
9
+ * Run loop (Life cycle)
10
+ * https://yeoman.io/authoring/running-context.html#the-run-loop
11
+ *
12
+ * 1. initializing
13
+ * 2. prompting
14
+ * 3. configuring
15
+ * 4. default
16
+ * 5. writing
17
+ * 6. conflicts
18
+ * 7. install
19
+ * 8. end
20
+ */
21
+
22
+ /**
23
+ * Questions.
24
+ *
25
+ * https://www.alwaystwisted.com/post.php?s=using-lists-in-a-yeoman-generator
26
+ * https://github.com/SBoudrias/Inquirer.js
27
+ */
28
+ async prompting() {
29
+ const {
30
+ say,
31
+ handleAnswers,
32
+ mergePromptOrOption,
33
+ promptChainLocator,
34
+ promptChain,
35
+ } = YoHelper(this);
36
+
37
+ const prompts = [
38
+ ...commonPrompt.mainName(this),
39
+ ...commonPrompt.desc(this),
40
+ /*
41
+ {
42
+ type: "input",
43
+ name: "xxx",
44
+ message: "Please input xxx?",
45
+ default: "",
46
+ },
47
+ */
48
+ ];
49
+
50
+ const answers = await mergePromptOrOption(prompts, (nextPrompts) =>
51
+ promptChain(promptChainLocator(nextPrompts))
52
+ );
53
+ handleAnswers(answers, payload => { say(payload) });
54
+ }
55
+
56
+ writing() {
57
+ this.env.options.nodePackageManager = "yarn";
58
+ const { cp, chMainName } = YoHelper(this);
59
+
60
+ // handle change to new folder
61
+ chMainName(this.mainName);
62
+
63
+ // handle copy file
64
+ }
65
+ };
@@ -0,0 +1,9 @@
1
+ # `<%= mainName %>`
2
+
3
+ > <%= description %>
4
+
5
+ ## Usage
6
+
7
+ ```
8
+
9
+ ```
@@ -0,0 +1,9 @@
1
+ # `library`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ npx yonpx reshow:library
9
+ ```
@@ -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("!! library !!", () => {
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,83 @@
1
+ const getYo = require("yo-reshow");
2
+ const { YoGenerator, YoHelper, commonPrompt } = getYo();
3
+
4
+ /**
5
+ * Library Generator
6
+ */
7
+
8
+ module.exports = class extends YoGenerator {
9
+ constructor(args, opts) {
10
+ super(args, opts);
11
+ this.argument("mainName", { type: String, required: false });
12
+ }
13
+
14
+ /**
15
+ * Run loop (Life cycle)
16
+ * https://yeoman.io/authoring/running-context.html#the-run-loop
17
+ *
18
+ * 1. initializing
19
+ * 2. prompting
20
+ * 3. configuring
21
+ * 4. default
22
+ * 5. writing
23
+ * 6. conflicts
24
+ * 7. install
25
+ * 8. end
26
+ */
27
+
28
+ /**
29
+ * Questions.
30
+ *
31
+ * https://www.alwaystwisted.com/post.php?s=using-lists-in-a-yeoman-generator
32
+ * https://github.com/SBoudrias/Inquirer.js
33
+ */
34
+ async prompting() {
35
+ this.env.options.nodePackageManager = "yarn";
36
+
37
+ const {
38
+ mergePromptOrOption,
39
+ promptChainLocator,
40
+ promptChain,
41
+ } = YoHelper(this);
42
+
43
+ const prompts = [
44
+ ...commonPrompt.mainName(this),
45
+ ...commonPrompt.desc(this),
46
+ ...commonPrompt.author(this),
47
+ ];
48
+
49
+ const answers = await mergePromptOrOption(
50
+ prompts,
51
+ (nextPrompts) => promptChain(promptChainLocator(nextPrompts))
52
+ );
53
+
54
+ this.mainName = answers.mainName;
55
+ this.payload = {
56
+ ...answers,
57
+ mainName: this.mainName,
58
+ description: answers.description || 'TODO: description',
59
+ keyword: answers.keyword || this.mainName,
60
+ };
61
+ }
62
+
63
+ writing() {
64
+ const { cp, chMainName } = YoHelper(this);
65
+
66
+ // handle change to new folder
67
+ chMainName(this.mainName);
68
+
69
+ // handle copy file
70
+ cp("README.md", null, this.payload);
71
+ cp("compile.sh", null, this.payload);
72
+ cp("package.json", null, this.payload);
73
+ cp("src", null, this.payload);
74
+ cp("Test.js", "src/__tests__/Test.js", this.payload);
75
+ }
76
+
77
+ end() {
78
+ if (!this.options?.skipInstall) {
79
+ const { say } = YoHelper(this);
80
+ say('Next you could try "npm run build" or "npm run test"');
81
+ }
82
+ }
83
+ };
@@ -0,0 +1,15 @@
1
+ # `<%= mainName %>`
2
+
3
+ > <%= description %>
4
+
5
+ ## Repositories
6
+ * GIT
7
+ * https://github.com/react-atomic/react-atomic-organism/tree/main/packages/lib/<%= mainName %>
8
+ * NPM
9
+ * https://www.npmjs.com/package/<%= mainName %>
10
+
11
+ ## Usage
12
+
13
+ ```
14
+
15
+ ```
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "<%= mainName %>",
3
+ "repository": {
4
+ "type": "git",
5
+ "url": "https://github.com/react-atomic/react-atomic-organism",
6
+ "directory": "packages/lib/<%= mainName %>"
7
+ },
8
+ "homepage": "https://github.com/react-atomic/react-atomic-organism/tree/main/packages/lib/<%= mainName %>",
9
+ "description": "<%= description %>",
10
+ "version": "0.0.0",
11
+ "main": "./build/cjs/src/index.js",
12
+ "module": "./build/es/src/index.js",
13
+ "keywords": [],
14
+ "author": "<%= authorName %> <<%= authorEmail %>>",
15
+ "license": "ISC",
16
+ "dependencies": {
17
+ "reshow-constant": "*"
18
+ },
19
+ "devDependencies": {
20
+ "@babel/cli": "^7.x",
21
+ "reshow-unit": "*"
22
+ },
23
+ "scripts": {
24
+ "clean": "find ./build -name '*.*' | xargs rm -rf",
25
+ "build:cjs": "BABEL_ENV=cjs babel src -d build/cjs/src --root-mode upward",
26
+ "build:es": "BABEL_ENV=es babel src -d build/es/src --root-mode upward",
27
+ "build": "npm run clean && npm run build:cjs && npm run build:es",
28
+ "mochaFor": "mocha -r jsdom-global/register",
29
+ "mocha": "npm run mochaFor -- 'build/cjs/**/__tests__/*.js'",
30
+ "test": "npm run build && npm run mocha",
31
+ "prepublishOnly": "npm run test"
32
+ },
33
+ "files": ["build", "package.json", "README.md"]
34
+ }
@@ -0,0 +1,9 @@
1
+ # `npm`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ npx yonpx reshow:npm
9
+ ```
@@ -0,0 +1,46 @@
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("!! npm !!", () => {
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
+ const {generator} = runResult;
43
+ // assert.fileContent('composer.json', 'foo-desc');
44
+ // assert.fileContent('.circleci/config.yml', 'foo');
45
+ });
46
+ });
@@ -0,0 +1,89 @@
1
+ const getYo = require("yo-reshow");
2
+ const { YoGenerator, YoHelper, commonPrompt } = getYo();
3
+
4
+ /**
5
+ * NPM Generator
6
+ */
7
+
8
+ module.exports = class extends YoGenerator {
9
+ /**
10
+ * Run loop (Life cycle)
11
+ * https://yeoman.io/authoring/running-context.html#the-run-loop
12
+ *
13
+ * 1. initializing
14
+ * 2. prompting
15
+ * 3. configuring
16
+ * 4. default
17
+ * 5. writing
18
+ * 6. conflicts
19
+ * 7. install
20
+ * 8. end
21
+ */
22
+
23
+ /**
24
+ * Questions.
25
+ *
26
+ * https://www.alwaystwisted.com/post.php?s=using-lists-in-a-yeoman-generator
27
+ * https://github.com/SBoudrias/Inquirer.js
28
+ */
29
+ async prompting() {
30
+ this.env.options.nodePackageManager = "yarn";
31
+
32
+ const {
33
+ handleAnswers,
34
+ mergePromptOrOption,
35
+ promptChainLocator,
36
+ promptChain,
37
+ } = YoHelper(this);
38
+
39
+ const prompts = [
40
+ ...commonPrompt.mainName(this),
41
+ ...commonPrompt.babel(this),
42
+ ...commonPrompt.desc(this),
43
+ ...commonPrompt.author(this),
44
+ ...commonPrompt.repository(this),
45
+ ];
46
+
47
+ const answers = await mergePromptOrOption(prompts, (nextPrompts) =>
48
+ promptChain(promptChainLocator(nextPrompts))
49
+ );
50
+ handleAnswers(answers);
51
+ this.composeWith(require.resolve("../compile-sh"), this.payload);
52
+ }
53
+
54
+ writing() {
55
+ const { cp, chMainName, updateJSON } = YoHelper(this);
56
+
57
+ // handle change to new folder
58
+ chMainName(this.mainName);
59
+
60
+ // handle copy file
61
+ cp("src", null, this.payload);
62
+ cp("README.md", null, this.payload);
63
+ cp("Test.js", "src/__tests__/Test.js", this.payload);
64
+
65
+ updateJSON("package.json", null, this.payload, (data) => {
66
+ data.repository = this.payload.repository;
67
+ data.homepage = this.payload.repositoryHomepage;
68
+ data.dependencies = {
69
+ ...data.dependencies,
70
+ ...this.payload.npmDependencies,
71
+ };
72
+ if (!this.payload.isUseBabel) {
73
+ delete data.devDependencies['@babel/cli'];
74
+ delete data.module;
75
+ delete data.scripts.clean;
76
+ delete data.scripts.build;
77
+ delete data.scripts["build:cjs"];
78
+ delete data.scripts["build:es"];
79
+ data.main = "./src/index.js";
80
+ data.bin[this.mainName] = "./src/index.js";
81
+ data.scripts.test = "npm run mocha";
82
+ data.files = data.files.filter(f => f !== "build");
83
+ data.files.push("src");
84
+ console.log({data});
85
+ }
86
+ return data;
87
+ });
88
+ }
89
+ };
@@ -0,0 +1,15 @@
1
+ # `<%= mainName %>`
2
+
3
+ > <%= description %>
4
+
5
+ ## Repository
6
+ * `GIT`
7
+ * <% repositoryHomepage %>
8
+ * `NPM`
9
+ * https://www.npmjs.com/package/<%= mainName %>
10
+
11
+ ## Usage
12
+
13
+ ```
14
+
15
+ ```
@@ -0,0 +1,34 @@
1
+ {
2
+ "version": "0.0.0",
3
+ "name": "<%= mainName %>",
4
+ "repository": {},
5
+ "homepage": "",
6
+ "description": "<%= description %>",
7
+ "keywords": [],
8
+ "author": "<%= authorName %> <<%= authorEmail %>>",
9
+ "license": "ISC",
10
+ "dependencies": {
11
+ "reshow-constant": "*"
12
+ },
13
+ "devDependencies": {
14
+ "@babel/cli": "^7.x",
15
+ "reshow-unit": "*"
16
+ },
17
+ "main": "./build/cjs/src/index.js",
18
+ "module": "./build/es/src/index.js",
19
+ "bin": {
20
+ "<%= mainName %>": "./build/cjs/src/index.js"
21
+ },
22
+ "scripts": {
23
+ "clean": "find ./build -name '*.*' | xargs rm -rf",
24
+ "build:cjs": "BABEL_ENV=cjs babel src -d build/cjs/src<%= babelRootMode %>",
25
+ "build:es": "BABEL_ENV=es babel src -d build/es/src<%= babelRootMode %>",
26
+ "build": "npm run clean && npm run build:cjs && npm run build:es",
27
+ "mochaFor": "mocha -r jsdom-global/register",
28
+ "mocha": "npm run mochaFor -- 'build/cjs/**/__tests__/*.js'",
29
+ "test": "npm run build && npm run mocha",
30
+ "prepublishOnly": "npm run test"
31
+ },
32
+ "files": ["build", "package.json", "README.md"],
33
+ "engines": { "node": ">=14" }
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-reshow",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "description": "Yeoman generator for reshow. (app, generator, ...etc)",
5
5
  "author": "Hill <hill@kimo.com>",
6
6
  "repository": {
@@ -16,6 +16,9 @@
16
16
  "dependencies": {
17
17
  "yo-reshow": "*"
18
18
  },
19
+ "devDependencies": {
20
+ "yo-unit": "*"
21
+ },
19
22
  "files": [
20
23
  "generators"
21
24
  ],
@@ -1,8 +0,0 @@
1
- import usePage from "../../src/usePage";
2
-
3
- const Atoms = (props) => {
4
- usePage({ ...props, pageName: "Atoms" });
5
- return <>This is atom</>;
6
- };
7
-
8
- export default Atoms;