How to use the flex-dev-utils/dist/ora.progress function in flex-dev-utils

To help you get started, we’ve selected a few flex-dev-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github twilio / flex-plugin-builder / packages / flex-plugin-scripts / src / scripts / deploy.ts View on Github external
:  buildAssets;

    // Create build
    const data = {
      FunctionVersions: buildFunctions.map((v) => v.sid),
      AssetVersions: existingAssets.map((v) => v.sid),
      Dependencies: buildDependencies,
    };
    data.AssetVersions.push(bundleVersion.sid);
    data.AssetVersions.push(sourceMapVersion.sid);

    return data;
  });

  // Register service sid with Config service
  await progress('Registering plugin with Flex', async () => {
    await configurationClient.registerSid(runtime.service.sid);
  });

  // Create a build, and poll regularly until build is complete
  await progress('Deploying a new build of your Twilio Runtime', async () => {
    const newBuild = await buildClient.create(buildData);
    const deployment = await deploymentClient.create(newBuild.sid);

    updatePackageVersion(nextVersion);

    return deployment;
  });

  const accountClient = new AccountsClient(credentials);
  const account = await accountClient.get(runtime.service.account_sid);
  deploySuccessful(pluginUrl, options.isPublic, account);
github twilio / flex-plugin-builder / packages / flex-plugin-scripts / src / scripts / deploy.ts View on Github external
const pluginBaseUrl = paths.assetBaseUrlTemplate.replace('%PLUGIN_VERSION%', nextVersion);
  const bundleUri = `${pluginBaseUrl}/bundle.js`;
  const sourceMapUri = `${pluginBaseUrl}/bundle.js.map`;

  const credentials = await getCredential();

  const runtime = await getRuntime(credentials);
  const pluginUrl = `https://${runtime.environment.domain_name}${bundleUri}`;

  const configurationClient = new ConfigurationClient(credentials);
  const buildClient = new BuildClient(credentials, runtime.service.sid);
  const assetClient = new AssetClient(credentials, runtime.service.sid);
  const deploymentClient = new DeploymentClient(credentials, runtime.service.sid, runtime.environment.sid);

  // Check duplicate routes
  const routeCollision = await progress('Validating the new plugin bundle', async () => {
    const collision = runtime.build ? !_verifyPath(pluginBaseUrl, runtime.build) : false;

    if (collision) {
      if (options.overwrite) {
        if (!options.disallowVersioning) {
          logger.newline();
          logger.warning('Plugin already exists and the flag --overwrite is going to overwrite this plugin.');
        }
      } else {
        throw new FlexPluginError(`You already have a plugin with the same version: ${pluginUrl}`);
      }
    }

    return collision;
  });
github twilio / flex-plugin-builder / packages / flex-plugin-scripts / src / scripts / deploy.ts View on Github external
AssetVersions: existingAssets.map((v) => v.sid),
      Dependencies: buildDependencies,
    };
    data.AssetVersions.push(bundleVersion.sid);
    data.AssetVersions.push(sourceMapVersion.sid);

    return data;
  });

  // Register service sid with Config service
  await progress('Registering plugin with Flex', async () => {
    await configurationClient.registerSid(runtime.service.sid);
  });

  // Create a build, and poll regularly until build is complete
  await progress('Deploying a new build of your Twilio Runtime', async () => {
    const newBuild = await buildClient.create(buildData);
    const deployment = await deploymentClient.create(newBuild.sid);

    updatePackageVersion(nextVersion);

    return deployment;
  });

  const accountClient = new AccountsClient(credentials);
  const account = await accountClient.get(runtime.service.account_sid);
  deploySuccessful(pluginUrl, options.isPublic, account);
};
github twilio / flex-plugin-builder / packages / create-flex-plugin / src / lib / create-flex-plugin.ts View on Github external
export const _scaffold = async (config: FlexPluginArguments): Promise => {
  let dirObject: TmpDirResult;

  const promise = progress('Creating project directory', async () => {
    // This copies the core such as public/ and craco config.
    await copyTemplateDir(
      templateCorePath,
      config.targetDirectory,
      config,
    );

    // Get src directory from template URL if provided
    let srcPath = templateJsPath;
    if (config.typescript) {
      srcPath = templateTsPath;
    }
    if (config.template) {
      dirObject = tmpDirSync();
      await downloadFromGitHub(config.template, dirObject.name);
      srcPath = dirObject.name;
github twilio / flex-plugin-builder / packages / flex-plugin-scripts / src / utils / runtime.ts View on Github external
const getRuntime = async (credentials: AuthConfig, serviceOnly = false): Promise => {
  // Fetch the runtime service instance
  return await progress('Fetching Twilio Runtime service', async () => {
    const serverlessClient = new ServiceClient(credentials);
    const configurationClient = new ConfigurationClient(credentials);

    const serviceSid = (await configurationClient.getServiceSids())[0];
    const service = serviceSid
      ? await serverlessClient.get(serviceSid)
      : await serverlessClient.getDefault();

    if (serviceOnly) {
      return { service };
    }

    const environmentClient = new EnvironmentClient(credentials, service.sid);
    const environment = await environmentClient.get();

    // This is the first time we are doing a build, so we don't have a pre-existing build
github twilio / flex-plugin-builder / packages / flex-plugin-scripts / src / scripts / deploy.ts View on Github external
logger.warning('Plugin already exists and the flag --overwrite is going to overwrite this plugin.');
        }
      } else {
        throw new FlexPluginError(`You already have a plugin with the same version: ${pluginUrl}`);
      }
    }

    return collision;
  });

  const buildAssets = runtime.build ? runtime.build.asset_versions : [];
  const buildFunctions = runtime.build ? runtime.build.function_versions : [];
  const buildDependencies = runtime.build ? runtime.build.dependencies : [];

  // Upload plugin bundle and source map to S3
  const buildData = await progress('Uploading your plugin bundle', async () => {
    // Upload bundle and sourcemap
    const bundleVersion = await assetClient
      .upload(paths.packageName, bundleUri, paths.localBundlePath, !options.isPublic);
    const sourceMapVersion = await assetClient
      .upload(paths.packageName, sourceMapUri, paths.localSourceMapPath, !options.isPublic);

    const existingAssets = routeCollision && options.overwrite
      ?  buildAssets.filter((v) => v.path !== bundleUri && v.path !== sourceMapUri)
      :  buildAssets;

    // Create build
    const data = {
      FunctionVersions: buildFunctions.map((v) => v.sid),
      AssetVersions: existingAssets.map((v) => v.sid),
      Dependencies: buildDependencies,
    };
github twilio / flex-plugin-builder / packages / flex-plugin-scripts / src / scripts / clear.ts View on Github external
const clear = async () => {
  logger.info('Clearing caches and stored credentials');

  await progress('Removing stored credentials', async () => await clearCredentials());

  logger.newline();
  logger.info('✨  Successfully cleared all caches and stored credentials');
  logger.newline();
};
github twilio / flex-plugin-builder / packages / create-flex-plugin / src / lib / create-flex-plugin.ts View on Github external
export const _install = async (config: FlexPluginArguments): Promise => {
  return progress('Installing dependencies', async () => {
    await installDependencies(config);

    return true;
  });
};