Skip to content
This repository has been archived by the owner on Mar 13, 2021. It is now read-only.

Commit

Permalink
W.I.P.
Browse files Browse the repository at this point in the history
  • Loading branch information
pierce-h committed Sep 15, 2020
1 parent 3ae3167 commit 9600456
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/commands/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ export default class Info extends BaseCommand {

const latestDeployment = paginatedDeployments.items[0];

const table = new Table({
head: ['ID', 'Name', "Type", "Status", "Created At"]
});
const table = new Table();

table.push([platformApp.id, platformApp.name, platformApp.type, latestDeployment.status, latestDeployment.createdAt])
table.push(
{ 'ID': [platformApp.id] },
{ 'Name': [platformApp.name] },
{ 'Type': [platformApp.type] },
{ 'Status': [latestDeployment.status] },
{ 'Created At': [latestDeployment.createdAt] },
);
this.log(table.toString());
} catch (error) {
switch (error.code) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/package-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function packageApp(cwd?: string): Promise<string> {
// Make a backup copy of the package.json file since we are going to add the bundledDependencies attribute
const pJsonBackup = await fs.promises.readFile(packagePath);

cli.action.start("packaging app");
cli.action.start("Packaging app");

const results = await fs.promises.readFile(packagePath, "utf-8");
const pjson = JSON.parse(results) as PackageJSON;
Expand All @@ -47,7 +47,7 @@ export async function packageApp(cwd?: string): Promise<string> {

} catch (error) {
const err = error as Error;
const errorMessage = `unable to bundle dependencies and package app: ${err.message}`;
const errorMessage = `Unable to bundle dependencies and package app: ${err.message}`;
throw new AppFailedToPackageError(errorMessage);
} finally {
// Restore the package.json backup
Expand Down Expand Up @@ -81,4 +81,4 @@ export function isAppFailedToPackageError(obj: unknown): obj is AppFailedToPacka
}

return false;
}
}
36 changes: 34 additions & 2 deletions src/core/publish-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { loadApp } from "@shipengine/connect-loader";
import { watchDeployment } from "./publish-app/watch-deployment";
import { green, red } from "chalk";
import parseDeploymentErrors from './utils/parse-deployment-errors';
import Table from 'cli-table';


class AppFailedToPackageError extends Error {
code: string;
Expand Down Expand Up @@ -59,7 +61,7 @@ export default async function publishApp(
{ noWatch = false }: PublishAppOptions,
): Promise<Deployment> {

cli.action.start("publishing app");
cli.action.start("Publishing app");

let newDeployment;
let platformApp;
Expand Down Expand Up @@ -121,14 +123,44 @@ export default async function publishApp(
})
}


} else if (deployment.status === DeploymentStatus.Terminated) {
console.log(red("Your app was terminated "));
} else {
console.log(
green(`Your app was published successfully ${logSymbols.success} `),
);
}

return newDeployment;
}

const sellers = await client.sellers.getSellersForAppId(platformApp.id)
const email = `${platformApp.id}@test.com`;

console.log(newDeployment);

if (sellers.some((seller) => seller.email === email)) {
const table = new Table();

table.push(
{ 'Email': [email] },
{ 'Password': [platformApp.id] },
{ 'URL': ["test.com"] }
);
} else {
cli.action.start("Creating test account");
await client.sellers.createSeller(platformApp.id, email, platformApp.id)
cli.action.stop(`${logSymbols.success}`);

const table = new Table();

table.push(
{ 'Email': [email] },
{ 'Password': [platformApp.id] },
{ 'URL': ["test.com"] }
);

console.log(table.toString());
}

return newDeployment;
Expand Down

0 comments on commit 9600456

Please sign in to comment.