Skip to content

Commit

Permalink
fix(core): replace empty preset with apps
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Mar 31, 2023
1 parent 5300762 commit 7464280
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
8 changes: 5 additions & 3 deletions e2e/utils/command-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import { ChildProcess, exec, execSync, ExecSyncOptions } from 'child_process';
import { join } from 'path';
import * as isCI from 'is-ci';
import { Workspaces } from '../../packages/nx/src/config/workspaces';
import { updateFile } from './file-utils';
import { exists, updateFile } from './file-utils';
import { logError, stripConsoleColors } from './log-utils';
import { existsSync } from 'fs-extra';

export interface RunCmdOpts {
silenceError?: boolean;
Expand Down Expand Up @@ -118,6 +119,7 @@ export function getPackageManagerCommand({
} {
const npmMajorVersion = getNpmMajorVersion();
const publishedVersion = getPublishedVersion();
const isPnpmWorkspace = existsSync(join(path, 'pnpm-workspace.yaml'));

return {
npm: {
Expand Down Expand Up @@ -158,8 +160,8 @@ export function getPackageManagerCommand({
runUninstalledPackage: 'pnpm dlx',
install: 'pnpm i',
ciInstall: 'pnpm install --frozen-lockfile',
addProd: `pnpm add`,
addDev: `pnpm add -D`,
addProd: isPnpmWorkspace ? 'pnpm add -w' : 'pnpm add',
addDev: isPnpmWorkspace ? 'pnpm add -Dw' : 'pnpm add -D',
list: 'npm ls --depth 10',
runLerna: `pnpm exec lerna`,
},
Expand Down
19 changes: 7 additions & 12 deletions e2e/utils/create-project-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function newProject({

if (!directoryExists(tmpBackupProjPath())) {
runCreateWorkspace(projScope, {
preset: 'empty',
preset: 'apps',
packageManager,
});

Expand Down Expand Up @@ -287,17 +287,12 @@ export function packageInstall(
} ${pkgsWithVersions}${isVerbose() ? ' --verbose' : ''}`;

try {
const install = execSync(
`${mode === 'dev' ? pm.addDev : pm.addProd} ${pkgsWithVersions}${
isVerbose() ? ' --verbose' : ''
}`,
{
cwd,
stdio: 'pipe',
env: process.env,
encoding: 'utf-8',
}
);
const install = execSync(command, {
cwd,
stdio: 'pipe',
env: process.env,
encoding: 'utf-8',
});

if (isVerbose()) {
output.log({
Expand Down
18 changes: 9 additions & 9 deletions e2e/workspace-create/src/create-nx-workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('create-nx-workspace', () => {
it('should be able to create an empty workspace built for apps', () => {
const wsName = uniq('apps');
runCreateWorkspace(wsName, {
preset: 'empty',
preset: 'apps',
packageManager,
});

Expand Down Expand Up @@ -273,7 +273,7 @@ describe('create-nx-workspace', () => {
it('should be able to create a workspace with a custom base branch and HEAD', () => {
const wsName = uniq('branch');
runCreateWorkspace(wsName, {
preset: 'empty',
preset: 'apps',
base: 'main',
packageManager,
});
Expand All @@ -282,7 +282,7 @@ describe('create-nx-workspace', () => {
it('should be able to create a workspace with custom commit information', () => {
const wsName = uniq('branch');
runCreateWorkspace(wsName, {
preset: 'empty',
preset: 'apps',
extraArgs:
'--commit.name="John Doe" --commit.email="[email protected]" --commit.message="Custom commit message!"',
packageManager,
Expand All @@ -307,8 +307,8 @@ describe('create-nx-workspace', () => {
process.env.SELECTED_PM = 'npm';

runCreateWorkspace(wsName, {
preset: 'empty',
packageManager,
preset: 'apps',
packageManager: 'npm',
});

checkFilesDoNotExist('yarn.lock');
Expand All @@ -320,7 +320,7 @@ describe('create-nx-workspace', () => {
it('should return error when ci workflow is selected but no cloud is set up', () => {
const wsName = uniq('github');
runCreateWorkspace(wsName, {
preset: 'empty',
preset: 'apps',
packageManager,
ci: 'circleci',
});
Expand All @@ -332,7 +332,7 @@ describe('create-nx-workspace', () => {
function setupProject(envPm: 'npm' | 'yarn' | 'pnpm') {
process.env.SELECTED_PM = envPm;
runCreateWorkspace(uniq('pm'), {
preset: 'empty',
preset: 'apps',
packageManager: envPm,
useDetectedPm: true,
});
Expand Down Expand Up @@ -379,7 +379,7 @@ describe('create-nx-workspace', () => {

describe('create-nx-workspace custom parent folder', () => {
const tmpDir = `${e2eCwd}/${uniq('with space')}`;
const wsName = uniq('empty');
const wsName = uniq('parent');
const packageManager = getSelectedPackageManager() || 'pnpm';

afterEach(() => cleanupProject({ cwd: `${tmpDir}/${wsName}` }));
Expand All @@ -388,7 +388,7 @@ describe('create-nx-workspace custom parent folder', () => {
mkdirSync(tmpDir, { recursive: true });

runCreateWorkspace(wsName, {
preset: 'empty',
preset: 'apps',
packageManager,
cwd: tmpDir,
});
Expand Down

0 comments on commit 7464280

Please sign in to comment.