Skip to content

Commit 4e4ae47

Browse files
committed
:enhance: 增加 version
1 parent 7a9c52b commit 4e4ae47

File tree

6 files changed

+950
-28
lines changed

6 files changed

+950
-28
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@micro-app/plugin-vue-cli",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "[Plugin] adapter vue cli plugin.",
55
"main": "src/index.js",
66
"scripts": {
@@ -29,7 +29,8 @@
2929
},
3030
"license": "MIT",
3131
"devDependencies": {
32-
"@micro-app/core": "0.1.0-beta.30",
32+
"@micro-app/cli": "0.1.1-rc.3",
33+
"@micro-app/core": "0.1.1",
3334
"@types/jest": "^24.0.18",
3435
"babel-eslint": "^10.0.2",
3536
"coveralls": "^3.0.6",

src/commands/version.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
module.exports = function versionCommand(api) {
4+
5+
const pkg = require('../../package.json');
6+
7+
api.addCommandVersion(pkg);
8+
9+
};

src/commands/version.test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
/* global expect */
4+
5+
const path = require('path');
6+
7+
describe('Command version', () => {
8+
9+
it('version', () => {
10+
11+
const { service } = require('@micro-app/cli/bin/base');
12+
13+
service.registerPlugin({
14+
id: 'test:VueCLIVersion',
15+
link: path.join(__dirname, './version.js'),
16+
});
17+
18+
const plugin = service.plugins.find(item => item.id === 'cli:plugins-commands-version');
19+
expect(typeof plugin).toEqual('object');
20+
21+
service.init();
22+
23+
expect(plugin._api).not.toBeUndefined();
24+
plugin._api.addCommandVersion({
25+
name: 'a',
26+
version: 'b',
27+
description: 'c',
28+
});
29+
30+
service.runCommand('version');
31+
32+
expect(service.commands.version).not.toBeNull();
33+
expect(service.commands.version).not.toBeUndefined();
34+
expect(typeof service.commands.version).toEqual('object');
35+
});
36+
37+
});

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ const path = require('path');
44

55
module.exports = function VueCLIAdapter(api, opts = {}) {
66

7+
// commands
8+
require('./commands/version')(api);
9+
710
// Current working directory.
811
api.extendMethod('getCwd', () => {
912
return opts.root || api.root;

test/testPlugin.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@
33

44
module.exports = function(api, opts) {
55
console.log(opts);
6-
const cwd = api.getCwd();
7-
console.log(cwd);
86
};

0 commit comments

Comments
 (0)