swallowkit 1.0.0-beta.5 → 1.0.0-beta.51
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/LICENSE +21 -21
- package/README.ja.md +153 -242
- package/README.md +153 -243
- package/dist/__tests__/fixtures.d.ts +22 -0
- package/dist/__tests__/fixtures.d.ts.map +1 -0
- package/dist/__tests__/fixtures.js +146 -0
- package/dist/__tests__/fixtures.js.map +1 -0
- package/dist/cli/commands/add-auth.d.ts +13 -0
- package/dist/cli/commands/add-auth.d.ts.map +1 -0
- package/dist/cli/commands/add-auth.js +759 -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 +163 -0
- package/dist/cli/commands/add-connector.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 +19 -81
- package/dist/cli/commands/create-model.js.map +1 -1
- package/dist/cli/commands/dev-seeds.d.ts +57 -0
- package/dist/cli/commands/dev-seeds.d.ts.map +1 -0
- package/dist/cli/commands/dev-seeds.js +470 -0
- package/dist/cli/commands/dev-seeds.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +37 -0
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/dev.js +720 -156
- 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 +73 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +3089 -1779
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/scaffold.d.ts +13 -0
- package/dist/cli/commands/scaffold.d.ts.map +1 -1
- package/dist/cli/commands/scaffold.js +513 -129
- 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 +206 -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 +172 -5
- 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/create-model.d.ts +15 -0
- package/dist/core/operations/create-model.d.ts.map +1 -0
- package/dist/core/operations/create-model.js +171 -0
- package/dist/core/operations/create-model.js.map +1 -0
- package/dist/core/operations/runtime.d.ts +32 -0
- package/dist/core/operations/runtime.d.ts.map +1 -0
- package/dist/core/operations/runtime.js +225 -0
- package/dist/core/operations/runtime.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 +63 -0
- package/dist/core/operations/scaffold-machine.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/validation.d.ts +20 -0
- package/dist/core/project/validation.d.ts.map +1 -0
- package/dist/core/project/validation.js +226 -0
- package/dist/core/project/validation.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 +1714 -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 +922 -220
- package/dist/core/scaffold/functions-generator.js.map +1 -1
- package/dist/core/scaffold/model-parser.d.ts +20 -1
- package/dist/core/scaffold/model-parser.d.ts.map +1 -1
- package/dist/core/scaffold/model-parser.js +333 -139
- 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 -0
- package/dist/core/scaffold/native-schema-generator.js +696 -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 +326 -182
- 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 +13 -4
- package/dist/core/scaffold/ui-generator.d.ts.map +1 -1
- package/dist/core/scaffold/ui-generator.js +772 -663
- package/dist/core/scaffold/ui-generator.js.map +1 -1
- 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 +16 -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 +11 -0
- package/dist/machine/errors.d.ts.map +1 -0
- package/dist/machine/errors.js +34 -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 +156 -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 +202 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/types/index.d.ts +95 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/package-manager.d.ts +5 -2
- package/dist/utils/package-manager.d.ts.map +1 -1
- package/dist/utils/package-manager.js +34 -13
- 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 +84 -74
- 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__/auth.test.ts +761 -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 +439 -0
- package/src/__tests__/connector-model-bff.test.ts +162 -0
- package/src/__tests__/dev-seeds.test.ts +173 -0
- package/src/__tests__/dev.test.ts +287 -0
- package/src/__tests__/fixtures.ts +144 -0
- package/src/__tests__/functions-generator.test.ts +237 -0
- package/src/__tests__/init.test.ts +356 -0
- package/src/__tests__/jest-globals.d.ts +8 -0
- package/src/__tests__/machine.test.ts +356 -0
- package/src/__tests__/mcp.test.ts +145 -0
- package/src/__tests__/model-parser.test.ts +52 -0
- package/src/__tests__/multi-auth.test.ts +133 -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 +227 -0
- package/src/__tests__/python-uv.test.ts +48 -0
- package/src/__tests__/scaffold.test.ts +191 -0
- package/src/__tests__/string-utils.test.ts +75 -0
- package/src/__tests__/tsconfig.json +15 -0
- package/src/__tests__/ui-generator.test.ts +144 -0
- package/src/__tests__/zod-mock-generator.test.ts +132 -0
- package/src/cli/commands/add-auth.ts +815 -0
- package/src/cli/commands/add-connector.ts +158 -0
- package/src/cli/commands/create-model.ts +62 -0
- package/src/cli/commands/dev-seeds.ts +614 -0
- package/src/cli/commands/dev.ts +1234 -0
- package/src/cli/commands/index.ts +9 -0
- package/src/cli/commands/init.ts +3902 -0
- package/src/cli/commands/provision.ts +193 -0
- package/src/cli/commands/scaffold.ts +1067 -0
- package/src/cli/index.ts +202 -0
- package/src/core/config.ts +379 -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/create-model.ts +174 -0
- package/src/core/operations/runtime.ts +235 -0
- package/src/core/operations/scaffold-machine.ts +91 -0
- package/src/core/project/manifest.ts +402 -0
- package/src/core/project/validation.ts +245 -0
- package/src/core/scaffold/auth-generator.ts +1760 -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 +847 -0
- package/src/core/scaffold/native-schema-generator.ts +822 -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 +1068 -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 +17 -0
- package/src/machine/errors.ts +34 -0
- package/src/machine/index.ts +173 -0
- package/src/mcp/index.ts +209 -0
- package/src/types/index.ts +165 -0
- package/src/utils/package-manager.ts +246 -0
- package/src/utils/python-uv.ts +96 -0
- package/src/version.ts +13 -0
- package/dist/cli/commands/build.d.ts +0 -6
- package/dist/cli/commands/build.d.ts.map +0 -1
- package/dist/cli/commands/build.js +0 -177
- package/dist/cli/commands/build.js.map +0 -1
- package/dist/cli/commands/deploy.d.ts +0 -3
- package/dist/cli/commands/deploy.d.ts.map +0 -1
- package/dist/cli/commands/deploy.js +0 -147
- package/dist/cli/commands/deploy.js.map +0 -1
- package/dist/cli/commands/setup.d.ts +0 -6
- package/dist/cli/commands/setup.d.ts.map +0 -1
- package/dist/cli/commands/setup.js +0 -254
- package/dist/cli/commands/setup.js.map +0 -1
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateCSharpAzureFunctionsCRUD,
|
|
3
|
+
generateCompactAzureFunctionsCRUD,
|
|
4
|
+
generatePythonAzureFunctionsCRUD,
|
|
5
|
+
} from "../core/scaffold/functions-generator";
|
|
6
|
+
import { createBasicModelInfo, createModelInfoWithEnum } from "./fixtures";
|
|
7
|
+
|
|
8
|
+
describe("generateCompactAzureFunctionsCRUD", () => {
|
|
9
|
+
it("generates correct CRUD code for a basic model", () => {
|
|
10
|
+
const model = createBasicModelInfo();
|
|
11
|
+
const code = generateCompactAzureFunctionsCRUD(model, "@myapp/shared");
|
|
12
|
+
expect(code).toMatchSnapshot();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("generates correct CRUD code for a model with enum fields", () => {
|
|
16
|
+
const model = createModelInfoWithEnum();
|
|
17
|
+
const code = generateCompactAzureFunctionsCRUD(model, "@myapp/shared");
|
|
18
|
+
expect(code).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("imports the correct schema from shared package", () => {
|
|
22
|
+
const model = createBasicModelInfo();
|
|
23
|
+
const code = generateCompactAzureFunctionsCRUD(model, "@myapp/shared");
|
|
24
|
+
expect(code).toContain("import { todoSchema } from '@myapp/shared'");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("uses correct container name (PascalCase + s)", () => {
|
|
28
|
+
const model = createBasicModelInfo();
|
|
29
|
+
const code = generateCompactAzureFunctionsCRUD(model, "@myapp/shared");
|
|
30
|
+
expect(code).toContain("const containerName = 'Todos'");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("registers correct route names (camelCase)", () => {
|
|
34
|
+
const model = createBasicModelInfo();
|
|
35
|
+
const code = generateCompactAzureFunctionsCRUD(model, "@myapp/shared");
|
|
36
|
+
expect(code).toContain("'todo-get-all'");
|
|
37
|
+
expect(code).toContain("'todo-get-by-id'");
|
|
38
|
+
expect(code).toContain("'todo-create'");
|
|
39
|
+
expect(code).toContain("'todo-update'");
|
|
40
|
+
expect(code).toContain("'todo-delete'");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("generates all CRUD HTTP methods", () => {
|
|
44
|
+
const model = createBasicModelInfo();
|
|
45
|
+
const code = generateCompactAzureFunctionsCRUD(model, "@myapp/shared");
|
|
46
|
+
expect(code).toContain("methods: ['GET']");
|
|
47
|
+
expect(code).toContain("methods: ['POST']");
|
|
48
|
+
expect(code).toContain("methods: ['PUT']");
|
|
49
|
+
expect(code).toContain("methods: ['DELETE']");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("uses correct route patterns", () => {
|
|
53
|
+
const model = createBasicModelInfo();
|
|
54
|
+
const code = generateCompactAzureFunctionsCRUD(model, "@myapp/shared");
|
|
55
|
+
expect(code).toContain("route: 'todo'");
|
|
56
|
+
expect(code).toContain("route: 'todo/{id}'");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("handles multi-word model names correctly", () => {
|
|
60
|
+
const model = createBasicModelInfo({
|
|
61
|
+
name: "TodoItem",
|
|
62
|
+
schemaName: "todoItemSchema",
|
|
63
|
+
});
|
|
64
|
+
const code = generateCompactAzureFunctionsCRUD(model, "@myapp/shared");
|
|
65
|
+
expect(code).toContain("const containerName = 'TodoItems'");
|
|
66
|
+
expect(code).toContain("route: 'todoItem'");
|
|
67
|
+
expect(code).toContain("'todoItem-get-all'");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("generates C# Cosmos-backed CRUD handlers", () => {
|
|
71
|
+
const model = createBasicModelInfo();
|
|
72
|
+
const code = generateCSharpAzureFunctionsCRUD(model);
|
|
73
|
+
expect(code).toContain("public sealed class TodoCrudFunctions");
|
|
74
|
+
expect(code).toContain('[Function("todoGetAll")]');
|
|
75
|
+
expect(code).toContain('Route = "todo/{id}"');
|
|
76
|
+
expect(code).toContain("CreateCosmosClient()");
|
|
77
|
+
expect(code).toContain('new CosmosClientOptions { ConnectionMode = ConnectionMode.Gateway }');
|
|
78
|
+
expect(code).toContain('endpoint.Contains("localhost:8081", StringComparison.OrdinalIgnoreCase)');
|
|
79
|
+
expect(code).toContain("container.ReadItemStreamAsync");
|
|
80
|
+
expect(code).toContain("JsonNode.Parse(document.RootElement.GetRawText())?.AsObject()");
|
|
81
|
+
expect(code).toContain("container.CreateItemStreamAsync");
|
|
82
|
+
expect(code).toContain("container.ReplaceItemStreamAsync");
|
|
83
|
+
expect(code).toContain("payload.ToJsonString()");
|
|
84
|
+
expect(code).toContain("container.DeleteItemAsync<JsonObject>");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("generates Python Cosmos-backed CRUD handlers", () => {
|
|
88
|
+
const model = createBasicModelInfo();
|
|
89
|
+
const generated = generatePythonAzureFunctionsCRUD(model);
|
|
90
|
+
expect(generated.registration).toContain("from blueprints.todo import bp as todo_bp");
|
|
91
|
+
expect(generated.registration).toContain("app.register_blueprint(todo_bp)");
|
|
92
|
+
expect(generated.blueprint).toContain('@bp.route(route="todo", methods=["GET"])');
|
|
93
|
+
expect(generated.blueprint).toContain("def todo_create");
|
|
94
|
+
expect(generated.blueprint).toContain("from azure.cosmos import CosmosClient, exceptions");
|
|
95
|
+
expect(generated.blueprint).toContain("container.query_items");
|
|
96
|
+
expect(generated.blueprint).toContain("container.read_item");
|
|
97
|
+
expect(generated.blueprint).toContain("container.create_item");
|
|
98
|
+
expect(generated.blueprint).toContain("container.replace_item");
|
|
99
|
+
expect(generated.blueprint).toContain("container.delete_item");
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// --- Custom Partition Key Tests ---
|
|
103
|
+
|
|
104
|
+
describe("custom partition key (TS)", () => {
|
|
105
|
+
it("uses input binding when partitionKey is /id (default)", () => {
|
|
106
|
+
const model = createBasicModelInfo({ partitionKey: "/id" });
|
|
107
|
+
const code = generateCompactAzureFunctionsCRUD(model, "@myapp/shared");
|
|
108
|
+
expect(code).toContain("partitionKey: '{id}'");
|
|
109
|
+
expect(code).toContain("container.item(id, id).delete()");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("uses SDK direct call when partitionKey is not /id", () => {
|
|
113
|
+
const model = createBasicModelInfo({
|
|
114
|
+
partitionKey: "/tenantId",
|
|
115
|
+
fields: [
|
|
116
|
+
{ name: "id", type: "string", isOptional: false, isArray: false },
|
|
117
|
+
{ name: "tenantId", type: "string", isOptional: false, isArray: false },
|
|
118
|
+
{ name: "title", type: "string", isOptional: false, isArray: false },
|
|
119
|
+
{ name: "createdAt", type: "string", isOptional: false, isArray: false },
|
|
120
|
+
{ name: "updatedAt", type: "string", isOptional: false, isArray: false },
|
|
121
|
+
],
|
|
122
|
+
});
|
|
123
|
+
const code = generateCompactAzureFunctionsCRUD(model, "@myapp/shared");
|
|
124
|
+
|
|
125
|
+
// Should NOT have input binding with partitionKey
|
|
126
|
+
expect(code).not.toContain("partitionKey: '{id}'");
|
|
127
|
+
// getById should use SDK query
|
|
128
|
+
expect(code).toContain("custom partition key");
|
|
129
|
+
expect(code).toContain("SELECT * FROM c WHERE c.id = @id");
|
|
130
|
+
// delete should read doc first to get PK value
|
|
131
|
+
expect(code).toContain("resources[0].tenantId");
|
|
132
|
+
expect(code).toContain("container.item(id, pkValue).delete()");
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("generates snapshot for custom partition key TS", () => {
|
|
136
|
+
const model = createBasicModelInfo({
|
|
137
|
+
partitionKey: "/tenantId",
|
|
138
|
+
fields: [
|
|
139
|
+
{ name: "id", type: "string", isOptional: false, isArray: false },
|
|
140
|
+
{ name: "tenantId", type: "string", isOptional: false, isArray: false },
|
|
141
|
+
{ name: "title", type: "string", isOptional: false, isArray: false },
|
|
142
|
+
{ name: "createdAt", type: "string", isOptional: false, isArray: false },
|
|
143
|
+
{ name: "updatedAt", type: "string", isOptional: false, isArray: false },
|
|
144
|
+
],
|
|
145
|
+
});
|
|
146
|
+
const code = generateCompactAzureFunctionsCRUD(model, "@myapp/shared");
|
|
147
|
+
expect(code).toMatchSnapshot();
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
describe("custom partition key (C#)", () => {
|
|
152
|
+
it("uses ReadItemStreamAsync when partitionKey is /id", () => {
|
|
153
|
+
const model = createBasicModelInfo({ partitionKey: "/id" });
|
|
154
|
+
const code = generateCSharpAzureFunctionsCRUD(model);
|
|
155
|
+
expect(code).toContain("ReadItemStreamAsync(id, new PartitionKey(id))");
|
|
156
|
+
expect(code).toContain("DeleteItemAsync<JsonObject>(id, new PartitionKey(id))");
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("uses query when partitionKey is not /id", () => {
|
|
160
|
+
const model = createBasicModelInfo({
|
|
161
|
+
partitionKey: "/tenantId",
|
|
162
|
+
fields: [
|
|
163
|
+
{ name: "id", type: "string", isOptional: false, isArray: false },
|
|
164
|
+
{ name: "tenantId", type: "string", isOptional: false, isArray: false },
|
|
165
|
+
{ name: "title", type: "string", isOptional: false, isArray: false },
|
|
166
|
+
{ name: "createdAt", type: "string", isOptional: false, isArray: false },
|
|
167
|
+
{ name: "updatedAt", type: "string", isOptional: false, isArray: false },
|
|
168
|
+
],
|
|
169
|
+
});
|
|
170
|
+
const code = generateCSharpAzureFunctionsCRUD(model);
|
|
171
|
+
// ReadCosmosItemAsync should use query instead of point read
|
|
172
|
+
expect(code).toContain("GetItemQueryStreamIterator(query)");
|
|
173
|
+
expect(code).not.toContain("ReadItemStreamAsync(id, new PartitionKey(id))");
|
|
174
|
+
// Delete should read doc first for PK value
|
|
175
|
+
expect(code).toContain('existing["tenantId"]');
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it("generates snapshot for custom partition key C#", () => {
|
|
179
|
+
const model = createBasicModelInfo({
|
|
180
|
+
partitionKey: "/tenantId",
|
|
181
|
+
fields: [
|
|
182
|
+
{ name: "id", type: "string", isOptional: false, isArray: false },
|
|
183
|
+
{ name: "tenantId", type: "string", isOptional: false, isArray: false },
|
|
184
|
+
{ name: "title", type: "string", isOptional: false, isArray: false },
|
|
185
|
+
{ name: "createdAt", type: "string", isOptional: false, isArray: false },
|
|
186
|
+
{ name: "updatedAt", type: "string", isOptional: false, isArray: false },
|
|
187
|
+
],
|
|
188
|
+
});
|
|
189
|
+
const code = generateCSharpAzureFunctionsCRUD(model);
|
|
190
|
+
expect(code).toMatchSnapshot();
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe("custom partition key (Python)", () => {
|
|
195
|
+
it("uses read_item with partition_key=item_id when partitionKey is /id", () => {
|
|
196
|
+
const model = createBasicModelInfo({ partitionKey: "/id" });
|
|
197
|
+
const generated = generatePythonAzureFunctionsCRUD(model);
|
|
198
|
+
expect(generated.blueprint).toContain("partition_key=item_id");
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it("uses cross-partition query when partitionKey is not /id", () => {
|
|
202
|
+
const model = createBasicModelInfo({
|
|
203
|
+
partitionKey: "/tenantId",
|
|
204
|
+
fields: [
|
|
205
|
+
{ name: "id", type: "string", isOptional: false, isArray: false },
|
|
206
|
+
{ name: "tenantId", type: "string", isOptional: false, isArray: false },
|
|
207
|
+
{ name: "title", type: "string", isOptional: false, isArray: false },
|
|
208
|
+
{ name: "createdAt", type: "string", isOptional: false, isArray: false },
|
|
209
|
+
{ name: "updatedAt", type: "string", isOptional: false, isArray: false },
|
|
210
|
+
],
|
|
211
|
+
});
|
|
212
|
+
const generated = generatePythonAzureFunctionsCRUD(model);
|
|
213
|
+
// Should not use direct read_item with partition_key=item_id
|
|
214
|
+
expect(generated.blueprint).not.toContain("partition_key=item_id");
|
|
215
|
+
// Should use cross-partition query
|
|
216
|
+
expect(generated.blueprint).toContain("enable_cross_partition_query=True");
|
|
217
|
+
expect(generated.blueprint).toContain('SELECT * FROM c WHERE c.id = @id');
|
|
218
|
+
// Delete should get PK value from document
|
|
219
|
+
expect(generated.blueprint).toContain('.get("tenantId")');
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it("generates snapshot for custom partition key Python", () => {
|
|
223
|
+
const model = createBasicModelInfo({
|
|
224
|
+
partitionKey: "/tenantId",
|
|
225
|
+
fields: [
|
|
226
|
+
{ name: "id", type: "string", isOptional: false, isArray: false },
|
|
227
|
+
{ name: "tenantId", type: "string", isOptional: false, isArray: false },
|
|
228
|
+
{ name: "title", type: "string", isOptional: false, isArray: false },
|
|
229
|
+
{ name: "createdAt", type: "string", isOptional: false, isArray: false },
|
|
230
|
+
{ name: "updatedAt", type: "string", isOptional: false, isArray: false },
|
|
231
|
+
],
|
|
232
|
+
});
|
|
233
|
+
const generated = generatePythonAzureFunctionsCRUD(model);
|
|
234
|
+
expect(generated.blueprint).toMatchSnapshot();
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
});
|
|
@@ -0,0 +1,356 @@
|
|
|
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("transpilePackages: ['@sample-app/shared']");
|
|
43
|
+
expect(updated).toContain("serverExternalPackages: ['applicationinsights', 'diagnostic-channel-publishers']");
|
|
44
|
+
expect(updated).not.toContain("turbopackUseSystemTlsCerts");
|
|
45
|
+
expect(updated).not.toContain("experimental:");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("supports JavaScript next.config format", () => {
|
|
49
|
+
const original = `const nextConfig = {
|
|
50
|
+
/* config options here */
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
module.exports = nextConfig;
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const updated = injectSwallowKitNextConfig(original, "sample-app");
|
|
57
|
+
|
|
58
|
+
expect(updated).toContain("transpilePackages: ['@sample-app/shared']");
|
|
59
|
+
expect(updated).toContain("module.exports = nextConfig;");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("generates a C# Program.cs compatible with the current worker packages", () => {
|
|
63
|
+
const source = buildCSharpFunctionsProgramSource();
|
|
64
|
+
|
|
65
|
+
expect(source).toContain("new HostBuilder()");
|
|
66
|
+
expect(source).toContain(".ConfigureFunctionsWorkerDefaults()");
|
|
67
|
+
expect(source).toContain("services.AddApplicationInsightsTelemetryWorkerService()");
|
|
68
|
+
expect(source).toContain("services.ConfigureFunctionsApplicationInsights()");
|
|
69
|
+
expect(source).toContain("Microsoft.Azure.Functions.Worker.ApplicationInsights");
|
|
70
|
+
expect(source).not.toContain("Microsoft.Azure.Functions.Worker.Builder");
|
|
71
|
+
expect(source).not.toContain("FunctionsApplication.CreateBuilder");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("excludes nested generated bin and obj files from the C# Functions project", () => {
|
|
75
|
+
const source = buildCSharpFunctionsProjectSource();
|
|
76
|
+
|
|
77
|
+
expect(source).toContain("<TargetFramework>net10.0</TargetFramework>");
|
|
78
|
+
expect(source).toContain('Version="2.52.0"');
|
|
79
|
+
expect(source).toContain('Version="3.3.0"');
|
|
80
|
+
expect(source).toContain('Version="2.0.7"');
|
|
81
|
+
expect(source).toContain('Version="2.50.0"');
|
|
82
|
+
expect(source).toContain('<Compile Remove="generated\\**\\bin\\**\\*.cs;generated\\**\\obj\\**\\*.cs" />');
|
|
83
|
+
expect(source).toContain('<EmbeddedResource Remove="generated\\**\\bin\\**;generated\\**\\obj\\**" />');
|
|
84
|
+
expect(source).toContain('<None Remove="generated\\**\\bin\\**;generated\\**\\obj\\**" />');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("builds swallowkit.config.js without a local swallowkit package type import", () => {
|
|
88
|
+
const source = buildSwallowKitConfigSource("typescript");
|
|
89
|
+
|
|
90
|
+
expect(source).toContain("language: 'typescript'");
|
|
91
|
+
expect(source).toContain("baseUrl: process.env.BACKEND_FUNCTIONS_BASE_URL");
|
|
92
|
+
expect(source).not.toContain("import('swallowkit').SwallowKitConfig");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("builds shared tsconfig with non-deprecated module resolution settings", () => {
|
|
96
|
+
const tsconfig = buildSharedTsConfig();
|
|
97
|
+
|
|
98
|
+
expect(tsconfig.compilerOptions.module).toBe("Node16");
|
|
99
|
+
expect(tsconfig.compilerOptions.moduleResolution).toBe("node16");
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("does not add swallowkit as a generated project dependency", () => {
|
|
103
|
+
const dependencies = buildGeneratedProjectDependencies("sample-app");
|
|
104
|
+
|
|
105
|
+
expect(dependencies).toEqual({
|
|
106
|
+
"@azure/cosmos": "^4.0.0",
|
|
107
|
+
applicationinsights: "^3.3.0",
|
|
108
|
+
zod: "^4.0.0",
|
|
109
|
+
"@sample-app/shared": "workspace:*",
|
|
110
|
+
});
|
|
111
|
+
expect(dependencies).not.toHaveProperty("swallowkit");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("uses npm-compatible file dependencies for the shared workspace", () => {
|
|
115
|
+
const dependencies = buildGeneratedProjectDependencies("sample-app", "npm");
|
|
116
|
+
|
|
117
|
+
expect(dependencies["@sample-app/shared"]).toBe("file:shared");
|
|
118
|
+
expect(Object.values(dependencies)).not.toContain("workspace:*");
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("uses an npm-compatible shared dependency in the Functions workspace", () => {
|
|
122
|
+
const packageJson = buildTypeScriptFunctionsPackageJson("sample-app", "npm");
|
|
123
|
+
|
|
124
|
+
expect(packageJson.dependencies["@sample-app/shared"]).toBe("file:../shared");
|
|
125
|
+
expect(Object.values(packageJson.dependencies)).not.toContain("workspace:*");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("adds swallowkit as a generated project devDependency", () => {
|
|
129
|
+
const devDependencies = buildGeneratedProjectDevDependencies();
|
|
130
|
+
|
|
131
|
+
expect(devDependencies).toEqual({
|
|
132
|
+
swallowkit: expect.stringMatching(/.+/),
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("builds a project-scoped MCP config that resolves the configured swallowkit-mcp version", () => {
|
|
137
|
+
const source = buildSwallowKitMcpProjectConfigSource();
|
|
138
|
+
const parsed = JSON.parse(source) as {
|
|
139
|
+
mcpServers: {
|
|
140
|
+
swallowkit: {
|
|
141
|
+
command: string;
|
|
142
|
+
args: string[];
|
|
143
|
+
cwd?: string;
|
|
144
|
+
env?: Record<string, string>;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
expect(parsed.mcpServers.swallowkit.command).toBe("pnpm");
|
|
150
|
+
expect(parsed.mcpServers.swallowkit.args).toEqual([
|
|
151
|
+
"dlx",
|
|
152
|
+
"--package",
|
|
153
|
+
"swallowkit@${SWALLOWKIT_MCP_VERSION}",
|
|
154
|
+
"swallowkit-mcp",
|
|
155
|
+
]);
|
|
156
|
+
expect(parsed.mcpServers.swallowkit.cwd).toBe(".");
|
|
157
|
+
expect(parsed.mcpServers.swallowkit.env).toEqual({ SWALLOWKIT_MCP_VERSION: "latest" });
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("builds an npm-based MCP config when pnpm is unavailable", () => {
|
|
161
|
+
const source = buildSwallowKitMcpProjectConfigSource("npm");
|
|
162
|
+
const parsed = JSON.parse(source);
|
|
163
|
+
|
|
164
|
+
expect(parsed.mcpServers.swallowkit.command).toBe("npx");
|
|
165
|
+
expect(parsed.mcpServers.swallowkit.args).toEqual([
|
|
166
|
+
"--yes",
|
|
167
|
+
"--package",
|
|
168
|
+
"swallowkit@${SWALLOWKIT_MCP_VERSION}",
|
|
169
|
+
"swallowkit-mcp",
|
|
170
|
+
]);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("temporarily rewrites workspace protocol dependencies for npm lockfile generation", async () => {
|
|
174
|
+
const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), "swallowkit-lockfile-"));
|
|
175
|
+
fs.mkdirSync(path.join(projectDir, "shared"));
|
|
176
|
+
fs.mkdirSync(path.join(projectDir, "functions"));
|
|
177
|
+
fs.mkdirSync(path.join(projectDir, "node_modules"));
|
|
178
|
+
fs.mkdirSync(path.join(projectDir, "shared", "node_modules"));
|
|
179
|
+
fs.writeFileSync(path.join(projectDir, "node_modules", ".pnpm-marker"), "root");
|
|
180
|
+
fs.writeFileSync(path.join(projectDir, "shared", "node_modules", ".pnpm-marker"), "shared");
|
|
181
|
+
|
|
182
|
+
const rootPackageJson = {
|
|
183
|
+
name: "sample-app",
|
|
184
|
+
dependencies: {
|
|
185
|
+
"@sample-app/shared": "workspace:*",
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
const functionsPackageJson = {
|
|
189
|
+
name: "functions",
|
|
190
|
+
dependencies: {
|
|
191
|
+
"@sample-app/shared": "workspace:*",
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
const sharedPackageJson = {
|
|
195
|
+
name: "@sample-app/shared",
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
fs.writeFileSync(path.join(projectDir, "package.json"), JSON.stringify(rootPackageJson, null, 2));
|
|
199
|
+
fs.writeFileSync(path.join(projectDir, "functions", "package.json"), JSON.stringify(functionsPackageJson, null, 2));
|
|
200
|
+
fs.writeFileSync(path.join(projectDir, "shared", "package.json"), JSON.stringify(sharedPackageJson, null, 2));
|
|
201
|
+
|
|
202
|
+
await withNpmLockfileSafeManifests(projectDir, async () => {
|
|
203
|
+
const normalizedRoot = JSON.parse(fs.readFileSync(path.join(projectDir, "package.json"), "utf-8"));
|
|
204
|
+
const normalizedFunctions = JSON.parse(fs.readFileSync(path.join(projectDir, "functions", "package.json"), "utf-8"));
|
|
205
|
+
|
|
206
|
+
expect(normalizedRoot.dependencies["@sample-app/shared"]).toBe("file:shared");
|
|
207
|
+
expect(normalizedFunctions.dependencies["@sample-app/shared"]).toBe("file:../shared");
|
|
208
|
+
expect(fs.existsSync(path.join(projectDir, "node_modules"))).toBe(false);
|
|
209
|
+
expect(fs.existsSync(path.join(projectDir, "shared", "node_modules"))).toBe(false);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
expect(JSON.parse(fs.readFileSync(path.join(projectDir, "package.json"), "utf-8"))).toEqual(rootPackageJson);
|
|
213
|
+
expect(JSON.parse(fs.readFileSync(path.join(projectDir, "functions", "package.json"), "utf-8"))).toEqual(functionsPackageJson);
|
|
214
|
+
expect(fs.readFileSync(path.join(projectDir, "node_modules", ".pnpm-marker"), "utf-8")).toBe("root");
|
|
215
|
+
expect(fs.readFileSync(path.join(projectDir, "shared", "node_modules", ".pnpm-marker"), "utf-8")).toBe("shared");
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
describe("parseIgnoredBuilds", () => {
|
|
220
|
+
it("extracts package names from the pnpm warning line", () => {
|
|
221
|
+
const output = [
|
|
222
|
+
"WARN Issues with peer dependencies found",
|
|
223
|
+
" ERR_PNPM_IGNORED_BUILDS Ignored build scripts: sharp@0.34.5, unrs-resolver@1.12.2",
|
|
224
|
+
"run pnpm approve-builds",
|
|
225
|
+
].join("\n");
|
|
226
|
+
expect(parseIgnoredBuilds(output)).toEqual(["sharp", "unrs-resolver"]);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("handles scoped packages and de-duplicates entries", () => {
|
|
230
|
+
const output = "Ignored build scripts: @scope/pkg@1.0.0, sharp@0.34.5, sharp@0.34.5";
|
|
231
|
+
expect(parseIgnoredBuilds(output)).toEqual(["@scope/pkg", "sharp"]);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it("returns an empty array when no warning is present", () => {
|
|
235
|
+
expect(parseIgnoredBuilds("everything is fine")).toEqual([]);
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
describe("buildCosmosDbFreeTierBicepSource", () => {
|
|
240
|
+
it("keeps database-level shared throughput at 1000 RU/s for Free Tier", () => {
|
|
241
|
+
const source = buildCosmosDbFreeTierBicepSource();
|
|
242
|
+
|
|
243
|
+
expect(source).toContain("throughput: 1000");
|
|
244
|
+
expect(source).not.toContain("containers");
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
describe("Static Web Apps plan", () => {
|
|
249
|
+
it("maps init plan values to Azure SKU names", () => {
|
|
250
|
+
expect(getStaticWebAppSku("free")).toBe("Free");
|
|
251
|
+
expect(getStaticWebAppSku("standard")).toBe("Standard");
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
describe("Functions host key infrastructure", () => {
|
|
256
|
+
it("reads the generated default host key without exposing a literal value", () => {
|
|
257
|
+
const expression = buildFunctionsHostKeyBicepExpression();
|
|
258
|
+
expect(expression).toContain("listKeys(");
|
|
259
|
+
expect(expression).toContain("functionKeys.default");
|
|
260
|
+
expect(expression).toContain("resourceId('Microsoft.Web/sites/host', 'func-${projectName}', 'default')");
|
|
261
|
+
expect(expression).not.toContain("functionsFlex.outputs.id");
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it("passes the key to SWA through a secure module parameter", () => {
|
|
265
|
+
const source = buildStaticWebAppConfigBicepSource();
|
|
266
|
+
expect(source).toContain("@secure()");
|
|
267
|
+
expect(source).toContain("param functionsHostKey string");
|
|
268
|
+
expect(source).toContain("BACKEND_FUNCTIONS_KEY: functionsHostKey");
|
|
269
|
+
expect(source).not.toContain("output functionsHostKey");
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
describe("Infrastructure generation", () => {
|
|
274
|
+
it.each([
|
|
275
|
+
["freetier", "free"],
|
|
276
|
+
["serverless", "standard"],
|
|
277
|
+
] as Array<["freetier" | "serverless", "free" | "standard"]>)(
|
|
278
|
+
"emits VNet module definitions with VNet disabled (%s)",
|
|
279
|
+
async (cosmosDbMode, swaPlan) => {
|
|
280
|
+
const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), "swallowkit-infra-no-vnet-"));
|
|
281
|
+
|
|
282
|
+
await createInfrastructure(
|
|
283
|
+
projectDir,
|
|
284
|
+
"sample-app",
|
|
285
|
+
{ cosmosDbMode, vnetOption: "none", swaPlan },
|
|
286
|
+
"typescript",
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
expect(fs.existsSync(path.join(projectDir, "infra", "modules", "vnet.bicep"))).toBe(true);
|
|
290
|
+
expect(fs.existsSync(path.join(projectDir, "infra", "modules", "private-endpoint-cosmos.bicep"))).toBe(true);
|
|
291
|
+
|
|
292
|
+
const mainBicep = fs.readFileSync(path.join(projectDir, "infra", "main.bicep"), "utf-8");
|
|
293
|
+
expect(mainBicep).toContain("param enableVNet bool = false");
|
|
294
|
+
expect(mainBicep).toContain("module vnet 'modules/vnet.bicep' = if (enableVNet)");
|
|
295
|
+
},
|
|
296
|
+
);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
describe("GitHub Actions workflow generation", () => {
|
|
300
|
+
it("uses npm ci for the SWA workflow when the project was initialized with pnpm", () => {
|
|
301
|
+
const workflow = buildGitHubSwaWorkflow("npm", "pnpm");
|
|
302
|
+
|
|
303
|
+
expect(workflow).toContain("Normalize pnpm workspace for npm CI");
|
|
304
|
+
expect(workflow).toContain("root.workspaces = ['shared', 'functions']");
|
|
305
|
+
expect(workflow).toContain("replaceSharedWorkspaceDep(root, 'file:shared')");
|
|
306
|
+
expect(workflow).toContain("root.scripts.build = \"npm run --workspace=shared build");
|
|
307
|
+
expect(workflow).toContain("npm install --package-lock-only --ignore-scripts");
|
|
308
|
+
expect(workflow).toContain("npm ci && npm run build");
|
|
309
|
+
expect(workflow).not.toContain("npm install && npm run build");
|
|
310
|
+
expect(workflow).not.toContain("pnpm/action-setup");
|
|
311
|
+
expect(workflow).not.toContain("pnpm install --frozen-lockfile");
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
it("uses npm ci for the Functions workflow when the project was initialized with pnpm", () => {
|
|
315
|
+
const workflow = getGitHubFunctionsWorkflow("npm", "typescript", "pnpm");
|
|
316
|
+
|
|
317
|
+
expect(workflow).toContain("Normalize pnpm workspace for npm CI");
|
|
318
|
+
expect(workflow).toContain("replaceSharedWorkspaceDep(functionsPkg, 'file:../shared')");
|
|
319
|
+
expect(workflow).toContain("functionsPkg.scripts.prestart = 'npm run build'");
|
|
320
|
+
expect(workflow).toContain("npm install --package-lock-only --ignore-scripts");
|
|
321
|
+
expect(workflow).toContain("- name: Install dependencies\n run: |\n npm ci");
|
|
322
|
+
expect(workflow).toContain("npm run --workspace=shared build");
|
|
323
|
+
expect(workflow).toContain("npm run --workspace=functions build");
|
|
324
|
+
expect(workflow).not.toContain("pnpm/action-setup");
|
|
325
|
+
expect(workflow).not.toContain("pnpm install --frozen-lockfile");
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it("uses npm ci for the SWA pipeline when the project was initialized with pnpm", () => {
|
|
329
|
+
const pipeline = buildAzureSwaPipeline("npm", "pnpm");
|
|
330
|
+
|
|
331
|
+
expect(pipeline).toContain("Normalize pnpm workspace for npm CI");
|
|
332
|
+
expect(pipeline).toContain("root.workspaces = ['shared', 'functions']");
|
|
333
|
+
expect(pipeline).toContain("replaceSharedWorkspaceDep(root, 'file:shared')");
|
|
334
|
+
expect(pipeline).toContain("root.scripts.build = \"npm run --workspace=shared build");
|
|
335
|
+
expect(pipeline).toContain("npm install --package-lock-only --ignore-scripts");
|
|
336
|
+
expect(pipeline).toContain("npm ci");
|
|
337
|
+
expect(pipeline).not.toContain("- script: |\n npm install\n displayName: 'Install dependencies'");
|
|
338
|
+
expect(pipeline).toContain("npm run build");
|
|
339
|
+
expect(pipeline).not.toContain("corepack enable");
|
|
340
|
+
expect(pipeline).not.toContain("pnpm install --frozen-lockfile");
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it("uses npm ci for the Functions pipeline when the project was initialized with pnpm", () => {
|
|
344
|
+
const pipeline = getAzureFunctionsPipeline("npm", "typescript", "pnpm");
|
|
345
|
+
|
|
346
|
+
expect(pipeline).toContain("Normalize pnpm workspace for npm CI");
|
|
347
|
+
expect(pipeline).toContain("replaceSharedWorkspaceDep(functionsPkg, 'file:../shared')");
|
|
348
|
+
expect(pipeline).toContain("functionsPkg.scripts.prestart = 'npm run build'");
|
|
349
|
+
expect(pipeline).toContain("npm install --package-lock-only --ignore-scripts");
|
|
350
|
+
expect(pipeline).toContain("- script: |\n npm ci\n displayName: 'Install workspace dependencies'");
|
|
351
|
+
expect(pipeline).toContain("npm run --workspace=shared build");
|
|
352
|
+
expect(pipeline).toContain("npm run --workspace=functions build");
|
|
353
|
+
expect(pipeline).not.toContain("corepack enable");
|
|
354
|
+
expect(pipeline).not.toContain("pnpm install --frozen-lockfile");
|
|
355
|
+
});
|
|
356
|
+
});
|
|
@@ -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;
|