akfun 1.6.0 → 1.6.1

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/module/inspect.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const path = require('path');
2
2
  const ora = require('ora');
3
3
  const fs = require('fs');
4
+ const {curConsoleTag} = require("../src/utils/akfunParams");
4
5
  const getCurWebpackConfig = require('../src/utils/getCurWebpackConfig.js'); // 用于获取当前webpack配置的方法
5
6
 
6
7
  // 根据当前配置文件内容创建指定名称的文件
@@ -17,22 +18,23 @@ const createConfigJs = function (fileName, fileCont) {
17
18
  /**
18
19
  * 用于输出当前项目配置文件
19
20
  */
20
- module.exports = (type) => {
21
- const spinner = ora( '[akfun]正在获取当前环境的配置数据...').start();
21
+ module.exports = (type, _consoleTag) => {
22
+ const consoleTag = _consoleTag || curConsoleTag;
23
+ const spinner = ora( `${consoleTag}正在获取当前环境的配置数据...`).start();
22
24
  if (type === 'dev') {
23
25
  const devConfig = getCurWebpackConfig(type);
24
26
  createConfigJs('current-akfun-dev-config.js', devConfig);
25
- spinner.succeed( '[akfun]当前配置数据已输出至akfun-dev-config.js中!');
27
+ spinner.succeed( `${consoleTag}当前配置数据已输出至akfun-dev-config.js中!`);
26
28
  } else if (type === 'lib') {
27
29
  const libraryConfig = getCurWebpackConfig(type);
28
30
  createConfigJs('current-akfun-build2lib-config.js', libraryConfig);
29
- spinner.succeed( '[akfun]当前配置数据已输出至akfun-build2lib-config.js中!');
31
+ spinner.succeed( `${consoleTag}当前配置数据已输出至akfun-build2lib-config.js中!`);
30
32
  } else if (type === 'build') {
31
33
  const prodConfig = getCurWebpackConfig(type);
32
34
  // 默认输出生产环境的配置文件
33
35
  createConfigJs('current-akfun-build-config.js', prodConfig);
34
- spinner.succeed( '[akfun]当前配置数据已输出至akfun-build-config.js中!');
36
+ spinner.succeed( `${consoleTag}当前配置数据已输出至akfun-build-config.js中!`);
35
37
  } else {
36
- console.log(`不能识别type=${type}。`);
38
+ spinner.fail(`${consoleTag}type不能为空。`);
37
39
  }
38
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akfun",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
package/src/build.js CHANGED
@@ -3,27 +3,31 @@ const rm = require('rimraf');
3
3
  const path = require('path');
4
4
  const chalk = require('chalk');
5
5
  const webpack = require('webpack');
6
+ const {curConsoleTag} = require("./utils/akfunParams");
6
7
  const checkVersion = require('./check-versions');
7
8
  const projectConfig = require('./config/index'); // 引入当前项目配置文件
9
+ const defaultConfig = require('./config/default.config');
8
10
  const deepMergeConfig = require('./utils/deepMergeConfig');
9
11
 
10
12
  // 构建脚本:一般用于构建生产环境的代码
11
- module.exports = function (BuildType, akfunConfig) {
13
+ module.exports = function (BuildType, akfunConfig, _consoleTag) {
14
+ const consoleTag = _consoleTag || curConsoleTag;
12
15
  let config = projectConfig; // 默认使用执行命令目录下的配置数据
13
16
  if (akfunConfig) {
17
+ // 参数中的config配置优先级最高
14
18
  config = deepMergeConfig(defaultConfig, akfunConfig);
15
19
  }
16
20
  // 检查当前npm版本号是否匹配
17
21
  checkVersion();
18
- const spinner = ora('[akfun]开启AKFun构建能力...').start();
22
+ const spinner = ora(`${consoleTag}开始构建...`).start();
19
23
  // 引入生产环境配置信息
20
24
  let webpackConfig;
21
25
  // 根据BuildType判断是否引用专用于第三方功能包的webpack配置
22
26
  if (BuildType && BuildType === 'lib') {
23
- spinner.start('[akfun]开始构建第三方功能包...');
27
+ spinner.start(`${consoleTag}开始构建lib库...`);
24
28
  webpackConfig = require('./webpack/webpack.library.conf')(config);
25
29
  } else {
26
- spinner.start('[akfun]开始构建生产环境的代码...');
30
+ spinner.start(`${consoleTag}开始构建生产环境的代码...`);
27
31
  webpackConfig = require('./webpack/webpack.prod.conf')(config);
28
32
  }
29
33
 
package/src/build2esm.js CHANGED
@@ -1,8 +1,11 @@
1
1
  const ora = require('ora');
2
2
  const rollup = require('rollup');
3
- const config = require('./config/index'); // 引入当前项目配置文件
3
+ const projectConfig = require('./config/index'); // 引入当前项目配置文件
4
+ const defaultConfig = require('./config/default.config');
4
5
  const rollupConfig = require('./config/rollup.config'); // rollup的配置文件
5
6
  const { isArray, isObject } = require('./utils/typeof');
7
+ const {curConsoleTag } = require("./utils/akfunParams");
8
+ const deepMergeConfig = require('./utils/deepMergeConfig');
6
9
 
7
10
  async function build2esmFunc(options) {
8
11
  // create a bundle
@@ -24,8 +27,14 @@ async function build2esmFunc(options) {
24
27
  }
25
28
 
26
29
  // 构建脚本:一般用于构建生产环境的代码
27
- module.exports = function (fileName) {
28
- const spinner = ora('[akfun]开启esm lib库的构建能力...').start();
30
+ module.exports = function (fileName, akfunConfig, _consoleTag) {
31
+ const consoleTag = _consoleTag || curConsoleTag;
32
+ let config = projectConfig; // 默认使用执行命令目录下的配置数据
33
+ if (akfunConfig) {
34
+ // 参数中的config配置优先级最高
35
+ config = deepMergeConfig(defaultConfig, akfunConfig);
36
+ }
37
+ const spinner = ora(`${consoleTag}开启esm lib库的构建能力...`).start();
29
38
  const curRollupConfig = rollupConfig(fileName); // 默认配置
30
39
  const build2esm = config.build2esm; // 用户的项目配置
31
40
  if (build2esm && build2esm.input) {
@@ -35,6 +44,6 @@ module.exports = function (fileName) {
35
44
  curRollupConfig.output = build2esm.output;
36
45
  }
37
46
  build2esmFunc(curRollupConfig).then(() => {
38
- spinner.succeed('[akfun]esm lib库构建完成');
47
+ spinner.succeed(`${consoleTag}esm lib库构建完成`);
39
48
  });
40
49
  };
package/src/dev-server.js CHANGED
@@ -11,16 +11,19 @@ const projectConfig = require('./config/index');
11
11
  const defaultConfig = require('./config/default.config');
12
12
  const getDevWebpackConfig = require('./webpack/webpack.dev.conf');
13
13
  const deepMergeConfig = require('./utils/deepMergeConfig');
14
+ const {curConsoleTag } = require("./utils/akfunParams");
14
15
 
15
16
  // 构建脚本:一般用于构建开发环境的代码(包含热更新、接口代理等功能)
16
- module.exports = function (akfunConfig) {
17
+ module.exports = function (akfunConfig, _consoleTag) {
18
+ const consoleTag = _consoleTag || curConsoleTag;
17
19
  let config = projectConfig; // 默认使用执行命令目录下的配置数据
18
20
  if (akfunConfig) {
21
+ // 参数中的config配置优先级最高
19
22
  config = deepMergeConfig(defaultConfig, akfunConfig);
20
23
  }
21
24
  // 检查当前npm版本号是否匹配
22
25
  checkVersion();
23
- const spinner = ora('[akfun]开启调试模式...').start();
26
+ const spinner = ora(`${consoleTag}开启调试模式...`).start();
24
27
  /**
25
28
  * 如果 Node 的环境无法判断当前是 dev / product 环境
26
29
  * 使用 config.dev.NODE_ENV 作为当前的环境
@@ -112,7 +115,7 @@ module.exports = function (akfunConfig) {
112
115
  console.log(`> Listening at ${uri}\n`);
113
116
  // 如果是开发环境,自动打开浏览器并跳到项目首页
114
117
  if (autoOpenBrowser && process.NODE_ENV === 'development') {
115
- spinner.succeed('[akfun]调试模式已开启!');
118
+ spinner.succeed(`${consoleTag}调试模式已开启!`);
116
119
  opn(uri);
117
120
  }
118
121
  server = app.listen(port);
@@ -0,0 +1,12 @@
1
+ var consoleTag = '[akfun]'; // 输出标记
2
+
3
+ function setConsoleTag(newText) {
4
+ consoleTag = newText;
5
+ }
6
+
7
+ module.exports = {
8
+ get curConsoleTag() {
9
+ return consoleTag;
10
+ },
11
+ setConsoleTag
12
+ };
@@ -3,9 +3,11 @@ const ora = require('ora');
3
3
  const gitclone = require('git-clone');
4
4
  const rm = require('rimraf').sync;
5
5
  const { resolveToCurrentRoot } = require('../utils/pathUtils');
6
+ const {curConsoleTag} = require("./akfunParams");
6
7
 
7
- function gitClone(gitUrl, dir, callback) {
8
- const spinner = ora('[akfun]正在加载项目模板...').start();
8
+ function _gitClone(gitUrl, dir, callback, _consoleTag) {
9
+ const consoleTag = _consoleTag || curConsoleTag;
10
+ const spinner = ora(`${consoleTag}正在加载项目模板...`).start();
9
11
  gitclone(
10
12
  gitUrl,
11
13
  resolveToCurrentRoot(dir),
@@ -15,7 +17,7 @@ function gitClone(gitUrl, dir, callback) {
15
17
  (err) => {
16
18
  if (err === undefined) {
17
19
  rm(resolveToCurrentRoot(path.resolve(dir, '.git')));
18
- spinner.succeed('[akfun]项目模板加载完成!');
20
+ spinner.succeed(`${consoleTag}项目模板加载完成!`);
19
21
  callback();
20
22
  } else {
21
23
  console.log(err);
@@ -24,4 +26,4 @@ function gitClone(gitUrl, dir, callback) {
24
26
  }
25
27
  );
26
28
  }
27
- module.exports = gitClone;
29
+ module.exports = _gitClone;