@aurtic/cli 1.0.3 → 2.0.4

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.
Files changed (57) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +20 -0
  3. package/dist/app.controller.d.ts +6 -0
  4. package/dist/app.controller.js +35 -0
  5. package/dist/app.controller.js.map +1 -0
  6. package/dist/app.module.d.ts +2 -0
  7. package/dist/app.module.js +40 -0
  8. package/dist/app.module.js.map +1 -0
  9. package/dist/app.service.d.ts +3 -0
  10. package/dist/app.service.js +20 -0
  11. package/dist/app.service.js.map +1 -0
  12. package/dist/authentication/authentication.command.d.ts +9 -0
  13. package/dist/authentication/authentication.command.js +60 -0
  14. package/dist/authentication/authentication.command.js.map +1 -0
  15. package/dist/authentication/authentication.module.d.ts +2 -0
  16. package/dist/authentication/authentication.module.js +24 -0
  17. package/dist/authentication/authentication.module.js.map +1 -0
  18. package/dist/authentication/authentication.service.d.ts +10 -0
  19. package/dist/authentication/authentication.service.js +69 -0
  20. package/dist/authentication/authentication.service.js.map +1 -0
  21. package/dist/builds/builds.command.d.ts +12 -0
  22. package/dist/builds/builds.command.js +116 -0
  23. package/dist/builds/builds.command.js.map +1 -0
  24. package/dist/builds/builds.module.d.ts +2 -0
  25. package/dist/builds/builds.module.js +25 -0
  26. package/dist/builds/builds.module.js.map +1 -0
  27. package/dist/builds/builds.service.d.ts +17 -0
  28. package/dist/builds/builds.service.js +156 -0
  29. package/dist/builds/builds.service.js.map +1 -0
  30. package/dist/builds/builds.zip.service.d.ts +3 -0
  31. package/dist/builds/builds.zip.service.js +73 -0
  32. package/dist/builds/builds.zip.service.js.map +1 -0
  33. package/dist/github/github.module.d.ts +2 -0
  34. package/dist/github/github.module.js +21 -0
  35. package/dist/github/github.module.js.map +1 -0
  36. package/dist/github/github.service.d.ts +3 -0
  37. package/dist/github/github.service.js +25 -0
  38. package/dist/github/github.service.js.map +1 -0
  39. package/dist/main.js +10 -0
  40. package/dist/main.js.map +1 -0
  41. package/dist/tsconfig.build.tsbuildinfo +1 -0
  42. package/package.json +73 -24
  43. package/README +0 -29
  44. package/dist/api.d.ts +0 -14
  45. package/dist/api.js +0 -148
  46. package/dist/cli.js +0 -281
  47. package/dist/entities/Project.d.ts +0 -39
  48. package/dist/entities/Project.js +0 -124
  49. package/dist/entities/ProjectContainer.d.ts +0 -227
  50. package/dist/entities/ProjectContainer.js +0 -465
  51. package/dist/entities/Server.d.ts +0 -45
  52. package/dist/entities/Server.js +0 -114
  53. package/dist/entities/Team.d.ts +0 -49
  54. package/dist/entities/Team.js +0 -149
  55. package/dist/tsconfig.tsbuildinfo +0 -1
  56. package/tsconfig.json +0 -24
  57. /package/dist/{cli.d.ts → main.d.ts} +0 -0
package/package.json CHANGED
@@ -1,37 +1,86 @@
1
1
  {
2
2
  "name": "@aurtic/cli",
3
- "version": "1.0.3",
4
- "private": false,
3
+ "version": "2.0.4",
5
4
  "description": "",
6
- "bin": "./dist/cli.js",
5
+ "author": "",
6
+ "private": false,
7
+ "license": "UNLICENSED",
8
+ "bin": "dist/main.js",
7
9
  "files": [
8
10
  "dist",
9
- "tsconfig.json"
11
+ ".env"
10
12
  ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/Aurtic/CLI"
16
+ },
11
17
  "scripts": {
12
- "test": "echo \"Error: no test specified\" && exit 1",
13
- "build": "tsc --outDir dist",
14
- "copy": "rm -r ./src/entities && cp -r ../next/src/entities ./src/entities"
18
+ "build": "nest build",
19
+ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
20
+ "start": "nest start",
21
+ "start:dev": "nest start --watch",
22
+ "start:debug": "nest start --debug --watch",
23
+ "start:prod": "node dist/main",
24
+ "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
25
+ "test": "jest",
26
+ "test:watch": "jest --watch",
27
+ "test:cov": "jest --coverage",
28
+ "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
29
+ "test:e2e": "jest --config ./test/jest-e2e.json"
15
30
  },
16
- "author": "",
17
- "license": "ISC",
18
31
  "dependencies": {
19
- "adm-zip": "^0.5.9",
20
- "chalk": "^4.1.2",
21
- "chalk-animation": "^2.0.3",
22
- "dotenv": "^8.6.0",
23
- "dotenv-expand": "^10.0.0",
24
- "gradient": "^0.2.0",
25
- "inquirer": "^8.2.5",
26
- "nanospinner": "^1.1.0",
27
- "node-fetch": "^2.6.9",
28
- "open": "^8.4.0"
32
+ "@actions/core": "^2.0.1",
33
+ "@nestjs/common": "^11.0.1",
34
+ "@nestjs/config": "^4.0.2",
35
+ "@nestjs/core": "^11.0.1",
36
+ "@nestjs/platform-express": "^11.0.1",
37
+ "ignore": "^7.0.5",
38
+ "jszip": "^3.10.1",
39
+ "nest-commander": "^3.20.1",
40
+ "node-fetch": "^3.3.2",
41
+ "reflect-metadata": "^0.2.2",
42
+ "rxjs": "^7.8.1"
29
43
  },
30
44
  "devDependencies": {
31
- "@types/adm-zip": "^0.5.0",
32
- "@types/inquirer": "^9.0.3",
33
- "@types/node": "^18.11.10",
34
- "@types/node-fetch": "^2.6.2",
35
- "typescript": "^4.9.3"
45
+ "@eslint/eslintrc": "^3.2.0",
46
+ "@eslint/js": "^9.18.0",
47
+ "@nestjs/cli": "^11.0.0",
48
+ "@nestjs/schematics": "^11.0.0",
49
+ "@nestjs/testing": "^11.0.1",
50
+ "@types/express": "^5.0.0",
51
+ "@types/jest": "^30.0.0",
52
+ "@types/node": "^22.10.7",
53
+ "@types/supertest": "^6.0.2",
54
+ "eslint": "^9.18.0",
55
+ "eslint-config-prettier": "^10.0.1",
56
+ "eslint-plugin-prettier": "^5.2.2",
57
+ "globals": "^16.0.0",
58
+ "jest": "^30.0.0",
59
+ "prettier": "^3.4.2",
60
+ "source-map-support": "^0.5.21",
61
+ "supertest": "^7.0.0",
62
+ "ts-jest": "^29.2.5",
63
+ "ts-loader": "^9.5.2",
64
+ "ts-node": "^10.9.2",
65
+ "tsconfig-paths": "^4.2.0",
66
+ "typescript": "^5.7.3",
67
+ "typescript-eslint": "^8.20.0"
68
+ },
69
+ "jest": {
70
+ "moduleFileExtensions": [
71
+ "js",
72
+ "json",
73
+ "ts"
74
+ ],
75
+ "rootDir": "src",
76
+ "testRegex": ".*\\.spec\\.ts$",
77
+ "transform": {
78
+ "^.+\\.(t|j)s$": "ts-jest"
79
+ },
80
+ "collectCoverageFrom": [
81
+ "**/*.(t|j)s"
82
+ ],
83
+ "coverageDirectory": "../coverage",
84
+ "testEnvironment": "node"
36
85
  }
37
86
  }
package/README DELETED
@@ -1,29 +0,0 @@
1
- # Aurtic CLI how-to
2
- Welcome to Aurtic CLI - a command line interface tool designed to simplify the deployment of your docker applications and provide secure login functionality to your servers.
3
-
4
- With Aurtic CLI, you can easily deploy your docker applications to your server with just a few simple commands. You can also easily manage your containers, and deployments using the CLI. Additionally, Aurtic CLI provides secure login functionality, so you can easily access your servers with a simple authentication process.
5
-
6
- This tool is designed to make the deployment process as simple as possible, regardless of your level of technical expertise. Whether you are a seasoned developer or new to docker, Aurtic CLI will make it easy for you to deploy your applications in a fast, reliable, and secure way.
7
-
8
-
9
- ## Login into your Aurtic account
10
- To push/ pull deployments from your Aurtic account you need to
11
-
12
- ```bash
13
- npx @aurtic/cli login
14
- ```
15
-
16
- ## Deploy applications using aurtic
17
- 1. Install the `@aurtic/cli` package
18
- ```bash
19
- npm install -g @aurtic/cli
20
- ```
21
- 2. First you need to login into your Aurtic account
22
- ```bash
23
- npx @aurtic/cli login
24
- ```
25
- 3. Deploy your applicaiton
26
- ```bash
27
- npx @aurtic/cli container projectId containerId deploy [path] [--verbose | -v]
28
- ```
29
- 4. Use the given link to follow the process, you will be notified if the build succeeds or not. You can also use the `--verbose` option to follow the process in the terminal.
package/dist/api.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { BodyInit, RequestInit } from "node-fetch";
2
- type JSON = string | number | boolean | {
3
- [index: string]: JSON;
4
- } | JSON[];
5
- type APIRequestInit = Omit<RequestInit, 'body' | 'headers'> & {
6
- body?: BodyInit | JSON;
7
- headers?: {
8
- [index: string]: string;
9
- };
10
- };
11
- export declare const authRequest: (url: URL | string, init?: APIRequestInit) => Promise<import("node-fetch").Response>;
12
- export declare const mapClass: <T, B>(obj: new (params: B) => T, data: B[]) => T[];
13
- export declare const request: (url: URL | string, init?: APIRequestInit) => Promise<import("node-fetch").Response>;
14
- export {};
package/dist/api.js DELETED
@@ -1,148 +0,0 @@
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __values = (this && this.__values) || function(o) {
39
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
- if (m) return m.call(o);
41
- if (o && typeof o.length === "number") return {
42
- next: function () {
43
- if (o && i >= o.length) o = void 0;
44
- return { value: o && o[i++], done: !o };
45
- }
46
- };
47
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
- };
49
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
- Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.request = exports.mapClass = exports.authRequest = void 0;
54
- var node_fetch_1 = __importDefault(require("node-fetch"));
55
- var fs_1 = __importDefault(require("fs"));
56
- var os_1 = __importDefault(require("os"));
57
- var homedir = os_1.default.homedir();
58
- var accessToken = null;
59
- var authRequest = function (url, init) {
60
- if (init === void 0) { init = {}; }
61
- return __awaiter(void 0, void 0, void 0, function () {
62
- var file, json, request_1, result;
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
65
- case 0:
66
- if (!!accessToken) return [3 /*break*/, 3];
67
- file = fs_1.default.readFileSync(homedir + "/.aurtic.json").toString();
68
- if (!file)
69
- throw "Please first use @aurtic/cli login";
70
- json = JSON.parse(file);
71
- if (!json['access_token'])
72
- throw "Invalid access token";
73
- accessToken = json['access_token'];
74
- return [4 /*yield*/, (0, node_fetch_1.default)("https://api.aurtic.com/v1/users/@me", {
75
- headers: {
76
- 'Authorization': 'Bearer ' + accessToken,
77
- }
78
- })];
79
- case 1:
80
- request_1 = _a.sent();
81
- return [4 /*yield*/, request_1.json()];
82
- case 2:
83
- result = _a.sent();
84
- if (result['error']) {
85
- throw "Please first use @aurtic/cli login";
86
- }
87
- else {
88
- accessToken = json['access_token'];
89
- }
90
- _a.label = 3;
91
- case 3:
92
- if (!init.headers)
93
- init.headers = {};
94
- init.headers = init.headers;
95
- init.headers['Authorization'] = "Bearer ".concat(accessToken);
96
- return [4 /*yield*/, (0, exports.request)(url, init)];
97
- case 4: return [2 /*return*/, _a.sent()];
98
- }
99
- });
100
- });
101
- };
102
- exports.authRequest = authRequest;
103
- var mapClass = function (obj, data) {
104
- var e_1, _a;
105
- var result = [];
106
- try {
107
- for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
108
- var entry = data_1_1.value;
109
- result.push(new obj(entry));
110
- }
111
- }
112
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
113
- finally {
114
- try {
115
- if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
116
- }
117
- finally { if (e_1) throw e_1.error; }
118
- }
119
- return result;
120
- };
121
- exports.mapClass = mapClass;
122
- var request = function (url, init) {
123
- if (init === void 0) { init = {}; }
124
- return __awaiter(void 0, void 0, void 0, function () {
125
- var res;
126
- return __generator(this, function (_a) {
127
- switch (_a.label) {
128
- case 0:
129
- if (!init.headers)
130
- init.headers = {};
131
- if (typeof init.body !== 'undefined' && 'string') {
132
- init.body = JSON.stringify(init.body);
133
- init.headers['Content-Type'] = 'application/json';
134
- }
135
- if (typeof url === 'string') {
136
- if (!url.startsWith("http")) {
137
- url = "https://api.aurtic.com".concat(url);
138
- }
139
- }
140
- return [4 /*yield*/, (0, node_fetch_1.default)(url, init)];
141
- case 1:
142
- res = _a.sent();
143
- return [2 /*return*/, res];
144
- }
145
- });
146
- });
147
- };
148
- exports.request = request;
package/dist/cli.js DELETED
@@ -1,281 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- var __generator = (this && this.__generator) || function (thisArg, body) {
13
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
- function verb(n) { return function (v) { return step([n, v]); }; }
16
- function step(op) {
17
- if (f) throw new TypeError("Generator is already executing.");
18
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
19
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20
- if (y = 0, t) op = [op[0] & 2, t.value];
21
- switch (op[0]) {
22
- case 0: case 1: t = op; break;
23
- case 4: _.label++; return { value: op[1], done: false };
24
- case 5: _.label++; y = op[1]; op = [0]; continue;
25
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
- default:
27
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
- if (t[2]) _.ops.pop();
32
- _.trys.pop(); continue;
33
- }
34
- op = body.call(thisArg, _);
35
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
- }
38
- };
39
- var __values = (this && this.__values) || function(o) {
40
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
41
- if (m) return m.call(o);
42
- if (o && typeof o.length === "number") return {
43
- next: function () {
44
- if (o && i >= o.length) o = void 0;
45
- return { value: o && o[i++], done: !o };
46
- }
47
- };
48
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
49
- };
50
- var __importDefault = (this && this.__importDefault) || function (mod) {
51
- return (mod && mod.__esModule) ? mod : { "default": mod };
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- var dotenv_1 = __importDefault(require("dotenv"));
55
- var dotenv_expand_1 = __importDefault(require("dotenv-expand"));
56
- var env = dotenv_1.default.config();
57
- dotenv_expand_1.default.expand(env);
58
- var path_1 = __importDefault(require("path"));
59
- var fs_1 = __importDefault(require("fs"));
60
- var os_1 = __importDefault(require("os"));
61
- var inquirer_1 = __importDefault(require("inquirer"));
62
- var node_fetch_1 = __importDefault(require("node-fetch"));
63
- var nanospinner_1 = require("nanospinner");
64
- var adm_zip_1 = __importDefault(require("adm-zip"));
65
- var ProjectContainer_1 = __importDefault(require("./entities/ProjectContainer"));
66
- var Project_1 = __importDefault(require("./entities/Project"));
67
- var chalk_1 = __importDefault(require("chalk"));
68
- var recursivelyCreateBuild = function (basePath, ePath, zip, ignore) {
69
- var e_1, _a;
70
- var files = fs_1.default.readdirSync(path_1.default.join(basePath, ePath));
71
- try {
72
- for (var files_1 = __values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) {
73
- var file = files_1_1.value;
74
- var lstat = fs_1.default.lstatSync(path_1.default.join(basePath, ePath, file));
75
- if (ignore.includes(path_1.default.join(ePath, file))) {
76
- continue;
77
- }
78
- if (!lstat.isFile()) {
79
- recursivelyCreateBuild(basePath, path_1.default.join(ePath, file), zip, ignore);
80
- }
81
- else {
82
- zip.addFile(path_1.default.join(ePath, file), fs_1.default.readFileSync(path_1.default.join(basePath, ePath, file)));
83
- }
84
- }
85
- }
86
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
87
- finally {
88
- try {
89
- if (files_1_1 && !files_1_1.done && (_a = files_1.return)) _a.call(files_1);
90
- }
91
- finally { if (e_1) throw e_1.error; }
92
- }
93
- };
94
- (function () { return __awaiter(void 0, void 0, void 0, function () {
95
- var e_2;
96
- return __generator(this, function (_a) {
97
- switch (_a.label) {
98
- case 0:
99
- _a.trys.push([0, 2, , 3]);
100
- return [4 /*yield*/, (function () { return __awaiter(void 0, void 0, void 0, function () {
101
- var args, command, _a, homedir, prompt, result, spinner, request, json, projectId, containerId, project, container, _b;
102
- return __generator(this, function (_c) {
103
- switch (_c.label) {
104
- case 0:
105
- args = process.argv;
106
- args.shift();
107
- args.shift();
108
- command = args.shift();
109
- _a = command;
110
- switch (_a) {
111
- case 'login': return [3 /*break*/, 1];
112
- case 'container': return [3 /*break*/, 5];
113
- }
114
- return [3 /*break*/, 10];
115
- case 1:
116
- homedir = os_1.default.homedir();
117
- prompt = inquirer_1.default.createPromptModule();
118
- return [4 /*yield*/, prompt([
119
- {
120
- name: 'email',
121
- message: "Email",
122
- type: 'text'
123
- },
124
- {
125
- name: 'password',
126
- message: "Password",
127
- type: 'password'
128
- }
129
- ])];
130
- case 2:
131
- result = _c.sent();
132
- spinner = (0, nanospinner_1.createSpinner)("Logging in...").start();
133
- return [4 /*yield*/, (0, node_fetch_1.default)("https://api.aurtic.com/v1/users/login", {
134
- method: 'POST',
135
- headers: {
136
- 'Content-Type': 'application/json',
137
- },
138
- body: JSON.stringify(result),
139
- })];
140
- case 3:
141
- request = _c.sent();
142
- return [4 /*yield*/, request.json()];
143
- case 4:
144
- json = _c.sent();
145
- if (json['error']) {
146
- spinner.error({
147
- text: json['error_description'] || json['error'],
148
- });
149
- return [2 /*return*/, process.exit(1)];
150
- }
151
- fs_1.default.writeFileSync(homedir + "/.aurtic.json", JSON.stringify(json));
152
- spinner.success({
153
- text: 'Successfully logged in!',
154
- });
155
- return [3 /*break*/, 11];
156
- case 5:
157
- projectId = args.shift();
158
- containerId = args.shift();
159
- return [4 /*yield*/, Project_1.default.get(projectId)];
160
- case 6:
161
- project = _c.sent();
162
- return [4 /*yield*/, ProjectContainer_1.default.get(project, containerId)];
163
- case 7:
164
- container = _c.sent();
165
- _b = args.shift();
166
- switch (_b) {
167
- case 'deploy': return [3 /*break*/, 8];
168
- }
169
- return [3 /*break*/, 10];
170
- case 8: return [4 /*yield*/, deploy(args, container, project)];
171
- case 9:
172
- _c.sent();
173
- _c.label = 10;
174
- case 10:
175
- {
176
- console.error(chalk_1.default.blue.bgRed.bold('Could not find command: ' + command, ', please see the README for more info!'));
177
- process.exit(1);
178
- }
179
- _c.label = 11;
180
- case 11:
181
- process.exit(0);
182
- return [2 /*return*/];
183
- }
184
- });
185
- }); })()];
186
- case 1:
187
- _a.sent();
188
- return [3 /*break*/, 3];
189
- case 2:
190
- e_2 = _a.sent();
191
- console.error(e_2);
192
- process.exit(1);
193
- return [3 /*break*/, 3];
194
- case 3: return [2 /*return*/];
195
- }
196
- });
197
- }); })();
198
- function deploy(args, container, project) {
199
- return __awaiter(this, void 0, void 0, function () {
200
- var spinner, options, requestedPath, resultPath, zip, cloudIgnorePath, cloudIgnore, data, base64, deployment, deployDeployment, result, e_3;
201
- var _this = this;
202
- return __generator(this, function (_a) {
203
- switch (_a.label) {
204
- case 0:
205
- spinner = (0, nanospinner_1.createSpinner)("Deploying: ".concat(project.name, " / ").concat(container.name)).start();
206
- options = {
207
- verbose: false,
208
- };
209
- if (args.includes("--verbose") || args.includes("-v"))
210
- options.verbose = true;
211
- requestedPath = args.shift();
212
- spinner.update({ text: "Optimizing build...", });
213
- resultPath = path_1.default.resolve(!requestedPath ? path_1.default.join(process.cwd(), './') : requestedPath);
214
- zip = new adm_zip_1.default();
215
- cloudIgnorePath = path_1.default.join(resultPath, ".dockerignore");
216
- cloudIgnore = fs_1.default.existsSync(cloudIgnorePath) ? fs_1.default.readFileSync(cloudIgnorePath).toString() : "";
217
- recursivelyCreateBuild(resultPath, "", zip, cloudIgnore.split("\n"));
218
- return [4 /*yield*/, zip.toBufferPromise()];
219
- case 1:
220
- data = _a.sent();
221
- base64 = data.toString('base64');
222
- spinner.update({ text: "Uploading build...", });
223
- return [4 /*yield*/, ProjectContainer_1.default.createDeployment(container, {
224
- data: base64
225
- })];
226
- case 2:
227
- deployment = _a.sent();
228
- return [4 /*yield*/, ProjectContainer_1.default.buildDeployment(deployment)];
229
- case 3:
230
- deployDeployment = _a.sent();
231
- if (!options.verbose) {
232
- spinner.success({ text: "Successfully created the deployment! Tagged with id: ".concat(deployment.id, " Visit https://www.aurtic.com/dashboard/projects/").concat(project.id, "/containers/").concat(container.id, "/deployments/").concat(deployment.id, " for more information.") });
233
- process.exit(0);
234
- }
235
- spinner.update({ text: "Deploying build...", });
236
- _a.label = 4;
237
- case 4:
238
- _a.trys.push([4, 6, , 7]);
239
- return [4 /*yield*/, new Promise(function (resolve, reject) {
240
- var index = 0;
241
- var interval = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
242
- var state;
243
- return __generator(this, function (_a) {
244
- switch (_a.label) {
245
- case 0: return [4 /*yield*/, ProjectContainer_1.default.getDeploymentBuildStatus(deployment)];
246
- case 1:
247
- state = _a.sent();
248
- for (index; index < state.data.logs.length; index++) {
249
- spinner.update({
250
- text: state.data.logs[index],
251
- });
252
- }
253
- if (state.finished) {
254
- clearInterval(interval);
255
- if (state.result) {
256
- resolve(state.data.logs.join("\n"));
257
- }
258
- else {
259
- reject(state.data.logs.concat(state.data.errors).join("\n"));
260
- }
261
- }
262
- return [2 /*return*/];
263
- }
264
- });
265
- }); }, 5000);
266
- })];
267
- case 5:
268
- result = _a.sent();
269
- spinner.success({ text: "Successfully created the deployment! Tagged with id: ".concat(deployment.id, " Visit https://www.aurtic.com/dashboard/projects/").concat(project.id, "/containers/").concat(container.id, "/deployments/").concat(deployment.id, " for more information.") });
270
- return [3 /*break*/, 7];
271
- case 6:
272
- e_3 = _a.sent();
273
- spinner.error({
274
- text: e_3 + "\nSuccessfully created the build! Tagged with id: \" + deployment.id + ' Visit https://www.aurtic.com/dashboard/projects/".concat(project.id, "/containers/").concat(container.id, "/deployments/").concat(deployment.id, " for more information.")
275
- });
276
- return [3 /*break*/, 7];
277
- case 7: return [2 /*return*/];
278
- }
279
- });
280
- });
281
- }
@@ -1,39 +0,0 @@
1
- import { ITeam } from "./Team";
2
- export interface IProject {
3
- readonly id: string;
4
- name: string;
5
- readonly services: {
6
- containers: number;
7
- archives: number;
8
- databases: number;
9
- 'content-delivery-networks': number;
10
- };
11
- readonly _links: {
12
- [index: string]: {
13
- href: string;
14
- type: string;
15
- };
16
- };
17
- }
18
- export interface IProjectService {
19
- readonly id: string;
20
- readonly type: 'container' | 'archive';
21
- readonly name: string;
22
- }
23
- export declare const create: ({ name, team }: {
24
- name: string;
25
- team: ITeam;
26
- }) => Promise<IProject>;
27
- export declare const get: (id: string) => Promise<IProject>;
28
- export declare const all: () => Promise<IProject[]>;
29
- export declare const getServices: (project: IProject) => Promise<IProjectService[]>;
30
- declare const Project: {
31
- all: () => Promise<IProject[]>;
32
- get: (id: string) => Promise<IProject>;
33
- create: ({ name, team }: {
34
- name: string;
35
- team: ITeam;
36
- }) => Promise<IProject>;
37
- getServices: (project: IProject) => Promise<IProjectService[]>;
38
- };
39
- export default Project;