Cleans up cli generator and enables prettier formatting (#3718)
parent
f589d06ed4
commit
70d6c8d8e7
|
@ -1,10 +1,10 @@
|
|||
import child_process from "child_process";
|
||||
import fs from "fs";
|
||||
import { Box, Text, useApp, useInput, useStdin } from "ink";
|
||||
import { Box, Text } from "ink";
|
||||
import SelectInput from "ink-select-input";
|
||||
import TextInput from "ink-text-input";
|
||||
import path from "path";
|
||||
import React, { FC, useEffect, useRef, useState } from "react";
|
||||
import React, { FC, useEffect, useState } from "react";
|
||||
|
||||
const slugify = (str: string) => {
|
||||
// It is to be a valid dir name, a valid JS variable name and a valid URL path
|
||||
|
@ -266,7 +266,8 @@ const CreateApp = ({ noDbUpdate, slug = null, editMode = false }) => {
|
|||
setInputIndex((index) => {
|
||||
return index + 1;
|
||||
});
|
||||
}}></SelectInput>
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
|
@ -275,7 +276,7 @@ const CreateApp = ({ noDbUpdate, slug = null, editMode = false }) => {
|
|||
const DeleteApp = ({ noDbUpdate, slug }) => {
|
||||
const [confirmedAppSlug, setConfirmedAppSlug] = useState("");
|
||||
const [allowDeletion, setAllowDeletion] = useState(false);
|
||||
const [state, setState] = useState({});
|
||||
const [state, setState] = useState({ done: null, description: null });
|
||||
useEffect(() => {
|
||||
if (allowDeletion) {
|
||||
BaseAppFork.delete({ slug });
|
||||
|
@ -303,7 +304,8 @@ const DeleteApp = ({ noDbUpdate, slug }) => {
|
|||
}}
|
||||
onChange={(val) => {
|
||||
setConfirmedAppSlug(val);
|
||||
}}></TextInput>
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<Text>{state.description}</Text>
|
||||
</>
|
||||
|
|
|
@ -2,12 +2,17 @@ import chokidar from "chokidar";
|
|||
import fs from "fs";
|
||||
import { debounce } from "lodash";
|
||||
import path from "path";
|
||||
import prettier from "prettier";
|
||||
|
||||
import prettierConfig from "../../config/prettier-preset";
|
||||
|
||||
let isInWatchMode = false;
|
||||
if (process.argv[2] === "--watch") {
|
||||
isInWatchMode = true;
|
||||
}
|
||||
|
||||
const formatOutput = (source: string) => prettier.format(source, prettierConfig);
|
||||
|
||||
const APP_STORE_PATH = path.join(__dirname, "..", "..", "app-store");
|
||||
type App = {
|
||||
name: string;
|
||||
|
@ -77,13 +82,16 @@ function generateFiles() {
|
|||
entryBuilder,
|
||||
}: {
|
||||
fileToBeImported: string;
|
||||
importBuilder: (arg: App) => string;
|
||||
importBuilder?: (arg: App) => string;
|
||||
entryBuilder: (arg: App) => string;
|
||||
}
|
||||
) {
|
||||
const output = [];
|
||||
forEachAppDir((app) => {
|
||||
if (fs.existsSync(path.join(APP_STORE_PATH, app.path, fileToBeImported))) {
|
||||
if (
|
||||
fs.existsSync(path.join(APP_STORE_PATH, app.path, fileToBeImported)) &&
|
||||
typeof importBuilder === "function"
|
||||
) {
|
||||
output.push(importBuilder(app));
|
||||
}
|
||||
});
|
||||
|
@ -104,8 +112,7 @@ function generateFiles() {
|
|||
...getObjectExporter("apiHandlers", {
|
||||
fileToBeImported: "api/index.ts",
|
||||
// Import path must have / even for windows and not \
|
||||
importBuilder: (app) => `const ${app.name}_api = import("./${app.path.replace(/\\/g, "/")}/api");`,
|
||||
entryBuilder: (app) => `${app.name}:${app.name}_api,`,
|
||||
entryBuilder: (app) => ` ${app.name}: import("./${app.path.replace(/\\/g, "/")}/api"),`,
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -115,16 +122,15 @@ function generateFiles() {
|
|||
// Import path must have / even for windows and not \
|
||||
importBuilder: (app) =>
|
||||
`import { metadata as ${app.name}_meta } from "./${app.path.replace(/\\/g, "/")}/_metadata";`,
|
||||
entryBuilder: (app) => `${app.name}:${app.name}_meta,`,
|
||||
entryBuilder: (app) => ` ${app.name}:${app.name}_meta,`,
|
||||
})
|
||||
);
|
||||
|
||||
browserOutput.push(
|
||||
...getObjectExporter("InstallAppButtonMap", {
|
||||
fileToBeImported: "components/InstallAppButton.tsx",
|
||||
importBuilder: (app) =>
|
||||
`const ${app.name}_installAppButton = dynamic(() =>import("./${app.path}/components/InstallAppButton"));`,
|
||||
entryBuilder: (app) => `${app.name}:${app.name}_installAppButton,`,
|
||||
entryBuilder: (app) =>
|
||||
` ${app.name}: dynamic(() =>import("./${app.path}/components/InstallAppButton")),`,
|
||||
})
|
||||
);
|
||||
const banner = `/**
|
||||
|
@ -132,8 +138,14 @@ function generateFiles() {
|
|||
Don't modify this file manually.
|
||||
**/
|
||||
`;
|
||||
fs.writeFileSync(`${APP_STORE_PATH}/apps.server.generated.ts`, `${banner}${serverOutput.join("\n")}`);
|
||||
fs.writeFileSync(`${APP_STORE_PATH}/apps.browser.generated.tsx`, `${banner}${browserOutput.join("\n")}`);
|
||||
fs.writeFileSync(
|
||||
`${APP_STORE_PATH}/apps.server.generated.ts`,
|
||||
formatOutput(`${banner}${serverOutput.join("\n")}`)
|
||||
);
|
||||
fs.writeFileSync(
|
||||
`${APP_STORE_PATH}/apps.browser.generated.tsx`,
|
||||
formatOutput(`${banner}${browserOutput.join("\n")}`)
|
||||
);
|
||||
console.log("Generated `apps.server.generated.ts` and `apps.browser.generated.tsx`");
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
This file is autogenerated using the command `yarn app-store:build --watch`.
|
||||
Don't modify this file manually.
|
||||
**/
|
||||
import dynamic from "next/dynamic"
|
||||
import dynamic from "next/dynamic";
|
||||
|
||||
import { metadata as applecalendar_meta } from "./applecalendar/_metadata";
|
||||
import { metadata as around_meta } from "./around/_metadata";
|
||||
import { metadata as caldavcalendar_meta } from "./caldavcalendar/_metadata";
|
||||
|
@ -28,76 +29,55 @@ import { metadata as whereby_meta } from "./whereby/_metadata";
|
|||
import { metadata as wipemycalother_meta } from "./wipemycalother/_metadata";
|
||||
import { metadata as zapier_meta } from "./zapier/_metadata";
|
||||
import { metadata as zoomvideo_meta } from "./zoomvideo/_metadata";
|
||||
|
||||
export const appStoreMetadata = {
|
||||
applecalendar:applecalendar_meta,
|
||||
around:around_meta,
|
||||
caldavcalendar:caldavcalendar_meta,
|
||||
dailyvideo:dailyvideo_meta,
|
||||
routing_forms:routing_forms_meta,
|
||||
exchange2013calendar:exchange2013calendar_meta,
|
||||
exchange2016calendar:exchange2016calendar_meta,
|
||||
giphy:giphy_meta,
|
||||
googlecalendar:googlecalendar_meta,
|
||||
googlevideo:googlevideo_meta,
|
||||
hubspotothercalendar:hubspotothercalendar_meta,
|
||||
huddle01video:huddle01video_meta,
|
||||
jitsivideo:jitsivideo_meta,
|
||||
metamask:metamask_meta,
|
||||
office365calendar:office365calendar_meta,
|
||||
office365video:office365video_meta,
|
||||
riverside:riverside_meta,
|
||||
slackmessaging:slackmessaging_meta,
|
||||
stripepayment:stripepayment_meta,
|
||||
tandemvideo:tandemvideo_meta,
|
||||
vital:vital_meta,
|
||||
whereby:whereby_meta,
|
||||
wipemycalother:wipemycalother_meta,
|
||||
zapier:zapier_meta,
|
||||
zoomvideo:zoomvideo_meta,
|
||||
applecalendar: applecalendar_meta,
|
||||
around: around_meta,
|
||||
caldavcalendar: caldavcalendar_meta,
|
||||
dailyvideo: dailyvideo_meta,
|
||||
routing_forms: routing_forms_meta,
|
||||
exchange2013calendar: exchange2013calendar_meta,
|
||||
exchange2016calendar: exchange2016calendar_meta,
|
||||
giphy: giphy_meta,
|
||||
googlecalendar: googlecalendar_meta,
|
||||
googlevideo: googlevideo_meta,
|
||||
hubspotothercalendar: hubspotothercalendar_meta,
|
||||
huddle01video: huddle01video_meta,
|
||||
jitsivideo: jitsivideo_meta,
|
||||
metamask: metamask_meta,
|
||||
office365calendar: office365calendar_meta,
|
||||
office365video: office365video_meta,
|
||||
riverside: riverside_meta,
|
||||
slackmessaging: slackmessaging_meta,
|
||||
stripepayment: stripepayment_meta,
|
||||
tandemvideo: tandemvideo_meta,
|
||||
vital: vital_meta,
|
||||
whereby: whereby_meta,
|
||||
wipemycalother: wipemycalother_meta,
|
||||
zapier: zapier_meta,
|
||||
zoomvideo: zoomvideo_meta,
|
||||
};
|
||||
const applecalendar_installAppButton = dynamic(() =>import("./applecalendar/components/InstallAppButton"));
|
||||
const around_installAppButton = dynamic(() =>import("./around/components/InstallAppButton"));
|
||||
const caldavcalendar_installAppButton = dynamic(() =>import("./caldavcalendar/components/InstallAppButton"));
|
||||
const exchange2013calendar_installAppButton = dynamic(() =>import("./exchange2013calendar/components/InstallAppButton"));
|
||||
const exchange2016calendar_installAppButton = dynamic(() =>import("./exchange2016calendar/components/InstallAppButton"));
|
||||
const giphy_installAppButton = dynamic(() =>import("./giphy/components/InstallAppButton"));
|
||||
const googlecalendar_installAppButton = dynamic(() =>import("./googlecalendar/components/InstallAppButton"));
|
||||
const hubspotothercalendar_installAppButton = dynamic(() =>import("./hubspotothercalendar/components/InstallAppButton"));
|
||||
const huddle01video_installAppButton = dynamic(() =>import("./huddle01video/components/InstallAppButton"));
|
||||
const jitsivideo_installAppButton = dynamic(() =>import("./jitsivideo/components/InstallAppButton"));
|
||||
const metamask_installAppButton = dynamic(() =>import("./metamask/components/InstallAppButton"));
|
||||
const office365calendar_installAppButton = dynamic(() =>import("./office365calendar/components/InstallAppButton"));
|
||||
const office365video_installAppButton = dynamic(() =>import("./office365video/components/InstallAppButton"));
|
||||
const riverside_installAppButton = dynamic(() =>import("./riverside/components/InstallAppButton"));
|
||||
const slackmessaging_installAppButton = dynamic(() =>import("./slackmessaging/components/InstallAppButton"));
|
||||
const stripepayment_installAppButton = dynamic(() =>import("./stripepayment/components/InstallAppButton"));
|
||||
const tandemvideo_installAppButton = dynamic(() =>import("./tandemvideo/components/InstallAppButton"));
|
||||
const vital_installAppButton = dynamic(() =>import("./vital/components/InstallAppButton"));
|
||||
const whereby_installAppButton = dynamic(() =>import("./whereby/components/InstallAppButton"));
|
||||
const wipemycalother_installAppButton = dynamic(() =>import("./wipemycalother/components/InstallAppButton"));
|
||||
const zapier_installAppButton = dynamic(() =>import("./zapier/components/InstallAppButton"));
|
||||
const zoomvideo_installAppButton = dynamic(() =>import("./zoomvideo/components/InstallAppButton"));
|
||||
export const InstallAppButtonMap = {
|
||||
applecalendar:applecalendar_installAppButton,
|
||||
around:around_installAppButton,
|
||||
caldavcalendar:caldavcalendar_installAppButton,
|
||||
exchange2013calendar:exchange2013calendar_installAppButton,
|
||||
exchange2016calendar:exchange2016calendar_installAppButton,
|
||||
giphy:giphy_installAppButton,
|
||||
googlecalendar:googlecalendar_installAppButton,
|
||||
hubspotothercalendar:hubspotothercalendar_installAppButton,
|
||||
huddle01video:huddle01video_installAppButton,
|
||||
jitsivideo:jitsivideo_installAppButton,
|
||||
metamask:metamask_installAppButton,
|
||||
office365calendar:office365calendar_installAppButton,
|
||||
office365video:office365video_installAppButton,
|
||||
riverside:riverside_installAppButton,
|
||||
slackmessaging:slackmessaging_installAppButton,
|
||||
stripepayment:stripepayment_installAppButton,
|
||||
tandemvideo:tandemvideo_installAppButton,
|
||||
vital:vital_installAppButton,
|
||||
whereby:whereby_installAppButton,
|
||||
wipemycalother:wipemycalother_installAppButton,
|
||||
zapier:zapier_installAppButton,
|
||||
zoomvideo:zoomvideo_installAppButton,
|
||||
};
|
||||
applecalendar: dynamic(() => import("./applecalendar/components/InstallAppButton")),
|
||||
around: dynamic(() => import("./around/components/InstallAppButton")),
|
||||
caldavcalendar: dynamic(() => import("./caldavcalendar/components/InstallAppButton")),
|
||||
exchange2013calendar: dynamic(() => import("./exchange2013calendar/components/InstallAppButton")),
|
||||
exchange2016calendar: dynamic(() => import("./exchange2016calendar/components/InstallAppButton")),
|
||||
giphy: dynamic(() => import("./giphy/components/InstallAppButton")),
|
||||
googlecalendar: dynamic(() => import("./googlecalendar/components/InstallAppButton")),
|
||||
hubspotothercalendar: dynamic(() => import("./hubspotothercalendar/components/InstallAppButton")),
|
||||
huddle01video: dynamic(() => import("./huddle01video/components/InstallAppButton")),
|
||||
jitsivideo: dynamic(() => import("./jitsivideo/components/InstallAppButton")),
|
||||
metamask: dynamic(() => import("./metamask/components/InstallAppButton")),
|
||||
office365calendar: dynamic(() => import("./office365calendar/components/InstallAppButton")),
|
||||
office365video: dynamic(() => import("./office365video/components/InstallAppButton")),
|
||||
riverside: dynamic(() => import("./riverside/components/InstallAppButton")),
|
||||
slackmessaging: dynamic(() => import("./slackmessaging/components/InstallAppButton")),
|
||||
stripepayment: dynamic(() => import("./stripepayment/components/InstallAppButton")),
|
||||
tandemvideo: dynamic(() => import("./tandemvideo/components/InstallAppButton")),
|
||||
vital: dynamic(() => import("./vital/components/InstallAppButton")),
|
||||
whereby: dynamic(() => import("./whereby/components/InstallAppButton")),
|
||||
wipemycalother: dynamic(() => import("./wipemycalother/components/InstallAppButton")),
|
||||
zapier: dynamic(() => import("./zapier/components/InstallAppButton")),
|
||||
zoomvideo: dynamic(() => import("./zoomvideo/components/InstallAppButton")),
|
||||
};
|
||||
|
|
|
@ -2,51 +2,28 @@
|
|||
This file is autogenerated using the command `yarn app-store:build --watch`.
|
||||
Don't modify this file manually.
|
||||
**/
|
||||
const applecalendar_api = import("./applecalendar/api");
|
||||
const around_api = import("./around/api");
|
||||
const caldavcalendar_api = import("./caldavcalendar/api");
|
||||
const routing_forms_api = import("./ee/routing_forms/api");
|
||||
const exchange2013calendar_api = import("./exchange2013calendar/api");
|
||||
const exchange2016calendar_api = import("./exchange2016calendar/api");
|
||||
const giphy_api = import("./giphy/api");
|
||||
const googlecalendar_api = import("./googlecalendar/api");
|
||||
const hubspotothercalendar_api = import("./hubspotothercalendar/api");
|
||||
const huddle01video_api = import("./huddle01video/api");
|
||||
const jitsivideo_api = import("./jitsivideo/api");
|
||||
const metamask_api = import("./metamask/api");
|
||||
const office365calendar_api = import("./office365calendar/api");
|
||||
const office365video_api = import("./office365video/api");
|
||||
const riverside_api = import("./riverside/api");
|
||||
const slackmessaging_api = import("./slackmessaging/api");
|
||||
const stripepayment_api = import("./stripepayment/api");
|
||||
const tandemvideo_api = import("./tandemvideo/api");
|
||||
const vital_api = import("./vital/api");
|
||||
const whereby_api = import("./whereby/api");
|
||||
const wipemycalother_api = import("./wipemycalother/api");
|
||||
const zapier_api = import("./zapier/api");
|
||||
const zoomvideo_api = import("./zoomvideo/api");
|
||||
export const apiHandlers = {
|
||||
applecalendar:applecalendar_api,
|
||||
around:around_api,
|
||||
caldavcalendar:caldavcalendar_api,
|
||||
routing_forms:routing_forms_api,
|
||||
exchange2013calendar:exchange2013calendar_api,
|
||||
exchange2016calendar:exchange2016calendar_api,
|
||||
giphy:giphy_api,
|
||||
googlecalendar:googlecalendar_api,
|
||||
hubspotothercalendar:hubspotothercalendar_api,
|
||||
huddle01video:huddle01video_api,
|
||||
jitsivideo:jitsivideo_api,
|
||||
metamask:metamask_api,
|
||||
office365calendar:office365calendar_api,
|
||||
office365video:office365video_api,
|
||||
riverside:riverside_api,
|
||||
slackmessaging:slackmessaging_api,
|
||||
stripepayment:stripepayment_api,
|
||||
tandemvideo:tandemvideo_api,
|
||||
vital:vital_api,
|
||||
whereby:whereby_api,
|
||||
wipemycalother:wipemycalother_api,
|
||||
zapier:zapier_api,
|
||||
zoomvideo:zoomvideo_api,
|
||||
};
|
||||
applecalendar: import("./applecalendar/api"),
|
||||
around: import("./around/api"),
|
||||
caldavcalendar: import("./caldavcalendar/api"),
|
||||
routing_forms: import("./ee/routing_forms/api"),
|
||||
exchange2013calendar: import("./exchange2013calendar/api"),
|
||||
exchange2016calendar: import("./exchange2016calendar/api"),
|
||||
giphy: import("./giphy/api"),
|
||||
googlecalendar: import("./googlecalendar/api"),
|
||||
hubspotothercalendar: import("./hubspotothercalendar/api"),
|
||||
huddle01video: import("./huddle01video/api"),
|
||||
jitsivideo: import("./jitsivideo/api"),
|
||||
metamask: import("./metamask/api"),
|
||||
office365calendar: import("./office365calendar/api"),
|
||||
office365video: import("./office365video/api"),
|
||||
riverside: import("./riverside/api"),
|
||||
slackmessaging: import("./slackmessaging/api"),
|
||||
stripepayment: import("./stripepayment/api"),
|
||||
tandemvideo: import("./tandemvideo/api"),
|
||||
vital: import("./vital/api"),
|
||||
whereby: import("./whereby/api"),
|
||||
wipemycalother: import("./wipemycalother/api"),
|
||||
zapier: import("./zapier/api"),
|
||||
zoomvideo: import("./zoomvideo/api"),
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue