@blocklet/component-studio-cli 0.4.151 → 0.4.152
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/commands/dev.js +10 -11
- package/dist/utils/helper.d.ts +1 -0
- package/dist/utils/helper.js +3 -0
- package/package.json +1 -1
package/dist/commands/dev.js
CHANGED
|
@@ -5,7 +5,7 @@ import fs from 'fs-extra';
|
|
|
5
5
|
import { existsSync } from 'node:fs';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import ora from 'ora';
|
|
8
|
-
import { getWorkspaceTemplatePath, installDependencies, getWorkspacePath, getProjectPath, replaceInDirectoryFileNameWithExample, } from '../utils/helper.js';
|
|
8
|
+
import { getWorkspaceTemplatePath, installDependencies, getWorkspacePath, getProjectPath, replaceInDirectoryFileNameWithExample, checkShouldInstallDependencies, } from '../utils/helper.js';
|
|
9
9
|
async function createDevServer(projectPath, _options) {
|
|
10
10
|
// 1. 创建工作区
|
|
11
11
|
const workspacePath = getWorkspacePath();
|
|
@@ -54,20 +54,19 @@ async function createDevServer(projectPath, _options) {
|
|
|
54
54
|
await fs.ensureSymlink(projectPath, projectLinkDir);
|
|
55
55
|
projectLinkSpinner.succeed(chalk.green('Project linked to workspace successfully!'));
|
|
56
56
|
}
|
|
57
|
-
let shouldInstallWorkspaceDeps =
|
|
58
|
-
let shouldInstallProjectDeps =
|
|
57
|
+
let shouldInstallWorkspaceDeps = await checkShouldInstallDependencies(workspacePath);
|
|
58
|
+
let shouldInstallProjectDeps = await checkShouldInstallDependencies(projectPath);
|
|
59
59
|
// 5. 安装依赖
|
|
60
60
|
if (shouldInstallWorkspaceDeps || shouldInstallProjectDeps) {
|
|
61
|
-
const dirsToInstall = {};
|
|
62
|
-
if (shouldInstallWorkspaceDeps) {
|
|
63
|
-
dirsToInstall['Workspace'] = workspacePath;
|
|
64
|
-
}
|
|
65
61
|
if (shouldInstallProjectDeps) {
|
|
66
|
-
|
|
62
|
+
await installDependencies({
|
|
63
|
+
Project: projectPath,
|
|
64
|
+
});
|
|
67
65
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
if (shouldInstallWorkspaceDeps) {
|
|
67
|
+
await installDependencies({
|
|
68
|
+
Workspace: workspacePath,
|
|
69
|
+
});
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
72
|
const devServerSpinner = ora({ text: 'Creating development server...', color: 'blue' }).start();
|
package/dist/utils/helper.d.ts
CHANGED
|
@@ -100,3 +100,4 @@ export declare function isCommandAvailable(command: string): boolean;
|
|
|
100
100
|
* @returns 安装是否成功
|
|
101
101
|
*/
|
|
102
102
|
export declare function installGlobalPackage(packageName: string): Promise<boolean>;
|
|
103
|
+
export declare function checkShouldInstallDependencies(dirPath: string): Promise<boolean>;
|
package/dist/utils/helper.js
CHANGED
|
@@ -513,3 +513,6 @@ export async function installGlobalPackage(packageName) {
|
|
|
513
513
|
return false;
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
|
+
export async function checkShouldInstallDependencies(dirPath) {
|
|
517
|
+
return !(await fs.exists(join(dirPath, 'node_modules'))) || !(await fs.exists(join(dirPath, 'pnpm-lock.yaml')));
|
|
518
|
+
}
|