Skip to content

Commit 8d7a092

Browse files
jhheidermxcl
authored andcommitted
fix external deps
1 parent 3917b38 commit 8d7a092

File tree

22 files changed

+117
-59
lines changed

22 files changed

+117
-59
lines changed

.github/deno-to-node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ await build({
4141
},
4242
importMap: "deno.json",
4343
mappings: {
44-
"https://deno.land/x/is_what@v4.1.8/src/index.ts": "is-what",
44+
"https://deno.land/x/is_what@v4.1.13/src/index.ts": "is-what",
4545
"https://deno.land/x/outdent@v0.8.0/mod.ts": "outdent",
4646
"./src/utils/flock.deno.ts": "./src/utils/flock.node.ts"
4747
},

.github/workflows/cd.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,50 @@ concurrency:
1515

1616
jobs:
1717
check:
18+
if: ${{ github.event.release.prerelease }}
1819
uses: ./.github/workflows/ci.yml
1920

20-
build:
21+
dnt:
2122
needs: [check]
22-
if: ${{ github.event.release.prerelease }}
23-
runs-on: ubuntu-latest
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
os:
28+
- [self-hosted, macOS, X64]
29+
- ubuntu-latest # ∵ resilience: PRs verify dnt with this env
30+
- [self-hosted, macOS, ARM64]
31+
- [self-hosted, linux, ARM64]
2432
steps:
2533
- uses: actions/checkout@v3
2634
- uses: teaxyz/setup@v0
35+
- run: deno task dnt ${{ github.event.release.tag_name }}
36+
37+
- uses: actions/upload-artifact@v3
38+
if: ${{ matrix.os == 'ubuntu-latest' }}
39+
with:
40+
path: dist
41+
42+
publish-npm:
43+
needs: [dnt]
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/download-artifact@v3
2747

2848
# if we don’t do this the npm publish step doesn’t work
2949
- uses: actions/setup-node@v2
3050
with:
3151
registry-url: https://registry.npmjs.org
3252

33-
- name: build
34-
run: .github/deno-to-node.ts ${{ github.event.release.tag_name }}
35-
3653
- run: npm publish --access public
3754
working-directory: dist
3855
env:
3956
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4057

41-
publish:
58+
publish-github:
4259
permissions:
4360
contents: write
44-
needs: [build]
61+
needs: [publish-npm]
4562
runs-on: ubuntu-latest
4663
steps:
4764
- uses: actions/checkout@v3

.github/workflows/ci.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,45 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v3
2626
- uses: teaxyz/setup@v0
27-
- run: deno cache $(find . -name \*.ts)
28-
- run: deno task test --coverage=cov_profile --no-check
29-
# ^^ no check as we have a separate type-checking step and it’s noise here
27+
- run: deno cache mod.ts
28+
29+
- run: deno task test
30+
--coverage=cov_profile
31+
--no-check # ⬆signal∶noise & ∵ we have `jobs.typecheck`
32+
3033
- run: deno coverage cov_profile --lcov --exclude=tests/ --output=cov_profile.lcov
34+
if: ${{ github.event_name != 'workflow_call' }}
35+
3136
- uses: coverallsapp/github-action@v1
37+
if: ${{ github.event_name != 'workflow_call' }}
3238
with:
3339
path-to-lcov: cov_profile.lcov
3440
parallel: true
3541
flag-name: ${{ matrix.platform.id }}
3642

3743
upload-coverage:
44+
if: ${{ github.event_name != 'workflow_call' }}
3845
needs: tests
3946
runs-on: ubuntu-latest
4047
steps:
4148
- uses: coverallsapp/github-action@v1
4249
with:
4350
parallel-finished: true
4451

52+
verify-usage-as-deno-lib:
53+
# we’re checking no import-map type imports snuck in
54+
runs-on: ubuntu-latest
55+
if: ${{ github.event_name != 'workflow_call' }}
56+
steps:
57+
- uses: actions/checkout@v3
58+
with:
59+
path: src
60+
- uses: denoland/setup-deno@v1
61+
- run: deno run --no-config --unstable src/mod.ts
62+
4563
dnt:
46-
runs-on: ${{ matrix.os }}
47-
strategy:
48-
fail-fast: false
49-
matrix:
50-
os:
51-
- [self-hosted, macOS, X64]
52-
- [self-hosted, linux, X64]
53-
- [self-hosted, macOS, ARM64]
54-
- [self-hosted, linux, ARM64]
64+
runs-on: ubuntu-latest
65+
if: ${{ github.event_name != 'workflow_call' }}
5566
steps:
5667
- uses: actions/checkout@v3
5768
- uses: teaxyz/setup@v0

deno.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
},
3030
"imports": {
3131
"is-what": "https://deno.land/x/is_what@v4.1.8/src/index.ts",
32-
"outdent": "https://deno.land/x/outdent@v0.8.0/mod.ts",
3332
"deno/": "https://deno.land/std@0.189.0/"
3433
}
3534
}

mod.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
import "./src/utils/misc.ts"
2+
import { flatmap, validate } from "./src/utils/misc.ts"
3+
14
import host from "./src/utils/host.ts"
25
import SemVer, * as semver from "./src/utils/semver.ts"
36
import Path from "./src/utils/Path.ts"
4-
export * as types from "./src/types.ts"
5-
6-
import "./src/utils/misc.ts"
7-
import { flatmap, validate } from "./src/utils/misc.ts"
87

8+
export * as types from "./src/types.ts"
99
import * as pkg from "./src/utils/pkg.ts"
10+
1011
import TeaError, { panic } from "./src/utils/error.ts"
1112
import useConfig from "./src/hooks/useConfig.ts"
1213
import useOffLicense from "./src/hooks/useOffLicense.ts"

src/deps.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as is_what from "https://deno.land/x/is_what@v4.1.13/src/index.ts"
2+
export { is_what }
3+
4+
import { type PlainObject } from "https://deno.land/x/is_what@v4.1.13/src/index.ts"
5+
export type { PlainObject }
6+
7+
import * as outdent from "https://deno.land/x/outdent@v0.8.0/mod.ts"
8+
export { outdent }
9+
10+
// importing super specifically to reduce final npm bundle size
11+
import * as crypto from "https://deno.land/std@0.190.0/crypto/mod.ts"
12+
import { moveSync } from "https://deno.land/std@0.190.0/fs/move.ts"
13+
import { readLines } from "https://deno.land/std@0.190.0/io/read_lines.ts"
14+
import { writeAll } from "https://deno.land/std@0.190.0/streams/write_all.ts"
15+
import { parse as parseYaml } from "https://deno.land/std@0.190.0/yaml/parse.ts"
16+
17+
const streams = { writeAll }
18+
const io = { readLines }
19+
const fs = { moveSync }
20+
const deno = { readLines, crypto, fs, io, streams, parseYaml }
21+
22+
export { deno }

src/hooks/useConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { flatmap } from "../utils/misc.ts"
12
import host from "../utils/host.ts"
2-
import { flatmap } from "../utils/misc.ts";
33
import Path from "../utils/Path.ts"
44

55
export interface Config {

src/hooks/useDownload.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { crypto, toHashString } from "deno/crypto/mod.ts"
2-
import { writeAll } from "deno/streams/write_all.ts"
1+
import { deno } from "../deps.ts"
2+
const { crypto: crypto_, streams: { writeAll } } = deno
3+
const { toHashString, crypto } = crypto_
34
import TeaError, { panic } from "../utils/error.ts"
45
import useConfig from "./useConfig.ts"
56
import useFetch from "./useFetch.ts"

src/hooks/usePantry.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { isNumber, isPlainObject, isString, isArray, isPrimitive, PlainObject, isBoolean } from "is-what"
1+
import { is_what, PlainObject } from "../deps.ts"
2+
const { isNumber, isPlainObject, isString, isArray, isPrimitive, isBoolean } = is_what
23
import { validatePackageRequirement } from "../utils/hacks.ts"
34
import { Package, Installation } from "../types.ts"
45
import useMoustaches from "./useMoustaches.ts"

src/hooks/useSync.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// deno-lint-ignore-file no-deprecated-deno-api
22
// ^^ Deno.Command is not implemented for dnt shims yet
3-
import { writeAll } from "deno/streams/write_all.ts"
3+
import { deno } from "../deps.ts"
4+
const { streams: { writeAll } } = deno
45
import { flock } from "../utils/flock.deno.ts"
56
import useDownload from "./useDownload.ts"
67
import usePantry from "./usePantry.ts"

0 commit comments

Comments
 (0)