@qn-pandora/pandora-tools 1.1.1 → 2.0.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/CHANGELOG.json +29 -5
- package/CHANGELOG.md +24 -7
- package/README.md +19 -19
- package/bin/pandora-tools +3 -3
- package/package.json +72 -74
- package/src/cli/commands/build.js +32 -32
- package/src/cli/commands/storybook.js +72 -72
- package/src/cli/commands/watchLess.js +32 -0
- package/src/cli/index.js +6 -6
- package/src/gulpfile.js +89 -40
- package/src/index.js +6 -6
- package/src/projectHelper.js +102 -103
- package/src/tasks/clear.js +6 -6
- package/src/tasks/less.js +64 -54
- package/src/tasks/ts.js +54 -54
package/CHANGELOG.json
CHANGED
|
@@ -2,13 +2,37 @@
|
|
|
2
2
|
"name": "@qn-pandora/pandora-tools",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"version": "
|
|
6
|
-
"tag": "@qn-pandora/pandora-
|
|
7
|
-
"date": "
|
|
5
|
+
"version": "2.0.2",
|
|
6
|
+
"tag": "@qn-pandora/pandora-tools_v2.0.2",
|
|
7
|
+
"date": "Wed, 06 Jul 2022 07:32:15 GMT",
|
|
8
8
|
"comments": {
|
|
9
|
-
"
|
|
9
|
+
"patch": [
|
|
10
10
|
{
|
|
11
|
-
"comment": "
|
|
11
|
+
"comment": "07月06日发布"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"version": "2.0.1",
|
|
18
|
+
"tag": "@qn-pandora/pandora-tools_v2.0.1",
|
|
19
|
+
"date": "Wed, 29 Jun 2022 08:28:54 GMT",
|
|
20
|
+
"comments": {
|
|
21
|
+
"patch": [
|
|
22
|
+
{
|
|
23
|
+
"comment": "app脚手架升级新低代码平台,增强searchContainer"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"version": "2.0.0",
|
|
30
|
+
"tag": "@qn-pandora/pandora-tools_v2.0.0",
|
|
31
|
+
"date": "Tue, 14 Jun 2022 09:21:39 GMT",
|
|
32
|
+
"comments": {
|
|
33
|
+
"major": [
|
|
34
|
+
{
|
|
35
|
+
"comment": "很久没发版了,统一发个大版本"
|
|
12
36
|
}
|
|
13
37
|
]
|
|
14
38
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
# Change Log - @qn-pandora/pandora-tools
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 06 Jul 2022 07:32:15 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
Tue, 15 Mar 2022 12:05:29 GMT
|
|
5
|
+
## 2.0.2
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
Wed, 06 Jul 2022 07:32:15 GMT
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
### Patches
|
|
10
|
+
|
|
11
|
+
- 07 月 06 日发布
|
|
12
|
+
|
|
13
|
+
## 2.0.1
|
|
14
|
+
|
|
15
|
+
Wed, 29 Jun 2022 08:28:54 GMT
|
|
16
|
+
|
|
17
|
+
### Patches
|
|
18
|
+
|
|
19
|
+
- app 脚手架升级新低代码平台,增强 searchContainer
|
|
20
|
+
|
|
21
|
+
## 2.0.0
|
|
22
|
+
|
|
23
|
+
Tue, 14 Jun 2022 09:21:39 GMT
|
|
24
|
+
|
|
25
|
+
### Breaking changes
|
|
26
|
+
|
|
27
|
+
- 很久没发版了,统一发个大版本
|
|
11
28
|
|
|
12
29
|
## 1.0.0
|
|
30
|
+
|
|
13
31
|
Mon, 20 Dec 2021 11:46:43 GMT
|
|
14
32
|
|
|
15
33
|
### Breaking changes
|
|
16
34
|
|
|
17
|
-
- 仓库迁移至rush后统一发个大版本
|
|
18
|
-
|
|
35
|
+
- 仓库迁移至 rush 后统一发个大版本
|
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# pandora-tools
|
|
2
|
-
|
|
3
|
-
develop and build pandora lib
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
``` bash
|
|
8
|
-
# run in terminal
|
|
9
|
-
yarn add @qn-pandora/pandora-tools -D
|
|
10
|
-
# or
|
|
11
|
-
npm install @qn-pandora/pandora-tools -dev
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Usage
|
|
15
|
-
|
|
16
|
-
``` bash
|
|
17
|
-
# run this command to get help
|
|
18
|
-
pandora-tools --help
|
|
19
|
-
```
|
|
1
|
+
# pandora-tools
|
|
2
|
+
|
|
3
|
+
develop and build pandora lib
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
``` bash
|
|
8
|
+
# run in terminal
|
|
9
|
+
yarn add @qn-pandora/pandora-tools -D
|
|
10
|
+
# or
|
|
11
|
+
npm install @qn-pandora/pandora-tools -dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
``` bash
|
|
17
|
+
# run this command to get help
|
|
18
|
+
pandora-tools --help
|
|
19
|
+
```
|
package/bin/pandora-tools
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
require('../src/cli')
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
require('../src/cli')
|
package/package.json
CHANGED
|
@@ -1,74 +1,72 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@qn-pandora/pandora-tools",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Pandora Lib 常用开发&打包工具集",
|
|
5
|
-
"author": "pandora <pandora@qiniu.com>",
|
|
6
|
-
"homepage": "https://github.com/qbox/phoenix#readme",
|
|
7
|
-
"license": "ISC",
|
|
8
|
-
"main": "src/index.js",
|
|
9
|
-
"bin": {
|
|
10
|
-
"pandora-tools": "./bin/pandora-tools"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
"/bin",
|
|
14
|
-
"/src"
|
|
15
|
-
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "exit 0",
|
|
18
|
-
"lint": "exit 0"
|
|
19
|
-
},
|
|
20
|
-
"publishConfig": {
|
|
21
|
-
"registry": "https://registry.npmjs.org/"
|
|
22
|
-
},
|
|
23
|
-
"repository": {
|
|
24
|
-
"type": "git",
|
|
25
|
-
"url": "git+https://github.com/qbox/phoenix.git"
|
|
26
|
-
},
|
|
27
|
-
"bugs": {
|
|
28
|
-
"url": "https://github.com/qbox/phoenix/issues"
|
|
29
|
-
},
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"@types/classnames": "^2.2.7",
|
|
32
|
-
"@types/lodash": "^4.14.152",
|
|
33
|
-
"@types/react": "^16.14.5",
|
|
34
|
-
"@types/node": "^14.0.12",
|
|
35
|
-
"gulp": "^4.0.2",
|
|
36
|
-
"gulp-less": "^4.0.1",
|
|
37
|
-
"gulp-typescript": "^6.0.0-alpha.1",
|
|
38
|
-
"less-plugin-autoprefix": "^2.0.0",
|
|
39
|
-
"merge2": "^1.4.1",
|
|
40
|
-
"oclif": "^1.16.1",
|
|
41
|
-
"react-docgen-typescript-loader": "^3.7.2",
|
|
42
|
-
"rimraf": "^3.0.2",
|
|
43
|
-
"through2": "^4.0.2",
|
|
44
|
-
"webpack": "^4.35.3",
|
|
45
|
-
"@oclif/command": "^1",
|
|
46
|
-
"@oclif/errors": "~1.3.5",
|
|
47
|
-
"classnames": "^2.
|
|
48
|
-
"@storybook/react": "6.4.9",
|
|
49
|
-
"@storybook/theming": "6.4.9",
|
|
50
|
-
"@storybook/components": "6.4.9",
|
|
51
|
-
"@storybook/addon-docs": "6.4.9",
|
|
52
|
-
"babel-loader": "^8.1.0",
|
|
53
|
-
"ts-loader": "^7.0.5",
|
|
54
|
-
"@babel/core": "^7.0.1",
|
|
55
|
-
"style-loader": "^0.23.1",
|
|
56
|
-
"css-loader": "^3.0.0",
|
|
57
|
-
"less-loader": "^5.0.0",
|
|
58
|
-
"@mdx-js/loader": "^1.5.1",
|
|
59
|
-
"react-is": "^16.8.0"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
},
|
|
66
|
-
"peerDependencies": {
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@qn-pandora/pandora-tools",
|
|
3
|
+
"version": "2.0.2",
|
|
4
|
+
"description": "Pandora Lib 常用开发&打包工具集",
|
|
5
|
+
"author": "pandora <pandora@qiniu.com>",
|
|
6
|
+
"homepage": "https://github.com/qbox/phoenix#readme",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"main": "src/index.js",
|
|
9
|
+
"bin": {
|
|
10
|
+
"pandora-tools": "./bin/pandora-tools"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"/bin",
|
|
14
|
+
"/src"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "exit 0",
|
|
18
|
+
"lint": "exit 0"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"registry": "https://registry.npmjs.org/"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/qbox/phoenix.git"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/qbox/phoenix/issues"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@types/classnames": "^2.2.7",
|
|
32
|
+
"@types/lodash": "^4.14.152",
|
|
33
|
+
"@types/react": "^16.14.5",
|
|
34
|
+
"@types/node": "^14.0.12",
|
|
35
|
+
"gulp": "^4.0.2",
|
|
36
|
+
"gulp-less": "^4.0.1",
|
|
37
|
+
"gulp-typescript": "^6.0.0-alpha.1",
|
|
38
|
+
"less-plugin-autoprefix": "^2.0.0",
|
|
39
|
+
"merge2": "^1.4.1",
|
|
40
|
+
"oclif": "^1.16.1",
|
|
41
|
+
"react-docgen-typescript-loader": "^3.7.2",
|
|
42
|
+
"rimraf": "^3.0.2",
|
|
43
|
+
"through2": "^4.0.2",
|
|
44
|
+
"webpack": "^4.35.3",
|
|
45
|
+
"@oclif/command": "^1",
|
|
46
|
+
"@oclif/errors": "~1.3.5",
|
|
47
|
+
"classnames": "^2.2.6",
|
|
48
|
+
"@storybook/react": "6.4.9",
|
|
49
|
+
"@storybook/theming": "6.4.9",
|
|
50
|
+
"@storybook/components": "6.4.9",
|
|
51
|
+
"@storybook/addon-docs": "6.4.9",
|
|
52
|
+
"babel-loader": "^8.1.0",
|
|
53
|
+
"ts-loader": "^7.0.5",
|
|
54
|
+
"@babel/core": "^7.0.1",
|
|
55
|
+
"style-loader": "^0.23.1",
|
|
56
|
+
"css-loader": "^3.0.0",
|
|
57
|
+
"less-loader": "^5.0.0",
|
|
58
|
+
"@mdx-js/loader": "^1.5.1",
|
|
59
|
+
"react-is": "^16.8.0",
|
|
60
|
+
"lodash": "^4.17.15",
|
|
61
|
+
"antd": "4.17.1"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"react": "^16.8.6"
|
|
65
|
+
},
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"react": "^16.8.6"
|
|
68
|
+
},
|
|
69
|
+
"oclif": {
|
|
70
|
+
"commands": "./src/cli/commands"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
const { Command } = require('@oclif/command')
|
|
2
|
-
const runTask = require('../../index')
|
|
3
|
-
const { initBuildContext } = require('../../projectHelper')
|
|
4
|
-
|
|
5
|
-
class BuildCommand extends Command {
|
|
6
|
-
async run() {
|
|
7
|
-
initBuildContext()
|
|
8
|
-
|
|
9
|
-
const { type } = this.parse(BuildCommand).args
|
|
10
|
-
runTask('compileTs:' + type)
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
BuildCommand.description = `Build project to esm or cjs
|
|
15
|
-
this command will
|
|
16
|
-
1. build .ts, .tsx
|
|
17
|
-
2. copy .less
|
|
18
|
-
3. generate index.less which import all .less files
|
|
19
|
-
4. build all .less to .css
|
|
20
|
-
you can set esmDir, cjsDir, srcDir in pandora-tools.config.json`
|
|
21
|
-
|
|
22
|
-
BuildCommand.args = [
|
|
23
|
-
{
|
|
24
|
-
name: 'type',
|
|
25
|
-
require: true,
|
|
26
|
-
description: 'module type',
|
|
27
|
-
default: 'esm',
|
|
28
|
-
options: ['esm', 'cjs']
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
|
|
32
|
-
module.exports = BuildCommand
|
|
1
|
+
const { Command } = require('@oclif/command')
|
|
2
|
+
const runTask = require('../../index')
|
|
3
|
+
const { initBuildContext } = require('../../projectHelper')
|
|
4
|
+
|
|
5
|
+
class BuildCommand extends Command {
|
|
6
|
+
async run() {
|
|
7
|
+
initBuildContext()
|
|
8
|
+
|
|
9
|
+
const { type } = this.parse(BuildCommand).args
|
|
10
|
+
runTask('compileTs:' + type)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
BuildCommand.description = `Build project to esm or cjs
|
|
15
|
+
this command will
|
|
16
|
+
1. build .ts, .tsx
|
|
17
|
+
2. copy .less
|
|
18
|
+
3. generate index.less which import all .less files
|
|
19
|
+
4. build all .less to .css
|
|
20
|
+
you can set esmDir, cjsDir, srcDir in pandora-tools.config.json`
|
|
21
|
+
|
|
22
|
+
BuildCommand.args = [
|
|
23
|
+
{
|
|
24
|
+
name: 'type',
|
|
25
|
+
require: true,
|
|
26
|
+
description: 'module type',
|
|
27
|
+
default: 'esm',
|
|
28
|
+
options: ['esm', 'cjs']
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
module.exports = BuildCommand
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
const { Command, flags } = require('@oclif/command')
|
|
2
|
-
const { spawn } = require('child_process')
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const { getProjectPath, initStorybookContext } = require('../../projectHelper')
|
|
5
|
-
|
|
6
|
-
const pandoraToolsDir = path.resolve(__dirname, '../../../')
|
|
7
|
-
const storybookConfigPath = path.resolve(pandoraToolsDir, './.storybook')
|
|
8
|
-
const startOptions = {
|
|
9
|
-
cmd: path.resolve(pandoraToolsDir, './node_modules/.bin/start-storybook'),
|
|
10
|
-
supportFlags: ['config-dir', 'port', 'static-dir']
|
|
11
|
-
}
|
|
12
|
-
const buildOptions = {
|
|
13
|
-
cmd: path.resolve(pandoraToolsDir, './node_modules/.bin/build-storybook'),
|
|
14
|
-
supportFlags: ['config-dir', 'static-dir', 'output-dir']
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
class StoryBookCommand extends Command {
|
|
18
|
-
async run() {
|
|
19
|
-
initStorybookContext()
|
|
20
|
-
|
|
21
|
-
const { args, flags } = this.parse(StoryBookCommand)
|
|
22
|
-
const { cmd, supportFlags } =
|
|
23
|
-
args.type === 'build' ? buildOptions : startOptions
|
|
24
|
-
|
|
25
|
-
const params = supportFlags.map(key => {
|
|
26
|
-
let value = flags[key]
|
|
27
|
-
if (key === 'output-dir' && value) {
|
|
28
|
-
// 默认输出路径
|
|
29
|
-
value = getProjectPath(value)
|
|
30
|
-
}
|
|
31
|
-
return value ? `--${key} ${value}` : ''
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
spawn(cmd, params, { stdio: 'inherit', shell: true, cwd: pandoraToolsDir })
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
StoryBookCommand.description = `start or build storybook of components`
|
|
39
|
-
|
|
40
|
-
StoryBookCommand.args = [
|
|
41
|
-
{
|
|
42
|
-
name: 'type',
|
|
43
|
-
require: true,
|
|
44
|
-
description: 'run type',
|
|
45
|
-
default: 'start',
|
|
46
|
-
options: ['start', 'build']
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
|
|
50
|
-
StoryBookCommand.flags = {
|
|
51
|
-
'config-dir': flags.string({
|
|
52
|
-
char: 'c',
|
|
53
|
-
default: storybookConfigPath,
|
|
54
|
-
description: 'storybook config path'
|
|
55
|
-
}),
|
|
56
|
-
port: flags.integer({
|
|
57
|
-
char: 'p',
|
|
58
|
-
default: 9000,
|
|
59
|
-
description: 'port of storybook run'
|
|
60
|
-
}),
|
|
61
|
-
'static-dir': flags.string({
|
|
62
|
-
char: 's',
|
|
63
|
-
description: 'static directory'
|
|
64
|
-
}),
|
|
65
|
-
'output-dir': flags.string({
|
|
66
|
-
char: 'o',
|
|
67
|
-
default: './storybook-static',
|
|
68
|
-
description: 'output directory, relative to your project root'
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
module.exports = StoryBookCommand
|
|
1
|
+
const { Command, flags } = require('@oclif/command')
|
|
2
|
+
const { spawn } = require('child_process')
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const { getProjectPath, initStorybookContext } = require('../../projectHelper')
|
|
5
|
+
|
|
6
|
+
const pandoraToolsDir = path.resolve(__dirname, '../../../')
|
|
7
|
+
const storybookConfigPath = path.resolve(pandoraToolsDir, './.storybook')
|
|
8
|
+
const startOptions = {
|
|
9
|
+
cmd: path.resolve(pandoraToolsDir, './node_modules/.bin/start-storybook'),
|
|
10
|
+
supportFlags: ['config-dir', 'port', 'static-dir']
|
|
11
|
+
}
|
|
12
|
+
const buildOptions = {
|
|
13
|
+
cmd: path.resolve(pandoraToolsDir, './node_modules/.bin/build-storybook'),
|
|
14
|
+
supportFlags: ['config-dir', 'static-dir', 'output-dir']
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
class StoryBookCommand extends Command {
|
|
18
|
+
async run() {
|
|
19
|
+
initStorybookContext()
|
|
20
|
+
|
|
21
|
+
const { args, flags } = this.parse(StoryBookCommand)
|
|
22
|
+
const { cmd, supportFlags } =
|
|
23
|
+
args.type === 'build' ? buildOptions : startOptions
|
|
24
|
+
|
|
25
|
+
const params = supportFlags.map(key => {
|
|
26
|
+
let value = flags[key]
|
|
27
|
+
if (key === 'output-dir' && !value) {
|
|
28
|
+
// 默认输出路径
|
|
29
|
+
value = getProjectPath(value)
|
|
30
|
+
}
|
|
31
|
+
return value ? `--${key} ${value}` : ''
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
spawn(cmd, params, { stdio: 'inherit', shell: true, cwd: pandoraToolsDir })
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
StoryBookCommand.description = `start or build storybook of components`
|
|
39
|
+
|
|
40
|
+
StoryBookCommand.args = [
|
|
41
|
+
{
|
|
42
|
+
name: 'type',
|
|
43
|
+
require: true,
|
|
44
|
+
description: 'run type',
|
|
45
|
+
default: 'start',
|
|
46
|
+
options: ['start', 'build']
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
StoryBookCommand.flags = {
|
|
51
|
+
'config-dir': flags.string({
|
|
52
|
+
char: 'c',
|
|
53
|
+
default: storybookConfigPath,
|
|
54
|
+
description: 'storybook config path'
|
|
55
|
+
}),
|
|
56
|
+
port: flags.integer({
|
|
57
|
+
char: 'p',
|
|
58
|
+
default: 9000,
|
|
59
|
+
description: 'port of storybook run'
|
|
60
|
+
}),
|
|
61
|
+
'static-dir': flags.string({
|
|
62
|
+
char: 's',
|
|
63
|
+
description: 'static directory'
|
|
64
|
+
}),
|
|
65
|
+
'output-dir': flags.string({
|
|
66
|
+
char: 'o',
|
|
67
|
+
default: './storybook-static',
|
|
68
|
+
description: 'output directory, relative to your project root'
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
module.exports = StoryBookCommand
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const { Command } = require('@oclif/command')
|
|
2
|
+
const runTask = require('../../index')
|
|
3
|
+
const { initBuildContext } = require('../../projectHelper')
|
|
4
|
+
|
|
5
|
+
class WatchLessCommand extends Command {
|
|
6
|
+
async run() {
|
|
7
|
+
initBuildContext()
|
|
8
|
+
|
|
9
|
+
const { type } = this.parse(WatchLessCommand).args
|
|
10
|
+
runTask('watchLess:' + type)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
WatchLessCommand.description = `Watch and build less files to esm or cjs
|
|
15
|
+
this command will
|
|
16
|
+
1. watching less files, run next steps when less files changed
|
|
17
|
+
2. copy .less
|
|
18
|
+
3. generate index.less which import all .less files
|
|
19
|
+
4. build all .less to .css
|
|
20
|
+
you can set esmDir, cjsDir, srcDir in pandora-tools.config.json`
|
|
21
|
+
|
|
22
|
+
WatchLessCommand.args = [
|
|
23
|
+
{
|
|
24
|
+
name: 'type',
|
|
25
|
+
require: true,
|
|
26
|
+
description: 'module type',
|
|
27
|
+
default: 'esm',
|
|
28
|
+
options: ['esm', 'cjs']
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
module.exports = WatchLessCommand
|
package/src/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
require('@oclif/command')
|
|
4
|
-
.run()
|
|
5
|
-
.then(require('@oclif/command/flush'))
|
|
6
|
-
.catch(require('@oclif/errors/handle'))
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
require('@oclif/command')
|
|
4
|
+
.run()
|
|
5
|
+
.then(require('@oclif/command/flush'))
|
|
6
|
+
.catch(require('@oclif/errors/handle'))
|
package/src/gulpfile.js
CHANGED
|
@@ -1,40 +1,89 @@
|
|
|
1
|
-
const gulp = require('gulp')
|
|
2
|
-
const clear = require('./tasks/clear')
|
|
3
|
-
const compileLess = require('./tasks/less')
|
|
4
|
-
const compileTs = require('./tasks/ts')
|
|
5
|
-
const {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
1
|
+
const gulp = require('gulp')
|
|
2
|
+
const clear = require('./tasks/clear')
|
|
3
|
+
const compileLess = require('./tasks/less')
|
|
4
|
+
const compileTs = require('./tasks/ts')
|
|
5
|
+
const {
|
|
6
|
+
getProjectRoot,
|
|
7
|
+
getToolsConfig,
|
|
8
|
+
getPackageJSON
|
|
9
|
+
} = require('./projectHelper')
|
|
10
|
+
|
|
11
|
+
process.on('uncaughtException', function (err) {
|
|
12
|
+
console.error(err.message)
|
|
13
|
+
process.exit(1)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
function compileLessToEsm() {
|
|
17
|
+
const { srcDir, esmDir } = getToolsConfig()
|
|
18
|
+
return compileLess(srcDir, esmDir)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function compileLessToCjs() {
|
|
22
|
+
const { srcDir, libDir } = getToolsConfig()
|
|
23
|
+
return compileLess(srcDir, libDir)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function building() {
|
|
27
|
+
console.log('building')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function done() {
|
|
31
|
+
console.log('done')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* watch 模式下构建报错不应该退出程序
|
|
36
|
+
*/
|
|
37
|
+
function catchErr(fn) {
|
|
38
|
+
return async () => {
|
|
39
|
+
try {
|
|
40
|
+
return await fn()
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.error(e)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
gulp.task(
|
|
48
|
+
'compileTs:esm',
|
|
49
|
+
gulp.series(
|
|
50
|
+
() => clear(getToolsConfig().esmDir),
|
|
51
|
+
() =>
|
|
52
|
+
compileTs(getProjectRoot(), getToolsConfig().esmDir, {
|
|
53
|
+
module: 'esnext'
|
|
54
|
+
}),
|
|
55
|
+
compileLessToEsm
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
gulp.task(
|
|
60
|
+
'compileTs:cjs',
|
|
61
|
+
gulp.series(
|
|
62
|
+
() => clear(getToolsConfig().libDir),
|
|
63
|
+
() =>
|
|
64
|
+
compileTs(getProjectRoot(), getToolsConfig().libDir, {
|
|
65
|
+
module: 'commonjs'
|
|
66
|
+
}),
|
|
67
|
+
compileLessToCjs
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
gulp.task('watchLess:esm', function () {
|
|
72
|
+
console.log(
|
|
73
|
+
`[pandora tools] watchLess:esm watching ${getPackageJSON().name}...`
|
|
74
|
+
)
|
|
75
|
+
return gulp.watch(
|
|
76
|
+
`${getToolsConfig().srcDir}/**/*.less`,
|
|
77
|
+
gulp.series(building, catchErr(compileLessToEsm), done)
|
|
78
|
+
)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
gulp.task('watchLess:cjs', function () {
|
|
82
|
+
console.log(
|
|
83
|
+
`[pandora tools] watchLess:cjs watching ${getPackageJSON().name}...`
|
|
84
|
+
)
|
|
85
|
+
return gulp.watch(
|
|
86
|
+
`${getToolsConfig().srcDir}/**/*.less`,
|
|
87
|
+
gulp.series(building, catchErr(compileLessToCjs), done)
|
|
88
|
+
)
|
|
89
|
+
})
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const gulp = require('gulp')
|
|
2
|
-
require('./gulpfile')
|
|
3
|
-
|
|
4
|
-
module.exports = function(taskName) {
|
|
5
|
-
gulp.task(taskName).apply(gulp)
|
|
6
|
-
}
|
|
1
|
+
const gulp = require('gulp')
|
|
2
|
+
require('./gulpfile')
|
|
3
|
+
|
|
4
|
+
module.exports = function(taskName) {
|
|
5
|
+
gulp.task(taskName).apply(gulp)
|
|
6
|
+
}
|
package/src/projectHelper.js
CHANGED
|
@@ -1,103 +1,102 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
|
|
4
|
-
const projectConfigFile = path.join(__dirname, '../project.json')
|
|
5
|
-
|
|
6
|
-
let isStorybookContext = true
|
|
7
|
-
|
|
8
|
-
function initBuildContext() {
|
|
9
|
-
initContext('build')
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function initStorybookContext() {
|
|
13
|
-
initContext('storybook')
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function initContext(context) {
|
|
17
|
-
if (context === 'build') {
|
|
18
|
-
isStorybookContext = false
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (isStorybookContext) {
|
|
22
|
-
const projectRoot = process.cwd()
|
|
23
|
-
let data = {}
|
|
24
|
-
try {
|
|
25
|
-
data = getProjectConfig()
|
|
26
|
-
} catch (e) {
|
|
27
|
-
// do nothing
|
|
28
|
-
}
|
|
29
|
-
console.log('[pandora tools] init storybook project root: ', projectRoot)
|
|
30
|
-
setProjectConfig({ ...data, projectRoot })
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function getProjectConfig() {
|
|
35
|
-
if (fs.existsSync(projectConfigFile)) {
|
|
36
|
-
const raw = fs.readFileSync(projectConfigFile)
|
|
37
|
-
return JSON.parse(raw)
|
|
38
|
-
}
|
|
39
|
-
return {}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function setProjectConfig(config) {
|
|
43
|
-
fs.writeFileSync(projectConfigFile, JSON.stringify(config))
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getProjectRoot() {
|
|
47
|
-
let projectRoot = process.cwd()
|
|
48
|
-
if (isStorybookContext) {
|
|
49
|
-
try {
|
|
50
|
-
const config = getProjectConfig()
|
|
51
|
-
projectRoot = config.projectRoot
|
|
52
|
-
} catch (e) {
|
|
53
|
-
// do nothing
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
|
|
4
|
+
const projectConfigFile = path.join(__dirname, '../project.json')
|
|
5
|
+
|
|
6
|
+
let isStorybookContext = true
|
|
7
|
+
|
|
8
|
+
function initBuildContext() {
|
|
9
|
+
initContext('build')
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function initStorybookContext() {
|
|
13
|
+
initContext('storybook')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function initContext(context) {
|
|
17
|
+
if (context === 'build') {
|
|
18
|
+
isStorybookContext = false
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (isStorybookContext) {
|
|
22
|
+
const projectRoot = process.cwd()
|
|
23
|
+
let data = {}
|
|
24
|
+
try {
|
|
25
|
+
data = getProjectConfig()
|
|
26
|
+
} catch (e) {
|
|
27
|
+
// do nothing
|
|
28
|
+
}
|
|
29
|
+
console.log('[pandora tools] init storybook project root: ', projectRoot)
|
|
30
|
+
setProjectConfig({ ...data, projectRoot })
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getProjectConfig() {
|
|
35
|
+
if (fs.existsSync(projectConfigFile)) {
|
|
36
|
+
const raw = fs.readFileSync(projectConfigFile)
|
|
37
|
+
return JSON.parse(raw)
|
|
38
|
+
}
|
|
39
|
+
return {}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function setProjectConfig(config) {
|
|
43
|
+
fs.writeFileSync(projectConfigFile, JSON.stringify(config))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getProjectRoot() {
|
|
47
|
+
let projectRoot = process.cwd()
|
|
48
|
+
if (isStorybookContext) {
|
|
49
|
+
try {
|
|
50
|
+
const config = getProjectConfig()
|
|
51
|
+
projectRoot = config.projectRoot
|
|
52
|
+
} catch (e) {
|
|
53
|
+
// do nothing
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return projectRoot
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function getProjectPath(pathStr) {
|
|
60
|
+
const projectRoot = getProjectRoot()
|
|
61
|
+
return path.resolve(projectRoot, pathStr)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getConfig(pathStr) {
|
|
65
|
+
const configPath = getProjectPath(pathStr)
|
|
66
|
+
if (fs.existsSync(configPath)) {
|
|
67
|
+
return require(configPath)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getToolsConfig(pathStr) {
|
|
74
|
+
const toolsConfig = getConfig(pathStr || '.pandora-tools.config.js')
|
|
75
|
+
return Object.assign(
|
|
76
|
+
{
|
|
77
|
+
srcDir: './src',
|
|
78
|
+
esmDir: './es',
|
|
79
|
+
libDir: './lib',
|
|
80
|
+
mainFileName: 'index'
|
|
81
|
+
},
|
|
82
|
+
toolsConfig
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getWebpackConfig(pathStr) {
|
|
87
|
+
return getConfig(pathStr || 'webpack.config.js')
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function getPackageJSON() {
|
|
91
|
+
return getConfig('package.json')
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
module.exports = {
|
|
95
|
+
initBuildContext,
|
|
96
|
+
initStorybookContext,
|
|
97
|
+
getProjectRoot,
|
|
98
|
+
getProjectPath,
|
|
99
|
+
getToolsConfig,
|
|
100
|
+
getWebpackConfig,
|
|
101
|
+
getPackageJSON
|
|
102
|
+
}
|
package/src/tasks/clear.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const rimraf = require('rimraf')
|
|
2
|
-
|
|
3
|
-
module.exports = function(dir) {
|
|
4
|
-
rimraf.sync(dir)
|
|
5
|
-
return Promise.resolve()
|
|
6
|
-
}
|
|
1
|
+
const rimraf = require('rimraf')
|
|
2
|
+
|
|
3
|
+
module.exports = function(dir) {
|
|
4
|
+
rimraf.sync(dir)
|
|
5
|
+
return Promise.resolve()
|
|
6
|
+
}
|
package/src/tasks/less.js
CHANGED
|
@@ -1,54 +1,64 @@
|
|
|
1
|
-
const gulp = require('gulp')
|
|
2
|
-
const gulpLess = require('gulp-less')
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const fs = require('fs')
|
|
5
|
-
const through2 = require('through2')
|
|
6
|
-
const LessAutoprefix = require('less-plugin-autoprefix')
|
|
7
|
-
|
|
8
|
-
const autoprefix = new LessAutoprefix({ browsers: ['last 2 versions'] })
|
|
9
|
-
|
|
10
|
-
function copyLess(srcDir, outDir) {
|
|
11
|
-
const imports = []
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
1
|
+
const gulp = require('gulp')
|
|
2
|
+
const gulpLess = require('gulp-less')
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const fs = require('fs')
|
|
5
|
+
const through2 = require('through2')
|
|
6
|
+
const LessAutoprefix = require('less-plugin-autoprefix')
|
|
7
|
+
|
|
8
|
+
const autoprefix = new LessAutoprefix({ browsers: ['last 2 versions'] })
|
|
9
|
+
|
|
10
|
+
function copyLess(srcDir, outDir) {
|
|
11
|
+
const imports = []
|
|
12
|
+
return new Promise(function (resolve, reject) {
|
|
13
|
+
gulp
|
|
14
|
+
.src(`${srcDir}/**/*.less`)
|
|
15
|
+
.on('error', reject)
|
|
16
|
+
.pipe(
|
|
17
|
+
through2.obj(function (file, _, next) {
|
|
18
|
+
this.push(file)
|
|
19
|
+
const filePath = path.relative(outDir, file.path)
|
|
20
|
+
imports.push(`@import './${filePath}';`)
|
|
21
|
+
next()
|
|
22
|
+
})
|
|
23
|
+
)
|
|
24
|
+
.on('error', reject)
|
|
25
|
+
.pipe(gulp.dest(outDir))
|
|
26
|
+
.on('error', reject)
|
|
27
|
+
.on('finish', function () {
|
|
28
|
+
if (imports.length === 0) {
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
// when copy finish write root index.less
|
|
32
|
+
fs.writeFileSync(
|
|
33
|
+
path.resolve(outDir, 'index.less'),
|
|
34
|
+
imports.join('\n'),
|
|
35
|
+
'utf8'
|
|
36
|
+
)
|
|
37
|
+
resolve()
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function compileLess(srcDir, outDir) {
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
gulp
|
|
45
|
+
.src(`${srcDir}/**/*.less`)
|
|
46
|
+
.on('error', reject)
|
|
47
|
+
.pipe(
|
|
48
|
+
gulpLess({
|
|
49
|
+
paths: [srcDir, 'node_modules'],
|
|
50
|
+
plugins: [autoprefix],
|
|
51
|
+
javascriptEnabled: true
|
|
52
|
+
})
|
|
53
|
+
)
|
|
54
|
+
.on('error', reject)
|
|
55
|
+
.pipe(gulp.dest(outDir))
|
|
56
|
+
.on('error', reject)
|
|
57
|
+
.on('finish', resolve)
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = async function (srcDir, outDir) {
|
|
62
|
+
await copyLess(srcDir, outDir)
|
|
63
|
+
await compileLess(outDir, outDir)
|
|
64
|
+
}
|
package/src/tasks/ts.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const gulp = require('gulp')
|
|
3
|
-
const tsGulp = require('gulp-typescript')
|
|
4
|
-
const merge = require('merge2')
|
|
5
|
-
|
|
6
|
-
module.exports = function(projectDir, outDir, extraTsConfig) {
|
|
7
|
-
const tsProject = tsGulp.createProject(
|
|
8
|
-
path.resolve(projectDir, 'tsconfig.json'),
|
|
9
|
-
extraTsConfig
|
|
10
|
-
)
|
|
11
|
-
const tsResult = tsProject.src().pipe(tsProject())
|
|
12
|
-
return merge([
|
|
13
|
-
tsResult.js.pipe(gulp.dest(outDir)),
|
|
14
|
-
tsResult.dts.pipe(gulp.dest(outDir))
|
|
15
|
-
])
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/* function compileByWebpack(done) {
|
|
19
|
-
rimraf.sync(distDir)
|
|
20
|
-
process.env.RUN_ENV = 'PRODUCTION'
|
|
21
|
-
webpack(getWebpackConfig(), (err, stats) => {
|
|
22
|
-
if (err) {
|
|
23
|
-
console.error(err.stack || err)
|
|
24
|
-
if (err.details) {
|
|
25
|
-
console.error(err.details)
|
|
26
|
-
}
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const info = stats.toJson()
|
|
31
|
-
|
|
32
|
-
if (stats.hasErrors()) {
|
|
33
|
-
console.error(info.errors)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (stats.hasWarnings()) {
|
|
37
|
-
console.warn(info.warnings)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const buildInfo = stats.toString({
|
|
41
|
-
colors: true,
|
|
42
|
-
children: true,
|
|
43
|
-
chunks: false,
|
|
44
|
-
modules: false,
|
|
45
|
-
chunkModules: false,
|
|
46
|
-
hash: false,
|
|
47
|
-
version: false
|
|
48
|
-
})
|
|
49
|
-
console.log(buildInfo)
|
|
50
|
-
|
|
51
|
-
done(0)
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
gulp.task('compileTs:dist', compileByWebpack)*/
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const gulp = require('gulp')
|
|
3
|
+
const tsGulp = require('gulp-typescript')
|
|
4
|
+
const merge = require('merge2')
|
|
5
|
+
|
|
6
|
+
module.exports = function(projectDir, outDir, extraTsConfig) {
|
|
7
|
+
const tsProject = tsGulp.createProject(
|
|
8
|
+
path.resolve(projectDir, 'tsconfig.json'),
|
|
9
|
+
extraTsConfig
|
|
10
|
+
)
|
|
11
|
+
const tsResult = tsProject.src().pipe(tsProject())
|
|
12
|
+
return merge([
|
|
13
|
+
tsResult.js.pipe(gulp.dest(outDir)),
|
|
14
|
+
tsResult.dts.pipe(gulp.dest(outDir))
|
|
15
|
+
])
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* function compileByWebpack(done) {
|
|
19
|
+
rimraf.sync(distDir)
|
|
20
|
+
process.env.RUN_ENV = 'PRODUCTION'
|
|
21
|
+
webpack(getWebpackConfig(), (err, stats) => {
|
|
22
|
+
if (err) {
|
|
23
|
+
console.error(err.stack || err)
|
|
24
|
+
if (err.details) {
|
|
25
|
+
console.error(err.details)
|
|
26
|
+
}
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const info = stats.toJson()
|
|
31
|
+
|
|
32
|
+
if (stats.hasErrors()) {
|
|
33
|
+
console.error(info.errors)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (stats.hasWarnings()) {
|
|
37
|
+
console.warn(info.warnings)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const buildInfo = stats.toString({
|
|
41
|
+
colors: true,
|
|
42
|
+
children: true,
|
|
43
|
+
chunks: false,
|
|
44
|
+
modules: false,
|
|
45
|
+
chunkModules: false,
|
|
46
|
+
hash: false,
|
|
47
|
+
version: false
|
|
48
|
+
})
|
|
49
|
+
console.log(buildInfo)
|
|
50
|
+
|
|
51
|
+
done(0)
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
gulp.task('compileTs:dist', compileByWebpack)*/
|