MCPcopy Create free account
hub / github.com/Crain99/cc-reverse / build

Function build

scripts/build.js:67–107  ·  view source on GitHub ↗

* 构建项目

()

Source from the content-addressed store, hash-verified

65 * 构建项目
66 */
67function build() {
68 const spinner = ora('开始构建项目...').start();
69
70 try {
71 // 1. 清理构建目录
72 spinner.text = '清理构建目录...';
73 cleanDir(BUILD_DIR);
74
75 // 2. 复制源文件
76 spinner.text = '复制源文件...';
77 copyDir(path.join(__dirname, '../src'), path.join(BUILD_DIR, 'src'));
78 copyDir(path.join(__dirname, '../bin'), path.join(BUILD_DIR, 'bin'));
79
80 // 3. 复制配置文件
81 spinner.text = '复制配置文件...';
82 copyFile(path.join(__dirname, '../package.json'), path.join(BUILD_DIR, 'package.json'));
83 copyFile(path.join(__dirname, '../README.md'), path.join(BUILD_DIR, 'README.md'));
84 copyFile(path.join(__dirname, '../cc-reverse.config.js'),
85 path.join(BUILD_DIR, 'cc-reverse.config.js'));
86
87 // 4. 设置bin权限
88 spinner.text = '设置执行权限...';
89 fs.chmodSync(path.join(BUILD_DIR, 'bin/cc-reverse.js'), '755');
90
91 // 5. 安装依赖
92 spinner.text = '安装依赖...';
93 process.chdir(BUILD_DIR);
94 execSync('npm install --production', { stdio: 'ignore' });
95
96 // 6. 完成构建
97 spinner.succeed(chalk.green('项目构建完成!'));
98 console.log(`\n构建目录: ${chalk.cyan(BUILD_DIR)}`);
99 console.log(`\n安装: ${chalk.yellow('npm install -g ' + BUILD_DIR)}`);
100 console.log(`运行: ${chalk.yellow('cc-reverse --path <源项目路径>')}`);
101
102 } catch (err) {
103 spinner.fail(chalk.red('构建失败!'));
104 console.error(err);
105 process.exit(1);
106 }
107}
108
109// 执行构建
110build();

Callers 1

build.jsFile · 0.70

Calls 3

cleanDirFunction · 0.85
copyDirFunction · 0.85
copyFileFunction · 0.70

Tested by

no test coverage detected