Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function copySkin(sdk: SDK, skin: string, skinpath: string): Promise {
const debug = Debug(`${modulePrefix}:${copySkin.name}`);
const skinsrc = pathlib.resolve(ASSETS_PATH, 'android', 'skins', skin);
const stat = await statSafe(skinsrc);
if (stat && stat.isDirectory()) {
debug('Copying skin from %s to %s', skinsrc, skinpath);
try {
return await copy(skinsrc, skinpath);
} catch (e) {
debug('Error while copying skin: %O', e);
}
}
throw new AVDException(`${skinpath} is an invalid skin.`, ERR_INVALID_SKIN);
}
export async function buildStarter(ionicType: string, starterType: string, starterDir: string): Promise {
const id = buildStarterId(ionicType, starterType, starterDir);
const baseDir = path.resolve(REPO_DIRECTORY, ionicType, 'base');
const tmpdest = path.resolve(BUILD_DIRECTORY, id);
log(id, 'Building...');
const manifest = await readStarterManifest(starterDir);
if (!manifest) {
throw new Error(`No starter manifest found in ${starterDir}`);
}
await copy(baseDir, tmpdest, {});
await copy(starterDir, tmpdest, {});
try {
await remove(path.resolve(tmpdest, '.git'));
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
const pkgPath = path.resolve(tmpdest, 'package.json');
const pkg = await readPackageJsonFile(pkgPath);
log(id, `Performing manifest operations for ${chalk.bold(manifest.name)}`);
if (manifest.packageJson) {
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);
await copy(tmpdir, details.root, {
filter: f => {
if (f === tmpdir) {
return true;
}
const projectf = f.substring(tmpdir.length + 1);
for (const item of blacklist) {
if (item.slice(-1) === '/' && `${projectf}/` === item) {
return false;
}
if (projectf.startsWith(item)) {
return false;
}
}
export async function buildStarter(ionicType: string, starterType: string, starterDir: string): Promise {
const id = buildStarterId(ionicType, starterType, starterDir);
const baseDir = path.resolve(REPO_DIRECTORY, ionicType, 'base');
const tmpdest = path.resolve(BUILD_DIRECTORY, id);
log(id, 'Building...');
const manifest = await readStarterManifest(starterDir);
if (!manifest) {
throw new Error(`No starter manifest found in ${starterDir}`);
}
await copy(baseDir, tmpdest, {});
await copy(starterDir, tmpdest, {});
try {
await remove(path.resolve(tmpdest, '.git'));
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
const pkgPath = path.resolve(tmpdest, 'package.json');
const pkg = await readPackageJsonFile(pkgPath);
log(id, `Performing manifest operations for ${chalk.bold(manifest.name)}`);
if (manifest.packageJson) {
_.mergeWith(pkg, manifest.packageJson, (objv, v) => _.isArray(v) ? v : undefined);