@yuw-cli-dev/core 1.0.37 → 1.0.39

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/bin/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
-
3
- const importLocal = require("import-local");
4
- if (importLocal(__filename)) {
5
- require("npmlog").info("cli", "正在使用 yuw-cli-dev 本地版本");
6
- } else {
7
- require("../lib/index.js")(process.argv.slice(2));
8
- }
2
+
3
+ const importLocal = require("import-local");
4
+ if (importLocal(__filename)) {
5
+ require("npmlog").info("cli", "正在使用 yuw-cli-dev 本地版本");
6
+ } else {
7
+ require("../lib/index.js")(process.argv.slice(2));
8
+ }
package/lib/const.js CHANGED
@@ -1,7 +1,7 @@
1
- const LOWEST_NODE_VERSION = "16.0.0";
2
- const DEFAULT_CLI_HOME = ".yuw-cli";
3
-
4
- module.exports = {
5
- LOWEST_NODE_VERSION,
6
- DEFAULT_CLI_HOME,
7
- };
1
+ const LOWEST_NODE_VERSION = '16.0.0';
2
+ const DEFAULT_CLI_HOME = '.yuw-cli';
3
+
4
+ module.exports = {
5
+ LOWEST_NODE_VERSION,
6
+ DEFAULT_CLI_HOME,
7
+ };
package/lib/index.js CHANGED
@@ -1,17 +1,17 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  module.exports = core;
4
4
 
5
- const path = require("path");
6
- const colors = require("colors/safe");
7
- const semver = require("semver");
8
- const userHome = require("user-home");
9
- const Commander = require("commander");
10
- const pathExists = require("path-exists").sync;
11
- const pkg = require("../package.json");
12
- const log = require("@yuw-cli-dev/log");
13
- const exec = require("@yuw-cli-dev/exec");
14
- const constants = require("./const");
5
+ const path = require('path');
6
+ const colors = require('colors/safe');
7
+ const semver = require('semver');
8
+ const userHome = require('user-home');
9
+ const Commander = require('commander');
10
+ const pathExists = require('path-exists').sync;
11
+ const pkg = require('../package.json');
12
+ const log = require('@yuw-cli-dev/log');
13
+ const exec = require('@yuw-cli-dev/exec');
14
+ const constants = require('./const');
15
15
  const program = new Commander.Command();
16
16
 
17
17
  async function core() {
@@ -34,7 +34,7 @@ async function perpare() {
34
34
  }
35
35
 
36
36
  function checkPkgVersion() {
37
- log.info("cli", pkg.version);
37
+ log.info('cli', pkg.version);
38
38
  }
39
39
 
40
40
  function checkNodeVersion() {
@@ -50,41 +50,41 @@ function checkNodeVersion() {
50
50
  }
51
51
 
52
52
  function checkRoot() {
53
- const rootCheck = require("root-check");
53
+ const rootCheck = require('root-check');
54
54
  rootCheck();
55
55
  }
56
56
 
57
57
  function checkUserHome() {
58
58
  if (!userHome || !pathExists(userHome)) {
59
- throw new Error(colors.red("当前登录用户主目录不存在!"));
59
+ throw new Error(colors.red('当前登录用户主目录不存在!'));
60
60
  }
61
61
  }
62
62
 
63
63
  function checkInputArgs() {
64
- const minimist = require("minimist");
64
+ const minimist = require('minimist');
65
65
  const args = minimist(process.argv.slice(2));
66
66
  checkArgs(args);
67
67
  }
68
68
 
69
69
  function checkArgs(args) {
70
70
  if (args.debug) {
71
- process.env.LOG_LEVEL = "verbose";
71
+ process.env.LOG_LEVEL = 'verbose';
72
72
  } else {
73
- process.env.LOG_LEVEL = "info";
73
+ process.env.LOG_LEVEL = 'info';
74
74
  }
75
75
  log.level = process.env.LOG_LEVEL;
76
76
  }
77
77
 
78
78
  function checkEnv() {
79
- const dotenv = require("dotenv");
80
- const dotenvPath = path.resolve(userHome, ".env");
79
+ const dotenv = require('dotenv');
80
+ const dotenvPath = path.resolve(userHome, '.env');
81
81
  if (pathExists(dotenvPath)) {
82
82
  dotenv.config({
83
83
  path: dotenvPath,
84
84
  });
85
85
  }
86
86
  createDefaultConfig();
87
- log.verbose("环境变量", process.env.CLI_HOME_PATH);
87
+ log.verbose('环境变量', process.env.CLI_HOME_PATH);
88
88
  }
89
89
 
90
90
  function createDefaultConfig() {
@@ -102,11 +102,11 @@ function createDefaultConfig() {
102
102
  async function checkGlobalUpdate() {
103
103
  const currentVersion = pkg.version;
104
104
  const npmName = pkg.name;
105
- const { getNpmSemverVersion } = require("@yuw-cli-dev/get-npm-info");
105
+ const { getNpmSemverVersion } = require('@yuw-cli-dev/get-npm-info');
106
106
  const latestVersion = await getNpmSemverVersion(npmName, currentVersion);
107
107
  if (latestVersion && semver.gt(latestVersion, currentVersion)) {
108
108
  log.warn(
109
- "更新提示",
109
+ '更新提示',
110
110
  colors.yellow(
111
111
  `请手动更新 ${npmName},当前版本:${currentVersion},最新版本:${latestVersion},更新命令:npm install -g ${npmName}`,
112
112
  ),
@@ -118,35 +118,35 @@ function registerCommand() {
118
118
  program.name(Object.keys(pkg.bin)[0]);
119
119
  program
120
120
  .version(pkg.version)
121
- .usage("<command> [options]")
122
- .option("-d, --debug", "是否开启调试模式", false)
123
- .option("-t, --targetPath <targetPath>", "是否指定本地调试文件路径", "");
121
+ .usage('<command> [options]')
122
+ .option('-d, --debug', '是否开启调试模式', false)
123
+ .option('-t, --targetPath <targetPath>', '是否指定本地调试文件路径', '');
124
124
 
125
125
  program
126
- .command("init [projectName]")
127
- .option("-f, --force", "是否强制初始化项目")
126
+ .command('init [projectName]')
127
+ .option('-f, --force', '是否强制初始化项目')
128
128
  .action(exec);
129
129
 
130
- program.on("option:debug", function () {
130
+ program.on('option:debug', function () {
131
131
  const options = program.opts();
132
132
  if (options.debug) {
133
- process.env.LOG_LEVEL = "verbose";
133
+ process.env.LOG_LEVEL = 'verbose';
134
134
  } else {
135
- process.env.LOG_LEVEL = "info";
135
+ process.env.LOG_LEVEL = 'info';
136
136
  }
137
137
  log.level = process.env.LOG_LEVEL;
138
- log.verbose("debug", "已开启调试模式");
138
+ log.verbose('debug', '已开启调试模式');
139
139
  });
140
140
 
141
- program.on("option:targetPath", function (targetPath) {
141
+ program.on('option:targetPath', function (targetPath) {
142
142
  process.env.CLI_TARGET_PATH = targetPath;
143
143
  });
144
144
 
145
- program.on("command:*", function (obj) {
146
- const availableCommands = program.commands.map((cmd) => cmd.name());
147
- console.log(colors.red("未知的命令:" + obj[0]));
145
+ program.on('command:*', function (obj) {
146
+ const availableCommands = program.commands.map(cmd => cmd.name());
147
+ console.log(colors.red('未知的命令:' + obj[0]));
148
148
  if (availableCommands.length > 0) {
149
- console.log(colors.red("可用命令:" + availableCommands.join(",")));
149
+ console.log(colors.red('可用命令:' + availableCommands.join(',')));
150
150
  }
151
151
  });
152
152
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuw-cli-dev/core",
3
- "version": "1.0.37",
3
+ "version": "1.0.39",
4
4
  "description": "> TODO: description",
5
5
  "author": "yuwei <yuwei@huya.com>",
6
6
  "homepage": "",
@@ -20,11 +20,11 @@
20
20
  "test": "echo \"Error: run tests from root\" && exit 1"
21
21
  },
22
22
  "dependencies": {
23
- "@yuw-cli-dev/exec": "^1.0.37",
24
- "@yuw-cli-dev/get-npm-info": "^1.0.37",
25
- "@yuw-cli-dev/init": "^1.0.37",
26
- "@yuw-cli-dev/log": "^1.0.36",
27
- "@yuw-cli-dev/utils": "^1.0.37",
23
+ "@yuw-cli-dev/exec": "^1.0.39",
24
+ "@yuw-cli-dev/get-npm-info": "^1.0.39",
25
+ "@yuw-cli-dev/init": "^1.0.39",
26
+ "@yuw-cli-dev/log": "^1.0.39",
27
+ "@yuw-cli-dev/utils": "^1.0.39",
28
28
  "colors": "^1.4.0",
29
29
  "commander": "^14.0.2",
30
30
  "dotenv": "^17.2.3",
@@ -35,7 +35,7 @@
35
35
  "root-check": "^1.0.0",
36
36
  "user-home": "^3.0.0"
37
37
  },
38
- "gitHead": "ab03556d97ed9d4caf7af33d1720f4e45e34749a",
38
+ "gitHead": "7bcace542ccccc47f518b0537cbb0cce93229adf",
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  }