How to use the now.json function in now

To help you get started, we’ve selected a few now 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 zeit / now / test / lib / run-build-lambda.js View on Github external
async function runBuildLambda(inputPath) {
  const inputFiles = await glob('**', inputPath);
  const nowJsonRef = inputFiles['now.json'];
  expect(nowJsonRef).toBeDefined();
  const nowJson = require(nowJsonRef.fsPath);
  expect(nowJson.builds.length).toBe(1);
  const build = nowJson.builds[0];
  expect(build.src.includes('*')).toBeFalsy();
  const entrypoint = build.src.replace(/^\//, ''); // strip leftmost slash
  expect(inputFiles[entrypoint]).toBeDefined();
  inputFiles[entrypoint].digest =
    'this-is-a-fake-digest-for-non-default-analyze';
  const wrapper = require(build.use);

  const analyzeResult = runAnalyze(wrapper, {
    files: inputFiles,
    entrypoint,
    config: build.config
  });
github nuxt / now-builder / test / utils / run-build-lambda.js View on Github external
async function runBuildLambda(inputPath) {
  const inputFiles = await glob('**', inputPath)

  const nowJsonRef = inputFiles['now.json']

  const nowJson = require(nowJsonRef.fsPath)

  const build = nowJson.builds[0]

  const entrypoint = build.src.replace(/^\//, '') // Strip leftmost slash

  inputFiles[entrypoint].digest = 'this-is-a-fake-digest-for-non-default-analyze'

  const wrapper = require(build.use)

  const analyzeResult = runAnalyze(wrapper, {
    files: inputFiles,
    entrypoint,
    config: build.config
  })
github codesandbox / codesandbox-client / packages / app / src / app / store / modules / deployment / actions.js View on Github external
export async function createApiData({ props, state }) {
  const { contents } = props;
  const sandboxId = state.get('editor.currentId');
  const sandbox = state.get(`editor.sandboxes.${sandboxId}`);
  const template = getTemplate(sandbox.template);
  let apiData = {
    files: [],
  };

  let packageJSON = {};
  let nowJSON = {};
  const projectPackage = contents.files['package.json'];
  const nowFile = contents.files['now.json'];

  if (projectPackage) {
    const data = await projectPackage.async('text'); // eslint-disable-line no-await-in-loop

    const parsed = JSON.parse(data);
    packageJSON = parsed;
  }

  if (nowFile) {
    const data = await nowFile.async('text'); // eslint-disable-line no-await-in-loop

    const parsed = JSON.parse(data);
    nowJSON = parsed;
  } else if (packageJSON.now) {
    // Also support package.json if imported like that
    nowJSON = packageJSON.now;
github codesandbox / codesandbox-client / packages / app / src / app / overmind / effects / zeit.ts View on Github external
async function getApiData(contents: any, sandbox: Sandbox) {
  const template = getTemplate(sandbox.template);

  let apiData: Partial = {
    files: [],
  };
  let packageJSON: any = {};
  let nowJSON: any = {};

  const projectPackage = contents.files['package.json'];
  const nowFile = contents.files['now.json'];

  if (projectPackage) {
    const data = await projectPackage.async('text'); // eslint-disable-line no-await-in-loop

    const parsed = JSON.parse(data);
    packageJSON = parsed;
  }

  if (nowFile) {
    const data = await nowFile.async('text'); // eslint-disable-line no-await-in-loop

    const parsed = JSON.parse(data);
    nowJSON = parsed;
  } else if (packageJSON.now) {
    // Also support package.json if imported like that
    nowJSON = packageJSON.now;
github zeit / now / test / lib / deployment / test-deployment.js View on Github external
build.config = build.config || {};
      const { config } = build;
      if (buildUtilsUrl === '@canary') {
        config.useBuildUtils = config.useBuildUtils || '@now/build-utils';
        config.useBuildUtils = `${config.useBuildUtils}@canary`;
      } else {
        config.useBuildUtils = `https://${buildUtilsUrl}`;
      }
    }

    if (buildDelegate) {
      buildDelegate(build);
    }
  }

  bodies['now.json'] = Buffer.from(JSON.stringify(nowJson));
  delete bodies['probe.js'];
  const { deploymentId, deploymentUrl } = await nowDeploy(bodies, randomness);
  console.log('deploymentUrl', `https://${deploymentUrl}`);

  for (const probe of nowJson.probes || []) {
    console.log('testing', JSON.stringify(probe));
    if (probe.delay) {
      await new Promise(resolve => setTimeout(resolve, probe.delay));
      continue;
    }
    const probeUrl = `https://${deploymentUrl}${probe.path}`;
    const fetchOpts = {
      ...probe.fetchOptions,
      method: probe.method,
      headers: { ...probe.headers },
    };
github zeit / now / test / lib / deployment / test-deployment.js View on Github external
}, {});

  const randomness = Math.floor(Math.random() * 0x7fffffff)
    .toString(16)
    .repeat(6)
    .slice(0, RANDOMNESS_PLACEHOLDER_STRING.length);

  for (const file of Object.keys(bodies)) {
    bodies[file] = bufferReplace(
      bodies[file],
      RANDOMNESS_PLACEHOLDER_STRING,
      randomness
    );
  }

  const nowJson = JSON.parse(bodies['now.json']);
  for (const build of nowJson.builds) {
    if (builderUrl) {
      if (builderUrl === '@canary') {
        build.use = `${build.use}@canary`;
      } else {
        build.use = `https://${builderUrl}`;
      }
    }
    if (buildUtilsUrl) {
      build.config = build.config || {};
      const { config } = build;
      if (buildUtilsUrl === '@canary') {
        config.useBuildUtils = config.useBuildUtils || '@now/build-utils';
        config.useBuildUtils = `${config.useBuildUtils}@canary`;
      } else {
        config.useBuildUtils = `https://${buildUtilsUrl}`;

now

The command-line interface for Vercel

Apache-2.0
Latest version published 4 years ago

Package Health Score

59 / 100
Full package analysis