zephyr-agent
Version:
Zephyr plugin agent
76 lines (75 loc) • 3.04 kB
JavaScript
;
var __webpack_require__ = {};
(()=>{
__webpack_require__.d = (exports1, getters, values)=>{
var define = (defs, kind)=>{
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
enumerable: true,
[kind]: defs[key]
});
};
define(getters, "get");
define(values, "value");
};
})();
(()=>{
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
__webpack_require__.r = (exports1)=>{
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
zeEnableSnapshotOnPages: ()=>zeEnableSnapshotOnPages
});
const get_application_configuration_js_namespaceObject = require("../edge-requests/get-application-configuration.js");
const index_js_namespaceObject = require("../errors/index.js");
const http_request_js_namespaceObject = require("../http/http-request.js");
const external_logging_index_js_namespaceObject = require("../logging/index.js");
async function zeEnableSnapshotOnPages({ pluginOptions: { application_uid }, envs_jwt, pages_url }) {
external_logging_index_js_namespaceObject.ze_log.snapshot('Enabling snapshot on cloudflare pages');
external_logging_index_js_namespaceObject.ze_log.snapshot(`Uploading envs to Zephyr, for ${application_uid}`);
const type = 'pages';
const json = JSON.stringify({
...envs_jwt,
pages_url
});
const { EDGE_URL, jwt } = await (0, get_application_configuration_js_namespaceObject.getApplicationConfiguration)({
application_uid
});
const [ok, cause] = await (0, http_request_js_namespaceObject.makeRequest)({
path: '/upload',
base: EDGE_URL,
query: {
type
}
}, {
method: 'POST',
headers: {
'Content-Length': Buffer.byteLength(json).toString(),
'Content-Type': 'application/json; charset=utf-8',
can_write_jwt: jwt
}
}, json);
if (!ok) throw new index_js_namespaceObject.ZephyrError(index_js_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
cause,
message: 'Failed to upload envs to Zephyr'
});
external_logging_index_js_namespaceObject.ze_log.snapshot('Build successfully deployed.');
}
exports.zeEnableSnapshotOnPages = __webpack_exports__.zeEnableSnapshotOnPages;
for(var __rspack_i in __webpack_exports__)if (-1 === [
"zeEnableSnapshotOnPages"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
value: true
});
//# sourceMappingURL=ze-enable-snapshot-on-pages.js.map