@microsoft/ado-npm-auth-lib 0.9.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 (112) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +3 -0
  3. package/lib/.tsbuildinfo +1 -0
  4. package/lib/ado/make-ado-request.d.ts +15 -0
  5. package/lib/ado/make-ado-request.d.ts.map +1 -0
  6. package/lib/ado/make-ado-request.js +37 -0
  7. package/lib/ado/make-ado-request.js.map +1 -0
  8. package/lib/args.d.ts +9 -0
  9. package/lib/args.d.ts.map +1 -0
  10. package/lib/args.js +38 -0
  11. package/lib/args.js.map +1 -0
  12. package/lib/azureauth/ado.d.ts +26 -0
  13. package/lib/azureauth/ado.d.ts.map +1 -0
  14. package/lib/azureauth/ado.js +85 -0
  15. package/lib/azureauth/ado.js.map +1 -0
  16. package/lib/azureauth/ado.test.d.ts +2 -0
  17. package/lib/azureauth/ado.test.d.ts.map +1 -0
  18. package/lib/azureauth/ado.test.js +154 -0
  19. package/lib/azureauth/ado.test.js.map +1 -0
  20. package/lib/azureauth/azureauth-command.d.ts +11 -0
  21. package/lib/azureauth/azureauth-command.d.ts.map +1 -0
  22. package/lib/azureauth/azureauth-command.js +30 -0
  23. package/lib/azureauth/azureauth-command.js.map +1 -0
  24. package/lib/azureauth/is-azureauth-installed.d.ts +7 -0
  25. package/lib/azureauth/is-azureauth-installed.d.ts.map +1 -0
  26. package/lib/azureauth/is-azureauth-installed.js +28 -0
  27. package/lib/azureauth/is-azureauth-installed.js.map +1 -0
  28. package/lib/azureauth/is-azureauth-installed.test.d.ts +2 -0
  29. package/lib/azureauth/is-azureauth-installed.test.d.ts.map +1 -0
  30. package/lib/azureauth/is-azureauth-installed.test.js +54 -0
  31. package/lib/azureauth/is-azureauth-installed.test.js.map +1 -0
  32. package/lib/azureauth/is-supported-platform-and-architecture.d.ts +6 -0
  33. package/lib/azureauth/is-supported-platform-and-architecture.d.ts.map +1 -0
  34. package/lib/azureauth/is-supported-platform-and-architecture.js +16 -0
  35. package/lib/azureauth/is-supported-platform-and-architecture.js.map +1 -0
  36. package/lib/cli.d.ts +4 -0
  37. package/lib/cli.d.ts.map +1 -0
  38. package/lib/cli.js +125 -0
  39. package/lib/cli.js.map +1 -0
  40. package/lib/fileProvider.d.ts +35 -0
  41. package/lib/fileProvider.d.ts.map +1 -0
  42. package/lib/fileProvider.js +79 -0
  43. package/lib/fileProvider.js.map +1 -0
  44. package/lib/index.d.ts +10 -0
  45. package/lib/index.d.ts.map +1 -0
  46. package/lib/index.js +9 -0
  47. package/lib/index.js.map +1 -0
  48. package/lib/npmrc/generate-npmrc-pat.d.ts +6 -0
  49. package/lib/npmrc/generate-npmrc-pat.d.ts.map +1 -0
  50. package/lib/npmrc/generate-npmrc-pat.js +49 -0
  51. package/lib/npmrc/generate-npmrc-pat.js.map +1 -0
  52. package/lib/npmrc/npmrcFileProvider.d.ts +13 -0
  53. package/lib/npmrc/npmrcFileProvider.d.ts.map +1 -0
  54. package/lib/npmrc/npmrcFileProvider.js +149 -0
  55. package/lib/npmrc/npmrcFileProvider.js.map +1 -0
  56. package/lib/npmrc/nugetCredentialProvider.d.ts +7 -0
  57. package/lib/npmrc/nugetCredentialProvider.d.ts.map +1 -0
  58. package/lib/npmrc/nugetCredentialProvider.js +76 -0
  59. package/lib/npmrc/nugetCredentialProvider.js.map +1 -0
  60. package/lib/telemetry/index.d.ts +20 -0
  61. package/lib/telemetry/index.d.ts.map +1 -0
  62. package/lib/telemetry/index.js +20 -0
  63. package/lib/telemetry/index.js.map +1 -0
  64. package/lib/utils/encoding.d.ts +13 -0
  65. package/lib/utils/encoding.d.ts.map +1 -0
  66. package/lib/utils/encoding.js +15 -0
  67. package/lib/utils/encoding.js.map +1 -0
  68. package/lib/utils/exec.d.ts +18 -0
  69. package/lib/utils/exec.d.ts.map +1 -0
  70. package/lib/utils/exec.js +46 -0
  71. package/lib/utils/exec.js.map +1 -0
  72. package/lib/utils/fileUtils.d.ts +2 -0
  73. package/lib/utils/fileUtils.d.ts.map +1 -0
  74. package/lib/utils/fileUtils.js +16 -0
  75. package/lib/utils/fileUtils.js.map +1 -0
  76. package/lib/utils/get-feed-without-protocol.d.ts +5 -0
  77. package/lib/utils/get-feed-without-protocol.d.ts.map +1 -0
  78. package/lib/utils/get-feed-without-protocol.js +11 -0
  79. package/lib/utils/get-feed-without-protocol.js.map +1 -0
  80. package/lib/utils/get-feed-without-protocol.test.d.ts +2 -0
  81. package/lib/utils/get-feed-without-protocol.test.d.ts.map +1 -0
  82. package/lib/utils/get-feed-without-protocol.test.js +31 -0
  83. package/lib/utils/get-feed-without-protocol.test.js.map +1 -0
  84. package/lib/utils/get-organization-from-feed-url.d.ts +8 -0
  85. package/lib/utils/get-organization-from-feed-url.d.ts.map +1 -0
  86. package/lib/utils/get-organization-from-feed-url.js +81 -0
  87. package/lib/utils/get-organization-from-feed-url.js.map +1 -0
  88. package/lib/utils/get-organization-from-feed-url.test.d.ts +2 -0
  89. package/lib/utils/get-organization-from-feed-url.test.d.ts.map +1 -0
  90. package/lib/utils/get-organization-from-feed-url.test.js +19 -0
  91. package/lib/utils/get-organization-from-feed-url.test.js.map +1 -0
  92. package/lib/utils/is-codespaces.d.ts +6 -0
  93. package/lib/utils/is-codespaces.d.ts.map +1 -0
  94. package/lib/utils/is-codespaces.js +10 -0
  95. package/lib/utils/is-codespaces.js.map +1 -0
  96. package/lib/utils/is-wsl.d.ts +6 -0
  97. package/lib/utils/is-wsl.d.ts.map +1 -0
  98. package/lib/utils/is-wsl.js +9 -0
  99. package/lib/utils/is-wsl.js.map +1 -0
  100. package/lib/utils/partition.d.ts +2 -0
  101. package/lib/utils/partition.d.ts.map +1 -0
  102. package/lib/utils/partition.js +15 -0
  103. package/lib/utils/partition.js.map +1 -0
  104. package/lib/utils/request.d.ts +15 -0
  105. package/lib/utils/request.d.ts.map +1 -0
  106. package/lib/utils/request.js +135 -0
  107. package/lib/utils/request.js.map +1 -0
  108. package/lib/yarnrc/yarnrcFileProvider.d.ts +27 -0
  109. package/lib/yarnrc/yarnrcFileProvider.d.ts.map +1 -0
  110. package/lib/yarnrc/yarnrcFileProvider.js +96 -0
  111. package/lib/yarnrc/yarnrcFileProvider.js.map +1 -0
  112. package/package.json +48 -0
@@ -0,0 +1,31 @@
1
+ import { expect, test } from "vitest";
2
+ import { getFeedWithoutProtocol } from "./get-feed-without-protocol.js";
3
+ test("getFeedWithoutProtocol with a normal feed", () => {
4
+ const feedWithoutProtocol = getFeedWithoutProtocol("https://foo.bar.baz/org/proj/_packaging/repo/npm/registry/");
5
+ expect(feedWithoutProtocol).toBe("foo.bar.baz/org/proj/_packaging/repo/npm/registry/");
6
+ });
7
+ test("getFeedWithoutProtocol throws error with an empty feed", () => {
8
+ expect(() => getFeedWithoutProtocol("")).toThrowError("Invalid URL");
9
+ });
10
+ test("getFeedWithoutProtocol with a port specified", () => {
11
+ // hint: if you use the default port for the protocol (ex https/443) then it will be stripped as it is not necessary
12
+ const feedHasPortWithoutProtocol = getFeedWithoutProtocol("https://foo.bar:444/baz");
13
+ expect(feedHasPortWithoutProtocol).toBe("foo.bar:444/baz");
14
+ });
15
+ test("getFeedWithoutProtocol with a query argument specified", () => {
16
+ const feedHasQueryArgWithoutProtocol = getFeedWithoutProtocol("https://foo.bar/baz?qux=qaz");
17
+ expect(feedHasQueryArgWithoutProtocol).toBe("foo.bar/baz?qux=qaz");
18
+ });
19
+ test("getFeedWithoutProtocol with many query arguments specified", () => {
20
+ const feedHasQueryArgsWithoutProtocol = getFeedWithoutProtocol("https://foo.bar/baz?qux=qaz&type=multi&env=test");
21
+ expect(feedHasQueryArgsWithoutProtocol).toBe("foo.bar/baz?qux=qaz&type=multi&env=test");
22
+ });
23
+ test("getFeedWithoutProtocol with a fragment specified", () => {
24
+ const feedHasFragmentWithoutProtocol = getFeedWithoutProtocol("https://foo.bar/baz#frag");
25
+ expect(feedHasFragmentWithoutProtocol).toBe("foo.bar/baz#frag");
26
+ });
27
+ test("getFeedWithoutProtocol with a port, many query arguments and fragment specified", () => {
28
+ const feedHasQueryArgsWithoutProtocol = getFeedWithoutProtocol("https://foo.bar.com:440/baz/pop?qux=qaz&type=multi&env=test#frag");
29
+ expect(feedHasQueryArgsWithoutProtocol).toBe("foo.bar.com:440/baz/pop?qux=qaz&type=multi&env=test#frag");
30
+ });
31
+ //# sourceMappingURL=get-feed-without-protocol.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-feed-without-protocol.test.js","sourceRoot":"","sources":["../../src/utils/get-feed-without-protocol.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,IAAI,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACrD,MAAM,mBAAmB,GAAG,sBAAsB,CAChD,4DAA4D,CAC7D,CAAC;IACF,MAAM,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAC9B,oDAAoD,CACrD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,wDAAwD,EAAE,GAAG,EAAE;IAClE,MAAM,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;AACvE,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,8CAA8C,EAAE,GAAG,EAAE;IACxD,oHAAoH;IACpH,MAAM,0BAA0B,GAAG,sBAAsB,CACvD,yBAAyB,CAC1B,CAAC;IACF,MAAM,CAAC,0BAA0B,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,wDAAwD,EAAE,GAAG,EAAE;IAClE,MAAM,8BAA8B,GAAG,sBAAsB,CAC3D,6BAA6B,CAC9B,CAAC;IACF,MAAM,CAAC,8BAA8B,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AACrE,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,4DAA4D,EAAE,GAAG,EAAE;IACtE,MAAM,+BAA+B,GAAG,sBAAsB,CAC5D,iDAAiD,CAClD,CAAC;IACF,MAAM,CAAC,+BAA+B,CAAC,CAAC,IAAI,CAC1C,yCAAyC,CAC1C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,kDAAkD,EAAE,GAAG,EAAE;IAC5D,MAAM,8BAA8B,GAAG,sBAAsB,CAC3D,0BAA0B,CAC3B,CAAC;IACF,MAAM,CAAC,8BAA8B,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AAClE,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,iFAAiF,EAAE,GAAG,EAAE;IAC3F,MAAM,+BAA+B,GAAG,sBAAsB,CAC5D,kEAAkE,CACnE,CAAC;IACF,MAAM,CAAC,+BAA+B,CAAC,CAAC,IAAI,CAC1C,0DAA0D,CAC3D,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Get the ADO Org for a npm feed
3
+ * @param {string} feedUrl URL of the feed to get the ADO organization from
4
+ * @param {string} [defaultOrg] Backup org in case it cannot be determined from the feed url
5
+ * @returns ADO Organization for the feed
6
+ */
7
+ export declare const getOrganizationFromFeedUrl: (feedUrl: string, defaultOrg?: string) => string;
8
+ //# sourceMappingURL=get-organization-from-feed-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-organization-from-feed-url.d.ts","sourceRoot":"","sources":["../../src/utils/get-organization-from-feed-url.ts"],"names":[],"mappings":"AAwEA;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GACrC,SAAS,MAAM,EACf,mBAAe,WAQhB,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Extracts the organization and project details from a given Azure DevOps URL.
3
+ * The function differentiates between the "new style" URLs that use 'dev.azure.com'
4
+ * and "old style" URLs that use a subdomain of 'visualstudio.com'.
5
+ *
6
+ * @param {string} url - The Azure DevOps URL from which to extract details.
7
+ * @returns {Object} An object containing the `organization` and `project` extracted from the URL.
8
+ * @throws {Error} Throws an error if the URL is invalid, not in the expected format,
9
+ * or does not contain the necessary information for extraction.
10
+ *
11
+ * @example
12
+ * // New style URL
13
+ * extractAdoDetails("https://dev.azure.com/contoso/WebsiteRedesign");
14
+ * // returns { organization: "contoso", project: "WebsiteRedesign" }
15
+ *
16
+ * // Old style URL
17
+ * extractAdoDetails("https://contoso.visualstudio.com/WebsiteRedesign");
18
+ * // returns { organization: "contoso", project: "WebsiteRedesign" }
19
+ *
20
+ * // Invalid URL
21
+ * extractAdoDetails("https://invalid.url.com");
22
+ * // throws Error
23
+ */
24
+ const extractAdoDetails = (url) => {
25
+ try {
26
+ if (!url.startsWith("https://")) {
27
+ url = "https://" + url;
28
+ }
29
+ const parsedUrl = new URL(url);
30
+ const hostname = parsedUrl.hostname;
31
+ const pathname = parsedUrl.pathname;
32
+ // Check for new style URLs (dev.azure.com)
33
+ if (hostname.endsWith("dev.azure.com")) {
34
+ const pathSegments = pathname.split("/").filter(Boolean); // Remove empty strings from the split result
35
+ if (pathSegments.length >= 2) {
36
+ return {
37
+ organization: pathSegments[0],
38
+ project: pathSegments[1],
39
+ };
40
+ }
41
+ else {
42
+ throw new Error("Not enough segments in path for a valid organization and project extraction.");
43
+ }
44
+ }
45
+ // Check for old style URLs (visualstudio.com)
46
+ if (hostname.endsWith("visualstudio.com")) {
47
+ const subdomain = hostname.split(".")[0];
48
+ const pathSegments = pathname.split("/").filter(Boolean);
49
+ if (subdomain && pathSegments.length >= 1) {
50
+ return {
51
+ organization: subdomain,
52
+ project: pathSegments[0],
53
+ };
54
+ }
55
+ else {
56
+ throw new Error("Not enough segments in path or missing subdomain for a valid organization and project extraction.");
57
+ }
58
+ }
59
+ // If the URL does not match expected formats
60
+ throw new Error("URL format not recognized or does not contain enough information.");
61
+ }
62
+ catch {
63
+ throw new Error("Invalid URL or unsupported format");
64
+ }
65
+ };
66
+ /**
67
+ * Get the ADO Org for a npm feed
68
+ * @param {string} feedUrl URL of the feed to get the ADO organization from
69
+ * @param {string} [defaultOrg] Backup org in case it cannot be determined from the feed url
70
+ * @returns ADO Organization for the feed
71
+ */
72
+ export const getOrganizationFromFeedUrl = (feedUrl, defaultOrg = "") => {
73
+ try {
74
+ const { organization } = extractAdoDetails(feedUrl);
75
+ return organization;
76
+ }
77
+ catch {
78
+ return defaultOrg;
79
+ }
80
+ };
81
+ //# sourceMappingURL=get-organization-from-feed-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-organization-from-feed-url.js","sourceRoot":"","sources":["../../src/utils/get-organization-from-feed-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAE,EAAE;IACxC,IAAI,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAChC,GAAG,GAAG,UAAU,GAAG,GAAG,CAAC;QACzB,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;QACpC,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;QAEpC,2CAA2C;QAC3C,IAAI,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;YACvC,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,6CAA6C;YACvG,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;gBAC7B,OAAO;oBACL,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC;oBAC7B,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;iBACzB,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;YACJ,CAAC;QACH,CAAC;QAED,8CAA8C;QAC9C,IAAI,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC1C,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACzC,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACzD,IAAI,SAAS,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;gBAC1C,OAAO;oBACL,YAAY,EAAE,SAAS;oBACvB,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;iBACzB,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CACb,mGAAmG,CACpG,CAAC;YACJ,CAAC;QACH,CAAC;QAED,6CAA6C;QAC7C,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;AACH,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,OAAe,EACf,UAAU,GAAG,EAAE,EACf,EAAE;IACF,IAAI,CAAC;QACH,MAAM,EAAE,YAAY,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACpD,OAAO,YAAY,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,UAAU,CAAC;IACpB,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=get-organization-from-feed-url.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-organization-from-feed-url.test.d.ts","sourceRoot":"","sources":["../../src/utils/get-organization-from-feed-url.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import { getOrganizationFromFeedUrl } from "./get-organization-from-feed-url.js";
2
+ import { expect, test } from "vitest";
3
+ test("should get the correct projects from the feed url", () => {
4
+ const stuff = getOrganizationFromFeedUrl("https://pkgs.dev.azure.com/org/proj/_packaging/feedname/npm/registry/");
5
+ expect(stuff).toBe("org");
6
+ });
7
+ test("should get the correct projects from the feed url with only a project name", () => {
8
+ const stuff = getOrganizationFromFeedUrl("https://pkgs.dev.azure.com/org/proj/_packaging/feedname/npm/registry/");
9
+ expect(stuff).toBe("org");
10
+ });
11
+ test("should get the correct projects from the feed url with only a project name but without _packaging", () => {
12
+ const stuff = getOrganizationFromFeedUrl("https://org.dev.azure.com/org/proj/feedname/npm/registry/");
13
+ expect(stuff).toBe("org");
14
+ });
15
+ test("should work for legacy vs urls", () => {
16
+ const stuff = getOrganizationFromFeedUrl("https://org.pkgs.visualstudio.com/proj/_packaging/feed/npm/registry/");
17
+ expect(stuff).toBe("org");
18
+ });
19
+ //# sourceMappingURL=get-organization-from-feed-url.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-organization-from-feed-url.test.js","sourceRoot":"","sources":["../../src/utils/get-organization-from-feed-url.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,IAAI,CAAC,mDAAmD,EAAE,GAAG,EAAE;IAC7D,MAAM,KAAK,GAAG,0BAA0B,CACtC,uEAAuE,CACxE,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,4EAA4E,EAAE,GAAG,EAAE;IACtF,MAAM,KAAK,GAAG,0BAA0B,CACtC,uEAAuE,CACxE,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,mGAAmG,EAAE,GAAG,EAAE;IAC7G,MAAM,KAAK,GAAG,0BAA0B,CACtC,2DAA2D,CAC5D,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC1C,MAAM,KAAK,GAAG,0BAA0B,CACtC,sEAAsE,CACvE,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Determines if the current machine's setup is codespaces
3
+ * @returns { boolean } if the current machine is in codespaces
4
+ */
5
+ export declare const isCodespaces: () => boolean;
6
+ //# sourceMappingURL=is-codespaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-codespaces.d.ts","sourceRoot":"","sources":["../../src/utils/is-codespaces.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,YAAY,eAGxB,CAAC"}
@@ -0,0 +1,10 @@
1
+ const truthy = [true, "true", "TRUE", 1];
2
+ /**
3
+ * Determines if the current machine's setup is codespaces
4
+ * @returns { boolean } if the current machine is in codespaces
5
+ */
6
+ export const isCodespaces = () => {
7
+ const codespaces = process.env["CODESPACES"] || "";
8
+ return truthy.includes(codespaces);
9
+ };
10
+ //# sourceMappingURL=is-codespaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-codespaces.js","sourceRoot":"","sources":["../../src/utils/is-codespaces.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;IACnD,OAAO,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Determine if the current machine's platform is WSL
3
+ * @returns { boolean } if the current platform is WSL
4
+ */
5
+ export declare const isWsl: () => boolean;
6
+ //# sourceMappingURL=is-wsl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-wsl.d.ts","sourceRoot":"","sources":["../../src/utils/is-wsl.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,KAAK,eAEjB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { release, platform } from "node:os";
2
+ /**
3
+ * Determine if the current machine's platform is WSL
4
+ * @returns { boolean } if the current platform is WSL
5
+ */
6
+ export const isWsl = () => {
7
+ return platform() === "linux" && release().toLowerCase().includes("wsl");
8
+ };
9
+ //# sourceMappingURL=is-wsl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-wsl.js","sourceRoot":"","sources":["../../src/utils/is-wsl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,EAAE;IACxB,OAAO,QAAQ,EAAE,KAAK,OAAO,IAAI,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC3E,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function partition<TValue, TKey>(items: TValue[], keySelector: (item: TValue) => TKey): Map<TKey, TValue[]>;
2
+ //# sourceMappingURL=partition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partition.d.ts","sourceRoot":"","sources":["../../src/utils/partition.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,MAAM,EAAE,IAAI,EACpC,KAAK,EAAE,MAAM,EAAE,EACf,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAClC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAarB"}
@@ -0,0 +1,15 @@
1
+ export function partition(items, keySelector) {
2
+ const result = new Map();
3
+ for (const item of items) {
4
+ const key = keySelector(item);
5
+ const existing = result.get(key);
6
+ if (existing) {
7
+ existing.push(item);
8
+ }
9
+ else {
10
+ result.set(key, [item]);
11
+ }
12
+ }
13
+ return result;
14
+ }
15
+ //# sourceMappingURL=partition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partition.js","sourceRoot":"","sources":["../../src/utils/partition.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CACvB,KAAe,EACf,WAAmC;IAEnC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAC9B,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type RequestOptions } from "node:https";
2
+ /**
3
+ *
4
+ * @param {import("http").RequestOptions} options
5
+ * @returns
6
+ */
7
+ export declare const makeRequest: (options: RequestOptions) => Promise<unknown>;
8
+ /**
9
+ * Downloads a file from a URL to a local path.
10
+ * @param url The URL of the file to download.
11
+ * @param downloadPath The local path to save the downloaded file.
12
+ * @returns A promise that resolves when the download is complete.
13
+ */
14
+ export declare function downloadFile(url: string, downloadPath: string): Promise<void>;
15
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/utils/request.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAUxD;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAU,SAAS,cAAc,qBA2CxD,CAAC;AAyCF;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAsDf"}
@@ -0,0 +1,135 @@
1
+ import https from "node:https";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ const defaultOptions = {
5
+ port: 443,
6
+ method: "GET",
7
+ };
8
+ /**
9
+ *
10
+ * @param {import("http").RequestOptions} options
11
+ * @returns
12
+ */
13
+ export const makeRequest = async (options) => {
14
+ return new Promise((resolve, reject) => {
15
+ const mergedOptions = {
16
+ ...defaultOptions,
17
+ ...options,
18
+ };
19
+ const req = https.request(mergedOptions, (res) => {
20
+ let data = "";
21
+ let dataJson = {};
22
+ const ok = res.statusCode === 200;
23
+ res.on("data", (d) => {
24
+ data += d;
25
+ });
26
+ res.on("end", () => {
27
+ if (data &&
28
+ hasAcceptHeaderValue(mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.headers, "application/json")) {
29
+ dataJson = JSON.parse(data.toString().trim());
30
+ }
31
+ if (ok) {
32
+ resolve(dataJson || data);
33
+ }
34
+ else {
35
+ if (dataJson) {
36
+ dataJson = { ...dataJson, statusCode: res.statusCode };
37
+ }
38
+ reject(dataJson || data || new Error(`Error code: ${res.statusCode}.`));
39
+ }
40
+ });
41
+ res.on("error", (/** @type {string} */ error) => {
42
+ reject(new Error(error));
43
+ });
44
+ });
45
+ req.end();
46
+ });
47
+ };
48
+ function hasAcceptHeaderValue(headers, acceptHeaderValueToCheck) {
49
+ var _a;
50
+ if (!headers) {
51
+ return false;
52
+ }
53
+ if (Array.isArray(headers)) {
54
+ for (const header of headers) {
55
+ const indx = header.toLowerCase().indexOf("accept:");
56
+ if (indx === 0) {
57
+ const acceptHeaderValue = header.slice(indx + 7).trim();
58
+ const acceptHeaderValues = acceptHeaderValue
59
+ .split(",")
60
+ .map((value) => value.trim());
61
+ if (acceptHeaderValues.includes(acceptHeaderValueToCheck)) {
62
+ return true;
63
+ }
64
+ }
65
+ }
66
+ return false;
67
+ }
68
+ const normalizedHeaders = headers;
69
+ const acceptHeaderValue = (_a = Object.entries(normalizedHeaders).find(([key]) => key.toLowerCase() === "accept")) === null || _a === void 0 ? void 0 : _a[1];
70
+ if (typeof acceptHeaderValue === "string") {
71
+ return acceptHeaderValue === acceptHeaderValueToCheck;
72
+ }
73
+ else if (Array.isArray(acceptHeaderValue)) {
74
+ return acceptHeaderValue.includes(acceptHeaderValueToCheck);
75
+ }
76
+ else {
77
+ return false;
78
+ }
79
+ }
80
+ /**
81
+ * Downloads a file from a URL to a local path.
82
+ * @param url The URL of the file to download.
83
+ * @param downloadPath The local path to save the downloaded file.
84
+ * @returns A promise that resolves when the download is complete.
85
+ */
86
+ export async function downloadFile(url, downloadPath) {
87
+ return new Promise((resolve, reject) => {
88
+ https
89
+ .get(url, (response) => {
90
+ // Handle redirects
91
+ if (response.statusCode === 301 || response.statusCode === 302) {
92
+ const redirectUrl = response.headers.location;
93
+ if (redirectUrl) {
94
+ downloadFile(redirectUrl, downloadPath).then(resolve).catch(reject);
95
+ return;
96
+ }
97
+ else {
98
+ reject(new Error("Redirect without location header"));
99
+ return;
100
+ }
101
+ }
102
+ // Check for successful response
103
+ if (response.statusCode !== 200) {
104
+ reject(new Error(`HTTP ${response.statusCode}: ${response.statusMessage}`));
105
+ return;
106
+ }
107
+ let downloadStream;
108
+ try {
109
+ const downloadDir = path.dirname(downloadPath);
110
+ if (!fs.existsSync(downloadDir)) {
111
+ fs.mkdirSync(downloadDir, { recursive: true });
112
+ }
113
+ downloadStream = fs.createWriteStream(downloadPath);
114
+ }
115
+ catch (error) {
116
+ reject(error);
117
+ return;
118
+ }
119
+ // Handle stream errors
120
+ downloadStream.on("error", (error) => {
121
+ reject(error);
122
+ });
123
+ // Pipe the response to the file stream
124
+ response.pipe(downloadStream);
125
+ // The whole response has been received and written
126
+ downloadStream.on("finish", () => {
127
+ resolve();
128
+ });
129
+ })
130
+ .on("error", (error) => {
131
+ reject(error); // Reject on request error
132
+ });
133
+ });
134
+ }
135
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/utils/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,YAAY,CAAC;AAExD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,cAAc,GAAmB;IACrC,IAAI,EAAE,GAAG;IACT,MAAM,EAAE,KAAK;CACd,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,OAAuB,EAAE,EAAE;IAC3D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,aAAa,GAAG;YACpB,GAAG,cAAc;YACjB,GAAG,OAAO;SACX,CAAC;QAEF,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE;YAC/C,IAAI,IAAI,GAAG,EAAE,CAAC;YACd,IAAI,QAAQ,GAAG,EAAE,CAAC;YAClB,MAAM,EAAE,GAAG,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC;YAElC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;gBACnB,IAAI,IAAI,CAAC,CAAC;YACZ,CAAC,CAAC,CAAC;YAEH,GAAG,CAA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,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAE9B,mDAAmD;YACnD,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;gBAC/B,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;aACD,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACrB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,0BAA0B;QAC3C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { Feed } from "../fileProvider.js";
2
+ import { FileProvider } from "../fileProvider.js";
3
+ export declare class YarnRcFileProvider extends FileProvider {
4
+ constructor(configFile?: string);
5
+ prepUserFile(): Promise<void>;
6
+ getUserFeeds(): Promise<Map<string, Feed>>;
7
+ getWorkspaceRegistries(): Promise<string[]>;
8
+ writeWorkspaceRegistries(feedsToPatch: Iterable<Feed>): Promise<void>;
9
+ writeYarnRc(filePath: string, yarnrc: YarnRc): Promise<void>;
10
+ paseYarnRc(filePath: string): Promise<YarnRc>;
11
+ }
12
+ type YarnRc = {
13
+ npmRegistryServer?: string;
14
+ npmScopes?: Record<string, {
15
+ npmRegistryServer?: string;
16
+ npmAlwaysAuth?: boolean;
17
+ npmAuthIdent?: string;
18
+ npmAuthToken?: string;
19
+ }>;
20
+ npmRegistries?: Record<string, {
21
+ npmAlwaysAuth?: boolean;
22
+ npmAuthIdent?: string;
23
+ npmAuthToken?: string;
24
+ }>;
25
+ };
26
+ export {};
27
+ //# sourceMappingURL=yarnrcFileProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yarnrcFileProvider.d.ts","sourceRoot":"","sources":["../../src/yarnrc/yarnrcFileProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQlD,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,UAAU,CAAC,EAAE,MAAM;IAIhB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAe7B,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAgC1C,sBAAsB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAoB3C,wBAAwB,CACrC,YAAY,EAAE,QAAQ,CAAC,IAAI,CAAC,GAC3B,OAAO,CAAC,IAAI,CAAC;IAqBV,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK5C,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAIpD;AAED,KAAK,MAAM,GAAG;IACZ,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAChB,MAAM,EACN;QACE,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CACF,CAAC;IACF,aAAa,CAAC,EAAE,MAAM,CACpB,MAAM,EACN;QACE,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CACF,CAAC;CACH,CAAC"}
@@ -0,0 +1,96 @@
1
+ import { FileProvider } from "../fileProvider.js";
2
+ import yaml from "js-yaml";
3
+ import fs from "node:fs/promises";
4
+ import { fromBase64, toBase64 } from "../utils/encoding.js";
5
+ import { getOrganizationFromFeedUrl } from "../utils/get-organization-from-feed-url.js";
6
+ import { getFeedWithoutProtocol } from "../utils/get-feed-without-protocol.js";
7
+ import { writeFileLazy } from "../utils/fileUtils.js";
8
+ export class YarnRcFileProvider extends FileProvider {
9
+ constructor(configFile) {
10
+ super("YarnRc", ".yarnrc.yml", configFile);
11
+ }
12
+ async prepUserFile() {
13
+ try {
14
+ const yarnrc = await this.paseYarnRc(this.userFilePath);
15
+ // remove the entry for registries in the user-level .npmrc
16
+ if (yarnrc && yarnrc.npmRegistryServer) {
17
+ delete yarnrc.npmRegistryServer;
18
+ await this.writeYarnRc(this.userFilePath, yarnrc);
19
+ }
20
+ }
21
+ catch {
22
+ // user .yarnrc file does not exist so make an empty one
23
+ await writeFileLazy(this.userFilePath, "");
24
+ }
25
+ }
26
+ async getUserFeeds() {
27
+ const result = new Map();
28
+ const yarnrc = await this.paseYarnRc(this.userFilePath);
29
+ if (!yarnrc) {
30
+ // No content
31
+ return result;
32
+ }
33
+ const npmRegistries = yarnrc.npmRegistries || {};
34
+ for (const registry of Object.keys(npmRegistries)) {
35
+ const registryData = npmRegistries[registry] || {};
36
+ const registryWithoutProtocol = registry.startsWith("//")
37
+ ? registry.substring(2)
38
+ : registry;
39
+ const feed = {
40
+ registry: registryWithoutProtocol,
41
+ adoOrganization: getOrganizationFromFeedUrl(registryWithoutProtocol),
42
+ };
43
+ const authToken = fromBase64(registryData.npmAuthIdent || "");
44
+ const userPasswordIndex = authToken.indexOf(":");
45
+ if (userPasswordIndex > 0) {
46
+ feed.userName = authToken.substring(0, userPasswordIndex);
47
+ feed.authToken = authToken.substring(userPasswordIndex + 1);
48
+ }
49
+ result.set(registryWithoutProtocol, feed);
50
+ }
51
+ return result;
52
+ }
53
+ async getWorkspaceRegistries() {
54
+ var _a;
55
+ const registries = [];
56
+ const yarnrc = await this.paseYarnRc(this.workspaceFilePath);
57
+ if (yarnrc.npmRegistryServer) {
58
+ registries.push(getFeedWithoutProtocol(yarnrc.npmRegistryServer));
59
+ }
60
+ if (yarnrc.npmScopes) {
61
+ for (const scope of Object.keys(yarnrc.npmScopes)) {
62
+ const scopeRegistry = (_a = yarnrc.npmScopes[scope]) === null || _a === void 0 ? void 0 : _a.npmRegistryServer;
63
+ if (scopeRegistry) {
64
+ registries.push(scopeRegistry);
65
+ }
66
+ }
67
+ }
68
+ return registries;
69
+ }
70
+ async writeWorkspaceRegistries(feedsToPatch) {
71
+ const yarnrc = (await this.paseYarnRc(this.userFilePath)) || {};
72
+ if (!yarnrc.npmRegistries) {
73
+ yarnrc.npmRegistries = {};
74
+ }
75
+ for (const feed of feedsToPatch) {
76
+ const yarnRcYamlKey = "//" + feed.registry;
77
+ const entry = yarnrc.npmRegistries[yarnRcYamlKey] || {};
78
+ // Make sure alwaysAuth is the default
79
+ if (entry.npmAlwaysAuth === undefined) {
80
+ entry.npmAlwaysAuth = true;
81
+ }
82
+ entry.npmAuthIdent = toBase64(`${feed.userName}:${feed.authToken}`);
83
+ yarnrc.npmRegistries[yarnRcYamlKey] = entry;
84
+ }
85
+ await this.writeYarnRc(this.userFilePath, yarnrc);
86
+ }
87
+ async writeYarnRc(filePath, yarnrc) {
88
+ const yarnrcContent = yaml.dump(yarnrc);
89
+ await writeFileLazy(filePath, yarnrcContent);
90
+ }
91
+ async paseYarnRc(filePath) {
92
+ const content = await fs.readFile(filePath, "utf8");
93
+ return yaml.load(content, { filename: filePath });
94
+ }
95
+ }
96
+ //# sourceMappingURL=yarnrcFileProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yarnrcFileProvider.js","sourceRoot":"","sources":["../../src/yarnrc/yarnrcFileProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,OAAO,kBAAmB,S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ACF"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@microsoft/ado-npm-auth-lib",
3
+ "version": "0.9.0",
4
+ "description": "The ado-npm-auth package can automatically use the azureauth CLI to fetch tokens and update a user's .npmrc file for authenticating to ADO package feeds.",
5
+ "repository": "https://github.com/microsoft/ado-npm-auth",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./lib/index.js",
9
+ "module": "./lib/index.js",
10
+ "typings": "./lib/index.d.ts",
11
+ "bin": "./bin/index.js",
12
+ "sideEffects": false,
13
+ "files": [
14
+ "lib/**/*",
15
+ "bin",
16
+ "static",
17
+ "LICENCSE.txt",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc",
22
+ "eslint": "eslint .",
23
+ "lint": "prettier --check src/**/*.ts",
24
+ "performance-test": "node lib/tests/performance.test.js",
25
+ "test": "vitest run src"
26
+ },
27
+ "dependencies": {
28
+ "@npmcli/config": "^10.1.0",
29
+ "azureauth": "^0.14.0",
30
+ "js-yaml": "^4.1.0",
31
+ "tslib": "^2.8.1",
32
+ "workspace-tools": "^0.40.0"
33
+ },
34
+ "devDependencies": {
35
+ "@microsoft/eslint-plugin-sdl": "^1.1.0",
36
+ "@rnx-kit/eslint-plugin": "^0.9.3",
37
+ "@types/js-yaml": "4.0.9",
38
+ "@types/node": "^20.17.28",
39
+ "@types/npmcli__config": "^6.0.3",
40
+ "@types/yargs": "^17.0.33",
41
+ "esbuild": "^0.27.0",
42
+ "eslint": "^9.39.1",
43
+ "prettier": "^3.5.3",
44
+ "typescript": "^5.8.2",
45
+ "vitest": "^2.1.9",
46
+ "yargs": "^17.7.2"
47
+ }
48
+ }