Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Sketch, Page, Artboard, Text, Rectangle } from 'sketch-constructor';
import * as sketchJson from 'sketch-json';
import * as fs from 'fs';
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
const buildFolder = './build';
const newSketch = new Sketch({});
const pageWelcome = new Page({
name: 'Welcome'
});
let yPos = 0;
const addYPos = (value: number = 0) => {
return yPos = yPos + value;
}
const textVersion = new Text({
string: `Version: ${pkg.version}`,
name: `Version: ${pkg.version}`,
fontSize: 16,
color: "#777",
frame: {
x: 1058,
function buildFlows(designInfo, newSketch) {
for (const flow of designInfo.flows) {
const page = new Page({
name: flow.flowName
});
if (flow.interactions == null) {
continue;
}
var index = 1;
for (const interaction of flow.interactions) {
let seeComponentName = interaction.see.componentName.replace(/\"/g, "");
let seeComponentData = interaction.see.data.replace(/\"/g, "");
const artboard = new Artboard({
name: seeComponentData + seeComponentName,
frame: {
width: '320px',
height: '480px',
function buildLibrary(designInfo, newSketch) {
const libraryPage = new Page({
name: "Library"
});
var offset = 20;
var lastX = 20;
for (const library of designInfo.libraries) {
const artboard = new Artboard({
name: library.libraryName
});
switch (library.libraryName) {
case "Color":
buildColorLibrary(library.libraryPresets, newSketch, artboard);
break;
case "FontSize":
buildFontSizeLibrary(library.libraryPresets, newSketch, artboard);