create-docusaurus 0.0.0-4607 → 0.0.0-4611
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
|
@@ -31,10 +31,8 @@ async function updatePkg(pkgPath, obj) {
|
|
|
31
31
|
const newPkg = Object.assign(pkg, obj);
|
|
32
32
|
await fs.outputFile(pkgPath, `${JSON.stringify(newPkg, null, 2)}\n`);
|
|
33
33
|
}
|
|
34
|
-
function readTemplates(templatesDir) {
|
|
35
|
-
const templates = fs
|
|
36
|
-
.readdirSync(templatesDir)
|
|
37
|
-
.filter((d) => !d.startsWith('.') &&
|
|
34
|
+
async function readTemplates(templatesDir) {
|
|
35
|
+
const templates = (await fs.readdir(templatesDir)).filter((d) => !d.startsWith('.') &&
|
|
38
36
|
!d.startsWith('README') &&
|
|
39
37
|
!d.endsWith(TypeScriptTemplateSuffix) &&
|
|
40
38
|
d !== 'shared');
|
|
@@ -66,7 +64,7 @@ async function copyTemplate(templatesDir, template, dest) {
|
|
|
66
64
|
if (tsBaseTemplate) {
|
|
67
65
|
const tsBaseTemplatePath = path.resolve(templatesDir, tsBaseTemplate);
|
|
68
66
|
await fs.copy(tsBaseTemplatePath, dest, {
|
|
69
|
-
filter: (filePath) => fs.
|
|
67
|
+
filter: async (filePath) => (await fs.stat(filePath)).isDirectory() ||
|
|
70
68
|
path.extname(filePath) === '.css' ||
|
|
71
69
|
path.basename(filePath) === 'docusaurus.config.js',
|
|
72
70
|
});
|
|
@@ -74,7 +72,7 @@ async function copyTemplate(templatesDir, template, dest) {
|
|
|
74
72
|
await fs.copy(path.resolve(templatesDir, template), dest, {
|
|
75
73
|
// Symlinks don't exist in published NPM packages anymore, so this is only
|
|
76
74
|
// to prevent errors during local testing
|
|
77
|
-
filter: (filePath) => !fs.
|
|
75
|
+
filter: async (filePath) => !(await fs.lstat(filePath)).isSymbolicLink(),
|
|
78
76
|
});
|
|
79
77
|
}
|
|
80
78
|
const gitStrategies = ['deep', 'shallow', 'copy', 'custom'];
|
|
@@ -100,8 +98,8 @@ export default async function init(rootDir, siteName, reqTemplate, cliOptions =
|
|
|
100
98
|
var _a;
|
|
101
99
|
const useYarn = cliOptions.useNpm ? false : hasYarn();
|
|
102
100
|
const templatesDir = fileURLToPath(new URL('../templates', import.meta.url));
|
|
103
|
-
const templates = readTemplates(templatesDir);
|
|
104
|
-
const hasTS = (templateName) => fs.
|
|
101
|
+
const templates = await readTemplates(templatesDir);
|
|
102
|
+
const hasTS = (templateName) => fs.pathExists(path.resolve(templatesDir, `${templateName}${TypeScriptTemplateSuffix}`));
|
|
105
103
|
let name = siteName;
|
|
106
104
|
// Prompt if siteName is not passed from CLI.
|
|
107
105
|
if (!name) {
|
|
@@ -118,7 +116,7 @@ export default async function init(rootDir, siteName, reqTemplate, cliOptions =
|
|
|
118
116
|
process.exit(1);
|
|
119
117
|
}
|
|
120
118
|
const dest = path.resolve(rootDir, name);
|
|
121
|
-
if (fs.
|
|
119
|
+
if (await fs.pathExists(dest)) {
|
|
122
120
|
logger.error `Directory already exists at path=${dest}!`;
|
|
123
121
|
process.exit(1);
|
|
124
122
|
}
|
|
@@ -133,7 +131,7 @@ export default async function init(rootDir, siteName, reqTemplate, cliOptions =
|
|
|
133
131
|
choices: createTemplateChoices(templates),
|
|
134
132
|
});
|
|
135
133
|
template = templatePrompt.template;
|
|
136
|
-
if (template && !useTS && hasTS(template)) {
|
|
134
|
+
if (template && !useTS && (await hasTS(template))) {
|
|
137
135
|
const tsPrompt = await prompts({
|
|
138
136
|
type: 'confirm',
|
|
139
137
|
name: 'useTS',
|
|
@@ -178,10 +176,10 @@ export default async function init(rootDir, siteName, reqTemplate, cliOptions =
|
|
|
178
176
|
const dirPrompt = await prompts({
|
|
179
177
|
type: 'text',
|
|
180
178
|
name: 'templateDir',
|
|
181
|
-
validate: (dir) => {
|
|
179
|
+
validate: async (dir) => {
|
|
182
180
|
if (dir) {
|
|
183
181
|
const fullDir = path.resolve(process.cwd(), dir);
|
|
184
|
-
if (fs.
|
|
182
|
+
if (await fs.pathExists(fullDir)) {
|
|
185
183
|
return true;
|
|
186
184
|
}
|
|
187
185
|
return logger.red(logger.interpolate `path=${fullDir} does not exist.`);
|
|
@@ -215,7 +213,7 @@ export default async function init(rootDir, siteName, reqTemplate, cliOptions =
|
|
|
215
213
|
else if (templates.includes(template)) {
|
|
216
214
|
// Docusaurus templates.
|
|
217
215
|
if (useTS) {
|
|
218
|
-
if (!hasTS(template)) {
|
|
216
|
+
if (!(await hasTS(template))) {
|
|
219
217
|
logger.error `Template name=${template} doesn't provide the Typescript variant.`;
|
|
220
218
|
process.exit(1);
|
|
221
219
|
}
|
|
@@ -229,7 +227,7 @@ export default async function init(rootDir, siteName, reqTemplate, cliOptions =
|
|
|
229
227
|
throw err;
|
|
230
228
|
}
|
|
231
229
|
}
|
|
232
|
-
else if (fs.
|
|
230
|
+
else if (await fs.pathExists(path.resolve(process.cwd(), template))) {
|
|
233
231
|
const templateDir = path.resolve(process.cwd(), template);
|
|
234
232
|
try {
|
|
235
233
|
await fs.copy(templateDir, dest);
|
|
@@ -256,12 +254,12 @@ export default async function init(rootDir, siteName, reqTemplate, cliOptions =
|
|
|
256
254
|
throw err;
|
|
257
255
|
}
|
|
258
256
|
// We need to rename the gitignore file to .gitignore
|
|
259
|
-
if (!fs.
|
|
260
|
-
fs.
|
|
257
|
+
if (!(await fs.pathExists(path.join(dest, '.gitignore'))) &&
|
|
258
|
+
(await fs.pathExists(path.join(dest, 'gitignore')))) {
|
|
261
259
|
await fs.move(path.join(dest, 'gitignore'), path.join(dest, '.gitignore'));
|
|
262
260
|
}
|
|
263
|
-
if (fs.
|
|
264
|
-
fs.
|
|
261
|
+
if (await fs.pathExists(path.join(dest, 'gitignore'))) {
|
|
262
|
+
await fs.remove(path.join(dest, 'gitignore'));
|
|
265
263
|
}
|
|
266
264
|
const pkgManager = useYarn ? 'yarn' : 'npm';
|
|
267
265
|
// Display the most elegant way to cd.
|
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-4611",
|
|
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-4611",
|
|
26
26
|
"commander": "^5.1.0",
|
|
27
27
|
"fs-extra": "^10.0.0",
|
|
28
28
|
"lodash": "^4.17.21",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"supports-color": "^9.2.1",
|
|
33
33
|
"tslib": "^2.3.1"
|
|
34
34
|
},
|
|
35
|
-
"engines": {
|
|
36
|
-
"node": ">=14"
|
|
37
|
-
},
|
|
38
35
|
"devDependencies": {
|
|
39
36
|
"@types/supports-color": "^8.1.1"
|
|
40
37
|
},
|
|
41
|
-
"
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=14"
|
|
40
|
+
},
|
|
41
|
+
"gitHead": "6a09283902da2fc8e205f36a018b80d8c8140d1f"
|
|
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-4611",
|
|
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-4611",
|
|
18
|
+
"@docusaurus/preset-classic": "0.0.0-4611",
|
|
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-4611",
|
|
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-4611",
|
|
19
|
+
"@docusaurus/preset-classic": "0.0.0-4611",
|
|
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-4611",
|
|
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-4611",
|
|
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-4611",
|
|
22
|
+
"@docusaurus/preset-classic": "0.0.0-4611",
|
|
23
23
|
"@mdx-js/react": "^1.6.22",
|
|
24
24
|
"clsx": "^1.1.1",
|
|
25
25
|
"react": "^17.0.1",
|