Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write auto configuration in TypeScript #1875

Merged
merged 2 commits into from Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
59 changes: 59 additions & 0 deletions auto.config.ts
@@ -0,0 +1,59 @@
import { AutoRc } from "./packages/core";

import { INpmConfig } from "./plugins/npm";
import { IBrewPluginOptions } from "./plugins/brew";
import { IGhPagesPluginOptions } from "./plugins/gh-pages";
import { IAllContributorsPluginOptions } from "./plugins/all-contributors";

const npmOptions: INpmConfig = {
exact: true,
canaryScope: "@auto-canary",
};

const allContributorsOptions: IAllContributorsPluginOptions = {
types: {
plugin: "**/plugin/**/*",
code: ["**/src/**/*", "**/package.json", "**/tsconfig.json"],
},
};

const brewOptions: IBrewPluginOptions = {
executable: "./packages/cli/binary/auto-macos.gz",
name: "auto",
};

const ghPagesOptions: IGhPagesPluginOptions = {
buildCommand: "yarn docs:build",
dir: "docs/out",
};

/** Auto configuration */
export default function rc(): AutoRc {
return {
plugins: [
[
"upload-assets",
[
"./packages/cli/binary/auto-linux.gz",
"./packages/cli/binary/auto-macos.gz",
"./packages/cli/binary/auto-win.exe.gz",
],
],
["npm", npmOptions],
"released",
"first-time-contributor",
"pr-body-labels",
"./scripts/auto-update-curl-version.js",
["all-contributors", allContributorsOptions],
["brew", brewOptions],
["gh-pages", ghPagesOptions],
],
labels: [
{
name: "blog-post",
changelogTitle: "πŸ“š Blog Post",
releaseType: "none",
},
],
};
}
52 changes: 48 additions & 4 deletions docs/pages/docs/configuration/autorc.mdx
Expand Up @@ -8,10 +8,11 @@ import { DefaultLabelRenderer } from "../../../components/defaultLabelsRenderer"
This means you can define this file a variety of ways.
`cosmiconfig` will start at the root of your project and start to search up the directory tree for the following:

- a package.json property
- a JSON or YAML, extension-less "rc file"
- an "rc file" with the extensions `.json`, `.yaml`, `.yml`, or `.js`
- a `.config.js` CommonJS module
- an `auto` package.json property
- a JSON or YAML, extension-less rc file ".autorc"
- an "rc file" with the extensions `.json`, `.yaml`, `.yml`, `.ts` or `.js`
- a `auto.config.js` or `auto.config.js` CommonJS module
- a `auto.config.ts` TypeScript module

## Initialization

Expand All @@ -21,6 +22,49 @@ To interactively create an `.autorc` use the `init` command. You can configure m
auto init
```

## TypeScript Configuration

You can write your `auto` configuration in a TypeScript file for easier validation

**auto.config.ts:**

```ts
import { AutoRc } from "auto";

import { INpmConfig } from "@auto-it/core";
import { IAllContributorsPluginOptions } from "@auto-it/all-contributors";

const npmOptions: INpmConfig = {
exact: true,
canaryScope: "@auto-canary",
};

const allContributorsOptions: IAllContributorsPluginOptions = {
types: {
plugin: "**/plugin/**/*",
code: ["**/src/**/*", "**/package.json", "**/tsconfig.json"],
},
};

/** Auto configuration */
export default function rc(): AutoRc {
return {
plugins: [
"released",
["npm", npmOptions],
["all-contributors", allContributorsOptions],
],
labels: [
{
name: "blog-post",
changelogTitle: "πŸ“š Blog Post",
releaseType: "none",
},
],
};
}
```

## Options

The following are all of the top level configuration options for `auto`.
Expand Down
57 changes: 0 additions & 57 deletions package.json
Expand Up @@ -134,62 +134,5 @@
"isolatedModules": true
}
}
},
"auto": {
"plugins": [
[
"upload-assets",
[
"./packages/cli/binary/auto-linux.gz",
"./packages/cli/binary/auto-macos.gz",
"./packages/cli/binary/auto-win.exe.gz"
]
],
[
"npm",
{
"exact": true,
"canaryScope": "@auto-canary"
}
],
"released",
"first-time-contributor",
"pr-body-labels",
"./scripts/auto-update-curl-version.js",
[
"all-contributors",
{
"types": {
"plugin": "**/plugin/**/*",
"code": [
"**/src/**/*",
"**/package.json",
"**/tsconfig.json"
]
}
}
],
[
"brew",
{
"executable": "./packages/cli/binary/auto-macos.gz",
"name": "auto"
}
],
[
"gh-pages",
{
"buildCommand": "yarn docs:build",
"dir": "docs/out"
}
]
],
"labels": [
{
"name": "blog-post",
"changelogTitle": "πŸ“š Blog Post",
"releaseType": "none"
}
]
}
}
2 changes: 2 additions & 0 deletions packages/cli/package.json
@@ -1,6 +1,8 @@
{
"name": "auto",
"bin": "dist/bin/auto.js",
"main": "dist/bin/index.js",
"types": "dist/bin/index.d.ts",
"description": "CLI tools to help facilitate semantic versioning based on GitHub PR labels",
"version": "10.19.0",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/index.ts
@@ -0,0 +1 @@
export { AutoRc } from "@auto-it/core";
1 change: 1 addition & 0 deletions packages/core/package.json
Expand Up @@ -38,6 +38,7 @@
},
"dependencies": {
"@auto-it/bot-list": "link:../../packages/bot-list",
"@endemolshinegroup/cosmiconfig-typescript-loader": "^3.0.2",
"@octokit/plugin-enterprise-compatibility": "^1.2.2",
"@octokit/plugin-retry": "^3.0.1",
"@octokit/plugin-throttling": "^3.2.0",
Expand Down