Skip to content

Commit

Permalink
Split as monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Aug 29, 2023
1 parent ad599f2 commit 4e4bedc
Show file tree
Hide file tree
Showing 27 changed files with 2,636 additions and 24 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
push:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
cache: yarn
cache-dependency-path: 'yarn.lock'
- name: Test
run: yarn workspace feishu-docx test
18 changes: 18 additions & 0 deletions feishu-docx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Feishu Docx

Convert Feishu Docx into other formats (Markdown, HTML ...)

## Usage

```bash
import { MarkdownRenderer } from 'feishu-docx'

// Load docx JSON from file
const docx = fs.readFileSync('test.json')
const renderer = new MarkdownRenderer(docx)
const text = renderer.parse();
```
## License
MIT
File renamed without changes.
31 changes: 31 additions & 0 deletions feishu-docx/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "feishu-docx",
"version": "0.1.0",
"description": "Generate static pages from Feishu Wiki.",
"main": "dist/index.js",
"repository": {
"url": "https://github.com/huacnlee/feishu-pages"
},
"publisher": "Jason Lee",
"author": {
"name": "Jason Lee",
"email": "huacnlee@gmail.com"
},
"scripts": {
"dev": "tsc && node dist/index.js",
"test": "jest"
},
"dependencies": {
"@types/node": "^20.5.7",
"dotenv": "^16.3.1",
"jsdom": "^22.1.0",
"typescript": "^5.2.2"
},
"devDependencies": {
"@jest/globals": "^29.6.4",
"@types/jsdom": "^21.1.2",
"jest": "^29.6.4",
"ts-jest": "^29.1.1"
},
"license": "MIT"
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class MarkdownRenderer extends Renderer {
buf.write('\n');

let listBlocks = [];
let lastBlock = null;
let lastBlock: any = null;

block.children?.forEach((childId, idx) => {
const child = this.blockMap[childId];
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion src/feishu-docx/types.ts → feishu-docx/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export class Renderer {
blockMap: Record<string, Block> = {};
parentId?: string;
imageTokens: string[];
nextBlock?: Block;
nextBlock?: Block | null;

constructor(doc: any) {
this.documentId = doc?.document?.document_id || '';
Expand All @@ -369,6 +369,10 @@ export class Renderer {
});
}

/**
* Parse Feishu doc to new format
* @returns Text of new format content.
*/
parse(): string {
const entryBlock = this.blockMap[this.documentId];
return this.parseBlock(entryBlock, 0);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, test } from '@jest/globals';
import assert from 'assert';
import fs from 'fs';
import path from 'path';
import { MarkdownRenderer } from '../src/feishu-docx';
import { MarkdownRenderer } from '../src';

const fixture = (filename: string): string => {
return fs.readFileSync(path.join(__dirname, 'fixtures', filename), 'utf8');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions feishu-pages/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "feishu-pages",
"version": "0.1.0",
"description": "Generate static pages from Feishu Wiki.",
"main": "dist/index.js",
"scripts": {
"dev": "tsc && node dist/index.js",
"test": "jest"
},
"dependencies": {
"@larksuiteoapi/node-sdk": "^1.20.0",
"@types/node": "^20.5.7",
"dotenv": "^16.3.1",
"typescript": "^5.2.2"
},
"devDependencies": {
"@jest/globals": "^29.6.4",
"jest": "^29.6.4",
"ts-jest": "^29.1.1"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions feishu-pages/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "es6",
"noImplicitAny": false,
"moduleResolution": "node",
"outDir": "dist",
"baseUrl": ".",
"paths": {
"*": ["node_modules/*", "src/types/*"]
}
},
"include": ["src/**/*"]
}
Loading

0 comments on commit 4e4bedc

Please sign in to comment.