Skip to content

Commit

Permalink
fix(misc): do not prompt in non tty env
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Aug 10, 2023
1 parent ad16426 commit 1478d60
Show file tree
Hide file tree
Showing 18 changed files with 113 additions and 148 deletions.
14 changes: 6 additions & 8 deletions e2e/esbuild/src/esbuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('EsBuild Plugin', () => {

it('should setup and build projects using build', async () => {
const myPkg = uniq('my-pkg');
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild --no-interactive`);
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild`);
updateFile(`libs/${myPkg}/src/index.ts`, `console.log('Hello');\n`);
updateProjectConfig(myPkg, (json) => {
json.targets.build.options.assets = [`libs/${myPkg}/assets/*`];
Expand Down Expand Up @@ -113,10 +113,8 @@ describe('EsBuild Plugin', () => {
packageInstall('lodash', undefined, '~4.14.0', 'prod');
const parentLib = uniq('parent-lib');
const childLib = uniq('child-lib');
runCLI(
`generate @nx/js:lib ${parentLib} --bundler=esbuild --no-interactive`
);
runCLI(`generate @nx/js:lib ${childLib} --bundler=none --no-interactive`);
runCLI(`generate @nx/js:lib ${parentLib} --bundler=esbuild`);
runCLI(`generate @nx/js:lib ${childLib} --bundler=none`);
updateFile(
`libs/${parentLib}/src/index.ts`,
`
Expand Down Expand Up @@ -163,7 +161,7 @@ describe('EsBuild Plugin', () => {

it('should support non-bundle builds', () => {
const myPkg = uniq('my-pkg');
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild --no-interactive`);
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild`);
updateFile(`libs/${myPkg}/src/lib/${myPkg}.ts`, `console.log('Hello');\n`);
updateFile(`libs/${myPkg}/src/index.ts`, `import './lib/${myPkg}.cjs';\n`);

Expand All @@ -183,7 +181,7 @@ describe('EsBuild Plugin', () => {

it('should support additional entry points', () => {
const myPkg = uniq('my-pkg');
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild --no-interactive`);
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild`);
updateFile(`libs/${myPkg}/src/index.ts`, `console.log('main');\n`);
updateFile(`libs/${myPkg}/src/extra.ts`, `console.log('extra');\n`);
updateProjectConfig(myPkg, (json) => {
Expand All @@ -209,7 +207,7 @@ describe('EsBuild Plugin', () => {

it('should support external esbuild.config.js file', async () => {
const myPkg = uniq('my-pkg');
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild --no-interactive`);
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild`);
updateFile(
`libs/${myPkg}/esbuild.config.js`,
`console.log('custom config loaded');\nmodule.exports = {};\n`
Expand Down
8 changes: 2 additions & 6 deletions e2e/jest/src/jest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ describe('Jest', () => {

it('should set the NODE_ENV to `test`', async () => {
const mylib = uniq('mylib');
runCLI(
`generate @nx/js:lib ${mylib} --unitTestRunner=jest --no-interactive`
);
runCLI(`generate @nx/js:lib ${mylib} --unitTestRunner=jest`);

updateFile(
`libs/${mylib}/src/lib/${mylib}.spec.ts`,
Expand All @@ -122,9 +120,7 @@ describe('Jest', () => {

it('should support multiple `coverageReporters` through CLI', async () => {
const mylib = uniq('mylib');
runCLI(
`generate @nx/js:lib ${mylib} --unitTestRunner=jest --no-interactive`
);
runCLI(`generate @nx/js:lib ${mylib} --unitTestRunner=jest`);

updateFile(
`libs/${mylib}/src/lib/${mylib}.spec.ts`,
Expand Down
22 changes: 7 additions & 15 deletions e2e/js/src/js.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ export function ${lib}Wildcard() {
const libName = uniq('mylib');
const dirName = uniq('dir');

runCLI(
`generate @nx/js:lib ${libName} --directory ${dirName} --no-interactive`
);
runCLI(`generate @nx/js:lib ${libName} --directory ${dirName}`);

checkFilesExist(
`libs/${dirName}/${libName}/src/index.ts`,
Expand All @@ -121,12 +119,8 @@ export function ${lib}Wildcard() {
const consumerLib = uniq('consumer');
const producerLib = uniq('producer');

runCLI(
`generate @nx/js:lib ${consumerLib} --bundler=none --no-interactive`
);
runCLI(
`generate @nx/js:lib ${producerLib} --bundler=none --no-interactive`
);
runCLI(`generate @nx/js:lib ${consumerLib} --bundler=none`);
runCLI(`generate @nx/js:lib ${producerLib} --bundler=none`);

updateFile(
`libs/${producerLib}/src/lib/${producerLib}.ts`,
Expand Down Expand Up @@ -160,9 +154,7 @@ export function ${lib}Wildcard() {
it('should be able to add build to non-buildable projects', () => {
const nonBuildable = uniq('nonbuildable');

runCLI(
`generate @nx/js:lib ${nonBuildable} --bundler=none --no-interactive`
);
runCLI(`generate @nx/js:lib ${nonBuildable} --bundler=none`);
expect(() => runCLI(`build ${nonBuildable}`)).toThrow();
checkFilesDoNotExist(`dist/libs/${nonBuildable}/src/index.js`);

Expand Down Expand Up @@ -242,7 +234,7 @@ export function ${lib}Wildcard() {
it('should generate project with name and directory as provided when --nameDirectoryFormat=as-provided', async () => {
const lib1 = uniq('lib1');
runCLI(
`generate @nx/js:lib ${lib1} --directory=shared --bundler=tsc --name-directory-format=as-provided --no-interactive`
`generate @nx/js:lib ${lib1} --directory=shared --bundler=tsc --name-directory-format=as-provided`
);

// check files are generated without the layout directory ("libs/") and
Expand All @@ -265,12 +257,12 @@ export function ${lib}Wildcard() {
// assert scoped project names are not supported when --nameDirectoryFormat=derived
expect(() =>
runCLI(
`generate @nx/js:lib ${scopedLib} --bundler=tsc --name-directory-format=derived --no-interactive`
`generate @nx/js:lib ${scopedLib} --bundler=tsc --name-directory-format=derived`
)
).toThrow();

runCLI(
`generate @nx/js:lib ${scopedLib} --bundler=tsc --name-directory-format=as-provided --no-interactive`
`generate @nx/js:lib ${scopedLib} --bundler=tsc --name-directory-format=as-provided`
);

// check files are generated without the layout directory ("libs/") and
Expand Down
20 changes: 7 additions & 13 deletions e2e/linter/src/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Linter', () => {
beforeAll(() => {
projScope = newProject();
runCLI(`generate @nx/react:app ${myapp} --tags=validtag`);
runCLI(`generate @nx/js:lib ${mylib} --no-interactive`);
runCLI(`generate @nx/js:lib ${mylib}`);
});
afterAll(() => cleanupProject());

Expand Down Expand Up @@ -198,12 +198,8 @@ describe('Linter', () => {

runCLI(`generate @nx/react:app ${myapp2}`);
runCLI(`generate @nx/react:lib ${lazylib}`);
runCLI(
`generate @nx/js:lib ${invalidtaglib} --tags=invalidtag --no-interactive`
);
runCLI(
`generate @nx/js:lib ${validtaglib} --tags=validtag --no-interactive`
);
runCLI(`generate @nx/js:lib ${invalidtaglib} --tags=invalidtag`);
runCLI(`generate @nx/js:lib ${validtaglib} --tags=validtag`);

const eslint = readJson('.eslintrc.json');
eslint.overrides[0].rules[
Expand Down Expand Up @@ -276,9 +272,9 @@ describe('Linter', () => {
const libC = uniq('tslib-c');

beforeAll(() => {
runCLI(`generate @nx/js:lib ${libA} --no-interactive`);
runCLI(`generate @nx/js:lib ${libB} --no-interactive`);
runCLI(`generate @nx/js:lib ${libC} --no-interactive`);
runCLI(`generate @nx/js:lib ${libA}`);
runCLI(`generate @nx/js:lib ${libB}`);
runCLI(`generate @nx/js:lib ${libC}`);

/**
* create tslib-a structure
Expand Down Expand Up @@ -683,9 +679,7 @@ describe('Linter', () => {
expect(appEslint.overrides[1].extends).toBeDefined();
expect(e2eEslint.overrides[0].extends).toBeDefined();

runCLI(
`generate @nx/js:lib ${mylib} --unitTestRunner=jest --no-interactive`
);
runCLI(`generate @nx/js:lib ${mylib} --unitTestRunner=jest`);
verifySuccessfulMigratedSetup(myapp, mylib);

appEslint = readJson(`.eslintrc.json`);
Expand Down
2 changes: 1 addition & 1 deletion e2e/node/src/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ describe('Build Node apps', () => {
runCLI(`generate @nx/node:app ${nodeapp} --bundler=webpack`);

const jslib = uniq('jslib');
runCLI(`generate @nx/js:lib ${jslib} --bundler=tsc --no-interactive`);
runCLI(`generate @nx/js:lib ${jslib} --bundler=tsc`);

updateFile(
`apps/${nodeapp}/src/main.ts`,
Expand Down
4 changes: 2 additions & 2 deletions e2e/nx-misc/src/extras.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('Extra Nx Misc Tests', () => {
describe('Run Commands', () => {
const mylib = uniq('lib');
beforeAll(() => {
runCLI(`generate @nx/js:lib ${mylib} --no-interactive`);
runCLI(`generate @nx/js:lib ${mylib}`);
});

it('should not override environment variables already set when setting a custom env file path', async () => {
Expand Down Expand Up @@ -229,7 +229,7 @@ describe('Extra Nx Misc Tests', () => {

const folder = `dist/libs/${mylib}/some-folder`;

runCLI(`generate @nx/js:lib ${mylib} --no-interactive`);
runCLI(`generate @nx/js:lib ${mylib}`);

runCLI(
`generate @nx/workspace:run-commands build --command=echo --outputs=${folder}/ --project=${mylib}`
Expand Down
2 changes: 1 addition & 1 deletion e2e/nx-misc/src/misc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('Nx Commands', () => {

beforeAll(() => {
runCLI(`generate @nx/web:app ${myapp}`);
runCLI(`generate @nx/js:lib ${mylib} --no-interactive`);
runCLI(`generate @nx/js:lib ${mylib}`);
});

beforeEach(() => {
Expand Down
6 changes: 3 additions & 3 deletions e2e/nx-misc/src/watch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ describe('Nx Commands', () => {
let proj3 = uniq('proj3');
beforeAll(() => {
newProject();
runCLI(`generate @nx/js:lib ${proj1} --no-interactive`);
runCLI(`generate @nx/js:lib ${proj2} --no-interactive`);
runCLI(`generate @nx/js:lib ${proj3} --no-interactive`);
runCLI(`generate @nx/js:lib ${proj1}`);
runCLI(`generate @nx/js:lib ${proj2}`);
runCLI(`generate @nx/js:lib ${proj3}`);
});

afterAll(() => cleanupProject());
Expand Down
Loading

0 comments on commit 1478d60

Please sign in to comment.