Skip to content

Commit 4834ac3

Browse files
authored
Merge pull request #1 from MicroAppJS/develop
Develop
2 parents d9ee2a0 + 415c278 commit 4834ac3

35 files changed

Lines changed: 767 additions & 199 deletions

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
coverage
33
.vscode
44
.circleci
5+
*.d.ts

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ module.exports = {
88
"eslint-config-2o3t"
99
],
1010
parserOptions: {
11-
parser: "babel-eslint"
11+
parser: "babel-eslint",
1212
},
1313
}

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @zyao89

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ Micro APP 依赖工具库.
99
[![NPM Version][npm-img]][npm-url]
1010
[![NPM Download][download-img]][download-url]
1111

12-
[Coverage-img]: https://coveralls.io/repos/github/MicrosApp/MicroApp-Shared-Utils/badge.svg?branch=master
13-
[Coverage-url]: https://coveralls.io/github/MicrosApp/MicroApp-Shared-Utils?branch=master
14-
[CircleCI-img]: https://circleci.com/gh/MicrosApp/MicroApp-Shared-Utils/tree/master.svg?style=svg
15-
[CircleCI-url]: https://circleci.com/gh/MicrosApp/MicroApp-Shared-Utils/tree/master
12+
[Coverage-img]: https://coveralls.io/repos/github/MicroAppJS/MicroApp-Shared-Utils/badge.svg?branch=master
13+
[Coverage-url]: https://coveralls.io/github/MicroAppJS/MicroApp-Shared-Utils?branch=master
14+
[CircleCI-img]: https://circleci.com/gh/MicroAppJS/MicroApp-Shared-Utils/tree/master.svg?style=svg
15+
[CircleCI-url]: https://circleci.com/gh/MicroAppJS/MicroApp-Shared-Utils/tree/master
1616
[npm-img]: https://img.shields.io/npm/v/@micro-app/shared-utils.svg?style=flat-square
1717
[npm-url]: https://npmjs.org/package/@micro-app/shared-utils
1818
[download-img]: https://img.shields.io/npm/dm/@micro-app/shared-utils.svg?style=flat-square

index.d.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import fs from 'fs-extra';
2+
import chalk from 'chalk';
3+
import cheerio from 'cheerio';
4+
import semver from 'semver';
5+
import semverRegex from 'semver-regex';
6+
import _ from 'lodash';
7+
import ora from 'ora';
8+
import dedent from 'dedent';
9+
import globby from 'globby';
10+
import globParent from 'glob-parent';
11+
import isGlob from 'is-glob';
12+
import npa from 'npm-package-arg';
13+
import parseGitUrl from 'git-url-parse';
14+
15+
export function tryRequire( id: string, req?: Object): any | null;
16+
export function assert(value: any, message?: string | Error): void;
17+
18+
import * as moduleAlias from './src/moduleAlias';
19+
import * as getPadLength from './src/getPadLength';
20+
import * as injectHtml from './src/injectHtml';
21+
import * as loadFile from './src/loadFile';
22+
import * as logger from './src/logger';
23+
import * as smartMerge from './src/smartMerge';
24+
import * as virtualFile from './src/virtualFile';
25+
26+
export {
27+
moduleAlias,
28+
getPadLength,
29+
injectHtml,
30+
loadFile,
31+
logger,
32+
smartMerge,
33+
virtualFile,
34+
};
35+
36+
export {
37+
assert,
38+
fs,
39+
chalk,
40+
cheerio,
41+
semver,
42+
semverRegex,
43+
_,
44+
ora,
45+
dedent,
46+
globby,
47+
globParent,
48+
isGlob,
49+
npa,
50+
parseGitUrl,
51+
}

index.js

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,44 @@
11
'use strict';
22

3-
[
3+
const internal = [
44
'moduleAlias',
55
'getPadLength',
66
'injectHtml',
77
'loadFile',
88
'logger',
99
'smartMerge',
1010
'virtualFile',
11-
].forEach(m => {
12-
Object.assign(exports, {
13-
[m]: require(`./libs/${m}`),
11+
].reduce((obj, key) => {
12+
obj[key] = require(`./src/${key}`);
13+
return obj;
14+
}, {});
15+
16+
internal.assert = internal.logger.assert.bind(internal.logger);
17+
18+
const thirdParty = {
19+
fs: 'fs-extra',
20+
chalk: 'chalk',
21+
cheerio: 'cheerio',
22+
semver: 'semver',
23+
semverRegex: 'semver-regex',
24+
_: 'lodash',
25+
tryRequire: 'try-require',
26+
ora: 'ora',
27+
dedent: 'dedent',
28+
globby: 'globby',
29+
globParent: 'glob-parent',
30+
isGlob: 'is-glob',
31+
npa: 'npm-package-arg',
32+
parseGitUrl: 'git-url-parse',
33+
};
34+
35+
Object.keys(thirdParty).forEach(key => {
36+
// lazy
37+
Object.defineProperty(internal, key, {
38+
get() {
39+
return require(thirdParty[key]);
40+
},
1441
});
1542
});
1643

17-
exports.assert = require('assert');
18-
exports.fs = require('fs-extra');
19-
exports.chalk = require('chalk');
20-
exports.cheerio = require('cheerio');
21-
exports.semver = require('semver');
22-
exports.semverRegex = require('semver-regex');
23-
exports._ = require('lodash');
24-
exports.tryRequire = require('try-require');
25-
exports.ora = require('ora');
44+
module.exports = internal;

libs/loadFile.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

libs/logger.js

Lines changed: 0 additions & 86 deletions
This file was deleted.

package.json

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
{
22
"name": "@micro-app/shared-utils",
3-
"version": "0.0.3",
3+
"version": "0.1.0",
44
"description": "[Shared] shared utilities for micro-app.",
55
"main": "index.js",
66
"scripts": {
77
"lint": "eslint .",
88
"lint:fix": "npm run lint -- --fix",
99
"test": "jest"
1010
},
11-
"homepage": "https://github.com/MicrosApp/MicroApp-Shared-Utils",
11+
"homepage": "https://github.com/MicroAppJS/MicroApp-Shared-Utils",
1212
"repository": {
1313
"type": "git",
14-
"url": "git+https://github.com/MicrosApp/MicroApp-Shared-Utils.git"
14+
"url": "git+https://github.com/MicroAppJS/MicroApp-Shared-Utils.git"
1515
},
1616
"bugs": {
17-
"url": "https://github.com/MicrosApp/MicroApp-Shared-Utils/issues"
17+
"url": "https://github.com/MicroAppJS/MicroApp-Shared-Utils/issues"
1818
},
1919
"files": [
20-
"constants",
21-
"libs",
20+
"src",
2221
"index.js"
2322
],
2423
"keywords": [
@@ -54,13 +53,23 @@
5453
"assert": "^2.0.0",
5554
"chalk": "^2.4.2",
5655
"cheerio": "^1.0.0-rc.3",
56+
"dedent": "^0.7.0",
5757
"fs-extra": "^8.1.0",
58+
"git-url-parse": "^11.1.2",
59+
"glob-parent": "^5.1.0",
60+
"globby": "^10.0.1",
61+
"import-fresh": "^3.1.0",
62+
"is-glob": "^4.0.1",
5863
"lodash": "^4.17.15",
64+
"npm-package-arg": "^6.1.1",
65+
"npmlog": "^4.1.2",
5966
"ora": "^3.4.0",
67+
"parse-json": "^5.0.0",
6068
"semver": "^6.3.0",
6169
"semver-regex": "^3.1.0",
6270
"stream-to-string": "^1.2.0",
63-
"try-require": "^1.2.1"
71+
"try-require": "^1.2.1",
72+
"yaml": "^1.7.2"
6473
},
6574
"engines": {
6675
"node": ">=8"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

33
module.exports = {
4+
SCOPE_NAME: '@micro-app',
45
INJECT_ID: '_MICRO_APP_INJECT_',
56
};

0 commit comments

Comments
 (0)