@sanlam-fintech-digital/mfe-platform-cli 0.2.8 → 0.3.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/dist/nuget/manager.js +1 -3
- package/dist/types/config.js +36 -0
- package/package.json +1 -1
package/dist/nuget/manager.js
CHANGED
|
@@ -103,9 +103,7 @@ async function addNuGetFeeds(feeds, tokenMap, configPath) {
|
|
|
103
103
|
// Add credentials if token provided
|
|
104
104
|
const token = tokenMap?.get(feed.url);
|
|
105
105
|
if (token) {
|
|
106
|
-
|
|
107
|
-
const credKey = sourceName.replace(/[^a-zA-Z0-9_]/g, '_');
|
|
108
|
-
credentials[credKey] = {
|
|
106
|
+
credentials[sourceName] = {
|
|
109
107
|
add: [
|
|
110
108
|
{ '@_key': 'Username', '@_value': 'PersonalAccessToken' },
|
|
111
109
|
{ '@_key': 'ClearTextPassword', '@_value': token }
|
package/dist/types/config.js
CHANGED
|
@@ -6,6 +6,29 @@ const zod_1 = require("zod");
|
|
|
6
6
|
* Package feed type
|
|
7
7
|
*/
|
|
8
8
|
const FeedTypeSchema = zod_1.z.enum(['npm', 'nuget']).default('npm');
|
|
9
|
+
/**
|
|
10
|
+
* Validates if a string is a valid XML element name.
|
|
11
|
+
* XML 1.0 specification (https://www.w3.org/TR/xml/#NT-Name):
|
|
12
|
+
* - Must start with a letter (A-Z, a-z) or underscore (_)
|
|
13
|
+
* - Can contain letters, digits, hyphens (-), underscores (_), and periods (.)
|
|
14
|
+
* - Cannot start with "xml" (case-insensitive)
|
|
15
|
+
* - Cannot contain spaces or special characters like @, $, %, etc.
|
|
16
|
+
*/
|
|
17
|
+
function isValidXmlElementName(name) {
|
|
18
|
+
// Empty string is invalid
|
|
19
|
+
if (!name)
|
|
20
|
+
return false;
|
|
21
|
+
// Must start with letter or underscore (not digit, hyphen, or period)
|
|
22
|
+
if (!/^[A-Za-z_]/.test(name))
|
|
23
|
+
return false;
|
|
24
|
+
// Can only contain letters, digits, hyphens, underscores, and periods
|
|
25
|
+
if (!/^[A-Za-z_][A-Za-z0-9._-]*$/.test(name))
|
|
26
|
+
return false;
|
|
27
|
+
// Cannot start with "xml" (case-insensitive)
|
|
28
|
+
if (/^xml/i.test(name))
|
|
29
|
+
return false;
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
9
32
|
/**
|
|
10
33
|
* Individual registry entry (npm or NuGet feed)
|
|
11
34
|
*/
|
|
@@ -13,6 +36,19 @@ const RegistryEntrySchema = zod_1.z.object({
|
|
|
13
36
|
scope: zod_1.z.string().describe('npm scope (e.g., "@org/package") or NuGet source name'),
|
|
14
37
|
url: zod_1.z.url().describe('Registry/Feed URL (Azure DevOps, GitHub, or public)').transform((url) => url.replace(/\/+$/, '')),
|
|
15
38
|
feedType: FeedTypeSchema.optional().describe('Package feed type (defaults to npm for backward compatibility)'),
|
|
39
|
+
}).superRefine((data, ctx) => {
|
|
40
|
+
// For NuGet feeds, the scope becomes an XML element name in NuGet.Config
|
|
41
|
+
// Validate it meets XML element name requirements
|
|
42
|
+
const feedType = data.feedType || 'npm';
|
|
43
|
+
if (feedType === 'nuget' && !isValidXmlElementName(data.scope)) {
|
|
44
|
+
ctx.addIssue({
|
|
45
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
46
|
+
message: `NuGet source name "${data.scope}" is not a valid XML element name. ` +
|
|
47
|
+
`It must start with a letter or underscore, contain only letters, digits, hyphens, underscores, and periods, ` +
|
|
48
|
+
`and cannot start with "xml" (case-insensitive).`,
|
|
49
|
+
path: ['scope'],
|
|
50
|
+
});
|
|
51
|
+
}
|
|
16
52
|
});
|
|
17
53
|
/**
|
|
18
54
|
* Azure DevOps auth group (requires tenantId)
|