@docusaurus/core 2.0.0-beta.1decd6f80 → 2.0.0-beta.20
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/bin/beforeCli.mjs +138 -0
- package/bin/docusaurus.mjs +228 -0
- package/lib/babel/preset.d.ts +8 -3
- package/lib/babel/preset.js +8 -7
- package/lib/client/.eslintrc.js +2 -4
- package/lib/client/App.d.ts +2 -3
- package/lib/client/App.js +30 -27
- package/lib/client/BaseUrlIssueBanner/index.d.ts +27 -0
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.js → BaseUrlIssueBanner/index.js} +24 -14
- package/lib/client/{baseUrlIssueBanner → BaseUrlIssueBanner}/styles.module.css +0 -0
- package/lib/client/ClientLifecyclesDispatcher.d.ts +16 -0
- package/lib/client/ClientLifecyclesDispatcher.js +39 -0
- package/lib/client/LinksCollector.d.ts +3 -3
- package/lib/client/LinksCollector.js +8 -13
- package/lib/client/PendingNavigation.d.ts +17 -3
- package/lib/client/PendingNavigation.js +39 -72
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.d.ts → SiteMetadataDefaults.d.ts} +1 -2
- package/lib/client/SiteMetadataDefaults.js +19 -0
- package/lib/{choosePort.d.ts → client/browserContext.d.ts} +5 -5
- package/lib/client/browserContext.js +22 -0
- package/lib/client/clientEntry.js +14 -9
- package/lib/client/docusaurus.d.ts +11 -5
- package/lib/client/docusaurus.js +29 -42
- package/lib/client/docusaurusContext.d.ts +12 -0
- package/lib/client/docusaurusContext.js +25 -0
- package/lib/client/exports/BrowserOnly.d.ts +3 -5
- package/lib/client/exports/BrowserOnly.js +14 -7
- package/lib/client/exports/ComponentCreator.d.ts +1 -2
- package/lib/client/exports/ComponentCreator.js +67 -41
- package/lib/client/exports/ErrorBoundary.d.ts +18 -0
- package/lib/client/exports/ErrorBoundary.js +35 -0
- package/lib/client/exports/Head.d.ts +2 -3
- package/lib/client/exports/Head.js +3 -4
- package/lib/client/exports/Interpolate.d.ts +2 -2
- package/lib/client/exports/Interpolate.js +20 -49
- package/lib/client/exports/Link.d.ts +4 -10
- package/lib/client/exports/Link.js +44 -38
- package/lib/client/exports/Translate.d.ts +1 -1
- package/lib/client/exports/Translate.js +14 -9
- package/lib/client/exports/constants.js +1 -11
- package/lib/client/exports/isInternalUrl.js +1 -1
- package/lib/client/exports/renderRoutes.d.ts +1 -2
- package/lib/client/exports/renderRoutes.js +1 -2
- package/lib/client/exports/router.d.ts +1 -1
- package/lib/client/exports/router.js +1 -1
- package/lib/client/exports/useBaseUrl.js +11 -14
- package/lib/client/exports/useDocusaurusContext.d.ts +2 -3
- package/lib/client/exports/useDocusaurusContext.js +3 -9
- package/lib/client/exports/useGlobalData.d.ts +4 -3
- package/lib/client/exports/useGlobalData.js +9 -13
- package/lib/{server/versions/__tests/index.test.d.ts → client/exports/useIsBrowser.d.ts} +1 -1
- package/lib/client/exports/useIsBrowser.js +11 -0
- package/lib/client/exports/useRouteContext.d.ts +8 -0
- package/lib/client/exports/useRouteContext.js +15 -0
- package/lib/client/flat.d.ts +12 -2
- package/lib/client/flat.js +19 -15
- package/lib/client/normalizeLocation.d.ts +2 -5
- package/lib/client/normalizeLocation.js +14 -10
- package/lib/client/prefetch.d.ts +1 -2
- package/lib/client/prefetch.js +11 -31
- package/lib/client/preload.d.ts +3 -4
- package/lib/client/preload.js +7 -12
- package/lib/client/routeContext.d.ts +13 -0
- package/lib/client/routeContext.js +31 -0
- package/lib/client/serverEntry.d.ts +10 -0
- package/lib/client/serverEntry.js +91 -132
- package/lib/client/theme-fallback/Error/index.d.ts +10 -0
- package/lib/client/theme-fallback/Error/index.js +45 -0
- package/lib/client/theme-fallback/Layout/index.d.ts +10 -0
- package/lib/client/theme-fallback/Layout/index.js +2 -26
- package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
- package/lib/client/theme-fallback/Loading/index.js +49 -115
- package/lib/client/{exports/context.js → theme-fallback/NotFound/index.d.ts} +2 -2
- package/lib/client/theme-fallback/NotFound/index.js +19 -18
- package/lib/client/theme-fallback/Root/index.d.ts +10 -0
- package/lib/client/theme-fallback/Root/index.js +2 -6
- package/lib/{server/html-tags/htmlTags.d.ts → client/theme-fallback/SiteMetadata/index.d.ts} +2 -1
- package/lib/client/theme-fallback/SiteMetadata/index.js +10 -0
- package/lib/commands/build.d.ts +6 -2
- package/lib/commands/build.js +77 -61
- package/lib/commands/clear.d.ts +7 -1
- package/lib/commands/clear.js +32 -20
- package/lib/commands/deploy.d.ts +5 -2
- package/lib/commands/deploy.js +91 -71
- package/lib/commands/external.d.ts +2 -2
- package/lib/commands/external.js +6 -11
- package/lib/commands/serve.d.ts +7 -2
- package/lib/commands/serve.js +31 -18
- package/lib/commands/start.d.ts +8 -2
- package/lib/commands/start.js +105 -91
- package/lib/commands/swizzle/actions.d.ts +23 -0
- package/lib/commands/swizzle/actions.js +102 -0
- package/lib/commands/swizzle/common.d.ts +33 -0
- package/lib/commands/swizzle/common.js +56 -0
- package/lib/commands/swizzle/components.d.ts +29 -0
- package/lib/commands/swizzle/components.js +200 -0
- package/lib/commands/swizzle/config.d.ts +10 -0
- package/lib/commands/swizzle/config.js +83 -0
- package/lib/{server/client-modules/index.d.ts → commands/swizzle/context.d.ts} +2 -2
- package/lib/commands/swizzle/context.js +24 -0
- package/lib/commands/swizzle/index.d.ts +8 -0
- package/lib/commands/swizzle/index.js +116 -0
- package/lib/commands/swizzle/prompts.d.ts +12 -0
- package/lib/commands/swizzle/prompts.js +110 -0
- package/lib/{client/exports/context.d.ts → commands/swizzle/tables.d.ts} +3 -4
- package/lib/commands/swizzle/tables.js +113 -0
- package/lib/commands/swizzle/themes.d.ts +20 -0
- package/lib/commands/swizzle/themes.js +106 -0
- package/lib/commands/writeHeadingIds.d.ts +2 -6
- package/lib/commands/writeHeadingIds.js +21 -81
- package/lib/commands/writeTranslations.d.ts +4 -5
- package/lib/commands/writeTranslations.js +41 -23
- package/lib/index.d.ts +9 -9
- package/lib/index.js +14 -14
- package/lib/server/brokenLinks.d.ts +4 -17
- package/lib/server/brokenLinks.js +65 -54
- package/lib/server/clientModules.d.ts +12 -0
- package/lib/server/clientModules.js +20 -0
- package/lib/server/config.d.ts +5 -2
- package/lib/server/config.js +14 -6
- package/lib/server/configValidation.d.ts +4 -2
- package/lib/server/configValidation.js +96 -39
- package/lib/server/getHostPort.d.ts +14 -0
- package/lib/server/getHostPort.js +79 -0
- package/lib/server/htmlTags.d.ts +12 -0
- package/lib/server/htmlTags.js +62 -0
- package/lib/server/i18n.d.ts +3 -13
- package/lib/server/i18n.js +19 -55
- package/lib/server/index.d.ts +28 -6
- package/lib/server/index.js +82 -171
- package/lib/server/plugins/configs.d.ts +51 -0
- package/lib/server/plugins/configs.js +101 -0
- package/lib/server/plugins/index.d.ts +10 -10
- package/lib/server/plugins/index.js +74 -125
- package/lib/server/plugins/init.d.ts +6 -9
- package/lib/server/plugins/init.js +43 -108
- package/lib/server/plugins/moduleShorthand.d.ts +9 -0
- package/lib/server/plugins/moduleShorthand.js +46 -0
- package/lib/server/plugins/pluginIds.d.ts +6 -2
- package/lib/server/plugins/pluginIds.js +12 -7
- package/lib/server/plugins/presets.d.ts +12 -0
- package/lib/server/plugins/presets.js +49 -0
- package/lib/server/plugins/routeConfig.d.ts +11 -0
- package/lib/server/plugins/routeConfig.js +54 -0
- package/lib/server/plugins/synthetic.d.ts +20 -0
- package/lib/server/plugins/synthetic.js +112 -0
- package/lib/server/routes.d.ts +39 -7
- package/lib/server/routes.js +185 -95
- package/lib/server/siteMetadata.d.ts +12 -0
- package/lib/server/siteMetadata.js +81 -0
- package/lib/server/translations/translations.d.ts +13 -17
- package/lib/server/translations/translations.js +37 -61
- package/lib/server/translations/translationsExtractor.d.ts +10 -5
- package/lib/server/translations/translationsExtractor.js +159 -121
- package/lib/server/utils.d.ts +9 -3
- package/lib/server/utils.js +7 -9
- package/lib/webpack/aliases/index.d.ts +34 -0
- package/lib/webpack/aliases/index.js +106 -0
- package/lib/webpack/base.d.ts +3 -4
- package/lib/webpack/base.js +53 -55
- package/lib/webpack/client.d.ts +3 -3
- package/lib/webpack/client.js +12 -19
- package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +13 -3
- package/lib/webpack/plugins/ChunkAssetPlugin.js +24 -17
- package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +8 -8
- package/lib/webpack/plugins/CleanWebpackPlugin.js +10 -16
- package/lib/webpack/plugins/LogPlugin.d.ts +1 -1
- package/lib/webpack/plugins/LogPlugin.js +4 -5
- package/lib/webpack/plugins/WaitPlugin.d.ts +3 -3
- package/lib/webpack/plugins/WaitPlugin.js +1 -1
- package/lib/webpack/server.d.ts +5 -5
- package/lib/webpack/server.js +18 -8
- package/lib/{client → webpack}/templates/index.html.template.ejs +0 -0
- package/lib/webpack/templates/ssr.html.template.d.ts +8 -0
- package/lib/{client → webpack}/templates/ssr.html.template.js +5 -4
- package/lib/webpack/utils.d.ts +16 -31
- package/lib/webpack/utils.js +59 -177
- package/package.json +77 -73
- package/bin/docusaurus.js +0 -326
- package/lib/.tsbuildinfo +0 -5682
- package/lib/choosePort.js +0 -105
- package/lib/client/.tsbuildinfo +0 -4127
- package/lib/client/client-lifecycles-dispatcher.d.ts +0 -12
- package/lib/client/client-lifecycles-dispatcher.js +0 -27
- package/lib/client/nprogress.css +0 -36
- package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
- package/lib/commands/buildRemoteBranchUrl.js +0 -27
- package/lib/commands/commandUtils.d.ts +0 -3
- package/lib/commands/commandUtils.js +0 -21
- package/lib/commands/swizzle.d.ts +0 -9
- package/lib/commands/swizzle.js +0 -245
- package/lib/constants.d.ts +0 -18
- package/lib/constants.js +0 -23
- package/lib/server/client-modules/index.js +0 -14
- package/lib/server/duplicateRoutes.d.ts +0 -10
- package/lib/server/duplicateRoutes.js +0 -38
- package/lib/server/html-tags/htmlTags.js +0 -39
- package/lib/server/html-tags/index.d.ts +0 -9
- package/lib/server/html-tags/index.js +0 -43
- package/lib/server/loadSetup.d.ts +0 -9
- package/lib/server/loadSetup.js +0 -25
- package/lib/server/presets/index.d.ts +0 -11
- package/lib/server/presets/index.js +0 -48
- package/lib/server/themes/alias.d.ts +0 -8
- package/lib/server/themes/alias.js +0 -39
- package/lib/server/themes/index.d.ts +0 -8
- package/lib/server/themes/index.js +0 -35
- package/lib/server/versions/__fixtures__/dummy-plugin.js +0 -0
- package/lib/server/versions/__fixtures__/package.json +0 -3
- package/lib/server/versions/__tests/index.test.js +0 -25
- package/lib/server/versions/index.d.ts +0 -10
- package/lib/server/versions/index.js +0 -50
- package/lib/webpack/react-dev-utils-webpack5/README.md +0 -11
- package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.js +0 -57
- package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +0 -138
- package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.js +0 -285
- package/lib/webpack/sharedModuleAliases.d.ts +0 -10
- package/lib/webpack/sharedModuleAliases.js +0 -18
- package/tsconfig.client.json +0 -13
- package/tsconfig.json +0 -13
package/lib/commands/build.d.ts
CHANGED
|
@@ -4,5 +4,9 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
export
|
|
7
|
+
import { type LoadContextOptions } from '../server';
|
|
8
|
+
export declare type BuildCLIOptions = Pick<LoadContextOptions, 'config' | 'locale' | 'outDir'> & {
|
|
9
|
+
bundleAnalyzer?: boolean;
|
|
10
|
+
minify?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function build(siteDir: string, cliOptions: Partial<BuildCLIOptions>, forceTerminate?: boolean): Promise<string>;
|
package/lib/commands/build.js
CHANGED
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.build = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
|
-
const
|
|
11
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
11
12
|
const copy_webpack_plugin_1 = tslib_1.__importDefault(require("copy-webpack-plugin"));
|
|
12
13
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
13
14
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
14
15
|
const react_loadable_ssr_addon_v5_slorber_1 = tslib_1.__importDefault(require("react-loadable-ssr-addon-v5-slorber"));
|
|
15
16
|
const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
|
|
16
17
|
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
17
|
-
const constants_1 = require("../constants");
|
|
18
18
|
const server_1 = require("../server");
|
|
19
19
|
const brokenLinks_1 = require("../server/brokenLinks");
|
|
20
20
|
const client_1 = tslib_1.__importDefault(require("../webpack/client"));
|
|
@@ -23,12 +23,17 @@ const utils_1 = require("../webpack/utils");
|
|
|
23
23
|
const CleanWebpackPlugin_1 = tslib_1.__importDefault(require("../webpack/plugins/CleanWebpackPlugin"));
|
|
24
24
|
const i18n_1 = require("../server/i18n");
|
|
25
25
|
const utils_2 = require("@docusaurus/utils");
|
|
26
|
-
async function build(siteDir, cliOptions
|
|
27
|
-
//
|
|
26
|
+
async function build(siteDir, cliOptions,
|
|
27
|
+
// When running build, we force terminate the process to prevent async
|
|
28
|
+
// operations from never returning. However, if run as part of docusaurus
|
|
29
|
+
// deploy, we have to let deploy finish.
|
|
30
|
+
// See https://github.com/facebook/docusaurus/pull/2496
|
|
28
31
|
forceTerminate = true) {
|
|
32
|
+
['SIGINT', 'SIGTERM'].forEach((sig) => {
|
|
33
|
+
process.on(sig, () => process.exit());
|
|
34
|
+
});
|
|
29
35
|
async function tryToBuildLocale({ locale, isLastLocale, }) {
|
|
30
36
|
try {
|
|
31
|
-
// console.log(chalk.green(`Site successfully built in locale=${locale}`));
|
|
32
37
|
return await buildLocale({
|
|
33
38
|
siteDir,
|
|
34
39
|
locale,
|
|
@@ -37,101 +42,110 @@ forceTerminate = true) {
|
|
|
37
42
|
isLastLocale,
|
|
38
43
|
});
|
|
39
44
|
}
|
|
40
|
-
catch (
|
|
41
|
-
|
|
42
|
-
throw
|
|
45
|
+
catch (err) {
|
|
46
|
+
logger_1.default.error `Unable to build website for locale name=${locale}.`;
|
|
47
|
+
throw err;
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
|
-
const context = await server_1.loadContext(
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
const context = await (0, server_1.loadContext)({
|
|
51
|
+
siteDir,
|
|
52
|
+
outDir: cliOptions.outDir,
|
|
53
|
+
config: cliOptions.config,
|
|
48
54
|
locale: cliOptions.locale,
|
|
49
55
|
localizePath: cliOptions.locale ? false : undefined,
|
|
50
56
|
});
|
|
51
|
-
const i18n = await i18n_1.loadI18n(context.siteConfig, {
|
|
57
|
+
const i18n = await (0, i18n_1.loadI18n)(context.siteConfig, {
|
|
52
58
|
locale: cliOptions.locale,
|
|
53
59
|
});
|
|
54
60
|
if (cliOptions.locale) {
|
|
55
61
|
return tryToBuildLocale({ locale: cliOptions.locale, isLastLocale: true });
|
|
56
62
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
console.log(chalk_1.default.yellow(`\nSite will be built for all these locales:
|
|
60
|
-
- ${i18n.locales.join('\n- ')}`));
|
|
61
|
-
}
|
|
62
|
-
// We need the default locale to always be the 1st in the list
|
|
63
|
-
// If we build it last, it would "erase" the localized sites built in subfolders
|
|
64
|
-
const orderedLocales = [
|
|
65
|
-
i18n.defaultLocale,
|
|
66
|
-
...i18n.locales.filter((locale) => locale !== i18n.defaultLocale),
|
|
67
|
-
];
|
|
68
|
-
const results = await utils_2.mapAsyncSequencial(orderedLocales, (locale) => {
|
|
69
|
-
const isLastLocale = orderedLocales.indexOf(locale) === orderedLocales.length - 1;
|
|
70
|
-
return tryToBuildLocale({ locale, isLastLocale });
|
|
71
|
-
});
|
|
72
|
-
return results[0];
|
|
63
|
+
if (i18n.locales.length > 1) {
|
|
64
|
+
logger_1.default.info `Website will be built for all these locales: ${i18n.locales}`;
|
|
73
65
|
}
|
|
66
|
+
// We need the default locale to always be the 1st in the list. If we build it
|
|
67
|
+
// last, it would "erase" the localized sites built in sub-folders
|
|
68
|
+
const orderedLocales = [
|
|
69
|
+
i18n.defaultLocale,
|
|
70
|
+
...i18n.locales.filter((locale) => locale !== i18n.defaultLocale),
|
|
71
|
+
];
|
|
72
|
+
const results = await (0, utils_2.mapAsyncSequential)(orderedLocales, (locale) => {
|
|
73
|
+
const isLastLocale = orderedLocales.indexOf(locale) === orderedLocales.length - 1;
|
|
74
|
+
return tryToBuildLocale({ locale, isLastLocale });
|
|
75
|
+
});
|
|
76
|
+
return results[0];
|
|
74
77
|
}
|
|
75
|
-
exports.
|
|
78
|
+
exports.build = build;
|
|
76
79
|
async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLastLocale, }) {
|
|
77
80
|
process.env.BABEL_ENV = 'production';
|
|
78
81
|
process.env.NODE_ENV = 'production';
|
|
79
|
-
|
|
80
|
-
const props = await server_1.load(
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
logger_1.default.info `name=${`[${locale}]`} Creating an optimized production build...`;
|
|
83
|
+
const props = await (0, server_1.load)({
|
|
84
|
+
siteDir,
|
|
85
|
+
outDir: cliOptions.outDir,
|
|
86
|
+
config: cliOptions.config,
|
|
83
87
|
locale,
|
|
84
88
|
localizePath: cliOptions.locale ? false : undefined,
|
|
85
89
|
});
|
|
86
90
|
// Apply user webpack config.
|
|
87
|
-
const { outDir, generatedFilesDir, plugins, siteConfig: { baseUrl, onBrokenLinks }, routes, } = props;
|
|
91
|
+
const { outDir, generatedFilesDir, plugins, siteConfig: { baseUrl, onBrokenLinks, staticDirectories: staticDirectoriesOption, }, routes, } = props;
|
|
88
92
|
const clientManifestPath = path_1.default.join(generatedFilesDir, 'client-manifest.json');
|
|
89
|
-
let clientConfig = webpack_merge_1.default(client_1.default(props, cliOptions.minify), {
|
|
93
|
+
let clientConfig = (0, webpack_merge_1.default)(await (0, client_1.default)(props, cliOptions.minify), {
|
|
90
94
|
plugins: [
|
|
91
95
|
// Remove/clean build folders before building bundles.
|
|
92
96
|
new CleanWebpackPlugin_1.default({ verbose: false }),
|
|
93
|
-
// Visualize size of webpack output files with an interactive zoomable
|
|
97
|
+
// Visualize size of webpack output files with an interactive zoomable
|
|
98
|
+
// tree map.
|
|
94
99
|
cliOptions.bundleAnalyzer && new webpack_bundle_analyzer_1.BundleAnalyzerPlugin(),
|
|
95
100
|
// Generate client manifests file that will be used for server bundle.
|
|
96
101
|
new react_loadable_ssr_addon_v5_slorber_1.default({
|
|
97
102
|
filename: clientManifestPath,
|
|
98
103
|
}),
|
|
99
|
-
].filter(Boolean),
|
|
104
|
+
].filter((x) => Boolean(x)),
|
|
100
105
|
});
|
|
101
106
|
const allCollectedLinks = {};
|
|
102
|
-
|
|
107
|
+
const headTags = {};
|
|
108
|
+
let serverConfig = await (0, server_2.default)({
|
|
103
109
|
props,
|
|
104
110
|
onLinksCollected: (staticPagePath, links) => {
|
|
105
111
|
allCollectedLinks[staticPagePath] = links;
|
|
106
112
|
},
|
|
113
|
+
onHeadTagsCollected: (staticPagePath, tags) => {
|
|
114
|
+
headTags[staticPagePath] = tags;
|
|
115
|
+
},
|
|
107
116
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
117
|
+
// The staticDirectories option can contain empty directories, or non-existent
|
|
118
|
+
// directories (e.g. user deleted `static`). Instead of issuing an error, we
|
|
119
|
+
// just silently filter them out, because user could have never configured it
|
|
120
|
+
// in the first place (the default option should always "work").
|
|
121
|
+
const staticDirectories = (await Promise.all(staticDirectoriesOption.map(async (dir) => {
|
|
122
|
+
const staticDir = path_1.default.resolve(siteDir, dir);
|
|
123
|
+
if ((await fs_extra_1.default.pathExists(staticDir)) &&
|
|
124
|
+
(await fs_extra_1.default.readdir(staticDir)).length > 0) {
|
|
125
|
+
return staticDir;
|
|
126
|
+
}
|
|
127
|
+
return '';
|
|
128
|
+
}))).filter(Boolean);
|
|
129
|
+
if (staticDirectories.length > 0) {
|
|
130
|
+
serverConfig = (0, webpack_merge_1.default)(serverConfig, {
|
|
111
131
|
plugins: [
|
|
112
132
|
new copy_webpack_plugin_1.default({
|
|
113
|
-
patterns:
|
|
114
|
-
{
|
|
115
|
-
from: staticDir,
|
|
116
|
-
to: outDir,
|
|
117
|
-
},
|
|
118
|
-
],
|
|
133
|
+
patterns: staticDirectories.map((dir) => ({ from: dir, to: outDir })),
|
|
119
134
|
}),
|
|
120
135
|
],
|
|
121
136
|
});
|
|
122
137
|
}
|
|
123
138
|
// Plugin Lifecycle - configureWebpack and configurePostCss.
|
|
124
139
|
plugins.forEach((plugin) => {
|
|
125
|
-
var _a, _b;
|
|
126
140
|
const { configureWebpack, configurePostCss } = plugin;
|
|
127
141
|
if (configurePostCss) {
|
|
128
|
-
clientConfig = utils_1.applyConfigurePostCss(configurePostCss, clientConfig);
|
|
142
|
+
clientConfig = (0, utils_1.applyConfigurePostCss)(configurePostCss.bind(plugin), clientConfig);
|
|
129
143
|
}
|
|
130
144
|
if (configureWebpack) {
|
|
131
|
-
clientConfig = utils_1.applyConfigureWebpack(configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`.
|
|
132
|
-
clientConfig, false,
|
|
133
|
-
serverConfig = utils_1.applyConfigureWebpack(configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`.
|
|
134
|
-
serverConfig, true,
|
|
145
|
+
clientConfig = (0, utils_1.applyConfigureWebpack)(configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`.
|
|
146
|
+
clientConfig, false, props.siteConfig.webpack?.jsLoader, plugin.content);
|
|
147
|
+
serverConfig = (0, utils_1.applyConfigureWebpack)(configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`.
|
|
148
|
+
serverConfig, true, props.siteConfig.webpack?.jsLoader, plugin.content);
|
|
135
149
|
}
|
|
136
150
|
});
|
|
137
151
|
// Make sure generated client-manifest is cleaned first so we don't reuse
|
|
@@ -140,11 +154,9 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
|
|
|
140
154
|
await fs_extra_1.default.unlink(clientManifestPath);
|
|
141
155
|
}
|
|
142
156
|
// Run webpack to build JS bundle (client) and static html files (server).
|
|
143
|
-
await utils_1.compile([clientConfig, serverConfig]);
|
|
157
|
+
await (0, utils_1.compile)([clientConfig, serverConfig]);
|
|
144
158
|
// Remove server.bundle.js because it is not needed.
|
|
145
|
-
if (serverConfig.output
|
|
146
|
-
serverConfig.output.filename &&
|
|
147
|
-
typeof serverConfig.output.filename === 'string') {
|
|
159
|
+
if (typeof serverConfig.output?.filename === 'string') {
|
|
148
160
|
const serverBundle = path_1.default.join(outDir, serverConfig.output.filename);
|
|
149
161
|
if (await fs_extra_1.default.pathExists(serverBundle)) {
|
|
150
162
|
await fs_extra_1.default.unlink(serverBundle);
|
|
@@ -155,18 +167,22 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
|
|
|
155
167
|
if (!plugin.postBuild) {
|
|
156
168
|
return;
|
|
157
169
|
}
|
|
158
|
-
await plugin.postBuild(
|
|
170
|
+
await plugin.postBuild({
|
|
171
|
+
...props,
|
|
172
|
+
head: headTags,
|
|
173
|
+
content: plugin.content,
|
|
174
|
+
});
|
|
159
175
|
}));
|
|
160
|
-
await brokenLinks_1.handleBrokenLinks({
|
|
176
|
+
await (0, brokenLinks_1.handleBrokenLinks)({
|
|
161
177
|
allCollectedLinks,
|
|
162
178
|
routes,
|
|
163
179
|
onBrokenLinks,
|
|
164
180
|
outDir,
|
|
165
181
|
baseUrl,
|
|
166
182
|
});
|
|
167
|
-
|
|
183
|
+
logger_1.default.success `Generated static files in path=${path_1.default.relative(process.cwd(), outDir)}.`;
|
|
168
184
|
if (isLastLocale) {
|
|
169
|
-
|
|
185
|
+
logger_1.default.info `Use code=${'npm run serve'} command to test your build locally.`;
|
|
170
186
|
}
|
|
171
187
|
if (forceTerminate && isLastLocale && !cliOptions.bundleAnalyzer) {
|
|
172
188
|
process.exit(0);
|
package/lib/commands/clear.d.ts
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
export declare function clear(siteDir: string): Promise<void>;
|
package/lib/commands/clear.js
CHANGED
|
@@ -1,32 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
2
|
/**
|
|
5
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
4
|
*
|
|
7
5
|
* This source code is licensed under the MIT license found in the
|
|
8
6
|
* LICENSE file in the root directory of this source tree.
|
|
9
7
|
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.clear = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
10
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
11
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
function removePath(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
14
|
+
const utils_1 = require("@docusaurus/utils");
|
|
15
|
+
async function removePath(entry) {
|
|
16
|
+
if (!(await fs_extra_1.default.pathExists(entry.path))) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
await fs_extra_1.default.remove(entry.path);
|
|
21
|
+
logger_1.default.success `Removed the ${entry.description} at path=${entry.path}.`;
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
logger_1.default.error `Could not remove the ${entry.description} at path=${entry.path}.`;
|
|
25
|
+
logger_1.default.error(err);
|
|
26
|
+
}
|
|
24
27
|
}
|
|
25
28
|
async function clear(siteDir) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const generatedFolder = {
|
|
30
|
+
path: path_1.default.join(siteDir, utils_1.GENERATED_FILES_DIR_NAME),
|
|
31
|
+
description: 'generated folder',
|
|
32
|
+
};
|
|
33
|
+
const buildFolder = {
|
|
34
|
+
path: path_1.default.join(siteDir, utils_1.DEFAULT_BUILD_DIR_NAME),
|
|
35
|
+
description: 'build output folder',
|
|
36
|
+
};
|
|
37
|
+
// In Yarn PnP, cache is stored in `.yarn/.cache` because n_m doesn't exist
|
|
38
|
+
const cacheFolders = ['node_modules', '.yarn'].map((p) => ({
|
|
39
|
+
path: path_1.default.join(siteDir, p, '.cache'),
|
|
40
|
+
description: 'Webpack persistent cache folder',
|
|
41
|
+
}));
|
|
42
|
+
await Promise.all([generatedFolder, buildFolder, ...cacheFolders].map(removePath));
|
|
31
43
|
}
|
|
32
|
-
exports.
|
|
44
|
+
exports.clear = clear;
|
package/lib/commands/deploy.d.ts
CHANGED
|
@@ -4,5 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
export
|
|
7
|
+
import { type LoadContextOptions } from '../server';
|
|
8
|
+
export declare type DeployCLIOptions = Pick<LoadContextOptions, 'config' | 'locale' | 'outDir'> & {
|
|
9
|
+
skipBuild?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function deploy(siteDir: string, cliOptions: Partial<DeployCLIOptions>): Promise<void>;
|
package/lib/commands/deploy.js
CHANGED
|
@@ -6,15 +6,16 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.deploy = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
11
12
|
const shelljs_1 = tslib_1.__importDefault(require("shelljs"));
|
|
12
|
-
const
|
|
13
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
14
|
+
const utils_1 = require("@docusaurus/utils");
|
|
13
15
|
const server_1 = require("../server");
|
|
14
|
-
const build_1 =
|
|
16
|
+
const build_1 = require("./build");
|
|
15
17
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
16
18
|
const os_1 = tslib_1.__importDefault(require("os"));
|
|
17
|
-
const buildRemoteBranchUrl_1 = require("./buildRemoteBranchUrl");
|
|
18
19
|
// GIT_PASS env variable should not appear in logs
|
|
19
20
|
function obfuscateGitPass(str) {
|
|
20
21
|
const gitPass = process.env.GIT_PASS;
|
|
@@ -25,72 +26,101 @@ function obfuscateGitPass(str) {
|
|
|
25
26
|
function shellExecLog(cmd) {
|
|
26
27
|
try {
|
|
27
28
|
const result = shelljs_1.default.exec(cmd);
|
|
28
|
-
|
|
29
|
+
logger_1.default.info `code=${obfuscateGitPass(cmd)} subdue=${`code: ${result.code}`}`;
|
|
29
30
|
return result;
|
|
30
31
|
}
|
|
31
|
-
catch (
|
|
32
|
-
|
|
33
|
-
throw
|
|
32
|
+
catch (err) {
|
|
33
|
+
logger_1.default.error `code=${obfuscateGitPass(cmd)}`;
|
|
34
|
+
throw err;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
async function deploy(siteDir, cliOptions
|
|
37
|
-
const { outDir, siteConfig, siteConfigPath } = await server_1.loadContext(
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
async function deploy(siteDir, cliOptions) {
|
|
38
|
+
const { outDir, siteConfig, siteConfigPath } = await (0, server_1.loadContext)({
|
|
39
|
+
siteDir,
|
|
40
|
+
config: cliOptions.config,
|
|
41
|
+
outDir: cliOptions.outDir,
|
|
40
42
|
});
|
|
41
|
-
|
|
43
|
+
if (typeof siteConfig.trailingSlash === 'undefined') {
|
|
44
|
+
logger_1.default.warn(`When deploying to GitHub Pages, it is better to use an explicit "trailingSlash" site config.
|
|
45
|
+
Otherwise, GitHub Pages will add an extra trailing slash to your site urls only on direct-access (not when navigation) with a server redirect.
|
|
46
|
+
This behavior can have SEO impacts and create relative link issues.
|
|
47
|
+
`);
|
|
48
|
+
}
|
|
49
|
+
logger_1.default.info('Deploy command invoked...');
|
|
42
50
|
if (!shelljs_1.default.which('git')) {
|
|
43
51
|
throw new Error('Git not installed or on the PATH!');
|
|
44
52
|
}
|
|
53
|
+
// Source repo is the repo from where the command is invoked
|
|
54
|
+
const sourceRepoUrl = shelljs_1.default
|
|
55
|
+
.exec('git config --get remote.origin.url', { silent: true })
|
|
56
|
+
.stdout.trim();
|
|
57
|
+
// The source branch; defaults to the currently checked out branch
|
|
58
|
+
const sourceBranch = process.env.CURRENT_BRANCH ||
|
|
59
|
+
shelljs_1.default.exec('git rev-parse --abbrev-ref HEAD', { silent: true }).stdout.trim();
|
|
45
60
|
const gitUser = process.env.GIT_USER;
|
|
46
|
-
|
|
47
|
-
|
|
61
|
+
let useSSH = process.env.USE_SSH !== undefined &&
|
|
62
|
+
process.env.USE_SSH.toLowerCase() === 'true';
|
|
63
|
+
if (!gitUser && !useSSH) {
|
|
64
|
+
// If USE_SSH is unspecified: try inferring from repo URL
|
|
65
|
+
if (process.env.USE_SSH === undefined && (0, utils_1.hasSSHProtocol)(sourceRepoUrl)) {
|
|
66
|
+
useSSH = true;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new Error('Please set the GIT_USER environment variable, or explicitly specify USE_SSH instead!');
|
|
70
|
+
}
|
|
48
71
|
}
|
|
49
|
-
// The branch that contains the latest docs changes that will be deployed.
|
|
50
|
-
const currentBranch = process.env.CURRENT_BRANCH ||
|
|
51
|
-
shelljs_1.default.exec('git rev-parse --abbrev-ref HEAD').stdout.trim();
|
|
52
72
|
const organizationName = process.env.ORGANIZATION_NAME ||
|
|
53
73
|
process.env.CIRCLE_PROJECT_USERNAME ||
|
|
54
74
|
siteConfig.organizationName;
|
|
55
75
|
if (!organizationName) {
|
|
56
|
-
throw new Error(`Missing project organization name. Did you forget to define
|
|
76
|
+
throw new Error(`Missing project organization name. Did you forget to define "organizationName" in ${siteConfigPath}? You may also export it via the ORGANIZATION_NAME environment variable.`);
|
|
57
77
|
}
|
|
58
|
-
|
|
78
|
+
logger_1.default.info `organizationName: name=${organizationName}`;
|
|
59
79
|
const projectName = process.env.PROJECT_NAME ||
|
|
60
80
|
process.env.CIRCLE_PROJECT_REPONAME ||
|
|
61
81
|
siteConfig.projectName;
|
|
62
82
|
if (!projectName) {
|
|
63
|
-
throw new Error(`Missing project name. Did you forget to define
|
|
83
|
+
throw new Error(`Missing project name. Did you forget to define "projectName" in ${siteConfigPath}? You may also export it via the PROJECT_NAME environment variable.`);
|
|
64
84
|
}
|
|
65
|
-
|
|
85
|
+
logger_1.default.info `projectName: name=${projectName}`;
|
|
66
86
|
// We never deploy on pull request.
|
|
67
87
|
const isPullRequest = process.env.CI_PULL_REQUEST || process.env.CIRCLE_PULL_REQUEST;
|
|
68
88
|
if (isPullRequest) {
|
|
69
|
-
shelljs_1.default.echo('Skipping deploy on a pull request');
|
|
89
|
+
shelljs_1.default.echo('Skipping deploy on a pull request.');
|
|
70
90
|
shelljs_1.default.exit(0);
|
|
71
91
|
}
|
|
72
|
-
// github.io indicates organization repos that deploy via
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
92
|
+
// github.io indicates organization repos that deploy via default branch. All
|
|
93
|
+
// others use gh-pages (either case can be configured actually, but we can
|
|
94
|
+
// make educated guesses). Organization deploys look like:
|
|
95
|
+
// - Git repo: https://github.com/<organization>/<organization>.github.io
|
|
96
|
+
// - Site url: https://<organization>.github.io
|
|
97
|
+
const isGitHubPagesOrganizationDeploy = projectName.includes('.github.io');
|
|
98
|
+
if (isGitHubPagesOrganizationDeploy &&
|
|
99
|
+
!process.env.DEPLOYMENT_BRANCH &&
|
|
100
|
+
!siteConfig.deploymentBranch) {
|
|
101
|
+
throw new Error(`For GitHub pages organization deployments, 'docusaurus deploy' does not assume anymore that 'master' is your default Git branch.
|
|
102
|
+
Please provide the branch name to deploy to as an environment variable, for example DEPLOYMENT_BRANCH=main or DEPLOYMENT_BRANCH=master .
|
|
103
|
+
You can also set the deploymentBranch property in docusaurus.config.js .`);
|
|
104
|
+
}
|
|
105
|
+
const deploymentBranch = process.env.DEPLOYMENT_BRANCH || siteConfig.deploymentBranch || 'gh-pages';
|
|
106
|
+
logger_1.default.info `deploymentBranch: name=${deploymentBranch}`;
|
|
76
107
|
const githubHost = process.env.GITHUB_HOST || siteConfig.githubHost || 'github.com';
|
|
77
108
|
const githubPort = process.env.GITHUB_PORT || siteConfig.githubPort;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
109
|
+
let deploymentRepoURL;
|
|
110
|
+
if (useSSH) {
|
|
111
|
+
deploymentRepoURL = (0, utils_1.buildSshUrl)(githubHost, organizationName, projectName, githubPort);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const gitPass = process.env.GIT_PASS;
|
|
115
|
+
const gitCredentials = gitPass ? `${gitUser}:${gitPass}` : gitUser;
|
|
116
|
+
deploymentRepoURL = (0, utils_1.buildHttpsUrl)(gitCredentials, githubHost, organizationName, projectName, githubPort);
|
|
82
117
|
}
|
|
83
|
-
|
|
84
|
-
const remoteBranch = buildRemoteBranchUrl_1.buildUrl(githubHost, githubPort, gitCredentials, organizationName, projectName, useSSH !== undefined && useSSH.toLowerCase() === 'true');
|
|
85
|
-
console.log(`${chalk_1.default.cyan('Remote branch:')} ${obfuscateGitPass(remoteBranch)}`);
|
|
118
|
+
logger_1.default.info `Remote repo URL: name=${obfuscateGitPass(deploymentRepoURL)}`;
|
|
86
119
|
// Check if this is a cross-repo publish.
|
|
87
|
-
const
|
|
88
|
-
.exec('git config --get remote.origin.url')
|
|
89
|
-
.stdout.trim();
|
|
90
|
-
const crossRepoPublish = !currentRepoUrl.endsWith(`${organizationName}/${projectName}.git`);
|
|
120
|
+
const crossRepoPublish = !sourceRepoUrl.endsWith(`${organizationName}/${projectName}.git`);
|
|
91
121
|
// We don't allow deploying to the same branch unless it's a cross publish.
|
|
92
|
-
if (
|
|
93
|
-
throw new Error(`You cannot deploy from this branch (${
|
|
122
|
+
if (sourceBranch === deploymentBranch && !crossRepoPublish) {
|
|
123
|
+
throw new Error(`You cannot deploy from this branch (${sourceBranch}).` +
|
|
94
124
|
'\nYou will need to checkout to a different branch!');
|
|
95
125
|
}
|
|
96
126
|
// Save the commit hash that triggers publish-gh-pages before checking
|
|
@@ -99,42 +129,32 @@ async function deploy(siteDir, cliOptions = {}) {
|
|
|
99
129
|
const runDeploy = async (outputDirectory) => {
|
|
100
130
|
const fromPath = outputDirectory;
|
|
101
131
|
const toPath = await fs_extra_1.default.mkdtemp(path_1.default.join(os_1.default.tmpdir(), `${projectName}-${deploymentBranch}`));
|
|
102
|
-
if (shellExecLog(`git clone ${remoteBranch} ${toPath}`).code !== 0) {
|
|
103
|
-
throw new Error(`Error: git clone failed in ${toPath}`);
|
|
104
|
-
}
|
|
105
132
|
shelljs_1.default.cd(toPath);
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
else if (shellExecLog(`git checkout -b ${deploymentBranch}`).code +
|
|
119
|
-
shellExecLog(`git branch --set-upstream-to=origin/${deploymentBranch}`).code !==
|
|
120
|
-
0) {
|
|
121
|
-
throw new Error(`Error: Git checkout ${deploymentBranch} failed`);
|
|
122
|
-
}
|
|
133
|
+
// Check out deployment branch when cloning repository, and then remove all
|
|
134
|
+
// the files in the directory. If the 'clone' command fails, assume that
|
|
135
|
+
// the deployment branch doesn't exist, and initialize git in an empty
|
|
136
|
+
// directory, check out a clean deployment branch and add remote.
|
|
137
|
+
if (shellExecLog(`git clone --depth 1 --branch ${deploymentBranch} ${deploymentRepoURL} "${toPath}"`).code === 0) {
|
|
138
|
+
shellExecLog('git rm -rf .');
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
shellExecLog('git init');
|
|
142
|
+
shellExecLog(`git checkout -b ${deploymentBranch}`);
|
|
143
|
+
shellExecLog(`git remote add origin ${deploymentRepoURL}`);
|
|
123
144
|
}
|
|
124
|
-
shellExecLog('git rm -rf .');
|
|
125
145
|
try {
|
|
126
146
|
await fs_extra_1.default.copy(fromPath, toPath);
|
|
127
147
|
}
|
|
128
|
-
catch (
|
|
129
|
-
|
|
148
|
+
catch (err) {
|
|
149
|
+
logger_1.default.error `Copying build assets from path=${fromPath} to path=${toPath} failed.`;
|
|
150
|
+
throw err;
|
|
130
151
|
}
|
|
131
|
-
shelljs_1.default.cd(toPath);
|
|
132
152
|
shellExecLog('git add --all');
|
|
133
153
|
const commitMessage = process.env.CUSTOM_COMMIT_MESSAGE ||
|
|
134
154
|
`Deploy website - based on ${currentCommit}`;
|
|
135
155
|
const commitResults = shellExecLog(`git commit -m "${commitMessage}"`);
|
|
136
156
|
if (shellExecLog(`git push --force origin ${deploymentBranch}`).code !== 0) {
|
|
137
|
-
throw new Error('
|
|
157
|
+
throw new Error('Running "git push" command failed. Does the GitHub user account you are using have push access to the repository?');
|
|
138
158
|
}
|
|
139
159
|
else if (commitResults.code === 0) {
|
|
140
160
|
// The commit might return a non-zero value when site is up to date.
|
|
@@ -148,18 +168,18 @@ async function deploy(siteDir, cliOptions = {}) {
|
|
|
148
168
|
// GitHub enterprise hosting.
|
|
149
169
|
websiteURL = `https://${githubHost}/pages/${organizationName}/${projectName}/`;
|
|
150
170
|
}
|
|
151
|
-
shelljs_1.default.echo(`Website is live at ${websiteURL}
|
|
171
|
+
shelljs_1.default.echo(`Website is live at "${websiteURL}".`);
|
|
152
172
|
shelljs_1.default.exit(0);
|
|
153
173
|
}
|
|
154
174
|
};
|
|
155
175
|
if (!cliOptions.skipBuild) {
|
|
156
|
-
// Build
|
|
176
|
+
// Build site, then push to deploymentBranch branch of specified repo.
|
|
157
177
|
try {
|
|
158
|
-
await
|
|
178
|
+
await (0, build_1.build)(siteDir, cliOptions, false).then(runDeploy);
|
|
159
179
|
}
|
|
160
|
-
catch (
|
|
161
|
-
|
|
162
|
-
|
|
180
|
+
catch (err) {
|
|
181
|
+
logger_1.default.error('Deployment of the build output failed.');
|
|
182
|
+
throw err;
|
|
163
183
|
}
|
|
164
184
|
}
|
|
165
185
|
else {
|
|
@@ -167,4 +187,4 @@ async function deploy(siteDir, cliOptions = {}) {
|
|
|
167
187
|
await runDeploy(outDir);
|
|
168
188
|
}
|
|
169
189
|
}
|
|
170
|
-
exports.
|
|
190
|
+
exports.deploy = deploy;
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
export
|
|
7
|
+
import type { CommanderStatic } from 'commander';
|
|
8
|
+
export declare function externalCommand(cli: CommanderStatic, siteDir: string): Promise<void>;
|
package/lib/commands/external.js
CHANGED
|
@@ -6,20 +6,15 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
|
|
9
|
+
exports.externalCommand = void 0;
|
|
10
10
|
const server_1 = require("../server");
|
|
11
|
-
const init_1 =
|
|
11
|
+
const init_1 = require("../server/plugins/init");
|
|
12
12
|
async function externalCommand(cli, siteDir) {
|
|
13
|
-
const context = await server_1.loadContext(siteDir);
|
|
14
|
-
const
|
|
15
|
-
const plugins = init_1.default({ pluginConfigs, context });
|
|
13
|
+
const context = await (0, server_1.loadContext)({ siteDir });
|
|
14
|
+
const plugins = await (0, init_1.initPlugins)(context);
|
|
16
15
|
// Plugin Lifecycle - extendCli.
|
|
17
16
|
plugins.forEach((plugin) => {
|
|
18
|
-
|
|
19
|
-
if (!extendCli) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
extendCli(cli);
|
|
17
|
+
plugin.extendCli?.(cli);
|
|
23
18
|
});
|
|
24
19
|
}
|
|
25
|
-
exports.
|
|
20
|
+
exports.externalCommand = externalCommand;
|
package/lib/commands/serve.d.ts
CHANGED
|
@@ -4,5 +4,10 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import type { LoadContextOptions } from '../server';
|
|
8
|
+
import { type HostPortOptions } from '../server/getHostPort';
|
|
9
|
+
export declare type ServeCLIOptions = HostPortOptions & Pick<LoadContextOptions, 'config'> & {
|
|
10
|
+
dir?: string;
|
|
11
|
+
build?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function serve(siteDir: string, cliOptions: Partial<ServeCLIOptions>): Promise<void>;
|