Skip to content

Commit

Permalink
Merge pull request #18 from brionmario/restructure-turbo
Browse files Browse the repository at this point in the history
chore: restructure repo with turbo
  • Loading branch information
brionmario authored Sep 10, 2023
2 parents c23e43b + 1c4eb09 commit 649049c
Show file tree
Hide file tree
Showing 46 changed files with 558 additions and 161 deletions.
32 changes: 32 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* MIT License
*
* Copyright (c) 2023, Brion Mario
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

module.exports = {
env: {
es6: true,
node: true,
},
extends: ['turbo', 'plugin:@brionmario/internal', 'plugin:@brionmario/prettier'],
plugins: ['@brionmario'],
};
37 changes: 37 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Purpose

<!-- Briefly describe the purpose and scope of this pull request. -->

## Changes Made

<!-- Describe the changes you have made in this pull request. Provide context for reviewers to understand the changes. -->

## Related Issues

<!-- If this pull request is related to any GitHub issues mention them here. Add `N/A` if there's nothing to mention. -->
- Fixes `<issue_url>`

## Related Pull Requests

<!-- If this pull request is related to any other pull requests, mention them here. Add `N/A` if there's nothing to mention. -->

- `<pull_request_url_1>`
- `<pull_request_url_2>`

## Screenshots (if applicable)

<!-- If your changes involve visual modifications, provide screenshots or GIFs to showcase the changes. Add `N/A` if there's nothing to mention. -->

## Checklist

<!-- Mark the items that are applicable by replacing [ ] with [x]. -->

- [ ] I have tested these changes thoroughly.
- [ ] I have updated the documentation to reflect these changes.
- [ ] I have followed the coding style guidelines of the project.
- [ ] I have added suitable comments to the code, especially in complex areas.
- [ ] I have reviewed my own code to ensure there are no obvious errors.

## Additional Notes

<!-- Any additional notes or information that may be helpful for reviewers or future reference. Add `N/A` if there's nothing to mention. -->
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ dist
# OS Specific files
.DS_Store

# <ROOT>/debug folder is used to store files nedded for debugging when `debug` mode is enabled.
debug
# turbo
.turbo
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
medium-export
output
1 change: 1 addition & 0 deletions lib/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../../.editorconfig
File renamed without changes.
File renamed without changes.
98 changes: 98 additions & 0 deletions lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# OS Specific files
.DS_Store

# <ROOT>/debug folder is used to store files nedded for debugging when `debug` mode is enabled.
debug

# turbo
.turbo
1 change: 1 addition & 0 deletions lib/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output
83 changes: 83 additions & 0 deletions lib/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"name": "medmark",
"version": "0.1.1",
"description": "Export your Medium articles to markdown(md).",
"keywords": [
"medium",
"medium-to-md",
"medium-2-md",
"m2m",
"medium-to-markdown",
"medium-to-mdx",
"markdown",
"medmark",
"mdx"
],
"homepage": "https://github.com/brionmario/medmark#readme",
"bugs": {
"url": "https://github.com/brionmario/medmark/issues"
},
"license": "MIT",
"author": "Brion Mario",
"type": "commonjs",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/index.d.ts",
"files": [
"dist",
"README.md",
"LICENSE"
],
"repository": {
"type": "git",
"url": "https://github.com/brionmario/markdown/",
"directory": "packages/cli"
},
"scripts": {
"build": "pnpm clean:dist && rollup -c rollup.config.cjs",
"clean:dist": "rimraf dist",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,css,json,md,mdx}\"",
"test": "echo \"Error: no test specified\" && exit 0",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"typecheck": "tsc --noemit -p tsconfig.lib.json"
},
"dependencies": {
"chalk": "^5.2.0",
"cheerio": "^1.0.0-rc.2",
"commander": "^10.0.0",
"fake-useragent": "^1.0.1",
"fs-extra": "^11.1.0",
"inquirer": "^9.1.5",
"json-to-pretty-yaml": "^1.2.2",
"meow": "^5.0.0",
"mkdirp": "^0.5.1",
"node-fetch": "^3.3.1",
"node-html-parser": "^6.1.4",
"turndown": "^4.0.1",
"turndown-plugin-gfm": "^1.0.2"
},
"devDependencies": {
"@brionmario/eslint-plugin": "^0.2.9",
"@brionmario/prettier-config": "^0.1.0",
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^11.1.0",
"@types/node": "^18.15.11",
"@types/turndown": "^5.0.1",
"cross-env": "^7.0.3",
"eslint": "^8.30.0",
"prettier": "^2.8.1",
"rimraf": "^4.4.1",
"rollup": "^3.20.2",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-preserve-shebang": "^1.0.1",
"ts-node": "^10.9.1",
"tslib": "^2.5.0"
},
"bin": {
"medmark": "./dist/cjs/index.js"
}
}
25 changes: 25 additions & 0 deletions lib/prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* MIT License
*
* Copyright (c) 2022, Brion Mario.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

module.exports = require('@brionmario/prettier-config');
73 changes: 73 additions & 0 deletions lib/rollup.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* MIT License
*
* Copyright (c) 2023, Brion Mario
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

const commonjs = require('@rollup/plugin-commonjs');
const {nodeResolve} = require('@rollup/plugin-node-resolve');
const terser = require('@rollup/plugin-terser');
const json = require('@rollup/plugin-json');
const typescript = require('@rollup/plugin-typescript');
const shebang = require('rollup-plugin-preserve-shebang');
const dts = require('rollup-plugin-dts');
const pkg = require('./package.json');

module.exports = [
{
cache: false,
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
inlineDynamicImports: true,
sourcemap: true,
},
{
file: pkg.module,
format: 'esm',
inlineDynamicImports: true,
sourcemap: true,
},
],
plugins: [
shebang(),
json(),
nodeResolve({
exportConditions: ['node'],
}),
commonjs(),
typescript({
tsconfig: './tsconfig.lib.json',
}),
// terser(),
],
// external: ['fs', 'path'],
},
{
cache: false,
external: [/\.s?css$/],
input: 'dist/esm/types/index.d.ts',
output: [{file: 'dist/index.d.ts', format: 'esm'}],
plugins: [dts.default()],
},
];
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions lib/converter.ts → lib/src/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ async function gatherPostData(
const description: string = $cheerioBody('meta[name=description]').attr('content'); // from page...

const schemaTags: Cheerio<Element> = $cheerioBody('script[type="application/ld+json"]');
const metadata: MediumPostMetadata = JSON.parse((schemaTags[0].children[0] as any).data);
const metadata: MediumPostMetadata = schemaTags[0]?.children[0]
? JSON.parse((schemaTags[0].children[0] as any)?.data)
: {};
const readingTime: string = $cheerioBody('.pw-reading-time').text();

if (debug.enabled) {
Expand Down Expand Up @@ -433,7 +435,7 @@ async function convertMediumFile(

// re-throw if you want it to bubble up
if (error.type !== 'silent') {
throw new MedmarkException(`Error occurred while converting medium: ${error}`);
throw new MedmarkException(`Error occurred while converting medium: ${PATHS.file}`);
}
}
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/utils.ts → lib/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const getAuthors = (
metadata: MediumPostMetadata,
): MedmarkFrontMatterAuthor[] => {
let author: MedmarkFrontMatterAuthor = null;
const authorNameFromMeta: string = metadata.author.name;
const authorNameFromMeta: string = metadata?.author?.name;

// FIXME: TS ISSUE
Object.entries(apolloState).forEach(([key, value]: any) => {
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 649049c

Please sign in to comment.