From b345cc57192d7d0aba6317e5b7054a4f9536b6d1 Mon Sep 17 00:00:00 2001
From: mantou132 <709922234@qq.com>
Date: Sat, 30 Dec 2023 19:00:55 +0800
Subject: [PATCH] Publish
- duoyun-ui@1.1.8
- @mantou/gem@1.7.8
- gem-analyzer@1.7.6
- gem-book@1.5.24
- gem-devtools@1.7.5
- gem-examples@1.7.5
- gem-port@0.0.6
---
packages/duoyun-ui/package.json | 2 +-
packages/gem-analyzer/package.json | 4 +--
.../gem-book/docs/zh/002-guide/003-cli.md | 4 +--
packages/gem-book/package.json | 6 ++---
packages/gem-book/src/bin/builder.ts | 1 +
packages/gem-book/src/bin/index.ts | 13 +++++++++-
.../src/element/elements/edit-link.ts | 25 +++++++++++--------
packages/gem-book/src/plugins/api.ts | 10 +++++---
packages/gem-devtools/package.json | 4 +--
packages/gem-examples/package.json | 6 ++---
packages/gem-port/package.json | 4 +--
packages/gem/package.json | 2 +-
12 files changed, 50 insertions(+), 31 deletions(-)
diff --git a/packages/duoyun-ui/package.json b/packages/duoyun-ui/package.json
index 2371999a..f1f6bd8b 100644
--- a/packages/duoyun-ui/package.json
+++ b/packages/duoyun-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "duoyun-ui",
- "version": "1.1.7",
+ "version": "1.1.8",
"description": "A lightweight desktop UI component library, implemented using Gem",
"keywords": [
"frontend",
diff --git a/packages/gem-analyzer/package.json b/packages/gem-analyzer/package.json
index 54a0d990..cd6fc7f0 100644
--- a/packages/gem-analyzer/package.json
+++ b/packages/gem-analyzer/package.json
@@ -1,6 +1,6 @@
{
"name": "gem-analyzer",
- "version": "1.7.5",
+ "version": "1.7.6",
"description": "gem analyzer",
"main": "index.js",
"files": [
@@ -13,7 +13,7 @@
"prepublishOnly": "yarn build"
},
"dependencies": {
- "@mantou/gem": "^1.7.6"
+ "@mantou/gem": "^1.7.8"
},
"devDependencies": {
"@gemjs/config": "^1.6.11",
diff --git a/packages/gem-book/docs/zh/002-guide/003-cli.md b/packages/gem-book/docs/zh/002-guide/003-cli.md
index 2399cf83..da56dd18 100644
--- a/packages/gem-book/docs/zh/002-guide/003-cli.md
+++ b/packages/gem-book/docs/zh/002-guide/003-cli.md
@@ -26,7 +26,7 @@ npx gem-book -h
#### `-d, --source-dir
`
-指定文档目录在 GitHub 中的位置,最终生成前往 GitHub 的链接。
+指定文档目录在 GitHub 中的位置,最终生成前往 GitHub 的链接,默认使用当前命令指定目录。
#### `-b, --source-branch `
@@ -34,7 +34,7 @@ npx gem-book -h
#### `--base `
-指定项目的基础目录
+指定项目的基础目录,默认会读取 `package.json` 的 `repository.directory` 字段。
#### `--github `
diff --git a/packages/gem-book/package.json b/packages/gem-book/package.json
index 3815cafe..751c7d0b 100644
--- a/packages/gem-book/package.json
+++ b/packages/gem-book/package.json
@@ -1,6 +1,6 @@
{
"name": "gem-book",
- "version": "1.5.23",
+ "version": "1.5.26",
"description": "Create your document website easily and quickly",
"keywords": [
"doc",
@@ -37,7 +37,7 @@
"prepublishOnly": "yarn build"
},
"dependencies": {
- "@mantou/gem": "^1.7.6",
+ "@mantou/gem": "^1.7.8",
"commander": "^7.2.0",
"copy-webpack-plugin": "^11.0.0",
"front-matter": "^4.0.2",
@@ -71,7 +71,7 @@
"@web/dev-server-esbuild": "^0.2.16",
"@web/test-runner": "^0.13.22",
"esbuild": "^0.14.14",
- "gem-analyzer": "^1.7.5",
+ "gem-analyzer": "^1.7.6",
"nodemon": "^2.0.7",
"ts-morph": "^13.0.0",
"webpack-cli": "^5.1.4",
diff --git a/packages/gem-book/src/bin/builder.ts b/packages/gem-book/src/bin/builder.ts
index 89c8ffac..5fe4f8dc 100644
--- a/packages/gem-book/src/bin/builder.ts
+++ b/packages/gem-book/src/bin/builder.ts
@@ -150,6 +150,7 @@ export function startBuilder(dir: string, options: Required, bo
if (stats.hasErrors()) {
console.error(info.errors);
+ process.exit(1);
}
if (stats.hasWarnings()) {
diff --git a/packages/gem-book/src/bin/index.ts b/packages/gem-book/src/bin/index.ts
index e374708b..b230704f 100644
--- a/packages/gem-book/src/bin/index.ts
+++ b/packages/gem-book/src/bin/index.ts
@@ -76,6 +76,13 @@ function readConfig(configPath: string) {
}
}
});
+ obj.nav = obj.nav?.filter((e) => {
+ if (e.title?.toLowerCase() === 'github') {
+ bookConfig.github = e.link;
+ } else {
+ return true;
+ }
+ });
Object.assign(bookConfig, obj);
}
@@ -276,7 +283,11 @@ program
bookConfig.nav ||= [];
const [title, link] = item.split(',');
if (!link) throw new Error('nav options error');
- bookConfig.nav.push({ title, link });
+ if (title.toLowerCase() === 'github') {
+ bookConfig.github = link;
+ } else {
+ bookConfig.nav.push({ title, link });
+ }
})
.option('--plugin ', 'load plugin', (name: string) => {
cliConfig.plugin.push(name);
diff --git a/packages/gem-book/src/element/elements/edit-link.ts b/packages/gem-book/src/element/elements/edit-link.ts
index 167c720b..ea7d6262 100644
--- a/packages/gem-book/src/element/elements/edit-link.ts
+++ b/packages/gem-book/src/element/elements/edit-link.ts
@@ -1,9 +1,9 @@
-import { html, GemElement, customElement, history, connectStore } from '@mantou/gem';
+import { html, GemElement, customElement, connectStore } from '@mantou/gem';
import { mediaQuery } from '@mantou/gem/helper/mediaquery';
import { getGithubPath } from '../lib/utils';
import { selfI18n } from '../helper/i18n';
-import { bookStore } from '../store';
+import { bookStore, locationStore } from '../store';
import { icons } from './icons';
@@ -26,6 +26,7 @@ const fetchData = async (api: string) => {
@customElement('gem-book-edit-link')
@connectStore(selfI18n.store)
+@connectStore(locationStore)
export class EditLink extends GemElement {
state = {
lastUpdated: '',
@@ -50,7 +51,7 @@ export class EditLink extends GemElement {
#getMdFullPath = () => {
const link = bookStore.getCurrentLink?.();
- if (!link) return;
+ if (!link) return '';
return getGithubPath(link.originLink);
};
@@ -59,8 +60,7 @@ export class EditLink extends GemElement {
const { message, commitUrl } = this.state;
const { config } = bookStore;
const { github, sourceBranch = '' } = config || {};
- const fullPath = this.#getMdFullPath();
- if (!github || !sourceBranch || !fullPath) return;
+ if (!github || !sourceBranch || !this.#fullPath) return;
return html`
-
+
${selfI18n.get('editOnGithub')}
@@ -110,17 +110,22 @@ export class EditLink extends GemElement {
`;
}
+ #fullPath = '';
+
mounted() {
+ this.memo(() => {
+ this.#fullPath = this.#getMdFullPath();
+ });
+
this.effect(
async () => {
const { config } = bookStore;
const { github, sourceBranch = '' } = config || {};
if (!github) return;
const repo = new URL(github).pathname;
- const path = this.#getMdFullPath();
- if (!path) return;
+ if (!this.#fullPath) return;
const query = new URLSearchParams({
- path,
+ path: this.#fullPath,
page: '1',
per_page: '1',
sha: sourceBranch,
@@ -138,7 +143,7 @@ export class EditLink extends GemElement {
this.setState({ lastUpdated: '' });
}
},
- () => [history.getParams().path],
+ () => [this.#fullPath],
);
}
}
diff --git a/packages/gem-book/src/plugins/api.ts b/packages/gem-book/src/plugins/api.ts
index ddc7d941..0a1149be 100644
--- a/packages/gem-book/src/plugins/api.ts
+++ b/packages/gem-book/src/plugins/api.ts
@@ -13,7 +13,7 @@ type State = { elements?: ElementDetail[]; exports?: ExportDetail[]; error?: any
customElements.whenDefined('gem-book').then(() => {
const { GemBookPluginElement } = customElements.get('gem-book') as typeof GemBookElement;
- const { Gem, config, theme } = GemBookPluginElement;
+ const { Gem, theme } = GemBookPluginElement;
const { html, customElement, attribute, numattribute, createCSSSheet, css, adoptedStyle } = Gem;
const MainElement = customElements.get('gem-book-main') as typeof Main;
@@ -53,9 +53,11 @@ customElements.whenDefined('gem-book').then(() => {
#parseFile = async (text: string) => {
const { Project } = (await import(/* webpackIgnore: true */ tsMorph)) as typeof import('ts-morph');
const { getElements, getExports } =
- config.github === 'https://github.com/mantou132/gem'
- ? await import('gem-analyzer')
- : ((await import(/* webpackIgnore: true */ gemAnalyzer)) as typeof import('gem-analyzer'));
+ // 如何在当前项目使用本地依赖?
+ // webpackIgnore.config.github === 'https://github.com/mantou132/gem'
+ // ? require('gem-analyzer')
+ // :
+ (await import(/* webpackIgnore: true */ gemAnalyzer)) as typeof import('gem-analyzer');
const project = new Project({ useInMemoryFileSystem: true });
const file = project.createSourceFile(this.src, text);
return { elements: getElements(file), exports: getExports(file) };
diff --git a/packages/gem-devtools/package.json b/packages/gem-devtools/package.json
index 9ef0ce52..ba61a672 100644
--- a/packages/gem-devtools/package.json
+++ b/packages/gem-devtools/package.json
@@ -1,6 +1,6 @@
{
"name": "gem-devtools",
- "version": "1.7.4",
+ "version": "1.7.5",
"description": "Gem devtools",
"scripts": {
"update:version": "node ./scripts/update.js",
@@ -11,7 +11,7 @@
"start": "yarn build && concurrently -k npm:watch npm:browser"
},
"dependencies": {
- "@mantou/gem": "^1.7.6",
+ "@mantou/gem": "^1.7.8",
"webextension-polyfill": "^0.10.0"
},
"devDependencies": {
diff --git a/packages/gem-examples/package.json b/packages/gem-examples/package.json
index 670a97f3..b2c268f9 100644
--- a/packages/gem-examples/package.json
+++ b/packages/gem-examples/package.json
@@ -1,15 +1,15 @@
{
"private": true,
"name": "gem-examples",
- "version": "1.7.4",
+ "version": "1.7.5",
"description": "gem examples",
"scripts": {
"build": "vite build",
"start": "vite serve"
},
"dependencies": {
- "@mantou/gem": "^1.7.6",
- "duoyun-ui": "^1.1.7"
+ "@mantou/gem": "^1.7.8",
+ "duoyun-ui": "^1.1.8"
},
"devDependencies": {
"@gemjs/config": "^1.6.11",
diff --git a/packages/gem-port/package.json b/packages/gem-port/package.json
index 5bedb3a0..14a07c42 100644
--- a/packages/gem-port/package.json
+++ b/packages/gem-port/package.json
@@ -1,6 +1,6 @@
{
"name": "gem-port",
- "version": "0.0.5",
+ "version": "0.0.6",
"description": "Export React component",
"keywords": [
"gem",
@@ -21,7 +21,7 @@
"dependencies": {
"@gemjs/config": "^1.6.11",
"commander": "^7.2.0",
- "gem-analyzer": "^1.7.5",
+ "gem-analyzer": "^1.7.6",
"ts-morph": "^13.0.0",
"typescript": "^4.5.0"
},
diff --git a/packages/gem/package.json b/packages/gem/package.json
index 50e265c7..2f660ad2 100644
--- a/packages/gem/package.json
+++ b/packages/gem/package.json
@@ -1,6 +1,6 @@
{
"name": "@mantou/gem",
- "version": "1.7.7",
+ "version": "1.7.8",
"description": "💎 使用自定义元素的轻量级 WebApp 开发框架",
"keywords": [
"frontend",