This bash script automates the setup of a Directus instance for development purposes, including support for multiple extensions.
- Automatically installs the latest version of Directus
- Actually Directus only supports Node.js 18.x, so the script checks if you have the correct version installed
- Sets up a SQLite database
- Configures environment variables
- Creates an admin user
- Installs development dependencies (nodemon and concurrently)
- Provides options to create and manage Directus extensions
- Sets up development scripts for running Directus with extensions
- Node.js and npm installed on your system (engine 18.x)
⚠️ - Bash shell environment
-
Download the
directus-instance-dev.sh
script to your local machine. -
Make the script executable:
chmod +x directus-instance-dev.sh
-
Run the script:
./directus-instance-dev.sh
-
Follow the prompts to configure your Directus instance:
- Enter a project name
- Specify the port for the Directus server (default is 8055)
- Provide an admin email and password (or let the script generate a random password)
-
The script will set up your Directus project and provide you with the necessary credentials and instructions.
After the script completes, you can:
-
Start the Directus server in development mode:
cd your-project-name npm run dev
-
Start the Directus server normally:
cd your-project-name npm start
-
Create a new Directus extension:
cd your-project-name npm run extension
The following npm scripts are available in your project:
npm start
: Starts the Directus servernpm run dev
: Runs Directus in development mode with extension supportnpm run dev:extensions
: Starts the development process for all extensionsnpm run dev:root
: Runs the Directus server with nodemon, watching for changes in extensionsnpm run extension
: Creates a new Directus extension in the correct directory
- Remember to change the admin password after your first login for security purposes.
- The script generates random keys for encryption and an admin token. These are saved in the
.env
file. - The default database is SQLite. If you need a different database, you'll need to modify the
.env
file manually.
You can modify the directus-instance-dev.sh
script to suit your specific needs. Some areas you might want to customize include:
- Database configuration
- Additional environment variables
- Pre-installing specific Directus extensions
- Modifying the development scripts
If you encounter any issues or have questions about using this script, please open an issue in the project repository or refer to the Directus documentation.