xref: /expo/docs/scripts/remove-version.js (revision ab4f0d2d)
1/**
2 * This script removes given SDK version from docs website.
3 * - yarn run remove-version 38 -> removes all the pages and files related to the SDK 38
4 */
5
6import fs from 'fs-extra';
7
8const version = process.argv[2];
9
10const run = () => {
11  if (!version) {
12    console.log('Please enter a version number!\n');
13    console.log('E.g., "yarn remove-version 38"');
14    return;
15  }
16
17  try {
18    const apiDataPath = `public/static/data/v${version}.0.0`;
19    if (fs.pathExistsSync(apiDataPath)) {
20      fs.rmSync(apiDataPath, { recursive: true });
21    }
22
23    const examplesPath = `public/static/examples/v${version}.0.0`;
24    if (fs.pathExistsSync(examplesPath)) {
25      fs.rmSync(examplesPath, { recursive: true });
26    }
27
28    const schemaPath = `public/static/schemas/v${version}.0.0`;
29    if (fs.pathExistsSync(schemaPath)) {
30      fs.rmSync(schemaPath, { recursive: true });
31    }
32
33    const pagesPath = `pages/versions/v${version}.0.0`;
34    if (fs.pathExistsSync(pagesPath)) {
35      fs.rmSync(pagesPath, { recursive: true });
36    }
37  } catch (e) {
38    console.error(e);
39  }
40
41  console.log(`�� SDK ${version} files have been removed successfully!`);
42};
43
44run();
45