@gluestack-v2/glue-plugin-web
Version:
Gluestack V2 Web Plugin
72 lines (71 loc) • 3.54 kB
JavaScript
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", "path", "@gluestack-v2/framework-cli/build/plugin/BaseGluestackPluginInstance", "@gluestack-v2/framework-cli/build/helpers/file/rewrite-file"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PluginInstance = void 0;
const path_1 = require("path");
const BaseGluestackPluginInstance_1 = __importDefault(require("@gluestack-v2/framework-cli/build/plugin/BaseGluestackPluginInstance"));
const rewrite_file_1 = __importDefault(require("@gluestack-v2/framework-cli/build/helpers/file/rewrite-file"));
class PluginInstance extends BaseGluestackPluginInstance_1.default {
constructor(app, callerPlugin, name, gluePluginStore, installationPath) {
// @ts-ignore
super(app, callerPlugin, name, gluePluginStore, installationPath);
}
init() {
//
}
destroy() {
//
}
updateNextConfig() {
return __awaiter(this, void 0, void 0, function* () {
yield (0, rewrite_file_1.default)((0, path_1.join)(this._destinationPath, 'next.config.js'), this._sourcePath, 'SOURCEPATH');
});
}
build() {
return __awaiter(this, void 0, void 0, function* () {
yield this.app.write(this._sourcePath, this._destinationPath);
yield this.updateWorkspacePackageJSON();
yield this.boltInit();
// await this.app.updateServices();
yield this.generateEnvFiles();
// // update next.config.js context for error mapping
// await this.updateNextConfig();
});
}
watch(callback) {
return __awaiter(this, void 0, void 0, function* () {
yield this.buildBeforeWatch();
yield this.app.watch(this._sourcePath, this._destinationPath, (events, path) => __awaiter(this, void 0, void 0, function* () {
if (path === 'next.config.js') {
// update next.config.js context for error mapping
yield this.updateNextConfig();
}
if (callback) {
callback(events, path);
}
}));
});
}
}
exports.PluginInstance = PluginInstance;
});