@blocklet/component-studio-cli 0.4.150 → 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.
@@ -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 = !(await fs.exists(join(workspacePath, 'node_modules')));
58
- let shouldInstallProjectDeps = !(await fs.exists(join(projectPath, 'node_modules')));
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
- dirsToInstall['Project'] = projectPath;
62
+ await installDependencies({
63
+ Project: projectPath,
64
+ });
67
65
  }
68
- const result = await installDependencies(dirsToInstall);
69
- if (!result) {
70
- process.exit(1);
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();
@@ -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>;
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/component-studio-cli",
3
- "version": "0.4.150",
3
+ "version": "0.4.152",
4
4
  "description": "CLI for Component Studio",
5
5
  "publishConfig": {
6
6
  "access": "public"