fix: deploy -d filename or directory
This commit is contained in:
parent
2d496917ab
commit
ce84ab4902
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kevisual/envision-cli",
|
||||
"version": "0.0.18",
|
||||
"version": "0.0.19",
|
||||
"description": "envision command tools",
|
||||
"main": "dist/index.js",
|
||||
"type": "module",
|
||||
|
@ -12,7 +12,7 @@ import { installDeps } from '@/uitls/npm.ts';
|
||||
|
||||
const command = new Command('deploy')
|
||||
.description('把前端文件传到服务器')
|
||||
.argument('<filePath>', 'Path to the file to be uploaded') // 定义文件路径参数
|
||||
.argument('<filePath>', 'Path to the file to be uploaded, filepath or directory') // 定义文件路径参数
|
||||
.option('-v, --version <version>', 'verbose')
|
||||
.option('-k, --key <key>', 'key')
|
||||
.option('-y, --yes <yes>', 'yes')
|
||||
@ -40,23 +40,30 @@ const command = new Command('deploy')
|
||||
}
|
||||
const pwd = process.cwd();
|
||||
const directory = path.join(pwd, filePath);
|
||||
const gPath = path.join(directory, '**/*');
|
||||
const files = await glob(gPath, { cwd: pwd, ignore: ['node_modules/**/*'], onlyFiles: true });
|
||||
const _relativeFiles = files.map((file) => path.relative(directory, file));
|
||||
console.log('upload Files', _relativeFiles);
|
||||
console.log('upload Files Key', key, version);
|
||||
if (!yes) {
|
||||
// 确认是否上传
|
||||
const confirm = await inquirer.prompt([
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'confirm',
|
||||
message: 'Do you want to upload these files?',
|
||||
},
|
||||
]);
|
||||
if (!confirm.confirm) {
|
||||
return;
|
||||
// 获取directory,如果是文件夹,获取文件夹下所有文件,如果是文件,获取文件
|
||||
const stat = fs.statSync(directory);
|
||||
let _relativeFiles = [];
|
||||
if (stat.isDirectory()) {
|
||||
const gPath = path.join(directory, '**/*');
|
||||
const files = await glob(gPath, { cwd: pwd, ignore: ['node_modules/**/*'], onlyFiles: true });
|
||||
_relativeFiles = files.map((file) => path.relative(directory, file));
|
||||
console.log('upload Files', _relativeFiles);
|
||||
console.log('upload Files Key', key, version);
|
||||
if (!yes) {
|
||||
// 确认是否上传
|
||||
const confirm = await inquirer.prompt([
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'confirm',
|
||||
message: 'Do you want to upload these files?',
|
||||
},
|
||||
]);
|
||||
if (!confirm.confirm) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (stat.isFile()) {
|
||||
_relativeFiles = [path.relative(pwd, directory)];
|
||||
}
|
||||
|
||||
const res = await uploadFiles(_relativeFiles, directory, { key, version });
|
||||
|
Loading…
x
Reference in New Issue
Block a user