mirror of
https://github.com/balzack/databag.git
synced 2025-04-22 17:45:18 +00:00
using boilerplate to get started
This commit is contained in:
parent
ef87e355fd
commit
ec9c139d8d
10
app/sdk/jest.config.js
Normal file
10
app/sdk/jest.config.js
Normal file
@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
roots: ['<rootDir>/src'],
|
||||
testMatch: [
|
||||
"**/__tests__/**/*.+(ts|tsx|js)",
|
||||
"**/?(*.)+(spec|test).+(ts|tsx|js)"
|
||||
],
|
||||
transform: {
|
||||
"^.+\\.(ts|tsx)$": "ts-jest"
|
||||
},
|
||||
}
|
@ -1,18 +1,47 @@
|
||||
{
|
||||
"name": "databag",
|
||||
"name": "databag-client-sdk",
|
||||
"version": "0.0.1",
|
||||
"description": "Client SDK for building applications on the Databag network.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/balzack/databag.git/app/sdk"
|
||||
},
|
||||
"description": "Client SDK for Databag Applications",
|
||||
"author": "Roland Osborne <roland.osborne@gmail.com>",
|
||||
"repository": "https://github.com/balzac/databag/app/sdk",
|
||||
"license": "Apache-2.0",
|
||||
"keywords": [
|
||||
"decentralized"
|
||||
"typescript",
|
||||
"databag"
|
||||
],
|
||||
"author": "Pierre Balzack",
|
||||
"license": "Apache-2.0"
|
||||
"main": "./dist/tsc/main.js",
|
||||
"types": "./dist/tsc/main.d.ts",
|
||||
"browser": "./dist/esbuild/browser.js",
|
||||
"bin": {
|
||||
"my-cli-tool": "./dist/esbuild/cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"cli": "ts-node src/cli.ts",
|
||||
"lint": "eslint src/ --ext .js,.jsx,.ts,.tsx",
|
||||
"test": "jest",
|
||||
"clean": "rm -rf dist build package",
|
||||
"ts-node": "ts-node",
|
||||
"docs": "typedoc --entryPoints src/main.ts",
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"build-all": "yarn clean && yarn build && yarn esbuild-node && yarn esbuild-browser",
|
||||
"esbuild-browser": "esbuild src/browser.ts --bundle --minify --sourcemap=external --outfile=dist/esbuild/browser.js",
|
||||
"esbuild-browser:dev": "esbuild src/browser.ts --bundle --outfile=dist/esbuild/browser.js",
|
||||
"esbuild-browser:watch": "esbuild src/browser.ts --bundle --watch --outfile=dist/esbuild/browser.js",
|
||||
"esbuild-node": "esbuild src/cli.ts --bundle --platform=node --minify --sourcemap=external --outfile=dist/esbuild/cli.js",
|
||||
"esbuild-node:dev": "esbuild src/cli.ts --bundle --platform=node --sourcemap=external --outfile=dist/esbuild/cli.js",
|
||||
"esbuild-node:watch": "esbuild src/cli.ts --bundle --platform=node --watch --sourcemap=external --outfile=dist/esbuild/cli.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^27.4.1",
|
||||
"@types/node": "^17.0.26",
|
||||
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
||||
"@typescript-eslint/parser": "^5.20.0",
|
||||
"esbuild": "^0.14.38",
|
||||
"eslint": "^8.14.0",
|
||||
"jest": "27.0.0",
|
||||
"ts-jest": "^27.1.4",
|
||||
"ts-node": "^10.7.0",
|
||||
"typedoc": "^0.22.15",
|
||||
"typescript": "^4.6.3"
|
||||
}
|
||||
}
|
||||
|
10
app/sdk/src/browser.ts
Normal file
10
app/sdk/src/browser.ts
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* This file is the entrypoint of browser builds.
|
||||
* The code executes when loaded in a browser.
|
||||
*/
|
||||
import { foo } from './main'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(window as any).foo = foo // instead of casting window to any, you can extend the Window interface: https://stackoverflow.com/a/43513740/5433572
|
||||
|
||||
console.log('Method "foo" was added to the window object. You can try it yourself by just entering "await foo()"')
|
4
app/sdk/src/cli.ts
Normal file
4
app/sdk/src/cli.ts
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
import { foo } from './main'
|
||||
|
||||
foo()
|
9
app/sdk/src/main.test.ts
Normal file
9
app/sdk/src/main.test.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { greet } from './main'
|
||||
|
||||
test('the data is peanut butter', () => {
|
||||
expect(1).toBe(1)
|
||||
});
|
||||
|
||||
test('greeting', () => {
|
||||
expect(greet('Foo')).toBe('Hello Foo')
|
||||
});
|
10
app/sdk/src/main.ts
Normal file
10
app/sdk/src/main.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export const delayMillis = (delayMs: number): Promise<void> => new Promise(resolve => setTimeout(resolve, delayMs));
|
||||
|
||||
export const greet = (name: string): string => `Hello ${name}`
|
||||
|
||||
export const foo = async (): Promise<boolean> => {
|
||||
console.log(greet('World'))
|
||||
await delayMillis(1000)
|
||||
console.log('done')
|
||||
return true
|
||||
}
|
38
app/sdk/tsconfig.json
Normal file
38
app/sdk/tsconfig.json
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"declaration": true,
|
||||
"strict": true,
|
||||
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
|
||||
"strictNullChecks": true /* Enable strict null checks. */,
|
||||
"strictFunctionTypes": true /* Enable strict checking of function types. */,
|
||||
"noUnusedLocals": true /* Report errors on unused locals. */,
|
||||
"noUnusedParameters": true /* Report errors on unused parameters. */,
|
||||
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
|
||||
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
|
||||
"importHelpers": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"experimentalDecorators": true,
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist/tsc/",
|
||||
"types": [
|
||||
"node",
|
||||
"jest"
|
||||
],
|
||||
"lib": [
|
||||
"ES6",
|
||||
"DOM"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"**/*.test.ts"
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user