create-docusaurus 0.0.0-4626 → 0.0.0-4629
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/index.js
CHANGED
|
@@ -36,14 +36,17 @@ program.version(packageJson.version);
|
|
|
36
36
|
|
|
37
37
|
program
|
|
38
38
|
.arguments('[siteName] [template] [rootDir]')
|
|
39
|
-
.option('--use-npm', 'Use NPM as package manage even with Yarn installed')
|
|
40
39
|
.option(
|
|
41
|
-
'--
|
|
40
|
+
'-p, --package-manager <manager>',
|
|
41
|
+
'The package manager used to install dependencies. One of yarn, npm, and pnpm.',
|
|
42
|
+
)
|
|
43
|
+
.option(
|
|
44
|
+
'-s, --skip-install',
|
|
42
45
|
'Do not run package manager immediately after scaffolding',
|
|
43
46
|
)
|
|
44
|
-
.option('--typescript', 'Use the TypeScript template variant')
|
|
47
|
+
.option('-t, --typescript', 'Use the TypeScript template variant')
|
|
45
48
|
.option(
|
|
46
|
-
'--git-strategy <strategy>',
|
|
49
|
+
'-g, --git-strategy <strategy>',
|
|
47
50
|
`Only used if the template is a git repository.
|
|
48
51
|
\`deep\`: preserve full history
|
|
49
52
|
\`shallow\`: clone with --depth=1
|
|
@@ -56,10 +59,10 @@ program
|
|
|
56
59
|
siteName,
|
|
57
60
|
template,
|
|
58
61
|
rootDir = '.',
|
|
59
|
-
{
|
|
62
|
+
{packageManager, skipInstall, typescript, gitStrategy} = {},
|
|
60
63
|
) => {
|
|
61
64
|
wrapCommand(init)(path.resolve(rootDir), siteName, template, {
|
|
62
|
-
|
|
65
|
+
packageManager,
|
|
63
66
|
skipInstall,
|
|
64
67
|
typescript,
|
|
65
68
|
gitStrategy,
|
package/lib/index.d.ts
CHANGED
|
@@ -4,9 +4,15 @@
|
|
|
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
|
+
declare const SupportedPackageManagers: {
|
|
8
|
+
npm: string;
|
|
9
|
+
yarn: string;
|
|
10
|
+
pnpm: string;
|
|
11
|
+
};
|
|
12
|
+
declare type SupportedPackageManager = keyof typeof SupportedPackageManagers;
|
|
7
13
|
declare const gitStrategies: readonly ["deep", "shallow", "copy", "custom"];
|
|
8
14
|
export default function init(rootDir: string, siteName?: string, reqTemplate?: string, cliOptions?: Partial<{
|
|
9
|
-
|
|
15
|
+
packageManager: SupportedPackageManager;
|
|
10
16
|
skipInstall: boolean;
|
|
11
17
|
typescript: boolean;
|
|
12
18
|
gitStrategy: typeof gitStrategies[number];
|
package/lib/index.js
CHANGED
|
@@ -14,6 +14,8 @@ import supportsColor from 'supports-color';
|
|
|
14
14
|
import { fileURLToPath } from 'url';
|
|
15
15
|
const RecommendedTemplate = 'classic';
|
|
16
16
|
const TypeScriptTemplateSuffix = '-typescript';
|
|
17
|
+
// Only used in the rare, rare case of running globally installed create +
|
|
18
|
+
// using --skip-install. We need a default name to show the tip text
|
|
17
19
|
const DefaultPackageManager = 'npm';
|
|
18
20
|
const SupportedPackageManagers = {
|
|
19
21
|
npm: 'package-lock.json',
|
|
@@ -33,13 +35,31 @@ async function findPackageManagerFromLockFile() {
|
|
|
33
35
|
function findPackageManagerFromUserAgent() {
|
|
34
36
|
return PackageManagersList.find((packageManager) => { var _a; return (_a = process.env.npm_config_user_agent) === null || _a === void 0 ? void 0 : _a.startsWith(packageManager); });
|
|
35
37
|
}
|
|
36
|
-
async function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (
|
|
38
|
+
async function askForPackageManagerChoice() {
|
|
39
|
+
const hasYarn = shell.exec('yarn --version', { silent: true }).code === 0;
|
|
40
|
+
const hasPNPM = shell.exec('pnpm --version', { silent: true }).code === 0;
|
|
41
|
+
if (!hasYarn && !hasPNPM) {
|
|
40
42
|
return 'npm';
|
|
41
43
|
}
|
|
42
|
-
|
|
44
|
+
const choices = ['npm', hasYarn && 'yarn', hasPNPM && 'pnpm']
|
|
45
|
+
.filter((p) => Boolean(p))
|
|
46
|
+
.map((p) => ({ title: p, value: p }));
|
|
47
|
+
return (await prompts({
|
|
48
|
+
type: 'select',
|
|
49
|
+
name: 'packageManager',
|
|
50
|
+
message: 'Select a package manager...',
|
|
51
|
+
choices,
|
|
52
|
+
})).packageManager;
|
|
53
|
+
}
|
|
54
|
+
async function getPackageManager(packageManagerChoice, skipInstall = false) {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
if (packageManagerChoice &&
|
|
57
|
+
!PackageManagersList.includes(packageManagerChoice)) {
|
|
58
|
+
throw new Error(`Invalid package manager choice ${packageManagerChoice}. Must be one of ${PackageManagersList.join(', ')}`);
|
|
59
|
+
}
|
|
60
|
+
return ((_b = (_a = packageManagerChoice !== null && packageManagerChoice !== void 0 ? packageManagerChoice : (await findPackageManagerFromLockFile())) !== null && _a !== void 0 ? _a : findPackageManagerFromUserAgent()) !== null && _b !== void 0 ? _b :
|
|
61
|
+
// This only happens if the user has a global installation in PATH
|
|
62
|
+
(skipInstall ? DefaultPackageManager : askForPackageManagerChoice()));
|
|
43
63
|
}
|
|
44
64
|
function isValidGitRepoUrl(gitRepoUrl) {
|
|
45
65
|
return ['https://', 'git@'].some((item) => gitRepoUrl.startsWith(item));
|
|
@@ -115,7 +135,6 @@ async function getGitCommand(gitStrategy) {
|
|
|
115
135
|
}
|
|
116
136
|
export default async function init(rootDir, siteName, reqTemplate, cliOptions = {}) {
|
|
117
137
|
var _a;
|
|
118
|
-
const pkgManager = await getPackageManager(cliOptions.useNpm);
|
|
119
138
|
const templatesDir = fileURLToPath(new URL('../templates', import.meta.url));
|
|
120
139
|
const templates = await readTemplates(templatesDir);
|
|
121
140
|
const hasTS = (templateName) => fs.pathExists(path.resolve(templatesDir, `${templateName}${TypeScriptTemplateSuffix}`));
|
|
@@ -282,6 +301,7 @@ export default async function init(rootDir, siteName, reqTemplate, cliOptions =
|
|
|
282
301
|
}
|
|
283
302
|
// Display the most elegant way to cd.
|
|
284
303
|
const cdpath = path.relative('.', dest);
|
|
304
|
+
const pkgManager = await getPackageManager(cliOptions.packageManager, cliOptions.skipInstall);
|
|
285
305
|
if (!cliOptions.skipInstall) {
|
|
286
306
|
shell.cd(dest);
|
|
287
307
|
logger.info `Installing dependencies with name=${pkgManager}...`;
|
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-4629",
|
|
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-4629",
|
|
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": "f8c9d534bda3d79388001f20dfb3a621c65b503a"
|
|
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-4629",
|
|
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-4629",
|
|
18
|
+
"@docusaurus/preset-classic": "0.0.0-4629",
|
|
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-4629",
|
|
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-4629",
|
|
19
|
+
"@docusaurus/preset-classic": "0.0.0-4629",
|
|
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-4629",
|
|
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-4629",
|
|
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-4629",
|
|
22
|
+
"@docusaurus/preset-classic": "0.0.0-4629",
|
|
23
23
|
"@mdx-js/react": "^1.6.22",
|
|
24
24
|
"clsx": "^1.1.1",
|
|
25
25
|
"react": "^17.0.1",
|