Skip to content

Commit

Permalink
localApp working
Browse files Browse the repository at this point in the history
  • Loading branch information
mmeigs committed Nov 20, 2023
1 parent 97cbc8b commit 2832b0e
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 65 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM arm64v8/ubuntu:20.04
ARG NPM_BASE_64_AUTH
ARG NPM_EMAIL
ARG SNOOTY_PARSER_VERSION=0.15.0
ARG SNOOTY_FRONTEND_VERSION=0.15.1.1
ARG SNOOTY_FRONTEND_VERSION=0.15.1
ARG MUT_VERSION=0.10.7
ARG REDOC_CLI_VERSION=1.2.2
ARG NPM_BASE_64_AUTH
Expand Down
7 changes: 6 additions & 1 deletion src/commands/src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,12 @@ export async function executeCliCommand({
console.error(errorText.join(''));
}

reject(new ExecuteCommandError('The command failed', exitCode));
reject(
new ExecuteCommandError(
`The command failed.\n${errorText.join('')}\n${outputText.join('')}\nError Code: ${exitCode}`,
exitCode
)
);
return;
}

Expand Down
14 changes: 7 additions & 7 deletions src/commands/src/shared/next-gen-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import path from 'path';
import { IJobRepoLogger } from '../../../services/logger';
import { executeCliCommand } from '../helpers';

export async function nextGenHtml(repoName: string, logger: IJobRepoLogger) {
let cwd = path.join(`${process.cwd()}`, `../../../snooty`);
if (repoName === 'docs-monorepo') {
cwd = path.join(`${process.cwd()}`, `../../snooty`);
}
export async function nextGenHtml(repoName: string) {
// let cwd = path.join(`${process.cwd()}`, `../../../snooty`);
// if (repoName === 'docs-monorepo') {
// cwd = path.join(`${process.cwd()}`, `../../snooty`);
// }

logger.save(repoName, `nextGenHtml cwd: ${cwd}`);
// logger.save(repoName, `nextGenHtml cwd: ${cwd}`);

const result = await executeCliCommand({
command: 'npm',
args: ['run', 'build'],
options: { cwd },
options: { cwd: `${process.cwd()}/snooty` },
});

// logger.save(repoName, result)
Expand Down
4 changes: 2 additions & 2 deletions src/commands/src/shared/next-gen-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function nextGenParse({ job, preppedLogger }: NextGenParseParams):
const commitHash = job.payload.newHead;
const patchId = job.payload.patch;

const commandArgs = ['build', `"${repoDir}"`, '--output', `"${repoDir}/bundle.zip"`];
const commandArgs = ['build', `${repoDir}`, '--output', `${repoDir}/bundle.zip`];

if (patchId && commitHash) {
commandArgs.push('--commit');
Expand All @@ -29,7 +29,7 @@ export async function nextGenParse({ job, preppedLogger }: NextGenParseParams):
preppedLogger(`COMMAND for parse: ${commandArgs.join(' ')}`);

try {
await executeCliCommand({ command: 'snooty', args: commandArgs, logger: preppedLogger });
return await executeCliCommand({ command: 'snooty', args: commandArgs, logger: preppedLogger });
} catch (error) {
preppedLogger(`ERROR: ${error}\n\n`);
}
Expand Down
20 changes: 1 addition & 19 deletions src/commands/src/shared/next-gen-stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,11 @@ import { executeCliCommand } from '../helpers';

const DOCS_WORKER_USER = 'docsworker-xlarge';
interface StageParams {
repoDir: string;
mutPrefix: string;
projectName: string;
bucket: string;
url: string;
patchId?: string;
commitBranch: string;
commitHash: string;
job: Job;
preppedLogger: (message: string) => void;
}

export async function nextGenStage({
job,
preppedLogger,
}: // mutPrefix,
// projectName,
// bucket,
// url,
// patchId,
// commitBranch,
// commitHash,
StageParams) {
export async function nextGenStage({ job, preppedLogger }: StageParams) {
// TODO: replace with a process to get this url??
const baseUrl = 'https://mongodbcom-cdn.website.staging.corp.mongodb.com';
// TODO: replace with process to access bucket
Expand Down
8 changes: 4 additions & 4 deletions src/commands/src/shared/persistence-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export async function persistenceModule({ job, preppedLogger }: PersistenceModul
githubUser,
];

if (job._id) {
args.push('--jobId');
args.push(job._id);
}
// if (job._id) {
// args.push('--jobId');
// args.push(job._id);
// }

preppedLogger(`persistence args: ${args}`);

Expand Down
84 changes: 54 additions & 30 deletions src/entrypoints/localApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
persistenceModule,
prepareBuildAndGetDependencies,
} from '../commands';
import { Payload } from '../entities/job';
import { Job, Payload } from '../entities/job';

const fakePayload: Payload = {
repoName: 'cloud-docs',
Expand All @@ -16,7 +16,7 @@ const fakePayload: Payload = {
jobType: '',
source: '',
action: '',
branchName: 'mmeigs-build', // mm-build??
branchName: 'master',
isFork: false,
repoOwner: '10gen',
url: 'https://github.com/10gen/cloud-docs', // ???
Expand All @@ -26,6 +26,36 @@ const fakePayload: Payload = {
} as Payload;
// Bucket??

const fakeJob: Job = {
_id: '082u3roinswdf988888888',
useWithBenchmark: true,
payload: fakePayload,
createdTime: new Date(),
startTime: new Date(),
title: '10gen/cloud-docs',
user: 'mmeigs',
mutPrefix: 'docs-qa/atlas/mmeigs-build',
buildCommands: [],
deployCommands: [],
email: '[email protected]',
shouldGenerateSearchManifest: false,
endTime: undefined,
error: undefined,
comMessage: undefined,
logs: undefined,
priority: undefined,
result: undefined,
status: null,
manifestPrefix: undefined,
pathPrefix: undefined,
invalidationStatusURL: undefined,
purgedUrls: undefined,
};

const preppedLogger = (message: string) => {
console.log('hey');
};

async function localApp() {
const baseUrl = 'https://mongodbcom-cdn.website.staging.corp.mongodb.com';
const bucket = 'docs-atlas-dotcomstg';
Expand Down Expand Up @@ -53,57 +83,51 @@ async function localApp() {
console.log('repoDir ', repoDir);

console.log('Begin snooty build...');
// const snootyBuildRes = await nextGenParse({ repoDir, commitHash, patchId });
const snootyBuildRes = await nextGenParse({ job: fakeJob, preppedLogger });

// console.log(snootyBuildRes.errorText);
console.log(snootyBuildRes.errorText);

console.log('snooty build complete');

console.log('Begin persistence-module');
// const persistenceModuleRes = await persistenceModule({ bundlePath });
// console.log(persistenceModuleRes);
const persistenceModuleRes = await persistenceModule({ job: fakeJob, preppedLogger });
console.log(persistenceModuleRes);
console.log('persistence-module complete');

console.log('Begin next-gen-html...');

// const nextGenHtmlRes = await nextGenHtml();
// console.log(nextGenHtmlRes.outputText);
const nextGenHtmlRes = await nextGenHtml(repoName);
console.log(nextGenHtmlRes.outputText);

console.log('next-gen-html complete');

console.log('Begin oas-page-build...');
const siteUrl = mutPrefix ? `${baseUrl}/${mutPrefix}` : `${baseUrl}`;
console.log('siteUrl: ', siteUrl);
// const oasPageBuildRes = await oasPageBuild({ repoDir, bundlePath, siteUrl });
const oasPageBuildRes = await oasPageBuild({ job: fakeJob, preppedLogger });
console.log('oas-page-build compelte');

// console.log(oasPageBuildRes);
console.log(oasPageBuildRes);
console.log('Begin next-gen-stage...');

// const {resultMessage, commands} = await nextGenStage({
// patchId,
// commitBranch,
// repoDir,
// projectName: project,
// bucket,
// url: baseUrl,
// mutPrefix: mutPrefix || '',
// commitHash,
// });
// console.log(resultMessage);
const { resultMessage, commands } = await nextGenStage({
job: fakeJob,
preppedLogger,
});
console.log(resultMessage);
console.log('next-gen-stage complete');

console.log('Begin next-gen-deploy...');
// const deployRes = await nextGenDeploy({
// bucket,
// hasConfigRedirects: hasRedirects,
// gitBranch: commitBranch,
// mutPrefix: mutPrefix || '',
// url: baseUrl,
// });
// console.log(deployRes);
const deployRes = await nextGenDeploy({
bucket,
hasConfigRedirects: hasRedirects,
gitBranch: commitBranch,
mutPrefix: mutPrefix || '',
url: baseUrl,
});
console.log(deployRes);
console.log('next-gen-deploy complete');
// console.log('commands: ', commands)
console.log('commands: ', commands);
console.log('bundle Path: ', bundlePath);
}

Expand Down
2 changes: 1 addition & 1 deletion src/job/jobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export abstract class JobHandler {
[K: string]: ({ job, preppedLogger }: { job: Job; preppedLogger: (message: string) => void }) => any;
} = {
// ['get-build-dependencies']: 'buildDepsExe',
// ['next-gen-parse']: nextGenParse,
['next-gen-parse']: nextGenParse,
['persistence-module']: persistenceModule,
// ['next-gen-html']: 'htmlExe',
['oas-page-build']: oasPageBuild,
Expand Down

0 comments on commit 2832b0e

Please sign in to comment.