@qn-pandora/pandora-tools 2.0.11 → 2.0.13
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 +185 -161
- package/CHANGELOG.md +123 -107
- package/README.md +19 -19
- package/bin/pandora-tools +3 -3
- package/package.json +69 -69
- package/src/cli/commands/build.js +32 -32
- package/src/cli/commands/storybook.js +72 -72
- package/src/cli/commands/watchLess.js +32 -32
- package/src/cli/index.js +6 -6
- package/src/gulpfile.js +89 -89
- package/src/index.js +6 -6
- package/src/projectHelper.js +102 -102
- package/src/tasks/clear.js +6 -6
- package/src/tasks/less.js +64 -64
- package/src/tasks/ts.js +54 -54
package/package.json
CHANGED
@@ -1,69 +1,69 @@
|
|
1
|
-
{
|
2
|
-
"name": "@qn-pandora/pandora-tools",
|
3
|
-
"version": "2.0.
|
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
|
-
"repository": {
|
21
|
-
"type": "git",
|
22
|
-
"url": "git+https://github.com/qbox/phoenix.git"
|
23
|
-
},
|
24
|
-
"bugs": {
|
25
|
-
"url": "https://github.com/qbox/phoenix/issues"
|
26
|
-
},
|
27
|
-
"dependencies": {
|
28
|
-
"@types/classnames": "^2.2.7",
|
29
|
-
"@types/lodash": "^4.14.152",
|
30
|
-
"@types/react": "^16.14.5",
|
31
|
-
"@types/node": "^14.0.12",
|
32
|
-
"gulp": "^4.0.2",
|
33
|
-
"gulp-less": "^4.0.1",
|
34
|
-
"gulp-typescript": "^6.0.0-alpha.1",
|
35
|
-
"less-plugin-autoprefix": "^2.0.0",
|
36
|
-
"merge2": "^1.4.1",
|
37
|
-
"oclif": "^1.16.1",
|
38
|
-
"react-docgen-typescript-loader": "^3.7.2",
|
39
|
-
"rimraf": "^3.0.2",
|
40
|
-
"through2": "^4.0.2",
|
41
|
-
"webpack": "^4.35.3",
|
42
|
-
"@oclif/command": "^1",
|
43
|
-
"@oclif/errors": "~1.3.5",
|
44
|
-
"classnames": "^2.2.6",
|
45
|
-
"@storybook/react": "6.4.9",
|
46
|
-
"@storybook/theming": "6.4.9",
|
47
|
-
"@storybook/components": "6.4.9",
|
48
|
-
"@storybook/addon-docs": "6.4.9",
|
49
|
-
"babel-loader": "^8.1.0",
|
50
|
-
"ts-loader": "^7.0.5",
|
51
|
-
"@babel/core": "^7.19.6",
|
52
|
-
"style-loader": "^0.23.1",
|
53
|
-
"css-loader": "^3.0.0",
|
54
|
-
"less-loader": "^5.0.0",
|
55
|
-
"@mdx-js/loader": "^1.5.1",
|
56
|
-
"react-is": "^16.8.0",
|
57
|
-
"lodash": "^4.17.15",
|
58
|
-
"antd": "4.17.1"
|
59
|
-
},
|
60
|
-
"devDependencies": {
|
61
|
-
"react": "^16.8.6"
|
62
|
-
},
|
63
|
-
"peerDependencies": {
|
64
|
-
"react": "^16.8.6"
|
65
|
-
},
|
66
|
-
"oclif": {
|
67
|
-
"commands": "./src/cli/commands"
|
68
|
-
}
|
69
|
-
}
|
1
|
+
{
|
2
|
+
"name": "@qn-pandora/pandora-tools",
|
3
|
+
"version": "2.0.13",
|
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
|
+
"repository": {
|
21
|
+
"type": "git",
|
22
|
+
"url": "git+https://github.com/qbox/phoenix.git"
|
23
|
+
},
|
24
|
+
"bugs": {
|
25
|
+
"url": "https://github.com/qbox/phoenix/issues"
|
26
|
+
},
|
27
|
+
"dependencies": {
|
28
|
+
"@types/classnames": "^2.2.7",
|
29
|
+
"@types/lodash": "^4.14.152",
|
30
|
+
"@types/react": "^16.14.5",
|
31
|
+
"@types/node": "^14.0.12",
|
32
|
+
"gulp": "^4.0.2",
|
33
|
+
"gulp-less": "^4.0.1",
|
34
|
+
"gulp-typescript": "^6.0.0-alpha.1",
|
35
|
+
"less-plugin-autoprefix": "^2.0.0",
|
36
|
+
"merge2": "^1.4.1",
|
37
|
+
"oclif": "^1.16.1",
|
38
|
+
"react-docgen-typescript-loader": "^3.7.2",
|
39
|
+
"rimraf": "^3.0.2",
|
40
|
+
"through2": "^4.0.2",
|
41
|
+
"webpack": "^4.35.3",
|
42
|
+
"@oclif/command": "^1",
|
43
|
+
"@oclif/errors": "~1.3.5",
|
44
|
+
"classnames": "^2.2.6",
|
45
|
+
"@storybook/react": "6.4.9",
|
46
|
+
"@storybook/theming": "6.4.9",
|
47
|
+
"@storybook/components": "6.4.9",
|
48
|
+
"@storybook/addon-docs": "6.4.9",
|
49
|
+
"babel-loader": "^8.1.0",
|
50
|
+
"ts-loader": "^7.0.5",
|
51
|
+
"@babel/core": "^7.19.6",
|
52
|
+
"style-loader": "^0.23.1",
|
53
|
+
"css-loader": "^3.0.0",
|
54
|
+
"less-loader": "^5.0.0",
|
55
|
+
"@mdx-js/loader": "^1.5.1",
|
56
|
+
"react-is": "^16.8.0",
|
57
|
+
"lodash": "^4.17.15",
|
58
|
+
"antd": "4.17.1"
|
59
|
+
},
|
60
|
+
"devDependencies": {
|
61
|
+
"react": "^16.8.6"
|
62
|
+
},
|
63
|
+
"peerDependencies": {
|
64
|
+
"react": "^16.8.6"
|
65
|
+
},
|
66
|
+
"oclif": {
|
67
|
+
"commands": "./src/cli/commands"
|
68
|
+
}
|
69
|
+
}
|
@@ -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
|
@@ -1,32 +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
|
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,89 +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
|
-
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
|
-
})
|
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
|
+
}
|