@superdesign/cli 0.1.3 → 0.1.5
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.
- package/dist/config/constants.d.ts +1 -1
- package/dist/index.cjs +91 -107
- package/dist/index.js +91 -107
- package/dist/utils/job-runner.d.ts +6 -0
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ export declare const POLL_TIMEOUT_MS: number;
|
|
|
12
12
|
export declare const AUTH_POLL_INTERVAL_MS = 2000;
|
|
13
13
|
export declare const AUTH_POLL_TIMEOUT_MS: number;
|
|
14
14
|
/** CLI version - should match package.json */
|
|
15
|
-
export declare const CLI_VERSION = "0.1.
|
|
15
|
+
export declare const CLI_VERSION = "0.1.5";
|
|
16
16
|
/** Config directory name */
|
|
17
17
|
export declare const CONFIG_DIR_NAME = ".superdesign";
|
|
18
18
|
/** Config file name */
|
package/dist/index.cjs
CHANGED
|
@@ -313,7 +313,7 @@ var __webpack_exports__ = {};
|
|
|
313
313
|
try {
|
|
314
314
|
startSpinner('Creating auth session...');
|
|
315
315
|
const session = await createSession({
|
|
316
|
-
cliVersion: "0.1.
|
|
316
|
+
cliVersion: "0.1.5",
|
|
317
317
|
os: `${external_os_namespaceObject.platform()} ${external_os_namespaceObject.release()}`,
|
|
318
318
|
hostname: external_os_namespaceObject.hostname()
|
|
319
319
|
});
|
|
@@ -866,102 +866,6 @@ superdesign get-design --draft-id <id> --json
|
|
|
866
866
|
const response = await client.post(`/external/projects/${projectId}/drafts/add`, data);
|
|
867
867
|
return response.data;
|
|
868
868
|
}
|
|
869
|
-
function createCreateProjectCommand() {
|
|
870
|
-
const command = new external_commander_namespaceObject.Command('create-project').description('Create a new SuperDesign project').requiredOption('--title <title>', 'Project title').option('--html <html>', 'Initial HTML content for first draft').option('--html-file <path>', 'Path to HTML file for first draft').option('--prompt <prompt>', 'System prompt for the AI agent').option('--prompt-file <path>', 'Path to markdown file containing system prompt').option('--device <mode>', 'Device mode for draft (mobile, tablet, desktop)', 'desktop').option('--json', 'Output in JSON format').option('--no-open', 'Do not open project in browser after creation').action(async (options)=>{
|
|
871
|
-
if (options.json) setJsonMode(true);
|
|
872
|
-
try {
|
|
873
|
-
if (!manager_isAuthenticated()) {
|
|
874
|
-
output_error('Not authenticated. Run `superdesign login` first.');
|
|
875
|
-
process.exit(EXIT_CODES.AUTH_REQUIRED);
|
|
876
|
-
}
|
|
877
|
-
if (options.device && ![
|
|
878
|
-
'mobile',
|
|
879
|
-
'tablet',
|
|
880
|
-
'desktop'
|
|
881
|
-
].includes(options.device)) {
|
|
882
|
-
output_error('Invalid device mode. Must be: mobile, tablet, or desktop');
|
|
883
|
-
process.exit(EXIT_CODES.VALIDATION_ERROR);
|
|
884
|
-
}
|
|
885
|
-
let htmlContent;
|
|
886
|
-
if (options.htmlFile) {
|
|
887
|
-
if (!external_fs_namespaceObject.existsSync(options.htmlFile)) {
|
|
888
|
-
output_error(`HTML file not found: ${options.htmlFile}`);
|
|
889
|
-
process.exit(EXIT_CODES.VALIDATION_ERROR);
|
|
890
|
-
}
|
|
891
|
-
htmlContent = external_fs_namespaceObject.readFileSync(options.htmlFile, 'utf-8');
|
|
892
|
-
} else if (options.html) htmlContent = options.html;
|
|
893
|
-
let promptContent;
|
|
894
|
-
if (options.promptFile) {
|
|
895
|
-
if (!external_fs_namespaceObject.existsSync(options.promptFile)) {
|
|
896
|
-
output_error(`Prompt file not found: ${options.promptFile}`);
|
|
897
|
-
process.exit(EXIT_CODES.VALIDATION_ERROR);
|
|
898
|
-
}
|
|
899
|
-
promptContent = external_fs_namespaceObject.readFileSync(options.promptFile, 'utf-8');
|
|
900
|
-
} else if (options.prompt) promptContent = options.prompt;
|
|
901
|
-
startSpinner('Creating project...');
|
|
902
|
-
const project = await createProject({
|
|
903
|
-
title: options.title,
|
|
904
|
-
html: htmlContent,
|
|
905
|
-
prompt: promptContent,
|
|
906
|
-
deviceMode: options.device
|
|
907
|
-
});
|
|
908
|
-
succeedSpinner('Project created successfully!');
|
|
909
|
-
if (options.open) {
|
|
910
|
-
const urlWithLive = `${project.projectUrl}?live=1`;
|
|
911
|
-
await openBrowser(urlWithLive);
|
|
912
|
-
}
|
|
913
|
-
if (isJsonMode()) output({
|
|
914
|
-
projectId: project.projectId,
|
|
915
|
-
title: project.title,
|
|
916
|
-
projectUrl: project.projectUrl,
|
|
917
|
-
shareToken: project.shareToken,
|
|
918
|
-
...project.draftId && {
|
|
919
|
-
draftId: project.draftId,
|
|
920
|
-
previewUrl: project.previewUrl
|
|
921
|
-
}
|
|
922
|
-
});
|
|
923
|
-
else {
|
|
924
|
-
success(`Project "${project.title}" created!`);
|
|
925
|
-
info(`\nProject ID: ${project.projectId}`);
|
|
926
|
-
info(`Project URL: ${project.projectUrl}`);
|
|
927
|
-
if (project.draftId) {
|
|
928
|
-
info(`\nDraft ID: ${project.draftId}`);
|
|
929
|
-
info(`Preview URL: ${project.previewUrl}`);
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
} catch (err) {
|
|
933
|
-
failSpinner('Failed to create project');
|
|
934
|
-
if (err instanceof ApiClientError) {
|
|
935
|
-
output_error(`API Error: ${err.message}`);
|
|
936
|
-
process.exit(EXIT_CODES.API_ERROR);
|
|
937
|
-
}
|
|
938
|
-
const message = err instanceof Error ? err.message : 'Unknown error';
|
|
939
|
-
output_error(message);
|
|
940
|
-
process.exit(EXIT_CODES.GENERAL_ERROR);
|
|
941
|
-
}
|
|
942
|
-
});
|
|
943
|
-
return command;
|
|
944
|
-
}
|
|
945
|
-
async function createDraft(projectId, data) {
|
|
946
|
-
const client = getApiClient();
|
|
947
|
-
const response = await client.post(`/external/projects/${projectId}/drafts/create`, data);
|
|
948
|
-
return response.data;
|
|
949
|
-
}
|
|
950
|
-
async function iterateDraft(draftId, data) {
|
|
951
|
-
const client = getApiClient();
|
|
952
|
-
const response = await client.post(`/external/drafts/${draftId}/iterate`, data);
|
|
953
|
-
return response.data;
|
|
954
|
-
}
|
|
955
|
-
async function planFlowPages(draftId, data) {
|
|
956
|
-
const client = getApiClient();
|
|
957
|
-
const response = await client.post(`/external/drafts/${draftId}/flow/plan`, data);
|
|
958
|
-
return response.data;
|
|
959
|
-
}
|
|
960
|
-
async function executeFlowPages(draftId, data) {
|
|
961
|
-
const client = getApiClient();
|
|
962
|
-
const response = await client.post(`/external/drafts/${draftId}/flow/execute`, data);
|
|
963
|
-
return response.data;
|
|
964
|
-
}
|
|
965
869
|
async function getJobStatus(jobId) {
|
|
966
870
|
const client = getApiClient();
|
|
967
871
|
const response = await client.get(`/external/jobs/${jobId}`);
|
|
@@ -1051,18 +955,98 @@ superdesign get-design --draft-id <id> --json
|
|
|
1051
955
|
else output_error(`${failureMessage}: ${message}`);
|
|
1052
956
|
process.exit(EXIT_CODES.GENERAL_ERROR);
|
|
1053
957
|
}
|
|
1054
|
-
|
|
1055
|
-
|
|
958
|
+
const VALID_DEVICES = [
|
|
959
|
+
'mobile',
|
|
960
|
+
'tablet',
|
|
961
|
+
'desktop'
|
|
962
|
+
];
|
|
963
|
+
function validateDeviceMode(device) {
|
|
964
|
+
if (device && !VALID_DEVICES.includes(device)) {
|
|
965
|
+
output_error('Invalid device mode. Must be: mobile, tablet, or desktop');
|
|
966
|
+
process.exit(EXIT_CODES.VALIDATION_ERROR);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
function readFileContent(filePath, inlineContent, fileType) {
|
|
970
|
+
if (filePath) {
|
|
971
|
+
if (!(0, external_fs_namespaceObject.existsSync)(filePath)) {
|
|
972
|
+
output_error(`${fileType} file not found: ${filePath}`);
|
|
973
|
+
process.exit(EXIT_CODES.VALIDATION_ERROR);
|
|
974
|
+
}
|
|
975
|
+
return (0, external_fs_namespaceObject.readFileSync)(filePath, 'utf-8');
|
|
976
|
+
}
|
|
977
|
+
return inlineContent;
|
|
978
|
+
}
|
|
979
|
+
function createCreateProjectCommand() {
|
|
980
|
+
const command = new external_commander_namespaceObject.Command('create-project').description('Create a new SuperDesign project').requiredOption('--title <title>', 'Project title').option('--html <html>', 'Initial HTML content for first draft').option('--html-file <path>', 'Path to HTML file for first draft').option('-s, --set-project-prompt <prompt>', 'System prompt for the AI agent').option('--set-project-prompt-file <path>', 'Path to markdown file containing system prompt').option('--device <mode>', 'Device mode for draft (mobile, tablet, desktop)', 'desktop').option('--json', 'Output in JSON format').option('--no-open', 'Do not open project in browser after creation').action(async (options)=>{
|
|
1056
981
|
if (options.json) setJsonMode(true);
|
|
1057
982
|
job_runner_requireAuth(manager_isAuthenticated);
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
983
|
+
validateDeviceMode(options.device);
|
|
984
|
+
const htmlContent = readFileContent(options.htmlFile, options.html, 'HTML');
|
|
985
|
+
const promptContent = readFileContent(options.setProjectPromptFile, options.setProjectPrompt, 'Prompt');
|
|
986
|
+
startSpinner('Creating project...');
|
|
987
|
+
try {
|
|
988
|
+
const project = await createProject({
|
|
989
|
+
title: options.title,
|
|
990
|
+
html: htmlContent,
|
|
991
|
+
prompt: promptContent,
|
|
992
|
+
deviceMode: options.device
|
|
993
|
+
});
|
|
994
|
+
succeedSpinner('Project created successfully!');
|
|
995
|
+
if (options.open) {
|
|
996
|
+
const urlWithLive = `${project.projectUrl}?live=1`;
|
|
997
|
+
await openBrowser(urlWithLive);
|
|
998
|
+
}
|
|
999
|
+
if (isJsonMode()) output({
|
|
1000
|
+
projectId: project.projectId,
|
|
1001
|
+
title: project.title,
|
|
1002
|
+
projectUrl: project.projectUrl,
|
|
1003
|
+
shareToken: project.shareToken,
|
|
1004
|
+
...project.draftId && {
|
|
1005
|
+
draftId: project.draftId,
|
|
1006
|
+
previewUrl: project.previewUrl
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
else {
|
|
1010
|
+
success(`Project "${project.title}" created!`);
|
|
1011
|
+
info(`\nProject ID: ${project.projectId}`);
|
|
1012
|
+
info(`Project URL: ${project.projectUrl}`);
|
|
1013
|
+
if (project.draftId) {
|
|
1014
|
+
info(`\nDraft ID: ${project.draftId}`);
|
|
1015
|
+
info(`Preview URL: ${project.previewUrl}`);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
} catch (err) {
|
|
1019
|
+
failSpinner('Failed to create project');
|
|
1020
|
+
handleApiError(err, 'Failed to create project');
|
|
1065
1021
|
}
|
|
1022
|
+
});
|
|
1023
|
+
return command;
|
|
1024
|
+
}
|
|
1025
|
+
async function createDraft(projectId, data) {
|
|
1026
|
+
const client = getApiClient();
|
|
1027
|
+
const response = await client.post(`/external/projects/${projectId}/drafts/create`, data);
|
|
1028
|
+
return response.data;
|
|
1029
|
+
}
|
|
1030
|
+
async function iterateDraft(draftId, data) {
|
|
1031
|
+
const client = getApiClient();
|
|
1032
|
+
const response = await client.post(`/external/drafts/${draftId}/iterate`, data);
|
|
1033
|
+
return response.data;
|
|
1034
|
+
}
|
|
1035
|
+
async function planFlowPages(draftId, data) {
|
|
1036
|
+
const client = getApiClient();
|
|
1037
|
+
const response = await client.post(`/external/drafts/${draftId}/flow/plan`, data);
|
|
1038
|
+
return response.data;
|
|
1039
|
+
}
|
|
1040
|
+
async function executeFlowPages(draftId, data) {
|
|
1041
|
+
const client = getApiClient();
|
|
1042
|
+
const response = await client.post(`/external/drafts/${draftId}/flow/execute`, data);
|
|
1043
|
+
return response.data;
|
|
1044
|
+
}
|
|
1045
|
+
function createCreateDesignDraftCommand() {
|
|
1046
|
+
const command = new external_commander_namespaceObject.Command('create-design-draft').description('Create a design draft using AI generation').requiredOption('--project-id <id>', 'Project ID').requiredOption('--title <title>', 'Draft title').requiredOption('-p, --prompt <prompt>', 'Design prompt for AI generation').option('--device <mode>', 'Device mode (mobile, tablet, desktop)', 'desktop').option('--json', 'Output in JSON format').action(async (options)=>{
|
|
1047
|
+
if (options.json) setJsonMode(true);
|
|
1048
|
+
job_runner_requireAuth(manager_isAuthenticated);
|
|
1049
|
+
validateDeviceMode(options.device);
|
|
1066
1050
|
await runJob({
|
|
1067
1051
|
startLabel: 'Creating design draft...',
|
|
1068
1052
|
pollingLabel: 'Generating design with AI...',
|
|
@@ -1533,7 +1517,7 @@ superdesign get-design --draft-id <id> --json
|
|
|
1533
1517
|
(0, external_dotenv_namespaceObject.config)();
|
|
1534
1518
|
function createProgram() {
|
|
1535
1519
|
const program = new external_commander_namespaceObject.Command();
|
|
1536
|
-
program.name('superdesign').description('SuperDesign CLI - AI product designer for coding agents').version("0.1.
|
|
1520
|
+
program.name('superdesign').description('SuperDesign CLI - AI product designer for coding agents').version("0.1.5");
|
|
1537
1521
|
program.addCommand(createLoginCommand());
|
|
1538
1522
|
program.addCommand(createLogoutCommand());
|
|
1539
1523
|
program.addCommand(createInitCommand());
|
package/dist/index.js
CHANGED
|
@@ -223,7 +223,7 @@ async function runAuthFlow(options = {}) {
|
|
|
223
223
|
try {
|
|
224
224
|
startSpinner('Creating auth session...');
|
|
225
225
|
const session = await createSession({
|
|
226
|
-
cliVersion: "0.1.
|
|
226
|
+
cliVersion: "0.1.5",
|
|
227
227
|
os: `${platform()} ${release()}`,
|
|
228
228
|
hostname: hostname()
|
|
229
229
|
});
|
|
@@ -776,102 +776,6 @@ async function addDraft(projectId, data) {
|
|
|
776
776
|
const response = await client.post(`/external/projects/${projectId}/drafts/add`, data);
|
|
777
777
|
return response.data;
|
|
778
778
|
}
|
|
779
|
-
function createCreateProjectCommand() {
|
|
780
|
-
const command = new Command('create-project').description('Create a new SuperDesign project').requiredOption('--title <title>', 'Project title').option('--html <html>', 'Initial HTML content for first draft').option('--html-file <path>', 'Path to HTML file for first draft').option('--prompt <prompt>', 'System prompt for the AI agent').option('--prompt-file <path>', 'Path to markdown file containing system prompt').option('--device <mode>', 'Device mode for draft (mobile, tablet, desktop)', 'desktop').option('--json', 'Output in JSON format').option('--no-open', 'Do not open project in browser after creation').action(async (options)=>{
|
|
781
|
-
if (options.json) setJsonMode(true);
|
|
782
|
-
try {
|
|
783
|
-
if (!manager_isAuthenticated()) {
|
|
784
|
-
output_error('Not authenticated. Run `superdesign login` first.');
|
|
785
|
-
process.exit(EXIT_CODES.AUTH_REQUIRED);
|
|
786
|
-
}
|
|
787
|
-
if (options.device && ![
|
|
788
|
-
'mobile',
|
|
789
|
-
'tablet',
|
|
790
|
-
'desktop'
|
|
791
|
-
].includes(options.device)) {
|
|
792
|
-
output_error('Invalid device mode. Must be: mobile, tablet, or desktop');
|
|
793
|
-
process.exit(EXIT_CODES.VALIDATION_ERROR);
|
|
794
|
-
}
|
|
795
|
-
let htmlContent;
|
|
796
|
-
if (options.htmlFile) {
|
|
797
|
-
if (!existsSync(options.htmlFile)) {
|
|
798
|
-
output_error(`HTML file not found: ${options.htmlFile}`);
|
|
799
|
-
process.exit(EXIT_CODES.VALIDATION_ERROR);
|
|
800
|
-
}
|
|
801
|
-
htmlContent = readFileSync(options.htmlFile, 'utf-8');
|
|
802
|
-
} else if (options.html) htmlContent = options.html;
|
|
803
|
-
let promptContent;
|
|
804
|
-
if (options.promptFile) {
|
|
805
|
-
if (!existsSync(options.promptFile)) {
|
|
806
|
-
output_error(`Prompt file not found: ${options.promptFile}`);
|
|
807
|
-
process.exit(EXIT_CODES.VALIDATION_ERROR);
|
|
808
|
-
}
|
|
809
|
-
promptContent = readFileSync(options.promptFile, 'utf-8');
|
|
810
|
-
} else if (options.prompt) promptContent = options.prompt;
|
|
811
|
-
startSpinner('Creating project...');
|
|
812
|
-
const project = await createProject({
|
|
813
|
-
title: options.title,
|
|
814
|
-
html: htmlContent,
|
|
815
|
-
prompt: promptContent,
|
|
816
|
-
deviceMode: options.device
|
|
817
|
-
});
|
|
818
|
-
succeedSpinner('Project created successfully!');
|
|
819
|
-
if (options.open) {
|
|
820
|
-
const urlWithLive = `${project.projectUrl}?live=1`;
|
|
821
|
-
await openBrowser(urlWithLive);
|
|
822
|
-
}
|
|
823
|
-
if (isJsonMode()) output({
|
|
824
|
-
projectId: project.projectId,
|
|
825
|
-
title: project.title,
|
|
826
|
-
projectUrl: project.projectUrl,
|
|
827
|
-
shareToken: project.shareToken,
|
|
828
|
-
...project.draftId && {
|
|
829
|
-
draftId: project.draftId,
|
|
830
|
-
previewUrl: project.previewUrl
|
|
831
|
-
}
|
|
832
|
-
});
|
|
833
|
-
else {
|
|
834
|
-
success(`Project "${project.title}" created!`);
|
|
835
|
-
info(`\nProject ID: ${project.projectId}`);
|
|
836
|
-
info(`Project URL: ${project.projectUrl}`);
|
|
837
|
-
if (project.draftId) {
|
|
838
|
-
info(`\nDraft ID: ${project.draftId}`);
|
|
839
|
-
info(`Preview URL: ${project.previewUrl}`);
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
} catch (err) {
|
|
843
|
-
failSpinner('Failed to create project');
|
|
844
|
-
if (err instanceof ApiClientError) {
|
|
845
|
-
output_error(`API Error: ${err.message}`);
|
|
846
|
-
process.exit(EXIT_CODES.API_ERROR);
|
|
847
|
-
}
|
|
848
|
-
const message = err instanceof Error ? err.message : 'Unknown error';
|
|
849
|
-
output_error(message);
|
|
850
|
-
process.exit(EXIT_CODES.GENERAL_ERROR);
|
|
851
|
-
}
|
|
852
|
-
});
|
|
853
|
-
return command;
|
|
854
|
-
}
|
|
855
|
-
async function createDraft(projectId, data) {
|
|
856
|
-
const client = getApiClient();
|
|
857
|
-
const response = await client.post(`/external/projects/${projectId}/drafts/create`, data);
|
|
858
|
-
return response.data;
|
|
859
|
-
}
|
|
860
|
-
async function iterateDraft(draftId, data) {
|
|
861
|
-
const client = getApiClient();
|
|
862
|
-
const response = await client.post(`/external/drafts/${draftId}/iterate`, data);
|
|
863
|
-
return response.data;
|
|
864
|
-
}
|
|
865
|
-
async function planFlowPages(draftId, data) {
|
|
866
|
-
const client = getApiClient();
|
|
867
|
-
const response = await client.post(`/external/drafts/${draftId}/flow/plan`, data);
|
|
868
|
-
return response.data;
|
|
869
|
-
}
|
|
870
|
-
async function executeFlowPages(draftId, data) {
|
|
871
|
-
const client = getApiClient();
|
|
872
|
-
const response = await client.post(`/external/drafts/${draftId}/flow/execute`, data);
|
|
873
|
-
return response.data;
|
|
874
|
-
}
|
|
875
779
|
async function getJobStatus(jobId) {
|
|
876
780
|
const client = getApiClient();
|
|
877
781
|
const response = await client.get(`/external/jobs/${jobId}`);
|
|
@@ -961,18 +865,98 @@ function handleApiError(err, failureMessage) {
|
|
|
961
865
|
else output_error(`${failureMessage}: ${message}`);
|
|
962
866
|
process.exit(EXIT_CODES.GENERAL_ERROR);
|
|
963
867
|
}
|
|
964
|
-
|
|
965
|
-
|
|
868
|
+
const VALID_DEVICES = [
|
|
869
|
+
'mobile',
|
|
870
|
+
'tablet',
|
|
871
|
+
'desktop'
|
|
872
|
+
];
|
|
873
|
+
function validateDeviceMode(device) {
|
|
874
|
+
if (device && !VALID_DEVICES.includes(device)) {
|
|
875
|
+
output_error('Invalid device mode. Must be: mobile, tablet, or desktop');
|
|
876
|
+
process.exit(EXIT_CODES.VALIDATION_ERROR);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
function readFileContent(filePath, inlineContent, fileType) {
|
|
880
|
+
if (filePath) {
|
|
881
|
+
if (!existsSync(filePath)) {
|
|
882
|
+
output_error(`${fileType} file not found: ${filePath}`);
|
|
883
|
+
process.exit(EXIT_CODES.VALIDATION_ERROR);
|
|
884
|
+
}
|
|
885
|
+
return readFileSync(filePath, 'utf-8');
|
|
886
|
+
}
|
|
887
|
+
return inlineContent;
|
|
888
|
+
}
|
|
889
|
+
function createCreateProjectCommand() {
|
|
890
|
+
const command = new Command('create-project').description('Create a new SuperDesign project').requiredOption('--title <title>', 'Project title').option('--html <html>', 'Initial HTML content for first draft').option('--html-file <path>', 'Path to HTML file for first draft').option('-s, --set-project-prompt <prompt>', 'System prompt for the AI agent').option('--set-project-prompt-file <path>', 'Path to markdown file containing system prompt').option('--device <mode>', 'Device mode for draft (mobile, tablet, desktop)', 'desktop').option('--json', 'Output in JSON format').option('--no-open', 'Do not open project in browser after creation').action(async (options)=>{
|
|
966
891
|
if (options.json) setJsonMode(true);
|
|
967
892
|
job_runner_requireAuth(manager_isAuthenticated);
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
893
|
+
validateDeviceMode(options.device);
|
|
894
|
+
const htmlContent = readFileContent(options.htmlFile, options.html, 'HTML');
|
|
895
|
+
const promptContent = readFileContent(options.setProjectPromptFile, options.setProjectPrompt, 'Prompt');
|
|
896
|
+
startSpinner('Creating project...');
|
|
897
|
+
try {
|
|
898
|
+
const project = await createProject({
|
|
899
|
+
title: options.title,
|
|
900
|
+
html: htmlContent,
|
|
901
|
+
prompt: promptContent,
|
|
902
|
+
deviceMode: options.device
|
|
903
|
+
});
|
|
904
|
+
succeedSpinner('Project created successfully!');
|
|
905
|
+
if (options.open) {
|
|
906
|
+
const urlWithLive = `${project.projectUrl}?live=1`;
|
|
907
|
+
await openBrowser(urlWithLive);
|
|
908
|
+
}
|
|
909
|
+
if (isJsonMode()) output({
|
|
910
|
+
projectId: project.projectId,
|
|
911
|
+
title: project.title,
|
|
912
|
+
projectUrl: project.projectUrl,
|
|
913
|
+
shareToken: project.shareToken,
|
|
914
|
+
...project.draftId && {
|
|
915
|
+
draftId: project.draftId,
|
|
916
|
+
previewUrl: project.previewUrl
|
|
917
|
+
}
|
|
918
|
+
});
|
|
919
|
+
else {
|
|
920
|
+
success(`Project "${project.title}" created!`);
|
|
921
|
+
info(`\nProject ID: ${project.projectId}`);
|
|
922
|
+
info(`Project URL: ${project.projectUrl}`);
|
|
923
|
+
if (project.draftId) {
|
|
924
|
+
info(`\nDraft ID: ${project.draftId}`);
|
|
925
|
+
info(`Preview URL: ${project.previewUrl}`);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
} catch (err) {
|
|
929
|
+
failSpinner('Failed to create project');
|
|
930
|
+
handleApiError(err, 'Failed to create project');
|
|
975
931
|
}
|
|
932
|
+
});
|
|
933
|
+
return command;
|
|
934
|
+
}
|
|
935
|
+
async function createDraft(projectId, data) {
|
|
936
|
+
const client = getApiClient();
|
|
937
|
+
const response = await client.post(`/external/projects/${projectId}/drafts/create`, data);
|
|
938
|
+
return response.data;
|
|
939
|
+
}
|
|
940
|
+
async function iterateDraft(draftId, data) {
|
|
941
|
+
const client = getApiClient();
|
|
942
|
+
const response = await client.post(`/external/drafts/${draftId}/iterate`, data);
|
|
943
|
+
return response.data;
|
|
944
|
+
}
|
|
945
|
+
async function planFlowPages(draftId, data) {
|
|
946
|
+
const client = getApiClient();
|
|
947
|
+
const response = await client.post(`/external/drafts/${draftId}/flow/plan`, data);
|
|
948
|
+
return response.data;
|
|
949
|
+
}
|
|
950
|
+
async function executeFlowPages(draftId, data) {
|
|
951
|
+
const client = getApiClient();
|
|
952
|
+
const response = await client.post(`/external/drafts/${draftId}/flow/execute`, data);
|
|
953
|
+
return response.data;
|
|
954
|
+
}
|
|
955
|
+
function createCreateDesignDraftCommand() {
|
|
956
|
+
const command = new Command('create-design-draft').description('Create a design draft using AI generation').requiredOption('--project-id <id>', 'Project ID').requiredOption('--title <title>', 'Draft title').requiredOption('-p, --prompt <prompt>', 'Design prompt for AI generation').option('--device <mode>', 'Device mode (mobile, tablet, desktop)', 'desktop').option('--json', 'Output in JSON format').action(async (options)=>{
|
|
957
|
+
if (options.json) setJsonMode(true);
|
|
958
|
+
job_runner_requireAuth(manager_isAuthenticated);
|
|
959
|
+
validateDeviceMode(options.device);
|
|
976
960
|
await runJob({
|
|
977
961
|
startLabel: 'Creating design draft...',
|
|
978
962
|
pollingLabel: 'Generating design with AI...',
|
|
@@ -1442,7 +1426,7 @@ external_dotenv_config({
|
|
|
1442
1426
|
external_dotenv_config();
|
|
1443
1427
|
function createProgram() {
|
|
1444
1428
|
const program = new Command();
|
|
1445
|
-
program.name('superdesign').description('SuperDesign CLI - AI product designer for coding agents').version("0.1.
|
|
1429
|
+
program.name('superdesign').description('SuperDesign CLI - AI product designer for coding agents').version("0.1.5");
|
|
1446
1430
|
program.addCommand(createLoginCommand());
|
|
1447
1431
|
program.addCommand(createLogoutCommand());
|
|
1448
1432
|
program.addCommand(createInitCommand());
|
|
@@ -44,3 +44,9 @@ export declare function requireAuth(isAuthenticated: () => boolean): void;
|
|
|
44
44
|
* Exits the process with appropriate exit code
|
|
45
45
|
*/
|
|
46
46
|
export declare function handleApiError(err: unknown, failureMessage: string): never;
|
|
47
|
+
export declare const VALID_DEVICES: readonly ["mobile", "tablet", "desktop"];
|
|
48
|
+
export type DeviceMode = (typeof VALID_DEVICES)[number];
|
|
49
|
+
/**
|
|
50
|
+
* Validate device mode option and exit with error if invalid
|
|
51
|
+
*/
|
|
52
|
+
export declare function validateDeviceMode(device: string | undefined): void;
|