From ffc5df4514066f81cac8aedcaddc97133ea35c86 Mon Sep 17 00:00:00 2001 From: hasundue Date: Sat, 21 Oct 2023 15:40:15 +0900 Subject: [PATCH] refactor(git)!: mv git/mod.ts to src/git.ts and create git.ts Because this seems more consistent with the rest of the project. --- README.md | 5 ++--- cli.ts | 4 ++-- git.ts | 26 +++++++++++++++++++++++ git/mod.ts => src/git.ts | 33 ++++-------------------------- git/mod_test.ts => src/git_test.ts | 4 ++-- 5 files changed, 36 insertions(+), 36 deletions(-) create mode 100644 git.ts rename git/mod.ts => src/git.ts (78%) rename git/mod_test.ts => src/git_test.ts (97%) diff --git a/README.md b/README.md index ec831e7c..8429d506 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,7 @@ registry. #### API Reference (WIP) - [mod.ts](https://deno.land/x/molt/mod.ts) - Main module -- [git/mod.ts](https://deno.land/x/molt/git/mod.ts) - Sub-module for Git - operations +- [git.ts](https://deno.land/x/molt/git/mod.ts) - Sub-module for Git operations - [lib/uri.ts](https://deno.land/x/molt/lib/uri.ts) - Library for handling URIs #### Examples @@ -50,7 +49,7 @@ FileUpdate.writeAll(results); ```ts import { DependencyUpdate } from "https://deno.land/x/molt@{VERSION}/mod.ts"; -import { commitAll } from "https://deno.land/x/molt@{VERSION}/git/mod.ts"; +import { commitAll } from "https://deno.land/x/molt@{VERSION}/git.ts"; const updates = await DependencyUpdate.collect("./mod.ts"); diff --git a/cli.ts b/cli.ts index e1858f34..a0a25215 100644 --- a/cli.ts +++ b/cli.ts @@ -1,11 +1,11 @@ import { existsSync } from "./lib/std/fs.ts"; import { distinct } from "./lib/std/collections.ts"; import { parse as parseJsonc } from "./lib/std/jsonc.ts"; +import { dirname, extname, join } from "./lib/std/path.ts"; import { colors, Command, List, Select } from "./lib/x/cliffy.ts"; import { URI } from "./lib/uri.ts"; import { DependencyUpdate, FileUpdate } from "./mod.ts"; -import { commitAll } from "./git/mod.ts"; -import { dirname, extname, join } from "./lib/std/path.ts"; +import { commitAll } from "./git.ts"; const { gray, yellow, bold } = colors; diff --git a/git.ts b/git.ts new file mode 100644 index 00000000..e1f21cf9 --- /dev/null +++ b/git.ts @@ -0,0 +1,26 @@ +// Copyright 2023 Chiezo (Shun Ueda). All rights reserved. MIT license. + +/** + * A sub module of molt for git operations. + * + * ### Example + * + * To update all dependencies in a module and commit the changes to git: + * + * ```ts + * import { DependencyUpdate } from "https://deno.land/x/molt@{VERSION}/mod.ts"; + * import { commitAll } from "https://deno.land/x/molt@{VERSION}/git.ts"; + * + * const updates = await DependencyUpdate.collect("./mod.ts"); + * + * commitAll(updates, { + * groupBy: (dependency) => dependency.name, + * composeCommitMessage: ({ group, version }) => + * `build(deps): bump ${group} to ${version!.to}`, + * }); + * ``` + * + * @module + */ + +export * from "./src/git.ts"; diff --git a/git/mod.ts b/src/git.ts similarity index 78% rename from git/mod.ts rename to src/git.ts index 1aafecd6..8cb69831 100644 --- a/git/mod.ts +++ b/src/git.ts @@ -1,31 +1,6 @@ -// Copyright 2023 Chiezo (Shun Ueda). All rights reserved. MIT license. - -/** - * A sub module of molt for git operations. - * - * ### Example - * - * To update all dependencies in a module and commit the changes to git: - * - * ```ts - * import { DependencyUpdate } from "https://deno.land/x/molt@{VERSION}/mod.ts"; - * import { commitAll } from "https://deno.land/x/molt@{VERSION}/git/mod.ts"; - * - * const updates = await DependencyUpdate.collect("./mod.ts"); - * - * commitAll(updates, { - * groupBy: (dependency) => dependency.name, - * composeCommitMessage: ({ group, version }) => - * `build(deps): bump ${group} to ${version!.to}`, - * }); - * ``` - * - * @module - */ - -import { DependencyUpdate } from "../src/update.ts"; -import { FileUpdate } from "../src/file.ts"; -import { createVersionProp, type VersionProp } from "../src/versions.ts"; +import { DependencyUpdate } from "./update.ts"; +import { FileUpdate } from "./file.ts"; +import { createVersionProp, type VersionProp } from "./versions.ts"; import { URI } from "../lib/uri.ts"; export interface CommitProps { @@ -43,7 +18,7 @@ export interface CommitOptions { gitCommitOptions?: string[]; } -export const defaultCommitOptions = { +const defaultCommitOptions = { groupBy: () => "dependencies", composeCommitMessage: ({ group, version }) => { let message = `build(deps): update ${group}`; diff --git a/git/mod_test.ts b/src/git_test.ts similarity index 97% rename from git/mod_test.ts rename to src/git_test.ts index 75985e1a..74cae21f 100644 --- a/git/mod_test.ts +++ b/src/git_test.ts @@ -12,8 +12,8 @@ import { } from "../lib/std/testing.ts"; import { assertArrayIncludes, assertEquals } from "../lib/std/assert.ts"; import { URI } from "../lib/uri.ts"; -import { DependencyUpdate } from "../mod.ts"; -import { commitAll } from "./mod.ts"; +import { DependencyUpdate } from "./update.ts"; +import { commitAll } from "./git.ts"; const DenoCommandOriginal = Deno.Command; const readTextFileSyncOriginal = Deno.readTextFileSync;