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