How to use the @teleporthq/teleport-shared.UIDLUtils.getComponentFolderPath function in @teleporthq/teleport-shared

To help you get started, we’ve selected a few @teleporthq/teleport-shared 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 teleporthq / teleport-code-generators / packages / teleport-project-generator / src / index.ts View on Github external
injectFilesToPath(rootFolder, path, files)
      collectedDependencies = { ...collectedDependencies, ...dependencies }

      if (this.strategy.pages.moduleGenerator) {
        const pageModule = await createPageModule(pageUIDL, this.strategy, options)
        injectFilesToPath(rootFolder, path, pageModule.files)
      }
    }

    // Handling components
    for (const componentName of Object.keys(components)) {
      const componentUIDL = components[componentName]
      const { files, dependencies } = await createComponent(componentUIDL, this.strategy, options)

      // Components might be generated inside subfolders in the main components folder
      const relativePath = UIDLUtils.getComponentFolderPath(componentUIDL)
      const path = this.strategy.components.path.concat(relativePath)

      injectFilesToPath(rootFolder, path, files)
      collectedDependencies = { ...collectedDependencies, ...dependencies }
    }

    // Handling module generation for components
    if (this.strategy.components.moduleGenerator) {
      const componentsModuleFile = await createComponentModule(uidl, this.strategy)
      injectFilesToPath(rootFolder, this.strategy.components.path, [componentsModuleFile])
    }

    // Global settings are transformed into the root html file and the manifest file for PWA support
    if (uidl.globals.manifest) {
      const manifestFile = createManifestJSONFile(uidl, assetsPrefix)
      injectFilesToPath(rootFolder, this.strategy.static.path, [manifestFile])
github teleporthq / teleport-code-generators / packages / teleport-project-generator / src / index.ts View on Github external
typeof this.strategy.static.prefix === 'string'
        ? this.strategy.static.prefix
        : '/' + this.getAssetsPath().join('/')
    const options: GeneratorOptions = {
      assetsPrefix,
      projectRouteDefinition: root.stateDefinitions.route,
      mapping,
      skipValidation: true,
    }

    // Handling pages
    for (const pageUIDL of pageUIDLs) {
      const { files, dependencies } = await createPage(pageUIDL, this.strategy, options)

      // Pages might be generated inside subfolders in the main pages folder
      const relativePath = UIDLUtils.getComponentFolderPath(pageUIDL)
      const path = this.strategy.pages.path.concat(relativePath)

      injectFilesToPath(rootFolder, path, files)
      collectedDependencies = { ...collectedDependencies, ...dependencies }

      if (this.strategy.pages.moduleGenerator) {
        const pageModule = await createPageModule(pageUIDL, this.strategy, options)
        injectFilesToPath(rootFolder, path, pageModule.files)
      }
    }

    // Handling components
    for (const componentName of Object.keys(components)) {
      const componentUIDL = components[componentName]
      const { files, dependencies } = await createComponent(componentUIDL, this.strategy, options)
github teleporthq / teleport-code-generators / packages / teleport-project-generator / src / utils.ts View on Github external
Object.keys(components).forEach((componentKey) => {
    const component = components[componentKey]

    // values coming from the input UIDL
    const { fileName, componentClassName } = component.outputOptions || {
      fileName: '',
      componentClassName: '',
    }

    const defaultComponentName = 'AppComponent'
    const friendlyName = StringUtils.removeIllegalCharacters(component.name) || defaultComponentName
    const friendlyFileName = fileName || StringUtils.camelCaseToDashCase(friendlyName) // ex: primary-button
    const friendlyComponentName =
      componentClassName || StringUtils.dashCaseToUpperCamelCase(friendlyName) // ex: PrimaryButton
    const folderPath = UIDLUtils.getComponentFolderPath(component)

    const {
      customComponentFileName,
      customStyleFileName,
      customTemplateFileName,
    } = componentStrategyOptions

    // If the component has its own folder, name is 'index' or an override from the strategy.
    // In this case, the file name (dash converted) is used as the folder name
    if (componentStrategyOptions.createFolderForEachComponent) {
      component.outputOptions = {
        componentClassName: friendlyComponentName,
        fileName: (customComponentFileName && customComponentFileName(friendlyFileName)) || 'index',
        styleFileName: (customStyleFileName && customStyleFileName(friendlyFileName)) || 'style',
        templateFileName:
          (customTemplateFileName && customTemplateFileName(friendlyFileName)) || 'template',
github teleporthq / teleport-code-generators / packages / teleport-project-generator / src / utils.ts View on Github external
const setLocalDependencyPath = (
  element: UIDLElement,
  components: Record,
  fromPath: string[],
  toBasePath: string[]
) => {
  const componentKey = element.elementType
  const component = components[componentKey]
  const componentPath = UIDLUtils.getComponentFolderPath(component)
  const componentClassName = UIDLUtils.getComponentClassName(component)

  const toPath = toBasePath.concat(componentPath)

  const importFileName = UIDLUtils.getComponentFileName(component)
  const importPath = generateLocalDependenciesPrefix(fromPath, toPath)
  element.dependency.path = `${importPath}${importFileName}`
  element.elementType = componentClassName
}
github teleporthq / teleport-code-generators / packages / teleport-project-generator / src / utils.ts View on Github external
pageUIDLs.forEach((pageUIDL) => {
    const pagePath = UIDLUtils.getComponentFolderPath(pageUIDL)
    const fromPath = strategy.pages.path.concat(pagePath)
    UIDLUtils.traverseElements(pageUIDL.node, (element) => {
      if (isLocalDependency(element)) {
        setLocalDependencyPath(element, components, fromPath, strategy.components.path)
      }
    })
  })
github teleporthq / teleport-code-generators / packages / teleport-plugin-angular-module / src / index.ts View on Github external
Object.keys(moduleComponents).forEach((componentKey) => {
            const component = moduleComponents[componentKey]
            const componentClassName = UIDLUtils.getComponentClassName(component)
            const componentFileName = UIDLUtils.getComponentFileName(component)
            const componentFolderPath = UIDLUtils.getComponentFolderPath(component)
            dependencies[componentClassName] = constructComponentDependency(
              componentFolderPath,
              componentFileName
            )
          })