From 08a2e17eb48427fb32e1f93aeedd6f617f557c41 Mon Sep 17 00:00:00 2001 From: Thada Wangthammang Date: Sun, 21 Jan 2024 11:43:07 +0700 Subject: [PATCH 1/4] feat: add main package for entry of nammatham package --- examples/azure-functions/package.json | 4 +- examples/azure-functions/src/main.ts | 2 +- examples/azure-functions/src/nammatham.ts | 3 +- package.json | 2 +- packages/express/src/middleware.ts | 2 +- packages/main/README.md | 134 ++++++++++++++++++++++ packages/main/package.json | 34 ++++++ packages/main/src/main.ts | 3 + pnpm-lock.yaml | 22 ++-- 9 files changed, 190 insertions(+), 16 deletions(-) create mode 100644 packages/main/README.md create mode 100644 packages/main/package.json create mode 100644 packages/main/src/main.ts diff --git a/examples/azure-functions/package.json b/examples/azure-functions/package.json index 1e97d8ed..d96c0616 100644 --- a/examples/azure-functions/package.json +++ b/examples/azure-functions/package.json @@ -12,9 +12,7 @@ "author": "Thada Wangthammang", "license": "MIT", "dependencies": { - "@nammatham/core": "2.0.0-alpha.8", - "@nammatham/express": "2.0.0-alpha.8", - "@nammatham/azure-functions": "2.0.0-alpha.8", + "nammatham": "2.0.0-alpha.8", "@azure/functions": "^4.1.0" }, "devDependencies": { diff --git a/examples/azure-functions/src/main.ts b/examples/azure-functions/src/main.ts index 0b790383..02c03d4c 100644 --- a/examples/azure-functions/src/main.ts +++ b/examples/azure-functions/src/main.ts @@ -1,4 +1,4 @@ -import { expressPlugin } from '@nammatham/express'; +import { expressPlugin } from 'nammatham'; import blob from './functions/blob'; import hello from './functions/hello'; import { app } from './nammatham'; diff --git a/examples/azure-functions/src/nammatham.ts b/examples/azure-functions/src/nammatham.ts index e4ec4298..280c2100 100644 --- a/examples/azure-functions/src/nammatham.ts +++ b/examples/azure-functions/src/nammatham.ts @@ -1,5 +1,4 @@ -import { initNammatham } from '@nammatham/core'; -import { AzureFunctionsAdapter } from '@nammatham/azure-functions'; +import { initNammatham, AzureFunctionsAdapter } from 'nammatham'; const n = initNammatham.create(new AzureFunctionsAdapter()); n.func; diff --git a/package.json b/package.json index 4874d38f..fe2c2197 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "test": "vitest", "test:coverage": "vitest run --coverage", - "dev": "nx run @nammatham/core:build && nx run-many -t dev --projects=@nammatham/* --parallel=5", + "dev": "nx run @nammatham/core:build && nx run-many -t dev --projects nammatham @nammatham/* --parallel=5", "pre-local": "tsx ./scripts/pre-local.ts", "post-local": "tsx ./scripts/post-local.ts", "release": "run-s build releaseOnly", diff --git a/packages/express/src/middleware.ts b/packages/express/src/middleware.ts index 44179d8e..25a959c4 100644 --- a/packages/express/src/middleware.ts +++ b/packages/express/src/middleware.ts @@ -11,7 +11,7 @@ interface NammathamAppRequestOption extends NammathamHttpHandlerOption { res: express.Response; } -export function trimSlash(str: string) { +function trimSlash(str: string) { return str.replace(/^\/|\/$/g, ''); } diff --git a/packages/main/README.md b/packages/main/README.md new file mode 100644 index 00000000..06c01130 --- /dev/null +++ b/packages/main/README.md @@ -0,0 +1,134 @@ +

+ Nammatham Logo +

+ +

+Type-safe Serverless Library for Azure Functions and friends +

+ +

npm version npm download

+ + +> 🚧 Alpha Stage: Internal Use Only 🚧 +> +> Please note that Nammatham v2 is currently in its Alpha stage and is intended for internal use only. As we actively develop and refine the platform, be aware that the API may undergo frequent changes. +> +> Note: [Nammatham v1](https://www.npmjs.com/package/nammatham) is currently in maintenance mode. no new features are actively being developed + +| Version | Status | Azure Functions Node.js | Branch | Build Status | +| ------- | ----------- | ----------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| v1.x | Maintenance | v3.x | [v1.x][v1.x] | [![Build & Test](https://github.com/thaitype/nammatham/actions/workflows/test.yml/badge.svg)](https://github.com/thaitype/nammatham/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/mildronize/nammatham/branch/main/graph/badge.svg?token=Y7ZMDKFPAN)](https://codecov.io/gh/mildronize/nammatham) | +| v2.x | Alpha | v4.x | [main][main] | [Tracking v2 Roadmap](https://github.com/thaitype/nammatham/issues?q=is%3Aissue+is%3Aopen+label%3Av2-blocker) | + +[v1.x]: https://github.com/thaitype/nammatham/tree/v1.x +[main]: https://github.com/thaitype/nammatham/tree/main + + +## Description +Nammatham (นามธรรม in Thai, pronounced `/naam ma tham/`, means **abstract** in Thai) is Azure Function Nodejs. + +## Getting Started for Azure Functions + +You can see [examples](examples) or follow the minimal app getting started below: + +```typescript +import { AzureFunctionsAdapter } from "@nammatham/azure-functions"; +import { initNammatham } from "@nammatham/core"; +import { expressPlugin } from "@nammatham/express"; + +const n = initNammatham.create(new AzureFunctionsAdapter()); +const func = n.func; +const app = n.app; + +const helloFunction = func + .httpGet('hello', { + route: 'hello-world', + }) + .handler(async ({trigger, context}) => { + context.log('HTTP trigger function processed a request.'); + context.debug(`Http function processed request for url "${trigger.url}"`); + const name = trigger.query.get('name') || (await trigger.text()) || 'world'; + return { body: `Hello, ${name}!` }; + }); + +app.addFunctions(helloFunction); +app.register(expressPlugin()); +app.start(); +``` + +Then edit `package.json` like this; + +```json +{ + "main": "dist/src/main.js", + "scripts": { + "dev": "cross-env NAMMATHAM_ENV=development tsx watch src/main.ts", + "start": "tsc && func start" + } +} +``` + +Run Dev Server on locally, (For dev server use `tsx watch` for reloading run dev server using `express` ) + +``` +npm run dev +``` + +Run Azure Functions on locally (Using Official Azure Functions Node.js) + +``` +npm start +``` + + +## Nammatham Packages + +- [core][@nammatham/core], Nammatham Core package for initializing Nammatham App + +### Available Adatpers + +- [azure-functions][@nammatham/azure-functions], Azure Functions Adapter for Nammatham + +### Available Plugins + +- [express][@nammatham/express], Express Plugin for run server. Nammatham itself doesn't contain any server, enabling this plugin to provide better DX than the original server e.g. Azure Functions Runtime +- [trpc-azure-functions][@nammatham/trpc-azure-functions], provide [tRPC](https://trpc.io/) Plugin for Azure Functions, inclduing [express][@nammatham/express] server for local testing. + +[@nammatham/core]: packages/core +[@nammatham/azure-functions]: packages/azure-functions +[@nammatham/express]: packages/express +[@nammatham/trpc-azure-functions]: packages/trpc-azure-functions + + +## Talks +Empowering TypeScript on Azure Functions with Nammatham, Azure Open Source Day @ Microsoft Thailand, 25 Mar 2023 +[![](docs/imgs/azure-open-source-day-2023.png)](https://www.youtube.com/watch?v=n6B4-5Lt2h0) (Thai speech, subtitle will added later) +- Slides: https://docs.google.com/presentation/d/1WUIXaUxXaiixZ2bgGCfx-f4Gdrmjl4RfbwKaEfAC6t4/edit?usp=sharing + + + + +## Local Dev Setup + +```bash +# Install dependencies +pnpm install +# Before dev (Update workspace to local dependencies) +pnpm pre-local && pnpm install +# While dev +pnpm dev +# After dev before submitting PRs (Update workspace to actual dependencies), `pnpm install` for making sure lockfile is correct. +pnpm post-local && pnpm install +# Release package +pnpm release +``` + +## Inspiration +- [Azure Functions .NET](https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-cli-csharp?tabs=azure-cli%2Cin-process) +- [inversify-express-utils](https://github.com/inversify/inversify-express-utils) - We use inversify as a Dependency Injection Tool. +- [Nestjs](https://nestjs.com/) +- [typestack/routing-controllers](https://github.com/typestack/routing-controllers) +- [azure-middleware](https://github.com/emanuelcasco/azure-middleware) - Azure Functions Middleware Libray + +## Author +- Thada Wangthammang, Software Engineer, Thailand \ No newline at end of file diff --git a/packages/main/package.json b/packages/main/package.json new file mode 100644 index 00000000..8c64c264 --- /dev/null +++ b/packages/main/package.json @@ -0,0 +1,34 @@ +{ + "name": "nammatham", + "version": "2.0.0-alpha.8", + "description": "Type-safe Serverless Library for Azure Functions and friends", + "main": "dist/main.js", + "types": "dist/main.d.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "prepublishOnly": "npm run build", + "build": "tsup src/main.ts --dts", + "format": "prettier -w src", + "lint": "tsc --noEmit && eslint ./src && prettier -c src", + "lint:fix": "eslint --fix ./src && prettier -w src", + "dev": "nodemon --watch src --ext ts --exec 'npm run build'" + }, + "keywords": [ + "azure-functions", + "azure" + ], + "author": "Thada Wangthammang", + "license": "MIT", + "dependencies": { + "@nammatham/core": "2.0.0-alpha.8", + "@nammatham/azure-functions": "2.0.0-alpha.8", + "@nammatham/express": "2.0.0-alpha.8" + }, + "repository": { + "type": "git", + "url": "https://github.com/thaitype/nammatham.git" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org/" + } +} \ No newline at end of file diff --git a/packages/main/src/main.ts b/packages/main/src/main.ts new file mode 100644 index 00000000..0ac3ec6e --- /dev/null +++ b/packages/main/src/main.ts @@ -0,0 +1,3 @@ +export * from '@nammatham/core'; +export * from '@nammatham/express'; +export * from '@nammatham/azure-functions'; \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 73cc0c05..ea7cf318 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -71,15 +71,9 @@ importers: '@azure/functions': specifier: ^4.1.0 version: 4.1.0 - '@nammatham/azure-functions': - specifier: 2.0.0-alpha.8 - version: link:../../packages/azure-functions - '@nammatham/core': - specifier: 2.0.0-alpha.8 - version: link:../../packages/core - '@nammatham/express': + nammatham: specifier: 2.0.0-alpha.8 - version: link:../../packages/express + version: link:../../packages/main devDependencies: cross-env: specifier: ^7.0.3 @@ -323,6 +317,18 @@ importers: specifier: ^4.18.2 version: 4.18.2 + packages/main: + dependencies: + '@nammatham/azure-functions': + specifier: 2.0.0-alpha.8 + version: link:../azure-functions + '@nammatham/core': + specifier: 2.0.0-alpha.8 + version: link:../core + '@nammatham/express': + specifier: 2.0.0-alpha.8 + version: link:../express + packages/trpc-azure-functions: dependencies: '@azure/functions': From 4ef0e28e9dcbae6cf4b84ce05b9ef0bcb0900f06 Mon Sep 17 00:00:00 2001 From: Thada Wangthammang Date: Sun, 21 Jan 2024 23:10:07 +0700 Subject: [PATCH 2/4] feat: examples use `nammatham` packages --- examples/azure-functions-minimal/package.json | 4 +- examples/azure-functions-minimal/src/main.ts | 4 +- .../package.json | 4 +- .../azure-functions-timer-trigger/src/main.ts | 2 +- .../src/nammatham.ts | 3 +- .../package.json | 4 +- .../src/main.ts | 2 +- .../src/nammatham.ts | 3 +- .../azure-functions-with-test/package.json | 4 +- .../azure-functions-with-test/src/main.ts | 2 +- .../src/nammatham.ts | 4 +- .../azure-functions-with-trpc/package.json | 4 +- .../src/nammatham.ts | 3 +- packages/main/package.json | 29 +++++++++- packages/main/src/azure-functions.ts | 1 + packages/main/src/core.ts | 1 + packages/main/src/express.ts | 1 + pnpm-lock.yaml | 54 +++++-------------- 18 files changed, 57 insertions(+), 72 deletions(-) create mode 100644 packages/main/src/azure-functions.ts create mode 100644 packages/main/src/core.ts create mode 100644 packages/main/src/express.ts diff --git a/examples/azure-functions-minimal/package.json b/examples/azure-functions-minimal/package.json index d619e402..09560fd4 100644 --- a/examples/azure-functions-minimal/package.json +++ b/examples/azure-functions-minimal/package.json @@ -12,9 +12,7 @@ "author": "Thada Wangthammang", "license": "MIT", "dependencies": { - "@nammatham/core": "2.0.0-alpha.8", - "@nammatham/express": "2.0.0-alpha.8", - "@nammatham/azure-functions": "2.0.0-alpha.8", + "nammatham": "2.0.0-alpha.8", "@azure/functions": "^4.1.0" }, "devDependencies": { diff --git a/examples/azure-functions-minimal/src/main.ts b/examples/azure-functions-minimal/src/main.ts index e9e906bc..229645e1 100644 --- a/examples/azure-functions-minimal/src/main.ts +++ b/examples/azure-functions-minimal/src/main.ts @@ -1,6 +1,4 @@ -import { AzureFunctionsAdapter } from "@nammatham/azure-functions"; -import { initNammatham } from "@nammatham/core"; -import { expressPlugin } from "@nammatham/express"; +import { AzureFunctionsAdapter, initNammatham, expressPlugin } from "nammatham"; const n = initNammatham.create(new AzureFunctionsAdapter()); const func = n.func; diff --git a/examples/azure-functions-timer-trigger/package.json b/examples/azure-functions-timer-trigger/package.json index 3ea06846..08aa8b9d 100644 --- a/examples/azure-functions-timer-trigger/package.json +++ b/examples/azure-functions-timer-trigger/package.json @@ -12,9 +12,7 @@ "author": "Thada Wangthammang", "license": "MIT", "dependencies": { - "@nammatham/core": "2.0.0-alpha.8", - "@nammatham/express": "2.0.0-alpha.8", - "@nammatham/azure-functions": "2.0.0-alpha.8", + "nammatham": "2.0.0-alpha.8", "@azure/functions": "^4.1.0" }, "devDependencies": { diff --git a/examples/azure-functions-timer-trigger/src/main.ts b/examples/azure-functions-timer-trigger/src/main.ts index f84cf505..e989672b 100644 --- a/examples/azure-functions-timer-trigger/src/main.ts +++ b/examples/azure-functions-timer-trigger/src/main.ts @@ -1,4 +1,4 @@ -import { expressPlugin } from '@nammatham/express'; +import { expressPlugin } from 'nammatham'; import simpleTimer from './functions/simple-timer'; import { app } from './nammatham'; diff --git a/examples/azure-functions-timer-trigger/src/nammatham.ts b/examples/azure-functions-timer-trigger/src/nammatham.ts index e4ec4298..280c2100 100644 --- a/examples/azure-functions-timer-trigger/src/nammatham.ts +++ b/examples/azure-functions-timer-trigger/src/nammatham.ts @@ -1,5 +1,4 @@ -import { initNammatham } from '@nammatham/core'; -import { AzureFunctionsAdapter } from '@nammatham/azure-functions'; +import { initNammatham, AzureFunctionsAdapter } from 'nammatham'; const n = initNammatham.create(new AzureFunctionsAdapter()); n.func; diff --git a/examples/azure-functions-with-inversify/package.json b/examples/azure-functions-with-inversify/package.json index dab5405f..40513e8d 100644 --- a/examples/azure-functions-with-inversify/package.json +++ b/examples/azure-functions-with-inversify/package.json @@ -14,9 +14,7 @@ "dependencies": { "@azure/functions": "^4.1.0", "@di-extra/inversify": "^0.2.0", - "@nammatham/azure-functions": "2.0.0-alpha.8", - "@nammatham/core": "2.0.0-alpha.8", - "@nammatham/express": "2.0.0-alpha.8", + "nammatham": "2.0.0-alpha.8", "inversify": "^6.0.2", "reflect-metadata": "^0.2.1" }, diff --git a/examples/azure-functions-with-inversify/src/main.ts b/examples/azure-functions-with-inversify/src/main.ts index 8b06f866..b455628e 100644 --- a/examples/azure-functions-with-inversify/src/main.ts +++ b/examples/azure-functions-with-inversify/src/main.ts @@ -1,5 +1,5 @@ import 'reflect-metadata'; -import { expressPlugin } from '@nammatham/express'; +import { expressPlugin } from 'nammatham'; import hello from './functions/hello'; import { app } from './nammatham'; diff --git a/examples/azure-functions-with-inversify/src/nammatham.ts b/examples/azure-functions-with-inversify/src/nammatham.ts index e4ec4298..280c2100 100644 --- a/examples/azure-functions-with-inversify/src/nammatham.ts +++ b/examples/azure-functions-with-inversify/src/nammatham.ts @@ -1,5 +1,4 @@ -import { initNammatham } from '@nammatham/core'; -import { AzureFunctionsAdapter } from '@nammatham/azure-functions'; +import { initNammatham, AzureFunctionsAdapter } from 'nammatham'; const n = initNammatham.create(new AzureFunctionsAdapter()); n.func; diff --git a/examples/azure-functions-with-test/package.json b/examples/azure-functions-with-test/package.json index 93181dab..6d840fb7 100644 --- a/examples/azure-functions-with-test/package.json +++ b/examples/azure-functions-with-test/package.json @@ -13,9 +13,7 @@ "license": "MIT", "dependencies": { "@azure/functions": "^4.1.0", - "@nammatham/azure-functions": "2.0.0-alpha.8", - "@nammatham/core": "2.0.0-alpha.8", - "@nammatham/express": "2.0.0-alpha.8" + "nammatham": "2.0.0-alpha.8" }, "devDependencies": { "cross-env": "^7.0.3", diff --git a/examples/azure-functions-with-test/src/main.ts b/examples/azure-functions-with-test/src/main.ts index a29a41bd..9857a2e1 100644 --- a/examples/azure-functions-with-test/src/main.ts +++ b/examples/azure-functions-with-test/src/main.ts @@ -1,4 +1,4 @@ -import { expressPlugin } from '@nammatham/express'; +import { expressPlugin } from 'nammatham'; import hello from './functions/hello'; import { app } from './nammatham'; diff --git a/examples/azure-functions-with-test/src/nammatham.ts b/examples/azure-functions-with-test/src/nammatham.ts index 31e14679..29502804 100644 --- a/examples/azure-functions-with-test/src/nammatham.ts +++ b/examples/azure-functions-with-test/src/nammatham.ts @@ -1,5 +1,5 @@ -import { initNammatham } from '@nammatham/core'; -import { AzureFunctionsAdapter } from '@nammatham/azure-functions'; +import { initNammatham } from 'nammatham'; +import { AzureFunctionsAdapter } from 'nammatham'; const n = initNammatham.create(new AzureFunctionsAdapter()); diff --git a/examples/azure-functions-with-trpc/package.json b/examples/azure-functions-with-trpc/package.json index 44223eec..c0fb4211 100644 --- a/examples/azure-functions-with-trpc/package.json +++ b/examples/azure-functions-with-trpc/package.json @@ -15,9 +15,7 @@ "license": "MIT", "dependencies": { "@azure/functions": "^4.1.0", - "@nammatham/azure-functions": "2.0.0-alpha.8", - "@nammatham/core": "2.0.0-alpha.8", - "@nammatham/express": "2.0.0-alpha.8", + "nammatham": "2.0.0-alpha.8", "@nammatham/trpc-azure-functions": "2.0.0-alpha.8", "@trpc/client": "^10.45.0", "@trpc/server": "^10.45.0", diff --git a/examples/azure-functions-with-trpc/src/nammatham.ts b/examples/azure-functions-with-trpc/src/nammatham.ts index 31e14679..a1755eca 100644 --- a/examples/azure-functions-with-trpc/src/nammatham.ts +++ b/examples/azure-functions-with-trpc/src/nammatham.ts @@ -1,5 +1,4 @@ -import { initNammatham } from '@nammatham/core'; -import { AzureFunctionsAdapter } from '@nammatham/azure-functions'; +import { initNammatham, AzureFunctionsAdapter } from 'nammatham'; const n = initNammatham.create(new AzureFunctionsAdapter()); diff --git a/packages/main/package.json b/packages/main/package.json index 8c64c264..aff8bdf2 100644 --- a/packages/main/package.json +++ b/packages/main/package.json @@ -4,10 +4,37 @@ "description": "Type-safe Serverless Library for Azure Functions and friends", "main": "dist/main.js", "types": "dist/main.d.ts", + "exports": { + "./package.json": "./package.json", + ".": { + "types": "./dist/main.d.ts", + "import": "./dist/main.mjs", + "default": "./dist/main.js" + }, + "./express": { + "types": "./dist/express.d.ts", + "import": "./dist/express.mjs", + "default": "./dist/express.js" + }, + "./core": { + "types": "./dist/core.d.ts", + "import": "./dist/core.mjs", + "default": "./dist/core.js" + }, + "./azure-functions": { + "types": "./dist/azure-functions.d.ts", + "import": "./dist/azure-functions.mjs", + "default": "./dist/azure-functions.js" + } + }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "prepublishOnly": "npm run build", - "build": "tsup src/main.ts --dts", + "build:main": "tsup src/main.ts --dts --format esm,cjs", + "build:express": "tsup src/express.ts --dts --format esm,cjs", + "build:core": "tsup src/core.ts --dts --format esm,cjs", + "build:azure-functions": "tsup src/azure-functions.ts --dts --format esm,cjs", + "build": "run-p build:*", "format": "prettier -w src", "lint": "tsc --noEmit && eslint ./src && prettier -c src", "lint:fix": "eslint --fix ./src && prettier -w src", diff --git a/packages/main/src/azure-functions.ts b/packages/main/src/azure-functions.ts new file mode 100644 index 00000000..0840a9ba --- /dev/null +++ b/packages/main/src/azure-functions.ts @@ -0,0 +1 @@ +export * from '@nammatham/azure-functions'; \ No newline at end of file diff --git a/packages/main/src/core.ts b/packages/main/src/core.ts new file mode 100644 index 00000000..2b6c221a --- /dev/null +++ b/packages/main/src/core.ts @@ -0,0 +1 @@ +export * from '@nammatham/core'; \ No newline at end of file diff --git a/packages/main/src/express.ts b/packages/main/src/express.ts new file mode 100644 index 00000000..cdee7cba --- /dev/null +++ b/packages/main/src/express.ts @@ -0,0 +1 @@ +export * from '@nammatham/express'; \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ea7cf318..6a70b3a0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -93,15 +93,9 @@ importers: '@azure/functions': specifier: ^4.1.0 version: 4.1.0 - '@nammatham/azure-functions': - specifier: 2.0.0-alpha.8 - version: link:../../packages/azure-functions - '@nammatham/core': - specifier: 2.0.0-alpha.8 - version: link:../../packages/core - '@nammatham/express': + nammatham: specifier: 2.0.0-alpha.8 - version: link:../../packages/express + version: link:../../packages/main devDependencies: cross-env: specifier: ^7.0.3 @@ -121,15 +115,9 @@ importers: '@azure/functions': specifier: ^4.1.0 version: 4.1.0 - '@nammatham/azure-functions': - specifier: 2.0.0-alpha.8 - version: link:../../packages/azure-functions - '@nammatham/core': - specifier: 2.0.0-alpha.8 - version: link:../../packages/core - '@nammatham/express': + nammatham: specifier: 2.0.0-alpha.8 - version: link:../../packages/express + version: link:../../packages/main devDependencies: cross-env: specifier: ^7.0.3 @@ -152,18 +140,12 @@ importers: '@di-extra/inversify': specifier: ^0.2.0 version: 0.2.0 - '@nammatham/azure-functions': - specifier: 2.0.0-alpha.8 - version: link:../../packages/azure-functions - '@nammatham/core': - specifier: 2.0.0-alpha.8 - version: link:../../packages/core - '@nammatham/express': - specifier: 2.0.0-alpha.8 - version: link:../../packages/express inversify: specifier: ^6.0.2 version: 6.0.2 + nammatham: + specifier: 2.0.0-alpha.8 + version: link:../../packages/main reflect-metadata: specifier: ^0.2.1 version: 0.2.1 @@ -186,15 +168,9 @@ importers: '@azure/functions': specifier: ^4.1.0 version: 4.1.0 - '@nammatham/azure-functions': - specifier: 2.0.0-alpha.8 - version: link:../../packages/azure-functions - '@nammatham/core': - specifier: 2.0.0-alpha.8 - version: link:../../packages/core - '@nammatham/express': + nammatham: specifier: 2.0.0-alpha.8 - version: link:../../packages/express + version: link:../../packages/main devDependencies: cross-env: specifier: ^7.0.3 @@ -214,15 +190,6 @@ importers: '@azure/functions': specifier: ^4.1.0 version: 4.1.0 - '@nammatham/azure-functions': - specifier: 2.0.0-alpha.8 - version: link:../../packages/azure-functions - '@nammatham/core': - specifier: 2.0.0-alpha.8 - version: link:../../packages/core - '@nammatham/express': - specifier: 2.0.0-alpha.8 - version: link:../../packages/express '@nammatham/trpc-azure-functions': specifier: 2.0.0-alpha.8 version: link:../../packages/trpc-azure-functions @@ -232,6 +199,9 @@ importers: '@trpc/server': specifier: ^10.45.0 version: 10.45.0 + nammatham: + specifier: 2.0.0-alpha.8 + version: link:../../packages/main trpc-azure-functions-adapter: specifier: 0.0.5 version: 0.0.5 From 5b966554e43ea1fa4236539215ef6accb970ae33 Mon Sep 17 00:00:00 2001 From: Thada Wangthammang Date: Sun, 21 Jan 2024 23:17:55 +0700 Subject: [PATCH 3/4] fix script nammatham package release as alpha version --- .eslintignore | 3 ++- scripts/release.ts | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.eslintignore b/.eslintignore index 2dc1a74a..f32e0be2 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ .eslintrc.js -examples \ No newline at end of file +examples +scripts \ No newline at end of file diff --git a/scripts/release.ts b/scripts/release.ts index ee0f71d1..9d61f9b7 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -6,6 +6,13 @@ import { releaseTypeSelectOption } from './input-option'; export type ReleaseType = 'major' | 'minor' | 'patch' | 'alpha'; +/** + * If the package is published with the tag, it will be published with the tag. + */ +export const publishTags: Record = { + nammatham: 'alpha', +}; + async function main() { const dryRun = process.env.DRY_RUN === 'true'; const releaseType = await select(releaseTypeSelectOption) as ReleaseType; @@ -37,6 +44,10 @@ export interface PublishPackagesOptions { dryRun?: boolean; } +function publishWithTag(packageName: string) { + return publishTags[packageName] ?? 'latest'; +} + async function publishPackages({ directory, dryRun, version }: PublishPackagesOptions) { console.log('Publishing packages...'); const otp = await input({ message: 'Enter your OTP' }); // Temp method, use github actions later @@ -47,7 +58,8 @@ async function publishPackages({ directory, dryRun, version }: PublishPackagesOp const { name } = await readPackageJson(packagePath); console.log(`Publishing ${name}@${version}`); const otpOption = otp ? ['--otp', otp] : []; - await execute('npm', ['publish', '--access', 'public', ...otpOption], { + const tagOption = ['--tag', publishWithTag(name)] + await execute('npm', ['publish', '--access', 'public', ...otpOption, ...tagOption], { cwd: packagePath, dryRun, }); From 72fe3290b2814b9b73db6c6978472296a952bf8d Mon Sep 17 00:00:00 2001 From: Thada Wangthammang Date: Sun, 21 Jan 2024 23:21:04 +0700 Subject: [PATCH 4/4] fix script order --- scripts/release.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/release.ts b/scripts/release.ts index 9d61f9b7..a2f252e6 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -15,9 +15,8 @@ export const publishTags: Record = { async function main() { const dryRun = process.env.DRY_RUN === 'true'; - const releaseType = await select(releaseTypeSelectOption) as ReleaseType; - console.log(`Starting release nammatham... ${dryRun ? 'with dry-run' : ''}`); + const releaseType = await select(releaseTypeSelectOption) as ReleaseType; const { version } = await readPackageJson(process.cwd()); console.log(`Current version: ${version}`);