generator-reshow 0.16.2 → 0.16.3

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.
@@ -9,8 +9,7 @@
9
9
  "keywords": ["app", "reshow-app"],
10
10
  "author": "",
11
11
  "license": "ISC",
12
- "dependencies": {},
13
- "devDependencies": {
12
+ "dependencies": {
14
13
  "get-object-value": "*",
15
14
  "organism-react-ajax": "*",
16
15
  "organism-react-navigation": "*",
@@ -1,13 +1,19 @@
1
- #!/bin/sh
1
+ #!/bin/bash
2
+
3
+ DIR=$( cd "$(dirname "$0")" ; pwd -P )
4
+ cd $DIR
5
+ SWJS=${DIR}/service-worker.js
2
6
 
3
7
  conf='{'
4
- conf+='"assetsRoot":"./assets/",'
5
- conf+='"externals":{"d3": "d3"},'
8
+ conf+='"assetsRoot":"/assets/",'
9
+ conf+='"externals":{},'
10
+ conf+='"indexTpl":"'${DIR}/index.tpl'",'
11
+ conf+='"indexHtml":"'${DIR}/index.html'",'
12
+ conf+='"swDest":"'${SWJS}'",'
13
+ # conf+='"swDebug":true,'
6
14
  conf+='"hotPort": "'${hotPort:-3088}'"'
7
15
  conf+='}'
8
16
 
9
- DIR=$( cd "$(dirname "$0")" ; pwd -P )
10
- cd $DIR
11
17
  OPEN=$(which xdg-open 2>/dev/null)
12
18
  if [ -z "$OPEN" ]; then
13
19
  OPEN="open"
@@ -25,26 +31,16 @@ checkBabel(){
25
31
  fi
26
32
  }
27
33
 
28
- production(){
29
- echo "Production Mode";
30
- checkBabel
31
- npm run build
32
- CONFIG=$conf NODE_ENV=production $webpack
33
- }
34
-
35
- analyzer(){
36
- echo "Analyzer Mode";
37
- checkBabel
38
- npm run build
39
- CONFIG=$conf BUNDLE='{}' $webpack
34
+ killBy(){
35
+ ps -eo pid,args | grep $1 | grep -v grep | awk '{print $1}' | xargs -I{} kill -9 {}
40
36
  }
41
37
 
42
- develop(){
43
- stop
44
- echo "Develop Mode";
45
- checkBabel
46
- npm run build
47
- CONFIG=$conf $webpack
38
+ stop(){
39
+ killBy ${DIR}/node_modules/.bin/babel
40
+ cat webpack.pid | xargs -I{} kill -9 {}
41
+ npm run clean
42
+ rm $SWJS
43
+ echo "Stop done";
48
44
  }
49
45
 
50
46
  stopServer(){
@@ -69,23 +65,36 @@ startServer(){
69
65
  fi
70
66
  }
71
67
 
72
- killBy(){
73
- ps -eo pid,args | grep $1 | grep -v grep | awk '{print $1}' | xargs -I{} kill -9 {}
68
+ production(){
69
+ stop
70
+ echo "Production Mode";
71
+ checkBabel
72
+ npm run build
73
+ ENABLE_SW=1 CONFIG=$conf NODE_ENV=production $webpack
74
74
  }
75
75
 
76
- stop(){
77
- killBy ${DIR}/node_modules/.bin/babel
78
- cat webpack.pid | xargs -I{} kill -9 {}
79
- npm run clean
80
- echo "Stop done";
76
+ analyzer(){
77
+ stop
78
+ echo "Analyzer Mode";
79
+ checkBabel
80
+ npm run build
81
+ CONFIG=$conf BUNDLE='{}' $webpack
82
+ }
83
+
84
+ develop(){
85
+ stop
86
+ echo "Develop Mode";
87
+ checkBabel
88
+ npm run build
89
+ CONFIG=$conf $webpack
81
90
  }
82
91
 
83
92
  watch(){
84
93
  stop
85
94
  echo "Watch Mode";
86
95
  checkBabel
87
- npm run build:ui -- --watch &
88
- npm run build:src -- --watch &
96
+ npm run build:es:ui -- --watch &
97
+ npm run build:es:src -- --watch &
89
98
  sleep 10
90
99
  CONFIG=$conf $webpack --watch &
91
100
  }
@@ -94,16 +103,17 @@ watchTest(){
94
103
  stop
95
104
  echo "Watch Test";
96
105
  checkBabel
97
- npm run build:test:ui -- --watch &
98
- npm run build:test:src -- --watch &
106
+ npm run build:cjs:ui -- --watch &
107
+ npm run build:cjs:src -- --watch &
99
108
  }
100
109
 
101
110
  hot(){
102
- stop
111
+ stop
112
+ rm $SWJS
103
113
  echo "Hot Mode";
104
114
  checkBabel
105
- npm run build:ui -- --watch &
106
- npm run build:src -- --watch &
115
+ npm run build:es:ui -- --watch &
116
+ npm run build:es:src -- --watch &
107
117
  sleep 5
108
118
  HOT_UPDATE=1 CONFIG=$conf $webpack serve &
109
119
  }
@@ -116,7 +126,7 @@ case "$1" in
116
126
  analyzer
117
127
  ;;
118
128
  s)
119
- startServer $2
129
+ startServer $2
120
130
  ;;
121
131
  ss)
122
132
  stopServer
@@ -37,6 +37,22 @@ module.exports = class extends YoGenerator {
37
37
  const prompts = [
38
38
  ...commonPrompt.mainName(this),
39
39
  ...commonPrompt.desc(this),
40
+ ...commonPrompt.repository(this, {
41
+ defaultRepositoryName: "[REPOSITORY_NAME]",
42
+ defaultRepositoryOrgName: "[REPOSITORY_ORG_NAME]",
43
+ }),
44
+ {
45
+ type: "input",
46
+ name: "dockerImageName",
47
+ message: "Please input your docker-image-name?",
48
+ default: "[DOCKER_IMAGE_NAME]",
49
+ },
50
+ {
51
+ type: "input",
52
+ name: "dockerOrgName",
53
+ message: "Please input your docker-org-name?",
54
+ default: "[DOCKER_ORG_NAME]",
55
+ },
40
56
  {
41
57
  type: "input",
42
58
  name: "folderPrefix",
@@ -1,3 +1,6 @@
1
+ [![CircleCI](https://circleci.com/gh/<%= repositoryOrgName %>/<%= repositoryName %>/tree/main.svg?style=svg)](https://circleci.com/gh/<%= repositoryOrgName %>/<%= repositoryName %>/tree/main)
2
+ [![Docker Pulls](https://img.shields.io/docker/pulls/<%= dockerOrgName %>/<%= dockerImageName %>.svg)](https://hub.docker.com/r/<%= dockerOrgName %>/<%= dockerImageName %>)
3
+
1
4
  # `<%= mainName %>`
2
5
 
3
6
  > <%= description %>
@@ -2,8 +2,6 @@ version: 2.1
2
2
 
3
3
  executors:
4
4
  docker-publisher:
5
- environment:
6
- IMAGE_NAME: <%= mainName %>
7
5
  docker:
8
6
  - image: circleci/buildpack-deps:18.04
9
7
 
@@ -33,6 +31,7 @@ jobs:
33
31
  name: build Docker image
34
32
  command: |
35
33
  VERSION=$(support/VERSION.sh)
34
+ IMAGE_NAME=$(support/targetImage.sh)
36
35
  BUILD_VERSION=<< parameters.docker-tag >>
37
36
  BUILD_FOLDER=<< parameters.folder-prefix >><< parameters.docker-tag >>
38
37
  BUILD_ARG=""
@@ -42,16 +42,20 @@ push() {
42
42
  fi
43
43
  fi
44
44
  echo "* <!-- Start to push ${targetImage}:$tag"
45
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_LOGIN" --password-stdin
45
+ IS_LOGIN=$(echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_LOGIN" --password-stdin)
46
+ if ! [[ $IS_LOGIN =~ "Succeeded" ]]; then
47
+ echo "Login Failed."
48
+ exit 1
49
+ fi
46
50
  docker push ${targetImage}:$tag
47
- echo "* Finish to push -->"
51
+ echo "* Finish pushed -->"
48
52
  echo ""
49
53
  if [ ! -z "$1" ]; then
50
54
  if [ "x$VERSION" == "x$PUSH_VERSION" ]; then
51
55
  echo "* <!-- Start to auto push ${targetImage}:${LATEST_TAG}"
52
56
  docker tag ${targetImage}:$tag ${targetImage}:${LATEST_TAG}
53
57
  docker push ${targetImage}:${LATEST_TAG}
54
- echo "* Finish to push -->"
58
+ echo "* Finish pushed -->"
55
59
  fi
56
60
  fi
57
61
  }
@@ -67,7 +71,7 @@ build() {
67
71
  BUILD_ARG="$BUILD_ARG --build-arg VERSION=${VERSION}"
68
72
  fi
69
73
  echo build: ${DIR}/${DOCKER_FILE}
70
- if [ -z "$NO_CACHE" ]; then
74
+ if [ "x" != "x$NO_CACHE" ]; then
71
75
  echo nocache: ${NO_CACHE}
72
76
  fi
73
77
  docker build ${BUILD_ARG} ${NO_CACHE} -f ${DIR}/${DOCKER_FILE} -t $sourceImage ${DIR}
@@ -29,9 +29,7 @@ module.exports = class extends YoGenerator {
29
29
  const {
30
30
  say,
31
31
  handleAnswers,
32
- mergePromptOrOption,
33
- promptChainLocator,
34
- promptChain,
32
+ promptChainAll,
35
33
  } = YoHelper(this);
36
34
 
37
35
  const prompts = [
@@ -47,14 +45,13 @@ module.exports = class extends YoGenerator {
47
45
  */
48
46
  ];
49
47
 
50
- const answers = await mergePromptOrOption(prompts, (nextPrompts) =>
51
- promptChain(promptChainLocator(nextPrompts))
52
- );
48
+ const answers = await promptChainAll(prompts);
53
49
  handleAnswers(answers);
54
50
  }
55
51
 
56
52
  writing() {
57
53
  this.env.options.nodePackageManager = "yarn";
54
+ this.options.skipInstall = true;
58
55
  const { cp, chMainName } = YoHelper(this);
59
56
 
60
57
  // handle change to new folder
@@ -59,7 +59,7 @@ module.exports = class extends YoGenerator {
59
59
  cp("package.json", null, this.payload);
60
60
  cp("src", null, this.payload);
61
61
  cp("Test.js", "src/__tests__/Test.js", this.payload);
62
- cp("yarn.lock");
62
+ // cp("yarn.lock");
63
63
  }
64
64
 
65
65
  end() {
@@ -0,0 +1,10 @@
1
+ import { expect } from "chai";
2
+
3
+ import YourFunc from "../index";
4
+
5
+ describe("Test <%= mainName %>", () => {
6
+ it("basic testt", () => {
7
+ /*your test code*/
8
+ YourFunc();
9
+ });
10
+ });
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ npm run build
@@ -0,0 +1,3 @@
1
+ const YourFunc = (props) => {};
2
+
3
+ export default YourFunc;
@@ -63,7 +63,7 @@ module.exports = class extends YoGenerator {
63
63
  cp("src", null, this.payload);
64
64
  cp("README.md", null, this.payload);
65
65
  cp("Test.js", "src/__tests__/Test.js", this.payload);
66
- cp("yarn.lock");
66
+ // cp("yarn.lock");
67
67
 
68
68
  updateJSON("package.json", null, this.payload, (data) => {
69
69
  data.repository = this.payload.repository;
@@ -0,0 +1,10 @@
1
+ const {expect} = require("chai");
2
+ const {init} = require("../init");
3
+
4
+ describe("Test <%= mainName %>", () => {
5
+ it("basic testt", () => {
6
+ /*your test code*/
7
+ const actual = init();
8
+ expect(actual).to.equal('bar');
9
+ });
10
+ });
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { init } = require("./init");
4
+
5
+ init();
@@ -0,0 +1,8 @@
1
+ const init = (props) => {
2
+ console.log("foo");
3
+ return "bar";
4
+ };
5
+
6
+ module.exports = {
7
+ init,
8
+ };
@@ -0,0 +1,9 @@
1
+ # `update-esm-export`
2
+
3
+ > update exm export
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ npx yonpx update-esm-export
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("!! update-esm-export !!", () => {
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,91 @@
1
+ const getYo = require("yo-reshow");
2
+ const { KEYS } = require("reshow-constant");
3
+ const { YoGenerator, YoHelper, commonPrompt } = getYo();
4
+
5
+ /**
6
+ * update-esm-export Generator
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
+ const {
31
+ say,
32
+ exit,
33
+ isFile,
34
+ getDotYo,
35
+ glob,
36
+ updateJSON,
37
+ } = YoHelper(this);
38
+ const pkg = isFile("package.json");
39
+
40
+ const opts = getDotYo();
41
+ if (!opts.exports) {
42
+ return;
43
+ }
44
+ const { srcArr, appendArr, prependArr, moreKeyArr, moreValArr, pkgjson } =
45
+ opts.exports;
46
+ const nextExports = {};
47
+ srcArr.forEach((v, index) => {
48
+ const prepend = prependArr[index];
49
+ const append = appendArr[index];
50
+ glob(
51
+ v,
52
+ ({ filename }) => {
53
+ nextExports[
54
+ `${prepend}${filename}`
55
+ ] = `${prepend}${filename}${append}`;
56
+ },
57
+ true
58
+ );
59
+ });
60
+ moreKeyArr?.forEach((v, index) => {
61
+ nextExports[v] = moreValArr[index];
62
+ });
63
+
64
+ const pkgFile = isFile(pkgjson);
65
+ if (pkgFile) {
66
+ updateJSON(null, pkgFile, null, ({ exports, ...json }) => {
67
+ if (this.options.n) {
68
+ const diff = {};
69
+ KEYS(exports).forEach((key) => {
70
+ if (exports[key] !== nextExports[key]) {
71
+ diff[key] = {
72
+ prev: exports[key],
73
+ next: nextExports[key]
74
+ };
75
+ }
76
+ delete exports[key];
77
+ });
78
+ const allDiff = {...diff, ...exports};
79
+ this.log({allDiff});
80
+ return null;
81
+ } else {
82
+ json.exports = nextExports;
83
+ return json;
84
+ }
85
+ });
86
+ }
87
+
88
+ }
89
+
90
+ writing() {}
91
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-reshow",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "description": "Yeoman generator for reshow. (app, generator, ...etc)",
5
5
  "author": "Hill <hill@kimo.com>",
6
6
  "repository": {
@@ -1,8 +0,0 @@
1
- node_modules
2
- npm-debug.log
3
- coverage*
4
- .tern-port
5
- v8.log
6
- build
7
- .*.sw?
8
- webpack.pid