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);
async run(inputs: CommandLineInputs, options: CommandLineOptions) {
const [ starter ] = inputs;
const current = options['current'] ? true : false;
const wipe = options['wipe'] ? true : false;
const gitVersion = (await runcmd('git', ['--version'])).trim();
console.log(getCommandHeader('BUILD'));
console.log(`\n${gitVersion}\n`);
if (wipe) {
console.log(`Wiping ${chalk.bold(`${BUILD_DIRECTORY}/*`)}`);
await remove(`${BUILD_DIRECTORY}/*`);
}
const changedBaseFiles = await gatherChangedBaseFiles();
if (!current && changedBaseFiles.length > 0) {
console.error(chalk.red(
`Changes detected in ${changedBaseFiles.map(p => chalk.bold(p)).join(', ')}.\n` +
`You must either commit/reset these changes OR explicitly use the ${chalk.green('--current')} flag, which ignores starter baserefs.`
));
process.exit(1);
}
if (starter) {
const starterDir = path.resolve(starter);
async cordovaRepair(cordova: Required, runinfo: CommandInstanceInfo) {
const tasks = this.createTaskChain();
const platformsDir = path.resolve(cordova.root, 'platforms');
const pluginsDir = path.resolve(cordova.root, 'plugins');
tasks.next(`Removing ${strong(prettyPath(platformsDir))}`);
await remove(platformsDir);
tasks.next(`Removing ${strong(prettyPath(pluginsDir))}`);
await remove(pluginsDir);
tasks.end();
await runCommand(runinfo, ['cordova', 'prepare', '--no-build']);
}
}
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);
await writeFile(pkgPath, JSON.stringify(pkg, undefined, 2) + '\n', { encoding: 'utf8' });
}
async cordovaRepair(cordova: Required, runinfo: CommandInstanceInfo) {
const tasks = this.createTaskChain();
const platformsDir = path.resolve(cordova.root, 'platforms');
const pluginsDir = path.resolve(cordova.root, 'plugins');
tasks.next(`Removing ${strong(prettyPath(platformsDir))}`);
await remove(platformsDir);
tasks.next(`Removing ${strong(prettyPath(pluginsDir))}`);
await remove(pluginsDir);
tasks.end();
await runCommand(runinfo, ['cordova', 'prepare', '--no-build']);
}
}
throw new FatalException(
`Git CLI not found on your PATH.\n` +
`Git must be installed to clone apps with ${input('ionic start')}. ${installationDocs}`
);
}
}
if (gitTopLevel && !this.schema.cloned) {
this.env.log.info(`Existing git project found (${strong(gitTopLevel)}). Git operations are disabled.`);
}
const tasks = this.createTaskChain();
tasks.next(`Preparing directory ${input(prettyPath(projectDir))}`);
if (this.canRemoveExisting) {
await remove(projectDir);
}
await mkdir(projectDir);
tasks.end();
if (this.schema.cloned) {
await this.env.shell.run('git', ['clone', this.schema.url, projectDir, '--progress'], { stdio: 'inherit' });
} else {
const starterTemplate = await this.findStarterTemplate(this.schema.template, this.schema.type, tag);
await this.downloadStarterTemplate(projectDir, starterTemplate);
}
let project: IProject | undefined;
if (this.project && this.project.details.context === 'multiapp' && !this.schema.cloned) {
const { pkgManagerArgs } = await import('../lib/utils/npm');
const [ installer, ...installerArgs ] = await pkgManagerArgs(this.env.config.get('npmClient'), { command: 'install' });
const tasks = this.createTaskChain();
const packageLockFile = path.resolve(project.directory, 'package-lock.json');
const nodeModulesDir = path.resolve(project.directory, 'node_modules');
tasks.next(`Removing ${strong(prettyPath(packageLockFile))}`);
const packageLockFileExists = await pathExists(packageLockFile);
if (packageLockFileExists) {
await unlink(packageLockFile);
}
tasks.next(`Removing ${strong(prettyPath(nodeModulesDir))}`);
await remove(nodeModulesDir);
tasks.end();
await this.env.shell.run(installer, installerArgs, { cwd: project.directory, stdio: 'inherit' });
}