@linyjs/plugin-docs 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -5
- package/docs/api-reference/index.md +20 -0
- package/docs/best-practices/error-handling.md +1 -1
- package/docs/best-practices/naming-conventions.md +2 -1
- package/docs/best-practices/performance.md +4 -4
- package/docs/best-practices/service-definition.md +332 -0
- package/docs/faq.md +0 -1
- package/docs/getting-started/first-plugin.md +15 -15
- package/docs/getting-started/installation.md +1 -1
- package/docs/getting-started/quick-start.md +28 -22
- package/docs/guides/authentication.md +428 -0
- package/docs/guides/client-module.md +6 -0
- package/docs/guides/data-persistence.md +104 -43
- package/docs/guides/server-module.md +6 -0
- package/docs/migration/v0-to-v1.md +2 -2
- package/examples/analytics-plugin/src/client/index.tsx +43 -39
- package/examples/analytics-plugin/src/server/index.ts +20 -19
- package/examples/blog-plugin/README.md +7 -4
- package/examples/blog-plugin/package.json +1 -1
- package/examples/blog-plugin/src/client/index.tsx +44 -40
- package/examples/blog-plugin/src/server/index.ts +8 -8
- package/examples/hello-world/src/client/index.tsx +8 -8
- package/examples/hello-world/src/server/index.ts +8 -8
- package/package.json +10 -6
- package/src/cli.ts +12 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IModule } from '@linyjs/server-module-interface';
|
|
1
|
+
import type { IModule, IServiceDef } from '@linyjs/server-module-interface';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Hello World 控制器
|
|
@@ -27,16 +27,16 @@ class HelloController {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
const helloControllerDef: IServiceDef = {
|
|
31
|
+
serviceTag: 'helloController',
|
|
32
|
+
serviceImpl: HelloController,
|
|
33
|
+
meta: { usageType: 'controller' }
|
|
34
|
+
};
|
|
35
|
+
|
|
30
36
|
/**
|
|
31
37
|
* 服务端模块定义
|
|
32
38
|
*/
|
|
33
39
|
export const helloServerModule: IModule = {
|
|
34
40
|
name: 'helloServer',
|
|
35
|
-
serviceDefs: [
|
|
36
|
-
{
|
|
37
|
-
serviceTag: 'helloController',
|
|
38
|
-
serviceImpl: HelloController,
|
|
39
|
-
meta: { usageType: 'controller' }
|
|
40
|
-
}
|
|
41
|
-
]
|
|
41
|
+
serviceDefs: [helloControllerDef]
|
|
42
42
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linyjs/plugin-docs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Plugin development documentation and examples for linyjs framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"linyjs",
|
|
@@ -27,16 +27,20 @@
|
|
|
27
27
|
},
|
|
28
28
|
"main": "src/cli.ts",
|
|
29
29
|
"type": "module",
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc"
|
|
32
|
+
},
|
|
30
33
|
"peerDependencies": {
|
|
31
|
-
"@linyjs/
|
|
32
|
-
"@linyjs/
|
|
33
|
-
"@linyjs/ui-slots-interface": "0.0.
|
|
34
|
+
"@linyjs/client-module-interface": "0.0.11",
|
|
35
|
+
"@linyjs/server-module-interface": "0.0.11",
|
|
36
|
+
"@linyjs/ui-slots-interface": "0.0.11"
|
|
34
37
|
},
|
|
35
38
|
"dependencies": {
|
|
36
39
|
"commander": "^11.1.0"
|
|
37
40
|
},
|
|
38
41
|
"devDependencies": {
|
|
39
|
-
"
|
|
40
|
-
"@types/node": "^20.10.0"
|
|
42
|
+
"@types/commander": "^2.12.0",
|
|
43
|
+
"@types/node": "^20.10.0",
|
|
44
|
+
"typescript": "^5.7.0"
|
|
41
45
|
}
|
|
42
46
|
}
|
package/src/cli.ts
CHANGED
|
@@ -104,9 +104,9 @@ function searchDocs(keyword: string): void {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.error(`Error searching in directory ${dir}:`, String(error));
|
|
109
|
+
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
searchInDirectory(docsDir);
|
|
@@ -167,9 +167,9 @@ function listExamples(): void {
|
|
|
167
167
|
console.log('\n💡 使用命令:');
|
|
168
168
|
console.log(' example <name> 生成示例到当前目录');
|
|
169
169
|
console.log(' example <name> -o <dir> 生成示例到指定目录');
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
} catch (error) {
|
|
171
|
+
console.error('❌ 读取示例列表失败:', String(error));
|
|
172
|
+
}
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
// 生成示例项目
|
|
@@ -235,9 +235,9 @@ async function copyDirectory(source: string, target: string): Promise<void> {
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
} catch (error) {
|
|
239
|
+
throw new Error(`复制目录失败: ${String(error)}`);
|
|
240
|
+
}
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
// 设置CLI命令
|
|
@@ -253,7 +253,7 @@ program
|
|
|
253
253
|
.option('--open', '在浏览器中打开在线文档')
|
|
254
254
|
.option('--list', '列出所有文档分类')
|
|
255
255
|
.argument('[keyword]', '搜索关键词')
|
|
256
|
-
.action((keyword, options) => {
|
|
256
|
+
.action((keyword: string | undefined, options: { open?: boolean; list?: boolean }) => {
|
|
257
257
|
if (options.open) {
|
|
258
258
|
console.log('🌐 正在打开在线文档...');
|
|
259
259
|
const docsUrl = 'https://github.com/linyjs/linyjs/tree/main/packages/plugin-docs/docs';
|
|
@@ -270,11 +270,11 @@ program
|
|
|
270
270
|
.command('example <name>')
|
|
271
271
|
.description('生成示例项目')
|
|
272
272
|
.option('-o, --output <directory>', '指定输出目录')
|
|
273
|
-
.action(async (name, options) => {
|
|
273
|
+
.action(async (name: string, options: { output?: string }) => {
|
|
274
274
|
try {
|
|
275
275
|
await generateExample(name, options.output);
|
|
276
276
|
} catch (error) {
|
|
277
|
-
console.error('❌ 生成示例失败:', error
|
|
277
|
+
console.error('❌ 生成示例失败:', String(error));
|
|
278
278
|
process.exit(1);
|
|
279
279
|
}
|
|
280
280
|
});
|