Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import R from 'ramda'
import deasync from 'deasync'
import { CONFIG } from './const'
import initCSSProcessor from './init-processor'
import initStyleGetter from './init-style-getter'
import parseTemplateString from './parse-template-string'
import PostJSSError from './utils/postjss-error'
const init = R.compose(
initStyleGetter,
deasync(cb => initCSSProcessor()
.then(data => cb(null, data))
.catch(cb)),
)
let processCSS
try {
processCSS = init()
} catch (e) {
throw new PostJSSError(e.message)
}
export default ({
extensionsRe = CONFIG.extensionsRe,
namespace = CONFIG.namespace,
* @see https://gist.github.com/muratgozel/e3ca2c08f74c9cb6eb7314e3088edb77#gistcomment-1802108
*
* At the moment PostCSS async parser is using.
*
* To get it as sync function deasync package has been used.
* Be careful! It blocks event loop. See more details in deasync README.
*
* @todo Find a way to do not use deasync
*/
import postcss from 'postcss'
import safeParse from 'postcss-safe-parser'
import postcssJs from 'postcss-js'
import postcssrc from 'postcss-load-config'
import deasync from 'deasync'
const postcssrcSync = deasync(cb => {
postcssrc()
.then(res => cb(null, res))
.catch(err => cb(err))
})
let config = {}
try {
config = postcssrcSync()
} catch (err) {
console.error(err)
}
const processor = postcss(config.plugins || [])
const options = config.options || {}
const finalOptions = { parser: safeParse, ...options }
.then(res => cb(null, res))
.catch(err => cb(err))
})
let config = {}
try {
config = postcssrcSync()
} catch (err) {
console.error(err)
}
const processor = postcss(config.plugins || [])
const options = config.options || {}
const finalOptions = { parser: safeParse, ...options }
const processSync = deasync((raw, cb) => {
return processor.process(raw, finalOptions)
.then(res => cb(null, res))
.catch(err => cb(err))
})
/**
* Parse specified Tagged Template Strings with CSS and expressions
*
* @param {String}
* @returns {Object} JSS object
*/
export default (rawStyles) => {
const processed = processSync(rawStyles)
return postcssJs.objectify(processed.root)
}
export default ({
extensionsRe = CONFIG.extensionsRe,
namespace = CONFIG.namespace,
throwError = CONFIG.throwError,
modules = CONFIG.modules,
} = {}) => ({
modules,
namespace,
throwError,
extensionsRe: new RegExp(extensionsRe, 'i'),
processCSS: deasync((data, cb) => processCSS(data)
.then(result => cb(null, result))
.catch(cb)),
parseTemplateString: deasync((data, cb) => parseTemplateString(data)
.then(result => cb(null, result))
.catch(cb)),
})
/*global module*/
import _ from 'lodash';
import serialize from 'serialize-javascript';
import { exec } from 'child_process';
import deasync from 'deasync';
let execSync = deasync(exec);
let escapeShell;
let AppleJavaScript = (...args) => {
let result = AppleJavaScript.runSafe(...args);
return AppleJavaScript.unserialize(result);
};
AppleJavaScript.runSafe = (...args) => {
let functionText = AppleJavaScript.build(...args);
return AppleJavaScript.execSync(functionText);
};
AppleJavaScript.build = (...args) => {
let fn = _(args).last();
let argsToPass = args
import ignore, { Ignore } from 'ignore';
import { safeLoad as loadYaml, dump as dumpYaml } from 'js-yaml';
import { mergeWith } from 'lodash';
import _mkdirp from 'mkdirp';
import { OpenAPIV2 } from 'openapi-types';
import Path from 'path';
import { sync as rimraf } from 'rimraf';
import { dereference } from 'swagger-parser';
import { v4 as uuid } from 'uuid';
import vm from 'vm';
import * as u from './util';
import { BaseState } from './state';
import { finalize, steps } from './steps';
import { TypeDictionary } from './types';
const mkdirp = deasync(_mkdirp);
export interface IConfig {
name: string;
platform: string;
default_storage: string;
output_dir: string;
api_spec?: string;
credentials?: ICredential[];
}
export interface ICredential {
api: string;
[x: string]: string;
}
export interface IPackageJson {
export default ({
extensionsRe = CONFIG.extensionsRe,
namespace = CONFIG.namespace,
throwError = CONFIG.throwError,
modules = CONFIG.modules,
} = {}) => ({
modules,
namespace,
throwError,
extensionsRe: new RegExp(extensionsRe, 'i'),
processCSS: deasync((data, cb) => processCSS(data)
.then(result => cb(null, result))
.catch(cb)),
parseTemplateString: deasync((data, cb) => parseTemplateString(data)
.then(result => cb(null, result))
.catch(cb)),
})