create-docusaurus 2.0.0-beta.7 → 2.0.0-rc.1

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.
Files changed (49) hide show
  1. package/bin/index.js +43 -41
  2. package/lib/index.d.ts +16 -5
  3. package/lib/index.js +348 -156
  4. package/package.json +18 -18
  5. package/templates/classic/docusaurus.config.js +17 -3
  6. package/templates/classic/package.json +14 -11
  7. package/templates/classic/src/components/{HomepageFeatures.js → HomepageFeatures/index.js} +5 -5
  8. package/templates/classic/src/components/{HomepageFeatures.module.css → HomepageFeatures/styles.module.css} +0 -0
  9. package/templates/classic/src/css/custom.css +18 -16
  10. package/templates/classic/src/pages/index.js +3 -2
  11. package/templates/classic/src/pages/index.module.css +1 -1
  12. package/templates/classic-typescript/package.json +14 -14
  13. package/templates/classic-typescript/src/components/{HomepageFeatures.tsx → HomepageFeatures/index.tsx} +7 -13
  14. package/templates/classic-typescript/src/pages/index.tsx +3 -2
  15. package/templates/facebook/.eslintrc.js +10 -4
  16. package/templates/facebook/.prettierrc +1 -1
  17. package/templates/facebook/.stylelintrc.js +1 -1
  18. package/templates/facebook/README.md +9 -1
  19. package/templates/facebook/babel.config.js +1 -1
  20. package/templates/facebook/docusaurus.config.js +22 -14
  21. package/templates/facebook/package.json +24 -24
  22. package/templates/facebook/sidebars.js +1 -1
  23. package/templates/facebook/src/css/custom.css +17 -13
  24. package/templates/facebook/src/pages/index.js +1 -1
  25. package/templates/facebook/src/pages/styles.module.css +2 -2
  26. package/templates/facebook/static/img/meta_opensource_logo.svg +1 -0
  27. package/templates/facebook/static/img/meta_opensource_logo_negative.svg +1 -0
  28. package/templates/shared/README.md +9 -1
  29. package/templates/shared/docs/intro.md +19 -7
  30. package/templates/shared/docs/tutorial-basics/_category_.json +5 -1
  31. package/templates/shared/docs/tutorial-basics/create-a-blog-post.md +1 -1
  32. package/templates/shared/docs/tutorial-basics/create-a-document.md +6 -6
  33. package/templates/shared/docs/tutorial-basics/create-a-page.md +5 -5
  34. package/templates/shared/docs/tutorial-basics/deploy-your-site.md +1 -1
  35. package/templates/shared/docs/tutorial-basics/markdown-features.mdx +3 -1
  36. package/templates/shared/docs/tutorial-extras/_category_.json +4 -1
  37. package/templates/shared/docs/tutorial-extras/img/docsVersionDropdown.png +0 -0
  38. package/templates/shared/docs/tutorial-extras/img/localeDropdown.png +0 -0
  39. package/templates/shared/docs/tutorial-extras/manage-docs-versions.md +1 -1
  40. package/templates/shared/docs/tutorial-extras/translate-your-site.md +2 -2
  41. package/templates/shared/static/img/undraw_docusaurus_mountain.svg +1 -0
  42. package/templates/shared/static/img/undraw_docusaurus_react.svg +1 -0
  43. package/templates/shared/static/img/undraw_docusaurus_tree.svg +40 -1
  44. package/lib/.tsbuildinfo +0 -1
  45. package/src/index.ts +0 -289
  46. package/templates/facebook/static/img/oss_logo.png +0 -0
  47. package/templates/shared/static/img/tutorial/docsVersionDropdown.png +0 -0
  48. package/templates/shared/static/img/tutorial/localeDropdown.png +0 -0
  49. package/tsconfig.json +0 -11
package/bin/index.js CHANGED
@@ -6,59 +6,61 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
 
9
- const chalk = require('chalk');
10
- const semver = require('semver');
11
- const path = require('path');
12
- const program = require('commander');
13
- const {default: init} = require('../lib');
14
- const requiredVersion = require('../package.json').engines.node;
9
+ // @ts-check
10
+
11
+ import path from 'path';
12
+ import {createRequire} from 'module';
13
+ import logger from '@docusaurus/logger';
14
+ import semver from 'semver';
15
+ import {program} from 'commander';
16
+
17
+ const packageJson = /** @type {import("../package.json")} */ (
18
+ createRequire(import.meta.url)('../package.json')
19
+ );
20
+ const requiredVersion = packageJson.engines.node;
15
21
 
16
22
  if (!semver.satisfies(process.version, requiredVersion)) {
17
- console.log(
18
- chalk.red(`\nMinimum Node.js version not met :)`) +
19
- chalk.yellow(
20
- `\nYou are using Node.js ${process.version}, Requirement: Node.js ${requiredVersion}.\n`,
21
- ),
22
- );
23
+ logger.error('Minimum Node.js version not met :(');
24
+ logger.info`You are using Node.js number=${process.version}, Requirement: Node.js number=${requiredVersion}.`;
23
25
  process.exit(1);
24
26
  }
25
27
 
26
- function wrapCommand(fn) {
27
- return (...args) =>
28
- fn(...args).catch((err) => {
29
- console.error(chalk.red(err.stack));
30
- process.exitCode = 1;
31
- });
32
- }
33
-
34
- program
35
- .version(require('../package.json').version)
36
- .usage('<command> [options]');
28
+ program.version(packageJson.version);
37
29
 
38
30
  program
39
- .command('init [siteName] [template] [rootDir]', {isDefault: true})
40
- .option('--use-npm')
41
- .option('--skip-install')
42
- .option('--typescript')
31
+ .arguments('[siteName] [template] [rootDir]')
32
+ .option(
33
+ '-p, --package-manager <manager>',
34
+ 'The package manager used to install dependencies. One of yarn, npm, and pnpm.',
35
+ )
36
+ .option(
37
+ '-s, --skip-install',
38
+ 'Do not run package manager immediately after scaffolding',
39
+ )
40
+ .option('-t, --typescript', 'Use the TypeScript template variant')
41
+ .option(
42
+ '-g, --git-strategy <strategy>',
43
+ `Only used if the template is a git repository.
44
+ \`deep\`: preserve full history
45
+ \`shallow\`: clone with --depth=1
46
+ \`copy\`: do a shallow clone, but do not create a git repo
47
+ \`custom\`: enter your custom git clone command. We will prompt you for it.`,
48
+ )
43
49
  .description('Initialize website.')
44
- .action(
45
- (siteName, template, rootDir = '.', {useNpm, skipInstall, typescript}) => {
46
- wrapCommand(init)(path.resolve(rootDir), siteName, template, {
47
- useNpm,
48
- skipInstall,
49
- typescript,
50
- });
51
- },
50
+ .action((siteName, template, rootDir, options) =>
51
+ // See https://github.com/facebook/docusaurus/pull/6860
52
+ import('../lib/index.js').then(({default: init}) =>
53
+ init(path.resolve(rootDir ?? '.'), siteName, template, options),
54
+ ),
52
55
  );
53
56
 
54
- program.arguments('<command>').action((cmd) => {
55
- program.outputHelp();
56
- console.log(` ${chalk.red(`\n Unknown command ${chalk.yellow(cmd)}.`)}`);
57
- console.log();
58
- });
59
-
60
57
  program.parse(process.argv);
61
58
 
62
59
  if (!process.argv.slice(1).length) {
63
60
  program.outputHelp();
64
61
  }
62
+
63
+ process.on('unhandledRejection', (err) => {
64
+ logger.error(err);
65
+ process.exit(1);
66
+ });
package/lib/index.d.ts CHANGED
@@ -4,8 +4,19 @@
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
- export default function init(rootDir: string, siteName?: string, reqTemplate?: string, cliOptions?: Partial<{
8
- useNpm: boolean;
9
- skipInstall: boolean;
10
- typescript: boolean;
11
- }>): Promise<void>;
7
+ declare type CLIOptions = {
8
+ packageManager?: PackageManager;
9
+ skipInstall?: boolean;
10
+ typescript?: boolean;
11
+ gitStrategy?: GitStrategy;
12
+ };
13
+ declare const lockfileNames: {
14
+ npm: string;
15
+ yarn: string;
16
+ pnpm: string;
17
+ };
18
+ declare type PackageManager = keyof typeof lockfileNames;
19
+ declare const gitStrategies: readonly ["deep", "shallow", "copy", "custom"];
20
+ declare type GitStrategy = typeof gitStrategies[number];
21
+ export default function init(rootDir: string, reqName?: string, reqTemplate?: string, cliOptions?: CLIOptions): Promise<void>;
22
+ export {};