generator-reshow 0.17.17 → 0.17.20

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 CHANGED
@@ -9,3 +9,9 @@ npx yonpx reshow my-app
9
9
  cd my-app
10
10
  npm start
11
11
  ```
12
+
13
+ ## GIT
14
+ https://github.com/react-atomic/reshow/tree/main/packages/generator-reshow
15
+
16
+ ## NPM
17
+ https://www.npmjs.com/package/generator-reshow
@@ -1,8 +1,12 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
- DIR=$( cd "$(dirname "$0")" ; pwd -P )
3
+ DIR=$(
4
+ cd "$(dirname "$0")"
5
+ pwd -P
6
+ )
4
7
  cd $DIR
5
8
  SWJS=${DIR}/service-worker.js
9
+ webpackEnabled=$(awk -F "=" '/^webpackEnabled/ {print $2}' $DIR/.yo)
6
10
 
7
11
  conf='{'
8
12
  conf+='"assetsRoot":"/assets/",'
@@ -14,16 +18,16 @@ conf+='"swDest":"'${SWJS}'",'
14
18
  conf+='"hotPort": "'${hotPort:-3088}'"'
15
19
  conf+='}'
16
20
 
17
- OPEN=$(which xdg-open 2>/dev/null)
18
- if [ -z "$OPEN" ]; then
21
+ OPEN=$(which xdg-open 2> /dev/null)
22
+ if [ -z "$OPEN" ]; then
19
23
  OPEN="open"
20
24
  fi
21
25
 
22
- if [ "x<%= webpackEnabled %>" == "xon" ]; then
26
+ if [ "x$webpackEnabled" == "xon" ]; then
23
27
  webpack='npm run webpack --'
24
28
  fi
25
29
 
26
- checkBabel(){
30
+ checkBabel() {
27
31
  if [ ! -e ".babelrc" ] && [ ! -e "../../packages" ]; then
28
32
  if [ -e ${DIR}/node_modules/reshow-app/.babelrc ]; then
29
33
  cp ${DIR}/node_modules/reshow-app/.babelrc ${DIR}/.babelrc
@@ -31,91 +35,84 @@ checkBabel(){
31
35
  fi
32
36
  }
33
37
 
34
- killBy(){
35
- ps -eo pid,args | grep $1 | grep -v grep | awk '{print $1}' | xargs -I{} kill -9 {}
38
+ killBy() {
39
+ ps -eo pid,args | grep $1 | grep -v grep | awk '{print $1}' | xargs -I{} kill -9 {}
36
40
  }
37
41
 
38
- stop(){
39
- killBy ${DIR}/node_modules/.bin/babel
42
+ stop() {
43
+ killBy ${DIR}/node_modules/.bin/babel
44
+ if [ ! -z "$webpack" ]; then
40
45
  cat webpack.pid | xargs -I{} kill -9 {}
41
- npm run clean
42
- rm $SWJS
43
- echo "Stop done";
46
+ npm run clean:webpack
47
+ fi
48
+ rm $SWJS
49
+ echo "Stop done"
44
50
  }
45
51
 
46
- stopServer(){
52
+ stopServer() {
47
53
  killBy ${DIR}/node_modules/.bin/ws
48
- echo "stop server done";
54
+ echo "stop server done"
49
55
  }
50
56
 
51
- startServer(){
52
- stopServer
53
- yarn
54
- if [ ! -e "build" ]; then
55
- develop
56
- fi
57
- port=${port-3000}
58
- echo "Start server";
59
- if [ "$1" == "open" ]; then
60
- npm run start -- -p $port &
61
- sleep 3
62
- $OPEN http://localhost:$port
63
- else
64
- npm run start -- -p $port -v
65
- fi
57
+ startServer() {
58
+ stopServer
59
+ yarn
60
+ if [ ! -e "build" ]; then
61
+ develop
62
+ fi
63
+ port=${port-3000}
64
+ echo "Start server"
65
+ if [ "$1" == "open" ]; then
66
+ npm run start -- -p $port &
67
+ sleep 3
68
+ $OPEN http://localhost:$port
69
+ else
70
+ npm run start -- -p $port -v
71
+ fi
66
72
  }
67
73
 
68
- production(){
69
- stop
70
- echo "Production Mode";
71
- checkBabel
72
- npm run build
74
+ production() {
75
+ stop
76
+ echo "Production Mode"
77
+ checkBabel
78
+ npm run build
79
+ if [ ! -z "$webpack" ]; then
73
80
  ENABLE_SW=1 CONFIG=$conf NODE_ENV=production $webpack
81
+ fi
74
82
  }
75
83
 
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
84
+ analyzer() {
85
+ stop
86
+ echo "Analyzer Mode"
87
+ checkBabel
88
+ npm run build
89
+ [ ! -z "$webpack" ] && CONFIG=$conf BUNDLE='{}' $webpack
90
90
  }
91
91
 
92
- watch(){
93
- stop
94
- echo "Watch Mode";
95
- checkBabel
96
- npm run build:es:ui -- --watch &
97
- npm run build:es:src -- --watch &
98
- sleep 10
99
- CONFIG=$conf $webpack --watch &
92
+ develop() {
93
+ stop
94
+ echo "Develop Mode"
95
+ checkBabel
96
+ npm run build
97
+ [ ! -z "$webpack" ] && CONFIG=$conf $webpack
100
98
  }
101
99
 
102
- watchTest(){
103
- stop
104
- echo "Watch Test";
105
- checkBabel
106
- npm run build:cjs:ui -- --watch &
107
- npm run build:cjs:src -- --watch &
100
+ watch() {
101
+ stop
102
+ echo "Watch Mode"
103
+ checkBabel
104
+ npm run build:es:ui -- --watch &
105
+ npm run build:es:src -- --watch &
108
106
  }
109
107
 
110
- hot(){
111
- stop
112
- rm $SWJS
113
- echo "Hot Mode";
114
- checkBabel
115
- npm run build:es:ui -- --watch &
116
- npm run build:es:src -- --watch &
117
- sleep 5
118
- HOT_UPDATE=1 CONFIG=$conf $webpack serve &
108
+ hot() {
109
+ stop
110
+ rm $SWJS
111
+ echo "Hot Mode"
112
+ checkBabel
113
+ npm run build:es:ui -- --watch &
114
+ npm run build:es:src -- --watch &
115
+ [ ! -z "$webpack" ] && sleep 10 && HOT_UPDATE=1 CONFIG=$conf $webpack serve &
119
116
  }
120
117
 
121
118
  case "$1" in
@@ -123,7 +120,7 @@ case "$1" in
123
120
  production
124
121
  ;;
125
122
  a)
126
- analyzer
123
+ analyzer
127
124
  ;;
128
125
  s)
129
126
  startServer $2
@@ -135,17 +132,15 @@ case "$1" in
135
132
  hot
136
133
  ;;
137
134
  watch)
138
- watch
139
- ;;
140
- watchTest)
141
- watchTest
135
+ watch
142
136
  ;;
143
137
  stop)
144
- stop
138
+ stop
145
139
  ;;
146
140
  *)
147
141
  develop
148
142
  exit
143
+ ;;
149
144
  esac
150
145
 
151
146
  exit $?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-reshow",
3
- "version": "0.17.17",
3
+ "version": "0.17.20",
4
4
  "description": "Yeoman generator for reshow. (app, generator, ...etc)",
5
5
  "author": "Hill <hill@kimo.com>",
6
6
  "repository": {