Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
load() {
const app = this.app;
let controllers = {};
const entries = glob.sync([`${app.ROOT_PATH}${this.config.pattern}`], {
dot: true,
});
entries
.filter(i => !i.includes('.d.ts'))
.forEach(entry => {
const key = this.resolveExtensions(entry.split('controllers/')[1], true);
controllers[key] = require(entry);
});
app.controllers = controllers;
}
}
docs.push({
name: formatName(component, lang),
path: join(SRC_DIR, component, fileName)
});
});
});
} else {
components.forEach(component => {
docs.push({
name: formatName(component),
path: join(SRC_DIR, component, 'README.md')
});
});
}
const staticDocs = glob.sync(join(DOCS_DIR, '**/*.md')).map(path => {
const pairs = parse(path).name.split('.');
return {
name: formatName(pairs[0], pairs[1] || defaultLang),
path
};
});
return [...staticDocs, ...docs.filter(item => existsSync(item.path))];
}
const upperFirst = require('lodash/upperFirst');
const docgenTypescript = require('react-docgen-typescript');
const sections = [
{
name: 'Lunar',
content: './guide/README.md',
},
];
const aliases = {
':core': path.join(__dirname, 'packages/core/src'),
':icons': path.join(__dirname, 'packages/icons/src'),
};
glob
.sync('./packages/*/', {
absolute: true,
onlyDirectories: true,
})
.forEach(filePath => {
const folder = path.basename(filePath);
const { name } = require(path.join(filePath, 'package.json'));
if (filePath.includes('metrics') || filePath.includes('test-utils')) {
return;
}
sections.push({
name: upperFirst(camelCase(folder)),
content: `packages/${folder}/GUIDE.md`,
components: `packages/${folder}/src/components/!(private)/+([a-zA-Z]).tsx`,
findConfigInLocalFiles(root: string): ConfigPathOrObject | null {
const configName = this.getConfigName();
const relPath = `configs/${configName}.{js,json,json5}`;
const configPaths = glob
.sync(relPath, {
absolute: true,
cwd: root,
onlyFiles: true,
})
.map(filePath => String(filePath));
this.debug.invariant(
configPaths.length === 1,
`Looking for local config file: ${relPath}`,
'Found',
'Not found',
);
if (configPaths.length === 1) {
this.debug('Found %s', chalk.cyan(path.basename(configPaths[0])));
export function loadProgram(pattern: true | string, root: string): ts.Program {
if (program) {
return program;
}
program = ts.createProgram(
glob.sync(pattern === true ? './src/**/*.ts' : pattern, { absolute: true, cwd: root }),
loadTSConfig(),
);
return program;
}
export const ensureFiles = ({ args }: ServerMachineCtx) => {
const appPath = path.join(paths.root, args.themesDir)
const themeNames = glob.sync('gatsby-theme-**', {
cwd: appPath,
onlyDirectories: true,
})
themeNames.forEach(themeName => {
fs.copySync(
path.join(appPath, themeName),
path.join(paths.docz, 'src', themeName)
)
})
copyDoczRc(args.config)
ensureFile('gatsby-browser.js')
ensureFile('gatsby-ssr.js')
ensureFile('gatsby-node.js')
ensureFile('gatsby-config.js', 'gatsby-config.custom.js')
const publicPath = path.join(paths.docz, '..', args.public)
return function toHtml() {
const files = fg.sync(patterns, {ignore});
return template({files});
}
}
function prototypes (context) {
const files = glob.sync('*.njk', {
cwd: path.join(context, 'src/prototypes')
})
return files.map(file => path.basename(file, '.njk'))
}
findConfigInLocalFiles(root: PortablePath): ConfigPathOrObject | null {
const configName = this.getConfigName();
const relPath = `configs/${configName}.{js,json,json5}`;
const configPaths = glob.sync(relPath, {
absolute: true,
cwd: String(root),
onlyFiles: true,
});
this.debug.invariant(
configPaths.length === 1,
`Looking for local config file: ${relPath}`,
'Found',
'Not found',
);
if (configPaths.length === 1) {
const localPath = new Path(configPaths[0]);
this.debug('Found %s', color.filePath(localPath.name()));
public async getTypesFromPaths(paths: string | string[]): Promise {
const filePaths = await glob.sync(paths, {
ignore: ['node_modules'],
});
const fileContentsPromises = filePaths.map((filePath) => {
return readFile(filePath.toString(), 'utf8');
});
return Promise.all(fileContentsPromises);
}
}