Skip to content

Commit 1800787

Browse files
committed
Fix cli visibility selection bug & refactor action runner
1 parent 231ed77 commit 1800787

File tree

9 files changed

+46
-21
lines changed

9 files changed

+46
-21
lines changed

npm-packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pulse-editor/cli",
3-
"version": "0.1.1-beta.0",
3+
"version": "0.1.1-beta.1",
44
"license": "MIT",
55
"bin": {
66
"pulse": "dist/cli.js"

npm-packages/cli/source/components/commands/create.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,23 @@ export default function Create({cli}: {cli: Result<Flags>}) {
125125
<Text> Initializing project...</Text>
126126
</Box>,
127127
);
128+
129+
/* Setup pulse.config.ts */
130+
const pulseConfigPath = path.join(process.cwd(), name, 'pulse.config.ts');
131+
let pulseConfig = fs.readFileSync(pulseConfigPath, 'utf8');
132+
// Modify visibility by matching the block that starts with 'visibility:',
133+
// and replacing the entire line with the new visibility value.
134+
pulseConfig = pulseConfig.replace(
135+
/visibility:\s*['"`](public|unlisted|private)['"`],?/,
136+
`visibility: '${visibility}',`,
137+
);
138+
fs.writeFileSync(pulseConfigPath, pulseConfig);
139+
140+
/* Setup packages.json */
128141
const packageJsonPath = path.join(process.cwd(), name, 'package.json');
129142
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
130143
packageJson.name = name.replaceAll('-', '_');
131144

132-
// Modify the visibility
133-
packageJson['pulse-editor-marketplace'] = {
134-
visibility,
135-
};
136-
137145
// Write the modified package.json back to the file
138146
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
139147

web/components/interface/command-viewer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import usePlatformAIAssistant from "@/lib/hooks/use-platform-ai-assistant";
2-
import useScopedActions from "@/lib/hooks/use-scoped-actions";
2+
import useActionExecutor from "@/lib/hooks/use-action-executor";
33
import { ScopedAction } from "@/lib/types";
44
import {
55
addToast,
@@ -28,7 +28,7 @@ export default function CommandViewer() {
2828
const editorContext = useContext(EditorContext);
2929

3030
const { chatWithAssistant, history } = usePlatformAIAssistant();
31-
const { actions, runScopedAction, setKeywordFilter } = useScopedActions();
31+
const { actions, runScopedAction, setKeywordFilter } = useActionExecutor();
3232

3333
const [inputPlaceholder, setInputPlaceholder] = useState("");
3434
const [selectActionIndex, setSelectActionIndex] = useState(-1);

web/components/marketplace/app/app-preview-card.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ContextMenuState, ExtensionApp } from "@/lib/types";
1414
import { DraggableAttributes } from "@dnd-kit/core";
1515
import { SyntheticListenerMap } from "@dnd-kit/core/dist/hooks/utilities";
1616
import {
17+
addToast,
1718
Button,
1819
Chip,
1920
Skeleton,
@@ -369,7 +370,11 @@ export default function AppPreviewCard({
369370
extension.config.version,
370371
)
371372
.then(() => {
372-
toast.success("Extension installed");
373+
addToast({
374+
title: "Extension installed",
375+
description: `Extension ${extension.config.id} installed successfully.`,
376+
color: "success",
377+
});
373378
setIsInstalled(true);
374379
setIsEnabled(extension.isEnabled);
375380
})
@@ -387,7 +392,11 @@ export default function AppPreviewCard({
387392
size="sm"
388393
onPress={(e) => {
389394
uninstallExtension(extension.config.id).then(() => {
390-
toast.success("Extension uninstalled");
395+
addToast({
396+
title: "Extension uninstalled",
397+
description: `Extension ${extension.config.id} uninstalled successfully.`,
398+
color: "success",
399+
});
391400
setIsInstalled(false);
392401
});
393402
}}
@@ -407,7 +416,11 @@ export default function AppPreviewCard({
407416
variant="light"
408417
onPress={(e) => {
409418
uninstallExtension(extension.config.id).then(() => {
410-
toast.success("Extension uninstalled");
419+
addToast({
420+
title: "Extension uninstalled",
421+
description: `Extension ${extension.config.id} uninstalled successfully.`,
422+
color: "success",
423+
});
411424
});
412425
setContextMenuState({ x: 0, y: 0, isOpen: false });
413426
}}
@@ -425,7 +438,11 @@ export default function AppPreviewCard({
425438
extension.config.version,
426439
)
427440
.then(() => {
428-
toast.success("Extension installed");
441+
addToast({
442+
title: "Extension installed",
443+
description: `Extension ${extension.config.id} installed successfully.`,
444+
color: "success",
445+
});
429446
setIsInstalled(true);
430447
setIsEnabled(extension.isEnabled);
431448
})

web/components/views/canvas/nodes/app-node/app-node.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import useScopedActions from "@/lib/hooks/use-scoped-actions";
1+
import useActionExecutor from "@/lib/hooks/use-action-executor";
22
import { useTabViewManager } from "@/lib/hooks/use-tab-view-manager";
33
import { AppNodeData } from "@/lib/types";
44
import { Node } from "@xyflow/react";
@@ -19,7 +19,7 @@ const AppNode = memo((props: any) => {
1919
const viewId = config.viewId;
2020

2121
const { createAppTabView, deleteAppViewInCanvasView } = useTabViewManager();
22-
const { actions } = useScopedActions(config.app);
22+
const { actions } = useActionExecutor(config.app);
2323

2424
async function openViewInFullScreen() {
2525
await createAppTabView({

web/components/views/canvas/nodes/backend-node/backend-node.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import BaseAppView from "@/components/views/base/base-app-view";
2-
import useScopedActions from "@/lib/hooks/use-scoped-actions";
2+
import useActionExecutor from "@/lib/hooks/use-action-executor";
33
import { useTabViewManager } from "@/lib/hooks/use-tab-view-manager";
44
import { AppNodeData } from "@/lib/types";
55
import { Node } from "@xyflow/react";
@@ -16,7 +16,7 @@ const BackendNode = memo((props: any) => {
1616
const viewId = config.viewId;
1717

1818
const { createAppTabView, deleteAppViewInCanvasView } = useTabViewManager();
19-
const { actions } = useScopedActions(config.app);
19+
const { actions } = useActionExecutor(config.app);
2020

2121
async function openViewInFullScreen() {
2222
await createAppTabView({

web/lib/hooks/use-scoped-actions.ts renamed to web/lib/hooks/use-action-executor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { useTabViewManager } from "./use-tab-view-manager";
1818
* This hook provides actions from the active tab
1919
* view and static actions from all installed apps.
2020
*/
21-
export default function useScopedActions(appName?: string) {
21+
export default function useActionExecutor(appName?: string) {
2222
const imcContext = useContext(IMCContext);
2323
const editorContext = useContext(EditorContext);
2424

web/lib/hooks/use-canvas-workflow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import {
1111
import { useCallback, useContext, useEffect, useState } from "react";
1212
import { useDebouncedCallback } from "use-debounce";
1313
import { AppNodeData, WorkflowContent } from "../types";
14-
import useScopedActions from "./use-scoped-actions";
14+
import useActionExecutor from "./use-action-executor";
1515

1616
export default function useCanvasWorkflow(
1717
initialWorkflowContent?: WorkflowContent,
1818
) {
1919
const editorContext = useContext(EditorContext);
2020
const imcContext = useContext(IMCContext);
2121

22-
const { runScopedAction } = useScopedActions();
22+
const { runScopedAction } = useActionExecutor();
2323

2424
const [pendingNodes, setPendingNodes] = useState<
2525
ReactFlowNode<AppNodeData>[]

web/lib/hooks/use-platform-ai-assistant.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { ViewModeEnum } from "@pulse-editor/shared-utils";
1919
import { useContext, useEffect, useState } from "react";
2020
import toast from "react-hot-toast";
2121
import { usePlatformApi } from "./use-platform-api";
22-
import useScopedActions from "./use-scoped-actions";
22+
import useActionExecutor from "./use-action-executor";
2323
import useSpeech2Speech from "./use-speech2speech";
2424
import { useTabViewManager } from "./use-tab-view-manager";
2525
import useTTS from "./use-tts";
@@ -36,7 +36,7 @@ export default function usePlatformAIAssistant() {
3636

3737
const { runSpeech2Speech, stopSpeech2Speech, isRunning } = useSpeech2Speech();
3838
const { readText, playAudio } = useTTS();
39-
const { runScopedAction, actions } = useScopedActions();
39+
const { runScopedAction, actions } = useActionExecutor();
4040
const { activeTabView } = useTabViewManager();
4141

4242
const [pendingAnalysis, setPendingAnalysis] = useState("");

0 commit comments

Comments
 (0)