@yaoxfly/cli 1.0.6 → 1.0.8

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/add.js CHANGED
@@ -1,28 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -43,9 +20,7 @@ const fs_1 = __importDefault(require("fs"));
43
20
  const log_symbols_1 = __importDefault(require("log-symbols"));
44
21
  const utils_1 = require("./utils");
45
22
  const add = () => __awaiter(void 0, void 0, void 0, function* () {
46
- const template = Promise.resolve().then(() => __importStar(require((0, utils_1.resolve)('../template'))));
47
- let templateObj = yield template;
48
- templateObj = templateObj.default;
23
+ const templateObj = (0, utils_1.readTemplates)();
49
24
  const question = [
50
25
  {
51
26
  name: "name",
@@ -78,7 +53,7 @@ const add = () => __awaiter(void 0, void 0, void 0, function* () {
78
53
  type: 'input',
79
54
  message: "请输入模板描述",
80
55
  validate: (val) => {
81
- if (val.length >= '70')
56
+ if (val.length >= 70)
82
57
  return 'The description is more than 70 characters!';
83
58
  return true;
84
59
  }
package/bin/create.js CHANGED
@@ -1,28 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -82,12 +59,8 @@ const create = (projectName, options) => __awaiter(void 0, void 0, void 0, funct
82
59
  console.log(chalk_1.default.green('You can use option -f to force delete the directory except for direct mode !'));
83
60
  return;
84
61
  }
85
- const template = Promise.resolve().then(() => __importStar(require((0, utils_1.resolve)('../template'))));
86
- const templateObj = yield template;
87
- const choices = [];
88
- Object.keys(templateObj.default).forEach(key => {
89
- choices.push(`${key} (${templateObj.default[key].description})`);
90
- });
62
+ const templateObj = (0, utils_1.readTemplates)();
63
+ const choices = Object.entries(templateObj).map(([key, template]) => `${key} (${template.description})`);
91
64
  const param = [
92
65
  {
93
66
  type: 'list',
@@ -118,8 +91,8 @@ const create = (projectName, options) => __awaiter(void 0, void 0, void 0, funct
118
91
  default: iMode(),
119
92
  choices: ['pnpm', 'npm', 'yarn'],
120
93
  when: (answers) => {
121
- const { install } = answers;
122
- return install;
94
+ const { install, templateName } = answers;
95
+ return install === true && templateName !== 'monorope-component';
123
96
  }
124
97
  },
125
98
  ];
@@ -131,7 +104,7 @@ const create = (projectName, options) => __awaiter(void 0, void 0, void 0, funct
131
104
  yield fs_extra_1.default.remove(projectName);
132
105
  spinner.succeed();
133
106
  }
134
- const { templateName, description, author, install, installMode } = answers || {};
107
+ const { templateName, description, author, install, installMode = 'pnpm' } = answers || {};
135
108
  const url = templateObj[templateName].url;
136
109
  const direct = url.split(':')[0] === 'direct';
137
110
  console.log(chalk_1.default.white('\n Start generating... \n'));
@@ -153,6 +126,13 @@ const create = (projectName, options) => __awaiter(void 0, void 0, void 0, funct
153
126
  Object.assign(packageJsonData, meta);
154
127
  fs_1.default.writeFileSync(filePath, JSON.stringify(packageJsonData, null, 2));
155
128
  spinner.succeed();
129
+ const gitignorePath = `${projectName}/.gitignore`;
130
+ const fileContent = fs_1.default.readFileSync(gitignorePath, 'utf-8');
131
+ const newContent = fileContent
132
+ .split('\n')
133
+ .filter(line => !line.includes('pnpm-lock.yaml'))
134
+ .join('\n');
135
+ fs_1.default.writeFileSync(gitignorePath, newContent, 'utf-8');
156
136
  if (install) {
157
137
  const stdout = yield (0, utils_1.shellExec)({
158
138
  directive: `${installMode} install --force`,
package/bin/delete.js CHANGED
@@ -1,28 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -43,9 +20,7 @@ const fs_1 = __importDefault(require("fs"));
43
20
  const log_symbols_1 = __importDefault(require("log-symbols"));
44
21
  const utils_1 = require("./utils");
45
22
  const del = () => __awaiter(void 0, void 0, void 0, function* () {
46
- const template = Promise.resolve().then(() => __importStar(require((0, utils_1.resolve)('../template'))));
47
- let templateObj = yield template;
48
- templateObj = templateObj.default;
23
+ const templateObj = (0, utils_1.readTemplates)();
49
24
  const question = [
50
25
  {
51
26
  name: "name",
package/bin/list.js CHANGED
@@ -1,28 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -40,9 +17,7 @@ exports.list = void 0;
40
17
  const utils_1 = require("./utils");
41
18
  const chalk_1 = __importDefault(require("chalk"));
42
19
  const list = () => __awaiter(void 0, void 0, void 0, function* () {
43
- const template = Promise.resolve().then(() => __importStar(require((0, utils_1.resolve)('../template'))));
44
- const templateObj = yield template;
45
20
  console.log(chalk_1.default.grey('The template list is: \n'));
46
- console.log(templateObj.default);
21
+ console.log((0, utils_1.readTemplates)());
47
22
  });
48
23
  exports.list = list;
package/bin/utils.js CHANGED
@@ -3,18 +3,26 @@ 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.hasPackage = exports.resolve = exports.shellExec = exports.readFile = void 0;
6
+ exports.hasPackage = exports.readTemplates = 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
10
  const path_1 = __importDefault(require("path"));
11
11
  const readFile = (filePath) => {
12
- const file = (0, fs_1.readFileSync)(filePath);
13
- return JSON.parse(file.toString());
12
+ let file = null;
13
+ try {
14
+ file = (0, fs_1.readFileSync)(filePath);
15
+ file = JSON.parse(file.toString());
16
+ }
17
+ catch (error) {
18
+ file = (0, fs_1.readFileSync)(filePath);
19
+ file = file.toString('utf-8');
20
+ }
21
+ return file;
14
22
  };
15
23
  exports.readFile = readFile;
16
24
  const shellExec = (config) => {
17
- const { directive, cwd, loading, log } = config || {};
25
+ const { directive, cwd, loading, log } = config;
18
26
  return new Promise((resolve, reject) => {
19
27
  log && console.log(`\n ${log} \n`);
20
28
  const spinner = (0, ora_1.default)(loading);
@@ -22,6 +30,7 @@ const shellExec = (config) => {
22
30
  (0, child_process_1.exec)(directive, { cwd }, (error, stdout) => {
23
31
  if (error) {
24
32
  loading && spinner.fail();
33
+ console.log(stdout);
25
34
  reject(error);
26
35
  return;
27
36
  }
@@ -33,6 +42,8 @@ const shellExec = (config) => {
33
42
  exports.shellExec = shellExec;
34
43
  const resolve = (...file) => path_1.default.resolve(__dirname, ...file);
35
44
  exports.resolve = resolve;
45
+ const readTemplates = () => JSON.parse((0, fs_1.readFileSync)((0, exports.resolve)('../template.json'), 'utf-8'));
46
+ exports.readTemplates = readTemplates;
36
47
  const hasPackage = () => {
37
48
  const fn = (tool) => {
38
49
  try {
package/package.json CHANGED
@@ -1,54 +1,54 @@
1
- {
2
- "name": "@yaoxfly/cli",
3
- "version": "1.0.6",
4
- "description": "脚手架工具,开箱即用",
5
- "main": "bin",
6
- "private": false,
7
- "author": "yaoxfly",
8
- "license": "MIT",
9
- "scripts": {
10
- "dev": "tsc -w",
11
- "test": "echo \"Error: no test specified\" && exit 1",
12
- "lint": "eslint . --ext .js,.ts, --fix",
13
- "prepublishOnly": "node ./bin/version.js",
14
- "publish": "npm version patch -f"
15
- },
16
- "bin": {
17
- "yx-cli": "./bin/index.js"
18
- },
19
- "files": [
20
- "bin",
21
- "template.json",
22
- "version.json"
23
- ],
24
- "publishConfig": {
25
- "access": "public"
26
- },
27
- "keywords": [
28
- "cli",
29
- "yaoxfly",
30
- "vue",
31
- "vitepress",
32
- "vite"
33
- ],
34
- "repository": {
35
- "type": "git",
36
- "url": "https://github.com/yaoxfly/yaoxfly-cli.git"
37
- },
38
- "devDependencies": {
39
- "@types/node": "^18.8.5",
40
- "@typescript-eslint/eslint-plugin": "^5.40.0",
41
- "@typescript-eslint/parser": "^5.40.0",
42
- "eslint": "^8.25.0",
43
- "typescript": "4.8.4"
44
- },
45
- "dependencies": {
46
- "chalk": "4.1.2",
47
- "commander": "9.4.1",
48
- "download-git-repo": "3.0.2",
49
- "fs-extra": "10.1.0",
50
- "inquirer": "8.0.0",
51
- "log-symbols": "4.0.0",
52
- "ora": "5.2.0"
53
- }
54
- }
1
+ {
2
+ "name": "@yaoxfly/cli",
3
+ "version": "1.0.8",
4
+ "description": "脚手架工具,开箱即用",
5
+ "main": "bin",
6
+ "private": false,
7
+ "author": "yaoxfly",
8
+ "license": "MIT",
9
+ "scripts": {
10
+ "dev": "tsc -w",
11
+ "test": "echo \"Error: no test specified\" && exit 1",
12
+ "lint": "eslint . --ext .js,.ts, --fix",
13
+ "prepublishOnly": "node ./bin/version.js",
14
+ "publish": "npm version patch -f"
15
+ },
16
+ "bin": {
17
+ "yx-cli": "./bin/index.js"
18
+ },
19
+ "files": [
20
+ "bin",
21
+ "template.json",
22
+ "version.json"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "keywords": [
28
+ "cli",
29
+ "yaoxfly",
30
+ "vue",
31
+ "vitepress",
32
+ "vite"
33
+ ],
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/yaoxfly/yaoxfly-cli.git"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^18.8.5",
40
+ "@typescript-eslint/eslint-plugin": "^5.40.0",
41
+ "@typescript-eslint/parser": "^5.40.0",
42
+ "eslint": "^8.25.0",
43
+ "typescript": "4.8.4"
44
+ },
45
+ "dependencies": {
46
+ "chalk": "4.1.2",
47
+ "commander": "9.4.1",
48
+ "download-git-repo": "3.0.2",
49
+ "fs-extra": "10.1.0",
50
+ "inquirer": "8.0.0",
51
+ "log-symbols": "4.0.0",
52
+ "ora": "5.2.0"
53
+ }
54
+ }
package/template.json CHANGED
@@ -11,5 +11,9 @@
11
11
  "monorope-component": {
12
12
  "url": "yaoxfly/monorope-component",
13
13
  "description": "[monorope]、typeScript、vue3、vite、pnpm"
14
+ },
15
+ "vue3-admin-frame": {
16
+ "url": "yaoxfly/vue3-admin-frame",
17
+ "description": "[vue3.x]、typeScript 、vite3、pinia、eslint、axios、mock、multiple environments"
14
18
  }
15
19
  }
package/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "1.0.6"
2
+ "version": "1.0.8"
3
3
  }