Skip to content

Commit

Permalink
use denops v7
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoh86 committed Jul 29, 2024
1 parent 63e595b commit 3146007
Show file tree
Hide file tree
Showing 21 changed files with 89 additions and 129 deletions.
2 changes: 2 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "denops-docbase.vim",
"version": "0.0.0",
"description": "A Vim plugin as a client for the DocBase",
"exports": {},
"tasks": {
"test": "deno test --allow-env=DENOPS_TEST_CONNECT_TIMEOUT,DENOPS_TEST_DENOPS_PATH,DENOPS_TEST_VERBOSE,DENOPS_TEST_VIM_EXECUTABLE,DENOPS_TEST_NVIM_EXECUTABLE --allow-run=vim,nvim --allow-net=127.0.0.1:0 --allow-read",
"check": "deno check ./**/*.ts",
Expand Down
11 changes: 4 additions & 7 deletions denops/docbase/api/fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import {
ensure,
Predicate as P,
} from "https://deno.land/x/[email protected]/mod.ts";
import { getLogger } from "https://deno.land/[email protected]/log/mod.ts";
import { Response, ResponseWithBody } from "./types.ts";
import { Stringer } from "./types.ts";
import { ensure, type Predicate as P } from "jsr:@core/[email protected]";
import { getLogger } from "jsr:@std/[email protected]";
import type { Response, ResponseWithBody } from "./types.ts";
import type { Stringer } from "./types.ts";

const API_URL = "https://api.docbase.io";

Expand Down
4 changes: 2 additions & 2 deletions denops/docbase/api/file.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fromUint8Array } from "https://deno.land/x/[email protected]/mod.ts";
import { encodeBase64 } from "jsr:@std/[email protected]";

export async function encode_content(filename: string) {
return fromUint8Array(await Deno.readFile(filename));
return encodeBase64(await Deno.readFile(filename));
}
7 changes: 2 additions & 5 deletions denops/docbase/api/resources/attachments.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {
is,
Predicate as P,
} from "https://deno.land/x/[email protected]/mod.ts";
import { Fetcher } from "../fetcher.ts";
import { is, type Predicate as P } from "jsr:@core/[email protected]";
import type { Fetcher } from "../fetcher.ts";

export interface UploadAttachmentParams {
name: string;
Expand Down
9 changes: 3 additions & 6 deletions denops/docbase/api/resources/comments.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {
is,
Predicate as P,
} from "https://deno.land/x/[email protected]/mod.ts";
import { Fetcher } from "../fetcher.ts";
import { isUserSummary, UserSummary } from "./user_summary.ts";
import { is, type Predicate as P } from "jsr:@core/[email protected]";
import type { Fetcher } from "../fetcher.ts";
import { isUserSummary, type UserSummary } from "./user_summary.ts";

export interface CreateCommentParams {
body: string;
Expand Down
5 changes: 1 addition & 4 deletions denops/docbase/api/resources/group_summary.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
is,
Predicate as P,
} from "https://deno.land/x/[email protected]/mod.ts";
import { is, type Predicate as P } from "jsr:@core/[email protected]";

export interface GroupSummary {
id: number;
Expand Down
11 changes: 4 additions & 7 deletions denops/docbase/api/resources/groups.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import {
is,
Predicate as P,
} from "https://deno.land/x/[email protected]/mod.ts";
import { isUserSummary, UserSummary } from "./user_summary.ts";
import { is, type Predicate as P } from "jsr:@core/[email protected]";
import { isUserSummary, type UserSummary } from "./user_summary.ts";
import { isGroupSummary } from "./group_summary.ts";
import { Fetcher } from "../fetcher.ts";
import { Stringer } from "../types.ts";
import type { Fetcher } from "../fetcher.ts";
import type { Stringer } from "../types.ts";

export interface CreateGroupParams {
name: string;
Expand Down
19 changes: 8 additions & 11 deletions denops/docbase/api/resources/posts.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import {
is,
Predicate as P,
} from "https://deno.land/x/[email protected]/mod.ts";
import { Fetcher } from "../fetcher.ts";
import { is, type Predicate as P } from "jsr:@core/[email protected]";
import type { Fetcher } from "../fetcher.ts";

import { isTagSummary, TagSummary } from "./tags.ts";
import { isUserSummary, UserSummary } from "./user_summary.ts";
import { Comment, isComment } from "./comments.ts";
import { GroupSummary, isGroupSummary } from "./group_summary.ts";
import { Attachment, isAttachment } from "./attachments.ts";
import { Stringer } from "../types.ts";
import { isTagSummary, type TagSummary } from "./tags.ts";
import { isUserSummary, type UserSummary } from "./user_summary.ts";
import { type Comment, isComment } from "./comments.ts";
import { type GroupSummary, isGroupSummary } from "./group_summary.ts";
import { type Attachment, isAttachment } from "./attachments.ts";
import type { Stringer } from "../types.ts";

export type Scope = "everyone" | "group" | "private";
export const isScope = is.UnionOf([
Expand Down
9 changes: 3 additions & 6 deletions denops/docbase/api/resources/profiles.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {
is,
Predicate as P,
} from "https://deno.land/x/[email protected]/mod.ts";
import { Fetcher } from "../fetcher.ts";
import { GroupSummary, isGroupSummary } from "./group_summary.ts";
import { is, type Predicate as P } from "jsr:@core/[email protected]";
import type { Fetcher } from "../fetcher.ts";
import { type GroupSummary, isGroupSummary } from "./group_summary.ts";

export interface Profile {
id: number;
Expand Down
7 changes: 2 additions & 5 deletions denops/docbase/api/resources/tags.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {
is,
Predicate as P,
} from "https://deno.land/x/[email protected]/mod.ts";
import { Fetcher } from "../fetcher.ts";
import { is, type Predicate as P } from "jsr:@core/[email protected]";
import type { Fetcher } from "../fetcher.ts";

export interface Tag {
id: number;
Expand Down
4 changes: 2 additions & 2 deletions denops/docbase/api/resources/templates.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Apply template to the text
// See: https://help.docbase.io/posts/15787
import { Fetcher } from "../fetcher.ts";
import { get, Profile } from "./profiles.ts";
import type { Fetcher } from "../fetcher.ts";
import { get, type Profile } from "./profiles.ts";

let cached: Profile | undefined = undefined;

Expand Down
5 changes: 1 addition & 4 deletions denops/docbase/api/resources/user_summary.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
is,
Predicate as P,
} from "https://deno.land/x/[email protected]/mod.ts";
import { is, type Predicate as P } from "jsr:@core/[email protected]";

export interface UserSummary {
id: number;
Expand Down
11 changes: 4 additions & 7 deletions denops/docbase/api/resources/users.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import {
is,
Predicate as P,
} from "https://deno.land/x/[email protected]/mod.ts";
import { Fetcher } from "../fetcher.ts";
import { GroupSummary, isGroupSummary } from "./group_summary.ts";
import { Stringer } from "../types.ts";
import { is, type Predicate as P } from "jsr:@core/[email protected]";
import type { Fetcher } from "../fetcher.ts";
import { type GroupSummary, isGroupSummary } from "./group_summary.ts";
import type { Stringer } from "../types.ts";

export type SearchUsersParams = {
q?: string | undefined;
Expand Down
4 changes: 2 additions & 2 deletions denops/docbase/cache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ensureDir } from "https://deno.land/std@0.224.0/fs/mod.ts";
import { join } from "https://deno.land/std@0.224.0/path/mod.ts";
import { ensureDir } from "jsr:@std/[email protected]";
import { join } from "jsr:@std/[email protected]";

async function getCacheDirectoryName() {
const localAppData = Deno.env.get("LOCALAPPDATA");
Expand Down
19 changes: 8 additions & 11 deletions denops/docbase/handler/new_post.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
// New Post Buffer

import type { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import { execute } from "https://deno.land/x/[email protected]/helper/execute.ts";
import * as option from "https://deno.land/x/[email protected]/option/mod.ts";
import * as buffer from "https://deno.land/x/[email protected]/buffer/mod.ts";
import { ensure, is } from "https://deno.land/x/unknownutil@v3.18.1/mod.ts";
import { getLogger } from "https://deno.land/[email protected].0/log/mod.ts";
import type { Denops } from "jsr:@denops/[email protected]";
import { execute } from "jsr:@denops/[email protected]/helper";
import * as option from "jsr:@denops/[email protected]/option";
import * as buffer from "jsr:@denops/[email protected]/buffer";
import { ensure, is } from "jsr:@core/unknownutil@3.18.1";
import { getLogger } from "jsr:@std/log@0.224.5";

import type { Post } from "../types.ts";
import type { CreatePostParams } from "../types.ts";
import { Client } from "../api/client.ts";
import { Filetype } from "./filetype.ts";
import { parsePostBufferLines, saveGroupsIntoPostBuffer } from "./post.ts";
import type {
Buffer,
Router,
} from "https://denopkg.com/kyoh86/denops-router@master/mod.ts";
import type { Buffer, Router } from "jsr:@kyoh86/[email protected]";
import type { StateMan } from "../state.ts";
import { getbufline } from "https://deno.land/x/[email protected]/function/mod.ts";
import { getbufline } from "jsr:@denops/[email protected]/function";

const isNewPostParams = is.ObjectOf({
domain: is.String,
Expand Down
20 changes: 10 additions & 10 deletions denops/docbase/handler/post.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Single Post Buffer

import { extract } from "https://deno.land/std@0.224.0/front_matter/yaml.ts";
import type { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import * as buffer from "https://deno.land/x/[email protected]/buffer/mod.ts";
import * as option from "https://deno.land/x/[email protected]/option/mod.ts";
import * as variable from "https://deno.land/x/[email protected]/variable/variable.ts";
import { getbufline } from "https://deno.land/x/[email protected]/function/buffer.ts";
import { ensure, is } from "https://deno.land/x/unknownutil@v3.18.1/mod.ts";
import { getLogger } from "https://deno.land/[email protected].0/log/mod.ts";
import { extractYaml } from "jsr:@std/[email protected]";
import type { Denops } from "jsr:@denops/[email protected]";
import * as buffer from "jsr:@denops/[email protected]/buffer";
import * as option from "jsr:@denops/[email protected]/option";
import * as variable from "jsr:@denops/[email protected]/variable";
import { getbufline } from "jsr:@denops/[email protected]/function";
import { ensure, is } from "jsr:@core/unknownutil@3.18.1";
import { getLogger } from "jsr:@std/log@0.224.5";

import { Filetype } from "./filetype.ts";
import type { Post as PostData, UpdatePostParams } from "../types.ts";
import { isGroupSummary } from "../types.ts";
import { Client } from "../api/client.ts";
import type { Buffer } from "https://denopkg.com/kyoh86/denops-router@master/mod.ts";
import type { Buffer } from "jsr:@kyoh86/denops-router@0.0.1";
import type { StateMan } from "../state.ts";
import { getCacheFile } from "../cache.ts";

Expand Down Expand Up @@ -245,7 +245,7 @@ export async function parsePostBufferLines(
draft: is.OptionalOf(is.Boolean),
tags: is.OptionalOf(is.ArrayOf(is.String)),
};
const content = extract(lines.join("\n"));
const content = extractYaml(lines.join("\n"));
const attr = ensure(
content.attrs,
is.UnionOf([
Expand Down
21 changes: 9 additions & 12 deletions denops/docbase/handler/posts_list.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
// Post List Buffer

import type { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import * as buffer from "https://deno.land/x/[email protected]/buffer/mod.ts";
import * as variable from "https://deno.land/x/[email protected]/variable/variable.ts";
import * as option from "https://deno.land/x/[email protected]/option/mod.ts";
import { batch } from "https://deno.land/x/[email protected]/batch/mod.ts";
import { getLogger } from "https://deno.land/[email protected].0/log/mod.ts";
import { ensure, is } from "https://deno.land/x/unknownutil@v3.18.1/mod.ts";
import type { Denops } from "jsr:@denops/[email protected]";
import * as buffer from "jsr:@denops/[email protected]/buffer";
import * as variable from "jsr:@denops/[email protected]/variable";
import * as option from "jsr:@denops/[email protected]/option";
import { batch } from "jsr:@denops/[email protected]/batch";
import { getLogger } from "jsr:@std/log@0.224.5";
import { ensure, is } from "jsr:@core/unknownutil@3.18.1";

import { Filetype } from "./filetype.ts";
import { Client } from "../api/client.ts";
import { StateMan } from "../state.ts";
import type {
Buffer,
Router,
} from "https://denopkg.com/kyoh86/denops-router@master/mod.ts";
import type { StateMan } from "../state.ts";
import type { Buffer, Router } from "jsr:@kyoh86/[email protected]";

export async function loadPostsList(
denops: Denops,
Expand Down
19 changes: 8 additions & 11 deletions denops/docbase/handler/teams_list.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
// Team List Buffer

import type { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import { batch } from "https://deno.land/x/[email protected]/batch/mod.ts";
import * as buffer from "https://deno.land/x/[email protected]/buffer/mod.ts";
import * as variable from "https://deno.land/x/[email protected]/variable/variable.ts";
import * as option from "https://deno.land/x/[email protected]/option/mod.ts";
import type { Denops } from "jsr:@denops/[email protected]";
import { batch } from "jsr:@denops/[email protected]/batch";
import * as buffer from "jsr:@denops/[email protected]/buffer";
import * as variable from "jsr:@denops/[email protected]/variable";
import * as option from "jsr:@denops/[email protected]/option";

import { ensure, is } from "https://deno.land/x/[email protected]/mod.ts";
import type {
Buffer,
Router,
} from "https://denopkg.com/kyoh86/denops-router@master/mod.ts";
import { ensure, is } from "jsr:@core/[email protected]";
import type { Buffer, Router } from "jsr:@kyoh86/[email protected]";
import { Filetype } from "./filetype.ts";
import { StateMan } from "../state.ts";
import type { StateMan } from "../state.ts";

export async function loadTeamsList(
denops: Denops,
Expand Down
17 changes: 7 additions & 10 deletions denops/docbase/main.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import {
echo,
input,
} from "https://deno.land/x/[email protected]/helper/mod.ts";
import type { Denops } from "jsr:@denops/[email protected]";
import { echo, input } from "jsr:@denops/[email protected]/helper";
import xdg from "https://deno.land/x/[email protected]/src/mod.deno.ts";
import { join } from "https://deno.land/std@0.224.0/path/mod.ts";
import { ensureFile } from "https://deno.land/std@0.224.0/fs/mod.ts";
import { ensure, is } from "https://deno.land/x/unknownutil@v3.18.1/mod.ts";
import { join } from "jsr:@std/[email protected]";
import { ensureFile } from "jsr:@std/[email protected]";
import { ensure, is } from "jsr:@core/unknownutil@3.18.1";
import {
ConsoleHandler,
getLogger,
RotatingFileHandler,
setup,
} from "https://deno.land/[email protected].0/log/mod.ts";
} from "jsr:@std/log@0.224.5";

import { isSearchPostsParams } from "./types.ts";
import { Client } from "./api/client.ts";
import { Router } from "https://denopkg.com/kyoh86/denops-router@master/mod.ts";
import { Router } from "jsr:@kyoh86/denops-router@0.0.1";
import { XDGStateMan } from "./state.ts";

import { loadTeamsList, openPostsList } from "./handler/teams_list.ts";
Expand Down
10 changes: 5 additions & 5 deletions denops/docbase/state.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import xdg from "https://deno.land/x/[email protected]/src/mod.deno.ts";
import { join } from "https://deno.land/std@0.224.0/path/mod.ts";
import { ensureFile } from "https://deno.land/std@0.224.0/fs/mod.ts";
import { exists, expandGlob } from "https://deno.land/std@0.224.0/fs/mod.ts";
import { parse, stringify } from "https://deno.land/std@0.224.0/toml/mod.ts";
import { is, maybe } from "https://deno.land/x/unknownutil@v3.18.1/mod.ts";
import { join } from "jsr:@std/[email protected]";
import { ensureFile } from "jsr:@std/[email protected]";
import { exists, expandGlob } from "jsr:@std/[email protected]";
import { parse, stringify } from "jsr:@std/[email protected]";
import { is, maybe } from "jsr:@core/unknownutil@3.18.1";

export type Domain = string;

Expand Down
4 changes: 2 additions & 2 deletions dummy_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from "https://deno.land/x/[email protected]/mod.ts";
import { assert } from "https://deno.land/std@0.224.0/assert/mod.ts";
import { test } from "jsr:@denops/[email protected]";
import { assert } from "jsr:@std/[email protected]";

test({
mode: "all",
Expand Down

0 comments on commit 3146007

Please sign in to comment.