vite-plugin-zephyr 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +11 -0
- package/package.json +17 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +8 -0
- package/src/index.js.map +1 -0
- package/src/lib/load_extra_files_from_dist.d.ts +7 -0
- package/src/lib/load_extra_files_from_dist.js +39 -0
- package/src/lib/load_extra_files_from_dist.js.map +1 -0
- package/src/lib/load_public_dir.d.ts +7 -0
- package/src/lib/load_public_dir.js +40 -0
- package/src/lib/load_public_dir.js.map +1 -0
- package/src/lib/load_static_entries.d.ts +7 -0
- package/src/lib/load_static_entries.js +44 -0
- package/src/lib/load_static_entries.js.map +1 -0
- package/src/lib/vite-plugin-zephyr-partial.d.ts +10 -0
- package/src/lib/vite-plugin-zephyr-partial.js +164 -0
- package/src/lib/vite-plugin-zephyr-partial.js.map +1 -0
- package/src/lib/vite-plugin-zephyr.d.ts +9 -0
- package/src/lib/vite-plugin-zephyr.js +212 -0
- package/src/lib/vite-plugin-zephyr.js.map +1 -0
- package/src/lib/zephyr-internal-options.d.ts +7 -0
- package/src/lib/zephyr-internal-options.js +3 -0
- package/src/lib/zephyr-internal-options.js.map +1 -0
package/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# vite-plugin-zephyr
|
2
|
+
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
4
|
+
|
5
|
+
## Building
|
6
|
+
|
7
|
+
Run `nx build vite-plugin-zephyr` to build the library.
|
8
|
+
|
9
|
+
## Running unit tests
|
10
|
+
|
11
|
+
Run `nx test vite-plugin-zephyr` to execute the unit tests via [Jest](https://jestjs.io).
|
package/package.json
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"name": "vite-plugin-zephyr",
|
3
|
+
"version": "0.0.12",
|
4
|
+
"license": "Apache-2.0",
|
5
|
+
"dependencies": {
|
6
|
+
"vite": "^5",
|
7
|
+
"rollup": "^4",
|
8
|
+
"is-ci": "^3.0.1",
|
9
|
+
"zephyr-edge-contract": "^0.0.12",
|
10
|
+
"zephyr-agent": "^0.0.12"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"@types/is-ci": "^3.0.4"
|
14
|
+
},
|
15
|
+
"main": "./src/index.js",
|
16
|
+
"type": "commonjs"
|
17
|
+
}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.withZephyrPartial = exports.withZephyr = void 0;
|
4
|
+
var vite_plugin_zephyr_1 = require("./lib/vite-plugin-zephyr");
|
5
|
+
Object.defineProperty(exports, "withZephyr", { enumerable: true, get: function () { return vite_plugin_zephyr_1.withZephyr; } });
|
6
|
+
var vite_plugin_zephyr_partial_1 = require("./lib/vite-plugin-zephyr-partial");
|
7
|
+
Object.defineProperty(exports, "withZephyrPartial", { enumerable: true, get: function () { return vite_plugin_zephyr_partial_1.withZephyrPartial; } });
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/vite-plugin-zephyr/src/index.ts"],"names":[],"mappings":";;;AAAA,+DAAsD;AAA7C,gHAAA,UAAU,OAAA;AACnB,+EAAqE;AAA5D,+HAAA,iBAAiB,OAAA"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { OutputAsset, OutputBundle } from 'rollup';
|
2
|
+
interface LoadExtraFilesFromDistOptions {
|
3
|
+
root: string;
|
4
|
+
bundle: OutputBundle;
|
5
|
+
}
|
6
|
+
export declare function load_extra_files_from_dist(props: LoadExtraFilesFromDistOptions): Promise<OutputAsset[]>;
|
7
|
+
export {};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.load_extra_files_from_dist = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const node_path_1 = require("node:path");
|
6
|
+
const node_fs_1 = require("node:fs");
|
7
|
+
const vite_1 = require("vite");
|
8
|
+
const node_util_1 = require("node:util");
|
9
|
+
function load_extra_files_from_dist(props) {
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
11
|
+
const { root, bundle } = props;
|
12
|
+
const publicAssets = [];
|
13
|
+
const root_dist_dir = (0, node_path_1.resolve)(root, 'dist');
|
14
|
+
const loadDir = (destDir) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
15
|
+
for (const file of (0, node_fs_1.readdirSync)(destDir)) {
|
16
|
+
const destFile = (0, node_path_1.resolve)(destDir, file);
|
17
|
+
const stat = (0, node_fs_1.statSync)(destFile);
|
18
|
+
if (stat.isDirectory()) {
|
19
|
+
yield loadDir(destFile);
|
20
|
+
continue;
|
21
|
+
}
|
22
|
+
const fileName = (0, vite_1.normalizePath)((0, node_path_1.relative)(root_dist_dir, destFile));
|
23
|
+
if (!(fileName in bundle)) {
|
24
|
+
publicAssets.push({
|
25
|
+
fileName,
|
26
|
+
name: file,
|
27
|
+
needsCodeReference: false,
|
28
|
+
source: yield (0, node_util_1.promisify)(node_fs_1.readFile)(destFile),
|
29
|
+
type: 'asset',
|
30
|
+
});
|
31
|
+
}
|
32
|
+
}
|
33
|
+
});
|
34
|
+
yield loadDir(root_dist_dir);
|
35
|
+
return publicAssets;
|
36
|
+
});
|
37
|
+
}
|
38
|
+
exports.load_extra_files_from_dist = load_extra_files_from_dist;
|
39
|
+
//# sourceMappingURL=load_extra_files_from_dist.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"load_extra_files_from_dist.js","sourceRoot":"","sources":["../../../../../libs/vite-plugin-zephyr/src/lib/load_extra_files_from_dist.ts"],"names":[],"mappings":";;;;AACA,yCAA8C;AAC9C,qCAA0D;AAC1D,+BAAqC;AACrC,yCAAsC;AAOtC,SAAsB,0BAA0B,CAC9C,KAAoC;;QAEpC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAC/B,MAAM,YAAY,GAAkB,EAAE,CAAC;QAEvC,MAAM,aAAa,GAAG,IAAA,mBAAO,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC5C,MAAM,OAAO,GAAG,CAAO,OAAe,EAAE,EAAE;YACxC,KAAK,MAAM,IAAI,IAAI,IAAA,qBAAW,EAAC,OAAO,CAAC,EAAE,CAAC;gBACxC,MAAM,QAAQ,GAAG,IAAA,mBAAO,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBACxC,MAAM,IAAI,GAAG,IAAA,kBAAQ,EAAC,QAAQ,CAAC,CAAC;gBAChC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;oBACvB,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;oBACxB,SAAS;gBACX,CAAC;gBACD,MAAM,QAAQ,GAAG,IAAA,oBAAa,EAAC,IAAA,oBAAQ,EAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAClE,IAAI,CAAC,CAAC,QAAQ,IAAI,MAAM,CAAC,EAAE,CAAC;oBAC1B,YAAY,CAAC,IAAI,CAAC;wBAChB,QAAQ;wBACR,IAAI,EAAE,IAAI;wBACV,kBAAkB,EAAE,KAAK;wBACzB,MAAM,EAAE,MAAM,IAAA,qBAAS,EAAC,kBAAQ,CAAC,CAAC,QAAQ,CAAC;wBAC3C,IAAI,EAAE,OAAO;qBACd,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC,CAAA,CAAC;QACF,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;QAE7B,OAAO,YAAY,CAAC;IACtB,CAAC;CAAA;AA9BD,gEA8BC"}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.load_public_dir = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const node_fs_1 = require("node:fs");
|
6
|
+
const node_path_1 = require("node:path");
|
7
|
+
const vite_1 = require("vite");
|
8
|
+
const node_util_1 = require("node:util");
|
9
|
+
function load_public_dir(props) {
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
11
|
+
const { publicDir, outDir } = props;
|
12
|
+
const publicAssets = [];
|
13
|
+
const loadDir = (srcDir, destDir) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
14
|
+
for (const file of (0, node_fs_1.readdirSync)(srcDir)) {
|
15
|
+
const srcFile = (0, node_path_1.resolve)(srcDir, file);
|
16
|
+
if (srcFile === destDir) {
|
17
|
+
continue;
|
18
|
+
}
|
19
|
+
const destFile = (0, node_path_1.resolve)(destDir, file);
|
20
|
+
const stat = (0, node_fs_1.statSync)(srcFile);
|
21
|
+
if (stat.isDirectory()) {
|
22
|
+
loadDir(srcFile, destFile);
|
23
|
+
}
|
24
|
+
else {
|
25
|
+
publicAssets.push({
|
26
|
+
fileName: (0, vite_1.normalizePath)((0, node_path_1.relative)(outDir, destFile)),
|
27
|
+
name: (0, node_path_1.basename)(file),
|
28
|
+
needsCodeReference: false,
|
29
|
+
source: yield (0, node_util_1.promisify)(node_fs_1.readFile)(srcFile),
|
30
|
+
type: 'asset',
|
31
|
+
});
|
32
|
+
}
|
33
|
+
}
|
34
|
+
});
|
35
|
+
yield loadDir(publicDir, outDir);
|
36
|
+
return publicAssets;
|
37
|
+
});
|
38
|
+
}
|
39
|
+
exports.load_public_dir = load_public_dir;
|
40
|
+
//# sourceMappingURL=load_public_dir.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"load_public_dir.js","sourceRoot":"","sources":["../../../../../libs/vite-plugin-zephyr/src/lib/load_public_dir.ts"],"names":[],"mappings":";;;;AACA,qCAA0D;AAC1D,yCAAwD;AACxD,+BAAqC;AACrC,yCAAsC;AAOtC,SAAsB,eAAe,CACnC,KAA2B;;QAE3B,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QACpC,MAAM,YAAY,GAAkB,EAAE,CAAC;QAEvC,MAAM,OAAO,GAAG,CAAO,MAAc,EAAE,OAAe,EAAE,EAAE;YACxD,KAAK,MAAM,IAAI,IAAI,IAAA,qBAAW,EAAC,MAAM,CAAC,EAAE,CAAC;gBACvC,MAAM,OAAO,GAAG,IAAA,mBAAO,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBACtC,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;oBACxB,SAAS;gBACX,CAAC;gBACD,MAAM,QAAQ,GAAG,IAAA,mBAAO,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBACxC,MAAM,IAAI,GAAG,IAAA,kBAAQ,EAAC,OAAO,CAAC,CAAC;gBAC/B,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;oBACvB,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;gBAC7B,CAAC;qBAAM,CAAC;oBACN,YAAY,CAAC,IAAI,CAAC;wBAChB,QAAQ,EAAE,IAAA,oBAAa,EAAC,IAAA,oBAAQ,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;wBACnD,IAAI,EAAE,IAAA,oBAAQ,EAAC,IAAI,CAAC;wBACpB,kBAAkB,EAAE,KAAK;wBACzB,MAAM,EAAE,MAAM,IAAA,qBAAS,EAAC,kBAAQ,CAAC,CAAC,OAAO,CAAC;wBAC1C,IAAI,EAAE,OAAO;qBACd,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC,CAAA,CAAC;QACF,MAAM,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACjC,OAAO,YAAY,CAAC;IACtB,CAAC;CAAA;AA7BD,0CA6BC"}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.load_static_entries = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const node_path_1 = require("node:path");
|
6
|
+
const node_fs_1 = require("node:fs");
|
7
|
+
const vite_1 = require("vite");
|
8
|
+
const node_util_1 = require("node:util");
|
9
|
+
const files_to_load = {
|
10
|
+
'index.html': true,
|
11
|
+
'404.html': true,
|
12
|
+
'q-data.json': true,
|
13
|
+
};
|
14
|
+
function load_static_entries(props) {
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
16
|
+
const { root, bundle } = props;
|
17
|
+
const publicAssets = [];
|
18
|
+
const root_dist_dir = (0, node_path_1.resolve)(root, 'dist');
|
19
|
+
const loadDir = (destDir) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
20
|
+
for (const file of (0, node_fs_1.readdirSync)(destDir)) {
|
21
|
+
const destFile = (0, node_path_1.resolve)(destDir, file);
|
22
|
+
const stat = (0, node_fs_1.statSync)(destFile);
|
23
|
+
if (stat.isDirectory()) {
|
24
|
+
yield loadDir(destFile);
|
25
|
+
continue;
|
26
|
+
}
|
27
|
+
const fileName = (0, vite_1.normalizePath)((0, node_path_1.relative)(root_dist_dir, destFile));
|
28
|
+
if (files_to_load[file]) {
|
29
|
+
publicAssets.push({
|
30
|
+
fileName,
|
31
|
+
name: file,
|
32
|
+
needsCodeReference: false,
|
33
|
+
source: yield (0, node_util_1.promisify)(node_fs_1.readFile)(destFile),
|
34
|
+
type: 'asset',
|
35
|
+
});
|
36
|
+
}
|
37
|
+
}
|
38
|
+
});
|
39
|
+
yield loadDir(root_dist_dir);
|
40
|
+
return publicAssets;
|
41
|
+
});
|
42
|
+
}
|
43
|
+
exports.load_static_entries = load_static_entries;
|
44
|
+
//# sourceMappingURL=load_static_entries.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"load_static_entries.js","sourceRoot":"","sources":["../../../../../libs/vite-plugin-zephyr/src/lib/load_static_entries.ts"],"names":[],"mappings":";;;;AACA,yCAA8C;AAC9C,qCAA0D;AAC1D,+BAAqC;AACrC,yCAAsC;AAOtC,MAAM,aAAa,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
|
+
import { ResolvedConfig } from 'vite';
|
2
|
+
import { NormalizedOutputOptions, OutputBundle } from 'rollup';
|
3
|
+
export declare function withZephyrPartial(): {
|
4
|
+
name: string;
|
5
|
+
apply: string;
|
6
|
+
enforce: string;
|
7
|
+
configResolved: (config: ResolvedConfig) => Promise<void>;
|
8
|
+
writeBundle: (options: NormalizedOutputOptions, _bundle: OutputBundle) => Promise<void>;
|
9
|
+
closeBundle: () => Promise<void>;
|
10
|
+
};
|
@@ -0,0 +1,164 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.withZephyrPartial = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const isCI = require("is-ci");
|
6
|
+
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
7
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
8
|
+
const load_public_dir_1 = require("./load_public_dir");
|
9
|
+
const load_extra_files_from_dist_1 = require("./load_extra_files_from_dist");
|
10
|
+
function withZephyrPartial() {
|
11
|
+
let bundle = {};
|
12
|
+
const vite_internal_options = {};
|
13
|
+
return {
|
14
|
+
name: 'with-zephyr-partial',
|
15
|
+
apply: 'build',
|
16
|
+
enforce: 'post',
|
17
|
+
configResolved: (config) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
18
|
+
Object.assign(vite_internal_options, {
|
19
|
+
root: config.root,
|
20
|
+
configFile: config.configFile,
|
21
|
+
outDir: config.build.outDir,
|
22
|
+
publicDir: config.publicDir,
|
23
|
+
});
|
24
|
+
}),
|
25
|
+
writeBundle: (options, _bundle) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
26
|
+
vite_internal_options.dir = options.dir;
|
27
|
+
bundle = _bundle;
|
28
|
+
}),
|
29
|
+
closeBundle: () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
30
|
+
const publicAssets = [];
|
31
|
+
if (vite_internal_options.publicDir) {
|
32
|
+
const _public_assets = yield (0, load_public_dir_1.load_public_dir)({
|
33
|
+
outDir: vite_internal_options.outDir,
|
34
|
+
publicDir: vite_internal_options.publicDir,
|
35
|
+
});
|
36
|
+
publicAssets.push(..._public_assets);
|
37
|
+
}
|
38
|
+
const _extra_assets = yield (0, load_extra_files_from_dist_1.load_extra_files_from_dist)({
|
39
|
+
root: vite_internal_options.root,
|
40
|
+
bundle,
|
41
|
+
});
|
42
|
+
publicAssets.push(..._extra_assets);
|
43
|
+
const assets = Object.assign({}, bundle, ...publicAssets.map((asset) => ({ [asset.fileName]: asset })));
|
44
|
+
yield _zephyr_partial({ assets, vite_internal_options });
|
45
|
+
}),
|
46
|
+
};
|
47
|
+
}
|
48
|
+
exports.withZephyrPartial = withZephyrPartial;
|
49
|
+
function _zephyr_partial(options) {
|
50
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
51
|
+
var _a;
|
52
|
+
const { assets, vite_internal_options } = options;
|
53
|
+
const path_to_execution_dir = vite_internal_options.root;
|
54
|
+
(0, zephyr_edge_contract_1.ze_log)('Configuring with Zephyr');
|
55
|
+
const packageJson = (0, zephyr_agent_1.getPackageJson)(path_to_execution_dir);
|
56
|
+
(0, zephyr_edge_contract_1.ze_log)('Loaded Package JSON', packageJson);
|
57
|
+
if (!packageJson)
|
58
|
+
return (0, zephyr_edge_contract_1.ze_error)('Could not find package json');
|
59
|
+
const gitInfo = (0, zephyr_agent_1.getGitInfo)();
|
60
|
+
(0, zephyr_edge_contract_1.ze_log)('Loaded Git Info', gitInfo);
|
61
|
+
if (!gitInfo ||
|
62
|
+
!(gitInfo === null || gitInfo === void 0 ? void 0 : gitInfo.app.org) ||
|
63
|
+
!(gitInfo === null || gitInfo === void 0 ? void 0 : gitInfo.app.project) ||
|
64
|
+
!(packageJson === null || packageJson === void 0 ? void 0 : packageJson.name))
|
65
|
+
return (0, zephyr_edge_contract_1.ze_error)('Could not get git info');
|
66
|
+
const application_uid = (0, zephyr_edge_contract_1.createFullAppName)({
|
67
|
+
org: gitInfo.app.org,
|
68
|
+
project: gitInfo.app.project,
|
69
|
+
name: packageJson === null || packageJson === void 0 ? void 0 : packageJson.name,
|
70
|
+
});
|
71
|
+
(0, zephyr_edge_contract_1.ze_log)('Going to check auth token or get it');
|
72
|
+
yield (0, zephyr_agent_1.checkAuth)();
|
73
|
+
(0, zephyr_edge_contract_1.ze_log)('Got auth token, going to get application configuration');
|
74
|
+
const { username, email, EDGE_URL } = yield (0, zephyr_agent_1.getApplicationConfiguration)({
|
75
|
+
application_uid,
|
76
|
+
});
|
77
|
+
(0, zephyr_edge_contract_1.ze_log)('Got application configuration', { username, email, EDGE_URL });
|
78
|
+
(0, zephyr_edge_contract_1.ze_log)('Going to get build id');
|
79
|
+
const buildId = yield (0, zephyr_agent_1.getBuildId)(application_uid).catch((err) => {
|
80
|
+
logEvent({
|
81
|
+
level: 'error',
|
82
|
+
action: 'build:get-build-id:error',
|
83
|
+
message: `error receiving build number for '${email}'\n
|
84
|
+
${err.message}\n`,
|
85
|
+
});
|
86
|
+
});
|
87
|
+
if (!buildId)
|
88
|
+
return (0, zephyr_edge_contract_1.ze_error)('[zephyr]: Could not get build id');
|
89
|
+
const pluginOptions = {
|
90
|
+
pluginName: 'rollup-plugin-zephyr',
|
91
|
+
application_uid,
|
92
|
+
buildEnv: 'local',
|
93
|
+
username,
|
94
|
+
app: {
|
95
|
+
name: packageJson.name,
|
96
|
+
version: packageJson.version,
|
97
|
+
org: gitInfo.app.org,
|
98
|
+
project: gitInfo.app.project,
|
99
|
+
},
|
100
|
+
git: gitInfo === null || gitInfo === void 0 ? void 0 : gitInfo.git,
|
101
|
+
isCI,
|
102
|
+
zeConfig: {
|
103
|
+
user: username,
|
104
|
+
edge_url: EDGE_URL,
|
105
|
+
buildId,
|
106
|
+
},
|
107
|
+
mfConfig: void 0,
|
108
|
+
};
|
109
|
+
(0, zephyr_edge_contract_1.ze_log)('zephyr agent started.');
|
110
|
+
const logEvent = (0, zephyr_agent_1.logger)(pluginOptions);
|
111
|
+
const zeStart = Date.now();
|
112
|
+
const extractBuffer = (asset) => {
|
113
|
+
switch (asset.type) {
|
114
|
+
case 'chunk':
|
115
|
+
return asset.code;
|
116
|
+
case 'asset':
|
117
|
+
return typeof asset.source === 'string'
|
118
|
+
? asset.source
|
119
|
+
: new TextDecoder().decode(asset.source);
|
120
|
+
default:
|
121
|
+
return void 0;
|
122
|
+
}
|
123
|
+
};
|
124
|
+
const getAssetType = (asset) => asset.type;
|
125
|
+
const assetsMap = Object.keys(assets).reduce((memo, filepath) => {
|
126
|
+
const asset = assets[filepath];
|
127
|
+
const buffer = extractBuffer(asset);
|
128
|
+
if (!buffer && buffer !== '') {
|
129
|
+
logEvent({
|
130
|
+
action: 'ze:build:assets:unknown-asset-type',
|
131
|
+
level: 'error',
|
132
|
+
message: `unknown asset type: ${getAssetType(asset)}`,
|
133
|
+
});
|
134
|
+
return memo;
|
135
|
+
}
|
136
|
+
const assetMap = (0, zephyr_agent_1.getZeBuildAsset)({ filepath, content: buffer });
|
137
|
+
memo[assetMap.hash] = assetMap;
|
138
|
+
return memo;
|
139
|
+
}, {});
|
140
|
+
const snapshot = (0, zephyr_agent_1.createSnapshot)({
|
141
|
+
options: pluginOptions,
|
142
|
+
assets: assetsMap,
|
143
|
+
username,
|
144
|
+
email,
|
145
|
+
});
|
146
|
+
const missingAssets = yield (0, zephyr_agent_1.zeUploadSnapshot)(pluginOptions, snapshot).catch((err) => (0, zephyr_edge_contract_1.ze_error)('Failed to upload snapshot.', err));
|
147
|
+
if (typeof missingAssets === 'undefined')
|
148
|
+
return (0, zephyr_edge_contract_1.ze_error)('Snapshot upload gave no result, exiting');
|
149
|
+
const assetsUploadSuccess = yield (0, zephyr_agent_1.zeUploadAssets)(pluginOptions, {
|
150
|
+
missingAssets,
|
151
|
+
assetsMap,
|
152
|
+
count: Object.keys(assets).length,
|
153
|
+
});
|
154
|
+
if (!assetsUploadSuccess)
|
155
|
+
return (0, zephyr_edge_contract_1.ze_error)('Failed to upload assets.', assetsUploadSuccess);
|
156
|
+
yield (0, zephyr_edge_contract_1.savePartialAssetMap)(application_uid, (_a = vite_internal_options.configFile) !== null && _a !== void 0 ? _a : 'partial', assetsMap);
|
157
|
+
logEvent({
|
158
|
+
level: 'info',
|
159
|
+
action: 'build:deploy:done',
|
160
|
+
message: `build deployed in ${Date.now() - zeStart}ms`,
|
161
|
+
});
|
162
|
+
});
|
163
|
+
}
|
164
|
+
//# sourceMappingURL=vite-plugin-zephyr-partial.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"vite-plugin-zephyr-partial.js","sourceRoot":"","sources":["../../../../../libs/vite-plugin-zephyr/src/lib/vite-plugin-zephyr-partial.ts"],"names":[],"mappings":";;;;AAOA,8BAA8B;AAE9B,+DAM8B;AAC9B,+CAWsB;AAEtB,uDAAoD;AACpD,6EAA0E;AAG1E,SAAgB,iBAAiB;IAC/B,IAAI,MAAM,GAAiB,EAAE,CAAC;IAC9B,MAAM,qBAAqB,GAAG,EAA2B,CAAC;IAE1D,OAAO;QACL,IAAI,EAAE,qBAAqB;QAC3B,KAAK,EAAE,OAAO;QACd,OAAO,EAAE,MAAM;QACf,cAAc,EAAE,CAAO,MAAsB,EAAE,EAAE;YAC/C,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE;gBACnC,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;gBAC3B,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;QACL,CAAC,CAAA;QAED,WAAW,EAAE,CACX,OAAgC,EAChC,OAAqB,EACrB,EAAE;YACF,qBAAqB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;YACxC,MAAM,GAAG,OAAO,CAAC;QACnB,CAAC,CAAA;QAED,WAAW,EAAE,GAAS,EAAE;YACtB,MAAM,YAAY,GAAkB,EAAE,CAAC;YAEvC,IAAI,qB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AM,CAAC,CAAC,MAAM;SAClC,CAAC,CAAC;QAEH,IAAI,CAAC,mBAAmB;YACtB,OAAO,IAAA,+BAAQ,EAAC,0BAA0B,EAAE,mBAAmB,CAAC,CAAC;QAEnE,MAAM,IAAA,0CAAmB,EACvB,eAAe,EACf,MAAA,qBAAqB,CAAC,UAAU,mCAAI,SAAS,EAC7C,SAAS,CACV,CAAC;QAEF,QAAQ,CAAC;YACP,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,mBAAmB;YAC3B,OAAO,EAAE,qBAAqB,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,IAAI;SACvD,CAAC,CAAC;IACL,CAAC;CAAA"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { NormalizedOutputOptions, OutputBundle } from 'rollup';
|
2
|
+
import { ResolvedConfig } from 'vite';
|
3
|
+
export declare function withZephyr(): {
|
4
|
+
name: string;
|
5
|
+
enforce: string;
|
6
|
+
configResolved: (config: ResolvedConfig) => Promise<void>;
|
7
|
+
writeBundle: (options: NormalizedOutputOptions, _bundle: OutputBundle) => Promise<void>;
|
8
|
+
closeBundle: () => Promise<void>;
|
9
|
+
};
|
@@ -0,0 +1,212 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.withZephyr = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const isCI = require("is-ci");
|
6
|
+
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
7
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
8
|
+
const load_static_entries_1 = require("./load_static_entries");
|
9
|
+
function withZephyr() {
|
10
|
+
// todo: set correctly
|
11
|
+
let bundle = {};
|
12
|
+
const vite_internal_options = {};
|
13
|
+
return {
|
14
|
+
name: 'with-zephyr',
|
15
|
+
enforce: 'post',
|
16
|
+
configResolved: (config) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
17
|
+
Object.assign(vite_internal_options, {
|
18
|
+
root: config.root,
|
19
|
+
configFile: config.configFile,
|
20
|
+
outDir: config.build.outDir,
|
21
|
+
publicDir: config.publicDir,
|
22
|
+
});
|
23
|
+
}),
|
24
|
+
writeBundle: (options, _bundle) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
25
|
+
bundle = _bundle;
|
26
|
+
}),
|
27
|
+
closeBundle: () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
28
|
+
const publicAssets = [];
|
29
|
+
const _static_assets = yield (0, load_static_entries_1.load_static_entries)({
|
30
|
+
root: vite_internal_options.root,
|
31
|
+
bundle,
|
32
|
+
});
|
33
|
+
publicAssets.push(..._static_assets);
|
34
|
+
const assets = Object.assign({}, bundle, ...publicAssets.map((asset) => ({ [asset.fileName]: asset })));
|
35
|
+
yield _zephyr({ assets, vite_internal_options });
|
36
|
+
}),
|
37
|
+
};
|
38
|
+
}
|
39
|
+
exports.withZephyr = withZephyr;
|
40
|
+
function _zephyr(options) {
|
41
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
42
|
+
const { assets, vite_internal_options } = options;
|
43
|
+
const path_to_execution_dir = vite_internal_options.root;
|
44
|
+
(0, zephyr_edge_contract_1.ze_log)('Configuring with Zephyr');
|
45
|
+
const packageJson = (0, zephyr_agent_1.getPackageJson)(path_to_execution_dir);
|
46
|
+
(0, zephyr_edge_contract_1.ze_log)('Loaded Package JSON', packageJson);
|
47
|
+
if (!packageJson)
|
48
|
+
return (0, zephyr_edge_contract_1.ze_error)('Could not find package json');
|
49
|
+
const gitInfo = (0, zephyr_agent_1.getGitInfo)();
|
50
|
+
(0, zephyr_edge_contract_1.ze_log)('Loaded Git Info', gitInfo);
|
51
|
+
if (!gitInfo ||
|
52
|
+
!(gitInfo === null || gitInfo === void 0 ? void 0 : gitInfo.app.org) ||
|
53
|
+
!(gitInfo === null || gitInfo === void 0 ? void 0 : gitInfo.app.project) ||
|
54
|
+
!(packageJson === null || packageJson === void 0 ? void 0 : packageJson.name))
|
55
|
+
return (0, zephyr_edge_contract_1.ze_error)('Could not get git info');
|
56
|
+
const application_uid = (0, zephyr_edge_contract_1.createFullAppName)({
|
57
|
+
org: gitInfo.app.org,
|
58
|
+
project: gitInfo.app.project,
|
59
|
+
name: packageJson === null || packageJson === void 0 ? void 0 : packageJson.name,
|
60
|
+
});
|
61
|
+
(0, zephyr_edge_contract_1.ze_log)('Going to check auth token or get it');
|
62
|
+
yield (0, zephyr_agent_1.checkAuth)();
|
63
|
+
(0, zephyr_edge_contract_1.ze_log)('Got auth token, going to get application configuration');
|
64
|
+
const { username, email, EDGE_URL } = yield (0, zephyr_agent_1.getApplicationConfiguration)({
|
65
|
+
application_uid,
|
66
|
+
});
|
67
|
+
(0, zephyr_edge_contract_1.ze_log)('Got application configuration', { username, email, EDGE_URL });
|
68
|
+
(0, zephyr_edge_contract_1.ze_log)('Going to get build id');
|
69
|
+
const buildId = yield (0, zephyr_agent_1.getBuildId)(application_uid).catch((err) => {
|
70
|
+
logEvent({
|
71
|
+
level: 'error',
|
72
|
+
action: 'build:get-build-id:error',
|
73
|
+
message: `error receiving build number for '${email}'\n
|
74
|
+
${err.message}\n`,
|
75
|
+
});
|
76
|
+
});
|
77
|
+
if (!buildId)
|
78
|
+
return (0, zephyr_edge_contract_1.ze_error)('[zephyr]: Could not get build id');
|
79
|
+
const pluginOptions = {
|
80
|
+
pluginName: 'rollup-plugin-zephyr',
|
81
|
+
application_uid,
|
82
|
+
buildEnv: 'local',
|
83
|
+
username,
|
84
|
+
app: {
|
85
|
+
name: packageJson.name,
|
86
|
+
version: packageJson.version,
|
87
|
+
org: gitInfo.app.org,
|
88
|
+
project: gitInfo.app.project,
|
89
|
+
},
|
90
|
+
git: gitInfo === null || gitInfo === void 0 ? void 0 : gitInfo.git,
|
91
|
+
isCI,
|
92
|
+
zeConfig: {
|
93
|
+
user: username,
|
94
|
+
edge_url: EDGE_URL,
|
95
|
+
buildId,
|
96
|
+
},
|
97
|
+
mfConfig: void 0,
|
98
|
+
};
|
99
|
+
(0, zephyr_edge_contract_1.ze_log)('zephyr agent started.');
|
100
|
+
const logEvent = (0, zephyr_agent_1.logger)(pluginOptions);
|
101
|
+
const zeStart = Date.now();
|
102
|
+
const extractBuffer = (asset) => {
|
103
|
+
switch (asset.type) {
|
104
|
+
case 'chunk':
|
105
|
+
return asset.code;
|
106
|
+
case 'asset':
|
107
|
+
return typeof asset.source === 'string'
|
108
|
+
? asset.source
|
109
|
+
: new TextDecoder().decode(asset.source);
|
110
|
+
default:
|
111
|
+
return void 0;
|
112
|
+
}
|
113
|
+
};
|
114
|
+
const getAssetType = (asset) => asset.type;
|
115
|
+
const assetsMap = Object.keys(assets).reduce((memo, filepath) => {
|
116
|
+
const asset = assets[filepath];
|
117
|
+
const buffer = extractBuffer(asset);
|
118
|
+
if (!buffer) {
|
119
|
+
logEvent({
|
120
|
+
action: 'ze:build:assets:unknown-asset-type',
|
121
|
+
level: 'error',
|
122
|
+
message: `unknown asset type: ${getAssetType(asset)}`,
|
123
|
+
});
|
124
|
+
1;
|
125
|
+
return memo;
|
126
|
+
}
|
127
|
+
const assetMap = (0, zephyr_agent_1.getZeBuildAsset)({ filepath, content: buffer });
|
128
|
+
memo[assetMap.hash] = assetMap;
|
129
|
+
return memo;
|
130
|
+
}, {});
|
131
|
+
const partialAssetMap = yield (0, zephyr_edge_contract_1.getPartialAssetMap)(application_uid);
|
132
|
+
yield (0, zephyr_edge_contract_1.removePartialAssetMap)(application_uid);
|
133
|
+
const snapshot = (0, zephyr_agent_1.createSnapshot)({
|
134
|
+
options: pluginOptions,
|
135
|
+
assets: Object.assign({}, assetsMap, ...Object.values(partialAssetMap !== null && partialAssetMap !== void 0 ? partialAssetMap : {})),
|
136
|
+
username,
|
137
|
+
email,
|
138
|
+
});
|
139
|
+
const missingAssets = yield (0, zephyr_agent_1.zeUploadSnapshot)(pluginOptions, snapshot).catch((err) => (0, zephyr_edge_contract_1.ze_error)('Failed to upload snapshot.', err));
|
140
|
+
if (typeof missingAssets === 'undefined')
|
141
|
+
return (0, zephyr_edge_contract_1.ze_error)('Snapshot upload gave no result, exiting');
|
142
|
+
const assetsUploadSuccess = yield (0, zephyr_agent_1.zeUploadAssets)(pluginOptions, {
|
143
|
+
missingAssets,
|
144
|
+
assetsMap,
|
145
|
+
count: Object.keys(assets).length,
|
146
|
+
});
|
147
|
+
if (!assetsUploadSuccess)
|
148
|
+
return (0, zephyr_edge_contract_1.ze_error)('Failed to upload assets.', assetsUploadSuccess);
|
149
|
+
const version = (0, zephyr_edge_contract_1.createSnapshotId)(pluginOptions);
|
150
|
+
const dashData = {
|
151
|
+
id: pluginOptions.application_uid,
|
152
|
+
name: packageJson.name,
|
153
|
+
// name: pluginOptions.mfConfig?.name,
|
154
|
+
edge: { url: EDGE_URL },
|
155
|
+
app: Object.assign({}, pluginOptions.app, {
|
156
|
+
buildId: pluginOptions.zeConfig.buildId,
|
157
|
+
}),
|
158
|
+
version,
|
159
|
+
git: pluginOptions.git,
|
160
|
+
// remote: pluginOptions.mfConfig?.filename,
|
161
|
+
// remotes: Object.keys(pluginOptions.mfConfig?.remotes || {}),
|
162
|
+
context: {
|
163
|
+
isCI: pluginOptions.isCI,
|
164
|
+
},
|
165
|
+
dependencies: [],
|
166
|
+
devDependencies: [],
|
167
|
+
optionalDependencies: [],
|
168
|
+
metadata: {},
|
169
|
+
overrides: [
|
170
|
+
/* {
|
171
|
+
"id": "react-dom",
|
172
|
+
"name": "react-dom",
|
173
|
+
"version": "18.2.0",
|
174
|
+
"location": "react-dom",
|
175
|
+
"applicationID": "react-dom"
|
176
|
+
},
|
177
|
+
{
|
178
|
+
"id": "react",
|
179
|
+
"name": "react",
|
180
|
+
"version": "18.2.0",
|
181
|
+
"location": "react",
|
182
|
+
"applicationID": "react"
|
183
|
+
}*/
|
184
|
+
],
|
185
|
+
consumes: [],
|
186
|
+
modules: [
|
187
|
+
/* {
|
188
|
+
"id": "GreenRecos:GreenRecos",
|
189
|
+
"name": "GreenRecos",
|
190
|
+
"applicationID": "GreenRecos",
|
191
|
+
"requires": [
|
192
|
+
"react"
|
193
|
+
],
|
194
|
+
"file": "./src/app/team-green-recos.tsx"
|
195
|
+
}*/
|
196
|
+
],
|
197
|
+
sha: pluginOptions.git.commit,
|
198
|
+
// todo: @deprecate
|
199
|
+
buildHash: pluginOptions.git.commit,
|
200
|
+
};
|
201
|
+
const envs = yield (0, zephyr_agent_1.zeUploadBuildStats)(dashData);
|
202
|
+
if (!envs)
|
203
|
+
return (0, zephyr_edge_contract_1.ze_error)('Did not receive envs from build stats upload. Exiting.');
|
204
|
+
yield (0, zephyr_agent_1.zeEnableSnapshotOnEdge)(pluginOptions, snapshot, envs.value);
|
205
|
+
logEvent({
|
206
|
+
level: 'info',
|
207
|
+
action: 'build:deploy:done',
|
208
|
+
message: `build deployed in ${Date.now() - zeStart}ms`,
|
209
|
+
});
|
210
|
+
});
|
211
|
+
}
|
212
|
+
//# sourceMappingURL=vite-plugin-zephyr.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"vite-plugin-zephyr.js","sourceRoot":"","sources":["../../../../../libs/vite-plugin-zephyr/src/lib/vite-plugin-zephyr.ts"],"names":[],"mappings":";;;;AAMA,8BAA8B;AAG9B,+DAQ8B;AAC9B,+CAasB;AAEtB,+DAA4D;AAU5D,SAAgB,UAAU;IACxB,sBAAsB;IACtB,IAAI,MAAM,GAAiB,EAAE,CAAC;IAE9B,MAAM,qBAAqB,GAAG,EAAkC,CAAC;IAEjE,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,MAAM;QACf,cAAc,EAAE,CAAO,MAAsB,EAAE,EAAE;YAC/C,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE;gBACnC,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;gBAC3B,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;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,IAAI;YACP,OAAO,IAAA,+BAAQ,EAAC,wDAAwD,CAAC,CAAC;QAE5E,MAAM,IAAA,qCAAsB,EAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAElE,QAAQ,CAAC;YACP,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,mBAAmB;YAC3B,OAAO,EAAE,qBAAqB,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,IAAI;SACvD,CAAC,CAAC;IACL,CAAC;CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"zephyr-internal-options.js","sourceRoot":"","sources":["../../../../../libs/vite-plugin-zephyr/src/lib/zephyr-internal-options.ts"],"names":[],"mappings":""}
|