mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
fix(v2): codesandbox generated examples should use published init package (#3760)
* Fix codesandbox generated examples to use published init script instead of local one * Fix codesandbox generated examples to use published init script instead of local one
This commit is contained in:
parent
3ab9204ced
commit
f26d478f2d
10 changed files with 18 additions and 34 deletions
20
examples/bootstrap/.gitignore
vendored
20
examples/bootstrap/.gitignore
vendored
|
@ -1,20 +0,0 @@
|
||||||
# Dependencies
|
|
||||||
/node_modules
|
|
||||||
|
|
||||||
# Production
|
|
||||||
/build
|
|
||||||
|
|
||||||
# Generated files
|
|
||||||
.docusaurus
|
|
||||||
.cache-loader
|
|
||||||
|
|
||||||
# Misc
|
|
||||||
.DS_Store
|
|
||||||
.env.local
|
|
||||||
.env.development.local
|
|
||||||
.env.test.local
|
|
||||||
.env.production.local
|
|
||||||
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
|
@ -4,7 +4,6 @@ module.exports = {
|
||||||
url: 'https://your-docusaurus-test-site.com',
|
url: 'https://your-docusaurus-test-site.com',
|
||||||
baseUrl: '/',
|
baseUrl: '/',
|
||||||
onBrokenLinks: 'throw',
|
onBrokenLinks: 'throw',
|
||||||
onBrokenMarkdownLinks: 'warn',
|
|
||||||
favicon: 'img/favicon.ico',
|
favicon: 'img/favicon.ico',
|
||||||
organizationName: 'facebook', // Usually your GitHub org/user name.
|
organizationName: 'facebook', // Usually your GitHub org/user name.
|
||||||
projectName: 'docusaurus', // Usually your repo name.
|
projectName: 'docusaurus', // Usually your repo name.
|
||||||
|
|
|
@ -4,7 +4,6 @@ module.exports = {
|
||||||
url: 'https://your-docusaurus-test-site.com',
|
url: 'https://your-docusaurus-test-site.com',
|
||||||
baseUrl: '/',
|
baseUrl: '/',
|
||||||
onBrokenLinks: 'throw',
|
onBrokenLinks: 'throw',
|
||||||
onBrokenMarkdownLinks: 'warn',
|
|
||||||
favicon: 'img/favicon.ico',
|
favicon: 'img/favicon.ico',
|
||||||
organizationName: 'facebook', // Usually your GitHub org/user name.
|
organizationName: 'facebook', // Usually your GitHub org/user name.
|
||||||
projectName: 'docusaurus', // Usually your repo name.
|
projectName: 'docusaurus', // Usually your repo name.
|
||||||
|
|
|
@ -9,20 +9,19 @@
|
||||||
"swizzle": "docusaurus swizzle",
|
"swizzle": "docusaurus swizzle",
|
||||||
"deploy": "docusaurus deploy",
|
"deploy": "docusaurus deploy",
|
||||||
"serve": "docusaurus serve",
|
"serve": "docusaurus serve",
|
||||||
"clear": "docusaurus clear",
|
|
||||||
"dev": "docusaurus start"
|
"dev": "docusaurus start"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@docusaurus/core": "2.0.0-alpha.66",
|
"@docusaurus/core": "2.0.0-alpha.66",
|
||||||
"@docusaurus/preset-classic": "2.0.0-alpha.66",
|
"@docusaurus/preset-classic": "2.0.0-alpha.66",
|
||||||
"@mdx-js/react": "^1.6.21",
|
"@mdx-js/react": "^1.5.8",
|
||||||
"clsx": "^1.1.1",
|
"clsx": "^1.1.1",
|
||||||
"react": "^16.8.4",
|
"react": "^16.8.4",
|
||||||
"react-dom": "^16.8.4"
|
"react-dom": "^16.8.4"
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
">0.5%",
|
">0.2%",
|
||||||
"not dead",
|
"not dead",
|
||||||
"not op_mini all"
|
"not op_mini all"
|
||||||
],
|
],
|
||||||
|
|
|
@ -1537,7 +1537,7 @@
|
||||||
unist-builder "2.0.3"
|
unist-builder "2.0.3"
|
||||||
unist-util-visit "2.0.3"
|
unist-util-visit "2.0.3"
|
||||||
|
|
||||||
"@mdx-js/react@^1.5.8", "@mdx-js/react@^1.6.21":
|
"@mdx-js/react@^1.5.8":
|
||||||
version "1.6.21"
|
version "1.6.21"
|
||||||
resolved "https://registry.yarnpkg.com/@mdx-js/react/-/react-1.6.21.tgz#86d962471a5e160c59a6b32054aa55c0c7ca404e"
|
resolved "https://registry.yarnpkg.com/@mdx-js/react/-/react-1.6.21.tgz#86d962471a5e160c59a6b32054aa55c0c7ca404e"
|
||||||
integrity sha512-CgSNT9sq2LAlhEbVlPg7DwUQkypz+CWaWGcJbkgmp9WCAy6vW33CQ44UbKPiH3wet9o+UbXeQOqzZd041va83g==
|
integrity sha512-CgSNT9sq2LAlhEbVlPg7DwUQkypz+CWaWGcJbkgmp9WCAy6vW33CQ44UbKPiH3wet9o+UbXeQOqzZd041va83g==
|
||||||
|
|
|
@ -13,7 +13,6 @@ module.exports = {
|
||||||
url: 'https://your-docusaurus-test-site.com',
|
url: 'https://your-docusaurus-test-site.com',
|
||||||
baseUrl: '/',
|
baseUrl: '/',
|
||||||
onBrokenLinks: 'throw',
|
onBrokenLinks: 'throw',
|
||||||
onBrokenMarkdownLinks: 'warn',
|
|
||||||
favicon: 'img/favicon.ico',
|
favicon: 'img/favicon.ico',
|
||||||
organizationName: 'facebook', // Usually your GitHub org/user name.
|
organizationName: 'facebook', // Usually your GitHub org/user name.
|
||||||
projectName: 'docusaurus', // Usually your repo name.
|
projectName: 'docusaurus', // Usually your repo name.
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
"swizzle": "docusaurus swizzle",
|
"swizzle": "docusaurus swizzle",
|
||||||
"deploy": "docusaurus deploy",
|
"deploy": "docusaurus deploy",
|
||||||
"serve": "docusaurus serve",
|
"serve": "docusaurus serve",
|
||||||
"clear": "docusaurus clear",
|
|
||||||
"ci": "yarn lint && yarn prettier:diff",
|
"ci": "yarn lint && yarn prettier:diff",
|
||||||
"lint": "eslint --cache \"**/*.js\" && stylelint \"**/*.css\"",
|
"lint": "eslint --cache \"**/*.js\" && stylelint \"**/*.css\"",
|
||||||
"prettier": "prettier --config .prettierrc --write \"**/*.{js,md}\"",
|
"prettier": "prettier --config .prettierrc --write \"**/*.{js,md}\"",
|
||||||
|
@ -19,7 +18,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@docusaurus/core": "2.0.0-alpha.66",
|
"@docusaurus/core": "2.0.0-alpha.66",
|
||||||
"@docusaurus/preset-classic": "2.0.0-alpha.66",
|
"@docusaurus/preset-classic": "2.0.0-alpha.66",
|
||||||
"@mdx-js/react": "^1.6.21",
|
"@mdx-js/react": "^1.5.8",
|
||||||
"clsx": "^1.1.1",
|
"clsx": "^1.1.1",
|
||||||
"react": "^16.8.4",
|
"react": "^16.8.4",
|
||||||
"react-dom": "^16.8.4"
|
"react-dom": "^16.8.4"
|
||||||
|
@ -39,7 +38,7 @@
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
">0.5%",
|
">0.2%",
|
||||||
"not dead",
|
"not dead",
|
||||||
"not op_mini all"
|
"not op_mini all"
|
||||||
],
|
],
|
||||||
|
|
|
@ -1537,7 +1537,7 @@
|
||||||
unist-builder "2.0.3"
|
unist-builder "2.0.3"
|
||||||
unist-util-visit "2.0.3"
|
unist-util-visit "2.0.3"
|
||||||
|
|
||||||
"@mdx-js/react@^1.5.8", "@mdx-js/react@^1.6.21":
|
"@mdx-js/react@^1.5.8":
|
||||||
version "1.6.21"
|
version "1.6.21"
|
||||||
resolved "https://registry.yarnpkg.com/@mdx-js/react/-/react-1.6.21.tgz#86d962471a5e160c59a6b32054aa55c0c7ca404e"
|
resolved "https://registry.yarnpkg.com/@mdx-js/react/-/react-1.6.21.tgz#86d962471a5e160c59a6b32054aa55c0c7ca404e"
|
||||||
integrity sha512-CgSNT9sq2LAlhEbVlPg7DwUQkypz+CWaWGcJbkgmp9WCAy6vW33CQ44UbKPiH3wet9o+UbXeQOqzZd041va83g==
|
integrity sha512-CgSNT9sq2LAlhEbVlPg7DwUQkypz+CWaWGcJbkgmp9WCAy6vW33CQ44UbKPiH3wet9o+UbXeQOqzZd041va83g==
|
||||||
|
|
|
@ -10,6 +10,9 @@ const rimraf = require('rimraf');
|
||||||
const {readFileSync, writeFileSync, readdir} = require('fs');
|
const {readFileSync, writeFileSync, readdir} = require('fs');
|
||||||
const {execSync} = require('child_process');
|
const {execSync} = require('child_process');
|
||||||
|
|
||||||
|
// Generate one example per init template
|
||||||
|
// We use those generated examples as CodeSandbox projects
|
||||||
|
// See https://github.com/facebook/docusaurus/issues/1699
|
||||||
function generateTemplateExample(template) {
|
function generateTemplateExample(template) {
|
||||||
try {
|
try {
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -18,8 +21,14 @@ function generateTemplateExample(template) {
|
||||||
|
|
||||||
// run the docusaurus script to bootstrap the template in the examples folder
|
// run the docusaurus script to bootstrap the template in the examples folder
|
||||||
execSync(
|
execSync(
|
||||||
`node ./packages/docusaurus-init/bin/index.js init examples/${template} ${template}`,
|
// /!\ we use the published init script on purpose,
|
||||||
{stdio: 'inherit'},
|
// because using the local init script is too early and could generate upcoming/unavailable config options
|
||||||
|
// remember CodeSandbox templates will use the published version, not the repo version
|
||||||
|
`npx @docusaurus/init@next init examples/${template} ${template}`,
|
||||||
|
// `node ./packages/docusaurus-init/bin/index.js init examples/${template} ${template}`,
|
||||||
|
{
|
||||||
|
stdio: 'inherit',
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// read the content of the package.json
|
// read the content of the package.json
|
|
@ -15,7 +15,7 @@
|
||||||
"start:v2:baseUrl": "yarn workspace docusaurus-2-website start:baseUrl",
|
"start:v2:baseUrl": "yarn workspace docusaurus-2-website start:baseUrl",
|
||||||
"start:v2:bootstrap": "yarn workspace docusaurus-2-website start:bootstrap",
|
"start:v2:bootstrap": "yarn workspace docusaurus-2-website start:bootstrap",
|
||||||
"start:v2:blogOnly": "yarn workspace docusaurus-2-website start:blogOnly",
|
"start:v2:blogOnly": "yarn workspace docusaurus-2-website start:blogOnly",
|
||||||
"examples:generate": "node codesandboxscript",
|
"examples:generate": "node generateExamples",
|
||||||
"build": "yarn build:packages && yarn build:v2",
|
"build": "yarn build:packages && yarn build:v2",
|
||||||
"build:packages": "lerna run build --no-private",
|
"build:packages": "lerna run build --no-private",
|
||||||
"build:v1": "yarn workspace docusaurus-1-website build",
|
"build:v1": "yarn workspace docusaurus-1-website build",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue