Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const onFileCreate = handlers.onFileCreate ? handlers.onFileCreate : lodash.noop;
const conflictHandler = handlers.conflictHandler ? handlers.conflictHandler : async () => false;
const { createRequest, download } = await import('../../utils/http');
const { tar } = await import('../../utils/archive');
this.e.log.info(`Downloading integration ${input(this.name)}`);
const tmpdir = path.resolve(os.tmpdir(), `ionic-integration-${this.name}`);
// TODO: etag
if (await pathExists(tmpdir)) {
await remove(tmpdir);
}
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);
async run(inputs: CommandLineInputs, options: CommandLineOptions): Promise {
const { getGeneratedPrivateKeyPath } = await import('../../lib/ssh');
const { bits, annotation } = options;
const keyPath = inputs[0] ? expandPath(String(inputs[0])) : await getGeneratedPrivateKeyPath(this.env.config.get('user.id'));
const keyPathDir = path.dirname(keyPath);
const pubkeyPath = `${keyPath}.pub`;
if (!(await pathExists(keyPathDir))) {
await mkdirp(keyPathDir, 0o700 as any); // tslint:disable-line
this.env.log.msg(`Created ${strong(prettyPath(keyPathDir))} directory for you.`);
}
if (await pathExists(keyPath)) {
const confirm = await this.env.prompt({
type: 'confirm',
name: 'confirm',
message: `Key ${strong(prettyPath(keyPath))} exists. Overwrite?`,
});
if (confirm) {
await unlink(keyPath);
} else {
this.env.log.msg(`Not overwriting ${strong(prettyPath(keyPath))}.`);
return;
}
private async ensureDirectory(p: string) {
if (!(await pathExists(p))) {
await mkdirp(p, 0o700 as any); // tslint:disable-line
this.env.log.msg(`Created ${strong(prettyPath(p))} directory for you.`);
}
}
export async function createAVD(sdk: SDK, schematic: AVDSchematic): Promise {
const { avdHome } = sdk;
const { id, ini, configini } = schematic;
if (!avdHome) {
throw new SDKException(`No valid Android AVD home found.`, ERR_AVD_HOME_NOT_FOUND);
}
await mkdirp(pathlib.join(avdHome, `${id}.avd`));
await Promise.all([
writeINI(pathlib.join(avdHome, `${id}.ini`), ini),
writeINI(pathlib.join(avdHome, `${id}.avd`, 'config.ini'), configini),
]);
return getAVDFromConfigINI(pathlib.join(avdHome, `${id}.ini`), ini, configini);
}
export async function sendMessage({ config, ctx }: SendMessageDeps, msg: IPCMessage) {
const dir = path.dirname(config.p);
await mkdirp(dir);
const fd = await open(path.resolve(dir, 'helper.log'), 'a');
const p = fork(ctx.binPath, ['_', '--no-interactive'], { stdio: ['ignore', fd, fd, 'ipc'] });
p.send(msg);
p.disconnect();
p.unref();
}
.map(dir => mkdirp(dir));
await unzip(ipaPath, async (entry, zipfile, openReadStream) => {
debug(`Unzip: ${entry.fileName}`);
const dest = path.join(destPath, entry.fileName);
if (entry.fileName.endsWith('/')) {
await mkdirp(dest);
if (entry.fileName.endsWith('.app/')) {
appPath = entry.fileName;
}
zipfile.readEntry();
} else {
await mkdirp(path.dirname(dest));
const readStream = await openReadStream(entry);
readStream.on('error', (err: Error) => error = err);
readStream.on('end', () => { zipfile.readEntry(); });
readStream.pipe(createWriteStream(dest));
}
});
if (details.enableArgs) {
const parsedArgs = parseArgs(details.enableArgs);
name = parsedArgs._[0] || name;
packageId = parsedArgs._[1] || packageId;
if (parsedArgs['web-dir']) {
options.push('--web-dir', parsedArgs['web-dir']);
}
options.push('--npm-client', this.e.config.get('npmClient'));
}
await this.installCapacitorCore();
await this.installCapacitorCLI();
await mkdirp(details.root);
await this.e.shell.run('capacitor', ['init', name, packageId, ...options], { cwd: details.root });
await super.add(details);
}