How to use the netlify.createClient function in netlify

To help you get started, we’ve selected a few netlify 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 bukinoshita / netlify-docs / lib / deploy.js View on Github external
return new Promise(async resolve => {
    const access_token = await getToken() // eslint-disable-line camelcase
    const { name } = await getCfg()
    const client = netlify.createClient({ access_token }) // eslint-disable-line camelcase
    const sites = await client.sites()
    const dir = join(process.cwd(), '.netlify-docs/build')
    let pkg = {}
    let newSite = true

    try {
      pkg = await readPackage()
    } catch (err) {}

    const siteName = name || `${pkg.name}-docs`

    await execa.shell(
      'cd .netlify-docs && yarn add react-scripts && yarn build'
    )

    sites.forEach(async site => {
github netlify / cli / lib / settings / config.js View on Github external
readOrCreateConfig(program, function(err, config) {
    config.client = netlify.createClient({
      client_id: CLIENT_ID,
      access_token: program.accessToken || (local && local.access_token) || config.access_token,
      endpoint: API_ENDPOINT
    });
    config.siteId = program.siteId || (local && local.site_id);
    config.path = program.path || (local && local.path);
    config.env = program.env;
    cb(config);
  });
};
github netlify / cli / lib / settings / config.js View on Github external
var readOrCreateConfig = function(options, cb) {
  var config = readConfig();
  if (config) {
    cb(null, config);
  } else if (options.accessToken) {
    cb(null, {access_token: options.accessToken});
  } else {
    var client = netlify.createClient({client_id: CLIENT_ID, endpoint: API_ENDPOINT});
    webauth.login({client: client}, function(err, token) {
      config = {access_token: token.access_token};
      writeConfig(config);
      cb(null, config);
    });
  }
};