@yaoxfly/cli 1.0.2 → 1.0.4

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
@@ -7,7 +7,7 @@
7
7
  无感知下载模板,无需安装`@yaoxfly/cli`。
8
8
 
9
9
  ```
10
- npx @yaoxfly/cli create [工程名]
10
+ npx @yaoxfly/cli@latest create [工程名]
11
11
 
12
12
  ```
13
13
 
package/bin/create.js CHANGED
@@ -45,12 +45,12 @@ const log_symbols_1 = __importDefault(require("log-symbols"));
45
45
  const fs_extra_1 = __importDefault(require("fs-extra"));
46
46
  const utils_1 = require("./utils");
47
47
  const tips = (param) => {
48
- const { install, installMode, projectName } = param || {};
48
+ const { install, installMode = 'pnpm', projectName } = param || {};
49
49
  console.log(log_symbols_1.default.success, chalk_1.default.green('The project is initialized'));
50
50
  console.log('\n To get started');
51
51
  console.log(`\n cd ${projectName}`);
52
- !install && console.log(`\n ${installMode} i`);
53
- console.log(`\n npm run serve`);
52
+ !install && console.log(`\n ${installMode} install`);
53
+ console.log(`\n ${installMode === 'yarn' ? 'yarn dev' : `${installMode} run dev`} `);
54
54
  };
55
55
  const create = (projectName, options) => __awaiter(void 0, void 0, void 0, function* () {
56
56
  const { force } = options || {};
@@ -59,7 +59,7 @@ const create = (projectName, options) => __awaiter(void 0, void 0, void 0, funct
59
59
  console.log(chalk_1.default.green('You can use option -f to force delete the directory except for direct mode !'));
60
60
  return;
61
61
  }
62
- const template = Promise.resolve().then(() => __importStar(require(`${__dirname}/../template`)));
62
+ const template = Promise.resolve().then(() => __importStar(require((0, utils_1.resolve)('../template'))));
63
63
  const templateObj = yield template;
64
64
  const choices = [];
65
65
  Object.keys(templateObj.default).forEach(key => {
@@ -132,10 +132,10 @@ const create = (projectName, options) => __awaiter(void 0, void 0, void 0, funct
132
132
  spinner.succeed();
133
133
  if (install) {
134
134
  const stdout = yield (0, utils_1.shellExec)({
135
- directive: `${installMode} i`,
135
+ directive: `${installMode} install --force`,
136
136
  cwd: projectName,
137
137
  loading: 'Install...',
138
- log: `${installMode} i`
138
+ log: `${installMode} install`
139
139
  });
140
140
  console.log(stdout);
141
141
  tips({ projectName, install, installMode });
package/bin/index.js CHANGED
@@ -9,7 +9,7 @@ const chalk_1 = __importDefault(require("chalk"));
9
9
  const create_1 = require("./create");
10
10
  const program = new commander_1.Command();
11
11
  program
12
- .version(require('../package').version)
12
+ .version(require('../version').version)
13
13
  .name('yx-cli');
14
14
  program
15
15
  .command('create <project-name>')
package/bin/utils.js CHANGED
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.shellExec = exports.readFile = void 0;
6
+ exports.resolve = exports.shellExec = exports.readFile = void 0;
7
7
  const fs_1 = require("fs");
8
8
  const ora_1 = __importDefault(require("ora"));
9
9
  const child_process_1 = require("child_process");
10
+ const path_1 = __importDefault(require("path"));
10
11
  const readFile = (filePath) => {
11
12
  const file = (0, fs_1.readFileSync)(filePath);
12
13
  return JSON.parse(file.toString());
@@ -31,3 +32,5 @@ const shellExec = (config) => {
31
32
  });
32
33
  };
33
34
  exports.shellExec = shellExec;
35
+ const resolve = (...file) => path_1.default.resolve(__dirname, ...file);
36
+ exports.resolve = resolve;
package/bin/version.js ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const utils_1 = require("./utils");
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const log_symbols_1 = __importDefault(require("log-symbols"));
11
+ const packageJson = (0, utils_1.readFile)((0, utils_1.resolve)('../package.json'));
12
+ fs_1.default.writeFile((0, utils_1.resolve)('../version.json'), JSON.stringify({ version: packageJson.version }, null, 2), function (err) {
13
+ if (err)
14
+ console.error(err);
15
+ console.log(log_symbols_1.default.success, chalk_1.default.green('version.json文件已经更新'));
16
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaoxfly/cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "脚手架工具,开箱即用",
5
5
  "main": "bin",
6
6
  "private": false,
@@ -10,6 +10,7 @@
10
10
  "dev": "tsc -w",
11
11
  "test": "echo \"Error: no test specified\" && exit 1",
12
12
  "lint": "eslint . --ext .js,.ts, --fix",
13
+ "prepublishOnly": "node ./bin/version.js",
13
14
  "publish": "npm version patch -f"
14
15
  },
15
16
  "bin": {
@@ -17,7 +18,8 @@
17
18
  },
18
19
  "files": [
19
20
  "bin",
20
- "template.json"
21
+ "template.json",
22
+ "version.json"
21
23
  ],
22
24
  "publishConfig": {
23
25
  "access": "public"
package/version.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "1.0.4"
3
+ }