Skip to content

Commit

Permalink
refactor: refactor code project folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 24, 2023
1 parent dbbb2be commit 8c05715
Show file tree
Hide file tree
Showing 28 changed files with 418 additions and 507 deletions.
61 changes: 31 additions & 30 deletions .github/workflows/ci.yml
Expand Up @@ -15,21 +15,21 @@ jobs:
registry-url: 'https://registry.npmjs.org'

- run: npm install
- run: npm run build
- run: npm run doc
- run: npm run build:lib
- run: npm run build:doc

- name: Generate Contributors Images
uses: jaywcjlove/github-action-contributors@main
with:
filter-author: (renovate\[bot\]|renovate-bot|dependabot\[bot\])
output: build/CONTRIBUTORS.svg
output: www/build/CONTRIBUTORS.svg
avatarSize: 42

- name: Create Tag
id: create_tag
uses: jaywcjlove/create-tag-action@main
with:
package-path: ./package.json
package-path: ./core/package.json

- name: get tag version
id: tag_version
Expand All @@ -40,7 +40,7 @@ jobs:
with:
commit_message: ${{steps.tag_version.outputs.tag}} ${{ github.event.head_commit.message }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
publish_dir: ./www/build

- name: Generate Changelog
id: changelog
Expand Down Expand Up @@ -72,32 +72,33 @@ jobs:
- name: 📦 @uiw/react-prismjs publish to NPM
run: npm publish
continue-on-error: true
working-directory: core
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

outputs:
successful: ${{steps.create_tag.outputs.successful }}

github-package:
runs-on: ubuntu-latest
needs: build-deploy
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://npm.pkg.github.com
scope: '@uiwjs'

- run: npm install
- run: npm run build

- name: Modify @uiw/react-prismjs => @uiwjs/react-prismjs
uses: jaywcjlove/github-action-package@main
with:
rename: '@uiwjs/react-prismjs'
# outputs:
# successful: ${{steps.create_tag.outputs.successful }}

# github-package:
# runs-on: ubuntu-latest
# needs: build-deploy
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: 16
# registry-url: https://npm.pkg.github.com
# scope: '@uiwjs'

# - run: npm install
# - run: npm run build

# - name: Modify @uiw/react-prismjs => @uiwjs/react-prismjs
# uses: jaywcjlove/github-action-package@main
# with:
# rename: '@uiwjs/react-prismjs'

- run: npm publish
env:
continue-on-error: true
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
# - run: npm publish
# env:
# continue-on-error: true
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
5 changes: 5 additions & 0 deletions .lintstagedrc
@@ -0,0 +1,5 @@
{
"*.{js,jsx,tsx,ts,less,md,json}": [
"prettier --write"
]
}
13 changes: 13 additions & 0 deletions .prettierignore
@@ -0,0 +1,13 @@
**/*.md
**/*.svg
**/*.ejs
**/*.html
**/*.yml
package.json
node_modules
dist
build
coverage
lib
esm
test
11 changes: 11 additions & 0 deletions .prettierrc
@@ -0,0 +1,11 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120,
"overrides": [
{
"files": ".prettierrc",
"options": { "parser": "json" }
}
]
}
80 changes: 0 additions & 80 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
106 changes: 106 additions & 0 deletions core/README.md
@@ -0,0 +1,106 @@
@uiw/react-prismjs
===
<!--dividing-->

[![Build & Deploy](https://github.com/uiwjs/react-prismjs/actions/workflows/ci.yml/badge.svg)](https://github.com/uiwjs/react-prismjs/actions/workflows/ci.yml)
[![NPM Downloads](https://img.shields.io/npm/dm/@uiw/react-prismjs.svg?style=flat)](https://www.npmjs.com/package/@uiw/react-prismjs)
[![npm version](https://img.shields.io/npm/v/@uiw/react-prismjs.svg)](https://www.npmjs.com/package/@uiw/react-prismjs)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/@uiw/react-prismjs.svg)](https://bundlephobia.com/result?p=@uiw/react-prismjs)

React Component for [prismjs](https://github.com/PrismJS/prism). The current [document website](https://uiwjs.github.io/react-prismjs/).

## Install

```bash
npm i @uiw/react-prismjs
```

## Basic Usage

[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?logo=codesandbox)](https://codesandbox.io/embed/example-uiw-react-prismjs-uj67m?fontsize=14&hidenavigation=1&theme=dark)

```jsx mdx:preview?background=#fff
import React from 'react';
import ReactPrismjs from '@uiw/react-prismjs';
import 'prismjs/components/prism-java';

const JAVAString =`import com.demo.util.MyType;
import com.demo.util.MyInterface;
public enum Enum {
VAL1, VAL2, VAL3
}
public class Class<T, V> implements MyInterface {
public static final MyType<T, V> member;
@Override
public MyType method() {
return member;
}
public void method2(MyType<T, V> value) {
method();
value.method3();
member = value;
}
}
`;

export default function Demo() {
return (
<ReactPrismjs language="java" source={JAVAString} style={{ backgroundColor: '#f6f8fa', fontSize: 16 }} />
)
}
```

### Theme

Support [`prismjs`](https://github.com/PrismJS/prism/tree/master/themes) theme setting

```js
import ReactPrismjs from '@uiw/react-prismjs';
import 'prismjs/themes/prism-coy.css';
```

### Options Props

```typescript
interface ReactPrismjsProps {
prefixCls?: string;
language?: string;
source?: string;
className?: string;
}
```

- `source` - _string_ The code string source to parse (**required**)
- `language` - _string_ A language id in [`Prism.languages`](https://github.com/PrismJS/prism/blob/388ad996c4b576205de4d4feda69202bd26c1345/components.json).
- `className` - _string_ Class name of the container element.

## Development

**development**

Runs the project in development mode.

```bash
# listen to the component compile and output the .js file and listen for compilation output type .d.ts file
npm run watch
# development mode, listen to compile preview website instance
npm run doc:dev
```

## Contributors

As always, thanks to our amazing contributors!

<a href="https://github.com/uiwjs/react-prismjs/graphs/contributors">
<img src="https://uiwjs.github.io/react-prismjs/CONTRIBUTORS.svg" />
</a>

Made with [contributors](https://github.com/jaywcjlove/github-action-contributors).

## License

Licensed under the MIT License.
35 changes: 35 additions & 0 deletions core/package.json
@@ -0,0 +1,35 @@
{
"name": "@uiw/react-prismjs",
"version": "1.3.6",
"description": "React Component for prismjs.",
"homepage": "https://uiwjs.github.io/react-prismjs/",
"main": "cjs/index.js",
"module": "esm/index.js",
"scripts": {
"css:build": "compile-less -d src -o esm",
"css:watch": "compile-less -d src -o esm --watch",
"css:build:dist": "compile-less -d src --combine dist.css --rm-global",
"watch": "tsbb watch src/*.tsx --use-babel & npm run css:watch",
"build": "tsbb build src/*.tsx --use-babel && npm run css:build && npm run css:build:dist"
},
"repository": {
"type": "git",
"url": "https://github.com/uiwjs/react-prismjs.git"
},
"author": "kenny wang <wowohoo@qq.com>",
"license": "MIT",
"files": [
"dist.css",
"src",
"cjs",
"esm"
],
"peerDependencies": {
"react": ">=16.8.0",
"react-dom": ">=16.8.0"
},
"dependencies": {
"@types/prismjs": "~1.26.0",
"prismjs": "~1.29.0"
}
}
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions core/tsconfig.json
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig",
"include": ["src"],
"compilerOptions": {
"baseUrl": "./",
"noEmit": false,
"outDir": "./cjs"
}
}
4 changes: 4 additions & 0 deletions lerna.json
@@ -0,0 +1,4 @@
{
"version": "1.3.6",
"packages": ["core", "www"]
}

0 comments on commit 8c05715

Please sign in to comment.