Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
const starterConfigPath = resolve(ROOT, 'tslint.json')
const libPackageConfigPath = resolve(PACKAGE_ROOT, 'tslint.json')
/**
* @type {TsLintConfig}
*/
const starterConfig = JSON5.parse(
readFileSync(starterConfigPath, { encoding: 'utf-8' })
)
/**
* @type {TsLintConfig}
*/
const libConfig = JSON5.parse(
readFileSync(libPackageConfigPath, { encoding: 'utf-8' })
)
// @TODO find out how to properly merge objects with comments as tslint.json supports comments
// 👉 https://github.com/Hotell/typescript-lib-starter/issues/133
// log('starter:', starterConfig)
// log('library:', libConfig)
log('==TS-Lint:nothing updated ☕️ ==\n')
}
function updateTsLintConfig() {
/**
* @typedef {typeof import('../../tslint.json')} TsLintConfig
*/
const starterConfigPath = resolve(ROOT, 'tslint.json')
const libPackageConfigPath = resolve(PACKAGE_ROOT, 'tslint.json')
/**
* @type {TsLintConfig}
*/
const starterConfig = JSON5.parse(
readFileSync(starterConfigPath, { encoding: 'utf-8' })
)
/**
* @type {TsLintConfig}
*/
const libConfig = JSON5.parse(
readFileSync(libPackageConfigPath, { encoding: 'utf-8' })
)
// @TODO find out how to properly merge objects with comments as tslint.json supports comments
// 👉 https://github.com/Hotell/typescript-lib-starter/issues/133
// log('starter:', starterConfig)
// log('library:', libConfig)
var d = getContents(handle).then(function (contents) {
var data = null;
if (!ALL_WHITE_SPACE.test(contents)) {
try {
data = JSON5.parse(contents);
} catch (e) {
data = {
error: "Couldn't parse (JSON5) '"+handle+"'\nERROR: " + e
};
}
}
data = data || {};
return data;
}).otherwise(function (err) {
debug_log(err);
parseFile(basePath: PortablePath, args: any[] = [], options: ParseOptions = {}): T {
const filePath = Path.create(basePath);
const name = filePath.name();
const ext = filePath.ext();
let value: any = null;
this.debug('Parsing file %s', color.filePath(filePath));
if (!filePath.isAbsolute()) {
throw new Error(this.tool.msg('errors:absolutePathRequired'));
}
if (ext === '.json' || ext === '.json5') {
value = JSON5.parse(fs.readFileSync(filePath.path(), 'utf8'));
} else if (ext === '.js') {
value = requireModule(filePath);
if (typeof value === 'function') {
if (options.errorOnFunction) {
throw new Error(this.tool.msg('errors:configNoFunction', { name }));
} else {
value = value(...args);
}
}
} else {
throw new Error(this.tool.msg('errors:configUnsupportedExt', { ext }));
}
if (!isObject(value)) {
throw new Error(this.tool.msg('errors:configInvalidNamed', { name }));
public read(filename: string): RawConfiguration {
switch (path.extname(filename)) {
case '.json':
case '.json5':
return json5.parse(this.fs.readFile(filename));
case '.yaml':
case '.yml':
return yaml.safeLoad(this.fs.readFile(filename))!;
default:
return this.resolver.require(filename, {cache: false});
}
}
function updateTsConfig() {
/**
* @typedef {typeof import('../tsconfig.json')} TsConfig
*/
const starterConfigPath = resolve(ROOT, 'tsconfig.json')
const libPackageConfigPath = resolve(PACKAGE_ROOT, 'tsconfig.json')
/**
* @type {TsConfig}
*/
const starterConfig = JSON5.parse(
readFileSync(starterConfigPath, { encoding: 'utf-8' })
)
/**
* @type {TsConfig}
*/
const libConfig = JSON5.parse(
readFileSync(libPackageConfigPath, { encoding: 'utf-8' })
)
const newConfig = {
...libConfig,
compilerOptions: {
...libConfig.compilerOptions,
...starterConfig.compilerOptions,
},
private parseComment(filepath: string, comment: string): IRcFragment {
let rc: IRcFragment = {};
try {
rc = JSON5.parse(comment);
} catch (e) {}
rc = fixPath(path.dirname(filepath), rc);
return rc;
}
function parseTheme(theme) {
return JSON.parse(theme.replace(/^\s*\/\/"/gm, '"'));
}
*/
const starterConfigPath = resolve(ROOT, 'tsconfig.json')
const libPackageConfigPath = resolve(PACKAGE_ROOT, 'tsconfig.json')
/**
* @type {TsConfig}
*/
const starterConfig = JSON5.parse(
readFileSync(starterConfigPath, { encoding: 'utf-8' })
)
/**
* @type {TsConfig}
*/
const libConfig = JSON5.parse(
readFileSync(libPackageConfigPath, { encoding: 'utf-8' })
)
const newConfig = {
...libConfig,
compilerOptions: {
...libConfig.compilerOptions,
...starterConfig.compilerOptions,
},
include: [...new Set([...libConfig.include, ...starterConfig.include])],
}
const updatedLibTsConfigToWrite = JSON.stringify(newConfig, null, 2)
writeFileSync(libPackageConfigPath, updatedLibTsConfigToWrite)
log(kleur.green('==TS-Config:updated ☕️ ✅ ==\n'))
import pkgJson from '../package.json'
import { actionMixin, registerAction, registerComponent } from 'maka'
import JSON5 from 'json5'
import beautify from 'js-beautify/js/lib/beautifier.min'
import JsonViewer from 'react-json-view'
import './style.less'
const name = pkgJson.name
registerAction('beautify', beautify, true)
registerAction('json5', JSON5, true)
registerComponent('JsonViewer', JsonViewer)
const strJson = beautify.js(JSON.stringify(JSON5.parse(`
{
aa:1,
bb:2
}`)))
const state = {
data: {
json: strJson
}
}
@actionMixin('base')
class action {
constructor(option) {
Object.assign(this, option.mixins)