generator-reshow 0.17.48 → 0.17.49

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 (44) hide show
  1. package/generators/app/__tests__/TestApp.js +0 -1
  2. package/generators/app/index.js +1 -0
  3. package/generators/compile-sh/__tests__/Test.js +0 -1
  4. package/generators/docker/__tests__/Test.js +0 -1
  5. package/generators/docker/commonDockerPrompt.js +24 -0
  6. package/generators/docker/index.js +17 -34
  7. package/generators/docker/templates/.env.build +6 -4
  8. package/generators/docker/templates/Dockerfile +4 -0
  9. package/generators/docker/templates/_circleci/config.yml +7 -7
  10. package/generators/docker/templates/_gitignore +1 -1
  11. package/generators/docker/templates/bin/enter.sh +26 -0
  12. package/generators/docker/templates/bin/run.sh +15 -0
  13. package/generators/docker/templates/bin/test.sh +11 -9
  14. package/generators/docker/templates/compile.sh +12 -12
  15. package/generators/docker/templates/docker/entrypoint.sh +12 -0
  16. package/generators/docker/templates/install-packages.sh +1 -1
  17. package/generators/docker/templates/support/COPY_FILES.sh +1 -1
  18. package/generators/docker/templates/support/DOCKER_FILES.sh +1 -1
  19. package/generators/docker/templates/support/TERRATEST.sh +14 -0
  20. package/generators/docker/templates/support/VERSION.sh +3 -1
  21. package/generators/docker/templates/support/VER_PREFIX.sh +14 -0
  22. package/generators/docker/templates/{build.sh → support/build-multi.sh} +5 -5
  23. package/generators/docker/templates/support/localImage.sh +14 -0
  24. package/generators/docker/templates/support/remoteImage.sh +14 -0
  25. package/generators/docker/templates/test/smoke_test.go +23 -0
  26. package/generators/generator/__tests__/TestGenerator.js +0 -1
  27. package/generators/generator/templates/Test.js +0 -1
  28. package/generators/gitlab-docker/README.md +9 -0
  29. package/generators/gitlab-docker/__tests__/Test.js +43 -0
  30. package/generators/gitlab-docker/index.js +65 -0
  31. package/generators/gitlab-docker/templates/.gitlab-ci.yml +79 -0
  32. package/generators/gitlab-docker/templates/.gitlab-trigger.yml +14 -0
  33. package/generators/gitlab-docker/templates/Dockerfile +18 -0
  34. package/generators/gitlab-docker/templates/README.md +15 -0
  35. package/generators/library/__tests__/Test.js +0 -1
  36. package/generators/npm/__tests__/Test.js +0 -1
  37. package/generators/package-json/__tests__/Test.js +3 -2
  38. package/generators/package-json/index.js +2 -0
  39. package/generators/update-esm-export/__tests__/Test.js +0 -1
  40. package/package.json +1 -1
  41. package/generators/docker/templates/enter +0 -24
  42. package/generators/docker/templates/support/FOLDER_PREFIX.sh +0 -12
  43. package/generators/docker/templates/support/sourceImage.sh +0 -12
  44. package/generators/docker/templates/support/targetImage.sh +0 -12
@@ -16,7 +16,6 @@ describe("generator-reshow:app", () => {
16
16
  source: __dirname + "/../.",
17
17
  params: {
18
18
  isReady: true,
19
- appNamee: "foo",
20
19
  description: "foo-desc",
21
20
  keyword: "foo-keyword",
22
21
  },
@@ -30,6 +30,7 @@ module.exports = class extends YoGenerator {
30
30
  const prompts = [
31
31
  ...commonPrompt.mainName(this),
32
32
  ...commonPrompt.desc(this),
33
+ ...commonPrompt.author(this),
33
34
  ];
34
35
  const answers = await this.prompt(prompts);
35
36
  handleAnswers(answers);
@@ -16,7 +16,6 @@ describe("!! compile-sh !!", () => {
16
16
  source: __dirname + "/../.",
17
17
  params: {
18
18
  isReady: true,
19
- appNamee: "foo",
20
19
  description: "foo-desc",
21
20
  keyword: "foo-keyword",
22
21
  },
@@ -16,7 +16,6 @@ describe("!! docker !!", () => {
16
16
  source: __dirname + "/../.",
17
17
  params: {
18
18
  isReady: true,
19
- appNamee: "foo",
20
19
  description: "foo-desc",
21
20
  },
22
21
  });
@@ -0,0 +1,24 @@
1
+ const commonDockerPrompt = (oGen) => {
2
+ return [
3
+ {
4
+ type: "input",
5
+ name: "dockerImageName",
6
+ message: "Please input your docker-image-name?",
7
+ default: "[DOCKER_IMAGE_NAME]",
8
+ },
9
+ {
10
+ type: "input",
11
+ name: "dockerOrgName",
12
+ message: "Please input your docker-org-name?",
13
+ default: "[DOCKER_ORG_NAME]",
14
+ },
15
+ {
16
+ type: "input",
17
+ name: "verPrefix",
18
+ message: "Please input your version-prefix, will use with folder name and version?",
19
+ default: "v",
20
+ },
21
+ ];
22
+ };
23
+
24
+ module.exports = commonDockerPrompt;
@@ -1,4 +1,5 @@
1
1
  const { YoGenerator, YoHelper, commonPrompt } = require("yo-reshow");
2
+ const commonDockerPrompt = require("./commonDockerPrompt");
2
3
 
3
4
  /**
4
5
  * docker Generator
@@ -25,13 +26,7 @@ module.exports = class extends YoGenerator {
25
26
  * https://github.com/SBoudrias/Inquirer.js
26
27
  */
27
28
  async prompting() {
28
- const {
29
- say,
30
- handleAnswers,
31
- mergePromptOrOption,
32
- promptChainLocator,
33
- promptChain,
34
- } = YoHelper(this);
29
+ const { say, handleAnswers, promptChainAll } = YoHelper(this);
35
30
 
36
31
  const prompts = [
37
32
  ...commonPrompt.mainName(this),
@@ -40,23 +35,12 @@ module.exports = class extends YoGenerator {
40
35
  defaultRepositoryName: "[REPOSITORY_NAME]",
41
36
  defaultRepositoryOrgName: "[REPOSITORY_ORG_NAME]",
42
37
  }),
38
+ ...commonDockerPrompt(this),
43
39
  {
44
40
  type: "input",
45
- name: "dockerImageName",
46
- message: "Please input your docker-image-name?",
47
- default: "[DOCKER_IMAGE_NAME]",
48
- },
49
- {
50
- type: "input",
51
- name: "dockerOrgName",
52
- message: "Please input your docker-org-name?",
53
- default: "[DOCKER_ORG_NAME]",
54
- },
55
- {
56
- type: "input",
57
- name: "folderPrefix",
58
- message: "Please input your folder-prefix?",
59
- default: "ver-",
41
+ name: "terratest",
42
+ message: "Please input terratest docker image name?",
43
+ default: "terratest",
60
44
  },
61
45
  /*
62
46
  {
@@ -68,14 +52,10 @@ module.exports = class extends YoGenerator {
68
52
  */
69
53
  ];
70
54
 
71
- const answers = await mergePromptOrOption(prompts, (nextPrompts) =>
72
- promptChain(promptChainLocator(nextPrompts))
73
- );
55
+ const answers = await promptChainAll(prompts);
74
56
  handleAnswers(answers, (payload) => {
75
57
  // add more payload
76
- payload.folderPrefixGitIgnore = payload.folderPrefix
77
- ? payload.folderPrefix + "*"
78
- : "";
58
+ payload.verPrefixGitIgnore = payload.verPrefix ? payload.verPrefix + "*" : "";
79
59
  let imgName = payload.mainName;
80
60
  if (payload.dockerImageName) {
81
61
  imgName = payload.dockerImageName;
@@ -83,8 +63,8 @@ module.exports = class extends YoGenerator {
83
63
  imgName = `${payload.dockerOrgName}/${payload.dockerImageName}`;
84
64
  }
85
65
  }
86
- payload.sourceImage = imgName;
87
- payload.targetImage = imgName;
66
+ payload.localImage = imgName;
67
+ payload.remoteImage = imgName;
88
68
  });
89
69
  }
90
70
 
@@ -95,15 +75,18 @@ module.exports = class extends YoGenerator {
95
75
  chMainName();
96
76
 
97
77
  // handle copy file
98
- cp(".env.build", null, this.payload);
99
- cp("Dockerfile", null, this.payload);
100
- cp("README.md", null, this.payload);
78
+ if (!this.options.fromGitlab) {
79
+ cp("Dockerfile", null, this.payload);
80
+ cp("README.md", null, this.payload);
81
+ }
101
82
  cp("_circleci", ".circleci", this.payload);
83
+ cp(".env.build", null, this.payload);
102
84
  cp("_gitignore", ".gitignore", this.payload);
103
- cp("build.sh", null, this.payload);
104
85
  cp("compile.sh", null, this.payload);
105
86
  cp("install-packages.sh", null, this.payload);
106
87
  cp("support", null, this.payload);
107
88
  cp("bin", null, this.payload);
89
+ cp("docker", null, this.payload);
90
+ cp("test", null, this.payload);
108
91
  }
109
92
  };
@@ -1,6 +1,8 @@
1
- sourceImage=<%= sourceImage %>
2
- targetImage=<%= targetImage %>
3
- VERSION=0.0
4
- FOLDER_PREFIX=<%= folderPrefix %>
1
+ localImage=<%= localImage %>
2
+ remoteImage=<%= remoteImage %>
3
+ TERRATEST=<%= terratest %>
4
+ VERSION=0.0.0
5
+ VER_PREFIX=<%= verPrefix %>
5
6
  COPY_FILES[]=install-packages.sh
7
+ COPY_FILES[]=docker
6
8
  DOCKER_FILES[]=Dockerfile
@@ -9,3 +9,7 @@ COPY ./install-packages.sh /usr/local/bin/install-packages
9
9
  RUN apk update && apk add bash bc \
10
10
  && INSTALL_VERSION=$VERSION install-packages \
11
11
  && rm /usr/local/bin/install-packages;
12
+
13
+ COPY ./docker/entrypoint.sh /entrypoint.sh
14
+ ENTRYPOINT ["/entrypoint.sh"]
15
+ CMD ["server"]
@@ -23,27 +23,27 @@ jobs:
23
23
  - run:
24
24
  name: Gen Docker file
25
25
  command: |
26
- FOLDER_PREFIX=$(support/FOLDER_PREFIX.sh)
26
+ VER_PREFIX=$(support/VER_PREFIX.sh)
27
27
  DOCKER_FILES=$(support/DOCKER_FILES.sh)
28
- FOLDER=${FOLDER_PREFIX}<< parameters.docker-tag >>
29
- ./build.sh << parameters.docker-tag >>
30
- ls -la ${FOLDER}
28
+ BUILD_FOLDER=${VER_PREFIX}<< parameters.docker-tag >>
29
+ ./support/build-multi.sh << parameters.docker-tag >>
30
+ ls -la ${BUILD_FOLDER}
31
31
  for file in $DOCKER_FILES; do
32
32
  echo ""
33
33
  echo "###"
34
34
  echo "# --- Dockerfile ($file) Content ---"
35
35
  echo "###"
36
36
  echo ""
37
- cat ${FOLDER}/$file
37
+ cat ${BUILD_FOLDER}/$file
38
38
  echo ""
39
39
  done
40
40
  - run:
41
41
  name: build Docker image
42
42
  command: |
43
- FOLDER_PREFIX=$(support/FOLDER_PREFIX.sh)
43
+ VER_PREFIX=$(support/VER_PREFIX.sh)
44
44
  IMAGE_NAME=$(support/targetImage.sh)
45
45
  BUILD_VERSION=<< parameters.docker-tag >>
46
- BUILD_FOLDER=${FOLDER_PREFIX}<< parameters.docker-tag >>
46
+ BUILD_FOLDER=${VER_PREFIX}<< parameters.docker-tag >>
47
47
  BUILD_ARG=""
48
48
  docker build ${BUILD_ARG} -f ${BUILD_FOLDER}/Dockerfile \
49
49
  -t $IMAGE_NAME:${BUILD_VERSION} \
@@ -1,3 +1,3 @@
1
1
  archive.tar
2
2
  .*.sw?
3
- <%= folderPrefixGitIgnore %>
3
+ <%= verPrefixGitIgnore %>
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env sh
2
+
3
+ DIR="$(
4
+ cd "$(dirname "$0")"
5
+ pwd -P
6
+ )"
7
+ MY_PWD=$(pwd)
8
+
9
+ localImage=$(${DIR}/../support/localImage.sh)
10
+
11
+ C=''
12
+ for i in "$@"; do
13
+ i="${i//\\/\\\\}"
14
+ C="$C \"${i//\"/\\\"}\""
15
+ done
16
+
17
+ pid=$$
18
+
19
+ cli='env docker run --rm -it'
20
+ cli+=" -v $DIR/../docker/entrypoint.sh:/entrypoint.sh"
21
+ cli+=" -v $MY_PWD:$MY_PWD"
22
+ cli+=" -w $MY_PWD"
23
+ cli+=" --name ${localImage}-${pid} ${localImage}"
24
+ cli+=" sh ${C}"
25
+
26
+ sh -c "$cli"
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env sh
2
+
3
+ DIR="$(
4
+ cd "$(dirname "$0")"
5
+ pwd -P
6
+ )"
7
+
8
+ localImage=$(${DIR}/../support/localImage.sh)
9
+ pid=$$
10
+ folderName=${PWD##*/}
11
+
12
+ cli='env docker run --rm -it'
13
+ cli+=" --name ${folderName}-${pid} ${localImage}"
14
+ echo $cli
15
+ sh -c "$cli"
@@ -1,13 +1,15 @@
1
- #!/usr/bin/env bash
1
+ #!/usr/bin/env sh
2
2
  DIR="$(
3
3
  cd "$(dirname "$0")"
4
4
  pwd -P
5
5
  )"
6
- sourceImage=$(${DIR}/../support/sourceImage.sh)
7
- pid=$$
8
- folderName=${PWD##*/}
9
-
10
- cli='env docker run --rm -it'
11
- cli+=" --name ${folderName}_${pid} ${sourceImage}"
12
- echo $cli
13
- bash -c "$cli"
6
+
7
+ TERRATEST=$(${DIR}/../support/TERRATEST.sh)
8
+
9
+ docker run --rm -v $DIR/../:/app/test \
10
+ -v /var/run/docker.sock:/var/run/docker.sock \
11
+ -w /app/test \
12
+ $TERRATEST \
13
+ go test -v ./test
14
+
15
+
@@ -1,11 +1,11 @@
1
- #!/usr/bin/env bash
1
+ #!/usr/bin/env sh
2
2
 
3
3
  DIR="$(
4
4
  cd "$(dirname "$0")"
5
5
  pwd -P
6
6
  )"
7
- sourceImage=$(${DIR}/support/sourceImage.sh)
8
- targetImage=$(${DIR}/support/targetImage.sh)
7
+ localImage=$(${DIR}/support/localImage.sh)
8
+ remoteImage=$(${DIR}/support/remoteImage.sh)
9
9
  archiveFile=$DIR/archive.tar
10
10
  VERSION=$(${DIR}/support/VERSION.sh)
11
11
  DOCKER_FILE=${DOCKER_FILE:-Dockerfile}
@@ -25,7 +25,7 @@ tag() {
25
25
  fi
26
26
  echo "* <!-- Start to tag: ${tag}"
27
27
  echo $tag
28
- docker tag $sourceImage ${targetImage}:$tag
28
+ docker tag ${localImage} ${remoteImage}:$tag
29
29
  list
30
30
  echo "* Finish tag -->"
31
31
  }
@@ -41,20 +41,20 @@ push() {
41
41
  tag=$LATEST_TAG-$PUSH_VERSION
42
42
  fi
43
43
  fi
44
- echo "* <!-- Start to push ${targetImage}:$tag"
44
+ echo "* <!-- Start to push ${remoteImage}:$tag"
45
45
  IS_LOGIN=$(echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_LOGIN" --password-stdin)
46
46
  if ! [[ $IS_LOGIN =~ "Succeeded" ]]; then
47
47
  echo "Login Failed."
48
48
  exit 1
49
49
  fi
50
- docker push ${targetImage}:$tag
50
+ docker push ${remoteImage}:$tag
51
51
  echo "* Finish pushed -->"
52
52
  echo ""
53
53
  if [ ! -z "$1" ]; then
54
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}
55
+ echo "* <!-- Start to auto push ${remoteImage}:${LATEST_TAG}"
56
+ docker tag ${remoteImage}:$tag ${remoteImage}:${LATEST_TAG}
57
+ docker push ${remoteImage}:${LATEST_TAG}
58
58
  echo "* Finish pushed -->"
59
59
  fi
60
60
  fi
@@ -77,18 +77,18 @@ build() {
77
77
  if [ "x" != "x$NO_CACHE" ]; then
78
78
  echo nocache: ${NO_CACHE}
79
79
  fi
80
- docker build ${BUILD_ARG} ${NO_CACHE} -f ${DIR}/${DOCKER_FILE} -t $sourceImage ${DIR}
80
+ docker build ${BUILD_ARG} ${NO_CACHE} -f ${DIR}/${DOCKER_FILE} -t $localImage ${DIR}
81
81
  list
82
82
  }
83
83
 
84
84
  save() {
85
85
  echo save
86
- docker save $sourceImage > $archiveFile
86
+ docker save $localImage > $archiveFile
87
87
  }
88
88
 
89
89
  restore() {
90
90
  echo restore
91
- docker save --output $archiveFile $sourceImage
91
+ docker save --output $archiveFile $localImage
92
92
  }
93
93
 
94
94
  case "$1" in
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # docker entrypoint script
4
+ server() {
5
+ tail -f /entrypoint.sh
6
+ }
7
+
8
+ if [ "$1" = 'server' ]; then
9
+ server
10
+ else
11
+ exec "$@"
12
+ fi
@@ -1,4 +1,4 @@
1
- #!/bin/sh
1
+ #!/usr/bin/env sh
2
2
 
3
3
  ###
4
4
  # Environment ${INSTALL_VERSION} pass from Dockerfile
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env sh
2
2
 
3
3
  DIR="$(
4
4
  cd "$(dirname "$0")"
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env sh
2
2
 
3
3
  DIR="$(
4
4
  cd "$(dirname "$0")"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env sh
2
+
3
+ DIR="$(
4
+ cd "$(dirname "$0")"
5
+ pwd -P
6
+ )"
7
+
8
+ ENV=${DIR}/../.env.build
9
+
10
+ if [ -z "$TERRATEST" ]; then
11
+ TERRATEST=$(awk -F "=" '/^TERRATEST/ {print $2}' $ENV)
12
+ fi
13
+
14
+ echo $TERRATEST
@@ -1,5 +1,7 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env sh
2
+
2
3
  DIR="$( cd "$(dirname "$0")" ; pwd -P )"
4
+
3
5
  ENV=${DIR}/../.env.build
4
6
 
5
7
  if [ -z $VERSION ]; then
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env sh
2
+
3
+ DIR="$(
4
+ cd "$(dirname "$0")"
5
+ pwd -P
6
+ )"
7
+
8
+ ENV=${DIR}/../.env.build
9
+
10
+ if [ -z "$VER_PREFIX" ]; then
11
+ VER_PREFIX=$(awk -F "=" '/^VER_PREFIX/ {print $2}' $ENV)
12
+ fi
13
+
14
+ echo $VER_PREFIX
@@ -1,13 +1,13 @@
1
- #!/usr/bin/env bash
1
+ #!/usr/bin/env sh
2
2
 
3
3
  DIR="$(
4
4
  cd "$(dirname "$0")"
5
5
  pwd -P
6
6
  )"
7
7
 
8
- FOLDER_PREFIX=$(${DIR}/support/FOLDER_PREFIX.sh)
9
- COPY_FILES=$(${DIR}/support/COPY_FILES.sh)
10
- DOCKER_FILES=$(${DIR}/support/DOCKER_FILES.sh)
8
+ FOLDER_PREFIX=$(${DIR}/FOLDER_PREFIX.sh)
9
+ COPY_FILES=$(${DIR}/COPY_FILES.sh)
10
+ DOCKER_FILES=$(${DIR}/DOCKER_FILES.sh)
11
11
  BUILD_VERSION=$1
12
12
 
13
13
  if [ -z "$BUILD_VERSION" ]; then
@@ -17,7 +17,7 @@ fi
17
17
 
18
18
  do_build() {
19
19
  echo 'building --- Version: ' $BUILD_VERSION '-->'
20
- DEST_FOLDER=${DIR}/${FOLDER_PREFIX}${BUILD_VERSION}
20
+ DEST_FOLDER=${DIR}/../${FOLDER_PREFIX}${BUILD_VERSION}
21
21
  mkdir -p ${DEST_FOLDER}
22
22
 
23
23
  for file in $COPY_FILES; do [ -e "$file" ] && cp -a $file ${DEST_FOLDER}; done
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env sh
2
+
3
+ DIR="$(
4
+ cd "$(dirname "$0")"
5
+ pwd -P
6
+ )"
7
+
8
+ ENV=${DIR}/../.env.build
9
+
10
+ if [ -z "$localImage" ]; then
11
+ localImage=$(awk -F "=" '/^localImage/ {print $2}' $ENV)
12
+ fi
13
+
14
+ echo $localImage
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env sh
2
+
3
+ DIR="$(
4
+ cd "$(dirname "$0")"
5
+ pwd -P
6
+ )"
7
+
8
+ ENV=${DIR}/../.env.build
9
+
10
+ if [ -z "$remoteImage" ]; then
11
+ remoteImage=$(awk -F "=" '/^remoteImage/ {print $2}' $ENV)
12
+ fi
13
+
14
+ echo $remoteImage
@@ -0,0 +1,23 @@
1
+ package test
2
+
3
+ import (
4
+ "testing"
5
+ "github.com/gruntwork-io/terratest/modules/docker"
6
+ "github.com/stretchr/testify/assert"
7
+ )
8
+
9
+ func TestSmoke(t *testing.T) {
10
+ // website::tag::1:: Configure the tag to use on the Docker image.
11
+ tag := "docker-smoke"
12
+ buildOptions := &docker.BuildOptions{
13
+ Tags: []string{tag},
14
+ }
15
+
16
+ // website::tag::2:: Build the Docker image.
17
+ docker.Build(t, "../", buildOptions)
18
+
19
+ // website::tag::3:: Run the Docker image.
20
+ opts := &docker.RunOptions{Command: []string{"ls", "/"}}
21
+ output := docker.Run(t, tag, opts)
22
+ assert.Contains(t, output, "etc")
23
+ }
@@ -16,7 +16,6 @@ describe("!! generator !!", () => {
16
16
  source: __dirname + "/../.",
17
17
  params: {
18
18
  isReady: true,
19
- mainNamee: "foo",
20
19
  description: "foo-desc",
21
20
  keyword: "foo-keyword",
22
21
  },
@@ -16,7 +16,6 @@ describe("!! <%= mainName %> !!", () => {
16
16
  source: __dirname + "/../.",
17
17
  params: {
18
18
  isReady: true,
19
- appNamee: "foo",
20
19
  description: "foo-desc",
21
20
  keyword: "foo-keyword",
22
21
  },
@@ -0,0 +1,9 @@
1
+ # `gitlab-docker`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ npx yonpx gitlab-docker
9
+ ```
@@ -0,0 +1,43 @@
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 { YoTest, assert } = require("yo-unit");
10
+
11
+ describe("!! gitlab-docker !!", () => {
12
+ let runResult;
13
+
14
+ before(async () => {
15
+ runResult = await YoTest({
16
+ source: __dirname + "/../.",
17
+ params: {
18
+ isReady: true,
19
+ description: "foo-desc",
20
+ keyword: "foo-keyword",
21
+ },
22
+ });
23
+ });
24
+
25
+ after(() => {
26
+ if (runResult) {
27
+ runResult.restore();
28
+ }
29
+ });
30
+
31
+ it("should have folder", () => {
32
+ // assert.file(["src", "ui"]);
33
+ });
34
+
35
+ it("should have file", () => {
36
+ assert.file([".gitlab-ci.yml", ".gitlab-trigger.yml"]);
37
+ });
38
+
39
+ it("should have content", () => {
40
+ // assert.fileContent('composer.json', 'foo-desc');
41
+ // assert.fileContent('.circleci/config.yml', 'foo');
42
+ });
43
+ });
@@ -0,0 +1,65 @@
1
+ const { YoGenerator, YoHelper, commonPrompt } = require("yo-reshow");
2
+ const commonDockerPrompt = require("../docker/commonDockerPrompt");
3
+
4
+ /**
5
+ * gitlab-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
+ handleAnswers,
31
+ promptChainAll,
32
+ } = YoHelper(this);
33
+
34
+ const prompts = [
35
+ ...commonPrompt.mainName(this),
36
+ ...commonPrompt.desc(this),
37
+ ...commonDockerPrompt(this),
38
+ ];
39
+
40
+ const answers = await promptChainAll(prompts);
41
+ handleAnswers(answers);
42
+ this.composeWith(require.resolve("../docker"), {
43
+ repositoryName: "",
44
+ repositoryOrgName: "",
45
+ description: "",
46
+ ...answers,
47
+ fromGitlab: true,
48
+ });
49
+ }
50
+
51
+ writing() {
52
+ this.env.options.nodePackageManager = "yarn";
53
+ this.options.skipInstall = true;
54
+ const { cp, chMainName } = YoHelper(this);
55
+
56
+ // handle change to new folder
57
+ chMainName(this.mainName);
58
+
59
+ // handle copy file
60
+ cp("Dockerfile", null, this.payload);
61
+ cp("README.md", null, this.payload);
62
+ cp(".gitlab-ci.yml", null, this.payload);
63
+ cp(".gitlab-trigger.yml", null, this.payload);
64
+ }
65
+ };
@@ -0,0 +1,79 @@
1
+ stages:
2
+ - info
3
+ - test
4
+ - build
5
+ - uat
6
+ - deploy
7
+
8
+ variables:
9
+ LATEST_TAG: <%= verPrefix %>0.0.0
10
+ LAST_IMAGE_STORE: ./last-image
11
+
12
+ .parallel:
13
+ parallel:
14
+ matrix:
15
+ - dockerTag: [<%= verPrefix %>0.0.0]
16
+
17
+ default:
18
+ before_script:
19
+ - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
20
+ after_script:
21
+ - docker logout
22
+ tags:
23
+ - swarm-cluster
24
+ - docker
25
+
26
+ # https://docs.gitlab.com/ee/ci/yaml/index.html
27
+ info-section:
28
+ # available stages are .pre, .post and form stages
29
+ stage: info
30
+ script:
31
+ - echo "Display Information"
32
+ - date
33
+ - echo "$CI_PIPELINE_ID"
34
+
35
+ pre-test:
36
+ stage: test
37
+ image: $CI_TERRATEST
38
+ script:
39
+ - go test -v ./test
40
+
41
+ build-docker-image:
42
+ extends: .parallel
43
+ stage: build
44
+ script:
45
+ - IMAGE_NAME=$CI_REGISTRY_IMAGE:$dockerTag-$CI_PIPELINE_ID
46
+ - echo $IMAGE_NAME > $LAST_IMAGE_STORE
47
+ - echo $IMAGE_NAME
48
+ - echo 'Start build docker images:' $dockerTag
49
+ - DOCKER_BUILDKIT=1 docker build -f Dockerfile --target $dockerTag -t $IMAGE_NAME .
50
+ - docker images | head -10 || trap '' PIPE
51
+ - docker push $IMAGE_NAME
52
+ artifacts:
53
+ paths:
54
+ - $LAST_IMAGE_STORE
55
+
56
+ e2e-test:
57
+ stage: uat
58
+ needs: ["build-docker-image"]
59
+ trigger:
60
+ include:
61
+ - local: .gitlab-trigger.yml
62
+
63
+ put-to-stable:
64
+ extends: .parallel
65
+ stage: deploy
66
+ rules:
67
+ - when: manual
68
+ script:
69
+ - STABLE_NAME=$CI_REGISTRY_IMAGE:$dockerTag
70
+ - echo 'Put Image to Stable:' $dockerTag
71
+ - IMAGE_NAME=$(cat $LAST_IMAGE_STORE)
72
+ - docker pull $IMAGE_NAME
73
+ - docker tag $IMAGE_NAME $STABLE_NAME
74
+ - docker push $STABLE_NAME
75
+ - |
76
+ if [ "x$LATEST_TAG" == "x$dockerTag" ]; then
77
+ docker tag $IMAGE_NAME $CI_REGISTRY_IMAGE:latest
78
+ docker push $CI_REGISTRY_IMAGE:latest
79
+ fi
@@ -0,0 +1,14 @@
1
+ image: alpine
2
+
3
+ stages:
4
+ - test
5
+
6
+ default:
7
+ tags:
8
+ - swarm-cluster
9
+ - docker
10
+
11
+ test:
12
+ stage: test
13
+ script:
14
+ - cat /etc/alpine-release
@@ -0,0 +1,18 @@
1
+ ARG VERSION=${VERSION:-[VERSION]}
2
+
3
+ FROM alpine:3.15 AS base
4
+
5
+ ARG VERSION
6
+
7
+ # apk
8
+ COPY ./install-packages.sh /usr/local/bin/install-packages
9
+ RUN apk update && apk add bash bc \
10
+ && INSTALL_VERSION=$VERSION install-packages \
11
+ && rm /usr/local/bin/install-packages;
12
+
13
+ FROM base AS <%= verPrefix %>0.0.0
14
+ RUN echo "<%= verPrefix %>0.0.0"
15
+
16
+ COPY ./docker/entrypoint.sh /entrypoint.sh
17
+ ENTRYPOINT ["/entrypoint.sh"]
18
+ CMD ["server"]
@@ -0,0 +1,15 @@
1
+ # `<%= mainName %>`
2
+
3
+ > <%= description %>
4
+
5
+ ## `GIT`
6
+ * <%= repositoryUrl %>
7
+
8
+ ## `Docker hub`
9
+ * Docker Image: <%= dockerOrgName %>/<%= dockerImageName %>
10
+
11
+ ## Usage
12
+
13
+ ```
14
+
15
+ ```
@@ -16,7 +16,6 @@ describe("!! library !!", () => {
16
16
  source: __dirname + "/../.",
17
17
  params: {
18
18
  isReady: true,
19
- appNamee: "foo",
20
19
  description: "foo-desc",
21
20
  keyword: "foo-keyword",
22
21
  },
@@ -16,7 +16,6 @@ describe("!! npm !!", () => {
16
16
  source: __dirname + "/../.",
17
17
  params: {
18
18
  isReady: true,
19
- appNamee: "foo",
20
19
  description: "foo-desc",
21
20
  keyword: "foo-keyword",
22
21
  repositoryName: "foo-repository-name",
@@ -14,11 +14,12 @@ describe("!! package-json !!", () => {
14
14
  before(async () => {
15
15
  runResult = await YoTest({
16
16
  source: __dirname + "/../.",
17
- params: {
17
+ options: {
18
18
  isReady: true,
19
- appNamee: "foo",
20
19
  description: "foo-desc",
21
20
  keyword: "foo-keyword",
21
+ authorName: "foo-name",
22
+ authorEmail: "foo@foo.com",
22
23
  },
23
24
  });
24
25
  });
@@ -13,6 +13,8 @@ module.exports = class extends YoGenerator {
13
13
  mainName: "",
14
14
  description: "",
15
15
  babelRootMode: "",
16
+ authorName: "",
17
+ authorEmail: "",
16
18
  ...this.payload,
17
19
  ...this.options,
18
20
  ...getDotYo(this.options),
@@ -16,7 +16,6 @@ describe("!! update-esm-export !!", () => {
16
16
  source: __dirname + "/../.",
17
17
  params: {
18
18
  isReady: true,
19
- appNamee: "foo",
20
19
  description: "foo-desc",
21
20
  keyword: "foo-keyword",
22
21
  },
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.17.48",
2
+ "version": "0.17.49",
3
3
  "name": "generator-reshow",
4
4
  "repository": {
5
5
  "type": "git",
@@ -1,24 +0,0 @@
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"
@@ -1,12 +0,0 @@
1
- #!/bin/bash
2
- DIR="$(
3
- cd "$(dirname "$0")"
4
- pwd -P
5
- )"
6
- ENV=${DIR}/../.env.build
7
-
8
- if [ -z $FOLDER_PREFIX ]; then
9
- FOLDER_PREFIX=$(awk -F "=" '/^FOLDER_PREFIX/ {print $2}' $ENV)
10
- fi
11
-
12
- echo $FOLDER_PREFIX
@@ -1,12 +0,0 @@
1
- #!/bin/bash
2
- DIR="$(
3
- cd "$(dirname "$0")"
4
- pwd -P
5
- )"
6
- ENV=${DIR}/../.env.build
7
-
8
- if [ -z $sourceImage ]; then
9
- sourceImage=$(awk -F "=" '/^sourceImage/ {print $2}' $ENV)
10
- fi
11
-
12
- echo $sourceImage
@@ -1,12 +0,0 @@
1
- #!/bin/bash
2
- DIR="$(
3
- cd "$(dirname "$0")"
4
- pwd -P
5
- )"
6
- ENV=${DIR}/../.env.build
7
-
8
- if [ -z $targetImage ]; then
9
- targetImage=$(awk -F "=" '/^targetImage/ {print $2}' $ENV)
10
- fi
11
-
12
- echo $targetImage