Skip to content

build: Ready for publishing JSR #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,5 @@ jobs:
- uses: denoland/setup-deno@v1
with:
deno-version: "v1.x"
- name: Check fmt
run: deno fmt --check
- name: Run lint
run: deno lint
- name: Run type check
run: deno check --remote ./**/*.ts
- name: Run test
run: deno test --allow-read --allow-write
- name: Check fmt & lint & type check & test
run: deno task check:dry
27 changes: 27 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# cf. https://jsr.io/@core/unknownutil/3.18.1/.github/workflows/jsr.yml
name: publish

env:
DENO_VERSION: 1.x

on:
push:
tags:
- '*'

permissions:
contents: read
id-token: write # The OIDC ID token is used for authentication with JSR.


jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Publish on tag
run: deno task publish
41 changes: 24 additions & 17 deletions .github/workflows/udd.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
# from https://zenn.dev/kawarimidoll/articles/c68204d248c107#設定ファイル
name: update-deno-dependencies
# ported from https://github.com/jsr-core/unknownutil/blob/v3.18.1/.github/workflows/udd.yml and modified a bit
name: Update

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
udd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: "v1.x"
deno-version: "1.x"
- name: Update dependencies
run: >
deno run --allow-net --allow-read --allow-write=deps/
--allow-run=deno https://deno.land/x/[email protected]/main.ts deps/*.ts
--test="deno test --allow-read"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
run: |
deno task upgrade > ../output.txt
env:
NO_COLOR: 1
- name: Read ../output.txt
id: log
uses: juliangruber/read-file-action@v1
with:
commit-message: ":arrow_up: update deno dependencies"
title: Update Deno Dependencies
body: >
Automated updates by [deno-udd](https://github.com/hayd/deno-udd)
and [create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action
path: ../output.txt
- uses: peter-evans/create-pull-request@v6
with:
commit-message: ":package: Update Deno dependencies"
title: ":package: Update Deno dependencies"
body: |
The output of `deno task update` is

```
${{ steps.log.outputs.content }}
```
branch: update-deno-dependencies
author: GitHub <[email protected]>
delete-branch: true
delete-branch: true
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# scrapbox-userscript-std

UNOFFICIAL standard module for Scrapbox UserScript
[![JSR](https://jsr.io/badges/@cosense/std)](https://jsr.io/@cosense/std)
[![test](https://github.com/takker99/scrapbox-userscript-std/workflows/ci/badge.svg)](https://github.com/takker99/scrapbox-userscript-std/actions?query=workflow%3Aci)

[document](https://doc.deno.land/https://raw.githubusercontent.com/takker99/scrapbox-userscript-std/0.14.9/mod.ts)
UNOFFICIAL standard module for Scrapbox UserScript
4 changes: 0 additions & 4 deletions browser/dom/caret.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />

import { textInput } from "./dom.ts";

/** editor上の位置情報 */
Expand Down
12 changes: 4 additions & 8 deletions browser/dom/click.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />

import { sleep } from "../../sleep.ts";
import { delay } from "@std/async/delay";

/** the options for `click()` */
export interface ClickOptions {
Expand Down Expand Up @@ -36,7 +32,7 @@ export const click = async (

// ScrapboxのReactの処理が終わるまで少し待つ
// 待ち時間は感覚で決めた
await sleep(10);
await delay(10);
};

export interface HoldDownOptions extends ClickOptions {
Expand Down Expand Up @@ -71,12 +67,12 @@ export const holdDown = async (
};
element.dispatchEvent(new TouchEvent("touchstart", mouseOptions));
element.dispatchEvent(new MouseEvent("mousedown", mouseOptions));
await sleep(options.holding ?? 1000);
await delay(options.holding ?? 1000);
element.dispatchEvent(new MouseEvent("mouseup", mouseOptions));
element.dispatchEvent(new TouchEvent("touchend", mouseOptions));
element.dispatchEvent(new MouseEvent("click", mouseOptions));

// ScrapboxのReactの処理が終わるまで少し待つ
// 待ち時間は感覚で決めた
await sleep(10);
await delay(10);
};
10 changes: 3 additions & 7 deletions browser/dom/cursor.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />

import { BaseLine, BaseStore } from "../../deps/scrapbox.ts";
import { Position } from "./position.ts";
import { Page } from "./page.d.ts";
import { type BaseLine, BaseStore } from "../../deps/scrapbox.ts";
import type { Position } from "./position.ts";
import type { Page } from "./page.d.ts";

export interface SetPositionOptions {
/** カーソルが画面外に移動したとき、カーソルが見える位置までページをスクロールするかどうか
Expand Down
6 changes: 1 addition & 5 deletions browser/dom/cursor.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />

import { takeStores } from "./stores.ts";
import { Cursor } from "./cursor.d.ts";
import type { Cursor } from "./cursor.d.ts";
export type { Cursor };

export const takeCursor = (): Cursor => takeStores().cursor;
3 changes: 0 additions & 3 deletions browser/dom/dom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />
import {
ensureHTMLAnchorElement,
ensureHTMLDivElement,
Expand Down
4 changes: 2 additions & 2 deletions browser/dom/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getLineCount } from "./node.ts";
import { range } from "../../range.ts";
import { textInput } from "./dom.ts";
import { isArray, isNumber, isString } from "../../is.ts";
import { sleep } from "../../sleep.ts";
import { delay } from "@std/async/delay";

export const undo = (count = 1): void => {
for (const _ of range(0, count)) {
Expand Down Expand Up @@ -165,5 +165,5 @@ export const insertText = async (text: string): Promise<void> => {

const event = new InputEvent("input", { bubbles: true });
cursor.dispatchEvent(event);
await sleep(1); // 待ち時間は感覚で決めた
await delay(1); // 待ち時間は感覚で決めた
};
1 change: 0 additions & 1 deletion browser/dom/ensure.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference lib="dom" />
// These code are based on https://deno.land/x/[email protected]/ensure.ts

export const ensureHTMLDivElement: (
Expand Down
2 changes: 1 addition & 1 deletion browser/dom/extractCodeFiles.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { extractCodeFiles } from "./extractCodeFiles.ts";
import { Line } from "../../deps/scrapbox.ts";
import type { Line } from "../../deps/scrapbox.ts";
import { assertSnapshot } from "../../deps/testing.ts";
import sample from "./sample-lines1.json" with { type: "json" };

Expand Down
2 changes: 1 addition & 1 deletion browser/dom/extractCodeFiles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Line } from "../../deps/scrapbox.ts";
import type { Line } from "../../deps/scrapbox.ts";

/** 一つのソースコードを表す */
export interface CodeFile {
Expand Down
2 changes: 1 addition & 1 deletion browser/dom/getCachedLines.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Line, Scrapbox } from "../../deps/scrapbox.ts";
import type { Line, Scrapbox } from "../../deps/scrapbox.ts";
declare const scrapbox: Scrapbox;

let isLatestData = false;
Expand Down
4 changes: 0 additions & 4 deletions browser/dom/isHeightViewable.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />

export const isHeightViewable = (element: HTMLElement): boolean => {
const { top, bottom } = element.getBoundingClientRect();
return top >= 0 && bottom <= globalThis.innerHeight;
Expand Down
4 changes: 0 additions & 4 deletions browser/dom/motion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />

import { press } from "./press.ts";
import { click, holdDown } from "./click.ts";
import {
Expand Down
5 changes: 1 addition & 4 deletions browser/dom/node.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />
import { isNone, isNumber, isString } from "../../is.ts";
import { ensureArray } from "../../ensure.ts";
import { getCachedLines } from "./getCachedLines.ts";
Expand Down Expand Up @@ -138,7 +135,7 @@ export const getInternalLink = (dom: HTMLElement): HTMLElement | undefined => {
if (isNone(link)) return undefined;
return link as HTMLElement;
};
export const getLink = (dom: HTMLElement) => {
export const getLink = (dom: HTMLElement): HTMLElement | undefined => {
const link = dom.closest(".link, .page-link");
if (isNone(link)) return undefined;
return link as HTMLElement;
Expand Down
10 changes: 3 additions & 7 deletions browser/dom/open.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />

import { encodeTitleURI } from "../../title.ts";
import {
PageTransitionContext,
type PageTransitionContext,
pushPageTransition,
} from "./pushPageTransition.ts";
import type { Scrapbox } from "../../deps/scrapbox.ts";
Expand Down Expand Up @@ -43,7 +39,7 @@ export const open = (
project: string,
title: string,
options?: OpenOptions,
) => {
): void => {
const url = new URL(`/${project}/${encodeTitleURI(title)}`, location.href);
if (options?.body) url.search = `?body=${encodeURIComponent(options.body)}`;
if (options?.id) url.hash = `#${options.id}`;
Expand Down Expand Up @@ -88,4 +84,4 @@ export const openInTheSameTab = (
project: string,
title: string,
body?: string,
) => open(project, title, { newTab: false, reload: false, body });
): void => open(project, title, { newTab: false, reload: false, body });
6 changes: 1 addition & 5 deletions browser/dom/page.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />

import { BaseStore } from "../../deps/scrapbox.ts";
import { Page as PageData } from "../../deps/scrapbox-rest.ts";
import type { Page as PageData } from "../../deps/scrapbox-rest.ts";

export interface SetPositionOptions {
/** カーソルが画面外に移動したとき、カーソルが見える位置までページをスクロールするかどうか
Expand Down
4 changes: 0 additions & 4 deletions browser/dom/press.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />

import { textInput } from "./dom.ts";

/** the options for `press()` */
Expand Down
8 changes: 2 additions & 6 deletions browser/dom/selection.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />

import { BaseLine, BaseStore } from "../../deps/scrapbox.ts";
import { Position } from "./position.ts";
import { type BaseLine, BaseStore } from "../../deps/scrapbox.ts";
import type { Position } from "./position.ts";

export interface Range {
start: Position;
Expand Down
6 changes: 1 addition & 5 deletions browser/dom/selection.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />

import { takeStores } from "./stores.ts";
import { Selection } from "./selection.d.ts";
import type { Selection } from "./selection.d.ts";
export type { Selection };

export const takeSelection = (): Selection => takeStores().selection;
8 changes: 2 additions & 6 deletions browser/dom/stores.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/// <reference no-default-lib="true"/>
/// <reference lib="esnext"/>
/// <reference lib="dom" />

import { textInput } from "./dom.ts";
import { Cursor } from "./cursor.d.ts";
import { Selection } from "./selection.d.ts";
import type { Cursor } from "./cursor.d.ts";
import type { Selection } from "./selection.d.ts";
export type { Cursor, Selection };

export const takeStores = (): { cursor: Cursor; selection: Selection } => {
Expand Down
2 changes: 1 addition & 1 deletion browser/dom/takeInternalLines.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { lines } from "./dom.ts";
import { BaseLine } from "../../deps/scrapbox.ts";
import type { BaseLine } from "../../deps/scrapbox.ts";

/** Scrapbox内部の本文データの参照を取得する
*
Expand Down
2 changes: 1 addition & 1 deletion browser/dom/textInputEventListener.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Scrapbox } from "../../deps/scrapbox.ts";
import type { Scrapbox } from "../../deps/scrapbox.ts";
import { textInput } from "./dom.ts";
import { decode, encode } from "./_internal.ts";
declare const scrapbox: Scrapbox;
Expand Down
2 changes: 0 additions & 2 deletions browser/websocket/_codeBlock.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/// <reference lib="deno.ns" />

import { assertEquals, assertSnapshot } from "../../deps/testing.ts";
import { extractFromCodeTitle } from "./_codeBlock.ts";

Expand Down
2 changes: 1 addition & 1 deletion browser/websocket/_codeBlock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TinyCodeBlock } from "../../rest/getCodeBlocks.ts";
import type { TinyCodeBlock } from "../../rest/getCodeBlocks.ts";

/** コードブロックのタイトル行の情報を保持しておくためのinterface */
export interface CodeTitle {
Expand Down
4 changes: 2 additions & 2 deletions browser/websocket/deletePage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { push, PushOptions, RetryError } from "./push.ts";
import { Result } from "../../rest/util.ts";
import { push, type PushOptions, type RetryError } from "./push.ts";
import type { Result } from "../../rest/util.ts";

export type DeletePageOptions = PushOptions;

Expand Down
2 changes: 1 addition & 1 deletion browser/websocket/findMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseLine, Node, parse } from "../../deps/scrapbox.ts";
import { type BaseLine, type Node, parse } from "../../deps/scrapbox.ts";
import { toTitleLc } from "../../title.ts";
import { parseYoutube } from "../../parser/youtube.ts";

Expand Down
2 changes: 1 addition & 1 deletion browser/websocket/isSimpleCodeFile.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert, assertFalse } from "../../deps/testing.ts";
import { isSimpleCodeFile } from "./isSimpleCodeFile.ts";
import { SimpleCodeFile } from "./updateCodeFile.ts";
import type { SimpleCodeFile } from "./updateCodeFile.ts";

const codeFile: SimpleCodeFile = {
filename: "filename",
Expand Down
2 changes: 1 addition & 1 deletion browser/websocket/isSimpleCodeFile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SimpleCodeFile } from "./updateCodeFile.ts";
import type { SimpleCodeFile } from "./updateCodeFile.ts";

/** objectがSimpleCodeFile型かどうかを判別する */
export function isSimpleCodeFile(obj: unknown): obj is SimpleCodeFile {
Expand Down
Loading
Loading