@pulse-editor/cli 0.1.1-beta.29 → 0.1.1-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,12 +10,14 @@ import path from 'path';
|
|
|
10
10
|
export default function Create({ cli }) {
|
|
11
11
|
const [framework, setFramework] = useState(undefined);
|
|
12
12
|
const [projectName, setProjectName] = useState(undefined);
|
|
13
|
+
const [displayName, setDisplayName] = useState(undefined);
|
|
13
14
|
const [visibility, setVisibility] = useState(undefined);
|
|
14
15
|
const projectPath = useMemo(() => {
|
|
15
16
|
return cli.flags.path ?? projectName;
|
|
16
17
|
}, [projectName, cli]);
|
|
17
18
|
const [isShowFrameworkSelect, setIsShowFrameworkSelect] = useState(true);
|
|
18
19
|
const [isShowProjectNameInput, setIsShowProjectNameInput] = useState(false);
|
|
20
|
+
const [isShowDisplayNameInput, setIsShowDisplayNameInput] = useState(false);
|
|
19
21
|
const [isShowVisibilitySelect, setIsShowVisibilitySelect] = useState(false);
|
|
20
22
|
const [createMessage, setCreateMessage] = useState();
|
|
21
23
|
const [errorMessage, setErrorMessage] = useState();
|
|
@@ -71,6 +73,17 @@ export default function Create({ cli }) {
|
|
|
71
73
|
}, 0);
|
|
72
74
|
return;
|
|
73
75
|
}
|
|
76
|
+
const displayName = cli.flags.displayName;
|
|
77
|
+
if (displayName) {
|
|
78
|
+
setDisplayName(displayName);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
setIsShowDisplayNameInput(true);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, [projectName, cli]);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (displayName) {
|
|
74
87
|
const visibility = cli.flags.visibility;
|
|
75
88
|
if (visibility) {
|
|
76
89
|
setVisibility(visibility);
|
|
@@ -79,7 +92,7 @@ export default function Create({ cli }) {
|
|
|
79
92
|
setIsShowVisibilitySelect(true);
|
|
80
93
|
}
|
|
81
94
|
}
|
|
82
|
-
}, [
|
|
95
|
+
}, [displayName, cli]);
|
|
83
96
|
useEffect(() => {
|
|
84
97
|
if (visibility && projectName) {
|
|
85
98
|
createFromTemplate(projectName, visibility);
|
|
@@ -113,6 +126,7 @@ export default function Create({ cli }) {
|
|
|
113
126
|
const packageJsonPath = path.join(process.cwd(), projectPath, 'package.json');
|
|
114
127
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
115
128
|
packageJson.name = name.replaceAll('-', '_');
|
|
129
|
+
packageJson.displayName = displayName;
|
|
116
130
|
// Write the modified package.json back to the file
|
|
117
131
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
118
132
|
// Remove the .git directory
|
|
@@ -145,7 +159,7 @@ export default function Create({ cli }) {
|
|
|
145
159
|
setCreateMessage(_jsx(Text, { children: "\uD83D\uDE80 Pulse Editor React app project created successfully!" }));
|
|
146
160
|
}
|
|
147
161
|
}
|
|
148
|
-
return (_jsxs(_Fragment, { children: [isShowFrameworkSelect && (_jsx(FrameworkSelect, { cli: cli, frameworkItems: frameworkItems, framework: framework, setFramework: setFramework })), isShowProjectNameInput && (_jsx(ProjectNameInput, { projectName: projectName, setProjectName: setProjectName })), isShowVisibilitySelect && (_jsx(VisibilitySelect, { visibility: visibility, setVisibility: setVisibility })), visibility !== undefined && (_jsxs(_Fragment, { children: [framework === 'react' && _jsx(_Fragment, { children: createMessage }), framework !== 'react' && (_jsx(Text, { children: "\uD83D\uDEA7 Currently not available. We'd like to invite you to work on these frameworks if you are interested in! Check out our tutorial to integrate your favorite web framework with Pulse Editor using Module Federation." }))] })), _jsx(Text, { children: errorMessage })] }));
|
|
162
|
+
return (_jsxs(_Fragment, { children: [isShowFrameworkSelect && (_jsx(FrameworkSelect, { cli: cli, frameworkItems: frameworkItems, framework: framework, setFramework: setFramework })), isShowProjectNameInput && (_jsx(ProjectNameInput, { projectName: projectName, setProjectName: setProjectName })), isShowDisplayNameInput && (_jsx(DisplayNameInput, { projectName: projectName ?? '', displayName: displayName, setDisplayName: setDisplayName })), isShowVisibilitySelect && (_jsx(VisibilitySelect, { visibility: visibility, setVisibility: setVisibility })), visibility !== undefined && (_jsxs(_Fragment, { children: [framework === 'react' && _jsx(_Fragment, { children: createMessage }), framework !== 'react' && (_jsx(Text, { children: "\uD83D\uDEA7 Currently not available. We'd like to invite you to work on these frameworks if you are interested in! Check out our tutorial to integrate your favorite web framework with Pulse Editor using Module Federation." }))] })), _jsx(Text, { children: errorMessage })] }));
|
|
149
163
|
}
|
|
150
164
|
function FrameworkSelect({ cli, frameworkItems, framework, setFramework, }) {
|
|
151
165
|
return (_jsx(_Fragment, { children: !cli.flags.framework && (_jsxs(_Fragment, { children: [_jsx(Text, { children: "\uD83D\uDEA9Create a new Pulse Editor app using your favorite web framework!" }), _jsx(SelectInput, { items: frameworkItems, onSelect: item => {
|
|
@@ -155,6 +169,9 @@ function FrameworkSelect({ cli, frameworkItems, framework, setFramework, }) {
|
|
|
155
169
|
function ProjectNameInput({ projectName, setProjectName, }) {
|
|
156
170
|
return (_jsx(_Fragment, { children: _jsxs(Box, { children: [_jsx(Text, { children: "Enter your project name: " }), _jsx(UncontrolledTextInput, { onSubmit: value => setTimeout(() => setProjectName(value), 0), focus: projectName === undefined })] }) }));
|
|
157
171
|
}
|
|
172
|
+
function DisplayNameInput({ projectName, displayName, setDisplayName, }) {
|
|
173
|
+
return (_jsx(_Fragment, { children: _jsxs(Box, { children: [_jsxs(Text, { children: ["Enter your project display name: (default: ", projectName, ")"] }), _jsx(UncontrolledTextInput, { onSubmit: value => setTimeout(() => setDisplayName(value.length > 0 ? value : projectName), 0), focus: displayName === undefined })] }) }));
|
|
174
|
+
}
|
|
158
175
|
function VisibilitySelect({ visibility, setVisibility, }) {
|
|
159
176
|
return (_jsxs(_Fragment, { children: [_jsx(Text, { children: "Enter marketplace visibility for your project:" }), _jsx(SelectInput, { items: [
|
|
160
177
|
{ label: 'Public', value: 'public' },
|
package/dist/lib/cli-flags.d.ts
CHANGED
package/dist/lib/cli-flags.js
CHANGED