mops init
Initialize a new Motoko project or package in the current directory.
mops init
Exits without changes if mops.toml already exists.
Interactive prompts
1. Project type
Select type:
› Project (I just want to use mops packages in my project)
Package (I plan to publish this package on mops)
- Project — you want to consume mops packages. No
[package]section is written. - Package — you plan to publish to the mops registry. Prompts for metadata and creates starter files.
2. Package metadata (package only)
- Name — defaults to the kebab-cased directory name
- Description
- Repository URL
- Keywords — space-separated
- License —
MITorApache-2.0 - Copyright owner — written into the license file
- Add example test file? — defaults to yes, creates
test/lib.test.mo
The version is initialized to 1.0.0.
3. GitHub workflow
Setup GitHub workflow? (run `mops test` on push)
When accepted, adds .github/workflows/mops-test.yml that runs mops test on push to main/master and on every pull request.
What it creates
dfx.json— setsdefaults.build.packtool = "mops sources"ifdfx.jsonis present. Existing indentation is preserved.mops.toml—[package]metadata for packages. For projects,[dependencies]is populated with the default package set keyed on yourdfxversion (fromdfx.jsonordfx --versiononPATH). Olderdfxversions0.9.0–0.27.0resolve to thebaserelease bundled with thatdfx. For any other version, or whendfxcannot be detected, the latestcoreis used.src/lib.mo— starter module (package only, whensrc/doesn't exist).test/lib.test.mo— starter test (package only, when you opted in andtest/doesn't exist).LICENSE(andNOTICEfor Apache-2.0) — package only, filled with the current year and copyright owner.README.md— package only, with placeholders replaced by the package name..github/workflows/mops-test.yml— when the workflow prompt was accepted..mopsand.migrations-*/appended to.gitignore(created if missing).
Existing LICENSE, README.md, and workflow files are not overwritten.
For projects, mops install runs at the end to fetch the default packages.
Migrating from Vessel
If vessel.dhall exists, mops init reads it and copies the listed dependencies into the new mops.toml. Dev-dependencies are not migrated. Skipped when --yes is used.
Options
--yes, -y
Skip prompts and initialize as a project with defaults: no [package] section, no starter files, GitHub workflow enabled, default packages installed per the rules in What it creates. Useful for CI and scripted scaffolding.
mops init --yes