rspress-plugin-gh-pages 0.1.6-beta.0 → 0.1.7-beta.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 +21 -0
- package/package.json +5 -2
- package/CHANGELOG.md +0 -40
- package/doc_build/index.html +0 -1
- package/doc_build/static/css/styles.178b55c4.css +0 -17
- package/doc_build/static/js/async/975.8dd6696b.js +0 -2
- package/doc_build/static/js/async/975.8dd6696b.js.LICENSE.txt +0 -3
- package/doc_build/static/js/index.4ffb173e.js +0 -2
- package/doc_build/static/js/index.4ffb173e.js.LICENSE.txt +0 -550
- package/doc_build/static/js/lib-lodash.03ab5c9a.js +0 -2
- package/doc_build/static/js/lib-lodash.03ab5c9a.js.LICENSE.txt +0 -445
- package/doc_build/static/js/lib-polyfill.e7809649.js +0 -2
- package/doc_build/static/js/lib-polyfill.e7809649.js.LICENSE.txt +0 -641
- package/doc_build/static/js/lib-react.548287ed.js +0 -2
- package/doc_build/static/js/lib-react.548287ed.js.LICENSE.txt +0 -55
- package/doc_build/static/js/lib-router.6f70bb88.js +0 -2
- package/doc_build/static/js/lib-router.6f70bb88.js.LICENSE.txt +0 -44
- package/doc_build/static/js/styles.5adf8b3b.js +0 -1
- package/doc_build/static/search_index.fb3fdf3b.json +0 -1
- package/docs/index.md +0 -1
- package/rspress.config.ts +0 -14
- package/src/index.ts +0 -93
- package/tsconfig.json +0 -10
package/src/index.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import ghpages from 'gh-pages';
|
|
3
|
-
import { logger } from '@rspress/shared/logger';
|
|
4
|
-
|
|
5
|
-
import type { MarkRequired } from 'rspress-plugin-devkit';
|
|
6
|
-
import type { RspressPlugin } from '@rspress/shared';
|
|
7
|
-
|
|
8
|
-
const DefaultDocBuildOutput = 'doc_build';
|
|
9
|
-
|
|
10
|
-
interface RspressPluginGHPagesOptions
|
|
11
|
-
extends MarkRequired<ghpages.PublishOptions, 'repo'> {
|
|
12
|
-
directory?: string;
|
|
13
|
-
silent?: boolean;
|
|
14
|
-
siteBase?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const logPrefix = chalk.green('[gh-pages]');
|
|
18
|
-
|
|
19
|
-
function normalizeBase(base: string): string {
|
|
20
|
-
return base === '/' || base === ''
|
|
21
|
-
? '/'
|
|
22
|
-
: `/${base.replace(/^\/+|\/+$/g, '')}/`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default function rspressPluginGHPages(
|
|
26
|
-
options: RspressPluginGHPagesOptions,
|
|
27
|
-
): RspressPlugin {
|
|
28
|
-
const {
|
|
29
|
-
repo,
|
|
30
|
-
directory,
|
|
31
|
-
branch = 'gh-pages',
|
|
32
|
-
silent = false,
|
|
33
|
-
siteBase = '',
|
|
34
|
-
...publishOptions
|
|
35
|
-
} = options;
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
name: 'rspress-plugin-gh-pages',
|
|
39
|
-
config(config) {
|
|
40
|
-
let baseFromRepo = repo.includes('github.io')
|
|
41
|
-
? '/'
|
|
42
|
-
: /\/([^\/]+)\.git$/.exec(repo)?.[1];
|
|
43
|
-
|
|
44
|
-
// Use || here to as ?? will consider '' as a valid value
|
|
45
|
-
const base = siteBase || baseFromRepo || '';
|
|
46
|
-
|
|
47
|
-
if (!base) {
|
|
48
|
-
logger.warn(
|
|
49
|
-
`${logPrefix} Failed to parse base from repo, site base path will not be updated.`,
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
return config;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
config.base = normalizeBase(base);
|
|
56
|
-
|
|
57
|
-
return config;
|
|
58
|
-
},
|
|
59
|
-
async afterBuild(config, isBuild) {
|
|
60
|
-
if (!repo) {
|
|
61
|
-
logger.error(
|
|
62
|
-
`Option ${chalk.cyan('repo')} is required for rspress-plugin-gh-pages.`,
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!isBuild) return;
|
|
67
|
-
|
|
68
|
-
const publishDir = directory ?? config.outDir ?? DefaultDocBuildOutput;
|
|
69
|
-
|
|
70
|
-
if (!silent) {
|
|
71
|
-
logger.info(
|
|
72
|
-
`${logPrefix} Publish directory: ${chalk.cyan(publishDir)}`,
|
|
73
|
-
);
|
|
74
|
-
logger.info(`${logPrefix} Publish branch: ${chalk.cyan(branch)}`);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
await ghpages.publish(publishDir, {
|
|
79
|
-
repo,
|
|
80
|
-
branch,
|
|
81
|
-
...publishOptions,
|
|
82
|
-
});
|
|
83
|
-
} catch (error) {
|
|
84
|
-
silent
|
|
85
|
-
? void 0
|
|
86
|
-
: logger.error(`${logPrefix} Failed to publish: ${error}`);
|
|
87
|
-
process.exit(1);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
silent ? void 0 : logger.success(`${logPrefix} Page Published.`);
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}
|