New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@botpress/cli

Package Overview
Dependencies
Maintainers
6
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@botpress/cli - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

88

dist/command-implementations/dev-command.js

@@ -38,9 +38,7 @@ "use strict";

class DevCommand extends import_project_command.ProjectCommand {
_initialDef = void 0;
async run() {
this.logger.warn("This command is experimental and subject to breaking changes without notice.");
if (!this.argv.noBuild) {
await this._runBuild();
}
const api = await this.ensureLoginAndCreateClient(this.argv);
const integrationDef = await this.readIntegrationDefinitionFromFS();
this._initialDef = await this.readIntegrationDefinitionFromFS();
let env = {

@@ -50,23 +48,9 @@ BP_API_URL: api.host,

};
if (integrationDef) {
await this._deployDevIntegration(api, this.argv.url, integrationDef);
const secrets = await this.promptSecrets(integrationDef, this.argv);
if (this._initialDef) {
const secrets = await this.promptSecrets(this._initialDef, this.argv);
env = { ...env, ...secrets };
} else {
await this._deployDevBot(api, this.argv.url);
}
const outfile = this.projectPaths.abs.outFile;
const importPath = utils.path.toUnix(outfile);
const requireFrom = utils.path.rmExtension(importPath);
const code = `require('${requireFrom}').default.start(${this.argv.port})`;
const worker = await import_worker.Worker.spawn(
{
type: "code",
code,
env
},
this.logger
).catch((thrown) => {
throw errors.BotpressCLIError.wrap(thrown, "Could not start dev worker");
});
await this._deploy(api);
await this._runBuild();
const worker = await this._spawnWorker(env);
try {

@@ -80,7 +64,8 @@ const watcher = await utils.filewatcher.FileWatcher.watch(

}
this.logger.log("Changes detected, reloading...");
await this._runBuild();
await worker.reload();
this.logger.log("Changes detected, rebuilding");
await this._restart(api, worker);
},
{ ignore: [this.projectPaths.abs.outDir] }
{
ignore: [this.projectPaths.abs.outDir]
}
);

@@ -97,2 +82,47 @@ await Promise.race([worker.wait(), watcher.wait()]);

}
_restart = async (api, worker) => {
await this._deploy(api);
try {
await this._runBuild();
} catch (thrown) {
const error = errors.BotpressCLIError.wrap(thrown, "Build failed");
this.logger.error(error.message);
return;
}
await worker.reload();
};
_deploy = async (api) => {
const integrationDef = await this.readIntegrationDefinitionFromFS();
if (integrationDef) {
this._checkSecrets(integrationDef);
await this._deployDevIntegration(api, this.argv.url, integrationDef);
} else {
await this._deployDevBot(api, this.argv.url);
}
};
_checkSecrets(integrationDef) {
const initialSecrets = this._initialDef?.secrets ?? [];
const currentSecrets = integrationDef.secrets ?? [];
const newSecrets = currentSecrets.filter((s) => !initialSecrets.includes(s));
if (newSecrets.length > 0) {
throw new errors.BotpressCLIError("Secrets were added while the server was running. A restart is required.");
}
}
_spawnWorker = async (env) => {
const outfile = this.projectPaths.abs.outFile;
const importPath = utils.path.toUnix(outfile);
const requireFrom = utils.path.rmExtension(importPath);
const code = `require('${requireFrom}').default.start(${this.argv.port})`;
const worker = await import_worker.Worker.spawn(
{
type: "code",
code,
env
},
this.logger
).catch((thrown) => {
throw errors.BotpressCLIError.wrap(thrown, "Could not start dev worker");
});
return worker;
};
_runBuild() {

@@ -164,7 +194,7 @@ return new import_build_command.BuildCommand(this.api, this.prompt, this.logger, this.argv).run();

const updateLine = this.logger.line();
updateLine.started("Updating bot integrations...");
updateLine.started("Deploying dev bot...");
const { bot: updatedBot } = await api.client.updateBot({ id: bot.id, integrations, url: externalUrl }).catch((thrown) => {
throw errors.BotpressCLIError.wrap(thrown, "Could not deploy dev bot");
});
updateLine.success("Integrations installed successfully");
updateLine.success("Dev Bot deployed");
this.displayWebhookUrls(updatedBot);

@@ -171,0 +201,0 @@ }

@@ -96,3 +96,3 @@ "use strict";

if (!import_lodash.default.keys(bot.integrations).length) {
this.logger.log("No integrations in bot");
this.logger.debug("No integrations in bot");
return;

@@ -99,0 +99,0 @@ }

@@ -151,3 +151,2 @@ "use strict";

port,
noBuild,
sourceMap

@@ -154,0 +153,0 @@ };

{
"name": "@botpress/cli",
"version": "0.1.1",
"version": "0.1.2",
"description": "Botpress CLI",

@@ -11,3 +11,3 @@ "scripts": {

"bundle": "ts-node -T build.ts",
"template:gen": "pnpm -r --stream -F './**/templates/*' exec bp gen"
"template:gen": "pnpm -r --stream -F echo-bot -F empty-integration exec bp gen"
},

@@ -14,0 +14,0 @@ "keywords": [],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc