Skip to content

Commit 0c93447

Browse files
Merge pull request #6 from scrapfly/deno
Deno rework
2 parents 6caab7a + e5a1a9f commit 0c93447

36 files changed

+3133
-10766
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true
8+
9+
[*.md]
10+
insert_final_newline = false
11+
trim_trailing_whitespace = false
12+
13+
[*.{js,json,ts,mts,yml,yaml}]
14+
indent_size = 2
15+
indent_style = space

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/nodejs.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/publish.yaml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
name: Publish to NPM
23

34
on:
@@ -11,18 +12,26 @@ jobs:
1112
runs-on: ubuntu-latest
1213

1314
steps:
14-
- uses: actions/checkout@v2
15-
- uses: volta-cli/action@v1
16-
- run: npm ci --no-audit
17-
- run: npm run lint --if-present
18-
- run: npm test
19-
- run: npm run build --if-present
20-
env:
21-
CI: true
22-
- name: Setup .npmrc file to publish to npm
23-
run: |
24-
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
25-
env:
26-
NPM_TOKEN: ${{secrets.NPM_AUTOMATION_TOKEN}}
27-
- name: Publish to NPM
28-
run: npm publish
15+
- name: Clone repository
16+
uses: actions/checkout@v3
17+
18+
- name: Install Deno
19+
uses: denoland/setup-deno@v1
20+
with:
21+
deno-version: v1.x
22+
23+
- name: Run Deno build script
24+
run: deno task build-npm
25+
26+
- name: Navigate to npm directory
27+
run: cd ./npm
28+
29+
- name: Setup .npmrc file to publish to npm
30+
run: |
31+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
32+
env:
33+
NPM_TOKEN: ${{ secrets.NPM_AUTOMATION_TOKEN }}
34+
35+
- name: Publish to NPM
36+
run: npm publish --dry-run
37+
working-directory: ./npm

.github/workflows/run-tests.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Run tests
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Clone repository
14+
uses: actions/checkout@v3
15+
16+
- name: Install Deno
17+
uses: denoland/setup-deno@v1
18+
with:
19+
deno-version: v1.x
20+
21+
- name: Run Deno Test
22+
run: deno task test
23+
24+
- name: Build JSR
25+
run: deno task build-jsr
26+
27+
- name: Build NPM
28+
run: deno task build-npm

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
node_modules
2-
coverage
2+
coverage
3+
scripts
4+
npm
5+
dev
6+
cov_profile
7+
.vscode
8+
.history

.prettierignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.md

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Scrapfly SDK
22

3-
`npm install scrapfly-sdk`
3+
`npm install scrapfly-sdk`
4+
`deno add jsr:@scrapfly/scrapfly-sdk`
5+
`bun jsr add @scrapfly/scrapfly-sdk`
46

5-
Typescript/NodeJS SDK for [Scrapfly.io](https://scrapfly.io/) web scraping API which allows to:
7+
Typescript/Javascript SDK for [Scrapfly.io](https://scrapfly.io/) web scraping API which allows to:
68

79
- Scrape the web without being blocked.
810
- Use headless browsers to access Javascript-powered page data.
@@ -11,14 +13,21 @@ Typescript/NodeJS SDK for [Scrapfly.io](https://scrapfly.io/) web scraping API w
1113

1214
For web scraping guides see [our blog](https://scrapfly.io/blog/) and [#scrapeguide](https://scrapfly.io/blog/tag/scrapeguide/) tag for how to scrape specific targets.
1315

16+
The SDK is distributed through:
17+
- [npmjs.com/package/scrapfly-sdk](https://www.npmjs.com/package/scrapfly-sdk)
18+
- [jsr.io/@scrapfly/scrapfly-sdk](https://jsr.io/@scrapfly/scrapfly-sdk)
19+
1420
## Quick Intro
1521

1622
1. Register a [Scrapfly account for free](https://scrapfly.io/register)
1723
2. Get your API Key on [scrapfly.io/dashboard](https://scrapfly.io/dashboard)
1824
3. Start scraping: 🚀
1925

2026
```javascript
27+
// node or bun:
2128
import { ScrapflyClient, ScrapeConfig } from 'scrapfly-sdk';
29+
// deno:
30+
import { ScrapflyClient, ScrapeConfig } from 'jsr:@scrapfly/scrapfly-sdk';
2231

2332
const key = 'YOUR SCRAPFLY KEY';
2433
const client = new ScrapflyClient({ key });
@@ -70,15 +79,25 @@ new ScrapeConfig({
7079

7180
## Development
7281

73-
Install and setup environment:
74-
75-
```shell
76-
$ npm install
77-
```
78-
79-
Build and test:
80-
81-
```shell
82-
$ npm run build
83-
$ npm run test
84-
```
82+
This is a Deno Typescript project that builds to NPM through [DNT](https://github.com/denoland/dnt).
83+
84+
- `/src` directory contains all of the source code with `main.ts` being the entry point.
85+
- `__tests__` directory contains tests for the source code.
86+
- `deno.json` contains meta information
87+
- `build.ts` is the build script that builds the project to nodejs ESM package.
88+
- `/npm` directory will be produced when `built.ts` is executed for building node package.
89+
90+
```bash
91+
# make modifications and run tests
92+
$ deno task test
93+
# format
94+
$ deno fmt
95+
# lint
96+
$ deno lint
97+
# publish JSR:
98+
$ deno publish
99+
# build NPM package:
100+
$ deno build-npm
101+
# publish NPM:
102+
$ cd npm && npm publish
103+
```

0 commit comments

Comments
 (0)