Skip to content

Feat/deploy #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
05b6447
chore: updated publish scripts
freakstreak Jun 30, 2023
a1fecb3
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jun 30, 2023
de9a1b9
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jun 30, 2023
e22eb5b
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jun 30, 2023
74277b8
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jun 30, 2023
561a8e1
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jun 30, 2023
b222f5e
chore: fixed logs and added .boltignore when busing bolt init
freakstreak Jun 30, 2023
e3643fd
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jun 30, 2023
c947f92
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jul 3, 2023
0ade57f
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jul 5, 2023
0bfb3a7
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jul 5, 2023
471e017
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jul 5, 2023
f8c67d4
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jul 5, 2023
17e2b9a
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jul 5, 2023
1aa0ef1
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jul 6, 2023
66a84c7
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jul 6, 2023
52d972e
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Jul 26, 2023
d7b476e
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Aug 1, 2023
a2d78da
chore: updated envs fixes
freakstreak Aug 1, 2023
d719658
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Aug 2, 2023
64d06a2
chore: fixed env management and removed env and route:generate command
freakstreak Aug 2, 2023
1a589b9
chore: removed unnecessary import
freakstreak Aug 2, 2023
24ea6b1
Merge branch 'main' of github.com:gluestack/bolt-framework
freakstreak Aug 3, 2023
b2fc441
chore: added deployment steps
freakstreak Jan 30, 2024
e055b24
chore: fixed route:generate
freakstreak Jan 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/bolt/build/actions/deploy/deploy.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ export default class DeployClass {
constructor();
setStore(): Promise<void>;
saveStore(): Promise<void>;
getSealContent(): Promise<import("../../typings/bolt").Bolt>;
getBoltFileContent(): Promise<import("../../typings/bolt").Bolt>;
setServices(): Promise<void>;
createZip(): Promise<string>;
auth(doAuth: boolean): Promise<void>;
upload(): Promise<void>;
auth(doAuth: boolean): Promise<{
user: any;
projects: any;
} | undefined>;
setProject(projects: any[]): Promise<any>;
upload(): Promise<any>;
submit({ projectId, fileId, userId, }: {
projectId: number;
fileId: number;
userId: number;
}): Promise<any>;
watch(): Promise<void>;
}
32 changes: 22 additions & 10 deletions packages/bolt/build/actions/deploy/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "../../helpers/get-store", "../../helpers/deploy/deploy", "../../common"], factory);
define(["require", "exports", "../../helpers/get-store", "../../helpers/deploy/deployment", "../../common"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const get_store_1 = __importDefault(require("../../helpers/get-store"));
const deploy_1 = require("../../helpers/deploy/deploy");
const deployment_1 = require("../../helpers/deploy/deployment");
const common_1 = __importDefault(require("../../common"));
class DeployClass {
constructor() {
Expand All @@ -48,7 +48,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
this.store.save();
});
}
getSealContent() {
getBoltFileContent() {
return __awaiter(this, void 0, void 0, function* () {
const _yamlContent = yield common_1.default.getAndValidateBoltYaml();
return _yamlContent;
Expand All @@ -59,7 +59,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
var _a, e_1, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
const services = this.services;
const _yamlContent = yield this.getSealContent();
const _yamlContent = yield this.getBoltFileContent();
try {
// Gather all the availables services
for (var _d = true, _e = __asyncValues(Object.entries(_yamlContent.services)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
Expand Down Expand Up @@ -89,28 +89,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
createZip() {
return __awaiter(this, void 0, void 0, function* () {
const cwd = this.cwd;
const { zipPath } = yield (0, deploy_1.zip)(cwd);
const { zipPath } = yield (0, deployment_1.zip)(cwd);
this.zipPath = zipPath;
return Promise.resolve(zipPath);
});
}
// Authenticates users credentials and
// stores the details into the project's store
auth(doAuth) {
return __awaiter(this, void 0, void 0, function* () {
yield (0, deploy_1.auth)(doAuth, this.store);
return yield (0, deployment_1.auth)(doAuth, this.store);
});
}
setProject(projects) {
return __awaiter(this, void 0, void 0, function* () {
return yield (0, deployment_1.setProject)(projects);
});
}
// uploads the zip into minio
upload() {
return __awaiter(this, void 0, void 0, function* () {
yield (0, deploy_1.upload)(this.zipPath, this.store);
return yield (0, deployment_1.upload)(this.zipPath, this.store);
});
}
submit({ projectId, fileId, userId, }) {
return __awaiter(this, void 0, void 0, function* () {
return yield (0, deployment_1.deploy)({
projectId,
fileId,
userId,
});
});
}
// watches the deployment steps
watch() {
return __awaiter(this, void 0, void 0, function* () {
yield (0, deploy_1.watch)(this.store);
yield (0, deployment_1.watch)(this.store);
});
}
}
Expand Down
42 changes: 26 additions & 16 deletions packages/bolt/build/actions/deploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
const route_generate_1 = __importDefault(require("../route-generate"));
const deploy_1 = __importDefault(require("./deploy"));
exports.default = (options, isWatch = false) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
// validate the project
console.log(">> Validating project...");
yield (0, validate_metadata_1.validateMetadata)();
yield (0, validate_services_1.validateServices)();
console.log(chalk_1.default.gray(">> Building Production Envs..."));
const envGenerate = new env_generate_1.default();
yield envGenerate.handle({ environment: "production" });
console.log(chalk_1.default.green(">> Production Envs built successfully!") + "\n");
const routeGenerate = new route_generate_1.default();
yield routeGenerate.handle(true);
return;
// validate the project
console.log(">> Validating project...");
yield (0, validate_metadata_1.validateMetadata)();
yield (0, validate_services_1.validateServices)();
console.log("\n> Note: Please remove any zip file or unnecessary files/folders from your project before deploying!");
console.log("\n> Deploying project...");
console.log("\n>> Note: Please remove any zip file or unnecessary files/folders from your project before deploying!");
console.log("\n>> Deploying project...");
const deploy = new deploy_1.default();
console.log("\n> Gathering all deployable services...");
console.log("\n>> Gathering all deployable services...");
// populate store
yield deploy.setStore();
// populate services
Expand All @@ -57,17 +58,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
yield deploy.createZip();
// authenticate the user & store creds in local store
console.log("\n>> Authenticating user credentials...");
yield deploy.auth(options.auth);
const authData = yield deploy.auth(options.auth);
console.log(">> Authentication successful!\n");
const projects = (authData === null || authData === void 0 ? void 0 : authData.projects) || [];
const selectedProject = yield deploy.setProject(projects);
// uploads the project zip file to minio
console.log(">> Uploading project zip file...");
yield deploy.upload();
const fileId = yield deploy.upload();
console.log(">> Project zip file uploaded successfully!\n");
// save store
yield deploy.saveStore();
if (isWatch) {
console.log(">> Fetching deployment details...\n");
yield deploy.watch();
}
console.log(">> Submitting the deployment now...");
const deployment = yield deploy.submit({
fileId,
projectId: selectedProject.id,
userId: (_a = authData === null || authData === void 0 ? void 0 : authData.user) === null || _a === void 0 ? void 0 : _a.id,
});
console.log(">> Deployment submitted successfully!\n");
// // save store
// await deploy.saveStore();
// if (isWatch) {
// console.log(">> Fetching deployment details...\n");
// await deploy.watch();
// }
});
});
4 changes: 3 additions & 1 deletion packages/bolt/build/actions/route-generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
yield (0, validate_services_1.validateServices)();
console.log(`>> Creating Ingress...`);
yield (0, generate_routes_1.default)(_yamlContent, isProd);
process.exit(0);
{
!isProd && process.exit(0);
}
});
}
}
Expand Down
9 changes: 3 additions & 6 deletions packages/bolt/build/commands/13-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "chalk"], factory);
define(["require", "exports", "../actions/deploy"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
// import deploy from "../actions/deploy";
const deploy_1 = __importDefault(require("../actions/deploy"));
exports.default = (program) => __awaiter(void 0, void 0, void 0, function* () {
program
.command("deploy")
.option("-a, --auth [true]", "Re-enter credentials, do not use presisted credentials from earlier", false)
.description("Prepares the compressed project & initiates the deployment")
.action((options) => {
console.log(chalk_1.default.green(">> Coming Soon..."));
process.exit();
// deploy(options, true);
(0, deploy_1.default)(options, true);
});
});
});
3 changes: 1 addition & 2 deletions packages/bolt/build/config/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/**
* SEAL server details
*/
export declare const SEAL_DOMAIN: string;
/**
* SEAL GQL service details
*/
export declare const SEAL_GQL: string;
export declare const BOX_SERVER_URL: string;
13 changes: 7 additions & 6 deletions packages/bolt/build/config/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* SEAL server details
*/
// export const SEAL_DOMAIN: string = "https://api.gluestack.io";
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
Expand All @@ -9,13 +13,10 @@
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SEAL_GQL = exports.SEAL_DOMAIN = void 0;
/**
* SEAL server details
*/
exports.SEAL_DOMAIN = 'https://api.gluestack.io';
exports.BOX_SERVER_URL = void 0;
/**
* SEAL GQL service details
*/
exports.SEAL_GQL = 'https://api.gluestack.io/backend/graphql';
// export const SEAL_GQL: string = "https://api.gluestack.io/backend/graphql";
exports.BOX_SERVER_URL = "http://localhost:8000/api";
});
7 changes: 7 additions & 0 deletions packages/bolt/build/helpers/deploy/apis/api-request.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export declare const apiRequest: ({ data, method, route, params, headers, }: {
data: any;
method: "GET" | "POST" | "PUT" | "DELETE";
route: string;
params?: any;
headers?: any;
}) => Promise<import("axios").AxiosResponse<any, any>>;
49 changes: 49 additions & 0 deletions packages/bolt/build/helpers/deploy/apis/api-request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "../../get-store-data", "axios", "../../../config"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.apiRequest = void 0;
const get_store_data_1 = require("../../get-store-data");
const axios_1 = __importDefault(require("axios"));
const config_1 = require("../../../config");
const apiRequest = ({ data, method, route, params, headers, }) => __awaiter(void 0, void 0, void 0, function* () {
const accessKey = yield (0, get_store_data_1.getStoreData)("access_key");
const secretKey = yield (0, get_store_data_1.getStoreData)("secret_key");
const requestHeaders = Object.assign({ ["Access-Key"]: accessKey, ["Secret-Key"]: secretKey }, headers);
params = params ? getParamString(params) : "";
const config = {
method: method,
url: `${config_1.BOX_SERVER_URL}/deployment${route}${params}`,
headers: requestHeaders,
data: data,
};
return yield axios_1.default.request(config);
});
exports.apiRequest = apiRequest;
const getParamString = (params) => {
let paramString = "?";
for (const [key, value] of Object.entries(params)) {
paramString += `${key}=${value}&`;
}
return paramString;
};
});
4 changes: 2 additions & 2 deletions packages/bolt/build/helpers/deploy/apis/client.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { GraphQLClient } from 'graphql-request';
import { GraphQLClient } from "graphql-request";
export declare const clientGQL: GraphQLClient;
export { request, gql } from 'graphql-request';
export { request, gql } from "graphql-request";
2 changes: 1 addition & 1 deletion packages/bolt/build/helpers/deploy/apis/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
exports.gql = exports.request = exports.clientGQL = void 0;
const graphql_request_1 = require("graphql-request");
const config_1 = require("../../../config");
exports.clientGQL = new graphql_request_1.GraphQLClient(config_1.SEAL_GQL);
exports.clientGQL = new graphql_request_1.GraphQLClient(config_1.BOX_SERVER_URL);
var graphql_request_2 = require("graphql-request");
Object.defineProperty(exports, "request", { enumerable: true, get: function () { return graphql_request_2.request; } });
Object.defineProperty(exports, "gql", { enumerable: true, get: function () { return graphql_request_2.gql; } });
Expand Down
72 changes: 0 additions & 72 deletions packages/bolt/build/helpers/deploy/deploy/auth.js

This file was deleted.

4 changes: 0 additions & 4 deletions packages/bolt/build/helpers/deploy/deploy/index.d.ts

This file was deleted.

Loading