-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ardriveapp/cleanup
chore(cleanup): some small updates based on learnings
- Loading branch information
Showing
13 changed files
with
375 additions
and
401 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ src/**/*.test.ts | |
lib | ||
**/*.cjs | ||
**/*.mjs | ||
examples |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
* @ardriveapp/services | ||
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,111 @@ | ||
# node-sdk-template | ||
|
||
Hello developer, welcome to this SDK!! | ||
This is the home of [INSERT SDK NAME] SDK. This SDK provides functionality for [SHORT DESCRIPTION HERE] available for both NodeJS and Web environments. | ||
|
||
## Table of Contents | ||
|
||
- [Installation](#installation) | ||
- [Quick Start](#quick-start) | ||
- [Usage](#usage) | ||
- [NodeJS Environments](#node) | ||
- [Web Environments](#web) | ||
- [Typescript](#typescript) | ||
- [APIs](#apis) | ||
- [Examples](./examples) | ||
- [Developers](#developers) | ||
- [Requirements](#requirements) | ||
- [Setup & Build](#setup--build) | ||
- [Testing](#testing) | ||
- [Linting and Formatting](#linting--formatting) | ||
- [Architecture](#architecture) | ||
- [Contributing](./CONTRIBUTING.md) | ||
|
||
## Installation | ||
|
||
```shell | ||
npm install @ardrive/INSERT-SDK-NAME | ||
``` | ||
|
||
or | ||
|
||
```shell | ||
yarn add @ardrive/INSERT-SDK-NAME | ||
``` | ||
|
||
## Quick Start | ||
|
||
```typescript | ||
// INSERT A SHORT EXAMPLE OF HOW TO SETUP AND USE THE SDK | ||
``` | ||
|
||
## Usage | ||
|
||
The SDK is provided in both CommonJS and ESM formats, and it's compatible with bundlers such as Webpack, Rollup, and ESbuild. Utilize the appropriately named exports provided by this SDK's [package.json] based on your project's configuration. Refer to the [examples] directory to see how to use the SDK in various environments. | ||
|
||
### Web | ||
|
||
#### Bundlers (Webpack, Rollup, ESbuild, etc.) | ||
|
||
```javascript | ||
// INSERT EXAMPLE FOR USING IN ESM PROJECT | ||
``` | ||
|
||
#### Browser | ||
|
||
```javascript | ||
// INSERT EXAMPLE FOR USING IN BROWSER PROJECT | ||
``` | ||
|
||
### Node | ||
|
||
```javascript | ||
// INSERT EXAMPLE FOR USING IN CJS PROJECT | ||
``` | ||
|
||
### Typescript | ||
|
||
The SDK provides TypeScript types. When you import the SDK in a TypeScript project: | ||
|
||
Types are exported from `./lib/types/[node/web]/index.d.ts` and should be automatically recognized, offering benefits such as type-checking and autocompletion. | ||
|
||
## APIs | ||
|
||
[INSERT A LIST OF ALL THE APIS PROVIDED BY THE SDK AND HOW TO USE THEM] | ||
|
||
## Developers | ||
|
||
### Requirements | ||
|
||
- `nvm` | ||
- `node` (>= 18) | ||
- `yarn` | ||
|
||
### Setup & Build | ||
|
||
- `yarn install` - installs dependencies | ||
- `yarn build` - builds web/node/bundled outputs | ||
|
||
### Testing | ||
|
||
- `yarn test` - runs integration tests | ||
- `yarn example:web` - opens up the example web page | ||
- `yarn example:cjs` - runs example CJS node script | ||
- `yarn example:esm` - runs example ESM node script | ||
|
||
### Linting & Formatting | ||
|
||
- `yarn lint:check` - checks for linting errors | ||
- `yarn lint:fix` - fixes linting errors | ||
- `yarn format:check` - checks for formatting errors | ||
- `yarn format:fix` - fixes formatting errors | ||
|
||
### Architecture | ||
|
||
- Code to interfaces. | ||
- Prefer type safety over runtime safety. | ||
- Prefer composition over inheritance. | ||
- Prefer integration tests over unit tests. | ||
|
||
For more information on how to contribute, please see [CONTRIBUTING.md]. | ||
|
||
<!-- ADD ALL LINK REFERENCES BELOW --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { build } from 'esbuild'; | ||
import { polyfillNode } from 'esbuild-plugin-polyfill-node'; | ||
|
||
const bundle = () => { | ||
console.log('Building web bundle esm.'); | ||
const result = build({ | ||
entryPoints: ['./src/index.ts'], | ||
bundle: true, | ||
platform: 'browser', | ||
target: ['esnext'], | ||
format: 'esm', | ||
globalName: 'turbo', | ||
plugins: [ | ||
polyfillNode({ | ||
polyfills: { | ||
crypto: true, | ||
}, | ||
}), | ||
], | ||
tsconfig: './tsconfig.web.json', | ||
outfile: './bundles/web.bundle.min.js', | ||
}) | ||
.catch((e) => { | ||
console.log(e); | ||
process.exit(1); | ||
}) | ||
.then(() => { | ||
console.log('Successfully built web bundle.'); | ||
}); | ||
}; | ||
|
||
bundle(); | ||
|
||
export { bundle }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"outDir": "./lib/cjs" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationMap": true, | ||
"outDir": "./lib/types", | ||
"emitDeclarationOnly": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["src/web", "src/common", "src/utils"], | ||
"compilerOptions": { | ||
"outDir": "./lib/web" | ||
} | ||
} |
Oops, something went wrong.