@auto-engineer/generate-react-client 1.84.0 → 1.86.0
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @auto-engineer/generate-react-client
|
|
2
2
|
|
|
3
|
+
## 1.86.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`d052585`](https://github.com/BeOnAuto/auto-engineer/commit/d052585817dac3e1d6cbe8e7ee78cc25aba4585e) Thanks [@SamHatoum](https://github.com/SamHatoum)! - - **generate-react-client**: add signer mode to uploadToArtifactPath
|
|
8
|
+
|
|
9
|
+
- [`4225014`](https://github.com/BeOnAuto/auto-engineer/commit/42250148e63ff945662f71a94f4f4a8eabad33cc) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **generate-react-client**: build-component-db uploads to artifact path via env vars
|
|
10
|
+
- **global**: version packages
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`d052585`](https://github.com/BeOnAuto/auto-engineer/commit/d052585817dac3e1d6cbe8e7ee78cc25aba4585e), [`4225014`](https://github.com/BeOnAuto/auto-engineer/commit/42250148e63ff945662f71a94f4f4a8eabad33cc)]:
|
|
15
|
+
- @auto-engineer/file-upload@1.86.0
|
|
16
|
+
- @auto-engineer/message-bus@1.86.0
|
|
17
|
+
|
|
18
|
+
## 1.85.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- [`eef47a0`](https://github.com/BeOnAuto/auto-engineer/commit/eef47a0424e6528ea832a907dacc8bc398b34dfe) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **server-generator-apollo-emmett**: merge co-firing GWT conditions in gwt.ts
|
|
23
|
+
- **server-generator-apollo-emmett**: fix singleton projection instruction steps 1 and 4
|
|
24
|
+
- **global**: version packages
|
|
25
|
+
- **server-generator-apollo-emmett**: add snapshot test for co-firing rule merge
|
|
26
|
+
- **server-implementer**: add Bursts 4-5 to ketchup plan
|
|
27
|
+
|
|
28
|
+
- [`f90636d`](https://github.com/BeOnAuto/auto-engineer/commit/f90636d198db18032ce9b9e8f165d158ad9d0176) Thanks [@SamHatoum](https://github.com/SamHatoum)! - - **generate-react-client**: build-component-db uploads to artifact path via env vars
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [[`eef47a0`](https://github.com/BeOnAuto/auto-engineer/commit/eef47a0424e6528ea832a907dacc8bc398b34dfe), [`f90636d`](https://github.com/BeOnAuto/auto-engineer/commit/f90636d198db18032ce9b9e8f165d158ad9d0176)]:
|
|
33
|
+
- @auto-engineer/file-upload@1.85.0
|
|
34
|
+
- @auto-engineer/message-bus@1.85.0
|
|
35
|
+
|
|
3
36
|
## 1.84.0
|
|
4
37
|
|
|
5
38
|
### Minor Changes
|
|
@@ -4,6 +4,7 @@ import { dirname, resolve } from 'node:path';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { parseArgs } from 'node:util';
|
|
6
6
|
import { uploadFile } from '@auto-engineer/file-upload';
|
|
7
|
+
import { uploadToArtifactPath } from './upload-artifact';
|
|
7
8
|
|
|
8
9
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
10
|
const OUTPUT_DIR = resolve(__dirname, '../../.context');
|
|
@@ -170,3 +171,16 @@ await uploadFile('.context/components-db.json', new TextEncoder().encode(json),
|
|
|
170
171
|
await mkdir(path, { recursive: true });
|
|
171
172
|
},
|
|
172
173
|
});
|
|
174
|
+
|
|
175
|
+
const artifactUrl = await uploadToArtifactPath(json, process.env, {
|
|
176
|
+
fetch,
|
|
177
|
+
writeFile: async (path, data) => {
|
|
178
|
+
await writeFile(path, data);
|
|
179
|
+
},
|
|
180
|
+
mkdir: async (path) => {
|
|
181
|
+
await mkdir(path, { recursive: true });
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
if (artifactUrl) {
|
|
185
|
+
console.log(`[build-component-db] Uploaded to ${artifactUrl}`);
|
|
186
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
|
|
3
|
+
vi.mock('@auto-engineer/file-upload', () => ({
|
|
4
|
+
uploadFile: vi.fn(),
|
|
5
|
+
}));
|
|
6
|
+
|
|
7
|
+
import { uploadFile } from '@auto-engineer/file-upload';
|
|
8
|
+
import { uploadToArtifactPath } from './upload-artifact';
|
|
9
|
+
|
|
10
|
+
const mockUploadFile = vi.mocked(uploadFile);
|
|
11
|
+
|
|
12
|
+
describe('uploadToArtifactPath', () => {
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
mockUploadFile.mockReset();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const fakeDeps = {
|
|
18
|
+
fetch: vi.fn<typeof globalThis.fetch>(),
|
|
19
|
+
writeFile: vi.fn().mockResolvedValue(undefined),
|
|
20
|
+
mkdir: vi.fn().mockResolvedValue(undefined),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
it('uploads to {artifactPath}/{orgId}/{projectId}/auto/components-db.json', async () => {
|
|
24
|
+
mockUploadFile.mockResolvedValue(undefined);
|
|
25
|
+
|
|
26
|
+
const result = await uploadToArtifactPath('[]', { ORG_ID: 'org-1', PROJECT_ID: 'proj-1', ARTIFACT_PATH: 'file:///tmp/artifacts' }, fakeDeps);
|
|
27
|
+
|
|
28
|
+
expect(result).toEqual('file:///tmp/artifacts/org-1/proj-1/auto/components-db.json');
|
|
29
|
+
expect(mockUploadFile).toHaveBeenCalledWith('components-db.json', new TextEncoder().encode('[]'), {
|
|
30
|
+
uploadUrl: 'file:///tmp/artifacts',
|
|
31
|
+
prefix: 'org-1/proj-1/auto',
|
|
32
|
+
fetch: fakeDeps.fetch,
|
|
33
|
+
writeFile: fakeDeps.writeFile,
|
|
34
|
+
mkdir: fakeDeps.mkdir,
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('returns null when env vars are not set', async () => {
|
|
39
|
+
const result = await uploadToArtifactPath('[]', {}, fakeDeps);
|
|
40
|
+
|
|
41
|
+
expect(result).toEqual(null);
|
|
42
|
+
expect(mockUploadFile).not.toHaveBeenCalled();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('returns null when only some env vars are set', async () => {
|
|
46
|
+
const result = await uploadToArtifactPath('[]', { ORG_ID: 'org-1' }, fakeDeps);
|
|
47
|
+
|
|
48
|
+
expect(result).toEqual(null);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('uses signer mode when CONDUCTOR_URL and SERVICE_TOKEN are set', async () => {
|
|
52
|
+
mockUploadFile.mockResolvedValue(undefined);
|
|
53
|
+
|
|
54
|
+
const result = await uploadToArtifactPath(
|
|
55
|
+
'[]',
|
|
56
|
+
{ ORG_ID: 'org-1', PROJECT_ID: 'proj-1', CONDUCTOR_URL: 'https://conductor.example.com', SERVICE_TOKEN: 'tok-123' },
|
|
57
|
+
fakeDeps,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
expect(result).toEqual('org-1/proj-1/auto/components-db.json');
|
|
61
|
+
expect(mockUploadFile).toHaveBeenCalledWith('components-db.json', new TextEncoder().encode('[]'), {
|
|
62
|
+
signerUrl: 'https://conductor.example.com/projects/proj-1/artifact-upload-urls',
|
|
63
|
+
signerToken: 'tok-123',
|
|
64
|
+
prefix: 'org-1/proj-1/auto',
|
|
65
|
+
fetch: fakeDeps.fetch,
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('signer mode takes precedence over file:// mode when both are set', async () => {
|
|
70
|
+
mockUploadFile.mockResolvedValue(undefined);
|
|
71
|
+
|
|
72
|
+
const result = await uploadToArtifactPath(
|
|
73
|
+
'[]',
|
|
74
|
+
{
|
|
75
|
+
ORG_ID: 'org-1',
|
|
76
|
+
PROJECT_ID: 'proj-1',
|
|
77
|
+
ARTIFACT_PATH: 'file:///tmp/artifacts',
|
|
78
|
+
CONDUCTOR_URL: 'https://conductor.example.com',
|
|
79
|
+
SERVICE_TOKEN: 'tok-123',
|
|
80
|
+
},
|
|
81
|
+
fakeDeps,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(result).toEqual('org-1/proj-1/auto/components-db.json');
|
|
85
|
+
expect(mockUploadFile).toHaveBeenCalledWith('components-db.json', new TextEncoder().encode('[]'), {
|
|
86
|
+
signerUrl: 'https://conductor.example.com/projects/proj-1/artifact-upload-urls',
|
|
87
|
+
signerToken: 'tok-123',
|
|
88
|
+
prefix: 'org-1/proj-1/auto',
|
|
89
|
+
fetch: fakeDeps.fetch,
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('returns null when orgId or projectId is missing even with CONDUCTOR_URL', async () => {
|
|
94
|
+
const result = await uploadToArtifactPath(
|
|
95
|
+
'[]',
|
|
96
|
+
{ CONDUCTOR_URL: 'https://conductor.example.com', SERVICE_TOKEN: 'tok-123' },
|
|
97
|
+
fakeDeps,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
expect(result).toEqual(null);
|
|
101
|
+
expect(mockUploadFile).not.toHaveBeenCalled();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { uploadFile } from '@auto-engineer/file-upload';
|
|
2
|
+
|
|
3
|
+
interface UploadArtifactDeps {
|
|
4
|
+
fetch: typeof globalThis.fetch;
|
|
5
|
+
writeFile: (path: string, data: Uint8Array) => Promise<void>;
|
|
6
|
+
mkdir: (path: string) => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function uploadToArtifactPath(
|
|
10
|
+
json: string,
|
|
11
|
+
env: { ORG_ID?: string; PROJECT_ID?: string; ARTIFACT_PATH?: string; CONDUCTOR_URL?: string; SERVICE_TOKEN?: string },
|
|
12
|
+
deps: UploadArtifactDeps,
|
|
13
|
+
): Promise<string | null> {
|
|
14
|
+
const { ORG_ID: orgId, PROJECT_ID: projectId } = env;
|
|
15
|
+
if (!orgId || !projectId) return null;
|
|
16
|
+
|
|
17
|
+
if (env.CONDUCTOR_URL && env.SERVICE_TOKEN) {
|
|
18
|
+
const signerUrl = `${env.CONDUCTOR_URL}/projects/${projectId}/artifact-upload-urls`;
|
|
19
|
+
await uploadFile('components-db.json', new TextEncoder().encode(json), {
|
|
20
|
+
signerUrl,
|
|
21
|
+
signerToken: env.SERVICE_TOKEN,
|
|
22
|
+
prefix: `${orgId}/${projectId}/auto`,
|
|
23
|
+
fetch: deps.fetch,
|
|
24
|
+
});
|
|
25
|
+
return `${orgId}/${projectId}/auto/components-db.json`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const { ARTIFACT_PATH: artifactPath } = env;
|
|
29
|
+
if (!artifactPath) return null;
|
|
30
|
+
await uploadFile('components-db.json', new TextEncoder().encode(json), {
|
|
31
|
+
uploadUrl: artifactPath,
|
|
32
|
+
prefix: `${orgId}/${projectId}/auto`,
|
|
33
|
+
fetch: deps.fetch,
|
|
34
|
+
writeFile: deps.writeFile,
|
|
35
|
+
mkdir: deps.mkdir,
|
|
36
|
+
});
|
|
37
|
+
return `${artifactPath}/${orgId}/${projectId}/auto/components-db.json`;
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"debug": "^4.4.1",
|
|
22
|
-
"@auto-engineer/file-upload": "1.
|
|
23
|
-
"@auto-engineer/message-bus": "1.
|
|
22
|
+
"@auto-engineer/file-upload": "1.86.0",
|
|
23
|
+
"@auto-engineer/message-bus": "1.86.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/debug": "^4.1.12"
|
|
27
27
|
},
|
|
28
|
-
"version": "1.
|
|
28
|
+
"version": "1.86.0",
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsc && tsx ../../scripts/fix-esm-imports.ts && cp -r starter dist/",
|
|
31
31
|
"test-cli": "tsx test-cli.ts",
|