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

feat: 添加 github page #5

Merged
merged 19 commits into from
Oct 24, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,40 @@
import { defineConfig } from 'dumi'

const isDev = process.env.NODE_ENV === 'development'
const BASE_URL = isDev ? '/' : '/dumlj-build/docs/'

export default defineConfig({
title: 'Dumlj',
outputPath: 'gh-pages/docs',
logo: 'images/android-chrome-512x512.png',
favicons: ['images/favicon.ico', 'images/favicon-32x32.png'],
logo: BASE_URL + 'images/android-chrome-512x512.png',
favicons: ['images/favicon.ico', 'images/favicon-32x32.png'].map((path) => BASE_URL + path),
resolve: {
docDirs: ['@docs'],
},
hash: true,
base: isDev ? '/' : '/dumlj/docs/',
publicPath: isDev ? '/' : '/dumlj/docs/',
base: BASE_URL,
publicPath: BASE_URL,
themeConfig: {
name: 'Dumlj',
footer: 'Dumlj MIT Licensed | Copyright © 2023-present',
socialLinks: {
github: 'https://github.com/dumlj/dumlj-build',
},
},
nodeStackblitz: {
ignored: [
'**/__tests__/**',
'**/__typetests__/**',
'**/__readme__/**',
'**/jest.*',
'**/src/**',
'**/*.map',
'**/tsconfig.*',
'**/.npmignore',
'**/.DS_Store',
'**/LICENSE.md',
'**/README.md',
],
},
plugins: [require.resolve('@dumlj/dumi-plugin-node-stackblitz'), require.resolve('@dumlj/dumi-plugin-mono-readme')],
})
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: dumlj-build.workflow
name: build

on:
push:
branches:
- main
- 'feature/**'
- 'hotfix/**'
- 'fix/**'
- 'feat/*'
- 'feature/*'
- 'hotfix/*'
- 'fix/*'
- 'ci/*'
- 'perf/*'
- 'docs/*'
Expand Down
25 changes: 4 additions & 21 deletions .github/workflows/gh-pages.workflow.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
name: gh-pages.workflow
name: gh-pages

on: [workflow_dispatch]

env:
# 默认分支
CI_DEFAULT_BRANCH: main

jobs:
# 发布 Github Pages
pages:
name: Page
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: macOS-latest
steps:
# 初始化
- name: Initialize project
uses: dumlj/dumlj-workflows/.github/actions/setup-composite@main
with:
token: ${{ secrets.CI_GIT_TOKEN }}
# 发布 github apge
- name: Deploy github page
uses: dumlj/dumlj-workflows/.github/actions/pages-composite@main
with:
token: ${{ secrets.CI_GIT_TOKEN }}
gh-pages:
uses: dumlj/dumlj-workflows/.github/workflows/gh-pages.workflow.yml@main
secrets: inherit
2 changes: 1 addition & 1 deletion @cli/seed-cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const BGCommands = {
/** 创建后台执行的进程 */
const spawnBGProcess = (command: keyof typeof BGCommands) => {
const cp = spawn(CLI_NAME, [command], {
detached: true,
...(process.platform === 'win32' ? { shell: true, windowsHide: true } : { detached: true }),
stdio: 'ignore',
env: {
...process.env,
Expand Down
14 changes: 11 additions & 3 deletions @cli/tidy-cli/__tests__/actions/tscfg.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from 'path'
import { tidyTscfg } from '@/actions/tscfg'
import { vol } from 'memfs'

Expand Down Expand Up @@ -59,9 +60,16 @@ describe('test actions/tidyTscfg', () => {
expect(aContent.compilerOptions.rootDir).toEqual('aSrc')
expect(bContent.compilerOptions.rootDir).toEqual('bSrc')

expect(bContent.references).toStrictEqual([{ path: '../a/tsconfig.build.json' }])
expect(bContent.references).toStrictEqual([{ path: '../a/tsconfig.build.json' }])
expect(bContent.references).toStrictEqual([{ path: path.normalize('../a/tsconfig.build.json') }])
expect(bContent.references).toStrictEqual([{ path: path.normalize('../a/tsconfig.build.json') }])

expect(rContent.references).toStrictEqual([{ path: './packages/a/tsconfig.build.json' }, { path: './packages/b/tsconfig.build.json' }])
expect(rContent.references).toStrictEqual([
{
path: process.platform === 'win32' ? `.\\${path.normalize('./packages/a/tsconfig.build.json')}` : './packages/a/tsconfig.build.json',
},
{
path: process.platform === 'win32' ? `.\\${path.normalize('./packages/b/tsconfig.build.json')}` : './packages/b/tsconfig.build.json',
},
])
})
})
2 changes: 1 addition & 1 deletion @cli/tidy-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@dumlj/tidy-cli",
"version": "0.0.1",
"private": true,
"description": "Cli for organizing projects.",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/dumlj/dumlj-build",
Expand Down
3 changes: 1 addition & 2 deletions @dumi-plugin/dumi-plugin-node-stackblitz/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export interface NodeStackblitzOptions {
}

export default createDumiPlugin<NodeStackblitzOptions>('nodeStackblitz', async (api, { pushWebpackPlugin }) => {
const { nodeStackblitz = {} } = api.useConfig || {}

const { nodeStackblitz = {} } = api.userConfig || {}
api.describe({
key: 'nodeStackblitz',
config: {
Expand Down
7 changes: 4 additions & 3 deletions @feature/feature-prepare/__tests__/findTsConfig.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from 'path'
import { findTsConfig } from '@/findTsConfig'
import { vol } from 'memfs'

Expand All @@ -19,9 +20,9 @@ describe('test findTsConfig', () => {
'/packages/b/path/index.ts': 'consnole.log("ok")',
})

expect(await findTsConfig('/packages/b/path/index.ts')).toBe('/packages/b/tsconfig.json')
expect(await findTsConfig('/packages/a/index.ts')).toBe('/packages/a/tsconfig.json')
expect(await findTsConfig('/index.ts')).toBe('/tsconfig.json')
expect(await findTsConfig('/packages/b/path/index.ts')).toBe(path.normalize('/packages/b/tsconfig.json'))
expect(await findTsConfig('/packages/a/index.ts')).toBe(path.normalize('/packages/a/tsconfig.json'))
expect(await findTsConfig('/index.ts')).toBe(path.normalize('/tsconfig.json'))
})

it('will return false when tsconfig not found.', async () => {
Expand Down
7 changes: 3 additions & 4 deletions @feature/feature-readme/__tests__/lookupFile.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from 'path'
import { vol } from 'memfs'
import { lookupFile } from '@/lookupFile'

Expand All @@ -15,8 +16,7 @@ describe('test actions/tidyReadme/lookupFile', () => {
})

const paths = ['/a/b/c/d/__readme__', '/a/b/c/__readme__']

expect(await lookupFile('TITLE.md', paths)).toEqual('/a/b/c/d/__readme__/TITLE.md')
expect(await lookupFile('TITLE.md', paths)).toEqual(path.normalize('/a/b/c/d/__readme__/TITLE.md'))
})

it('search file according to order of input paths', async () => {
Expand All @@ -26,8 +26,7 @@ describe('test actions/tidyReadme/lookupFile', () => {
})

const paths = ['/__readme__', '/a/__readme__', '/a/b/__readme__', '/a/b/c/__readme__', '/a/b/c/d/__readme__']

expect(await lookupFile('TITLE.md', paths)).toEqual('/__readme__/TITLE.md')
expect(await lookupFile('TITLE.md', paths)).toEqual(path.normalize('/__readme__/TITLE.md'))
})

it('will return undefined when file not exists', async () => {
Expand Down
4 changes: 4 additions & 0 deletions @webpack-plugin/__template__/__example__/.stackblitzrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"installDependencies": false,
"startCommand": "yarn install && yarn build"
}
24 changes: 24 additions & 0 deletions @webpack-plugin/crx-manifest-webpack-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

generate manifest file for chrome extension

## BACKGROUND

## FEATURE

## INSTALL

```bash
Expand All @@ -14,3 +18,23 @@ $ yarn add --dev @dumlj/crx-manifest-webpack-plugin
# use pnpm
$ pnpm add @dumlj/crx-manifest-webpack-plugin -D
```

## USAGE

```ts
import fs from 'fs-extra'
import { CrxManifestWebpackPlugin } from '@dumlj/crx-manifest-webpack-plugin'
import webpack, { type Configuration } from 'webpack'

const manifest: ChromeManifest = fs.readJSONSync(manifestFile)
const config: Configuration = {
// ...
plugins: [new CrxManifestWebpackPlugin({ manifest })],
}

export default config
```

## LIVE DEMO

<stackblitz-live-demo height="800px" src="@dumlj-example/crx-manifest-webpack-plugin"></stackblitz-live-demo>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"installDependencies": false,
"startCommand": "yarn install && yarn build"
}
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Dumlj",
"description": "crx-manifest-webpack-plugin example",
"version": "0.0.1",
"manifest_version": 3,
"permissions": ["storage", "activeTab", "scripting", "tabs"],
"host_permissions": ["*://*/*", "http://*/*", "https://*/*"],
"icons": {
"16": "logo-16.png",
"32": "logo-32.png",
"48": "logo-48.png",
"128": "logo-128.png"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@dumlj-example/crx-manifest-webpack-plugin",
"version": "0.0.1",
"private": true,
"main": "webpack.config.ts",
"scripts": {
"build": "yarn webpack -c webpack.config.ts"
},
"dependencies": {
"@dumlj/crx-manifest-webpack-plugin": "0.0.1",
"@dumlj/feature-pretty": "^0.0.1",
"@dumlj/vitrual-webpack-plugin": "0.0.1",
"fs-extra": "^11.1.1",
"html-webpack-plugin": "^5.5.3"
},
"devDependencies": {
"webpack": "^5",
"webpack-cli": "^5"
},
"optionalDependencies": {
"@babel/core": "^7.23.2",
"@babel/preset-env": "^7.23.2",
"@babel/preset-typescript": "^7.23.2",
"@babel/register": "^7.22.15"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import fs from 'fs-extra'
import path from 'path'
import { type Configuration, type Compiler } from 'webpack'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import { ok, warn } from '@dumlj/feature-pretty'
import { VitrualWebpackPlugin } from '@dumlj/vitrual-webpack-plugin'
import { CrxManifestWebpackPlugin, type ChromeManifest } from '@dumlj/crx-manifest-webpack-plugin'

const manifestFile = path.join(__dirname, 'manifest.json')
const manifest: ChromeManifest = fs.readJSONSync(manifestFile)

const CONFIG: Configuration = {
mode: 'production',
plugins: [
new VitrualWebpackPlugin({ readFromDisk: true }),
new CrxManifestWebpackPlugin({ manifest }),
{
apply(compiler: Compiler) {
compiler.hooks.afterDone.tap('use-for-echo-ignore-me', (stats) => {
if (stats.hasErrors()) {
return
}

const files = VitrualWebpackPlugin.files
const manifest = Object.keys(files).find((file) => path.relative(__dirname, file) === 'dist/manifest.json')
ok(`The following is the content of manifest.json.`, { verbose: false })

// eslint-disable-next-line no-console
console.dir(JSON.parse(files[manifest]), { depth: null, colors: true })
warn('Please compare the contents above and ./manifest.json.', { verbose: false })
})
},
},
],
entry: {
index: './entries/index.ts',
background: './entries/background.ts',
contentScript: './entries/contentScript.ts',
launch: './entries/launch.ts',
popup: './entries/popup.ts',
},
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
},
usedExports: true,
},
}

CONFIG.output = {
...CONFIG.output,
filename: '[name].js',
}

CONFIG.plugins.push(new HtmlWebpackPlugin({ filename: 'popup.html' }))

export default CONFIG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## BACKGROUND
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## LIVE DEMO

<stackblitz-live-demo height="800px" src="@dumlj-example/crx-manifest-webpack-plugin"></stackblitz-live-demo>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## FEATURE
15 changes: 15 additions & 0 deletions @webpack-plugin/crx-manifest-webpack-plugin/__readme__/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## USAGE

```ts
import fs from 'fs-extra'
import { CrxManifestWebpackPlugin } from '@dumlj/crx-manifest-webpack-plugin'
import webpack, { type Configuration } from 'webpack'

const manifest: ChromeManifest = fs.readJSONSync(manifestFile)
const config: Configuration = {
// ...
plugins: [new CrxManifestWebpackPlugin({ manifest })],
}

export default config
```
3 changes: 3 additions & 0 deletions @webpack-plugin/seed-webpack-plugin/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// 主要用于兼容 VSCODE 等编辑器在没有编译文件时不显示错误信息
// 部分编辑器会存在缓存,需要手动刷新造成开发麻烦
export * from './src'
3 changes: 2 additions & 1 deletion @webpack-plugin/stackblitz-webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"glob": "^10.3.4",
"tslib": "^2.5.0",
"jszip": "^3.10.1",
"utility-types": "^3.10.0"
"utility-types": "^3.10.0",
"lodash": "^4.17.21"
},
"devDependencies": {
"@jest/types": "^29.6.3",
Expand Down
Loading
Loading