Skip to content

Commit

Permalink
feat: publish to jsr.io (#679)
Browse files Browse the repository at this point in the history
Co-authored-by: Benjamin Fischer <[email protected]>
  • Loading branch information
JOTSR and c4spar authored May 5, 2024
1 parent d9600b5 commit ff14148
Show file tree
Hide file tree
Showing 180 changed files with 439 additions and 437 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish

on:
pull_request:
push:
branches: [main]
release:
types: [published]

env:
DENO_UNSTABLE_WORKSPACES: true

jobs:
publish:
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Deno
uses: denoland/setup-deno@v1

- name: Publish (dry run)
if: github.event_name != 'release'
run: deno publish --dry-run

- name: Publish
if: github.event_name == 'release'
run: deno publish
4 changes: 2 additions & 2 deletions ansi/ansi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type Ansi = AnsiFactory & AnsiChain;
* If invoked as method, a new Ansi instance will be returned.
*
* ```ts
* import { ansi } from "./mod.ts";
* import { ansi } from "@cliffy/ansi";
*
* await Deno.stdout.write(
* new TextEncoder().encode(
Expand All @@ -44,7 +44,7 @@ export type Ansi = AnsiFactory & AnsiChain;
* Or shorter:
*
* ```ts
* import { ansi } from "./mod.ts";
* import { ansi } from "@cliffy/ansi";
*
* await Deno.stdout.write(
* ansi.cursorTo(0, 0).eraseScreen.bytes(),
Expand Down
30 changes: 15 additions & 15 deletions ansi/ansi_escapes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { encodeBase64 } from "./deps.ts";
import { encodeBase64 } from "@std/encoding/base64";

/** Escape sequence: `\x1B` */
const ESC = "\x1B";
/** Control sequence intro: `\x1B[` */
const CSI = `${ESC}[`;
const CSI: string = `${ESC}[`;
/** Operating system command: `\x1B]` */
const OSC = `${ESC}]`;
/** Link separator */
Expand All @@ -12,7 +12,7 @@ const SEP = ";";
/** Ring audio bell: `\u0007` */
export const bel = "\u0007";
/** Get cursor position. */
export const cursorPosition = `${CSI}6n`;
export const cursorPosition: string = `${CSI}6n`;

/**
* Move cursor to x, y, counting from the top left corner.
Expand Down Expand Up @@ -98,15 +98,15 @@ export function cursorPrevLine(count = 1): string {
}

/** Move cursor to first column of current row. */
export const cursorLeft = `${CSI}G`;
export const cursorLeft: string = `${CSI}G`;
/** Hide cursor. */
export const cursorHide = `${CSI}?25l`;
export const cursorHide: string = `${CSI}?25l`;
/** Show cursor. */
export const cursorShow = `${CSI}?25h`;
export const cursorShow: string = `${CSI}?25h`;
/** Save cursor. */
export const cursorSave = `${ESC}7`;
export const cursorSave: string = `${ESC}7`;
/** Restore cursor. */
export const cursorRestore = `${ESC}8`;
export const cursorRestore: string = `${ESC}8`;

/**
* Scroll window up by n lines.
Expand All @@ -125,7 +125,7 @@ export function scrollDown(count = 1): string {
}

/** Clear screen. */
export const eraseScreen = `${CSI}2J`;
export const eraseScreen: string = `${CSI}2J`;

/**
* Clear screen up by n lines.
Expand All @@ -144,11 +144,11 @@ export function eraseDown(count = 1): string {
}

/** Clear current line. */
export const eraseLine = `${CSI}2K`;
export const eraseLine: string = `${CSI}2K`;
/** Clear to line end. */
export const eraseLineEnd = `${CSI}0K`;
export const eraseLineEnd: string = `${CSI}0K`;
/** Clear to line start. */
export const eraseLineStart = `${CSI}1K`;
export const eraseLineStart: string = `${CSI}1K`;

/**
* Clear screen and move cursor by n lines up and move cursor to first column.
Expand All @@ -170,7 +170,7 @@ export const clearScreen = "\u001Bc";
* Clear the whole terminal, including scrollback buffer.
* (Not just the visible part of it).
*/
export const clearTerminal = Deno.build.os === "windows"
export const clearTerminal: string = Deno.build.os === "windows"
? `${eraseScreen}${CSI}0f`
// 1. Erases the screen (Only done in case `2` is not supported)
// 2. Erases the whole screen including scrollback buffer
Expand All @@ -185,7 +185,7 @@ export const clearTerminal = Deno.build.os === "windows"
* @param url Link url.
*
* ```ts
* import { link } from "./mod.ts";
* import { link } from "@cliffy/ansi/ansi-escapes";
*
* console.log(
* link("Click me.", "https://deno.land"),
Expand Down Expand Up @@ -223,7 +223,7 @@ export interface ImageOptions {
* @param options Image options.
*
* ```ts
* import { image } from "./mod.ts";
* import { image } from "@cliffy/ansi/ansi-escapes";
*
* const response = await fetch("https://deno.land/images/hashrock_simple.png");
* const imageBuffer: ArrayBuffer = await response.arrayBuffer();
Expand Down
2 changes: 1 addition & 1 deletion ansi/ansi_escapes_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
scrollDown,
scrollUp,
} from "./ansi_escapes.ts";
import { assertEquals } from "../dev_deps.ts";
import { assertEquals } from "@std/assert";

Deno.test({
name: "ansi - ansi escapes - cursorTo x",
Expand Down
2 changes: 1 addition & 1 deletion ansi/ansi_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "../dev_deps.ts";
import { assertEquals } from "@std/assert";
import { ansi } from "./ansi.ts";

Deno.test({
Expand Down
4 changes: 2 additions & 2 deletions ansi/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export interface Chain<TContext extends Chain<TContext>> {
* @param url Link url.
*
* ```ts
* import { ansi } from "./mod.ts";
* import { ansi } from "@cliffy/ansi";
*
* console.log(
* ansi.link("Click me.", "https://deno.land"),
Expand All @@ -124,7 +124,7 @@ export interface Chain<TContext extends Chain<TContext>> {
* @param options Image options.
*
* ```ts
* import { ansi } from "./mod.ts";
* import { ansi } from "@cliffy/ansi";
*
* const response = await fetch("https://deno.land/images/hashrock_simple.png");
* const imageBuffer: ArrayBuffer = await response.arrayBuffer();
Expand Down
6 changes: 3 additions & 3 deletions ansi/colors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as stdColors from "https://deno.land/[email protected]/fmt/colors.ts";
import * as stdColors from "@std/fmt/colors";

type ExcludedColorMethods = "setColorEnabled" | "getColorEnabled";
type PropertyNames = keyof typeof stdColors;
Expand Down Expand Up @@ -39,15 +39,15 @@ for (const name of methodNames) {
* Chainable colors module.
*
* ```ts
* import { colors } from "./mod.ts";
* import { colors } from "@cliffy/ansi/colors";
*
* console.log(colors.blue.bgRed.bold('Welcome to Deno.Land!'));
* ```
*
* If invoked as method, a new Ansi instance will be returned.
*
* ```ts
* import { Colors, colors } from "./mod.ts";
* import { Colors, colors } from "@cliffy/ansi/colors";
*
* const myColors: Colors = colors();
* console.log(myColors.blue.bgRed.bold('Welcome to Deno.Land!'));
Expand Down
4 changes: 2 additions & 2 deletions ansi/colors_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assertEquals, bold, red } from "../dev_deps.ts";
import { underline } from "../prompt/deps.ts";
import { assertEquals } from "@std/assert";
import { bold, red, underline } from "@std/fmt/colors";
import { colors } from "./colors.ts";

Deno.test({
Expand Down
4 changes: 2 additions & 2 deletions ansi/cursor_position.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cursorPosition } from "./ansi_escapes.ts";
import type { ReaderSync, WriterSync } from "./deps.ts";
import type { ReaderSync, WriterSync } from "@std/io/types";

/** Cursor position. */
export interface Cursor {
Expand All @@ -25,7 +25,7 @@ const decoder = new TextDecoder();
* @param options Options.
*
* ```ts
* import { Cursor, getCursorPosition } from "./mod.ts";
* import { Cursor, getCursorPosition } from "@cliffy/ansi/cursor-position";
*
* const cursor: Cursor = getCursorPosition();
* console.log(cursor); // { x: 0, y: 14}
Expand Down
11 changes: 11 additions & 0 deletions ansi/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@cliffy/ansi",
"version": "1.0.0-rc.4",
"exports": {
".": "./ansi.ts",
"./ansi-escapes": "./ansi_escapes.ts",
"./colors": "./colors.ts",
"./cursor-position": "./cursor_position.ts",
"./tty": "./tty.ts"
}
}
5 changes: 0 additions & 5 deletions ansi/deps.ts

This file was deleted.

51 changes: 0 additions & 51 deletions ansi/mod.ts

This file was deleted.

4 changes: 2 additions & 2 deletions ansi/tty.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as ansiEscapes from "./ansi_escapes.ts";
import type { Chain } from "./chain.ts";
import { Cursor, getCursorPosition } from "./cursor_position.ts";
import type { ReaderSync, WriterSync } from "./deps.ts";
import { ReaderSync, WriterSync } from "@std/io/types";

/** Create new `Ansi` instance. */
export interface TtyOptions {
Expand Down Expand Up @@ -39,7 +39,7 @@ export type Tty = TtyFactory & TtyChain;
* If invoked as method, a new Tty instance will be returned.
*
* ```ts
* import { tty } from "./mod.ts";
* import { tty } from "@cliffy/ansi/tty";
*
* tty.cursorTo(0, 0).eraseScreen();
* ```
Expand Down
2 changes: 1 addition & 1 deletion ansi/tty_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "../dev_deps.ts";
import { assertEquals } from "@std/assert";
import { tty } from "./tty.ts";

Deno.test({
Expand Down
2 changes: 1 addition & 1 deletion command/_errors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { didYouMeanCommand } from "./_utils.ts";
import type { Command } from "./command.ts";
import { getFlag } from "./_utils.ts";
import { bold } from "./deps.ts";
import { bold } from "@std/fmt/colors";
import { EnvVar } from "./types.ts";

export class CommandError extends Error {
Expand Down
6 changes: 3 additions & 3 deletions command/_utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { closestString } from "https://deno.land/[email protected]/text/closest_string.ts";
import { closestString } from "@std/text/closest-string";
import {
OptionType,
UnexpectedArgumentAfterVariadicArgumentError,
UnexpectedRequiredArgumentError,
} from "../flags/_errors.ts";
import { OptionType } from "../flags/deprecated.ts";
} from "@cliffy/flags";
import type { Command } from "./command.ts";
import type { Argument } from "./types.ts";

Expand Down
Loading

0 comments on commit ff14148

Please sign in to comment.