How to use the @ditojs/utils.camelize function in @ditojs/utils

To help you get started, we’ve selected a few @ditojs/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 ditojs / dito / packages / build / src / webpack.js View on Github external
const addDependency = dependency => {
    if (!externals[dependency] && !excludes[dependency]) {
      externals[dependency] = {
        root: camelize(dependency, true),
        amd: dependency,
        commonjs: dependency,
        commonjs2: dependency
      }
      try {
        // Attempt loading the dependency's own dependencies and recursively
        // mark these as externals as well:
        const packageJson = require(`${dependency}/package.json`)
        addDependencies(packageJson.dependencies)
        addDependencies(packageJson.peerDependencies)
        addDependencies(packageJson.devDependencies)
      } catch (err) {
      }
    }
  }
  // Start with cwd to read from './package.json' and take it from there.
github ditojs / dito / packages / server / src / cli / db / seed.js View on Github external
indices[name] = index
      return indices
    },
    {}
  )
  // Collect all seed, and separate between seed functions and model see data:
  for (const file of files) {
    const { name, ext, base } = path.parse(file)
    if (!name.startsWith('.') && ['.js', '.json'].includes(ext)) {
      const object = await import(path.resolve(seedDir, file))
      const seed = object.default || object
      // Try to determine the related model from the seed name, and use it also
      // to determine seed sequence based on its index in `app.models`.
      const modelClass =
        app.models[name] ||
        app.models[camelize(pluralize.singular(name), true)]
      const index = modelClass ? modelIndices[modelClass.name] : Infinity
      seeds.push({
        base,
        seed,
        modelClass,
        index
      })
    }
  }
  // Now sort the seed model data according to `app.models` sorting,
  // as determined by `Application.sortModels()`:
  seeds.sort((entry1, entry2) => entry1.index - entry2.index)
  for (const { base, seed, modelClass } of seeds) {
    await handleSeed(app, base, seed, modelClass)
  }
  return true
github ditojs / dito / packages / server / src / controllers / ModelController.js View on Github external
setup() {
    super.setup(true)
    this.modelClass = this.modelClass ||
      this.app.models[camelize(pluralize.singular(this.name), true)]
    this.relations = this.setupRelations()
  }
github ditojs / dito / packages / server / src / schema / relations.js View on Github external
export function getRelationClass(relation) {
  return isString(relation)
    ? relationLookup[camelize(relation)] || relationClasses[relation]
    : Relation.isPrototypeOf(relation)
      ? relation
      : null
}
github ditojs / dito / packages / admin / src / utils / schema.js View on Github external
? toObject(descriptions, value => (
      isObject(value) ? value : {
        name: camelize(value, false)
      }
    ))
    : isObject(descriptions)
github ditojs / dito / packages / server / src / cli / index.js View on Github external
function getCommand(commands, parts) {
  const part = parts.shift()
  return commands && part
    ? getCommand(commands[camelize(part)], parts)
    : commands
}
github ditojs / dito / packages / admin / src / utils / schema.js View on Github external
? toObject(descriptions, value => (
      isObject(value) ? value : {
        name: camelize(value, false)
      }
    ))
    : isObject(descriptions) && Object.keys(descriptions).length
github ditojs / dito / packages / server / src / services / Service.js View on Github external
constructor(app, name) {
    this.app = app
    this.name = camelize(
      (name || this.constructor.name).match(/^(.*?)(?:Service|)$/)[1]
    )
    this.config = null
  }