mulesoft-anypoint-cli-agent-fabric-plugin 1.3.0 → 1.3.1
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/README.md +77 -42
- package/bin/run +6 -0
- package/dist/commands/agent-network/project/agent-console.d.ts +16 -0
- package/dist/commands/agent-network/project/agent-console.js +175 -0
- package/dist/commands/agent-network/project/agent-console.js.map +1 -0
- package/dist/commands/agent-network/project/broker/create.d.ts +10 -0
- package/dist/commands/agent-network/project/broker/create.js +192 -0
- package/dist/commands/agent-network/project/broker/create.js.map +1 -0
- package/dist/commands/agent-network/project/create.d.ts +12 -0
- package/dist/commands/agent-network/project/create.js +48 -11
- package/dist/commands/agent-network/project/create.js.map +1 -1
- package/dist/commands/agent-network/project/deploy.d.ts +24 -14
- package/dist/commands/agent-network/project/deploy.js +228 -171
- package/dist/commands/agent-network/project/deploy.js.map +1 -1
- package/dist/commands/agent-network/project/export-logs.d.ts +11 -0
- package/dist/commands/agent-network/project/export-logs.js +38 -0
- package/dist/commands/agent-network/project/export-logs.js.map +1 -0
- package/dist/commands/agent-network/project/mcp/introspect.js +4 -1
- package/dist/commands/agent-network/project/mcp/introspect.js.map +1 -1
- package/dist/commands/agent-network/project/publish.js +1 -1
- package/dist/commands/agent-network/project/publish.js.map +1 -1
- package/dist/commands/agent-network/project/run-local.d.ts +85 -0
- package/dist/commands/agent-network/project/run-local.js +825 -0
- package/dist/commands/agent-network/project/run-local.js.map +1 -0
- package/dist/commands/agent-network/project/secrets.d.ts +21 -0
- package/dist/commands/agent-network/project/secrets.js +163 -0
- package/dist/commands/agent-network/project/secrets.js.map +1 -0
- package/dist/commands/agent-network/project/stop-local.d.ts +11 -0
- package/dist/commands/agent-network/project/stop-local.js +38 -0
- package/dist/commands/agent-network/project/stop-local.js.map +1 -0
- package/dist/commands/agent-network/project/undeploy.js +18 -13
- package/dist/commands/agent-network/project/undeploy.js.map +1 -1
- package/dist/commands/agent-network/project/unpublish.js +17 -9
- package/dist/commands/agent-network/project/unpublish.js.map +1 -1
- package/dist/commands/agent-network/setup/gateways.d.ts +3 -0
- package/dist/commands/agent-network/setup/gateways.js +66 -3
- package/dist/commands/agent-network/setup/gateways.js.map +1 -1
- package/dist/errors/error-factory.d.ts +73 -7
- package/dist/errors/error-factory.js +359 -18
- package/dist/errors/error-factory.js.map +1 -1
- package/dist/helpers/request-utils.d.ts +2 -1
- package/dist/helpers/request-utils.js +2 -2
- package/dist/helpers/request-utils.js.map +1 -1
- package/dist/helpers/utils.d.ts +1 -0
- package/dist/helpers/utils.js +6 -2
- package/dist/helpers/utils.js.map +1 -1
- package/dist/resources/agent-console.html +478 -0
- package/dist/resources/schemas/broker-deployment-settings.schema.json +46 -0
- package/dist/types/agent-network-v2.d.ts +4 -0
- package/dist/types/agent-network-v2.js.map +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/utils/builders/network-lock.d.ts +1 -0
- package/dist/utils/builders/network-lock.js +41 -6
- package/dist/utils/builders/network-lock.js.map +1 -1
- package/dist/utils/builders/policies-factory.d.ts +5 -1
- package/dist/utils/builders/policies-factory.js +10 -2
- package/dist/utils/builders/policies-factory.js.map +1 -1
- package/dist/utils/builders/project-builder-impl.d.ts +16 -2
- package/dist/utils/builders/project-builder-impl.js +29 -1
- package/dist/utils/builders/project-builder-impl.js.map +1 -1
- package/dist/utils/builders/project-builder.d.ts +29 -2
- package/dist/utils/builders/project-builder.js +10 -2
- package/dist/utils/builders/project-builder.js.map +1 -1
- package/dist/utils/builders/remote-space-resolver.d.ts +2 -2
- package/dist/utils/builders/remote-space-resolver.js +28 -12
- package/dist/utils/builders/remote-space-resolver.js.map +1 -1
- package/dist/utils/builders/space-serializer.js +3 -1
- package/dist/utils/builders/space-serializer.js.map +1 -1
- package/dist/utils/builders/stage-diagnostics.d.ts +2 -0
- package/dist/utils/builders/stage-diagnostics.js +27 -0
- package/dist/utils/builders/stage-diagnostics.js.map +1 -0
- package/dist/utils/builders/tooling-metadata.d.ts +4 -4
- package/dist/utils/builders/tooling-metadata.js +27 -15
- package/dist/utils/builders/tooling-metadata.js.map +1 -1
- package/dist/utils/builders/v1/network-builder.js +2 -1
- package/dist/utils/builders/v1/network-builder.js.map +1 -1
- package/dist/utils/builders/v2/broker-builder.d.ts +1 -0
- package/dist/utils/builders/v2/broker-builder.js +69 -4
- package/dist/utils/builders/v2/broker-builder.js.map +1 -1
- package/dist/utils/builders/v2/network-builder.js +1 -1
- package/dist/utils/builders/v2/network-builder.js.map +1 -1
- package/dist/utils/constants.d.ts +3 -0
- package/dist/utils/constants.js +8 -3
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/deployment-settings.d.ts +13 -0
- package/dist/utils/deployment-settings.js +97 -0
- package/dist/utils/deployment-settings.js.map +1 -0
- package/dist/utils/facets/abstract-facet.d.ts +1 -0
- package/dist/utils/facets/abstract-facet.js +3 -0
- package/dist/utils/facets/abstract-facet.js.map +1 -1
- package/dist/utils/facets/agent-graph-facet.d.ts +14 -1
- package/dist/utils/facets/agent-graph-facet.js +126 -49
- package/dist/utils/facets/agent-graph-facet.js.map +1 -1
- package/dist/utils/facets/api-instance-facet.d.ts +36 -1
- package/dist/utils/facets/api-instance-facet.js +196 -5
- package/dist/utils/facets/api-instance-facet.js.map +1 -1
- package/dist/utils/facets/connection-facet.d.ts +8 -0
- package/dist/utils/facets/connection-facet.js +65 -1
- package/dist/utils/facets/connection-facet.js.map +1 -1
- package/dist/utils/facets/deployment-helpers.d.ts +18 -1
- package/dist/utils/facets/deployment-helpers.js +53 -0
- package/dist/utils/facets/deployment-helpers.js.map +1 -1
- package/dist/utils/facets/deployment-logs.js +1 -0
- package/dist/utils/facets/deployment-logs.js.map +1 -1
- package/dist/utils/facets/deployment-runner.js +5 -0
- package/dist/utils/facets/deployment-runner.js.map +1 -1
- package/dist/utils/facets/facets.d.ts +2 -0
- package/dist/utils/facets/facets.js +31 -14
- package/dist/utils/facets/facets.js.map +1 -1
- package/dist/utils/facets/mule-application-facet.d.ts +1 -1
- package/dist/utils/facets/mule-application-facet.js +25 -21
- package/dist/utils/facets/mule-application-facet.js.map +1 -1
- package/dist/utils/facets/publication-metadata-patcher.js +1 -1
- package/dist/utils/facets/publication-metadata-patcher.js.map +1 -1
- package/dist/utils/facets/publication-rank.js +1 -1
- package/dist/utils/facets/publication-rank.js.map +1 -1
- package/dist/utils/files.d.ts +25 -0
- package/dist/utils/files.js +62 -0
- package/dist/utils/files.js.map +1 -1
- package/dist/utils/gateway.d.ts +6 -2
- package/dist/utils/gateway.js +37 -33
- package/dist/utils/gateway.js.map +1 -1
- package/dist/utils/keychain.d.ts +56 -0
- package/dist/utils/keychain.js +488 -0
- package/dist/utils/keychain.js.map +1 -0
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/logger.js +3 -0
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/mcp/mcp-metadata-mapper.d.ts +8 -0
- package/dist/utils/mcp/mcp-metadata-mapper.js +7 -1
- package/dist/utils/mcp/mcp-metadata-mapper.js.map +1 -1
- package/dist/utils/mcp/project-registrar.js +2 -26
- package/dist/utils/mcp/project-registrar.js.map +1 -1
- package/dist/utils/naming.d.ts +13 -0
- package/dist/utils/naming.js +36 -4
- package/dist/utils/naming.js.map +1 -1
- package/dist/utils/request-executor.d.ts +5 -5
- package/dist/utils/run-local/agent-console-proxy.d.ts +56 -0
- package/dist/utils/run-local/agent-console-proxy.js +182 -0
- package/dist/utils/run-local/agent-console-proxy.js.map +1 -0
- package/dist/utils/run-local/broker-recreate-selector.d.ts +31 -0
- package/dist/utils/run-local/broker-recreate-selector.js +82 -0
- package/dist/utils/run-local/broker-recreate-selector.js.map +1 -0
- package/dist/utils/run-local/build-status.d.ts +73 -0
- package/dist/utils/run-local/build-status.js +210 -0
- package/dist/utils/run-local/build-status.js.map +1 -0
- package/dist/utils/run-local/constants.d.ts +28 -0
- package/dist/utils/run-local/constants.js +36 -0
- package/dist/utils/run-local/constants.js.map +1 -0
- package/dist/utils/run-local/crd-files.d.ts +2 -0
- package/dist/utils/run-local/crd-files.js +24 -0
- package/dist/utils/run-local/crd-files.js.map +1 -0
- package/dist/utils/run-local/index.d.ts +9 -0
- package/dist/utils/run-local/index.js +42 -0
- package/dist/utils/run-local/index.js.map +1 -0
- package/dist/utils/run-local/local-a2a-upstream.d.ts +9 -0
- package/dist/utils/run-local/local-a2a-upstream.js +55 -0
- package/dist/utils/run-local/local-a2a-upstream.js.map +1 -0
- package/dist/utils/run-local/local-deploy-descriptor.d.ts +36 -0
- package/dist/utils/run-local/local-deploy-descriptor.js +70 -0
- package/dist/utils/run-local/local-deploy-descriptor.js.map +1 -0
- package/dist/utils/run-local/local-run-manager.d.ts +51 -0
- package/dist/utils/run-local/local-run-manager.js +218 -0
- package/dist/utils/run-local/local-run-manager.js.map +1 -0
- package/dist/utils/run-local/policy-resolver.d.ts +69 -0
- package/dist/utils/run-local/policy-resolver.js +461 -0
- package/dist/utils/run-local/policy-resolver.js.map +1 -0
- package/dist/utils/run-local/runtime-environment-manager.d.ts +89 -0
- package/dist/utils/run-local/runtime-environment-manager.js +313 -0
- package/dist/utils/run-local/runtime-environment-manager.js.map +1 -0
- package/dist/utils/run-local/secrets-manager.d.ts +66 -0
- package/dist/utils/run-local/secrets-manager.js +181 -0
- package/dist/utils/run-local/secrets-manager.js.map +1 -0
- package/dist/utils/uris.js +4 -0
- package/dist/utils/uris.js.map +1 -1
- package/dist/utils/variables.d.ts +17 -4
- package/dist/utils/variables.js +52 -7
- package/dist/utils/variables.js.map +1 -1
- package/package.json +4 -2
- package/scripts/check-gus-ticket-format.sh +29 -0
- package/scripts/resolve-version.sh +161 -52
- package/scripts/resolve-version.test.sh +207 -20
- package/templates/agent-network/exchange.json.template +1 -0
- package/templates/agentic-network/brokers/broker1.agent.template +3 -3
- package/templates/agentic-network/exchange.json.template +1 -0
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import { NestedVariables, Variables } from '../types/types';
|
|
2
|
-
import { StageContext } from './builders/project-builder';
|
|
2
|
+
import { SpaceVariable, StageContext } from './builders/project-builder';
|
|
3
3
|
import { AgentNetwork } from '../types/agent-network';
|
|
4
4
|
import Properties = AgentNetwork.Properties;
|
|
5
5
|
export declare const VariablesHelper: {
|
|
6
6
|
flattenVariables(variables: NestedVariables, prefix?: string): Variables;
|
|
7
|
+
/** Whether a declared variable holds a secret; an omitted `secret` flag counts as secret (only `secret: false` opts out). */
|
|
8
|
+
isSecret(varDef: {
|
|
9
|
+
secret?: boolean;
|
|
10
|
+
}): boolean;
|
|
7
11
|
propertiesArrayToObject(properties: string[]): Record<string, string>;
|
|
8
12
|
checkIfPromptsNeeded(variables: any, defaultProp: Record<string, string>, prefix?: string): boolean;
|
|
9
13
|
sanitizeVariables(variables: NestedVariables, prefix?: string): NestedVariables;
|
|
10
14
|
promptForVariables(variables: Variables, defaultProp: Record<string, string>, prefix?: string): Promise<Properties>;
|
|
11
|
-
/**
|
|
12
|
-
* Recursively traverses all values in an object or array and applies replacePlaceholder to each simple value (string, number, boolean).
|
|
13
|
-
*/
|
|
14
15
|
recursivelyReplacePlaceholders<T>(obj: T, collectedVariables: Record<string, string>): T;
|
|
15
16
|
getAllVariablesFromContext(context: StageContext): Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Every declared secret is forced to an inert plaintext token so no real secret is ever written into
|
|
19
|
+
* an on-disk CRD or env file. Non-secret vars (including facet-injected values like deployment URLs,
|
|
20
|
+
* which are not in space.variables) keep their real values. The token is a bare string (not `${...}`)
|
|
21
|
+
* so Flex's own conf.d interpolation never tries to resolve it; a policy needing the real secret at
|
|
22
|
+
* request time reads the `${SECURE_*}` env var instead.
|
|
23
|
+
*/
|
|
24
|
+
buildSecretRedactionMap(spaceVariables: {
|
|
25
|
+
[key: string]: SpaceVariable;
|
|
26
|
+
} | undefined, resolvedVariables: Record<string, string>): Record<string, string>;
|
|
27
|
+
/** Traversal mirrors recursivelyReplacePlaceholders so the two agree on what counts as a placeholder. */
|
|
28
|
+
collectPlaceholderNames(obj: unknown, sink: Set<string>): Set<string>;
|
|
16
29
|
};
|
package/dist/utils/variables.js
CHANGED
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
exports.VariablesHelper = void 0;
|
|
9
9
|
const logger_1 = require("./logger");
|
|
10
10
|
const error_factory_1 = require("../errors/error-factory");
|
|
11
|
+
const constants_1 = require("./constants");
|
|
11
12
|
exports.VariablesHelper = {
|
|
12
13
|
flattenVariables(variables, prefix) {
|
|
13
14
|
let collectedVariables = {};
|
|
@@ -25,11 +26,17 @@ exports.VariablesHelper = {
|
|
|
25
26
|
}
|
|
26
27
|
return collectedVariables;
|
|
27
28
|
},
|
|
29
|
+
/** Whether a declared variable holds a secret; an omitted `secret` flag counts as secret (only `secret: false` opts out). */
|
|
30
|
+
isSecret(varDef) {
|
|
31
|
+
return varDef.secret !== false;
|
|
32
|
+
},
|
|
28
33
|
propertiesArrayToObject(properties) {
|
|
29
34
|
const result = {};
|
|
30
35
|
for (const entry of properties) {
|
|
31
36
|
const [name, ...rest] = entry.split(':');
|
|
32
|
-
|
|
37
|
+
// Trim like the interactive prompt path: a value piped in from a shell/env substitution can
|
|
38
|
+
// carry a trailing newline that would otherwise be baked verbatim into a secret.
|
|
39
|
+
result[name] = rest.join(':').trim(); // Handles values with colons
|
|
33
40
|
}
|
|
34
41
|
return result;
|
|
35
42
|
},
|
|
@@ -52,7 +59,7 @@ exports.VariablesHelper = {
|
|
|
52
59
|
for (const [key, value] of Object.entries(variables)) {
|
|
53
60
|
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
54
61
|
if (typeof value === 'object' && value !== null && 'description' in value) {
|
|
55
|
-
const isSecured = value
|
|
62
|
+
const isSecured = this.isSecret(value);
|
|
56
63
|
if (isSecured && value.default) {
|
|
57
64
|
sanitized[key] = { description: value.description, secret: value.secret };
|
|
58
65
|
}
|
|
@@ -72,7 +79,7 @@ exports.VariablesHelper = {
|
|
|
72
79
|
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
73
80
|
if (typeof value === 'object' && value !== null && 'description' in value) {
|
|
74
81
|
const varValue = value;
|
|
75
|
-
const isSecured =
|
|
82
|
+
const isSecured = this.isSecret(varValue);
|
|
76
83
|
const propertyGroup = isSecured ? collectedVariables.securedProperties : collectedVariables.properties;
|
|
77
84
|
if (defaultProp[fullKey]) {
|
|
78
85
|
propertyGroup[fullKey] = defaultProp[fullKey];
|
|
@@ -83,7 +90,7 @@ exports.VariablesHelper = {
|
|
|
83
90
|
default: varValue.default,
|
|
84
91
|
type: isSecured ? 'mask' : 'normal',
|
|
85
92
|
});
|
|
86
|
-
propertyGroup[fullKey] = userInput || varValue.default || '';
|
|
93
|
+
propertyGroup[fullKey] = (userInput === null || userInput === void 0 ? void 0 : userInput.trim()) || varValue.default || '';
|
|
87
94
|
}
|
|
88
95
|
}
|
|
89
96
|
else if (typeof value === 'object' && value !== null) {
|
|
@@ -102,9 +109,6 @@ exports.VariablesHelper = {
|
|
|
102
109
|
}
|
|
103
110
|
return collectedVariables;
|
|
104
111
|
},
|
|
105
|
-
/**
|
|
106
|
-
* Recursively traverses all values in an object or array and applies replacePlaceholder to each simple value (string, number, boolean).
|
|
107
|
-
*/
|
|
108
112
|
recursivelyReplacePlaceholders(obj, collectedVariables) {
|
|
109
113
|
if (Array.isArray(obj)) {
|
|
110
114
|
return obj.map(item => this.recursivelyReplacePlaceholders(item, collectedVariables));
|
|
@@ -128,6 +132,47 @@ exports.VariablesHelper = {
|
|
|
128
132
|
...context.stageResultRegistry.getVariables(),
|
|
129
133
|
};
|
|
130
134
|
},
|
|
135
|
+
/**
|
|
136
|
+
* Every declared secret is forced to an inert plaintext token so no real secret is ever written into
|
|
137
|
+
* an on-disk CRD or env file. Non-secret vars (including facet-injected values like deployment URLs,
|
|
138
|
+
* which are not in space.variables) keep their real values. The token is a bare string (not `${...}`)
|
|
139
|
+
* so Flex's own conf.d interpolation never tries to resolve it; a policy needing the real secret at
|
|
140
|
+
* request time reads the `${SECURE_*}` env var instead.
|
|
141
|
+
*/
|
|
142
|
+
buildSecretRedactionMap(spaceVariables, resolvedVariables) {
|
|
143
|
+
const redacted = { ...resolvedVariables };
|
|
144
|
+
const flatVars = this.flattenVariables(spaceVariables !== null && spaceVariables !== void 0 ? spaceVariables : {});
|
|
145
|
+
for (const [key, varDef] of Object.entries(flatVars)) {
|
|
146
|
+
if (!this.isSecret(varDef)) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
redacted[key] = constants_1.LOCAL_INERT_SECRET_PLACEHOLDER;
|
|
150
|
+
}
|
|
151
|
+
return redacted;
|
|
152
|
+
},
|
|
153
|
+
/** Traversal mirrors recursivelyReplacePlaceholders so the two agree on what counts as a placeholder. */
|
|
154
|
+
collectPlaceholderNames(obj, sink) {
|
|
155
|
+
if (Array.isArray(obj)) {
|
|
156
|
+
for (const item of obj) {
|
|
157
|
+
this.collectPlaceholderNames(item, sink);
|
|
158
|
+
}
|
|
159
|
+
return sink;
|
|
160
|
+
}
|
|
161
|
+
if (obj !== null && typeof obj === 'object') {
|
|
162
|
+
for (const value of Object.values(obj)) {
|
|
163
|
+
this.collectPlaceholderNames(value, sink);
|
|
164
|
+
}
|
|
165
|
+
return sink;
|
|
166
|
+
}
|
|
167
|
+
if (typeof obj !== 'string') {
|
|
168
|
+
return sink;
|
|
169
|
+
}
|
|
170
|
+
const matches = obj.matchAll(/\${([^}]+)}/g);
|
|
171
|
+
for (const match of matches) {
|
|
172
|
+
sink.add(match[1]);
|
|
173
|
+
}
|
|
174
|
+
return sink;
|
|
175
|
+
},
|
|
131
176
|
};
|
|
132
177
|
function replacePlaceholders(input, allVariables) {
|
|
133
178
|
return input.replace(/\${([^}]+)}/g, (_, varName) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.js","sourceRoot":"","sources":["../../src/utils/variables.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,qCAA4B;AAC5B,2DAAoD;
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C,CAAA;QAC9B,CAAC;QAED,MAAM,4BAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mulesoft-anypoint-cli-agent-fabric-plugin",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Agent Fabric CLI Plugin",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"files": [
|
|
@@ -18,14 +18,16 @@
|
|
|
18
18
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
19
19
|
"@oclif/core": "1.26.2",
|
|
20
20
|
"@oclif/plugin-version": "1.0.4",
|
|
21
|
-
"@sf-agentscript/agentfabric-dialect": "1.
|
|
21
|
+
"@sf-agentscript/agentfabric-dialect": "1.2.46",
|
|
22
22
|
"ajv": "^8.17.1",
|
|
23
23
|
"ajv-formats": "^3.0.1",
|
|
24
24
|
"ajv-keywords": "^5.1.0",
|
|
25
25
|
"anypoint-cli-command-lib": "1.6.14",
|
|
26
26
|
"anypoint-cli-exchange-library": "0.1.13",
|
|
27
|
+
"anypoint-pdk-plugin": "^1.10.1",
|
|
27
28
|
"anypoint-project-builder": "2.4.23",
|
|
28
29
|
"fs-extra": "^11.3.0",
|
|
30
|
+
"js-yaml": "^3.14.1",
|
|
29
31
|
"jszip": "^3.10.1",
|
|
30
32
|
"junit-report-builder": "^3.2.1",
|
|
31
33
|
"semver": "^7.7.2",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# Warns (never blocks) when a commit message does not start with a GUS
|
|
4
|
+
# ticket at-mention in the `@W-XXXXXXX: <message>` format required by
|
|
5
|
+
# SFCI's mandatory-gus-wi-and-changelist compliance check.
|
|
6
|
+
#
|
|
7
|
+
# Invoked by pre-commit as a commit-msg hook: $1 is the path to the file
|
|
8
|
+
# containing the commit message being authored.
|
|
9
|
+
|
|
10
|
+
set -euo pipefail
|
|
11
|
+
|
|
12
|
+
COMMIT_MSG_FILE="$1"
|
|
13
|
+
FIRST_LINE="$(head -n1 "$COMMIT_MSG_FILE")"
|
|
14
|
+
|
|
15
|
+
# Accepts a leading `@W-XXXXXXX:` at message start, or immediately after a
|
|
16
|
+
# Conventional Commits type (fix:/feat:) as documented for semantic-release
|
|
17
|
+
# repos, e.g. `fix: @W-23849126: comment`.
|
|
18
|
+
if [[ ! "$FIRST_LINE" =~ ^@W-[0-9]+: ]] && [[ ! "$FIRST_LINE" =~ ^(fix|feat):[[:space:]]*@W-[0-9]+: ]]; then
|
|
19
|
+
cat >&2 <<EOF
|
|
20
|
+
WARNING: commit message does not start with a GUS ticket at-mention.
|
|
21
|
+
Expected: @W-XXXXXXX: <message> (or fix:/feat: @W-XXXXXXX: <message>)
|
|
22
|
+
Got: ${FIRST_LINE}
|
|
23
|
+
This is a warning only — the commit will proceed. SFCI's
|
|
24
|
+
mandatory-gus-wi-and-changelist check requires the @W-XXXXXXX at-mention
|
|
25
|
+
in the last commit message or PR title.
|
|
26
|
+
EOF
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
exit 0
|
|
@@ -7,37 +7,104 @@
|
|
|
7
7
|
# - master -> clean release whose patch is
|
|
8
8
|
# (highest published MAJOR.MINOR.*
|
|
9
9
|
# patch + 1), e.g. 1.2.7
|
|
10
|
-
# - release/*
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
# 1.2.
|
|
10
|
+
# - release/* / test/* / develop / feature / -> pre-release MAJOR.MINOR.PATCH-branch,
|
|
11
|
+
# any other production branch where PATCH has its OWN counter per
|
|
12
|
+
# branch (the full branch path,
|
|
13
|
+
# slashes -> dashes, so different
|
|
14
|
+
# branch types never collide) and
|
|
15
|
+
# increments by 1 on each build of
|
|
16
|
+
# that same branch, starting at
|
|
17
|
+
# package.json's current patch:
|
|
18
|
+
# test/develop -> 1.2.25-test-develop,
|
|
19
|
+
# then 1.2.26-test-develop, ...
|
|
19
20
|
#
|
|
20
|
-
# master
|
|
21
|
-
#
|
|
22
|
-
# never collides with an existing one
|
|
23
|
-
#
|
|
21
|
+
# Both master and per-branch pre-releases derive the patch from the registry
|
|
22
|
+
# (not BUILD_NUMBER, which is not used anywhere in this script) so every
|
|
23
|
+
# build publishes a fresh version that never collides with an existing one
|
|
24
|
+
# and stays monotonic even across CI-counter resets.
|
|
24
25
|
|
|
25
26
|
set -euo pipefail
|
|
26
27
|
|
|
28
|
+
is_git_repo() {
|
|
29
|
+
git rev-parse --git-dir >/dev/null 2>&1
|
|
30
|
+
}
|
|
31
|
+
|
|
27
32
|
# Published versions of this package, newline/JSON as npm emits. Tests inject
|
|
28
33
|
# RESOLVE_PUBLISHED_VERSIONS_JSON to stay offline; CI queries the registry.
|
|
34
|
+
#
|
|
35
|
+
# A registry error is NOT treated the same as "genuinely nothing published":
|
|
36
|
+
# npm view exits non-zero both on a real 404 (new/unpublished package, a
|
|
37
|
+
# legitimate empty result) and on a transient failure (network/auth/registry
|
|
38
|
+
# down). Silently falling back to `[]` on the latter would make next_patch /
|
|
39
|
+
# next_patch_for_branch re-derive the floor version even though it was
|
|
40
|
+
# already published, and npm-publish would then fail on a duplicate. Only
|
|
41
|
+
# E404 is treated as empty; anything else aborts the build.
|
|
42
|
+
#
|
|
43
|
+
# stdout and stderr are captured SEPARATELY (stderr to a temp file, never
|
|
44
|
+
# merged via 2>&1) -- npm (confirmed: npm@10.8.3) writes informational
|
|
45
|
+
# banners like "npm info using npm@10.8.3" to stderr even on a SUCCESSFUL
|
|
46
|
+
# call. Merging them into stdout corrupted the JSON payload with that banner
|
|
47
|
+
# line prepended, breaking JSON.parse on every single branch build in
|
|
48
|
+
# production. stderr is inspected only to classify a FAILURE (E404 or not);
|
|
49
|
+
# on success only the clean stdout is ever used.
|
|
29
50
|
published_versions() {
|
|
30
51
|
if [[ -n "${RESOLVE_PUBLISHED_VERSIONS_JSON:-}" ]]; then
|
|
31
52
|
printf '%s' "$RESOLVE_PUBLISHED_VERSIONS_JSON"
|
|
32
53
|
return
|
|
33
54
|
fi
|
|
34
|
-
local name
|
|
55
|
+
local name out errfile
|
|
35
56
|
name="$(node -p "require('./package.json').name")"
|
|
36
|
-
|
|
57
|
+
errfile="$(mktemp)"
|
|
58
|
+
# Guarantees errfile cleanup on every normal return path, including any
|
|
59
|
+
# future one added here -- exit 1 below bypasses RETURN traps (it unwinds
|
|
60
|
+
# the whole process, not just this function), so that path still cleans up
|
|
61
|
+
# explicitly.
|
|
62
|
+
trap 'rm -f "$errfile"' RETURN
|
|
63
|
+
if out="$(npm view "$name" versions --json 2>"$errfile")"; then
|
|
64
|
+
printf '%s' "$out"
|
|
65
|
+
elif grep -q "E404" "$errfile"; then
|
|
66
|
+
echo '[]'
|
|
67
|
+
else
|
|
68
|
+
echo "ERROR: npm view failed for ${name} and it's not a 404 (registry unreachable/auth failure?) — refusing to fall back to an empty version list, which could re-derive an already-published version:" >&2
|
|
69
|
+
cat "$errfile" >&2
|
|
70
|
+
rm -f "$errfile"
|
|
71
|
+
exit 1
|
|
72
|
+
fi
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
# Every git tag in this checkout, as a JSON array. This script tags every
|
|
76
|
+
# resolved version on the current commit (see the bottom of this file) and
|
|
77
|
+
# the pipeline pushes those tags (git-push-tags), so on a repeat build of
|
|
78
|
+
# the same branch they're already fetched from origin -- confirmed in
|
|
79
|
+
# production (a build's "could not create tag, already exists" warning
|
|
80
|
+
# proved the PRIOR build's tag was right there in the same checkout).
|
|
81
|
+
#
|
|
82
|
+
# npm view, in contrast, goes through a Nexus proxy/group repo whose
|
|
83
|
+
# metadata can lag behind a just-published version by more than the gap
|
|
84
|
+
# between two builds -- confirmed in production: a branch's 2nd build
|
|
85
|
+
# re-derived and re-published the exact same version as its 1st, 28 minutes
|
|
86
|
+
# earlier, because published_versions() alone didn't see it. Merging git
|
|
87
|
+
# tags into the candidate list (next_patch/next_patch_for_branch already
|
|
88
|
+
# filter by regex, so unrelated tags are harmlessly ignored) closes that
|
|
89
|
+
# gap without giving up the registry as the primary source of truth.
|
|
90
|
+
git_tag_versions() {
|
|
91
|
+
if is_git_repo; then
|
|
92
|
+
git tag -l | node -e '
|
|
93
|
+
const lines = require("fs").readFileSync(0, "utf8").split("\n").filter(Boolean);
|
|
94
|
+
process.stdout.write(JSON.stringify(lines));
|
|
95
|
+
'
|
|
96
|
+
else
|
|
97
|
+
echo '[]'
|
|
98
|
+
fi
|
|
37
99
|
}
|
|
38
100
|
|
|
39
101
|
# Next clean patch for MAJOR.MINOR: max patch of any published MAJOR.MINOR.*
|
|
40
|
-
# (clean or pre-release) + 1, or 0 if none exists.
|
|
102
|
+
# (clean or pre-release) + 1, or 0 if none exists. Takes the published-versions
|
|
103
|
+
# JSON as $2 rather than calling published_versions() itself -- a failing
|
|
104
|
+
# command substitution nested as another command's ARGUMENT does not trip
|
|
105
|
+
# `set -e` in bash (only the outer command's own exit status is checked), so
|
|
106
|
+
# published_versions()'s hard-failure path must be called from a plain
|
|
107
|
+
# top-level assignment to actually abort the build.
|
|
41
108
|
next_patch() {
|
|
42
109
|
node -e '
|
|
43
110
|
const mm = process.argv[1];
|
|
@@ -47,7 +114,35 @@ next_patch() {
|
|
|
47
114
|
const patches = list.map(v => (String(v).match(re) || [])[1])
|
|
48
115
|
.filter(x => x != null).map(Number);
|
|
49
116
|
process.stdout.write(String(patches.length ? Math.max(...patches) + 1 : 0));
|
|
50
|
-
' "$1" "$
|
|
117
|
+
' "$1" "$2"
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
# Next patch for a branch's own pre-release line: max patch already published
|
|
121
|
+
# as MAJOR.MINOR.PATCH-BRANCH + 1, or the base version's own patch (floor) if
|
|
122
|
+
# nothing has been published for this branch yet -- each branch's counter
|
|
123
|
+
# restarts from package.json's current patch, independent of every other
|
|
124
|
+
# branch and of master's counter.
|
|
125
|
+
#
|
|
126
|
+
# Also matches the legacy MAJOR.MINOR.PATCH-BRANCH.BUILD shape (trailing
|
|
127
|
+
# `.digits`) published by the pre-migration BUILD_NUMBER scheme, purely to
|
|
128
|
+
# fold its PATCH into the max -- never written going forward. Without this,
|
|
129
|
+
# a branch's first post-migration build would be invisible to the ones it
|
|
130
|
+
# already published and reset to the floor, which is a semver *regression*
|
|
131
|
+
# (fewer pre-release fields = lower precedence at equal PATCH) rather than a
|
|
132
|
+
# fresh build.
|
|
133
|
+
next_patch_for_branch() {
|
|
134
|
+
node -e '
|
|
135
|
+
const mm = process.argv[1];
|
|
136
|
+
const branch = process.argv[2];
|
|
137
|
+
const floor = parseInt(process.argv[3], 10);
|
|
138
|
+
let list; try { list = JSON.parse(process.argv[4] || "[]"); } catch { list = []; }
|
|
139
|
+
if (!Array.isArray(list)) list = list ? [list] : [];
|
|
140
|
+
const escBranch = branch.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
141
|
+
const re = new RegExp("^" + mm.replace(/\./g, "\\.") + "\\.(\\d+)-" + escBranch + "(?:\\.\\d+)?$");
|
|
142
|
+
const patches = list.map(v => (String(v).match(re) || [])[1])
|
|
143
|
+
.filter(x => x != null).map(Number);
|
|
144
|
+
process.stdout.write(String(patches.length ? Math.max(...patches) + 1 : floor));
|
|
145
|
+
' "$1" "$2" "$3" "$4"
|
|
51
146
|
}
|
|
52
147
|
|
|
53
148
|
# Base version from package.json
|
|
@@ -61,52 +156,66 @@ fi
|
|
|
61
156
|
# Branch builds expose BRANCH_NAME (GIT_BRANCH is an alias fallback).
|
|
62
157
|
RAW_BRANCH="${BRANCH_NAME:-${GIT_BRANCH:-}}"
|
|
63
158
|
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
|
|
73
|
-
|
|
159
|
+
# Normalize into a valid semver/npm identifier: drop only the `origin/`
|
|
160
|
+
# remote prefix, lowercase, turn every `/` path separator into `-` (keeping
|
|
161
|
+
# every segment -- e.g. release/1.3 -> release-1.3, test/release/foo ->
|
|
162
|
+
# test-release-foo -- so two branches of different types that share a tail,
|
|
163
|
+
# e.g. release/1.3 and test/1.3, never collide on one prerelease lineage;
|
|
164
|
+
# confirmed in production, release/1.2.25-2 and test/1.2.25-2 both published
|
|
165
|
+
# the exact same version before this fix). Everything else in the branch
|
|
166
|
+
# name -- including `.` -- is kept AS-IS rather than collapsed to `-`, so
|
|
167
|
+
# e.g. release/1.2.25-2 keeps its literal dots: release-1.2.25-2. Only
|
|
168
|
+
# characters npm/semver can't use in a pre-release identifier at all
|
|
169
|
+
# (anything other than [A-Za-z0-9.-]) get collapsed to `-`.
|
|
170
|
+
BRANCH="$(echo "$RAW_BRANCH" \
|
|
171
|
+
| sed -e 's#^origin/##' \
|
|
74
172
|
| tr '[:upper:]' '[:lower:]' \
|
|
75
|
-
| sed -e 's/[^a-z0-9]\{1,\}/-/g' -e 's
|
|
173
|
+
| sed -e 's#/#-#g' -e 's/[^a-z0-9.-]\{1,\}/-/g' -e 's/^[-.]*//' -e 's/[-.]*$//')"
|
|
76
174
|
|
|
77
|
-
|
|
175
|
+
# A branch name that's purely digits with no other segment (e.g. bare branch
|
|
176
|
+
# `007`, no slash) would be an invalid semver pre-release identifier:
|
|
177
|
+
# numeric-only identifiers must not have a leading zero. Prefix it so it's
|
|
178
|
+
# always alphanumeric.
|
|
179
|
+
if [[ "$BRANCH" =~ ^[0-9]+$ ]]; then
|
|
180
|
+
BRANCH="b${BRANCH}"
|
|
181
|
+
fi
|
|
78
182
|
|
|
79
183
|
if [[ -z "$BRANCH" ]]; then
|
|
80
184
|
echo "ERROR: could not resolve branch name (BRANCH_NAME/GIT_BRANCH all empty)" >&2
|
|
81
185
|
exit 1
|
|
82
|
-
|
|
186
|
+
fi
|
|
187
|
+
|
|
188
|
+
# Plain top-level assignment -- unlike passing $(published_versions) directly
|
|
189
|
+
# as another command's argument, this DOES trip `set -e` if it exits 1.
|
|
190
|
+
PUBLISHED_VERSIONS_JSON="$(published_versions)"
|
|
191
|
+
GIT_TAG_VERSIONS_JSON="$(git_tag_versions)"
|
|
192
|
+
|
|
193
|
+
# Merge both candidate lists so a version either source has seen counts --
|
|
194
|
+
# next_patch/next_patch_for_branch's own regex already filters out anything
|
|
195
|
+
# that isn't a match for the exact MAJOR.MINOR (and branch), so tags/versions
|
|
196
|
+
# unrelated to this build are harmlessly ignored.
|
|
197
|
+
COMBINED_VERSIONS_JSON="$(node -e '
|
|
198
|
+
const a = JSON.parse(process.argv[1] || "[]");
|
|
199
|
+
const b = JSON.parse(process.argv[2] || "[]");
|
|
200
|
+
process.stdout.write(JSON.stringify([...(Array.isArray(a) ? a : []), ...(Array.isArray(b) ? b : [])]));
|
|
201
|
+
' "$PUBLISHED_VERSIONS_JSON" "$GIT_TAG_VERSIONS_JSON")"
|
|
202
|
+
|
|
203
|
+
if [[ "$BRANCH" == "master" ]]; then
|
|
83
204
|
# Clean release: keep major.minor from package.json, derive patch from the
|
|
84
205
|
# registry so it never collides and always supersedes prior 1.2.x artifacts.
|
|
85
206
|
MAJOR_MINOR="${BASE%.*}"
|
|
86
|
-
VERSION="${MAJOR_MINOR}.$(next_patch "$MAJOR_MINOR")"
|
|
87
|
-
elif [[ "$BRANCH_PATH" == release/* ]]; then
|
|
88
|
-
# Clean release from a maintenance line. If the branch encodes a MAJOR.MINOR
|
|
89
|
-
# (e.g. release/1.3 or release/1.3.x), pin to it so the line stays on its own
|
|
90
|
-
# major.minor; otherwise fall back to package.json's major.minor. Patch comes
|
|
91
|
-
# from the registry, same monotonic rule as master.
|
|
92
|
-
REL="${BRANCH_PATH#release/}"
|
|
93
|
-
# Accept an optional `v` prefix and either MAJOR.MINOR or a bare MAJOR
|
|
94
|
-
# (release/v1.3, release/1.3.x, release/1 -> 1.0). Anything else (e.g.
|
|
95
|
-
# release/hardening) falls back to package.json's major.minor.
|
|
96
|
-
if [[ "$REL" =~ ^v?([0-9]+)\.([0-9]+) ]]; then
|
|
97
|
-
MAJOR_MINOR="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
|
|
98
|
-
elif [[ "$REL" =~ ^v?([0-9]+)([^0-9]|$) ]]; then
|
|
99
|
-
MAJOR_MINOR="${BASH_REMATCH[1]}.0"
|
|
100
|
-
else
|
|
101
|
-
MAJOR_MINOR="${BASE%.*}"
|
|
102
|
-
fi
|
|
103
|
-
VERSION="${MAJOR_MINOR}.$(next_patch "$MAJOR_MINOR")"
|
|
207
|
+
VERSION="${MAJOR_MINOR}.$(next_patch "$MAJOR_MINOR" "$COMBINED_VERSIONS_JSON")"
|
|
104
208
|
else
|
|
105
|
-
# test/* / develop / feature
|
|
106
|
-
|
|
209
|
+
# release/* / test/* / develop / feature / any other production branch
|
|
210
|
+
# publishes a pre-release with its OWN patch counter, starting at the base
|
|
211
|
+
# version's patch and incrementing per build of that branch. Only master
|
|
212
|
+
# cuts a clean semver release.
|
|
213
|
+
MAJOR_MINOR="${BASE%.*}"
|
|
214
|
+
BASE_PATCH="${BASE##*.}"
|
|
215
|
+
VERSION="${MAJOR_MINOR}.$(next_patch_for_branch "$MAJOR_MINOR" "$BRANCH" "$BASE_PATCH" "$COMBINED_VERSIONS_JSON")-${BRANCH}"
|
|
107
216
|
fi
|
|
108
217
|
|
|
109
|
-
echo "Resolved version: ${VERSION} (base=${BASE}, branch=${BRANCH}
|
|
218
|
+
echo "Resolved version: ${VERSION} (base=${BASE}, branch=${BRANCH})"
|
|
110
219
|
|
|
111
220
|
# Write back to package.json (Node instead of jq — RHEL Node build image lacks jq)
|
|
112
221
|
node -e '
|
|
@@ -121,7 +230,7 @@ node -e '
|
|
|
121
230
|
# something to publish to GitHub. Without this, npm publishes the version
|
|
122
231
|
# but no matching git tag is ever created. No `v` prefix — the tag matches
|
|
123
232
|
# the npm/package.json version verbatim.
|
|
124
|
-
if
|
|
233
|
+
if is_git_repo; then
|
|
125
234
|
if git tag "$VERSION" 2>/dev/null; then
|
|
126
235
|
echo "Tagged commit with ${VERSION}"
|
|
127
236
|
else
|