How to use the @serverless/utils.resolve function in @serverless/utils

To help you get started, we’ve selected a few @serverless/utils 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 serverless / components / registry / AwsLambdaCompute / src / index.js View on Github external
async defineFunction(functionInstance, context) {
      const funcInstance = resolve(functionInstance)
      // need to resolve these two variables now to convert values
      const ufs = resolve(funcInstance.ufs) || resolve(this.ufs) || false
      const runtime = convertRuntime(resolve(funcInstance.runtime) || resolve(this.runtime))
      let code = resolve(funcInstance.code)

      const inputs = {
        provider: this.provider,
        role: this.role,
        functionName: funcInstance.functionName,
        functionDescription: funcInstance.functionDescription,
        memorySize: resolve(funcInstance.memory) || resolve(this.memory),
        timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
        runtime,
        handler: resolve(funcInstance.handler),
        environment: {
          ...resolve(this.environment),
github serverless / components / registry / AwsLambdaCompute / src / index.js View on Github external
async defineFunction(functionInstance, context) {
      const funcInstance = resolve(functionInstance)
      // need to resolve these two variables now to convert values
      const ufs = resolve(funcInstance.ufs) || resolve(this.ufs) || false
      const runtime = convertRuntime(resolve(funcInstance.runtime) || resolve(this.runtime))
      let code = resolve(funcInstance.code)

      const inputs = {
        provider: this.provider,
        role: this.role,
        functionName: funcInstance.functionName,
        functionDescription: funcInstance.functionDescription,
        memorySize: resolve(funcInstance.memory) || resolve(this.memory),
        timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
        runtime,
        handler: resolve(funcInstance.handler),
        environment: {
          ...resolve(this.environment),
          ...resolve(funcInstance.environment)
        },
        code,
        tags: {
          ...resolve(this.tags),
          ...resolve(funcInstance.tags)
        }
      }

      if (ufs) {
        code = [code, getShimFile(runtime)]
github serverless / components / src / types / AwsLambdaCompute / index.js View on Github external
async defineFunction(functionInstance, context) {
      const funcInstance = resolve(functionInstance)
      // need to resolve these two variables now to convert values
      const ufs = resolve(this.ufs) || resolve(funcInstance.ufs) || false
      const runtime = convertRuntime(resolve(funcInstance.runtime) || resolve(this.runtime))
      let code = resolve(funcInstance.code)

      const inputs = {
        provider: this.provider,
        role: this.role,
        functionName: funcInstance.functionName,
        functionDescription: funcInstance.functionDescription,
        memorySize: resolve(funcInstance.memory) || resolve(this.memory),
        timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
        runtime,
        handler: resolve(funcInstance.handler),
        environment: {
          ...resolve(this.environment),
          ...resolve(funcInstance.environment)
        },
github serverless / components / registry / AwsS3Website / src / index.js View on Github external
async construct(inputs, context) {
      await super.construct(inputs, context)

      this.buildCmd = inputs.buildCmd
      this.env = inputs.env
      this.projectDir = resolve(inputs.projectDir)
      this.assets = resolve(inputs.assets) || resolve(inputs.projectDir)

      // TODO BRN: Move this to a validate step (maybe on a per property basis that validates when set)
      if (!path.isAbsolute(this.projectDir)) {
        throw new Error('projectDir must be an absolute path. Construct local paths using ${path}.')
      }

      this.envFileLocation = path.resolve(this.projectDir, resolve(inputs.envFileLocation))
      this.assets = path.resolve(this.projectDir, resolve(inputs.assets))
    }
github serverless / components / src / utils / serialize / utils / serializeObject.js View on Github external
(accum, value, key) => {
      value = resolve(value)
      if (isSerializable(value)) {
        if (isSymbol(key)) {
          const symbolString = getSymbolString(context, key)
          if (symbolString) {
            if (isSerializableReferenceable(value)) {
              return set(['symbols', symbolString], toReference(context, value), accum)
            }
            return set(['symbols', symbolString], serializeValue(context, value), accum)
          }
          // context.log(`unhandled symbol detected ${toString(key)}`)
        } else {
          if (isSerializableReferenceable(value)) {
            return set(['props', key], toReference(context, value), accum)
          }
          return set(['props', key], serializeValue(context, value), accum)
        }
github serverless / components / src / types / AwsLambdaCompute / index.js View on Github external
async defineFunction(functionInstance, context) {
      const funcInstance = resolve(functionInstance)
      // need to resolve these two variables now to convert values
      const ufs = resolve(this.ufs) || resolve(funcInstance.ufs) || false
      const runtime = convertRuntime(resolve(funcInstance.runtime) || resolve(this.runtime))
      let code = resolve(funcInstance.code)

      const inputs = {
        provider: this.provider,
        role: this.role,
        functionName: funcInstance.functionName,
        functionDescription: funcInstance.functionDescription,
        memorySize: resolve(funcInstance.memory) || resolve(this.memory),
        timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
        runtime,
        handler: resolve(funcInstance.handler),
        environment: {
          ...resolve(this.environment),
          ...resolve(funcInstance.environment)
        },
        code,
        tags: {
          ...resolve(this.tags),
          ...resolve(funcInstance.tags)
        }
      }

      if (ufs) {
        code = [code, getShimFile(runtime)]
        inputs.code = code
github serverless / components / src / utils / component / getChildrenIds.js View on Github external
(accum, childKey) => {
        const instanceId = resolve(get('instanceId', children[childKey]))
        if (isNil(instanceId)) {
          throw new Error(
            `Found a child without an instanceId while getting children ids. This should not happen. The child was ${
              children[childKey]
            } and belongs to parent ${component}`
          )
        }
        return append(instanceId, accum)
      },
      [],
github serverless / components / src / types / AwsLambdaCompute / index.js View on Github external
const inputs = {
        provider: this.provider,
        role: this.role,
        functionName: funcInstance.functionName,
        functionDescription: funcInstance.functionDescription,
        memorySize: resolve(funcInstance.memory) || resolve(this.memory),
        timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
        runtime,
        handler: resolve(funcInstance.handler),
        environment: {
          ...resolve(this.environment),
          ...resolve(funcInstance.environment)
        },
        code,
        tags: {
          ...resolve(this.tags),
          ...resolve(funcInstance.tags)
        }
      }

      if (ufs) {
        code = [code, getShimFile(runtime)]
        inputs.code = code
        inputs.handler = 'shim.handler'
        inputs.environment.SERVERLESS_HANDLER = functionInstance.handler
      }

      return context.construct(AwsLambdaFunction, inputs)
    },
    async defineSchedule(functionInstance, rate, context) {
github serverless / components / registry / AwsS3Bucket / src / index.js View on Github external
async sync() {
      let { provider } = this
      provider = resolve(provider)
      const AWS = provider.getSdk()
      const S3 = new AWS.S3()

      try {
        await S3.getBucketLocation({ Bucket: resolve(this.bucketName) }).promise()
      } catch (e) {
        if (e.code === 'NoSuchBucket') {
          return 'removed'
        }
        throw e
      }
    }