Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (const ionicType of IONIC_TYPE_DIRECTORIES) {
const baseDir = path.resolve(REPO_DIRECTORY, ionicType, 'base');
const starterDirs = await getStarterDirectories(ionicType, { community });
for (const starterDir of starterDirs) {
const [ , starterType ] = getStarterInfoFromPath(starterDir);
const id = buildStarterId(ionicType, starterType, starterDir);
const contents = (await readdirp(starterDir)).map(p => p.substring(starterDir.length + 1));
for (const file of contents) {
const filePath = path.resolve(starterDir, file);
const baseFilePath = path.resolve(baseDir, file);
try {
const [ fileStat, baseFileStat ] = await Promise.all([stat(filePath), stat(baseFilePath)]);
if (!fileStat.isDirectory() && !baseFileStat.isDirectory()) {
const [ fileChecksum, baseFileChecksum ] = await Promise.all([getFileChecksum(filePath), getFileChecksum(baseFilePath)]);
if (fileChecksum === baseFileChecksum) {
log(id, chalk.red(`${chalk.bold(file)}: same file in base files`));
redundantFiles.push(filePath);
} else {
log(id, chalk.gray(`${chalk.bold(file)}: found in base files, but checksum differs`));
}
}
} catch (e) {
// ignore
}
}
}
export async function validatePrivateKey(keyPath: string): Promise {
try {
await stat(keyPath);
} catch (e) {
if (e.code === 'ENOENT') {
throw ERROR_SSH_MISSING_PRIVKEY;
}
throw e;
}
const f = await readFile(keyPath, { encoding: 'utf8' });
const lines = f.split('\n');
if (!lines[0].match(/^\-{5}BEGIN [A-Z]+ PRIVATE KEY\-{5}$/)) {
throw ERROR_SSH_INVALID_PRIVKEY;
}
}
return filter(contents.map(f => path.resolve(p, f)), async f => (await stat(f)).isDirectory());
}
const stats = await map(contents, async (f): Promise<[string, fs.Stats]> => [f, await stat(f)]);
const files = stats.filter(([ , s ]) => !s.isDirectory());
await mkdirp(tmpdir);
const ws = tar.extract({ cwd: tmpdir });
const { req } = await createRequest('GET', this.archiveUrl, this.e.config.getHTTPConfig());
await download(req, ws, {});
const contents = await readdirSafe(tmpdir);
const blacklist: string[] = [];
debug(`Integration files downloaded to ${strong(tmpdir)} (files: ${contents.map(f => strong(f)).join(', ')})`);
for (const f of contents) {
const projectf = path.resolve(this.e.project.directory, f);
try {
const stats = await stat(projectf);
const overwrite = await conflictHandler(projectf, stats);
if (!overwrite) {
blacklist.push(f);
}
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
}
this.e.log.info(`Copying integrations files to project`);
debug(`Blacklist: ${blacklist.map(f => strong(f)).join(', ')}`);
await mkdirp(details.root);