nx/e2e/nx-init/src/nx-init-npm-repo.test.ts
Emily Xiong 7da6f85734
fix(core): remove strong-log-transformer (#28094)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes https://github.com/nrwl/nx/issues/26904
2024-09-26 15:51:53 -04:00

81 lines
1.8 KiB
TypeScript

import {
cleanupProject,
createNonNxProjectDirectory,
getPackageManagerCommand,
getPublishedVersion,
getSelectedPackageManager,
renameFile,
runCLI,
runCommand,
updateFile,
} from '@nx/e2e/utils';
describe('nx init (NPM repo - legacy)', () => {
const pmc = getPackageManagerCommand({
packageManager: getSelectedPackageManager(),
});
beforeAll(() => {
process.env.NX_ADD_PLUGINS = 'false';
});
afterAll(() => {
delete process.env.NX_ADD_PLUGINS;
});
it('should work in a regular npm repo', () => {
createNonNxProjectDirectory('regular-repo', false);
updateFile(
'package.json',
JSON.stringify({
name: 'package',
scripts: {
echo: 'echo 123',
},
})
);
runCommand(pmc.install);
const output = runCommand(
`${
pmc.runUninstalledPackage
} nx@${getPublishedVersion()} init --cacheable=echo --no-interactive`
);
expect(output).toContain('Run it again to replay the cached computation.');
expect(runCLI('echo')).toContain('123');
renameFile('nx.json', 'nx.json.old');
expect(runCLI('echo')).toContain('123');
cleanupProject();
});
it('should support compound scripts', () => {
createNonNxProjectDirectory('regular-repo', false);
updateFile(
'package.json',
JSON.stringify({
name: 'package',
scripts: {
compound: 'echo HELLO && echo COMPOUND',
},
})
);
runCommand(pmc.install);
runCommand(
`${
pmc.runUninstalledPackage
} nx@${getPublishedVersion()} init --cacheable=compound --no-interactive`
);
const output = runCommand('npm run compound TEST');
expect(output).toContain('HELLO');
expect(output).toContain('COMPOUND TEST');
expect(output).not.toContain('HELLO COMPOUND');
cleanupProject();
});
});