🦕 Molt

CI codecov

[!WARNING]
Molt is still being developed actively. The API is not stable yet and may change frequently.

Molt is a Deno module to bump versions in import specifiers, like udd, but with some unique concepts:

The Deno way - Molt finds dependencies and checks their latest versions in the same way as the Deno runtime does.

Module-first - The core logic is provided as a Deno module, which enables you to write the best scripts for your use cases.

Git-friendly - The operations can be easily divided into logical groups for subsequent git commits.

Usage

Deno Module

API Reference

Examples

Update all dependencies in a module and write the changes to local files
import { collect, writeAll } from "https://deno.land/x/molt@{VERSION}/mod.ts";

const updates = await collect("./mod.ts");
await writeAll(updates);
Update all dependencies in a module and commit the changes to git
import { collect, commitAll } from "https://deno.land/x/molt@{VERSION}/mod.ts";

const updates = await collect("./mod.ts");

await commitAll(updates, {
  groupBy: (dependency) => dependency.name,
  composeCommitMessage: ({ group, version }) =>
    `build(deps): bump ${group} to ${version!.to}`,
});

CLI

Although it is encouraged to write your own scripts, a pre-built CLI tool is also provided as cli.ts for convenience or a reference implementation, which is supposed to cover most of the use cases.

Installation (optional)

The molt CLI can be installed globally with the following command, for example:

deno install --allow-env --allow-read --allow-write --allow-net --allow-run=git,deno\
--name molt https://deno.land/x/molt@{VERSION}/cli.ts

Alternatively, you may prefer to run the remote script directly through deno task for better security or reproducibility:

{
  "tasks": {
    "update": "deno run --allow-env --allow-read --allow-write=. --allow-run=git,deno --allow-net=deno.land https://deno.land/x/molt@{VERSION}/cli.ts ./**/*.ts",
    "update:commit": "deno task -q update --commit --pre-commit=fmt"
  }
}

Usage

> molt --help
Usage: molt <modules...>

Description:

  Check updates to dependencies in Deno modules and configuration files

Options:

  -h, --help               - Show this help.                                              
  -v, --version            - Print version info.                                          
  --import-map   <file>    - Specify import map file                                      
  --ignore       <deps>    - Ignore dependencies                                          
  --only         <deps>    - Check specified dependencies                                 
  -w, --write              - Write changes to local files            (Conflicts: --commit)
  -c, --commit             - Commit changes to local git repository  (Conflicts: --write) 
  --pre-commit   <tasks>   - Run tasks before each commit            (Depends: --commit)  
  --post-commit  <tasks>   - Run tasks after each commit             (Depends: --commit)  
  --prefix       <prefix>  - Prefix for commit messages              (Depends: --commit)  
  --summary      <file>    - Write a summary of changes to file                           
  --report       <file>    - Write a report of changes to file                            

Examples:

  Check import maps in a config: molt deno.json                             
  Check imports in a module:     molt deps.ts                               
  Include multiple modules:      molt mod.ts lib.ts                         
  Target all .ts files:          molt ./**/*.ts                             
  Specify an import map:         molt mod.ts --import-map deno.json         
  Ignore specified dependencies: molt deps.ts --ignore=deno_graph,node_emoji
  Check deno_std only:           molt deps.ts --only deno.land/std

[!Note]
Molt CLI automatically finds deno.json or deno.jsonc in the current working directory or its parent directories and uses import maps defined in the file if available.

Examples

Check for updates
> molt deno.json
📦 @luca/flag 1.0.0 => 123.456.789
📦 deno.land/std 0.200.0 => 123.456.789
📦 deno.land/x/deno_graph 0.50.0 => 123.456.789
📦 node-emoji 1.0.0 => 123.456.789
Write changes to files
> molt deno.json --write
    ...
💾 deno.json
Commit changes to git
> molt deno.json --commit --prefix :package:
    ...
📝 :package: bump @luca/flag from 1.0.0 to 123.456.789
📝 :package: bump deno.land/std from 0.200.0 to 123.456.789
📝 :package: bump deno.land/x/deno_graph from 0.50.0 to 123.456.789
📝 :package: bump node-emoji from 2.0.0 to 123.456.789

Compatibility with registries

We check compatibility with various registries in an integration test.

Deno's official registries

Molt offers first-class support for the following registries, which means that we may implement registry-specific routines for them:

[!NOTE]
Version constraints like ~1.2.3 and ^1.2.3 in npm: and jrs: specifiers are not updated.

Third-party registries

Molt also works with the following third-party registries:

The following registries are not compatible with Molt:

How it works

TBW

Limitations

The following limitations are imposed by the design of Molt:

  • Dependencies are always updated to the latest versions. Version constraints are not handled.
  • Dependencies in import specifiers are only targeted.

See issues for other known limitations.

References

Molt is inspired by prior works such as

and of full respect to the authors.