ado-npm-auth 0.1.2 → 0.1.4
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 +25 -0
- package/dist/ado-npm-auth.cjs +281 -39128
- package/dist/index.js +1 -0
- package/package.json +21 -15
- package/dist/ado-auto-auth.cjs +0 -39047
- package/lib/.tsbuildinfo +0 -1
- package/lib/azureauth/ado.d.ts +0 -26
- package/lib/azureauth/ado.d.ts.map +0 -1
- package/lib/azureauth/ado.js +0 -84
- package/lib/azureauth/ado.js.map +0 -1
- package/lib/azureauth/ado.test.d.ts +0 -2
- package/lib/azureauth/ado.test.d.ts.map +0 -1
- package/lib/azureauth/ado.test.js +0 -119
- package/lib/azureauth/ado.test.js.map +0 -1
- package/lib/azureauth/azureauth-command.d.ts +0 -8
- package/lib/azureauth/azureauth-command.d.ts.map +0 -1
- package/lib/azureauth/azureauth-command.js +0 -24
- package/lib/azureauth/azureauth-command.js.map +0 -1
- package/lib/azureauth/index.d.ts +0 -2
- package/lib/azureauth/index.d.ts.map +0 -1
- package/lib/azureauth/index.js +0 -2
- package/lib/azureauth/index.js.map +0 -1
- package/lib/azureauth/is-azureauth-installed.d.ts +0 -7
- package/lib/azureauth/is-azureauth-installed.d.ts.map +0 -1
- package/lib/azureauth/is-azureauth-installed.js +0 -27
- package/lib/azureauth/is-azureauth-installed.js.map +0 -1
- package/lib/azureauth/is-azureauth-installed.test.d.ts +0 -2
- package/lib/azureauth/is-azureauth-installed.test.d.ts.map +0 -1
- package/lib/azureauth/is-azureauth-installed.test.js +0 -51
- package/lib/azureauth/is-azureauth-installed.test.js.map +0 -1
- package/lib/azureauth/is-supported-platform-and-architecture.d.ts +0 -6
- package/lib/azureauth/is-supported-platform-and-architecture.d.ts.map +0 -1
- package/lib/azureauth/is-supported-platform-and-architecture.js +0 -16
- package/lib/azureauth/is-supported-platform-and-architecture.js.map +0 -1
- package/lib/cli.d.ts +0 -2
- package/lib/cli.d.ts.map +0 -1
- package/lib/cli.js +0 -61
- package/lib/cli.js.map +0 -1
- package/lib/index.d.ts +0 -2
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/npmrc/base64.d.ts +0 -7
- package/lib/npmrc/base64.d.ts.map +0 -1
- package/lib/npmrc/base64.js +0 -7
- package/lib/npmrc/base64.js.map +0 -1
- package/lib/npmrc/check-tokens.d.ts +0 -11
- package/lib/npmrc/check-tokens.d.ts.map +0 -1
- package/lib/npmrc/check-tokens.js +0 -31
- package/lib/npmrc/check-tokens.js.map +0 -1
- package/lib/npmrc/generate-npmrc-pat.d.ts +0 -6
- package/lib/npmrc/generate-npmrc-pat.d.ts.map +0 -1
- package/lib/npmrc/generate-npmrc-pat.js +0 -24
- package/lib/npmrc/generate-npmrc-pat.js.map +0 -1
- package/lib/npmrc/get-repo-npmrc-ado-orgs.d.ts +0 -12
- package/lib/npmrc/get-repo-npmrc-ado-orgs.d.ts.map +0 -1
- package/lib/npmrc/get-repo-npmrc-ado-orgs.js +0 -49
- package/lib/npmrc/get-repo-npmrc-ado-orgs.js.map +0 -1
- package/lib/npmrc/get-user-pat.d.ts +0 -14
- package/lib/npmrc/get-user-pat.d.ts.map +0 -1
- package/lib/npmrc/get-user-pat.js +0 -33
- package/lib/npmrc/get-user-pat.js.map +0 -1
- package/lib/npmrc/index.d.ts +0 -2
- package/lib/npmrc/index.d.ts.map +0 -1
- package/lib/npmrc/index.js +0 -2
- package/lib/npmrc/index.js.map +0 -1
- package/lib/npmrc/is-valid-pat.d.ts +0 -2
- package/lib/npmrc/is-valid-pat.d.ts.map +0 -1
- package/lib/npmrc/is-valid-pat.js +0 -59
- package/lib/npmrc/is-valid-pat.js.map +0 -1
- package/lib/npmrc/make-ado-request.d.ts +0 -15
- package/lib/npmrc/make-ado-request.d.ts.map +0 -1
- package/lib/npmrc/make-ado-request.js +0 -36
- package/lib/npmrc/make-ado-request.js.map +0 -1
- package/lib/npmrc/npmrc.d.ts +0 -15
- package/lib/npmrc/npmrc.d.ts.map +0 -1
- package/lib/npmrc/npmrc.js +0 -22
- package/lib/npmrc/npmrc.js.map +0 -1
- package/lib/npmrc/pat.d.ts +0 -13
- package/lib/npmrc/pat.d.ts.map +0 -1
- package/lib/npmrc/pat.js +0 -32
- package/lib/npmrc/pat.js.map +0 -1
- package/lib/npmrc/set-npmrc-pat.d.ts +0 -16
- package/lib/npmrc/set-npmrc-pat.d.ts.map +0 -1
- package/lib/npmrc/set-npmrc-pat.js +0 -109
- package/lib/npmrc/set-npmrc-pat.js.map +0 -1
- package/lib/telemetry/index.d.ts +0 -20
- package/lib/telemetry/index.d.ts.map +0 -1
- package/lib/telemetry/index.js +0 -21
- package/lib/telemetry/index.js.map +0 -1
- package/lib/utils/exec.d.ts +0 -4
- package/lib/utils/exec.d.ts.map +0 -1
- package/lib/utils/exec.js +0 -4
- package/lib/utils/exec.js.map +0 -1
- package/lib/utils/get-feed-without-protocol.d.ts +0 -7
- package/lib/utils/get-feed-without-protocol.d.ts.map +0 -1
- package/lib/utils/get-feed-without-protocol.js +0 -13
- package/lib/utils/get-feed-without-protocol.js.map +0 -1
- package/lib/utils/get-feed-without-protocol.test.d.ts +0 -2
- package/lib/utils/get-feed-without-protocol.test.d.ts.map +0 -1
- package/lib/utils/get-feed-without-protocol.test.js +0 -31
- package/lib/utils/get-feed-without-protocol.test.js.map +0 -1
- package/lib/utils/get-organization-from-feed-url.d.ts +0 -8
- package/lib/utils/get-organization-from-feed-url.d.ts.map +0 -1
- package/lib/utils/get-organization-from-feed-url.js +0 -78
- package/lib/utils/get-organization-from-feed-url.js.map +0 -1
- package/lib/utils/get-organization-from-feed-url.test.d.ts +0 -2
- package/lib/utils/get-organization-from-feed-url.test.d.ts.map +0 -1
- package/lib/utils/get-organization-from-feed-url.test.js +0 -19
- package/lib/utils/get-organization-from-feed-url.test.js.map +0 -1
- package/lib/utils/is-codespaces.d.ts +0 -6
- package/lib/utils/is-codespaces.d.ts.map +0 -1
- package/lib/utils/is-codespaces.js +0 -10
- package/lib/utils/is-codespaces.js.map +0 -1
- package/lib/utils/is-wsl.d.ts +0 -6
- package/lib/utils/is-wsl.d.ts.map +0 -1
- package/lib/utils/is-wsl.js +0 -9
- package/lib/utils/is-wsl.js.map +0 -1
- package/lib/utils/request.d.ts +0 -9
- package/lib/utils/request.d.ts.map +0 -1
- package/lib/utils/request.js +0 -38
- package/lib/utils/request.js.map +0 -1
package/lib/npmrc/npmrc.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"npmrc.js","sourceRoot":"","sources":["../../src/npmrc/npmrc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IACzE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEhD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,EAAE,KAAK,EAAsB,EAAE,EAAE;IAC/D,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAE3D,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
package/lib/npmrc/pat.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { NpmrcOrg } from "./get-repo-npmrc-ado-orgs.js";
|
|
2
|
-
/**
|
|
3
|
-
* Get the User's PAT from the .npmrc file
|
|
4
|
-
* @param {Object} options
|
|
5
|
-
* @param {string} options.npmrc Path to the users' .npmrc file
|
|
6
|
-
* @param { Array<NpmrcOrg> } [options.feeds] Feeds to get the PATs for
|
|
7
|
-
* @returns { Promise<Array<NpmrcOrg>> }
|
|
8
|
-
*/
|
|
9
|
-
export declare const getUserPat: ({ npmrc, feeds }: {
|
|
10
|
-
npmrc: string;
|
|
11
|
-
feeds: NpmrcOrg[];
|
|
12
|
-
}) => Promise<NpmrcOrg[]>;
|
|
13
|
-
//# sourceMappingURL=pat.d.ts.map
|
package/lib/npmrc/pat.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pat.d.ts","sourceRoot":"","sources":["../../src/npmrc/pat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAIxD;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,qBAAiC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,QAAQ,EAAE,CAAA;CAAC,wBAwB1F,CAAC"}
|
package/lib/npmrc/pat.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { decode } from "./base64.js";
|
|
2
|
-
import { getFeedWithoutProtocol } from "../utils/get-feed-without-protocol.js";
|
|
3
|
-
import { readNpmRC } from "./npmrc.js";
|
|
4
|
-
/**
|
|
5
|
-
* Get the User's PAT from the .npmrc file
|
|
6
|
-
* @param {Object} options
|
|
7
|
-
* @param {string} options.npmrc Path to the users' .npmrc file
|
|
8
|
-
* @param { Array<NpmrcOrg> } [options.feeds] Feeds to get the PATs for
|
|
9
|
-
* @returns { Promise<Array<NpmrcOrg>> }
|
|
10
|
-
*/
|
|
11
|
-
export const getUserPat = async ({ npmrc, feeds = [] }) => {
|
|
12
|
-
try {
|
|
13
|
-
const contents = await readNpmRC({ npmrc });
|
|
14
|
-
const feedsWithPat = feeds.slice(); // create a copy of feeds
|
|
15
|
-
for (let i = 0; i < feeds.length; i++) {
|
|
16
|
-
const match = contents.toString().match(
|
|
17
|
-
// SHould match the URL from the user .npmrc
|
|
18
|
-
new RegExp(`${getFeedWithoutProtocol(feeds[i].feed)}:_password=(.*)`));
|
|
19
|
-
if (match) {
|
|
20
|
-
const [, base64password] = match;
|
|
21
|
-
const pat = decode(base64password);
|
|
22
|
-
feedsWithPat[i].pat = pat;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return feedsWithPat;
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
// user npmrc does not exist, or is invalid
|
|
29
|
-
return [];
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=pat.js.map
|
package/lib/npmrc/pat.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pat.js","sourceRoot":"","sources":["../../src/npmrc/pat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,EAAE,EAAuC,EAAE,EAAE;IAC7F,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5C,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,yBAAyB;QAE7D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK;YACrC,4CAA4C;YAC5C,IAAI,MAAM,CAAC,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CACtE,CAAC;YAEF,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,CAAC,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC;gBACjC,MAAM,GAAG,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;gBAEnC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,2CAA2C;QAC3C,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { NpmrcOrg } from "./get-repo-npmrc-ado-orgs.js";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} options
|
|
5
|
-
* @param {Record<string, string>} [options.organizationPatMap] Map of ADO Organization to packaging PAT for that org
|
|
6
|
-
* @param {boolean} [options.accept]
|
|
7
|
-
* @param {string} [options.npmrcFilePath]
|
|
8
|
-
* @param {boolean} [options.silent]
|
|
9
|
-
* @returnsshort
|
|
10
|
-
*/
|
|
11
|
-
export declare const setupNpmrc: ({ organizationPatMap, feeds, }: {
|
|
12
|
-
organizationPatMap: Record<string, string>;
|
|
13
|
-
feeds: NpmrcOrg[];
|
|
14
|
-
}) => Promise<void>;
|
|
15
|
-
export declare const setNpmrcPat: () => Promise<void>;
|
|
16
|
-
//# sourceMappingURL=set-npmrc-pat.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"set-npmrc-pat.d.ts","sourceRoot":"","sources":["../../src/npmrc/set-npmrc-pat.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAgC,MAAM,8BAA8B,CAAC;AAyEtF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,mCAGpB;IACD,kBAAkB,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,kBAgCA,CAAC;AAEF,eAAO,MAAM,WAAW,QAAa,QAAQ,IAAI,CAgBhD,CAAC"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { EOL } from "os";
|
|
3
|
-
import { generateNpmrcPat } from "./generate-npmrc-pat.js";
|
|
4
|
-
import { getRepoNpmrcAdoOrganizations } from "./get-repo-npmrc-ado-orgs.js";
|
|
5
|
-
import { getUserNPMRC, readNpmRC } from "./npmrc.js";
|
|
6
|
-
import { getFeedWithoutProtocol } from "../utils/get-feed-without-protocol.js";
|
|
7
|
-
// /**
|
|
8
|
-
// * URL for the user's PAT settings
|
|
9
|
-
// * @param { string } organization
|
|
10
|
-
// */
|
|
11
|
-
// const getTokenUrl = (organization: string) =>
|
|
12
|
-
// `https://dev.azure.com/${organization}/_usersSettings/tokens`;
|
|
13
|
-
/**
|
|
14
|
-
* Default user to be used in the .npmrc
|
|
15
|
-
*/
|
|
16
|
-
const defaultUser = "me";
|
|
17
|
-
/**
|
|
18
|
-
* Default email to be used in the .npmrc
|
|
19
|
-
*/
|
|
20
|
-
const defaultEmail = "me@example.com";
|
|
21
|
-
/**
|
|
22
|
-
* Create a base64 encoded string from a string
|
|
23
|
-
* @param {string} input
|
|
24
|
-
* @returns {string}
|
|
25
|
-
*/
|
|
26
|
-
const base64 = (input) => {
|
|
27
|
-
return Buffer.from(input).toString("base64");
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Create the user npmrc given an array of registry urls and a token
|
|
31
|
-
* @param {object} options
|
|
32
|
-
* @param {Array<import("../../utils/pat.js").NpmrcOrg> } options.feeds
|
|
33
|
-
* @param {string} options.existingNpmrc
|
|
34
|
-
* @returns {string}
|
|
35
|
-
*/
|
|
36
|
-
const createUserNpmrc = async ({ feeds, existingNpmrc }) => {
|
|
37
|
-
let newUserNpmRc = existingNpmrc;
|
|
38
|
-
if (newUserNpmRc.indexOf("Azure Artifacts Auth") === -1) {
|
|
39
|
-
newUserNpmRc = `# Generated by Azure Artifacts Auth${EOL}${newUserNpmRc}`;
|
|
40
|
-
}
|
|
41
|
-
for (const feed of feeds) {
|
|
42
|
-
const feedWithoutProtocol = "//" + getFeedWithoutProtocol(feed.feed);
|
|
43
|
-
let isAlreadyInNpmrc = newUserNpmRc.indexOf(feedWithoutProtocol) > -1;
|
|
44
|
-
if (isAlreadyInNpmrc) {
|
|
45
|
-
newUserNpmRc = newUserNpmRc.replace(new RegExp(`${feedWithoutProtocol}:_password\=(.*)`), `${feedWithoutProtocol}:_password=${feed.pat}`);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
const entry = [
|
|
49
|
-
`${feedWithoutProtocol}:username=${defaultUser}`,
|
|
50
|
-
`${feedWithoutProtocol}:email=${defaultEmail}`,
|
|
51
|
-
`${feedWithoutProtocol}:_password=${feed.pat}`,
|
|
52
|
-
"",
|
|
53
|
-
].join(EOL);
|
|
54
|
-
newUserNpmRc += entry + EOL;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return newUserNpmRc;
|
|
58
|
-
};
|
|
59
|
-
const userNpmrc = getUserNPMRC();
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
* @param {Object} options
|
|
63
|
-
* @param {Record<string, string>} [options.organizationPatMap] Map of ADO Organization to packaging PAT for that org
|
|
64
|
-
* @param {boolean} [options.accept]
|
|
65
|
-
* @param {string} [options.npmrcFilePath]
|
|
66
|
-
* @param {boolean} [options.silent]
|
|
67
|
-
* @returnsshort
|
|
68
|
-
*/
|
|
69
|
-
export const setupNpmrc = async function ({ organizationPatMap = {}, feeds, }) {
|
|
70
|
-
for (const feed of feeds) {
|
|
71
|
-
try {
|
|
72
|
-
let pat = organizationPatMap[feed.organization];
|
|
73
|
-
if (!pat) {
|
|
74
|
-
throw new Error(`No PAT found for ${feed.organization}`);
|
|
75
|
-
}
|
|
76
|
-
const b64Pat = base64(pat);
|
|
77
|
-
feed.pat = b64Pat;
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
throw new Error(`Error setting up npmrc for ${feed.organization} organization: ${e.message}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
let userNpmrcFile = "";
|
|
84
|
-
try {
|
|
85
|
-
userNpmrcFile = await readNpmRC({ npmrc: userNpmrc });
|
|
86
|
-
}
|
|
87
|
-
catch (e) {
|
|
88
|
-
/* No user .npmrc file, that's ok */
|
|
89
|
-
}
|
|
90
|
-
// const newnpmrc =
|
|
91
|
-
let newnpmrc = await createUserNpmrc({
|
|
92
|
-
existingNpmrc: userNpmrcFile,
|
|
93
|
-
feeds,
|
|
94
|
-
});
|
|
95
|
-
await fs.promises.writeFile(userNpmrc, newnpmrc);
|
|
96
|
-
};
|
|
97
|
-
export const setNpmrcPat = async () => {
|
|
98
|
-
const adoOrgs = await getRepoNpmrcAdoOrganizations();
|
|
99
|
-
// get a token for each feed
|
|
100
|
-
const organizationPatMap = {};
|
|
101
|
-
for (const adoOrg of adoOrgs) {
|
|
102
|
-
organizationPatMap[adoOrg.organization] = await generateNpmrcPat(adoOrg.organization, false);
|
|
103
|
-
}
|
|
104
|
-
await setupNpmrc({
|
|
105
|
-
organizationPatMap,
|
|
106
|
-
feeds: adoOrgs
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
//# sourceMappingURL=set-npmrc-pat.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"set-npmrc-pat.js","sourceRoot":"","sources":["../../src/npmrc/set-npmrc-pat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAY,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MA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CAAC,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,IAAmB,EAAE;IACnD,MAAM,OAAO,GAAG,MAAM,4BAA4B,EAAE,CAAC;IAErD,4BAA4B;IAC5B,MAAM,kBAAkB,GAA2B,EAAE,CAAC;IACtD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,kBAAkB,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,gBAAgB,CAC9D,MAAM,CAAC,YAAY,EACnB,KAAK,CACN,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,CAAC;QACf,kBAAkB;QAClB,KAAK,EAAE,OAAO;KACf,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/lib/telemetry/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export type TelemetryProperties = {
|
|
2
|
-
success: boolean;
|
|
3
|
-
automaticSuccess: boolean;
|
|
4
|
-
platform: string;
|
|
5
|
-
arch: string;
|
|
6
|
-
error: string;
|
|
7
|
-
};
|
|
8
|
-
export interface TelemetryClient {
|
|
9
|
-
LogEvent: (eventName: string, properties: Map<string, string>) => void;
|
|
10
|
-
flush(): void;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Logs an node-azure-auth event to telemetry.
|
|
14
|
-
*/
|
|
15
|
-
export declare const logTelemetry: (inputProperties: {
|
|
16
|
-
success?: boolean;
|
|
17
|
-
automaticSuccess?: boolean;
|
|
18
|
-
error?: string;
|
|
19
|
-
}, flush?: boolean, client?: TelemetryClient) => void;
|
|
20
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IACvE,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,oBACN;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,UACO,OAAO,WACN,eAAe,SAsBzB,CAAC"}
|
package/lib/telemetry/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { platform, arch } from "os";
|
|
2
|
-
import { isWsl } from "../utils/is-wsl.js";
|
|
3
|
-
;
|
|
4
|
-
/**
|
|
5
|
-
* Logs an node-azure-auth event to telemetry.
|
|
6
|
-
*/
|
|
7
|
-
export const logTelemetry = (inputProperties, flush, client) => {
|
|
8
|
-
const outputProperties = new Map();
|
|
9
|
-
outputProperties.set("success", inputProperties.success ? "true" : "false");
|
|
10
|
-
outputProperties.set("automaticSuccess", inputProperties.automaticSuccess ? "true" : "false");
|
|
11
|
-
outputProperties.set("error", inputProperties.error ? inputProperties.error : "");
|
|
12
|
-
outputProperties.set("platform", isWsl() ? "wsl" : platform());
|
|
13
|
-
outputProperties.set("arch", arch());
|
|
14
|
-
if (client) {
|
|
15
|
-
client.LogEvent("node-azure-auth", outputProperties);
|
|
16
|
-
if (flush) {
|
|
17
|
-
client.flush();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAa1C,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,eAIC,EACD,KAAe,EACf,MAAwB,EACxB,EAAE;IACF,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;IACnD,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAC5E,gBAAgB,CAAC,GAAG,CAClB,kBAAkB,EAClB,eAAe,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CACpD,CAAC;IACF,gBAAgB,CAAC,GAAG,CAClB,OAAO,EACP,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CACnD,CAAC;IACF,gBAAgB,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/D,gBAAgB,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAErC,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,QAAQ,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;QAErD,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
|
package/lib/utils/exec.d.ts
DELETED
package/lib/utils/exec.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAGnD,eAAO,MAAM,IAAI,4BAAmB,CAAC"}
|
package/lib/utils/exec.js
DELETED
package/lib/utils/exec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,CAAC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Given the feed url, get the name of the feed without the protocol ("https") at the beginning
|
|
3
|
-
* @param {string} feed
|
|
4
|
-
* @returns {string}
|
|
5
|
-
*/
|
|
6
|
-
export declare const getFeedWithoutProtocol: (feed: string) => string;
|
|
7
|
-
//# sourceMappingURL=get-feed-without-protocol.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-feed-without-protocol.d.ts","sourceRoot":"","sources":["../../src/utils/get-feed-without-protocol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,SAAU,MAAM,WAMlD,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Given the feed url, get the name of the feed without the protocol ("https") at the beginning
|
|
3
|
-
* @param {string} feed
|
|
4
|
-
* @returns {string}
|
|
5
|
-
*/
|
|
6
|
-
export const getFeedWithoutProtocol = (feed) => {
|
|
7
|
-
const feedUrl = new URL(feed);
|
|
8
|
-
const protocol = feedUrl.protocol; // will be something like "http:"
|
|
9
|
-
const protocolLength = protocol.length + 2; // we want to strip out the protocol, colon, and double slash
|
|
10
|
-
const feedWithoutProtocol = feedUrl.toString().slice(protocolLength);
|
|
11
|
-
return feedWithoutProtocol;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=get-feed-without-protocol.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-feed-without-protocol.js","sourceRoot":"","sources":["../../src/utils/get-feed-without-protocol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,IAAY,EAAE,EAAE;IACrD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,iCAAiC;IACpE,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,6DAA6D;IACzG,MAAM,mBAAmB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IACrE,OAAO,mBAAmB,CAAC;AAC7B,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-feed-without-protocol.test.d.ts","sourceRoot":"","sources":["../../src/utils/get-feed-without-protocol.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,EAA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AAkB,CAAC,CAAC;AACpE,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,iFAAiF,EAAE,GAAG,EAAE;IACzF,MAAM,+BAA+B,GAAG,sBAAsB,CAAC,kEAAkE,CAAC,CAAC;IACnI,MAAM,CAAC,+BAA+B,CAAC,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;AAC7G,CAAC,CAAC,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-organization-from-feed-url.d.ts","sourceRoot":"","sources":["../../src/utils/get-organization-from-feed-url.ts"],"names":[],"mappings":"AA+DA;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,YAAa,MAAM,gCAOzD,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
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
|
-
const parsedUrl = new URL(url);
|
|
27
|
-
const hostname = parsedUrl.hostname;
|
|
28
|
-
const pathname = parsedUrl.pathname;
|
|
29
|
-
// Check for new style URLs (dev.azure.com)
|
|
30
|
-
if (hostname.endsWith("dev.azure.com")) {
|
|
31
|
-
const pathSegments = pathname.split('/').filter(Boolean); // Remove empty strings from the split result
|
|
32
|
-
if (pathSegments.length >= 2) {
|
|
33
|
-
return {
|
|
34
|
-
organization: pathSegments[0],
|
|
35
|
-
project: pathSegments[1]
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
throw new Error("Not enough segments in path for a valid organization and project extraction.");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
// Check for old style URLs (visualstudio.com)
|
|
43
|
-
if (hostname.endsWith("visualstudio.com")) {
|
|
44
|
-
const subdomain = hostname.split('.')[0];
|
|
45
|
-
const pathSegments = pathname.split('/').filter(Boolean);
|
|
46
|
-
if (subdomain && pathSegments.length >= 1) {
|
|
47
|
-
return {
|
|
48
|
-
organization: subdomain,
|
|
49
|
-
project: pathSegments[0]
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
throw new Error("Not enough segments in path or missing subdomain for a valid organization and project extraction.");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// If the URL does not match expected formats
|
|
57
|
-
throw new Error("URL format not recognized or does not contain enough information.");
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
throw new Error("Invalid URL or unsupported format");
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Get the ADO Org for a npm feed
|
|
65
|
-
* @param {string} feedUrl URL of the feed to get the ADO organization from
|
|
66
|
-
* @param {string} [defaultOrg] Backup org in case it cannot be determined from the feed url
|
|
67
|
-
* @returns ADO Organization for the feed
|
|
68
|
-
*/
|
|
69
|
-
export const getOrganizationFromFeedUrl = (feedUrl, defaultOrg = "") => {
|
|
70
|
-
try {
|
|
71
|
-
const { organization } = extractAdoDetails(feedUrl);
|
|
72
|
-
return organization;
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
return defaultOrg;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
//# sourceMappingURL=get-organization-from-feed-url.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,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,CAA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-organization-from-feed-url.test.d.ts","sourceRoot":"","sources":["../../src/utils/get-organization-from-feed-url.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC,uEAAuE,CAAC,CAAC;IAElH,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,CAAC,uEAAuE,CAAC,CAAC;IAElH,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,CAAC,2DAA2D,CAAC,CAAC;IAEtG,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,CAAC,sEAAsE,CAAC,CAAC;IAEjH,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/lib/utils/is-wsl.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/lib/utils/is-wsl.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { release, platform } from "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
|
package/lib/utils/is-wsl.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-wsl.js","sourceRoot":"","sources":["../../src/utils/is-wsl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAEvC;;;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"}
|
package/lib/utils/request.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { RequestOptions } from "https";
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {import("http").RequestOptions} options
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare const makeRequest: (options: RequestOptions) => Promise<unknown>;
|
|
9
|
-
//# sourceMappingURL=request.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/utils/request.ts"],"names":[],"mappings":";AAAA,OAAc,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC9C;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAAmB,cAAc,qBAmCxD,CAAC"}
|
package/lib/utils/request.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import https from "https";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param {import("http").RequestOptions} options
|
|
5
|
-
* @returns
|
|
6
|
-
*/
|
|
7
|
-
export const makeRequest = async (options) => {
|
|
8
|
-
return new Promise((resolve, reject) => {
|
|
9
|
-
const req = https.request(options, (res) => {
|
|
10
|
-
let data = "";
|
|
11
|
-
let dataJson = {};
|
|
12
|
-
let ok = res.statusCode === 200;
|
|
13
|
-
res.on("data", (d) => {
|
|
14
|
-
data += d;
|
|
15
|
-
});
|
|
16
|
-
res.on("end", () => {
|
|
17
|
-
var _a;
|
|
18
|
-
if (data && ((_a = options === null || options === void 0 ? void 0 : options.headers) === null || _a === void 0 ? void 0 : _a.Accept) === "application/json") {
|
|
19
|
-
dataJson = JSON.parse(data.toString().trim());
|
|
20
|
-
}
|
|
21
|
-
if (ok) {
|
|
22
|
-
resolve(dataJson || data);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
if (dataJson) {
|
|
26
|
-
dataJson = { ...dataJson, statusCode: res.statusCode };
|
|
27
|
-
}
|
|
28
|
-
reject(dataJson || data || new Error(`Error code: ${res.statusCode}.`));
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
res.on("error", (/** @type {string} */ error) => {
|
|
32
|
-
reject(new Error(error));
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
req.end();
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=request.js.map
|
package/lib/utils/request.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/utils/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAC;AAC9C;;;;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,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACzC,IAAI,IAAI,GAAG,EAAE,CAAC;YACd,IAAI,QAAQ,GAAG,EAAE,CAAC;YAClB,IAAI,EAAE,GAAG,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC;YAEhC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;gBACnB,IAAI,IAAI,CAAC,CAAC;YACZ,CAAC,CAAC,CAAC;YAEH,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;;gBACjB,IAAI,IAAI,IAAI,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,0CAAE,MAAM,MAAK,kBAAkB,EAAE,CAAC;oBAC5D,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;gBAChD,CAAC;gBAED,IAAI,EAAE,EAAE,CAAC;oBACP,OAAO,CAAC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