How to use the @atomist/sdm.spawnLog function in @atomist/sdm

To help you get started, we’ve selected a few @atomist/sdm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atomist / sdm-pack-aspect / lib / aspect / sdm / sdmNpmDeps.ts View on Github external
}
            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;
    }
};
github atomist / sdm-pack-spring / lib / gradle / build / gradleBuilder.ts View on Github external
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,
        },
    );
}
github atomist / sdm-pack-spring / lib / maven / build / helpers.ts View on Github external
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,
            });
    }
}
github atomist / sdm-core / lib / goal / cache / FileSystemGoalCacheArchiveStore.ts View on Github external
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,
        });
    }
github atomist / sdm-pack-spring / lib / maven / build / MavenBuilder.ts View on Github external
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,
        },
github atomist / sdm-core / lib / goal / cache / FileSystemGoalCacheArchiveStore.ts View on Github external
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,
        });
    }
github atomist / sdm-core / lib / goal / container / docker.ts View on Github external
`--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("; ")}`,
                    };
github atomist / sdm-pack-aspect / lib / aspect / node / TypeScriptVersion.ts View on Github external
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",
github atomist / sdm-core / lib / internal / delivery / build / executeTag.ts View on Github external
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;
    }
}