Skip to content

Commit

Permalink
feat: add father-plugin-dumi-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript committed Oct 28, 2022
1 parent b395227 commit b86c201
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/node_modules
/examples/*/node_modules
/suites/**/node_modules
/suites/**/dist
/dist
/docs-dist
/theme-default
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"@types/react-helmet": "^6.1.5",
"@umijs/lint": "^4.0.22",
"eslint": "^8.20.0",
"father": "^4.0.7",
"father": "^4.1.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
Expand Down
11 changes: 7 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
packages:
- '.'
- 'assets-types'
- 'suites/*'
- 'examples/*'
5 changes: 5 additions & 0 deletions suites/father-plugin/.fatherrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from 'father';

export default defineConfig({
cjs: { output: 'dist' },
});
21 changes: 21 additions & 0 deletions suites/father-plugin/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022-present UmiJS Team

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.
50 changes: 50 additions & 0 deletions suites/father-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# father-plugin-dumi-theme

[![NPM version](https://img.shields.io/npm/v/father-plugin-dumi-theme.svg?style=flat)](https://npmjs.org/package/father-plugin-dumi-theme) [![NPM downloads](http://img.shields.io/npm/dm/father-plugin-dumi-theme.svg?style=flat)](https://npmjs.org/package/father-plugin-dumi-theme)

The father plugin for develop dumi theme package.

## Usage

## `create-dumi`

It is recommended to use `create-dumi` to start developing a new dumi theme package:

```bash
$ npx create-dumi # then select `theme`
```

This plugin is included in the template.

### Manually

Install this plugin in `devDependencies`:

```bash
$ npm i father-plugin-dumi-theme -D
```

Register it in `.fatherrc.ts`:

```ts
import { defineConfig } from 'father';

export default defineConfig({
plugins: ['father-plugin-dumi-theme'],
});
```

## Development

```bash
$ pnpm install
```

```bash
$ npm run dev
$ npm run build
```

## LICENSE

MIT
3 changes: 3 additions & 0 deletions suites/father-plugin/example/.fatherrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
plugins: [require.resolve('..')],
};
5 changes: 5 additions & 0 deletions suites/father-plugin/example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"build": "father build"
}
}
1 change: 1 addition & 0 deletions suites/father-plugin/example/src/layouts/DocLayout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => null;
1 change: 1 addition & 0 deletions suites/father-plugin/example/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => {};
33 changes: 33 additions & 0 deletions suites/father-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "father-plugin-dumi-theme",
"version": "1.0.0-beta.0",
"description": "The father plugin for develop dumi theme package",
"keywords": [
"father",
"father-plugin",
"dumi",
"theme"
],
"license": "MIT",
"main": "dist/index.js",
"files": [
"dist"
],
"scripts": {
"build": "father build",
"dev": "father dev",
"prepublishOnly": "father doctor && npm run build"
},
"devDependencies": {
"father": "^4.1.0"
},
"peerDependencies": {
"father": "^4.1.0"
},
"publishConfig": {
"access": "public"
},
"authors": [
"PeachScript <[email protected]>"
]
}
24 changes: 24 additions & 0 deletions suites/father-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { IApi } from 'father';
import fs from 'fs';
import path from 'path';

export default (api: IApi) => {
const defaultConfig: IApi['userConfig'] = {
// client files to esm
esm: {
output: 'dist',
ignores: ['src/plugin', 'src/plugin.*'],
},
};

if (fs.existsSync(path.join(api.cwd, 'src/plugin'))) {
// node files to cjs
defaultConfig.cjs = {
output: 'dist',
ignores: ['!src/plugin', '!src/plugin.*'],
};
}

// modify default build config for dumi theme project
api.modifyDefaultConfig((memo) => Object.assign(memo, defaultConfig));
};
8 changes: 8 additions & 0 deletions suites/father-plugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"strict": true,
"skipLibCheck": true,
"esModuleInterop": true,
"baseUrl": "./"
}
}

0 comments on commit b86c201

Please sign in to comment.