Skip to content

Commit

Permalink
Write auto configuration in TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
hipstersmoothie committed Mar 13, 2021
1 parent 86e294f commit c36b974
Show file tree
Hide file tree
Showing 11 changed files with 218 additions and 151 deletions.
63 changes: 63 additions & 0 deletions auto.config.ts
@@ -0,0 +1,63 @@
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";

/** 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",
{
exact: true,
canaryScope: "@auto-canary",
} as INpmConfig,
],
"released",
"first-time-contributor",
"pr-body-labels",
"./scripts/auto-update-curl-version.js",
[
"all-contributors",
{
types: {
plugin: "**/plugin/**/*",
code: ["**/src/**/*", "**/package.json", "**/tsconfig.json"],
},
} as IAllContributorsPluginOptions,
],
[
"brew",
{
executable: "./packages/cli/binary/auto-macos.gz",
name: "auto",
} as IBrewPluginOptions,
],
[
"gh-pages",
{
buildCommand: "yarn docs:build",
dir: "docs/out",
} as IGhPagesPluginOptions,
],
],
labels: [
{
name: "blog-post",
changelogTitle: "📚 Blog Post",
releaseType: "none",
},
],
};
}
54 changes: 50 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,51 @@ 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";

/** Auto configuration */
export default function rc(): AutoRc {
return {
plugins: [
"released",
[
"npm",
{
exact: true,
canaryScope: "@auto-canary",
} as INpmConfig,
],
[
"all-contributors",
{
types: {
plugin: "**/plugin/**/*",
code: ["**/src/**/*", "**/package.json", "**/tsconfig.json"],
},
} as IAllContributorsPluginOptions,
],
],
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

0 comments on commit c36b974

Please sign in to comment.