@mxfb/cli 1.0.4 → 1.0.5
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/health-check/index.js +10 -0
- package/health-check/index.js.map +7 -0
- package/make-calendar/index.js +3 -0
- package/make-calendar/index.js.map +7 -0
- package/mxfb/assets/list.txt +4 -1
- package/mxfb/assets/version.txt +1 -1
- package/package.json +14 -11
- package/scrape-tumblr/index.js +4 -3
- package/scrape-tumblr/index.js.map +3 -3
- package/term-glossary/index.js +3 -0
- package/term-glossary/index.js.map +7 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{promises as p}from"node:fs";import a from"node:path";import d from"node:process";import{Command as $}from"commander";import{styles as n}from"@design-edito/tools/agnostic/misc/logs/styles/index.js";import{compareVersions as b,readWorkspaceHealth as C}from"@mxfb/tools/node/@mxfb/workspace/index.js";var h=["critical","high","moderate","low"],m=new $().name("health-check").description("The state of every repository a workspace synchronises. Reads, never writes.").argument("[root]","the workspace directory, the one holding repos.txt",d.cwd()).option("--scope <scope...>","only treat packages under these scopes as the workspace's own").option("--no-digest","skip writing .health/last.json").parse(),[k]=m.processedArgs,{scope:S,digest:j}=m.opts(),c=a.resolve(k);await v(a.join(c,"repos.txt"))||(console.log(""),console.log(n.error(`No repos.txt in ${c}`)),console.log(n.light("> run this from a workspace root, or name one as the argument")),d.exit(1));async function v(e){try{return await p.stat(e),!0}catch{return!1}}function i(e,t){return e.length>=t?e:`${e}${" ".repeat(t-e.length)}`}function V(e){if(e===null)return["no git",n.light];if(e.upstream===null)return["no upstream",n.warning];let t=[];if((e.ahead??0)>0&&t.push(`+${e.ahead}`),(e.behind??0)>0&&t.push(`-${e.behind}`),e.dirtyCount>0&&t.push(`${e.dirtyCount} dirty`),t.length===0)return["clean",n.success];let s=(e.behind??0)>0||e.dirtyCount>0;return[t.join(" "),s?n.warning:n.info]}function N(e){if(e===null)return["",n.light];let t=e.localVersion??"?",s=e.registryVersion??"?",l=e.commitsSinceTag;return e.registryVersion!==null&&b(t,s)===0?l===null||l===0?[`${t} published`,n.success]:[`${t}, ${l} since tag`,n.info]:[`${t} local, ${s} published`,n.warning]}function R(e){if(e.length===0)return["",n.light];let t=s=>e.filter(l=>l.verdict===s).length;return t("unreachable")>0?[`${t("unreachable")} unreachable`,n.error]:t("missing")>0?[`${t("missing")} missing`,n.warning]:t("behind")>0?[`${t("behind")} behind`,n.warning]:[`${e.length} current`,n.success]}function T(e,t){return e===null?[t??"unparsed",n.light]:h.reduce((o,r)=>o+e[r],0)===0?["clean",n.success]:[h.filter(o=>e[o]>0).map(o=>`${e[o]} ${o}`).join(" "),e.critical>0?n.error:n.warning]}function x(e,t){return e===null?[t??"unparsed",n.light]:e.length===0?["clean",n.success]:[`${e.length}`,n.warning]}function E(e){let t=e.map(o=>({name:o.target.name,cells:o.present?[[o.git?.branch??"",n.light],V(o.git),N(o.publish),R(o.consumption),T(o.audit,o.skipped),x(o.outdated,o.skipped)]:[["absent",n.warning]]})),s=["repository","branch","git","publish","deps","audit","outdated"],l=s.map((o,r)=>Math.max(o.length,...t.map(u=>r===0?u.name.length:u.cells[r-1]?.[0].length??0)));console.log(n.light(s.map((o,r)=>i(o,l[r]??0)).join(" ")));for(let o of t){let r=[n.important(i(o.name,l[0]??0))];o.cells.forEach((u,f)=>{let[y,w]=u;r.push(w(i(y,l[f+1]??0)))}),console.log(r.join(" "))}}console.log("");console.log(n.title(`Reading ${a.basename(c)}...`));var g=await C(c,{scopes:S,onTargetRead:e=>{if(!e.present){console.log(n.warning(`> ${e.target.name} is absent from disk`));return}if(e.git?.fetchFailed===!0){console.log(n.warning(`> ${e.target.name}: git fetch failed, its remote state is stale`));return}console.log(n.light(`> ${e.target.name}`))}});console.log("");console.log(n.title("Health digest."));console.log(n.info(`
|
|
3
|
+
Published packages
|
|
4
|
+
`));for(let e of g.published)console.log(n.light(`> ${i(e,28)} ${g.registryVersions[e]??"unknown"}`));if(g.globals.length>0){console.log(n.info(`
|
|
5
|
+
Globally installed
|
|
6
|
+
`));for(let e of g.globals){let t=e.installedVersion;if(t===null){console.log(n.warning(`> ${i(e.packageName,28)} not installed globally`));continue}let s=`> ${i(e.packageName,28)} ${i(t,10)} ${e.current?"up to date":`latest is ${e.registryVersion??"unknown"}`}`;console.log(e.current?n.light(s):n.warning(s))}}console.log(n.info(`
|
|
7
|
+
Repositories
|
|
8
|
+
`));E(g.targets);if(j){let e=a.join(c,".health");await p.mkdir(e,{recursive:!0});let t=a.join(e,"last.json");await p.writeFile(t,`${JSON.stringify(g,null,2)}
|
|
9
|
+
`,{encoding:"utf-8"}),console.log(""),console.log(n.success("Health pass complete.")),console.log(n.light(`> ${a.relative(c,t)}`))}else console.log(""),console.log(n.success("Health pass complete."));
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/health-check/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { promises as fs } from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { Command } from 'commander'\nimport { styles } from '@design-edito/tools/agnostic/misc/logs/styles/index.js'\nimport {\n compareVersions,\n readWorkspaceHealth,\n type GitState,\n type OutdatedEntry,\n type PublishState,\n type SeverityCounts,\n type TargetReport,\n type ConsumptionState\n} from '@mxfb/tools/node/@mxfb/workspace/index.js'\n\ntype Style = (text: string) => string\ntype Cell = [string, Style]\n\nconst severityNames = ['critical', 'high', 'moderate', 'low'] as const\n\nconst program = new Command()\n .name('health-check')\n .description('The state of every repository a workspace synchronises. Reads, never writes.')\n .argument('[root]', 'the workspace directory, the one holding repos.txt', process.cwd())\n .option('--scope <scope...>', 'only treat packages under these scopes as the workspace\\'s own')\n .option('--no-digest', 'skip writing .health/last.json')\n .parse()\n\nconst [rootArg] = program.processedArgs as [string]\nconst { scope, digest } = program.opts<{ scope?: string[], digest: boolean }>()\nconst root = path.resolve(rootArg)\n\nif (!await pathExists(path.join(root, 'repos.txt'))) {\n console.log('')\n console.log(styles.error(`No repos.txt in ${root}`))\n console.log(styles.light('> run this from a workspace root, or name one as the argument'))\n process.exit(1)\n}\n\nasync function pathExists (target: string): Promise<boolean> {\n try {\n await fs.stat(target)\n return true\n } catch {\n return false\n }\n}\n\nfunction pad (text: string, width: number): string {\n return text.length >= width ? text : `${text}${' '.repeat(width - text.length)}`\n}\n\nfunction gitCell (git: GitState | null): Cell {\n if (git === null) return ['no git', styles.light]\n if (git.upstream === null) return ['no upstream', styles.warning]\n const parts: string[] = []\n if ((git.ahead ?? 0) > 0) parts.push(`+${git.ahead}`)\n if ((git.behind ?? 0) > 0) parts.push(`-${git.behind}`)\n if (git.dirtyCount > 0) parts.push(`${git.dirtyCount} dirty`)\n if (parts.length === 0) return ['clean', styles.success]\n const pressing = (git.behind ?? 0) > 0 || git.dirtyCount > 0\n return [parts.join(' '), pressing ? styles.warning : styles.info]\n}\n\nfunction publishCell (publish: PublishState | null): Cell {\n if (publish === null) return ['', styles.light]\n const local = publish.localVersion ?? '?'\n const remote = publish.registryVersion ?? '?'\n const since = publish.commitsSinceTag\n const matches = publish.registryVersion !== null && compareVersions(local, remote) === 0\n if (!matches) return [`${local} local, ${remote} published`, styles.warning]\n if (since === null || since === 0) return [`${local} published`, styles.success]\n return [`${local}, ${since} since tag`, styles.info]\n}\n\nfunction consumptionCell (states: ConsumptionState[]): Cell {\n if (states.length === 0) return ['', styles.light]\n const count = (verdict: string): number => states.filter(state => state.verdict === verdict).length\n if (count('unreachable') > 0) return [`${count('unreachable')} unreachable`, styles.error]\n if (count('missing') > 0) return [`${count('missing')} missing`, styles.warning]\n if (count('behind') > 0) return [`${count('behind')} behind`, styles.warning]\n return [`${states.length} current`, styles.success]\n}\n\nfunction auditCell (counts: SeverityCounts | null, skipped: string | null): Cell {\n if (counts === null) return [skipped ?? 'unparsed', styles.light]\n const total = severityNames.reduce((sum, severity) => sum + counts[severity], 0)\n if (total === 0) return ['clean', styles.success]\n const parts = severityNames\n .filter(severity => counts[severity] > 0)\n .map(severity => `${counts[severity]} ${severity}`)\n return [parts.join(' '), counts.critical > 0 ? styles.error : styles.warning]\n}\n\nfunction outdatedCell (entries: OutdatedEntry[] | null, skipped: string | null): Cell {\n if (entries === null) return [skipped ?? 'unparsed', styles.light]\n if (entries.length === 0) return ['clean', styles.success]\n return [`${entries.length}`, styles.warning]\n}\n\nfunction printTable (reports: TargetReport[]): void {\n const rows = reports.map(report => ({\n name: report.target.name,\n cells: report.present\n ? [\n [report.git?.branch ?? '', styles.light] as Cell,\n gitCell(report.git),\n publishCell(report.publish),\n consumptionCell(report.consumption),\n auditCell(report.audit, report.skipped),\n outdatedCell(report.outdated, report.skipped)\n ]\n : [['absent', styles.warning] as Cell]\n }))\n const headers = ['repository', 'branch', 'git', 'publish', 'deps', 'audit', 'outdated']\n const widths = headers.map((header, column) => Math.max(\n header.length,\n ...rows.map(row => column === 0\n ? row.name.length\n : (row.cells[column - 1]?.[0].length ?? 0))\n ))\n console.log(styles.light(headers.map((header, column) => pad(header, widths[column] ?? 0)).join(' ')))\n for (const row of rows) {\n const cells = [styles.important(pad(row.name, widths[0] ?? 0))]\n row.cells.forEach((cell, index) => {\n const [text, style] = cell\n cells.push(style(pad(text, widths[index + 1] ?? 0)))\n })\n console.log(cells.join(' '))\n }\n}\n\nconsole.log('')\nconsole.log(styles.title(`Reading ${path.basename(root)}...`))\n\nconst report = await readWorkspaceHealth(root, {\n scopes: scope,\n onTargetRead: target => {\n if (!target.present) { console.log(styles.warning(`> ${target.target.name} is absent from disk`)); return }\n if (target.git?.fetchFailed === true) { console.log(styles.warning(`> ${target.target.name}: git fetch failed, its remote state is stale`)); return }\n console.log(styles.light(`> ${target.target.name}`))\n }\n})\n\nconsole.log('')\nconsole.log(styles.title('Health digest.'))\n\nconsole.log(styles.info('\\nPublished packages\\n'))\nfor (const packageName of report.published) {\n console.log(styles.light(`> ${pad(packageName, 28)} ${report.registryVersions[packageName] ?? 'unknown'}`))\n}\n\nif (report.globals.length > 0) {\n console.log(styles.info('\\nGlobally installed\\n'))\n for (const global of report.globals) {\n const installed = global.installedVersion\n if (installed === null) {\n console.log(styles.warning(`> ${pad(global.packageName, 28)} not installed globally`))\n continue\n }\n const line = `> ${pad(global.packageName, 28)} ${pad(installed, 10)} ${global.current ? 'up to date' : `latest is ${global.registryVersion ?? 'unknown'}`}`\n console.log(global.current ? styles.light(line) : styles.warning(line))\n }\n}\n\nconsole.log(styles.info('\\nRepositories\\n'))\nprintTable(report.targets)\n\nif (digest) {\n const dir = path.join(root, '.health')\n await fs.mkdir(dir, { recursive: true })\n const file = path.join(dir, 'last.json')\n await fs.writeFile(file, `${JSON.stringify(report, null, 2)}\\n`, { encoding: 'utf-8' })\n console.log('')\n console.log(styles.success('Health pass complete.'))\n console.log(styles.light(`> ${path.relative(root, file)}`))\n} else {\n console.log('')\n console.log(styles.success('Health pass complete.'))\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,YAAYA,MAAU,UAC/B,OAAOC,MAAU,YACjB,OAAOC,MAAa,eACpB,OAAS,WAAAC,MAAe,YACxB,OAAS,UAAAC,MAAc,yDACvB,OACE,mBAAAC,EACA,uBAAAC,MAOK,4CAKP,IAAMC,EAAgB,CAAC,WAAY,OAAQ,WAAY,KAAK,EAEtDC,EAAU,IAAIL,EAAQ,EACzB,KAAK,cAAc,EACnB,YAAY,8EAA8E,EAC1F,SAAS,SAAU,qDAAsDD,EAAQ,IAAI,CAAC,EACtF,OAAO,qBAAsB,+DAAgE,EAC7F,OAAO,cAAe,gCAAgC,EACtD,MAAM,EAEH,CAACO,CAAO,EAAID,EAAQ,cACpB,CAAE,MAAAE,EAAO,OAAAC,CAAO,EAAIH,EAAQ,KAA4C,EACxEI,EAAOX,EAAK,QAAQQ,CAAO,EAE5B,MAAMI,EAAWZ,EAAK,KAAKW,EAAM,WAAW,CAAC,IAChD,QAAQ,IAAI,EAAE,EACd,QAAQ,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AUjD,EAAO,MAAMmD,CAAI,EAAInD,EAAO,QAAQmD,CAAI,CAAC,CACxE,CACF,CAEA,QAAQ,IAAInD,EAAO,KAAK;AAAA;AAAA,CAAkB,CAAC,EAC3CmC,EAAWG,EAAO,OAAO,EAEzB,GAAI/B,EAAQ,CACV,IAAM6C,EAAMvD,EAAK,KAAKW,EAAM,SAAS,EACrC,MAAMZ,EAAG,MAAMwD,EAAK,CAAE,UAAW,EAAK,CAAC,EACvC,IAAMC,EAAOxD,EAAK,KAAKuD,EAAK,WAAW,EACvC,MAAMxD,EAAG,UAAUyD,EAAM,GAAG,KAAK,UAAUf,EAAQ,KAAM,CAAC,CAAC;AAAA,EAAM,CAAE,SAAU,OAAQ,CAAC,EACtF,QAAQ,IAAI,EAAE,EACd,QAAQ,IAAItC,EAAO,QAAQ,uBAAuB,CAAC,EACnD,QAAQ,IAAIA,EAAO,MAAM,KAAKH,EAAK,SAASW,EAAM6C,CAAI,CAAC,EAAE,CAAC,CAC5D,MACE,QAAQ,IAAI,EAAE,EACd,QAAQ,IAAIrD,EAAO,QAAQ,uBAAuB,CAAC",
|
|
6
|
+
"names": ["fs", "path", "process", "Command", "styles", "compareVersions", "readWorkspaceHealth", "severityNames", "program", "rootArg", "scope", "digest", "root", "pathExists", "target", "pad", "text", "width", "gitCell", "git", "parts", "pressing", "publishCell", "publish", "local", "remote", "since", "consumptionCell", "states", "count", "verdict", "state", "auditCell", "counts", "skipped", "sum", "severity", "outdatedCell", "entries", "printTable", "reports", "rows", "report", "headers", "widths", "header", "column", "row", "cells", "cell", "index", "style", "packageName", "global", "installed", "line", "dir", "file"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{Command as m,InvalidArgumentError as d}from"commander";import{styles as o}from"@design-edito/tools/agnostic/misc/logs/styles/index.js";var f=864e5,T="_ _ _ _ _ + _ _",p="m t w t f + s s",y="___",r=7,i=`\u2502 ${"date".padEnd(11)} \u2014 week \u2014 ${p} `;function h(t){let e=Number.parseInt(t,10);if(Number.isNaN(e)||e<1||e>9999)throw new d("Expected a year.");return e}function g(t){let e=new Date(t.getTime());return e.setUTCDate(e.getUTCDate()+4-(e.getUTCDay()||7)),e}function C(t){return g(t).getUTCFullYear()}function U(t){let e=g(t),n=Date.UTC(e.getUTCFullYear(),0,1);return Math.floor((e.getTime()-n)/f/7)+1}function _(t){let e=new Date(Date.UTC(t,0,4));return e.setUTCDate(e.getUTCDate()-((e.getUTCDay()||7)-1)),e}function b(t){let e=[],n=_(t);for(;C(n)===t;){let a=new Date(n.getTime()),s=new Date(n.getTime());s.setUTCDate(s.getUTCDate()+6),e.push({number:U(a),firstDay:a,lastDay:s}),n.setUTCDate(n.getUTCDate()+7)}return e}function w(t){let e=t.firstDay.toLocaleDateString("en-GB",{month:"short",timeZone:"UTC"}),n=t.firstDay.getUTCDate().toString().padStart(2,"0"),a=t.lastDay.getUTCDate().toString().padStart(2,"0");return`${e} ${n} \u203A ${a}`.padEnd(11)}function E(t){return`\u2502 ${w(t)} \u2014 W ${t.number.toString().padStart(2,"0")} \u2014 ${T} `+new Array(4).fill(y.padEnd(r)).join("").trimEnd()}var S=new m().name("make-calendar").description("Prints a year as ISO weeks, with blank columns to track leave by hand.").argument("[year]","the year to print",h,new Date().getUTCFullYear()).parse(),[c]=S.processedArgs,u=typeof c=="number"?c:new Date().getUTCFullYear(),l=b(u),D=`\u2502${" ".repeat(i.length-1)}${"Taken".padEnd(r*2)}${"Balance".padEnd(r*2)}Note`,k=(i+["cp","rtt","cp","rtt"].map(t=>t.padEnd(r)).join("")).trimEnd(),$=`\u2502 ${"\u2500".repeat(D.length)}`;console.log("");console.log(o.title(`Calendar ${u}.`));console.log(o.light(`${l.length} ISO weeks, Monday to Sunday.`));console.log("");console.log(o.light(D));console.log(o.light(k));console.log(o.light($));console.log(o.light("\u2502"));l.forEach((t,e)=>{console.log(o.regular(E(t)));let n=l[e+1];n!==void 0&&n.firstDay.getUTCMonth()!==t.firstDay.getUTCMonth()&&console.log(o.light("\u2502"))});console.log("");
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/make-calendar/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command, InvalidArgumentError } from 'commander'\nimport { styles } from '@design-edito/tools/agnostic/misc/logs/styles/index.js'\n\nconst MS_IN_A_DAY = 86_400_000\nconst DAY_SLOTS = '_ _ _ _ _ + _ _'\nconst DAY_LABELS = 'm t w t f + s s'\nconst BLANK_FIELD = '___'\nconst FIELD_WIDTH = 7\nconst ROW_LEAD = `\u2502 ${'date'.padEnd(11)} \u2014 week \u2014 ${DAY_LABELS} `\n\ntype Week = {\n number: number\n firstDay: Date\n lastDay: Date\n}\n\nfunction toYear (raw: string): number {\n const parsed = Number.parseInt(raw, 10)\n if (Number.isNaN(parsed) || parsed < 1 || parsed > 9999) throw new InvalidArgumentError('Expected a year.')\n return parsed\n}\n\n// A week belongs to the year its Thursday falls in \u2014 that is the whole of the ISO rule,\n// and what makes weeks 1 and 53 straddle January.\nfunction toThursday (date: Date): Date {\n const thursday = new Date(date.getTime())\n thursday.setUTCDate(thursday.getUTCDate() + 4 - (thursday.getUTCDay() || 7))\n return thursday\n}\n\nfunction toIsoWeekYear (date: Date): number {\n return toThursday(date).getUTCFullYear()\n}\n\nfunction toIsoWeekNumber (date: Date): number {\n const thursday = toThursday(date)\n const firstOfThatYear = Date.UTC(thursday.getUTCFullYear(), 0, 1)\n return Math.floor((thursday.getTime() - firstOfThatYear) / MS_IN_A_DAY / 7) + 1\n}\n\nfunction toFirstMondayOfIsoYear (year: number): Date {\n // January 4 falls in ISO week 1 every year, by definition.\n const monday = new Date(Date.UTC(year, 0, 4))\n monday.setUTCDate(monday.getUTCDate() - ((monday.getUTCDay() || 7) - 1))\n return monday\n}\n\nfunction listIsoWeeks (year: number): Week[] {\n const weeks: Week[] = []\n const cursor = toFirstMondayOfIsoYear(year)\n while (toIsoWeekYear(cursor) === year) {\n const firstDay = new Date(cursor.getTime())\n const lastDay = new Date(cursor.getTime())\n lastDay.setUTCDate(lastDay.getUTCDate() + 6)\n weeks.push({ number: toIsoWeekNumber(firstDay), firstDay, lastDay })\n cursor.setUTCDate(cursor.getUTCDate() + 7)\n }\n return weeks\n}\n\n// Dates are built in UTC so that a spring-forward Sunday cannot shift a week by a day.\nfunction formatSpan (week: Week): string {\n const month = week.firstDay.toLocaleDateString('en-GB', { month: 'short', timeZone: 'UTC' })\n const first = week.firstDay.getUTCDate().toString().padStart(2, '0')\n const last = week.lastDay.getUTCDate().toString().padStart(2, '0')\n return `${month} ${first} \u203A ${last}`.padEnd(11)\n}\n\nfunction formatRow (week: Week): string {\n return `\u2502 ${formatSpan(week)} \u2014 W ${week.number.toString().padStart(2, '0')} \u2014 ${DAY_SLOTS} `\n + new Array(4).fill(BLANK_FIELD.padEnd(FIELD_WIDTH)).join('').trimEnd()\n}\n\nconst program = new Command()\n .name('make-calendar')\n .description('Prints a year as ISO weeks, with blank columns to track leave by hand.')\n .argument('[year]', 'the year to print', toYear, new Date().getUTCFullYear())\n .parse()\n\nconst [yearArgument] = program.processedArgs\nconst year = typeof yearArgument === 'number' ? yearArgument : new Date().getUTCFullYear()\nconst weeks = listIsoWeeks(year)\n\nconst groupsHeader = `\u2502${' '.repeat(ROW_LEAD.length - 1)}`\n + `${'Taken'.padEnd(FIELD_WIDTH * 2)}${'Balance'.padEnd(FIELD_WIDTH * 2)}Note`\nconst fieldsHeader = (ROW_LEAD + ['cp', 'rtt', 'cp', 'rtt'].map(label => label.padEnd(FIELD_WIDTH)).join('')).trimEnd()\nconst rule = `\u2502 ${'\u2500'.repeat(groupsHeader.length)}`\n\nconsole.log('')\nconsole.log(styles.title(`Calendar ${year}.`))\nconsole.log(styles.light(`${weeks.length} ISO weeks, Monday to Sunday.`))\nconsole.log('')\nconsole.log(styles.light(groupsHeader))\nconsole.log(styles.light(fieldsHeader))\nconsole.log(styles.light(rule))\nconsole.log(styles.light('\u2502'))\n\nweeks.forEach((week, index) => {\n console.log(styles.regular(formatRow(week)))\n const nextWeek = weeks[index + 1]\n if (nextWeek === undefined) return\n if (nextWeek.firstDay.getUTCMonth() !== week.firstDay.getUTCMonth()) console.log(styles.light('\u2502'))\n})\n\nconsole.log('')\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,WAAAA,EAAS,wBAAAC,MAA4B,YAC9C,OAAS,UAAAC,MAAc,yDAEvB,IAAMC,EAAc,MACdC,EAAY,kBACZC,EAAa,kBACbC,EAAc,MACdC,EAAc,EACdC,EAAW,UAAK,OAAO,OAAO,EAAE,CAAC,2BAAiBH,CAAU,KAQlE,SAASI,EAAQC,EAAqB,CACpC,IAAMC,EAAS,OAAO,SAASD,EAAK,EAAE,EACtC,GAAI,OAAO,MAAMC,CAAM,GAAKA,EAAS,GAAKA,EAAS,KAAM,MAAM,IAAIV,EAAqB,kBAAkB,EAC1G,OAAOU,CACT,CAIA,SAASC,EAAYC,EAAkB,CACrC,IAAMC,EAAW,IAAI,KAAKD,EAAK,QAAQ,CAAC,EACxC,OAAAC,EAAS,WAAWA,EAAS,WAAW,EAAI,GAAKA,EAAS,UAAU,GAAK,EAAE,EACpEA,CACT,CAEA,SAASC,EAAeF,EAAoB,CAC1C,OAAOD,EAAWC,CAAI,EAAE,eAAe,CACzC,CAEA,SAASG,EAAiBH,EAAoB,CAC5C,IAAMC,EAAWF,EAAWC,CAAI,EAC1BI,EAAkB,KAAK,IAAIH,EAAS,eAAe,EAAG,EAAG,CAAC,EAChE,OAAO,KAAK,OAAOA,EAAS,QAAQ,EAAIG,GAAmBd,EAAc,CAAC,EAAI,CAChF,CAEA,SAASe,EAAwBC,EAAoB,CAEnD,IAAMC,EAAS,IAAI,KAAK,KAAK,IAAID,EAAM,EAAG,CAAC,CAAC,EAC5C,OAAAC,EAAO,WAAWA,EAAO,WAAW,IAAMA,EAAO,UAAU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eekNumber", "firstOfThatYear", "toFirstMondayOfIsoYear", "year", "monday", "listIsoWeeks", "weeks", "cursor", "firstDay", "lastDay", "formatSpan", "week", "month", "first", "last", "formatRow", "program", "yearArgument", "groupsHeader", "fieldsHeader", "label", "rule", "index", "nextWeek"]
|
|
7
|
+
}
|
package/mxfb/assets/list.txt
CHANGED
package/mxfb/assets/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.5
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mxfb/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Maxime Fabas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -12,21 +12,24 @@
|
|
|
12
12
|
"main": "index.js",
|
|
13
13
|
"module": "index.js",
|
|
14
14
|
"bin": {
|
|
15
|
+
"health-check": "./health-check/index.js",
|
|
15
16
|
"mxfb": "./mxfb/index.js",
|
|
16
|
-
"
|
|
17
|
+
"make-calendar": "./make-calendar/index.js",
|
|
18
|
+
"scrape-tumblr": "./scrape-tumblr/index.js",
|
|
19
|
+
"term-glossary": "./term-glossary/index.js"
|
|
17
20
|
},
|
|
18
21
|
"dependencies": {
|
|
19
|
-
"@design-edito/tools": "^0.
|
|
20
|
-
"@inquirer/prompts": "^8.
|
|
21
|
-
"@mxfb/tools": "^1.
|
|
22
|
-
"commander": "^
|
|
22
|
+
"@design-edito/tools": "^0.8.0",
|
|
23
|
+
"@inquirer/prompts": "^8.8.1",
|
|
24
|
+
"@mxfb/tools": "^1.1.1",
|
|
25
|
+
"commander": "^15.1.0"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
|
-
"@types/node": "^
|
|
26
|
-
"@types/semver": "^7.
|
|
27
|
-
"esbuild": "^0.
|
|
28
|
-
"semver": "^7.
|
|
29
|
-
"simple-git": "^
|
|
28
|
+
"@types/node": "^26.6.11",
|
|
29
|
+
"@types/semver": "^7.8.0",
|
|
30
|
+
"esbuild": "^0.28.2",
|
|
31
|
+
"semver": "^7.8.6",
|
|
32
|
+
"simple-git": "^4.1.0",
|
|
30
33
|
"typescript": "^5.9.3"
|
|
31
34
|
}
|
|
32
35
|
}
|
package/scrape-tumblr/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{mkdir as
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import{mkdir as F}from"node:fs/promises";import b from"node:os";import y from"node:path";import $ from"node:process";import{Command as S,InvalidArgumentError as q}from"commander";import{confirm as x,input as v,select as I}from"@inquirer/prompts";import{styles as t}from"@design-edito/tools/agnostic/misc/logs/styles/index.js";import{crawlBlog as P,readArchivePosts as C}from"@mxfb/tools/node/scrapers/@tumblr/index.js";var N=500,h=10;function f(e){let o=Number.parseInt(e,10);if(Number.isNaN(o)||o<=0)throw new q("Expected a positive number.");return o}function c(e,o){return`${e} ${o}${e===1?"":"s"}`}function D(e){let o=e.trim();if(o==="")return"A blog URL is needed.";try{new URL(o)}catch{return"Expected a full URL, protocol included."}return null}function B(e){try{return new URL(e).hostname}catch{return"tumblr-archive"}}async function d(e){let o=e.replace(/^~(?=\/|$)/,b.homedir()),r=y.resolve(o);return await F(r,{recursive:!0}),r}async function O(e,o){if(e!==void 0)return await d(e);let r=y.join($.cwd(),B(o)),n=await I({message:"Where should the archive be written?",choices:[{name:"Here",value:"here",description:r},{name:"A temporary directory",value:"temp",description:`under ${b.tmpdir()}, cleared on reboot`},{name:"Somewhere else",value:"manual",description:"type a path"}]});if(n==="temp")return;if(n==="here")return await d(r);let a=await v({message:"Which directory?",default:r,validate:u=>u.trim()===""?"A path is needed.":!0});return await d(a.trim())}function T(e){let{url:o,kind:r,postCount:n,newPostCount:a,error:u,scannedPageCount:R,foundPageCount:L}=e,p=`${R} scanned, over ${L} found`;if(u!==null){console.log(t.warning(`${"failed".padEnd(10)}${o}`)),console.log(t.light(` ${u} \xB7 ${p}`));return}let k=a===n?c(n,"post"):`${c(n,"post")}, ${a} new`;console.log(`${t.light((r??"unknown").padEnd(10))}${o}`),console.log(t.light(` ${k} \xB7 ${p}`))}function _(e){let o=[...e].sort((n,a)=>a.failureCount-n.failureCount);console.log(t.info(`
|
|
3
|
+
Failed`)),o.slice(0,h).forEach(n=>{let a=n.failureCount===1?"":`, ${n.failureCount} times`;console.log(t.warning(n.url)),console.log(t.light(` ${n.error}${a}`))});let r=o.length-h;r>0&&console.log(t.light(`... and ${r} more`))}var A=new S().name("scrape-tumblr").description("Archives a Tumblr blog: every page it serves, every post it holds.").argument("[blog-url]","any URL on the blog \u2014 only its origin is used").option("-d, --data-dir <path>","where to write, and where to resume from").option("-l, --limit <count>","stop after this many pages",f).option("--delay <ms>","wait between two requests",f,N).option("-r, --resume","pick up where a previous crawl of the same directory stopped",!1).option("--no-sitemap","walk the listings instead of reading the sitemap").option("-q, --quiet","report only the result",!1).parse(),s=A.opts(),[M]=A.args,E=M??await v({message:"Which blog should be scraped? (e.g. https://myblog.tumblr.com)",validate:e=>D(e)??!0}),w=D(E);w!==null&&(console.log(t.error(w)),$.exit(1));var l=E.trim(),W=await O(s.dataDir,l);console.log("");console.log(t.title(`Scraping ${l}...`));console.log(t.light("> starting a headless browser, the blog host refuses plain requests"));console.log("");var U={limit:s.limit,delayMs:s.delay,useSitemap:s.sitemap,onPageCrawled:s.quiet?void 0:T},i=await P(l,{...U,dataDirPath:W,resume:s.resume}),g=await C(i.dataDirPath),m=!0;for(;m;){let e=g.filter(r=>r.publishedOn!==null).length,o=g.filter(r=>r.rawHtml!==null).length;if(console.log(""),console.log(t.title("Scrape complete.")),console.log(t.important(i.blog?.title??l)),console.log(t.success(`${c(i.pageCount,"page")} read, ${c(g.length,"post")} in the archive`)),console.log(t.light(`${e} with a date, ${o} with their markup kept`)),i.failures.length===0)break;console.log(t.warning(`${c(i.failures.length,"page")} could not be read`)),_(i.failures),console.log(""),m=await x({message:"Try the failed pages again?",default:!0}),m&&(console.log(""),console.log(t.title("Retrying the failed pages...")),console.log(""),i=await P(l,{...U,dataDirPath:i.dataDirPath,resume:!0,retryFailures:!0}),g=await C(i.dataDirPath))}console.log(t.info(`
|
|
4
|
+
Archive`));console.log(t.light(i.dataDirPath));console.log(t.info(`
|
|
5
|
+
Resume`));console.log(t.light(`> scrape-tumblr ${l} --data-dir ${i.dataDirPath} --resume`));console.log("");
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/scrape-tumblr/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { mkdir } from 'node:fs/promises'\nimport os from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { Command, InvalidArgumentError } from 'commander'\nimport { input, select } from '@inquirer/prompts'\nimport { styles } from '@design-edito/tools/agnostic/misc/logs/styles/index.js'\nimport { crawlBlog, readArchivePosts } from '@mxfb/tools/node/scrapers/@tumblr/index.js'\nimport type { CrawledPageReport } from '@mxfb/tools/node/scrapers/@tumblr/types.js'\n\nconst DEFAULT_DELAY_MS = 500\n\ntype CommandOptions = {\n dataDir?: string\n limit?: number\n delay: number\n resume: boolean\n sitemap: boolean\n quiet: boolean\n}\n\nfunction toPositiveInteger (raw: string): number {\n const parsed = Number.parseInt(raw, 10)\n if (Number.isNaN(parsed) || parsed <= 0) throw new InvalidArgumentError('Expected a positive number.')\n return parsed\n}\n\nfunction pluralize (count: number, singular: string): string {\n return `${count} ${singular}${count === 1 ? '' : 's'}`\n}\n\nfunction toBlogUrlError (raw: string): string | null {\n const trimmed = raw.trim()\n if (trimmed === '') return 'A blog URL is needed.'\n try { new URL(trimmed) }\n catch { return 'Expected a full URL, protocol included.' }\n return null\n}\n\nfunction toArchiveDirName (rawUrl: string): string {\n try { return new URL(rawUrl).hostname }\n catch { return 'tumblr-archive' }\n}\n\n// inquirer hands back what was typed, so a leading ~ never went through a shell.\nasync function ensureDirectory (rawPath: string): Promise<string> {\n const expanded = rawPath.replace(/^~(?=\\/|$)/, os.homedir())\n const dirPath = path.resolve(expanded)\n await mkdir(dirPath, { recursive: true })\n return dirPath\n}\n\nasync function resolveDataDirPath (\n optionPath: string | undefined,\n blogUrl: string\n): Promise<string | undefined> {\n if (optionPath !== undefined) return await ensureDirectory(optionPath)\n const herePath = path.join(process.cwd(), toArchiveDirName(blogUrl))\n const choice = await select({\n message: 'Where should the archive be written?',\n choices: [\n { name: 'Here', value: 'here', description: herePath },\n { name: 'A temporary directory', value: 'temp', description: `under ${os.tmpdir()}, cleared on reboot` },\n { name: 'Somewhere else', value: 'manual', description: 'type a path' }\n ]\n })\n if (choice === 'temp') return undefined\n if (choice === 'here') return await ensureDirectory(herePath)\n const typedPath = await input({\n message: 'Which directory?',\n default: herePath,\n validate: value => value.trim() === '' ? 'A path is needed.' : true\n })\n return await ensureDirectory(typedPath.trim())\n}\n\nfunction reportPage (report: CrawledPageReport): void {\n const { url, kind, postCount, newPostCount, error } = report\n if (error !== null) {\n console.log(styles.warning(`${'failed'.padEnd(10)}${url}`))\n console.log(styles.light(` ${error}`))\n return\n }\n const posts = newPostCount === postCount\n ? pluralize(postCount, 'post')\n : `${pluralize(postCount, 'post')}, ${newPostCount} new`\n console.log(`${styles.light((kind ?? 'unknown').padEnd(10))}${url}`)\n console.log(styles.light(` ${posts}`))\n}\n\nconst program = new Command()\n .name('scrape-tumblr')\n .description('Archives a Tumblr blog: every page it serves, every post it holds.')\n .argument('[blog-url]', 'any URL on the blog \u2014 only its origin is used')\n .option('-d, --data-dir <path>', 'where to write, and where to resume from')\n .option('-l, --limit <count>', 'stop after this many pages', toPositiveInteger)\n .option('--delay <ms>', 'wait between two requests', toPositiveInteger, DEFAULT_DELAY_MS)\n .option('-r, --resume', 'pick up where a previous crawl of the same directory stopped', false)\n .option('--no-sitemap', 'walk the listings instead of reading the sitemap')\n .option('-q, --quiet', 'report only the result', false)\n .parse()\n\nconst options = program.opts<CommandOptions>()\nconst [blogUrlArgument] = program.args\n\nconst rawBlogUrl = blogUrlArgument ?? await input({\n message: 'Which blog should be scraped? (e.g. https://myblog.tumblr.com)',\n validate: value => toBlogUrlError(value) ?? true\n})\n\nconst blogUrlError = toBlogUrlError(rawBlogUrl)\nif (blogUrlError !== null) {\n console.log(styles.error(blogUrlError))\n process.exit(1)\n}\n\nconst blogUrl = rawBlogUrl.trim()\n\nconst dataDirPath = await resolveDataDirPath(options.dataDir, blogUrl)\n\nconsole.log('')\nconsole.log(styles.title(`Scraping ${blogUrl}...`))\n// Chrome has to clear the blog host's challenge before anything is readable, which takes a\n// few seconds on the first page and nothing on the ones after.\nconsole.log(styles.light('> starting a headless browser, the blog host refuses plain requests'))\nconsole.log('')\n\nconst
|
|
5
|
-
"mappings": "AAAA,OAAS,SAAAA,MAAa,mBACtB,OAAOC,MAAQ,UACf,OAAOC,MAAU,YACjB,OAAOC,MAAa,eACpB,OAAS,WAAAC,EAAS,wBAAAC,MAA4B,YAC9C,OAAS,SAAAC,EAAO,UAAAC,MAAc,
|
|
6
|
-
"names": ["mkdir", "os", "path", "process", "Command", "InvalidArgumentError", "input", "select", "styles", "crawlBlog", "readArchivePosts", "DEFAULT_DELAY_MS", "toPositiveInteger", "raw", "parsed", "pluralize", "count", "singular", "toBlogUrlError", "trimmed", "toArchiveDirName", "rawUrl", "ensureDirectory", "rawPath", "expanded", "dirPath", "resolveDataDirPath", "optionPath", "blogUrl", "herePath", "choice", "typedPath", "value", "reportPage", "report", "url", "kind", "postCount", "newPostCount", "error", "posts", "program", "options", "blogUrlArgument", "rawBlogUrl", "blogUrlError", "dataDirPath", "result", "dated", "post", "withBody"]
|
|
4
|
+
"sourcesContent": ["import { mkdir } from 'node:fs/promises'\nimport os from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { Command, InvalidArgumentError } from 'commander'\nimport { confirm, input, select } from '@inquirer/prompts'\nimport { styles } from '@design-edito/tools/agnostic/misc/logs/styles/index.js'\nimport { crawlBlog, readArchivePosts } from '@mxfb/tools/node/scrapers/@tumblr/index.js'\nimport type { CrawledPageReport, CrawlFailure } from '@mxfb/tools/node/scrapers/@tumblr/types.js'\n\nconst DEFAULT_DELAY_MS = 500\nconst MAX_LISTED_FAILURES = 10\n\ntype CommandOptions = {\n dataDir?: string\n limit?: number\n delay: number\n resume: boolean\n sitemap: boolean\n quiet: boolean\n}\n\nfunction toPositiveInteger (raw: string): number {\n const parsed = Number.parseInt(raw, 10)\n if (Number.isNaN(parsed) || parsed <= 0) throw new InvalidArgumentError('Expected a positive number.')\n return parsed\n}\n\nfunction pluralize (count: number, singular: string): string {\n return `${count} ${singular}${count === 1 ? '' : 's'}`\n}\n\nfunction toBlogUrlError (raw: string): string | null {\n const trimmed = raw.trim()\n if (trimmed === '') return 'A blog URL is needed.'\n try { new URL(trimmed) }\n catch { return 'Expected a full URL, protocol included.' }\n return null\n}\n\nfunction toArchiveDirName (rawUrl: string): string {\n try { return new URL(rawUrl).hostname }\n catch { return 'tumblr-archive' }\n}\n\n// inquirer hands back what was typed, so a leading ~ never went through a shell.\nasync function ensureDirectory (rawPath: string): Promise<string> {\n const expanded = rawPath.replace(/^~(?=\\/|$)/, os.homedir())\n const dirPath = path.resolve(expanded)\n await mkdir(dirPath, { recursive: true })\n return dirPath\n}\n\nasync function resolveDataDirPath (\n optionPath: string | undefined,\n blogUrl: string\n): Promise<string | undefined> {\n if (optionPath !== undefined) return await ensureDirectory(optionPath)\n const herePath = path.join(process.cwd(), toArchiveDirName(blogUrl))\n const choice = await select({\n message: 'Where should the archive be written?',\n choices: [\n { name: 'Here', value: 'here', description: herePath },\n { name: 'A temporary directory', value: 'temp', description: `under ${os.tmpdir()}, cleared on reboot` },\n { name: 'Somewhere else', value: 'manual', description: 'type a path' }\n ]\n })\n if (choice === 'temp') return undefined\n if (choice === 'here') return await ensureDirectory(herePath)\n const typedPath = await input({\n message: 'Which directory?',\n default: herePath,\n validate: value => value.trim() === '' ? 'A path is needed.' : true\n })\n return await ensureDirectory(typedPath.trim())\n}\n\nfunction reportPage (report: CrawledPageReport): void {\n const { url, kind, postCount, newPostCount, error, scannedPageCount, foundPageCount } = report\n const progress = `${scannedPageCount} scanned, over ${foundPageCount} found`\n if (error !== null) {\n console.log(styles.warning(`${'failed'.padEnd(10)}${url}`))\n console.log(styles.light(` ${error} \u00B7 ${progress}`))\n return\n }\n const posts = newPostCount === postCount\n ? pluralize(postCount, 'post')\n : `${pluralize(postCount, 'post')}, ${newPostCount} new`\n console.log(`${styles.light((kind ?? 'unknown').padEnd(10))}${url}`)\n console.log(styles.light(` ${posts} \u00B7 ${progress}`))\n}\n\n// Most stubborn first: a page that has resisted four rounds is the one worth looking at\n// before answering the prompt.\nfunction reportFailures (failures: CrawlFailure[]): void {\n const sorted = [...failures].sort((a, b) => b.failureCount - a.failureCount)\n console.log(styles.info('\\nFailed'))\n sorted.slice(0, MAX_LISTED_FAILURES).forEach(failure => {\n const attempts = failure.failureCount === 1 ? '' : `, ${failure.failureCount} times`\n console.log(styles.warning(failure.url))\n console.log(styles.light(` ${failure.error}${attempts}`))\n })\n const hidden = sorted.length - MAX_LISTED_FAILURES\n if (hidden > 0) console.log(styles.light(`... and ${hidden} more`))\n}\n\nconst program = new Command()\n .name('scrape-tumblr')\n .description('Archives a Tumblr blog: every page it serves, every post it holds.')\n .argument('[blog-url]', 'any URL on the blog \u2014 only its origin is used')\n .option('-d, --data-dir <path>', 'where to write, and where to resume from')\n .option('-l, --limit <count>', 'stop after this many pages', toPositiveInteger)\n .option('--delay <ms>', 'wait between two requests', toPositiveInteger, DEFAULT_DELAY_MS)\n .option('-r, --resume', 'pick up where a previous crawl of the same directory stopped', false)\n .option('--no-sitemap', 'walk the listings instead of reading the sitemap')\n .option('-q, --quiet', 'report only the result', false)\n .parse()\n\nconst options = program.opts<CommandOptions>()\nconst [blogUrlArgument] = program.args\n\nconst rawBlogUrl = blogUrlArgument ?? await input({\n message: 'Which blog should be scraped? (e.g. https://myblog.tumblr.com)',\n validate: value => toBlogUrlError(value) ?? true\n})\n\nconst blogUrlError = toBlogUrlError(rawBlogUrl)\nif (blogUrlError !== null) {\n console.log(styles.error(blogUrlError))\n process.exit(1)\n}\n\nconst blogUrl = rawBlogUrl.trim()\n\nconst dataDirPath = await resolveDataDirPath(options.dataDir, blogUrl)\n\nconsole.log('')\nconsole.log(styles.title(`Scraping ${blogUrl}...`))\n// Chrome has to clear the blog host's challenge before anything is readable, which takes a\n// few seconds on the first page and nothing on the ones after.\nconsole.log(styles.light('> starting a headless browser, the blog host refuses plain requests'))\nconsole.log('')\n\nconst crawlOptions = {\n limit: options.limit,\n delayMs: options.delay,\n useSitemap: options.sitemap,\n onPageCrawled: options.quiet ? undefined : reportPage\n}\n\nlet result = await crawlBlog(blogUrl, {\n ...crawlOptions,\n dataDirPath,\n resume: options.resume\n})\nlet posts = await readArchivePosts(result.dataDirPath)\nlet retrying = true\n\nwhile (retrying) {\n const dated = posts.filter(post => post.publishedOn !== null).length\n const withBody = posts.filter(post => post.rawHtml !== null).length\n console.log('')\n console.log(styles.title('Scrape complete.'))\n console.log(styles.important(result.blog?.title ?? blogUrl))\n console.log(styles.success(`${pluralize(result.pageCount, 'page')} read, ${pluralize(posts.length, 'post')} in the archive`))\n console.log(styles.light(`${dated} with a date, ${withBody} with their markup kept`))\n if (result.failures.length === 0) break\n console.log(styles.warning(`${pluralize(result.failures.length, 'page')} could not be read`))\n reportFailures(result.failures)\n console.log('')\n retrying = await confirm({ message: 'Try the failed pages again?', default: true })\n if (!retrying) continue\n console.log('')\n console.log(styles.title('Retrying the failed pages...'))\n console.log('')\n result = await crawlBlog(blogUrl, {\n ...crawlOptions,\n dataDirPath: result.dataDirPath,\n resume: true,\n retryFailures: true\n })\n posts = await readArchivePosts(result.dataDirPath)\n}\n\nconsole.log(styles.info('\\nArchive'))\nconsole.log(styles.light(result.dataDirPath))\nconsole.log(styles.info('\\nResume'))\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AAQ,CAAE,QAAS,8BAA+B,QAAS,EAAK,CAAC,EAC7EwD,IACL,QAAQ,IAAI,EAAE,EACd,QAAQ,IAAIrD,EAAO,MAAM,8BAA8B,CAAC,EACxD,QAAQ,IAAI,EAAE,EACdoD,EAAS,MAAMnD,EAAUoB,EAAS,CAChC,GAAG8B,EACH,YAAaC,EAAO,YACpB,OAAQ,GACR,cAAe,EACjB,CAAC,EACDhB,EAAQ,MAAMlC,EAAiBkD,EAAO,WAAW,EACnD,CAEA,QAAQ,IAAIpD,EAAO,KAAK;AAAA,QAAW,CAAC,EACpC,QAAQ,IAAIA,EAAO,MAAMoD,EAAO,WAAW,CAAC,EAC5C,QAAQ,IAAIpD,EAAO,KAAK;AAAA,OAAU,CAAC,EACnC,QAAQ,IAAIA,EAAO,MAAM,mBAAmBqB,CAAO,eAAe+B,EAAO,WAAW,WAAW,CAAC,EAChG,QAAQ,IAAI,EAAE",
|
|
6
|
+
"names": ["mkdir", "os", "path", "process", "Command", "InvalidArgumentError", "confirm", "input", "select", "styles", "crawlBlog", "readArchivePosts", "DEFAULT_DELAY_MS", "MAX_LISTED_FAILURES", "toPositiveInteger", "raw", "parsed", "pluralize", "count", "singular", "toBlogUrlError", "trimmed", "toArchiveDirName", "rawUrl", "ensureDirectory", "rawPath", "expanded", "dirPath", "resolveDataDirPath", "optionPath", "blogUrl", "herePath", "choice", "typedPath", "value", "reportPage", "report", "url", "kind", "postCount", "newPostCount", "error", "scannedPageCount", "foundPageCount", "progress", "posts", "reportFailures", "failures", "sorted", "a", "b", "failure", "attempts", "hidden", "program", "options", "blogUrlArgument", "rawBlogUrl", "blogUrlError", "dataDirPath", "crawlOptions", "result", "retrying", "dated", "post", "withBody"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{Command as s}from"commander";import{styles as a}from"@design-edito/tools/agnostic/misc/logs/styles/index.js";var m=[{label:"Keeping a fork up to date",recipes:[{command:"git fetch upstream",what:"bring the upstream refs up to date"},{command:"git status",what:"how far apart from upstream/master this is"},{command:"git log HEAD..upstream/master",what:"the commits upstream has and this one does not"},{command:"git merge upstream/master",what:"take upstream/master into the local master"},{command:"git push origin master",what:"send the merge to the fork"}]},{label:"Processes and ports",recipes:[{command:"lsof -i :<port>",what:"the processes holding <port>"},{command:"ps aux | grep <name>",what:"the running processes whose name matches <name>"}]}];new s().name("term-glossary").description("Terminal recipes worth not looking up twice.").parse();m.forEach(t=>{let o=Math.max(...t.recipes.map(e=>e.command.length));console.log(""),console.log(a.info(t.label)),t.recipes.forEach(e=>{console.log(`${a.important(e.command.padEnd(o))} ${a.light(e.what)}`)})});console.log("");
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/term-glossary/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander'\nimport { styles } from '@design-edito/tools/agnostic/misc/logs/styles/index.js'\n\ntype Recipe = {\n command: string\n what: string\n}\n\ntype Section = {\n label: string\n recipes: Recipe[]\n}\n\nconst SECTIONS: Section[] = [\n {\n label: 'Keeping a fork up to date',\n recipes: [\n { command: 'git fetch upstream', what: 'bring the upstream refs up to date' },\n { command: 'git status', what: 'how far apart from upstream/master this is' },\n { command: 'git log HEAD..upstream/master', what: 'the commits upstream has and this one does not' },\n { command: 'git merge upstream/master', what: 'take upstream/master into the local master' },\n { command: 'git push origin master', what: 'send the merge to the fork' }\n ]\n },\n {\n label: 'Processes and ports',\n recipes: [\n { command: 'lsof -i :<port>', what: 'the processes holding <port>' },\n { command: 'ps aux | grep <name>', what: 'the running processes whose name matches <name>' }\n ]\n }\n]\n\nnew Command()\n .name('term-glossary')\n .description('Terminal recipes worth not looking up twice.')\n .parse()\n\nSECTIONS.forEach(section => {\n const width = Math.max(...section.recipes.map(recipe => recipe.command.length))\n console.log('')\n console.log(styles.info(section.label))\n section.recipes.forEach(recipe => {\n console.log(`${styles.important(recipe.command.padEnd(width))} ${styles.light(recipe.what)}`)\n })\n})\n\nconsole.log('')\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,WAAAA,MAAe,YACxB,OAAS,UAAAC,MAAc,yDAYvB,IAAMC,EAAsB,CAC1B,CACE,MAAO,4BACP,QAAS,CACP,CAAE,QAAS,qBAAsB,KAAM,oCAAqC,EAC5E,CAAE,QAAS,aAAc,KAAM,4CAA6C,EAC5E,CAAE,QAAS,gCAAiC,KAAM,gDAAiD,EACnG,CAAE,QAAS,4BAA6B,KAAM,4CAA6C,EAC3F,CAAE,QAAS,yBAA0B,KAAM,4BAA6B,CAC1E,CACF,EACA,CACE,MAAO,sBACP,QAAS,CACP,CAAE,QAAS,kBAAmB,KAAM,8BAA+B,EACnE,CAAE,QAAS,uBAAwB,KAAM,iDAAkD,CAC7F,CACF,CACF,EAEA,IAAIF,EAAQ,EACT,KAAK,eAAe,EACpB,YAAY,8CAA8C,EAC1D,MAAM,EAETE,EAAS,QAAQC,GAAW,CAC1B,IAAMC,EAAQ,KAAK,IAAI,GAAGD,EAAQ,QAAQ,IAAIE,GAAUA,EAAO,QAAQ,MAAM,CAAC,EAC9E,QAAQ,IAAI,EAAE,EACd,QAAQ,IAAIJ,EAAO,KAAKE,EAAQ,KAAK,CAAC,EACtCA,EAAQ,QAAQ,QAAQE,GAAU,CAChC,QAAQ,IAAI,GAAGJ,EAAO,UAAUI,EAAO,QAAQ,OAAOD,CAAK,CAAC,CAAC,MAAMH,EAAO,MAAMI,EAAO,IAAI,CAAC,EAAE,CAChG,CAAC,CACH,CAAC,EAED,QAAQ,IAAI,EAAE",
|
|
6
|
+
"names": ["Command", "styles", "SECTIONS", "section", "width", "recipe"]
|
|
7
|
+
}
|