create-docusaurus 0.0.0-4291 → 0.0.0-4297
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
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// @ts-check
|
|
10
|
+
|
|
11
|
+
const logger = require('@docusaurus/logger').default;
|
|
10
12
|
const semver = require('semver');
|
|
11
13
|
const path = require('path');
|
|
12
14
|
const program = require('commander');
|
|
@@ -14,19 +16,15 @@ const {default: init} = require('../lib');
|
|
|
14
16
|
const requiredVersion = require('../package.json').engines.node;
|
|
15
17
|
|
|
16
18
|
if (!semver.satisfies(process.version, requiredVersion)) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
chalk.yellow(
|
|
20
|
-
`\nYou are using Node.js ${process.version}, Requirement: Node.js ${requiredVersion}.\n`,
|
|
21
|
-
),
|
|
22
|
-
);
|
|
19
|
+
logger.error('Minimum Node.js version not met :(');
|
|
20
|
+
logger.info`You are using Node.js number=${process.version}, Requirement: Node.js number=${requiredVersion}.`;
|
|
23
21
|
process.exit(1);
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
function wrapCommand(fn) {
|
|
27
25
|
return (...args) =>
|
|
28
26
|
fn(...args).catch((err) => {
|
|
29
|
-
|
|
27
|
+
logger.error(err.stack);
|
|
30
28
|
process.exitCode = 1;
|
|
31
29
|
});
|
|
32
30
|
}
|
|
@@ -58,8 +56,7 @@ program
|
|
|
58
56
|
|
|
59
57
|
program.arguments('<command>').action((cmd) => {
|
|
60
58
|
program.outputHelp();
|
|
61
|
-
|
|
62
|
-
console.log();
|
|
59
|
+
logger.error`Unknown command code=${cmd}.`;
|
|
63
60
|
});
|
|
64
61
|
|
|
65
62
|
program.parse(process.argv);
|
package/lib/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
|
-
const
|
|
10
|
+
const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
|
|
11
11
|
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
12
12
|
const child_process_1 = require("child_process");
|
|
13
13
|
const prompts_1 = (0, tslib_1.__importDefault)(require("prompts"));
|
|
@@ -96,11 +96,13 @@ async function init(rootDir, siteName, reqTemplate, cliOptions = {}) {
|
|
|
96
96
|
name = prompt.name;
|
|
97
97
|
}
|
|
98
98
|
if (!name) {
|
|
99
|
-
|
|
99
|
+
logger_1.default.error('A website name is required.');
|
|
100
|
+
process.exit(1);
|
|
100
101
|
}
|
|
101
102
|
const dest = path_1.default.resolve(rootDir, name);
|
|
102
103
|
if (fs_extra_1.default.existsSync(dest)) {
|
|
103
|
-
|
|
104
|
+
logger_1.default.error `Directory already exists at path=${dest}!`;
|
|
105
|
+
process.exit(1);
|
|
104
106
|
}
|
|
105
107
|
let template = reqTemplate;
|
|
106
108
|
let useTS = cliOptions.typescript;
|
|
@@ -132,9 +134,10 @@ async function init(rootDir, siteName, reqTemplate, cliOptions = {}) {
|
|
|
132
134
|
if (url && isValidGitRepoUrl(url)) {
|
|
133
135
|
return true;
|
|
134
136
|
}
|
|
135
|
-
return
|
|
137
|
+
return logger_1.default.red('Invalid repository URL');
|
|
136
138
|
},
|
|
137
|
-
message:
|
|
139
|
+
message: logger_1.default.interpolate `Enter a repository URL from GitHub, Bitbucket, GitLab, or any other public repo.
|
|
140
|
+
(e.g: path=${'https://github.com/ownerName/repoName.git'})`,
|
|
138
141
|
});
|
|
139
142
|
template = repoPrompt.gitRepoUrl;
|
|
140
143
|
}
|
|
@@ -148,32 +151,33 @@ async function init(rootDir, siteName, reqTemplate, cliOptions = {}) {
|
|
|
148
151
|
if (fs_extra_1.default.existsSync(fullDir)) {
|
|
149
152
|
return true;
|
|
150
153
|
}
|
|
151
|
-
return
|
|
154
|
+
return logger_1.default.red(logger_1.default.interpolate `path=${fullDir} does not exist.`);
|
|
152
155
|
}
|
|
153
|
-
return
|
|
156
|
+
return logger_1.default.red('Please enter a valid path.');
|
|
154
157
|
},
|
|
155
158
|
message: 'Enter a local folder path, relative to the current working directory.',
|
|
156
159
|
});
|
|
157
160
|
template = dirPrompt.templateDir;
|
|
158
161
|
}
|
|
159
162
|
if (!template) {
|
|
160
|
-
|
|
163
|
+
logger_1.default.error('Template should not be empty');
|
|
164
|
+
process.exit(1);
|
|
161
165
|
}
|
|
162
|
-
|
|
163
|
-
${chalk_1.default.cyan('Creating new Docusaurus project...')}
|
|
164
|
-
`);
|
|
166
|
+
logger_1.default.info('Creating new Docusaurus project...');
|
|
165
167
|
if (isValidGitRepoUrl(template)) {
|
|
166
|
-
|
|
168
|
+
logger_1.default.info `Cloning Git template path=${template}...`;
|
|
167
169
|
if (shelljs_1.default.exec(`git clone --recursive ${template} ${dest}`, { silent: true })
|
|
168
170
|
.code !== 0) {
|
|
169
|
-
|
|
171
|
+
logger_1.default.error `Cloning Git template name=${template} failed!`;
|
|
172
|
+
process.exit(1);
|
|
170
173
|
}
|
|
171
174
|
}
|
|
172
175
|
else if (templates.includes(template)) {
|
|
173
176
|
// Docusaurus templates.
|
|
174
177
|
if (useTS) {
|
|
175
178
|
if (!hasTS(template)) {
|
|
176
|
-
|
|
179
|
+
logger_1.default.error `Template name=${template} doesn't provide the Typescript variant.`;
|
|
180
|
+
process.exit(1);
|
|
177
181
|
}
|
|
178
182
|
template = `${template}${TypeScriptTemplateSuffix}`;
|
|
179
183
|
}
|
|
@@ -181,7 +185,7 @@ ${chalk_1.default.cyan('Creating new Docusaurus project...')}
|
|
|
181
185
|
await copyTemplate(templatesDir, template, dest);
|
|
182
186
|
}
|
|
183
187
|
catch (err) {
|
|
184
|
-
|
|
188
|
+
logger_1.default.error `Copying Docusaurus template name=${template} failed!`;
|
|
185
189
|
throw err;
|
|
186
190
|
}
|
|
187
191
|
}
|
|
@@ -191,12 +195,13 @@ ${chalk_1.default.cyan('Creating new Docusaurus project...')}
|
|
|
191
195
|
await fs_extra_1.default.copy(templateDir, dest);
|
|
192
196
|
}
|
|
193
197
|
catch (err) {
|
|
194
|
-
|
|
198
|
+
logger_1.default.error `Copying local template path=${templateDir} failed!`;
|
|
195
199
|
throw err;
|
|
196
200
|
}
|
|
197
201
|
}
|
|
198
202
|
else {
|
|
199
|
-
|
|
203
|
+
logger_1.default.error('Invalid template.');
|
|
204
|
+
process.exit(1);
|
|
200
205
|
}
|
|
201
206
|
// Update package.json info.
|
|
202
207
|
try {
|
|
@@ -207,7 +212,7 @@ ${chalk_1.default.cyan('Creating new Docusaurus project...')}
|
|
|
207
212
|
});
|
|
208
213
|
}
|
|
209
214
|
catch (err) {
|
|
210
|
-
|
|
215
|
+
logger_1.default.error('Failed to update package.json.');
|
|
211
216
|
throw err;
|
|
212
217
|
}
|
|
213
218
|
// We need to rename the gitignore file to .gitignore
|
|
@@ -224,7 +229,7 @@ ${chalk_1.default.cyan('Creating new Docusaurus project...')}
|
|
|
224
229
|
? name
|
|
225
230
|
: path_1.default.relative(process.cwd(), name);
|
|
226
231
|
if (!cliOptions.skipInstall) {
|
|
227
|
-
|
|
232
|
+
logger_1.default.info `Installing dependencies with name=${pkgManager}...`;
|
|
228
233
|
if (shelljs_1.default.exec(`cd "${name}" && ${useYarn ? 'yarn' : 'npm install --color always'}`, {
|
|
229
234
|
env: {
|
|
230
235
|
...process.env,
|
|
@@ -232,36 +237,35 @@ ${chalk_1.default.cyan('Creating new Docusaurus project...')}
|
|
|
232
237
|
...(supports_color_1.default.stdout ? { FORCE_COLOR: '1' } : {}),
|
|
233
238
|
},
|
|
234
239
|
}).code !== 0) {
|
|
235
|
-
|
|
236
|
-
|
|
240
|
+
logger_1.default.error('Dependency installation failed.');
|
|
241
|
+
logger_1.default.info `The site directory has already been created, and you can retry by typing:
|
|
237
242
|
|
|
238
|
-
|
|
239
|
-
|
|
243
|
+
code=${`cd ${cdpath}`}
|
|
244
|
+
code=${`${pkgManager} install`}`;
|
|
240
245
|
process.exit(0);
|
|
241
246
|
}
|
|
242
247
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
Inside that directory, you can run several commands:
|
|
248
|
+
logger_1.default.success `Created path=${cdpath}.`;
|
|
249
|
+
logger_1.default.info `Inside that directory, you can run several commands:
|
|
246
250
|
|
|
247
|
-
|
|
251
|
+
code=${`${pkgManager} start`}
|
|
248
252
|
Starts the development server.
|
|
249
253
|
|
|
250
|
-
|
|
254
|
+
code=${`${pkgManager} ${useYarn ? '' : 'run '}build`}
|
|
251
255
|
Bundles your website into static files for production.
|
|
252
256
|
|
|
253
|
-
|
|
257
|
+
code=${`${pkgManager} ${useYarn ? '' : 'run '}serve`}
|
|
254
258
|
Serves the built website locally.
|
|
255
259
|
|
|
256
|
-
|
|
260
|
+
code=${`${pkgManager} deploy`}
|
|
257
261
|
Publishes the website to GitHub pages.
|
|
258
262
|
|
|
259
263
|
We recommend that you begin by typing:
|
|
260
264
|
|
|
261
|
-
|
|
262
|
-
|
|
265
|
+
code=${`cd ${cdpath}`}
|
|
266
|
+
code=${`${pkgManager} start`}
|
|
263
267
|
|
|
264
268
|
Happy building awesome websites!
|
|
265
|
-
|
|
269
|
+
`;
|
|
266
270
|
}
|
|
267
271
|
exports.default = init;
|
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-4297",
|
|
4
4
|
"description": "Create Docusaurus apps easily.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"
|
|
26
|
+
"@docusaurus/logger": "0.0.0-4297",
|
|
27
27
|
"commander": "^5.1.0",
|
|
28
28
|
"fs-extra": "^10.0.0",
|
|
29
29
|
"lodash": "^4.17.20",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/supports-color": "^8.1.1"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "84ae34c33c664bf856f3a92047919a074e087d77"
|
|
43
43
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-2-classic-template",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4297",
|
|
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-4297",
|
|
18
|
+
"@docusaurus/preset-classic": "0.0.0-4297",
|
|
19
19
|
"@mdx-js/react": "^1.6.21",
|
|
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-4297",
|
|
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-4297",
|
|
19
|
+
"@docusaurus/preset-classic": "0.0.0-4297",
|
|
20
20
|
"@mdx-js/react": "^1.6.21",
|
|
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-4297",
|
|
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-4297",
|
|
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-4297",
|
|
22
|
+
"@docusaurus/preset-classic": "0.0.0-4297",
|
|
23
23
|
"@mdx-js/react": "^1.6.21",
|
|
24
24
|
"clsx": "^1.1.1",
|
|
25
25
|
"react": "^17.0.1",
|