@blocklet/component-studio-cli 0.5.11 → 0.5.13
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.
|
@@ -59,7 +59,13 @@ export function createComponentStudioCommand() {
|
|
|
59
59
|
.addCommand(createAddCommand()) // 添加组件
|
|
60
60
|
.addCommand(createMigrateCommand()) // 迁移组件
|
|
61
61
|
.showHelpAfterError(true)
|
|
62
|
-
.showSuggestionAfterError(true)
|
|
62
|
+
.showSuggestionAfterError(true)
|
|
63
|
+
.action(() => {
|
|
64
|
+
program.outputHelp();
|
|
65
|
+
});
|
|
66
|
+
program.on('command:*', () => {
|
|
67
|
+
program.outputHelp();
|
|
68
|
+
});
|
|
63
69
|
// 添加依赖检查逻辑
|
|
64
70
|
const originalParse = program.parseAsync;
|
|
65
71
|
program.parseAsync = async (argv) => {
|
package/dist/commands/dev.js
CHANGED
|
@@ -3,7 +3,7 @@ import { spawn } from 'child_process';
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
5
|
import { existsSync } from 'node:fs';
|
|
6
|
-
import { join } from 'node:path';
|
|
6
|
+
import { join, dirname } from 'node:path';
|
|
7
7
|
import ora from 'ora';
|
|
8
8
|
import { getWorkspaceTemplatePath, installDependencies, getWorkspacePath, getProjectPath, replaceInDirectoryFileNameWithExample, checkShouldInstallDependencies, } from '../utils/helper.js';
|
|
9
9
|
async function createDevServer(projectPath, _options) {
|
|
@@ -14,6 +14,12 @@ async function createDevServer(projectPath, _options) {
|
|
|
14
14
|
// 2. 准备基础环境
|
|
15
15
|
if (!existsSync(workspacePath)) {
|
|
16
16
|
const workspaceTemplatePath = getWorkspaceTemplatePath();
|
|
17
|
+
const workspaceParentDir = dirname(workspacePath);
|
|
18
|
+
// 删除 workspace parent 目录(清空历史的 component studio 项目,节省用户磁盘空间)
|
|
19
|
+
await fs.remove(workspaceParentDir);
|
|
20
|
+
// 创建 workspace parent 目录
|
|
21
|
+
await fs.ensureDir(workspaceParentDir);
|
|
22
|
+
// 复制 workspace 模板
|
|
17
23
|
await fs.copy(workspaceTemplatePath, workspacePath);
|
|
18
24
|
// 修改 workspace 目录中,_example 后缀的文件名,删除 _example 后缀
|
|
19
25
|
await replaceInDirectoryFileNameWithExample(workspacePath);
|
package/dist/utils/helper.js
CHANGED
|
@@ -3,13 +3,14 @@ import { execSync, exec } from 'child_process';
|
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import { glob } from 'glob';
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
|
-
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
6
|
+
import { existsSync, readFileSync, readdirSync, rmSync } from 'node:fs';
|
|
7
7
|
import { cp } from 'node:fs/promises';
|
|
8
8
|
import { readdir, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
9
9
|
import { join, resolve, dirname, basename, relative } from 'node:path';
|
|
10
10
|
import ora from 'ora';
|
|
11
11
|
import os from 'os';
|
|
12
|
-
|
|
12
|
+
import path from 'path';
|
|
13
|
+
const workspaceVersion = '0.1.5';
|
|
13
14
|
const METADATA_FILE_NAME = '@metadata.json';
|
|
14
15
|
// 获取CLI内置的workspace模板路径
|
|
15
16
|
export function getWorkspaceTemplatePath() {
|
|
@@ -104,6 +105,21 @@ export async function installDependencies(dirs, operation = 'install') {
|
|
|
104
105
|
try {
|
|
105
106
|
const installPromises = Object.entries(dirs).map(([dirType, dirPath]) => {
|
|
106
107
|
return new Promise((resolve, reject) => {
|
|
108
|
+
// 检查 dir 是否存在,不存在则跳过
|
|
109
|
+
if (!existsSync(dirPath)) {
|
|
110
|
+
resolve();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// 尝试删除 node_modules/.vite 目录
|
|
114
|
+
try {
|
|
115
|
+
const viteDir = path.join(dirPath, 'node_modules', '.vite');
|
|
116
|
+
if (existsSync(viteDir)) {
|
|
117
|
+
rmSync(viteDir, { recursive: true, force: true });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
// ignore error
|
|
122
|
+
}
|
|
107
123
|
let errorOutput = '';
|
|
108
124
|
const depProcess = exec("npx -y taze -f -r -w -n '/arcblock|ocap|abtnode|blocklet|did-connect|did-comment|nedb/' latest && pnpm install && pnpm dedupe", {
|
|
109
125
|
cwd: dirPath,
|
|
@@ -146,9 +162,15 @@ export async function installDependencies(dirs, operation = 'install') {
|
|
|
146
162
|
if (progress >= 70) {
|
|
147
163
|
progressStep = 0.3;
|
|
148
164
|
}
|
|
165
|
+
if (progress >= 80) {
|
|
166
|
+
progressStep = 0.2;
|
|
167
|
+
}
|
|
149
168
|
if (progress >= 90) {
|
|
150
169
|
progressStep = 0.1;
|
|
151
170
|
}
|
|
171
|
+
if (progress >= 95) {
|
|
172
|
+
progressStep = 0.05;
|
|
173
|
+
}
|
|
152
174
|
}
|
|
153
175
|
}, 1000);
|
|
154
176
|
await Promise.all(installPromises);
|