mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-19 01:28:38 +02:00
feat: docusaurus.new + improved StackBlitz playground (#5235)
* Upgrade playground shortcut domain to docusaurus.new * update generateExamples * update generateExamples + re-generate with stackblitz config * test * test * test * test * test * update examples * upgrade lockfile * fix yarnlock * fix yarnlock
This commit is contained in:
parent
4cfbfa11ee
commit
b3e89d2a86
30 changed files with 2000 additions and 1993 deletions
|
@ -7,7 +7,7 @@
|
|||
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
const rimraf = require('rimraf');
|
||||
const {readFileSync, writeFileSync, readdir} = require('fs');
|
||||
const {readFileSync, writeFileSync, readdirSync} = require('fs');
|
||||
const {execSync} = require('child_process');
|
||||
|
||||
// Generate one example per init template
|
||||
|
@ -60,7 +60,7 @@ function generateTemplateExample(template) {
|
|||
);
|
||||
|
||||
// create sandbox.config.json file at the root of template
|
||||
const sandboxConfigContent = {
|
||||
const codeSanboxConfig = {
|
||||
infiniteLoopProtection: true,
|
||||
hardReloadOnChange: true,
|
||||
view: 'browser',
|
||||
|
@ -70,10 +70,18 @@ function generateTemplateExample(template) {
|
|||
node: '14',
|
||||
},
|
||||
};
|
||||
|
||||
writeFileSync(
|
||||
`./examples/${template}/sandbox.config.json`,
|
||||
JSON.stringify(sandboxConfigContent, null, 2),
|
||||
JSON.stringify(codeSanboxConfig, null, 2),
|
||||
);
|
||||
|
||||
const stackBlitzConfig = {
|
||||
installDependencies: true,
|
||||
startCommand: 'npm start',
|
||||
};
|
||||
writeFileSync(
|
||||
`./examples/${template}/.stackblitzrc`,
|
||||
JSON.stringify(stackBlitzConfig, null, 2),
|
||||
);
|
||||
|
||||
console.log(`Generated example for template ${template}`);
|
||||
|
@ -83,11 +91,6 @@ function generateTemplateExample(template) {
|
|||
}
|
||||
}
|
||||
|
||||
// delete the examples directories if they exists
|
||||
rimraf.sync('./examples/classic');
|
||||
rimraf.sync('./examples/facebook');
|
||||
rimraf.sync('./examples/bootstrap');
|
||||
|
||||
/*
|
||||
Starters are repositories/branches that only contains a newly initialized Docusaurus site
|
||||
Those are useful for users to inspect (may be more convenient than "examples/classic)
|
||||
|
@ -96,8 +99,6 @@ See https://github.com/jamstack/jamstack.org/pull/609
|
|||
Button visible here: https://jamstack.org/generators/
|
||||
*/
|
||||
function updateStarters() {
|
||||
console.log('Will update starter repositories / branches');
|
||||
|
||||
execSync(
|
||||
'git subtree push --prefix examples/classic --squash origin starter',
|
||||
);
|
||||
|
@ -119,9 +120,57 @@ function updateStarters() {
|
|||
}
|
||||
}
|
||||
|
||||
// get the list of all available templates
|
||||
readdir('./packages/docusaurus-init/templates', (err, data) => {
|
||||
function run() {
|
||||
const branch = execSync('git rev-parse --abbrev-ref HEAD').toString();
|
||||
if (branch === 'master') {
|
||||
throw new Error(
|
||||
"Please don't generate Docusaurus examples from the master branch!\nWe are going to commit during this process!",
|
||||
);
|
||||
}
|
||||
try {
|
||||
execSync('git diff --exit-code');
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
'Please run the generate examples command with a clean Git state and no uncommited local changes. git diff should display nothing!',
|
||||
);
|
||||
}
|
||||
|
||||
console.log('');
|
||||
console.log('# Generate examples start!');
|
||||
console.log('');
|
||||
|
||||
// delete the examples directories if they exists
|
||||
console.log('-------');
|
||||
console.log('## Removing example folders...');
|
||||
rimraf.sync('./examples/classic');
|
||||
rimraf.sync('./examples/facebook');
|
||||
rimraf.sync('./examples/bootstrap');
|
||||
console.log('');
|
||||
|
||||
// get the list of all available templates
|
||||
console.log('-------');
|
||||
console.log('## Generate example folders...');
|
||||
console.log('');
|
||||
const data = readdirSync('./packages/docusaurus-init/templates');
|
||||
const templates = data.filter((i) => i !== 'README.MD');
|
||||
templates.forEach(generateTemplateExample);
|
||||
console.log('Commiting changes');
|
||||
execSync('git add examples');
|
||||
execSync("git commit -am 'update examples'");
|
||||
console.log('');
|
||||
|
||||
// update starters
|
||||
console.log('-------');
|
||||
console.log('# Updating starter repos and branches ...');
|
||||
console.log('It can take some time... please wait until done...');
|
||||
updateStarters();
|
||||
});
|
||||
|
||||
console.log('');
|
||||
console.log('-------');
|
||||
console.log('');
|
||||
console.log('Generate examples end!');
|
||||
console.log("Don't forget to push and merge your pull-request!");
|
||||
console.log('');
|
||||
}
|
||||
|
||||
run();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue