Skip to content

Commit

Permalink
chore(core): remove dotenv from executors
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Aug 22, 2023
1 parent 34f4148 commit bd26deb
Show file tree
Hide file tree
Showing 25 changed files with 37 additions and 25 deletions.
37 changes: 37 additions & 0 deletions e2e/node/src/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,43 @@ describe('Node Applications', () => {
expect(additionalResult).toContain('Hello Additional World!');
}, 60000);

it('should be able to generate an empty application with variable in .env file', async () => {
const originalEnvPort = process.env.PORT;
const port = 3457;
process.env.PORT = `${port}`;
const nodeapp = uniq('nodeapp');

runCLI(
`generate @nx/node:app ${nodeapp} --linter=eslint --bundler=webpack --framework=none`
);
await setMaxWorkers();

updateFile('.env', `NX_FOOBAR="test foo bar"`);

updateFile(
`apps/${nodeapp}/src/main.ts`,
`console.log('foobar: ' + process.env['NX_FOOBAR']);`
);

await runCLIAsync(`build ${nodeapp}`);
checkFilesExist(`dist/apps/${nodeapp}/main.js`);

// check serving
const p = await runCommandUntil(
`serve ${nodeapp} --port=${port} --watch=false`,
(output) => {
process.stdout.write(output);
return output.includes(`foobar: test foo bar`);
}
);
try {
await promisifiedTreeKill(p.pid, 'SIGKILL');
await killPorts(port);
} finally {
process.env.port = originalEnvPort;
}
}, 60000);

it('should be able to generate an express application', async () => {
const nodeapp = uniq('nodeapp');
const originalEnvPort = process.env.PORT;
Expand Down
1 change: 0 additions & 1 deletion packages/cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"dependencies": {
"@phenomnomnominal/tsquery": "~5.0.1",
"detect-port": "^1.5.1",
"dotenv": "~16.3.1",
"semver": "7.5.3",
"tslib": "^2.3.0",
"@nx/devkit": "file:../devkit",
Expand Down
1 change: 0 additions & 1 deletion packages/cypress/src/executors/cypress/cypress.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
output,
} from '@nx/devkit';
import { getExecutorInformation } from 'nx/src/command-line/run/executor-utils';
import 'dotenv/config';
import { existsSync, readdirSync, unlinkSync, writeFileSync } from 'fs';
import { basename, dirname, join } from 'path';
import { getTempTailwindPath } from '../../utils/ct-helpers';
Expand Down
1 change: 0 additions & 1 deletion packages/esbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
},
"dependencies": {
"chalk": "^4.1.0",
"dotenv": "~16.3.1",
"fast-glob": "3.2.7",
"fs-extra": "^11.1.0",
"tslib": "^2.3.0",
Expand Down
1 change: 0 additions & 1 deletion packages/esbuild/src/executors/esbuild/esbuild.impl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dotenv/config';
import * as chalk from 'chalk';
import type { ExecutorContext } from '@nx/devkit';
import { cacheDir, joinPathFragments, logger, stripIndents } from '@nx/devkit';
Expand Down
1 change: 0 additions & 1 deletion packages/jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"@jest/test-result": "^29.4.1",
"@phenomnomnominal/tsquery": "~5.0.1",
"chalk": "^4.1.0",
"dotenv": "~16.3.1",
"identity-obj-proxy": "3.0.0",
"jest-config": "^29.4.1",
"jest-resolve": "^29.4.1",
Expand Down
1 change: 0 additions & 1 deletion packages/jest/src/executors/jest/jest.impl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dotenv/config';
import { runCLI } from 'jest';
import { readConfig, readConfigs } from 'jest-config';
import { utils as jestReporterUtils } from '@jest/reporters';
Expand Down
1 change: 0 additions & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"@svgr/webpack": "^8.0.1",
"chalk": "^4.1.0",
"copy-webpack-plugin": "^10.2.4",
"dotenv": "~16.3.1",
"fs-extra": "^11.1.0",
"ignore": "^5.0.4",
"semver": "7.5.3",
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/executors/build/build.impl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dotenv/config';
import {
ExecutorContext,
logger,
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/executors/export/export.impl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dotenv/config';
import {
ExecutorContext,
parseTargetString,
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/executors/server/custom-server.impl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dotenv/config';
import { ExecutorContext, parseTargetString, runExecutor } from '@nx/devkit';
import { join } from 'path';

Expand Down
1 change: 0 additions & 1 deletion packages/next/src/executors/server/server.impl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dotenv/config';
import {
ExecutorContext,
parseTargetString,
Expand Down
1 change: 0 additions & 1 deletion packages/plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
},
"dependencies": {
"@phenomnomnominal/tsquery": "~5.0.1",
"dotenv": "~16.3.1",
"fs-extra": "^11.1.0",
"tslib": "^2.3.0",
"@nx/devkit": "file:../devkit",
Expand Down
2 changes: 0 additions & 2 deletions packages/plugin/src/executors/e2e/e2e.impl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dotenv/config';

import type { ExecutorContext } from '@nx/devkit';

import {
Expand Down
1 change: 0 additions & 1 deletion packages/rollup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"autoprefixer": "^10.4.9",
"babel-plugin-transform-async-to-promises": "^0.8.15",
"chalk": "^4.1.0",
"dotenv": "~16.3.1",
"fast-glob": "^3.2.7",
"postcss": "^8.4.14",
"rollup": "^2.56.2",
Expand Down
1 change: 0 additions & 1 deletion packages/rollup/src/executors/rollup/rollup.impl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dotenv/config';
import * as ts from 'typescript';
import * as rollup from 'rollup';
import * as peerDepsExternal from 'rollup-plugin-peer-deps-external';
Expand Down
1 change: 0 additions & 1 deletion packages/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"migrations": "./migrations.json"
},
"dependencies": {
"dotenv": "~16.3.1",
"@phenomnomnominal/tsquery": "~5.0.1",
"semver": "7.5.3",
"tslib": "^2.3.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ExecutorContext, logger } from '@nx/devkit';
import * as build from '@storybook/core-server';
import { CLIOptions } from '@storybook/types';
import 'dotenv/config';
import {
pleaseUpgrade,
storybookConfigExistsCheck,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ExecutorContext, logger } from '@nx/devkit';
import * as build from '@storybook/core-server';
import 'dotenv/config';
import {
pleaseUpgrade,
storybookConfigExistsCheck,
Expand Down
1 change: 0 additions & 1 deletion packages/storybook/src/executors/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { joinPathFragments, logger } from '@nx/devkit';
import { findNodes } from '@nx/js';
import 'dotenv/config';
import { existsSync, readFileSync } from 'fs';
import { join } from 'path';
import { gte } from 'semver';
Expand Down
1 change: 0 additions & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"dependencies": {
"@phenomnomnominal/tsquery": "~5.0.1",
"@swc/helpers": "~0.5.0",
"dotenv": "~16.3.1",
"enquirer": "~2.3.6",
"@nx/devkit": "file:../devkit",
"@nx/js": "file:../js",
Expand Down
1 change: 0 additions & 1 deletion packages/vite/src/executors/build/build.impl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dotenv/config';
import {
ExecutorContext,
logger,
Expand Down
1 change: 0 additions & 1 deletion packages/vite/src/executors/dev-server/dev-server.impl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dotenv/config';
import { ExecutorContext } from '@nx/devkit';
import { createServer, InlineConfig, mergeConfig, ViteDevServer } from 'vite';

Expand Down
1 change: 0 additions & 1 deletion packages/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"copy-webpack-plugin": "^10.2.4",
"css-loader": "^6.4.0",
"css-minimizer-webpack-plugin": "^5.0.0",
"dotenv": "~16.3.1",
"fork-ts-checker-webpack-plugin": "7.2.13",
"ignore": "^5.0.4",
"less": "4.1.3",
Expand Down
1 change: 0 additions & 1 deletion packages/webpack/src/executors/webpack/webpack.impl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dotenv/config';
import { ExecutorContext, logger, stripIndents } from '@nx/devkit';
import { eachValueFrom } from '@nx/devkit/src/utils/rxjs-for-await';
import type { Configuration, Stats } from 'webpack';
Expand Down

0 comments on commit bd26deb

Please sign in to comment.