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AAc;IACjD,+BAAS,GAAG,CAAC;IACb,0CAAe,SAAS,KAAK,CAAC;AAChC;AAEO,SAAS;IACd,+BAAS,GAAG,CAAC;IACb,OAAO,cAAe,KAAK,CAAC;AAC9B;AAEO,eAAe;IACpB,MAAM,gBAAgB,CAAA,GAAA,YAAI,EAAE,CAAA,GAAA,cAAM,EAAE;IACpC,MAAM,QAAE,IAAI,EAAE,GAAG;IAEjB,IAAI,OAAO,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM;QACnC;QACA;IACF;IAEA,MAAM,UAAE,MAAM,EAAE,GAAG;IAEnB,IAAI,CAAC,QAAQ;QACX;QACA;IACF;IAEA,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,IAAI;IAEnC,IAAI,SAAS,QAAQ,CAAC,YAAY,SAAS,QAAQ,CAAC,YAClD,MAAM;IAGR,+BAAS,GAAG,CAAC;IACb,YAAa;AACf;AAEA,MAAM","sources":["src/index.ts","package.json","src/convert.ts","src/prepare.ts"],"sourcesContent":["#!/usr/bin/env -S node --no-warnings\nimport { format } from 'date-fns'\nimport * as fs from 'node:fs/promises'\nimport * as os from 'node:os'\nimport * as process from 'node:process'\nimport yargs from 'yargs'\nimport { hideBin } from 'yargs/helpers'\nimport * as packageJson from '../package.json'\nimport { convertAll } from './convert'\n\nprocess.stdin.resume()\nprocess.stdin.setEncoding('utf8')\n\nconst DEBUG_LOG = process.env.DEBUG ?? false\n\nconst _console = DEBUG_LOG ? console : { log: () => {}, error: () => {} }\n\nexport function writeConverted(toConvert: string[]): void {\n  const converted = convertAll(toConvert)\n  const trimmed = converted.trim()\n  process.stdout.write(trimmed)\n  _console.log('Converted output written.')\n}\n\nexport function runOnStdIn() {\n  _console.log('Reading from stdin...')\n  let remainder = ''\n  process.stdin.on('data', function (chunk) {\n    _console.log('Data chunk received...')\n    const lines = chunk.toString().split('\\n')\n    lines.unshift(remainder + lines.shift())\n    const popped = lines.pop()\n    remainder = popped ?? ''\n    const toConvert = []\n    let skip = false\n    let index = 0\n    for (const line of lines) {\n      if (index === 0 && line.startsWith('---')) {\n        skip = true\n      }\n\n      if (!skip) {\n        toConvert.push(line)\n      } else if (skip && line.startsWith('---')) {\n        skip = false\n      }\n\n      index++\n    }\n\n    _console.log('Writing converted lines...')\n    writeConverted(toConvert)\n  })\n}\n\nexport async function runOnToday() {\n  const dateFormat = 'yyyy-MM-dd EEE'\n  const directory: string =\n    process.env.DAILY_STANDUP_DIRECTORY ?? `${os.homedir()}/notes/work/log`\n  const filename: string = format(new Date(), dateFormat)\n  const filenameFull = `${directory}/done ${filename}.md`\n  _console.log(`Reading file: ${filenameFull}`)\n  const contents = await fs.readFile(filenameFull, 'utf8')\n  _console.log('File read successfully.')\n  writeConverted(contents.split('\\n'))\n}\n\nexport function version() {\n  _console.log('Writing version...')\n  return process.stdout.write(packageJson.version)\n}\n\nexport async function main() {\n  const fullArguments = yargs(hideBin(process.argv))\n  const { argv } = fullArguments\n\n  if (Object.keys(argv).includes('v')) {\n    version()\n    return\n  }\n\n  const { parsed } = fullArguments\n\n  if (!parsed) {\n    runOnStdIn()\n    return\n  }\n\n  const { _: argument } = parsed.argv\n\n  if (argument.includes('today') || argument.includes('standup')) {\n    await runOnToday()\n  }\n\n  _console.log('Exiting...')\n  process.exit(0)\n}\n\nawait main()\n","{\n  \"name\": \"md2slack\",\n  \"version\": \"1.1.5\",\n  \"description\": \"Command line tool that takes markdown from stdin and writes Slack markdown to stdout\",\n  \"source\": \"src/index.ts\",\n  \"main\": \"dist/index.mjs\",\n  \"scripts\": {\n    \"test\": \"jest\",\n    \"prepare\": \"husky install\",\n    \"build\": \"parcel build\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/rbutera/markdown-to-slack.git\"\n  },\n  \"keywords\": [\n    \"markdown\",\n    \"slack\",\n    \"clt\",\n    \"cli\"\n  ],\n  \"author\": \"rbutera\",\n  \"license\": \"SEE LICENSE IN LICENSE\",\n  \"bugs\": {\n    \"url\": \"https://github.com/rbutera/markdown-to-slack/issues\"\n  },\n  \"homepage\": \"https://github.com/rbutera/markdown-to-slack#readme\",\n  \"engines\": {\n    \"npm\": \">=7.0.0\",\n    \"node\": \">=18.7.0\"\n  },\n  \"devDependencies\": {\n    \"@tsconfig/node16\": \"^1.0.2\",\n    \"@types/jest\": \"^29.4.2\",\n    \"@types/node\": \"^18.15.3\",\n    \"@types/yargs\": \"^17.0.32\",\n    \"@typescript-eslint/eslint-plugin\": \"^5.27.1\",\n    \"@typescript-eslint/parser\": \"^5.27.1\",\n    \"cross-env\": \"^7.0.3\",\n    \"eslint\": \"^8.17.0\",\n    \"eslint-config-prettier\": \"^8.5.0\",\n    \"eslint-config-xo\": \"^0.43.1\",\n    \"eslint-config-xo-typescript\": \"^0.56.0\",\n    \"eslint-plugin-functional\": \"^5.0.6\",\n    \"eslint-plugin-import\": \"^2.26.0\",\n    \"eslint-plugin-jest\": \"^27.2.1\",\n    \"eslint-plugin-jest-formatting\": \"^3.1.0\",\n    \"eslint-plugin-node\": \"^11.1.0\",\n    \"eslint-plugin-prettier\": \"^4.0.0\",\n    \"eslint-plugin-unicorn\": \"^46.0.0\",\n    \"eslint-plugin-you-dont-need-lodash-underscore\": \"^6.12.0\",\n    \"husky\": \"^8.0.1\",\n    \"jest\": \"^29.5.0\",\n    \"jest-extended\": \"^3.2.4\",\n    \"lint-staged\": \"^13.0.1\",\n    \"npm-run-all\": \"^4.1.5\",\n    \"parcel\": \"^2.7.0\",\n    \"prettier\": \"^2.6.2\",\n    \"remark\": \"^14.0.2\",\n    \"rimraf\": \"^4.4.0\",\n    \"ts-jest\": \"^29.0.5\",\n    \"ts-node\": \"^10.9.1\",\n    \"tsconfig-paths\": \"^4.0.0\",\n    \"typescript\": \"^4.7.4\"\n  },\n  \"lint-staged\": {\n    \"*.{js,ts}\": [\n      \"eslint --cache --fix --quiet\",\n      \"jest --runInBand --findRelatedTests --passWithNoTests\"\n    ],\n    \"*.{js,ts,css,md}\": \"prettier --write\"\n  },\n  \"bin\": \"./dist/index.mjs\",\n  \"dependencies\": {\n    \"date-fns\": \"^2.29.2\",\n    \"slackify-markdown\": \"^4.4.0\",\n    \"yargs\": \"^17.5.1\"\n  }\n}\n","import slackify from 'slackify-markdown'\nimport { prepare } from './prepare'\n\nfunction replace(input: string): string {\n  return input.replace(/- \\[x] /g, '• ✔️  ').replace(/- \\[ ] /, '• ')\n  // .replace(/\\[([\\s\\w]+)](\\S+)/g, '$1: $2')\n}\n\nfunction format(input: string): string {\n  return input\n    .replace(/<(\\/)?cite>/g, '_')\n    .replace(/<([^|]+)\\|(.+)>/g, '$2: $1')\n    .replace(/\\[\\!quote\\]/g, ' ')\n    .trimEnd()\n}\n\n/*\n * Converts a markdown string to slack markdown\n */\nfunction convert(input: string): string {\n  if (!!input && input.length > 0) {\n    const prepared = replace(input)\n    const slackified = slackify(prepared)\n    return format(slackified)\n  } else {\n    return input\n  }\n}\n\nexport function convertAll(input: string[]): string {\n  // split into sections\n  const toConvert = prepare(input.join('\\n'))\n  const paragraphs = toConvert.split(/\\n(# [\\S ]*)/g)\n  const trimmed = paragraphs.map((text) => {\n    return text.startsWith('\\n\\n') ? text.slice(2) : text\n  })\n  const convertedParagraphs = trimmed.map((text) => convert(text))\n  const result = convertedParagraphs.join('\\n\\n')\n\n  return result\n}\n\nexport default convert\n","/*\n * takes a markdown string as input and removes YAML frontmatter, if any\n */\nexport function prepare(input: string) {\n  const lines = input.split('\\n')\n  const [firstLine, ...rest] = lines\n\n  if (!firstLine.startsWith('---')) {\n    return input\n  }\n\n  let end = false\n\n  const body = []\n\n  for (const line of rest) {\n    const ending = line.startsWith('---')\n\n    if (end) {\n      body.push(line)\n    } else if (ending) {\n      end = true\n    }\n  }\n\n  return body.join('\\n')\n}\n"],"names":[],"version":3,"file":"index.mjs.map","sourceRoot":"../"}