@yaoxfly/cli 1.0.6 → 1.0.7

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/create.js CHANGED
@@ -118,8 +118,8 @@ const create = (projectName, options) => __awaiter(void 0, void 0, void 0, funct
118
118
  default: iMode(),
119
119
  choices: ['pnpm', 'npm', 'yarn'],
120
120
  when: (answers) => {
121
- const { install } = answers;
122
- return install;
121
+ const { install, templateName } = answers;
122
+ return install && templateName !== 'monorope-component';
123
123
  }
124
124
  },
125
125
  ];
@@ -131,7 +131,7 @@ const create = (projectName, options) => __awaiter(void 0, void 0, void 0, funct
131
131
  yield fs_extra_1.default.remove(projectName);
132
132
  spinner.succeed();
133
133
  }
134
- const { templateName, description, author, install, installMode } = answers || {};
134
+ const { templateName, description, author, install, installMode = 'pnpm' } = answers || {};
135
135
  const url = templateObj[templateName].url;
136
136
  const direct = url.split(':')[0] === 'direct';
137
137
  console.log(chalk_1.default.white('\n Start generating... \n'));
@@ -153,6 +153,25 @@ const create = (projectName, options) => __awaiter(void 0, void 0, void 0, funct
153
153
  Object.assign(packageJsonData, meta);
154
154
  fs_1.default.writeFileSync(filePath, JSON.stringify(packageJsonData, null, 2));
155
155
  spinner.succeed();
156
+ const gitignorePath = `${projectName}/.gitignore`;
157
+ const fileContent = (0, utils_1.readFile)(`${projectName}/.gitignore`);
158
+ const newContent = fileContent
159
+ .split('\n')
160
+ .filter(line => !line.includes('pnpm-lock.yaml'))
161
+ .join('\n');
162
+ fs_1.default.writeFileSync(gitignorePath, newContent, 'utf-8');
163
+ try {
164
+ console.log(chalk_1.default.white('\n Start update... \n'));
165
+ const output = yield (0, child_process_1.execSync)(`npx npm-check-updates@16.14.20 -u --target semver --packageManager ${installMode}`, {
166
+ cwd: projectName,
167
+ encoding: 'utf-8',
168
+ stdio: 'inherit'
169
+ });
170
+ output && console.log('Command output:\n', output);
171
+ }
172
+ catch (error) {
173
+ console.error('Error executing command:\n', error.message);
174
+ }
156
175
  if (install) {
157
176
  const stdout = yield (0, utils_1.shellExec)({
158
177
  directive: `${installMode} install --force`,
package/bin/utils.js CHANGED
@@ -9,8 +9,16 @@ 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) => {
@@ -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
  }
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.7",
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/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "1.0.6"
2
+ "version": "1.0.7"
3
3
  }