@capawesome/cli 0.0.1
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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/commands/apps/bundles/create.js +104 -0
- package/dist/commands/apps/bundles/delete.js +79 -0
- package/dist/commands/apps/channels/create.js +71 -0
- package/dist/commands/apps/channels/delete.js +83 -0
- package/dist/commands/apps/create.js +55 -0
- package/dist/commands/apps/delete.js +65 -0
- package/dist/commands/apps/devices/delete.js +79 -0
- package/dist/commands/login.js +54 -0
- package/dist/commands/logout.js +31 -0
- package/dist/commands/whoami.js +32 -0
- package/dist/config/consts.js +5 -0
- package/dist/config/index.js +17 -0
- package/dist/index.js +50 -0
- package/dist/service/app-bundle.js +45 -0
- package/dist/service/app-channel.js +50 -0
- package/dist/service/app-device.js +35 -0
- package/dist/service/apps.js +61 -0
- package/dist/service/authorization-service.js +23 -0
- package/dist/types/app-bundle.js +2 -0
- package/dist/types/app-channel.js +2 -0
- package/dist/types/app-device.js +2 -0
- package/dist/types/app.js +2 -0
- package/dist/types/index.js +20 -0
- package/dist/utils/ci.js +7 -0
- package/dist/utils/http-client.js +77 -0
- package/dist/utils/prompt.js +43 -0
- package/dist/utils/userConfig.js +16 -0
- package/dist/utils/zip.js +35 -0
- package/package.json +61 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const citty_1 = require("citty");
|
|
16
|
+
const consola_1 = __importDefault(require("consola"));
|
|
17
|
+
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
18
|
+
exports.default = (0, citty_1.defineCommand)({
|
|
19
|
+
meta: {
|
|
20
|
+
name: 'logout',
|
|
21
|
+
description: 'Sign out from the Capawesome Cloud Console.',
|
|
22
|
+
},
|
|
23
|
+
args: {},
|
|
24
|
+
run: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
const config = userConfig_1.default.read();
|
|
26
|
+
delete config.username;
|
|
27
|
+
delete config.token;
|
|
28
|
+
userConfig_1.default.write(config);
|
|
29
|
+
consola_1.default.success('Successfully signed out.');
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const citty_1 = require("citty");
|
|
16
|
+
const consola_1 = __importDefault(require("consola"));
|
|
17
|
+
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
18
|
+
exports.default = (0, citty_1.defineCommand)({
|
|
19
|
+
meta: {
|
|
20
|
+
name: 'whoami',
|
|
21
|
+
description: 'Show current user',
|
|
22
|
+
},
|
|
23
|
+
run: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const { username } = userConfig_1.default.read();
|
|
25
|
+
if (!username) {
|
|
26
|
+
consola_1.default.error('Not logged in');
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
consola_1.default.info(`Logged in as ${username}`);
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./consts"), exports);
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const citty_1 = require("citty");
|
|
30
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
31
|
+
const main = (0, citty_1.defineCommand)({
|
|
32
|
+
meta: {
|
|
33
|
+
name: package_json_1.default.name,
|
|
34
|
+
version: package_json_1.default.version,
|
|
35
|
+
description: package_json_1.default.description,
|
|
36
|
+
},
|
|
37
|
+
subCommands: {
|
|
38
|
+
whoami: Promise.resolve().then(() => __importStar(require('./commands/whoami'))).then((mod) => mod.default),
|
|
39
|
+
login: Promise.resolve().then(() => __importStar(require('./commands/login'))).then((mod) => mod.default),
|
|
40
|
+
logout: Promise.resolve().then(() => __importStar(require('./commands/logout'))).then((mod) => mod.default),
|
|
41
|
+
'apps:create': Promise.resolve().then(() => __importStar(require('./commands/apps/create'))).then((mod) => mod.default),
|
|
42
|
+
'apps:delete': Promise.resolve().then(() => __importStar(require('./commands/apps/delete'))).then((mod) => mod.default),
|
|
43
|
+
'apps:bundles:create': Promise.resolve().then(() => __importStar(require('./commands/apps/bundles/create'))).then((mod) => mod.default),
|
|
44
|
+
'apps:bundles:delete': Promise.resolve().then(() => __importStar(require('./commands/apps/bundles/delete'))).then((mod) => mod.default),
|
|
45
|
+
'apps:channels:create': Promise.resolve().then(() => __importStar(require('./commands/apps/channels/create'))).then((mod) => mod.default),
|
|
46
|
+
'apps:channels:delete': Promise.resolve().then(() => __importStar(require('./commands/apps/channels/delete'))).then((mod) => mod.default),
|
|
47
|
+
'apps:devices:delete': Promise.resolve().then(() => __importStar(require('./commands/apps/devices/delete'))).then((mod) => mod.default),
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
(0, citty_1.runMain)(main);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const http_client_1 = __importDefault(require("../utils/http-client"));
|
|
16
|
+
const authorization_service_1 = __importDefault(require("./authorization-service"));
|
|
17
|
+
class AppBundlesServiceImpl {
|
|
18
|
+
constructor(httpClient) {
|
|
19
|
+
this.httpClient = httpClient;
|
|
20
|
+
}
|
|
21
|
+
create(data) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const res = yield this.httpClient.post(`/apps/${data.appId}/bundles`, data.formData, {
|
|
24
|
+
headers: Object.assign({ Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}` }, data.formData.getHeaders()),
|
|
25
|
+
});
|
|
26
|
+
if (!res.success) {
|
|
27
|
+
throw res.error;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
delete(data) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const res = yield this.httpClient.delete(`/apps/${data.appId}/bundles/${data.bundleId}`, {
|
|
34
|
+
headers: {
|
|
35
|
+
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
if (!res.success) {
|
|
39
|
+
throw res.error;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const appBundlesService = new AppBundlesServiceImpl(http_client_1.default);
|
|
45
|
+
exports.default = appBundlesService;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const http_client_1 = __importDefault(require("../utils/http-client"));
|
|
16
|
+
const authorization_service_1 = __importDefault(require("./authorization-service"));
|
|
17
|
+
class AppChannelsServiceImpl {
|
|
18
|
+
constructor(httpClient) {
|
|
19
|
+
this.httpClient = httpClient;
|
|
20
|
+
}
|
|
21
|
+
create(dto) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const res = yield this.httpClient.post(`/apps/${dto.appId}/channels`, dto, {
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
if (!res.success) {
|
|
29
|
+
throw res.error;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
delete(data) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const res = yield this.httpClient.delete(`/apps/${data.appId}/channels`, {
|
|
36
|
+
headers: {
|
|
37
|
+
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
38
|
+
},
|
|
39
|
+
params: {
|
|
40
|
+
name: data.name,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
if (!res.success) {
|
|
44
|
+
throw res.error;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const appChannelsService = new AppChannelsServiceImpl(http_client_1.default);
|
|
50
|
+
exports.default = appChannelsService;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const http_client_1 = __importDefault(require("../utils/http-client"));
|
|
16
|
+
const authorization_service_1 = __importDefault(require("./authorization-service"));
|
|
17
|
+
class AppDevicesServiceImpl {
|
|
18
|
+
constructor(httpClient) {
|
|
19
|
+
this.httpClient = httpClient;
|
|
20
|
+
}
|
|
21
|
+
delete(data) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const res = yield this.httpClient.delete(`/apps/${data.appId}/devices/${data.deviceId}`, {
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
if (!res.success) {
|
|
29
|
+
throw res.error;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const appDevicesService = new AppDevicesServiceImpl(http_client_1.default);
|
|
35
|
+
exports.default = appDevicesService;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const http_client_1 = __importDefault(require("../utils/http-client"));
|
|
16
|
+
const authorization_service_1 = __importDefault(require("./authorization-service"));
|
|
17
|
+
class AppsServiceImpl {
|
|
18
|
+
constructor(httpClient) {
|
|
19
|
+
this.httpClient = httpClient;
|
|
20
|
+
}
|
|
21
|
+
create(dto) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const response = yield this.httpClient.post(`/apps`, dto, {
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
if (!response.success) {
|
|
29
|
+
throw response.error;
|
|
30
|
+
}
|
|
31
|
+
return response.data;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
delete(dto) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const response = yield this.httpClient.delete(`/apps/${dto.id}`, {
|
|
37
|
+
headers: {
|
|
38
|
+
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
if (!response.success) {
|
|
42
|
+
throw response.error;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
findAll() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const response = yield this.httpClient.get('/apps', {
|
|
49
|
+
headers: {
|
|
50
|
+
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
if (!response.success) {
|
|
54
|
+
throw response.error;
|
|
55
|
+
}
|
|
56
|
+
return response.data;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const appsService = new AppsServiceImpl(http_client_1.default);
|
|
61
|
+
exports.default = appsService;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ci_1 = require("../utils/ci");
|
|
7
|
+
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
8
|
+
class AuthorizationServiceImpl {
|
|
9
|
+
constructor(userConfig) {
|
|
10
|
+
this.userConfig = userConfig;
|
|
11
|
+
}
|
|
12
|
+
getCurrentAuthorizationToken() {
|
|
13
|
+
if ((0, ci_1.isRunningInCi)()) {
|
|
14
|
+
return process.env.CAPAWESOME_TOKEN || null;
|
|
15
|
+
}
|
|
16
|
+
return this.userConfig.read().token || null;
|
|
17
|
+
}
|
|
18
|
+
hasAuthorizationToken() {
|
|
19
|
+
return !!this.getCurrentAuthorizationToken();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const authorizationService = new AuthorizationServiceImpl(userConfig_1.default);
|
|
23
|
+
exports.default = authorizationService;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./app"), exports);
|
|
18
|
+
__exportStar(require("./app-bundle"), exports);
|
|
19
|
+
__exportStar(require("./app-device"), exports);
|
|
20
|
+
__exportStar(require("./app-channel"), exports);
|
package/dist/utils/ci.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
const config_1 = require("../config");
|
|
17
|
+
class HttpClientImpl {
|
|
18
|
+
delete(url, config) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
try {
|
|
21
|
+
const res = yield axios_1.default.delete(config_1.API_URL + url, config);
|
|
22
|
+
return {
|
|
23
|
+
success: true,
|
|
24
|
+
status: res.status,
|
|
25
|
+
data: res.data,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
return {
|
|
30
|
+
success: false,
|
|
31
|
+
status: e.response.status,
|
|
32
|
+
error: e,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
get(url, config) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
try {
|
|
40
|
+
const res = yield axios_1.default.get(config_1.API_URL + url, config);
|
|
41
|
+
return {
|
|
42
|
+
success: true,
|
|
43
|
+
status: res.status,
|
|
44
|
+
data: res.data,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
return {
|
|
49
|
+
success: false,
|
|
50
|
+
status: e.response.status,
|
|
51
|
+
error: e,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
post(url, data, config) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
try {
|
|
59
|
+
const res = yield axios_1.default.post(config_1.API_URL + url, data, config);
|
|
60
|
+
return {
|
|
61
|
+
success: true,
|
|
62
|
+
status: res.status,
|
|
63
|
+
data: res.data,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
return {
|
|
68
|
+
success: false,
|
|
69
|
+
status: e.response.status,
|
|
70
|
+
error: e,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
let httpClient = new HttpClientImpl();
|
|
77
|
+
exports.default = httpClient;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.passwordPrompt = exports.prompt = void 0;
|
|
16
|
+
const consola_1 = __importDefault(require("consola"));
|
|
17
|
+
const prompts_1 = require("@clack/prompts");
|
|
18
|
+
/**
|
|
19
|
+
* This is a workaround for the issue with consola.prompt not detecting command cancellation.
|
|
20
|
+
*
|
|
21
|
+
* @see https://github.com/unjs/consola/issues/251#issuecomment-1810269084
|
|
22
|
+
*/
|
|
23
|
+
const prompt = (message, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const response = yield consola_1.default.prompt(message, options);
|
|
25
|
+
if (response && response.toString() === 'Symbol(clack:cancel)') {
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
return response;
|
|
29
|
+
});
|
|
30
|
+
exports.prompt = prompt;
|
|
31
|
+
/**
|
|
32
|
+
* This is a workaround to support password prompts.
|
|
33
|
+
*
|
|
34
|
+
* @see https://github.com/unjs/consola/issues/285
|
|
35
|
+
*/
|
|
36
|
+
const passwordPrompt = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
const result = yield (0, prompts_1.password)({ message });
|
|
38
|
+
if (typeof result === 'symbol') {
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
});
|
|
43
|
+
exports.passwordPrompt = passwordPrompt;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const rc9_1 = require("rc9");
|
|
4
|
+
class UserConfigImpl {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.file = '.capawesome';
|
|
7
|
+
}
|
|
8
|
+
read() {
|
|
9
|
+
return (0, rc9_1.readUser)({ name: this.file });
|
|
10
|
+
}
|
|
11
|
+
write(config) {
|
|
12
|
+
(0, rc9_1.writeUser)(config, { name: this.file });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const userConfig = new UserConfigImpl();
|
|
16
|
+
exports.default = userConfig;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const archiver_1 = __importDefault(require("archiver"));
|
|
16
|
+
class ZipImpl {
|
|
17
|
+
zipFolder(sourceFolder) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const archive = (0, archiver_1.default)('zip', { zlib: { level: 9 } });
|
|
21
|
+
const buffers = [];
|
|
22
|
+
archive.on('data', (data) => buffers.push(data));
|
|
23
|
+
archive.on('error', (err) => reject(err));
|
|
24
|
+
archive.on('end', () => resolve(Buffer.concat(buffers)));
|
|
25
|
+
archive.directory(sourceFolder, false);
|
|
26
|
+
archive.finalize();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
isZipped(path) {
|
|
31
|
+
return path.endsWith('.zip');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const zip = new ZipImpl();
|
|
35
|
+
exports.default = zip;
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@capawesome/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "The Capawesome Cloud Command Line Interface (CLI) to manage Live Updates and more.",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "rimraf ./dist && tsc",
|
|
7
|
+
"start": "npm run build && node ./dist/index.js",
|
|
8
|
+
"lint": "npm run prettier -- --check",
|
|
9
|
+
"fmt": "npm run prettier -- --write",
|
|
10
|
+
"prettier": "prettier \"**/*.{css,html,ts,js}\"",
|
|
11
|
+
"prepublishOnly": "npm run build",
|
|
12
|
+
"release": "commit-and-tag-version"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"capawesome": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"capawesome",
|
|
19
|
+
"cli",
|
|
20
|
+
"capacitor"
|
|
21
|
+
],
|
|
22
|
+
"author": "Robin Genz <mail@robingenz.dev>",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/capawesome-team/cli.git"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/capawesome-team/cli/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://capawesome.io/",
|
|
32
|
+
"funding": [
|
|
33
|
+
{
|
|
34
|
+
"type": "github",
|
|
35
|
+
"url": "https://github.com/sponsors/capawesome-team/"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"type": "opencollective",
|
|
39
|
+
"url": "https://opencollective.com/capawesome"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@clack/prompts": "0.7.0",
|
|
44
|
+
"archiver": "7.0.1",
|
|
45
|
+
"axios": "1.6.8",
|
|
46
|
+
"citty": "0.1.6",
|
|
47
|
+
"consola": "3.2.3",
|
|
48
|
+
"form-data": "4.0.0",
|
|
49
|
+
"rc9": "2.1.1"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@ionic/prettier-config": "4.0.0",
|
|
53
|
+
"@types/archiver": "6.0.2",
|
|
54
|
+
"@types/node": "20.11.30",
|
|
55
|
+
"commit-and-tag-version": "12.4.0",
|
|
56
|
+
"prettier": "3.2.5",
|
|
57
|
+
"rimraf": "5.0.5",
|
|
58
|
+
"typescript": "5.4.3"
|
|
59
|
+
},
|
|
60
|
+
"prettier": "@ionic/prettier-config"
|
|
61
|
+
}
|