Bootstrapping new projects comes with some friction. Even if it only takes a couple of commands, taking the time to come up with a project name or waiting for packages to install can disrupt your flow.
If you regularly create scratchpad projects using the same template, it's helpful to always have an empty project ready.
That's what nextpage
does: it prepares a spare project for you, so it's
ready when you need it. You can start working immediately while another spare
project is bootstrapped in the background.
Run the nextpage
to initialize the current directory:
npx @myandrienko/nextpage
A .nextpage
subdirectory is created with the default configuration:
.nextpage
├ template ← project structure
│ └ README.md
├ open ← launch an editor, IDE...
└ prepare ← install dependencies
Run nextpage
again to bootstrap and open your first project:
npx @myandrienko/nextpage
A spare project is also created.
Install globally from npm:
npm install -g @myandrienko/nextpage
pnpm add -g @myandrienko/nextpage
Run the nextpage
command in the directory where you store your scratchpad
projects:
nextpage
This will initialize the scratchpad directory by adding the .nextpage
subdirectory:
.nextpage
├ template
│ └ README.md
├ open
└ prepare
Running the nextpage
command again at this point will bootstrap and open your
first project (using the default template) and prepare a spare project.
You can configure how the project opens and customize the bootstrapping process
by editing the files in the .nextpage
subdirectory.
The open
script opens a prepared project. In this script, you probably want to
launch your favorite editor or IDE. You may also want to execute additional
commands, like launching a dev server:
.nextpage/open:
#!/usr/bin/env bash
code . # open project in vscode
npm run dev # start dev server
When this script is executed, cwd is the prepared project's directory. The
randomly generated project name is also passed to the script via the $NEXTPAGE
environment variable, though you likely won't need it.
The prepare
script contains the bootstrapping steps. It is used to prepare a
spare project. First, the .nextpage/template
directory is used to create a new
directory with a randomly generated name. Then, the prepare
script is executed
in this directory.
For example, for a Node project you might want to have a template with a
package.json
file and install dependencies in the prepare
script:
.nextpage
├ template
│ └ package.json
├ open
└ prepare
.nextpage/prepare:
#!/usr/bin/env bash
npm install
Ensure that the open
and prepare
files are executable; otherwise, they will
be ignored.
Since the bootstrapping steps are executed in advance, there's always a randomly
named spare project prepared. Its name is stored in the .nextpage/next
file.
Do not edit this file manually.