How to use the @atomist/sdm.LoggingProgressLog 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
pj.dependencies[pk.name] = pk.version;
            }
            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-core / lib / handlers / events / delivery / goals / FulfillGoalOnRequested.ts View on Github external
description: `No fulfillment for ${sdmGoal.uniqueName}`,
                });
            return Success;
        }

        const id = this.configuration.sdm.repoRefResolver.repoRefFromSdmGoal(sdmGoal);
        const credentials = await resolveCredentialsPromise(this.configuration.sdm.credentialsResolver.eventHandlerCredentials(ctx, id));
        const addressChannels = addressChannelsFor(sdmGoal.push.repo, ctx);
        const preferences = this.configuration.sdm.preferenceStoreFactory(ctx);

        const implementation = this.implementationMapper.findImplementationBySdmGoal(sdmGoal);
        const { goal } = implementation;

        const progressLog = new WriteToAllProgressLog(
            sdmGoal.name,
            new LoggingProgressLog(sdmGoal.name, "debug"),
            await this.configuration.sdm.logFactory(ctx, sdmGoal));

        const goalInvocation: GoalInvocation = {
            configuration: this.configuration,
            sdmGoal,
            goalEvent: sdmGoal,
            goal,
            progressLog,
            context: ctx,
            addressChannels,
            preferences,
            id,
            credentials,
            parameters: !!event.data.SdmGoal[0].parameters ? JSON.parse(event.data.SdmGoal[0].parameters) : {},
        };
github atomist / sdm-core / lib / log / rolarAndDashboardLogFactory.ts View on Github external
return async (context, sdmGoal) => {
        const name = sdmGoal.name;
        const persistentLog = await persistentLogFactory(context, sdmGoal, new LoggingProgressLog(name, "info"));
        return new WriteToAllProgressLog(name, await createEphemeralProgressLog(context, sdmGoal), persistentLog);
    };
}
github atomist / sdm-core / lib / internal / delivery / build / executeTag.ts View on Github external
export async function createGitTag(opts: CreateGitTagOptions): Promise {
    if (!opts.tag) {
        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}`);
        }
github atomist / sdm-core / lib / handlers / events / delivery / goals / k8s / launchGoalK8.ts View on Github external
errorFinder: SuccessIsReturn0ErrorFinder,
            logCommand: false,
        },
    );

    const jobs = JSON.parse(log.log).items;
    const sdmJobs = jobs.filter(j => j.metadata.name.startsWith(`${deploymentName}-job-`));
    const completedSdmJobs =
        sdmJobs.filter(j => j.status && j.status.completionTime && j.status.succeeded && j.status.succeeded > 0)
            .map(j => j.metadata.name);

    if (completedSdmJobs.length > 0) {
        logger.info(`Deleting the following goal jobs from namespace '${deploymentNamespace}': ${
            completedSdmJobs.join(", ")}`);

        log = new LoggingProgressLog("");

        for (const completedSdmJob of completedSdmJobs) {
            await spawnAndWatch({
                command: "kubectl",
                args: ["delete", "job", completedSdmJob, "-n", deploymentNamespace],
            },
                {},
                log,
                {
                    errorFinder: SuccessIsReturn0ErrorFinder,
                },
            );
        }
    }
}