authentik/website/scripts/docsmg
Bama ff53bccc0f
website/scripts/docsmg: final version (#11501)
* add docsmg tool

* moved to the correct scripts directory

* removed test files

* added install script and readme draft to docsmg

* fix install script

* fixed issues

* Revert "fixed issues"

This reverts commit a51192025f.

* Revert "Revert "fixed issues""

This reverts commit ab68918fea.

* added dotenv and updated readme

* fixed install script

* update readme to ensure that new installers of rust have envs loaded

* changed docsmg from using .env to docsmg.env

* fixed docsmg to fix internal links in file

* fixed docsmg migrate not making directories to file

* fixed docsmg migrate trying to read pngs to string

* did stuff

* fix links

* fix links 2

* fix links 3

* fix links

* fix links

* fix links

* fix links

* fix links

* fixed docsmg migrate replacing links

* fixed docsmg migrate replacing links

* fixed docsmg migrate replacing links

* fixed docsmg migrate replacing links

* fixed links

* update docsmg fixing links

* update docsmg fixing links

* update docsmg fixing links

* update docsmg removing empty directories

* remove changed docs

* Revert "remove changed docs"

This reverts commit 2e21a5bac8.

* remove changed docs

* fixed readme

---------

Signed-off-by: Tana M Berry <tanamarieberry@yahoo.com>
Co-authored-by: Tana M Berry <tanamarieberry@yahoo.com>
2024-09-26 07:32:31 -05:00
..
src website/scripts/docsmg: final version (#11501) 2024-09-26 07:32:31 -05:00
.gitignore website/scripts: Add docsmg migration tool (#10658) 2024-07-26 15:54:41 -05:00
Cargo.lock website/scripts/docsmg: final version (#11501) 2024-09-26 07:32:31 -05:00
Cargo.toml website/scripts/docsmg: final version (#11501) 2024-09-26 07:32:31 -05:00
README.md website/scripts/docsmg: final version (#11501) 2024-09-26 07:32:31 -05:00
install.sh website/scripts/docsmg: Bug fixes (#10668) 2024-07-28 21:32:29 -05:00
m.bash website/scripts: Add docsmg migration tool (#10658) 2024-07-26 15:54:41 -05:00
mcomplete.bash website/scripts/docsmg: Add install script and readme draft (#10659) 2024-07-26 16:52:10 -05:00

README.md

Docsmg

This CLI tool is used to generate a mapping file (migratefile) that is then used by the tool to migrate .md, .mdx, and images file from their current structure into a new structure.

Use this migration tool to:

  • generate the mapping file with the current structure
  • read the completed (manual process to define target structure) and create the directories and move the files.
  • modify the internal, cross-reference links to point to new location
  • write to the netlify.toml file to add redirect entries for all migrated files.

Steps to install

  1. Verify that you have the latest version of rust installed
    • Install rust or update rust to the latest version with rustup update
    • If installing rust from scratch, you may need to run . $HOME/.cargo/env
  2. Install the cli tool with cargo install --git https://github.com/goauthentik/authentik --bin docsmg
  3. In the /website directory, create a file named docsmg.env with the entry of MIGRATE_PATH=./docs.

Steps to use

  1. Generate a migratefile with docsmg generate >> migratefile
  2. Find the files you want to move in migratefile and insert the path you want to move them to after the arrow; ex path/to/move/from/file.md -> path/to/move/to/file.md Note: make sure to put spaces on either side of the arrow or that line won't be recognized
  3. Once you have entered all the paths you want to move, migrate the files with docsmg migrate
  4. To revert the migration, use docsmg unmigrate; Note: DO NOT edit the migrate file in between steps 3 and 4
  5. Repeat steps 2-4 until you are satisfied with the result

Create the mapping file (migratefile)

  1. Navigate to the authentik/website dir.

  2. Generate a migratefile with docsmg generate | sort >> migratefile. You can also just run docsmg generate | sort to see the output in the terminal, before writing it to a file.

    :::info The new migratefile will be created in the /website dir. :::

  3. Edit the migratefile to add the target directory paths in the new structure for each entry. For each file listed in migratefile insert the path you want to move them to. EXAMPLE: path/to/move/from/file.md -> path/to/move/to/file.md

    Note: make sure to put spaces on either side of the arrow or that line won't be recognized.

Migrate the docs

  1. After you have entered all the paths you want to move, migrate the files with the command docsmg migrate.

:::info After you have run migrate, you cannot run it again or you will get a panic error... because the files have already been moved. :::

  1. To revert the migration, use docsmg unmigrate. Note: DO NOT edit the migratefile file before running unmigrate.
  2. Continue modifying the migratefile file and then using the docsmg migrate command until you are satisfied with the result.

Update the sidebar.js file

Because the structure is completely changed, you will need to modify/reconstruct the navigation bar.

Test the results

To test the internal links, navigate up a level to authentik and then run make website-watch.

Troubleshooting

  • If the docsmg generate command pulls all of the files in the repo (even non-docs files), then check that:
    • the docsmg.env exists
    • that it is in /website
    • the content is MIGRATE_PATH=./docs