Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(cli): create empty plugin directory

Alex Yang3a64b43032c5
diff --git a/packages/cli/src/bin/dev-plugin.ts b/packages/cli/src/bin/dev-plugin.ts
index 8e650047fd..f71cfe060d 100644
--- a/packages/cli/src/bin/dev-plugin.ts
+++ b/packages/cli/src/bin/dev-plugin.ts
@@ -1,5 +1,6 @@
import { ok } from 'node:assert';
-import { open, readFile } from 'node:fs/promises';
+import { existsSync } from 'node:fs';
+import { mkdir, open, readFile } from 'node:fs/promises';
import path from 'node:path';
import { parseArgs } from 'node:util';
@@ -95,14 +96,9 @@ const metadata: Metadata = {
assets: new Set(),
};
-const coreOutDir = path.resolve(
- projectRoot,
- 'apps',
- 'core',
- 'public',
- 'plugins',
- plugin
-);
+const outDir = path.resolve(projectRoot, 'apps', 'core', 'public', 'plugins');
+
+const coreOutDir = path.resolve(outDir, plugin);
const serverOutDir = path.resolve(
projectRoot,
@@ -113,7 +109,7 @@ const serverOutDir = path.resolve(
plugin
);
-const pluginListJsonPath = path.resolve(coreOutDir, '..', 'plugin-list.json');
+const pluginListJsonPath = path.resolve(outDir, 'plugin-list.json');
const coreEntry = path.resolve(pluginDir, json.affinePlugin.entry.core);
if (json.affinePlugin.entry.server) {
@@ -168,7 +164,10 @@ await build({
{
name: 'generate-list-json',
async generateBundle() {
- const file = await open(pluginListJsonPath, 'as+');
+ if (!existsSync(outDir)) {
+ await mkdir(outDir, { recursive: true });
+ }
+ const file = await open(pluginListJsonPath, 'w+', 0o777);
const txt = await file.readFile({
encoding: 'utf-8',
});