@node-cli/secret 1.2.6 → 1.2.7
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/parse.js +1 -1
- package/dist/parse.js.map +1 -1
- package/dist/utilities.js +4 -4
- package/dist/utilities.js.map +1 -1
- package/package.json +9 -9
package/dist/parse.js
CHANGED
package/dist/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/parse.ts"],"sourcesContent":["/* v8 ignore start */\nimport { parser } from \"@node-cli/parser\";\nimport kleur from \"kleur\";\n\nexport type Flags = {\n\tdecrypt?: boolean;\n\tencrypt?: boolean;\n\thelp?: boolean;\n\tversion?: boolean;\n};\n\nexport type Parameters = {\n\tinput?: string;\n\toutput?: string;\n};\n\nexport type Configuration = {\n\tflags?: Flags;\n\tparameters?: Parameters;\n};\n\
|
|
1
|
+
{"version":3,"sources":["../src/parse.ts"],"sourcesContent":["/* v8 ignore start */\nimport { parser } from \"@node-cli/parser\";\nimport kleur from \"kleur\";\n\nexport type Flags = {\n\tdecrypt?: boolean;\n\tencrypt?: boolean;\n\thelp?: boolean;\n\tversion?: boolean;\n};\n\nexport type Parameters = {\n\tinput?: string;\n\toutput?: string;\n};\n\nexport type Configuration = {\n\tflags?: Flags;\n\tparameters?: Parameters;\n};\n\nexport const config: Configuration = parser({\n\tmeta: import.meta,\n\texamples: [\n\t\t{\n\t\t\tcommand: 'secret -e \"my-file.txt\" \"my-file.txt.enc\"',\n\t\t\tcomment:\n\t\t\t\t'## Encrypt the file \"my-file.txt\" and save the result in\\n ## \"my-file.txt.enc\" - password will be prompted',\n\t\t},\n\t\t{\n\t\t\tcommand: 'secret -d \"my-file.txt.enc\" \"my-file.txt\"',\n\t\t\tcomment: `## Decrypt the file \"my-file.txt.enc\" and save the\\n ## result in \"my-file.txt\" - password will be prompted`,\n\t\t},\n\t],\n\tflags: {\n\t\tdecrypt: {\n\t\t\tshortFlag: \"d\",\n\t\t\tdescription: `Decrypt a password protected file`,\n\t\t\ttype: \"boolean\",\n\t\t},\n\t\tencrypt: {\n\t\t\tshortFlag: \"e\",\n\t\t\tdescription: `Encrypt a file with a password`,\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\tinput: {\n\t\t\tdescription: \"The file to encrypt or decrypt\",\n\t\t},\n\t\toutput: {\n\t\t\tdescription:\n\t\t\t\t\"The file to create in order to save the result of the encryption or decryption\",\n\t\t},\n\t},\n\trestrictions: [\n\t\t{\n\t\t\texit: 1,\n\t\t\tmessage: () =>\n\t\t\t\tkleur.red(\n\t\t\t\t\t`\\nError: one of --encrypt or --decrypt option must be provided.`,\n\t\t\t\t),\n\t\t\ttest: (x: { encrypt: boolean; decrypt: boolean }) =>\n\t\t\t\tx.encrypt === false && x.decrypt === false,\n\t\t},\n\t\t{\n\t\t\texit: 1,\n\t\t\tmessage: () =>\n\t\t\t\tkleur.red(\n\t\t\t\t\t`\\nError: either --encrypt or --decrypt option must be provided, but not both.`,\n\t\t\t\t),\n\t\t\ttest: (x: { encrypt: boolean; decrypt: boolean }) =>\n\t\t\t\tx.encrypt === true && x.decrypt === true,\n\t\t},\n\t],\n\n\tusage: \"secret [options] [input] [output]\",\n});\n/* v8 ignore stop */\n"],"names":["parser","kleur","config","meta","examples","command","comment","flags","decrypt","shortFlag","description","type","encrypt","help","version","parameters","input","output","restrictions","exit","message","red","test","x","usage"],"mappings":"AAAA,mBAAmB,GACnB,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,WAAW,QAAQ;AAmB1B,OAAO,MAAMC,SAAwBF,OAAO;IAC3CG,MAAM;IACNC,UAAU;QACT;YACCC,SAAS;YACTC,SACC;QACF;QACA;YACCD,SAAS;YACTC,SAAS,CAAC,8GAA8G,CAAC;QAC1H;KACA;IACDC,OAAO;QACNC,SAAS;YACRC,WAAW;YACXC,aAAa,CAAC,iCAAiC,CAAC;YAChDC,MAAM;QACP;QACAC,SAAS;YACRH,WAAW;YACXC,aAAa,CAAC,8BAA8B,CAAC;YAC7CC,MAAM;QACP;QACAE,MAAM;YACLJ,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;QACAG,SAAS;YACRL,WAAW;YACXC,aAAa;YACbC,MAAM;QACP;IACD;IACAI,YAAY;QACXC,OAAO;YACNN,aAAa;QACd;QACAO,QAAQ;YACPP,aACC;QACF;IACD;IACAQ,cAAc;QACb;YACCC,MAAM;YACNC,SAAS,IACRnB,MAAMoB,GAAG,CACR,CAAC,+DAA+D,CAAC;YAEnEC,MAAM,CAACC,IACNA,EAAEX,OAAO,KAAK,SAASW,EAAEf,OAAO,KAAK;QACvC;QACA;YACCW,MAAM;YACNC,SAAS,IACRnB,MAAMoB,GAAG,CACR,CAAC,6EAA6E,CAAC;YAEjFC,MAAM,CAACC,IACNA,EAAEX,OAAO,KAAK,QAAQW,EAAEf,OAAO,KAAK;QACtC;KACA;IAEDgB,OAAO;AACR,GAAG,CACH,kBAAkB"}
|
package/dist/utilities.js
CHANGED
|
@@ -19,7 +19,7 @@ export const processFileWithPassword = async (options)=>{
|
|
|
19
19
|
logger.log(fileProcessor(password, data));
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
/* v8 ignore
|
|
22
|
+
/* v8 ignore start */ export const displayConfirmation = async (message)=>{
|
|
23
23
|
const questions = {
|
|
24
24
|
default: true,
|
|
25
25
|
message: message || "Do you want to continue?",
|
|
@@ -30,7 +30,7 @@ export const processFileWithPassword = async (options)=>{
|
|
|
30
30
|
const answers = await inquirer.prompt(questions);
|
|
31
31
|
return answers.goodToGo;
|
|
32
32
|
};
|
|
33
|
-
|
|
33
|
+
export const displayPromptWithPassword = async (message)=>{
|
|
34
34
|
const questions = {
|
|
35
35
|
message: message,
|
|
36
36
|
name: "password",
|
|
@@ -45,13 +45,13 @@ export const processFileWithPassword = async (options)=>{
|
|
|
45
45
|
const answers = await inquirer.prompt(questions);
|
|
46
46
|
return answers.password;
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
export const shouldContinue = (goodToGo)=>{
|
|
49
49
|
if (!goodToGo) {
|
|
50
50
|
logger.log("\nBye then!");
|
|
51
51
|
// eslint-disable-next-line unicorn/no-process-exit
|
|
52
52
|
process.exit(0);
|
|
53
53
|
}
|
|
54
54
|
return true;
|
|
55
|
-
};
|
|
55
|
+
}; /* v8 ignore stop */
|
|
56
56
|
|
|
57
57
|
//# sourceMappingURL=utilities.js.map
|
package/dist/utilities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utilities.ts"],"sourcesContent":["import { Logger } from \"@node-cli/logger\";\nimport fs from \"fs-extra\";\nimport inquirer from \"inquirer\";\n\nimport { decrypt, encrypt } from \"./lib.js\";\n\nexport const logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\n\nconst UTF8 = \"utf8\";\nconst DEFAULT_FILE_ENCODING = UTF8;\n\n/**\n * Process a file with a given password. The file can be encoded or decoded\n * depending on the `encode` flag.\n * @param {Boolean} encode whether to encode or decode the file\n * @param {String} input the input file path\n * @param {String} [output] the output file path\n * @param {String} password the password to use\n * @return {Promise} a promise that resolves when\n * the file has been processed.\n */\nexport type ProcessFileOptions = {\n\tencode: boolean;\n\tinput: string;\n\toutput?: string;\n\tpassword: string;\n};\nexport const processFileWithPassword = async (\n\toptions: ProcessFileOptions,\n): Promise<void> => {\n\tconst { encode, input, output, password } = options;\n\tconst fileProcessor = encode ? encrypt : decrypt;\n\tconst data = await fs.readFile(input, DEFAULT_FILE_ENCODING);\n\n\tif (output) {\n\t\t// Save data to output file.\n\t\tawait fs.outputFile(output, fileProcessor(password, data));\n\t} else {\n\t\t// Print to stdout directly.\n\t\tlogger.log(fileProcessor(password, data));\n\t}\n};\n\n/* v8 ignore
|
|
1
|
+
{"version":3,"sources":["../src/utilities.ts"],"sourcesContent":["import { Logger } from \"@node-cli/logger\";\nimport fs from \"fs-extra\";\nimport inquirer from \"inquirer\";\n\nimport { decrypt, encrypt } from \"./lib.js\";\n\nexport const logger = new Logger({\n\tboring: process.env.NODE_ENV === \"test\",\n});\n\nconst UTF8 = \"utf8\";\nconst DEFAULT_FILE_ENCODING = UTF8;\n\n/**\n * Process a file with a given password. The file can be encoded or decoded\n * depending on the `encode` flag.\n * @param {Boolean} encode whether to encode or decode the file\n * @param {String} input the input file path\n * @param {String} [output] the output file path\n * @param {String} password the password to use\n * @return {Promise} a promise that resolves when\n * the file has been processed.\n */\nexport type ProcessFileOptions = {\n\tencode: boolean;\n\tinput: string;\n\toutput?: string;\n\tpassword: string;\n};\nexport const processFileWithPassword = async (\n\toptions: ProcessFileOptions,\n): Promise<void> => {\n\tconst { encode, input, output, password } = options;\n\tconst fileProcessor = encode ? encrypt : decrypt;\n\tconst data = await fs.readFile(input, DEFAULT_FILE_ENCODING);\n\n\tif (output) {\n\t\t// Save data to output file.\n\t\tawait fs.outputFile(output, fileProcessor(password, data));\n\t} else {\n\t\t// Print to stdout directly.\n\t\tlogger.log(fileProcessor(password, data));\n\t}\n};\n\n/* v8 ignore start */\nexport const displayConfirmation = async (message: string) => {\n\tconst questions = {\n\t\tdefault: true,\n\t\tmessage: message || \"Do you want to continue?\",\n\t\tname: \"goodToGo\",\n\t\ttype: \"confirm\",\n\t};\n\tlogger.log();\n\tconst answers = await inquirer.prompt(questions);\n\treturn answers.goodToGo;\n};\n\nexport const displayPromptWithPassword = async (message: string) => {\n\tconst questions = {\n\t\tmessage: message,\n\t\tname: \"password\",\n\t\ttype: \"password\",\n\t\tvalidate(value: string) {\n\t\t\tif (!value) {\n\t\t\t\treturn \"Password cannot be empty...\";\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t};\n\tconst answers = await inquirer.prompt(questions);\n\treturn answers.password;\n};\n\nexport const shouldContinue = (goodToGo: boolean) => {\n\tif (!goodToGo) {\n\t\tlogger.log(\"\\nBye then!\");\n\t\t// eslint-disable-next-line unicorn/no-process-exit\n\t\tprocess.exit(0);\n\t}\n\treturn true;\n};\n/* v8 ignore stop */\n"],"names":["Logger","fs","inquirer","decrypt","encrypt","logger","boring","process","env","NODE_ENV","UTF8","DEFAULT_FILE_ENCODING","processFileWithPassword","options","encode","input","output","password","fileProcessor","data","readFile","outputFile","log","displayConfirmation","message","questions","default","name","type","answers","prompt","goodToGo","displayPromptWithPassword","validate","value","shouldContinue","exit"],"mappings":"AAAA,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,cAAc,WAAW;AAEhC,SAASC,OAAO,EAAEC,OAAO,QAAQ,WAAW;AAE5C,OAAO,MAAMC,SAAS,IAAIL,OAAO;IAChCM,QAAQC,QAAQC,GAAG,CAACC,QAAQ,KAAK;AAClC,GAAG;AAEH,MAAMC,OAAO;AACb,MAAMC,wBAAwBD;AAkB9B,OAAO,MAAME,0BAA0B,OACtCC;IAEA,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGJ;IAC5C,MAAMK,gBAAgBJ,SAASV,UAAUD;IACzC,MAAMgB,OAAO,MAAMlB,GAAGmB,QAAQ,CAACL,OAAOJ;IAEtC,IAAIK,QAAQ;QACX,4BAA4B;QAC5B,MAAMf,GAAGoB,UAAU,CAACL,QAAQE,cAAcD,UAAUE;IACrD,OAAO;QACN,4BAA4B;QAC5Bd,OAAOiB,GAAG,CAACJ,cAAcD,UAAUE;IACpC;AACD,EAAE;AAEF,mBAAmB,GACnB,OAAO,MAAMI,sBAAsB,OAAOC;IACzC,MAAMC,YAAY;QACjBC,SAAS;QACTF,SAASA,WAAW;QACpBG,MAAM;QACNC,MAAM;IACP;IACAvB,OAAOiB,GAAG;IACV,MAAMO,UAAU,MAAM3B,SAAS4B,MAAM,CAACL;IACtC,OAAOI,QAAQE,QAAQ;AACxB,EAAE;AAEF,OAAO,MAAMC,4BAA4B,OAAOR;IAC/C,MAAMC,YAAY;QACjBD,SAASA;QACTG,MAAM;QACNC,MAAM;QACNK,UAASC,KAAa;YACrB,IAAI,CAACA,OAAO;gBACX,OAAO;YACR;YACA,OAAO;QACR;IACD;IACA,MAAML,UAAU,MAAM3B,SAAS4B,MAAM,CAACL;IACtC,OAAOI,QAAQZ,QAAQ;AACxB,EAAE;AAEF,OAAO,MAAMkB,iBAAiB,CAACJ;IAC9B,IAAI,CAACA,UAAU;QACd1B,OAAOiB,GAAG,CAAC;QACX,mDAAmD;QACnDf,QAAQ6B,IAAI,CAAC;IACd;IACA,OAAO;AACR,EAAE,CACF,kBAAkB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-cli/secret",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"description": "Secret is a CLI tool that can encode or decode a file with a password",
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
"watch": "swc --strip-leading-paths --watch --out-dir dist src"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@node-cli/logger": "1.3.
|
|
32
|
-
"@node-cli/parser": "2.4.
|
|
33
|
-
"fs-extra": "11.3.
|
|
34
|
-
"inquirer": "
|
|
31
|
+
"@node-cli/logger": "1.3.3",
|
|
32
|
+
"@node-cli/parser": "2.4.4",
|
|
33
|
+
"fs-extra": "11.3.3",
|
|
34
|
+
"inquirer": "13.1.0"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@node-cli/comments": "0.2.
|
|
41
|
-
"@vitest/coverage-v8": "
|
|
42
|
-
"vitest": "
|
|
40
|
+
"@node-cli/comments": "0.2.7",
|
|
41
|
+
"@vitest/coverage-v8": "4.0.16",
|
|
42
|
+
"vitest": "4.0.16"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "096003826471508d839f2ec3346bb12b1a73b7fe"
|
|
45
45
|
}
|