create-docusaurus 3.10.1-canary-6655 → 3.10.2

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.d.ts CHANGED
@@ -4,7 +4,6 @@
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 { type PackageManager, type GitCloneStrategy } from './constants.js';
8
7
  type LanguagesOptions = {
9
8
  javascript?: boolean;
10
9
  typescript?: boolean;
@@ -12,7 +11,16 @@ type LanguagesOptions = {
12
11
  type CLIOptions = LanguagesOptions & {
13
12
  packageManager?: PackageManager;
14
13
  skipInstall?: boolean;
15
- gitStrategy?: GitCloneStrategy;
14
+ gitStrategy?: GitStrategy;
16
15
  };
16
+ declare const lockfileNames: {
17
+ npm: string;
18
+ yarn: string;
19
+ pnpm: string;
20
+ bun: string;
21
+ };
22
+ type PackageManager = keyof typeof lockfileNames;
23
+ declare const gitStrategies: readonly ["deep", "shallow", "copy", "custom"];
24
+ type GitStrategy = (typeof gitStrategies)[number];
17
25
  export default function init(rootDir: string, reqName?: string, reqTemplate?: string, cliOptions?: CLIOptions): Promise<void>;
18
26
  export {};
package/lib/index.js CHANGED
@@ -12,9 +12,8 @@ import path from 'node:path';
12
12
  // TODO try to remove these third-party dependencies if possible
13
13
  import { logger } from '@docusaurus/logger';
14
14
  import prompts from 'prompts';
15
- import { LockfileNames, PackageManagers, DefaultPackageManager, GitCloneStrategies, } from './constants.js';
16
- import { getAvailablePackageManagers, runGitCloneCommand, runPackageManagerInstallCommand, } from './commands.js';
17
- import { siteNameToPackageName, updatePkg, pathExists, printPackageManagerHelp, } from './utils.js';
15
+ import supportsColor from 'supports-color';
16
+ import { runCommand, siteNameToPackageName } from './utils.js';
18
17
  import { askPreferredLanguage } from './prompts.js';
19
18
  async function getLanguage(options) {
20
19
  if (options.typescript) {
@@ -25,9 +24,25 @@ async function getLanguage(options) {
25
24
  }
26
25
  return askPreferredLanguage();
27
26
  }
27
+ // Only used in the rare, rare case of running globally installed create +
28
+ // using --skip-install. We need a default name to show the tip text
29
+ const defaultPackageManager = 'npm';
30
+ const lockfileNames = {
31
+ npm: 'package-lock.json',
32
+ yarn: 'yarn.lock',
33
+ pnpm: 'pnpm-lock.yaml',
34
+ bun: 'bun.lockb',
35
+ };
36
+ const packageManagers = Object.keys(lockfileNames);
37
+ function pathExists(filePath) {
38
+ return fs
39
+ .access(filePath, fs.constants.F_OK)
40
+ .then(() => true)
41
+ .catch(() => false);
42
+ }
28
43
  async function findPackageManagerFromLockFile(rootDir) {
29
- for (const packageManager of PackageManagers) {
30
- const lockFilePath = path.join(rootDir, LockfileNames[packageManager]);
44
+ for (const packageManager of packageManagers) {
45
+ const lockFilePath = path.join(rootDir, lockfileNames[packageManager]);
31
46
  if (await pathExists(lockFilePath)) {
32
47
  return packageManager;
33
48
  }
@@ -35,18 +50,18 @@ async function findPackageManagerFromLockFile(rootDir) {
35
50
  return undefined;
36
51
  }
37
52
  function findPackageManagerFromUserAgent() {
38
- return PackageManagers.find((packageManager) => process.env.npm_config_user_agent?.startsWith(packageManager));
53
+ return packageManagers.find((packageManager) => process.env.npm_config_user_agent?.startsWith(packageManager));
39
54
  }
40
55
  async function askForPackageManagerChoice() {
41
- const packageManagers = await getAvailablePackageManagers();
42
- if (packageManagers.length === 0) {
43
- logger.warn `No package maintainer available? Trying with name=${DefaultPackageManager}`;
44
- return DefaultPackageManager;
45
- }
46
- if (packageManagers.length === 1) {
47
- return packageManagers[0];
56
+ const hasYarn = (await runCommand('yarn --version')) === 0;
57
+ const hasPnpm = (await runCommand('pnpm --version')) === 0;
58
+ const hasBun = (await runCommand('bun --version')) === 0;
59
+ if (!hasYarn && !hasPnpm && !hasBun) {
60
+ return 'npm';
48
61
  }
49
- const choices = packageManagers.map((p) => ({ title: p, value: p }));
62
+ const choices = ['npm', hasYarn && 'yarn', hasPnpm && 'pnpm', hasBun && 'bun']
63
+ .filter((p) => Boolean(p))
64
+ .map((p) => ({ title: p, value: p }));
50
65
  return ((await prompts({
51
66
  type: 'select',
52
67
  name: 'packageManager',
@@ -54,13 +69,13 @@ async function askForPackageManagerChoice() {
54
69
  choices,
55
70
  }, {
56
71
  onCancel() {
57
- logger.info `Falling back to name=${DefaultPackageManager}`;
72
+ logger.info `Falling back to name=${defaultPackageManager}`;
58
73
  },
59
- })).packageManager ?? DefaultPackageManager);
74
+ })).packageManager ?? defaultPackageManager);
60
75
  }
61
76
  async function getPackageManager(dest, { packageManager, skipInstall }) {
62
- if (packageManager && !PackageManagers.includes(packageManager)) {
63
- throw new Error(`Invalid package manager choice ${packageManager}. Must be one of ${PackageManagers.join(', ')}`);
77
+ if (packageManager && !packageManagers.includes(packageManager)) {
78
+ throw new Error(`Invalid package manager choice ${packageManager}. Must be one of ${packageManagers.join(', ')}`);
64
79
  }
65
80
  return (
66
81
  // If dest already contains a lockfile (e.g. if using a local template), we
@@ -70,7 +85,7 @@ async function getPackageManager(dest, { packageManager, skipInstall }) {
70
85
  (await findPackageManagerFromLockFile('.')) ??
71
86
  findPackageManagerFromUserAgent() ??
72
87
  // This only happens if the user has a global installation in PATH
73
- (skipInstall ? DefaultPackageManager : await askForPackageManagerChoice()));
88
+ (skipInstall ? defaultPackageManager : askForPackageManagerChoice()));
74
89
  }
75
90
  const recommendedTemplate = 'classic';
76
91
  const typeScriptTemplateSuffix = '-typescript';
@@ -149,6 +164,29 @@ async function askTemplateChoice({ templates, cliOptions, }) {
149
164
  function isValidGitRepoUrl(gitRepoUrl) {
150
165
  return ['https://', 'git@'].some((item) => gitRepoUrl.startsWith(item));
151
166
  }
167
+ const gitStrategies = ['deep', 'shallow', 'copy', 'custom'];
168
+ async function getGitCommand(gitStrategy) {
169
+ switch (gitStrategy) {
170
+ case 'shallow':
171
+ case 'copy':
172
+ return 'git clone --recursive --depth 1';
173
+ case 'custom': {
174
+ const { command } = (await prompts({
175
+ type: 'text',
176
+ name: 'command',
177
+ message: 'Write your own git clone command. The repository URL and destination directory will be supplied. E.g. "git clone --depth 10"',
178
+ }, {
179
+ onCancel() {
180
+ logger.info `Falling back to code=${'git clone'}`;
181
+ },
182
+ }));
183
+ return command ?? 'git clone';
184
+ }
185
+ case 'deep':
186
+ default:
187
+ return 'git clone';
188
+ }
189
+ }
152
190
  async function getSiteName(reqName, rootDir) {
153
191
  async function validateSiteName(siteName) {
154
192
  if (!siteName) {
@@ -208,8 +246,8 @@ async function getTemplateSource({ templateName, templates, cliOptions, }) {
208
246
  async function getUserProvidedSource({ reqTemplate, templates, cliOptions, }) {
209
247
  if (isValidGitRepoUrl(reqTemplate)) {
210
248
  if (cliOptions.gitStrategy &&
211
- !GitCloneStrategies.includes(cliOptions.gitStrategy)) {
212
- logger.error `Invalid git strategy: name=${cliOptions.gitStrategy}. Value must be one of ${GitCloneStrategies.join(', ')}.`;
249
+ !gitStrategies.includes(cliOptions.gitStrategy)) {
250
+ logger.error `Invalid git strategy: name=${cliOptions.gitStrategy}. Value must be one of ${gitStrategies.join(', ')}.`;
213
251
  process.exit(1);
214
252
  }
215
253
  return {
@@ -320,6 +358,12 @@ async function getSource(reqTemplate, templates, cliOptions) {
320
358
  cliOptions,
321
359
  });
322
360
  }
361
+ async function updatePkg(pkgPath, obj) {
362
+ const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf8'));
363
+ const newPkg = Object.assign(pkg, obj);
364
+ await fs.mkdir(path.dirname(pkgPath), { recursive: true });
365
+ await fs.writeFile(pkgPath, `${JSON.stringify(newPkg, null, 2)}\n`);
366
+ }
323
367
  export default async function init(rootDir, reqName, reqTemplate, cliOptions = {}) {
324
368
  const [templates, siteName] = await Promise.all([
325
369
  readTemplates(),
@@ -329,7 +373,8 @@ export default async function init(rootDir, reqName, reqTemplate, cliOptions = {
329
373
  const source = await getSource(reqTemplate, templates, cliOptions);
330
374
  logger.info('Creating new Docusaurus project...');
331
375
  if (source.type === 'git') {
332
- if (!(await runGitCloneCommand(source, dest))) {
376
+ const gitCommand = await getGitCommand(source.strategy);
377
+ if ((await runCommand(gitCommand, [source.url, dest])) !== 0) {
333
378
  logger.error `Cloning Git template failed!`;
334
379
  process.exit(1);
335
380
  }
@@ -382,7 +427,17 @@ export default async function init(rootDir, reqName, reqTemplate, cliOptions = {
382
427
  process.chdir(dest);
383
428
  logger.info `Installing dependencies with name=${pkgManager}...`;
384
429
  // ...
385
- if (!(await runPackageManagerInstallCommand(pkgManager))) {
430
+ if ((await runCommand(pkgManager === 'yarn'
431
+ ? 'yarn'
432
+ : pkgManager === 'bun'
433
+ ? 'bun install'
434
+ : `${pkgManager} install --color always`, [], {
435
+ env: {
436
+ ...process.env,
437
+ // Force coloring the output
438
+ ...(supportsColor.stdout ? { FORCE_COLOR: '1' } : {}),
439
+ },
440
+ })) !== 0) {
386
441
  logger.error('Dependency installation failed.');
387
442
  logger.info `The site directory has already been created, and you can retry by typing:
388
443
 
@@ -391,5 +446,29 @@ export default async function init(rootDir, reqName, reqTemplate, cliOptions = {
391
446
  process.exit(0);
392
447
  }
393
448
  }
394
- printPackageManagerHelp({ pkgManager, cdpath });
449
+ const useNpm = pkgManager === 'npm';
450
+ const useBun = pkgManager === 'bun';
451
+ const useRunCommand = useNpm || useBun;
452
+ logger.success `Created name=${cdpath}.`;
453
+ logger.info `Inside that directory, you can run several commands:
454
+
455
+ code=${`${pkgManager} start`}
456
+ Starts the development server.
457
+
458
+ code=${`${pkgManager} ${useRunCommand ? 'run ' : ''}build`}
459
+ Bundles your website into static files for production.
460
+
461
+ code=${`${pkgManager} ${useRunCommand ? 'run ' : ''}serve`}
462
+ Serves the built website locally.
463
+
464
+ code=${`${pkgManager} ${useRunCommand ? 'run ' : ''}deploy`}
465
+ Publishes the website to GitHub pages.
466
+
467
+ We recommend that you begin by typing:
468
+
469
+ code=${`cd ${cdpath}`}
470
+ code=${`${pkgManager} start`}
471
+
472
+ Happy building awesome websites!
473
+ `;
395
474
  }
package/lib/prompts.d.ts CHANGED
@@ -5,4 +5,3 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  export declare function askPreferredLanguage(): Promise<'javascript' | 'typescript'>;
8
- export declare function askForCustomGitCloneCommand(): Promise<string>;
package/lib/prompts.js CHANGED
@@ -21,15 +21,3 @@ export async function askPreferredLanguage() {
21
21
  }
22
22
  return language;
23
23
  }
24
- export async function askForCustomGitCloneCommand() {
25
- const { command } = (await prompts({
26
- type: 'text',
27
- name: 'command',
28
- message: 'Write your own git clone command. The repository URL and destination directory will be supplied. E.g. "git clone --depth 10"',
29
- }, {
30
- onCancel() {
31
- logger.info `Falling back to code=${'git clone'}`;
32
- },
33
- }));
34
- return command ?? 'git clone';
35
- }
package/lib/types.d.ts ADDED
@@ -0,0 +1,7 @@
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 type PackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun';
package/lib/types.js ADDED
@@ -0,0 +1,7 @@
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 {};
package/lib/utils.d.ts CHANGED
@@ -4,7 +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
- import { type PackageManager } from './constants.js';
7
+ import type { SpawnOptions } from 'node:child_process';
8
+ /**
9
+ * Run a command, similar to execa(cmd,args) but simpler
10
+ * @param command
11
+ * @param args
12
+ * @param options
13
+ * @returns the command exit code
14
+ */
15
+ export declare function runCommand(command: string, args?: string[], options?: SpawnOptions): Promise<number>;
8
16
  /**
9
17
  * We use a simple kebab-case-like conversion
10
18
  * It's not perfect, but good enough
@@ -13,11 +21,3 @@ import { type PackageManager } from './constants.js';
13
21
  * @param siteName
14
22
  */
15
23
  export declare function siteNameToPackageName(siteName: string): string;
16
- export declare function updatePkg(pkgPath: string, obj: {
17
- [key: string]: unknown;
18
- }): Promise<void>;
19
- export declare function pathExists(filePath: string): Promise<boolean>;
20
- export declare function printPackageManagerHelp({ pkgManager, cdpath, }: {
21
- pkgManager: PackageManager;
22
- cdpath: string;
23
- }): void;
package/lib/utils.js CHANGED
@@ -4,9 +4,36 @@
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 fs from 'node:fs/promises';
8
- import path from 'node:path';
9
- import { logger } from '@docusaurus/logger';
7
+ // @ts-expect-error: no types, but same as spawn()
8
+ import CrossSpawn from 'cross-spawn';
9
+ // We use cross-spawn instead of spawn because of Windows compatibility issues.
10
+ // For example, "yarn" doesn't work on Windows, it requires "yarn.cmd"
11
+ // Tools like execa() use cross-spawn under the hood, and "resolve" the command
12
+ const crossSpawn = CrossSpawn;
13
+ /**
14
+ * Run a command, similar to execa(cmd,args) but simpler
15
+ * @param command
16
+ * @param args
17
+ * @param options
18
+ * @returns the command exit code
19
+ */
20
+ export async function runCommand(command, args = [], options = {}) {
21
+ // This does something similar to execa.command()
22
+ // we split a string command (with optional args) into command+args
23
+ // this way it's compatible with spawn()
24
+ const [realCommand, ...baseArgs] = command.split(' ');
25
+ const allArgs = [...baseArgs, ...args];
26
+ if (!realCommand) {
27
+ throw new Error(`Invalid command: ${command}`);
28
+ }
29
+ return new Promise((resolve, reject) => {
30
+ const p = crossSpawn(realCommand, allArgs, { stdio: 'ignore', ...options });
31
+ p.on('error', reject);
32
+ p.on('close', (exitCode) => exitCode !== null
33
+ ? resolve(exitCode)
34
+ : reject(new Error(`No exit code for command ${command}`)));
35
+ });
36
+ }
10
37
  /**
11
38
  * We use a simple kebab-case-like conversion
12
39
  * It's not perfect, but good enough
@@ -21,43 +48,3 @@ export function siteNameToPackageName(siteName) {
21
48
  }
22
49
  return siteName;
23
50
  }
24
- export async function updatePkg(pkgPath, obj) {
25
- const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf8'));
26
- const newPkg = Object.assign(pkg, obj);
27
- await fs.mkdir(path.dirname(pkgPath), { recursive: true });
28
- await fs.writeFile(pkgPath, `${JSON.stringify(newPkg, null, 2)}\n`);
29
- }
30
- // No need for fs-extra dependency
31
- export async function pathExists(filePath) {
32
- return fs
33
- .access(filePath, fs.constants.F_OK)
34
- .then(() => true)
35
- .catch(() => false);
36
- }
37
- export function printPackageManagerHelp({ pkgManager, cdpath, }) {
38
- const useNpm = pkgManager === 'npm';
39
- const useBun = pkgManager === 'bun';
40
- const run = useNpm || useBun ? 'run ' : '';
41
- logger.success `Created name=${cdpath}.`;
42
- logger.info `Inside that directory, you can run several commands:
43
-
44
- code=${`${pkgManager} start`}
45
- Starts the development server.
46
-
47
- code=${`${pkgManager} ${run}build`}
48
- Bundles your website into static files for production.
49
-
50
- code=${`${pkgManager} ${run}serve`}
51
- Serves the built website locally.
52
-
53
- code=${`${pkgManager} ${run}deploy`}
54
- Publishes the website to GitHub pages.
55
-
56
- We recommend that you begin by typing:
57
-
58
- code=${`cd ${cdpath}`}
59
- code=${`${pkgManager} start`}
60
-
61
- Happy building awesome websites!
62
- `;
63
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-docusaurus",
3
- "version": "3.10.1-canary-6655",
3
+ "version": "3.10.2",
4
4
  "description": "Create Docusaurus apps easily.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -22,20 +22,19 @@
22
22
  },
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@docusaurus/logger": "3.10.1-canary-6655",
25
+ "@docusaurus/logger": "3.10.2",
26
26
  "commander": "^5.1.0",
27
- "cross-spawn": "^7.0.6",
27
+ "cross-spawn": "^7.0.0",
28
28
  "prompts": "^2.4.2",
29
- "semver": "^7.7.4",
30
- "supports-color": "^10.2.2",
29
+ "semver": "^7.5.4",
30
+ "supports-color": "^9.4.0",
31
31
  "tslib": "^2.6.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/cross-spawn": "^6.0.6",
35
- "@types/supports-color": "^10.0.0"
34
+ "@types/supports-color": "^8.1.1"
36
35
  },
37
36
  "engines": {
38
- "node": ">=24.14"
37
+ "node": ">=20.0"
39
38
  },
40
- "gitHead": "6e93a3055178dd0af922ba627f787229dcdf948b"
39
+ "gitHead": "f37f9035584917a97a260b91fc2842cba4f8b94f"
41
40
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docusaurus-2-classic-template",
3
- "version": "3.10.1-canary-6655",
3
+ "version": "3.10.2",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "docusaurus": "docusaurus",
@@ -14,18 +14,18 @@
14
14
  "write-heading-ids": "docusaurus write-heading-ids"
15
15
  },
16
16
  "dependencies": {
17
- "@docusaurus/core": "3.10.1-canary-6655",
18
- "@docusaurus/faster": "3.10.1-canary-6655",
19
- "@docusaurus/preset-classic": "3.10.1-canary-6655",
20
- "@mdx-js/react": "^3.1.1",
17
+ "@docusaurus/core": "3.10.2",
18
+ "@docusaurus/faster": "3.10.2",
19
+ "@docusaurus/preset-classic": "3.10.2",
20
+ "@mdx-js/react": "^3.0.0",
21
21
  "clsx": "^2.0.0",
22
- "prism-react-renderer": "^2.4.1",
23
- "react": "^19.2.5",
24
- "react-dom": "^19.2.5"
22
+ "prism-react-renderer": "^2.3.0",
23
+ "react": "^19.0.0",
24
+ "react-dom": "^19.0.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@docusaurus/module-type-aliases": "3.10.1-canary-6655",
28
- "@docusaurus/types": "3.10.1-canary-6655"
27
+ "@docusaurus/module-type-aliases": "3.10.2",
28
+ "@docusaurus/types": "3.10.2"
29
29
  },
30
30
  "browserslist": {
31
31
  "production": [
@@ -40,6 +40,6 @@
40
40
  ]
41
41
  },
42
42
  "engines": {
43
- "node": ">=24.14"
43
+ "node": ">=20.0"
44
44
  }
45
45
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docusaurus-2-classic-typescript-template",
3
- "version": "3.10.1-canary-6655",
3
+ "version": "3.10.2",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "docusaurus": "docusaurus",
@@ -15,21 +15,21 @@
15
15
  "typecheck": "tsc"
16
16
  },
17
17
  "dependencies": {
18
- "@docusaurus/core": "3.10.1-canary-6655",
19
- "@docusaurus/faster": "3.10.1-canary-6655",
20
- "@docusaurus/preset-classic": "3.10.1-canary-6655",
21
- "@mdx-js/react": "^3.1.1",
18
+ "@docusaurus/core": "3.10.2",
19
+ "@docusaurus/faster": "3.10.2",
20
+ "@docusaurus/preset-classic": "3.10.2",
21
+ "@mdx-js/react": "^3.0.0",
22
22
  "clsx": "^2.0.0",
23
- "prism-react-renderer": "^2.4.1",
24
- "react": "^19.2.5",
25
- "react-dom": "^19.2.5"
23
+ "prism-react-renderer": "^2.3.0",
24
+ "react": "^19.0.0",
25
+ "react-dom": "^19.0.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@docusaurus/module-type-aliases": "3.10.1-canary-6655",
29
- "@docusaurus/tsconfig": "3.10.1-canary-6655",
30
- "@docusaurus/types": "3.10.1-canary-6655",
31
- "@types/react": "^19.2.14",
32
- "typescript": "~6.0.3"
28
+ "@docusaurus/module-type-aliases": "3.10.2",
29
+ "@docusaurus/tsconfig": "3.10.2",
30
+ "@docusaurus/types": "3.10.2",
31
+ "@types/react": "^19.0.0",
32
+ "typescript": "~6.0.2"
33
33
  },
34
34
  "browserslist": {
35
35
  "production": [
@@ -44,6 +44,6 @@
44
44
  ]
45
45
  },
46
46
  "engines": {
47
- "node": ">=24.14"
47
+ "node": ">=20.0"
48
48
  }
49
49
  }
@@ -1,7 +1,12 @@
1
1
  // This file is not used by "docusaurus start/build" commands.
2
- // It helps improve your IDE experience (type-checking, autocompletion...),
3
- // You can also run the package.json "typecheck" script manually.
4
- // Our base config is often good enough, but feel free to customize it!
2
+ // It is here to improve your IDE experience (type-checking, autocompletion...),
3
+ // and can also run the package.json "typecheck" script manually.
5
4
  {
6
- "extends": "@docusaurus/tsconfig"
5
+ "extends": "@docusaurus/tsconfig",
6
+ "compilerOptions": {
7
+ "baseUrl": ".",
8
+ "ignoreDeprecations": "6.0",
9
+ "strict": true
10
+ },
11
+ "exclude": [".docusaurus", "build"]
7
12
  }
@@ -5,13 +5,15 @@ This website is built using [Docusaurus](https://docusaurus.io/), a modern stati
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- yarn
8
+ npm install
9
9
  ```
10
10
 
11
+ **Note**: feel free to use the package manager of your choice.
12
+
11
13
  ## Local Development
12
14
 
13
15
  ```bash
14
- yarn start
16
+ npm run start
15
17
  ```
16
18
 
17
19
  This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
@@ -19,7 +21,7 @@ This command starts a local development server and opens up a browser window. Mo
19
21
  ## Build
20
22
 
21
23
  ```bash
22
- yarn build
24
+ npm run build
23
25
  ```
24
26
 
25
27
  This command generates static content into the `build` directory and can be served using any static contents hosting service.
@@ -29,13 +31,13 @@ This command generates static content into the `build` directory and can be serv
29
31
  Using SSH:
30
32
 
31
33
  ```bash
32
- USE_SSH=true yarn deploy
34
+ USE_SSH=true npm run deploy
33
35
  ```
34
36
 
35
37
  Not using SSH:
36
38
 
37
39
  ```bash
38
- GIT_USER=<Your GitHub username> yarn deploy
40
+ GIT_USER=<Your GitHub username> npm run deploy
39
41
  ```
40
42
 
41
- If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
43
+ If you are using GitHub Pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
@@ -14,7 +14,7 @@ Or **try Docusaurus immediately** with **[docusaurus.new](https://docusaurus.new
14
14
 
15
15
  ### What you'll need
16
16
 
17
- - [Node.js](https://nodejs.org/en/download/) version 24.14 or above:
17
+ - [Node.js](https://nodejs.org/en/download/) version 20.0 or above:
18
18
  - When installing Node.js, you are recommended to check all checkboxes related to dependencies.
19
19
 
20
20
  ## Generate a new site
package/lib/commands.d.ts DELETED
@@ -1,12 +0,0 @@
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 PackageManager, type Source } from './constants.js';
8
- export declare function getAvailablePackageManagers(): Promise<PackageManager[]>;
9
- export declare function runPackageManagerInstallCommand(pkgManager: PackageManager): Promise<boolean>;
10
- export declare function runGitCloneCommand(source: Source & {
11
- type: 'git';
12
- }, dest: string): Promise<boolean>;
package/lib/commands.js DELETED
@@ -1,77 +0,0 @@
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
- // We use cross-spawn instead of spawn because of Windows compatibility issues.
8
- // For example, "yarn" doesn't work on Windows, it requires "yarn.cmd"
9
- // Tools like execa() use cross-spawn under the hood, and "resolve" the command
10
- import crossSpawn from 'cross-spawn';
11
- import supportsColor from 'supports-color';
12
- import { PackageManagers, } from './constants.js';
13
- import { askForCustomGitCloneCommand } from './prompts.js';
14
- /**
15
- * Run a command, similar to execa(cmd,args) but simpler
16
- * @param command
17
- * @param args
18
- * @param options
19
- * @returns the command exit code
20
- */
21
- async function runCommand(command, args = [], options = {}) {
22
- // This does something similar to execa.command()
23
- // we split a string command (with optional args) into command+args
24
- // this way it's compatible with spawn()
25
- const [realCommand, ...baseArgs] = command.split(' ');
26
- const allArgs = [...baseArgs, ...args];
27
- if (!realCommand) {
28
- throw new Error(`Invalid command: ${command}`);
29
- }
30
- return new Promise((resolve, reject) => {
31
- const p = crossSpawn(realCommand, allArgs, { stdio: 'ignore', ...options });
32
- p.on('error', reject);
33
- p.on('close', (exitCode) => exitCode !== null
34
- ? resolve(exitCode)
35
- : reject(new Error(`No exit code for command ${command}`)));
36
- });
37
- }
38
- async function hasPackageManager(packageManager) {
39
- return (await runCommand(packageManager, ['--version'])) === 0;
40
- }
41
- export async function getAvailablePackageManagers() {
42
- const list = await Promise.all(PackageManagers.map(async (name) => {
43
- return (await hasPackageManager(name)) ? name : null;
44
- }));
45
- return list.filter((item) => item !== null);
46
- }
47
- export async function runPackageManagerInstallCommand(pkgManager) {
48
- const installCommand = pkgManager === 'yarn'
49
- ? 'yarn'
50
- : pkgManager === 'bun'
51
- ? 'bun install'
52
- : `${pkgManager} install --color always`;
53
- return ((await runCommand(installCommand, [], {
54
- env: {
55
- ...process.env,
56
- // Force coloring the output
57
- ...(supportsColor.stdout ? { FORCE_COLOR: '1' } : {}),
58
- },
59
- })) === 0);
60
- }
61
- async function getGitCloneCommand(gitStrategy) {
62
- switch (gitStrategy) {
63
- case 'shallow':
64
- case 'copy':
65
- return 'git clone --recursive --depth 1';
66
- case 'custom': {
67
- return askForCustomGitCloneCommand();
68
- }
69
- case 'deep':
70
- default:
71
- return 'git clone';
72
- }
73
- }
74
- export async function runGitCloneCommand(source, dest) {
75
- const gitCommand = await getGitCloneCommand(source.strategy);
76
- return (await runCommand(gitCommand, [source.url, dest])) === 0;
77
- }
@@ -1,34 +0,0 @@
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 const DefaultPackageManager = "npm";
8
- export declare const LockfileNames: {
9
- npm: string;
10
- yarn: string;
11
- pnpm: string;
12
- bun: string;
13
- };
14
- export type PackageManager = keyof typeof LockfileNames;
15
- export declare const PackageManagers: PackageManager[];
16
- export declare const GitCloneStrategies: readonly ["deep", "shallow", "copy", "custom"];
17
- export type GitCloneStrategy = (typeof GitCloneStrategies)[number];
18
- export type Template = {
19
- name: string;
20
- path: string;
21
- tsVariantPath: string | undefined;
22
- };
23
- export type Source = {
24
- type: 'template';
25
- template: Template;
26
- language: 'javascript' | 'typescript';
27
- } | {
28
- type: 'git';
29
- url: string;
30
- strategy: GitCloneStrategy;
31
- } | {
32
- type: 'local';
33
- path: string;
34
- };
package/lib/constants.js DELETED
@@ -1,23 +0,0 @@
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
- // Only used in the rare, rare case of running globally installed create +
8
- // using --skip-install. We need a default name to show the tip text
9
- export const DefaultPackageManager = 'npm';
10
- // Order matters
11
- export const LockfileNames = {
12
- npm: 'package-lock.json',
13
- yarn: 'yarn.lock',
14
- pnpm: 'pnpm-lock.yaml',
15
- bun: 'bun.lockb',
16
- };
17
- export const PackageManagers = Object.keys(LockfileNames);
18
- export const GitCloneStrategies = [
19
- 'deep',
20
- 'shallow',
21
- 'copy',
22
- 'custom',
23
- ];