@blocklet/component-studio-cli 0.6.59 → 0.6.61
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/dist/utils/helper.js +10 -10
- package/package.json +1 -1
package/dist/utils/helper.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
/* eslint-disable no-await-in-loop */
|
|
1
2
|
import chalk from 'chalk';
|
|
2
3
|
import { execSync, exec } from 'child_process';
|
|
3
4
|
import fs from 'fs-extra';
|
|
4
5
|
import { glob } from 'glob';
|
|
5
6
|
import inquirer from 'inquirer';
|
|
6
7
|
import { existsSync, readFileSync, readdirSync, rmSync } from 'node:fs';
|
|
7
|
-
import { cp } from 'node:fs/promises';
|
|
8
|
-
import { readdir, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
8
|
+
import { readdir, mkdir, readFile, writeFile, cp } 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 DEFAULT_WORKSPACE_VERSION = '0.2.
|
|
13
|
+
const DEFAULT_WORKSPACE_VERSION = '0.2.3';
|
|
14
14
|
const METADATA_FILE_NAME = '@metadata.json';
|
|
15
15
|
export const BLOCKLET_INFO_DIR = '.blocklet-info';
|
|
16
16
|
// 获取CLI内置的workspace模板路径
|
|
@@ -21,7 +21,7 @@ export function getWorkspaceTemplatePath() {
|
|
|
21
21
|
export function getWorkspacePath(version) {
|
|
22
22
|
const homeDir = os.homedir();
|
|
23
23
|
const workspaceHash = version || DEFAULT_WORKSPACE_VERSION;
|
|
24
|
-
const workspaceDir = join(homeDir,
|
|
24
|
+
const workspaceDir = join(homeDir, '.component-studio', workspaceHash);
|
|
25
25
|
return workspaceDir;
|
|
26
26
|
}
|
|
27
27
|
// 获取当前项目路径
|
|
@@ -48,8 +48,8 @@ export async function copyTemplateFilesExcept(sourcePath, targetPath) {
|
|
|
48
48
|
await mkdir(targetName, { recursive: true });
|
|
49
49
|
await copyTemplateFilesExcept(sourceName, targetName);
|
|
50
50
|
}
|
|
51
|
-
// 如果是文件且不在排除列表中,则复制
|
|
52
51
|
else if (!excludeFiles.includes(entry.name)) {
|
|
52
|
+
// 如果是文件且不在排除列表中,则复制
|
|
53
53
|
await cp(sourceName, targetName);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -76,8 +76,8 @@ export async function mergePackageJson(basePath, templatePath) {
|
|
|
76
76
|
// 读取模板 package.json
|
|
77
77
|
const templatePackage = JSON.parse(await readFile(templatePackagePath, 'utf8'));
|
|
78
78
|
// 合并包,保留基础包的 name 和 version
|
|
79
|
-
const name = basePackage
|
|
80
|
-
const version = basePackage
|
|
79
|
+
const { name } = basePackage;
|
|
80
|
+
const { version } = basePackage;
|
|
81
81
|
const mergedPackage = {
|
|
82
82
|
name, // 保留原名称
|
|
83
83
|
version, // 保留原版本
|
|
@@ -218,7 +218,7 @@ export function loadTemplates(templatesDir) {
|
|
|
218
218
|
{
|
|
219
219
|
key: folder,
|
|
220
220
|
name: metadata.name || folder,
|
|
221
|
-
description: metadata.description ||
|
|
221
|
+
description: metadata.description || 'The description of this template is empty',
|
|
222
222
|
},
|
|
223
223
|
];
|
|
224
224
|
}
|
|
@@ -239,7 +239,7 @@ export function loadTemplates(templatesDir) {
|
|
|
239
239
|
return {
|
|
240
240
|
key: `${folder}/${subFolder}`,
|
|
241
241
|
name: metadata.name || subFolder,
|
|
242
|
-
description: metadata.description ||
|
|
242
|
+
description: metadata.description || 'The description of this template is empty',
|
|
243
243
|
};
|
|
244
244
|
}
|
|
245
245
|
catch (error) {
|
|
@@ -250,7 +250,7 @@ export function loadTemplates(templatesDir) {
|
|
|
250
250
|
return {
|
|
251
251
|
key: `${folder}/${subFolder}`,
|
|
252
252
|
name: subFolder,
|
|
253
|
-
description:
|
|
253
|
+
description: 'The description of this template is empty',
|
|
254
254
|
};
|
|
255
255
|
});
|
|
256
256
|
});
|