mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 21:38:44 +08:00
chore: move client folders (#948)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/* 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 clientAppDirectory = path.join(__dirname, '..');
|
||||
const publicDistributionDirectory = path.join(clientAppDirectory, 'public');
|
||||
const affineSrcDirectory = path.join(repoDirectory, 'packages', 'app');
|
||||
const affineSrcOutDirectory = path.join(affineSrcDirectory, 'out');
|
||||
const publicAffineOutDirectory = path.join(
|
||||
publicDistributionDirectory,
|
||||
'affine-out'
|
||||
);
|
||||
|
||||
/**
|
||||
* Build affine dist html
|
||||
*/
|
||||
cd(repoDirectory);
|
||||
await $`pnpm i -r`;
|
||||
await $`pnpm build`;
|
||||
cd(affineSrcDirectory);
|
||||
$.env.BASE_PATH = '/affine-out';
|
||||
await $`pnpm build`;
|
||||
await $`pnpm export`;
|
||||
await fs.remove(publicAffineOutDirectory);
|
||||
await fs.move(affineSrcOutDirectory, publicAffineOutDirectory);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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}`;
|
||||
await $`git reset --hard origin/${octoBaseBranchName}`;
|
||||
@@ -0,0 +1,53 @@
|
||||
/* 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';
|
||||
|
||||
const projectRoot = path.join(__dirname, '..', '..');
|
||||
const tsTypingsFolder = path.join(
|
||||
projectRoot,
|
||||
'packages/data-center/src/provider/tauri-ipc/ipc/types'
|
||||
);
|
||||
|
||||
/**
|
||||
* 1. generate JSONSchema using rs crate `schemars`, this happened on rs side script `src-tauri/examples/generate-jsonschema.rs`
|
||||
*/
|
||||
cd('./src-tauri');
|
||||
try {
|
||||
fs.mkdirSync(tsTypingsFolder);
|
||||
} catch {}
|
||||
await $`cargo run --example generate-jsonschema`;
|
||||
|
||||
/**
|
||||
* 2. generate TS from JSON schema, this is efficient on NodeJS side.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
cd(path.join(projectRoot, 'packages/data-center'));
|
||||
await $`eslint ${tsTypingsFolder} --ext ts --fix`;
|
||||
|
||||
/**
|
||||
* 4. // TODO: parse all #[tauri::command] and generate ts method code
|
||||
*/
|
||||
Reference in New Issue
Block a user