Pārlūkot izejas kodu

Add basic project files.

saul 1 gadu atpakaļ
vecāks
revīzija
9b5ef14292
10 mainītis faili ar 151 papildinājumiem un 130 dzēšanām
  1. 2 0
      .eslintignore
  2. 38 0
      .eslintrc.cjs
  3. 8 129
      .gitignore
  4. 14 0
      .npmignore
  5. 1 1
      README.md
  6. 20 0
      jest.config.cjs
  7. 34 0
      package.json
  8. 1 0
      src/index.ts
  9. 3 0
      test/index.spec.ts
  10. 30 0
      tsconfig.json

+ 2 - 0
.eslintignore

@@ -0,0 +1,2 @@
+node_modules
+dist

+ 38 - 0
.eslintrc.cjs

@@ -0,0 +1,38 @@
+module.exports = {
+	env: {
+		commonjs: true,
+		es2021: true,
+		node: true,
+		jest: true
+	},
+	parserOptions: {
+		ecmaVersion: "latest"
+	},
+	parser: "@typescript-eslint/parser",
+	extends: [
+		"eslint:recommended"
+	],
+	rules: {
+		curly: [1, "all"],
+		// disallow single quotes
+		quotes: [1, "double", { allowTemplateLiterals: true }],
+		// force semi-colons
+		semi: 1,
+		// allow tabs
+		"no-tabs": [0],
+		// use tab indentation
+		indent: [1, "tab", {
+			SwitchCase: 1
+		}],
+		// prevent commar dangles
+		"comma-dangle": [1, "never"],
+		// allow paren-less arrow functions
+		"arrow-parens": 0,
+		// allow async-await
+		"generator-star-spacing": 0,
+		"no-unused-vars": [0, { args: "after-used", vars: "local" }],
+		"no-constant-condition": 0,
+		// allow debugger during development
+		"no-debugger": process.env.NODE_ENV === "production" ? 2 : 0
+	}
+};

+ 8 - 129
.gitignore

@@ -1,130 +1,9 @@
-# Logs
-logs
-*.log
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-lerna-debug.log*
-.pnpm-debug.log*
-
-# Diagnostic reports (https://nodejs.org/api/report.html)
-report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
-
-# Runtime data
-pids
-*.pid
-*.seed
-*.pid.lock
-
-# Directory for instrumented libs generated by jscoverage/JSCover
-lib-cov
-
-# Coverage directory used by tools like istanbul
-coverage
-*.lcov
-
-# nyc test coverage
-.nyc_output
-
-# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
-.grunt
-
-# Bower dependency directory (https://bower.io/)
-bower_components
-
-# node-waf configuration
-.lock-wscript
-
-# Compiled binary addons (https://nodejs.org/api/addons.html)
-build/Release
-
-# Dependency directories
-node_modules/
-jspm_packages/
-
-# Snowpack dependency directory (https://snowpack.dev/)
-web_modules/
-
-# TypeScript cache
-*.tsbuildinfo
-
-# Optional npm cache directory
-.npm
-
-# Optional eslint cache
-.eslintcache
-
-# Optional stylelint cache
-.stylelintcache
-
-# Microbundle cache
-.rpt2_cache/
-.rts2_cache_cjs/
-.rts2_cache_es/
-.rts2_cache_umd/
-
-# Optional REPL history
-.node_repl_history
-
-# Output of 'npm pack'
-*.tgz
-
-# Yarn Integrity file
-.yarn-integrity
-
-# dotenv environment variable files
-.env
-.env.development.local
-.env.test.local
-.env.production.local
-.env.local
-
-# parcel-bundler cache (https://parceljs.org/)
-.cache
-.parcel-cache
-
-# Next.js build output
-.next
-out
-
-# Nuxt.js build / generate output
-.nuxt
+node_modules
+build
 dist
-
-# Gatsby files
-.cache/
-# Comment in the public line in if your project uses Gatsby and not Next.js
-# https://nextjs.org/blog/next-9-1#public-directory-support
-# public
-
-# vuepress build output
-.vuepress/dist
-
-# vuepress v2.x temp and cache directory
-.temp
-.cache
-
-# Docusaurus cache and generated files
-.docusaurus
-
-# Serverless directories
-.serverless/
-
-# FuseBox cache
-.fusebox/
-
-# DynamoDB Local files
-.dynamodb/
-
-# TernJS port file
-.tern-port
-
-# Stores VSCode versions used for testing VSCode extensions
-.vscode-test
-
-# yarn v2
-.yarn/cache
-.yarn/unplugged
-.yarn/build-state.yml
-.yarn/install-state.gz
-.pnp.*
+.docs
+.coverage
+node_modules
+package-lock.json
+yarn.lock
+.vscode

+ 14 - 0
.npmignore

@@ -0,0 +1,14 @@
+node_modules
+build
+.docs
+.coverage
+node_modules
+package-lock.json
+yarn.lock
+.vscode
+.gitignore
+.eslintrc.cjs
+.eslintignore
+jest.config.cjs
+tsconfig.json
+test

+ 1 - 1
README.md

@@ -1,2 +1,2 @@
 # node-ollama
-Iterface with a ollama instance over HTTP.
+Iterface with an ollama instance over HTTP.

+ 20 - 0
jest.config.cjs

@@ -0,0 +1,20 @@
+/** @type {import('ts-jest').JestConfigWithTsJest} */
+module.exports = {
+	preset: "ts-jest",
+	testEnvironment: "node",
+	maxWorkers: 1,
+	extensionsToTreatAsEsm: [".ts"],
+	moduleNameMapper: {
+		"^(\\.{1,2}/.*)\\.js$": "$1"
+	},
+	transform: {
+		// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
+		// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
+		"^.+\\.tsx?$": [
+			"ts-jest",
+			{
+				useESM: true
+			}
+		]
+	}
+};

+ 34 - 0
package.json

@@ -0,0 +1,34 @@
+{
+  "type": "module",
+  "name": "ollama",
+  "version": "0.1.0",
+  "description": "Iterface with an ollama instance over HTTP.",
+  "main": "dist/index.js",
+  "types": "dist/index.d.ts",
+  "scripts": {
+    "test": "jest --config=jest.config.cjs ./test/*",
+    "build": "mkdir -p dist && touch dist/cleanup && rm dist/* && tsc -b",
+    "lint": "eslint ./src/* ./test/*",
+    "prepublishOnly": "npm run build"
+  },
+  "repository": {
+    "type": "git",
+    "url": "ssh://git@github.com:saul-jb/node-ollama.git"
+  },
+  "author": "Saul Boyd",
+  "license": "GPL-3.0-or-later",
+  "devDependencies": {
+    "@swc/core": "^1.3.14",
+    "@types/jest": "^29.2.2",
+    "@typescript-eslint/eslint-plugin": "^5.42.1",
+    "@typescript-eslint/parser": "^5.42.1",
+    "eslint": "^8.29.0",
+    "eslint-plugin-jest": "^27.1.4",
+    "jest": "^29.3.0",
+    "ts-jest": "^29.0.3",
+    "typescript": "^4.8.4"
+  },
+  "dependencies": {
+    "node-fetch": "^3.3.2"
+  }
+}

+ 1 - 0
src/index.ts

@@ -0,0 +1 @@
+// Export your project files here.

+ 3 - 0
test/index.spec.ts

@@ -0,0 +1,3 @@
+describe("Empty test", () => {
+	it("runs", () => {});
+});

+ 30 - 0
tsconfig.json

@@ -0,0 +1,30 @@
+{
+	"compilerOptions": {
+		"noImplicitAny": false,
+		"noImplicitThis": true,
+		"strictNullChecks": true,
+		"esModuleInterop": true,
+		"declaration": true,
+		"declarationMap": true,
+		"skipLibCheck": true,
+		"strict": true,
+		"forceConsistentCasingInFileNames": true,
+		"moduleResolution": "node",
+		"module": "ES2022",
+		"outDir": "./dist",
+		"target": "ES6"
+	},
+
+	"ts-node": {
+		"swc": true,
+		"esm": true
+	},
+
+	"include": [
+		"./src/**/*.ts"
+	],
+
+	"exclude": [
+		"node_modules"
+	]
+}