zephyr-rspress-plugin 0.0.53
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 +136 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/assets/buildAssets.d.ts +2 -0
- package/dist/internal/assets/buildAssets.js +27 -0
- package/dist/internal/assets/buildAssets.js.map +1 -0
- package/dist/internal/assets/setupZeDeploy.d.ts +2 -0
- package/dist/internal/assets/setupZeDeploy.js +28 -0
- package/dist/internal/assets/setupZeDeploy.js.map +1 -0
- package/dist/internal/files/showFiles.d.ts +1 -0
- package/dist/internal/files/showFiles.js +26 -0
- package/dist/internal/files/showFiles.js.map +1 -0
- package/dist/internal/files/walkFiles.d.ts +1 -0
- package/dist/internal/files/walkFiles.js +24 -0
- package/dist/internal/files/walkFiles.js.map +1 -0
- package/dist/internal/stats/buildStats.d.ts +2 -0
- package/dist/internal/stats/buildStats.js +16 -0
- package/dist/internal/stats/buildStats.js.map +1 -0
- package/dist/package.json +44 -0
- package/dist/types/index.d.ts +40 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/with-zephyr.d.ts +2 -0
- package/dist/with-zephyr.js +21 -0
- package/dist/with-zephyr.js.map +1 -0
- package/dist/zephyrRsbuildPlugin.d.ts +2 -0
- package/dist/zephyrRsbuildPlugin.js +14 -0
- package/dist/zephyrRsbuildPlugin.js.map +1 -0
- package/dist/zephyrRspressSSGPlugin.d.ts +4 -0
- package/dist/zephyrRspressSSGPlugin.js +33 -0
- package/dist/zephyrRspressSSGPlugin.js.map +1 -0
- package/package.json +44 -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,136 @@
|
|
|
1
|
+
# Zephyr Rspress Plugin
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
[Zephyr Cloud](https://zephyr-cloud.io) | [Zephyr Docs](https://docs.zephyr-cloud.io/recipes/rspress) | [Rspress Docs](https://rspress.dev/) | [Discord](https://zephyr-cloud.io/discord) | [Twitter](https://x.com/ZephyrCloudIO) | [LinkedIn](https://www.linkedin.com/company/zephyr-cloud/)
|
|
6
|
+
|
|
7
|
+
<hr/>
|
|
8
|
+
<img src="https://cdn.prod.website-files.com/669061ee3adb95b628c3acda/66981c766e352fe1f57191e2_Opengraph-zephyr.png" alt="Zephyr Logo" />
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
An Rspress plugin for deploying documentation and static apps with Zephyr Cloud. This plugin enables seamless integration with Rspress to optimize, build, and deploy your site globally with CDN-backed delivery and analytics.
|
|
12
|
+
|
|
13
|
+
> Learn more in our [documentation](https://docs.zephyr-cloud.io/recipes/rspress).
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Get Started
|
|
18
|
+
|
|
19
|
+
You can quickly get started using the official Rspress template:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx create-zephyr-apps@latest
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Select the Rspress example when prompted.
|
|
26
|
+
|
|
27
|
+
For advanced usage and more recipes, visit our [documentation](https://docs.zephyr-cloud.io/recipes/rspress).
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# npm
|
|
35
|
+
npm install --save-dev zephyr-rspress-plugin
|
|
36
|
+
|
|
37
|
+
# yarn
|
|
38
|
+
yarn add --dev zephyr-rspress-plugin
|
|
39
|
+
|
|
40
|
+
# pnpm
|
|
41
|
+
pnpm add --dev zephyr-rspress-plugin
|
|
42
|
+
|
|
43
|
+
# bun
|
|
44
|
+
bun add --dev zephyr-rspress-plugin
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
### With Rspress
|
|
52
|
+
|
|
53
|
+
Add the plugin to your \`rspress.config.ts\` or \`rspress.config.js\` file:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
// rspress.config.ts
|
|
57
|
+
import { defineConfig } from 'rspress/config';
|
|
58
|
+
import { withZephyr } from 'zephyr-rspress-plugin';
|
|
59
|
+
|
|
60
|
+
export default defineConfig({
|
|
61
|
+
ssg: true,
|
|
62
|
+
plugins: [withZephyr()],
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
You can also pass options:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
export default defineConfig({
|
|
70
|
+
ssg: true,
|
|
71
|
+
plugins: [
|
|
72
|
+
withZephyr({
|
|
73
|
+
environment: 'production',
|
|
74
|
+
deploy: true,
|
|
75
|
+
}),
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Features
|
|
83
|
+
|
|
84
|
+
- 📘 Seamless Rspress integration
|
|
85
|
+
- 📦 Automatic static asset upload
|
|
86
|
+
- 🌍 Global CDN distribution
|
|
87
|
+
- 🔍 Optional search index support
|
|
88
|
+
- 🧠 Smart caching and invalidation
|
|
89
|
+
- 📊 Build analytics and logs via Zephyr Cloud
|
|
90
|
+
- 🛠️ Minimal config, works with \`rspress build\`
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Build Scripts
|
|
95
|
+
|
|
96
|
+
Add these scripts to your \`package.json\`:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"scripts": {
|
|
101
|
+
"dev": "rspress dev",
|
|
102
|
+
"build": "rspress build",
|
|
103
|
+
"build:prod": "NODE_ENV=production rspress build"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
After running \`build\`, your site will automatically be uploaded to Zephyr Cloud if the plugin is enabled and configured.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Requirements
|
|
113
|
+
|
|
114
|
+
- Rspress 0.7 or higher
|
|
115
|
+
- Node.js 18 or higher
|
|
116
|
+
- Zephyr Cloud account (sign up at [zephyr-cloud.io](https://zephyr-cloud.io))
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Examples
|
|
121
|
+
|
|
122
|
+
Explore our [examples directory](../../examples/) to see the plugin in action:
|
|
123
|
+
|
|
124
|
+
- [rspress-site](../../examples/rspress-site/) – A simple Rspress documentation site deployed via Zephyr
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Contributing
|
|
129
|
+
|
|
130
|
+
We welcome contributions! Please see our [contributing guidelines](../../CONTRIBUTING.md) before submitting pull requests.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
Licensed under the Apache-2.0 License. See [LICENSE](LICENSE) for more information.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { withZephyr } from './with-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 with_zephyr_1 = require("./with-zephyr");
|
|
5
|
+
Object.defineProperty(exports, "withZephyr", { enumerable: true, get: function () { return with_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,6CAA2C;AAAlC,yGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildAssetMapFromFiles = buildAssetMapFromFiles;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
|
|
6
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
7
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
8
|
+
async function buildAssetMapFromFiles(root, files) {
|
|
9
|
+
const resolvedRoot = node_path_1.default.resolve(root);
|
|
10
|
+
const assetEntries = await Promise.all(files.map(async (rel) => {
|
|
11
|
+
const abs = node_path_1.default.resolve(root, rel);
|
|
12
|
+
if (!abs.startsWith(resolvedRoot)) {
|
|
13
|
+
throw new zephyr_agent_1.ZephyrError(zephyr_agent_1.ZeErrors.ERR_UNKNOWN, {
|
|
14
|
+
message: `Invalid file path: ${rel}`,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const content = await promises_1.default.readFile(abs);
|
|
18
|
+
const source = {
|
|
19
|
+
source: () => content,
|
|
20
|
+
size: () => content.length,
|
|
21
|
+
buffer: () => content,
|
|
22
|
+
};
|
|
23
|
+
return [rel, source];
|
|
24
|
+
}));
|
|
25
|
+
return Object.fromEntries(assetEntries);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=buildAssets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildAssets.js","sourceRoot":"","sources":["../../../src/internal/assets/buildAssets.ts"],"names":[],"mappings":";;AAKA,wDA0BC;;AA/BD,wEAAkC;AAClC,kEAA6B;AAC7B,+CAAqD;AAG9C,KAAK,UAAU,sBAAsB,CAC1C,IAAY,EACZ,KAAe;IAEf,MAAM,YAAY,GAAG,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAExC,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,GAAG,CACpC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACtB,MAAM,GAAG,GAAG,mBAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAEpC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,0BAAW,CAAC,uBAAQ,CAAC,WAAW,EAAE;gBAC1C,OAAO,EAAE,sBAAsB,GAAG,EAAE;aACrC,CAAC,CAAC;QACL,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACvC,MAAM,MAAM,GAAW;YACrB,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO;YACrB,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM;YAC1B,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO;SACtB,CAAC;QACF,OAAO,CAAC,GAAG,EAAE,MAAM,CAAU,CAAC;IAChC,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupZeDeploy = setupZeDeploy;
|
|
4
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
5
|
+
const zephyr_xpack_internal_1 = require("zephyr-xpack-internal");
|
|
6
|
+
const buildStats_1 = require("../stats/buildStats");
|
|
7
|
+
const buildAssets_1 = require("./buildAssets");
|
|
8
|
+
async function setupZeDeploy({ deferEngine, root, files, }) {
|
|
9
|
+
if (!files.length) {
|
|
10
|
+
zephyr_agent_1.ze_log.package('ZeRspressPlugin: No files to process.');
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const [assets, stats] = await Promise.all([
|
|
14
|
+
(0, buildAssets_1.buildAssetMapFromFiles)(root, files),
|
|
15
|
+
Promise.resolve((0, buildStats_1.buildStats)(root, files)),
|
|
16
|
+
]);
|
|
17
|
+
process.nextTick(zephyr_xpack_internal_1.xpack_zephyr_agent, {
|
|
18
|
+
stats,
|
|
19
|
+
stats_json: stats.toJson(),
|
|
20
|
+
assets,
|
|
21
|
+
pluginOptions: {
|
|
22
|
+
pluginName: 'rspress-ssg',
|
|
23
|
+
zephyr_engine: await deferEngine,
|
|
24
|
+
options: {},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=setupZeDeploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupZeDeploy.js","sourceRoot":"","sources":["../../../src/internal/assets/setupZeDeploy.ts"],"names":[],"mappings":";;AAMA,sCAyBC;AA/BD,+CAAsC;AACtC,iEAA2D;AAE3D,oDAAiD;AACjD,+CAAuD;AAEhD,KAAK,UAAU,aAAa,CAAC,EAClC,WAAW,EACX,IAAI,EACJ,KAAK,GACsB;IAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAClB,qBAAM,CAAC,OAAO,CAAC,uCAAuC,CAAC,CAAC;QACxD,OAAO;IACT,CAAC;IAED,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACxC,IAAA,oCAAsB,EAAC,IAAI,EAAE,KAAK,CAAC;QACnC,OAAO,CAAC,OAAO,CAAC,IAAA,uBAAU,EAAC,IAAI,EAAE,KAAK,CAAC,CAAC;KACzC,CAAC,CAAC;IAEH,OAAO,CAAC,QAAQ,CAAC,0CAAkB,EAAE;QACnC,KAAK;QACL,UAAU,EAAE,KAAK,CAAC,MAAM,EAAE;QAC1B,MAAM;QACN,aAAa,EAAE;YACb,UAAU,EAAE,aAAa;YACzB,aAAa,EAAE,MAAM,WAAW;YAChC,OAAO,EAAE,EAAE;SACZ;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function showFiles(dir: string, files: string[]): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.showFiles = showFiles;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
|
|
6
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
7
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
8
|
+
async function showFiles(dir, files) {
|
|
9
|
+
if (files.length === 0) {
|
|
10
|
+
zephyr_agent_1.ze_log.package('No files found in output directory.');
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const statTasks = files.map(async (rel) => {
|
|
14
|
+
const abs = node_path_1.default.join(dir, rel);
|
|
15
|
+
try {
|
|
16
|
+
const stats = await promises_1.default.stat(abs);
|
|
17
|
+
const sizeKB = (stats.size / 1024).toFixed(2);
|
|
18
|
+
zephyr_agent_1.ze_log.package(`${rel} — ${sizeKB} KB`);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
zephyr_agent_1.ze_log.package(`Failed to stat file: ${rel}`);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
await Promise.all(statTasks);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=showFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"showFiles.js","sourceRoot":"","sources":["../../../src/internal/files/showFiles.ts"],"names":[],"mappings":";;AAIA,8BAkBC;;AAtBD,wEAAkC;AAClC,kEAA6B;AAC7B,+CAAsC;AAE/B,KAAK,UAAU,SAAS,CAAC,GAAW,EAAE,KAAe;IAC1D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,qBAAM,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC;QACtD,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACxC,MAAM,GAAG,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,kBAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACjC,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAC9C,qBAAM,CAAC,OAAO,CAAC,GAAG,GAAG,MAAM,MAAM,KAAK,CAAC,CAAC;QAC1C,CAAC;QAAC,MAAM,CAAC;YACP,qBAAM,CAAC,OAAO,CAAC,wBAAwB,GAAG,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function walkFiles(dir: string, prefix?: string): Promise<string[]>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.walkFiles = walkFiles;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
|
|
6
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
7
|
+
async function walkFiles(dir, prefix = '') {
|
|
8
|
+
const entries = await promises_1.default.readdir(dir, { withFileTypes: true });
|
|
9
|
+
const files = [];
|
|
10
|
+
for (const entry of entries) {
|
|
11
|
+
if (entry.isSymbolicLink())
|
|
12
|
+
continue;
|
|
13
|
+
const rel = node_path_1.default.join(prefix, entry.name);
|
|
14
|
+
const full = node_path_1.default.join(dir, entry.name);
|
|
15
|
+
if (entry.isDirectory()) {
|
|
16
|
+
files.push(...(await walkFiles(full, rel)));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
files.push(rel);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return files;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=walkFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walkFiles.js","sourceRoot":"","sources":["../../../src/internal/files/walkFiles.ts"],"names":[],"mappings":";;AAGA,8BAkBC;;AArBD,wEAAkC;AAClC,kEAA6B;AAEtB,KAAK,UAAU,SAAS,CAAC,GAAW,EAAE,MAAM,GAAG,EAAE;IACtD,MAAM,OAAO,GAAG,MAAM,kBAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,cAAc,EAAE;YAAE,SAAS;QAErC,MAAM,GAAG,GAAG,mBAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAExC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildStats = buildStats;
|
|
4
|
+
function buildStats(root, files) {
|
|
5
|
+
return {
|
|
6
|
+
compilation: {
|
|
7
|
+
options: {
|
|
8
|
+
context: root,
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
toJson: () => ({
|
|
12
|
+
assets: files.map((name) => ({ name })),
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=buildStats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildStats.js","sourceRoot":"","sources":["../../../src/internal/stats/buildStats.ts"],"names":[],"mappings":";;AAEA,gCAWC;AAXD,SAAgB,UAAU,CAAC,IAAY,EAAE,KAAe;IACtD,OAAO;QACL,WAAW,EAAE;YACX,OAAO,EAAE;gBACP,OAAO,EAAE,IAAI;aACd;SACF;QACD,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;YACb,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;SACxC,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zephyr-rspress-plugin",
|
|
3
|
+
"version": "0.0.53",
|
|
4
|
+
"description": "Rspress plugin for Zephyr",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/ZephyrCloudIO/zephyr-packages.git",
|
|
8
|
+
"directory": "libs/zephyr-rspress-plugin"
|
|
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-rspress-plugin:build",
|
|
20
|
+
"dev": "nx run zephyr-rspress-plugin:build --watch",
|
|
21
|
+
"patch-version": "pnpm version",
|
|
22
|
+
"test": "jest"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@rsbuild/core": "^1.3.22",
|
|
26
|
+
"@rspress/shared": "catalog:rspress",
|
|
27
|
+
"tslib": "catalog:typescript",
|
|
28
|
+
"zephyr-agent": "workspace:*",
|
|
29
|
+
"zephyr-edge-contract": "workspace:*",
|
|
30
|
+
"zephyr-xpack-internal": "workspace:*"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/is-ci": "catalog:typescript",
|
|
34
|
+
"@types/jest": "catalog:typescript",
|
|
35
|
+
"@types/node-persist": "catalog:typescript",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "catalog:eslint",
|
|
37
|
+
"ts-jest": "catalog:typescript",
|
|
38
|
+
"zephyr-rspack-plugin": "workspace:*"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public",
|
|
42
|
+
"provenance": true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ZephyrEngine } from 'zephyr-agent';
|
|
2
|
+
export interface ZephyrRspressPluginOptions {
|
|
3
|
+
deferEngine: Promise<ZephyrEngine>;
|
|
4
|
+
root: string;
|
|
5
|
+
files: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface Stats {
|
|
8
|
+
compilation: {
|
|
9
|
+
options: {
|
|
10
|
+
context: string;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
assets?: {
|
|
14
|
+
name: string;
|
|
15
|
+
size?: number;
|
|
16
|
+
info?: {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
}[];
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
};
|
|
22
|
+
toJson: (options?: any) => {
|
|
23
|
+
assets?: {
|
|
24
|
+
name: string;
|
|
25
|
+
size?: number;
|
|
26
|
+
emitted?: boolean;
|
|
27
|
+
chunkNames?: string[];
|
|
28
|
+
info?: {
|
|
29
|
+
minimized?: boolean;
|
|
30
|
+
related?: Record<string, string[]>;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
};
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}[];
|
|
35
|
+
errors?: any[];
|
|
36
|
+
warnings?: any[];
|
|
37
|
+
outputPath?: string;
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withZephyr = withZephyr;
|
|
4
|
+
const zephyrRsbuildPlugin_1 = require("./zephyrRsbuildPlugin");
|
|
5
|
+
const zephyrRspressSSGPlugin_1 = require("./zephyrRspressSSGPlugin");
|
|
6
|
+
function withZephyr() {
|
|
7
|
+
return {
|
|
8
|
+
name: 'zephyr-rspress-plugin',
|
|
9
|
+
async config(config, { addPlugin }) {
|
|
10
|
+
const { ssg = false } = config;
|
|
11
|
+
if (ssg) {
|
|
12
|
+
addPlugin((0, zephyrRspressSSGPlugin_1.zephyrRspressSSGPlugin)({ outDir: config.outDir }));
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
config.builderPlugins = [...(config.builderPlugins ?? []), (0, zephyrRsbuildPlugin_1.zephyrRsbuildPlugin)()];
|
|
16
|
+
}
|
|
17
|
+
return config;
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=with-zephyr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-zephyr.js","sourceRoot":"","sources":["../src/with-zephyr.ts"],"names":[],"mappings":";;AAIA,gCAcC;AAjBD,+DAA4D;AAC5D,qEAAkE;AAElE,SAAgB,UAAU;IACxB,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE;YAChC,MAAM,EAAE,GAAG,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;YAE/B,IAAI,GAAG,EAAE,CAAC;gBACR,SAAS,CAAC,IAAA,+CAAsB,EAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YAC/D,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,cAAc,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC,EAAE,IAAA,yCAAmB,GAAE,CAAC,CAAC;YACpF,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zephyrRsbuildPlugin = void 0;
|
|
4
|
+
const zephyr_rspack_plugin_1 = require("zephyr-rspack-plugin");
|
|
5
|
+
const zephyrRsbuildPlugin = () => ({
|
|
6
|
+
name: 'zephyr-rsbuild-plugin',
|
|
7
|
+
setup(api) {
|
|
8
|
+
api.modifyRspackConfig(async (config) => {
|
|
9
|
+
await (0, zephyr_rspack_plugin_1.withZephyr)()(config);
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
exports.zephyrRsbuildPlugin = zephyrRsbuildPlugin;
|
|
14
|
+
//# sourceMappingURL=zephyrRsbuildPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zephyrRsbuildPlugin.js","sourceRoot":"","sources":["../src/zephyrRsbuildPlugin.ts"],"names":[],"mappings":";;;AACA,+DAAkD;AAE3C,MAAM,mBAAmB,GAAG,GAAkB,EAAE,CAAC,CAAC;IACvD,IAAI,EAAE,uBAAuB;IAC7B,KAAK,CAAC,GAAG;QACP,GAAG,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YACtC,MAAM,IAAA,iCAAU,GAAE,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC;AAPU,QAAA,mBAAmB,uBAO7B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zephyrRspressSSGPlugin = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
6
|
+
const zephyr_agent_1 = require("zephyr-agent");
|
|
7
|
+
const setupZeDeploy_1 = require("./internal/assets/setupZeDeploy");
|
|
8
|
+
const showFiles_1 = require("./internal/files/showFiles");
|
|
9
|
+
const walkFiles_1 = require("./internal/files/walkFiles");
|
|
10
|
+
const zephyrRspressSSGPlugin = ({ outDir = 'doc_build' }) => {
|
|
11
|
+
const root = node_path_1.default.resolve(outDir);
|
|
12
|
+
const { zephyr_engine_defer, zephyr_defer_create } = zephyr_agent_1.ZephyrEngine.defer_create();
|
|
13
|
+
zephyr_defer_create({ builder: 'rspack', context: root });
|
|
14
|
+
return {
|
|
15
|
+
name: 'zephyr-rspress-plugin-ssg',
|
|
16
|
+
async afterBuild() {
|
|
17
|
+
try {
|
|
18
|
+
const files = await (0, walkFiles_1.walkFiles)(root);
|
|
19
|
+
if (files.length === 0) {
|
|
20
|
+
zephyr_agent_1.ze_log.upload('No files found in output directory.');
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
await (0, showFiles_1.showFiles)(root, files);
|
|
24
|
+
await (0, setupZeDeploy_1.setupZeDeploy)({ deferEngine: zephyr_engine_defer, root, files });
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
(0, zephyr_agent_1.logFn)('error', zephyr_agent_1.ZephyrError.format(error));
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.zephyrRspressSSGPlugin = zephyrRspressSSGPlugin;
|
|
33
|
+
//# sourceMappingURL=zephyrRspressSSGPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zephyrRspressSSGPlugin.js","sourceRoot":"","sources":["../src/zephyrRspressSSGPlugin.ts"],"names":[],"mappings":";;;;AACA,kEAA6B;AAC7B,+CAAwE;AACxE,mEAAgE;AAChE,0DAAuD;AACvD,0DAAuD;AAEhD,MAAM,sBAAsB,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,EAAiB,EAAE;IAChF,MAAM,IAAI,GAAG,mBAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAElC,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,GAAG,2BAAY,CAAC,YAAY,EAAE,CAAC;IACjF,mBAAmB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAE1D,OAAO;QACL,IAAI,EAAE,2BAA2B;QACjC,KAAK,CAAC,UAAU;YACd,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,IAAA,qBAAS,EAAC,IAAI,CAAC,CAAC;gBAEpC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACvB,qBAAM,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC;oBACrD,OAAO;gBACT,CAAC;gBAED,MAAM,IAAA,qBAAS,EAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBAE7B,MAAM,IAAA,6BAAa,EAAC,EAAE,WAAW,EAAE,mBAAmB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YACzE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAA,oBAAK,EAAC,OAAO,EAAE,0BAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,sBAAsB,0BAyBjC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zephyr-rspress-plugin",
|
|
3
|
+
"version": "0.0.53",
|
|
4
|
+
"description": "Rspress plugin for Zephyr",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/ZephyrCloudIO/zephyr-packages.git",
|
|
8
|
+
"directory": "libs/zephyr-rspress-plugin"
|
|
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
|
+
"@rsbuild/core": "^1.3.22",
|
|
20
|
+
"@rspress/shared": "^1.44.0",
|
|
21
|
+
"tslib": "^2.8.1",
|
|
22
|
+
"zephyr-agent": "0.0.53",
|
|
23
|
+
"zephyr-edge-contract": "0.0.53",
|
|
24
|
+
"zephyr-xpack-internal": "0.0.53"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/is-ci": "3.0.4",
|
|
28
|
+
"@types/jest": "29.5.14",
|
|
29
|
+
"@types/node-persist": "^3.1.8",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^8.27.0",
|
|
31
|
+
"ts-jest": "^29.2.6",
|
|
32
|
+
"zephyr-rspack-plugin": "0.0.53"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public",
|
|
36
|
+
"provenance": true
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "nx run zephyr-rspress-plugin:build",
|
|
40
|
+
"dev": "nx run zephyr-rspress-plugin:build --watch",
|
|
41
|
+
"patch-version": "pnpm version",
|
|
42
|
+
"test": "jest"
|
|
43
|
+
}
|
|
44
|
+
}
|