mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
feat: add basic tauri client app
This commit is contained in:
17
client-app/scripts/buildSubModules.mjs
Normal file
17
client-app/scripts/buildSubModules.mjs
Normal file
@@ -0,0 +1,17 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
const repoDirectory = path.join(__dirname, '..');
|
||||
const publicDistributionDirectory = path.join(repoDirectory, 'public');
|
||||
|
||||
const octoBaseBranchName = 'master';
|
||||
/**
|
||||
* 1. Until OctoBase become public, we link it using submodule too.
|
||||
*/
|
||||
cd(`${path.join(repoDirectory, 'src-OctoBase')}`);
|
||||
await $`git checkout ${octoBaseBranchName}`;
|
||||
await $`git submodule update --recursive && git submodule update --remote`;
|
||||
await $`git pull origin ${octoBaseBranchName}`;
|
||||
44
client-app/scripts/generateTsTypingsFromJsonSchema.mjs
Normal file
44
client-app/scripts/generateTsTypingsFromJsonSchema.mjs
Normal file
@@ -0,0 +1,44 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
// TODO: use https://github.com/quicktype/quicktype#installation instead
|
||||
import { compileFromFile } from 'json-schema-to-typescript';
|
||||
import { cd } from 'zx/core';
|
||||
|
||||
/**
|
||||
* 1. generate JSONSchema using rs crate `schemars`, this happened on rs side script `src-tauri/examples/generate-jsonschema.rs`
|
||||
*/
|
||||
cd('./src-tauri');
|
||||
await $`cargo run --example generate-jsonschema`;
|
||||
|
||||
/**
|
||||
* 2. generate TS from JSON schema, this is efficient on NodeJS side.
|
||||
*/
|
||||
const tsTypingsFolder = path.join(__dirname, '..', 'src', 'types', 'ipc');
|
||||
const fileNames = fs.readdirSync(tsTypingsFolder);
|
||||
const jsonSchemaFilePaths = fileNames
|
||||
.filter(fileName => fileName.endsWith('.json'))
|
||||
.map(fileName => path.join(tsTypingsFolder, fileName));
|
||||
|
||||
await Promise.all(
|
||||
jsonSchemaFilePaths.map(
|
||||
async fileName =>
|
||||
await compileFromFile(fileName).then(tsContent =>
|
||||
fs.writeFileSync(fileName.replace('.json', '.ts'), tsContent)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* 3. fix eslint error on generated ts files
|
||||
*/
|
||||
await $`eslint ${tsTypingsFolder} --ext ts --fix`;
|
||||
|
||||
/**
|
||||
* 4. // TODO: parse all #[tauri::command] and generate ts method code
|
||||
*/
|
||||
Reference in New Issue
Block a user