cmyr-template-cli 1.9.2 → 1.10.2
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/dist/index.js +1 -1
- package/dist/plopfile.js +50 -16
- package/package.json +2 -2
- package/templates/.dockerignore +30 -0
- package/templates/Dockerfile +28 -0
- package/templates/docker-compose.yml +40 -0
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
|
13
13
|
|
|
14
14
|
const program = new commander.Command('ct')
|
|
15
15
|
.description('草梅项目创建器');
|
|
16
|
-
program.version("1.
|
|
16
|
+
program.version("1.10.1" , '-v, --version');
|
|
17
17
|
const args = process.argv.slice(2);
|
|
18
18
|
if (args.length === 0) {
|
|
19
19
|
args.push('create');
|
package/dist/plopfile.js
CHANGED
|
@@ -114,7 +114,7 @@ async function initProject(answers) {
|
|
|
114
114
|
}
|
|
115
115
|
async function init(projectPath, answers) {
|
|
116
116
|
var _a;
|
|
117
|
-
const { isOpenSource, gitRemoteUrl, isInitReadme, isInitContributing, isInitHusky, isInitSemanticRelease } = answers;
|
|
117
|
+
const { isOpenSource, gitRemoteUrl, isInitReadme, isInitContributing, isInitHusky, isInitSemanticRelease, isInitDocker } = answers;
|
|
118
118
|
try {
|
|
119
119
|
await asyncExec('git --version', {
|
|
120
120
|
cwd: projectPath,
|
|
@@ -125,20 +125,11 @@ async function init(projectPath, answers) {
|
|
|
125
125
|
await asyncExec('git init', {
|
|
126
126
|
cwd: projectPath,
|
|
127
127
|
});
|
|
128
|
-
if (gitRemoteUrl) {
|
|
129
|
-
await asyncExec(`git remote add origin ${gitRemoteUrl}`, {
|
|
130
|
-
cwd: projectPath,
|
|
131
|
-
});
|
|
132
|
-
console.info(colors__default["default"].green(`请在远程 Git 仓库初始化 ${gitRemoteUrl}`));
|
|
133
|
-
}
|
|
134
|
-
await initDependabot(projectPath, answers);
|
|
135
|
-
await initYarn(projectPath, answers);
|
|
136
128
|
const newPkg = await initProjectJson(projectPath, answers);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
await initHusky(projectPath);
|
|
129
|
+
await initConfig(projectPath);
|
|
130
|
+
await initCommitizen(projectPath);
|
|
131
|
+
if (isInitDocker) {
|
|
132
|
+
await initDocker(projectPath);
|
|
142
133
|
}
|
|
143
134
|
if (isOpenSource) {
|
|
144
135
|
const info = await getProjectInfo(projectPath, answers);
|
|
@@ -153,9 +144,21 @@ async function init(projectPath, answers) {
|
|
|
153
144
|
}
|
|
154
145
|
await initGithubWorkflows(projectPath, answers);
|
|
155
146
|
}
|
|
156
|
-
|
|
157
|
-
|
|
147
|
+
if (gitRemoteUrl) {
|
|
148
|
+
await asyncExec(`git remote add origin ${gitRemoteUrl}`, {
|
|
149
|
+
cwd: projectPath,
|
|
150
|
+
});
|
|
151
|
+
console.info(colors__default["default"].green(`请在远程 Git 仓库初始化 ${gitRemoteUrl}`));
|
|
152
|
+
}
|
|
153
|
+
if (isInitSemanticRelease) {
|
|
154
|
+
await initSemanticRelease(projectPath);
|
|
155
|
+
}
|
|
156
|
+
if (isInitHusky) {
|
|
157
|
+
await initHusky(projectPath);
|
|
158
|
+
}
|
|
158
159
|
await sortProjectJson(projectPath);
|
|
160
|
+
await initDependabot(projectPath, answers);
|
|
161
|
+
await initYarn(projectPath, answers);
|
|
159
162
|
await asyncExec('git add .', {
|
|
160
163
|
cwd: projectPath,
|
|
161
164
|
});
|
|
@@ -618,6 +621,24 @@ async function initCommitizen(projectPath) {
|
|
|
618
621
|
loading.fail('commitizen 初始化失败!');
|
|
619
622
|
}
|
|
620
623
|
}
|
|
624
|
+
async function initDocker(projectPath) {
|
|
625
|
+
const loading = ora__default["default"]('正在初始化 Docker ……').start();
|
|
626
|
+
try {
|
|
627
|
+
const files = ['.dockerignore', 'docker-compose.yml', 'Dockerfile'];
|
|
628
|
+
files.forEach(async (file) => {
|
|
629
|
+
const templatePath = path__default["default"].join(__dirname, '../templates/', file);
|
|
630
|
+
const newPath = path__default["default"].join(projectPath, file);
|
|
631
|
+
if (await fs__default["default"].pathExists(newPath)) {
|
|
632
|
+
await fs__default["default"].remove(newPath);
|
|
633
|
+
}
|
|
634
|
+
await fs__default["default"].copyFile(templatePath, newPath);
|
|
635
|
+
});
|
|
636
|
+
loading.succeed('Docker 初始化成功!');
|
|
637
|
+
}
|
|
638
|
+
catch (error) {
|
|
639
|
+
loading.fail('Docker 初始化失败!');
|
|
640
|
+
}
|
|
641
|
+
}
|
|
621
642
|
async function sortProjectJson(projectPath) {
|
|
622
643
|
try {
|
|
623
644
|
const pkg = await getProjectJson(projectPath);
|
|
@@ -749,6 +770,19 @@ module.exports = function (plop) {
|
|
|
749
770
|
},
|
|
750
771
|
default: '',
|
|
751
772
|
},
|
|
773
|
+
{
|
|
774
|
+
type: 'confirm',
|
|
775
|
+
name: 'isInitDocker',
|
|
776
|
+
message: '是否初始化 Docker?',
|
|
777
|
+
default: false,
|
|
778
|
+
when(answers) {
|
|
779
|
+
return [
|
|
780
|
+
'express',
|
|
781
|
+
'koa2',
|
|
782
|
+
'nest',
|
|
783
|
+
].map((e) => `${e}-template`).includes(answers.template);
|
|
784
|
+
},
|
|
785
|
+
},
|
|
752
786
|
{
|
|
753
787
|
type: 'confirm',
|
|
754
788
|
name: 'isOpenSource',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cmyr-template-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.2",
|
|
4
4
|
"description": "草梅友仁自制的项目模板创建器",
|
|
5
5
|
"author": "CaoMeiYouRen",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
36
36
|
"@rollup/plugin-json": "^4.1.0",
|
|
37
37
|
"@rollup/plugin-node-resolve": "^13.0.5",
|
|
38
|
-
"@rollup/plugin-replace": "^
|
|
38
|
+
"@rollup/plugin-replace": "^4.0.0",
|
|
39
39
|
"@rollup/plugin-typescript": "^8.0.0",
|
|
40
40
|
"@semantic-release/changelog": "^6.0.0",
|
|
41
41
|
"@semantic-release/git": "^10.0.0",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
node_modules
|
|
2
|
+
npm-debug.log
|
|
3
|
+
Dockerfile*
|
|
4
|
+
docker-compose*
|
|
5
|
+
.dockerignore
|
|
6
|
+
.gitignore
|
|
7
|
+
# .eslintignore
|
|
8
|
+
# .eslintrc.js
|
|
9
|
+
LICENSE
|
|
10
|
+
.vscode
|
|
11
|
+
.github
|
|
12
|
+
assets
|
|
13
|
+
coverage
|
|
14
|
+
docs
|
|
15
|
+
# test
|
|
16
|
+
.codecov.yml
|
|
17
|
+
# .eslint*
|
|
18
|
+
.prettier*
|
|
19
|
+
.(yarn|npm|nvm)rc
|
|
20
|
+
*.md
|
|
21
|
+
process.json
|
|
22
|
+
app.json
|
|
23
|
+
# tsconfig.json
|
|
24
|
+
|
|
25
|
+
.travis.yml
|
|
26
|
+
|
|
27
|
+
#git but keep the git commit hash
|
|
28
|
+
.git
|
|
29
|
+
# src
|
|
30
|
+
logs
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
FROM alpine:latest
|
|
2
|
+
|
|
3
|
+
# ENV NODE_ENV production
|
|
4
|
+
|
|
5
|
+
# 安装nodejs环境
|
|
6
|
+
RUN echo "http://mirrors.aliyun.com/alpine/edge/main/" > /etc/apk/repositories \
|
|
7
|
+
&& echo "http://mirrors.aliyun.com/alpine/edge/community/" >> /etc/apk/repositories \
|
|
8
|
+
&& apk update \
|
|
9
|
+
&& apk add --no-cache --update nodejs npm git \
|
|
10
|
+
&& node -v && npm -v && git --version \
|
|
11
|
+
&& npm config set registry https://registry.npmmirror.com \
|
|
12
|
+
&& npm i -g pnpm\
|
|
13
|
+
&& pnpm -v\
|
|
14
|
+
&& pnpm config set registry https://registry.npmmirror.com
|
|
15
|
+
|
|
16
|
+
WORKDIR /home/app
|
|
17
|
+
|
|
18
|
+
COPY package.json /home/app/
|
|
19
|
+
|
|
20
|
+
RUN pnpm i
|
|
21
|
+
|
|
22
|
+
COPY . /home/app
|
|
23
|
+
|
|
24
|
+
RUN pnpm run build
|
|
25
|
+
|
|
26
|
+
EXPOSE 3000
|
|
27
|
+
|
|
28
|
+
CMD ["pnpm","run", "start"]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
version: "3"
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
server:
|
|
5
|
+
build: .
|
|
6
|
+
restart: always
|
|
7
|
+
ports:
|
|
8
|
+
- "3000:3000"
|
|
9
|
+
environment:
|
|
10
|
+
NODE_ENV: production
|
|
11
|
+
PORT: 3000
|
|
12
|
+
TZ: "Asia/Shanghai"
|
|
13
|
+
TIMEOUT: 10000
|
|
14
|
+
# MONGODB_DB_NAME: "mongo-db"
|
|
15
|
+
# MONGODB_HOST: "mongo"
|
|
16
|
+
# MONGODB_PORT: 27017
|
|
17
|
+
# MONGODB_URL: "mongodb://mongo:27017/"
|
|
18
|
+
# MONGODB_USER: "admin"
|
|
19
|
+
# MONGODB_PASSWORD: "123456"
|
|
20
|
+
# REDIS_HOST: "redis"
|
|
21
|
+
# REDIS_PORT: 6379
|
|
22
|
+
|
|
23
|
+
# mongo:
|
|
24
|
+
# image: mongo:4.2
|
|
25
|
+
# restart: always
|
|
26
|
+
# # ports:
|
|
27
|
+
# # - "27017:27017"
|
|
28
|
+
# environment:
|
|
29
|
+
# MONGO_INITDB_ROOT_USERNAME: "admin"
|
|
30
|
+
# MONGO_INITDB_ROOT_PASSWORD: "123456"
|
|
31
|
+
# volumes:
|
|
32
|
+
# - mongo-data:/data/db
|
|
33
|
+
# redis:
|
|
34
|
+
# image: redis:6-alpine
|
|
35
|
+
# restart: always
|
|
36
|
+
# volumes:
|
|
37
|
+
# - redis-data:/data
|
|
38
|
+
# volumes:
|
|
39
|
+
# mongo-data:
|
|
40
|
+
# redis-data:
|