swallowkit 1.1.2 → 2.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +61 -7
- package/README.md +61 -7
- package/dist/cli/commands/add-auth.d.ts.map +1 -1
- package/dist/cli/commands/add-auth.js +103 -27
- package/dist/cli/commands/add-auth.js.map +1 -1
- package/dist/cli/commands/configure-mcp.d.ts +12 -0
- package/dist/cli/commands/configure-mcp.d.ts.map +1 -0
- package/dist/cli/commands/configure-mcp.js +42 -0
- package/dist/cli/commands/configure-mcp.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +5 -2
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/dev.js +143 -67
- package/dist/cli/commands/dev.js.map +1 -1
- package/dist/cli/commands/init.d.ts +14 -7
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +149 -170
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/migrations.d.ts.map +1 -1
- package/dist/cli/commands/migrations.js +25 -0
- package/dist/cli/commands/migrations.js.map +1 -1
- package/dist/cli/commands/provision.d.ts +5 -0
- package/dist/cli/commands/provision.d.ts.map +1 -1
- package/dist/cli/commands/provision.js +278 -55
- package/dist/cli/commands/provision.js.map +1 -1
- package/dist/cli/commands/scaffold.d.ts +5 -1
- package/dist/cli/commands/scaffold.d.ts.map +1 -1
- package/dist/cli/commands/scaffold.js +123 -18
- package/dist/cli/commands/scaffold.js.map +1 -1
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +49 -8
- package/dist/cli/index.js.map +1 -1
- package/dist/core/config.d.ts +2 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +19 -0
- package/dist/core/config.js.map +1 -1
- package/dist/core/operations/create-model.d.ts +2 -0
- package/dist/core/operations/create-model.d.ts.map +1 -1
- package/dist/core/operations/create-model.js +60 -8
- package/dist/core/operations/create-model.js.map +1 -1
- package/dist/core/operations/migration-generator.d.ts.map +1 -1
- package/dist/core/operations/migration-generator.js +12 -1
- package/dist/core/operations/migration-generator.js.map +1 -1
- package/dist/core/operations/model-migration.d.ts +22 -0
- package/dist/core/operations/model-migration.d.ts.map +1 -0
- package/dist/core/operations/model-migration.js +36 -0
- package/dist/core/operations/model-migration.js.map +1 -0
- package/dist/core/operations/provision-deployment.d.ts +52 -0
- package/dist/core/operations/provision-deployment.d.ts.map +1 -0
- package/dist/core/operations/provision-deployment.js +164 -0
- package/dist/core/operations/provision-deployment.js.map +1 -0
- package/dist/core/operations/provision-operations.d.ts +62 -6
- package/dist/core/operations/provision-operations.d.ts.map +1 -1
- package/dist/core/operations/provision-operations.js +653 -115
- package/dist/core/operations/provision-operations.js.map +1 -1
- package/dist/core/operations/scaffold-apply.d.ts +1 -0
- package/dist/core/operations/scaffold-apply.d.ts.map +1 -1
- package/dist/core/operations/scaffold-apply.js +1 -0
- package/dist/core/operations/scaffold-apply.js.map +1 -1
- package/dist/core/operations/scaffold-machine.d.ts +1 -0
- package/dist/core/operations/scaffold-machine.d.ts.map +1 -1
- package/dist/core/operations/scaffold-machine.js.map +1 -1
- package/dist/core/operations/scaffold-plan.d.ts +2 -0
- package/dist/core/operations/scaffold-plan.d.ts.map +1 -1
- package/dist/core/operations/scaffold-plan.js +3 -1
- package/dist/core/operations/scaffold-plan.js.map +1 -1
- package/dist/core/project/agent-instructions.d.ts +2 -1
- package/dist/core/project/agent-instructions.d.ts.map +1 -1
- package/dist/core/project/agent-instructions.js +15 -0
- package/dist/core/project/agent-instructions.js.map +1 -1
- package/dist/core/project/boundaries.d.ts +5 -2
- package/dist/core/project/boundaries.d.ts.map +1 -1
- package/dist/core/project/boundaries.js +51 -20
- package/dist/core/project/boundaries.js.map +1 -1
- package/dist/core/project/capabilities.d.ts +17 -0
- package/dist/core/project/capabilities.d.ts.map +1 -1
- package/dist/core/project/capabilities.js +45 -6
- package/dist/core/project/capabilities.js.map +1 -1
- package/dist/core/project/home-page.d.ts +4 -0
- package/dist/core/project/home-page.d.ts.map +1 -0
- package/dist/core/project/home-page.js +113 -0
- package/dist/core/project/home-page.js.map +1 -0
- package/dist/core/project/manifest.d.ts +3 -1
- package/dist/core/project/manifest.d.ts.map +1 -1
- package/dist/core/project/manifest.js +47 -25
- package/dist/core/project/manifest.js.map +1 -1
- package/dist/core/project/mcp-config.d.ts +26 -0
- package/dist/core/project/mcp-config.d.ts.map +1 -0
- package/dist/core/project/mcp-config.js +117 -0
- package/dist/core/project/mcp-config.js.map +1 -0
- package/dist/core/project/react-project.d.ts +26 -0
- package/dist/core/project/react-project.d.ts.map +1 -0
- package/dist/core/project/react-project.js +443 -0
- package/dist/core/project/react-project.js.map +1 -0
- package/dist/core/project/state.d.ts +7 -0
- package/dist/core/project/state.d.ts.map +1 -1
- package/dist/core/project/state.js +86 -0
- package/dist/core/project/state.js.map +1 -1
- package/dist/core/project/validation.d.ts.map +1 -1
- package/dist/core/project/validation.js +32 -10
- package/dist/core/project/validation.js.map +1 -1
- package/dist/core/project/workflows.d.ts.map +1 -1
- package/dist/core/project/workflows.js +53 -7
- package/dist/core/project/workflows.js.map +1 -1
- package/dist/core/scaffold/auth-generator.d.ts.map +1 -1
- package/dist/core/scaffold/auth-generator.js +26 -27
- package/dist/core/scaffold/auth-generator.js.map +1 -1
- package/dist/core/scaffold/model-parser.d.ts +23 -0
- package/dist/core/scaffold/model-parser.d.ts.map +1 -1
- package/dist/core/scaffold/model-parser.js +407 -137
- package/dist/core/scaffold/model-parser.js.map +1 -1
- package/dist/core/scaffold/native-schema-generator.d.ts +13 -0
- package/dist/core/scaffold/native-schema-generator.d.ts.map +1 -1
- package/dist/core/scaffold/native-schema-generator.js +294 -91
- package/dist/core/scaffold/native-schema-generator.js.map +1 -1
- package/dist/core/scaffold/openapi-generator.d.ts +5 -0
- package/dist/core/scaffold/openapi-generator.d.ts.map +1 -1
- package/dist/core/scaffold/openapi-generator.js +53 -3
- package/dist/core/scaffold/openapi-generator.js.map +1 -1
- package/dist/core/scaffold/react-bff-generator.d.ts +10 -0
- package/dist/core/scaffold/react-bff-generator.d.ts.map +1 -0
- package/dist/core/scaffold/react-bff-generator.js +252 -0
- package/dist/core/scaffold/react-bff-generator.js.map +1 -0
- package/dist/core/scaffold/react-ui-generator.d.ts +6 -0
- package/dist/core/scaffold/react-ui-generator.d.ts.map +1 -0
- package/dist/core/scaffold/react-ui-generator.js +41 -0
- package/dist/core/scaffold/react-ui-generator.js.map +1 -0
- package/dist/core/scaffold/ui-generator.d.ts +0 -3
- package/dist/core/scaffold/ui-generator.d.ts.map +1 -1
- package/dist/core/scaffold/ui-generator.js +68 -7
- package/dist/core/scaffold/ui-generator.js.map +1 -1
- package/dist/core/verify/index.d.ts +4 -3
- package/dist/core/verify/index.d.ts.map +1 -1
- package/dist/core/verify/index.js +122 -5
- package/dist/core/verify/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/machine/contracts.d.ts +1 -0
- package/dist/machine/contracts.d.ts.map +1 -1
- package/dist/machine/errors.d.ts +3 -2
- package/dist/machine/errors.d.ts.map +1 -1
- package/dist/machine/errors.js +2 -1
- package/dist/machine/errors.js.map +1 -1
- package/dist/machine/index.d.ts.map +1 -1
- package/dist/machine/index.js +61 -30
- package/dist/machine/index.js.map +1 -1
- package/dist/mcp/index.d.ts +6 -4
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +210 -25
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/version-selection.d.ts +55 -0
- package/dist/mcp/version-selection.d.ts.map +1 -0
- package/dist/mcp/version-selection.js +152 -0
- package/dist/mcp/version-selection.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/azure-cli.d.ts +56 -0
- package/dist/utils/azure-cli.d.ts.map +1 -0
- package/dist/utils/azure-cli.js +326 -0
- package/dist/utils/azure-cli.js.map +1 -0
- package/dist/utils/azure-diagnostics.d.ts +16 -0
- package/dist/utils/azure-diagnostics.d.ts.map +1 -0
- package/dist/utils/azure-diagnostics.js +68 -0
- package/dist/utils/azure-diagnostics.js.map +1 -0
- package/dist/utils/package-manager.d.ts +2 -2
- package/dist/utils/package-manager.d.ts.map +1 -1
- package/dist/utils/package-manager.js +6 -3
- package/dist/utils/package-manager.js.map +1 -1
- package/dist/utils/python-uv.d.ts +5 -7
- package/dist/utils/python-uv.d.ts.map +1 -1
- package/dist/utils/python-uv.js +50 -24
- package/dist/utils/python-uv.js.map +1 -1
- package/dist/utils/react-dev.d.ts +4 -0
- package/dist/utils/react-dev.d.ts.map +1 -0
- package/dist/utils/react-dev.js +35 -0
- package/dist/utils/react-dev.js.map +1 -0
- package/dist/utils/semver.d.ts +14 -0
- package/dist/utils/semver.d.ts.map +1 -0
- package/dist/utils/semver.js +61 -0
- package/dist/utils/semver.js.map +1 -0
- package/package.json +7 -4
- package/src/__tests__/__snapshots__/boundaries.test.ts.snap +154 -0
- package/src/__tests__/agent-instructions.test.ts +6 -1
- package/src/__tests__/agent-loop-phase34.test.ts +143 -8
- package/src/__tests__/auth.test.ts +9 -0
- package/src/__tests__/azure-cli.test.ts +202 -0
- package/src/__tests__/boundaries.test.ts +42 -0
- package/src/__tests__/csharp-schema.test.ts +261 -0
- package/src/__tests__/dev.test.ts +13 -6
- package/src/__tests__/fixtures/az wrapper.cmd +2 -0
- package/src/__tests__/fixtures/azure-cli.cjs +153 -0
- package/src/__tests__/fixtures/provision-runner.cjs +28 -0
- package/src/__tests__/generated-project-matrix.test.ts +789 -0
- package/src/__tests__/home-page.test.ts +50 -0
- package/src/__tests__/init.test.ts +145 -5
- package/src/__tests__/mcp-version.test.ts +262 -0
- package/src/__tests__/mcp.test.ts +120 -3
- package/src/__tests__/multi-auth.test.ts +115 -4
- package/src/__tests__/package-manager.test.ts +17 -2
- package/src/__tests__/plan-apply.test.ts +179 -0
- package/src/__tests__/provision-runtime.test.ts +722 -0
- package/src/__tests__/python-uv.test.ts +50 -14
- package/src/__tests__/python-venv.test.ts +48 -0
- package/src/__tests__/react-dev.test.ts +72 -0
- package/src/__tests__/react.test.ts +838 -0
- package/src/__tests__/release-metadata.test.ts +121 -0
- package/src/__tests__/schema-analysis.test.ts +329 -0
- package/src/cli/commands/add-auth.ts +103 -29
- package/src/cli/commands/configure-mcp.ts +54 -0
- package/src/cli/commands/dev.ts +145 -73
- package/src/cli/commands/init.ts +147 -172
- package/src/cli/commands/migrations.ts +22 -0
- package/src/cli/commands/provision.ts +294 -56
- package/src/cli/commands/scaffold.ts +145 -22
- package/src/cli/index.ts +46 -10
- package/src/core/config.ts +21 -1
- package/src/core/operations/create-model.ts +51 -13
- package/src/core/operations/migration-generator.ts +14 -1
- package/src/core/operations/model-migration.ts +52 -0
- package/src/core/operations/provision-deployment.ts +183 -0
- package/src/core/operations/provision-operations.ts +662 -154
- package/src/core/operations/scaffold-apply.ts +2 -0
- package/src/core/operations/scaffold-machine.ts +1 -0
- package/src/core/operations/scaffold-plan.ts +5 -1
- package/src/core/project/agent-instructions.ts +17 -1
- package/src/core/project/agent-templates/AGENTS.md +113 -15
- package/src/core/project/agent-templates/CLAUDE.md +14 -1
- package/src/core/project/agent-templates/bff-routes.instructions.md +5 -3
- package/src/core/project/agent-templates/copilot-instructions.md +15 -1
- package/src/core/project/agent-templates/shared-models.instructions.md +11 -3
- package/src/core/project/boundaries.ts +62 -20
- package/src/core/project/capabilities.ts +63 -6
- package/src/core/project/home-page.ts +114 -0
- package/src/core/project/manifest.ts +52 -27
- package/src/core/project/mcp-config.ts +84 -0
- package/src/core/project/react-project.ts +529 -0
- package/src/core/project/state.ts +70 -0
- package/src/core/project/validation.ts +32 -10
- package/src/core/project/workflows.ts +53 -7
- package/src/core/scaffold/auth-generator.ts +26 -27
- package/src/core/scaffold/model-parser.ts +413 -129
- package/src/core/scaffold/native-schema-generator.ts +319 -103
- package/src/core/scaffold/openapi-generator.ts +63 -5
- package/src/core/scaffold/react-bff-generator.ts +292 -0
- package/src/core/scaffold/react-ui-generator.ts +51 -0
- package/src/core/scaffold/ui-generator.ts +70 -8
- package/src/core/verify/index.ts +118 -6
- package/src/index.ts +3 -1
- package/src/machine/contracts.ts +1 -0
- package/src/machine/errors.ts +4 -2
- package/src/machine/index.ts +67 -36
- package/src/mcp/index.ts +221 -31
- package/src/mcp/version-selection.ts +163 -0
- package/src/types/index.ts +4 -0
- package/src/utils/azure-cli.ts +315 -0
- package/src/utils/azure-diagnostics.ts +75 -0
- package/src/utils/package-manager.ts +7 -4
- package/src/utils/python-uv.ts +53 -33
- package/src/utils/react-dev.ts +31 -0
- package/src/utils/semver.ts +59 -0
package/README.ja.md
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
[English](./README.md) | 日本語
|
|
9
9
|
|
|
10
|
-
Next.js
|
|
10
|
+
Next.js または React を使って Azure 上にアプリを構築する、スキーマ駆動開発ツールキットです。
|
|
11
11
|
|
|
12
12
|
SwallowKit は、共有された Zod スキーマを中心にして、保守しやすいフルスタックアプリケーションを Azure 上に構築するための scaffolding ツールです。1 つのスキーマ定義から、フロントエンドフォーム、BFF ルート、Azure Functions バックエンド、OpenAPI、インフラ定義、AI エージェント向けのプロジェクトメタデータなどを生成できます。
|
|
13
13
|
|
|
14
|
-
フロントエンド、バックエンド、データベース、バリデーション、API 契約、デプロイ構成がばらばらになりがちな Next.js + Azure アプリケーション開発を、明示的な構成で整理することを目的としています。
|
|
14
|
+
フロントエンド、バックエンド、データベース、バリデーション、API 契約、デプロイ構成がばらばらになりがちな Next.js / React + Azure アプリケーション開発を、明示的な構成で整理することを目的としています。
|
|
15
15
|
|
|
16
16
|
## 🎯 なぜ SwallowKit か
|
|
17
17
|
|
|
@@ -35,7 +35,7 @@ AI はアプリケーションコードをすばやく生成できます。フ
|
|
|
35
35
|
## ✨ 主な機能
|
|
36
36
|
|
|
37
37
|
- **Zod スキーマを中心にした型定義** とバリデーション共有
|
|
38
|
-
- **Next.js、BFF ルート、Azure Functions、UI コンポーネントの CRUD scaffolding**
|
|
38
|
+
- **Next.js / React、BFF ルート、Azure Functions、UI コンポーネントの CRUD scaffolding**
|
|
39
39
|
- **Bicep による Azure 向けインフラ定義**
|
|
40
40
|
- **複数言語の Azure Functions バックエンド対応**(TypeScript、C#、Python)
|
|
41
41
|
- **ローカル開発支援** とシードデータ
|
|
@@ -46,7 +46,7 @@ AI はアプリケーションコードをすばやく生成できます。フ
|
|
|
46
46
|
|
|
47
47
|
SwallowKit は、次のような構成のアプリケーションを主な対象にしています。
|
|
48
48
|
|
|
49
|
-
- Next.js
|
|
49
|
+
- Next.js、または React + Vite + React Router
|
|
50
50
|
- Azure Static Web Apps
|
|
51
51
|
- Azure Functions
|
|
52
52
|
- Azure Cosmos DB
|
|
@@ -58,11 +58,11 @@ SwallowKit は、次のような構成のアプリケーションを主な対象
|
|
|
58
58
|
```
|
|
59
59
|
ブラウザー
|
|
60
60
|
|
|
|
61
|
-
Next.js
|
|
61
|
+
Next.js / React フロントエンド(SWA)
|
|
62
62
|
|
|
|
63
|
-
Next.js BFF
|
|
63
|
+
Next.js API Routes / SWA マネージド Functions BFF
|
|
64
64
|
|
|
|
65
|
-
Azure Functions API
|
|
65
|
+
独立 Azure Functions API(SWA にはリンクしない)
|
|
66
66
|
|
|
|
67
67
|
Azure Cosmos DB
|
|
68
68
|
```
|
|
@@ -76,6 +76,7 @@ BFF レイヤーを置くことで、フロントエンドをシンプルに保
|
|
|
76
76
|
詳しい使い方はドキュメントサイトを参照してください([English](https://himanago.github.io/swallowkit/en/) もあります)。
|
|
77
77
|
|
|
78
78
|
- **[はじめる](https://himanago.github.io/swallowkit/ja/getting-started)** - 最初のプロジェクトセットアップ
|
|
79
|
+
- **[React フロントエンド](docs/ja/react-guide.md)** - React SPA、マネージド BFF、開発とデプロイ
|
|
79
80
|
- **[基本概念](https://himanago.github.io/swallowkit/ja/concepts)** - スキーマ中心のアーキテクチャ
|
|
80
81
|
- **[Scaffold ガイド](https://himanago.github.io/swallowkit/ja/scaffold-guide)** - CRUD コード生成
|
|
81
82
|
- **[ローカル開発](https://himanago.github.io/swallowkit/ja/dev-guide)** - Dev サーバー、seeds、モックコネクタ
|
|
@@ -94,6 +95,11 @@ npx swallowkit init my-app
|
|
|
94
95
|
cd my-app
|
|
95
96
|
```
|
|
96
97
|
|
|
98
|
+
対話プロンプトで Next.js / React を選択するか、`--frontend react` を指定します。
|
|
99
|
+
React では静的フロントエンドと HTTP 専用のマネージド Functions BFF を SWA に配置します。
|
|
100
|
+
独立 Functions は別途配置し、**SWA にはリンクしません**。
|
|
101
|
+
フロントエンド指定のない既存設定は Next.js のままです。
|
|
102
|
+
|
|
97
103
|
pnpm 11/12 は `pnpm dlx swallowkit init my-app` で作成し、以後 project 内で `pnpm exec swallowkit …` を使います。`npx` は npm を選択し、`--package-manager npm|pnpm` で明示指定できます。Node.js 22.14 以上が必要です。MCP は選択した manager で意図的に `latest` を参照します。[コマンド・workspace・security の詳細](docs/ja/package-managers.md)を参照してください。
|
|
98
104
|
|
|
99
105
|
|
|
@@ -146,6 +152,54 @@ SwallowKit は、AI コーディングエージェントがプロジェクト構
|
|
|
146
152
|
└── .swallowkit/ # SwallowKit プロジェクトメタデータ
|
|
147
153
|
```
|
|
148
154
|
|
|
155
|
+
## リリース公開(メンテナー向け)
|
|
156
|
+
|
|
157
|
+
`v<version>` 形式の Git タグを push すると、`.github/workflows/publish.yml` が
|
|
158
|
+
ビルド、テスト、パッケージ化した consumer の検証を経て公開します。
|
|
159
|
+
Git タグ、`package.json`、`package-lock.json` の両方の version が一致している必要があります。
|
|
160
|
+
|
|
161
|
+
| バージョンの例 | npm dist-tag |
|
|
162
|
+
| --- | --- |
|
|
163
|
+
| `2.0.0-alpha.1` | `alpha` |
|
|
164
|
+
| `2.0.0-beta.1` | `beta` |
|
|
165
|
+
| `2.0.0-rc.1` などその他のプレリリース | `next` |
|
|
166
|
+
| `2.0.0` | `latest` |
|
|
167
|
+
|
|
168
|
+
リリース対象の変更をコミットした後、次のようにアルファ版を準備・公開します。
|
|
169
|
+
|
|
170
|
+
```sh
|
|
171
|
+
npm version 2.0.0-alpha.1
|
|
172
|
+
git push origin HEAD
|
|
173
|
+
git push origin v2.0.0-alpha.1
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`npm version` は両方の manifest を更新し、バージョン更新のコミットとタグを作成します。
|
|
177
|
+
以降は `2.0.0-alpha.2`、`2.0.0-beta.1`、`2.0.0` など、公開するバージョンを指定します。
|
|
178
|
+
プレリリースで `latest` は更新されません。
|
|
179
|
+
公開には引き続きリポジトリの `NPM_TOKEN` シークレットが必要です。
|
|
180
|
+
|
|
181
|
+
公開せずにパイプラインを確認する場合は、バージョンタグを push する前に、
|
|
182
|
+
リリース対象のコミットで **Publish to npm** を手動実行し、**dry-run** を有効にしてください。
|
|
183
|
+
サマリーにはバージョンと npm タグが表示され、公開済みとは表示されません。
|
|
184
|
+
|
|
185
|
+
リリース用の consumer 検証は pnpm 11・pnpm 12・npm ごとに別のランナーで実行します。
|
|
186
|
+
生成アプリやパッケージキャッシュが公開用ランナーに蓄積しない構成です。
|
|
187
|
+
公開には引き続き、すべての consumer 検証・ビルド・テストの成功が必要です。
|
|
188
|
+
consumer のログと依存関係の監査結果は、検証が失敗した場合もアップロードします。
|
|
189
|
+
|
|
190
|
+
npm 公開前に失敗し、修正がリリースワークフローだけの場合は、既存の Git タグを
|
|
191
|
+
移動・再作成しないでください。ワークフロー修正をマージした後、`main` から
|
|
192
|
+
**Publish to npm** を実行し、**release-tag** に既存タグ
|
|
193
|
+
(例: `v2.0.0-alpha.1`)を指定して、まず **dry-run** を有効にします。
|
|
194
|
+
タグのコミットは最初に一度だけ解決され、すべての検証と公開で同じコミットを使います。
|
|
195
|
+
成功後に **dry-run** を無効にして再実行すると公開できます。
|
|
196
|
+
GitHub の **Re-run jobs** は古いワークフローを使うため、修正が反映されません。
|
|
197
|
+
パッケージ自体に修正が必要な場合は、新しいバージョンとタグを作成してください。
|
|
198
|
+
|
|
199
|
+
特定のアルファ版は `npx swallowkit@2.0.0-alpha.1 init my-app --frontend react` で試せます。
|
|
200
|
+
`npx swallowkit@alpha ...` / `npx swallowkit@beta ...` は各チャネルの最新版を使います。
|
|
201
|
+
通常の `npx swallowkit ...` は引き続き `latest` を使います。
|
|
202
|
+
|
|
149
203
|
## 🔗 ステータス
|
|
150
204
|
|
|
151
205
|
SwallowKit は現在開発中です。API、プロジェクト構成、生成されるコードは変更される可能性があります。
|
package/README.md
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
English | [日本語](./README.ja.md)
|
|
9
9
|
|
|
10
|
-
Schema-driven application scaffolding for Next.js
|
|
10
|
+
Schema-driven application scaffolding for Next.js or React on Azure.
|
|
11
11
|
|
|
12
12
|
SwallowKit helps you build maintainable full-stack applications on Azure by using shared Zod schemas as the source of truth. From one schema definition, it can generate frontend forms, BFF routes, Azure Functions backends, OpenAPI contracts, infrastructure templates, and AI-agent-friendly project metadata.
|
|
13
13
|
|
|
14
|
-
It is designed for developers who want to build Next.js applications on Azure without letting the frontend, backend, database model, validation rules, and deployment configuration drift apart.
|
|
14
|
+
It is designed for developers who want to build Next.js or React applications on Azure without letting the frontend, backend, database model, validation rules, and deployment configuration drift apart.
|
|
15
15
|
|
|
16
16
|
## 🎯 Why SwallowKit?
|
|
17
17
|
|
|
@@ -35,7 +35,7 @@ As the application grows, these layers often drift apart. SwallowKit reduces tha
|
|
|
35
35
|
## ✨ What it gives you
|
|
36
36
|
|
|
37
37
|
- **Shared Zod schemas** as the source of truth
|
|
38
|
-
- **CRUD scaffolding** for Next.js, BFF routes, Azure Functions, and UI components
|
|
38
|
+
- **CRUD scaffolding** for Next.js or React, BFF routes, Azure Functions, and UI components
|
|
39
39
|
- **Azure-ready infrastructure** using Bicep
|
|
40
40
|
- **Multi-language Azure Functions** backends (TypeScript, C#, Python)
|
|
41
41
|
- **Local development helpers** and seed data
|
|
@@ -46,7 +46,7 @@ As the application grows, these layers often drift apart. SwallowKit reduces tha
|
|
|
46
46
|
|
|
47
47
|
SwallowKit is optimized for applications built with:
|
|
48
48
|
|
|
49
|
-
- Next.js
|
|
49
|
+
- Next.js, or React + Vite + React Router
|
|
50
50
|
- Azure Static Web Apps
|
|
51
51
|
- Azure Functions
|
|
52
52
|
- Azure Cosmos DB
|
|
@@ -58,11 +58,11 @@ The default architecture follows a BFF pattern:
|
|
|
58
58
|
```
|
|
59
59
|
Browser
|
|
60
60
|
|
|
|
61
|
-
Next.js frontend
|
|
61
|
+
Next.js or React frontend (SWA)
|
|
62
62
|
|
|
|
63
|
-
Next.js
|
|
63
|
+
Next.js API routes or SWA managed Functions BFF
|
|
64
64
|
|
|
|
65
|
-
Azure Functions API
|
|
65
|
+
Independent Azure Functions API (not linked to SWA)
|
|
66
66
|
|
|
|
67
67
|
Azure Cosmos DB
|
|
68
68
|
```
|
|
@@ -76,6 +76,7 @@ The BFF layer keeps frontend code simple while allowing backend services, authen
|
|
|
76
76
|
Visit the **[SwallowKit Documentation](https://himanago.github.io/swallowkit/)** for the full docs (also available in [日本語](https://himanago.github.io/swallowkit/ja/)).
|
|
77
77
|
|
|
78
78
|
- **[Getting Started](https://himanago.github.io/swallowkit/en/getting-started)** - First project setup
|
|
79
|
+
- **[React frontend](docs/en/react-guide.md)** - React SPA, managed Functions BFF, development and deployment
|
|
79
80
|
- **[Core Concepts](https://himanago.github.io/swallowkit/en/concepts)** - Schema-centric architecture
|
|
80
81
|
- **[Scaffold Guide](https://himanago.github.io/swallowkit/en/scaffold-guide)** - CRUD code generation
|
|
81
82
|
- **[Local Development](https://himanago.github.io/swallowkit/en/dev-guide)** - Dev server, seeds, mock connectors
|
|
@@ -94,6 +95,11 @@ npx swallowkit init my-app
|
|
|
94
95
|
cd my-app
|
|
95
96
|
```
|
|
96
97
|
|
|
98
|
+
Choose Next.js or React in the wizard, or pass `--frontend react`.
|
|
99
|
+
React deploys static assets and an HTTP-only managed Functions BFF to SWA;
|
|
100
|
+
the standalone Functions backend remains separate and **is never linked to SWA**.
|
|
101
|
+
Existing configurations without a frontend setting retain Next.js.
|
|
102
|
+
|
|
97
103
|
For pnpm 11/12: bootstrap with `pnpm dlx swallowkit init my-app`, then use `pnpm exec swallowkit …` inside the project. `npx` selects npm; `--package-manager npm|pnpm` overrides detection. Node.js 22.14+ is required. MCP intentionally uses `latest` with the selected package manager. See [commands, workspace setup, and security troubleshooting](docs/en/package-managers.md).
|
|
98
104
|
|
|
99
105
|
|
|
@@ -146,6 +152,54 @@ The goal is to make AI-assisted development safer by giving agents explicit arch
|
|
|
146
152
|
└── .swallowkit/ # SwallowKit project metadata
|
|
147
153
|
```
|
|
148
154
|
|
|
155
|
+
## Publishing releases (maintainers)
|
|
156
|
+
|
|
157
|
+
Pushing a `v<version>` Git tag runs `.github/workflows/publish.yml`, including
|
|
158
|
+
the build, tests, and packed-consumer release gate. The tag, `package.json`,
|
|
159
|
+
and both version fields in `package-lock.json` must match.
|
|
160
|
+
|
|
161
|
+
| Version example | npm dist-tag |
|
|
162
|
+
| --- | --- |
|
|
163
|
+
| `2.0.0-alpha.1` | `alpha` |
|
|
164
|
+
| `2.0.0-beta.1` | `beta` |
|
|
165
|
+
| `2.0.0-rc.1` or other prereleases | `next` |
|
|
166
|
+
| `2.0.0` | `latest` |
|
|
167
|
+
|
|
168
|
+
After committing the release changes, prepare and publish an alpha with:
|
|
169
|
+
|
|
170
|
+
```sh
|
|
171
|
+
npm version 2.0.0-alpha.1
|
|
172
|
+
git push origin HEAD
|
|
173
|
+
git push origin v2.0.0-alpha.1
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`npm version` updates both manifests and creates the version commit and tag.
|
|
177
|
+
For subsequent releases, use an explicit version such as `2.0.0-alpha.2`,
|
|
178
|
+
`2.0.0-beta.1`, or `2.0.0`. Prereleases never update `latest`.
|
|
179
|
+
The workflow still requires the repository's `NPM_TOKEN` secret.
|
|
180
|
+
|
|
181
|
+
To check the pipeline without publishing, run **Publish to npm** manually on
|
|
182
|
+
the release commit with **dry-run** enabled, before pushing the version tag.
|
|
183
|
+
The summary reports the selected version and npm tag without claiming a publish.
|
|
184
|
+
|
|
185
|
+
Consumer release gates run on separate runners for pnpm 11, pnpm 12, and npm.
|
|
186
|
+
Their generated applications and package caches do not accumulate on the publish
|
|
187
|
+
runner; publication still requires every gate, the build, and the tests to pass.
|
|
188
|
+
Consumer logs and dependency audits are uploaded even when a gate fails.
|
|
189
|
+
|
|
190
|
+
If a release failed before npm publication and the fix only changes the release
|
|
191
|
+
workflow, do not move or recreate its Git tag. After merging the workflow fix,
|
|
192
|
+
run **Publish to npm** from `main`, set **release-tag** to the existing tag
|
|
193
|
+
(for example, `v2.0.0-alpha.1`), and enable **dry-run** first. The workflow resolves
|
|
194
|
+
that tag once and checks out the same commit for every gate and for publication.
|
|
195
|
+
After a successful dry run, repeat with **dry-run** disabled to publish.
|
|
196
|
+
GitHub's **Re-run jobs** uses the old workflow revision and will not pick up the fix.
|
|
197
|
+
If the package itself needs changes, create a new version and tag instead.
|
|
198
|
+
|
|
199
|
+
Try the exact alpha with `npx swallowkit@2.0.0-alpha.1 init my-app --frontend react`,
|
|
200
|
+
or use `npx swallowkit@alpha ...` / `npx swallowkit@beta ...` for the respective
|
|
201
|
+
channel. Plain `npx swallowkit ...` continues to use `latest`.
|
|
202
|
+
|
|
149
203
|
## 🔗 Status
|
|
150
204
|
|
|
151
205
|
SwallowKit is under active development. The API, project structure, and generated output may change.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-auth.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/add-auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"add-auth.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/add-auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiDH,UAAU,cAAc;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAsJD,wBAAgB,sBAAsB,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CA0C1E;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAclE;AAgCD,wBAAsB,cAAc,CAAC,OAAO,EAAE,cAAc,iBAkJ3D"}
|
|
@@ -43,6 +43,8 @@ exports.addAuthCommand = addAuthCommand;
|
|
|
43
43
|
const fs = __importStar(require("fs"));
|
|
44
44
|
const path = __importStar(require("path"));
|
|
45
45
|
const config_1 = require("../../core/config");
|
|
46
|
+
const react_bff_generator_1 = require("../../core/scaffold/react-bff-generator");
|
|
47
|
+
const react_ui_generator_1 = require("../../core/scaffold/react-ui-generator");
|
|
46
48
|
const auth_generator_1 = require("../../core/scaffold/auth-generator");
|
|
47
49
|
const manifest_1 = require("../../core/project/manifest");
|
|
48
50
|
const file_session_1 = require("../../core/operations/file-session");
|
|
@@ -87,6 +89,29 @@ function defaultCustomJwtConfig() {
|
|
|
87
89
|
tokenExpiry: "24h",
|
|
88
90
|
};
|
|
89
91
|
}
|
|
92
|
+
function writeCallFunction(cwd, session, nextSource, auth) {
|
|
93
|
+
if ((0, config_1.getFrontendFramework)() === "react") {
|
|
94
|
+
const name = JSON.parse(session.readFile(path.join(cwd, "package.json"))).name;
|
|
95
|
+
session.writeFile(path.join(cwd, "bff", "src", "lib", "call-function.ts"), (0, react_bff_generator_1.generateReactBffHelper)(name, auth), managedMeta);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
session.writeFile(path.join(cwd, "lib", "api", "call-function.ts"), nextSource, managedMeta);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function writeLoginPage(cwd, session, source) {
|
|
102
|
+
const react = (0, config_1.getFrontendFramework)() === "react";
|
|
103
|
+
const destination = react ? path.join(cwd, "src", "pages", "login.tsx") : path.join(cwd, "app", "login", "page.tsx");
|
|
104
|
+
session.writeFile(destination, react ? (0, react_ui_generator_1.adaptReactPage)(source) : source, managedMeta);
|
|
105
|
+
}
|
|
106
|
+
function writeAuthContext(cwd, session, source) {
|
|
107
|
+
session.writeFile(path.join(cwd, "lib", "auth", "auth-context.tsx"), (0, config_1.getFrontendFramework)() === "react" ? (0, react_ui_generator_1.adaptReactPage)(source) : source, managedMeta);
|
|
108
|
+
}
|
|
109
|
+
function writeManagedAuthRoute(cwd, session, customJwt) {
|
|
110
|
+
const name = JSON.parse(session.readFile(path.join(cwd, "package.json"))).name;
|
|
111
|
+
const sharedName = JSON.parse(session.readFile(path.join(cwd, "shared", "package.json"))).name;
|
|
112
|
+
session.writeFile(path.join(cwd, "bff", "src", "auth", "index.ts"), (0, react_bff_generator_1.generateReactAuthBff)(name, sharedName, customJwt), managedMeta);
|
|
113
|
+
session.writeFile(path.join(cwd, "bff", "auth", "function.json"), (0, react_bff_generator_1.generateManagedFunctionConfig)("auth/{action}", ["GET", "POST"], "auth"), managedMeta);
|
|
114
|
+
}
|
|
90
115
|
function setupSwaAuth(cwd, backendLanguage, session, allowedProviders) {
|
|
91
116
|
const providers = normalizeSwaProviders(allowedProviders);
|
|
92
117
|
const helperPath = backendLanguage === "typescript"
|
|
@@ -100,23 +125,23 @@ function setupSwaAuth(cwd, backendLanguage, session, allowedProviders) {
|
|
|
100
125
|
? (0, auth_generator_1.generateSwaAuthHelperCSharp)()
|
|
101
126
|
: (0, auth_generator_1.generateSwaAuthHelperPython)();
|
|
102
127
|
session.writeFile(helperPath, helper, managedMeta);
|
|
103
|
-
|
|
104
|
-
session.writeFile(callFnPath, (0, auth_generator_1.generateBFFCallFunctionWithSwaAuth)(), managedMeta);
|
|
128
|
+
writeCallFunction(cwd, session, (0, auth_generator_1.generateBFFCallFunctionWithSwaAuth)(), { provider: "swa" });
|
|
105
129
|
const authDir = path.join(cwd, "lib", "auth");
|
|
106
130
|
session.writeFile(path.join(authDir, "auth-context.tsx"), generateSwaAuthContext(providers), managedMeta);
|
|
107
131
|
updateRootLayoutWithAuthProvider(cwd, session);
|
|
108
|
-
|
|
109
|
-
session.writeFile(path.join(loginDir, "page.tsx"), generateSwaLoginPage(providers), managedMeta);
|
|
132
|
+
writeLoginPage(cwd, session, generateSwaLoginPage(providers));
|
|
110
133
|
updateSwaRouteConfig(cwd, session, providers);
|
|
111
134
|
}
|
|
112
135
|
function setupExternalTokenAuth(cwd, backendLanguage, session) {
|
|
113
136
|
const authDir = path.join(cwd, "lib", "auth");
|
|
114
137
|
writeIfMissing(session, path.join(authDir, "external-token-adapter.ts"), (0, auth_generator_1.generateExternalTokenAdapter)());
|
|
115
138
|
session.writeFile(path.join(authDir, "authenticated-fetch.ts"), (0, auth_generator_1.generateAuthenticatedFetch)(), managedMeta);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
139
|
+
writeAuthContext(cwd, session, (0, auth_generator_1.generateExternalTokenAuthContext)());
|
|
140
|
+
writeCallFunction(cwd, session, (0, auth_generator_1.generateBFFCallFunctionWithAuth)(), { provider: "external-token" });
|
|
141
|
+
if ((0, config_1.getFrontendFramework)() === "react")
|
|
142
|
+
writeManagedAuthRoute(cwd, session, false);
|
|
143
|
+
else
|
|
144
|
+
session.writeFile(path.join(cwd, "app", "api", "auth", "me", "route.ts"), (0, auth_generator_1.generateExternalTokenBFFMeRoute)(), managedMeta);
|
|
120
145
|
updateRootLayoutWithAuthProvider(cwd, session);
|
|
121
146
|
if (backendLanguage === "typescript") {
|
|
122
147
|
const verifier = path.join(cwd, "functions", "src", "auth", "external-token-verifier.ts");
|
|
@@ -224,6 +249,16 @@ function addAuthProviderToRootLayout(layout) {
|
|
|
224
249
|
return updated;
|
|
225
250
|
}
|
|
226
251
|
function updateRootLayoutWithAuthProvider(cwd, session) {
|
|
252
|
+
if ((0, config_1.getFrontendFramework)() === "react") {
|
|
253
|
+
const mainPath = path.join(cwd, "src", "main.tsx");
|
|
254
|
+
const main = session.readFile(mainPath);
|
|
255
|
+
if (main.includes("<AuthProvider>"))
|
|
256
|
+
return;
|
|
257
|
+
if (!main.includes("<App />"))
|
|
258
|
+
throw new Error("Could not find <App /> in src/main.tsx; cannot install AuthProvider");
|
|
259
|
+
session.writeFile(mainPath, `import { AuthProvider } from '@/lib/auth/auth-context';\n${main.replace("<App />", "<AuthProvider><App /></AuthProvider>")}`, extensionMeta);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
227
262
|
const layoutPath = path.join(cwd, "app", "layout.tsx");
|
|
228
263
|
if (!session.fileExists(layoutPath)) {
|
|
229
264
|
throw new Error("app/layout.tsx was not found; cannot install AuthProvider");
|
|
@@ -332,24 +367,22 @@ async function addAuthCommand(options) {
|
|
|
332
367
|
generateBFFAuth(cwd, projectName, sharedPackageName, session);
|
|
333
368
|
// 4. Generate proxy
|
|
334
369
|
console.log("\n Generating proxy...");
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
370
|
+
if ((0, config_1.getFrontendFramework)() === "nextjs") {
|
|
371
|
+
const proxyPath = path.join(cwd, "proxy.ts");
|
|
372
|
+
session.writeFile(proxyPath, (0, auth_generator_1.generateProxy)(projectName), managedMeta);
|
|
373
|
+
console.log(` Created: proxy.ts`);
|
|
374
|
+
}
|
|
338
375
|
// 5. Generate login page
|
|
339
376
|
console.log("\n Generating login page...");
|
|
340
|
-
|
|
341
|
-
session.writeFile(path.join(loginDir, "page.tsx"), (0, auth_generator_1.generateLoginPage)(), managedMeta);
|
|
342
|
-
console.log(` Created: app/login/page.tsx`);
|
|
377
|
+
writeLoginPage(cwd, session, (0, auth_generator_1.generateLoginPage)());
|
|
343
378
|
// 6. Generate auth context
|
|
344
379
|
console.log("\n Generating auth context...");
|
|
345
|
-
|
|
346
|
-
session.writeFile(path.join(authLibDir, "auth-context.tsx"), (0, auth_generator_1.generateAuthContext)(), managedMeta);
|
|
380
|
+
writeAuthContext(cwd, session, (0, auth_generator_1.generateAuthContext)());
|
|
347
381
|
console.log(`✅ Created: lib/auth/auth-context.tsx`);
|
|
348
382
|
// 7. Update callFunction with auth support
|
|
349
383
|
console.log("\n Updating callFunction with auth support...");
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
console.log(` Updated: lib/api/call-function.ts`);
|
|
384
|
+
writeCallFunction(cwd, session, (0, auth_generator_1.generateBFFCallFunctionWithAuth)(), { provider: "custom-jwt" });
|
|
385
|
+
console.log(` Updated: ${(0, config_1.getFrontendFramework)() === "react" ? "bff/src/lib" : "lib/api"}/call-function.ts`);
|
|
353
386
|
// 8. Update swallowkit.config.js
|
|
354
387
|
console.log("\n Updating configuration...");
|
|
355
388
|
updateConfigWithAuth(cwd, provider, customJwtConfig, session);
|
|
@@ -358,7 +391,7 @@ async function addAuthCommand(options) {
|
|
|
358
391
|
updateEnvironmentFiles(cwd, session);
|
|
359
392
|
// 10. Install dependencies
|
|
360
393
|
console.log("\n Installing auth dependencies...");
|
|
361
|
-
|
|
394
|
+
installAuthDependenciesSync(cwd, backendLanguage, rdbProvider, session);
|
|
362
395
|
await finalize();
|
|
363
396
|
console.log("\n Authentication setup complete!");
|
|
364
397
|
console.log("\n Next steps:");
|
|
@@ -395,7 +428,8 @@ function updateConfigWithNamedScheme(cwd, scheme, provider, session, allowedProv
|
|
|
395
428
|
var _a, _b;
|
|
396
429
|
const jsPath = path.join(cwd, "swallowkit.config.js");
|
|
397
430
|
const jsonPath = path.join(cwd, "swallowkit.config.json");
|
|
398
|
-
|
|
431
|
+
// Match loadConfig precedence: swallowkit.config.json wins when both files exist.
|
|
432
|
+
const configPath = session.fileExists(jsonPath) ? jsonPath : jsPath;
|
|
399
433
|
if (!session.fileExists(configPath))
|
|
400
434
|
throw new Error("swallowkit.config.js or swallowkit.config.json is required");
|
|
401
435
|
const swaProviders = provider === "swa" ? normalizeSwaProviders(allowedProviders) : undefined;
|
|
@@ -451,6 +485,11 @@ function addNamedScheme(cwd, scheme, provider, language, session, allowedProvide
|
|
|
451
485
|
// Validate/update config before creating files, so duplicate names stop safely.
|
|
452
486
|
updateConfigWithNamedScheme(cwd, scheme, provider, session, allowedProviders);
|
|
453
487
|
const slug = scheme.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
|
|
488
|
+
if (provider === "custom-jwt") {
|
|
489
|
+
// The scheme's JWT helper needs the same token/password/driver packages as single-provider custom-jwt.
|
|
490
|
+
const connector = (0, config_1.getConnectorDefinition)(defaultCustomJwtConfig().userConnector);
|
|
491
|
+
installAuthDependenciesSync(cwd, language, connector?.provider ?? "mysql", session);
|
|
492
|
+
}
|
|
454
493
|
if (language === "typescript") {
|
|
455
494
|
const dir = path.join(cwd, "functions", "src", "auth", "schemes", slug);
|
|
456
495
|
if (provider === "external-token")
|
|
@@ -482,13 +521,21 @@ function addNamedScheme(cwd, scheme, provider, language, session, allowedProvide
|
|
|
482
521
|
if (provider === "external-token") {
|
|
483
522
|
writeIfMissing(session, path.join(clientDir, "token-adapter.ts"), (0, auth_generator_1.generateExternalTokenAdapter)());
|
|
484
523
|
writeIfMissing(session, path.join(clientDir, "authenticated-fetch.ts"), (0, auth_generator_1.generateAuthenticatedFetch)().replace("'./external-token-adapter'", "'./token-adapter'"));
|
|
485
|
-
|
|
524
|
+
const source = (0, auth_generator_1.generateExternalTokenAuthContext)().replace(/external-token-adapter/g, "token-adapter");
|
|
525
|
+
writeIfMissing(session, path.join(clientDir, "auth-context.tsx"), (0, config_1.getFrontendFramework)() === "react" ? (0, react_ui_generator_1.adaptReactPage)(source) : source);
|
|
486
526
|
}
|
|
487
527
|
else if (provider === "swa") {
|
|
488
528
|
writeIfMissing(session, path.join(clientDir, "auth-context.tsx"), generateSwaAuthContext(allowedProviders));
|
|
489
529
|
}
|
|
490
530
|
else if (provider === "custom-jwt") {
|
|
491
|
-
writeIfMissing(session, path.join(clientDir, "auth-context.tsx"), (0, auth_generator_1.generateAuthContext)());
|
|
531
|
+
writeIfMissing(session, path.join(clientDir, "auth-context.tsx"), (0, config_1.getFrontendFramework)() === "react" ? (0, react_ui_generator_1.adaptReactPage)((0, auth_generator_1.generateAuthContext)()) : (0, auth_generator_1.generateAuthContext)());
|
|
532
|
+
}
|
|
533
|
+
if ((0, config_1.getFrontendFramework)() === "react") {
|
|
534
|
+
const existing = (0, config_1.getValidatedFullConfig)().auth;
|
|
535
|
+
writeCallFunction(cwd, session, "", {
|
|
536
|
+
...existing, schemes: { ...existing?.schemes, [scheme]: { provider } },
|
|
537
|
+
});
|
|
538
|
+
return;
|
|
492
539
|
}
|
|
493
540
|
const callFunctionPath = path.join(cwd, "lib", "api", "call-function.ts");
|
|
494
541
|
if (!session.fileExists(callFunctionPath))
|
|
@@ -599,9 +646,15 @@ function generateFunctionsAuth(cwd, backendLanguage, sharedPackageName, config,
|
|
|
599
646
|
const functionAppPath = path.join(functionsDir, "function_app.py");
|
|
600
647
|
if (session.fileExists(functionAppPath)) {
|
|
601
648
|
const content = session.readFile(functionAppPath);
|
|
602
|
-
const authImport = "from blueprints.auth import
|
|
649
|
+
const authImport = "from blueprints.auth import auth_bp";
|
|
603
650
|
const authRegister = "app.register_blueprint(auth_bp)";
|
|
604
|
-
|
|
651
|
+
// Earlier releases imported a non-existent `bp`; repair it in place when re-running.
|
|
652
|
+
const legacyImport = "from blueprints.auth import bp as auth_bp";
|
|
653
|
+
if (content.includes(legacyImport)) {
|
|
654
|
+
session.writeFile(functionAppPath, content.replace(legacyImport, authImport), extensionMeta);
|
|
655
|
+
console.log(` Updated: functions/function_app.py (fixed auth blueprint import)`);
|
|
656
|
+
}
|
|
657
|
+
else if (!content.includes(authImport)) {
|
|
605
658
|
const marker = "# SwallowKit scaffold registrations";
|
|
606
659
|
if (content.includes(marker)) {
|
|
607
660
|
const updated = content.replace(marker, `${authImport}\n${authRegister}\n${marker}`);
|
|
@@ -613,6 +666,10 @@ function generateFunctionsAuth(cwd, backendLanguage, sharedPackageName, config,
|
|
|
613
666
|
}
|
|
614
667
|
}
|
|
615
668
|
function generateBFFAuth(cwd, projectName, sharedPackageName, session) {
|
|
669
|
+
if ((0, config_1.getFrontendFramework)() === "react") {
|
|
670
|
+
writeManagedAuthRoute(cwd, session, true);
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
616
673
|
const authApiDir = path.join(cwd, "app", "api", "auth");
|
|
617
674
|
// Login route
|
|
618
675
|
const loginDir = path.join(authApiDir, "login");
|
|
@@ -628,6 +685,24 @@ function generateBFFAuth(cwd, projectName, sharedPackageName, session) {
|
|
|
628
685
|
console.log(` Created: app/api/auth/me/route.ts`);
|
|
629
686
|
}
|
|
630
687
|
function updateConfigWithAuth(cwd, provider, config, session, allowedProviders) {
|
|
688
|
+
const jsonPath = path.join(cwd, "swallowkit.config.json");
|
|
689
|
+
if (session.fileExists(jsonPath)) {
|
|
690
|
+
// loadConfig reads swallowkit.config.json first, so it is the effective configuration.
|
|
691
|
+
const value = JSON.parse(session.readFile(jsonPath));
|
|
692
|
+
if (value.auth) {
|
|
693
|
+
console.log(" 'auth' section already exists in swallowkit.config.json");
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
value.auth = {
|
|
697
|
+
provider,
|
|
698
|
+
...(provider === "custom-jwt" ? { customJwt: { ...config, jwtSecretEnv: config.jwtSecretEnv || "JWT_SECRET", tokenExpiry: config.tokenExpiry || "24h" } } : {}),
|
|
699
|
+
...(provider === "swa" ? { swa: { allowedProviders: normalizeSwaProviders(allowedProviders), roleSource: "swa-roles" } } : {}),
|
|
700
|
+
authorization: { defaultPolicy: provider === "none" ? "anonymous" : "authenticated" },
|
|
701
|
+
};
|
|
702
|
+
session.writeFile(jsonPath, JSON.stringify(value, null, 2) + "\n", extensionMeta);
|
|
703
|
+
console.log(` Updated: swallowkit.config.json`);
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
631
706
|
const configPath = path.join(cwd, "swallowkit.config.js");
|
|
632
707
|
if (!session.fileExists(configPath)) {
|
|
633
708
|
console.warn(" swallowkit.config.js not found. Please add auth config manually.");
|
|
@@ -666,7 +741,8 @@ function updateConfigWithAuth(cwd, provider, config, session, allowedProviders)
|
|
|
666
741
|
provider: '${provider}',
|
|
667
742
|
${providerSettings}
|
|
668
743
|
authorization: {
|
|
669
|
-
|
|
744
|
+
// Disabled auth has no scheme to authenticate against; 'authenticated' would fail validateConfig.
|
|
745
|
+
defaultPolicy: '${provider === "none" ? "anonymous" : "authenticated"}',
|
|
670
746
|
},
|
|
671
747
|
},
|
|
672
748
|
`;
|
|
@@ -698,7 +774,7 @@ function updateEnvironmentFiles(cwd, session) {
|
|
|
698
774
|
}
|
|
699
775
|
}
|
|
700
776
|
}
|
|
701
|
-
|
|
777
|
+
function installAuthDependenciesSync(cwd, backendLanguage, provider = "mysql", session) {
|
|
702
778
|
if (backendLanguage === "typescript") {
|
|
703
779
|
const funcPkgPath = path.join(cwd, "functions", "package.json");
|
|
704
780
|
if (session.fileExists(funcPkgPath)) {
|