Skip to content

Commit

Permalink
Deploy publish build fixes (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmikey authored Sep 8, 2022
1 parent 2704bdb commit 7e19588
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 12 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"replace-in-file": "^6.3.5",
"ts-node": "^10.8.2",
"typescript": "^4.7.4",
"unique-names-generator": "^4.7.1",
"zlib": "^1.0.5"
},
"devDependencies": {
Expand Down
8 changes: 7 additions & 1 deletion src/commands/function/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import axios from "axios";
import { IDeploymentOptions } from "./interfaces";
import { run as runPublish } from "./publish";
import { getConsoleServer } from "../../lib/utils";
import { basename, resolve } from "path";

const deploymentOptions: IDeploymentOptions = {
functionId: "",
Expand Down Expand Up @@ -67,7 +68,12 @@ const deployFunction = (data: any) => {
};

export const run = (options: any) => {
const { debug, name, path = process.cwd(), rebuild } = options;
const {
debug,
name = basename(resolve(process.cwd())),
path = process.cwd(),
rebuild,
} = options;

const {
bls: { functionId: userFunctionId },
Expand Down
28 changes: 20 additions & 8 deletions src/commands/function/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { execSync } from "child_process";
import replace from "replace-in-file";
import { getNpmConfigInitVersion } from "../../lib/utils";
import prompt from "prompt";
import {
uniqueNamesGenerator,
adjectives,
colors,
animals,
} from "unique-names-generator";

prompt.start();
prompt.message = "";
Expand All @@ -24,9 +30,13 @@ const checkForNpm = () => {
}
};

const randomName = uniqueNamesGenerator({
dictionaries: [adjectives, colors, animals],
}); // big_red_donkey

export const run = (options: any) => {
const {
name,
name = randomName,
path = process.cwd(),
private: isPrivate,
yes = false,
Expand Down Expand Up @@ -115,9 +125,9 @@ export const run = (options: any) => {
}
// initialize new local project
console.log(
Chalk.yellow(
`Initializing new function in ${installationPath} with ID ${functionId}`
)
`${Chalk.blue("Initializing")} new function in \n${Chalk.yellow(
installationPath
)} \nwith ID ${functionId}`
);

execSync(
Expand All @@ -127,12 +137,14 @@ export const run = (options: any) => {
isPrivate
).toString()} "bls.functionId"=${functionId}`,
{
stdio: "inherit",
stdio: "ignore",
}
);
console.log(
Chalk.green(
`Initialization of function ${installationPath} completed successfully`
) // because I said so in the absence of actual verification :D
`Initialization of function\n${Chalk.blue(
installationPath
)}\ncompleted ${Chalk.green("successfully")}`
);
console.log("");
console.log(`change into the directory\n${installationPath}\nto get started`);
};
3 changes: 2 additions & 1 deletion src/commands/function/invoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { store } from "../../store";
import fs from "fs";
import { execSync } from "child_process";
import { run as runBuild } from "./build";
import { basename, resolve } from "path";

export const run = (options: any) => {
const {
systemPath = `${store.system.homedir}/.bls/`,
cwd: path = process.cwd(),
name,
name = basename(resolve(process.cwd())),
rebuild = true,
} = options;
const runtimePath = `${systemPath}runtime/blockless-cli`;
Expand Down
3 changes: 2 additions & 1 deletion src/commands/function/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getToken } from "../../store/db";
import { IDeploymentOptions } from "./interfaces";
import { run as runBuild } from "./build";
import { createWasmArchive, getBuildDir } from "./shared";
import { basename, resolve } from "path";

const deploymentOptions: IDeploymentOptions = {
functionId: "",
Expand Down Expand Up @@ -52,7 +53,7 @@ const logResult = (data: any) => {
export const run = (options: any) => {
const {
debug,
name,
name = basename(resolve(process.cwd())),
path = process.cwd(),
publishCallback = logResult,
rebuild,
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { run as runInfo } from "./commands/info";
let didRun = false;
let pkg = { version: "0.0.0" };
const name = "bls";
const consoleHost = "https://console.bls.dev";
const consoleHost = "https://localhost:3005";

function printHelp(commands: any = [], options: any = []) {
console.log("");
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,11 @@ typescript@^4.7.4:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.2.tgz#e3b33d5ccfb5914e4eeab6699cf208adee3fd790"
integrity sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==

unique-names-generator@^4.7.1:
version "4.7.1"
resolved "https://registry.yarnpkg.com/unique-names-generator/-/unique-names-generator-4.7.1.tgz#966407b12ba97f618928f77322cfac8c80df5597"
integrity sha512-lMx9dX+KRmG8sq6gulYYpKWZc9RlGsgBR6aoO8Qsm3qvkSJ+3rAymr+TnV8EDMrIrwuFJ4kruzMWM/OpYzPoow==

universalify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
Expand Down

0 comments on commit 7e19588

Please sign in to comment.