@embrace-ai/infra-api-schema-sync 1.0.1 → 1.0.2
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 +7 -0
- package/dist/src/generate-schema-url.d.ts.map +1 -1
- package/dist/src/generate-schema-url.js +23 -6
- package/dist/src/generate-schema-url.js.map +1 -1
- package/package.json +1 -1
- package/src/generate-schema-url.js +22 -8
- package/templates/workflows/emit-schema-update.yml +5 -6
- package/templates/workflows/graphql-schema-validate.yml +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.2](https://github.com/Embrace-AI/infra-api-schema-sync/compare/v1.0.1...v1.0.2) (2025-10-07)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **cli:** use process.stderr for logs, and output logs to file ([#13](https://github.com/Embrace-AI/infra-api-schema-sync/issues/13)) ([84b30d0](https://github.com/Embrace-AI/infra-api-schema-sync/commit/84b30d05cc922912edf34c3c1f3e50f5cbc65644))
|
|
9
|
+
|
|
3
10
|
## [1.0.1](https://github.com/Embrace-AI/infra-api-schema-sync/compare/v1.0.0...v1.0.1) (2025-06-19)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-schema-url.d.ts","sourceRoot":"","sources":["../../src/generate-schema-url.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-schema-url.d.ts","sourceRoot":"","sources":["../../src/generate-schema-url.js"],"names":[],"mappings":"AAYO,yDALJ;IAAwB,KAAK,EAArB,MAAM;IACU,OAAO,EAAvB,MAAM;IACU,IAAI,EAApB,MAAM;CACd,GAAU,MAAM,CAwBlB;AAkGM,qDA2CN"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execSync } from "child_process";
|
|
2
|
-
import
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
3
4
|
export const buildSchemaUrl = ({ stage = "dev", service, repo }) => {
|
|
4
5
|
if (!repo) {
|
|
5
6
|
repo = detectRepositoryName();
|
|
@@ -67,18 +68,34 @@ const extractServiceName = (repo) => {
|
|
|
67
68
|
export const generateSchemaUrl = (opts) => {
|
|
68
69
|
try {
|
|
69
70
|
const { stage, service, repo } = opts;
|
|
70
|
-
console.log("🔧 Generating schema URL...");
|
|
71
71
|
const detectedRepo = repo || detectRepositoryName();
|
|
72
72
|
const detectedService = service || extractServiceName(detectedRepo);
|
|
73
|
-
console.log(`📁 Repository: ${detectedRepo}`);
|
|
74
|
-
console.log(`🏷️ Service: ${detectedService}`);
|
|
75
|
-
console.log(`🚀 Stage: ${stage}`);
|
|
76
73
|
const url = buildSchemaUrl({
|
|
77
74
|
stage,
|
|
78
75
|
service: detectedService,
|
|
79
76
|
repo: detectedRepo,
|
|
80
77
|
});
|
|
81
|
-
|
|
78
|
+
const summaryPath = process.env.GITHUB_STEP_SUMMARY;
|
|
79
|
+
if (summaryPath) {
|
|
80
|
+
const md = [
|
|
81
|
+
"### Schema URL Generation",
|
|
82
|
+
"",
|
|
83
|
+
`- Repository: ${detectedRepo}`,
|
|
84
|
+
`- Service: ${detectedService}`,
|
|
85
|
+
`- Stage: ${stage}`,
|
|
86
|
+
`- URL: ${url}`,
|
|
87
|
+
"",
|
|
88
|
+
].join("\n");
|
|
89
|
+
try {
|
|
90
|
+
fs.appendFileSync(summaryPath, md);
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
console.warn("Failed to write summary:", e.message);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
process.stderr.write("::notice::Generated schema URL\n");
|
|
98
|
+
}
|
|
82
99
|
process.stdout.write(url);
|
|
83
100
|
return url;
|
|
84
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-schema-url.js","sourceRoot":"","sources":["../../src/generate-schema-url.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-schema-url.js","sourceRoot":"","sources":["../../src/generate-schema-url.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAU7B,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;IAEjE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,IAAI,GAAG,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAGD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAGD,IACE,OAAO,KAAK,SAAS;QACrB,IAAI,KAAK,SAAS;QAClB,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EACzB,CAAC;QACD,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAGD,OAAO,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC,CAAC;AAOF,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;IAChC,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,KAAK;YACR,OAAO,8CAA8C,CAAC;QACxD;YACE,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,OAAO,eAAe,KAAK,mCAAmC,CAAC;YACjE,CAAC;YAED,OAAO,8CAA8C,CAAC;IAC1D,CAAC;AACH,CAAC,CAAC;AAQF,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,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oCAAoC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACnE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC;AAGF,eAAe,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execSync } from "child_process";
|
|
2
|
-
import
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Generate a dynamic GraphQL schema URL based on repository and deployment stage
|
|
@@ -133,23 +134,36 @@ export const generateSchemaUrl = (opts) => {
|
|
|
133
134
|
try {
|
|
134
135
|
const { stage, service, repo } = opts;
|
|
135
136
|
|
|
136
|
-
console.log("🔧 Generating schema URL...");
|
|
137
|
-
|
|
138
137
|
// Detect values if not provided
|
|
139
138
|
const detectedRepo = repo || detectRepositoryName();
|
|
140
139
|
const detectedService = service || extractServiceName(detectedRepo);
|
|
141
140
|
|
|
142
|
-
console.log(`📁 Repository: ${detectedRepo}`);
|
|
143
|
-
console.log(`🏷️ Service: ${detectedService}`);
|
|
144
|
-
console.log(`🚀 Stage: ${stage}`);
|
|
145
|
-
|
|
146
141
|
const url = buildSchemaUrl({
|
|
147
142
|
stage,
|
|
148
143
|
service: detectedService,
|
|
149
144
|
repo: detectedRepo,
|
|
150
145
|
});
|
|
151
146
|
|
|
152
|
-
|
|
147
|
+
const summaryPath = process.env.GITHUB_STEP_SUMMARY;
|
|
148
|
+
if (summaryPath) {
|
|
149
|
+
const md = [
|
|
150
|
+
"### Schema URL Generation",
|
|
151
|
+
"",
|
|
152
|
+
`- Repository: ${detectedRepo}`,
|
|
153
|
+
`- Service: ${detectedService}`,
|
|
154
|
+
`- Stage: ${stage}`,
|
|
155
|
+
`- URL: ${url}`,
|
|
156
|
+
"",
|
|
157
|
+
].join("\n");
|
|
158
|
+
try {
|
|
159
|
+
fs.appendFileSync(summaryPath, md);
|
|
160
|
+
} catch (e) {
|
|
161
|
+
console.warn("Failed to write summary:", e.message);
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
// Optional: Create a GitHub Actions notice without using console.*
|
|
165
|
+
process.stderr.write("::notice::Generated schema URL\n");
|
|
166
|
+
}
|
|
153
167
|
|
|
154
168
|
// Output just the URL for easy consumption by scripts
|
|
155
169
|
process.stdout.write(url);
|
|
@@ -6,7 +6,7 @@ on:
|
|
|
6
6
|
branches:
|
|
7
7
|
- main
|
|
8
8
|
paths:
|
|
9
|
-
-
|
|
9
|
+
- "**/*schema.ts"
|
|
10
10
|
workflow_dispatch: {}
|
|
11
11
|
|
|
12
12
|
env:
|
|
@@ -16,12 +16,12 @@ env:
|
|
|
16
16
|
# SCHEMA_URL: "https://api.dev.embrace.ai/v2/graphql/schema"
|
|
17
17
|
|
|
18
18
|
# Deployment stage - determines the environment URL pattern
|
|
19
|
-
DEPLOYMENT_STAGE: "dev"
|
|
19
|
+
DEPLOYMENT_STAGE: "dev" # Options: dev, prod, pr-* (e.g., pr-123)
|
|
20
20
|
# Optional: Override service name (auto-detected from repository name if not set)
|
|
21
21
|
# SERVICE_NAME: "your-service-name"
|
|
22
22
|
|
|
23
23
|
# Optional: Filter repositories by name pattern (regex)
|
|
24
|
-
REPO_FILTER: ".*"
|
|
24
|
+
REPO_FILTER: ".*" # Default: all repos. Example: "^(frontend|mobile|web)-.*" for specific patterns
|
|
25
25
|
permissions:
|
|
26
26
|
id-token: write
|
|
27
27
|
contents: read
|
|
@@ -41,7 +41,7 @@ jobs:
|
|
|
41
41
|
uses: actions/setup-node@v4
|
|
42
42
|
with:
|
|
43
43
|
node-version: 22.16.0
|
|
44
|
-
cache:
|
|
44
|
+
cache: "pnpm"
|
|
45
45
|
- name: Setup NPM
|
|
46
46
|
env:
|
|
47
47
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -49,7 +49,7 @@ jobs:
|
|
|
49
49
|
|
|
50
50
|
- name: Install GraphQL schema sync tool
|
|
51
51
|
# Update below to use the version you want
|
|
52
|
-
run: pnpm install -w @embrace-ai/infra-api-schema-sync@
|
|
52
|
+
run: pnpm install -w @embrace-ai/infra-api-schema-sync@latest
|
|
53
53
|
|
|
54
54
|
# Generate dynamic schema URL based on repository and stage
|
|
55
55
|
- name: Generate schema URL
|
|
@@ -67,7 +67,6 @@ jobs:
|
|
|
67
67
|
echo "url=$SCHEMA_URL" >> $GITHUB_OUTPUT
|
|
68
68
|
echo "🌐 Generated schema URL: $SCHEMA_URL"
|
|
69
69
|
|
|
70
|
-
|
|
71
70
|
# Fetch all organization repositories and dispatch to each
|
|
72
71
|
- name: Dispatch schema update events to all org repositories
|
|
73
72
|
env:
|
|
@@ -20,7 +20,7 @@ jobs:
|
|
|
20
20
|
uses: actions/setup-node@v4
|
|
21
21
|
with:
|
|
22
22
|
node-version: 22.16.0
|
|
23
|
-
cache:
|
|
23
|
+
cache: "pnpm"
|
|
24
24
|
|
|
25
25
|
- name: Setup NPM
|
|
26
26
|
env:
|
|
@@ -29,7 +29,7 @@ jobs:
|
|
|
29
29
|
|
|
30
30
|
- name: Install GraphQL schema sync tool
|
|
31
31
|
# Update line below to use the version you want
|
|
32
|
-
run: pnpm install -w @embrace-ai/infra-api-schema-sync@
|
|
32
|
+
run: pnpm install -w @embrace-ai/infra-api-schema-sync@latest
|
|
33
33
|
|
|
34
34
|
- name: Configure aws credentials
|
|
35
35
|
uses: aws-actions/configure-aws-credentials@v4.2.1
|
|
@@ -55,9 +55,9 @@ jobs:
|
|
|
55
55
|
- name: Check for issues
|
|
56
56
|
id: check-issues
|
|
57
57
|
run: |
|
|
58
|
-
if [ -s report.json ] && [ "$(jq '
|
|
58
|
+
if [ -s report.json ] && [ "$(jq 'length' report.json)" -gt 0 ]; then
|
|
59
59
|
echo "has_issues=true" >> $GITHUB_OUTPUT
|
|
60
|
-
echo "issue_count=$(jq '
|
|
60
|
+
echo "issue_count=$(jq 'length' report.json)" >> $GITHUB_OUTPUT
|
|
61
61
|
else
|
|
62
62
|
echo "has_issues=false" >> $GITHUB_OUTPUT
|
|
63
63
|
echo "issue_count=0" >> $GITHUB_OUTPUT
|