@node-cli/npmrc 1.2.0 → 1.2.2
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/defaults.js +2 -2
- package/dist/defaults.js.map +1 -1
- package/dist/npmrc.js +3 -3
- package/dist/npmrc.js.map +1 -1
- package/dist/parse.js +3 -3
- package/dist/parse.js.map +1 -1
- package/dist/utilities/common.js +2 -2
- package/dist/utilities/common.js.map +1 -1
- package/dist/utilities/createProfile.js.map +1 -1
- package/dist/utilities/deleteProfile.js.map +1 -1
- package/dist/utilities/listProfiles.js +1 -1
- package/dist/utilities/listProfiles.js.map +1 -1
- package/dist/utilities/switchProfile.js +1 -1
- package/dist/utilities/switchProfile.js.map +1 -1
- package/dist/utilities/updateProfile.js +1 -1
- package/dist/utilities/updateProfile.js.map +1 -1
- package/package.json +14 -10
package/dist/defaults.js
CHANGED
package/dist/defaults.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["/*
|
|
1
|
+
{"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["/* v8 ignore start */\nexport const defaultFlags = {\n\tboring: false,\n\tverbose: false,\n};\n/* v8 ignore stop */\n"],"names":["defaultFlags","boring","verbose"],"mappings":"AAAA,mBAAmB,GACnB,OAAO,MAAMA,eAAe;IAC3BC,QAAQ;IACRC,SAAS;AACV,EAAE,CACF,kBAAkB"}
|
package/dist/npmrc.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/*
|
|
2
|
+
/* v8 ignore start */ import path from "node:path";
|
|
3
|
+
import { config } from "./parse.js";
|
|
3
4
|
import { createProfile } from "./utilities/createProfile.js";
|
|
4
5
|
import { deleteProfile } from "./utilities/deleteProfile.js";
|
|
5
6
|
import { listProfiles } from "./utilities/listProfiles.js";
|
|
6
|
-
import path from "node:path";
|
|
7
7
|
import { switchProfile } from "./utilities/switchProfile.js";
|
|
8
8
|
import { updateProfile } from "./utilities/updateProfile.js";
|
|
9
9
|
const HOME = process.env.HOME;
|
|
@@ -55,6 +55,6 @@ if (flags.list || !flags.version && !flags.help) {
|
|
|
55
55
|
});
|
|
56
56
|
process.exit(exitFlag);
|
|
57
57
|
}
|
|
58
|
-
showHelp();
|
|
58
|
+
showHelp(); /* v8 ignore stop */
|
|
59
59
|
|
|
60
60
|
//# sourceMappingURL=npmrc.js.map
|
package/dist/npmrc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/npmrc.ts"],"sourcesContent":["#!/usr/bin/env node\n/*
|
|
1
|
+
{"version":3,"sources":["../src/npmrc.ts"],"sourcesContent":["#!/usr/bin/env node\n/* v8 ignore start */\n\nimport path from \"node:path\";\nimport { config } from \"./parse.js\";\nimport { createProfile } from \"./utilities/createProfile.js\";\nimport { deleteProfile } from \"./utilities/deleteProfile.js\";\nimport { listProfiles } from \"./utilities/listProfiles.js\";\nimport { switchProfile } from \"./utilities/switchProfile.js\";\nimport { updateProfile } from \"./utilities/updateProfile.js\";\n\nconst HOME = process.env.HOME;\nconst NPMRC_STORE = path.join(HOME, \".envtools/npmrcs\");\nconst NPMRC_STORE_CONFIG = path.join(HOME, \"/.envtools/npmrcs.json\");\n\nconst { parameters, flags, showHelp } = config;\n\nif (flags.create && parameters !== undefined) {\n\tconst exitFlag = await createProfile({\n\t\tflags,\n\t\tstoreConfig: NPMRC_STORE_CONFIG,\n\t\tstoreLocation: NPMRC_STORE,\n\t\tprofileName: parameters[\"0\"],\n\t\thomeLocation: HOME,\n\t});\n\tprocess.exit(exitFlag);\n}\n\nif (flags.update && parameters !== undefined) {\n\tconst exitFlag = await updateProfile({\n\t\tflags,\n\t\tstoreConfig: NPMRC_STORE_CONFIG,\n\t\tstoreLocation: NPMRC_STORE,\n\t\thomeLocation: HOME,\n\t});\n\tprocess.exit(exitFlag);\n}\n\nif (flags.delete && parameters !== undefined) {\n\tconst exitFlag = await deleteProfile({\n\t\tflags,\n\t\tstoreConfig: NPMRC_STORE_CONFIG,\n\t\tstoreLocation: NPMRC_STORE,\n\t\tprofileName: parameters[\"0\"],\n\t});\n\tprocess.exit(exitFlag);\n}\n\nif (parameters !== undefined && parameters[\"0\"] !== undefined) {\n\tconst exitFlag = await switchProfile({\n\t\tflags,\n\t\tstoreConfig: NPMRC_STORE_CONFIG,\n\t\tstoreLocation: NPMRC_STORE,\n\t\tprofileName: parameters[\"0\"],\n\t\thomeLocation: HOME,\n\t});\n\tprocess.exit(exitFlag);\n}\n\nif (flags.list || (!flags.version && !flags.help)) {\n\tconst exitFlag = await listProfiles({\n\t\tflags,\n\t\tstoreConfig: NPMRC_STORE_CONFIG,\n\t});\n\tprocess.exit(exitFlag);\n}\n\nshowHelp();\n/* v8 ignore stop */\n"],"names":["path","config","createProfile","deleteProfile","listProfiles","switchProfile","updateProfile","HOME","process","env","NPMRC_STORE","join","NPMRC_STORE_CONFIG","parameters","flags","showHelp","create","undefined","exitFlag","storeConfig","storeLocation","profileName","homeLocation","exit","update","delete","list","version","help"],"mappings":";AACA,mBAAmB,GAEnB,OAAOA,UAAU,YAAY;AAC7B,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,aAAa,QAAQ,+BAA+B;AAC7D,SAASC,aAAa,QAAQ,+BAA+B;AAC7D,SAASC,YAAY,QAAQ,8BAA8B;AAC3D,SAASC,aAAa,QAAQ,+BAA+B;AAC7D,SAASC,aAAa,QAAQ,+BAA+B;AAE7D,MAAMC,OAAOC,QAAQC,GAAG,CAACF,IAAI;AAC7B,MAAMG,cAAcV,KAAKW,IAAI,CAACJ,MAAM;AACpC,MAAMK,qBAAqBZ,KAAKW,IAAI,CAACJ,MAAM;AAE3C,MAAM,EAAEM,UAAU,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGd;AAExC,IAAIa,MAAME,MAAM,IAAIH,eAAeI,WAAW;IAC7C,MAAMC,WAAW,MAAMhB,cAAc;QACpCY;QACAK,aAAaP;QACbQ,eAAeV;QACfW,aAAaR,UAAU,CAAC,IAAI;QAC5BS,cAAcf;IACf;IACAC,QAAQe,IAAI,CAACL;AACd;AAEA,IAAIJ,MAAMU,MAAM,IAAIX,eAAeI,WAAW;IAC7C,MAAMC,WAAW,MAAMZ,cAAc;QACpCQ;QACAK,aAAaP;QACbQ,eAAeV;QACfY,cAAcf;IACf;IACAC,QAAQe,IAAI,CAACL;AACd;AAEA,IAAIJ,MAAMW,MAAM,IAAIZ,eAAeI,WAAW;IAC7C,MAAMC,WAAW,MAAMf,cAAc;QACpCW;QACAK,aAAaP;QACbQ,eAAeV;QACfW,aAAaR,UAAU,CAAC,IAAI;IAC7B;IACAL,QAAQe,IAAI,CAACL;AACd;AAEA,IAAIL,eAAeI,aAAaJ,UAAU,CAAC,IAAI,KAAKI,WAAW;IAC9D,MAAMC,WAAW,MAAMb,cAAc;QACpCS;QACAK,aAAaP;QACbQ,eAAeV;QACfW,aAAaR,UAAU,CAAC,IAAI;QAC5BS,cAAcf;IACf;IACAC,QAAQe,IAAI,CAACL;AACd;AAEA,IAAIJ,MAAMY,IAAI,IAAK,CAACZ,MAAMa,OAAO,IAAI,CAACb,MAAMc,IAAI,EAAG;IAClD,MAAMV,WAAW,MAAMd,aAAa;QACnCU;QACAK,aAAaP;IACd;IACAJ,QAAQe,IAAI,CAACL;AACd;AAEAH,YACA,kBAAkB"}
|
package/dist/parse.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
/* v8 ignore start */ import { parser } from "@node-cli/parser";
|
|
1
2
|
import { defaultFlags } from "./defaults.js";
|
|
2
|
-
|
|
3
|
-
/* istanbul ignore next */ export const config = parser({
|
|
3
|
+
/* v8 ignore next 80 */ export const config = parser({
|
|
4
4
|
meta: import.meta,
|
|
5
5
|
examples: [
|
|
6
6
|
{
|
|
@@ -78,6 +78,6 @@ import { parser } from "@node-cli/parser";
|
|
|
78
78
|
}
|
|
79
79
|
],
|
|
80
80
|
usage: "npmrc [options] [profile]"
|
|
81
|
-
});
|
|
81
|
+
}); /* v8 ignore stop */
|
|
82
82
|
|
|
83
83
|
//# sourceMappingURL=parse.js.map
|
package/dist/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/parse.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/parse.ts"],"sourcesContent":["/* v8 ignore start */\nimport { parser } from \"@node-cli/parser\";\nimport { defaultFlags } from \"./defaults.js\";\n\nexport type Parameters = {\n\t[\"0\"]?: string;\n};\nexport type Flags = {\n\tverbose?: boolean;\n\tdelete?: boolean;\n\tcreate?: boolean;\n\tlist?: boolean;\n\tupdate?: boolean;\n\tboring?: boolean;\n\thelp?: boolean;\n\tversion?: boolean;\n};\nexport type Configuration = {\n\tflags?: Flags;\n\tparameters?: Parameters;\n\tshowHelp?: () => void;\n};\n\n/* v8 ignore next 80 */\nexport const config: Configuration = parser({\n\tmeta: import.meta,\n\texamples: [\n\t\t{\n\t\t\tcommand: \"npmrc -l\",\n\t\t\tcomment: \"## List existing profiles\",\n\t\t},\n\t\t{\n\t\t\tcommand: \"npmrc -c [name]\",\n\t\t\tcomment: \"## Create a profile\",\n\t\t},\n\t\t{\n\t\t\tcommand: \"npmrc [name]\",\n\t\t\tcomment: \"## Switch to an existing profile\",\n\t\t},\n\t\t{\n\t\t\tcommand: \"npmrc -d [name]\",\n\t\t\tcomment: \"## Delete an existing profile\",\n\t\t},\n\t],\n\tflags: {\n\t\tverbose: {\n\t\t\tshortFlag: \"V\",\n\t\t\tdescription: \"Output debugging information\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tdelete: {\n\t\t\tshortFlag: \"d\",\n\t\t\tdescription: \"Delete a profile\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tcreate: {\n\t\t\tshortFlag: \"c\",\n\t\t\tdescription: \"Create a new profile\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tlist: {\n\t\t\tshortFlag: \"l\",\n\t\t\tdescription: \"List all profiles\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tupdate: {\n\t\t\tshortFlag: \"u\",\n\t\t\tdescription: \"Update the current profile\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tboring: {\n\t\t\tshortFlag: \"b\",\n\t\t\tdefault: defaultFlags.boring,\n\t\t\tdescription: \"Do not use color output\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\thelp: {\n\t\t\tshortFlag: \"h\",\n\t\t\tdescription: \"Display help instructions\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tversion: {\n\t\t\tshortFlag: \"v\",\n\t\t\tdescription: \"Output the current version\",\n\t\t\ttype: \"boolean\",\n\t\t},\n\t},\n\tparameters: {\n\t\tprofile: {\n\t\t\tdescription: \"profile name\",\n\t\t},\n\t},\n\trestrictions: [\n\t\t{\n\t\t\texit: 1,\n\t\t\tmessage: \"To create a profile, you must provide a profile name\",\n\t\t\ttest: (flags?: Flags, parameters?: Parameters) => {\n\t\t\t\treturn flags.create && (!parameters || !parameters[\"0\"]);\n\t\t\t},\n\t\t},\n\t],\n\tusage: \"npmrc [options] [profile]\",\n});\n/* v8 ignore stop */\n"],"names":["parser","defaultFlags","config","meta","examples","command","comment","flags","verbose","shortFlag","description","type","delete","create","list","update","boring","default","help","version","parameters","profile","restrictions","exit","message","test","usage"],"mappings":"AAAA,mBAAmB,GACnB,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,YAAY,QAAQ,gBAAgB;AAqB7C,qBAAqB,GACrB,OAAO,MAAMC,SAAwBF,OAAO;IAC3CG,MAAM;IACNC,UAAU;QACT;YACCC,SAAS;YACTC,SAAS;QACV;QACA;YACCD,SAAS;YACTC,SAAS;QACV;QACA;YACCD,SAAS;YACTC,SAAS;QACV;QACA;YACCD,SAAS;YACTC,SAAS;QACV;KACA;IACDC,OAAO;QACNC,SAAS;YACRC,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;QACAC,QAAQ;YACPH,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;QACAE,QAAQ;YACPJ,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;QACAG,MAAM;YACLL,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;QACAI,QAAQ;YACPN,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;QACAK,QAAQ;YACPP,WAAW;YACXQ,SAAShB,aAAae,MAAM;YAC5BN,aAAa;YACbC,MAAM;QACP;QACAO,MAAM;YACLT,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;QACAQ,SAAS;YACRV,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;IACD;IACAS,YAAY;QACXC,SAAS;YACRX,aAAa;QACd;IACD;IACAY,cAAc;QACb;YACCC,MAAM;YACNC,SAAS;YACTC,MAAM,CAAClB,OAAea;gBACrB,OAAOb,MAAMM,MAAM,IAAK,CAAA,CAACO,cAAc,CAACA,UAAU,CAAC,IAAI,AAAD;YACvD;QACD;KACA;IACDM,OAAO;AACR,GAAG,CACH,kBAAkB"}
|
package/dist/utilities/common.js
CHANGED
|
@@ -21,13 +21,13 @@ export const formatRegistries = (registries)=>{
|
|
|
21
21
|
try {
|
|
22
22
|
const jsonObject = JSON.parse(`{${jsonLine}}`);
|
|
23
23
|
return jsonObject;
|
|
24
|
-
} catch {
|
|
24
|
+
/* v8 ignore start */ } catch {
|
|
25
25
|
// nothing to declare officer
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
// eslint-disable-next-line unicorn/no-null
|
|
29
29
|
return null;
|
|
30
|
-
}).filter(Boolean); // remove undefined values
|
|
30
|
+
/* v8 ignore stop */ }).filter(Boolean); // remove undefined values
|
|
31
31
|
for (const jsonObject of jsonObjects){
|
|
32
32
|
messages.push(` • ${Object.keys(jsonObject)}:`, ` ${kleur.underline().grey(`${Object.values(jsonObject)}`)}`);
|
|
33
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/common.ts"],"sourcesContent":["import kleur from \"kleur\";\n\nexport const GET_REGISTRY_CMD =\n\t'npm config list -l -g -json | grep registry\\\\\"';\n\nexport const formatRegistries = (registries: string) => {\n\t/**\n\t * We receive this kind of output:\n\t * [\n\t * ' \"@node-cli:registry\": \"https://other-registry.npmjs.org/\"',\n\t * ' \"registry\": \"https://registry.npmjs.org/\"',\n\t * ]\n\t * And we need convert that to a JSON object that looks like that:\n\t * [\n\t * { \"@node-cli:registry\": \"https://other-registry.npmjs.org/\" },\n\t * { \"registry\": \"https://registry.npmjs.org/\" },\n\t * ]\n\t */\n\tconst messages = [];\n\tconst stdoutLines = registries.split(\"\\n\");\n\tconst jsonObjects = stdoutLines\n\t\t.map((line) => {\n\t\t\tconst trimmedLine = line.trim();\n\t\t\tif (trimmedLine.startsWith('\"') && trimmedLine.endsWith(\",\")) {\n\t\t\t\tconst jsonLine = trimmedLine.slice(0, -1); // remove trailing comma\n\t\t\t\ttry {\n\t\t\t\t\tconst jsonObject = JSON.parse(`{${jsonLine}}`);\n\t\t\t\t\treturn jsonObject;\n\t\t\t\t} catch {\n\t\t\t\t\t// nothing to declare officer\n\t\t\t\t}\n\t\t\t}\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\treturn null;\n\t\t})\n\t\t.filter(Boolean); // remove undefined values\n\n\tfor (const jsonObject of jsonObjects) {\n\t\tmessages.push(\n\t\t\t` • ${Object.keys(jsonObject)}:`,\n\t\t\t` ${kleur.underline().grey(`${Object.values(jsonObject)}`)}`,\n\t\t);\n\t}\n\treturn messages;\n};\n"],"names":["kleur","GET_REGISTRY_CMD","formatRegistries","registries","messages","stdoutLines","split","jsonObjects","map","line","trimmedLine","trim","startsWith","endsWith","jsonLine","slice","jsonObject","JSON","parse","filter","Boolean","push","Object","keys","underline","grey","values"],"mappings":"AAAA,OAAOA,WAAW,QAAQ;AAE1B,OAAO,MAAMC,mBACZ,iDAAiD;AAElD,OAAO,MAAMC,mBAAmB,CAACC;IAChC;;;;;;;;;;;EAWC,GACD,MAAMC,WAAW,EAAE;IACnB,MAAMC,cAAcF,WAAWG,KAAK,CAAC;IACrC,MAAMC,cAAcF,YAClBG,GAAG,CAAC,CAACC;QACL,MAAMC,cAAcD,KAAKE,IAAI;QAC7B,IAAID,YAAYE,UAAU,CAAC,QAAQF,YAAYG,QAAQ,CAAC,MAAM;YAC7D,MAAMC,WAAWJ,YAAYK,KAAK,CAAC,GAAG,CAAC,IAAI,wBAAwB;YACnE,IAAI;gBACH,MAAMC,aAAaC,KAAKC,KAAK,CAAC,CAAC,CAAC,EAAEJ,SAAS,CAAC,CAAC;gBAC7C,OAAOE;
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/common.ts"],"sourcesContent":["import kleur from \"kleur\";\n\nexport const GET_REGISTRY_CMD =\n\t'npm config list -l -g -json | grep registry\\\\\"';\n\nexport const formatRegistries = (registries: string) => {\n\t/**\n\t * We receive this kind of output:\n\t * [\n\t * ' \"@node-cli:registry\": \"https://other-registry.npmjs.org/\"',\n\t * ' \"registry\": \"https://registry.npmjs.org/\"',\n\t * ]\n\t * And we need convert that to a JSON object that looks like that:\n\t * [\n\t * { \"@node-cli:registry\": \"https://other-registry.npmjs.org/\" },\n\t * { \"registry\": \"https://registry.npmjs.org/\" },\n\t * ]\n\t */\n\tconst messages = [];\n\tconst stdoutLines = registries.split(\"\\n\");\n\tconst jsonObjects = stdoutLines\n\t\t.map((line) => {\n\t\t\tconst trimmedLine = line.trim();\n\t\t\tif (trimmedLine.startsWith('\"') && trimmedLine.endsWith(\",\")) {\n\t\t\t\tconst jsonLine = trimmedLine.slice(0, -1); // remove trailing comma\n\t\t\t\ttry {\n\t\t\t\t\tconst jsonObject = JSON.parse(`{${jsonLine}}`);\n\t\t\t\t\treturn jsonObject;\n\t\t\t\t\t/* v8 ignore start */\n\t\t\t\t} catch {\n\t\t\t\t\t// nothing to declare officer\n\t\t\t\t}\n\t\t\t}\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\treturn null;\n\t\t\t/* v8 ignore stop */\n\t\t})\n\t\t.filter(Boolean); // remove undefined values\n\n\tfor (const jsonObject of jsonObjects) {\n\t\tmessages.push(\n\t\t\t` • ${Object.keys(jsonObject)}:`,\n\t\t\t` ${kleur.underline().grey(`${Object.values(jsonObject)}`)}`,\n\t\t);\n\t}\n\treturn messages;\n};\n"],"names":["kleur","GET_REGISTRY_CMD","formatRegistries","registries","messages","stdoutLines","split","jsonObjects","map","line","trimmedLine","trim","startsWith","endsWith","jsonLine","slice","jsonObject","JSON","parse","filter","Boolean","push","Object","keys","underline","grey","values"],"mappings":"AAAA,OAAOA,WAAW,QAAQ;AAE1B,OAAO,MAAMC,mBACZ,iDAAiD;AAElD,OAAO,MAAMC,mBAAmB,CAACC;IAChC;;;;;;;;;;;EAWC,GACD,MAAMC,WAAW,EAAE;IACnB,MAAMC,cAAcF,WAAWG,KAAK,CAAC;IACrC,MAAMC,cAAcF,YAClBG,GAAG,CAAC,CAACC;QACL,MAAMC,cAAcD,KAAKE,IAAI;QAC7B,IAAID,YAAYE,UAAU,CAAC,QAAQF,YAAYG,QAAQ,CAAC,MAAM;YAC7D,MAAMC,WAAWJ,YAAYK,KAAK,CAAC,GAAG,CAAC,IAAI,wBAAwB;YACnE,IAAI;gBACH,MAAMC,aAAaC,KAAKC,KAAK,CAAC,CAAC,CAAC,EAAEJ,SAAS,CAAC,CAAC;gBAC7C,OAAOE;YACP,mBAAmB,GACpB,EAAE,OAAM;YACP,6BAA6B;YAC9B;QACD;QACA,2CAA2C;QAC3C,OAAO;IACP,kBAAkB,GACnB,GACCG,MAAM,CAACC,UAAU,0BAA0B;IAE7C,KAAK,MAAMJ,cAAcT,YAAa;QACrCH,SAASiB,IAAI,CACZ,CAAC,GAAG,EAAEC,OAAOC,IAAI,CAACP,YAAY,CAAC,CAAC,EAChC,CAAC,IAAI,EAAEhB,MAAMwB,SAAS,GAAGC,IAAI,CAAC,GAAGH,OAAOI,MAAM,CAACV,aAAa,GAAG;IAEjE;IACA,OAAOZ;AACR,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/createProfile.ts"],"sourcesContent":["import { Logger } from \"@node-cli/logger\";\nimport fs from \"fs-extra\";\n\nexport const createProfile = async ({\n\tflags,\n\tstoreConfig,\n\tstoreLocation,\n\tprofileName,\n\thomeLocation,\n}) => {\n\tconst logger = new Logger({\n\t\tboring: process.env.NODE_ENV === \"test\" || flags.boring,\n\t});\n\n\tlet profiles = { available: [], enabled: undefined };\n\tawait fs.ensureFile(storeConfig);\n\ttry {\n\t\t// if the profile already exists, do nothing\n\t\tprofiles = await fs.readJson(storeConfig);\n\t\tif (profiles.available.includes(profileName)) {\n\t\t\tlogger.warn(`Profile '${profileName}' already exists...`);\n\t\t\treturn 0;\n\t\t}\n\t} catch {\n\t\t// ignoring error since we are going to create the file\n\t}\n\n\t/**\n\t * If the profile does not exist, create a folder named as\n\t * the profile under the storeLocation folder, with the\n\t * existing npmrc / yarnrc files.\n\t */\n\tawait fs.ensureDir(`${storeLocation}/${profileName}`);\n\t// copy the existing npmrc / yarnrc files to the new folder\n\tconst NPMRC = `${homeLocation}/.npmrc`;\n\tconst YARNRC = `${homeLocation}/.yarnrc`;\n\tif (await fs.pathExists(YARNRC)) {\n\t\tawait fs.copy(YARNRC, `${storeLocation}/${profileName}/yarnrc`);\n\t}\n\tif (await fs.pathExists(NPMRC)) {\n\t\tawait fs.copy(NPMRC, `${storeLocation}/${profileName}/npmrc`);\n\t}\n\t// then add the profile to the configuration file\n\tconst newProfiles = {\n\t\tavailable: [...profiles.available, profileName],\n\t\tenabled: profiles.enabled ?? profileName,\n\t};\n\tawait fs.writeJson(storeConfig, newProfiles, { spaces: 2 });\n\tlogger.printBox(`Profile '${profileName}' created`, {\n\t\ttextAlignment: \"left\",\n\t\ttitle: \"Profiles\",\n\t\tborderColor: \"blue\",\n\t});\n\treturn 0;\n};\n"],"names":["Logger","fs","createProfile","flags","storeConfig","storeLocation","profileName","homeLocation","logger","boring","process","env","NODE_ENV","profiles","available","enabled","undefined","ensureFile","readJson","includes","warn","ensureDir","NPMRC","YARNRC","pathExists","copy","newProfiles","writeJson","spaces","printBox","textAlignment","title","borderColor"],"mappings":"AAAA,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,QAAQ,WAAW;AAE1B,OAAO,MAAMC,gBAAgB,OAAO,EACnCC,KAAK,EACLC,WAAW,EACXC,aAAa,EACbC,WAAW,EACXC,YAAY,EACZ;IACA,MAAMC,SAAS,IAAIR,OAAO;QACzBS,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK,UAAUT,MAAMM,MAAM;IACxD;IAEA,IAAII,WAAW;QAAEC,WAAW,EAAE;QAAEC,SAASC;IAAU;IACnD,MAAMf,GAAGgB,UAAU,CAACb;IACpB,IAAI;QACH,4CAA4C;QAC5CS,WAAW,MAAMZ,GAAGiB,QAAQ,CAACd;QAC7B,IAAIS,SAASC,SAAS,CAACK,QAAQ,CAACb,cAAc;YAC7CE,OAAOY,IAAI,CAAC,CAAC,SAAS,EAAEd,YAAY,mBAAmB,CAAC;YACxD,OAAO;QACR;IACD,EAAE,OAAM;IACP,uDAAuD;IACxD;IAEA;;;;EAIC,GACD,MAAML,GAAGoB,SAAS,CAAC,
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/createProfile.ts"],"sourcesContent":["import { Logger } from \"@node-cli/logger\";\nimport fs from \"fs-extra\";\n\nexport const createProfile = async ({\n\tflags,\n\tstoreConfig,\n\tstoreLocation,\n\tprofileName,\n\thomeLocation,\n}) => {\n\tconst logger = new Logger({\n\t\tboring: process.env.NODE_ENV === \"test\" || flags.boring,\n\t});\n\n\tlet profiles = { available: [], enabled: undefined };\n\tawait fs.ensureFile(storeConfig);\n\ttry {\n\t\t// if the profile already exists, do nothing\n\t\tprofiles = await fs.readJson(storeConfig);\n\t\tif (profiles.available.includes(profileName)) {\n\t\t\tlogger.warn(`Profile '${profileName}' already exists...`);\n\t\t\treturn 0;\n\t\t}\n\t} catch {\n\t\t// ignoring error since we are going to create the file\n\t}\n\n\t/**\n\t * If the profile does not exist, create a folder named as\n\t * the profile under the storeLocation folder, with the\n\t * existing npmrc / yarnrc files.\n\t */\n\tawait fs.ensureDir(`${storeLocation}/${profileName}`);\n\t// copy the existing npmrc / yarnrc files to the new folder\n\tconst NPMRC = `${homeLocation}/.npmrc`;\n\tconst YARNRC = `${homeLocation}/.yarnrc`;\n\tif (await fs.pathExists(YARNRC)) {\n\t\tawait fs.copy(YARNRC, `${storeLocation}/${profileName}/yarnrc`);\n\t}\n\tif (await fs.pathExists(NPMRC)) {\n\t\tawait fs.copy(NPMRC, `${storeLocation}/${profileName}/npmrc`);\n\t}\n\t// then add the profile to the configuration file\n\tconst newProfiles = {\n\t\tavailable: [...profiles.available, profileName],\n\t\tenabled: profiles.enabled ?? profileName,\n\t};\n\tawait fs.writeJson(storeConfig, newProfiles, { spaces: 2 });\n\tlogger.printBox(`Profile '${profileName}' created`, {\n\t\ttextAlignment: \"left\",\n\t\ttitle: \"Profiles\",\n\t\tborderColor: \"blue\",\n\t});\n\treturn 0;\n};\n"],"names":["Logger","fs","createProfile","flags","storeConfig","storeLocation","profileName","homeLocation","logger","boring","process","env","NODE_ENV","profiles","available","enabled","undefined","ensureFile","readJson","includes","warn","ensureDir","NPMRC","YARNRC","pathExists","copy","newProfiles","writeJson","spaces","printBox","textAlignment","title","borderColor"],"mappings":"AAAA,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,QAAQ,WAAW;AAE1B,OAAO,MAAMC,gBAAgB,OAAO,EACnCC,KAAK,EACLC,WAAW,EACXC,aAAa,EACbC,WAAW,EACXC,YAAY,EACZ;IACA,MAAMC,SAAS,IAAIR,OAAO;QACzBS,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK,UAAUT,MAAMM,MAAM;IACxD;IAEA,IAAII,WAAW;QAAEC,WAAW,EAAE;QAAEC,SAASC;IAAU;IACnD,MAAMf,GAAGgB,UAAU,CAACb;IACpB,IAAI;QACH,4CAA4C;QAC5CS,WAAW,MAAMZ,GAAGiB,QAAQ,CAACd;QAC7B,IAAIS,SAASC,SAAS,CAACK,QAAQ,CAACb,cAAc;YAC7CE,OAAOY,IAAI,CAAC,CAAC,SAAS,EAAEd,YAAY,mBAAmB,CAAC;YACxD,OAAO;QACR;IACD,EAAE,OAAM;IACP,uDAAuD;IACxD;IAEA;;;;EAIC,GACD,MAAML,GAAGoB,SAAS,CAAC,GAAGhB,cAAc,CAAC,EAAEC,aAAa;IACpD,2DAA2D;IAC3D,MAAMgB,QAAQ,GAAGf,aAAa,OAAO,CAAC;IACtC,MAAMgB,SAAS,GAAGhB,aAAa,QAAQ,CAAC;IACxC,IAAI,MAAMN,GAAGuB,UAAU,CAACD,SAAS;QAChC,MAAMtB,GAAGwB,IAAI,CAACF,QAAQ,GAAGlB,cAAc,CAAC,EAAEC,YAAY,OAAO,CAAC;IAC/D;IACA,IAAI,MAAML,GAAGuB,UAAU,CAACF,QAAQ;QAC/B,MAAMrB,GAAGwB,IAAI,CAACH,OAAO,GAAGjB,cAAc,CAAC,EAAEC,YAAY,MAAM,CAAC;IAC7D;IACA,iDAAiD;IACjD,MAAMoB,cAAc;QACnBZ,WAAW;eAAID,SAASC,SAAS;YAAER;SAAY;QAC/CS,SAASF,SAASE,OAAO,IAAIT;IAC9B;IACA,MAAML,GAAG0B,SAAS,CAACvB,aAAasB,aAAa;QAAEE,QAAQ;IAAE;IACzDpB,OAAOqB,QAAQ,CAAC,CAAC,SAAS,EAAEvB,YAAY,SAAS,CAAC,EAAE;QACnDwB,eAAe;QACfC,OAAO;QACPC,aAAa;IACd;IACA,OAAO;AACR,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/deleteProfile.ts"],"sourcesContent":["import { Logger } from \"@node-cli/logger\";\nimport fs from \"fs-extra\";\n\nexport const deleteProfile = async ({\n\tflags,\n\tprofileName,\n\tstoreConfig,\n\tstoreLocation,\n}) => {\n\tconst logger = new Logger({\n\t\tboring: process.env.NODE_ENV === \"test\" || flags.boring,\n\t});\n\n\ttry {\n\t\tconst profiles = await fs.readJson(storeConfig);\n\t\tif (!profiles.available.includes(profileName)) {\n\t\t\tlogger.error(`Profile '${profileName}' does not exist`);\n\t\t\treturn 1;\n\t\t}\n\t\t// if the profile is enabled, do nothing\n\t\tif (profiles.enabled === profileName) {\n\t\t\tlogger.error(`Profile '${profileName}' is currently active`);\n\t\t\treturn 1;\n\t\t}\n\t\t// if profile exists, delete it by removing the profile folder\n\t\tawait fs.remove(`${storeLocation}/${profileName}`);\n\t\t// then remove the profile from the configuration file\n\t\tconst newProfiles = {\n\t\t\tavailable: profiles.available.filter(\n\t\t\t\t(profile: any) => profile !== profileName,\n\t\t\t),\n\t\t\tenabled: profiles.enabled,\n\t\t};\n\t\tawait fs.writeJson(storeConfig, newProfiles, { spaces: 2 });\n\t\tlogger.printBox(`Profile '${profileName}' deleted`, {\n\t\t\ttextAlignment: \"left\",\n\t\t\ttitle: \"Profiles\",\n\t\t\tborderColor: \"blue\",\n\t\t});\n\t\treturn 0;\n\t} catch (error) {\n\t\tif (flags.verbose) {\n\t\t\tlogger.log(error);\n\t\t}\n\t\tlogger.error(\"Could not delete profile\");\n\t\treturn 1;\n\t}\n};\n"],"names":["Logger","fs","deleteProfile","flags","profileName","storeConfig","storeLocation","logger","boring","process","env","NODE_ENV","profiles","readJson","available","includes","error","enabled","remove","newProfiles","filter","profile","writeJson","spaces","printBox","textAlignment","title","borderColor","verbose","log"],"mappings":"AAAA,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,QAAQ,WAAW;AAE1B,OAAO,MAAMC,gBAAgB,OAAO,EACnCC,KAAK,EACLC,WAAW,EACXC,WAAW,EACXC,aAAa,EACb;IACA,MAAMC,SAAS,IAAIP,OAAO;QACzBQ,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK,UAAUR,MAAMK,MAAM;IACxD;IAEA,IAAI;QACH,MAAMI,WAAW,MAAMX,GAAGY,QAAQ,CAACR;QACnC,IAAI,CAACO,SAASE,SAAS,CAACC,QAAQ,CAACX,cAAc;YAC9CG,OAAOS,KAAK,CAAC,CAAC,SAAS,EAAEZ,YAAY,gBAAgB,CAAC;YACtD,OAAO;QACR;QACA,wCAAwC;QACxC,IAAIQ,SAASK,OAAO,KAAKb,aAAa;YACrCG,OAAOS,KAAK,CAAC,CAAC,SAAS,EAAEZ,YAAY,qBAAqB,CAAC;YAC3D,OAAO;QACR;QACA,8DAA8D;QAC9D,MAAMH,GAAGiB,MAAM,CAAC,
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/deleteProfile.ts"],"sourcesContent":["import { Logger } from \"@node-cli/logger\";\nimport fs from \"fs-extra\";\n\nexport const deleteProfile = async ({\n\tflags,\n\tprofileName,\n\tstoreConfig,\n\tstoreLocation,\n}) => {\n\tconst logger = new Logger({\n\t\tboring: process.env.NODE_ENV === \"test\" || flags.boring,\n\t});\n\n\ttry {\n\t\tconst profiles = await fs.readJson(storeConfig);\n\t\tif (!profiles.available.includes(profileName)) {\n\t\t\tlogger.error(`Profile '${profileName}' does not exist`);\n\t\t\treturn 1;\n\t\t}\n\t\t// if the profile is enabled, do nothing\n\t\tif (profiles.enabled === profileName) {\n\t\t\tlogger.error(`Profile '${profileName}' is currently active`);\n\t\t\treturn 1;\n\t\t}\n\t\t// if profile exists, delete it by removing the profile folder\n\t\tawait fs.remove(`${storeLocation}/${profileName}`);\n\t\t// then remove the profile from the configuration file\n\t\tconst newProfiles = {\n\t\t\tavailable: profiles.available.filter(\n\t\t\t\t(profile: any) => profile !== profileName,\n\t\t\t),\n\t\t\tenabled: profiles.enabled,\n\t\t};\n\t\tawait fs.writeJson(storeConfig, newProfiles, { spaces: 2 });\n\t\tlogger.printBox(`Profile '${profileName}' deleted`, {\n\t\t\ttextAlignment: \"left\",\n\t\t\ttitle: \"Profiles\",\n\t\t\tborderColor: \"blue\",\n\t\t});\n\t\treturn 0;\n\t} catch (error) {\n\t\tif (flags.verbose) {\n\t\t\tlogger.log(error);\n\t\t}\n\t\tlogger.error(\"Could not delete profile\");\n\t\treturn 1;\n\t}\n};\n"],"names":["Logger","fs","deleteProfile","flags","profileName","storeConfig","storeLocation","logger","boring","process","env","NODE_ENV","profiles","readJson","available","includes","error","enabled","remove","newProfiles","filter","profile","writeJson","spaces","printBox","textAlignment","title","borderColor","verbose","log"],"mappings":"AAAA,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,QAAQ,WAAW;AAE1B,OAAO,MAAMC,gBAAgB,OAAO,EACnCC,KAAK,EACLC,WAAW,EACXC,WAAW,EACXC,aAAa,EACb;IACA,MAAMC,SAAS,IAAIP,OAAO;QACzBQ,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK,UAAUR,MAAMK,MAAM;IACxD;IAEA,IAAI;QACH,MAAMI,WAAW,MAAMX,GAAGY,QAAQ,CAACR;QACnC,IAAI,CAACO,SAASE,SAAS,CAACC,QAAQ,CAACX,cAAc;YAC9CG,OAAOS,KAAK,CAAC,CAAC,SAAS,EAAEZ,YAAY,gBAAgB,CAAC;YACtD,OAAO;QACR;QACA,wCAAwC;QACxC,IAAIQ,SAASK,OAAO,KAAKb,aAAa;YACrCG,OAAOS,KAAK,CAAC,CAAC,SAAS,EAAEZ,YAAY,qBAAqB,CAAC;YAC3D,OAAO;QACR;QACA,8DAA8D;QAC9D,MAAMH,GAAGiB,MAAM,CAAC,GAAGZ,cAAc,CAAC,EAAEF,aAAa;QACjD,sDAAsD;QACtD,MAAMe,cAAc;YACnBL,WAAWF,SAASE,SAAS,CAACM,MAAM,CACnC,CAACC,UAAiBA,YAAYjB;YAE/Ba,SAASL,SAASK,OAAO;QAC1B;QACA,MAAMhB,GAAGqB,SAAS,CAACjB,aAAac,aAAa;YAAEI,QAAQ;QAAE;QACzDhB,OAAOiB,QAAQ,CAAC,CAAC,SAAS,EAAEpB,YAAY,SAAS,CAAC,EAAE;YACnDqB,eAAe;YACfC,OAAO;YACPC,aAAa;QACd;QACA,OAAO;IACR,EAAE,OAAOX,OAAO;QACf,IAAIb,MAAMyB,OAAO,EAAE;YAClBrB,OAAOsB,GAAG,CAACb;QACZ;QACAT,OAAOS,KAAK,CAAC;QACb,OAAO;IACR;AACD,EAAE"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { GET_REGISTRY_CMD, formatRegistries } from "./common.js";
|
|
2
2
|
import { Logger } from "@node-cli/logger";
|
|
3
|
+
import { run } from "@node-cli/run";
|
|
3
4
|
import fs from "fs-extra";
|
|
4
5
|
import kleur from "kleur";
|
|
5
|
-
import { run } from "@node-cli/run";
|
|
6
6
|
export const listProfiles = async ({ flags, storeConfig })=>{
|
|
7
7
|
const logger = new Logger({
|
|
8
8
|
boring: process.env.NODE_ENV === "test" || flags.boring
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/listProfiles.ts"],"sourcesContent":["import { GET_REGISTRY_CMD, formatRegistries } from \"./common.js\";\n\nimport { Logger } from \"@node-cli/logger\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/listProfiles.ts"],"sourcesContent":["import { GET_REGISTRY_CMD, formatRegistries } from \"./common.js\";\n\nimport { Logger } from \"@node-cli/logger\";\nimport { run } from \"@node-cli/run\";\nimport fs from \"fs-extra\";\nimport kleur from \"kleur\";\n\nexport const listProfiles = async ({ flags, storeConfig }) => {\n\tconst logger = new Logger({\n\t\tboring: process.env.NODE_ENV === \"test\" || flags.boring,\n\t});\n\n\ttry {\n\t\tconst profiles = await fs.readJson(storeConfig);\n\n\t\tif (profiles?.available?.length > 0) {\n\t\t\tconst activeProfile = profiles.enabled;\n\t\t\tconst messages =\n\t\t\t\tactiveProfile === undefined\n\t\t\t\t\t? []\n\t\t\t\t\t: [kleur.green(`★ ${activeProfile} (active)`)];\n\n\t\t\t/**\n\t\t\t * Since there is an active profile, we can check the\n\t\t\t * global registries and list them, alongside the active profile.\n\t\t\t */\n\t\t\tif (activeProfile) {\n\t\t\t\tconst { stdout, stderr } = await run(GET_REGISTRY_CMD, {\n\t\t\t\t\tignoreError: true,\n\t\t\t\t});\n\n\t\t\t\tif (!stderr) {\n\t\t\t\t\tmessages.push(...formatRegistries(stdout as string));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const profile of profiles.available) {\n\t\t\t\tif (profile !== activeProfile) {\n\t\t\t\t\tmessages.push(`${profile}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.printBox(messages.join(\"\\n\"), {\n\t\t\t\ttextAlignment: \"left\",\n\t\t\t\ttitle: \"Profiles\",\n\t\t\t\tborderColor: \"blue\",\n\t\t\t});\n\t\t} else {\n\t\t\tlogger.warn(\"No profiles found\");\n\t\t}\n\t\treturn 0;\n\t} catch (error) {\n\t\tif (flags.verbose) {\n\t\t\tlogger.log(error);\n\t\t}\n\t\tlogger.error(\"Unable to read the profile configuration file\");\n\t\treturn 1;\n\t}\n};\n"],"names":["GET_REGISTRY_CMD","formatRegistries","Logger","run","fs","kleur","listProfiles","flags","storeConfig","logger","boring","process","env","NODE_ENV","profiles","readJson","available","length","activeProfile","enabled","messages","undefined","green","stdout","stderr","ignoreError","push","profile","printBox","join","textAlignment","title","borderColor","warn","error","verbose","log"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,gBAAgB,QAAQ,cAAc;AAEjE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,WAAW,QAAQ;AAE1B,OAAO,MAAMC,eAAe,OAAO,EAAEC,KAAK,EAAEC,WAAW,EAAE;IACxD,MAAMC,SAAS,IAAIP,OAAO;QACzBQ,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK,UAAUN,MAAMG,MAAM;IACxD;IAEA,IAAI;QACH,MAAMI,WAAW,MAAMV,GAAGW,QAAQ,CAACP;QAEnC,IAAIM,UAAUE,WAAWC,SAAS,GAAG;YACpC,MAAMC,gBAAgBJ,SAASK,OAAO;YACtC,MAAMC,WACLF,kBAAkBG,YACf,EAAE,GACF;gBAAChB,MAAMiB,KAAK,CAAC,CAAC,EAAE,EAAEJ,cAAc,SAAS,CAAC;aAAE;YAEhD;;;IAGC,GACD,IAAIA,eAAe;gBAClB,MAAM,EAAEK,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMrB,IAAIH,kBAAkB;oBACtDyB,aAAa;gBACd;gBAEA,IAAI,CAACD,QAAQ;oBACZJ,SAASM,IAAI,IAAIzB,iBAAiBsB;gBACnC;YACD;YAEA,KAAK,MAAMI,WAAWb,SAASE,SAAS,CAAE;gBACzC,IAAIW,YAAYT,eAAe;oBAC9BE,SAASM,IAAI,CAAC,GAAGC,SAAS;gBAC3B;YACD;YAEAlB,OAAOmB,QAAQ,CAACR,SAASS,IAAI,CAAC,OAAO;gBACpCC,eAAe;gBACfC,OAAO;gBACPC,aAAa;YACd;QACD,OAAO;YACNvB,OAAOwB,IAAI,CAAC;QACb;QACA,OAAO;IACR,EAAE,OAAOC,OAAO;QACf,IAAI3B,MAAM4B,OAAO,EAAE;YAClB1B,OAAO2B,GAAG,CAACF;QACZ;QACAzB,OAAOyB,KAAK,CAAC;QACb,OAAO;IACR;AACD,EAAE"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { GET_REGISTRY_CMD, formatRegistries } from "./common.js";
|
|
2
2
|
import { Logger } from "@node-cli/logger";
|
|
3
|
+
import { run } from "@node-cli/run";
|
|
3
4
|
import fs from "fs-extra";
|
|
4
5
|
import kleur from "kleur";
|
|
5
|
-
import { run } from "@node-cli/run";
|
|
6
6
|
export const switchProfile = async ({ flags, storeConfig, storeLocation, profileName, homeLocation })=>{
|
|
7
7
|
const logger = new Logger({
|
|
8
8
|
boring: process.env.NODE_ENV === "test" || flags.boring
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/switchProfile.ts"],"sourcesContent":["import { GET_REGISTRY_CMD, formatRegistries } from \"./common.js\";\n\nimport { Logger } from \"@node-cli/logger\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/switchProfile.ts"],"sourcesContent":["import { GET_REGISTRY_CMD, formatRegistries } from \"./common.js\";\n\nimport { Logger } from \"@node-cli/logger\";\nimport { run } from \"@node-cli/run\";\nimport fs from \"fs-extra\";\nimport kleur from \"kleur\";\n\nexport const switchProfile = async ({\n\tflags,\n\tstoreConfig,\n\tstoreLocation,\n\tprofileName,\n\thomeLocation,\n}) => {\n\tconst logger = new Logger({\n\t\tboring: process.env.NODE_ENV === \"test\" || flags.boring,\n\t});\n\n\ttry {\n\t\tconst profiles = await fs.readJson(storeConfig);\n\t\tif (!profiles.available.includes(profileName)) {\n\t\t\tlogger.error(`Profile '${profileName}' does not exist`);\n\t\t\treturn 1;\n\t\t}\n\t\t// if profile is already enabled, do nothing\n\t\tif (profiles.enabled === profileName) {\n\t\t\tlogger.warn(`Profile '${profileName}' is already active`);\n\t\t\treturn 0;\n\t\t}\n\t\t// if profile exists and is not enabled, switch to it by copying\n\t\t// the npmrc and yarnrc files from the profile folder to the home folder\n\t\tconst NPMRC = `${homeLocation}/.npmrc`;\n\t\tconst PROFILE_NPMRC = `${storeLocation}/${profileName}/npmrc`;\n\t\tconst YARNRC = `${homeLocation}/.yarnrc`;\n\t\tconst PROFILE_YARNRC = `${storeLocation}/${profileName}/yarnrc`;\n\n\t\tif (await fs.pathExists(PROFILE_NPMRC)) {\n\t\t\tawait fs.copy(PROFILE_NPMRC, NPMRC, {\n\t\t\t\toverwrite: true,\n\t\t\t});\n\t\t} else {\n\t\t\tlogger.warn(`No npmrc file found for profile '${profileName}'`);\n\t\t}\n\t\tif (await fs.pathExists(PROFILE_YARNRC)) {\n\t\t\tawait fs.copy(PROFILE_YARNRC, YARNRC, {\n\t\t\t\toverwrite: true,\n\t\t\t});\n\t\t} else {\n\t\t\tlogger.warn(`No yarnrc file found for profile '${profileName}'`);\n\t\t}\n\n\t\tconst newProfiles = {\n\t\t\tavailable: profiles.available,\n\t\t\tenabled: profileName,\n\t\t};\n\t\tawait fs.writeJson(storeConfig, newProfiles, { spaces: 2 });\n\t\tconst messages = [kleur.green(`Profile switched to '${profileName}'`)];\n\t\tconst { stdout, stderr } = await run(GET_REGISTRY_CMD, {\n\t\t\tignoreError: true,\n\t\t});\n\t\tif (!stderr) {\n\t\t\tmessages.push(...formatRegistries(stdout as string));\n\t\t}\n\t\tlogger.printBox(messages.join(\"\\n\"), {\n\t\t\ttextAlignment: \"left\",\n\t\t\ttitle: \"Profiles\",\n\t\t\tborderColor: \"blue\",\n\t\t});\n\t\treturn 0;\n\t} catch (error) {\n\t\tif (flags.verbose) {\n\t\t\tlogger.log(error);\n\t\t}\n\t\tlogger.error(\"Could not switch profile\");\n\t\treturn 1;\n\t}\n};\n"],"names":["GET_REGISTRY_CMD","formatRegistries","Logger","run","fs","kleur","switchProfile","flags","storeConfig","storeLocation","profileName","homeLocation","logger","boring","process","env","NODE_ENV","profiles","readJson","available","includes","error","enabled","warn","NPMRC","PROFILE_NPMRC","YARNRC","PROFILE_YARNRC","pathExists","copy","overwrite","newProfiles","writeJson","spaces","messages","green","stdout","stderr","ignoreError","push","printBox","join","textAlignment","title","borderColor","verbose","log"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,gBAAgB,QAAQ,cAAc;AAEjE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,WAAW,QAAQ;AAE1B,OAAO,MAAMC,gBAAgB,OAAO,EACnCC,KAAK,EACLC,WAAW,EACXC,aAAa,EACbC,WAAW,EACXC,YAAY,EACZ;IACA,MAAMC,SAAS,IAAIV,OAAO;QACzBW,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK,UAAUT,MAAMM,MAAM;IACxD;IAEA,IAAI;QACH,MAAMI,WAAW,MAAMb,GAAGc,QAAQ,CAACV;QACnC,IAAI,CAACS,SAASE,SAAS,CAACC,QAAQ,CAACV,cAAc;YAC9CE,OAAOS,KAAK,CAAC,CAAC,SAAS,EAAEX,YAAY,gBAAgB,CAAC;YACtD,OAAO;QACR;QACA,4CAA4C;QAC5C,IAAIO,SAASK,OAAO,KAAKZ,aAAa;YACrCE,OAAOW,IAAI,CAAC,CAAC,SAAS,EAAEb,YAAY,mBAAmB,CAAC;YACxD,OAAO;QACR;QACA,gEAAgE;QAChE,wEAAwE;QACxE,MAAMc,QAAQ,GAAGb,aAAa,OAAO,CAAC;QACtC,MAAMc,gBAAgB,GAAGhB,cAAc,CAAC,EAAEC,YAAY,MAAM,CAAC;QAC7D,MAAMgB,SAAS,GAAGf,aAAa,QAAQ,CAAC;QACxC,MAAMgB,iBAAiB,GAAGlB,cAAc,CAAC,EAAEC,YAAY,OAAO,CAAC;QAE/D,IAAI,MAAMN,GAAGwB,UAAU,CAACH,gBAAgB;YACvC,MAAMrB,GAAGyB,IAAI,CAACJ,eAAeD,OAAO;gBACnCM,WAAW;YACZ;QACD,OAAO;YACNlB,OAAOW,IAAI,CAAC,CAAC,iCAAiC,EAAEb,YAAY,CAAC,CAAC;QAC/D;QACA,IAAI,MAAMN,GAAGwB,UAAU,CAACD,iBAAiB;YACxC,MAAMvB,GAAGyB,IAAI,CAACF,gBAAgBD,QAAQ;gBACrCI,WAAW;YACZ;QACD,OAAO;YACNlB,OAAOW,IAAI,CAAC,CAAC,kCAAkC,EAAEb,YAAY,CAAC,CAAC;QAChE;QAEA,MAAMqB,cAAc;YACnBZ,WAAWF,SAASE,SAAS;YAC7BG,SAASZ;QACV;QACA,MAAMN,GAAG4B,SAAS,CAACxB,aAAauB,aAAa;YAAEE,QAAQ;QAAE;QACzD,MAAMC,WAAW;YAAC7B,MAAM8B,KAAK,CAAC,CAAC,qBAAqB,EAAEzB,YAAY,CAAC,CAAC;SAAE;QACtE,MAAM,EAAE0B,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMlC,IAAIH,kBAAkB;YACtDsC,aAAa;QACd;QACA,IAAI,CAACD,QAAQ;YACZH,SAASK,IAAI,IAAItC,iBAAiBmC;QACnC;QACAxB,OAAO4B,QAAQ,CAACN,SAASO,IAAI,CAAC,OAAO;YACpCC,eAAe;YACfC,OAAO;YACPC,aAAa;QACd;QACA,OAAO;IACR,EAAE,OAAOvB,OAAO;QACf,IAAId,MAAMsC,OAAO,EAAE;YAClBjC,OAAOkC,GAAG,CAACzB;QACZ;QACAT,OAAOS,KAAK,CAAC;QACb,OAAO;IACR;AACD,EAAE"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { GET_REGISTRY_CMD, formatRegistries } from "./common.js";
|
|
2
2
|
import { Logger } from "@node-cli/logger";
|
|
3
|
+
import { run } from "@node-cli/run";
|
|
3
4
|
import fs from "fs-extra";
|
|
4
5
|
import kleur from "kleur";
|
|
5
|
-
import { run } from "@node-cli/run";
|
|
6
6
|
export const updateProfile = async ({ flags, storeConfig, storeLocation, homeLocation })=>{
|
|
7
7
|
const logger = new Logger({
|
|
8
8
|
boring: process.env.NODE_ENV === "test" || flags.boring
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/updateProfile.ts"],"sourcesContent":["import { GET_REGISTRY_CMD, formatRegistries } from \"./common.js\";\n\nimport { Logger } from \"@node-cli/logger\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/updateProfile.ts"],"sourcesContent":["import { GET_REGISTRY_CMD, formatRegistries } from \"./common.js\";\n\nimport { Logger } from \"@node-cli/logger\";\nimport { run } from \"@node-cli/run\";\nimport fs from \"fs-extra\";\nimport kleur from \"kleur\";\n\nexport const updateProfile = async ({\n\tflags,\n\tstoreConfig,\n\tstoreLocation,\n\thomeLocation,\n}) => {\n\tconst logger = new Logger({\n\t\tboring: process.env.NODE_ENV === \"test\" || flags.boring,\n\t});\n\n\tlet profiles: { available: string | any[]; enabled: any };\n\n\t// Step 1: check if there is an active profile\n\ttry {\n\t\tprofiles = await fs.readJson(storeConfig);\n\t} catch {\n\t\t// ignoring error since we are going to create the file\n\t}\n\n\tif (profiles?.available?.length > 0) {\n\t\tconst profileName = profiles.enabled;\n\t\tif (profileName) {\n\t\t\tconst messages = [kleur.green(`Profile '${profileName}' updated`)];\n\t\t\t/**\n\t\t\t * Step2: since there is an active profile, we can check the\n\t\t\t * global registries and list them, alongside the updated profile.\n\t\t\t */\n\t\t\tconst { stdout, stderr } = await run(GET_REGISTRY_CMD, {\n\t\t\t\tignoreError: true,\n\t\t\t});\n\t\t\tif (!stderr) {\n\t\t\t\tmessages.push(...formatRegistries(stdout as string));\n\t\t\t}\n\n\t\t\t// Step 3: update the active profile\n\t\t\tawait fs.ensureDir(`${storeLocation}/${profileName}`);\n\t\t\t// copy the existing npmrc / yarnrc files to the storage folder\n\t\t\tconst NPMRC = `${homeLocation}/.npmrc`;\n\t\t\tconst YARNRC = `${homeLocation}/.yarnrc`;\n\t\t\tif (await fs.pathExists(YARNRC)) {\n\t\t\t\tawait fs.copy(YARNRC, `${storeLocation}/${profileName}/yarnrc`);\n\t\t\t}\n\t\t\tif (await fs.pathExists(NPMRC)) {\n\t\t\t\tawait fs.copy(NPMRC, `${storeLocation}/${profileName}/npmrc`);\n\t\t\t}\n\t\t\tlogger.printBox(messages.join(\"\\n\"), {\n\t\t\t\ttextAlignment: \"left\",\n\t\t\t\ttitle: \"Profiles\",\n\t\t\t\tborderColor: \"blue\",\n\t\t\t});\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tlogger.warn(\n\t\t\"Only active profiles can be updated. Please switch to the profile you want to update.\",\n\t);\n\treturn 0;\n};\n"],"names":["GET_REGISTRY_CMD","formatRegistries","Logger","run","fs","kleur","updateProfile","flags","storeConfig","storeLocation","homeLocation","logger","boring","process","env","NODE_ENV","profiles","readJson","available","length","profileName","enabled","messages","green","stdout","stderr","ignoreError","push","ensureDir","NPMRC","YARNRC","pathExists","copy","printBox","join","textAlignment","title","borderColor","warn"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,gBAAgB,QAAQ,cAAc;AAEjE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,WAAW,QAAQ;AAE1B,OAAO,MAAMC,gBAAgB,OAAO,EACnCC,KAAK,EACLC,WAAW,EACXC,aAAa,EACbC,YAAY,EACZ;IACA,MAAMC,SAAS,IAAIT,OAAO;QACzBU,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK,UAAUR,MAAMK,MAAM;IACxD;IAEA,IAAII;IAEJ,8CAA8C;IAC9C,IAAI;QACHA,WAAW,MAAMZ,GAAGa,QAAQ,CAACT;IAC9B,EAAE,OAAM;IACP,uDAAuD;IACxD;IAEA,IAAIQ,UAAUE,WAAWC,SAAS,GAAG;QACpC,MAAMC,cAAcJ,SAASK,OAAO;QACpC,IAAID,aAAa;YAChB,MAAME,WAAW;gBAACjB,MAAMkB,KAAK,CAAC,CAAC,SAAS,EAAEH,YAAY,SAAS,CAAC;aAAE;YAClE;;;IAGC,GACD,MAAM,EAAEI,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMtB,IAAIH,kBAAkB;gBACtD0B,aAAa;YACd;YACA,IAAI,CAACD,QAAQ;gBACZH,SAASK,IAAI,IAAI1B,iBAAiBuB;YACnC;YAEA,oCAAoC;YACpC,MAAMpB,GAAGwB,SAAS,CAAC,GAAGnB,cAAc,CAAC,EAAEW,aAAa;YACpD,+DAA+D;YAC/D,MAAMS,QAAQ,GAAGnB,aAAa,OAAO,CAAC;YACtC,MAAMoB,SAAS,GAAGpB,aAAa,QAAQ,CAAC;YACxC,IAAI,MAAMN,GAAG2B,UAAU,CAACD,SAAS;gBAChC,MAAM1B,GAAG4B,IAAI,CAACF,QAAQ,GAAGrB,cAAc,CAAC,EAAEW,YAAY,OAAO,CAAC;YAC/D;YACA,IAAI,MAAMhB,GAAG2B,UAAU,CAACF,QAAQ;gBAC/B,MAAMzB,GAAG4B,IAAI,CAACH,OAAO,GAAGpB,cAAc,CAAC,EAAEW,YAAY,MAAM,CAAC;YAC7D;YACAT,OAAOsB,QAAQ,CAACX,SAASY,IAAI,CAAC,OAAO;gBACpCC,eAAe;gBACfC,OAAO;gBACPC,aAAa;YACd;YACA,OAAO;QACR;IACD;IAEA1B,OAAO2B,IAAI,CACV;IAED,OAAO;AACR,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-cli/npmrc",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"description": "Toggle different npmrc configuration files on the fly",
|
|
@@ -18,21 +18,25 @@
|
|
|
18
18
|
"build:js": "swc --strip-leading-paths --source-maps --out-dir dist src",
|
|
19
19
|
"build:types": "tsc",
|
|
20
20
|
"clean": "rimraf dist types coverage",
|
|
21
|
-
"lint": "
|
|
22
|
-
"test": "
|
|
23
|
-
"test:coverage": "
|
|
24
|
-
"test:watch": "
|
|
21
|
+
"lint": "biome lint src",
|
|
22
|
+
"test": "vitest run --globals",
|
|
23
|
+
"test:coverage": "vitest run --coverage --globals",
|
|
24
|
+
"test:watch": "vitest --globals",
|
|
25
25
|
"watch": "swc --strip-leading-paths --watch --out-dir dist src"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@node-cli/logger": "1.
|
|
29
|
-
"@node-cli/parser": "2.
|
|
30
|
-
"@node-cli/run": "1.
|
|
31
|
-
"fs-extra": "11.
|
|
28
|
+
"@node-cli/logger": "1.3.1",
|
|
29
|
+
"@node-cli/parser": "2.4.1",
|
|
30
|
+
"@node-cli/run": "1.1.3",
|
|
31
|
+
"fs-extra": "11.3.0",
|
|
32
32
|
"kleur": "4.1.5"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
39
|
+
"vitest": "3.2.4"
|
|
40
|
+
},
|
|
41
|
+
"gitHead": "2cef8f88aa5316a1789caad2bd7327ca908ccb9f"
|
|
38
42
|
}
|