Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (!!_.get(pj.devDependencies, pk.name)) {
pj.devDependencies[pk.name] = pk.version;
}
// Fix up peerDependency entries
if (!!_.get(pj.peerDependencies, pk.name)) {
const version = pk.version.replace(/\^/g, "");
const peerVersion = `>=${semver.major(version)}.${semver.minor(version)}.0`;
pj.peerDependencies[pk.name] = peerVersion;
}
});
await file.setContent(JSON.stringify(pj, undefined, 2));
const log = new LoggingProgressLog("npm install");
const result = await spawnLog(
"npm",
["install"],
{
cwd: (p as LocalProject).baseDir,
log,
logCommand: true,
});
return result.code === 0;
} else {
return false;
}
};
export async function gradleCommand(p: LocalProject,
options: GradleCommandOptions): Promise {
const command = determineGradleCommand(p);
const args = [];
if (options.flags) {
args.push(...options.flags);
}
if (options.args) {
args.push(...options.args.map(a => `-D${a.name}${a.value ? `=${a.value}` : ""}`));
}
if (options.initScript) {
args.push(`-I ${options.initScript}`);
}
args.push(...(options.tasks || ["build"]));
return spawnLog(
command,
args,
{
cwd: p.baseDir,
log: options.progressLog,
errorFinder: options.errorFinder,
},
);
}
async function mvnPackageProjectListener(p: GitProject,
gi: GoalInvocation,
event: GoalProjectListenerEvent): Promise {
const command = await determineMavenCommand(p);
if (event === GoalProjectListenerEvent.before) {
return spawnLog(command,
["package", ...MavenOptions, "-DskipTests=true", `-Dartifact.name=${p.id.repo}`],
{
cwd: p.baseDir,
log: gi.progressLog,
});
}
}
public async retrieve(gi: GoalInvocation, classifier: string, targetArchivePath: string): Promise {
const cacheDir = await FileSystemGoalCacheArchiveStore.getCacheDirectory(gi, classifier);
const archiveName = FileSystemGoalCacheArchiveStore.archiveName;
const archiveFileName = path.join(cacheDir, archiveName);
await spawnLog("cp", [archiveFileName, targetArchivePath], {
log: gi.progressLog,
});
}
export async function mavenPackage(p: GitProject,
progressLog: ProgressLog,
args: MavenArgs[] = [],
mavenGoal: string = "package"): Promise {
const command = await determineMavenCommand(p);
return spawnLog(
command,
[
mavenGoal,
...MavenOptions,
..._.flatten(args.filter(
a => a.type === MavenArgType.Option)
.map(a => [`${a.name.length <= 3 ? "-" : "--"}${a.name}`, !!a.value ? `${a.value}` : undefined]))
.filter(a => !!a),
...args.filter(
a => a.type === MavenArgType.Property || !a.type)
.map(a => `-D${a.name}${!!a.value ? `=${a.value}` : ""}`),
],
{
cwd: p.baseDir,
log: progressLog,
},
public async delete(gi: GoalInvocation, classifier: string): Promise {
const cacheDir = await FileSystemGoalCacheArchiveStore.getCacheDirectory(gi, classifier);
const archiveName = FileSystemGoalCacheArchiveStore.archiveName;
const archiveFileName = path.join(cacheDir, archiveName);
await spawnLog("rm", ["-f", archiveFileName], {
log: gi.progressLog,
});
}
`--volume=${outputDir}:${ContainerOutput}`,
...secrets.files.map(f => `--volume=${f.hostPath}:${f.mountPath}`),
`--network=${network}`,
`--network-alias=${container.name}`,
...containerArgs,
...(registration.dockerOptions || []),
...((container as DockerGoalContainer).dockerOptions || []),
...atomistEnvs,
...secrets.env.map(e => `--env=${e.name}=${e.value}`),
container.image,
...(container.args || []),
];
if (spawnedContainers.length < 1) {
dockerArgs.splice(5, 0, `--workdir=${ContainerProjectHome}`);
}
const promise = spawnLog("docker", dockerArgs, spawnOpts);
spawnedContainers.push({ name: containerName, promise });
}
if (failures.length > 0) {
try {
await dockerCleanup({
network,
spawnOpts,
containers: spawnedContainers,
});
} catch (e) {
failures.push(e.message);
}
return {
code: failures.length,
message: `Failed to spawn Docker containers: ${failures.join("; ")}`,
};
apply: async (p, papi) => {
const fp = papi.parameters.fp;
if (fp.data.length !== 1) {
return p;
}
if (!(await p.hasFile(PackageJsonName))) {
return p;
}
if (!(p as LocalProject).baseDir) {
return p;
}
const log = new StringCapturingProgressLog();
log.stripAnsi = true;
const result = await spawnLog(
"npm",
["install", `typescript@${fp.data[0]}`, "--save-dev", "--safe-exact"],
{ cwd: (p as LocalProject).baseDir, log });
if (result.code !== 0) {
return {
edited: false,
success: false,
target: p,
error: new Error(`npm install typescript@${fp.data[0]} failed:\n\n${log.log}`),
};
}
return p;
},
toDisplayableFingerprintName: () => "TypeScript version",
throw new Error("You must provide a valid Git tag");
}
if (!opts.project) {
throw new Error("You must provide a Git project");
}
if (!opts.log) {
opts.log = new LoggingProgressLog("logger");
}
const remote = opts.project.remote || "origin";
try {
const spawnOpts = { cwd: opts.project.baseDir, log: opts.log };
const tagArgs = ["tag", opts.tag];
if (opts.message) {
tagArgs.splice(1, 0, "-m", opts.message);
}
const tagResult = await spawnLog("git", tagArgs, spawnOpts);
if (tagResult.code) {
throw new Error(`git tag failed: ${tagResult.message}`);
}
const pushResult = await spawnLog("git", ["push", remote, opts.tag], spawnOpts);
if (pushResult.code) {
throw new Error(`git push failed: ${pushResult.message}`);
}
} catch (e) {
e.message = `Failed to create and push git tag '${opts.tag}': ${e.message}`;
throw e;
}
}