zephyr-astro-integration 0.1.0
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 +66 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/astro-integration-zephyr.d.ts +2 -0
- package/dist/lib/astro-integration-zephyr.js +55 -0
- package/dist/lib/astro-integration-zephyr.js.map +1 -0
- package/dist/lib/internal/extract-astro-assets-map.d.ts +9 -0
- package/dist/lib/internal/extract-astro-assets-map.js +235 -0
- package/dist/lib/internal/extract-astro-assets-map.js.map +1 -0
- package/dist/package.json +39 -0
- package/package.json +39 -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,66 @@
|
|
|
1
|
+
# zephyr-astro-integration
|
|
2
|
+
|
|
3
|
+
Astro integration for Zephyr Cloud deployment and analytics platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install zephyr-astro-integration
|
|
9
|
+
# or
|
|
10
|
+
pnpm add zephyr-astro-integration
|
|
11
|
+
# or
|
|
12
|
+
yarn add zephyr-astro-integration
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
Add the integration to your `astro.config.mjs`:
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { defineConfig } from 'astro/config';
|
|
21
|
+
import { withZephyr } from 'zephyr-astro-integration';
|
|
22
|
+
|
|
23
|
+
export default defineConfig({
|
|
24
|
+
integrations: [
|
|
25
|
+
withZephyr({
|
|
26
|
+
// Integration options (if needed)
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- **Automated Asset Upload**: Automatically uploads your Astro build assets to Zephyr Cloud
|
|
35
|
+
- **Build Analytics**: Provides detailed build statistics and performance metrics
|
|
36
|
+
- **Easy Integration**: Simple one-line addition to your Astro configuration
|
|
37
|
+
- **Build Optimization**: Integrates with Zephyr's optimization pipeline
|
|
38
|
+
|
|
39
|
+
## How it Works
|
|
40
|
+
|
|
41
|
+
The integration hooks into Astro's build lifecycle:
|
|
42
|
+
|
|
43
|
+
1. **Setup Phase**: Initializes the Zephyr engine during Astro config setup
|
|
44
|
+
2. **Build Phase**: Monitors the build process and collects metrics
|
|
45
|
+
3. **Post-Build Phase**: Extracts built assets and uploads them to Zephyr Cloud
|
|
46
|
+
4. **Analytics**: Generates build statistics for the Zephyr dashboard
|
|
47
|
+
|
|
48
|
+
## Configuration
|
|
49
|
+
|
|
50
|
+
The integration works out of the box without additional configuration. For advanced use cases, you can pass options to customize behavior:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
withZephyr({
|
|
54
|
+
// Add custom options here when needed
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Requirements
|
|
59
|
+
|
|
60
|
+
- Astro 4.0 or higher
|
|
61
|
+
- Node.js 16 or higher
|
|
62
|
+
- Zephyr Cloud account
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
Apache-2.0
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.withZephyr = void 0;
|
|
4
|
+
var astro_integration_zephyr_1 = require("./lib/astro-integration-zephyr");
|
|
5
|
+
Object.defineProperty(exports, "withZephyr", { enumerable: true, get: function () { return astro_integration_zephyr_1.withZephyr; } });
|
|
6
|
+
var astro_integration_zephyr_2 = require("./lib/astro-integration-zephyr");
|
|
7
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return astro_integration_zephyr_2.withZephyr; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2EAA4D;AAAnD,sHAAA,UAAU,OAAA;AACnB,2EAAuE;AAA9D,mHAAA,UAAU,OAAW"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withZephyr = withZephyr;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_url_1 = require("node:url");
|
|
6
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
7
|
+
const extract_astro_assets_map_1 = require("./internal/extract-astro-assets-map");
|
|
8
|
+
function withZephyr() {
|
|
9
|
+
const { zephyr_engine_defer, zephyr_defer_create } = zephyr_agent_1.ZephyrEngine.defer_create();
|
|
10
|
+
return {
|
|
11
|
+
name: 'with-zephyr',
|
|
12
|
+
hooks: {
|
|
13
|
+
'astro:config:done': async ({ config }) => {
|
|
14
|
+
// config.root is a URL object, convert to file path
|
|
15
|
+
const contextPath = (0, node_url_1.fileURLToPath)(config.root);
|
|
16
|
+
try {
|
|
17
|
+
// Initialize ZephyrEngine with Astro context
|
|
18
|
+
zephyr_defer_create({
|
|
19
|
+
builder: 'astro',
|
|
20
|
+
context: contextPath,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
(0, zephyr_agent_1.logFn)('error', zephyr_agent_1.ZephyrError.format(error));
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
'astro:build:done': async (_a) => {
|
|
28
|
+
var { dir } = _a, params = tslib_1.__rest(_a, ["dir"]);
|
|
29
|
+
try {
|
|
30
|
+
const zephyr_engine = await zephyr_engine_defer;
|
|
31
|
+
// Convert URL to file system path
|
|
32
|
+
const outputPath = (0, node_url_1.fileURLToPath)(dir);
|
|
33
|
+
// Set output directory for ZephyrEngine
|
|
34
|
+
zephyr_engine.buildProperties.output = outputPath;
|
|
35
|
+
// Start a new build
|
|
36
|
+
await zephyr_engine.start_new_build();
|
|
37
|
+
// Extract assets from params if available (Astro v5+), fallback to filesystem walking
|
|
38
|
+
const assets = params.assets;
|
|
39
|
+
const assetsMap = await (0, extract_astro_assets_map_1.extractAstroAssetsFromBuildHook)(assets, outputPath);
|
|
40
|
+
// Upload assets and build stats
|
|
41
|
+
await zephyr_engine.upload_assets({
|
|
42
|
+
assetsMap,
|
|
43
|
+
buildStats: await (0, zephyr_agent_1.zeBuildDashData)(zephyr_engine),
|
|
44
|
+
});
|
|
45
|
+
// Mark build as finished
|
|
46
|
+
await zephyr_engine.build_finished();
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
(0, zephyr_agent_1.logFn)('error', zephyr_agent_1.ZephyrError.format(error));
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=astro-integration-zephyr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro-integration-zephyr.js","sourceRoot":"","sources":["../../src/lib/astro-integration-zephyr.ts"],"names":[],"mappings":";;AASA,gCAqDC;;AA7DD,uCAAyC;AACzC,+CAAiF;AACjF,kFAAsF;AAMtF,SAAgB,UAAU;IACxB,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,GAAG,2BAAY,CAAC,YAAY,EAAE,CAAC;IAEjF,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE;YACL,mBAAmB,EAAE,KAAK,EAAE,EAAE,MAAM,EAAuC,EAAE,EAAE;gBAC7E,oDAAoD;gBACpD,MAAM,WAAW,GAAG,IAAA,wBAAa,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAC/C,IAAI,CAAC;oBACH,6CAA6C;oBAC7C,mBAAmB,CAAC;wBAClB,OAAO,EAAE,OAAO;wBAChB,OAAO,EAAE,WAAW;qBACrB,CAAC,CAAC;gBACL,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,IAAA,oBAAK,EAAC,OAAO,EAAE,0BAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC5C,CAAC;YACH,CAAC;YACD,kBAAkB,EAAE,KAAK,EAAE,EAGU,EAAE,EAAE;oBAHd,EACzB,GAAG,OAEgC,EADhC,MAAM,sBAFgB,OAG1B,CADU;gBAET,IAAI,CAAC;oBACH,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC;oBAEhD,kCAAkC;oBAClC,MAAM,UAAU,GAAG,IAAA,wBAAa,EAAC,GAAG,CAAC,CAAC;oBAEtC,wCAAwC;oBACxC,aAAa,CAAC,eAAe,CAAC,MAAM,GAAG,UAAU,CAAC;oBAElD,oBAAoB;oBACpB,MAAM,aAAa,CAAC,eAAe,EAAE,CAAC;oBAEtC,sFAAsF;oBACtF,MAAM,MAAM,GAAI,MAA+B,CAAC,MAAM,CAAC;oBACvD,MAAM,SAAS,GAAG,MAAM,IAAA,0DAA+B,EAAC,MAAM,EAAE,UAAU,CAAC,CAAC;oBAE5E,gCAAgC;oBAChC,MAAM,aAAa,CAAC,aAAa,CAAC;wBAChC,SAAS;wBACT,UAAU,EAAE,MAAM,IAAA,8BAAe,EAAC,aAAa,CAAC;qBACjD,CAAC,CAAC;oBAEH,yBAAyB;oBACzB,MAAM,aAAa,CAAC,cAAc,EAAE,CAAC;gBACvC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,IAAA,oBAAK,EAAC,OAAO,EAAE,0BAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC5C,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ZeBuildAssetsMap } from 'zephyr-agent';
|
|
2
|
+
type AstroAssets = Record<string, unknown> | Map<string, unknown> | Array<unknown> | undefined | null;
|
|
3
|
+
/**
|
|
4
|
+
* Extract assets map from Astro's build hook assets parameter. This is more efficient
|
|
5
|
+
* than walking the filesystem manually.
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractAstroAssetsFromBuildHook(assets: AstroAssets, outputPath: string): Promise<ZeBuildAssetsMap>;
|
|
8
|
+
export declare function extractAstroAssetsMap(buildDir: string): Promise<ZeBuildAssetsMap>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractAstroAssetsFromBuildHook = extractAstroAssetsFromBuildHook;
|
|
4
|
+
exports.extractAstroAssetsMap = extractAstroAssetsMap;
|
|
5
|
+
const promises_1 = require("node:fs/promises");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const node_url_1 = require("node:url");
|
|
8
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
9
|
+
function extractBuffer(asset) {
|
|
10
|
+
return asset.content;
|
|
11
|
+
}
|
|
12
|
+
function getAssetType(asset) {
|
|
13
|
+
return asset.type;
|
|
14
|
+
}
|
|
15
|
+
/** Normalize path separators to forward slashes for cross-platform consistency */
|
|
16
|
+
function normalizePath(filePath) {
|
|
17
|
+
return filePath.split(node_path_1.sep).join('/');
|
|
18
|
+
}
|
|
19
|
+
/** Check if a path looks like a URL route rather than a filesystem path */
|
|
20
|
+
function looksLikeRoute(path) {
|
|
21
|
+
if (!path || !path.startsWith('/')) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
// Dynamic routes have brackets
|
|
25
|
+
if (path.includes('[') || path.includes(']')) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
// Check if it's a real absolute filesystem path vs a route
|
|
29
|
+
// Real absolute paths are typically long and contain multiple segments
|
|
30
|
+
const segments = path.split('/').filter(Boolean);
|
|
31
|
+
// Paths with just 1-2 segments like /about, /blog, /rss.xml are likely routes
|
|
32
|
+
// Real filesystem paths like /Users/name/project/file.js have many segments
|
|
33
|
+
if (segments.length <= 2) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Extract assets map from Astro's build hook assets parameter. This is more efficient
|
|
40
|
+
* than walking the filesystem manually.
|
|
41
|
+
*/
|
|
42
|
+
async function extractAstroAssetsFromBuildHook(assets, outputPath) {
|
|
43
|
+
const astroAssets = {};
|
|
44
|
+
try {
|
|
45
|
+
// Handle different possible structures of the assets parameter
|
|
46
|
+
if (!assets) {
|
|
47
|
+
// Fallback to filesystem walking if assets is not available
|
|
48
|
+
return await extractAstroAssetsMap(outputPath);
|
|
49
|
+
}
|
|
50
|
+
// Assets might be an object, Map, or array depending on Astro version
|
|
51
|
+
const assetEntries = extractAssetEntries(assets);
|
|
52
|
+
for (const [filePath, assetInfo] of assetEntries) {
|
|
53
|
+
try {
|
|
54
|
+
let fullPath = null;
|
|
55
|
+
// Handle URL objects or string paths
|
|
56
|
+
if (assetInfo && typeof assetInfo === 'object' && 'href' in assetInfo) {
|
|
57
|
+
// It's a URL object
|
|
58
|
+
fullPath = (0, node_url_1.fileURLToPath)(assetInfo);
|
|
59
|
+
}
|
|
60
|
+
else if (typeof assetInfo === 'string' && assetInfo) {
|
|
61
|
+
// It's a string path - skip if it looks like a route
|
|
62
|
+
if (looksLikeRoute(assetInfo)) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
// Only treat as absolute if it's really an absolute filesystem path
|
|
66
|
+
// (not just a route starting with /)
|
|
67
|
+
fullPath =
|
|
68
|
+
(0, node_path_1.isAbsolute)(assetInfo) && !looksLikeRoute(assetInfo)
|
|
69
|
+
? assetInfo // Absolute file system path
|
|
70
|
+
: (0, node_path_1.join)(outputPath, assetInfo); // Relative path or route
|
|
71
|
+
}
|
|
72
|
+
else if (typeof filePath === 'string' && filePath) {
|
|
73
|
+
// Use the key as the file path only if it looks like a file path
|
|
74
|
+
if (looksLikeRoute(filePath)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
// Only treat as absolute if it's really an absolute filesystem path
|
|
78
|
+
fullPath =
|
|
79
|
+
(0, node_path_1.isAbsolute)(filePath) && !looksLikeRoute(filePath)
|
|
80
|
+
? filePath // Absolute file system path
|
|
81
|
+
: (0, node_path_1.join)(outputPath, filePath); // Relative path or route
|
|
82
|
+
}
|
|
83
|
+
// Skip if we couldn't determine a valid file path
|
|
84
|
+
if (!fullPath) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
// Skip files we don't want to upload
|
|
88
|
+
const relativePath = normalizePath((0, node_path_1.relative)(outputPath, fullPath));
|
|
89
|
+
if (shouldSkipFile(relativePath)) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
// Read the file content
|
|
93
|
+
const content = await (0, promises_1.readFile)(fullPath);
|
|
94
|
+
const fileType = getFileType(relativePath);
|
|
95
|
+
astroAssets[relativePath] = {
|
|
96
|
+
content,
|
|
97
|
+
type: fileType,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
catch (readError) {
|
|
101
|
+
(0, zephyr_agent_1.logFn)('warn', `Failed to read asset file ${filePath}: ${readError}`);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// If we didn't find any assets from the hook, fallback to filesystem walking
|
|
106
|
+
if (Object.keys(astroAssets).length === 0) {
|
|
107
|
+
return await extractAstroAssetsMap(outputPath);
|
|
108
|
+
}
|
|
109
|
+
return (0, zephyr_agent_1.buildAssetsMap)(astroAssets, extractBuffer, getAssetType);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
(0, zephyr_agent_1.logFn)('warn', 'Error processing assets from Astro build hook:' + JSON.stringify(error, null, 2));
|
|
113
|
+
// Fallback to filesystem walking on any error
|
|
114
|
+
return await extractAstroAssetsMap(outputPath);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Extract asset entries from the Astro assets parameter. Handles different possible data
|
|
119
|
+
* structures.
|
|
120
|
+
*/
|
|
121
|
+
function extractAssetEntries(assets) {
|
|
122
|
+
const entries = [];
|
|
123
|
+
if (Array.isArray(assets)) {
|
|
124
|
+
// Handle array of assets
|
|
125
|
+
assets.forEach((asset) => {
|
|
126
|
+
if (typeof asset === 'string') {
|
|
127
|
+
entries.push([asset, asset]);
|
|
128
|
+
}
|
|
129
|
+
else if (asset && typeof asset === 'object') {
|
|
130
|
+
// Could be an object with path/url properties
|
|
131
|
+
const assetObj = asset;
|
|
132
|
+
const path = assetObj['path'] || assetObj['url'] || assetObj['href'] || assetObj['pathname'];
|
|
133
|
+
if (path && typeof path === 'string') {
|
|
134
|
+
entries.push([path, asset]);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else if (assets instanceof Map) {
|
|
140
|
+
// Handle Map objects
|
|
141
|
+
for (const [key, value] of assets.entries()) {
|
|
142
|
+
entries.push([key, value]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else if (assets && typeof assets === 'object') {
|
|
146
|
+
// Handle plain objects
|
|
147
|
+
for (const [key, value] of Object.entries(assets)) {
|
|
148
|
+
if (Array.isArray(value)) {
|
|
149
|
+
// If value is an array, it might contain multiple assets for this route
|
|
150
|
+
value.forEach((item) => {
|
|
151
|
+
entries.push([key, item]);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
entries.push([key, value]);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return entries;
|
|
160
|
+
}
|
|
161
|
+
async function extractAstroAssetsMap(buildDir) {
|
|
162
|
+
const assets = {};
|
|
163
|
+
// Recursively walk through the build directory
|
|
164
|
+
async function walkDir(dirPath) {
|
|
165
|
+
try {
|
|
166
|
+
const entries = await (0, promises_1.readdir)(dirPath, { withFileTypes: true });
|
|
167
|
+
for (const entry of entries) {
|
|
168
|
+
const fullPath = (0, node_path_1.join)(dirPath, entry.name);
|
|
169
|
+
if (entry.isDirectory()) {
|
|
170
|
+
await walkDir(fullPath);
|
|
171
|
+
}
|
|
172
|
+
else if (entry.isFile()) {
|
|
173
|
+
// Get relative path from build directory
|
|
174
|
+
const relativePath = normalizePath((0, node_path_1.relative)(buildDir, fullPath));
|
|
175
|
+
// Skip certain files that shouldn't be uploaded
|
|
176
|
+
if (shouldSkipFile(relativePath)) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
try {
|
|
180
|
+
const content = await (0, promises_1.readFile)(fullPath);
|
|
181
|
+
const fileType = getFileType(relativePath);
|
|
182
|
+
assets[relativePath] = {
|
|
183
|
+
content,
|
|
184
|
+
type: fileType,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
catch (readError) {
|
|
188
|
+
(0, zephyr_agent_1.logFn)('warn', `Failed to read file ${fullPath}: ${readError}`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
(0, zephyr_agent_1.logFn)('warn', `Failed to walk directory ${dirPath}: ${error}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
await walkDir(buildDir);
|
|
198
|
+
return (0, zephyr_agent_1.buildAssetsMap)(assets, extractBuffer, getAssetType);
|
|
199
|
+
}
|
|
200
|
+
function shouldSkipFile(filePath) {
|
|
201
|
+
// Skip common files that shouldn't be uploaded
|
|
202
|
+
const skipPatterns = [
|
|
203
|
+
/\.map$/, // Source maps
|
|
204
|
+
/node_modules/, // Node modules
|
|
205
|
+
/\.git/, // Git files
|
|
206
|
+
/\.DS_Store$/, // macOS files
|
|
207
|
+
/thumbs\.db$/i, // Windows files
|
|
208
|
+
];
|
|
209
|
+
return skipPatterns.some((pattern) => pattern.test(filePath));
|
|
210
|
+
}
|
|
211
|
+
function getFileType(filePath) {
|
|
212
|
+
var _a;
|
|
213
|
+
const extension = ((_a = filePath.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
|
|
214
|
+
const typeMap = {
|
|
215
|
+
html: 'text/html',
|
|
216
|
+
css: 'text/css',
|
|
217
|
+
js: 'application/javascript',
|
|
218
|
+
mjs: 'application/javascript',
|
|
219
|
+
json: 'application/json',
|
|
220
|
+
png: 'image/png',
|
|
221
|
+
jpg: 'image/jpeg',
|
|
222
|
+
jpeg: 'image/jpeg',
|
|
223
|
+
gif: 'image/gif',
|
|
224
|
+
svg: 'image/svg+xml',
|
|
225
|
+
ico: 'image/x-icon',
|
|
226
|
+
woff: 'font/woff',
|
|
227
|
+
woff2: 'font/woff2',
|
|
228
|
+
ttf: 'font/ttf',
|
|
229
|
+
eot: 'application/vnd.ms-fontobject',
|
|
230
|
+
xml: 'text/xml',
|
|
231
|
+
txt: 'text/plain',
|
|
232
|
+
};
|
|
233
|
+
return typeMap[extension] || 'application/octet-stream';
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=extract-astro-assets-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-astro-assets-map.js","sourceRoot":"","sources":["../../../src/lib/internal/extract-astro-assets-map.ts"],"names":[],"mappings":";;AA0DA,0EAwFC;AA8CD,sDA2CC;AA3OD,+CAAqD;AACrD,yCAA4D;AAC5D,uCAAyC;AACzC,+CAA4E;AAO5E,SAAS,aAAa,CAAC,KAAiB;IACtC,OAAO,KAAK,CAAC,OAAO,CAAC;AACvB,CAAC;AAED,SAAS,YAAY,CAAC,KAAiB;IACrC,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB,CAAC;AAED,kFAAkF;AAClF,SAAS,aAAa,CAAC,QAAgB;IACrC,OAAO,QAAQ,CAAC,KAAK,CAAC,eAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,2EAA2E;AAC3E,SAAS,cAAc,CAAC,IAAY;IAClC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,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nB,QAAQ,EAAE,cAAc;QACxB,cAAc,EAAE,eAAe;QAC/B,OAAO,EAAE,YAAY;QACrB,aAAa,EAAE,cAAc;QAC7B,cAAc,EAAE,gBAAgB;KACjC,CAAC;IAEF,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,WAAW,CAAC,QAAgB;;IACnC,MAAM,SAAS,GAAG,CAAA,MAAA,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,0CAAE,WAAW,EAAE,KAAI,EAAE,CAAC;IAEjE,MAAM,OAAO,GAA2B;QACtC,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,UAAU;QACf,EAAE,EAAE,wBAAwB;QAC5B,GAAG,EAAE,wBAAwB;QAC7B,IAAI,EAAE,kBAAkB;QACxB,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,YAAY;QACjB,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,eAAe;QACpB,GAAG,EAAE,cAAc;QACnB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,YAAY;QACnB,GAAG,EAAE,UAAU;QACf,GAAG,EAAE,+BAA+B;QACpC,GAAG,EAAE,UAAU;QACf,GAAG,EAAE,YAAY;KAClB,CAAC;IAEF,OAAO,OAAO,CAAC,SAAS,CAAC,IAAI,0BAA0B,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zephyr-astro-integration",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Astro integration for Zephyr",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/ZephyrCloudIO/zephyr-packages.git",
|
|
8
|
+
"directory": "libs/zephyr-astro-integration"
|
|
9
|
+
},
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"author": {
|
|
12
|
+
"name": "ZephyrCloudIO",
|
|
13
|
+
"url": "https://github.com/ZephyrCloudIO"
|
|
14
|
+
},
|
|
15
|
+
"type": "commonjs",
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "nx run zephyr-astro-integration:build",
|
|
20
|
+
"patch-version": "pnpm version"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"is-ci": "catalog:plugin-shared",
|
|
24
|
+
"zephyr-agent": "workspace:*"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/jest": "catalog:typescript",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "catalog:eslint",
|
|
29
|
+
"astro": "^4.0.0",
|
|
30
|
+
"ts-jest": "catalog:typescript"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"astro": "^4.0.0"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"provenance": true
|
|
38
|
+
}
|
|
39
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zephyr-astro-integration",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Astro integration for Zephyr",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/ZephyrCloudIO/zephyr-packages.git",
|
|
8
|
+
"directory": "libs/zephyr-astro-integration"
|
|
9
|
+
},
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"author": {
|
|
12
|
+
"name": "ZephyrCloudIO",
|
|
13
|
+
"url": "https://github.com/ZephyrCloudIO"
|
|
14
|
+
},
|
|
15
|
+
"type": "commonjs",
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"is-ci": "^4.1.0",
|
|
20
|
+
"zephyr-agent": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/jest": "29.5.14",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "^8.27.0",
|
|
25
|
+
"astro": "^4.0.0",
|
|
26
|
+
"ts-jest": "^29.2.6"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"astro": "^4.0.0"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public",
|
|
33
|
+
"provenance": true
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "nx run zephyr-astro-integration:build",
|
|
37
|
+
"patch-version": "pnpm version"
|
|
38
|
+
}
|
|
39
|
+
}
|