├── .bench ├── 1-buffer-vector-add.bench.json ├── 2-vector-buffer-add.bench.json ├── array.bench.json ├── removeLast.bench.json └── stable-memory.bench.json ├── .editorconfig ├── .eslintrc.json ├── .github └── workflows │ ├── benchmarks.yml │ ├── build-hash.yml │ ├── ci.yml │ ├── cli-bundle.yml │ ├── lint.yml │ ├── mops-test-mac.yml │ ├── mops-test.yml │ └── setup-mops.yml ├── .gitignore ├── .husky ├── pre-commit └── pre-commit.js ├── .npmrc ├── DEVELOPMENT.md ├── LICENSE ├── README.md ├── backend ├── generate-id.mo ├── main │ ├── DownloadLog.mo │ ├── PackagePublisher.mo │ ├── Users.mo │ ├── badges.mo │ ├── main-canister.mo │ ├── registry │ │ ├── Registry.mo │ │ ├── getDefaultPackages.mo │ │ ├── getPackageChanges.mo │ │ ├── getPackageDetails.mo │ │ ├── getPackageSummary.mo │ │ ├── packagesByCategory.mo │ │ └── searchInRegistry.mo │ ├── types.mo │ ├── utils │ │ ├── is-letter.mo │ │ ├── package-utils.mo │ │ ├── semver.mo │ │ ├── validateConfig.mo │ │ └── validateLicense.mo │ └── verifyPackageRepository.mo ├── storage │ ├── storage-canister.mo │ ├── storage-manager.mo │ └── types.mo └── utils.mo ├── bench ├── 1-buffer-vector-add.bench.mo ├── 2-vector-buffer-add.bench.mo ├── array.bench.mo ├── removeLast.bench.mo └── stable-memory.bench.mo ├── blog ├── .gitignore ├── README.md ├── babel.config.js ├── blog │ ├── 0-unlisted.md │ ├── 2024-07-30 │ │ └── index.md │ ├── 2024-09-13 │ │ └── index.md │ ├── 2024-10-08 │ │ └── index.md │ ├── 2024-12-11 │ │ └── index.md │ ├── 2025-06-01 │ │ └── index.md │ ├── authors.yml │ └── tags.yml ├── docusaurus.config.js ├── package-lock.json ├── package.json ├── sidebars.js ├── src │ ├── components │ │ └── HomepageFeatures │ │ │ ├── index.js │ │ │ └── styles.module.css │ └── css │ │ └── custom.css └── static │ ├── .ic-assets.json │ ├── .nojekyll │ ├── .well-known │ └── ic-domains │ └── img │ └── logo.svg ├── canister_ids.json ├── cli-builder ├── Dockerfile └── README.md ├── cli-releases ├── .ic-assets.json ├── .well-known │ └── ic-domains ├── frontend │ ├── .eslintignore │ ├── .eslintrc.cjs │ ├── .gitignore │ ├── .npmrc │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── app.d.ts │ │ ├── app.html │ │ ├── components │ │ │ ├── Header.svelte │ │ │ └── Install.svelte │ │ ├── lib │ │ │ ├── index.ts │ │ │ └── markdown-to-html.ts │ │ ├── mops.svg │ │ └── routes │ │ │ ├── +layout.ts │ │ │ └── +page.svelte │ ├── static │ │ └── mops.svg │ ├── svelte.config.js │ ├── tsconfig.json │ └── vite.config.ts ├── install.sh ├── package-lock.json ├── package.json ├── releases.json ├── tags │ └── latest └── versions │ ├── 0.41.0.tgz │ ├── 0.41.1.tgz │ ├── 0.42.0.tgz │ ├── 0.42.1.tgz │ ├── 0.43.0.tgz │ ├── 0.44.0.tgz │ ├── 0.44.1.tgz │ ├── 0.45.0.tgz │ ├── 0.45.2.tgz │ ├── 0.45.3.tgz │ ├── 0.tgz │ ├── 1.0.0.tgz │ ├── 1.0.1.tgz │ ├── 1.1.0.tgz │ ├── 1.1.1.tgz │ ├── 1.1.2.tgz │ ├── 1.2.0.tgz │ ├── 1.3.0.tgz │ ├── 1.4.0.tgz │ ├── 1.5.0.tgz │ ├── 1.5.1.tgz │ ├── 1.6.0.tgz │ ├── 1.6.1.tgz │ ├── 1.7.0.tgz │ ├── 1.7.1.tgz │ ├── 1.7.2.tgz │ ├── 1.8.0.tgz │ ├── 1.tgz │ └── latest.tgz ├── cli ├── .eslintrc.json ├── .gitignore ├── .npmrc ├── CHANGELOG.md ├── DEVELOPMENT.md ├── Dockerfile ├── README.md ├── api │ ├── actors.ts │ ├── downloadPackageFiles.ts │ ├── getHighestVersion.ts │ ├── index.ts │ ├── network.ts │ └── resolveVersion.ts ├── bin │ ├── moc-wrapper.sh │ └── mops.js ├── build.sh ├── bundle-package-json.ts ├── cache.ts ├── check-requirements.ts ├── cli.ts ├── commands │ ├── add.ts │ ├── available-updates.ts │ ├── bench-replica.ts │ ├── bench.ts │ ├── bench │ │ ├── bench-canister.mo │ │ └── user-bench.mo │ ├── bump.ts │ ├── docs.ts │ ├── format.ts │ ├── init.ts │ ├── install │ │ ├── install-all.ts │ │ ├── install-dep.ts │ │ ├── install-deps.ts │ │ ├── install-local-dep.ts │ │ ├── install-mops-dep.ts │ │ └── sync-local-cache.ts │ ├── maintainer.ts │ ├── outdated.ts │ ├── owner.ts │ ├── publish.ts │ ├── remove.ts │ ├── replica.ts │ ├── search.ts │ ├── self.ts │ ├── sources.ts │ ├── sync.ts │ ├── template.ts │ ├── test │ │ ├── mmf1.ts │ │ ├── reporters │ │ │ ├── compact-reporter.ts │ │ │ ├── files-reporter.ts │ │ │ ├── reporter.ts │ │ │ ├── silent-reporter.ts │ │ │ └── verbose-reporter.ts │ │ ├── test.ts │ │ └── utils.ts │ ├── toolchain │ │ ├── index.ts │ │ ├── moc.ts │ │ ├── pocket-ic.ts │ │ ├── toolchain-utils.ts │ │ └── wasmtime.ts │ ├── update.ts │ ├── user.ts │ └── watch │ │ ├── deployer.ts │ │ ├── error-checker.ts │ │ ├── formatter.ts │ │ ├── generator.ts │ │ ├── globMoFiles.ts │ │ ├── parseDfxJson.ts │ │ ├── tester.ts │ │ ├── warning-checker.ts │ │ └── watch.ts ├── declarations │ ├── bench │ │ ├── bench.did │ │ ├── bench.did.d.ts │ │ ├── bench.did.js │ │ ├── index.d.ts │ │ └── index.js │ ├── main │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── main.did │ │ ├── main.did.d.ts │ │ └── main.did.js │ └── storage │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── storage.did │ │ ├── storage.did.d.ts │ │ └── storage.did.js ├── fix-dist.ts ├── global.d.ts ├── helpers │ ├── find-changelog-entry.ts │ ├── get-dep-name.ts │ ├── get-dfx-version.ts │ ├── get-moc-path.ts │ ├── get-moc-version.ts │ └── get-package-id.ts ├── integrity.ts ├── mops.ts ├── notify-installs.ts ├── package-lock.json ├── package.json ├── parallel.ts ├── pem.ts ├── release-cli.ts ├── resolve-packages.ts ├── templates.ts ├── templates │ ├── README.md │ ├── licenses │ │ ├── Apache-2.0 │ │ ├── Apache-2.0-NOTICE │ │ └── MIT │ ├── mops-publish.yml │ ├── mops-test.yml │ ├── src │ │ └── lib.mo │ └── test │ │ └── lib.test.mo ├── tsconfig.json ├── types.ts ├── verify.sh └── vessel.ts ├── dfx.json ├── dfx.schema.json ├── docs ├── .eslintrc.json ├── .gitignore ├── .npmrc ├── README.md ├── babel.config.js ├── docs │ ├── 00-introduction.md │ ├── 01-quick-start.md │ ├── 09-mops.toml.md │ ├── 10-mops.lock.md │ ├── articles │ │ ├── 00-dependency-version-pinning.md │ │ ├── 01-how-dependecy-resolution-works.md │ │ ├── 02-how-to-version-a-package.md │ │ ├── 03-package-owners-and-maintainers.md │ │ └── _category_.json │ └── cli │ │ ├── 00-mops-init.md │ │ ├── 1-deps │ │ ├── 01-mops-add.md │ │ ├── 01-mops-remove.md │ │ ├── 02-mops-install.md │ │ ├── 03-mops-outdated.md │ │ ├── 04-mops-update.md │ │ ├── 05-mops-sync.md │ │ └── _category_.json │ │ ├── 2-publish │ │ ├── 01-mops-publish.md │ │ ├── 02-mops-bump.md │ │ ├── 05-mops-owner.md │ │ ├── 06-mops-maintainer.md │ │ └── _category_.json │ │ ├── 3-user │ │ ├── 01-mops-user-import.md │ │ ├── 02-mops-user-get-principal.md │ │ ├── 03-mops-user-set.md │ │ ├── _category_.json │ │ └── user-info.png │ │ ├── 4-dev │ │ ├── 01-mops-test.md │ │ ├── 01-mops-watch.md │ │ ├── 02-mops-bench.md │ │ ├── 02-mops-format.md │ │ └── _category_.json │ │ ├── 5-toolchain │ │ ├── 01-toolchain-overview.md │ │ ├── 02-mops-toolchain-init.md │ │ ├── 03-mops-toolchain-use.md │ │ ├── 04-mops-toolchain-update.md │ │ ├── 05-mops-toolchain-bin.md │ │ ├── 06-mops-toolchain-rest.md │ │ ├── _category_.json │ │ └── mops-toolchain-use-moc.png │ │ ├── 6-self │ │ ├── 01-mops-self-update.md │ │ ├── 02-mops-self-uninstall.md │ │ └── _category_.json │ │ ├── 7-misc │ │ ├── 03-mops-cache.md │ │ ├── 04-mops-sources.md │ │ └── _category_.json │ │ ├── _category_.json │ │ └── structure ├── docusaurus.config.js ├── package-lock.json ├── package.json ├── sidebars.js ├── src │ ├── components │ │ └── HomepageFeatures │ │ │ ├── index.tsx │ │ │ └── styles.module.css │ ├── css │ │ └── custom.css │ └── pages │ │ ├── index-old.tsx │ │ ├── index.module.css │ │ └── markdown-page.md ├── static │ ├── .ic-assets.json │ ├── .nojekyll │ ├── .well-known │ │ └── ic-domains │ └── img │ │ ├── docusaurus-social-card.jpg │ │ ├── docusaurus.png │ │ ├── favicon.ico │ │ ├── logo.svg │ │ ├── undraw_docusaurus_mountain.svg │ │ ├── undraw_docusaurus_react.svg │ │ └── undraw_docusaurus_tree.svg └── tsconfig.json ├── frontend ├── .eslintrc.json ├── .ic-assets.json ├── .npmrc ├── .well-known │ └── ic-domains ├── components │ ├── App.svelte │ ├── ColorizedValue.svelte │ ├── Date.svelte │ ├── DownloadTrend.svelte │ ├── Footer.svelte │ ├── Header.svelte │ ├── Home.svelte │ ├── Loader.svelte │ ├── Modal.svelte │ ├── NotFound.svelte │ ├── PackagesByCategory.svelte │ ├── RecentlyUpdatedPackages.svelte │ ├── SearchResults.svelte │ ├── TopPackages.svelte │ ├── TotalStats.svelte │ ├── docs │ │ ├── ConfigDoc.svelte │ │ ├── InstallDoc.svelte │ │ ├── PublishDoc.svelte │ │ └── docs.css │ ├── links │ │ ├── Discord.svelte │ │ ├── GitHub.svelte │ │ ├── Logo.svelte │ │ └── Twitter.svelte │ └── package │ │ ├── BadgesModal.svelte │ │ ├── Keywords.svelte │ │ ├── Package.svelte │ │ ├── PackageBenchmark.svelte │ │ ├── PackageBenchmarks.svelte │ │ ├── PackageBenchmarksDiff.svelte │ │ ├── PackageCard.svelte │ │ ├── PackageCode.svelte │ │ ├── PackageCodeTreeView.svelte │ │ ├── PackageDocs.svelte │ │ ├── PackageQualityIcon.svelte │ │ ├── PackageReadme.svelte │ │ ├── PackageRightPanel.svelte │ │ ├── PackageTestStats.svelte │ │ ├── PackageTestStatsLine.svelte │ │ ├── PackageVersionSummary.svelte │ │ └── UserCard.svelte ├── declarations │ ├── bench │ │ ├── bench.did │ │ ├── bench.did.d.ts │ │ ├── bench.did.js │ │ ├── index.d.ts │ │ └── index.js │ ├── main │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── main.did │ │ ├── main.did.d.ts │ │ └── main.did.js │ └── storage │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── storage.did │ │ ├── storage.did.d.ts │ │ └── storage.did.js ├── external │ ├── gfm-table.css │ └── onig@1.7.0.wasm ├── global.d.ts ├── img │ ├── discord.svg │ ├── github.svg │ ├── mops-motoko.svg │ ├── mops.svg │ ├── mops2.svg │ ├── motoko.svg │ ├── sad-mops.svg │ ├── search.svg │ └── twitter.svg ├── index.html ├── index.ts ├── logic │ ├── actors.ts │ ├── benchmark-utils.ts │ ├── compare-versions.ts │ ├── get-quality-points.ts │ ├── get-starry-night.ts │ └── markdown-to-html.ts ├── package-lock.json ├── package.json ├── svelte.config.cjs ├── tsconfig.json ├── types.d.ts └── vite.config.ts ├── mops.lock ├── mops.toml ├── package-lock.json ├── package.json ├── test ├── .alias │ ├── ccc0 │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ ├── ccc1 │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ └── main │ │ ├── Changelog.md │ │ ├── README.md │ │ ├── mops.toml │ │ ├── src │ │ ├── a.mo │ │ ├── a │ │ │ ├── a.mo │ │ │ ├── b.mo │ │ │ └── lib.mo │ │ ├── b │ │ │ ├── a.mo │ │ │ ├── b.mo │ │ │ └── lib.mo │ │ └── lib.mo │ │ └── test │ │ ├── lib.test.mo │ │ ├── suite.test.mo │ │ └── test.mo ├── .deep │ ├── aa │ │ ├── README.md │ │ ├── mops.toml │ │ └── src │ │ │ └── test.mo │ ├── bb │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ ├── cc │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ ├── dd │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ ├── ee │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ ├── ff │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ ├── gg │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ ├── mops.toml │ └── pub ├── .flat │ ├── aaa │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ ├── bbb │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ ├── ccc │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ ├── ddd │ │ ├── README.md │ │ ├── mops.toml │ │ ├── test copy 10.mo │ │ ├── test copy 11.mo │ │ ├── test copy 12.mo │ │ ├── test copy 13.mo │ │ ├── test copy 2.mo │ │ ├── test copy 3.mo │ │ ├── test copy 4.mo │ │ ├── test copy 5.mo │ │ ├── test copy 6.mo │ │ ├── test copy 7.mo │ │ ├── test copy 8.mo │ │ ├── test copy 9.mo │ │ ├── test copy.mo │ │ └── test.mo │ ├── eee │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ ├── fff │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ ├── ggg │ │ ├── README.md │ │ ├── mops.toml │ │ └── test.mo │ ├── mops.toml │ └── pub ├── .hello │ ├── Changelog.md │ ├── README.md │ ├── mops.toml │ ├── src │ │ ├── a.mo │ │ ├── a │ │ │ ├── a.mo │ │ │ ├── b.mo │ │ │ └── lib.mo │ │ ├── b │ │ │ ├── a.mo │ │ │ ├── b.mo │ │ │ └── lib.mo │ │ └── lib.mo │ └── test │ │ ├── lib.test.mo │ │ ├── suite.test.mo │ │ └── test.mo ├── .staging-alias │ ├── mops.toml │ └── test │ │ └── simple.test.mo ├── .staging-conflict │ ├── mops.toml │ └── test │ │ └── simple.test.mo ├── datetime.test.mo ├── download-log.test.mo ├── download-trend.test.mo ├── hello.test.mo ├── is-letter.test.mo ├── is-type.test.mo ├── main-canister.test.mo ├── simple.test.mo ├── storage-actor.test.mo ├── storage.test.mo ├── users.test.mo └── validate-license.test.mo └── ui-kit ├── .eslintrc.json ├── .npmrc ├── index.js ├── mops-navbar.js ├── mops.svg.js └── package.json /.bench/removeLast.bench.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "moc": "0.12.1", 4 | "replica": "pocket-ic", 5 | "replicaVersion": "4.0.0", 6 | "gc": "copying", 7 | "forceGc": true, 8 | "results": [ 9 | [ 10 | "Vector:remove 70k", 11 | { 12 | "rts_stable_memory_size": 0, 13 | "stable_memory_size": 0, 14 | "instructions": 32210297, 15 | "rts_memory_size": 0, 16 | "rts_total_allocation": 2716, 17 | "rts_collector_instructions": -1326219, 18 | "rts_mutator_instructions": -11870, 19 | "rts_logical_stable_memory_size": 0, 20 | "rts_heap_size": -140080, 21 | "rts_reclaimed": 142796 22 | } 23 | ], 24 | [ 25 | "Buffer:remove 70k", 26 | { 27 | "rts_stable_memory_size": 0, 28 | "stable_memory_size": 0, 29 | "instructions": 31716422, 30 | "rts_memory_size": 0, 31 | "rts_total_allocation": 277160, 32 | "rts_collector_instructions": -2551425, 33 | "rts_mutator_instructions": -7922, 34 | "rts_logical_stable_memory_size": 0, 35 | "rts_heap_size": -276236, 36 | "rts_reclaimed": 553396 37 | } 38 | ] 39 | ] 40 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{mo,ts,js,html,css,svelte}] 2 | indent_style = tab 3 | end_of_line = lf 4 | insert_final_newline = false 5 | trim_trailing_whitespace = true -------------------------------------------------------------------------------- /.github/workflows/build-hash.yml: -------------------------------------------------------------------------------- 1 | name: Build CLI and print hash 2 | 3 | on: 4 | push: 5 | 6 | jobs: 7 | build: 8 | strategy: 9 | matrix: 10 | os: [ubuntu-22.04, ubuntu-24.04] 11 | runs-on: ${{ matrix.os }} 12 | name: ${{ matrix.os }} 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Build using Docker 16 | run: | 17 | # MOPS_VERSION=$(cd cli && npm pkg get version | tr -d \") 18 | # echo MOPS_VERSION=$MOPS_VERSION 19 | # if [ -z "$MOPS_VERSION" ]; then 20 | # echo "MOPS_VERSION is empty" 21 | # exit 1 22 | # fi 23 | MOPS_VERSION=0.0.0 24 | cd cli 25 | docker build . --build-arg COMMIT_HASH=${{ github.sha }} --build-arg MOPS_VERSION=$MOPS_VERSION -t mops 26 | docker run --rm mops || echo "." -------------------------------------------------------------------------------- /.github/workflows/cli-bundle.yml: -------------------------------------------------------------------------------- 1 | name: CLI bundle 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - master 8 | pull_request: 9 | 10 | jobs: 11 | build: 12 | strategy: 13 | matrix: 14 | node-version: [18, 20, 24] 15 | os: [ubuntu-latest] 16 | 17 | runs-on: ${{ matrix.os }} 18 | name: ${{ matrix.os }}, node ${{ matrix.node-version }} 19 | 20 | steps: 21 | - uses: actions/checkout@v4 22 | - uses: actions/setup-node@v4 23 | with: 24 | node-version: ${{ matrix.node-version }} 25 | cache: 'npm' 26 | 27 | - name: Install npm dependencies 28 | run: cd cli && npm i 29 | 30 | - name: Prepare 31 | run: cd cli && npm run prepare 32 | 33 | - name: Bundle 34 | run: cd cli && npm run bundle 35 | 36 | - name: Check local bundle 37 | run: node ./cli/bundle/cli.js -v 38 | 39 | - name: Install bundle globally 40 | run: npm i -g ./cli/bundle/cli.tgz 41 | 42 | - name: Check global bundle 43 | run: mops -v 44 | 45 | - run: mops format -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: lint 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - master 8 | pull_request: 9 | 10 | jobs: 11 | lint: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - uses: actions/setup-node@v4 16 | with: 17 | node-version: 20 18 | - name: Lint 19 | run: | 20 | npm i 21 | npm run lint -------------------------------------------------------------------------------- /.github/workflows/setup-mops.yml: -------------------------------------------------------------------------------- 1 | name: mops test with ZenVoich/setup-mops 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | name: Test with ZenVoich/setup-mops 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - uses: ZenVoich/setup-mops@v1 17 | with: 18 | mops-version: 1.0.0 19 | 20 | - name: Run tests 21 | run: mops test -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | .dfx 4 | .vscode 5 | .mops 6 | .DS_Store -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | # npm run lint && npm run test && (cd cli && npm run check) 2 | node .husky/pre-commit.js -------------------------------------------------------------------------------- /.husky/pre-commit.js: -------------------------------------------------------------------------------- 1 | import {promisify} from 'node:util'; 2 | import {exec} from 'node:child_process'; 3 | 4 | let execAsync = promisify(exec); 5 | 6 | try { 7 | await Promise.all([ 8 | execAsync('npm run lint'), 9 | execAsync('npm run test'), 10 | execAsync('npm run check', {cwd: 'cli'}), 11 | execAsync('npm run check', {cwd: 'frontend'}), 12 | ]); 13 | } 14 | catch (error) { 15 | console.error(error.stdout); 16 | console.error(error.stderr); 17 | process.exit(error.code); 18 | } -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | save-exact = true -------------------------------------------------------------------------------- /DEVELOPMENT.md: -------------------------------------------------------------------------------- 1 | # Development 2 | 3 | ## Folder structure 4 | 5 | - `backend/` - Source code for the backend 6 | - `backend/main/` - Package registry canister 7 | - `backend/storage/` - Storage canisters 8 | - `frontend/` - Source code for the package registry frontend ([mops.one](https://mops.one)) 9 | - `cli/` - Source code for the `mops` command line tool 10 | - `cli-builder/` - Docker base image for reproducible Mops CLI builds 11 | - `cli-release/` - Mops CLI builds and frontend 12 | - `cli-release/frontend/` - Frontend for the Mops CLI ([cli.mops.one](https://cli.mops.one)) 13 | - `cli-release/versions/` - Mops CLI versions 14 | - `docs/` - Mops documentation ([docs.mops.one](https://docs.mops.one)) 15 | - `blog/` - Mops blog ([blog.mops.one](https://blog.mops.one)) 16 | - `ui-kit/` - Mops UI Kit with shared UI components 17 | - `bench/` - Dogfood for `mops bench` command 18 | - `test/` - Dogfood for `mops test` command 19 | 20 | ## Local Development 21 | `npm start` - starts local replica and dev server 22 | 23 | To be able to install/publish packages locally: 24 | 25 | 1. Install `tsx` globally 26 | ``` 27 | npm install -g tsx 28 | ``` 29 | 30 | 2. Add `mops-local` alias to your shell (`~/.zshrc`, `~/.bashrc`) 31 | ```bash 32 | alias mops-local="tsx //cli/cli.ts" 33 | ``` 34 | 35 | 3. Switch network to local 36 | ``` 37 | mops-local set-network local 38 | ``` 39 | 40 | Now you can install/publish packages locally like this `mops-local add ` -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Zen Voich 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /backend/generate-id.mo: -------------------------------------------------------------------------------- 1 | import Random "mo:base/Random"; 2 | import Blob "mo:base/Blob"; 3 | import Nat8 "mo:base/Nat8"; 4 | 5 | module { 6 | public func generateId() : async Text { 7 | let b = await Random.blob(); 8 | let ar = Blob.toArray(b); 9 | Nat8.toText(ar[0]) # Nat8.toText(ar[1]) # Nat8.toText(ar[2]) # Nat8.toText(ar[3]) # Nat8.toText(ar[4]) # Nat8.toText(ar[5]) # Nat8.toText(ar[6]) 10 | }; 11 | }; -------------------------------------------------------------------------------- /backend/main/utils/is-letter.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func isLowerCaseLetter(char : Char) : Bool { 3 | let letters = "abcdefghijklmnopqrstuvwxyz"; 4 | for (letter in letters.chars()) { 5 | if (char == letter) { 6 | return true; 7 | } 8 | }; 9 | return false; 10 | }; 11 | 12 | public func isUpperCaseLetter(char : Char) : Bool { 13 | let letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 14 | for (letter in letters.chars()) { 15 | if (char == letter) { 16 | return true; 17 | } 18 | }; 19 | return false; 20 | }; 21 | 22 | public func isLetter(char : Char) : Bool { 23 | isLowerCaseLetter(char) or isUpperCaseLetter(char); 24 | }; 25 | }; -------------------------------------------------------------------------------- /backend/main/utils/package-utils.mo: -------------------------------------------------------------------------------- 1 | import Types "../types"; 2 | import Iter "mo:base/Iter"; 3 | import Text "mo:base/Text"; 4 | 5 | module { 6 | public type PackageName = Types.PackageName; 7 | public type PackageVersion = Types.PackageVersion; 8 | public type AliasVersion = Types.AliasVersion; 9 | public type PackageId = Types.PackageId; 10 | public type PackageFileStats = Types.PackageFileStats; 11 | public type PackageChanges = Types.PackageChanges; 12 | 13 | public func getPackageId(name : PackageName, version : PackageVersion) : PackageId { 14 | getDepName(name) # "@" # version; 15 | }; 16 | 17 | public func parsePackageId(packageId : PackageId) : (PackageName, PackageVersion) { 18 | let parts = Iter.toArray(Text.split(packageId, #char('@'))); 19 | (parts[0], parts[1]); 20 | }; 21 | 22 | public func parseDepName(depName : PackageName) : (PackageName, AliasVersion) { 23 | let parts = Iter.toArray(Text.split(depName, #char('@'))); 24 | if (parts.size() == 1) { 25 | return (parts[0], ""); 26 | }; 27 | (parts[0], parts[1]); 28 | }; 29 | 30 | public func getDepName(depName : PackageName) : Text { 31 | parseDepName(depName).0; 32 | }; 33 | 34 | public func defaultPackageFileStats() : PackageFileStats { 35 | { 36 | sourceFiles = 0; 37 | sourceSize = 0; 38 | docsCount = 0; 39 | docsSize = 0; 40 | testFiles = 0; 41 | testSize = 0; 42 | benchFiles = 0; 43 | benchSize = 0; 44 | } 45 | }; 46 | 47 | public func defaultPackageChanges() : PackageChanges { 48 | { 49 | notes = ""; 50 | tests = { 51 | addedNames = []; 52 | removedNames = []; 53 | }; 54 | deps = []; 55 | devDeps = []; 56 | curBenchmarks = []; 57 | prevBenchmarks = []; 58 | }; 59 | }; 60 | }; -------------------------------------------------------------------------------- /backend/storage/types.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public type Err = Text; 3 | public type FileId = Text; 4 | 5 | public type StorageStats = { 6 | fileCount : Nat; 7 | memorySize : Nat; 8 | cyclesBalance : Nat; 9 | }; 10 | 11 | public type FileMeta = { 12 | id : FileId; 13 | path : Text; 14 | chunkCount : Nat; 15 | owners : [Principal]; // empty - public 16 | }; 17 | 18 | public type Chunk = Blob; 19 | }; -------------------------------------------------------------------------------- /backend/utils.mo: -------------------------------------------------------------------------------- 1 | import Principal "mo:base/Principal"; 2 | import Option "mo:base/Option"; 3 | import Array "mo:base/Array"; 4 | import Prelude "mo:base/Prelude"; 5 | import Buffer "mo:base/Buffer"; 6 | import Nat "mo:base/Nat"; 7 | import Iter "mo:base/Iter"; 8 | import Int "mo:base/Int"; 9 | 10 | module { 11 | let admins = ["hc7ih-ylbcm-cxqrk-kembs-xbsdz-7fhd7-amg45-yi62z-xvihp-6zilv-kae"]; 12 | 13 | public func isAdmin(principal : Principal) : Bool { 14 | let principalText = Principal.toText(principal); 15 | let admin = Array.find(admins, func(id : Text) = id == principalText) != null; 16 | admin or Principal.isController(principal); 17 | }; 18 | 19 | func _getPageItems(items : [T], pageIndex : Nat, limit : Nat) : [T] { 20 | let start = pageIndex * limit; 21 | let end = Nat.min(start + limit, items.size()); 22 | let size : Nat = end - start; 23 | 24 | if (size == 0) { 25 | return []; 26 | }; 27 | 28 | let buf = Buffer.Buffer(size); 29 | for (i in Iter.range(start, end - 1)) { 30 | buf.add(items[i]); 31 | }; 32 | 33 | Buffer.toArray(buf); 34 | }; 35 | 36 | public func getPage(items : [T], pageIndex : Nat, limit : Nat) : ([T], Nat) { 37 | ( 38 | _getPageItems(items, pageIndex, limit), 39 | items.size() / limit + (if (items.size() % limit == 0) 0 else 1), 40 | ); 41 | }; 42 | } -------------------------------------------------------------------------------- /bench/1-buffer-vector-add.bench.mo: -------------------------------------------------------------------------------- 1 | import Nat "mo:base/Nat"; 2 | import Iter "mo:base/Iter"; 3 | import Buffer "mo:base/Buffer"; 4 | import Vector "mo:vector/Class"; 5 | import Bench "mo:bench"; 6 | 7 | module { 8 | public func init() : Bench.Bench { 9 | let bench = Bench.Bench(); 10 | 11 | bench.name("Add (second)"); 12 | bench.description("Add items one-by-one (second)"); 13 | 14 | bench.rows(["Buffer", "Vector"]); 15 | bench.cols(["10", "10000", "1000000"]); 16 | 17 | bench.runner(func(row, col) { 18 | let ?n = Nat.fromText(col); 19 | 20 | // Vector 21 | if (row == "Vector") { 22 | let vec = Vector.Vector(); 23 | for (i in Iter.range(1, n)) { 24 | vec.add(i); 25 | }; 26 | // bench.heap.add(vec); 27 | } 28 | // Buffer 29 | else if (row == "Buffer") { 30 | let buf = Buffer.Buffer(0); 31 | for (i in Iter.range(1, n)) { 32 | buf.add(i); 33 | }; 34 | // bench.heap.add(buf); 35 | }; 36 | }); 37 | 38 | bench; 39 | }; 40 | }; -------------------------------------------------------------------------------- /bench/2-vector-buffer-add.bench.mo: -------------------------------------------------------------------------------- 1 | import Nat "mo:base/Nat"; 2 | import Iter "mo:base/Iter"; 3 | import Buffer "mo:base/Buffer"; 4 | import Vector "mo:vector/Class"; 5 | import Bench "mo:bench"; 6 | 7 | module { 8 | public func init() : Bench.Bench { 9 | let bench = Bench.Bench(); 10 | 11 | bench.name("Add"); 12 | bench.description("Add items one-by-one"); 13 | 14 | bench.rows(["Vector", "Buffer"]); 15 | bench.cols(["10", "10000", "1000000"]); 16 | 17 | bench.runner(func(row, col) { 18 | let ?n = Nat.fromText(col); 19 | 20 | // Vector 21 | if (row == "Vector") { 22 | let vec = Vector.Vector(); 23 | for (i in Iter.range(1, n)) { 24 | vec.add(i); 25 | }; 26 | } 27 | // Buffer 28 | else if (row == "Buffer") { 29 | let buf = Buffer.Buffer(0); 30 | for (i in Iter.range(1, n)) { 31 | buf.add(i); 32 | }; 33 | }; 34 | }); 35 | 36 | bench; 37 | }; 38 | }; -------------------------------------------------------------------------------- /bench/removeLast.bench.mo: -------------------------------------------------------------------------------- 1 | import Nat "mo:base/Nat"; 2 | import Iter "mo:base/Iter"; 3 | import Buffer "mo:base/Buffer"; 4 | import Vector "mo:vector/Class"; 5 | import Bench "mo:bench"; 6 | 7 | module { 8 | public func init() : Bench.Bench { 9 | let bench = Bench.Bench(); 10 | let initN = 100_000; 11 | let delN = 70_000; 12 | 13 | bench.name("Remove items using `removeLast`"); 14 | bench.description("Vector and buffer are initialized with 100k items and then 70k items are removed one-by-one."); 15 | 16 | bench.rows(["Vector", "Buffer"]); 17 | bench.cols(["remove 70k"]); 18 | 19 | // init Vector 20 | let vec = Vector.Vector(); 21 | for (i in Iter.range(1, initN)) { 22 | vec.add(i); 23 | }; 24 | // bench.heap.add(vec); 25 | 26 | // init Buffer 27 | let buf = Buffer.Buffer(0); 28 | for (i in Iter.range(1, initN)) { 29 | buf.add(i); 30 | }; 31 | // bench.heap.add(buf); 32 | 33 | bench.runner(func(row, col) { 34 | // Vector 35 | if (row == "Vector") { 36 | for (i in Iter.range(1, delN)) { 37 | ignore vec.removeLast(); 38 | }; 39 | } 40 | // Buffer 41 | else if (row == "Buffer") { 42 | for (i in Iter.range(1, delN)) { 43 | ignore buf.removeLast(); 44 | }; 45 | }; 46 | }); 47 | 48 | bench; 49 | }; 50 | }; -------------------------------------------------------------------------------- /blog/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /blog/README.md: -------------------------------------------------------------------------------- 1 | # Website 2 | 3 | This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator. 4 | 5 | ### Installation 6 | 7 | ``` 8 | $ yarn 9 | ``` 10 | 11 | ### Local Development 12 | 13 | ``` 14 | $ yarn start 15 | ``` 16 | 17 | This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. 18 | 19 | ### Build 20 | 21 | ``` 22 | $ yarn build 23 | ``` 24 | 25 | This command generates static content into the `build` directory and can be served using any static contents hosting service. 26 | 27 | ### Deployment 28 | 29 | Using SSH: 30 | 31 | ``` 32 | $ USE_SSH=true yarn deploy 33 | ``` 34 | 35 | Not using SSH: 36 | 37 | ``` 38 | $ GIT_USER= yarn deploy 39 | ``` 40 | 41 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. 42 | -------------------------------------------------------------------------------- /blog/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /blog/blog/0-unlisted.md: -------------------------------------------------------------------------------- 1 | --- 2 | unlisted: true 3 | slug: 0-unlisted 4 | title: Unlisted 5 | authors: [zen] 6 | tags: [] 7 | --- 8 | 9 | ### Summary 10 | - Mops CLI updates (v1.1.0) 11 | - More information of package dependencies and dependents 12 | 13 | 14 | 15 | ## Mops CLI updates 16 | 17 | ### Release 1.1.0 18 | 19 | Run `mops self update` to update Mops CLI to the latest version. 20 | 21 | - New `mops watch` command to check for syntax errors, show warnings, run tests, generate declarations and deploy canisters ([docs](https://docs.mops.one/cli/mops-watch)) 22 | - New flag `--no-toolchain` in `mops install` command to skip toolchain installation 23 | - New lock file format v3 ([docs](https://docs.mops.one/mops.lock)) 24 | - Faster `mops install` from lock file when lock file is up-to-date and there are no cached packages 25 | - Fixed replica test hanging in watch mode bug 26 | - Fixed mops failing when dfx is not installed 27 | - Fixed `mops test` Github Action template 28 | 29 | ## Fix GitHub images in package readme 30 | 31 | Now images in the package readme are displayed correctly when main branch is `master` instead of `main`. -------------------------------------------------------------------------------- /blog/blog/2024-10-08/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: 2024-10-08-updates 3 | title: Updates 8 October, 2024 4 | authors: [zen] 5 | tags: [] 6 | --- 7 | 8 | ### Summary 9 | - Mops CLI updates (v1.1.0) 10 | - More information of package dependencies and dependents 11 | 12 | 13 | 14 | ## Mops CLI updates 15 | 16 | ### Release 1.1.0 17 | 18 | Run `mops self update` to update Mops CLI to the latest version. 19 | 20 | - New `mops watch` command to check for syntax errors, show warnings, run tests, generate declarations and deploy canisters ([docs](https://docs.mops.one/cli/mops-watch)) 21 | - New flag `--no-toolchain` in `mops install` command to skip toolchain installation 22 | - New lock file format v3 ([docs](https://docs.mops.one/mops.lock)) 23 | - Faster `mops install` from lock file when lock file is up-to-date and there are no cached packages 24 | - Fixed replica test hanging in watch mode bug 25 | - Fixed mops failing when dfx is not installed 26 | - Fixed `mops test` Github Action template 27 | 28 | ## More information of package dependencies and dependents 29 | 30 | On the package page, in the "Dependencies" tab, you can see how old is a dependency and the latest available version of the dependency. 31 | 32 | In the "Dependents" tab, you can see which version of a package a dependent package uses. -------------------------------------------------------------------------------- /blog/blog/authors.yml: -------------------------------------------------------------------------------- 1 | zen: 2 | name: Zen Voich 3 | title: Mops Maintainer 4 | url: https://github.com/ZenVoich 5 | image_url: https://github.com/ZenVoich.png -------------------------------------------------------------------------------- /blog/blog/tags.yml: -------------------------------------------------------------------------------- 1 | hello: 2 | label: Hello 3 | permalink: /hello 4 | description: Hello tag description 5 | -------------------------------------------------------------------------------- /blog/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "blog", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "docusaurus": "docusaurus", 7 | "start": "docusaurus start --no-open --port 3002", 8 | "build": "docusaurus build", 9 | "swizzle": "docusaurus swizzle", 10 | "deploy": "docusaurus deploy", 11 | "clear": "docusaurus clear", 12 | "serve": "docusaurus serve --no-open", 13 | "write-translations": "docusaurus write-translations", 14 | "write-heading-ids": "docusaurus write-heading-ids" 15 | }, 16 | "dependencies": { 17 | "@docusaurus/core": "3.4.0", 18 | "@docusaurus/preset-classic": "3.4.0", 19 | "@mdx-js/react": "^3.0.0", 20 | "clsx": "^2.0.0", 21 | "docusaurus-plugin-fathom": "^1.2.0", 22 | "prism-react-renderer": "^2.3.0", 23 | "react": "^18.0.0", 24 | "react-dom": "^18.0.0" 25 | }, 26 | "devDependencies": { 27 | "@docusaurus/module-type-aliases": "3.4.0", 28 | "@docusaurus/types": "3.4.0" 29 | }, 30 | "browserslist": { 31 | "production": [ 32 | ">0.5%", 33 | "not dead", 34 | "not op_mini all" 35 | ], 36 | "development": [ 37 | "last 3 chrome version", 38 | "last 3 firefox version", 39 | "last 5 safari version" 40 | ] 41 | }, 42 | "engines": { 43 | "node": ">=18.0" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /blog/sidebars.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creating a sidebar enables you to: 3 | - create an ordered group of docs 4 | - render a sidebar for each doc of that group 5 | - provide next/previous navigation 6 | 7 | The sidebars can be generated from the filesystem, or explicitly defined here. 8 | 9 | Create as many sidebars as you want. 10 | */ 11 | 12 | // @ts-check 13 | 14 | /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ 15 | const sidebars = { 16 | // By default, Docusaurus generates a sidebar from the docs folder structure 17 | tutorialSidebar: [{type: 'autogenerated', dirName: '.'}], 18 | 19 | // But you can create a sidebar manually 20 | /* 21 | tutorialSidebar: [ 22 | 'intro', 23 | 'hello', 24 | { 25 | type: 'category', 26 | label: 'Tutorial', 27 | items: ['tutorial-basics/create-a-document'], 28 | }, 29 | ], 30 | */ 31 | }; 32 | 33 | export default sidebars; 34 | -------------------------------------------------------------------------------- /blog/src/components/HomepageFeatures/styles.module.css: -------------------------------------------------------------------------------- 1 | .features { 2 | display: flex; 3 | align-items: center; 4 | padding: 2rem 0; 5 | width: 100%; 6 | } 7 | 8 | .featureSvg { 9 | height: 200px; 10 | width: 200px; 11 | } 12 | -------------------------------------------------------------------------------- /blog/static/.ic-assets.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "match": ".well-known", 4 | "ignore": false 5 | } 6 | ] -------------------------------------------------------------------------------- /blog/static/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/blog/static/.nojekyll -------------------------------------------------------------------------------- /blog/static/.well-known/ic-domains: -------------------------------------------------------------------------------- 1 | blog.mops.one -------------------------------------------------------------------------------- /canister_ids.json: -------------------------------------------------------------------------------- 1 | { 2 | "assets": { 3 | "staging": "ogp6e-diaaa-aaaam-qajta-cai", 4 | "ic": "j4mwm-bqaaa-aaaam-qajbq-cai" 5 | }, 6 | "main": { 7 | "staging": "2d2zu-vaaaa-aaaak-qb6pq-cai", 8 | "ic": "oknww-riaaa-aaaam-qaf6a-cai" 9 | }, 10 | "docs": { 11 | "staging": "iwejr-6iaaa-aaaal-qcema-cai", 12 | "ic": "iwejr-6iaaa-aaaal-qcema-cai" 13 | }, 14 | "blog": { 15 | "staging": "zktta-iaaaa-aaaap-qhobq-cai", 16 | "ic": "zktta-iaaaa-aaaap-qhobq-cai" 17 | }, 18 | "cli": { 19 | "staging": "x344g-ziaaa-aaaap-abl7a-cai", 20 | "ic": "x344g-ziaaa-aaaap-abl7a-cai" 21 | } 22 | } -------------------------------------------------------------------------------- /cli-builder/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM --platform=linux/amd64 node:22.7.0-alpine3.20@sha256:1a526b97cace6b4006256570efa1a29cd1fe4b96a5301f8d48e87c5139438a45 2 | 3 | RUN apk add --no-cache git tar 4 | 5 | # for Bun 6 | RUN apk --no-cache add ca-certificates wget 7 | RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub 8 | RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk 9 | RUN apk add --no-cache --force-overwrite glibc-2.28-r0.apk -------------------------------------------------------------------------------- /cli-builder/README.md: -------------------------------------------------------------------------------- 1 | # Mops CLI builder 2 | 3 | This is a base image for building Mops CLI. 4 | 5 | Images are available on Docker Hub: https://hub.docker.com/r/zenvoich/mops-builder/tags 6 | 7 | ## Usage 8 | 9 | ```dockerfile 10 | FROM --platform=linux/amd64 zenvoich/mops-builder:1.0.0@sha256:ce283d3c4ad2e6fe8caff6dd9511224f234a77a90590ddfeb49e598266a44773 11 | # ... 12 | ``` 13 | 14 | ## Publish new version 15 | 16 | ``` 17 | docker build . -t zenvoich/mops-builder: 18 | docker push zenvoich/mops-builder: 19 | ``` -------------------------------------------------------------------------------- /cli-releases/.ic-assets.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "match": ".well-known", 4 | "ignore": false 5 | }, 6 | { 7 | "match": "frontend/node_modules", 8 | "ignore": true 9 | } 10 | ] -------------------------------------------------------------------------------- /cli-releases/.well-known/ic-domains: -------------------------------------------------------------------------------- 1 | cli.mops.one -------------------------------------------------------------------------------- /cli-releases/frontend/.eslintignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /build 4 | /.svelte-kit 5 | /package 6 | .env 7 | .env.* 8 | !.env.example 9 | 10 | # Ignore files for PNPM, NPM and YARN 11 | pnpm-lock.yaml 12 | package-lock.json 13 | yarn.lock 14 | -------------------------------------------------------------------------------- /cli-releases/frontend/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /** @type { import("eslint").Linter.Config } */ 2 | module.exports = { 3 | extends: [ 4 | 'eslint:recommended', 5 | // 'plugin:@typescript-eslint/recommended', 6 | 'plugin:svelte/base', 7 | ], 8 | // parser: '@typescript-eslint/parser', 9 | // plugins: ['@typescript-eslint'], 10 | parserOptions: { 11 | sourceType: 'module', 12 | ecmaVersion: 2020, 13 | extraFileExtensions: ['.svelte'], 14 | }, 15 | env: { 16 | browser: true, 17 | es2017: true, 18 | node: true, 19 | }, 20 | overrides: [ 21 | { 22 | files: ['*.svelte'], 23 | parser: 'svelte-eslint-parser', 24 | parserOptions: { 25 | parser: '@typescript-eslint/parser', 26 | }, 27 | }, 28 | ], 29 | rules: { 30 | 'no-unused-vars': 'off', 31 | // "@typescript-eslint/no-unused-vars": [ 32 | // "error", 33 | // { 34 | // "argsIgnorePattern": "^_", 35 | // "destructuredArrayIgnorePattern": "^_" 36 | // } 37 | // ] 38 | }, 39 | }; 40 | -------------------------------------------------------------------------------- /cli-releases/frontend/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /build 4 | /.svelte-kit 5 | /package 6 | .env 7 | .env.* 8 | !.env.example 9 | vite.config.js.timestamp-* 10 | vite.config.ts.timestamp-* 11 | -------------------------------------------------------------------------------- /cli-releases/frontend/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | save-exact = true 3 | -------------------------------------------------------------------------------- /cli-releases/frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "scripts": { 4 | "dev": "vite dev --port 3003", 5 | "build": "vite build", 6 | "preview": "vite preview", 7 | "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", 8 | "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", 9 | "lint": "eslint ." 10 | }, 11 | "devDependencies": { 12 | "@sveltejs/adapter-auto": "3.1.1", 13 | "@sveltejs/adapter-static": "3.0.1", 14 | "@sveltejs/kit": "2.5.4", 15 | "@sveltejs/vite-plugin-svelte": "3.0.2", 16 | "@types/eslint": "8.56.6", 17 | "@types/markdown-it": "13.0.7", 18 | "@typescript-eslint/eslint-plugin": "7.4.0", 19 | "@typescript-eslint/parser": "7.4.0", 20 | "eslint": "8.57.0", 21 | "eslint-plugin-svelte": "2.35.1", 22 | "svelte": "4.2.12", 23 | "svelte-check": "3.6.8", 24 | "tslib": "2.6.2", 25 | "typescript": "5.4.3", 26 | "vite": "5.2.6" 27 | }, 28 | "dependencies": { 29 | "filesize": "10.1.1", 30 | "hast-util-to-html": "9.0.0", 31 | "markdown-it": "14.1.0" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cli-releases/frontend/src/app.d.ts: -------------------------------------------------------------------------------- 1 | // See https://kit.svelte.dev/docs/types#app 2 | // for information about these interfaces 3 | declare global { 4 | namespace App { 5 | // interface Error {} 6 | // interface Locals {} 7 | // interface PageData {} 8 | // interface PageState {} 9 | // interface Platform {} 10 | } 11 | } 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /cli-releases/frontend/src/app.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %sveltekit.head% 8 | 9 | 10 |
%sveltekit.body%
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /cli-releases/frontend/src/components/Header.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 |
6 | 7 |
8 | 9 | -------------------------------------------------------------------------------- /cli-releases/frontend/src/lib/index.ts: -------------------------------------------------------------------------------- 1 | // place files you want to import through the `$lib` alias in this folder. 2 | -------------------------------------------------------------------------------- /cli-releases/frontend/src/lib/markdown-to-html.ts: -------------------------------------------------------------------------------- 1 | import markdownIt from 'markdown-it'; 2 | // import {toHtml} from 'hast-util-to-html'; 3 | 4 | export function markdownToHtml(markdown : string, repositoryUrl ?: string) { 5 | // make links to issues and PRs clickable 6 | if (repositoryUrl) { 7 | markdown = markdown.replace(/\(#(\d+)\)/g, `([#$1](${repositoryUrl}/issues/$1))`); 8 | } 9 | 10 | return markdownIt({ 11 | html: false, // Enable HTML tags in source 12 | breaks: false, // Convert '\n' in paragraphs into
13 | linkify: true, // Autoconvert URL-like text to links 14 | typographer: false, 15 | }).render(markdown); 16 | } -------------------------------------------------------------------------------- /cli-releases/frontend/src/routes/+layout.ts: -------------------------------------------------------------------------------- 1 | export const ssr = false; 2 | export const prerender = true; -------------------------------------------------------------------------------- /cli-releases/frontend/svelte.config.js: -------------------------------------------------------------------------------- 1 | import adapter from '@sveltejs/adapter-static'; 2 | import {vitePreprocess} from '@sveltejs/vite-plugin-svelte'; 3 | 4 | /** @type {import('@sveltejs/kit').Config} */ 5 | const config = { 6 | // Consult https://kit.svelte.dev/docs/integrations#preprocessors 7 | // for more information about preprocessors 8 | preprocess: vitePreprocess(), 9 | 10 | kit: { 11 | // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. 12 | // If your environment is not supported or you settled on a specific environment, switch out the adapter. 13 | // See https://kit.svelte.dev/docs/adapters for more information about adapters. 14 | adapter: adapter({ 15 | pages: 'dist', 16 | assets: 'dist', 17 | fallback: undefined, 18 | precompress: false, 19 | strict: true, 20 | }), 21 | }, 22 | }; 23 | 24 | export default config; 25 | -------------------------------------------------------------------------------- /cli-releases/frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "checkJs": true, 6 | "esModuleInterop": true, 7 | "forceConsistentCasingInFileNames": true, 8 | "resolveJsonModule": true, 9 | "skipLibCheck": true, 10 | "sourceMap": true, 11 | "strict": true, 12 | "moduleResolution": "bundler" 13 | } 14 | // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias 15 | // except $lib which is handled by https://kit.svelte.dev/docs/configuration#files 16 | // 17 | // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes 18 | // from the referenced tsconfig.json - TypeScript does not merge them in 19 | } 20 | -------------------------------------------------------------------------------- /cli-releases/frontend/vite.config.ts: -------------------------------------------------------------------------------- 1 | import {sveltekit} from '@sveltejs/kit/vite'; 2 | import {defineConfig} from 'vite'; 3 | 4 | export default defineConfig({ 5 | plugins: [sveltekit()], 6 | }); 7 | -------------------------------------------------------------------------------- /cli-releases/install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | url="https://x344g-ziaaa-aaaap-abl7a-cai.icp0.io/versions/${MOPS_VERSION:-latest}.tgz" 4 | 5 | uninstall() { 6 | echo "Uninstalling previous version" 7 | npm remove -g ic-mops >/dev/null 2>&1 8 | pnpm remove -g ic-mops >/dev/null 2>&1 9 | # bun remove -g ic-mops >/dev/null 2>&1 10 | } 11 | 12 | install_with_npm() { 13 | echo "Installing mops with npm..." 14 | npm add -g --no-fund --no-audit $url || exit 1 15 | } 16 | 17 | install_with_pnpm() { 18 | echo "Installing mops with pnpm..." 19 | # ignore cache to always get the latest version 20 | pnpm add -g "${url}?$(awk 'BEGIN{print srand(srand())}')" || exit 1 21 | } 22 | 23 | install_with_bun() { 24 | # bug with `mops self update` 25 | # bug with `dhall-to-json` on `mops init` 26 | echo "Bun is not recommended for installing mops. Please use npm or pnpm." 27 | exit 1 28 | } 29 | 30 | # uninstall previous version 31 | if command -v mops >/dev/null 2>&1; then 32 | uninstall 33 | fi 34 | 35 | # use specified package manager 36 | if [ "$PM" = "npm" ]; then 37 | install_with_npm 38 | elif [ "$PM" = "pnpm" ]; then 39 | install_with_pnpm 40 | elif [ "$PM" = "bun" ]; then 41 | install_with_bun 42 | # use the first package manager found 43 | else 44 | if command -v npm >/dev/null 2>&1; then 45 | install_with_npm 46 | elif command -v pnpm >/dev/null 2>&1; then 47 | install_with_pnpm 48 | elif command -v bun >/dev/null 2>&1; then 49 | install_with_bun 50 | else 51 | echo "No Node.js package manager found. Please install npm or pnpm" 52 | exit 1 53 | fi 54 | fi 55 | 56 | GREEN='\033[0;32m' 57 | NC='\033[0m' 58 | 59 | echo "${GREEN}Installation complete${NC}" -------------------------------------------------------------------------------- /cli-releases/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cli-releases", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": { 6 | "": { 7 | "hasInstallScript": true 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /cli-releases/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "cd frontend && npm run dev", 4 | "build": "cd frontend && npm run build", 5 | "postinstall": "cd frontend && npm install" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /cli-releases/tags/latest: -------------------------------------------------------------------------------- 1 | 1.8.0 -------------------------------------------------------------------------------- /cli-releases/versions/0.41.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/0.41.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/0.41.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/0.41.1.tgz -------------------------------------------------------------------------------- /cli-releases/versions/0.42.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/0.42.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/0.42.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/0.42.1.tgz -------------------------------------------------------------------------------- /cli-releases/versions/0.43.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/0.43.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/0.44.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/0.44.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/0.44.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/0.44.1.tgz -------------------------------------------------------------------------------- /cli-releases/versions/0.45.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/0.45.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/0.45.2.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/0.45.2.tgz -------------------------------------------------------------------------------- /cli-releases/versions/0.45.3.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/0.45.3.tgz -------------------------------------------------------------------------------- /cli-releases/versions/0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.0.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.0.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.0.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.0.1.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.1.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.1.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.1.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.1.1.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.1.2.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.1.2.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.2.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.2.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.3.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.3.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.4.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.4.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.5.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.5.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.5.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.5.1.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.6.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.6.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.6.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.6.1.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.7.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.7.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.7.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.7.1.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.7.2.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.7.2.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.8.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.8.0.tgz -------------------------------------------------------------------------------- /cli-releases/versions/1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/1.tgz -------------------------------------------------------------------------------- /cli-releases/versions/latest.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/cli-releases/versions/latest.tgz -------------------------------------------------------------------------------- /cli/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "node": true 4 | }, 5 | "parserOptions": { 6 | "sourceType": "module" 7 | } 8 | } -------------------------------------------------------------------------------- /cli/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | bundle 4 | cli.js 5 | identity.pem 6 | network.txt -------------------------------------------------------------------------------- /cli/.npmrc: -------------------------------------------------------------------------------- 1 | save-exact = true 2 | # omit = optional -------------------------------------------------------------------------------- /cli/DEVELOPMENT.md: -------------------------------------------------------------------------------- 1 | # Mops CLI 2 | 3 | ## Prerequisites 4 | 5 | On macOS, you need to install `gnu-tar` package: 6 | ``` 7 | brew install gnu-tar 8 | ``` 9 | 10 | To make it available in your shell as `tar`, add the following to your `~/.zshrc` or `~/.bashrc`: 11 | ``` 12 | export PATH="$HOMEBREW_PREFIX/opt/gnu-tar/libexec/gnubin:$PATH" 13 | ``` 14 | 15 | ## Steps 16 | 17 | 1. Update changelog in `CHANGELOG.md` file 18 | 19 | 2. Push latest commits to `main` branch 20 | 21 | 3. Check reproducibility of the build (see below) 22 | 23 | 4. Update the version in `package.json` using `npm version` command 24 | 25 | 5. Publish 26 | 27 | ## Publish to npm 28 | ``` 29 | npm publish 30 | ``` 31 | 32 | ## Check reproducibility of the build 33 | 34 | Check release hash of latest build for version `0.0.0` at https://github.com/ZenVoich/mops/actions/workflows/build-hash.yml 35 | 36 | Build locally version `0.0.0` 37 | ``` 38 | MOPS_VERSION=0.0.0 ./build.sh 39 | ``` 40 | 41 | Compare hashes. 42 | 43 | ## Publish on-chain 44 | _Run from root of the project_ 45 | 46 | 1. Prepeare release 47 | ``` 48 | npm run release-cli 49 | ``` 50 | 51 | 2. Deploy canister 52 | ``` 53 | dfx deploy --network ic --no-wallet cli --identity mops 54 | ``` 55 | 56 | ## Verify build 57 | 58 | ``` 59 | docker build . --build-arg COMMIT_HASH= --build-arg MOPS_VERSION= -t mops 60 | docker run --rm --env SHASUM= mops 61 | ``` -------------------------------------------------------------------------------- /cli/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM --platform=linux/amd64 zenvoich/mops-builder:1.0.0@sha256:ce283d3c4ad2e6fe8caff6dd9511224f234a77a90590ddfeb49e598266a44773 2 | 3 | # clone repository 4 | ARG COMMIT_HASH 5 | RUN git clone https://github.com/ZenVoich/mops.git 6 | 7 | WORKDIR /mops 8 | RUN git checkout $COMMIT_HASH 9 | 10 | WORKDIR /mops/cli 11 | RUN npm ci 12 | 13 | # build 14 | ARG MOPS_VERSION 15 | RUN npm version $MOPS_VERSION --allow-same-version 16 | RUN npm run build 17 | 18 | # verify 19 | ARG SHASUM 20 | ENV SHASUM=$SHASUM 21 | COPY verify.sh /verify.sh 22 | RUN chmod +x /verify.sh 23 | ENTRYPOINT ["sh", "/verify.sh"] -------------------------------------------------------------------------------- /cli/api/getHighestVersion.ts: -------------------------------------------------------------------------------- 1 | import {mainActor} from './actors.js'; 2 | 3 | export async function getHighestVersion(pkgName : string) { 4 | let actor = await mainActor(); 5 | return actor.getHighestVersion(pkgName); 6 | } -------------------------------------------------------------------------------- /cli/api/index.ts: -------------------------------------------------------------------------------- 1 | export {mainActor, storageActor} from './actors.js'; 2 | export {downloadPackageFiles} from './downloadPackageFiles.js'; 3 | export {getEndpoint, getNetwork} from './network.js'; 4 | export {resolveVersion} from './resolveVersion.js'; -------------------------------------------------------------------------------- /cli/api/network.ts: -------------------------------------------------------------------------------- 1 | export function getNetwork() { 2 | return globalThis.MOPS_NETWORK || 'ic'; 3 | } 4 | 5 | export function getEndpoint(network : string) { 6 | if (network === 'staging') { 7 | return { 8 | host: 'https://icp-api.io', 9 | canisterId: '2d2zu-vaaaa-aaaak-qb6pq-cai', 10 | }; 11 | } 12 | else if (network === 'ic') { 13 | return { 14 | host: 'https://icp-api.io', 15 | canisterId: 'oknww-riaaa-aaaam-qaf6a-cai', 16 | }; 17 | } 18 | else { 19 | return { 20 | host: 'http://127.0.0.1:4943', 21 | canisterId: '2d2zu-vaaaa-aaaak-qb6pq-cai', 22 | }; 23 | } 24 | } -------------------------------------------------------------------------------- /cli/api/resolveVersion.ts: -------------------------------------------------------------------------------- 1 | import {getHighestVersion} from './getHighestVersion.js'; 2 | 3 | export async function resolveVersion(pkg : string, version = '') : Promise { 4 | if (!version) { 5 | let versionRes = await getHighestVersion(pkg); 6 | if ('err' in versionRes) { 7 | throw versionRes.err; 8 | } 9 | version = versionRes.ok; 10 | } 11 | return version; 12 | } -------------------------------------------------------------------------------- /cli/bin/moc-wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # set -e 4 | 5 | findRootDir() { 6 | dir="$(pwd)" 7 | while [[ "$dir" != "" && ! -e "$dir/mops.toml" ]]; do 8 | dir=${dir%/*} 9 | done 10 | echo "$dir" 11 | } 12 | 13 | rootDir=$(findRootDir) 14 | mopsToml="$rootDir/mops.toml" 15 | 16 | if [[ $rootDir == "" ]] || [[ ! -f $mopsToml ]]; then 17 | mocPath="$(mops toolchain bin moc --fallback)" 18 | else 19 | if command -v openssl >/dev/null 2>&1; then 20 | mopsTomlHash=$(openssl sha256 $mopsToml | awk -F'= ' '{print $2}') 21 | else 22 | mopsTomlHash=$(shasum $mopsToml -a 256 | awk -F' ' '{print $1}') 23 | fi; 24 | 25 | cached="$rootDir/.mops/moc-$(uname -n)-$mopsTomlHash" 26 | 27 | if [ -f $cached ]; then 28 | mocPath=$(cat $cached) 29 | if [[ "$mocPath" != *"/moc" ]] ; then 30 | mocPath="$(mops toolchain bin moc --fallback)" 31 | echo -n $mocPath > "$cached" 32 | fi; 33 | else 34 | mkdir -p "$(dirname $cached)" 35 | mocPath="$(mops toolchain bin moc --fallback)" 36 | echo -n $mocPath > "$cached" 37 | fi; 38 | fi; 39 | 40 | $mocPath "$@" 41 | -------------------------------------------------------------------------------- /cli/bin/mops.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import '../cli.js'; -------------------------------------------------------------------------------- /cli/build.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | 3 | # default: current commit hash 4 | COMMIT_HASH=${COMMIT_HASH:-$(git rev-parse HEAD)} 5 | # default: current mops version 6 | MOPS_VERSION=${MOPS_VERSION:-$(npm pkg get version | tr -d \")} 7 | 8 | echo "Commit hash: $COMMIT_HASH" 9 | echo "Mops version: $MOPS_VERSION" 10 | 11 | # build verifiable bundle using Docker 12 | docker build . --build-arg COMMIT_HASH=$COMMIT_HASH --build-arg MOPS_VERSION=$MOPS_VERSION -t mops 13 | 14 | # print hash 15 | docker run --rm mops || echo "" 16 | 17 | # replace cli.tgz with the one from the Docker container 18 | cid=$(docker create mops) 19 | echo "Container ID: $cid" 20 | mkdir -p bundle 21 | docker cp $cid:/mops/cli/bundle/cli.tgz ./bundle/cli.tgz 22 | 23 | # verify 24 | # docker run --rm --env SHASUM=d57fc281a24fb12b0b6ef72cac4d478b357e6f22dca53bcc4a5506759fc96b06 mops -------------------------------------------------------------------------------- /cli/bundle-package-json.ts: -------------------------------------------------------------------------------- 1 | import {readFileSync, writeFileSync} from 'node:fs'; 2 | 3 | let packageJson = JSON.parse(readFileSync('./bundle/package.json', 'utf8')); 4 | 5 | packageJson.bin.mops = 'bin/mops.js'; 6 | packageJson.bin['ic-mops'] = 'bin/mops.js'; 7 | 8 | delete packageJson.scripts; 9 | delete packageJson.devDependencies; 10 | delete packageJson.overrides; 11 | packageJson.dependencies = { 12 | 'dhall-to-json-cli': packageJson.dependencies['dhall-to-json-cli'], 13 | 'decomp-tarxz': packageJson.dependencies['decomp-tarxz'], 14 | 'buffer': packageJson.dependencies['buffer'], 15 | }; 16 | 17 | writeFileSync('./bundle/package.json', JSON.stringify(packageJson, null, ' ')); -------------------------------------------------------------------------------- /cli/commands/available-updates.ts: -------------------------------------------------------------------------------- 1 | import process from 'node:process'; 2 | import chalk from 'chalk'; 3 | import {mainActor} from '../api/actors.js'; 4 | import {Config} from '../types.js'; 5 | import {getDepName} from '../helpers/get-dep-name.js'; 6 | 7 | // [pkg, oldVersion, newVersion] 8 | export async function getAvailableUpdates(config : Config, pkg ?: string) : Promise> { 9 | let deps = Object.values(config.dependencies || {}); 10 | let devDeps = Object.values(config['dev-dependencies'] || {}); 11 | let allDeps = [...deps, ...devDeps].filter((dep) => dep.version); 12 | let depsToUpdate = pkg ? allDeps.filter((dep) => dep.name === pkg) : allDeps; 13 | 14 | // skip pinned dependencies 15 | depsToUpdate = depsToUpdate.filter((dep) => getDepName(dep.name) === dep.name); 16 | 17 | let getCurrentVersion = (pkg : string) => { 18 | for (let dep of allDeps) { 19 | if (dep.name === pkg && dep.version) { 20 | return dep.version; 21 | } 22 | } 23 | return ''; 24 | }; 25 | 26 | let actor = await mainActor(); 27 | let res = await actor.getHighestSemverBatch(depsToUpdate.map((dep) => [dep.name, dep.version || '', {major: null}])); 28 | 29 | if ('err' in res) { 30 | console.log(chalk.red('Error:'), res.err); 31 | process.exit(1); 32 | } 33 | 34 | return res.ok.filter((dep) => dep[1] !== getCurrentVersion(dep[0])).map((dep) => [dep[0], getCurrentVersion(dep[0]), dep[1]]); 35 | } -------------------------------------------------------------------------------- /cli/commands/bench/user-bench.mo: -------------------------------------------------------------------------------- 1 | import Nat "mo:base/Nat"; 2 | import Iter "mo:base/Iter"; 3 | import Buffer "mo:base/Buffer"; 4 | import Vector "mo:vector/Class"; 5 | import Bench "mo:bench"; 6 | 7 | // placeholder file that will be replaced with the *.bench.mo file 8 | module { 9 | public func init() : Bench.Bench { 10 | let bench = Bench.Bench(); 11 | // benchmark code goes here... 12 | bench; 13 | }; 14 | }; -------------------------------------------------------------------------------- /cli/commands/install/install-dep.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path'; 2 | import {installFromGithub} from '../../vessel.js'; 3 | import {installMopsDep} from './install-mops-dep.js'; 4 | import {Dependency} from '../../types.js'; 5 | import {installLocalDep} from './install-local-dep.js'; 6 | import {getRootDir} from '../../mops.js'; 7 | 8 | type InstallDepOptions = { 9 | verbose ?: boolean; 10 | silent ?: boolean; 11 | threads ?: number; 12 | ignoreTransitive ?: boolean; 13 | }; 14 | 15 | // install dependency 16 | // returns false if failed 17 | export async function installDep(dep : Dependency, {verbose, silent, threads, ignoreTransitive} : InstallDepOptions = {}, parentPkgPath ?: string) : Promise { 18 | if (dep.repo) { 19 | await installFromGithub(dep.name, dep.repo, {silent, verbose, ignoreTransitive}); 20 | return true; 21 | } 22 | else if (dep.path) { 23 | let depPath = dep.path; 24 | parentPkgPath = parentPkgPath || getRootDir(); 25 | if (parentPkgPath) { 26 | depPath = path.resolve(parentPkgPath, dep.path); 27 | } 28 | return installLocalDep(dep.name, depPath, {silent, verbose, ignoreTransitive}); 29 | } 30 | else if (dep.version) { 31 | return installMopsDep(dep.name, dep.version, {silent, verbose, threads, ignoreTransitive}); 32 | } 33 | 34 | return true; 35 | } -------------------------------------------------------------------------------- /cli/commands/install/install-deps.ts: -------------------------------------------------------------------------------- 1 | import {Dependency} from '../../types.js'; 2 | import {installDep} from './install-dep.js'; 3 | 4 | type InstallDepsOptions = { 5 | verbose ?: boolean; 6 | silent ?: boolean; 7 | threads ?: number; 8 | ignoreTransitive ?: boolean; 9 | }; 10 | 11 | // install all dependencies 12 | // returns actual installed dependencies 13 | // returns false if failed 14 | export async function installDeps(deps : Dependency[], {verbose, silent, threads, ignoreTransitive} : InstallDepsOptions = {}, parentPkgPath ?: string) : Promise { 15 | let ok = true; 16 | 17 | for (const dep of deps) { 18 | let res = await installDep(dep, {verbose, silent, threads, ignoreTransitive}, parentPkgPath); 19 | if (!res) { 20 | ok = false; 21 | } 22 | } 23 | 24 | return ok; 25 | } 26 | -------------------------------------------------------------------------------- /cli/commands/install/install-local-dep.ts: -------------------------------------------------------------------------------- 1 | import process from 'node:process'; 2 | import path from 'node:path'; 3 | import {existsSync} from 'node:fs'; 4 | import {createLogUpdate} from 'log-update'; 5 | import {getRootDir, readConfig} from '../../mops.js'; 6 | import {installDeps} from './install-deps.js'; 7 | 8 | type InstallLocalDepOptions = { 9 | verbose ?: boolean; 10 | silent ?: boolean; 11 | ignoreTransitive ?: boolean; 12 | }; 13 | 14 | // skip install and just find non-local dependencies to install 15 | // pkgPath should be relative to the current root dir or absolute 16 | export async function installLocalDep(pkg : string, pkgPath = '', {verbose, silent, ignoreTransitive} : InstallLocalDepOptions = {}) : Promise { 17 | if (!silent) { 18 | let logUpdate = createLogUpdate(process.stdout, {showCursor: true}); 19 | logUpdate(`Local dependency ${pkg} = "${pkgPath}"`); 20 | 21 | if (verbose) { 22 | silent || logUpdate.done(); 23 | } 24 | else { 25 | logUpdate.clear(); 26 | } 27 | } 28 | 29 | // install dependencies 30 | if (!ignoreTransitive) { 31 | let dir = path.resolve(getRootDir(), pkgPath).replaceAll('{MOPS_ENV}', process.env.MOPS_ENV || 'local'); 32 | let mopsToml = path.join(dir, 'mops.toml'); 33 | 34 | if (!existsSync(mopsToml)) { 35 | return true; 36 | } 37 | 38 | let config = readConfig(mopsToml); 39 | return installDeps(Object.values(config.dependencies || {}), {silent, verbose}, pkgPath); 40 | } 41 | else { 42 | return true; 43 | } 44 | } -------------------------------------------------------------------------------- /cli/commands/install/sync-local-cache.ts: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | import path from 'node:path'; 3 | import {copyCache, getDepCacheName} from '../../cache.js'; 4 | import {getDependencyType, getRootDir} from '../../mops.js'; 5 | import {resolvePackages} from '../../resolve-packages.js'; 6 | 7 | export async function syncLocalCache({verbose = false} = {}) : Promise> { 8 | let resolvedPackages = await resolvePackages(); 9 | let rootDir = getRootDir(); 10 | 11 | verbose && console.log('Syncing local cache...'); 12 | 13 | let installedDeps : Record = {}; 14 | 15 | await Promise.all(Object.entries(resolvedPackages).map(([name, value]) => { 16 | let depType = getDependencyType(value); 17 | 18 | if (depType === 'mops' || depType === 'github') { 19 | let cacheName = getDepCacheName(name, value); 20 | let dest = path.join(rootDir, '.mops', cacheName); 21 | 22 | if (!fs.existsSync(dest)) { 23 | if (depType === 'mops') { 24 | installedDeps[name] = value; 25 | } 26 | return copyCache(cacheName, path.join(rootDir, '.mops', cacheName)); 27 | } 28 | } 29 | 30 | return Promise.resolve(); 31 | })).catch((errors) => { 32 | throw errors?.[0]; 33 | }); 34 | 35 | return installedDeps; 36 | } 37 | -------------------------------------------------------------------------------- /cli/commands/outdated.ts: -------------------------------------------------------------------------------- 1 | import chalk from 'chalk'; 2 | import {checkConfigFile, readConfig} from '../mops.js'; 3 | import {getAvailableUpdates} from './available-updates.js'; 4 | 5 | export async function outdated() { 6 | if (!checkConfigFile()) { 7 | return; 8 | } 9 | let config = readConfig(); 10 | 11 | let available = await getAvailableUpdates(config); 12 | 13 | if (available.length === 0) { 14 | console.log(chalk.green('All dependencies are up to date!')); 15 | } 16 | else { 17 | console.log('Available updates:'); 18 | for (let dep of available) { 19 | console.log(`${dep[0]} ${chalk.yellow(dep[1])} -> ${chalk.green(dep[2])}`); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /cli/commands/search.ts: -------------------------------------------------------------------------------- 1 | import process from 'node:process'; 2 | import asTable from 'as-table'; 3 | import chalk from 'chalk'; 4 | import {mainActor} from '../api/actors.js'; 5 | 6 | export async function search(text : string) { 7 | let actor = await mainActor(); 8 | let [packages, _pageCount] = await actor.search(text, [], []); 9 | 10 | if (!packages.length) { 11 | console.log('Packages not found'); 12 | return; 13 | } 14 | 15 | let ellipsis = (text : string, max : number) => { 16 | if (text.length <= max) { 17 | return text; 18 | } 19 | else { 20 | return text.slice(0, max) + '…'; 21 | } 22 | }; 23 | 24 | let maxNameLength = Math.max(...packages.map(a => a.config.name.length)); 25 | 26 | let table = packages.map((item) => { 27 | return { 28 | NAME: chalk.bold(item.config.name), 29 | DESCRIPTION: ellipsis(item.config.description, process.stdout.columns - 40 - maxNameLength), 30 | VERSION: item.config.version, 31 | UPDATED: new Date(Number(item.publication.time / 1_000_000n)).toISOString().split('T')[0], 32 | }; 33 | }); 34 | 35 | console.log(''); 36 | console.log(asTable.configure({ 37 | delimiter: chalk.gray(' | '), 38 | dash: chalk.gray('─'), 39 | title: t => chalk.gray.bold(t), 40 | })(table)); 41 | console.log(''); 42 | } -------------------------------------------------------------------------------- /cli/commands/sources.ts: -------------------------------------------------------------------------------- 1 | import process from 'node:process'; 2 | import path from 'node:path'; 3 | import fs from 'node:fs'; 4 | import {checkConfigFile, formatDir, formatGithubDir, getDependencyType, readConfig} from '../mops.js'; 5 | import {resolvePackages} from '../resolve-packages.js'; 6 | 7 | export async function sources({conflicts = 'ignore' as 'warning' | 'error' | 'ignore', cwd = process.cwd()} = {}) { 8 | if (!checkConfigFile()) { 9 | return []; 10 | } 11 | 12 | let resolvedPackages = await resolvePackages({conflicts}); 13 | 14 | // sources 15 | return Object.entries(resolvedPackages).map(([name, version]) => { 16 | let depType = getDependencyType(version); 17 | 18 | let pkgDir; 19 | if (depType === 'local') { 20 | pkgDir = path.relative(cwd, version); 21 | } 22 | else if (depType === 'github') { 23 | pkgDir = path.relative(cwd, formatGithubDir(name, version)); 24 | } 25 | else if (depType === 'mops') { 26 | pkgDir = path.relative(cwd, formatDir(name, version)); 27 | } 28 | else { 29 | return; 30 | } 31 | 32 | // append baseDir 33 | let pkgBaseDir; 34 | if (fs.existsSync(path.join(pkgDir, 'mops.toml'))) { 35 | let config = readConfig(path.join(pkgDir, 'mops.toml')); 36 | pkgBaseDir = path.join(pkgDir, config.package?.baseDir || 'src'); 37 | } 38 | else { 39 | pkgBaseDir = path.join(pkgDir, 'src'); 40 | } 41 | 42 | // use pkgDir if baseDir doesn't exist for local packages 43 | if (depType === 'local' && !fs.existsSync(path.resolve(cwd, pkgBaseDir))) { 44 | pkgBaseDir = pkgDir; 45 | } 46 | 47 | return `--package ${name} ${pkgBaseDir}`; 48 | }).filter(x => x != null); 49 | } -------------------------------------------------------------------------------- /cli/commands/test/reporters/files-reporter.ts: -------------------------------------------------------------------------------- 1 | import chalk from 'chalk'; 2 | import {absToRel} from '../utils.js'; 3 | import {MMF1} from '../mmf1.js'; 4 | import {Reporter} from './reporter.js'; 5 | import {TestMode} from '../../../types.js'; 6 | 7 | export class FilesReporter implements Reporter { 8 | passed = 0; 9 | failed = 0; 10 | skipped = 0; 11 | 12 | #startTime = Date.now(); 13 | 14 | addFiles(files : string[]) { 15 | console.log(`Test files: ${files.length}`); 16 | console.log('='.repeat(50)); 17 | } 18 | 19 | addRun(file : string, mmf : MMF1, state : Promise, mode : TestMode) { 20 | state.then(() => { 21 | this.passed += Number(mmf.failed === 0); 22 | this.failed += Number(mmf.failed !== 0); 23 | this.skipped += mmf.skipped; 24 | 25 | if (mmf.failed) { 26 | console.log(chalk.red('✖'), absToRel(file)); 27 | mmf.flush('fail'); 28 | console.log('-'.repeat(50)); 29 | } 30 | else { 31 | console.log(`${chalk.green('✓')} ${absToRel(file)} ${mode === 'interpreter' ? '' : chalk.gray(`(${mode})`)}`); 32 | } 33 | }); 34 | } 35 | 36 | done() : boolean { 37 | console.log('='.repeat(50)); 38 | if (this.failed) { 39 | console.log(chalk.redBright('Tests failed')); 40 | } 41 | else { 42 | console.log(chalk.greenBright('Tests passed')); 43 | } 44 | 45 | console.log(`Done in ${chalk.gray(((Date.now() - this.#startTime) / 1000).toFixed(2) + 's')}` 46 | + `, passed ${chalk.greenBright(this.passed)} files` 47 | + (this.skipped ? `, skipped ${chalk[this.skipped ? 'yellowBright' : 'gray'](this.skipped)} cases` : '') 48 | + (this.failed ? `, failed ${chalk[this.failed ? 'redBright' : 'gray'](this.failed)} files` : '') 49 | ); 50 | 51 | return this.failed === 0; 52 | } 53 | } -------------------------------------------------------------------------------- /cli/commands/test/reporters/reporter.ts: -------------------------------------------------------------------------------- 1 | import {TestMode} from '../../../types.js'; 2 | import {MMF1} from '../mmf1.js'; 3 | 4 | export interface Reporter { 5 | addFiles(files : string[]) : void; 6 | addRun(file : string, mmf : MMF1, state : Promise, mode : TestMode, progressive ?: boolean) : void; 7 | done() : boolean; 8 | } -------------------------------------------------------------------------------- /cli/commands/test/utils.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path'; 2 | import {getRootDir} from '../../mops.js'; 3 | 4 | export function absToRel(p : string) { 5 | let rootDir = getRootDir(); 6 | return path.relative(rootDir, path.resolve(p)); 7 | } -------------------------------------------------------------------------------- /cli/commands/toolchain/pocket-ic.ts: -------------------------------------------------------------------------------- 1 | import process from 'node:process'; 2 | import path from 'node:path'; 3 | import fs from 'node:fs'; 4 | 5 | import {globalCacheDir} from '../../mops.js'; 6 | import * as toolchainUtils from './toolchain-utils.js'; 7 | 8 | let cacheDir = path.join(globalCacheDir, 'pocket-ic'); 9 | 10 | export let repo = 'dfinity/pocketic'; 11 | 12 | export let getLatestReleaseTag = async () => { 13 | return toolchainUtils.getLatestReleaseTag(repo); 14 | }; 15 | 16 | export let getReleases = async () => { 17 | return toolchainUtils.getReleases(repo); 18 | }; 19 | 20 | export let isCached = (version : string) => { 21 | let dir = path.join(cacheDir, version); 22 | return fs.existsSync(dir) && fs.existsSync(path.join(dir, 'pocket-ic')); 23 | }; 24 | 25 | export let download = async (version : string, {silent = false, verbose = false} = {}) => { 26 | if (!version) { 27 | console.error('version is not defined'); 28 | process.exit(1); 29 | } 30 | if (isCached(version)) { 31 | if (verbose) { 32 | console.log(`pocket-ic ${version} is already installed`); 33 | } 34 | return; 35 | } 36 | 37 | let platfrom = process.platform == 'darwin' ? 'darwin' : 'linux'; 38 | let arch = 'x86_64'; 39 | let url = `https://github.com/dfinity/pocketic/releases/download/${version}/pocket-ic-${arch}-${platfrom}.gz`; 40 | 41 | if (verbose && !silent) { 42 | console.log(`Downloading ${url}`); 43 | } 44 | 45 | await toolchainUtils.downloadAndExtract(url, path.join(cacheDir, version), 'pocket-ic'); 46 | }; -------------------------------------------------------------------------------- /cli/commands/toolchain/wasmtime.ts: -------------------------------------------------------------------------------- 1 | import process from 'node:process'; 2 | import path from 'node:path'; 3 | import fs from 'fs-extra'; 4 | 5 | import {globalCacheDir} from '../../mops.js'; 6 | import * as toolchainUtils from './toolchain-utils.js'; 7 | 8 | let cacheDir = path.join(globalCacheDir, 'wasmtime'); 9 | 10 | export let repo = 'bytecodealliance/wasmtime'; 11 | 12 | export let getLatestReleaseTag = async () => { 13 | return toolchainUtils.getLatestReleaseTag(repo); 14 | }; 15 | 16 | export let getReleases = async () => { 17 | return toolchainUtils.getReleases(repo); 18 | }; 19 | 20 | export let isCached = (version : string) => { 21 | let dir = path.join(cacheDir, version); 22 | return fs.existsSync(dir) && fs.existsSync(path.join(dir, 'wasmtime')); 23 | }; 24 | 25 | export let download = async (version : string, {silent = false, verbose = false} = {}) => { 26 | if (!version) { 27 | console.error('version is not defined'); 28 | process.exit(1); 29 | } 30 | if (isCached(version)) { 31 | if (verbose) { 32 | console.log(`wasmtime ${version} is already installed`); 33 | } 34 | return; 35 | } 36 | 37 | let platfrom = process.platform == 'darwin' ? 'macos' : 'linux'; 38 | let arch = process.arch.startsWith('arm') ? 'aarch64' : 'x86_64'; 39 | let url = `https://github.com/bytecodealliance/wasmtime/releases/download/v${version}/wasmtime-v${version}-${arch}-${platfrom}.tar.xz`; 40 | 41 | if (verbose && !silent) { 42 | console.log(`Downloading ${url}`); 43 | } 44 | 45 | await toolchainUtils.downloadAndExtract(url, path.join(cacheDir, version)); 46 | }; -------------------------------------------------------------------------------- /cli/commands/watch/globMoFiles.ts: -------------------------------------------------------------------------------- 1 | import {globSync} from 'glob'; 2 | 3 | let globConfig = { 4 | nocase: true, 5 | ignore: [ 6 | '**/node_modules/**', 7 | '**/.mops/**', 8 | '**/.vessel/**', 9 | '**/.git/**', 10 | ], 11 | }; 12 | 13 | export function globMoFiles(rootDir : string) { 14 | // return globSync('{src,test?(s)}/**/*.mo', {cwd: rootDir, ...globConfig}); 15 | return globSync('src/**/*.mo', {cwd: rootDir, ...globConfig}); 16 | } -------------------------------------------------------------------------------- /cli/declarations/bench/bench.did: -------------------------------------------------------------------------------- 1 | type _anon_class_13_1 = 2 | service { 3 | getSchema: () -> (BenchSchema) query; 4 | getStats: () -> (BenchResult) query; 5 | init: () -> (BenchSchema); 6 | runCellQuery: (nat, nat) -> (BenchResult) query; 7 | runCellUpdate: (nat, nat) -> (BenchResult); 8 | runCellUpdateAwait: (nat, nat) -> (BenchResult); 9 | }; 10 | type BenchSchema = 11 | record { 12 | cols: vec text; 13 | description: text; 14 | name: text; 15 | rows: vec text; 16 | }; 17 | type BenchResult = 18 | record { 19 | instructions: int; 20 | rts_collector_instructions: int; 21 | rts_heap_size: int; 22 | rts_logical_stable_memory_size: int; 23 | rts_memory_size: int; 24 | rts_mutator_instructions: int; 25 | rts_reclaimed: int; 26 | rts_stable_memory_size: int; 27 | rts_total_allocation: int; 28 | stable_memory_size: int; 29 | }; 30 | service : () -> _anon_class_13_1 31 | -------------------------------------------------------------------------------- /cli/declarations/bench/bench.did.d.ts: -------------------------------------------------------------------------------- 1 | import type { Principal } from '@dfinity/principal'; 2 | import type { ActorMethod } from '@dfinity/agent'; 3 | import type { IDL } from '@dfinity/candid'; 4 | 5 | export interface BenchResult { 6 | 'rts_stable_memory_size' : bigint, 7 | 'stable_memory_size' : bigint, 8 | 'instructions' : bigint, 9 | 'rts_memory_size' : bigint, 10 | 'rts_total_allocation' : bigint, 11 | 'rts_collector_instructions' : bigint, 12 | 'rts_mutator_instructions' : bigint, 13 | 'rts_logical_stable_memory_size' : bigint, 14 | 'rts_heap_size' : bigint, 15 | 'rts_reclaimed' : bigint, 16 | } 17 | export interface BenchSchema { 18 | 'cols' : Array, 19 | 'name' : string, 20 | 'rows' : Array, 21 | 'description' : string, 22 | } 23 | export interface _anon_class_13_1 { 24 | 'getSchema' : ActorMethod<[], BenchSchema>, 25 | 'getStats' : ActorMethod<[], BenchResult>, 26 | 'init' : ActorMethod<[], BenchSchema>, 27 | 'runCellQuery' : ActorMethod<[bigint, bigint], BenchResult>, 28 | 'runCellUpdate' : ActorMethod<[bigint, bigint], BenchResult>, 29 | 'runCellUpdateAwait' : ActorMethod<[bigint, bigint], BenchResult>, 30 | } 31 | export interface _SERVICE extends _anon_class_13_1 {} 32 | export declare const idlFactory: IDL.InterfaceFactory; 33 | export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[]; 34 | -------------------------------------------------------------------------------- /cli/declarations/bench/bench.did.js: -------------------------------------------------------------------------------- 1 | export const idlFactory = ({ IDL }) => { 2 | const BenchSchema = IDL.Record({ 3 | 'cols' : IDL.Vec(IDL.Text), 4 | 'name' : IDL.Text, 5 | 'rows' : IDL.Vec(IDL.Text), 6 | 'description' : IDL.Text, 7 | }); 8 | const BenchResult = IDL.Record({ 9 | 'rts_stable_memory_size' : IDL.Int, 10 | 'stable_memory_size' : IDL.Int, 11 | 'instructions' : IDL.Int, 12 | 'rts_memory_size' : IDL.Int, 13 | 'rts_total_allocation' : IDL.Int, 14 | 'rts_collector_instructions' : IDL.Int, 15 | 'rts_mutator_instructions' : IDL.Int, 16 | 'rts_logical_stable_memory_size' : IDL.Int, 17 | 'rts_heap_size' : IDL.Int, 18 | 'rts_reclaimed' : IDL.Int, 19 | }); 20 | const _anon_class_13_1 = IDL.Service({ 21 | 'getSchema' : IDL.Func([], [BenchSchema], ['query']), 22 | 'getStats' : IDL.Func([], [BenchResult], ['query']), 23 | 'init' : IDL.Func([], [BenchSchema], []), 24 | 'runCellQuery' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], ['query']), 25 | 'runCellUpdate' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], []), 26 | 'runCellUpdateAwait' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], []), 27 | }); 28 | return _anon_class_13_1; 29 | }; 30 | export const init = ({ IDL }) => { return []; }; 31 | -------------------------------------------------------------------------------- /cli/declarations/bench/index.js: -------------------------------------------------------------------------------- 1 | import { Actor, HttpAgent } from "@dfinity/agent"; 2 | 3 | // Imports and re-exports candid interface 4 | import { idlFactory } from "./bench.did.js"; 5 | export { idlFactory } from "./bench.did.js"; 6 | 7 | /* CANISTER_ID is replaced by webpack based on node environment 8 | * Note: canister environment variable will be standardized as 9 | * process.env.CANISTER_ID_ 10 | * beginning in dfx 0.15.0 11 | */ 12 | export const canisterId = 13 | process.env.CANISTER_ID_BENCH; 14 | 15 | export const createActor = (canisterId, options = {}) => { 16 | const agent = options.agent || new HttpAgent({ ...options.agentOptions }); 17 | 18 | if (options.agent && options.agentOptions) { 19 | console.warn( 20 | "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." 21 | ); 22 | } 23 | 24 | // Fetch root key for certificate validation during development 25 | if (process.env.DFX_NETWORK !== "ic") { 26 | agent.fetchRootKey().catch((err) => { 27 | console.warn( 28 | "Unable to fetch root key. Check to ensure that your local replica is running" 29 | ); 30 | console.error(err); 31 | }); 32 | } 33 | 34 | // Creates an actor with using the candid interface and the HttpAgent 35 | return Actor.createActor(idlFactory, { 36 | agent, 37 | canisterId, 38 | ...options.actorOptions, 39 | }); 40 | }; 41 | -------------------------------------------------------------------------------- /cli/declarations/main/index.js: -------------------------------------------------------------------------------- 1 | import { Actor, HttpAgent } from "@dfinity/agent"; 2 | 3 | // Imports and re-exports candid interface 4 | import { idlFactory } from "./main.did.js"; 5 | export { idlFactory } from "./main.did.js"; 6 | 7 | /* CANISTER_ID is replaced by webpack based on node environment 8 | * Note: canister environment variable will be standardized as 9 | * process.env.CANISTER_ID_ 10 | * beginning in dfx 0.15.0 11 | */ 12 | export const canisterId = 13 | process.env.CANISTER_ID_MAIN; 14 | 15 | export const createActor = (canisterId, options = {}) => { 16 | const agent = options.agent || new HttpAgent({ ...options.agentOptions }); 17 | 18 | if (options.agent && options.agentOptions) { 19 | console.warn( 20 | "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." 21 | ); 22 | } 23 | 24 | // Fetch root key for certificate validation during development 25 | if (process.env.DFX_NETWORK !== "ic") { 26 | agent.fetchRootKey().catch((err) => { 27 | console.warn( 28 | "Unable to fetch root key. Check to ensure that your local replica is running" 29 | ); 30 | console.error(err); 31 | }); 32 | } 33 | 34 | // Creates an actor with using the candid interface and the HttpAgent 35 | return Actor.createActor(idlFactory, { 36 | agent, 37 | canisterId, 38 | ...options.actorOptions, 39 | }); 40 | }; 41 | -------------------------------------------------------------------------------- /cli/declarations/storage/index.js: -------------------------------------------------------------------------------- 1 | import { Actor, HttpAgent } from "@dfinity/agent"; 2 | 3 | // Imports and re-exports candid interface 4 | import { idlFactory } from './storage.did.js'; 5 | export { idlFactory } from './storage.did.js'; 6 | 7 | /** 8 | * 9 | * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent 10 | * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig}} [options] 11 | * @return {import("@dfinity/agent").ActorSubclass} 12 | */ 13 | export const createActor = (canisterId, options) => { 14 | const agent = new HttpAgent({ ...options?.agentOptions }); 15 | 16 | // Fetch root key for certificate validation during development 17 | if(process.env.NODE_ENV !== "production") { 18 | agent.fetchRootKey().catch(err=>{ 19 | console.warn("Unable to fetch root key. Check to ensure that your local replica is running"); 20 | console.error(err); 21 | }); 22 | } 23 | 24 | // Creates an actor with using the candid interface and the HttpAgent 25 | return Actor.createActor(idlFactory, { 26 | agent, 27 | canisterId, 28 | ...options?.actorOptions, 29 | }); 30 | }; -------------------------------------------------------------------------------- /cli/declarations/storage/storage.did: -------------------------------------------------------------------------------- 1 | type StorageStats = 2 | record { 3 | cyclesBalance: nat; 4 | fileCount: nat; 5 | memorySize: nat; 6 | }; 7 | type Storage = 8 | service { 9 | acceptCycles: () -> (); 10 | deleteFile: (FileId) -> (); 11 | downloadChunk: (FileId, nat) -> (Result_2) query; 12 | finishUpload: (FileId) -> (); 13 | getFileIdsRange: (nat, nat) -> (vec FileId) query; 14 | getFileMeta: (FileId) -> (Result_1) query; 15 | getStats: () -> (StorageStats) query; 16 | startUpload: (FileMeta) -> (Result); 17 | updateFileOwners: (FileId, vec principal) -> (); 18 | uploadChunk: (FileId, nat, Chunk) -> (); 19 | }; 20 | type Result_2 = 21 | variant { 22 | err: Err; 23 | ok: Chunk; 24 | }; 25 | type Result_1 = 26 | variant { 27 | err: Err; 28 | ok: FileMeta; 29 | }; 30 | type Result = 31 | variant { 32 | err: Err; 33 | ok; 34 | }; 35 | type FileMeta = 36 | record { 37 | chunkCount: nat; 38 | id: FileId__1; 39 | owners: vec principal; 40 | path: text; 41 | }; 42 | type FileId__1 = text; 43 | type FileId = text; 44 | type Err = text; 45 | type Chunk = blob; 46 | service : () -> Storage 47 | -------------------------------------------------------------------------------- /cli/declarations/storage/storage.did.d.ts: -------------------------------------------------------------------------------- 1 | import type { Principal } from '@dfinity/principal'; 2 | import type { ActorMethod } from '@dfinity/agent'; 3 | import type { IDL } from '@dfinity/candid'; 4 | 5 | export type Chunk = Array; 6 | export type Err = string; 7 | export type FileId = string; 8 | export type FileId__1 = string; 9 | export interface FileMeta { 10 | 'id' : FileId__1, 11 | 'owners' : Array, 12 | 'path' : string, 13 | 'chunkCount' : bigint, 14 | } 15 | export type Result = { 'ok' : null } | 16 | { 'err' : Err }; 17 | export type Result_1 = { 'ok' : FileMeta } | 18 | { 'err' : Err }; 19 | export type Result_2 = { 'ok' : Chunk } | 20 | { 'err' : Err }; 21 | export interface Storage { 22 | 'acceptCycles' : ActorMethod<[], undefined>, 23 | 'deleteFile' : ActorMethod<[FileId], undefined>, 24 | 'downloadChunk' : ActorMethod<[FileId, bigint], Result_2>, 25 | 'finishUpload' : ActorMethod<[FileId], undefined>, 26 | 'getFileIdsRange' : ActorMethod<[bigint, bigint], Array>, 27 | 'getFileMeta' : ActorMethod<[FileId], Result_1>, 28 | 'getStats' : ActorMethod<[], StorageStats>, 29 | 'startUpload' : ActorMethod<[FileMeta], Result>, 30 | 'updateFileOwners' : ActorMethod<[FileId, Array], undefined>, 31 | 'uploadChunk' : ActorMethod<[FileId, bigint, Chunk], undefined>, 32 | } 33 | export interface StorageStats { 34 | 'fileCount' : bigint, 35 | 'cyclesBalance' : bigint, 36 | 'memorySize' : bigint, 37 | } 38 | export interface _SERVICE extends Storage {} 39 | export declare const idlFactory: IDL.InterfaceFactory; 40 | export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[]; -------------------------------------------------------------------------------- /cli/declarations/storage/storage.did.js: -------------------------------------------------------------------------------- 1 | export const idlFactory = ({ IDL }) => { 2 | const FileId = IDL.Text; 3 | const Chunk = IDL.Vec(IDL.Nat8); 4 | const Err = IDL.Text; 5 | const Result_2 = IDL.Variant({ 'ok' : Chunk, 'err' : Err }); 6 | const FileId__1 = IDL.Text; 7 | const FileMeta = IDL.Record({ 8 | 'id' : FileId__1, 9 | 'owners' : IDL.Vec(IDL.Principal), 10 | 'path' : IDL.Text, 11 | 'chunkCount' : IDL.Nat, 12 | }); 13 | const Result_1 = IDL.Variant({ 'ok' : FileMeta, 'err' : Err }); 14 | const StorageStats = IDL.Record({ 15 | 'fileCount' : IDL.Nat, 16 | 'cyclesBalance' : IDL.Nat, 17 | 'memorySize' : IDL.Nat, 18 | }); 19 | const Result = IDL.Variant({ 'ok' : IDL.Null, 'err' : Err }); 20 | const Storage = IDL.Service({ 21 | 'acceptCycles' : IDL.Func([], [], []), 22 | 'deleteFile' : IDL.Func([FileId], [], []), 23 | 'downloadChunk' : IDL.Func([FileId, IDL.Nat], [Result_2], ['query']), 24 | 'finishUpload' : IDL.Func([FileId], [], []), 25 | 'getFileIdsRange' : IDL.Func( 26 | [IDL.Nat, IDL.Nat], 27 | [IDL.Vec(FileId)], 28 | ['query'], 29 | ), 30 | 'getFileMeta' : IDL.Func([FileId], [Result_1], ['query']), 31 | 'getStats' : IDL.Func([], [StorageStats], ['query']), 32 | 'startUpload' : IDL.Func([FileMeta], [Result], []), 33 | 'updateFileOwners' : IDL.Func([FileId, IDL.Vec(IDL.Principal)], [], []), 34 | 'uploadChunk' : IDL.Func([FileId, IDL.Nat, Chunk], [], []), 35 | }); 36 | return Storage; 37 | }; 38 | export const init = ({ IDL }) => { return []; }; 39 | -------------------------------------------------------------------------------- /cli/fix-dist.ts: -------------------------------------------------------------------------------- 1 | import {readFileSync, writeFileSync} from 'node:fs'; 2 | 3 | // remove scripts 4 | let text = readFileSync('dist/package.json', 'utf8'); 5 | let json = JSON.parse(text); 6 | delete json.scripts; 7 | 8 | // dist/bin/cli.js -> bin/cli.js 9 | json.bin.mops = 'bin/mops.js'; 10 | json.bin['ic-mops'] = 'bin/mops.js'; 11 | 12 | writeFileSync('dist/package.json', JSON.stringify(json, null, 2)); -------------------------------------------------------------------------------- /cli/global.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'pem-file'; 2 | declare module 'get-folder-size'; 3 | declare module 'decomp-tarxz'; -------------------------------------------------------------------------------- /cli/helpers/find-changelog-entry.ts: -------------------------------------------------------------------------------- 1 | import {fromMarkdown} from 'mdast-util-from-markdown'; 2 | import {toMarkdown} from 'mdast-util-to-markdown'; 3 | 4 | export function findChangelogEntry(changelog : string, version : string) : string { 5 | let tree = fromMarkdown(changelog); 6 | let found = false; 7 | let nodes = []; 8 | 9 | for (let node of tree.children) { 10 | if (found) { 11 | if (node.type === 'heading') { 12 | break; 13 | } 14 | else { 15 | nodes.push(node); 16 | } 17 | } 18 | else if (node.type === 'heading' && toMarkdown(node).match(new RegExp(`\\b${version}\\b`))) { 19 | found = true; 20 | } 21 | } 22 | 23 | return toMarkdown({ 24 | type: 'root', 25 | children: nodes, 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /cli/helpers/get-dep-name.ts: -------------------------------------------------------------------------------- 1 | export function getDepName(name : string) : string { 2 | return name.split('@')[0] || ''; 3 | } -------------------------------------------------------------------------------- /cli/helpers/get-dfx-version.ts: -------------------------------------------------------------------------------- 1 | import {execSync} from 'node:child_process'; 2 | 3 | export function getDfxVersion() : string { 4 | try { 5 | let res = execSync('dfx --version').toString(); 6 | return res.trim().split('dfx ')[1] || ''; 7 | } 8 | catch {} 9 | return ''; 10 | } -------------------------------------------------------------------------------- /cli/helpers/get-moc-path.ts: -------------------------------------------------------------------------------- 1 | import process from 'node:process'; 2 | import {execFileSync} from 'node:child_process'; 3 | 4 | export function getMocPath(throwIfNotFound = false) : string { 5 | let mocPath = process.env.DFX_MOC_PATH; 6 | if (!mocPath) { 7 | try { 8 | mocPath = execFileSync('dfx', ['cache', 'show']).toString().trim() + '/moc'; 9 | } 10 | catch (e) { 11 | mocPath = ''; 12 | } 13 | } 14 | if (!mocPath) { 15 | mocPath = 'moc'; 16 | } 17 | 18 | if (throwIfNotFound) { 19 | try { 20 | execFileSync(mocPath, ['--version']); 21 | } 22 | catch (e) { 23 | console.error(e); 24 | throw new Error('moc not found'); 25 | } 26 | } 27 | 28 | return mocPath; 29 | } -------------------------------------------------------------------------------- /cli/helpers/get-moc-version.ts: -------------------------------------------------------------------------------- 1 | import {execFileSync} from 'node:child_process'; 2 | import {getMocPath} from './get-moc-path.js'; 3 | 4 | export function getMocVersion(throwOnError = false) : string { 5 | let mocPath = getMocPath(false); 6 | if (!mocPath) { 7 | return ''; 8 | } 9 | try { 10 | let match = execFileSync(mocPath, ['--version']).toString().trim().match(/Motoko compiler ([^\s]+) .*/); 11 | return match?.[1] || ''; 12 | } 13 | catch (e) { 14 | if (throwOnError) { 15 | console.error(e); 16 | throw new Error('moc not found'); 17 | } 18 | return ''; 19 | } 20 | } -------------------------------------------------------------------------------- /cli/helpers/get-package-id.ts: -------------------------------------------------------------------------------- 1 | import {getDepName} from './get-dep-name.js'; 2 | 3 | export function getPackageId(name : string, version : string) : string { 4 | return getDepName(name) + '@' + version; 5 | } -------------------------------------------------------------------------------- /cli/notify-installs.ts: -------------------------------------------------------------------------------- 1 | import {getDependencyType} from './mops.js'; 2 | import {mainActor} from './api/actors.js'; 3 | import {getDepName} from './helpers/get-dep-name.js'; 4 | 5 | export async function notifyInstalls(installedDeps : Record) { 6 | let packages = Object.entries(installedDeps) 7 | .filter(([_, version]) => getDependencyType(version) === 'mops') 8 | .map(([name, version]) => [getDepName(name), version] as [string, string]); 9 | 10 | if (packages.length) { 11 | let actor = await mainActor(); 12 | 13 | try { 14 | await actor.notifyInstalls(packages); 15 | } 16 | catch (err) { 17 | // console.error('Failed to notify installs:', err); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /cli/parallel.ts: -------------------------------------------------------------------------------- 1 | export async function parallel(threads : number, items : T[], fn : (item : T) => Promise) { 2 | return new Promise((resolve) => { 3 | let busyThreads = 0; 4 | items = items.slice(); 5 | 6 | let loop = () => { 7 | if (!items.length) { 8 | if (busyThreads === 0) { 9 | resolve(); 10 | } 11 | return; 12 | } 13 | if (busyThreads >= threads) { 14 | return; 15 | } 16 | busyThreads++; 17 | fn(items.shift() as T).then(() => { 18 | busyThreads--; 19 | loop(); 20 | }); 21 | loop(); 22 | }; 23 | loop(); 24 | }); 25 | } -------------------------------------------------------------------------------- /cli/templates.ts: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | 3 | export function copyTemplateFileSync(file : string, dest : string) { 4 | fs.copyFileSync(new URL(`./templates/${file}`, import.meta.url), dest); 5 | } -------------------------------------------------------------------------------- /cli/templates/README.md: -------------------------------------------------------------------------------- 1 | # 2 | 3 | ## Install 4 | ``` 5 | mops add 6 | ``` 7 | 8 | ## Usage 9 | ```motoko 10 | import "mo:"; 11 | 12 | // example... 13 | ``` -------------------------------------------------------------------------------- /cli/templates/licenses/Apache-2.0-NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /cli/templates/licenses/MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /cli/templates/mops-publish.yml: -------------------------------------------------------------------------------- 1 | name: publish on mops 2 | 3 | on: 4 | release: 5 | types: [released] 6 | 7 | jobs: 8 | publish: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v4 13 | - uses: ZenVoich/setup-mops@v1 14 | with: 15 | # Make sure you set the MOPS_IDENTITY_PEM secret in your repository settings https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository 16 | identity-pem: ${{ secrets.MOPS_IDENTITY_PEM }} 17 | - run: mops publish -------------------------------------------------------------------------------- /cli/templates/mops-test.yml: -------------------------------------------------------------------------------- 1 | name: mops test 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - master 8 | pull_request: 9 | 10 | jobs: 11 | test: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - uses: ZenVoich/setup-mops@v1 17 | with: 18 | mops-version: 1 19 | 20 | - name: install mops packages 21 | run: mops install 22 | 23 | - name: run tests 24 | run: mops test -------------------------------------------------------------------------------- /cli/templates/src/lib.mo: -------------------------------------------------------------------------------- 1 | module { 2 | // This comment will not be included in the documentation 3 | // Use triple slash for documentation 4 | 5 | /// Add two natural numbers 6 | /// 7 | /// Example: 8 | /// ```motoko 9 | /// assert add(1, 2) == 3; 10 | /// assert add(7, 3) == 10; 11 | /// ``` 12 | public func add(x : Nat, y : Nat) : Nat { 13 | return x + y; 14 | }; 15 | }; -------------------------------------------------------------------------------- /cli/templates/test/lib.test.mo: -------------------------------------------------------------------------------- 1 | import {add} "../src"; 2 | 3 | assert add(1, 2) == 3; 4 | assert add(3, 22) == 25; -------------------------------------------------------------------------------- /cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["@tsconfig/strictest/tsconfig.json"], 3 | "include": ["**/*.ts", "**/*.js"], 4 | "exclude": ["node_modules", "dist", "bundle", "dist.js", "declarations/**/*.js"], 5 | "compilerOptions": { 6 | "types": ["node"], 7 | "target": "ES2021", 8 | "outDir": "./dist", 9 | "allowJs": true, 10 | "module": "nodenext", 11 | "moduleResolution": "nodenext", 12 | "noEmitOnError": false, 13 | "noUnusedLocals": false, 14 | "noUnusedParameters": false, 15 | "noPropertyAccessFromIndexSignature": false, 16 | "exactOptionalPropertyTypes": false, 17 | "declaration": true 18 | } 19 | } -------------------------------------------------------------------------------- /cli/types.ts: -------------------------------------------------------------------------------- 1 | export type Config = { 2 | package ?: { 3 | name : string; 4 | version : string; 5 | description ?: string; 6 | license ?: string; 7 | repository ?: string; 8 | keywords ?: string[]; 9 | baseDir ?: string; 10 | readme ?: string; 11 | files ?: string[]; 12 | homepage ?: string; 13 | documentation ?: string; 14 | dfx ?: string; 15 | moc ?: string; 16 | donation ?: string; 17 | }; 18 | dependencies ?: Dependencies; 19 | 'dev-dependencies' ?: Dependencies; 20 | toolchain ?: Toolchain; 21 | requirements ?: Requirements; 22 | // format ?: Format; 23 | }; 24 | 25 | export type Dependencies = Record; 26 | 27 | export type Dependency = { 28 | name : string; 29 | version ?: string; // mops package 30 | repo ?: string; // github package 31 | path ?: string; // local package 32 | }; 33 | 34 | export type Toolchain = { 35 | moc ?: string; 36 | wasmtime ?: string; 37 | 'pocket-ic' ?: string; 38 | }; 39 | 40 | export type Tool = 'moc' | 'wasmtime' | 'pocket-ic'; 41 | 42 | export type Requirements = { 43 | moc ?: string; 44 | }; 45 | 46 | // export type Format = { 47 | // useTabs ?: boolean; 48 | // tabWidth ?: number; 49 | // printWidth ?: number; 50 | // semi ?: boolean; 51 | // bracketSpacing ?: boolean; 52 | // trailingComma ?: 'none' | 'all'; 53 | // }; 54 | 55 | export type TestMode = 'interpreter' | 'wasi' | 'replica'; -------------------------------------------------------------------------------- /cli/verify.sh: -------------------------------------------------------------------------------- 1 | actual_shasum=$(sha256sum bundle/cli.tgz | head -n1 | awk '{print $1;}') 2 | 3 | if [ "$actual_shasum" != "$SHASUM" ]; then 4 | echo "Expected shasum: $SHASUM" 5 | echo "Actual shasum: $actual_shasum" 6 | echo "Verification failed" 7 | exit 1 8 | else 9 | echo "Verification successful for shasum: $actual_shasum" 10 | fi -------------------------------------------------------------------------------- /docs/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "node": true 5 | }, 6 | "rules": { 7 | "@typescript-eslint/no-var-requires": "off" 8 | } 9 | } -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /docs/.npmrc: -------------------------------------------------------------------------------- 1 | save-exact = true -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Website 2 | 3 | This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. 4 | 5 | ### Installation 6 | 7 | ``` 8 | $ yarn 9 | ``` 10 | 11 | ### Local Development 12 | 13 | ``` 14 | $ yarn start 15 | ``` 16 | 17 | This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. 18 | 19 | ### Build 20 | 21 | ``` 22 | $ yarn build 23 | ``` 24 | 25 | This command generates static content into the `build` directory and can be served using any static contents hosting service. 26 | 27 | ### Deployment 28 | 29 | Using SSH: 30 | 31 | ``` 32 | $ USE_SSH=true yarn deploy 33 | ``` 34 | 35 | Not using SSH: 36 | 37 | ``` 38 | $ GIT_USER= yarn deploy 39 | ``` 40 | 41 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. 42 | -------------------------------------------------------------------------------- /docs/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /docs/docs/00-introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | # sidebar_position: 0.1 3 | slug: / 4 | --- 5 | 6 | # Introduction 7 | 8 | Mops aims to be a one-stop solution for all your Motoko development needs. 9 | 10 | Mops empowers and simplifies Motoko developer experience. 11 | 12 | Learn how to start using Mops in [Quick Start](/quick-start). 13 | 14 | ## What is Mops? 15 | 16 | ### Mops is a package manager for Motoko 17 | 18 | Add dependencies as easily as `mops add `. 19 | 20 | Update dependencies as easily as `mops update `. 21 | 22 | ### Mops is on on-chain package registry for Motoko 23 | 24 | All packages published to Mops registry are hosted on the [Internet Computer](https://internetcomputer.org/) blockchain. 25 | 26 | You can discover Motoko packages on [mops.one](https://mops.one/). 27 | 28 | ### Mops is a test runner for Motoko 29 | 30 | Mops comes with a [test runner](/cli/mops-test) that follows [Mops Message Format](https://github.com/ZenVoich/mops-message-format) and works with the [`test` package](https://mops.one/test). 31 | 32 | ### Mops is a benchmarking tool for Motoko 33 | 34 | Mops comes with a [benchmarking tool](/cli/mops-bench) that works with the [`bench` package](https://mops.one/bench). 35 | 36 | ### Mops is a toolchain manager for Motoko 37 | 38 | [`mops toolchain`](/cli/toolchain) helps you install and manage Motoko toolchain, including `moc`, `pocket-ic` and `wasmtime`. 39 | 40 | ### Mops is an essential tool for Motoko developers 41 | 42 | Use [`mops watch`](/cli/mops-watch) to check syntax errors, show warnings, run tests, generate declarations, and deploy canisters each time you make changes in your code. -------------------------------------------------------------------------------- /docs/docs/01-quick-start.md: -------------------------------------------------------------------------------- 1 | --- 2 | # sidebar_position: 0.1 3 | # sidebar_label: 'Quick Start' 4 | --- 5 | 6 | # Quick Start 7 | 8 | ## 1. Prerequisites 9 | - [Node.js](https://nodejs.org/) >= 18.0.0 10 | - [DFX](https://internetcomputer.org/docs/current/developer-docs/quickstart/local-quickstart) >= 0.10.0 11 | 12 | ## 2. Install Mops CLI 13 | 14 | Install from on-chain storage 15 | 16 | ```shell 17 | curl -fsSL cli.mops.one/install.sh | sh 18 | ``` 19 | 20 | or install from npm registry 21 | ```shell 22 | npm i -g ic-mops 23 | ``` 24 | 25 | ## 3. Initialize 26 | Run this command in the root directory of your project (where is `dfx.json` placed) 27 | 28 | ``` 29 | mops init 30 | ``` 31 | 32 | ## 4. Configure dfx.json 33 | Add `mops` as a packtool to your `dfx.json` 34 | 35 | ```json 36 | { 37 | "defaults": { 38 | "build": { 39 | "packtool": "mops sources" 40 | } 41 | } 42 | } 43 | ``` 44 | 45 | ## 5. Install Motoko Packages 46 | Use [`mops add`](/cli/mops-add) to install a specific package and save it to `mops.toml` 47 | 48 | ``` 49 | mops add base 50 | ``` 51 | 52 | ## 6. Import Package 53 | Now you can import installed packages in your Motoko code 54 | 55 | ```motoko 56 | import Array "mo:base/Array"; 57 | ``` -------------------------------------------------------------------------------- /docs/docs/10-mops.lock.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /mops.lock 3 | sidebar_label: mops.lock 4 | --- 5 | 6 | # `mops.lock` file 7 | 8 | :::info 9 | Currently lockfile is disabled by default. You can enable it by running `mops i --lock update` once. 10 | 11 | When `mops.lock` file exists, no need to specify `--lock` flag. 12 | ::: 13 | 14 | `mops.lock` is used to ensure integrity of dependencies, so that you can be sure that all dependencies have exactly the same source code as they had when the package author published them to the Mops Registry. 15 | 16 | A valid `mops.lock` speeds up `mops install` command because it avoids downloading intermediate versions of dependencies. 17 | 18 | _It's only faster when there are no global cached packages. For example you are running `mops install` inside a fresh Docker container. Or when you call `mops install` for the first time in a project._ 19 | 20 | `mops.lock` contains the following information: 21 | - Hash of `[dependencies]` and `[dev-dependencies]` section of `mops.toml` file 22 | - All transitive dependencies with the final resolved versions 23 | - Hash of each file of each dependency 24 | 25 | File hashes are retrieved from the mops registry canister. 26 | 27 | When `mops.lock` exists, it is updated(and checked) automatically when you run any of the following commands: 28 | - `mops add` 29 | - `mops remove` 30 | - `mops install` 31 | - `mops update` 32 | - `mops sync` 33 | 34 | `mops.lock` maintained by Mops and should not be manually edited. -------------------------------------------------------------------------------- /docs/docs/articles/01-how-dependecy-resolution-works.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /how-dependency-resolution-works 3 | sidebar_label: How dependency resolution works 4 | --- 5 | 6 | # How dependency resolution works 7 | 8 | 1. Direct dependencies listed in `mops.toml` are always resolved to the specified version. 9 | _Only for project's root `mops.toml` file. Does not apply to `mops.toml` files of dependencies_ 10 | 11 | 2. Compatible transitive dependency versions are resolved to the highest version in the dependency graph. 12 | 13 | 3. Incompatible transitive dependency versions are reported as warnings. 14 | 15 | 16 | ### Version compatibility 17 | 18 | Dependency versions are considered compatible if they have the same major version. 19 | 20 | For example: 21 | - `1.0.0` and `2.0.0` are incompatible 22 | - `1.0.0` and `1.1.0` are compatible 23 | - `0.1.0` and `0.23.0` are compatible 24 | 25 | ### Unwanted dependency changes 26 | 27 | If you don't change the version of a direct dependency, the version of the transitive dependencies will not change. 28 | 29 | So, unchanged `mops.toml` - unchanged dependency graph. -------------------------------------------------------------------------------- /docs/docs/articles/02-how-to-version-a-package.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /how-to-version-a-package 3 | sidebar_label: How to version a package 4 | --- 5 | 6 | # How to version a package 7 | 8 | **TL;DR:** Follow the [Semantic Versioning](https://semver.org/). 9 | 10 | ### Semantic Versioning 11 | 12 | Given a version number MAJOR.MINOR.PATCH, increment the: 13 | 14 | 1. MAJOR version when you make incompatible API changes 15 | 2. MINOR version when you add functionality in a backward compatible manner 16 | 3. PATCH version when you make backward compatible bug fixes 17 | 18 | [`mops bump`](/cli/mops-bump) command can help you to bump the version of your package. 19 | 20 | ### How do I know when to release 1.0.0? 21 | 22 | - If your package is being used in production, it should probably already be 1.0.0. 23 | - If you have a stable API on which users have come to depend, you should be 1.0.0. 24 | - If you’re worrying a lot about backward compatibility, you should probably already be 1.0.0. 25 | 26 | Also see: [How dependency resolution works](/how-dependency-resolution-works). -------------------------------------------------------------------------------- /docs/docs/articles/03-package-owners-and-maintainers.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /package-owners-and-maintainers 3 | sidebar_label: Package owners and maintainers 4 | --- 5 | 6 | # Package owners and maintainers 7 | 8 | A package can have multiple owners and maintainers. 9 | 10 | Owners have full control over the package, including the ability to publish new versions, add or remove owners, and maintainers. Maintainers can publish new versions, but they cannot add or remove owners or maintainers. 11 | 12 | | Action | Owner | Maintainer | 13 | |--------|-------|------------| 14 | | Publish new versions | :heavy_check_mark: | :heavy_check_mark: | 15 | | Add or remove owners | :heavy_check_mark: | :x: | 16 | | Add or remove maintainers | :heavy_check_mark: | :x: | 17 | 18 | Use [`mops owner`](/cli/mops-owner) command to manage owners of a package. 19 | 20 | Use [`mops maintainer`](/cli/mops-maintainer) command to manage maintainers of a package. -------------------------------------------------------------------------------- /docs/docs/articles/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "position": 2, 3 | "label": "Articles", 4 | "collapsible": true, 5 | "collapsed": true 6 | } 7 | -------------------------------------------------------------------------------- /docs/docs/cli/00-mops-init.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-init 3 | sidebar_label: mops init 4 | --- 5 | 6 | # `mops init` 7 | 8 | Initialize a new project or package in the current directory 9 | ``` 10 | mops init 11 | ``` 12 | 13 | ## Options 14 | 15 | ### `--yes`, `-y` 16 | 17 | Initalize with all defaults -------------------------------------------------------------------------------- /docs/docs/cli/1-deps/01-mops-add.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-add 3 | sidebar_label: mops add 4 | --- 5 | 6 | # `mops add` 7 | 8 | Install a specific package and save it to `mops.toml` 9 | ``` 10 | mops add 11 | ``` 12 | 13 | ### Examples 14 | 15 | Install latest `base` package from `mops` registry 16 | ``` 17 | mops add base 18 | ``` 19 | 20 | Install specific version of `base` package from `mops` registry 21 | ``` 22 | mops add base@0.10.0 23 | ``` 24 | 25 | Add package from GitHub 26 | ``` 27 | mops add https://github.com/dfinity/motoko-base 28 | ``` 29 | 30 | For GitHub-packages you can specify branch, tag, or commit hash by adding `#` 31 | ``` 32 | mops add https://github.com/dfinity/motoko-base#moc-0.9.1 33 | ``` 34 | 35 | Add local package 36 | ``` 37 | mops add ./shared 38 | ``` 39 | 40 | ## Options 41 | 42 | ### `--dev` 43 | Add package to `[dev-dependencies]` section. 44 | 45 | ### `--lock` 46 | 47 | What to do with the [lockfile](/mops.lock) 48 | 49 | Default value is `update` if lockfile exists and `ignore` otherwise. 50 | 51 | Possible values: 52 | - `update` - update lockfile (create if not exists). Always checks after update 53 | - `ignore` - ignore lockfile 54 | 55 | ### `--verbose` 56 | 57 | Verbose output. -------------------------------------------------------------------------------- /docs/docs/cli/1-deps/01-mops-remove.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-remove 3 | sidebar_label: mops remove 4 | --- 5 | 6 | # `mops remove` 7 | 8 | Alias `mops rm` 9 | 10 | Remove package and update mops.toml 11 | 12 | ``` 13 | mops remove 14 | ``` 15 | 16 | ## Options 17 | 18 | ### `--dev` 19 | Remove package from `[dev-dependencies]` section. 20 | 21 | ### `--lock` 22 | 23 | What to do with the [lockfile](/mops.lock). 24 | 25 | Default value is `update` if lockfile exists and `ignore` otherwise. 26 | 27 | Possible values: 28 | - `update` - update lockfile (create if not exists). Always checks after update 29 | - `ignore` - ignore lockfile 30 | 31 | ### `--dry-run` 32 | 33 | Do not actually remove anything 34 | 35 | ### `--verbose` 36 | 37 | Verbose output. -------------------------------------------------------------------------------- /docs/docs/cli/1-deps/02-mops-install.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-install 3 | sidebar_label: mops install 4 | --- 5 | 6 | # `mops install` 7 | 8 | Install all dependencies specified in mops.toml 9 | ``` 10 | mops install 11 | ``` 12 | 13 | ## Options 14 | 15 | ### `--lock` 16 | 17 | What to do with the [lockfile](/mops.lock). 18 | 19 | Default value is `update` if lockfile exists and `ignore` otherwise. 20 | 21 | Possible values: 22 | - `check` - check downloaded dependencies against lockfile 23 | - `update` - update lockfile (create if not exists). Always checks after update 24 | - `ignore` - ignore lockfile 25 | 26 | ### `--verbose` 27 | 28 | Verbose output. -------------------------------------------------------------------------------- /docs/docs/cli/1-deps/03-mops-outdated.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-outdated 3 | sidebar_label: mops outdated 4 | --- 5 | 6 | # `mops outdated` 7 | 8 | Print available dependency updates 9 | ``` 10 | mops outdated 11 | ``` -------------------------------------------------------------------------------- /docs/docs/cli/1-deps/04-mops-update.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-update 3 | sidebar_label: mops update 4 | --- 5 | 6 | # `mops update` 7 | 8 | Update all dependencies 9 | ``` 10 | mops update 11 | ``` 12 | 13 | Update only a specific dependency 14 | ``` 15 | mops update [pkg] 16 | ``` 17 | 18 | ### Example 19 | 20 | Update the `base` package to the latest version: 21 | ``` 22 | mops update base 23 | ``` 24 | 25 | ## Options 26 | 27 | ### `--lock` 28 | 29 | What to do with the [lockfile](/mops.lock). 30 | 31 | Default value is `update` if lockfile exists and `ignore` otherwise. 32 | 33 | Possible values: 34 | - `update` - update lockfile (create if not exists). Always checks after update 35 | - `ignore` - ignore lockfile -------------------------------------------------------------------------------- /docs/docs/cli/1-deps/05-mops-sync.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-sync 3 | sidebar_label: mops sync 4 | --- 5 | 6 | # `mops sync` 7 | 8 | Analyze source code and: 9 | - Add missing packages that are used in the source code but are not listed in `mops.toml` 10 | - Remove unused packages listed in `mops.toml` but not imported in the source code 11 | 12 | ``` 13 | mops sync 14 | ``` 15 | 16 | ## Options 17 | 18 | ### `--lock` 19 | 20 | What to do with the [lockfile](/mops.lock). 21 | 22 | Default value is `update` if lockfile exists and `ignore` otherwise. 23 | 24 | Possible values: 25 | - `update` - update lockfile (create if not exists). Always checks after update 26 | - `ignore` - ignore lockfile -------------------------------------------------------------------------------- /docs/docs/cli/1-deps/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "position": 1, 3 | "label": "Manage dependencies", 4 | "collapsible": true, 5 | "collapsed": true 6 | } -------------------------------------------------------------------------------- /docs/docs/cli/2-publish/01-mops-publish.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-publish 3 | sidebar_label: mops publish 4 | --- 5 | 6 | # `mops publish` 7 | 8 | Publish package to the mops registry 9 | ``` 10 | mops publish 11 | ``` 12 | 13 | You need to [import identity](/cli/mops-user-import) before publishing a package. 14 | 15 | Tests will be run before publishing to ensure the package works correctly. 16 | 17 | Documentation for the package will be generated automatically from the source code(`src` folder) and published to the registry. 18 | 19 | ### Benchmarks 20 | 21 | Benchmarks will be run with `pocket-ic` replica if it is present in `mops.toml`, otherwise `dfx` replica will be used. 22 | 23 | Benchmark results will be published to the registry. 24 | 25 | You can view the results on the package page in the `Benchmarks` tab. 26 | 27 | You can also view the diff of the benchmark results between the current version and the previous version in the `Versions` tab. Benchmarks compared by file name, not by the benchmark name. 28 | 29 | ## Options 30 | 31 | `--no-docs` - Do not generate docs 32 | 33 | `--no-test` - Do not run tests 34 | 35 | `--no-bench` - Do not run benchmarks 36 | 37 | `--verbose` - Verbose output (print file names to be uploaded) -------------------------------------------------------------------------------- /docs/docs/cli/2-publish/02-mops-bump.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-bump 3 | sidebar_label: mops bump 4 | --- 5 | 6 | # `mops bump` 7 | 8 | Update `version = "x.x.x"` in mops.toml 9 | 10 | ``` 11 | mops bump [part] 12 | ``` 13 | 14 | `mops bump major` - bump major part of version (**X**.y.z) 15 | 16 | `mops bump minor` - bump minor part of version (x.**Y**.z) 17 | 18 | `mops bump patch` - bump patch part of version (x.y.**Z**) 19 | 20 | `mops bump` - you will be prompted to select a part of the version to update -------------------------------------------------------------------------------- /docs/docs/cli/2-publish/05-mops-owner.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-owner 3 | sidebar_label: mops owner 4 | --- 5 | 6 | # `mops owner` 7 | 8 | List, add or remove owners of a package. 9 | 10 | :::info 11 | Check the [Package owners and maintainers](/package-owners-and-maintainers) for more information. 12 | ::: 13 | 14 | ## `mops owner` 15 | Manage owners of the current package. 16 | 17 | ### `mops owner list` 18 | 19 | List all owners of the package. 20 | 21 | ### `mops owner add` 22 | 23 | Add new package owner. 24 | ``` 25 | mops owner add 26 | ``` 27 | 28 | ### `mops owner remove` 29 | 30 | Remove package owner. 31 | ``` 32 | mops owner remove 33 | ``` 34 | 35 | ## Example 36 | 37 | Imagine you have a package named `hello` and you want to add the principal `2d2zu-vaaaa-aaaak-qb6pq-cai` as an owner. 38 | 39 | mops.toml: 40 | ```toml 41 | [package] 42 | name = "hello" 43 | version = "0.1.0" 44 | ... 45 | ``` 46 | 47 | Add the owner: 48 | ``` 49 | mops owner add 2d2zu-vaaaa-aaaak-qb6pq-cai 50 | ``` -------------------------------------------------------------------------------- /docs/docs/cli/2-publish/06-mops-maintainer.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-maintainer 3 | sidebar_label: mops maintainer 4 | --- 5 | 6 | # `mops maintainer` 7 | 8 | List, add or remove maintainers of a package. 9 | 10 | :::info 11 | Check the [Package owners and maintainers](/package-owners-and-maintainers) for more information. 12 | ::: 13 | 14 | ## `mops maintainer` 15 | Manage maintainers of the current package. 16 | 17 | ### `mops maintainer list` 18 | 19 | List all maintainers of the package. 20 | 21 | ### `mops maintainer add` 22 | 23 | Add new package maintainer. 24 | ``` 25 | mops maintainer add 26 | ``` 27 | 28 | ### `mops maintainer remove` 29 | 30 | Remove package maintainer. 31 | ``` 32 | mops maintainer remove 33 | ``` 34 | 35 | ## Example 36 | 37 | Imagine you have a package named `hello` and you want to add the principal `2d2zu-vaaaa-aaaak-qb6pq-cai` as a maintainer. 38 | 39 | mops.toml: 40 | ```toml 41 | [package] 42 | name = "hello" 43 | version = "0.1.0" 44 | ... 45 | ``` 46 | 47 | Add the maintainer: 48 | ``` 49 | mops maintainer add 2d2zu-vaaaa-aaaak-qb6pq-cai 50 | ``` -------------------------------------------------------------------------------- /docs/docs/cli/2-publish/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "position": 2, 3 | "label": "Publish a package", 4 | "collapsible": true, 5 | "collapsed": true 6 | } -------------------------------------------------------------------------------- /docs/docs/cli/3-user/01-mops-user-import.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-user-import 3 | sidebar_label: mops user import 4 | --- 5 | 6 | # `mops user import` 7 | 8 | Import `.pem` file data to use as identity. 9 | 10 | ``` 11 | mops user import -- 12 | ``` 13 | 14 | To be able to publish a packages to the `mops` registry, you need to import an identity from DFX. 15 | 16 | ### Import identity from DFX 17 | 18 | ``` 19 | mops user import -- "$(dfx identity export )" 20 | ``` 21 | 22 | ### Example 23 | 24 | 1. Create new identity in DFX named `mops` 25 | 26 | ``` 27 | dfx identity new mops 28 | ``` 29 | 30 | 2. Import identity into `mops` 31 | 32 | ``` 33 | mops user import -- "$(dfx identity export mops)" 34 | ``` -------------------------------------------------------------------------------- /docs/docs/cli/3-user/02-mops-user-get-principal.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-user-get-principal 3 | sidebar_label: mops user get-principal 4 | --- 5 | 6 | # `mops user get-principal` 7 | 8 | Print your principal. 9 | 10 | ``` 11 | mops user get-principal 12 | ``` -------------------------------------------------------------------------------- /docs/docs/cli/3-user/03-mops-user-set.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-user-set 3 | sidebar_label: mops user set 4 | --- 5 | 6 | # `mops user set` 7 | 8 | Set user properties. 9 | 10 | ``` 11 | mops user set 12 | ``` 13 | 14 | You can get the current value with: 15 | ``` 16 | mops user get 17 | ``` 18 | 19 | ## Available properties 20 | 21 | - `name` - username on mops.one 22 | - `github` - github username 23 | - `twitter` - twitter username 24 | 25 | ## Example 26 | 27 | ```bash 28 | mops user set name zen 29 | mops user set github ZenVoich 30 | mops user set twitter mops_one 31 | ``` 32 | 33 | Here is how the user info looks like on mops.one: 34 | 35 | ![user info on mops.one](user-info.png) -------------------------------------------------------------------------------- /docs/docs/cli/3-user/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "position": 3, 3 | "label": "User", 4 | "collapsible": true, 5 | "collapsed": true 6 | } -------------------------------------------------------------------------------- /docs/docs/cli/3-user/user-info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/docs/docs/cli/3-user/user-info.png -------------------------------------------------------------------------------- /docs/docs/cli/4-dev/02-mops-bench.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-bench 3 | sidebar_label: mops bench 4 | --- 5 | 6 | # `mops bench` 7 | 8 | Run Motoko benchmarks. 9 | 10 | ``` 11 | mops bench [filter] 12 | ``` 13 | 14 | Put your benchmark code in `bench/*.bench.mo` files. 15 | 16 | It is necessary to use [bench package](https://mops.one/bench) to write benchmarks. 17 | 18 | The output format is a markdown table, so you can copy-paste it into your `README.md`. 19 | 20 | ### How it works 21 | 22 | Under the hood, Mops will: 23 | - Start a local replica on port `4944` 24 | - Wrap each `*.bench.mo` file in a canister 25 | - Compile canisters with `--force-gc` flag and deploy them 26 | - Run each cell of the benchmark file as an update call 27 | - For each call measure usage of wasm instructions(`performance_counter`) and heap size(`rts_heap_size`) 28 | 29 | ## Options 30 | 31 | ### `--replica` 32 | 33 | Which replica to use. 34 | 35 | Default `pocket-ic` if `pocket-ic` is specified in `mops.toml` in `[toolchain]` section, otherwise `dfx`. 36 | 37 | Possible values: 38 | - `dfx` - use `dfx` local replica 39 | - `pocket-ic` - use [PocketIC](https://pypi.org/project/pocket-ic/) light replica via [pic.js](https://www.npmjs.com/package/@hadronous/pic) wrapper 40 | 41 | ### `--gc` 42 | 43 | Select garbage collector. 44 | 45 | Possible values: 46 | - `copying` (default) 47 | - `compacting` 48 | - `generational` 49 | - `incremental` 50 | 51 | ### `--save` 52 | 53 | Save benchmark results to `.bench/.json` file. 54 | 55 | ### `--compare` 56 | 57 | Compare benchmark results with the results from `.bench/.json` file. 58 | 59 | ### `--verbose` 60 | 61 | Verbose output. -------------------------------------------------------------------------------- /docs/docs/cli/4-dev/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "position": 4, 3 | "label": "Development", 4 | "collapsible": true, 5 | "collapsed": true 6 | } -------------------------------------------------------------------------------- /docs/docs/cli/5-toolchain/01-toolchain-overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/toolchain 3 | sidebar_label: Overview 4 | --- 5 | 6 | # Toolchain Management with Mops 7 | 8 | Mops simplifies toolchain management for Motoko projects, allowing you to specify exact versions of each tool in the `mops.toml` file for each project. 9 | 10 | When you run `mops install` command, Mops will install the specified version of each tool. 11 | 12 | ## Available tools 13 | - `moc` - Motoko compiler 14 | - `wasmtime` - Wasmtime runtime (used by `mops test --mode wasi`) 15 | - `pocket-ic` - PocketIC replica (used by `mops bench --replica pocket-ic`) 16 | 17 | ## Specifying tool versions 18 | 19 | ### Option 1: Use `mops toolchain use` command 20 | 21 | You can use [`mops toolchain use`](/cli/mops-toolchain-use) command to install specific tool version and update `mops.toml` file. 22 | ``` 23 | mops toolchain use moc 0.10.3 24 | mops toolchain use wasmtime 16.0.0 25 | mops toolchain use pocket-ic 1.0.0 26 | ``` 27 | 28 | No need to run `mops install` when you use `mops toolchain use` command. 29 | 30 | ### Option 2: Edit `mops.toml` file 31 | 32 | You can manually edit `mops.toml` file to specify exact versions of each tool. 33 | 34 | ```toml 35 | [toolchain] 36 | moc = "0.10.3" 37 | wasmtime = "16.0.0" 38 | pocket-ic = "1.0.0" 39 | ``` 40 | 41 | You need to run `mops install` command when you edit `mops.toml` file manually. 42 | 43 | ## Toolchain management commands 44 | 45 | - [`mops toolchain init`](/cli/mops-toolchain-init) 46 | - [`mops toolchain use`](/cli/mops-toolchain-use) 47 | - [`mops toolchain update`](/cli/mops-toolchain-update) 48 | - [`mops toolchain bin`](/cli/mops-toolchain-bin) 49 | - [`mops toolchain reset`](/cli/mops-toolchain-reset) -------------------------------------------------------------------------------- /docs/docs/cli/5-toolchain/02-mops-toolchain-init.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-toolchain-init 3 | sidebar_label: mops toolchain init 4 | --- 5 | 6 | # `mops toolchain init` 7 | 8 | Initialize Mops toolchain management. 9 | 10 | ``` 11 | mops toolchain init 12 | ``` 13 | 14 | This command should be run only once. 15 | 16 | This command is only needed to make `dfx` use `moc` version specified in `mops.toml` file. 17 | 18 | It will update your `.bashrc`/`.zshrc` file to set `DFX_MOC_PATH` to the `moc-wrapper`. 19 | So when you build your project with `dfx`, it will use `moc` version specified in `mops.toml` file. If `moc` version is not specified, it will use default `moc` version that comes with `dfx`. 20 | 21 | :::info 22 | In CI environment, this command runs automatically when you run `mops install` or `mops toolchain use`. 23 | 24 | So no need to run it manually in GitHub Actions. 25 | ::: 26 | 27 | To undo changes made by this command, run [`mops toolchain reset`](/cli/mops-toolchain-reset) command. 28 | -------------------------------------------------------------------------------- /docs/docs/cli/5-toolchain/03-mops-toolchain-use.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-toolchain-use 3 | sidebar_label: mops toolchain use 4 | --- 5 | 6 | # `mops toolchain use` 7 | 8 | Install specific tool version and update `mops.toml` file. 9 | 10 | ``` 11 | mops toolchain use [version] 12 | ``` 13 | 14 | ## Examples 15 | 16 | Install specific tool version 17 | ``` 18 | mops toolchain use moc 0.10.3 19 | mops toolchain use wasmtime 16.0.0 20 | mops toolchain use pocket-ic 1.0.0 21 | ``` 22 | 23 | You can specify `latest` as version to install the latest available version. 24 | ``` 25 | mops toolchain use moc latest 26 | ``` 27 | 28 | If a version is not specified, you will be prompted to select the version from the list of available versions. 29 | ``` 30 | mops toolchain use moc 31 | ``` 32 | 33 | ![user prompt image](mops-toolchain-use-moc.png) -------------------------------------------------------------------------------- /docs/docs/cli/5-toolchain/04-mops-toolchain-update.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-toolchain-update 3 | sidebar_label: mops toolchain update 4 | --- 5 | 6 | # `mops toolchain update` 7 | 8 | Update specified tool or all tools to the latest version and update `mops.toml` 9 | 10 | ``` 11 | mops toolchain update [tool] 12 | ``` 13 | 14 | ## Examples 15 | 16 | Update all tools to the latest version 17 | ``` 18 | mops toolchain update 19 | ``` 20 | 21 | Update specific tool to the latest version 22 | ``` 23 | mops toolchain update moc 24 | mops toolchain update wasmtime 25 | mops toolchain update pocket-ic 26 | ``` -------------------------------------------------------------------------------- /docs/docs/cli/5-toolchain/05-mops-toolchain-bin.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-toolchain-bin 3 | sidebar_label: mops toolchain bin 4 | --- 5 | 6 | # `mops toolchain bin` 7 | 8 | Print path to the specified tool binary. 9 | 10 | ``` 11 | mops toolchain bin 12 | ``` 13 | 14 | ## Examples 15 | 16 | Print path to the `moc` binary: 17 | ``` 18 | mops toolchain bin moc 19 | ``` 20 | 21 | Print path to the `wasmtime` binary: 22 | ``` 23 | mops toolchain bin wasmtime 24 | ``` 25 | 26 | Print path to the `pocket-ic` binary: 27 | ``` 28 | mops toolchain bin pocket-ic 29 | ``` 30 | 31 | ### Run tool 32 | 33 | You can run the version of the tool defined in `mops.toml` by running: 34 | ``` 35 | $(mops toolchain bin ) 36 | ``` 37 | 38 | Run `moc`: 39 | ``` 40 | $(mops toolchain bin moc) 41 | ``` 42 | 43 | Run `moc` with mops packages: 44 | ``` 45 | $(mops toolchain bin moc) $(mops sources) --version 46 | ``` 47 | 48 | Run `pocket-ic`: 49 | ``` 50 | $(mops toolchain bin pocket-ic) 51 | ``` 52 | 53 | Run `wasmtime`: 54 | ``` 55 | $(mops toolchain bin wasmtime) 56 | ``` -------------------------------------------------------------------------------- /docs/docs/cli/5-toolchain/06-mops-toolchain-rest.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-toolchain-reset 3 | sidebar_label: mops toolchain reset 4 | --- 5 | 6 | # `mops toolchain reset` 7 | 8 | Uninstall toolchain management. 9 | 10 | ``` 11 | mops toolchain reset 12 | ``` 13 | 14 | This command will undo changes made by [`mops toolchain init`](/cli/mops-toolchain-init) command. -------------------------------------------------------------------------------- /docs/docs/cli/5-toolchain/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "position": 5, 3 | "label": "Toolchain management", 4 | "collapsible": true, 5 | "collapsed": true 6 | } -------------------------------------------------------------------------------- /docs/docs/cli/5-toolchain/mops-toolchain-use-moc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/docs/docs/cli/5-toolchain/mops-toolchain-use-moc.png -------------------------------------------------------------------------------- /docs/docs/cli/6-self/01-mops-self-update.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-self-update 3 | sidebar_label: mops self update 4 | --- 5 | 6 | # `mops self update` 7 | 8 | Update the Mops CLI to the latest version. 9 | 10 | ``` 11 | mops self update 12 | ``` -------------------------------------------------------------------------------- /docs/docs/cli/6-self/02-mops-self-uninstall.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-self-uninstall 3 | sidebar_label: mops self uninstall 4 | --- 5 | 6 | # `mops self uninstall` 7 | 8 | Clean cache and uninstall the Mops CLI. 9 | 10 | ``` 11 | mops self uninstall 12 | ``` -------------------------------------------------------------------------------- /docs/docs/cli/6-self/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "position": 6, 3 | "label": "Mops CLI management", 4 | "collapsible": true, 5 | "collapsed": true 6 | } -------------------------------------------------------------------------------- /docs/docs/cli/7-misc/03-mops-cache.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-cache 3 | sidebar_label: mops cache 4 | --- 5 | 6 | # `mops cache` 7 | 8 | Mops caches the downloaded files(package sources, toolchains binaries) to speed up the installation process. 9 | 10 | When you run `mops install`, `mops add ` or `mops toolchain use/update`, Mops will download the files and store them in the cache directory. For subsequent installations, Mops will use the cached files instead of downloading them again. 11 | 12 | Local cache directory is created in the project root in the `.mops` directory. 13 | 14 | The integrity of cached files is verified using the [mops.lock](/mops.lock) file. 15 | 16 | ### `mops cache show` 17 | 18 | Print global cache directory path. 19 | 20 | ### `mops cache size` 21 | 22 | Print global cache size. 23 | 24 | ### `mops cache clean` 25 | 26 | Clean global and local cache directories. -------------------------------------------------------------------------------- /docs/docs/cli/7-misc/04-mops-sources.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /cli/mops-sources 3 | sidebar_label: mops sources 4 | --- 5 | 6 | # `mops sources` 7 | 8 | Prints the final resolved package sources. 9 | 10 | The main purpose of this command is to be specified in the dfx.json file: 11 | ```json 12 | ... 13 | "defaults": { 14 | "build": { 15 | "packtool": "mops sources" 16 | } 17 | }, 18 | ... 19 | ``` 20 | 21 | The output is formatted to be passed to the `moc`. 22 | 23 | Example output: 24 | ``` 25 | --package base .mops/base@0.10.4/src 26 | --package time-consts .mops/time-consts@1.0.1/src 27 | --package map .mops/map@9.0.1/src 28 | --package ic .mops/ic@1.0.1/src 29 | ``` 30 | 31 | ## Options 32 | 33 | ### `--no-install` 34 | 35 | Do not install dependencies before resolving sources. 36 | 37 | ### `--conflicts ` 38 | 39 | What to do with dependency version conflicts. 40 | 41 | If the dependency graph contains packages with the same name but different major versions, they will be treated as conflicting. 42 | 43 | Possible values: 44 | - `warning` - Show conflics _(default)_ 45 | - `error` - Show conflics and exit with error code 46 | - `ignore` - Ignore conflicts -------------------------------------------------------------------------------- /docs/docs/cli/7-misc/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "position": 7, 3 | "label": "Miscellaneous", 4 | "collapsible": true, 5 | "collapsed": true 6 | } -------------------------------------------------------------------------------- /docs/docs/cli/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "position": 1, 3 | "label": "CLI", 4 | "collapsible": true, 5 | "collapsed": false 6 | } 7 | -------------------------------------------------------------------------------- /docs/docs/cli/structure: -------------------------------------------------------------------------------- 1 | User: 2 | user set [value] User settings 3 | user get User settings 4 | 5 | Other commands: 6 | cache Manage cache 7 | sources [options] for dfx packtool 8 | search Search for packages 9 | template Apply template -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "docusaurus": "docusaurus", 5 | "start": "docusaurus start --no-open --port 3001", 6 | "build": "docusaurus build", 7 | "swizzle": "docusaurus swizzle", 8 | "deploy": "docusaurus deploy", 9 | "clear": "docusaurus clear", 10 | "serve": "docusaurus serve --no-open", 11 | "write-translations": "docusaurus write-translations", 12 | "write-heading-ids": "docusaurus write-heading-ids", 13 | "typecheck": "tsc" 14 | }, 15 | "dependencies": { 16 | "@docusaurus/core": "2.4.3", 17 | "@docusaurus/preset-classic": "2.4.3", 18 | "@mdx-js/react": "^1.6.22", 19 | "clsx": "^1.2.1", 20 | "docusaurus-plugin-fathom": "1.1.0", 21 | "prism-react-renderer": "^1.3.5", 22 | "react": "^17.0.2", 23 | "react-dom": "^17.0.2" 24 | }, 25 | "devDependencies": { 26 | "@docusaurus/module-type-aliases": "2.4.3", 27 | "@tsconfig/docusaurus": "^1.0.5", 28 | "typescript": "^4.7.4" 29 | }, 30 | "browserslist": { 31 | "production": [ 32 | ">0.5%", 33 | "not dead", 34 | "not op_mini all" 35 | ], 36 | "development": [ 37 | "last 1 chrome version", 38 | "last 1 firefox version", 39 | "last 1 safari version" 40 | ] 41 | }, 42 | "engines": { 43 | "node": ">=18.0.0" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /docs/sidebars.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creating a sidebar enables you to: 3 | - create an ordered group of docs 4 | - render a sidebar for each doc of that group 5 | - provide next/previous navigation 6 | 7 | The sidebars can be generated from the filesystem, or explicitly defined here. 8 | 9 | Create as many sidebars as you want. 10 | */ 11 | 12 | // @ts-check 13 | 14 | /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ 15 | const sidebars = { 16 | // By default, Docusaurus generates a sidebar from the docs folder structure 17 | tutorialSidebar: [{type: 'autogenerated', dirName: '.'}], 18 | 19 | // But you can create a sidebar manually 20 | /* 21 | tutorialSidebar: [ 22 | 'intro', 23 | 'hello', 24 | { 25 | type: 'category', 26 | label: 'Tutorial', 27 | items: ['tutorial-basics/create-a-document'], 28 | }, 29 | ], 30 | */ 31 | }; 32 | 33 | module.exports = sidebars; 34 | -------------------------------------------------------------------------------- /docs/src/components/HomepageFeatures/styles.module.css: -------------------------------------------------------------------------------- 1 | .features { 2 | display: flex; 3 | align-items: center; 4 | padding: 2rem 0; 5 | width: 100%; 6 | } 7 | 8 | .featureSvg { 9 | height: 200px; 10 | width: 200px; 11 | } 12 | -------------------------------------------------------------------------------- /docs/src/pages/index-old.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import clsx from 'clsx'; 3 | import Link from '@docusaurus/Link'; 4 | import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; 5 | import Layout from '@theme/Layout'; 6 | import HomepageFeatures from '@site/src/components/HomepageFeatures'; 7 | 8 | import styles from './index.module.css'; 9 | 10 | function HomepageHeader() { 11 | const {siteConfig} = useDocusaurusContext(); 12 | return ( 13 |
14 |
15 |

{siteConfig.title}

16 |

{siteConfig.tagline}

17 |
18 | 21 | Documentation 22 | 23 |
24 |
25 |
26 | ); 27 | } 28 | 29 | export default function Home(): JSX.Element { 30 | const {siteConfig} = useDocusaurusContext(); 31 | return ( 32 | 35 | 36 |
37 | 38 |
39 |
40 | ); 41 | } 42 | -------------------------------------------------------------------------------- /docs/src/pages/index.module.css: -------------------------------------------------------------------------------- 1 | /** 2 | * CSS files with the .module.css suffix will be treated as CSS modules 3 | * and scoped locally. 4 | */ 5 | 6 | .heroBanner { 7 | padding: 4rem 0; 8 | text-align: center; 9 | position: relative; 10 | overflow: hidden; 11 | } 12 | 13 | @media screen and (max-width: 996px) { 14 | .heroBanner { 15 | padding: 2rem; 16 | } 17 | } 18 | 19 | .buttons { 20 | display: flex; 21 | align-items: center; 22 | justify-content: center; 23 | } 24 | -------------------------------------------------------------------------------- /docs/src/pages/markdown-page.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Markdown page example 3 | --- 4 | 5 | # Markdown page example 6 | 7 | You don't need React to write simple standalone pages. 8 | -------------------------------------------------------------------------------- /docs/static/.ic-assets.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "match": ".well-known", 4 | "ignore": false 5 | } 6 | ] -------------------------------------------------------------------------------- /docs/static/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/docs/static/.nojekyll -------------------------------------------------------------------------------- /docs/static/.well-known/ic-domains: -------------------------------------------------------------------------------- 1 | docs.mops.one -------------------------------------------------------------------------------- /docs/static/img/docusaurus-social-card.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/docs/static/img/docusaurus-social-card.jpg -------------------------------------------------------------------------------- /docs/static/img/docusaurus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/docs/static/img/docusaurus.png -------------------------------------------------------------------------------- /docs/static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/docs/static/img/favicon.ico -------------------------------------------------------------------------------- /docs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // This file is not used in compilation. It is here just for a nice editor experience. 3 | "extends": "@tsconfig/docusaurus/tsconfig.json", 4 | "compilerOptions": { 5 | "baseUrl": "." 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /frontend/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "node": true 5 | }, 6 | "extends": [ 7 | "plugin:svelte/base" 8 | ], 9 | "parserOptions": { 10 | // ... 11 | "project": "./frontend/tsconfig.json", 12 | "extraFileExtensions": [".svelte"] // This is a required setting in `@typescript-eslint/parser` v4.24.0. 13 | }, 14 | "rules": { 15 | "no-irregular-whitespace": "off" 16 | }, 17 | "overrides": [ 18 | { 19 | "files": ["*.svelte"], 20 | "parser": "svelte-eslint-parser", 21 | // Parse the ` 6 | 7 | {sign}{+value.toFixed(2)}% -------------------------------------------------------------------------------- /frontend/components/Date.svelte: -------------------------------------------------------------------------------- 1 | 14 | 15 | {distance(date)} -------------------------------------------------------------------------------- /frontend/components/Footer.svelte: -------------------------------------------------------------------------------- 1 | 7 | 8 |
9 | 10 | 11 | 12 | 13 |
14 | 15 | -------------------------------------------------------------------------------- /frontend/components/Loader.svelte: -------------------------------------------------------------------------------- 1 | 13 | 14 |
15 | 16 |
17 |
18 | 19 | -------------------------------------------------------------------------------- /frontend/components/NotFound.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 |
6 |
7 | 8 |
9 | 10 | -------------------------------------------------------------------------------- /frontend/components/RecentlyUpdatedPackages.svelte: -------------------------------------------------------------------------------- 1 | 16 | 17 |
18 |
Recently Updated
19 | 20 | {#if loaded} 21 | {#each packages as pkg} 22 | 23 | {:else} 24 | {#if loaded} 25 |
Packages not found
26 | {/if} 27 | {/each} 28 | {:else} 29 | 30 | {/if} 31 |
32 | 33 | -------------------------------------------------------------------------------- /frontend/components/TotalStats.svelte: -------------------------------------------------------------------------------- 1 | 13 | 14 |
15 |
Total packages: {totalPackages?.toLocaleString() || '-'}
16 |
Total downloads: {totalDownloads?.toLocaleString() || '-'}
17 |
18 | 19 | -------------------------------------------------------------------------------- /frontend/components/docs/docs.css: -------------------------------------------------------------------------------- 1 | .documentation { 2 | display: flex; 3 | flex-direction: column; 4 | align-items: center; 5 | margin-bottom: 80px; 6 | } 7 | 8 | .documentation .content { 9 | max-width: 700px; 10 | width: 100%; 11 | padding: 30px 15px; 12 | box-sizing: border-box; 13 | } 14 | 15 | .documentation h2 { 16 | border-bottom: none; 17 | } 18 | 19 | .documentation h3 { 20 | margin-top: 30px; 21 | } 22 | 23 | .documentation code.inline { 24 | display: inline; 25 | padding: 3px; 26 | } 27 | 28 | .documentation code { 29 | display: block; 30 | padding: 10px 12px; 31 | overflow-x: auto; 32 | } -------------------------------------------------------------------------------- /frontend/components/links/Discord.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | Discord logo 7 | 8 | 9 | -------------------------------------------------------------------------------- /frontend/components/links/GitHub.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | GitHub logo 7 | 8 | 9 | -------------------------------------------------------------------------------- /frontend/components/links/Logo.svelte: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /frontend/components/links/Twitter.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | Twitter logo 7 | 8 | 9 | -------------------------------------------------------------------------------- /frontend/components/package/BadgesModal.svelte: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 |
19 | If you are the author of this package, you can use these badges by adding the following code to your README.md file: 20 | 21 |
22 | 23 | [![mops]({badgeUrl('mops')})](https://mops.one/{packageName}) 24 | 25 |
26 | 27 |
28 |
29 | 30 |
31 | 32 | [![documentation]({badgeUrl('documentation')})](https://mops.one/{packageName}/docs) 33 | 34 |
35 | 36 |
37 |
38 |
39 |
40 | 41 | -------------------------------------------------------------------------------- /frontend/components/package/Keywords.svelte: -------------------------------------------------------------------------------- 1 | 6 | 7 |
8 | {#each keywords as keyword} 9 | #{keyword} 10 | {/each} 11 |
12 | 13 | -------------------------------------------------------------------------------- /frontend/components/package/PackageBenchmarks.svelte: -------------------------------------------------------------------------------- 1 | 7 | 8 |
9 | {#if packageDetails.benchmarks.length === 0} 10 |
No benchmarks
11 | {:else} 12 |
13 |
{packageDetails.benchmarks[0].replica} {packageDetails.benchmarks[0].replicaVersion}, {packageDetails.benchmarks[0].compiler} {packageDetails.benchmarks[0].compilerVersion}, {packageDetails.benchmarks[0].gc} GC
14 |
15 | 16 | {#each packageDetails.benchmarks as benchmark} 17 | 18 | {/each} 19 | {/if} 20 |
21 | 22 | -------------------------------------------------------------------------------- /frontend/components/package/PackageQualityIcon.svelte: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /frontend/components/package/PackageReadme.svelte: -------------------------------------------------------------------------------- 1 | 8 | 9 |
10 | {#await markdownToHtml(readme, repository)} 11 | Loading... 12 | {:then html} 13 | {@html html} 14 | {/await} 15 |
16 | 17 | -------------------------------------------------------------------------------- /frontend/components/package/PackageTestStats.svelte: -------------------------------------------------------------------------------- 1 | 34 | 35 | -------------------------------------------------------------------------------- /frontend/declarations/bench/bench.did: -------------------------------------------------------------------------------- 1 | type _anon_class_13_1 = 2 | service { 3 | getSchema: () -> (BenchSchema) query; 4 | getStats: () -> (BenchResult) query; 5 | init: () -> (BenchSchema); 6 | runCellQuery: (nat, nat) -> (BenchResult) query; 7 | runCellUpdate: (nat, nat) -> (BenchResult); 8 | runCellUpdateAwait: (nat, nat) -> (BenchResult); 9 | }; 10 | type BenchSchema = 11 | record { 12 | cols: vec text; 13 | description: text; 14 | name: text; 15 | rows: vec text; 16 | }; 17 | type BenchResult = 18 | record { 19 | instructions: int; 20 | rts_collector_instructions: int; 21 | rts_heap_size: int; 22 | rts_logical_stable_memory_size: int; 23 | rts_memory_size: int; 24 | rts_mutator_instructions: int; 25 | rts_reclaimed: int; 26 | rts_stable_memory_size: int; 27 | rts_total_allocation: int; 28 | stable_memory_size: int; 29 | }; 30 | service : () -> _anon_class_13_1 31 | -------------------------------------------------------------------------------- /frontend/declarations/bench/bench.did.d.ts: -------------------------------------------------------------------------------- 1 | import type { Principal } from '@dfinity/principal'; 2 | import type { ActorMethod } from '@dfinity/agent'; 3 | import type { IDL } from '@dfinity/candid'; 4 | 5 | export interface BenchResult { 6 | 'rts_stable_memory_size' : bigint, 7 | 'stable_memory_size' : bigint, 8 | 'instructions' : bigint, 9 | 'rts_memory_size' : bigint, 10 | 'rts_total_allocation' : bigint, 11 | 'rts_collector_instructions' : bigint, 12 | 'rts_mutator_instructions' : bigint, 13 | 'rts_logical_stable_memory_size' : bigint, 14 | 'rts_heap_size' : bigint, 15 | 'rts_reclaimed' : bigint, 16 | } 17 | export interface BenchSchema { 18 | 'cols' : Array, 19 | 'name' : string, 20 | 'rows' : Array, 21 | 'description' : string, 22 | } 23 | export interface _anon_class_13_1 { 24 | 'getSchema' : ActorMethod<[], BenchSchema>, 25 | 'getStats' : ActorMethod<[], BenchResult>, 26 | 'init' : ActorMethod<[], BenchSchema>, 27 | 'runCellQuery' : ActorMethod<[bigint, bigint], BenchResult>, 28 | 'runCellUpdate' : ActorMethod<[bigint, bigint], BenchResult>, 29 | 'runCellUpdateAwait' : ActorMethod<[bigint, bigint], BenchResult>, 30 | } 31 | export interface _SERVICE extends _anon_class_13_1 {} 32 | export declare const idlFactory: IDL.InterfaceFactory; 33 | export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[]; 34 | -------------------------------------------------------------------------------- /frontend/declarations/bench/bench.did.js: -------------------------------------------------------------------------------- 1 | export const idlFactory = ({ IDL }) => { 2 | const BenchSchema = IDL.Record({ 3 | 'cols' : IDL.Vec(IDL.Text), 4 | 'name' : IDL.Text, 5 | 'rows' : IDL.Vec(IDL.Text), 6 | 'description' : IDL.Text, 7 | }); 8 | const BenchResult = IDL.Record({ 9 | 'rts_stable_memory_size' : IDL.Int, 10 | 'stable_memory_size' : IDL.Int, 11 | 'instructions' : IDL.Int, 12 | 'rts_memory_size' : IDL.Int, 13 | 'rts_total_allocation' : IDL.Int, 14 | 'rts_collector_instructions' : IDL.Int, 15 | 'rts_mutator_instructions' : IDL.Int, 16 | 'rts_logical_stable_memory_size' : IDL.Int, 17 | 'rts_heap_size' : IDL.Int, 18 | 'rts_reclaimed' : IDL.Int, 19 | }); 20 | const _anon_class_13_1 = IDL.Service({ 21 | 'getSchema' : IDL.Func([], [BenchSchema], ['query']), 22 | 'getStats' : IDL.Func([], [BenchResult], ['query']), 23 | 'init' : IDL.Func([], [BenchSchema], []), 24 | 'runCellQuery' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], ['query']), 25 | 'runCellUpdate' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], []), 26 | 'runCellUpdateAwait' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], []), 27 | }); 28 | return _anon_class_13_1; 29 | }; 30 | export const init = ({ IDL }) => { return []; }; 31 | -------------------------------------------------------------------------------- /frontend/declarations/bench/index.js: -------------------------------------------------------------------------------- 1 | import { Actor, HttpAgent } from "@dfinity/agent"; 2 | 3 | // Imports and re-exports candid interface 4 | import { idlFactory } from "./bench.did.js"; 5 | export { idlFactory } from "./bench.did.js"; 6 | 7 | /* CANISTER_ID is replaced by webpack based on node environment 8 | * Note: canister environment variable will be standardized as 9 | * process.env.CANISTER_ID_ 10 | * beginning in dfx 0.15.0 11 | */ 12 | export const canisterId = 13 | process.env.CANISTER_ID_BENCH; 14 | 15 | export const createActor = (canisterId, options = {}) => { 16 | const agent = options.agent || new HttpAgent({ ...options.agentOptions }); 17 | 18 | if (options.agent && options.agentOptions) { 19 | console.warn( 20 | "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." 21 | ); 22 | } 23 | 24 | // Fetch root key for certificate validation during development 25 | if (process.env.DFX_NETWORK !== "ic") { 26 | agent.fetchRootKey().catch((err) => { 27 | console.warn( 28 | "Unable to fetch root key. Check to ensure that your local replica is running" 29 | ); 30 | console.error(err); 31 | }); 32 | } 33 | 34 | // Creates an actor with using the candid interface and the HttpAgent 35 | return Actor.createActor(idlFactory, { 36 | agent, 37 | canisterId, 38 | ...options.actorOptions, 39 | }); 40 | }; 41 | -------------------------------------------------------------------------------- /frontend/declarations/main/index.js: -------------------------------------------------------------------------------- 1 | import { Actor, HttpAgent } from "@dfinity/agent"; 2 | 3 | // Imports and re-exports candid interface 4 | import { idlFactory } from "./main.did.js"; 5 | export { idlFactory } from "./main.did.js"; 6 | 7 | /* CANISTER_ID is replaced by webpack based on node environment 8 | * Note: canister environment variable will be standardized as 9 | * process.env.CANISTER_ID_ 10 | * beginning in dfx 0.15.0 11 | */ 12 | export const canisterId = 13 | process.env.CANISTER_ID_MAIN; 14 | 15 | export const createActor = (canisterId, options = {}) => { 16 | const agent = options.agent || new HttpAgent({ ...options.agentOptions }); 17 | 18 | if (options.agent && options.agentOptions) { 19 | console.warn( 20 | "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." 21 | ); 22 | } 23 | 24 | // Fetch root key for certificate validation during development 25 | if (process.env.DFX_NETWORK !== "ic") { 26 | agent.fetchRootKey().catch((err) => { 27 | console.warn( 28 | "Unable to fetch root key. Check to ensure that your local replica is running" 29 | ); 30 | console.error(err); 31 | }); 32 | } 33 | 34 | // Creates an actor with using the candid interface and the HttpAgent 35 | return Actor.createActor(idlFactory, { 36 | agent, 37 | canisterId, 38 | ...options.actorOptions, 39 | }); 40 | }; 41 | -------------------------------------------------------------------------------- /frontend/declarations/storage/index.js: -------------------------------------------------------------------------------- 1 | import { Actor, HttpAgent } from "@dfinity/agent"; 2 | 3 | // Imports and re-exports candid interface 4 | import { idlFactory } from './storage.did.js'; 5 | export { idlFactory } from './storage.did.js'; 6 | 7 | /** 8 | * 9 | * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent 10 | * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig}} [options] 11 | * @return {import("@dfinity/agent").ActorSubclass} 12 | */ 13 | export const createActor = (canisterId, options) => { 14 | const agent = new HttpAgent({ ...options?.agentOptions }); 15 | 16 | // Fetch root key for certificate validation during development 17 | if(process.env.NODE_ENV !== "production") { 18 | agent.fetchRootKey().catch(err=>{ 19 | console.warn("Unable to fetch root key. Check to ensure that your local replica is running"); 20 | console.error(err); 21 | }); 22 | } 23 | 24 | // Creates an actor with using the candid interface and the HttpAgent 25 | return Actor.createActor(idlFactory, { 26 | agent, 27 | canisterId, 28 | ...options?.actorOptions, 29 | }); 30 | }; -------------------------------------------------------------------------------- /frontend/declarations/storage/storage.did: -------------------------------------------------------------------------------- 1 | type StorageStats = 2 | record { 3 | cyclesBalance: nat; 4 | fileCount: nat; 5 | memorySize: nat; 6 | }; 7 | type Storage = 8 | service { 9 | acceptCycles: () -> (); 10 | deleteFile: (FileId) -> (); 11 | downloadChunk: (FileId, nat) -> (Result_2) query; 12 | finishUpload: (FileId) -> (); 13 | getFileIdsRange: (nat, nat) -> (vec FileId) query; 14 | getFileMeta: (FileId) -> (Result_1) query; 15 | getStats: () -> (StorageStats) query; 16 | startUpload: (FileMeta) -> (Result); 17 | updateFileOwners: (FileId, vec principal) -> (); 18 | uploadChunk: (FileId, nat, Chunk) -> (); 19 | }; 20 | type Result_2 = 21 | variant { 22 | err: Err; 23 | ok: Chunk; 24 | }; 25 | type Result_1 = 26 | variant { 27 | err: Err; 28 | ok: FileMeta; 29 | }; 30 | type Result = 31 | variant { 32 | err: Err; 33 | ok; 34 | }; 35 | type FileMeta = 36 | record { 37 | chunkCount: nat; 38 | id: FileId__1; 39 | owners: vec principal; 40 | path: text; 41 | }; 42 | type FileId__1 = text; 43 | type FileId = text; 44 | type Err = text; 45 | type Chunk = blob; 46 | service : () -> Storage 47 | -------------------------------------------------------------------------------- /frontend/declarations/storage/storage.did.d.ts: -------------------------------------------------------------------------------- 1 | import type { Principal } from '@dfinity/principal'; 2 | import type { ActorMethod } from '@dfinity/agent'; 3 | import type { IDL } from '@dfinity/candid'; 4 | 5 | export type Chunk = Array; 6 | export type Err = string; 7 | export type FileId = string; 8 | export type FileId__1 = string; 9 | export interface FileMeta { 10 | 'id' : FileId__1, 11 | 'owners' : Array, 12 | 'path' : string, 13 | 'chunkCount' : bigint, 14 | } 15 | export type Result = { 'ok' : null } | 16 | { 'err' : Err }; 17 | export type Result_1 = { 'ok' : FileMeta } | 18 | { 'err' : Err }; 19 | export type Result_2 = { 'ok' : Chunk } | 20 | { 'err' : Err }; 21 | export interface Storage { 22 | 'acceptCycles' : ActorMethod<[], undefined>, 23 | 'deleteFile' : ActorMethod<[FileId], undefined>, 24 | 'downloadChunk' : ActorMethod<[FileId, bigint], Result_2>, 25 | 'finishUpload' : ActorMethod<[FileId], undefined>, 26 | 'getFileIdsRange' : ActorMethod<[bigint, bigint], Array>, 27 | 'getFileMeta' : ActorMethod<[FileId], Result_1>, 28 | 'getStats' : ActorMethod<[], StorageStats>, 29 | 'startUpload' : ActorMethod<[FileMeta], Result>, 30 | 'updateFileOwners' : ActorMethod<[FileId, Array], undefined>, 31 | 'uploadChunk' : ActorMethod<[FileId, bigint, Chunk], undefined>, 32 | } 33 | export interface StorageStats { 34 | 'fileCount' : bigint, 35 | 'cyclesBalance' : bigint, 36 | 'memorySize' : bigint, 37 | } 38 | export interface _SERVICE extends Storage {} 39 | export declare const idlFactory: IDL.InterfaceFactory; 40 | export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[]; -------------------------------------------------------------------------------- /frontend/declarations/storage/storage.did.js: -------------------------------------------------------------------------------- 1 | export const idlFactory = ({ IDL }) => { 2 | const FileId = IDL.Text; 3 | const Chunk = IDL.Vec(IDL.Nat8); 4 | const Err = IDL.Text; 5 | const Result_2 = IDL.Variant({ 'ok' : Chunk, 'err' : Err }); 6 | const FileId__1 = IDL.Text; 7 | const FileMeta = IDL.Record({ 8 | 'id' : FileId__1, 9 | 'owners' : IDL.Vec(IDL.Principal), 10 | 'path' : IDL.Text, 11 | 'chunkCount' : IDL.Nat, 12 | }); 13 | const Result_1 = IDL.Variant({ 'ok' : FileMeta, 'err' : Err }); 14 | const StorageStats = IDL.Record({ 15 | 'fileCount' : IDL.Nat, 16 | 'cyclesBalance' : IDL.Nat, 17 | 'memorySize' : IDL.Nat, 18 | }); 19 | const Result = IDL.Variant({ 'ok' : IDL.Null, 'err' : Err }); 20 | const Storage = IDL.Service({ 21 | 'acceptCycles' : IDL.Func([], [], []), 22 | 'deleteFile' : IDL.Func([FileId], [], []), 23 | 'downloadChunk' : IDL.Func([FileId, IDL.Nat], [Result_2], ['query']), 24 | 'finishUpload' : IDL.Func([FileId], [], []), 25 | 'getFileIdsRange' : IDL.Func( 26 | [IDL.Nat, IDL.Nat], 27 | [IDL.Vec(FileId)], 28 | ['query'], 29 | ), 30 | 'getFileMeta' : IDL.Func([FileId], [Result_1], ['query']), 31 | 'getStats' : IDL.Func([], [StorageStats], ['query']), 32 | 'startUpload' : IDL.Func([FileMeta], [Result], []), 33 | 'updateFileOwners' : IDL.Func([FileId, IDL.Vec(IDL.Principal)], [], []), 34 | 'uploadChunk' : IDL.Func([FileId, IDL.Nat, Chunk], [], []), 35 | }); 36 | return Storage; 37 | }; 38 | export const init = ({ IDL }) => { return []; }; 39 | -------------------------------------------------------------------------------- /frontend/external/gfm-table.css: -------------------------------------------------------------------------------- 1 | /* Light theme. */ 2 | :root { 3 | --color-canvas-default: #ffffff; 4 | /* --color-canvas-subtle: #f6f8fa; */ 5 | --color-canvas-subtle: rgb(246 248 248); 6 | --color-border-default: #d0d7de; 7 | --color-border-muted: hsla(210, 18%, 87%, 1); 8 | } 9 | 10 | /* Dark theme. */ 11 | /* @media (prefers-color-scheme: dark) { 12 | :root { 13 | --color-canvas-default: #0d1117; 14 | --color-canvas-subtle: #161b22; 15 | --color-border-default: #30363d; 16 | --color-border-muted: #21262d; 17 | } 18 | } */ 19 | 20 | table { 21 | border-spacing: 0; 22 | border-collapse: collapse; 23 | display: block; 24 | margin-top: 0; 25 | margin-bottom: 16px; 26 | width: max-content; 27 | max-width: 100%; 28 | overflow: auto; 29 | } 30 | 31 | tr { 32 | background-color: var(--color-canvas-default); 33 | border-top: 1px solid var(--color-border-muted); 34 | } 35 | 36 | tr:nth-child(2n) { 37 | background-color: var(--color-canvas-subtle); 38 | } 39 | 40 | td, 41 | th { 42 | padding: 6px 13px; 43 | border: 1px solid var(--color-border-default); 44 | word-break: normal; 45 | } 46 | 47 | th { 48 | font-weight: 600; 49 | } 50 | 51 | table img { 52 | background-color: transparent; 53 | } -------------------------------------------------------------------------------- /frontend/external/onig@1.7.0.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/frontend/external/onig@1.7.0.wasm -------------------------------------------------------------------------------- /frontend/global.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | declare module 'svelte-spa-history-router'; 5 | declare module 'js-untar'; -------------------------------------------------------------------------------- /frontend/img/discord.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/img/github.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/img/search.svg: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /frontend/img/twitter.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/index.html: -------------------------------------------------------------------------------- 1 | 2 | Mops • Motoko Package Manager 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 24 | 25 |
26 | 27 | -------------------------------------------------------------------------------- /frontend/index.ts: -------------------------------------------------------------------------------- 1 | import '../ui-kit/index.js'; 2 | import App from './components/App.svelte'; 3 | 4 | const app = new App({ 5 | target: document.getElementById('root'), 6 | }); 7 | 8 | export default app; -------------------------------------------------------------------------------- /frontend/logic/actors.ts: -------------------------------------------------------------------------------- 1 | import {Principal} from '@dfinity/principal'; 2 | import {createActor as createMainActor, canisterId as mainCanisterId} from '/declarations/main'; 3 | import {createActor as createStorageActor} from '/declarations/storage'; 4 | 5 | let getOptions = () => { 6 | return { 7 | agentOptions: { 8 | host: process.env.NODE_ENV === 'production' ? 'https://icp-api.io' : 'http://localhost:4943', 9 | verifyQuerySignatures: false, 10 | }, 11 | }; 12 | }; 13 | 14 | export let mainActor = () => { 15 | return createMainActor(mainCanisterId, getOptions()); 16 | }; 17 | 18 | export let storageActor = (storageId : string | Principal) => { 19 | return createStorageActor(storageId, getOptions()); 20 | }; 21 | 22 | declare global { 23 | // eslint-disable-next-line no-unused-vars, no-var 24 | var getStoragesStats : () => void; 25 | } 26 | 27 | window.getStoragesStats = () => { 28 | mainActor().getStoragesStats().then((statsAr) => { 29 | console.log(statsAr.map(([principal, stats]) => { 30 | return [principal.toText(), stats]; 31 | })); 32 | }); 33 | }; -------------------------------------------------------------------------------- /frontend/logic/benchmark-utils.ts: -------------------------------------------------------------------------------- 1 | import {Benchmark} from '/declarations/main/main.did.js'; 2 | 3 | export function getMetricNum(benchmark : Benchmark, row : string, col : string, metric : string) : number | undefined { 4 | let metricData = benchmark.metrics.find((m) => m[0] === metric); 5 | let rowIndex = benchmark.rows.indexOf(row); 6 | let colIndex = benchmark.cols.indexOf(col); 7 | let value = metricData?.[1]?.[rowIndex]?.[colIndex]; 8 | 9 | return value ? Number(value) : undefined; 10 | } 11 | 12 | export function getMetricDiff(benchmark : Benchmark, otherBenchmark : Benchmark, row : string, col : string, metric : string) : number { 13 | let curValue = getMetricNum(benchmark, row, col, metric); 14 | let prevValue = getMetricNum(otherBenchmark, row, col, metric); 15 | 16 | if (curValue && prevValue) { 17 | return (curValue - prevValue) / prevValue * 100; 18 | } 19 | else { 20 | return 0; 21 | } 22 | } -------------------------------------------------------------------------------- /frontend/logic/compare-versions.ts: -------------------------------------------------------------------------------- 1 | export let compareVersions = (a : string = '0.0.0', b : string = '0.0.0') => { 2 | let ap = a.split('.').map((x : string) => parseInt(x)) as [number, number, number]; 3 | let bp = b.split('.').map((x : string) => parseInt(x)) as [number, number, number]; 4 | if (ap[0] - bp[0]) { 5 | return Math.sign(ap[0] - bp[0]); 6 | } 7 | if (ap[0] === bp[0] && ap[1] - bp[1]) { 8 | return Math.sign(ap[1] - bp[1]); 9 | } 10 | if (ap[0] === bp[0] && ap[1] === bp[1] && ap[2] - bp[2]) { 11 | return Math.sign(ap[2] - bp[2]); 12 | } 13 | return 0; 14 | }; -------------------------------------------------------------------------------- /frontend/logic/get-quality-points.ts: -------------------------------------------------------------------------------- 1 | import {PackageQuality} from '/declarations/main/main.did'; 2 | 3 | export let getQualityPoints = (quality : PackageQuality) => { 4 | let maxBasePoints = 6; 5 | 6 | let basePoints = 7 | Number(quality.hasDescription) 8 | + Number(quality.hasDocumentation) 9 | + Number(quality.hasKeywords) 10 | + Number(quality.hasLicense) 11 | + Number(quality.hasRepository) 12 | + Number(!('tooOld' in quality.depsStatus)); 13 | let extraPoints = Number(quality.hasTests) + Number(quality.hasReleaseNotes) + Number('allLatest' in quality.depsStatus); 14 | 15 | if (basePoints !== maxBasePoints) { 16 | extraPoints = 0; 17 | } 18 | 19 | return { 20 | base: basePoints, 21 | extra: extraPoints, 22 | total: basePoints + extraPoints, 23 | }; 24 | }; -------------------------------------------------------------------------------- /frontend/logic/get-starry-night.ts: -------------------------------------------------------------------------------- 1 | import {createStarryNight} from '@wooorm/starry-night'; 2 | // @ts-ignore 3 | import moGrammar from '@wooorm/starry-night/source.mo'; 4 | // @ts-ignore 5 | import mdGrammar from '@wooorm/starry-night/text.md'; 6 | // @ts-ignore 7 | import tomlGrammar from '@wooorm/starry-night/source.toml'; 8 | 9 | type StarryNight = Awaited>; 10 | 11 | declare global { 12 | // eslint-disable-next-line no-unused-vars, no-var 13 | var starryNight : StarryNight; 14 | } 15 | 16 | export async function getStarryNight() : Promise { 17 | if (!window.starryNight) { 18 | window.starryNight = await createStarryNight([moGrammar, mdGrammar, tomlGrammar], { 19 | getOnigurumaUrlFetch: () => { 20 | return new URL('/external/onig@1.7.0.wasm', import.meta.url); 21 | }, 22 | }); 23 | } 24 | 25 | return window.starryNight; 26 | } -------------------------------------------------------------------------------- /frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mops", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "start": "DFX_NETWORK=local vite --port 3000", 9 | "vite": "vite", 10 | "build": "vite build", 11 | "preview": "vite preview", 12 | "check": "svelte-check --threshold error --no-tsconfig" 13 | }, 14 | "author": "Zen Voich ", 15 | "license": "ISC", 16 | "dependencies": { 17 | "@asciidoctor/core": "3.0.4", 18 | "@dfinity/agent": "1.0.1", 19 | "@dfinity/auth-client": "1.0.1", 20 | "@dfinity/principal": "1.0.1", 21 | "@types/throttle-debounce": "5.0.2", 22 | "@wooorm/starry-night": "3.2.0", 23 | "chart.js": "4.4.2", 24 | "chartjs-adapter-date-fns": "^3.0.0", 25 | "date-fns": "3.6.0", 26 | "events": "^3.3.0", 27 | "filesize": "10.1.1", 28 | "hast-util-to-html": "9.0.0", 29 | "ic-mops": "0.40.0", 30 | "js-untar": "^2.0.0", 31 | "markdown-it": "14.1.0", 32 | "pako": "^2.1.0", 33 | "svelte-chartjs": "3.1.5", 34 | "svelte-simple-modal": "1.6.2", 35 | "svelte-spa-history-router": "2.1.1", 36 | "throttle-debounce": "5.0.0" 37 | }, 38 | "devDependencies": { 39 | "@sveltejs/vite-plugin-svelte": "3.0.2", 40 | "@types/markdown-it": "13.0.7", 41 | "@types/node": "20.11.30", 42 | "@types/pako": "2.0.3", 43 | "buffer": "^6.0.3", 44 | "eslint-plugin-svelte": "2.35.1", 45 | "svelte": "4.2.12", 46 | "svelte-check": "3.6.8", 47 | "svelte-preprocess": "5.1.3", 48 | "typescript": "5.4.3", 49 | "vite": "5.2.6", 50 | "vite-plugin-static-copy": "1.0.2" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /frontend/svelte.config.cjs: -------------------------------------------------------------------------------- 1 | const sveltePreprocess = require('svelte-preprocess'); 2 | 3 | module.exports = { 4 | // Consult https://github.com/sveltejs/svelte-preprocess 5 | // for more information about preprocessors 6 | preprocess: sveltePreprocess(), 7 | onwarn: (warning, handler) => { 8 | if (warning.code.startsWith('a11y-')) { 9 | return; 10 | } 11 | handler(warning); 12 | }, 13 | }; -------------------------------------------------------------------------------- /frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2020", 4 | "module": "es2022", 5 | "lib": ["es2023", "dom"], 6 | "noImplicitAny": true, 7 | "alwaysStrict": true, 8 | // "noImplicitReturns": true, 9 | // "noUnusedLocals": true, 10 | // "noUnusedParameters": true, 11 | // "strictNullChecks": true, 12 | "allowUnreachableCode": false, 13 | "allowUnusedLabels": false, 14 | "sourceMap": true, 15 | // "isolatedModules": true, 16 | // "skipLibCheck": true, 17 | // "forceConsistentCasingInFileNames": true, 18 | "allowJs": true, 19 | // "checkJs": true, 20 | "skipLibCheck": true, 21 | "esModuleInterop": true, 22 | "resolveJsonModule": true, 23 | "moduleResolution": "node", 24 | "types": [ 25 | "node", 26 | "vite/client", 27 | ], 28 | "baseUrl": ".", 29 | "outDir": "dist", 30 | "paths": { 31 | "/logic/*": ["./logic/*"], 32 | "/declarations/*": ["./declarations/*"], 33 | }, 34 | }, 35 | // "include": [ 36 | // "**/*.d.ts", 37 | // "**/*.ts", 38 | // "**/*.js", 39 | // "**/*.svelte", 40 | // ], 41 | } -------------------------------------------------------------------------------- /frontend/types.d.ts: -------------------------------------------------------------------------------- 1 | declare global { 2 | interface Window { 3 | MOPS_NETWORK : string; 4 | } 5 | } 6 | 7 | export {}; -------------------------------------------------------------------------------- /mops.toml: -------------------------------------------------------------------------------- 1 | [dependencies] 2 | base = "0.12.1" 3 | time-consts = "1.0.1" 4 | map = "9.0.1" 5 | ic = "1.0.1" 6 | backup = "3.0.0" 7 | sha2 = "0.1.0" 8 | vector = "0.4.0" 9 | http-types = "1.0.1" 10 | datetime = "0.3.0" 11 | principal-ext = "0.1.0" 12 | 13 | [dev-dependencies] 14 | test = "2.0.0" 15 | fuzz = "0.2.1" 16 | bench = "1.0.0" 17 | 18 | [toolchain] 19 | moc = "0.12.1" 20 | wasmtime = "23.0.1" 21 | pocket-ic = "4.0.0" -------------------------------------------------------------------------------- /test/.alias/ccc0/README.md: -------------------------------------------------------------------------------- 1 | bbb -------------------------------------------------------------------------------- /test/.alias/ccc0/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = 'ccc' 3 | version = '0.1.0' 4 | description = 'ccc' 5 | keywords = [ "ccc" ] 6 | 7 | # [dependencies] 8 | # bbb = "../bbb" -------------------------------------------------------------------------------- /test/.alias/ccc0/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello1(name : Text) : Text { 3 | "Hello bbb, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.alias/ccc1/README.md: -------------------------------------------------------------------------------- 1 | bbb -------------------------------------------------------------------------------- /test/.alias/ccc1/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = 'ccc' 3 | version = '1.0.0' 4 | description = 'ccc' 5 | keywords = [ "ccc" ] 6 | 7 | # [dependencies] 8 | # bbb = "../bbb" -------------------------------------------------------------------------------- /test/.alias/ccc1/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello1(name : Text) : Text { 3 | "Hello bbb, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.alias/main/README.md: -------------------------------------------------------------------------------- 1 | # Hello lib 2 | 3 | [![mops](http://localhost:4943/badge/mops/hello?canisterId=2d2zu-vaaaa-aaaak-qb6pq-cai)](https://mops.one/hello) 4 | [![documentation](http://localhost:4943/badge/documentation/hello?canisterId=2d2zu-vaaaa-aaaak-qb6pq-cai)](https://mops.one/hello/docs) 5 | 6 | `hello` - example lib 7 | 8 | ### Usage 9 | ```motoko 10 | import {hello} "mo:hello"; 11 | 12 | func greet(): Text { 13 | hello("World"); 14 | }; 15 | ``` -------------------------------------------------------------------------------- /test/.alias/main/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "main" 3 | version = "1.0.0" 4 | description = "main lib" 5 | license = "Apache-2.0" 6 | keywords = [ "test", "map" ] 7 | 8 | [dependencies] 9 | ccc = "1.0.0" 10 | "ccc@0.1.0" = "0.1.0" 11 | 12 | [requirements] 13 | moc = "0.11.0" -------------------------------------------------------------------------------- /test/.alias/main/src/a.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.alias/main/src/a.mo -------------------------------------------------------------------------------- /test/.alias/main/src/a/a.mo: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/.alias/main/src/a/b.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.alias/main/src/a/b.mo -------------------------------------------------------------------------------- /test/.alias/main/src/a/lib.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name # "!"; 4 | }; 5 | 6 | public func hi(name : Text) : Text { 7 | "Hi, " # name # "!"; 8 | }; 9 | }; -------------------------------------------------------------------------------- /test/.alias/main/src/b/a.mo: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/.alias/main/src/b/b.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.alias/main/src/b/b.mo -------------------------------------------------------------------------------- /test/.alias/main/src/b/lib.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name # "!"; 4 | }; 5 | 6 | public func hi(name : Text) : Text { 7 | "Hi, " # name # "!"; 8 | }; 9 | }; -------------------------------------------------------------------------------- /test/.alias/main/src/lib.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name # "!"; 4 | }; 5 | 6 | public func hi(name : Text) : Text { 7 | "Hi, " # name # "!"; 8 | }; 9 | }; -------------------------------------------------------------------------------- /test/.alias/main/test/lib.test.mo: -------------------------------------------------------------------------------- 1 | import {hello1} "mo:ccc"; 2 | import {hello} "mo:ccc@0.1.0"; 3 | import Prim "mo:⛔"; 4 | 5 | Prim.debugPrint(debug_show(hello1("World"))); 6 | Prim.debugPrint(debug_show(hello("Old World"))); -------------------------------------------------------------------------------- /test/.alias/main/test/suite.test.mo: -------------------------------------------------------------------------------- 1 | import {hello} "../src"; 2 | import {test; suite} "./test"; 3 | 4 | suite("Hello", func() { 5 | test("should say hello to the World", func() { 6 | assert hello("World") == "Hello, World!"; 7 | }); 8 | 9 | test("should say hello to Motoko", func() { 10 | assert hello("Motoko") == "Hello, Motoko!"; 11 | }); 12 | }); -------------------------------------------------------------------------------- /test/.alias/main/test/test.mo: -------------------------------------------------------------------------------- 1 | import Prim "mo:prim"; 2 | 3 | module { 4 | public func test(name: Text, fn: () -> ()) { 5 | Prim.debugPrint("mops:1:start " # name); 6 | fn(); 7 | Prim.debugPrint("mops:1:end " # name); 8 | }; 9 | 10 | public func suite(name: Text, fn: () -> ()) { 11 | test(name, fn); 12 | }; 13 | 14 | public func skip(name: Text, fn: () -> ()) { 15 | Prim.debugPrint("mops:1:skip " # name); 16 | }; 17 | }; -------------------------------------------------------------------------------- /test/.deep/aa/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.deep/aa/README.md -------------------------------------------------------------------------------- /test/.deep/aa/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aa" 3 | version = "0.1.2" 4 | description = "aa" 5 | files = [ "test.mo" ] 6 | 7 | [dependencies] 8 | hello = "1.0.2" -------------------------------------------------------------------------------- /test/.deep/aa/src/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.deep/bb/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.deep/bb/README.md -------------------------------------------------------------------------------- /test/.deep/bb/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = 'bb' 3 | version = '0.1.0' 4 | description = 'bb' 5 | repository = 'repo' 6 | files = ['test.mo'] 7 | 8 | [dependencies] 9 | aa = "0.1.0" -------------------------------------------------------------------------------- /test/.deep/bb/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.deep/cc/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.deep/cc/README.md -------------------------------------------------------------------------------- /test/.deep/cc/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = 'cc' 3 | version = '0.1.0' 4 | description = 'cc' 5 | repository = 'repo' 6 | files = ['test.mo'] 7 | 8 | [dependencies] 9 | bb = "0.1.0" -------------------------------------------------------------------------------- /test/.deep/cc/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.deep/dd/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.deep/dd/README.md -------------------------------------------------------------------------------- /test/.deep/dd/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = 'dd' 3 | version = '0.1.0' 4 | description = 'dd' 5 | repository = 'repo' 6 | files = ['test.mo'] 7 | 8 | [dependencies] 9 | cc = "0.1.0" -------------------------------------------------------------------------------- /test/.deep/dd/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.deep/ee/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.deep/ee/README.md -------------------------------------------------------------------------------- /test/.deep/ee/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = 'ee' 3 | version = '0.1.0' 4 | description = 'ee' 5 | repository = 'repo' 6 | files = ['test.mo'] 7 | 8 | [dependencies] 9 | dd = "0.1.0" -------------------------------------------------------------------------------- /test/.deep/ee/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.deep/ff/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.deep/ff/README.md -------------------------------------------------------------------------------- /test/.deep/ff/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = 'ff' 3 | version = '0.1.0' 4 | description = 'ff' 5 | repository = 'repo' 6 | files = ['test.mo'] 7 | 8 | [dependencies] 9 | ee = "0.1.0" -------------------------------------------------------------------------------- /test/.deep/ff/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.deep/gg/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.deep/gg/README.md -------------------------------------------------------------------------------- /test/.deep/gg/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gg" 3 | version = "0.1.1" 4 | description = "gg" 5 | repository = "repo" 6 | files = [ "test.mo" ] 7 | 8 | [dependencies] 9 | dd = "0.1.0" 10 | ff = "0.1.0" 11 | fuzz = "https://github.com/ZenVoich/fuzz#master" 12 | 13 | [dev-dependencies] 14 | ee = "0.1.0" -------------------------------------------------------------------------------- /test/.deep/gg/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.deep/mops.toml: -------------------------------------------------------------------------------- 1 | [dependencies] 2 | gg = "0.1.0" 3 | bb = "0.1.0" 4 | aa = "0.1.0" -------------------------------------------------------------------------------- /test/.deep/pub: -------------------------------------------------------------------------------- 1 | cd aa && mops-local publish && cd .. 2 | cd bb && mops-local publish && cd .. 3 | cd cc && mops-local publish && cd .. 4 | cd dd && mops-local publish && cd .. 5 | cd ee && mops-local publish && cd .. 6 | cd ff && mops-local publish && cd .. 7 | cd gg && mops-local publish && cd .. -------------------------------------------------------------------------------- /test/.flat/aaa/README.md: -------------------------------------------------------------------------------- 1 | # Hello lib 2 | 3 | `hello` - example lib 4 | 5 | ### Usage 6 | ```motoko 7 | import {hello} "mo:hello"; 8 | 9 | func greet(): Text { 10 | hello("World"); 11 | }; 12 | ``` -------------------------------------------------------------------------------- /test/.flat/aaa/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aaa" 3 | version = "0.1.0" 4 | description = "asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd " 5 | keywords = [ "test", "cli", "data" ] 6 | files = [ "test.mo" ] -------------------------------------------------------------------------------- /test/.flat/aaa/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, aaa " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/bbb/README.md: -------------------------------------------------------------------------------- 1 | bb -------------------------------------------------------------------------------- /test/.flat/bbb/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bbb" 3 | version = "0.1.0" 4 | description = "bbb" 5 | repository = "repo bbb" 6 | keywords = [ "test", "cli", "pkg" ] 7 | files = [ "test.mo" ] 8 | 9 | [dependencies] 10 | aaa = "0.1.0" -------------------------------------------------------------------------------- /test/.flat/bbb/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ccc/README.md: -------------------------------------------------------------------------------- 1 | bbb -------------------------------------------------------------------------------- /test/.flat/ccc/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = 'ccc' 3 | version = '0.1.0' 4 | description = 'ccc' 5 | repository = 'repo bbb' 6 | keywords = [ "ccc" ] 7 | files = ['test.mo'] 8 | 9 | [dependencies] 10 | bbb = "../bbb" -------------------------------------------------------------------------------- /test/.flat/ccc/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello bbb, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/README.md: -------------------------------------------------------------------------------- 1 | ddd -------------------------------------------------------------------------------- /test/.flat/ddd/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ddd" 3 | version = "0.1.0" 4 | description = "ddd" 5 | repository = "repo ddd" 6 | keywords = [ "http", "test" ] 7 | 8 | [dependencies] 9 | aaa = "0.1.0" 10 | 11 | [dev-dependencies] 12 | ccc = "0.1.0" -------------------------------------------------------------------------------- /test/.flat/ddd/test copy 10.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/test copy 11.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/test copy 12.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/test copy 13.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/test copy 2.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello ddd, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/test copy 3.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/test copy 4.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/test copy 5.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/test copy 6.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/test copy 7.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/test copy 8.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/test copy 9.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/test copy.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ddd/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/eee/README.md: -------------------------------------------------------------------------------- 1 | eee -------------------------------------------------------------------------------- /test/.flat/eee/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = 'eee' 3 | version = '0.1.0' 4 | description = 'eee' 5 | repository = 'repo eeee' 6 | keywords = [ "test" ] 7 | files = ['test.mo'] -------------------------------------------------------------------------------- /test/.flat/eee/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, eee " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/fff/README.md: -------------------------------------------------------------------------------- 1 | fff -------------------------------------------------------------------------------- /test/.flat/fff/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = 'fff' 3 | version = '0.1.0' 4 | description = 'fff' 5 | repository = 'repo fff' 6 | keywords = [ "fff" ] 7 | files = ['test.mo'] 8 | 9 | [dependencies] 10 | ddd = "0.1.0" -------------------------------------------------------------------------------- /test/.flat/fff/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, fff " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/ggg/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.flat/ggg/README.md -------------------------------------------------------------------------------- /test/.flat/ggg/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = 'ggg' 3 | version = '0.1.0' 4 | description = 'ggg' 5 | repository = 'repo' 6 | files = ['test.mo'] -------------------------------------------------------------------------------- /test/.flat/ggg/test.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name; 4 | }; 5 | }; -------------------------------------------------------------------------------- /test/.flat/mops.toml: -------------------------------------------------------------------------------- 1 | [dependencies] 2 | aaa = "0.1.0" 3 | bbb = "0.1.0" 4 | ccc = "0.1.0" 5 | ddd = "0.1.0" 6 | eee = "0.1.0" 7 | fff = "0.1.0" 8 | ggg = "0.1.0" -------------------------------------------------------------------------------- /test/.flat/pub: -------------------------------------------------------------------------------- 1 | cd aaa && mops-local publish && cd .. 2 | cd bbb && mops-local publish && cd .. 3 | cd ccc && mops-local publish && cd .. 4 | cd ddd && mops-local publish && cd .. 5 | cd eee && mops-local publish && cd .. 6 | cd fff && mops-local publish && cd .. 7 | cd ggg && mops-local publish && cd .. -------------------------------------------------------------------------------- /test/.hello/README.md: -------------------------------------------------------------------------------- 1 | # Hello lib 2 | 3 | [![mops](http://localhost:4943/badge/mops/hello?canisterId=2d2zu-vaaaa-aaaak-qb6pq-cai)](https://mops.one/hello) 4 | [![documentation](http://localhost:4943/badge/documentation/hello?canisterId=2d2zu-vaaaa-aaaak-qb6pq-cai)](https://mops.one/hello/docs) 5 | 6 | `hello` - example lib 7 | 8 | ### Usage 9 | ```motoko 10 | import {hello} "mo:hello"; 11 | 12 | func greet(): Text { 13 | hello("World"); 14 | }; 15 | ``` -------------------------------------------------------------------------------- /test/.hello/mops.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "1.0.3" 4 | description = "hello lib" 5 | # repository = "https://github.com/ZenVoich/hello" 6 | license = "Apache-2.0" 7 | keywords = [ "test", "map" ] 8 | 9 | [dependencies] 10 | base = "0.10.3" 11 | # base = "https://github.com/dfinity/motoko-base#moc-0.10.1@80ededb39954739b18b88fc0e5561264003cf9ab" 12 | # ccc = "../.flat/ccc" 13 | 14 | [requirements] 15 | moc = "0.11.0" -------------------------------------------------------------------------------- /test/.hello/src/a.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.hello/src/a.mo -------------------------------------------------------------------------------- /test/.hello/src/a/a.mo: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/.hello/src/a/b.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.hello/src/a/b.mo -------------------------------------------------------------------------------- /test/.hello/src/a/lib.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name # "!"; 4 | }; 5 | 6 | public func hi(name : Text) : Text { 7 | "Hi, " # name # "!"; 8 | }; 9 | }; -------------------------------------------------------------------------------- /test/.hello/src/b/a.mo: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/.hello/src/b/b.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZenVoich/mops/03e947110c8bbfba4b38b2a2cf9004330e66b8a4/test/.hello/src/b/b.mo -------------------------------------------------------------------------------- /test/.hello/src/b/lib.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name # "!"; 4 | }; 5 | 6 | public func hi(name : Text) : Text { 7 | "Hi, " # name # "!"; 8 | }; 9 | }; -------------------------------------------------------------------------------- /test/.hello/src/lib.mo: -------------------------------------------------------------------------------- 1 | module { 2 | public func hello(name : Text) : Text { 3 | "Hello, " # name # "!"; 4 | }; 5 | 6 | public func hi(name : Text) : Text { 7 | "Hi, " # name # "!"; 8 | }; 9 | }; -------------------------------------------------------------------------------- /test/.hello/test/lib.test.mo: -------------------------------------------------------------------------------- 1 | import {hello} "../src"; 2 | 3 | assert hello("World") == "Hello, World!"; 4 | assert hello("Motoko") == "Hello, Motoko!"; -------------------------------------------------------------------------------- /test/.hello/test/suite.test.mo: -------------------------------------------------------------------------------- 1 | import {hello} "../src"; 2 | import {test; suite} "./test"; 3 | 4 | suite("Hello", func() { 5 | test("should say hello to the World", func() { 6 | assert hello("World") == "Hello, World!"; 7 | }); 8 | 9 | test("should say hello to Motoko", func() { 10 | assert hello("Motoko") == "Hello, Motoko!"; 11 | }); 12 | }); -------------------------------------------------------------------------------- /test/.hello/test/test.mo: -------------------------------------------------------------------------------- 1 | import Prim "mo:prim"; 2 | 3 | module { 4 | public func test(name: Text, fn: () -> ()) { 5 | Prim.debugPrint("mops:1:start " # name); 6 | fn(); 7 | Prim.debugPrint("mops:1:end " # name); 8 | }; 9 | 10 | public func suite(name: Text, fn: () -> ()) { 11 | test(name, fn); 12 | }; 13 | 14 | public func skip(name: Text, fn: () -> ()) { 15 | Prim.debugPrint("mops:1:skip " # name); 16 | }; 17 | }; -------------------------------------------------------------------------------- /test/.staging-alias/mops.toml: -------------------------------------------------------------------------------- 1 | [dependencies] 2 | # base = "0.11.1" 3 | aa = "0.1.1" 4 | hello = "1.0.2" -------------------------------------------------------------------------------- /test/.staging-alias/test/simple.test.mo: -------------------------------------------------------------------------------- 1 | import Nat "mo:base/Nat"; 2 | import Nat2 "mo:base@0.10.2/Nat"; 3 | 4 | assert Nat.toText(1) == "1"; 5 | assert Nat2.toText(1) == "1"; -------------------------------------------------------------------------------- /test/.staging-conflict/mops.toml: -------------------------------------------------------------------------------- 1 | [dependencies] 2 | aa = "0.1.2" 3 | hello = "0.1.15" -------------------------------------------------------------------------------- /test/.staging-conflict/test/simple.test.mo: -------------------------------------------------------------------------------- 1 | import Nat "mo:base/Nat"; 2 | import Nat2 "mo:base@0.10.2/Nat"; 3 | 4 | assert Nat.toText(1) == "1"; 5 | assert Nat2.toText(1) == "1"; -------------------------------------------------------------------------------- /test/datetime.test.mo: -------------------------------------------------------------------------------- 1 | import DateComponents "mo:datetime/Components"; 2 | import Debug "mo:base/Debug"; 3 | import Iter "mo:base/Iter"; 4 | import {test} "mo:test"; 5 | 6 | test("dayOfWeek", func() { 7 | for (i in Iter.range(1, 30)) { 8 | let components = { 9 | year = 2_023; 10 | month = 11; 11 | day = i; 12 | hour = 0; 13 | minute = 0; 14 | nanosecond = 0; 15 | }; 16 | Debug.print(debug_show(i) # " - " # debug_show(DateComponents.dayOfWeek(components))); 17 | }; 18 | }); -------------------------------------------------------------------------------- /test/hello.test.mo: -------------------------------------------------------------------------------- 1 | import Debug "mo:base/Debug"; 2 | import {test} "mo:test"; 3 | 4 | test("succ", func() { 5 | assert true; 6 | }); -------------------------------------------------------------------------------- /test/is-letter.test.mo: -------------------------------------------------------------------------------- 1 | import {test; suite; skip} "mo:test"; 2 | 3 | import {isLetter; isLowerCaseLetter; isUpperCaseLetter} "../backend/main/utils/is-letter"; 4 | 5 | test("isLetter", func() { 6 | assert isLetter('a'); 7 | assert isLetter('b'); 8 | assert isLetter('z'); 9 | assert isLetter('y'); 10 | assert not isLetter('2'); 11 | assert not isLetter('0'); 12 | assert not isLetter('1'); 13 | assert not isLetter('-'); 14 | assert not isLetter('&'); 15 | }); 16 | 17 | test("isLowerCaseLetter", func() { 18 | assert isLowerCaseLetter('a'); 19 | assert isLowerCaseLetter('b'); 20 | assert isLowerCaseLetter('z'); 21 | assert isLowerCaseLetter('y'); 22 | assert not isLowerCaseLetter('A'); 23 | assert not isLowerCaseLetter('G'); 24 | assert not isLowerCaseLetter('1'); 25 | assert not isLowerCaseLetter('-'); 26 | assert not isLowerCaseLetter('&'); 27 | }); 28 | 29 | test("isUpperCaseLetter", func() { 30 | assert isUpperCaseLetter('A'); 31 | assert isUpperCaseLetter('B'); 32 | assert isUpperCaseLetter('Z'); 33 | assert isUpperCaseLetter('Y'); 34 | assert not isUpperCaseLetter('g'); 35 | assert not isUpperCaseLetter('d'); 36 | assert not isUpperCaseLetter('1'); 37 | assert not isUpperCaseLetter('-'); 38 | assert not isUpperCaseLetter('&'); 39 | }); -------------------------------------------------------------------------------- /test/is-type.test.mo: -------------------------------------------------------------------------------- 1 | // @testmode wasi 2 | 3 | import Debug "mo:base/Debug"; 4 | import {test} "mo:test"; 5 | 6 | func to(x : Any) : Blob { 7 | to_candid(x); 8 | }; 9 | 10 | // func isType(value : Any) : Bool { 11 | // let candid = to_candid(value); 12 | // let from = from_candid(candid) : ?T; 13 | // switch (from) { 14 | // case (?x) true; 15 | // case (null) false; 16 | // }; 17 | // }; 18 | 19 | func isNat(candid : Blob) : Bool { 20 | let parsed = from_candid(candid) : ?Nat; 21 | parsed != null; 22 | }; 23 | 24 | Debug.print(debug_show(isNat(to_candid(123)))); 25 | Debug.print(debug_show(isNat(to_candid("123")))); 26 | 27 | test("suaaacc", func() { 28 | let x = to(1); 29 | assert true; 30 | }); -------------------------------------------------------------------------------- /test/main-canister.test.mo: -------------------------------------------------------------------------------- 1 | import Main "../backend/main/main-canister"; -------------------------------------------------------------------------------- /test/simple.test.mo: -------------------------------------------------------------------------------- 1 | 2 | 3 | assert 1 == 1; -------------------------------------------------------------------------------- /test/validate-license.test.mo: -------------------------------------------------------------------------------- 1 | import Result "mo:base/Result"; 2 | import {test; suite; skip} "mo:test"; 3 | 4 | import {validateLicense} "../backend/main/utils/validateLicense"; 5 | 6 | test("check valid licenses", func() { 7 | assert Result.isOk(validateLicense("Apache-2.0")); 8 | assert Result.isOk(validateLicense("Zend-2.0")); 9 | assert Result.isOk(validateLicense("Ruby")); 10 | assert Result.isOk(validateLicense("GPL-1.0-only")); 11 | assert Result.isOk(validateLicense("CC-BY-NC-ND-2.5")); 12 | }); 13 | 14 | test("lowercased valid licenses should return #err", func() { 15 | assert Result.isErr(validateLicense("apache-2.0")); 16 | assert Result.isErr(validateLicense("zend-2.0")); 17 | assert Result.isErr(validateLicense("ruby")); 18 | assert Result.isErr(validateLicense("gpl-1.0-only")); 19 | assert Result.isErr(validateLicense("cc-by-nc-nd-2.5")); 20 | }); 21 | 22 | test("valid licenses with spaces should return #err", func() { 23 | assert Result.isErr(validateLicense(" Apache-2.0")); 24 | assert Result.isErr(validateLicense(" Zend-2.0")); 25 | assert Result.isErr(validateLicense("Ruby ")); 26 | assert Result.isErr(validateLicense(" GPL-1.0-only ")); 27 | assert Result.isErr(validateLicense(" CC-BY-NC-ND-2.5 ")); 28 | }); 29 | 30 | test("wrong license ids", func() { 31 | assert Result.isErr(validateLicense("Apache 2.0")); 32 | assert Result.isErr(validateLicense("MIT License")); 33 | assert Result.isErr(validateLicense("custom sda")); 34 | assert Result.isErr(validateLicense("Creative Commons")); 35 | }); -------------------------------------------------------------------------------- /ui-kit/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true 4 | }, 5 | "rules": { 6 | "no-irregular-whitespace": "off" 7 | }, 8 | "overrides": [ 9 | { 10 | "files": ["*.svelte"], 11 | "parser": "svelte-eslint-parser", 12 | // Parse the `