rollup-plugin-zephyr 0.0.0-canary-20241116123955

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,39 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ ...
13
+
14
+ END OF TERMS AND CONDITIONS
15
+
16
+ APPENDIX: How to apply the Apache License to your work.
17
+
18
+ To apply the Apache License to your work, attach the following
19
+ boilerplate notice, with the fields enclosed by brackets "[]"
20
+ replaced with your own identifying information. (Don't include
21
+ the brackets!) The text should be enclosed in the appropriate
22
+ comment syntax for the file format. We also recommend that a
23
+ file or class name and description of purpose be included on the
24
+ same line as the copyright notice for each file. The "copyright"
25
+ word should be left as is (without quotes).
26
+
27
+ Copyright [2023] [Zephyr Cloud]
28
+
29
+ Licensed under the Apache License, Version 2.0 (the "License");
30
+ you may not use this file except in compliance with the License.
31
+ You may obtain a copy of the License at
32
+
33
+ http://www.apache.org/licenses/LICENSE-2.0
34
+
35
+ Unless required by applicable law or agreed to in writing, software
36
+ distributed under the License is distributed on an "AS IS" BASIS,
37
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
38
+ See the License for the specific language governing permissions and
39
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # rollup-plugin-zephyr
@@ -0,0 +1 @@
1
+ export { withZephyr } from './lib/rollup-plugin-zephyr';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withZephyr = void 0;
4
+ var rollup_plugin_zephyr_1 = require("./lib/rollup-plugin-zephyr");
5
+ Object.defineProperty(exports, "withZephyr", { enumerable: true, get: function () { return rollup_plugin_zephyr_1.withZephyr; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mEAAwD;AAA/C,kHAAA,UAAU,OAAA"}
@@ -0,0 +1,6 @@
1
+ import type { InputOptions, NormalizedOutputOptions, OutputBundle } from 'rollup';
2
+ export declare function withZephyr(): {
3
+ name: string;
4
+ buildStart: (options: InputOptions) => Promise<void>;
5
+ writeBundle: (options: NormalizedOutputOptions, bundle: OutputBundle) => Promise<void>;
6
+ };
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withZephyr = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const isCI = tslib_1.__importStar(require("is-ci"));
6
+ const zephyr_agent_1 = require("zephyr-agent");
7
+ const zephyr_edge_contract_1 = require("zephyr-edge-contract");
8
+ const get_assets_map_1 = require("./utils/get-assets-map");
9
+ const get_dash_data_1 = require("./utils/get-dash-data");
10
+ const getInputFolder = (options) => {
11
+ if (typeof options.input === 'string')
12
+ return options.input;
13
+ if (Array.isArray(options.input))
14
+ return options.input[0];
15
+ if (typeof options.input === 'object')
16
+ return Object.values(options.input)[0];
17
+ return process.cwd();
18
+ };
19
+ function withZephyr() {
20
+ let _state;
21
+ return {
22
+ name: 'with-zephyr',
23
+ buildStart: async (options) => {
24
+ _state = (async function zephyr_init() {
25
+ (0, zephyr_edge_contract_1.ze_log)('Setting up zephyr agent configuration.');
26
+ const _zephyrOptions = { wait_for_index_html: false };
27
+ const path_to_execution_dir = getInputFolder(options);
28
+ const [packageJson, gitInfo] = await Promise.all([(0, zephyr_agent_1.getPackageJson)(path_to_execution_dir), (0, zephyr_agent_1.getGitInfo)()]);
29
+ const application_uid = (0, zephyr_edge_contract_1.createApplicationUID)({
30
+ org: gitInfo.app.org,
31
+ project: gitInfo.app.project,
32
+ name: packageJson.name,
33
+ });
34
+ await (0, zephyr_agent_1.checkAuth)();
35
+ const [appConfig, buildId, hash_set] = await Promise.all([
36
+ (0, zephyr_agent_1.getApplicationConfiguration)({ application_uid }),
37
+ (0, zephyr_agent_1.getBuildId)(application_uid),
38
+ (0, zephyr_agent_1.get_hash_list)(application_uid),
39
+ ]);
40
+ const { username, email, EDGE_URL } = appConfig;
41
+ (0, zephyr_edge_contract_1.ze_log)('Got application configuration: ', {
42
+ username,
43
+ email,
44
+ EDGE_URL,
45
+ });
46
+ if (!buildId)
47
+ return (0, zephyr_edge_contract_1.ze_error)('ERR_GET_BUILD_ID');
48
+ (0, zephyr_edge_contract_1.ze_log)(`Got build id: ${buildId}`);
49
+ const pluginOptions = {
50
+ pluginName: 'rollup-plugin-zephyr',
51
+ application_uid,
52
+ buildEnv: 'local',
53
+ username,
54
+ app: {
55
+ name: packageJson.name,
56
+ version: packageJson.version,
57
+ org: gitInfo.app.org,
58
+ project: gitInfo.app.project,
59
+ },
60
+ git: gitInfo.git,
61
+ isCI: isCI,
62
+ zeConfig: {
63
+ user: username,
64
+ edge_url: EDGE_URL,
65
+ buildId: buildId,
66
+ },
67
+ mfConfig: void 0,
68
+ wait_for_index_html: _zephyrOptions === null || _zephyrOptions === void 0 ? void 0 : _zephyrOptions.wait_for_index_html,
69
+ };
70
+ const logEvent = (0, zephyr_agent_1.logger)(pluginOptions);
71
+ logEvent({
72
+ level: 'info',
73
+ action: 'build:info:user',
74
+ ignore: true,
75
+ message: `Hi ${(0, zephyr_edge_contract_1.cyanBright)(username)}!\n${(0, zephyr_edge_contract_1.white)(application_uid)}${(0, zephyr_edge_contract_1.yellow)(`#${buildId}`)}\n`,
76
+ });
77
+ return {
78
+ appConfig,
79
+ buildId,
80
+ hash_set,
81
+ pluginOptions,
82
+ };
83
+ })();
84
+ },
85
+ writeBundle: async (options, bundle) => {
86
+ const zeStart = Date.now();
87
+ await (async function zephyr_upload(props) {
88
+ (0, zephyr_edge_contract_1.ze_log)('zephyr agent started...');
89
+ const { state, bundle } = props;
90
+ const _state = await state;
91
+ if (!_state)
92
+ return (0, zephyr_edge_contract_1.ze_error)('ERR_INITIALIZE_ZEPHYR_AGENT');
93
+ const { appConfig, hash_set, pluginOptions } = _state;
94
+ const assetsMap = (0, get_assets_map_1.getAssetsMap)(bundle);
95
+ const missingAssets = (0, zephyr_agent_1.get_missing_assets)({ assetsMap, hash_set });
96
+ await (0, zephyr_agent_1.upload)({
97
+ pluginOptions,
98
+ assets: {
99
+ assetsMap,
100
+ missingAssets,
101
+ outputPath: options.dir,
102
+ count: Object.keys(bundle).length,
103
+ },
104
+ // @ts-expect-error TODO: fix this types to get legacy and current working
105
+ getDashData: get_dash_data_1.getDashData,
106
+ appConfig,
107
+ zeStart,
108
+ });
109
+ })({ state: _state, bundle });
110
+ console.log('zephyr agent done in', Date.now() - zeStart, 'ms');
111
+ },
112
+ };
113
+ }
114
+ exports.withZephyr = withZephyr;
115
+ //# sourceMappingURL=rollup-plugin-zephyr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup-plugin-zephyr.js","sourceRoot":"","sources":["../../src/lib/rollup-plugin-zephyr.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAE9B,+CAUsB;AACtB,+DAS8B;AAC9B,2DAAsD;AACtD,yDAAoD;AASpD,MAAM,cAAc,GAAG,CAAC,OAAqB,EAAU,EAAE;IACvD,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC;IAC5D,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1D,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,OAAO,OAAO,CAAC,GAA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C,GAAG,EAAE,CAAC;YAE3B,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAAyE;gBAC3G,IAAA,6BAAM,EAAC,yBAAyB,CAAC,CAAC;gBAClC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;gBAChC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC;gBAE3B,IAAI,CAAC,MAAM;oBAAE,OAAO,IAAA,+BAAQ,EAAC,6BAA6B,CAAC,CAAC;gBAE5D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC;gBAEtD,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,MAAM,CAAC,CAAC;gBACvC,MAAM,aAAa,GAAG,IAAA,iCAAkB,EAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;gBAClE,MAAM,IAAA,qBAAM,EAAC;oBACX,aAAa;oBACb,MAAM,EAAE;wBACN,SAAS;wBACT,aAAa;wBACb,UAAU,EAAE,OAAO,CAAC,GAAa;wBACjC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM;qBAClC;oBACD,0EAA0E;oBAC1E,WAAW,EAAX,2BAAW;oBACX,SAAS;oBACT,OAAO;iBACR,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAE9B,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,IAAI,CAAC,CAAC;QAClE,CAAC;KACF,CAAC;AACJ,CAAC;AA7GD,gCA6GC"}
@@ -0,0 +1,3 @@
1
+ import { OutputBundle } from 'rollup';
2
+ import { ZeBuildAssetsMap } from 'zephyr-edge-contract';
3
+ export declare function getAssetsMap(assets: OutputBundle): ZeBuildAssetsMap;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAssetsMap = void 0;
4
+ const zephyr_agent_1 = require("zephyr-agent");
5
+ function getAssetsMap(assets) {
6
+ return (0, zephyr_agent_1.buildAssetsMap)(assets, extractBuffer, getAssetType);
7
+ }
8
+ exports.getAssetsMap = getAssetsMap;
9
+ const extractBuffer = (asset) => {
10
+ switch (asset.type) {
11
+ case 'chunk':
12
+ return asset.code;
13
+ case 'asset':
14
+ return typeof asset.source === 'string'
15
+ ? asset.source
16
+ : new TextDecoder().decode(asset.source);
17
+ default:
18
+ return void 0;
19
+ }
20
+ };
21
+ const getAssetType = (asset) => asset.type;
22
+ //# sourceMappingURL=get-assets-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-assets-map.js","sourceRoot":"","sources":["../../../src/lib/utils/get-assets-map.ts"],"names":[],"mappings":";;;AACA,+CAA8C;AAG9C,SAAgB,YAAY,CAAC,MAAoB;IAC/C,OAAO,IAAA,6BAAc,EAAC,MAAM,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AAC7D,CAAC;AAFD,oCAEC;AAED,MAAM,aAAa,GAAG,CACpB,KAAgC,EACZ,EAAE;IACtB,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,OAAO;YACV,OAAO,KAAK,CAAC,IAAI,CAAC;QACpB,KAAK,OAAO;YACV,OAAO,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;gBACrC,CAAC,CAAC,KAAK,CAAC,MAAM;gBACd,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7C;YACE,OAAO,KAAK,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,KAAgC,EAAU,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { ZeApplicationConfig, ZephyrPluginOptions } from 'zephyr-edge-contract';
2
+ interface GetDashDataOptions {
3
+ appConfig: ZeApplicationConfig;
4
+ pluginOptions: ZephyrPluginOptions;
5
+ }
6
+ export declare function getDashData({ pluginOptions, appConfig }: GetDashDataOptions): {
7
+ id: string;
8
+ name: string;
9
+ environment: string;
10
+ edge: {
11
+ url: string;
12
+ };
13
+ app: {
14
+ org: string;
15
+ project: string;
16
+ name: string;
17
+ version: string;
18
+ } & {
19
+ buildId: string;
20
+ };
21
+ version: string;
22
+ git: {
23
+ name: string;
24
+ email: string;
25
+ branch: string;
26
+ commit: string;
27
+ };
28
+ context: {
29
+ isCI: boolean;
30
+ };
31
+ dependencies: never[];
32
+ devDependencies: never[];
33
+ optionalDependencies: never[];
34
+ metadata: {};
35
+ overrides: never[];
36
+ consumes: never[];
37
+ modules: never[];
38
+ };
39
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDashData = void 0;
4
+ const zephyr_agent_1 = require("zephyr-agent");
5
+ function getDashData({ pluginOptions, appConfig }) {
6
+ return (0, zephyr_agent_1.zeGetDashData)({ pluginOptions, appConfig });
7
+ }
8
+ exports.getDashData = getDashData;
9
+ //# sourceMappingURL=get-dash-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-dash-data.js","sourceRoot":"","sources":["../../../src/lib/utils/get-dash-data.ts"],"names":[],"mappings":";;;AACA,+CAA6C;AAO7C,SAAgB,WAAW,CAAC,EAAE,aAAa,EAAE,SAAS,EAAsB;IAC1E,OAAO,IAAA,4BAAa,EAAC,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC;AACrD,CAAC;AAFD,kCAEC"}
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "rollup-plugin-zephyr",
3
+ "version": "0.0.26",
4
+ "license": "Apache-2.0",
5
+ "type": "commonjs",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "nx run rollup-plugin-zephyr:build",
10
+ "patch-version": "pnpm version"
11
+ },
12
+ "dependencies": {
13
+ "is-ci": "^3.0.1",
14
+ "rollup": "^4",
15
+ "tslib": "^2",
16
+ "zephyr-agent": "workspace:*",
17
+ "zephyr-edge-contract": "workspace:*"
18
+ },
19
+ "keywords": [
20
+ "rollup",
21
+ "rollup-plugin",
22
+ "zephyr",
23
+ "deploy"
24
+ ],
25
+ "devDependencies": {
26
+ "@types/is-ci": "^3.0.4"
27
+ }
28
+ }
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "rollup-plugin-zephyr",
3
+ "version": "0.0.0-canary-20241116123955",
4
+ "license": "Apache-2.0",
5
+ "type": "commonjs",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "dependencies": {
9
+ "is-ci": "^3.0.1",
10
+ "rollup": "^4",
11
+ "tslib": "^2",
12
+ "zephyr-agent": "0.0.0-canary-20241116123955",
13
+ "zephyr-edge-contract": "0.0.0-canary-20241116123955"
14
+ },
15
+ "keywords": [
16
+ "rollup",
17
+ "rollup-plugin",
18
+ "zephyr",
19
+ "deploy"
20
+ ],
21
+ "devDependencies": {
22
+ "@types/is-ci": "^3.0.4"
23
+ },
24
+ "scripts": {
25
+ "build": "nx run rollup-plugin-zephyr:build",
26
+ "patch-version": "pnpm version"
27
+ }
28
+ }