Skip to content

Commit

Permalink
feat: doctoc and todo plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
hongaar committed Nov 24, 2022
1 parent c246b1e commit e6b8371
Show file tree
Hide file tree
Showing 14 changed files with 305 additions and 538 deletions.
7 changes: 4 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
. "$(dirname -- "$0")/_/husky.sh"

yarn doctoc
yarn leasot
git add .
yarn lint-staged
yarn prettier --write README.md
yarn todos
yarn prettier --write TODO.md
yarn lint-staged
47 changes: 28 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ yarn moker add --template cra client
- [Available plugins](#available-plugins)
- [`dependabot` _monorepo_](#dependabot-_monorepo_)
- [`devcontainer` _monorepo_](#devcontainer-_monorepo_)
- [`doctoc` _monorepo_](#doctoc-_monorepo_)
- [`github-actions` _monorepo_](#github-actions-_monorepo_)
- [`husky` _monorepo_](#husky-_monorepo_)
- [`jest` _workspace_](#jest-_workspace_)
- [`lint-staged` _monorepo_](#lint-staged-_monorepo_)
- [`prettier` _monorepo_](#prettier-_monorepo_)
- [`jest` _workspace_](#jest-_workspace_)
- [`semantic-release` _monorepo_](#semantic-release-_monorepo_)
- [`todos` _workspace_](#todos-_workspace_)
- [`typescript` _workspace_](#typescript-_workspace_)
- [Available templates](#available-templates)
- [`common` _monorepo_](#common-_monorepo_)
Expand Down Expand Up @@ -163,6 +165,13 @@ image.
If you have the `prettier` plugin installed, it will add the
[Prettier VS Code extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode).

## `doctoc` _monorepo_

This plugin adds a script to generate a table of contents for the README using
[doctoc](https://github.com/thlorenz/doctoc).

If you have the `husky` plugin installed, it will also add a pre-commit hook.

## `github-actions` _monorepo_

This plugin creates a simple `ci.yml`
Expand All @@ -186,6 +195,11 @@ repository:
This plugin sets up [Husky](https://typicode.github.io/husky/#/) at the monorepo
level.

## `jest` _workspace_

This plugin sets up [Jest](https://jestjs.io) and adds a `test` and `watch:test`
script to both the workspace and the monorepo.

## `lint-staged` _monorepo_

This plugin sets up [lint-staged](https://github.com/okonet/lint-staged) at the
Expand All @@ -211,11 +225,6 @@ This plugin sets up [Prettier](https://prettier.io).
> always be truncated to match whatever the `printWidth` setting is. This makes
> it so much easier to read and write markdown files!
## `jest` _workspace_
This plugin sets up [Jest](https://jestjs.io) and adds a `test` and `watch:test`
script to both the workspace and the monorepo.
## `semantic-release` _monorepo_
This plugin sets up
Expand Down Expand Up @@ -252,6 +261,13 @@ Otherwise, the `semantic-release` process will skip the `publish` step.
[patch-semantic-commit.js]:
https://github.com/hongaar/moker/blob/main/scripts/patch-semantic-commit.js
## `todos` _workspace_
This plugin adds a script to generate a TODO markdown file from all code
annotations using [leasot](https://github.com/pgilad/leasot).
If you have the `husky` plugin installed, it will also add a pre-commit hook.
## `typescript` _workspace_
This plugin sets up [TypeScript](https://www.typescriptlang.org) and adds a
Expand All @@ -261,15 +277,8 @@ This plugin sets up [TypeScript](https://www.typescriptlang.org) and adds a
## `common` _monorepo_
This is the only monorepo template at this point. It simply installs these
plugins in the monorepo:
- `prettier`
- `husky`
- `lint-staged`
- `semantic-release`
- `github-actions`
- `devcontainer`
This is the only monorepo template at this point. It simply installs all
available monorepo plugins.
## `bandersnatch` _workspace_
Expand Down Expand Up @@ -298,16 +307,16 @@ Contributions are very welcome!
## Roadmap
- [x] github-actions plugin
- [x] devcontainer plugin
- [ ] leasot (todos) plugin
- [ ] doctoc plugin
- [ ] Add LICENSE file to monorepo
- [ ] Support for `swc`/`esbuild`
- [ ] A compat lib (which builds cjs and mjs targets)
- [ ] Adapt for non-monorepo use-cases (?)
- [ ] Blog post / tutorial
- [ ] Docs for writing custom plugins / templates
- [x] github-actions plugin
- [x] devcontainer plugin
- [x] leasot (todos) plugin
- [x] doctoc plugin
- [x] semantic-release plugin
- [x] Port templates
- [x] Support for BYO plugins/templates
Expand Down
13 changes: 7 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
### TODOs
| Filename | line # | TODO |
|:------|:------:|:------|
| [packages/core/src/yarnrc.ts](packages/core/src/yarnrc.ts#L23) | 23 | etc, fix later |
| [packages/cli/src/commands/create.ts](packages/cli/src/commands/create.ts#L16) | 16 | re-enable prompts |
| [packages/cli/src/commands/list.ts](packages/cli/src/commands/list.ts#L15) | 15 | list workspaces |
| [packages/plugins/src/jest/jest.ts](packages/plugins/src/jest/jest.ts#L35) | 35 | install jest without ts-jest |

| Filename | line # | TODO |
| :----------------------------------------------------------------------------- | :----: | :--------------------------- |
| [packages/core/src/yarnrc.ts](packages/core/src/yarnrc.ts#L23) | 23 | etc, fix later |
| [packages/cli/src/commands/create.ts](packages/cli/src/commands/create.ts#L16) | 16 | re-enable prompts |
| [packages/cli/src/commands/list.ts](packages/cli/src/commands/list.ts#L15) | 15 | list workspaces |
| [packages/plugins/src/jest/jest.ts](packages/plugins/src/jest/jest.ts#L35) | 35 | install jest without ts-jest |
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"semantic-release",
"github-actions",
"devcontainer",
"dependabot"
"dependabot",
"todos",
"doctoc"
]
},
"packageManager": "yarn@3.2.4",
Expand All @@ -31,16 +33,16 @@
"format": "prettier --write --ignore-unknown .",
"format-check": "prettier --check --ignore-unknown .",
"doctoc": "doctoc README.md",
"leasot": "leasot --exit-nicely --reporter markdown --ignore \"**/node_modules\" \"**/*.ts\" > TODO.md",
"todos": "leasot --exit-nicely --reporter markdown --ignore \"**/node_modules\" \"**/*.ts\" > TODO.md",
"release": "semantic-release"
},
"devDependencies": {
"@semantic-release/changelog": "6.0.1",
"@semantic-release/git": "10.0.1",
"@types/prettier": "^2",
"doctoc": "^2.2.1",
"doctoc": "2.2.1",
"husky": "8.0.2",
"leasot": "^13.2.0",
"leasot": "13.2.0",
"lint-staged": "13.0.3",
"prettier": "2.7.1",
"semantic-release": "19.0.5"
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const CORE_PLUGINS = [
"jest",
"semantic-release",
"dependabot",
"todos",
"doctoc",
];

export function isPlugin(plugin: unknown): plugin is Plugin {
Expand Down
90 changes: 2 additions & 88 deletions packages/plugins/src/dependabot/dependabot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,59 +22,30 @@ type GitHubDependabotV2Config = {
updates: PackageEcosystem[];
registries?: Registries;
};
/**
* Element for each one package manager that you want GitHub Dependabot to monitor for new versions
*/

interface PackageEcosystem {
/**
* Customize which updates are allowed
*/
allow?: {
"dependency-name"?: string;
"dependency-type"?: DependencyType;
[k: string]: any;
}[];
/**
* Assignees to set on pull requests
*/
assignees?: string[];
/**
* Commit message preferences
*/
"commit-message"?: {
prefix?: string;
"prefix-development"?: string;
include?: "scope";
[k: string]: any;
};
/**
* Location of package manifests
*/
directory: string;
/**
* Ignore certain dependencies or versions
*/
ignore?: {
"dependency-name"?: string;
"dependency-type"?: DependencyType;
versions?: string[];
[k: string]: any;
}[];
/**
* Labels to set on pull requests
*/
labels?: string[];
/**
* Milestone to set on pull requests
*/
milestone?: string | number;
/**
* Limit number of open pull requests for version updates
*/
"open-pull-requests-limit"?: number;
/**
* Package manager to use
*/
"package-ecosystem":
| "bundler"
| "cargo"
Expand All @@ -92,32 +63,14 @@ interface PackageEcosystem {
| "pip"
| "pub"
| "terraform";
/**
* Pull request branch name preferences
*/
"pull-request-branch-name"?: {
/**
* Change separator for PR branch name
*/
separator: string;
[k: string]: any;
};
/**
* Disable automatic rebasing
*/
"rebase-strategy"?: "auto" | "disabled";
/**
* Reviewers to set on pull requests
*/
reviewers?: string[];
/**
* Schedule preferences
*/
schedule: {
interval?: ScheduleInterval;
/**
* Specify an alternative day to check for updates
*/
day?:
| "monday"
| "tuesday"
Expand All @@ -126,23 +79,11 @@ interface PackageEcosystem {
| "friday"
| "saturday"
| "sunday";
/**
* Specify an alternative time of day to check for updates (format: hh:mm)
*/
time?: string;
/**
* The time zone identifier must be from the Time Zone database maintained by IANA
*/
timezone?: string;
[k: string]: any;
};
/**
* Branch to create pull requests against
*/
"target-branch"?: string;
/**
* How to update manifest version requirements
*/
"versioning-strategy"?:
| "lockfile-only"
| "auto"
Expand All @@ -151,18 +92,9 @@ interface PackageEcosystem {
| "increase-if-necessary";
[k: string]: any;
}
/**
* The top-level registries key is optional. It allows you to specify authentication details that Dependabot can use to access private package registries.
*/

interface Registries {
/**
* This interface was referenced by `Registries`'s JSON-Schema definition
* via the `patternProperty` ".*".
*/
[k: string]: {
/**
* Identifies the type of registry.
*/
type:
| "composer-repository"
| "docker-registry"
Expand All @@ -174,29 +106,11 @@ interface Registries {
| "python-index"
| "rubygems-server"
| "terraform-registry";
/**
* The URL to use to access the dependencies in this registry. The protocol is optional. If not specified, https:// is assumed. Dependabot adds or ignores trailing slashes as required.
*/
url?: string;
/**
* The username that Dependabot uses to access the registry.
*/
username?: string;
/**
* A reference to a Dependabot secret containing the password for the specified user.
*/
password?: string;
/**
* A reference to a Dependabot secret containing an access key for this registry.
*/
key?: string;
/**
* A reference to a Dependabot secret containing an access token for this registry.
*/
token?: string;
/**
* For registries with type: python-index, if the boolean value is true, pip resolves dependencies by using the specified URL rather than the base URL of the Python Package Index (by default https://pypi.org/simple).
*/
"replaces-base"?: boolean;
organization?: string;
};
Expand Down

0 comments on commit e6b8371

Please sign in to comment.