Skip to content

Commit

Permalink
fix mistakes in command enablement, remove redundant command visibili…
Browse files Browse the repository at this point in the history
…ty, improve error messages in originate
  • Loading branch information
ac10n committed Jul 8, 2022
1 parent efcda71 commit 7282afe
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 72 deletions.
9 changes: 5 additions & 4 deletions taqueria-plugin-taquito/originate.ts
@@ -1,4 +1,5 @@
import {
getCurrentEnvironment,
getCurrentEnvironmentConfig,
getDefaultAccount,
getInitialStorage,
Expand Down Expand Up @@ -60,9 +61,10 @@ const getValidContracts = async (parsedArgs: Opts) => {
return contracts.reduce(
(retval, filename) => {
const storage = getInitialStorage(parsedArgs)(filename);
// TODO. The environment name in the error string should be a variable.
if (storage === undefined || storage === null) {
throw (`Michelson artifact ${filename} has no initial storage specifed. Storage is expected to be specified at JSON path: environment.development.storage.${filename}`);
throw (`Michelson artifact ${filename} has no initial storage specified. Storage is expected to be specified in .taq/config.json at JSON path: environment.${
getCurrentEnvironment(parsedArgs)
}.storage."${filename}"`);
}
return [...retval, { filename, storage }];
},
Expand Down Expand Up @@ -178,10 +180,9 @@ const originateToSandboxes = (parsedArgs: Opts, currentEnv: Protocol.Environment
const first = getFirstAccountAlias(sandboxName, parsedArgs);
if (first) {
defaultAccount = getSandboxAccountConfig(parsedArgs)(sandboxName)(first);
// TODO: error must be generalized for non sandbox deployment scenarious
// TODO: The error should be a warning, not an error. Descriptive string should not begin with 'Warning:'
sendErr(
`Warning: A default origination account is not specified for sandbox ${sandboxName}. Using the account ${first} for this origination. Specify a default account in .taq/config.json at location sandbox.local.accounts.default`,
`Warning: A default origination account is not specified for sandbox ${sandboxName}. Using the account ${first} for this origination. Specify a default account in .taq/config.json at JSON path: sandbox.${sandboxName}.accounts.default`,
);
}
}
Expand Down
72 changes: 6 additions & 66 deletions taqueria-vscode-extension/package.json
Expand Up @@ -86,28 +86,28 @@
"category": "Taqueria",
"title": "Initialize Project",
"shortTitle": "init",
"enablement": "!@taqueria-state/is-taqified"
"enablement": "@taqueria-state/enable-init-scaffold"
},
{
"command": "taqueria.scaffold",
"category": "Taqueria",
"title": "Scaffold Project",
"shortTitle": "scaffold",
"enablement": "!@taqueria-state/is-taqified"
"enablement": "@taqueria-state/enable-init-scaffold"
},
{
"command": "taqueria.install",
"category": "Taqueria",
"title": "Install Plugin",
"shortTitle": "install",
"enablement": "@taqueria-state/is-taqified && @taqueria-state/not-installed-plugin-count != 0"
"enablement": "@taqueria-state/enable-install-uninstall && @taqueria-state/not-installed-plugin-count != 0"
},
{
"command": "taqueria.uninstall",
"category": "Taqueria",
"title": "Uninstall Plugin",
"shortTitle": "uninstall",
"enablement": "@taqueria-state/is-taqified && @taqueria-state/installed-plugin-count != 0"
"enablement": "@taqueria-state/enable-install-uninstall && @taqueria-state/installed-plugin-count != 0"
},
{
"command": "taqueria.compile_smartpy",
Expand Down Expand Up @@ -182,7 +182,7 @@
"category": "Taqueria",
"title": "Typecheck Michelson contracts",
"shortTitle": "typecheck",
"enablement": "@taqueria/plugin-contract-types"
"enablement": "@taqueria/plugin-tezos-client"
},
{
"command": "taqueria.test",
Expand All @@ -191,67 +191,7 @@
"shortTitle": "test",
"enablement": "@taqueria/plugin-jest"
}
],
"menus": {
"commandPalette": [
{
"command": "taqueria.init",
"when": "!@taqueria-state/is-taqified"
},
{
"command": "taqueria.scaffold",
"when": "!@taqueria-state/is-taqified"
},
{
"command": "taqueria.install",
"when": "@taqueria-state/is-taqified"
},
{
"command": "taqueria.uninstall",
"when": "@taqueria-state/is-taqified && @taqueria-state/installed-plugin-count != 0"
},
{
"command": "taqueria.compile_smartpy",
"when": "@taqueria/plugin-smartpy"
},
{
"command": "taqueria.compile_ligo",
"when": "@taqueria/plugin-ligo"
},
{
"command": "taqueria.compile_archetype",
"when": "@taqueria/plugin-archetype"
},
{
"command": "taqueria.start_sandbox",
"when": "@taqueria/plugin-flextesa"
},
{
"command": "taqueria.stop_sandbox",
"when": "@taqueria/plugin-flextesa"
},
{
"command": "taqueria.list_accounts",
"when": "@taqueria/plugin-flextesa"
},
{
"command": "taqueria.originate",
"when": "@taqueria/plugin-taquito"
},
{
"command": "taqueria.generate_types",
"when": "@taqueria/plugin-contract-types"
},
{
"command": "taqueria.typecheck",
"when": "@taqueria/plugin-contract-types"
},
{
"command": "taqueria.test",
"when": "@taqueria/plugin-jest"
}
]
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
Expand Down
25 changes: 23 additions & 2 deletions taqueria-vscode-extension/src/lib/helpers.ts
Expand Up @@ -609,8 +609,8 @@ export const inject = (deps: InjectedDependencies) => {
showOutput(output)(OutputLevels.debug, 'Taq folder is found');
taqFolderFound = true;
} catch {
showOutput(output)(OutputLevels.debug, 'Taq folder not found');
taqFolderFound = false;
showOutput(output)(OutputLevels.debug, 'Taq folder not found');
}
let enableAllCommands: boolean;
let config: Util.TaqifiedDir | null;
Expand All @@ -637,8 +637,29 @@ export const inject = (deps: InjectedDependencies) => {
const availablePluginsNotInstalled = config?.config?.plugins
? availablePlugins.filter(name => config?.config.plugins?.findIndex(p => p.name === name) === -1)
: availablePlugins;
showOutput(output)(
OutputLevels.debug,
`@taqueria-state/enable-init-scaffold: ${enableAllCommands || !config?.config}`,
);
vscode.commands.executeCommand(
'setContext',
'@taqueria-state/enable-init-scaffold',
enableAllCommands || !config?.config,
);

showOutput(output)(
OutputLevels.debug,
`@taqueria-state/enable-install-uninstall: ${enableAllCommands || !!config?.config}`,
);
vscode.commands.executeCommand(
'setContext',
'@taqueria-state/enable-install-uninstall',
enableAllCommands || !!config?.config,
);

showOutput(output)(OutputLevels.debug, `@taqueria-state/is-taqified: ${!!config?.config}`);
vscode.commands.executeCommand('setContext', '@taqueria-state/is-taqified', enableAllCommands || !!config?.config);
vscode.commands.executeCommand('setContext', '@taqueria-state/is-taqified', !!config?.config);

vscode.commands.executeCommand(
'setContext',
'@taqueria-state/installed-plugin-count',
Expand Down

0 comments on commit 7282afe

Please sign in to comment.