Skip to content

Commit

Permalink
Removed debug logging and some process.chdir calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
seanparsons committed Feb 3, 2025
1 parent 345846b commit 959a89f
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 55 deletions.
3 changes: 0 additions & 3 deletions packages/cli/src/lib/classic-compiler/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,12 @@ export async function runClassicCompilerBuild({
lockfileCheck = true,
assetPath,
}: RunBuildOptions) {
console.log('runClassicCompilerBuild');
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'production';
}
if (assetPath) {
process.env.HYDROGEN_ASSET_BASE_URL = assetPath;
}
console.log('directory', directory);
process.chdir(directory!);

const {root, buildPath, buildPathClient, buildPathWorkerFile, publicPath} =
getProjectPaths(directory);
Expand Down
6 changes: 1 addition & 5 deletions packages/cli/src/lib/classic-compiler/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,15 @@ describe('Classic Remix Compiler dev', () => {
outputMock.clear();
vi.stubEnv('NODE_ENV', 'development');

console.log('runClassicCompilerDev starting');
process.chdir(tmpDir);
const {close, getUrl} = await runClassicCompilerDev({
path: tmpDir,
disableVirtualRoutes: true,
disableVersionCheck: true,
cliConfig: {root: tmpDir} as any,
cliConfig: {} as any,
envFile: '.env',
});
console.log('runClassicCompilerDev finished');

try {
console.log('outputMock.output()', outputMock.output());
await vi.waitFor(() => expect(outputMock.output()).toMatch('success'), {
timeout: 5000,
});
Expand Down
8 changes: 0 additions & 8 deletions packages/cli/src/lib/classic-compiler/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export async function runClassicCompilerDev({
getProjectPaths(appPath);

const copyFilesPromise = copyPublicFiles(publicPath, buildPathClient);
console.log('root', root);
const cliCommandPromise = getCliCommand(root);

const reloadConfig = async () => {
Expand All @@ -120,7 +119,6 @@ export async function runClassicCompilerDev({
return [fileRelative, resolvePath(root, fileRelative)] as const;
};

console.log('buildPathWorkerFile', buildPathWorkerFile);
const serverBundleExists = () => fileExists(buildPathWorkerFile);

if (!appPort) {
Expand Down Expand Up @@ -156,7 +154,6 @@ export async function runClassicCompilerDev({
});

const remixConfig = await reloadConfig();
console.log('remixConfig', JSON.stringify(remixConfig, null, 2));
assertOxygenChecks(remixConfig);

const envPromise = backgroundPromise.then(({fetchRemote, localVariables}) =>
Expand Down Expand Up @@ -217,7 +214,6 @@ export async function runClassicCompilerDev({
const host = (await tunnelPromise)?.host ?? miniOxygen.listeningAt;

const cliCommand = await cliCommandPromise;
console.log('cliCommand', cliCommand);
enhanceH2Logs({host, cliCommand, ...remixConfig});

const {storefrontTitle} = await backgroundPromise;
Expand Down Expand Up @@ -265,7 +261,6 @@ export async function runClassicCompilerDev({
{
reloadConfig,
onBuildStart(ctx) {
console.log('onBuildStart');
if (!isInitialBuild && !skipRebuildLogs) {
outputInfo(LOG_REBUILDING);
console.time(LOG_REBUILT);
Expand All @@ -275,7 +270,6 @@ export async function runClassicCompilerDev({
},
onBuildManifest: liveReload?.onBuildManifest,
async onBuildFinish(context, duration, succeeded) {
console.log('onBuildFinish', new Error());
if (isInitialBuild) {
await copyFilesPromise;
initialBuildDurationMs = Date.now() - initialBuildStartTimeMs;
Expand All @@ -286,8 +280,6 @@ export async function runClassicCompilerDev({
if (!miniOxygen) console.log(''); // New line
}

console.log('serverBundleExists', await serverBundleExists());

if (!miniOxygen && !(await serverBundleExists())) {
return renderFatalError({
name: 'BuildError',
Expand Down
36 changes: 13 additions & 23 deletions packages/cli/src/lib/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,12 @@ export async function mergePackageJson(
onResult?: (pkgJson: PackageJson) => PackageJson;
},
) {
console.log('mergePackageJson 1');
const targetPkgJson: PackageJson = await readAndParsePackageJson(
joinPath(targetDir, 'package.json'),
);
console.log('mergePackageJson 2');
const sourcePkgJson: PackageJson = await readAndParsePackageJson(
joinPath(sourceDir, 'package.json'),
);
console.log('mergePackageJson 3');

const ignoredKeys = new Set(['comment', ...(options?.ignoredKeys ?? [])]);

Expand All @@ -120,12 +117,11 @@ export async function mergePackageJson(
Array.isArray(sourceValue) && Array.isArray(targetValue)
? [...targetValue, ...sourceValue]
: typeof sourceValue === 'object' && typeof targetValue === 'object'
? {...targetValue, ...sourceValue}
: sourceValue;
? {...targetValue, ...sourceValue}
: sourceValue;

targetPkgJson[key] = newValue as any;
}
console.log('mergePackageJson 4');

const remixVersion = Object.entries(targetPkgJson.dependencies || {}).find(
([dep]) => dep.startsWith('@remix-run/'),
Expand All @@ -142,33 +138,27 @@ export async function mergePackageJson(
]),
]
.sort()
.reduce(
(acc, dep) => {
let version = (sourcePkgJson[key]?.[dep] ??
targetPkgJson[key]?.[dep])!;

if (dep.startsWith('@remix-run/') && remixVersion) {
version = remixVersion;
}

acc[dep] = version;
return acc;
},
{} as Record<string, string>,
);
.reduce((acc, dep) => {
let version = (sourcePkgJson[key]?.[dep] ??
targetPkgJson[key]?.[dep])!;

if (dep.startsWith('@remix-run/') && remixVersion) {
version = remixVersion;
}

acc[dep] = version;
return acc;
}, {} as Record<string, string>);
}
}
console.log('mergePackageJson 5');

await writePackageJSON(
targetDir,
options?.onResult?.(targetPkgJson) ?? targetPkgJson,
);
console.log('mergePackageJson 6');
}

export async function mergeTsConfig(sourceDir: string, targetDir: string) {
console.log('mergeTsConfig');
const sourceTsConfig = await readFile(joinPath(sourceDir, 'tsconfig.json'));
const sourceTsTypes = sourceTsConfig.match(/"types": \[(.*?)\]/)?.[1];

Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/lib/onboarding/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export async function setupLocalStarterTemplate(
options: InitOptions,
controller: AbortController,
) {
console.log('setupLocalStarterTemplate');
const templateAction = options.mockShop
? 'mock'
: await renderSelectPrompt<'mock' | 'link'>({
Expand Down
7 changes: 0 additions & 7 deletions packages/cli/src/lib/onboarding/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export async function setupRemoteTemplate(
options: InitOptions & Required<Pick<InitOptions, 'template'>>,
controller: AbortController,
) {
console.log('setupRemoteTemplate');
const appTemplate =
options.template === 'demo-store' ? DEMO_STORE_REPO : options.template;

Expand All @@ -54,7 +53,6 @@ export async function setupRemoteTemplate(

let backgroundWorkPromise = Promise.resolve()
.then(async () => {
console.log('backgroundWorkPromise');
// Result is undefined in certain tests,
// do not continue if it's already aborted
if (controller.signal.aborted) return;
Expand All @@ -64,7 +62,6 @@ export async function setupRemoteTemplate(
const pkgJson = await readAndParsePackageJson(
joinPath(sourcePath, 'package.json'),
);
console.log('pkgJson', pkgJson);

if (pkgJson.scripts?.dev?.includes('--diff')) {
return applyTemplateDiff(project.directory, sourcePath, skeletonPath);
Expand Down Expand Up @@ -134,7 +131,6 @@ export async function setupRemoteTemplate(

if (controller.signal.aborted) return;

console.log('tasks', tasks);
await renderTasks(tasks);

if (options.git) {
Expand All @@ -152,7 +148,6 @@ export async function setupRemoteTemplate(
body: `To connect this project to your Shopify store’s inventory, update \`${project.name}/.env\` with your store ID and Storefront API key.`,
});

console.log('project', project);
return {
...project,
...setupSummary,
Expand All @@ -168,9 +163,7 @@ async function getExternalTemplate(
appTemplate: string,
signal: AbortSignal,
): Promise<DownloadedTemplate> {
console.log('getExternalTemplate');
const {templateDir} = await downloadExternalRepo(appTemplate, signal);
console.log('templateDir', templateDir);
return {sourcePath: templateDir};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/setups/i18n/replacers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('i18n replacers', () => {
export async function createAppLoadContext(
request: Request,
env: Env,
executionContext: ExecutionContext,
executionContext: ExecutionContext
) {
/**
* Open a cache instance in the worker and a custom session instance.
Expand Down
7 changes: 0 additions & 7 deletions packages/cli/src/lib/template-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,23 +205,19 @@ export async function applyTemplateDiff(
diffDirectory: string,
templateDir?: string,
) {
console.log('applyTemplateDiff 1');
templateDir ??= await getStarterDir();
console.log('applyTemplateDiff 2');

const diffPkgJson = await readAndParsePackageJson(
joinPath(diffDirectory, 'package.json'),
);
const diffOptions: DiffOptions = (diffPkgJson as any)['h2:diff'] ?? {};
console.log('applyTemplateDiff 3');

const createFilter =
(re: RegExp, skipFiles?: string[]) => (filepath: string) => {
const filename = relativePath(templateDir, filepath);
return !re.test(filename) && !skipFiles?.includes(filename);
};

console.log('applyTemplateDiff 4');
await copyDirectory(templateDir, targetDirectory, {
force: true,
recursive: true,
Expand All @@ -231,7 +227,6 @@ export async function applyTemplateDiff(
diffOptions.skipFiles || [],
),
});
console.log('applyTemplateDiff 5');
await copyDirectory(diffDirectory, targetDirectory, {
force: true,
recursive: true,
Expand All @@ -240,7 +235,6 @@ export async function applyTemplateDiff(
),
});

console.log('applyTemplateDiff 6');
await mergePackageJson(diffDirectory, targetDirectory, {
ignoredKeys: ['h2:diff'],
onResult: (pkgJson) => {
Expand All @@ -267,6 +261,5 @@ export async function applyTemplateDiff(
},
});

console.log('About to call mergeTsConfig');
await mergeTsConfig(diffDirectory, targetDirectory);
}

0 comments on commit 959a89f

Please sign in to comment.