Skip to content

Commit dee2c26

Browse files
committed
Support code workflow
1 parent 833f2e9 commit dee2c26

File tree

23 files changed

+166
-93
lines changed

23 files changed

+166
-93
lines changed

.changeset/pre.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"social-donkeys-cross",
6060
"soft-cases-share",
6161
"stale-groups-poke",
62+
"sunny-symbols-flash",
6263
"tender-jeans-occur",
6364
"tender-phones-ring",
6465
"tough-aliens-appear",

.changeset/sunny-symbols-flash.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@pulse-editor/shared-utils": patch
3+
"@pulse-editor/react-api": patch
4+
---
5+
6+
Fix imc intent typo

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.0-beta.4",
3+
"version": "0.1.0-beta.5",
44
"license": "MIT",
55
"bin": {
66
"pulse": "./dist/cli.js"

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,14 @@ export default function Create({cli}: {cli: Result<Flags>}) {
5757

5858
useEffect(() => {
5959
if (framework) {
60-
setIsShowProjectNameInput(true);
60+
const name = cli.flags.name;
61+
if (name) {
62+
setProjectName(name);
63+
} else {
64+
setIsShowProjectNameInput(true);
65+
}
6166
}
62-
}, [framework]);
67+
}, [framework, cli]);
6368

6469
useEffect(() => {
6570
if (projectName) {
@@ -77,9 +82,14 @@ export default function Create({cli}: {cli: Result<Flags>}) {
7782
return;
7883
}
7984

80-
setIsShowVisibilitySelect(true);
85+
const visibility = cli.flags.visibility;
86+
if (visibility) {
87+
setVisibility(visibility);
88+
} else {
89+
setIsShowVisibilitySelect(true);
90+
}
8191
}
82-
}, [projectName]);
92+
}, [projectName, cli]);
8393

8494
useEffect(() => {
8595
if (visibility && projectName) {

npm-packages/cli/source/lib/cli-flags.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ export const flags = defineFlags({
2626
type: 'boolean',
2727
default: false,
2828
},
29+
name: {
30+
type: 'string',
31+
shortFlag: 'n',
32+
},
33+
visibility: {
34+
type: 'string',
35+
shortFlag: 'v',
36+
},
2937
});
3038

3139
export type Flags = typeof flags;

npm-packages/cli/source/lib/manual.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ const create = `\
3838
The framework to use for the new app.
3939
Currently available options: react.
4040
Future options: vue, angular, etc.
41+
--name, -n [project-name]
42+
The name of the new project.
43+
--visibility, -v [visibility]
44+
The visibility of the new project. Options are private,
45+
public, and unlisted.
4146
`;
4247

4348
export const commandsManual: Record<string, string> = {

npm-packages/react-api/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @pulse-editor/react-api
22

3+
## 0.1.1-alpha.54
4+
5+
### Patch Changes
6+
7+
- Fix imc intent typo
8+
- Updated dependencies
9+
- @pulse-editor/shared-utils@0.1.1-alpha.54
10+
311
## 0.1.1-alpha.53
412

513
### Patch Changes

npm-packages/react-api/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pulse-editor/react-api",
3-
"version": "0.1.1-alpha.53",
3+
"version": "0.1.1-alpha.54",
44
"main": "dist/main.js",
55
"files": [
66
"dist"
@@ -37,7 +37,7 @@
3737
"typescript-eslint": "^8.30.1"
3838
},
3939
"peerDependencies": {
40-
"@pulse-editor/shared-utils": "0.1.1-alpha.53",
40+
"@pulse-editor/shared-utils": "0.1.1-alpha.54",
4141
"react": "^19.0.0",
4242
"react-dom": "^19.0.0"
4343
}

npm-packages/react-api/src/hooks/editor/use-file.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ export default function useFile(uri: string | undefined) {
3939
});
4040
}
4141
},
42-
[uri, file, isReady]
42+
[uri, file, isReady],
4343
);
4444

4545
// Read file when uri changes
4646
useEffect(() => {
47-
if (isReady) {
47+
if (isReady && uri) {
4848
imc
4949
?.sendMessage(IMCMessageTypeEnum.PlatformReadFile, {
5050
uri,
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
11
import {
2-
AppConfig,
32
IMCMessage,
43
IMCMessageTypeEnum,
4+
ViewModel,
55
} from "@pulse-editor/shared-utils";
66
import { useCallback } from "react";
77
import useIMC from "../imc/use-imc";
88

9-
export default function useOwnedApp() {
9+
export default function useOwnedAppView() {
1010
const receiverHandlerMap = new Map<
1111
IMCMessageTypeEnum,
1212
(senderWindow: Window, message: IMCMessage) => Promise<void>
1313
>([]);
1414

1515
const { imc, isReady } = useIMC(receiverHandlerMap, "owned-app");
1616

17-
const runOwnedAppAction = useCallback(
18-
async (
19-
ownedApp: {
20-
viewId: string;
21-
config: AppConfig;
22-
},
23-
actionName: string,
24-
args: any
25-
) => {
17+
const runAppAction = useCallback(
18+
async (ownedAppViewModel: ViewModel, actionName: string, args: any) => {
2619
if (isReady) {
27-
const appViewId = ownedApp.viewId;
28-
const preRegisteredActions = ownedApp.config.preRegisteredActions || [];
20+
const appViewId = ownedAppViewModel.viewId;
21+
const preRegisteredActions =
22+
ownedAppViewModel.appConfig.preRegisteredActions || [];
2923

3024
const action = preRegisteredActions.find((a) => a.name === actionName);
3125
if (!action) {
3226
throw new Error(
33-
`Action ${actionName} not found in owned app ${ownedApp.config.id}`
27+
`Action ${actionName} not found in owned app ${ownedAppViewModel.appConfig.id}`,
3428
);
3529
}
3630

@@ -40,16 +34,16 @@ export default function useOwnedApp() {
4034
viewId: appViewId,
4135
actionName,
4236
args,
43-
}
37+
},
4438
);
4539
return result;
4640
}
4741
return undefined;
4842
},
49-
[imc, isReady]
43+
[imc, isReady],
5044
);
5145

5246
return {
53-
runOwnedAppAction,
47+
runAppAction,
5448
};
5549
}

0 commit comments

Comments
 (0)