Skip to content

Commit ea93f23

Browse files
committed
feat: art, add release.
1 parent b792f31 commit ea93f23

File tree

14 files changed

+555
-54
lines changed

14 files changed

+555
-54
lines changed

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "@micro-app/plugin-deploy",
3-
"version": "0.0.3",
3+
"version": "0.0.3-alpha.1",
44
"description": "[Plugin] auto deploy plugin.",
55
"main": "src/index.js",
66
"scripts": {
77
"prepublishOnly": "npm run test",
8-
"test": "jest"
8+
"test": "jest",
9+
"publish:next": "npm publish --tag next"
910
},
1011
"files": [
1112
"src"
@@ -41,5 +42,8 @@
4142
"eslint": "^5.16.0",
4243
"eslint-config-2o3t": "^1.1.17",
4344
"jest": "^24.9.0"
45+
},
46+
"dependencies": {
47+
"release-it": "^12.4.3"
4448
}
4549
}

src/commands/index.js

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22

33
const path = require('path');
44
const { fs, _, chalk, Env } = require('@micro-app/shared-utils');
5-
const CONSTANTS = require('../../constants');
5+
const CONSTANTS = require('../constants');
66
const { execGit, execGitSync, getCurrBranch, getGitBranch, getGitUser, getCommitHash } = require('./utils');
77

88
function createCNAMEFile({ deployConfig, deployDir }) {
99
const cname = deployConfig.cname;
10-
if (!_.isEmpty(cname) && _.isString(cname)) {
10+
if (!_.isEmpty(cname)) {
11+
const cnames = [];
12+
if (_.isString(cname)) {
13+
cnames.push(cname);
14+
} else if (_.isArray(cname)) {
15+
cnames.push(...cname);
16+
}
1117
const filepath = path.resolve(deployDir, 'CNAME');
12-
fs.writeFileSync(filepath, cname, 'utf8');
18+
fs.writeFileSync(filepath, cnames.join('\n'), 'utf8');
1319
}
1420
}
1521

@@ -128,7 +134,7 @@ module.exports = async function deployCommit(api, args, deployConfigs) {
128134
logger.throw('Sorry, this script requires git');
129135
}
130136

131-
// TODO 迁移到外部,且不中断
137+
// TODO 迁移到外部,且不中断(分成不同组类型,批量部署)
132138
return Promise.all(deployConfigs.map(async (deployConfig, index) => {
133139

134140
const gitURL = deployConfig.url || '';
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
module.exports = function(api, opts = {}) {
44

5-
const { chalk } = require('@micro-app/shared-utils');
5+
const registerMethods = require('./methods');
6+
registerMethods(api);
7+
8+
const { _, chalk } = require('@micro-app/shared-utils');
69

710
api.registerCommand('deploy', {
811
description: 'sync commit status.',
@@ -39,9 +42,8 @@ Config:
3942
dest: '', ${chalk.gray('// git dest')}
4043
cname: '', ${chalk.gray('// 如果是发布到自定义域名, default: false')}
4144
}
42-
`.trim(),
45+
`.trim(),
4346
}, args => {
44-
const _ = require('lodash');
4547
const logger = api.logger;
4648

4749
const parseConfig = require('./parseConfig');
@@ -60,7 +62,7 @@ Config:
6062
const deployCmds = [
6163
{
6264
type: 'git',
63-
run: require('../git'),
65+
run: require('./git'),
6466
},
6567
].concat(api.applyPluginHooks('addCommandDeployType', []) || []);
6668

@@ -83,7 +85,9 @@ Config:
8385
}
8486
chain = chain.then(() => api.applyPluginHooks('afterCommandDeploy', { args, config: deployConfig }));
8587

86-
return chain;
88+
return chain.catch(e => {
89+
logger.throw('[Deploy]', e);
90+
});
8791
});
8892

8993
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const _ = require('lodash');
44
const path = require('path');
55
const tryRequire = require('try-require');
6-
const CONSTANTS = require('../../constants');
6+
const CONSTANTS = require('./constants');
77

88
const rRepoURL = /^(?:(?:git|https?|git\+https|git\+ssh):\/\/)?(?:[^@]+@)?([^\/]+?)[\/:](.+?)\.git$/;
99
const rGithubPage = /\.github\.(io|com)$/;

0 commit comments

Comments
 (0)