Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit a301fb2

Browse files
chhpthengechang
authored andcommitted
[fix] fix hosting and storage path error on windows
1 parent 82e4139 commit a301fb2

15 files changed

Lines changed: 161 additions & 53 deletions

File tree

lib/auth/logout.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
1111
Object.defineProperty(exports, "__esModule", { value: true });
1212
const utils_1 = require("../utils");
1313
const constant_1 = require("../constant");
14-
const logger_1 = require("../logger");
15-
const error_1 = require("../error");
1614
function logout() {
1715
return __awaiter(this, void 0, void 0, function* () {
1816
const credentail = utils_1.getCredentialData();
@@ -22,12 +20,10 @@ function logout() {
2220
}
2321
utils_1.authStore.delete(constant_1.ConfigItems.credentail);
2422
utils_1.authStore.delete(constant_1.ConfigItems.ssh);
25-
logger_1.successLog('注销登录成功!');
2623
}
2724
catch (e) {
2825
utils_1.authStore.delete(constant_1.ConfigItems.credentail);
2926
utils_1.authStore.delete(constant_1.ConfigItems.ssh);
30-
throw new error_1.CloudBaseError('云端设备登录记录删除失败,请手动删除!');
3127
}
3228
});
3329
}

lib/commands/logout.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4+
return new (P || (P = Promise))(function (resolve, reject) {
5+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8+
step((generator = generator.apply(thisArg, _arguments || [])).next());
9+
});
10+
};
211
var __importDefault = (this && this.__importDefault) || function (mod) {
312
return (mod && mod.__esModule) ? mod : { "default": mod };
413
};
514
Object.defineProperty(exports, "__esModule", { value: true });
615
const commander_1 = __importDefault(require("commander"));
716
const auth_1 = require("../auth");
17+
const logger_1 = require("../logger");
818
commander_1.default
919
.command('logout')
1020
.description('登出腾讯云账号')
11-
.action(auth_1.logout);
21+
.action(() => __awaiter(void 0, void 0, void 0, function* () {
22+
yield auth_1.logout();
23+
logger_1.successLog('注销登录成功!');
24+
}));

lib/commands/storage.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,18 @@ commander_1.default
5959
logger_1.successLog(`上传${fileText}成功!`);
6060
});
6161
if (isDir) {
62-
yield storageService.uploadDirectory(resolveLocalPath, cloudPath, {
62+
yield storageService.uploadDirectory({
63+
localPath: resolveLocalPath,
64+
cloudPath,
6365
onProgress
6466
});
6567
}
6668
else {
67-
yield storageService.uploadFile(resolveLocalPath, cloudPath, onProgress);
69+
yield storageService.uploadFile({
70+
localPath: resolveLocalPath,
71+
cloudPath,
72+
onProgress
73+
});
6874
}
6975
});
7076
});
@@ -87,10 +93,16 @@ commander_1.default
8793
const loading = utils_1.loadingFactory();
8894
loading.start(`下载${fileText}中`);
8995
if (dir) {
90-
yield storageService.downloadDirectory(cloudPath, resolveLocalPath);
96+
yield storageService.downloadDirectory({
97+
localPath: resolveLocalPath,
98+
cloudPath
99+
});
91100
}
92101
else {
93-
yield storageService.downloadFile(cloudPath, resolveLocalPath);
102+
yield storageService.downloadFile({
103+
cloudPath,
104+
localPath: resolveLocalPath
105+
});
94106
}
95107
loading.succeed(`下载${fileText}成功!`);
96108
});

lib/hosting.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ function hostingList(options) {
9494
const hosting = yield checkHostingStatus(envId);
9595
const { bucket, regoin } = hosting;
9696
const storageService = yield getStorageService(envId);
97-
const list = yield storageService.walkCloudDirCustom('', bucket, regoin);
97+
const list = yield storageService.walkCloudDirCustom({
98+
prefix: '',
99+
bucket,
100+
region: regoin
101+
});
98102
return list;
99103
});
100104
}
@@ -141,12 +145,20 @@ function hostingDeploy(options) {
141145
const { bucket, regoin } = hosting;
142146
const storageService = yield getStorageService(envId);
143147
if (utils_1.isDirectory(resolvePath)) {
144-
yield storageService.uploadDirectoryCustom(resolvePath, cloudPath, bucket, regoin, {
148+
yield storageService.uploadDirectoryCustom({
149+
localPath: resolvePath,
150+
cloudPath,
151+
bucket,
152+
region: regoin,
145153
onProgress
146154
});
147155
}
148156
else {
149-
yield storageService.uploadFileCustom(resolvePath, cloudPath, bucket, regoin, {
157+
yield storageService.uploadFileCustom({
158+
localPath: resolvePath,
159+
cloudPath,
160+
bucket,
161+
region: regoin,
150162
onProgress
151163
});
152164
}
@@ -160,7 +172,11 @@ function hostingDelete(options) {
160172
const { bucket, regoin } = hosting;
161173
const storageService = yield getStorageService(envId);
162174
if (isDir) {
163-
yield storageService.deleteDirectoryCustom(cloudPath, bucket, regoin);
175+
yield storageService.deleteDirectoryCustom({
176+
cloudPath,
177+
bucket,
178+
region: regoin
179+
});
164180
}
165181
else {
166182
yield storageService.deleteFileCustom([cloudPath], bucket, regoin);

lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const utils_1 = require("./utils");
1515
module.exports = class CloudBase {
1616
constructor(secretId, secretKey) {
1717
this.login = auth_1.login;
18+
this.logout = auth_1.logout;
1819
this.env = {
1920
list: env_1.listEnvs,
2021
create: env_1.createEnv,

lib/storage.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,43 @@ function uploadFile(options) {
3232
return __awaiter(this, void 0, void 0, function* () {
3333
const { envId, localPath, cloudPath } = options;
3434
const storageService = yield getStorageService(envId);
35-
return storageService.uploadFile(localPath, cloudPath);
35+
return storageService.uploadFile({
36+
localPath,
37+
cloudPath
38+
});
3639
});
3740
}
3841
exports.uploadFile = uploadFile;
3942
function uploadDirectory(options) {
4043
return __awaiter(this, void 0, void 0, function* () {
4144
const { envId, localPath, cloudPath } = options;
4245
const storageService = yield getStorageService(envId);
43-
return storageService.uploadDirectory(localPath, cloudPath);
46+
return storageService.uploadDirectory({
47+
localPath,
48+
cloudPath
49+
});
4450
});
4551
}
4652
exports.uploadDirectory = uploadDirectory;
4753
function downloadFile(options) {
4854
return __awaiter(this, void 0, void 0, function* () {
4955
const { envId, localPath, cloudPath } = options;
5056
const storageService = yield getStorageService(envId);
51-
return storageService.downloadFile(cloudPath, localPath);
57+
return storageService.downloadFile({
58+
cloudPath,
59+
localPath
60+
});
5261
});
5362
}
5463
exports.downloadFile = downloadFile;
5564
function downloadDirectory(options) {
5665
return __awaiter(this, void 0, void 0, function* () {
5766
const { envId, localPath, cloudPath } = options;
5867
const storageService = yield getStorageService(envId);
59-
return storageService.downloadDirectory(cloudPath, localPath);
68+
return storageService.downloadDirectory({
69+
cloudPath,
70+
localPath
71+
});
6072
});
6173
}
6274
exports.downloadDirectory = downloadDirectory;

package-lock.json

Lines changed: 28 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"build": "rimraf lib types && tsc",
88
"eslint": "eslint \"./**/*.ts\"",
99
"test": "jest --runInBand --forceExit --detectOpenHandles --coverage --verbose --testTimeout=10000",
10-
"publish": "node scripts/publish.js"
10+
"publish": "node scripts/publish.js",
11+
"pkg": "pkg ./bin/cloudbase.js --out-path ./pkg"
1112
},
1213
"repository": {
1314
"type": "git",
@@ -25,7 +26,7 @@
2526
"author": "",
2627
"license": "ISC",
2728
"dependencies": {
28-
"@cloudbase/manager-node": "^1.3.0",
29+
"@cloudbase/manager-node": "^2.0.0",
2930
"@sentry/node": "^5.10.2",
3031
"address": "^1.1.2",
3132
"archiver": "^3.1.1",

src/auth/logout.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { getCredentialData, authStore, refreshTmpToken } from '../utils'
22
import { ConfigItems } from '../constant'
3-
import { successLog } from '../logger'
4-
import { CloudBaseError } from '../error'
53

64
// 注销登录信息
75
export async function logout() {
@@ -17,10 +15,8 @@ export async function logout() {
1715
}
1816
authStore.delete(ConfigItems.credentail)
1917
authStore.delete(ConfigItems.ssh)
20-
successLog('注销登录成功!')
2118
} catch (e) {
2219
authStore.delete(ConfigItems.credentail)
2320
authStore.delete(ConfigItems.ssh)
24-
throw new CloudBaseError('云端设备登录记录删除失败,请手动删除!')
2521
}
2622
}

0 commit comments

Comments
 (0)