fix(cli): create empty plugin directory
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { ok } from 'node:assert';
|
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 path from 'node:path';
|
||||||
import { parseArgs } from 'node:util';
|
import { parseArgs } from 'node:util';
|
||||||
|
|
||||||
@@ -95,14 +96,9 @@ const metadata: Metadata = {
|
|||||||
assets: new Set(),
|
assets: new Set(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const coreOutDir = path.resolve(
|
const outDir = path.resolve(projectRoot, 'apps', 'core', 'public', 'plugins');
|
||||||
projectRoot,
|
|
||||||
'apps',
|
const coreOutDir = path.resolve(outDir, plugin);
|
||||||
'core',
|
|
||||||
'public',
|
|
||||||
'plugins',
|
|
||||||
plugin
|
|
||||||
);
|
|
||||||
|
|
||||||
const serverOutDir = path.resolve(
|
const serverOutDir = path.resolve(
|
||||||
projectRoot,
|
projectRoot,
|
||||||
@@ -113,7 +109,7 @@ const serverOutDir = path.resolve(
|
|||||||
plugin
|
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);
|
const coreEntry = path.resolve(pluginDir, json.affinePlugin.entry.core);
|
||||||
if (json.affinePlugin.entry.server) {
|
if (json.affinePlugin.entry.server) {
|
||||||
@@ -168,7 +164,10 @@ await build({
|
|||||||
{
|
{
|
||||||
name: 'generate-list-json',
|
name: 'generate-list-json',
|
||||||
async generateBundle() {
|
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({
|
const txt = await file.readFile({
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user