parcel-reporter-zephyr 0.0.0-canary-20250227203709
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 +39 -0
- package/README.md +37 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/get-assets-map.d.ts +8 -0
- package/dist/lib/get-assets-map.js +34 -0
- package/dist/lib/get-assets-map.js.map +1 -0
- package/dist/package.json +23 -0
- package/package.json +22 -0
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,37 @@
|
|
|
1
|
+
# Zephyr Parcel Plugin
|
|
2
|
+
|
|
3
|
+
## Usage
|
|
4
|
+
|
|
5
|
+
### With .parcelrc (Recommended)
|
|
6
|
+
|
|
7
|
+
The easiest way to use the Zephyr Parcel plugin is to add it to your `.parcelrc` file:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
//.parcelrc
|
|
11
|
+
{
|
|
12
|
+
"extends": "@parcel/config-default",
|
|
13
|
+
"reporters": ["...", "parcel-reporter-zephyr"]
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Programmatic Usage
|
|
18
|
+
|
|
19
|
+
If you're using Parcel programmatically, you can add the plugin directly:
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
// build.js
|
|
23
|
+
const { Parcel } = require('@parcel/core');
|
|
24
|
+
const ZephyrReporter = require('parcel-reporter-zephyr');
|
|
25
|
+
|
|
26
|
+
async function build() {
|
|
27
|
+
const bundler = new Parcel({
|
|
28
|
+
entries: ['src/index.html'],
|
|
29
|
+
defaultConfig: '@parcel/config-default',
|
|
30
|
+
reporters: ['...', ZephyrReporter],
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
await bundler.run();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
build();
|
|
37
|
+
```
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const plugin_1 = require("@parcel/plugin");
|
|
5
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
6
|
+
const get_assets_map_1 = require("./lib/get-assets-map");
|
|
7
|
+
const path = tslib_1.__importStar(require("path"));
|
|
8
|
+
// Create the engine and assets map outside the reporter function
|
|
9
|
+
// so they persist between calls
|
|
10
|
+
const { zephyr_engine_defer, zephyr_defer_create } = zephyr_agent_1.ZephyrEngine.defer_create();
|
|
11
|
+
const assets = new Map();
|
|
12
|
+
exports.default = new plugin_1.Reporter({
|
|
13
|
+
report: async ({ event, options }) => {
|
|
14
|
+
const projectRoot = options.projectRoot;
|
|
15
|
+
if (event.type === 'buildStart') {
|
|
16
|
+
zephyr_defer_create({
|
|
17
|
+
builder: 'parcel',
|
|
18
|
+
context: projectRoot,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (event.type === 'buildSuccess') {
|
|
22
|
+
const zephyr_engine = await zephyr_engine_defer;
|
|
23
|
+
// Start a new build
|
|
24
|
+
await zephyr_engine.start_new_build();
|
|
25
|
+
// Collect assets from the build
|
|
26
|
+
event.bundleGraph.getBundles().forEach((bundle) => {
|
|
27
|
+
const filePath = bundle.filePath;
|
|
28
|
+
if (!filePath)
|
|
29
|
+
return;
|
|
30
|
+
const name = path.basename(filePath);
|
|
31
|
+
assets.set(name, {
|
|
32
|
+
name: name,
|
|
33
|
+
filePath,
|
|
34
|
+
type: bundle.type,
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
// Upload assets and finish the build
|
|
38
|
+
await zephyr_engine.upload_assets({
|
|
39
|
+
assetsMap: (0, get_assets_map_1.getAssetsMap)(assets),
|
|
40
|
+
buildStats: await (0, zephyr_agent_1.zeBuildDashData)(zephyr_engine),
|
|
41
|
+
});
|
|
42
|
+
await zephyr_engine.build_finished();
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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SAAS,EAAE,IAAA,6BAAY,EAAC,MAAM,CAAC;gBAC/B,UAAU,EAAE,MAAM,IAAA,8BAAe,EAAC,aAAa,CAAC;aACjD,CAAC,CAAC;YAEH,MAAM,aAAa,CAAC,cAAc,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ZeBuildAssetsMap } from 'zephyr-agent';
|
|
2
|
+
export interface ParcelOutputAsset {
|
|
3
|
+
name: string;
|
|
4
|
+
filePath: string;
|
|
5
|
+
type: string;
|
|
6
|
+
content?: Buffer | string;
|
|
7
|
+
}
|
|
8
|
+
export declare function getAssetsMap(assets: Map<string, ParcelOutputAsset>): ZeBuildAssetsMap;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAssetsMap = getAssetsMap;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
7
|
+
function getAssetsMap(assets) {
|
|
8
|
+
// Convert Map to a plain object (Record<string, ParcelOutputAsset>)
|
|
9
|
+
const assetsRecord = {};
|
|
10
|
+
// Read content for all assets
|
|
11
|
+
for (const [key, value] of assets.entries()) {
|
|
12
|
+
value.content = fs.readFileSync(value.filePath, 'utf8');
|
|
13
|
+
assetsRecord[key] = value;
|
|
14
|
+
}
|
|
15
|
+
return (0, zephyr_agent_1.buildAssetsMap)(assetsRecord, extractBuffer, getAssetType);
|
|
16
|
+
}
|
|
17
|
+
const extractBuffer = (asset) => {
|
|
18
|
+
if (!asset.content) {
|
|
19
|
+
try {
|
|
20
|
+
return fs.readFileSync(asset.filePath, 'utf8');
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return typeof asset.content === 'string'
|
|
27
|
+
? asset.content
|
|
28
|
+
: new TextDecoder().decode(asset.content);
|
|
29
|
+
};
|
|
30
|
+
const getAssetType = (asset) => {
|
|
31
|
+
const type = asset.type || 'asset';
|
|
32
|
+
return type;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=get-assets-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-assets-map.js","sourceRoot":"","sources":["../../src/lib/get-assets-map.ts"],"names":[],"mappings":";;AAUA,oCAYC;;AAtBD,+CAAyB;AACzB,+CAAgE;AAShE,SAAgB,YAAY,CAAC,MAAsC;IACjE,oEAAoE;IACpE,MAAM,YAAY,GAAsC,EAAE,CAAC;IAE3D,8BAA8B;IAC9B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5C,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAExD,YAAY,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,OAAO,IAAA,6BAAc,EAAC,YAAY,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,aAAa,GAAG,CAAC,KAAwB,EAAsB,EAAE;IACrE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACnB,IAAI,CAAC;YACH,OAAO,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;QACtC,CAAC,CAAC,KAAK,CAAC,OAAO;QACf,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,KAAwB,EAAU,EAAE;IACxD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,OAAO,CAAC;IACnC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "parcel-reporter-zephyr",
|
|
3
|
+
"version": "0.0.35",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "nx run parcel-reporter-zephyr:build",
|
|
9
|
+
"patch-version": "pnpm version"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"is-ci": "^3",
|
|
13
|
+
"@parcel/plugin": "^2.13.3",
|
|
14
|
+
"@parcel/types": "^2.13.3",
|
|
15
|
+
"@parcel/core": "^2.13.3",
|
|
16
|
+
"zephyr-agent": "workspace:*",
|
|
17
|
+
"zephyr-xpack-internal": "workspace:*"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/is-ci": "^3.0.4"
|
|
21
|
+
},
|
|
22
|
+
"type": "commonjs"
|
|
23
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "parcel-reporter-zephyr",
|
|
3
|
+
"version": "0.0.0-canary-20250227203709",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"is-ci": "^3",
|
|
9
|
+
"@parcel/plugin": "^2.13.3",
|
|
10
|
+
"@parcel/types": "^2.13.3",
|
|
11
|
+
"@parcel/core": "^2.13.3",
|
|
12
|
+
"zephyr-agent": "0.0.35",
|
|
13
|
+
"zephyr-xpack-internal": "0.0.35"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/is-ci": "^3.0.4"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "nx run parcel-reporter-zephyr:build",
|
|
20
|
+
"patch-version": "pnpm version"
|
|
21
|
+
}
|
|
22
|
+
}
|