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.
- package/generators/app/templates/package.json +1 -2
- package/generators/compile-sh/templates/compile.sh +48 -38
- package/generators/docker/index.js +16 -0
- package/generators/docker/templates/README.md +3 -0
- package/generators/docker/templates/_circleci/config.yml +1 -2
- package/generators/docker/templates/compile.sh +8 -4
- package/generators/generator/templates/index.js +3 -6
- package/generators/library/index.js +1 -1
- package/generators/library/templates/Test.js +10 -0
- package/generators/library/templates/compile.sh +3 -0
- package/generators/library/templates/src/index.js +3 -0
- package/generators/npm/index.js +1 -1
- package/generators/npm/templates/Test.js +10 -0
- package/generators/npm/templates/src/index.js +5 -0
- package/generators/npm/templates/src/init.js +8 -0
- package/generators/update-esm-export/README.md +9 -0
- package/generators/update-esm-export/__tests__/Test.js +45 -0
- package/generators/update-esm-export/index.js +91 -0
- package/package.json +1 -1
- package/generators/app/templates/.gitignore +0 -8
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
#!/bin/
|
|
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":"
|
|
5
|
-
conf+='"externals":{
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
73
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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:
|
|
98
|
-
npm run build:
|
|
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
|
+
[](https://circleci.com/gh/<%= repositoryOrgName %>/<%= repositoryName %>/tree/main)
|
|
2
|
+
[](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
|
|
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
|
|
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 [
|
|
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
|
-
|
|
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
|
|
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
|
package/generators/npm/index.js
CHANGED
|
@@ -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,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