@peterhauge/apiops-cli 0.1.7-alpha.0 → 0.2.0-alpha.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.
Files changed (207) hide show
  1. package/LICENSE.md +22 -22
  2. package/README.md +169 -169
  3. package/dist/cli/extract-command.d.ts +0 -0
  4. package/dist/cli/extract-command.d.ts.map +0 -0
  5. package/dist/cli/extract-command.js +0 -0
  6. package/dist/cli/extract-command.js.map +0 -0
  7. package/dist/cli/index.d.ts +0 -0
  8. package/dist/cli/index.d.ts.map +0 -0
  9. package/dist/cli/index.js +0 -0
  10. package/dist/cli/index.js.map +0 -0
  11. package/dist/cli/init-command.d.ts +0 -0
  12. package/dist/cli/init-command.d.ts.map +1 -1
  13. package/dist/cli/init-command.js +2 -1
  14. package/dist/cli/init-command.js.map +1 -1
  15. package/dist/cli/publish-command.d.ts +0 -0
  16. package/dist/cli/publish-command.d.ts.map +0 -0
  17. package/dist/cli/publish-command.js +0 -0
  18. package/dist/cli/publish-command.js.map +0 -0
  19. package/dist/clients/apim-client.d.ts +25 -1
  20. package/dist/clients/apim-client.d.ts.map +1 -1
  21. package/dist/clients/apim-client.js +173 -9
  22. package/dist/clients/apim-client.js.map +1 -1
  23. package/dist/clients/artifact-store.d.ts +0 -0
  24. package/dist/clients/artifact-store.d.ts.map +0 -0
  25. package/dist/clients/artifact-store.js +0 -0
  26. package/dist/clients/artifact-store.js.map +0 -0
  27. package/dist/clients/iapim-client.d.ts +6 -0
  28. package/dist/clients/iapim-client.d.ts.map +1 -1
  29. package/dist/clients/iapim-client.js +0 -0
  30. package/dist/clients/iapim-client.js.map +0 -0
  31. package/dist/clients/iartifact-store.d.ts +0 -0
  32. package/dist/clients/iartifact-store.d.ts.map +0 -0
  33. package/dist/clients/iartifact-store.js +0 -0
  34. package/dist/clients/iartifact-store.js.map +0 -0
  35. package/dist/lib/auto-generated.d.ts +0 -0
  36. package/dist/lib/auto-generated.d.ts.map +0 -0
  37. package/dist/lib/auto-generated.js +0 -0
  38. package/dist/lib/auto-generated.js.map +0 -0
  39. package/dist/lib/cloud-config.d.ts +0 -0
  40. package/dist/lib/cloud-config.d.ts.map +0 -0
  41. package/dist/lib/cloud-config.js +0 -0
  42. package/dist/lib/cloud-config.js.map +0 -0
  43. package/dist/lib/config-loader.d.ts +0 -4
  44. package/dist/lib/config-loader.d.ts.map +1 -1
  45. package/dist/lib/config-loader.js +290 -51
  46. package/dist/lib/config-loader.js.map +1 -1
  47. package/dist/lib/dependency-graph.d.ts +0 -0
  48. package/dist/lib/dependency-graph.d.ts.map +0 -0
  49. package/dist/lib/dependency-graph.js +0 -0
  50. package/dist/lib/dependency-graph.js.map +0 -0
  51. package/dist/lib/exit-codes.d.ts +0 -0
  52. package/dist/lib/exit-codes.d.ts.map +0 -0
  53. package/dist/lib/exit-codes.js +0 -0
  54. package/dist/lib/exit-codes.js.map +0 -0
  55. package/dist/lib/logger.d.ts +0 -0
  56. package/dist/lib/logger.d.ts.map +0 -0
  57. package/dist/lib/logger.js +0 -0
  58. package/dist/lib/logger.js.map +0 -0
  59. package/dist/lib/parallel-runner.d.ts +0 -0
  60. package/dist/lib/parallel-runner.d.ts.map +0 -0
  61. package/dist/lib/parallel-runner.js +0 -0
  62. package/dist/lib/parallel-runner.js.map +0 -0
  63. package/dist/lib/resource-path.d.ts +0 -0
  64. package/dist/lib/resource-path.d.ts.map +1 -1
  65. package/dist/lib/resource-path.js +20 -2
  66. package/dist/lib/resource-path.js.map +1 -1
  67. package/dist/lib/resource-uri.d.ts +0 -0
  68. package/dist/lib/resource-uri.d.ts.map +1 -1
  69. package/dist/lib/resource-uri.js +24 -4
  70. package/dist/lib/resource-uri.js.map +1 -1
  71. package/dist/lib/user-agent.d.ts +0 -0
  72. package/dist/lib/user-agent.d.ts.map +0 -0
  73. package/dist/lib/user-agent.js +0 -0
  74. package/dist/lib/user-agent.js.map +0 -0
  75. package/dist/lib/workspace-link.d.ts +46 -0
  76. package/dist/lib/workspace-link.d.ts.map +1 -0
  77. package/dist/lib/workspace-link.js +93 -0
  78. package/dist/lib/workspace-link.js.map +1 -0
  79. package/dist/models/config.d.ts +80 -44
  80. package/dist/models/config.d.ts.map +1 -1
  81. package/dist/models/config.js +0 -0
  82. package/dist/models/config.js.map +0 -0
  83. package/dist/models/resource-types.d.ts +14 -1
  84. package/dist/models/resource-types.d.ts.map +1 -1
  85. package/dist/models/resource-types.js +11 -3
  86. package/dist/models/resource-types.js.map +1 -1
  87. package/dist/models/types.d.ts +0 -0
  88. package/dist/models/types.d.ts.map +0 -0
  89. package/dist/models/types.js +0 -0
  90. package/dist/models/types.js.map +0 -0
  91. package/dist/services/api-extractor.d.ts +19 -0
  92. package/dist/services/api-extractor.d.ts.map +1 -1
  93. package/dist/services/api-extractor.js +87 -6
  94. package/dist/services/api-extractor.js.map +1 -1
  95. package/dist/services/api-publisher.d.ts +0 -0
  96. package/dist/services/api-publisher.d.ts.map +1 -1
  97. package/dist/services/api-publisher.js +242 -62
  98. package/dist/services/api-publisher.js.map +1 -1
  99. package/dist/services/delete-unmatched-service.d.ts +0 -0
  100. package/dist/services/delete-unmatched-service.d.ts.map +0 -0
  101. package/dist/services/delete-unmatched-service.js +0 -0
  102. package/dist/services/delete-unmatched-service.js.map +0 -0
  103. package/dist/services/dry-run-reporter.d.ts +0 -0
  104. package/dist/services/dry-run-reporter.d.ts.map +0 -0
  105. package/dist/services/dry-run-reporter.js +0 -0
  106. package/dist/services/dry-run-reporter.js.map +0 -0
  107. package/dist/services/extract-service.d.ts +0 -0
  108. package/dist/services/extract-service.d.ts.map +0 -0
  109. package/dist/services/extract-service.js +0 -0
  110. package/dist/services/extract-service.js.map +0 -0
  111. package/dist/services/filter-service.d.ts +1 -0
  112. package/dist/services/filter-service.d.ts.map +1 -1
  113. package/dist/services/filter-service.js +101 -40
  114. package/dist/services/filter-service.js.map +1 -1
  115. package/dist/services/git-diff-service.d.ts +0 -0
  116. package/dist/services/git-diff-service.d.ts.map +0 -0
  117. package/dist/services/git-diff-service.js +0 -0
  118. package/dist/services/git-diff-service.js.map +0 -0
  119. package/dist/services/identity-guide-service.d.ts +1 -1
  120. package/dist/services/identity-guide-service.d.ts.map +1 -1
  121. package/dist/services/identity-guide-service.js +37 -518
  122. package/dist/services/identity-guide-service.js.map +1 -1
  123. package/dist/services/init-service.d.ts +0 -0
  124. package/dist/services/init-service.d.ts.map +1 -1
  125. package/dist/services/init-service.js +51 -19
  126. package/dist/services/init-service.js.map +1 -1
  127. package/dist/services/keyvault-checker.d.ts +0 -0
  128. package/dist/services/keyvault-checker.d.ts.map +0 -0
  129. package/dist/services/keyvault-checker.js +0 -0
  130. package/dist/services/keyvault-checker.js.map +0 -0
  131. package/dist/services/override-merger.d.ts +3 -7
  132. package/dist/services/override-merger.d.ts.map +1 -1
  133. package/dist/services/override-merger.js +198 -47
  134. package/dist/services/override-merger.js.map +1 -1
  135. package/dist/services/product-extractor.d.ts +20 -0
  136. package/dist/services/product-extractor.d.ts.map +1 -1
  137. package/dist/services/product-extractor.js +101 -5
  138. package/dist/services/product-extractor.js.map +1 -1
  139. package/dist/services/product-publisher.d.ts +0 -0
  140. package/dist/services/product-publisher.d.ts.map +1 -1
  141. package/dist/services/product-publisher.js +23 -6
  142. package/dist/services/product-publisher.js.map +1 -1
  143. package/dist/services/prompt-service.d.ts +0 -0
  144. package/dist/services/prompt-service.d.ts.map +0 -0
  145. package/dist/services/prompt-service.js +0 -0
  146. package/dist/services/prompt-service.js.map +0 -0
  147. package/dist/services/publish-service.d.ts +0 -0
  148. package/dist/services/publish-service.d.ts.map +0 -0
  149. package/dist/services/publish-service.js +38 -2
  150. package/dist/services/publish-service.js.map +1 -1
  151. package/dist/services/resource-extractor.d.ts +0 -0
  152. package/dist/services/resource-extractor.d.ts.map +0 -0
  153. package/dist/services/resource-extractor.js +0 -0
  154. package/dist/services/resource-extractor.js.map +0 -0
  155. package/dist/services/resource-publisher.d.ts +0 -0
  156. package/dist/services/resource-publisher.d.ts.map +1 -1
  157. package/dist/services/resource-publisher.js +64 -2
  158. package/dist/services/resource-publisher.js.map +1 -1
  159. package/dist/services/secret-redactor.d.ts +0 -0
  160. package/dist/services/secret-redactor.d.ts.map +0 -0
  161. package/dist/services/secret-redactor.js +0 -0
  162. package/dist/services/secret-redactor.js.map +0 -0
  163. package/dist/services/transitive-resolver.d.ts +0 -0
  164. package/dist/services/transitive-resolver.d.ts.map +1 -1
  165. package/dist/services/transitive-resolver.js +4 -4
  166. package/dist/services/transitive-resolver.js.map +1 -1
  167. package/dist/services/workspace-extractor.d.ts +0 -0
  168. package/dist/services/workspace-extractor.d.ts.map +1 -1
  169. package/dist/services/workspace-extractor.js +50 -7
  170. package/dist/services/workspace-extractor.js.map +1 -1
  171. package/dist/templates/azure-devops/extract-pipeline.d.ts +2 -1
  172. package/dist/templates/azure-devops/extract-pipeline.d.ts.map +1 -1
  173. package/dist/templates/azure-devops/extract-pipeline.js +147 -88
  174. package/dist/templates/azure-devops/extract-pipeline.js.map +1 -1
  175. package/dist/templates/azure-devops/publish-pipeline.d.ts +0 -0
  176. package/dist/templates/azure-devops/publish-pipeline.d.ts.map +1 -1
  177. package/dist/templates/azure-devops/publish-pipeline.js +116 -89
  178. package/dist/templates/azure-devops/publish-pipeline.js.map +1 -1
  179. package/dist/templates/configs/filter-config.d.ts +1 -1
  180. package/dist/templates/configs/filter-config.d.ts.map +1 -1
  181. package/dist/templates/configs/filter-config.js +109 -44
  182. package/dist/templates/configs/filter-config.js.map +1 -1
  183. package/dist/templates/configs/override-config.d.ts +0 -0
  184. package/dist/templates/configs/override-config.d.ts.map +1 -1
  185. package/dist/templates/configs/override-config.js +88 -37
  186. package/dist/templates/configs/override-config.js.map +1 -1
  187. package/dist/templates/configs/package-json.d.ts +0 -0
  188. package/dist/templates/configs/package-json.d.ts.map +0 -0
  189. package/dist/templates/configs/package-json.js +0 -0
  190. package/dist/templates/configs/package-json.js.map +0 -0
  191. package/dist/templates/copilot/identity-setup-prompt.d.ts +4 -3
  192. package/dist/templates/copilot/identity-setup-prompt.d.ts.map +1 -1
  193. package/dist/templates/copilot/identity-setup-prompt.js +59 -269
  194. package/dist/templates/copilot/identity-setup-prompt.js.map +1 -1
  195. package/dist/templates/generated/embedded-markdown.d.ts +12 -0
  196. package/dist/templates/generated/embedded-markdown.d.ts.map +1 -0
  197. package/dist/templates/generated/embedded-markdown.js +14 -0
  198. package/dist/templates/generated/embedded-markdown.js.map +1 -0
  199. package/dist/templates/github-actions/extract-workflow.d.ts +0 -0
  200. package/dist/templates/github-actions/extract-workflow.d.ts.map +0 -0
  201. package/dist/templates/github-actions/extract-workflow.js +118 -118
  202. package/dist/templates/github-actions/extract-workflow.js.map +0 -0
  203. package/dist/templates/github-actions/publish-workflow.d.ts +0 -0
  204. package/dist/templates/github-actions/publish-workflow.d.ts.map +1 -1
  205. package/dist/templates/github-actions/publish-workflow.js +104 -90
  206. package/dist/templates/github-actions/publish-workflow.js.map +1 -1
  207. package/package.json +69 -66
@@ -5,124 +5,124 @@
5
5
  * Generates extract workflow with manual trigger, configuration choice, and auto-PR creation
6
6
  */
7
7
  export function generateExtractWorkflow(config) {
8
- return `name: Run APIM Extractor
9
-
10
- on:
11
- workflow_dispatch:
12
- inputs:
13
- ENVIRONMENT:
14
- description: 'Choose which environment to extract from'
15
- required: true
16
- type: choice
17
- default: dev
18
- options:
19
- - dev
20
- - prod
21
- CONFIGURATION_YAML_PATH:
22
- description: 'Choose whether to extract all APIs or use the extraction configuration file'
23
- required: true
24
- type: choice
25
- options:
26
- - Extract All APIs
27
- - configuration.extract.yaml
28
-
29
- permissions:
30
- id-token: write
31
- contents: write
32
- pull-requests: write
33
-
34
- jobs:
35
- extract:
36
- runs-on: ubuntu-latest
37
- environment: \${{ github.event.inputs.ENVIRONMENT }}
38
- env:
39
- APIM_RESOURCE_GROUP: \${{ (github.event.inputs.ENVIRONMENT == 'dev' && secrets.APIM_RESOURCE_GROUP_DEV) || (github.event.inputs.ENVIRONMENT == 'prod' && secrets.APIM_RESOURCE_GROUP_PROD) }}
40
- APIM_SERVICE_NAME: \${{ (github.event.inputs.ENVIRONMENT == 'dev' && secrets.APIM_SERVICE_NAME_DEV) || (github.event.inputs.ENVIRONMENT == 'prod' && secrets.APIM_SERVICE_NAME_PROD) }}
41
- steps:
42
- - name: Validate required secrets
43
- run: |
44
- if [ -z "\${{ env.APIM_RESOURCE_GROUP }}" ]; then
45
- echo "::error::APIM_RESOURCE_GROUP secret is not set for environment '\${{ github.event.inputs.ENVIRONMENT }}'"
46
- echo "Please configure APIM_RESOURCE_GROUP_\${{ github.event.inputs.ENVIRONMENT == 'dev' && 'DEV' || 'PROD' }} secret in the \${{ github.event.inputs.ENVIRONMENT }} environment"
47
- exit 1
48
- fi
49
- if [ -z "\${{ env.APIM_SERVICE_NAME }}" ]; then
50
- echo "::error::APIM_SERVICE_NAME secret is not set for environment '\${{ github.event.inputs.ENVIRONMENT }}'"
51
- echo "Please configure APIM_SERVICE_NAME_\${{ github.event.inputs.ENVIRONMENT == 'dev' && 'DEV' || 'PROD' }} secret in the \${{ github.event.inputs.ENVIRONMENT }} environment"
52
- exit 1
53
- fi
54
- echo "✓ All required secrets are configured"
55
- echo " Environment: \${{ github.event.inputs.ENVIRONMENT }}"
56
- echo " Resource Group: \${{ env.APIM_RESOURCE_GROUP }}"
57
- echo " Service Name: \${{ env.APIM_SERVICE_NAME }}"
58
-
59
- - name: Checkout repository
60
- uses: actions/checkout@v4
61
-
62
- - name: Setup Node.js
63
- uses: actions/setup-node@v4
64
- with:
65
- node-version: '22'
66
-
67
- - name: Install dependencies
68
- run: npm install
69
-
70
- - name: Azure Login (Federated Credential)
71
- uses: azure/login@v2
72
- with:
73
- client-id: \${{ secrets.AZURE_CLIENT_ID }}
74
- tenant-id: \${{ secrets.AZURE_TENANT_ID }}
75
- subscription-id: \${{ secrets.AZURE_SUBSCRIPTION_ID }}
76
-
77
- - name: Run APIM Extract (All APIs)
78
- if: \${{ github.event.inputs.CONFIGURATION_YAML_PATH == 'Extract All APIs' }}
79
- run: |
80
- npx apiops extract \\
81
- --subscription-id \${{ secrets.AZURE_SUBSCRIPTION_ID }} \\
82
- --resource-group \${{ env.APIM_RESOURCE_GROUP }} \\
83
- --service-name \${{ env.APIM_SERVICE_NAME }} \\
84
- --output ${config.artifactDir}
85
-
86
- - name: Run APIM Extract (With Configuration)
87
- if: \${{ github.event.inputs.CONFIGURATION_YAML_PATH != 'Extract All APIs' }}
88
- run: |
89
- npx apiops extract \\
90
- --subscription-id \${{ secrets.AZURE_SUBSCRIPTION_ID }} \\
91
- --resource-group \${{ env.APIM_RESOURCE_GROUP }} \\
92
- --service-name \${{ env.APIM_SERVICE_NAME }} \\
93
- --output ${config.artifactDir} \\
94
- --filter configuration.extract.yaml
95
-
96
- - name: Upload artifacts
97
- uses: actions/upload-artifact@v4
98
- with:
99
- name: apim-artifacts
100
- path: ${config.artifactDir}
101
- retention-days: 30
102
-
103
- create-pull-request:
104
- needs: extract
105
- runs-on: ubuntu-latest
106
- steps:
107
- - name: Checkout repository
108
- uses: actions/checkout@v4
109
-
110
- - name: Download artifacts
111
- uses: actions/download-artifact@v4
112
- with:
113
- name: apim-artifacts
114
- path: ${config.artifactDir}
115
-
116
- - name: Create pull request
117
- uses: peter-evans/create-pull-request@v6
118
- with:
119
- token: \${{ secrets.GITHUB_TOKEN }}
120
- commit-message: "chore: update APIM artifacts from extract"
121
- title: "APIM Extract - Update artifacts"
122
- body: >
123
- This PR is auto-generated by the APIM extract workflow.
124
- labels: extract, automated pr
125
- branch: apim-extract-\${{ github.run_id }}
8
+ return `name: Run APIM Extractor
9
+
10
+ on:
11
+ workflow_dispatch:
12
+ inputs:
13
+ ENVIRONMENT:
14
+ description: 'Choose which environment to extract from'
15
+ required: true
16
+ type: choice
17
+ default: dev
18
+ options:
19
+ - dev
20
+ - prod
21
+ CONFIGURATION_YAML_PATH:
22
+ description: 'Choose whether to extract all APIs or use the extraction configuration file'
23
+ required: true
24
+ type: choice
25
+ options:
26
+ - Extract All APIs
27
+ - configuration.extractor.yaml
28
+
29
+ permissions:
30
+ id-token: write
31
+ contents: write
32
+ pull-requests: write
33
+
34
+ jobs:
35
+ extract:
36
+ runs-on: ubuntu-latest
37
+ environment: \${{ github.event.inputs.ENVIRONMENT }}
38
+ env:
39
+ APIM_RESOURCE_GROUP: \${{ (github.event.inputs.ENVIRONMENT == 'dev' && secrets.APIM_RESOURCE_GROUP_DEV) || (github.event.inputs.ENVIRONMENT == 'prod' && secrets.APIM_RESOURCE_GROUP_PROD) }}
40
+ APIM_SERVICE_NAME: \${{ (github.event.inputs.ENVIRONMENT == 'dev' && secrets.APIM_SERVICE_NAME_DEV) || (github.event.inputs.ENVIRONMENT == 'prod' && secrets.APIM_SERVICE_NAME_PROD) }}
41
+ steps:
42
+ - name: Validate required secrets
43
+ run: |
44
+ if [ -z "\${{ env.APIM_RESOURCE_GROUP }}" ]; then
45
+ echo "::error::APIM_RESOURCE_GROUP secret is not set for environment '\${{ github.event.inputs.ENVIRONMENT }}'"
46
+ echo "Please configure APIM_RESOURCE_GROUP_\${{ github.event.inputs.ENVIRONMENT == 'dev' && 'DEV' || 'PROD' }} secret in the \${{ github.event.inputs.ENVIRONMENT }} environment"
47
+ exit 1
48
+ fi
49
+ if [ -z "\${{ env.APIM_SERVICE_NAME }}" ]; then
50
+ echo "::error::APIM_SERVICE_NAME secret is not set for environment '\${{ github.event.inputs.ENVIRONMENT }}'"
51
+ echo "Please configure APIM_SERVICE_NAME_\${{ github.event.inputs.ENVIRONMENT == 'dev' && 'DEV' || 'PROD' }} secret in the \${{ github.event.inputs.ENVIRONMENT }} environment"
52
+ exit 1
53
+ fi
54
+ echo "✓ All required secrets are configured"
55
+ echo " Environment: \${{ github.event.inputs.ENVIRONMENT }}"
56
+ echo " Resource Group: \${{ env.APIM_RESOURCE_GROUP }}"
57
+ echo " Service Name: \${{ env.APIM_SERVICE_NAME }}"
58
+
59
+ - name: Checkout repository
60
+ uses: actions/checkout@v4
61
+
62
+ - name: Setup Node.js
63
+ uses: actions/setup-node@v4
64
+ with:
65
+ node-version: '22'
66
+
67
+ - name: Install dependencies
68
+ run: npm install
69
+
70
+ - name: Azure Login (Federated Credential)
71
+ uses: azure/login@v2
72
+ with:
73
+ client-id: \${{ secrets.AZURE_CLIENT_ID }}
74
+ tenant-id: \${{ secrets.AZURE_TENANT_ID }}
75
+ subscription-id: \${{ secrets.AZURE_SUBSCRIPTION_ID }}
76
+
77
+ - name: Run APIM Extract (All APIs)
78
+ if: \${{ github.event.inputs.CONFIGURATION_YAML_PATH == 'Extract All APIs' }}
79
+ run: |
80
+ npx apiops extract \\
81
+ --subscription-id \${{ secrets.AZURE_SUBSCRIPTION_ID }} \\
82
+ --resource-group \${{ env.APIM_RESOURCE_GROUP }} \\
83
+ --service-name \${{ env.APIM_SERVICE_NAME }} \\
84
+ --output ${config.artifactDir}
85
+
86
+ - name: Run APIM Extract (With Configuration)
87
+ if: \${{ github.event.inputs.CONFIGURATION_YAML_PATH != 'Extract All APIs' }}
88
+ run: |
89
+ npx apiops extract \\
90
+ --subscription-id \${{ secrets.AZURE_SUBSCRIPTION_ID }} \\
91
+ --resource-group \${{ env.APIM_RESOURCE_GROUP }} \\
92
+ --service-name \${{ env.APIM_SERVICE_NAME }} \\
93
+ --output ${config.artifactDir} \\
94
+ --filter configuration.extractor.yaml
95
+
96
+ - name: Upload artifacts
97
+ uses: actions/upload-artifact@v4
98
+ with:
99
+ name: apim-artifacts
100
+ path: ${config.artifactDir}
101
+ retention-days: 30
102
+
103
+ create-pull-request:
104
+ needs: extract
105
+ runs-on: ubuntu-latest
106
+ steps:
107
+ - name: Checkout repository
108
+ uses: actions/checkout@v4
109
+
110
+ - name: Download artifacts
111
+ uses: actions/download-artifact@v4
112
+ with:
113
+ name: apim-artifacts
114
+ path: ${config.artifactDir}
115
+
116
+ - name: Create pull request
117
+ uses: peter-evans/create-pull-request@v6
118
+ with:
119
+ token: \${{ secrets.GITHUB_TOKEN }}
120
+ commit-message: "chore: update APIM artifacts from extract"
121
+ title: "APIM Extract - Update artifacts"
122
+ body: >
123
+ This PR is auto-generated by the APIM extract workflow.
124
+ labels: extract, automated pr
125
+ branch: apim-extract-\${{ github.run_id }}
126
126
  `;
127
127
  }
128
128
  //# sourceMappingURL=extract-workflow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"publish-workflow.d.ts","sourceRoot":"","sources":["../../../src/templates/github-actions/publish-workflow.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAsG7E"}
1
+ {"version":3,"file":"publish-workflow.d.ts","sourceRoot":"","sources":["../../../src/templates/github-actions/publish-workflow.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAoH7E"}
@@ -7,101 +7,115 @@
7
7
  export function generatePublishWorkflow(config) {
8
8
  const envChoices = config.environments.map((env) => ` - ${env}`).join('\n');
9
9
  const envJobs = config.environments.map((env, idx) => {
10
+ const envUpper = env.toUpperCase();
10
11
  const autoDeployComment = idx === 0
11
- ? ` # To enable automatic deployment on push to main, uncomment the condition below:
12
+ ? ` # To enable automatic deployment on push to main, uncomment the condition below:
12
13
  # if: github.event.inputs.ENVIRONMENT == '${env}' || github.event_name == 'push'`
13
- : ` # To enable automatic deployment on push to main, uncomment the condition below:
14
- # if: github.event.inputs.ENVIRONMENT == '${env}' || github.event_name == 'push'
14
+ : ` # To enable automatic deployment on push to main, uncomment the condition below:
15
+ # if: github.event.inputs.ENVIRONMENT == '${env}' || github.event_name == 'push'
15
16
  # And change needs to: needs: [get-commit, publish-${config.environments[idx - 1]}]`;
16
- return ` publish-${env}:
17
- ${autoDeployComment}
18
- if: github.event.inputs.ENVIRONMENT == '${env}'
19
- runs-on: ubuntu-latest
20
- environment: ${env}
21
- needs: get-commit
22
- steps:
23
- - name: Checkout repository
24
- uses: actions/checkout@v4
25
- with:
26
- fetch-depth: 2
27
-
28
- - name: Setup Node.js
29
- uses: actions/setup-node@v4
30
- with:
31
- node-version: '22'
32
-
33
- - name: Install dependencies
34
- run: npm install
35
-
36
- - name: Azure Login (Federated Credential)
37
- uses: azure/login@v2
38
- with:
39
- client-id: \${{ secrets.AZURE_CLIENT_ID }}
40
- tenant-id: \${{ secrets.AZURE_TENANT_ID }}
41
- subscription-id: \${{ secrets.AZURE_SUBSCRIPTION_ID }}
42
-
43
- - name: Publish to ${env} (incremental - last commit only)
44
- if: \${{ github.event.inputs.COMMIT_ID_CHOICE != 'publish-all-artifacts-in-repo' }}
45
- run: |
46
- npx apiops publish \\
47
- --subscription-id \${{ secrets.AZURE_SUBSCRIPTION_ID }} \\
48
- --resource-group \${{ secrets.APIM_RESOURCE_GROUP_${env.toUpperCase()} }} \\
49
- --service-name \${{ secrets.APIM_SERVICE_NAME_${env.toUpperCase()} }} \\
50
- --source ${config.artifactDir} \\
51
- --commit-id \${{ needs.get-commit.outputs.commit_id }}
52
-
53
- - name: Publish to ${env} (all artifacts)
54
- if: \${{ github.event.inputs.COMMIT_ID_CHOICE == 'publish-all-artifacts-in-repo' }}
55
- run: |
56
- npx apiops publish \\
57
- --subscription-id \${{ secrets.AZURE_SUBSCRIPTION_ID }} \\
58
- --resource-group \${{ secrets.APIM_RESOURCE_GROUP_${env.toUpperCase()} }} \\
59
- --service-name \${{ secrets.APIM_SERVICE_NAME_${env.toUpperCase()} }} \\
60
- --source ${config.artifactDir}
17
+ return ` publish-${env}:
18
+ ${autoDeployComment}
19
+ if: github.event.inputs.ENVIRONMENT == '${env}'
20
+ runs-on: ubuntu-latest
21
+ environment: ${env}
22
+ needs: get-commit
23
+ steps:
24
+ - name: Checkout repository
25
+ uses: actions/checkout@v4
26
+ with:
27
+ fetch-depth: 2
28
+
29
+ - name: Setup Node.js
30
+ uses: actions/setup-node@v4
31
+ with:
32
+ node-version: '22'
33
+
34
+ - name: Install dependencies
35
+ run: npm install
36
+
37
+ - name: Azure Login (Federated Credential)
38
+ uses: azure/login@v2
39
+ with:
40
+ client-id: \${{ secrets.AZURE_CLIENT_ID }}
41
+ tenant-id: \${{ secrets.AZURE_TENANT_ID }}
42
+ subscription-id: \${{ secrets.AZURE_SUBSCRIPTION_ID }}
43
+
44
+ - name: Substitute tokens in configuration.${env}.yaml
45
+ uses: cschleiden/replace-tokens@v1.3
46
+ with:
47
+ tokenPrefix: '{#['
48
+ tokenSuffix: ']#}'
49
+ files: '["configuration.${env}.yaml"]'
50
+ # Example token mapping for ${env} (uncomment and customize when needed):
51
+ # env:
52
+ # MY_SECRET: \${{ secrets.MY_SECRET_${envUpper} }}
53
+ # ANOTHER_TOKEN: \${{ secrets.ANOTHER_TOKEN_${envUpper} }}
54
+
55
+ - name: Publish to ${env} (incremental - last commit only)
56
+ if: \${{ github.event.inputs.COMMIT_ID_CHOICE != 'publish-all-artifacts-in-repo' }}
57
+ run: |
58
+ npx apiops publish \\
59
+ --subscription-id \${{ secrets.AZURE_SUBSCRIPTION_ID }} \\
60
+ --resource-group \${{ secrets.APIM_RESOURCE_GROUP_${envUpper} }} \\
61
+ --service-name \${{ secrets.APIM_SERVICE_NAME_${envUpper} }} \\
62
+ --source ${config.artifactDir} \\
63
+ --overrides configuration.${env}.yaml \\
64
+ --commit-id \${{ needs.get-commit.outputs.commit_id }}
65
+
66
+ - name: Publish to ${env} (all artifacts)
67
+ if: \${{ github.event.inputs.COMMIT_ID_CHOICE == 'publish-all-artifacts-in-repo' }}
68
+ run: |
69
+ npx apiops publish \\
70
+ --subscription-id \${{ secrets.AZURE_SUBSCRIPTION_ID }} \\
71
+ --resource-group \${{ secrets.APIM_RESOURCE_GROUP_${envUpper} }} \\
72
+ --service-name \${{ secrets.APIM_SERVICE_NAME_${envUpper} }} \\
73
+ --source ${config.artifactDir} \\
74
+ --overrides configuration.${env}.yaml
61
75
  `;
62
76
  }).join('\n');
63
- return `name: Run APIM Publisher
64
-
65
- on:
66
- push:
67
- branches:
68
- - main
69
- paths:
70
- - '${config.artifactDir}/**'
71
- - 'configuration.*.yaml'
72
- workflow_dispatch:
73
- inputs:
74
- COMMIT_ID_CHOICE:
75
- description: 'Choose "publish-all-artifacts-in-repo" only when you want to force republishing all artifacts (e.g. after build failure). Otherwise stick with the default behavior of "publish-artifacts-in-last-commit"'
76
- required: true
77
- type: choice
78
- default: publish-artifacts-in-last-commit
79
- options:
80
- - publish-artifacts-in-last-commit
81
- - publish-all-artifacts-in-repo
82
- ENVIRONMENT:
83
- description: 'Choose which environment to publish to'
84
- required: true
85
- type: choice
86
- default: ${config.environments[0]}
87
- options:
88
- ${envChoices}
89
-
90
- permissions:
91
- id-token: write
92
- contents: read
93
-
94
- jobs:
95
- get-commit:
96
- runs-on: ubuntu-latest
97
- outputs:
98
- commit_id: \${{ steps.commit.outputs.commit_id }}
99
- steps:
100
- - name: Set the Commit Id
101
- id: commit
102
- run: echo "commit_id=\${GITHUB_SHA}" >> $GITHUB_OUTPUT
103
-
104
- ${envJobs}
77
+ return `name: Run APIM Publisher
78
+
79
+ on:
80
+ push:
81
+ branches:
82
+ - main
83
+ paths:
84
+ - '${config.artifactDir}/**'
85
+ - 'configuration.*.yaml'
86
+ workflow_dispatch:
87
+ inputs:
88
+ COMMIT_ID_CHOICE:
89
+ description: 'Choose "publish-all-artifacts-in-repo" only when you want to force republishing all artifacts (e.g. after build failure). Otherwise stick with the default behavior of "publish-artifacts-in-last-commit"'
90
+ required: true
91
+ type: choice
92
+ default: publish-artifacts-in-last-commit
93
+ options:
94
+ - publish-artifacts-in-last-commit
95
+ - publish-all-artifacts-in-repo
96
+ ENVIRONMENT:
97
+ description: 'Choose which environment to publish to'
98
+ required: true
99
+ type: choice
100
+ default: ${config.environments[0]}
101
+ options:
102
+ ${envChoices}
103
+
104
+ permissions:
105
+ id-token: write
106
+ contents: read
107
+
108
+ jobs:
109
+ get-commit:
110
+ runs-on: ubuntu-latest
111
+ outputs:
112
+ commit_id: \${{ steps.commit.outputs.commit_id }}
113
+ steps:
114
+ - name: Set the Commit Id
115
+ id: commit
116
+ run: echo "commit_id=\${GITHUB_SHA}" >> $GITHUB_OUTPUT
117
+
118
+ ${envJobs}
105
119
  `;
106
120
  }
107
121
  //# sourceMappingURL=publish-workflow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"publish-workflow.js","sourceRoot":"","sources":["../../../src/templates/github-actions/publish-workflow.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;;GAGG;AAOH,MAAM,UAAU,uBAAuB,CAAC,MAA6B;IACnE,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAErF,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnD,MAAM,iBAAiB,GAAG,GAAG,KAAK,CAAC;YACjC,CAAC,CAAC;gDACwC,GAAG,kCAAkC;YAC/E,CAAC,CAAC;gDACwC,GAAG;yDACM,MAAM,CAAC,YAAY,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;QAErF,OAAO,aAAa,GAAG;EACzB,iBAAiB;8CAC2B,GAAG;;mBAE9B,GAAG;;;;;;;;;;;;;;;;;;;;;;;2BAuBK,GAAG;;;;;gEAKkC,GAAG,CAAC,WAAW,EAAE;4DACrB,GAAG,CAAC,WAAW,EAAE;uBACtD,MAAM,CAAC,WAAW;;;2BAGd,GAAG;;;;;gEAKkC,GAAG,CAAC,WAAW,EAAE;4DACrB,GAAG,CAAC,WAAW,EAAE;uBACtD,MAAM,CAAC,WAAW;CACxC,CAAC;IACA,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;;;;;;;WAOE,MAAM,CAAC,WAAW;;;;;;;;;;;;;;;;mBAgBV,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;;EAEvC,UAAU;;;;;;;;;;;;;;;;EAgBV,OAAO;CACR,CAAC;AACF,CAAC"}
1
+ {"version":3,"file":"publish-workflow.js","sourceRoot":"","sources":["../../../src/templates/github-actions/publish-workflow.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;;GAGG;AAOH,MAAM,UAAU,uBAAuB,CAAC,MAA6B;IACnE,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAErF,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnD,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,iBAAiB,GAAG,GAAG,KAAK,CAAC;YACjC,CAAC,CAAC;gDACwC,GAAG,kCAAkC;YAC/E,CAAC,CAAC;gDACwC,GAAG;yDACM,MAAM,CAAC,YAAY,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;QAErF,OAAO,aAAa,GAAG;EACzB,iBAAiB;8CAC2B,GAAG;;mBAE9B,GAAG;;;;;;;;;;;;;;;;;;;;;;;mDAuB6B,GAAG;;;;;oCAKlB,GAAG;wCACC,GAAG;;kDAEO,QAAQ;0DACA,QAAQ;;2BAEvC,GAAG;;;;;gEAKkC,QAAQ;4DACZ,QAAQ;uBAC7C,MAAM,CAAC,WAAW;wCACD,GAAG;;;2BAGhB,GAAG;;;;;gEAKkC,QAAQ;4DACZ,QAAQ;uBAC7C,MAAM,CAAC,WAAW;wCACD,GAAG;CAC1C,CAAC;IACA,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;;;;;;;WAOE,MAAM,CAAC,WAAW;;;;;;;;;;;;;;;;mBAgBV,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;;EAEvC,UAAU;;;;;;;;;;;;;;;;EAgBV,OAAO;CACR,CAAC;AACF,CAAC"}
package/package.json CHANGED
@@ -1,66 +1,69 @@
1
- {
2
- "name": "@peterhauge/apiops-cli",
3
- "version": "0.1.7-alpha.0",
4
- "description": "CLI tool for Azure API Management configuration-as-code",
5
- "type": "module",
6
- "private": false,
7
- "main": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "bin": {
10
- "apiops": "dist/cli/index.js"
11
- },
12
- "files": [
13
- "dist"
14
- ],
15
- "readme": "README.md",
16
- "scripts": {
17
- "build": "tsc",
18
- "test": "vitest run",
19
- "test:watch": "vitest",
20
- "lint": "eslint src tests",
21
- "start": "tsx src/cli/index.ts"
22
- },
23
- "engines": {
24
- "node": ">=22.0.0"
25
- },
26
- "repository": {
27
- "type": "git",
28
- "url": "git+https://github.com/Azure/apiops-cli.git"
29
- },
30
- "keywords": [
31
- "azure",
32
- "api-management",
33
- "apim",
34
- "cli",
35
- "gitops",
36
- "configuration-as-code"
37
- ],
38
- "author": "",
39
- "license": "MIT",
40
- "bugs": {
41
- "url": "https://github.com/Azure/apiops-cli/issues"
42
- },
43
- "homepage": "https://github.com/Azure/apiops-cli#readme",
44
- "dependencies": {
45
- "@azure/identity": "^4.13.1",
46
- "any-ascii": "^0.3.3",
47
- "commander": "^14.0.3",
48
- "he": "^1.2.0",
49
- "js-yaml": "^4.1.1",
50
- "simple-git": "^3.35.2"
51
- },
52
- "devDependencies": {
53
- "@eslint/js": "^10.0.1",
54
- "@types/he": "^1.2.3",
55
- "@types/js-yaml": "^4.0.9",
56
- "@types/node": "^25.5.2",
57
- "@typescript-eslint/eslint-plugin": "^8.58.1",
58
- "@typescript-eslint/parser": "^8.58.1",
59
- "@vitest/coverage-v8": "^4.1.4",
60
- "eslint": "^10.2.0",
61
- "tsx": "^4.21.0",
62
- "typescript": "^6.0.2",
63
- "typescript-eslint": "^8.58.1",
64
- "vitest": "^4.1.3"
65
- }
66
- }
1
+ {
2
+ "name": "@peterhauge/apiops-cli",
3
+ "version": "0.2.0-alpha.0",
4
+ "description": "CLI tool for Azure API Management configuration-as-code",
5
+ "type": "module",
6
+ "private": false,
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "bin": {
10
+ "apiops": "dist/cli/index.js"
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "readme": "README.md",
16
+ "scripts": {
17
+ "prelint": "node scripts/embed-markdown-templates.mjs",
18
+ "prebuild": "node scripts/embed-markdown-templates.mjs",
19
+ "pretest": "node scripts/embed-markdown-templates.mjs",
20
+ "build": "tsc",
21
+ "test": "vitest run",
22
+ "test:watch": "vitest",
23
+ "lint": "eslint src tests",
24
+ "start": "tsx src/cli/index.ts"
25
+ },
26
+ "engines": {
27
+ "node": ">=22.0.0"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/Azure/apiops-cli.git"
32
+ },
33
+ "keywords": [
34
+ "azure",
35
+ "api-management",
36
+ "apim",
37
+ "cli",
38
+ "gitops",
39
+ "configuration-as-code"
40
+ ],
41
+ "author": "",
42
+ "license": "MIT",
43
+ "bugs": {
44
+ "url": "https://github.com/Azure/apiops-cli/issues"
45
+ },
46
+ "homepage": "https://github.com/Azure/apiops-cli#readme",
47
+ "dependencies": {
48
+ "@azure/identity": "^4.13.1",
49
+ "any-ascii": "^0.3.3",
50
+ "commander": "^14.0.3",
51
+ "he": "^1.2.0",
52
+ "js-yaml": "^4.1.1",
53
+ "simple-git": "^3.35.2"
54
+ },
55
+ "devDependencies": {
56
+ "@eslint/js": "^10.0.1",
57
+ "@types/he": "^1.2.3",
58
+ "@types/js-yaml": "^4.0.9",
59
+ "@types/node": "^25.5.2",
60
+ "@typescript-eslint/eslint-plugin": "^8.58.1",
61
+ "@typescript-eslint/parser": "^8.58.1",
62
+ "@vitest/coverage-v8": "^4.1.4",
63
+ "eslint": "^10.2.0",
64
+ "tsx": "^4.21.0",
65
+ "typescript": "^6.0.2",
66
+ "typescript-eslint": "^8.58.1",
67
+ "vitest": "^4.1.3"
68
+ }
69
+ }