create-docusaurus 0.0.0-4623 → 0.0.0-4626
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/lib/index.js
CHANGED
|
@@ -14,13 +14,32 @@ import supportsColor from 'supports-color';
|
|
|
14
14
|
import { fileURLToPath } from 'url';
|
|
15
15
|
const RecommendedTemplate = 'classic';
|
|
16
16
|
const TypeScriptTemplateSuffix = '-typescript';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const DefaultPackageManager = 'npm';
|
|
18
|
+
const SupportedPackageManagers = {
|
|
19
|
+
npm: 'package-lock.json',
|
|
20
|
+
yarn: 'yarn.lock',
|
|
21
|
+
pnpm: 'pnpm-lock.yaml',
|
|
22
|
+
};
|
|
23
|
+
const PackageManagersList = Object.keys(SupportedPackageManagers);
|
|
24
|
+
async function findPackageManagerFromLockFile() {
|
|
25
|
+
for (const packageManager of PackageManagersList) {
|
|
26
|
+
const lockFilePath = path.resolve(process.cwd(), SupportedPackageManagers[packageManager]);
|
|
27
|
+
if (await fs.pathExists(lockFilePath)) {
|
|
28
|
+
return packageManager;
|
|
29
|
+
}
|
|
20
30
|
}
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
function findPackageManagerFromUserAgent() {
|
|
34
|
+
return PackageManagersList.find((packageManager) => { var _a; return (_a = process.env.npm_config_user_agent) === null || _a === void 0 ? void 0 : _a.startsWith(packageManager); });
|
|
35
|
+
}
|
|
36
|
+
async function getPackageManager(forceUseNpm) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
// TODO replace --use-npm by --package-manager option
|
|
39
|
+
if (forceUseNpm) {
|
|
40
|
+
return 'npm';
|
|
23
41
|
}
|
|
42
|
+
return ((_b = (_a = (await findPackageManagerFromLockFile())) !== null && _a !== void 0 ? _a : findPackageManagerFromUserAgent()) !== null && _b !== void 0 ? _b : DefaultPackageManager);
|
|
24
43
|
}
|
|
25
44
|
function isValidGitRepoUrl(gitRepoUrl) {
|
|
26
45
|
return ['https://', 'git@'].some((item) => gitRepoUrl.startsWith(item));
|
|
@@ -96,7 +115,7 @@ async function getGitCommand(gitStrategy) {
|
|
|
96
115
|
}
|
|
97
116
|
export default async function init(rootDir, siteName, reqTemplate, cliOptions = {}) {
|
|
98
117
|
var _a;
|
|
99
|
-
const
|
|
118
|
+
const pkgManager = await getPackageManager(cliOptions.useNpm);
|
|
100
119
|
const templatesDir = fileURLToPath(new URL('../templates', import.meta.url));
|
|
101
120
|
const templates = await readTemplates(templatesDir);
|
|
102
121
|
const hasTS = (templateName) => fs.pathExists(path.resolve(templatesDir, `${templateName}${TypeScriptTemplateSuffix}`));
|
|
@@ -261,17 +280,16 @@ export default async function init(rootDir, siteName, reqTemplate, cliOptions =
|
|
|
261
280
|
if (await fs.pathExists(path.join(dest, 'gitignore'))) {
|
|
262
281
|
await fs.remove(path.join(dest, 'gitignore'));
|
|
263
282
|
}
|
|
264
|
-
const pkgManager = useYarn ? 'yarn' : 'npm';
|
|
265
283
|
// Display the most elegant way to cd.
|
|
266
284
|
const cdpath = path.relative('.', dest);
|
|
267
285
|
if (!cliOptions.skipInstall) {
|
|
268
286
|
shell.cd(dest);
|
|
269
287
|
logger.info `Installing dependencies with name=${pkgManager}...`;
|
|
270
|
-
if (shell.exec(
|
|
288
|
+
if (shell.exec(pkgManager === 'yarn' ? 'yarn' : `${pkgManager} install --color always`, {
|
|
271
289
|
env: {
|
|
272
290
|
...process.env,
|
|
273
|
-
// Force coloring the output, since the command is invoked
|
|
274
|
-
// which is not the interactive shell
|
|
291
|
+
// Force coloring the output, since the command is invoked,
|
|
292
|
+
// by shelljs which is not the interactive shell
|
|
275
293
|
...(supportsColor.stdout ? { FORCE_COLOR: '1' } : {}),
|
|
276
294
|
},
|
|
277
295
|
}).code !== 0) {
|
|
@@ -283,16 +301,17 @@ export default async function init(rootDir, siteName, reqTemplate, cliOptions =
|
|
|
283
301
|
process.exit(0);
|
|
284
302
|
}
|
|
285
303
|
}
|
|
304
|
+
const useNpm = pkgManager === 'npm';
|
|
286
305
|
logger.success `Created path=${cdpath}.`;
|
|
287
306
|
logger.info `Inside that directory, you can run several commands:
|
|
288
307
|
|
|
289
308
|
code=${`${pkgManager} start`}
|
|
290
309
|
Starts the development server.
|
|
291
310
|
|
|
292
|
-
code=${`${pkgManager} ${
|
|
311
|
+
code=${`${pkgManager} ${useNpm ? 'run ' : ''}build`}
|
|
293
312
|
Bundles your website into static files for production.
|
|
294
313
|
|
|
295
|
-
code=${`${pkgManager} ${
|
|
314
|
+
code=${`${pkgManager} ${useNpm ? 'run ' : ''}serve`}
|
|
296
315
|
Serves the built website locally.
|
|
297
316
|
|
|
298
317
|
code=${`${pkgManager} deploy`}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-docusaurus",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4626",
|
|
4
4
|
"description": "Create Docusaurus apps easily.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@docusaurus/logger": "0.0.0-
|
|
25
|
+
"@docusaurus/logger": "0.0.0-4626",
|
|
26
26
|
"commander": "^5.1.0",
|
|
27
27
|
"fs-extra": "^10.0.0",
|
|
28
28
|
"lodash": "^4.17.21",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=14"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "1a36de8f473e7e7f79779e64748d47745068c89f"
|
|
42
42
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-2-classic-template",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4626",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"docusaurus": "docusaurus",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"write-heading-ids": "docusaurus write-heading-ids"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@docusaurus/core": "0.0.0-
|
|
18
|
-
"@docusaurus/preset-classic": "0.0.0-
|
|
17
|
+
"@docusaurus/core": "0.0.0-4626",
|
|
18
|
+
"@docusaurus/preset-classic": "0.0.0-4626",
|
|
19
19
|
"@mdx-js/react": "^1.6.22",
|
|
20
20
|
"clsx": "^1.1.1",
|
|
21
21
|
"prism-react-renderer": "^1.2.1",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-2-classic-typescript-template",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4626",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"docusaurus": "docusaurus",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"typecheck": "tsc"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@docusaurus/core": "0.0.0-
|
|
19
|
-
"@docusaurus/preset-classic": "0.0.0-
|
|
18
|
+
"@docusaurus/core": "0.0.0-4626",
|
|
19
|
+
"@docusaurus/preset-classic": "0.0.0-4626",
|
|
20
20
|
"@mdx-js/react": "^1.6.22",
|
|
21
21
|
"clsx": "^1.1.1",
|
|
22
22
|
"prism-react-renderer": "^1.2.1",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"react-dom": "^17.0.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
27
|
+
"@docusaurus/module-type-aliases": "0.0.0-4626",
|
|
28
28
|
"@tsconfig/docusaurus": "^1.0.4",
|
|
29
29
|
"typescript": "^4.5.2"
|
|
30
30
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-2-facebook-template",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4626",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"docusaurus": "docusaurus",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"format:diff": "prettier --config .prettierrc --list-different \"**/*.{js,jsx,ts,tsx,md,mdx}\""
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "0.0.0-
|
|
22
|
-
"@docusaurus/preset-classic": "0.0.0-
|
|
21
|
+
"@docusaurus/core": "0.0.0-4626",
|
|
22
|
+
"@docusaurus/preset-classic": "0.0.0-4626",
|
|
23
23
|
"@mdx-js/react": "^1.6.22",
|
|
24
24
|
"clsx": "^1.1.1",
|
|
25
25
|
"react": "^17.0.1",
|