ko 5.2.1 → 5.2.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.
Files changed (81) hide show
  1. package/README.md +2 -128
  2. package/lib/actions/build.js +74 -0
  3. package/lib/actions/creator.js +42 -0
  4. package/lib/actions/dev.js +110 -0
  5. package/lib/cli.js +41 -0
  6. package/lib/interfaces.js +2 -0
  7. package/lib/utils/config.js +42 -0
  8. package/lib/utils/config.test.js +30 -0
  9. package/lib/webpack/index.js +55 -0
  10. package/lib/webpack/loaders/asset.js +19 -0
  11. package/lib/webpack/loaders/index.js +12 -0
  12. package/lib/webpack/loaders/script.js +59 -0
  13. package/lib/webpack/loaders/style.js +72 -0
  14. package/lib/webpack/plugins.js +61 -0
  15. package/package.json +43 -85
  16. package/{preinstall.js → scripts/preinstall.js} +6 -5
  17. package/.eslintignore +0 -3
  18. package/.eslintrc.js +0 -96
  19. package/.github/workflows/auto-publish.yml +0 -32
  20. package/.github/workflows/ci.yml +0 -67
  21. package/.husky/pre-commit +0 -4
  22. package/.prettierignore +0 -5
  23. package/CHANGELOG.md +0 -115
  24. package/bin/ko-build.js +0 -30
  25. package/bin/ko-create.js +0 -14
  26. package/bin/ko-dev.js +0 -31
  27. package/bin/ko-init.js +0 -14
  28. package/bin/ko-install.js +0 -27
  29. package/bin/ko-lint.js +0 -18
  30. package/bin/ko-move.js +0 -14
  31. package/bin/ko-preview.js +0 -27
  32. package/bin/ko-swagger.js +0 -41
  33. package/bin/ko.js +0 -29
  34. package/commitlint.config.js +0 -7
  35. package/config/defaultPaths.js +0 -26
  36. package/config/lint/getEslintConf.js +0 -23
  37. package/config/lint/getPrettierConf.js +0 -14
  38. package/config/lint/index.js +0 -14
  39. package/config/webpack/base.js +0 -77
  40. package/config/webpack/devServer.js +0 -39
  41. package/config/webpack/index.js +0 -63
  42. package/config/webpack/loaders.js +0 -142
  43. package/config/webpack/plugins.js +0 -70
  44. package/constants/default.js +0 -7
  45. package/constants/env.js +0 -7
  46. package/jest.config.js +0 -44
  47. package/prettier.config.js +0 -8
  48. package/script/build.js +0 -23
  49. package/script/create.js +0 -31
  50. package/script/dev.js +0 -96
  51. package/script/init.js +0 -129
  52. package/script/install.js +0 -91
  53. package/script/lint.js +0 -24
  54. package/script/move.js +0 -38
  55. package/script/preview.js +0 -22
  56. package/script/swagger.js +0 -239
  57. package/template/index.html +0 -0
  58. package/template/pageTemplate.mustache +0 -21
  59. package/template/pageTemplateTS.mustache +0 -29
  60. package/template/restful.hbs +0 -14
  61. package/template/restfulTemplate.mustache +0 -12
  62. package/template/routerConfTemplate.mustache +0 -15
  63. package/template/styleTemplate.mustache +0 -3
  64. package/template/tsconfig.json +0 -22
  65. package/util/__tests__/file.test.js +0 -16
  66. package/util/__tests__/fileService.test.js +0 -101
  67. package/util/__tests__/index.test.js +0 -51
  68. package/util/__tests__/userConfig.test.js +0 -83
  69. package/util/__tests__/verifyHtml.test.js +0 -81
  70. package/util/createComp.js +0 -71
  71. package/util/createPage.js +0 -141
  72. package/util/defaultData.js +0 -64
  73. package/util/file.js +0 -9
  74. package/util/fileService.js +0 -55
  75. package/util/index.js +0 -25
  76. package/util/prepareUrl.js +0 -69
  77. package/util/program.js +0 -20
  78. package/util/request.js +0 -18
  79. package/util/stdout.js +0 -36
  80. package/util/userConfig.js +0 -40
  81. package/util/verifyHtml.js +0 -63
@@ -1,70 +0,0 @@
1
- const webpack = require('webpack');
2
- const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
3
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4
- const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');
5
- const SimpleProgressPlugin = require('webpack-simple-progress-plugin');
6
- const HtmlWebpackPlugin = require('html-webpack-plugin');
7
- const HtmlWebpackTagsPlugin = require('html-webpack-tags-plugin');
8
- // const VueLoaderPlugin = require('vue-loader/lib/plugin'); //TODO: support vue loader when it adapted webpack 5
9
- const { appHtml, appTsConfig, appPkg } = require('../defaultPaths');
10
- const userConf = require('../../util/userConfig');
11
- const { PROD, DEV } = require('../../constants/env');
12
-
13
- const { name: appPkgName } = require(appPkg);
14
-
15
- function getPlugins() {
16
- const { opts } = require('../../util/program');
17
- const { env, ts } = opts;
18
- // TODO: redefined plugins order
19
- const userDefinedWebpackConf = userConf.webpack || {};
20
- const userDefinedPlugins = userDefinedWebpackConf.plugins || [];
21
- let plugins = [
22
- new MiniCssExtractPlugin({
23
- filename: 'css/[name].[hash:6].css',
24
- chunkFilename: 'css/[id].[hash:6].css',
25
- }),
26
- new FilterWarningsPlugin({
27
- exclude: /Conflicting order between:/,
28
- }),
29
- new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
30
- new SimpleProgressPlugin(),
31
- new CaseSensitivePathsPlugin(),
32
- new webpack.ProvidePlugin({
33
- _: 'lodash',
34
- }),
35
- new HtmlWebpackPlugin({
36
- template: appHtml,
37
- filename: 'index.html',
38
- title: appPkgName || 'Ko App',
39
- }),
40
- new HtmlWebpackTagsPlugin({
41
- tags: [`config/conf.${process.env.NODE_ENV === DEV ? 'dev' : env}.js`],
42
- append: false,
43
- }),
44
- ];
45
- if (ts) {
46
- const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
47
- const typescriptPlugins = [
48
- new ForkTsCheckerWebpackPlugin({
49
- async: false,
50
- typescript: {
51
- configFile: appTsConfig,
52
- },
53
- }),
54
- ];
55
- plugins = plugins.concat(typescriptPlugins);
56
- }
57
- plugins = plugins.concat(userDefinedPlugins);
58
- if (process.env.NODE_ENV === PROD) {
59
- const { CleanWebpackPlugin } = require('clean-webpack-plugin');
60
- plugins.push(
61
- new CleanWebpackPlugin({
62
- verbose: false,
63
- dry: false,
64
- })
65
- );
66
- }
67
- return plugins;
68
- }
69
-
70
- module.exports = getPlugins;
@@ -1,7 +0,0 @@
1
- const PORT = 8080;
2
- const HOST = '127.0.0.1';
3
-
4
- module.exports = {
5
- PORT,
6
- HOST,
7
- };
package/constants/env.js DELETED
@@ -1,7 +0,0 @@
1
- const PROD = 'production';
2
- const DEV = 'development';
3
-
4
- module.exports = {
5
- PROD,
6
- DEV,
7
- };
package/jest.config.js DELETED
@@ -1,44 +0,0 @@
1
- /*
2
- * For a detailed explanation regarding each configuration property, visit:
3
- * https://jestjs.io/docs/configuration
4
- */
5
-
6
- module.exports = {
7
- // Automatically clear mock calls and instances between every test
8
- clearMocks: true,
9
- // Indicates whether the coverage information should be collected while executing the test
10
- collectCoverage: false,
11
- // The directory where Jest should output its coverage files
12
- coverageDirectory: 'coverage',
13
- // An array of regexp pattern strings used to skip coverage collection
14
- coveragePathIgnorePatterns: ['/node_modules/'],
15
- // Indicates which provider should be used to instrument code for coverage
16
- coverageProvider: 'babel',
17
- // A path to a module which exports an async function that is triggered once before all test suites
18
- // globalSetup: undefined,
19
- // An array of directory names to be searched recursively up from the requiring module's location
20
- moduleDirectories: ['node_modules'],
21
- // An array of file extensions your modules use
22
- moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
23
- // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
24
- // moduleNameMapper: {},
25
- // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
26
- // modulePathIgnorePatterns: [],
27
-
28
- // The root directory that Jest should scan for tests and modules within
29
- // rootDir: undefined,
30
-
31
- // A list of paths to directories that Jest should use to search for files in
32
- // roots: [
33
- // "<rootDir>"
34
- // ],
35
-
36
- // The glob patterns Jest uses to detect test files
37
- testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)'],
38
-
39
- // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
40
- testPathIgnorePatterns: ['/node_modules/'],
41
-
42
- // Indicates whether each individual test should be reported during the run
43
- verbose: true,
44
- };
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- bracketSpacing: true,
3
- singleQuote: true,
4
- jsxBracketSameLine: true,
5
- trailingComma: 'es5',
6
- arrowParens: 'always',
7
- printWidth: 80,
8
- };
package/script/build.js DELETED
@@ -1,23 +0,0 @@
1
- const webpack = require('webpack');
2
- const { getWebpackPro } = require('../config/webpack');
3
-
4
- function buildWebpackPro() {
5
- const webpackProConf = getWebpackPro();
6
- webpack(webpackProConf, (error, stats) => {
7
- if (error || stats.hasErrors()) {
8
- throw (
9
- error ||
10
- stats.toString({
11
- colors: true,
12
- chunks: false,
13
- children: false,
14
- modules: false,
15
- chunkModules: false,
16
- })
17
- );
18
- }
19
- console.log('ko build completed!');
20
- });
21
- }
22
-
23
- module.exports = buildWebpackPro;
package/script/create.js DELETED
@@ -1,31 +0,0 @@
1
- const inquirer = require('inquirer');
2
- const defaultData = require('../util/defaultData');
3
- const initComp = require('../util/createComp');
4
- const initPage = require('../util/createPage');
5
- async function inquirerAnswer(inquireType) {
6
- const ret = inquirer.prompt([inquireType]);
7
- return ret;
8
- }
9
-
10
- module.exports = async (program) => {
11
- const choices = defaultData.createChoiceData;
12
- const inquireType = {
13
- type: 'list',
14
- name: 'web',
15
- choices,
16
- message: 'choose you want to create',
17
- };
18
-
19
- const inquireRet = await inquirerAnswer(inquireType);
20
- const questions =
21
- inquireRet.web == 'page'
22
- ? defaultData.createPageData
23
- : defaultData.createComData;
24
- inquirer.prompt(questions).then((answers) => {
25
- const reg = /^\/.*/;
26
- const path = reg.test(answers.path) ? '.' + answers.path : answers.path;
27
- inquireRet.web == 'page'
28
- ? initPage(answers.name, answers.path, answers.route, null, answers.ts)
29
- : initComp(answers.name, path, answers.ts);
30
- });
31
- };
package/script/dev.js DELETED
@@ -1,96 +0,0 @@
1
- const webpack = require('webpack');
2
- const WebpackDevServer = require('webpack-dev-server');
3
- const detect = require('detect-port');
4
- const inquirer = require('inquirer');
5
- const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
6
- const { DEV } = require('../constants/env');
7
- const { logWithColor } = require('../util/stdout');
8
- const { getWebpackDev, getDevServerConfig } = require('../config/webpack');
9
-
10
- async function checkPort(port) {
11
- const newPort = await detect(port);
12
- if (newPort === port) {
13
- return newPort;
14
- }
15
- const isInteractive = process.stdout.isTTY;
16
- if (isInteractive) {
17
- return changePort(newPort, port);
18
- }
19
- }
20
-
21
- async function changePort(newPort, port) {
22
- const question = {
23
- type: 'confirm',
24
- name: 'changePort',
25
- message: `port: ${port} has been used,use new port ${newPort} instead?`,
26
- default: true,
27
- };
28
- const answer = await inquirer.prompt(question);
29
- if (answer.changePort) {
30
- return newPort;
31
- } else {
32
- return null;
33
- }
34
- }
35
-
36
- function getUrlHost(host) {
37
- const regex = /^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*$/i;
38
- return regex.test(host) ? host : `http://${host}`;
39
- }
40
-
41
- module.exports = async function () {
42
- process.env.NODE_ENV = DEV;
43
- const webpackDevServerConf = getDevServerConfig();
44
- const webpackDevConf = getWebpackDev();
45
- const { port, host } = webpackDevServerConf;
46
- const newPort = await checkPort(parseInt(webpackDevServerConf.port));
47
- if (!newPort) return;
48
- WebpackDevServer.addDevServerEntrypoints(
49
- webpackDevConf,
50
- webpackDevServerConf
51
- );
52
- const compiler = webpack(webpackDevConf);
53
- const devServer = new WebpackDevServer(compiler, webpackDevServerConf);
54
- let isFirstCompile = true;
55
-
56
- compiler.hooks.done.tap('done', (stats) => {
57
- if (isFirstCompile) {
58
- isFirstCompile = false;
59
- logWithColor('cyan', 'development server has been started');
60
- logWithColor('yellow', `server starts at:${getUrlHost(host)}:${port}`);
61
- }
62
- /**
63
- * fixed react-dev-utils bug.
64
- * ref: https://github.com/facebook/create-react-app/issues/9880
65
- */
66
- const rawMessages = stats.toJson({ moduleTrace: false }, true);
67
- const messages = formatWebpackMessages({
68
- errors: rawMessages.errors.map((e) => e.message),
69
- warnings: rawMessages.warnings.map((e) => e.message),
70
- });
71
- const isSuccessful = !messages.errors.length && !messages.warnings.length;
72
- if (isSuccessful) {
73
- if (stats.stats) {
74
- logWithColor('green', 'compiled successfully');
75
- }
76
- }
77
- if (messages.errors.length) {
78
- logWithColor('red', 'failed to compiled with errors:\n');
79
- messages.errors.forEach((msg) => console.log(msg + '\n'));
80
- } else if (messages.warnings.length) {
81
- logWithColor('yellow', 'compiled with warnings:\n');
82
- messages.warnings.forEach((msg) => console.log(msg + '\n'));
83
- }
84
- });
85
-
86
- compiler.hooks.invalid.tap('invalid', () => {
87
- console.log('Compiling...');
88
- });
89
-
90
- devServer.listen(port, host, (err) => {
91
- if (err) {
92
- console.error(err);
93
- process.exit(500);
94
- }
95
- });
96
- };
package/script/init.js DELETED
@@ -1,129 +0,0 @@
1
- /*
2
- * @Description: 文件
3
- * @version: 1.0.0
4
- * @Company: 袋鼠云
5
- * @Author: Charles
6
- * @Date: 2019-01-07 17:06:53
7
- * @LastEditors: Charles
8
- * @LastEditTime: 2019-02-21 14:55:09
9
- */
10
-
11
- const colors = require('colors');
12
- const download = require('download-git-repo');
13
- const paths = require('path');
14
- const log = console.log;
15
- const ora = require('ora');
16
- const shell = require('shelljs');
17
- const inquirer = require('inquirer');
18
- const { existsSync } = require('../util/fileService');
19
- const { get } = require('../util/request');
20
- const { scaffoldConfUrl, userCacheRepoDir } = require('../config/defaultPaths');
21
-
22
- async function getKoScriptConf() {
23
- return get({}, scaffoldConfUrl);
24
- }
25
-
26
- async function inquirerAnswer(inquireType) {
27
- const ret = inquirer.prompt([inquireType]);
28
- return ret;
29
- }
30
-
31
- /**
32
- * @description: 初始化脚手架
33
- * @param1: param
34
- * @param2: param
35
- * @return: ret
36
- * @Author: Charles
37
- * @Date: 2019-01-08 16:48:38
38
- */
39
- async function initScaffold(tempRepo) {
40
- const curPath = process.cwd();
41
- const inquireProject = {
42
- type: 'input',
43
- name: 'name',
44
- message: 'please input the name of project',
45
- default: 'ko-project',
46
- };
47
- const projectRet = await inquirerAnswer(inquireProject);
48
- const dest = `${curPath}/${projectRet.name}`;
49
- shell.rm('-rf', dest);
50
- shell.mkdir('-p', dest);
51
- const spinner = ora('generating project...');
52
- spinner.start();
53
- shell.cp('-rf', `${tempRepo}/*`, dest);
54
- spinner.stop();
55
- log(
56
- [
57
- ` - tip: ${colors.yellow('scaffold init success')}`,
58
-
59
- ` - tip: ${colors.yellow(`The address of project is ${dest}`)}`,
60
- ].join('\n')
61
- );
62
- }
63
- /**
64
- * @description:下载脚手架
65
- * @param1: param
66
- * @param2: param
67
- * @return: ret
68
- * @Author: Charles
69
- * @Date: 2019-01-08 16:49:19
70
- */
71
- function downScaffold(gitRepo, tempRepo) {
72
- const spinner = ora('downloading scaffold...');
73
- spinner.start();
74
- download(gitRepo, tempRepo, { clone: false }, function (err) {
75
- if (err) {
76
- log(
77
- [
78
- ` - tip: ${colors.yellow(
79
- 'scaffold Download failed ,please try it'
80
- )}`,
81
- ].join('\n')
82
- );
83
- } else {
84
- spinner.succeed(colors.green('download scaffold successfully'));
85
- initScaffold(tempRepo);
86
- }
87
- });
88
- }
89
- module.exports = async (program) => {
90
- let ret = [];
91
- try {
92
- const res = await getKoScriptConf();
93
- ret = res.data;
94
- } catch (error) {
95
- console.error(error);
96
- }
97
- const choices = ret.map((item) => {
98
- return {
99
- name: `${item.name} - ${item.description}`,
100
- value: `${item.name}|${item.url}#ko-script`,
101
- };
102
- });
103
- const inquireScaffold = {
104
- type: 'list',
105
- name: 'scaffold',
106
- choices,
107
- message: 'choose scaffold you want',
108
- };
109
- const scaffoldRet = await inquirerAnswer(inquireScaffold);
110
- const scaffoldInfo = scaffoldRet.scaffold.split('|');
111
- const gitRepo = scaffoldInfo[1];
112
- const tempRepo = paths.join(userCacheRepoDir, scaffoldInfo[0]);
113
- if (existsSync(tempRepo)) {
114
- const inquireConfirm = {
115
- type: 'confirm',
116
- name: 'override',
117
- message: 'The scaffold exists.Override?',
118
- };
119
- const confirmRet = await inquirerAnswer(inquireConfirm);
120
- if (confirmRet.override) {
121
- shell.rm('-rf', tempRepo);
122
- downScaffold(gitRepo, tempRepo);
123
- } else {
124
- initScaffold(tempRepo);
125
- }
126
- } else {
127
- downScaffold(gitRepo, tempRepo);
128
- }
129
- };
package/script/install.js DELETED
@@ -1,91 +0,0 @@
1
- const path = require('path');
2
- const { realpathSync } = require('fs');
3
- const curDir = realpathSync(process.cwd());
4
- const urllib = require('urllib');
5
- const compressing = require('compressing');
6
- const userHome = require('user-home');
7
- const { existsSync, mkdir } = require('../util/fileService');
8
- const shell = require('shelljs');
9
- const colors = require('colors');
10
- const inquirer = require('inquirer');
11
- const log = console.log;
12
-
13
- async function inquirerAnswer(inquireType) {
14
- const ret = inquirer.prompt([inquireType]);
15
- return ret;
16
- }
17
-
18
- const downPackage = (url, name, basePath, customPath) => {
19
- urllib
20
- .request(url, { streaming: true, followRedirect: true })
21
- .then((result) => compressing.tgz.uncompress(result.res, basePath))
22
- .then(() => {
23
- const sourceDir = `${basePath}/package/src`;
24
- moveTargetDir(name, sourceDir, customPath);
25
- })
26
- .catch(console.error);
27
- };
28
-
29
- const moveTargetDir = async (name, sourceDir, customPath) => {
30
- let targetDir = path.join(curDir, `src/components/${name}`);
31
- if (customPath) {
32
- targetDir = path.join(customPath, name);
33
- }
34
- const inquireProject = {
35
- type: 'confirm',
36
- name: 'name',
37
- message: `Are you sure to create directory about ${targetDir}?`,
38
- };
39
- const projectRet = await inquirerAnswer(inquireProject);
40
- if (projectRet.name) {
41
- if (!existsSync(targetDir)) {
42
- mkdir(targetDir);
43
- }
44
- console.log(sourceDir, targetDir);
45
- shell.cp('-rf', `${sourceDir}` + '/*', targetDir);
46
- log([` - Tip: ${colors.green('组件下载并安装成功')}`].join('\n'));
47
- }
48
- };
49
- const getPackageInfo = async (url_package) => {
50
- let result = {};
51
- await urllib
52
- .request(url_package, { dataType: 'json' })
53
- .then((ret) => {
54
- result = ret.data;
55
- })
56
- .catch(function (err) {
57
- console.error(err);
58
- });
59
- return result;
60
- };
61
- module.exports = async (program) => {
62
- const basePath = path.join(userHome, '.kangaroo/component');
63
- if (!existsSync(basePath)) {
64
- mkdir(basePath);
65
- }
66
- let [name, relativePath] = program.args;
67
- if (!name) {
68
- name = program.name;
69
- }
70
- if (!name) {
71
- log(
72
- [` - Tip: ${colors.red('请输入组件名称或通过-n指定组件名称')}`].join(
73
- '\n'
74
- )
75
- );
76
- return;
77
- }
78
- if (program.path) {
79
- relativePath = program.path;
80
- }
81
- // 获取包信息地址
82
- const registry = 'http://registry.npm.taobao.org';
83
- const url_package = `${registry}/${name}`;
84
- const package_info = await getPackageInfo(url_package);
85
- // 下去下载压缩包地址
86
- const fileName = `${name}-${package_info['dist-tags'].latest}.tgz`;
87
- const url_tgz = `${registry}/${name}/download/${fileName}`;
88
- const customPath = relativePath ? path.resolve(basePath, relativePath) : null;
89
- // console.log(url_tgz,name,basePath,customPath);
90
- downPackage(url_tgz, name, basePath, customPath);
91
- };
package/script/lint.js DELETED
@@ -1,24 +0,0 @@
1
- const { exec } = require('child_process');
2
- const { logWithColor } = require('../util/stdout');
3
- const { prettierCmd, eslintCmd } = require('../config/lint');
4
-
5
- module.exports = function lint() {
6
- exec(prettierCmd, (error, stdout) => {
7
- if (error) {
8
- logWithColor('red', 'prettier failed:' + error);
9
- process.stdout.write(stdout);
10
- process.exit(1);
11
- } else {
12
- exec(eslintCmd, (ex, stdout) => {
13
- if (ex) {
14
- logWithColor('red', 'eslint failed:');
15
- process.stdout.write(stdout);
16
- process.exit(1);
17
- } else {
18
- logWithColor('green', 'code has been linted successfully!');
19
- process.exit(0);
20
- }
21
- });
22
- }
23
- });
24
- };
package/script/move.js DELETED
@@ -1,38 +0,0 @@
1
- const { existsSync } = require('../util/fileService');
2
- const { appDist, appGhPage } = require('../config/defaultPaths');
3
- const colors = require('colors');
4
- const shell = require('shelljs');
5
- const getUserConf = require('../config/getUserConf');
6
-
7
- function isExistDir(params) {
8
- const { keys } = Object;
9
- for (const key of keys(params)) {
10
- if (!existsSync(params[key])) {
11
- shell.mkdir('-p', params[key]);
12
- console.log(
13
- [
14
- ` - Local: ${colors.green('创建' + params[key] + '目录完成')}`,
15
- ].join('\n')
16
- );
17
- }
18
- }
19
- }
20
- module.exports = () => {
21
- try {
22
- const userConfig = getUserConf();
23
- const oldConf = {
24
- from: appDist,
25
- to: appGhPage,
26
- };
27
- const { move = {} } = userConfig;
28
-
29
- const newMove = { ...oldConf, ...move };
30
- isExistDir(newMove);
31
- shell.cp('-rf', newMove.from + '/*', newMove.to);
32
- console.log([` - Tip: ${colors.green('目录移动完成')}`].join('\n'));
33
- } catch (err) {
34
- console.log(
35
- [` - Tip: ${colors.red('目录移动失败')} ${err}`].join('\n')
36
- );
37
- }
38
- };
package/script/preview.js DELETED
@@ -1,22 +0,0 @@
1
- const server = require('pushstate-server');
2
- const paths = require('../config/defaultPaths');
3
- const colors = require('colors');
4
- module.exports = (program) => {
5
- const directory = program.dist
6
- ? paths.resolveApp(program.dist)
7
- : paths.appDist;
8
-
9
- const port = program.port || 1234;
10
- const host = program.ip || '127.0.0.1';
11
- server.start({
12
- port,
13
- host,
14
- directory,
15
- });
16
- console.log(
17
- [
18
- `\n - directory: ${colors.yellow(directory)}`,
19
- ` - Local: ${colors.yellow('http://' + host + ':' + port)}`,
20
- ].join('\n')
21
- );
22
- };