ko 5.3.8 → 6.0.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.
@@ -4,66 +4,61 @@ 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
+ defaultValue: true,
48
+ },
49
+ ],
50
+ });
51
+ this.service.commander.bindAction(cmdName, this.action.bind(this));
60
52
  }
61
- action() {
62
- //TODO: redefine stats
63
- (0, webpack_1.default)(this.config(), (error, stats) => {
53
+ async action(cliOpts) {
54
+ process.title = 'ko-build';
55
+ process.env.NODE_ENV = 'production';
56
+ this.service.freezeCliOptsWith(cliOpts);
57
+ const config = await this.generateConfig();
58
+ (0, webpack_1.default)(config, (error, stats) => {
64
59
  if (stats && stats.hasErrors()) {
65
60
  throw stats.toString({
66
- logging: 'warn',
61
+ logging: 'error',
67
62
  colors: true,
68
63
  });
69
64
  }
@@ -5,103 +5,97 @@ 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
+ defaultValue: true,
66
+ },
67
+ {
68
+ flags: '--analyzer',
69
+ description: 'support building analyzer',
70
+ defaultValue: false,
71
+ },
72
+ ],
73
+ });
74
+ this.service.commander.bindAction(cmdName, this.action.bind(this));
76
75
  }
77
- async action() {
78
- const { port } = this.devServerConf;
79
- const newPort = await this.checkPort(port);
80
- if (!newPort) {
76
+ async action(cliOpts) {
77
+ process.title = 'ko-dev';
78
+ process.env.NODE_ENV = 'development';
79
+ this.service.freezeCliOptsWith(cliOpts);
80
+ const config = await this.generateConfig();
81
+ const compiler = (0, webpack_1.default)(config);
82
+ const devServer = new webpack_dev_server_1.default(config.devServer, compiler);
83
+ await devServer.start();
84
+ const exitProcess = (callback) => () => {
85
+ callback && callback();
81
86
  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
- }
87
+ };
88
+ process.stdin.on('end', () => {
89
+ devServer.stopCallback(() => {
90
+ exitProcess(() => this.successStdout('webpack devServer process exit successfully'));
91
+ });
92
+ process.stdin.resume();
99
93
  });
100
- devServer.listen(this.devServerConf.port, this.devServerConf.host, err => {
101
- if (err) {
102
- console.error(err);
103
- process.exit(1);
104
- }
94
+ ['SIGINT', 'SIGTERM'].forEach(signal => {
95
+ process.on(signal, exitProcess(() => {
96
+ console.log('\n');
97
+ this.warningStdout('stop webpack devServer process via command signal:', signal);
98
+ }));
105
99
  });
106
100
  }
107
101
  }
@@ -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,70 @@
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
+ defaultValue: false,
35
+ },
36
+ {
37
+ flags: '-c, --configPath <configPath>',
38
+ description: `Specify ${name} config path`,
39
+ defaultValue: '',
40
+ },
41
+ ],
42
+ });
43
+ this.service.commander.bindAction(name, this.action.bind(this));
44
+ }
45
+ async action(patterns, cliOpts) {
46
+ const config = this.generateConfig();
47
+ const finalOpts = Object.freeze({
48
+ name: this.name,
49
+ ...config,
50
+ ...cliOpts,
51
+ patterns: Array.isArray(patterns) ? patterns : [patterns],
52
+ });
53
+ const { name, ...opts } = finalOpts;
54
+ (0, utils_1.assert)(opts.patterns, `patterns config of ${name} should be specified(via glob)`);
55
+ process.title = finalOpts.name;
56
+ const lintRunner = new ko_lints_1.default(opts);
57
+ const result = await lintRunner.run(name);
58
+ if (typeof result === 'boolean' && result) {
59
+ this.successStdout('[success]', `lint via ${name}`);
60
+ process.exit(0);
61
+ }
62
+ else {
63
+ this.warningStdout(`lint via ${name} failed:`);
64
+ result.forEach(str => {
65
+ this.warningStdout('[failed]', str);
66
+ });
67
+ }
68
+ }
69
+ }
70
+ 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;
@@ -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
+ const commander_1 = __importDefault(require("./commander"));
7
+ const hooks_1 = __importDefault(require("./hooks"));
8
+ const config_1 = __importDefault(require("./config"));
9
+ class Service extends hooks_1.default {
10
+ constructor() {
11
+ super();
12
+ this.commander = new commander_1.default();
13
+ this.config = new config_1.default().generate();
14
+ this.config.plugins && this.config.plugins.forEach(p => this.register(p));
15
+ }
16
+ freezeCliOptsWith(cliOpts) {
17
+ this.cliOpts = Object.freeze(cliOpts);
18
+ }
19
+ run() {
20
+ this.commander.parse();
21
+ }
22
+ }
23
+ exports.default = Service;
package/lib/types.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ACTION = void 0;
4
+ var ACTION;
5
+ (function (ACTION) {
6
+ ACTION["ADD"] = "add";
7
+ ACTION["UPDATE"] = "update";
8
+ })(ACTION = exports.ACTION || (exports.ACTION = {}));
@@ -0,0 +1,22 @@
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.assert = exports.getResolvePath = exports.getCacheIdentifier = void 0;
7
+ function getCacheIdentifier(env, pkgs) {
8
+ let cacheIdentifier = env || '';
9
+ Object.values(pkgs).forEach(pkgName => {
10
+ cacheIdentifier += `:${pkgName}@`;
11
+ cacheIdentifier += require(`${pkgName}/package.json`).version || '';
12
+ });
13
+ return cacheIdentifier;
14
+ }
15
+ exports.getCacheIdentifier = getCacheIdentifier;
16
+ function getResolvePath(name) {
17
+ const resolvePath = require.resolve(name);
18
+ return resolvePath;
19
+ }
20
+ exports.getResolvePath = getResolvePath;
21
+ var assert_1 = require("assert");
22
+ Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return __importDefault(assert_1).default; } });