@node-cli/npmrc 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/defaults.d.ts +4 -0
- package/dist/defaults.js +6 -0
- package/dist/defaults.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/npmrc.d.ts +2 -0
- package/dist/npmrc.js +47 -0
- package/dist/npmrc.js.map +1 -0
- package/dist/parse.d.ts +18 -0
- package/dist/parse.js +78 -0
- package/dist/parse.js.map +1 -0
- package/dist/utilities.d.ts +26 -0
- package/dist/utilities.js +172 -0
- package/dist/utilities.js.map +1 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Arno Versini
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Node CLI npmrc package
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
> Npmrc allows you to toggle different npmrc configuration files on the fly.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
> npm install --global @node-cli/npmrc
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Examples
|
|
14
|
+
|
|
15
|
+
List existing profiles
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
> npmrc -l
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Create a profile
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
> npmrc -c my-profile
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Switch to an existing profile
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
> npmrc my-profile
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Delete a profile
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
> npmrc -d my-profile
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Get help
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
> npmrc --help
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT © Arno Versini
|
package/dist/defaults.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["/* istanbul ignore file */\nexport const defaultFlags = {\n\tboring: false,\n\tverbose: false,\n};\n"],"names":["defaultFlags","boring","verbose"],"mappings":"AAAA,wBAAwB,GACxB,OAAO,MAAMA,eAAe;IAC3BC,QAAQ;IACRC,SAAS;AACV,EAAE"}
|
package/dist/index.d.ts
ADDED
package/dist/npmrc.d.ts
ADDED
package/dist/npmrc.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* istanbul ignore file */ import { createProfile, deleteProfile, listProfiles, switchProfile } from "./utilities.js";
|
|
3
|
+
import { config } from "./parse.js";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
const HOME = process.env.HOME;
|
|
6
|
+
const NPMRC_STORE = path.join(HOME, ".envtools/npmrcs");
|
|
7
|
+
const NPMRC_STORE_CONFIG = path.join(HOME, "/.envtools/npmrcs.json");
|
|
8
|
+
const { parameters, flags, showHelp } = config;
|
|
9
|
+
if (flags.create && parameters !== undefined) {
|
|
10
|
+
const exitFlag = await createProfile({
|
|
11
|
+
flags,
|
|
12
|
+
storeConfig: NPMRC_STORE_CONFIG,
|
|
13
|
+
storeLocation: NPMRC_STORE,
|
|
14
|
+
profileName: parameters["0"],
|
|
15
|
+
homeLocation: HOME
|
|
16
|
+
});
|
|
17
|
+
process.exit(exitFlag);
|
|
18
|
+
}
|
|
19
|
+
if (flags.delete && parameters !== undefined) {
|
|
20
|
+
const exitFlag = await deleteProfile({
|
|
21
|
+
flags,
|
|
22
|
+
storeConfig: NPMRC_STORE_CONFIG,
|
|
23
|
+
storeLocation: NPMRC_STORE,
|
|
24
|
+
profileName: parameters["0"]
|
|
25
|
+
});
|
|
26
|
+
process.exit(exitFlag);
|
|
27
|
+
}
|
|
28
|
+
if (parameters !== undefined && parameters["0"] !== undefined) {
|
|
29
|
+
const exitFlag = await switchProfile({
|
|
30
|
+
flags,
|
|
31
|
+
storeConfig: NPMRC_STORE_CONFIG,
|
|
32
|
+
storeLocation: NPMRC_STORE,
|
|
33
|
+
profileName: parameters["0"],
|
|
34
|
+
homeLocation: HOME
|
|
35
|
+
});
|
|
36
|
+
process.exit(exitFlag);
|
|
37
|
+
}
|
|
38
|
+
if (flags.list || !flags.version && !flags.help) {
|
|
39
|
+
const exitFlag = await listProfiles({
|
|
40
|
+
flags,
|
|
41
|
+
storeConfig: NPMRC_STORE_CONFIG
|
|
42
|
+
});
|
|
43
|
+
process.exit(exitFlag);
|
|
44
|
+
}
|
|
45
|
+
showHelp();
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=npmrc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/npmrc.ts"],"sourcesContent":["#!/usr/bin/env node\n/* istanbul ignore file */\n\nimport {\n\tcreateProfile,\n\tdeleteProfile,\n\tlistProfiles,\n\tswitchProfile,\n} from \"./utilities.js\";\n\nimport { config } from \"./parse.js\";\nimport path from \"node:path\";\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.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"],"names":["createProfile","deleteProfile","listProfiles","switchProfile","config","path","HOME","process","env","NPMRC_STORE","join","NPMRC_STORE_CONFIG","parameters","flags","showHelp","create","undefined","exitFlag","storeConfig","storeLocation","profileName","homeLocation","exit","delete","list","version","help"],"mappings":";AACA,wBAAwB,GAExB,SACCA,aAAa,EACbC,aAAa,EACbC,YAAY,EACZC,aAAa,QACP,iBAAiB;AAExB,SAASC,MAAM,QAAQ,aAAa;AACpC,OAAOC,UAAU,YAAY;AAE7B,MAAMC,OAAOC,QAAQC,GAAG,CAACF,IAAI;AAC7B,MAAMG,cAAcJ,KAAKK,IAAI,CAACJ,MAAM;AACpC,MAAMK,qBAAqBN,KAAKK,IAAI,CAACJ,MAAM;AAE3C,MAAM,EAAEM,UAAU,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGV;AAExC,IAAIS,MAAME,MAAM,IAAIH,eAAeI,WAAW;IAC7C,MAAMC,WAAW,MAAMjB,cAAc;QACpCa;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,MAAMhB,cAAc;QACpCY;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,MAAMd,cAAc;QACpCU;QACAK,aAAaP;QACbQ,eAAeV;QACfW,aAAaR,UAAU,CAAC,IAAI;QAC5BS,cAAcf;IACf;IACAC,QAAQe,IAAI,CAACL;AACd;AAEA,IAAIJ,MAAMW,IAAI,IAAK,CAACX,MAAMY,OAAO,IAAI,CAACZ,MAAMa,IAAI,EAAG;IAClD,MAAMT,WAAW,MAAMf,aAAa;QACnCW;QACAK,aAAaP;IACd;IACAJ,QAAQe,IAAI,CAACL;AACd;AAEAH"}
|
package/dist/parse.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type Parameters = {
|
|
2
|
+
["0"]?: string;
|
|
3
|
+
};
|
|
4
|
+
export type Flags = {
|
|
5
|
+
verbose?: boolean;
|
|
6
|
+
delete?: boolean;
|
|
7
|
+
create?: boolean;
|
|
8
|
+
list?: boolean;
|
|
9
|
+
boring?: boolean;
|
|
10
|
+
help?: boolean;
|
|
11
|
+
version?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type Configuration = {
|
|
14
|
+
flags?: Flags;
|
|
15
|
+
parameters?: Parameters;
|
|
16
|
+
showHelp?: () => void;
|
|
17
|
+
};
|
|
18
|
+
export declare const config: Configuration;
|
package/dist/parse.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { defaultFlags } from "./defaults.js";
|
|
2
|
+
import { parser } from "@node-cli/parser";
|
|
3
|
+
/* istanbul ignore next */ export const config = parser({
|
|
4
|
+
meta: import.meta,
|
|
5
|
+
examples: [
|
|
6
|
+
{
|
|
7
|
+
command: "npmrc -l",
|
|
8
|
+
comment: "## List existing profiles"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
command: "npmrc -c [name]",
|
|
12
|
+
comment: "## Create a profile"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
command: "npmrc [name]",
|
|
16
|
+
comment: "## Switch to an existing profile"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
command: "npmrc -d [name]",
|
|
20
|
+
comment: "## Delete an existing profile"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
flags: {
|
|
24
|
+
verbose: {
|
|
25
|
+
shortFlag: "V",
|
|
26
|
+
description: "Output debugging information",
|
|
27
|
+
type: "boolean"
|
|
28
|
+
},
|
|
29
|
+
delete: {
|
|
30
|
+
shortFlag: "d",
|
|
31
|
+
description: "Delete a profile",
|
|
32
|
+
type: "boolean"
|
|
33
|
+
},
|
|
34
|
+
create: {
|
|
35
|
+
shortFlag: "c",
|
|
36
|
+
description: "Create a new profile",
|
|
37
|
+
type: "boolean"
|
|
38
|
+
},
|
|
39
|
+
list: {
|
|
40
|
+
shortFlag: "l",
|
|
41
|
+
description: "List all profiles",
|
|
42
|
+
type: "boolean"
|
|
43
|
+
},
|
|
44
|
+
boring: {
|
|
45
|
+
shortFlag: "b",
|
|
46
|
+
default: defaultFlags.boring,
|
|
47
|
+
description: "Do not use color output",
|
|
48
|
+
type: "boolean"
|
|
49
|
+
},
|
|
50
|
+
help: {
|
|
51
|
+
shortFlag: "h",
|
|
52
|
+
description: "Display help instructions",
|
|
53
|
+
type: "boolean"
|
|
54
|
+
},
|
|
55
|
+
version: {
|
|
56
|
+
shortFlag: "v",
|
|
57
|
+
description: "Output the current version",
|
|
58
|
+
type: "boolean"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
parameters: {
|
|
62
|
+
profile: {
|
|
63
|
+
description: "profile name"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
restrictions: [
|
|
67
|
+
{
|
|
68
|
+
exit: 1,
|
|
69
|
+
message: "To create a profile, you must provide a profile name",
|
|
70
|
+
test: (flags, parameters)=>{
|
|
71
|
+
return flags.create && (!parameters || !parameters["0"]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
usage: "npmrc [options] [profile]"
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/parse.ts"],"sourcesContent":["import { defaultFlags } from \"./defaults.js\";\nimport { parser } from \"@node-cli/parser\";\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\tboring?: boolean;\n\thelp?: boolean;\n\tversion?: boolean;\n};\nexport type Configuration = {\n\tflags?: Flags;\n\tparameters?: Parameters;\n\tshowHelp?: () => void;\n};\n\n/* istanbul ignore next */\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\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"],"names":["defaultFlags","parser","config","meta","examples","command","comment","flags","verbose","shortFlag","description","type","delete","create","list","boring","default","help","version","parameters","profile","restrictions","exit","message","test","usage"],"mappings":"AAAA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,MAAM,QAAQ,mBAAmB;AAoB1C,wBAAwB,GACxB,OAAO,MAAMC,SAAwBD,OAAO;IAC3CE,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;YACXO,SAAShB,aAAae,MAAM;YAC5BL,aAAa;YACbC,MAAM;QACP;QACAM,MAAM;YACLR,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;QACAO,SAAS;YACRT,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;IACD;IACAQ,YAAY;QACXC,SAAS;YACRV,aAAa;QACd;IACD;IACAW,cAAc;QACb;YACCC,MAAM;YACNC,SAAS;YACTC,MAAM,CAACjB,OAAeY;gBACrB,OAAOZ,MAAMM,MAAM,IAAK,CAAA,CAACM,cAAc,CAACA,UAAU,CAAC,IAAI,AAAD;YACvD;QACD;KACA;IACDM,OAAO;AACR,GAAG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Logger } from "@node-cli/logger";
|
|
2
|
+
export declare const logger: Logger;
|
|
3
|
+
export declare const listProfiles: ({ flags, storeConfig }: {
|
|
4
|
+
flags: any;
|
|
5
|
+
storeConfig: any;
|
|
6
|
+
}) => Promise<0 | 1>;
|
|
7
|
+
export declare const createProfile: ({ flags, storeConfig, storeLocation, profileName, homeLocation, }: {
|
|
8
|
+
flags: any;
|
|
9
|
+
storeConfig: any;
|
|
10
|
+
storeLocation: any;
|
|
11
|
+
profileName: any;
|
|
12
|
+
homeLocation: any;
|
|
13
|
+
}) => Promise<0 | 1>;
|
|
14
|
+
export declare const switchProfile: ({ flags, storeConfig, storeLocation, profileName, homeLocation, }: {
|
|
15
|
+
flags: any;
|
|
16
|
+
storeConfig: any;
|
|
17
|
+
storeLocation: any;
|
|
18
|
+
profileName: any;
|
|
19
|
+
homeLocation: any;
|
|
20
|
+
}) => Promise<0 | 1>;
|
|
21
|
+
export declare const deleteProfile: ({ flags, profileName, storeConfig, storeLocation, }: {
|
|
22
|
+
flags: any;
|
|
23
|
+
profileName: any;
|
|
24
|
+
storeConfig: any;
|
|
25
|
+
storeLocation: any;
|
|
26
|
+
}) => Promise<0 | 1>;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Logger } from "@node-cli/logger";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import kleur from "kleur";
|
|
4
|
+
export const logger = new Logger();
|
|
5
|
+
logger.boring = process.env.NODE_ENV === "test";
|
|
6
|
+
export const listProfiles = async ({ flags, storeConfig })=>{
|
|
7
|
+
try {
|
|
8
|
+
const profiles = await fs.readJson(storeConfig);
|
|
9
|
+
if (profiles?.available?.length > 0) {
|
|
10
|
+
const activeProfile = profiles.enabled;
|
|
11
|
+
const messages = activeProfile === undefined ? [] : [
|
|
12
|
+
kleur.green(`★ ${activeProfile} (active)`)
|
|
13
|
+
];
|
|
14
|
+
for (const profile of profiles.available){
|
|
15
|
+
if (profile !== activeProfile) {
|
|
16
|
+
messages.push(`${profile}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
logger.printBox(messages.join("\n"), {
|
|
20
|
+
textAlignment: "left",
|
|
21
|
+
title: "Profiles",
|
|
22
|
+
borderColor: "blue"
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
logger.warn("No profiles found");
|
|
26
|
+
}
|
|
27
|
+
return 0;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (flags.verbose) {
|
|
30
|
+
logger.log(error);
|
|
31
|
+
}
|
|
32
|
+
logger.error("Unable to read the profile configuration file");
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export const createProfile = async ({ flags, storeConfig, storeLocation, profileName, homeLocation })=>{
|
|
37
|
+
try {
|
|
38
|
+
const profiles = await fs.readJson(storeConfig);
|
|
39
|
+
// if the profile already exists, do nothing
|
|
40
|
+
if (profiles.available.includes(profileName)) {
|
|
41
|
+
logger.warn(`Profile '${profileName}' already exists...`);
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
// if the profile does not exist, create
|
|
45
|
+
// a folder named as the profile under the storeLocation folder,
|
|
46
|
+
// with the existing npmrc / yarnrc files
|
|
47
|
+
await fs.ensureDir(`${storeLocation}/${profileName}`);
|
|
48
|
+
// copy the existing npmrc / yarnrc files to the new folder
|
|
49
|
+
const NPMRC = `${homeLocation}/.npmrc`;
|
|
50
|
+
const YARNRC = `${homeLocation}/.yarnrc`;
|
|
51
|
+
if (await fs.pathExists(YARNRC)) {
|
|
52
|
+
await fs.copy(YARNRC, `${storeLocation}/${profileName}/yarnrc`);
|
|
53
|
+
}
|
|
54
|
+
if (await fs.pathExists(NPMRC)) {
|
|
55
|
+
await fs.copy(NPMRC, `${storeLocation}/${profileName}/npmrc`);
|
|
56
|
+
}
|
|
57
|
+
// then add the profile to the configuration file
|
|
58
|
+
const newProfiles = {
|
|
59
|
+
available: [
|
|
60
|
+
...profiles.available,
|
|
61
|
+
profileName
|
|
62
|
+
],
|
|
63
|
+
enabled: profiles.enabled
|
|
64
|
+
};
|
|
65
|
+
await fs.writeJson(storeConfig, newProfiles, {
|
|
66
|
+
spaces: 2
|
|
67
|
+
});
|
|
68
|
+
logger.printBox(`Profile '${profileName}' created`, {
|
|
69
|
+
textAlignment: "left",
|
|
70
|
+
title: "Profiles",
|
|
71
|
+
borderColor: "blue"
|
|
72
|
+
});
|
|
73
|
+
return 0;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (flags.verbose) {
|
|
76
|
+
logger.log(error);
|
|
77
|
+
}
|
|
78
|
+
logger.error("Could not create profile");
|
|
79
|
+
return 1;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
export const switchProfile = async ({ flags, storeConfig, storeLocation, profileName, homeLocation })=>{
|
|
83
|
+
try {
|
|
84
|
+
const profiles = await fs.readJson(storeConfig);
|
|
85
|
+
if (!profiles.available.includes(profileName)) {
|
|
86
|
+
logger.error(`Profile '${profileName}' does not exist`);
|
|
87
|
+
return 1;
|
|
88
|
+
}
|
|
89
|
+
// if profile is already enabled, do nothing
|
|
90
|
+
if (profiles.enabled === profileName) {
|
|
91
|
+
logger.warn(`Profile '${profileName}' is already active`);
|
|
92
|
+
return 0;
|
|
93
|
+
}
|
|
94
|
+
// if profile exists and is not enabled, switch to it by copying
|
|
95
|
+
// the npmrc and yarnrc files from the profile folder to the home folder
|
|
96
|
+
const NPMRC = `${homeLocation}/.npmrc`;
|
|
97
|
+
const PROFILE_NPMRC = `${storeLocation}/${profileName}/npmrc`;
|
|
98
|
+
const YARNRC = `${homeLocation}/.yarnrc`;
|
|
99
|
+
const PROFILE_YARNRC = `${storeLocation}/${profileName}/yarnrc`;
|
|
100
|
+
if (await fs.pathExists(PROFILE_NPMRC)) {
|
|
101
|
+
await fs.copy(PROFILE_NPMRC, NPMRC, {
|
|
102
|
+
overwrite: true
|
|
103
|
+
});
|
|
104
|
+
} else {
|
|
105
|
+
logger.warn(`No npmrc file found for profile '${profileName}'`);
|
|
106
|
+
}
|
|
107
|
+
if (await fs.pathExists(PROFILE_YARNRC)) {
|
|
108
|
+
await fs.copy(PROFILE_YARNRC, YARNRC, {
|
|
109
|
+
overwrite: true
|
|
110
|
+
});
|
|
111
|
+
} else {
|
|
112
|
+
logger.warn(`No yarnrc file found for profile '${profileName}'`);
|
|
113
|
+
}
|
|
114
|
+
const newProfiles = {
|
|
115
|
+
available: profiles.available,
|
|
116
|
+
enabled: profileName
|
|
117
|
+
};
|
|
118
|
+
await fs.writeJson(storeConfig, newProfiles, {
|
|
119
|
+
spaces: 2
|
|
120
|
+
});
|
|
121
|
+
logger.printBox(`Profile switched to '${profileName}'`, {
|
|
122
|
+
textAlignment: "left",
|
|
123
|
+
title: "Profiles",
|
|
124
|
+
borderColor: "blue"
|
|
125
|
+
});
|
|
126
|
+
return 0;
|
|
127
|
+
} catch (error) {
|
|
128
|
+
if (flags.verbose) {
|
|
129
|
+
logger.log(error);
|
|
130
|
+
}
|
|
131
|
+
logger.error("Could not switch profile");
|
|
132
|
+
return 1;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
export const deleteProfile = async ({ flags, profileName, storeConfig, storeLocation })=>{
|
|
136
|
+
try {
|
|
137
|
+
const profiles = await fs.readJson(storeConfig);
|
|
138
|
+
if (!profiles.available.includes(profileName)) {
|
|
139
|
+
logger.error(`Profile '${profileName}' does not exist`);
|
|
140
|
+
return 1;
|
|
141
|
+
}
|
|
142
|
+
// if the profile is enabled, do nothing
|
|
143
|
+
if (profiles.enabled === profileName) {
|
|
144
|
+
logger.error(`Profile '${profileName}' is currently active`);
|
|
145
|
+
return 1;
|
|
146
|
+
}
|
|
147
|
+
// if profile exists, delete it by removing the profile folder
|
|
148
|
+
await fs.remove(`${storeLocation}/${profileName}`);
|
|
149
|
+
// then remove the profile from the configuration file
|
|
150
|
+
const newProfiles = {
|
|
151
|
+
available: profiles.available.filter((profile)=>profile !== profileName),
|
|
152
|
+
enabled: profiles.enabled
|
|
153
|
+
};
|
|
154
|
+
await fs.writeJson(storeConfig, newProfiles, {
|
|
155
|
+
spaces: 2
|
|
156
|
+
});
|
|
157
|
+
logger.printBox(`Profile '${profileName}' deleted`, {
|
|
158
|
+
textAlignment: "left",
|
|
159
|
+
title: "Profiles",
|
|
160
|
+
borderColor: "blue"
|
|
161
|
+
});
|
|
162
|
+
return 0;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
if (flags.verbose) {
|
|
165
|
+
logger.log(error);
|
|
166
|
+
}
|
|
167
|
+
logger.error("Could not delete profile");
|
|
168
|
+
return 1;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
//# sourceMappingURL=utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utilities.ts"],"sourcesContent":["import { Logger } from \"@node-cli/logger\";\nimport fs from \"fs-extra\";\nimport kleur from \"kleur\";\n\nexport const logger = new Logger();\nlogger.boring = process.env.NODE_ENV === \"test\";\n\nexport const listProfiles = async ({ flags, storeConfig }) => {\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\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\nexport const createProfile = async ({\n\tflags,\n\tstoreConfig,\n\tstoreLocation,\n\tprofileName,\n\thomeLocation,\n}) => {\n\ttry {\n\t\tconst profiles = await fs.readJson(storeConfig);\n\t\t// if the profile already exists, do nothing\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\t// if the profile does not exist, create\n\t\t// a folder named as the profile under the storeLocation folder,\n\t\t// with the existing npmrc / yarnrc files\n\t\tawait fs.ensureDir(`${storeLocation}/${profileName}`);\n\t\t// copy the existing npmrc / yarnrc files to the new folder\n\t\tconst NPMRC = `${homeLocation}/.npmrc`;\n\t\tconst YARNRC = `${homeLocation}/.yarnrc`;\n\t\tif (await fs.pathExists(YARNRC)) {\n\t\t\tawait fs.copy(YARNRC, `${storeLocation}/${profileName}/yarnrc`);\n\t\t}\n\t\tif (await fs.pathExists(NPMRC)) {\n\t\t\tawait fs.copy(NPMRC, `${storeLocation}/${profileName}/npmrc`);\n\t\t}\n\t\t// then add the profile to the configuration file\n\t\tconst newProfiles = {\n\t\t\tavailable: [...profiles.available, profileName],\n\t\t\tenabled: profiles.enabled,\n\t\t};\n\t\tawait fs.writeJson(storeConfig, newProfiles, { spaces: 2 });\n\t\tlogger.printBox(`Profile '${profileName}' created`, {\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 create profile\");\n\t\treturn 1;\n\t}\n};\n\nexport const switchProfile = async ({\n\tflags,\n\tstoreConfig,\n\tstoreLocation,\n\tprofileName,\n\thomeLocation,\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\tlogger.printBox(`Profile switched to '${profileName}'`, {\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\nexport const deleteProfile = async ({\n\tflags,\n\tprofileName,\n\tstoreConfig,\n\tstoreLocation,\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","kleur","logger","boring","process","env","NODE_ENV","listProfiles","flags","storeConfig","profiles","readJson","available","length","activeProfile","enabled","messages","undefined","green","profile","push","printBox","join","textAlignment","title","borderColor","warn","error","verbose","log","createProfile","storeLocation","profileName","homeLocation","includes","ensureDir","NPMRC","YARNRC","pathExists","copy","newProfiles","writeJson","spaces","switchProfile","PROFILE_NPMRC","PROFILE_YARNRC","overwrite","deleteProfile","remove","filter"],"mappings":"AAAA,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,WAAW,QAAQ;AAE1B,OAAO,MAAMC,SAAS,IAAIH,SAAS;AACnCG,OAAOC,MAAM,GAAGC,QAAQC,GAAG,CAACC,QAAQ,KAAK;AAEzC,OAAO,MAAMC,eAAe,OAA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MrB,WAAW,MAAMV,GAAGW,QAAQ,CAACF;QACnC,IAAI,CAACC,SAASE,SAAS,CAACsB,QAAQ,CAACF,cAAc;YAC9C9B,OAAOyB,KAAK,CAAC,CAAC,SAAS,EAAEK,YAAY,gBAAgB,CAAC;YACtD,OAAO;QACR;QACA,wCAAwC;QACxC,IAAItB,SAASK,OAAO,KAAKiB,aAAa;YACrC9B,OAAOyB,KAAK,CAAC,CAAC,SAAS,EAAEK,YAAY,qBAAqB,CAAC;YAC3D,OAAO;QACR;QACA,8DAA8D;QAC9D,MAAMhC,GAAGgD,MAAM,CAAC,CAAC,EAAEjB,cAAc,CAAC,EAAEC,YAAY,CAAC;QACjD,sDAAsD;QACtD,MAAMQ,cAAc;YACnB5B,WAAWF,SAASE,SAAS,CAACqC,MAAM,CACnC,CAAC9B,UAAiBA,YAAYa;YAE/BjB,SAASL,SAASK,OAAO;QAC1B;QACA,MAAMf,GAAGyC,SAAS,CAAChC,aAAa+B,aAAa;YAAEE,QAAQ;QAAE;QACzDxC,OAAOmB,QAAQ,CAAC,CAAC,SAAS,EAAEW,YAAY,SAAS,CAAC,EAAE;YACnDT,eAAe;YACfC,OAAO;YACPC,aAAa;QACd;QACA,OAAO;IACR,EAAE,OAAOE,OAAO;QACf,IAAInB,MAAMoB,OAAO,EAAE;YAClB1B,OAAO2B,GAAG,CAACF;QACZ;QACAzB,OAAOyB,KAAK,CAAC;QACb,OAAO;IACR;AACD,EAAE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@node-cli/npmrc",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Arno Versini",
|
|
6
|
+
"description": "Toggle different npmrc configuration files on the fly",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": "./dist/npmrc.js",
|
|
10
|
+
"bin": "dist/npmrc.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"node": ">=18",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "npm-run-all --serial clean build:types build:js build:barrel",
|
|
17
|
+
"build:barrel": "barrelsby --delete --directory dist --pattern \"**/*.d.ts\" --name \"index.d\"",
|
|
18
|
+
"build:js": "swc --source-maps --out-dir dist src",
|
|
19
|
+
"build:types": "tsc",
|
|
20
|
+
"clean": "rimraf dist types coverage",
|
|
21
|
+
"lint": "prettier --write \"src/*.ts\" && eslint --fix \"src/*.ts\"",
|
|
22
|
+
"test": "cross-env-shell NODE_OPTIONS=--experimental-vm-modules TZ=UTC jest",
|
|
23
|
+
"test:coverage": "npm run test -- --coverage",
|
|
24
|
+
"test:watch": "npm run test -- --watch",
|
|
25
|
+
"watch": "swc --watch --out-dir dist src"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@node-cli/logger": ">=1.2.2",
|
|
29
|
+
"@node-cli/parser": ">=2.2.3",
|
|
30
|
+
"fs-extra": "11.2.0",
|
|
31
|
+
"kleur": "4.1.5"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"gitHead": "1e911dd50d20399d3ed9a8bfc860237212a3f0b6"
|
|
37
|
+
}
|