generator-reshow 0.16.1 → 0.16.4
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/README.md +9 -0
- package/generators/docker/__tests__/Test.js +45 -0
- package/generators/docker/index.js +100 -0
- package/generators/docker/templates/.env.build +4 -0
- package/generators/docker/templates/Dockerfile +9 -0
- package/generators/docker/templates/README.md +12 -0
- package/generators/docker/templates/_circleci/config.yml +52 -0
- package/generators/docker/templates/_gitignore +3 -0
- package/generators/docker/templates/build.sh +22 -0
- package/generators/docker/templates/compile.sh +123 -0
- package/generators/docker/templates/enter +24 -0
- package/generators/docker/templates/install-packages.sh +24 -0
- package/generators/docker/templates/support/FOLDER_PREFIX.sh +8 -0
- package/generators/docker/templates/support/VERSION.sh +8 -0
- package/generators/docker/templates/support/sourceImage.sh +8 -0
- package/generators/docker/templates/support/targetImage.sh +8 -0
- package/generators/generator/templates/index.js +4 -7
- 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 +90 -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
|
|
@@ -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("!! docker !!", () => {
|
|
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,100 @@
|
|
|
1
|
+
const getYo = require("yo-reshow");
|
|
2
|
+
const { YoGenerator, YoHelper, commonPrompt } = getYo();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* docker 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
|
+
...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
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: "input",
|
|
58
|
+
name: "folderPrefix",
|
|
59
|
+
message: "Please input your folder-prefix?",
|
|
60
|
+
default: "",
|
|
61
|
+
},
|
|
62
|
+
/*
|
|
63
|
+
{
|
|
64
|
+
type: "input",
|
|
65
|
+
name: "xxx",
|
|
66
|
+
message: "Please input xxx?",
|
|
67
|
+
default: "",
|
|
68
|
+
},
|
|
69
|
+
*/
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
const answers = await mergePromptOrOption(prompts, (nextPrompts) =>
|
|
73
|
+
promptChain(promptChainLocator(nextPrompts))
|
|
74
|
+
);
|
|
75
|
+
handleAnswers(answers);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
writing() {
|
|
79
|
+
this.payload.folderPrefixGitIgnore = this.payload.folderPrefix
|
|
80
|
+
? this.payload.folderPrefix + "*"
|
|
81
|
+
: "";
|
|
82
|
+
|
|
83
|
+
this.env.options.nodePackageManager = "yarn";
|
|
84
|
+
const { cp, chMainName } = YoHelper(this);
|
|
85
|
+
|
|
86
|
+
// handle change to new folder
|
|
87
|
+
chMainName();
|
|
88
|
+
|
|
89
|
+
// handle copy file
|
|
90
|
+
cp(".env.build", null, this.payload);
|
|
91
|
+
cp("Dockerfile", null, this.payload);
|
|
92
|
+
cp("README.md", null, this.payload);
|
|
93
|
+
cp("_circleci", ".circleci", this.payload);
|
|
94
|
+
cp("_gitignore", ".gitignore", this.payload);
|
|
95
|
+
cp("build.sh", null, this.payload);
|
|
96
|
+
cp("compile.sh", null, this.payload);
|
|
97
|
+
cp("install-packages.sh", null, this.payload);
|
|
98
|
+
cp("support", null, this.payload);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[](https://circleci.com/gh/<%= repositoryOrgName %>/<%= repositoryName %>/tree/main)
|
|
2
|
+
[](https://hub.docker.com/r/<%= dockerOrgName %>/<%= dockerImageName %>)
|
|
3
|
+
|
|
4
|
+
# `<%= mainName %>`
|
|
5
|
+
|
|
6
|
+
> <%= description %>
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
|
|
3
|
+
executors:
|
|
4
|
+
docker-publisher:
|
|
5
|
+
docker:
|
|
6
|
+
- image: circleci/buildpack-deps:18.04
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build-and-publish:
|
|
10
|
+
parameters:
|
|
11
|
+
docker-tag:
|
|
12
|
+
type: string
|
|
13
|
+
folder-prefix:
|
|
14
|
+
type: string
|
|
15
|
+
default: "<%= folderPrefix %>"
|
|
16
|
+
executor: docker-publisher
|
|
17
|
+
steps:
|
|
18
|
+
- checkout
|
|
19
|
+
- setup_remote_docker:
|
|
20
|
+
version: 20.10.7
|
|
21
|
+
docker_layer_caching: true
|
|
22
|
+
- run:
|
|
23
|
+
name: Log time
|
|
24
|
+
command: date
|
|
25
|
+
- run:
|
|
26
|
+
name: Gen Docker file
|
|
27
|
+
command: |
|
|
28
|
+
./build.sh << parameters.docker-tag >>
|
|
29
|
+
ls -la << parameters.folder-prefix >><< parameters.docker-tag >>
|
|
30
|
+
- run:
|
|
31
|
+
name: build Docker image
|
|
32
|
+
command: |
|
|
33
|
+
VERSION=$(support/VERSION.sh)
|
|
34
|
+
IMAGE_NAME=$(support/targetImage.sh)
|
|
35
|
+
BUILD_VERSION=<< parameters.docker-tag >>
|
|
36
|
+
BUILD_FOLDER=<< parameters.folder-prefix >><< parameters.docker-tag >>
|
|
37
|
+
BUILD_ARG=""
|
|
38
|
+
docker build ${BUILD_ARG} -f ${BUILD_FOLDER}/Dockerfile \
|
|
39
|
+
-t $IMAGE_NAME:${BUILD_VERSION} \
|
|
40
|
+
./${BUILD_FOLDER}
|
|
41
|
+
- run:
|
|
42
|
+
name: Publish Docker Image to Docker Hub
|
|
43
|
+
command: |
|
|
44
|
+
./compile.sh p << parameters.docker-tag >>
|
|
45
|
+
|
|
46
|
+
workflows:
|
|
47
|
+
run-job:
|
|
48
|
+
jobs:
|
|
49
|
+
- build-and-publish:
|
|
50
|
+
matrix:
|
|
51
|
+
parameters:
|
|
52
|
+
docker-tag: ["0.0"]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
DIR="$(
|
|
4
|
+
cd "$(dirname "$0")"
|
|
5
|
+
pwd -P
|
|
6
|
+
)"
|
|
7
|
+
|
|
8
|
+
FOLDER_PREFIX=$(${DIR}/support/FOLDER_PREFIX.sh)
|
|
9
|
+
|
|
10
|
+
do_build() {
|
|
11
|
+
SED_REPLACE_VER=$1
|
|
12
|
+
DEST_FOLDER=${DIR}/${FOLDER_PREFIX}${SED_REPLACE_VER}
|
|
13
|
+
mkdir -p ${DEST_FOLDER}
|
|
14
|
+
echo "building --- Version: " $SED_REPLACE_VER "-->"
|
|
15
|
+
DEST_FILE=${DEST_FOLDER}/Dockerfile
|
|
16
|
+
cp Dockerfile ${DEST_FILE}
|
|
17
|
+
cp install-packages.sh ${DEST_FOLDER}
|
|
18
|
+
sed -i -e "s|\[VERSION\]|$SED_REPLACE_VER|g" ${DEST_FILE}
|
|
19
|
+
if [ -e "${DEST_FILE}-e" ]; then rm ${DEST_FILE}-e; fi
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
do_build $1
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
DIR="$(
|
|
4
|
+
cd "$(dirname "$0")"
|
|
5
|
+
pwd -P
|
|
6
|
+
)"
|
|
7
|
+
sourceImage=$(${DIR}/support/sourceImage.sh)
|
|
8
|
+
targetImage=$(${DIR}/support/targetImage.sh)
|
|
9
|
+
archiveFile=$DIR/archive.tar
|
|
10
|
+
VERSION=$(${DIR}/support/VERSION.sh)
|
|
11
|
+
DOCKER_FILE=${DOCKER_FILE:-Dockerfile}
|
|
12
|
+
|
|
13
|
+
list() {
|
|
14
|
+
docker images | head -10
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
tag() {
|
|
18
|
+
tag=$1
|
|
19
|
+
if [ -z "$tag" ]; then
|
|
20
|
+
if [ -z "$VERSION" ]; then
|
|
21
|
+
tag=latest
|
|
22
|
+
else
|
|
23
|
+
tag=$VERSION
|
|
24
|
+
fi
|
|
25
|
+
fi
|
|
26
|
+
echo "* <!-- Start to tag: ${tag}"
|
|
27
|
+
echo $tag
|
|
28
|
+
docker tag $sourceImage ${targetImage}:$tag
|
|
29
|
+
list
|
|
30
|
+
echo "* Finish tag -->"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
push() {
|
|
34
|
+
PUSH_VERSION=${1:-$VERSION}
|
|
35
|
+
LATEST_TAG=${2:-latest}
|
|
36
|
+
if [ -z "$PUSH_VERSION" ]; then
|
|
37
|
+
tag=latest
|
|
38
|
+
else
|
|
39
|
+
tag=$PUSH_VERSION
|
|
40
|
+
if [ "x$LATEST_TAG" != "xlatest" ]; then
|
|
41
|
+
tag=$LATEST_TAG-$PUSH_VERSION
|
|
42
|
+
fi
|
|
43
|
+
fi
|
|
44
|
+
echo "* <!-- Start to push ${targetImage}:$tag"
|
|
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
|
|
50
|
+
docker push ${targetImage}:$tag
|
|
51
|
+
echo "* Finish pushed -->"
|
|
52
|
+
echo ""
|
|
53
|
+
if [ ! -z "$1" ]; then
|
|
54
|
+
if [ "x$VERSION" == "x$PUSH_VERSION" ]; then
|
|
55
|
+
echo "* <!-- Start to auto push ${targetImage}:${LATEST_TAG}"
|
|
56
|
+
docker tag ${targetImage}:$tag ${targetImage}:${LATEST_TAG}
|
|
57
|
+
docker push ${targetImage}:${LATEST_TAG}
|
|
58
|
+
echo "* Finish pushed -->"
|
|
59
|
+
fi
|
|
60
|
+
fi
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
build() {
|
|
64
|
+
if [ -z "$1" ]; then
|
|
65
|
+
NO_CACHE=""
|
|
66
|
+
else
|
|
67
|
+
NO_CACHE="--no-cache"
|
|
68
|
+
fi
|
|
69
|
+
BUILD_ARG=""
|
|
70
|
+
if [ ! -z "$VERSION" ]; then
|
|
71
|
+
BUILD_ARG="$BUILD_ARG --build-arg VERSION=${VERSION}"
|
|
72
|
+
fi
|
|
73
|
+
echo build: ${DIR}/${DOCKER_FILE}
|
|
74
|
+
if [ "x" != "x$NO_CACHE" ]; then
|
|
75
|
+
echo nocache: ${NO_CACHE}
|
|
76
|
+
fi
|
|
77
|
+
docker build ${BUILD_ARG} ${NO_CACHE} -f ${DIR}/${DOCKER_FILE} -t $sourceImage ${DIR}
|
|
78
|
+
list
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
save() {
|
|
82
|
+
echo save
|
|
83
|
+
docker save $sourceImage > $archiveFile
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
restore() {
|
|
87
|
+
echo restore
|
|
88
|
+
docker save --output $archiveFile $sourceImage
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
case "$1" in
|
|
92
|
+
save)
|
|
93
|
+
save
|
|
94
|
+
;;
|
|
95
|
+
restore)
|
|
96
|
+
restore
|
|
97
|
+
;;
|
|
98
|
+
p)
|
|
99
|
+
push $2 $3
|
|
100
|
+
;;
|
|
101
|
+
t)
|
|
102
|
+
tag $2
|
|
103
|
+
;;
|
|
104
|
+
nocache)
|
|
105
|
+
build --no-cache
|
|
106
|
+
;;
|
|
107
|
+
auto)
|
|
108
|
+
build
|
|
109
|
+
tag
|
|
110
|
+
;;
|
|
111
|
+
b)
|
|
112
|
+
build
|
|
113
|
+
;;
|
|
114
|
+
l)
|
|
115
|
+
list
|
|
116
|
+
;;
|
|
117
|
+
*)
|
|
118
|
+
echo "$0 [save|restore|p|t|nocache|auto|b|l]"
|
|
119
|
+
exit
|
|
120
|
+
;;
|
|
121
|
+
esac
|
|
122
|
+
|
|
123
|
+
exit $?
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
DIR="$(
|
|
4
|
+
cd "$(dirname "$0")"
|
|
5
|
+
pwd -P
|
|
6
|
+
)"
|
|
7
|
+
VERSION=${VERSION:-latest}
|
|
8
|
+
SOURCE_IMAGE=$(${DIR}/support/sourceImage.sh)
|
|
9
|
+
|
|
10
|
+
C=''
|
|
11
|
+
for i in "$@"; do
|
|
12
|
+
i="${i//\\/\\\\}"
|
|
13
|
+
C="$C \"${i//\"/\\\"}\""
|
|
14
|
+
done
|
|
15
|
+
|
|
16
|
+
pid=$$
|
|
17
|
+
|
|
18
|
+
cli='env docker run --rm -it'
|
|
19
|
+
cli+=" -v $DIR:$DIR"
|
|
20
|
+
cli+=" -w $DIR"
|
|
21
|
+
cli+=" --name ${SOURCE_IMAGE}-${pid} ${SOURCE_IMAGE}:${VERSION}"
|
|
22
|
+
cli+=" sh ${C}"
|
|
23
|
+
|
|
24
|
+
bash -c "$cli"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
INSTALL=""
|
|
4
|
+
|
|
5
|
+
BUILD_DEPS=""
|
|
6
|
+
|
|
7
|
+
echo "###"
|
|
8
|
+
echo "# Will install"
|
|
9
|
+
echo "###"
|
|
10
|
+
echo ""
|
|
11
|
+
echo $INSTALL
|
|
12
|
+
echo ""
|
|
13
|
+
echo "###"
|
|
14
|
+
echo "# Will build package"
|
|
15
|
+
echo "###"
|
|
16
|
+
echo ""
|
|
17
|
+
echo $BUILD_DEPS
|
|
18
|
+
echo ""
|
|
19
|
+
|
|
20
|
+
apk add --virtual .build-deps $BUILD_DEPS && apk add $INSTALL
|
|
21
|
+
|
|
22
|
+
apk del -f .build-deps && rm -rf /var/cache/apk/* || exit 1
|
|
23
|
+
|
|
24
|
+
exit 0
|
|
@@ -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
|
-
|
|
52
|
-
);
|
|
53
|
-
handleAnswers(answers, payload => { say(payload) });
|
|
48
|
+
const answers = await promptChainAll(prompts);
|
|
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,90 @@
|
|
|
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 { say, exit, isFile, getDotYo, glob, updateJSON } = YoHelper(this);
|
|
31
|
+
const pkg = isFile("package.json");
|
|
32
|
+
|
|
33
|
+
const opts = getDotYo();
|
|
34
|
+
if (!opts.exports) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const { srcArr, appendArr, prependArr, moreKeyArr, moreValArr, pkgjson } =
|
|
38
|
+
opts.exports;
|
|
39
|
+
const nextExports = {};
|
|
40
|
+
srcArr.forEach((v, index) => {
|
|
41
|
+
const prepend = prependArr[index];
|
|
42
|
+
const append = appendArr[index];
|
|
43
|
+
glob(
|
|
44
|
+
v,
|
|
45
|
+
({ filename }) => {
|
|
46
|
+
nextExports[
|
|
47
|
+
`${prepend}${filename}`
|
|
48
|
+
] = `${prepend}${filename}${append}`;
|
|
49
|
+
},
|
|
50
|
+
true
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
moreKeyArr?.forEach((v, index) => {
|
|
54
|
+
nextExports[v] = moreValArr[index];
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const pkgFile = isFile(pkgjson);
|
|
58
|
+
if (pkgFile) {
|
|
59
|
+
updateJSON(null, pkgFile, null, ({ exports = {}, ...json }) => {
|
|
60
|
+
if (this.options.n) {
|
|
61
|
+
const diff = {};
|
|
62
|
+
KEYS(exports).forEach((key) => {
|
|
63
|
+
if (exports[key] !== nextExports[key]) {
|
|
64
|
+
diff[key] = {
|
|
65
|
+
prev: exports[key],
|
|
66
|
+
next: nextExports[key],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (exports[key] && nextExports[key]) {
|
|
70
|
+
delete exports[key];
|
|
71
|
+
delete nextExports[key];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const allDiff = {
|
|
75
|
+
new: nextExports,
|
|
76
|
+
willClean: exports,
|
|
77
|
+
modify: diff,
|
|
78
|
+
};
|
|
79
|
+
this.log({ allDiff });
|
|
80
|
+
return null;
|
|
81
|
+
} else {
|
|
82
|
+
json.exports = nextExports;
|
|
83
|
+
return json;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
writing() {}
|
|
90
|
+
};
|
package/package.json
CHANGED