Skip to content
This repository was archived by the owner on Jun 3, 2021. It is now read-only.

Commit 23faad2

Browse files
committed
[Feature] Add dependency injection mechanism
1 parent 7187f48 commit 23faad2

38 files changed

+23641
-31561
lines changed

Diff for: .babelrc

-6
This file was deleted.

Diff for: .eslintrc

-152
This file was deleted.

Diff for: .gitignore

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
.idea
2-
.project
3-
.svn
4-
.DS_Store
5-
.sass-cache
6-
*/.svn
7-
*/.DS_Store
8-
*/.idea
91
.vscode/
102

113
node_modules/
12-
npm-debug.log
4+
lib/
135

Diff for: .npmignore

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
.idea
2-
.project
3-
.svn
4-
.DS_Store
5-
.sass-cache
6-
*/.svn
7-
*/.DS_Store
8-
*/.idea
91
.vscode/
102

113
node_modules/
124
npm-debug.log
135

14-
.github/
6+
.github/
7+
8+
src/
9+
lib/**/*.js.map
10+
11+
typings/

Diff for: bin/weex.js

100755100644
+2-124
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,5 @@
11
#!/usr/bin/env node
2-
'use strict';
32

4-
const xtoolkit = require('xtoolkit');
5-
const chalk = require('chalk');
6-
const check = require('check-node-version');
7-
const path = require('path');
8-
const updateNotifier = require('update-notifier');
9-
const pkg = require('../package.json');
10-
const PROGRAMS = check.PROGRAMS;
11-
const {
12-
logger
13-
} = require('../lib/utils');
3+
"use strict";
144

15-
const options = {
16-
'node': '>=6',
17-
'npm': '>=4'
18-
};
19-
20-
const logResult = function logResult (result) {
21-
// display any non-compliant versions
22-
Object.keys(PROGRAMS).forEach(function (name) {
23-
const info = result[name];
24-
const raw = info.wanted && info.wanted.raw;
25-
const range = info.wanted && info.wanted.range;
26-
if (!info || !info.version) return;
27-
if (info.isSatisfied === false) {
28-
logger.log(chalk.yellow('\nWarning:' + (info.version ? ' Local version is ' + info.version + ',' : '') + ' Wanted ' + name + ' version ' + raw + ' (' + range + ')'));
29-
logger.log(chalk.grey(PROGRAMS[name].getInstallInstructions(raw)));
30-
}
31-
else {
32-
if (info.version.toString().match(/\d+/)[0] === '5') {
33-
logger.log(chalk.yellow(`Warning: npm 5 is not supported yet!
34-
35-
${chalk.grey(`It looks like you're using npm 5 which was recently released.
36-
Weex Toolkit doesn't work well with npm 5 yet, unfortunately.
37-
38-
We recommend using npm 4 until some bugs are resolved.
39-
To install npm 4, you can just run \`npm i npm@4 -g\` or use \`n\` to manage your npm version with node.
40-
41-
You can follow the known issues with npm 5 at https://github.com/npm/npm/issues/16991`)}\n`)
42-
);
43-
}
44-
}
45-
});
46-
};
47-
48-
const checkVersion = () => {
49-
check(options, function (err, result) {
50-
if (err) {
51-
logger.error(err.message);
52-
process.exit(1);
53-
return;
54-
}
55-
logResult(result);
56-
});
57-
}
58-
59-
const binname = 'weex';
60-
61-
const userinfo = `
62-
${chalk.underline('Usage:')}
63-
64-
$ ${chalk.green(`${binname} <command>`)}`;
65-
// This command help message is for weex-toolkit.
66-
const command = `
67-
${chalk.underline('Commands:')}
68-
69-
${chalk.green('debug')} Start weex debugger
70-
${chalk.green('config')} Configure the global configuration file
71-
${chalk.green('compile')} Compile we/vue file
72-
${chalk.green('create')} Create a weex project
73-
${chalk.green('preview')} Preview a weex page
74-
${chalk.green('platform')} Add/remove/update ios/android platform
75-
${chalk.green('plugin')} Add/remove/create weex plugin
76-
${chalk.green('run')} Build your ios/android app and run
77-
${chalk.green('update')} Update weex package version
78-
${chalk.green('remove')} Remove a package from weex-toolkit
79-
${chalk.green('xbind')} Binding a thrid-part tool
80-
81-
weex <command> --help help on <command>
82-
`;
83-
84-
const isPreview = (file) => {
85-
const ext = path.extname(file);
86-
if (ext === '.vue' || ext === '.we') {
87-
return true;
88-
}
89-
return false;
90-
};
91-
92-
const showHelp = () => {
93-
checkVersion()
94-
logger.log(userinfo);
95-
logger.log(command);
96-
};
97-
98-
// Checks for available update and returns an instance
99-
const notifier = updateNotifier({pkg});
100-
notifier.notify();
101-
102-
if (process.argv.length <= 3) {
103-
// Compatible with `weex xxx.vue`
104-
if (process.argv[2] && isPreview(process.argv[2])) {
105-
logger.warn(`we suggest you to use \`weex preview ${process.argv[2]}\`, that's more readable.`);
106-
}
107-
else if (process.argv[2] === '-h' || process.argv[2] === '--help') {
108-
showHelp();
109-
}
110-
else if (!process.argv[2]) {
111-
showHelp();
112-
}
113-
else if(process.argv[2] === '-v' || process.argv[2] === '--version') {
114-
checkVersion();
115-
}
116-
}
117-
118-
xtoolkit.command('init', 'npm:weexpack.create');
119-
xtoolkit.command('debug', 'npm:weex-debugger');
120-
xtoolkit.command('compile', 'npm:weex-builder').locate(require.resolve('weex-builder'));
121-
xtoolkit.command('preview', 'npm:weex-previewer').locate(require.resolve('weex-previewer'));
122-
xtoolkit.command('platform', 'npm:weexpack.platform');
123-
xtoolkit.command('plugin', 'npm:weexpack.plugin');
124-
xtoolkit.command('build', 'npm:weexpack.build');
125-
xtoolkit.command('run', 'npm:weexpack.run');
126-
xtoolkit.command('create', 'npm:weexpack.create');
127-
xtoolkit.version(require('../package.json').version);
5+
new (require('../lib/cli'))(process);

Diff for: lib/utils/index.js

-7
This file was deleted.

0 commit comments

Comments
 (0)