@auto-engineer/generate-react-client 1.84.0 → 1.85.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,23 @@
1
1
  # @auto-engineer/generate-react-client
2
2
 
3
+ ## 1.85.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`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
8
+ - **server-generator-apollo-emmett**: fix singleton projection instruction steps 1 and 4
9
+ - **global**: version packages
10
+ - **server-generator-apollo-emmett**: add snapshot test for co-firing rule merge
11
+ - **server-implementer**: add Bursts 4-5 to ketchup plan
12
+
13
+ - [`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
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [[`eef47a0`](https://github.com/BeOnAuto/auto-engineer/commit/eef47a0424e6528ea832a907dacc8bc398b34dfe), [`f90636d`](https://github.com/BeOnAuto/auto-engineer/commit/f90636d198db18032ce9b9e8f165d158ad9d0176)]:
18
+ - @auto-engineer/file-upload@1.85.0
19
+ - @auto-engineer/message-bus@1.85.0
20
+
3
21
  ## 1.84.0
4
22
 
5
23
  ### 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,50 @@
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
+ });
@@ -0,0 +1,26 @@
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 },
12
+ deps: UploadArtifactDeps,
13
+ ): Promise<string | null> {
14
+ const { ORG_ID: orgId, PROJECT_ID: projectId, ARTIFACT_PATH: artifactPath } = env;
15
+ if (!artifactPath || !orgId || !projectId) return null;
16
+
17
+ await uploadFile('components-db.json', new TextEncoder().encode(json), {
18
+ uploadUrl: artifactPath,
19
+ prefix: `${orgId}/${projectId}/auto`,
20
+ fetch: deps.fetch,
21
+ writeFile: deps.writeFile,
22
+ mkdir: deps.mkdir,
23
+ });
24
+
25
+ return `${artifactPath}/${orgId}/${projectId}/auto/components-db.json`;
26
+ }
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.84.0",
23
- "@auto-engineer/message-bus": "1.84.0"
22
+ "@auto-engineer/file-upload": "1.85.0",
23
+ "@auto-engineer/message-bus": "1.85.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/debug": "^4.1.12"
27
27
  },
28
- "version": "1.84.0",
28
+ "version": "1.85.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",