xref: /expo/docs/scripts/remove-version.js (revision ab4f0d2d)
18970bcfaSBartosz Kaszubowski/**
28970bcfaSBartosz Kaszubowski * This script removes given SDK version from docs website.
38970bcfaSBartosz Kaszubowski * - yarn run remove-version 38 -> removes all the pages and files related to the SDK 38
48970bcfaSBartosz Kaszubowski */
58970bcfaSBartosz Kaszubowski
6d09e6f78SBartosz Kaszubowskiimport fs from 'fs-extra';
78970bcfaSBartosz Kaszubowski
88970bcfaSBartosz Kaszubowskiconst version = process.argv[2];
98970bcfaSBartosz Kaszubowski
108970bcfaSBartosz Kaszubowskiconst run = () => {
118970bcfaSBartosz Kaszubowski  if (!version) {
128970bcfaSBartosz Kaszubowski    console.log('Please enter a version number!\n');
138970bcfaSBartosz Kaszubowski    console.log('E.g., "yarn remove-version 38"');
148970bcfaSBartosz Kaszubowski    return;
158970bcfaSBartosz Kaszubowski  }
168970bcfaSBartosz Kaszubowski
178970bcfaSBartosz Kaszubowski  try {
188970bcfaSBartosz Kaszubowski    const apiDataPath = `public/static/data/v${version}.0.0`;
198970bcfaSBartosz Kaszubowski    if (fs.pathExistsSync(apiDataPath)) {
208970bcfaSBartosz Kaszubowski      fs.rmSync(apiDataPath, { recursive: true });
218970bcfaSBartosz Kaszubowski    }
228970bcfaSBartosz Kaszubowski
238970bcfaSBartosz Kaszubowski    const examplesPath = `public/static/examples/v${version}.0.0`;
248970bcfaSBartosz Kaszubowski    if (fs.pathExistsSync(examplesPath)) {
258970bcfaSBartosz Kaszubowski      fs.rmSync(examplesPath, { recursive: true });
268970bcfaSBartosz Kaszubowski    }
278970bcfaSBartosz Kaszubowski
28*ab4f0d2dSBartosz Kaszubowski    const schemaPath = `public/static/schemas/v${version}.0.0`;
298970bcfaSBartosz Kaszubowski    if (fs.pathExistsSync(schemaPath)) {
308970bcfaSBartosz Kaszubowski      fs.rmSync(schemaPath, { recursive: true });
318970bcfaSBartosz Kaszubowski    }
328970bcfaSBartosz Kaszubowski
338970bcfaSBartosz Kaszubowski    const pagesPath = `pages/versions/v${version}.0.0`;
348970bcfaSBartosz Kaszubowski    if (fs.pathExistsSync(pagesPath)) {
358970bcfaSBartosz Kaszubowski      fs.rmSync(pagesPath, { recursive: true });
368970bcfaSBartosz Kaszubowski    }
378970bcfaSBartosz Kaszubowski  } catch (e) {
388970bcfaSBartosz Kaszubowski    console.error(e);
398970bcfaSBartosz Kaszubowski  }
408970bcfaSBartosz Kaszubowski
418970bcfaSBartosz Kaszubowski  console.log(`�� SDK ${version} files have been removed successfully!`);
428970bcfaSBartosz Kaszubowski};
438970bcfaSBartosz Kaszubowski
448970bcfaSBartosz Kaszubowskirun();
45