From 9d61a5ef3e07d71d79abcdf59970f6fd457b42ad Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Thu, 11 Feb 2021 13:02:06 -0800 Subject: [PATCH] add automated TOC to hooks documentation --- docs/css/syntax-highlighting-overrides.css | 6 +- docs/next.config.js | 11 +++ docs/pages/docs/plugins/changelog-hooks.mdx | 10 +-- .../docs/plugins/configuration-hooks.mdx | 7 +- docs/pages/docs/plugins/init-hooks.mdx | 6 +- docs/pages/docs/plugins/log-parse-hooks.mdx | 4 +- .../docs/plugins/release-lifecycle-hooks.mdx | 14 +--- package.json | 12 ++- patches/@atomictech+rehype-toc+3.1.2.patch | 13 +++ yarn.lock | 83 ++++++++++++++++--- 10 files changed, 111 insertions(+), 55 deletions(-) create mode 100644 docs/next.config.js create mode 100644 patches/@atomictech+rehype-toc+3.1.2.patch diff --git a/docs/css/syntax-highlighting-overrides.css b/docs/css/syntax-highlighting-overrides.css index 95ae5d366..ba6170a56 100644 --- a/docs/css/syntax-highlighting-overrides.css +++ b/docs/css/syntax-highlighting-overrides.css @@ -8,4 +8,8 @@ * { text-shadow: none !important; -} \ No newline at end of file +} + +#ignite .toc ol li { + list-style-type: disc; +} diff --git a/docs/next.config.js b/docs/next.config.js new file mode 100644 index 000000000..b302a3b45 --- /dev/null +++ b/docs/next.config.js @@ -0,0 +1,11 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const toc = require("@atomictech/rehype-toc"); + +const withIgnite = require("next-ignite/next")({ + repo: "intuit/auto", + name: "auto", + url: "https://intuit.github.io/auto", + rehypePlugins: [[toc, { placeholder: "{{TOC}}" }]], +}); + +module.exports = withIgnite(); diff --git a/docs/pages/docs/plugins/changelog-hooks.mdx b/docs/pages/docs/plugins/changelog-hooks.mdx index ee23dd714..2fea03c78 100644 --- a/docs/pages/docs/plugins/changelog-hooks.mdx +++ b/docs/pages/docs/plugins/changelog-hooks.mdx @@ -6,15 +6,7 @@ One of the main outputs from `auto` is the changelogs it produces. The changelog is created from a set of commits that has been parsed using the [log parser](./log-parse-hooks). The hooks it provides allow you to customize everything about how the changelog renders. -- [onCreateChangelog](#oncreatechangelog) -- [addToBody](#addtobody) -- [renderChangelogLine](#renderchangelogline) -- [sortChangelogLines](#sortchangeloglines) -- [renderChangelogTitle](#renderchangelogtitle) -- [renderChangelogAuthor](#renderchangelogauthor) -- [renderChangelogAuthorLine](#renderchangelogauthorline) -- [createChangelogTitle](#createchangelogtitle) -- [omitReleaseNotes](#omitreleasenotes) +{{TOC}} ## onCreateChangelog diff --git a/docs/pages/docs/plugins/configuration-hooks.mdx b/docs/pages/docs/plugins/configuration-hooks.mdx index 9ac91902d..baf3a251d 100644 --- a/docs/pages/docs/plugins/configuration-hooks.mdx +++ b/docs/pages/docs/plugins/configuration-hooks.mdx @@ -4,12 +4,7 @@ title: Configuration Hooks All of the following hooks in some way deal with detecting, modifying and validating `auto`'s configuration. -- [beforeRun](#beforerun) -- [modifyConfig](#modifyconfig) -- [getAuthor](#getauthor) -- [getPreviousVersion](#getpreviousversion) -- [getRepository](#getrepository) -- [validateConfig](#validateconfig) +{{TOC}} ## beforeRun diff --git a/docs/pages/docs/plugins/init-hooks.mdx b/docs/pages/docs/plugins/init-hooks.mdx index 0f6f3d553..2ac97244c 100644 --- a/docs/pages/docs/plugins/init-hooks.mdx +++ b/docs/pages/docs/plugins/init-hooks.mdx @@ -6,11 +6,7 @@ The `auto init` command provides an easy way to create an `.autorc` without read It exposes hooks to get the basic information auto needs to function ([getRepo](#getrepo) and [getAuthor](#getauthor)). It also provides hooks the set up your plugin quicker ([configurePlugin](#configureplugin) and [createEnv](#createenv)). -- [writeRcFile](#writercfile) -- [getRepo](#getrepo) -- [getAuthor](#getauthor) -- [configurePlugin](#configureplugin) -- [createEnv](#createenv) +{{TOC}} ## writeRcFile diff --git a/docs/pages/docs/plugins/log-parse-hooks.mdx b/docs/pages/docs/plugins/log-parse-hooks.mdx index 98bd67826..87fc15bf7 100644 --- a/docs/pages/docs/plugins/log-parse-hooks.mdx +++ b/docs/pages/docs/plugins/log-parse-hooks.mdx @@ -9,9 +9,7 @@ The construct that does that work is the `LogParse` class. The `LogParse` class is involved in any command that interacts with the git log. You can use its hooks to attach information to the commit object ([parseCommit](#parsecommit)) or make `auto` ignore commits entirely ([omitCommit](#omitcommit)). -- [onCreateLogParse](#oncreatelogparse) -- [parseCommit](#parsecommit) -- [omitCommit](#omitcommit) +{{TOC}} ## onCreateLogParse diff --git a/docs/pages/docs/plugins/release-lifecycle-hooks.mdx b/docs/pages/docs/plugins/release-lifecycle-hooks.mdx index fee94eb23..d6f1d869e 100644 --- a/docs/pages/docs/plugins/release-lifecycle-hooks.mdx +++ b/docs/pages/docs/plugins/release-lifecycle-hooks.mdx @@ -5,19 +5,7 @@ title: Release Lifecycle Hooks The following hooks are all called during various release commands (ex: `latest`, `next`, `canary`, `shipit`). These hooks is where the publishing of your package actually happens. -- [prCheck](#prCheck) -- [beforeShipIt](#beforeshipit) -- [beforeCommitChangelog](#beforecommitchangelog) -- [afterChangelog](#afterchangelog) -- [version](#version) -- [afterVersion](#afterversion) -- [publish](#publish) -- [afterPublish](#afterpublish) -- [canary](#canary) -- [next](#next) -- [makeRelease](#makerelease) -- [afterRelease](#afterrelease) -- [afterShipIt](#aftershipit) +{{TOC}} ## prCheck diff --git a/package.json b/package.json index c60db2081..d8473fbb8 100644 --- a/package.json +++ b/package.json @@ -36,9 +36,11 @@ "docs:build": "yarn docs:generate && ignite build", "create:plugin": "./scripts/create-plugin.js", "create:package": "./scripts/create-package.js", - "install-mac": "yarn lerna run bundle --scope=auto && gunzip -c ./packages/cli/binary/auto-macos.gz > /usr/local/bin/auto" + "install-mac": "yarn lerna run bundle --scope=auto && gunzip -c ./packages/cli/binary/auto-macos.gz > /usr/local/bin/auto", + "postinstall": "patch-package" }, "devDependencies": { + "@atomictech/rehype-toc": "^3.1.2", "@fortawesome/fontawesome-svg-core": "^1.2.27", "@fortawesome/free-solid-svg-icons": "^5.12.1", "@fortawesome/react-fontawesome": "^0.1.9", @@ -66,7 +68,8 @@ "jest-snapshot-serializer-ansi": "^1.0.0", "lerna": "^3.13.4", "lint-staged": "^10.0.7", - "next-ignite": "^0.9.16", + "next-ignite": "^0.9.20", + "patch-package": "^6.2.2", "prettier": "^2.0.1", "prism-react-renderer": "^1.1.1", "push-dir": "^0.4.1", @@ -128,11 +131,6 @@ } } }, - "ignite": { - "repo": "intuit/auto", - "name": "auto", - "url": "https://intuit.github.io/auto" - }, "auto": { "plugins": [ [ diff --git a/patches/@atomictech+rehype-toc+3.1.2.patch b/patches/@atomictech+rehype-toc+3.1.2.patch new file mode 100644 index 000000000..471d8c78e --- /dev/null +++ b/patches/@atomictech+rehype-toc+3.1.2.patch @@ -0,0 +1,13 @@ +diff --git a/node_modules/@atomictech/rehype-toc/lib/create-toc.js b/node_modules/@atomictech/rehype-toc/lib/create-toc.js +index b576955..fbec54f 100644 +--- a/node_modules/@atomictech/rehype-toc/lib/create-toc.js ++++ b/node_modules/@atomictech/rehype-toc/lib/create-toc.js +@@ -120,7 +120,7 @@ function createListItem(heading, options) { + properties: { + className: options_1.buildClass(options.cssClasses.link, heading.tagName), + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access +- href: `#${heading.properties?.id || ""}`, ++ href: `#${(heading.properties && heading.properties.id) || ""}`, + }, + children: [ + { diff --git a/yarn.lock b/yarn.lock index 57b1c3427..5c66e43a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -53,16 +53,21 @@ dependencies: cross-fetch "3.0.6" +"@atomictech/rehype-toc@^3.1.2": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@atomictech/rehype-toc/-/rehype-toc-3.1.2.tgz#62ec993528be26dbf304e1ec0db75ae074d459df" + integrity sha512-ZLqzgBo9WUgXmLpCF8e2rYeHZjJbvWk/3R+mmpKBMDmjYRTb6/Fk6SSGFv0x1aorPwg0OLfg6ZvjAaRbndRPcA== + "@atomist/slack-messages@~1.2.0": version "1.2.1" resolved "https://registry.yarnpkg.com/@atomist/slack-messages/-/slack-messages-1.2.1.tgz#74e9499ae2b017cbb0e4f047033b9434cb42c1d7" integrity sha512-TYiuOxy5Pf9ORn94X/ujl7PY9opIh+l6NzRAV8EBLpIv3IC9gmEoev4wmmyP7Q33J0/nGjqxAaZcq/n2SZrYaQ== "@auto-it/bot-list@link:packages/bot-list": - version "10.16.1" + version "10.16.2" "@auto-it/core@link:packages/core": - version "10.16.1" + version "10.16.2" dependencies: "@auto-it/bot-list" "link:packages/bot-list" "@octokit/plugin-enterprise-compatibility" "^1.2.2" @@ -102,7 +107,7 @@ url-join "^4.0.0" "@auto-it/npm@link:plugins/npm": - version "10.16.1" + version "10.16.2" dependencies: "@auto-it/core" "link:packages/core" "@auto-it/package-json-utils" "link:packages/package-json-utils" @@ -119,13 +124,13 @@ user-home "^2.0.0" "@auto-it/package-json-utils@link:packages/package-json-utils": - version "10.16.1" + version "10.16.2" dependencies: parse-author "^2.0.0" parse-github-url "1.0.2" "@auto-it/released@link:plugins/released": - version "10.16.1" + version "10.16.2" dependencies: "@auto-it/bot-list" "link:packages/bot-list" "@auto-it/core" "link:packages/core" @@ -135,7 +140,7 @@ tslib "2.0.3" "@auto-it/slack@link:plugins/slack": - version "10.16.1" + version "10.16.2" dependencies: "@atomist/slack-messages" "~1.2.0" "@auto-it/core" "link:packages/core" @@ -3622,6 +3627,11 @@ resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== +"@yarnpkg/lockfile@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31" + integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ== + "@zkochan/cmd-shim@^3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@zkochan/cmd-shim/-/cmd-shim-3.1.0.tgz#2ab8ed81f5bb5452a85f25758eb9b8681982fd2e" @@ -5849,7 +5859,7 @@ cross-spawn@^5.0.1: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^6.0.0: +cross-spawn@^6.0.0, cross-spawn@^6.0.5: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== @@ -7517,6 +7527,14 @@ find-versions@^4.0.0: dependencies: semver-regex "^3.1.2" +find-yarn-workspace-root@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-1.2.1.tgz#40eb8e6e7c2502ddfaa2577c176f221422f860db" + integrity sha512-dVtfb0WuQG+8Ag2uWkbG79hOUzEsRrhBzgfn86g2sJPkzmcpGdghbNTfUKGTxymFrY/tLIodDzLoW9nOJ4FY8Q== + dependencies: + fs-extra "^4.0.3" + micromatch "^3.1.4" + flat-cache@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" @@ -7627,6 +7645,24 @@ fs-constants@^1.0.0: resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== +fs-extra@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94" + integrity sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + +fs-extra@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" + integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + fs-extra@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" @@ -9908,6 +9944,13 @@ kind-of@^6.0.3: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== +klaw-sync@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c" + integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ== + dependencies: + graceful-fs "^4.1.11" + kleur@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" @@ -10984,10 +11027,10 @@ neo-async@^2.6.2: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== -next-ignite@^0.9.16: - version "0.9.16" - resolved "https://registry.yarnpkg.com/next-ignite/-/next-ignite-0.9.16.tgz#737c552002ebea283c62c7201a278533a03b5e27" - integrity sha512-8qHcapEUOoFXciXAkIjEI6eWJhkRjNFcbzuEAwpm8+rhGVC1sFrLlb5Ha6aAIKRNgVYFbNtmgRgn5RwsYM8zSA== +next-ignite@^0.9.20: + version "0.9.20" + resolved "https://registry.yarnpkg.com/next-ignite/-/next-ignite-0.9.20.tgz#f8a4f17a87a469f434a26b121e10a0de7322f326" + integrity sha512-BCXYFrCskLli1ILgA5FcKxAaLE2C0BDGhzAsLLWK8enBH4Dq9fkbt11FTbR+nvTFbEUs9nl/zGYQv2k0UAAyFA== dependencies: "@babel/helper-call-delegate" "^7.12.1" "@mapbox/rehype-prism" "^0.4.0" @@ -12011,6 +12054,24 @@ pascalcase@^0.1.1: resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= +patch-package@^6.2.2: + version "6.2.2" + resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.2.2.tgz#71d170d650c65c26556f0d0fbbb48d92b6cc5f39" + integrity sha512-YqScVYkVcClUY0v8fF0kWOjDYopzIM8e3bj/RU1DPeEF14+dCGm6UeOYm4jvCyxqIEQ5/eJzmbWfDWnUleFNMg== + dependencies: + "@yarnpkg/lockfile" "^1.1.0" + chalk "^2.4.2" + cross-spawn "^6.0.5" + find-yarn-workspace-root "^1.2.1" + fs-extra "^7.0.1" + is-ci "^2.0.0" + klaw-sync "^6.0.0" + minimist "^1.2.0" + rimraf "^2.6.3" + semver "^5.6.0" + slash "^2.0.0" + tmp "^0.0.33" + path-browserify@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a"