commit e8688c0b8f4667178011a758778c20efcd8cc2e1 Author: js <> Date: Tue Aug 22 01:46:01 2023 +0000 Initial commit diff --git a/.gitea/workflows/build-and-publish.yaml b/.gitea/workflows/build-and-publish.yaml new file mode 100644 index 0000000..07fd5c3 --- /dev/null +++ b/.gitea/workflows/build-and-publish.yaml @@ -0,0 +1,36 @@ + +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: Install dependencies + run: npm ci + + - name: Compile TypeScript + run: npm run tsc + + - name: Publish package + run: npm publish diff --git a/.gitea/workflows/build-and-test.yaml b/.gitea/workflows/build-and-test.yaml new file mode 100644 index 0000000..3f97cd5 --- /dev/null +++ b/.gitea/workflows/build-and-test.yaml @@ -0,0 +1,40 @@ + +name: Build and test + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build-and-test: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x, 20.x] + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - 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: Install dependencies + run: npm ci + + - name: Compile TypeScript + run: npm run tsc + + # todo: tests + - name: Run tests + run: exit 0 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