@gluestack-v2/framework-cli
Version:
Gluestack V2 Framework CLI
155 lines (154 loc) • 7.14 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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 __asyncValues = (this && this.__asyncValues) || function (o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
};
(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", "path"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importStar(require("path"));
class BaseGluestackPlugin {
constructor(app, gluePluginStore) {
this.type = 'stateless';
this.runningPlatforms = ['local', 'docker'];
this.pluginEnvironment = 'server';
this.app = app;
this.instances = [];
this.type = 'stateless';
this.gluePluginStore = gluePluginStore;
}
getType() {
return this.type;
}
prepare() {
var _a, e_1, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
const instances = this.getInstances();
try {
for (var _d = true, instances_1 = __asyncValues(instances), instances_1_1; instances_1_1 = yield instances_1.next(), _a = instances_1_1.done, !_a; _d = true) {
_c = instances_1_1.value;
_d = false;
const instance = _c;
yield instance.prepare();
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_d && !_a && (_b = instances_1.return)) yield _b.call(instances_1);
}
finally { if (e_1) throw e_1.error; }
}
});
}
getTemplateFolderPath() {
return (0, path_1.join)(this.getPackagePath(), 'template');
}
getPackagePath() {
const packageJSONPath = require.resolve(path_1.default.join(this.getName(), 'package.json'));
const packagePath = path_1.default.dirname(packageJSONPath);
return packagePath;
}
getInstallationPath(target) {
return (0, path_1.join)(target);
}
getInstances() {
return this.instances;
}
getPluginEnvironment() {
return this.pluginEnvironment;
}
build() {
var _a, e_2, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
const instances = this.getInstances();
try {
for (var _d = true, instances_2 = __asyncValues(instances), instances_2_1; instances_2_1 = yield instances_2.next(), _a = instances_2_1.done, !_a; _d = true) {
_c = instances_2_1.value;
_d = false;
const instance = _c;
yield instance.build();
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (!_d && !_a && (_b = instances_2.return)) yield _b.call(instances_2);
}
finally { if (e_2) throw e_2.error; }
}
});
}
watch(callback) {
var _a, e_3, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
const instances = this.getInstances();
try {
for (var _d = true, instances_3 = __asyncValues(instances), instances_3_1; instances_3_1 = yield instances_3.next(), _a = instances_3_1.done, !_a; _d = true) {
_c = instances_3_1.value;
_d = false;
const instance = _c;
if (instance.watch) {
yield instance.watch((event, path) => {
// use this for debuggin
if (callback) {
callback(event, path, this.pluginEnvironment);
}
});
}
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (!_d && !_a && (_b = instances_3.return)) yield _b.call(instances_3);
}
finally { if (e_3) throw e_3.error; }
}
});
}
}
exports.default = BaseGluestackPlugin;
});