@aenode/cli 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +24 -2
  2. package/assets/favicon.svg +1 -0
  3. package/bin/aenode.mjs +2 -0
  4. package/dist/commands/bye/bye.d.ts +3 -0
  5. package/dist/commands/bye/bye.d.ts.map +1 -0
  6. package/dist/commands/bye/bye.js +7 -0
  7. package/dist/commands/bye/bye.js.map +1 -0
  8. package/dist/commands/history/history.d.ts +3 -0
  9. package/dist/commands/history/history.d.ts.map +1 -0
  10. package/dist/commands/history/history.js +29 -0
  11. package/dist/commands/history/history.js.map +1 -0
  12. package/dist/commands/merge/merge.d.ts +3 -0
  13. package/dist/commands/merge/merge.d.ts.map +1 -0
  14. package/dist/commands/merge/merge.js +37 -0
  15. package/dist/commands/merge/merge.js.map +1 -0
  16. package/dist/commands/rename/rename.d.ts +3 -0
  17. package/dist/commands/rename/rename.d.ts.map +1 -0
  18. package/dist/commands/rename/rename.js +42 -0
  19. package/dist/commands/rename/rename.js.map +1 -0
  20. package/dist/commands/replace/replace.d.ts +3 -0
  21. package/dist/commands/replace/replace.d.ts.map +1 -0
  22. package/dist/commands/replace/replace.js +32 -0
  23. package/dist/commands/replace/replace.js.map +1 -0
  24. package/dist/commands/uuid/uuid.d.ts +3 -0
  25. package/dist/commands/uuid/uuid.d.ts.map +1 -0
  26. package/dist/commands/uuid/uuid.js +23 -0
  27. package/dist/commands/uuid/uuid.js.map +1 -0
  28. package/dist/log/log.d.ts +5 -0
  29. package/dist/log/log.d.ts.map +1 -0
  30. package/dist/log/log.js +19 -0
  31. package/dist/log/log.js.map +1 -0
  32. package/dist/main.d.ts +2 -0
  33. package/dist/main.d.ts.map +1 -0
  34. package/dist/main.js +24 -0
  35. package/dist/main.js.map +1 -0
  36. package/package.json +65 -4
package/README.md CHANGED
@@ -1,3 +1,25 @@
1
- # Temporary Holding Version
1
+ ![Version](https://img.shields.io/npm/v/@aenode/cli) ![Downloads](https://img.shields.io/npm/dm/@aenode/cli) ![Status](https://img.shields.io/github/actions/workflow/status/aenode/aenode/ci.yml) ![Size](https://img.shields.io/bundlephobia/min/@aenode/cli)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <p align="center">
4
+ <img src="https://aenode.github.io/aenode/tools/cli/assets/favicon.svg" alt="aenode Logo" height="128" width="128" style="border-radius: 32px;"/>
5
+ </p>
6
+
7
+ ## @aenode/cli
8
+
9
+ Aenode cli tool
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ bun add @aenode/cli
15
+ ```
16
+
17
+ ## Examples
18
+
19
+ ```ts
20
+ const message = 'Hello there';
21
+ ```
22
+
23
+ ---
24
+
25
+ [![CashUp](https://img.shields.io/badge/Cash%20Up-%23EA4AAA.svg?style=for-the-badge&logo=github-sponsors&logoColor=white)](https://cash.app/$puqlib) [![EmainMe](https://img.shields.io/badge/Email-D14836?style=for-the-badge&logo=proton&logoColor=white)](mailto:aenode+aenode@-cliproton.me)
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" height="48px" width="48px" fill="#5985E1"><path d="M22.93,41.57Q22.5,41.14 22.5,40.5V27.6l-9.1,9.1q-0.44,0.45-1.04,0.45T11.3,36.71t-0.45-1.05T11.3,34.6l9.1-9.1H7.5q-0.64,0-1.07-0.43T6,23.99t0.43-1.07T7.5,22.5H20.45L11.3,13.35q-0.45-0.44-0.45-1.05t0.44-1.05t1.05-0.45t1.06,0.45l9.1,9.1V7.5q0-0.64 0.43-1.07T24.01,6t1.07,0.43T25.5,7.5V20.4l9.15-9.15q0.44-0.45 1.05-0.45t1.05,0.44t0.45,1.05t-0.45,1.06L27.6,22.5H40.5q0.64,0 1.07,0.43T42,24.01t-0.43,1.07T40.5,25.5H27.65l9.1,9.1q0.45,0.44 0.45,1.04T36.76,36.7t-1.05,0.45T34.65,36.7L25.5,27.55V40.5q0,0.64-0.43,1.07T23.99,42t-1.07-0.43Z"/></svg>
package/bin/aenode.mjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/main.js';
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ export declare function bye(program: Command): void;
3
+ //# sourceMappingURL=bye.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bye.d.ts","sourceRoot":"","sources":["../../../src/commands/bye/bye.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,wBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,QAOnC"}
@@ -0,0 +1,7 @@
1
+ export function bye(program) {
2
+ program.command('bye').requiredOption('-u,--username <string>', 'Say bye to user').action(({ username })=>{
3
+ console.log(`Bye, ${username}`);
4
+ });
5
+ }
6
+
7
+ //# sourceMappingURL=bye.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/commands/bye/bye.ts"],"sourcesContent":["import type { Command } from 'commander';\n\nexport function bye(program: Command) {\n program\n .command('bye')\n .requiredOption('-u,--username <string>', 'Say bye to user')\n .action(({ username }) => {\n console.log(`Bye, ${username}`);\n });\n}\n"],"names":["bye","program","command","requiredOption","action","username","console","log"],"mappings":"AAEA,OAAO,SAASA,IAAIC,OAAgB;IAClCA,QACGC,OAAO,CAAC,OACRC,cAAc,CAAC,0BAA0B,mBACzCC,MAAM,CAAC,CAAC,EAAEC,QAAQ,EAAE;QACnBC,QAAQC,GAAG,CAAC,CAAC,KAAK,EAAEF,UAAU;IAChC;AACJ"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ export declare function history(program: Command): void;
3
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/commands/history/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,QAmCvC"}
@@ -0,0 +1,29 @@
1
+ import { execSync } from 'node:child_process';
2
+ import { clearLogs, readLogs } from '../../log/log.js';
3
+ export function history(program) {
4
+ program.command('history').description('Manage history').option('-c,--clear', 'Clean up the history log').option('-r,--run <number>', 'Run command from history by index').action(async ({ clear, run })=>{
5
+ if (clear === true) {
6
+ await clearLogs();
7
+ return;
8
+ }
9
+ const logs = await readLogs();
10
+ if (run && run > 0) {
11
+ const command = logs.split('\n')[run - 1];
12
+ if (command) {
13
+ const logParts = command.split(' ');
14
+ const cleanCommand = logParts.slice(1, logParts.length - 1).join(' ').trim();
15
+ console.log('Command: ', cleanCommand);
16
+ if (cleanCommand) {
17
+ execSync(cleanCommand, {
18
+ stdio: 'inherit'
19
+ });
20
+ }
21
+ } else {
22
+ throw new Error(`History does not have ${run} index`);
23
+ }
24
+ }
25
+ console.log(logs);
26
+ });
27
+ }
28
+
29
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/commands/history/history.ts"],"sourcesContent":["import type { Command } from 'commander';\nimport { execSync } from 'node:child_process';\nimport { clearLogs, readLogs } from '../../log/log.js';\n\nexport function history(program: Command) {\n program\n .command('history')\n .description('Manage history')\n .option('-c,--clear', 'Clean up the history log')\n .option('-r,--run <number>', 'Run command from history by index')\n .action(async ({ clear, run }) => {\n if (clear === true) {\n await clearLogs();\n return;\n }\n const logs = await readLogs();\n\n if (run && run > 0) {\n const command = logs.split('\\n')[(run as number) - 1];\n\n if (command) {\n const logParts = command.split(' ');\n\n const cleanCommand = logParts\n .slice(1, logParts.length - 1)\n .join(' ')\n .trim();\n\n console.log('Command: ', cleanCommand);\n if (cleanCommand) {\n execSync(cleanCommand, { stdio: 'inherit' });\n }\n } else {\n throw new Error(`History does not have ${run} index`);\n }\n }\n\n console.log(logs);\n });\n}\n"],"names":["execSync","clearLogs","readLogs","history","program","command","description","option","action","clear","run","logs","split","logParts","cleanCommand","slice","length","join","trim","console","log","stdio","Error"],"mappings":"AACA,SAASA,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,SAAS,EAAEC,QAAQ,QAAQ,mBAAmB;AAEvD,OAAO,SAASC,QAAQC,OAAgB;IACtCA,QACGC,OAAO,CAAC,WACRC,WAAW,CAAC,kBACZC,MAAM,CAAC,cAAc,4BACrBA,MAAM,CAAC,qBAAqB,qCAC5BC,MAAM,CAAC,OAAO,EAAEC,KAAK,EAAEC,GAAG,EAAE;QAC3B,IAAID,UAAU,MAAM;YAClB,MAAMR;YACN;QACF;QACA,MAAMU,OAAO,MAAMT;QAEnB,IAAIQ,OAAOA,MAAM,GAAG;YAClB,MAAML,UAAUM,KAAKC,KAAK,CAAC,KAAK,CAAC,AAACF,MAAiB,EAAE;YAErD,IAAIL,SAAS;gBACX,MAAMQ,WAAWR,QAAQO,KAAK,CAAC;gBAE/B,MAAME,eAAeD,SAClBE,KAAK,CAAC,GAAGF,SAASG,MAAM,GAAG,GAC3BC,IAAI,CAAC,KACLC,IAAI;gBAEPC,QAAQC,GAAG,CAAC,cAAcN;gBAC1B,IAAIA,cAAc;oBAChBd,SAASc,cAAc;wBAAEO,OAAO;oBAAU;gBAC5C;YACF,OAAO;gBACL,MAAM,IAAIC,MAAM,CAAC,sBAAsB,EAAEZ,IAAI,MAAM,CAAC;YACtD;QACF;QAEAS,QAAQC,GAAG,CAACT;IACd;AACJ"}
@@ -0,0 +1,3 @@
1
+ import { type Command } from 'commander';
2
+ export declare function merge(program: Command): void;
3
+ //# sourceMappingURL=merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/commands/merge/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAMjD,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,QAqCrC"}
@@ -0,0 +1,37 @@
1
+ import { Option } from 'commander';
2
+ import { createReadStream, createWriteStream } from 'node:fs';
3
+ import { mkdir } from 'node:fs/promises';
4
+ import { dirname } from 'node:path';
5
+ import { finished, pipeline } from 'node:stream/promises';
6
+ export function merge(program) {
7
+ program.command('merge').description('Merge files into the target file').requiredOption('-s,--source <paths...>', 'Source file paths').requiredOption('-d,--destination <path>', 'Destination file path').addOption(new Option('-t,--type <string>', 'File type').choices([
8
+ 'json',
9
+ 'txt'
10
+ ]).default('txt')).action(async ({ source, destination, type })=>{
11
+ await mkdir(dirname(destination), {
12
+ recursive: true
13
+ });
14
+ const out = createWriteStream(destination);
15
+ if (type === 'json') {
16
+ out.write('[\n');
17
+ }
18
+ try {
19
+ for (const [i, s] of source.entries()){
20
+ await pipeline(createReadStream(s), out, {
21
+ end: false
22
+ });
23
+ if (type === 'json' && i < source.length - 1) {
24
+ out.write(',');
25
+ }
26
+ }
27
+ } finally{
28
+ if (type === 'json') {
29
+ out.write('\n]');
30
+ }
31
+ out.end();
32
+ }
33
+ await finished(out);
34
+ });
35
+ }
36
+
37
+ //# sourceMappingURL=merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/commands/merge/merge.ts"],"sourcesContent":["import { Option, type Command } from 'commander';\nimport { createReadStream, createWriteStream } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { dirname } from 'node:path';\nimport { finished, pipeline } from 'node:stream/promises';\n\nexport function merge(program: Command) {\n program\n .command('merge')\n .description('Merge files into the target file')\n\n .requiredOption('-s,--source <paths...>', 'Source file paths')\n .requiredOption('-d,--destination <path>', 'Destination file path')\n .addOption(\n new Option('-t,--type <string>', 'File type')\n .choices(['json', 'txt'])\n .default('txt'),\n )\n .action(async ({ source, destination, type }) => {\n await mkdir(dirname(destination), { recursive: true });\n\n const out = createWriteStream(destination);\n\n if (type === 'json') {\n out.write('[\\n');\n }\n\n try {\n for (const [i, s] of source.entries()) {\n await pipeline(createReadStream(s), out, { end: false });\n if (type === 'json' && i < source.length - 1) {\n out.write(',');\n }\n }\n } finally {\n if (type === 'json') {\n out.write('\\n]');\n }\n out.end();\n }\n\n await finished(out);\n });\n}\n"],"names":["Option","createReadStream","createWriteStream","mkdir","dirname","finished","pipeline","merge","program","command","description","requiredOption","addOption","choices","default","action","source","destination","type","recursive","out","write","i","s","entries","end","length"],"mappings":"AAAA,SAASA,MAAM,QAAsB,YAAY;AACjD,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,UAAU;AAC9D,SAASC,KAAK,QAAQ,mBAAmB;AACzC,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,uBAAuB;AAE1D,OAAO,SAASC,MAAMC,OAAgB;IACpCA,QACGC,OAAO,CAAC,SACRC,WAAW,CAAC,oCAEZC,cAAc,CAAC,0BAA0B,qBACzCA,cAAc,CAAC,2BAA2B,yBAC1CC,SAAS,CACR,IAAIZ,OAAO,sBAAsB,aAC9Ba,OAAO,CAAC;QAAC;QAAQ;KAAM,EACvBC,OAAO,CAAC,QAEZC,MAAM,CAAC,OAAO,EAAEC,MAAM,EAAEC,WAAW,EAAEC,IAAI,EAAE;QAC1C,MAAMf,MAAMC,QAAQa,cAAc;YAAEE,WAAW;QAAK;QAEpD,MAAMC,MAAMlB,kBAAkBe;QAE9B,IAAIC,SAAS,QAAQ;YACnBE,IAAIC,KAAK,CAAC;QACZ;QAEA,IAAI;YACF,KAAK,MAAM,CAACC,GAAGC,EAAE,IAAIP,OAAOQ,OAAO,GAAI;gBACrC,MAAMlB,SAASL,iBAAiBsB,IAAIH,KAAK;oBAAEK,KAAK;gBAAM;gBACtD,IAAIP,SAAS,UAAUI,IAAIN,OAAOU,MAAM,GAAG,GAAG;oBAC5CN,IAAIC,KAAK,CAAC;gBACZ;YACF;QACF,SAAU;YACR,IAAIH,SAAS,QAAQ;gBACnBE,IAAIC,KAAK,CAAC;YACZ;YACAD,IAAIK,GAAG;QACT;QAEA,MAAMpB,SAASe;IACjB;AACJ"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ export declare function rename(program: Command): void;
3
+ //# sourceMappingURL=rename.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rename.d.ts","sourceRoot":"","sources":["../../../src/commands/rename/rename.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,QAyDtC"}
@@ -0,0 +1,42 @@
1
+ import { rename as fsRename, readdir } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { cwd } from 'node:process';
4
+ export function rename(program) {
5
+ program.command('rename').description('Rename multiple files based on file extention').option('-e,--extention <extentions...>', 'Include the files with the extention only').option('-t,--target <string>', 'Target working directory', cwd()).option('-p,--prefix <string>', 'Prefix to add the file name').option('-s,--suffix <string>', 'Suffix to add the file name').option('-u,--undo', 'Undo the operation').option('-r,--recursive', 'Include sub directories').action(async ({ target, extention, prefix, suffix, recursive, undo })=>{
6
+ const dridents = await readdir(target, {
7
+ recursive,
8
+ withFileTypes: true
9
+ });
10
+ const files = dridents.filter((e)=>e.isFile()).filter((e)=>{
11
+ if (extention) {
12
+ return extention.some((ex)=>e.name.endsWith(ex));
13
+ }
14
+ return true;
15
+ });
16
+ for (const f of files){
17
+ const oldPath = join(f.parentPath, f.name);
18
+ const oldFileName = f.name;
19
+ let newFileName = oldFileName;
20
+ if (undo) {
21
+ if (prefix) {
22
+ newFileName = newFileName.replace(new RegExp(`^${prefix}`), '');
23
+ }
24
+ if (suffix) {
25
+ newFileName = newFileName.replace(new RegExp(`${suffix}$`), '');
26
+ }
27
+ } else {
28
+ if (prefix) {
29
+ newFileName = prefix + newFileName;
30
+ }
31
+ if (suffix) {
32
+ newFileName = newFileName + suffix;
33
+ }
34
+ }
35
+ if (newFileName !== oldFileName) {
36
+ await fsRename(oldPath, join(f.parentPath, newFileName));
37
+ }
38
+ }
39
+ });
40
+ }
41
+
42
+ //# sourceMappingURL=rename.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/commands/rename/rename.ts"],"sourcesContent":["import type { Command } from 'commander';\nimport { rename as fsRename, readdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { cwd } from 'node:process';\n\nexport function rename(program: Command) {\n program\n .command('rename')\n .description('Rename multiple files based on file extention')\n .option(\n '-e,--extention <extentions...>',\n 'Include the files with the extention only',\n )\n .option('-t,--target <string>', 'Target working directory', cwd())\n .option('-p,--prefix <string>', 'Prefix to add the file name')\n .option('-s,--suffix <string>', 'Suffix to add the file name')\n .option('-u,--undo', 'Undo the operation')\n .option('-r,--recursive', 'Include sub directories')\n .action(async ({ target, extention, prefix, suffix, recursive, undo }) => {\n const dridents = await readdir(target, {\n recursive,\n withFileTypes: true,\n });\n\n const files = dridents\n .filter((e) => e.isFile())\n .filter((e) => {\n if (extention) {\n return extention.some((ex: string) => e.name.endsWith(ex));\n }\n return true;\n });\n\n for (const f of files) {\n const oldPath = join(f.parentPath, f.name);\n const oldFileName = f.name;\n\n let newFileName = oldFileName;\n\n if (undo) {\n if (prefix) {\n newFileName = newFileName.replace(new RegExp(`^${prefix}`), '');\n }\n\n if (suffix) {\n newFileName = newFileName.replace(new RegExp(`${suffix}$`), '');\n }\n } else {\n if (prefix) {\n newFileName = prefix + newFileName;\n }\n\n if (suffix) {\n newFileName = newFileName + suffix;\n }\n }\n\n if (newFileName !== oldFileName) {\n await fsRename(oldPath, join(f.parentPath, newFileName));\n }\n }\n });\n}\n"],"names":["rename","fsRename","readdir","join","cwd","program","command","description","option","action","target","extention","prefix","suffix","recursive","undo","dridents","withFileTypes","files","filter","e","isFile","some","ex","name","endsWith","f","oldPath","parentPath","oldFileName","newFileName","replace","RegExp"],"mappings":"AACA,SAASA,UAAUC,QAAQ,EAAEC,OAAO,QAAQ,mBAAmB;AAC/D,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,GAAG,QAAQ,eAAe;AAEnC,OAAO,SAASJ,OAAOK,OAAgB;IACrCA,QACGC,OAAO,CAAC,UACRC,WAAW,CAAC,iDACZC,MAAM,CACL,kCACA,6CAEDA,MAAM,CAAC,wBAAwB,4BAA4BJ,OAC3DI,MAAM,CAAC,wBAAwB,+BAC/BA,MAAM,CAAC,wBAAwB,+BAC/BA,MAAM,CAAC,aAAa,sBACpBA,MAAM,CAAC,kBAAkB,2BACzBC,MAAM,CAAC,OAAO,EAAEC,MAAM,EAAEC,SAAS,EAAEC,MAAM,EAAEC,MAAM,EAAEC,SAAS,EAAEC,IAAI,EAAE;QACnE,MAAMC,WAAW,MAAMd,QAAQQ,QAAQ;YACrCI;YACAG,eAAe;QACjB;QAEA,MAAMC,QAAQF,SACXG,MAAM,CAAC,CAACC,IAAMA,EAAEC,MAAM,IACtBF,MAAM,CAAC,CAACC;YACP,IAAIT,WAAW;gBACb,OAAOA,UAAUW,IAAI,CAAC,CAACC,KAAeH,EAAEI,IAAI,CAACC,QAAQ,CAACF;YACxD;YACA,OAAO;QACT;QAEF,KAAK,MAAMG,KAAKR,MAAO;YACrB,MAAMS,UAAUxB,KAAKuB,EAAEE,UAAU,EAAEF,EAAEF,IAAI;YACzC,MAAMK,cAAcH,EAAEF,IAAI;YAE1B,IAAIM,cAAcD;YAElB,IAAId,MAAM;gBACR,IAAIH,QAAQ;oBACVkB,cAAcA,YAAYC,OAAO,CAAC,IAAIC,OAAO,CAAC,CAAC,EAAEpB,QAAQ,GAAG;gBAC9D;gBAEA,IAAIC,QAAQ;oBACViB,cAAcA,YAAYC,OAAO,CAAC,IAAIC,OAAO,GAAGnB,OAAO,CAAC,CAAC,GAAG;gBAC9D;YACF,OAAO;gBACL,IAAID,QAAQ;oBACVkB,cAAclB,SAASkB;gBACzB;gBAEA,IAAIjB,QAAQ;oBACViB,cAAcA,cAAcjB;gBAC9B;YACF;YAEA,IAAIiB,gBAAgBD,aAAa;gBAC/B,MAAM5B,SAAS0B,SAASxB,KAAKuB,EAAEE,UAAU,EAAEE;YAC7C;QACF;IACF;AACJ"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ export declare function replace(program: Command): void;
3
+ //# sourceMappingURL=replace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../../../src/commands/replace/replace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,QA8CvC"}
@@ -0,0 +1,32 @@
1
+ import { readdir, readFile, writeFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { cwd } from 'node:process';
4
+ export function replace(program) {
5
+ program.command('replace').description('Replace multiple files content based file extentions').option('-e,--extention <extentions...>', 'Include the files with the extention only').option('-t,--target <string>', 'Target working directory', cwd()).option('-p,--placeholders <placeholders...>', 'placeholders').option('-v,--values <values...>', 'New values').option('-r,--recursive', 'Include sub directories').action(async ({ extention, target, placeholders, values, recursive })=>{
6
+ const dridents = await readdir(target, {
7
+ recursive,
8
+ withFileTypes: true
9
+ });
10
+ const files = dridents.filter((e)=>e.isFile()).filter((e)=>{
11
+ if (extention) {
12
+ return e.name.endsWith(extention);
13
+ }
14
+ return true;
15
+ });
16
+ for (const f of files){
17
+ const filePath = join(f.parentPath, f.name);
18
+ let fileContent = await readFile(filePath, {
19
+ encoding: 'utf-8'
20
+ });
21
+ for (const [index, placeholder] of placeholders.entries()){
22
+ if (!values[index]) {
23
+ throw new Error(`Value is not provided for ${placeholder} at index ${index}`);
24
+ }
25
+ fileContent = fileContent.replace(new RegExp(placeholder, 'g'), values[index]);
26
+ }
27
+ await writeFile(filePath, fileContent);
28
+ }
29
+ });
30
+ }
31
+
32
+ //# sourceMappingURL=replace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/commands/replace/replace.ts"],"sourcesContent":["import type { Command } from 'commander';\nimport { readdir, readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { cwd } from 'node:process';\n\nexport function replace(program: Command) {\n program\n .command('replace')\n .description('Replace multiple files content based file extentions')\n .option(\n '-e,--extention <extentions...>',\n 'Include the files with the extention only',\n )\n .option('-t,--target <string>', 'Target working directory', cwd())\n .option('-p,--placeholders <placeholders...>', 'placeholders')\n .option('-v,--values <values...>', 'New values')\n .option('-r,--recursive', 'Include sub directories')\n .action(async ({ extention, target, placeholders, values, recursive }) => {\n const dridents = await readdir(target, {\n recursive,\n withFileTypes: true,\n });\n\n const files = dridents\n .filter((e) => e.isFile())\n .filter((e) => {\n if (extention) {\n return e.name.endsWith(extention);\n }\n return true;\n });\n\n for (const f of files) {\n const filePath = join(f.parentPath, f.name);\n let fileContent = await readFile(filePath, { encoding: 'utf-8' });\n\n for (const [index, placeholder] of placeholders.entries()) {\n if (!values[index]) {\n throw new Error(\n `Value is not provided for ${placeholder} at index ${index}`,\n );\n }\n fileContent = fileContent.replace(\n new RegExp(placeholder, 'g'),\n values[index],\n );\n }\n\n await writeFile(filePath, fileContent);\n }\n });\n}\n"],"names":["readdir","readFile","writeFile","join","cwd","replace","program","command","description","option","action","extention","target","placeholders","values","recursive","dridents","withFileTypes","files","filter","e","isFile","name","endsWith","f","filePath","parentPath","fileContent","encoding","index","placeholder","entries","Error","RegExp"],"mappings":"AACA,SAASA,OAAO,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,mBAAmB;AAChE,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,GAAG,QAAQ,eAAe;AAEnC,OAAO,SAASC,QAAQC,OAAgB;IACtCA,QACGC,OAAO,CAAC,WACRC,WAAW,CAAC,wDACZC,MAAM,CACL,kCACA,6CAEDA,MAAM,CAAC,wBAAwB,4BAA4BL,OAC3DK,MAAM,CAAC,uCAAuC,gBAC9CA,MAAM,CAAC,2BAA2B,cAClCA,MAAM,CAAC,kBAAkB,2BACzBC,MAAM,CAAC,OAAO,EAAEC,SAAS,EAAEC,MAAM,EAAEC,YAAY,EAAEC,MAAM,EAAEC,SAAS,EAAE;QACnE,MAAMC,WAAW,MAAMhB,QAAQY,QAAQ;YACrCG;YACAE,eAAe;QACjB;QAEA,MAAMC,QAAQF,SACXG,MAAM,CAAC,CAACC,IAAMA,EAAEC,MAAM,IACtBF,MAAM,CAAC,CAACC;YACP,IAAIT,WAAW;gBACb,OAAOS,EAAEE,IAAI,CAACC,QAAQ,CAACZ;YACzB;YACA,OAAO;QACT;QAEF,KAAK,MAAMa,KAAKN,MAAO;YACrB,MAAMO,WAAWtB,KAAKqB,EAAEE,UAAU,EAAEF,EAAEF,IAAI;YAC1C,IAAIK,cAAc,MAAM1B,SAASwB,UAAU;gBAAEG,UAAU;YAAQ;YAE/D,KAAK,MAAM,CAACC,OAAOC,YAAY,IAAIjB,aAAakB,OAAO,GAAI;gBACzD,IAAI,CAACjB,MAAM,CAACe,MAAM,EAAE;oBAClB,MAAM,IAAIG,MACR,CAAC,0BAA0B,EAAEF,YAAY,UAAU,EAAED,OAAO;gBAEhE;gBACAF,cAAcA,YAAYtB,OAAO,CAC/B,IAAI4B,OAAOH,aAAa,MACxBhB,MAAM,CAACe,MAAM;YAEjB;YAEA,MAAM3B,UAAUuB,UAAUE;QAC5B;IACF;AACJ"}
@@ -0,0 +1,3 @@
1
+ import { type Command } from 'commander';
2
+ export declare function uuid(program: Command): void;
3
+ //# sourceMappingURL=uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../../src/commands/uuid/uuid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAGjD,wBAAgB,IAAI,CAAC,OAAO,EAAE,OAAO,QAkBpC"}
@@ -0,0 +1,23 @@
1
+ import { Option } from 'commander';
2
+ import { v4, v7 } from 'uuid';
3
+ export function uuid(program) {
4
+ program.command('uuid').addOption(new Option('-t,--type <string>', 'UUID type').choices([
5
+ '4',
6
+ '7'
7
+ ])).action(({ type })=>{
8
+ switch(type){
9
+ case '7':
10
+ {
11
+ console.log(v7());
12
+ break;
13
+ }
14
+ default:
15
+ {
16
+ console.log(v4());
17
+ break;
18
+ }
19
+ }
20
+ });
21
+ }
22
+
23
+ //# sourceMappingURL=uuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/commands/uuid/uuid.ts"],"sourcesContent":["import { Option, type Command } from 'commander';\nimport { v4, v7 } from 'uuid';\n\nexport function uuid(program: Command) {\n program\n .command('uuid')\n .addOption(\n new Option('-t,--type <string>', 'UUID type').choices(['4', '7']),\n )\n .action(({ type }) => {\n switch (type) {\n case '7': {\n console.log(v7());\n break;\n }\n default: {\n console.log(v4());\n break;\n }\n }\n });\n}\n"],"names":["Option","v4","v7","uuid","program","command","addOption","choices","action","type","console","log"],"mappings":"AAAA,SAASA,MAAM,QAAsB,YAAY;AACjD,SAASC,EAAE,EAAEC,EAAE,QAAQ,OAAO;AAE9B,OAAO,SAASC,KAAKC,OAAgB;IACnCA,QACGC,OAAO,CAAC,QACRC,SAAS,CACR,IAAIN,OAAO,sBAAsB,aAAaO,OAAO,CAAC;QAAC;QAAK;KAAI,GAEjEC,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAE;QACf,OAAQA;YACN,KAAK;gBAAK;oBACRC,QAAQC,GAAG,CAACT;oBACZ;gBACF;YACA;gBAAS;oBACPQ,QAAQC,GAAG,CAACV;oBACZ;gBACF;QACF;IACF;AACJ"}
@@ -0,0 +1,5 @@
1
+ export declare const LOG_FILE_PATH: string;
2
+ export declare function writeLog(mesage: string): Promise<void>;
3
+ export declare function readLogs(): Promise<string>;
4
+ export declare function clearLogs(): Promise<void>;
5
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/log/log.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,QAGzB,CAAC;AAEF,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,iBAE5C;AAED,wBAAsB,QAAQ,oBAW7B;AAED,wBAAsB,SAAS,kBAE9B"}
@@ -0,0 +1,19 @@
1
+ import { appendFile, readFile, writeFile } from 'node:fs/promises';
2
+ import { tmpdir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ export const LOG_FILE_PATH = join(tmpdir(), 'aenode-cli-history-logs-1298749812764.log');
5
+ export async function writeLog(mesage) {
6
+ await appendFile(LOG_FILE_PATH, `\n${mesage} [${new Date().toISOString()}]`);
7
+ }
8
+ export async function readLogs() {
9
+ const logs = await readFile(LOG_FILE_PATH, {
10
+ encoding: 'utf-8'
11
+ });
12
+ const indexedLogs = logs.split('\n').map((e)=>e.trim()).filter((e)=>e).map((e, i)=>`${String(i + 1).padEnd(5)}${e}`).join('\n');
13
+ return indexedLogs;
14
+ }
15
+ export async function clearLogs() {
16
+ return await writeFile(LOG_FILE_PATH, '');
17
+ }
18
+
19
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/log/log.ts"],"sourcesContent":["import { appendFile, readFile, writeFile } from 'node:fs/promises';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\nexport const LOG_FILE_PATH = join(\n tmpdir(),\n 'aenode-cli-history-logs-1298749812764.log',\n);\n\nexport async function writeLog(mesage: string) {\n await appendFile(LOG_FILE_PATH, `\\n${mesage} [${new Date().toISOString()}]`);\n}\n\nexport async function readLogs() {\n const logs = await readFile(LOG_FILE_PATH, { encoding: 'utf-8' });\n\n const indexedLogs = logs\n .split('\\n')\n .map((e) => e.trim())\n .filter((e) => e)\n .map((e, i) => `${String(i + 1).padEnd(5)}${e}`)\n .join('\\n');\n\n return indexedLogs;\n}\n\nexport async function clearLogs() {\n return await writeFile(LOG_FILE_PATH, '');\n}\n"],"names":["appendFile","readFile","writeFile","tmpdir","join","LOG_FILE_PATH","writeLog","mesage","Date","toISOString","readLogs","logs","encoding","indexedLogs","split","map","e","trim","filter","i","String","padEnd","clearLogs"],"mappings":"AAAA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,mBAAmB;AACnE,SAASC,MAAM,QAAQ,UAAU;AACjC,SAASC,IAAI,QAAQ,YAAY;AAEjC,OAAO,MAAMC,gBAAgBD,KAC3BD,UACA,6CACA;AAEF,OAAO,eAAeG,SAASC,MAAc;IAC3C,MAAMP,WAAWK,eAAe,CAAC,EAAE,EAAEE,OAAO,EAAE,EAAE,IAAIC,OAAOC,WAAW,GAAG,CAAC,CAAC;AAC7E;AAEA,OAAO,eAAeC;IACpB,MAAMC,OAAO,MAAMV,SAASI,eAAe;QAAEO,UAAU;IAAQ;IAE/D,MAAMC,cAAcF,KACjBG,KAAK,CAAC,MACNC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,IACjBC,MAAM,CAAC,CAACF,IAAMA,GACdD,GAAG,CAAC,CAACC,GAAGG,IAAM,GAAGC,OAAOD,IAAI,GAAGE,MAAM,CAAC,KAAKL,GAAG,EAC9CZ,IAAI,CAAC;IAER,OAAOS;AACT;AAEA,OAAO,eAAeS;IACpB,OAAO,MAAMpB,UAAUG,eAAe;AACxC"}
package/dist/main.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
package/dist/main.js ADDED
@@ -0,0 +1,24 @@
1
+ import { program } from 'commander';
2
+ import { bye } from './commands/bye/bye.js';
3
+ import { history } from './commands/history/history.js';
4
+ import { merge } from './commands/merge/merge.js';
5
+ import { rename } from './commands/rename/rename.js';
6
+ import { replace } from './commands/replace/replace.js';
7
+ import { uuid } from './commands/uuid/uuid.js';
8
+ import { writeLog } from './log/log.js';
9
+ [
10
+ bye,
11
+ merge,
12
+ history,
13
+ uuid,
14
+ rename,
15
+ replace
16
+ ].forEach((e)=>e(program));
17
+ const aenode = program.name('aenode').description('aenode cli');
18
+ aenode.hook('postAction', (command, action)=>{
19
+ const options = Object.entries(action.opts()).map(([k, v])=>`--${k} "${v}"`).join(' ');
20
+ writeLog(`${command.name()} ${action.name()} ${options}`);
21
+ });
22
+ aenode.parse();
23
+
24
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/main.ts"],"sourcesContent":["import { program } from 'commander';\nimport { bye } from './commands/bye/bye.js';\nimport { history } from './commands/history/history.js';\nimport { merge } from './commands/merge/merge.js';\nimport { rename } from './commands/rename/rename.js';\nimport { replace } from './commands/replace/replace.js';\nimport { uuid } from './commands/uuid/uuid.js';\nimport { writeLog } from './log/log.js';\n\n[bye, merge, history, uuid, rename, replace].forEach((e) => e(program));\n\nconst aenode = program.name('aenode').description('aenode cli');\n\naenode.hook('postAction', (command, action) => {\n const options = Object.entries(action.opts())\n .map(([k, v]) => `--${k} \"${v}\"`)\n .join(' ');\n writeLog(`${command.name()} ${action.name()} ${options}`);\n});\n\naenode.parse();\n"],"names":["program","bye","history","merge","rename","replace","uuid","writeLog","forEach","e","aenode","name","description","hook","command","action","options","Object","entries","opts","map","k","v","join","parse"],"mappings":"AAAA,SAASA,OAAO,QAAQ,YAAY;AACpC,SAASC,GAAG,QAAQ,wBAAwB;AAC5C,SAASC,OAAO,QAAQ,gCAAgC;AACxD,SAASC,KAAK,QAAQ,4BAA4B;AAClD,SAASC,MAAM,QAAQ,8BAA8B;AACrD,SAASC,OAAO,QAAQ,gCAAgC;AACxD,SAASC,IAAI,QAAQ,0BAA0B;AAC/C,SAASC,QAAQ,QAAQ,eAAe;AAExC;IAACN;IAAKE;IAAOD;IAASI;IAAMF;IAAQC;CAAQ,CAACG,OAAO,CAAC,CAACC,IAAMA,EAAET;AAE9D,MAAMU,SAASV,QAAQW,IAAI,CAAC,UAAUC,WAAW,CAAC;AAElDF,OAAOG,IAAI,CAAC,cAAc,CAACC,SAASC;IAClC,MAAMC,UAAUC,OAAOC,OAAO,CAACH,OAAOI,IAAI,IACvCC,GAAG,CAAC,CAAC,CAACC,GAAGC,EAAE,GAAK,CAAC,EAAE,EAAED,EAAE,EAAE,EAAEC,EAAE,CAAC,CAAC,EAC/BC,IAAI,CAAC;IACRhB,SAAS,GAAGO,QAAQH,IAAI,GAAG,CAAC,EAAEI,OAAOJ,IAAI,GAAG,CAAC,EAAEK,SAAS;AAC1D;AAEAN,OAAOc,KAAK"}
package/package.json CHANGED
@@ -1,6 +1,67 @@
1
1
  {
2
2
  "name": "@aenode/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "- [ ] Add project description",
5
+ "author": {
6
+ "name": "Ahmet Emrebas",
7
+ "email": "aenode+aenode@-cliproton.me",
8
+ "url": "https://aenode.github.io/#profile"
9
+ },
10
+ "bin": {
11
+ "aenode": "./bin/aenode.mjs"
12
+ },
13
+ "funding": "https://cash.app/$puqlib",
14
+ "homepage": "https://aenode.github.io/aenode/tools/cli",
15
+ "repository": {
16
+ "directory": "tools/cli",
17
+ "type": "github",
18
+ "url": "https://github.com/aenode/aenode/tree/main/tools/cli"
19
+ },
20
+ "icon": "https://aenode.github.io/aenode/tools/cli/assets/favicon.svg",
21
+ "keywords": [
22
+ "lib"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "tag": "latest"
27
+ },
28
+ "type": "module",
29
+ "main": "./dist/index.js",
30
+ "module": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "exports": {
33
+ "./package.json": "./package.json",
34
+ ".": {
35
+ "bun": "./src/index.ts",
36
+ "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.js",
38
+ "default": "./dist/index.js"
39
+ }
40
+ },
41
+ "files": [
42
+ "assets",
43
+ "bin",
44
+ "dist",
45
+ "generators.json",
46
+ "!**/*.tsbuildinfo"
47
+ ],
48
+ "nx": {
49
+ "projectType": "application",
50
+ "sourceRoot": "tools/cli/src",
51
+ "tags": [
52
+ "lib:common"
53
+ ],
54
+ "targets": {
55
+ "build": {},
56
+ "doc": {}
57
+ }
58
+ },
59
+ "dependencies": {
60
+ "@swc/helpers": "~0.5.18",
61
+ "commander": "^15.0.0",
62
+ "uuid": "^14.0.3"
63
+ },
64
+ "devDependencies": {
65
+ "@types/uuid": "^11.0.0"
66
+ }
67
+ }