@alloy-js/go 0.3.1-dev.0 → 0.3.1-dev.1
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/dist/dev/src/components/doc/comment.test.js +39 -40
- package/dist/dev/src/components/doc/comment.test.js.map +1 -1
- package/dist/dev/src/components/interface/interface.test.js +27 -28
- package/dist/dev/src/components/interface/interface.test.js.map +1 -1
- package/dist/dev/src/components/struct/struct.test.js +49 -51
- package/dist/dev/src/components/struct/struct.test.js.map +1 -1
- package/dist/dev/src/components/var/var-declaration.test.js +72 -67
- package/dist/dev/src/components/var/var-declaration.test.js.map +1 -1
- package/dist/dev/test/utils.js +5 -55
- package/dist/dev/test/utils.js.map +1 -1
- package/dist/src/components/doc/comment.test.d.ts +1 -1
- package/dist/src/components/doc/comment.test.d.ts.map +1 -1
- package/dist/src/components/doc/comment.test.js +0 -1
- package/dist/src/components/doc/comment.test.js.map +1 -1
- package/dist/src/components/interface/interface.test.js +4 -5
- package/dist/src/components/interface/interface.test.js.map +1 -1
- package/dist/src/components/struct/struct.test.js +6 -8
- package/dist/src/components/struct/struct.test.js.map +1 -1
- package/dist/src/components/var/var-declaration.test.d.ts +1 -1
- package/dist/src/components/var/var-declaration.test.d.ts.map +1 -1
- package/dist/src/components/var/var-declaration.test.js +16 -11
- package/dist/src/components/var/var-declaration.test.js.map +1 -1
- package/dist/test/utils.d.ts +1 -4
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +1 -43
- package/dist/test/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/components/doc/comment.test.tsx +0 -1
- package/src/components/interface/interface.test.tsx +4 -6
- package/src/components/struct/struct.test.tsx +6 -10
- package/src/components/var/var-declaration.test.tsx +15 -13
- package/test/utils.tsx +1 -64
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alloy-js/go",
|
|
3
|
-
"version": "0.3.1-dev.
|
|
3
|
+
"version": "0.3.1-dev.1",
|
|
4
4
|
"description": "Go bindings for Alloy",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"author": "",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@alloy-js/core": "~0.23.
|
|
30
|
+
"@alloy-js/core": "~0.23.1 || >= 0.24.0-dev.7",
|
|
31
31
|
"change-case": "^5.4.4",
|
|
32
32
|
"pathe": "^2.0.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@alloy-js/cli": "~0.23.0 || >= 0.24.0-dev.
|
|
36
|
-
"@alloy-js/rollup-plugin": "~0.1.1 || >= 0.1.2-dev.
|
|
35
|
+
"@alloy-js/cli": "~0.23.0 || >= 0.24.0-dev.1",
|
|
36
|
+
"@alloy-js/rollup-plugin": "~0.1.1 || >= 0.1.2-dev.2",
|
|
37
37
|
"@microsoft/api-extractor": "~7.52.8",
|
|
38
38
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
39
39
|
"concurrently": "^9.2.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { List, Output, refkey
|
|
1
|
+
import { List, Output, refkey } from "@alloy-js/core";
|
|
2
2
|
import { describe, expect, it } from "vitest";
|
|
3
|
-
import {
|
|
3
|
+
import { TestPackage } from "../../../test/utils.js";
|
|
4
4
|
import { ModuleDirectory } from "../ModuleDirectory.jsx";
|
|
5
5
|
import { SourceDirectory } from "../SourceDirectory.jsx";
|
|
6
6
|
import { SourceFile } from "../SourceFile.jsx";
|
|
@@ -260,7 +260,7 @@ describe("embedded", () => {
|
|
|
260
260
|
const TestInterface = refkey("TestInterface");
|
|
261
261
|
const TestInterfaceEmbed = refkey("TestInterfaceEmbed");
|
|
262
262
|
|
|
263
|
-
|
|
263
|
+
expect(
|
|
264
264
|
<Output>
|
|
265
265
|
<ModuleDirectory name="github.com/alloy-framework/alloy">
|
|
266
266
|
<SourceDirectory path=".">
|
|
@@ -292,9 +292,7 @@ describe("embedded", () => {
|
|
|
292
292
|
</SourceDirectory>
|
|
293
293
|
</ModuleDirectory>
|
|
294
294
|
</Output>,
|
|
295
|
-
)
|
|
296
|
-
|
|
297
|
-
assertFileContents(res, {
|
|
295
|
+
).toRenderTo({
|
|
298
296
|
"hello/types.go": `
|
|
299
297
|
package hello
|
|
300
298
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { List, Output, refkey
|
|
1
|
+
import { List, Output, refkey } from "@alloy-js/core";
|
|
2
2
|
import { describe, expect, it } from "vitest";
|
|
3
|
-
import {
|
|
3
|
+
import { TestPackage } from "../../../test/utils.js";
|
|
4
4
|
import { ModuleDirectory } from "../ModuleDirectory.js";
|
|
5
5
|
import { SourceDirectory } from "../SourceDirectory.js";
|
|
6
6
|
import { SourceFile } from "../SourceFile.js";
|
|
@@ -320,7 +320,7 @@ describe("embedded", () => {
|
|
|
320
320
|
const TestStruct = refkey("TestStruct");
|
|
321
321
|
const TestStructEmbed = refkey("TestStructEmbed");
|
|
322
322
|
|
|
323
|
-
|
|
323
|
+
expect(
|
|
324
324
|
<Output>
|
|
325
325
|
<ModuleDirectory name="github.com/alloy-framework/alloy">
|
|
326
326
|
<SourceDirectory path=".">
|
|
@@ -352,9 +352,7 @@ describe("embedded", () => {
|
|
|
352
352
|
</SourceDirectory>
|
|
353
353
|
</ModuleDirectory>
|
|
354
354
|
</Output>,
|
|
355
|
-
)
|
|
356
|
-
|
|
357
|
-
assertFileContents(res, {
|
|
355
|
+
).toRenderTo({
|
|
358
356
|
"hello/types.go": `
|
|
359
357
|
package hello
|
|
360
358
|
|
|
@@ -380,7 +378,7 @@ describe("embedded", () => {
|
|
|
380
378
|
const TestStruct = refkey("TestStruct");
|
|
381
379
|
const TestStructEmbed = refkey("TestStructEmbed");
|
|
382
380
|
|
|
383
|
-
|
|
381
|
+
expect(
|
|
384
382
|
<Output>
|
|
385
383
|
<ModuleDirectory name="github.com/alloy-framework/alloy">
|
|
386
384
|
<SourceDirectory path=".">
|
|
@@ -412,9 +410,7 @@ describe("embedded", () => {
|
|
|
412
410
|
</SourceDirectory>
|
|
413
411
|
</ModuleDirectory>
|
|
414
412
|
</Output>,
|
|
415
|
-
)
|
|
416
|
-
|
|
417
|
-
assertFileContents(res, {
|
|
413
|
+
).toRenderTo({
|
|
418
414
|
"hello/types.go": `
|
|
419
415
|
package hello
|
|
420
416
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Output, refkey, render } from "@alloy-js/core";
|
|
2
|
-
import "@alloy-js/core/testing";
|
|
3
2
|
import { expect, it } from "vitest";
|
|
4
|
-
import { assertFileContents } from "../../../test/utils.js";
|
|
5
3
|
import * as go from "../index.js";
|
|
6
4
|
|
|
7
5
|
it("works variable", () => {
|
|
@@ -82,7 +80,7 @@ it("works const group", () => {
|
|
|
82
80
|
it("works end-to-end", () => {
|
|
83
81
|
const TestType = refkey("TestType");
|
|
84
82
|
|
|
85
|
-
|
|
83
|
+
expect(
|
|
86
84
|
<Output>
|
|
87
85
|
<go.ModuleDirectory name="github.com/alloy-framework/alloy">
|
|
88
86
|
<go.SourceDirectory path=".">
|
|
@@ -99,9 +97,7 @@ it("works end-to-end", () => {
|
|
|
99
97
|
</go.SourceDirectory>
|
|
100
98
|
</go.ModuleDirectory>
|
|
101
99
|
</Output>,
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
assertFileContents(res, {
|
|
100
|
+
).toRenderTo({
|
|
105
101
|
"types.go": `
|
|
106
102
|
package alloy
|
|
107
103
|
|
|
@@ -147,7 +143,7 @@ it("throws end-to-end cross-package with unexported type", () => {
|
|
|
147
143
|
it("works end-to-end cross-package", () => {
|
|
148
144
|
const TestType = refkey("TestType");
|
|
149
145
|
|
|
150
|
-
|
|
146
|
+
expect(
|
|
151
147
|
<Output>
|
|
152
148
|
<go.ModuleDirectory name="github.com/alloy-framework/alloy">
|
|
153
149
|
<go.SourceDirectory path="hello">
|
|
@@ -166,9 +162,7 @@ it("works end-to-end cross-package", () => {
|
|
|
166
162
|
</go.SourceDirectory>
|
|
167
163
|
</go.ModuleDirectory>
|
|
168
164
|
</Output>,
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
assertFileContents(res, {
|
|
165
|
+
).toRenderTo({
|
|
172
166
|
"hello/types.go": `
|
|
173
167
|
package hello
|
|
174
168
|
|
|
@@ -188,7 +182,7 @@ it("works with conflict resolution", () => {
|
|
|
188
182
|
const TestType1 = refkey("TestType1");
|
|
189
183
|
const TestType2 = refkey("TestType2");
|
|
190
184
|
|
|
191
|
-
|
|
185
|
+
expect(
|
|
192
186
|
<Output>
|
|
193
187
|
<go.ModuleDirectory name="github.com/alloy-framework/alloy">
|
|
194
188
|
<go.SourceDirectory path="hello" name="hello">
|
|
@@ -218,9 +212,17 @@ it("works with conflict resolution", () => {
|
|
|
218
212
|
</go.SourceDirectory>
|
|
219
213
|
</go.ModuleDirectory>
|
|
220
214
|
</Output>,
|
|
221
|
-
)
|
|
215
|
+
).toRenderTo({
|
|
216
|
+
"hello/types.go": `
|
|
217
|
+
package hello
|
|
218
|
+
|
|
219
|
+
type TestType string
|
|
220
|
+
`,
|
|
221
|
+
"hello2/types.go": `
|
|
222
|
+
package hello
|
|
222
223
|
|
|
223
|
-
|
|
224
|
+
type TestType string
|
|
225
|
+
`,
|
|
224
226
|
"world/test.go": `
|
|
225
227
|
package world
|
|
226
228
|
|
package/test/utils.tsx
CHANGED
|
@@ -1,69 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Children,
|
|
3
|
-
ContentOutputFile,
|
|
4
|
-
Output,
|
|
5
|
-
OutputDirectory,
|
|
6
|
-
OutputFile,
|
|
7
|
-
PrintTreeOptions,
|
|
8
|
-
render,
|
|
9
|
-
} from "@alloy-js/core";
|
|
10
|
-
import { dedent } from "@alloy-js/core/testing";
|
|
11
|
-
import { expect } from "vitest";
|
|
1
|
+
import { Children, Output } from "@alloy-js/core";
|
|
12
2
|
import * as go from "../src/index.js";
|
|
13
3
|
|
|
14
|
-
export function toSourceText(c: Children, options?: PrintTreeOptions): string {
|
|
15
|
-
const res = render(
|
|
16
|
-
<Output>
|
|
17
|
-
<go.SourceFile path="test.go">{c}</go.SourceFile>
|
|
18
|
-
</Output>,
|
|
19
|
-
options,
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
return findFile(res, "test.go").contents;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function findFile(
|
|
26
|
-
res: OutputDirectory,
|
|
27
|
-
path: string,
|
|
28
|
-
): ContentOutputFile {
|
|
29
|
-
const result = findFileWorker(res, path);
|
|
30
|
-
|
|
31
|
-
if (!result) {
|
|
32
|
-
throw new Error("Expected to find file " + path);
|
|
33
|
-
}
|
|
34
|
-
return result as ContentOutputFile;
|
|
35
|
-
|
|
36
|
-
function findFileWorker(
|
|
37
|
-
res: OutputDirectory,
|
|
38
|
-
path: string,
|
|
39
|
-
): OutputFile | null {
|
|
40
|
-
for (const item of res.contents) {
|
|
41
|
-
if (item.kind === "file") {
|
|
42
|
-
if (item.path === path) {
|
|
43
|
-
return item;
|
|
44
|
-
}
|
|
45
|
-
continue;
|
|
46
|
-
} else {
|
|
47
|
-
const found = findFileWorker(item, path);
|
|
48
|
-
if (found) {
|
|
49
|
-
return found;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function assertFileContents(
|
|
58
|
-
res: OutputDirectory,
|
|
59
|
-
expectedFiles: Record<string, string>,
|
|
60
|
-
) {
|
|
61
|
-
for (const [path, contents] of Object.entries(expectedFiles)) {
|
|
62
|
-
const file = findFile(res, path);
|
|
63
|
-
expect(file.contents.trim()).toBe(dedent(contents).trim());
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
4
|
export function TestPackage(props: { children: Children }): Children {
|
|
68
5
|
return (
|
|
69
6
|
<Output>
|