Skip to content
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
3 changes: 2 additions & 1 deletion .github/workflows/check-code.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Check code

on: push
on: ["push", "pull_request"]

jobs:
build:
Expand Down Expand Up @@ -32,6 +32,7 @@ jobs:
run: deno coverage --lcov coverage/ > coverage/lcov.info

- name: Upload coverage to Coveralls.io

uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }} # Generated by GitHub.
11 changes: 11 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,16 @@ jobs:
config-file: deno.json # or deno.json
tag: ${{ steps.gettag.outputs.tag }}

- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: "https://registry.npmjs.org"
- name: Transpile for npm
run: deno run --allow-all build.ts
- name: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: cd npm && npm publish --provenance --access public

- name: Publish to JSR
run: deno publish --allow-dirty
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.direnv
coverage
coverage
npm/
30 changes: 30 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// ex. scripts/build_npm.ts
import { build, emptyDir } from "@deno/dnt";
import denoJson from "./deno.json" with { type: "json" };

await emptyDir("./npm");

await build({
entryPoints: ["./mod.ts"],
outDir: "./npm",
shims: {
// see JS docs for overview and more options
deno: "dev",
},
testPattern: "tests/[!_]*_test.ts",
importMap: "deno.json",
typeCheck: false,
package: {
name: denoJson.name,
version: denoJson.version,
description: denoJson.description,
license: "MIT",
repository: {
type: "git",
url: "git+https://github.com/ankarhem/secrecy-ts.git",
},
bugs: {
url: "https://github.com/ankarhem/secrecy-ts/issues",
},
},
});
9 changes: 6 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
},
"license": "MIT",
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@std/testing": "jsr:@std/testing@^1.0.4",
"test-console": "npm:test-console@^2.0.0"
"@deno/dnt": "jsr:@deno/dnt@^0.41.3",
"@std/assert": "jsr:@std/assert@^1.0.7",
"@std/testing": "jsr:@std/testing@^1.0.4"
},
"compilerOptions": {
"checkJs": true
},
"test": {
"include": ["tests/**/*_test.ts"]
},
"fmt": {
"indentWidth": 2,
"lineWidth": 80,
Expand Down
114 changes: 105 additions & 9 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions console_test.ts → tests/_console_log_test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { assertEquals } from "@std/assert";
import { Secret } from "./mod.ts";

import { Secret } from "../mod.ts";
console.log(new Secret("password"));

Deno.test("Secret - hidden from stdout and stderr", async () => {
// spawn a process and verify that stdout is redacted
const command = new Deno.Command("deno", {
args: ["console_test.ts"],
args: ["./tests/_console_log_test.ts"],
stdout: "piped",
stderr: "piped",
stdin: "piped",
Expand Down
2 changes: 1 addition & 1 deletion mod_test.ts → tests/mod_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, assertEquals, assertFalse, assertThrows } from "@std/assert";
import { assertSecret, isSecret, Secret } from "./mod.ts";
import { assertSecret, isSecret, Secret } from "../mod.ts";

Deno.test("Secret - can expose", () => {
const secret = new Secret("password");
Expand Down
Loading