Skip to content

Commit

Permalink
refactor: move src/* to lib/
Browse files Browse the repository at this point in the history
  • Loading branch information
hasundue committed Oct 21, 2023
1 parent 3a59893 commit a3bf60e
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 56 deletions.
5 changes: 3 additions & 2 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ 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.ts";
import { DependencyUpdate } from "./lib/update.ts";
import { FileUpdate } from "./lib/file.ts";
import { commitAll } from "./lib/git.ts";

const { gray, yellow, bold } = colors;

Expand Down
2 changes: 1 addition & 1 deletion git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
* @module
*/

export * from "./src/git.ts";
export * from "./lib/git.ts";
7 changes: 3 additions & 4 deletions src/dependency.ts → lib/dependency.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Maybe } from "../lib/types.ts";
import { Mutex } from "../lib/x/async.ts";
import type { Path, SemVerString } from "./types.ts";
import { assertExists } from "./std/assert.ts";
import { Mutex } from "./x/async.ts";
import type { Maybe, Path, SemVerString } from "./types.ts";
import { parseSemVer } from "./semver.ts";
import { assertExists } from "../lib/std/assert.ts";

export interface Dependency {
name: string;
Expand Down
4 changes: 2 additions & 2 deletions src/dependency_test.ts → lib/dependency_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it } from "../lib/std/testing.ts";
import { assertEquals } from "../lib/std/assert.ts";
import { describe, it } from "./std/testing.ts";
import { assertEquals } from "./std/assert.ts";
import { Dependency } from "./dependency.ts";

describe("parseProps()", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/file.ts → lib/file.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DependencyUpdate } from "./update.ts";
import { URI } from "../lib/uri.ts";
import { URI } from "./uri.ts";

export interface FileUpdate {
/** The specifier of the updated dependency (a remote module.) */
Expand Down
6 changes: 3 additions & 3 deletions src/file_test.ts → lib/file_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import {
it,
type Stub,
stub,
} from "../lib/std/testing.ts";
} from "./std/testing.ts";
import {
assertArrayIncludes,
assertEquals,
assertExists,
} from "../lib/std/assert.ts";
} from "./std/assert.ts";
import { DependencyUpdate } from "./update.ts";
import { FileUpdate } from "./file.ts";
import { URI } from "../lib/uri.ts";
import { URI } from "./uri.ts";

describe("collect", () => {
it("direct import", async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/git.ts → lib/git.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DependencyUpdate } from "./update.ts";
import { FileUpdate } from "./file.ts";
import { createVersionProp, type VersionProp } from "./versions.ts";
import { URI } from "../lib/uri.ts";
import { URI } from "./uri.ts";

export interface CommitProps {
/** The name of the module group */
Expand Down
7 changes: 3 additions & 4 deletions src/git_test.ts → lib/git_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// deno-lint-ignore-file no-explicit-any

import {
afterAll,
afterEach,
Expand All @@ -9,9 +8,9 @@ import {
it,
type Stub,
stub,
} from "../lib/std/testing.ts";
import { assertArrayIncludes, assertEquals } from "../lib/std/assert.ts";
import { URI } from "../lib/uri.ts";
} from "./std/testing.ts";
import { assertArrayIncludes, assertEquals } from "./std/assert.ts";
import { URI } from "./uri.ts";
import { DependencyUpdate } from "./update.ts";
import { commitAll } from "./git.ts";

Expand Down
12 changes: 6 additions & 6 deletions src/import_map.ts → lib/import_map.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { maxBy } from "../lib/std/collections.ts";
import { parse as parseJsonc } from "../lib/std/jsonc.ts";
import { type ImportMapJson, parseFromJson } from "../lib/x/import_map.ts";
import { is } from "../lib/x/unknownutil.ts";
import type { Maybe } from "../lib/types.ts";
import { URI } from "../lib/uri.ts";
import { maxBy } from "./std/collections.ts";
import { parse as parseJsonc } from "./std/jsonc.ts";
import { type ImportMapJson, parseFromJson } from "./x/import_map.ts";
import { is } from "./x/unknownutil.ts";
import type { Maybe } from "./types.ts";
import { URI } from "./uri.ts";
import { URIScheme } from "./types.ts";

export type { ImportMapJson };
Expand Down
6 changes: 3 additions & 3 deletions src/import_map_test.ts → lib/import_map_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { beforeAll, describe, it } from "../lib/std/testing.ts";
import { assertEquals, assertExists } from "../lib/std/assert.ts";
import { URI } from "../lib/uri.ts";
import { beforeAll, describe, it } from "./std/testing.ts";
import { assertEquals, assertExists } from "./std/assert.ts";
import { URI } from "./uri.ts";
import { ImportMap } from "./import_map.ts";

describe("readFromJson()", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/loader.ts → lib/loader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
type CreateGraphOptions,
load as defaultLoad,
} from "../lib/x/deno_graph.ts";
} from "./x/deno_graph.ts";

export const load: NonNullable<CreateGraphOptions["load"]> = async (
specifier,
Expand Down
3 changes: 1 addition & 2 deletions src/semver.ts → lib/semver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Maybe } from "../lib/types.ts";
import type { SemVerString } from "./types.ts";
import type { Maybe, SemVerString } from "./types.ts";

// Ref: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
const SEMVER_REGEXP =
Expand Down
4 changes: 2 additions & 2 deletions src/semver_test.ts → lib/semver_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it } from "../lib/std/testing.ts";
import { assertEquals } from "../lib/std/assert.ts";
import { describe, it } from "./std/testing.ts";
import { assertEquals } from "./std/assert.ts";
import { parseSemVer } from "./semver.ts";

describe("parseSemVer", () => {
Expand Down
12 changes: 12 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
export type Maybe<T> = T | undefined;
export type Brand<T, B> = T & { __brand: B };

/** A string that represents a path segment (e.g. `src/lib.ts`.) */
export type Path = Brand<string, "Path">;

/** A string that represents a semver (e.g. `v1.0.0`.) */
export type SemVerString = Brand<string, "SemVerString">;

const URI_SCHEMES = ["http", "https", "file", "npm", "node"] as const;
export type URIScheme = typeof URI_SCHEMES[number];
export const URIScheme = {
values: URI_SCHEMES,
};
4 changes: 2 additions & 2 deletions src/update.ts → lib/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
createGraph,
init as initDenoGraph,
type ModuleJson,
} from "../lib/x/deno_graph.ts";
import { RelativePath, URI } from "../lib/uri.ts";
} from "./x/deno_graph.ts";
import { RelativePath, URI } from "./uri.ts";
import type { SemVerString } from "./types.ts";
import { ImportMap, ImportMapJson } from "./import_map.ts";
import { Dependency } from "./dependency.ts";
Expand Down
6 changes: 3 additions & 3 deletions src/update_test.ts → lib/update_test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { beforeAll, describe, it } from "../lib/std/testing.ts";
import { beforeAll, describe, it } from "./std/testing.ts";
import {
assertEquals,
assertExists,
assertNotEquals,
assertObjectMatch,
} from "../lib/std/assert.ts";
import { URI } from "../lib/uri.ts";
} from "./std/assert.ts";
import { URI } from "./uri.ts";
import { _create, DependencyUpdate } from "./update.ts";
import { ImportMap } from "./import_map.ts";

Expand Down
6 changes: 3 additions & 3 deletions src/versions.ts → lib/versions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2023 Shun Ueda. All rights reserved. MIT license.

import type { Maybe } from "../lib/types.ts";
import { distinct } from "../lib/std/collections.ts";
import { DependencyUpdate } from "../mod.ts";
import type { Maybe } from "./types.ts";
import { distinct } from "./std/collections.ts";
import { DependencyUpdate } from "./update.ts";

export type VersionProp = {
from?: string;
Expand Down
6 changes: 3 additions & 3 deletions src/versions_test.ts → lib/versions_test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// deno-lint-ignore-file no-explicit-any

import { describe, it } from "../lib/std/testing.ts";
import { assertEquals, assertThrows } from "../lib/std/assert.ts";
import { createVersionProp } from "../src/versions.ts";
import { describe, it } from "./std/testing.ts";
import { assertEquals, assertThrows } from "./std/assert.ts";
import { createVersionProp } from "./versions.ts";

describe("createVersionProps()", () => {
it("single version", () => {
Expand Down
13 changes: 0 additions & 13 deletions src/types.ts

This file was deleted.

0 comments on commit a3bf60e

Please sign in to comment.