swallowkit 1.0.0-beta.6 → 1.0.0-beta.61
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 +87 -175
- package/README.md +87 -176
- package/dist/__tests__/fixtures.d.ts +12 -0
- package/dist/__tests__/fixtures.d.ts.map +1 -1
- package/dist/__tests__/fixtures.js +101 -0
- package/dist/__tests__/fixtures.js.map +1 -1
- package/dist/cli/commands/add-auth.d.ts +15 -0
- package/dist/cli/commands/add-auth.d.ts.map +1 -0
- package/dist/cli/commands/add-auth.js +790 -0
- package/dist/cli/commands/add-auth.js.map +1 -0
- package/dist/cli/commands/add-connector.d.ts +20 -0
- package/dist/cli/commands/add-connector.d.ts.map +1 -0
- package/dist/cli/commands/add-connector.js +164 -0
- package/dist/cli/commands/add-connector.js.map +1 -0
- package/dist/cli/commands/cosmos-worktree-isolation.d.ts +25 -0
- package/dist/cli/commands/cosmos-worktree-isolation.d.ts.map +1 -0
- package/dist/cli/commands/cosmos-worktree-isolation.js +124 -0
- package/dist/cli/commands/cosmos-worktree-isolation.js.map +1 -0
- package/dist/cli/commands/create-model.d.ts +1 -4
- package/dist/cli/commands/create-model.d.ts.map +1 -1
- package/dist/cli/commands/create-model.js +20 -82
- package/dist/cli/commands/create-model.js.map +1 -1
- package/dist/cli/commands/dev-seeds.d.ts +62 -0
- package/dist/cli/commands/dev-seeds.d.ts.map +1 -0
- package/dist/cli/commands/dev-seeds.js +474 -0
- package/dist/cli/commands/dev-seeds.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +38 -0
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/dev.js +733 -155
- package/dist/cli/commands/dev.js.map +1 -1
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +3 -1
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init.d.ts +74 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +1376 -930
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/scaffold.d.ts +24 -0
- package/dist/cli/commands/scaffold.d.ts.map +1 -1
- package/dist/cli/commands/scaffold.js +473 -90
- package/dist/cli/commands/scaffold.js.map +1 -1
- package/dist/cli/index.d.ts +5 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +335 -55
- package/dist/cli/index.js.map +1 -1
- package/dist/core/config.d.ts +14 -3
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +179 -8
- package/dist/core/config.js.map +1 -1
- package/dist/core/mock/connector-mock-server.d.ts +101 -0
- package/dist/core/mock/connector-mock-server.d.ts.map +1 -0
- package/dist/core/mock/connector-mock-server.js +480 -0
- package/dist/core/mock/connector-mock-server.js.map +1 -0
- package/dist/core/mock/zod-mock-generator.d.ts +14 -0
- package/dist/core/mock/zod-mock-generator.d.ts.map +1 -0
- package/dist/core/mock/zod-mock-generator.js +163 -0
- package/dist/core/mock/zod-mock-generator.js.map +1 -0
- package/dist/core/operations/auth-operations.d.ts +61 -0
- package/dist/core/operations/auth-operations.d.ts.map +1 -0
- package/dist/core/operations/auth-operations.js +272 -0
- package/dist/core/operations/auth-operations.js.map +1 -0
- package/dist/core/operations/create-model.d.ts +15 -0
- package/dist/core/operations/create-model.d.ts.map +1 -0
- package/dist/core/operations/create-model.js +185 -0
- package/dist/core/operations/create-model.js.map +1 -0
- package/dist/core/operations/file-session.d.ts +56 -0
- package/dist/core/operations/file-session.d.ts.map +1 -0
- package/dist/core/operations/file-session.js +203 -0
- package/dist/core/operations/file-session.js.map +1 -0
- package/dist/core/operations/provision-operations.d.ts +52 -0
- package/dist/core/operations/provision-operations.d.ts.map +1 -0
- package/dist/core/operations/provision-operations.js +211 -0
- package/dist/core/operations/provision-operations.js.map +1 -0
- package/dist/core/operations/runtime.d.ts +37 -0
- package/dist/core/operations/runtime.d.ts.map +1 -0
- package/dist/core/operations/runtime.js +248 -0
- package/dist/core/operations/runtime.js.map +1 -0
- package/dist/core/operations/scaffold-apply.d.ts +21 -0
- package/dist/core/operations/scaffold-apply.d.ts.map +1 -0
- package/dist/core/operations/scaffold-apply.js +57 -0
- package/dist/core/operations/scaffold-apply.js.map +1 -0
- package/dist/core/operations/scaffold-machine.d.ts +16 -0
- package/dist/core/operations/scaffold-machine.d.ts.map +1 -0
- package/dist/core/operations/scaffold-machine.js +51 -0
- package/dist/core/operations/scaffold-machine.js.map +1 -0
- package/dist/core/operations/scaffold-plan.d.ts +43 -0
- package/dist/core/operations/scaffold-plan.d.ts.map +1 -0
- package/dist/core/operations/scaffold-plan.js +187 -0
- package/dist/core/operations/scaffold-plan.js.map +1 -0
- package/dist/core/project/agent-instructions.d.ts +29 -0
- package/dist/core/project/agent-instructions.d.ts.map +1 -0
- package/dist/core/project/agent-instructions.js +160 -0
- package/dist/core/project/agent-instructions.js.map +1 -0
- package/dist/core/project/artifacts.d.ts +58 -0
- package/dist/core/project/artifacts.d.ts.map +1 -0
- package/dist/core/project/artifacts.js +179 -0
- package/dist/core/project/artifacts.js.map +1 -0
- package/dist/core/project/boundaries.d.ts +50 -0
- package/dist/core/project/boundaries.d.ts.map +1 -0
- package/dist/core/project/boundaries.js +117 -0
- package/dist/core/project/boundaries.js.map +1 -0
- package/dist/core/project/capabilities.d.ts +58 -0
- package/dist/core/project/capabilities.d.ts.map +1 -0
- package/dist/core/project/capabilities.js +135 -0
- package/dist/core/project/capabilities.js.map +1 -0
- package/dist/core/project/drift.d.ts +29 -0
- package/dist/core/project/drift.d.ts.map +1 -0
- package/dist/core/project/drift.js +188 -0
- package/dist/core/project/drift.js.map +1 -0
- package/dist/core/project/infra.d.ts +49 -0
- package/dist/core/project/infra.d.ts.map +1 -0
- package/dist/core/project/infra.js +167 -0
- package/dist/core/project/infra.js.map +1 -0
- package/dist/core/project/manifest.d.ts +92 -0
- package/dist/core/project/manifest.d.ts.map +1 -0
- package/dist/core/project/manifest.js +321 -0
- package/dist/core/project/manifest.js.map +1 -0
- package/dist/core/project/state.d.ts +15 -0
- package/dist/core/project/state.d.ts.map +1 -0
- package/dist/core/project/state.js +106 -0
- package/dist/core/project/state.js.map +1 -0
- package/dist/core/project/validation.d.ts +20 -0
- package/dist/core/project/validation.d.ts.map +1 -0
- package/dist/core/project/validation.js +274 -0
- package/dist/core/project/validation.js.map +1 -0
- package/dist/core/project/workflows.d.ts +43 -0
- package/dist/core/project/workflows.d.ts.map +1 -0
- package/dist/core/project/workflows.js +299 -0
- package/dist/core/project/workflows.js.map +1 -0
- package/dist/core/scaffold/auth-generator.d.ts +63 -0
- package/dist/core/scaffold/auth-generator.d.ts.map +1 -0
- package/dist/core/scaffold/auth-generator.js +1774 -0
- package/dist/core/scaffold/auth-generator.js.map +1 -0
- package/dist/core/scaffold/connector-functions-generator.d.ts +41 -0
- package/dist/core/scaffold/connector-functions-generator.d.ts.map +1 -0
- package/dist/core/scaffold/connector-functions-generator.js +1029 -0
- package/dist/core/scaffold/connector-functions-generator.js.map +1 -0
- package/dist/core/scaffold/functions-generator.d.ts +7 -1
- package/dist/core/scaffold/functions-generator.d.ts.map +1 -1
- package/dist/core/scaffold/functions-generator.js +771 -69
- package/dist/core/scaffold/functions-generator.js.map +1 -1
- package/dist/core/scaffold/model-parser.d.ts +21 -1
- package/dist/core/scaffold/model-parser.d.ts.map +1 -1
- package/dist/core/scaffold/model-parser.js +230 -79
- package/dist/core/scaffold/model-parser.js.map +1 -1
- package/dist/core/scaffold/native-schema-generator.d.ts +19 -0
- package/dist/core/scaffold/native-schema-generator.d.ts.map +1 -0
- package/dist/core/scaffold/native-schema-generator.js +753 -0
- package/dist/core/scaffold/native-schema-generator.js.map +1 -0
- package/dist/core/scaffold/nextjs-generator.d.ts +8 -0
- package/dist/core/scaffold/nextjs-generator.d.ts.map +1 -1
- package/dist/core/scaffold/nextjs-generator.js +153 -9
- package/dist/core/scaffold/nextjs-generator.js.map +1 -1
- package/dist/core/scaffold/openapi-generator.d.ts +3 -0
- package/dist/core/scaffold/openapi-generator.d.ts.map +1 -0
- package/dist/core/scaffold/openapi-generator.js +190 -0
- package/dist/core/scaffold/openapi-generator.js.map +1 -0
- package/dist/core/scaffold/ui-generator.d.ts +17 -4
- package/dist/core/scaffold/ui-generator.d.ts.map +1 -1
- package/dist/core/scaffold/ui-generator.js +174 -34
- package/dist/core/scaffold/ui-generator.js.map +1 -1
- package/dist/core/verify/index.d.ts +69 -0
- package/dist/core/verify/index.d.ts.map +1 -0
- package/dist/core/verify/index.js +412 -0
- package/dist/core/verify/index.js.map +1 -0
- package/dist/database/base-model.d.ts +3 -3
- package/dist/database/base-model.js +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/machine/contracts.d.ts +24 -0
- package/dist/machine/contracts.d.ts.map +1 -0
- package/dist/machine/contracts.js +3 -0
- package/dist/machine/contracts.js.map +1 -0
- package/dist/machine/errors.d.ts +14 -0
- package/dist/machine/errors.d.ts.map +1 -0
- package/dist/machine/errors.js +42 -0
- package/dist/machine/errors.js.map +1 -0
- package/dist/machine/index.d.ts +3 -0
- package/dist/machine/index.d.ts.map +1 -0
- package/dist/machine/index.js +566 -0
- package/dist/machine/index.js.map +1 -0
- package/dist/mcp/index.d.ts +25 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +425 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/types/index.d.ts +109 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/package-manager.d.ts +9 -12
- package/dist/utils/package-manager.d.ts.map +1 -1
- package/dist/utils/package-manager.js +51 -22
- package/dist/utils/package-manager.js.map +1 -1
- package/dist/utils/python-uv.d.ts +21 -0
- package/dist/utils/python-uv.d.ts.map +1 -0
- package/dist/utils/python-uv.js +111 -0
- package/dist/utils/python-uv.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +49 -0
- package/dist/version.js.map +1 -0
- package/package.json +16 -17
- package/src/__tests__/__snapshots__/functions-generator.test.ts.snap +1139 -0
- package/src/__tests__/__snapshots__/nextjs-generator.test.ts.snap +206 -0
- package/src/__tests__/__snapshots__/ui-generator.test.ts.snap +532 -0
- package/src/__tests__/agent-instructions.test.ts +237 -0
- package/src/__tests__/agent-loop-phase34.test.ts +513 -0
- package/src/__tests__/auth.test.ts +770 -0
- package/src/__tests__/bff-swa-auth.test.ts +275 -0
- package/src/__tests__/config.test.ts +295 -0
- package/src/__tests__/connector-functions-generator.test.ts +288 -0
- package/src/__tests__/connector-mock-server.test.ts +459 -0
- package/src/__tests__/connector-model-bff.test.ts +162 -0
- package/src/__tests__/cosmos-worktree-isolation.test.ts +149 -0
- package/src/__tests__/dev-seeds.test.ts +236 -0
- package/src/__tests__/dev.test.ts +296 -0
- package/src/__tests__/file-session.test.ts +98 -0
- package/src/__tests__/fixtures.ts +184 -0
- package/src/__tests__/functions-generator.test.ts +237 -0
- package/src/__tests__/init.test.ts +363 -0
- package/src/__tests__/jest-globals.d.ts +8 -0
- package/src/__tests__/machine.test.ts +371 -0
- package/src/__tests__/mcp.test.ts +253 -0
- package/src/__tests__/model-parser.test.ts +142 -0
- package/src/__tests__/multi-auth.test.ts +160 -0
- package/src/__tests__/nextjs-generator.test.ts +105 -0
- package/src/__tests__/openapi-generator.test.ts +43 -0
- package/src/__tests__/package-manager.test.ts +244 -0
- package/src/__tests__/plan-apply.test.ts +499 -0
- package/src/__tests__/python-uv.test.ts +48 -0
- package/src/__tests__/scaffold.test.ts +302 -0
- package/src/__tests__/string-utils.test.ts +75 -0
- package/src/__tests__/tsconfig.json +15 -0
- package/src/__tests__/ui-generator.test.ts +248 -0
- package/src/__tests__/zod-mock-generator.test.ts +132 -0
- package/src/cli/commands/add-auth.ts +853 -0
- package/src/cli/commands/add-connector.ts +159 -0
- package/src/cli/commands/cosmos-worktree-isolation.ts +130 -0
- package/src/cli/commands/create-model.ts +62 -0
- package/src/cli/commands/dev-seeds.ts +629 -0
- package/src/cli/commands/dev.ts +1252 -0
- package/src/cli/commands/index.ts +9 -0
- package/src/cli/commands/init.ts +3414 -0
- package/src/cli/commands/provision.ts +193 -0
- package/src/cli/commands/scaffold.ts +1081 -0
- package/src/cli/index.ts +352 -0
- package/src/core/config.ts +380 -0
- package/src/core/mock/connector-mock-server.ts +555 -0
- package/src/core/mock/zod-mock-generator.ts +205 -0
- package/src/core/operations/auth-operations.ts +360 -0
- package/src/core/operations/create-model.ts +191 -0
- package/src/core/operations/file-session.ts +222 -0
- package/src/core/operations/provision-operations.ts +297 -0
- package/src/core/operations/runtime.ts +258 -0
- package/src/core/operations/scaffold-apply.ts +106 -0
- package/src/core/operations/scaffold-machine.ts +77 -0
- package/src/core/operations/scaffold-plan.ts +215 -0
- package/src/core/project/agent-instructions.ts +167 -0
- package/src/core/project/agent-templates/AGENTS.md +504 -0
- package/src/core/project/agent-templates/CLAUDE.md +31 -0
- package/src/core/project/agent-templates/azure-functions.instructions.md +22 -0
- package/src/core/project/agent-templates/bff-routes.instructions.md +18 -0
- package/src/core/project/agent-templates/copilot-instructions.md +27 -0
- package/src/core/project/agent-templates/shared-models.instructions.md +72 -0
- package/src/core/project/artifacts.ts +205 -0
- package/src/core/project/boundaries.ts +170 -0
- package/src/core/project/capabilities.ts +193 -0
- package/src/core/project/drift.ts +202 -0
- package/src/core/project/infra.ts +196 -0
- package/src/core/project/manifest.ts +402 -0
- package/src/core/project/state.ts +77 -0
- package/src/core/project/validation.ts +295 -0
- package/src/core/project/workflows.ts +295 -0
- package/src/core/scaffold/auth-generator.ts +1824 -0
- package/src/core/scaffold/connector-functions-generator.ts +1133 -0
- package/src/core/scaffold/functions-generator.ts +972 -0
- package/src/core/scaffold/model-parser.ts +781 -0
- package/src/core/scaffold/native-schema-generator.ts +904 -0
- package/src/core/scaffold/nextjs-generator.ts +382 -0
- package/src/core/scaffold/openapi-generator.ts +212 -0
- package/src/core/scaffold/ui-generator.ts +1100 -0
- package/src/core/verify/index.ts +468 -0
- package/src/database/base-model.ts +184 -0
- package/src/database/client.ts +140 -0
- package/src/database/repository.ts +104 -0
- package/src/database/runtime-check.ts +25 -0
- package/src/index.ts +27 -0
- package/src/machine/contracts.ts +33 -0
- package/src/machine/errors.ts +45 -0
- package/src/machine/index.ts +690 -0
- package/src/mcp/index.ts +423 -0
- package/src/types/index.ts +182 -0
- package/src/utils/package-manager.ts +251 -0
- package/src/utils/python-uv.ts +96 -0
- package/src/version.ts +13 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as os from "os";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
buildGeneratedProjectDependencies,
|
|
7
|
+
buildGeneratedProjectDevDependencies,
|
|
8
|
+
buildSharedTsConfig,
|
|
9
|
+
buildAzureSwaPipeline,
|
|
10
|
+
buildSwallowKitMcpProjectConfigSource,
|
|
11
|
+
buildGitHubSwaWorkflow,
|
|
12
|
+
buildCSharpFunctionsProgramSource,
|
|
13
|
+
buildCSharpFunctionsProjectSource,
|
|
14
|
+
buildSwallowKitConfigSource,
|
|
15
|
+
getAzureFunctionsPipeline,
|
|
16
|
+
getGitHubFunctionsWorkflow,
|
|
17
|
+
injectSwallowKitNextConfig,
|
|
18
|
+
parseIgnoredBuilds,
|
|
19
|
+
buildCosmosDbFreeTierBicepSource,
|
|
20
|
+
buildFunctionsHostKeyBicepExpression,
|
|
21
|
+
buildStaticWebAppConfigBicepSource,
|
|
22
|
+
buildTypeScriptFunctionsPackageJson,
|
|
23
|
+
createInfrastructure,
|
|
24
|
+
getStaticWebAppSku,
|
|
25
|
+
withNpmLockfileSafeManifests,
|
|
26
|
+
} from "../cli/commands/init";
|
|
27
|
+
|
|
28
|
+
describe("injectSwallowKitNextConfig", () => {
|
|
29
|
+
it("adds standalone settings without deprecated experimental options", () => {
|
|
30
|
+
const original = `import type { NextConfig } from "next";
|
|
31
|
+
|
|
32
|
+
const nextConfig: NextConfig = {
|
|
33
|
+
/* config options here */
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default nextConfig;
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
const updated = injectSwallowKitNextConfig(original, "sample-app");
|
|
40
|
+
|
|
41
|
+
expect(updated).toContain("output: 'standalone'");
|
|
42
|
+
expect(updated).toContain("agentRules: false");
|
|
43
|
+
expect(updated).toContain("transpilePackages: ['@sample-app/shared']");
|
|
44
|
+
expect(updated).toContain("serverExternalPackages: ['applicationinsights', 'diagnostic-channel-publishers']");
|
|
45
|
+
expect(updated).not.toContain("turbopackUseSystemTlsCerts");
|
|
46
|
+
expect(updated).not.toContain("experimental:");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("supports JavaScript next.config format", () => {
|
|
50
|
+
const original = `const nextConfig = {
|
|
51
|
+
/* config options here */
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
module.exports = nextConfig;
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
const updated = injectSwallowKitNextConfig(original, "sample-app");
|
|
58
|
+
|
|
59
|
+
expect(updated).toContain("transpilePackages: ['@sample-app/shared']");
|
|
60
|
+
expect(updated).toContain("agentRules: false");
|
|
61
|
+
expect(updated).toContain("module.exports = nextConfig;");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("generates a C# Program.cs compatible with the current worker packages", () => {
|
|
65
|
+
const source = buildCSharpFunctionsProgramSource();
|
|
66
|
+
|
|
67
|
+
expect(source).toContain("new HostBuilder()");
|
|
68
|
+
expect(source).toContain(".ConfigureFunctionsWorkerDefaults()");
|
|
69
|
+
expect(source).toContain("services.AddApplicationInsightsTelemetryWorkerService()");
|
|
70
|
+
expect(source).toContain("services.ConfigureFunctionsApplicationInsights()");
|
|
71
|
+
expect(source).toContain("Microsoft.Azure.Functions.Worker.ApplicationInsights");
|
|
72
|
+
expect(source).not.toContain("Microsoft.Azure.Functions.Worker.Builder");
|
|
73
|
+
expect(source).not.toContain("FunctionsApplication.CreateBuilder");
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("excludes nested generated bin and obj files from the C# Functions project", () => {
|
|
77
|
+
const source = buildCSharpFunctionsProjectSource();
|
|
78
|
+
|
|
79
|
+
expect(source).toContain("<TargetFramework>net10.0</TargetFramework>");
|
|
80
|
+
expect(source).toContain('Version="2.52.0"');
|
|
81
|
+
expect(source).toContain('Version="3.3.0"');
|
|
82
|
+
expect(source).toContain('Version="2.0.7"');
|
|
83
|
+
expect(source).toContain('Version="2.50.0"');
|
|
84
|
+
expect(source).toContain('<Compile Remove="generated\\**\\bin\\**\\*.cs;generated\\**\\obj\\**\\*.cs" />');
|
|
85
|
+
expect(source).toContain('<EmbeddedResource Remove="generated\\**\\bin\\**;generated\\**\\obj\\**" />');
|
|
86
|
+
expect(source).toContain('<None Remove="generated\\**\\bin\\**;generated\\**\\obj\\**" />');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("builds swallowkit.config.js without a local swallowkit package type import", () => {
|
|
90
|
+
const source = buildSwallowKitConfigSource("typescript");
|
|
91
|
+
|
|
92
|
+
expect(source).toContain("language: 'typescript'");
|
|
93
|
+
expect(source).toContain("baseUrl: process.env.BACKEND_FUNCTIONS_BASE_URL");
|
|
94
|
+
expect(source).not.toContain("import('swallowkit').SwallowKitConfig");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("builds shared tsconfig with non-deprecated module resolution settings", () => {
|
|
98
|
+
const tsconfig = buildSharedTsConfig();
|
|
99
|
+
|
|
100
|
+
expect(tsconfig.compilerOptions.module).toBe("Node16");
|
|
101
|
+
expect(tsconfig.compilerOptions.moduleResolution).toBe("node16");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("does not add swallowkit as a generated project dependency", () => {
|
|
105
|
+
const dependencies = buildGeneratedProjectDependencies("sample-app");
|
|
106
|
+
|
|
107
|
+
expect(dependencies).toEqual({
|
|
108
|
+
"@azure/cosmos": "^4.0.0",
|
|
109
|
+
applicationinsights: "^3.3.0",
|
|
110
|
+
zod: "^4.0.0",
|
|
111
|
+
"@sample-app/shared": "workspace:*",
|
|
112
|
+
});
|
|
113
|
+
expect(dependencies).not.toHaveProperty("swallowkit");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("uses npm-compatible file dependencies for the shared workspace", () => {
|
|
117
|
+
const dependencies = buildGeneratedProjectDependencies("sample-app", "npm");
|
|
118
|
+
|
|
119
|
+
expect(dependencies["@sample-app/shared"]).toBe("file:shared");
|
|
120
|
+
expect(Object.values(dependencies)).not.toContain("workspace:*");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("uses an npm-compatible shared dependency in the Functions workspace", () => {
|
|
124
|
+
const packageJson = buildTypeScriptFunctionsPackageJson("sample-app", "npm");
|
|
125
|
+
|
|
126
|
+
expect(packageJson.dependencies["@sample-app/shared"]).toBe("file:../shared");
|
|
127
|
+
expect(Object.values(packageJson.dependencies)).not.toContain("workspace:*");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("adds swallowkit as a generated project devDependency", () => {
|
|
131
|
+
const devDependencies = buildGeneratedProjectDevDependencies();
|
|
132
|
+
|
|
133
|
+
expect(devDependencies).toEqual({
|
|
134
|
+
swallowkit: expect.stringMatching(/.+/),
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("builds a project-scoped MCP config that resolves the configured swallowkit-mcp version", () => {
|
|
139
|
+
const source = buildSwallowKitMcpProjectConfigSource();
|
|
140
|
+
const parsed = JSON.parse(source) as {
|
|
141
|
+
mcpServers: {
|
|
142
|
+
swallowkit: {
|
|
143
|
+
command: string;
|
|
144
|
+
args: string[];
|
|
145
|
+
cwd?: string;
|
|
146
|
+
env?: Record<string, string>;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
expect(parsed.mcpServers.swallowkit.command).toBe("pnpm");
|
|
152
|
+
expect(parsed.mcpServers.swallowkit.args).toEqual([
|
|
153
|
+
"dlx",
|
|
154
|
+
"--package",
|
|
155
|
+
"swallowkit@${SWALLOWKIT_MCP_VERSION}",
|
|
156
|
+
"swallowkit-mcp",
|
|
157
|
+
]);
|
|
158
|
+
expect(parsed.mcpServers.swallowkit.cwd).toBe(".");
|
|
159
|
+
expect(parsed.mcpServers.swallowkit.env).toEqual({ SWALLOWKIT_MCP_VERSION: "latest" });
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("builds an npm-based MCP config resolving latest when npm is selected", () => {
|
|
163
|
+
const source = buildSwallowKitMcpProjectConfigSource("npm");
|
|
164
|
+
const parsed = JSON.parse(source);
|
|
165
|
+
|
|
166
|
+
expect(parsed.mcpServers.swallowkit.command).toBe("npx");
|
|
167
|
+
expect(parsed.mcpServers.swallowkit.args).toEqual([
|
|
168
|
+
"--yes",
|
|
169
|
+
"--package",
|
|
170
|
+
"swallowkit@${SWALLOWKIT_MCP_VERSION}",
|
|
171
|
+
"swallowkit-mcp",
|
|
172
|
+
]);
|
|
173
|
+
expect(parsed.mcpServers.swallowkit.env).toEqual({ SWALLOWKIT_MCP_VERSION: "latest" });
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("temporarily rewrites workspace protocol dependencies for npm lockfile generation", async () => {
|
|
177
|
+
const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), "swallowkit-lockfile-"));
|
|
178
|
+
fs.mkdirSync(path.join(projectDir, "shared"));
|
|
179
|
+
fs.mkdirSync(path.join(projectDir, "functions"));
|
|
180
|
+
fs.mkdirSync(path.join(projectDir, "node_modules"));
|
|
181
|
+
fs.mkdirSync(path.join(projectDir, "shared", "node_modules"));
|
|
182
|
+
fs.writeFileSync(path.join(projectDir, "node_modules", ".pnpm-marker"), "root");
|
|
183
|
+
fs.writeFileSync(path.join(projectDir, "shared", "node_modules", ".pnpm-marker"), "shared");
|
|
184
|
+
|
|
185
|
+
const rootPackageJson = {
|
|
186
|
+
name: "sample-app",
|
|
187
|
+
dependencies: {
|
|
188
|
+
"@sample-app/shared": "workspace:*",
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
const functionsPackageJson = {
|
|
192
|
+
name: "functions",
|
|
193
|
+
dependencies: {
|
|
194
|
+
"@sample-app/shared": "workspace:*",
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
const sharedPackageJson = {
|
|
198
|
+
name: "@sample-app/shared",
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
fs.writeFileSync(path.join(projectDir, "package.json"), JSON.stringify(rootPackageJson, null, 2));
|
|
202
|
+
fs.writeFileSync(path.join(projectDir, "functions", "package.json"), JSON.stringify(functionsPackageJson, null, 2));
|
|
203
|
+
fs.writeFileSync(path.join(projectDir, "shared", "package.json"), JSON.stringify(sharedPackageJson, null, 2));
|
|
204
|
+
|
|
205
|
+
await withNpmLockfileSafeManifests(projectDir, async () => {
|
|
206
|
+
const normalizedRoot = JSON.parse(fs.readFileSync(path.join(projectDir, "package.json"), "utf-8"));
|
|
207
|
+
const normalizedFunctions = JSON.parse(fs.readFileSync(path.join(projectDir, "functions", "package.json"), "utf-8"));
|
|
208
|
+
|
|
209
|
+
expect(normalizedRoot.dependencies["@sample-app/shared"]).toBe("file:shared");
|
|
210
|
+
expect(normalizedFunctions.dependencies["@sample-app/shared"]).toBe("file:../shared");
|
|
211
|
+
expect(fs.existsSync(path.join(projectDir, "node_modules"))).toBe(false);
|
|
212
|
+
expect(fs.existsSync(path.join(projectDir, "shared", "node_modules"))).toBe(false);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
expect(JSON.parse(fs.readFileSync(path.join(projectDir, "package.json"), "utf-8"))).toEqual(rootPackageJson);
|
|
216
|
+
expect(JSON.parse(fs.readFileSync(path.join(projectDir, "functions", "package.json"), "utf-8"))).toEqual(functionsPackageJson);
|
|
217
|
+
expect(fs.readFileSync(path.join(projectDir, "node_modules", ".pnpm-marker"), "utf-8")).toBe("root");
|
|
218
|
+
expect(fs.readFileSync(path.join(projectDir, "shared", "node_modules", ".pnpm-marker"), "utf-8")).toBe("shared");
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
describe("parseIgnoredBuilds", () => {
|
|
223
|
+
it("extracts package names from the pnpm warning line", () => {
|
|
224
|
+
const output = [
|
|
225
|
+
"WARN Issues with peer dependencies found",
|
|
226
|
+
" ERR_PNPM_IGNORED_BUILDS Ignored build scripts: sharp@0.34.5, unrs-resolver@1.12.2",
|
|
227
|
+
"run pnpm approve-builds",
|
|
228
|
+
].join("\n");
|
|
229
|
+
expect(parseIgnoredBuilds(output)).toEqual(["sharp", "unrs-resolver"]);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("handles scoped packages and de-duplicates entries", () => {
|
|
233
|
+
const output = "Ignored build scripts: @scope/pkg@1.0.0, sharp@0.34.5, sharp@0.34.5";
|
|
234
|
+
expect(parseIgnoredBuilds(output)).toEqual(["@scope/pkg", "sharp"]);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("returns an empty array when no warning is present", () => {
|
|
238
|
+
expect(parseIgnoredBuilds("everything is fine")).toEqual([]);
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
describe("buildCosmosDbFreeTierBicepSource", () => {
|
|
244
|
+
it("keeps database-level shared throughput at 1000 RU/s for Free Tier", () => {
|
|
245
|
+
const source = buildCosmosDbFreeTierBicepSource();
|
|
246
|
+
|
|
247
|
+
expect(source).toContain("throughput: 1000");
|
|
248
|
+
expect(source).not.toContain("containers");
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
describe("Static Web Apps plan", () => {
|
|
253
|
+
it("maps init plan values to Azure SKU names", () => {
|
|
254
|
+
expect(getStaticWebAppSku("free")).toBe("Free");
|
|
255
|
+
expect(getStaticWebAppSku("standard")).toBe("Standard");
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
describe("Functions host key infrastructure", () => {
|
|
260
|
+
it("reads the generated default host key without exposing a literal value", () => {
|
|
261
|
+
const expression = buildFunctionsHostKeyBicepExpression();
|
|
262
|
+
expect(expression).toContain("listKeys(");
|
|
263
|
+
expect(expression).toContain("functionKeys.default");
|
|
264
|
+
expect(expression).toContain("${resourceId('Microsoft.Web/sites', functionsAppName)}/host/default");
|
|
265
|
+
expect(expression).not.toContain("Microsoft.Web/sites/host");
|
|
266
|
+
expect(expression).not.toContain("functionsFlex.outputs.id");
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it("resolves the key inside the SWA config module after Functions deployment", () => {
|
|
270
|
+
const source = buildStaticWebAppConfigBicepSource();
|
|
271
|
+
expect(source).toContain("param functionsAppName string");
|
|
272
|
+
expect(source).toContain("BACKEND_FUNCTIONS_KEY: listKeys(");
|
|
273
|
+
expect(source).not.toContain("param functionsHostKey string");
|
|
274
|
+
expect(source).not.toContain("output functionsHostKey");
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
describe("Infrastructure generation", () => {
|
|
279
|
+
it.each([
|
|
280
|
+
["freetier", "free"],
|
|
281
|
+
["serverless", "standard"],
|
|
282
|
+
] as Array<["freetier" | "serverless", "free" | "standard"]>)(
|
|
283
|
+
"emits VNet module definitions with VNet disabled (%s)",
|
|
284
|
+
async (cosmosDbMode, swaPlan) => {
|
|
285
|
+
const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), "swallowkit-infra-no-vnet-"));
|
|
286
|
+
|
|
287
|
+
await createInfrastructure(
|
|
288
|
+
projectDir,
|
|
289
|
+
"sample-app",
|
|
290
|
+
{ cosmosDbMode, vnetOption: "none", swaPlan },
|
|
291
|
+
"typescript",
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
expect(fs.existsSync(path.join(projectDir, "infra", "modules", "vnet.bicep"))).toBe(true);
|
|
295
|
+
expect(fs.existsSync(path.join(projectDir, "infra", "modules", "private-endpoint-cosmos.bicep"))).toBe(true);
|
|
296
|
+
|
|
297
|
+
const mainBicep = fs.readFileSync(path.join(projectDir, "infra", "main.bicep"), "utf-8");
|
|
298
|
+
expect(mainBicep).toContain("param enableVNet bool = false");
|
|
299
|
+
expect(mainBicep).toContain("module vnet 'modules/vnet.bicep' = if (enableVNet)");
|
|
300
|
+
expect(mainBicep).toContain("functionsAppName: functionsFlex.outputs.name");
|
|
301
|
+
expect(mainBicep).not.toContain("functionsHostKey:");
|
|
302
|
+
},
|
|
303
|
+
);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
describe("GitHub Actions workflow generation", () => {
|
|
307
|
+
it("uses npm ci for the SWA workflow when the project was initialized with pnpm", () => {
|
|
308
|
+
const workflow = buildGitHubSwaWorkflow("npm", "pnpm");
|
|
309
|
+
|
|
310
|
+
expect(workflow).toContain("Normalize pnpm workspace for npm CI");
|
|
311
|
+
expect(workflow).toContain("root.workspaces = ['shared', 'functions']");
|
|
312
|
+
expect(workflow).toContain("replaceSharedWorkspaceDep(root, 'file:shared')");
|
|
313
|
+
expect(workflow).toContain("root.scripts.build = \"npm run --workspace=shared build");
|
|
314
|
+
expect(workflow).toContain("npm install --package-lock-only --ignore-scripts");
|
|
315
|
+
expect(workflow).toContain("npm ci && npm run build");
|
|
316
|
+
expect(workflow).not.toContain("npm install && npm run build");
|
|
317
|
+
expect(workflow).not.toContain("pnpm/action-setup");
|
|
318
|
+
expect(workflow).not.toContain("pnpm install --frozen-lockfile");
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it("uses npm ci for the Functions workflow when the project was initialized with pnpm", () => {
|
|
322
|
+
const workflow = getGitHubFunctionsWorkflow("npm", "typescript", "pnpm");
|
|
323
|
+
|
|
324
|
+
expect(workflow).toContain("Normalize pnpm workspace for npm CI");
|
|
325
|
+
expect(workflow).toContain("replaceSharedWorkspaceDep(functionsPkg, 'file:../shared')");
|
|
326
|
+
expect(workflow).toContain("functionsPkg.scripts.prestart = 'npm run build'");
|
|
327
|
+
expect(workflow).toContain("npm install --package-lock-only --ignore-scripts");
|
|
328
|
+
expect(workflow).toContain("- name: Install dependencies\n run: |\n npm ci");
|
|
329
|
+
expect(workflow).toContain("npm run --workspace=shared build");
|
|
330
|
+
expect(workflow).toContain("npm run --workspace=functions build");
|
|
331
|
+
expect(workflow).not.toContain("pnpm/action-setup");
|
|
332
|
+
expect(workflow).not.toContain("pnpm install --frozen-lockfile");
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it("uses npm ci for the SWA pipeline when the project was initialized with pnpm", () => {
|
|
336
|
+
const pipeline = buildAzureSwaPipeline("npm", "pnpm");
|
|
337
|
+
|
|
338
|
+
expect(pipeline).toContain("Normalize pnpm workspace for npm CI");
|
|
339
|
+
expect(pipeline).toContain("root.workspaces = ['shared', 'functions']");
|
|
340
|
+
expect(pipeline).toContain("replaceSharedWorkspaceDep(root, 'file:shared')");
|
|
341
|
+
expect(pipeline).toContain("root.scripts.build = \"npm run --workspace=shared build");
|
|
342
|
+
expect(pipeline).toContain("npm install --package-lock-only --ignore-scripts");
|
|
343
|
+
expect(pipeline).toContain("npm ci");
|
|
344
|
+
expect(pipeline).not.toContain("- script: |\n npm install\n displayName: 'Install dependencies'");
|
|
345
|
+
expect(pipeline).toContain("npm run build");
|
|
346
|
+
expect(pipeline).not.toContain("corepack enable");
|
|
347
|
+
expect(pipeline).not.toContain("pnpm install --frozen-lockfile");
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it("uses npm ci for the Functions pipeline when the project was initialized with pnpm", () => {
|
|
351
|
+
const pipeline = getAzureFunctionsPipeline("npm", "typescript", "pnpm");
|
|
352
|
+
|
|
353
|
+
expect(pipeline).toContain("Normalize pnpm workspace for npm CI");
|
|
354
|
+
expect(pipeline).toContain("replaceSharedWorkspaceDep(functionsPkg, 'file:../shared')");
|
|
355
|
+
expect(pipeline).toContain("functionsPkg.scripts.prestart = 'npm run build'");
|
|
356
|
+
expect(pipeline).toContain("npm install --package-lock-only --ignore-scripts");
|
|
357
|
+
expect(pipeline).toContain("- script: |\n npm ci\n displayName: 'Install workspace dependencies'");
|
|
358
|
+
expect(pipeline).toContain("npm run --workspace=shared build");
|
|
359
|
+
expect(pipeline).toContain("npm run --workspace=functions build");
|
|
360
|
+
expect(pipeline).not.toContain("corepack enable");
|
|
361
|
+
expect(pipeline).not.toContain("pnpm install --frozen-lockfile");
|
|
362
|
+
});
|
|
363
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const describe: typeof import("@jest/globals").describe;
|
|
2
|
+
declare const it: typeof import("@jest/globals").it;
|
|
3
|
+
declare const expect: typeof import("@jest/globals").expect;
|
|
4
|
+
declare const beforeAll: typeof import("@jest/globals").beforeAll;
|
|
5
|
+
declare const afterAll: typeof import("@jest/globals").afterAll;
|
|
6
|
+
declare const beforeEach: typeof import("@jest/globals").beforeEach;
|
|
7
|
+
declare const afterEach: typeof import("@jest/globals").afterEach;
|
|
8
|
+
declare const jest: typeof import("@jest/globals").jest;
|