Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI - init command #380

Open
webketje opened this issue Aug 23, 2022 · 1 comment
Open

CLI - init command #380

webketje opened this issue Aug 23, 2022 · 1 comment

Comments

@webketje
Copy link
Member

Sample usage:

metalsmith create <app> [-o <dest>] [--force]

Where app is a "registered" metalsmith starter. "Registered" means as much as "committed to a source file in the package".
The command should:

  • not bloat the main NPM package or git repo with starters code
  • consider . the default destination
  • error when the destination is not empty (unless --force option is passed)
  • support using git repositories as source. The command would proxy a git clone --depth=1 command, see also: https://www.systutorials.com/how-to-clone-a-snapshot-of-a-remote-repository-at-a-specific-branch/. This stays true to metalsmith's simplicity and avoids relying on OS-specific/optional soft (like unzip/curl etc) and offers a DX as good as npx @org/pkg without requiring NPM (which brings its own share of trouble, ie what if the used pkg mgr is yarn or pnpm?)
  • (alternative) support using git repositories as source. The command would proxy a git clone --depth=1 command, see also: https://www.systutorials.com/how-to-clone-a-snapshot-of-a-remote-repository-at-a-specific-branch/. This stays true to metalsmith's simplicity and avoids relying on OS-specific/optional soft (like unzip/curl etc) and offers a DX as good as npx @org/pkg without requiring NPM (which brings its own share of trouble, ie what if the used pkg mgr is yarn or pnpm?)
  • should provide a shortcut to specifying full git repo URL's. This could be like npm install's coupling to github npm i <author>/<repo> which involves text parsing, or with an alias registry (similar to metalsmith.io's plugin registry).
  • (nice to have) allow cloning subdirectories?
  • (optional) is there a use case for setting up a pre/post-install script? I don't really see one

It would be nice to have a signature like metalsmith create company-website & metalsmith create basic/express-app&metalsmith create :namespace/portfolio|resume

@webketje
Copy link
Member Author

Second thoughts: scope is too broad. metalsmith init [--bare] [--json] <folder> will do and would set up a boilerplate with some essential core plugins like @metalsmith/layouts, @metalsmith/markdown, @metalsmith/permalinks and metalsmith-gzip and metalsmith-html-minifier, as well as some sane companion libraries like dotenv and prettier.

The --bare option would not add any plugins or content.
The --json option would output a metalsmith.json instead of a metalsmith.js.
The basic features to demonstrate are:

  • loading env vars into metalsmith
  • toggling the DEBUG env var
  • switching between watch & single build modes
  • defining common npm scripts

@webketje webketje changed the title CLI - create command CLI - init command Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant