ko 5.3.10 → 6.1.0

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/README.md CHANGED
@@ -1,3 +1,38 @@
1
1
  # ko
2
2
 
3
- build & lint library
3
+ ## Simple, yet powerful, tool for managing your react applications.
4
+
5
+ <a href="https://www.npmjs.com/package/ko"><img alt="NPM Status" src="https://img.shields.io/npm/v/ko.svg?style=flat"></a>
6
+
7
+ ## Features
8
+
9
+ * Support building applications on top of **webpack v5** and **esbuild**
10
+ * Customize ko to work exactly the way you need it for your applications
11
+ * Built-in popular linting tools to lint your source code
12
+ * Built-in support typescript
13
+
14
+ ## Installation
15
+
16
+ You can install ko using npm, yarn or pnpm:
17
+ ``` bash
18
+ npm install ko --save-dev
19
+ # or
20
+ yarn add ko --dev
21
+ # or
22
+ pnpm add ko --save-dev
23
+ ```
24
+
25
+ ## Documents
26
+ * [Introduction](https://dtstack.github.io/ko/docs/introduction)
27
+ * [Getting Started](https://dtstack.github.io/ko/docs/getting-started)
28
+ * [FAQ](https://dtstack.github.io/ko/docs/FAQ)
29
+
30
+ ## Contributing
31
+
32
+ We'd love to have your helping hand on `ko`! See [CONTRIBUTING](https://dtstack.github.io/ko/docs/contributing/) for more information on how to get started.
33
+
34
+ ## License
35
+
36
+ Copyright © DTStack. All rights reserved.
37
+
38
+ Licensed under the MIT license.
@@ -4,66 +4,60 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const webpack_1 = __importDefault(require("webpack"));
7
- const creator_1 = require("./creator");
8
- const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
9
- class Build extends creator_1.WebpackCreator {
10
- constructor(opts) {
11
- super(opts);
7
+ const webpack_2 = __importDefault(require("../webpack"));
8
+ const factory_1 = require("./factory");
9
+ const css_minimizer_webpack_plugin_1 = __importDefault(require("css-minimizer-webpack-plugin"));
10
+ const esbuild_loader_1 = require("esbuild-loader");
11
+ class Build extends factory_1.ActionFactory {
12
+ constructor(service) {
13
+ super(service);
12
14
  }
13
- config() {
14
- // const { esbuild } = this.opts;
15
- const conf = {
15
+ async generateConfig() {
16
+ this.webpackConfig = new webpack_2.default(this.service);
17
+ const extraConfig = {
16
18
  optimization: {
17
19
  minimize: true,
18
- minimizer: ['...', new CssMinimizerPlugin()],
20
+ minimizer: this.service.config.experiment?.minimizer
21
+ ? [
22
+ new esbuild_loader_1.ESBuildMinifyPlugin({
23
+ target: 'es2015',
24
+ css: true,
25
+ }),
26
+ ]
27
+ : ['...', css_minimizer_webpack_plugin_1.default.parcelCssMinify],
19
28
  },
20
- plugins: [
21
- new webpack_1.default.optimize.SplitChunksPlugin({
22
- chunks: 'all',
23
- minSize: 30000,
24
- maxSize: 600000,
25
- minChunks: 1,
26
- automaticNameDelimiter: '_',
27
- cacheGroups: {
28
- baseCommon: {
29
- test: new RegExp(`[\\/]node_modules[\\/](${[
30
- 'react',
31
- 'react-router',
32
- 'react-dom',
33
- 'react-redux',
34
- 'redux',
35
- 'react-router-redux',
36
- ].join('|')})`),
37
- priority: 1,
38
- },
39
- antd: {
40
- name: 'antd',
41
- test: /[\\/]node_modules[\\/]antd[\\/]/,
42
- chunks: 'initial',
43
- },
44
- lodash: {
45
- name: 'lodash',
46
- test: /[\\/]node_modules[\\/]lodash[\\/]/,
47
- chunks: 'initial',
48
- priority: -10,
49
- },
50
- default: {
51
- minChunks: 2,
52
- priority: -20,
53
- reuseExistingChunk: true,
54
- },
55
- },
56
- }),
57
- ],
58
29
  };
59
- return this.mergeConfig([this.baseConfig, conf]);
30
+ const ret = this.webpackConfig.merge(extraConfig);
31
+ const plugins = await this.service.apply({
32
+ key: this.service.hookKeySet.WEBPACK_PLUGIN,
33
+ context: ret.plugins,
34
+ });
35
+ ret.plugins = plugins;
36
+ return ret;
37
+ }
38
+ registerCommand() {
39
+ const cmdName = 'build';
40
+ this.service.commander.registerCommand({
41
+ name: cmdName,
42
+ description: 'build project',
43
+ options: [
44
+ {
45
+ flags: '--hash',
46
+ description: 'output file name with hash',
47
+ },
48
+ ],
49
+ });
50
+ this.service.commander.bindAction(cmdName, this.action.bind(this));
60
51
  }
61
- action() {
62
- //TODO: redefine stats
63
- (0, webpack_1.default)(this.config(), (error, stats) => {
52
+ async action(cliOpts) {
53
+ process.title = 'ko-build';
54
+ process.env.NODE_ENV = 'production';
55
+ this.service.freezeCliOptsWith(cliOpts);
56
+ const config = await this.generateConfig();
57
+ (0, webpack_1.default)(config, (error, stats) => {
64
58
  if (stats && stats.hasErrors()) {
65
59
  throw stats.toString({
66
- logging: 'warn',
60
+ logging: 'error',
67
61
  colors: true,
68
62
  });
69
63
  }
@@ -5,103 +5,95 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const webpack_1 = __importDefault(require("webpack"));
7
7
  const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
8
- const detect_port_1 = __importDefault(require("detect-port"));
9
- const inquirer_1 = require("inquirer");
10
- const config_1 = __importDefault(require("../utils/config"));
11
- const creator_1 = require("./creator");
12
- const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
13
- class Dev extends creator_1.WebpackCreator {
14
- constructor(opts) {
15
- super(opts);
16
- const { port, host } = this.opts;
17
- const userDefinedDevServerConfig = config_1.default.userConf.devServer || {};
18
- this.devServerConf = {
8
+ const webpack_2 = __importDefault(require("../webpack"));
9
+ const factory_1 = __importDefault(require("./factory"));
10
+ class Dev extends factory_1.default {
11
+ constructor(service) {
12
+ super(service);
13
+ }
14
+ get devServerConfig() {
15
+ const { serve, publicPath } = this.service.config;
16
+ const { host, port, proxy, staticPath } = serve;
17
+ return {
19
18
  port,
20
19
  host,
21
- contentBase: config_1.default.defaultPaths.dist,
22
- historyApiFallback: true,
23
- disableHostCheck: true,
24
- compress: true,
25
- clientLogLevel: 'none',
26
20
  hot: true,
27
- inline: true,
28
- publicPath: '/',
29
- watchOptions: {
30
- ignored: /node_modules/,
31
- aggregateTimeout: 600,
21
+ proxy,
22
+ static: {
23
+ directory: staticPath,
24
+ watch: true,
25
+ publicPath,
32
26
  },
33
- ...userDefinedDevServerConfig,
34
- };
35
- }
36
- config() {
37
- const conf = {
38
- devtool: 'cheap-module-source-map',
39
- plugins: [this.opts.analyzer && new BundleAnalyzerPlugin()].filter(Boolean),
40
- optimization: {
41
- splitChunks: {
42
- chunks: 'all',
43
- },
27
+ setupExitSignals: false,
28
+ allowedHosts: 'all',
29
+ client: {
30
+ overlay: false,
31
+ logging: 'none',
44
32
  },
45
33
  };
46
- return this.mergeConfig([this.baseConfig, conf]);
47
34
  }
48
- async changePort(newPort, port) {
49
- const question = {
50
- type: 'confirm',
51
- name: 'changePort',
52
- message: `port: ${port} has been used,use new port ${newPort} instead?`,
53
- default: true,
35
+ async generateConfig() {
36
+ this.webpackConfig = new webpack_2.default(this.service);
37
+ const extraConfig = {
38
+ devtool: 'cheap-module-source-map',
39
+ mode: 'development',
54
40
  };
55
- const answer = await (0, inquirer_1.prompt)([question]);
56
- if (answer.changePort) {
57
- return newPort;
58
- }
59
- else {
60
- return null;
61
- }
62
- }
63
- async checkPort(port) {
64
- const newPort = await (0, detect_port_1.default)(port);
65
- if (newPort === port) {
66
- return newPort;
67
- }
68
- const isInteractive = process.stdout.isTTY;
69
- if (isInteractive) {
70
- return this.changePort(newPort, port);
41
+ const ret = this.webpackConfig.merge(extraConfig, {
42
+ devServer: this.devServerConfig,
43
+ });
44
+ if (ret.plugins) {
45
+ const plugins = await this.service.apply({
46
+ key: this.service.hookKeySet.WEBPACK_PLUGIN,
47
+ context: ret.plugins,
48
+ });
49
+ ret.plugins = plugins;
71
50
  }
51
+ ret.experiments = {
52
+ lazyCompilation: this.service.config?.experiment?.speedUp,
53
+ };
54
+ return ret;
72
55
  }
73
- threadLoaderWarmUp() {
74
- const threadLoader = require('thread-loader');
75
- threadLoader.warmup({}, [require.resolve('babel-loader')]);
56
+ registerCommand() {
57
+ const cmdName = 'dev';
58
+ this.service.commander.registerCommand({
59
+ name: cmdName,
60
+ description: 'start devServer',
61
+ options: [
62
+ {
63
+ flags: '--hash',
64
+ description: 'output file name with hash',
65
+ },
66
+ {
67
+ flags: '--analyzer',
68
+ description: 'support building analyzer',
69
+ },
70
+ ],
71
+ });
72
+ this.service.commander.bindAction(cmdName, this.action.bind(this));
76
73
  }
77
- async action() {
78
- const { port } = this.devServerConf;
79
- const newPort = await this.checkPort(port);
80
- if (!newPort) {
74
+ async action(cliOpts) {
75
+ process.title = 'ko-dev';
76
+ process.env.NODE_ENV = 'development';
77
+ this.service.freezeCliOptsWith(cliOpts);
78
+ const config = await this.generateConfig();
79
+ const compiler = (0, webpack_1.default)(config);
80
+ const devServer = new webpack_dev_server_1.default(config.devServer, compiler);
81
+ await devServer.start();
82
+ const exitProcess = (callback) => () => {
83
+ callback && callback();
81
84
  process.exit(0);
82
- }
83
- this.devServerConf.port = newPort;
84
- webpack_dev_server_1.default.addDevServerEntrypoints(this.config(), this.devServerConf);
85
- this.threadLoaderWarmUp();
86
- const compiler = (0, webpack_1.default)(this.config());
87
- const devServer = new webpack_dev_server_1.default(compiler, this.devServerConf);
88
- let isFirstCompile = true;
89
- compiler.hooks.done.tap('done', stats => {
90
- if (isFirstCompile) {
91
- isFirstCompile = false;
92
- this.successStdout('development server has been started');
93
- }
94
- if (stats.hasErrors()) {
95
- console.log(stats.toString({
96
- colors: true,
97
- }));
98
- }
85
+ };
86
+ process.stdin.on('end', () => {
87
+ devServer.stopCallback(() => {
88
+ exitProcess(() => this.successStdout('webpack devServer process exit successfully'));
89
+ });
90
+ process.stdin.resume();
99
91
  });
100
- devServer.listen(this.devServerConf.port, this.devServerConf.host, err => {
101
- if (err) {
102
- console.error(err);
103
- process.exit(1);
104
- }
92
+ ['SIGINT', 'SIGTERM'].forEach(signal => {
93
+ process.on(signal, exitProcess(() => {
94
+ console.log('\n');
95
+ this.warningStdout('stop webpack devServer process via command signal:', signal);
96
+ }));
105
97
  });
106
98
  }
107
99
  }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ActionFactory = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ class ActionFactory {
9
+ constructor(service) {
10
+ this.service = service;
11
+ }
12
+ successStdout(...logs) {
13
+ console.log(...logs.map(log => chalk_1.default.green(log)));
14
+ }
15
+ warningStdout(...logs) {
16
+ console.log(...logs.map(log => chalk_1.default.green(log)));
17
+ }
18
+ errorStdout(...logs) {
19
+ console.log(...logs.map(log => chalk_1.default.green(log)));
20
+ }
21
+ }
22
+ exports.ActionFactory = ActionFactory;
23
+ exports.default = ActionFactory;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const factory_1 = require("./factory");
7
+ const ko_lints_1 = __importDefault(require("ko-lints"));
8
+ const utils_1 = require("../utils");
9
+ class LintFactory extends factory_1.ActionFactory {
10
+ constructor(service, name) {
11
+ super(service);
12
+ this.name = name;
13
+ this.generateConfig();
14
+ }
15
+ generateConfig() {
16
+ const opts = this.service.config?.lints?.[this.name];
17
+ return opts || {};
18
+ }
19
+ registerCommand() {
20
+ const name = this.name;
21
+ this.service.commander.registerCommand({
22
+ name,
23
+ description: `lint your codes via ${name}`,
24
+ args: [
25
+ {
26
+ flags: '<patterns>',
27
+ description: ` Specify ${name} lint patterns(via glob)`,
28
+ },
29
+ ],
30
+ options: [
31
+ {
32
+ flags: '-w, --write',
33
+ description: 'try to fix problems automatically',
34
+ },
35
+ {
36
+ flags: '-c, --configPath <configPath>',
37
+ description: `Specify ${name} config path`,
38
+ },
39
+ {
40
+ flags: '--concurrency',
41
+ description: 'Enable concurrency mode',
42
+ },
43
+ {
44
+ flags: '--concurrentNumber <number>',
45
+ description: 'Specify max worker count',
46
+ },
47
+ ],
48
+ });
49
+ this.service.commander.bindAction(name, this.action.bind(this));
50
+ }
51
+ async action(patterns, cliOpts) {
52
+ const config = this.generateConfig();
53
+ const finalOpts = Object.freeze({
54
+ name: this.name,
55
+ ...config,
56
+ ...cliOpts,
57
+ patterns: Array.isArray(patterns) ? patterns : [patterns],
58
+ });
59
+ const { name, ...opts } = finalOpts;
60
+ (0, utils_1.assert)(opts.patterns, `patterns config of ${name} should be specified(via glob)`);
61
+ process.title = finalOpts.name;
62
+ const lintRunner = new ko_lints_1.default(opts);
63
+ const result = (await lintRunner.run(name)).filter(Boolean);
64
+ if (result.length === 0) {
65
+ this.successStdout('[success]', `lint via ${name}`);
66
+ }
67
+ else {
68
+ this.warningStdout(`lint via ${name} failed:`);
69
+ result.forEach(str => {
70
+ str && this.warningStdout('[failed]', str);
71
+ });
72
+ }
73
+ process.exit(0);
74
+ }
75
+ }
76
+ exports.default = LintFactory;
package/lib/cli.js CHANGED
@@ -4,37 +4,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const commander_1 = require("commander");
8
- const build_1 = __importDefault(require("./actions/build"));
7
+ const service_1 = __importDefault(require("./core/service"));
9
8
  const dev_1 = __importDefault(require("./actions/dev"));
10
- const program = new commander_1.Command();
11
- const pkg = require('../package.json');
12
- program
13
- .description('Project toolkit base on webpack,babel,eslint and prettier.')
14
- .version(pkg.version, '-v, --version')
15
- .usage('<command> [options]');
16
- program
17
- .command('build')
18
- .description('build project')
19
- .option('--hash', 'output file name with hash')
20
- .option('-t,--ts,--typescript', 'support typescript')
21
- .option('-e,--esbuild', 'enable esbuild')
22
- .action((opts) => {
23
- process.env.NODE_ENV = 'production';
24
- const buildInstance = new build_1.default(opts);
25
- buildInstance.action();
26
- });
27
- program
28
- .command('dev')
29
- .description('start devServer')
30
- .option('-p, --port <port>', 'server start on which port', parseInt)
31
- .option('--host <host>', 'specify a host to use')
32
- .option('-t, --ts', 'support typescript')
33
- .option('-h, --hash', 'output file name with hash')
34
- .option('-a,--analyzer', 'support building analyzer')
35
- .action((opts) => {
36
- process.env.NODE_ENV = 'development';
37
- const devInstance = new dev_1.default(opts);
38
- devInstance.action();
39
- });
40
- program.parse();
9
+ const build_1 = __importDefault(require("./actions/build"));
10
+ const lints_1 = __importDefault(require("./actions/lints"));
11
+ function exec() {
12
+ const service = new service_1.default();
13
+ // register commands
14
+ const dev = new dev_1.default(service);
15
+ dev.registerCommand();
16
+ const build = new build_1.default(service);
17
+ build.registerCommand();
18
+ ['eslint', 'prettier', 'stylelint'].forEach(name => {
19
+ const runner = new lints_1.default(service, name);
20
+ runner.registerCommand();
21
+ });
22
+ service.run();
23
+ }
24
+ exec();
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const commander_1 = require("commander");
4
+ const utils_1 = require("../utils");
5
+ var STATE;
6
+ (function (STATE) {
7
+ STATE[STATE["INIT"] = 0] = "INIT";
8
+ STATE[STATE["PARSE"] = 1] = "PARSE";
9
+ STATE[STATE["DONE"] = 2] = "DONE";
10
+ })(STATE || (STATE = {}));
11
+ class Commander {
12
+ constructor() {
13
+ this.program = commander_1.program;
14
+ this.STATE = STATE.INIT;
15
+ this.cmdSet = {};
16
+ this.pkg = require('../../package.json');
17
+ }
18
+ registerCommand({ name, description, args, options, }) {
19
+ (0, utils_1.assert)(this.STATE === STATE.INIT, `register command should be called in INIT state`);
20
+ (0, utils_1.assert)(!this.cmdSet[name], `command ${name} has been registered`);
21
+ (0, utils_1.assert)(description, `command ${name} must have a description`);
22
+ this.cmdSet[name] = {
23
+ description,
24
+ options,
25
+ args,
26
+ };
27
+ }
28
+ bindAction(name, fn) {
29
+ (0, utils_1.assert)(this.STATE === STATE.INIT, `bind command action should be called in INIT state`);
30
+ (0, utils_1.assert)(this.cmdSet[name], `command ${name} hasn't been registered`);
31
+ (0, utils_1.assert)(!this.cmdSet[name].action, `command ${name} action has been registered`);
32
+ this.cmdSet[name].action = fn;
33
+ }
34
+ parse() {
35
+ this.STATE = STATE.PARSE;
36
+ this.program
37
+ .description('Project Toolkit for React Applications')
38
+ .version(this.pkg.version, '-v, --version')
39
+ .usage('<command> [options]');
40
+ Object.keys(this.cmdSet).forEach(name => {
41
+ const cmd = this.cmdSet[name];
42
+ const command = this.program.command(name);
43
+ command.description(cmd.description);
44
+ if (cmd.args) {
45
+ cmd.args.forEach(argv => {
46
+ command.argument(argv.flags, argv.description);
47
+ });
48
+ }
49
+ if (cmd.options) {
50
+ cmd.options.forEach(option => {
51
+ command.option(option.flags, option.description, option.defaultValue);
52
+ });
53
+ }
54
+ if (cmd.action) {
55
+ command.action(cmd.action);
56
+ }
57
+ else {
58
+ throw new Error(`command ${name} action hasn't been bind`);
59
+ }
60
+ });
61
+ this.program.parse();
62
+ this.STATE = STATE.DONE;
63
+ }
64
+ }
65
+ exports.default = Commander;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const path_1 = require("path");
4
+ const fs_1 = require("fs");
5
+ const lodash_1 = require("lodash");
6
+ const utils_1 = require("../utils");
7
+ class Config {
8
+ constructor() {
9
+ this.cwd = process.cwd();
10
+ this.path = this.getConfigPath('ko.config.js');
11
+ this.generate();
12
+ }
13
+ get isDevOrBuildCommand() {
14
+ const flag = process.argv.find(arg => arg === 'dev' || arg === 'build');
15
+ return !!flag;
16
+ }
17
+ getConfigPath(path) {
18
+ const absolutePath = (0, path_1.join)(process.cwd(), path);
19
+ this.isDevOrBuildCommand &&
20
+ (0, utils_1.assert)((0, fs_1.existsSync)(absolutePath), 'ko.config.js file not exist, please check if it exist');
21
+ return absolutePath;
22
+ }
23
+ generate() {
24
+ this.origin = {};
25
+ if (this.isDevOrBuildCommand) {
26
+ this.origin = require(this.path);
27
+ }
28
+ this.current = (0, lodash_1.merge)(this.default, (0, lodash_1.cloneDeep)(this.origin));
29
+ return Object.freeze(this.current);
30
+ }
31
+ freezeWithOpts(cliOpts) {
32
+ this.cliOpts = cliOpts;
33
+ return Object.freeze((0, lodash_1.merge)(this.current, this.cliOpts));
34
+ }
35
+ get default() {
36
+ return {
37
+ cwd: this.cwd,
38
+ serve: {
39
+ host: '127.0.0.1',
40
+ port: 8080,
41
+ },
42
+ hash: true,
43
+ analyzer: false,
44
+ lessOptions: {
45
+ javascriptEnabled: true,
46
+ },
47
+ publicPath: '/',
48
+ experiment: {
49
+ speedUp: true,
50
+ minimizer: true,
51
+ enableCssModule: true,
52
+ },
53
+ };
54
+ }
55
+ }
56
+ exports.default = Config;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tapable_1 = require("tapable");
4
+ const types_1 = require("../types");
5
+ var HOOK_KEY_SET;
6
+ (function (HOOK_KEY_SET) {
7
+ HOOK_KEY_SET["WEBPACK_PLUGIN"] = "WebpackPlugin";
8
+ })(HOOK_KEY_SET || (HOOK_KEY_SET = {}));
9
+ class Hooks {
10
+ constructor() {
11
+ this.hookKeySet = HOOK_KEY_SET;
12
+ this.hooks = {};
13
+ }
14
+ register({ key, action, opts }) {
15
+ var _a;
16
+ (_a = this.hooks)[key] || (_a[key] = {
17
+ [types_1.ACTION.ADD]: [],
18
+ [types_1.ACTION.UPDATE]: [],
19
+ });
20
+ this.hooks[key][action].push(opts);
21
+ }
22
+ apply(opts) {
23
+ const hooks = this.hooks[opts.key];
24
+ const tapInstance = new tapable_1.AsyncSeriesWaterfallHook(['ctx']);
25
+ hooks[types_1.ACTION.ADD].forEach(hook => {
26
+ tapInstance.tapPromise({ name: hook.name, stage: hook.stage, before: hook.before }, async (ctx) => {
27
+ const result = await hook.fn(ctx);
28
+ return ctx.concat(result);
29
+ });
30
+ });
31
+ hooks[types_1.ACTION.UPDATE].forEach(hook => {
32
+ tapInstance.tapPromise({ name: hook.name, stage: hook.stage, before: hook.before }, async (ctx) => {
33
+ const result = await hook.fn(ctx);
34
+ return result;
35
+ });
36
+ });
37
+ return tapInstance.promise(opts.context);
38
+ }
39
+ }
40
+ exports.default = Hooks;