How to use the @expo/xdl.ProjectUtils.attachLoggerStream function in @expo/xdl

To help you get started, we’ve selected a few @expo/xdl 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 expo / expo-cli / packages / dev-tools / server / DevToolsServer.js View on Github external
},
    onFinishBuildBundle: (error, start, end, chunk) => {
      buffer.push({
        type: 'UPDATED',
        sourceId: PROCESS_SOURCE.id,
        node: {
          ...chunk,
          error,
          duration: end - (start || new Date()),
        },
      });
    },
  });

  // needed for validation logging to function
  ProjectUtils.attachLoggerStream(projectRoot, {
    stream: {
      write: chunk => {
        if (chunk.tag === 'device') {
          buffer.push({
            type: 'ADDED',
            sourceId: chunk.deviceId,
            node: chunk,
          });
        }
      },
    },
    type: 'raw',
  });

  Logger.global.addStream({
    stream: {
github expo / expo-cli / packages / expo-cli / src / exp.ts View on Github external
}
        }
      },
      updateLogs: (updater: LogUpdater) => {
        let newLogChunks = updater([]);
        newLogChunks.forEach((newLogChunk: LogRecord) => {
          if (newLogChunk.issueId && newLogChunk.issueCleared) {
            return;
          }
          logWithLevel(newLogChunk);
        });
      },
    });

    // needed for validation logging to function
    ProjectUtils.attachLoggerStream(projectDir, {
      stream: {
        write: (chunk: LogRecord) => {
          if (chunk.tag === 'device') {
            logWithLevel(chunk);
          }
        },
      },
      type: 'raw',
    });

    // The existing CLI modules only pass one argument to this function, so skipProjectValidation
    // will be undefined in most cases. we can explicitly pass a truthy value here to avoid
    // validation (eg for init)
    //
    // If the packager/manifest server is running and healthy, there is no need
    // to rerun Doctor because the directory was already checked previously
github expo / expo / apps / test-suite / runner / Run.js View on Github external
export async function ios(Log, { root = '.', 'ios-sim-app-url': iosSimAppUrl }) {
  const testSuitePath = path.resolve(root);

  Log.collapsed('log in as exponent_ci_bot');
  await User.initialize(XDL_CLIENT_ID);
  await User.loginAsync('user-pass', XDL_LOGIN_USERPASS);

  Log.collapsed('start packager');
  ProjectUtils.attachLoggerStream(testSuitePath, {
    type: 'raw',
    stream: {
      write: chunk => console.log(chunk.msg.replace(/\n$/, '')),
    },
  });
  const packagerStarted = new Promise(resolve => {
    ProjectUtils.attachLoggerStream(testSuitePath, {
      type: 'raw',
      stream: {
        write: chunk => {
          if (chunk.tag !== 'metro') {
            return;
          }

          let payload;
          try {
github expo / expo / apps / test-suite / runner / Run.js View on Github external
const allDone = new Promise(resolve => {
    ProjectUtils.attachLoggerStream(testSuitePath, {
      type: 'raw',
      stream: {
        write: chunk => {
          if (chunk.msg.indexOf('[TEST-SUITE-END]') >= 0) {
            resolve(JSON.parse(chunk.msg));
          }
        },
      },
    });
  });
  const results = await allDone;
github expo / expo / tools / expotools / src / commands / RecordDevModeTestAppFixturesCommand.ts View on Github external
async function action(options) {
  console.log('Starting project...');
  let projectDir = path.join(Directories.getExpoRepositoryRootDir(), 'apps', 'dev-mode-test');
  await spawnAsync('yarn', [], {
    cwd: projectDir,
  });
  _rewriteAppJsFileAsync(projectDir, 'INITIAL_STATE');
  await Project.startAsync(projectDir);
  await Fixtures.startRecordingAsync(projectDir, false, options.file || 'devModeFixture.txt');

  let currentState = STATE_INITIAL;
  ProjectUtils.attachLoggerStream(projectDir, {
    type: 'raw',
    stream: {
      write: async chunk => {
        if (chunk.msg.includes('DEV_MODE_TEST_FINISHED_LOADING')) {
          console.log('Detected that app finished loading');

          if (currentState === STATE_INITIAL) {
            console.log('Triggering a live reload...');
            Fixtures.recordFindTextOnScreenEvent('INITIAL_STATE');
            currentState = STATE_FINISHED_FIRST_LOAD;
            await _rewriteAppJsFileAsync(projectDir, 'AFTER_LIVE_RELOAD');
            console.log(
              `Sometimes triggering a live reload doesn't work. If it's not happening please run 'touch ${path.join(
                projectDir,
                'App.js'
              )}'`