Ejemplo n.º 1
0
    eventFields.map((key: string) => {

        const variant = eventData[key];
        if (!variant || variant.dataType === DataType.Null) {
            return;
        }
        if (variant.dataType === DataType.ByteString) {
            console.log(w("", 20), chalk.yellow(w(key, 15)),
              chalk.cyan(w(DataType[variant.dataType], 10).toString()),
              variant.value.toString("hex"));

        } else if (variant.dataType === DataType.NodeId) {

            const node = addressSpace.findNode(variant.value);
            const name = node ? node.browseName.toString() : variant.value.toString();

            console.log(chalk.yellow(w(name, 20), w(key, 15)),
              chalk.cyan(w(DataType[variant.dataType], 10).toString()),
              chalk.cyan.bold(name), "(", w(variant.value, 20), ")");

        } else {
            console.log(w("", 20),
              chalk.yellow(w(key, 15)),
              chalk.cyan(w(DataType[variant.dataType], 10).toString()),
              variant.value.toString());
        }
    });
Ejemplo n.º 2
0
export const usageRoot = (showQuickstart: boolean) => `
  Serverless GraphQL backend for frontend developers (${chalk.underline('https://www.graph.cool')})
  
  ${chalk.dim('Usage:')} ${chalk.bold('graphcool')} [command]

  ${chalk.dim('Commands:')}${showQuickstart ? `
    quickstart    Open Graphcool Quickstart examples`: ''}
    init          Create a new project
    push          Push project file changes
    pull          Download the latest project file
    export        Export project data
    endpoints     Print GraphQL endpoints
    console       Open Graphcool Console
    playground    Open GraphQL Playground
    projects      List projects
    delete        Delete existing projects
    auth          Sign up or login
    version       Print version
    
  Run 'graphcool COMMAND --help' for more information on a command.
  
  ${chalk.dim('Examples:')}
  
  ${chalk.gray('-')} Initialize a new Graphcool project
    ${chalk.cyan('$ graphcool init')}
  
  ${chalk.gray('-')} Local setup of an existing project
    ${chalk.cyan('$ graphcool pull -p <project-id | alias>')}
    
  ${chalk.gray('-')} Update live project with local changes
    ${chalk.cyan('$ graphcool push')}
    
`
// Verifies that the test workspace contains the given directory
export default async function verifyWorkspaceContainsDirectory(
  args: ActionArgs
) {
  const directory = args.nodes.text()
  const fullPath = path.join(args.configuration.workspace, directory)
  args.formatter.name(
    `verifying the ${chalk.bold(
      chalk.cyan(directory)
    )} directory exists in the test workspace`
  )
  args.formatter.log(`ls ${fullPath}`)
  let stats
  try {
    stats = await fs.lstat(fullPath)
  } catch (err) {
    throw new Error(
      `directory ${chalk.cyan(
        chalk.bold(directory)
      )} does not exist in the test workspace`
    )
  }
  if (!stats.isDirectory()) {
    throw new Error(
      `${chalk.cyan(chalk.bold(directory))} exists but is not a directory`
    )
  }
}
app.listen(port, () => {
  if (process.env.NODE_ENV === 'development') {
    if (process.env.GRAPHIQL) {
      console.log('The GraphiQL App is running at:');
      console.log();
      console.log(`  ${chalk.cyan(`http://localhost:${port}/${paths.GRAPHIQL_PATH }`)}`);
    } else {
      console.log('The Koa App is running at:');
      console.log();
      console.log(`  ${chalk.cyan(`http://localhost:${port}`)}`);
    }
    if (process.env.VOYAGER) {
      if (process.env.GRAPHIQL) {
        console.log();
      }
      console.log('The GraphQL Voyager App is running at:');
      console.log();
      console.log(`  ${chalk.cyan(`http://localhost:${port}/${paths.VOYAGER_PATH}`)}`);
    }
    if (process.env.PLAYGROUND) {
      if (process.env.GRAPHIQL || process.env.VOYAGER) {
        console.log();
      }
      console.log('The GraphQL Plaground App is running at:');
      console.log();
      console.log(`  ${chalk.cyan(`http://localhost:${port}/${paths.PLAYGROUND_PATH}`)}`);
    }
  } else {
    console.log('The Koa App is running');
  }
});
Ejemplo n.º 5
0
export const unknownOptionsWarning = (command: string, unknownOptions: string[]) => unknownOptions.length > 1 ? `\
${chalk.bold('Error:')} The following options are not recognized: ${chalk.red(`${unknownOptions.map(a => a)}`)}
Use ${chalk.cyan(`\`graphcool ${command} --help\``)} to see a list of all possible options.
` : `\
${chalk.bold('Error:')} The following option is not recognized: ${chalk.red(`${unknownOptions[0]}`)}
Use ${chalk.cyan(`\`graphcool ${command} --help\``)} to see a list of all possible options.
`
Ejemplo n.º 6
0
 compiler.hooks.done.tap('taroDoneFirst', stats => {
   if (isFirst) {
     isFirst = false
     getServeSpinner().clear()
     console.log()
     console.log(chalk.cyan(`ℹ️  Listening at ${urls.lanUrlForTerminal}`))
     console.log(chalk.cyan(`ℹ️  Listening at ${urls.localUrlForBrowser}`))
     console.log(chalk.gray('\n监听文件修改中...\n'))
   }
 })
        it('should return a cyan-styled percentage', () => {
            const reporter = new LzhReporter({});

            let styled = reporter._getStyledPercentage(100, 89);
            let expected = chalk.cyan('11%');
            expect(styled).to.eq(expected);

            styled = reporter._getStyledPercentage(100, 80);
            expected = chalk.cyan('20%');
            expect(styled).to.eq(expected);
        });
// istanbul ignore next
function dump_request(request: Request, requestId: number, channelId: number) {
    console.log(
      chalk.cyan("xxxx   <<<< ---------------------------------------- "),
      chalk.yellow(request.schema.name),
      "requestId",
      requestId,
      "channelId=",
      channelId
    );
    console.log(request.toString());
    console.log(chalk.cyan("xxxx   <<<< ---------------------------------------- \n"));
}
Ejemplo n.º 9
0
  function build_graph(task: Task<any>): void {
    nodes.add(task)

    for (const dep of task.deps) {
      const task_dep = tasks.get(dep)
      if (task_dep != null) {
        edges.push([task_dep, task]) // before -> after
        build_graph(task_dep)
      } else
        throw new Error(`unknown task '${chalk.cyan(dep)}' referenced from '${chalk.cyan(name)}'`)
    }
  }
Ejemplo n.º 10
0
async function main() {

    const server = new OPCUAServer(server_options);

    server.on("post_initialize", () => {
        /* empty */
    });

    console.log(chalk.yellow("  server PID          :"), process.pid);
    console.log(chalk.yellow("  silent              :"), argv.silent);

    await server.start();

    const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl!;
    console.log(chalk.yellow("  server on port      :"), chalk.cyan(server.endpoints[0].port.toString()));
    console.log(chalk.yellow("  endpointUrl         :"), chalk.cyan(endpointUrl));

    console.log(chalk.yellow("\n  server now waiting for connections. CTRL+C to stop"));

    if (argv.silent) {
        console.log("silent");
        console.log = (...args: [any?, ... any[]]) => {
            /* silent */
        };
    }

    server.on("create_session", (session: ServerSession) => {
        console.log(" SESSION CREATED");
        console.log(chalk.cyan("    client application URI: "), session.clientDescription!.applicationUri);
        console.log(chalk.cyan("        client product URI: "), session.clientDescription!.productUri);
        console.log(chalk.cyan("   client application name: "), session.clientDescription!.applicationName.toString());
        console.log(chalk.cyan("   client application type: "), session.clientDescription!.applicationType.toString());
        console.log(chalk.cyan("              session name: "), session.sessionName ? session.sessionName.toString() : "<null>");
        console.log(chalk.cyan("           session timeout: "), session.sessionTimeout);
        console.log(chalk.cyan("                session id: "), session.nodeId);
    });

    server.on("session_closed", (session: ServerSession, reason: string) => {
        console.log(" SESSION CLOSED :", reason);
        console.log(chalk.cyan("              session name: "), session.sessionName ? session.sessionName.toString() : "<null>");
    });

    process.on("SIGINT", async () => {
        // only work on linux apparently
        console.error(chalk.red.bold(" Received server interruption from user "));
        console.error(chalk.red.bold(" shutting down ..."));
        await server.shutdown(1000);
        console.error(chalk.red.bold(" shot down ..."));
        process.exit(1);
    });

}