Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sm][cli] remove unused code #540

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 0 additions & 82 deletions client/packages/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,88 +512,6 @@ async function getOrInstallInstantModuleWithErrorLogging(pkgDir) {
return moduleName;
}

async function createApp({ pkgDir, instantModuleName }) {
const schema = await readLocalSchemaFile();
const { perms } = await readLocalPermsFile();

const id = randomUUID();
const token = randomUUID();
const _title = await input({
message: "What would you like to call it?",
default: "My cool app",
required: true,
}).catch(() => null);

const title = _title?.trim();

if (!title) {
error("No name provided. Exiting.");
return;
}

const appRes = await fetchJson({
method: "POST",
path: "/dash/apps",
debugName: "App create",
errorMessage: "Failed to create app.",
body: { id, title, admin_token: token },
});

if (!appRes.ok) return;

console.log(chalk.green(`Successfully created your Instant app "${title}"`));
console.log(`Please add your app ID to your .env config:`);
console.log(chalk.magenta(`INSTANT_APP_ID=${id}`));
console.log(chalk.underline(appDashUrl(id)));

if (!schema) {
const schemaPath = join(pkgDir, "instant.schema.ts");
await writeFile(
schemaPath,
instantSchemaTmpl(title, id, instantModuleName),
"utf-8",
);
console.log("Start building your schema: " + schemaPath);
}

if (!perms) {
await writeFile(
join(pkgDir, "instant.perms.ts"),
examplePermsTmpl,
"utf-8",
);
}
}

async function promptForAppId(pkgAndAuthInfo) {
const res = await fetchJson({
debugName: "Fetching apps",
method: "GET",
path: "/dash",
errorMessage: "Failed to fetch apps.",
});
if (!res.ok) {
return;
}
const { apps } = res.data;
if (!apps.length) {
const ok = await promptOk(
"You don't have any apps. Want to create a new one?",
);
if (!ok) return;
await createApp(pkgAndAuthInfo);
return;
}
const choice = await select({
message: "Which app would you like to import?",
choices: res.data.apps.map((app) => {
return { name: `${app.title} (${app.id})`, value: app.id };
}),
});
if (!choice) return;
return choice;
}

async function promptCreateApp() {
const id = randomUUID();
const token = randomUUID();
Expand Down