@peterhauge/apiops-cli 0.1.7-alpha.0 → 0.2.1-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.
- package/LICENSE.md +22 -22
- package/README.md +169 -169
- package/dist/cli/init-command.d.ts.map +1 -1
- package/dist/cli/init-command.js +2 -1
- package/dist/cli/init-command.js.map +1 -1
- package/dist/clients/apim-client.d.ts +25 -1
- package/dist/clients/apim-client.d.ts.map +1 -1
- package/dist/clients/apim-client.js +173 -9
- package/dist/clients/apim-client.js.map +1 -1
- package/dist/clients/iapim-client.d.ts +6 -0
- package/dist/clients/iapim-client.d.ts.map +1 -1
- package/dist/lib/config-loader.d.ts +0 -4
- package/dist/lib/config-loader.d.ts.map +1 -1
- package/dist/lib/config-loader.js +290 -51
- package/dist/lib/config-loader.js.map +1 -1
- package/dist/lib/resource-path.d.ts.map +1 -1
- package/dist/lib/resource-path.js +20 -2
- package/dist/lib/resource-path.js.map +1 -1
- package/dist/lib/resource-uri.d.ts.map +1 -1
- package/dist/lib/resource-uri.js +24 -4
- package/dist/lib/resource-uri.js.map +1 -1
- package/dist/lib/workspace-link.d.ts +46 -0
- package/dist/lib/workspace-link.d.ts.map +1 -0
- package/dist/lib/workspace-link.js +93 -0
- package/dist/lib/workspace-link.js.map +1 -0
- package/dist/models/config.d.ts +80 -44
- package/dist/models/config.d.ts.map +1 -1
- package/dist/models/resource-types.d.ts +14 -1
- package/dist/models/resource-types.d.ts.map +1 -1
- package/dist/models/resource-types.js +11 -3
- package/dist/models/resource-types.js.map +1 -1
- package/dist/services/api-extractor.d.ts +19 -0
- package/dist/services/api-extractor.d.ts.map +1 -1
- package/dist/services/api-extractor.js +87 -6
- package/dist/services/api-extractor.js.map +1 -1
- package/dist/services/api-publisher.d.ts.map +1 -1
- package/dist/services/api-publisher.js +251 -60
- package/dist/services/api-publisher.js.map +1 -1
- package/dist/services/filter-service.d.ts +1 -0
- package/dist/services/filter-service.d.ts.map +1 -1
- package/dist/services/filter-service.js +101 -40
- package/dist/services/filter-service.js.map +1 -1
- package/dist/services/identity-guide-service.d.ts +1 -1
- package/dist/services/identity-guide-service.d.ts.map +1 -1
- package/dist/services/identity-guide-service.js +37 -518
- package/dist/services/identity-guide-service.js.map +1 -1
- package/dist/services/init-service.d.ts.map +1 -1
- package/dist/services/init-service.js +51 -19
- package/dist/services/init-service.js.map +1 -1
- package/dist/services/override-merger.d.ts +3 -7
- package/dist/services/override-merger.d.ts.map +1 -1
- package/dist/services/override-merger.js +198 -47
- package/dist/services/override-merger.js.map +1 -1
- package/dist/services/product-extractor.d.ts +20 -0
- package/dist/services/product-extractor.d.ts.map +1 -1
- package/dist/services/product-extractor.js +101 -5
- package/dist/services/product-extractor.js.map +1 -1
- package/dist/services/product-publisher.d.ts.map +1 -1
- package/dist/services/product-publisher.js +23 -6
- package/dist/services/product-publisher.js.map +1 -1
- package/dist/services/publish-service.d.ts.map +1 -1
- package/dist/services/publish-service.js +55 -7
- package/dist/services/publish-service.js.map +1 -1
- package/dist/services/resource-extractor.d.ts.map +1 -1
- package/dist/services/resource-extractor.js +1 -52
- package/dist/services/resource-extractor.js.map +1 -1
- package/dist/services/resource-publisher.d.ts.map +1 -1
- package/dist/services/resource-publisher.js +179 -2
- package/dist/services/resource-publisher.js.map +1 -1
- package/dist/services/transitive-resolver.d.ts.map +1 -1
- package/dist/services/transitive-resolver.js +4 -4
- package/dist/services/transitive-resolver.js.map +1 -1
- package/dist/services/workspace-extractor.d.ts.map +1 -1
- package/dist/services/workspace-extractor.js +50 -7
- package/dist/services/workspace-extractor.js.map +1 -1
- package/dist/templates/azure-devops/extract-pipeline.d.ts +2 -1
- package/dist/templates/azure-devops/extract-pipeline.d.ts.map +1 -1
- package/dist/templates/azure-devops/extract-pipeline.js +147 -88
- package/dist/templates/azure-devops/extract-pipeline.js.map +1 -1
- package/dist/templates/azure-devops/publish-pipeline.d.ts.map +1 -1
- package/dist/templates/azure-devops/publish-pipeline.js +116 -89
- package/dist/templates/azure-devops/publish-pipeline.js.map +1 -1
- package/dist/templates/configs/filter-config.d.ts +1 -1
- package/dist/templates/configs/filter-config.d.ts.map +1 -1
- package/dist/templates/configs/filter-config.js +109 -44
- package/dist/templates/configs/filter-config.js.map +1 -1
- package/dist/templates/configs/override-config.d.ts.map +1 -1
- package/dist/templates/configs/override-config.js +90 -37
- package/dist/templates/configs/override-config.js.map +1 -1
- package/dist/templates/copilot/identity-setup-prompt.d.ts +4 -3
- package/dist/templates/copilot/identity-setup-prompt.d.ts.map +1 -1
- package/dist/templates/copilot/identity-setup-prompt.js +59 -269
- package/dist/templates/copilot/identity-setup-prompt.js.map +1 -1
- package/dist/templates/generated/embedded-markdown.d.ts +12 -0
- package/dist/templates/generated/embedded-markdown.d.ts.map +1 -0
- package/dist/templates/generated/embedded-markdown.js +14 -0
- package/dist/templates/generated/embedded-markdown.js.map +1 -0
- package/dist/templates/github-actions/extract-workflow.js +118 -118
- package/dist/templates/github-actions/publish-workflow.d.ts.map +1 -1
- package/dist/templates/github-actions/publish-workflow.js +104 -90
- package/dist/templates/github-actions/publish-workflow.js.map +1 -1
- package/package.json +69 -66
|
@@ -2,96 +2,155 @@
|
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
/**
|
|
4
4
|
* T045: Azure DevOps extract pipeline template
|
|
5
|
-
* Manual trigger with configuration choice and auto-PR creation
|
|
5
|
+
* Manual trigger with environment choice, configuration choice, and auto-PR creation
|
|
6
6
|
*/
|
|
7
7
|
export function generateExtractPipeline(config) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- name:
|
|
25
|
-
type: string
|
|
26
|
-
displayName: '
|
|
27
|
-
default:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
8
|
+
const defaultEnv = config.environments[0];
|
|
9
|
+
const envValues = config.environments.map((env) => ` - '${env}'`).join('\n');
|
|
10
|
+
const varGroupBlocks = config.environments
|
|
11
|
+
.map((env) => `- \${{ if eq(parameters.ENVIRONMENT, '${env}') }}:\n - group: apim-${env}`)
|
|
12
|
+
.join('\n');
|
|
13
|
+
return `# Azure DevOps Pipeline: Run APIM Extractor
|
|
14
|
+
|
|
15
|
+
trigger: none
|
|
16
|
+
|
|
17
|
+
parameters:
|
|
18
|
+
- name: ENVIRONMENT
|
|
19
|
+
type: string
|
|
20
|
+
displayName: 'Choose which environment to extract from'
|
|
21
|
+
default: '${defaultEnv}'
|
|
22
|
+
values:
|
|
23
|
+
${envValues}
|
|
24
|
+
- name: CONFIGURATION_YAML_PATH
|
|
25
|
+
type: string
|
|
26
|
+
displayName: 'Choose whether to extract all APIs or use the extraction configuration file'
|
|
27
|
+
default: 'Extract All APIs'
|
|
28
|
+
values:
|
|
29
|
+
- 'Extract All APIs'
|
|
30
|
+
- 'configuration.extractor.yaml'
|
|
31
|
+
|
|
32
|
+
pool:
|
|
33
|
+
vmImage: 'ubuntu-latest'
|
|
34
|
+
|
|
35
|
+
variables:
|
|
36
|
+
${varGroupBlocks}
|
|
37
|
+
|
|
38
|
+
steps:
|
|
39
|
+
- checkout: self
|
|
40
|
+
persistCredentials: true
|
|
41
|
+
fetchDepth: 2
|
|
42
|
+
|
|
43
|
+
- task: UseNode@1
|
|
44
|
+
displayName: 'Setup Node.js'
|
|
45
|
+
inputs:
|
|
46
|
+
version: '22.x'
|
|
47
|
+
|
|
48
|
+
- script: |
|
|
49
|
+
if [ -f package-lock.json ] || [ -f npm-shrinkwrap.json ]; then
|
|
50
|
+
npm ci
|
|
51
|
+
else
|
|
52
|
+
npm install --no-audit --no-fund
|
|
53
|
+
fi
|
|
54
|
+
displayName: 'Install dependencies'
|
|
55
|
+
|
|
56
|
+
- bash: |
|
|
57
|
+
APIM_RESOURCE_GROUP='$(APIM_RESOURCE_GROUP)'
|
|
58
|
+
APIM_SERVICE_NAME='$(APIM_SERVICE_NAME)'
|
|
59
|
+
SERVICE_CONNECTION='$(AZURE_SERVICE_CONNECTION)'
|
|
60
|
+
SUBSCRIPTION_ID='$(AZURE_SUBSCRIPTION_ID)'
|
|
61
|
+
|
|
62
|
+
if [[ -z "$APIM_RESOURCE_GROUP" || "$APIM_RESOURCE_GROUP" == '$('*')' ]]; then
|
|
63
|
+
echo "##vso[task.logissue type=error]APIM_RESOURCE_GROUP is not set. Ensure variable group 'apim-\${{ parameters.ENVIRONMENT }}' is authorized and defines APIM_RESOURCE_GROUP."
|
|
64
|
+
exit 2
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
if [[ -z "$APIM_SERVICE_NAME" || "$APIM_SERVICE_NAME" == '$('*')' ]]; then
|
|
68
|
+
echo "##vso[task.logissue type=error]APIM_SERVICE_NAME is not set. Ensure variable group 'apim-\${{ parameters.ENVIRONMENT }}' is authorized and defines APIM_SERVICE_NAME."
|
|
69
|
+
exit 2
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
if [[ -z "$SERVICE_CONNECTION" || "$SERVICE_CONNECTION" == '$('*')' ]]; then
|
|
73
|
+
echo "##vso[task.logissue type=error]AZURE_SERVICE_CONNECTION is not set. Ensure variable group 'apim-\${{ parameters.ENVIRONMENT }}' is authorized and defines AZURE_SERVICE_CONNECTION."
|
|
74
|
+
exit 2
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
if [[ -z "$SUBSCRIPTION_ID" || "$SUBSCRIPTION_ID" == '$('*')' ]]; then
|
|
78
|
+
echo "##vso[task.logissue type=error]AZURE_SUBSCRIPTION_ID is not set. Ensure variable group 'apim-\${{ parameters.ENVIRONMENT }}' is authorized and defines AZURE_SUBSCRIPTION_ID."
|
|
79
|
+
exit 2
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
echo "All required variables are configured for environment '\${{ parameters.ENVIRONMENT }}'"
|
|
83
|
+
displayName: 'Validate required variables'
|
|
84
|
+
|
|
85
|
+
- task: AzureCLI@2
|
|
86
|
+
displayName: 'Run APIM Extract (All APIs)'
|
|
87
|
+
condition: eq('\${{ parameters.CONFIGURATION_YAML_PATH }}', 'Extract All APIs')
|
|
88
|
+
inputs:
|
|
89
|
+
azureSubscription: '$(AZURE_SERVICE_CONNECTION)'
|
|
90
|
+
scriptType: 'bash'
|
|
91
|
+
scriptLocation: 'inlineScript'
|
|
92
|
+
inlineScript: |
|
|
93
|
+
npx @peterhauge/apiops-cli extract \\
|
|
94
|
+
--resource-group "$(APIM_RESOURCE_GROUP)" \\
|
|
95
|
+
--service-name "$(APIM_SERVICE_NAME)" \\
|
|
96
|
+
--output ${config.artifactDir} \\
|
|
97
|
+
--subscription-id "$(AZURE_SUBSCRIPTION_ID)"
|
|
98
|
+
|
|
99
|
+
- task: AzureCLI@2
|
|
100
|
+
displayName: 'Run APIM Extract (With Configuration)'
|
|
101
|
+
condition: ne('\${{ parameters.CONFIGURATION_YAML_PATH }}', 'Extract All APIs')
|
|
102
|
+
inputs:
|
|
103
|
+
azureSubscription: '$(AZURE_SERVICE_CONNECTION)'
|
|
104
|
+
scriptType: 'bash'
|
|
105
|
+
scriptLocation: 'inlineScript'
|
|
106
|
+
inlineScript: |
|
|
107
|
+
npx @peterhauge/apiops-cli extract \\
|
|
108
|
+
--resource-group "$(APIM_RESOURCE_GROUP)" \\
|
|
109
|
+
--service-name "$(APIM_SERVICE_NAME)" \\
|
|
110
|
+
--output ${config.artifactDir} \\
|
|
111
|
+
--filter configuration.extractor.yaml \\
|
|
112
|
+
--subscription-id "$(AZURE_SUBSCRIPTION_ID)"
|
|
113
|
+
|
|
114
|
+
- task: PublishPipelineArtifact@1
|
|
115
|
+
displayName: 'Publish artifacts'
|
|
116
|
+
inputs:
|
|
117
|
+
targetPath: ${config.artifactDir}
|
|
118
|
+
artifactName: apim-artifacts
|
|
119
|
+
|
|
120
|
+
- bash: |
|
|
121
|
+
BRANCH_NAME="apim-extract-$(Build.BuildId)"
|
|
122
|
+
TARGET_BRANCH="$(Build.SourceBranch)"
|
|
123
|
+
BUILD_ID="$(Build.BuildId)"
|
|
124
|
+
|
|
125
|
+
git config user.name "Azure DevOps"
|
|
126
|
+
git config user.email "azuredevops@microsoft.com"
|
|
127
|
+
git checkout -b "$BRANCH_NAME"
|
|
128
|
+
git add ${config.artifactDir}
|
|
129
|
+
if git diff --cached --quiet; then
|
|
130
|
+
echo "No changes to commit"
|
|
131
|
+
exit 0
|
|
132
|
+
fi
|
|
133
|
+
git commit -m "chore: update APIM artifacts from extract"
|
|
134
|
+
git push origin "$BRANCH_NAME"
|
|
135
|
+
|
|
136
|
+
PR_PAYLOAD=$(printf '{"title":"APIM Extract - Update artifacts","description":"Auto-generated by APIM extract pipeline run %s","sourceRefName":"refs/heads/%s","targetRefName":"%s"}' \\
|
|
137
|
+
"$BUILD_ID" "$BRANCH_NAME" "$TARGET_BRANCH")
|
|
138
|
+
|
|
139
|
+
HTTP_STATUS=$(curl -s -o /tmp/pr_response.json -w "%{http_code}" -X POST \\
|
|
140
|
+
-H "Content-Type: application/json" \\
|
|
141
|
+
-H "Authorization: Bearer $SYSTEM_ACCESSTOKEN" \\
|
|
142
|
+
"$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_apis/git/repositories/$(Build.Repository.Name)/pullrequests?api-version=7.1" \\
|
|
143
|
+
-d "$PR_PAYLOAD")
|
|
144
|
+
|
|
145
|
+
if [ "$HTTP_STATUS" = "201" ]; then
|
|
146
|
+
PR_ID=$(python3 -c "import json; print(json.load(open('/tmp/pr_response.json'))['pullRequestId'])" 2>/dev/null)
|
|
147
|
+
echo "##vso[task.logissue type=warning]Pull request created: $(System.TeamFoundationCollectionUri)$(System.TeamProject)/_git/$(Build.Repository.Name)/pullrequest/$PR_ID"
|
|
148
|
+
else
|
|
149
|
+
echo "##vso[task.logissue type=warning]Could not auto-create PR (HTTP $HTTP_STATUS). Please create a PR from '$BRANCH_NAME' to '$TARGET_BRANCH' manually."
|
|
150
|
+
fi
|
|
151
|
+
displayName: 'Create branch and open pull request'
|
|
152
|
+
env:
|
|
153
|
+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
|
|
95
154
|
`;
|
|
96
155
|
}
|
|
97
156
|
//# sourceMappingURL=extract-pipeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-pipeline.js","sourceRoot":"","sources":["../../../src/templates/azure-devops/extract-pipeline.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;;GAGG;
|
|
1
|
+
{"version":3,"file":"extract-pipeline.js","sourceRoot":"","sources":["../../../src/templates/azure-devops/extract-pipeline.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;;GAGG;AAOH,MAAM,UAAU,uBAAuB,CAAC,MAA6B;IACnE,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClF,MAAM,cAAc,GAAG,MAAM,CAAC,YAAY;SACvC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,yCAAyC,GAAG,2BAA2B,GAAG,EAAE,CAAC;SAC1F,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;;;;;;;;gBAQO,UAAU;;EAExB,SAAS;;;;;;;;;;;;;EAaT,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA4DK,MAAM,CAAC,WAAW;;;;;;;;;;;;;;qBAclB,MAAM,CAAC,WAAW;;;;;;;oBAOnB,MAAM,CAAC,WAAW;;;;;;;;;;;gBAWtB,MAAM,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BjC,CAAC;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-pipeline.d.ts","sourceRoot":"","sources":["../../../src/templates/azure-devops/publish-pipeline.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,
|
|
1
|
+
{"version":3,"file":"publish-pipeline.d.ts","sourceRoot":"","sources":["../../../src/templates/azure-devops/publish-pipeline.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,CA4H7E"}
|
|
@@ -5,98 +5,125 @@
|
|
|
5
5
|
* Multi-stage pipeline with commit ID choice, environment selection, and variable groups
|
|
6
6
|
*/
|
|
7
7
|
export function generatePublishPipeline(config) {
|
|
8
|
+
const defaultEnvironment = config.environments[0] ?? 'dev';
|
|
8
9
|
const envValues = config.environments.map((env) => ` - '${env}'`).join('\n');
|
|
9
|
-
const stages = config.environments.map((env
|
|
10
|
-
const
|
|
11
|
-
return
|
|
12
|
-
displayName: 'Publish to ${env}'
|
|
13
|
-
condition:
|
|
14
|
-
variables:
|
|
15
|
-
- group: apim-${env}
|
|
16
|
-
jobs:
|
|
17
|
-
- deployment: Deploy
|
|
18
|
-
displayName: 'Deploy to ${env}'
|
|
19
|
-
environment: ${env}
|
|
20
|
-
pool:
|
|
21
|
-
vmImage: 'ubuntu-latest'
|
|
22
|
-
strategy:
|
|
23
|
-
runOnce:
|
|
24
|
-
deploy:
|
|
25
|
-
steps:
|
|
26
|
-
- checkout: self
|
|
27
|
-
fetchDepth: 2
|
|
28
|
-
|
|
29
|
-
- task:
|
|
30
|
-
displayName: 'Setup Node.js'
|
|
31
|
-
inputs:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
- script:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
10
|
+
const stages = config.environments.map((env) => {
|
|
11
|
+
const envUpper = env.toUpperCase();
|
|
12
|
+
return `- stage: Publish_${env}
|
|
13
|
+
displayName: 'Publish to ${env}'
|
|
14
|
+
condition: eq('\${{ parameters.ENVIRONMENT }}', '${env}')
|
|
15
|
+
variables:
|
|
16
|
+
- group: apim-${env}
|
|
17
|
+
jobs:
|
|
18
|
+
- deployment: Deploy
|
|
19
|
+
displayName: 'Deploy to ${env}'
|
|
20
|
+
environment: ${env}
|
|
21
|
+
pool:
|
|
22
|
+
vmImage: 'ubuntu-latest'
|
|
23
|
+
strategy:
|
|
24
|
+
runOnce:
|
|
25
|
+
deploy:
|
|
26
|
+
steps:
|
|
27
|
+
- checkout: self
|
|
28
|
+
fetchDepth: 2
|
|
29
|
+
|
|
30
|
+
- task: UseNode@1
|
|
31
|
+
displayName: 'Setup Node.js'
|
|
32
|
+
inputs:
|
|
33
|
+
version: '22.x'
|
|
34
|
+
|
|
35
|
+
- script: |
|
|
36
|
+
node -v
|
|
37
|
+
npm -v
|
|
38
|
+
displayName: 'Verify Node.js version'
|
|
39
|
+
|
|
40
|
+
- script: |
|
|
41
|
+
if [[ -f package-lock.json || -f npm-shrinkwrap.json ]]; then
|
|
42
|
+
npm ci
|
|
43
|
+
else
|
|
44
|
+
npm install
|
|
45
|
+
fi
|
|
46
|
+
displayName: 'Install dependencies'
|
|
47
|
+
|
|
48
|
+
- task: replacetokens@6
|
|
49
|
+
displayName: 'Substitute tokens in configuration.${env}.yaml'
|
|
50
|
+
inputs:
|
|
51
|
+
sources: 'configuration.${env}.yaml'
|
|
52
|
+
tokenPattern: 'custom'
|
|
53
|
+
tokenPrefix: '{#['
|
|
54
|
+
tokenSuffix: ']#}'
|
|
55
|
+
missingVarAction: 'keep'
|
|
56
|
+
|
|
57
|
+
- script: |
|
|
58
|
+
if grep -q '{#\\[' configuration.${env}.yaml; then
|
|
59
|
+
echo "Unresolved tokens remain in configuration.${env}.yaml"
|
|
60
|
+
grep -o '{#\\[[^]]*\\]#}' configuration.${env}.yaml | sort -u
|
|
61
|
+
exit 1
|
|
62
|
+
fi
|
|
63
|
+
displayName: 'Validate token substitution (${env})'
|
|
64
|
+
|
|
65
|
+
- task: AzureCLI@2
|
|
66
|
+
displayName: 'Publish to ${env} (incremental - last commit only)'
|
|
67
|
+
condition: ne('\${{ parameters.COMMIT_ID_CHOICE }}', 'publish-all-artifacts-in-repo')
|
|
68
|
+
inputs:
|
|
69
|
+
azureSubscription: 'AZURE_SERVICE_CONNECTION_${envUpper}'
|
|
70
|
+
scriptType: 'bash'
|
|
71
|
+
scriptLocation: 'inlineScript'
|
|
72
|
+
inlineScript: |
|
|
73
|
+
npx apiops publish \\
|
|
74
|
+
--resource-group $(APIM_RESOURCE_GROUP_${envUpper}) \\
|
|
75
|
+
--service-name $(APIM_SERVICE_NAME_${envUpper}) \\
|
|
76
|
+
--source ${config.artifactDir} \\
|
|
77
|
+
--overrides configuration.${env}.yaml \\
|
|
78
|
+
--commit-id $(Build.SourceVersion) \\
|
|
79
|
+
--subscription-id $(AZURE_SUBSCRIPTION_ID)
|
|
80
|
+
|
|
81
|
+
- task: AzureCLI@2
|
|
82
|
+
displayName: 'Publish to ${env} (all artifacts)'
|
|
83
|
+
condition: eq('\${{ parameters.COMMIT_ID_CHOICE }}', 'publish-all-artifacts-in-repo')
|
|
84
|
+
inputs:
|
|
85
|
+
azureSubscription: 'AZURE_SERVICE_CONNECTION_${envUpper}'
|
|
86
|
+
scriptType: 'bash'
|
|
87
|
+
scriptLocation: 'inlineScript'
|
|
88
|
+
inlineScript: |
|
|
89
|
+
npx apiops publish \\
|
|
90
|
+
--resource-group $(APIM_RESOURCE_GROUP_${envUpper}) \\
|
|
91
|
+
--service-name $(APIM_SERVICE_NAME_${envUpper}) \\
|
|
92
|
+
--source ${config.artifactDir} \\
|
|
93
|
+
--overrides configuration.${env}.yaml \\
|
|
94
|
+
--subscription-id $(AZURE_SUBSCRIPTION_ID)
|
|
67
95
|
`;
|
|
68
96
|
}).join('\n');
|
|
69
|
-
return `# Azure DevOps Pipeline: Run APIM Publisher
|
|
70
|
-
|
|
71
|
-
trigger:
|
|
72
|
-
branches:
|
|
73
|
-
include:
|
|
74
|
-
- main
|
|
75
|
-
paths:
|
|
76
|
-
include:
|
|
77
|
-
- '${config.artifactDir}/**'
|
|
78
|
-
- 'configuration.*.yaml'
|
|
79
|
-
|
|
80
|
-
pr: none
|
|
81
|
-
|
|
82
|
-
parameters:
|
|
83
|
-
- name: COMMIT_ID_CHOICE
|
|
84
|
-
type: string
|
|
85
|
-
displayName: '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"'
|
|
86
|
-
default: 'publish-artifacts-in-last-commit'
|
|
87
|
-
values:
|
|
88
|
-
- 'publish-artifacts-in-last-commit'
|
|
89
|
-
- 'publish-all-artifacts-in-repo'
|
|
90
|
-
- name: ENVIRONMENT
|
|
91
|
-
type: string
|
|
92
|
-
displayName: 'Choose which environment to publish to'
|
|
93
|
-
default: '
|
|
94
|
-
values:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
stages
|
|
99
|
-
${stages}
|
|
97
|
+
return `# Azure DevOps Pipeline: Run APIM Publisher
|
|
98
|
+
|
|
99
|
+
trigger:
|
|
100
|
+
branches:
|
|
101
|
+
include:
|
|
102
|
+
- main
|
|
103
|
+
paths:
|
|
104
|
+
include:
|
|
105
|
+
- '${config.artifactDir}/**'
|
|
106
|
+
- 'configuration.*.yaml'
|
|
107
|
+
|
|
108
|
+
pr: none
|
|
109
|
+
|
|
110
|
+
parameters:
|
|
111
|
+
- name: COMMIT_ID_CHOICE
|
|
112
|
+
type: string
|
|
113
|
+
displayName: '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"'
|
|
114
|
+
default: 'publish-artifacts-in-last-commit'
|
|
115
|
+
values:
|
|
116
|
+
- 'publish-artifacts-in-last-commit'
|
|
117
|
+
- 'publish-all-artifacts-in-repo'
|
|
118
|
+
- name: ENVIRONMENT
|
|
119
|
+
type: string
|
|
120
|
+
displayName: 'Choose which environment to publish to'
|
|
121
|
+
default: '${defaultEnvironment}'
|
|
122
|
+
values:
|
|
123
|
+
${envValues}
|
|
124
|
+
|
|
125
|
+
stages:
|
|
126
|
+
${stages}
|
|
100
127
|
`;
|
|
101
128
|
}
|
|
102
129
|
//# sourceMappingURL=publish-pipeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-pipeline.js","sourceRoot":"","sources":["../../../src/templates/azure-devops/publish-pipeline.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;;GAGG;AAOH,MAAM,UAAU,uBAAuB,CAAC,MAA6B;IACnE,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElF,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"publish-pipeline.js","sourceRoot":"","sources":["../../../src/templates/azure-devops/publish-pipeline.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;;GAGG;AAOH,MAAM,UAAU,uBAAuB,CAAC,MAA6B;IACnE,MAAM,kBAAkB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC;IAC3D,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElF,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QAC7C,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QAEnC,OAAO,oBAAoB,GAAG;6BACL,GAAG;qDACqB,GAAG;;oBAEpC,GAAG;;;gCAGS,GAAG;qBACd,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mEA6B2C,GAAG;;4CAE1B,GAAG;;;;;;;qDAOM,GAAG;sEACc,GAAG;8DACX,GAAG;;;6DAGJ,GAAG;;;2CAGrB,GAAG;;;iEAGmB,QAAQ;;;;;+DAKV,QAAQ;2DACZ,QAAQ;iCAClC,MAAM,CAAC,WAAW;kDACD,GAAG;;;;;2CAKV,GAAG;;;iEAGmB,QAAQ;;;;;+DAKV,QAAQ;2DACZ,QAAQ;iCAClC,MAAM,CAAC,WAAW;kDACD,GAAG;;CAEpD,CAAC;IACA,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;;;;;;;;WAQE,MAAM,CAAC,WAAW;;;;;;;;;;;;;;;;gBAgBb,kBAAkB;;EAEhC,SAAS;;;EAGT,MAAM;CACP,CAAC;AACF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* T047: Sample filter configuration template
|
|
3
|
-
* Generates a sample configuration.
|
|
3
|
+
* Generates a sample configuration.extractor.yaml file
|
|
4
4
|
*/
|
|
5
5
|
export declare function generateFilterConfig(): string;
|
|
6
6
|
//# sourceMappingURL=filter-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-config.d.ts","sourceRoot":"","sources":["../../../src/templates/configs/filter-config.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,wBAAgB,oBAAoB,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"filter-config.d.ts","sourceRoot":"","sources":["../../../src/templates/configs/filter-config.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,wBAAgB,oBAAoB,IAAI,MAAM,CA8G7C"}
|
|
@@ -2,52 +2,117 @@
|
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
/**
|
|
4
4
|
* T047: Sample filter configuration template
|
|
5
|
-
* Generates a sample configuration.
|
|
5
|
+
* Generates a sample configuration.extractor.yaml file
|
|
6
6
|
*/
|
|
7
7
|
export function generateFilterConfig() {
|
|
8
|
-
return `# APIM Extract Filter Configuration
|
|
9
|
-
# Customize this file to control which resources are extracted
|
|
10
|
-
|
|
11
|
-
# Extract only specific APIs by name
|
|
12
|
-
#
|
|
13
|
-
# - echo-api
|
|
14
|
-
# - petstore-api
|
|
15
|
-
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
# -
|
|
19
|
-
# -
|
|
20
|
-
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
# -
|
|
38
|
-
|
|
39
|
-
# Extract only specific
|
|
40
|
-
#
|
|
41
|
-
# -
|
|
42
|
-
# -
|
|
43
|
-
|
|
44
|
-
# Extract only specific
|
|
45
|
-
#
|
|
46
|
-
# -
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
#
|
|
50
|
-
#
|
|
8
|
+
return `# APIM Extract Filter Configuration
|
|
9
|
+
# Customize this file to control which resources are extracted
|
|
10
|
+
|
|
11
|
+
# Extract only specific APIs by name
|
|
12
|
+
# apis:
|
|
13
|
+
# - echo-api
|
|
14
|
+
# - petstore-api
|
|
15
|
+
|
|
16
|
+
# Advanced: Filter API sub-resources (operations, diagnostics, schemas, releases)
|
|
17
|
+
# apis:
|
|
18
|
+
# - echo-api # Include all sub-resources
|
|
19
|
+
# - petstore-api: # Control sub-resources
|
|
20
|
+
# operations:
|
|
21
|
+
# - get-pets
|
|
22
|
+
# - create-pet
|
|
23
|
+
# diagnostics:
|
|
24
|
+
# - applicationinsights
|
|
25
|
+
# schemas: [] # Exclude all schemas
|
|
26
|
+
# releases:
|
|
27
|
+
# - v1
|
|
28
|
+
|
|
29
|
+
# Extract only specific products
|
|
30
|
+
# products:
|
|
31
|
+
# - starter
|
|
32
|
+
# - unlimited
|
|
33
|
+
|
|
34
|
+
# Extract only specific backends
|
|
35
|
+
# backends:
|
|
36
|
+
# - backend-api
|
|
37
|
+
# - legacy-backend
|
|
38
|
+
|
|
39
|
+
# Extract only specific named values
|
|
40
|
+
# namedValues:
|
|
41
|
+
# - api-key
|
|
42
|
+
# - connection-string
|
|
43
|
+
|
|
44
|
+
# Extract only specific loggers
|
|
45
|
+
# loggers:
|
|
46
|
+
# - appinsights-logger
|
|
47
|
+
|
|
48
|
+
# Extract only specific diagnostics
|
|
49
|
+
# diagnostics:
|
|
50
|
+
# - applicationinsights
|
|
51
|
+
|
|
52
|
+
# Extract only specific tags
|
|
53
|
+
# tags:
|
|
54
|
+
# - production
|
|
55
|
+
# - external
|
|
56
|
+
|
|
57
|
+
# Extract only specific policy fragments
|
|
58
|
+
# policyFragments:
|
|
59
|
+
# - rate-limit-fragment
|
|
60
|
+
# - cors-fragment
|
|
61
|
+
|
|
62
|
+
# Extract only specific gateways
|
|
63
|
+
# gateways:
|
|
64
|
+
# - default
|
|
65
|
+
# - internal-gateway
|
|
66
|
+
|
|
67
|
+
# Extract only specific version sets
|
|
68
|
+
# versionSets:
|
|
69
|
+
# - payments-v1
|
|
70
|
+
|
|
71
|
+
# Extract only specific groups
|
|
72
|
+
# groups:
|
|
73
|
+
# - administrators
|
|
74
|
+
|
|
75
|
+
# Extract only specific subscriptions
|
|
76
|
+
# subscriptions:
|
|
77
|
+
# - starter-subscription
|
|
78
|
+
|
|
79
|
+
# Extract only specific schemas
|
|
80
|
+
# schemas:
|
|
81
|
+
# - pet-schema
|
|
82
|
+
|
|
83
|
+
# Filter service-level policies
|
|
84
|
+
# policies:
|
|
85
|
+
# - policy
|
|
86
|
+
|
|
87
|
+
# Extract only specific policy restrictions
|
|
88
|
+
# policyRestrictions:
|
|
89
|
+
# - global-policy-restriction
|
|
90
|
+
|
|
91
|
+
# Extract only specific documentations
|
|
92
|
+
# documentations:
|
|
93
|
+
# - getting-started
|
|
94
|
+
|
|
95
|
+
# Extract only specific workspaces
|
|
96
|
+
# workspaces:
|
|
97
|
+
# - dev-workspace
|
|
98
|
+
|
|
99
|
+
# Advanced: Filter workspace sub-resources
|
|
100
|
+
# workspaces:
|
|
101
|
+
# - team-workspace:
|
|
102
|
+
# apis:
|
|
103
|
+
# - team-api-1
|
|
104
|
+
# - team-api-2
|
|
105
|
+
# backends:
|
|
106
|
+
# - team-backend
|
|
107
|
+
# namedValues:
|
|
108
|
+
# - team-api-key
|
|
109
|
+
|
|
110
|
+
# Filter behavior:
|
|
111
|
+
# - Leave a section commented out to include ALL resources of that type
|
|
112
|
+
# - Set a section to an empty array ([]) to exclude ALL resources of that type
|
|
113
|
+
# Example:
|
|
114
|
+
# gateways: []
|
|
115
|
+
# subscriptions: []
|
|
51
116
|
`;
|
|
52
117
|
}
|
|
53
118
|
//# sourceMappingURL=filter-config.js.map
|