mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-01 17:50:50 +08:00
chore: add monorepo tools (#9196)
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import('@affine/bump-blocksuite');
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cargo update -p jwst-codec -p jwst-core -p jwst-storage
|
||||
@@ -1,15 +0,0 @@
|
||||
const semver = await import('semver').catch(
|
||||
() => import('../packages/backend/server/node_modules/semver/index.js')
|
||||
);
|
||||
|
||||
import packageJson from '../package.json' with { type: 'json' };
|
||||
|
||||
const { engines } = packageJson;
|
||||
|
||||
const version = engines.node;
|
||||
if (!semver.satisfies(process.version, version)) {
|
||||
console.log(
|
||||
`Required node version ${version} not satisfied with current version ${process.version}.`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
const { exec } = await import('node:child_process');
|
||||
const { fileURLToPath } = await import('node:url');
|
||||
const { readdir } = await import('node:fs/promises');
|
||||
const { join } = await import('node:path');
|
||||
|
||||
async function readJsonFromCommit(commit, file) {
|
||||
function readFile(commit, file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(`git show ${commit}:${file}`, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(stderr);
|
||||
} else {
|
||||
resolve(stdout);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const content = await readFile(commit, file);
|
||||
return JSON.parse(content);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
function checkBlocksuiteChanged(oldPkg, newPkg) {
|
||||
const changed = new Set();
|
||||
const keys = ['dependencies', 'devDependencies'];
|
||||
|
||||
keys.forEach(key => {
|
||||
const oldDeps = oldPkg[key] || {};
|
||||
const newDeps = newPkg[key] || {};
|
||||
|
||||
Object.keys(newDeps).forEach(dep => {
|
||||
if (newDeps[dep] !== oldDeps[dep] && dep.startsWith('@blocksuite/')) {
|
||||
changed.add(dep);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
async function findPackageJson(root) {
|
||||
const packages = new Set();
|
||||
|
||||
async function walk(dir) {
|
||||
const files = await readdir(dir, { withFileTypes: true });
|
||||
|
||||
for (const file of files) {
|
||||
if (file.isDirectory() && file.name !== 'node_modules') {
|
||||
await walk(join(dir, file.name));
|
||||
} else if (file.name === 'package.json') {
|
||||
let path = join(dir.replace(root, ''), file.name);
|
||||
if (path.startsWith('/')) {
|
||||
path = path.slice(1);
|
||||
}
|
||||
packages.add(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await walk(root);
|
||||
|
||||
return packages;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const commitHash = process.argv[2] || process.env.GITHUB_BASE_REF;
|
||||
const currentHead = process.argv[3] || 'HEAD';
|
||||
if (!commitHash) {
|
||||
console.error('Missing base ref commit hash, skipping check.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const changedPackages = new Set();
|
||||
const folders = await findPackageJson(
|
||||
join(fileURLToPath(import.meta.url), '..', '..')
|
||||
);
|
||||
|
||||
for (const packagePath of folders) {
|
||||
const old = await readJsonFromCommit(commitHash, packagePath);
|
||||
const current = await readJsonFromCommit(currentHead, packagePath);
|
||||
console.log('checking:', packagePath);
|
||||
if (
|
||||
old &&
|
||||
current &&
|
||||
typeof old === 'object' &&
|
||||
typeof current === 'object'
|
||||
) {
|
||||
for (const p of checkBlocksuiteChanged(old, current)) {
|
||||
changedPackages.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changedPackages.size > 0) {
|
||||
console.log('Blocksuite packages have been updated.', changedPackages);
|
||||
process.exit(0);
|
||||
} else {
|
||||
console.log('No changes to Blocksuite packages.');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -1,11 +1,10 @@
|
||||
import { getBuildConfig } from '@affine/cli/src/webpack/runtime-config';
|
||||
import { setupGlobal } from '@affine/env/global';
|
||||
import { getBuildConfig } from '@affine-tools/utils/build-config';
|
||||
import { Package } from '@affine-tools/utils/workspace';
|
||||
|
||||
globalThis.BUILD_CONFIG = getBuildConfig({
|
||||
distribution: 'web',
|
||||
globalThis.BUILD_CONFIG = getBuildConfig(new Package('@affine/web'), {
|
||||
mode: 'development',
|
||||
channel: 'canary',
|
||||
static: false,
|
||||
});
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
|
||||
Reference in New Issue
Block a user