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)
exports.logDiff = function logDiff(expected, actual) {
console.log(json.stringify(diff(actual, expected), null, 4));
};
function parseDataLinksHelper(patternlab, obj, key) {
var linkRE, dataObjAsString, linkMatches, expandedLink;
linkRE = /link\.[A-z0-9-_]+/g;
dataObjAsString = JSON5.stringify(obj);
linkMatches = dataObjAsString.match(linkRE);
if (linkMatches) {
for (var i = 0; i < linkMatches.length; i++) {
expandedLink = patternlab.data.link[linkMatches[i].split('.')[1]];
if (expandedLink) {
if (patternlab.config.debug) {
console.log('expanded data link from ' + linkMatches[i] + ' to ' + expandedLink + ' inside ' + key);
}
dataObjAsString = dataObjAsString.replace(linkMatches[i], expandedLink);
}
}
}
var dataObj;
try {
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);
traverseProperty(input, function ({ value, property, selector }) {
if (property === 'transform') {
const arr = [];
const match = value.replace(/(\w+)\s*\(([^)]+)\)\s*/g, (nothing, name, value) => {
if (value.match(/^[\d\.]+$/)) {
value = value * 1;
}
arr.push({ [name]: value });
});
return JSON5.stringify(arr);
}
});
const regexpArr = args.split(',').map(arg => arg.trim()).map(name => new RegExp(`(^|['"])` + name + "([\\[\\.\"? *\/+-]|$)"));
it('should resolve node paths', () => {
const cs = createConfigSet({ jestConfig: { rootDir: '/root', cwd: '/cwd' } as any, resolve: null })
const doResolve = (path: string) => cs.resolvePath(path, { throwIfMissing: false, nodeResolve: true })
expect(doResolve('json5')).toBe(resolve(__dirname, '../../node_modules/json5', require('json5/package.json').main))
expect(doResolve('./bar.js')).toBe(resolve('/cwd/bar.js'))
expect(doResolve('bar.js')).toBe(resolve('/root/bar.js'))
expect(doResolve('/bar.js')).toBe(resolve('/root//bar.js'))
})
it('should throw for invalid paths', () => {
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,
},