@mxfb/cli 0.0.55 → 0.0.64

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 (33) hide show
  1. package/cli/assets/list.txt +5 -1
  2. package/cli/assets/version.txt +1 -1
  3. package/cli/index.js +4 -3
  4. package/cli/index.js.map +7 -0
  5. package/make-calendar/index.js +8 -0
  6. package/make-calendar/index.js.map +7 -0
  7. package/make-template/assets/react/gitignore +2 -0
  8. package/make-template/assets/react/package.json +19 -8
  9. package/make-template/assets/react/{pages → public}/index.html +1 -0
  10. package/make-template/assets/react/scripts/build/index.ts +44 -0
  11. package/make-template/assets/react/scripts/tsconfig.json +21 -0
  12. package/make-template/assets/react/src/components/App/index.tsx +5 -1
  13. package/make-template/assets/react/src/components/App/style.module.scss +3 -0
  14. package/make-template/assets/react/src/index.d.ts +9 -0
  15. package/make-template/assets/react/src/tsconfig.json +8 -2
  16. package/make-template/assets/react/src/utils/some-util/index.ts +1 -0
  17. package/make-template/index.js +3 -2
  18. package/make-template/index.js.map +7 -0
  19. package/package.json +13 -6
  20. package/term-glossary/index.js +27 -0
  21. package/term-glossary/index.js.map +7 -0
  22. package/tree/index.js +3 -0
  23. package/tree/index.js.map +7 -0
  24. package/tumblr-crawler/index.js +5 -0
  25. package/tumblr-crawler/index.js.map +7 -0
  26. /package/make-template/assets/react/{pages → public}/icons/about.txt +0 -0
  27. /package/make-template/assets/react/{pages → public}/icons/android-chrome-192x192.png +0 -0
  28. /package/make-template/assets/react/{pages → public}/icons/android-chrome-512x512.png +0 -0
  29. /package/make-template/assets/react/{pages → public}/icons/apple-touch-icon.png +0 -0
  30. /package/make-template/assets/react/{pages → public}/icons/favicon-16x16.png +0 -0
  31. /package/make-template/assets/react/{pages → public}/icons/favicon-32x32.png +0 -0
  32. /package/make-template/assets/react/{pages → public}/icons/favicon.ico +0 -0
  33. /package/make-template/assets/react/{pages → public}/icons/site.webmanifest +0 -0
@@ -1,2 +1,6 @@
1
1
  cli
2
- make-template
2
+ make-calendar
3
+ make-template
4
+ term-glossary
5
+ tree
6
+ tumblr-crawler
@@ -1 +1 @@
1
- 0.0.55
1
+ 0.0.64
package/cli/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import m from"node:process";import{promises as l}from"node:fs";import u from"node:url";import r from"node:path";import{spawn as h}from"node:child_process";import{program as t}from"commander";var g=u.fileURLToPath(import.meta.url),e=r.dirname(g);t.name("@mxfb-cli/cli").description("The home of @mxfb/cli's project");t.command("list").description("list all the available commands").action(w);t.command("version").description("print current version of the package").action(x);var b=await c();b.forEach(n=>{t.command(n,{hidden:!0}).allowUnknownOption(!0).action(async(...i)=>{let[o,a,s,...p]=m.argv;if(s===void 0)return t.help();if(!(await c()).includes(s))return t.help();let d=r.join(e,"../",s,"index.js");h(d,p,{stdio:"inherit"}).on("error",f=>console.error(`Failed to start subprogram '${s}':`,f))})});t.parse(m.argv);async function c(){let n=r.join(e,"assets/list.txt");return(await l.readFile(n,{encoding:"utf-8"})).split(`
3
- `).map(o=>o.trim())}async function w(){let i=(await c()).map(o=>{let a=Object.assign(new Array(24).fill(" "),o.split("")).join("");return o==="cli"?`${a} # npx @mxfb/cli help`:`${a} # npx @mxfb/cli ${o} help`}).join(`
4
- `);console.log(i)}async function x(){let n=r.join(e,"assets/version.txt"),i=await l.readFile(n,{encoding:"utf-8"});console.log(i)}
2
+ import m from"node:process";import{promises as l}from"node:fs";import f from"node:url";import r from"node:path";import{spawn as g}from"node:child_process";import{program as t}from"commander";var h=f.fileURLToPath(import.meta.url),a=r.dirname(h);t.name("@design-edito/cli").description("The home of @design-edito/cli's project");t.command("list").description("list all the available commands").action(j);t.command("version").description("print current version of the package").action(v);var w=await c();w.forEach(n=>{t.command(n,{hidden:!0}).allowUnknownOption(!0).action(async(...i)=>{let[o,e,s,...d]=m.argv;if(s===void 0)return t.help();if(!(await c()).includes(s))return t.help();let p=r.join(a,"../",s,"index.js");g(p,d,{stdio:"inherit"}).on("error",u=>console.error(`Failed to start subprogram '${s}':`,u))})});t.parse(m.argv);async function c(){let n=r.join(a,"assets/list.txt");return(await l.readFile(n,{encoding:"utf-8"})).split(`
3
+ `).map(o=>o.trim())}async function j(){let i=(await c()).map(o=>{let e=Object.assign(new Array(24).fill(" "),o.split("")).join("");return o==="cli"?`${e} # npx @design-edito/cli help`:`${e} # npx @design-edito/cli ${o} help`}).join(`
4
+ `);console.log(i)}async function v(){let n=r.join(a,"assets/version.txt"),i=await l.readFile(n,{encoding:"utf-8"});console.log(i)}
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/cli/index.ts"],
4
+ "sourcesContent": ["import process from 'node:process'\nimport { promises as fs } from 'node:fs'\nimport url from 'node:url'\nimport path from 'node:path'\nimport { spawn } from 'node:child_process'\nimport { program } from 'commander'\n\nconst __filename = url.fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\nprogram\n .name('@design-edito/cli')\n .description('The home of @design-edito/cli\\'s project')\n \nprogram\n .command('list')\n .description('list all the available commands')\n .action(printCommands)\n\nprogram\n .command('version')\n .description('print current version of the package')\n .action(printVersion)\n\nconst subCommands = await listCommands()\nsubCommands.forEach(subCommand => {\n program\n .command(subCommand, { hidden: true })\n .allowUnknownOption(true)\n .action(async (...args) => {\n const [_nodePath, _thisPath, targetCommand, ...forwardedArgs] = process.argv\n if (targetCommand === undefined) return program.help()\n const commandsList = await listCommands()\n if (!commandsList.includes(targetCommand)) return program.help()\n const subprogramPath = path.join(__dirname, '../', targetCommand, 'index.js')\n const subprocess = spawn(subprogramPath, forwardedArgs, { stdio: 'inherit' })\n subprocess.on('error', err => console.error(`Failed to start subprogram '${targetCommand}':`, err))\n })\n})\n\nprogram.parse(process.argv)\n\nasync function listCommands () {\n const listFilePath = path.join(__dirname, 'assets/list.txt')\n const list = await fs.readFile(listFilePath, { encoding: 'utf-8' })\n return list.split('\\n').map(e => e.trim())\n}\n\nasync function printCommands () {\n const list = await listCommands()\n const output = list\n .map(c => {\n const twentyFourCharName = Object.assign(\n new Array(24).fill(' ') as string[],\n c.split('') as string[]\n ).join('')\n if (c === 'cli') return `${twentyFourCharName} # npx @design-edito/cli help`\n return `${twentyFourCharName} # npx @design-edito/cli ${c} help`\n })\n .join('\\n')\n console.log(output)\n return;\n}\n\nasync function printVersion () {\n const versionFilePath = path.join(__dirname, 'assets/version.txt')\n const version = await fs.readFile(versionFilePath, { encoding: 'utf-8' })\n console.log(version)\n return;\n}\n"],
5
+ "mappings": "AAAA,OAAOA,MAAa,eACpB,OAAS,YAAYC,MAAU,UAC/B,OAAOC,MAAS,WAChB,OAAOC,MAAU,YACjB,OAAS,SAAAC,MAAa,qBACtB,OAAS,WAAAC,MAAe,YAExB,IAAMC,EAAaJ,EAAI,cAAc,YAAY,GAAG,EAC9CK,EAAYJ,EAAK,QAAQG,CAAU,EAEzCD,EACG,KAAK,mBAAmB,EACxB,YAAY,yCAA0C,EAEzDA,EACG,QAAQ,MAAM,EACd,YAAY,iCAAiC,EAC7C,OAAOG,CAAa,EAEvBH,EACG,QAAQ,SAAS,EACjB,YAAY,sCAAsC,EAClD,OAAOI,CAAY,EAEtB,IAAMC,EAAc,MAAMC,EAAa,EACvCD,EAAY,QAAQE,GAAc,CAChCP,EACG,QAAQO,EAAY,CAAE,OAAQ,EAAK,CAAC,EACpC,mBAAmB,EAAI,EACvB,OAAO,SAAUC,IAAS,CACzB,GAAM,CAACC,EAAWC,EAAWC,EAAe,GAAGC,CAAa,EAAIjB,EAAQ,KACxE,GAAIgB,IAAkB,OAAW,OAAOX,EAAQ,KAAK,EAErD,GAAI,EADiB,MAAMM,EAAa,GACtB,SAASK,CAAa,EAAG,OAAOX,EAAQ,KAAK,EAC/D,IAAMa,EAAiBf,EAAK,KAAKI,EAAW,MAAOS,EAAe,UAAU,EACzDZ,EAAMc,EAAgBD,EAAe,CAAE,MAAO,SAAU,CAAC,EACjE,GAAG,QAASE,GAAO,QAAQ,MAAM,+BAA+BH,CAAa,KAAMG,CAAG,CAAC,CACpG,CAAC,CACL,CAAC,EAEDd,EAAQ,MAAML,EAAQ,IAAI,EAE1B,eAAeW,GAAgB,CAC7B,IAAMS,EAAejB,EAAK,KAAKI,EAAW,iBAAiB,EAE3D,OADa,MAAMN,EAAG,SAASmB,EAAc,CAAE,SAAU,OAAQ,CAAC,GACtD,MAAM;AAAA,CAAI,EAAE,IAAIC,GAAKA,EAAE,KAAK,CAAC,CAC3C,CAEA,eAAeb,GAAiB,CAE9B,IAAMc,GADO,MAAMX,EAAa,GAE7B,IAAIY,GAAK,CACR,IAAMC,EAAqB,OAAO,OAChC,IAAI,MAAM,EAAE,EAAE,KAAK,GAAG,EACtBD,EAAE,MAAM,EAAE,CACZ,EAAE,KAAK,EAAE,EACT,OAAIA,IAAM,MAAc,GAAGC,CAAkB,gCACtC,GAAGA,CAAkB,4BAA4BD,CAAC,OAC3D,CAAC,EACA,KAAK;AAAA,CAAI,EACZ,QAAQ,IAAID,CAAM,CAEpB,CAEA,eAAeb,GAAgB,CAC7B,IAAMgB,EAAkBtB,EAAK,KAAKI,EAAW,oBAAoB,EAC3DmB,EAAU,MAAMzB,EAAG,SAASwB,EAAiB,CAAE,SAAU,OAAQ,CAAC,EACxE,QAAQ,IAAIC,CAAO,CAErB",
6
+ "names": ["process", "fs", "url", "path", "spawn", "program", "__filename", "__dirname", "printCommands", "printVersion", "subCommands", "listCommands", "subCommand", "args", "_nodePath", "_thisPath", "targetCommand", "forwardedArgs", "subprogramPath", "err", "listFilePath", "e", "output", "c", "twentyFourCharName", "versionFilePath", "version"]
7
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import{endOfYear as D,startOfYear as i,endOfMonth as g,getWeek as p,eachWeekOfInterval as u,endOfWeek as O,format as r,getMonth as o,getDate as c}from"date-fns";var S=parseInt(`${process.argv[2]}`);l(S);function l(_){let s=parseInt(`${_}`),f=i(new Date(s,0,1)),m=D(new Date(s,11,31)),d=u({start:f,end:m},{weekStartsOn:1}).map(t=>{let e=t,a=O(e,{weekStartsOn:1}),n=a.getFullYear(),y=p(e,{weekStartsOn:1});return{year:n,number:y,firstDay:e,lastDay:a}});console.log(`\u2502 ${s} Pos\xE9s Solde Note
3
+ \u2502 date \u2014 sem \u2014 l m m j v s + l cp rtt cp rtt
4
+ \u2502 \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014
5
+ \u2502`),d.forEach(t=>{let e=o(t.firstDay)!==o(t.lastDay),a=g(t.firstDay),n=c(t.lastDay)===c(a);console.log(`
6
+ \u2502 ${r(t.firstDay,"MMM dd")} \u203A ${r(t.lastDay,"dd")} \u2014 S ${t.number.toString().padStart(2,"0")} \u2014 _ _ _ _ _ + _ _ ___ ___ ___ ___
7
+ `.trim()),(e||n)&&console.log("\u2502")})}export{l as default};
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/make-calendar/index.ts"],
4
+ "sourcesContent": ["import {\n endOfYear,\n startOfYear,\n endOfMonth,\n getWeek,\n eachWeekOfInterval,\n startOfWeek,\n endOfWeek,\n format as dateFormat,\n getMonth,\n getDate,\n getDay\n} from 'date-fns'\n\ntype WeekData = {\n year: number\n number: number\n firstDay: Date\n lastDay: Date\n}\n\n// [WIP] use commander\n\nconst year = parseInt(`${process.argv[2]}`)\nmakeCalendar(year)\n\nexport default function makeCalendar (inputYear: number) {\n const year = parseInt(`${inputYear}`)\n const start = startOfYear(new Date(year, 0, 1))\n const end = endOfYear(new Date(year, 11, 31))\n const weeksStartDates = eachWeekOfInterval({ start, end }, { weekStartsOn: 1 })\n const weeks: WeekData[] = weeksStartDates.map(weekStartDate => {\n const firstDay = weekStartDate\n const lastDay = endOfWeek(firstDay, { weekStartsOn: 1 });\n const year = lastDay.getFullYear();\n const number = getWeek(firstDay, { weekStartsOn: 1 })\n return {\n year,\n number,\n firstDay,\n lastDay\n }\n })\n console.log(\n`\u2502 ${year} Pos\u00E9s Solde Note\n\u2502 date \u2014 sem \u2014 l m m j v s + l cp rtt cp rtt \n\u2502 \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n\u2502`)\n weeks.forEach(weekData => {\n const onTwoMonths = getMonth(weekData.firstDay) !== getMonth(weekData.lastDay)\n const monthEnd = endOfMonth(weekData.firstDay)\n const isMonthEnd = getDate(weekData.lastDay) === getDate(monthEnd)\n console.log(`\n \u2502 ${dateFormat(weekData.firstDay, 'MMM dd')} \u203A ${dateFormat(weekData.lastDay, 'dd')} \u2014 S ${weekData.number.toString().padStart(2, '0')} \u2014 _ _ _ _ _ + _ _ ___ ___ ___ ___\n `.trim())\n if (onTwoMonths || isMonthEnd) console.log('\u2502')\n })\n}\n\n/*`\n62 jours\n \n| Calendrier Pos\u00E9s Solde Note\n| date - sem - l m m j v s + l cp rtt cp rtt \n| ------------------------------------------------------------------------------------------------\n|\n| jan XX \u203A XX - S 01 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| jan XX \u203A XX - S 02 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| jan XX \u203A XX - S 03 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| jan XX \u203A XX - S 04 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| jan XX \u203A XX - S 05 - _ _ _ _ _ _ + _ -10 -10 80 80 \n\n| feb XX \u203A XX - S 06 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| feb XX \u203A XX - S 07 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| feb XX \u203A XX - S 08 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| feb XX \u203A XX - S 09 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| \n| mar XX \u203A XX - S 10 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| mar XX \u203A XX - S 11 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| mar XX \u203A XX - S 12 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| mar XX \u203A XX - S 13 - _ _ _ _ _ _ + _ -10 -10 80 80 \n\n| apr XX \u203A XX - S 14 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| apr XX \u203A XX - S 15 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| apr XX \u203A XX - S 16 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| apr XX \u203A XX - S 17 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| apr XX \u203A XX - S 18 - _ _ _ _ _ _ + _ -10 -10 80 80 \n\n| may XX \u203A XX - S 19 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| may XX \u203A XX - S 20 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| may XX \u203A XX - S 21 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| may XX \u203A XX - S 22 - _ _ _ _ _ _ + _ -10 -10 80 80 \n\n| jun XX \u203A XX - S 23 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| jun XX \u203A XX - S 24 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| jun XX \u203A XX - S 25 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| jun XX \u203A XX - S 26 - _ _ _ _ _ _ + _ -10 -10 80 80 \n\n| jul XX \u203A XX - S 27 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| jul XX \u203A XX - S 28 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| jul XX \u203A XX - S 29 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| jul XX \u203A XX - S 30 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| jul XX \u203A XX - S 31 - _ _ _ _ _ _ + _ -10 -10 80 80 \n\n| aug XX \u203A XX - S 32 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| aug XX \u203A XX - S 33 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| aug XX \u203A XX - S 34 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| aug XX \u203A XX - S 35 - _ _ _ _ _ _ + _ -10 -10 80 80 \n\n| sep XX \u203A XX - S 36 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| sep XX \u203A XX - S 37 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| sep XX \u203A XX - S 38 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| sep XX \u203A XX - S 39 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| sep XX \u203A XX - S 40 - _ _ _ _ _ _ + _ -10 -10 80 80 \n\n| oct XX \u203A XX - S 41 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| oct XX \u203A XX - S 42 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| oct XX \u203A XX - S 43 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| oct XX \u203A XX - S 44 - _ _ _ _ _ _ + _ -10 -10 80 80 \n\n| nov XX \u203A XX - S 45 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| nov XX \u203A XX - S 46 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| nov XX \u203A XX - S 47 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| nov XX \u203A XX - S 48 - _ _ _ _ _ _ + _ -10 -10 80 80 \n\n| dec XX \u203A XX - S 49 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| dec XX \u203A XX - S 50 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| dec XX \u203A XX - S 51 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| dec XX \u203A XX - S 52 - _ _ _ _ _ _ + _ -10 -10 80 80 \n| dec XX \u203A XX - S 53 - _ _ _ _ _ _ + _ -10 -10 80 80 \n`*/\n"],
5
+ "mappings": "AAAA,OACE,aAAAA,EACA,eAAAC,EACA,cAAAC,EACA,WAAAC,EACA,sBAAAC,EAEA,aAAAC,EACA,UAAUC,EACV,YAAAC,EACA,WAAAC,MAEK,WAWP,IAAMC,EAAO,SAAS,GAAG,QAAQ,KAAK,CAAC,CAAC,EAAE,EAC1CC,EAAaD,CAAI,EAEF,SAARC,EAA+BC,EAAmB,CACvD,IAAMF,EAAO,SAAS,GAAGE,CAAS,EAAE,EAC9BC,EAAQX,EAAY,IAAI,KAAKQ,EAAM,EAAG,CAAC,CAAC,EACxCI,EAAMb,EAAU,IAAI,KAAKS,EAAM,GAAI,EAAE,CAAC,EAEtCK,EADkBV,EAAmB,CAAE,MAAAQ,EAAO,IAAAC,CAAI,EAAG,CAAE,aAAc,CAAE,CAAC,EACpC,IAAIE,GAAiB,CAC7D,IAAMC,EAAWD,EACXE,EAAUZ,EAAUW,EAAU,CAAE,aAAc,CAAE,CAAC,EACjDP,EAAOQ,EAAQ,YAAY,EAC3BC,EAASf,EAAQa,EAAU,CAAE,aAAc,CAAE,CAAC,EACpD,MAAO,CACL,KAAAP,EACA,OAAAS,EACA,SAAAF,EACA,QAAAC,CACF,CACF,CAAC,EACD,QAAQ,IACV,UAAKR,CAAI;AAAA;AAAA;AAAA,OAGP,EACAK,EAAM,QAAQK,GAAY,CACxB,IAAMC,EAAcb,EAASY,EAAS,QAAQ,IAAMZ,EAASY,EAAS,OAAO,EACvEE,EAAWnB,EAAWiB,EAAS,QAAQ,EACvCG,EAAad,EAAQW,EAAS,OAAO,IAAMX,EAAQa,CAAQ,EACjE,QAAQ,IAAI;AAAA,eACNf,EAAWa,EAAS,SAAU,QAAQ,CAAC,WAAMb,EAAWa,EAAS,QAAS,IAAI,CAAC,eAAUA,EAAS,OAAO,SAAS,EAAE,SAAS,EAAG,GAAG,CAAC;AAAA,MACxI,KAAK,CAAC,GACJC,GAAeE,IAAY,QAAQ,IAAI,QAAG,CAChD,CAAC,CACH",
6
+ "names": ["endOfYear", "startOfYear", "endOfMonth", "getWeek", "eachWeekOfInterval", "endOfWeek", "dateFormat", "getMonth", "getDate", "year", "makeCalendar", "inputYear", "start", "end", "weeks", "weekStartDate", "firstDay", "lastDay", "number", "weekData", "onTwoMonths", "monthEnd", "isMonthEnd"]
7
+ }
@@ -1,3 +1,5 @@
1
+ dist
2
+
1
3
  # Created by https://www.toptal.com/developers/gitignore/api/react,nextjs,node,windows,osx,linux
2
4
  # Edit at https://www.toptal.com/developers/gitignore?templates=react,nextjs,node,windows,osx,linux
3
5
 
@@ -3,27 +3,38 @@
3
3
  "version": "0.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
+ "type": "module",
6
7
  "scripts": {
7
- "build:src": "npx esbuild src/index.tsx --bundle --minify --outfile=dist/index.js --platform=browser --target=esnext --jsx-factory=React.createElement --jsx-fragment=React.Fragment",
8
- "watch:src": "npm run build:src -- --watch",
8
+ "build:scripts": "npx tsc -p scripts/tsconfig.json",
9
+ "build:public": "cp -r public/* dist",
10
+ "build:src": "npm run build:scripts && node .scripts/build/index.js",
11
+ "build:src:preact": "PREACT=true npm run build:src",
12
+ "watch:public": "npx chokidar-cli 'public/**/*' -c 'npm run build:public'",
13
+ "watch:src": "WATCH=true npm run build:src",
14
+ "watch:src:preact": "PREACT=true npm run watch:src",
9
15
  "make:dist": "mkdir -p dist",
10
- "make:pages": "mkdir -p pages",
11
16
  "serve:dist": "npm run make:dist && npx http-server dist --port ${PORT} --cors -c-1",
12
- "serve:pages": "npm run make:pages && npx http-server pages --port ${PORT} --cors -c-1",
13
- "start": "npx concurrently -n 'watch:src ,serve:dist ,serve:pages' 'npm run watch:src' 'PORT=${PORT_DIST:-3001} npm run serve:dist' 'PORT=${PORT_DIST:-3000} npm run serve:pages'"
17
+ "start": "npx concurrently -n 'watch:src ,watch:public,serve:dist ' 'npm run watch:src' 'npm run watch:public' 'PORT=${PORT_DIST:-3000} npm run serve:dist'",
18
+ "start:preact": "PREACT=true npm start"
14
19
  },
15
20
  "author": "",
16
21
  "license": "ISC",
17
22
  "devDependencies": {
18
23
  "@types/node": "^20.11.30",
19
24
  "@types/react": "^18.2.72",
25
+ "@types/react-dom": "^18.2.22",
20
26
  "concurrently": "^8.2.2",
21
- "esbuild": "^0.20.2",
22
27
  "http-server": "^14.1.1",
23
- "typescript": "^5.4.3"
28
+ "typescript": "^5.4.3",
29
+ "esbuild": "^0.20.2",
30
+ "esbuild-plugin-inline-image": "^0.0.9",
31
+ "esbuild-sass-plugin": "^3.2.0",
32
+ "postcss": "^8.4.38",
33
+ "postcss-modules": "^6.0.0",
34
+ "sass": "^1.74.1"
24
35
  },
25
36
  "dependencies": {
26
- "@types/react-dom": "^18.2.22",
37
+ "preact": "^10.20.1",
27
38
  "react": "^18.2.0",
28
39
  "react-dom": "^18.2.0"
29
40
  }
@@ -11,6 +11,7 @@
11
11
  <link rel="icon" type="image/png" sizes="16x16" href="./icons/favicon-16x16.png">
12
12
  <link rel="manifest" href="./icons/site.webmanifest">
13
13
  <script type="module" src="http://localhost:3001/index.js"></script>
14
+ <link rel="stylesheet" href="http://localhost:3001/index.css">
14
15
  </head>
15
16
  <body>
16
17
  <div class="root"></div>
@@ -0,0 +1,44 @@
1
+ import esbuild, { BuildOptions } from 'esbuild'
2
+ import path from 'node:path'
3
+ import { sassPlugin, postcssModules } from 'esbuild-sass-plugin'
4
+ import inlineImageModule from 'esbuild-plugin-inline-image'
5
+
6
+ const PREACT = process.env.PREACT === 'true'
7
+ const WATCH = process.env.WATCH === 'true'
8
+
9
+ console.log(`scripts/build/index.ts PREACT=${PREACT} WATCH=${WATCH}`)
10
+
11
+ const options: BuildOptions = {
12
+ format: 'esm',
13
+ entryPoints: [path.join(process.cwd(), 'src/index.tsx')],
14
+ bundle: true,
15
+ outfile: path.join(process.cwd(), 'dist/index.js'),
16
+ minify: true,
17
+ platform: 'browser',
18
+ sourcemap: true,
19
+ target: ['esnext'],
20
+ tsconfig: path.join(process.cwd(), 'src/tsconfig.json'),
21
+ logLevel: 'info',
22
+ jsxFactory: PREACT ? 'h' : 'React.createElement',
23
+ jsxFragment: PREACT ? 'FRAGMENT' : 'React.Fragment',
24
+ plugins: [
25
+ inlineImageModule({ limit: -1 }),
26
+ sassPlugin({ filter: /\.module\.scss$/, type: 'css', transform: postcssModules({}) }),
27
+ sassPlugin({ filter: /.scss$/, type: 'css' })
28
+ ],
29
+ alias: PREACT ? {
30
+ 'react': 'preact/compat',
31
+ 'react-dom/test-utils': 'preact/test-utils',
32
+ 'react-dom': 'preact/compat',
33
+ 'react/jsx-runtime': 'preact/jsx-runtime'
34
+ } : {}
35
+ }
36
+
37
+ if (WATCH) {
38
+ const ctx = await esbuild.context(options)
39
+ await ctx.watch()
40
+ console.log('watching...')
41
+ } else {
42
+ await esbuild.build(options)
43
+ console.log('built.')
44
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "lib": ["ESNext"],
5
+ "module": "ESNext",
6
+ "target": "ESNext",
7
+ "baseUrl": ".",
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "outDir": "../.scripts",
11
+ "declaration": true,
12
+ "moduleResolution": "Node",
13
+ "rootDir": ".",
14
+ "noUncheckedIndexedAccess": true,
15
+ },
16
+ "include": ["**/*"],
17
+ "exclude": [
18
+ "../node_modules",
19
+ "../.scripts"
20
+ ]
21
+ }
@@ -1,3 +1,7 @@
1
+ import styles from './style.module.scss'
2
+
1
3
  export default function App () {
2
- return <div>App.</div>
4
+ return <div className={styles['app']}>
5
+ App.
6
+ </div>
3
7
  }
@@ -0,0 +1,3 @@
1
+ .app {
2
+ display: block;
3
+ }
@@ -0,0 +1,9 @@
1
+ declare module '*.module.scss' {
2
+ const content: { [className: string]: string }
3
+ export = content
4
+ }
5
+
6
+ declare module '*.svg' {
7
+ const content: string;
8
+ export default content;
9
+ }
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "baseUrl": ".",
3
4
  "target": "ESNext",
4
5
  "lib": ["DOM", "DOM.Iterable", "ESNext"],
5
6
  "skipLibCheck": true,
@@ -13,7 +14,12 @@
13
14
  "resolveJsonModule": true,
14
15
  "isolatedModules": true,
15
16
  "noEmit": true,
16
- "jsx": "react-jsx"
17
+ "jsx": "react-jsx",
18
+ "paths": {
19
+ "~/components/*": ["./components/*"],
20
+ "~/utils/*": ["./utils/*"]
21
+ }
17
22
  },
18
- "include": ["./"]
23
+ "include": ["./"],
24
+ "files": ["./index.d.ts"]
19
25
  }
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import p from"node:process";import{promises as c,existsSync as h}from"node:fs";import y from"node:url";import e from"node:path";import{spawn as P}from"node:child_process";import{program as l}from"commander";import k from"prompts";import{promises as d}from"node:fs";async function g(t,r,...a){let[m,s]=a,n=await d.readFile(t,m),o=r(n),i=a.length===2?s:m;return await d.writeFile(t,o,i),o}var x=y.fileURLToPath(import.meta.url),j=e.dirname(x),f=p.cwd();l.name("@mxfb-cli/make-template").description("Generate in cwd a project template");l.command("html").description("make simple html project structure").action(S);l.command("react").description("make react + typescript project structure").action(b);l.parse(p.argv);async function S(){let t=e.join(j,"assets/html");if(!h(t))return console.error(`Could not find the template to copy at ${t}`),p.exit(1);let r=e.join(f,"html-template");await c.cp(t,r,{recursive:!0})}async function b(){let t=e.join(j,"assets/react");if(!h(t))return console.error(`Could not find the template to copy at ${t}`),p.exit(1);let r=e.join(f,"react-template");await c.cp(t,r,{recursive:!0});let{projectName:a}=await k({name:"projectName",message:"Project name ? (for package.json name field)",type:"text"}),m=e.join(r,"package.json");await g(m,o=>{let i=typeof o=="string"?o:o.toString(),u=JSON.parse(i);delete u.name;let w={name:a,...u};return`${JSON.stringify(w,null,2)}
3
- `},{encoding:"utf-8"});let s=P(`cd ${r} && npm i`,{stdio:"inherit",shell:!0});await new Promise((o,i)=>{s.on("exit",()=>o(!0)),s.on("error",()=>i(!1))});let n=e.join(f,a);await c.rename(r,n),await c.rename(e.join(n,"gitignore"),e.join(n,".gitignore"))}
2
+ import n from"node:process";import{promises as a,existsSync as d}from"node:fs";import j from"node:url";import t from"node:path";import{spawn as w}from"node:child_process";import{program as i}from"commander";import y from"prompts";import P from"@design-edito/tools/utils/node/read-write-file/index.js";var k=j.fileURLToPath(import.meta.url),u=t.dirname(k),c=n.cwd();i.name("@design-edito/make-template").description("Generate in cwd a project template");i.command("html").description("make simple html project structure").action(x);i.command("react").description("make react + typescript project structure").action(S);i.parse(n.argv);async function x(){let e=t.join(u,"assets/html");if(!d(e))return console.error(`Could not find the template to copy at ${e}`),n.exit(1);let o=t.join(c,"html-template");await a.cp(e,o,{recursive:!0})}async function S(){let e=t.join(u,"assets/react");if(!d(e))return console.error(`Could not find the template to copy at ${e}`),n.exit(1);let o=t.join(c,"react-template");await a.cp(e,o,{recursive:!0});let{projectName:p}=await y({name:"projectName",message:"Project name ? (for package.json name field)",type:"text"}),g=t.join(o,"package.json");await P(g,r=>{let s=typeof r=="string"?r:r.toString(),f=JSON.parse(s);delete f.name;let h={name:p,...f};return`${JSON.stringify(h,null,2)}
3
+ `},{encoding:"utf-8"});let l=w(`cd ${o} && npm i`,{stdio:"inherit",shell:!0});await new Promise((r,s)=>{l.on("exit",()=>r(!0)),l.on("error",()=>s(!1))});let m=t.join(c,p);await a.rename(o,m),await a.rename(t.join(m,"gitignore"),t.join(m,".gitignore"))}
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/make-template/index.ts"],
4
+ "sourcesContent": ["import process from 'node:process'\nimport { promises as fs, existsSync } from 'node:fs'\nimport url from 'node:url'\nimport path from 'node:path'\nimport { spawn } from 'node:child_process'\nimport { program } from 'commander'\nimport prompts from 'prompts'\nimport readWriteFile from '@design-edito/tools/utils/node/read-write-file/index.js'\n\nconst __filename = url.fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\nconst CWD = process.cwd()\n\nprogram\n .name('@design-edito/make-template')\n .description('Generate in cwd a project template')\n \nprogram\n .command('html')\n .description('make simple html project structure')\n .action(makeHtml)\n\nprogram\n .command('react')\n .description('make react + typescript project structure')\n .action(makeReact)\n\nprogram.parse(process.argv)\n\nasync function makeHtml () {\n const htmlTemplatePath = path.join(__dirname, 'assets/html')\n if (!existsSync(htmlTemplatePath)) {\n console.error(`Could not find the template to copy at ${htmlTemplatePath}`)\n return process.exit(1)\n }\n const targetPath = path.join(CWD, 'html-template')\n await fs.cp(htmlTemplatePath, targetPath, { recursive: true })\n}\n\nasync function makeReact () {\n const htmlTemplatePath = path.join(__dirname, 'assets/react')\n if (!existsSync(htmlTemplatePath)) {\n console.error(`Could not find the template to copy at ${htmlTemplatePath}`)\n return process.exit(1)\n }\n const defaultTargetPath = path.join(CWD, 'react-template')\n \n // Copy\n await fs.cp(htmlTemplatePath, defaultTargetPath, { recursive: true })\n const { projectName } = await prompts({\n name: 'projectName',\n message: 'Project name ? (for package.json name field)',\n type: 'text'\n })\n \n // Custom name\n const packageJsonPath = path.join(defaultTargetPath, 'package.json')\n await readWriteFile(packageJsonPath, rawContent => {\n const content = typeof rawContent === 'string'\n ? rawContent\n : rawContent.toString()\n const contentObj = JSON.parse(content) as Record<string, string>\n delete contentObj.name\n const newContentObj = {\n name: projectName,\n ...contentObj\n }\n return `${JSON.stringify(newContentObj, null, 2)}\\n`\n }, { encoding: 'utf-8' })\n \n // Install deps\n const npmISubprocess = spawn(`cd ${defaultTargetPath} && npm i`, { stdio: 'inherit', shell: true })\n await new Promise((resolve, reject) => {\n npmISubprocess.on('exit', () => resolve(true))\n npmISubprocess.on('error', () => reject(false))\n })\n\n // Rename project\n const targetPath = path.join(CWD, projectName)\n await fs.rename(defaultTargetPath, targetPath)\n\n // Rename gitignore\n await fs.rename(\n path.join(targetPath, 'gitignore'),\n path.join(targetPath, '.gitignore')\n )\n}\n"],
5
+ "mappings": "AAAA,OAAOA,MAAa,eACpB,OAAS,YAAYC,EAAI,cAAAC,MAAkB,UAC3C,OAAOC,MAAS,WAChB,OAAOC,MAAU,YACjB,OAAS,SAAAC,MAAa,qBACtB,OAAS,WAAAC,MAAe,YACxB,OAAOC,MAAa,UACpB,OAAOC,MAAmB,0DAE1B,IAAMC,EAAaN,EAAI,cAAc,YAAY,GAAG,EAC9CO,EAAYN,EAAK,QAAQK,CAAU,EACnCE,EAAMX,EAAQ,IAAI,EAExBM,EACG,KAAK,6BAA6B,EAClC,YAAY,oCAAoC,EAEnDA,EACG,QAAQ,MAAM,EACd,YAAY,oCAAoC,EAChD,OAAOM,CAAQ,EAElBN,EACG,QAAQ,OAAO,EACf,YAAY,2CAA2C,EACvD,OAAOO,CAAS,EAEnBP,EAAQ,MAAMN,EAAQ,IAAI,EAE1B,eAAeY,GAAY,CACzB,IAAME,EAAmBV,EAAK,KAAKM,EAAW,aAAa,EAC3D,GAAI,CAACR,EAAWY,CAAgB,EAC9B,eAAQ,MAAM,0CAA0CA,CAAgB,EAAE,EACnEd,EAAQ,KAAK,CAAC,EAEvB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AAK,KAAKW,EAAY,YAAY,CACpC,CACF",
6
+ "names": ["process", "fs", "existsSync", "url", "path", "spawn", "program", "prompts", "readWriteFile", "__filename", "__dirname", "CWD", "makeHtml", "makeReact", "htmlTemplatePath", "targetPath", "defaultTargetPath", "projectName", "packageJsonPath", "rawContent", "content", "contentObj", "newContentObj", "npmISubprocess", "resolve", "reject"]
7
+ }
package/package.json CHANGED
@@ -1,27 +1,34 @@
1
1
  {
2
2
  "name": "@mxfb/cli",
3
- "version": "0.0.55",
3
+ "version": "0.0.64",
4
4
  "description": "",
5
5
  "author": "Maxime Fabas",
6
6
  "license": "ISC",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/maximefabas/mxfb-cli"
9
+ "url": "https://github.com/mxfb/cli"
10
10
  },
11
11
  "type": "module",
12
12
  "main": "index.js",
13
13
  "module": "index.js",
14
14
  "bin": {
15
15
  "cli": "./cli/index.js",
16
- "make-template": "./make-template/index.js"
16
+ "make-calendar": "./make-calendar/index.js",
17
+ "make-template": "./make-template/index.js",
18
+ "term-glossary": "./term-glossary/index.js",
19
+ "tree": "./tree/index.js",
20
+ "tumblr-crawler": "./tumblr-crawler/index.js"
17
21
  },
18
22
  "dependencies": {
23
+ "@design-edito/tools": "^0.0.30",
19
24
  "commander": "^12.0.0",
20
- "prompts": "^2.4.2"
25
+ "date-fns": "^3.6.0",
26
+ "jsdom": "^24.0.0",
27
+ "prompts": "^2.4.2",
28
+ "puppeteer": "^22.6.5"
21
29
  },
22
30
  "devDependencies": {
23
- "@commander-js/extra-typings": "^12.0.1",
24
- "@mxfb/tools": "^0.0.16",
31
+ "@types/jsdom": "^21.1.6",
25
32
  "@types/node": "^20.11.30",
26
33
  "@types/prompts": "^2.4.9",
27
34
  "@types/semver": "^7.5.8",
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ console.log(`: <<'END'
3
+
4
+ \u2039 TERM GLOSSARY \u203A
5
+
6
+ 1. git & GitHub
7
+
8
+ 1.1 Forking
9
+
10
+ 1.1.1 Creating the fork
11
+
12
+ 1.1.2 Comparing
13
+
14
+ git fetch upstream # r\xE9cup upstream \xE0 jour
15
+ git status # Affiche le diff avec upstream/master
16
+ git log HEAD..upstream/master # log les commits de upstream/master
17
+
18
+ 1.1.3 Updating
19
+
20
+ git merge upstream/master # r\xE9cup\xE8re upstream/master dans origin/master
21
+ git push origin master
22
+
23
+
24
+ END
25
+
26
+ `);
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/term-glossary/index.ts"],
4
+ "sourcesContent": ["// [WIP] use commander\n\nconsole.log(`: <<'END'\n\n\u2039 TERM GLOSSARY \u203A\n\n1. git & GitHub\n\n 1.1 Forking\n\n 1.1.1 Creating the fork\n \n 1.1.2 Comparing\n\n git fetch upstream # r\u00E9cup upstream \u00E0 jour\n git status # Affiche le diff avec upstream/master\n git log HEAD..upstream/master # log les commits de upstream/master\n\n 1.1.3 Updating\n\n git merge upstream/master # r\u00E9cup\u00E8re upstream/master dans origin/master\n git push origin master\n\n\nEND\n\n`)\n"],
5
+ "mappings": "AAEA,QAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAwBX",
6
+ "names": []
7
+ }
package/tree/index.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{program as b}from"commander";import w from"@design-edito/tools/utils/node/list-subpaths/index.js";import f from"@design-edito/tools/utils/node/is-in-directory/index.js";var h=process.cwd();b.name("@design-edito/tree").description("List subpaths from the current working directory").argument("[depth]","Depth (optional, defaults to 0)").option("-f, --files [bool]","Include files",i,!0).option("-H, --hidden [bool]","Include hidden files",i,!0).option("-d, --directories [bool]","Include directories",i,!0).option("-s, --symlinks [bool]","Include symlinks",i,!0).option("-F, --follow [bool]","Follow symlinks",i,!1).option("-u, --unique [bool]","Ensures followed symlinks contents don't create duplicates",i,!1).option("-e, --exclude [pattern]","Regexp patterns to exclude from the result").option("-i, --include [pattern]","Regexp patterns to include in the result").action(async(n,e)=>{let r=n!==void 0?parseInt(n):0;if(Number.isNaN(r))return console.error("Depth should be a number"),process.exit(1);let s=(await w(h,{maxDepth:r,files:e.files,hidden:e.hidden,directories:e.directories,symlinks:e.symlinks,followSimlinks:e.follow,dedupeSimlinksContents:e.unique,exclude:m(e.exclude),include:m(e.include),returnRelative:!0})).reduce((u,l)=>{let a=y(l),c={value:l,level:a,children:[]};u.filter(t=>t.level===a-1&&f(l,t.value)).forEach(t=>t.children.push(c));let p=u.filter(t=>t.level===a+1&&f(t.value,l));return c.children.push(...p),[...u,c]},[]);console.log(h),g(s)});b.parse(process.argv);function i(n){let e=`${n}`.trim().toLowerCase();if(e==="true")return!0;if(e==="false")return!1}function m(n){if(typeof n!="string")return;let e=/^\/(.+)\/([a-z]*)$/,r=n.match(e);if(r===null)return;let[,o,s]=r;return new RegExp(o,s)}function y(n){return n.split("/").length-1}function g(n,e=0,r=[]){n.filter(o=>o.level===e).forEach((o,s,u)=>{let l=s===u.length-1,a=l?"\u2514\u2500\u2500":"\u251C\u2500\u2500",{value:c,level:d,children:p}=o,t=c.split("/").slice(d).join("/"),v=new Array(d).fill(null).map((x,k)=>r[k]===!0?" ":"\u2502 ").join("");console.log(`${v}${a} ${t}`),g(p,d+1,[...r,l])})}
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tree/index.ts"],
4
+ "sourcesContent": ["import { program } from 'commander'\nimport listSubpaths from '@design-edito/tools/utils/node/list-subpaths/index.js'\nimport isInDirectory from '@design-edito/tools/utils/node/is-in-directory/index.js'\n\nconst CWD = process.cwd()\n\ntype SubpathData = {\n value: string\n level: number\n children: SubpathData[]\n}\n\nprogram\n .name('@design-edito/tree')\n .description('List subpaths from the current working directory')\n .argument('[depth]', 'Depth (optional, defaults to 0)')\n .option('-f, --files [bool]', 'Include files', parseBoolean, true)\n .option('-H, --hidden [bool]', 'Include hidden files', parseBoolean, true)\n .option('-d, --directories [bool]', 'Include directories', parseBoolean, true)\n .option('-s, --symlinks [bool]', 'Include symlinks', parseBoolean, true)\n .option('-F, --follow [bool]', 'Follow symlinks', parseBoolean, false)\n .option('-u, --unique [bool]', 'Ensures followed symlinks contents don\\'t create duplicates', parseBoolean, false)\n .option('-e, --exclude [pattern]', 'Regexp patterns to exclude from the result')\n .option('-i, --include [pattern]', 'Regexp patterns to include in the result')\n .action(async (_depth, options) => {\n const depth = _depth !== undefined ? parseInt(_depth) : 0\n if (Number.isNaN(depth)) {\n console.error('Depth should be a number')\n return process.exit(1)\n }\n const subpaths = await listSubpaths(CWD, {\n maxDepth: depth,\n files: options.files,\n hidden: options.hidden,\n directories: options.directories,\n symlinks: options.symlinks,\n followSimlinks: options.follow,\n dedupeSimlinksContents: options.unique,\n exclude: makeRegexp(options.exclude),\n include: makeRegexp(options.include),\n returnRelative: true\n })\n const subpathsData = subpaths.reduce<SubpathData[]>((reduced, subpath) => {\n const level = getLevel(subpath)\n const thisSubpathData = {\n value: subpath,\n level,\n children: [] as SubpathData[]\n }\n // Parents\n const parents = reduced.filter(subpathData => subpathData.level === level - 1 && isInDirectory(subpath, subpathData.value))\n parents.forEach(parent => parent.children.push(thisSubpathData))\n // Children\n const children = reduced.filter(subpathData => subpathData.level === level + 1 && isInDirectory(subpathData.value, subpath))\n thisSubpathData.children.push(...children)\n return [...reduced, thisSubpathData]\n }, [])\n console.log(CWD)\n printSubpathData(subpathsData)\n })\n\nprogram.parse(process.argv)\n\nfunction parseBoolean (val: unknown) {\n const strVal = `${val}`.trim().toLowerCase()\n if (strVal === 'true') return true\n if (strVal === 'false') return false\n return undefined\n}\n\nfunction makeRegexp (strRegexp: unknown) {\n if (typeof strRegexp !== 'string') return undefined\n const validRegexpRegexp = /^\\/(.+)\\/([a-z]*)$/\n const inputMatches = strRegexp.match(validRegexpRegexp)\n if (inputMatches === null) return undefined\n const [, pattern, flags] = inputMatches\n return new RegExp(pattern!, flags!)\n}\n\nfunction getLevel (path: string) {\n const chunks = path.split('/')\n return chunks.length - 1\n}\n\nfunction printSubpathData (\n subpathsData: SubpathData[],\n level: number = 0,\n parentsAreLastMap: boolean[] = []) {\n subpathsData\n .filter(subpathData => subpathData.level === level)\n .forEach((subpathsData, pos, filtered) => {\n const isLast = pos === filtered.length - 1\n const indentChar = isLast ? '\u2514\u2500\u2500' : '\u251C\u2500\u2500'\n const { value, level, children } = subpathsData\n const toPrint = value.split('/').slice(level).join('/')\n const indentChars = new Array(level).fill(null).map((e, pos) => {\n if (parentsAreLastMap[pos] === true) return ' '\n else return '\u2502 '\n }).join('')\n console.log(`${indentChars}${indentChar} ${toPrint}`)\n printSubpathData(children, level + 1, [...parentsAreLastMap, isLast])\n })\n}\n"],
5
+ "mappings": "AAAA,OAAS,WAAAA,MAAe,YACxB,OAAOC,MAAkB,wDACzB,OAAOC,MAAmB,0DAE1B,IAAMC,EAAM,QAAQ,IAAI,EAQxBH,EACG,KAAK,oBAAoB,EACzB,YAAY,kDAAkD,EAC9D,SAAS,UAAW,iCAAiC,EACrD,OAAO,qBAAsB,gBAAiBI,EAAc,EAAI,EAChE,OAAO,sBAAuB,uBAAwBA,EAAc,EAAI,EACxE,OAAO,2BAA4B,sBAAuBA,EAAc,EAAI,EAC5E,OAAO,wBAAyB,mBAAoBA,EAAc,EAAI,EACtE,OAAO,sBAAuB,kBAAmBA,EAAc,EAAK,EACpE,OAAO,sBAAuB,6DAA+DA,EAAc,EAAK,EAChH,OAAO,0BAA2B,4CAA4C,EAC9E,OAAO,0BAA2B,0CAA0C,EAC5E,OAAO,MAAOC,EAAQC,IAAY,CACjC,IAAMC,EAAQF,IAAW,OAAY,SAASA,CAAM,EAAI,EACxD,GAAI,OAAO,MAAME,CAAK,EACpB,eAAQ,MAAM,0BAA0B,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UC,CAAM,CACpC,CAEA,SAASZ,EAAUa,EAAc,CAE/B,OADeA,EAAK,MAAM,GAAG,EACf,OAAS,CACzB,CAEA,SAASR,EACPV,EACAI,EAAgB,EAChBe,EAA+B,CAAC,EAAG,CACnCnB,EACG,OAAOO,GAAeA,EAAY,QAAUH,CAAK,EACjD,QAAQ,CAACJ,EAAcoB,EAAKC,IAAa,CACxC,IAAMC,EAASF,IAAQC,EAAS,OAAS,EACnCE,EAAaD,EAAS,qBAAQ,qBAC9B,CAAE,MAAAE,EAAO,MAAApB,EAAO,SAAAK,CAAS,EAAIT,EAC7ByB,EAAUD,EAAM,MAAM,GAAG,EAAE,MAAMpB,CAAK,EAAE,KAAK,GAAG,EAChDsB,EAAc,IAAI,MAAMtB,CAAK,EAAE,KAAK,IAAI,EAAE,IAAI,CAACuB,EAAGP,IAClDD,EAAkBC,CAAG,IAAM,GAAa,OAChC,WACb,EAAE,KAAK,EAAE,EACV,QAAQ,IAAI,GAAGM,CAAW,GAAGH,CAAU,IAAIE,CAAO,EAAE,EACpDf,EAAiBD,EAAUL,EAAQ,EAAG,CAAC,GAAGe,EAAmBG,CAAM,CAAC,CACtE,CAAC,CACL",
6
+ "names": ["program", "listSubpaths", "isInDirectory", "CWD", "parseBoolean", "_depth", "options", "depth", "subpathsData", "makeRegexp", "reduced", "subpath", "level", "getLevel", "thisSubpathData", "subpathData", "parent", "children", "printSubpathData", "val", "strVal", "strRegexp", "validRegexpRegexp", "inputMatches", "pattern", "flags", "path", "parentsAreLastMap", "pos", "filtered", "isLast", "indentChar", "value", "toPrint", "indentChars", "e"]
7
+ }
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import w from"node:process";import d from"node:path";import{promises as p}from"node:fs";import y from"prompts";import{parse as _}from"date-fns";import{program as g}from"commander";import{JSDOM as S}from"jsdom";import C from"@design-edito/tools/utils/agnostic/wait/index.js";import I from"@design-edito/tools/utils/agnostic/round-numbers/index.js";g.name("@design-edito/tumblr-crawler").description("Crawls a Tumblr blog");g.command("fetch").description("Fetch all pages DOM content").argument("url","Root URL of the tumblr blog").action(async e=>{let{outputPath:t}=await y({type:"text",name:"outputPath",message:"Please select an output path for the data files",initial:`${w.cwd()}/.tmblrcrwlr`}),a=e.trim(),o=[a];/^https?:\/\//i.test(a)||(a.startsWith("://")?o.unshift("https"):o.unshift("https://"));let r=new URL(o.join("")).toString().replace(/\/+$/igm,"");console.log("you wanna crawl",r);let s=await q(r,t),i=JSON.stringify(s,null,2),u=d.join(t,"shallow.json");console.log(`outputting fetched data (${s.length}) pages`),await p.mkdir(t,{recursive:!0}),await p.writeFile(u,i,{encoding:"utf-8"}),console.log("Wrote data at",u)});g.command("extract-posts").description("Axtracts post data from the outputs of tumblr-crawler fetch <url>").action(async()=>{let{shallowJsonPath:e}=await y({type:"text",name:"shallowJsonPath",message:"Please enter a shallow.json file path",initial:`${w.cwd()}/.tmblrcrwlr/shallow.json`}),t=await p.readFile(e,{encoding:"utf-8"}),a=JSON.parse(t),o=await F(a),n=Object.fromEntries(o),r=JSON.stringify(n,null,2),s=d.join(d.dirname(e),"extracted.json");await p.writeFile(s,r,{encoding:"utf-8"})});g.command("output").description("Fills missing post data").action(async()=>{let{extractedJsonPath:e}=await y({type:"text",name:"extractedJsonPath",message:"Please enter a extracted.json file path",initial:`${w.cwd()}/.tmblrcrwlr/extracted.json`}),t=await p.readFile(e,{encoding:"utf-8"}),a=JSON.parse(t),o=[];Object.entries(a).forEach(([s,i])=>{let{id:u,date:c,url:l,youtube_id:m,youtube_title:h,post_content:b}=i,f=c!==null?_(c,"EEE. MMMM d, yyyy '@' h:mm a",new Date).toISOString():null;o.push({publishOn:f,publishOnRaw:c,songTitle:b,youtubeId:m,youtubeTitle:h,postUrl:l,postId:u})});let n=JSON.stringify(o,null,2),r=d.join(d.dirname(e),"output.json");await p.writeFile(r,n,{encoding:"utf-8"})});g.parse(w.argv);async function q(e,t,a=0){let o=new Map,n=0+a;try{for(;;){n++;let s=`${e}/page/${n}`;if(n>200)break;console.log(s,"...");let i=await A(n,e);if(i===void 0){o.set(n,{isValid:!1,domString:"",dom:null,url:s});break}let{isValid:u,dom:c}=await $(i);if(o.set(n,{isValid:u,domString:i,dom:c,url:s}),!u)break;let l=Math.random()*2e3+2e3;console.log(`Waiting before new request... (${I(l/1e3,1)}s)
3
+
4
+ `),await C(l)}}catch(s){console.log("Something went wrong while crawling..."),console.log(s)}let r=[];return o.forEach((s,i)=>{r.push({number:i,url:s.url,content:s.domString,isValid:s.isValid})}),r}async function A(e,t){if(!Number.isInteger(e)||e<=0)throw new Error(`Page number must be a non-zero positive integer. Found: ${e}`);return await(await fetch(`${t}/page/${e}`)).text()}async function $(e){let t=new S(e),{window:{document:a}}=t,o=a.querySelector("#page");if(o===null)return{isValid:!1,dom:t};let n=o.querySelector("#content");return n===null?{isValid:!1,dom:t}:n.querySelectorAll("article.post").length===0?{isValid:!1,dom:t}:{isValid:!0,dom:t}}async function F(e){let t=new Map;for(let a of e)(await R(a))?.forEach((n,r)=>t.set(r,n));return t}async function R(e){let t=new Map,{number:a,url:o,content:n,isValid:r}=e;if(!r)return;let s=new S(n),{window:{document:i}}=s,u=i.querySelector("#page");if(u===null)return;let c=u.querySelectorAll("article.post");if(c.length!==0){for(let l of Array.from(c)){let m=l.getAttribute("id")?.split("post-").at(1);if(m===void 0)continue;let h=Array.from(l.classList).find(V=>V.trim().match(/^type\-/igm))?.replace(/^type\-/igm,""),f=l.querySelector(".post-panel .media")?.querySelector('iframe[src^="https://www.youtube.com/embed/"]')??null,J=f?.getAttribute("src")?.split("https://www.youtube.com/embed/").at(1)?.split("?").at(0),O=f?.getAttribute("title")??void 0,x=l.querySelector(".post-panel .copy")?.textContent?.trim(),P=l.querySelector(".post-panel .meta .meta-list"),D=P?.querySelector(".date a"),j=P?.querySelector(".permalink a"),M=D?.getAttribute("title"),E=j?.getAttribute("href");t.set(m,{id:m,url:E??null,date:M??null,type:h??null,post_element_outerhtml:l.outerHTML,youtube_id:J??null,youtube_title:O??null,post_content:x??null})}return t}}
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tumblr-crawler/index.ts"],
4
+ "sourcesContent": ["import process from 'node:process'\nimport path from 'node:path'\nimport { promises as fs } from 'node:fs'\nimport prompts from 'prompts'\nimport { parse as dateParse, format as dateFormat } from 'date-fns'\nimport { program } from 'commander'\nimport { JSDOM } from 'jsdom'\nimport wait from '@design-edito/tools/utils/agnostic/wait/index.js'\nimport roundNumbers from '@design-edito/tools/utils/agnostic/round-numbers/index.js'\nimport { beforeForcedExit, beforeExit } from '@design-edito/tools/utils/node/process-exit/index.js'\n\n// const browser = await puppeteer.launch()\n// beforeExit(async () => browser.close())\n// beforeForcedExit(async () => browser.close())\n\nprogram\n .name('@design-edito/tumblr-crawler')\n .description('Crawls a Tumblr blog')\n\nprogram\n .command('fetch')\n .description('Fetch all pages DOM content')\n .argument('url', 'Root URL of the tumblr blog')\n .action(async inputUrl => {\n const { outputPath } = await prompts({\n type: 'text',\n name: 'outputPath',\n message: 'Please select an output path for the data files',\n initial: `${process.cwd()}/.tmblrcrwlr`\n }) as { outputPath: string }\n const trimmedInput = inputUrl.trim()\n const urlChunks = [trimmedInput]\n if (!/^https?:\\/\\//i.test(trimmedInput)) {\n if (trimmedInput.startsWith('://')) urlChunks.unshift('https')\n else urlChunks.unshift('https://')\n }\n const url = new URL(urlChunks.join(''))\n const stringifiedUrl = url.toString().replace(/\\/+$/igm, '')\n console.log('you wanna crawl', stringifiedUrl)\n const shallowJson = await fetchPagesDom(stringifiedUrl, outputPath)\n const shallowJsonContent = JSON.stringify(shallowJson, null, 2)\n const outputShallowJsonPath = path.join(outputPath, `shallow.json`)\n console.log(`outputting fetched data (${shallowJson.length}) pages`)\n await fs.mkdir(outputPath, { recursive: true })\n await fs.writeFile(outputShallowJsonPath, shallowJsonContent, { encoding: 'utf-8' })\n console.log('Wrote data at', outputShallowJsonPath)\n // await browser.close()\n })\n\nprogram\n .command('extract-posts')\n .description('Axtracts post data from the outputs of tumblr-crawler fetch <url>')\n .action(async () => {\n const { shallowJsonPath } = await prompts({\n type: 'text',\n name: 'shallowJsonPath',\n message: 'Please enter a shallow.json file path',\n initial: `${process.cwd()}/.tmblrcrwlr/shallow.json`\n })\n const shallowJsonContent = await fs.readFile(shallowJsonPath, { encoding: 'utf-8' })\n const shallowJsonObj = JSON.parse(shallowJsonContent) as ShallowJson\n const extractedPages = await extractPages(shallowJsonObj)\n const postsDataObj = Object.fromEntries(extractedPages)\n const postsDataContent = JSON.stringify(postsDataObj, null, 2)\n const extractedPath = path.join(path.dirname(shallowJsonPath), 'extracted.json')\n await fs.writeFile(extractedPath, postsDataContent, { encoding: 'utf-8' })\n // await browser.close()\n })\n\ntype OutputPostData = {\n publishOn: string | null,\n publishOnRaw: string | null,\n songTitle: string | null,\n youtubeId: string | null,\n youtubeTitle: string | null,\n postUrl: string | null,\n postId: string | null\n}\n\nprogram\n .command('output')\n .description('Fills missing post data')\n .action(async () => {\n const { extractedJsonPath } = await prompts({\n type: 'text',\n name: 'extractedJsonPath',\n message: 'Please enter a extracted.json file path',\n initial: `${process.cwd()}/.tmblrcrwlr/extracted.json`\n })\n const extractedJsonContent = await fs.readFile(extractedJsonPath, { encoding: 'utf-8' })\n const extractedJsonObj = JSON.parse(extractedJsonContent) as Record<string, PostData>\n const output: OutputPostData[] = []\n Object.entries(extractedJsonObj).forEach(([_id, postData]) => {\n const { id, date, url, youtube_id, youtube_title, post_content } = postData\n const dt = date !== null ? dateParse(date, 'EEE. MMMM d, yyyy \\'@\\' h:mm a', new Date()).toISOString() : null\n output.push({\n publishOn: dt,\n publishOnRaw: date,\n songTitle: post_content,\n youtubeId: youtube_id,\n youtubeTitle: youtube_title,\n postUrl: url,\n postId: id\n })\n })\n const jsonOutput = JSON.stringify(output, null, 2)\n const outputPath = path.join(path.dirname(extractedJsonPath), 'output.json')\n await fs.writeFile(outputPath, jsonOutput, { encoding: 'utf-8' })\n })\n \nprogram.parse(process.argv)\n\ntype PageData = {\n isValid: boolean\n domString: string\n dom: JSDOM | null\n url: string\n}\n\ntype ShallowJson = Array<{\n number: number\n url: string\n content: string\n isValid: boolean\n}>\n\nasync function fetchPagesDom (rootUrl: string, outputPath: string, startOffset: number = 0) {\n const pagesMap = new Map<number, PageData>()\n let pagePos = 0 + startOffset\n try {\n while (true) {\n pagePos ++\n const url = `${rootUrl}/page/${pagePos}`\n if (pagePos > 200) break;\n console.log(url, '...')\n const domString = await fetchPostsPageContent(pagePos, rootUrl)\n if (domString === undefined) {\n pagesMap.set(pagePos, { isValid: false, domString: '', dom: null, url })\n break;\n }\n const { isValid, dom } = await validatePageContent(domString)\n pagesMap.set(pagePos, { isValid, domString, dom, url })\n if (!isValid) break;\n const delay = (Math.random() * 2000) + 2000\n console.log(`Waiting before new request... (${roundNumbers(delay / 1000, 1)}s)\\n\\n`)\n await wait(delay)\n }\n } catch (err) {\n console.log('Something went wrong while crawling...')\n console.log(err)\n }\n const shallowJson: ShallowJson = []\n pagesMap.forEach((pageData, pagePos) => {\n shallowJson.push({\n number: pagePos,\n url: pageData.url,\n content: pageData.domString,\n isValid: pageData.isValid\n })\n })\n return shallowJson\n}\n\nasync function fetchPostsPageContent (pagePos: number, rootUrl: string) {\n const isInteger = Number.isInteger(pagePos)\n if (!isInteger || pagePos <= 0) throw new Error(`Page number must be a non-zero positive integer. Found: ${pagePos}`)\n // const page = await browser.newPage()\n // page.goto(`${rootUrl}/page/${pagePos}`, { waitUntil: 'networkidle2' })\n // await page.waitForNavigation()\n // await wait(1000)\n // const content = await page.evaluate(() => {\n // try { return document.documentElement.outerHTML }\n // catch { return undefined }\n // })\n // page.close()\n return await (await fetch(`${rootUrl}/page/${pagePos}`)).text()\n // return content\n}\n\ntype PageValidationResult = {\n isValid: boolean\n dom: JSDOM\n}\n\nasync function validatePageContent (pageContent: string): Promise<PageValidationResult> {\n const dom = new JSDOM(pageContent)\n const { window: { document } } = dom\n const page = document.querySelector('#page')\n if (page === null) return { isValid: false, dom }\n const content = page.querySelector('#content')\n if (content === null) return { isValid: false, dom }\n const posts = content.querySelectorAll('article.post')\n if (posts.length === 0) return { isValid: false, dom }\n return { isValid: true, dom }\n}\n\ntype PostData = {\n id: string\n url: string | null\n date: string | null\n type: string | null\n post_element_outerhtml: string | null\n post_content: string | null\n youtube_id: string | null\n youtube_title: string | null\n}\n\nasync function extractPages (shallowJson: ShallowJson): Promise<Map<string, PostData>> {\n const postsData = new Map<string, PostData>()\n for (const shallowPage of shallowJson) {\n const extractedPage = await analysePage(shallowPage)\n extractedPage?.forEach((postData, postId) => postsData.set(postId, postData))\n }\n return postsData\n}\n\nasync function analysePage (shallowPage: ShallowJson[number]) {\n const postData = new Map<string, PostData>()\n const { number, url, content, isValid } = shallowPage\n if (!isValid) return;\n const dom = new JSDOM(content)\n const { window: { document } } = dom\n const page = document.querySelector('#page')\n if (page === null) return;\n const posts = page.querySelectorAll('article.post')\n if (posts.length === 0) return;\n for (const postElement of Array.from(posts)) {\n const id = postElement.getAttribute('id')?.split('post-').at(1)\n if (id === undefined) continue\n const type = Array\n .from(postElement.classList)\n .find(clss => clss.trim().match(/^type\\-/igm))\n ?.replace(/^type\\-/igm, '')\n const mediaContainer = postElement.querySelector('.post-panel .media')\n const youtubeIframeContainer = mediaContainer?.querySelector('iframe[src^=\"https://www.youtube.com/embed/\"]') ?? null\n const youtubeIframeId = youtubeIframeContainer\n ?.getAttribute('src')\n ?.split('https://www.youtube.com/embed/').at(1)\n ?.split('?').at(0)\n const youtubeIframeTitle = youtubeIframeContainer?.getAttribute('title') ?? undefined\n const postContent = postElement.querySelector('.post-panel .copy')?.textContent?.trim()\n const postMetaListElement = postElement.querySelector('.post-panel .meta .meta-list')\n const postDateElement = postMetaListElement?.querySelector('.date a')\n const postPermalinkElement = postMetaListElement?.querySelector('.permalink a')\n const postDate = postDateElement?.getAttribute('title')\n const postUrl = postPermalinkElement?.getAttribute('href')\n postData.set(id, {\n id,\n url: postUrl ?? null,\n date: postDate ?? null,\n type: type ?? null,\n post_element_outerhtml: postElement.outerHTML,\n youtube_id: youtubeIframeId ?? null,\n youtube_title: youtubeIframeTitle ?? null,\n post_content: postContent ?? null\n })\n }\n return postData\n}\n"],
5
+ "mappings": "AAAA,OAAOA,MAAa,eACpB,OAAOC,MAAU,YACjB,OAAS,YAAYC,MAAU,UAC/B,OAAOC,MAAa,UACpB,OAAS,SAASC,MAAuC,WACzD,OAAS,WAAAC,MAAe,YACxB,OAAS,SAAAC,MAAa,QACtB,OAAOC,MAAU,mDACjB,OAAOC,MAAkB,4DAOzBH,EACG,KAAK,8BAA8B,EACnC,YAAY,sBAAsB,EAErCA,EACG,QAAQ,OAAO,EACf,YAAY,6BAA6B,EACzC,SAAS,MAAO,6BAA6B,EAC7C,OAAO,MAAMI,GAAY,CACxB,GAAM,CAAE,WAAAC,CAAW,EAAI,MAAMP,EAAQ,CACnC,KAAM,OACN,KAAM,aACN,QAAS,kDACT,QAAS,GAAGH,EAAQ,IAAI,CAAC,cAC3B,CAAC,EACKW,EAAeF,EAAS,KAAK,EAC7BG,EAAY,CAACD,CAAY,EAC1B,gBAAgB,KAAKA,CAAY,IAChCA,EAAa,WAAW,KAAK,EAAGC,EAAU,QAAQ,OAAO,EACxDA,EAAU,QAAQ,UAAU,GAGnC,IAAMC,EADM,IAAI,IAAID,EAAU,KAAK,EAAE,CAAC,EACX,SAAS,EAAE,QAAQ,UAAW,EAAE,EAC3D,QAAQ,IAAI,kBAAmBC,CAAc,EAC7C,IAAMC,EAAc,MAAMC,EAAcF,EAAgBH,CAAU,EAC5DM,EAAqB,KAAK,UAAUF,EAAa,KAAM,CAAC,EACxDG,EAAwBhB,EAAK,KAAKS,EAAY,cAAc,EAClE,QAAQ,IAAI,4BAA4BI,EAAY,MAAM,SAAS,EACnE,MAAMZ,EAAG,MAAMQ,EAAY,CAAE,UAAW,EAAK,CAAC,EAC9C,MAAMR,EAAG,UAAUe,EAAuBD,EAAoB,CA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,CAAE,SAAAF,CAAS,CAAE,EAAIN,EAC3BO,EAAOD,EAAS,cAAc,OAAO,EAC3C,GAAIC,IAAS,KAAM,OACnB,IAAMO,EAAQP,EAAK,iBAAiB,cAAc,EAClD,GAAIO,EAAM,SAAW,EACrB,SAAWC,KAAe,MAAM,KAAKD,CAAK,EAAG,CAC3C,IAAM7B,EAAK8B,EAAY,aAAa,IAAI,GAAG,MAAM,OAAO,EAAE,GAAG,CAAC,EAC9D,GAAI9B,IAAO,OAAW,SACtB,IAAM+B,EAAO,MACV,KAAKD,EAAY,SAAS,EAC1B,KAAKE,GAAQA,EAAK,KAAK,EAAE,MAAM,YAAY,CAAC,GAC3C,QAAQ,aAAc,EAAE,EAEtBC,EADiBH,EAAY,cAAc,oBAAoB,GACtB,cAAc,+CAA+C,GAAK,KAC3GI,EAAkBD,GACpB,aAAa,KAAK,GAClB,MAAM,gCAAgC,EAAE,GAAG,CAAC,GAC5C,MAAM,GAAG,EAAE,GAAG,CAAC,EACbE,EAAqBF,GAAwB,aAAa,OAAO,GAAK,OACtEG,EAAcN,EAAY,cAAc,mBAAmB,GAAG,aAAa,KAAK,EAChFO,EAAsBP,EAAY,cAAc,8BAA8B,EAC9EQ,EAAkBD,GAAqB,cAAc,SAAS,EAC9DE,EAAuBF,GAAqB,cAAc,cAAc,EACxEG,EAAWF,GAAiB,aAAa,OAAO,EAChDG,EAAUF,GAAsB,aAAa,MAAM,EACzDxC,EAAS,IAAIC,EAAI,CACf,GAAAA,EACA,IAAKyC,GAAW,KAChB,KAAMD,GAAY,KAClB,KAAMT,GAAQ,KACd,uBAAwBD,EAAY,UACpC,WAAYI,GAAmB,KAC/B,cAAeC,GAAsB,KACrC,aAAcC,GAAe,IAC/B,CAAC,CACH,CACA,OAAOrC,EACT",
6
+ "names": ["process", "path", "fs", "prompts", "dateParse", "program", "JSDOM", "wait", "roundNumbers", "inputUrl", "outputPath", "trimmedInput", "urlChunks", "stringifiedUrl", "shallowJson", "fetchPagesDom", "shallowJsonContent", "outputShallowJsonPath", "shallowJsonPath", "shallowJsonObj", "extractedPages", "extractPages", "postsDataObj", "postsDataContent", "extractedPath", "extractedJsonPath", "extractedJsonContent", "extractedJsonObj", "output", "_id", "postData", "id", "date", "url", "youtube_id", "youtube_title", "post_content", "dt", "jsonOutput", "rootUrl", "startOffset", "pagesMap", "pagePos", "domString", "fetchPostsPageContent", "isValid", "dom", "validatePageContent", "delay", "err", "pageData", "pageContent", "document", "page", "content", "postsData", "shallowPage", "analysePage", "postId", "number", "posts", "postElement", "type", "clss", "youtubeIframeContainer", "youtubeIframeId", "youtubeIframeTitle", "postContent", "postMetaListElement", "postDateElement", "postPermalinkElement", "postDate", "postUrl"]
7
+ }