From acf02696ce8e9c62e59b13981ce395007a842e53 Mon Sep 17 00:00:00 2001 From: js <> Date: Mon, 21 Aug 2023 02:02:50 +0000 Subject: [PATCH] Initial commit --- .gitea/workflows/publish.yaml | 30 ++++++++++++++++++++++++++++++ .gitignore | 2 ++ package-lock.json | 29 +++++++++++++++++++++++++++++ package.json | 23 +++++++++++++++++++++++ readme.md | 30 ++++++++++++++++++++++++++++++ src/index.ts | 4 ++++ tsconfig.json | 14 ++++++++++++++ 7 files changed, 132 insertions(+) create mode 100644 .gitea/workflows/publish.yaml create mode 100644 .gitignore create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 readme.md create mode 100644 src/index.ts create mode 100644 tsconfig.json diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml new file mode 100644 index 0000000..d155937 --- /dev/null +++ b/.gitea/workflows/publish.yaml @@ -0,0 +1,30 @@ + +name: Build and publish + +on: + workflow_dispatch: { } + # push: + # branches: + # - master + +jobs: + build-and-publish: + runs-on: ubuntu-latest + env: + NPM_PUBLISH_TOKEN: ${{ secrets.NPM_TOKEN }} + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Use Node.js 20 + uses: actions/setup-node@v3 + with: + node-version: 20 + + - name: Login to package registry + run: | + npm config set @:registry https://gitea.jbrumond.me/api/packages//npm/ + npm config set -- '//gitea.jbrumond.me/api/packages//npm/:_authToken' "$NPM_PUBLISH_TOKEN" + + - name: Publish package + run: npm publish diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dd87e2d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +build diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..b8d09b5 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,29 @@ +{ + "name": "@templates/typescript-library", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@templates/typescript-library", + "version": "1.0.0", + "license": "ISC", + "devDependencies": { + "typescript": "^5.1.3" + } + }, + "node_modules/typescript": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", + "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..ded3a6d --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "@templates/typescript-library", + "version": "1.0.0", + "description": "Template project for creating new TypeScript library packages", + "main": "build/index.js", + "types": "build/index.d.ts", + "scripts": { + "tsc": "tsc --build", + "clean": "rm -rf ./build" + }, + "publishConfig": { + "registry": "https://gitea.jbrumond.me/api/packages/templates/npm/" + }, + "repository": { + "type": "git", + "url": "https://gitea.jbrumond.me/templates/typescript-library.git" + }, + "author": "James Brumond ", + "license": "ISC", + "devDependencies": { + "typescript": "^5.1.3" + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..7389046 --- /dev/null +++ b/readme.md @@ -0,0 +1,30 @@ + +Template project for creating new TypeScript library packages + +--- + +## Get Started + +### Pull down the code + +```bash +git init +git pull https://gitea.jbrumond.me/templates/typescript-library.git master +``` + +### Update configuration + +- In `package.json`, update any fields like `name`, `description`, `repository`, etc. +- In `.gitea/workflows/publish.yaml`, update `` placeholders + + + +## Building + +```bash +npm run tsc +``` + + + + diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..4fa933d --- /dev/null +++ b/src/index.ts @@ -0,0 +1,4 @@ + +export function hello() : string { + return 'hello'; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..9c4c705 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,14 @@ +{ + "include": [ + "src/**/*.ts" + ], + "compilerOptions": { + "rootDir": "./src", + "outDir": "./build", + "target": "ES2022", + "moduleResolution": "NodeNext", + "module": "CommonJS", + "declaration": true, + "sourceMap": true + } +} \ No newline at end of file