Skip to content

Commit

Permalink
Make command output visible and fix some stuff
Browse files Browse the repository at this point in the history
* fix: modify regexp that detects if version was provided together with package name

* fix: remove settings.json from version control

* fix: add missing keyPair name to fluence.yaml example

* fix: set stable aqua version as recommended

* feat: make command output visible
  • Loading branch information
shamsartem authored Oct 12, 2022
1 parent 0084729 commit 2261f3f
Show file tree
Hide file tree
Showing 18 changed files with 259 additions and 238 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ oclif.manifest.json
Cargo.lock
**/target/
.repl_history
vscode/settings.json
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"aquaSettings.imports": [
".fluence/aqua"
".fluence/aqua",
"/home/shams/.fluence/npm/@fluencelabs/registry/0.0.0-nightly/node_modules"
]
}
35 changes: 14 additions & 21 deletions src/commands/dependency/cargo/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import assert from "node:assert";
import path from "node:path";

import color from "@oclif/color";
import { CliUx, Command, Flags } from "@oclif/core";
import { Command, Flags } from "@oclif/core";

import {
FluenceConfig,
Expand Down Expand Up @@ -106,25 +106,18 @@ export const installAllCargoDependenciesFromFluenceConfig = async ({
fluenceConfig,
commandObj,
}: InstallAllDependenciesArg): Promise<void> => {
CliUx.ux.action.start(
`Installing cargo dependencies from ${color.yellow(
fluenceConfig.$getPath()
)}`
);
for (const [name, version] of Object.entries(
fluenceConfig.dependencies.cargo
)) {
assert(name !== undefined && version !== undefined);

await Promise.all(
Object.entries(fluenceConfig.dependencies.cargo).map(
([name, version]): Promise<string> => {
assert(name !== undefined && version !== undefined);
return ensureCargoDependency({
nameAndVersion: `${name}@${version}`,
commandObj,
fluenceConfig,
isSpinnerVisible: false,
});
}
)
);

CliUx.ux.action.stop();
// Not installing dependencies in parallel
// for cargo logs to be clearly readable
// eslint-disable-next-line no-await-in-loop
await ensureCargoDependency({
nameAndVersion: `${name}@${version}`,
commandObj,
fluenceConfig,
});
}
};
39 changes: 19 additions & 20 deletions src/commands/dependency/npm/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import assert from "node:assert";
import path from "node:path";

import color from "@oclif/color";
import { CliUx, Command } from "@oclif/core";
import { Command } from "@oclif/core";

import {
FluenceConfig,
Expand Down Expand Up @@ -117,25 +117,24 @@ export const installAllNPMDependenciesFromFluenceConfig = async ({
fluenceConfig,
commandObj,
}: InstallAllDependenciesArg): Promise<string[]> => {
CliUx.ux.action.start(
`Installing npm dependencies from ${color.yellow(fluenceConfig.$getPath())}`
);

const dependencyPaths = await Promise.all(
Object.entries(fluenceConfig.dependencies.npm).map(
([name, version]): Promise<string> => {
assert(name !== undefined && version !== undefined);
return ensureNpmDependency({
nameAndVersion: `${name}@${version}`,
commandObj,
fluenceConfig,
isSpinnerVisible: false,
});
}
)
);

CliUx.ux.action.stop();
const dependencyPaths = [];

for (const [name, version] of Object.entries(
fluenceConfig.dependencies.npm
)) {
assert(name !== undefined && version !== undefined);

dependencyPaths.push(
// Not installing dependencies in parallel
// for npm logs to be clearly readable
// eslint-disable-next-line no-await-in-loop
await ensureNpmDependency({
nameAndVersion: `${name}@${version}`,
commandObj,
fluenceConfig,
})
);
}

return dependencyPaths;
};
6 changes: 3 additions & 3 deletions src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,9 @@ const prepareForDeploy = async ({

if (moduleConfig.type === MODULE_TYPE_RUST) {
await marineCli({
command: "build",
args: ["build"],
flags: { release: true },
workingDir: path.dirname(moduleConfig.$getPath()),
cwd: path.dirname(moduleConfig.$getPath()),
});
}

Expand Down Expand Up @@ -880,7 +880,7 @@ const deployService = async ({
try {
result = await aquaCli(
{
command: "remote deploy_service",
args: ["remote", "deploy_service"],
flags: {
"config-path": tmpDeployJSONPath,
service: DEFAULT_DEPLOY_NAME,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export const removeApp = async (
// eslint-disable-next-line no-await-in-loop
await aquaCli(
{
command: "remote remove_service",
args: ["remote", "remove_service"],
flags: {
addr,
id: serviceId,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default class Run extends Command {
try {
result = await aquaCli(
{
command: "run",
args: ["run"],
flags: {
addr: relay,
func,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/service/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ const ensureModuleConfigs = ({

if (type === MODULE_TYPE_RUST) {
await marineCli({
command: "build",
args: ["build"],
flags: { release: true },
workingDir: path.dirname(moduleConfig.$getPath()),
cwd: path.dirname(moduleConfig.$getPath()),
});
}

Expand Down
33 changes: 19 additions & 14 deletions src/lib/aquaCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import type { FluenceConfig } from "./configs/project/fluence";
import { AQUA_NPM_DEPENDENCY, CommandObj } from "./const";
import { execPromise } from "./execPromise";
import { getMessageWithKeyValuePairs } from "./helpers/getMessageWithKeyValuePairs";
import { unparseFlags } from "./helpers/unparseFlags";
import { ensureNpmDependency } from "./npm";
import type { Flags, OptionalFlags } from "./typeHelpers";

Expand All @@ -29,20 +28,20 @@ const AQUA_CLI_EXECUTION_TIMEOUT = 90_000;

export type AquaCliInput =
| {
command: "remote deploy_service";
args: ["remote", "deploy_service"];
flags: Flags<"addr" | "sk" | "service" | "config-path"> &
OptionalFlags<"on" | "timeout" | "log-level" | "verbose" | "print-air">;
}
| {
command: "remote create_service";
args: ["remote", "create_service"];
flags: Flags<"addr" | "sk" | "id"> & OptionalFlags<"on" | "timeout">;
}
| {
command: "remote remove_service";
args: ["remote", "remove_service"];
flags: Flags<"addr" | "sk" | "id"> & OptionalFlags<"on" | "timeout">;
}
| {
command: "run";
args: ["run"];
flags: Flags<"addr" | "input" | "func"> &
OptionalFlags<
| "on"
Expand All @@ -56,7 +55,7 @@ export type AquaCliInput =
>;
}
| {
command?: never;
args?: never;
flags: Flags<"input" | "output"> &
OptionalFlags<
| "js"
Expand Down Expand Up @@ -90,16 +89,22 @@ export const initAquaCli = async (
});

return (aquaCliInput, message, keyValuePairs): Promise<string> => {
const { command, flags } = aquaCliInput;
const { args, flags } = aquaCliInput;

const timeoutNumber = Number(flags.timeout);

return execPromise(
`${aquaCliPath} ${command ?? ""}${unparseFlags(flags, commandObj)}`,
message === undefined
? undefined
: getMessageWithKeyValuePairs(message, keyValuePairs),
Number.isNaN(timeoutNumber) ? AQUA_CLI_EXECUTION_TIMEOUT : timeoutNumber
);
return execPromise({
command: aquaCliPath,
args,
flags,
message:
message === undefined
? undefined
: getMessageWithKeyValuePairs(message, keyValuePairs),
timeout: Number.isNaN(timeoutNumber)
? AQUA_CLI_EXECUTION_TIMEOUT
: timeoutNumber,
printOutput: true,
});
};
};
12 changes: 3 additions & 9 deletions src/lib/configs/project/fluence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,14 @@ export type FluenceConfig = InitializedConfig<LatestConfig>;
export type FluenceConfigReadonly = InitializedReadonlyConfig<LatestConfig>;

const examples = `
keyPairName: # Name of key pair to use. Default: defaultKeyPairName from project's .fluence/secretes.yaml or if it is empty - defaultKeyPairName from user's .fluence/secrets.yaml
keyPairName: myKeyPairName # Name of key pair to use. Default: defaultKeyPairName from project's .fluence/secretes.yaml or if it is empty - defaultKeyPairName from user's .fluence/secrets.yaml
# keyPairName is always searched in project's .fluence/secrets.yaml first and then if nothing is found it is searched in user's .fluence/secrets.yaml.
services:
someService: # Service name. It must start with a lowercase letter and contain only letters, numbers, and underscores.
keyPairName: # overrides top-level keyPairName. Optional
keyPairName: myKeyPairName # overrides top-level keyPairName. Optional
get: https://github.com/fluencelabs/services/blob/master/adder.tar.gz?raw=true # URL or path
deploy:
- keyPairName: # overrides top-level keyPairName. Optional
- keyPairName: myKeyPairName # overrides top-level keyPairName. Optional
deployId: default # must start with a lowercase letter and contain only letters, numbers, and underscores.
# Used in aqua to access deployed service ids
# You can access deployment info in aqua like this:
Expand All @@ -359,12 +359,6 @@ services:
peerIds: # A map of named peerIds. Optional.
MY_PEER: 12D3KooWCMr9mU894i8JXAFqpgoFtx6qnV1LFPSfVc3Y34N4h4LS
relays: kras # Array of relay multi-addresses or keywords: kras, testnet, stage. Default: kras
dependencies:
cargo: # cargo dependencies. They are installed in user's home directory in .fluence/cargo
marine: 0.12.2
mrepl: 0.18.1
npm: # npm dependencies. They are installed in user's home directory in .fluence/npm
"@fluencelabs/aqua": 0.7.5-342
appTSPath: ./path/to/app-ts/dir # Optional. If you want to generate ts files including app.ts to be able to access deployed app data in aqua when using FluenceJS,
appJSPath: ./path/to/app-js/dir # Optional. If you want to generate js files including app.js to be able to access deployed app data in aqua when using FluenceJS`;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { Command, Flags } from "@oclif/core";

export const AQUA_RECOMMENDED_VERSION = "0.7.6-347";
export const AQUA_RECOMMENDED_VERSION = "0.7.5-342";
export const MARINE_RECOMMENDED_VERSION = "0.12.4";
export const MREPL_RECOMMENDED_VERSION = "0.18.6";
export const MARINE_RS_SDK_TEMPLATE_VERSION = "0.6.15";
Expand Down
Loading

0 comments on commit 2261f3f

Please sign in to comment.