How to use the @netlify/zip-it-and-ship-it.zipFunctions function in @netlify/zip-it-and-ship-it

To help you get started, we’ve selected a few @netlify/zip-it-and-ship-it 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 netlify / build / packages / netlify-plugin-search-index / index.js View on Github external
if (await pathExists(searchIndexPath)) {
        console.warn(
          `searchIndex detected at ${searchIndexPath}, will overwrite for this build but this may indicate an accidental conflict`,
        )
      }
      await makeDir(`${searchIndexPath}/..`)
      let stringifiedIndex = JSON.stringify(searchIndex)
      await pWriteFile(searchIndexPath, stringifiedIndex)

      const searchIndexFunctionPath = path.join(FUNCTIONS_SRC, 'searchIndex')
      await cpy(__dirname + '/functionTemplate', searchIndexFunctionPath)
      // now we have copied it out to intermediate dir
      // we may want to do some processing/templating
      await pWriteFile(path.join(searchIndexFunctionPath, 'searchIndex.json'), stringifiedIndex)
      // and then..
      await zipFunctions(FUNCTIONS_SRC, FUNCTIONS_DIST)
      console.log('Files copied!')
      // done with generating functions
    },
  }
github netlify / js-client / src / deploy / hash-fns.js View on Github external
async function hashFns(dir, opts) {
  opts = Object.assign(
    {
      concurrentHash: 100,
      assetType: 'function',
      hashAlgorithm: 'sha256',
      // tmpDir,
      statusCb: () => {}
    },
    opts
  )
  // early out if the functions dir is omitted
  if (!dir) return { functions: {}, shaMap: {} }
  if (!opts.tmpDir) throw new Error('Missing tmpDir directory for zipping files')

  const functionZips = await zipIt.zipFunctions(dir, opts.tmpDir)

  const fileObjs = functionZips.map(({ path: functionPath, runtime }) => ({
    filepath: functionPath,
    root: opts.tmpDir,
    relname: path.relative(opts.tmpDir, functionPath),
    basename: path.basename(functionPath),
    extname: path.extname(functionPath),
    type: 'file',
    assetType: 'function',
    normalizedPath: path.basename(functionPath, path.extname(functionPath)),
    runtime
  }))

  const functionStream = fromArray.obj(fileObjs)

  const hasher = hasherCtor(opts)
github netlify / build / packages / build / src / plugins_core / functions.js View on Github external
const onFunctionsPackage = async function({ constants: { FUNCTIONS_SRC, FUNCTIONS_DIST } }) {
  if (!(await pathExists(FUNCTIONS_SRC))) {
    return
  }

  console.log(`Packaging functions from ${FUNCTIONS_SRC}`)
  await zipFunctions(FUNCTIONS_SRC, FUNCTIONS_DIST)

  await logResults(FUNCTIONS_DIST)
}
github netlify / build / packages / build / src / plugins / functions / index.js View on Github external
const onFunctionsPackage = async function({ constants: { FUNCTIONS_SRC, FUNCTIONS_DIST } }) {
  console.log(`Packaging functions from ${FUNCTIONS_SRC}`)
  await zipFunctions(FUNCTIONS_SRC, FUNCTIONS_DIST)

  await logResults(FUNCTIONS_DIST)
}
github netlify / netlify-dev-plugin / src / commands / functions / build.js View on Github external
if (!src || !dst) {
      if (!src)
        this.log(
          `${NETLIFYDEVERR} Error: You must specify a source folder with a --src flag or a functionsSource field in your config`
        );
      if (!dst)
        this.log(
          `${NETLIFYDEVERR} Error: You must specify a destination functions folder with a --functions flag or a functions field in your config`
        );
      process.exit(1);
    }

    fs.mkdirSync(dst, { recursive: true });

    this.log(`${NETLIFYDEVLOG} Building functions`);
    zipFunctions(src, dst, { skipGo: true });
    this.log(`${NETLIFYDEVLOG} Functions built to `, dst);
  }
}
github netlify / cli / src / commands / functions / build.js View on Github external
`${NETLIFYDEVERR} Error: You must specify a destination functions folder with a --functions flag or a functions field in your config`
        )
      process.exit(1)
    }

    await this.config.runHook('analytics', {
      eventName: 'command',
      payload: {
        command: 'functions:build'
      }
    })

    fs.mkdirSync(dst, { recursive: true })

    this.log(`${NETLIFYDEVLOG} Building functions`)
    zipFunctions(src, dst, { skipGo: true })
    this.log(`${NETLIFYDEVLOG} Functions built to `, dst)
  }
}

@netlify/zip-it-and-ship-it

Zip it and ship it

MIT
Latest version published 21 days ago

Package Health Score

86 / 100
Full package analysis