3.0.0-rc.21-pinotest2 • Published 1 year ago

@opendesign/octopus-xd v3.0.0-rc.21-pinotest2

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
1 year ago

Octopus Converter for Adobe XD

Adobe XD to Octopus 3 converter.

Install

yarn

Usage

There are three main processing steps:

  • reading source data (using readers)
  • conversion (using convertor with SourceDesign instance produced by reader)
  • exporting (using exporters)

Although you can define the way of reading assets or exporting results yourself (create your own reader/exporter class), you can also choose between existing ones:

import os from 'os'
import path from 'path'

import { v4 as uuidv4 } from 'uuid'

/**
 * Reader (`XDFileReader`) reads `.xd` files by given path.
 * Exporter (`LocalExporter`) defines how and where save outputs.
 * Converter takes `SourceDesign` entitiy which should be available from reader as constructor option and exporter as convertDesign option.
 */
import { OctopusXDConverter, LocalExporter, XDFileReader } from '../src'

async function convert() {
  const [filename] = process.argv.slice(2)
  const testDir = path.join(os.tmpdir(), uuidv4())
  const reader = new XDFileReader({ path: filename, storeAssetsOnFs: true })
  const sourceDesign = await reader.sourceDesign
  const converter = new OctopusXDConverter({ sourceDesign })
  const exporter = new LocalExporter({ path: testDir })
  await converter.convertDesign({ exporter })
  await exporter.completed()
  await reader.cleanup()
  console.log(`Input: ${filename}`)
  console.log(`Output: ${testDir}`)
}

convert()

Check src/services/conversion/exporter for more details about exporters.

Check src/services/conversion/xd-file-reader for more details about readers


Environment

You can create .env file which will be autoloaded using dotenv.

VariableTypeDescription
NODE_ENVproduction / development / debugNode environment
LOG_LEVELfatal / error / warn / info / debug / trace / silentLog level
SENTRY_DSNstringSentry DSN
CONVERT_RENDERbooleanif true will trigger rendering when octopus3.json is ready
RENDERING_PATHstringpath to rendering command (e.g. orchestrator4.run)
RENDERING_IGNORE_VALIDATIONbooleanignores the rendering validation
FONTS_PATHstringpath to directory with fonts

Scripts

Convert to temporary directory

yarn convert:all PATH_TO_XD_FILE

Converts XD file located at PATH_TO_XD_FILE to temporary directory.

Debug

yarn convert:all:debug PATH_TO_XD_FILE

Useful and verbose script for debugging. Accepts multiple paths.


TypeDoc

Command yarn typedoc will generate TypeDoc documentation for public Classes into ./docs folder


Unit Tests

yarn test